@rocicorp/zero 1.11.0-canary.2 → 1.11.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/analyze-query/src/bin-analyze.js +9 -8
- package/out/analyze-query/src/bin-analyze.js.map +1 -1
- package/out/ast-to-zql/src/ast-to-zql.d.ts +8 -1
- package/out/ast-to-zql/src/ast-to-zql.d.ts.map +1 -1
- package/out/ast-to-zql/src/ast-to-zql.js +25 -25
- package/out/ast-to-zql/src/ast-to-zql.js.map +1 -1
- package/out/otel/src/log-options.d.ts +16 -0
- package/out/otel/src/log-options.d.ts.map +1 -1
- package/out/otel/src/log-options.js +54 -1
- package/out/otel/src/log-options.js.map +1 -1
- package/out/replicache/src/bg-interval.d.ts +2 -1
- package/out/replicache/src/bg-interval.d.ts.map +1 -1
- package/out/replicache/src/bg-interval.js +13 -4
- package/out/replicache/src/bg-interval.js.map +1 -1
- package/out/replicache/src/btree/node.d.ts.map +1 -1
- package/out/replicache/src/btree/node.js +3 -6
- package/out/replicache/src/btree/node.js.map +1 -1
- package/out/replicache/src/dag/gc.d.ts.map +1 -1
- package/out/replicache/src/dag/gc.js +8 -11
- package/out/replicache/src/dag/gc.js.map +1 -1
- package/out/replicache/src/dag/invalid-ref-count-error.d.ts +12 -0
- package/out/replicache/src/dag/invalid-ref-count-error.d.ts.map +1 -0
- package/out/replicache/src/dag/invalid-ref-count-error.js +19 -0
- package/out/replicache/src/dag/invalid-ref-count-error.js.map +1 -0
- package/out/replicache/src/dag/lazy-store.d.ts +17 -4
- package/out/replicache/src/dag/lazy-store.d.ts.map +1 -1
- package/out/replicache/src/dag/lazy-store.js +35 -9
- package/out/replicache/src/dag/lazy-store.js.map +1 -1
- package/out/replicache/src/dag/store-impl.d.ts +12 -2
- package/out/replicache/src/dag/store-impl.d.ts.map +1 -1
- package/out/replicache/src/dag/store-impl.js +29 -9
- package/out/replicache/src/dag/store-impl.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/get-kv-store-provider.d.ts +1 -1
- package/out/replicache/src/get-kv-store-provider.d.ts.map +1 -1
- package/out/replicache/src/get-kv-store-provider.js +4 -4
- package/out/replicache/src/get-kv-store-provider.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 +28 -5
- package/out/replicache/src/kv/expo-sqlite/store.js.map +1 -1
- package/out/replicache/src/kv/idb-store.d.ts +18 -0
- package/out/replicache/src/kv/idb-store.d.ts.map +1 -1
- package/out/replicache/src/kv/idb-store.js +30 -2
- package/out/replicache/src/kv/idb-store.js.map +1 -1
- package/out/replicache/src/kv/mem-fallback-store.d.ts +54 -0
- package/out/replicache/src/kv/mem-fallback-store.d.ts.map +1 -0
- package/out/replicache/src/kv/mem-fallback-store.js +177 -0
- package/out/replicache/src/kv/mem-fallback-store.js.map +1 -0
- package/out/replicache/src/kv/mem-store.d.ts +1 -0
- package/out/replicache/src/kv/mem-store.d.ts.map +1 -1
- package/out/replicache/src/kv/mem-store.js +3 -0
- package/out/replicache/src/kv/mem-store.js.map +1 -1
- package/out/replicache/src/kv/op-sqlite/store.d.ts.map +1 -1
- package/out/replicache/src/kv/op-sqlite/store.js +4 -4
- package/out/replicache/src/kv/op-sqlite/store.js.map +1 -1
- package/out/replicache/src/kv/sqlite-store.d.ts +22 -1
- package/out/replicache/src/kv/sqlite-store.d.ts.map +1 -1
- package/out/replicache/src/kv/sqlite-store.js +159 -14
- package/out/replicache/src/kv/sqlite-store.js.map +1 -1
- package/out/replicache/src/kv/store.d.ts +6 -0
- package/out/replicache/src/kv/store.d.ts.map +1 -1
- package/out/replicache/src/new-client-channel.js.map +1 -1
- package/out/replicache/src/persist/client-gc.d.ts +2 -1
- package/out/replicache/src/persist/client-gc.d.ts.map +1 -1
- package/out/replicache/src/persist/client-gc.js +2 -2
- package/out/replicache/src/persist/client-gc.js.map +1 -1
- package/out/replicache/src/persist/client-group-gc.d.ts +2 -1
- package/out/replicache/src/persist/client-group-gc.d.ts.map +1 -1
- package/out/replicache/src/persist/client-group-gc.js +2 -2
- package/out/replicache/src/persist/client-group-gc.js.map +1 -1
- package/out/replicache/src/persist/collect-idb-databases.d.ts +28 -8
- package/out/replicache/src/persist/collect-idb-databases.d.ts.map +1 -1
- package/out/replicache/src/persist/collect-idb-databases.js +97 -20
- package/out/replicache/src/persist/collect-idb-databases.js.map +1 -1
- package/out/replicache/src/persist/heartbeat.d.ts +2 -1
- package/out/replicache/src/persist/heartbeat.d.ts.map +1 -1
- package/out/replicache/src/persist/heartbeat.js +2 -2
- package/out/replicache/src/persist/heartbeat.js.map +1 -1
- package/out/replicache/src/persist/idb-databases-store-db-name.js +1 -1
- package/out/replicache/src/persist/idb-databases-store-db-name.js.map +1 -1
- package/out/replicache/src/persist/persist.d.ts.map +1 -1
- package/out/replicache/src/persist/persist.js +18 -8
- 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 +85 -3
- package/out/replicache/src/replicache-impl.d.ts.map +1 -1
- package/out/replicache/src/replicache-impl.js +321 -29
- 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/storage-failure.d.ts +37 -0
- package/out/replicache/src/storage-failure.d.ts.map +1 -0
- package/out/replicache/src/storage-failure.js +31 -0
- package/out/replicache/src/storage-failure.js.map +1 -0
- package/out/shared/src/arrays.d.ts +5 -0
- package/out/shared/src/arrays.d.ts.map +1 -1
- package/out/shared/src/arrays.js +8 -10
- package/out/shared/src/arrays.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/iterables.d.ts +2 -0
- package/out/shared/src/iterables.d.ts.map +1 -1
- package/out/shared/src/iterables.js +18 -1
- package/out/shared/src/iterables.js.map +1 -1
- package/out/shared/src/map.d.ts +24 -2
- package/out/shared/src/map.d.ts.map +1 -1
- package/out/shared/src/map.js +18 -4
- package/out/shared/src/map.js.map +1 -1
- package/out/shared/src/random-values.js +12 -1
- package/out/shared/src/random-values.js.map +1 -1
- package/out/shared/src/ring-buffer.d.ts +10 -0
- package/out/shared/src/ring-buffer.d.ts.map +1 -1
- package/out/shared/src/ring-buffer.js +26 -1
- package/out/shared/src/ring-buffer.js.map +1 -1
- package/out/z2s/src/compiler.js +1 -1
- package/out/z2s/src/sql.d.ts.map +1 -1
- package/out/z2s/src/sql.js +2 -2
- package/out/z2s/src/sql.js.map +1 -1
- package/out/zero/package.js +3 -4
- package/out/zero/package.js.map +1 -1
- package/out/zero/src/zero.js +2 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.js +1 -0
- package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
- package/out/zero-cache/src/config/normalize.d.ts.map +1 -1
- package/out/zero-cache/src/config/normalize.js +26 -2
- package/out/zero-cache/src/config/normalize.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +102 -6
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +254 -57
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/db/lite-tables.d.ts.map +1 -1
- package/out/zero-cache/src/db/lite-tables.js +3 -4
- package/out/zero-cache/src/db/lite-tables.js.map +1 -1
- package/out/zero-cache/src/observability/events.js +4 -1
- package/out/zero-cache/src/observability/events.js.map +1 -1
- package/out/zero-cache/src/observability/log-throttle.d.ts +44 -0
- package/out/zero-cache/src/observability/log-throttle.d.ts.map +1 -0
- package/out/zero-cache/src/observability/log-throttle.js +76 -0
- package/out/zero-cache/src/observability/log-throttle.js.map +1 -0
- package/out/zero-cache/src/observability/metrics.d.ts.map +1 -1
- package/out/zero-cache/src/observability/metrics.js +2 -7
- package/out/zero-cache/src/observability/metrics.js.map +1 -1
- package/out/zero-cache/src/scripts/permissions.d.ts +16 -0
- package/out/zero-cache/src/scripts/permissions.d.ts.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 -10
- package/out/zero-cache/src/server/change-streamer.js.map +1 -1
- package/out/zero-cache/src/server/inspector-delegate.d.ts +28 -2
- package/out/zero-cache/src/server/inspector-delegate.d.ts.map +1 -1
- package/out/zero-cache/src/server/inspector-delegate.js +37 -17
- package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
- package/out/zero-cache/src/server/main.d.ts.map +1 -1
- package/out/zero-cache/src/server/main.js +8 -1
- package/out/zero-cache/src/server/main.js.map +1 -1
- package/out/zero-cache/src/server/mutator.js +2 -0
- package/out/zero-cache/src/server/mutator.js.map +1 -1
- package/out/zero-cache/src/server/reaper.d.ts.map +1 -1
- package/out/zero-cache/src/server/reaper.js +2 -0
- package/out/zero-cache/src/server/reaper.js.map +1 -1
- package/out/zero-cache/src/server/replicator.d.ts +3 -0
- package/out/zero-cache/src/server/replicator.d.ts.map +1 -1
- package/out/zero-cache/src/server/replicator.js +79 -15
- package/out/zero-cache/src/server/replicator.js.map +1 -1
- package/out/zero-cache/src/server/runner/zero-dispatcher.d.ts.map +1 -1
- package/out/zero-cache/src/server/runner/zero-dispatcher.js +5 -0
- package/out/zero-cache/src/server/runner/zero-dispatcher.js.map +1 -1
- package/out/zero-cache/src/server/syncer-assigner.d.ts +14 -0
- package/out/zero-cache/src/server/syncer-assigner.d.ts.map +1 -0
- package/out/zero-cache/src/server/syncer-assigner.js +72 -0
- package/out/zero-cache/src/server/syncer-assigner.js.map +1 -0
- package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/server/syncer.js +24 -2
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/server/worker-dispatcher.d.ts.map +1 -1
- package/out/zero-cache/src/server/worker-dispatcher.js +21 -4
- package/out/zero-cache/src/server/worker-dispatcher.js.map +1 -1
- package/out/zero-cache/src/services/analyze.d.ts.map +1 -1
- package/out/zero-cache/src/services/analyze.js +11 -9
- package/out/zero-cache/src/services/analyze.js.map +1 -1
- 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 +198 -24
- package/out/zero-cache/src/services/change-source/common/backfill-manager.js.map +1 -1
- package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js +15 -3
- package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js.map +1 -1
- package/out/zero-cache/src/services/change-source/common/replica-schema.d.ts +1 -0
- 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 +15 -3
- 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 +9 -0
- 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 +204 -18
- 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-init.d.ts +25 -0
- package/out/zero-cache/src/services/change-source/pg/change-source-init.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-source/pg/change-source-init.js +202 -0
- package/out/zero-cache/src/services/change-source/pg/change-source-init.js.map +1 -0
- package/out/zero-cache/src/services/change-source/pg/change-source.d.ts +14 -16
- 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 +64 -143
- package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts +37 -2
- 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 +53 -21
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/replication-slot-cleanup-monitor.d.ts +16 -0
- package/out/zero-cache/src/services/change-source/pg/replication-slot-cleanup-monitor.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-source/pg/replication-slot-cleanup-monitor.js +113 -0
- package/out/zero-cache/src/services/change-source/pg/replication-slot-cleanup-monitor.js.map +1 -0
- package/out/zero-cache/src/services/change-source/pg/replication-slots.d.ts +21 -15
- 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 +86 -23
- 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/index-predicate.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js +68 -8
- package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js.map +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 +32 -1
- 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/replica-stage-enum.d.ts +10 -0
- package/out/zero-cache/src/services/change-source/pg/schema/replica-stage-enum.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-source/pg/schema/replica-stage-enum.js +6 -0
- package/out/zero-cache/src/services/change-source/pg/schema/replica-stage-enum.js.map +1 -0
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +50 -27
- 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 +100 -34
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/backfill-progress.d.ts +68 -0
- package/out/zero-cache/src/services/change-source/protocol/backfill-progress.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-source/protocol/backfill-progress.js +141 -0
- package/out/zero-cache/src/services/change-source/protocol/backfill-progress.js.map +1 -0
- package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts +43 -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/data.js +10 -1
- package/out/zero-cache/src/services/change-source/protocol/current/data.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +57 -0
- package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/upstream.d.ts +20 -6
- package/out/zero-cache/src/services/change-source/protocol/current/upstream.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/upstream.js +17 -7
- package/out/zero-cache/src/services/change-source/protocol/current/upstream.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current.js +2 -1
- package/out/zero-cache/src/services/change-streamer/backfill-state-tracker.d.ts +66 -0
- package/out/zero-cache/src/services/change-streamer/backfill-state-tracker.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-streamer/backfill-state-tracker.js +154 -0
- package/out/zero-cache/src/services/change-streamer/backfill-state-tracker.js.map +1 -0
- package/out/zero-cache/src/services/change-streamer/backfill-state.d.ts +50 -0
- package/out/zero-cache/src/services/change-streamer/backfill-state.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-streamer/backfill-state.js +268 -0
- package/out/zero-cache/src/services/change-streamer/backfill-state.js.map +1 -0
- 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 +2 -0
- 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 +58 -7
- 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 +8 -2
- package/out/zero-cache/src/services/change-streamer/broadcast.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/broadcast.js +24 -4
- package/out/zero-cache/src/services/change-streamer/broadcast.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-log-codec.d.ts +19 -4
- package/out/zero-cache/src/services/change-streamer/change-log-codec.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-log-codec.js +28 -8
- package/out/zero-cache/src/services/change-streamer/change-log-codec.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +48 -6
- 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 +130 -34
- 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 +11 -0
- 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 +118 -68
- 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 +37 -15
- 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 +3 -3
- package/out/zero-cache/src/services/change-streamer/forwarder.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/forwarder.js +36 -5
- package/out/zero-cache/src/services/change-streamer/forwarder.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/litestream-sync-requester.d.ts +51 -0
- package/out/zero-cache/src/services/change-streamer/litestream-sync-requester.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-streamer/litestream-sync-requester.js +132 -0
- package/out/zero-cache/src/services/change-streamer/litestream-sync-requester.js.map +1 -0
- package/out/zero-cache/src/services/change-streamer/schema/tables.d.ts +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/tables.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/tables.js +19 -8
- package/out/zero-cache/src/services/change-streamer/schema/tables.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/snapshot-message.d.ts +92 -0
- package/out/zero-cache/src/services/change-streamer/snapshot-message.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-streamer/snapshot-message.js +42 -0
- package/out/zero-cache/src/services/change-streamer/snapshot-message.js.map +1 -0
- package/out/zero-cache/src/services/change-streamer/snapshot-reservations.d.ts +1 -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 +16 -4
- package/out/zero-cache/src/services/change-streamer/snapshot-reservations.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/snapshot.d.ts +7 -69
- package/out/zero-cache/src/services/change-streamer/snapshot.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/snapshot.js +21 -53
- package/out/zero-cache/src/services/change-streamer/snapshot.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-writer.d.ts +6 -1
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-writer.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-writer.js +27 -9
- package/out/zero-cache/src/services/change-streamer/sqlite-change-log-writer.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.d.ts +2 -2
- package/out/zero-cache/src/services/change-streamer/storer.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.js +9 -6
- package/out/zero-cache/src/services/change-streamer/storer.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/subscribe.d.ts +446 -0
- package/out/zero-cache/src/services/change-streamer/subscribe.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-streamer/subscribe.js +76 -0
- package/out/zero-cache/src/services/change-streamer/subscribe.js.map +1 -0
- package/out/zero-cache/src/services/change-streamer/subscriber.d.ts +33 -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 +76 -0
- package/out/zero-cache/src/services/change-streamer/subscriber.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/upstream-acker.d.ts +17 -1
- package/out/zero-cache/src/services/change-streamer/upstream-acker.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/upstream-acker.js +19 -3
- package/out/zero-cache/src/services/change-streamer/upstream-acker.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/vfs-watermark-poller.d.ts +5 -0
- package/out/zero-cache/src/services/change-streamer/vfs-watermark-poller.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/vfs-watermark-poller.js +35 -5
- package/out/zero-cache/src/services/change-streamer/vfs-watermark-poller.js.map +1 -1
- package/out/zero-cache/src/services/life-cycle.d.ts.map +1 -1
- package/out/zero-cache/src/services/life-cycle.js +3 -1
- package/out/zero-cache/src/services/life-cycle.js.map +1 -1
- package/out/zero-cache/src/services/litestream/commands.d.ts +15 -3
- package/out/zero-cache/src/services/litestream/commands.d.ts.map +1 -1
- package/out/zero-cache/src/services/litestream/commands.js +24 -7
- package/out/zero-cache/src/services/litestream/commands.js.map +1 -1
- package/out/zero-cache/src/services/litestream/config-v5.yml +11 -4
- package/out/zero-cache/src/services/litestream/litestream-checkpointer.js +51 -24
- package/out/zero-cache/src/services/litestream/litestream-checkpointer.js.map +1 -1
- package/out/zero-cache/src/services/litestream/litestream-controller.d.ts +10 -2
- package/out/zero-cache/src/services/litestream/litestream-controller.d.ts.map +1 -1
- package/out/zero-cache/src/services/litestream/litestream-controller.js +3 -2
- package/out/zero-cache/src/services/litestream/litestream-controller.js.map +1 -1
- package/out/zero-cache/src/services/litestream/restore-progress.d.ts +24 -0
- package/out/zero-cache/src/services/litestream/restore-progress.d.ts.map +1 -0
- package/out/zero-cache/src/services/litestream/restore-progress.js +91 -0
- package/out/zero-cache/src/services/litestream/restore-progress.js.map +1 -0
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts +5 -0
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js +7 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.js +5 -6
- package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
- package/out/zero-cache/src/services/plannerz.d.ts +163 -0
- package/out/zero-cache/src/services/plannerz.d.ts.map +1 -0
- package/out/zero-cache/src/services/plannerz.js +267 -0
- package/out/zero-cache/src/services/plannerz.js.map +1 -0
- package/out/zero-cache/src/services/profz.d.ts +30 -0
- package/out/zero-cache/src/services/profz.d.ts.map +1 -0
- package/out/zero-cache/src/services/profz.js +145 -0
- package/out/zero-cache/src/services/profz.js.map +1 -0
- package/out/zero-cache/src/services/replicator/change-log-cookies.js +1 -1
- package/out/zero-cache/src/services/replicator/change-log-cookies.js.map +1 -1
- package/out/zero-cache/src/services/replicator/change-log-stream-writer.d.ts +5 -4
- package/out/zero-cache/src/services/replicator/change-log-stream-writer.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/change-log-stream-writer.js +20 -22
- package/out/zero-cache/src/services/replicator/change-log-stream-writer.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 +49 -5
- package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.d.ts +3 -2
- package/out/zero-cache/src/services/replicator/incremental-sync.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.js +50 -20
- package/out/zero-cache/src/services/replicator/incremental-sync.js.map +1 -1
- package/out/zero-cache/src/services/replicator/replication-status.d.ts +35 -1
- package/out/zero-cache/src/services/replicator/replication-status.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/replication-status.js +96 -6
- package/out/zero-cache/src/services/replicator/replication-status.js.map +1 -1
- package/out/zero-cache/src/services/replicator/replicator.d.ts +2 -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/schema/backfilling.d.ts +23 -2
- package/out/zero-cache/src/services/replicator/schema/backfilling.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/backfilling.js +54 -2
- package/out/zero-cache/src/services/replicator/schema/backfilling.js.map +1 -1
- package/out/zero-cache/src/services/replicator/sqlite-change-log-observability.d.ts +6 -6
- 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 +19 -14
- 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 +11 -3
- 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.map +1 -1
- package/out/zero-cache/src/services/replicator/write-worker.js +5 -1
- package/out/zero-cache/src/services/replicator/write-worker.js.map +1 -1
- package/out/zero-cache/src/services/run-ast.d.ts +12 -0
- package/out/zero-cache/src/services/run-ast.d.ts.map +1 -1
- package/out/zero-cache/src/services/run-ast.js +26 -14
- package/out/zero-cache/src/services/run-ast.js.map +1 -1
- package/out/zero-cache/src/services/runner.d.ts +2 -1
- package/out/zero-cache/src/services/runner.d.ts.map +1 -1
- package/out/zero-cache/src/services/runner.js +10 -2
- package/out/zero-cache/src/services/runner.js.map +1 -1
- package/out/zero-cache/src/services/statz.d.ts +4 -0
- package/out/zero-cache/src/services/statz.d.ts.map +1 -1
- package/out/zero-cache/src/services/statz.js +22 -5
- package/out/zero-cache/src/services/statz.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.d.ts +19 -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 +42 -30
- 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 +19 -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 +34 -11
- package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts +51 -2
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.js +142 -6
- package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/deferred-writes-budget.d.ts +81 -0
- package/out/zero-cache/src/services/view-syncer/deferred-writes-budget.d.ts.map +1 -0
- package/out/zero-cache/src/services/view-syncer/deferred-writes-budget.js +128 -0
- package/out/zero-cache/src/services/view-syncer/deferred-writes-budget.js.map +1 -0
- package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts +14 -1
- package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/drain-coordinator.js +30 -4
- package/out/zero-cache/src/services/view-syncer/drain-coordinator.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts +33 -0
- package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts.map +1 -0
- package/out/zero-cache/src/services/view-syncer/hydration-budget.js +62 -0
- package/out/zero-cache/src/services/view-syncer/hydration-budget.js.map +1 -0
- package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts +51 -0
- package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts.map +1 -0
- package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.js +78 -0
- package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.js.map +1 -0
- package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts +1 -1
- package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/inspect-handler.js +3 -3
- package/out/zero-cache/src/services/view-syncer/inspect-handler.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +50 -2
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +466 -62
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/plan-warnings.d.ts +7 -0
- package/out/zero-cache/src/services/view-syncer/plan-warnings.d.ts.map +1 -0
- package/out/zero-cache/src/services/view-syncer/plan-warnings.js +35 -0
- package/out/zero-cache/src/services/view-syncer/plan-warnings.js.map +1 -0
- package/out/zero-cache/src/services/view-syncer/query-covering.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/query-covering.js +2 -6
- package/out/zero-cache/src/services/view-syncer/query-covering.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/query-shape.d.ts +25 -0
- package/out/zero-cache/src/services/view-syncer/query-shape.d.ts.map +1 -0
- package/out/zero-cache/src/services/view-syncer/query-shape.js +28 -0
- package/out/zero-cache/src/services/view-syncer/query-shape.js.map +1 -0
- package/out/zero-cache/src/services/view-syncer/query-stats.d.ts +77 -0
- package/out/zero-cache/src/services/view-syncer/query-stats.d.ts.map +1 -0
- package/out/zero-cache/src/services/view-syncer/query-stats.js +206 -0
- package/out/zero-cache/src/services/view-syncer/query-stats.js.map +1 -0
- package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.d.ts +95 -0
- package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.d.ts.map +1 -0
- package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.js +155 -0
- package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.js.map +1 -0
- package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts +78 -4
- package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/snapshotter.js +158 -28
- package/out/zero-cache/src/services/view-syncer/snapshotter.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +11 -1
- 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 +587 -103
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/processes.d.ts +39 -0
- package/out/zero-cache/src/types/processes.d.ts.map +1 -1
- package/out/zero-cache/src/types/processes.js +43 -4
- package/out/zero-cache/src/types/processes.js.map +1 -1
- package/out/zero-cache/src/types/profiler.d.ts +12 -0
- package/out/zero-cache/src/types/profiler.d.ts.map +1 -1
- package/out/zero-cache/src/types/profiler.js +46 -1
- package/out/zero-cache/src/types/profiler.js.map +1 -1
- package/out/zero-cache/src/types/row-key.d.ts.map +1 -1
- package/out/zero-cache/src/types/row-key.js +5 -5
- package/out/zero-cache/src/types/row-key.js.map +1 -1
- package/out/zero-cache/src/types/streams.d.ts +49 -7
- package/out/zero-cache/src/types/streams.d.ts.map +1 -1
- package/out/zero-cache/src/types/streams.js +190 -58
- package/out/zero-cache/src/types/streams.js.map +1 -1
- package/out/zero-cache/src/types/subscription.d.ts +15 -0
- package/out/zero-cache/src/types/subscription.d.ts.map +1 -1
- package/out/zero-cache/src/types/subscription.js +123 -31
- package/out/zero-cache/src/types/subscription.js.map +1 -1
- package/out/zero-cache/src/types/websocket-handoff.d.ts +1 -1
- package/out/zero-cache/src/types/websocket-handoff.d.ts.map +1 -1
- package/out/zero-cache/src/types/websocket-handoff.js +18 -9
- package/out/zero-cache/src/types/websocket-handoff.js.map +1 -1
- package/out/zero-cache/src/types/ws.d.ts.map +1 -1
- package/out/zero-cache/src/types/ws.js +1 -16
- package/out/zero-cache/src/types/ws.js.map +1 -1
- package/out/zero-cache/src/workers/connect-params.d.ts +1 -0
- package/out/zero-cache/src/workers/connect-params.d.ts.map +1 -1
- package/out/zero-cache/src/workers/connect-params.js.map +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts.map +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js +21 -16
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
- package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/workers/syncer.js +55 -4
- package/out/zero-cache/src/workers/syncer.js.map +1 -1
- package/out/zero-client/src/client/active-clients-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/active-clients-manager.js +4 -1
- package/out/zero-client/src/client/active-clients-manager.js.map +1 -1
- package/out/zero-client/src/client/connection-manager.d.ts +20 -0
- package/out/zero-client/src/client/connection-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/connection-manager.js +77 -13
- package/out/zero-client/src/client/connection-manager.js.map +1 -1
- package/out/zero-client/src/client/connection-status-enum.d.ts +2 -0
- package/out/zero-client/src/client/connection-status-enum.d.ts.map +1 -1
- package/out/zero-client/src/client/connection-status-enum.js +3 -1
- package/out/zero-client/src/client/connection-status-enum.js.map +1 -1
- package/out/zero-client/src/client/connection.d.ts +6 -0
- package/out/zero-client/src/client/connection.d.ts.map +1 -1
- package/out/zero-client/src/client/connection.js +2 -1
- package/out/zero-client/src/client/connection.js.map +1 -1
- package/out/zero-client/src/client/context.d.ts +22 -12
- package/out/zero-client/src/client/context.d.ts.map +1 -1
- package/out/zero-client/src/client/context.js +92 -25
- package/out/zero-client/src/client/context.js.map +1 -1
- package/out/zero-client/src/client/custom.js +2 -2
- package/out/zero-client/src/client/custom.js.map +1 -1
- package/out/zero-client/src/client/error.js +1 -1
- package/out/zero-client/src/client/ivm-branch.d.ts.map +1 -1
- package/out/zero-client/src/client/ivm-branch.js +20 -3
- package/out/zero-client/src/client/ivm-branch.js.map +1 -1
- package/out/zero-client/src/client/mutator-proxy.d.ts.map +1 -1
- package/out/zero-client/src/client/mutator-proxy.js +5 -2
- package/out/zero-client/src/client/mutator-proxy.js.map +1 -1
- package/out/zero-client/src/client/options.d.ts +33 -0
- package/out/zero-client/src/client/options.d.ts.map +1 -1
- package/out/zero-client/src/client/options.js.map +1 -1
- package/out/zero-client/src/client/query-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/query-manager.js +44 -11
- package/out/zero-client/src/client/query-manager.js.map +1 -1
- package/out/zero-client/src/client/version.js +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 +8 -6
- package/out/zero-client/src/client/zero-rep.js.map +1 -1
- package/out/zero-client/src/client/zero.d.ts +18 -3
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.js +84 -47
- package/out/zero-client/src/client/zero.js.map +1 -1
- package/out/zero-client/src/mod.d.ts +1 -0
- package/out/zero-client/src/mod.d.ts.map +1 -1
- package/out/zero-client/src/mod.js +1 -0
- package/out/zero-client/src/types/query-result.d.ts +2 -0
- package/out/zero-client/src/types/query-result.d.ts.map +1 -1
- package/out/zero-events/src/status.d.ts +58 -0
- package/out/zero-events/src/status.d.ts.map +1 -1
- package/out/zero-protocol/src/ast.d.ts.map +1 -1
- package/out/zero-protocol/src/ast.js +13 -14
- package/out/zero-protocol/src/ast.js.map +1 -1
- package/out/zero-protocol/src/down.d.ts +29 -29
- package/out/zero-protocol/src/query-hash.d.ts.map +1 -1
- package/out/zero-protocol/src/query-hash.js +2 -5
- package/out/zero-protocol/src/query-hash.js.map +1 -1
- package/out/zero-react/src/use-query.d.ts +5 -4
- package/out/zero-react/src/use-query.d.ts.map +1 -1
- package/out/zero-react/src/use-query.js +62 -4
- package/out/zero-react/src/use-query.js.map +1 -1
- package/out/zero-react/src/zero.js +1 -0
- package/out/zero-server/src/adapters/drizzle.d.ts +2 -1
- package/out/zero-server/src/adapters/drizzle.d.ts.map +1 -1
- package/out/zero-server/src/adapters/drizzle.js +12 -7
- package/out/zero-server/src/adapters/drizzle.js.map +1 -1
- package/out/zero-server/src/adapters/kysely.d.ts +2 -1
- package/out/zero-server/src/adapters/kysely.d.ts.map +1 -1
- package/out/zero-server/src/adapters/kysely.js +8 -2
- package/out/zero-server/src/adapters/kysely.js.map +1 -1
- package/out/zero-server/src/adapters/pg.d.ts +1 -0
- package/out/zero-server/src/adapters/pg.d.ts.map +1 -1
- package/out/zero-server/src/adapters/pg.js +8 -2
- package/out/zero-server/src/adapters/pg.js.map +1 -1
- package/out/zero-server/src/adapters/postgresjs.d.ts +1 -0
- package/out/zero-server/src/adapters/postgresjs.d.ts.map +1 -1
- package/out/zero-server/src/adapters/postgresjs.js +7 -1
- package/out/zero-server/src/adapters/postgresjs.js.map +1 -1
- package/out/zero-server/src/adapters/prisma.d.ts +3 -2
- package/out/zero-server/src/adapters/prisma.d.ts.map +1 -1
- package/out/zero-server/src/adapters/prisma.js +8 -2
- package/out/zero-server/src/adapters/prisma.js.map +1 -1
- package/out/zero-server/src/custom.d.ts +5 -1
- package/out/zero-server/src/custom.d.ts.map +1 -1
- package/out/zero-server/src/custom.js +6 -3
- package/out/zero-server/src/custom.js.map +1 -1
- package/out/zero-server/src/logging.d.ts +2 -2
- package/out/zero-server/src/logging.d.ts.map +1 -1
- package/out/zero-server/src/logging.js +2 -2
- package/out/zero-server/src/logging.js.map +1 -1
- package/out/zero-server/src/mod.d.ts +1 -1
- package/out/zero-server/src/mod.d.ts.map +1 -1
- package/out/zero-server/src/pg-query-executor.d.ts +2 -2
- package/out/zero-server/src/pg-query-executor.d.ts.map +1 -1
- package/out/zero-server/src/pg-query-executor.js +2 -2
- package/out/zero-server/src/pg-query-executor.js.map +1 -1
- package/out/zero-server/src/process-mutations.d.ts +12 -3
- package/out/zero-server/src/process-mutations.d.ts.map +1 -1
- package/out/zero-server/src/process-mutations.js +13 -8
- package/out/zero-server/src/process-mutations.js.map +1 -1
- package/out/zero-server/src/push-processor.d.ts +8 -2
- package/out/zero-server/src/push-processor.d.ts.map +1 -1
- package/out/zero-server/src/push-processor.js +12 -4
- package/out/zero-server/src/push-processor.js.map +1 -1
- package/out/zero-server/src/schema.d.ts +2 -2
- package/out/zero-server/src/schema.d.ts.map +1 -1
- package/out/zero-server/src/schema.js +2 -2
- package/out/zero-server/src/schema.js.map +1 -1
- package/out/zero-server/src/zql-database.d.ts +21 -1
- package/out/zero-server/src/zql-database.d.ts.map +1 -1
- package/out/zero-server/src/zql-database.js +33 -2
- package/out/zero-server/src/zql-database.js.map +1 -1
- package/out/zero-solid/src/solid-view.d.ts +17 -0
- package/out/zero-solid/src/solid-view.d.ts.map +1 -1
- package/out/zero-solid/src/solid-view.js +39 -1
- package/out/zero-solid/src/solid-view.js.map +1 -1
- package/out/zero-solid/src/use-query.js +1 -2
- package/out/zero-solid/src/use-query.js.map +1 -1
- package/out/zero-solid/src/zero.js +1 -0
- package/out/zql/src/builder/builder.d.ts +25 -0
- package/out/zql/src/builder/builder.d.ts.map +1 -1
- package/out/zql/src/builder/builder.js +69 -19
- package/out/zql/src/builder/builder.js.map +1 -1
- package/out/zql/src/builder/correlated-predicate-pushdown.d.ts +43 -0
- package/out/zql/src/builder/correlated-predicate-pushdown.d.ts.map +1 -0
- package/out/zql/src/builder/correlated-predicate-pushdown.js +161 -0
- package/out/zql/src/builder/correlated-predicate-pushdown.js.map +1 -0
- package/out/zql/src/builder/debug-delegate.d.ts +6 -1
- package/out/zql/src/builder/debug-delegate.d.ts.map +1 -1
- package/out/zql/src/builder/debug-delegate.js +14 -2
- package/out/zql/src/builder/debug-delegate.js.map +1 -1
- package/out/zql/src/ivm/array-view.d.ts +29 -0
- package/out/zql/src/ivm/array-view.d.ts.map +1 -1
- package/out/zql/src/ivm/array-view.js +58 -9
- package/out/zql/src/ivm/array-view.js.map +1 -1
- package/out/zql/src/ivm/cap.d.ts +2 -1
- package/out/zql/src/ivm/cap.d.ts.map +1 -1
- package/out/zql/src/ivm/cap.js +14 -4
- package/out/zql/src/ivm/cap.js.map +1 -1
- package/out/zql/src/ivm/connection-index.d.ts +68 -0
- package/out/zql/src/ivm/connection-index.d.ts.map +1 -0
- package/out/zql/src/ivm/connection-index.js +149 -0
- package/out/zql/src/ivm/connection-index.js.map +1 -0
- 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.map +1 -1
- package/out/zql/src/ivm/deferred-input.js +3 -2
- package/out/zql/src/ivm/deferred-input.js.map +1 -1
- package/out/zql/src/ivm/exists.d.ts +3 -1
- package/out/zql/src/ivm/exists.d.ts.map +1 -1
- package/out/zql/src/ivm/exists.js +4 -1
- package/out/zql/src/ivm/exists.js.map +1 -1
- package/out/zql/src/ivm/fan-in.d.ts +6 -2
- package/out/zql/src/ivm/fan-in.d.ts.map +1 -1
- package/out/zql/src/ivm/fan-in.js +13 -5
- package/out/zql/src/ivm/fan-in.js.map +1 -1
- package/out/zql/src/ivm/fan-out.d.ts +5 -2
- package/out/zql/src/ivm/fan-out.d.ts.map +1 -1
- package/out/zql/src/ivm/fan-out.js +4 -0
- package/out/zql/src/ivm/fan-out.js.map +1 -1
- package/out/zql/src/ivm/filter-operators.d.ts +8 -6
- package/out/zql/src/ivm/filter-operators.d.ts.map +1 -1
- package/out/zql/src/ivm/filter-operators.js +19 -8
- package/out/zql/src/ivm/filter-operators.js.map +1 -1
- package/out/zql/src/ivm/filter.d.ts +5 -2
- package/out/zql/src/ivm/filter.d.ts.map +1 -1
- package/out/zql/src/ivm/filter.js +10 -4
- package/out/zql/src/ivm/filter.js.map +1 -1
- package/out/zql/src/ivm/flipped-join.d.ts +9 -4
- package/out/zql/src/ivm/flipped-join.d.ts.map +1 -1
- package/out/zql/src/ivm/flipped-join.js +97 -46
- package/out/zql/src/ivm/flipped-join.js.map +1 -1
- package/out/zql/src/ivm/join-index-tap.d.ts +33 -0
- package/out/zql/src/ivm/join-index-tap.d.ts.map +1 -0
- package/out/zql/src/ivm/join-index-tap.js +70 -0
- package/out/zql/src/ivm/join-index-tap.js.map +1 -0
- package/out/zql/src/ivm/join-index.d.ts +35 -0
- package/out/zql/src/ivm/join-index.d.ts.map +1 -0
- package/out/zql/src/ivm/join-index.js +141 -0
- package/out/zql/src/ivm/join-index.js.map +1 -0
- package/out/zql/src/ivm/join-utils.d.ts +6 -0
- package/out/zql/src/ivm/join-utils.d.ts.map +1 -1
- package/out/zql/src/ivm/join-utils.js +22 -1
- package/out/zql/src/ivm/join-utils.js.map +1 -1
- package/out/zql/src/ivm/join.d.ts +19 -1
- package/out/zql/src/ivm/join.d.ts.map +1 -1
- package/out/zql/src/ivm/join.js +107 -15
- package/out/zql/src/ivm/join.js.map +1 -1
- package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts +1 -1
- package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts.map +1 -1
- package/out/zql/src/ivm/maybe-split-and-push-edit-change.js +6 -4
- package/out/zql/src/ivm/maybe-split-and-push-edit-change.js.map +1 -1
- package/out/zql/src/ivm/memory-source.d.ts +28 -3
- package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
- package/out/zql/src/ivm/memory-source.js +69 -33
- package/out/zql/src/ivm/memory-source.js.map +1 -1
- package/out/zql/src/ivm/memory-storage.d.ts +1 -0
- package/out/zql/src/ivm/memory-storage.d.ts.map +1 -1
- package/out/zql/src/ivm/memory-storage.js +1 -0
- package/out/zql/src/ivm/memory-storage.js.map +1 -1
- package/out/zql/src/ivm/operator.d.ts +45 -10
- package/out/zql/src/ivm/operator.d.ts.map +1 -1
- package/out/zql/src/ivm/operator.js +9 -4
- package/out/zql/src/ivm/operator.js.map +1 -1
- package/out/zql/src/ivm/push-accumulated.d.ts +6 -1
- package/out/zql/src/ivm/push-accumulated.d.ts.map +1 -1
- package/out/zql/src/ivm/push-accumulated.js +47 -2
- package/out/zql/src/ivm/push-accumulated.js.map +1 -1
- package/out/zql/src/ivm/skip.d.ts +2 -1
- package/out/zql/src/ivm/skip.d.ts.map +1 -1
- package/out/zql/src/ivm/skip.js +3 -0
- package/out/zql/src/ivm/skip.js.map +1 -1
- package/out/zql/src/ivm/take-gate.d.ts +57 -0
- package/out/zql/src/ivm/take-gate.d.ts.map +1 -0
- package/out/zql/src/ivm/take-gate.js +106 -0
- package/out/zql/src/ivm/take-gate.js.map +1 -0
- package/out/zql/src/ivm/take.d.ts +8 -2
- package/out/zql/src/ivm/take.d.ts.map +1 -1
- package/out/zql/src/ivm/take.js +139 -103
- package/out/zql/src/ivm/take.js.map +1 -1
- package/out/zql/src/ivm/union-fan-in.d.ts +3 -0
- package/out/zql/src/ivm/union-fan-in.d.ts.map +1 -1
- package/out/zql/src/ivm/union-fan-in.js +63 -10
- package/out/zql/src/ivm/union-fan-in.js.map +1 -1
- package/out/zql/src/ivm/union-fan-out.d.ts +2 -1
- package/out/zql/src/ivm/union-fan-out.d.ts.map +1 -1
- package/out/zql/src/ivm/union-fan-out.js +5 -0
- package/out/zql/src/ivm/union-fan-out.js.map +1 -1
- package/out/zql/src/ivm/view-apply-change.d.ts.map +1 -1
- package/out/zql/src/ivm/view-apply-change.js +9 -4
- package/out/zql/src/ivm/view-apply-change.js.map +1 -1
- package/out/zql/src/ivm/view.d.ts +15 -0
- package/out/zql/src/ivm/view.d.ts.map +1 -1
- package/out/zql/src/mutate/custom.d.ts +24 -1
- package/out/zql/src/mutate/custom.d.ts.map +1 -1
- package/out/zql/src/mutate/custom.js.map +1 -1
- package/out/zql/src/mutate/mutator-registry.d.ts.map +1 -1
- package/out/zql/src/mutate/mutator-registry.js +2 -2
- package/out/zql/src/mutate/mutator-registry.js.map +1 -1
- package/out/zql/src/planner/planner-builder.d.ts +23 -3
- package/out/zql/src/planner/planner-builder.d.ts.map +1 -1
- package/out/zql/src/planner/planner-builder.js +34 -17
- package/out/zql/src/planner/planner-builder.js.map +1 -1
- package/out/zql/src/planner/planner-connection.d.ts +58 -2
- package/out/zql/src/planner/planner-connection.d.ts.map +1 -1
- package/out/zql/src/planner/planner-connection.js +103 -11
- package/out/zql/src/planner/planner-connection.js.map +1 -1
- package/out/zql/src/planner/planner-debug.d.ts.map +1 -1
- package/out/zql/src/planner/planner-debug.js +3 -8
- package/out/zql/src/planner/planner-debug.js.map +1 -1
- package/out/zql/src/planner/planner-graph.d.ts +10 -0
- package/out/zql/src/planner/planner-graph.d.ts.map +1 -1
- package/out/zql/src/planner/planner-graph.js +14 -0
- package/out/zql/src/planner/planner-graph.js.map +1 -1
- package/out/zql/src/planner/planner-source.d.ts +2 -2
- package/out/zql/src/planner/planner-source.d.ts.map +1 -1
- package/out/zql/src/planner/planner-source.js +2 -2
- package/out/zql/src/planner/planner-source.js.map +1 -1
- package/out/zql/src/planner/planner-warnings.d.ts +83 -0
- package/out/zql/src/planner/planner-warnings.d.ts.map +1 -0
- package/out/zql/src/planner/planner-warnings.js +78 -0
- package/out/zql/src/planner/planner-warnings.js.map +1 -0
- package/out/zql/src/query/measure-push-operator.d.ts +2 -1
- package/out/zql/src/query/measure-push-operator.d.ts.map +1 -1
- package/out/zql/src/query/measure-push-operator.js +33 -4
- package/out/zql/src/query/measure-push-operator.js.map +1 -1
- package/out/zql/src/query/query-delegate-base.d.ts +4 -2
- package/out/zql/src/query/query-delegate-base.d.ts.map +1 -1
- package/out/zql/src/query/query-delegate-base.js +66 -33
- package/out/zql/src/query/query-delegate-base.js.map +1 -1
- package/out/zql/src/query/query-delegate.d.ts +33 -6
- package/out/zql/src/query/query-delegate.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.d.ts +1 -0
- package/out/zql/src/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.js +6 -23
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/out/zql/src/query/query-transitions.d.ts.map +1 -1
- package/out/zql/src/query/query-transitions.js +2 -5
- package/out/zql/src/query/query-transitions.js.map +1 -1
- package/out/zql/src/query/query.d.ts +11 -2
- package/out/zql/src/query/query.d.ts.map +1 -1
- package/out/zql/src/query/runnable-query-impl.d.ts +1 -0
- package/out/zql/src/query/runnable-query-impl.d.ts.map +1 -1
- package/out/zql/src/query/runnable-query-impl.js +2 -10
- package/out/zql/src/query/runnable-query-impl.js.map +1 -1
- package/out/zql/src/query/typed-view.d.ts +1 -1
- package/out/zql/src/query/typed-view.d.ts.map +1 -1
- package/out/zqlite/src/database-storage.d.ts.map +1 -1
- package/out/zqlite/src/database-storage.js +9 -1
- package/out/zqlite/src/database-storage.js.map +1 -1
- package/out/zqlite/src/db.d.ts +9 -1
- package/out/zqlite/src/db.d.ts.map +1 -1
- package/out/zqlite/src/db.js +31 -27
- package/out/zqlite/src/db.js.map +1 -1
- package/out/zqlite/src/pending-delta.d.ts +110 -0
- package/out/zqlite/src/pending-delta.d.ts.map +1 -0
- package/out/zqlite/src/pending-delta.js +278 -0
- package/out/zqlite/src/pending-delta.js.map +1 -0
- package/out/zqlite/src/query-builder.d.ts +17 -1
- package/out/zqlite/src/query-builder.d.ts.map +1 -1
- package/out/zqlite/src/query-builder.js +111 -20
- package/out/zqlite/src/query-builder.js.map +1 -1
- package/out/zqlite/src/query-delegate.d.ts.map +1 -1
- package/out/zqlite/src/query-delegate.js +10 -7
- package/out/zqlite/src/query-delegate.js.map +1 -1
- package/out/zqlite/src/sqlite-cost-model.d.ts.map +1 -1
- package/out/zqlite/src/sqlite-cost-model.js +52 -1
- package/out/zqlite/src/sqlite-cost-model.js.map +1 -1
- package/out/zqlite/src/sqlite-stat-fanout.d.ts.map +1 -1
- package/out/zqlite/src/sqlite-stat-fanout.js +5 -31
- package/out/zqlite/src/sqlite-stat-fanout.js.map +1 -1
- package/out/zqlite/src/sqlite-stat4-sample.d.ts +37 -0
- package/out/zqlite/src/sqlite-stat4-sample.d.ts.map +1 -0
- package/out/zqlite/src/sqlite-stat4-sample.js +61 -0
- package/out/zqlite/src/sqlite-stat4-sample.js.map +1 -0
- package/out/zqlite/src/table-source.d.ts +82 -2
- package/out/zqlite/src/table-source.d.ts.map +1 -1
- package/out/zqlite/src/table-source.js +261 -38
- package/out/zqlite/src/table-source.js.map +1 -1
- package/package.json +3 -4
- package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts +0 -25
- package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts.map +0 -1
- package/out/replicache/src/kv/idb-store-with-mem-fallback.js +0 -83
- package/out/replicache/src/kv/idb-store-with-mem-fallback.js.map +0 -1
|
@@ -35,6 +35,8 @@ export interface Input extends InputBase {
|
|
|
35
35
|
* caller of fetch immediately.
|
|
36
36
|
* - During push: If a fetch to an input consumed by the push logic yields
|
|
37
37
|
* 'yield', it must be yielded to the caller of push immediately.
|
|
38
|
+
* - During reconcile: If a fetch to an input consumed by reconcile logic
|
|
39
|
+
* yields 'yield', it must be yielded to the caller of reconcile immediately.
|
|
38
40
|
*/
|
|
39
41
|
fetch(req: FetchRequest): Stream<Node | 'yield'>;
|
|
40
42
|
}
|
|
@@ -115,37 +117,64 @@ export type Start = {
|
|
|
115
117
|
readonly basis: 'at' | 'after';
|
|
116
118
|
};
|
|
117
119
|
/**
|
|
118
|
-
* An output for an operator. Typically another Operator
|
|
119
|
-
*
|
|
120
|
+
* An output for an operator. Typically another Operator in an IVM pipeline,
|
|
121
|
+
* but can also be a terminal sink (such as a View or test consumer).
|
|
120
122
|
*/
|
|
121
123
|
export interface Output {
|
|
122
124
|
/**
|
|
123
|
-
*
|
|
124
|
-
* Consumers must apply all pushed changes or
|
|
125
|
-
* be incorrect.
|
|
125
|
+
* Phase 1 of two-phase push: pushes incremental changes to data previously
|
|
126
|
+
* received with fetch(). Consumers must apply all pushed changes or the
|
|
127
|
+
* incremental result will be incorrect.
|
|
128
|
+
*
|
|
126
129
|
* Callers must maintain some invariants for correct operation:
|
|
127
130
|
* - Only add rows which do not already exist (by deep equality).
|
|
128
131
|
* - Only remove rows which do exist (by deep equality).
|
|
129
|
-
*
|
|
130
|
-
*
|
|
132
|
+
*
|
|
133
|
+
* Implementations can yield 'yield' to yield control to the caller for
|
|
134
|
+
* purposes of responsiveness.
|
|
135
|
+
*
|
|
131
136
|
* Yield contract:
|
|
132
137
|
* - During a push: If a push call to an output yields 'yield', it must be
|
|
133
|
-
*
|
|
138
|
+
* yielded to the caller of push immediately.
|
|
134
139
|
*/
|
|
135
140
|
push(change: Change, pusher: InputBase): Stream<'yield'>;
|
|
141
|
+
/**
|
|
142
|
+
* Phase 2 of two-phase push: invoked after Phase 1 changes have propagated.
|
|
143
|
+
* Bounded operators (such as Take or Cap) use this signal to refill deficits,
|
|
144
|
+
* emit refilled rows downstream via push(), and update their bounds.
|
|
145
|
+
*
|
|
146
|
+
* Implementations can yield 'yield' to yield control to the caller for
|
|
147
|
+
* purposes of responsiveness.
|
|
148
|
+
*
|
|
149
|
+
* Yield contract:
|
|
150
|
+
* - During reconcile: If an internal fetch, push, or downstream reconcile call
|
|
151
|
+
* yields 'yield', it must be yielded to the caller of reconcile immediately.
|
|
152
|
+
*
|
|
153
|
+
* This method is optional on Output to allow terminal sinks (such as UI views
|
|
154
|
+
* or custom third-party sinks) that only consume changes to omit it without
|
|
155
|
+
* breaking compatibility. Intermediate operators must check
|
|
156
|
+
* `if (this.#output.reconcile)` before forwarding.
|
|
157
|
+
*/
|
|
158
|
+
reconcile?(pusher: InputBase): Stream<'yield'>;
|
|
136
159
|
}
|
|
137
160
|
/**
|
|
138
161
|
* An implementation of Output that throws if pushed to. It is used as the
|
|
139
|
-
* initial value for
|
|
162
|
+
* initial value for an operator's output before it is set.
|
|
140
163
|
*/
|
|
141
164
|
export declare const throwOutput: Output;
|
|
142
165
|
/**
|
|
143
|
-
* Operators are arranged into pipelines.
|
|
166
|
+
* Operators are arranged into IVM pipelines.
|
|
144
167
|
* They are stateful.
|
|
145
168
|
* Each operator is an input to the next operator in the chain and an output
|
|
146
169
|
* to the previous.
|
|
147
170
|
*/
|
|
148
171
|
export interface Operator extends Input, Output {
|
|
172
|
+
/**
|
|
173
|
+
* Intermediate pipeline operators MUST implement reconcile so that Phase 2
|
|
174
|
+
* reconciliation reaches all bounded operators in the pipeline and is never
|
|
175
|
+
* accidentally swallowed.
|
|
176
|
+
*/
|
|
177
|
+
reconcile(pusher: InputBase): Stream<'yield'>;
|
|
149
178
|
}
|
|
150
179
|
/**
|
|
151
180
|
* Operators get access to storage that they can store their internal
|
|
@@ -161,5 +190,11 @@ export interface Storage {
|
|
|
161
190
|
prefix: string;
|
|
162
191
|
}): Stream<[string, JSONValue]>;
|
|
163
192
|
del(key: string): void;
|
|
193
|
+
/**
|
|
194
|
+
* Called by the operator that owns the storage when the operator is
|
|
195
|
+
* destroyed. Releases anything the storage holds outside of the operator
|
|
196
|
+
* (e.g. rows in a shared database). The storage is not used afterwards.
|
|
197
|
+
*/
|
|
198
|
+
destroy(): void;
|
|
164
199
|
}
|
|
165
200
|
//# sourceMappingURL=operator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../../../../../zql/src/ivm/operator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAC5D,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,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B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,QAAS,SAAQ,KAAK,EAAE,MAAM;IAC7C;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACzC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IACzD;;OAEG;IACH,IAAI,CAAC,OAAO,CAAC,EAAE;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAC9D,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB;;;;OAIG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
|
@@ -2,11 +2,16 @@ import "./skip-yields.js";
|
|
|
2
2
|
//#region ../zql/src/ivm/operator.ts
|
|
3
3
|
/**
|
|
4
4
|
* An implementation of Output that throws if pushed to. It is used as the
|
|
5
|
-
* initial value for
|
|
5
|
+
* initial value for an operator's output before it is set.
|
|
6
6
|
*/
|
|
7
|
-
var throwOutput = {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
var throwOutput = {
|
|
8
|
+
push(_change) {
|
|
9
|
+
throw new Error("Output not set");
|
|
10
|
+
},
|
|
11
|
+
reconcile() {
|
|
12
|
+
throw new Error("Output not set");
|
|
13
|
+
}
|
|
14
|
+
};
|
|
10
15
|
//#endregion
|
|
11
16
|
export { throwOutput };
|
|
12
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.js","names":[],"sources":["../../../../../zql/src/ivm/operator.ts"],"sourcesContent":["import type {JSONValue} from '../../../shared/src/json.ts';\nimport type {Row} from '../../../zero-protocol/src/data.ts';\nimport type {NoSubqueryCondition} from '../builder/filter.ts';\nimport type {Change} from './change.ts';\nimport type {Constraint} from './constraint.ts';\nimport type {Node} from './data.ts';\nimport type {SourceSchema} from './schema.ts';\nimport type {Stream} from './stream.ts';\n\nexport {skipYields} from './skip-yields.ts';\n\n/**\n * Input to an operator.\n */\nexport interface InputBase {\n /** The schema of the data this input returns. */\n getSchema(): SourceSchema;\n\n /**\n * Completely destroy the input. Destroying an input\n * causes it to call destroy on its upstreams, fully\n * cleaning up a pipeline.\n */\n destroy(): void;\n}\n\nexport interface Input extends InputBase {\n /** Tell the input where to send its output. */\n setOutput(output: Output): void;\n\n /**\n * Fetch data. May modify the data in place.\n * Returns nodes sorted in order of `SourceSchema.compareRows`.\n *\n * The stream may contain 'yield' to yield control to the caller for purposes\n * of responsiveness.\n *\n * Contract:\n * - During fetch: If an input yields 'yield', 'yield' must be yielded to the\n * caller of fetch immediately.\n * - During push: If a fetch to an input consumed by the push logic yields\n * 'yield', it must be yielded to the caller of push immediately.\n */\n fetch(req: FetchRequest): Stream<Node | 'yield'>;\n}\n\n/**\n * A single multi-row IN clause: a non-empty list of Constraints all\n * sharing the same column shape. Sources treat it as\n * `(col_a, col_b, …) IN VALUES (…)`.\n *\n * Caller invariants (sources rely on these — they are not re-checked):\n * - **Unique entries.** TableSource gets set semantics for free from SQL\n * `IN`; MemorySource fans sub-fetches out per entry, so duplicates\n * would yield the same row N times. FlippedJoin groups by canonical\n * parent-key (`flipped-join.ts:#fetchBatched`) before emitting.\n * - **Key-compatible with `req.constraint`.** Entries that contradict\n * `constraint` should be dropped upstream. FlippedJoin filters\n * incompatible children via `constraintsAreCompatible` before adding\n * them to a batch.\n */\nexport type MultiConstraint = readonly Constraint[];\n\nexport type FetchRequest = {\n readonly constraint?: Constraint | undefined;\n\n /**\n * List of multi-row IN clauses, all ANDed together (and ANDed with\n * `constraint` if both are provided). Each entry is a `MultiConstraint`\n * over its own set of columns.\n *\n * Used by FlippedJoin to push child→parent fetches into a single\n * batched statement, and to AND together constraints contributed by\n * chained FlippedJoins (e.g. `assigneeID IN (…) AND creatorID IN (…)`).\n */\n readonly multiConstraints?: readonly MultiConstraint[] | undefined;\n\n /** If supplied, `start.row` must have previously been output by fetch or push. */\n readonly start?: Start | undefined;\n\n /** Whether to fetch in reverse order of the SourceSchema's sort. */\n readonly reverse?: boolean | undefined;\n\n /**\n * Additional predicate the consumer wants the source/intermediate operators\n * to apply to the fetched rows. The receiver must AND this with whatever\n * filtering it already applies. Sources may use this to drive index\n * selection (e.g. PK lookup) the same way they use the connection-time\n * filter.\n *\n * Always a `NoSubqueryCondition` — anything passed via `req.filter` must\n * already have had correlated subqueries stripped (see `transformFilters`).\n *\n * Contract:\n * - The only operator that *introduces* `req.filter` is `FilterStart`. It\n * AND-merges its static condition with whatever `req.filter` it receives\n * and forwards the merged value upstream. No other operator should\n * construct a `req.filter`.\n * - \"Pass-through\" fetch operators (`Skip`, `Take`, `Join`, `FlippedJoin`,\n * `UnionFanIn`, `UnionFanOut`) MUST preserve `req.filter` when forwarding\n * to their input — typically via `{...req, ...overrides}` spread. Dropping\n * it silently regresses predicate pushdown for queries below the\n * forwarding operator.\n * - Operators that *initiate* internal fetches (e.g., `Join.#pushChildChange`,\n * `FlippedJoin.#pushChildChange`, `UnionFanIn.#pushInternalChange`,\n * `Take`'s push-time bound recomputation) construct fresh\n * `FetchRequest`s without `req.filter`, and that is correct: there is no\n * inbound consumer-side filter at those call sites. Any `FilterStart`\n * that sits between such an internal fetch and the source will still\n * apply its own condition on the way through, so the source still gets\n * the right WHERE.\n * - `Cap` is *not* a pass-through: it intentionally builds fresh\n * `{constraint}` requests when replaying tracked PKs and drops any\n * incoming `req.filter`. This is sound only because `Cap`'s sole\n * consumer in production is a `Join`'s child fetch (see\n * `Join.#processParentNode` in `join.ts`), which itself never carries\n * `req.filter` — Join's child fetches are constructed with just\n * `{constraint}` derived from join keys. If `Cap` is ever wired below\n * something that does push a `req.filter`, this carve-out becomes a\n * correctness bug.\n */\n readonly filter?: NoSubqueryCondition | undefined;\n};\n\nexport type Start = {\n readonly row: Row;\n readonly basis: 'at' | 'after';\n};\n\n/**\n * An output for an operator. Typically another Operator but can also be
|
|
1
|
+
{"version":3,"file":"operator.js","names":[],"sources":["../../../../../zql/src/ivm/operator.ts"],"sourcesContent":["import type {JSONValue} from '../../../shared/src/json.ts';\nimport type {Row} from '../../../zero-protocol/src/data.ts';\nimport type {NoSubqueryCondition} from '../builder/filter.ts';\nimport type {Change} from './change.ts';\nimport type {Constraint} from './constraint.ts';\nimport type {Node} from './data.ts';\nimport type {SourceSchema} from './schema.ts';\nimport type {Stream} from './stream.ts';\n\nexport {skipYields} from './skip-yields.ts';\n\n/**\n * Input to an operator.\n */\nexport interface InputBase {\n /** The schema of the data this input returns. */\n getSchema(): SourceSchema;\n\n /**\n * Completely destroy the input. Destroying an input\n * causes it to call destroy on its upstreams, fully\n * cleaning up a pipeline.\n */\n destroy(): void;\n}\n\nexport interface Input extends InputBase {\n /** Tell the input where to send its output. */\n setOutput(output: Output): void;\n\n /**\n * Fetch data. May modify the data in place.\n * Returns nodes sorted in order of `SourceSchema.compareRows`.\n *\n * The stream may contain 'yield' to yield control to the caller for purposes\n * of responsiveness.\n *\n * Contract:\n * - During fetch: If an input yields 'yield', 'yield' must be yielded to the\n * caller of fetch immediately.\n * - During push: If a fetch to an input consumed by the push logic yields\n * 'yield', it must be yielded to the caller of push immediately.\n * - During reconcile: If a fetch to an input consumed by reconcile logic\n * yields 'yield', it must be yielded to the caller of reconcile immediately.\n */\n fetch(req: FetchRequest): Stream<Node | 'yield'>;\n}\n\n/**\n * A single multi-row IN clause: a non-empty list of Constraints all\n * sharing the same column shape. Sources treat it as\n * `(col_a, col_b, …) IN VALUES (…)`.\n *\n * Caller invariants (sources rely on these — they are not re-checked):\n * - **Unique entries.** TableSource gets set semantics for free from SQL\n * `IN`; MemorySource fans sub-fetches out per entry, so duplicates\n * would yield the same row N times. FlippedJoin groups by canonical\n * parent-key (`flipped-join.ts:#fetchBatched`) before emitting.\n * - **Key-compatible with `req.constraint`.** Entries that contradict\n * `constraint` should be dropped upstream. FlippedJoin filters\n * incompatible children via `constraintsAreCompatible` before adding\n * them to a batch.\n */\nexport type MultiConstraint = readonly Constraint[];\n\nexport type FetchRequest = {\n readonly constraint?: Constraint | undefined;\n\n /**\n * List of multi-row IN clauses, all ANDed together (and ANDed with\n * `constraint` if both are provided). Each entry is a `MultiConstraint`\n * over its own set of columns.\n *\n * Used by FlippedJoin to push child→parent fetches into a single\n * batched statement, and to AND together constraints contributed by\n * chained FlippedJoins (e.g. `assigneeID IN (…) AND creatorID IN (…)`).\n */\n readonly multiConstraints?: readonly MultiConstraint[] | undefined;\n\n /** If supplied, `start.row` must have previously been output by fetch or push. */\n readonly start?: Start | undefined;\n\n /** Whether to fetch in reverse order of the SourceSchema's sort. */\n readonly reverse?: boolean | undefined;\n\n /**\n * Additional predicate the consumer wants the source/intermediate operators\n * to apply to the fetched rows. The receiver must AND this with whatever\n * filtering it already applies. Sources may use this to drive index\n * selection (e.g. PK lookup) the same way they use the connection-time\n * filter.\n *\n * Always a `NoSubqueryCondition` — anything passed via `req.filter` must\n * already have had correlated subqueries stripped (see `transformFilters`).\n *\n * Contract:\n * - The only operator that *introduces* `req.filter` is `FilterStart`. It\n * AND-merges its static condition with whatever `req.filter` it receives\n * and forwards the merged value upstream. No other operator should\n * construct a `req.filter`.\n * - \"Pass-through\" fetch operators (`Skip`, `Take`, `Join`, `FlippedJoin`,\n * `UnionFanIn`, `UnionFanOut`) MUST preserve `req.filter` when forwarding\n * to their input — typically via `{...req, ...overrides}` spread. Dropping\n * it silently regresses predicate pushdown for queries below the\n * forwarding operator.\n * - Operators that *initiate* internal fetches (e.g., `Join.#pushChildChange`,\n * `FlippedJoin.#pushChildChange`, `UnionFanIn.#pushInternalChange`,\n * `Take`'s push-time bound recomputation) construct fresh\n * `FetchRequest`s without `req.filter`, and that is correct: there is no\n * inbound consumer-side filter at those call sites. Any `FilterStart`\n * that sits between such an internal fetch and the source will still\n * apply its own condition on the way through, so the source still gets\n * the right WHERE.\n * - `Cap` is *not* a pass-through: it intentionally builds fresh\n * `{constraint}` requests when replaying tracked PKs and drops any\n * incoming `req.filter`. This is sound only because `Cap`'s sole\n * consumer in production is a `Join`'s child fetch (see\n * `Join.#processParentNode` in `join.ts`), which itself never carries\n * `req.filter` — Join's child fetches are constructed with just\n * `{constraint}` derived from join keys. If `Cap` is ever wired below\n * something that does push a `req.filter`, this carve-out becomes a\n * correctness bug.\n */\n readonly filter?: NoSubqueryCondition | undefined;\n};\n\nexport type Start = {\n readonly row: Row;\n readonly basis: 'at' | 'after';\n};\n\n/**\n * An output for an operator. Typically another Operator in an IVM pipeline,\n * but can also be a terminal sink (such as a View or test consumer).\n */\nexport interface Output {\n /**\n * Phase 1 of two-phase push: pushes incremental changes to data previously\n * received with fetch(). Consumers must apply all pushed changes or the\n * incremental result will be incorrect.\n *\n * Callers must maintain some invariants for correct operation:\n * - Only add rows which do not already exist (by deep equality).\n * - Only remove rows which do exist (by deep equality).\n *\n * Implementations can yield 'yield' to yield control to the caller for\n * purposes of responsiveness.\n *\n * Yield contract:\n * - During a push: If a push call to an output yields 'yield', it must be\n * yielded to the caller of push immediately.\n */\n push(change: Change, pusher: InputBase): Stream<'yield'>;\n\n /**\n * Phase 2 of two-phase push: invoked after Phase 1 changes have propagated.\n * Bounded operators (such as Take or Cap) use this signal to refill deficits,\n * emit refilled rows downstream via push(), and update their bounds.\n *\n * Implementations can yield 'yield' to yield control to the caller for\n * purposes of responsiveness.\n *\n * Yield contract:\n * - During reconcile: If an internal fetch, push, or downstream reconcile call\n * yields 'yield', it must be yielded to the caller of reconcile immediately.\n *\n * This method is optional on Output to allow terminal sinks (such as UI views\n * or custom third-party sinks) that only consume changes to omit it without\n * breaking compatibility. Intermediate operators must check\n * `if (this.#output.reconcile)` before forwarding.\n */\n reconcile?(pusher: InputBase): Stream<'yield'>;\n}\n\n/**\n * An implementation of Output that throws if pushed to. It is used as the\n * initial value for an operator's output before it is set.\n */\nexport const throwOutput: Output = {\n push(_change: Change): Stream<'yield'> {\n throw new Error('Output not set');\n },\n reconcile(): Stream<'yield'> {\n throw new Error('Output not set');\n },\n};\n\n/**\n * Operators are arranged into IVM pipelines.\n * They are stateful.\n * Each operator is an input to the next operator in the chain and an output\n * to the previous.\n */\nexport interface Operator extends Input, Output {\n /**\n * Intermediate pipeline operators MUST implement reconcile so that Phase 2\n * reconciliation reaches all bounded operators in the pipeline and is never\n * accidentally swallowed.\n */\n reconcile(pusher: InputBase): Stream<'yield'>;\n}\n\n/**\n * Operators get access to storage that they can store their internal\n * state in.\n */\nexport interface Storage {\n set(key: string, value: JSONValue): void;\n get(key: string, def?: JSONValue): JSONValue | undefined;\n /**\n * If options is not specified, defaults to scanning all entries.\n */\n scan(options?: {prefix: string}): Stream<[string, JSONValue]>;\n del(key: string): void;\n /**\n * Called by the operator that owns the storage when the operator is\n * destroyed. Releases anything the storage holds outside of the operator\n * (e.g. rows in a shared database). The storage is not used afterwards.\n */\n destroy(): void;\n}\n"],"mappings":";;;;;;AAkLA,IAAa,cAAsB;CACjC,KAAK,SAAkC;EACrC,MAAM,IAAI,MAAM,gBAAgB;CAClC;CACA,YAA6B;EAC3B,MAAM,IAAI,MAAM,gBAAgB;CAClC;AACF"}
|
|
@@ -73,7 +73,12 @@ import type { Stream } from './stream.ts';
|
|
|
73
73
|
* If an edit enters and is converted to only add or only remove, it exits as that change.
|
|
74
74
|
* If an edit enters and exits as edits only, it exits as a single edit.
|
|
75
75
|
*/
|
|
76
|
-
export declare function pushAccumulatedChanges(accumulatedPushes: Change[], output: Output, pusher: InputBase, fanOutChangeType: ChangeType, mergeRelationships: (existing: Change, incoming: Change) => Change, addEmptyRelationships: (change: Change) => Change): Stream<'yield'>;
|
|
76
|
+
export declare function pushAccumulatedChanges(accumulatedPushes: Change[], output: Output, pusher: InputBase, fanOutChangeType: ChangeType, mergeRelationships: (existing: Change, incoming: Change) => Change, addEmptyRelationships: (change: Change) => Change, isBranchRel?: (name: string) => boolean): Stream<'yield'>;
|
|
77
|
+
/**
|
|
78
|
+
* The row stays downstream, but it gained (`ADD`) or lost (`REMOVE`) every
|
|
79
|
+
* witness in `node`'s branch relationships. One child change per witness.
|
|
80
|
+
*/
|
|
81
|
+
export declare function pushWitnessDeltas(node: Node, type: ChangeType.ADD | ChangeType.REMOVE, isBranchRel: (name: string) => boolean, output: Output, pusher: InputBase): Stream<'yield'>;
|
|
77
82
|
/**
|
|
78
83
|
* Puts relationships from `right` into `left` if they don't already exist in `left`.
|
|
79
84
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push-accumulated.d.ts","sourceRoot":"","sources":["../../../../../zql/src/ivm/push-accumulated.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAKL,KAAK,MAAM,EACZ,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,wBAAiB,sBAAsB,CACrC,iBAAiB,EAAE,MAAM,EAAE,EAC3B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,gBAAgB,EAAE,UAAU,EAC5B,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,EAClE,qBAAqB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,
|
|
1
|
+
{"version":3,"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GtE;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,YAAY,GACnB,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CA0C5B;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC,EAC3D,iBAAiB,EAAE,MAAM,EAAE,QAO5B"}
|
|
@@ -72,10 +72,16 @@ import { makeAddChange, makeChildChange, makeEditChange, makeRemoveChange } from
|
|
|
72
72
|
* If an edit enters and is converted to only add or only remove, it exits as that change.
|
|
73
73
|
* If an edit enters and exits as edits only, it exits as a single edit.
|
|
74
74
|
*/
|
|
75
|
-
function* pushAccumulatedChanges(accumulatedPushes, output, pusher, fanOutChangeType, mergeRelationships, addEmptyRelationships) {
|
|
75
|
+
function* pushAccumulatedChanges(accumulatedPushes, output, pusher, fanOutChangeType, mergeRelationships, addEmptyRelationships, isBranchRel) {
|
|
76
76
|
if (accumulatedPushes.length === 0) return;
|
|
77
|
+
const witnessesLeft = [];
|
|
78
|
+
const witnessesEntered = [];
|
|
77
79
|
const candidatesToPush = /* @__PURE__ */ new Map();
|
|
78
80
|
for (const change of accumulatedPushes) {
|
|
81
|
+
if (isBranchRel && change[0] === 3 && isBranchRel(change[2].relationshipName)) {
|
|
82
|
+
(change[2].change[0] === 1 ? witnessesLeft : witnessesEntered).push(change);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
79
85
|
if (fanOutChangeType === 3 && change[0] !== 3) assert(candidatesToPush.has(change[0]) === false, () => `Fan-in:child expected at most one ${change[0]} when fan-out is of type child`);
|
|
80
86
|
const existing = candidatesToPush.get(change[0]);
|
|
81
87
|
let mergedChange = change;
|
|
@@ -83,6 +89,12 @@ function* pushAccumulatedChanges(accumulatedPushes, output, pusher, fanOutChange
|
|
|
83
89
|
candidatesToPush.set(change[0], mergedChange);
|
|
84
90
|
}
|
|
85
91
|
accumulatedPushes.length = 0;
|
|
92
|
+
assert(candidatesToPush.size > 0, "Fan-in: witness changes without a change for their row");
|
|
93
|
+
for (const change of witnessesLeft) yield* output.push(change, pusher);
|
|
94
|
+
yield* pushCollapsed(candidatesToPush, output, pusher, fanOutChangeType, mergeRelationships, addEmptyRelationships, isBranchRel);
|
|
95
|
+
for (const change of witnessesEntered) yield* output.push(change, pusher);
|
|
96
|
+
}
|
|
97
|
+
function* pushCollapsed(candidatesToPush, output, pusher, fanOutChangeType, mergeRelationships, addEmptyRelationships, isBranchRel) {
|
|
86
98
|
const types = [...candidatesToPush.keys()];
|
|
87
99
|
/**
|
|
88
100
|
* Based on the received `fanOutChangeType` only certain output types are valid.
|
|
@@ -108,6 +120,16 @@ function* pushAccumulatedChanges(accumulatedPushes, output, pusher, fanOutChange
|
|
|
108
120
|
const addChange = candidatesToPush.get(0);
|
|
109
121
|
const removeChange = candidatesToPush.get(1);
|
|
110
122
|
let editChange = candidatesToPush.get(2);
|
|
123
|
+
if (isBranchRel && (editChange || addChange && removeChange)) {
|
|
124
|
+
if (removeChange) yield* pushWitnessDeltas(removeChange[1], 1, isBranchRel, output, pusher);
|
|
125
|
+
const strip = (n) => ({
|
|
126
|
+
row: n.row,
|
|
127
|
+
relationships: Object.fromEntries(Object.entries(n.relationships).filter(([k]) => !isBranchRel(k)))
|
|
128
|
+
});
|
|
129
|
+
yield* output.push(addEmptyRelationships(editChange ?? makeEditChange(strip(must(addChange)[1]), strip(must(removeChange)[1]))), pusher);
|
|
130
|
+
if (addChange) yield* pushWitnessDeltas(addChange[1], 0, isBranchRel, output, pusher);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
111
133
|
if (editChange) {
|
|
112
134
|
if (addChange) editChange = mergeRelationships(editChange, addChange);
|
|
113
135
|
if (removeChange) editChange = mergeRelationships(editChange, removeChange);
|
|
@@ -126,7 +148,11 @@ function* pushAccumulatedChanges(accumulatedPushes, output, pusher, fanOutChange
|
|
|
126
148
|
assert(types.length <= 2, "Fan-in:child expected at most 2 types on a child change from fan-out");
|
|
127
149
|
const childChange = candidatesToPush.get(3);
|
|
128
150
|
if (childChange) {
|
|
151
|
+
const left = candidatesToPush.get(1);
|
|
152
|
+
const entered = candidatesToPush.get(0);
|
|
153
|
+
if (isBranchRel && left) yield* pushWitnessDeltas(left[1], 1, isBranchRel, output, pusher);
|
|
129
154
|
yield* output.push(childChange, pusher);
|
|
155
|
+
if (isBranchRel && entered) yield* pushWitnessDeltas(entered[1], 0, isBranchRel, output, pusher);
|
|
130
156
|
return;
|
|
131
157
|
}
|
|
132
158
|
const addChange = candidatesToPush.get(0);
|
|
@@ -139,6 +165,25 @@ function* pushAccumulatedChanges(accumulatedPushes, output, pusher, fanOutChange
|
|
|
139
165
|
}
|
|
140
166
|
}
|
|
141
167
|
/**
|
|
168
|
+
* The row stays downstream, but it gained (`ADD`) or lost (`REMOVE`) every
|
|
169
|
+
* witness in `node`'s branch relationships. One child change per witness.
|
|
170
|
+
*/
|
|
171
|
+
function* pushWitnessDeltas(node, type, isBranchRel, output, pusher) {
|
|
172
|
+
for (const [relationshipName, children] of Object.entries(node.relationships)) {
|
|
173
|
+
if (!isBranchRel(relationshipName)) continue;
|
|
174
|
+
for (const child of children()) {
|
|
175
|
+
if (child === "yield") {
|
|
176
|
+
yield child;
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
yield* output.push(makeChildChange(node, {
|
|
180
|
+
relationshipName,
|
|
181
|
+
change: type === 0 ? makeAddChange(child) : makeRemoveChange(child)
|
|
182
|
+
}), pusher);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
142
187
|
* Puts relationships from `right` into `left` if they don't already exist in `left`.
|
|
143
188
|
*/
|
|
144
189
|
function mergeRelationships(left, right) {
|
|
@@ -248,6 +293,6 @@ function mergeEmpty(relationships, relationshipNames) {
|
|
|
248
293
|
for (const relName of relationshipNames) if (relationships[relName] === void 0) relationships[relName] = () => emptyArray;
|
|
249
294
|
}
|
|
250
295
|
//#endregion
|
|
251
|
-
export { makeAddEmptyRelationships, mergeRelationships, pushAccumulatedChanges };
|
|
296
|
+
export { makeAddEmptyRelationships, mergeEmpty, mergeRelationships, pushAccumulatedChanges, pushWitnessDeltas };
|
|
252
297
|
|
|
253
298
|
//# sourceMappingURL=push-accumulated.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push-accumulated.js","names":[],"sources":["../../../../../zql/src/ivm/push-accumulated.ts"],"sourcesContent":["import {assert, unreachable} from '../../../shared/src/asserts.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport {emptyArray} from '../../../shared/src/sentinels.ts';\nimport {ChangeIndex} from './change-index.ts';\nimport {ChangeType} from './change-type.ts';\nimport {\n makeAddChange,\n makeChildChange,\n makeEditChange,\n makeRemoveChange,\n type Change,\n} from './change.ts';\nimport type {Node} from './data.ts';\nimport type {InputBase, Output} from './operator.ts';\nimport type {SourceSchema} from './schema.ts';\nimport type {Stream} from './stream.ts';\n\n/**\n * # pushAccumulatedChanges\n *\n * Pushes the changes that were accumulated by\n * [fan-out, fan-in] or [ufo, ufi] sub-graphs.\n *\n * This function is called at the end of the sub-graph.\n *\n * The sub-graphs represents `OR`s.\n *\n * Changes that can enter the subgraphs:\n * 1. child (due to exist joins being above the sub-graph)\n * 2. add\n * 3. remove\n * 4. edit\n *\n * # Changes that can exit into `pushAccumulatedChanges`:\n *\n * ## Child\n * If a `child` change enters a sub-graph, it will flow to all branches.\n * Each branch will either:\n * - preserve the `child` change\n * - stop the `child` change (e.g., filter)\n * - convert it to an `add` or `remove` (e.g., exists filter)\n *\n * ## Add\n * If an `add` change enters a sub-graph, it will flow to all branches.\n * Each branch will either:\n * - preserve the `add` change\n * - hide the change (e.g., filter)\n *\n * ## Remove\n * If a `remove` change enters a sub-graph, it will flow to all branches.\n * Each branch will either:\n * - preserve the `remove` change\n * - hide the change (e.g., filter)\n *\n * ## Edit\n * If an `edit` change enters a sub-graph, it will flow to all branches.\n * Each branch will either:\n * - preserve the `edit` change\n * - convert it to an `add` (e.g., filter where old didn't match but new does)\n * - convert it to a `remove` (e.g., filter where old matched but new doesn't)\n *\n * This results in some invariants:\n * - an add coming in will only create adds coming out\n * - a remove coming in will only create removes coming out\n * - an edit coming in can create adds, removes, and edits coming out\n * - a child coming in can create adds, removes, and children coming out\n *\n * # Return of `pushAccumulatedChanges`\n *\n * This function will only push a single change.\n * Given the above invariants, how is this possible?\n *\n * An add that becomes many `adds` results in a single add\n * as the `add` is the same row across all adds. Branches do not change the row.\n *\n * A remove that becomes many `removes` results in a single remove\n * for the same reason.\n *\n * If a child enters and exits, it takes precedence over all other changes.\n * If a child enters and is converted only to add and remove it exits as an edit.\n * If a child enters and is converted to only add or only remove, it exits as that change.\n *\n * If an edit enters and is converted to add and remove it exits as an edit.\n * If an edit enters and is converted to only add or only remove, it exits as that change.\n * If an edit enters and exits as edits only, it exits as a single edit.\n */\nexport function* pushAccumulatedChanges(\n accumulatedPushes: Change[],\n output: Output,\n pusher: InputBase,\n fanOutChangeType: ChangeType,\n mergeRelationships: (existing: Change, incoming: Change) => Change,\n addEmptyRelationships: (change: Change) => Change,\n): Stream<'yield'> {\n if (accumulatedPushes.length === 0) {\n // It is possible for no forks to pass along the push.\n // E.g., if no filters match in any fork.\n return;\n }\n\n // collapse down to a single change per type\n const candidatesToPush = new Map<ChangeType, Change>();\n for (const change of accumulatedPushes) {\n if (\n fanOutChangeType === ChangeType.CHILD &&\n change[ChangeIndex.TYPE] !== ChangeType.CHILD\n ) {\n assert(\n candidatesToPush.has(change[ChangeIndex.TYPE]) === false,\n () =>\n `Fan-in:child expected at most one ${change[ChangeIndex.TYPE]} when fan-out is of type child`,\n );\n }\n\n const existing = candidatesToPush.get(change[ChangeIndex.TYPE]);\n let mergedChange = change;\n if (existing) {\n // merge in relationships\n mergedChange = mergeRelationships(existing, change);\n }\n candidatesToPush.set(change[ChangeIndex.TYPE], mergedChange);\n }\n\n accumulatedPushes.length = 0;\n\n const types = [...candidatesToPush.keys()];\n /**\n * Based on the received `fanOutChangeType` only certain output types are valid.\n *\n * - remove must result in all removes\n * - add must result in all adds\n * - edit must result in add or removes or edits\n * - child must result in a single add or single remove or many child changes\n * - Single add or remove because the relationship will be unique to one exist check within the fan-out,fan-in sub-graph\n * - Many child changes because other operators may preserve the child change\n */\n switch (fanOutChangeType) {\n case ChangeType.REMOVE:\n assert(\n types.length === 1 && types[0] === ChangeType.REMOVE,\n 'Fan-in:remove expected all removes',\n );\n yield* output.push(\n addEmptyRelationships(must(candidatesToPush.get(ChangeType.REMOVE))),\n pusher,\n );\n return;\n case ChangeType.ADD:\n assert(\n types.length === 1 && types[0] === ChangeType.ADD,\n 'Fan-in:add expected all adds',\n );\n yield* output.push(\n addEmptyRelationships(must(candidatesToPush.get(ChangeType.ADD))),\n pusher,\n );\n return;\n case ChangeType.EDIT: {\n assert(\n types.every(\n type =>\n type === ChangeType.ADD ||\n type === ChangeType.REMOVE ||\n type === ChangeType.EDIT,\n ),\n 'Fan-in:edit expected all adds, removes, or edits',\n );\n const addChange = candidatesToPush.get(ChangeType.ADD);\n const removeChange = candidatesToPush.get(ChangeType.REMOVE);\n let editChange = candidatesToPush.get(ChangeType.EDIT);\n\n // If an `edit` is present, it supersedes `add` and `remove`\n // as it semantically represents both.\n if (editChange) {\n if (addChange) {\n editChange = mergeRelationships(editChange, addChange);\n }\n if (removeChange) {\n editChange = mergeRelationships(editChange, removeChange);\n }\n yield* output.push(addEmptyRelationships(editChange), pusher);\n return;\n }\n\n // If `edit` didn't make it through but both `add` and `remove` did,\n // convert back to an edit.\n //\n // When can this happen?\n //\n // EDIT old: a=1, new: a=2\n // |\n // FanOut\n // / \\\n // a=1 a=2\n // | |\n // remove add\n // \\ /\n // FanIn\n //\n // The left filter converts the edit into a remove.\n // The right filter converts the edit into an add.\n if (addChange && removeChange) {\n yield* output.push(\n addEmptyRelationships(\n makeEditChange(\n addChange[ChangeIndex.NODE],\n removeChange[ChangeIndex.NODE],\n ),\n ),\n pusher,\n );\n return;\n }\n\n yield* output.push(\n addEmptyRelationships(must(addChange ?? removeChange)),\n pusher,\n );\n return;\n }\n case ChangeType.CHILD: {\n assert(\n types.every(\n type =>\n type === ChangeType.ADD || // exists can change child to add or remove\n type === ChangeType.REMOVE || // exists can change child to add or remove\n type === ChangeType.CHILD, // other operators may preserve the child change\n ),\n 'Fan-in:child expected all adds, removes, or children',\n );\n assert(\n types.length <= 2,\n 'Fan-in:child expected at most 2 types on a child change from fan-out',\n );\n\n // If any branch preserved the original child change, that takes precedence over all other changes.\n const childChange = candidatesToPush.get(ChangeType.CHILD);\n if (childChange) {\n yield* output.push(childChange, pusher);\n return;\n }\n\n const addChange = candidatesToPush.get(ChangeType.ADD);\n const removeChange = candidatesToPush.get(ChangeType.REMOVE);\n\n assert(\n addChange === undefined || removeChange === undefined,\n 'Fan-in:child expected either add or remove, not both',\n );\n\n yield* output.push(\n addEmptyRelationships(must(addChange ?? removeChange)),\n pusher,\n );\n return;\n }\n default:\n fanOutChangeType satisfies never;\n }\n}\n\n/**\n * Puts relationships from `right` into `left` if they don't already exist in `left`.\n */\nexport function mergeRelationships(left: Change, right: Change): Change {\n // change types will always match\n // unless we have an edit on the left\n // then the right could be edit, add, or remove\n if (left[ChangeIndex.TYPE] === right[ChangeIndex.TYPE]) {\n switch (left[ChangeIndex.TYPE]) {\n case ChangeType.ADD: {\n return makeAddChange({\n row: left[ChangeIndex.NODE].row,\n relationships: {\n ...right[ChangeIndex.NODE].relationships,\n ...left[ChangeIndex.NODE].relationships,\n },\n });\n }\n case ChangeType.REMOVE: {\n return makeRemoveChange({\n row: left[ChangeIndex.NODE].row,\n relationships: {\n ...right[ChangeIndex.NODE].relationships,\n ...left[ChangeIndex.NODE].relationships,\n },\n });\n }\n case ChangeType.EDIT: {\n assert(\n right[ChangeIndex.TYPE] === ChangeType.EDIT,\n () =>\n `mergeRelationships: when left.type is edit and types match, right.type must be edit, got ${right[ChangeIndex.TYPE]}`,\n );\n // merge edits into a single edit\n return makeEditChange(\n {\n row: left[ChangeIndex.NODE].row,\n relationships: {\n ...right[ChangeIndex.NODE].relationships,\n ...left[ChangeIndex.NODE].relationships,\n },\n },\n {\n row: left[ChangeIndex.OLD_NODE].row,\n relationships: {\n ...right[ChangeIndex.OLD_NODE].relationships,\n ...left[ChangeIndex.OLD_NODE].relationships,\n },\n },\n );\n }\n case ChangeType.CHILD: {\n // Multiple branches may preserve the same child change, each adding\n // different relationships. Merge the relationships, keeping the child\n // (which should be identical across branches).\n assert(\n right[ChangeIndex.TYPE] === ChangeType.CHILD,\n () =>\n `mergeRelationships: when left.type is child and types match, right.type must be child, got ${right[ChangeIndex.TYPE]}`,\n );\n return makeChildChange(\n {\n row: left[ChangeIndex.NODE].row,\n relationships: {\n ...right[ChangeIndex.NODE].relationships,\n ...left[ChangeIndex.NODE].relationships,\n },\n },\n left[ChangeIndex.CHILD_DATA],\n );\n }\n }\n }\n\n // left is always an edit here\n assert(\n left[ChangeIndex.TYPE] === ChangeType.EDIT,\n () =>\n `mergeRelationships: when types differ, left.type must be edit, got left.type=${left[ChangeIndex.TYPE]}, right.type=${right[ChangeIndex.TYPE]}`,\n );\n switch (right[ChangeIndex.TYPE]) {\n case ChangeType.ADD: {\n return makeEditChange(\n {\n ...left[ChangeIndex.NODE],\n relationships: {\n ...right[ChangeIndex.NODE].relationships,\n ...left[ChangeIndex.NODE].relationships,\n },\n },\n left[ChangeIndex.OLD_NODE],\n );\n }\n case ChangeType.REMOVE: {\n return makeEditChange(left[ChangeIndex.NODE], {\n ...left[ChangeIndex.OLD_NODE],\n relationships: {\n ...right[ChangeIndex.NODE].relationships,\n ...left[ChangeIndex.OLD_NODE].relationships,\n },\n });\n }\n }\n\n unreachable();\n}\n\nexport function makeAddEmptyRelationships(\n schema: SourceSchema,\n): (change: Change) => Change {\n return (change: Change): Change => {\n if (Object.keys(schema.relationships).length === 0) {\n return change;\n }\n\n switch (change[ChangeIndex.TYPE]) {\n case ChangeType.ADD: {\n const relationships = {...change[ChangeIndex.NODE].relationships};\n mergeEmpty(relationships, Object.keys(schema.relationships));\n return makeAddChange({\n row: change[ChangeIndex.NODE].row,\n relationships,\n });\n }\n case ChangeType.REMOVE: {\n const relationships = {...change[ChangeIndex.NODE].relationships};\n mergeEmpty(relationships, Object.keys(schema.relationships));\n return makeRemoveChange({\n row: change[ChangeIndex.NODE].row,\n relationships,\n });\n }\n case ChangeType.EDIT: {\n const nodeRelationships = {...change[ChangeIndex.NODE].relationships};\n const oldNodeRelationships = {\n ...change[ChangeIndex.OLD_NODE].relationships,\n };\n mergeEmpty(nodeRelationships, Object.keys(schema.relationships));\n mergeEmpty(oldNodeRelationships, Object.keys(schema.relationships));\n return makeEditChange(\n {row: change[ChangeIndex.NODE].row, relationships: nodeRelationships},\n {\n row: change[ChangeIndex.OLD_NODE].row,\n relationships: oldNodeRelationships,\n },\n );\n }\n case ChangeType.CHILD:\n return change; // children only have relationships along the path to the change\n }\n };\n}\n\n/**\n * For each relationship in `schema` that does not exist\n * in `relationships`, add it with an empty stream.\n *\n * This modifies the `relationships` object in place.\n */\nexport function mergeEmpty(\n relationships: Record<string, () => Stream<Node | 'yield'>>,\n relationshipNames: string[],\n) {\n for (const relName of relationshipNames) {\n if (relationships[relName] === undefined) {\n relationships[relName] = () => emptyArray;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,UAAiB,uBACf,mBACA,QACA,QACA,kBACA,oBACA,uBACiB;CACjB,IAAI,kBAAkB,WAAW,GAG/B;CAIF,MAAM,mCAAmB,IAAI,IAAwB;CACrD,KAAK,MAAM,UAAU,mBAAmB;EACtC,IACE,qBAAqB,KACrB,OAAO,OAAsB,GAE7B,OACE,iBAAiB,IAAI,OAAO,EAAiB,MAAM,aAEjD,qCAAqC,OAAO,GAAkB,+BAClE;EAGF,MAAM,WAAW,iBAAiB,IAAI,OAAO,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,eACA,mBACA;CACA,KAAK,MAAM,WAAW,mBACpB,IAAI,cAAc,aAAa,KAAA,GAC7B,cAAc,iBAAiB;AAGrC"}
|
|
1
|
+
{"version":3,"file":"push-accumulated.js","names":[],"sources":["../../../../../zql/src/ivm/push-accumulated.ts"],"sourcesContent":["import {assert, unreachable} from '../../../shared/src/asserts.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport {emptyArray} from '../../../shared/src/sentinels.ts';\nimport {ChangeIndex} from './change-index.ts';\nimport {ChangeType} from './change-type.ts';\nimport {\n makeAddChange,\n makeChildChange,\n makeEditChange,\n makeRemoveChange,\n type Change,\n} from './change.ts';\nimport type {Node} from './data.ts';\nimport type {InputBase, Output} from './operator.ts';\nimport type {SourceSchema} from './schema.ts';\nimport type {Stream} from './stream.ts';\n\n/**\n * # pushAccumulatedChanges\n *\n * Pushes the changes that were accumulated by\n * [fan-out, fan-in] or [ufo, ufi] sub-graphs.\n *\n * This function is called at the end of the sub-graph.\n *\n * The sub-graphs represents `OR`s.\n *\n * Changes that can enter the subgraphs:\n * 1. child (due to exist joins being above the sub-graph)\n * 2. add\n * 3. remove\n * 4. edit\n *\n * # Changes that can exit into `pushAccumulatedChanges`:\n *\n * ## Child\n * If a `child` change enters a sub-graph, it will flow to all branches.\n * Each branch will either:\n * - preserve the `child` change\n * - stop the `child` change (e.g., filter)\n * - convert it to an `add` or `remove` (e.g., exists filter)\n *\n * ## Add\n * If an `add` change enters a sub-graph, it will flow to all branches.\n * Each branch will either:\n * - preserve the `add` change\n * - hide the change (e.g., filter)\n *\n * ## Remove\n * If a `remove` change enters a sub-graph, it will flow to all branches.\n * Each branch will either:\n * - preserve the `remove` change\n * - hide the change (e.g., filter)\n *\n * ## Edit\n * If an `edit` change enters a sub-graph, it will flow to all branches.\n * Each branch will either:\n * - preserve the `edit` change\n * - convert it to an `add` (e.g., filter where old didn't match but new does)\n * - convert it to a `remove` (e.g., filter where old matched but new doesn't)\n *\n * This results in some invariants:\n * - an add coming in will only create adds coming out\n * - a remove coming in will only create removes coming out\n * - an edit coming in can create adds, removes, and edits coming out\n * - a child coming in can create adds, removes, and children coming out\n *\n * # Return of `pushAccumulatedChanges`\n *\n * This function will only push a single change.\n * Given the above invariants, how is this possible?\n *\n * An add that becomes many `adds` results in a single add\n * as the `add` is the same row across all adds. Branches do not change the row.\n *\n * A remove that becomes many `removes` results in a single remove\n * for the same reason.\n *\n * If a child enters and exits, it takes precedence over all other changes.\n * If a child enters and is converted only to add and remove it exits as an edit.\n * If a child enters and is converted to only add or only remove, it exits as that change.\n *\n * If an edit enters and is converted to add and remove it exits as an edit.\n * If an edit enters and is converted to only add or only remove, it exits as that change.\n * If an edit enters and exits as edits only, it exits as a single edit.\n */\nexport function* pushAccumulatedChanges(\n accumulatedPushes: Change[],\n output: Output,\n pusher: InputBase,\n fanOutChangeType: ChangeType,\n mergeRelationships: (existing: Change, incoming: Change) => Change,\n addEmptyRelationships: (change: Change) => Change,\n // Relationships a branch adds (a flipped join's witnesses). Only the union\n // fan has any; the filter fan passes nothing and behaves as before.\n isBranchRel?: (name: string) => boolean,\n): Stream<'yield'> {\n if (accumulatedPushes.length === 0) {\n // It is possible for no forks to pass along the push.\n // E.g., if no filters match in any fork.\n return;\n }\n\n // A union nested in a branch keeps the row but reports its witness changes\n // as child changes on its own branch relationships, around the change it\n // pushes for the row. (A child change entering through the fan-out is on\n // one of the fan-out's relationships, never a branch's.) Those are not\n // candidates to collapse: pass them through around this fan-in's change,\n // removals (old row) before and additions (new row) after, as the nested\n // union ordered them.\n const witnessesLeft: Change[] = [];\n const witnessesEntered: Change[] = [];\n\n // collapse down to a single change per type\n const candidatesToPush = new Map<ChangeType, Change>();\n for (const change of accumulatedPushes) {\n if (\n isBranchRel &&\n change[ChangeIndex.TYPE] === ChangeType.CHILD &&\n isBranchRel(change[ChangeIndex.CHILD_DATA].relationshipName)\n ) {\n (change[ChangeIndex.CHILD_DATA].change[ChangeIndex.TYPE] ===\n ChangeType.REMOVE\n ? witnessesLeft\n : witnessesEntered\n ).push(change);\n continue;\n }\n if (\n fanOutChangeType === ChangeType.CHILD &&\n change[ChangeIndex.TYPE] !== ChangeType.CHILD\n ) {\n assert(\n candidatesToPush.has(change[ChangeIndex.TYPE]) === false,\n () =>\n `Fan-in:child expected at most one ${change[ChangeIndex.TYPE]} when fan-out is of type child`,\n );\n }\n\n const existing = candidatesToPush.get(change[ChangeIndex.TYPE]);\n let mergedChange = change;\n if (existing) {\n // merge in relationships\n mergedChange = mergeRelationships(existing, change);\n }\n candidatesToPush.set(change[ChangeIndex.TYPE], mergedChange);\n }\n\n accumulatedPushes.length = 0;\n\n assert(\n candidatesToPush.size > 0,\n 'Fan-in: witness changes without a change for their row',\n );\n for (const change of witnessesLeft) {\n yield* output.push(change, pusher);\n }\n yield* pushCollapsed(\n candidatesToPush,\n output,\n pusher,\n fanOutChangeType,\n mergeRelationships,\n addEmptyRelationships,\n isBranchRel,\n );\n for (const change of witnessesEntered) {\n yield* output.push(change, pusher);\n }\n}\n\nfunction* pushCollapsed(\n candidatesToPush: Map<ChangeType, Change>,\n output: Output,\n pusher: InputBase,\n fanOutChangeType: ChangeType,\n mergeRelationships: (existing: Change, incoming: Change) => Change,\n addEmptyRelationships: (change: Change) => Change,\n isBranchRel: ((name: string) => boolean) | undefined,\n): Stream<'yield'> {\n const types = [...candidatesToPush.keys()];\n /**\n * Based on the received `fanOutChangeType` only certain output types are valid.\n *\n * - remove must result in all removes\n * - add must result in all adds\n * - edit must result in add or removes or edits\n * - child must result in a single add or single remove or many child changes\n * - Single add or remove because the relationship will be unique to one exist check within the fan-out,fan-in sub-graph\n * - Many child changes because other operators may preserve the child change\n */\n switch (fanOutChangeType) {\n case ChangeType.REMOVE:\n assert(\n types.length === 1 && types[0] === ChangeType.REMOVE,\n 'Fan-in:remove expected all removes',\n );\n yield* output.push(\n addEmptyRelationships(must(candidatesToPush.get(ChangeType.REMOVE))),\n pusher,\n );\n return;\n case ChangeType.ADD:\n assert(\n types.length === 1 && types[0] === ChangeType.ADD,\n 'Fan-in:add expected all adds',\n );\n yield* output.push(\n addEmptyRelationships(must(candidatesToPush.get(ChangeType.ADD))),\n pusher,\n );\n return;\n case ChangeType.EDIT: {\n assert(\n types.every(\n type =>\n type === ChangeType.ADD ||\n type === ChangeType.REMOVE ||\n type === ChangeType.EDIT,\n ),\n 'Fan-in:edit expected all adds, removes, or edits',\n );\n const addChange = candidatesToPush.get(ChangeType.ADD);\n const removeChange = candidatesToPush.get(ChangeType.REMOVE);\n let editChange = candidatesToPush.get(ChangeType.EDIT);\n\n // The row stays downstream (a branch kept the edit, or it moved from\n // one branch to another). Branches it left take their witnesses with\n // them; branches it entered bring theirs. An edit syncs one row, so\n // those must travel as child changes around it.\n if (isBranchRel && (editChange || (addChange && removeChange))) {\n if (removeChange) {\n yield* pushWitnessDeltas(\n removeChange[ChangeIndex.NODE],\n ChangeType.REMOVE,\n isBranchRel,\n output,\n pusher,\n );\n }\n const strip = (n: Node): Node => ({\n row: n.row,\n relationships: Object.fromEntries(\n Object.entries(n.relationships).filter(([k]) => !isBranchRel(k)),\n ),\n });\n yield* output.push(\n addEmptyRelationships(\n editChange ??\n makeEditChange(\n strip(must(addChange)[ChangeIndex.NODE]),\n strip(must(removeChange)[ChangeIndex.NODE]),\n ),\n ),\n pusher,\n );\n if (addChange) {\n yield* pushWitnessDeltas(\n addChange[ChangeIndex.NODE],\n ChangeType.ADD,\n isBranchRel,\n output,\n pusher,\n );\n }\n return;\n }\n\n // If an `edit` is present, it supersedes `add` and `remove`\n // as it semantically represents both.\n if (editChange) {\n if (addChange) {\n editChange = mergeRelationships(editChange, addChange);\n }\n if (removeChange) {\n editChange = mergeRelationships(editChange, removeChange);\n }\n yield* output.push(addEmptyRelationships(editChange), pusher);\n return;\n }\n\n // If `edit` didn't make it through but both `add` and `remove` did,\n // convert back to an edit.\n //\n // When can this happen?\n //\n // EDIT old: a=1, new: a=2\n // |\n // FanOut\n // / \\\n // a=1 a=2\n // | |\n // remove add\n // \\ /\n // FanIn\n //\n // The left filter converts the edit into a remove.\n // The right filter converts the edit into an add.\n if (addChange && removeChange) {\n yield* output.push(\n addEmptyRelationships(\n makeEditChange(\n addChange[ChangeIndex.NODE],\n removeChange[ChangeIndex.NODE],\n ),\n ),\n pusher,\n );\n return;\n }\n\n yield* output.push(\n addEmptyRelationships(must(addChange ?? removeChange)),\n pusher,\n );\n return;\n }\n case ChangeType.CHILD: {\n assert(\n types.every(\n type =>\n type === ChangeType.ADD || // exists can change child to add or remove\n type === ChangeType.REMOVE || // exists can change child to add or remove\n type === ChangeType.CHILD, // other operators may preserve the child change\n ),\n 'Fan-in:child expected all adds, removes, or children',\n );\n assert(\n types.length <= 2,\n 'Fan-in:child expected at most 2 types on a child change from fan-out',\n );\n\n // If any branch preserved the original child change, that takes precedence over all other changes.\n const childChange = candidatesToPush.get(ChangeType.CHILD);\n if (childChange) {\n const left = candidatesToPush.get(ChangeType.REMOVE);\n const entered = candidatesToPush.get(ChangeType.ADD);\n if (isBranchRel && left) {\n yield* pushWitnessDeltas(\n left[ChangeIndex.NODE],\n ChangeType.REMOVE,\n isBranchRel,\n output,\n pusher,\n );\n }\n yield* output.push(childChange, pusher);\n if (isBranchRel && entered) {\n yield* pushWitnessDeltas(\n entered[ChangeIndex.NODE],\n ChangeType.ADD,\n isBranchRel,\n output,\n pusher,\n );\n }\n return;\n }\n\n const addChange = candidatesToPush.get(ChangeType.ADD);\n const removeChange = candidatesToPush.get(ChangeType.REMOVE);\n\n assert(\n addChange === undefined || removeChange === undefined,\n 'Fan-in:child expected either add or remove, not both',\n );\n\n yield* output.push(\n addEmptyRelationships(must(addChange ?? removeChange)),\n pusher,\n );\n return;\n }\n default:\n fanOutChangeType satisfies never;\n }\n}\n\n/**\n * The row stays downstream, but it gained (`ADD`) or lost (`REMOVE`) every\n * witness in `node`'s branch relationships. One child change per witness.\n */\nexport function* pushWitnessDeltas(\n node: Node,\n type: ChangeType.ADD | ChangeType.REMOVE,\n isBranchRel: (name: string) => boolean,\n output: Output,\n pusher: InputBase,\n): Stream<'yield'> {\n for (const [relationshipName, children] of Object.entries(\n node.relationships,\n )) {\n if (!isBranchRel(relationshipName)) {\n continue;\n }\n for (const child of children()) {\n if (child === 'yield') {\n yield child;\n continue;\n }\n yield* output.push(\n makeChildChange(node, {\n relationshipName,\n change:\n type === ChangeType.ADD\n ? makeAddChange(child)\n : makeRemoveChange(child),\n }),\n pusher,\n );\n }\n }\n}\n\n/**\n * Puts relationships from `right` into `left` if they don't already exist in `left`.\n */\nexport function mergeRelationships(left: Change, right: Change): Change {\n // change types will always match\n // unless we have an edit on the left\n // then the right could be edit, add, or remove\n if (left[ChangeIndex.TYPE] === right[ChangeIndex.TYPE]) {\n switch (left[ChangeIndex.TYPE]) {\n case ChangeType.ADD: {\n return makeAddChange({\n row: left[ChangeIndex.NODE].row,\n relationships: {\n ...right[ChangeIndex.NODE].relationships,\n ...left[ChangeIndex.NODE].relationships,\n },\n });\n }\n case ChangeType.REMOVE: {\n return makeRemoveChange({\n row: left[ChangeIndex.NODE].row,\n relationships: {\n ...right[ChangeIndex.NODE].relationships,\n ...left[ChangeIndex.NODE].relationships,\n },\n });\n }\n case ChangeType.EDIT: {\n assert(\n right[ChangeIndex.TYPE] === ChangeType.EDIT,\n () =>\n `mergeRelationships: when left.type is edit and types match, right.type must be edit, got ${right[ChangeIndex.TYPE]}`,\n );\n // merge edits into a single edit\n return makeEditChange(\n {\n row: left[ChangeIndex.NODE].row,\n relationships: {\n ...right[ChangeIndex.NODE].relationships,\n ...left[ChangeIndex.NODE].relationships,\n },\n },\n {\n row: left[ChangeIndex.OLD_NODE].row,\n relationships: {\n ...right[ChangeIndex.OLD_NODE].relationships,\n ...left[ChangeIndex.OLD_NODE].relationships,\n },\n },\n );\n }\n case ChangeType.CHILD: {\n // Multiple branches may preserve the same child change, each adding\n // different relationships. Merge the relationships, keeping the child\n // (which should be identical across branches).\n assert(\n right[ChangeIndex.TYPE] === ChangeType.CHILD,\n () =>\n `mergeRelationships: when left.type is child and types match, right.type must be child, got ${right[ChangeIndex.TYPE]}`,\n );\n return makeChildChange(\n {\n row: left[ChangeIndex.NODE].row,\n relationships: {\n ...right[ChangeIndex.NODE].relationships,\n ...left[ChangeIndex.NODE].relationships,\n },\n },\n left[ChangeIndex.CHILD_DATA],\n );\n }\n }\n }\n\n // left is always an edit here\n assert(\n left[ChangeIndex.TYPE] === ChangeType.EDIT,\n () =>\n `mergeRelationships: when types differ, left.type must be edit, got left.type=${left[ChangeIndex.TYPE]}, right.type=${right[ChangeIndex.TYPE]}`,\n );\n switch (right[ChangeIndex.TYPE]) {\n case ChangeType.ADD: {\n return makeEditChange(\n {\n ...left[ChangeIndex.NODE],\n relationships: {\n ...right[ChangeIndex.NODE].relationships,\n ...left[ChangeIndex.NODE].relationships,\n },\n },\n left[ChangeIndex.OLD_NODE],\n );\n }\n case ChangeType.REMOVE: {\n return makeEditChange(left[ChangeIndex.NODE], {\n ...left[ChangeIndex.OLD_NODE],\n relationships: {\n ...right[ChangeIndex.NODE].relationships,\n ...left[ChangeIndex.OLD_NODE].relationships,\n },\n });\n }\n }\n\n unreachable();\n}\n\nexport function makeAddEmptyRelationships(\n schema: SourceSchema,\n): (change: Change) => Change {\n return (change: Change): Change => {\n if (Object.keys(schema.relationships).length === 0) {\n return change;\n }\n\n switch (change[ChangeIndex.TYPE]) {\n case ChangeType.ADD: {\n const relationships = {...change[ChangeIndex.NODE].relationships};\n mergeEmpty(relationships, Object.keys(schema.relationships));\n return makeAddChange({\n row: change[ChangeIndex.NODE].row,\n relationships,\n });\n }\n case ChangeType.REMOVE: {\n const relationships = {...change[ChangeIndex.NODE].relationships};\n mergeEmpty(relationships, Object.keys(schema.relationships));\n return makeRemoveChange({\n row: change[ChangeIndex.NODE].row,\n relationships,\n });\n }\n case ChangeType.EDIT: {\n const nodeRelationships = {...change[ChangeIndex.NODE].relationships};\n const oldNodeRelationships = {\n ...change[ChangeIndex.OLD_NODE].relationships,\n };\n mergeEmpty(nodeRelationships, Object.keys(schema.relationships));\n mergeEmpty(oldNodeRelationships, Object.keys(schema.relationships));\n return makeEditChange(\n {row: change[ChangeIndex.NODE].row, relationships: nodeRelationships},\n {\n row: change[ChangeIndex.OLD_NODE].row,\n relationships: oldNodeRelationships,\n },\n );\n }\n case ChangeType.CHILD:\n return change; // children only have relationships along the path to the change\n }\n };\n}\n\n/**\n * For each relationship in `schema` that does not exist\n * in `relationships`, add it with an empty stream.\n *\n * This modifies the `relationships` object in place.\n */\nexport function mergeEmpty(\n relationships: Record<string, () => Stream<Node | 'yield'>>,\n relationshipNames: string[],\n) {\n for (const relName of relationshipNames) {\n if (relationships[relName] === undefined) {\n relationships[relName] = () => emptyArray;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,UAAiB,uBACf,mBACA,QACA,QACA,kBACA,oBACA,uBAGA,aACiB;CACjB,IAAI,kBAAkB,WAAW,GAG/B;CAUF,MAAM,gBAA0B,CAAC;CACjC,MAAM,mBAA6B,CAAC;CAGpC,MAAM,mCAAmB,IAAI,IAAwB;CACrD,KAAK,MAAM,UAAU,mBAAmB;EACtC,IACE,eACA,OAAO,OAAsB,KAC7B,YAAY,OAAO,GAAwB,gBAAgB,GAC3D;GACA,CAAC,OAAO,GAAwB,OAAO,OACvC,IACI,gBACA,kBACF,KAAK,MAAM;GACb;EACF;EACA,IACE,qBAAqB,KACrB,OAAO,OAAsB,GAE7B,OACE,iBAAiB,IAAI,OAAO,EAAiB,MAAM,aAEjD,qCAAqC,OAAO,GAAkB,+BAClE;EAGF,MAAM,WAAW,iBAAiB,IAAI,OAAO,EAAiB;EAC9D,IAAI,eAAe;EACnB,IAAI,UAEF,eAAe,mBAAmB,UAAU,MAAM;EAEpD,iBAAiB,IAAI,OAAO,IAAmB,YAAY;CAC7D;CAEA,kBAAkB,SAAS;CAE3B,OACE,iBAAiB,OAAO,G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AAGrC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Row } from '../../../zero-protocol/src/data.ts';
|
|
2
2
|
import { type Change } from './change.ts';
|
|
3
3
|
import type { Node } from './data.ts';
|
|
4
|
-
import { type FetchRequest, type Input, type Operator, type Output } from './operator.ts';
|
|
4
|
+
import { type FetchRequest, type Input, type InputBase, type Operator, type Output } from './operator.ts';
|
|
5
5
|
import type { SourceSchema } from './schema.ts';
|
|
6
6
|
import type { Stream } from './stream.ts';
|
|
7
7
|
export type Bound = {
|
|
@@ -20,5 +20,6 @@ export declare class Skip implements Operator {
|
|
|
20
20
|
setOutput(output: Output): void;
|
|
21
21
|
destroy(): void;
|
|
22
22
|
push(change: Change): Stream<'yield'>;
|
|
23
|
+
reconcile(_pusher: InputBase): Stream<'yield'>;
|
|
23
24
|
}
|
|
24
25
|
//# sourceMappingURL=skip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip.d.ts","sourceRoot":"","sources":["../../../../../zql/src/ivm/skip.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAG5D,OAAO,EAEL,KAAK,MAAM,EAGZ,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAa,IAAI,EAAC,MAAM,WAAW,CAAC;AAEhD,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,MAAM,EAEZ,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,KAAK,GAAG;IAClB,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,qBAAa,IAAK,YAAW,QAAQ;;IAOnC,YAAY,KAAK,EAAE,KAAK,EAA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,EAAE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAiBrC;IAEA,SAAS,CAAC,OAAO,EAAE,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAI9C;CA8DF"}
|
package/out/zql/src/ivm/skip.js
CHANGED
|
@@ -60,6 +60,9 @@ var Skip = class {
|
|
|
60
60
|
}
|
|
61
61
|
if (shouldBePresent(change[1].row)) yield* this.#output.push(change, this);
|
|
62
62
|
}
|
|
63
|
+
*reconcile(_pusher) {
|
|
64
|
+
if (this.#output.reconcile) yield* this.#output.reconcile(this);
|
|
65
|
+
}
|
|
63
66
|
#getStart(req) {
|
|
64
67
|
const boundStart = {
|
|
65
68
|
row: this.#bound.row,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip.js","names":["#input","#bound","#comparator","#getStart","#shouldBePresent","#output"],"sources":["../../../../../zql/src/ivm/skip.ts"],"sourcesContent":["import {assert} from '../../../shared/src/asserts.ts';\nimport type {Row} from '../../../zero-protocol/src/data.ts';\nimport {ChangeIndex} from './change-index.ts';\nimport {ChangeType} from './change-type.ts';\nimport {\n type AddChange,\n type Change,\n type ChildChange,\n type RemoveChange,\n} from './change.ts';\nimport type {Comparator, Node} from './data.ts';\nimport {maybeSplitAndPushEditChange} from './maybe-split-and-push-edit-change.ts';\nimport {\n throwOutput,\n type FetchRequest,\n type Input,\n type Operator,\n type Output,\n type Start,\n} from './operator.ts';\nimport type {SourceSchema} from './schema.ts';\nimport type {Stream} from './stream.ts';\n\nexport type Bound = {\n row: Row;\n exclusive: boolean;\n};\n\n/**\n * Skip sets the start position for the pipeline. No rows before the bound will\n * be output.\n */\nexport class Skip implements Operator {\n readonly #input: Input;\n readonly #bound: Bound;\n readonly #comparator: Comparator;\n\n #output: Output = throwOutput;\n\n constructor(input: Input, bound: Bound) {\n const {sort} = input.getSchema();\n assert(sort !== undefined, 'Skip requires sorted input');\n this.#input = input;\n this.#bound = bound;\n this.#comparator = input.getSchema().compareRows;\n input.setOutput(this);\n }\n\n getSchema(): SourceSchema {\n return this.#input.getSchema();\n }\n\n *fetch(req: FetchRequest): Stream<Node | 'yield'> {\n const start = this.#getStart(req);\n if (start === 'empty') {\n return;\n }\n const nodes = this.#input.fetch({...req, start});\n if (!req.reverse) {\n yield* nodes;\n return;\n }\n for (const node of nodes) {\n if (node === 'yield') {\n yield node;\n continue;\n }\n if (!this.#shouldBePresent(node.row)) {\n return;\n }\n yield node;\n }\n }\n\n setOutput(output: Output): void {\n this.#output = output;\n }\n\n destroy(): void {\n this.#input.destroy();\n }\n\n #shouldBePresent(row: Row): boolean {\n const cmp = this.#comparator(this.#bound.row, row);\n return cmp < 0 || (cmp === 0 && !this.#bound.exclusive);\n }\n\n *push(change: Change): Stream<'yield'> {\n const shouldBePresent = (row: Row) => this.#shouldBePresent(row);\n if (change[ChangeIndex.TYPE] === ChangeType.EDIT) {\n yield* maybeSplitAndPushEditChange(\n change,\n shouldBePresent,\n this.#output,\n this,\n );\n return;\n }\n\n change satisfies AddChange | RemoveChange | ChildChange;\n\n if (shouldBePresent(change[ChangeIndex.NODE].row)) {\n yield* this.#output.push(change, this);\n }\n }\n\n #getStart(req: FetchRequest): Start | undefined | 'empty' {\n const boundStart = {\n row: this.#bound.row,\n basis: this.#bound.exclusive ? 'after' : 'at',\n } as const;\n\n if (!req.start) {\n if (req.reverse) {\n return undefined;\n }\n return boundStart;\n }\n\n const cmp = this.#comparator(this.#bound.row, req.start.row);\n\n if (!req.reverse) {\n // The skip bound is after the requested bound. The requested bound cannot\n // be relevant because even if it was basis: 'after', the skip bound is\n // itself after the requested bound. Return the skip bound.\n if (cmp > 0) {\n return boundStart;\n }\n\n // The skip bound and requested bound are equal. If either is exclusive,\n // return that bound with exclusive. Otherwise, return the skip bound.\n if (cmp === 0) {\n if (this.#bound.exclusive || req.start.basis === 'after') {\n return {\n row: this.#bound.row,\n basis: 'after',\n };\n }\n return boundStart;\n }\n\n return req.start;\n }\n\n req.reverse satisfies true;\n\n // bound is after the start, but request is for reverse so results\n // must be empty\n if (cmp > 0) {\n return 'empty';\n }\n\n if (cmp === 0) {\n // if both are inclusive, the result can be the single row at bound\n // return it as start\n if (!this.#bound.exclusive && req.start.basis === 'at') {\n return boundStart;\n }\n // otherwise the results must be empty, one or both are exclusive\n // in opposite directions\n return 'empty';\n }\n\n // bound is before the start, return start\n return req.start;\n }\n}\n"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"skip.js","names":["#input","#bound","#comparator","#getStart","#shouldBePresent","#output"],"sources":["../../../../../zql/src/ivm/skip.ts"],"sourcesContent":["import {assert} from '../../../shared/src/asserts.ts';\nimport type {Row} from '../../../zero-protocol/src/data.ts';\nimport {ChangeIndex} from './change-index.ts';\nimport {ChangeType} from './change-type.ts';\nimport {\n type AddChange,\n type Change,\n type ChildChange,\n type RemoveChange,\n} from './change.ts';\nimport type {Comparator, Node} from './data.ts';\nimport {maybeSplitAndPushEditChange} from './maybe-split-and-push-edit-change.ts';\nimport {\n throwOutput,\n type FetchRequest,\n type Input,\n type InputBase,\n type Operator,\n type Output,\n type Start,\n} from './operator.ts';\nimport type {SourceSchema} from './schema.ts';\nimport type {Stream} from './stream.ts';\n\nexport type Bound = {\n row: Row;\n exclusive: boolean;\n};\n\n/**\n * Skip sets the start position for the pipeline. No rows before the bound will\n * be output.\n */\nexport class Skip implements Operator {\n readonly #input: Input;\n readonly #bound: Bound;\n readonly #comparator: Comparator;\n\n #output: Output = throwOutput;\n\n constructor(input: Input, bound: Bound) {\n const {sort} = input.getSchema();\n assert(sort !== undefined, 'Skip requires sorted input');\n this.#input = input;\n this.#bound = bound;\n this.#comparator = input.getSchema().compareRows;\n input.setOutput(this);\n }\n\n getSchema(): SourceSchema {\n return this.#input.getSchema();\n }\n\n *fetch(req: FetchRequest): Stream<Node | 'yield'> {\n const start = this.#getStart(req);\n if (start === 'empty') {\n return;\n }\n const nodes = this.#input.fetch({...req, start});\n if (!req.reverse) {\n yield* nodes;\n return;\n }\n for (const node of nodes) {\n if (node === 'yield') {\n yield node;\n continue;\n }\n if (!this.#shouldBePresent(node.row)) {\n return;\n }\n yield node;\n }\n }\n\n setOutput(output: Output): void {\n this.#output = output;\n }\n\n destroy(): void {\n this.#input.destroy();\n }\n\n #shouldBePresent(row: Row): boolean {\n const cmp = this.#comparator(this.#bound.row, row);\n return cmp < 0 || (cmp === 0 && !this.#bound.exclusive);\n }\n\n *push(change: Change): Stream<'yield'> {\n const shouldBePresent = (row: Row) => this.#shouldBePresent(row);\n if (change[ChangeIndex.TYPE] === ChangeType.EDIT) {\n yield* maybeSplitAndPushEditChange(\n change,\n shouldBePresent,\n this.#output,\n this,\n );\n return;\n }\n\n change satisfies AddChange | RemoveChange | ChildChange;\n\n if (shouldBePresent(change[ChangeIndex.NODE].row)) {\n yield* this.#output.push(change, this);\n }\n }\n\n *reconcile(_pusher: InputBase): Stream<'yield'> {\n if (this.#output.reconcile) {\n yield* this.#output.reconcile(this);\n }\n }\n\n #getStart(req: FetchRequest): Start | undefined | 'empty' {\n const boundStart = {\n row: this.#bound.row,\n basis: this.#bound.exclusive ? 'after' : 'at',\n } as const;\n\n if (!req.start) {\n if (req.reverse) {\n return undefined;\n }\n return boundStart;\n }\n\n const cmp = this.#comparator(this.#bound.row, req.start.row);\n\n if (!req.reverse) {\n // The skip bound is after the requested bound. The requested bound cannot\n // be relevant because even if it was basis: 'after', the skip bound is\n // itself after the requested bound. Return the skip bound.\n if (cmp > 0) {\n return boundStart;\n }\n\n // The skip bound and requested bound are equal. If either is exclusive,\n // return that bound with exclusive. Otherwise, return the skip bound.\n if (cmp === 0) {\n if (this.#bound.exclusive || req.start.basis === 'after') {\n return {\n row: this.#bound.row,\n basis: 'after',\n };\n }\n return boundStart;\n }\n\n return req.start;\n }\n\n req.reverse satisfies true;\n\n // bound is after the start, but request is for reverse so results\n // must be empty\n if (cmp > 0) {\n return 'empty';\n }\n\n if (cmp === 0) {\n // if both are inclusive, the result can be the single row at bound\n // return it as start\n if (!this.#bound.exclusive && req.start.basis === 'at') {\n return boundStart;\n }\n // otherwise the results must be empty, one or both are exclusive\n // in opposite directions\n return 'empty';\n }\n\n // bound is before the start, return start\n return req.start;\n }\n}\n"],"mappings":";;;;;;;;AAiCA,IAAa,OAAb,MAAsC;CACpC;CACA;CACA;CAEA,UAAkB;CAElB,YAAY,OAAc,OAAc;EACtC,MAAM,EAAC,SAAQ,MAAM,UAAU;EAC/B,OAAO,SAAS,KAAA,GAAW,4BAA4B;EACvD,KAAKA,SAAS;EACd,KAAKC,SAAS;EACd,KAAKC,cAAc,MAAM,UAAU,EAAE;EACrC,MAAM,UAAU,IAAI;CACtB;CAEA,YAA0B;EACxB,OAAO,KAAKF,OAAO,UAAU;CAC/B;CAEA,CAAC,MAAM,KAA2C;EAChD,MAAM,QAAQ,KAAKG,UAAU,GAAG;EAChC,IAAI,UAAU,SACZ;EAEF,MAAM,QAAQ,KAAKH,OAAO,MAAM;GAAC,GAAG;GAAK;EAAK,CAAC;EAC/C,IAAI,CAAC,IAAI,SAAS;GAChB,OAAO;GACP;EACF;EACA,KAAK,MAAM,QAAQ,OAAO;GACxB,IAAI,SAAS,SAAS;IACpB,MAAM;IACN;GACF;GACA,IAAI,CAAC,KAAKI,iBAAiB,KAAK,GAAG,GACjC;GAEF,MAAM;EACR;CACF;CAEA,UAAU,QAAsB;EAC9B,KAAKC,UAAU;CACjB;CAEA,UAAgB;EACd,KAAKL,OAAO,QAAQ;CACtB;CAEA,iBAAiB,KAAmB;EAClC,MAAM,MAAM,KAAKE,YAAY,KAAKD,OAAO,KAAK,GAAG;EACjD,OAAO,MAAM,KAAM,QAAQ,KAAK,CAAC,KAAKA,OAAO;CAC/C;CAEA,CAAC,KAAK,QAAiC;EACrC,MAAM,mBAAmB,QAAa,KAAKG,iBAAiB,GAAG;EAC/D,IAAI,OAAO,OAAsB,GAAiB;GAChD,OAAO,4BACL,QACA,iBACA,KAAKC,SACL,IACF;GACA;EACF;EAIA,IAAI,gBAAgB,OAAO,GAAkB,GAAG,GAC9C,OAAO,KAAKA,QAAQ,KAAK,QAAQ,IAAI;CAEzC;CAEA,CAAC,UAAU,SAAqC;EAC9C,IAAI,KAAKA,QAAQ,WACf,OAAO,KAAKA,QAAQ,UAAU,IAAI;CAEtC;CAEA,UAAU,KAAgD;EACxD,MAAM,aAAa;GACjB,KAAK,KAAKJ,OAAO;GACjB,OAAO,KAAKA,OAAO,YAAY,UAAU;EAC3C;EAEA,IAAI,CAAC,IAAI,OAAO;GACd,IAAI,IAAI,SACN;GAEF,OAAO;EACT;EAEA,MAAM,MAAM,KAAKC,YAAY,KAAKD,OAAO,KAAK,IAAI,MAAM,GAAG;EAE3D,IAAI,CAAC,IAAI,SAAS;GAIhB,IAAI,MAAM,GACR,OAAO;GAKT,IAAI,QAAQ,GAAG;IACb,IAAI,KAAKA,OAAO,aAAa,IAAI,MAAM,UAAU,SAC/C,OAAO;KACL,KAAK,KAAKA,OAAO;KACjB,OAAO;IACT;IAEF,OAAO;GACT;GAEA,OAAO,IAAI;EACb;EAEA,IAAI;EAIJ,IAAI,MAAM,GACR,OAAO;EAGT,IAAI,QAAQ,GAAG;GAGb,IAAI,CAAC,KAAKA,OAAO,aAAa,IAAI,MAAM,UAAU,MAChD,OAAO;GAIT,OAAO;EACT;EAGA,OAAO,IAAI;CACb;AACF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Row } from '../../../zero-protocol/src/data.ts';
|
|
2
|
+
import type { Change } from './change.ts';
|
|
3
|
+
import { type Constraint } from './constraint.ts';
|
|
4
|
+
import type { Comparator, Node } from './data.ts';
|
|
5
|
+
import { type FetchRequest, type Input, type InputBase, type Operator, type Output } from './operator.ts';
|
|
6
|
+
import type { SourceSchema } from './schema.ts';
|
|
7
|
+
import type { Stream } from './stream.ts';
|
|
8
|
+
export interface TakeBoundProvider {
|
|
9
|
+
getBound(constraint?: Constraint): Row | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The bound that a TakeGate caps one parent fetch of a join's child push at.
|
|
13
|
+
* `undefined` means the fetch is not capped.
|
|
14
|
+
*/
|
|
15
|
+
export type ParentFetchBound = {
|
|
16
|
+
readonly constraint: Constraint;
|
|
17
|
+
readonly bound: Row | undefined;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Reads the bounds for the parent fetches of a child push before the join
|
|
21
|
+
* starts them. TakeGate reads its bound once, when a fetch starts, so the set
|
|
22
|
+
* of parents that get the push stays fixed even when Take moves its bound
|
|
23
|
+
* during the push. Split-push overlays must use these bounds, not the bound
|
|
24
|
+
* Take reports later in the push.
|
|
25
|
+
*/
|
|
26
|
+
export declare function readParentFetchBounds(boundProvider: TakeBoundProvider, constraints: readonly Constraint[]): ParentFetchBound[];
|
|
27
|
+
/**
|
|
28
|
+
* Returns true if one of the parent fetches of the push yields `row`: `row`
|
|
29
|
+
* matches the fetch's constraint and is not after the fetch's bound.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isInParentFetch(bounds: readonly ParentFetchBound[], row: Row, compareRows: Comparator): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* TakeGate bounds upstream parent fetches using the active bound from a
|
|
34
|
+
* downstream Take operator.
|
|
35
|
+
*
|
|
36
|
+
* When a child table changes, joins fetch matching parent rows. Without
|
|
37
|
+
* TakeGate, this fetch scans all matching parent rows (which may be thousands)
|
|
38
|
+
* even if downstream Take only needs a few. TakeGate intercepts this fetch and
|
|
39
|
+
* stops the upstream stream once rows exceed Take's bound.
|
|
40
|
+
*/
|
|
41
|
+
export declare class TakeGate implements Operator, TakeBoundProvider {
|
|
42
|
+
#private;
|
|
43
|
+
constructor(input: Input);
|
|
44
|
+
open(): void;
|
|
45
|
+
close(): void;
|
|
46
|
+
isOpen(): boolean;
|
|
47
|
+
setBoundProvider(provider: TakeBoundProvider): void;
|
|
48
|
+
getBoundProvider(): TakeBoundProvider | undefined;
|
|
49
|
+
getBound(constraint?: Constraint): Row | undefined;
|
|
50
|
+
getSchema(): SourceSchema;
|
|
51
|
+
setOutput(output: Output): void;
|
|
52
|
+
destroy(): void;
|
|
53
|
+
push(change: Change, _pusher: InputBase): Stream<'yield'>;
|
|
54
|
+
reconcile(_pusher: InputBase): Stream<'yield'>;
|
|
55
|
+
fetch(req: FetchRequest): Stream<Node | 'yield'>;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=take-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"take-gate.d.ts","sourceRoot":"","sources":["../../../../../zql/src/ivm/take-gate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAC5D,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,EAAuB,KAAK,UAAU,EAAC,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAC,UAAU,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AAChD,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,MAAM,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAExC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,GAAG,GAAG,SAAS,CAAC;CACpD;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC;CACjC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,iBAAiB,EAChC,WAAW,EAAE,SAAS,UAAU,EAAE,GACjC,gBAAgB,EAAE,CAKpB;AAED;;;GAGG;AAC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