@rocicorp/zero 1.10.0-canary.24 → 1.10.0-canary.26
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 +8 -9
- package/out/analyze-query/src/bin-analyze.js.map +1 -1
- package/out/replicache/src/btree/node.d.ts.map +1 -1
- package/out/replicache/src/btree/node.js +6 -3
- package/out/replicache/src/btree/node.js.map +1 -1
- package/out/replicache/src/btree/read.d.ts +1 -12
- package/out/replicache/src/btree/read.d.ts.map +1 -1
- package/out/replicache/src/btree/read.js +12 -24
- package/out/replicache/src/btree/read.js.map +1 -1
- package/out/replicache/src/dag/gc.d.ts.map +1 -1
- package/out/replicache/src/dag/gc.js +11 -8
- package/out/replicache/src/dag/gc.js.map +1 -1
- package/out/replicache/src/dag/store-impl.d.ts +2 -12
- package/out/replicache/src/dag/store-impl.d.ts.map +1 -1
- package/out/replicache/src/dag/store-impl.js +8 -22
- package/out/replicache/src/dag/store-impl.js.map +1 -1
- package/out/replicache/src/db/rebase.d.ts +2 -14
- package/out/replicache/src/db/rebase.d.ts.map +1 -1
- package/out/replicache/src/db/rebase.js +5 -27
- package/out/replicache/src/db/rebase.js.map +1 -1
- package/out/replicache/src/db/write.js.map +1 -1
- package/out/replicache/src/kv/expo-sqlite/store.d.ts.map +1 -1
- package/out/replicache/src/kv/expo-sqlite/store.js +5 -28
- package/out/replicache/src/kv/expo-sqlite/store.js.map +1 -1
- package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts +5 -15
- package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts.map +1 -1
- package/out/replicache/src/kv/idb-store-with-mem-fallback.js +25 -25
- package/out/replicache/src/kv/idb-store-with-mem-fallback.js.map +1 -1
- package/out/replicache/src/kv/idb-store.d.ts +0 -9
- package/out/replicache/src/kv/idb-store.d.ts.map +1 -1
- package/out/replicache/src/kv/idb-store.js +2 -14
- package/out/replicache/src/kv/idb-store.js.map +1 -1
- package/out/replicache/src/kv/mem-store.d.ts +0 -1
- package/out/replicache/src/kv/mem-store.d.ts.map +1 -1
- package/out/replicache/src/kv/mem-store.js +0 -3
- 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 +1 -1
- package/out/replicache/src/kv/op-sqlite/store.js.map +1 -1
- package/out/replicache/src/kv/sqlite-store.d.ts +1 -13
- package/out/replicache/src/kv/sqlite-store.d.ts.map +1 -1
- package/out/replicache/src/kv/sqlite-store.js +6 -73
- package/out/replicache/src/kv/sqlite-store.js.map +1 -1
- package/out/replicache/src/kv/store.d.ts +0 -6
- package/out/replicache/src/kv/store.d.ts.map +1 -1
- package/out/replicache/src/persist/collect-idb-databases.d.ts +5 -10
- package/out/replicache/src/persist/collect-idb-databases.d.ts.map +1 -1
- package/out/replicache/src/persist/collect-idb-databases.js +9 -16
- package/out/replicache/src/persist/collect-idb-databases.js.map +1 -1
- package/out/replicache/src/persist/persist.d.ts.map +1 -1
- package/out/replicache/src/persist/persist.js +6 -13
- package/out/replicache/src/persist/persist.js.map +1 -1
- package/out/replicache/src/persist/refresh.js +2 -6
- package/out/replicache/src/persist/refresh.js.map +1 -1
- package/out/replicache/src/replicache-impl.d.ts +3 -14
- package/out/replicache/src/replicache-impl.d.ts.map +1 -1
- package/out/replicache/src/replicache-impl.js +11 -118
- package/out/replicache/src/replicache-impl.js.map +1 -1
- package/out/replicache/src/replicache-options.d.ts +0 -9
- package/out/replicache/src/replicache-options.d.ts.map +1 -1
- package/out/replicache/src/transactions.d.ts.map +1 -1
- package/out/replicache/src/transactions.js +1 -1
- package/out/replicache/src/transactions.js.map +1 -1
- package/out/shared/src/arrays.d.ts +0 -5
- package/out/shared/src/arrays.d.ts.map +1 -1
- package/out/shared/src/arrays.js +24 -8
- package/out/shared/src/arrays.js.map +1 -1
- package/out/shared/src/base64.d.ts +19 -0
- package/out/shared/src/base64.d.ts.map +1 -0
- package/out/shared/src/base64.js +40 -0
- package/out/shared/src/base64.js.map +1 -0
- package/out/shared/src/error.d.ts +0 -11
- package/out/shared/src/error.d.ts.map +1 -1
- package/out/shared/src/error.js +1 -35
- package/out/shared/src/error.js.map +1 -1
- package/out/shared/src/hash.d.ts +0 -1
- package/out/shared/src/hash.d.ts.map +1 -1
- package/out/shared/src/hash.js +10 -87
- package/out/shared/src/hash.js.map +1 -1
- package/out/shared/src/iterables.d.ts +0 -2
- package/out/shared/src/iterables.d.ts.map +1 -1
- package/out/shared/src/iterables.js +1 -18
- package/out/shared/src/iterables.js.map +1 -1
- package/out/shared/src/json.d.ts.map +1 -1
- package/out/shared/src/json.js +2 -2
- package/out/shared/src/json.js.map +1 -1
- package/out/shared/src/map.d.ts +2 -24
- package/out/shared/src/map.d.ts.map +1 -1
- package/out/shared/src/map.js +4 -18
- package/out/shared/src/map.js.map +1 -1
- package/out/shared/src/ring-buffer.d.ts +0 -8
- package/out/shared/src/ring-buffer.d.ts.map +1 -1
- package/out/shared/src/ring-buffer.js +1 -22
- package/out/shared/src/ring-buffer.js.map +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 -2
- package/out/zero/package.js.map +1 -1
- package/out/zero-cache/src/auth/read-authorizer.js +1 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.js +0 -1
- package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +2 -42
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +28 -149
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/custom-queries/transform-query.js +1 -1
- package/out/zero-cache/src/db/create.d.ts.map +1 -1
- package/out/zero-cache/src/db/create.js +1 -4
- package/out/zero-cache/src/db/create.js.map +1 -1
- package/out/zero-cache/src/db/lite-tables.d.ts +2 -10
- package/out/zero-cache/src/db/lite-tables.d.ts.map +1 -1
- package/out/zero-cache/src/db/lite-tables.js +6 -10
- package/out/zero-cache/src/db/lite-tables.js.map +1 -1
- package/out/zero-cache/src/db/specs.d.ts +0 -41
- package/out/zero-cache/src/db/specs.d.ts.map +1 -1
- package/out/zero-cache/src/db/specs.js +3 -30
- package/out/zero-cache/src/db/specs.js.map +1 -1
- package/out/zero-cache/src/observability/metrics.d.ts.map +1 -1
- package/out/zero-cache/src/observability/metrics.js +7 -2
- package/out/zero-cache/src/observability/metrics.js.map +1 -1
- package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
- package/out/zero-cache/src/server/change-streamer.js +4 -13
- package/out/zero-cache/src/server/change-streamer.js.map +1 -1
- package/out/zero-cache/src/server/inspector-delegate.d.ts +2 -18
- package/out/zero-cache/src/server/inspector-delegate.d.ts.map +1 -1
- package/out/zero-cache/src/server/inspector-delegate.js +17 -25
- 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 +1 -8
- package/out/zero-cache/src/server/main.js.map +1 -1
- package/out/zero-cache/src/server/mutator.js +0 -2
- 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 +0 -2
- package/out/zero-cache/src/server/reaper.js.map +1 -1
- package/out/zero-cache/src/server/replicator.d.ts.map +1 -1
- package/out/zero-cache/src/server/replicator.js +2 -8
- 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 +0 -3
- package/out/zero-cache/src/server/runner/zero-dispatcher.js.map +1 -1
- package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/server/syncer.js +1 -5
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/services/analyze.d.ts.map +1 -1
- package/out/zero-cache/src/services/analyze.js +9 -11
- 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 +1 -14
- 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 +3 -15
- package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.d.ts +1 -11
- 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 +2 -21
- 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 +0 -1
- 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 +7 -8
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +229 -1513
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.js +2 -2
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.js +6 -15
- package/out/zero-cache/src/services/change-source/pg/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts +20 -137
- package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/published.js +13 -82
- package/out/zero-cache/src/services/change-source/pg/schema/published.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +21 -128
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js +5 -5
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts +0 -2
- package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +0 -3
- package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +0 -3
- 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 +1 -3
- 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.d.ts +0 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts.map +1 -1
- package/out/zero-cache/src/services/litestream/commands.d.ts.map +1 -1
- package/out/zero-cache/src/services/litestream/commands.js +3 -8
- package/out/zero-cache/src/services/litestream/commands.js.map +1 -1
- package/out/zero-cache/src/services/litestream/config-v5.yml +1 -15
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts +0 -5
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js +1 -7
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.d.ts +119 -119
- package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.js +6 -5
- package/out/zero-cache/src/services/mutagen/pusher.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 +16 -16
- package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.js +0 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.js.map +1 -1
- package/out/zero-cache/src/services/replicator/write-worker-client.d.ts +2 -27
- 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 +2 -3
- 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 -24
- package/out/zero-cache/src/services/replicator/write-worker.js.map +1 -1
- package/out/zero-cache/src/services/run-ast.d.ts +0 -12
- package/out/zero-cache/src/services/run-ast.d.ts.map +1 -1
- package/out/zero-cache/src/services/run-ast.js +15 -27
- package/out/zero-cache/src/services/run-ast.js.map +1 -1
- package/out/zero-cache/src/services/runner.d.ts.map +1 -1
- package/out/zero-cache/src/services/runner.js +1 -1
- package/out/zero-cache/src/services/runner.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts +0 -45
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.js +1 -133
- package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts +1 -14
- 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 +4 -30
- package/out/zero-cache/src/services/view-syncer/drain-coordinator.js.map +1 -1
- 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 +2 -2
- 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 +1 -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 +27 -48
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
- 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 +6 -2
- package/out/zero-cache/src/services/view-syncer/query-covering.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts +4 -42
- package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/snapshotter.js +28 -117
- 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 +1 -11
- 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 +95 -466
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/processes.d.ts +0 -32
- package/out/zero-cache/src/types/processes.d.ts.map +1 -1
- package/out/zero-cache/src/types/processes.js +4 -43
- package/out/zero-cache/src/types/processes.js.map +1 -1
- package/out/zero-cache/src/types/profiler.d.ts +0 -12
- package/out/zero-cache/src/types/profiler.d.ts.map +1 -1
- package/out/zero-cache/src/types/profiler.js +1 -46
- 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/workers/connect-params.d.ts +7 -0
- package/out/zero-cache/src/workers/connect-params.d.ts.map +1 -1
- package/out/zero-cache/src/workers/connect-params.js +20 -1
- package/out/zero-cache/src/workers/connect-params.js.map +1 -1
- package/out/zero-cache/src/workers/connection.d.ts +4 -4
- package/out/zero-cache/src/workers/connection.d.ts.map +1 -1
- package/out/zero-cache/src/workers/connection.js +8 -8
- package/out/zero-cache/src/workers/connection.js.map +1 -1
- package/out/zero-cache/src/workers/replicator.d.ts +0 -1
- package/out/zero-cache/src/workers/replicator.d.ts.map +1 -1
- package/out/zero-cache/src/workers/replicator.js +2 -4
- package/out/zero-cache/src/workers/replicator.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 +16 -21
- 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 +1 -10
- package/out/zero-cache/src/workers/syncer.js.map +1 -1
- package/out/zero-client/src/client/connection-manager.d.ts +0 -20
- package/out/zero-client/src/client/connection-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/connection-manager.js +13 -77
- package/out/zero-client/src/client/connection-manager.js.map +1 -1
- package/out/zero-client/src/client/connection-status-enum.d.ts +0 -2
- package/out/zero-client/src/client/connection-status-enum.d.ts.map +1 -1
- package/out/zero-client/src/client/connection-status-enum.js +1 -3
- package/out/zero-client/src/client/connection-status-enum.js.map +1 -1
- package/out/zero-client/src/client/connection.d.ts +0 -6
- package/out/zero-client/src/client/connection.d.ts.map +1 -1
- package/out/zero-client/src/client/connection.js +1 -2
- package/out/zero-client/src/client/connection.js.map +1 -1
- package/out/zero-client/src/client/context.d.ts +2 -27
- package/out/zero-client/src/client/context.d.ts.map +1 -1
- package/out/zero-client/src/client/context.js +1 -112
- 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/inspector/lazy-inspector.js +2 -2
- package/out/zero-client/src/client/inspector/lazy-inspector.js.map +1 -1
- package/out/zero-client/src/client/ivm-branch.d.ts.map +1 -1
- package/out/zero-client/src/client/ivm-branch.js +3 -20
- package/out/zero-client/src/client/ivm-branch.js.map +1 -1
- package/out/zero-client/src/client/mutation-tracker.d.ts.map +1 -1
- package/out/zero-client/src/client/mutation-tracker.js +1 -1
- package/out/zero-client/src/client/mutation-tracker.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 +1 -2
- package/out/zero-client/src/client/mutator-proxy.js.map +1 -1
- package/out/zero-client/src/client/options.d.ts +0 -3
- 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 +0 -2
- package/out/zero-client/src/client/query-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/query-manager.js +14 -50
- 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 +0 -1
- package/out/zero-client/src/client/zero-rep.d.ts.map +1 -1
- package/out/zero-client/src/client/zero-rep.js +6 -9
- package/out/zero-client/src/client/zero-rep.js.map +1 -1
- package/out/zero-client/src/client/zero.d.ts +3 -18
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.js +36 -123
- package/out/zero-client/src/client/zero.js.map +1 -1
- package/out/zero-client/src/types/query-result.d.ts +0 -2
- package/out/zero-client/src/types/query-result.d.ts.map +1 -1
- package/out/zero-protocol/src/analyze-query-result.d.ts +5 -5
- package/out/zero-protocol/src/analyze-query-result.d.ts.map +1 -1
- package/out/zero-protocol/src/analyze-query-result.js +1 -1
- package/out/zero-protocol/src/analyze-query-result.js.map +1 -1
- package/out/zero-protocol/src/ast.d.ts +1 -64
- package/out/zero-protocol/src/ast.d.ts.map +1 -1
- package/out/zero-protocol/src/ast.js +54 -225
- package/out/zero-protocol/src/ast.js.map +1 -1
- package/out/zero-protocol/src/connect.d.ts +13 -0
- package/out/zero-protocol/src/connect.d.ts.map +1 -1
- package/out/zero-protocol/src/connect.js +30 -1
- package/out/zero-protocol/src/connect.js.map +1 -1
- package/out/zero-protocol/src/down.d.ts +2 -2
- package/out/zero-protocol/src/error.d.ts +1 -1
- package/out/zero-protocol/src/inspect-down.d.ts +6 -6
- package/out/zero-protocol/src/poke.d.ts +11 -4
- package/out/zero-protocol/src/poke.d.ts.map +1 -1
- package/out/zero-protocol/src/poke.js +3 -2
- package/out/zero-protocol/src/poke.js.map +1 -1
- package/out/zero-protocol/src/protocol-flag-enum.d.ts +7 -0
- package/out/zero-protocol/src/protocol-flag-enum.d.ts.map +1 -0
- package/out/zero-protocol/src/protocol-flag-enum.js +7 -0
- package/out/zero-protocol/src/protocol-flag-enum.js.map +1 -0
- package/out/zero-protocol/src/protocol-flag.d.ts +14 -0
- package/out/zero-protocol/src/protocol-flag.d.ts.map +1 -0
- package/out/zero-protocol/src/protocol-flag.js +8 -0
- package/out/zero-protocol/src/protocol-flag.js.map +1 -0
- package/out/zero-protocol/src/protocol-version.d.ts +30 -6
- package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
- package/out/zero-protocol/src/protocol-version.js +1 -1
- package/out/zero-protocol/src/protocol-version.js.map +1 -1
- package/out/zero-protocol/src/query-hash.d.ts +2 -7
- package/out/zero-protocol/src/query-hash.d.ts.map +1 -1
- package/out/zero-protocol/src/query-hash.js +10 -10
- package/out/zero-protocol/src/query-hash.js.map +1 -1
- package/out/zero-react/src/use-query.d.ts +4 -5
- package/out/zero-react/src/use-query.d.ts.map +1 -1
- package/out/zero-react/src/use-query.js +9 -86
- package/out/zero-react/src/use-query.js.map +1 -1
- package/out/zero-solid/src/solid-view.d.ts +0 -17
- package/out/zero-solid/src/solid-view.d.ts.map +1 -1
- package/out/zero-solid/src/solid-view.js +1 -39
- package/out/zero-solid/src/solid-view.js.map +1 -1
- package/out/zero-solid/src/use-query.js +3 -5
- package/out/zero-solid/src/use-query.js.map +1 -1
- package/out/zql/src/builder/builder.d.ts +0 -19
- package/out/zql/src/builder/builder.d.ts.map +1 -1
- package/out/zql/src/builder/builder.js +11 -28
- package/out/zql/src/builder/builder.js.map +1 -1
- package/out/zql/src/builder/debug-delegate.d.ts +1 -6
- package/out/zql/src/builder/debug-delegate.d.ts.map +1 -1
- package/out/zql/src/builder/debug-delegate.js +2 -14
- package/out/zql/src/builder/debug-delegate.js.map +1 -1
- package/out/zql/src/ivm/array-view.d.ts +0 -29
- package/out/zql/src/ivm/array-view.d.ts.map +1 -1
- package/out/zql/src/ivm/array-view.js +12 -63
- package/out/zql/src/ivm/array-view.js.map +1 -1
- package/out/zql/src/ivm/cap.d.ts.map +1 -1
- package/out/zql/src/ivm/cap.js +3 -5
- package/out/zql/src/ivm/cap.js.map +1 -1
- package/out/zql/src/ivm/data.d.ts.map +1 -1
- package/out/zql/src/ivm/data.js +3 -8
- package/out/zql/src/ivm/data.js.map +1 -1
- package/out/zql/src/ivm/exists.d.ts +1 -1
- package/out/zql/src/ivm/exists.d.ts.map +1 -1
- package/out/zql/src/ivm/exists.js.map +1 -1
- package/out/zql/src/ivm/fan-in.d.ts +2 -2
- package/out/zql/src/ivm/fan-in.d.ts.map +1 -1
- package/out/zql/src/ivm/fan-in.js +5 -6
- package/out/zql/src/ivm/fan-in.js.map +1 -1
- package/out/zql/src/ivm/fan-out.d.ts +2 -2
- package/out/zql/src/ivm/fan-out.d.ts.map +1 -1
- package/out/zql/src/ivm/fan-out.js.map +1 -1
- package/out/zql/src/ivm/filter-operators.d.ts +6 -7
- package/out/zql/src/ivm/filter-operators.d.ts.map +1 -1
- package/out/zql/src/ivm/filter-operators.js +12 -29
- package/out/zql/src/ivm/filter-operators.js.map +1 -1
- package/out/zql/src/ivm/filter.d.ts +2 -2
- package/out/zql/src/ivm/filter.d.ts.map +1 -1
- package/out/zql/src/ivm/filter.js +4 -7
- package/out/zql/src/ivm/filter.js.map +1 -1
- package/out/zql/src/ivm/flipped-join.js +2 -2
- package/out/zql/src/ivm/flipped-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 +4 -6
- package/out/zql/src/ivm/maybe-split-and-push-edit-change.js.map +1 -1
- package/out/zql/src/ivm/memory-source.d.ts +3 -15
- package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
- package/out/zql/src/ivm/memory-source.js +23 -57
- package/out/zql/src/ivm/memory-source.js.map +1 -1
- package/out/zql/src/ivm/operator.d.ts +0 -40
- package/out/zql/src/ivm/operator.d.ts.map +1 -1
- package/out/zql/src/ivm/operator.js.map +1 -1
- package/out/zql/src/ivm/take.d.ts.map +1 -1
- package/out/zql/src/ivm/take.js +4 -3
- package/out/zql/src/ivm/take.js.map +1 -1
- package/out/zql/src/ivm/union-fan-in.d.ts.map +1 -1
- package/out/zql/src/ivm/union-fan-in.js +7 -9
- package/out/zql/src/ivm/union-fan-in.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 +4 -9
- package/out/zql/src/ivm/view-apply-change.js.map +1 -1
- package/out/zql/src/ivm/view.d.ts +0 -15
- package/out/zql/src/ivm/view.d.ts.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 +3 -12
- package/out/zql/src/planner/planner-builder.d.ts.map +1 -1
- package/out/zql/src/planner/planner-builder.js +20 -40
- package/out/zql/src/planner/planner-builder.js.map +1 -1
- package/out/zql/src/planner/planner-connection.d.ts +2 -28
- package/out/zql/src/planner/planner-connection.d.ts.map +1 -1
- package/out/zql/src/planner/planner-connection.js +8 -108
- package/out/zql/src/planner/planner-connection.js.map +1 -1
- package/out/zql/src/planner/planner-debug.d.ts +1 -1
- package/out/zql/src/planner/planner-debug.d.ts.map +1 -1
- package/out/zql/src/planner/planner-debug.js +8 -3
- package/out/zql/src/planner/planner-debug.js.map +1 -1
- package/out/zql/src/planner/planner-fan-out.d.ts +0 -1
- package/out/zql/src/planner/planner-fan-out.d.ts.map +1 -1
- package/out/zql/src/planner/planner-fan-out.js +0 -3
- package/out/zql/src/planner/planner-fan-out.js.map +1 -1
- package/out/zql/src/planner/planner-graph.d.ts +0 -2
- package/out/zql/src/planner/planner-graph.d.ts.map +1 -1
- package/out/zql/src/planner/planner-graph.js +0 -2
- package/out/zql/src/planner/planner-graph.js.map +1 -1
- package/out/zql/src/planner/planner-join.d.ts +0 -2
- package/out/zql/src/planner/planner-join.d.ts.map +1 -1
- package/out/zql/src/planner/planner-join.js +0 -7
- package/out/zql/src/planner/planner-join.js.map +1 -1
- package/out/zql/src/planner/planner-node.d.ts +1 -2
- package/out/zql/src/planner/planner-node.d.ts.map +1 -1
- package/out/zql/src/planner/planner-node.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/query/query-delegate-base.d.ts +1 -9
- package/out/zql/src/query/query-delegate-base.d.ts.map +1 -1
- package/out/zql/src/query/query-delegate-base.js +36 -132
- package/out/zql/src/query/query-delegate-base.js.map +1 -1
- package/out/zql/src/query/query-delegate.d.ts +1 -50
- package/out/zql/src/query/query-delegate.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.d.ts +14 -25
- package/out/zql/src/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.js +94 -397
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/out/zql/src/query/query-internals.d.ts +11 -21
- package/out/zql/src/query/query-internals.d.ts.map +1 -1
- package/out/zql/src/query/query-internals.js.map +1 -1
- package/out/zql/src/query/query.d.ts +2 -11
- package/out/zql/src/query/query.d.ts.map +1 -1
- package/out/zql/src/query/runnable-query-impl.d.ts +2 -3
- package/out/zql/src/query/runnable-query-impl.d.ts.map +1 -1
- package/out/zql/src/query/runnable-query-impl.js +2 -15
- 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/db.d.ts +1 -9
- package/out/zqlite/src/db.d.ts.map +1 -1
- package/out/zqlite/src/db.js +2 -8
- package/out/zqlite/src/db.js.map +1 -1
- package/out/zqlite/src/query-builder.d.ts +1 -1
- package/out/zqlite/src/query-builder.d.ts.map +1 -1
- package/out/zqlite/src/query-builder.js +2 -4
- 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 +6 -5
- 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 +30 -2
- 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 -4
- package/out/zqlite/src/sqlite-stat-fanout.js.map +1 -1
- package/out/zqlite/src/table-source.d.ts +3 -16
- package/out/zqlite/src/table-source.d.ts.map +1 -1
- package/out/zqlite/src/table-source.js +14 -33
- package/out/zqlite/src/table-source.js.map +1 -1
- package/package.json +3 -2
- package/out/replicache/src/dag/invalid-ref-count-error.d.ts +0 -12
- package/out/replicache/src/dag/invalid-ref-count-error.d.ts.map +0 -1
- package/out/replicache/src/dag/invalid-ref-count-error.js +0 -19
- package/out/replicache/src/dag/invalid-ref-count-error.js.map +0 -1
- package/out/shared/src/xxhash32.d.ts +0 -36
- package/out/shared/src/xxhash32.d.ts.map +0 -1
- package/out/shared/src/xxhash32.js +0 -51
- package/out/shared/src/xxhash32.js.map +0 -1
- package/out/zero-cache/src/db/index-predicate.d.ts +0 -4
- package/out/zero-cache/src/db/index-predicate.d.ts.map +0 -1
- package/out/zero-cache/src/db/index-predicate.js +0 -46
- package/out/zero-cache/src/db/index-predicate.js.map +0 -1
- package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.d.ts +0 -19
- package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.d.ts.map +0 -1
- package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js +0 -581
- package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js.map +0 -1
- package/out/zero-cache/src/services/litestream/litestream-checkpointer.js +0 -131
- package/out/zero-cache/src/services/litestream/litestream-checkpointer.js.map +0 -1
- package/out/zero-cache/src/services/litestream/litestream-controller.d.ts +0 -70
- package/out/zero-cache/src/services/litestream/litestream-controller.d.ts.map +0 -1
- package/out/zero-cache/src/services/litestream/litestream-controller.js +0 -101
- package/out/zero-cache/src/services/litestream/litestream-controller.js.map +0 -1
- package/out/zero-cache/src/services/profz.d.ts +0 -7
- package/out/zero-cache/src/services/profz.d.ts.map +0 -1
- package/out/zero-cache/src/services/profz.js +0 -103
- package/out/zero-cache/src/services/profz.js.map +0 -1
- package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts +0 -33
- package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts.map +0 -1
- package/out/zero-cache/src/services/view-syncer/hydration-budget.js +0 -62
- package/out/zero-cache/src/services/view-syncer/hydration-budget.js.map +0 -1
- package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts +0 -51
- package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts.map +0 -1
- package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.js +0 -78
- package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.js.map +0 -1
- package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.d.ts +0 -95
- package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.d.ts.map +0 -1
- package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.js +0 -155
- package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.js.map +0 -1
- package/out/zero-protocol/src/query-hash-visitor.d.ts +0 -81
- package/out/zero-protocol/src/query-hash-visitor.d.ts.map +0 -1
- package/out/zero-protocol/src/query-hash-visitor.js +0 -324
- package/out/zero-protocol/src/query-hash-visitor.js.map +0 -1
- package/out/zql/src/builder/correlated-predicate-pushdown.d.ts +0 -43
- package/out/zql/src/builder/correlated-predicate-pushdown.d.ts.map +0 -1
- package/out/zql/src/builder/correlated-predicate-pushdown.js +0 -161
- package/out/zql/src/builder/correlated-predicate-pushdown.js.map +0 -1
- package/out/zql/src/ivm/connection-index.d.ts +0 -68
- package/out/zql/src/ivm/connection-index.d.ts.map +0 -1
- package/out/zql/src/ivm/connection-index.js +0 -149
- package/out/zql/src/ivm/connection-index.js.map +0 -1
- package/out/zql/src/ivm/deferred-input.d.ts +0 -44
- package/out/zql/src/ivm/deferred-input.d.ts.map +0 -1
- package/out/zql/src/ivm/deferred-input.js +0 -89
- package/out/zql/src/ivm/deferred-input.js.map +0 -1
- package/out/zql/src/planner/planner-filter.d.ts +0 -59
- package/out/zql/src/planner/planner-filter.d.ts.map +0 -1
- package/out/zql/src/planner/planner-filter.js +0 -116
- package/out/zql/src/planner/planner-filter.js.map +0 -1
- package/out/zql/src/query/query-transitions.d.ts +0 -171
- package/out/zql/src/query/query-transitions.d.ts.map +0 -1
- package/out/zql/src/query/query-transitions.js +0 -204
- package/out/zql/src/query/query-transitions.js.map +0 -1
|
@@ -1,64 +1,18 @@
|
|
|
1
1
|
import { assert } from "../../../shared/src/asserts.js";
|
|
2
|
-
import {
|
|
3
|
-
import { getOrInsertComputed, newMap } from "../../../shared/src/map.js";
|
|
4
|
-
import { SUBQ_PREFIX, insertRelated, normalizeAST, normalizeCondition, normalizedRelated, tableAST } from "../../../zero-protocol/src/ast.js";
|
|
2
|
+
import { SUBQ_PREFIX } from "../../../zero-protocol/src/ast.js";
|
|
5
3
|
import { defaultFormat } from "../../../zero-types/src/format.js";
|
|
6
|
-
import {
|
|
4
|
+
import { hashOfAST } from "../../../zero-protocol/src/query-hash.js";
|
|
7
5
|
import { NotImplementedError } from "../error.js";
|
|
8
6
|
import { ExpressionBuilder, and, cmp, simplifyCondition } from "./expression.js";
|
|
9
7
|
import { queryInternalsTag } from "./query-internals.js";
|
|
10
|
-
import { HashIndex, Transitions } from "./query-transitions.js";
|
|
11
8
|
//#region ../zql/src/query/query-impl.ts
|
|
12
9
|
function newQuery(schema, table) {
|
|
13
|
-
return
|
|
10
|
+
return newQueryImpl(schema, table, { table }, defaultFormat, "client");
|
|
14
11
|
}
|
|
15
12
|
function newQueryImpl(schema, tableName, ast, format, system) {
|
|
16
|
-
return newQueryInternal(schema, tableName, normalizeAST(ast), format, system);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Root queries are interned per schema so that two `createBuilder(schema)` calls
|
|
20
|
-
* hand out the same starting point, and therefore share the whole transition
|
|
21
|
-
* tree below it. Only cleared entries accumulate here, at most one per
|
|
22
|
-
* system/table pair, so no sweeping is needed.
|
|
23
|
-
*/
|
|
24
|
-
var rootsBySchema = /* @__PURE__ */ new WeakMap();
|
|
25
|
-
/**
|
|
26
|
-
* Whether this is the AST `tableAST(tableName)` produces -- the whole table,
|
|
27
|
-
* nothing else. A normalized AST carries every field, so this cannot be a key
|
|
28
|
-
* count; each one has to be checked.
|
|
29
|
-
*/
|
|
30
|
-
function isRootAST(ast, tableName) {
|
|
31
|
-
return ast.table === tableName && ast.schema === void 0 && ast.alias === void 0 && ast.where === void 0 && ast.related === void 0 && ast.start === void 0 && ast.limit === void 0 && ast.orderBy === void 0;
|
|
32
|
-
}
|
|
33
|
-
function newQueryInternal(schema, tableName, ast, format, system) {
|
|
34
|
-
const interned = format === defaultFormat && isRootAST(ast, tableName);
|
|
35
|
-
const key = `${system}:${tableName}`;
|
|
36
|
-
let roots;
|
|
37
|
-
if (interned) {
|
|
38
|
-
roots = rootsBySchema.get(schema);
|
|
39
|
-
const existing = roots?.get(key)?.deref();
|
|
40
|
-
if (existing) return existing;
|
|
41
|
-
}
|
|
42
13
|
const inner = (tableName, ast, format, customQueryID, currentJunction) => new QueryImpl(schema, tableName, ast, format, system, customQueryID, currentJunction, inner);
|
|
43
|
-
|
|
44
|
-
if (interned) {
|
|
45
|
-
if (!roots) {
|
|
46
|
-
roots = /* @__PURE__ */ new Map();
|
|
47
|
-
rootsBySchema.set(schema, roots);
|
|
48
|
-
}
|
|
49
|
-
roots.set(key, new WeakRef(created));
|
|
50
|
-
}
|
|
51
|
-
return created;
|
|
14
|
+
return inner(tableName, ast, format, void 0, void 0);
|
|
52
15
|
}
|
|
53
|
-
/**
|
|
54
|
-
* The AST of a QueryImpl is always normalized. Each step builds its AST in
|
|
55
|
-
* normalized form rather than normalizing afterwards: a normalized AST has
|
|
56
|
-
* every field, so spreading one and replacing a field keeps the field order
|
|
57
|
-
* intact, and only the field a step actually changes needs normalizing (the
|
|
58
|
-
* conditions of a `where`, the position of a new `related`). The ASTs that
|
|
59
|
-
* come in from the outside are normalized by {@link newQueryImpl}, which is
|
|
60
|
-
* what the `NormalizedAST` of the AST it holds stands for.
|
|
61
|
-
*/
|
|
62
16
|
var QueryImpl = class {
|
|
63
17
|
[queryInternalsTag] = true;
|
|
64
18
|
#schema;
|
|
@@ -70,26 +24,6 @@ var QueryImpl = class {
|
|
|
70
24
|
#currentJunction;
|
|
71
25
|
customQueryID;
|
|
72
26
|
#newQuery;
|
|
73
|
-
/**
|
|
74
|
-
* The query this one was derived from, held *strongly*, and the queries
|
|
75
|
-
* derived from this one, held *weakly*. This is the arrangement V8 uses for
|
|
76
|
-
* hidden-class transitions, and it is what makes interning stable: as long as
|
|
77
|
-
* a query is reachable its whole ancestor spine is too, so re-deriving it from
|
|
78
|
-
* the root yields the same instance. See `query-transitions.ts`.
|
|
79
|
-
*/
|
|
80
|
-
#parent;
|
|
81
|
-
#transitions;
|
|
82
|
-
/**
|
|
83
|
-
* The second level of interning, keyed by hash; see `HashIndex`. Set on the
|
|
84
|
-
* root only, which is what scopes it to one schema and one delegate.
|
|
85
|
-
*/
|
|
86
|
-
#byHash;
|
|
87
|
-
/**
|
|
88
|
-
* Memoized because a query is interned: the same node serves every rebuild of
|
|
89
|
-
* a chain, so building this once rather than per `where(fn)` call takes the
|
|
90
|
-
* whole thing -- the builder and the bound `#exists` -- off the repeat path.
|
|
91
|
-
*/
|
|
92
|
-
#expressionBuilder;
|
|
93
27
|
constructor(schema, tableName, ast, format, system, customQueryID, currentJunction, newQuery) {
|
|
94
28
|
this.#schema = schema;
|
|
95
29
|
this.#tableName = tableName;
|
|
@@ -100,44 +34,6 @@ var QueryImpl = class {
|
|
|
100
34
|
this.customQueryID = customQueryID;
|
|
101
35
|
this.#newQuery = newQuery;
|
|
102
36
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Interns a transition whose key space is finite and schema-derived; see
|
|
105
|
-
* {@linkcode Transitions.storeBounded}. Used for the base sub-query handed to
|
|
106
|
-
* a `related`/`exists` callback, which is determined entirely by the
|
|
107
|
-
* relationship name.
|
|
108
|
-
*/
|
|
109
|
-
#deriveBounded(key, build) {
|
|
110
|
-
const existing = this.#transitions?.lookupBounded(key);
|
|
111
|
-
if (existing !== void 0) return existing;
|
|
112
|
-
return this.#record(key, void 0, void 0, build(), true);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Interns the result of applying a builder operation to this query.
|
|
116
|
-
*
|
|
117
|
-
* `key` names the operation and `value` carries its varying argument, kept
|
|
118
|
-
* apart so the key stays a string V8 has already hashed. When the two do not
|
|
119
|
-
* settle it, `delta` carries the rest and is compared with `deepEqual`. Only
|
|
120
|
-
* the delta is compared, never the whole AST: this query is already canonical,
|
|
121
|
-
* so two of its children are equal exactly when the operations that produced
|
|
122
|
-
* them are.
|
|
123
|
-
*
|
|
124
|
-
* `T` is deliberately unconstrained so that the contextual return type at each
|
|
125
|
-
* call site still drives `#newQuery`'s inference, exactly as it did when the
|
|
126
|
-
* call sites returned `this.#newQuery(...)` directly.
|
|
127
|
-
*/
|
|
128
|
-
#derive(key, value, delta, build) {
|
|
129
|
-
const existing = this.#transitions?.lookup(key, value, delta);
|
|
130
|
-
if (existing !== void 0) return existing;
|
|
131
|
-
return this.#record(key, value, delta, build(), false);
|
|
132
|
-
}
|
|
133
|
-
#record(key, value, delta, created, bounded) {
|
|
134
|
-
const q = created;
|
|
135
|
-
q.#parent = this;
|
|
136
|
-
const transitions = this.#transitions ??= new Transitions();
|
|
137
|
-
if (bounded) transitions.storeBounded(key, q);
|
|
138
|
-
else transitions.store(key, value, delta, q);
|
|
139
|
-
return created;
|
|
140
|
-
}
|
|
141
37
|
run(_options) {
|
|
142
38
|
throwQueryNotRunnable();
|
|
143
39
|
}
|
|
@@ -148,204 +44,150 @@ var QueryImpl = class {
|
|
|
148
44
|
throwQueryNotRunnable();
|
|
149
45
|
}
|
|
150
46
|
nameAndArgs(name, args) {
|
|
151
|
-
return this.#
|
|
47
|
+
return this.#newQuery(this.#tableName, this.#ast, this.format, {
|
|
152
48
|
name,
|
|
153
49
|
args
|
|
154
|
-
}, this.#currentJunction)
|
|
50
|
+
}, this.#currentJunction);
|
|
155
51
|
}
|
|
156
52
|
hash() {
|
|
157
|
-
if (!this.#hash)
|
|
158
|
-
this.#hash = hashOfQueryInternals(this.#ast, this.format, this.#system, this.#currentJunction, this.customQueryID?.name, this.customQueryID?.args);
|
|
159
|
-
this.#canonicalize();
|
|
160
|
-
}
|
|
53
|
+
if (!this.#hash) this.#hash = hashOfAST(this.#ast);
|
|
161
54
|
return this.#hash;
|
|
162
55
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
* than a missed unification.
|
|
172
|
-
*/
|
|
173
|
-
#canonicalize() {
|
|
174
|
-
const parent = this.#parent;
|
|
175
|
-
if (parent === void 0) return;
|
|
176
|
-
let root = parent;
|
|
177
|
-
while (root.#parent !== void 0) root = root.#parent;
|
|
178
|
-
const index = root.#byHash ??= new HashIndex();
|
|
179
|
-
const existing = index.get(this.#hash);
|
|
180
|
-
if (existing === void 0) index.set(this.#hash, this);
|
|
181
|
-
else if (existing !== this && this.#sameAs(existing)) parent.#transitions?.replace(this, existing);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Whether `other` is interchangeable with this query: everything `hash()`
|
|
185
|
-
* covers, compared structurally. Schema and delegate are not compared. Both
|
|
186
|
-
* are fixed by the root, and this only ever compares queries under one root.
|
|
187
|
-
*/
|
|
188
|
-
#sameAs(other) {
|
|
189
|
-
return this.#system === other.#system && this.#currentJunction === other.#currentJunction && this.customQueryID?.name === other.customQueryID?.name && deepEqual(this.customQueryID?.args, other.customQueryID?.args) && deepEqual(this.format, other.format) && deepEqual(this.#ast, other.#ast);
|
|
190
|
-
}
|
|
191
|
-
one() {
|
|
192
|
-
return this.#derive("one", void 0, void 0, () => this.#newQuery(this.#tableName, {
|
|
193
|
-
...this.#ast,
|
|
194
|
-
limit: 1
|
|
195
|
-
}, {
|
|
196
|
-
...this.format,
|
|
197
|
-
singular: true
|
|
198
|
-
}, this.customQueryID, this.#currentJunction));
|
|
199
|
-
}
|
|
200
|
-
whereExists(relationship, cbOrOptions, options) {
|
|
56
|
+
one = () => this.#newQuery(this.#tableName, {
|
|
57
|
+
...this.#ast,
|
|
58
|
+
limit: 1
|
|
59
|
+
}, {
|
|
60
|
+
...this.format,
|
|
61
|
+
singular: true
|
|
62
|
+
}, this.customQueryID, this.#currentJunction);
|
|
63
|
+
whereExists = (relationship, cbOrOptions, options) => {
|
|
201
64
|
const cb = typeof cbOrOptions === "function" ? cbOrOptions : void 0;
|
|
202
65
|
const opts = typeof cbOrOptions === "function" ? options : cbOrOptions;
|
|
203
66
|
return this.where(({ exists }) => exists(relationship, cb, opts));
|
|
204
|
-
}
|
|
205
|
-
related(relationship, cb) {
|
|
67
|
+
};
|
|
68
|
+
related = (relationship, cb) => {
|
|
206
69
|
if (relationship.startsWith("zsubq_")) throw new Error(`Relationship names may not start with "${SUBQ_PREFIX}". That is a reserved prefix.`);
|
|
207
70
|
cb = cb ?? ((q) => q);
|
|
208
71
|
const related = this.#schema.relationships[this.#tableName][relationship];
|
|
209
72
|
assert(related, "Invalid relationship");
|
|
210
73
|
if (isOneHop(related)) {
|
|
211
74
|
const { destSchema, destField, sourceField, cardinality } = related[0];
|
|
212
|
-
const q = this.#
|
|
75
|
+
const q = this.#newQuery(destSchema, {
|
|
76
|
+
table: destSchema,
|
|
77
|
+
alias: relationship
|
|
78
|
+
}, {
|
|
213
79
|
relationships: {},
|
|
214
80
|
singular: cardinality === "one"
|
|
215
|
-
}, this.customQueryID, void 0)
|
|
81
|
+
}, this.customQueryID, void 0);
|
|
216
82
|
const subQuery = asQueryImpl(cb(q));
|
|
217
83
|
assert(isCompoundKey(sourceField), "The source of a relationship must specify at last 1 field");
|
|
218
84
|
assert(isCompoundKey(destField), "The destination of a relationship must specify at last 1 field");
|
|
219
85
|
assert(sourceField.length === destField.length, "The source and destination of a relationship must have the same number of fields");
|
|
220
|
-
return this.#
|
|
86
|
+
return this.#newQuery(this.#tableName, {
|
|
221
87
|
...this.#ast,
|
|
222
|
-
related:
|
|
88
|
+
related: [...this.#ast.related ?? [], {
|
|
89
|
+
system: this.#system,
|
|
223
90
|
correlation: {
|
|
224
91
|
parentField: sourceField,
|
|
225
92
|
childField: destField
|
|
226
93
|
},
|
|
227
|
-
subquery: subQuery.#ast
|
|
228
|
-
|
|
229
|
-
})
|
|
94
|
+
subquery: subQuery.#ast
|
|
95
|
+
}]
|
|
230
96
|
}, {
|
|
231
97
|
...this.format,
|
|
232
98
|
relationships: {
|
|
233
99
|
...this.format.relationships,
|
|
234
100
|
[relationship]: subQuery.format
|
|
235
101
|
}
|
|
236
|
-
}, this.customQueryID, this.#currentJunction)
|
|
102
|
+
}, this.customQueryID, this.#currentJunction);
|
|
237
103
|
}
|
|
238
104
|
if (isTwoHop(related)) {
|
|
239
105
|
const [firstRelation, secondRelation] = related;
|
|
240
106
|
const { destSchema } = secondRelation;
|
|
241
107
|
const junctionSchema = firstRelation.destSchema;
|
|
242
|
-
const sq = asQueryImpl(cb(this.#
|
|
108
|
+
const sq = asQueryImpl(cb(this.#newQuery(destSchema, {
|
|
109
|
+
table: destSchema,
|
|
110
|
+
alias: relationship
|
|
111
|
+
}, {
|
|
243
112
|
relationships: {},
|
|
244
113
|
singular: secondRelation.cardinality === "one"
|
|
245
|
-
}, this.customQueryID, relationship)))
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
assert(isCompoundKey(
|
|
249
|
-
assert(isCompoundKey(
|
|
250
|
-
|
|
251
|
-
assert(isCompoundKey(secondDest), "Invalid relationship");
|
|
252
|
-
return this.#derive(relatedKey(relationship), astID(sq.#ast), void 0, () => this.#newQuery(this.#tableName, {
|
|
114
|
+
}, this.customQueryID, relationship)));
|
|
115
|
+
assert(isCompoundKey(firstRelation.sourceField), "Invalid relationship");
|
|
116
|
+
assert(isCompoundKey(firstRelation.destField), "Invalid relationship");
|
|
117
|
+
assert(isCompoundKey(secondRelation.sourceField), "Invalid relationship");
|
|
118
|
+
assert(isCompoundKey(secondRelation.destField), "Invalid relationship");
|
|
119
|
+
return this.#newQuery(this.#tableName, {
|
|
253
120
|
...this.#ast,
|
|
254
|
-
related:
|
|
121
|
+
related: [...this.#ast.related ?? [], {
|
|
122
|
+
system: this.#system,
|
|
255
123
|
correlation: {
|
|
256
|
-
parentField:
|
|
257
|
-
childField:
|
|
124
|
+
parentField: firstRelation.sourceField,
|
|
125
|
+
childField: firstRelation.destField
|
|
258
126
|
},
|
|
259
127
|
hidden: true,
|
|
260
128
|
subquery: {
|
|
261
|
-
|
|
262
|
-
|
|
129
|
+
table: junctionSchema,
|
|
130
|
+
alias: relationship,
|
|
131
|
+
related: [{
|
|
132
|
+
system: this.#system,
|
|
263
133
|
correlation: {
|
|
264
|
-
parentField:
|
|
265
|
-
childField:
|
|
134
|
+
parentField: secondRelation.sourceField,
|
|
135
|
+
childField: secondRelation.destField
|
|
266
136
|
},
|
|
267
|
-
subquery: sq.#ast
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
system: this.#system
|
|
272
|
-
})
|
|
137
|
+
subquery: sq.#ast
|
|
138
|
+
}]
|
|
139
|
+
}
|
|
140
|
+
}]
|
|
273
141
|
}, {
|
|
274
142
|
...this.format,
|
|
275
143
|
relationships: {
|
|
276
144
|
...this.format.relationships,
|
|
277
145
|
[relationship]: sq.format
|
|
278
146
|
}
|
|
279
|
-
}, this.customQueryID, this.#currentJunction)
|
|
147
|
+
}, this.customQueryID, this.#currentJunction);
|
|
280
148
|
}
|
|
281
149
|
throw new Error(`Invalid relationship ${relationship}`);
|
|
282
|
-
}
|
|
283
|
-
where(fieldOrExpressionFactory, opOrValue, value) {
|
|
150
|
+
};
|
|
151
|
+
where = function(fieldOrExpressionFactory, opOrValue, value) {
|
|
284
152
|
let cond;
|
|
285
153
|
if (typeof fieldOrExpressionFactory === "function") cond = fieldOrExpressionFactory(this.expressionBuilder());
|
|
286
154
|
else {
|
|
287
155
|
assert(arguments.length >= 2, "Invalid condition. Too few arguments.");
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const raw = twoArg ? opOrValue : value;
|
|
291
|
-
if (raw === null || typeof raw !== "object") {
|
|
292
|
-
const hit = this.#transitions?.lookup(whereKey(fieldOrExpressionFactory, op), raw ?? null, void 0);
|
|
293
|
-
if (hit !== void 0) return hit;
|
|
294
|
-
}
|
|
295
|
-
cond = twoArg ? cmp(fieldOrExpressionFactory, opOrValue) : cmp(fieldOrExpressionFactory, opOrValue, value);
|
|
156
|
+
if (arguments.length === 2) cond = cmp(fieldOrExpressionFactory, opOrValue);
|
|
157
|
+
else cond = cmp(fieldOrExpressionFactory, opOrValue, value);
|
|
296
158
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
key = whereKey(cond.left.name, cond.op);
|
|
302
|
-
const right = cond.right;
|
|
303
|
-
tValue = right.type === "literal" && isPrimitive(right.value) ? right.value : rightTag(right);
|
|
304
|
-
delta = void 0;
|
|
305
|
-
} else {
|
|
306
|
-
const exact = condKey(cond);
|
|
307
|
-
if (exact === void 0) key = treeKey(cond);
|
|
308
|
-
else {
|
|
309
|
-
key = "where:tree";
|
|
310
|
-
tValue = exact;
|
|
311
|
-
delta = void 0;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
return this.#derive(key, tValue, delta, () => {
|
|
315
|
-
const existingWhere = this.#ast.where;
|
|
316
|
-
const merged = existingWhere ? and(existingWhere, cond) : cond;
|
|
317
|
-
return this.#newQuery(this.#tableName, {
|
|
318
|
-
...this.#ast,
|
|
319
|
-
where: normalizeCondition(simplifyCondition(merged))
|
|
320
|
-
}, this.format, this.customQueryID, this.#currentJunction);
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
start(row, opts) {
|
|
324
|
-
return this.#derive(opts?.inclusive ? "start:inclusive" : "start:exclusive", valueTag(row), void 0, () => this.#newQuery(this.#tableName, {
|
|
159
|
+
const existingWhere = this.#ast.where;
|
|
160
|
+
if (existingWhere) cond = and(existingWhere, cond);
|
|
161
|
+
const where = simplifyCondition(cond);
|
|
162
|
+
return this.#newQuery(this.#tableName, {
|
|
325
163
|
...this.#ast,
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
164
|
+
where
|
|
165
|
+
}, this.format, this.customQueryID, this.#currentJunction);
|
|
166
|
+
}.bind(this);
|
|
167
|
+
start = (row, opts) => this.#newQuery(this.#tableName, {
|
|
168
|
+
...this.#ast,
|
|
169
|
+
start: {
|
|
170
|
+
row,
|
|
171
|
+
exclusive: !opts?.inclusive
|
|
172
|
+
}
|
|
173
|
+
}, this.format, this.customQueryID, this.#currentJunction);
|
|
174
|
+
limit = (limit) => {
|
|
333
175
|
if (limit < 0) throw new Error("Limit must be non-negative");
|
|
334
176
|
if ((limit | 0) !== limit) throw new Error("Limit must be an integer");
|
|
335
177
|
if (this.#currentJunction) throw new NotImplementedError("Limit is not supported in junction relationships yet. Junction relationship being limited: " + this.#currentJunction);
|
|
336
|
-
return this.#
|
|
178
|
+
return this.#newQuery(this.#tableName, {
|
|
337
179
|
...this.#ast,
|
|
338
180
|
limit
|
|
339
|
-
}, this.format, this.customQueryID, this.#currentJunction)
|
|
340
|
-
}
|
|
341
|
-
orderBy(field, direction) {
|
|
181
|
+
}, this.format, this.customQueryID, this.#currentJunction);
|
|
182
|
+
};
|
|
183
|
+
orderBy = (field, direction) => {
|
|
342
184
|
if (this.#currentJunction) throw new NotImplementedError("Order by is not supported in junction relationships yet. Junction relationship being ordered: " + this.#currentJunction);
|
|
343
|
-
return this.#
|
|
185
|
+
return this.#newQuery(this.#tableName, {
|
|
344
186
|
...this.#ast,
|
|
345
187
|
orderBy: [...this.#ast.orderBy ?? [], [field, direction]]
|
|
346
|
-
}, this.format, this.customQueryID, this.#currentJunction)
|
|
347
|
-
}
|
|
348
|
-
#exists(relationship, cb, options) {
|
|
188
|
+
}, this.format, this.customQueryID, this.#currentJunction);
|
|
189
|
+
};
|
|
190
|
+
#exists = (relationship, cb, options) => {
|
|
349
191
|
cb = cb ?? ((q) => q);
|
|
350
192
|
const flip = options?.flip;
|
|
351
193
|
const scalar = options?.scalar;
|
|
@@ -355,8 +197,10 @@ var QueryImpl = class {
|
|
|
355
197
|
const { destSchema: destTableName, sourceField, destField } = related[0];
|
|
356
198
|
assert(isCompoundKey(sourceField), "Invalid relationship");
|
|
357
199
|
assert(isCompoundKey(destField), "Invalid relationship");
|
|
358
|
-
const subQuery = asQueryImpl(cb(this.#
|
|
359
|
-
|
|
200
|
+
const subQuery = asQueryImpl(cb(this.#newQuery(destTableName, {
|
|
201
|
+
table: destTableName,
|
|
202
|
+
alias: `${SUBQ_PREFIX}${relationship}`
|
|
203
|
+
}, defaultFormat, this.customQueryID, void 0)));
|
|
360
204
|
return {
|
|
361
205
|
type: "correlatedSubquery",
|
|
362
206
|
related: {
|
|
@@ -380,7 +224,10 @@ var QueryImpl = class {
|
|
|
380
224
|
assert(isCompoundKey(secondRelation.destField), "Invalid relationship");
|
|
381
225
|
const { destSchema } = secondRelation;
|
|
382
226
|
const junctionSchema = firstRelation.destSchema;
|
|
383
|
-
const queryToDest = cb(this.#
|
|
227
|
+
const queryToDest = cb(this.#newQuery(destSchema, {
|
|
228
|
+
table: destSchema,
|
|
229
|
+
alias: `${SUBQ_PREFIX}zhidden_${relationship}`
|
|
230
|
+
}, defaultFormat, this.customQueryID, relationship));
|
|
384
231
|
return {
|
|
385
232
|
type: "correlatedSubquery",
|
|
386
233
|
related: {
|
|
@@ -390,8 +237,9 @@ var QueryImpl = class {
|
|
|
390
237
|
childField: firstRelation.destField
|
|
391
238
|
},
|
|
392
239
|
subquery: {
|
|
393
|
-
|
|
394
|
-
|
|
240
|
+
table: junctionSchema,
|
|
241
|
+
alias: `${SUBQ_PREFIX}${relationship}`,
|
|
242
|
+
where: {
|
|
395
243
|
type: "correlatedSubquery",
|
|
396
244
|
related: {
|
|
397
245
|
system: this.#system,
|
|
@@ -404,7 +252,7 @@ var QueryImpl = class {
|
|
|
404
252
|
op: "EXISTS",
|
|
405
253
|
...flip !== void 0 ? { flip } : {},
|
|
406
254
|
...scalar !== void 0 ? { scalar } : {}
|
|
407
|
-
}
|
|
255
|
+
}
|
|
408
256
|
}
|
|
409
257
|
},
|
|
410
258
|
op: "EXISTS",
|
|
@@ -412,169 +260,18 @@ var QueryImpl = class {
|
|
|
412
260
|
};
|
|
413
261
|
}
|
|
414
262
|
throw new Error(`Invalid relationship ${relationship}`);
|
|
415
|
-
}
|
|
263
|
+
};
|
|
416
264
|
get ast() {
|
|
417
265
|
return this.#ast;
|
|
418
266
|
}
|
|
419
267
|
expressionBuilder() {
|
|
420
|
-
return
|
|
268
|
+
return new ExpressionBuilder(this.#exists);
|
|
421
269
|
}
|
|
422
270
|
};
|
|
423
271
|
function asQueryImpl(q) {
|
|
424
272
|
assert(q instanceof QueryImpl, "Expected QueryImpl instance");
|
|
425
273
|
return q;
|
|
426
274
|
}
|
|
427
|
-
/**
|
|
428
|
-
* A stable id per query AST.
|
|
429
|
-
*
|
|
430
|
-
* Every `QueryImpl` allocates its own AST object, so these are one-to-one with
|
|
431
|
-
* queries, and interning makes the object identity stable across rebuilds. That
|
|
432
|
-
* lets a `related` or `exists` transition key on *which* sub-query it points at
|
|
433
|
-
* rather than comparing the sub-tree.
|
|
434
|
-
*
|
|
435
|
-
* Assigned only where it is needed. A `WeakMap.set` costs on the order of a
|
|
436
|
-
* hundred nanoseconds, so doing this for every query rather than for the few
|
|
437
|
-
* that are sub-queries was one of the largest single costs of building a query
|
|
438
|
-
* from cold. ASTs that never pass through here -- including the junction AST a
|
|
439
|
-
* two-hop `exists` builds inline -- are absent, and fall back to a delta.
|
|
440
|
-
*/
|
|
441
|
-
var astIDs = /* @__PURE__ */ new WeakMap();
|
|
442
|
-
var nextASTID = 0;
|
|
443
|
-
var newASTID = () => ++nextASTID;
|
|
444
|
-
function astID(ast) {
|
|
445
|
-
return getOrInsertComputed(astIDs, ast, newASTID);
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Memoized transition keys.
|
|
449
|
-
*
|
|
450
|
-
* A transition key must be a string V8 has already hashed, or the `Map` lookup
|
|
451
|
-
* has to hash it from scratch -- measured at ~148ns against ~10ns, which dwarfs
|
|
452
|
-
* everything else a lookup does. Both tables are keyed by schema-derived names,
|
|
453
|
-
* so they are bounded by the schema.
|
|
454
|
-
*/
|
|
455
|
-
var whereKeys = /* @__PURE__ */ new Map();
|
|
456
|
-
function whereKey(column, op) {
|
|
457
|
-
return getOrInsertComputed(getOrInsertComputed(whereKeys, column, newMap), op, (op) => `where:${column}:${op}`);
|
|
458
|
-
}
|
|
459
|
-
var relatedKeys = /* @__PURE__ */ new Map();
|
|
460
|
-
var newRelatedKey = (relationship) => `related:${relationship}`;
|
|
461
|
-
function relatedKey(relationship) {
|
|
462
|
-
return getOrInsertComputed(relatedKeys, relationship, newRelatedKey);
|
|
463
|
-
}
|
|
464
|
-
function isPrimitive(v) {
|
|
465
|
-
return v === null || typeof v !== "object";
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Folds a JSON value into a self-delimiting token: a string is
|
|
469
|
-
* length-prefixed, a number is terminated, an array or object is
|
|
470
|
-
* count-prefixed and encodes its members recursively, and the rest are fixed
|
|
471
|
-
* width. Tokens can therefore be concatenated into a key with no way for one
|
|
472
|
-
* to run into the next, and the leading tag keeps `'1'` and `1` apart.
|
|
473
|
-
*
|
|
474
|
-
* Not `JSON.stringify`: it writes `Infinity`, `NaN` and `null` all as `null`,
|
|
475
|
-
* and this token is trusted as exact, so a nested value that serialized like
|
|
476
|
-
* another's would hand back a query with the wrong value in its AST. Numbers
|
|
477
|
-
* are written the way `String` writes them, which keeps those apart. An
|
|
478
|
-
* `undefined` property is skipped, as `deepEqual` would skip it; property
|
|
479
|
-
* order is part of the encoding, so an object spelled in another order
|
|
480
|
-
* interns separately.
|
|
481
|
-
*/
|
|
482
|
-
function valueTag(v) {
|
|
483
|
-
switch (typeof v) {
|
|
484
|
-
case "string": return `:s${enc(v)}`;
|
|
485
|
-
case "number": return `:n${v};`;
|
|
486
|
-
case "boolean": return v ? ":t" : ":f";
|
|
487
|
-
default: {
|
|
488
|
-
if (v === null) return ":z";
|
|
489
|
-
if (Array.isArray(v)) {
|
|
490
|
-
let out = `:a${v.length}:`;
|
|
491
|
-
for (const e of v) out += valueTag(e);
|
|
492
|
-
return out;
|
|
493
|
-
}
|
|
494
|
-
const o = v;
|
|
495
|
-
let body = "";
|
|
496
|
-
let n = 0;
|
|
497
|
-
for (const key in o) {
|
|
498
|
-
const e = o[key];
|
|
499
|
-
if (e !== void 0 && Object.hasOwn(o, key)) {
|
|
500
|
-
body += enc(key) + valueTag(e);
|
|
501
|
-
n++;
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
return `:o${n}:${body}`;
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* Folds the right-hand side of a simple condition into a transition value, so
|
|
510
|
-
* that the transition is exact and the lookup needs no comparison at all.
|
|
511
|
-
*
|
|
512
|
-
* Arrays (`IN`) and parameter references are encoded in full: that is one
|
|
513
|
-
* pass over a small value, where leaving them in the delta would instead cost
|
|
514
|
-
* a `deepEqual` over the whole condition for every sibling a lookup walks
|
|
515
|
-
* past.
|
|
516
|
-
*/
|
|
517
|
-
function rightTag(right) {
|
|
518
|
-
if (right.type !== "literal") return `:p${valueTag(right)}`;
|
|
519
|
-
return valueTag(right.value);
|
|
520
|
-
}
|
|
521
|
-
/**
|
|
522
|
-
* Length-prefixes a free-form string so it can be concatenated into a key
|
|
523
|
-
* without a separator being ambiguous with the content.
|
|
524
|
-
*/
|
|
525
|
-
function enc(s) {
|
|
526
|
-
return `${s.length}:${s}`;
|
|
527
|
-
}
|
|
528
|
-
/** Encodes an optional boolean without collapsing `undefined` into `false`. */
|
|
529
|
-
function tri(b) {
|
|
530
|
-
return b === void 0 ? "-" : b ? "t" : "f";
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* An exact key for a whole condition tree, or `undefined` for a shape we cannot
|
|
534
|
-
* encode (which falls back to {@linkcode treeKey} plus a delta).
|
|
535
|
-
*
|
|
536
|
-
* Everything variable-length is length-prefixed, so distinct trees cannot
|
|
537
|
-
* produce the same string and the key needs no `deepEqual` to back it up. That
|
|
538
|
-
* matters because the alternative -- one coarse bucket per shape -- turns N
|
|
539
|
-
* sibling conditions off the same parent into an N-deep scan of tree
|
|
540
|
-
* comparisons, which measured far slower than not interning at all.
|
|
541
|
-
*/
|
|
542
|
-
function condKey(cond) {
|
|
543
|
-
switch (cond.type) {
|
|
544
|
-
case "simple":
|
|
545
|
-
if (cond.left.type !== "column") return;
|
|
546
|
-
return `S${enc(cond.left.name)}${enc(cond.op)}${rightTag(cond.right)}`;
|
|
547
|
-
case "correlatedSubquery": {
|
|
548
|
-
const id = astIDs.get(cond.related.subquery);
|
|
549
|
-
return id === void 0 ? void 0 : `E${id}:${enc(cond.op)}${tri(cond.flip)}${tri(cond.scalar)}`;
|
|
550
|
-
}
|
|
551
|
-
case "and":
|
|
552
|
-
case "or": {
|
|
553
|
-
let out = `${cond.type === "and" ? "A" : "O"}${cond.conditions.length}:`;
|
|
554
|
-
for (const c of cond.conditions) {
|
|
555
|
-
const k = condKey(c);
|
|
556
|
-
if (k === void 0) return;
|
|
557
|
-
out += k;
|
|
558
|
-
}
|
|
559
|
-
return out;
|
|
560
|
-
}
|
|
561
|
-
default: return;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
/**
|
|
565
|
-
* A coarse bucket key for the conditions {@linkcode condKey} cannot encode --
|
|
566
|
-
* a two-hop `exists`, whose junction AST is built inline and so has no identity
|
|
567
|
-
* of its own. Reads only the top of the tree, so it is cheap; the delta tells
|
|
568
|
-
* apart what shares it.
|
|
569
|
-
*/
|
|
570
|
-
function treeKey(cond) {
|
|
571
|
-
switch (cond.type) {
|
|
572
|
-
case "correlatedSubquery": return `where:e:${cond.related.subquery.alias}:${cond.op}`;
|
|
573
|
-
case "and":
|
|
574
|
-
case "or": return `where:${cond.type}:${cond.conditions.length}`;
|
|
575
|
-
default: return "where:*";
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
275
|
function throwQueryNotRunnable() {
|
|
579
276
|
throw new Error("Query is not runnable");
|
|
580
277
|
}
|