@powersync/service-core 0.0.0-dev-20240620165206
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 +82 -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 +25 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/locks/LockManager.d.ts +10 -0
- package/dist/locks/LockManager.js +7 -0
- package/dist/locks/LockManager.js.map +1 -0
- package/dist/locks/MongoLocks.d.ts +36 -0
- package/dist/locks/MongoLocks.js +81 -0
- package/dist/locks/MongoLocks.js.map +1 -0
- package/dist/locks/locks-index.d.ts +2 -0
- package/dist/locks/locks-index.js +3 -0
- package/dist/locks/locks-index.js.map +1 -0
- package/dist/metrics/Metrics.d.ts +30 -0
- package/dist/metrics/Metrics.js +176 -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/definitions.d.ts +18 -0
- package/dist/migrations/definitions.js +6 -0
- package/dist/migrations/definitions.js.map +1 -0
- package/dist/migrations/executor.d.ts +16 -0
- package/dist/migrations/executor.js +64 -0
- package/dist/migrations/executor.js.map +1 -0
- package/dist/migrations/migrations-index.d.ts +3 -0
- package/dist/migrations/migrations-index.js +4 -0
- package/dist/migrations/migrations-index.js.map +1 -0
- package/dist/migrations/migrations.d.ts +10 -0
- package/dist/migrations/migrations.js +90 -0
- package/dist/migrations/migrations.js.map +1 -0
- package/dist/migrations/store/migration-store.d.ts +11 -0
- package/dist/migrations/store/migration-store.js +46 -0
- package/dist/migrations/store/migration-store.js.map +1 -0
- package/dist/replication/ErrorRateLimiter.d.ts +17 -0
- package/dist/replication/ErrorRateLimiter.js +43 -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 +57 -0
- package/dist/replication/WalStream.js +515 -0
- package/dist/replication/WalStream.js.map +1 -0
- package/dist/replication/WalStreamManager.d.ts +30 -0
- package/dist/replication/WalStreamManager.js +198 -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/auth.d.ts +56 -0
- package/dist/routes/auth.js +182 -0
- package/dist/routes/auth.js.map +1 -0
- package/dist/routes/endpoints/admin.d.ts +1011 -0
- package/dist/routes/endpoints/admin.js +207 -0
- package/dist/routes/endpoints/admin.js.map +1 -0
- package/dist/routes/endpoints/checkpointing.d.ts +76 -0
- package/dist/routes/endpoints/checkpointing.js +36 -0
- package/dist/routes/endpoints/checkpointing.js.map +1 -0
- package/dist/routes/endpoints/dev.d.ts +312 -0
- package/dist/routes/endpoints/dev.js +172 -0
- package/dist/routes/endpoints/dev.js.map +1 -0
- package/dist/routes/endpoints/route-endpoints-index.d.ts +6 -0
- package/dist/routes/endpoints/route-endpoints-index.js +7 -0
- package/dist/routes/endpoints/route-endpoints-index.js.map +1 -0
- package/dist/routes/endpoints/socket-route.d.ts +2 -0
- package/dist/routes/endpoints/socket-route.js +119 -0
- package/dist/routes/endpoints/socket-route.js.map +1 -0
- package/dist/routes/endpoints/sync-rules.d.ts +174 -0
- package/dist/routes/endpoints/sync-rules.js +202 -0
- package/dist/routes/endpoints/sync-rules.js.map +1 -0
- package/dist/routes/endpoints/sync-stream.d.ts +132 -0
- package/dist/routes/endpoints/sync-stream.js +83 -0
- package/dist/routes/endpoints/sync-stream.js.map +1 -0
- package/dist/routes/hooks.d.ts +10 -0
- package/dist/routes/hooks.js +32 -0
- package/dist/routes/hooks.js.map +1 -0
- package/dist/routes/route-register.d.ts +10 -0
- package/dist/routes/route-register.js +87 -0
- package/dist/routes/route-register.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 +26 -0
- package/dist/routes/router.js +7 -0
- package/dist/routes/router.js.map +1 -0
- package/dist/routes/routes-index.d.ts +6 -0
- package/dist/routes/routes-index.js +7 -0
- package/dist/routes/routes-index.js.map +1 -0
- package/dist/runner/teardown.d.ts +2 -0
- package/dist/runner/teardown.js +94 -0
- package/dist/runner/teardown.js.map +1 -0
- package/dist/storage/BucketStorage.d.ts +307 -0
- package/dist/storage/BucketStorage.js +25 -0
- package/dist/storage/BucketStorage.js.map +1 -0
- package/dist/storage/ChecksumCache.d.ts +50 -0
- package/dist/storage/ChecksumCache.js +234 -0
- package/dist/storage/ChecksumCache.js.map +1 -0
- package/dist/storage/MongoBucketStorage.d.ts +52 -0
- package/dist/storage/MongoBucketStorage.js +409 -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 +581 -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 +29 -0
- package/dist/storage/mongo/MongoSyncBucketStorage.js +391 -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 +46 -0
- package/dist/storage/mongo/PersistedBatch.js +213 -0
- package/dist/storage/mongo/PersistedBatch.js.map +1 -0
- package/dist/storage/mongo/db.d.ts +26 -0
- package/dist/storage/mongo/db.js +35 -0
- package/dist/storage/mongo/db.js.map +1 -0
- package/dist/storage/mongo/models.d.ts +140 -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 +259 -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 +23 -0
- package/dist/system/CorePowerSyncSystem.js +52 -0
- package/dist/system/CorePowerSyncSystem.js.map +1 -0
- package/dist/system/system-index.d.ts +1 -0
- package/dist/system/system-index.js +2 -0
- package/dist/system/system-index.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 +2 -0
- package/dist/util/alerting.js +8 -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 +37 -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 +130 -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 +57 -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 +9 -0
- package/dist/util/env.js +26 -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 +182 -0
- package/dist/util/protocol-types.js +42 -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 +17 -0
- package/dist/util/utils.js +92 -0
- package/dist/util/utils.js.map +1 -0
- package/package.json +59 -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 +40 -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 +40 -0
- package/src/locks/LockManager.ts +16 -0
- package/src/locks/MongoLocks.ts +142 -0
- package/src/locks/locks-index.ts +2 -0
- package/src/metrics/Metrics.ts +265 -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/definitions.ts +21 -0
- package/src/migrations/executor.ts +87 -0
- package/src/migrations/migrations-index.ts +3 -0
- package/src/migrations/migrations.ts +118 -0
- package/src/migrations/store/migration-store.ts +63 -0
- package/src/replication/ErrorRateLimiter.ts +50 -0
- package/src/replication/PgRelation.ts +42 -0
- package/src/replication/WalConnection.ts +227 -0
- package/src/replication/WalStream.ts +624 -0
- package/src/replication/WalStreamManager.ts +213 -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/auth.ts +215 -0
- package/src/routes/endpoints/admin.ts +237 -0
- package/src/routes/endpoints/checkpointing.ts +41 -0
- package/src/routes/endpoints/dev.ts +199 -0
- package/src/routes/endpoints/route-endpoints-index.ts +6 -0
- package/src/routes/endpoints/socket-route.ts +135 -0
- package/src/routes/endpoints/sync-rules.ts +227 -0
- package/src/routes/endpoints/sync-stream.ts +101 -0
- package/src/routes/hooks.ts +46 -0
- package/src/routes/route-register.ts +104 -0
- package/src/routes/router-socket.ts +13 -0
- package/src/routes/router.ts +46 -0
- package/src/routes/routes-index.ts +6 -0
- package/src/runner/teardown.ts +108 -0
- package/src/storage/BucketStorage.ts +396 -0
- package/src/storage/ChecksumCache.ts +294 -0
- package/src/storage/MongoBucketStorage.ts +519 -0
- package/src/storage/SourceTable.ts +60 -0
- package/src/storage/mongo/MongoBucketBatch.ts +752 -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 +533 -0
- package/src/storage/mongo/MongoSyncRulesLock.ts +81 -0
- package/src/storage/mongo/OperationBatch.ts +115 -0
- package/src/storage/mongo/PersistedBatch.ts +268 -0
- package/src/storage/mongo/db.ts +73 -0
- package/src/storage/mongo/models.ts +162 -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 +319 -0
- package/src/sync/util.ts +98 -0
- package/src/system/CorePowerSyncSystem.ts +64 -0
- package/src/system/system-index.ts +1 -0
- package/src/util/Mutex.ts +159 -0
- package/src/util/PgManager.ts +64 -0
- package/src/util/alerting.ts +9 -0
- package/src/util/config/collectors/config-collector.ts +143 -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 +43 -0
- package/src/util/config/compound-config-collector.ts +176 -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 +66 -0
- package/src/util/config.ts +39 -0
- package/src/util/env.ts +30 -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 +228 -0
- package/src/util/secs.ts +54 -0
- package/src/util/util-index.ts +25 -0
- package/src/util/utils.ts +122 -0
- package/test/src/__snapshots__/pg_test.test.ts.snap +256 -0
- package/test/src/__snapshots__/sync.test.ts.snap +247 -0
- package/test/src/auth.test.ts +342 -0
- package/test/src/broadcast_iterable.test.ts +156 -0
- package/test/src/checksum_cache.test.ts +436 -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 +450 -0
- package/test/src/schema_changes.test.ts +545 -0
- package/test/src/setup.ts +7 -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 +1053 -0
- package/test/src/util.ts +76 -0
- package/test/src/validation.test.ts +63 -0
- package/test/src/wal_stream.test.ts +319 -0
- package/test/src/wal_stream_utils.ts +147 -0
- package/test/tsconfig.json +20 -0
- package/tsconfig.json +31 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vitest.config.ts +9 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import * as t from 'ts-codec';
|
|
2
|
+
import { errors, router, schema } from '@powersync/lib-services-framework';
|
|
3
|
+
import * as util from '../../util/util-index.js';
|
|
4
|
+
import { authDevUser, authUser, endpoint, issueDevToken, issueLegacyDevToken, issuePowerSyncToken } from '../auth.js';
|
|
5
|
+
import { routeDefinition } from '../router.js';
|
|
6
|
+
const AuthParams = t.object({
|
|
7
|
+
user: t.string,
|
|
8
|
+
password: t.string
|
|
9
|
+
});
|
|
10
|
+
// For legacy web client only. Remove soon.
|
|
11
|
+
export const auth = routeDefinition({
|
|
12
|
+
path: '/auth.json',
|
|
13
|
+
method: router.HTTPMethod.POST,
|
|
14
|
+
validator: schema.createTsCodecValidator(AuthParams, { allowAdditional: true }),
|
|
15
|
+
handler: async (payload) => {
|
|
16
|
+
const { user, password } = payload.params;
|
|
17
|
+
const config = payload.context.system.config;
|
|
18
|
+
if (config.dev.demo_auth == false || config.dev.demo_password == null) {
|
|
19
|
+
throw new errors.AuthorizationError(['Demo auth disabled']);
|
|
20
|
+
}
|
|
21
|
+
if (password == config.dev.demo_password) {
|
|
22
|
+
const token = await issueLegacyDevToken(payload.request, user, payload.context.system.config);
|
|
23
|
+
return { token, user_id: user, endpoint: endpoint(payload.request) };
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
throw new errors.AuthorizationError(['Authentication failed']);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export const auth2 = routeDefinition({
|
|
31
|
+
path: '/dev/auth.json',
|
|
32
|
+
method: router.HTTPMethod.POST,
|
|
33
|
+
validator: schema.createTsCodecValidator(AuthParams, { allowAdditional: true }),
|
|
34
|
+
handler: async (payload) => {
|
|
35
|
+
const { user, password } = payload.params;
|
|
36
|
+
const config = payload.context.system.config;
|
|
37
|
+
if (config.dev.demo_auth == false || config.dev.demo_password == null) {
|
|
38
|
+
throw new errors.AuthorizationError(['Demo auth disabled']);
|
|
39
|
+
}
|
|
40
|
+
if (password == config.dev.demo_password) {
|
|
41
|
+
const token = await issueDevToken(payload.request, user, payload.context.system.config);
|
|
42
|
+
return { token, user_id: user };
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw new errors.AuthorizationError(['Authentication failed']);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const TokenParams = t.object({});
|
|
50
|
+
export const token = routeDefinition({
|
|
51
|
+
path: '/dev/token.json',
|
|
52
|
+
method: router.HTTPMethod.POST,
|
|
53
|
+
validator: schema.createTsCodecValidator(TokenParams, { allowAdditional: true }),
|
|
54
|
+
authorize: authDevUser,
|
|
55
|
+
handler: async (payload) => {
|
|
56
|
+
const { user_id } = payload.context;
|
|
57
|
+
const outToken = await issuePowerSyncToken(payload.request, user_id, payload.context.system.config);
|
|
58
|
+
return { token: outToken, user_id: user_id, endpoint: endpoint(payload.request) };
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const OpType = {
|
|
62
|
+
PUT: 'PUT',
|
|
63
|
+
PATCH: 'PATCH',
|
|
64
|
+
DELETE: 'DELETE'
|
|
65
|
+
};
|
|
66
|
+
const CrudEntry = t.object({
|
|
67
|
+
op: t.Enum(OpType),
|
|
68
|
+
type: t.string,
|
|
69
|
+
id: t.string,
|
|
70
|
+
op_id: t.number.optional(),
|
|
71
|
+
data: t.any.optional()
|
|
72
|
+
});
|
|
73
|
+
const CrudRequest = t.object({
|
|
74
|
+
data: t.array(CrudEntry),
|
|
75
|
+
write_checkpoint: t.boolean.optional()
|
|
76
|
+
});
|
|
77
|
+
export const crud = routeDefinition({
|
|
78
|
+
path: '/crud.json',
|
|
79
|
+
method: router.HTTPMethod.POST,
|
|
80
|
+
validator: schema.createTsCodecValidator(CrudRequest, { allowAdditional: true }),
|
|
81
|
+
authorize: authUser,
|
|
82
|
+
handler: async (payload) => {
|
|
83
|
+
const { user_id, system } = payload.context;
|
|
84
|
+
const pool = system.requirePgPool();
|
|
85
|
+
if (!system.config.dev.crud_api) {
|
|
86
|
+
throw new Error('CRUD api disabled');
|
|
87
|
+
}
|
|
88
|
+
const params = payload.params;
|
|
89
|
+
let statements = [];
|
|
90
|
+
// Implementation note:
|
|
91
|
+
// Postgres does automatic "assigment cast" for query literals,
|
|
92
|
+
// e.g. a string literal to uuid. However, the same doesn't apply
|
|
93
|
+
// to query parameters.
|
|
94
|
+
// To handle those automatically, we use `json_populate_record`
|
|
95
|
+
// to automatically cast to the correct types.
|
|
96
|
+
for (let op of params.data) {
|
|
97
|
+
const table = util.escapeIdentifier(op.type);
|
|
98
|
+
if (op.op == 'PUT') {
|
|
99
|
+
const data = op.data;
|
|
100
|
+
const with_id = { ...data, id: op.id };
|
|
101
|
+
const columnsEscaped = Object.keys(with_id).map(util.escapeIdentifier);
|
|
102
|
+
const columnsJoined = columnsEscaped.join(', ');
|
|
103
|
+
let updateClauses = [];
|
|
104
|
+
for (let key of Object.keys(data)) {
|
|
105
|
+
updateClauses.push(`${util.escapeIdentifier(key)} = EXCLUDED.${util.escapeIdentifier(key)}`);
|
|
106
|
+
}
|
|
107
|
+
const updateClause = updateClauses.length > 0 ? `DO UPDATE SET ${updateClauses.join(', ')}` : `DO NOTHING`;
|
|
108
|
+
const statement = `
|
|
109
|
+
WITH data_row AS (
|
|
110
|
+
SELECT (json_populate_record(null::${table}, $1::json)).*
|
|
111
|
+
)
|
|
112
|
+
INSERT INTO ${table} (${columnsJoined})
|
|
113
|
+
SELECT ${columnsJoined} FROM data_row
|
|
114
|
+
ON CONFLICT(id) ${updateClause}`;
|
|
115
|
+
statements.push({
|
|
116
|
+
statement: statement,
|
|
117
|
+
params: [{ type: 'varchar', value: JSON.stringify(with_id) }]
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
else if (op.op == 'PATCH') {
|
|
121
|
+
const data = op.data;
|
|
122
|
+
const with_id = { ...data, id: op.id };
|
|
123
|
+
let updateClauses = [];
|
|
124
|
+
for (let key of Object.keys(data)) {
|
|
125
|
+
updateClauses.push(`${util.escapeIdentifier(key)} = data_row.${util.escapeIdentifier(key)}`);
|
|
126
|
+
}
|
|
127
|
+
const statement = `
|
|
128
|
+
WITH data_row AS (
|
|
129
|
+
SELECT (json_populate_record(null::${table}, $1::json)).*
|
|
130
|
+
)
|
|
131
|
+
UPDATE ${table}
|
|
132
|
+
SET ${updateClauses.join(', ')}
|
|
133
|
+
FROM data_row
|
|
134
|
+
WHERE ${table}.id = data_row.id`;
|
|
135
|
+
statements.push({
|
|
136
|
+
statement: statement,
|
|
137
|
+
params: [{ type: 'varchar', value: JSON.stringify(with_id) }]
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
else if (op.op == 'DELETE') {
|
|
141
|
+
statements.push({
|
|
142
|
+
statement: `
|
|
143
|
+
WITH data_row AS (
|
|
144
|
+
SELECT (json_populate_record(null::${table}, $1::json)).*
|
|
145
|
+
)
|
|
146
|
+
DELETE FROM ${table}
|
|
147
|
+
USING data_row
|
|
148
|
+
WHERE ${table}.id = data_row.id`,
|
|
149
|
+
params: [{ type: 'varchar', value: JSON.stringify({ id: op.id }) }]
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
await pool.query(...statements);
|
|
154
|
+
const storage = system.storage;
|
|
155
|
+
if (payload.params.write_checkpoint === true) {
|
|
156
|
+
const write_checkpoint = await util.createWriteCheckpoint(pool, storage, payload.context.user_id);
|
|
157
|
+
return { write_checkpoint: String(write_checkpoint) };
|
|
158
|
+
}
|
|
159
|
+
else if (payload.params.write_checkpoint === false) {
|
|
160
|
+
return {};
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
// Legacy
|
|
164
|
+
const checkpoint = await util.getClientCheckpoint(pool, storage);
|
|
165
|
+
return {
|
|
166
|
+
checkpoint
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
export const DEV_ROUTES = [auth, auth2, token, crud];
|
|
172
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../../src/routes/endpoints/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAE3E,OAAO,KAAK,IAAI,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,IAAI,EAAE,CAAC,CAAC,MAAM;IACd,QAAQ,EAAE,CAAC,CAAC,MAAM;CACnB,CAAC,CAAC;AAEH,2CAA2C;AAC3C,MAAM,CAAC,MAAM,IAAI,GAAG,eAAe,CAAC;IAClC,IAAI,EAAE,YAAY;IAClB,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI;IAC9B,SAAS,EAAE,MAAM,CAAC,sBAAsB,CAAC,UAAU,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;IAC/E,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACzB,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;QAC1C,MAAM,MAAM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,MAAM,CAAC,gBAAgB,KAAK,IAAI,EAAE;YAC5C,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAQ,CAAC,CAAC;YACnG,OAAO,EAAE,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC;SACvD;aAAM,IAAI,OAAO,CAAC,MAAM,CAAC,gBAAgB,KAAK,KAAK,EAAE;YACpD,OAAO,EAAE,CAAC;SACX;aAAM;YACL,SAAS;YACT,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACjE,OAAO;gBACL,UAAU;aACX,CAAC;SACH;IACH,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-endpoints-index.js","sourceRoot":"","sources":["../../../src/routes/endpoints/route-endpoints-index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { serialize } from 'bson';
|
|
2
|
+
import { normalizeTokenParameters } from '@powersync/service-sync-rules';
|
|
3
|
+
import { errors, logger, schema } from '@powersync/lib-services-framework';
|
|
4
|
+
import * as util from '../../util/util-index.js';
|
|
5
|
+
import { streamResponse } from '../../sync/sync.js';
|
|
6
|
+
import { SyncRoutes } from './sync-stream.js';
|
|
7
|
+
import { Metrics } from '../../metrics/Metrics.js';
|
|
8
|
+
export const syncStreamReactive = (router) => router.reactiveStream(SyncRoutes.STREAM, {
|
|
9
|
+
authorize: ({ context }) => {
|
|
10
|
+
return {
|
|
11
|
+
authorized: !!context.token_payload,
|
|
12
|
+
errors: ['Authentication required'].concat(context.token_errors ?? [])
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
validator: schema.createTsCodecValidator(util.StreamingSyncRequest, { allowAdditional: true }),
|
|
16
|
+
handler: async ({ context, params, responder, observer, initialN }) => {
|
|
17
|
+
const { system } = context;
|
|
18
|
+
if (system.closed) {
|
|
19
|
+
responder.onError(new errors.JourneyError({
|
|
20
|
+
status: 503,
|
|
21
|
+
code: 'SERVICE_UNAVAILABLE',
|
|
22
|
+
description: 'Service temporarily unavailable'
|
|
23
|
+
}));
|
|
24
|
+
responder.onComplete();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
const syncParams = normalizeTokenParameters(context.token_payload?.parameters ?? {}, params.parameters ?? {});
|
|
29
|
+
const storage = system.storage;
|
|
30
|
+
// Sanity check before we start the stream
|
|
31
|
+
const cp = await storage.getActiveCheckpoint();
|
|
32
|
+
if (!cp.hasSyncRules()) {
|
|
33
|
+
responder.onError(new errors.JourneyError({
|
|
34
|
+
status: 500,
|
|
35
|
+
code: 'NO_SYNC_RULES',
|
|
36
|
+
description: 'No sync rules available'
|
|
37
|
+
}));
|
|
38
|
+
responder.onComplete();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
let requestedN = initialN;
|
|
42
|
+
const disposer = observer.registerListener({
|
|
43
|
+
request(n) {
|
|
44
|
+
requestedN += n;
|
|
45
|
+
},
|
|
46
|
+
cancel: () => {
|
|
47
|
+
controller.abort();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const removeStopHandler = system.addStopHandler(() => {
|
|
51
|
+
observer.triggerCancel();
|
|
52
|
+
});
|
|
53
|
+
Metrics.getInstance().concurrent_connections.add(1);
|
|
54
|
+
try {
|
|
55
|
+
for await (const data of streamResponse({
|
|
56
|
+
storage,
|
|
57
|
+
params: {
|
|
58
|
+
...params,
|
|
59
|
+
binary_data: true // always true for web sockets
|
|
60
|
+
},
|
|
61
|
+
syncParams,
|
|
62
|
+
token: context.token_payload,
|
|
63
|
+
tokenStreamOptions: {
|
|
64
|
+
// RSocket handles keepalive events by default
|
|
65
|
+
keep_alive: false
|
|
66
|
+
},
|
|
67
|
+
signal: controller.signal
|
|
68
|
+
})) {
|
|
69
|
+
if (data == null) {
|
|
70
|
+
// Empty value just to flush iterator memory
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
else if (typeof data == 'string') {
|
|
74
|
+
// Should not happen with binary_data: true
|
|
75
|
+
throw new Error(`Unexpected string data: ${data}`);
|
|
76
|
+
}
|
|
77
|
+
{
|
|
78
|
+
// On NodeJS, serialize always returns a Buffer
|
|
79
|
+
const serialized = serialize(data);
|
|
80
|
+
responder.onNext({ data: serialized }, false);
|
|
81
|
+
requestedN--;
|
|
82
|
+
Metrics.getInstance().data_synced_bytes.add(serialized.length);
|
|
83
|
+
}
|
|
84
|
+
if (requestedN <= 0) {
|
|
85
|
+
await new Promise((resolve) => {
|
|
86
|
+
const l = observer.registerListener({
|
|
87
|
+
request() {
|
|
88
|
+
if (requestedN > 0) {
|
|
89
|
+
// Management of updating the total requested items is done above
|
|
90
|
+
resolve();
|
|
91
|
+
l();
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
cancel: () => {
|
|
95
|
+
// Don't wait here if the request is cancelled
|
|
96
|
+
resolve();
|
|
97
|
+
l();
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (ex) {
|
|
105
|
+
// Convert to our standard form before responding.
|
|
106
|
+
// This ensures the error can be serialized.
|
|
107
|
+
const error = new errors.InternalServerError(ex);
|
|
108
|
+
logger.error('Sync stream error', error);
|
|
109
|
+
responder.onError(error);
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
responder.onComplete();
|
|
113
|
+
removeStopHandler();
|
|
114
|
+
disposer();
|
|
115
|
+
Metrics.getInstance().concurrent_connections.add(-1);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=socket-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket-route.js","sourceRoot":"","sources":["../../../src/routes/endpoints/socket-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAkB,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAE3E,OAAO,KAAK,IAAI,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,MAAM,CAAC,MAAM,kBAAkB,GAAyB,CAAC,MAAM,EAAE,EAAE,CACjE,MAAM,CAAC,cAAc,CAAiC,UAAU,CAAC,MAAM,EAAE;IACvE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;QACzB,OAAO;YACL,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa;YACnC,MAAM,EAAE,CAAC,yBAAyB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC;SACvE,CAAC;IACJ,CAAC;IACD,SAAS,EAAE,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;IAC9F,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,E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;gCACX,8CAA8C;gCAC9C,OAAO,EAAE,CAAC;gCACV,CAAC,EAAE,CAAC;4BACN,CAAC;yBACF,CAAC,CAAC;oBACL,CAAC,CAAC,CAAC;iBACJ;aACF;SACF;QAAC,OAAO,EAAE,EAAE;YACX,kDAAkD;YAClD,4CAA4C;YAC5C,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC;YACjD,MAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;YACzC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SAC1B;gBAAS;YACR,SAAS,CAAC,UAAU,EAAE,CAAC;YACvB,iBAAiB,EAAE,CAAC;YACpB,QAAQ,EAAE,CAAC;YACX,OAAO,CAAC,WAAW,EAAE,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SACtD;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { FastifyPluginAsync } from 'fastify';
|
|
2
|
+
import { router, schema } from '@powersync/lib-services-framework';
|
|
3
|
+
export declare const yamlPlugin: FastifyPluginAsync;
|
|
4
|
+
export declare const deploySyncRules: router.Endpoint<{
|
|
5
|
+
content: string;
|
|
6
|
+
}, {
|
|
7
|
+
slot_name: string;
|
|
8
|
+
}, import("../router.js").Context, import("../router.js").RequestEndpointHandlerPayload<{
|
|
9
|
+
content: string;
|
|
10
|
+
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, router.EndpointHandler<import("../router.js").RequestEndpointHandlerPayload<{
|
|
11
|
+
content: string;
|
|
12
|
+
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, {
|
|
13
|
+
slot_name: string;
|
|
14
|
+
}>> & {
|
|
15
|
+
path: string;
|
|
16
|
+
method: router.HTTPMethod.POST;
|
|
17
|
+
authorize: (payload: import("../router.js").RequestEndpointHandlerPayload) => {
|
|
18
|
+
authorized: boolean;
|
|
19
|
+
errors: string[];
|
|
20
|
+
} | {
|
|
21
|
+
authorized: boolean;
|
|
22
|
+
errors?: undefined;
|
|
23
|
+
};
|
|
24
|
+
parse: boolean;
|
|
25
|
+
plugins: FastifyPluginAsync[];
|
|
26
|
+
validator: schema.MicroValidator<{
|
|
27
|
+
content: string;
|
|
28
|
+
}, string[]>;
|
|
29
|
+
handler: (payload: import("../router.js").RequestEndpointHandlerPayload<{
|
|
30
|
+
content: string;
|
|
31
|
+
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>) => Promise<{
|
|
32
|
+
slot_name: string;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
export declare const validateSyncRules: router.Endpoint<{
|
|
36
|
+
content: string;
|
|
37
|
+
}, router.RouterResponse<string>, import("../router.js").Context, import("../router.js").RequestEndpointHandlerPayload<{
|
|
38
|
+
content: string;
|
|
39
|
+
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, router.EndpointHandler<import("../router.js").RequestEndpointHandlerPayload<{
|
|
40
|
+
content: string;
|
|
41
|
+
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, router.RouterResponse<string>>> & {
|
|
42
|
+
path: string;
|
|
43
|
+
method: router.HTTPMethod.POST;
|
|
44
|
+
authorize: (payload: import("../router.js").RequestEndpointHandlerPayload) => {
|
|
45
|
+
authorized: boolean;
|
|
46
|
+
errors: string[];
|
|
47
|
+
} | {
|
|
48
|
+
authorized: boolean;
|
|
49
|
+
errors?: undefined;
|
|
50
|
+
};
|
|
51
|
+
parse: boolean;
|
|
52
|
+
plugins: FastifyPluginAsync[];
|
|
53
|
+
validator: schema.MicroValidator<{
|
|
54
|
+
content: string;
|
|
55
|
+
}, string[]>;
|
|
56
|
+
handler: (payload: import("../router.js").RequestEndpointHandlerPayload<{
|
|
57
|
+
content: string;
|
|
58
|
+
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>) => Promise<router.RouterResponse<string>>;
|
|
59
|
+
};
|
|
60
|
+
export declare const currentSyncRules: router.Endpoint<any, router.RouterResponse<string>, import("../router.js").Context, import("../router.js").RequestEndpointHandlerPayload<any, import("../router.js").Context, import("../router.js").BasicRouterRequest>, router.EndpointHandler<import("../router.js").RequestEndpointHandlerPayload<any, import("../router.js").Context, import("../router.js").BasicRouterRequest>, router.RouterResponse<string>>> & {
|
|
61
|
+
path: string;
|
|
62
|
+
method: router.HTTPMethod.GET;
|
|
63
|
+
authorize: (payload: import("../router.js").RequestEndpointHandlerPayload) => {
|
|
64
|
+
authorized: boolean;
|
|
65
|
+
errors: string[];
|
|
66
|
+
} | {
|
|
67
|
+
authorized: boolean;
|
|
68
|
+
errors?: undefined;
|
|
69
|
+
};
|
|
70
|
+
handler: (payload: import("../router.js").RequestEndpointHandlerPayload<any, import("../router.js").Context, import("../router.js").BasicRouterRequest>) => Promise<router.RouterResponse<string>>;
|
|
71
|
+
};
|
|
72
|
+
export declare const reprocessSyncRules: router.Endpoint<{}, {
|
|
73
|
+
slot_name: string;
|
|
74
|
+
}, import("../router.js").Context, import("../router.js").RequestEndpointHandlerPayload<{}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, router.EndpointHandler<import("../router.js").RequestEndpointHandlerPayload<{}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, {
|
|
75
|
+
slot_name: string;
|
|
76
|
+
}>> & {
|
|
77
|
+
path: string;
|
|
78
|
+
method: router.HTTPMethod.POST;
|
|
79
|
+
authorize: (payload: import("../router.js").RequestEndpointHandlerPayload) => {
|
|
80
|
+
authorized: boolean;
|
|
81
|
+
errors: string[];
|
|
82
|
+
} | {
|
|
83
|
+
authorized: boolean;
|
|
84
|
+
errors?: undefined;
|
|
85
|
+
};
|
|
86
|
+
validator: schema.MicroValidator<{}, string[]>;
|
|
87
|
+
handler: (payload: import("../router.js").RequestEndpointHandlerPayload<{}, import("../router.js").Context, import("../router.js").BasicRouterRequest>) => Promise<{
|
|
88
|
+
slot_name: string;
|
|
89
|
+
}>;
|
|
90
|
+
};
|
|
91
|
+
export declare const SYNC_RULES_ROUTES: ((router.Endpoint<{
|
|
92
|
+
content: string;
|
|
93
|
+
}, {
|
|
94
|
+
slot_name: string;
|
|
95
|
+
}, import("../router.js").Context, import("../router.js").RequestEndpointHandlerPayload<{
|
|
96
|
+
content: string;
|
|
97
|
+
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, router.EndpointHandler<import("../router.js").RequestEndpointHandlerPayload<{
|
|
98
|
+
content: string;
|
|
99
|
+
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, {
|
|
100
|
+
slot_name: string;
|
|
101
|
+
}>> & {
|
|
102
|
+
path: string;
|
|
103
|
+
method: router.HTTPMethod.POST;
|
|
104
|
+
authorize: (payload: import("../router.js").RequestEndpointHandlerPayload) => {
|
|
105
|
+
authorized: boolean;
|
|
106
|
+
errors: string[];
|
|
107
|
+
} | {
|
|
108
|
+
authorized: boolean;
|
|
109
|
+
errors?: undefined;
|
|
110
|
+
};
|
|
111
|
+
parse: boolean;
|
|
112
|
+
plugins: FastifyPluginAsync[];
|
|
113
|
+
validator: schema.MicroValidator<{
|
|
114
|
+
content: string;
|
|
115
|
+
}, string[]>;
|
|
116
|
+
handler: (payload: import("../router.js").RequestEndpointHandlerPayload<{
|
|
117
|
+
content: string;
|
|
118
|
+
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>) => Promise<{
|
|
119
|
+
slot_name: string;
|
|
120
|
+
}>;
|
|
121
|
+
}) | (router.Endpoint<{
|
|
122
|
+
content: string;
|
|
123
|
+
}, router.RouterResponse<string>, import("../router.js").Context, import("../router.js").RequestEndpointHandlerPayload<{
|
|
124
|
+
content: string;
|
|
125
|
+
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, router.EndpointHandler<import("../router.js").RequestEndpointHandlerPayload<{
|
|
126
|
+
content: string;
|
|
127
|
+
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, router.RouterResponse<string>>> & {
|
|
128
|
+
path: string;
|
|
129
|
+
method: router.HTTPMethod.POST;
|
|
130
|
+
authorize: (payload: import("../router.js").RequestEndpointHandlerPayload) => {
|
|
131
|
+
authorized: boolean;
|
|
132
|
+
errors: string[];
|
|
133
|
+
} | {
|
|
134
|
+
authorized: boolean;
|
|
135
|
+
errors?: undefined;
|
|
136
|
+
};
|
|
137
|
+
parse: boolean;
|
|
138
|
+
plugins: FastifyPluginAsync[];
|
|
139
|
+
validator: schema.MicroValidator<{
|
|
140
|
+
content: string;
|
|
141
|
+
}, string[]>;
|
|
142
|
+
handler: (payload: import("../router.js").RequestEndpointHandlerPayload<{
|
|
143
|
+
content: string;
|
|
144
|
+
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>) => Promise<router.RouterResponse<string>>;
|
|
145
|
+
}) | (router.Endpoint<any, router.RouterResponse<string>, import("../router.js").Context, import("../router.js").RequestEndpointHandlerPayload<any, import("../router.js").Context, import("../router.js").BasicRouterRequest>, router.EndpointHandler<import("../router.js").RequestEndpointHandlerPayload<any, import("../router.js").Context, import("../router.js").BasicRouterRequest>, router.RouterResponse<string>>> & {
|
|
146
|
+
path: string;
|
|
147
|
+
method: router.HTTPMethod.GET;
|
|
148
|
+
authorize: (payload: import("../router.js").RequestEndpointHandlerPayload) => {
|
|
149
|
+
authorized: boolean;
|
|
150
|
+
errors: string[];
|
|
151
|
+
} | {
|
|
152
|
+
authorized: boolean;
|
|
153
|
+
errors?: undefined;
|
|
154
|
+
};
|
|
155
|
+
handler: (payload: import("../router.js").RequestEndpointHandlerPayload<any, import("../router.js").Context, import("../router.js").BasicRouterRequest>) => Promise<router.RouterResponse<string>>;
|
|
156
|
+
}) | (router.Endpoint<{}, {
|
|
157
|
+
slot_name: string;
|
|
158
|
+
}, import("../router.js").Context, import("../router.js").RequestEndpointHandlerPayload<{}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, router.EndpointHandler<import("../router.js").RequestEndpointHandlerPayload<{}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, {
|
|
159
|
+
slot_name: string;
|
|
160
|
+
}>> & {
|
|
161
|
+
path: string;
|
|
162
|
+
method: router.HTTPMethod.POST;
|
|
163
|
+
authorize: (payload: import("../router.js").RequestEndpointHandlerPayload) => {
|
|
164
|
+
authorized: boolean;
|
|
165
|
+
errors: string[];
|
|
166
|
+
} | {
|
|
167
|
+
authorized: boolean;
|
|
168
|
+
errors?: undefined;
|
|
169
|
+
};
|
|
170
|
+
validator: schema.MicroValidator<{}, string[]>;
|
|
171
|
+
handler: (payload: import("../router.js").RequestEndpointHandlerPayload<{}, import("../router.js").Context, import("../router.js").BasicRouterRequest>) => Promise<{
|
|
172
|
+
slot_name: string;
|
|
173
|
+
}>;
|
|
174
|
+
}))[];
|