@rocicorp/zero 1.10.0-canary.2 → 1.10.0-canary.21
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/out/replicache/src/btree/read.d.ts +12 -1
- package/out/replicache/src/btree/read.d.ts.map +1 -1
- package/out/replicache/src/btree/read.js +24 -12
- package/out/replicache/src/btree/read.js.map +1 -1
- package/out/replicache/src/db/rebase.d.ts +14 -2
- package/out/replicache/src/db/rebase.d.ts.map +1 -1
- package/out/replicache/src/db/rebase.js +27 -5
- package/out/replicache/src/db/rebase.js.map +1 -1
- package/out/replicache/src/db/write.js.map +1 -1
- package/out/replicache/src/kv/expo-sqlite/store.d.ts.map +1 -1
- package/out/replicache/src/kv/expo-sqlite/store.js +27 -4
- package/out/replicache/src/kv/expo-sqlite/store.js.map +1 -1
- package/out/replicache/src/kv/sqlite-store.d.ts +11 -0
- package/out/replicache/src/kv/sqlite-store.d.ts.map +1 -1
- package/out/replicache/src/kv/sqlite-store.js +43 -3
- package/out/replicache/src/kv/sqlite-store.js.map +1 -1
- package/out/replicache/src/persist/persist.d.ts.map +1 -1
- package/out/replicache/src/persist/persist.js +12 -5
- package/out/replicache/src/persist/persist.js.map +1 -1
- package/out/replicache/src/persist/refresh.js +6 -2
- package/out/replicache/src/persist/refresh.js.map +1 -1
- package/out/replicache/src/replicache-impl.d.ts.map +1 -1
- package/out/replicache/src/replicache-impl.js +14 -2
- package/out/replicache/src/replicache-impl.js.map +1 -1
- package/out/replicache/src/replicache-options.d.ts +9 -0
- package/out/replicache/src/replicache-options.d.ts.map +1 -1
- package/out/replicache/src/transactions.d.ts.map +1 -1
- package/out/replicache/src/transactions.js +1 -1
- package/out/replicache/src/transactions.js.map +1 -1
- package/out/shared/src/error.d.ts +11 -0
- package/out/shared/src/error.d.ts.map +1 -1
- package/out/shared/src/error.js +35 -1
- package/out/shared/src/error.js.map +1 -1
- package/out/shared/src/hash.d.ts.map +1 -1
- package/out/shared/src/hash.js +105 -10
- package/out/shared/src/hash.js.map +1 -1
- package/out/shared/src/map.d.ts +7 -2
- package/out/shared/src/map.d.ts.map +1 -1
- package/out/shared/src/map.js.map +1 -1
- package/out/shared/src/promise-race.d.ts +14 -0
- package/out/shared/src/promise-race.d.ts.map +1 -1
- package/out/shared/src/promise-race.js +32 -1
- package/out/shared/src/promise-race.js.map +1 -1
- package/out/zero/package.js +2 -3
- package/out/zero/package.js.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.js +8 -1
- package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
- package/out/zero-cache/src/config/normalize.d.ts +5 -0
- package/out/zero-cache/src/config/normalize.d.ts.map +1 -1
- package/out/zero-cache/src/config/normalize.js +16 -3
- package/out/zero-cache/src/config/normalize.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +36 -7
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +121 -46
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/db/create.d.ts.map +1 -1
- package/out/zero-cache/src/db/create.js +4 -1
- package/out/zero-cache/src/db/create.js.map +1 -1
- package/out/zero-cache/src/db/index-predicate.d.ts +4 -0
- package/out/zero-cache/src/db/index-predicate.d.ts.map +1 -0
- package/out/zero-cache/src/db/index-predicate.js +46 -0
- package/out/zero-cache/src/db/index-predicate.js.map +1 -0
- package/out/zero-cache/src/db/lite-tables.d.ts +10 -2
- package/out/zero-cache/src/db/lite-tables.d.ts.map +1 -1
- package/out/zero-cache/src/db/lite-tables.js +8 -3
- package/out/zero-cache/src/db/lite-tables.js.map +1 -1
- package/out/zero-cache/src/db/migration-lite.d.ts.map +1 -1
- package/out/zero-cache/src/db/migration-lite.js +5 -3
- package/out/zero-cache/src/db/migration-lite.js.map +1 -1
- package/out/zero-cache/src/db/specs.d.ts +41 -0
- package/out/zero-cache/src/db/specs.d.ts.map +1 -1
- package/out/zero-cache/src/db/specs.js +30 -3
- package/out/zero-cache/src/db/specs.js.map +1 -1
- package/out/zero-cache/src/db/transaction-pool.d.ts +5 -15
- package/out/zero-cache/src/db/transaction-pool.d.ts.map +1 -1
- package/out/zero-cache/src/db/transaction-pool.js +39 -73
- package/out/zero-cache/src/db/transaction-pool.js.map +1 -1
- package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
- package/out/zero-cache/src/server/change-streamer.js +27 -15
- package/out/zero-cache/src/server/change-streamer.js.map +1 -1
- package/out/zero-cache/src/server/main.d.ts.map +1 -1
- package/out/zero-cache/src/server/main.js +4 -4
- package/out/zero-cache/src/server/main.js.map +1 -1
- package/out/zero-cache/src/server/replicator.d.ts.map +1 -1
- package/out/zero-cache/src/server/replicator.js +8 -4
- package/out/zero-cache/src/server/replicator.js.map +1 -1
- package/out/zero-cache/src/server/runner/run-worker.js +1 -1
- package/out/zero-cache/src/server/worker-urls.d.ts +0 -1
- package/out/zero-cache/src/server/worker-urls.d.ts.map +1 -1
- package/out/zero-cache/src/server/worker-urls.js +1 -2
- package/out/zero-cache/src/server/worker-urls.js.map +1 -1
- package/out/zero-cache/src/services/analyze.d.ts.map +1 -1
- package/out/zero-cache/src/services/analyze.js +1 -0
- package/out/zero-cache/src/services/analyze.js.map +1 -1
- package/out/zero-cache/src/services/change-source/common/backfill-manager.d.ts +12 -2
- package/out/zero-cache/src/services/change-source/common/backfill-manager.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/common/backfill-manager.js +14 -3
- package/out/zero-cache/src/services/change-source/common/backfill-manager.js.map +1 -1
- package/out/zero-cache/src/services/change-source/common/replica-schema.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/common/replica-schema.js +10 -41
- package/out/zero-cache/src/services/change-source/common/replica-schema.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/backfill-stream.d.ts +3 -2
- package/out/zero-cache/src/services/change-source/pg/backfill-stream.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/backfill-stream.js +42 -16
- package/out/zero-cache/src/services/change-source/pg/backfill-stream.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.d.ts +34 -2
- package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.js +47 -19
- package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/decommission.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/decommission.js +20 -11
- package/out/zero-cache/src/services/change-source/pg/decommission.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts +1 -0
- package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js +58 -80
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.d.ts +20 -0
- package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.js +43 -3
- package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/replication-slots.d.ts +24 -1
- package/out/zero-cache/src/services/change-source/pg/replication-slots.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/replication-slots.js +35 -5
- package/out/zero-cache/src/services/change-source/pg/replication-slots.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +1513 -229
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.js +2 -2
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.d.ts +19 -0
- package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js +581 -0
- package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js.map +1 -0
- package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.js +15 -6
- package/out/zero-cache/src/services/change-source/pg/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts +137 -20
- package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/published.js +82 -13
- package/out/zero-cache/src/services/change-source/pg/schema/published.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +128 -21
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js +5 -5
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts +2 -0
- package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +3 -0
- package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/backup-cleanup-monitor-factory.d.ts +1 -4
- package/out/zero-cache/src/services/change-streamer/backup-cleanup-monitor-factory.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/backup-cleanup-monitor-factory.js +11 -18
- package/out/zero-cache/src/services/change-streamer/backup-cleanup-monitor-factory.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/backup-monitor.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/backup-monitor.js +8 -3
- package/out/zero-cache/src/services/change-streamer/backup-monitor.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/broadcast.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/broadcast.js +4 -1
- package/out/zero-cache/src/services/change-streamer/broadcast.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-log-compare-digest.d.ts +34 -0
- package/out/zero-cache/src/services/change-streamer/change-log-compare-digest.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-streamer/change-log-compare-digest.js +67 -0
- package/out/zero-cache/src/services/change-streamer/change-log-compare-digest.js.map +1 -0
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +2 -4
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +8 -2
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.d.ts +34 -13
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.js +165 -36
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts +4 -9
- package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/forwarder.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/forwarder.js +12 -3
- package/out/zero-cache/src/services/change-streamer/forwarder.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/litestream3-prometheus-poller.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/litestream3-prometheus-poller.js +11 -5
- package/out/zero-cache/src/services/change-streamer/litestream3-prometheus-poller.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/shard-sampling.d.ts +11 -0
- package/out/zero-cache/src/services/change-streamer/shard-sampling.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-streamer/shard-sampling.js +19 -0
- package/out/zero-cache/src/services/change-streamer/shard-sampling.js.map +1 -0
- package/out/zero-cache/src/services/change-streamer/snapshot-reservations.d.ts +11 -1
- package/out/zero-cache/src/services/change-streamer/snapshot-reservations.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/snapshot-reservations.js +38 -5
- package/out/zero-cache/src/services/change-streamer/snapshot-reservations.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-catchup.d.ts +25 -1
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-catchup.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-catchup.js +95 -12
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-catchup.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-comparator.d.ts +83 -0
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-comparator.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-comparator.js +417 -0
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-comparator.js.map +1 -0
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-read-router.d.ts +73 -0
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-read-router.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-read-router.js +157 -0
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-read-router.js.map +1 -0
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-reader.d.ts +1 -1
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-reader.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-reader.js +8 -3
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-reader.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.d.ts +63 -1
- package/out/zero-cache/src/services/change-streamer/storer.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.js +217 -49
- package/out/zero-cache/src/services/change-streamer/storer.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/subscriber.d.ts +8 -1
- package/out/zero-cache/src/services/change-streamer/subscriber.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/subscriber.js +10 -1
- package/out/zero-cache/src/services/change-streamer/subscriber.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/vfs-watermark-poller.d.ts +29 -0
- package/out/zero-cache/src/services/change-streamer/vfs-watermark-poller.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-streamer/vfs-watermark-poller.js +154 -0
- package/out/zero-cache/src/services/change-streamer/vfs-watermark-poller.js.map +1 -0
- package/out/zero-cache/src/services/http-service.d.ts +1 -0
- package/out/zero-cache/src/services/http-service.d.ts.map +1 -1
- package/out/zero-cache/src/services/http-service.js +7 -3
- package/out/zero-cache/src/services/http-service.js.map +1 -1
- package/out/zero-cache/src/services/litestream/commands.d.ts.map +1 -1
- package/out/zero-cache/src/services/litestream/commands.js +16 -7
- package/out/zero-cache/src/services/litestream/commands.js.map +1 -1
- package/out/zero-cache/src/services/litestream/config-v5.yml +15 -1
- package/out/zero-cache/src/services/litestream/litestream-checkpointer.js +131 -0
- package/out/zero-cache/src/services/litestream/litestream-checkpointer.js.map +1 -0
- package/out/zero-cache/src/services/litestream/litestream-controller.d.ts +70 -0
- package/out/zero-cache/src/services/litestream/litestream-controller.d.ts.map +1 -0
- package/out/zero-cache/src/services/litestream/litestream-controller.js +101 -0
- package/out/zero-cache/src/services/litestream/litestream-controller.js.map +1 -0
- package/out/zero-cache/src/services/litestream/metrics.d.ts +1 -0
- package/out/zero-cache/src/services/litestream/metrics.d.ts.map +1 -1
- package/out/zero-cache/src/services/litestream/metrics.js +4 -1
- package/out/zero-cache/src/services/litestream/metrics.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/replicator/change-log-db.d.ts +10 -0
- package/out/zero-cache/src/services/replicator/change-log-db.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/change-log-db.js +15 -1
- package/out/zero-cache/src/services/replicator/change-log-db.js.map +1 -1
- package/out/zero-cache/src/services/replicator/change-processor.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/change-processor.js +18 -21
- package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.d.ts +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.js +2 -6
- package/out/zero-cache/src/services/replicator/incremental-sync.js.map +1 -1
- package/out/zero-cache/src/services/replicator/replicator.d.ts +1 -1
- package/out/zero-cache/src/services/replicator/replicator.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/replicator.js +2 -2
- package/out/zero-cache/src/services/replicator/replicator.js.map +1 -1
- package/out/zero-cache/src/services/replicator/sqlite-change-log-observability.d.ts +3 -2
- package/out/zero-cache/src/services/replicator/sqlite-change-log-observability.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/sqlite-change-log-observability.js +8 -6
- package/out/zero-cache/src/services/replicator/sqlite-change-log-observability.js.map +1 -1
- package/out/zero-cache/src/services/replicator/write-worker-client.d.ts +27 -2
- package/out/zero-cache/src/services/replicator/write-worker-client.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/write-worker-client.js +3 -2
- package/out/zero-cache/src/services/replicator/write-worker-client.js.map +1 -1
- package/out/zero-cache/src/services/replicator/write-worker.js +24 -5
- package/out/zero-cache/src/services/replicator/write-worker.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.d.ts +3 -2
- package/out/zero-cache/src/services/view-syncer/client-handler.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.js +25 -17
- package/out/zero-cache/src/services/view-syncer/client-handler.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.js +14 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +3 -3
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.js +6 -2
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/downstream.d.ts +11 -0
- package/out/zero-cache/src/types/downstream.d.ts.map +1 -0
- package/out/zero-cache/src/types/pg.d.ts +15 -2
- package/out/zero-cache/src/types/pg.d.ts.map +1 -1
- package/out/zero-cache/src/types/pg.js +21 -8
- package/out/zero-cache/src/types/pg.js.map +1 -1
- package/out/zero-cache/src/types/poke-chunk.d.ts +18 -0
- package/out/zero-cache/src/types/poke-chunk.d.ts.map +1 -0
- package/out/zero-cache/src/types/poke-chunk.js +57 -0
- package/out/zero-cache/src/types/poke-chunk.js.map +1 -0
- package/out/zero-cache/src/types/processes.js +1 -4
- package/out/zero-cache/src/types/processes.js.map +1 -1
- package/out/zero-cache/src/types/streams.d.ts +4 -9
- package/out/zero-cache/src/types/streams.d.ts.map +1 -1
- package/out/zero-cache/src/types/streams.js.map +1 -1
- package/out/zero-cache/src/types/subscription.d.ts +2 -11
- package/out/zero-cache/src/types/subscription.d.ts.map +1 -1
- package/out/zero-cache/src/types/subscription.js +4 -25
- package/out/zero-cache/src/types/subscription.js.map +1 -1
- package/out/zero-cache/src/workers/connection.d.ts +22 -4
- package/out/zero-cache/src/workers/connection.d.ts.map +1 -1
- package/out/zero-cache/src/workers/connection.js +112 -14
- package/out/zero-cache/src/workers/connection.js.map +1 -1
- package/out/zero-cache/src/workers/replicator.d.ts +1 -0
- package/out/zero-cache/src/workers/replicator.d.ts.map +1 -1
- package/out/zero-cache/src/workers/replicator.js +4 -2
- package/out/zero-cache/src/workers/replicator.js.map +1 -1
- package/out/zero-client/src/client/connection-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/connection-manager.js +46 -0
- package/out/zero-client/src/client/connection-manager.js.map +1 -1
- package/out/zero-client/src/client/context.d.ts +15 -0
- package/out/zero-client/src/client/context.d.ts.map +1 -1
- package/out/zero-client/src/client/context.js +44 -0
- package/out/zero-client/src/client/context.js.map +1 -1
- package/out/zero-client/src/client/inspector/lazy-inspector.d.ts.map +1 -1
- package/out/zero-client/src/client/inspector/lazy-inspector.js +19 -12
- package/out/zero-client/src/client/inspector/lazy-inspector.js.map +1 -1
- package/out/zero-client/src/client/ivm-branch.js.map +1 -1
- package/out/zero-client/src/client/version.js +1 -1
- package/out/zero-client/src/client/zero-poke-handler.d.ts +7 -2
- package/out/zero-client/src/client/zero-poke-handler.d.ts.map +1 -1
- package/out/zero-client/src/client/zero-poke-handler.js +52 -2
- package/out/zero-client/src/client/zero-poke-handler.js.map +1 -1
- package/out/zero-client/src/client/zero-rep.d.ts +1 -0
- package/out/zero-client/src/client/zero-rep.d.ts.map +1 -1
- package/out/zero-client/src/client/zero-rep.js +9 -6
- package/out/zero-client/src/client/zero-rep.js.map +1 -1
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.js +98 -25
- package/out/zero-client/src/client/zero.js.map +1 -1
- package/out/zero-protocol/src/custom-queries.d.ts +1 -1
- package/out/zero-protocol/src/down.d.ts +1 -1
- package/out/zero-protocol/src/error.d.ts +4 -4
- package/out/zero-protocol/src/inspect-down.js +1 -1
- package/out/zero-protocol/src/mutate-server.d.ts +2 -2
- package/out/zero-protocol/src/poke.d.ts +89 -7
- package/out/zero-protocol/src/poke.d.ts.map +1 -1
- package/out/zero-protocol/src/poke.js +16 -8
- package/out/zero-protocol/src/poke.js.map +1 -1
- package/out/zero-protocol/src/protocol-version.d.ts +12 -7
- package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
- package/out/zero-protocol/src/protocol-version.js.map +1 -1
- package/out/zero-protocol/src/push.d.ts +1 -1
- package/out/zero-protocol/src/query-server.d.ts +2 -2
- package/out/zql/src/ivm/array-view.d.ts.map +1 -1
- package/out/zql/src/ivm/array-view.js +5 -3
- package/out/zql/src/ivm/array-view.js.map +1 -1
- package/out/zql/src/ivm/data.d.ts.map +1 -1
- package/out/zql/src/ivm/data.js +8 -3
- package/out/zql/src/ivm/data.js.map +1 -1
- package/out/zql/src/ivm/deferred-input.d.ts +44 -0
- package/out/zql/src/ivm/deferred-input.d.ts.map +1 -0
- package/out/zql/src/ivm/deferred-input.js +88 -0
- package/out/zql/src/ivm/deferred-input.js.map +1 -0
- package/out/zql/src/ivm/memory-source.d.ts +10 -2
- package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
- package/out/zql/src/ivm/memory-source.js +19 -16
- package/out/zql/src/ivm/memory-source.js.map +1 -1
- package/out/zql/src/ivm/stream.d.ts +0 -1
- package/out/zql/src/ivm/stream.d.ts.map +1 -1
- package/out/zql/src/ivm/stream.js +1 -7
- package/out/zql/src/ivm/stream.js.map +1 -1
- package/out/zql/src/ivm/union-fan-in.d.ts +1 -1
- package/out/zql/src/ivm/union-fan-in.d.ts.map +1 -1
- package/out/zql/src/ivm/union-fan-in.js +11 -2
- package/out/zql/src/ivm/union-fan-in.js.map +1 -1
- package/out/zql/src/ivm/view-apply-change.js +6 -1
- package/out/zql/src/ivm/view-apply-change.js.map +1 -1
- package/out/zql/src/query/query-delegate-base.d.ts +6 -0
- package/out/zql/src/query/query-delegate-base.d.ts.map +1 -1
- package/out/zql/src/query/query-delegate-base.js +73 -10
- package/out/zql/src/query/query-delegate-base.js.map +1 -1
- package/out/zql/src/query/query-delegate.d.ts +22 -0
- package/out/zql/src/query/query-delegate.d.ts.map +1 -1
- package/out/zqlite/src/query-builder.d.ts.map +1 -1
- package/out/zqlite/src/query-builder.js +2 -1
- package/out/zqlite/src/query-builder.js.map +1 -1
- package/out/zqlite/src/sqlite-stat-fanout.d.ts.map +1 -1
- package/out/zqlite/src/sqlite-stat-fanout.js +1 -0
- package/out/zqlite/src/sqlite-stat-fanout.js.map +1 -1
- package/out/zqlite/src/table-source.d.ts +1 -1
- package/out/zqlite/src/table-source.d.ts.map +1 -1
- package/out/zqlite/src/table-source.js +3 -2
- package/out/zqlite/src/table-source.js.map +1 -1
- package/package.json +2 -3
- package/out/zero-cache/src/server/backup-watermark-poller.js +0 -31
- package/out/zero-cache/src/server/backup-watermark-poller.js.map +0 -1
- package/out/zero-cache/src/services/litestream/vfs-watermark-poller.d.ts +0 -57
- package/out/zero-cache/src/services/litestream/vfs-watermark-poller.d.ts.map +0 -1
- package/out/zero-cache/src/services/litestream/vfs-watermark-poller.js +0 -137
- package/out/zero-cache/src/services/litestream/vfs-watermark-poller.js.map +0 -1
|
@@ -117,7 +117,7 @@ export declare const transformResponseMessageSchema: v.UnionType<[v.TupleType<[v
|
|
|
117
117
|
message: v.Type<string>;
|
|
118
118
|
}, "reason" | "origin"> & {
|
|
119
119
|
origin: v.Type<"zeroCache">;
|
|
120
|
-
reason: v.Type<"parse" | "
|
|
120
|
+
reason: v.Type<"parse" | "timeout" | "internal">;
|
|
121
121
|
}, undefined>]>]>]>;
|
|
122
122
|
export type TransformResponseMessage = v.Infer<typeof transformResponseMessageSchema>;
|
|
123
123
|
//# sourceMappingURL=custom-queries.d.ts.map
|
|
@@ -11,7 +11,6 @@ export declare const downstreamSchema: v.UnionType<[v.TupleType<[v.Type<"connect
|
|
|
11
11
|
}>;
|
|
12
12
|
timestamp: v.Optional<number>;
|
|
13
13
|
}, undefined>]>, v.TupleType<[v.Type<"pokePart">, v.ObjectType<{
|
|
14
|
-
pokeID: v.Type<string>;
|
|
15
14
|
lastMutationIDChanges: v.Optional<Record<string, number>>;
|
|
16
15
|
desiredQueriesPatches: v.Optional<Record<string, ({
|
|
17
16
|
ttl?: number | undefined;
|
|
@@ -75,6 +74,7 @@ export declare const downstreamSchema: v.UnionType<[v.TupleType<[v.Type<"connect
|
|
|
75
74
|
clientID: string;
|
|
76
75
|
};
|
|
77
76
|
})[]>;
|
|
77
|
+
pokeID: v.Type<string>;
|
|
78
78
|
}, undefined>]>, v.TupleType<[v.Type<"pokeEnd">, v.ObjectType<{
|
|
79
79
|
pokeID: v.Type<string>;
|
|
80
80
|
cookie: v.Type<string>;
|
|
@@ -55,7 +55,7 @@ export declare const pushFailedBodySchema: v.UnionType<[v.ObjectType<Omit<{
|
|
|
55
55
|
message: v.Type<string>;
|
|
56
56
|
}, "reason" | "origin"> & {
|
|
57
57
|
origin: v.Type<"zeroCache">;
|
|
58
|
-
reason: v.Type<"parse" | "
|
|
58
|
+
reason: v.Type<"parse" | "timeout" | "internal">;
|
|
59
59
|
}, undefined>]>;
|
|
60
60
|
export declare const transformFailedBodySchema: v.UnionType<[v.ObjectType<Omit<{
|
|
61
61
|
kind: v.Type<"TransformFailed">;
|
|
@@ -91,7 +91,7 @@ export declare const transformFailedBodySchema: v.UnionType<[v.ObjectType<Omit<{
|
|
|
91
91
|
message: v.Type<string>;
|
|
92
92
|
}, "reason" | "origin"> & {
|
|
93
93
|
origin: v.Type<"zeroCache">;
|
|
94
|
-
reason: v.Type<"parse" | "
|
|
94
|
+
reason: v.Type<"parse" | "timeout" | "internal">;
|
|
95
95
|
}, undefined>]>;
|
|
96
96
|
export declare const errorBodySchema: v.UnionType<[v.ObjectType<{
|
|
97
97
|
kind: v.Type<"AuthInvalidated" | "ClientNotFound" | "InvalidConnectionRequest" | "InvalidConnectionRequestBaseCookie" | "InvalidConnectionRequestLastMutationID" | "InvalidConnectionRequestClientDeleted" | "InvalidMessage" | "InvalidPush" | "MutationFailed" | "MutationRateLimited" | "Unauthorized" | "VersionNotSupported" | "SchemaVersionNotSupported" | "Internal">;
|
|
@@ -150,7 +150,7 @@ export declare const errorBodySchema: v.UnionType<[v.ObjectType<{
|
|
|
150
150
|
message: v.Type<string>;
|
|
151
151
|
}, "reason" | "origin"> & {
|
|
152
152
|
origin: v.Type<"zeroCache">;
|
|
153
|
-
reason: v.Type<"parse" | "
|
|
153
|
+
reason: v.Type<"parse" | "timeout" | "internal">;
|
|
154
154
|
}, undefined>]>, v.UnionType<[v.ObjectType<Omit<{
|
|
155
155
|
kind: v.Type<"TransformFailed">;
|
|
156
156
|
details: v.Optional<import("../../shared/src/json.ts").ReadonlyJSONValue>;
|
|
@@ -185,7 +185,7 @@ export declare const errorBodySchema: v.UnionType<[v.ObjectType<{
|
|
|
185
185
|
message: v.Type<string>;
|
|
186
186
|
}, "reason" | "origin"> & {
|
|
187
187
|
origin: v.Type<"zeroCache">;
|
|
188
|
-
reason: v.Type<"parse" | "
|
|
188
|
+
reason: v.Type<"parse" | "timeout" | "internal">;
|
|
189
189
|
}, undefined>]>]>;
|
|
190
190
|
export type BackoffBody = v.Infer<typeof backoffBodySchema>;
|
|
191
191
|
export type PushFailedBody = v.Infer<typeof pushFailedBodySchema>;
|
|
@@ -59,6 +59,6 @@ var inspectErrorDownSchema = inspectBaseDownSchema.extend({
|
|
|
59
59
|
var inspectDownBodySchema = valita_exports.union(inspectQueriesDownSchema, inspectMetricsDownSchema, inspectVersionDownSchema, inspectAuthenticatedDownSchema, inspectAnalyzeQueryDownSchema, inspectErrorDownSchema);
|
|
60
60
|
var inspectDownMessageSchema = valita_exports.tuple([valita_exports.literal("inspect"), inspectDownBodySchema]);
|
|
61
61
|
//#endregion
|
|
62
|
-
export { inspectAnalyzeQueryDownSchema, inspectAuthenticatedDownSchema, inspectDownMessageSchema, inspectMetricsDownSchema, inspectQueriesDownSchema, inspectVersionDownSchema };
|
|
62
|
+
export { inspectAnalyzeQueryDownSchema, inspectAuthenticatedDownSchema, inspectDownMessageSchema, inspectErrorDownSchema, inspectMetricsDownSchema, inspectQueriesDownSchema, inspectVersionDownSchema };
|
|
63
63
|
|
|
64
64
|
//# sourceMappingURL=inspect-down.js.map
|
|
@@ -73,7 +73,7 @@ export declare const mutateResponseSchema: v.UnionType<[v.ObjectType<{
|
|
|
73
73
|
message: v.Type<string>;
|
|
74
74
|
}, "reason" | "origin"> & {
|
|
75
75
|
origin: v.Type<"zeroCache">;
|
|
76
|
-
reason: v.Type<"parse" | "
|
|
76
|
+
reason: v.Type<"parse" | "timeout" | "internal">;
|
|
77
77
|
}, undefined>]>, v.UnionType<[v.ObjectType<{
|
|
78
78
|
mutations: v.ArrayType<v.ObjectType<{
|
|
79
79
|
id: v.ObjectType<{
|
|
@@ -152,7 +152,7 @@ export declare const mutateResponseSchema: v.UnionType<[v.ObjectType<{
|
|
|
152
152
|
message: v.Type<string>;
|
|
153
153
|
}, "reason" | "origin"> & {
|
|
154
154
|
origin: v.Type<"zeroCache">;
|
|
155
|
-
reason: v.Type<"parse" | "
|
|
155
|
+
reason: v.Type<"parse" | "timeout" | "internal">;
|
|
156
156
|
}, undefined>]>]>]>;
|
|
157
157
|
export type MutateResponse = v.Infer<typeof mutateResponseSchema>;
|
|
158
158
|
/**
|
|
@@ -11,12 +11,14 @@ import * as v from '../../shared/src/valita.ts';
|
|
|
11
11
|
* A poke begins with a `poke-start` message which contains the `baseCookie`
|
|
12
12
|
* the poke is updating from and the `cookie` the poke is updating to.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Through protocol version 51, the poke continues with zero to many
|
|
15
|
+
* `poke-part` JSON messages. Starting in version 52, it continues with zero to
|
|
16
|
+
* many binary `pokeChunk` messages. Each binary message starts with a message
|
|
17
|
+
* type byte. Concatenating and decoding the payload after that byte produces a
|
|
18
|
+
* PokePartBody array. pokeChunk boundaries have no semantic meaning.
|
|
17
19
|
*
|
|
18
|
-
* Finally, the poke ends with a `poke-end` message.
|
|
19
|
-
*
|
|
20
|
+
* Finally, the poke ends with a `poke-end` message. The decoded patches can
|
|
21
|
+
* now be applied as a whole to update from `baseCookie` to `cookie`.
|
|
20
22
|
*
|
|
21
23
|
* Poke messages can be intermingled with other `down` messages, but cannot be
|
|
22
24
|
* intermingled with poke messages for a different `pokeID`. If this is
|
|
@@ -37,7 +39,6 @@ export declare const pokeStartBodySchema: v.ObjectType<{
|
|
|
37
39
|
timestamp: v.Optional<number>;
|
|
38
40
|
}, undefined>;
|
|
39
41
|
export declare const pokePartBodySchema: v.ObjectType<{
|
|
40
|
-
pokeID: v.Type<string>;
|
|
41
42
|
lastMutationIDChanges: v.Optional<Record<string, number>>;
|
|
42
43
|
desiredQueriesPatches: v.Optional<Record<string, ({
|
|
43
44
|
ttl?: number | undefined;
|
|
@@ -101,7 +102,79 @@ export declare const pokePartBodySchema: v.ObjectType<{
|
|
|
101
102
|
clientID: string;
|
|
102
103
|
};
|
|
103
104
|
})[]>;
|
|
105
|
+
pokeID: v.Type<string>;
|
|
104
106
|
}, undefined>;
|
|
107
|
+
/**
|
|
108
|
+
* The logical payload carried by binary poke chunks. Chunk boundaries are
|
|
109
|
+
* arbitrary; concatenating and decoding all chunks for a poke produces this
|
|
110
|
+
* array.
|
|
111
|
+
*/
|
|
112
|
+
export declare const pokePartsSchema: v.ArrayType<v.ObjectType<{
|
|
113
|
+
lastMutationIDChanges: v.Optional<Record<string, number>>;
|
|
114
|
+
desiredQueriesPatches: v.Optional<Record<string, ({
|
|
115
|
+
ttl?: number | undefined;
|
|
116
|
+
op: "put";
|
|
117
|
+
hash: string;
|
|
118
|
+
} | {
|
|
119
|
+
op: "del";
|
|
120
|
+
hash: string;
|
|
121
|
+
} | {
|
|
122
|
+
op: "clear";
|
|
123
|
+
})[]>>;
|
|
124
|
+
gotQueriesPatch: v.Optional<({
|
|
125
|
+
ttl?: number | undefined;
|
|
126
|
+
op: "put";
|
|
127
|
+
hash: string;
|
|
128
|
+
} | {
|
|
129
|
+
op: "del";
|
|
130
|
+
hash: string;
|
|
131
|
+
} | {
|
|
132
|
+
op: "clear";
|
|
133
|
+
})[]>;
|
|
134
|
+
rowsPatch: v.Optional<({
|
|
135
|
+
op: "put";
|
|
136
|
+
tableName: string;
|
|
137
|
+
value: Readonly<Record<string, import("../../shared/src/json.ts").ReadonlyJSONValue | undefined>>;
|
|
138
|
+
} | {
|
|
139
|
+
merge?: import("../../shared/src/json.ts").ReadonlyJSONObject | undefined;
|
|
140
|
+
constrain?: string[] | undefined;
|
|
141
|
+
op: "update";
|
|
142
|
+
tableName: string;
|
|
143
|
+
id: Readonly<Record<string, string | number | boolean>>;
|
|
144
|
+
} | {
|
|
145
|
+
op: "del";
|
|
146
|
+
tableName: string;
|
|
147
|
+
id: Readonly<Record<string, string | number | boolean>>;
|
|
148
|
+
} | {
|
|
149
|
+
op: "clear";
|
|
150
|
+
})[]>;
|
|
151
|
+
mutationsPatch: v.Optional<({
|
|
152
|
+
op: "put";
|
|
153
|
+
mutation: {
|
|
154
|
+
id: {
|
|
155
|
+
id: number;
|
|
156
|
+
clientID: string;
|
|
157
|
+
};
|
|
158
|
+
result: {
|
|
159
|
+
message?: string | undefined;
|
|
160
|
+
details?: import("../../shared/src/json.ts").ReadonlyJSONValue | undefined;
|
|
161
|
+
error: "app";
|
|
162
|
+
} | {
|
|
163
|
+
details?: import("../../shared/src/json.ts").ReadonlyJSONValue | undefined;
|
|
164
|
+
error: "oooMutation" | "alreadyProcessed";
|
|
165
|
+
} | {
|
|
166
|
+
data?: import("../../shared/src/json.ts").ReadonlyJSONValue | undefined;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
} | {
|
|
170
|
+
op: "del";
|
|
171
|
+
id: {
|
|
172
|
+
id: number;
|
|
173
|
+
clientID: string;
|
|
174
|
+
};
|
|
175
|
+
})[]>;
|
|
176
|
+
pokeID: v.Type<string>;
|
|
177
|
+
}, undefined>>;
|
|
105
178
|
export declare const pokeEndBodySchema: v.ObjectType<{
|
|
106
179
|
pokeID: v.Type<string>;
|
|
107
180
|
cookie: v.Type<string>;
|
|
@@ -121,7 +194,6 @@ export declare const pokeStartMessageSchema: v.TupleType<[v.Type<"pokeStart">, v
|
|
|
121
194
|
timestamp: v.Optional<number>;
|
|
122
195
|
}, undefined>]>;
|
|
123
196
|
export declare const pokePartMessageSchema: v.TupleType<[v.Type<"pokePart">, v.ObjectType<{
|
|
124
|
-
pokeID: v.Type<string>;
|
|
125
197
|
lastMutationIDChanges: v.Optional<Record<string, number>>;
|
|
126
198
|
desiredQueriesPatches: v.Optional<Record<string, ({
|
|
127
199
|
ttl?: number | undefined;
|
|
@@ -185,6 +257,7 @@ export declare const pokePartMessageSchema: v.TupleType<[v.Type<"pokePart">, v.O
|
|
|
185
257
|
clientID: string;
|
|
186
258
|
};
|
|
187
259
|
})[]>;
|
|
260
|
+
pokeID: v.Type<string>;
|
|
188
261
|
}, undefined>]>;
|
|
189
262
|
export declare const pokeEndMessageSchema: v.TupleType<[v.Type<"pokeEnd">, v.ObjectType<{
|
|
190
263
|
pokeID: v.Type<string>;
|
|
@@ -193,7 +266,16 @@ export declare const pokeEndMessageSchema: v.TupleType<[v.Type<"pokeEnd">, v.Obj
|
|
|
193
266
|
}, undefined>]>;
|
|
194
267
|
export type PokeStartBody = v.Infer<typeof pokeStartBodySchema>;
|
|
195
268
|
export type PokePartBody = v.Infer<typeof pokePartBodySchema>;
|
|
269
|
+
export type PokeParts = v.Infer<typeof pokePartsSchema>;
|
|
196
270
|
export type PokeEndBody = v.Infer<typeof pokeEndBodySchema>;
|
|
271
|
+
/** The first byte identifying a binary WebSocket message as a poke chunk. */
|
|
272
|
+
export declare const POKE_CHUNK_MESSAGE_TYPE = 0;
|
|
273
|
+
/** The first protocol version that receives binary poke chunks. */
|
|
274
|
+
export declare const POKE_CHUNK_PROTOCOL_VERSION = 52;
|
|
275
|
+
/** The last protocol version that receives JSON pokePart messages. */
|
|
276
|
+
export declare const LAST_POKE_PART_PROTOCOL_VERSION = 51;
|
|
277
|
+
/** A tagged binary poke chunk WebSocket message. */
|
|
278
|
+
export type PokeChunk = Uint8Array;
|
|
197
279
|
export type PokeStartMessage = v.Infer<typeof pokeStartMessageSchema>;
|
|
198
280
|
export type PokePartMessage = v.Infer<typeof pokePartMessageSchema>;
|
|
199
281
|
export type PokeEndMessage = v.Infer<typeof pokeEndMessageSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poke.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/poke.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAMhD
|
|
1
|
+
{"version":3,"file":"poke.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/poke.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAMhD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,eAAO,MAAM,mBAAmB;;;IAM9B;;;OAGG;;;;;;aAQH,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAa7B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAA8B,CAAC;AAE3D,eAAO,MAAM,iBAAiB;;;;aAO5B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;IA5CjC;;;OAGG;;;;;;eA4CH,CAAC;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAGhC,CAAC;AACH,eAAO,MAAM,oBAAoB;;;;eAG/B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AACxD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,6EAA6E;AAC7E,eAAO,MAAM,uBAAuB,IAAO,CAAC;AAE5C,mEAAmE;AACnE,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C,sEAAsE;AACtE,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAElD,oDAAoD;AACpD,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC;AAEnC,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -16,12 +16,14 @@ import { nullableVersionSchema, versionSchema } from "./version.js";
|
|
|
16
16
|
* A poke begins with a `poke-start` message which contains the `baseCookie`
|
|
17
17
|
* the poke is updating from and the `cookie` the poke is updating to.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Through protocol version 51, the poke continues with zero to many
|
|
20
|
+
* `poke-part` JSON messages. Starting in version 52, it continues with zero to
|
|
21
|
+
* many binary `pokeChunk` messages. Each binary message starts with a message
|
|
22
|
+
* type byte. Concatenating and decoding the payload after that byte produces a
|
|
23
|
+
* PokePartBody array. pokeChunk boundaries have no semantic meaning.
|
|
22
24
|
*
|
|
23
|
-
* Finally, the poke ends with a `poke-end` message.
|
|
24
|
-
*
|
|
25
|
+
* Finally, the poke ends with a `poke-end` message. The decoded patches can
|
|
26
|
+
* now be applied as a whole to update from `baseCookie` to `cookie`.
|
|
25
27
|
*
|
|
26
28
|
* Poke messages can be intermingled with other `down` messages, but cannot be
|
|
27
29
|
* intermingled with poke messages for a different `pokeID`. If this is
|
|
@@ -42,13 +44,19 @@ var pokeStartBodySchema = valita_exports.object({
|
|
|
42
44
|
timestamp: valita_exports.number().optional()
|
|
43
45
|
});
|
|
44
46
|
var pokePartBodySchema = valita_exports.object({
|
|
45
|
-
pokeID: valita_exports.string(),
|
|
46
47
|
lastMutationIDChanges: valita_exports.record(valita_exports.number()).optional(),
|
|
47
48
|
desiredQueriesPatches: valita_exports.record(queriesPatchSchema).optional(),
|
|
48
49
|
gotQueriesPatch: queriesPatchSchema.optional(),
|
|
49
50
|
rowsPatch: rowsPatchSchema.optional(),
|
|
50
|
-
mutationsPatch: mutationsPatchSchema.optional()
|
|
51
|
+
mutationsPatch: mutationsPatchSchema.optional(),
|
|
52
|
+
pokeID: valita_exports.string()
|
|
51
53
|
});
|
|
54
|
+
/**
|
|
55
|
+
* The logical payload carried by binary poke chunks. Chunk boundaries are
|
|
56
|
+
* arbitrary; concatenating and decoding all chunks for a poke produces this
|
|
57
|
+
* array.
|
|
58
|
+
*/
|
|
59
|
+
var pokePartsSchema = valita_exports.array(pokePartBodySchema);
|
|
52
60
|
var pokeEndBodySchema = valita_exports.object({
|
|
53
61
|
pokeID: valita_exports.string(),
|
|
54
62
|
cookie: versionSchema,
|
|
@@ -58,6 +66,6 @@ var pokeStartMessageSchema = valita_exports.tuple([valita_exports.literal("pokeS
|
|
|
58
66
|
var pokePartMessageSchema = valita_exports.tuple([valita_exports.literal("pokePart"), pokePartBodySchema]);
|
|
59
67
|
var pokeEndMessageSchema = valita_exports.tuple([valita_exports.literal("pokeEnd"), pokeEndBodySchema]);
|
|
60
68
|
//#endregion
|
|
61
|
-
export { pokeEndMessageSchema, pokePartMessageSchema, pokeStartMessageSchema };
|
|
69
|
+
export { pokeEndMessageSchema, pokePartMessageSchema, pokePartsSchema, pokeStartMessageSchema };
|
|
62
70
|
|
|
63
71
|
//# sourceMappingURL=poke.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poke.js","names":[],"sources":["../../../../zero-protocol/src/poke.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {mutationsPatchSchema} from './mutations-patch.ts';\nimport {queriesPatchSchema} from './queries-patch.ts';\nimport {rowsPatchSchema} from './row-patch.ts';\nimport {nullableVersionSchema, versionSchema} from './version.ts';\n\n/**\n * Pokes use a multi-part format. Pokes send entity data to the client and can\n * be multiple mega-bytes in size. Using a multi-part format allows the server\n * to avoid having to have the full poke in memory at one time.\n *\n * Each poke is assigned a `pokeID`, a unique id (within the context of the\n * connection) for identifying the poke. All messages for a poke will have the\n * same `pokeID`.\n *\n * A poke begins with a `poke-start` message which contains the `baseCookie`\n * the poke is updating from and the `cookie` the poke is updating to.\n *\n *
|
|
1
|
+
{"version":3,"file":"poke.js","names":[],"sources":["../../../../zero-protocol/src/poke.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {mutationsPatchSchema} from './mutations-patch.ts';\nimport {queriesPatchSchema} from './queries-patch.ts';\nimport {rowsPatchSchema} from './row-patch.ts';\nimport {nullableVersionSchema, versionSchema} from './version.ts';\n\n/**\n * Pokes use a multi-part format. Pokes send entity data to the client and can\n * be multiple mega-bytes in size. Using a multi-part format allows the server\n * to avoid having to have the full poke in memory at one time.\n *\n * Each poke is assigned a `pokeID`, a unique id (within the context of the\n * connection) for identifying the poke. All messages for a poke will have the\n * same `pokeID`.\n *\n * A poke begins with a `poke-start` message which contains the `baseCookie`\n * the poke is updating from and the `cookie` the poke is updating to.\n *\n * Through protocol version 51, the poke continues with zero to many\n * `poke-part` JSON messages. Starting in version 52, it continues with zero to\n * many binary `pokeChunk` messages. Each binary message starts with a message\n * type byte. Concatenating and decoding the payload after that byte produces a\n * PokePartBody array. pokeChunk boundaries have no semantic meaning.\n *\n * Finally, the poke ends with a `poke-end` message. The decoded patches can\n * now be applied as a whole to update from `baseCookie` to `cookie`.\n *\n * Poke messages can be intermingled with other `down` messages, but cannot be\n * intermingled with poke messages for a different `pokeID`. If this is\n * observed it is an unexpected error; the client should ignore both pokes,\n * disconnect, and reconnect.\n */\n\nexport const pokeStartBodySchema = v.object({\n pokeID: v.string(),\n // We always specify a Version as our cookie, but Replicache starts clients\n // with initial cookie `null`, before the first request. So we have to be\n // able to send a base cookie with value `null` to match that state.\n baseCookie: nullableVersionSchema,\n /**\n * This field is always set if the poke contains a `rowsPatch`.\n * It may be absent for patches that only update clients and queries.\n */\n schemaVersions: v\n .object({\n minSupportedVersion: v.number(),\n maxSupportedVersion: v.number(),\n })\n .optional(),\n timestamp: v.number().optional(),\n});\n\nexport const pokePartBodySchema = v.object({\n // Changes to last mutation id by client id.\n lastMutationIDChanges: v.record(v.number()).optional(),\n // Patches to the desired query sets by client id.\n desiredQueriesPatches: v.record(queriesPatchSchema).optional(),\n // Patches to the set of queries for which entities are sync'd in\n // rowsPatch.\n gotQueriesPatch: queriesPatchSchema.optional(),\n // Patches to the rows set.\n rowsPatch: rowsPatchSchema.optional(),\n // Mutation results patch\n mutationsPatch: mutationsPatchSchema.optional(),\n pokeID: v.string(),\n});\n\n/**\n * The logical payload carried by binary poke chunks. Chunk boundaries are\n * arbitrary; concatenating and decoding all chunks for a poke produces this\n * array.\n */\nexport const pokePartsSchema = v.array(pokePartBodySchema);\n\nexport const pokeEndBodySchema = v.object({\n pokeID: v.string(),\n // Note: This should be ignored (and may be empty) if cancel === `true`.\n cookie: versionSchema,\n // If `true`, the poke with id `pokeID` should be discarded without\n // applying it.\n cancel: v.boolean().optional(),\n});\n\nexport const pokeStartMessageSchema = v.tuple([\n v.literal('pokeStart'),\n pokeStartBodySchema,\n]);\nexport const pokePartMessageSchema = v.tuple([\n v.literal('pokePart'),\n pokePartBodySchema,\n]);\nexport const pokeEndMessageSchema = v.tuple([\n v.literal('pokeEnd'),\n pokeEndBodySchema,\n]);\n\nexport type PokeStartBody = v.Infer<typeof pokeStartBodySchema>;\nexport type PokePartBody = v.Infer<typeof pokePartBodySchema>;\nexport type PokeParts = v.Infer<typeof pokePartsSchema>;\nexport type PokeEndBody = v.Infer<typeof pokeEndBodySchema>;\n\n/** The first byte identifying a binary WebSocket message as a poke chunk. */\nexport const POKE_CHUNK_MESSAGE_TYPE = 0x00;\n\n/** The first protocol version that receives binary poke chunks. */\nexport const POKE_CHUNK_PROTOCOL_VERSION = 52;\n\n/** The last protocol version that receives JSON pokePart messages. */\nexport const LAST_POKE_PART_PROTOCOL_VERSION = 51;\n\n/** A tagged binary poke chunk WebSocket message. */\nexport type PokeChunk = Uint8Array;\n\nexport type PokeStartMessage = v.Infer<typeof pokeStartMessageSchema>;\nexport type PokePartMessage = v.Infer<typeof pokePartMessageSchema>;\nexport type PokeEndMessage = v.Infer<typeof pokeEndMessageSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAa,sBAAsB,eAAE,OAAO;CAC1C,QAAQ,eAAE,OAAO;CAIjB,YAAY;;;;;CAKZ,gBAAgB,eACb,OAAO;EACN,qBAAqB,eAAE,OAAO;EAC9B,qBAAqB,eAAE,OAAO;CAChC,CAAC,EACA,SAAS;CACZ,WAAW,eAAE,OAAO,EAAE,SAAS;AACjC,CAAC;AAED,IAAa,qBAAqB,eAAE,OAAO;CAEzC,uBAAuB,eAAE,OAAO,eAAE,OAAO,CAAC,EAAE,SAAS;CAErD,uBAAuB,eAAE,OAAO,kBAAkB,EAAE,SAAS;CAG7D,iBAAiB,mBAAmB,SAAS;CAE7C,WAAW,gBAAgB,SAAS;CAEpC,gBAAgB,qBAAqB,SAAS;CAC9C,QAAQ,eAAE,OAAO;AACnB,CAAC;;;;;;AAOD,IAAa,kBAAkB,eAAE,MAAM,kBAAkB;AAEzD,IAAa,oBAAoB,eAAE,OAAO;CACxC,QAAQ,eAAE,OAAO;CAEjB,QAAQ;CAGR,QAAQ,eAAE,QAAQ,EAAE,SAAS;AAC/B,CAAC;AAED,IAAa,yBAAyB,eAAE,MAAM,CAC5C,eAAE,QAAQ,WAAW,GACrB,mBACF,CAAC;AACD,IAAa,wBAAwB,eAAE,MAAM,CAC3C,eAAE,QAAQ,UAAU,GACpB,kBACF,CAAC;AACD,IAAa,uBAAuB,eAAE,MAAM,CAC1C,eAAE,QAAQ,SAAS,GACnB,iBACF,CAAC"}
|
|
@@ -10,15 +10,20 @@
|
|
|
10
10
|
* release. The server (`zero-cache`) must be deployed before clients start
|
|
11
11
|
* running the new code.
|
|
12
12
|
*/
|
|
13
|
-
export declare const PROTOCOL_VERSION =
|
|
13
|
+
export declare const PROTOCOL_VERSION = 52;
|
|
14
14
|
/**
|
|
15
15
|
* The minimum server-supported sync protocol version (i.e. the version
|
|
16
|
-
* declared in the "/sync/v{#}/connect" URL).
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
16
|
+
* declared in the "/sync/v{#}/connect" URL).
|
|
17
|
+
*
|
|
18
|
+
* CloudZero can serve applications running old client releases indefinitely.
|
|
19
|
+
* Consequently, this value must never be increased: `zero-cache` must continue
|
|
20
|
+
* to support every sync protocol from this version through `PROTOCOL_VERSION`.
|
|
21
|
+
* A wire change that an old client cannot ignore must branch on the client's
|
|
22
|
+
* protocol version and retain the old behavior. Keep each compatibility fork
|
|
23
|
+
* isolated at the boundary that owns the changed behavior and test both sides
|
|
24
|
+
* of its version cutoff.
|
|
25
|
+
*
|
|
26
|
+
* Client connections from protocol versions before this historical floor are
|
|
22
27
|
* closed with a `VersionNotSupported` error.
|
|
23
28
|
*/
|
|
24
29
|
export declare const MIN_SERVER_SUPPORTED_SYNC_PROTOCOL = 30;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-version.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/protocol-version.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"protocol-version.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/protocol-version.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAgDH,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kCAAkC,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-version.js","names":[],"sources":["../../../../zero-protocol/src/protocol-version.ts"],"sourcesContent":["import {assert} from '../../shared/src/asserts.ts';\n\n/**\n * The current `PROTOCOL_VERSION` of the code.\n *\n * The `PROTOCOL_VERSION` encompasses both the wire-protocol of the `/sync/...`\n * connection between the browser and `zero-cache`, as well as the format of\n * the `AST` objects stored in both components (i.e. IDB and CVR).\n *\n * A change in the `AST` schema (e.g. new functionality added) must be\n * accompanied by an increment of the `PROTOCOL_VERSION` and a new major\n * release. The server (`zero-cache`) must be deployed before clients start\n * running the new code.\n */\n// History:\n// -- Version 5 adds support for `pokeEnd.cookie`. (0.14)\n// -- Version 6 makes `pokeStart.cookie` optional. (0.16)\n// -- Version 7 introduces the initConnection.clientSchema field. (0.17)\n// -- Version 8 drops support for Version 5 (0.18).\n// -- Version 11 adds inspect queries. (0.18)\n// -- Version 12 adds 'timestamp' and 'date' types to the ClientSchema ValueType. (not shipped, reversed by version 14)\n// -- Version 14 removes 'timestamp' and 'date' types from the ClientSchema ValueType. (0.18)\n// -- Version 15 adds a `userPushParams` field to `initConnection` (0.19)\n// -- Version 16 adds a new error type (alreadyProcessed) to mutation responses (0.19)\n// -- Version 17 deprecates `AST` in downstream query puts. It was never used anyway. (0.21)\n// -- Version 18 adds `name` and `args` to the `queries-patch` protocol (0.21)\n// -- Version 19 adds `activeClients` to the `initConnection` protocol (0.22)\n// -- Version 20 changes inspector down message (0.22)\n// -- Version 21 removes `AST` in downstream query puts which was deprecated in Version 17, removes support for versions < 18 (0.22)\n// -- Version 22 adds an optional 'userQueryParams' field to `initConnection` (0.22)\n// -- Version 23 add `mutationResults` to poke (0.22)\n// -- Version 24 adds `ackMutationResults` to upstream (0.22).\n// -- version 25 modifies `mutationsResults` to include `del` patches (0.22)\n// -- version 26 adds inspect/metrics and adds metrics to inspect/query (0.23)\n// -- version 27 adds inspect/version (0.23)\n// -- version 28 adds more inspect/metrics (0.23)\n// -- version 29 adds error responses for custom queries (0.23)\n// -- version 30 adds an optional primaryKey to the ClientSchema (0.24)\n// -- version 31 adds admin password authentication to inspector RPC calls (0.24)\n// -- version 32 adds analyze-query to the inspector RPC calls (0.24)\n// -- version 33 adds `flip` to CorrelatedSubquery (0.25)\n// -- version 34 moves `flip` from CorrelatedSubquery to CorrelatedSubqueryCondition (0.25)\n// -- version 35 adds `readRows`, `readRowCountsByQuery` and `readRowCount` to analyze-query result (0.25)\n// -- version 36 changes inspector analyze-query and adds error response to RPC (0.25)\n// -- version 37 adds `elapsed` to AnalyzeQueryResult (0.25)\n// -- version 38 adds structured push/transform error responses (0.25)\n// -- version 39 removes per-transform error types and adds `message` to app error (0.25)\n// -- version 40 adds `dbRowScansByQuery` to AnalyzeQueryResult (0.25)\n// -- version 41 makes ClientSchema.primaryKey required (0.25)\n// -- version 42 adds planner events to AnalyzeQueryResult (0.25)\n// -- version 43 renames `plans` to `sqlitePlans`, `plannerEvents` to `joinPlans`, and `plannerDebug` option to `joinPlans` (0.25)\n// -- version 44 adds profileID to connection URL (0.25)\n// -- version 45 adds userPushHeaders and userQueryHeaders to initConnection (0.25)\n// -- version 46 adds scalarSubquery condition type to AST\n// -- version 47 adds optional auth token to push body\n// -- version 48 adds updateAuth\n// -- version 49 adds `scalar` to CorrelatedSubqueryCondition, removes scalarSubquery\n// -- version 50 adds OTEL headers to push and query messages\n// -- version 51 changes inspector metrics fields\nexport const PROTOCOL_VERSION =
|
|
1
|
+
{"version":3,"file":"protocol-version.js","names":[],"sources":["../../../../zero-protocol/src/protocol-version.ts"],"sourcesContent":["import {assert} from '../../shared/src/asserts.ts';\n\n/**\n * The current `PROTOCOL_VERSION` of the code.\n *\n * The `PROTOCOL_VERSION` encompasses both the wire-protocol of the `/sync/...`\n * connection between the browser and `zero-cache`, as well as the format of\n * the `AST` objects stored in both components (i.e. IDB and CVR).\n *\n * A change in the `AST` schema (e.g. new functionality added) must be\n * accompanied by an increment of the `PROTOCOL_VERSION` and a new major\n * release. The server (`zero-cache`) must be deployed before clients start\n * running the new code.\n */\n// History:\n// -- Version 5 adds support for `pokeEnd.cookie`. (0.14)\n// -- Version 6 makes `pokeStart.cookie` optional. (0.16)\n// -- Version 7 introduces the initConnection.clientSchema field. (0.17)\n// -- Version 8 drops support for Version 5 (0.18).\n// -- Version 11 adds inspect queries. (0.18)\n// -- Version 12 adds 'timestamp' and 'date' types to the ClientSchema ValueType. (not shipped, reversed by version 14)\n// -- Version 14 removes 'timestamp' and 'date' types from the ClientSchema ValueType. (0.18)\n// -- Version 15 adds a `userPushParams` field to `initConnection` (0.19)\n// -- Version 16 adds a new error type (alreadyProcessed) to mutation responses (0.19)\n// -- Version 17 deprecates `AST` in downstream query puts. It was never used anyway. (0.21)\n// -- Version 18 adds `name` and `args` to the `queries-patch` protocol (0.21)\n// -- Version 19 adds `activeClients` to the `initConnection` protocol (0.22)\n// -- Version 20 changes inspector down message (0.22)\n// -- Version 21 removes `AST` in downstream query puts which was deprecated in Version 17, removes support for versions < 18 (0.22)\n// -- Version 22 adds an optional 'userQueryParams' field to `initConnection` (0.22)\n// -- Version 23 add `mutationResults` to poke (0.22)\n// -- Version 24 adds `ackMutationResults` to upstream (0.22).\n// -- version 25 modifies `mutationsResults` to include `del` patches (0.22)\n// -- version 26 adds inspect/metrics and adds metrics to inspect/query (0.23)\n// -- version 27 adds inspect/version (0.23)\n// -- version 28 adds more inspect/metrics (0.23)\n// -- version 29 adds error responses for custom queries (0.23)\n// -- version 30 adds an optional primaryKey to the ClientSchema (0.24)\n// -- version 31 adds admin password authentication to inspector RPC calls (0.24)\n// -- version 32 adds analyze-query to the inspector RPC calls (0.24)\n// -- version 33 adds `flip` to CorrelatedSubquery (0.25)\n// -- version 34 moves `flip` from CorrelatedSubquery to CorrelatedSubqueryCondition (0.25)\n// -- version 35 adds `readRows`, `readRowCountsByQuery` and `readRowCount` to analyze-query result (0.25)\n// -- version 36 changes inspector analyze-query and adds error response to RPC (0.25)\n// -- version 37 adds `elapsed` to AnalyzeQueryResult (0.25)\n// -- version 38 adds structured push/transform error responses (0.25)\n// -- version 39 removes per-transform error types and adds `message` to app error (0.25)\n// -- version 40 adds `dbRowScansByQuery` to AnalyzeQueryResult (0.25)\n// -- version 41 makes ClientSchema.primaryKey required (0.25)\n// -- version 42 adds planner events to AnalyzeQueryResult (0.25)\n// -- version 43 renames `plans` to `sqlitePlans`, `plannerEvents` to `joinPlans`, and `plannerDebug` option to `joinPlans` (0.25)\n// -- version 44 adds profileID to connection URL (0.25)\n// -- version 45 adds userPushHeaders and userQueryHeaders to initConnection (0.25)\n// -- version 46 adds scalarSubquery condition type to AST\n// -- version 47 adds optional auth token to push body\n// -- version 48 adds updateAuth\n// -- version 49 adds `scalar` to CorrelatedSubqueryCondition, removes scalarSubquery\n// -- version 50 adds OTEL headers to push and query messages\n// -- version 51 changes inspector metrics fields\n// -- version 52 replaces JSON pokePart messages with binary poke chunks for\n// clients using protocol version 52 or newer. Older clients retain pokePart.\nexport const PROTOCOL_VERSION = 52;\n\n/**\n * The minimum server-supported sync protocol version (i.e. the version\n * declared in the \"/sync/v{#}/connect\" URL).\n *\n * CloudZero can serve applications running old client releases indefinitely.\n * Consequently, this value must never be increased: `zero-cache` must continue\n * to support every sync protocol from this version through `PROTOCOL_VERSION`.\n * A wire change that an old client cannot ignore must branch on the client's\n * protocol version and retain the old behavior. Keep each compatibility fork\n * isolated at the boundary that owns the changed behavior and test both sides\n * of its version cutoff.\n *\n * Client connections from protocol versions before this historical floor are\n * closed with a `VersionNotSupported` error.\n */\nexport const MIN_SERVER_SUPPORTED_SYNC_PROTOCOL = 30;\n\nassert(\n MIN_SERVER_SUPPORTED_SYNC_PROTOCOL < PROTOCOL_VERSION,\n 'MIN_SERVER_SUPPORTED_SYNC_PROTOCOL must be less than PROTOCOL_VERSION',\n);\n"],"mappings":";AAgFA,OAAA,MAEE,uEACF"}
|
|
@@ -307,7 +307,7 @@ export declare const pushResponseSchema: v.UnionType<[v.UnionType<[v.ObjectType<
|
|
|
307
307
|
message: v.Type<string>;
|
|
308
308
|
}, "reason" | "origin"> & {
|
|
309
309
|
origin: v.Type<"zeroCache">;
|
|
310
|
-
reason: v.Type<"parse" | "
|
|
310
|
+
reason: v.Type<"parse" | "timeout" | "internal">;
|
|
311
311
|
}, undefined>]>]>;
|
|
312
312
|
export declare const pushResponseMessageSchema: v.TupleType<[v.Type<"pushResponse">, v.UnionType<[v.ObjectType<{
|
|
313
313
|
mutations: v.ArrayType<v.ObjectType<{
|
|
@@ -102,7 +102,7 @@ export declare const queryResponseSchema: v.UnionType<[v.ObjectType<{
|
|
|
102
102
|
message: v.Type<string>;
|
|
103
103
|
}, "reason" | "origin"> & {
|
|
104
104
|
origin: v.Type<"zeroCache">;
|
|
105
|
-
reason: v.Type<"parse" | "
|
|
105
|
+
reason: v.Type<"parse" | "timeout" | "internal">;
|
|
106
106
|
}, undefined>]>, v.UnionType<[v.TupleType<[v.Type<"transformed">, v.ArrayType<v.UnionType<[v.ObjectType<{
|
|
107
107
|
id: v.Type<string>;
|
|
108
108
|
name: v.Type<string>;
|
|
@@ -144,7 +144,7 @@ export declare const queryResponseSchema: v.UnionType<[v.ObjectType<{
|
|
|
144
144
|
message: v.Type<string>;
|
|
145
145
|
}, "reason" | "origin"> & {
|
|
146
146
|
origin: v.Type<"zeroCache">;
|
|
147
|
-
reason: v.Type<"parse" | "
|
|
147
|
+
reason: v.Type<"parse" | "timeout" | "internal">;
|
|
148
148
|
}, undefined>]>]>]>]>;
|
|
149
149
|
export type QueryResponse = v.Infer<typeof queryResponseSchema>;
|
|
150
150
|
//# sourceMappingURL=query-server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-view.d.ts","sourceRoot":"","sources":["../../../../../zql/src/ivm/array-view.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,8CAA8C,CAAC;AAC/E,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,EAAC,QAAQ,EAAc,SAAS,EAAC,MAAM,wBAAwB,CAAC;AAG5E,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,EAAa,KAAK,KAAK,EAAE,KAAK,MAAM,EAAC,MAAM,eAAe,CAAC;AAGlE,OAAO,KAAK,EAAQ,MAAM,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AA0BnD;;;;;;;;;;GAUG;AACH,qBAAa,SAAS,CAAC,CAAC,SAAS,IAAI,CAAE,YAAW,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;;
|
|
1
|
+
{"version":3,"file":"array-view.d.ts","sourceRoot":"","sources":["../../../../../zql/src/ivm/array-view.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,8CAA8C,CAAC;AAC/E,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,EAAC,QAAQ,EAAc,SAAS,EAAC,MAAM,wBAAwB,CAAC;AAG5E,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,EAAa,KAAK,KAAK,EAAE,KAAK,MAAM,EAAC,MAAM,eAAe,CAAC;AAGlE,OAAO,KAAK,EAAQ,MAAM,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AA0BnD;;;;;;;;;;GAUG;AACH,qBAAa,SAAS,CAAC,CAAC,SAAS,IAAI,CAAE,YAAW,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;;IAgBpE,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;gBAelC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,IAAI,GAAG,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,EAClD,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI;IA4B/B,IAAI,IAAI,IACmB,CAAC,CAC3B;IAMD,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAqBjC,OAAO;IAuBP,IAAI,CAAC,MAAM,EAAE,MAAM;IAcnB,KAAK;IAYL,SAAS,CAAC,GAAG,EAAE,GAAG;CAGnB"}
|
|
@@ -53,7 +53,6 @@ var ArrayView = class {
|
|
|
53
53
|
#txnDirty = /* @__PURE__ */ new WeakSet();
|
|
54
54
|
constructor(input, format, queryComplete, updateTTL) {
|
|
55
55
|
this.#input = input;
|
|
56
|
-
this.#schema = input.getSchema();
|
|
57
56
|
this.#format = format;
|
|
58
57
|
this.#updateTTL = updateTTL;
|
|
59
58
|
this.#root = { "": format.singular ? void 0 : [] };
|
|
@@ -75,6 +74,9 @@ var ArrayView = class {
|
|
|
75
74
|
get data() {
|
|
76
75
|
return this.#root[""];
|
|
77
76
|
}
|
|
77
|
+
#getSchema() {
|
|
78
|
+
return this.#schema ??= this.#input.getSchema();
|
|
79
|
+
}
|
|
78
80
|
addListener(listener) {
|
|
79
81
|
assert(!this.#listeners.has(listener), "Listener already registered");
|
|
80
82
|
this.#listeners.add(listener);
|
|
@@ -97,12 +99,12 @@ var ArrayView = class {
|
|
|
97
99
|
for (const node of skipYields(this.#input.fetch({}))) this.#root = applyChange(this.#root, {
|
|
98
100
|
type: "add",
|
|
99
101
|
node
|
|
100
|
-
}, this.#
|
|
102
|
+
}, this.#getSchema(), "", this.#format, false, true);
|
|
101
103
|
this.flush();
|
|
102
104
|
}
|
|
103
105
|
push(change) {
|
|
104
106
|
this.#dirty = true;
|
|
105
|
-
this.#root = applyChange(this.#root, changeToViewChange(change), this.#
|
|
107
|
+
this.#root = applyChange(this.#root, changeToViewChange(change), this.#getSchema(), "", this.#format, false, this.#txnDirty);
|
|
106
108
|
return emptyArray;
|
|
107
109
|
}
|
|
108
110
|
flush() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-view.js","names":["#input","#listeners","#
|
|
1
|
+
{"version":3,"file":"array-view.js","names":["#input","#listeners","#format","#updateTTL","#root","#resultType","#error","#fireListeners","#hydrate","#schema","#fireListener","#dirty","#getSchema","#txnDirty"],"sources":["../../../../../zql/src/ivm/array-view.ts"],"sourcesContent":["import {assert} from '../../../shared/src/asserts.ts';\nimport type {Immutable} from '../../../shared/src/immutable.ts';\nimport {emptyArray} from '../../../shared/src/sentinels.ts';\nimport type {ErroredQuery} from '../../../zero-protocol/src/custom-queries.ts';\nimport type {TTL} from '../query/ttl.ts';\nimport type {Listener, ResultType, TypedView} from '../query/typed-view.ts';\nimport {ChangeIndex} from './change-index.ts';\nimport {ChangeType} from './change-type.ts';\nimport type {Change} from './change.ts';\nimport {skipYields, type Input, type Output} from './operator.ts';\nimport type {SourceSchema} from './schema.ts';\nimport {applyChange, type ViewChange} from './view-apply-change.ts';\nimport type {Entry, Format, View} from './view.ts';\n\nfunction changeToViewChange(change: Change): ViewChange {\n switch (change[ChangeIndex.TYPE]) {\n case ChangeType.ADD:\n return {type: 'add', node: change[ChangeIndex.NODE]};\n case ChangeType.REMOVE:\n return {type: 'remove', node: change[ChangeIndex.NODE]};\n case ChangeType.CHILD:\n return {\n type: 'child',\n node: change[ChangeIndex.NODE],\n child: {\n relationshipName: change[ChangeIndex.CHILD_DATA].relationshipName,\n change: changeToViewChange(change[ChangeIndex.CHILD_DATA].change),\n },\n };\n case ChangeType.EDIT:\n return {\n type: 'edit',\n node: change[ChangeIndex.NODE],\n oldNode: change[ChangeIndex.OLD_NODE],\n };\n }\n}\n\n/**\n * Implements a materialized view of the output of an operator.\n *\n * It might seem more efficient to use an immutable b-tree for the\n * materialization, but it's not so clear. Inserts in the middle are\n * asymptotically slower in an array, but can often be done with zero\n * allocations, where changes to the b-tree will often require several allocs.\n *\n * Also the plain array view is more convenient for consumers since you can dump\n * it into console to see what it is, rather than having to iterate it.\n */\nexport class ArrayView<V extends View> implements Output, TypedView<V> {\n readonly #input: Input;\n readonly #listeners = new Set<Listener<V>>();\n // Read lazily: a DeferredInput has no schema until its pipeline is attached,\n // and the schema is only needed once there is a change to apply.\n #schema: SourceSchema | undefined;\n readonly #format: Format;\n\n // Synthetic \"root\" entry that has a single \"\" relationship, so that we can\n // treat all changes, including the root change, generically.\n //\n // applyChange is immutable: it returns a new root, preserving the references\n // of unchanged subtrees so consumers (React.memo / Solid) can skip them. We\n // therefore reassign #root on every change rather than mutating in place.\n #root: Entry;\n\n onDestroy: (() => void) | undefined;\n\n #dirty = false;\n #resultType: ResultType = 'unknown';\n #error: ErroredQuery | undefined;\n readonly #updateTTL: (ttl: TTL) => void;\n\n // Objects/arrays created or cloned during the current (un-flushed)\n // transaction. applyChange may mutate these in place rather than copying\n // again, since they are not yet observed by any listener. Replaced at\n // flush(), after which the committed snapshot must be copied-on-write again.\n // A WeakSet (not a Set) so it never extends the lifetime of transient clones.\n #txnDirty: WeakSet<object> = new WeakSet();\n\n constructor(\n input: Input,\n format: Format,\n queryComplete: true | ErroredQuery | Promise<true>,\n updateTTL: (ttl: TTL) => void,\n ) {\n this.#input = input;\n this.#format = format;\n this.#updateTTL = updateTTL;\n this.#root = {'': format.singular ? undefined : []};\n input.setOutput(this);\n\n if (queryComplete === true) {\n this.#resultType = 'complete';\n } else if ('error' in queryComplete) {\n this.#resultType = 'error';\n this.#error = queryComplete;\n } else {\n void queryComplete\n .then(() => {\n this.#resultType = 'complete';\n this.#fireListeners();\n })\n .catch(e => {\n this.#resultType = 'error';\n this.#error = e;\n this.#fireListeners();\n });\n }\n this.#hydrate();\n }\n\n get data() {\n return this.#root[''] as V;\n }\n\n #getSchema(): SourceSchema {\n return (this.#schema ??= this.#input.getSchema());\n }\n\n addListener(listener: Listener<V>) {\n assert(!this.#listeners.has(listener), 'Listener already registered');\n this.#listeners.add(listener);\n\n this.#fireListener(listener);\n\n return () => {\n this.#listeners.delete(listener);\n };\n }\n\n #fireListeners() {\n for (const listener of this.#listeners) {\n this.#fireListener(listener);\n }\n }\n\n #fireListener(listener: Listener<V>) {\n listener(this.data as Immutable<V>, this.#resultType, this.#error);\n }\n\n destroy() {\n this.onDestroy?.();\n }\n\n #hydrate() {\n this.#dirty = true;\n for (const node of skipYields(this.#input.fetch({}))) {\n this.#root = applyChange(\n this.#root,\n {type: 'add', node},\n this.#getSchema(),\n '',\n this.#format,\n false /* withIDs */,\n true /* mutate: #root is freshly created and not yet observed by any\n consumer, so build it in place to avoid O(N^2) array copies.\n Every later push() is immutable, preserving reference\n stability for unchanged subtrees. */,\n );\n }\n this.flush();\n }\n\n push(change: Change) {\n this.#dirty = true;\n this.#root = applyChange(\n this.#root,\n changeToViewChange(change),\n this.#getSchema(),\n '',\n this.#format,\n false /* withIDs */,\n this.#txnDirty /* mutate: copy-on-write within this transaction */,\n );\n return emptyArray;\n }\n\n flush() {\n if (!this.#dirty) {\n return;\n }\n this.#dirty = false;\n this.#fireListeners();\n // The snapshot just handed to listeners is now observed; the next\n // transaction must copy-on-write rather than mutate these objects. A fresh\n // WeakSet drops all \"owned\" marks (WeakSet has no clear()).\n this.#txnDirty = new WeakSet();\n }\n\n updateTTL(ttl: TTL) {\n this.#updateTTL(ttl);\n }\n}\n"],"mappings":";;;;;AAcA,SAAS,mBAAmB,QAA4B;CACtD,QAAQ,OAAO,IAAf;EACE,KAAK,GACH,OAAO;GAAC,MAAM;GAAO,MAAM,OAAO;EAAiB;EACrD,KAAK,GACH,OAAO;GAAC,MAAM;GAAU,MAAM,OAAO;EAAiB;EACxD,KAAK,GACH,OAAO;GACL,MAAM;GACN,MAAM,OAAO;GACb,OAAO;IACL,kBAAkB,OAAO,GAAwB;IACjD,QAAQ,mBAAmB,OAAO,GAAwB,MAAM;GAClE;EACF;EACF,KAAK,GACH,OAAO;GACL,MAAM;GACN,MAAM,OAAO;GACb,SAAS,OAAO;EAClB;CACJ;AACF;;;;;;;;;;;;AAaA,IAAa,YAAb,MAAuE;CACrE;CACA,6BAAsB,IAAI,IAAiB;CAG3C;CACA;CAQA;CAEA;CAEA,SAAS;CACT,cAA0B;CAC1B;CACA;CAOA,4BAA6B,IAAI,QAAQ;CAEzC,YACE,OACA,QACA,eACA,WACA;EACA,KAAKA,SAAS;EACd,KAAKE,UAAU;EACf,KAAKC,aAAa;EAClB,KAAKC,QAAQ,EAAC,IAAI,OAAO,WAAW,KAAA,IAAY,CAAC,EAAC;EAClD,MAAM,UAAU,IAAI;EAEpB,IAAI,kBAAkB,MACpB,KAAKC,cAAc;OACd,IAAI,WAAW,eAAe;GACnC,KAAKA,cAAc;GACnB,KAAKC,SAAS;EAChB,OACE,cACG,WAAW;GACV,KAAKD,cAAc;GACnB,KAAKE,eAAe;EACtB,CAAC,EACA,OAAM,MAAK;GACV,KAAKF,cAAc;GACnB,KAAKC,SAAS;GACd,KAAKC,eAAe;EACtB,CAAC;EAEL,KAAKC,SAAS;CAChB;CAEA,IAAI,OAAO;EACT,OAAO,KAAKJ,MAAM;CACpB;CAEA,aAA2B;EACzB,OAAQ,KAAKK,YAAY,KAAKT,OAAO,UAAU;CACjD;CAEA,YAAY,UAAuB;EACjC,OAAO,CAAC,KAAKC,WAAW,IAAI,QAAQ,GAAG,6BAA6B;EACpE,KAAKA,WAAW,IAAI,QAAQ;EAE5B,KAAKS,cAAc,QAAQ;EAE3B,aAAa;GACX,KAAKT,WAAW,OAAO,QAAQ;EACjC;CACF;CAEA,iBAAiB;EACf,KAAK,MAAM,YAAY,KAAKA,YAC1B,KAAKS,cAAc,QAAQ;CAE/B;CAEA,cAAc,UAAuB;EACnC,SAAS,KAAK,MAAsB,KAAKL,aAAa,KAAKC,MAAM;CACnE;CAEA,UAAU;EACR,KAAK,YAAY;CACnB;CAEA,WAAW;EACT,KAAKK,SAAS;EACd,KAAK,MAAM,QAAQ,WAAW,KAAKX,OAAO,MAAM,CAAC,CAAC,CAAC,GACjD,KAAKI,QAAQ,YACX,KAAKA,OACL;GAAC,MAAM;GAAO;EAAI,GAClB,KAAKQ,WAAW,GAChB,IACA,KAAKV,SACL,OACA,IAIF;EAEF,KAAK,MAAM;CACb;CAEA,KAAK,QAAgB;EACnB,KAAKS,SAAS;EACd,KAAKP,QAAQ,YACX,KAAKA,OACL,mBAAmB,MAAM,GACzB,KAAKQ,WAAW,GAChB,IACA,KAAKV,SACL,OACA,KAAKW,SACP;EACA,OAAO;CACT;CAEA,QAAQ;EACN,IAAI,CAAC,KAAKF,QACR;EAEF,KAAKA,SAAS;EACd,KAAKJ,eAAe;EAIpB,KAAKM,4BAAY,IAAI,QAAQ;CAC/B;CAEA,UAAU,KAAU;EAClB,KAAKV,WAAW,GAAG;CACrB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../../zql/src/ivm/data.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAC;AAChE,OAAO,KAAK,EAAC,GAAG,EAAE,KAAK,EAAC,MAAM,oCAAoC,CAAC;AACnE,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,GAAG,EAAE,GAAG,CAAC;IACT;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;CAC7D,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,MAAM,CA4CxD;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,GAAG,eAAe,CAE5D;AAED,MAAM,MAAM,UAAU,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,KAAK,MAAM,CAAC;AAEtD,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../../zql/src/ivm/data.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAC;AAChE,OAAO,KAAK,EAAC,GAAG,EAAE,KAAK,EAAC,MAAM,oCAAoC,CAAC;AACnE,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,GAAG,EAAE,GAAG,CAAC;IACT;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;CAC7D,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,MAAM,CA4CxD;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,GAAG,eAAe,CAE5D;AAED,MAAM,MAAM,UAAU,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,KAAK,MAAM,CAAC;AAEtD,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CA0B7E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,OAAO,CAMvD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,QAShD"}
|
package/out/zql/src/ivm/data.js
CHANGED
|
@@ -33,10 +33,15 @@ function normalizeUndefined(v) {
|
|
|
33
33
|
return v ?? null;
|
|
34
34
|
}
|
|
35
35
|
function makeComparator(order, reverse) {
|
|
36
|
+
if (order.length === 1 && order[0][1] === "asc" && !reverse) {
|
|
37
|
+
const field = order[0][0];
|
|
38
|
+
return (a, b) => compareValues(a[field], b[field]);
|
|
39
|
+
}
|
|
40
|
+
const length = order.length;
|
|
36
41
|
return (a, b) => {
|
|
37
|
-
for (
|
|
38
|
-
const
|
|
39
|
-
const comp = compareValues(a[
|
|
42
|
+
for (let i = 0; i < length; i++) {
|
|
43
|
+
const ord = order[i];
|
|
44
|
+
const comp = compareValues(a[ord[0]], b[ord[0]]);
|
|
40
45
|
if (comp !== 0) {
|
|
41
46
|
const result = ord[1] === "asc" ? comp : -comp;
|
|
42
47
|
return reverse ? -result : result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.js","names":[],"sources":["../../../../../zql/src/ivm/data.ts"],"sourcesContent":["import {compareUTF8} from 'compare-utf8';\nimport type {Ordering} from '../../../zero-protocol/src/ast.ts';\nimport type {Row, Value} from '../../../zero-protocol/src/data.ts';\nimport type {Stream} from './stream.ts';\n\n/**\n * A row flowing through the pipeline, plus its relationships.\n * Relationships are generated lazily as read.\n */\nexport type Node = {\n row: Row;\n /**\n * Relationships are generated lazily as read.\n * The stream may contain 'yield' to indicate the operator has yielded control.\n * See {@linkcode Operator.fetch} for more details about yields.\n */\n relationships: Record<string, () => Stream<Node | 'yield'>>;\n};\n\n/**\n * Compare two values. The values must be of the same type. This function\n * throws at runtime if the types differ.\n *\n * Note, this function considers `null === null` and\n * `undefined === undefined`. This is different than SQL. In join code,\n * null must be treated separately.\n *\n * See: https://github.com/rocicorp/mono/pull/2116/files#r1704811479\n *\n * @returns < 0 if a < b, 0 if a === b, > 0 if a > b\n */\nexport function compareValues(a: Value, b: Value): number {\n a = a ?? null;\n b = b ?? null;\n\n if (a === b) {\n return 0;\n }\n\n if (typeof a === 'string' && typeof b === 'string') {\n // We compare all strings in Zero as UTF-8. This is the default on SQLite\n // and we need to match it. See:\n // https://blog.replicache.dev/blog/replicache-11-adventures-in-text-encoding.\n //\n // TODO: We could change this since SQLite supports UTF-16. Microbenchmark\n // to see if there's a big win.\n //\n // https://www.sqlite.org/c3ref/create_collation.html\n return compareUTF8(a, b);\n }\n\n if (typeof a === 'number' && typeof b === 'number') {\n return a - b;\n }\n\n if (typeof a === 'boolean' && typeof b === 'boolean') {\n return a ? 1 : -1;\n }\n\n // check with null after since it is less likely to be the common case and we\n // want to avoid the extra checks in that case\n if (a === null) {\n return -1;\n }\n if (b === null) {\n return 1;\n }\n\n if (typeof a !== typeof b) {\n throw new Error(\n `Cannot compare values of different types: ${typeof a} and ${typeof b}`,\n );\n }\n\n throw new Error(`Unsupported type: ${a}`);\n}\n\nexport type NormalizedValue = Exclude<Value, undefined>;\n\n/**\n * We allow undefined to be passed for the convenience of developers, but we\n * treat it equivalently to null. It's better for perf to not create an copy\n * of input values, so we just normalize at use when necessary.\n */\nexport function normalizeUndefined(v: Value): NormalizedValue {\n return v ?? null;\n}\n\nexport type Comparator = (r1: Row, r2: Row) => number;\n\nexport function makeComparator(order: Ordering, reverse?: boolean): Comparator {\n return (a, b) => {\n // Skip destructuring here since it is hot code.\n for (
|
|
1
|
+
{"version":3,"file":"data.js","names":[],"sources":["../../../../../zql/src/ivm/data.ts"],"sourcesContent":["import {compareUTF8} from 'compare-utf8';\nimport type {Ordering} from '../../../zero-protocol/src/ast.ts';\nimport type {Row, Value} from '../../../zero-protocol/src/data.ts';\nimport type {Stream} from './stream.ts';\n\n/**\n * A row flowing through the pipeline, plus its relationships.\n * Relationships are generated lazily as read.\n */\nexport type Node = {\n row: Row;\n /**\n * Relationships are generated lazily as read.\n * The stream may contain 'yield' to indicate the operator has yielded control.\n * See {@linkcode Operator.fetch} for more details about yields.\n */\n relationships: Record<string, () => Stream<Node | 'yield'>>;\n};\n\n/**\n * Compare two values. The values must be of the same type. This function\n * throws at runtime if the types differ.\n *\n * Note, this function considers `null === null` and\n * `undefined === undefined`. This is different than SQL. In join code,\n * null must be treated separately.\n *\n * See: https://github.com/rocicorp/mono/pull/2116/files#r1704811479\n *\n * @returns < 0 if a < b, 0 if a === b, > 0 if a > b\n */\nexport function compareValues(a: Value, b: Value): number {\n a = a ?? null;\n b = b ?? null;\n\n if (a === b) {\n return 0;\n }\n\n if (typeof a === 'string' && typeof b === 'string') {\n // We compare all strings in Zero as UTF-8. This is the default on SQLite\n // and we need to match it. See:\n // https://blog.replicache.dev/blog/replicache-11-adventures-in-text-encoding.\n //\n // TODO: We could change this since SQLite supports UTF-16. Microbenchmark\n // to see if there's a big win.\n //\n // https://www.sqlite.org/c3ref/create_collation.html\n return compareUTF8(a, b);\n }\n\n if (typeof a === 'number' && typeof b === 'number') {\n return a - b;\n }\n\n if (typeof a === 'boolean' && typeof b === 'boolean') {\n return a ? 1 : -1;\n }\n\n // check with null after since it is less likely to be the common case and we\n // want to avoid the extra checks in that case\n if (a === null) {\n return -1;\n }\n if (b === null) {\n return 1;\n }\n\n if (typeof a !== typeof b) {\n throw new Error(\n `Cannot compare values of different types: ${typeof a} and ${typeof b}`,\n );\n }\n\n throw new Error(`Unsupported type: ${a}`);\n}\n\nexport type NormalizedValue = Exclude<Value, undefined>;\n\n/**\n * We allow undefined to be passed for the convenience of developers, but we\n * treat it equivalently to null. It's better for perf to not create an copy\n * of input values, so we just normalize at use when necessary.\n */\nexport function normalizeUndefined(v: Value): NormalizedValue {\n return v ?? null;\n}\n\nexport type Comparator = (r1: Row, r2: Row) => number;\n\nexport function makeComparator(order: Ordering, reverse?: boolean): Comparator {\n // A single ascending field is the common shape -- it is what every source\n // ordered by a single-column primary key gets -- and specializing it drops\n // the loop, the direction test and the reverse test from the hottest\n // function in hydration.\n if (order.length === 1 && order[0][1] === 'asc' && !reverse) {\n const field = order[0][0];\n return (a, b) => compareValues(a[field], b[field]);\n }\n\n const length = order.length;\n return (a, b) => {\n // Skip destructuring here since it is hot code. An indexed loop rather\n // than `for...of` for the same reason: Hermes allocates an iterator and\n // calls `next()` per element, which costs more than the comparison for an\n // ordering this short.\n for (let i = 0; i < length; i++) {\n const ord = order[i];\n const comp = compareValues(a[ord[0]], b[ord[0]]);\n if (comp !== 0) {\n const result = ord[1] === 'asc' ? comp : -comp;\n return reverse ? -result : result;\n }\n }\n return 0;\n };\n}\n\n/**\n * Determine if two values are equal. Note that unlike compareValues() above,\n * this function treats `null` as unequal to itself (and same for `undefined`).\n * This is required to make joins work correctly, but may not be the right\n * semantic for your application.\n */\nexport function valuesEqual(a: Value, b: Value): boolean {\n // oxlint-disable-next-line eqeqeq\n if (a == null || b == null) {\n return false;\n }\n return a === b;\n}\n\nexport function drainStreams(node: Node | 'yield') {\n if (node === 'yield') {\n return;\n }\n for (const stream of Object.values(node.relationships)) {\n for (const node of stream()) {\n drainStreams(node);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA+BA,SAAgB,cAAc,GAAU,GAAkB;CACxD,IAAI,KAAK;CACT,IAAI,KAAK;CAET,IAAI,MAAM,GACR,OAAO;CAGT,IAAI,OAAO,MAAM,YAAY,OAAO,MAAM,UASxC,OAAO,YAAY,GAAG,CAAC;CAGzB,IAAI,OAAO,MAAM,YAAY,OAAO,MAAM,UACxC,OAAO,IAAI;CAGb,IAAI,OAAO,MAAM,aAAa,OAAO,MAAM,WACzC,OAAO,IAAI,IAAI;CAKjB,IAAI,MAAM,MACR,OAAO;CAET,IAAI,MAAM,MACR,OAAO;CAGT,IAAI,OAAO,MAAM,OAAO,GACtB,MAAM,IAAI,MACR,6CAA6C,OAAO,EAAE,OAAO,OAAO,GACtE;CAGF,MAAM,IAAI,MAAM,qBAAqB,GAAG;AAC1C;;;;;;AASA,SAAgB,mBAAmB,GAA2B;CAC5D,OAAO,KAAK;AACd;AAIA,SAAgB,eAAe,OAAiB,SAA+B;CAK7E,IAAI,MAAM,WAAW,KAAK,MAAM,GAAG,OAAO,SAAS,CAAC,SAAS;EAC3D,MAAM,QAAQ,MAAM,GAAG;EACvB,QAAQ,GAAG,MAAM,cAAc,EAAE,QAAQ,EAAE,MAAM;CACnD;CAEA,MAAM,SAAS,MAAM;CACrB,QAAQ,GAAG,MAAM;EAKf,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,KAAK;GAC/B,MAAM,MAAM,MAAM;GAClB,MAAM,OAAO,cAAc,EAAE,IAAI,KAAK,EAAE,IAAI,GAAG;GAC/C,IAAI,SAAS,GAAG;IACd,MAAM,SAAS,IAAI,OAAO,QAAQ,OAAO,CAAC;IAC1C,OAAO,UAAU,CAAC,SAAS;GAC7B;EACF;EACA,OAAO;CACT;AACF;;;;;;;AAQA,SAAgB,YAAY,GAAU,GAAmB;CAEvD,IAAI,KAAK,QAAQ,KAAK,MACpB,OAAO;CAET,OAAO,MAAM;AACf"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Node } from './data.ts';
|
|
2
|
+
import type { FetchRequest, Input, Output } from './operator.ts';
|
|
3
|
+
import type { SourceSchema } from './schema.ts';
|
|
4
|
+
import { type Stream } from './stream.ts';
|
|
5
|
+
/**
|
|
6
|
+
* A placeholder `Input` for a view whose pipeline has not been built yet.
|
|
7
|
+
*
|
|
8
|
+
* Until {@link attach} is called it behaves like an empty pipeline: `fetch`
|
|
9
|
+
* yields nothing and pushes never happen. When the real pipeline is attached
|
|
10
|
+
* the view is hydrated with a single `fetch`, whose rows are delivered to the
|
|
11
|
+
* view as add changes, so the view sees the data exactly as it would see rows
|
|
12
|
+
* arriving incrementally.
|
|
13
|
+
*
|
|
14
|
+
* This lets `materialize()` stay synchronous and return a view immediately
|
|
15
|
+
* while the expensive pipeline construction and hydration are postponed, for
|
|
16
|
+
* example until the client's replica has been loaded into the IVM sources.
|
|
17
|
+
*/
|
|
18
|
+
export declare class DeferredInput implements Input {
|
|
19
|
+
#private;
|
|
20
|
+
/**
|
|
21
|
+
* @param schema The schema the built pipeline reports. Passed in so this
|
|
22
|
+
* input can answer `getSchema()` unconditionally, as the `Input` contract
|
|
23
|
+
* requires, before its pipeline exists.
|
|
24
|
+
* @param build Builds the real pipeline. Called once, from {@link attach}.
|
|
25
|
+
*/
|
|
26
|
+
constructor(schema: SourceSchema, build: () => Input);
|
|
27
|
+
get attached(): boolean;
|
|
28
|
+
get destroyed(): boolean;
|
|
29
|
+
setOutput(output: Output): void;
|
|
30
|
+
getSchema(): SourceSchema;
|
|
31
|
+
fetch(req: FetchRequest): Stream<Node | 'yield'>;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Build the real pipeline and hydrate the output with its current contents.
|
|
35
|
+
*
|
|
36
|
+
* Must be called inside the delegate's `batchViewUpdates`; the delegate is
|
|
37
|
+
* responsible for notifying commit listeners afterwards so views flush.
|
|
38
|
+
*
|
|
39
|
+
* If building or hydrating throws, the pipeline is torn down again and this
|
|
40
|
+
* input stays unattached so the caller can report the failure.
|
|
41
|
+
*/
|
|
42
|
+
attach(): void;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=deferred-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deferred-input.d.ts","sourceRoot":"","sources":["../../../../../zql/src/ivm/deferred-input.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAC,YAAY,EAAE,KAAK,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AAC/D,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAU,KAAK,MAAM,EAAC,MAAM,aAAa,CAAC;AAEjD;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAc,YAAW,KAAK;;IAOzC;;;;;OAKG;gBACS,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,KAAK;IAKpD,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK/B,SAAS,IAAI,YAAY;IAIxB,KAAK,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;IAMjD,OAAO,IAAI,IAAI;IAKf;;;;;;;;OAQG;IACH,MAAM,IAAI,IAAI;CAwBf"}
|