@rocicorp/zero 0.5.2024110200 → 0.6.2024111700
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/{internal.js → advanced.js} +2 -2
- package/out/{chunk-YCMA66NH.js → chunk-5UY46OAF.js} +5 -2
- package/out/{chunk-YCMA66NH.js.map → chunk-5UY46OAF.js.map} +2 -2
- package/out/{chunk-INJ4WJHS.js → chunk-PIFWXXO2.js} +1209 -586
- package/out/chunk-PIFWXXO2.js.map +7 -0
- package/out/react.js.map +2 -2
- package/out/shared/src/browser-env.d.ts +17 -0
- package/out/shared/src/browser-env.d.ts.map +1 -1
- package/out/shared/src/expand.d.ts +7 -0
- package/out/shared/src/expand.d.ts.map +1 -0
- package/out/solid.js +5 -5
- package/out/solid.js.map +2 -2
- package/out/zero-cache/src/auth/load-authorization.d.ts +3 -0
- package/out/zero-cache/src/auth/load-authorization.d.ts.map +1 -0
- package/out/zero-cache/src/auth/load-authorization.js +21 -0
- package/out/zero-cache/src/auth/load-authorization.js.map +1 -0
- package/out/zero-cache/src/config/config.d.ts +112 -0
- package/out/zero-cache/src/config/config.d.ts.map +1 -0
- package/out/zero-cache/src/config/config.js +246 -0
- package/out/zero-cache/src/config/config.js.map +1 -0
- package/out/zero-cache/src/config/zero-config.d.ts +145 -964
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +242 -115
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/db/delete-lite-db.d.ts +2 -0
- package/out/zero-cache/src/db/delete-lite-db.d.ts.map +1 -0
- package/out/zero-cache/src/db/delete-lite-db.js +7 -0
- package/out/zero-cache/src/db/delete-lite-db.js.map +1 -0
- package/out/zero-cache/src/db/migration.d.ts +1 -0
- package/out/zero-cache/src/db/migration.d.ts.map +1 -1
- package/out/zero-cache/src/db/migration.js +17 -7
- package/out/zero-cache/src/db/migration.js.map +1 -1
- package/out/zero-cache/src/db/pg-to-lite.d.ts +1 -1
- package/out/zero-cache/src/db/pg-to-lite.d.ts.map +1 -1
- package/out/zero-cache/src/db/pg-to-lite.js +7 -3
- package/out/zero-cache/src/db/pg-to-lite.js.map +1 -1
- package/out/zero-cache/src/db/short-lived-client.d.ts +16 -0
- package/out/zero-cache/src/db/short-lived-client.d.ts.map +1 -0
- package/out/zero-cache/src/db/short-lived-client.js +50 -0
- package/out/zero-cache/src/db/short-lived-client.js.map +1 -0
- package/out/zero-cache/src/db/specs.d.ts +12 -3
- package/out/zero-cache/src/db/specs.d.ts.map +1 -1
- package/out/zero-cache/src/db/specs.js +6 -1
- package/out/zero-cache/src/db/specs.js.map +1 -1
- package/out/zero-cache/src/db/transaction-pool.d.ts +8 -2
- package/out/zero-cache/src/db/transaction-pool.d.ts.map +1 -1
- package/out/zero-cache/src/db/transaction-pool.js +43 -9
- package/out/zero-cache/src/db/transaction-pool.js.map +1 -1
- package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
- package/out/zero-cache/src/server/change-streamer.js +34 -9
- package/out/zero-cache/src/server/change-streamer.js.map +1 -1
- package/out/zero-cache/src/server/life-cycle.d.ts +1 -1
- package/out/zero-cache/src/server/life-cycle.d.ts.map +1 -1
- package/out/zero-cache/src/server/life-cycle.js +2 -3
- package/out/zero-cache/src/server/life-cycle.js.map +1 -1
- package/out/zero-cache/src/server/logging.d.ts.map +1 -1
- package/out/zero-cache/src/server/logging.js +2 -15
- package/out/zero-cache/src/server/logging.js.map +1 -1
- package/out/zero-cache/src/server/main.js +28 -10
- package/out/zero-cache/src/server/main.js.map +1 -1
- package/out/zero-cache/src/server/replicator.d.ts.map +1 -1
- package/out/zero-cache/src/server/replicator.js +6 -5
- package/out/zero-cache/src/server/replicator.js.map +1 -1
- package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/server/syncer.js +16 -12
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +2 -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 +2 -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-service.d.ts +153 -2
- 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 +136 -19
- 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 +17 -9
- package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer.js +4 -2
- 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 +1 -0
- package/out/zero-cache/src/services/change-streamer/forwarder.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/forwarder.js +9 -2
- package/out/zero-cache/src/services/change-streamer/forwarder.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/change-source.d.ts +10 -0
- package/out/zero-cache/src/services/change-streamer/pg/change-source.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/change-source.js +171 -24
- package/out/zero-cache/src/services/change-streamer/pg/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/initial-sync.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/initial-sync.js +33 -19
- package/out/zero-cache/src/services/change-streamer/pg/initial-sync.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/schema/ddl.d.ts +62 -39
- package/out/zero-cache/src/services/change-streamer/pg/schema/ddl.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/schema/ddl.js +8 -40
- package/out/zero-cache/src/services/change-streamer/pg/schema/ddl.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/schema/init.d.ts +8 -0
- package/out/zero-cache/src/services/change-streamer/pg/schema/init.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/schema/init.js +41 -8
- package/out/zero-cache/src/services/change-streamer/pg/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/schema/published.d.ts +83 -13
- package/out/zero-cache/src/services/change-streamer/pg/schema/published.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/schema/published.js +15 -5
- package/out/zero-cache/src/services/change-streamer/pg/schema/published.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/schema/shard.d.ts +39 -3
- package/out/zero-cache/src/services/change-streamer/pg/schema/shard.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/schema/shard.js +67 -36
- package/out/zero-cache/src/services/change-streamer/pg/schema/shard.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/schema/validation.d.ts +8 -0
- package/out/zero-cache/src/services/change-streamer/pg/schema/validation.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-streamer/pg/schema/validation.js +33 -0
- package/out/zero-cache/src/services/change-streamer/pg/schema/validation.js.map +1 -0
- package/out/zero-cache/src/services/change-streamer/schema/change.d.ts +5 -1
- package/out/zero-cache/src/services/change-streamer/schema/change.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/change.js +3 -0
- package/out/zero-cache/src/services/change-streamer/schema/change.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/init.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/init.js +4 -6
- package/out/zero-cache/src/services/change-streamer/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/tables.d.ts +6 -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 -4
- package/out/zero-cache/src/services/change-streamer/schema/tables.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.d.ts +29 -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 +90 -8
- package/out/zero-cache/src/services/change-streamer/storer.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/subscriber.d.ts +1 -0
- package/out/zero-cache/src/services/change-streamer/subscriber.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/subscriber.js +18 -3
- package/out/zero-cache/src/services/change-streamer/subscriber.js.map +1 -1
- package/out/zero-cache/src/services/dispatcher/dispatcher.d.ts +5 -3
- package/out/zero-cache/src/services/dispatcher/dispatcher.d.ts.map +1 -1
- package/out/zero-cache/src/services/dispatcher/dispatcher.js +20 -5
- package/out/zero-cache/src/services/dispatcher/dispatcher.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts +6 -5
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js +26 -20
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/write-authorizer.d.ts +7 -6
- package/out/zero-cache/src/services/mutagen/write-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/write-authorizer.js +10 -18
- package/out/zero-cache/src/services/mutagen/write-authorizer.js.map +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.d.ts +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.js +8 -8
- package/out/zero-cache/src/services/replicator/incremental-sync.js.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/replication-state.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/replication-state.js +1 -10
- package/out/zero-cache/src/services/replicator/schema/replication-state.js.map +1 -1
- package/out/zero-cache/src/services/running-state.d.ts +6 -1
- package/out/zero-cache/src/services/running-state.d.ts.map +1 -1
- package/out/zero-cache/src/services/running-state.js +23 -5
- package/out/zero-cache/src/services/running-state.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/types.d.ts +49 -29
- package/out/zero-cache/src/services/view-syncer/schema/types.d.ts.map +1 -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 +2 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/lexi-version.d.ts +3 -2
- package/out/zero-cache/src/types/lexi-version.d.ts.map +1 -1
- package/out/zero-cache/src/types/lexi-version.js +8 -6
- package/out/zero-cache/src/types/lexi-version.js.map +1 -1
- package/out/zero-cache/src/types/processes.d.ts.map +1 -1
- package/out/zero-cache/src/types/processes.js +1 -0
- package/out/zero-cache/src/types/processes.js.map +1 -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.js +1 -1
- package/out/zero-cache/src/workers/syncer.js.map +1 -1
- package/out/zero-client/src/client/crud.d.ts +56 -25
- package/out/zero-client/src/client/crud.d.ts.map +1 -1
- package/out/zero-client/src/client/http-string.d.ts +1 -0
- package/out/zero-client/src/client/http-string.d.ts.map +1 -1
- package/out/zero-client/src/client/log-options.d.ts +2 -1
- package/out/zero-client/src/client/log-options.d.ts.map +1 -1
- package/out/zero-client/src/client/options.d.ts +8 -8
- package/out/zero-client/src/client/options.d.ts.map +1 -1
- package/out/zero-client/src/client/protocol-version.d.ts +2 -0
- package/out/zero-client/src/client/protocol-version.d.ts.map +1 -0
- package/out/zero-client/src/client/server-option.d.ts.map +1 -1
- package/out/zero-client/src/client/zero-poke-handler.d.ts +1 -1
- package/out/zero-client/src/client/zero-poke-handler.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.d.ts +26 -14
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/mod.d.ts +4 -2
- package/out/zero-client/src/mod.d.ts.map +1 -1
- package/out/zero-protocol/src/ast.d.ts +37 -21
- package/out/zero-protocol/src/ast.d.ts.map +1 -1
- package/out/zero-protocol/src/ast.js +21 -6
- package/out/zero-protocol/src/ast.js.map +1 -1
- package/out/zero-protocol/src/change-desired-queries.d.ts +16 -8
- package/out/zero-protocol/src/change-desired-queries.d.ts.map +1 -1
- package/out/zero-protocol/src/connect.d.ts +16 -8
- package/out/zero-protocol/src/connect.d.ts.map +1 -1
- package/out/zero-protocol/src/down.d.ts +16 -8
- package/out/zero-protocol/src/down.d.ts.map +1 -1
- package/out/zero-protocol/src/poke.d.ts +32 -16
- package/out/zero-protocol/src/poke.d.ts.map +1 -1
- package/out/zero-protocol/src/push.d.ts +18 -18
- package/out/zero-protocol/src/push.d.ts.map +1 -1
- package/out/zero-protocol/src/push.js +5 -5
- package/out/zero-protocol/src/push.js.map +1 -1
- package/out/zero-protocol/src/queries-patch.d.ts +24 -12
- package/out/zero-protocol/src/queries-patch.d.ts.map +1 -1
- package/out/zero-protocol/src/up.d.ts +18 -10
- package/out/zero-protocol/src/up.d.ts.map +1 -1
- package/out/zero-react/src/use-zero.d.ts.map +1 -1
- package/out/zero-schema/src/authorization.d.ts +25 -0
- package/out/zero-schema/src/authorization.d.ts.map +1 -0
- package/out/zero-schema/src/compiled-authorization.d.ts +379 -0
- package/out/zero-schema/src/compiled-authorization.d.ts.map +1 -0
- package/out/zero-schema/src/compiled-authorization.js +15 -0
- package/out/zero-schema/src/compiled-authorization.js.map +1 -0
- package/out/zero-schema/src/mod.d.ts +1 -0
- package/out/zero-schema/src/mod.d.ts.map +1 -1
- package/out/{zero-client/src/client → zero-schema/src}/normalized-schema.d.ts +2 -2
- package/out/zero-schema/src/normalized-schema.d.ts.map +1 -0
- package/out/zero-schema/src/table-schema.d.ts +15 -7
- package/out/zero-schema/src/table-schema.d.ts.map +1 -1
- package/out/zero-schema/src/table-schema.js.map +1 -1
- package/out/zero.js +10 -14
- package/out/zql/src/builder/builder.d.ts +1 -1
- package/out/zql/src/builder/builder.d.ts.map +1 -1
- package/out/zql/src/builder/builder.js +136 -30
- package/out/zql/src/builder/builder.js.map +1 -1
- package/out/zql/src/builder/filter.d.ts +2 -1
- package/out/zql/src/builder/filter.d.ts.map +1 -1
- package/out/zql/src/builder/filter.js +18 -0
- package/out/zql/src/builder/filter.js.map +1 -1
- package/out/zql/src/builder/like.d.ts +2 -2
- package/out/zql/src/builder/like.d.ts.map +1 -1
- package/out/zql/src/ivm/change.d.ts +1 -0
- package/out/zql/src/ivm/change.d.ts.map +1 -1
- package/out/zql/src/ivm/change.js +4 -1
- package/out/zql/src/ivm/change.js.map +1 -1
- package/out/zql/src/ivm/exists.d.ts +18 -0
- package/out/zql/src/ivm/exists.d.ts.map +1 -0
- package/out/zql/src/ivm/exists.js +186 -0
- package/out/zql/src/ivm/exists.js.map +1 -0
- package/out/zql/src/ivm/fan-in.d.ts +1 -1
- package/out/zql/src/ivm/fan-in.d.ts.map +1 -1
- package/out/zql/src/ivm/fan-in.js +3 -3
- package/out/zql/src/ivm/fan-in.js.map +1 -1
- package/out/zql/src/ivm/fan-out.d.ts.map +1 -1
- package/out/zql/src/ivm/fan-out.js +4 -7
- package/out/zql/src/ivm/fan-out.js.map +1 -1
- package/out/zql/src/ivm/filter.js +1 -1
- package/out/zql/src/ivm/filter.js.map +1 -1
- package/out/zql/src/ivm/memory-source.d.ts +10 -6
- package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
- package/out/zql/src/ivm/memory-source.js +60 -75
- package/out/zql/src/ivm/memory-source.js.map +1 -1
- package/out/zql/src/ivm/skip.js +1 -1
- package/out/zql/src/ivm/skip.js.map +1 -1
- package/out/zql/src/ivm/take.d.ts +1 -1
- package/out/zql/src/ivm/take.d.ts.map +1 -1
- package/out/zql/src/ivm/take.js +11 -7
- package/out/zql/src/ivm/take.js.map +1 -1
- package/out/zql/src/ivm/view-apply-change.d.ts.map +1 -1
- package/out/zql/src/query/auth-query.d.ts +7 -3
- package/out/zql/src/query/auth-query.d.ts.map +1 -1
- package/out/zql/src/query/dnf.d.ts +10 -0
- package/out/zql/src/query/dnf.d.ts.map +1 -0
- package/out/zql/src/query/expression.d.ts +40 -23
- package/out/zql/src/query/expression.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.d.ts +7 -6
- package/out/zql/src/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/query/query.d.ts +17 -46
- package/out/zql/src/query/query.d.ts.map +1 -1
- package/out/zqlite/src/db.d.ts.map +1 -1
- package/out/zqlite/src/db.js +19 -6
- package/out/zqlite/src/db.js.map +1 -1
- package/out/zqlite/src/table-source.d.ts +12 -3
- package/out/zqlite/src/table-source.d.ts.map +1 -1
- package/out/zqlite/src/table-source.js +81 -2
- package/out/zqlite/src/table-source.js.map +1 -1
- package/package.json +7 -11
- package/out/chunk-INJ4WJHS.js.map +0 -7
- package/out/datadog/src/datadog-log-sink.js +0 -231
- package/out/datadog/src/datadog-log-sink.js.map +0 -1
- package/out/datadog/src/mod.js +0 -2
- package/out/datadog/src/mod.js.map +0 -1
- package/out/shared/src/immutable.js +0 -2
- package/out/shared/src/immutable.js.map +0 -1
- package/out/shared/src/sorted-entries.js +0 -6
- package/out/shared/src/sorted-entries.js.map +0 -1
- package/out/shared/src/writable.js +0 -2
- package/out/shared/src/writable.js.map +0 -1
- package/out/zero/src/config.d.ts +0 -2
- package/out/zero/src/config.d.ts.map +0 -1
- package/out/zero/src/config.js +0 -2
- package/out/zero/src/config.js.map +0 -1
- package/out/zero-cache/src/config/config-query.d.ts +0 -19
- package/out/zero-cache/src/config/config-query.d.ts.map +0 -1
- package/out/zero-cache/src/config/config-query.js +0 -22
- package/out/zero-cache/src/config/config-query.js.map +0 -1
- package/out/zero-cache/src/config/define-config.d.ts +0 -43
- package/out/zero-cache/src/config/define-config.d.ts.map +0 -1
- package/out/zero-cache/src/config/define-config.js +0 -121
- package/out/zero-cache/src/config/define-config.js.map +0 -1
- package/out/zero-cache/src/config/refs.d.ts +0 -3
- package/out/zero-cache/src/config/refs.d.ts.map +0 -1
- package/out/zero-cache/src/config/refs.js +0 -14
- package/out/zero-cache/src/config/refs.js.map +0 -1
- package/out/zero-client/src/client/normalized-schema.d.ts.map +0 -1
- package/out/zero-client/src/client/normalized-schema.js +0 -31
- package/out/zero-client/src/client/normalized-schema.js.map +0 -1
- package/out/zero-protocol/src/ast-hash.js +0 -14
- package/out/zero-protocol/src/ast-hash.js.map +0 -1
- package/out/zero-schema/src/mod.js +0 -4
- package/out/zero-schema/src/mod.js.map +0 -1
- package/out/zero-schema/src/normalize-table-schema.js +0 -116
- package/out/zero-schema/src/normalize-table-schema.js.map +0 -1
- package/out/zero-schema/src/schema.js +0 -4
- package/out/zero-schema/src/schema.js.map +0 -1
- package/out/zql/src/ivm/array-view.js +0 -70
- package/out/zql/src/ivm/array-view.js.map +0 -1
- package/out/zql/src/ivm/view-apply-change.js +0 -156
- package/out/zql/src/ivm/view-apply-change.js.map +0 -1
- package/out/zql/src/ivm/view.js +0 -2
- package/out/zql/src/ivm/view.js.map +0 -1
- package/out/zql/src/query/auth-query.js +0 -26
- package/out/zql/src/query/auth-query.js.map +0 -1
- package/out/zql/src/query/expression.js +0 -121
- package/out/zql/src/query/expression.js.map +0 -1
- package/out/zql/src/query/query-impl.js +0 -291
- package/out/zql/src/query/query-impl.js.map +0 -1
- package/out/zql/src/query/query-internal.js +0 -2
- package/out/zql/src/query/query-internal.js.map +0 -1
- package/out/zql/src/query/query.js +0 -3
- package/out/zql/src/query/query.js.map +0 -1
- package/out/zql/src/query/typed-view.js +0 -2
- package/out/zql/src/query/typed-view.js.map +0 -1
- /package/out/{internal.js.map → advanced.js.map} +0 -0
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
must,
|
|
15
15
|
throwInvalidType,
|
|
16
16
|
unreachable
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-5UY46OAF.js";
|
|
18
18
|
import {
|
|
19
19
|
__export,
|
|
20
20
|
__reExport
|
|
@@ -564,6 +564,9 @@ var WriteImplBase = class {
|
|
|
564
564
|
function getBrowserGlobal(name) {
|
|
565
565
|
return globalThis[name];
|
|
566
566
|
}
|
|
567
|
+
function getBrowserGlobalMethod(name) {
|
|
568
|
+
return globalThis[name]?.bind(globalThis);
|
|
569
|
+
}
|
|
567
570
|
function mustGetBrowserGlobal(name) {
|
|
568
571
|
const r = getBrowserGlobal(name);
|
|
569
572
|
if (r === void 0) {
|
|
@@ -9236,121 +9239,186 @@ function getKVStoreProvider(lc, kvStore) {
|
|
|
9236
9239
|
// ../replicache/src/mod.ts
|
|
9237
9240
|
import { consoleLogSink as consoleLogSink3 } from "@rocicorp/logger";
|
|
9238
9241
|
|
|
9239
|
-
// ../
|
|
9240
|
-
function
|
|
9241
|
-
|
|
9242
|
-
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
|
|
9242
|
+
// ../zero-schema/src/table-schema.ts
|
|
9243
|
+
function createTableSchema(schema) {
|
|
9244
|
+
return schema;
|
|
9245
|
+
}
|
|
9246
|
+
function isFieldRelationship(relationship) {
|
|
9247
|
+
return relationship.junction === void 0;
|
|
9248
|
+
}
|
|
9249
|
+
function isJunctionRelationship(relationship) {
|
|
9250
|
+
return !isFieldRelationship(relationship);
|
|
9251
|
+
}
|
|
9252
|
+
|
|
9253
|
+
// ../shared/src/sorted-entries.ts
|
|
9254
|
+
function sortedEntries(object16) {
|
|
9255
|
+
return Object.entries(object16).sort((a, b) => stringCompare(a[0], b[0]));
|
|
9256
|
+
}
|
|
9257
|
+
|
|
9258
|
+
// ../zero-schema/src/normalize-table-schema.ts
|
|
9259
|
+
var NormalizedTableSchema = class {
|
|
9260
|
+
tableName;
|
|
9261
|
+
primaryKey;
|
|
9262
|
+
columns;
|
|
9263
|
+
relationships;
|
|
9264
|
+
constructor(tableSchema, tableSchemaCache) {
|
|
9265
|
+
this.tableName = tableSchema.tableName;
|
|
9266
|
+
const primaryKey = normalizePrimaryKey(tableSchema.primaryKey);
|
|
9267
|
+
this.primaryKey = primaryKey;
|
|
9268
|
+
this.columns = normalizeColumns(tableSchema.columns, primaryKey);
|
|
9269
|
+
tableSchemaCache.set(tableSchema, this);
|
|
9270
|
+
this.relationships = normalizeRelationships(
|
|
9271
|
+
tableSchema.relationships,
|
|
9272
|
+
tableSchemaCache
|
|
9273
|
+
);
|
|
9247
9274
|
}
|
|
9248
|
-
|
|
9249
|
-
|
|
9250
|
-
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9275
|
+
};
|
|
9276
|
+
function normalizeTableSchema(tableSchema) {
|
|
9277
|
+
return normalizeTableSchemaWithCache(
|
|
9278
|
+
tableSchema,
|
|
9279
|
+
tableSchema.tableName,
|
|
9280
|
+
/* @__PURE__ */ new Map()
|
|
9281
|
+
);
|
|
9254
9282
|
}
|
|
9255
|
-
function
|
|
9256
|
-
if (
|
|
9257
|
-
return
|
|
9283
|
+
function normalizeTableSchemaWithCache(tableSchema, expectedName, tableSchemaCache) {
|
|
9284
|
+
if (tableSchema instanceof NormalizedTableSchema) {
|
|
9285
|
+
return tableSchema;
|
|
9258
9286
|
}
|
|
9259
|
-
|
|
9260
|
-
|
|
9261
|
-
|
|
9262
|
-
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
return
|
|
9266
|
-
}
|
|
9267
|
-
|
|
9268
|
-
|
|
9287
|
+
assert(
|
|
9288
|
+
tableSchema.tableName === expectedName,
|
|
9289
|
+
`Table name mismatch: "${tableSchema.tableName}" !== "${expectedName}"`
|
|
9290
|
+
);
|
|
9291
|
+
let normalizedTableSchema = tableSchemaCache.get(tableSchema);
|
|
9292
|
+
if (normalizedTableSchema) {
|
|
9293
|
+
return normalizedTableSchema;
|
|
9294
|
+
}
|
|
9295
|
+
normalizedTableSchema = new NormalizedTableSchema(
|
|
9296
|
+
tableSchema,
|
|
9297
|
+
tableSchemaCache
|
|
9269
9298
|
);
|
|
9270
|
-
|
|
9271
|
-
|
|
9299
|
+
return normalizedTableSchema;
|
|
9300
|
+
}
|
|
9301
|
+
function isSorted(arr) {
|
|
9302
|
+
for (let i = 1; i < arr.length; i++) {
|
|
9303
|
+
if (arr[i - 1] >= arr[i]) {
|
|
9304
|
+
return false;
|
|
9305
|
+
}
|
|
9306
|
+
}
|
|
9307
|
+
return true;
|
|
9308
|
+
}
|
|
9309
|
+
function assertNoDuplicates(arr) {
|
|
9310
|
+
for (let i = 1; i < arr.length; i++) {
|
|
9311
|
+
assert(arr[i - 1] !== arr[i], "Primary key must not contain duplicates");
|
|
9312
|
+
}
|
|
9313
|
+
}
|
|
9314
|
+
function normalizePrimaryKey(arr) {
|
|
9315
|
+
if (isSorted(arr)) {
|
|
9316
|
+
return arr;
|
|
9317
|
+
}
|
|
9318
|
+
arr = [...arr].sort();
|
|
9319
|
+
assertNoDuplicates(arr);
|
|
9320
|
+
return arr;
|
|
9321
|
+
}
|
|
9322
|
+
function normalizeColumns(columns, primaryKey) {
|
|
9323
|
+
const rv = {};
|
|
9324
|
+
for (const pk of primaryKey) {
|
|
9325
|
+
const schemaValue = columns[pk];
|
|
9326
|
+
assert(schemaValue, `Primary key column "${pk}" not found`);
|
|
9327
|
+
const { type, optional } = schemaValue;
|
|
9328
|
+
assert(!optional, `Primary key column "${pk}" cannot be optional`);
|
|
9329
|
+
assert(
|
|
9330
|
+
type === "string" || type === "number" || type === "boolean",
|
|
9331
|
+
`Primary key column "${pk}" must be a string, number, or boolean. Got ${type}`
|
|
9332
|
+
);
|
|
9272
9333
|
}
|
|
9273
|
-
const
|
|
9274
|
-
|
|
9334
|
+
for (const [name, column] of sortedEntries(columns)) {
|
|
9335
|
+
rv[name] = normalizeSchemaValue(column);
|
|
9336
|
+
}
|
|
9337
|
+
return rv;
|
|
9338
|
+
}
|
|
9339
|
+
function normalizeSchemaValue(value) {
|
|
9275
9340
|
return {
|
|
9276
|
-
type:
|
|
9277
|
-
|
|
9278
|
-
type: "and",
|
|
9279
|
-
conditions: [
|
|
9280
|
-
...part.type === "and" ? part.conditions : [part],
|
|
9281
|
-
...flatAnds.conditions
|
|
9282
|
-
]
|
|
9283
|
-
}))
|
|
9341
|
+
type: value.type,
|
|
9342
|
+
optional: value.optional ?? false
|
|
9284
9343
|
};
|
|
9285
9344
|
}
|
|
9286
|
-
function
|
|
9287
|
-
|
|
9288
|
-
|
|
9345
|
+
function normalizeRelationships(relationships, tableSchemaCache) {
|
|
9346
|
+
const rv = {};
|
|
9347
|
+
for (const [name, relationship] of sortedEntries(relationships)) {
|
|
9348
|
+
rv[name] = normalizeRelationship(relationship, tableSchemaCache);
|
|
9289
9349
|
}
|
|
9290
|
-
return
|
|
9350
|
+
return rv;
|
|
9291
9351
|
}
|
|
9292
|
-
function
|
|
9293
|
-
|
|
9294
|
-
|
|
9295
|
-
return {
|
|
9296
|
-
type: "or",
|
|
9297
|
-
conditions: expr.conditions.map(not)
|
|
9298
|
-
};
|
|
9299
|
-
case "or":
|
|
9300
|
-
return {
|
|
9301
|
-
type: "and",
|
|
9302
|
-
conditions: expr.conditions.map(not)
|
|
9303
|
-
};
|
|
9304
|
-
default:
|
|
9305
|
-
return {
|
|
9306
|
-
type: "simple",
|
|
9307
|
-
op: negateOperator(expr.op),
|
|
9308
|
-
field: expr.field,
|
|
9309
|
-
value: expr.value
|
|
9310
|
-
};
|
|
9352
|
+
function normalizeRelationship(relationship, tableSchemaCache) {
|
|
9353
|
+
if (isFieldRelationship(relationship)) {
|
|
9354
|
+
return normalizeFieldRelationship(relationship, tableSchemaCache);
|
|
9311
9355
|
}
|
|
9356
|
+
return normalizeJunctionRelationship(relationship, tableSchemaCache);
|
|
9312
9357
|
}
|
|
9313
|
-
function
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
|
|
9358
|
+
function normalizeFieldRelationship(relationship, tableSchemaCache) {
|
|
9359
|
+
return {
|
|
9360
|
+
source: relationship.source,
|
|
9361
|
+
dest: {
|
|
9362
|
+
field: relationship.dest.field,
|
|
9363
|
+
schema: normalizeLazyTableSchema(
|
|
9364
|
+
relationship.dest.schema,
|
|
9365
|
+
tableSchemaCache
|
|
9366
|
+
)
|
|
9320
9367
|
}
|
|
9321
|
-
}
|
|
9368
|
+
};
|
|
9369
|
+
}
|
|
9370
|
+
function normalizeJunctionRelationship(relationship, tableSchemaCache) {
|
|
9322
9371
|
return {
|
|
9323
|
-
|
|
9324
|
-
|
|
9372
|
+
source: relationship.source,
|
|
9373
|
+
junction: {
|
|
9374
|
+
sourceField: relationship.junction.sourceField,
|
|
9375
|
+
destField: relationship.junction.destField,
|
|
9376
|
+
schema: normalizeLazyTableSchema(
|
|
9377
|
+
relationship.junction.schema,
|
|
9378
|
+
tableSchemaCache
|
|
9379
|
+
)
|
|
9380
|
+
},
|
|
9381
|
+
dest: {
|
|
9382
|
+
field: relationship.dest.field,
|
|
9383
|
+
schema: normalizeLazyTableSchema(
|
|
9384
|
+
relationship.dest.schema,
|
|
9385
|
+
tableSchemaCache
|
|
9386
|
+
)
|
|
9387
|
+
}
|
|
9325
9388
|
};
|
|
9326
9389
|
}
|
|
9327
|
-
function
|
|
9328
|
-
|
|
9329
|
-
|
|
9330
|
-
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
|
|
9335
|
-
|
|
9336
|
-
|
|
9337
|
-
|
|
9338
|
-
|
|
9339
|
-
|
|
9340
|
-
|
|
9341
|
-
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
|
|
9345
|
-
|
|
9346
|
-
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
|
|
9352
|
-
|
|
9390
|
+
function normalizeLazyTableSchema(tableSchema, buildCache) {
|
|
9391
|
+
const tableSchemaInstance = typeof tableSchema === "function" ? tableSchema() : tableSchema;
|
|
9392
|
+
return normalizeTableSchemaWithCache(
|
|
9393
|
+
tableSchemaInstance,
|
|
9394
|
+
tableSchemaInstance.tableName,
|
|
9395
|
+
// Don't care about name here.
|
|
9396
|
+
buildCache
|
|
9397
|
+
);
|
|
9398
|
+
}
|
|
9399
|
+
|
|
9400
|
+
// ../zero-schema/src/normalized-schema.ts
|
|
9401
|
+
function normalizeSchema(schema) {
|
|
9402
|
+
if (schema instanceof NormalizedSchema) {
|
|
9403
|
+
return schema;
|
|
9404
|
+
}
|
|
9405
|
+
return new NormalizedSchema(schema);
|
|
9406
|
+
}
|
|
9407
|
+
var NormalizedSchema = class {
|
|
9408
|
+
version;
|
|
9409
|
+
tables;
|
|
9410
|
+
constructor(schema) {
|
|
9411
|
+
this.version = schema.version;
|
|
9412
|
+
this.tables = normalizeTables(schema.tables);
|
|
9413
|
+
}
|
|
9414
|
+
};
|
|
9415
|
+
function normalizeTables(tables) {
|
|
9416
|
+
const rv = {};
|
|
9417
|
+
const tableSchemaCache = /* @__PURE__ */ new Map();
|
|
9418
|
+
for (const [name, table] of sortedEntries(tables)) {
|
|
9419
|
+
rv[name] = normalizeTableSchemaWithCache(table, name, tableSchemaCache);
|
|
9353
9420
|
}
|
|
9421
|
+
return rv;
|
|
9354
9422
|
}
|
|
9355
9423
|
|
|
9356
9424
|
// ../zql/src/query/query-impl.ts
|
|
@@ -9395,7 +9463,12 @@ var primitiveSchema = valita_exports.union(
|
|
|
9395
9463
|
valita_exports.boolean(),
|
|
9396
9464
|
valita_exports.null()
|
|
9397
9465
|
);
|
|
9398
|
-
var equalityOpsSchema = valita_exports.union(
|
|
9466
|
+
var equalityOpsSchema = valita_exports.union(
|
|
9467
|
+
valita_exports.literal("="),
|
|
9468
|
+
valita_exports.literal("!="),
|
|
9469
|
+
valita_exports.literal("IS"),
|
|
9470
|
+
valita_exports.literal("IS NOT")
|
|
9471
|
+
);
|
|
9399
9472
|
var orderOpsSchema = valita_exports.union(
|
|
9400
9473
|
valita_exports.literal("<"),
|
|
9401
9474
|
valita_exports.literal(">"),
|
|
@@ -9423,6 +9496,7 @@ var simpleConditionSchema = valita_exports.object({
|
|
|
9423
9496
|
valita_exports.string(),
|
|
9424
9497
|
valita_exports.number(),
|
|
9425
9498
|
valita_exports.boolean(),
|
|
9499
|
+
valita_exports.null(),
|
|
9426
9500
|
readonlyArray(valita_exports.union(valita_exports.string(), valita_exports.number(), valita_exports.boolean())),
|
|
9427
9501
|
valita_exports.object({
|
|
9428
9502
|
type: valita_exports.literal("static"),
|
|
@@ -9431,10 +9505,20 @@ var simpleConditionSchema = valita_exports.object({
|
|
|
9431
9505
|
})
|
|
9432
9506
|
)
|
|
9433
9507
|
});
|
|
9508
|
+
var correlatedSubqueryConditionOperatorSchema = valita_exports.union(
|
|
9509
|
+
valita_exports.literal("EXISTS"),
|
|
9510
|
+
valita_exports.literal("NOT EXISTS")
|
|
9511
|
+
);
|
|
9512
|
+
var correlatedSubqueryConditionSchema = readonlyObject({
|
|
9513
|
+
type: valita_exports.literal("correlatedSubquery"),
|
|
9514
|
+
related: valita_exports.lazy(() => correlatedSubquerySchema),
|
|
9515
|
+
op: correlatedSubqueryConditionOperatorSchema
|
|
9516
|
+
});
|
|
9434
9517
|
var conditionSchema = valita_exports.union(
|
|
9435
9518
|
simpleConditionSchema,
|
|
9436
9519
|
valita_exports.lazy(() => conjunctionSchema),
|
|
9437
|
-
valita_exports.lazy(() => disjunctionSchema)
|
|
9520
|
+
valita_exports.lazy(() => disjunctionSchema),
|
|
9521
|
+
correlatedSubqueryConditionSchema
|
|
9438
9522
|
);
|
|
9439
9523
|
var conjunctionSchema = readonlyObject({
|
|
9440
9524
|
type: valita_exports.literal("and"),
|
|
@@ -9501,7 +9585,7 @@ function normalizeAST(ast) {
|
|
|
9501
9585
|
return normalized;
|
|
9502
9586
|
}
|
|
9503
9587
|
function sortedWhere(where) {
|
|
9504
|
-
if (where.type === "simple") {
|
|
9588
|
+
if (where.type === "simple" || where.type === "correlatedSubquery") {
|
|
9505
9589
|
return where;
|
|
9506
9590
|
}
|
|
9507
9591
|
return {
|
|
@@ -9525,6 +9609,15 @@ function cmpCondition(a, b) {
|
|
|
9525
9609
|
if (b.type === "simple") {
|
|
9526
9610
|
return 1;
|
|
9527
9611
|
}
|
|
9612
|
+
if (a.type === "correlatedSubquery") {
|
|
9613
|
+
if (b.type !== "correlatedSubquery") {
|
|
9614
|
+
return -1;
|
|
9615
|
+
}
|
|
9616
|
+
return cmpRelated(a.related, b.related) || compareUTF8MaybeNull(a.op, b.op);
|
|
9617
|
+
}
|
|
9618
|
+
if (b.type === "correlatedSubquery") {
|
|
9619
|
+
return -1;
|
|
9620
|
+
}
|
|
9528
9621
|
const val = compareUTF8MaybeNull(a.type, b.type);
|
|
9529
9622
|
if (val !== 0) {
|
|
9530
9623
|
return val;
|
|
@@ -9544,7 +9637,7 @@ function flattened(cond) {
|
|
|
9544
9637
|
if (cond === void 0) {
|
|
9545
9638
|
return void 0;
|
|
9546
9639
|
}
|
|
9547
|
-
if (cond.type === "simple") {
|
|
9640
|
+
if (cond.type === "simple" || cond.type === "correlatedSubquery") {
|
|
9548
9641
|
return cond;
|
|
9549
9642
|
}
|
|
9550
9643
|
const conditions = defined(
|
|
@@ -9590,31 +9683,275 @@ function hashOfAST(ast) {
|
|
|
9590
9683
|
return hash;
|
|
9591
9684
|
}
|
|
9592
9685
|
|
|
9593
|
-
// ../zql/src/ivm/
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
}
|
|
9686
|
+
// ../zql/src/ivm/change.ts
|
|
9687
|
+
function rowForChange(change) {
|
|
9688
|
+
const { type } = change;
|
|
9689
|
+
return type === "add" || type === "remove" ? change.node.row : change.row;
|
|
9690
|
+
}
|
|
9691
|
+
|
|
9692
|
+
// ../zql/src/ivm/data.ts
|
|
9693
|
+
import { compareUTF8 as compareUTF84 } from "compare-utf8";
|
|
9694
|
+
function compareValues(a, b) {
|
|
9695
|
+
a = normalizeUndefined(a);
|
|
9696
|
+
b = normalizeUndefined(b);
|
|
9697
|
+
if (a === b) {
|
|
9698
|
+
return 0;
|
|
9607
9699
|
}
|
|
9608
|
-
|
|
9609
|
-
|
|
9700
|
+
if (a === null) {
|
|
9701
|
+
return -1;
|
|
9610
9702
|
}
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
input.destroy();
|
|
9614
|
-
}
|
|
9703
|
+
if (b === null) {
|
|
9704
|
+
return 1;
|
|
9615
9705
|
}
|
|
9616
|
-
|
|
9617
|
-
|
|
9706
|
+
if (typeof a === "boolean") {
|
|
9707
|
+
assertBoolean(b);
|
|
9708
|
+
return a ? 1 : -1;
|
|
9709
|
+
}
|
|
9710
|
+
if (typeof a === "number") {
|
|
9711
|
+
assertNumber(b);
|
|
9712
|
+
return a - b;
|
|
9713
|
+
}
|
|
9714
|
+
if (typeof a === "string") {
|
|
9715
|
+
assertString(b);
|
|
9716
|
+
return compareUTF84(a, b);
|
|
9717
|
+
}
|
|
9718
|
+
throw new Error(`Unsupported type: ${a}`);
|
|
9719
|
+
}
|
|
9720
|
+
function normalizeUndefined(v2) {
|
|
9721
|
+
return v2 ?? null;
|
|
9722
|
+
}
|
|
9723
|
+
function makeComparator(order) {
|
|
9724
|
+
return (a, b) => {
|
|
9725
|
+
for (const ord of order) {
|
|
9726
|
+
const field = ord[0];
|
|
9727
|
+
const comp = compareValues(a[field], b[field]);
|
|
9728
|
+
if (comp !== 0) {
|
|
9729
|
+
return ord[1] === "asc" ? comp : -comp;
|
|
9730
|
+
}
|
|
9731
|
+
}
|
|
9732
|
+
return 0;
|
|
9733
|
+
};
|
|
9734
|
+
}
|
|
9735
|
+
function valuesEqual(a, b) {
|
|
9736
|
+
a = normalizeUndefined(a);
|
|
9737
|
+
b = normalizeUndefined(b);
|
|
9738
|
+
if (a === null || b === null) {
|
|
9739
|
+
return false;
|
|
9740
|
+
}
|
|
9741
|
+
return a === b;
|
|
9742
|
+
}
|
|
9743
|
+
|
|
9744
|
+
// ../zql/src/ivm/stream.ts
|
|
9745
|
+
function* take(stream, limit) {
|
|
9746
|
+
if (limit < 1) {
|
|
9747
|
+
return;
|
|
9748
|
+
}
|
|
9749
|
+
let count = 0;
|
|
9750
|
+
for (const v2 of stream) {
|
|
9751
|
+
yield v2;
|
|
9752
|
+
if (++count === limit) {
|
|
9753
|
+
break;
|
|
9754
|
+
}
|
|
9755
|
+
}
|
|
9756
|
+
}
|
|
9757
|
+
function first(stream) {
|
|
9758
|
+
const it = stream[Symbol.iterator]();
|
|
9759
|
+
const { value } = it.next();
|
|
9760
|
+
it.return?.();
|
|
9761
|
+
return value;
|
|
9762
|
+
}
|
|
9763
|
+
|
|
9764
|
+
// ../zql/src/ivm/exists.ts
|
|
9765
|
+
var Exists = class {
|
|
9766
|
+
#input;
|
|
9767
|
+
#relationshipName;
|
|
9768
|
+
#storage;
|
|
9769
|
+
#not;
|
|
9770
|
+
#output;
|
|
9771
|
+
constructor(input, storage, relationshipName, type) {
|
|
9772
|
+
this.#input = input;
|
|
9773
|
+
this.#relationshipName = relationshipName;
|
|
9774
|
+
this.#input.setOutput(this);
|
|
9775
|
+
this.#storage = storage;
|
|
9776
|
+
assert(this.#input.getSchema().relationships[relationshipName]);
|
|
9777
|
+
this.#not = type === "NOT EXISTS";
|
|
9778
|
+
}
|
|
9779
|
+
setOutput(output) {
|
|
9780
|
+
this.#output = output;
|
|
9781
|
+
}
|
|
9782
|
+
destroy() {
|
|
9783
|
+
this.#input.destroy();
|
|
9784
|
+
}
|
|
9785
|
+
getSchema() {
|
|
9786
|
+
return this.#input.getSchema();
|
|
9787
|
+
}
|
|
9788
|
+
*fetch(req) {
|
|
9789
|
+
for (const node of this.#input.fetch(req)) {
|
|
9790
|
+
if (this.#filter(node.row)) {
|
|
9791
|
+
yield node;
|
|
9792
|
+
}
|
|
9793
|
+
}
|
|
9794
|
+
}
|
|
9795
|
+
*cleanup(req) {
|
|
9796
|
+
for (const node of this.#input.cleanup(req)) {
|
|
9797
|
+
if (this.#filter(node.row)) {
|
|
9798
|
+
yield node;
|
|
9799
|
+
}
|
|
9800
|
+
this.#delSize(node.row);
|
|
9801
|
+
}
|
|
9802
|
+
}
|
|
9803
|
+
push(change) {
|
|
9804
|
+
assert(this.#output, "Output not set");
|
|
9805
|
+
switch (change.type) {
|
|
9806
|
+
case "add":
|
|
9807
|
+
case "edit": {
|
|
9808
|
+
this.#pushWithFilter(change);
|
|
9809
|
+
return;
|
|
9810
|
+
}
|
|
9811
|
+
case "remove": {
|
|
9812
|
+
this.#pushWithFilter(change);
|
|
9813
|
+
this.#delSize(change.node.row);
|
|
9814
|
+
return;
|
|
9815
|
+
}
|
|
9816
|
+
case "child":
|
|
9817
|
+
if (change.child.relationshipName !== this.#relationshipName || change.child.change.type === "edit" || change.child.change.type === "child") {
|
|
9818
|
+
this.#pushWithFilter(change);
|
|
9819
|
+
return;
|
|
9820
|
+
}
|
|
9821
|
+
switch (change.child.change.type) {
|
|
9822
|
+
case "add": {
|
|
9823
|
+
let size = this.#getSize(change.row);
|
|
9824
|
+
if (size !== void 0) {
|
|
9825
|
+
size++;
|
|
9826
|
+
this.#setSize(change.row, size);
|
|
9827
|
+
} else {
|
|
9828
|
+
size = this.#fetchSize(change.row);
|
|
9829
|
+
}
|
|
9830
|
+
if (size === 1) {
|
|
9831
|
+
this.#output.push({
|
|
9832
|
+
type: this.#not ? "remove" : "add",
|
|
9833
|
+
node: this.#fetchNodeForRow(change.row)
|
|
9834
|
+
});
|
|
9835
|
+
} else {
|
|
9836
|
+
this.#pushWithFilter(change, size);
|
|
9837
|
+
}
|
|
9838
|
+
return;
|
|
9839
|
+
}
|
|
9840
|
+
case "remove": {
|
|
9841
|
+
let size = this.#getSize(change.row);
|
|
9842
|
+
if (size !== void 0) {
|
|
9843
|
+
assert(size > 0);
|
|
9844
|
+
size--;
|
|
9845
|
+
this.#setSize(change.row, size);
|
|
9846
|
+
} else {
|
|
9847
|
+
size = this.#fetchSize(change.row);
|
|
9848
|
+
}
|
|
9849
|
+
if (size === 0) {
|
|
9850
|
+
this.#output.push({
|
|
9851
|
+
type: this.#not ? "add" : "remove",
|
|
9852
|
+
node: this.#fetchNodeForRow(change.row)
|
|
9853
|
+
});
|
|
9854
|
+
} else {
|
|
9855
|
+
this.#pushWithFilter(change, size);
|
|
9856
|
+
}
|
|
9857
|
+
return;
|
|
9858
|
+
}
|
|
9859
|
+
}
|
|
9860
|
+
return;
|
|
9861
|
+
default:
|
|
9862
|
+
unreachable(change);
|
|
9863
|
+
}
|
|
9864
|
+
}
|
|
9865
|
+
/**
|
|
9866
|
+
* Returns whether or not the change's row's this.#relationshipName
|
|
9867
|
+
* relationship passes the exist/not exists filter condition.
|
|
9868
|
+
* If the optional `size` is passed it is used.
|
|
9869
|
+
* Otherwise, if there is a stored size for the row it is used.
|
|
9870
|
+
* Otherwise the size is computed by fetching a node for the row from
|
|
9871
|
+
* this.#input (this computed size is also stored).
|
|
9872
|
+
*/
|
|
9873
|
+
#filter(row, size) {
|
|
9874
|
+
const exists = (size ?? this.#getOrFetchSize(row)) > 0;
|
|
9875
|
+
return this.#not ? !exists : exists;
|
|
9876
|
+
}
|
|
9877
|
+
/**
|
|
9878
|
+
* Pushes a change if this.#filter is true for its row.
|
|
9879
|
+
*/
|
|
9880
|
+
#pushWithFilter(change, size) {
|
|
9881
|
+
const row = rowForChange(change);
|
|
9882
|
+
if (this.#filter(row, size)) {
|
|
9883
|
+
must(this.#output).push(change);
|
|
9884
|
+
}
|
|
9885
|
+
}
|
|
9886
|
+
#getSize(row) {
|
|
9887
|
+
return this.#storage.get(this.#makeSizeStorageKey(row));
|
|
9888
|
+
}
|
|
9889
|
+
#setSize(row, size) {
|
|
9890
|
+
this.#storage.set(this.#makeSizeStorageKey(row), size);
|
|
9891
|
+
}
|
|
9892
|
+
#delSize(row) {
|
|
9893
|
+
this.#storage.del(this.#makeSizeStorageKey(row));
|
|
9894
|
+
}
|
|
9895
|
+
#getOrFetchSize(row) {
|
|
9896
|
+
const size = this.#getSize(row);
|
|
9897
|
+
if (size !== void 0) {
|
|
9898
|
+
return size;
|
|
9899
|
+
}
|
|
9900
|
+
return this.#fetchSize(row);
|
|
9901
|
+
}
|
|
9902
|
+
#fetchSize(row) {
|
|
9903
|
+
const relationship = this.#fetchNodeForRow(row).relationships[this.#relationshipName];
|
|
9904
|
+
assert(relationship);
|
|
9905
|
+
let size = 0;
|
|
9906
|
+
for (const _relatedNode of relationship) {
|
|
9907
|
+
size++;
|
|
9908
|
+
}
|
|
9909
|
+
this.#setSize(row, size);
|
|
9910
|
+
return size;
|
|
9911
|
+
}
|
|
9912
|
+
#fetchNodeForRow(row) {
|
|
9913
|
+
return must(
|
|
9914
|
+
first(
|
|
9915
|
+
this.#input.fetch({
|
|
9916
|
+
start: { row, basis: "at" }
|
|
9917
|
+
})
|
|
9918
|
+
)
|
|
9919
|
+
);
|
|
9920
|
+
}
|
|
9921
|
+
#makeSizeStorageKey(row) {
|
|
9922
|
+
const primaryKey = [];
|
|
9923
|
+
for (const key of this.#input.getSchema().primaryKey) {
|
|
9924
|
+
primaryKey.push(normalizeUndefined(row[key]));
|
|
9925
|
+
}
|
|
9926
|
+
return JSON.stringify(["size", primaryKey]);
|
|
9927
|
+
}
|
|
9928
|
+
};
|
|
9929
|
+
|
|
9930
|
+
// ../zql/src/ivm/fan-in.ts
|
|
9931
|
+
var FanIn = class {
|
|
9932
|
+
#inputs;
|
|
9933
|
+
#fanOut;
|
|
9934
|
+
#schema;
|
|
9935
|
+
#output;
|
|
9936
|
+
constructor(fanOut, inputs) {
|
|
9937
|
+
this.#inputs = inputs;
|
|
9938
|
+
this.#schema = fanOut.getSchema();
|
|
9939
|
+
this.#fanOut = fanOut;
|
|
9940
|
+
for (const input of inputs) {
|
|
9941
|
+
input.setOutput(this);
|
|
9942
|
+
assert(this.#schema === input.getSchema(), `Schema mismatch in fan-in`);
|
|
9943
|
+
}
|
|
9944
|
+
}
|
|
9945
|
+
setOutput(output) {
|
|
9946
|
+
this.#output = output;
|
|
9947
|
+
}
|
|
9948
|
+
destroy() {
|
|
9949
|
+
for (const input of this.#inputs) {
|
|
9950
|
+
input.destroy();
|
|
9951
|
+
}
|
|
9952
|
+
}
|
|
9953
|
+
getSchema() {
|
|
9954
|
+
return this.#schema;
|
|
9618
9955
|
}
|
|
9619
9956
|
fetch(req) {
|
|
9620
9957
|
return this.#fetchOrCleanup((input) => input.fetch(req));
|
|
@@ -9639,19 +9976,16 @@ var FanIn = class {
|
|
|
9639
9976
|
// ../zql/src/ivm/fan-out.ts
|
|
9640
9977
|
var FanOut = class {
|
|
9641
9978
|
#input;
|
|
9642
|
-
#outputs;
|
|
9979
|
+
#outputs = [];
|
|
9643
9980
|
// FanOut is paired with a FanIn.
|
|
9644
9981
|
// Once FanIn has received a push from FanOut along
|
|
9645
9982
|
// any branch, FanOut no longer needs to push that value
|
|
9646
9983
|
// across the rest of its outputs..
|
|
9647
|
-
#fanInReceivedPush;
|
|
9648
|
-
#destroyCount;
|
|
9984
|
+
#fanInReceivedPush = false;
|
|
9985
|
+
#destroyCount = 0;
|
|
9649
9986
|
constructor(input) {
|
|
9650
9987
|
this.#input = input;
|
|
9651
|
-
|
|
9652
|
-
this.#outputs = [];
|
|
9653
|
-
this.#fanInReceivedPush = false;
|
|
9654
|
-
this.#destroyCount = 0;
|
|
9988
|
+
input.setOutput(this);
|
|
9655
9989
|
}
|
|
9656
9990
|
setOutput(output) {
|
|
9657
9991
|
this.#outputs.push(output);
|
|
@@ -9724,7 +10058,7 @@ var Filter = class {
|
|
|
9724
10058
|
this.#input = input;
|
|
9725
10059
|
this.#mode = mode;
|
|
9726
10060
|
this.#predicate = predicate;
|
|
9727
|
-
|
|
10061
|
+
input.setOutput(this);
|
|
9728
10062
|
}
|
|
9729
10063
|
setOutput(output) {
|
|
9730
10064
|
this.#output = output;
|
|
@@ -9771,78 +10105,6 @@ var Filter = class {
|
|
|
9771
10105
|
}
|
|
9772
10106
|
};
|
|
9773
10107
|
|
|
9774
|
-
// ../zql/src/ivm/data.ts
|
|
9775
|
-
import { compareUTF8 as compareUTF84 } from "compare-utf8";
|
|
9776
|
-
function compareValues(a, b) {
|
|
9777
|
-
a = normalizeUndefined(a);
|
|
9778
|
-
b = normalizeUndefined(b);
|
|
9779
|
-
if (a === b) {
|
|
9780
|
-
return 0;
|
|
9781
|
-
}
|
|
9782
|
-
if (a === null) {
|
|
9783
|
-
return -1;
|
|
9784
|
-
}
|
|
9785
|
-
if (b === null) {
|
|
9786
|
-
return 1;
|
|
9787
|
-
}
|
|
9788
|
-
if (typeof a === "boolean") {
|
|
9789
|
-
assertBoolean(b);
|
|
9790
|
-
return a ? 1 : -1;
|
|
9791
|
-
}
|
|
9792
|
-
if (typeof a === "number") {
|
|
9793
|
-
assertNumber(b);
|
|
9794
|
-
return a - b;
|
|
9795
|
-
}
|
|
9796
|
-
if (typeof a === "string") {
|
|
9797
|
-
assertString(b);
|
|
9798
|
-
return compareUTF84(a, b);
|
|
9799
|
-
}
|
|
9800
|
-
throw new Error(`Unsupported type: ${a}`);
|
|
9801
|
-
}
|
|
9802
|
-
function normalizeUndefined(v2) {
|
|
9803
|
-
return v2 ?? null;
|
|
9804
|
-
}
|
|
9805
|
-
function makeComparator(order) {
|
|
9806
|
-
return (a, b) => {
|
|
9807
|
-
for (const ord of order) {
|
|
9808
|
-
const field = ord[0];
|
|
9809
|
-
const comp = compareValues(a[field], b[field]);
|
|
9810
|
-
if (comp !== 0) {
|
|
9811
|
-
return ord[1] === "asc" ? comp : -comp;
|
|
9812
|
-
}
|
|
9813
|
-
}
|
|
9814
|
-
return 0;
|
|
9815
|
-
};
|
|
9816
|
-
}
|
|
9817
|
-
function valuesEqual(a, b) {
|
|
9818
|
-
a = normalizeUndefined(a);
|
|
9819
|
-
b = normalizeUndefined(b);
|
|
9820
|
-
if (a === null || b === null) {
|
|
9821
|
-
return false;
|
|
9822
|
-
}
|
|
9823
|
-
return a === b;
|
|
9824
|
-
}
|
|
9825
|
-
|
|
9826
|
-
// ../zql/src/ivm/stream.ts
|
|
9827
|
-
function* take(stream, limit) {
|
|
9828
|
-
if (limit < 1) {
|
|
9829
|
-
return;
|
|
9830
|
-
}
|
|
9831
|
-
let count = 0;
|
|
9832
|
-
for (const v2 of stream) {
|
|
9833
|
-
yield v2;
|
|
9834
|
-
if (++count === limit) {
|
|
9835
|
-
break;
|
|
9836
|
-
}
|
|
9837
|
-
}
|
|
9838
|
-
}
|
|
9839
|
-
function first(stream) {
|
|
9840
|
-
const it = stream[Symbol.iterator]();
|
|
9841
|
-
const { value } = it.next();
|
|
9842
|
-
it.return?.();
|
|
9843
|
-
return value;
|
|
9844
|
-
}
|
|
9845
|
-
|
|
9846
10108
|
// ../zql/src/ivm/join.ts
|
|
9847
10109
|
var Join = class {
|
|
9848
10110
|
#parent;
|
|
@@ -10139,7 +10401,7 @@ var Skip = class {
|
|
|
10139
10401
|
this.#input = input;
|
|
10140
10402
|
this.#bound = bound;
|
|
10141
10403
|
this.#comparator = input.getSchema().compareRows;
|
|
10142
|
-
|
|
10404
|
+
input.setOutput(this);
|
|
10143
10405
|
}
|
|
10144
10406
|
getSchema() {
|
|
10145
10407
|
return this.#input.getSchema();
|
|
@@ -10230,10 +10492,10 @@ var Take = class {
|
|
|
10230
10492
|
this.#partitionKey = partitionKey;
|
|
10231
10493
|
assert(limit >= 0);
|
|
10232
10494
|
assertOrderingIncludesPK(
|
|
10233
|
-
|
|
10234
|
-
|
|
10495
|
+
input.getSchema().sort,
|
|
10496
|
+
input.getSchema().primaryKey
|
|
10235
10497
|
);
|
|
10236
|
-
|
|
10498
|
+
input.setOutput(this);
|
|
10237
10499
|
}
|
|
10238
10500
|
setOutput(output) {
|
|
10239
10501
|
this.#output = output;
|
|
@@ -10355,8 +10617,7 @@ var Take = class {
|
|
|
10355
10617
|
return;
|
|
10356
10618
|
}
|
|
10357
10619
|
assert(this.#output, "Output not set");
|
|
10358
|
-
|
|
10359
|
-
const { takeState, takeStateKey, maxBound, constraint } = this.#getStateAndConstraint(change.node.row);
|
|
10620
|
+
const { takeState, takeStateKey, maxBound, constraint } = this.#getStateAndConstraint(rowForChange(change));
|
|
10360
10621
|
if (!takeState) {
|
|
10361
10622
|
return;
|
|
10362
10623
|
}
|
|
@@ -10475,6 +10736,10 @@ var Take = class {
|
|
|
10475
10736
|
maxBound
|
|
10476
10737
|
);
|
|
10477
10738
|
this.#output.push(change);
|
|
10739
|
+
} else if (change.type === "child") {
|
|
10740
|
+
if (takeState.bound && compareRows(change.row, takeState.bound) <= 0) {
|
|
10741
|
+
this.#output.push(change);
|
|
10742
|
+
}
|
|
10478
10743
|
}
|
|
10479
10744
|
}
|
|
10480
10745
|
#pushEditChange(change) {
|
|
@@ -10722,10 +10987,17 @@ function patternToRegExp(source, flags = "") {
|
|
|
10722
10987
|
|
|
10723
10988
|
// ../zql/src/builder/filter.ts
|
|
10724
10989
|
function createPredicate(condition) {
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10990
|
+
switch (condition.op) {
|
|
10991
|
+
case "IS":
|
|
10992
|
+
case "IS NOT": {
|
|
10993
|
+
const impl2 = createIsPredicate(condition.value, condition.op);
|
|
10994
|
+
return (row) => impl2(row[condition.field]);
|
|
10995
|
+
}
|
|
10996
|
+
}
|
|
10997
|
+
if (condition.value === null || condition.value === void 0) {
|
|
10998
|
+
return (_row) => false;
|
|
10999
|
+
}
|
|
11000
|
+
const impl = createPredicateImpl(condition.value, condition.op);
|
|
10729
11001
|
return (row) => {
|
|
10730
11002
|
const lhs = row[condition.field];
|
|
10731
11003
|
if (lhs === null || lhs === void 0) {
|
|
@@ -10734,6 +11006,14 @@ function createPredicate(condition) {
|
|
|
10734
11006
|
return impl(lhs);
|
|
10735
11007
|
};
|
|
10736
11008
|
}
|
|
11009
|
+
function createIsPredicate(rhs, operator) {
|
|
11010
|
+
switch (operator) {
|
|
11011
|
+
case "IS":
|
|
11012
|
+
return (lhs) => lhs === rhs;
|
|
11013
|
+
case "IS NOT":
|
|
11014
|
+
return (lhs) => lhs !== rhs;
|
|
11015
|
+
}
|
|
11016
|
+
}
|
|
10737
11017
|
function createPredicateImpl(rhs, operator) {
|
|
10738
11018
|
switch (operator) {
|
|
10739
11019
|
case "=":
|
|
@@ -10751,11 +11031,11 @@ function createPredicateImpl(rhs, operator) {
|
|
|
10751
11031
|
case "LIKE":
|
|
10752
11032
|
return getLikePredicate(rhs, "");
|
|
10753
11033
|
case "NOT LIKE":
|
|
10754
|
-
return
|
|
11034
|
+
return not(getLikePredicate(rhs, ""));
|
|
10755
11035
|
case "ILIKE":
|
|
10756
11036
|
return getLikePredicate(rhs, "i");
|
|
10757
11037
|
case "NOT ILIKE":
|
|
10758
|
-
return
|
|
11038
|
+
return not(getLikePredicate(rhs, "i"));
|
|
10759
11039
|
case "IN": {
|
|
10760
11040
|
assert(Array.isArray(rhs));
|
|
10761
11041
|
const set = new Set(rhs);
|
|
@@ -10771,7 +11051,7 @@ function createPredicateImpl(rhs, operator) {
|
|
|
10771
11051
|
throw new Error(`Unexpected operator: ${operator}`);
|
|
10772
11052
|
}
|
|
10773
11053
|
}
|
|
10774
|
-
function
|
|
11054
|
+
function not(f) {
|
|
10775
11055
|
return (lhs) => !f(lhs);
|
|
10776
11056
|
}
|
|
10777
11057
|
|
|
@@ -10798,10 +11078,22 @@ function bindStaticParameters(ast, staticQueryParameters) {
|
|
|
10798
11078
|
return node;
|
|
10799
11079
|
};
|
|
10800
11080
|
function bindCondition(condition) {
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
11081
|
+
if (condition.type === "simple") {
|
|
11082
|
+
return {
|
|
11083
|
+
...condition,
|
|
11084
|
+
value: bindValue(condition.value)
|
|
11085
|
+
};
|
|
11086
|
+
}
|
|
11087
|
+
if (condition.type === "correlatedSubquery") {
|
|
11088
|
+
return {
|
|
11089
|
+
...condition,
|
|
11090
|
+
related: {
|
|
11091
|
+
...condition.related,
|
|
11092
|
+
subquery: visit(condition.related.subquery)
|
|
11093
|
+
}
|
|
11094
|
+
};
|
|
11095
|
+
}
|
|
11096
|
+
return {
|
|
10805
11097
|
...condition,
|
|
10806
11098
|
conditions: condition.conditions.map(bindCondition)
|
|
10807
11099
|
};
|
|
@@ -10834,60 +11126,49 @@ function buildPipelineInternal(ast, delegate, staticQueryParameters, partitionKe
|
|
|
10834
11126
|
const conn = source.connect(must(ast.orderBy), ast.where);
|
|
10835
11127
|
let end = conn;
|
|
10836
11128
|
const { appliedFilters } = conn;
|
|
11129
|
+
ast = uniquifyCorrelatedSubqueryConditionAliases(ast);
|
|
10837
11130
|
if (ast.start) {
|
|
10838
11131
|
end = new Skip(end, ast.start);
|
|
10839
11132
|
}
|
|
11133
|
+
for (const csq of gatherCorrelatedSubqueryQueriesFromCondition(ast.where)) {
|
|
11134
|
+
end = applyCorrelatedSubQuery(csq, delegate, staticQueryParameters, end);
|
|
11135
|
+
}
|
|
10840
11136
|
if (ast.where) {
|
|
10841
|
-
end = applyWhere(end, ast.where, appliedFilters);
|
|
11137
|
+
end = applyWhere(end, ast.where, appliedFilters, delegate);
|
|
10842
11138
|
}
|
|
10843
11139
|
if (ast.limit) {
|
|
10844
11140
|
end = new Take(end, delegate.createStorage(), ast.limit, partitionKey);
|
|
10845
11141
|
}
|
|
10846
11142
|
if (ast.related) {
|
|
10847
|
-
for (const
|
|
10848
|
-
|
|
10849
|
-
const child = buildPipelineInternal(
|
|
10850
|
-
sq.subquery,
|
|
10851
|
-
delegate,
|
|
10852
|
-
staticQueryParameters,
|
|
10853
|
-
sq.correlation.childField
|
|
10854
|
-
);
|
|
10855
|
-
end = new Join({
|
|
10856
|
-
parent: end,
|
|
10857
|
-
child,
|
|
10858
|
-
storage: delegate.createStorage(),
|
|
10859
|
-
parentKey: sq.correlation.parentField,
|
|
10860
|
-
childKey: sq.correlation.childField,
|
|
10861
|
-
relationshipName: sq.subquery.alias,
|
|
10862
|
-
hidden: sq.hidden ?? false
|
|
10863
|
-
});
|
|
11143
|
+
for (const csq of ast.related) {
|
|
11144
|
+
end = applyCorrelatedSubQuery(csq, delegate, staticQueryParameters, end);
|
|
10864
11145
|
}
|
|
10865
11146
|
}
|
|
10866
11147
|
return end;
|
|
10867
11148
|
}
|
|
10868
|
-
function applyWhere(input, condition, appliedFilters) {
|
|
11149
|
+
function applyWhere(input, condition, appliedFilters, delegate) {
|
|
10869
11150
|
switch (condition.type) {
|
|
10870
11151
|
case "and":
|
|
10871
|
-
return applyAnd(input, condition, appliedFilters);
|
|
11152
|
+
return applyAnd(input, condition, appliedFilters, delegate);
|
|
10872
11153
|
case "or":
|
|
10873
|
-
return applyOr(input, condition, appliedFilters);
|
|
11154
|
+
return applyOr(input, condition, appliedFilters, delegate);
|
|
11155
|
+
case "correlatedSubquery":
|
|
11156
|
+
return applyCorrelatedSubqueryCondition(input, condition, delegate);
|
|
10874
11157
|
default:
|
|
10875
11158
|
return applySimpleCondition(input, condition, appliedFilters);
|
|
10876
11159
|
}
|
|
10877
11160
|
}
|
|
10878
|
-
function applyAnd(input, condition, appliedFilters) {
|
|
11161
|
+
function applyAnd(input, condition, appliedFilters, delegate) {
|
|
10879
11162
|
for (const subCondition of condition.conditions) {
|
|
10880
|
-
input = applyWhere(input, subCondition, appliedFilters);
|
|
11163
|
+
input = applyWhere(input, subCondition, appliedFilters, delegate);
|
|
10881
11164
|
}
|
|
10882
11165
|
return input;
|
|
10883
11166
|
}
|
|
10884
|
-
function applyOr(input, condition, appliedFilters) {
|
|
11167
|
+
function applyOr(input, condition, appliedFilters, delegate) {
|
|
10885
11168
|
const fanOut = new FanOut(input);
|
|
10886
|
-
const branches =
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
}
|
|
10890
|
-
assert(branches.length > 0, "Or condition must have at least one branch");
|
|
11169
|
+
const branches = condition.conditions.map(
|
|
11170
|
+
(subCondition) => applyWhere(fanOut, subCondition, appliedFilters, delegate)
|
|
11171
|
+
);
|
|
10891
11172
|
return new FanIn(fanOut, branches);
|
|
10892
11173
|
}
|
|
10893
11174
|
function applySimpleCondition(input, condition, appliedFilters) {
|
|
@@ -10897,6 +11178,58 @@ function applySimpleCondition(input, condition, appliedFilters) {
|
|
|
10897
11178
|
createPredicate(condition)
|
|
10898
11179
|
);
|
|
10899
11180
|
}
|
|
11181
|
+
function applyCorrelatedSubQuery(sq, delegate, staticQueryParameters, end) {
|
|
11182
|
+
assert(sq.subquery.alias, "Subquery must have an alias");
|
|
11183
|
+
const child = buildPipelineInternal(
|
|
11184
|
+
sq.subquery,
|
|
11185
|
+
delegate,
|
|
11186
|
+
staticQueryParameters,
|
|
11187
|
+
sq.correlation.childField
|
|
11188
|
+
);
|
|
11189
|
+
end = new Join({
|
|
11190
|
+
parent: end,
|
|
11191
|
+
child,
|
|
11192
|
+
storage: delegate.createStorage(),
|
|
11193
|
+
parentKey: sq.correlation.parentField,
|
|
11194
|
+
childKey: sq.correlation.childField,
|
|
11195
|
+
relationshipName: sq.subquery.alias,
|
|
11196
|
+
hidden: sq.hidden ?? false
|
|
11197
|
+
});
|
|
11198
|
+
return end;
|
|
11199
|
+
}
|
|
11200
|
+
function applyCorrelatedSubqueryCondition(input, condition, delegate) {
|
|
11201
|
+
assert(condition.op === "EXISTS" || condition.op === "NOT EXISTS");
|
|
11202
|
+
return new Exists(
|
|
11203
|
+
input,
|
|
11204
|
+
delegate.createStorage(),
|
|
11205
|
+
must(condition.related.subquery.alias),
|
|
11206
|
+
condition.op
|
|
11207
|
+
);
|
|
11208
|
+
}
|
|
11209
|
+
function gatherCorrelatedSubqueryQueriesFromCondition(condition) {
|
|
11210
|
+
const csqs = [];
|
|
11211
|
+
const gather = (condition2) => {
|
|
11212
|
+
if (condition2.type === "correlatedSubquery") {
|
|
11213
|
+
assert(condition2.op === "EXISTS" || condition2.op === "NOT EXISTS");
|
|
11214
|
+
csqs.push({
|
|
11215
|
+
...condition2.related,
|
|
11216
|
+
subquery: { ...condition2.related.subquery, limit: EXISTS_LIMIT }
|
|
11217
|
+
});
|
|
11218
|
+
return;
|
|
11219
|
+
}
|
|
11220
|
+
if (condition2.type === "and" || condition2.type === "or") {
|
|
11221
|
+
for (const c of condition2.conditions) {
|
|
11222
|
+
gather(c);
|
|
11223
|
+
}
|
|
11224
|
+
return;
|
|
11225
|
+
}
|
|
11226
|
+
};
|
|
11227
|
+
if (condition) {
|
|
11228
|
+
gather(condition);
|
|
11229
|
+
}
|
|
11230
|
+
return csqs;
|
|
11231
|
+
}
|
|
11232
|
+
var EXISTS_LIMIT = 5;
|
|
10900
11233
|
function assertOrderingIncludesPK(ordering, pk) {
|
|
10901
11234
|
const orderingFields = ordering.map(([field]) => field);
|
|
10902
11235
|
const missingFields = pk.filter((pkField) => !orderingFields.includes(pkField));
|
|
@@ -10912,6 +11245,63 @@ function assertOrderingIncludesPK(ordering, pk) {
|
|
|
10912
11245
|
);
|
|
10913
11246
|
}
|
|
10914
11247
|
}
|
|
11248
|
+
function uniquifyCorrelatedSubqueryConditionAliases(ast) {
|
|
11249
|
+
if (!ast.where) {
|
|
11250
|
+
return ast;
|
|
11251
|
+
}
|
|
11252
|
+
const { where } = ast;
|
|
11253
|
+
if (where.type !== "and" && where.type !== "or") {
|
|
11254
|
+
return ast;
|
|
11255
|
+
}
|
|
11256
|
+
let count = 0;
|
|
11257
|
+
const uniquifyCorrelatedSubquery = (csqc) => ({
|
|
11258
|
+
...csqc,
|
|
11259
|
+
related: {
|
|
11260
|
+
...csqc.related,
|
|
11261
|
+
subquery: {
|
|
11262
|
+
...csqc.related.subquery,
|
|
11263
|
+
alias: (csqc.related.subquery.alias ?? "") + "_" + count++
|
|
11264
|
+
}
|
|
11265
|
+
}
|
|
11266
|
+
});
|
|
11267
|
+
const uniquifyAnd = (and2) => {
|
|
11268
|
+
const conds2 = [];
|
|
11269
|
+
for (const cond of and2.conditions) {
|
|
11270
|
+
if (cond.type === "correlatedSubquery") {
|
|
11271
|
+
conds2.push(uniquifyCorrelatedSubquery(cond));
|
|
11272
|
+
} else {
|
|
11273
|
+
conds2.push(cond);
|
|
11274
|
+
}
|
|
11275
|
+
}
|
|
11276
|
+
return {
|
|
11277
|
+
...and2,
|
|
11278
|
+
conditions: conds2
|
|
11279
|
+
};
|
|
11280
|
+
};
|
|
11281
|
+
if (where.type === "and") {
|
|
11282
|
+
return {
|
|
11283
|
+
...ast,
|
|
11284
|
+
where: uniquifyAnd(where)
|
|
11285
|
+
};
|
|
11286
|
+
}
|
|
11287
|
+
const conds = [];
|
|
11288
|
+
for (const cond of where.conditions) {
|
|
11289
|
+
if (cond.type === "simple") {
|
|
11290
|
+
conds.push(cond);
|
|
11291
|
+
} else if (cond.type === "correlatedSubquery") {
|
|
11292
|
+
conds.push(uniquifyCorrelatedSubquery(cond));
|
|
11293
|
+
} else if (cond.type === "and") {
|
|
11294
|
+
conds.push(uniquifyAnd(cond));
|
|
11295
|
+
}
|
|
11296
|
+
}
|
|
11297
|
+
return {
|
|
11298
|
+
...ast,
|
|
11299
|
+
where: {
|
|
11300
|
+
...where,
|
|
11301
|
+
conditions: conds
|
|
11302
|
+
}
|
|
11303
|
+
};
|
|
11304
|
+
}
|
|
10915
11305
|
|
|
10916
11306
|
// ../zql/src/ivm/array-view.ts
|
|
10917
11307
|
var ArrayView = class {
|
|
@@ -10928,8 +11318,8 @@ var ArrayView = class {
|
|
|
10928
11318
|
this.#input = input;
|
|
10929
11319
|
this.#schema = input.getSchema();
|
|
10930
11320
|
this.#format = format;
|
|
10931
|
-
this.#input.setOutput(this);
|
|
10932
11321
|
this.#root = { "": format.singular ? void 0 : [] };
|
|
11322
|
+
input.setOutput(this);
|
|
10933
11323
|
this.#hydrate();
|
|
10934
11324
|
}
|
|
10935
11325
|
get data() {
|
|
@@ -10977,159 +11367,198 @@ var ArrayView = class {
|
|
|
10977
11367
|
}
|
|
10978
11368
|
};
|
|
10979
11369
|
|
|
10980
|
-
// ../
|
|
10981
|
-
|
|
10982
|
-
|
|
10983
|
-
|
|
10984
|
-
|
|
10985
|
-
|
|
10986
|
-
|
|
10987
|
-
|
|
10988
|
-
|
|
10989
|
-
|
|
10990
|
-
|
|
10991
|
-
|
|
10992
|
-
|
|
10993
|
-
|
|
10994
|
-
|
|
10995
|
-
|
|
10996
|
-
|
|
10997
|
-
|
|
10998
|
-
relationships;
|
|
10999
|
-
constructor(tableSchema, tableSchemaCache) {
|
|
11000
|
-
this.tableName = tableSchema.tableName;
|
|
11001
|
-
const primaryKey = normalizePrimaryKey(tableSchema.primaryKey);
|
|
11002
|
-
this.primaryKey = primaryKey;
|
|
11003
|
-
this.columns = normalizeColumns(tableSchema.columns, primaryKey);
|
|
11004
|
-
tableSchemaCache.set(tableSchema, this);
|
|
11005
|
-
this.relationships = normalizeRelationships(
|
|
11006
|
-
tableSchema.relationships,
|
|
11007
|
-
tableSchemaCache
|
|
11008
|
-
);
|
|
11370
|
+
// ../zql/src/query/expression.ts
|
|
11371
|
+
var ExpressionBuilder = class {
|
|
11372
|
+
#exists;
|
|
11373
|
+
constructor(exists) {
|
|
11374
|
+
this.#exists = exists;
|
|
11375
|
+
this.exists = this.exists.bind(this);
|
|
11376
|
+
}
|
|
11377
|
+
get eb() {
|
|
11378
|
+
return this;
|
|
11379
|
+
}
|
|
11380
|
+
cmp(field, opOrValue, value) {
|
|
11381
|
+
return cmp(field, opOrValue, value);
|
|
11382
|
+
}
|
|
11383
|
+
and = and;
|
|
11384
|
+
or = or;
|
|
11385
|
+
not = not2;
|
|
11386
|
+
exists(relationship, cb) {
|
|
11387
|
+
return this.#exists(relationship, cb);
|
|
11009
11388
|
}
|
|
11010
11389
|
};
|
|
11011
|
-
function
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
/* @__PURE__ */ new Map()
|
|
11016
|
-
);
|
|
11017
|
-
}
|
|
11018
|
-
function normalizeTableSchemaWithCache(tableSchema, expectedName, tableSchemaCache) {
|
|
11019
|
-
if (tableSchema instanceof NormalizedTableSchema) {
|
|
11020
|
-
return tableSchema;
|
|
11390
|
+
function and(...conditions) {
|
|
11391
|
+
const expressions = filterTrue(filterUndefined(conditions));
|
|
11392
|
+
if (expressions.length === 1) {
|
|
11393
|
+
return expressions[0];
|
|
11021
11394
|
}
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
`Table name mismatch: "${tableSchema.tableName}" !== "${expectedName}"`
|
|
11025
|
-
);
|
|
11026
|
-
let normalizedTableSchema = tableSchemaCache.get(tableSchema);
|
|
11027
|
-
if (normalizedTableSchema) {
|
|
11028
|
-
return normalizedTableSchema;
|
|
11395
|
+
if (expressions.some(isAlwaysFalse)) {
|
|
11396
|
+
return FALSE;
|
|
11029
11397
|
}
|
|
11030
|
-
|
|
11031
|
-
tableSchema,
|
|
11032
|
-
tableSchemaCache
|
|
11033
|
-
);
|
|
11034
|
-
return normalizedTableSchema;
|
|
11398
|
+
return { type: "and", conditions: expressions };
|
|
11035
11399
|
}
|
|
11036
|
-
function
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
|
|
11040
|
-
}
|
|
11400
|
+
function or(...conditions) {
|
|
11401
|
+
const expressions = filterFalse(filterUndefined(conditions));
|
|
11402
|
+
if (expressions.length === 1) {
|
|
11403
|
+
return expressions[0];
|
|
11041
11404
|
}
|
|
11042
|
-
|
|
11043
|
-
|
|
11044
|
-
function assertNoDuplicates(arr) {
|
|
11045
|
-
for (let i = 1; i < arr.length; i++) {
|
|
11046
|
-
assert(arr[i - 1] !== arr[i], "Primary key must not contain duplicates");
|
|
11405
|
+
if (expressions.some(isAlwaysTrue)) {
|
|
11406
|
+
return TRUE;
|
|
11047
11407
|
}
|
|
11408
|
+
return { type: "or", conditions: expressions };
|
|
11048
11409
|
}
|
|
11049
|
-
function
|
|
11050
|
-
|
|
11051
|
-
|
|
11410
|
+
function not2(expression) {
|
|
11411
|
+
switch (expression.type) {
|
|
11412
|
+
case "and":
|
|
11413
|
+
return {
|
|
11414
|
+
type: "or",
|
|
11415
|
+
conditions: expression.conditions.map(not2)
|
|
11416
|
+
};
|
|
11417
|
+
case "or":
|
|
11418
|
+
return {
|
|
11419
|
+
type: "and",
|
|
11420
|
+
conditions: expression.conditions.map(not2)
|
|
11421
|
+
};
|
|
11422
|
+
case "correlatedSubquery":
|
|
11423
|
+
return {
|
|
11424
|
+
type: "correlatedSubquery",
|
|
11425
|
+
related: expression.related,
|
|
11426
|
+
op: negateOperator(expression.op)
|
|
11427
|
+
};
|
|
11428
|
+
default:
|
|
11429
|
+
return {
|
|
11430
|
+
type: "simple",
|
|
11431
|
+
op: negateOperator(expression.op),
|
|
11432
|
+
field: expression.field,
|
|
11433
|
+
value: expression.value
|
|
11434
|
+
};
|
|
11052
11435
|
}
|
|
11053
|
-
arr = [...arr].sort();
|
|
11054
|
-
assertNoDuplicates(arr);
|
|
11055
|
-
return arr;
|
|
11056
11436
|
}
|
|
11057
|
-
function
|
|
11058
|
-
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11062
|
-
|
|
11063
|
-
|
|
11064
|
-
assert(
|
|
11065
|
-
type === "string" || type === "number" || type === "boolean",
|
|
11066
|
-
`Primary key column "${pk}" must be a string, number, or boolean. Got ${type}`
|
|
11067
|
-
);
|
|
11068
|
-
}
|
|
11069
|
-
for (const [name, column] of sortedEntries(columns)) {
|
|
11070
|
-
rv[name] = normalizeSchemaValue(column);
|
|
11437
|
+
function cmp(field, opOrValue, value) {
|
|
11438
|
+
let op;
|
|
11439
|
+
if (value === void 0) {
|
|
11440
|
+
value = opOrValue;
|
|
11441
|
+
op = "=";
|
|
11442
|
+
} else {
|
|
11443
|
+
op = opOrValue;
|
|
11071
11444
|
}
|
|
11072
|
-
return rv;
|
|
11073
|
-
}
|
|
11074
|
-
function normalizeSchemaValue(value) {
|
|
11075
11445
|
return {
|
|
11076
|
-
type:
|
|
11077
|
-
|
|
11446
|
+
type: "simple",
|
|
11447
|
+
field,
|
|
11448
|
+
op,
|
|
11449
|
+
value
|
|
11078
11450
|
};
|
|
11079
11451
|
}
|
|
11080
|
-
|
|
11081
|
-
|
|
11082
|
-
|
|
11083
|
-
|
|
11084
|
-
|
|
11085
|
-
|
|
11452
|
+
var TRUE = {
|
|
11453
|
+
type: "and",
|
|
11454
|
+
conditions: []
|
|
11455
|
+
};
|
|
11456
|
+
var FALSE = {
|
|
11457
|
+
type: "or",
|
|
11458
|
+
conditions: []
|
|
11459
|
+
};
|
|
11460
|
+
function isAlwaysTrue(condition) {
|
|
11461
|
+
return condition.type === "and" && condition.conditions.length === 0;
|
|
11086
11462
|
}
|
|
11087
|
-
function
|
|
11088
|
-
|
|
11089
|
-
return normalizeFieldRelationship(relationship, tableSchemaCache);
|
|
11090
|
-
}
|
|
11091
|
-
return normalizeJunctionRelationship(relationship, tableSchemaCache);
|
|
11463
|
+
function isAlwaysFalse(condition) {
|
|
11464
|
+
return condition.type === "or" && condition.conditions.length === 0;
|
|
11092
11465
|
}
|
|
11093
|
-
function
|
|
11094
|
-
|
|
11095
|
-
|
|
11096
|
-
|
|
11097
|
-
|
|
11098
|
-
|
|
11099
|
-
|
|
11100
|
-
tableSchemaCache
|
|
11101
|
-
)
|
|
11466
|
+
function flatten(type, conditions) {
|
|
11467
|
+
const flattened2 = [];
|
|
11468
|
+
for (const c of conditions) {
|
|
11469
|
+
if (c.type === type) {
|
|
11470
|
+
flattened2.push(...c.conditions);
|
|
11471
|
+
} else {
|
|
11472
|
+
flattened2.push(c);
|
|
11102
11473
|
}
|
|
11103
|
-
}
|
|
11474
|
+
}
|
|
11475
|
+
return flattened2;
|
|
11476
|
+
}
|
|
11477
|
+
var negateSimpleOperatorMap = {
|
|
11478
|
+
["="]: "!=",
|
|
11479
|
+
["!="]: "=",
|
|
11480
|
+
["<"]: ">=",
|
|
11481
|
+
[">"]: "<=",
|
|
11482
|
+
[">="]: "<",
|
|
11483
|
+
["<="]: ">",
|
|
11484
|
+
["IN"]: "NOT IN",
|
|
11485
|
+
["NOT IN"]: "IN",
|
|
11486
|
+
["LIKE"]: "NOT LIKE",
|
|
11487
|
+
["NOT LIKE"]: "LIKE",
|
|
11488
|
+
["ILIKE"]: "NOT ILIKE",
|
|
11489
|
+
["NOT ILIKE"]: "ILIKE",
|
|
11490
|
+
["IS"]: "IS NOT",
|
|
11491
|
+
["IS NOT"]: "IS"
|
|
11492
|
+
};
|
|
11493
|
+
var negateOperatorMap = {
|
|
11494
|
+
...negateSimpleOperatorMap,
|
|
11495
|
+
["EXISTS"]: "NOT EXISTS",
|
|
11496
|
+
["NOT EXISTS"]: "EXISTS"
|
|
11497
|
+
};
|
|
11498
|
+
function negateOperator(op) {
|
|
11499
|
+
return must(negateOperatorMap[op]);
|
|
11104
11500
|
}
|
|
11105
|
-
function
|
|
11106
|
-
return
|
|
11107
|
-
|
|
11108
|
-
|
|
11109
|
-
|
|
11110
|
-
|
|
11111
|
-
|
|
11112
|
-
|
|
11113
|
-
|
|
11114
|
-
|
|
11115
|
-
|
|
11116
|
-
|
|
11117
|
-
|
|
11118
|
-
|
|
11119
|
-
|
|
11120
|
-
|
|
11121
|
-
|
|
11501
|
+
function filterUndefined(array9) {
|
|
11502
|
+
return array9.filter((e) => e !== void 0);
|
|
11503
|
+
}
|
|
11504
|
+
function filterTrue(conditions) {
|
|
11505
|
+
return conditions.filter((c) => !isAlwaysTrue(c));
|
|
11506
|
+
}
|
|
11507
|
+
function filterFalse(conditions) {
|
|
11508
|
+
return conditions.filter((c) => !isAlwaysFalse(c));
|
|
11509
|
+
}
|
|
11510
|
+
|
|
11511
|
+
// ../zql/src/query/dnf.ts
|
|
11512
|
+
function dnf(condition) {
|
|
11513
|
+
return unwrap(dnfInner(condition));
|
|
11514
|
+
}
|
|
11515
|
+
function dnfInner(condition) {
|
|
11516
|
+
switch (condition.type) {
|
|
11517
|
+
case "simple":
|
|
11518
|
+
case "correlatedSubquery":
|
|
11519
|
+
return { type: "or", conditions: [condition] };
|
|
11520
|
+
case "and":
|
|
11521
|
+
return distributeAnd(condition.conditions.map(dnfInner));
|
|
11522
|
+
case "or":
|
|
11523
|
+
return {
|
|
11524
|
+
type: "or",
|
|
11525
|
+
conditions: flatten(
|
|
11526
|
+
"or",
|
|
11527
|
+
condition.conditions.map(dnfInner).flatMap((c) => c.conditions)
|
|
11528
|
+
)
|
|
11529
|
+
};
|
|
11530
|
+
default:
|
|
11531
|
+
unreachable(condition);
|
|
11532
|
+
}
|
|
11533
|
+
}
|
|
11534
|
+
function distributeAnd(conditions) {
|
|
11535
|
+
if (conditions.length === 0) {
|
|
11536
|
+
return { type: "or", conditions: [TRUE] };
|
|
11537
|
+
}
|
|
11538
|
+
return conditions.reduce((acc, orCondition) => {
|
|
11539
|
+
const newConditions = [];
|
|
11540
|
+
for (const accCondition of acc.conditions) {
|
|
11541
|
+
for (const orSubCondition of orCondition.conditions) {
|
|
11542
|
+
newConditions.push({
|
|
11543
|
+
type: "and",
|
|
11544
|
+
conditions: [accCondition, orSubCondition]
|
|
11545
|
+
});
|
|
11546
|
+
}
|
|
11122
11547
|
}
|
|
11123
|
-
|
|
11548
|
+
return {
|
|
11549
|
+
type: "or",
|
|
11550
|
+
conditions: flatten("or", newConditions)
|
|
11551
|
+
};
|
|
11552
|
+
});
|
|
11124
11553
|
}
|
|
11125
|
-
function
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
|
|
11129
|
-
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
);
|
|
11554
|
+
function unwrap(c) {
|
|
11555
|
+
if (c.type === "simple" || c.type === "correlatedSubquery") {
|
|
11556
|
+
return c;
|
|
11557
|
+
}
|
|
11558
|
+
if (c.conditions.length === 1) {
|
|
11559
|
+
return unwrap(c.conditions[0]);
|
|
11560
|
+
}
|
|
11561
|
+
return { type: c.type, conditions: flatten(c.type, c.conditions.map(unwrap)) };
|
|
11133
11562
|
}
|
|
11134
11563
|
|
|
11135
11564
|
// ../zql/src/query/query-impl.ts
|
|
@@ -11139,6 +11568,14 @@ function newQuery(delegate, tableSchema) {
|
|
|
11139
11568
|
function newQueryWithDetails(delegate, schema, ast, format) {
|
|
11140
11569
|
return new QueryImpl(delegate, schema, ast, format);
|
|
11141
11570
|
}
|
|
11571
|
+
function staticParam(anchorClass, field) {
|
|
11572
|
+
return {
|
|
11573
|
+
type: "static",
|
|
11574
|
+
anchor: anchorClass,
|
|
11575
|
+
field
|
|
11576
|
+
};
|
|
11577
|
+
}
|
|
11578
|
+
var SUBQ_PREFIX = "zsubq_";
|
|
11142
11579
|
var AbstractQuery = class {
|
|
11143
11580
|
#ast;
|
|
11144
11581
|
#schema;
|
|
@@ -11160,9 +11597,6 @@ var AbstractQuery = class {
|
|
|
11160
11597
|
}
|
|
11161
11598
|
return this.#hash;
|
|
11162
11599
|
}
|
|
11163
|
-
select(..._fields) {
|
|
11164
|
-
return this._newQuery(this.#schema, this.#ast, this.#format);
|
|
11165
|
-
}
|
|
11166
11600
|
one() {
|
|
11167
11601
|
return this._newQuery(
|
|
11168
11602
|
this.#schema,
|
|
@@ -11176,13 +11610,21 @@ var AbstractQuery = class {
|
|
|
11176
11610
|
}
|
|
11177
11611
|
);
|
|
11178
11612
|
}
|
|
11613
|
+
whereExists(relationship, cb = (q) => q) {
|
|
11614
|
+
return this.where(({ exists }) => exists(relationship, cb));
|
|
11615
|
+
}
|
|
11179
11616
|
related(relationship, cb = (q) => q) {
|
|
11617
|
+
if (relationship.startsWith(SUBQ_PREFIX)) {
|
|
11618
|
+
throw new Error(
|
|
11619
|
+
`Relationship names may not start with "${SUBQ_PREFIX}". That is a reserved prefix.`
|
|
11620
|
+
);
|
|
11621
|
+
}
|
|
11180
11622
|
const related = this.#schema.relationships[relationship];
|
|
11181
11623
|
assert(related, "Invalid relationship");
|
|
11182
|
-
const
|
|
11183
|
-
const
|
|
11184
|
-
if (isFieldRelationship(
|
|
11185
|
-
const destSchema =
|
|
11624
|
+
const fieldRelationship = related;
|
|
11625
|
+
const junctionRelationship = related;
|
|
11626
|
+
if (isFieldRelationship(fieldRelationship)) {
|
|
11627
|
+
const destSchema = fieldRelationship.dest.schema;
|
|
11186
11628
|
const sq = cb(
|
|
11187
11629
|
this._newQuery(
|
|
11188
11630
|
destSchema,
|
|
@@ -11201,8 +11643,8 @@ var AbstractQuery = class {
|
|
|
11201
11643
|
...this.#ast.related ?? [],
|
|
11202
11644
|
{
|
|
11203
11645
|
correlation: {
|
|
11204
|
-
parentField:
|
|
11205
|
-
childField:
|
|
11646
|
+
parentField: fieldRelationship.source,
|
|
11647
|
+
childField: fieldRelationship.dest.field,
|
|
11206
11648
|
op: "="
|
|
11207
11649
|
},
|
|
11208
11650
|
subquery: addPrimaryKeysToAst(destSchema, sq.#ast)
|
|
@@ -11218,9 +11660,9 @@ var AbstractQuery = class {
|
|
|
11218
11660
|
}
|
|
11219
11661
|
);
|
|
11220
11662
|
}
|
|
11221
|
-
if (isJunctionRelationship(
|
|
11222
|
-
const destSchema =
|
|
11223
|
-
const junctionSchema =
|
|
11663
|
+
if (isJunctionRelationship(junctionRelationship)) {
|
|
11664
|
+
const destSchema = junctionRelationship.dest.schema;
|
|
11665
|
+
const junctionSchema = junctionRelationship.junction.schema;
|
|
11224
11666
|
const sq = cb(
|
|
11225
11667
|
this._newQuery(
|
|
11226
11668
|
destSchema,
|
|
@@ -11239,8 +11681,8 @@ var AbstractQuery = class {
|
|
|
11239
11681
|
...this.#ast.related ?? [],
|
|
11240
11682
|
{
|
|
11241
11683
|
correlation: {
|
|
11242
|
-
parentField:
|
|
11243
|
-
childField:
|
|
11684
|
+
parentField: junctionRelationship.source,
|
|
11685
|
+
childField: junctionRelationship.junction.sourceField,
|
|
11244
11686
|
op: "="
|
|
11245
11687
|
},
|
|
11246
11688
|
subquery: {
|
|
@@ -11250,8 +11692,8 @@ var AbstractQuery = class {
|
|
|
11250
11692
|
related: [
|
|
11251
11693
|
{
|
|
11252
11694
|
correlation: {
|
|
11253
|
-
parentField:
|
|
11254
|
-
childField:
|
|
11695
|
+
parentField: junctionRelationship.junction.destField,
|
|
11696
|
+
childField: junctionRelationship.dest.field,
|
|
11255
11697
|
op: "="
|
|
11256
11698
|
},
|
|
11257
11699
|
hidden: true,
|
|
@@ -11273,13 +11715,13 @@ var AbstractQuery = class {
|
|
|
11273
11715
|
}
|
|
11274
11716
|
throw new Error(`Invalid relationship ${relationship}`);
|
|
11275
11717
|
}
|
|
11276
|
-
where(
|
|
11718
|
+
where(fieldOrExpressionFactory, opOrValue, value) {
|
|
11277
11719
|
let cond;
|
|
11278
|
-
if (
|
|
11279
|
-
|
|
11280
|
-
cond = field;
|
|
11720
|
+
if (typeof fieldOrExpressionFactory === "function") {
|
|
11721
|
+
cond = fieldOrExpressionFactory(new ExpressionBuilder(this.#exists));
|
|
11281
11722
|
} else {
|
|
11282
|
-
|
|
11723
|
+
assert(opOrValue !== void 0, "Invalid condition");
|
|
11724
|
+
cond = cmp(fieldOrExpressionFactory, opOrValue, value);
|
|
11283
11725
|
}
|
|
11284
11726
|
const existingWhere = this.#ast.where;
|
|
11285
11727
|
if (existingWhere) {
|
|
@@ -11289,7 +11731,7 @@ var AbstractQuery = class {
|
|
|
11289
11731
|
this.#schema,
|
|
11290
11732
|
{
|
|
11291
11733
|
...this.#ast,
|
|
11292
|
-
where: cond
|
|
11734
|
+
where: dnf(cond)
|
|
11293
11735
|
},
|
|
11294
11736
|
this.#format
|
|
11295
11737
|
);
|
|
@@ -11333,6 +11775,80 @@ var AbstractQuery = class {
|
|
|
11333
11775
|
this.#format
|
|
11334
11776
|
);
|
|
11335
11777
|
}
|
|
11778
|
+
#exists = (relationship, cb = (q) => q) => {
|
|
11779
|
+
const related = this.#schema.relationships[relationship];
|
|
11780
|
+
assert(related, "Invalid relationship");
|
|
11781
|
+
const fieldRelationship = related;
|
|
11782
|
+
const junctionRelationship = related;
|
|
11783
|
+
if (isFieldRelationship(fieldRelationship)) {
|
|
11784
|
+
const destSchema = fieldRelationship.dest.schema;
|
|
11785
|
+
const sq = cb(
|
|
11786
|
+
this._newQuery(
|
|
11787
|
+
destSchema,
|
|
11788
|
+
{
|
|
11789
|
+
table: destSchema.tableName,
|
|
11790
|
+
alias: `${SUBQ_PREFIX}${relationship}`
|
|
11791
|
+
},
|
|
11792
|
+
void 0
|
|
11793
|
+
)
|
|
11794
|
+
);
|
|
11795
|
+
return {
|
|
11796
|
+
type: "correlatedSubquery",
|
|
11797
|
+
related: {
|
|
11798
|
+
correlation: {
|
|
11799
|
+
parentField: fieldRelationship.source,
|
|
11800
|
+
childField: fieldRelationship.dest.field,
|
|
11801
|
+
op: "="
|
|
11802
|
+
},
|
|
11803
|
+
subquery: addPrimaryKeysToAst(destSchema, sq.#ast)
|
|
11804
|
+
},
|
|
11805
|
+
op: "EXISTS"
|
|
11806
|
+
};
|
|
11807
|
+
}
|
|
11808
|
+
if (isJunctionRelationship(junctionRelationship)) {
|
|
11809
|
+
const destSchema = junctionRelationship.dest.schema;
|
|
11810
|
+
const junctionSchema = junctionRelationship.junction.schema;
|
|
11811
|
+
const queryToDest = cb(
|
|
11812
|
+
this._newQuery(
|
|
11813
|
+
destSchema,
|
|
11814
|
+
{
|
|
11815
|
+
table: destSchema.tableName,
|
|
11816
|
+
alias: `${SUBQ_PREFIX}${relationship}`
|
|
11817
|
+
},
|
|
11818
|
+
void 0
|
|
11819
|
+
)
|
|
11820
|
+
);
|
|
11821
|
+
return {
|
|
11822
|
+
type: "correlatedSubquery",
|
|
11823
|
+
related: {
|
|
11824
|
+
correlation: {
|
|
11825
|
+
parentField: junctionRelationship.source,
|
|
11826
|
+
childField: junctionRelationship.junction.sourceField,
|
|
11827
|
+
op: "="
|
|
11828
|
+
},
|
|
11829
|
+
subquery: {
|
|
11830
|
+
table: junctionSchema.tableName,
|
|
11831
|
+
alias: `${SUBQ_PREFIX}${relationship}`,
|
|
11832
|
+
orderBy: addPrimaryKeys(junctionSchema, void 0),
|
|
11833
|
+
where: {
|
|
11834
|
+
type: "correlatedSubquery",
|
|
11835
|
+
related: {
|
|
11836
|
+
correlation: {
|
|
11837
|
+
parentField: junctionRelationship.junction.destField,
|
|
11838
|
+
childField: junctionRelationship.dest.field,
|
|
11839
|
+
op: "="
|
|
11840
|
+
},
|
|
11841
|
+
subquery: addPrimaryKeysToAst(destSchema, queryToDest.#ast)
|
|
11842
|
+
},
|
|
11843
|
+
op: "EXISTS"
|
|
11844
|
+
}
|
|
11845
|
+
}
|
|
11846
|
+
},
|
|
11847
|
+
op: "EXISTS"
|
|
11848
|
+
};
|
|
11849
|
+
}
|
|
11850
|
+
throw new Error(`Invalid relationship ${relationship}`);
|
|
11851
|
+
};
|
|
11336
11852
|
#completedAST;
|
|
11337
11853
|
_completeAst() {
|
|
11338
11854
|
if (!this.#completedAST) {
|
|
@@ -11444,6 +11960,113 @@ function arrayViewFactory(_query, input, format, onDestroy, onTransactionCommit)
|
|
|
11444
11960
|
return v2;
|
|
11445
11961
|
}
|
|
11446
11962
|
|
|
11963
|
+
// ../zql/src/query/auth-query.ts
|
|
11964
|
+
var AuthQuery = class _AuthQuery extends AbstractQuery {
|
|
11965
|
+
constructor(schema, ast = { table: schema.tableName }, format) {
|
|
11966
|
+
super(schema, ast, format);
|
|
11967
|
+
}
|
|
11968
|
+
_newQuery(schema, ast, format) {
|
|
11969
|
+
return new _AuthQuery(schema, ast, format);
|
|
11970
|
+
}
|
|
11971
|
+
get ast() {
|
|
11972
|
+
return this._completeAst();
|
|
11973
|
+
}
|
|
11974
|
+
materialize() {
|
|
11975
|
+
throw new Error("AuthQuery cannot be materialized");
|
|
11976
|
+
}
|
|
11977
|
+
run() {
|
|
11978
|
+
throw new Error("AuthQuery cannot be run");
|
|
11979
|
+
}
|
|
11980
|
+
preload() {
|
|
11981
|
+
throw new Error("AuthQuery cannot be preloaded");
|
|
11982
|
+
}
|
|
11983
|
+
};
|
|
11984
|
+
|
|
11985
|
+
// ../zero-schema/src/authorization.ts
|
|
11986
|
+
async function defineAuthorization(schema, definer) {
|
|
11987
|
+
const normalizedSchema = normalizeSchema(schema);
|
|
11988
|
+
const queries = {};
|
|
11989
|
+
for (const [name, tableSchema] of Object.entries(normalizedSchema.tables)) {
|
|
11990
|
+
queries[name] = new AuthQuery(tableSchema);
|
|
11991
|
+
}
|
|
11992
|
+
const config = await definer(queries);
|
|
11993
|
+
return compileAuthorization(config);
|
|
11994
|
+
}
|
|
11995
|
+
function compileAuthorization(authz) {
|
|
11996
|
+
if (!authz) {
|
|
11997
|
+
return void 0;
|
|
11998
|
+
}
|
|
11999
|
+
const ret = {};
|
|
12000
|
+
for (const [tableName, tableConfig] of Object.entries(authz)) {
|
|
12001
|
+
ret[tableName] = {
|
|
12002
|
+
row: compileRowConfig(tableConfig.row),
|
|
12003
|
+
cell: compileCellConfig(tableConfig.cell)
|
|
12004
|
+
};
|
|
12005
|
+
}
|
|
12006
|
+
return ret;
|
|
12007
|
+
}
|
|
12008
|
+
function compileRowConfig(rowRules) {
|
|
12009
|
+
if (!rowRules) {
|
|
12010
|
+
return void 0;
|
|
12011
|
+
}
|
|
12012
|
+
return {
|
|
12013
|
+
select: compileInstanceRules(rowRules.select),
|
|
12014
|
+
insert: compileInstanceRules(rowRules.insert),
|
|
12015
|
+
update: compileInstanceRules(rowRules.update),
|
|
12016
|
+
delete: compileInstanceRules(rowRules.delete)
|
|
12017
|
+
};
|
|
12018
|
+
}
|
|
12019
|
+
function compileInstanceRules(rules) {
|
|
12020
|
+
if (!rules) {
|
|
12021
|
+
return void 0;
|
|
12022
|
+
}
|
|
12023
|
+
return rules.map(
|
|
12024
|
+
(rule) => [
|
|
12025
|
+
"allow",
|
|
12026
|
+
rule(
|
|
12027
|
+
authDataRef,
|
|
12028
|
+
preMutationRowRef
|
|
12029
|
+
).ast
|
|
12030
|
+
]
|
|
12031
|
+
);
|
|
12032
|
+
}
|
|
12033
|
+
function compileCellConfig(cellRules) {
|
|
12034
|
+
if (!cellRules) {
|
|
12035
|
+
return void 0;
|
|
12036
|
+
}
|
|
12037
|
+
const ret = {};
|
|
12038
|
+
for (const [columnName, rules] of Object.entries(cellRules)) {
|
|
12039
|
+
ret[columnName] = {
|
|
12040
|
+
select: compileInstanceRules(rules.select),
|
|
12041
|
+
insert: compileInstanceRules(rules.insert),
|
|
12042
|
+
update: compileInstanceRules(rules.update),
|
|
12043
|
+
delete: compileInstanceRules(rules.delete)
|
|
12044
|
+
};
|
|
12045
|
+
}
|
|
12046
|
+
return ret;
|
|
12047
|
+
}
|
|
12048
|
+
var authDataRef = new Proxy(
|
|
12049
|
+
{},
|
|
12050
|
+
{
|
|
12051
|
+
get(_target, prop, _receiver) {
|
|
12052
|
+
return staticParam("authData", prop);
|
|
12053
|
+
}
|
|
12054
|
+
}
|
|
12055
|
+
);
|
|
12056
|
+
var preMutationRowRef = new Proxy(
|
|
12057
|
+
{},
|
|
12058
|
+
{
|
|
12059
|
+
get(_target, prop, _receiver) {
|
|
12060
|
+
return staticParam("preMutationRow", prop);
|
|
12061
|
+
}
|
|
12062
|
+
}
|
|
12063
|
+
);
|
|
12064
|
+
|
|
12065
|
+
// ../zero-schema/src/schema.ts
|
|
12066
|
+
function createSchema(schema) {
|
|
12067
|
+
return schema;
|
|
12068
|
+
}
|
|
12069
|
+
|
|
11447
12070
|
// ../zql/src/query/escape-like.ts
|
|
11448
12071
|
function escapeLike(val) {
|
|
11449
12072
|
return val.replace(/[%_]/g, "\\$&");
|
|
@@ -11685,14 +12308,14 @@ var pingMessageSchema = valita_exports.tuple([valita_exports.literal("ping"), pi
|
|
|
11685
12308
|
|
|
11686
12309
|
// ../zero-protocol/src/push.ts
|
|
11687
12310
|
var CRUD_MUTATION_NAME = "_zero_crud";
|
|
11688
|
-
var
|
|
11689
|
-
op: valita_exports.literal("
|
|
12311
|
+
var insertOpSchema = valita_exports.object({
|
|
12312
|
+
op: valita_exports.literal("insert"),
|
|
11690
12313
|
tableName: valita_exports.string(),
|
|
11691
12314
|
primaryKey: primaryKeySchema,
|
|
11692
12315
|
value: rowSchema
|
|
11693
12316
|
});
|
|
11694
|
-
var
|
|
11695
|
-
op: valita_exports.literal("
|
|
12317
|
+
var upsertOpSchema = valita_exports.object({
|
|
12318
|
+
op: valita_exports.literal("upsert"),
|
|
11696
12319
|
tableName: valita_exports.string(),
|
|
11697
12320
|
primaryKey: primaryKeySchema,
|
|
11698
12321
|
value: rowSchema
|
|
@@ -11712,8 +12335,8 @@ var deleteOpSchema = valita_exports.object({
|
|
|
11712
12335
|
value: primaryKeyValueRecordSchema
|
|
11713
12336
|
});
|
|
11714
12337
|
var crudOpSchema = valita_exports.union(
|
|
11715
|
-
|
|
11716
|
-
|
|
12338
|
+
insertOpSchema,
|
|
12339
|
+
upsertOpSchema,
|
|
11717
12340
|
updateOpSchema2,
|
|
11718
12341
|
deleteOpSchema
|
|
11719
12342
|
);
|
|
@@ -13482,6 +14105,8 @@ var MemorySource = class {
|
|
|
13482
14105
|
};
|
|
13483
14106
|
}
|
|
13484
14107
|
connect(sort, optionalFilters) {
|
|
14108
|
+
const filteredOptionalFilters = filterOptionalFilters(optionalFilters);
|
|
14109
|
+
const predicates = filteredOptionalFilters.filters.map((c) => createPredicate(c));
|
|
13485
14110
|
const input = {
|
|
13486
14111
|
getSchema: () => schema,
|
|
13487
14112
|
fetch: (req) => this.#fetch(req, connection),
|
|
@@ -13492,11 +14117,8 @@ var MemorySource = class {
|
|
|
13492
14117
|
destroy: () => {
|
|
13493
14118
|
this.#disconnect(input);
|
|
13494
14119
|
},
|
|
13495
|
-
appliedFilters:
|
|
14120
|
+
appliedFilters: filteredOptionalFilters.allApplied
|
|
13496
14121
|
};
|
|
13497
|
-
const predicates = filteredOptionalFilters(
|
|
13498
|
-
optionalFilters
|
|
13499
|
-
).filters.map((c) => createPredicate(c));
|
|
13500
14122
|
const connection = {
|
|
13501
14123
|
input,
|
|
13502
14124
|
output: void 0,
|
|
@@ -13752,87 +14374,74 @@ function* generateWithOverlay(startAt, rows, constraint, overlay, compare) {
|
|
|
13752
14374
|
yield* generateWithOverlayInner(rows, overlays, compare);
|
|
13753
14375
|
}
|
|
13754
14376
|
function computeOverlays(startAt, constraint, overlay, compare) {
|
|
13755
|
-
let
|
|
13756
|
-
|
|
13757
|
-
|
|
14377
|
+
let overlays = {
|
|
14378
|
+
add: void 0,
|
|
14379
|
+
remove: void 0
|
|
14380
|
+
};
|
|
14381
|
+
switch (overlay?.change.type) {
|
|
14382
|
+
case "add":
|
|
14383
|
+
overlays = {
|
|
14384
|
+
add: overlay.change.row,
|
|
14385
|
+
remove: void 0
|
|
14386
|
+
};
|
|
14387
|
+
break;
|
|
14388
|
+
case "remove":
|
|
14389
|
+
overlays = {
|
|
14390
|
+
add: void 0,
|
|
14391
|
+
remove: overlay.change.row
|
|
14392
|
+
};
|
|
14393
|
+
break;
|
|
14394
|
+
case "edit":
|
|
14395
|
+
overlays = {
|
|
14396
|
+
add: overlay.change.row,
|
|
14397
|
+
remove: overlay.change.oldRow
|
|
14398
|
+
};
|
|
14399
|
+
break;
|
|
13758
14400
|
}
|
|
13759
14401
|
if (startAt) {
|
|
13760
|
-
|
|
13761
|
-
secondOverlay = overlayForStartAt(secondOverlay, startAt, compare);
|
|
14402
|
+
overlays = overlaysForStartAt(overlays, startAt, compare);
|
|
13762
14403
|
}
|
|
13763
14404
|
if (constraint) {
|
|
13764
|
-
|
|
13765
|
-
secondOverlay = overlayForConstraint(secondOverlay, constraint);
|
|
13766
|
-
}
|
|
13767
|
-
if (secondOverlay !== void 0 && overlay === void 0) {
|
|
13768
|
-
overlay = secondOverlay;
|
|
13769
|
-
secondOverlay = void 0;
|
|
14405
|
+
overlays = overlaysForConstraint(overlays, constraint);
|
|
13770
14406
|
}
|
|
13771
|
-
return
|
|
14407
|
+
return overlays;
|
|
13772
14408
|
}
|
|
13773
|
-
function
|
|
13774
|
-
|
|
13775
|
-
|
|
13776
|
-
|
|
13777
|
-
|
|
13778
|
-
return void 0;
|
|
13779
|
-
}
|
|
13780
|
-
return overlay;
|
|
13781
|
-
}
|
|
13782
|
-
function overlayForConstraint(overlay, constraint) {
|
|
13783
|
-
if (!overlay) {
|
|
13784
|
-
return void 0;
|
|
13785
|
-
}
|
|
13786
|
-
if (!valuesEqual(overlay.change.row[constraint.key], constraint.value)) {
|
|
13787
|
-
return void 0;
|
|
13788
|
-
}
|
|
13789
|
-
return overlay;
|
|
13790
|
-
}
|
|
13791
|
-
function splitEditChange(overlay, compare) {
|
|
13792
|
-
const { oldRow, row } = overlay.change;
|
|
13793
|
-
const removeOverlay = {
|
|
13794
|
-
outputIndex: overlay.outputIndex,
|
|
13795
|
-
change: { type: "remove", row: oldRow }
|
|
14409
|
+
function overlaysForStartAt({ add, remove }, startAt, compare) {
|
|
14410
|
+
const undefinedIfBeforeStartAt = (row) => row === void 0 || compare(row, startAt) < 0 ? void 0 : row;
|
|
14411
|
+
return {
|
|
14412
|
+
add: undefinedIfBeforeStartAt(add),
|
|
14413
|
+
remove: undefinedIfBeforeStartAt(remove)
|
|
13796
14414
|
};
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
|
|
14415
|
+
}
|
|
14416
|
+
function overlaysForConstraint({ add, remove }, constraint) {
|
|
14417
|
+
const undefinedIfDoesntMatchConstraint = (row) => row === void 0 || !valuesEqual(row[constraint.key], constraint.value) ? void 0 : row;
|
|
14418
|
+
return {
|
|
14419
|
+
add: undefinedIfDoesntMatchConstraint(add),
|
|
14420
|
+
remove: undefinedIfDoesntMatchConstraint(remove)
|
|
13800
14421
|
};
|
|
13801
|
-
const cmp2 = compare(oldRow, row);
|
|
13802
|
-
assert(cmp2 !== 0, "We should not split edit change with same PK");
|
|
13803
|
-
if (cmp2 < 0) {
|
|
13804
|
-
return [removeOverlay, addOverlay];
|
|
13805
|
-
}
|
|
13806
|
-
return [addOverlay, removeOverlay];
|
|
13807
14422
|
}
|
|
13808
14423
|
function* generateWithOverlayInner(rowIterator, overlays, compare) {
|
|
13809
|
-
let
|
|
14424
|
+
let addOverlayYielded = false;
|
|
14425
|
+
let removeOverlaySkipped = false;
|
|
13810
14426
|
for (const row of rowIterator) {
|
|
13811
|
-
if (
|
|
13812
|
-
|
|
13813
|
-
|
|
13814
|
-
|
|
13815
|
-
|
|
13816
|
-
overlay = secondOverlay;
|
|
13817
|
-
secondOverlay = void 0;
|
|
13818
|
-
}
|
|
14427
|
+
if (!addOverlayYielded && overlays.add) {
|
|
14428
|
+
const cmp2 = compare(overlays.add, row);
|
|
14429
|
+
if (cmp2 < 0) {
|
|
14430
|
+
addOverlayYielded = true;
|
|
14431
|
+
yield { row: overlays.add, relationships: {} };
|
|
13819
14432
|
}
|
|
13820
|
-
|
|
13821
|
-
|
|
13822
|
-
|
|
13823
|
-
|
|
13824
|
-
|
|
13825
|
-
|
|
13826
|
-
overlay = secondOverlay;
|
|
13827
|
-
secondOverlay = void 0;
|
|
13828
|
-
continue;
|
|
13829
|
-
}
|
|
14433
|
+
}
|
|
14434
|
+
if (!removeOverlaySkipped && overlays.remove) {
|
|
14435
|
+
const cmp2 = compare(overlays.remove, row);
|
|
14436
|
+
if (cmp2 === 0) {
|
|
14437
|
+
removeOverlaySkipped = true;
|
|
14438
|
+
continue;
|
|
13830
14439
|
}
|
|
13831
14440
|
}
|
|
13832
14441
|
yield { row, relationships: {} };
|
|
13833
14442
|
}
|
|
13834
|
-
if (
|
|
13835
|
-
yield { row:
|
|
14443
|
+
if (!addOverlayYielded && overlays.add) {
|
|
14444
|
+
yield { row: overlays.add, relationships: {} };
|
|
13836
14445
|
}
|
|
13837
14446
|
}
|
|
13838
14447
|
var minValue = Symbol("min-value");
|
|
@@ -13867,7 +14476,7 @@ function compareBounds(a, b) {
|
|
|
13867
14476
|
}
|
|
13868
14477
|
return compareValues(a, b);
|
|
13869
14478
|
}
|
|
13870
|
-
function
|
|
14479
|
+
function filterOptionalFilters(optionalFilters) {
|
|
13871
14480
|
if (optionalFilters) {
|
|
13872
14481
|
if (optionalFilters.type === "or" && optionalFilters.conditions.length === 1) {
|
|
13873
14482
|
optionalFilters = optionalFilters.conditions[0];
|
|
@@ -14075,7 +14684,7 @@ var ZeroContext = class {
|
|
|
14075
14684
|
function makeCRUDMutate(schema, repMutate) {
|
|
14076
14685
|
const { [CRUD_MUTATION_NAME]: zeroCRUD } = repMutate;
|
|
14077
14686
|
let inBatch = false;
|
|
14078
|
-
const
|
|
14687
|
+
const mutateBatch = async (body) => {
|
|
14079
14688
|
if (inBatch) {
|
|
14080
14689
|
throw new Error("Cannot call mutate inside a batch");
|
|
14081
14690
|
}
|
|
@@ -14098,6 +14707,7 @@ function makeCRUDMutate(schema, repMutate) {
|
|
|
14098
14707
|
throw new Error(`Cannot call mutate.${tableName}.${op} inside a batch`);
|
|
14099
14708
|
}
|
|
14100
14709
|
};
|
|
14710
|
+
const mutate = {};
|
|
14101
14711
|
for (const [name, tableSchema] of Object.entries(schema.tables)) {
|
|
14102
14712
|
mutate[name] = makeEntityCRUDMutate(
|
|
14103
14713
|
name,
|
|
@@ -14106,24 +14716,27 @@ function makeCRUDMutate(schema, repMutate) {
|
|
|
14106
14716
|
assertNotInBatch
|
|
14107
14717
|
);
|
|
14108
14718
|
}
|
|
14109
|
-
return
|
|
14719
|
+
return {
|
|
14720
|
+
mutate,
|
|
14721
|
+
mutateBatch
|
|
14722
|
+
};
|
|
14110
14723
|
}
|
|
14111
14724
|
function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD, assertNotInBatch) {
|
|
14112
14725
|
return {
|
|
14113
|
-
|
|
14114
|
-
assertNotInBatch(tableName, "
|
|
14726
|
+
insert: (value) => {
|
|
14727
|
+
assertNotInBatch(tableName, "insert");
|
|
14115
14728
|
const op = {
|
|
14116
|
-
op: "
|
|
14729
|
+
op: "insert",
|
|
14117
14730
|
tableName,
|
|
14118
14731
|
primaryKey,
|
|
14119
14732
|
value
|
|
14120
14733
|
};
|
|
14121
14734
|
return zeroCRUD({ ops: [op] });
|
|
14122
14735
|
},
|
|
14123
|
-
|
|
14124
|
-
assertNotInBatch(tableName, "
|
|
14736
|
+
upsert: (value) => {
|
|
14737
|
+
assertNotInBatch(tableName, "upsert");
|
|
14125
14738
|
const op = {
|
|
14126
|
-
op: "
|
|
14739
|
+
op: "upsert",
|
|
14127
14740
|
tableName,
|
|
14128
14741
|
primaryKey,
|
|
14129
14742
|
value
|
|
@@ -14155,9 +14768,9 @@ function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD, assertNotInBatch)
|
|
|
14155
14768
|
function makeBatchCRUDMutate(tableName, schema, ops) {
|
|
14156
14769
|
const { primaryKey } = schema.tables[tableName];
|
|
14157
14770
|
return {
|
|
14158
|
-
|
|
14771
|
+
insert: (value) => {
|
|
14159
14772
|
const op = {
|
|
14160
|
-
op: "
|
|
14773
|
+
op: "insert",
|
|
14161
14774
|
tableName,
|
|
14162
14775
|
primaryKey,
|
|
14163
14776
|
value
|
|
@@ -14165,9 +14778,9 @@ function makeBatchCRUDMutate(tableName, schema, ops) {
|
|
|
14165
14778
|
ops.push(op);
|
|
14166
14779
|
return promiseVoid;
|
|
14167
14780
|
},
|
|
14168
|
-
|
|
14781
|
+
upsert: (value) => {
|
|
14169
14782
|
const op = {
|
|
14170
|
-
op: "
|
|
14783
|
+
op: "upsert",
|
|
14171
14784
|
tableName,
|
|
14172
14785
|
primaryKey,
|
|
14173
14786
|
value
|
|
@@ -14201,11 +14814,11 @@ function makeCRUDMutator(schema) {
|
|
|
14201
14814
|
return async function zeroCRUDMutator(tx, crudArg) {
|
|
14202
14815
|
for (const op of crudArg.ops) {
|
|
14203
14816
|
switch (op.op) {
|
|
14204
|
-
case "
|
|
14205
|
-
await
|
|
14817
|
+
case "insert":
|
|
14818
|
+
await insertImpl(tx, op, schema);
|
|
14206
14819
|
break;
|
|
14207
|
-
case "
|
|
14208
|
-
await
|
|
14820
|
+
case "upsert":
|
|
14821
|
+
await upsertImpl(tx, op, schema);
|
|
14209
14822
|
break;
|
|
14210
14823
|
case "update":
|
|
14211
14824
|
await updateImpl(tx, op, schema);
|
|
@@ -14217,23 +14830,40 @@ function makeCRUDMutator(schema) {
|
|
|
14217
14830
|
}
|
|
14218
14831
|
};
|
|
14219
14832
|
}
|
|
14220
|
-
|
|
14833
|
+
function defaultOptionalFieldsToNull(schema, value) {
|
|
14834
|
+
let rv = value;
|
|
14835
|
+
for (const name in schema.columns) {
|
|
14836
|
+
if (rv[name] === void 0) {
|
|
14837
|
+
rv = { ...rv, [name]: null };
|
|
14838
|
+
}
|
|
14839
|
+
}
|
|
14840
|
+
return rv;
|
|
14841
|
+
}
|
|
14842
|
+
async function insertImpl(tx, arg, schema) {
|
|
14221
14843
|
const key = toPrimaryKeyString(
|
|
14222
14844
|
arg.tableName,
|
|
14223
14845
|
schema.tables[arg.tableName].primaryKey,
|
|
14224
14846
|
arg.value
|
|
14225
14847
|
);
|
|
14226
14848
|
if (!await tx.has(key)) {
|
|
14227
|
-
|
|
14849
|
+
const val = defaultOptionalFieldsToNull(
|
|
14850
|
+
schema.tables[arg.tableName],
|
|
14851
|
+
arg.value
|
|
14852
|
+
);
|
|
14853
|
+
await tx.set(key, val);
|
|
14228
14854
|
}
|
|
14229
14855
|
}
|
|
14230
|
-
async function
|
|
14856
|
+
async function upsertImpl(tx, arg, schema) {
|
|
14231
14857
|
const key = toPrimaryKeyString(
|
|
14232
14858
|
arg.tableName,
|
|
14233
14859
|
schema.tables[arg.tableName].primaryKey,
|
|
14234
14860
|
arg.value
|
|
14235
14861
|
);
|
|
14236
|
-
|
|
14862
|
+
const val = defaultOptionalFieldsToNull(
|
|
14863
|
+
schema.tables[arg.tableName],
|
|
14864
|
+
arg.value
|
|
14865
|
+
);
|
|
14866
|
+
await tx.set(key, val);
|
|
14237
14867
|
}
|
|
14238
14868
|
async function updateImpl(tx, arg, schema) {
|
|
14239
14869
|
const key = toPrimaryKeyString(
|
|
@@ -14246,7 +14876,12 @@ async function updateImpl(tx, arg, schema) {
|
|
|
14246
14876
|
return;
|
|
14247
14877
|
}
|
|
14248
14878
|
const update = arg.value;
|
|
14249
|
-
const next = { ...prev
|
|
14879
|
+
const next = { ...prev };
|
|
14880
|
+
for (const k in update) {
|
|
14881
|
+
if (update[k] !== void 0) {
|
|
14882
|
+
next[k] = update[k];
|
|
14883
|
+
}
|
|
14884
|
+
}
|
|
14250
14885
|
await tx.set(key, next);
|
|
14251
14886
|
}
|
|
14252
14887
|
async function deleteImpl(tx, arg, schema) {
|
|
@@ -14277,6 +14912,9 @@ function shouldEnableAnalytics(server, enableAnalytics = true) {
|
|
|
14277
14912
|
function toWSString(url) {
|
|
14278
14913
|
return "ws" + url.slice(4);
|
|
14279
14914
|
}
|
|
14915
|
+
function appendPath(url, toAppend) {
|
|
14916
|
+
return url + (url.endsWith("/") ? toAppend.substring(1) : toAppend);
|
|
14917
|
+
}
|
|
14280
14918
|
|
|
14281
14919
|
// ../zero-client/src/client/log-options.ts
|
|
14282
14920
|
import {
|
|
@@ -14503,7 +15141,7 @@ function makeMessage(message, context, logLevel) {
|
|
|
14503
15141
|
}
|
|
14504
15142
|
|
|
14505
15143
|
// ../zero-client/src/client/version.ts
|
|
14506
|
-
var version2 = "0.
|
|
15144
|
+
var version2 = "0.6.2024111700+e4dfbb";
|
|
14507
15145
|
|
|
14508
15146
|
// ../zero-client/src/client/log-options.ts
|
|
14509
15147
|
var LevelFilterLogSink = class {
|
|
@@ -14537,9 +15175,9 @@ function createLogOptions(options, createDatadogLogSink = (options2) => new Data
|
|
|
14537
15175
|
};
|
|
14538
15176
|
}
|
|
14539
15177
|
const serverURL = new URL(server);
|
|
14540
|
-
const
|
|
14541
|
-
const datadogServiceLabel =
|
|
14542
|
-
const baseURL = new URL("/
|
|
15178
|
+
const { hostname } = serverURL;
|
|
15179
|
+
const datadogServiceLabel = hostname.endsWith(ZERO_SASS_DOMAIN) ? hostname.substring(0, hostname.length - ZERO_SASS_DOMAIN.length).toLowerCase() : hostname;
|
|
15180
|
+
const baseURL = new URL(appendPath(server, "/logs/v0/log"));
|
|
14543
15181
|
const logLevel = consoleLogLevel === "debug" ? "debug" : "info";
|
|
14544
15182
|
const logSink = new TeeLogSink2([
|
|
14545
15183
|
new LevelFilterLogSink(consoleLogSink4, consoleLogLevel),
|
|
@@ -14789,30 +15427,6 @@ var State = class {
|
|
|
14789
15427
|
}
|
|
14790
15428
|
};
|
|
14791
15429
|
|
|
14792
|
-
// ../zero-client/src/client/normalized-schema.ts
|
|
14793
|
-
function normalizeSchema(schema) {
|
|
14794
|
-
if (schema instanceof NormalizedSchema) {
|
|
14795
|
-
return schema;
|
|
14796
|
-
}
|
|
14797
|
-
return new NormalizedSchema(schema);
|
|
14798
|
-
}
|
|
14799
|
-
var NormalizedSchema = class {
|
|
14800
|
-
version;
|
|
14801
|
-
tables;
|
|
14802
|
-
constructor(schema) {
|
|
14803
|
-
this.version = schema.version;
|
|
14804
|
-
this.tables = normalizeTables(schema.tables);
|
|
14805
|
-
}
|
|
14806
|
-
};
|
|
14807
|
-
function normalizeTables(tables) {
|
|
14808
|
-
const rv = {};
|
|
14809
|
-
const tableSchemaCache = /* @__PURE__ */ new Map();
|
|
14810
|
-
for (const [name, table] of sortedEntries(tables)) {
|
|
14811
|
-
rv[name] = normalizeTableSchemaWithCache(table, name, tableSchemaCache);
|
|
14812
|
-
}
|
|
14813
|
-
return rv;
|
|
14814
|
-
}
|
|
14815
|
-
|
|
14816
15430
|
// ../zero-client/src/client/query-manager.ts
|
|
14817
15431
|
var QueryManager = class {
|
|
14818
15432
|
#clientID;
|
|
@@ -14993,7 +15607,7 @@ function isAuthErrorKind(kind) {
|
|
|
14993
15607
|
// ../zero-client/src/client/server-option.ts
|
|
14994
15608
|
function validateServerParam(paramName, server) {
|
|
14995
15609
|
const expectedProtocol = "http";
|
|
14996
|
-
const forExample = () => ` For example: "${expectedProtocol}s://myapp-myteam.zero.ms
|
|
15610
|
+
const forExample = (path2 = "") => ` For example: "${expectedProtocol}s://myapp-myteam.zero.ms/${path2}".`;
|
|
14997
15611
|
if (!server.startsWith(`${expectedProtocol}://`) && !server.startsWith(`${expectedProtocol}s://`)) {
|
|
14998
15612
|
throw new Error(
|
|
14999
15613
|
`ZeroOptions.${paramName} must use the "${expectedProtocol}" or "${expectedProtocol}s" scheme.`
|
|
@@ -15008,9 +15622,18 @@ function validateServerParam(paramName, server) {
|
|
|
15008
15622
|
);
|
|
15009
15623
|
}
|
|
15010
15624
|
const urlString = url.toString();
|
|
15011
|
-
|
|
15625
|
+
const pathComponents = url.pathname.split("/");
|
|
15626
|
+
if (pathComponents[0] === "") {
|
|
15627
|
+
pathComponents.shift();
|
|
15628
|
+
}
|
|
15629
|
+
if (pathComponents[pathComponents.length - 1] === "") {
|
|
15630
|
+
pathComponents.pop();
|
|
15631
|
+
}
|
|
15632
|
+
if (pathComponents.length > 1) {
|
|
15012
15633
|
throw new Error(
|
|
15013
|
-
`ZeroOptions.${paramName}
|
|
15634
|
+
`ZeroOptions.${paramName} may have at most one path component.${forExample(
|
|
15635
|
+
"zero"
|
|
15636
|
+
)}`
|
|
15014
15637
|
);
|
|
15015
15638
|
}
|
|
15016
15639
|
for (const [property, invalidEndsWith] of [
|
|
@@ -15050,6 +15673,7 @@ var PokeHandler = class {
|
|
|
15050
15673
|
// order poke errors.
|
|
15051
15674
|
#pokeLock = new Lock3();
|
|
15052
15675
|
#schema;
|
|
15676
|
+
#raf = getBrowserGlobalMethod("requestAnimationFrame") ?? rafFallback;
|
|
15053
15677
|
constructor(replicachePoke, onPokeError, clientID, schema, lc) {
|
|
15054
15678
|
this.#replicachePoke = replicachePoke;
|
|
15055
15679
|
this.#onPokeError = onPokeError;
|
|
@@ -15107,7 +15731,7 @@ var PokeHandler = class {
|
|
|
15107
15731
|
#startPlaybackLoop() {
|
|
15108
15732
|
this.#lc.debug?.("starting playback loop");
|
|
15109
15733
|
this.#pokePlaybackLoopRunning = true;
|
|
15110
|
-
|
|
15734
|
+
this.#raf(this.#rafCallback);
|
|
15111
15735
|
}
|
|
15112
15736
|
#rafCallback = async () => {
|
|
15113
15737
|
const rafLC = this.#lc.withContext("rafAt", Math.floor(performance.now()));
|
|
@@ -15116,7 +15740,7 @@ var PokeHandler = class {
|
|
|
15116
15740
|
this.#pokePlaybackLoopRunning = false;
|
|
15117
15741
|
return;
|
|
15118
15742
|
}
|
|
15119
|
-
|
|
15743
|
+
this.#raf(this.#rafCallback);
|
|
15120
15744
|
const start = performance.now();
|
|
15121
15745
|
rafLC.debug?.(
|
|
15122
15746
|
"raf fired, processing pokes. Since last raf",
|
|
@@ -15305,6 +15929,12 @@ function rowsPatchOpToReplicachePatchOp(op, schema) {
|
|
|
15305
15929
|
throw new Error("to be implemented");
|
|
15306
15930
|
}
|
|
15307
15931
|
}
|
|
15932
|
+
function rafFallback(callback) {
|
|
15933
|
+
setTimeout(callback, 0);
|
|
15934
|
+
}
|
|
15935
|
+
|
|
15936
|
+
// ../zero-client/src/client/protocol-version.ts
|
|
15937
|
+
var PROTOCOL_VERSION = 1;
|
|
15308
15938
|
|
|
15309
15939
|
// ../zero-client/src/client/zero.ts
|
|
15310
15940
|
var onSetConnectionStateSymbol = Symbol();
|
|
@@ -15318,7 +15948,6 @@ var DEFAULT_DISCONNECT_HIDDEN_DELAY_MS = 5e3;
|
|
|
15318
15948
|
var CONNECT_TIMEOUT_MS = 1e4;
|
|
15319
15949
|
var CHECK_CONNECTIVITY_ON_ERROR_FREQUENCY = 6;
|
|
15320
15950
|
var NULL_LAST_MUTATION_ID_SENT = { clientID: "", id: -1 };
|
|
15321
|
-
var REFLECT_VERSION = 1;
|
|
15322
15951
|
function convertOnUpdateNeededReason(reason) {
|
|
15323
15952
|
return { type: reason.type };
|
|
15324
15953
|
}
|
|
@@ -15502,7 +16131,8 @@ var Zero = class {
|
|
|
15502
16131
|
const server = getServer(options.server);
|
|
15503
16132
|
this.#enableAnalytics = shouldEnableAnalytics(
|
|
15504
16133
|
server,
|
|
15505
|
-
|
|
16134
|
+
false
|
|
16135
|
+
// Reenable analytics
|
|
15506
16136
|
);
|
|
15507
16137
|
if (jurisdiction !== void 0 && jurisdiction !== "eu") {
|
|
15508
16138
|
throw new Error('ZeroOptions.jurisdiction must be "eu" if present.');
|
|
@@ -15572,7 +16202,12 @@ var Zero = class {
|
|
|
15572
16202
|
reason ?? ON_CLIENT_STATE_NOT_FOUND_REASON_CLIENT
|
|
15573
16203
|
);
|
|
15574
16204
|
};
|
|
15575
|
-
|
|
16205
|
+
const { mutate, mutateBatch } = makeCRUDMutate(
|
|
16206
|
+
normalizedSchema,
|
|
16207
|
+
rep.mutate
|
|
16208
|
+
);
|
|
16209
|
+
this.mutate = mutate;
|
|
16210
|
+
this.mutateBatch = mutateBatch;
|
|
15576
16211
|
this.#queryManager = new QueryManager(
|
|
15577
16212
|
rep.clientID,
|
|
15578
16213
|
(msg) => this.#sendChangeDesiredQueries(msg),
|
|
@@ -15666,30 +16301,42 @@ var Zero = class {
|
|
|
15666
16301
|
return this.#rep.clientGroupID;
|
|
15667
16302
|
}
|
|
15668
16303
|
/**
|
|
15669
|
-
* Provides
|
|
16304
|
+
* Provides simple "CRUD" mutations for the tables in the schema.
|
|
15670
16305
|
*
|
|
15671
|
-
*
|
|
15672
|
-
* mutations. When used as a function it is used to batch multiple mutations.
|
|
16306
|
+
* Each table has `create`, `set`, `update`, and `delete` methods.
|
|
15673
16307
|
*
|
|
15674
16308
|
* ```ts
|
|
15675
|
-
* await zero.mutate.issue.create({id: '1', title: 'First issue'});
|
|
16309
|
+
* await zero.mutate.issue.create({id: '1', title: 'First issue', priority: 'high'});
|
|
15676
16310
|
* await zero.mutate.comment.create({id: '1', text: 'First comment', issueID: '1'});
|
|
16311
|
+
* ```
|
|
16312
|
+
*
|
|
16313
|
+
* The `update` methods support partials. Unspecified or `undefined` fields
|
|
16314
|
+
* are left unchanged:
|
|
15677
16315
|
*
|
|
15678
|
-
*
|
|
15679
|
-
*
|
|
16316
|
+
* ```ts
|
|
16317
|
+
* // Priority left unchanged.
|
|
16318
|
+
* await zero.mutate.issue.update({id: '1', title: 'Updated title'});
|
|
16319
|
+
* ```
|
|
16320
|
+
*/
|
|
16321
|
+
mutate;
|
|
16322
|
+
/**
|
|
16323
|
+
* Provides a way to batch multiple CRUD mutations together:
|
|
16324
|
+
*
|
|
16325
|
+
* ```ts
|
|
16326
|
+
* await zero.mutateBatch(m => {
|
|
15680
16327
|
* await m.issue.create({id: '1', title: 'First issue'});
|
|
15681
16328
|
* await m.comment.create({id: '1', text: 'First comment', issueID: '1'});
|
|
15682
16329
|
* });
|
|
15683
16330
|
* ```
|
|
15684
16331
|
*
|
|
15685
|
-
*
|
|
15686
|
-
*
|
|
15687
|
-
* individual
|
|
16332
|
+
* Batch sends all mutations in a single transaction. If one fails, all are
|
|
16333
|
+
* rolled back together. Batch can also be more efficient than making many
|
|
16334
|
+
* individual mutations.
|
|
15688
16335
|
*
|
|
15689
|
-
*
|
|
15690
|
-
*
|
|
16336
|
+
* `mutateBatch` is not allowed inside another `mutateBatch` call. Doing so
|
|
16337
|
+
* will throw an error.
|
|
15691
16338
|
*/
|
|
15692
|
-
|
|
16339
|
+
mutateBatch;
|
|
15693
16340
|
/**
|
|
15694
16341
|
* Whether this Zero instance has been closed. Once a Zero instance has
|
|
15695
16342
|
* been closed it no longer syncs and you can no longer read or write data out
|
|
@@ -15760,11 +16407,8 @@ var Zero = class {
|
|
|
15760
16407
|
rejectInvalidMessage();
|
|
15761
16408
|
}
|
|
15762
16409
|
};
|
|
15763
|
-
#onOpen = (
|
|
15764
|
-
const l = addWebSocketIDFromSocketToLogContext(
|
|
15765
|
-
e.target,
|
|
15766
|
-
this.#lc
|
|
15767
|
-
);
|
|
16410
|
+
#onOpen = () => {
|
|
16411
|
+
const l = addWebSocketIDFromSocketToLogContext(this.#socket, this.#lc);
|
|
15768
16412
|
if (this.#connectStart === void 0) {
|
|
15769
16413
|
l.error?.(
|
|
15770
16414
|
"Got open event but connect start time is undefined. This should not happen."
|
|
@@ -15779,10 +16423,7 @@ var Zero = class {
|
|
|
15779
16423
|
}
|
|
15780
16424
|
};
|
|
15781
16425
|
#onClose = (e) => {
|
|
15782
|
-
const l = addWebSocketIDFromSocketToLogContext(
|
|
15783
|
-
e.target,
|
|
15784
|
-
this.#lc
|
|
15785
|
-
);
|
|
16426
|
+
const l = addWebSocketIDFromSocketToLogContext(this.#socket, this.#lc);
|
|
15786
16427
|
const { code, reason, wasClean } = e;
|
|
15787
16428
|
l.info?.("Got socket close event", { code, reason, wasClean });
|
|
15788
16429
|
const closeKind = wasClean ? "CleanClose" : "AbruptClose";
|
|
@@ -16264,16 +16905,6 @@ var Zero = class {
|
|
|
16264
16905
|
}
|
|
16265
16906
|
if (gotError) {
|
|
16266
16907
|
this.#setOnline(false);
|
|
16267
|
-
let cfGetCheckSucceeded = false;
|
|
16268
|
-
const cfGetCheckURL = new URL(this.#server);
|
|
16269
|
-
cfGetCheckURL.pathname = "/api/canary/v0/get";
|
|
16270
|
-
cfGetCheckURL.searchParams.set("id", nanoid());
|
|
16271
|
-
const cfGetCheckController = new AbortController();
|
|
16272
|
-
fetch(cfGetCheckURL, { signal: cfGetCheckController.signal }).then((_) => {
|
|
16273
|
-
cfGetCheckSucceeded = true;
|
|
16274
|
-
}).catch((_) => {
|
|
16275
|
-
cfGetCheckSucceeded = false;
|
|
16276
|
-
});
|
|
16277
16908
|
lc.debug?.(
|
|
16278
16909
|
"Sleeping",
|
|
16279
16910
|
RUN_LOOP_INTERVAL_MS,
|
|
@@ -16281,13 +16912,6 @@ var Zero = class {
|
|
|
16281
16912
|
this.#connectionState
|
|
16282
16913
|
);
|
|
16283
16914
|
await sleep(RUN_LOOP_INTERVAL_MS);
|
|
16284
|
-
cfGetCheckController.abort();
|
|
16285
|
-
if (!cfGetCheckSucceeded) {
|
|
16286
|
-
lc.info?.(
|
|
16287
|
-
"Canary request failed, resetting total time to connect start time."
|
|
16288
|
-
);
|
|
16289
|
-
this.#totalToConnectStart = void 0;
|
|
16290
|
-
}
|
|
16291
16915
|
}
|
|
16292
16916
|
}
|
|
16293
16917
|
}
|
|
@@ -16420,8 +17044,9 @@ var Zero = class {
|
|
|
16420
17044
|
}
|
|
16421
17045
|
};
|
|
16422
17046
|
async function createSocket(rep, queryManager, socketOrigin, baseCookie, clientID, clientGroupID, schemaVersion, userID, auth, jurisdiction, lmid, wsid, debugPerf, lc, maxHeaderLength = 1024 * 8) {
|
|
16423
|
-
const url = new URL(
|
|
16424
|
-
|
|
17047
|
+
const url = new URL(
|
|
17048
|
+
appendPath(socketOrigin, `/sync/v${PROTOCOL_VERSION}/connect`)
|
|
17049
|
+
);
|
|
16425
17050
|
const { searchParams } = url;
|
|
16426
17051
|
searchParams.set("clientID", clientID);
|
|
16427
17052
|
searchParams.set("clientGroupID", clientGroupID);
|
|
@@ -16484,12 +17109,10 @@ export {
|
|
|
16484
17109
|
makeIDBName,
|
|
16485
17110
|
dropDatabase,
|
|
16486
17111
|
dropAllDatabases,
|
|
16487
|
-
|
|
16488
|
-
|
|
16489
|
-
|
|
16490
|
-
not,
|
|
16491
|
-
QueryImpl,
|
|
17112
|
+
createTableSchema,
|
|
17113
|
+
defineAuthorization,
|
|
17114
|
+
createSchema,
|
|
16492
17115
|
escapeLike,
|
|
16493
17116
|
Zero
|
|
16494
17117
|
};
|
|
16495
|
-
//# sourceMappingURL=chunk-
|
|
17118
|
+
//# sourceMappingURL=chunk-PIFWXXO2.js.map
|