mirror of
https://github.com/standardnotes/server
synced 2026-02-15 02:01:18 -05:00
Compare commits
13 Commits
@standardn
...
@standardn
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d931c52508 | ||
|
|
800fe9e4c8 | ||
|
|
8b3d78678f | ||
|
|
2351cd3ad6 | ||
|
|
dd86c5bcdf | ||
|
|
d0c00e306e | ||
|
|
6cd68ddd6a | ||
|
|
02639cddb2 | ||
|
|
0f67aa4058 | ||
|
|
78c3403d5f | ||
|
|
fc8f8c574d | ||
|
|
3972ee580d | ||
|
|
b0a994d5be |
@@ -3,6 +3,18 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.11.17](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.11.16...@standardnotes/analytics@2.11.17) (2022-12-02)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/analytics
|
||||
|
||||
## [2.11.16](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.11.15...@standardnotes/analytics@2.11.16) (2022-12-02)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/analytics
|
||||
|
||||
## [2.11.15](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.11.14...@standardnotes/analytics@2.11.15) (2022-11-30)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/analytics
|
||||
|
||||
## [2.11.14](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.11.13...@standardnotes/analytics@2.11.14) (2022-11-28)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/analytics
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/analytics",
|
||||
"version": "2.11.14",
|
||||
"version": "2.11.17",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.39.6](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.39.5...@standardnotes/api-gateway@1.39.6) (2022-11-30)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||
|
||||
## [1.39.5](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.39.4...@standardnotes/api-gateway@1.39.5) (2022-11-28)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/api-gateway",
|
||||
"version": "1.39.5",
|
||||
"version": "1.39.6",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.60.15](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.60.14...@standardnotes/auth-server@1.60.15) (2022-11-30)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/auth-server
|
||||
|
||||
## [1.60.14](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.60.13...@standardnotes/auth-server@1.60.14) (2022-11-28)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/auth-server
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/auth-server",
|
||||
"version": "1.60.14",
|
||||
"version": "1.60.15",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,18 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
# [1.6.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.5.2...@standardnotes/domain-core@1.6.0) (2022-12-02)
|
||||
|
||||
### Features
|
||||
|
||||
* **domain-core:** add subscription plan name value object ([800fe9e](https://github.com/standardnotes/server/commit/800fe9e4c80c33f2da8097b5a153f470a23b7984))
|
||||
|
||||
## [1.5.2](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.5.1...@standardnotes/domain-core@1.5.2) (2022-12-02)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **domain-core:** rename timestamps to dates ([dd86c5b](https://github.com/standardnotes/server/commit/dd86c5bcdf3a1a37d684f6416d4cc6f24497fe5e))
|
||||
|
||||
## [1.5.1](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.5.0...@standardnotes/domain-core@1.5.1) (2022-11-25)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/domain-core
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/domain-core",
|
||||
"version": "1.5.1",
|
||||
"version": "1.6.0",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Timestamps } from './Timestamps'
|
||||
import { Dates } from './Dates'
|
||||
|
||||
describe('Timestamps', () => {
|
||||
describe('Dates', () => {
|
||||
it('should create a value object', () => {
|
||||
const valueOrError = Timestamps.create(new Date(1), new Date(2))
|
||||
const valueOrError = Dates.create(new Date(1), new Date(2))
|
||||
|
||||
expect(valueOrError.isFailed()).toBeFalsy()
|
||||
expect(valueOrError.getValue().createdAt).toEqual(new Date(1))
|
||||
@@ -10,11 +10,11 @@ describe('Timestamps', () => {
|
||||
})
|
||||
|
||||
it('should not create an invalid value object', () => {
|
||||
let valueOrError = Timestamps.create(null as unknown as Date, '2' as unknown as Date)
|
||||
let valueOrError = Dates.create(null as unknown as Date, '2' as unknown as Date)
|
||||
|
||||
expect(valueOrError.isFailed()).toBeTruthy()
|
||||
|
||||
valueOrError = Timestamps.create(new Date(2), '2' as unknown as Date)
|
||||
valueOrError = Dates.create(new Date(2), '2' as unknown as Date)
|
||||
|
||||
expect(valueOrError.isFailed()).toBeTruthy()
|
||||
})
|
||||
28
packages/domain-core/src/Domain/Common/Dates.ts
Normal file
28
packages/domain-core/src/Domain/Common/Dates.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Result } from '../Core/Result'
|
||||
import { ValueObject } from '../Core/ValueObject'
|
||||
import { DatesProps } from './DatesProps'
|
||||
|
||||
export class Dates extends ValueObject<DatesProps> {
|
||||
get createdAt(): Date {
|
||||
return this.props.createdAt
|
||||
}
|
||||
|
||||
get updatedAt(): Date {
|
||||
return this.props.updatedAt
|
||||
}
|
||||
|
||||
private constructor(props: DatesProps) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
static create(createdAt: Date, updatedAt: Date): Result<Dates> {
|
||||
if (!(createdAt instanceof Date)) {
|
||||
return Result.fail<Dates>(`Could not create Dates. Creation date should be a date object, given: ${createdAt}`)
|
||||
}
|
||||
if (!(updatedAt instanceof Date)) {
|
||||
return Result.fail<Dates>(`Could not create Dates. Update date should be a date object, given: ${createdAt}`)
|
||||
}
|
||||
|
||||
return Result.ok<Dates>(new Dates({ createdAt, updatedAt }))
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface TimestampsProps {
|
||||
export interface DatesProps {
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import { Result } from '../Core/Result'
|
||||
import { ValueObject } from '../Core/ValueObject'
|
||||
import { TimestampsProps } from './TimestampsProps'
|
||||
|
||||
export class Timestamps extends ValueObject<TimestampsProps> {
|
||||
get createdAt(): Date {
|
||||
return this.props.createdAt
|
||||
}
|
||||
|
||||
get updatedAt(): Date {
|
||||
return this.props.updatedAt
|
||||
}
|
||||
|
||||
private constructor(props: TimestampsProps) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
static create(createdAt: Date, updatedAt: Date): Result<Timestamps> {
|
||||
if (!(createdAt instanceof Date)) {
|
||||
return Result.fail<Timestamps>(
|
||||
`Could not create Timestamps. Creation date should be a date object, given: ${createdAt}`,
|
||||
)
|
||||
}
|
||||
if (!(updatedAt instanceof Date)) {
|
||||
return Result.fail<Timestamps>(
|
||||
`Could not create Timestamps. Update date should be a date object, given: ${createdAt}`,
|
||||
)
|
||||
}
|
||||
|
||||
return Result.ok<Timestamps>(new Timestamps({ createdAt, updatedAt }))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { SubscriptionPlanName } from './SubscriptionPlanName'
|
||||
|
||||
describe('SubscriptionPlanName', () => {
|
||||
it('should create a value object', () => {
|
||||
const valueOrError = SubscriptionPlanName.create('PRO_PLAN')
|
||||
|
||||
expect(valueOrError.isFailed()).toBeFalsy()
|
||||
expect(valueOrError.getValue().value).toEqual('PRO_PLAN')
|
||||
})
|
||||
|
||||
it('should not create an invalid value object', () => {
|
||||
for (const value of ['', undefined, null, 0, 'SOME_PLAN']) {
|
||||
const valueOrError = SubscriptionPlanName.create(value as string)
|
||||
|
||||
expect(valueOrError.isFailed()).toBeTruthy()
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,27 @@
|
||||
import { ValueObject } from '../Core/ValueObject'
|
||||
import { Result } from '../Core/Result'
|
||||
import { SubscriptionPlanNameProps } from './SubscriptionPlanNameProps'
|
||||
|
||||
export class SubscriptionPlanName extends ValueObject<SubscriptionPlanNameProps> {
|
||||
static readonly NAMES = {
|
||||
PlusPlan: 'PLUS_PLAN',
|
||||
ProPlan: 'PRO_PLAN',
|
||||
}
|
||||
|
||||
get value(): string {
|
||||
return this.props.value
|
||||
}
|
||||
|
||||
private constructor(props: SubscriptionPlanNameProps) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
static create(name: string): Result<SubscriptionPlanName> {
|
||||
const isValidName = Object.values(this.NAMES).includes(name)
|
||||
if (!isValidName) {
|
||||
return Result.fail<SubscriptionPlanName>(`Invalid subscription plan name: ${name}`)
|
||||
} else {
|
||||
return Result.ok<SubscriptionPlanName>(new SubscriptionPlanName({ value: name }))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export interface SubscriptionPlanNameProps {
|
||||
value: string
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
export * from './Common/Dates'
|
||||
export * from './Common/DatesProps'
|
||||
export * from './Common/Email'
|
||||
export * from './Common/EmailProps'
|
||||
export * from './Common/RoleName'
|
||||
export * from './Common/RoleNameProps'
|
||||
export * from './Common/RoleNameCollection'
|
||||
export * from './Common/RoleNameCollectionProps'
|
||||
export * from './Common/Timestamps'
|
||||
export * from './Common/TimestampsProps'
|
||||
export * from './Common/Uuid'
|
||||
export * from './Common/UuidProps'
|
||||
|
||||
@@ -20,4 +20,7 @@ export * from './Core/ValueObjectProps'
|
||||
|
||||
export * from './Mapping/MapperInterface'
|
||||
|
||||
export * from './Subscription/SubscriptionPlanName'
|
||||
export * from './Subscription/SubscriptionPlanNameProps'
|
||||
|
||||
export * from './UseCase/UseCaseInterface'
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.9.36](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.9.35...@standardnotes/domain-events-infra@1.9.36) (2022-11-30)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/domain-events-infra
|
||||
|
||||
## [1.9.35](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.9.34...@standardnotes/domain-events-infra@1.9.35) (2022-11-28)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/domain-events-infra
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/domain-events-infra",
|
||||
"version": "1.9.35",
|
||||
"version": "1.9.36",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
# [2.92.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.91.0...@standardnotes/domain-events@2.92.0) (2022-11-30)
|
||||
|
||||
### Features
|
||||
|
||||
* **revisions:** add updating user uuid on revisions in async processing ([0f67aa4](https://github.com/standardnotes/server/commit/0f67aa4058301dfa92794b90a842966173f71b95))
|
||||
|
||||
# [2.91.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.90.2...@standardnotes/domain-events@2.91.0) (2022-11-28)
|
||||
|
||||
### Features
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/domain-events",
|
||||
"version": "2.91.0",
|
||||
"version": "2.92.0",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { DomainEventInterface } from './DomainEventInterface'
|
||||
import { RevisionsOwnershipUpdateRequestedEventPayload } from './RevisionsOwnershipUpdateRequestedEventPayload'
|
||||
|
||||
export interface RevisionsOwnershipUpdateRequestedEvent extends DomainEventInterface {
|
||||
type: 'REVISIONS_OWNERSHIP_UPDATE_REQUESTED'
|
||||
payload: RevisionsOwnershipUpdateRequestedEventPayload
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface RevisionsOwnershipUpdateRequestedEventPayload {
|
||||
itemUuid: string
|
||||
userUuid: string
|
||||
}
|
||||
@@ -76,6 +76,8 @@ export * from './Event/RefundProcessedEvent'
|
||||
export * from './Event/RefundProcessedEventPayload'
|
||||
export * from './Event/RevisionsCopyRequestedEvent'
|
||||
export * from './Event/RevisionsCopyRequestedEventPayload'
|
||||
export * from './Event/RevisionsOwnershipUpdateRequestedEvent'
|
||||
export * from './Event/RevisionsOwnershipUpdateRequestedEventPayload'
|
||||
export * from './Event/SharedSubscriptionInvitationCanceledEvent'
|
||||
export * from './Event/SharedSubscriptionInvitationCanceledEventPayload'
|
||||
export * from './Event/SharedSubscriptionInvitationCreatedEvent'
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.6.32](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.6.31...@standardnotes/event-store@1.6.32) (2022-11-30)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/event-store
|
||||
|
||||
## [1.6.31](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.6.30...@standardnotes/event-store@1.6.31) (2022-11-28)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/event-store
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/event-store",
|
||||
"version": "1.6.31",
|
||||
"version": "1.6.32",
|
||||
"description": "Event Store Service",
|
||||
"private": true,
|
||||
"main": "dist/src/index.js",
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.8.32](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.8.31...@standardnotes/files-server@1.8.32) (2022-11-30)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/files-server
|
||||
|
||||
## [1.8.31](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.8.30...@standardnotes/files-server@1.8.31) (2022-11-28)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/files-server
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/files-server",
|
||||
"version": "1.8.31",
|
||||
"version": "1.8.32",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,34 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.9.2](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.9.1...@standardnotes/revisions-server@1.9.2) (2022-12-02)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/revisions-server
|
||||
|
||||
## [1.9.1](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.9.0...@standardnotes/revisions-server@1.9.1) (2022-12-02)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **revisions:** change timestamps to dates value object ([2351cd3](https://github.com/standardnotes/server/commit/2351cd3ad660c81b3b6bbc3759bc1c32a03406af))
|
||||
|
||||
# [1.9.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.8.2...@standardnotes/revisions-server@1.9.0) (2022-11-30)
|
||||
|
||||
### Features
|
||||
|
||||
* **revisions:** add updating user uuid on revisions in async processing ([0f67aa4](https://github.com/standardnotes/server/commit/0f67aa4058301dfa92794b90a842966173f71b95))
|
||||
|
||||
## [1.8.2](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.8.1...@standardnotes/revisions-server@1.8.2) (2022-11-29)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **revisions:** make user uuid nullable ([fc8f8c5](https://github.com/standardnotes/server/commit/fc8f8c574dbc8901cc4a12986154841d39abcc9b))
|
||||
|
||||
## [1.8.1](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.8.0...@standardnotes/revisions-server@1.8.1) (2022-11-29)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **revisions:** mysql queries ([b0a994d](https://github.com/standardnotes/server/commit/b0a994d5be3b35f054a14a6e9661232090ec11e5))
|
||||
|
||||
# [1.8.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.7.1...@standardnotes/revisions-server@1.8.0) (2022-11-28)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm'
|
||||
|
||||
export class makeUserUuidNullable1669735585016 implements MigrationInterface {
|
||||
name = 'makeUserUuidNullable1669735585016'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query('ALTER TABLE `revisions` CHANGE `user_uuid` `user_uuid` varchar(36) NULL')
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query('ALTER TABLE `revisions` CHANGE `user_uuid` `user_uuid` varchar(36) NOT NULL')
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/revisions-server",
|
||||
"version": "1.8.0",
|
||||
"version": "1.9.2",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
@@ -41,6 +41,7 @@ import { DeleteRevision } from '../Domain/UseCase/DeleteRevision/DeleteRevision'
|
||||
import { AccountDeletionRequestedEventHandler } from '../Domain/Handler/AccountDeletionRequestedEventHandler'
|
||||
import { RevisionsCopyRequestedEventHandler } from '../Domain/Handler/RevisionsCopyRequestedEventHandler'
|
||||
import { CopyRevisions } from '../Domain/UseCase/CopyRevisions/CopyRevisions'
|
||||
import { RevisionsOwnershipUpdateRequestedEventHandler } from '../Domain/Handler/RevisionsOwnershipUpdateRequestedEventHandler'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const newrelicFormatter = require('@newrelic/winston-enricher')
|
||||
@@ -195,6 +196,9 @@ export class ContainerConfigLoader {
|
||||
.toConstantValue(
|
||||
new RevisionsCopyRequestedEventHandler(container.get(TYPES.CopyRevisions), container.get(TYPES.Logger)),
|
||||
)
|
||||
container
|
||||
.bind<RevisionsOwnershipUpdateRequestedEventHandler>(TYPES.RevisionsOwnershipUpdateRequestedEventHandler)
|
||||
.toConstantValue(new RevisionsOwnershipUpdateRequestedEventHandler(container.get(TYPES.RevisionRepository)))
|
||||
|
||||
// Services
|
||||
container
|
||||
@@ -210,6 +214,7 @@ export class ContainerConfigLoader {
|
||||
['ITEM_DUMPED', container.get(TYPES.ItemDumpedEventHandler)],
|
||||
['ACCOUNT_DELETION_REQUESTED', container.get(TYPES.AccountDeletionRequestedEventHandler)],
|
||||
['REVISIONS_COPY_REQUESTED', container.get(TYPES.RevisionsCopyRequestedEventHandler)],
|
||||
['REVISIONS_OWNERSHIP_UPDATE_REQUESTED', container.get(TYPES.RevisionsOwnershipUpdateRequestedEventHandler)],
|
||||
])
|
||||
|
||||
if (env.get('SQS_QUEUE_URL', true)) {
|
||||
|
||||
@@ -34,6 +34,7 @@ const TYPES = {
|
||||
ItemDumpedEventHandler: Symbol.for('ItemDumpedEventHandler'),
|
||||
AccountDeletionRequestedEventHandler: Symbol.for('AccountDeletionRequestedEventHandler'),
|
||||
RevisionsCopyRequestedEventHandler: Symbol.for('RevisionsCopyRequestedEventHandler'),
|
||||
RevisionsOwnershipUpdateRequestedEventHandler: Symbol.for('RevisionsOwnershipUpdateRequestedEventHandler'),
|
||||
// Services
|
||||
CrossServiceTokenDecoder: Symbol.for('CrossServiceTokenDecoder'),
|
||||
DomainEventSubscriberFactory: Symbol.for('DomainEventSubscriberFactory'),
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/* istanbul ignore file */
|
||||
|
||||
import { Uuid } from '@standardnotes/domain-core'
|
||||
import { DomainEventHandlerInterface, RevisionsOwnershipUpdateRequestedEvent } from '@standardnotes/domain-events'
|
||||
import { RevisionRepositoryInterface } from '../Revision/RevisionRepositoryInterface'
|
||||
|
||||
export class RevisionsOwnershipUpdateRequestedEventHandler implements DomainEventHandlerInterface {
|
||||
constructor(private revisionRepository: RevisionRepositoryInterface) {}
|
||||
|
||||
async handle(event: RevisionsOwnershipUpdateRequestedEvent): Promise<void> {
|
||||
const userUuidOrError = Uuid.create(event.payload.userUuid)
|
||||
if (userUuidOrError.isFailed()) {
|
||||
return
|
||||
}
|
||||
const userUuid = userUuidOrError.getValue()
|
||||
|
||||
const itemUuidOrError = Uuid.create(event.payload.itemUuid)
|
||||
if (itemUuidOrError.isFailed()) {
|
||||
return
|
||||
}
|
||||
const itemUuid = itemUuidOrError.getValue()
|
||||
|
||||
await this.revisionRepository.updateUserUuid(itemUuid, userUuid)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Timestamps, Uuid } from '@standardnotes/domain-core'
|
||||
import { Dates, Uuid } from '@standardnotes/domain-core'
|
||||
import { ContentType } from './ContentType'
|
||||
import { Revision } from './Revision'
|
||||
|
||||
@@ -13,7 +13,7 @@ describe('Revision', () => {
|
||||
encItemKey: 'test',
|
||||
authHash: 'test',
|
||||
creationDate: new Date(1),
|
||||
timestamps: Timestamps.create(new Date(1), new Date(2)).getValue(),
|
||||
dates: Dates.create(new Date(1), new Date(2)).getValue(),
|
||||
})
|
||||
|
||||
expect(entityOrError.isFailed()).toBeFalsy()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Timestamps } from '@standardnotes/domain-core'
|
||||
import { Dates } from '@standardnotes/domain-core'
|
||||
|
||||
import { ContentType } from './ContentType'
|
||||
|
||||
export interface RevisionMetadataProps {
|
||||
contentType: ContentType
|
||||
timestamps: Timestamps
|
||||
dates: Dates
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { Timestamps, Uuid } from '@standardnotes/domain-core'
|
||||
import { Dates, Uuid } from '@standardnotes/domain-core'
|
||||
|
||||
import { ContentType } from './ContentType'
|
||||
|
||||
export interface RevisionProps {
|
||||
itemUuid: Uuid
|
||||
userUuid: Uuid
|
||||
userUuid: Uuid | null
|
||||
content: string | null
|
||||
contentType: ContentType
|
||||
itemsKeyId: string | null
|
||||
encItemKey: string | null
|
||||
authHash: string | null
|
||||
creationDate: Date
|
||||
timestamps: Timestamps
|
||||
dates: Dates
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@ export interface RevisionRepositoryInterface {
|
||||
findOneByUuid(revisionUuid: Uuid, userUuid: Uuid): Promise<Revision | null>
|
||||
findByItemUuid(itemUuid: Uuid): Promise<Array<Revision>>
|
||||
findMetadataByItemId(itemUuid: Uuid, userUuid: Uuid): Promise<Array<RevisionMetadata>>
|
||||
updateUserUuid(itemUuid: Uuid, userUuid: Uuid): Promise<void>
|
||||
save(revision: Revision): Promise<Revision>
|
||||
}
|
||||
|
||||
@@ -13,10 +13,21 @@ export class MySQLRevisionRepository implements RevisionRepositoryInterface {
|
||||
private revisionMapper: MapperInterface<Revision, TypeORMRevision>,
|
||||
) {}
|
||||
|
||||
async updateUserUuid(itemUuid: Uuid, userUuid: Uuid): Promise<void> {
|
||||
await this.ormRepository
|
||||
.createQueryBuilder()
|
||||
.update()
|
||||
.set({
|
||||
userUuid: userUuid.value,
|
||||
})
|
||||
.where('item_uuid = :itemUuid', { itemUuid: itemUuid.value })
|
||||
.execute()
|
||||
}
|
||||
|
||||
async findByItemUuid(itemUuid: Uuid): Promise<Revision[]> {
|
||||
const typeormRevisions = await this.ormRepository
|
||||
.createQueryBuilder()
|
||||
.where('item_uuid = :itemUuid', { itemUuid })
|
||||
.where('item_uuid = :itemUuid', { itemUuid: itemUuid.value })
|
||||
.getMany()
|
||||
|
||||
const revisions = []
|
||||
@@ -32,7 +43,7 @@ export class MySQLRevisionRepository implements RevisionRepositoryInterface {
|
||||
.createQueryBuilder()
|
||||
.delete()
|
||||
.from('revisions')
|
||||
.where('user_uuid = :userUuid', { userUuid })
|
||||
.where('user_uuid = :userUuid', { userUuid: userUuid.value })
|
||||
.execute()
|
||||
}
|
||||
|
||||
@@ -41,15 +52,18 @@ export class MySQLRevisionRepository implements RevisionRepositoryInterface {
|
||||
.createQueryBuilder()
|
||||
.delete()
|
||||
.from('revisions')
|
||||
.where('uuid = :revisionUuid AND user_uuid = :userUuid', { userUuid, revisionUuid })
|
||||
.where('uuid = :revisionUuid AND user_uuid = :userUuid', {
|
||||
userUuid: userUuid.value,
|
||||
revisionUuid: revisionUuid.value,
|
||||
})
|
||||
.execute()
|
||||
}
|
||||
|
||||
async findOneByUuid(revisionUuid: Uuid, userUuid: Uuid): Promise<Revision | null> {
|
||||
const typeormRevision = await this.ormRepository
|
||||
.createQueryBuilder()
|
||||
.where('uuid = :revisionUuid', { revisionUuid })
|
||||
.andWhere('user_uuid = :userUuid', { userUuid })
|
||||
.where('uuid = :revisionUuid', { revisionUuid: revisionUuid.value })
|
||||
.andWhere('user_uuid = :userUuid', { userUuid: userUuid.value })
|
||||
.getOne()
|
||||
|
||||
if (typeormRevision === null) {
|
||||
@@ -74,8 +88,8 @@ export class MySQLRevisionRepository implements RevisionRepositoryInterface {
|
||||
.addSelect('content_type', 'contentType')
|
||||
.addSelect('created_at', 'createdAt')
|
||||
.addSelect('updated_at', 'updatedAt')
|
||||
.where('item_uuid = :itemUuid', { itemUuid })
|
||||
.andWhere('user_uuid = :userUuid', { userUuid })
|
||||
.where('item_uuid = :itemUuid', { itemUuid: itemUuid.value })
|
||||
.andWhere('user_uuid = :userUuid', { userUuid: userUuid.value })
|
||||
.orderBy('created_at', 'DESC')
|
||||
|
||||
const simplifiedRevisions = await queryBuilder.getMany()
|
||||
|
||||
@@ -15,9 +15,11 @@ export class TypeORMRevision {
|
||||
@Column({
|
||||
name: 'user_uuid',
|
||||
length: 36,
|
||||
type: 'varchar',
|
||||
nullable: true,
|
||||
})
|
||||
@Index('user_uuid')
|
||||
declare userUuid: string
|
||||
declare userUuid: string | null
|
||||
|
||||
@Column({
|
||||
type: 'mediumtext',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MapperInterface, Timestamps, Uuid } from '@standardnotes/domain-core'
|
||||
import { MapperInterface, Dates, Uuid } from '@standardnotes/domain-core'
|
||||
|
||||
import { ContentType } from '../Domain/Revision/ContentType'
|
||||
import { Revision } from '../Domain/Revision/Revision'
|
||||
@@ -34,7 +34,7 @@ export class RevisionItemStringMapper implements MapperInterface<Revision, strin
|
||||
itemsKeyId: item.items_key_id,
|
||||
encItemKey: item.enc_item_key,
|
||||
creationDate: new Date(),
|
||||
timestamps: Timestamps.create(new Date(), new Date()).getValue(),
|
||||
dates: Dates.create(new Date(), new Date()).getValue(),
|
||||
})
|
||||
|
||||
if (revisionOrError.isFailed()) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MapperInterface, Timestamps, UniqueEntityId } from '@standardnotes/domain-core'
|
||||
import { MapperInterface, Dates, UniqueEntityId } from '@standardnotes/domain-core'
|
||||
|
||||
import { ContentType } from '../Domain/Revision/ContentType'
|
||||
import { RevisionMetadata } from '../Domain/Revision/RevisionMetadata'
|
||||
@@ -12,16 +12,16 @@ export class RevisionMetadataPersistenceMapper implements MapperInterface<Revisi
|
||||
}
|
||||
const contentType = contentTypeOrError.getValue()
|
||||
|
||||
const timestampsOrError = Timestamps.create(projection.createdAt, projection.updatedAt)
|
||||
if (timestampsOrError.isFailed()) {
|
||||
throw new Error(`Could not create timestamps: ${timestampsOrError.getError()}`)
|
||||
const datesOrError = Dates.create(projection.createdAt, projection.updatedAt)
|
||||
if (datesOrError.isFailed()) {
|
||||
throw new Error(`Could not create dates: ${datesOrError.getError()}`)
|
||||
}
|
||||
const timestamps = timestampsOrError.getValue()
|
||||
const dates = datesOrError.getValue()
|
||||
|
||||
const revisionMetadataOrError = RevisionMetadata.create(
|
||||
{
|
||||
contentType,
|
||||
timestamps,
|
||||
dates,
|
||||
},
|
||||
new UniqueEntityId(projection.uuid),
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MapperInterface, Timestamps, UniqueEntityId, Uuid } from '@standardnotes/domain-core'
|
||||
import { MapperInterface, Dates, UniqueEntityId, Uuid } from '@standardnotes/domain-core'
|
||||
import { ContentType } from '../Domain/Revision/ContentType'
|
||||
import { Revision } from '../Domain/Revision/Revision'
|
||||
import { TypeORMRevision } from '../Infra/TypeORM/TypeORMRevision'
|
||||
@@ -11,11 +11,11 @@ export class RevisionPersistenceMapper implements MapperInterface<Revision, Type
|
||||
}
|
||||
const contentType = contentTypeOrError.getValue()
|
||||
|
||||
const timestampsOrError = Timestamps.create(projection.createdAt, projection.updatedAt)
|
||||
if (timestampsOrError.isFailed()) {
|
||||
throw new Error(`Could not map typeorm revision to domain revision: ${timestampsOrError.getError()}`)
|
||||
const datesOrError = Dates.create(projection.createdAt, projection.updatedAt)
|
||||
if (datesOrError.isFailed()) {
|
||||
throw new Error(`Could not map typeorm revision to domain revision: ${datesOrError.getError()}`)
|
||||
}
|
||||
const timestamps = timestampsOrError.getValue()
|
||||
const dates = datesOrError.getValue()
|
||||
|
||||
const itemUuidOrError = Uuid.create(projection.itemUuid)
|
||||
if (itemUuidOrError.isFailed()) {
|
||||
@@ -23,11 +23,14 @@ export class RevisionPersistenceMapper implements MapperInterface<Revision, Type
|
||||
}
|
||||
const itemUuid = itemUuidOrError.getValue()
|
||||
|
||||
const userUuidOrError = Uuid.create(projection.userUuid)
|
||||
if (userUuidOrError.isFailed()) {
|
||||
throw new Error(`Could not map typeorm revision to domain revision: ${userUuidOrError.getError()}`)
|
||||
let userUuid = null
|
||||
if (projection.userUuid !== null) {
|
||||
const userUuidOrError = Uuid.create(projection.userUuid)
|
||||
if (userUuidOrError.isFailed()) {
|
||||
throw new Error(`Could not map typeorm revision to domain revision: ${userUuidOrError.getError()}`)
|
||||
}
|
||||
userUuid = userUuidOrError.getValue()
|
||||
}
|
||||
const userUuid = userUuidOrError.getValue()
|
||||
|
||||
const revisionOrError = Revision.create(
|
||||
{
|
||||
@@ -39,7 +42,7 @@ export class RevisionPersistenceMapper implements MapperInterface<Revision, Type
|
||||
itemsKeyId: projection.itemsKeyId,
|
||||
itemUuid,
|
||||
userUuid,
|
||||
timestamps,
|
||||
dates,
|
||||
},
|
||||
new UniqueEntityId(projection.uuid),
|
||||
)
|
||||
@@ -56,13 +59,13 @@ export class RevisionPersistenceMapper implements MapperInterface<Revision, Type
|
||||
typeormRevision.authHash = domain.props.authHash
|
||||
typeormRevision.content = domain.props.content
|
||||
typeormRevision.contentType = domain.props.contentType.value
|
||||
typeormRevision.createdAt = domain.props.timestamps.createdAt
|
||||
typeormRevision.updatedAt = domain.props.timestamps.updatedAt
|
||||
typeormRevision.createdAt = domain.props.dates.createdAt
|
||||
typeormRevision.updatedAt = domain.props.dates.updatedAt
|
||||
typeormRevision.creationDate = domain.props.creationDate
|
||||
typeormRevision.encItemKey = domain.props.encItemKey
|
||||
typeormRevision.itemUuid = domain.props.itemUuid.value
|
||||
typeormRevision.itemsKeyId = domain.props.itemsKeyId
|
||||
typeormRevision.userUuid = domain.props.userUuid.value
|
||||
typeormRevision.userUuid = domain.props.userUuid ? domain.props.userUuid.value : null
|
||||
typeormRevision.uuid = domain.id.toString()
|
||||
|
||||
return typeormRevision
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.13.33](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.13.32...@standardnotes/scheduler-server@1.13.33) (2022-11-30)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/scheduler-server
|
||||
|
||||
## [1.13.32](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.13.31...@standardnotes/scheduler-server@1.13.32) (2022-11-28)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/scheduler-server
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/scheduler-server",
|
||||
"version": "1.13.32",
|
||||
"version": "1.13.33",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,24 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.20.2](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.20.1...@standardnotes/syncing-server@1.20.2) (2022-12-02)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/syncing-server
|
||||
|
||||
## [1.20.1](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.20.0...@standardnotes/syncing-server@1.20.1) (2022-12-02)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/syncing-server
|
||||
|
||||
# [1.20.0](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.19.1...@standardnotes/syncing-server@1.20.0) (2022-11-30)
|
||||
|
||||
### Features
|
||||
|
||||
* **syncing-server:** add revisions ownership fix procedure ([6cd68dd](https://github.com/standardnotes/syncing-server-js/commit/6cd68ddd6af0b1adde6c0d1cb3acef6e1aa9811b))
|
||||
|
||||
## [1.19.1](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.19.0...@standardnotes/syncing-server@1.19.1) (2022-11-30)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/syncing-server
|
||||
|
||||
# [1.19.0](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.18.12...@standardnotes/syncing-server@1.19.0) (2022-11-28)
|
||||
|
||||
### Features
|
||||
|
||||
78
packages/syncing-server/bin/revisions.ts
Normal file
78
packages/syncing-server/bin/revisions.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import 'newrelic'
|
||||
|
||||
import { Logger } from 'winston'
|
||||
|
||||
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
||||
import TYPES from '../src/Bootstrap/Types'
|
||||
import { Env } from '../src/Bootstrap/Env'
|
||||
import { DomainEventFactoryInterface } from '../src/Domain/Event/DomainEventFactoryInterface'
|
||||
import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
|
||||
import { ItemRepositoryInterface } from '../src/Domain/Item/ItemRepositoryInterface'
|
||||
import { Stream } from 'stream'
|
||||
|
||||
const fixRevisionsOwnership = async (
|
||||
itemRepository: ItemRepositoryInterface,
|
||||
domainEventFactory: DomainEventFactoryInterface,
|
||||
domainEventPublisher: DomainEventPublisherInterface,
|
||||
logger: Logger,
|
||||
): Promise<void> => {
|
||||
const stream = await itemRepository.streamAll({
|
||||
sortBy: 'updated_at_timestamp',
|
||||
sortOrder: 'ASC',
|
||||
createdBefore: new Date('2022-11-23'),
|
||||
selectFields: ['user_uuid', 'item_uuid'],
|
||||
})
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
stream
|
||||
.pipe(
|
||||
new Stream.Transform({
|
||||
objectMode: true,
|
||||
transform: async (rawItemData, _encoding, callback) => {
|
||||
try {
|
||||
await domainEventPublisher.publish(
|
||||
domainEventFactory.createRevisionsOwnershipUpdateRequestedEvent({
|
||||
userUuid: rawItemData.item_user_uuid,
|
||||
itemUuid: rawItemData.item_uuid,
|
||||
}),
|
||||
)
|
||||
} catch (error) {
|
||||
logger.error(`Could not process item ${rawItemData.item_uuid}: ${(error as Error).message}`)
|
||||
}
|
||||
|
||||
callback()
|
||||
},
|
||||
}),
|
||||
)
|
||||
.on('finish', resolve)
|
||||
.on('error', reject)
|
||||
})
|
||||
}
|
||||
|
||||
const container = new ContainerConfigLoader()
|
||||
void container.load().then((container) => {
|
||||
const env: Env = new Env()
|
||||
env.load()
|
||||
|
||||
const logger: Logger = container.get(TYPES.Logger)
|
||||
|
||||
logger.info('Starting revisions ownership fixing')
|
||||
|
||||
const itemRepository: ItemRepositoryInterface = container.get(TYPES.ItemRepository)
|
||||
const domainEventFactory: DomainEventFactoryInterface = container.get(TYPES.DomainEventFactory)
|
||||
const domainEventPublisher: DomainEventPublisherInterface = container.get(TYPES.DomainEventPublisher)
|
||||
|
||||
Promise.resolve(fixRevisionsOwnership(itemRepository, domainEventFactory, domainEventPublisher, logger))
|
||||
.then(() => {
|
||||
logger.info('revisions ownership fix complete.')
|
||||
|
||||
process.exit(0)
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error(`Could not finish revisions ownership fix: ${error.message}`)
|
||||
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
@@ -25,6 +25,11 @@ case "$COMMAND" in
|
||||
yarn workspace @standardnotes/syncing-server content-size $USER_UUID
|
||||
;;
|
||||
|
||||
'revisions-ownership-fix' )
|
||||
echo "Starting Revisions Ownership Fixing..."
|
||||
yarn workspace @standardnotes/syncing-server revisions-ownership
|
||||
;;
|
||||
|
||||
* )
|
||||
echo "Unknown command"
|
||||
;;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/syncing-server",
|
||||
"version": "1.19.0",
|
||||
"version": "1.20.2",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
@@ -22,6 +22,7 @@
|
||||
"start": "yarn node dist/bin/server.js",
|
||||
"worker": "yarn node dist/bin/worker.js",
|
||||
"content-size": "yarn node dist/bin/content.js",
|
||||
"revisions-ownership": "yarn node dist/bin/revisions.js",
|
||||
"upgrade:snjs": "yarn ncu -u '@standardnotes/*'"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
ItemsSyncedEvent,
|
||||
OneDriveBackupFailedEvent,
|
||||
RevisionsCopyRequestedEvent,
|
||||
RevisionsOwnershipUpdateRequestedEvent,
|
||||
UserContentSizeRecalculationRequestedEvent,
|
||||
} from '@standardnotes/domain-events'
|
||||
import { TimerInterface } from '@standardnotes/time'
|
||||
@@ -22,6 +23,24 @@ import { DomainEventFactoryInterface } from './DomainEventFactoryInterface'
|
||||
export class DomainEventFactory implements DomainEventFactoryInterface {
|
||||
constructor(@inject(TYPES.Timer) private timer: TimerInterface) {}
|
||||
|
||||
createRevisionsOwnershipUpdateRequestedEvent(dto: {
|
||||
userUuid: string
|
||||
itemUuid: string
|
||||
}): RevisionsOwnershipUpdateRequestedEvent {
|
||||
return {
|
||||
type: 'REVISIONS_OWNERSHIP_UPDATE_REQUESTED',
|
||||
createdAt: this.timer.getUTCDate(),
|
||||
meta: {
|
||||
correlation: {
|
||||
userIdentifier: dto.userUuid,
|
||||
userIdentifierType: 'uuid',
|
||||
},
|
||||
origin: DomainEventService.SyncingServer,
|
||||
},
|
||||
payload: dto,
|
||||
}
|
||||
}
|
||||
|
||||
createRevisionsCopyRequestedEvent(
|
||||
userUuid: string,
|
||||
dto: {
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
ItemsSyncedEvent,
|
||||
OneDriveBackupFailedEvent,
|
||||
RevisionsCopyRequestedEvent,
|
||||
RevisionsOwnershipUpdateRequestedEvent,
|
||||
UserContentSizeRecalculationRequestedEvent,
|
||||
} from '@standardnotes/domain-events'
|
||||
|
||||
@@ -40,4 +41,8 @@ export interface DomainEventFactoryInterface {
|
||||
userUuid: string,
|
||||
dto: { originalItemUuid: string; newItemUuid: string },
|
||||
): RevisionsCopyRequestedEvent
|
||||
createRevisionsOwnershipUpdateRequestedEvent(dto: {
|
||||
userUuid: string
|
||||
itemUuid: string
|
||||
}): RevisionsOwnershipUpdateRequestedEvent
|
||||
}
|
||||
|
||||
@@ -9,4 +9,6 @@ export type ItemQuery = {
|
||||
deleted?: boolean
|
||||
offset?: number
|
||||
limit?: number
|
||||
createdBefore?: Date
|
||||
selectFields?: string[]
|
||||
}
|
||||
|
||||
@@ -130,8 +130,12 @@ export class MySQLItemRepository implements ItemRepositoryInterface {
|
||||
|
||||
private createFindAllQueryBuilder(query: ItemQuery): SelectQueryBuilder<Item> {
|
||||
const queryBuilder = this.ormRepository.createQueryBuilder('item')
|
||||
|
||||
queryBuilder.orderBy(`item.${query.sortBy}`, query.sortOrder)
|
||||
|
||||
if (query.selectFields !== undefined) {
|
||||
queryBuilder.select(query.selectFields.map((field) => `item.${field}`))
|
||||
}
|
||||
if (query.userUuid !== undefined) {
|
||||
queryBuilder.where('item.user_uuid = :userUuid', { userUuid: query.userUuid })
|
||||
}
|
||||
@@ -149,6 +153,9 @@ export class MySQLItemRepository implements ItemRepositoryInterface {
|
||||
lastSyncTime: query.lastSyncTime,
|
||||
})
|
||||
}
|
||||
if (query.createdBefore !== undefined) {
|
||||
queryBuilder.andWhere('item.created_at < :createdAt', { createdAt: query.createdBefore.toISOString() })
|
||||
}
|
||||
if (query.offset !== undefined) {
|
||||
queryBuilder.skip(query.offset)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.4.33](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.4.32...@standardnotes/websockets-server@1.4.33) (2022-11-30)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/websockets-server
|
||||
|
||||
## [1.4.32](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.4.31...@standardnotes/websockets-server@1.4.32) (2022-11-28)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/websockets-server
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/websockets-server",
|
||||
"version": "1.4.32",
|
||||
"version": "1.4.33",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.17.32](https://github.com/standardnotes/server/compare/@standardnotes/workspace-server@1.17.31...@standardnotes/workspace-server@1.17.32) (2022-11-30)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/workspace-server
|
||||
|
||||
## [1.17.31](https://github.com/standardnotes/server/compare/@standardnotes/workspace-server@1.17.30...@standardnotes/workspace-server@1.17.31) (2022-11-28)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/workspace-server
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/workspace-server",
|
||||
"version": "1.17.31",
|
||||
"version": "1.17.32",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user