@powersync/service-core 0.0.0-dev-20240718134716 → 0.0.0-dev-20240918082156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -6
- package/dist/api/RouteAPI.d.ts +68 -0
- package/dist/api/RouteAPI.js +2 -0
- package/dist/api/RouteAPI.js.map +1 -0
- package/dist/api/api-index.d.ts +1 -0
- package/dist/api/api-index.js +1 -0
- package/dist/api/api-index.js.map +1 -1
- package/dist/api/diagnostics.d.ts +4 -4
- package/dist/api/diagnostics.js +11 -65
- package/dist/api/diagnostics.js.map +1 -1
- package/dist/api/schema.d.ts +3 -5
- package/dist/api/schema.js +9 -79
- package/dist/api/schema.js.map +1 -1
- package/dist/auth/KeyStore.d.ts +7 -4
- package/dist/auth/KeyStore.js +1 -1
- package/dist/auth/KeyStore.js.map +1 -1
- package/dist/auth/auth-index.d.ts +0 -1
- package/dist/auth/auth-index.js +0 -1
- package/dist/auth/auth-index.js.map +1 -1
- package/dist/entry/cli-entry.js +4 -2
- package/dist/entry/cli-entry.js.map +1 -1
- package/dist/entry/commands/compact-action.d.ts +2 -0
- package/dist/entry/commands/compact-action.js +52 -0
- package/dist/entry/commands/compact-action.js.map +1 -0
- package/dist/entry/commands/migrate-action.js +4 -5
- package/dist/entry/commands/migrate-action.js.map +1 -1
- package/dist/entry/commands/teardown-action.js +2 -2
- package/dist/entry/commands/teardown-action.js.map +1 -1
- package/dist/entry/entry-index.d.ts +1 -0
- package/dist/entry/entry-index.js +1 -0
- package/dist/entry/entry-index.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/metrics/Metrics.d.ts +6 -5
- package/dist/metrics/Metrics.js +53 -10
- package/dist/metrics/Metrics.js.map +1 -1
- package/dist/migrations/db/migrations/1684951997326-init.d.ts +2 -2
- package/dist/migrations/db/migrations/1684951997326-init.js +4 -2
- package/dist/migrations/db/migrations/1684951997326-init.js.map +1 -1
- package/dist/migrations/db/migrations/1702295701188-sync-rule-state.d.ts +2 -2
- package/dist/migrations/db/migrations/1702295701188-sync-rule-state.js +4 -2
- package/dist/migrations/db/migrations/1702295701188-sync-rule-state.js.map +1 -1
- package/dist/migrations/db/migrations/1711543888062-write-checkpoint-index.d.ts +2 -2
- package/dist/migrations/db/migrations/1711543888062-write-checkpoint-index.js +4 -2
- package/dist/migrations/db/migrations/1711543888062-write-checkpoint-index.js.map +1 -1
- package/dist/migrations/migrations.d.ts +8 -0
- package/dist/migrations/migrations.js +19 -7
- package/dist/migrations/migrations.js.map +1 -1
- package/dist/modules/AbstractModule.d.ts +26 -0
- package/dist/modules/AbstractModule.js +11 -0
- package/dist/modules/AbstractModule.js.map +1 -0
- package/dist/modules/ModuleManager.d.ts +11 -0
- package/dist/modules/ModuleManager.js +32 -0
- package/dist/modules/ModuleManager.js.map +1 -0
- package/dist/modules/modules-index.d.ts +2 -0
- package/dist/modules/modules-index.js +3 -0
- package/dist/modules/modules-index.js.map +1 -0
- package/dist/replication/AbstractReplicationJob.d.ts +38 -0
- package/dist/replication/AbstractReplicationJob.js +51 -0
- package/dist/replication/AbstractReplicationJob.js.map +1 -0
- package/dist/replication/AbstractReplicator.d.ts +53 -0
- package/dist/replication/AbstractReplicator.js +187 -0
- package/dist/replication/AbstractReplicator.js.map +1 -0
- package/dist/replication/ErrorRateLimiter.d.ts +0 -9
- package/dist/replication/ErrorRateLimiter.js +1 -42
- package/dist/replication/ErrorRateLimiter.js.map +1 -1
- package/dist/replication/ReplicationEngine.d.ts +18 -0
- package/dist/replication/ReplicationEngine.js +41 -0
- package/dist/replication/ReplicationEngine.js.map +1 -0
- package/dist/replication/ReplicationModule.d.ts +39 -0
- package/dist/replication/ReplicationModule.js +65 -0
- package/dist/replication/ReplicationModule.js.map +1 -0
- package/dist/replication/replication-index.d.ts +4 -6
- package/dist/replication/replication-index.js +4 -6
- package/dist/replication/replication-index.js.map +1 -1
- package/dist/routes/RouterEngine.d.ts +42 -0
- package/dist/routes/RouterEngine.js +80 -0
- package/dist/routes/RouterEngine.js.map +1 -0
- package/dist/routes/auth.d.ts +2 -2
- package/dist/routes/auth.js +11 -11
- package/dist/routes/auth.js.map +1 -1
- package/dist/routes/configure-fastify.d.ts +737 -0
- package/dist/routes/configure-fastify.js +57 -0
- package/dist/routes/configure-fastify.js.map +1 -0
- package/dist/routes/configure-rsocket.d.ts +13 -0
- package/dist/routes/configure-rsocket.js +47 -0
- package/dist/routes/configure-rsocket.js.map +1 -0
- package/dist/routes/endpoints/admin.d.ts +0 -34
- package/dist/routes/endpoints/admin.js +48 -89
- package/dist/routes/endpoints/admin.js.map +1 -1
- package/dist/routes/endpoints/checkpointing.d.ts +56 -16
- package/dist/routes/endpoints/checkpointing.js +33 -12
- package/dist/routes/endpoints/checkpointing.js.map +1 -1
- package/dist/routes/endpoints/route-endpoints-index.d.ts +0 -1
- package/dist/routes/endpoints/route-endpoints-index.js +0 -1
- package/dist/routes/endpoints/route-endpoints-index.js.map +1 -1
- package/dist/routes/endpoints/socket-route.js +46 -39
- package/dist/routes/endpoints/socket-route.js.map +1 -1
- package/dist/routes/endpoints/sync-rules.d.ts +1 -1
- package/dist/routes/endpoints/sync-rules.js +32 -23
- package/dist/routes/endpoints/sync-rules.js.map +1 -1
- package/dist/routes/endpoints/sync-stream.d.ts +10 -0
- package/dist/routes/endpoints/sync-stream.js +17 -13
- package/dist/routes/endpoints/sync-stream.js.map +1 -1
- package/dist/routes/route-register.d.ts +1 -1
- package/dist/routes/route-register.js +1 -1
- package/dist/routes/route-register.js.map +1 -1
- package/dist/routes/router-socket.d.ts +5 -4
- package/dist/routes/router-socket.js +2 -1
- package/dist/routes/router-socket.js.map +1 -1
- package/dist/routes/router.d.ts +7 -2
- package/dist/routes/router.js.map +1 -1
- package/dist/routes/routes-index.d.ts +3 -0
- package/dist/routes/routes-index.js +3 -0
- package/dist/routes/routes-index.js.map +1 -1
- package/dist/runner/teardown.js +47 -76
- package/dist/runner/teardown.js.map +1 -1
- package/dist/storage/BucketStorage.d.ts +61 -20
- package/dist/storage/BucketStorage.js +0 -10
- package/dist/storage/BucketStorage.js.map +1 -1
- package/dist/storage/MongoBucketStorage.d.ts +4 -4
- package/dist/storage/MongoBucketStorage.js +19 -24
- package/dist/storage/MongoBucketStorage.js.map +1 -1
- package/dist/storage/SourceEntity.d.ts +20 -0
- package/dist/storage/SourceEntity.js +2 -0
- package/dist/storage/SourceEntity.js.map +1 -0
- package/dist/storage/SourceTable.d.ts +4 -5
- package/dist/storage/SourceTable.js +3 -4
- package/dist/storage/SourceTable.js.map +1 -1
- package/dist/storage/StorageEngine.d.ts +24 -0
- package/dist/storage/StorageEngine.js +43 -0
- package/dist/storage/StorageEngine.js.map +1 -0
- package/dist/storage/StorageProvider.d.ts +21 -0
- package/dist/storage/StorageProvider.js +2 -0
- package/dist/storage/StorageProvider.js.map +1 -0
- package/dist/storage/mongo/MongoBucketBatch.d.ts +1 -1
- package/dist/storage/mongo/MongoBucketBatch.js +6 -7
- package/dist/storage/mongo/MongoBucketBatch.js.map +1 -1
- package/dist/storage/mongo/MongoCompactor.d.ts +40 -0
- package/dist/storage/mongo/MongoCompactor.js +293 -0
- package/dist/storage/mongo/MongoCompactor.js.map +1 -0
- package/dist/storage/mongo/MongoPersistedSyncRulesContent.d.ts +2 -2
- package/dist/storage/mongo/MongoPersistedSyncRulesContent.js +2 -2
- package/dist/storage/mongo/MongoPersistedSyncRulesContent.js.map +1 -1
- package/dist/storage/mongo/MongoStorageProvider.d.ts +5 -0
- package/dist/storage/mongo/MongoStorageProvider.js +26 -0
- package/dist/storage/mongo/MongoStorageProvider.js.map +1 -0
- package/dist/storage/mongo/MongoSyncBucketStorage.d.ts +9 -7
- package/dist/storage/mongo/MongoSyncBucketStorage.js +43 -28
- package/dist/storage/mongo/MongoSyncBucketStorage.js.map +1 -1
- package/dist/storage/mongo/MongoSyncRulesLock.js +1 -1
- package/dist/storage/mongo/MongoSyncRulesLock.js.map +1 -1
- package/dist/storage/mongo/OperationBatch.d.ts +7 -3
- package/dist/storage/mongo/OperationBatch.js +16 -7
- package/dist/storage/mongo/OperationBatch.js.map +1 -1
- package/dist/storage/mongo/PersistedBatch.d.ts +3 -3
- package/dist/storage/mongo/PersistedBatch.js +2 -2
- package/dist/storage/mongo/PersistedBatch.js.map +1 -1
- package/dist/storage/mongo/models.d.ts +17 -7
- package/dist/storage/mongo/models.js.map +1 -1
- package/dist/storage/mongo/util.d.ts +14 -0
- package/dist/storage/mongo/util.js +70 -0
- package/dist/storage/mongo/util.js.map +1 -1
- package/dist/storage/storage-index.d.ts +5 -2
- package/dist/storage/storage-index.js +5 -2
- package/dist/storage/storage-index.js.map +1 -1
- package/dist/sync/RequestTracker.js +2 -3
- package/dist/sync/RequestTracker.js.map +1 -1
- package/dist/sync/sync-index.d.ts +1 -0
- package/dist/sync/sync-index.js +1 -0
- package/dist/sync/sync-index.js.map +1 -1
- package/dist/sync/sync.d.ts +2 -1
- package/dist/sync/sync.js +56 -17
- package/dist/sync/sync.js.map +1 -1
- package/dist/system/ServiceContext.d.ts +37 -0
- package/dist/system/ServiceContext.js +48 -0
- package/dist/system/ServiceContext.js.map +1 -0
- package/dist/system/system-index.d.ts +1 -1
- package/dist/system/system-index.js +1 -1
- package/dist/system/system-index.js.map +1 -1
- package/dist/util/config/collectors/config-collector.d.ts +12 -0
- package/dist/util/config/collectors/config-collector.js +43 -0
- package/dist/util/config/collectors/config-collector.js.map +1 -1
- package/dist/util/config/compound-config-collector.d.ts +10 -29
- package/dist/util/config/compound-config-collector.js +28 -84
- package/dist/util/config/compound-config-collector.js.map +1 -1
- package/dist/util/config/sync-rules/sync-rules-provider.d.ts +9 -0
- package/dist/util/config/sync-rules/sync-rules-provider.js +15 -0
- package/dist/util/config/sync-rules/sync-rules-provider.js.map +1 -0
- package/dist/util/config/types.d.ts +6 -4
- package/dist/util/config/types.js.map +1 -1
- package/dist/util/config.d.ts +3 -4
- package/dist/util/config.js +5 -20
- package/dist/util/config.js.map +1 -1
- package/dist/util/protocol-types.d.ts +4 -0
- package/dist/util/protocol-types.js +5 -1
- package/dist/util/protocol-types.js.map +1 -1
- package/dist/util/util-index.d.ts +3 -6
- package/dist/util/util-index.js +3 -6
- package/dist/util/util-index.js.map +1 -1
- package/dist/util/utils.d.ts +10 -6
- package/dist/util/utils.js +45 -25
- package/dist/util/utils.js.map +1 -1
- package/package.json +7 -7
- package/src/api/RouteAPI.ts +78 -0
- package/src/api/api-index.ts +1 -0
- package/src/api/diagnostics.ts +16 -71
- package/src/api/schema.ts +13 -89
- package/src/auth/KeyStore.ts +9 -6
- package/src/auth/auth-index.ts +0 -1
- package/src/entry/cli-entry.ts +4 -2
- package/src/entry/commands/compact-action.ts +57 -0
- package/src/entry/commands/migrate-action.ts +5 -8
- package/src/entry/commands/teardown-action.ts +2 -2
- package/src/entry/entry-index.ts +1 -0
- package/src/index.ts +5 -2
- package/src/metrics/Metrics.ts +70 -15
- package/src/migrations/db/migrations/1684951997326-init.ts +9 -4
- package/src/migrations/db/migrations/1702295701188-sync-rule-state.ts +7 -4
- package/src/migrations/db/migrations/1711543888062-write-checkpoint-index.ts +6 -4
- package/src/migrations/migrations.ts +24 -8
- package/src/modules/AbstractModule.ts +37 -0
- package/src/modules/ModuleManager.ts +34 -0
- package/src/modules/modules-index.ts +2 -0
- package/src/replication/AbstractReplicationJob.ts +79 -0
- package/src/replication/AbstractReplicator.ts +227 -0
- package/src/replication/ErrorRateLimiter.ts +0 -44
- package/src/replication/ReplicationEngine.ts +43 -0
- package/src/replication/ReplicationModule.ts +101 -0
- package/src/replication/replication-index.ts +4 -6
- package/src/routes/RouterEngine.ts +120 -0
- package/src/routes/auth.ts +21 -12
- package/src/routes/configure-fastify.ts +101 -0
- package/src/routes/configure-rsocket.ts +60 -0
- package/src/routes/endpoints/admin.ts +74 -100
- package/src/routes/endpoints/checkpointing.ts +46 -12
- package/src/routes/endpoints/route-endpoints-index.ts +0 -1
- package/src/routes/endpoints/socket-route.ts +50 -42
- package/src/routes/endpoints/sync-rules.ts +41 -25
- package/src/routes/endpoints/sync-stream.ts +17 -13
- package/src/routes/route-register.ts +2 -2
- package/src/routes/router-socket.ts +6 -5
- package/src/routes/router.ts +7 -2
- package/src/routes/routes-index.ts +3 -0
- package/src/runner/teardown.ts +50 -88
- package/src/storage/BucketStorage.ts +74 -26
- package/src/storage/MongoBucketStorage.ts +23 -26
- package/src/storage/SourceEntity.ts +22 -0
- package/src/storage/SourceTable.ts +4 -6
- package/src/storage/StorageEngine.ts +55 -0
- package/src/storage/StorageProvider.ts +27 -0
- package/src/storage/mongo/MongoBucketBatch.ts +8 -8
- package/src/storage/mongo/MongoCompactor.ts +372 -0
- package/src/storage/mongo/MongoPersistedSyncRulesContent.ts +3 -3
- package/src/storage/mongo/MongoStorageProvider.ts +31 -0
- package/src/storage/mongo/MongoSyncBucketStorage.ts +64 -34
- package/src/storage/mongo/MongoSyncRulesLock.ts +1 -1
- package/src/storage/mongo/OperationBatch.ts +18 -11
- package/src/storage/mongo/PersistedBatch.ts +6 -5
- package/src/storage/mongo/models.ts +17 -7
- package/src/storage/mongo/util.ts +71 -1
- package/src/storage/storage-index.ts +5 -2
- package/src/sync/RequestTracker.ts +3 -3
- package/src/sync/sync-index.ts +1 -0
- package/src/sync/sync.ts +66 -17
- package/src/system/ServiceContext.ts +68 -0
- package/src/system/system-index.ts +1 -1
- package/src/util/config/collectors/config-collector.ts +48 -0
- package/src/util/config/compound-config-collector.ts +45 -110
- package/src/util/config/sync-rules/sync-rules-provider.ts +18 -0
- package/src/util/config/types.ts +6 -5
- package/src/util/config.ts +6 -23
- package/src/util/protocol-types.ts +6 -1
- package/src/util/util-index.ts +3 -6
- package/src/util/utils.ts +55 -39
- package/test/src/__snapshots__/sync.test.ts.snap +90 -5
- package/test/src/auth.test.ts +7 -7
- package/test/src/broadcast_iterable.test.ts +1 -1
- package/test/src/bucket_validation.test.ts +142 -0
- package/test/src/bucket_validation.ts +116 -0
- package/test/src/checksum_cache.test.ts +3 -3
- package/test/src/compacting.test.ts +216 -0
- package/test/src/data_storage.test.ts +275 -204
- package/test/src/env.ts +1 -3
- package/test/src/merge_iterable.test.ts +1 -6
- package/test/src/setup.ts +1 -1
- package/test/src/stream_utils.ts +42 -0
- package/test/src/sync.test.ts +209 -48
- package/test/src/util.ts +110 -55
- package/test/tsconfig.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/auth/SupabaseKeyCollector.d.ts +0 -22
- package/dist/auth/SupabaseKeyCollector.js +0 -61
- package/dist/auth/SupabaseKeyCollector.js.map +0 -1
- package/dist/replication/PgRelation.d.ts +0 -16
- package/dist/replication/PgRelation.js +0 -26
- package/dist/replication/PgRelation.js.map +0 -1
- package/dist/replication/WalConnection.d.ts +0 -34
- package/dist/replication/WalConnection.js +0 -190
- package/dist/replication/WalConnection.js.map +0 -1
- package/dist/replication/WalStream.d.ts +0 -57
- package/dist/replication/WalStream.js +0 -517
- package/dist/replication/WalStream.js.map +0 -1
- package/dist/replication/WalStreamManager.d.ts +0 -30
- package/dist/replication/WalStreamManager.js +0 -198
- package/dist/replication/WalStreamManager.js.map +0 -1
- package/dist/replication/WalStreamRunner.d.ts +0 -38
- package/dist/replication/WalStreamRunner.js +0 -155
- package/dist/replication/WalStreamRunner.js.map +0 -1
- package/dist/replication/util.d.ts +0 -9
- package/dist/replication/util.js +0 -62
- package/dist/replication/util.js.map +0 -1
- package/dist/routes/endpoints/dev.d.ts +0 -312
- package/dist/routes/endpoints/dev.js +0 -172
- package/dist/routes/endpoints/dev.js.map +0 -1
- package/dist/system/CorePowerSyncSystem.d.ts +0 -23
- package/dist/system/CorePowerSyncSystem.js +0 -52
- package/dist/system/CorePowerSyncSystem.js.map +0 -1
- package/dist/util/PgManager.d.ts +0 -24
- package/dist/util/PgManager.js +0 -55
- package/dist/util/PgManager.js.map +0 -1
- package/dist/util/migration_lib.d.ts +0 -11
- package/dist/util/migration_lib.js +0 -64
- package/dist/util/migration_lib.js.map +0 -1
- package/dist/util/pgwire_utils.d.ts +0 -24
- package/dist/util/pgwire_utils.js +0 -117
- package/dist/util/pgwire_utils.js.map +0 -1
- package/dist/util/populate_test_data.d.ts +0 -8
- package/dist/util/populate_test_data.js +0 -65
- package/dist/util/populate_test_data.js.map +0 -1
- package/src/auth/SupabaseKeyCollector.ts +0 -67
- package/src/replication/PgRelation.ts +0 -42
- package/src/replication/WalConnection.ts +0 -227
- package/src/replication/WalStream.ts +0 -628
- package/src/replication/WalStreamManager.ts +0 -213
- package/src/replication/WalStreamRunner.ts +0 -180
- package/src/replication/util.ts +0 -76
- package/src/routes/endpoints/dev.ts +0 -199
- package/src/system/CorePowerSyncSystem.ts +0 -64
- package/src/util/PgManager.ts +0 -64
- package/src/util/migration_lib.ts +0 -79
- package/src/util/pgwire_utils.ts +0 -139
- package/src/util/populate_test_data.ts +0 -78
- package/test/src/__snapshots__/pg_test.test.ts.snap +0 -256
- package/test/src/large_batch.test.ts +0 -194
- package/test/src/pg_test.test.ts +0 -450
- package/test/src/schema_changes.test.ts +0 -545
- package/test/src/slow_tests.test.ts +0 -296
- package/test/src/validation.test.ts +0 -63
- package/test/src/wal_stream.test.ts +0 -314
- package/test/src/wal_stream_utils.ts +0 -147
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { configFile
|
|
3
|
-
import { ConfigCollector } from './collectors/config-collector.js';
|
|
4
|
-
import { ResolvedConnection, ResolvedPowerSyncConfig, RunnerConfig, SyncRulesConfig } from './types.js';
|
|
1
|
+
import { logger } from '@powersync/lib-services-framework';
|
|
2
|
+
import { configFile } from '@powersync/service-types';
|
|
5
3
|
import * as auth from '../../auth/auth-index.js';
|
|
6
|
-
import {
|
|
4
|
+
import { ConfigCollector } from './collectors/config-collector.js';
|
|
7
5
|
import { Base64ConfigCollector } from './collectors/impl/base64-config-collector.js';
|
|
6
|
+
import { FallbackConfigCollector } from './collectors/impl/fallback-config-collector.js';
|
|
8
7
|
import { FileSystemConfigCollector } from './collectors/impl/filesystem-config-collector.js';
|
|
9
8
|
import { Base64SyncRulesCollector } from './sync-rules/impl/base64-sync-rules-collector.js';
|
|
10
|
-
import { InlineSyncRulesCollector } from './sync-rules/impl/inline-sync-rules-collector.js';
|
|
11
9
|
import { FileSystemSyncRulesCollector } from './sync-rules/impl/filesystem-sync-rules-collector.js';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
const POWERSYNC_DEV_KID = 'powersync-dev';
|
|
10
|
+
import { InlineSyncRulesCollector } from './sync-rules/impl/inline-sync-rules-collector.js';
|
|
11
|
+
import { SyncRulesCollector } from './sync-rules/sync-collector.js';
|
|
12
|
+
import { ResolvedPowerSyncConfig, RunnerConfig, SyncRulesConfig } from './types.js';
|
|
16
13
|
|
|
17
14
|
export type CompoundConfigCollectorOptions = {
|
|
18
15
|
/**
|
|
@@ -29,12 +26,17 @@ export type CompoundConfigCollectorOptions = {
|
|
|
29
26
|
syncRulesCollectors: SyncRulesCollector[];
|
|
30
27
|
};
|
|
31
28
|
|
|
32
|
-
export type
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
export type ConfigCollectedEvent = {
|
|
30
|
+
base_config: configFile.PowerSyncConfig;
|
|
31
|
+
resolved_config: ResolvedPowerSyncConfig;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type ConfigCollectorListener = {
|
|
35
|
+
configCollected?: (event: ConfigCollectedEvent) => Promise<void>;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
const POWERSYNC_DEV_KID = 'powersync-dev';
|
|
39
|
+
|
|
38
40
|
const DEFAULT_COLLECTOR_OPTIONS: CompoundConfigCollectorOptions = {
|
|
39
41
|
configCollectors: [new Base64ConfigCollector(), new FileSystemConfigCollector(), new FallbackConfigCollector()],
|
|
40
42
|
syncRulesCollectors: [
|
|
@@ -44,71 +46,20 @@ const DEFAULT_COLLECTOR_OPTIONS: CompoundConfigCollectorOptions = {
|
|
|
44
46
|
]
|
|
45
47
|
};
|
|
46
48
|
|
|
47
|
-
export class CompoundConfigCollector
|
|
49
|
+
export class CompoundConfigCollector {
|
|
48
50
|
constructor(protected options: CompoundConfigCollectorOptions = DEFAULT_COLLECTOR_OPTIONS) {}
|
|
49
51
|
|
|
50
|
-
/**
|
|
51
|
-
* The default ts-codec for validations and decoding
|
|
52
|
-
*/
|
|
53
|
-
get codec(): t.AnyCodec {
|
|
54
|
-
return configFile.powerSyncConfig;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
52
|
/**
|
|
58
53
|
* Collects and resolves base config
|
|
59
54
|
*/
|
|
60
|
-
async collectConfig(runnerConfig: RunnerConfig = {}): Promise<
|
|
55
|
+
async collectConfig(runnerConfig: RunnerConfig = {}): Promise<ResolvedPowerSyncConfig> {
|
|
61
56
|
const baseConfig = await this.collectBaseConfig(runnerConfig);
|
|
62
|
-
const baseResolvedConfig = await this.resolveBaseConfig(baseConfig, runnerConfig);
|
|
63
|
-
return this.resolveConfig(baseConfig, baseResolvedConfig, runnerConfig);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Collects the base PowerSyncConfig from various registered collectors.
|
|
68
|
-
* @throws if no collector could return a configuration.
|
|
69
|
-
*/
|
|
70
|
-
protected async collectBaseConfig(runner_config: RunnerConfig): Promise<Generics['DESERIALIZED']> {
|
|
71
|
-
for (const collector of this.options.configCollectors) {
|
|
72
|
-
try {
|
|
73
|
-
const baseConfig = await collector.collectSerialized(runner_config);
|
|
74
|
-
if (baseConfig) {
|
|
75
|
-
const decoded = this.decode(baseConfig);
|
|
76
|
-
this.validate(decoded);
|
|
77
|
-
return decoded;
|
|
78
|
-
}
|
|
79
|
-
logger.debug(
|
|
80
|
-
`Could not collect PowerSync config with ${collector.name} method. Moving on to next method if available.`
|
|
81
|
-
);
|
|
82
|
-
} catch (ex) {
|
|
83
|
-
// An error in a collector is a hard stop
|
|
84
|
-
throw new Error(`Could not collect config using ${collector.name} method. Caught exception: ${ex}`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
throw new Error('PowerSyncConfig could not be collected using any of the registered config collectors.');
|
|
88
|
-
}
|
|
89
57
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
protected async resolveBaseConfig(
|
|
94
|
-
baseConfig: Generics['DESERIALIZED'],
|
|
95
|
-
runnerConfig: RunnerConfig = {}
|
|
96
|
-
): Promise<ResolvedPowerSyncConfig> {
|
|
97
|
-
const connections = baseConfig.replication?.connections ?? [];
|
|
98
|
-
if (connections.length > 1) {
|
|
99
|
-
throw new Error('Only a single replication connection is supported currently');
|
|
58
|
+
const dataSources = baseConfig.replication?.connections ?? [];
|
|
59
|
+
if (dataSources.length > 1) {
|
|
60
|
+
throw new Error('Only a single replication data source is supported currently');
|
|
100
61
|
}
|
|
101
62
|
|
|
102
|
-
const mapped = connections.map((c) => {
|
|
103
|
-
const conf: ResolvedConnection = {
|
|
104
|
-
type: 'postgresql' as const,
|
|
105
|
-
...normalizeConnection(c),
|
|
106
|
-
debug_api: c.debug_api ?? false
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
return conf;
|
|
110
|
-
});
|
|
111
|
-
|
|
112
63
|
const collectors = new auth.CompoundKeyCollector();
|
|
113
64
|
const keyStore = new auth.KeyStore(collectors);
|
|
114
65
|
|
|
@@ -117,10 +68,6 @@ export class CompoundConfigCollector<Generics extends ConfigCollectorGenerics =
|
|
|
117
68
|
|
|
118
69
|
collectors.add(staticCollector);
|
|
119
70
|
|
|
120
|
-
if (baseConfig.client_auth?.supabase && mapped.length > 0) {
|
|
121
|
-
collectors.add(new auth.CachedKeyCollector(new auth.SupabaseKeyCollector(mapped[0])));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
71
|
let jwks_uris = baseConfig.client_auth?.jwks_uri ?? [];
|
|
125
72
|
if (typeof jwks_uris == 'string') {
|
|
126
73
|
jwks_uris = [jwks_uris];
|
|
@@ -146,7 +93,8 @@ export class CompoundConfigCollector<Generics extends ConfigCollectorGenerics =
|
|
|
146
93
|
let jwt_audiences: string[] = baseConfig.client_auth?.audience ?? [];
|
|
147
94
|
|
|
148
95
|
let config: ResolvedPowerSyncConfig = {
|
|
149
|
-
|
|
96
|
+
base_config: baseConfig,
|
|
97
|
+
connections: baseConfig.replication?.connections || [],
|
|
150
98
|
storage: baseConfig.storage,
|
|
151
99
|
client_keystore: keyStore,
|
|
152
100
|
// Dev tokens only use the static keys, no external key sources
|
|
@@ -172,23 +120,34 @@ export class CompoundConfigCollector<Generics extends ConfigCollectorGenerics =
|
|
|
172
120
|
internal_service_endpoint:
|
|
173
121
|
baseConfig.telemetry?.internal_service_endpoint ?? 'https://pulse.journeyapps.com/v1/metrics'
|
|
174
122
|
},
|
|
175
|
-
|
|
123
|
+
// TODO maybe move this out of the connection or something
|
|
124
|
+
// slot_name_prefix: connections[0]?.slot_name_prefix ?? 'powersync_'
|
|
125
|
+
slot_name_prefix: 'powersync_'
|
|
176
126
|
};
|
|
127
|
+
|
|
177
128
|
return config;
|
|
178
129
|
}
|
|
179
130
|
|
|
180
131
|
/**
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
132
|
+
* Collects the base PowerSyncConfig from various registered collectors.
|
|
133
|
+
* @throws if no collector could return a configuration.
|
|
184
134
|
*/
|
|
185
|
-
protected async
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
135
|
+
protected async collectBaseConfig(runner_config: RunnerConfig): Promise<configFile.PowerSyncConfig> {
|
|
136
|
+
for (const collector of this.options.configCollectors) {
|
|
137
|
+
try {
|
|
138
|
+
const baseConfig = await collector.collect(runner_config);
|
|
139
|
+
if (baseConfig) {
|
|
140
|
+
return baseConfig;
|
|
141
|
+
}
|
|
142
|
+
logger.debug(
|
|
143
|
+
`Could not collect PowerSync config with ${collector.name} method. Moving on to next method if available.`
|
|
144
|
+
);
|
|
145
|
+
} catch (ex) {
|
|
146
|
+
// An error in a collector is a hard stop
|
|
147
|
+
throw new Error(`Could not collect config using ${collector.name} method. Caught exception: ${ex}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
throw new Error('PowerSyncConfig could not be collected using any of the registered config collectors.');
|
|
192
151
|
}
|
|
193
152
|
|
|
194
153
|
protected async collectSyncRules(
|
|
@@ -213,28 +172,4 @@ export class CompoundConfigCollector<Generics extends ConfigCollectorGenerics =
|
|
|
213
172
|
present: false
|
|
214
173
|
};
|
|
215
174
|
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Validates input config
|
|
219
|
-
* ts-codec itself doesn't give great validation errors, so we use json schema for that
|
|
220
|
-
*/
|
|
221
|
-
protected validate(config: Generics['DESERIALIZED']) {
|
|
222
|
-
// ts-codec itself doesn't give great validation errors, so we use json schema for that
|
|
223
|
-
const validator = schema
|
|
224
|
-
.parseJSONSchema(t.generateJSONSchema(this.codec, { allowAdditional: true, parsers: [configFile.portParser] }))
|
|
225
|
-
.validator();
|
|
226
|
-
|
|
227
|
-
const valid = validator.validate(config);
|
|
228
|
-
if (!valid.valid) {
|
|
229
|
-
throw new Error(`Failed to validate PowerSync config: ${valid.errors.join(', ')}`);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
protected decode(encoded: Generics['SERIALIZED']): Generics['DESERIALIZED'] {
|
|
234
|
-
try {
|
|
235
|
-
return this.codec.decode(encoded);
|
|
236
|
-
} catch (ex) {
|
|
237
|
-
throw new Error(`Failed to decode PowerSync config: ${ex}`);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
175
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SyncRulesConfig } from '../types.js';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
|
|
4
|
+
export interface SyncRulesProvider {
|
|
5
|
+
get(): Promise<string | undefined>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class ConfigurationFileSyncRulesProvider implements SyncRulesProvider {
|
|
9
|
+
constructor(private config: SyncRulesConfig) {}
|
|
10
|
+
|
|
11
|
+
async get(): Promise<string | undefined> {
|
|
12
|
+
if (this.config.content) {
|
|
13
|
+
return this.config.content;
|
|
14
|
+
} else if (this.config.path) {
|
|
15
|
+
return await fs.readFile(this.config.path, 'utf-8');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/util/config/types.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { configFile } from '@powersync/service-types';
|
|
2
|
+
import { PowerSyncConfig } from '@powersync/service-types/src/config/PowerSyncConfig.js';
|
|
3
|
+
import { CompoundKeyCollector } from '../../auth/CompoundKeyCollector.js';
|
|
2
4
|
import { KeySpec } from '../../auth/KeySpec.js';
|
|
3
5
|
import { KeyStore } from '../../auth/KeyStore.js';
|
|
4
6
|
|
|
@@ -20,8 +22,6 @@ export type MigrationContext = {
|
|
|
20
22
|
|
|
21
23
|
export type Runner = (config: RunnerConfig) => Promise<void>;
|
|
22
24
|
|
|
23
|
-
export type ResolvedConnection = configFile.PostgresConnection & NormalizedPostgresConnection;
|
|
24
|
-
|
|
25
25
|
export type SyncRulesConfig = {
|
|
26
26
|
present: boolean;
|
|
27
27
|
content?: string;
|
|
@@ -29,7 +29,8 @@ export type SyncRulesConfig = {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export type ResolvedPowerSyncConfig = {
|
|
32
|
-
|
|
32
|
+
base_config: PowerSyncConfig;
|
|
33
|
+
connections?: configFile.DataSourceConfig[];
|
|
33
34
|
storage: configFile.StorageConfig;
|
|
34
35
|
dev: {
|
|
35
36
|
demo_auth: boolean;
|
|
@@ -41,7 +42,7 @@ export type ResolvedPowerSyncConfig = {
|
|
|
41
42
|
*/
|
|
42
43
|
dev_key?: KeySpec;
|
|
43
44
|
};
|
|
44
|
-
client_keystore: KeyStore
|
|
45
|
+
client_keystore: KeyStore<CompoundKeyCollector>;
|
|
45
46
|
/**
|
|
46
47
|
* Keystore for development tokens.
|
|
47
48
|
*/
|
package/src/util/config.ts
CHANGED
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
import * as fs from 'fs/promises';
|
|
2
|
-
import { baseUri } from '@powersync/service-types';
|
|
3
2
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { container } from '@powersync/lib-services-framework';
|
|
4
|
+
import { ResolvedPowerSyncConfig, RunnerConfig } from './config/types.js';
|
|
5
|
+
import { CompoundConfigCollector } from './util-index.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Loads the resolved config using the registered config collector
|
|
9
9
|
*/
|
|
10
|
-
export function
|
|
11
|
-
|
|
12
|
-
throw new Error('Not supported');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const uri = new URL(baseUri(options));
|
|
16
|
-
uri.username = options.username;
|
|
17
|
-
uri.password = options.password;
|
|
18
|
-
if (options.sslmode != 'disable') {
|
|
19
|
-
// verify-full is tricky to actually use on a client, since they won't have the cert
|
|
20
|
-
// Just use "require" by default
|
|
21
|
-
// uri.searchParams.set('sslmode', options.sslmode);
|
|
22
|
-
uri.searchParams.set('sslmode', 'require');
|
|
23
|
-
}
|
|
24
|
-
return uri.toString();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function loadConfig(runnerConfig: RunnerConfig = {}) {
|
|
28
|
-
const collector = new CompoundConfigCollector();
|
|
10
|
+
export async function loadConfig(runnerConfig: RunnerConfig) {
|
|
11
|
+
const collector = container.getImplementation(CompoundConfigCollector);
|
|
29
12
|
return collector.collectConfig(runnerConfig);
|
|
30
13
|
}
|
|
31
14
|
|
|
@@ -94,7 +94,12 @@ export const StreamingSyncRequest = t.object({
|
|
|
94
94
|
/**
|
|
95
95
|
* Client parameters to be passed to the sync rules.
|
|
96
96
|
*/
|
|
97
|
-
parameters: t.record(t.any).optional()
|
|
97
|
+
parameters: t.record(t.any).optional(),
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Unique client id.
|
|
101
|
+
*/
|
|
102
|
+
client_id: t.string.optional()
|
|
98
103
|
});
|
|
99
104
|
|
|
100
105
|
export type StreamingSyncRequest = t.Decoded<typeof StreamingSyncRequest>;
|
package/src/util/util-index.ts
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
export * from './alerting.js';
|
|
2
2
|
export * from './env.js';
|
|
3
3
|
export * from './memory-tracking.js';
|
|
4
|
-
export * from './migration_lib.js';
|
|
5
4
|
export * from './Mutex.js';
|
|
6
|
-
export * from './PgManager.js';
|
|
7
|
-
export * from './pgwire_utils.js';
|
|
8
|
-
export * from './populate_test_data.js';
|
|
9
5
|
export * from './protocol-types.js';
|
|
10
6
|
export * from './secs.js';
|
|
11
7
|
export * from './utils.js';
|
|
12
8
|
|
|
13
9
|
export * from './config.js';
|
|
14
|
-
export * from './config/types.js';
|
|
15
10
|
export * from './config/compound-config-collector.js';
|
|
11
|
+
export * from './config/types.js';
|
|
16
12
|
|
|
17
13
|
export * from './config/collectors/config-collector.js';
|
|
18
14
|
export * from './config/collectors/impl/base64-config-collector.js';
|
|
19
15
|
export * from './config/collectors/impl/fallback-config-collector.js';
|
|
20
16
|
export * from './config/collectors/impl/filesystem-config-collector.js';
|
|
21
17
|
|
|
22
|
-
export * from './config/sync-rules/sync-collector.js';
|
|
23
18
|
export * from './config/sync-rules/impl/base64-sync-rules-collector.js';
|
|
24
19
|
export * from './config/sync-rules/impl/filesystem-sync-rules-collector.js';
|
|
25
20
|
export * from './config/sync-rules/impl/inline-sync-rules-collector.js';
|
|
21
|
+
export * from './config/sync-rules/sync-collector.js';
|
|
22
|
+
export * from './config/sync-rules/sync-rules-provider.js';
|
package/src/util/utils.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import * as sync_rules from '@powersync/service-sync-rules';
|
|
2
|
+
import * as bson from 'bson';
|
|
1
3
|
import crypto from 'crypto';
|
|
2
|
-
import * as
|
|
3
|
-
import {
|
|
4
|
+
import * as uuid from 'uuid';
|
|
5
|
+
import { BucketChecksum, OpId } from './protocol-types.js';
|
|
4
6
|
|
|
5
7
|
import * as storage from '../storage/storage-index.js';
|
|
6
|
-
import { BucketChecksum, OpId } from './protocol-types.js';
|
|
7
|
-
import { retriedQuery } from './pgwire_utils.js';
|
|
8
|
-
import { logger } from '@powersync/lib-services-framework';
|
|
9
8
|
|
|
10
9
|
export type ChecksumMap = Map<string, BucketChecksum>;
|
|
11
10
|
|
|
11
|
+
export const ID_NAMESPACE = 'a396dd91-09fc-4017-a28d-3df722f651e9';
|
|
12
|
+
|
|
13
|
+
export function escapeIdentifier(identifier: string) {
|
|
14
|
+
return `"${identifier.replace(/"/g, '""').replace(/\./g, '"."')}"`;
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
export function hashData(type: string, id: string, data: string): number {
|
|
13
18
|
const hash = crypto.createHash('sha256');
|
|
14
19
|
hash.update(`put.${type}.${id}.${data}`);
|
|
@@ -76,47 +81,58 @@ export function addBucketChecksums(a: BucketChecksum, b: BucketChecksum | null):
|
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
function getRawReplicaIdentity(
|
|
85
|
+
tuple: sync_rules.ToastableSqliteRow,
|
|
86
|
+
columns: storage.ColumnDescriptor[]
|
|
87
|
+
): Record<string, any> {
|
|
88
|
+
let result: Record<string, any> = {};
|
|
89
|
+
for (let column of columns) {
|
|
90
|
+
const name = column.name;
|
|
91
|
+
result[name] = tuple[name];
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
85
95
|
|
|
86
|
-
|
|
96
|
+
export function getUuidReplicaIdentityBson(
|
|
97
|
+
tuple: sync_rules.ToastableSqliteRow,
|
|
98
|
+
columns: storage.ColumnDescriptor[]
|
|
99
|
+
): bson.UUID {
|
|
100
|
+
if (columns.length == 0) {
|
|
101
|
+
// REPLICA IDENTITY NOTHING - generate random id
|
|
102
|
+
return new bson.UUID(uuid.v4());
|
|
103
|
+
}
|
|
104
|
+
const rawIdentity = getRawReplicaIdentity(tuple, columns);
|
|
87
105
|
|
|
88
|
-
|
|
89
|
-
|
|
106
|
+
return uuidForRowBson(rawIdentity);
|
|
107
|
+
}
|
|
90
108
|
|
|
91
|
-
|
|
109
|
+
export function uuidForRowBson(row: sync_rules.SqliteRow): bson.UUID {
|
|
110
|
+
// Important: This must not change, since it will affect how ids are generated.
|
|
111
|
+
// Use BSON so that it's a well-defined format without encoding ambiguities.
|
|
112
|
+
const repr = bson.serialize(row);
|
|
113
|
+
const buffer = Buffer.alloc(16);
|
|
114
|
+
return new bson.UUID(uuid.v5(repr, ID_NAMESPACE, buffer));
|
|
115
|
+
}
|
|
92
116
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
throw new Error('No sync rules available');
|
|
117
|
+
export function hasToastedValues(row: sync_rules.ToastableSqliteRow) {
|
|
118
|
+
for (let key in row) {
|
|
119
|
+
if (typeof row[key] == 'undefined') {
|
|
120
|
+
return true;
|
|
98
121
|
}
|
|
99
|
-
if (cp.lsn >= lsn) {
|
|
100
|
-
logger.info(`Got write checkpoint: ${lsn} : ${cp.checkpoint}`);
|
|
101
|
-
return cp.checkpoint;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
105
122
|
}
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
106
125
|
|
|
107
|
-
|
|
126
|
+
export function isCompleteRow(row: sync_rules.ToastableSqliteRow): row is sync_rules.SqliteRow {
|
|
127
|
+
return !hasToastedValues(row);
|
|
108
128
|
}
|
|
109
129
|
|
|
110
|
-
export
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const id = await bucketStorage.createWriteCheckpoint(user_id, { '1': lsn });
|
|
120
|
-
logger.info(`Write checkpoint 2: ${JSON.stringify({ lsn, id: String(id) })}`);
|
|
121
|
-
return id;
|
|
130
|
+
export function checkpointUserId(user_id: string | undefined, client_id: string | undefined) {
|
|
131
|
+
if (user_id == null) {
|
|
132
|
+
throw new Error('user_id is required');
|
|
133
|
+
}
|
|
134
|
+
if (client_id == null) {
|
|
135
|
+
return user_id;
|
|
136
|
+
}
|
|
137
|
+
return `${user_id}/${client_id}`;
|
|
122
138
|
}
|
|
@@ -1,5 +1,90 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
+
exports[`sync - mongodb > compacting data - invalidate checkpoint 1`] = `
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
|
+
"checkpoint": {
|
|
7
|
+
"buckets": [
|
|
8
|
+
{
|
|
9
|
+
"bucket": "mybucket[]",
|
|
10
|
+
"checksum": -93886621,
|
|
11
|
+
"count": 2,
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
"last_op_id": "2",
|
|
15
|
+
"write_checkpoint": undefined,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
]
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
exports[`sync - mongodb > compacting data - invalidate checkpoint 2`] = `
|
|
22
|
+
[
|
|
23
|
+
{
|
|
24
|
+
"data": {
|
|
25
|
+
"after": "0",
|
|
26
|
+
"bucket": "mybucket[]",
|
|
27
|
+
"data": [
|
|
28
|
+
{
|
|
29
|
+
"checksum": -93886621n,
|
|
30
|
+
"op": "CLEAR",
|
|
31
|
+
"op_id": "2",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
"has_more": false,
|
|
35
|
+
"next_after": "2",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"checkpoint_diff": {
|
|
40
|
+
"last_op_id": "4",
|
|
41
|
+
"removed_buckets": [],
|
|
42
|
+
"updated_buckets": [
|
|
43
|
+
{
|
|
44
|
+
"bucket": "mybucket[]",
|
|
45
|
+
"checksum": 499012468,
|
|
46
|
+
"count": 4,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
"write_checkpoint": undefined,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"data": {
|
|
54
|
+
"after": "2",
|
|
55
|
+
"bucket": "mybucket[]",
|
|
56
|
+
"data": [
|
|
57
|
+
{
|
|
58
|
+
"checksum": 1859363232n,
|
|
59
|
+
"data": "{\\"id\\":\\"t1\\",\\"description\\":\\"Test 1b\\"}",
|
|
60
|
+
"object_id": "t1",
|
|
61
|
+
"object_type": "test",
|
|
62
|
+
"op": "PUT",
|
|
63
|
+
"op_id": "3",
|
|
64
|
+
"subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"checksum": 3028503153n,
|
|
68
|
+
"data": "{\\"id\\":\\"t2\\",\\"description\\":\\"Test 2b\\"}",
|
|
69
|
+
"object_id": "t2",
|
|
70
|
+
"object_type": "test",
|
|
71
|
+
"op": "PUT",
|
|
72
|
+
"op_id": "4",
|
|
73
|
+
"subkey": "13423353-9f27-59b4-baf0-64a5e09f1769",
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
"has_more": false,
|
|
77
|
+
"next_after": "4",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"checkpoint_complete": {
|
|
82
|
+
"last_op_id": "4",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
]
|
|
86
|
+
`;
|
|
87
|
+
|
|
3
88
|
exports[`sync - mongodb > expired token 1`] = `
|
|
4
89
|
[
|
|
5
90
|
{
|
|
@@ -66,7 +151,7 @@ exports[`sync - mongodb > sync global data 1`] = `
|
|
|
66
151
|
"object_type": "test",
|
|
67
152
|
"op": "PUT",
|
|
68
153
|
"op_id": "1",
|
|
69
|
-
"subkey": "
|
|
154
|
+
"subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
|
|
70
155
|
},
|
|
71
156
|
{
|
|
72
157
|
"checksum": 3280762209n,
|
|
@@ -75,7 +160,7 @@ exports[`sync - mongodb > sync global data 1`] = `
|
|
|
75
160
|
"object_type": "test",
|
|
76
161
|
"op": "PUT",
|
|
77
162
|
"op_id": "2",
|
|
78
|
-
"subkey": "
|
|
163
|
+
"subkey": "13423353-9f27-59b4-baf0-64a5e09f1769",
|
|
79
164
|
},
|
|
80
165
|
],
|
|
81
166
|
"has_more": false,
|
|
@@ -122,7 +207,7 @@ exports[`sync - mongodb > sync legacy non-raw data 1`] = `
|
|
|
122
207
|
"object_type": "test",
|
|
123
208
|
"op": "PUT",
|
|
124
209
|
"op_id": "1",
|
|
125
|
-
"subkey": "
|
|
210
|
+
"subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
|
|
126
211
|
},
|
|
127
212
|
],
|
|
128
213
|
"has_more": false,
|
|
@@ -188,7 +273,7 @@ exports[`sync - mongodb > sync updates to global data 2`] = `
|
|
|
188
273
|
"object_type": "test",
|
|
189
274
|
"op": "PUT",
|
|
190
275
|
"op_id": "1",
|
|
191
|
-
"subkey": "
|
|
276
|
+
"subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
|
|
192
277
|
},
|
|
193
278
|
],
|
|
194
279
|
"has_more": false,
|
|
@@ -231,7 +316,7 @@ exports[`sync - mongodb > sync updates to global data 3`] = `
|
|
|
231
316
|
"object_type": "test",
|
|
232
317
|
"op": "PUT",
|
|
233
318
|
"op_id": "2",
|
|
234
|
-
"subkey": "
|
|
319
|
+
"subkey": "13423353-9f27-59b4-baf0-64a5e09f1769",
|
|
235
320
|
},
|
|
236
321
|
],
|
|
237
322
|
"has_more": false,
|
package/test/src/auth.test.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CachedKeyCollector } from '@/auth/CachedKeyCollector.js';
|
|
2
|
+
import { KeyResult } from '@/auth/KeyCollector.js';
|
|
3
|
+
import { KeySpec } from '@/auth/KeySpec.js';
|
|
4
|
+
import { KeyStore } from '@/auth/KeyStore.js';
|
|
5
|
+
import { RemoteJWKSCollector } from '@/auth/RemoteJWKSCollector.js';
|
|
6
|
+
import { StaticKeyCollector } from '@/auth/StaticKeyCollector.js';
|
|
3
7
|
import * as jose from 'jose';
|
|
4
|
-
import {
|
|
5
|
-
import { KeySpec } from '../../src/auth/KeySpec.js';
|
|
6
|
-
import { RemoteJWKSCollector } from '../../src/auth/RemoteJWKSCollector.js';
|
|
7
|
-
import { KeyResult } from '../../src/auth/KeyCollector.js';
|
|
8
|
-
import { CachedKeyCollector } from '../../src/auth/CachedKeyCollector.js';
|
|
8
|
+
import { describe, expect, test } from 'vitest';
|
|
9
9
|
|
|
10
10
|
const publicKey: jose.JWK = {
|
|
11
11
|
use: 'sig',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BroadcastIterable, IterableSource } from '@/sync/BroadcastIterable.js';
|
|
1
2
|
import { AsyncIterableX, interval } from 'ix/asynciterable/index.js';
|
|
2
3
|
import { delayEach } from 'ix/asynciterable/operators/delayeach.js';
|
|
3
4
|
import { take } from 'ix/asynciterable/operators/take.js';
|
|
@@ -5,7 +6,6 @@ import { wrapWithAbort } from 'ix/asynciterable/operators/withabort.js';
|
|
|
5
6
|
import { toArray } from 'ix/asynciterable/toarray.js';
|
|
6
7
|
import * as timers from 'timers/promises';
|
|
7
8
|
import { describe, expect, test } from 'vitest';
|
|
8
|
-
import { BroadcastIterable, IterableSource } from '../../src/sync/BroadcastIterable.js';
|
|
9
9
|
|
|
10
10
|
describe('BroadcastIterable', () => {
|
|
11
11
|
test('should iterate', async () => {
|