mirror of
https://github.com/standardnotes/server
synced 2026-04-22 09:01:42 -04:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d1244d165a | |||
| 106d8f9192 |
@@ -3,6 +3,10 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [2.26.8](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.7...@standardnotes/analytics@2.26.8) (2023-09-12)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
## [2.26.7](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.6...@standardnotes/analytics@2.26.7) (2023-09-08)
|
## [2.26.7](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.6...@standardnotes/analytics@2.26.7) (2023-09-08)
|
||||||
|
|
||||||
**Note:** Version bump only for package @standardnotes/analytics
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/analytics",
|
"name": "@standardnotes/analytics",
|
||||||
"version": "2.26.7",
|
"version": "2.26.8",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.74.5](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.4...@standardnotes/api-gateway@1.74.5) (2023-09-12)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
## [1.74.4](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.3...@standardnotes/api-gateway@1.74.4) (2023-09-11)
|
## [1.74.4](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.3...@standardnotes/api-gateway@1.74.4) (2023-09-11)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/api-gateway",
|
"name": "@standardnotes/api-gateway",
|
||||||
"version": "1.74.4",
|
"version": "1.74.5",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,12 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.141.4](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.3...@standardnotes/auth-server@1.141.4) (2023-09-12)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* adjust transitions to not create revisions during ongoing revisions transition ([106d8f9](https://github.com/standardnotes/server/commit/106d8f9192f630794ca4ddc2c4503f2c6cd196e7))
|
||||||
|
|
||||||
## [1.141.3](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.2...@standardnotes/auth-server@1.141.3) (2023-09-12)
|
## [1.141.3](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.2...@standardnotes/auth-server@1.141.3) (2023-09-12)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/auth-server",
|
"name": "@standardnotes/auth-server",
|
||||||
"version": "1.141.3",
|
"version": "1.141.4",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
export interface TransitionStatusRepositoryInterface {
|
export interface TransitionStatusRepositoryInterface {
|
||||||
updateStatus(userUuid: string, transitionType: 'items' | 'revisions', status: 'STARTED' | 'FAILED'): Promise<void>
|
updateStatus(
|
||||||
|
userUuid: string,
|
||||||
|
transitionType: 'items' | 'revisions',
|
||||||
|
status: 'STARTED' | 'IN_PROGRESS' | 'FAILED',
|
||||||
|
): Promise<void>
|
||||||
removeStatus(userUuid: string, transitionType: 'items' | 'revisions'): Promise<void>
|
removeStatus(userUuid: string, transitionType: 'items' | 'revisions'): Promise<void>
|
||||||
getStatus(
|
getStatus(
|
||||||
userUuid: string,
|
userUuid: string,
|
||||||
|
|||||||
+5
@@ -113,6 +113,7 @@ describe('CreateCrossServiceToken', () => {
|
|||||||
uuid: '00000000-0000-0000-0000-000000000000',
|
uuid: '00000000-0000-0000-0000-000000000000',
|
||||||
},
|
},
|
||||||
ongoing_transition: false,
|
ongoing_transition: false,
|
||||||
|
ongoing_revisions_transition: false,
|
||||||
},
|
},
|
||||||
60,
|
60,
|
||||||
)
|
)
|
||||||
@@ -148,6 +149,7 @@ describe('CreateCrossServiceToken', () => {
|
|||||||
uuid: '00000000-0000-0000-0000-000000000000',
|
uuid: '00000000-0000-0000-0000-000000000000',
|
||||||
},
|
},
|
||||||
ongoing_transition: true,
|
ongoing_transition: true,
|
||||||
|
ongoing_revisions_transition: true,
|
||||||
},
|
},
|
||||||
60,
|
60,
|
||||||
)
|
)
|
||||||
@@ -177,6 +179,7 @@ describe('CreateCrossServiceToken', () => {
|
|||||||
uuid: '00000000-0000-0000-0000-000000000000',
|
uuid: '00000000-0000-0000-0000-000000000000',
|
||||||
},
|
},
|
||||||
ongoing_transition: false,
|
ongoing_transition: false,
|
||||||
|
ongoing_revisions_transition: false,
|
||||||
},
|
},
|
||||||
60,
|
60,
|
||||||
)
|
)
|
||||||
@@ -206,6 +209,7 @@ describe('CreateCrossServiceToken', () => {
|
|||||||
uuid: '00000000-0000-0000-0000-000000000000',
|
uuid: '00000000-0000-0000-0000-000000000000',
|
||||||
},
|
},
|
||||||
ongoing_transition: false,
|
ongoing_transition: false,
|
||||||
|
ongoing_revisions_transition: false,
|
||||||
},
|
},
|
||||||
60,
|
60,
|
||||||
)
|
)
|
||||||
@@ -261,6 +265,7 @@ describe('CreateCrossServiceToken', () => {
|
|||||||
email: 'test@test.te',
|
email: 'test@test.te',
|
||||||
uuid: '00000000-0000-0000-0000-000000000000',
|
uuid: '00000000-0000-0000-0000-000000000000',
|
||||||
},
|
},
|
||||||
|
ongoing_revisions_transition: false,
|
||||||
ongoing_transition: false,
|
ongoing_transition: false,
|
||||||
},
|
},
|
||||||
60,
|
60,
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export class CreateCrossServiceToken implements UseCaseInterface<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const transitionStatus = await this.transitionStatusRepository.getStatus(user.uuid, 'items')
|
const transitionStatus = await this.transitionStatusRepository.getStatus(user.uuid, 'items')
|
||||||
|
const revisionsTransitionStatus = await this.transitionStatusRepository.getStatus(user.uuid, 'revisions')
|
||||||
|
|
||||||
const roles = await user.roles
|
const roles = await user.roles
|
||||||
|
|
||||||
@@ -60,6 +61,8 @@ export class CreateCrossServiceToken implements UseCaseInterface<string> {
|
|||||||
roles: this.projectRoles(roles),
|
roles: this.projectRoles(roles),
|
||||||
shared_vault_owner_context: undefined,
|
shared_vault_owner_context: undefined,
|
||||||
ongoing_transition: transitionStatus === 'IN_PROGRESS',
|
ongoing_transition: transitionStatus === 'IN_PROGRESS',
|
||||||
|
ongoing_revisions_transition:
|
||||||
|
revisionsTransitionStatus === 'STARTED' || revisionsTransitionStatus === 'IN_PROGRESS',
|
||||||
belongs_to_shared_vaults: sharedVaultAssociations.map((association) => ({
|
belongs_to_shared_vaults: sharedVaultAssociations.map((association) => ({
|
||||||
shared_vault_uuid: association.props.sharedVaultUuid.value,
|
shared_vault_uuid: association.props.sharedVaultUuid.value,
|
||||||
permission: association.props.permission.value,
|
permission: association.props.permission.value,
|
||||||
|
|||||||
@@ -10,9 +10,13 @@ export class RedisTransitionStatusRepository implements TransitionStatusReposito
|
|||||||
async updateStatus(
|
async updateStatus(
|
||||||
userUuid: string,
|
userUuid: string,
|
||||||
transitionType: 'items' | 'revisions',
|
transitionType: 'items' | 'revisions',
|
||||||
status: 'STARTED' | 'FAILED',
|
status: 'STARTED' | 'IN_PROGRESS' | 'FAILED',
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await this.redisClient.set(`${this.PREFIX}:${transitionType}:${userUuid}`, status)
|
if (status === 'IN_PROGRESS') {
|
||||||
|
await this.redisClient.setex(`${this.PREFIX}:${transitionType}:${userUuid}`, 7200, status)
|
||||||
|
} else {
|
||||||
|
await this.redisClient.set(`${this.PREFIX}:${transitionType}:${userUuid}`, status)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeStatus(userUuid: string, transitionType: 'items' | 'revisions'): Promise<void> {
|
async removeStatus(userUuid: string, transitionType: 'items' | 'revisions'): Promise<void> {
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.12.25](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.12.24...@standardnotes/domain-events-infra@1.12.25) (2023-09-12)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/domain-events-infra
|
||||||
|
|
||||||
## [1.12.24](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.12.23...@standardnotes/domain-events-infra@1.12.24) (2023-09-08)
|
## [1.12.24](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.12.23...@standardnotes/domain-events-infra@1.12.24) (2023-09-08)
|
||||||
|
|
||||||
**Note:** Version bump only for package @standardnotes/domain-events-infra
|
**Note:** Version bump only for package @standardnotes/domain-events-infra
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/domain-events-infra",
|
"name": "@standardnotes/domain-events-infra",
|
||||||
"version": "1.12.24",
|
"version": "1.12.25",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [2.125.1](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.125.0...@standardnotes/domain-events@2.125.1) (2023-09-12)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/domain-events
|
||||||
|
|
||||||
# [2.125.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.124.0...@standardnotes/domain-events@2.125.0) (2023-09-08)
|
# [2.125.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.124.0...@standardnotes/domain-events@2.125.0) (2023-09-08)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/domain-events",
|
"name": "@standardnotes/domain-events",
|
||||||
"version": "2.125.0",
|
"version": "2.125.1",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.11.36](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.11.35...@standardnotes/event-store@1.11.36) (2023-09-12)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/event-store
|
||||||
|
|
||||||
## [1.11.35](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.11.34...@standardnotes/event-store@1.11.35) (2023-09-08)
|
## [1.11.35](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.11.34...@standardnotes/event-store@1.11.35) (2023-09-08)
|
||||||
|
|
||||||
**Note:** Version bump only for package @standardnotes/event-store
|
**Note:** Version bump only for package @standardnotes/event-store
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/event-store",
|
"name": "@standardnotes/event-store",
|
||||||
"version": "1.11.35",
|
"version": "1.11.36",
|
||||||
"description": "Event Store Service",
|
"description": "Event Store Service",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "dist/src/index.js",
|
"main": "dist/src/index.js",
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.22.15](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.22.14...@standardnotes/files-server@1.22.15) (2023-09-12)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/files-server
|
||||||
|
|
||||||
## [1.22.14](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.22.13...@standardnotes/files-server@1.22.14) (2023-09-08)
|
## [1.22.14](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.22.13...@standardnotes/files-server@1.22.14) (2023-09-08)
|
||||||
|
|
||||||
**Note:** Version bump only for package @standardnotes/files-server
|
**Note:** Version bump only for package @standardnotes/files-server
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/files-server",
|
"name": "@standardnotes/files-server",
|
||||||
"version": "1.22.14",
|
"version": "1.22.15",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.15.38](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.37...@standardnotes/home-server@1.15.38) (2023-09-12)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/home-server
|
||||||
|
|
||||||
## [1.15.37](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.36...@standardnotes/home-server@1.15.37) (2023-09-12)
|
## [1.15.37](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.36...@standardnotes/home-server@1.15.37) (2023-09-12)
|
||||||
|
|
||||||
**Note:** Version bump only for package @standardnotes/home-server
|
**Note:** Version bump only for package @standardnotes/home-server
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/home-server",
|
"name": "@standardnotes/home-server",
|
||||||
"version": "1.15.37",
|
"version": "1.15.38",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,12 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.33.9](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.8...@standardnotes/revisions-server@1.33.9) (2023-09-12)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* adjust transitions to not create revisions during ongoing revisions transition ([106d8f9](https://github.com/standardnotes/server/commit/106d8f9192f630794ca4ddc2c4503f2c6cd196e7))
|
||||||
|
|
||||||
## [1.33.8](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.7...@standardnotes/revisions-server@1.33.8) (2023-09-12)
|
## [1.33.8](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.7...@standardnotes/revisions-server@1.33.8) (2023-09-12)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/revisions-server",
|
"name": "@standardnotes/revisions-server",
|
||||||
"version": "1.33.8",
|
"version": "1.33.9",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
+24
-4
@@ -99,7 +99,7 @@ describe('TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser', () => {
|
|||||||
secondaryRevisionRepository = {} as jest.Mocked<RevisionRepositoryInterface>
|
secondaryRevisionRepository = {} as jest.Mocked<RevisionRepositoryInterface>
|
||||||
secondaryRevisionRepository.insert = jest.fn().mockResolvedValue(true)
|
secondaryRevisionRepository.insert = jest.fn().mockResolvedValue(true)
|
||||||
secondaryRevisionRepository.removeByUserUuid = jest.fn().mockResolvedValue(undefined)
|
secondaryRevisionRepository.removeByUserUuid = jest.fn().mockResolvedValue(undefined)
|
||||||
secondaryRevisionRepository.countByUserUuid = jest.fn().mockResolvedValue(2)
|
secondaryRevisionRepository.countByUserUuid = jest.fn().mockResolvedValueOnce(0).mockResolvedValueOnce(2)
|
||||||
secondaryRevisionRepository.findOneByUuid = jest
|
secondaryRevisionRepository.findOneByUuid = jest
|
||||||
.fn()
|
.fn()
|
||||||
.mockResolvedValueOnce(secondaryRevision1)
|
.mockResolvedValueOnce(secondaryRevision1)
|
||||||
@@ -329,7 +329,10 @@ describe('TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should fail integrity check if the Revision count is not the same in both databases', async () => {
|
it('should fail integrity check if the Revision count is not the same in both databases', async () => {
|
||||||
;(secondaryRevisionRepository as RevisionRepositoryInterface).countByUserUuid = jest.fn().mockResolvedValue(1)
|
;(secondaryRevisionRepository as RevisionRepositoryInterface).countByUserUuid = jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValueOnce(0)
|
||||||
|
.mockResolvedValueOnce(1)
|
||||||
|
|
||||||
const useCase = createUseCase()
|
const useCase = createUseCase()
|
||||||
|
|
||||||
@@ -346,7 +349,7 @@ describe('TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser', () => {
|
|||||||
expect(primaryRevisionRepository.countByUserUuid).toHaveBeenCalledWith(
|
expect(primaryRevisionRepository.countByUserUuid).toHaveBeenCalledWith(
|
||||||
Uuid.create('00000000-0000-0000-0000-000000000000').getValue(),
|
Uuid.create('00000000-0000-0000-0000-000000000000').getValue(),
|
||||||
)
|
)
|
||||||
expect((secondaryRevisionRepository as RevisionRepositoryInterface).countByUserUuid).toHaveBeenCalledTimes(1)
|
expect((secondaryRevisionRepository as RevisionRepositoryInterface).countByUserUuid).toHaveBeenCalledTimes(2)
|
||||||
expect(primaryRevisionRepository.removeByUserUuid).not.toHaveBeenCalled()
|
expect(primaryRevisionRepository.removeByUserUuid).not.toHaveBeenCalled()
|
||||||
expect((secondaryRevisionRepository as RevisionRepositoryInterface).removeByUserUuid).toHaveBeenCalledTimes(1)
|
expect((secondaryRevisionRepository as RevisionRepositoryInterface).removeByUserUuid).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
@@ -370,7 +373,6 @@ describe('TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser', () => {
|
|||||||
expect(primaryRevisionRepository.countByUserUuid).toHaveBeenCalledWith(
|
expect(primaryRevisionRepository.countByUserUuid).toHaveBeenCalledWith(
|
||||||
Uuid.create('00000000-0000-0000-0000-000000000000').getValue(),
|
Uuid.create('00000000-0000-0000-0000-000000000000').getValue(),
|
||||||
)
|
)
|
||||||
expect((secondaryRevisionRepository as RevisionRepositoryInterface).countByUserUuid).not.toHaveBeenCalled()
|
|
||||||
expect(primaryRevisionRepository.removeByUserUuid).not.toHaveBeenCalled()
|
expect(primaryRevisionRepository.removeByUserUuid).not.toHaveBeenCalled()
|
||||||
expect((secondaryRevisionRepository as RevisionRepositoryInterface).removeByUserUuid).toHaveBeenCalledTimes(1)
|
expect((secondaryRevisionRepository as RevisionRepositoryInterface).removeByUserUuid).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
@@ -378,6 +380,7 @@ describe('TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser', () => {
|
|||||||
it('should fail if an error is thrown during integrity check between primary and secondary database', async () => {
|
it('should fail if an error is thrown during integrity check between primary and secondary database', async () => {
|
||||||
;(secondaryRevisionRepository as RevisionRepositoryInterface).countByUserUuid = jest
|
;(secondaryRevisionRepository as RevisionRepositoryInterface).countByUserUuid = jest
|
||||||
.fn()
|
.fn()
|
||||||
|
.mockReturnValueOnce(0)
|
||||||
.mockRejectedValue(new Error('error'))
|
.mockRejectedValue(new Error('error'))
|
||||||
|
|
||||||
const useCase = createUseCase()
|
const useCase = createUseCase()
|
||||||
@@ -432,4 +435,21 @@ describe('TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser', () => {
|
|||||||
expect(primaryRevisionRepository.removeByUserUuid).not.toHaveBeenCalled()
|
expect(primaryRevisionRepository.removeByUserUuid).not.toHaveBeenCalled()
|
||||||
expect((secondaryRevisionRepository as RevisionRepositoryInterface).removeByUserUuid).not.toHaveBeenCalled()
|
expect((secondaryRevisionRepository as RevisionRepositoryInterface).removeByUserUuid).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should not migrate revisions if there are already revisions in the secondary database', async () => {
|
||||||
|
;(secondaryRevisionRepository as RevisionRepositoryInterface).countByUserUuid = jest.fn().mockResolvedValueOnce(1)
|
||||||
|
|
||||||
|
const useCase = createUseCase()
|
||||||
|
|
||||||
|
const result = await useCase.execute({
|
||||||
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(result.isFailed()).toBeTruthy()
|
||||||
|
|
||||||
|
expect(primaryRevisionRepository.findByUserUuid).not.toHaveBeenCalled()
|
||||||
|
expect((secondaryRevisionRepository as RevisionRepositoryInterface).insert).not.toHaveBeenCalled()
|
||||||
|
expect(primaryRevisionRepository.removeByUserUuid).not.toHaveBeenCalled()
|
||||||
|
expect((secondaryRevisionRepository as RevisionRepositoryInterface).removeByUserUuid).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
+14
@@ -15,6 +15,8 @@ export class TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser implements
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async execute(dto: TransitionRevisionsFromPrimaryToSecondaryDatabaseForUserDTO): Promise<Result<void>> {
|
async execute(dto: TransitionRevisionsFromPrimaryToSecondaryDatabaseForUserDTO): Promise<Result<void>> {
|
||||||
|
this.logger.info(`Transitioning revisions for user ${dto.userUuid}`)
|
||||||
|
|
||||||
if (this.secondRevisionsRepository === null) {
|
if (this.secondRevisionsRepository === null) {
|
||||||
return Result.fail('Secondary revision repository is not set')
|
return Result.fail('Secondary revision repository is not set')
|
||||||
}
|
}
|
||||||
@@ -31,6 +33,10 @@ export class TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser implements
|
|||||||
return Result.ok()
|
return Result.ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (await this.hasAlreadyDataInSecondaryDatabase(userUuid)) {
|
||||||
|
return Result.fail(`Revisions for user ${userUuid.value} already exist in secondary database`)
|
||||||
|
}
|
||||||
|
|
||||||
const migrationTimeStart = this.timer.getTimestampInMicroseconds()
|
const migrationTimeStart = this.timer.getTimestampInMicroseconds()
|
||||||
|
|
||||||
this.logger.debug(`Transitioning revisions for user ${userUuid.value}`)
|
this.logger.debug(`Transitioning revisions for user ${userUuid.value}`)
|
||||||
@@ -143,6 +149,14 @@ export class TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser implements
|
|||||||
await this.timer.sleep(twoSecondsInMilliseconds)
|
await this.timer.sleep(twoSecondsInMilliseconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async hasAlreadyDataInSecondaryDatabase(userUuid: Uuid): Promise<boolean> {
|
||||||
|
const totalRevisionsCountForUserInSecondary = await (
|
||||||
|
this.secondRevisionsRepository as RevisionRepositoryInterface
|
||||||
|
).countByUserUuid(userUuid)
|
||||||
|
|
||||||
|
return totalRevisionsCountForUserInSecondary > 0
|
||||||
|
}
|
||||||
|
|
||||||
private async isAlreadyMigrated(userUuid: Uuid): Promise<boolean> {
|
private async isAlreadyMigrated(userUuid: Uuid): Promise<boolean> {
|
||||||
const totalRevisionsCountForUserInPrimary = await this.primaryRevisionsRepository.countByUserUuid(userUuid)
|
const totalRevisionsCountForUserInPrimary = await this.primaryRevisionsRepository.countByUserUuid(userUuid)
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.20.40](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.20.39...@standardnotes/scheduler-server@1.20.40) (2023-09-12)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/scheduler-server
|
||||||
|
|
||||||
## [1.20.39](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.20.38...@standardnotes/scheduler-server@1.20.39) (2023-09-08)
|
## [1.20.39](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.20.38...@standardnotes/scheduler-server@1.20.39) (2023-09-08)
|
||||||
|
|
||||||
**Note:** Version bump only for package @standardnotes/scheduler-server
|
**Note:** Version bump only for package @standardnotes/scheduler-server
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/scheduler-server",
|
"name": "@standardnotes/scheduler-server",
|
||||||
"version": "1.20.39",
|
"version": "1.20.40",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,12 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.13.1](https://github.com/standardnotes/server/compare/@standardnotes/security@1.13.0...@standardnotes/security@1.13.1) (2023-09-12)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* adjust transitions to not create revisions during ongoing revisions transition ([106d8f9](https://github.com/standardnotes/server/commit/106d8f9192f630794ca4ddc2c4503f2c6cd196e7))
|
||||||
|
|
||||||
# [1.13.0](https://github.com/standardnotes/server/compare/@standardnotes/security@1.12.2...@standardnotes/security@1.13.0) (2023-09-06)
|
# [1.13.0](https://github.com/standardnotes/server/compare/@standardnotes/security@1.12.2...@standardnotes/security@1.13.0) (2023-09-06)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/security",
|
"name": "@standardnotes/security",
|
||||||
"version": "1.13.0",
|
"version": "1.13.1",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -25,4 +25,5 @@ export type CrossServiceTokenData = {
|
|||||||
}
|
}
|
||||||
extensionKey?: string
|
extensionKey?: string
|
||||||
ongoing_transition?: boolean
|
ongoing_transition?: boolean
|
||||||
|
ongoing_revisions_transition?: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,12 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.95.5](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.95.4...@standardnotes/syncing-server@1.95.5) (2023-09-12)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* adjust transitions to not create revisions during ongoing revisions transition ([106d8f9](https://github.com/standardnotes/syncing-server-js/commit/106d8f9192f630794ca4ddc2c4503f2c6cd196e7))
|
||||||
|
|
||||||
## [1.95.4](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.95.3...@standardnotes/syncing-server@1.95.4) (2023-09-12)
|
## [1.95.4](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.95.3...@standardnotes/syncing-server@1.95.4) (2023-09-12)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/syncing-server",
|
"name": "@standardnotes/syncing-server",
|
||||||
"version": "1.95.4",
|
"version": "1.95.5",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ describe('SaveItems', () => {
|
|||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
itemHashes: [itemHash1],
|
itemHashes: [itemHash1],
|
||||||
userUuid: 'user-uuid',
|
userUuid: 'user-uuid',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
apiVersion: '1',
|
apiVersion: '1',
|
||||||
readOnlyAccess: false,
|
readOnlyAccess: false,
|
||||||
sessionUuid: 'session-uuid',
|
sessionUuid: 'session-uuid',
|
||||||
@@ -96,6 +97,7 @@ describe('SaveItems', () => {
|
|||||||
expect(saveNewItem.execute).toHaveBeenCalledWith({
|
expect(saveNewItem.execute).toHaveBeenCalledWith({
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
userUuid: 'user-uuid',
|
userUuid: 'user-uuid',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
sessionUuid: 'session-uuid',
|
sessionUuid: 'session-uuid',
|
||||||
roleNames: ['CORE_USER'],
|
roleNames: ['CORE_USER'],
|
||||||
})
|
})
|
||||||
@@ -109,6 +111,7 @@ describe('SaveItems', () => {
|
|||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
itemHashes: [itemHash1],
|
itemHashes: [itemHash1],
|
||||||
userUuid: 'user-uuid',
|
userUuid: 'user-uuid',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
apiVersion: '1',
|
apiVersion: '1',
|
||||||
readOnlyAccess: false,
|
readOnlyAccess: false,
|
||||||
sessionUuid: 'session-uuid',
|
sessionUuid: 'session-uuid',
|
||||||
@@ -133,6 +136,7 @@ describe('SaveItems', () => {
|
|||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
itemHashes: [itemHash1],
|
itemHashes: [itemHash1],
|
||||||
userUuid: 'user-uuid',
|
userUuid: 'user-uuid',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
apiVersion: '1',
|
apiVersion: '1',
|
||||||
readOnlyAccess: false,
|
readOnlyAccess: false,
|
||||||
sessionUuid: 'session-uuid',
|
sessionUuid: 'session-uuid',
|
||||||
@@ -155,6 +159,7 @@ describe('SaveItems', () => {
|
|||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
itemHashes: [itemHash1],
|
itemHashes: [itemHash1],
|
||||||
userUuid: 'user-uuid',
|
userUuid: 'user-uuid',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
apiVersion: '1',
|
apiVersion: '1',
|
||||||
readOnlyAccess: true,
|
readOnlyAccess: true,
|
||||||
sessionUuid: 'session-uuid',
|
sessionUuid: 'session-uuid',
|
||||||
@@ -178,6 +183,7 @@ describe('SaveItems', () => {
|
|||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
itemHashes: [itemHash1],
|
itemHashes: [itemHash1],
|
||||||
userUuid: 'user-uuid',
|
userUuid: 'user-uuid',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
apiVersion: '1',
|
apiVersion: '1',
|
||||||
readOnlyAccess: false,
|
readOnlyAccess: false,
|
||||||
sessionUuid: 'session-uuid',
|
sessionUuid: 'session-uuid',
|
||||||
@@ -197,6 +203,7 @@ describe('SaveItems', () => {
|
|||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
itemHashes: [itemHash1],
|
itemHashes: [itemHash1],
|
||||||
userUuid: 'user-uuid',
|
userUuid: 'user-uuid',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
apiVersion: '1',
|
apiVersion: '1',
|
||||||
readOnlyAccess: false,
|
readOnlyAccess: false,
|
||||||
sessionUuid: 'session-uuid',
|
sessionUuid: 'session-uuid',
|
||||||
@@ -215,6 +222,7 @@ describe('SaveItems', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
itemHashes: [itemHash1],
|
itemHashes: [itemHash1],
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
apiVersion: '1',
|
apiVersion: '1',
|
||||||
readOnlyAccess: false,
|
readOnlyAccess: false,
|
||||||
@@ -229,6 +237,7 @@ describe('SaveItems', () => {
|
|||||||
existingItem: savedItem,
|
existingItem: savedItem,
|
||||||
sessionUuid: 'session-uuid',
|
sessionUuid: 'session-uuid',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: ['CORE_USER'],
|
roleNames: ['CORE_USER'],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -242,6 +251,7 @@ describe('SaveItems', () => {
|
|||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
itemHashes: [itemHash1],
|
itemHashes: [itemHash1],
|
||||||
userUuid: 'user-uuid',
|
userUuid: 'user-uuid',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
apiVersion: '1',
|
apiVersion: '1',
|
||||||
readOnlyAccess: false,
|
readOnlyAccess: false,
|
||||||
sessionUuid: 'session-uuid',
|
sessionUuid: 'session-uuid',
|
||||||
@@ -267,6 +277,7 @@ describe('SaveItems', () => {
|
|||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
itemHashes: [ItemHash.create({ ...itemHash1.props, uuid: 'invalid-uuid' }).getValue()],
|
itemHashes: [ItemHash.create({ ...itemHash1.props, uuid: 'invalid-uuid' }).getValue()],
|
||||||
userUuid: 'user-uuid',
|
userUuid: 'user-uuid',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
apiVersion: '1',
|
apiVersion: '1',
|
||||||
readOnlyAccess: false,
|
readOnlyAccess: false,
|
||||||
sessionUuid: 'session-uuid',
|
sessionUuid: 'session-uuid',
|
||||||
@@ -313,6 +324,7 @@ describe('SaveItems', () => {
|
|||||||
ItemHash.create({ ...itemHash1.props, uuid: '00000000-0000-0000-0000-000000000003' }).getValue(),
|
ItemHash.create({ ...itemHash1.props, uuid: '00000000-0000-0000-0000-000000000003' }).getValue(),
|
||||||
],
|
],
|
||||||
userUuid: 'user-uuid',
|
userUuid: 'user-uuid',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
apiVersion: '2',
|
apiVersion: '2',
|
||||||
readOnlyAccess: false,
|
readOnlyAccess: false,
|
||||||
sessionUuid: 'session-uuid',
|
sessionUuid: 'session-uuid',
|
||||||
@@ -330,6 +342,7 @@ describe('SaveItems', () => {
|
|||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
itemHashes: [itemHash1],
|
itemHashes: [itemHash1],
|
||||||
userUuid: 'user-uuid',
|
userUuid: 'user-uuid',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
apiVersion: '2',
|
apiVersion: '2',
|
||||||
readOnlyAccess: false,
|
readOnlyAccess: false,
|
||||||
sessionUuid: 'session-uuid',
|
sessionUuid: 'session-uuid',
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ export class SaveItems implements UseCaseInterface<SaveItemsResult> {
|
|||||||
sessionUuid: dto.sessionUuid,
|
sessionUuid: dto.sessionUuid,
|
||||||
performingUserUuid: dto.userUuid,
|
performingUserUuid: dto.userUuid,
|
||||||
roleNames: dto.roleNames,
|
roleNames: dto.roleNames,
|
||||||
|
onGoingRevisionsTransition: dto.onGoingRevisionsTransition,
|
||||||
})
|
})
|
||||||
if (udpatedItemOrError.isFailed()) {
|
if (udpatedItemOrError.isFailed()) {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
@@ -109,6 +110,7 @@ export class SaveItems implements UseCaseInterface<SaveItemsResult> {
|
|||||||
itemHash,
|
itemHash,
|
||||||
sessionUuid: dto.sessionUuid,
|
sessionUuid: dto.sessionUuid,
|
||||||
roleNames: dto.roleNames,
|
roleNames: dto.roleNames,
|
||||||
|
onGoingRevisionsTransition: dto.onGoingRevisionsTransition,
|
||||||
})
|
})
|
||||||
if (newItemOrError.isFailed()) {
|
if (newItemOrError.isFailed()) {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
|
|||||||
@@ -8,4 +8,5 @@ export interface SaveItemsDTO {
|
|||||||
sessionUuid: string | null
|
sessionUuid: string | null
|
||||||
snjsVersion: string
|
snjsVersion: string
|
||||||
roleNames: string[]
|
roleNames: string[]
|
||||||
|
onGoingRevisionsTransition: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -112,6 +113,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: true,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -132,6 +134,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -150,6 +153,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -170,6 +174,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -190,6 +195,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -208,6 +214,7 @@ describe('SaveNewItem', () => {
|
|||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(result.isFailed()).toBeTruthy()
|
expect(result.isFailed()).toBeTruthy()
|
||||||
@@ -218,6 +225,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
roleNames: ['invalid'],
|
roleNames: ['invalid'],
|
||||||
@@ -231,6 +239,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-00000000000',
|
sessionUuid: '00000000-0000-0000-0000-00000000000',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -249,6 +258,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -267,6 +277,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -285,6 +296,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -305,6 +317,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -328,6 +341,7 @@ describe('SaveNewItem', () => {
|
|||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(result.isFailed()).toBeTruthy()
|
expect(result.isFailed()).toBeTruthy()
|
||||||
@@ -344,6 +358,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -371,6 +386,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -393,6 +409,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -412,6 +429,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
@@ -435,6 +453,7 @@ describe('SaveNewItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
sessionUuid: '00000000-0000-0000-0000-000000000001',
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
|
|||||||
@@ -145,13 +145,15 @@ export class SaveNewItem implements UseCaseInterface<Item> {
|
|||||||
await itemRepository.save(newItem)
|
await itemRepository.save(newItem)
|
||||||
|
|
||||||
if (contentType.value !== null && [ContentType.TYPES.Note, ContentType.TYPES.File].includes(contentType.value)) {
|
if (contentType.value !== null && [ContentType.TYPES.Note, ContentType.TYPES.File].includes(contentType.value)) {
|
||||||
await this.domainEventPublisher.publish(
|
if (!dto.onGoingRevisionsTransition) {
|
||||||
this.domainEventFactory.createItemRevisionCreationRequested({
|
await this.domainEventPublisher.publish(
|
||||||
itemUuid: newItem.id.toString(),
|
this.domainEventFactory.createItemRevisionCreationRequested({
|
||||||
userUuid: newItem.props.userUuid.value,
|
itemUuid: newItem.id.toString(),
|
||||||
roleNames: dto.roleNames,
|
userUuid: newItem.props.userUuid.value,
|
||||||
}),
|
roleNames: dto.roleNames,
|
||||||
)
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (duplicateOf) {
|
if (duplicateOf) {
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ export interface SaveNewItemDTO {
|
|||||||
roleNames: string[]
|
roleNames: string[]
|
||||||
itemHash: ItemHash
|
itemHash: ItemHash
|
||||||
sessionUuid: string | null
|
sessionUuid: string | null
|
||||||
|
onGoingRevisionsTransition: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ describe('SyncItems', () => {
|
|||||||
it('should sync items', async () => {
|
it('should sync items', async () => {
|
||||||
const result = await createUseCase().execute({
|
const result = await createUseCase().execute({
|
||||||
userUuid: '1-2-3',
|
userUuid: '1-2-3',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHashes: [itemHash],
|
itemHashes: [itemHash],
|
||||||
computeIntegrityHash: false,
|
computeIntegrityHash: false,
|
||||||
syncToken: 'foo',
|
syncToken: 'foo',
|
||||||
@@ -178,6 +179,7 @@ describe('SyncItems', () => {
|
|||||||
expect(saveItemsUseCase.execute).toHaveBeenCalledWith({
|
expect(saveItemsUseCase.execute).toHaveBeenCalledWith({
|
||||||
itemHashes: [itemHash],
|
itemHashes: [itemHash],
|
||||||
userUuid: '1-2-3',
|
userUuid: '1-2-3',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
apiVersion: '20200115',
|
apiVersion: '20200115',
|
||||||
snjsVersion: '1.2.3',
|
snjsVersion: '1.2.3',
|
||||||
roleNames: [RoleName.NAMES.CoreUser],
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
@@ -189,6 +191,7 @@ describe('SyncItems', () => {
|
|||||||
it('should sync items and return items keys on top for first sync that is not a shared vault exclusive sync', async () => {
|
it('should sync items and return items keys on top for first sync that is not a shared vault exclusive sync', async () => {
|
||||||
const result = await createUseCase().execute({
|
const result = await createUseCase().execute({
|
||||||
userUuid: '1-2-3',
|
userUuid: '1-2-3',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHashes: [itemHash],
|
itemHashes: [itemHash],
|
||||||
computeIntegrityHash: false,
|
computeIntegrityHash: false,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
@@ -215,6 +218,7 @@ describe('SyncItems', () => {
|
|||||||
it('should sync items and not return items keys on top for first sync that is a shared vault exclusive sync', async () => {
|
it('should sync items and not return items keys on top for first sync that is a shared vault exclusive sync', async () => {
|
||||||
const result = await createUseCase().execute({
|
const result = await createUseCase().execute({
|
||||||
userUuid: '1-2-3',
|
userUuid: '1-2-3',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHashes: [itemHash],
|
itemHashes: [itemHash],
|
||||||
computeIntegrityHash: false,
|
computeIntegrityHash: false,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
@@ -266,6 +270,7 @@ describe('SyncItems', () => {
|
|||||||
|
|
||||||
const result = await createUseCase().execute({
|
const result = await createUseCase().execute({
|
||||||
userUuid: '1-2-3',
|
userUuid: '1-2-3',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHashes: [itemHash],
|
itemHashes: [itemHash],
|
||||||
computeIntegrityHash: false,
|
computeIntegrityHash: false,
|
||||||
syncToken: 'foo',
|
syncToken: 'foo',
|
||||||
@@ -306,6 +311,7 @@ describe('SyncItems', () => {
|
|||||||
|
|
||||||
const result = await createUseCase().execute({
|
const result = await createUseCase().execute({
|
||||||
userUuid: '1-2-3',
|
userUuid: '1-2-3',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHashes: [itemHash],
|
itemHashes: [itemHash],
|
||||||
computeIntegrityHash: false,
|
computeIntegrityHash: false,
|
||||||
syncToken: 'foo',
|
syncToken: 'foo',
|
||||||
@@ -327,6 +333,7 @@ describe('SyncItems', () => {
|
|||||||
|
|
||||||
const result = await createUseCase().execute({
|
const result = await createUseCase().execute({
|
||||||
userUuid: '1-2-3',
|
userUuid: '1-2-3',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHashes: [itemHash],
|
itemHashes: [itemHash],
|
||||||
computeIntegrityHash: false,
|
computeIntegrityHash: false,
|
||||||
syncToken: 'foo',
|
syncToken: 'foo',
|
||||||
@@ -346,6 +353,7 @@ describe('SyncItems', () => {
|
|||||||
it('should return error if role names are invalid', async () => {
|
it('should return error if role names are invalid', async () => {
|
||||||
const result = await createUseCase().execute({
|
const result = await createUseCase().execute({
|
||||||
userUuid: '1-2-3',
|
userUuid: '1-2-3',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHashes: [itemHash],
|
itemHashes: [itemHash],
|
||||||
computeIntegrityHash: false,
|
computeIntegrityHash: false,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
@@ -365,6 +373,7 @@ describe('SyncItems', () => {
|
|||||||
|
|
||||||
const result = await createUseCase().execute({
|
const result = await createUseCase().execute({
|
||||||
userUuid: '1-2-3',
|
userUuid: '1-2-3',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHashes: [itemHash],
|
itemHashes: [itemHash],
|
||||||
computeIntegrityHash: false,
|
computeIntegrityHash: false,
|
||||||
syncToken: 'foo',
|
syncToken: 'foo',
|
||||||
@@ -386,6 +395,7 @@ describe('SyncItems', () => {
|
|||||||
|
|
||||||
const result = await createUseCase().execute({
|
const result = await createUseCase().execute({
|
||||||
userUuid: '1-2-3',
|
userUuid: '1-2-3',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHashes: [itemHash],
|
itemHashes: [itemHash],
|
||||||
computeIntegrityHash: false,
|
computeIntegrityHash: false,
|
||||||
syncToken: 'foo',
|
syncToken: 'foo',
|
||||||
@@ -407,6 +417,7 @@ describe('SyncItems', () => {
|
|||||||
|
|
||||||
const result = await createUseCase().execute({
|
const result = await createUseCase().execute({
|
||||||
userUuid: '1-2-3',
|
userUuid: '1-2-3',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHashes: [itemHash],
|
itemHashes: [itemHash],
|
||||||
computeIntegrityHash: false,
|
computeIntegrityHash: false,
|
||||||
syncToken: 'foo',
|
syncToken: 'foo',
|
||||||
@@ -428,6 +439,7 @@ describe('SyncItems', () => {
|
|||||||
|
|
||||||
const result = await createUseCase().execute({
|
const result = await createUseCase().execute({
|
||||||
userUuid: '1-2-3',
|
userUuid: '1-2-3',
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHashes: [itemHash],
|
itemHashes: [itemHash],
|
||||||
computeIntegrityHash: false,
|
computeIntegrityHash: false,
|
||||||
syncToken: 'foo',
|
syncToken: 'foo',
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export class SyncItems implements UseCaseInterface<SyncItemsResponse> {
|
|||||||
sessionUuid: dto.sessionUuid,
|
sessionUuid: dto.sessionUuid,
|
||||||
snjsVersion: dto.snjsVersion,
|
snjsVersion: dto.snjsVersion,
|
||||||
roleNames: dto.roleNames,
|
roleNames: dto.roleNames,
|
||||||
|
onGoingRevisionsTransition: dto.onGoingRevisionsTransition,
|
||||||
})
|
})
|
||||||
if (saveItemsResultOrError.isFailed()) {
|
if (saveItemsResultOrError.isFailed()) {
|
||||||
return Result.fail(saveItemsResultOrError.getError())
|
return Result.fail(saveItemsResultOrError.getError())
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ export type SyncItemsDTO = {
|
|||||||
snjsVersion: string
|
snjsVersion: string
|
||||||
readOnlyAccess: boolean
|
readOnlyAccess: boolean
|
||||||
sessionUuid: string | null
|
sessionUuid: string | null
|
||||||
|
onGoingRevisionsTransition: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
+40
@@ -140,6 +140,23 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
|
itemHash: itemHash1,
|
||||||
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
roleNames: [RoleName.NAMES.CoreUser],
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(result.isFailed()).toBeFalsy()
|
||||||
|
expect(itemRepository.save).toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should not create a revision if user has an ongoin revisions transition', async () => {
|
||||||
|
const useCase = createUseCase()
|
||||||
|
|
||||||
|
const result = await useCase.execute({
|
||||||
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: true,
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
@@ -155,6 +172,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
sessionUuid: 'invalid-uuid',
|
sessionUuid: 'invalid-uuid',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
@@ -169,6 +187,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
@@ -183,6 +202,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash: ItemHash.create({
|
itemHash: ItemHash.create({
|
||||||
...itemHash1.props,
|
...itemHash1.props,
|
||||||
content_type: 'invalid',
|
content_type: 'invalid',
|
||||||
@@ -200,6 +220,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash: ItemHash.create({
|
itemHash: ItemHash.create({
|
||||||
...itemHash1.props,
|
...itemHash1.props,
|
||||||
deleted: true,
|
deleted: true,
|
||||||
@@ -224,6 +245,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash: ItemHash.create({
|
itemHash: ItemHash.create({
|
||||||
...itemHash1.props,
|
...itemHash1.props,
|
||||||
duplicate_of: '00000000-0000-0000-0000-000000000001',
|
duplicate_of: '00000000-0000-0000-0000-000000000001',
|
||||||
@@ -243,6 +265,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash: ItemHash.create({
|
itemHash: ItemHash.create({
|
||||||
...itemHash1.props,
|
...itemHash1.props,
|
||||||
duplicate_of: 'invalid-uuid',
|
duplicate_of: 'invalid-uuid',
|
||||||
@@ -260,6 +283,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash: ItemHash.create({
|
itemHash: ItemHash.create({
|
||||||
...itemHash1.props,
|
...itemHash1.props,
|
||||||
updated_at_timestamp: 123,
|
updated_at_timestamp: 123,
|
||||||
@@ -279,6 +303,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash: ItemHash.create({
|
itemHash: ItemHash.create({
|
||||||
...itemHash1.props,
|
...itemHash1.props,
|
||||||
created_at: undefined,
|
created_at: undefined,
|
||||||
@@ -302,6 +327,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash: ItemHash.create({
|
itemHash: ItemHash.create({
|
||||||
...itemHash1.props,
|
...itemHash1.props,
|
||||||
created_at_timestamp: 123,
|
created_at_timestamp: 123,
|
||||||
@@ -327,6 +353,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash: ItemHash.create({
|
itemHash: ItemHash.create({
|
||||||
...itemHash1.props,
|
...itemHash1.props,
|
||||||
created_at_timestamp: 123,
|
created_at_timestamp: 123,
|
||||||
@@ -346,6 +373,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash: itemHash1,
|
itemHash: itemHash1,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: 'invalid-uuid',
|
performingUserUuid: 'invalid-uuid',
|
||||||
@@ -365,6 +393,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash,
|
itemHash,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
@@ -392,6 +421,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash,
|
itemHash,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
@@ -430,6 +460,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash,
|
itemHash,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
@@ -459,6 +490,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash,
|
itemHash,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
@@ -480,6 +512,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash,
|
itemHash,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
@@ -512,6 +545,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash,
|
itemHash,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
@@ -547,6 +581,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash,
|
itemHash,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
@@ -569,6 +604,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash,
|
itemHash,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
@@ -589,6 +625,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash,
|
itemHash,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
@@ -611,6 +648,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash,
|
itemHash,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
@@ -632,6 +670,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash,
|
itemHash,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
@@ -655,6 +694,7 @@ describe('UpdateExistingItem', () => {
|
|||||||
|
|
||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
existingItem: item1,
|
existingItem: item1,
|
||||||
|
onGoingRevisionsTransition: false,
|
||||||
itemHash,
|
itemHash,
|
||||||
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
sessionUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
performingUserUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
|||||||
+9
-7
@@ -191,13 +191,15 @@ export class UpdateExistingItem implements UseCaseInterface<Item> {
|
|||||||
dto.existingItem.props.contentType.value !== null &&
|
dto.existingItem.props.contentType.value !== null &&
|
||||||
[ContentType.TYPES.Note, ContentType.TYPES.File].includes(dto.existingItem.props.contentType.value)
|
[ContentType.TYPES.Note, ContentType.TYPES.File].includes(dto.existingItem.props.contentType.value)
|
||||||
) {
|
) {
|
||||||
await this.domainEventPublisher.publish(
|
if (!dto.onGoingRevisionsTransition) {
|
||||||
this.domainEventFactory.createItemRevisionCreationRequested({
|
await this.domainEventPublisher.publish(
|
||||||
itemUuid: dto.existingItem.id.toString(),
|
this.domainEventFactory.createItemRevisionCreationRequested({
|
||||||
userUuid: dto.existingItem.props.userUuid.value,
|
itemUuid: dto.existingItem.id.toString(),
|
||||||
roleNames: dto.roleNames,
|
userUuid: dto.existingItem.props.userUuid.value,
|
||||||
}),
|
roleNames: dto.roleNames,
|
||||||
)
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
@@ -7,4 +7,5 @@ export interface UpdateExistingItemDTO {
|
|||||||
sessionUuid: string | null
|
sessionUuid: string | null
|
||||||
performingUserUuid: string
|
performingUserUuid: string
|
||||||
roleNames: string[]
|
roleNames: string[]
|
||||||
|
onGoingRevisionsTransition: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-5
@@ -107,7 +107,7 @@ describe('TransitionItemsFromPrimaryToSecondaryDatabaseForUser', () => {
|
|||||||
secondaryItemRepository = {} as jest.Mocked<ItemRepositoryInterface>
|
secondaryItemRepository = {} as jest.Mocked<ItemRepositoryInterface>
|
||||||
secondaryItemRepository.save = jest.fn().mockResolvedValue(undefined)
|
secondaryItemRepository.save = jest.fn().mockResolvedValue(undefined)
|
||||||
secondaryItemRepository.deleteByUserUuid = jest.fn().mockResolvedValue(undefined)
|
secondaryItemRepository.deleteByUserUuid = jest.fn().mockResolvedValue(undefined)
|
||||||
secondaryItemRepository.countAll = jest.fn().mockResolvedValue(2)
|
secondaryItemRepository.countAll = jest.fn().mockReturnValueOnce(0).mockReturnValueOnce(2)
|
||||||
secondaryItemRepository.findByUuid = jest
|
secondaryItemRepository.findByUuid = jest
|
||||||
.fn()
|
.fn()
|
||||||
.mockResolvedValueOnce(secondaryItem1)
|
.mockResolvedValueOnce(secondaryItem1)
|
||||||
@@ -314,7 +314,10 @@ describe('TransitionItemsFromPrimaryToSecondaryDatabaseForUser', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should fail integrity check if the item count is not the same in both databases', async () => {
|
it('should fail integrity check if the item count is not the same in both databases', async () => {
|
||||||
;(secondaryItemRepository as ItemRepositoryInterface).countAll = jest.fn().mockResolvedValue(1)
|
;(secondaryItemRepository as ItemRepositoryInterface).countAll = jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValueOnce(0)
|
||||||
|
.mockResolvedValueOnce(1)
|
||||||
|
|
||||||
const useCase = createUseCase()
|
const useCase = createUseCase()
|
||||||
|
|
||||||
@@ -329,7 +332,7 @@ describe('TransitionItemsFromPrimaryToSecondaryDatabaseForUser', () => {
|
|||||||
|
|
||||||
expect(primaryItemRepository.countAll).toHaveBeenCalledTimes(3)
|
expect(primaryItemRepository.countAll).toHaveBeenCalledTimes(3)
|
||||||
expect(primaryItemRepository.countAll).toHaveBeenCalledWith({ userUuid: '00000000-0000-0000-0000-000000000000' })
|
expect(primaryItemRepository.countAll).toHaveBeenCalledWith({ userUuid: '00000000-0000-0000-0000-000000000000' })
|
||||||
expect((secondaryItemRepository as ItemRepositoryInterface).countAll).toHaveBeenCalledTimes(1)
|
expect((secondaryItemRepository as ItemRepositoryInterface).countAll).toHaveBeenCalledTimes(2)
|
||||||
expect(primaryItemRepository.deleteByUserUuid).not.toHaveBeenCalled()
|
expect(primaryItemRepository.deleteByUserUuid).not.toHaveBeenCalled()
|
||||||
expect((secondaryItemRepository as ItemRepositoryInterface).deleteByUserUuid).toHaveBeenCalledTimes(1)
|
expect((secondaryItemRepository as ItemRepositoryInterface).deleteByUserUuid).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
@@ -351,13 +354,16 @@ describe('TransitionItemsFromPrimaryToSecondaryDatabaseForUser', () => {
|
|||||||
|
|
||||||
expect(primaryItemRepository.countAll).toHaveBeenCalledTimes(3)
|
expect(primaryItemRepository.countAll).toHaveBeenCalledTimes(3)
|
||||||
expect(primaryItemRepository.countAll).toHaveBeenCalledWith({ userUuid: '00000000-0000-0000-0000-000000000000' })
|
expect(primaryItemRepository.countAll).toHaveBeenCalledWith({ userUuid: '00000000-0000-0000-0000-000000000000' })
|
||||||
expect((secondaryItemRepository as ItemRepositoryInterface).countAll).toHaveBeenCalledTimes(1)
|
expect((secondaryItemRepository as ItemRepositoryInterface).countAll).toHaveBeenCalledTimes(2)
|
||||||
expect(primaryItemRepository.deleteByUserUuid).not.toHaveBeenCalled()
|
expect(primaryItemRepository.deleteByUserUuid).not.toHaveBeenCalled()
|
||||||
expect((secondaryItemRepository as ItemRepositoryInterface).deleteByUserUuid).toHaveBeenCalledTimes(1)
|
expect((secondaryItemRepository as ItemRepositoryInterface).deleteByUserUuid).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should fail if an error is thrown during integrity check between primary and secondary database', async () => {
|
it('should fail if an error is thrown during integrity check between primary and secondary database', async () => {
|
||||||
;(secondaryItemRepository as ItemRepositoryInterface).countAll = jest.fn().mockRejectedValue(new Error('error'))
|
;(secondaryItemRepository as ItemRepositoryInterface).countAll = jest
|
||||||
|
.fn()
|
||||||
|
.mockReturnValueOnce(0)
|
||||||
|
.mockRejectedValue(new Error('error'))
|
||||||
|
|
||||||
const useCase = createUseCase()
|
const useCase = createUseCase()
|
||||||
|
|
||||||
@@ -391,4 +397,21 @@ describe('TransitionItemsFromPrimaryToSecondaryDatabaseForUser', () => {
|
|||||||
expect(primaryItemRepository.deleteByUserUuid).not.toHaveBeenCalled()
|
expect(primaryItemRepository.deleteByUserUuid).not.toHaveBeenCalled()
|
||||||
expect((secondaryItemRepository as ItemRepositoryInterface).deleteByUserUuid).not.toHaveBeenCalled()
|
expect((secondaryItemRepository as ItemRepositoryInterface).deleteByUserUuid).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should not migrate items if there are items in the secondary database', async () => {
|
||||||
|
;(secondaryItemRepository as ItemRepositoryInterface).countAll = jest.fn().mockResolvedValue(1)
|
||||||
|
|
||||||
|
const useCase = createUseCase()
|
||||||
|
|
||||||
|
const result = await useCase.execute({
|
||||||
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(result.isFailed()).toBeTruthy()
|
||||||
|
|
||||||
|
expect(primaryItemRepository.findAll).not.toHaveBeenCalled()
|
||||||
|
expect((secondaryItemRepository as ItemRepositoryInterface).save).not.toHaveBeenCalled()
|
||||||
|
expect(primaryItemRepository.deleteByUserUuid).not.toHaveBeenCalled()
|
||||||
|
expect((secondaryItemRepository as ItemRepositoryInterface).deleteByUserUuid).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
+14
@@ -16,6 +16,8 @@ export class TransitionItemsFromPrimaryToSecondaryDatabaseForUser implements Use
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async execute(dto: TransitionItemsFromPrimaryToSecondaryDatabaseForUserDTO): Promise<Result<void>> {
|
async execute(dto: TransitionItemsFromPrimaryToSecondaryDatabaseForUserDTO): Promise<Result<void>> {
|
||||||
|
this.logger.info(`Transitioning items for user ${dto.userUuid}`)
|
||||||
|
|
||||||
if (this.secondaryItemRepository === null) {
|
if (this.secondaryItemRepository === null) {
|
||||||
return Result.fail('Secondary item repository is not set')
|
return Result.fail('Secondary item repository is not set')
|
||||||
}
|
}
|
||||||
@@ -32,6 +34,10 @@ export class TransitionItemsFromPrimaryToSecondaryDatabaseForUser implements Use
|
|||||||
return Result.ok()
|
return Result.ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (await this.hasAlreadyDataInSecondaryDatabase(userUuid)) {
|
||||||
|
return Result.fail(`Items for user ${userUuid.value} already exist in secondary database`)
|
||||||
|
}
|
||||||
|
|
||||||
const migrationTimeStart = this.timer.getTimestampInMicroseconds()
|
const migrationTimeStart = this.timer.getTimestampInMicroseconds()
|
||||||
|
|
||||||
const migrationResult = await this.migrateItemsForUser(userUuid)
|
const migrationResult = await this.migrateItemsForUser(userUuid)
|
||||||
@@ -79,6 +85,14 @@ export class TransitionItemsFromPrimaryToSecondaryDatabaseForUser implements Use
|
|||||||
return Result.ok()
|
return Result.ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async hasAlreadyDataInSecondaryDatabase(userUuid: Uuid): Promise<boolean> {
|
||||||
|
const totalItemsCountForUser = await (this.secondaryItemRepository as ItemRepositoryInterface).countAll({
|
||||||
|
userUuid: userUuid.value,
|
||||||
|
})
|
||||||
|
|
||||||
|
return totalItemsCountForUser > 0
|
||||||
|
}
|
||||||
|
|
||||||
private async isAlreadyMigrated(userUuid: Uuid): Promise<boolean> {
|
private async isAlreadyMigrated(userUuid: Uuid): Promise<boolean> {
|
||||||
const totalItemsCountForUser = await this.primaryItemRepository.countAll({ userUuid: userUuid.value })
|
const totalItemsCountForUser = await this.primaryItemRepository.countAll({ userUuid: userUuid.value })
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ export class BaseItemsController extends BaseHttpController {
|
|||||||
readOnlyAccess: response.locals.readOnlyAccess,
|
readOnlyAccess: response.locals.readOnlyAccess,
|
||||||
sessionUuid: response.locals.session ? response.locals.session.uuid : null,
|
sessionUuid: response.locals.session ? response.locals.session.uuid : null,
|
||||||
sharedVaultUuids,
|
sharedVaultUuids,
|
||||||
|
onGoingRevisionsTransition: response.locals.onGoingRevisionsTransition,
|
||||||
})
|
})
|
||||||
if (syncResult.isFailed()) {
|
if (syncResult.isFailed()) {
|
||||||
return this.json({ error: { message: syncResult.getError() } }, HttpStatusCode.BadRequest)
|
return this.json({ error: { message: syncResult.getError() } }, HttpStatusCode.BadRequest)
|
||||||
|
|||||||
+1
@@ -30,6 +30,7 @@ export class InversifyExpressAuthMiddleware extends BaseMiddleware {
|
|||||||
response.locals.readOnlyAccess = decodedToken.session?.readonly_access ?? false
|
response.locals.readOnlyAccess = decodedToken.session?.readonly_access ?? false
|
||||||
response.locals.sharedVaultOwnerContext = decodedToken.shared_vault_owner_context
|
response.locals.sharedVaultOwnerContext = decodedToken.shared_vault_owner_context
|
||||||
response.locals.ongoingTransition = decodedToken.ongoing_transition
|
response.locals.ongoingTransition = decodedToken.ongoing_transition
|
||||||
|
response.locals.onGoingRevisionsTransition = decodedToken.ongoing_revisions_transition
|
||||||
|
|
||||||
return next()
|
return next()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.10.37](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.10.36...@standardnotes/websockets-server@1.10.37) (2023-09-12)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/websockets-server
|
||||||
|
|
||||||
## [1.10.36](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.10.35...@standardnotes/websockets-server@1.10.36) (2023-09-08)
|
## [1.10.36](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.10.35...@standardnotes/websockets-server@1.10.36) (2023-09-08)
|
||||||
|
|
||||||
**Note:** Version bump only for package @standardnotes/websockets-server
|
**Note:** Version bump only for package @standardnotes/websockets-server
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/websockets-server",
|
"name": "@standardnotes/websockets-server",
|
||||||
"version": "1.10.36",
|
"version": "1.10.37",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user