Compare commits

..

1 Commits

Author SHA1 Message Date
dependabot[bot]
132ad3faef chore(deps): bump actions/upload-artifact from 3 to 4
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-18 06:16:01 +00:00
56 changed files with 16 additions and 517 deletions

View File

@@ -97,7 +97,7 @@ jobs:
- name: Archive failed run logs
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: home-server-failure-logs-${{ inputs.suite }}-${{ matrix.db_type }}-${{ matrix.cache_type }}
retention-days: 5

View File

@@ -61,7 +61,7 @@ jobs:
- name: Archive failed run logs
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: self-hosted-failure-logs-${{ inputs.suite }}
retention-days: 5

View File

@@ -3,10 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.34.8](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.34.7...@standardnotes/analytics@2.34.8) (2023-12-26)
**Note:** Version bump only for package @standardnotes/analytics
## [2.34.7](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.34.6...@standardnotes/analytics@2.34.7) (2023-12-14)
**Note:** Version bump only for package @standardnotes/analytics

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/analytics",
"version": "2.34.8",
"version": "2.34.7",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,35 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.89.6](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.89.5...@standardnotes/api-gateway@1.89.6) (2023-12-26)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.89.5](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.89.4...@standardnotes/api-gateway@1.89.5) (2023-12-22)
### Bug Fixes
* logs severity ([0762ed1](https://github.com/standardnotes/server/commit/0762ed1127a5de295bd50c14afad31c7fb88a853))
## [1.89.4](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.89.3...@standardnotes/api-gateway@1.89.4) (2023-12-22)
### Bug Fixes
* case sensitive typo ([b1cb6a1](https://github.com/standardnotes/server/commit/b1cb6a1d21479b67d9826b55e1221a803e2f41a7))
## [1.89.3](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.89.2...@standardnotes/api-gateway@1.89.3) (2023-12-22)
### Bug Fixes
* add more readonly access debug logs ([54091f2](https://github.com/standardnotes/server/commit/54091f23da33a5d1df2ecffdfa559e3fa4c562f6))
* **api-gateway:** add debug log for operating on readonly access ([e4a8324](https://github.com/standardnotes/server/commit/e4a8324db26454a7587f37096653ad9565541295))
## [1.89.2](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.89.1...@standardnotes/api-gateway@1.89.2) (2023-12-21)
### Bug Fixes
* **api-gateway:** missing readonly access for demo when utilizing grpc workflow ([#1005](https://github.com/standardnotes/server/issues/1005)) ([e551a36](https://github.com/standardnotes/server/commit/e551a364f63e28c9329dbce492488b9f112e3473))
## [1.89.1](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.89.0...@standardnotes/api-gateway@1.89.1) (2023-12-14)
**Note:** Version bump only for package @standardnotes/api-gateway

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.89.6",
"version": "1.89.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -74,13 +74,6 @@ export abstract class AuthMiddleware extends BaseMiddleware {
response.locals.session = decodedToken.session
response.locals.roles = decodedToken.roles
response.locals.sharedVaultOwnerContext = decodedToken.shared_vault_owner_context
response.locals.readOnlyAccess = decodedToken.session?.readonly_access ?? false
if (response.locals.readOnlyAccess) {
this.logger.debug('User operates on read-only access', {
codeTag: 'AuthMiddleware',
userId: response.locals.user.uuid,
})
}
response.locals.belongsToSharedVaults = decodedToken.belongs_to_shared_vaults ?? []
} catch (error) {
let detailedErrorMessage = (error as Error).message

View File

@@ -27,13 +27,7 @@ export class GRPCSyncingServerServiceProxy {
const metadata = new Metadata()
metadata.set('x-user-uuid', response.locals.user.uuid)
metadata.set('x-snjs-version', request.headers['x-snjs-version'] as string)
metadata.set('x-read-only-access', response.locals.readOnlyAccess ? 'true' : 'false')
if (response.locals.readOnlyAccess) {
this.logger.debug('Syncing with read-only access', {
codeTag: 'GRPCSyncingServerServiceProxy',
userId: response.locals.user.uuid,
})
}
metadata.set('x-read-only-access', response.locals.readonlyAccess ? 'true' : 'false')
if (response.locals.session) {
metadata.set('x-session-uuid', response.locals.session.uuid)
}

View File

@@ -3,25 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.177.3](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.177.2...@standardnotes/auth-server@1.177.3) (2023-12-26)
### Bug Fixes
* stop revisions propagation ([#1008](https://github.com/standardnotes/server/issues/1008)) ([7962b24](https://github.com/standardnotes/server/commit/7962b245b51703ff7d33728dee117b2074f2692a))
## [1.177.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.177.1...@standardnotes/auth-server@1.177.2) (2023-12-22)
### Bug Fixes
* logs severity ([0762ed1](https://github.com/standardnotes/server/commit/0762ed1127a5de295bd50c14afad31c7fb88a853))
## [1.177.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.177.0...@standardnotes/auth-server@1.177.1) (2023-12-22)
### Bug Fixes
* **auth:** specs issue ([0342cdc](https://github.com/standardnotes/server/commit/0342cdcfc06bd3bb0192a428c30c5af15e5eb0d7))
* case sensitive typo ([b1cb6a1](https://github.com/standardnotes/server/commit/b1cb6a1d21479b67d9826b55e1221a803e2f41a7))
# [1.177.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.176.5...@standardnotes/auth-server@1.177.0) (2023-12-14)
### Features

View File

@@ -1,71 +0,0 @@
import 'reflect-metadata'
import { Logger } from 'winston'
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
import TYPES from '../src/Bootstrap/Types'
import { Env } from '../src/Bootstrap/Env'
import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
import { DomainEventFactoryInterface } from '../src/Domain/Event/DomainEventFactoryInterface'
import { UserSubscriptionRepositoryInterface } from '../src/Domain/Subscription/UserSubscriptionRepositoryInterface'
import { SubscriptionPlanName } from '@standardnotes/domain-core'
const requestCleanup = async (
userSubscriptionRepository: UserSubscriptionRepositoryInterface,
domainEventFactory: DomainEventFactoryInterface,
domainEventPublisher: DomainEventPublisherInterface,
): Promise<void> => {
const proSubscriptionPlan = SubscriptionPlanName.create(SubscriptionPlanName.NAMES.ProPlan).getValue()
const plusSubscriptionPlan = SubscriptionPlanName.create(SubscriptionPlanName.NAMES.PlusPlan).getValue()
const totalSubscriptions = await userSubscriptionRepository.countByPlanName([
proSubscriptionPlan,
plusSubscriptionPlan,
])
const limitPerPage = 100
const numberOfPages = Math.ceil(totalSubscriptions / limitPerPage)
for (let i = 0; i < numberOfPages; i++) {
const subscriptions = await userSubscriptionRepository.findByPlanName(
[proSubscriptionPlan, plusSubscriptionPlan],
i * limitPerPage,
limitPerPage,
)
for (const subscription of subscriptions) {
await domainEventPublisher.publish(
domainEventFactory.createRevisionsCleanupRequestedEvent({
userUuid: subscription.userUuid,
}),
)
}
}
}
const container = new ContainerConfigLoader('worker')
void container.load().then((container) => {
const env: Env = new Env()
env.load()
const logger: Logger = container.get(TYPES.Auth_Logger)
logger.info('Starting revisions cleanup triggering...')
const domainEventFactory = container.get<DomainEventFactoryInterface>(TYPES.Auth_DomainEventFactory)
const domainEventPublisher = container.get<DomainEventPublisherInterface>(TYPES.Auth_DomainEventPublisher)
const userSubscriptionRepository = container.get<UserSubscriptionRepositoryInterface>(
TYPES.Auth_UserSubscriptionRepository,
)
Promise.resolve(requestCleanup(userSubscriptionRepository, domainEventFactory, domainEventPublisher))
.then(() => {
logger.info('Finished revisions cleanup triggering')
process.exit(0)
})
.catch((error) => {
logger.error(`Failed to trigger revisions cleanup: ${(error as Error).message}`)
process.exit(1)
})
})

View File

@@ -1,11 +0,0 @@
'use strict'
const path = require('path')
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/revisions_cleanup.js')))
Object.defineProperty(exports, '__esModule', { value: true })
exports.default = index

View File

@@ -44,10 +44,6 @@ case "$COMMAND" in
exec node docker/entrypoint-delete-accounts.js $FILE_NAME $MODE
;;
'revisions-cleanup' )
exec node docker/entrypoint-revisions-cleanup.js
;;
* )
echo "[Docker] Unknown command"
;;

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.177.3",
"version": "1.177.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -27,7 +27,6 @@ describe('AuthenticationMethodResolver', () => {
beforeEach(() => {
logger = {} as jest.Mocked<Logger>
logger.debug = jest.fn()
logger.info = jest.fn()
user = {} as jest.Mocked<User>

View File

@@ -36,10 +36,6 @@ export class AuthenticationMethodResolver implements AuthenticationMethodResolve
}
const userUuid = userUuidOrError.getValue()
this.logger.debug('User utilizing JWT authentication method.', {
userId: userUuid.value,
})
return {
type: 'jwt',
user: await this.userRepository.findOneByUuid(userUuid),

View File

@@ -22,7 +22,6 @@ import {
SessionRefreshedEvent,
AccountDeletionVerificationRequestedEvent,
FileQuotaRecalculationRequestedEvent,
RevisionsCleanupRequestedEvent,
} from '@standardnotes/domain-events'
import { Predicate, PredicateVerificationResult } from '@standardnotes/predicates'
import { TimerInterface } from '@standardnotes/time'
@@ -36,21 +35,6 @@ import { KeyParamsData } from '@standardnotes/responses'
export class DomainEventFactory implements DomainEventFactoryInterface {
constructor(@inject(TYPES.Auth_Timer) private timer: TimerInterface) {}
createRevisionsCleanupRequestedEvent(dto: { userUuid: string }): RevisionsCleanupRequestedEvent {
return {
type: 'REVISIONS_CLEANUP_REQUESTED',
createdAt: this.timer.getUTCDate(),
meta: {
correlation: {
userIdentifier: dto.userUuid,
userIdentifierType: 'uuid',
},
origin: DomainEventService.Auth,
},
payload: dto,
}
}
createFileQuotaRecalculationRequestedEvent(dto: { userUuid: string }): FileQuotaRecalculationRequestedEvent {
return {
type: 'FILE_QUOTA_RECALCULATION_REQUESTED',

View File

@@ -20,13 +20,11 @@ import {
SessionRefreshedEvent,
AccountDeletionVerificationRequestedEvent,
FileQuotaRecalculationRequestedEvent,
RevisionsCleanupRequestedEvent,
} from '@standardnotes/domain-events'
import { InviteeIdentifierType } from '../SharedSubscription/InviteeIdentifierType'
import { KeyParamsData } from '@standardnotes/responses'
export interface DomainEventFactoryInterface {
createRevisionsCleanupRequestedEvent(dto: { userUuid: string }): RevisionsCleanupRequestedEvent
createFileQuotaRecalculationRequestedEvent(dto: { userUuid: string }): FileQuotaRecalculationRequestedEvent
createWebSocketMessageRequestedEvent(dto: { userUuid: string; message: JSONString }): WebSocketMessageRequestedEvent
createEmailRequestedEvent(dto: {

View File

@@ -1,4 +1,3 @@
import { SubscriptionPlanName } from '@standardnotes/domain-core'
import { UserSubscription } from './UserSubscription'
import { UserSubscriptionType } from './UserSubscriptionType'
@@ -8,8 +7,6 @@ export interface UserSubscriptionRepositoryInterface {
findOneByUserUuid(userUuid: string): Promise<UserSubscription | null>
findOneByUserUuidAndType(userUuid: string, type: UserSubscriptionType): Promise<UserSubscription | null>
findByUserUuid(userUuid: string): Promise<UserSubscription[]>
countByPlanName(planNames: SubscriptionPlanName[]): Promise<number>
findByPlanName(planNames: SubscriptionPlanName[], offset: number, limit: number): Promise<UserSubscription[]>
findOneByUserUuidAndSubscriptionId(userUuid: string, subscriptionId: number): Promise<UserSubscription | null>
findBySubscriptionIdAndType(subscriptionId: number, type: UserSubscriptionType): Promise<UserSubscription[]>
findBySubscriptionId(subscriptionId: number): Promise<UserSubscription[]>

View File

@@ -6,7 +6,6 @@ import TYPES from '../../Bootstrap/Types'
import { UserSubscription } from '../../Domain/Subscription/UserSubscription'
import { UserSubscriptionRepositoryInterface } from '../../Domain/Subscription/UserSubscriptionRepositoryInterface'
import { UserSubscriptionType } from '../../Domain/Subscription/UserSubscriptionType'
import { SubscriptionPlanName } from '@standardnotes/domain-core'
@injectable()
export class TypeORMUserSubscriptionRepository implements UserSubscriptionRepositoryInterface {
@@ -16,27 +15,6 @@ export class TypeORMUserSubscriptionRepository implements UserSubscriptionReposi
@inject(TYPES.Auth_Timer) private timer: TimerInterface,
) {}
async countByPlanName(planNames: SubscriptionPlanName[]): Promise<number> {
return await this.ormRepository
.createQueryBuilder()
.where('plan_name IN (:...planNames)', {
planNames: planNames.map((planName) => planName.value),
})
.getCount()
}
async findByPlanName(planNames: SubscriptionPlanName[], offset: number, limit: number): Promise<UserSubscription[]> {
return await this.ormRepository
.createQueryBuilder()
.where('plan_name IN (:...planNames)', {
planNames: planNames.map((planName) => planName.value),
})
.orderBy('created_at', 'ASC')
.skip(offset)
.take(limit)
.getMany()
}
async countActiveSubscriptions(): Promise<number> {
return await this.ormRepository
.createQueryBuilder()

View File

@@ -3,10 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.7](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.22.6...@standardnotes/domain-events-infra@1.22.7) (2023-12-26)
**Note:** Version bump only for package @standardnotes/domain-events-infra
## [1.22.6](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.22.5...@standardnotes/domain-events-infra@1.22.6) (2023-12-14)
**Note:** Version bump only for package @standardnotes/domain-events-infra

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-events-infra",
"version": "1.22.7",
"version": "1.22.6",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,12 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.139.1](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.139.0...@standardnotes/domain-events@2.139.1) (2023-12-26)
### Bug Fixes
* stop revisions propagation ([#1008](https://github.com/standardnotes/server/issues/1008)) ([7962b24](https://github.com/standardnotes/server/commit/7962b245b51703ff7d33728dee117b2074f2692a))
# [2.139.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.138.2...@standardnotes/domain-events@2.139.0) (2023-12-14)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-events",
"version": "2.139.1",
"version": "2.139.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -1,7 +0,0 @@
import { DomainEventInterface } from './DomainEventInterface'
import { ItemDeletedEventPayload } from './ItemDeletedEventPayload'
export interface ItemDeletedEvent extends DomainEventInterface {
type: 'ITEM_DELETED'
payload: ItemDeletedEventPayload
}

View File

@@ -1,4 +0,0 @@
export interface ItemDeletedEventPayload {
userUuid: string
itemUuid: string
}

View File

@@ -1,7 +0,0 @@
import { DomainEventInterface } from './DomainEventInterface'
import { RevisionsCleanupRequestedEventPayload } from './RevisionsCleanupRequestedEventPayload'
export interface RevisionsCleanupRequestedEvent extends DomainEventInterface {
type: 'REVISIONS_CLEANUP_REQUESTED'
payload: RevisionsCleanupRequestedEventPayload
}

View File

@@ -1,3 +0,0 @@
export interface RevisionsCleanupRequestedEventPayload {
userUuid: string
}

View File

@@ -40,8 +40,6 @@ export * from './Event/FileUploadedEvent'
export * from './Event/FileUploadedEventPayload'
export * from './Event/ItemDumpedEvent'
export * from './Event/ItemDumpedEventPayload'
export * from './Event/ItemDeletedEvent'
export * from './Event/ItemDeletedEventPayload'
export * from './Event/ItemRemovedFromSharedVaultEvent'
export * from './Event/ItemRemovedFromSharedVaultEventPayload'
export * from './Event/ItemRevisionCreationRequestedEvent'
@@ -72,8 +70,6 @@ export * from './Event/PredicateVerifiedEvent'
export * from './Event/PredicateVerifiedEventPayload'
export * from './Event/RefundProcessedEvent'
export * from './Event/RefundProcessedEventPayload'
export * from './Event/RevisionsCleanupRequestedEvent'
export * from './Event/RevisionsCleanupRequestedEventPayload'
export * from './Event/RevisionsCopyRequestedEvent'
export * from './Event/RevisionsCopyRequestedEventPayload'
export * from './Event/SessionCreatedEvent'

View File

@@ -3,10 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.37.2](https://github.com/standardnotes/server/compare/@standardnotes/files-server@1.37.1...@standardnotes/files-server@1.37.2) (2023-12-26)
**Note:** Version bump only for package @standardnotes/files-server
## [1.37.1](https://github.com/standardnotes/server/compare/@standardnotes/files-server@1.37.0...@standardnotes/files-server@1.37.1) (2023-12-14)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/files-server",
"version": "1.37.2",
"version": "1.37.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,26 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.27](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.26...@standardnotes/home-server@1.22.27) (2023-12-26)
**Note:** Version bump only for package @standardnotes/home-server
## [1.22.26](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.25...@standardnotes/home-server@1.22.26) (2023-12-22)
**Note:** Version bump only for package @standardnotes/home-server
## [1.22.25](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.24...@standardnotes/home-server@1.22.25) (2023-12-22)
**Note:** Version bump only for package @standardnotes/home-server
## [1.22.24](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.23...@standardnotes/home-server@1.22.24) (2023-12-22)
**Note:** Version bump only for package @standardnotes/home-server
## [1.22.23](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.22...@standardnotes/home-server@1.22.23) (2023-12-21)
**Note:** Version bump only for package @standardnotes/home-server
## [1.22.22](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.21...@standardnotes/home-server@1.22.22) (2023-12-14)
**Note:** Version bump only for package @standardnotes/home-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/home-server",
"version": "1.22.27",
"version": "1.22.22",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,12 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.51.8](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.51.7...@standardnotes/revisions-server@1.51.8) (2023-12-26)
### Bug Fixes
* stop revisions propagation ([#1008](https://github.com/standardnotes/server/issues/1008)) ([7962b24](https://github.com/standardnotes/server/commit/7962b245b51703ff7d33728dee117b2074f2692a))
## [1.51.7](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.51.6...@standardnotes/revisions-server@1.51.7) (2023-12-14)
**Note:** Version bump only for package @standardnotes/revisions-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/revisions-server",
"version": "1.51.8",
"version": "1.51.7",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -52,8 +52,6 @@ import { RemoveRevisionsFromSharedVault } from '../Domain/UseCase/RemoveRevision
import { ItemRemovedFromSharedVaultEventHandler } from '../Domain/Handler/ItemRemovedFromSharedVaultEventHandler'
import { SharedVaultRemovedEventHandler } from '../Domain/Handler/SharedVaultRemovedEventHandler'
import { CreateRevisionFromDump } from '../Domain/UseCase/CreateRevisionFromDump/CreateRevisionFromDump'
import { DeleteRevisions } from '../Domain/UseCase/DeleteRevisions/DeleteRevisions'
import { ItemDeletedEventHandler } from '../Domain/Handler/ItemDeletedEventHandler'
export class ContainerConfigLoader {
constructor(private mode: 'server' | 'worker' = 'server') {}
@@ -228,11 +226,6 @@ export class ContainerConfigLoader {
.toConstantValue(
new DeleteRevision(container.get<RevisionRepositoryInterface>(TYPES.Revisions_SQLRevisionRepository)),
)
container
.bind<DeleteRevisions>(TYPES.Revisions_DeleteRevisions)
.toConstantValue(
new DeleteRevisions(container.get<RevisionRepositoryInterface>(TYPES.Revisions_SQLRevisionRepository)),
)
container
.bind<CopyRevisions>(TYPES.Revisions_CopyRevisions)
.toConstantValue(
@@ -318,14 +311,6 @@ export class ContainerConfigLoader {
container.get<winston.Logger>(TYPES.Revisions_Logger),
),
)
container
.bind<ItemDeletedEventHandler>(TYPES.Revisions_ItemDeletedEventHandler)
.toConstantValue(
new ItemDeletedEventHandler(
container.get<DeleteRevisions>(TYPES.Revisions_DeleteRevisions),
container.get<winston.Logger>(TYPES.Revisions_Logger),
),
)
const eventHandlers: Map<string, DomainEventHandlerInterface> = new Map([
['ITEM_DUMPED', container.get(TYPES.Revisions_ItemDumpedEventHandler)],
@@ -333,7 +318,6 @@ export class ContainerConfigLoader {
['REVISIONS_COPY_REQUESTED', container.get(TYPES.Revisions_RevisionsCopyRequestedEventHandler)],
['ITEM_REMOVED_FROM_SHARED_VAULT', container.get(TYPES.Revisions_ItemRemovedFromSharedVaultEventHandler)],
['SHARED_VAULT_REMOVED', container.get(TYPES.Revisions_SharedVaultRemovedEventHandler)],
['ITEM_DELETED', container.get(TYPES.Revisions_ItemDeletedEventHandler)],
])
if (isConfiguredForHomeServer) {

View File

@@ -33,7 +33,6 @@ const TYPES = {
Revisions_GetRevisionsMetada: Symbol.for('Revisions_GetRevisionsMetada'),
Revisions_GetRevision: Symbol.for('Revisions_GetRevision'),
Revisions_DeleteRevision: Symbol.for('Revisions_DeleteRevision'),
Revisions_DeleteRevisions: Symbol.for('Revisions_DeleteRevisions'),
Revisions_CopyRevisions: Symbol.for('Revisions_CopyRevisions'),
Revisions_GetRequiredRoleToViewRevision: Symbol.for('Revisions_GetRequiredRoleToViewRevision'),
Revisions_RemoveRevisionsFromSharedVault: Symbol.for('Revisions_RemoveRevisionsFromSharedVault'),
@@ -48,7 +47,6 @@ const TYPES = {
Revisions_RevisionsCopyRequestedEventHandler: Symbol.for('Revisions_RevisionsCopyRequestedEventHandler'),
Revisions_ItemRemovedFromSharedVaultEventHandler: Symbol.for('Revisions_ItemRemovedFromSharedVaultEventHandler'),
Revisions_SharedVaultRemovedEventHandler: Symbol.for('Revisions_SharedVaultRemovedEventHandler'),
Revisions_ItemDeletedEventHandler: Symbol.for('Revisions_ItemDeletedEventHandler'),
// Services
Revisions_CrossServiceTokenDecoder: Symbol.for('Revisions_CrossServiceTokenDecoder'),
Revisions_DomainEventSubscriber: Symbol.for('Revisions_DomainEventSubscriber'),

View File

@@ -1,21 +0,0 @@
import { DomainEventHandlerInterface, ItemDeletedEvent } from '@standardnotes/domain-events'
import { Logger } from 'winston'
import { DeleteRevisions } from '../UseCase/DeleteRevisions/DeleteRevisions'
export class ItemDeletedEventHandler implements DomainEventHandlerInterface {
constructor(
private deleteRevisions: DeleteRevisions,
private logger: Logger,
) {}
async handle(event: ItemDeletedEvent): Promise<void> {
const result = await this.deleteRevisions.execute({ itemUuid: event.payload.itemUuid })
if (result.isFailed()) {
this.logger.error(`Could not delete revisions for item ${event.payload.itemUuid}: ${result.getError()}`, {
userId: event.payload.userUuid,
})
}
}
}

View File

@@ -6,7 +6,6 @@ import { RevisionMetadata } from './RevisionMetadata'
export interface RevisionRepositoryInterface {
countByUserUuid(userUuid: Uuid): Promise<number>
removeByUserUuid(userUuid: Uuid): Promise<void>
removeByItemUuid(itemUuid: Uuid): Promise<void>
removeOneByUuid(revisionUuid: Uuid, userUuid: Uuid): Promise<void>
findOneByUuid(revisionUuid: Uuid, userUuid: Uuid, sharedVaultUuids: Uuid[]): Promise<Revision | null>
findByItemUuid(itemUuid: Uuid): Promise<Array<Revision>>

View File

@@ -1,32 +0,0 @@
import { RevisionRepositoryInterface } from '../../Revision/RevisionRepositoryInterface'
import { DeleteRevisions } from './DeleteRevisions'
describe('DeleteRevisions', () => {
let revisionRepository: RevisionRepositoryInterface
const createUseCase = () => new DeleteRevisions(revisionRepository)
beforeEach(() => {
revisionRepository = {} as jest.Mocked<RevisionRepositoryInterface>
revisionRepository.removeByItemUuid = jest.fn()
})
it('should remove revisions by item uuid', async () => {
const useCase = createUseCase()
const itemUuid = '00000000-0000-0000-0000-000000000000'
const result = await useCase.execute({ itemUuid })
expect(result.isFailed()).toBe(false)
expect(revisionRepository.removeByItemUuid).toHaveBeenCalled()
})
it('should return failed result if item uuid is invalid', async () => {
const useCase = createUseCase()
const itemUuid = 'invalid'
const result = await useCase.execute({ itemUuid })
expect(result.isFailed()).toBe(true)
})
})

View File

@@ -1,19 +0,0 @@
import { Result, UseCaseInterface, Uuid } from '@standardnotes/domain-core'
import { RevisionRepositoryInterface } from '../../Revision/RevisionRepositoryInterface'
import { DeleteRevisionsDTO } from './DeleteRevisionsDTO'
export class DeleteRevisions implements UseCaseInterface<void> {
constructor(private revisionRepository: RevisionRepositoryInterface) {}
async execute(dto: DeleteRevisionsDTO): Promise<Result<void>> {
const itemUuidOrError = Uuid.create(dto.itemUuid)
if (itemUuidOrError.isFailed()) {
return Result.fail(`Could not delete revisions: ${itemUuidOrError.getError()}`)
}
const itemUuid = itemUuidOrError.getValue()
await this.revisionRepository.removeByItemUuid(itemUuid)
return Result.ok()
}
}

View File

@@ -1,3 +0,0 @@
export interface DeleteRevisionsDTO {
itemUuid: string
}

View File

@@ -15,15 +15,6 @@ export class SQLRevisionRepository implements RevisionRepositoryInterface {
protected logger: Logger,
) {}
async removeByItemUuid(itemUuid: Uuid): Promise<void> {
await this.ormRepository
.createQueryBuilder()
.delete()
.from('revisions_revisions')
.where('item_uuid = :itemUuid', { itemUuid: itemUuid.value })
.execute()
}
async removeByUserUuid(userUuid: Uuid): Promise<void> {
await this.ormRepository
.createQueryBuilder()

View File

@@ -3,10 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.27.13](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.27.12...@standardnotes/scheduler-server@1.27.13) (2023-12-26)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.27.12](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.27.11...@standardnotes/scheduler-server@1.27.12) (2023-12-14)
**Note:** Version bump only for package @standardnotes/scheduler-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/scheduler-server",
"version": "1.27.13",
"version": "1.27.12",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,24 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.129.4](https://github.com/standardnotes/server/compare/@standardnotes/syncing-server@1.129.3...@standardnotes/syncing-server@1.129.4) (2023-12-26)
### Bug Fixes
* stop revisions propagation ([#1008](https://github.com/standardnotes/server/issues/1008)) ([7962b24](https://github.com/standardnotes/server/commit/7962b245b51703ff7d33728dee117b2074f2692a))
## [1.129.3](https://github.com/standardnotes/server/compare/@standardnotes/syncing-server@1.129.2...@standardnotes/syncing-server@1.129.3) (2023-12-22)
### Bug Fixes
* logs severity ([0762ed1](https://github.com/standardnotes/server/commit/0762ed1127a5de295bd50c14afad31c7fb88a853))
## [1.129.2](https://github.com/standardnotes/server/compare/@standardnotes/syncing-server@1.129.1...@standardnotes/syncing-server@1.129.2) (2023-12-22)
### Bug Fixes
* add more readonly access debug logs ([54091f2](https://github.com/standardnotes/server/commit/54091f23da33a5d1df2ecffdfa559e3fa4c562f6))
## [1.129.1](https://github.com/standardnotes/server/compare/@standardnotes/syncing-server@1.129.0...@standardnotes/syncing-server@1.129.1) (2023-12-14)
**Note:** Version bump only for package @standardnotes/syncing-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.129.4",
"version": "1.129.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -162,7 +162,6 @@ import { SyncResponse } from '@standardnotes/grpc'
import { SyncResponseGRPCMapper } from '../Mapping/gRPC/SyncResponseGRPCMapper'
import { AccountDeletionVerificationRequestedEventHandler } from '../Domain/Handler/AccountDeletionVerificationRequestedEventHandler'
import { SendEventToClients } from '../Domain/UseCase/Syncing/SendEventToClients/SendEventToClients'
import { RevisionsCleanupRequestedEventHandler } from '../Domain/Handler/RevisionsCleanupRequestedEventHandler'
export class ContainerConfigLoader {
private readonly DEFAULT_CONTENT_SIZE_TRANSFER_LIMIT = 10_000_000
@@ -981,16 +980,6 @@ export class ContainerConfigLoader {
container.get<Logger>(TYPES.Sync_Logger),
),
)
container
.bind<RevisionsCleanupRequestedEventHandler>(TYPES.Sync_RevisionsCleanupRequestedEventHandler)
.toConstantValue(
new RevisionsCleanupRequestedEventHandler(
container.get<ItemRepositoryInterface>(TYPES.Sync_SQLItemRepository),
container.get<DomainEventFactoryInterface>(TYPES.Sync_DomainEventFactory),
container.get<DomainEventPublisherInterface>(TYPES.Sync_DomainEventPublisher),
container.get<Logger>(TYPES.Sync_Logger),
),
)
// Services
container.bind<ContentDecoderInterface>(TYPES.Sync_ContentDecoder).toDynamicValue(() => new ContentDecoder())
@@ -1019,7 +1008,6 @@ export class ContainerConfigLoader {
'SHARED_VAULT_REMOVED',
container.get<SharedVaultRemovedEventHandler>(TYPES.Sync_SharedVaultRemovedEventHandler),
],
['REVISIONS_CLEANUP_REQUESTED', container.get(TYPES.Sync_RevisionsCleanupRequestedEventHandler)],
])
if (!isConfiguredForHomeServer) {
container

View File

@@ -97,7 +97,6 @@ const TYPES = {
Sync_SharedVaultFileUploadedEventHandler: Symbol.for('Sync_SharedVaultFileUploadedEventHandler'),
Sync_SharedVaultFileMovedEventHandler: Symbol.for('Sync_SharedVaultFileMovedEventHandler'),
Sync_SharedVaultRemovedEventHandler: Symbol.for('Sync_SharedVaultRemovedEventHandler'),
Sync_RevisionsCleanupRequestedEventHandler: Symbol.for('Sync_RevisionsCleanupRequestedEventHandler'),
// Services
Sync_ContentDecoder: Symbol.for('Sync_ContentDecoder'),
Sync_DomainEventPublisher: Symbol.for('Sync_DomainEventPublisher'),

View File

@@ -4,7 +4,6 @@ import {
DomainEventService,
DuplicateItemSyncedEvent,
EmailRequestedEvent,
ItemDeletedEvent,
ItemDumpedEvent,
ItemRemovedFromSharedVaultEvent,
ItemRevisionCreationRequestedEvent,
@@ -317,21 +316,6 @@ export class DomainEventFactory implements DomainEventFactoryInterface {
}
}
createItemDeletedEvent(dto: { itemUuid: string; userUuid: string }): ItemDeletedEvent {
return {
type: 'ITEM_DELETED',
createdAt: this.timer.getUTCDate(),
meta: {
correlation: {
userIdentifier: dto.userUuid,
userIdentifierType: 'uuid',
},
origin: DomainEventService.SyncingServer,
},
payload: dto,
}
}
createEmailRequestedEvent(dto: {
userEmail: string
messageIdentifier: string

View File

@@ -2,7 +2,6 @@ import {
AccountDeletionVerificationPassedEvent,
DuplicateItemSyncedEvent,
EmailRequestedEvent,
ItemDeletedEvent,
ItemDumpedEvent,
ItemRemovedFromSharedVaultEvent,
ItemRevisionCreationRequestedEvent,
@@ -78,7 +77,6 @@ export interface DomainEventFactoryInterface {
userUuid?: string
}): EmailRequestedEvent
createDuplicateItemSyncedEvent(dto: { itemUuid: string; userUuid: string }): DuplicateItemSyncedEvent
createItemDeletedEvent(dto: { itemUuid: string; userUuid: string }): ItemDeletedEvent
createItemRevisionCreationRequested(dto: { itemUuid: string; userUuid: string }): ItemRevisionCreationRequestedEvent
createItemDumpedEvent(dto: { fileDumpPath: string; userUuid: string }): ItemDumpedEvent
createRevisionsCopyRequestedEvent(

View File

@@ -1,56 +0,0 @@
import {
RevisionsCleanupRequestedEvent,
DomainEventHandlerInterface,
DomainEventPublisherInterface,
} from '@standardnotes/domain-events'
import { Logger } from 'winston'
import { ItemRepositoryInterface } from '../Item/ItemRepositoryInterface'
import { DomainEventFactoryInterface } from '../Event/DomainEventFactoryInterface'
export class RevisionsCleanupRequestedEventHandler implements DomainEventHandlerInterface {
constructor(
private itemRepository: ItemRepositoryInterface,
private domainEventFactory: DomainEventFactoryInterface,
private domainEventPublisher: DomainEventPublisherInterface,
private logger: Logger,
) {}
async handle(event: RevisionsCleanupRequestedEvent): Promise<void> {
const totalDeletedItems = await this.itemRepository.countAll({
userUuid: event.payload.userUuid,
deleted: true,
})
this.logger.info(`Found ${totalDeletedItems} deleted items`, {
userId: event.payload.userUuid,
})
const limitPerPage = 100
const numberOfPages = Math.ceil(totalDeletedItems / limitPerPage)
for (let i = 0; i < numberOfPages; i++) {
const items = await this.itemRepository.findAll({
userUuid: event.payload.userUuid,
deleted: true,
offset: i * limitPerPage,
limit: limitPerPage,
sortOrder: 'ASC',
sortBy: 'created_at_timestamp',
})
for (const item of items) {
await this.domainEventPublisher.publish(
this.domainEventFactory.createItemDeletedEvent({
itemUuid: item.id.toString(),
userUuid: item.props.userUuid.value,
}),
)
}
}
this.logger.info(`Finished processing ${totalDeletedItems} deleted items`, {
userId: event.payload.userUuid,
})
}
}

View File

@@ -109,7 +109,6 @@ describe('UpdateExistingItem', () => {
domainEventFactory.createItemRemovedFromSharedVaultEvent = jest
.fn()
.mockReturnValue({} as jest.Mocked<DomainEventInterface>)
domainEventFactory.createItemDeletedEvent = jest.fn().mockReturnValue({} as jest.Mocked<DomainEventInterface>)
determineSharedVaultOperationOnItem = {} as jest.Mocked<DetermineSharedVaultOperationOnItem>
determineSharedVaultOperationOnItem.execute = jest.fn().mockResolvedValue(

View File

@@ -159,7 +159,6 @@ export class UpdateExistingItem implements UseCaseInterface<Item> {
dto.existingItem.props.keySystemAssociation = undefined
}
let wasMarkedAsDeleted = false
if (dto.itemHash.props.deleted === true) {
dto.existingItem.props.deleted = true
dto.existingItem.props.content = null
@@ -167,8 +166,6 @@ export class UpdateExistingItem implements UseCaseInterface<Item> {
dto.existingItem.props.encItemKey = null
dto.existingItem.props.authHash = null
dto.existingItem.props.itemsKeyId = null
wasMarkedAsDeleted = true
}
await this.itemRepository.update(dto.existingItem)
@@ -199,15 +196,6 @@ export class UpdateExistingItem implements UseCaseInterface<Item> {
)
}
if (wasMarkedAsDeleted) {
await this.domainEventPublisher.publish(
this.domainEventFactory.createItemDeletedEvent({
itemUuid: dto.existingItem.id.toString(),
userUuid: dto.existingItem.props.userUuid.value,
}),
)
}
const notificationsResult = await this.addNotificationsAndPublishEvents(userUuid, sharedVaultOperation, dto)
if (notificationsResult.isFailed()) {
return Result.fail(notificationsResult.getError())

View File

@@ -74,17 +74,9 @@ export class SyncingServer implements ISyncingServer {
}
const apiVersion = call.request.hasApiVersion() ? (call.request.getApiVersion() as string) : ApiVersion.v20161215
const userUuid = call.metadata.get('x-user-uuid').pop() as string
const readOnlyAccess = call.metadata.get('x-read-only-access').pop() === 'true'
if (readOnlyAccess) {
this.logger.debug('Syncing with read-only access', {
codeTag: 'SyncingServer',
userId: userUuid,
})
}
const syncResult = await this.syncItemsUseCase.execute({
userUuid,
userUuid: call.metadata.get('x-user-uuid').pop() as string,
itemHashes,
computeIntegrityHash: call.request.hasComputeIntegrity() ? call.request.getComputeIntegrity() === true : false,
syncToken: call.request.hasSyncToken() ? call.request.getSyncToken() : undefined,
@@ -93,7 +85,7 @@ export class SyncingServer implements ISyncingServer {
contentType: call.request.hasContentType() ? call.request.getContentType() : undefined,
apiVersion,
snjsVersion: call.metadata.get('x-snjs-version').pop() as string,
readOnlyAccess,
readOnlyAccess: call.metadata.get('x-read-only-access').pop() === 'true',
sessionUuid: call.metadata.get('x-session-uuid').pop() as string,
sharedVaultUuids,
isFreeUser: call.metadata.get('x-is-free-user').pop() === 'true',

View File

@@ -3,10 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.4](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.22.3...@standardnotes/websockets-server@1.22.4) (2023-12-26)
**Note:** Version bump only for package @standardnotes/websockets-server
## [1.22.3](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.22.2...@standardnotes/websockets-server@1.22.3) (2023-12-14)
**Note:** Version bump only for package @standardnotes/websockets-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/websockets-server",
"version": "1.22.4",
"version": "1.22.3",
"engines": {
"node": ">=18.0.0 <21.0.0"
},