Compare commits

..

87 Commits

Author SHA1 Message Date
standardci 6778a80f21 chore(release): publish new version
- @standardnotes/analytics@2.26.13
 - @standardnotes/api-gateway@1.74.11
 - @standardnotes/auth-server@1.142.0
 - @standardnotes/domain-events-infra@1.12.29
 - @standardnotes/domain-events@2.126.0
 - @standardnotes/event-store@1.11.41
 - @standardnotes/files-server@1.22.20
 - @standardnotes/home-server@1.15.56
 - @standardnotes/revisions-server@1.34.0
 - @standardnotes/scheduler-server@1.20.45
 - @standardnotes/syncing-server@1.96.0
 - @standardnotes/websockets-server@1.10.42
2023-09-15 09:49:09 +00:00
Karol Sójko d4d49454a6 feat: add skipping verified transitions (#827)
* fix(syncing-server): remove transitioning individual users

* feat: add skipping verified transitions

* fix(auth): remove unused use case
2023-09-15 11:31:52 +02:00
standardci 04b52e6773 chore(release): publish new version
- @standardnotes/auth-server@1.141.14
 - @standardnotes/home-server@1.15.55
 - @standardnotes/syncing-server@1.95.19
2023-09-15 08:53:53 +00:00
Karol Sójko 2a1859e4be fix(auth): remove extensive logs from updating transitions 2023-09-15 10:35:50 +02:00
Karol Sójko dd9a9c68cb fix(auth): upgrade simplewebauthn dependency (#826) 2023-09-15 10:35:14 +02:00
Karol Sójko 9147ff5d49 fix(syncing-server): remove unused index in mongodb 2023-09-14 14:18:20 +02:00
standardci 503b84531b chore(release): publish new version
- @standardnotes/auth-server@1.141.13
 - @standardnotes/home-server@1.15.54
 - @standardnotes/revisions-server@1.33.21
 - @standardnotes/syncing-server@1.95.18
2023-09-14 10:16:54 +00:00
Karol Sójko fe8ca828fb fix(auth): set ttl for started and not picked up transitions to 10h 2023-09-14 11:57:21 +02:00
Karol Sójko 03a4a3f2ab fix: skip already updated items and revisions in integrity check (#825) 2023-09-14 11:54:30 +02:00
Karol Sójko 3a8607d146 fix(syncing-server): updating with missing creation date (#824) 2023-09-14 11:45:24 +02:00
standardci 93b6e65554 chore(release): publish new version
- @standardnotes/auth-server@1.141.12
 - @standardnotes/home-server@1.15.53
2023-09-13 10:22:30 +00:00
Karol Sójko 5984e4c3e7 fix(auth): remove re-triggering revisions transition 2023-09-13 11:51:34 +02:00
standardci b4257c10ea chore(release): publish new version
- @standardnotes/auth-server@1.141.11
 - @standardnotes/home-server@1.15.52
2023-09-13 09:41:28 +00:00
Karol Sójko c164bde847 fix(auth): passing transition timestamp 2023-09-13 11:03:32 +02:00
standardci 883df939dd chore(release): publish new version
- @standardnotes/api-gateway@1.74.10
 - @standardnotes/auth-server@1.141.10
 - @standardnotes/home-server@1.15.51
 - @standardnotes/revisions-server@1.33.20
 - @standardnotes/syncing-server@1.95.17
2023-09-13 08:40:17 +00:00
Karol Sójko c7807d0f9e fix: adjust transition timestamps to be universal 2023-09-13 10:25:02 +02:00
standardci fc90343aaa chore(release): publish new version
- @standardnotes/home-server@1.15.50
 - @standardnotes/revisions-server@1.33.19
 - @standardnotes/syncing-server@1.95.16
2023-09-13 08:17:45 +00:00
Karol Sójko fbcb45c3a2 fix: include handling updated items in revisions in secondary 2023-09-13 10:00:02 +02:00
standardci 179d8eaaa1 chore(release): publish new version
- @standardnotes/analytics@2.26.12
 - @standardnotes/api-gateway@1.74.9
 - @standardnotes/auth-server@1.141.9
 - @standardnotes/domain-events-infra@1.12.28
 - @standardnotes/domain-events@2.125.4
 - @standardnotes/event-store@1.11.40
 - @standardnotes/files-server@1.22.19
 - @standardnotes/home-server@1.15.49
 - @standardnotes/revisions-server@1.33.18
 - @standardnotes/scheduler-server@1.20.44
 - @standardnotes/syncing-server@1.95.15
 - @standardnotes/websockets-server@1.10.41
2023-09-13 07:47:36 +00:00
Karol Sójko 38685c1861 fix: display transition progress in logs 2023-09-13 09:31:07 +02:00
standardci cdf42fbe2d chore(release): publish new version
- @standardnotes/home-server@1.15.48
 - @standardnotes/revisions-server@1.33.17
 - @standardnotes/syncing-server@1.95.14
2023-09-13 06:39:14 +00:00
Karol Sójko 9be4c002b7 fix: setting status for already migrated users 2023-09-13 08:21:21 +02:00
standardci a16c5307a0 chore(release): publish new version
- @standardnotes/home-server@1.15.47
 - @standardnotes/revisions-server@1.33.16
 - @standardnotes/syncing-server@1.95.13
2023-09-13 04:50:15 +00:00
Karol Sójko d5536f5430 fix(syncing-server): case insensitive integrity check 2023-09-13 06:33:31 +02:00
Karol Sójko b1d88b15be fix: cleanup only for 0 new items 2023-09-12 22:51:39 +02:00
Karol Sójko ff78285e43 fix(syncing-server): add catch up timeout for secondary db 2023-09-12 22:24:48 +02:00
standardci 1a26221385 chore(release): publish new version
- @standardnotes/auth-server@1.141.8
 - @standardnotes/home-server@1.15.46
 - @standardnotes/revisions-server@1.33.15
 - @standardnotes/syncing-server@1.95.12
2023-09-12 20:05:02 +00:00
Karol Sójko 54113abe2a fix: imports 2023-09-12 21:31:58 +02:00
Karol Sójko afe385aed4 fix(auth): remove the transition role constraint 2023-09-12 21:28:48 +02:00
Karol Sójko f055e52e06 fix(auth): add transition role only if the items transition has completed 2023-09-12 21:26:40 +02:00
Karol Sójko fab5d18064 fix: sync between primary and secondary database with diff 2023-09-12 21:00:01 +02:00
standardci a1e654a0d0 chore(release): publish new version
- @standardnotes/home-server@1.15.45
 - @standardnotes/revisions-server@1.33.14
2023-09-12 16:21:14 +00:00
Karol Sójko aa835268ea fix(revisions): handle transitions with already existing data in secondary 2023-09-12 17:42:11 +02:00
standardci 74b4312928 chore(release): publish new version
- @standardnotes/home-server@1.15.44
 - @standardnotes/syncing-server@1.95.11
2023-09-12 15:17:12 +00:00
Karol Sójko e91a832152 fix(syncing-server): binding 2023-09-12 16:41:39 +02:00
standardci 4f95bbee3f chore(release): publish new version
- @standardnotes/analytics@2.26.11
 - @standardnotes/api-gateway@1.74.8
 - @standardnotes/auth-server@1.141.7
 - @standardnotes/domain-events-infra@1.12.27
 - @standardnotes/domain-events@2.125.3
 - @standardnotes/event-store@1.11.39
 - @standardnotes/files-server@1.22.18
 - @standardnotes/home-server@1.15.43
 - @standardnotes/revisions-server@1.33.13
 - @standardnotes/scheduler-server@1.20.43
 - @standardnotes/syncing-server@1.95.10
 - @standardnotes/websockets-server@1.10.40
2023-09-12 13:37:37 +00:00
Karol Sójko b9c9f74d0c fix(syncing-server): log syncing errors 2023-09-12 15:03:11 +02:00
Karol Sójko e535cd504c fix: retry failed revision transitions 2023-09-12 14:45:17 +02:00
standardci db0360860a chore(release): publish new version
- @standardnotes/home-server@1.15.42
 - @standardnotes/revisions-server@1.33.12
 - @standardnotes/syncing-server@1.95.9
2023-09-12 10:57:29 +00:00
Karol Sójko aa2b5f3b74 chore: add logs for failed item dumps 2023-09-12 12:13:55 +02:00
standardci 6241661e27 chore(release): publish new version
- @standardnotes/home-server@1.15.41
 - @standardnotes/syncing-server@1.95.8
2023-09-12 09:38:19 +00:00
Karol Sójko 25047bf46d fix(syncing-server): allow fetching shared vault users for members (#821) 2023-09-12 11:00:55 +02:00
standardci a1820ed212 chore(release): publish new version
- @standardnotes/analytics@2.26.10
 - @standardnotes/api-gateway@1.74.7
 - @standardnotes/auth-server@1.141.6
 - @standardnotes/domain-core@1.28.1
 - @standardnotes/event-store@1.11.38
 - @standardnotes/files-server@1.22.17
 - @standardnotes/home-server@1.15.40
 - @standardnotes/revisions-server@1.33.11
 - @standardnotes/scheduler-server@1.20.42
 - @standardnotes/settings@1.21.31
 - @standardnotes/syncing-server@1.95.7
 - @standardnotes/websockets-server@1.10.39
2023-09-12 08:55:11 +00:00
Karol Sójko 0a1d1624e8 fix: comparing uuids 2023-09-12 10:21:42 +02:00
standardci 7367de6832 chore(release): publish new version
- @standardnotes/analytics@2.26.9
 - @standardnotes/api-gateway@1.74.6
 - @standardnotes/auth-server@1.141.5
 - @standardnotes/domain-events-infra@1.12.26
 - @standardnotes/domain-events@2.125.2
 - @standardnotes/event-store@1.11.37
 - @standardnotes/files-server@1.22.16
 - @standardnotes/home-server@1.15.39
 - @standardnotes/revisions-server@1.33.10
 - @standardnotes/scheduler-server@1.20.41
 - @standardnotes/syncing-server@1.95.6
 - @standardnotes/websockets-server@1.10.38
2023-09-12 07:40:20 +00:00
Karol Sójko f0abfe89fc fix: domain event values 2023-09-12 08:59:28 +02:00
standardci d1244d165a chore(release): publish new version
- @standardnotes/analytics@2.26.8
 - @standardnotes/api-gateway@1.74.5
 - @standardnotes/auth-server@1.141.4
 - @standardnotes/domain-events-infra@1.12.25
 - @standardnotes/domain-events@2.125.1
 - @standardnotes/event-store@1.11.36
 - @standardnotes/files-server@1.22.15
 - @standardnotes/home-server@1.15.38
 - @standardnotes/revisions-server@1.33.9
 - @standardnotes/scheduler-server@1.20.40
 - @standardnotes/security@1.13.1
 - @standardnotes/syncing-server@1.95.5
 - @standardnotes/websockets-server@1.10.37
2023-09-12 06:58:11 +00:00
Karol Sójko 106d8f9192 fix: adjust transitions to not create revisions during ongoing revisions transition 2023-09-12 08:22:50 +02:00
standardci 1d86ba8fcb chore(release): publish new version
- @standardnotes/auth-server@1.141.3
 - @standardnotes/home-server@1.15.37
 - @standardnotes/revisions-server@1.33.8
 - @standardnotes/syncing-server@1.95.4
2023-09-12 05:31:57 +00:00
Karol Sójko f20a947f8a fix: transition adjustments 2023-09-12 06:52:34 +02:00
standardci 19b9de05ae chore(release): publish new version
- @standardnotes/home-server@1.15.36
 - @standardnotes/syncing-server@1.95.3
2023-09-11 19:06:39 +00:00
Karol Sójko 1d751c0fbe fix: debug sync block 2023-09-11 19:23:09 +02:00
standardci fa2564e164 chore(release): publish new version
- @standardnotes/auth-server@1.141.2
 - @standardnotes/home-server@1.15.35
 - @standardnotes/revisions-server@1.33.7
 - @standardnotes/syncing-server@1.95.2
2023-09-11 15:18:55 +00:00
Karol Sójko 330bff0124 fix(auth): remove transitioning upon sign out (#819) 2023-09-11 16:42:11 +02:00
standardci ca57c8e7b5 chore(release): publish new version
- @standardnotes/auth-server@1.141.1
 - @standardnotes/home-server@1.15.34
 - @standardnotes/revisions-server@1.33.6
 - @standardnotes/syncing-server@1.95.1
2023-09-11 13:00:46 +00:00
Karol Sójko a82b9a0c8a fix: disable running migrations in worker mode of a given service 2023-09-11 14:27:52 +02:00
standardci ea7e9d73c4 chore(release): publish new version
- @standardnotes/api-gateway@1.74.4
 - @standardnotes/auth-server@1.141.0
 - @standardnotes/home-server@1.15.33
 - @standardnotes/revisions-server@1.33.5
2023-09-11 11:23:06 +00:00
Karol Sójko 117b7b4b99 fix(revisions): removing queries 2023-09-11 12:42:40 +02:00
Karol Sójko b4bf11d9da fix(revisions): legacy table syncing and select for metadata 2023-09-11 12:23:11 +02:00
Karol Sójko 0306e10469 fix: db debug level on e2e 2023-09-11 12:03:15 +02:00
Karol Sójko 0ab47013f2 fix(api-gateway): awaiting for other services to start 2023-09-11 12:00:43 +02:00
Karol Sójko 836883b82d fix(revisions): rename table only if exists 2023-09-11 11:56:57 +02:00
Karol Sójko ed671be9c5 fix(revisions): conflict with table naming 2023-09-11 11:52:39 +02:00
Karol Sójko 9676a2586c fix(revisions): add item_uuid to revisions metadata http representation 2023-09-11 11:39:42 +02:00
Karol Sójko e95ba61c7f feat(auth): add procedure to transition users created between dates (#816) 2023-09-11 10:40:40 +02:00
standardci a0718aea26 chore(release): publish new version
- @standardnotes/home-server@1.15.32
 - @standardnotes/revisions-server@1.33.4
2023-09-11 07:17:47 +00:00
Karol Sójko 156fa7a618 fix(revisions): add shared vault uuid to revision metadata http representation 2023-09-11 08:44:18 +02:00
standardci 8d006ece30 chore(release): publish new version
- @standardnotes/analytics@2.26.7
 - @standardnotes/api-gateway@1.74.3
 - @standardnotes/auth-server@1.140.0
 - @standardnotes/domain-events-infra@1.12.24
 - @standardnotes/domain-events@2.125.0
 - @standardnotes/event-store@1.11.35
 - @standardnotes/files-server@1.22.14
 - @standardnotes/home-server@1.15.31
 - @standardnotes/revisions-server@1.33.3
 - @standardnotes/scheduler-server@1.20.39
 - @standardnotes/syncing-server@1.95.0
 - @standardnotes/websockets-server@1.10.36
2023-09-08 14:54:00 +00:00
Karol Sójko 037c994040 chore: add run name for e2e test suite 2023-09-08 15:21:26 +02:00
Karol Sójko a164ba291d fix(auth): specs 2023-09-08 13:41:37 +02:00
Karol Sójko 610fba2601 fix(auth): transition users only when transition mode enabled 2023-09-08 13:34:54 +02:00
Karol Sójko 398338c8f8 feat: transition users after sign out 2023-09-08 12:51:44 +02:00
standardci 34be157d8e chore(release): publish new version
- @standardnotes/home-server@1.15.30
 - @standardnotes/revisions-server@1.33.2
2023-09-08 10:08:48 +00:00
Karol Sójko 76372fe357 fix(revisions): persistence mapper (#814) 2023-09-08 11:29:03 +02:00
standardci 46879c336b chore(release): publish new version
- @standardnotes/auth-server@1.139.0
 - @standardnotes/home-server@1.15.29
 - @standardnotes/syncing-server@1.94.0
2023-09-08 07:53:10 +00:00
Karol Sójko aef9e936bd feat(auth): add vaults user role into database 2023-09-08 09:19:52 +02:00
Karol Sójko 8cb92d9678 feat(syncing-server): add procedure to trigger transition for specific user 2023-09-08 09:14:07 +02:00
Karol Sójko 52db89de81 chore: disable fail fast on e2e 2023-09-07 19:03:38 +02:00
standardci c5af8dfc05 chore(release): publish new version
- @standardnotes/home-server@1.15.28
 - @standardnotes/revisions-server@1.33.1
 - @standardnotes/syncing-server@1.93.1
2023-09-07 16:23:44 +00:00
Karol Sójko 27ad8e6959 fix(revisions): waiting for syncing-server on self-hosted setup 2023-09-07 17:44:53 +02:00
Karol Sójko c4a1502f70 fix(syncing-server): invalidating cache for user removed from shared vault (#812) 2023-09-07 15:41:34 +02:00
standardci d1d6c753c4 chore(release): publish new version
- @standardnotes/analytics@2.26.6
 - @standardnotes/api-gateway@1.74.2
 - @standardnotes/auth-server@1.138.2
 - @standardnotes/domain-events-infra@1.12.23
 - @standardnotes/domain-events@2.124.0
 - @standardnotes/event-store@1.11.34
 - @standardnotes/files-server@1.22.13
 - @standardnotes/home-server@1.15.27
 - @standardnotes/revisions-server@1.33.0
 - @standardnotes/scheduler-server@1.20.38
 - @standardnotes/syncing-server@1.93.0
 - @standardnotes/websockets-server@1.10.35
2023-09-07 10:46:30 +00:00
Karol Sójko 3bd63f7674 feat: add removing revisions from shared vaults (#811) 2023-09-07 12:02:38 +02:00
standardci 376466d9b2 chore(release): publish new version
- @standardnotes/analytics@2.26.5
 - @standardnotes/api-gateway@1.74.1
 - @standardnotes/auth-server@1.138.1
 - @standardnotes/domain-core@1.28.0
 - @standardnotes/event-store@1.11.33
 - @standardnotes/files-server@1.22.12
 - @standardnotes/home-server@1.15.26
 - @standardnotes/revisions-server@1.32.0
 - @standardnotes/scheduler-server@1.20.37
 - @standardnotes/settings@1.21.30
 - @standardnotes/syncing-server@1.92.1
 - @standardnotes/websockets-server@1.10.34
2023-09-07 09:00:39 +00:00
Karol Sójko e100c52bbc feat(revisions): fetching single revision in shared vault (#810)
* feat(revisions): fetching single revision in shared vault

* fix(revisions): mapping to http representation
2023-09-07 10:23:03 +02:00
Aman Harwara d4830dec01 feat: add VaultsUser role name (#809)
* feat: add VaultsUser role name

* fix: test coverage
2023-09-07 08:07:06 +02:00
Karol Sójko 7e11821021 fix(revisions): query for shared vault revisions 2023-09-07 08:05:47 +02:00
183 changed files with 2992 additions and 1756 deletions
+1
View File
@@ -4,6 +4,7 @@ DB_USERNAME=std_notes_user
DB_PASSWORD=changeme123 DB_PASSWORD=changeme123
DB_DATABASE=standard_notes_db DB_DATABASE=standard_notes_db
DB_PORT=3306 DB_PORT=3306
DB_DEBUG_LEVEL=all
DB_SQLITE_DATABASE_PATH=standard_notes_db DB_SQLITE_DATABASE_PATH=standard_notes_db
REDIS_PORT=6379 REDIS_PORT=6379
REDIS_HOST=cache REDIS_HOST=cache
+3 -2
View File
@@ -21,7 +21,7 @@ jobs:
e2e: e2e:
name: (Self Hosting) E2E Test Suite name: (Self Hosting) E2E Test Suite
strategy: strategy:
fail-fast: true fail-fast: false
matrix: matrix:
secondary_db_enabled: [true, false] secondary_db_enabled: [true, false]
transition_mode_enabled: [true, false] transition_mode_enabled: [true, false]
@@ -70,7 +70,7 @@ jobs:
e2e-home-server: e2e-home-server:
name: (Home Server) E2E Test Suite name: (Home Server) E2E Test Suite
strategy: strategy:
fail-fast: true fail-fast: false
matrix: matrix:
db_type: [mysql, sqlite] db_type: [mysql, sqlite]
cache_type: [redis, memory] cache_type: [redis, memory]
@@ -141,6 +141,7 @@ jobs:
echo "DB_USERNAME=standardnotes" >> packages/home-server/.env echo "DB_USERNAME=standardnotes" >> packages/home-server/.env
echo "DB_PASSWORD=standardnotes" >> packages/home-server/.env echo "DB_PASSWORD=standardnotes" >> packages/home-server/.env
echo "DB_TYPE=${{ matrix.db_type }}" >> packages/home-server/.env echo "DB_TYPE=${{ matrix.db_type }}" >> packages/home-server/.env
echo "DB_DEBUG_LEVEL=all" >> packages/home-server/.env
echo "REDIS_URL=redis://localhost:6379" >> packages/home-server/.env echo "REDIS_URL=redis://localhost:6379" >> packages/home-server/.env
echo "CACHE_TYPE=${{ matrix.cache_type }}" >> packages/home-server/.env echo "CACHE_TYPE=${{ matrix.cache_type }}" >> packages/home-server/.env
echo "SECONDARY_DB_ENABLED=${{ matrix.secondary_db_enabled }}" >> packages/home-server/.env echo "SECONDARY_DB_ENABLED=${{ matrix.secondary_db_enabled }}" >> packages/home-server/.env
+10
View File
@@ -1,5 +1,7 @@
name: E2E Test Suite On Self Hosted Server name: E2E Test Suite On Self Hosted Server
run-name: E2E Test Suite against ${{ inputs.ref_name }} by ${{ inputs.author }}
on: on:
schedule: schedule:
- cron: '0 */12 * * *' - cron: '0 */12 * * *'
@@ -9,6 +11,14 @@ on:
type: string type: string
default: latest default: latest
description: The Docker image tag used for SNJS container description: The Docker image tag used for SNJS container
author:
type: string
default: unknown
description: The author that triggered the workflow
ref_name:
type: string
default: unknown
description: The ref name from which the workflow was triggered
jobs: jobs:
e2e: e2e:
Generated
+43 -63
View File
@@ -3326,10 +3326,10 @@ const RAW_RUNTIME_STATE =
}]\ }]\
]],\ ]],\
["@hexagon/base64", [\ ["@hexagon/base64", [\
["npm:1.1.26", {\ ["npm:1.1.27", {\
"packageLocation": "./.yarn/cache/@hexagon-base64-npm-1.1.26-dbfda05df8-e42582ed12.zip/node_modules/@hexagon/base64/",\ "packageLocation": "./.yarn/cache/@hexagon-base64-npm-1.1.27-df6f264962-899fffaf54.zip/node_modules/@hexagon/base64/",\
"packageDependencies": [\ "packageDependencies": [\
["@hexagon/base64", "npm:1.1.26"]\ ["@hexagon/base64", "npm:1.1.27"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
@@ -5067,44 +5067,29 @@ const RAW_RUNTIME_STATE =
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
]],\ ]],\
["@simplewebauthn/iso-webcrypto", [\
["npm:7.2.0", {\
"packageLocation": "./.yarn/cache/@simplewebauthn-iso-webcrypto-npm-7.2.0-db7b12b859-b57899d0ad.zip/node_modules/@simplewebauthn/iso-webcrypto/",\
"packageDependencies": [\
["@simplewebauthn/iso-webcrypto", "npm:7.2.0"],\
["@simplewebauthn/typescript-types", "npm:7.0.0"],\
["@types/node", "npm:18.16.16"]\
],\
"linkType": "HARD"\
}]\
]],\
["@simplewebauthn/server", [\ ["@simplewebauthn/server", [\
["npm:7.2.0", {\ ["npm:8.1.1", {\
"packageLocation": "./.yarn/cache/@simplewebauthn-server-npm-7.2.0-f1ed5fde8a-2e37c87edd.zip/node_modules/@simplewebauthn/server/",\ "packageLocation": "./.yarn/cache/@simplewebauthn-server-npm-8.1.1-106d3bd108-a07c2a067b.zip/node_modules/@simplewebauthn/server/",\
"packageDependencies": [\ "packageDependencies": [\
["@simplewebauthn/server", "npm:7.2.0"],\ ["@simplewebauthn/server", "npm:8.1.1"],\
["@hexagon/base64", "npm:1.1.26"],\ ["@hexagon/base64", "npm:1.1.27"],\
["@peculiar/asn1-android", "npm:2.3.6"],\ ["@peculiar/asn1-android", "npm:2.3.6"],\
["@peculiar/asn1-ecc", "npm:2.3.6"],\ ["@peculiar/asn1-ecc", "npm:2.3.6"],\
["@peculiar/asn1-rsa", "npm:2.3.6"],\ ["@peculiar/asn1-rsa", "npm:2.3.6"],\
["@peculiar/asn1-schema", "npm:2.3.6"],\ ["@peculiar/asn1-schema", "npm:2.3.6"],\
["@peculiar/asn1-x509", "npm:2.3.6"],\ ["@peculiar/asn1-x509", "npm:2.3.6"],\
["@simplewebauthn/iso-webcrypto", "npm:7.2.0"],\ ["@simplewebauthn/typescript-types", "npm:8.0.0"],\
["@simplewebauthn/typescript-types", "npm:7.0.0"],\ ["cbor-x", "npm:1.5.4"],\
["@types/debug", "npm:4.1.8"],\ ["cross-fetch", "npm:4.0.0"]\
["@types/node", "npm:18.16.16"],\
["cbor-x", "npm:1.5.3"],\
["cross-fetch", "npm:3.1.6"],\
["debug", "virtual:ac3d8e680759ce54399273724d44e041d6c9b73454d191d411a8c44bb27e22f02aaf6ed9d3ad0ac1c298eac4833cff369c9c7b84c573016112c4f84be2cd8543#npm:4.3.4"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
]],\ ]],\
["@simplewebauthn/typescript-types", [\ ["@simplewebauthn/typescript-types", [\
["npm:7.0.0", {\ ["npm:8.0.0", {\
"packageLocation": "./.yarn/cache/@simplewebauthn-typescript-types-npm-7.0.0-cc6ca20415-124238ea18.zip/node_modules/@simplewebauthn/typescript-types/",\ "packageLocation": "./.yarn/cache/@simplewebauthn-typescript-types-npm-8.0.0-f3b313c27b-21e0b13268.zip/node_modules/@simplewebauthn/typescript-types/",\
"packageDependencies": [\ "packageDependencies": [\
["@simplewebauthn/typescript-types", "npm:7.0.0"]\ ["@simplewebauthn/typescript-types", "npm:8.0.0"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
@@ -5864,8 +5849,8 @@ const RAW_RUNTIME_STATE =
["@cbor-extract/cbor-extract-linux-arm64", "npm:2.1.1"],\ ["@cbor-extract/cbor-extract-linux-arm64", "npm:2.1.1"],\
["@cbor-extract/cbor-extract-linux-x64", "npm:2.1.1"],\ ["@cbor-extract/cbor-extract-linux-x64", "npm:2.1.1"],\
["@newrelic/winston-enricher", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.0.1"],\ ["@newrelic/winston-enricher", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.0.1"],\
["@simplewebauthn/server", "npm:7.2.0"],\ ["@simplewebauthn/server", "npm:8.1.1"],\
["@simplewebauthn/typescript-types", "npm:7.0.0"],\ ["@simplewebauthn/typescript-types", "npm:8.0.0"],\
["@standardnotes/api", "npm:1.26.26"],\ ["@standardnotes/api", "npm:1.26.26"],\
["@standardnotes/common", "workspace:packages/common"],\ ["@standardnotes/common", "workspace:packages/common"],\
["@standardnotes/domain-core", "workspace:packages/domain-core"],\ ["@standardnotes/domain-core", "workspace:packages/domain-core"],\
@@ -6720,16 +6705,6 @@ const RAW_RUNTIME_STATE =
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
]],\ ]],\
["@types/debug", [\
["npm:4.1.8", {\
"packageLocation": "./.yarn/cache/@types-debug-npm-4.1.8-a04e2ca136-9c190e8129.zip/node_modules/@types/debug/",\
"packageDependencies": [\
["@types/debug", "npm:4.1.8"],\
["@types/ms", "npm:0.7.31"]\
],\
"linkType": "HARD"\
}]\
]],\
["@types/dotenv", [\ ["@types/dotenv", [\
["npm:8.2.0", {\ ["npm:8.2.0", {\
"packageLocation": "./.yarn/cache/@types-dotenv-npm-8.2.0-f4d0e3d65b-13f90a36f7.zip/node_modules/@types/dotenv/",\ "packageLocation": "./.yarn/cache/@types-dotenv-npm-8.2.0-f4d0e3d65b-13f90a36f7.zip/node_modules/@types/dotenv/",\
@@ -6956,15 +6931,6 @@ const RAW_RUNTIME_STATE =
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
]],\ ]],\
["@types/ms", [\
["npm:0.7.31", {\
"packageLocation": "./.yarn/cache/@types-ms-npm-0.7.31-ea3b89342b-cccb52777b.zip/node_modules/@types/ms/",\
"packageDependencies": [\
["@types/ms", "npm:0.7.31"]\
],\
"linkType": "HARD"\
}]\
]],\
["@types/newrelic", [\ ["@types/newrelic", [\
["npm:9.14.0", {\ ["npm:9.14.0", {\
"packageLocation": "./.yarn/cache/@types-newrelic-npm-9.14.0-4668da51a1-2ec951bd8f.zip/node_modules/@types/newrelic/",\ "packageLocation": "./.yarn/cache/@types-newrelic-npm-9.14.0-4668da51a1-2ec951bd8f.zip/node_modules/@types/newrelic/",\
@@ -6982,13 +6948,6 @@ const RAW_RUNTIME_STATE =
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}],\ }],\
["npm:18.16.16", {\
"packageLocation": "./.yarn/cache/@types-node-npm-18.16.16-8a41330dc3-946bd4d8e6.zip/node_modules/@types/node/",\
"packageDependencies": [\
["@types/node", "npm:18.16.16"]\
],\
"linkType": "HARD"\
}],\
["npm:20.2.5", {\ ["npm:20.2.5", {\
"packageLocation": "./.yarn/cache/@types-node-npm-20.2.5-0014d2d9ce-55e4f8d08e.zip/node_modules/@types/node/",\ "packageLocation": "./.yarn/cache/@types-node-npm-20.2.5-0014d2d9ce-55e4f8d08e.zip/node_modules/@types/node/",\
"packageDependencies": [\ "packageDependencies": [\
@@ -8706,10 +8665,10 @@ const RAW_RUNTIME_STATE =
}]\ }]\
]],\ ]],\
["cbor-x", [\ ["cbor-x", [\
["npm:1.5.3", {\ ["npm:1.5.4", {\
"packageLocation": "./.yarn/cache/cbor-x-npm-1.5.3-1d452dd267-d4df85b339.zip/node_modules/cbor-x/",\ "packageLocation": "./.yarn/cache/cbor-x-npm-1.5.4-2d5a649a4b-742aea498a.zip/node_modules/cbor-x/",\
"packageDependencies": [\ "packageDependencies": [\
["cbor-x", "npm:1.5.3"],\ ["cbor-x", "npm:1.5.4"],\
["cbor-extract", "npm:2.1.1"]\ ["cbor-extract", "npm:2.1.1"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
@@ -9434,11 +9393,11 @@ const RAW_RUNTIME_STATE =
}]\ }]\
]],\ ]],\
["cross-fetch", [\ ["cross-fetch", [\
["npm:3.1.6", {\ ["npm:4.0.0", {\
"packageLocation": "./.yarn/cache/cross-fetch-npm-3.1.6-cdb982d446-a8989fca82.zip/node_modules/cross-fetch/",\ "packageLocation": "./.yarn/cache/cross-fetch-npm-4.0.0-9c67668db4-30e86b703a.zip/node_modules/cross-fetch/",\
"packageDependencies": [\ "packageDependencies": [\
["cross-fetch", "npm:3.1.6"],\ ["cross-fetch", "npm:4.0.0"],\
["node-fetch", "virtual:0f92dfe7f9dc4fd492639d4a5b7805c2b27442bf599fd4f370b22a7966ba078f5d4525e2a8e8af29369f20e1833ed084bd52be59679efaa6c1c6c10cdbcd8baa#npm:2.6.11"]\ ["node-fetch", "virtual:9c67668db478e95ba4d6a763bc55027eeff0d22eaf59478017ea07386fc33a3c7b7b625af78aa86a33991a9a500a7aa216e28632de568f02adefd662ef53a42d#npm:2.7.0"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
@@ -14174,6 +14133,13 @@ const RAW_RUNTIME_STATE =
],\ ],\
"linkType": "SOFT"\ "linkType": "SOFT"\
}],\ }],\
["npm:2.7.0", {\
"packageLocation": "./.yarn/cache/node-fetch-npm-2.7.0-587d57004e-a3ad788903.zip/node_modules/node-fetch/",\
"packageDependencies": [\
["node-fetch", "npm:2.7.0"]\
],\
"linkType": "SOFT"\
}],\
["npm:3.3.1", {\ ["npm:3.3.1", {\
"packageLocation": "./.yarn/cache/node-fetch-npm-3.3.1-576511fc5a-1d0c635bdf.zip/node_modules/node-fetch/",\ "packageLocation": "./.yarn/cache/node-fetch-npm-3.3.1-576511fc5a-1d0c635bdf.zip/node_modules/node-fetch/",\
"packageDependencies": [\ "packageDependencies": [\
@@ -14197,6 +14163,20 @@ const RAW_RUNTIME_STATE =
"encoding"\ "encoding"\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}],\
["virtual:9c67668db478e95ba4d6a763bc55027eeff0d22eaf59478017ea07386fc33a3c7b7b625af78aa86a33991a9a500a7aa216e28632de568f02adefd662ef53a42d#npm:2.7.0", {\
"packageLocation": "./.yarn/__virtual__/node-fetch-virtual-0ec1497d1c/0/cache/node-fetch-npm-2.7.0-587d57004e-a3ad788903.zip/node_modules/node-fetch/",\
"packageDependencies": [\
["node-fetch", "virtual:9c67668db478e95ba4d6a763bc55027eeff0d22eaf59478017ea07386fc33a3c7b7b625af78aa86a33991a9a500a7aa216e28632de568f02adefd662ef53a42d#npm:2.7.0"],\
["@types/encoding", null],\
["encoding", null],\
["whatwg-url", "npm:5.0.0"]\
],\
"packagePeers": [\
"@types/encoding",\
"encoding"\
],\
"linkType": "HARD"\
}]\ }]\
]],\ ]],\
["node-gyp", [\ ["node-gyp", [\
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3 -3
View File
@@ -53,7 +53,7 @@ services:
image: mysql:8 image: mysql:8
container_name: db-ci container_name: db-ci
env_file: .github/ci.env env_file: .github/ci.env
expose: ports:
- 3306 - 3306
restart: unless-stopped restart: unless-stopped
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
@@ -66,7 +66,7 @@ services:
secondary_db: secondary_db:
image: mongo:5.0 image: mongo:5.0
container_name: secondary_db-ci container_name: secondary_db-ci
expose: ports:
- 27017 - 27017
restart: unless-stopped restart: unless-stopped
volumes: volumes:
@@ -83,7 +83,7 @@ services:
container_name: cache-ci container_name: cache-ci
volumes: volumes:
- ./data/redis/:/data - ./data/redis/:/data
expose: ports:
- 6379 - 6379
restart: unless-stopped restart: unless-stopped
networks: networks:
+36
View File
@@ -3,6 +3,42 @@
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.13](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.12...@standardnotes/analytics@2.26.13) (2023-09-15)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.12](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.11...@standardnotes/analytics@2.26.12) (2023-09-13)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.11](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.10...@standardnotes/analytics@2.26.11) (2023-09-12)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.10](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.9...@standardnotes/analytics@2.26.10) (2023-09-12)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.9](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.8...@standardnotes/analytics@2.26.9) (2023-09-12)
**Note:** Version bump only for package @standardnotes/analytics
## [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)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.6](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.5...@standardnotes/analytics@2.26.6) (2023-09-07)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.5](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.4...@standardnotes/analytics@2.26.5) (2023-09-07)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.4](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.3...@standardnotes/analytics@2.26.4) (2023-09-06) ## [2.26.4](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.3...@standardnotes/analytics@2.26.4) (2023-09-06)
**Note:** Version bump only for package @standardnotes/analytics **Note:** Version bump only for package @standardnotes/analytics
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@standardnotes/analytics", "name": "@standardnotes/analytics",
"version": "2.26.4", "version": "2.26.13",
"engines": { "engines": {
"node": ">=18.0.0 <21.0.0" "node": ">=18.0.0 <21.0.0"
}, },
+48
View File
@@ -3,6 +3,54 @@
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.11](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.10...@standardnotes/api-gateway@1.74.11) (2023-09-15)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.74.10](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.9...@standardnotes/api-gateway@1.74.10) (2023-09-13)
### Bug Fixes
* adjust transition timestamps to be universal ([c7807d0](https://github.com/standardnotes/api-gateway/commit/c7807d0f9e69ce572c4c03ff606375d706f24d9f))
## [1.74.9](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.8...@standardnotes/api-gateway@1.74.9) (2023-09-13)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.74.8](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.7...@standardnotes/api-gateway@1.74.8) (2023-09-12)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.74.7](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.6...@standardnotes/api-gateway@1.74.7) (2023-09-12)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.74.6](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.5...@standardnotes/api-gateway@1.74.6) (2023-09-12)
**Note:** Version bump only for package @standardnotes/api-gateway
## [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)
### Bug Fixes
* **api-gateway:** awaiting for other services to start ([0ab4701](https://github.com/standardnotes/api-gateway/commit/0ab47013f210dca7aa404966798011947fb5c362))
## [1.74.3](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.2...@standardnotes/api-gateway@1.74.3) (2023-09-08)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.74.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.1...@standardnotes/api-gateway@1.74.2) (2023-09-07)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.74.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.0...@standardnotes/api-gateway@1.74.1) (2023-09-07)
**Note:** Version bump only for package @standardnotes/api-gateway
# [1.74.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.73.7...@standardnotes/api-gateway@1.74.0) (2023-09-06) # [1.74.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.73.7...@standardnotes/api-gateway@1.74.0) (2023-09-06)
### Features ### Features
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@standardnotes/api-gateway", "name": "@standardnotes/api-gateway",
"version": "1.74.0", "version": "1.74.11",
"engines": { "engines": {
"node": ">=18.0.0 <21.0.0" "node": ">=18.0.0 <21.0.0"
}, },
@@ -80,15 +80,6 @@ export class UsersController extends BaseHttpController {
) )
} }
@httpGet('/transition-status', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
async getTransitionStatus(request: Request, response: Response): Promise<void> {
await this.httpService.callAuthServer(
request,
response,
this.endpointResolver.resolveEndpointOrMethodIdentifier('GET', 'users/transition-status'),
)
}
@httpGet('/:userId/params', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware) @httpGet('/:userId/params', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
async getKeyParams(request: Request, response: Response): Promise<void> { async getKeyParams(request: Request, response: Response): Promise<void> {
await this.httpService.callAuthServer( await this.httpService.callAuthServer(
@@ -43,7 +43,6 @@ export class EndpointResolver implements EndpointResolverInterface {
['[PATCH]:users/:userId', 'auth.users.update'], ['[PATCH]:users/:userId', 'auth.users.update'],
['[PUT]:users/:userUuid/attributes/credentials', 'auth.users.updateCredentials'], ['[PUT]:users/:userUuid/attributes/credentials', 'auth.users.updateCredentials'],
['[GET]:users/params', 'auth.users.getKeyParams'], ['[GET]:users/params', 'auth.users.getKeyParams'],
['[GET]:users/transition-status', 'auth.users.transition-status'],
['[DELETE]:users/:userUuid', 'auth.users.delete'], ['[DELETE]:users/:userUuid', 'auth.users.delete'],
['[POST]:listed', 'auth.users.createListedAccount'], ['[POST]:listed', 'auth.users.createListedAccount'],
['[POST]:auth', 'auth.users.register'], ['[POST]:auth', 'auth.users.register'],
@@ -59,13 +58,11 @@ export class EndpointResolver implements EndpointResolverInterface {
// Syncing Server // Syncing Server
['[POST]:items/sync', 'sync.items.sync'], ['[POST]:items/sync', 'sync.items.sync'],
['[POST]:items/check-integrity', 'sync.items.check_integrity'], ['[POST]:items/check-integrity', 'sync.items.check_integrity'],
['[POST]:items/transition', 'sync.items.transition'],
['[GET]:items/:uuid', 'sync.items.get_item'], ['[GET]:items/:uuid', 'sync.items.get_item'],
// Revisions Controller V2 // Revisions Controller V2
['[GET]:items/:itemUuid/revisions', 'revisions.revisions.getRevisions'], ['[GET]:items/:itemUuid/revisions', 'revisions.revisions.getRevisions'],
['[GET]:items/:itemUuid/revisions/:id', 'revisions.revisions.getRevision'], ['[GET]:items/:itemUuid/revisions/:id', 'revisions.revisions.getRevision'],
['[DELETE]:items/:itemUuid/revisions/:id', 'revisions.revisions.deleteRevision'], ['[DELETE]:items/:itemUuid/revisions/:id', 'revisions.revisions.deleteRevision'],
['[POST]:revisions/transition', 'revisions.revisions.transition'],
// Messages Controller // Messages Controller
['[GET]:messages/', 'sync.messages.get-received'], ['[GET]:messages/', 'sync.messages.get-received'],
['[GET]:messages/outbound', 'sync.messages.get-sent'], ['[GET]:messages/outbound', 'sync.messages.get-sent'],
@@ -2,5 +2,8 @@
set -euo pipefail set -euo pipefail
sh supervisor/wait-for.sh localhost $AUTH_SERVER_PORT
sh supervisor/wait-for.sh localhost $FILES_SERVER_PORT
sh supervisor/wait-for.sh localhost $REVISIONS_SERVER_PORT
sh supervisor/wait-for.sh localhost $SYNCING_SERVER_PORT sh supervisor/wait-for.sh localhost $SYNCING_SERVER_PORT
node docker/entrypoint-server.js node docker/entrypoint-server.js
+122
View File
@@ -3,6 +3,128 @@
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.142.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.14...@standardnotes/auth-server@1.142.0) (2023-09-15)
### Features
* add skipping verified transitions ([#827](https://github.com/standardnotes/server/issues/827)) ([d4d4945](https://github.com/standardnotes/server/commit/d4d49454a68de0acdf440dc202fa14b9743905f6))
## [1.141.14](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.13...@standardnotes/auth-server@1.141.14) (2023-09-15)
### Bug Fixes
* **auth:** remove extensive logs from updating transitions ([2a1859e](https://github.com/standardnotes/server/commit/2a1859e4beff4cc7c4348ebbff8357a8e061bf5e))
* **auth:** upgrade simplewebauthn dependency ([#826](https://github.com/standardnotes/server/issues/826)) ([dd9a9c6](https://github.com/standardnotes/server/commit/dd9a9c68cb431a61700a8e5d8247eb1b505a9d62))
## [1.141.13](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.12...@standardnotes/auth-server@1.141.13) (2023-09-14)
### Bug Fixes
* **auth:** set ttl for started and not picked up transitions to 10h ([fe8ca82](https://github.com/standardnotes/server/commit/fe8ca828fb37306e0e5056627e67366885e86861))
## [1.141.12](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.11...@standardnotes/auth-server@1.141.12) (2023-09-13)
### Bug Fixes
* **auth:** remove re-triggering revisions transition ([5984e4c](https://github.com/standardnotes/server/commit/5984e4c3e7e550e5ed53805bde1e6dabcbe54da8))
## [1.141.11](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.10...@standardnotes/auth-server@1.141.11) (2023-09-13)
### Bug Fixes
* **auth:** passing transition timestamp ([c164bde](https://github.com/standardnotes/server/commit/c164bde847b5974e74fd439f0d439526ad439443))
## [1.141.10](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.9...@standardnotes/auth-server@1.141.10) (2023-09-13)
### Bug Fixes
* adjust transition timestamps to be universal ([c7807d0](https://github.com/standardnotes/server/commit/c7807d0f9e69ce572c4c03ff606375d706f24d9f))
## [1.141.9](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.8...@standardnotes/auth-server@1.141.9) (2023-09-13)
### Bug Fixes
* display transition progress in logs ([38685c1](https://github.com/standardnotes/server/commit/38685c1861b13e398dd96aa39f2cf1aece2090fb))
## [1.141.8](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.7...@standardnotes/auth-server@1.141.8) (2023-09-12)
### Bug Fixes
* **auth:** add transition role only if the items transition has completed ([f055e52](https://github.com/standardnotes/server/commit/f055e52e06b6e93501abd340dfce214d5363bc30))
* **auth:** remove the transition role constraint ([afe385a](https://github.com/standardnotes/server/commit/afe385aed4ba5ca53d8ef429ae4154f4ccf81419))
* imports ([54113ab](https://github.com/standardnotes/server/commit/54113abe2a961720a3561e5ff3a0069046ea8d25))
## [1.141.7](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.6...@standardnotes/auth-server@1.141.7) (2023-09-12)
### Bug Fixes
* retry failed revision transitions ([e535cd5](https://github.com/standardnotes/server/commit/e535cd504cf1929539ff7faf13e9c1fdd2b7bfd1))
## [1.141.6](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.5...@standardnotes/auth-server@1.141.6) (2023-09-12)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.141.5](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.4...@standardnotes/auth-server@1.141.5) (2023-09-12)
### Bug Fixes
* domain event values ([f0abfe8](https://github.com/standardnotes/server/commit/f0abfe89fca0049c47131389683efe2f5aff23f8))
## [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)
### Bug Fixes
* transition adjustments ([f20a947](https://github.com/standardnotes/server/commit/f20a947f8a555c074d8dc1543c7a8bf61d1d887e))
## [1.141.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.1...@standardnotes/auth-server@1.141.2) (2023-09-11)
### Bug Fixes
* **auth:** remove transitioning upon sign out ([#819](https://github.com/standardnotes/server/issues/819)) ([330bff0](https://github.com/standardnotes/server/commit/330bff0124f5f49c3441304d166ea43c21fea7bc))
## [1.141.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.0...@standardnotes/auth-server@1.141.1) (2023-09-11)
### Bug Fixes
* disable running migrations in worker mode of a given service ([a82b9a0](https://github.com/standardnotes/server/commit/a82b9a0c8a023ba8a450ff9e34bcd62f928fcab3))
# [1.141.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.140.0...@standardnotes/auth-server@1.141.0) (2023-09-11)
### Features
* **auth:** add procedure to transition users created between dates ([#816](https://github.com/standardnotes/server/issues/816)) ([e95ba61](https://github.com/standardnotes/server/commit/e95ba61c7f769736698ebbc38179d6dc05a8cc5e))
# [1.140.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.139.0...@standardnotes/auth-server@1.140.0) (2023-09-08)
### Bug Fixes
* **auth:** specs ([a164ba2](https://github.com/standardnotes/server/commit/a164ba291d4893b5a0bb4b39a8795d654212a1a6))
* **auth:** transition users only when transition mode enabled ([610fba2](https://github.com/standardnotes/server/commit/610fba260150d0757020e01ac0c8967feeadd4d6))
### Features
* transition users after sign out ([398338c](https://github.com/standardnotes/server/commit/398338c8f81b12406c7ab3bf1654e60b94d7cfd0))
# [1.139.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.138.2...@standardnotes/auth-server@1.139.0) (2023-09-08)
### Features
* **auth:** add vaults user role into database ([aef9e93](https://github.com/standardnotes/server/commit/aef9e936bdbd1f4ccc32658d3d892e7675ec0e0e))
## [1.138.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.138.1...@standardnotes/auth-server@1.138.2) (2023-09-07)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.138.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.138.0...@standardnotes/auth-server@1.138.1) (2023-09-07)
**Note:** Version bump only for package @standardnotes/auth-server
# [1.138.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.137.6...@standardnotes/auth-server@1.138.0) (2023-09-06) # [1.138.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.137.6...@standardnotes/auth-server@1.138.0) (2023-09-06)
### Features ### Features
+1 -1
View File
@@ -75,7 +75,7 @@ const requestBackups = async (
}) })
} }
const container = new ContainerConfigLoader() const container = new ContainerConfigLoader('worker')
void container.load().then((container) => { void container.load().then((container) => {
dayjs.extend(utc) dayjs.extend(utc)
+1 -1
View File
@@ -18,7 +18,7 @@ const cleanup = async (
await cleanupExpiredSessions.execute({ date }) await cleanupExpiredSessions.execute({ date })
} }
const container = new ContainerConfigLoader() const container = new ContainerConfigLoader('worker')
void container.load().then((container) => { void container.load().then((container) => {
const env: Env = new Env() const env: Env = new Env()
env.load() env.load()
+1 -1
View File
@@ -8,7 +8,7 @@ import TYPES from '../src/Bootstrap/Types'
import { Env } from '../src/Bootstrap/Env' import { Env } from '../src/Bootstrap/Env'
import { PersistStatistics } from '../src/Domain/UseCase/PersistStatistics/PersistStatistics' import { PersistStatistics } from '../src/Domain/UseCase/PersistStatistics/PersistStatistics'
const container = new ContainerConfigLoader() const container = new ContainerConfigLoader('worker')
void container.load().then((container) => { void container.load().then((container) => {
const env: Env = new Env() const env: Env = new Env()
env.load() env.load()
+112
View File
@@ -0,0 +1,112 @@
import 'reflect-metadata'
import { Logger } from 'winston'
import * as dayjs from 'dayjs'
import * as utc from 'dayjs/plugin/utc'
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
import TYPES from '../src/Bootstrap/Types'
import { Env } from '../src/Bootstrap/Env'
import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
import { DomainEventFactoryInterface } from '../src/Domain/Event/DomainEventFactoryInterface'
import { UserRepositoryInterface } from '../src/Domain/User/UserRepositoryInterface'
import { TimerInterface } from '@standardnotes/time'
import { TransitionStatusRepositoryInterface } from '../src/Domain/Transition/TransitionStatusRepositoryInterface'
import { RoleName } from '@standardnotes/domain-core'
const inputArgs = process.argv.slice(2)
const startDateString = inputArgs[0]
const endDateString = inputArgs[1]
const requestTransition = async (
transitionStatusRepository: TransitionStatusRepositoryInterface,
userRepository: UserRepositoryInterface,
logger: Logger,
domainEventFactory: DomainEventFactoryInterface,
domainEventPublisher: DomainEventPublisherInterface,
timer: TimerInterface,
): Promise<void> => {
const startDate = new Date(startDateString)
const endDate = new Date(endDateString)
const users = await userRepository.findAllCreatedBetween(startDate, endDate)
const timestamp = timer.getTimestampInMicroseconds()
logger.info(
`[TRANSITION ${timestamp}] Found ${users.length} users created between ${startDateString} and ${endDateString}`,
)
let usersTriggered = 0
for (const user of users) {
const itemsTransitionStatus = await transitionStatusRepository.getStatus(user.uuid, 'items')
const revisionsTransitionStatus = await transitionStatusRepository.getStatus(user.uuid, 'revisions')
const userRoles = await user.roles
const userHasTransitionRole = userRoles.some((role) => role.name === RoleName.NAMES.TransitionUser)
const bothTransitionStatusesAreVerified =
itemsTransitionStatus === 'VERIFIED' && revisionsTransitionStatus === 'VERIFIED'
if (userHasTransitionRole && bothTransitionStatusesAreVerified) {
continue
}
const transitionRequestedEvent = domainEventFactory.createTransitionRequestedEvent({
userUuid: user.uuid,
type: 'items',
timestamp,
})
usersTriggered += 1
await domainEventPublisher.publish(transitionRequestedEvent)
}
logger.info(
`[TRANSITION ${timestamp}] Triggered transition for ${usersTriggered} users created between ${startDateString} and ${endDateString}`,
)
}
const container = new ContainerConfigLoader('worker')
void container.load().then((container) => {
dayjs.extend(utc)
const env: Env = new Env()
env.load()
const logger: Logger = container.get(TYPES.Auth_Logger)
logger.info(`Starting transition request for users created between ${startDateString} and ${endDateString}`)
const userRepository: UserRepositoryInterface = container.get(TYPES.Auth_UserRepository)
const domainEventFactory: DomainEventFactoryInterface = container.get(TYPES.Auth_DomainEventFactory)
const domainEventPublisher: DomainEventPublisherInterface = container.get(TYPES.Auth_DomainEventPublisher)
const timer = container.get<TimerInterface>(TYPES.Auth_Timer)
const transitionStatusRepository = container.get<TransitionStatusRepositoryInterface>(
TYPES.Auth_TransitionStatusRepository,
)
Promise.resolve(
requestTransition(
transitionStatusRepository,
userRepository,
logger,
domainEventFactory,
domainEventPublisher,
timer,
),
)
.then(() => {
logger.info(`Finished transition request for users created between ${startDateString} and ${endDateString}`)
process.exit(0)
})
.catch((error) => {
logger.error(
`Error while requesting transition for users created between ${startDateString} and ${endDateString}: ${error}`,
)
process.exit(1)
})
})
+1 -1
View File
@@ -63,7 +63,7 @@ const requestBackups = async (
return return
} }
const container = new ContainerConfigLoader() const container = new ContainerConfigLoader('worker')
void container.load().then((container) => { void container.load().then((container) => {
dayjs.extend(utc) dayjs.extend(utc)
+1 -1
View File
@@ -9,7 +9,7 @@ import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-eve
import * as dayjs from 'dayjs' import * as dayjs from 'dayjs'
import * as utc from 'dayjs/plugin/utc' import * as utc from 'dayjs/plugin/utc'
const container = new ContainerConfigLoader() const container = new ContainerConfigLoader('worker')
void container.load().then((container) => { void container.load().then((container) => {
dayjs.extend(utc) dayjs.extend(utc)
@@ -0,0 +1,11 @@
'use strict'
const path = require('path')
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/transition.js')))
Object.defineProperty(exports, '__esModule', { value: true })
exports.default = index
+7
View File
@@ -55,6 +55,13 @@ case "$COMMAND" in
node docker/entrypoint-backup.js one_drive daily node docker/entrypoint-backup.js one_drive daily
;; ;;
'transition' )
START_DATE=$1 && shift 1
END_DATE=$1 && shift 1
echo "[Docker] Starting Transition..."
node docker/entrypoint-transition.js $START_DATE $END_DATE
;;
* ) * )
echo "[Docker] Unknown command" echo "[Docker] Unknown command"
;; ;;
@@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddVaultsUser1694157482134 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'INSERT INTO `roles` (uuid, name, version) VALUES ("35669f45-a2d8-4172-bdab-b7b3d42044ce", "VAULTS_USER", 1)',
)
}
public async down(): Promise<void> {
return
}
}
+3 -3
View File
@@ -1,6 +1,6 @@
{ {
"name": "@standardnotes/auth-server", "name": "@standardnotes/auth-server",
"version": "1.138.0", "version": "1.142.0",
"engines": { "engines": {
"node": ">=18.0.0 <21.0.0" "node": ">=18.0.0 <21.0.0"
}, },
@@ -40,8 +40,8 @@
"@aws-sdk/client-sqs": "^3.332.0", "@aws-sdk/client-sqs": "^3.332.0",
"@cbor-extract/cbor-extract-linux-arm64": "^2.1.1", "@cbor-extract/cbor-extract-linux-arm64": "^2.1.1",
"@cbor-extract/cbor-extract-linux-x64": "^2.1.1", "@cbor-extract/cbor-extract-linux-x64": "^2.1.1",
"@simplewebauthn/server": "^7.2.0", "@simplewebauthn/server": "^8.1.1",
"@simplewebauthn/typescript-types": "^7.0.0", "@simplewebauthn/typescript-types": "^8.0.0",
"@standardnotes/api": "^1.26.26", "@standardnotes/api": "^1.26.26",
"@standardnotes/common": "workspace:*", "@standardnotes/common": "workspace:*",
"@standardnotes/domain-core": "workspace:^", "@standardnotes/domain-core": "workspace:^",
+3 -11
View File
@@ -263,7 +263,6 @@ import { RedisTransitionStatusRepository } from '../Infra/Redis/RedisTransitionS
import { InMemoryTransitionStatusRepository } from '../Infra/InMemory/InMemoryTransitionStatusRepository' import { InMemoryTransitionStatusRepository } from '../Infra/InMemory/InMemoryTransitionStatusRepository'
import { TransitionStatusUpdatedEventHandler } from '../Domain/Handler/TransitionStatusUpdatedEventHandler' import { TransitionStatusUpdatedEventHandler } from '../Domain/Handler/TransitionStatusUpdatedEventHandler'
import { UpdateTransitionStatus } from '../Domain/UseCase/UpdateTransitionStatus/UpdateTransitionStatus' import { UpdateTransitionStatus } from '../Domain/UseCase/UpdateTransitionStatus/UpdateTransitionStatus'
import { GetTransitionStatus } from '../Domain/UseCase/GetTransitionStatus/GetTransitionStatus'
import { TypeORMSharedVaultUser } from '../Infra/TypeORM/TypeORMSharedVaultUser' import { TypeORMSharedVaultUser } from '../Infra/TypeORM/TypeORMSharedVaultUser'
import { SharedVaultUserPersistenceMapper } from '../Mapping/SharedVaultUserPersistenceMapper' import { SharedVaultUserPersistenceMapper } from '../Mapping/SharedVaultUserPersistenceMapper'
import { SharedVaultUserRepositoryInterface } from '../Domain/SharedVault/SharedVaultUserRepositoryInterface' import { SharedVaultUserRepositoryInterface } from '../Domain/SharedVault/SharedVaultUserRepositoryInterface'
@@ -274,6 +273,8 @@ import { UserAddedToSharedVaultEventHandler } from '../Domain/Handler/UserAddedT
import { UserRemovedFromSharedVaultEventHandler } from '../Domain/Handler/UserRemovedFromSharedVaultEventHandler' import { UserRemovedFromSharedVaultEventHandler } from '../Domain/Handler/UserRemovedFromSharedVaultEventHandler'
export class ContainerConfigLoader { export class ContainerConfigLoader {
constructor(private mode: 'server' | 'worker' = 'server') {}
async load(configuration?: { async load(configuration?: {
controllerConatiner?: ControllerContainerInterface controllerConatiner?: ControllerContainerInterface
directCallDomainEventPublisher?: DirectCallDomainEventPublisher directCallDomainEventPublisher?: DirectCallDomainEventPublisher
@@ -310,7 +311,7 @@ export class ContainerConfigLoader {
} }
container.bind<winston.Logger>(TYPES.Auth_Logger).toConstantValue(logger) container.bind<winston.Logger>(TYPES.Auth_Logger).toConstantValue(logger)
const appDataSource = new AppDataSource(env) const appDataSource = new AppDataSource({ env, runMigrations: this.mode === 'server' })
await appDataSource.initialize() await appDataSource.initialize()
logger.debug('Database initialized') logger.debug('Database initialized')
@@ -943,14 +944,6 @@ export class ContainerConfigLoader {
container.get<RoleServiceInterface>(TYPES.Auth_RoleService), container.get<RoleServiceInterface>(TYPES.Auth_RoleService),
), ),
) )
container
.bind<GetTransitionStatus>(TYPES.Auth_GetTransitionStatus)
.toConstantValue(
new GetTransitionStatus(
container.get<TransitionStatusRepositoryInterface>(TYPES.Auth_TransitionStatusRepository),
container.get<UserRepositoryInterface>(TYPES.Auth_UserRepository),
),
)
container container
.bind<AddSharedVaultUser>(TYPES.Auth_AddSharedVaultUser) .bind<AddSharedVaultUser>(TYPES.Auth_AddSharedVaultUser)
.toConstantValue( .toConstantValue(
@@ -1273,7 +1266,6 @@ export class ContainerConfigLoader {
container.get<ClearLoginAttempts>(TYPES.Auth_ClearLoginAttempts), container.get<ClearLoginAttempts>(TYPES.Auth_ClearLoginAttempts),
container.get<IncreaseLoginAttempts>(TYPES.Auth_IncreaseLoginAttempts), container.get<IncreaseLoginAttempts>(TYPES.Auth_IncreaseLoginAttempts),
container.get<ChangeCredentials>(TYPES.Auth_ChangeCredentials), container.get<ChangeCredentials>(TYPES.Auth_ChangeCredentials),
container.get<GetTransitionStatus>(TYPES.Auth_GetTransitionStatus),
container.get<ControllerContainerInterface>(TYPES.Auth_ControllerContainer), container.get<ControllerContainerInterface>(TYPES.Auth_ControllerContainer),
), ),
) )
+29 -24
View File
@@ -23,7 +23,12 @@ import { TypeORMSharedVaultUser } from '../Infra/TypeORM/TypeORMSharedVaultUser'
export class AppDataSource { export class AppDataSource {
private _dataSource: DataSource | undefined private _dataSource: DataSource | undefined
constructor(private env: Env) {} constructor(
private configuration: {
env: Env
runMigrations: boolean
},
) {}
getRepository<Entity extends ObjectLiteral>(target: EntityTarget<Entity>): Repository<Entity> { getRepository<Entity extends ObjectLiteral>(target: EntityTarget<Entity>): Repository<Entity> {
if (!this._dataSource) { if (!this._dataSource) {
@@ -38,12 +43,12 @@ export class AppDataSource {
} }
get dataSource(): DataSource { get dataSource(): DataSource {
this.env.load() this.configuration.env.load()
const isConfiguredForMySQL = this.env.get('DB_TYPE') === 'mysql' const isConfiguredForMySQL = this.configuration.env.get('DB_TYPE') === 'mysql'
const maxQueryExecutionTime = this.env.get('DB_MAX_QUERY_EXECUTION_TIME', true) const maxQueryExecutionTime = this.configuration.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
? +this.env.get('DB_MAX_QUERY_EXECUTION_TIME', true) ? +this.configuration.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
: 45_000 : 45_000
const commonDataSourceOptions = { const commonDataSourceOptions = {
@@ -68,28 +73,28 @@ export class AppDataSource {
TypeORMSharedVaultUser, TypeORMSharedVaultUser,
], ],
migrations: [`${__dirname}/../../migrations/${isConfiguredForMySQL ? 'mysql' : 'sqlite'}/*.js`], migrations: [`${__dirname}/../../migrations/${isConfiguredForMySQL ? 'mysql' : 'sqlite'}/*.js`],
migrationsRun: true, migrationsRun: this.configuration.runMigrations,
logging: <LoggerOptions>this.env.get('DB_DEBUG_LEVEL', true) ?? 'info', logging: <LoggerOptions>this.configuration.env.get('DB_DEBUG_LEVEL', true) ?? 'info',
} }
if (isConfiguredForMySQL) { if (isConfiguredForMySQL) {
const inReplicaMode = this.env.get('DB_REPLICA_HOST', true) ? true : false const inReplicaMode = this.configuration.env.get('DB_REPLICA_HOST', true) ? true : false
const replicationConfig = { const replicationConfig = {
master: { master: {
host: this.env.get('DB_HOST'), host: this.configuration.env.get('DB_HOST'),
port: parseInt(this.env.get('DB_PORT')), port: parseInt(this.configuration.env.get('DB_PORT')),
username: this.env.get('DB_USERNAME'), username: this.configuration.env.get('DB_USERNAME'),
password: this.env.get('DB_PASSWORD'), password: this.configuration.env.get('DB_PASSWORD'),
database: this.env.get('DB_DATABASE'), database: this.configuration.env.get('DB_DATABASE'),
}, },
slaves: [ slaves: [
{ {
host: this.env.get('DB_REPLICA_HOST', true), host: this.configuration.env.get('DB_REPLICA_HOST', true),
port: parseInt(this.env.get('DB_PORT')), port: parseInt(this.configuration.env.get('DB_PORT')),
username: this.env.get('DB_USERNAME'), username: this.configuration.env.get('DB_USERNAME'),
password: this.env.get('DB_PASSWORD'), password: this.configuration.env.get('DB_PASSWORD'),
database: this.env.get('DB_DATABASE'), database: this.configuration.env.get('DB_DATABASE'),
}, },
], ],
removeNodeErrorCount: 10, removeNodeErrorCount: 10,
@@ -103,11 +108,11 @@ export class AppDataSource {
supportBigNumbers: true, supportBigNumbers: true,
bigNumberStrings: false, bigNumberStrings: false,
replication: inReplicaMode ? replicationConfig : undefined, replication: inReplicaMode ? replicationConfig : undefined,
host: inReplicaMode ? undefined : this.env.get('DB_HOST'), host: inReplicaMode ? undefined : this.configuration.env.get('DB_HOST'),
port: inReplicaMode ? undefined : parseInt(this.env.get('DB_PORT')), port: inReplicaMode ? undefined : parseInt(this.configuration.env.get('DB_PORT')),
username: inReplicaMode ? undefined : this.env.get('DB_USERNAME'), username: inReplicaMode ? undefined : this.configuration.env.get('DB_USERNAME'),
password: inReplicaMode ? undefined : this.env.get('DB_PASSWORD'), password: inReplicaMode ? undefined : this.configuration.env.get('DB_PASSWORD'),
database: inReplicaMode ? undefined : this.env.get('DB_DATABASE'), database: inReplicaMode ? undefined : this.configuration.env.get('DB_DATABASE'),
} }
this._dataSource = new DataSource(mySQLDataSourceOptions) this._dataSource = new DataSource(mySQLDataSourceOptions)
@@ -115,7 +120,7 @@ export class AppDataSource {
const sqliteDataSourceOptions: SqliteConnectionOptions = { const sqliteDataSourceOptions: SqliteConnectionOptions = {
...commonDataSourceOptions, ...commonDataSourceOptions,
type: 'sqlite', type: 'sqlite',
database: this.env.get('DB_SQLITE_DATABASE_PATH'), database: this.configuration.env.get('DB_SQLITE_DATABASE_PATH'),
enableWAL: true, enableWAL: true,
busyErrorRetry: 2000, busyErrorRetry: 2000,
} }
@@ -4,4 +4,4 @@ import { Env } from './Env'
const env: Env = new Env() const env: Env = new Env()
env.load() env.load()
export const MigrationsDataSource = new AppDataSource(env).dataSource export const MigrationsDataSource = new AppDataSource({ env, runMigrations: true }).dataSource
-1
View File
@@ -159,7 +159,6 @@ const TYPES = {
Auth_GetUserKeyParamsRecovery: Symbol.for('Auth_GetUserKeyParamsRecovery'), Auth_GetUserKeyParamsRecovery: Symbol.for('Auth_GetUserKeyParamsRecovery'),
Auth_UpdateStorageQuotaUsedForUser: Symbol.for('Auth_UpdateStorageQuotaUsedForUser'), Auth_UpdateStorageQuotaUsedForUser: Symbol.for('Auth_UpdateStorageQuotaUsedForUser'),
Auth_UpdateTransitionStatus: Symbol.for('Auth_UpdateTransitionStatus'), Auth_UpdateTransitionStatus: Symbol.for('Auth_UpdateTransitionStatus'),
Auth_GetTransitionStatus: Symbol.for('Auth_GetTransitionStatus'),
Auth_AddSharedVaultUser: Symbol.for('Auth_AddSharedVaultUser'), Auth_AddSharedVaultUser: Symbol.for('Auth_AddSharedVaultUser'),
Auth_RemoveSharedVaultUser: Symbol.for('Auth_RemoveSharedVaultUser'), Auth_RemoveSharedVaultUser: Symbol.for('Auth_RemoveSharedVaultUser'),
// Handlers // Handlers
@@ -20,6 +20,7 @@ import {
StatisticPersistenceRequestedEvent, StatisticPersistenceRequestedEvent,
SessionCreatedEvent, SessionCreatedEvent,
SessionRefreshedEvent, SessionRefreshedEvent,
TransitionRequestedEvent,
} from '@standardnotes/domain-events' } from '@standardnotes/domain-events'
import { Predicate, PredicateVerificationResult } from '@standardnotes/predicates' import { Predicate, PredicateVerificationResult } from '@standardnotes/predicates'
import { TimerInterface } from '@standardnotes/time' import { TimerInterface } from '@standardnotes/time'
@@ -32,6 +33,25 @@ import { DomainEventFactoryInterface } from './DomainEventFactoryInterface'
export class DomainEventFactory implements DomainEventFactoryInterface { export class DomainEventFactory implements DomainEventFactoryInterface {
constructor(@inject(TYPES.Auth_Timer) private timer: TimerInterface) {} constructor(@inject(TYPES.Auth_Timer) private timer: TimerInterface) {}
createTransitionRequestedEvent(dto: {
userUuid: string
type: 'items' | 'revisions'
timestamp: number
}): TransitionRequestedEvent {
return {
type: 'TRANSITION_REQUESTED',
createdAt: this.timer.getUTCDate(),
meta: {
correlation: {
userIdentifier: dto.userUuid,
userIdentifierType: 'uuid',
},
origin: DomainEventService.Auth,
},
payload: dto,
}
}
createSessionCreatedEvent(dto: { userUuid: string }): SessionCreatedEvent { createSessionCreatedEvent(dto: { userUuid: string }): SessionCreatedEvent {
return { return {
type: 'SESSION_CREATED', type: 'SESSION_CREATED',
@@ -18,6 +18,7 @@ import {
StatisticPersistenceRequestedEvent, StatisticPersistenceRequestedEvent,
SessionCreatedEvent, SessionCreatedEvent,
SessionRefreshedEvent, SessionRefreshedEvent,
TransitionRequestedEvent,
} from '@standardnotes/domain-events' } from '@standardnotes/domain-events'
import { InviteeIdentifierType } from '../SharedSubscription/InviteeIdentifierType' import { InviteeIdentifierType } from '../SharedSubscription/InviteeIdentifierType'
@@ -89,4 +90,9 @@ export interface DomainEventFactoryInterface {
}): StatisticPersistenceRequestedEvent }): StatisticPersistenceRequestedEvent
createSessionCreatedEvent(dto: { userUuid: string }): SessionCreatedEvent createSessionCreatedEvent(dto: { userUuid: string }): SessionCreatedEvent
createSessionRefreshedEvent(dto: { userUuid: string }): SessionRefreshedEvent createSessionRefreshedEvent(dto: { userUuid: string }): SessionRefreshedEvent
createTransitionRequestedEvent(dto: {
userUuid: string
type: 'items' | 'revisions'
timestamp: number
}): TransitionRequestedEvent
} }
@@ -13,6 +13,7 @@ export class TransitionStatusUpdatedEventHandler implements DomainEventHandlerIn
status: event.payload.status, status: event.payload.status,
userUuid: event.payload.userUuid, userUuid: event.payload.userUuid,
transitionType: event.payload.transitionType, transitionType: event.payload.transitionType,
transitionTimestamp: event.payload.transitionTimestamp,
}) })
if (result.isFailed()) { if (result.isFailed()) {
@@ -1,5 +1,11 @@
export interface TransitionStatusRepositoryInterface { export interface TransitionStatusRepositoryInterface {
updateStatus(userUuid: string, transitionType: 'items' | 'revisions', status: 'STARTED' | 'FAILED'): Promise<void> updateStatus(
removeStatus(userUuid: string, transitionType: 'items' | 'revisions'): Promise<void> userUuid: string,
getStatus(userUuid: string, transitionType: 'items' | 'revisions'): Promise<'STARTED' | 'FAILED' | null> transitionType: 'items' | 'revisions',
status: 'STARTED' | 'IN_PROGRESS' | 'FINISHED' | 'FAILED' | 'VERIFIED',
): Promise<void>
getStatus(
userUuid: string,
transitionType: 'items' | 'revisions',
): Promise<'STARTED' | 'IN_PROGRESS' | 'FINISHED' | 'FAILED' | 'VERIFIED' | null>
} }
@@ -113,13 +113,14 @@ 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,
) )
}) })
it('should create a cross service token for user that has an ongoing transaction', async () => { it('should create a cross service token for user that has an ongoing transaction', async () => {
transitionStatusRepository.getStatus = jest.fn().mockReturnValue('STARTED') transitionStatusRepository.getStatus = jest.fn().mockReturnValue('IN_PROGRESS')
await createUseCase().execute({ await createUseCase().execute({
user, user,
@@ -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
@@ -59,7 +60,9 @@ export class CreateCrossServiceToken implements UseCaseInterface<string> {
user: this.projectUser(user), user: this.projectUser(user),
roles: this.projectRoles(roles), roles: this.projectRoles(roles),
shared_vault_owner_context: undefined, shared_vault_owner_context: undefined,
ongoing_transition: transitionStatus === 'STARTED', 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,
@@ -35,7 +35,7 @@ export class GenerateAuthenticatorAuthenticationOptions
.update(`u2f-selector-${dto.username}${this.pseudoKeyParamsKey}`) .update(`u2f-selector-${dto.username}${this.pseudoKeyParamsKey}`)
.digest('base64url') .digest('base64url')
const options = generateAuthenticationOptions({ const options = await generateAuthenticationOptions({
allowCredentials: [ allowCredentials: [
{ {
id: Buffer.from(credentialIdHash), id: Buffer.from(credentialIdHash),
@@ -56,7 +56,7 @@ export class GenerateAuthenticatorAuthenticationOptions
const userUuid = userUuidOrError.getValue() const userUuid = userUuidOrError.getValue()
const authenticators = await this.authenticatorRepository.findByUserUuid(userUuid) const authenticators = await this.authenticatorRepository.findByUserUuid(userUuid)
const options = generateAuthenticationOptions({ const options = await generateAuthenticationOptions({
allowCredentials: authenticators.map((authenticator) => ({ allowCredentials: authenticators.map((authenticator) => ({
id: authenticator.props.credentialId, id: authenticator.props.credentialId,
type: 'public-key', type: 'public-key',
@@ -52,7 +52,7 @@ export class GenerateAuthenticatorRegistrationOptions
} }
const authenticators = await this.authenticatorRepository.findByUserUuid(userUuid) const authenticators = await this.authenticatorRepository.findByUserUuid(userUuid)
const options = generateRegistrationOptions({ const options = await generateRegistrationOptions({
rpID: this.relyingPartyId, rpID: this.relyingPartyId,
rpName: this.relyingPartyName, rpName: this.relyingPartyName,
userID: userUuid.value, userID: userUuid.value,
@@ -1,114 +0,0 @@
import { RoleName } from '@standardnotes/domain-core'
import { Role } from '../../Role/Role'
import { TransitionStatusRepositoryInterface } from '../../Transition/TransitionStatusRepositoryInterface'
import { User } from '../../User/User'
import { UserRepositoryInterface } from '../../User/UserRepositoryInterface'
import { GetTransitionStatus } from './GetTransitionStatus'
describe('GetTransitionStatus', () => {
let transitionStatusRepository: TransitionStatusRepositoryInterface
let userRepository: UserRepositoryInterface
let user: User
let role: Role
const createUseCase = () => new GetTransitionStatus(transitionStatusRepository, userRepository)
beforeEach(() => {
transitionStatusRepository = {} as jest.Mocked<TransitionStatusRepositoryInterface>
transitionStatusRepository.getStatus = jest.fn().mockReturnValue(null)
role = {} as jest.Mocked<Role>
role.name = RoleName.NAMES.CoreUser
user = {
uuid: '00000000-0000-0000-0000-000000000000',
email: 'test@test.te',
} as jest.Mocked<User>
user.roles = Promise.resolve([role])
userRepository = {} as jest.Mocked<UserRepositoryInterface>
userRepository.findOneByUuid = jest.fn().mockReturnValue(user)
})
it('returns transition status FINISHED', async () => {
role.name = RoleName.NAMES.TransitionUser
user.roles = Promise.resolve([role])
userRepository.findOneByUuid = jest.fn().mockReturnValue(user)
const useCase = createUseCase()
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
transitionType: 'items',
})
expect(result.isFailed()).toBeFalsy()
expect(result.getValue()).toEqual('FINISHED')
})
it('returns transition status STARTED', async () => {
const useCase = createUseCase()
transitionStatusRepository.getStatus = jest.fn().mockReturnValue('STARTED')
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
transitionType: 'items',
})
expect(result.isFailed()).toBeFalsy()
expect(result.getValue()).toEqual('STARTED')
})
it('returns transition status TO-DO', async () => {
const useCase = createUseCase()
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
transitionType: 'items',
})
expect(result.isFailed()).toBeFalsy()
expect(result.getValue()).toEqual('TO-DO')
})
it('returns transition status FAILED', async () => {
const useCase = createUseCase()
transitionStatusRepository.getStatus = jest.fn().mockReturnValue('FAILED')
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
transitionType: 'items',
})
expect(result.isFailed()).toBeFalsy()
expect(result.getValue()).toEqual('FAILED')
})
it('return error if user uuid is invalid', async () => {
const useCase = createUseCase()
const result = await useCase.execute({
userUuid: 'invalid',
transitionType: 'items',
})
expect(result.isFailed()).toBeTruthy()
expect(result.getError()).toEqual('Given value is not a valid uuid: invalid')
})
it('return error if user not found', async () => {
const useCase = createUseCase()
userRepository.findOneByUuid = jest.fn().mockReturnValue(null)
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
transitionType: 'items',
})
expect(result.isFailed()).toBeTruthy()
expect(result.getError()).toEqual('User not found.')
})
})
@@ -1,39 +0,0 @@
import { Result, RoleName, UseCaseInterface, Uuid } from '@standardnotes/domain-core'
import { GetTransitionStatusDTO } from './GetTransitionStatusDTO'
import { UserRepositoryInterface } from '../../User/UserRepositoryInterface'
import { TransitionStatusRepositoryInterface } from '../../Transition/TransitionStatusRepositoryInterface'
export class GetTransitionStatus implements UseCaseInterface<'TO-DO' | 'STARTED' | 'FINISHED' | 'FAILED'> {
constructor(
private transitionStatusRepository: TransitionStatusRepositoryInterface,
private userRepository: UserRepositoryInterface,
) {}
async execute(dto: GetTransitionStatusDTO): Promise<Result<'TO-DO' | 'STARTED' | 'FINISHED' | 'FAILED'>> {
const userUuidOrError = Uuid.create(dto.userUuid)
if (userUuidOrError.isFailed()) {
return Result.fail(userUuidOrError.getError())
}
const userUuid = userUuidOrError.getValue()
const user = await this.userRepository.findOneByUuid(userUuid)
if (user === null) {
return Result.fail('User not found.')
}
const roles = await user.roles
for (const role of roles) {
if (role.name === RoleName.NAMES.TransitionUser) {
return Result.ok('FINISHED')
}
}
const transitionStatus = await this.transitionStatusRepository.getStatus(userUuid.value, dto.transitionType)
if (transitionStatus === null) {
return Result.ok('TO-DO')
}
return Result.ok(transitionStatus)
}
}
@@ -1,4 +0,0 @@
export interface GetTransitionStatusDTO {
userUuid: string
transitionType: 'items' | 'revisions'
}
@@ -12,27 +12,23 @@ describe('UpdateTransitionStatus', () => {
beforeEach(() => { beforeEach(() => {
transitionStatusRepository = {} as jest.Mocked<TransitionStatusRepositoryInterface> transitionStatusRepository = {} as jest.Mocked<TransitionStatusRepositoryInterface>
transitionStatusRepository.removeStatus = jest.fn()
transitionStatusRepository.updateStatus = jest.fn() transitionStatusRepository.updateStatus = jest.fn()
roleService = {} as jest.Mocked<RoleServiceInterface> roleService = {} as jest.Mocked<RoleServiceInterface>
roleService.addRoleToUser = jest.fn() roleService.addRoleToUser = jest.fn()
}) })
it('should remove transition status and add TransitionUser role', async () => { it('should add TRANSITION_USER role', async () => {
const useCase = createUseCase() const useCase = createUseCase()
const result = await useCase.execute({ const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000', userUuid: '00000000-0000-0000-0000-000000000000',
status: 'FINISHED', status: 'VERIFIED',
transitionType: 'items', transitionType: 'items',
transitionTimestamp: 123,
}) })
expect(result.isFailed()).toBeFalsy() expect(result.isFailed()).toBeFalsy()
expect(transitionStatusRepository.removeStatus).toHaveBeenCalledWith(
'00000000-0000-0000-0000-000000000000',
'items',
)
expect(roleService.addRoleToUser).toHaveBeenCalledWith( expect(roleService.addRoleToUser).toHaveBeenCalledWith(
Uuid.create('00000000-0000-0000-0000-000000000000').getValue(), Uuid.create('00000000-0000-0000-0000-000000000000').getValue(),
RoleName.create(RoleName.NAMES.TransitionUser).getValue(), RoleName.create(RoleName.NAMES.TransitionUser).getValue(),
@@ -46,6 +42,7 @@ describe('UpdateTransitionStatus', () => {
userUuid: '00000000-0000-0000-0000-000000000000', userUuid: '00000000-0000-0000-0000-000000000000',
status: 'STARTED', status: 'STARTED',
transitionType: 'items', transitionType: 'items',
transitionTimestamp: 123,
}) })
expect(result.isFailed()).toBeFalsy() expect(result.isFailed()).toBeFalsy()
@@ -63,6 +60,7 @@ describe('UpdateTransitionStatus', () => {
userUuid: 'invalid', userUuid: 'invalid',
status: 'STARTED', status: 'STARTED',
transitionType: 'items', transitionType: 'items',
transitionTimestamp: 123,
}) })
expect(result.isFailed()).toBeTruthy() expect(result.isFailed()).toBeTruthy()
@@ -16,16 +16,12 @@ export class UpdateTransitionStatus implements UseCaseInterface<void> {
} }
const userUuid = userUuidOrError.getValue() const userUuid = userUuidOrError.getValue()
if (dto.status === 'FINISHED') {
await this.transitionStatusRepository.removeStatus(dto.userUuid, dto.transitionType)
await this.roleService.addRoleToUser(userUuid, RoleName.create(RoleName.NAMES.TransitionUser).getValue())
return Result.ok()
}
await this.transitionStatusRepository.updateStatus(dto.userUuid, dto.transitionType, dto.status) await this.transitionStatusRepository.updateStatus(dto.userUuid, dto.transitionType, dto.status)
if (dto.transitionType === 'items' && dto.status === 'VERIFIED') {
await this.roleService.addRoleToUser(userUuid, RoleName.create(RoleName.NAMES.TransitionUser).getValue())
}
return Result.ok() return Result.ok()
} }
} }
@@ -1,5 +1,6 @@
export interface UpdateTransitionStatusDTO { export interface UpdateTransitionStatusDTO {
userUuid: string userUuid: string
transitionType: 'items' | 'revisions' transitionType: 'items' | 'revisions'
status: 'STARTED' | 'FINISHED' | 'FAILED' transitionTimestamp: number
status: 'STARTED' | 'IN_PROGRESS' | 'FINISHED' | 'FAILED' | 'VERIFIED'
} }
@@ -8,6 +8,7 @@ export interface UserRepositoryInterface {
streamTeam(memberEmail?: Email): Promise<ReadStream> streamTeam(memberEmail?: Email): Promise<ReadStream>
findOneByUuid(uuid: Uuid): Promise<User | null> findOneByUuid(uuid: Uuid): Promise<User | null>
findOneByUsernameOrEmail(usernameOrEmail: Email | Username): Promise<User | null> findOneByUsernameOrEmail(usernameOrEmail: Email | Username): Promise<User | null>
findAllCreatedBetween(start: Date, end: Date): Promise<User[]>
save(user: User): Promise<User> save(user: User): Promise<User>
remove(user: User): Promise<User> remove(user: User): Promise<User>
} }
@@ -14,7 +14,6 @@ import { IncreaseLoginAttempts } from '../../Domain/UseCase/IncreaseLoginAttempt
import { InviteToSharedSubscription } from '../../Domain/UseCase/InviteToSharedSubscription/InviteToSharedSubscription' import { InviteToSharedSubscription } from '../../Domain/UseCase/InviteToSharedSubscription/InviteToSharedSubscription'
import { UpdateUser } from '../../Domain/UseCase/UpdateUser' import { UpdateUser } from '../../Domain/UseCase/UpdateUser'
import { User } from '../../Domain/User/User' import { User } from '../../Domain/User/User'
import { GetTransitionStatus } from '../../Domain/UseCase/GetTransitionStatus/GetTransitionStatus'
describe('AnnotatedUsersController', () => { describe('AnnotatedUsersController', () => {
let updateUser: UpdateUser let updateUser: UpdateUser
@@ -25,7 +24,6 @@ describe('AnnotatedUsersController', () => {
let increaseLoginAttempts: IncreaseLoginAttempts let increaseLoginAttempts: IncreaseLoginAttempts
let changeCredentials: ChangeCredentials let changeCredentials: ChangeCredentials
let inviteToSharedSubscription: InviteToSharedSubscription let inviteToSharedSubscription: InviteToSharedSubscription
let getTransitionStatus: GetTransitionStatus
let request: express.Request let request: express.Request
let response: express.Response let response: express.Response
@@ -40,7 +38,6 @@ describe('AnnotatedUsersController', () => {
clearLoginAttempts, clearLoginAttempts,
increaseLoginAttempts, increaseLoginAttempts,
changeCredentials, changeCredentials,
getTransitionStatus,
) )
beforeEach(() => { beforeEach(() => {
@@ -72,9 +69,6 @@ describe('AnnotatedUsersController', () => {
inviteToSharedSubscription = {} as jest.Mocked<InviteToSharedSubscription> inviteToSharedSubscription = {} as jest.Mocked<InviteToSharedSubscription>
inviteToSharedSubscription.execute = jest.fn() inviteToSharedSubscription.execute = jest.fn()
getTransitionStatus = {} as jest.Mocked<GetTransitionStatus>
getTransitionStatus.execute = jest.fn()
request = { request = {
headers: {}, headers: {},
body: {}, body: {},
@@ -18,7 +18,6 @@ import { ClearLoginAttempts } from '../../Domain/UseCase/ClearLoginAttempts'
import { IncreaseLoginAttempts } from '../../Domain/UseCase/IncreaseLoginAttempts' import { IncreaseLoginAttempts } from '../../Domain/UseCase/IncreaseLoginAttempts'
import { ChangeCredentials } from '../../Domain/UseCase/ChangeCredentials/ChangeCredentials' import { ChangeCredentials } from '../../Domain/UseCase/ChangeCredentials/ChangeCredentials'
import { BaseUsersController } from './Base/BaseUsersController' import { BaseUsersController } from './Base/BaseUsersController'
import { GetTransitionStatus } from '../../Domain/UseCase/GetTransitionStatus/GetTransitionStatus'
@controller('/users') @controller('/users')
export class AnnotatedUsersController extends BaseUsersController { export class AnnotatedUsersController extends BaseUsersController {
@@ -30,7 +29,6 @@ export class AnnotatedUsersController extends BaseUsersController {
@inject(TYPES.Auth_ClearLoginAttempts) override clearLoginAttempts: ClearLoginAttempts, @inject(TYPES.Auth_ClearLoginAttempts) override clearLoginAttempts: ClearLoginAttempts,
@inject(TYPES.Auth_IncreaseLoginAttempts) override increaseLoginAttempts: IncreaseLoginAttempts, @inject(TYPES.Auth_IncreaseLoginAttempts) override increaseLoginAttempts: IncreaseLoginAttempts,
@inject(TYPES.Auth_ChangeCredentials) override changeCredentialsUseCase: ChangeCredentials, @inject(TYPES.Auth_ChangeCredentials) override changeCredentialsUseCase: ChangeCredentials,
@inject(TYPES.Auth_GetTransitionStatus) override getTransitionStatusUseCase: GetTransitionStatus,
) { ) {
super( super(
updateUser, updateUser,
@@ -40,7 +38,6 @@ export class AnnotatedUsersController extends BaseUsersController {
clearLoginAttempts, clearLoginAttempts,
increaseLoginAttempts, increaseLoginAttempts,
changeCredentialsUseCase, changeCredentialsUseCase,
getTransitionStatusUseCase,
) )
} }
@@ -54,11 +51,6 @@ export class AnnotatedUsersController extends BaseUsersController {
return super.keyParams(request) return super.keyParams(request)
} }
@httpGet('/transition-status', TYPES.Auth_RequiredCrossServiceTokenMiddleware)
override async transitionStatus(request: Request, response: Response): Promise<results.JsonResult> {
return super.transitionStatus(request, response)
}
@httpDelete('/:userUuid', TYPES.Auth_RequiredCrossServiceTokenMiddleware) @httpDelete('/:userUuid', TYPES.Auth_RequiredCrossServiceTokenMiddleware)
override async deleteAccount(request: Request, response: Response): Promise<results.JsonResult> { override async deleteAccount(request: Request, response: Response): Promise<results.JsonResult> {
return super.deleteAccount(request, response) return super.deleteAccount(request, response)
@@ -10,7 +10,6 @@ import { GetUserSubscription } from '../../../Domain/UseCase/GetUserSubscription
import { IncreaseLoginAttempts } from '../../../Domain/UseCase/IncreaseLoginAttempts' import { IncreaseLoginAttempts } from '../../../Domain/UseCase/IncreaseLoginAttempts'
import { UpdateUser } from '../../../Domain/UseCase/UpdateUser' import { UpdateUser } from '../../../Domain/UseCase/UpdateUser'
import { ErrorTag } from '@standardnotes/responses' import { ErrorTag } from '@standardnotes/responses'
import { GetTransitionStatus } from '../../../Domain/UseCase/GetTransitionStatus/GetTransitionStatus'
export class BaseUsersController extends BaseHttpController { export class BaseUsersController extends BaseHttpController {
constructor( constructor(
@@ -21,7 +20,6 @@ export class BaseUsersController extends BaseHttpController {
protected clearLoginAttempts: ClearLoginAttempts, protected clearLoginAttempts: ClearLoginAttempts,
protected increaseLoginAttempts: IncreaseLoginAttempts, protected increaseLoginAttempts: IncreaseLoginAttempts,
protected changeCredentialsUseCase: ChangeCredentials, protected changeCredentialsUseCase: ChangeCredentials,
protected getTransitionStatusUseCase: GetTransitionStatus,
private controllerContainer?: ControllerContainerInterface, private controllerContainer?: ControllerContainerInterface,
) { ) {
super() super()
@@ -32,7 +30,6 @@ export class BaseUsersController extends BaseHttpController {
this.controllerContainer.register('auth.users.getSubscription', this.getSubscription.bind(this)) this.controllerContainer.register('auth.users.getSubscription', this.getSubscription.bind(this))
this.controllerContainer.register('auth.users.updateCredentials', this.changeCredentials.bind(this)) this.controllerContainer.register('auth.users.updateCredentials', this.changeCredentials.bind(this))
this.controllerContainer.register('auth.users.delete', this.deleteAccount.bind(this)) this.controllerContainer.register('auth.users.delete', this.deleteAccount.bind(this))
this.controllerContainer.register('auth.users.transition-status', this.transitionStatus.bind(this))
} }
} }
@@ -106,30 +103,6 @@ export class BaseUsersController extends BaseHttpController {
return this.json(result.keyParams) return this.json(result.keyParams)
} }
async transitionStatus(_request: Request, response: Response): Promise<results.JsonResult> {
const result = await this.getTransitionStatusUseCase.execute({
userUuid: response.locals.user.uuid,
transitionType: 'items',
})
if (result.isFailed()) {
return this.json(
{
error: {
message: result.getError(),
},
},
400,
)
}
response.setHeader('x-invalidate-cache', response.locals.user.uuid)
return this.json({
status: result.getValue(),
})
}
async deleteAccount(request: Request, response: Response): Promise<results.JsonResult> { async deleteAccount(request: Request, response: Response): Promise<results.JsonResult> {
if (request.params.userUuid !== response.locals.user.uuid) { if (request.params.userUuid !== response.locals.user.uuid) {
return this.json( return this.json(
@@ -10,21 +10,32 @@ 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' | 'FINISHED' | 'FAILED' | 'VERIFIED',
): Promise<void> { ): Promise<void> {
await this.redisClient.set(`${this.PREFIX}:${transitionType}:${userUuid}`, status) switch (status) {
case 'FAILED':
case 'VERIFIED':
await this.redisClient.set(`${this.PREFIX}:${transitionType}:${userUuid}`, status)
break
case 'IN_PROGRESS': {
const ttl2Hourse = 7_200
await this.redisClient.setex(`${this.PREFIX}:${transitionType}:${userUuid}`, ttl2Hourse, status)
break
}
default: {
const ttl10Hours = 36_000
await this.redisClient.setex(`${this.PREFIX}:${transitionType}:${userUuid}`, ttl10Hours, status)
break
}
}
} }
async removeStatus(userUuid: string, transitionType: 'items' | 'revisions'): Promise<void> { async getStatus(
await this.redisClient.del(`${this.PREFIX}:${transitionType}:${userUuid}`) userUuid: string,
} transitionType: 'items' | 'revisions',
): Promise<'STARTED' | 'IN_PROGRESS' | 'FINISHED' | 'FAILED' | 'VERIFIED' | null> {
const status = await this.redisClient.get(`${this.PREFIX}:${transitionType}:${userUuid}`)
async getStatus(userUuid: string, transitionType: 'items' | 'revisions'): Promise<'STARTED' | 'FAILED' | null> { return status as 'STARTED' | 'IN_PROGRESS' | 'FINISHED' | 'FAILED' | 'VERIFIED' | null
const status = (await this.redisClient.get(`${this.PREFIX}:${transitionType}:${userUuid}`)) as
| 'STARTED'
| 'FAILED'
| null
return status
} }
} }
@@ -14,6 +14,13 @@ export class TypeORMUserRepository implements UserRepositoryInterface {
private ormRepository: Repository<User>, private ormRepository: Repository<User>,
) {} ) {}
async findAllCreatedBetween(start: Date, end: Date): Promise<User[]> {
return this.ormRepository
.createQueryBuilder('user')
.where('user.created_at BETWEEN :start AND :end', { start, end })
.getMany()
}
async save(user: User): Promise<User> { async save(user: User): Promise<User> {
return this.ormRepository.save(user) return this.ormRepository.save(user)
} }
+12
View File
@@ -3,6 +3,18 @@
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.28.1](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.28.0...@standardnotes/domain-core@1.28.1) (2023-09-12)
### Bug Fixes
* comparing uuids ([0a1d162](https://github.com/standardnotes/server/commit/0a1d1624e818000f2e951f29323a88e6e233c755))
# [1.28.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.27.0...@standardnotes/domain-core@1.28.0) (2023-09-07)
### Features
* add VaultsUser role name ([#809](https://github.com/standardnotes/server/issues/809)) ([d4830de](https://github.com/standardnotes/server/commit/d4830dec018139ffaf93d0e91d6655c5dcc6be9c))
# [1.27.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.26.3...@standardnotes/domain-core@1.27.0) (2023-09-06) # [1.27.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.26.3...@standardnotes/domain-core@1.27.0) (2023-09-06)
### Features ### Features
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@standardnotes/domain-core", "name": "@standardnotes/domain-core",
"version": "1.27.0", "version": "1.28.1",
"engines": { "engines": {
"node": ">=18.0.0 <21.0.0" "node": ">=18.0.0 <21.0.0"
}, },
@@ -9,6 +9,7 @@ export class RoleName extends ValueObject<RoleNameProps> {
ProUser: 'PRO_USER', ProUser: 'PRO_USER',
InternalTeamUser: 'INTERNAL_TEAM_USER', InternalTeamUser: 'INTERNAL_TEAM_USER',
TransitionUser: 'TRANSITION_USER', TransitionUser: 'TRANSITION_USER',
VaultsUser: 'VAULTS_USER',
} }
get value(): string { get value(): string {
@@ -32,6 +33,7 @@ export class RoleName extends ValueObject<RoleNameProps> {
) )
case RoleName.NAMES.CoreUser: case RoleName.NAMES.CoreUser:
case RoleName.NAMES.TransitionUser: case RoleName.NAMES.TransitionUser:
case RoleName.NAMES.VaultsUser:
return [RoleName.NAMES.CoreUser, RoleName.NAMES.TransitionUser].includes(roleName.value) return [RoleName.NAMES.CoreUser, RoleName.NAMES.TransitionUser].includes(roleName.value)
/*istanbul ignore next*/ /*istanbul ignore next*/
default: default:
@@ -51,7 +51,7 @@ describe('RoleNameCollection', () => {
}) })
it('should tell if collection has a role with more or equal power to', () => { it('should tell if collection has a role with more or equal power to', () => {
let roles = [RoleName.NAMES.CoreUser] let roles = [RoleName.NAMES.VaultsUser]
let valueOrError = RoleNameCollection.create(roles) let valueOrError = RoleNameCollection.create(roles)
let roleNames = valueOrError.getValue() let roleNames = valueOrError.getValue()
@@ -63,6 +63,18 @@ describe('RoleNameCollection', () => {
roleNames.hasARoleNameWithMoreOrEqualPowerTo(RoleName.create(RoleName.NAMES.CoreUser).getValue()), roleNames.hasARoleNameWithMoreOrEqualPowerTo(RoleName.create(RoleName.NAMES.CoreUser).getValue()),
).toBeTruthy() ).toBeTruthy()
roles = [RoleName.NAMES.CoreUser]
valueOrError = RoleNameCollection.create(roles)
roleNames = valueOrError.getValue()
expect(
roleNames.hasARoleNameWithMoreOrEqualPowerTo(RoleName.create(RoleName.NAMES.PlusUser).getValue()),
).toBeFalsy()
expect(roleNames.hasARoleNameWithMoreOrEqualPowerTo(RoleName.create(RoleName.NAMES.ProUser).getValue())).toBeFalsy()
expect(
roleNames.hasARoleNameWithMoreOrEqualPowerTo(RoleName.create(RoleName.NAMES.CoreUser).getValue()),
).toBeTruthy()
roles = [RoleName.NAMES.CoreUser, RoleName.NAMES.PlusUser] roles = [RoleName.NAMES.CoreUser, RoleName.NAMES.PlusUser]
valueOrError = RoleNameCollection.create(roles) valueOrError = RoleNameCollection.create(roles)
roleNames = valueOrError.getValue() roleNames = valueOrError.getValue()
@@ -8,6 +8,13 @@ describe('Uuid', () => {
expect(valueOrError.getValue().value).toEqual('84c0f8e8-544a-4c7e-9adf-26209303bc1d') expect(valueOrError.getValue().value).toEqual('84c0f8e8-544a-4c7e-9adf-26209303bc1d')
}) })
it('should create a value object on upper case', () => {
const valueOrError = Uuid.create('00B57455-B563-4B50-A2AA-B19762102219')
expect(valueOrError.isFailed()).toBeFalsy()
expect(valueOrError.getValue().value).toEqual('00B57455-B563-4B50-A2AA-B19762102219')
})
it('should not create an invalid value object', () => { it('should not create an invalid value object', () => {
const valueOrError = Uuid.create('1-2-3') const valueOrError = Uuid.create('1-2-3')
+28
View File
@@ -3,6 +3,34 @@
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.29](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.12.28...@standardnotes/domain-events-infra@1.12.29) (2023-09-15)
**Note:** Version bump only for package @standardnotes/domain-events-infra
## [1.12.28](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.12.27...@standardnotes/domain-events-infra@1.12.28) (2023-09-13)
**Note:** Version bump only for package @standardnotes/domain-events-infra
## [1.12.27](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.12.26...@standardnotes/domain-events-infra@1.12.27) (2023-09-12)
**Note:** Version bump only for package @standardnotes/domain-events-infra
## [1.12.26](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.12.25...@standardnotes/domain-events-infra@1.12.26) (2023-09-12)
**Note:** Version bump only for package @standardnotes/domain-events-infra
## [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)
**Note:** Version bump only for package @standardnotes/domain-events-infra
## [1.12.23](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.12.22...@standardnotes/domain-events-infra@1.12.23) (2023-09-07)
**Note:** Version bump only for package @standardnotes/domain-events-infra
## [1.12.22](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.12.21...@standardnotes/domain-events-infra@1.12.22) (2023-09-06) ## [1.12.22](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.12.21...@standardnotes/domain-events-infra@1.12.22) (2023-09-06)
**Note:** Version bump only for package @standardnotes/domain-events-infra **Note:** Version bump only for package @standardnotes/domain-events-infra
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@standardnotes/domain-events-infra", "name": "@standardnotes/domain-events-infra",
"version": "1.12.22", "version": "1.12.29",
"engines": { "engines": {
"node": ">=18.0.0 <21.0.0" "node": ">=18.0.0 <21.0.0"
}, },
+40
View File
@@ -3,6 +3,46 @@
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.126.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.125.4...@standardnotes/domain-events@2.126.0) (2023-09-15)
### Features
* add skipping verified transitions ([#827](https://github.com/standardnotes/server/issues/827)) ([d4d4945](https://github.com/standardnotes/server/commit/d4d49454a68de0acdf440dc202fa14b9743905f6))
## [2.125.4](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.125.3...@standardnotes/domain-events@2.125.4) (2023-09-13)
### Bug Fixes
* display transition progress in logs ([38685c1](https://github.com/standardnotes/server/commit/38685c1861b13e398dd96aa39f2cf1aece2090fb))
## [2.125.3](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.125.2...@standardnotes/domain-events@2.125.3) (2023-09-12)
### Bug Fixes
* retry failed revision transitions ([e535cd5](https://github.com/standardnotes/server/commit/e535cd504cf1929539ff7faf13e9c1fdd2b7bfd1))
## [2.125.2](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.125.1...@standardnotes/domain-events@2.125.2) (2023-09-12)
### Bug Fixes
* domain event values ([f0abfe8](https://github.com/standardnotes/server/commit/f0abfe89fca0049c47131389683efe2f5aff23f8))
## [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)
### Features
* transition users after sign out ([398338c](https://github.com/standardnotes/server/commit/398338c8f81b12406c7ab3bf1654e60b94d7cfd0))
# [2.124.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.123.0...@standardnotes/domain-events@2.124.0) (2023-09-07)
### Features
* add removing revisions from shared vaults ([#811](https://github.com/standardnotes/server/issues/811)) ([3bd63f7](https://github.com/standardnotes/server/commit/3bd63f767464baf9b9f1ffa52eea9eed4a4e11b5))
# [2.123.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.122.2...@standardnotes/domain-events@2.123.0) (2023-09-06) # [2.123.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.122.2...@standardnotes/domain-events@2.123.0) (2023-09-06)
### Features ### Features
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@standardnotes/domain-events", "name": "@standardnotes/domain-events",
"version": "2.123.0", "version": "2.126.0",
"engines": { "engines": {
"node": ">=18.0.0 <21.0.0" "node": ">=18.0.0 <21.0.0"
}, },
@@ -0,0 +1,7 @@
import { DomainEventInterface } from './DomainEventInterface'
import { ItemRemovedFromSharedVaultEventPayload } from './ItemRemovedFromSharedVaultEventPayload'
export interface ItemRemovedFromSharedVaultEvent extends DomainEventInterface {
type: 'ITEM_REMOVED_FROM_SHARED_VAULT'
payload: ItemRemovedFromSharedVaultEventPayload
}
@@ -0,0 +1,6 @@
export interface ItemRemovedFromSharedVaultEventPayload {
userUuid: string
itemUuid: string
sharedVaultUuid: string
roleNames: string[]
}
@@ -0,0 +1,8 @@
import { DomainEventInterface } from './DomainEventInterface'
import { TransitionRequestedEventPayload } from './TransitionRequestedEventPayload'
export interface TransitionRequestedEvent extends DomainEventInterface {
type: 'TRANSITION_REQUESTED'
payload: TransitionRequestedEventPayload
}
@@ -0,0 +1,5 @@
export interface TransitionRequestedEventPayload {
userUuid: string
type: 'items' | 'revisions'
timestamp: number
}
@@ -1,5 +1,6 @@
export interface TransitionStatusUpdatedEventPayload { export interface TransitionStatusUpdatedEventPayload {
userUuid: string userUuid: string
transitionType: 'items' | 'revisions' transitionType: 'items' | 'revisions'
status: 'STARTED' | 'FINISHED' | 'FAILED' transitionTimestamp: number
status: 'STARTED' | 'IN_PROGRESS' | 'FINISHED' | 'FAILED' | 'VERIFIED'
} }
@@ -32,6 +32,8 @@ export * from './Event/FileUploadedEvent'
export * from './Event/FileUploadedEventPayload' export * from './Event/FileUploadedEventPayload'
export * from './Event/ItemDumpedEvent' export * from './Event/ItemDumpedEvent'
export * from './Event/ItemDumpedEventPayload' export * from './Event/ItemDumpedEventPayload'
export * from './Event/ItemRemovedFromSharedVaultEvent'
export * from './Event/ItemRemovedFromSharedVaultEventPayload'
export * from './Event/ItemRevisionCreationRequestedEvent' export * from './Event/ItemRevisionCreationRequestedEvent'
export * from './Event/ItemRevisionCreationRequestedEventPayload' export * from './Event/ItemRevisionCreationRequestedEventPayload'
export * from './Event/ListedAccountCreatedEvent' export * from './Event/ListedAccountCreatedEvent'
@@ -94,6 +96,8 @@ export * from './Event/SubscriptionRevertRequestedEvent'
export * from './Event/SubscriptionRevertRequestedEventPayload' export * from './Event/SubscriptionRevertRequestedEventPayload'
export * from './Event/SubscriptionSyncRequestedEvent' export * from './Event/SubscriptionSyncRequestedEvent'
export * from './Event/SubscriptionSyncRequestedEventPayload' export * from './Event/SubscriptionSyncRequestedEventPayload'
export * from './Event/TransitionRequestedEvent'
export * from './Event/TransitionRequestedEventPayload'
export * from './Event/TransitionStatusUpdatedEvent' export * from './Event/TransitionStatusUpdatedEvent'
export * from './Event/TransitionStatusUpdatedEventPayload' export * from './Event/TransitionStatusUpdatedEventPayload'
export * from './Event/UserAddedToSharedVaultEvent' export * from './Event/UserAddedToSharedVaultEvent'
+36
View File
@@ -3,6 +3,42 @@
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.41](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.11.40...@standardnotes/event-store@1.11.41) (2023-09-15)
**Note:** Version bump only for package @standardnotes/event-store
## [1.11.40](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.11.39...@standardnotes/event-store@1.11.40) (2023-09-13)
**Note:** Version bump only for package @standardnotes/event-store
## [1.11.39](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.11.38...@standardnotes/event-store@1.11.39) (2023-09-12)
**Note:** Version bump only for package @standardnotes/event-store
## [1.11.38](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.11.37...@standardnotes/event-store@1.11.38) (2023-09-12)
**Note:** Version bump only for package @standardnotes/event-store
## [1.11.37](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.11.36...@standardnotes/event-store@1.11.37) (2023-09-12)
**Note:** Version bump only for package @standardnotes/event-store
## [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)
**Note:** Version bump only for package @standardnotes/event-store
## [1.11.34](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.11.33...@standardnotes/event-store@1.11.34) (2023-09-07)
**Note:** Version bump only for package @standardnotes/event-store
## [1.11.33](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.11.32...@standardnotes/event-store@1.11.33) (2023-09-07)
**Note:** Version bump only for package @standardnotes/event-store
## [1.11.32](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.11.31...@standardnotes/event-store@1.11.32) (2023-09-06) ## [1.11.32](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.11.31...@standardnotes/event-store@1.11.32) (2023-09-06)
**Note:** Version bump only for package @standardnotes/event-store **Note:** Version bump only for package @standardnotes/event-store
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@standardnotes/event-store", "name": "@standardnotes/event-store",
"version": "1.11.32", "version": "1.11.41",
"description": "Event Store Service", "description": "Event Store Service",
"private": true, "private": true,
"main": "dist/src/index.js", "main": "dist/src/index.js",
+36
View File
@@ -3,6 +3,42 @@
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.20](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.22.19...@standardnotes/files-server@1.22.20) (2023-09-15)
**Note:** Version bump only for package @standardnotes/files-server
## [1.22.19](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.22.18...@standardnotes/files-server@1.22.19) (2023-09-13)
**Note:** Version bump only for package @standardnotes/files-server
## [1.22.18](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.22.17...@standardnotes/files-server@1.22.18) (2023-09-12)
**Note:** Version bump only for package @standardnotes/files-server
## [1.22.17](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.22.16...@standardnotes/files-server@1.22.17) (2023-09-12)
**Note:** Version bump only for package @standardnotes/files-server
## [1.22.16](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.22.15...@standardnotes/files-server@1.22.16) (2023-09-12)
**Note:** Version bump only for package @standardnotes/files-server
## [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)
**Note:** Version bump only for package @standardnotes/files-server
## [1.22.13](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.22.12...@standardnotes/files-server@1.22.13) (2023-09-07)
**Note:** Version bump only for package @standardnotes/files-server
## [1.22.12](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.22.11...@standardnotes/files-server@1.22.12) (2023-09-07)
**Note:** Version bump only for package @standardnotes/files-server
## [1.22.11](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.22.10...@standardnotes/files-server@1.22.11) (2023-09-06) ## [1.22.11](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.22.10...@standardnotes/files-server@1.22.11) (2023-09-06)
**Note:** Version bump only for package @standardnotes/files-server **Note:** Version bump only for package @standardnotes/files-server
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@standardnotes/files-server", "name": "@standardnotes/files-server",
"version": "1.22.11", "version": "1.22.20",
"engines": { "engines": {
"node": ">=18.0.0 <21.0.0" "node": ">=18.0.0 <21.0.0"
}, },
+124
View File
@@ -3,6 +3,130 @@
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.56](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.55...@standardnotes/home-server@1.15.56) (2023-09-15)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.55](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.54...@standardnotes/home-server@1.15.55) (2023-09-15)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.54](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.53...@standardnotes/home-server@1.15.54) (2023-09-14)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.53](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.52...@standardnotes/home-server@1.15.53) (2023-09-13)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.52](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.51...@standardnotes/home-server@1.15.52) (2023-09-13)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.51](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.50...@standardnotes/home-server@1.15.51) (2023-09-13)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.50](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.49...@standardnotes/home-server@1.15.50) (2023-09-13)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.49](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.48...@standardnotes/home-server@1.15.49) (2023-09-13)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.48](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.47...@standardnotes/home-server@1.15.48) (2023-09-13)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.47](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.46...@standardnotes/home-server@1.15.47) (2023-09-13)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.46](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.45...@standardnotes/home-server@1.15.46) (2023-09-12)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.45](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.44...@standardnotes/home-server@1.15.45) (2023-09-12)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.44](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.43...@standardnotes/home-server@1.15.44) (2023-09-12)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.43](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.42...@standardnotes/home-server@1.15.43) (2023-09-12)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.42](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.41...@standardnotes/home-server@1.15.42) (2023-09-12)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.41](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.40...@standardnotes/home-server@1.15.41) (2023-09-12)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.40](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.39...@standardnotes/home-server@1.15.40) (2023-09-12)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.39](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.38...@standardnotes/home-server@1.15.39) (2023-09-12)
**Note:** Version bump only for package @standardnotes/home-server
## [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)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.36](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.35...@standardnotes/home-server@1.15.36) (2023-09-11)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.35](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.34...@standardnotes/home-server@1.15.35) (2023-09-11)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.34](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.33...@standardnotes/home-server@1.15.34) (2023-09-11)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.33](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.32...@standardnotes/home-server@1.15.33) (2023-09-11)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.32](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.31...@standardnotes/home-server@1.15.32) (2023-09-11)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.31](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.30...@standardnotes/home-server@1.15.31) (2023-09-08)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.30](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.29...@standardnotes/home-server@1.15.30) (2023-09-08)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.29](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.28...@standardnotes/home-server@1.15.29) (2023-09-08)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.28](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.27...@standardnotes/home-server@1.15.28) (2023-09-07)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.27](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.26...@standardnotes/home-server@1.15.27) (2023-09-07)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.26](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.25...@standardnotes/home-server@1.15.26) (2023-09-07)
**Note:** Version bump only for package @standardnotes/home-server
## [1.15.25](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.24...@standardnotes/home-server@1.15.25) (2023-09-06) ## [1.15.25](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.15.24...@standardnotes/home-server@1.15.25) (2023-09-06)
**Note:** Version bump only for package @standardnotes/home-server **Note:** Version bump only for package @standardnotes/home-server
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@standardnotes/home-server", "name": "@standardnotes/home-server",
"version": "1.15.25", "version": "1.15.56",
"engines": { "engines": {
"node": ">=18.0.0 <21.0.0" "node": ">=18.0.0 <21.0.0"
}, },
+146
View File
@@ -3,6 +3,152 @@
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.34.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.21...@standardnotes/revisions-server@1.34.0) (2023-09-15)
### Features
* add skipping verified transitions ([#827](https://github.com/standardnotes/server/issues/827)) ([d4d4945](https://github.com/standardnotes/server/commit/d4d49454a68de0acdf440dc202fa14b9743905f6))
## [1.33.21](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.20...@standardnotes/revisions-server@1.33.21) (2023-09-14)
### Bug Fixes
* skip already updated items and revisions in integrity check ([#825](https://github.com/standardnotes/server/issues/825)) ([03a4a3f](https://github.com/standardnotes/server/commit/03a4a3f2abc0b4e09942ba39dbd227524068dfb6))
## [1.33.20](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.19...@standardnotes/revisions-server@1.33.20) (2023-09-13)
### Bug Fixes
* adjust transition timestamps to be universal ([c7807d0](https://github.com/standardnotes/server/commit/c7807d0f9e69ce572c4c03ff606375d706f24d9f))
## [1.33.19](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.18...@standardnotes/revisions-server@1.33.19) (2023-09-13)
### Bug Fixes
* include handling updated items in revisions in secondary ([fbcb45c](https://github.com/standardnotes/server/commit/fbcb45c3a23fde09702fae7bfcb409bdbb610191))
## [1.33.18](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.17...@standardnotes/revisions-server@1.33.18) (2023-09-13)
### Bug Fixes
* display transition progress in logs ([38685c1](https://github.com/standardnotes/server/commit/38685c1861b13e398dd96aa39f2cf1aece2090fb))
## [1.33.17](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.16...@standardnotes/revisions-server@1.33.17) (2023-09-13)
### Bug Fixes
* setting status for already migrated users ([9be4c00](https://github.com/standardnotes/server/commit/9be4c002b755fea057489b6077b297162223aefe))
## [1.33.16](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.15...@standardnotes/revisions-server@1.33.16) (2023-09-13)
### Bug Fixes
* cleanup only for 0 new items ([b1d88b1](https://github.com/standardnotes/server/commit/b1d88b15be78a48224963e337a222fb675ed2692))
## [1.33.15](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.14...@standardnotes/revisions-server@1.33.15) (2023-09-12)
### Bug Fixes
* sync between primary and secondary database with diff ([fab5d18](https://github.com/standardnotes/server/commit/fab5d180645e0a6fa0c9c67205d44f27c8a65c8b))
## [1.33.14](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.13...@standardnotes/revisions-server@1.33.14) (2023-09-12)
### Bug Fixes
* **revisions:** handle transitions with already existing data in secondary ([aa83526](https://github.com/standardnotes/server/commit/aa835268ea80e3aa74907e449d189e8b2774a859))
## [1.33.13](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.12...@standardnotes/revisions-server@1.33.13) (2023-09-12)
### Bug Fixes
* retry failed revision transitions ([e535cd5](https://github.com/standardnotes/server/commit/e535cd504cf1929539ff7faf13e9c1fdd2b7bfd1))
## [1.33.12](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.11...@standardnotes/revisions-server@1.33.12) (2023-09-12)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.33.11](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.10...@standardnotes/revisions-server@1.33.11) (2023-09-12)
### Bug Fixes
* comparing uuids ([0a1d162](https://github.com/standardnotes/server/commit/0a1d1624e818000f2e951f29323a88e6e233c755))
## [1.33.10](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.9...@standardnotes/revisions-server@1.33.10) (2023-09-12)
**Note:** Version bump only for package @standardnotes/revisions-server
## [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)
### Bug Fixes
* transition adjustments ([f20a947](https://github.com/standardnotes/server/commit/f20a947f8a555c074d8dc1543c7a8bf61d1d887e))
## [1.33.7](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.6...@standardnotes/revisions-server@1.33.7) (2023-09-11)
### Bug Fixes
* **auth:** remove transitioning upon sign out ([#819](https://github.com/standardnotes/server/issues/819)) ([330bff0](https://github.com/standardnotes/server/commit/330bff0124f5f49c3441304d166ea43c21fea7bc))
## [1.33.6](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.5...@standardnotes/revisions-server@1.33.6) (2023-09-11)
### Bug Fixes
* disable running migrations in worker mode of a given service ([a82b9a0](https://github.com/standardnotes/server/commit/a82b9a0c8a023ba8a450ff9e34bcd62f928fcab3))
## [1.33.5](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.4...@standardnotes/revisions-server@1.33.5) (2023-09-11)
### Bug Fixes
* **revisions:** add item_uuid to revisions metadata http representation ([9676a25](https://github.com/standardnotes/server/commit/9676a2586cabc344f3c244a5a20d4e1d57ac4c35))
* **revisions:** conflict with table naming ([ed671be](https://github.com/standardnotes/server/commit/ed671be9c56eb8d54b8dd52a69d5e30e07203aa4))
* **revisions:** legacy table syncing and select for metadata ([b4bf11d](https://github.com/standardnotes/server/commit/b4bf11d9da44cc1d980b6922f532ff487fe582df))
* **revisions:** removing queries ([117b7b4](https://github.com/standardnotes/server/commit/117b7b4b99e09aebfd081433646ec05c2ebf308f))
* **revisions:** rename table only if exists ([836883b](https://github.com/standardnotes/server/commit/836883b82dd436d0e9b3ae3b70f734ceb508e227))
## [1.33.4](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.3...@standardnotes/revisions-server@1.33.4) (2023-09-11)
### Bug Fixes
* **revisions:** add shared vault uuid to revision metadata http representation ([156fa7a](https://github.com/standardnotes/server/commit/156fa7a618b9f33a839580019d0398c1b838697d))
## [1.33.3](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.2...@standardnotes/revisions-server@1.33.3) (2023-09-08)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.33.2](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.1...@standardnotes/revisions-server@1.33.2) (2023-09-08)
### Bug Fixes
* **revisions:** persistence mapper ([#814](https://github.com/standardnotes/server/issues/814)) ([76372fe](https://github.com/standardnotes/server/commit/76372fe3579a99bf44abfce9667fec134baafedf))
## [1.33.1](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.33.0...@standardnotes/revisions-server@1.33.1) (2023-09-07)
### Bug Fixes
* **revisions:** waiting for syncing-server on self-hosted setup ([27ad8e6](https://github.com/standardnotes/server/commit/27ad8e6959aeb9c2f11ee0fecba37514bf91dda8))
# [1.33.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.32.0...@standardnotes/revisions-server@1.33.0) (2023-09-07)
### Features
* add removing revisions from shared vaults ([#811](https://github.com/standardnotes/server/issues/811)) ([3bd63f7](https://github.com/standardnotes/server/commit/3bd63f767464baf9b9f1ffa52eea9eed4a4e11b5))
# [1.32.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.31.0...@standardnotes/revisions-server@1.32.0) (2023-09-07)
### Bug Fixes
* **revisions:** query for shared vault revisions ([7e11821](https://github.com/standardnotes/server/commit/7e11821021a663fcf452ad8bb03eda33c03fe221))
### Features
* **revisions:** fetching single revision in shared vault ([#810](https://github.com/standardnotes/server/issues/810)) ([e100c52](https://github.com/standardnotes/server/commit/e100c52bbc07447188af3b9a04f3744401dac0ab))
# [1.31.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.30.14...@standardnotes/revisions-server@1.31.0) (2023-09-06) # [1.31.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.30.14...@standardnotes/revisions-server@1.31.0) (2023-09-06)
### Features ### Features
+1 -1
View File
@@ -7,7 +7,7 @@ import { Env } from '../src/Bootstrap/Env'
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events' import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
import { ContainerConfigLoader } from '../src/Bootstrap/Container' import { ContainerConfigLoader } from '../src/Bootstrap/Container'
const container = new ContainerConfigLoader() const container = new ContainerConfigLoader('worker')
void container.load().then((container) => { void container.load().then((container) => {
const env: Env = new Env() const env: Env = new Env()
env.load() env.load()
@@ -4,19 +4,19 @@ export class init1669113322388 implements MigrationInterface {
name = 'init1669113322388' name = 'init1669113322388'
public async up(queryRunner: QueryRunner): Promise<void> { public async up(queryRunner: QueryRunner): Promise<void> {
await this.syncSchemaBetweenLegacyRevisions(queryRunner)
await queryRunner.query( await queryRunner.query(
'CREATE TABLE IF NOT EXISTS `revisions` (`uuid` varchar(36) NOT NULL, `item_uuid` varchar(36) NOT NULL, `user_uuid` varchar(36) NOT NULL, `content` mediumtext NULL, `content_type` varchar(255) NULL, `items_key_id` varchar(255) NULL, `enc_item_key` text NULL, `auth_hash` varchar(255) NULL, `creation_date` date NULL, `created_at` datetime(6) NULL, `updated_at` datetime(6) NULL, INDEX `item_uuid` (`item_uuid`), INDEX `user_uuid` (`user_uuid`), INDEX `creation_date` (`creation_date`), INDEX `created_at` (`created_at`), PRIMARY KEY (`uuid`)) ENGINE=InnoDB', 'CREATE TABLE `revisions_revisions` (`uuid` varchar(36) NOT NULL, `item_uuid` varchar(36) NOT NULL, `user_uuid` varchar(36) NULL, `content` mediumtext NULL, `content_type` varchar(255) NULL, `items_key_id` varchar(255) NULL, `enc_item_key` text NULL, `auth_hash` varchar(255) NULL, `creation_date` date NULL, `created_at` datetime(6) NULL, `updated_at` datetime(6) NULL, INDEX `item_uuid` (`item_uuid`), INDEX `user_uuid` (`user_uuid`), INDEX `creation_date` (`creation_date`), INDEX `created_at` (`created_at`), PRIMARY KEY (`uuid`)) ENGINE=InnoDB',
) )
await this.syncSchemaBetweenLegacyRevisions(queryRunner)
} }
public async down(queryRunner: QueryRunner): Promise<void> { public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('DROP INDEX `created_at` ON `revisions`') await queryRunner.query('DROP INDEX `created_at` ON `revisions_revisions`')
await queryRunner.query('DROP INDEX `creation_date` ON `revisions`') await queryRunner.query('DROP INDEX `creation_date` ON `revisions_revisions`')
await queryRunner.query('DROP INDEX `user_uuid` ON `revisions`') await queryRunner.query('DROP INDEX `user_uuid` ON `revisions_revisions`')
await queryRunner.query('DROP INDEX `item_uuid` ON `revisions`') await queryRunner.query('DROP INDEX `item_uuid` ON `revisions_revisions`')
await queryRunner.query('DROP TABLE `revisions`') await queryRunner.query('DROP TABLE `revisions_revisions`')
} }
private async syncSchemaBetweenLegacyRevisions(queryRunner: QueryRunner): Promise<void> { private async syncSchemaBetweenLegacyRevisions(queryRunner: QueryRunner): Promise<void> {
@@ -28,14 +28,10 @@ export class init1669113322388 implements MigrationInterface {
return return
} }
const revisionsTableHasUserUuidColumnQueryResult = await queryRunner.manager.query( await queryRunner.query(
'SELECT COUNT(*) as count FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = "revisions" AND column_name = "user_uuid"', 'INSERT INTO `revisions_revisions`(`uuid`, `item_uuid`, `user_uuid`, `content`, `content_type`, `items_key_id`, `enc_item_key`, `auth_hash`, `creation_date`, `created_at`, `updated_at`) SELECT `uuid`, `item_uuid`, NULL, `content`, `content_type`, `items_key_id`, `enc_item_key`, `auth_hash`, `creation_date`, `created_at`, `updated_at` FROM `revisions`',
) )
const revisionsTableHasUserUuidColumn = revisionsTableHasUserUuidColumnQueryResult[0].count === 1
if (revisionsTableHasUserUuidColumn) {
return
}
await queryRunner.query('ALTER TABLE `revisions` ADD COLUMN `user_uuid` varchar(36) NULL') await queryRunner.query('DROP TABLE `revisions`')
} }
} }
@@ -5,24 +5,24 @@ export class removeDateIndexes1669636497932 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> { public async up(queryRunner: QueryRunner): Promise<void> {
const indexRevisionsOnCreatedAt = await queryRunner.manager.query( const indexRevisionsOnCreatedAt = await queryRunner.manager.query(
'SHOW INDEX FROM `revisions` where `key_name` = "created_at"', 'SHOW INDEX FROM `revisions_revisions` where `key_name` = "created_at"',
) )
const indexRevisionsOnCreatedAtExist = indexRevisionsOnCreatedAt && indexRevisionsOnCreatedAt.length > 0 const indexRevisionsOnCreatedAtExist = indexRevisionsOnCreatedAt && indexRevisionsOnCreatedAt.length > 0
if (indexRevisionsOnCreatedAtExist) { if (indexRevisionsOnCreatedAtExist) {
await queryRunner.query('DROP INDEX `created_at` ON `revisions`') await queryRunner.query('DROP INDEX `created_at` ON `revisions_revisions`')
} }
const indexRevisionsOnCreationDate = await queryRunner.manager.query( const indexRevisionsOnCreationDate = await queryRunner.manager.query(
'SHOW INDEX FROM `revisions` where `key_name` = "creation_date"', 'SHOW INDEX FROM `revisions_revisions` where `key_name` = "creation_date"',
) )
const indexRevisionsOnCreationDateAtExist = indexRevisionsOnCreationDate && indexRevisionsOnCreationDate.length > 0 const indexRevisionsOnCreationDateAtExist = indexRevisionsOnCreationDate && indexRevisionsOnCreationDate.length > 0
if (indexRevisionsOnCreationDateAtExist) { if (indexRevisionsOnCreationDateAtExist) {
await queryRunner.query('DROP INDEX `creation_date` ON `revisions`') await queryRunner.query('DROP INDEX `creation_date` ON `revisions_revisions`')
} }
} }
public async down(queryRunner: QueryRunner): Promise<void> { public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('CREATE INDEX `creation_date` ON `revisions` (`creation_date`)') await queryRunner.query('CREATE INDEX `creation_date` ON `revisions_revisions` (`creation_date`)')
await queryRunner.query('CREATE INDEX `created_at` ON `revisions` (`created_at`)') await queryRunner.query('CREATE INDEX `created_at` ON `revisions_revisions` (`created_at`)')
} }
} }
@@ -4,10 +4,10 @@ export class makeUserUuidNullable1669735585016 implements MigrationInterface {
name = 'makeUserUuidNullable1669735585016' name = 'makeUserUuidNullable1669735585016'
public async up(queryRunner: QueryRunner): Promise<void> { public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('ALTER TABLE `revisions` CHANGE `user_uuid` `user_uuid` varchar(36) NULL') await queryRunner.query('ALTER TABLE `revisions_revisions` CHANGE `user_uuid` `user_uuid` varchar(36) NULL')
} }
public async down(queryRunner: QueryRunner): Promise<void> { public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('ALTER TABLE `revisions` CHANGE `user_uuid` `user_uuid` varchar(36) NOT NULL') await queryRunner.query('ALTER TABLE `revisions_revisions` CHANGE `user_uuid` `user_uuid` varchar(36) NOT NULL')
} }
} }
@@ -2,16 +2,18 @@ import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddSharedVaultInformation1693915383950 implements MigrationInterface { export class AddSharedVaultInformation1693915383950 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> { public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('ALTER TABLE `revisions` ADD `edited_by` varchar(36) NULL') await queryRunner.query('ALTER TABLE `revisions_revisions` ADD `edited_by` varchar(36) NULL')
await queryRunner.query('ALTER TABLE `revisions` ADD `shared_vault_uuid` varchar(36) NULL') await queryRunner.query('ALTER TABLE `revisions_revisions` ADD `shared_vault_uuid` varchar(36) NULL')
await queryRunner.query('ALTER TABLE `revisions` ADD `key_system_identifier` varchar(36) NULL') await queryRunner.query('ALTER TABLE `revisions_revisions` ADD `key_system_identifier` varchar(36) NULL')
await queryRunner.query('CREATE INDEX `index_revisions_on_shared_vault_uuid` ON `revisions` (`shared_vault_uuid`)') await queryRunner.query(
'CREATE INDEX `index_revisions_on_shared_vault_uuid` ON `revisions_revisions` (`shared_vault_uuid`)',
)
} }
public async down(queryRunner: QueryRunner): Promise<void> { public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('DROP INDEX `index_revisions_on_shared_vault_uuid` ON `revisions`') await queryRunner.query('DROP INDEX `index_revisions_on_shared_vault_uuid` ON `revisions_revisions`')
await queryRunner.query('ALTER TABLE `revisions` DROP COLUMN `key_system_identifier`') await queryRunner.query('ALTER TABLE `revisions_revisions` DROP COLUMN `key_system_identifier`')
await queryRunner.query('ALTER TABLE `revisions` DROP COLUMN `shared_vault_uuid`') await queryRunner.query('ALTER TABLE `revisions_revisions` DROP COLUMN `shared_vault_uuid`')
await queryRunner.query('ALTER TABLE `revisions` DROP COLUMN `last_edited_by`') await queryRunner.query('ALTER TABLE `revisions_revisions` DROP COLUMN `last_edited_by`')
} }
} }
@@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class RenameRevisionsTable1694425333972 implements MigrationInterface {
name = 'RenameRevisionsTable1694425333972'
public async up(queryRunner: QueryRunner): Promise<void> {
const revisionsTableExistsQueryResult = await queryRunner.manager.query(
'SELECT COUNT(*) as count FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = "revisions"',
)
const revisionsTableExists = revisionsTableExistsQueryResult[0].count === 1
if (revisionsTableExists) {
await queryRunner.query('RENAME TABLE `revisions` TO `revisions_revisions`')
}
}
public async down(): Promise<void> {
return
}
}
@@ -5,15 +5,15 @@ export class initialBoilerplate1682678053275 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> { public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query( await queryRunner.query(
'CREATE TABLE "revisions" ("uuid" varchar PRIMARY KEY NOT NULL, "item_uuid" varchar(36) NOT NULL, "user_uuid" varchar(36), "content" text, "content_type" varchar(255), "items_key_id" varchar(255), "enc_item_key" text, "auth_hash" varchar(255), "creation_date" date, "created_at" datetime(6), "updated_at" datetime(6))', 'CREATE TABLE "revisions_revisions" ("uuid" varchar PRIMARY KEY NOT NULL, "item_uuid" varchar(36) NOT NULL, "user_uuid" varchar(36), "content" text, "content_type" varchar(255), "items_key_id" varchar(255), "enc_item_key" text, "auth_hash" varchar(255), "creation_date" date, "created_at" datetime(6), "updated_at" datetime(6))',
) )
await queryRunner.query('CREATE INDEX "item_uuid" ON "revisions" ("item_uuid") ') await queryRunner.query('CREATE INDEX "item_uuid" ON "revisions_revisions" ("item_uuid") ')
await queryRunner.query('CREATE INDEX "user_uuid" ON "revisions" ("user_uuid") ') await queryRunner.query('CREATE INDEX "user_uuid" ON "revisions_revisions" ("user_uuid") ')
} }
public async down(queryRunner: QueryRunner): Promise<void> { public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('DROP INDEX "user_uuid"') await queryRunner.query('DROP INDEX "user_uuid"')
await queryRunner.query('DROP INDEX "item_uuid"') await queryRunner.query('DROP INDEX "item_uuid"')
await queryRunner.query('DROP TABLE "revisions"') await queryRunner.query('DROP TABLE "revisions_revisions"')
} }
} }
@@ -10,28 +10,30 @@ export class AddSharedVaultInformation1693915775491 implements MigrationInterfac
'CREATE TABLE "temporary_revisions" ("uuid" varchar PRIMARY KEY NOT NULL, "item_uuid" varchar(36) NOT NULL, "user_uuid" varchar(36), "content" text, "content_type" varchar(255), "items_key_id" varchar(255), "enc_item_key" text, "auth_hash" varchar(255), "creation_date" date, "created_at" datetime(6), "updated_at" datetime(6), "edited_by" varchar(36), "shared_vault_uuid" varchar(36), "key_system_identifier" varchar(36))', 'CREATE TABLE "temporary_revisions" ("uuid" varchar PRIMARY KEY NOT NULL, "item_uuid" varchar(36) NOT NULL, "user_uuid" varchar(36), "content" text, "content_type" varchar(255), "items_key_id" varchar(255), "enc_item_key" text, "auth_hash" varchar(255), "creation_date" date, "created_at" datetime(6), "updated_at" datetime(6), "edited_by" varchar(36), "shared_vault_uuid" varchar(36), "key_system_identifier" varchar(36))',
) )
await queryRunner.query( await queryRunner.query(
'INSERT INTO "temporary_revisions"("uuid", "item_uuid", "user_uuid", "content", "content_type", "items_key_id", "enc_item_key", "auth_hash", "creation_date", "created_at", "updated_at") SELECT "uuid", "item_uuid", "user_uuid", "content", "content_type", "items_key_id", "enc_item_key", "auth_hash", "creation_date", "created_at", "updated_at" FROM "revisions"', 'INSERT INTO "temporary_revisions"("uuid", "item_uuid", "user_uuid", "content", "content_type", "items_key_id", "enc_item_key", "auth_hash", "creation_date", "created_at", "updated_at") SELECT "uuid", "item_uuid", "user_uuid", "content", "content_type", "items_key_id", "enc_item_key", "auth_hash", "creation_date", "created_at", "updated_at" FROM "revisions_revisions"',
)
await queryRunner.query('DROP TABLE "revisions_revisions"')
await queryRunner.query('ALTER TABLE "temporary_revisions" RENAME TO "revisions_revisions"')
await queryRunner.query('CREATE INDEX "user_uuid" ON "revisions_revisions" ("user_uuid") ')
await queryRunner.query('CREATE INDEX "item_uuid" ON "revisions_revisions" ("item_uuid") ')
await queryRunner.query(
'CREATE INDEX "index_revisions_on_shared_vault_uuid" ON "revisions_revisions" ("shared_vault_uuid") ',
) )
await queryRunner.query('DROP TABLE "revisions"')
await queryRunner.query('ALTER TABLE "temporary_revisions" RENAME TO "revisions"')
await queryRunner.query('CREATE INDEX "user_uuid" ON "revisions" ("user_uuid") ')
await queryRunner.query('CREATE INDEX "item_uuid" ON "revisions" ("item_uuid") ')
await queryRunner.query('CREATE INDEX "index_revisions_on_shared_vault_uuid" ON "revisions" ("shared_vault_uuid") ')
} }
public async down(queryRunner: QueryRunner): Promise<void> { public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('DROP INDEX "index_revisions_on_shared_vault_uuid"') await queryRunner.query('DROP INDEX "index_revisions_on_shared_vault_uuid"')
await queryRunner.query('DROP INDEX "item_uuid"') await queryRunner.query('DROP INDEX "item_uuid"')
await queryRunner.query('DROP INDEX "user_uuid"') await queryRunner.query('DROP INDEX "user_uuid"')
await queryRunner.query('ALTER TABLE "revisions" RENAME TO "temporary_revisions"') await queryRunner.query('ALTER TABLE "revisions_revisions" RENAME TO "temporary_revisions"')
await queryRunner.query( await queryRunner.query(
'CREATE TABLE "revisions" ("uuid" varchar PRIMARY KEY NOT NULL, "item_uuid" varchar(36) NOT NULL, "user_uuid" varchar(36), "content" text, "content_type" varchar(255), "items_key_id" varchar(255), "enc_item_key" text, "auth_hash" varchar(255), "creation_date" date, "created_at" datetime(6), "updated_at" datetime(6))', 'CREATE TABLE "revisions_revisions" ("uuid" varchar PRIMARY KEY NOT NULL, "item_uuid" varchar(36) NOT NULL, "user_uuid" varchar(36), "content" text, "content_type" varchar(255), "items_key_id" varchar(255), "enc_item_key" text, "auth_hash" varchar(255), "creation_date" date, "created_at" datetime(6), "updated_at" datetime(6))',
) )
await queryRunner.query( await queryRunner.query(
'INSERT INTO "revisions"("uuid", "item_uuid", "user_uuid", "content", "content_type", "items_key_id", "enc_item_key", "auth_hash", "creation_date", "created_at", "updated_at") SELECT "uuid", "item_uuid", "user_uuid", "content", "content_type", "items_key_id", "enc_item_key", "auth_hash", "creation_date", "created_at", "updated_at" FROM "temporary_revisions"', 'INSERT INTO "revisions_revisions"("uuid", "item_uuid", "user_uuid", "content", "content_type", "items_key_id", "enc_item_key", "auth_hash", "creation_date", "created_at", "updated_at") SELECT "uuid", "item_uuid", "user_uuid", "content", "content_type", "items_key_id", "enc_item_key", "auth_hash", "creation_date", "created_at", "updated_at" FROM "temporary_revisions"',
) )
await queryRunner.query('DROP TABLE "temporary_revisions"') await queryRunner.query('DROP TABLE "temporary_revisions"')
await queryRunner.query('CREATE INDEX "item_uuid" ON "revisions" ("item_uuid") ') await queryRunner.query('CREATE INDEX "item_uuid" ON "revisions_revisions" ("item_uuid") ')
await queryRunner.query('CREATE INDEX "user_uuid" ON "revisions" ("user_uuid") ') await queryRunner.query('CREATE INDEX "user_uuid" ON "revisions_revisions" ("user_uuid") ')
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@standardnotes/revisions-server", "name": "@standardnotes/revisions-server",
"version": "1.31.0", "version": "1.34.0",
"engines": { "engines": {
"node": ">=18.0.0 <21.0.0" "node": ">=18.0.0 <21.0.0"
}, },
+36 -4
View File
@@ -66,8 +66,13 @@ import { SQLRevision } from '../Infra/TypeORM/SQL/SQLRevision'
import { SQLRevisionRepository } from '../Infra/TypeORM/SQL/SQLRevisionRepository' import { SQLRevisionRepository } from '../Infra/TypeORM/SQL/SQLRevisionRepository'
import { SQLRevisionMetadataPersistenceMapper } from '../Mapping/Persistence/SQL/SQLRevisionMetadataPersistenceMapper' import { SQLRevisionMetadataPersistenceMapper } from '../Mapping/Persistence/SQL/SQLRevisionMetadataPersistenceMapper'
import { SQLRevisionPersistenceMapper } from '../Mapping/Persistence/SQL/SQLRevisionPersistenceMapper' import { SQLRevisionPersistenceMapper } from '../Mapping/Persistence/SQL/SQLRevisionPersistenceMapper'
import { RemoveRevisionsFromSharedVault } from '../Domain/UseCase/RemoveRevisionsFromSharedVault/RemoveRevisionsFromSharedVault'
import { ItemRemovedFromSharedVaultEventHandler } from '../Domain/Handler/ItemRemovedFromSharedVaultEventHandler'
import { TransitionRequestedEventHandler } from '../Domain/Handler/TransitionRequestedEventHandler'
export class ContainerConfigLoader { export class ContainerConfigLoader {
constructor(private mode: 'server' | 'worker' = 'server') {}
async load(configuration?: { async load(configuration?: {
controllerConatiner?: ControllerContainerInterface controllerConatiner?: ControllerContainerInterface
directCallDomainEventPublisher?: DirectCallDomainEventPublisher directCallDomainEventPublisher?: DirectCallDomainEventPublisher
@@ -113,7 +118,7 @@ export class ContainerConfigLoader {
container.bind<TimerInterface>(TYPES.Revisions_Timer).toDynamicValue(() => new Timer()) container.bind<TimerInterface>(TYPES.Revisions_Timer).toDynamicValue(() => new Timer())
const appDataSource = new AppDataSource(env) const appDataSource = new AppDataSource({ env, runMigrations: this.mode === 'server' })
await appDataSource.initialize() await appDataSource.initialize()
logger.debug('Database initialized') logger.debug('Database initialized')
@@ -346,6 +351,7 @@ export class ContainerConfigLoader {
: null, : null,
container.get<TimerInterface>(TYPES.Revisions_Timer), container.get<TimerInterface>(TYPES.Revisions_Timer),
container.get<winston.Logger>(TYPES.Revisions_Logger), container.get<winston.Logger>(TYPES.Revisions_Logger),
env.get('MIGRATION_BATCH_SIZE', true) ? +env.get('MIGRATION_BATCH_SIZE', true) : 100,
), ),
) )
container container
@@ -358,6 +364,13 @@ export class ContainerConfigLoader {
container.get<DomainEventFactoryInterface>(TYPES.Revisions_DomainEventFactory), container.get<DomainEventFactoryInterface>(TYPES.Revisions_DomainEventFactory),
), ),
) )
container
.bind<RemoveRevisionsFromSharedVault>(TYPES.Revisions_RemoveRevisionsFromSharedVault)
.toConstantValue(
new RemoveRevisionsFromSharedVault(
container.get<RevisionRepositoryResolverInterface>(TYPES.Revisions_RevisionRepositoryResolver),
),
)
// env vars // env vars
container.bind(TYPES.Revisions_AUTH_JWT_SECRET).toConstantValue(env.get('AUTH_JWT_SECRET')) container.bind(TYPES.Revisions_AUTH_JWT_SECRET).toConstantValue(env.get('AUTH_JWT_SECRET'))
@@ -407,6 +420,7 @@ export class ContainerConfigLoader {
new ItemDumpedEventHandler( new ItemDumpedEventHandler(
container.get<DumpRepositoryInterface>(TYPES.Revisions_DumpRepository), container.get<DumpRepositoryInterface>(TYPES.Revisions_DumpRepository),
container.get<RevisionRepositoryResolverInterface>(TYPES.Revisions_RevisionRepositoryResolver), container.get<RevisionRepositoryResolverInterface>(TYPES.Revisions_RevisionRepositoryResolver),
container.get<winston.Logger>(TYPES.Revisions_Logger),
), ),
) )
container container
@@ -429,6 +443,7 @@ export class ContainerConfigLoader {
.bind<TransitionStatusUpdatedEventHandler>(TYPES.Revisions_TransitionStatusUpdatedEventHandler) .bind<TransitionStatusUpdatedEventHandler>(TYPES.Revisions_TransitionStatusUpdatedEventHandler)
.toConstantValue( .toConstantValue(
new TransitionStatusUpdatedEventHandler( new TransitionStatusUpdatedEventHandler(
container.get<RevisionRepositoryInterface>(TYPES.Revisions_SQLRevisionRepository),
container.get<TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser>( container.get<TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser>(
TYPES.Revisions_TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser, TYPES.Revisions_TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser,
), ),
@@ -437,12 +452,32 @@ export class ContainerConfigLoader {
container.get<winston.Logger>(TYPES.Revisions_Logger), container.get<winston.Logger>(TYPES.Revisions_Logger),
), ),
) )
container
.bind<ItemRemovedFromSharedVaultEventHandler>(TYPES.Revisions_ItemRemovedFromSharedVaultEventHandler)
.toConstantValue(
new ItemRemovedFromSharedVaultEventHandler(
container.get<RemoveRevisionsFromSharedVault>(TYPES.Revisions_RemoveRevisionsFromSharedVault),
container.get<winston.Logger>(TYPES.Revisions_Logger),
),
)
container
.bind<TransitionRequestedEventHandler>(TYPES.Revisions_TransitionRequestedEventHandler)
.toConstantValue(
new TransitionRequestedEventHandler(
container.get<TriggerTransitionFromPrimaryToSecondaryDatabaseForUser>(
TYPES.Revisions_TriggerTransitionFromPrimaryToSecondaryDatabaseForUser,
),
container.get<winston.Logger>(TYPES.Revisions_Logger),
),
)
const eventHandlers: Map<string, DomainEventHandlerInterface> = new Map([ const eventHandlers: Map<string, DomainEventHandlerInterface> = new Map([
['ITEM_DUMPED', container.get(TYPES.Revisions_ItemDumpedEventHandler)], ['ITEM_DUMPED', container.get(TYPES.Revisions_ItemDumpedEventHandler)],
['ACCOUNT_DELETION_REQUESTED', container.get(TYPES.Revisions_AccountDeletionRequestedEventHandler)], ['ACCOUNT_DELETION_REQUESTED', container.get(TYPES.Revisions_AccountDeletionRequestedEventHandler)],
['REVISIONS_COPY_REQUESTED', container.get(TYPES.Revisions_RevisionsCopyRequestedEventHandler)], ['REVISIONS_COPY_REQUESTED', container.get(TYPES.Revisions_RevisionsCopyRequestedEventHandler)],
['TRANSITION_STATUS_UPDATED', container.get(TYPES.Revisions_TransitionStatusUpdatedEventHandler)], ['TRANSITION_STATUS_UPDATED', container.get(TYPES.Revisions_TransitionStatusUpdatedEventHandler)],
['ITEM_REMOVED_FROM_SHARED_VAULT', container.get(TYPES.Revisions_ItemRemovedFromSharedVaultEventHandler)],
['TRANSITION_REQUESTED', container.get(TYPES.Revisions_TransitionRequestedEventHandler)],
]) ])
if (isConfiguredForHomeServer) { if (isConfiguredForHomeServer) {
@@ -485,9 +520,6 @@ export class ContainerConfigLoader {
container.get<DeleteRevision>(TYPES.Revisions_DeleteRevision), container.get<DeleteRevision>(TYPES.Revisions_DeleteRevision),
container.get<RevisionHttpMapper>(TYPES.Revisions_RevisionHttpMapper), container.get<RevisionHttpMapper>(TYPES.Revisions_RevisionHttpMapper),
container.get<RevisionMetadataHttpMapper>(TYPES.Revisions_RevisionMetadataHttpMapper), container.get<RevisionMetadataHttpMapper>(TYPES.Revisions_RevisionMetadataHttpMapper),
container.get<TriggerTransitionFromPrimaryToSecondaryDatabaseForUser>(
TYPES.Revisions_TriggerTransitionFromPrimaryToSecondaryDatabaseForUser,
),
container.get<ControllerContainerInterface>(TYPES.Revisions_ControllerContainer), container.get<ControllerContainerInterface>(TYPES.Revisions_ControllerContainer),
), ),
) )
+38 -32
View File
@@ -12,7 +12,12 @@ export class AppDataSource {
private _dataSource: DataSource | undefined private _dataSource: DataSource | undefined
private _secondaryDataSource: DataSource | undefined private _secondaryDataSource: DataSource | undefined
constructor(private env: Env) {} constructor(
private configuration: {
env: Env
runMigrations: boolean
},
) {}
getRepository<Entity extends ObjectLiteral>(target: EntityTarget<Entity>): Repository<Entity> { getRepository<Entity extends ObjectLiteral>(target: EntityTarget<Entity>): Repository<Entity> {
if (!this._dataSource) { if (!this._dataSource) {
@@ -39,20 +44,20 @@ export class AppDataSource {
} }
get secondaryDataSource(): DataSource | undefined { get secondaryDataSource(): DataSource | undefined {
this.env.load() this.configuration.env.load()
if (this.env.get('SECONDARY_DB_ENABLED', true) !== 'true') { if (this.configuration.env.get('SECONDARY_DB_ENABLED', true) !== 'true') {
return undefined return undefined
} }
this._secondaryDataSource = new DataSource({ this._secondaryDataSource = new DataSource({
type: 'mongodb', type: 'mongodb',
host: this.env.get('MONGO_HOST'), host: this.configuration.env.get('MONGO_HOST'),
authSource: 'admin', authSource: 'admin',
port: parseInt(this.env.get('MONGO_PORT')), port: parseInt(this.configuration.env.get('MONGO_PORT')),
username: this.env.get('MONGO_USERNAME'), username: this.configuration.env.get('MONGO_USERNAME'),
password: this.env.get('MONGO_PASSWORD', true), password: this.configuration.env.get('MONGO_PASSWORD', true),
database: this.env.get('MONGO_DATABASE'), database: this.configuration.env.get('MONGO_DATABASE'),
entities: [MongoDBRevision], entities: [MongoDBRevision],
retryWrites: false, retryWrites: false,
synchronize: true, synchronize: true,
@@ -62,15 +67,16 @@ export class AppDataSource {
} }
get dataSource(): DataSource { get dataSource(): DataSource {
this.env.load() this.configuration.env.load()
const isConfiguredForMySQL = this.env.get('DB_TYPE') === 'mysql' const isConfiguredForMySQL = this.configuration.env.get('DB_TYPE') === 'mysql'
const isConfiguredForHomeServerOrSelfHosting = const isConfiguredForHomeServerOrSelfHosting =
this.env.get('MODE', true) === 'home-server' || this.env.get('MODE', true) === 'self-hosted' this.configuration.env.get('MODE', true) === 'home-server' ||
this.configuration.env.get('MODE', true) === 'self-hosted'
const maxQueryExecutionTime = this.env.get('DB_MAX_QUERY_EXECUTION_TIME', true) const maxQueryExecutionTime = this.configuration.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
? +this.env.get('DB_MAX_QUERY_EXECUTION_TIME', true) ? +this.configuration.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
: 45_000 : 45_000
const migrationsSourceDirectoryName = isConfiguredForMySQL const migrationsSourceDirectoryName = isConfiguredForMySQL
@@ -83,28 +89,28 @@ export class AppDataSource {
maxQueryExecutionTime, maxQueryExecutionTime,
entities: [isConfiguredForHomeServerOrSelfHosting ? SQLRevision : SQLLegacyRevision], entities: [isConfiguredForHomeServerOrSelfHosting ? SQLRevision : SQLLegacyRevision],
migrations: [`${__dirname}/../../migrations/${migrationsSourceDirectoryName}/*.js`], migrations: [`${__dirname}/../../migrations/${migrationsSourceDirectoryName}/*.js`],
migrationsRun: true, migrationsRun: this.configuration.runMigrations,
logging: <LoggerOptions>this.env.get('DB_DEBUG_LEVEL', true) ?? 'info', logging: <LoggerOptions>this.configuration.env.get('DB_DEBUG_LEVEL', true) ?? 'info',
} }
if (isConfiguredForMySQL) { if (isConfiguredForMySQL) {
const inReplicaMode = this.env.get('DB_REPLICA_HOST', true) ? true : false const inReplicaMode = this.configuration.env.get('DB_REPLICA_HOST', true) ? true : false
const replicationConfig = { const replicationConfig = {
master: { master: {
host: this.env.get('DB_HOST'), host: this.configuration.env.get('DB_HOST'),
port: parseInt(this.env.get('DB_PORT')), port: parseInt(this.configuration.env.get('DB_PORT')),
username: this.env.get('DB_USERNAME'), username: this.configuration.env.get('DB_USERNAME'),
password: this.env.get('DB_PASSWORD'), password: this.configuration.env.get('DB_PASSWORD'),
database: this.env.get('DB_DATABASE'), database: this.configuration.env.get('DB_DATABASE'),
}, },
slaves: [ slaves: [
{ {
host: this.env.get('DB_REPLICA_HOST', true), host: this.configuration.env.get('DB_REPLICA_HOST', true),
port: parseInt(this.env.get('DB_PORT')), port: parseInt(this.configuration.env.get('DB_PORT')),
username: this.env.get('DB_USERNAME'), username: this.configuration.env.get('DB_USERNAME'),
password: this.env.get('DB_PASSWORD'), password: this.configuration.env.get('DB_PASSWORD'),
database: this.env.get('DB_DATABASE'), database: this.configuration.env.get('DB_DATABASE'),
}, },
], ],
removeNodeErrorCount: 10, removeNodeErrorCount: 10,
@@ -118,11 +124,11 @@ export class AppDataSource {
supportBigNumbers: true, supportBigNumbers: true,
bigNumberStrings: false, bigNumberStrings: false,
replication: inReplicaMode ? replicationConfig : undefined, replication: inReplicaMode ? replicationConfig : undefined,
host: inReplicaMode ? undefined : this.env.get('DB_HOST'), host: inReplicaMode ? undefined : this.configuration.env.get('DB_HOST'),
port: inReplicaMode ? undefined : parseInt(this.env.get('DB_PORT')), port: inReplicaMode ? undefined : parseInt(this.configuration.env.get('DB_PORT')),
username: inReplicaMode ? undefined : this.env.get('DB_USERNAME'), username: inReplicaMode ? undefined : this.configuration.env.get('DB_USERNAME'),
password: inReplicaMode ? undefined : this.env.get('DB_PASSWORD'), password: inReplicaMode ? undefined : this.configuration.env.get('DB_PASSWORD'),
database: inReplicaMode ? undefined : this.env.get('DB_DATABASE'), database: inReplicaMode ? undefined : this.configuration.env.get('DB_DATABASE'),
} }
this._dataSource = new DataSource(mySQLDataSourceOptions) this._dataSource = new DataSource(mySQLDataSourceOptions)
@@ -130,7 +136,7 @@ export class AppDataSource {
const sqliteDataSourceOptions: SqliteConnectionOptions = { const sqliteDataSourceOptions: SqliteConnectionOptions = {
...commonDataSourceOptions, ...commonDataSourceOptions,
type: 'sqlite', type: 'sqlite',
database: this.env.get('DB_SQLITE_DATABASE_PATH'), database: this.configuration.env.get('DB_SQLITE_DATABASE_PATH'),
enableWAL: true, enableWAL: true,
busyErrorRetry: 2000, busyErrorRetry: 2000,
} }
@@ -4,4 +4,4 @@ import { Env } from './Env'
const env: Env = new Env() const env: Env = new Env()
env.load() env.load()
export const MigrationsDataSource = new AppDataSource(env).dataSource export const MigrationsDataSource = new AppDataSource({ env, runMigrations: true }).dataSource
@@ -49,6 +49,7 @@ const TYPES = {
Revisions_TriggerTransitionFromPrimaryToSecondaryDatabaseForUser: Symbol.for( Revisions_TriggerTransitionFromPrimaryToSecondaryDatabaseForUser: Symbol.for(
'Revisions_TriggerTransitionFromPrimaryToSecondaryDatabaseForUser', 'Revisions_TriggerTransitionFromPrimaryToSecondaryDatabaseForUser',
), ),
Revisions_RemoveRevisionsFromSharedVault: Symbol.for('Revisions_RemoveRevisionsFromSharedVault'),
// Controller // Controller
Revisions_ControllerContainer: Symbol.for('Revisions_ControllerContainer'), Revisions_ControllerContainer: Symbol.for('Revisions_ControllerContainer'),
Revisions_RevisionsController: Symbol.for('Revisions_RevisionsController'), Revisions_RevisionsController: Symbol.for('Revisions_RevisionsController'),
@@ -58,6 +59,8 @@ const TYPES = {
Revisions_AccountDeletionRequestedEventHandler: Symbol.for('Revisions_AccountDeletionRequestedEventHandler'), Revisions_AccountDeletionRequestedEventHandler: Symbol.for('Revisions_AccountDeletionRequestedEventHandler'),
Revisions_RevisionsCopyRequestedEventHandler: Symbol.for('Revisions_RevisionsCopyRequestedEventHandler'), Revisions_RevisionsCopyRequestedEventHandler: Symbol.for('Revisions_RevisionsCopyRequestedEventHandler'),
Revisions_TransitionStatusUpdatedEventHandler: Symbol.for('Revisions_TransitionStatusUpdatedEventHandler'), Revisions_TransitionStatusUpdatedEventHandler: Symbol.for('Revisions_TransitionStatusUpdatedEventHandler'),
Revisions_ItemRemovedFromSharedVaultEventHandler: Symbol.for('Revisions_ItemRemovedFromSharedVaultEventHandler'),
Revisions_TransitionRequestedEventHandler: Symbol.for('Revisions_TransitionRequestedEventHandler'),
// Services // Services
Revisions_CrossServiceTokenDecoder: Symbol.for('Revisions_CrossServiceTokenDecoder'), Revisions_CrossServiceTokenDecoder: Symbol.for('Revisions_CrossServiceTokenDecoder'),
Revisions_DomainEventSubscriberFactory: Symbol.for('Revisions_DomainEventSubscriberFactory'), Revisions_DomainEventSubscriberFactory: Symbol.for('Revisions_DomainEventSubscriberFactory'),
@@ -9,7 +9,8 @@ export class DomainEventFactory implements DomainEventFactoryInterface {
createTransitionStatusUpdatedEvent(dto: { createTransitionStatusUpdatedEvent(dto: {
userUuid: string userUuid: string
transitionType: 'items' | 'revisions' transitionType: 'items' | 'revisions'
status: 'STARTED' | 'FAILED' | 'FINISHED' transitionTimestamp: number
status: 'STARTED' | 'IN_PROGRESS' | 'FAILED' | 'FINISHED' | 'VERIFIED'
}): TransitionStatusUpdatedEvent { }): TransitionStatusUpdatedEvent {
return { return {
type: 'TRANSITION_STATUS_UPDATED', type: 'TRANSITION_STATUS_UPDATED',
@@ -19,7 +20,7 @@ export class DomainEventFactory implements DomainEventFactoryInterface {
userIdentifier: dto.userUuid, userIdentifier: dto.userUuid,
userIdentifierType: 'uuid', userIdentifierType: 'uuid',
}, },
origin: DomainEventService.SyncingServer, origin: DomainEventService.Revisions,
}, },
payload: dto, payload: dto,
} }
@@ -4,6 +4,7 @@ export interface DomainEventFactoryInterface {
createTransitionStatusUpdatedEvent(dto: { createTransitionStatusUpdatedEvent(dto: {
userUuid: string userUuid: string
transitionType: 'items' | 'revisions' transitionType: 'items' | 'revisions'
status: 'STARTED' | 'FAILED' | 'FINISHED' transitionTimestamp: number
status: 'STARTED' | 'IN_PROGRESS' | 'FAILED' | 'FINISHED' | 'VERIFIED'
}): TransitionStatusUpdatedEvent }): TransitionStatusUpdatedEvent
} }
@@ -1,4 +1,7 @@
import { ItemDumpedEvent } from '@standardnotes/domain-events' import { ItemDumpedEvent } from '@standardnotes/domain-events'
import { Logger } from 'winston'
import { Uuid, ContentType, Dates } from '@standardnotes/domain-core'
import { DumpRepositoryInterface } from '../Dump/DumpRepositoryInterface' import { DumpRepositoryInterface } from '../Dump/DumpRepositoryInterface'
import { Revision } from '../Revision/Revision' import { Revision } from '../Revision/Revision'
import { RevisionRepositoryInterface } from '../Revision/RevisionRepositoryInterface' import { RevisionRepositoryInterface } from '../Revision/RevisionRepositoryInterface'
@@ -11,11 +14,22 @@ describe('ItemDumpedEventHandler', () => {
let revisionRepositoryResolver: RevisionRepositoryResolverInterface let revisionRepositoryResolver: RevisionRepositoryResolverInterface
let revision: Revision let revision: Revision
let event: ItemDumpedEvent let event: ItemDumpedEvent
let logger: Logger
const createHandler = () => new ItemDumpedEventHandler(dumpRepository, revisionRepositoryResolver) const createHandler = () => new ItemDumpedEventHandler(dumpRepository, revisionRepositoryResolver, logger)
beforeEach(() => { beforeEach(() => {
revision = {} as jest.Mocked<Revision> revision = Revision.create({
itemUuid: Uuid.create('84c0f8e8-544a-4c7e-9adf-26209303bc1d').getValue(),
userUuid: Uuid.create('84c0f8e8-544a-4c7e-9adf-26209303bc1d').getValue(),
content: 'test',
contentType: ContentType.create('Note').getValue(),
itemsKeyId: 'test',
encItemKey: 'test',
authHash: 'test',
creationDate: new Date(1),
dates: Dates.create(new Date(1), new Date(2)).getValue(),
}).getValue()
dumpRepository = {} as jest.Mocked<DumpRepositoryInterface> dumpRepository = {} as jest.Mocked<DumpRepositoryInterface>
dumpRepository.getRevisionFromDumpPath = jest.fn().mockReturnValue(revision) dumpRepository.getRevisionFromDumpPath = jest.fn().mockReturnValue(revision)
@@ -32,6 +46,10 @@ describe('ItemDumpedEventHandler', () => {
fileDumpPath: 'foobar', fileDumpPath: 'foobar',
roleNames: ['CORE_USER'], roleNames: ['CORE_USER'],
} }
logger = {} as jest.Mocked<Logger>
logger.debug = jest.fn()
logger.error = jest.fn()
}) })
it('should save a revision from file dump', async () => { it('should save a revision from file dump', async () => {
@@ -3,16 +3,20 @@ import { DomainEventHandlerInterface, ItemDumpedEvent } from '@standardnotes/dom
import { DumpRepositoryInterface } from '../Dump/DumpRepositoryInterface' import { DumpRepositoryInterface } from '../Dump/DumpRepositoryInterface'
import { RevisionRepositoryResolverInterface } from '../Revision/RevisionRepositoryResolverInterface' import { RevisionRepositoryResolverInterface } from '../Revision/RevisionRepositoryResolverInterface'
import { RoleNameCollection } from '@standardnotes/domain-core' import { RoleNameCollection } from '@standardnotes/domain-core'
import { Logger } from 'winston'
export class ItemDumpedEventHandler implements DomainEventHandlerInterface { export class ItemDumpedEventHandler implements DomainEventHandlerInterface {
constructor( constructor(
private dumpRepository: DumpRepositoryInterface, private dumpRepository: DumpRepositoryInterface,
private revisionRepositoryResolver: RevisionRepositoryResolverInterface, private revisionRepositoryResolver: RevisionRepositoryResolverInterface,
private logger: Logger,
) {} ) {}
async handle(event: ItemDumpedEvent): Promise<void> { async handle(event: ItemDumpedEvent): Promise<void> {
const revision = await this.dumpRepository.getRevisionFromDumpPath(event.payload.fileDumpPath) const revision = await this.dumpRepository.getRevisionFromDumpPath(event.payload.fileDumpPath)
if (revision === null) { if (revision === null) {
this.logger.error(`Revision not found for dump path ${event.payload.fileDumpPath}`)
await this.dumpRepository.removeDump(event.payload.fileDumpPath) await this.dumpRepository.removeDump(event.payload.fileDumpPath)
return return
@@ -20,6 +24,8 @@ export class ItemDumpedEventHandler implements DomainEventHandlerInterface {
const roleNamesOrError = RoleNameCollection.create(event.payload.roleNames) const roleNamesOrError = RoleNameCollection.create(event.payload.roleNames)
if (roleNamesOrError.isFailed()) { if (roleNamesOrError.isFailed()) {
this.logger.error(`Invalid role names ${event.payload.roleNames}`)
await this.dumpRepository.removeDump(event.payload.fileDumpPath) await this.dumpRepository.removeDump(event.payload.fileDumpPath)
return return
@@ -28,7 +34,10 @@ export class ItemDumpedEventHandler implements DomainEventHandlerInterface {
const revisionRepository = this.revisionRepositoryResolver.resolve(roleNames) const revisionRepository = this.revisionRepositoryResolver.resolve(roleNames)
await revisionRepository.insert(revision) const successfullyInserted = await revisionRepository.insert(revision)
if (!successfullyInserted) {
this.logger.error(`Could not insert revision ${revision.id.toString()}`)
}
await this.dumpRepository.removeDump(event.payload.fileDumpPath) await this.dumpRepository.removeDump(event.payload.fileDumpPath)
} }

Some files were not shown because too many files have changed in this diff Show More