@powersync/service-core 0.0.2
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/.probes/.gitkeep +0 -0
- package/CHANGELOG.md +13 -0
- package/LICENSE +67 -0
- package/README.md +3 -0
- package/dist/api/api-index.d.ts +2 -0
- package/dist/api/api-index.js +3 -0
- package/dist/api/api-index.js.map +1 -0
- package/dist/api/diagnostics.d.ts +21 -0
- package/dist/api/diagnostics.js +183 -0
- package/dist/api/diagnostics.js.map +1 -0
- package/dist/api/schema.d.ts +5 -0
- package/dist/api/schema.js +88 -0
- package/dist/api/schema.js.map +1 -0
- package/dist/auth/CachedKeyCollector.d.ts +46 -0
- package/dist/auth/CachedKeyCollector.js +116 -0
- package/dist/auth/CachedKeyCollector.js.map +1 -0
- package/dist/auth/CompoundKeyCollector.d.ts +8 -0
- package/dist/auth/CompoundKeyCollector.js +23 -0
- package/dist/auth/CompoundKeyCollector.js.map +1 -0
- package/dist/auth/JwtPayload.d.ts +10 -0
- package/dist/auth/JwtPayload.js +2 -0
- package/dist/auth/JwtPayload.js.map +1 -0
- package/dist/auth/KeyCollector.d.ts +24 -0
- package/dist/auth/KeyCollector.js +2 -0
- package/dist/auth/KeyCollector.js.map +1 -0
- package/dist/auth/KeySpec.d.ts +26 -0
- package/dist/auth/KeySpec.js +49 -0
- package/dist/auth/KeySpec.js.map +1 -0
- package/dist/auth/KeyStore.d.ts +39 -0
- package/dist/auth/KeyStore.js +131 -0
- package/dist/auth/KeyStore.js.map +1 -0
- package/dist/auth/LeakyBucket.d.ts +39 -0
- package/dist/auth/LeakyBucket.js +57 -0
- package/dist/auth/LeakyBucket.js.map +1 -0
- package/dist/auth/RemoteJWKSCollector.d.ts +24 -0
- package/dist/auth/RemoteJWKSCollector.js +106 -0
- package/dist/auth/RemoteJWKSCollector.js.map +1 -0
- package/dist/auth/StaticKeyCollector.d.ts +14 -0
- package/dist/auth/StaticKeyCollector.js +19 -0
- package/dist/auth/StaticKeyCollector.js.map +1 -0
- package/dist/auth/SupabaseKeyCollector.d.ts +22 -0
- package/dist/auth/SupabaseKeyCollector.js +61 -0
- package/dist/auth/SupabaseKeyCollector.js.map +1 -0
- package/dist/auth/auth-index.d.ts +10 -0
- package/dist/auth/auth-index.js +11 -0
- package/dist/auth/auth-index.js.map +1 -0
- package/dist/db/db-index.d.ts +1 -0
- package/dist/db/db-index.js +2 -0
- package/dist/db/db-index.js.map +1 -0
- package/dist/db/mongo.d.ts +29 -0
- package/dist/db/mongo.js +65 -0
- package/dist/db/mongo.js.map +1 -0
- package/dist/entry/cli-entry.d.ts +15 -0
- package/dist/entry/cli-entry.js +36 -0
- package/dist/entry/cli-entry.js.map +1 -0
- package/dist/entry/commands/config-command.d.ts +10 -0
- package/dist/entry/commands/config-command.js +21 -0
- package/dist/entry/commands/config-command.js.map +1 -0
- package/dist/entry/commands/migrate-action.d.ts +2 -0
- package/dist/entry/commands/migrate-action.js +18 -0
- package/dist/entry/commands/migrate-action.js.map +1 -0
- package/dist/entry/commands/start-action.d.ts +3 -0
- package/dist/entry/commands/start-action.js +15 -0
- package/dist/entry/commands/start-action.js.map +1 -0
- package/dist/entry/commands/teardown-action.d.ts +2 -0
- package/dist/entry/commands/teardown-action.js +17 -0
- package/dist/entry/commands/teardown-action.js.map +1 -0
- package/dist/entry/entry-index.d.ts +5 -0
- package/dist/entry/entry-index.js +6 -0
- package/dist/entry/entry-index.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics/metrics.d.ts +16 -0
- package/dist/metrics/metrics.js +139 -0
- package/dist/metrics/metrics.js.map +1 -0
- package/dist/migrations/db/migrations/1684951997326-init.d.ts +3 -0
- package/dist/migrations/db/migrations/1684951997326-init.js +31 -0
- package/dist/migrations/db/migrations/1684951997326-init.js.map +1 -0
- package/dist/migrations/db/migrations/1688556755264-initial-sync-rules.d.ts +2 -0
- package/dist/migrations/db/migrations/1688556755264-initial-sync-rules.js +5 -0
- package/dist/migrations/db/migrations/1688556755264-initial-sync-rules.js.map +1 -0
- package/dist/migrations/db/migrations/1702295701188-sync-rule-state.d.ts +3 -0
- package/dist/migrations/db/migrations/1702295701188-sync-rule-state.js +54 -0
- package/dist/migrations/db/migrations/1702295701188-sync-rule-state.js.map +1 -0
- package/dist/migrations/db/migrations/1711543888062-write-checkpoint-index.d.ts +3 -0
- package/dist/migrations/db/migrations/1711543888062-write-checkpoint-index.js +27 -0
- package/dist/migrations/db/migrations/1711543888062-write-checkpoint-index.js.map +1 -0
- package/dist/migrations/db/store.d.ts +3 -0
- package/dist/migrations/db/store.js +10 -0
- package/dist/migrations/db/store.js.map +1 -0
- package/dist/migrations/migrations.d.ts +10 -0
- package/dist/migrations/migrations.js +94 -0
- package/dist/migrations/migrations.js.map +1 -0
- package/dist/replication/ErrorRateLimiter.d.ts +17 -0
- package/dist/replication/ErrorRateLimiter.js +42 -0
- package/dist/replication/ErrorRateLimiter.js.map +1 -0
- package/dist/replication/PgRelation.d.ts +16 -0
- package/dist/replication/PgRelation.js +26 -0
- package/dist/replication/PgRelation.js.map +1 -0
- package/dist/replication/WalConnection.d.ts +34 -0
- package/dist/replication/WalConnection.js +190 -0
- package/dist/replication/WalConnection.js.map +1 -0
- package/dist/replication/WalStream.d.ts +58 -0
- package/dist/replication/WalStream.js +517 -0
- package/dist/replication/WalStream.js.map +1 -0
- package/dist/replication/WalStreamManager.d.ts +30 -0
- package/dist/replication/WalStreamManager.js +199 -0
- package/dist/replication/WalStreamManager.js.map +1 -0
- package/dist/replication/WalStreamRunner.d.ts +38 -0
- package/dist/replication/WalStreamRunner.js +155 -0
- package/dist/replication/WalStreamRunner.js.map +1 -0
- package/dist/replication/replication-index.d.ts +7 -0
- package/dist/replication/replication-index.js +8 -0
- package/dist/replication/replication-index.js.map +1 -0
- package/dist/replication/util.d.ts +9 -0
- package/dist/replication/util.js +62 -0
- package/dist/replication/util.js.map +1 -0
- package/dist/routes/admin.d.ts +7 -0
- package/dist/routes/admin.js +192 -0
- package/dist/routes/admin.js.map +1 -0
- package/dist/routes/auth.d.ts +58 -0
- package/dist/routes/auth.js +182 -0
- package/dist/routes/auth.js.map +1 -0
- package/dist/routes/checkpointing.d.ts +3 -0
- package/dist/routes/checkpointing.js +30 -0
- package/dist/routes/checkpointing.js.map +1 -0
- package/dist/routes/dev.d.ts +6 -0
- package/dist/routes/dev.js +163 -0
- package/dist/routes/dev.js.map +1 -0
- package/dist/routes/route-generators.d.ts +15 -0
- package/dist/routes/route-generators.js +32 -0
- package/dist/routes/route-generators.js.map +1 -0
- package/dist/routes/router-socket.d.ts +10 -0
- package/dist/routes/router-socket.js +5 -0
- package/dist/routes/router-socket.js.map +1 -0
- package/dist/routes/router.d.ts +13 -0
- package/dist/routes/router.js +2 -0
- package/dist/routes/router.js.map +1 -0
- package/dist/routes/routes-index.d.ts +4 -0
- package/dist/routes/routes-index.js +5 -0
- package/dist/routes/routes-index.js.map +1 -0
- package/dist/routes/socket-route.d.ts +2 -0
- package/dist/routes/socket-route.js +119 -0
- package/dist/routes/socket-route.js.map +1 -0
- package/dist/routes/sync-rules.d.ts +6 -0
- package/dist/routes/sync-rules.js +182 -0
- package/dist/routes/sync-rules.js.map +1 -0
- package/dist/routes/sync-stream.d.ts +5 -0
- package/dist/routes/sync-stream.js +74 -0
- package/dist/routes/sync-stream.js.map +1 -0
- package/dist/runner/teardown.d.ts +2 -0
- package/dist/runner/teardown.js +79 -0
- package/dist/runner/teardown.js.map +1 -0
- package/dist/storage/BucketStorage.d.ts +298 -0
- package/dist/storage/BucketStorage.js +25 -0
- package/dist/storage/BucketStorage.js.map +1 -0
- package/dist/storage/MongoBucketStorage.d.ts +51 -0
- package/dist/storage/MongoBucketStorage.js +388 -0
- package/dist/storage/MongoBucketStorage.js.map +1 -0
- package/dist/storage/SourceTable.d.ts +39 -0
- package/dist/storage/SourceTable.js +50 -0
- package/dist/storage/SourceTable.js.map +1 -0
- package/dist/storage/mongo/MongoBucketBatch.d.ts +48 -0
- package/dist/storage/mongo/MongoBucketBatch.js +584 -0
- package/dist/storage/mongo/MongoBucketBatch.js.map +1 -0
- package/dist/storage/mongo/MongoIdSequence.d.ts +12 -0
- package/dist/storage/mongo/MongoIdSequence.js +21 -0
- package/dist/storage/mongo/MongoIdSequence.js.map +1 -0
- package/dist/storage/mongo/MongoPersistedSyncRules.d.ts +9 -0
- package/dist/storage/mongo/MongoPersistedSyncRules.js +9 -0
- package/dist/storage/mongo/MongoPersistedSyncRules.js.map +1 -0
- package/dist/storage/mongo/MongoPersistedSyncRulesContent.d.ts +20 -0
- package/dist/storage/mongo/MongoPersistedSyncRulesContent.js +26 -0
- package/dist/storage/mongo/MongoPersistedSyncRulesContent.js.map +1 -0
- package/dist/storage/mongo/MongoSyncBucketStorage.d.ts +27 -0
- package/dist/storage/mongo/MongoSyncBucketStorage.js +379 -0
- package/dist/storage/mongo/MongoSyncBucketStorage.js.map +1 -0
- package/dist/storage/mongo/MongoSyncRulesLock.d.ts +16 -0
- package/dist/storage/mongo/MongoSyncRulesLock.js +65 -0
- package/dist/storage/mongo/MongoSyncRulesLock.js.map +1 -0
- package/dist/storage/mongo/OperationBatch.d.ts +26 -0
- package/dist/storage/mongo/OperationBatch.js +101 -0
- package/dist/storage/mongo/OperationBatch.js.map +1 -0
- package/dist/storage/mongo/PersistedBatch.d.ts +42 -0
- package/dist/storage/mongo/PersistedBatch.js +200 -0
- package/dist/storage/mongo/PersistedBatch.js.map +1 -0
- package/dist/storage/mongo/db.d.ts +23 -0
- package/dist/storage/mongo/db.js +34 -0
- package/dist/storage/mongo/db.js.map +1 -0
- package/dist/storage/mongo/models.d.ts +137 -0
- package/dist/storage/mongo/models.js +27 -0
- package/dist/storage/mongo/models.js.map +1 -0
- package/dist/storage/mongo/util.d.ts +26 -0
- package/dist/storage/mongo/util.js +81 -0
- package/dist/storage/mongo/util.js.map +1 -0
- package/dist/storage/storage-index.d.ts +14 -0
- package/dist/storage/storage-index.js +15 -0
- package/dist/storage/storage-index.js.map +1 -0
- package/dist/sync/BroadcastIterable.d.ts +38 -0
- package/dist/sync/BroadcastIterable.js +153 -0
- package/dist/sync/BroadcastIterable.js.map +1 -0
- package/dist/sync/LastValueSink.d.ts +25 -0
- package/dist/sync/LastValueSink.js +84 -0
- package/dist/sync/LastValueSink.js.map +1 -0
- package/dist/sync/merge.d.ts +39 -0
- package/dist/sync/merge.js +175 -0
- package/dist/sync/merge.js.map +1 -0
- package/dist/sync/safeRace.d.ts +1 -0
- package/dist/sync/safeRace.js +91 -0
- package/dist/sync/safeRace.js.map +1 -0
- package/dist/sync/sync-index.d.ts +6 -0
- package/dist/sync/sync-index.js +7 -0
- package/dist/sync/sync-index.js.map +1 -0
- package/dist/sync/sync.d.ts +18 -0
- package/dist/sync/sync.js +248 -0
- package/dist/sync/sync.js.map +1 -0
- package/dist/sync/util.d.ts +26 -0
- package/dist/sync/util.js +73 -0
- package/dist/sync/util.js.map +1 -0
- package/dist/system/CorePowerSyncSystem.d.ts +18 -0
- package/dist/system/CorePowerSyncSystem.js +28 -0
- package/dist/system/CorePowerSyncSystem.js.map +1 -0
- package/dist/util/Mutex.d.ts +47 -0
- package/dist/util/Mutex.js +132 -0
- package/dist/util/Mutex.js.map +1 -0
- package/dist/util/PgManager.d.ts +24 -0
- package/dist/util/PgManager.js +55 -0
- package/dist/util/PgManager.js.map +1 -0
- package/dist/util/alerting.d.ts +4 -0
- package/dist/util/alerting.js +14 -0
- package/dist/util/alerting.js.map +1 -0
- package/dist/util/config/collectors/config-collector.d.ts +29 -0
- package/dist/util/config/collectors/config-collector.js +116 -0
- package/dist/util/config/collectors/config-collector.js.map +1 -0
- package/dist/util/config/collectors/impl/base64-config-collector.d.ts +6 -0
- package/dist/util/config/collectors/impl/base64-config-collector.js +15 -0
- package/dist/util/config/collectors/impl/base64-config-collector.js.map +1 -0
- package/dist/util/config/collectors/impl/fallback-config-collector.d.ts +11 -0
- package/dist/util/config/collectors/impl/fallback-config-collector.js +19 -0
- package/dist/util/config/collectors/impl/fallback-config-collector.js.map +1 -0
- package/dist/util/config/collectors/impl/filesystem-config-collector.d.ts +6 -0
- package/dist/util/config/collectors/impl/filesystem-config-collector.js +35 -0
- package/dist/util/config/collectors/impl/filesystem-config-collector.js.map +1 -0
- package/dist/util/config/compound-config-collector.d.ts +32 -0
- package/dist/util/config/compound-config-collector.js +126 -0
- package/dist/util/config/compound-config-collector.js.map +1 -0
- package/dist/util/config/sync-rules/impl/base64-sync-rules-collector.d.ts +7 -0
- package/dist/util/config/sync-rules/impl/base64-sync-rules-collector.js +17 -0
- package/dist/util/config/sync-rules/impl/base64-sync-rules-collector.js.map +1 -0
- package/dist/util/config/sync-rules/impl/filesystem-sync-rules-collector.d.ts +7 -0
- package/dist/util/config/sync-rules/impl/filesystem-sync-rules-collector.js +21 -0
- package/dist/util/config/sync-rules/impl/filesystem-sync-rules-collector.js.map +1 -0
- package/dist/util/config/sync-rules/impl/inline-sync-rules-collector.d.ts +7 -0
- package/dist/util/config/sync-rules/impl/inline-sync-rules-collector.js +17 -0
- package/dist/util/config/sync-rules/impl/inline-sync-rules-collector.js.map +1 -0
- package/dist/util/config/sync-rules/sync-collector.d.ts +6 -0
- package/dist/util/config/sync-rules/sync-collector.js +3 -0
- package/dist/util/config/sync-rules/sync-collector.js.map +1 -0
- package/dist/util/config/types.d.ts +53 -0
- package/dist/util/config/types.js +7 -0
- package/dist/util/config/types.js.map +1 -0
- package/dist/util/config.d.ts +7 -0
- package/dist/util/config.js +35 -0
- package/dist/util/config.js.map +1 -0
- package/dist/util/env.d.ts +10 -0
- package/dist/util/env.js +25 -0
- package/dist/util/env.js.map +1 -0
- package/dist/util/memory-tracking.d.ts +7 -0
- package/dist/util/memory-tracking.js +58 -0
- package/dist/util/memory-tracking.js.map +1 -0
- package/dist/util/migration_lib.d.ts +11 -0
- package/dist/util/migration_lib.js +64 -0
- package/dist/util/migration_lib.js.map +1 -0
- package/dist/util/pgwire_utils.d.ts +24 -0
- package/dist/util/pgwire_utils.js +117 -0
- package/dist/util/pgwire_utils.js.map +1 -0
- package/dist/util/populate_test_data.d.ts +8 -0
- package/dist/util/populate_test_data.js +65 -0
- package/dist/util/populate_test_data.js.map +1 -0
- package/dist/util/protocol-types.d.ts +178 -0
- package/dist/util/protocol-types.js +38 -0
- package/dist/util/protocol-types.js.map +1 -0
- package/dist/util/secs.d.ts +2 -0
- package/dist/util/secs.js +49 -0
- package/dist/util/secs.js.map +1 -0
- package/dist/util/util-index.d.ts +22 -0
- package/dist/util/util-index.js +23 -0
- package/dist/util/util-index.js.map +1 -0
- package/dist/util/utils.d.ts +14 -0
- package/dist/util/utils.js +75 -0
- package/dist/util/utils.js.map +1 -0
- package/package.json +55 -0
- package/src/api/api-index.ts +2 -0
- package/src/api/diagnostics.ts +221 -0
- package/src/api/schema.ts +99 -0
- package/src/auth/CachedKeyCollector.ts +132 -0
- package/src/auth/CompoundKeyCollector.ts +33 -0
- package/src/auth/JwtPayload.ts +11 -0
- package/src/auth/KeyCollector.ts +27 -0
- package/src/auth/KeySpec.ts +67 -0
- package/src/auth/KeyStore.ts +156 -0
- package/src/auth/LeakyBucket.ts +66 -0
- package/src/auth/RemoteJWKSCollector.ts +130 -0
- package/src/auth/StaticKeyCollector.ts +21 -0
- package/src/auth/SupabaseKeyCollector.ts +67 -0
- package/src/auth/auth-index.ts +10 -0
- package/src/db/db-index.ts +1 -0
- package/src/db/mongo.ts +72 -0
- package/src/entry/cli-entry.ts +41 -0
- package/src/entry/commands/config-command.ts +36 -0
- package/src/entry/commands/migrate-action.ts +25 -0
- package/src/entry/commands/start-action.ts +24 -0
- package/src/entry/commands/teardown-action.ts +23 -0
- package/src/entry/entry-index.ts +5 -0
- package/src/index.ts +37 -0
- package/src/metrics/metrics.ts +169 -0
- package/src/migrations/db/migrations/1684951997326-init.ts +33 -0
- package/src/migrations/db/migrations/1688556755264-initial-sync-rules.ts +5 -0
- package/src/migrations/db/migrations/1702295701188-sync-rule-state.ts +99 -0
- package/src/migrations/db/migrations/1711543888062-write-checkpoint-index.ts +32 -0
- package/src/migrations/db/store.ts +11 -0
- package/src/migrations/migrations.ts +122 -0
- package/src/replication/ErrorRateLimiter.ts +49 -0
- package/src/replication/PgRelation.ts +42 -0
- package/src/replication/WalConnection.ts +227 -0
- package/src/replication/WalStream.ts +626 -0
- package/src/replication/WalStreamManager.ts +214 -0
- package/src/replication/WalStreamRunner.ts +180 -0
- package/src/replication/replication-index.ts +7 -0
- package/src/replication/util.ts +76 -0
- package/src/routes/admin.ts +229 -0
- package/src/routes/auth.ts +209 -0
- package/src/routes/checkpointing.ts +38 -0
- package/src/routes/dev.ts +194 -0
- package/src/routes/route-generators.ts +39 -0
- package/src/routes/router-socket.ts +13 -0
- package/src/routes/router.ts +17 -0
- package/src/routes/routes-index.ts +5 -0
- package/src/routes/socket-route.ts +131 -0
- package/src/routes/sync-rules.ts +210 -0
- package/src/routes/sync-stream.ts +92 -0
- package/src/runner/teardown.ts +91 -0
- package/src/storage/BucketStorage.ts +386 -0
- package/src/storage/MongoBucketStorage.ts +493 -0
- package/src/storage/SourceTable.ts +60 -0
- package/src/storage/mongo/MongoBucketBatch.ts +756 -0
- package/src/storage/mongo/MongoIdSequence.ts +24 -0
- package/src/storage/mongo/MongoPersistedSyncRules.ts +16 -0
- package/src/storage/mongo/MongoPersistedSyncRulesContent.ts +47 -0
- package/src/storage/mongo/MongoSyncBucketStorage.ts +517 -0
- package/src/storage/mongo/MongoSyncRulesLock.ts +81 -0
- package/src/storage/mongo/OperationBatch.ts +115 -0
- package/src/storage/mongo/PersistedBatch.ts +245 -0
- package/src/storage/mongo/db.ts +69 -0
- package/src/storage/mongo/models.ts +157 -0
- package/src/storage/mongo/util.ts +88 -0
- package/src/storage/storage-index.ts +15 -0
- package/src/sync/BroadcastIterable.ts +161 -0
- package/src/sync/LastValueSink.ts +100 -0
- package/src/sync/merge.ts +200 -0
- package/src/sync/safeRace.ts +99 -0
- package/src/sync/sync-index.ts +6 -0
- package/src/sync/sync.ts +312 -0
- package/src/sync/util.ts +98 -0
- package/src/system/CorePowerSyncSystem.ts +43 -0
- package/src/util/Mutex.ts +159 -0
- package/src/util/PgManager.ts +64 -0
- package/src/util/alerting.ts +17 -0
- package/src/util/config/collectors/config-collector.ts +141 -0
- package/src/util/config/collectors/impl/base64-config-collector.ts +18 -0
- package/src/util/config/collectors/impl/fallback-config-collector.ts +22 -0
- package/src/util/config/collectors/impl/filesystem-config-collector.ts +41 -0
- package/src/util/config/compound-config-collector.ts +171 -0
- package/src/util/config/sync-rules/impl/base64-sync-rules-collector.ts +21 -0
- package/src/util/config/sync-rules/impl/filesystem-sync-rules-collector.ts +26 -0
- package/src/util/config/sync-rules/impl/inline-sync-rules-collector.ts +21 -0
- package/src/util/config/sync-rules/sync-collector.ts +8 -0
- package/src/util/config/types.ts +60 -0
- package/src/util/config.ts +39 -0
- package/src/util/env.ts +28 -0
- package/src/util/memory-tracking.ts +67 -0
- package/src/util/migration_lib.ts +79 -0
- package/src/util/pgwire_utils.ts +139 -0
- package/src/util/populate_test_data.ts +78 -0
- package/src/util/protocol-types.ts +223 -0
- package/src/util/secs.ts +54 -0
- package/src/util/util-index.ts +25 -0
- package/src/util/utils.ts +102 -0
- package/test/src/__snapshots__/pg_test.test.ts.snap +256 -0
- package/test/src/__snapshots__/sync.test.ts.snap +235 -0
- package/test/src/auth.test.ts +340 -0
- package/test/src/broadcast_iterable.test.ts +156 -0
- package/test/src/data_storage.test.ts +1176 -0
- package/test/src/env.ts +8 -0
- package/test/src/large_batch.test.ts +194 -0
- package/test/src/merge_iterable.test.ts +355 -0
- package/test/src/pg_test.test.ts +432 -0
- package/test/src/schema_changes.test.ts +545 -0
- package/test/src/slow_tests.test.ts +257 -0
- package/test/src/sql_functions.test.ts +254 -0
- package/test/src/sql_operators.test.ts +132 -0
- package/test/src/sync.test.ts +293 -0
- package/test/src/sync_rules.test.ts +1051 -0
- package/test/src/util.ts +67 -0
- package/test/src/validation.test.ts +63 -0
- package/test/src/wal_stream.test.ts +310 -0
- package/test/src/wal_stream_utils.ts +147 -0
- package/test/tsconfig.json +20 -0
- package/tsconfig.json +20 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vitest.config.ts +11 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SupabaseKeyCollector.js","sourceRoot":"","sources":["../../src/auth/SupabaseKeyCollector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE3E,OAAO,EAAc,OAAO,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD;;;;;GAKG;AACH,MAAM,OAAO,oBAAoB;IAQ/B,YAAY,UAA8B;QALlC,eAAU,GAAe;YAC/B,gBAAgB,EAAE,CAAC,eAAe,CAAC;YACnC,kBAAkB,EAAE,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,6BAA6B;SACnE,CAAC;QAGA,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC,UAAU,EAAE;YACxC,kEAAkE;YAClE,iEAAiE;YACjE,kBAAkB;YAClB,WAAW,EAAE,IAAK;YAClB,OAAO,EAAE,CAAC;SACX,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,GAA2B,CAAC;QAChC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,UAAU,CACrB,MAAM,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,iEAAiE,CAAC,CACjG,CAAC;YACF,GAAG,GAAG,IAAI,CAAC,CAAC,CAAQ,CAAC;QACvB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,sCAAsC,CAAC,EAAE,CAAC;gBAChE,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,iDAAiD,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAChG,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,CAAC;YACV,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,GAAG,EAAE,UAAgC,CAAC;QACrD,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,OAAO;gBACL,IAAI,EAAE,EAAE;gBACR,MAAM,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;aAC9C,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,GAAa;gBACpB,GAAG,EAAE,KAAK;gBACV,GAAG,EAAE,OAAO;gBACZ,iFAAiF;gBACjF,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;aACrD,CAAC;YACF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YAC/D,OAAO;gBACL,IAAI,EAAE,CAAC,QAAQ,CAAC;gBAChB,MAAM,EAAE,EAAE;aACX,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './CachedKeyCollector.js';
|
|
2
|
+
export * from './CompoundKeyCollector.js';
|
|
3
|
+
export * from './JwtPayload.js';
|
|
4
|
+
export * from './KeyCollector.js';
|
|
5
|
+
export * from './KeySpec.js';
|
|
6
|
+
export * from './KeyStore.js';
|
|
7
|
+
export * from './LeakyBucket.js';
|
|
8
|
+
export * from './RemoteJWKSCollector.js';
|
|
9
|
+
export * from './StaticKeyCollector.js';
|
|
10
|
+
export * from './SupabaseKeyCollector.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './CachedKeyCollector.js';
|
|
2
|
+
export * from './CompoundKeyCollector.js';
|
|
3
|
+
export * from './JwtPayload.js';
|
|
4
|
+
export * from './KeyCollector.js';
|
|
5
|
+
export * from './KeySpec.js';
|
|
6
|
+
export * from './KeyStore.js';
|
|
7
|
+
export * from './LeakyBucket.js';
|
|
8
|
+
export * from './RemoteJWKSCollector.js';
|
|
9
|
+
export * from './StaticKeyCollector.js';
|
|
10
|
+
export * from './SupabaseKeyCollector.js';
|
|
11
|
+
//# sourceMappingURL=auth-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-index.js","sourceRoot":"","sources":["../../src/auth/auth-index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as mongo from './mongo.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-index.js","sourceRoot":"","sources":["../../src/db/db-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as mongo from 'mongodb';
|
|
2
|
+
import { configFile } from '@powersync/service-types';
|
|
3
|
+
/**
|
|
4
|
+
* Time for new connection to timeout.
|
|
5
|
+
*/
|
|
6
|
+
export declare const MONGO_CONNECT_TIMEOUT_MS = 10000;
|
|
7
|
+
/**
|
|
8
|
+
* Time for individual requests to timeout the socket.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MONGO_SOCKET_TIMEOUT_MS = 60000;
|
|
11
|
+
/**
|
|
12
|
+
* Time for individual requests to timeout the operation.
|
|
13
|
+
*
|
|
14
|
+
* This is time spent on the cursor, not total time.
|
|
15
|
+
*
|
|
16
|
+
* Must be less than MONGO_SOCKET_TIMEOUT_MS to ensure proper error handling.
|
|
17
|
+
*/
|
|
18
|
+
export declare const MONGO_OPERATION_TIMEOUT_MS = 30000;
|
|
19
|
+
export declare function createMongoClient(config: configFile.PowerSyncConfig['storage']): mongo.MongoClient;
|
|
20
|
+
/**
|
|
21
|
+
* Wait up to a minute for authentication errors to resolve.
|
|
22
|
+
*
|
|
23
|
+
* There can be a delay between an Atlas user being created, and that user being
|
|
24
|
+
* available on the database cluster. This works around it.
|
|
25
|
+
*
|
|
26
|
+
* This is specifically relevant for migrations and teardown - other parts of the stack
|
|
27
|
+
* can generate handle these failures and just retry or restart.
|
|
28
|
+
*/
|
|
29
|
+
export declare function waitForAuth(db: mongo.Db): Promise<void>;
|
package/dist/db/mongo.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as mongo from 'mongodb';
|
|
2
|
+
import * as timers from 'timers/promises';
|
|
3
|
+
/**
|
|
4
|
+
* Time for new connection to timeout.
|
|
5
|
+
*/
|
|
6
|
+
export const MONGO_CONNECT_TIMEOUT_MS = 10000;
|
|
7
|
+
/**
|
|
8
|
+
* Time for individual requests to timeout the socket.
|
|
9
|
+
*/
|
|
10
|
+
export const MONGO_SOCKET_TIMEOUT_MS = 60000;
|
|
11
|
+
/**
|
|
12
|
+
* Time for individual requests to timeout the operation.
|
|
13
|
+
*
|
|
14
|
+
* This is time spent on the cursor, not total time.
|
|
15
|
+
*
|
|
16
|
+
* Must be less than MONGO_SOCKET_TIMEOUT_MS to ensure proper error handling.
|
|
17
|
+
*/
|
|
18
|
+
export const MONGO_OPERATION_TIMEOUT_MS = 30000;
|
|
19
|
+
export function createMongoClient(config) {
|
|
20
|
+
return new mongo.MongoClient(config.uri, {
|
|
21
|
+
auth: {
|
|
22
|
+
username: config.username,
|
|
23
|
+
password: config.password
|
|
24
|
+
},
|
|
25
|
+
// Time for connection to timeout
|
|
26
|
+
connectTimeoutMS: MONGO_CONNECT_TIMEOUT_MS,
|
|
27
|
+
// Time for individual requests to timeout
|
|
28
|
+
socketTimeoutMS: MONGO_SOCKET_TIMEOUT_MS,
|
|
29
|
+
// How long to wait for new primary selection
|
|
30
|
+
serverSelectionTimeoutMS: 30000,
|
|
31
|
+
// Avoid too many connections:
|
|
32
|
+
// 1. It can overwhelm the source database.
|
|
33
|
+
// 2. Processing too many queries in parallel can cause the process to run out of memory.
|
|
34
|
+
maxPoolSize: 8,
|
|
35
|
+
maxConnecting: 3,
|
|
36
|
+
maxIdleTimeMS: 60000
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Wait up to a minute for authentication errors to resolve.
|
|
41
|
+
*
|
|
42
|
+
* There can be a delay between an Atlas user being created, and that user being
|
|
43
|
+
* available on the database cluster. This works around it.
|
|
44
|
+
*
|
|
45
|
+
* This is specifically relevant for migrations and teardown - other parts of the stack
|
|
46
|
+
* can generate handle these failures and just retry or restart.
|
|
47
|
+
*/
|
|
48
|
+
export async function waitForAuth(db) {
|
|
49
|
+
const start = Date.now();
|
|
50
|
+
while (Date.now() - start < 60000) {
|
|
51
|
+
try {
|
|
52
|
+
await db.command({ ping: 1 });
|
|
53
|
+
// Success
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
if (e.codeName == 'AuthenticationFailed') {
|
|
58
|
+
await timers.setTimeout(1000);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
throw e;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=mongo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongo.js","sourceRoot":"","sources":["../../src/db/mongo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAI1C;;GAEG;AACH,MAAM,CAAC,MAAM,w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{ Command } from 'commander';
|
|
2
|
+
import * as utils from '../util/util-index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Generates a Commander program which serves as the entry point
|
|
5
|
+
* for the PowerSync service.
|
|
6
|
+
* This registers standard actions for teardown and migrations.
|
|
7
|
+
* Optionally registers the start command handlers.
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateEntryProgram(startHandlers?: Record<utils.ServiceRunner, utils.Runner>): {
|
|
10
|
+
program: Command;
|
|
11
|
+
/**
|
|
12
|
+
* Executes the main program. Ends the NodeJS process if an exception was caught.
|
|
13
|
+
*/
|
|
14
|
+
execute: () => Promise<void>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import * as micro from '@journeyapps-platform/micro';
|
|
3
|
+
import { registerMigrationAction } from './commands/migrate-action.js';
|
|
4
|
+
import { registerTearDownAction } from './commands/teardown-action.js';
|
|
5
|
+
import { registerStartAction } from './entry-index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Generates a Commander program which serves as the entry point
|
|
8
|
+
* for the PowerSync service.
|
|
9
|
+
* This registers standard actions for teardown and migrations.
|
|
10
|
+
* Optionally registers the start command handlers.
|
|
11
|
+
*/
|
|
12
|
+
export function generateEntryProgram(startHandlers) {
|
|
13
|
+
const entryProgram = new Command();
|
|
14
|
+
entryProgram.name('powersync-runner').description('CLI to initiate a PowerSync service runner');
|
|
15
|
+
registerTearDownAction(entryProgram);
|
|
16
|
+
registerMigrationAction(entryProgram);
|
|
17
|
+
if (startHandlers) {
|
|
18
|
+
registerStartAction(entryProgram, startHandlers);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
program: entryProgram,
|
|
22
|
+
/**
|
|
23
|
+
* Executes the main program. Ends the NodeJS process if an exception was caught.
|
|
24
|
+
*/
|
|
25
|
+
execute: async function runProgram() {
|
|
26
|
+
try {
|
|
27
|
+
await entryProgram.parseAsync();
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
micro.logger.error('Fatal error', e);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=cli-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-entry.js","sourceRoot":"","sources":["../../src/entry/cli-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,KAAK,KAAK,MAAM,6BAA6B,CAAC;AAGrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,aAAyD;IAC5F,MAAM,YAAY,GAAG,IAAI,OAAO,EAAE,CAAC;IACnC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,WAAW,CAAC,4CAA4C,CAAC,CAAC;IAEhG,sBAAsB,CAAC,YAAY,CAAC,CAAC;IACrC,uBAAuB,CAAC,YAAY,CAAC,CAAC;IAEtC,IAAI,aAAa,EAAE,CAAC;QAClB,mBAAmB,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;IACnD,CAAC;IAED,OAAO;QACL,OAAO,EAAE,YAAY;QACrB;;WAEG;QACH,OAAO,EAAE,KAAK,UAAU,UAAU;YAChC,IAAI,CAAC;gBACH,MAAM,YAAY,CAAC,UAAU,EAAE,CAAC;YAClC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;gBACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import * as util from '../../util/util-index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a Command with the standard config options
|
|
5
|
+
*/
|
|
6
|
+
export declare function wrapConfigCommand(command: Command): Command;
|
|
7
|
+
/**
|
|
8
|
+
* Extracts runner configuration params from Command options.
|
|
9
|
+
*/
|
|
10
|
+
export declare function extractRunnerOptions(options: any): util.RunnerConfig;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as util from '../../util/util-index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a Command with the standard config options
|
|
4
|
+
*/
|
|
5
|
+
export function wrapConfigCommand(command) {
|
|
6
|
+
return command
|
|
7
|
+
.option(`-c, --config-path [path]`, 'Path (inside container) to YAML config file. Defaults to process.env.POWERSYNC_CONFIG_PATH', util.env.POWERSYNC_CONFIG_PATH)
|
|
8
|
+
.option(`-c64, --config-base64 [base64]`, 'Base64 encoded YAML or JSON config file. Defaults to process.env.POWERSYNC_CONFIG_B64', util.env.POWERSYNC_CONFIG_B64)
|
|
9
|
+
.option(`-sync64, --sync-base64 [base64]`, 'Base64 encoded YAML Sync Rules. Defaults to process.env.POWERSYNC_SYNC_RULES_B64', util.env.POWERSYNC_SYNC_RULES_B64);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Extracts runner configuration params from Command options.
|
|
13
|
+
*/
|
|
14
|
+
export function extractRunnerOptions(options) {
|
|
15
|
+
return {
|
|
16
|
+
config_path: options.configPath,
|
|
17
|
+
config_base64: options.configBase64,
|
|
18
|
+
sync_rules_base64: options.syncBase64
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=config-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-command.js","sourceRoot":"","sources":["../../../src/entry/commands/config-command.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,OAAO,OAAO;SACX,MAAM,CACL,0BAA0B,EAC1B,4FAA4F,EAC5F,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAC/B;SACA,MAAM,CACL,gCAAgC,EAChC,uFAAuF,EACvF,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAC9B;SACA,MAAM,CACL,iCAAiC,EACjC,kFAAkF,EAClF,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAClC,CAAC;AACN,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAY;IAC/C,OAAO;QACL,WAAW,EAAE,OAAO,CAAC,UAAU;QAC/B,aAAa,EAAE,OAAO,CAAC,YAAY;QACnC,iBAAiB,EAAE,OAAO,CAAC,UAAU;KACtC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { extractRunnerOptions, wrapConfigCommand } from './config-command.js';
|
|
2
|
+
import { migrate } from '../../migrations/migrations.js';
|
|
3
|
+
const COMMAND_NAME = 'migrate';
|
|
4
|
+
export function registerMigrationAction(program) {
|
|
5
|
+
const migrationCommand = program.command(COMMAND_NAME);
|
|
6
|
+
wrapConfigCommand(migrationCommand);
|
|
7
|
+
return migrationCommand
|
|
8
|
+
.description('Run migrations')
|
|
9
|
+
.argument('<direction>', 'Migration direction. `up` or `down`')
|
|
10
|
+
.action(async (direction, options) => {
|
|
11
|
+
const runnerConfig = extractRunnerOptions(options);
|
|
12
|
+
await migrate({
|
|
13
|
+
direction,
|
|
14
|
+
runner_config: runnerConfig
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=migrate-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-action.js","sourceRoot":"","sources":["../../../src/entry/commands/migrate-action.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,MAAM,YAAY,GAAG,SAAS,CAAC;AAE/B,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAEvD,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAEpC,OAAO,gBAAgB;SACpB,WAAW,CAAC,gBAAgB,CAAC;SAC7B,QAAQ,CAAC,aAAa,EAAE,qCAAqC,CAAC;SAC9D,MAAM,CAAC,KAAK,EAAE,SAAoB,EAAE,OAAO,EAAE,EAAE;QAC9C,MAAM,YAAY,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAEnD,MAAM,OAAO,CAAC;YACZ,SAAS;YACT,aAAa,EAAE,YAAY;SAC5B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as utils from '../../util/util-index.js';
|
|
2
|
+
import { extractRunnerOptions, wrapConfigCommand } from './config-command.js';
|
|
3
|
+
const COMMAND_NAME = 'start';
|
|
4
|
+
export function registerStartAction(program, handlers) {
|
|
5
|
+
const startCommand = program.command(COMMAND_NAME);
|
|
6
|
+
wrapConfigCommand(startCommand);
|
|
7
|
+
return startCommand
|
|
8
|
+
.description('Starts a PowerSync service runner.')
|
|
9
|
+
.option(`-r, --runner-type [${Object.values(utils.ServiceRunner).join('|')}]`, 'Type of runner to start. Defaults to unified runner.', utils.env.PS_RUNNER_TYPE)
|
|
10
|
+
.action(async (options) => {
|
|
11
|
+
const runner = handlers[options.runnerType];
|
|
12
|
+
await runner(extractRunnerOptions(options));
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=start-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-action.js","sourceRoot":"","sources":["../../../src/entry/commands/start-action.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,MAAM,YAAY,GAAG,OAAO,CAAC;AAE7B,MAAM,UAAU,mBAAmB,CAAC,OAAgB,EAAE,QAAmD;IACvG,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAEnD,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAEhC,OAAO,YAAY;SAChB,WAAW,CAAC,oCAAoC,CAAC;SACjD,MAAM,CACL,sBAAsB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EACrE,sDAAsD,EACtD,KAAK,CAAC,GAAG,CAAC,cAAc,CACzB;SACA,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACxB,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAiC,CAAC,CAAC;QACnE,MAAM,MAAM,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { extractRunnerOptions, wrapConfigCommand } from './config-command.js';
|
|
2
|
+
import { teardown } from '../../runner/teardown.js';
|
|
3
|
+
const COMMAND_NAME = 'teardown';
|
|
4
|
+
export function registerTearDownAction(program) {
|
|
5
|
+
const teardownCommand = program.command(COMMAND_NAME);
|
|
6
|
+
wrapConfigCommand(teardownCommand);
|
|
7
|
+
return teardownCommand
|
|
8
|
+
.argument('[ack]', 'Type `TEARDOWN` to confirm teardown should occur')
|
|
9
|
+
.description('Terminate all replicating sync rules, deleting the replication slots')
|
|
10
|
+
.action(async (ack, options) => {
|
|
11
|
+
if (ack !== 'TEARDOWN') {
|
|
12
|
+
throw new Error('TEARDOWN was not acknowledged.');
|
|
13
|
+
}
|
|
14
|
+
await teardown(extractRunnerOptions(options));
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=teardown-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teardown-action.js","sourceRoot":"","sources":["../../../src/entry/commands/teardown-action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,MAAM,YAAY,GAAG,UAAU,CAAC;AAEhC,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAEtD,iBAAiB,CAAC,eAAe,CAAC,CAAC;IAEnC,OAAO,eAAe;SACnB,QAAQ,CAAC,OAAO,EAAE,kDAAkD,CAAC;SACrE,WAAW,CAAC,sEAAsE,CAAC;SACnF,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;QAC7B,IAAI,GAAG,KAAK,UAAU,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;QAED,MAAM,QAAQ,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-index.js","sourceRoot":"","sources":["../../src/entry/entry-index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from './api/api-index.js';
|
|
2
|
+
export * as api from './api/api-index.js';
|
|
3
|
+
export * from './auth/auth-index.js';
|
|
4
|
+
export * as auth from './auth/auth-index.js';
|
|
5
|
+
export * from './db/db-index.js';
|
|
6
|
+
export * as db from './db/db-index.js';
|
|
7
|
+
export * from './entry/entry-index.js';
|
|
8
|
+
export * as entry from './entry/entry-index.js';
|
|
9
|
+
export * from './metrics/metrics.js';
|
|
10
|
+
export * as metrics from './metrics/metrics.js';
|
|
11
|
+
export * from './migrations/migrations.js';
|
|
12
|
+
export * as migrations from './migrations/migrations.js';
|
|
13
|
+
export * from './replication/replication-index.js';
|
|
14
|
+
export * as replication from './replication/replication-index.js';
|
|
15
|
+
export * from './routes/routes-index.js';
|
|
16
|
+
export * as routes from './routes/routes-index.js';
|
|
17
|
+
export * from './storage/storage-index.js';
|
|
18
|
+
export * as storage from './storage/storage-index.js';
|
|
19
|
+
export * from './sync/sync-index.js';
|
|
20
|
+
export * as sync from './sync/sync-index.js';
|
|
21
|
+
export * from './system/CorePowerSyncSystem.js';
|
|
22
|
+
export * as system from './system/CorePowerSyncSystem.js';
|
|
23
|
+
export * from './util/util-index.js';
|
|
24
|
+
export * as utils from './util/util-index.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Provides global and namespaced exports
|
|
2
|
+
export * from './api/api-index.js';
|
|
3
|
+
export * as api from './api/api-index.js';
|
|
4
|
+
export * from './auth/auth-index.js';
|
|
5
|
+
export * as auth from './auth/auth-index.js';
|
|
6
|
+
export * from './db/db-index.js';
|
|
7
|
+
export * as db from './db/db-index.js';
|
|
8
|
+
export * from './entry/entry-index.js';
|
|
9
|
+
export * as entry from './entry/entry-index.js';
|
|
10
|
+
export * from './metrics/metrics.js';
|
|
11
|
+
export * as metrics from './metrics/metrics.js';
|
|
12
|
+
export * from './migrations/migrations.js';
|
|
13
|
+
export * as migrations from './migrations/migrations.js';
|
|
14
|
+
export * from './replication/replication-index.js';
|
|
15
|
+
export * as replication from './replication/replication-index.js';
|
|
16
|
+
export * from './routes/routes-index.js';
|
|
17
|
+
export * as routes from './routes/routes-index.js';
|
|
18
|
+
export * from './storage/storage-index.js';
|
|
19
|
+
export * as storage from './storage/storage-index.js';
|
|
20
|
+
export * from './sync/sync-index.js';
|
|
21
|
+
export * as sync from './sync/sync-index.js';
|
|
22
|
+
export * from './system/CorePowerSyncSystem.js';
|
|
23
|
+
export * as system from './system/CorePowerSyncSystem.js';
|
|
24
|
+
export * from './util/util-index.js';
|
|
25
|
+
export * as utils from './util/util-index.js';
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,cAAc,oBAAoB,CAAC;AACnC,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAE1C,cAAc,sBAAsB,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAE7C,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEvC,cAAc,wBAAwB,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAC;AAEhD,cAAc,sBAAsB,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAEhD,cAAc,4BAA4B,CAAC;AAC3C,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAEzD,cAAc,oCAAoC,CAAC;AACnD,OAAO,KAAK,WAAW,MAAM,oCAAoC,CAAC;AAElE,cAAc,0BAA0B,CAAC;AACzC,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAC;AAEnD,cAAc,4BAA4B,CAAC;AAC3C,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AAEtD,cAAc,sBAAsB,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAE7C,cAAc,iCAAiC,CAAC;AAChD,OAAO,KAAK,MAAM,MAAM,iCAAiC,CAAC;AAE1D,cAAc,sBAAsB,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
|
|
2
|
+
import { CorePowerSyncSystem } from '../system/CorePowerSyncSystem.js';
|
|
3
|
+
export declare const exporter: PrometheusExporter;
|
|
4
|
+
export declare const data_replicated_bytes: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
5
|
+
export declare const data_synced_bytes: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
6
|
+
export declare const rows_replicated_total: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
7
|
+
export declare const transactions_replicated_total: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
8
|
+
export declare const chunks_replicated_total: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
9
|
+
export declare const operations_synced_total: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
10
|
+
export declare const replication_storage_size_bytes: import("@opentelemetry/api").ObservableGauge<import("@opentelemetry/api").Attributes>;
|
|
11
|
+
export declare const operation_storage_size_bytes: import("@opentelemetry/api").ObservableGauge<import("@opentelemetry/api").Attributes>;
|
|
12
|
+
export declare const parameter_storage_size_bytes: import("@opentelemetry/api").ObservableGauge<import("@opentelemetry/api").Attributes>;
|
|
13
|
+
export declare const concurrent_connections: import("@opentelemetry/api").UpDownCounter<import("@opentelemetry/api").Attributes>;
|
|
14
|
+
export declare function configureApiMetrics(): void;
|
|
15
|
+
export declare function configureReplicationMetrics(system: CorePowerSyncSystem): void;
|
|
16
|
+
export declare function getMetricValueForTests(name: string): Promise<number | undefined>;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import * as micro from '@journeyapps-platform/micro';
|
|
2
|
+
import { ValueType } from '@opentelemetry/api';
|
|
3
|
+
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
|
|
4
|
+
import { MeterProvider } from '@opentelemetry/sdk-metrics';
|
|
5
|
+
import * as jpgwire from '@powersync/service-jpgwire';
|
|
6
|
+
import * as util from '../util/util-index.js';
|
|
7
|
+
const meterProvider = new MeterProvider();
|
|
8
|
+
const port = util.env.METRICS_PORT ?? 0;
|
|
9
|
+
// Expose a pull-based metrics exporter on a prometheus endpoint.
|
|
10
|
+
// This is not quite the standard approach of opentelemetry or journey-micro.
|
|
11
|
+
// However, it avoids the need for running a separate sidecar that uses additional resources.
|
|
12
|
+
// We can consider switching to the standard push-based architecture if needed later.
|
|
13
|
+
export const exporter = new PrometheusExporter({ port: port, preventServerStart: true });
|
|
14
|
+
meterProvider.addMetricReader(exporter);
|
|
15
|
+
if (port > 0) {
|
|
16
|
+
exporter.startServer();
|
|
17
|
+
}
|
|
18
|
+
const meter = meterProvider.getMeter('powersync');
|
|
19
|
+
// 1. Data processing / month
|
|
20
|
+
// 1a. Postgres -> PowerSync
|
|
21
|
+
// Record on replication pod
|
|
22
|
+
export const data_replicated_bytes = meter.createCounter('powersync_data_replicated_bytes_total', {
|
|
23
|
+
description: 'Uncompressed size of replicated data',
|
|
24
|
+
unit: 'bytes',
|
|
25
|
+
valueType: ValueType.INT
|
|
26
|
+
});
|
|
27
|
+
// 1b. PowerSync -> clients
|
|
28
|
+
// Record on API pod
|
|
29
|
+
export const data_synced_bytes = meter.createCounter('powersync_data_synced_bytes_total', {
|
|
30
|
+
description: 'Uncompressed size of synced data',
|
|
31
|
+
unit: 'bytes',
|
|
32
|
+
valueType: ValueType.INT
|
|
33
|
+
});
|
|
34
|
+
// Unused for pricing
|
|
35
|
+
// Record on replication pod
|
|
36
|
+
export const rows_replicated_total = meter.createCounter('powersync_rows_replicated_total', {
|
|
37
|
+
description: 'Total number of replicated rows',
|
|
38
|
+
valueType: ValueType.INT
|
|
39
|
+
});
|
|
40
|
+
// Unused for pricing
|
|
41
|
+
// Record on replication pod
|
|
42
|
+
export const transactions_replicated_total = meter.createCounter('powersync_transactions_replicated_total', {
|
|
43
|
+
description: 'Total number of replicated transactions',
|
|
44
|
+
valueType: ValueType.INT
|
|
45
|
+
});
|
|
46
|
+
// Unused for pricing
|
|
47
|
+
// Record on replication pod
|
|
48
|
+
export const chunks_replicated_total = meter.createCounter('powersync_chunks_replicated_total', {
|
|
49
|
+
description: 'Total number of replication chunks',
|
|
50
|
+
valueType: ValueType.INT
|
|
51
|
+
});
|
|
52
|
+
// 2. Sync operations / month
|
|
53
|
+
// Record on API pod
|
|
54
|
+
export const operations_synced_total = meter.createCounter('powersync_operations_synced_total', {
|
|
55
|
+
description: 'Number of operations synced',
|
|
56
|
+
valueType: ValueType.INT
|
|
57
|
+
});
|
|
58
|
+
// 3. Data hosted on PowerSync sync service
|
|
59
|
+
// Record on replication pod
|
|
60
|
+
// 3a. Replication storage -> raw data as received from Postgres.
|
|
61
|
+
export const replication_storage_size_bytes = meter.createObservableGauge('powersync_replication_storage_size_bytes', {
|
|
62
|
+
description: 'Size of current data stored in PowerSync',
|
|
63
|
+
unit: 'bytes',
|
|
64
|
+
valueType: ValueType.INT
|
|
65
|
+
});
|
|
66
|
+
// 3b. Operations storage -> transformed history, as will be synced to clients
|
|
67
|
+
export const operation_storage_size_bytes = meter.createObservableGauge('powersync_operation_storage_size_bytes', {
|
|
68
|
+
description: 'Size of operations stored in PowerSync',
|
|
69
|
+
unit: 'bytes',
|
|
70
|
+
valueType: ValueType.INT
|
|
71
|
+
});
|
|
72
|
+
// 3c. Parameter storage -> used for parameter queries
|
|
73
|
+
export const parameter_storage_size_bytes = meter.createObservableGauge('powersync_parameter_storage_size_bytes', {
|
|
74
|
+
description: 'Size of parameter data stored in PowerSync',
|
|
75
|
+
unit: 'bytes',
|
|
76
|
+
valueType: ValueType.INT
|
|
77
|
+
});
|
|
78
|
+
// 4. Peak concurrent connections
|
|
79
|
+
// Record on API pod
|
|
80
|
+
export const concurrent_connections = meter.createUpDownCounter('powersync_concurrent_connections', {
|
|
81
|
+
description: 'Number of concurrent sync connections',
|
|
82
|
+
valueType: ValueType.INT
|
|
83
|
+
});
|
|
84
|
+
export function configureApiMetrics() {
|
|
85
|
+
// Initialize the metric, so that it reports a value before connections
|
|
86
|
+
// have been opened.
|
|
87
|
+
concurrent_connections.add(0);
|
|
88
|
+
}
|
|
89
|
+
export function configureReplicationMetrics(system) {
|
|
90
|
+
// Rate limit collection of these stats, since it may be an expensive query
|
|
91
|
+
const MINIMUM_INTERVAL = 60000;
|
|
92
|
+
let cachedRequest = undefined;
|
|
93
|
+
let cacheTimestamp = 0;
|
|
94
|
+
function getMetrics() {
|
|
95
|
+
if (cachedRequest == null || Date.now() - cacheTimestamp > MINIMUM_INTERVAL) {
|
|
96
|
+
cachedRequest = system.storage.getStorageMetrics().catch((e) => {
|
|
97
|
+
micro.logger.error(`Failed to get storage metrics`, e);
|
|
98
|
+
return null;
|
|
99
|
+
});
|
|
100
|
+
cacheTimestamp = Date.now();
|
|
101
|
+
}
|
|
102
|
+
return cachedRequest;
|
|
103
|
+
}
|
|
104
|
+
operation_storage_size_bytes.addCallback(async (result) => {
|
|
105
|
+
const metrics = await getMetrics();
|
|
106
|
+
if (metrics) {
|
|
107
|
+
result.observe(metrics.operations_size_bytes);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
parameter_storage_size_bytes.addCallback(async (result) => {
|
|
111
|
+
const metrics = await getMetrics();
|
|
112
|
+
if (metrics) {
|
|
113
|
+
result.observe(metrics.parameters_size_bytes);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
replication_storage_size_bytes.addCallback(async (result) => {
|
|
117
|
+
const metrics = await getMetrics();
|
|
118
|
+
if (metrics) {
|
|
119
|
+
result.observe(metrics.replication_size_bytes);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
// Record replicated bytes using global jpgwire metrics.
|
|
123
|
+
jpgwire.setMetricsRecorder({
|
|
124
|
+
addBytesRead(bytes) {
|
|
125
|
+
data_replicated_bytes.add(bytes);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
export async function getMetricValueForTests(name) {
|
|
130
|
+
const metrics = await exporter.collect();
|
|
131
|
+
const scoped = metrics.resourceMetrics.scopeMetrics[0].metrics;
|
|
132
|
+
const metric = scoped.find((metric) => metric.descriptor.name == name);
|
|
133
|
+
if (metric == null) {
|
|
134
|
+
throw new Error(`Cannot find metric ${name}. Options: ${scoped.map((metric) => metric.descriptor.name).join(',')}`);
|
|
135
|
+
}
|
|
136
|
+
const point = metric.dataPoints[metric.dataPoints.length - 1];
|
|
137
|
+
return point?.value;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/metrics/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AAEtD,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAI7C,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;AAE1C,MAAM,IAAI,GAAW,IAAI,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,CAAC;AAEhD,iEAAiE;AACjE,6EAA6E;AAC7E,6FAA6F;AAC7F,qFAAqF;AAErF,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,kBAAkB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;AACzF,aAAa,CAAC,eAAe,CAAC,QAAQ,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BAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,IAAY;IACvD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;IACzC,MAAM,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/D,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;IACvE,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,cAAc,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACtH,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC9D,OAAO,KAAK,EAAE,KAAe,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as mongo from '../../../db/mongo.js';
|
|
2
|
+
import * as storage from '../../../storage/storage-index.js';
|
|
3
|
+
import * as utils from '../../../util/util-index.js';
|
|
4
|
+
export const up = async (context) => {
|
|
5
|
+
const config = await utils.loadConfig(context?.runner_config);
|
|
6
|
+
const database = storage.createPowerSyncMongo(config.storage);
|
|
7
|
+
await mongo.waitForAuth(database.db);
|
|
8
|
+
try {
|
|
9
|
+
await database.bucket_parameters.createIndex({
|
|
10
|
+
'key.g': 1,
|
|
11
|
+
lookup: 1,
|
|
12
|
+
_id: 1
|
|
13
|
+
}, { name: 'lookup1' });
|
|
14
|
+
}
|
|
15
|
+
finally {
|
|
16
|
+
await database.client.close();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export const down = async (context) => {
|
|
20
|
+
const config = await utils.loadConfig(context?.runner_config);
|
|
21
|
+
const database = storage.createPowerSyncMongo(config.storage);
|
|
22
|
+
try {
|
|
23
|
+
if (await database.bucket_parameters.indexExists('lookup')) {
|
|
24
|
+
await database.bucket_parameters.dropIndex('lookup1');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
await database.client.close();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=1684951997326-init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1684951997326-init.js","sourceRoot":"","sources":["../../../../src/migrations/db/migrations/1684951997326-init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAE9C,MAAM,CAAC,MAAM,EAAE,GAAG,KAAK,EAAE,OAAgC,EAAE,EAAE;IAC3D,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9D,MAAM,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACrC,IAAI,CAAC;QACH,MAAM,QAAQ,CAAC,iBAAiB,CAAC,WAAW,CAC1C;YACE,OAAO,EAAE,CAAC;YACV,MAAM,EAAE,CAAC;YACT,GAAG,EAAE,CAAC;SACP,EACD,EAAE,IAAI,EAAE,SAAS,EAAE,CACpB,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EAAE,OAAgC,EAAE,EAAE;IAC7D,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9D,IAAI,CAAC;QACH,IAAI,MAAM,QAAQ,CAAC,iBAAiB,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC3D,MAAM,QAAQ,CAAC,iBAAiB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1688556755264-initial-sync-rules.js","sourceRoot":"","sources":["../../../../src/migrations/db/migrations/1688556755264-initial-sync-rules.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,EAAE;IAC3B,kDAAkD;AACpD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE,GAAE,CAAC,CAAC"}
|