@rocicorp/zero 1.6.0-canary.12 → 1.6.0-canary.13
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/README.md +3 -28
- package/out/_virtual/{_@oxc-project_runtime@0.130.0 → _@oxc-project_runtime@0.122.0}/helpers/usingCtx.js +1 -1
- package/out/analyze-query/src/analyze-cli.js +3 -3
- package/out/analyze-query/src/analyze-cli.js.map +1 -1
- package/out/analyze-query/src/bin-analyze.js +1 -6
- package/out/analyze-query/src/bin-analyze.js.map +1 -1
- package/out/analyze-query/src/bin-transform.js.map +1 -1
- package/out/ast-to-zql/src/ast-to-zql.js.map +1 -1
- package/out/ast-to-zql/src/bin.js.map +1 -1
- package/out/ast-to-zql/src/format.js.map +1 -1
- package/out/datadog/src/datadog-log-sink.js.map +1 -1
- package/out/otel/src/enabled.js.map +1 -1
- package/out/otel/src/log-options.js.map +1 -1
- package/out/otel/src/maybe-time.js.map +1 -1
- package/out/otel/src/span.js.map +1 -1
- package/out/replicache/src/async-iterable-to-array.js.map +1 -1
- package/out/replicache/src/bg-interval.js.map +1 -1
- package/out/replicache/src/btree/diff.js.map +1 -1
- package/out/replicache/src/btree/node.js.map +1 -1
- package/out/replicache/src/btree/read.js.map +1 -1
- package/out/replicache/src/btree/splice.js.map +1 -1
- package/out/replicache/src/btree/write.js +3 -6
- package/out/replicache/src/btree/write.js.map +1 -1
- package/out/replicache/src/call-default-fetch.js.map +1 -1
- package/out/replicache/src/connection-loop-delegates.js.map +1 -1
- package/out/replicache/src/connection-loop.js.map +1 -1
- package/out/replicache/src/cookies.js.map +1 -1
- package/out/replicache/src/dag/chunk.js.map +1 -1
- package/out/replicache/src/dag/gc.js.map +1 -1
- package/out/replicache/src/dag/key.js.map +1 -1
- package/out/replicache/src/dag/lazy-store.js.map +1 -1
- package/out/replicache/src/dag/store-impl.js.map +1 -1
- package/out/replicache/src/dag/store.js.map +1 -1
- package/out/replicache/src/dag/visitor.js.map +1 -1
- package/out/replicache/src/db/commit.js.map +1 -1
- package/out/replicache/src/db/index.js.map +1 -1
- package/out/replicache/src/db/read.js.map +1 -1
- package/out/replicache/src/db/rebase.js.map +1 -1
- package/out/replicache/src/db/write.js.map +1 -1
- package/out/replicache/src/deleted-clients.js.map +1 -1
- package/out/replicache/src/error-responses.js.map +1 -1
- package/out/replicache/src/frozen-json.js.map +1 -1
- package/out/replicache/src/get-default-puller.js.map +1 -1
- package/out/replicache/src/get-default-pusher.js.map +1 -1
- package/out/replicache/src/get-kv-store-provider.js.map +1 -1
- package/out/replicache/src/hash.js.map +1 -1
- package/out/replicache/src/http-request-info.js.map +1 -1
- package/out/replicache/src/index-defs.js.map +1 -1
- package/out/replicache/src/kv/expo-sqlite/store.js.map +1 -1
- package/out/replicache/src/kv/idb-store-with-mem-fallback.js.map +1 -1
- package/out/replicache/src/kv/idb-store.js.map +1 -1
- package/out/replicache/src/kv/mem-store.js.map +1 -1
- package/out/replicache/src/kv/op-sqlite/store.js.map +1 -1
- package/out/replicache/src/kv/read-impl.js.map +1 -1
- package/out/replicache/src/kv/sqlite-store.d.ts.map +1 -1
- package/out/replicache/src/kv/sqlite-store.js +1 -4
- package/out/replicache/src/kv/sqlite-store.js.map +1 -1
- package/out/replicache/src/kv/throw-if-closed.js.map +1 -1
- package/out/replicache/src/kv/write-impl-base.js.map +1 -1
- package/out/replicache/src/kv/write-impl.js.map +1 -1
- package/out/replicache/src/lazy.js.map +1 -1
- package/out/replicache/src/log-options.js.map +1 -1
- package/out/replicache/src/make-idb-name.js.map +1 -1
- package/out/replicache/src/new-client-channel.js.map +1 -1
- package/out/replicache/src/on-persist-channel.js.map +1 -1
- package/out/replicache/src/patch-operation.js.map +1 -1
- package/out/replicache/src/pending-mutations.js.map +1 -1
- package/out/replicache/src/persist/client-gc.js.map +1 -1
- package/out/replicache/src/persist/client-group-gc.js.map +1 -1
- package/out/replicache/src/persist/client-groups.js +0 -40
- package/out/replicache/src/persist/client-groups.js.map +1 -1
- package/out/replicache/src/persist/clients.js +0 -28
- package/out/replicache/src/persist/clients.js.map +1 -1
- package/out/replicache/src/persist/collect-idb-databases.js.map +1 -1
- package/out/replicache/src/persist/gather-mem-only-visitor.js.map +1 -1
- package/out/replicache/src/persist/gather-not-cached-visitor.js.map +1 -1
- package/out/replicache/src/persist/heartbeat.js.map +1 -1
- package/out/replicache/src/persist/idb-databases-store-db-name.js.map +1 -1
- package/out/replicache/src/persist/idb-databases-store.js.map +1 -1
- package/out/replicache/src/persist/make-client-id.js.map +1 -1
- package/out/replicache/src/persist/persist.js.map +1 -1
- package/out/replicache/src/persist/refresh.js.map +1 -1
- package/out/replicache/src/process-scheduler.js.map +1 -1
- package/out/replicache/src/pusher.js.map +1 -1
- package/out/replicache/src/replicache-impl.js.map +1 -1
- package/out/replicache/src/report-error.js.map +1 -1
- package/out/replicache/src/request-idle.js.map +1 -1
- package/out/replicache/src/scan-iterator.js.map +1 -1
- package/out/replicache/src/scan-options.js.map +1 -1
- package/out/replicache/src/set-interval-with-signal.js.map +1 -1
- package/out/replicache/src/subscriptions.js.map +1 -1
- package/out/replicache/src/sync/diff.js.map +1 -1
- package/out/replicache/src/sync/ids.js.map +1 -1
- package/out/replicache/src/sync/patch.js.map +1 -1
- package/out/replicache/src/sync/pull-error.js.map +1 -1
- package/out/replicache/src/sync/pull.js.map +1 -1
- package/out/replicache/src/sync/push.js.map +1 -1
- package/out/replicache/src/sync/request-id.js.map +1 -1
- package/out/replicache/src/to-error.js.map +1 -1
- package/out/replicache/src/transaction-closed-error.js.map +1 -1
- package/out/replicache/src/transactions.js.map +1 -1
- package/out/replicache/src/with-transactions.js.map +1 -1
- package/out/shared/src/abort-error.js.map +1 -1
- package/out/shared/src/arrays.js.map +1 -1
- package/out/shared/src/asserts.js.map +1 -1
- package/out/shared/src/bigint-json.js.map +1 -1
- package/out/shared/src/binary-search.js.map +1 -1
- package/out/shared/src/broadcast-channel.js.map +1 -1
- package/out/shared/src/browser-env.js.map +1 -1
- package/out/shared/src/btree-set.js.map +1 -1
- package/out/shared/src/cache.js.map +1 -1
- package/out/shared/src/centroid.js.map +1 -1
- package/out/shared/src/custom-key-map.js.map +1 -1
- package/out/shared/src/custom-key-set.js.map +1 -1
- package/out/shared/src/deep-clone.js.map +1 -1
- package/out/shared/src/deep-merge.js.map +1 -1
- package/out/shared/src/document-visible.js.map +1 -1
- package/out/shared/src/dotenv.js.map +1 -1
- package/out/shared/src/error.js.map +1 -1
- package/out/shared/src/hash.js.map +1 -1
- package/out/shared/src/iterables.d.ts +0 -2
- package/out/shared/src/iterables.d.ts.map +1 -1
- package/out/shared/src/iterables.js +1 -9
- package/out/shared/src/iterables.js.map +1 -1
- package/out/shared/src/json-schema.js.map +1 -1
- package/out/shared/src/json.js.map +1 -1
- package/out/shared/src/logging-test-utils.js.map +1 -1
- package/out/shared/src/logging.js.map +1 -1
- package/out/shared/src/map.js.map +1 -1
- package/out/shared/src/must.js.map +1 -1
- package/out/shared/src/object-traversal.js.map +1 -1
- package/out/shared/src/objects.js.map +1 -1
- package/out/shared/src/options.js.map +1 -1
- package/out/shared/src/parse-big-int.js.map +1 -1
- package/out/shared/src/promise-race.js.map +1 -1
- package/out/shared/src/queue.d.ts.map +1 -1
- package/out/shared/src/queue.js +21 -15
- package/out/shared/src/queue.js.map +1 -1
- package/out/shared/src/rand.js.map +1 -1
- package/out/shared/src/random-uint64.js.map +1 -1
- package/out/shared/src/random-values.js.map +1 -1
- package/out/shared/src/record-proxy.js.map +1 -1
- package/out/shared/src/resolved-promises.js.map +1 -1
- package/out/shared/src/sentinels.js.map +1 -1
- package/out/shared/src/set-utils.js.map +1 -1
- package/out/shared/src/size-of-value.js.map +1 -1
- package/out/shared/src/sleep.js.map +1 -1
- package/out/shared/src/sorted-entries.js.map +1 -1
- package/out/shared/src/string-compare.js.map +1 -1
- package/out/shared/src/subscribable.js.map +1 -1
- package/out/shared/src/tdigest-schema.js.map +1 -1
- package/out/shared/src/tdigest.js.map +1 -1
- package/out/shared/src/valita.js.map +1 -1
- package/out/z2s/src/compiler.js.map +1 -1
- package/out/z2s/src/sql.js.map +1 -1
- package/out/zero/package.js +26 -34
- package/out/zero/package.js.map +1 -1
- package/out/zero/src/build-schema.js.map +1 -1
- package/out/zero/src/zero-cache-dev.js.map +1 -1
- package/out/zero/src/zero-out.js.map +1 -1
- package/out/zero-cache/src/auth/auth.js.map +1 -1
- package/out/zero-cache/src/auth/jwt.js.map +1 -1
- package/out/zero-cache/src/auth/load-permissions.js.map +1 -1
- package/out/zero-cache/src/auth/read-authorizer.js.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
- package/out/zero-cache/src/config/network.js.map +1 -1
- package/out/zero-cache/src/config/normalize.js.map +1 -1
- package/out/zero-cache/src/config/server-context.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +0 -5
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/custom/fetch.js.map +1 -1
- package/out/zero-cache/src/custom-queries/transform-query.js.map +1 -1
- package/out/zero-cache/src/db/create.js.map +1 -1
- package/out/zero-cache/src/db/delete-lite-db.js.map +1 -1
- package/out/zero-cache/src/db/lite-tables.js.map +1 -1
- package/out/zero-cache/src/db/migration-lite.js +0 -19
- package/out/zero-cache/src/db/migration-lite.js.map +1 -1
- package/out/zero-cache/src/db/migration.js +0 -19
- package/out/zero-cache/src/db/migration.js.map +1 -1
- package/out/zero-cache/src/db/pg-copy-binary.js.map +1 -1
- package/out/zero-cache/src/db/pg-copy.js.map +1 -1
- package/out/zero-cache/src/db/pg-to-lite.js.map +1 -1
- package/out/zero-cache/src/db/pg-type-parser.js.map +1 -1
- package/out/zero-cache/src/db/run-transaction.js.map +1 -1
- package/out/zero-cache/src/db/specs.js.map +1 -1
- package/out/zero-cache/src/db/statements.js.map +1 -1
- package/out/zero-cache/src/db/transaction-pool.js.map +1 -1
- package/out/zero-cache/src/db/warmup.js.map +1 -1
- package/out/zero-cache/src/observability/events.js.map +1 -1
- package/out/zero-cache/src/observability/metrics.js.map +1 -1
- package/out/zero-cache/src/scripts/decommission.js.map +1 -1
- package/out/zero-cache/src/scripts/deploy-permissions.js.map +1 -1
- package/out/zero-cache/src/scripts/permissions.d.ts.map +1 -1
- package/out/zero-cache/src/scripts/permissions.js +2 -1
- package/out/zero-cache/src/scripts/permissions.js.map +1 -1
- package/out/zero-cache/src/server/anonymous-otel-start.js +7 -8
- package/out/zero-cache/src/server/anonymous-otel-start.js.map +1 -1
- package/out/zero-cache/src/server/change-streamer.js.map +1 -1
- package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
- package/out/zero-cache/src/server/logging.js.map +1 -1
- package/out/zero-cache/src/server/main.js.map +1 -1
- package/out/zero-cache/src/server/mutator.js.map +1 -1
- package/out/zero-cache/src/server/otel-diag-logger.js.map +1 -1
- package/out/zero-cache/src/server/otel-log-sink.js.map +1 -1
- package/out/zero-cache/src/server/otel-start.js.map +1 -1
- package/out/zero-cache/src/server/priority-op.js.map +1 -1
- package/out/zero-cache/src/server/reaper.js.map +1 -1
- package/out/zero-cache/src/server/replicator.js.map +1 -1
- package/out/zero-cache/src/server/runner/main.js.map +1 -1
- package/out/zero-cache/src/server/runner/run-worker.js.map +1 -1
- package/out/zero-cache/src/server/runner/runtime.js.map +1 -1
- package/out/zero-cache/src/server/runner/zero-dispatcher.js.map +1 -1
- package/out/zero-cache/src/server/shadow-syncer.js.map +1 -1
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/server/worker-dispatcher.js.map +1 -1
- package/out/zero-cache/src/server/worker-urls.js.map +1 -1
- package/out/zero-cache/src/services/analyze.d.ts.map +1 -1
- package/out/zero-cache/src/services/analyze.js +2 -5
- package/out/zero-cache/src/services/analyze.js.map +1 -1
- package/out/zero-cache/src/services/change-source/common/backfill-manager.js.map +1 -1
- package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js.map +1 -1
- package/out/zero-cache/src/services/change-source/common/replica-schema.js.map +1 -1
- package/out/zero-cache/src/services/change-source/custom/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/backfill-metadata.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/backfill-stream.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/decommission.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/logical-replication/pgoutput-parser.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/lsn.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/replication-slots.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/published.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/validation.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/control.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/data.js +0 -2
- package/out/zero-cache/src/services/change-source/protocol/current/data.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/downstream.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/json.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/status.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/upstream.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/backup-monitor.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/broadcast.js.map +1 -1
- 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.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/forwarder.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/replica-monitor.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/init.js +25 -21
- package/out/zero-cache/src/services/change-streamer/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/tables.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/snapshot.js +0 -15
- package/out/zero-cache/src/services/change-streamer/snapshot.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/subscriber.js.map +1 -1
- package/out/zero-cache/src/services/heapz.js.map +1 -1
- package/out/zero-cache/src/services/http-service.js.map +1 -1
- package/out/zero-cache/src/services/life-cycle.js.map +1 -1
- package/out/zero-cache/src/services/limiter/sliding-window-limiter.js.map +1 -1
- package/out/zero-cache/src/services/litestream/commands.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/error.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
- package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.js.map +1 -1
- package/out/zero-cache/src/services/replicator/notifier.js.map +1 -1
- package/out/zero-cache/src/services/replicator/replication-status.js.map +1 -1
- package/out/zero-cache/src/services/replicator/replicator.js.map +1 -1
- package/out/zero-cache/src/services/replicator/reporter/recorder.js.map +1 -1
- package/out/zero-cache/src/services/replicator/reporter/report-schema.js.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/change-log.js.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/column-metadata.js.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/replication-state.js.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/table-metadata.js.map +1 -1
- package/out/zero-cache/src/services/replicator/write-worker-client.js.map +1 -1
- package/out/zero-cache/src/services/replicator/write-worker.js.map +1 -1
- package/out/zero-cache/src/services/run-ast.d.ts.map +1 -1
- package/out/zero-cache/src/services/run-ast.js +0 -1
- package/out/zero-cache/src/services/run-ast.js.map +1 -1
- package/out/zero-cache/src/services/runner.js.map +1 -1
- package/out/zero-cache/src/services/running-state.js.map +1 -1
- package/out/zero-cache/src/services/shadow-sync/shadow-sync-service.js.map +1 -1
- package/out/zero-cache/src/services/statz.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/active-users-gauge.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-schema.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/connection-context-manager.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-purger.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-purger.js +1 -2
- package/out/zero-cache/src/services/view-syncer/cvr-purger.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.js +1 -2
- package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/drain-coordinator.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts +14 -0
- package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/inspect-handler.js +25 -2
- package/out/zero-cache/src/services/view-syncer/inspect-handler.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/row-record-cache.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/row-set-signature.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/init.js +113 -97
- package/out/zero-cache/src/services/view-syncer/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/types.js +1 -103
- package/out/zero-cache/src/services/view-syncer/schema/types.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/snapshotter.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/tracer.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/ttl-clock.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.js +1 -4
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/configuration-error.js.map +1 -1
- package/out/zero-cache/src/types/error-with-level.js.map +1 -1
- package/out/zero-cache/src/types/http.js.map +1 -1
- package/out/zero-cache/src/types/lexi-version.js.map +1 -1
- package/out/zero-cache/src/types/lite.js.map +1 -1
- package/out/zero-cache/src/types/names.js.map +1 -1
- package/out/zero-cache/src/types/pg-data-type.js.map +1 -1
- package/out/zero-cache/src/types/pg.js.map +1 -1
- package/out/zero-cache/src/types/processes.js.map +1 -1
- package/out/zero-cache/src/types/profiler.js.map +1 -1
- package/out/zero-cache/src/types/row-key.js.map +1 -1
- package/out/zero-cache/src/types/shards.js.map +1 -1
- package/out/zero-cache/src/types/sql.js.map +1 -1
- package/out/zero-cache/src/types/state-version.js.map +1 -1
- package/out/zero-cache/src/types/streams.js.map +1 -1
- package/out/zero-cache/src/types/strings.js.map +1 -1
- package/out/zero-cache/src/types/subscription.js.map +1 -1
- package/out/zero-cache/src/types/timeout.js.map +1 -1
- package/out/zero-cache/src/types/url-params.js.map +1 -1
- package/out/zero-cache/src/types/websocket-handoff.js.map +1 -1
- package/out/zero-cache/src/types/ws.js.map +1 -1
- package/out/zero-cache/src/workers/connect-params.js.map +1 -1
- package/out/zero-cache/src/workers/connection.js.map +1 -1
- package/out/zero-cache/src/workers/mutator.js.map +1 -1
- package/out/zero-cache/src/workers/replicator.js.map +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
- package/out/zero-cache/src/workers/syncer.js.map +1 -1
- package/out/zero-client/src/client/active-clients-manager.js.map +1 -1
- package/out/zero-client/src/client/connection-manager.js +1 -2
- package/out/zero-client/src/client/connection-manager.js.map +1 -1
- package/out/zero-client/src/client/connection.js.map +1 -1
- package/out/zero-client/src/client/context.js.map +1 -1
- package/out/zero-client/src/client/crud-impl.js.map +1 -1
- package/out/zero-client/src/client/crud.js.map +1 -1
- package/out/zero-client/src/client/custom.js +1 -2
- package/out/zero-client/src/client/custom.js.map +1 -1
- package/out/zero-client/src/client/delete-clients-manager.js.map +1 -1
- package/out/zero-client/src/client/enable-analytics.js.map +1 -1
- package/out/zero-client/src/client/error.js.map +1 -1
- package/out/zero-client/src/client/http-string.js.map +1 -1
- package/out/zero-client/src/client/inspector/client-group.js.map +1 -1
- package/out/zero-client/src/client/inspector/client.js.map +1 -1
- package/out/zero-client/src/client/inspector/html-dialog-prompt.js.map +1 -1
- package/out/zero-client/src/client/inspector/inspector.js.map +1 -1
- package/out/zero-client/src/client/inspector/lazy-inspector.js.map +1 -1
- package/out/zero-client/src/client/inspector/query.js.map +1 -1
- package/out/zero-client/src/client/ivm-branch.js.map +1 -1
- package/out/zero-client/src/client/keys.js.map +1 -1
- package/out/zero-client/src/client/log-options.js.map +1 -1
- package/out/zero-client/src/client/make-mutate-property.js.map +1 -1
- package/out/zero-client/src/client/make-replicache-mutators.js.map +1 -1
- package/out/zero-client/src/client/metrics.js.map +1 -1
- package/out/zero-client/src/client/mutation-tracker.js.map +1 -1
- package/out/zero-client/src/client/mutator-proxy.js.map +1 -1
- package/out/zero-client/src/client/options.js.map +1 -1
- package/out/zero-client/src/client/query-manager.js.map +1 -1
- package/out/zero-client/src/client/reload-error-handler.js.map +1 -1
- package/out/zero-client/src/client/server-option.js.map +1 -1
- package/out/zero-client/src/client/version.js +1 -1
- package/out/zero-client/src/client/zero-poke-handler.js.map +1 -1
- package/out/zero-client/src/client/zero-rep.js.map +1 -1
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.js +32 -58
- package/out/zero-client/src/client/zero.js.map +1 -1
- package/out/zero-client/src/util/nanoid.js.map +1 -1
- package/out/zero-client/src/util/socket.d.ts +3 -0
- package/out/zero-client/src/util/socket.d.ts.map +1 -0
- package/out/zero-client/src/util/socket.js +8 -0
- package/out/zero-client/src/util/socket.js.map +1 -0
- package/out/zero-protocol/src/analyze-query-result.js +0 -3
- package/out/zero-protocol/src/analyze-query-result.js.map +1 -1
- package/out/zero-protocol/src/application-error.js.map +1 -1
- package/out/zero-protocol/src/ast.js.map +1 -1
- package/out/zero-protocol/src/change-desired-queries.js +0 -1
- package/out/zero-protocol/src/change-desired-queries.js.map +1 -1
- package/out/zero-protocol/src/client-schema.js.map +1 -1
- package/out/zero-protocol/src/close-connection.js.map +1 -1
- package/out/zero-protocol/src/connect.js +0 -7
- package/out/zero-protocol/src/connect.js.map +1 -1
- package/out/zero-protocol/src/custom-queries.js.map +1 -1
- package/out/zero-protocol/src/data.js.map +1 -1
- package/out/zero-protocol/src/delete-clients.js.map +1 -1
- package/out/zero-protocol/src/down.js.map +1 -1
- package/out/zero-protocol/src/error.js +0 -7
- package/out/zero-protocol/src/error.js.map +1 -1
- package/out/zero-protocol/src/inspect-down.js.map +1 -1
- package/out/zero-protocol/src/inspect-up.js +0 -1
- package/out/zero-protocol/src/inspect-up.js.map +1 -1
- package/out/zero-protocol/src/mutate-server.js.map +1 -1
- package/out/zero-protocol/src/mutation-id.js.map +1 -1
- package/out/zero-protocol/src/mutation.js.map +1 -1
- package/out/zero-protocol/src/mutations-patch.js.map +1 -1
- package/out/zero-protocol/src/ping.js.map +1 -1
- package/out/zero-protocol/src/poke.js +0 -4
- package/out/zero-protocol/src/poke.js.map +1 -1
- package/out/zero-protocol/src/pong.js.map +1 -1
- package/out/zero-protocol/src/primary-key.js.map +1 -1
- package/out/zero-protocol/src/protocol-version.js.map +1 -1
- package/out/zero-protocol/src/pull.js.map +1 -1
- package/out/zero-protocol/src/push.js +0 -16
- package/out/zero-protocol/src/push.js.map +1 -1
- package/out/zero-protocol/src/queries-patch.js.map +1 -1
- package/out/zero-protocol/src/query-hash.js.map +1 -1
- package/out/zero-protocol/src/query-server.js.map +1 -1
- package/out/zero-protocol/src/row-patch.js.map +1 -1
- package/out/zero-protocol/src/up.js.map +1 -1
- package/out/zero-protocol/src/update-auth.js.map +1 -1
- package/out/zero-protocol/src/version.js.map +1 -1
- package/out/zero-react/src/use-connection-state.js.map +1 -1
- package/out/zero-react/src/use-query.js.map +1 -1
- package/out/zero-react/src/use-zero-online.js.map +1 -1
- package/out/zero-react/src/zero-provider.js.map +1 -1
- package/out/zero-schema/src/builder/relationship-builder.js.map +1 -1
- package/out/zero-schema/src/builder/schema-builder.js.map +1 -1
- package/out/zero-schema/src/builder/table-builder.js.map +1 -1
- package/out/zero-schema/src/compiled-permissions.js.map +1 -1
- package/out/zero-schema/src/name-mapper.js.map +1 -1
- package/out/zero-schema/src/permissions.js.map +1 -1
- package/out/zero-schema/src/schema-config.js.map +1 -1
- package/out/zero-server/src/adapters/drizzle.js.map +1 -1
- package/out/zero-server/src/adapters/kysely.js.map +1 -1
- package/out/zero-server/src/adapters/pg.js.map +1 -1
- package/out/zero-server/src/adapters/postgresjs.js.map +1 -1
- package/out/zero-server/src/adapters/prisma.js.map +1 -1
- package/out/zero-server/src/custom.js +1 -2
- package/out/zero-server/src/custom.js.map +1 -1
- package/out/zero-server/src/logging.js.map +1 -1
- package/out/zero-server/src/pg-query-executor.js.map +1 -1
- package/out/zero-server/src/process-mutations.js.map +1 -1
- package/out/zero-server/src/push-processor.js.map +1 -1
- package/out/zero-server/src/queries/process-queries.js.map +1 -1
- package/out/zero-server/src/schema.js.map +1 -1
- package/out/zero-server/src/zql-database.js.map +1 -1
- package/out/zero-solid/src/solid-view.js.map +1 -1
- package/out/zero-solid/src/use-connection-state.js.map +1 -1
- package/out/zero-solid/src/use-query.js.map +1 -1
- package/out/zero-solid/src/use-zero-online.js.map +1 -1
- package/out/zero-solid/src/use-zero.js.map +1 -1
- package/out/zero-types/src/format.js.map +1 -1
- package/out/zero-types/src/name-mapper.js.map +1 -1
- package/out/zql/src/builder/builder.js.map +1 -1
- package/out/zql/src/builder/debug-delegate.d.ts +0 -5
- package/out/zql/src/builder/debug-delegate.d.ts.map +1 -1
- package/out/zql/src/builder/debug-delegate.js +1 -10
- package/out/zql/src/builder/debug-delegate.js.map +1 -1
- package/out/zql/src/builder/filter.js.map +1 -1
- package/out/zql/src/builder/like.js.map +1 -1
- package/out/zql/src/error.js.map +1 -1
- package/out/zql/src/ivm/array-view.js.map +1 -1
- package/out/zql/src/ivm/cap.js.map +1 -1
- package/out/zql/src/ivm/change.js.map +1 -1
- package/out/zql/src/ivm/constraint.js +1 -1
- package/out/zql/src/ivm/constraint.js.map +1 -1
- package/out/zql/src/ivm/data.js.map +1 -1
- package/out/zql/src/ivm/exists.js.map +1 -1
- package/out/zql/src/ivm/fan-in.js.map +1 -1
- package/out/zql/src/ivm/fan-out.js.map +1 -1
- package/out/zql/src/ivm/filter-operators.js.map +1 -1
- package/out/zql/src/ivm/filter-push.js.map +1 -1
- package/out/zql/src/ivm/filter.js.map +1 -1
- package/out/zql/src/ivm/flipped-join.d.ts +8 -4
- package/out/zql/src/ivm/flipped-join.d.ts.map +1 -1
- package/out/zql/src/ivm/flipped-join.js +63 -59
- package/out/zql/src/ivm/flipped-join.js.map +1 -1
- package/out/zql/src/ivm/join-utils.js.map +1 -1
- package/out/zql/src/ivm/join.js.map +1 -1
- package/out/zql/src/ivm/maybe-split-and-push-edit-change.js.map +1 -1
- package/out/zql/src/ivm/memory-source.js.map +1 -1
- package/out/zql/src/ivm/memory-storage.js.map +1 -1
- package/out/zql/src/ivm/operator.d.ts +1 -1
- package/out/zql/src/ivm/operator.js.map +1 -1
- package/out/zql/src/ivm/push-accumulated.js.map +1 -1
- package/out/zql/src/ivm/schema.d.ts +8 -0
- package/out/zql/src/ivm/schema.d.ts.map +1 -1
- package/out/zql/src/ivm/skip-yields.js.map +1 -1
- package/out/zql/src/ivm/skip.js.map +1 -1
- package/out/zql/src/ivm/source.js.map +1 -1
- package/out/zql/src/ivm/stream.js.map +1 -1
- package/out/zql/src/ivm/take.js.map +1 -1
- package/out/zql/src/ivm/union-fan-in.js.map +1 -1
- package/out/zql/src/ivm/union-fan-out.js.map +1 -1
- package/out/zql/src/ivm/view-apply-change.js.map +1 -1
- package/out/zql/src/mutate/crud.js.map +1 -1
- package/out/zql/src/mutate/custom.js.map +1 -1
- package/out/zql/src/mutate/mutator-registry.js.map +1 -1
- package/out/zql/src/mutate/mutator.js.map +1 -1
- package/out/zql/src/planner/planner-builder.js.map +1 -1
- package/out/zql/src/planner/planner-connection.js.map +1 -1
- package/out/zql/src/planner/planner-constraint.js.map +1 -1
- package/out/zql/src/planner/planner-debug.js.map +1 -1
- package/out/zql/src/planner/planner-fan-in.js.map +1 -1
- package/out/zql/src/planner/planner-fan-out.js.map +1 -1
- package/out/zql/src/planner/planner-graph.js.map +1 -1
- package/out/zql/src/planner/planner-join.d.ts.map +1 -1
- package/out/zql/src/planner/planner-join.js +1 -2
- package/out/zql/src/planner/planner-join.js.map +1 -1
- package/out/zql/src/planner/planner-node.js.map +1 -1
- package/out/zql/src/planner/planner-source.js.map +1 -1
- package/out/zql/src/planner/planner-terminus.js.map +1 -1
- package/out/zql/src/query/complete-ordering.js.map +1 -1
- package/out/zql/src/query/create-builder.js.map +1 -1
- package/out/zql/src/query/error.js.map +1 -1
- package/out/zql/src/query/escape-like.js.map +1 -1
- package/out/zql/src/query/expression.js.map +1 -1
- package/out/zql/src/query/measure-push-operator.js.map +1 -1
- package/out/zql/src/query/metrics-delegate.js.map +1 -1
- package/out/zql/src/query/named.js.map +1 -1
- package/out/zql/src/query/query-delegate-base.js.map +1 -1
- package/out/zql/src/query/query-impl.js +1 -1
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/out/zql/src/query/query-internals.js.map +1 -1
- package/out/zql/src/query/query-registry.js.map +1 -1
- package/out/zql/src/query/runnable-query-impl.js.map +1 -1
- package/out/zql/src/query/static-query.js.map +1 -1
- package/out/zql/src/query/ttl.js.map +1 -1
- package/out/zql/src/query/validate-input.js.map +1 -1
- package/out/zqlite/src/database-storage.js.map +1 -1
- package/out/zqlite/src/db.js.map +1 -1
- package/out/zqlite/src/explain-queries.js.map +1 -1
- package/out/zqlite/src/internal/sql-inline.js.map +1 -1
- package/out/zqlite/src/internal/sql.js.map +1 -1
- package/out/zqlite/src/internal/statement-cache.js.map +1 -1
- package/out/zqlite/src/query-builder.js.map +1 -1
- package/out/zqlite/src/query-delegate.js.map +1 -1
- package/out/zqlite/src/resolve-scalar-subqueries.js.map +1 -1
- package/out/zqlite/src/sqlite-cost-model.js.map +1 -1
- package/out/zqlite/src/sqlite-stat-fanout.js.map +1 -1
- package/out/zqlite/src/table-source.d.ts.map +1 -1
- package/out/zqlite/src/table-source.js +6 -6
- package/out/zqlite/src/table-source.js.map +1 -1
- package/package.json +26 -42
- package/out/shared/src/ring-buffer.d.ts +0 -32
- package/out/shared/src/ring-buffer.d.ts.map +0 -1
- package/out/shared/src/ring-buffer.js +0 -109
- package/out/shared/src/ring-buffer.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nanoid.js","names":[],"sources":["../../../../../zero-client/src/util/nanoid.ts"],"sourcesContent":["// This is taken from https://github.com/ai/nanoid/blob/main/index.browser.js We\n// copy this because we want to use `--platform=neutral` which doesn't work with\n// the npm package.\n// Also we changed the random number generator to use Math.random() for compat\n// with React Native.\n\nimport {getNonCryptoRandomValues} from '../../../shared/src/random-values.ts';\n\nexport function nanoid(size = 21): string {\n // Use our custom getRandomValues function to fill a Uint8Array with random values.\n const randomBytes = getNonCryptoRandomValues(new Uint8Array(size));\n\n return randomBytes.reduce((id, byte) => {\n // It is incorrect to use bytes exceeding the alphabet size.\n // The following mask reduces the random byte in the 0-255 value\n // range to the 0-63 value range. Therefore, adding hacks, such\n // as empty string fallback or magic numbers, is unneccessary because\n // the bitmask trims bytes down to the alphabet size.\n byte &= 63;\n if (byte < 36) {\n // `0-9a-z`\n id += byte.toString(36);\n } else if (byte < 62) {\n // `A-Z`\n id += (byte - 26).toString(36).toUpperCase();\n } else if (byte > 62) {\n id += '-';\n } else {\n id += '_';\n }\n return id;\n }, '');\n}\n"],"mappings":";;AAQA,SAAgB,OAAO,OAAO,IAAY;
|
|
1
|
+
{"version":3,"file":"nanoid.js","names":[],"sources":["../../../../../zero-client/src/util/nanoid.ts"],"sourcesContent":["// This is taken from https://github.com/ai/nanoid/blob/main/index.browser.js We\n// copy this because we want to use `--platform=neutral` which doesn't work with\n// the npm package.\n// Also we changed the random number generator to use Math.random() for compat\n// with React Native.\n\nimport {getNonCryptoRandomValues} from '../../../shared/src/random-values.ts';\n\nexport function nanoid(size = 21): string {\n // Use our custom getRandomValues function to fill a Uint8Array with random values.\n const randomBytes = getNonCryptoRandomValues(new Uint8Array(size));\n\n return randomBytes.reduce((id, byte) => {\n // It is incorrect to use bytes exceeding the alphabet size.\n // The following mask reduces the random byte in the 0-255 value\n // range to the 0-63 value range. Therefore, adding hacks, such\n // as empty string fallback or magic numbers, is unneccessary because\n // the bitmask trims bytes down to the alphabet size.\n byte &= 63;\n if (byte < 36) {\n // `0-9a-z`\n id += byte.toString(36);\n } else if (byte < 62) {\n // `A-Z`\n id += (byte - 26).toString(36).toUpperCase();\n } else if (byte > 62) {\n id += '-';\n } else {\n id += '_';\n }\n return id;\n }, '');\n}\n"],"mappings":";;AAQA,SAAgB,OAAO,OAAO,IAAY;AAIxC,QAFoB,yBAAyB,IAAI,WAAW,KAAK,CAAC,CAE/C,QAAQ,IAAI,SAAS;AAMtC,UAAQ;AACR,MAAI,OAAO,GAET,OAAM,KAAK,SAAS,GAAG;WACd,OAAO,GAEhB,QAAO,OAAO,IAAI,SAAS,GAAG,CAAC,aAAa;WACnC,OAAO,GAChB,OAAM;MAEN,OAAM;AAER,SAAO;IACN,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/util/socket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,kCAAkC,CAAC;AAE/D,wBAAgB,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,QAEjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket.js","names":[],"sources":["../../../../../zero-client/src/util/socket.ts"],"sourcesContent":["import type {Upstream} from '../../../zero-protocol/src/up.ts';\n\nexport function send(ws: WebSocket, data: Upstream) {\n ws.send(JSON.stringify(data));\n}\n"],"mappings":";AAEA,SAAgB,KAAK,IAAe,MAAgB;AAClD,IAAG,KAAK,KAAK,UAAU,KAAK,CAAC"}
|
|
@@ -102,13 +102,10 @@ var analyzeQueryResultSchema = valita_exports.object({
|
|
|
102
102
|
syncedRows: valita_exports.record(valita_exports.array(rowSchema)).optional(),
|
|
103
103
|
syncedRowCount: valita_exports.number(),
|
|
104
104
|
start: valita_exports.number(),
|
|
105
|
-
/** @deprecated Use start + elapsed instead */
|
|
106
105
|
end: valita_exports.number(),
|
|
107
106
|
elapsed: valita_exports.number().optional(),
|
|
108
107
|
afterPermissions: valita_exports.string().optional(),
|
|
109
|
-
/** @deprecated Use readRowCountsByQuery */
|
|
110
108
|
vendedRowCounts: rowCountsBySourceSchema.optional(),
|
|
111
|
-
/** @deprecated Use readRows */
|
|
112
109
|
vendedRows: rowsBySourceSchema.optional(),
|
|
113
110
|
sqlitePlans: valita_exports.record(valita_exports.array(valita_exports.string())).optional(),
|
|
114
111
|
readRows: rowsBySourceSchema.optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-query-result.js","names":[],"sources":["../../../../zero-protocol/src/analyze-query-result.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\n\nimport {conditionSchema, orderingSchema} from './ast.ts';\nimport {rowSchema} from './data.ts';\n\nexport const rowCountsByQuerySchema = v.record(v.number());\nexport type RowCountsByQuery = v.Infer<typeof rowCountsByQuerySchema>;\n\nexport const rowCountsBySourceSchema = v.record(rowCountsByQuerySchema);\nexport type RowCountsBySource = v.Infer<typeof rowCountsBySourceSchema>;\n\nexport const rowsByQuerySchema = v.record(v.array(rowSchema));\nexport type RowsByQuery = v.Infer<typeof rowsByQuerySchema>;\n\nexport const rowsBySourceSchema = v.record(rowsByQuerySchema);\nexport type RowsBySource = v.Infer<typeof rowsBySourceSchema>;\n\n// Planner debug event schemas\n\nconst costEstimateJSONSchema = v.object({\n startupCost: v.number(),\n scanEst: v.number(),\n cost: v.number(),\n returnedRows: v.number(),\n selectivity: v.number(),\n limit: v.number().optional(),\n});\n\nconst plannerConstraintSchema = v.record(v.union(v.unknown(), v.null()));\n\nconst attemptStartEventJSONSchema = v.object({\n type: v.literal('attempt-start'),\n attemptNumber: v.number(),\n totalAttempts: v.number(),\n});\n\nconst connectionCostsEventJSONSchema = v.object({\n type: v.literal('connection-costs'),\n attemptNumber: v.number(),\n costs: v.array(\n v.object({\n connection: v.string(),\n cost: v.number(),\n costEstimate: costEstimateJSONSchema,\n pinned: v.boolean(),\n constraints: v.record(v.union(plannerConstraintSchema, v.null())),\n constraintCosts: v.record(costEstimateJSONSchema),\n }),\n ),\n});\n\nconst connectionSelectedEventJSONSchema = v.object({\n type: v.literal('connection-selected'),\n attemptNumber: v.number(),\n connection: v.string(),\n cost: v.number(),\n isRoot: v.boolean(),\n});\n\nconst constraintsPropagatedEventJSONSchema = v.object({\n type: v.literal('constraints-propagated'),\n attemptNumber: v.number(),\n connectionConstraints: v.array(\n v.object({\n connection: v.string(),\n constraints: v.record(v.union(plannerConstraintSchema, v.null())),\n constraintCosts: v.record(costEstimateJSONSchema),\n }),\n ),\n});\n\nconst joinTypeSchema = v.union(\n v.literal('semi'),\n v.literal('flipped'),\n v.literal('unflippable'),\n);\n\nconst planCompleteEventJSONSchema = v.object({\n type: v.literal('plan-complete'),\n attemptNumber: v.number(),\n totalCost: v.number(),\n flipPattern: v.number(),\n joinStates: v.array(\n v.object({\n join: v.string(),\n type: joinTypeSchema,\n }),\n ),\n});\n\nconst planFailedEventJSONSchema = v.object({\n type: v.literal('plan-failed'),\n attemptNumber: v.number(),\n reason: v.string(),\n});\n\nconst bestPlanSelectedEventJSONSchema = v.object({\n type: v.literal('best-plan-selected'),\n bestAttemptNumber: v.number(),\n totalCost: v.number(),\n flipPattern: v.number(),\n joinStates: v.array(\n v.object({\n join: v.string(),\n type: joinTypeSchema,\n }),\n ),\n});\n\nconst nodeTypeSchema = v.union(\n v.literal('connection'),\n v.literal('join'),\n v.literal('fan-out'),\n v.literal('fan-in'),\n v.literal('terminus'),\n);\n\nconst nodeCostEventJSONSchema = v.object({\n type: v.literal('node-cost'),\n attemptNumber: v.number().optional(),\n nodeType: nodeTypeSchema,\n node: v.string(),\n branchPattern: v.array(v.number()),\n downstreamChildSelectivity: v.number(),\n costEstimate: costEstimateJSONSchema,\n filters: conditionSchema.optional(),\n ordering: orderingSchema.optional(),\n joinType: joinTypeSchema.optional(),\n});\n\nconst nodeConstraintEventJSONSchema = v.object({\n type: v.literal('node-constraint'),\n attemptNumber: v.number().optional(),\n nodeType: nodeTypeSchema,\n node: v.string(),\n branchPattern: v.array(v.number()),\n constraint: v.union(plannerConstraintSchema, v.null()).optional(),\n from: v.string(),\n});\n\nconst planDebugEventJSONSchema = v.union(\n attemptStartEventJSONSchema,\n connectionCostsEventJSONSchema,\n connectionSelectedEventJSONSchema,\n constraintsPropagatedEventJSONSchema,\n planCompleteEventJSONSchema,\n planFailedEventJSONSchema,\n bestPlanSelectedEventJSONSchema,\n nodeCostEventJSONSchema,\n nodeConstraintEventJSONSchema,\n);\n\nexport type PlanDebugEventJSON = v.Infer<typeof planDebugEventJSONSchema>;\n\nexport {\n attemptStartEventJSONSchema,\n connectionSelectedEventJSONSchema,\n planFailedEventJSONSchema,\n bestPlanSelectedEventJSONSchema,\n nodeConstraintEventJSONSchema,\n};\n\nexport const analyzeQueryResultSchema = v.object({\n warnings: v.array(v.string()),\n syncedRows: v.record(v.array(rowSchema)).optional(),\n syncedRowCount: v.number(),\n start: v.number(),\n /** @deprecated Use start + elapsed instead */\n end: v.number(),\n elapsed: v.number().optional(),\n afterPermissions: v.string().optional(),\n /** @deprecated Use readRowCountsByQuery */\n vendedRowCounts: rowCountsBySourceSchema.optional(),\n /** @deprecated Use readRows */\n vendedRows: rowsBySourceSchema.optional(),\n sqlitePlans: v.record(v.array(v.string())).optional(),\n readRows: rowsBySourceSchema.optional(),\n readRowCountsByQuery: rowCountsBySourceSchema.optional(),\n readRowCount: v.number().optional(),\n dbScansByQuery: rowCountsBySourceSchema.optional(),\n joinPlans: v.array(planDebugEventJSONSchema).optional(),\n});\n\nexport type AnalyzeQueryResult = v.Infer<typeof analyzeQueryResultSchema>;\n"],"mappings":";;;;AAKA,IAAa,yBAAyB,eAAE,OAAO,eAAE,
|
|
1
|
+
{"version":3,"file":"analyze-query-result.js","names":[],"sources":["../../../../zero-protocol/src/analyze-query-result.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\n\nimport {conditionSchema, orderingSchema} from './ast.ts';\nimport {rowSchema} from './data.ts';\n\nexport const rowCountsByQuerySchema = v.record(v.number());\nexport type RowCountsByQuery = v.Infer<typeof rowCountsByQuerySchema>;\n\nexport const rowCountsBySourceSchema = v.record(rowCountsByQuerySchema);\nexport type RowCountsBySource = v.Infer<typeof rowCountsBySourceSchema>;\n\nexport const rowsByQuerySchema = v.record(v.array(rowSchema));\nexport type RowsByQuery = v.Infer<typeof rowsByQuerySchema>;\n\nexport const rowsBySourceSchema = v.record(rowsByQuerySchema);\nexport type RowsBySource = v.Infer<typeof rowsBySourceSchema>;\n\n// Planner debug event schemas\n\nconst costEstimateJSONSchema = v.object({\n startupCost: v.number(),\n scanEst: v.number(),\n cost: v.number(),\n returnedRows: v.number(),\n selectivity: v.number(),\n limit: v.number().optional(),\n});\n\nconst plannerConstraintSchema = v.record(v.union(v.unknown(), v.null()));\n\nconst attemptStartEventJSONSchema = v.object({\n type: v.literal('attempt-start'),\n attemptNumber: v.number(),\n totalAttempts: v.number(),\n});\n\nconst connectionCostsEventJSONSchema = v.object({\n type: v.literal('connection-costs'),\n attemptNumber: v.number(),\n costs: v.array(\n v.object({\n connection: v.string(),\n cost: v.number(),\n costEstimate: costEstimateJSONSchema,\n pinned: v.boolean(),\n constraints: v.record(v.union(plannerConstraintSchema, v.null())),\n constraintCosts: v.record(costEstimateJSONSchema),\n }),\n ),\n});\n\nconst connectionSelectedEventJSONSchema = v.object({\n type: v.literal('connection-selected'),\n attemptNumber: v.number(),\n connection: v.string(),\n cost: v.number(),\n isRoot: v.boolean(),\n});\n\nconst constraintsPropagatedEventJSONSchema = v.object({\n type: v.literal('constraints-propagated'),\n attemptNumber: v.number(),\n connectionConstraints: v.array(\n v.object({\n connection: v.string(),\n constraints: v.record(v.union(plannerConstraintSchema, v.null())),\n constraintCosts: v.record(costEstimateJSONSchema),\n }),\n ),\n});\n\nconst joinTypeSchema = v.union(\n v.literal('semi'),\n v.literal('flipped'),\n v.literal('unflippable'),\n);\n\nconst planCompleteEventJSONSchema = v.object({\n type: v.literal('plan-complete'),\n attemptNumber: v.number(),\n totalCost: v.number(),\n flipPattern: v.number(),\n joinStates: v.array(\n v.object({\n join: v.string(),\n type: joinTypeSchema,\n }),\n ),\n});\n\nconst planFailedEventJSONSchema = v.object({\n type: v.literal('plan-failed'),\n attemptNumber: v.number(),\n reason: v.string(),\n});\n\nconst bestPlanSelectedEventJSONSchema = v.object({\n type: v.literal('best-plan-selected'),\n bestAttemptNumber: v.number(),\n totalCost: v.number(),\n flipPattern: v.number(),\n joinStates: v.array(\n v.object({\n join: v.string(),\n type: joinTypeSchema,\n }),\n ),\n});\n\nconst nodeTypeSchema = v.union(\n v.literal('connection'),\n v.literal('join'),\n v.literal('fan-out'),\n v.literal('fan-in'),\n v.literal('terminus'),\n);\n\nconst nodeCostEventJSONSchema = v.object({\n type: v.literal('node-cost'),\n attemptNumber: v.number().optional(),\n nodeType: nodeTypeSchema,\n node: v.string(),\n branchPattern: v.array(v.number()),\n downstreamChildSelectivity: v.number(),\n costEstimate: costEstimateJSONSchema,\n filters: conditionSchema.optional(),\n ordering: orderingSchema.optional(),\n joinType: joinTypeSchema.optional(),\n});\n\nconst nodeConstraintEventJSONSchema = v.object({\n type: v.literal('node-constraint'),\n attemptNumber: v.number().optional(),\n nodeType: nodeTypeSchema,\n node: v.string(),\n branchPattern: v.array(v.number()),\n constraint: v.union(plannerConstraintSchema, v.null()).optional(),\n from: v.string(),\n});\n\nconst planDebugEventJSONSchema = v.union(\n attemptStartEventJSONSchema,\n connectionCostsEventJSONSchema,\n connectionSelectedEventJSONSchema,\n constraintsPropagatedEventJSONSchema,\n planCompleteEventJSONSchema,\n planFailedEventJSONSchema,\n bestPlanSelectedEventJSONSchema,\n nodeCostEventJSONSchema,\n nodeConstraintEventJSONSchema,\n);\n\nexport type PlanDebugEventJSON = v.Infer<typeof planDebugEventJSONSchema>;\n\nexport {\n attemptStartEventJSONSchema,\n connectionSelectedEventJSONSchema,\n planFailedEventJSONSchema,\n bestPlanSelectedEventJSONSchema,\n nodeConstraintEventJSONSchema,\n};\n\nexport const analyzeQueryResultSchema = v.object({\n warnings: v.array(v.string()),\n syncedRows: v.record(v.array(rowSchema)).optional(),\n syncedRowCount: v.number(),\n start: v.number(),\n /** @deprecated Use start + elapsed instead */\n end: v.number(),\n elapsed: v.number().optional(),\n afterPermissions: v.string().optional(),\n /** @deprecated Use readRowCountsByQuery */\n vendedRowCounts: rowCountsBySourceSchema.optional(),\n /** @deprecated Use readRows */\n vendedRows: rowsBySourceSchema.optional(),\n sqlitePlans: v.record(v.array(v.string())).optional(),\n readRows: rowsBySourceSchema.optional(),\n readRowCountsByQuery: rowCountsBySourceSchema.optional(),\n readRowCount: v.number().optional(),\n dbScansByQuery: rowCountsBySourceSchema.optional(),\n joinPlans: v.array(planDebugEventJSONSchema).optional(),\n});\n\n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3,"file":"application-error.js","names":["#details"],"sources":["../../../../zero-protocol/src/application-error.ts"],"sourcesContent":["import {getErrorDetails, getErrorMessage} from '../../shared/src/error.ts';\nimport type {ReadonlyJSONValue} from '../../shared/src/json.ts';\n\n/**\n * Options accepted by {@link ApplicationError}.\n *\n * Use these when you need to attach additional context to an error that will\n * be sent back to the client.\n */\nexport interface ApplicationErrorOptions<\n T extends ReadonlyJSONValue | undefined,\n> {\n details?: T;\n cause?: unknown;\n}\n\n/**\n * Error type that application code can throw to surface structured metadata back to\n * the client.\n *\n * Use this when you want to return a descriptive message along with the\n * JSON-serializable `details`.\n */\nexport class ApplicationError<\n const T extends ReadonlyJSONValue | undefined = ReadonlyJSONValue | undefined,\n> extends Error {\n /**\n * This maps onto errors for transform and push app-level failures.\n */\n readonly #details: T;\n\n constructor(message: string, options?: ApplicationErrorOptions<T>) {\n super(message, {cause: options?.cause});\n this.name = 'ApplicationError';\n this.#details = options?.details ?? (undefined as T);\n }\n\n get details(): T {\n return this.#details;\n }\n\n get kind(): 'Application' {\n return 'Application';\n }\n}\n\nexport function isApplicationError(error: unknown): error is ApplicationError {\n return error instanceof ApplicationError;\n}\n\nexport function wrapWithApplicationError<\n T extends ReadonlyJSONValue | undefined = ReadonlyJSONValue | undefined,\n>(error: unknown): ApplicationError<T> {\n if (isApplicationError(error)) {\n return error as ApplicationError<T>;\n }\n\n const message = getErrorMessage(error);\n const details = getErrorDetails(error);\n\n return new ApplicationError<T>(message, {\n cause: error,\n details: details as T,\n });\n}\n"],"mappings":";;;;;;;;;AAuBA,IAAa,mBAAb,cAEU,MAAM;;;;CAId;CAEA,YAAY,SAAiB,SAAsC;
|
|
1
|
+
{"version":3,"file":"application-error.js","names":["#details"],"sources":["../../../../zero-protocol/src/application-error.ts"],"sourcesContent":["import {getErrorDetails, getErrorMessage} from '../../shared/src/error.ts';\nimport type {ReadonlyJSONValue} from '../../shared/src/json.ts';\n\n/**\n * Options accepted by {@link ApplicationError}.\n *\n * Use these when you need to attach additional context to an error that will\n * be sent back to the client.\n */\nexport interface ApplicationErrorOptions<\n T extends ReadonlyJSONValue | undefined,\n> {\n details?: T;\n cause?: unknown;\n}\n\n/**\n * Error type that application code can throw to surface structured metadata back to\n * the client.\n *\n * Use this when you want to return a descriptive message along with the\n * JSON-serializable `details`.\n */\nexport class ApplicationError<\n const T extends ReadonlyJSONValue | undefined = ReadonlyJSONValue | undefined,\n> extends Error {\n /**\n * This maps onto errors for transform and push app-level failures.\n */\n readonly #details: T;\n\n constructor(message: string, options?: ApplicationErrorOptions<T>) {\n super(message, {cause: options?.cause});\n this.name = 'ApplicationError';\n this.#details = options?.details ?? (undefined as T);\n }\n\n get details(): T {\n return this.#details;\n }\n\n get kind(): 'Application' {\n return 'Application';\n }\n}\n\nexport function isApplicationError(error: unknown): error is ApplicationError {\n return error instanceof ApplicationError;\n}\n\nexport function wrapWithApplicationError<\n T extends ReadonlyJSONValue | undefined = ReadonlyJSONValue | undefined,\n>(error: unknown): ApplicationError<T> {\n if (isApplicationError(error)) {\n return error as ApplicationError<T>;\n }\n\n const message = getErrorMessage(error);\n const details = getErrorDetails(error);\n\n return new ApplicationError<T>(message, {\n cause: error,\n details: details as T,\n });\n}\n"],"mappings":";;;;;;;;;AAuBA,IAAa,mBAAb,cAEU,MAAM;;;;CAId;CAEA,YAAY,SAAiB,SAAsC;AACjE,QAAM,SAAS,EAAC,OAAO,SAAS,OAAM,CAAC;AACvC,OAAK,OAAO;AACZ,QAAA,UAAgB,SAAS,WAAY,KAAA;;CAGvC,IAAI,UAAa;AACf,SAAO,MAAA;;CAGT,IAAI,OAAsB;AACxB,SAAO;;;AAIX,SAAgB,mBAAmB,OAA2C;AAC5E,QAAO,iBAAiB;;AAG1B,SAAgB,yBAEd,OAAqC;AACrC,KAAI,mBAAmB,MAAM,CAC3B,QAAO;AAMT,QAAO,IAAI,iBAHK,gBAAgB,MAAM,EAGE;EACtC,OAAO;EACE,SAJK,gBAAgB,MAAM;EAKrC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","names":[],"sources":["../../../../zero-protocol/src/ast.ts"],"sourcesContent":["/**\n * Wire-format representation of the zql AST interface.\n *\n * `v.Type<...>` types are explicitly declared to facilitate Typescript verification\n * that the schemas satisfy the zql type definitions. (Incidentally, explicit types\n * are also required for recursive schema definitions.)\n */\n\nimport {compareUTF8} from 'compare-utf8';\nimport {defined} from '../../shared/src/arrays.ts';\nimport {assert} from '../../shared/src/asserts.ts';\nimport {must} from '../../shared/src/must.ts';\nimport * as v from '../../shared/src/valita.ts';\nimport type {NameMapper} from '../../zero-types/src/name-mapper.ts';\nimport {rowSchema, type Row} from './data.ts';\n\nexport const SUBQ_PREFIX = 'zsubq_';\n\nexport const selectorSchema = v.string();\nexport const toStaticParam = Symbol();\nexport const planIdSymbol = Symbol('planId');\n\nconst orderingElementSchema = v.readonly(\n v.tuple([selectorSchema, v.literalUnion('asc', 'desc')]),\n);\n\nexport const orderingSchema = v.readonlyArray(orderingElementSchema);\nexport type System = 'permissions' | 'client' | 'test';\n\nexport const primitiveSchema = v.union(\n v.string(),\n v.number(),\n v.boolean(),\n v.null(),\n);\n\nexport const equalityOpsSchema = v.literalUnion('=', '!=', 'IS', 'IS NOT');\n\nexport const orderOpsSchema = v.literalUnion('<', '>', '<=', '>=');\n\nexport const likeOpsSchema = v.literalUnion(\n 'LIKE',\n 'NOT LIKE',\n 'ILIKE',\n 'NOT ILIKE',\n);\n\nexport const inOpsSchema = v.literalUnion('IN', 'NOT IN');\n\nexport const simpleOperatorSchema = v.union(\n equalityOpsSchema,\n orderOpsSchema,\n likeOpsSchema,\n inOpsSchema,\n);\n\nconst literalReferenceSchema: v.Type<LiteralReference> = v.readonlyObject({\n type: v.literal('literal'),\n value: v.union(\n v.string(),\n v.number(),\n v.boolean(),\n v.null(),\n v.readonlyArray(v.union(v.string(), v.number(), v.boolean())),\n ),\n});\nconst columnReferenceSchema: v.Type<ColumnReference> = v.readonlyObject({\n type: v.literal('column'),\n name: v.string(),\n});\n\n/**\n * A parameter is a value that is not known at the time the query is written\n * and is resolved at runtime.\n *\n * Static parameters refer to something provided by the caller.\n * Static parameters are injected when the query pipeline is built from the AST\n * and do not change for the life of that pipeline.\n *\n * An example static parameter is the current authentication data.\n * When a user is authenticated, queries on the server have access\n * to the user's authentication data in order to evaluate authorization rules.\n * Authentication data doesn't change over the life of a query as a change\n * in auth data would represent a log-in / log-out of the user.\n *\n * AncestorParameters refer to rows encountered while running the query.\n * They are used by subqueries to refer to rows emitted by parent queries.\n */\nconst parameterReferenceSchema = v.readonlyObject({\n type: v.literal('static'),\n // The \"namespace\" of the injected parameter.\n // Write authorization will send the value of a row\n // prior to the mutation being run (preMutationRow).\n // Read and write authorization will both send the\n // current authentication data (authData).\n anchor: v.literalUnion('authData', 'preMutationRow'),\n field: v.union(v.string(), v.array(v.string())),\n});\n\nconst conditionValueSchema = v.union(\n literalReferenceSchema,\n columnReferenceSchema,\n parameterReferenceSchema,\n);\n\nexport type Parameter = v.Infer<typeof parameterReferenceSchema>;\n\nexport const simpleConditionSchema: v.Type<SimpleCondition> = v.readonlyObject({\n type: v.literal('simple'),\n op: simpleOperatorSchema,\n left: conditionValueSchema,\n right: v.union(parameterReferenceSchema, literalReferenceSchema),\n});\n\ntype ConditionValue = v.Infer<typeof conditionValueSchema>;\n\nexport const correlatedSubqueryConditionOperatorSchema: v.Type<CorrelatedSubqueryConditionOperator> =\n v.literalUnion('EXISTS', 'NOT EXISTS');\n\nexport const correlatedSubqueryConditionSchema: v.Type<CorrelatedSubqueryCondition> =\n v.readonlyObject({\n type: v.literal('correlatedSubquery'),\n related: v.lazy(() => correlatedSubquerySchema),\n op: correlatedSubqueryConditionOperatorSchema,\n flip: v.boolean().optional(),\n scalar: v.boolean().optional(),\n });\n\nexport const conditionSchema: v.Type<Condition> = v.union(\n simpleConditionSchema,\n v.lazy(() => conjunctionSchema),\n v.lazy(() => disjunctionSchema),\n correlatedSubqueryConditionSchema,\n);\n\nconst conjunctionSchema: v.Type<Conjunction> = v.readonlyObject({\n type: v.literal('and'),\n conditions: v.readonlyArray(conditionSchema),\n});\n\nconst disjunctionSchema: v.Type<Disjunction> = v.readonlyObject({\n type: v.literal('or'),\n conditions: v.readonlyArray(conditionSchema),\n});\n\nexport type CompoundKey = readonly [string, ...string[]];\n\nfunction mustCompoundKey(field: readonly string[]): CompoundKey {\n assert(\n Array.isArray(field) && field.length >= 1,\n 'Expected non-empty array for compound key',\n );\n return field as unknown as CompoundKey;\n}\n\nexport const compoundKeySchema: v.Type<CompoundKey> = v.readonly(\n // oxlint-disable-next-line e18e/prefer-spread-syntax\n v.tuple([v.string()]).concat(v.array(v.string())),\n);\n\nconst correlationSchema = v.readonlyObject({\n parentField: compoundKeySchema,\n childField: compoundKeySchema,\n});\n\n// Split out so that its inferred type can be checked against\n// Omit<CorrelatedSubquery, 'correlation'> in ast-type-test.ts.\n// The mutually-recursive reference of the 'other' field to astSchema\n// is the only thing added in v.lazy. The v.lazy is necessary due to the\n// mutually-recursive types, but v.lazy prevents inference of the resulting\n// type.\nexport const correlatedSubquerySchemaOmitSubquery = v.readonlyObject({\n correlation: correlationSchema,\n hidden: v.boolean().optional(),\n system: v.literalUnion('permissions', 'client', 'test').optional(),\n});\n\nexport const correlatedSubquerySchema: v.Type<CorrelatedSubquery> =\n correlatedSubquerySchemaOmitSubquery.extend({\n subquery: v.lazy(() => astSchema),\n });\n\nexport const astSchema: v.Type<AST> = v.readonlyObject({\n schema: v.string().optional(),\n table: v.string(),\n alias: v.string().optional(),\n where: conditionSchema.optional(),\n related: v.readonlyArray(correlatedSubquerySchema).optional(),\n limit: v.number().optional(),\n orderBy: orderingSchema.optional(),\n start: v\n .object({\n row: rowSchema,\n exclusive: v.boolean(),\n })\n .optional(),\n});\n\nexport type Bound = {\n row: Row;\n exclusive: boolean;\n};\n\n/**\n * As in SQL you can have multiple orderings. We don't currently\n * support ordering on anything other than the root query.\n */\nexport type OrderPart = readonly [field: string, direction: 'asc' | 'desc'];\nexport type Ordering = readonly OrderPart[];\n\nexport type SimpleOperator = EqualityOps | OrderOps | LikeOps | InOps;\nexport type EqualityOps = '=' | '!=' | 'IS' | 'IS NOT';\nexport type OrderOps = '<' | '>' | '<=' | '>=';\nexport type LikeOps = 'LIKE' | 'NOT LIKE' | 'ILIKE' | 'NOT ILIKE';\nexport type InOps = 'IN' | 'NOT IN';\n\nexport type AST = {\n readonly schema?: string | undefined;\n readonly table: string;\n\n // A query would be aliased if the AST is a subquery.\n // e.g., when two subqueries select from the same table\n // they need an alias to differentiate them.\n // `SELECT\n // [SELECT * FROM issue WHERE issue.id = outer.parentId] AS parent\n // [SELECT * FROM issue WHERE issue.parentId = outer.id] AS children\n // FROM issue as outer`\n readonly alias?: string | undefined;\n\n // `select` is missing given we return all columns for now.\n\n // The PipelineBuilder will pick what to use to correlate\n // a subquery with a parent query. It can choose something from the\n // where conditions or choose the _first_ `related` entry.\n // Choosing the first `related` entry is almost always the best choice if\n // one exists.\n readonly where?: Condition | undefined;\n\n readonly related?: readonly CorrelatedSubquery[] | undefined;\n readonly start?: Bound | undefined;\n readonly limit?: number | undefined;\n readonly orderBy?: Ordering | undefined;\n};\n\nexport type Correlation = {\n readonly parentField: CompoundKey;\n readonly childField: CompoundKey;\n};\n\nexport type CorrelatedSubquery = {\n /**\n * Only equality correlation are supported for now.\n * E.g., direct foreign key relationships.\n */\n readonly correlation: Correlation;\n readonly subquery: AST;\n readonly system?: System | undefined;\n // If a hop in the subquery chain should be hidden from the output view.\n // A common example is junction edges. The query API provides the illusion\n // that they don't exist: `issue.related('labels')` instead of `issue.related('issue_labels').related('labels')`.\n // To maintain this illusion, the junction edge should be hidden.\n // When `hidden` is set to true, this hop will not be included in the output view\n // but its children will be.\n readonly hidden?: boolean | undefined;\n};\n\nexport type ValuePosition = LiteralReference | Parameter | ColumnReference;\n\nexport type ColumnReference = {\n readonly type: 'column';\n /**\n * Not a path yet as we're currently not allowing\n * comparisons across tables. This will need to\n * be a path through the tree in the near future.\n */\n readonly name: string;\n};\n\nexport type LiteralReference = {\n readonly type: 'literal';\n readonly value: LiteralValue;\n};\n\nexport type LiteralValue =\n | string\n | number\n | boolean\n | null\n | ReadonlyArray<string | number | boolean>;\n\n/**\n * Starting only with SimpleCondition for now.\n * ivm1 supports Conjunctions and Disjunctions.\n * We'll support them in the future.\n */\nexport type Condition =\n | SimpleCondition\n | Conjunction\n | Disjunction\n | CorrelatedSubqueryCondition;\n\nexport type SimpleCondition = {\n readonly type: 'simple';\n readonly op: SimpleOperator;\n readonly left: ValuePosition;\n\n /**\n * `null` is absent since we do not have an `IS` or `IS NOT`\n * operator defined and `null != null` in SQL.\n */\n readonly right: Exclude<ValuePosition, ColumnReference>;\n};\n\nexport type Conjunction = {\n type: 'and';\n conditions: readonly Condition[];\n};\n\nexport type Disjunction = {\n type: 'or';\n conditions: readonly Condition[];\n};\n\nexport type CorrelatedSubqueryCondition = {\n type: 'correlatedSubquery';\n related: CorrelatedSubquery;\n op: CorrelatedSubqueryConditionOperator;\n flip?: boolean | undefined;\n scalar?: boolean | undefined;\n [planIdSymbol]?: number | undefined;\n};\n\nexport type CorrelatedSubqueryConditionOperator = 'EXISTS' | 'NOT EXISTS';\n\ninterface ASTTransform {\n tableName(orig: string): string;\n columnName(origTable: string, origColumn: string): string;\n related(subqueries: CorrelatedSubquery[]): readonly CorrelatedSubquery[];\n where(cond: Condition): Condition | undefined;\n // conjunction or disjunction, called when traversing the return value of where()\n conditions(conds: Condition[]): readonly Condition[];\n}\n\nfunction transformAST(ast: AST, transform: ASTTransform): Required<AST> {\n // Name mapping functions (e.g. to server names)\n const {tableName, columnName} = transform;\n const colName = (c: string) => columnName(ast.table, c);\n const key = (table: string, k: CompoundKey) => {\n const serverKey = k.map(col => columnName(table, col));\n return mustCompoundKey(serverKey);\n };\n\n const where = ast.where ? transform.where(ast.where) : undefined;\n const transformed = {\n schema: ast.schema,\n table: tableName(ast.table),\n alias: ast.alias,\n where: where ? transformWhere(where, ast.table, transform) : undefined,\n related: ast.related\n ? transform.related(\n ast.related.map(\n r =>\n ({\n correlation: {\n parentField: key(ast.table, r.correlation.parentField),\n childField: key(r.subquery.table, r.correlation.childField),\n },\n hidden: r.hidden,\n subquery: transformAST(r.subquery, transform),\n system: r.system,\n }) satisfies Required<CorrelatedSubquery>,\n ),\n )\n : undefined,\n start: ast.start\n ? {\n ...ast.start,\n row: Object.fromEntries(\n Object.entries(ast.start.row).map(([col, val]) => [\n colName(col),\n val,\n ]),\n ),\n }\n : undefined,\n limit: ast.limit,\n orderBy: ast.orderBy?.map(([col, dir]) => [colName(col), dir] as const),\n };\n\n return transformed;\n}\n\nfunction transformWhere(\n where: Condition,\n table: string,\n transform: ASTTransform,\n): Condition {\n // Name mapping functions (e.g. to server names)\n const {columnName} = transform;\n const condValue = (c: ConditionValue) =>\n c.type !== 'column' ? c : {...c, name: columnName(table, c.name)};\n const key = (table: string, k: CompoundKey) => {\n const serverKey = k.map(col => columnName(table, col));\n return mustCompoundKey(serverKey);\n };\n\n if (where.type === 'simple') {\n return {...where, left: condValue(where.left)};\n } else if (where.type === 'correlatedSubquery') {\n const {correlation, subquery} = where.related;\n return {\n ...where,\n related: {\n ...where.related,\n correlation: {\n parentField: key(table, correlation.parentField),\n childField: key(subquery.table, correlation.childField),\n },\n subquery: transformAST(subquery, transform),\n },\n };\n }\n\n return {\n type: where.type,\n conditions: transform.conditions(\n where.conditions.map(c => transformWhere(c, table, transform)),\n ),\n };\n}\n\nconst normalizeCache = new WeakMap<AST, Required<AST>>();\n\nconst NORMALIZE_TRANSFORM: ASTTransform = {\n tableName: t => t,\n columnName: (_, c) => c,\n related: sortedRelated,\n where: flattened,\n conditions: c => c.sort(cmpCondition),\n};\n\nexport function normalizeAST(ast: AST): Required<AST> {\n let normalized = normalizeCache.get(ast);\n if (!normalized) {\n normalized = transformAST(ast, NORMALIZE_TRANSFORM);\n normalizeCache.set(ast, normalized);\n }\n return normalized;\n}\n\nexport function mapAST(ast: AST, mapper: NameMapper) {\n return transformAST(ast, {\n tableName: table => mapper.tableName(table),\n columnName: (table, col) => mapper.columnName(table, col),\n related: r => r,\n where: w => w,\n conditions: c => c,\n });\n}\n\nexport function mapCondition(\n cond: Condition,\n table: string,\n mapper: NameMapper,\n) {\n return transformWhere(cond, table, {\n tableName: table => mapper.tableName(table),\n columnName: (table, col) => mapper.columnName(table, col),\n related: r => r,\n where: w => w,\n conditions: c => c,\n });\n}\n\nfunction sortedRelated(\n related: CorrelatedSubquery[],\n): readonly CorrelatedSubquery[] {\n return related.sort(cmpRelated);\n}\n\nfunction cmpCondition(a: Condition, b: Condition): number {\n if (a.type === 'simple') {\n if (b.type !== 'simple') {\n return -1; // Order SimpleConditions first\n }\n\n return (\n compareValuePosition(a.left, b.left) ||\n compareUTF8MaybeNull(a.op, b.op) ||\n compareValuePosition(a.right, b.right)\n );\n }\n\n if (b.type === 'simple') {\n return 1; // Order SimpleConditions first\n }\n\n if (a.type === 'correlatedSubquery') {\n if (b.type !== 'correlatedSubquery') {\n return -1; // Order subquery before conjuctions/disjuctions\n }\n return (\n cmpRelated(a.related, b.related) ||\n compareUTF8MaybeNull(a.op, b.op) ||\n cmpOptionalBool(a.flip, b.flip) ||\n cmpOptionalBool(a.scalar, b.scalar)\n );\n }\n if (b.type === 'correlatedSubquery') {\n return -1; // Order correlatedSubquery before conjuctions/disjuctions\n }\n\n const val = compareUTF8MaybeNull(a.type, b.type);\n if (val !== 0) {\n return val;\n }\n for (\n let l = 0, r = 0;\n l < a.conditions.length && r < b.conditions.length;\n l++, r++\n ) {\n const val = cmpCondition(a.conditions[l], b.conditions[r]);\n if (val !== 0) {\n return val;\n }\n }\n // prefixes first\n return a.conditions.length - b.conditions.length;\n}\n\nfunction compareValuePosition(a: ValuePosition, b: ValuePosition): number {\n if (a.type !== b.type) {\n return compareUTF8(a.type, b.type);\n }\n switch (a.type) {\n case 'literal':\n assert(b.type === 'literal', 'Expected literal type for comparison');\n return compareUTF8(String(a.value), String(b.value));\n case 'column':\n assert(b.type === 'column', 'Expected column type for comparison');\n return compareUTF8(a.name, b.name);\n case 'static':\n throw new Error(\n 'Static parameters should be resolved before normalization',\n );\n }\n}\n\nfunction cmpRelated(a: CorrelatedSubquery, b: CorrelatedSubquery): number {\n return compareUTF8(must(a.subquery.alias), must(b.subquery.alias));\n}\n\n/**\n * Returns a flattened version of the Conditions in which nested Conjunctions with\n * the same operation ('AND' or 'OR') are flattened to the same level. e.g.\n *\n * ```\n * ((a AND b) AND (c AND (d OR (e OR f)))) -> (a AND b AND c AND (d OR e OR f))\n * ```\n *\n * Also flattens singleton Conjunctions regardless of operator, and removes\n * empty Conjunctions.\n */\nfunction flattened(cond: Condition): Condition | undefined {\n if (cond.type === 'simple' || cond.type === 'correlatedSubquery') {\n return cond;\n }\n const conditions = defined(\n cond.conditions.flatMap(c =>\n c.type === cond.type ? c.conditions.map(c => flattened(c)) : flattened(c),\n ),\n );\n\n switch (conditions.length) {\n case 0:\n return undefined;\n case 1:\n return conditions[0];\n default:\n return {\n type: cond.type,\n conditions,\n };\n }\n}\n\nfunction compareUTF8MaybeNull(a: string | null, b: string | null): number {\n if (a !== null && b !== null) {\n return compareUTF8(a, b);\n }\n if (b !== null) {\n return -1;\n }\n if (a !== null) {\n return 1;\n }\n return 0;\n}\n\nfunction cmpOptionalBool(\n a: boolean | undefined,\n b: boolean | undefined,\n): number {\n // undefined < false < true\n const toNum = (v: boolean | undefined) => (v === undefined ? 0 : v ? 2 : 1);\n return toNum(a) - toNum(b);\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAa,cAAc;AAE3B,IAAa,iBAAiB,eAAE,OAAO;AACvC,IAAa,gBAAgB,OAAO;AACpC,IAAa,eAAe,OAAO,QAAQ;AAM3C,IAAa,iBAAiB,cAJA,SAC5B,eAAE,MAAM,CAAC,gBAAgB,aAAe,OAAO,MAAM,CAAC,CAAC,CAGX,CAAqB;AAGpC,eAAE,MAC/B,eAAE,OAAO,GACT,eAAE,OAAO,GAC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AEA,SAAS,WAAW,GAAuB,GAA+B;CACxE,OAAO,YAAY,KAAK,EAAE,SAAS,KAAK,GAAG,KAAK,EAAE,SAAS,KAAK,CAAC;AACnE;;;;;;;;;;;;AAaA,SAAS,UAAU,MAAwC;CACzD,IAAI,KAAK,SAAS,YAAY,KAAK,SAAS,sBAC1C,OAAO;CAET,MAAM,aAAa,QACjB,KAAK,WAAW,SAAQ,MACtB,EAAE,SAAS,KAAK,OAAO,EAAE,WAAW,KAAI,MAAK,UAAU,CAAC,CAAC,IAAI,UAAU,CAAC,CAC1E,CACF;CAEA,QAAQ,WAAW,QAAnB;EACE,KAAK,GACH;EACF,KAAK,GACH,OAAO,WAAW;EACpB,SACE,OAAO;GACL,MAAM,KAAK;GACX;EACF;CACJ;AACF;AAEA,SAAS,qBAAqB,GAAkB,GAA0B;CACxE,IAAI,MAAM,QAAQ,MAAM,MACtB,OAAO,YAAY,GAAG,CAAC;CAEzB,IAAI,MAAM,MACR,OAAO;CAET,IAAI,MAAM,MACR,OAAO;CAET,OAAO;AACT;AAEA,SAAS,gBACP,GACA,GACQ;CAER,MAAM,SAAS,MAA4B,MAAM,KAAA,IAAY,IAAI,IAAI,IAAI;CACzE,OAAO,MAAM,CAAC,IAAI,MAAM,CAAC;AAC3B"}
|
|
1
|
+
{"version":3,"file":"ast.js","names":[],"sources":["../../../../zero-protocol/src/ast.ts"],"sourcesContent":["/**\n * Wire-format representation of the zql AST interface.\n *\n * `v.Type<...>` types are explicitly declared to facilitate Typescript verification\n * that the schemas satisfy the zql type definitions. (Incidentally, explicit types\n * are also required for recursive schema definitions.)\n */\n\nimport {compareUTF8} from 'compare-utf8';\nimport {defined} from '../../shared/src/arrays.ts';\nimport {assert} from '../../shared/src/asserts.ts';\nimport {must} from '../../shared/src/must.ts';\nimport * as v from '../../shared/src/valita.ts';\nimport type {NameMapper} from '../../zero-types/src/name-mapper.ts';\nimport {rowSchema, type Row} from './data.ts';\n\nexport const SUBQ_PREFIX = 'zsubq_';\n\nexport const selectorSchema = v.string();\nexport const toStaticParam = Symbol();\nexport const planIdSymbol = Symbol('planId');\n\nconst orderingElementSchema = v.readonly(\n v.tuple([selectorSchema, v.literalUnion('asc', 'desc')]),\n);\n\nexport const orderingSchema = v.readonlyArray(orderingElementSchema);\nexport type System = 'permissions' | 'client' | 'test';\n\nexport const primitiveSchema = v.union(\n v.string(),\n v.number(),\n v.boolean(),\n v.null(),\n);\n\nexport const equalityOpsSchema = v.literalUnion('=', '!=', 'IS', 'IS NOT');\n\nexport const orderOpsSchema = v.literalUnion('<', '>', '<=', '>=');\n\nexport const likeOpsSchema = v.literalUnion(\n 'LIKE',\n 'NOT LIKE',\n 'ILIKE',\n 'NOT ILIKE',\n);\n\nexport const inOpsSchema = v.literalUnion('IN', 'NOT IN');\n\nexport const simpleOperatorSchema = v.union(\n equalityOpsSchema,\n orderOpsSchema,\n likeOpsSchema,\n inOpsSchema,\n);\n\nconst literalReferenceSchema: v.Type<LiteralReference> = v.readonlyObject({\n type: v.literal('literal'),\n value: v.union(\n v.string(),\n v.number(),\n v.boolean(),\n v.null(),\n v.readonlyArray(v.union(v.string(), v.number(), v.boolean())),\n ),\n});\nconst columnReferenceSchema: v.Type<ColumnReference> = v.readonlyObject({\n type: v.literal('column'),\n name: v.string(),\n});\n\n/**\n * A parameter is a value that is not known at the time the query is written\n * and is resolved at runtime.\n *\n * Static parameters refer to something provided by the caller.\n * Static parameters are injected when the query pipeline is built from the AST\n * and do not change for the life of that pipeline.\n *\n * An example static parameter is the current authentication data.\n * When a user is authenticated, queries on the server have access\n * to the user's authentication data in order to evaluate authorization rules.\n * Authentication data doesn't change over the life of a query as a change\n * in auth data would represent a log-in / log-out of the user.\n *\n * AncestorParameters refer to rows encountered while running the query.\n * They are used by subqueries to refer to rows emitted by parent queries.\n */\nconst parameterReferenceSchema = v.readonlyObject({\n type: v.literal('static'),\n // The \"namespace\" of the injected parameter.\n // Write authorization will send the value of a row\n // prior to the mutation being run (preMutationRow).\n // Read and write authorization will both send the\n // current authentication data (authData).\n anchor: v.literalUnion('authData', 'preMutationRow'),\n field: v.union(v.string(), v.array(v.string())),\n});\n\nconst conditionValueSchema = v.union(\n literalReferenceSchema,\n columnReferenceSchema,\n parameterReferenceSchema,\n);\n\nexport type Parameter = v.Infer<typeof parameterReferenceSchema>;\n\nexport const simpleConditionSchema: v.Type<SimpleCondition> = v.readonlyObject({\n type: v.literal('simple'),\n op: simpleOperatorSchema,\n left: conditionValueSchema,\n right: v.union(parameterReferenceSchema, literalReferenceSchema),\n});\n\ntype ConditionValue = v.Infer<typeof conditionValueSchema>;\n\nexport const correlatedSubqueryConditionOperatorSchema: v.Type<CorrelatedSubqueryConditionOperator> =\n v.literalUnion('EXISTS', 'NOT EXISTS');\n\nexport const correlatedSubqueryConditionSchema: v.Type<CorrelatedSubqueryCondition> =\n v.readonlyObject({\n type: v.literal('correlatedSubquery'),\n related: v.lazy(() => correlatedSubquerySchema),\n op: correlatedSubqueryConditionOperatorSchema,\n flip: v.boolean().optional(),\n scalar: v.boolean().optional(),\n });\n\nexport const conditionSchema: v.Type<Condition> = v.union(\n simpleConditionSchema,\n v.lazy(() => conjunctionSchema),\n v.lazy(() => disjunctionSchema),\n correlatedSubqueryConditionSchema,\n);\n\nconst conjunctionSchema: v.Type<Conjunction> = v.readonlyObject({\n type: v.literal('and'),\n conditions: v.readonlyArray(conditionSchema),\n});\n\nconst disjunctionSchema: v.Type<Disjunction> = v.readonlyObject({\n type: v.literal('or'),\n conditions: v.readonlyArray(conditionSchema),\n});\n\nexport type CompoundKey = readonly [string, ...string[]];\n\nfunction mustCompoundKey(field: readonly string[]): CompoundKey {\n assert(\n Array.isArray(field) && field.length >= 1,\n 'Expected non-empty array for compound key',\n );\n return field as unknown as CompoundKey;\n}\n\nexport const compoundKeySchema: v.Type<CompoundKey> = v.readonly(\n // oxlint-disable-next-line e18e/prefer-spread-syntax\n v.tuple([v.string()]).concat(v.array(v.string())),\n);\n\nconst correlationSchema = v.readonlyObject({\n parentField: compoundKeySchema,\n childField: compoundKeySchema,\n});\n\n// Split out so that its inferred type can be checked against\n// Omit<CorrelatedSubquery, 'correlation'> in ast-type-test.ts.\n// The mutually-recursive reference of the 'other' field to astSchema\n// is the only thing added in v.lazy. The v.lazy is necessary due to the\n// mutually-recursive types, but v.lazy prevents inference of the resulting\n// type.\nexport const correlatedSubquerySchemaOmitSubquery = v.readonlyObject({\n correlation: correlationSchema,\n hidden: v.boolean().optional(),\n system: v.literalUnion('permissions', 'client', 'test').optional(),\n});\n\nexport const correlatedSubquerySchema: v.Type<CorrelatedSubquery> =\n correlatedSubquerySchemaOmitSubquery.extend({\n subquery: v.lazy(() => astSchema),\n });\n\nexport const astSchema: v.Type<AST> = v.readonlyObject({\n schema: v.string().optional(),\n table: v.string(),\n alias: v.string().optional(),\n where: conditionSchema.optional(),\n related: v.readonlyArray(correlatedSubquerySchema).optional(),\n limit: v.number().optional(),\n orderBy: orderingSchema.optional(),\n start: v\n .object({\n row: rowSchema,\n exclusive: v.boolean(),\n })\n .optional(),\n});\n\nexport type Bound = {\n row: Row;\n exclusive: boolean;\n};\n\n/**\n * As in SQL you can have multiple orderings. We don't currently\n * support ordering on anything other than the root query.\n */\nexport type OrderPart = readonly [field: string, direction: 'asc' | 'desc'];\nexport type Ordering = readonly OrderPart[];\n\nexport type SimpleOperator = EqualityOps | OrderOps | LikeOps | InOps;\nexport type EqualityOps = '=' | '!=' | 'IS' | 'IS NOT';\nexport type OrderOps = '<' | '>' | '<=' | '>=';\nexport type LikeOps = 'LIKE' | 'NOT LIKE' | 'ILIKE' | 'NOT ILIKE';\nexport type InOps = 'IN' | 'NOT IN';\n\nexport type AST = {\n readonly schema?: string | undefined;\n readonly table: string;\n\n // A query would be aliased if the AST is a subquery.\n // e.g., when two subqueries select from the same table\n // they need an alias to differentiate them.\n // `SELECT\n // [SELECT * FROM issue WHERE issue.id = outer.parentId] AS parent\n // [SELECT * FROM issue WHERE issue.parentId = outer.id] AS children\n // FROM issue as outer`\n readonly alias?: string | undefined;\n\n // `select` is missing given we return all columns for now.\n\n // The PipelineBuilder will pick what to use to correlate\n // a subquery with a parent query. It can choose something from the\n // where conditions or choose the _first_ `related` entry.\n // Choosing the first `related` entry is almost always the best choice if\n // one exists.\n readonly where?: Condition | undefined;\n\n readonly related?: readonly CorrelatedSubquery[] | undefined;\n readonly start?: Bound | undefined;\n readonly limit?: number | undefined;\n readonly orderBy?: Ordering | undefined;\n};\n\nexport type Correlation = {\n readonly parentField: CompoundKey;\n readonly childField: CompoundKey;\n};\n\nexport type CorrelatedSubquery = {\n /**\n * Only equality correlation are supported for now.\n * E.g., direct foreign key relationships.\n */\n readonly correlation: Correlation;\n readonly subquery: AST;\n readonly system?: System | undefined;\n // If a hop in the subquery chain should be hidden from the output view.\n // A common example is junction edges. The query API provides the illusion\n // that they don't exist: `issue.related('labels')` instead of `issue.related('issue_labels').related('labels')`.\n // To maintain this illusion, the junction edge should be hidden.\n // When `hidden` is set to true, this hop will not be included in the output view\n // but its children will be.\n readonly hidden?: boolean | undefined;\n};\n\nexport type ValuePosition = LiteralReference | Parameter | ColumnReference;\n\nexport type ColumnReference = {\n readonly type: 'column';\n /**\n * Not a path yet as we're currently not allowing\n * comparisons across tables. This will need to\n * be a path through the tree in the near future.\n */\n readonly name: string;\n};\n\nexport type LiteralReference = {\n readonly type: 'literal';\n readonly value: LiteralValue;\n};\n\nexport type LiteralValue =\n | string\n | number\n | boolean\n | null\n | ReadonlyArray<string | number | boolean>;\n\n/**\n * Starting only with SimpleCondition for now.\n * ivm1 supports Conjunctions and Disjunctions.\n * We'll support them in the future.\n */\nexport type Condition =\n | SimpleCondition\n | Conjunction\n | Disjunction\n | CorrelatedSubqueryCondition;\n\nexport type SimpleCondition = {\n readonly type: 'simple';\n readonly op: SimpleOperator;\n readonly left: ValuePosition;\n\n /**\n * `null` is absent since we do not have an `IS` or `IS NOT`\n * operator defined and `null != null` in SQL.\n */\n readonly right: Exclude<ValuePosition, ColumnReference>;\n};\n\nexport type Conjunction = {\n type: 'and';\n conditions: readonly Condition[];\n};\n\nexport type Disjunction = {\n type: 'or';\n conditions: readonly Condition[];\n};\n\nexport type CorrelatedSubqueryCondition = {\n type: 'correlatedSubquery';\n related: CorrelatedSubquery;\n op: CorrelatedSubqueryConditionOperator;\n flip?: boolean | undefined;\n scalar?: boolean | undefined;\n [planIdSymbol]?: number | undefined;\n};\n\nexport type CorrelatedSubqueryConditionOperator = 'EXISTS' | 'NOT EXISTS';\n\ninterface ASTTransform {\n tableName(orig: string): string;\n columnName(origTable: string, origColumn: string): string;\n related(subqueries: CorrelatedSubquery[]): readonly CorrelatedSubquery[];\n where(cond: Condition): Condition | undefined;\n // conjunction or disjunction, called when traversing the return value of where()\n conditions(conds: Condition[]): readonly Condition[];\n}\n\nfunction transformAST(ast: AST, transform: ASTTransform): Required<AST> {\n // Name mapping functions (e.g. to server names)\n const {tableName, columnName} = transform;\n const colName = (c: string) => columnName(ast.table, c);\n const key = (table: string, k: CompoundKey) => {\n const serverKey = k.map(col => columnName(table, col));\n return mustCompoundKey(serverKey);\n };\n\n const where = ast.where ? transform.where(ast.where) : undefined;\n const transformed = {\n schema: ast.schema,\n table: tableName(ast.table),\n alias: ast.alias,\n where: where ? transformWhere(where, ast.table, transform) : undefined,\n related: ast.related\n ? transform.related(\n ast.related.map(\n r =>\n ({\n correlation: {\n parentField: key(ast.table, r.correlation.parentField),\n childField: key(r.subquery.table, r.correlation.childField),\n },\n hidden: r.hidden,\n subquery: transformAST(r.subquery, transform),\n system: r.system,\n }) satisfies Required<CorrelatedSubquery>,\n ),\n )\n : undefined,\n start: ast.start\n ? {\n ...ast.start,\n row: Object.fromEntries(\n Object.entries(ast.start.row).map(([col, val]) => [\n colName(col),\n val,\n ]),\n ),\n }\n : undefined,\n limit: ast.limit,\n orderBy: ast.orderBy?.map(([col, dir]) => [colName(col), dir] as const),\n };\n\n return transformed;\n}\n\nfunction transformWhere(\n where: Condition,\n table: string,\n transform: ASTTransform,\n): Condition {\n // Name mapping functions (e.g. to server names)\n const {columnName} = transform;\n const condValue = (c: ConditionValue) =>\n c.type !== 'column' ? c : {...c, name: columnName(table, c.name)};\n const key = (table: string, k: CompoundKey) => {\n const serverKey = k.map(col => columnName(table, col));\n return mustCompoundKey(serverKey);\n };\n\n if (where.type === 'simple') {\n return {...where, left: condValue(where.left)};\n } else if (where.type === 'correlatedSubquery') {\n const {correlation, subquery} = where.related;\n return {\n ...where,\n related: {\n ...where.related,\n correlation: {\n parentField: key(table, correlation.parentField),\n childField: key(subquery.table, correlation.childField),\n },\n subquery: transformAST(subquery, transform),\n },\n };\n }\n\n return {\n type: where.type,\n conditions: transform.conditions(\n where.conditions.map(c => transformWhere(c, table, transform)),\n ),\n };\n}\n\nconst normalizeCache = new WeakMap<AST, Required<AST>>();\n\nconst NORMALIZE_TRANSFORM: ASTTransform = {\n tableName: t => t,\n columnName: (_, c) => c,\n related: sortedRelated,\n where: flattened,\n conditions: c => c.sort(cmpCondition),\n};\n\nexport function normalizeAST(ast: AST): Required<AST> {\n let normalized = normalizeCache.get(ast);\n if (!normalized) {\n normalized = transformAST(ast, NORMALIZE_TRANSFORM);\n normalizeCache.set(ast, normalized);\n }\n return normalized;\n}\n\nexport function mapAST(ast: AST, mapper: NameMapper) {\n return transformAST(ast, {\n tableName: table => mapper.tableName(table),\n columnName: (table, col) => mapper.columnName(table, col),\n related: r => r,\n where: w => w,\n conditions: c => c,\n });\n}\n\nexport function mapCondition(\n cond: Condition,\n table: string,\n mapper: NameMapper,\n) {\n return transformWhere(cond, table, {\n tableName: table => mapper.tableName(table),\n columnName: (table, col) => mapper.columnName(table, col),\n related: r => r,\n where: w => w,\n conditions: c => c,\n });\n}\n\nfunction sortedRelated(\n related: CorrelatedSubquery[],\n): readonly CorrelatedSubquery[] {\n return related.sort(cmpRelated);\n}\n\nfunction cmpCondition(a: Condition, b: Condition): number {\n if (a.type === 'simple') {\n if (b.type !== 'simple') {\n return -1; // Order SimpleConditions first\n }\n\n return (\n compareValuePosition(a.left, b.left) ||\n compareUTF8MaybeNull(a.op, b.op) ||\n compareValuePosition(a.right, b.right)\n );\n }\n\n if (b.type === 'simple') {\n return 1; // Order SimpleConditions first\n }\n\n if (a.type === 'correlatedSubquery') {\n if (b.type !== 'correlatedSubquery') {\n return -1; // Order subquery before conjuctions/disjuctions\n }\n return (\n cmpRelated(a.related, b.related) ||\n compareUTF8MaybeNull(a.op, b.op) ||\n cmpOptionalBool(a.flip, b.flip) ||\n cmpOptionalBool(a.scalar, b.scalar)\n );\n }\n if (b.type === 'correlatedSubquery') {\n return -1; // Order correlatedSubquery before conjuctions/disjuctions\n }\n\n const val = compareUTF8MaybeNull(a.type, b.type);\n if (val !== 0) {\n return val;\n }\n for (\n let l = 0, r = 0;\n l < a.conditions.length && r < b.conditions.length;\n l++, r++\n ) {\n const val = cmpCondition(a.conditions[l], b.conditions[r]);\n if (val !== 0) {\n return val;\n }\n }\n // prefixes first\n return a.conditions.length - b.conditions.length;\n}\n\nfunction compareValuePosition(a: ValuePosition, b: ValuePosition): number {\n if (a.type !== b.type) {\n return compareUTF8(a.type, b.type);\n }\n switch (a.type) {\n case 'literal':\n assert(b.type === 'literal', 'Expected literal type for comparison');\n return compareUTF8(String(a.value), String(b.value));\n case 'column':\n assert(b.type === 'column', 'Expected column type for comparison');\n return compareUTF8(a.name, b.name);\n case 'static':\n throw new Error(\n 'Static parameters should be resolved before normalization',\n );\n }\n}\n\nfunction cmpRelated(a: CorrelatedSubquery, b: CorrelatedSubquery): number {\n return compareUTF8(must(a.subquery.alias), must(b.subquery.alias));\n}\n\n/**\n * Returns a flattened version of the Conditions in which nested Conjunctions with\n * the same operation ('AND' or 'OR') are flattened to the same level. e.g.\n *\n * ```\n * ((a AND b) AND (c AND (d OR (e OR f)))) -> (a AND b AND c AND (d OR e OR f))\n * ```\n *\n * Also flattens singleton Conjunctions regardless of operator, and removes\n * empty Conjunctions.\n */\nfunction flattened(cond: Condition): Condition | undefined {\n if (cond.type === 'simple' || cond.type === 'correlatedSubquery') {\n return cond;\n }\n const conditions = defined(\n cond.conditions.flatMap(c =>\n c.type === cond.type ? c.conditions.map(c => flattened(c)) : flattened(c),\n ),\n );\n\n switch (conditions.length) {\n case 0:\n return undefined;\n case 1:\n return conditions[0];\n default:\n return {\n type: cond.type,\n conditions,\n };\n }\n}\n\nfunction compareUTF8MaybeNull(a: string | null, b: string | null): number {\n if (a !== null && b !== null) {\n return compareUTF8(a, b);\n }\n if (b !== null) {\n return -1;\n }\n if (a !== null) {\n return 1;\n }\n return 0;\n}\n\nfunction cmpOptionalBool(\n a: boolean | undefined,\n b: boolean | undefined,\n): number {\n // undefined < false < true\n const toNum = (v: boolean | undefined) => (v === undefined ? 0 : v ? 2 : 1);\n return toNum(a) - toNum(b);\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAa,cAAc;AAE3B,IAAa,iBAAiB,eAAE,QAAQ;AACxC,IAAa,gBAAgB,QAAQ;AACrC,IAAa,eAAe,OAAO,SAAS;AAM5C,IAAa,iBAAiB,cAJA,SAC5B,eAAE,MAAM,CAAC,gBAAgB,aAAe,OAAO,OAAO,CAAC,CAAC,CACzD,CAEmE;AAGrC,eAAE,MAC/B,eAAE,QAAQ,EACV,eAAE,QAAQ,EACV,eAAE,SAAS,EACX,eAAE,MAAM,CACT;AAED,IAAa,oBAAoB,aAAe,KAAK,MAAM,MAAM,SAAS;AAE1E,IAAa,iBAAiB,aAAe,KAAK,KAAK,MAAM,KAAK;AAElE,IAAa,gBAAgB,aAC3B,QACA,YACA,SACA,YACD;AAED,IAAa,cAAc,aAAe,MAAM,SAAS;AAEzD,IAAa,uBAAuB,eAAE,MACpC,mBACA,gBACA,eACA,YACD;AAED,IAAM,yBAAmD,eAAiB;CACxE,MAAM,eAAE,QAAQ,UAAU;CAC1B,OAAO,eAAE,MACP,eAAE,QAAQ,EACV,eAAE,QAAQ,EACV,eAAE,SAAS,EACX,eAAE,MAAM,EACR,cAAgB,eAAE,MAAM,eAAE,QAAQ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MAAM,KACtB,QAAO,YAAY,GAAG,EAAE;AAE1B,KAAI,MAAM,KACR,QAAO;AAET,KAAI,MAAM,KACR,QAAO;AAET,QAAO;;AAGT,SAAS,gBACP,GACA,GACQ;CAER,MAAM,SAAS,MAA4B,MAAM,KAAA,IAAY,IAAI,IAAI,IAAI;AACzE,QAAO,MAAM,EAAE,GAAG,MAAM,EAAE"}
|
|
@@ -3,7 +3,6 @@ import { upQueriesPatchSchema } from "./queries-patch.js";
|
|
|
3
3
|
//#region ../zero-protocol/src/change-desired-queries.ts
|
|
4
4
|
var changeDesiredQueriesBodySchema = valita_exports.object({
|
|
5
5
|
desiredQueriesPatch: upQueriesPatchSchema,
|
|
6
|
-
/** W3C traceparent header for distributed tracing. */
|
|
7
6
|
traceparent: valita_exports.string().optional()
|
|
8
7
|
});
|
|
9
8
|
var changeDesiredQueriesMessageSchema = valita_exports.tuple([valita_exports.literal("changeDesiredQueries"), changeDesiredQueriesBodySchema]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change-desired-queries.js","names":[],"sources":["../../../../zero-protocol/src/change-desired-queries.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {upQueriesPatchSchema} from './queries-patch.ts';\n\nconst changeDesiredQueriesBodySchema = v.object({\n desiredQueriesPatch: upQueriesPatchSchema,\n /** W3C traceparent header for distributed tracing. */\n traceparent: v.string().optional(),\n});\n\nexport const changeDesiredQueriesMessageSchema = v.tuple([\n v.literal('changeDesiredQueries'),\n changeDesiredQueriesBodySchema,\n]);\n\nexport type ChangeDesiredQueriesBody = v.Infer<\n typeof changeDesiredQueriesBodySchema\n>;\nexport type ChangeDesiredQueriesMessage = v.Infer<\n typeof changeDesiredQueriesMessageSchema\n>;\n"],"mappings":";;;AAGA,IAAM,iCAAiC,eAAE,OAAO;CAC9C,qBAAqB
|
|
1
|
+
{"version":3,"file":"change-desired-queries.js","names":[],"sources":["../../../../zero-protocol/src/change-desired-queries.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {upQueriesPatchSchema} from './queries-patch.ts';\n\nconst changeDesiredQueriesBodySchema = v.object({\n desiredQueriesPatch: upQueriesPatchSchema,\n /** W3C traceparent header for distributed tracing. */\n traceparent: v.string().optional(),\n});\n\nexport const changeDesiredQueriesMessageSchema = v.tuple([\n v.literal('changeDesiredQueries'),\n changeDesiredQueriesBodySchema,\n]);\n\nexport type ChangeDesiredQueriesBody = v.Infer<\n typeof changeDesiredQueriesBodySchema\n>;\nexport type ChangeDesiredQueriesMessage = v.Infer<\n typeof changeDesiredQueriesMessageSchema\n>;\n"],"mappings":";;;AAGA,IAAM,iCAAiC,eAAE,OAAO;CAC9C,qBAAqB;CAErB,aAAa,eAAE,QAAQ,CAAC,UAAU;CACnC,CAAC;AAEF,IAAa,oCAAoC,eAAE,MAAM,CACvD,eAAE,QAAQ,uBAAuB,EACjC,+BACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-schema.js","names":[],"sources":["../../../../zero-protocol/src/client-schema.ts"],"sourcesContent":["import {must} from '../../shared/src/must.ts';\nimport {mapAllEntries} from '../../shared/src/objects.ts';\nimport * as v from '../../shared/src/valita.ts';\n\nexport type ValueType = 'string' | 'number' | 'boolean' | 'null' | 'json';\n\nexport const valueTypeSchema: v.Type<ValueType> = v.literalUnion(\n 'string',\n 'number',\n 'boolean',\n 'null',\n 'json',\n);\n\nexport const columnSchemaSchema = v.object({\n type: valueTypeSchema,\n});\n\nexport type ColumnSchema = v.Infer<typeof columnSchemaSchema>;\n\nexport const tableSchemaSchema = v.object({\n columns: v.record(columnSchemaSchema),\n primaryKey: v.array(v.string()),\n});\n\nexport type TableSchema = v.Infer<typeof tableSchemaSchema>;\n\nexport const clientSchemaSchema = v.object({\n tables: v.record(tableSchemaSchema),\n});\n\nexport type ClientSchema = v.Infer<typeof clientSchemaSchema>;\n\nconst keyCmp = ([a]: [a: string, _: unknown], [b]: [b: string, _: unknown]) =>\n a < b ? -1 : a > b ? 1 : 0;\n\n/**\n * Returns a normalized schema (with the tables and columns sorted)\n * suitable for hashing.\n */\nexport function normalizeClientSchema(schema: ClientSchema): ClientSchema {\n return {\n tables: mapAllEntries(schema.tables, tables =>\n tables.sort(keyCmp).map(([name, table]) => [\n name,\n {\n columns: mapAllEntries(table.columns, e => e.sort(keyCmp)),\n primaryKey: must(\n table.primaryKey,\n `new clients always specify a primaryKey`,\n ).sort(),\n },\n ]),\n ),\n };\n}\n"],"mappings":";;;;AAMA,IAAa,kBAAqC,aAChD,UACA,UACA,WACA,QACA,
|
|
1
|
+
{"version":3,"file":"client-schema.js","names":[],"sources":["../../../../zero-protocol/src/client-schema.ts"],"sourcesContent":["import {must} from '../../shared/src/must.ts';\nimport {mapAllEntries} from '../../shared/src/objects.ts';\nimport * as v from '../../shared/src/valita.ts';\n\nexport type ValueType = 'string' | 'number' | 'boolean' | 'null' | 'json';\n\nexport const valueTypeSchema: v.Type<ValueType> = v.literalUnion(\n 'string',\n 'number',\n 'boolean',\n 'null',\n 'json',\n);\n\nexport const columnSchemaSchema = v.object({\n type: valueTypeSchema,\n});\n\nexport type ColumnSchema = v.Infer<typeof columnSchemaSchema>;\n\nexport const tableSchemaSchema = v.object({\n columns: v.record(columnSchemaSchema),\n primaryKey: v.array(v.string()),\n});\n\nexport type TableSchema = v.Infer<typeof tableSchemaSchema>;\n\nexport const clientSchemaSchema = v.object({\n tables: v.record(tableSchemaSchema),\n});\n\nexport type ClientSchema = v.Infer<typeof clientSchemaSchema>;\n\nconst keyCmp = ([a]: [a: string, _: unknown], [b]: [b: string, _: unknown]) =>\n a < b ? -1 : a > b ? 1 : 0;\n\n/**\n * Returns a normalized schema (with the tables and columns sorted)\n * suitable for hashing.\n */\nexport function normalizeClientSchema(schema: ClientSchema): ClientSchema {\n return {\n tables: mapAllEntries(schema.tables, tables =>\n tables.sort(keyCmp).map(([name, table]) => [\n name,\n {\n columns: mapAllEntries(table.columns, e => e.sort(keyCmp)),\n primaryKey: must(\n table.primaryKey,\n `new clients always specify a primaryKey`,\n ).sort(),\n },\n ]),\n ),\n };\n}\n"],"mappings":";;;;AAMA,IAAa,kBAAqC,aAChD,UACA,UACA,WACA,QACA,OACD;AAED,IAAa,qBAAqB,eAAE,OAAO,EACzC,MAAM,iBACP,CAAC;AAIF,IAAa,oBAAoB,eAAE,OAAO;CACxC,SAAS,eAAE,OAAO,mBAAmB;CACrC,YAAY,eAAE,MAAM,eAAE,QAAQ,CAAC;CAChC,CAAC;AAIF,IAAa,qBAAqB,eAAE,OAAO,EACzC,QAAQ,eAAE,OAAO,kBAAkB,EACpC,CAAC;AAIF,IAAM,UAAU,CAAC,IAA6B,CAAC,OAC7C,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI;;;;;AAM3B,SAAgB,sBAAsB,QAAoC;AACxE,QAAO,EACL,QAAQ,cAAc,OAAO,SAAQ,WACnC,OAAO,KAAK,OAAO,CAAC,KAAK,CAAC,MAAM,WAAW,CACzC,MACA;EACE,SAAS,cAAc,MAAM,UAAS,MAAK,EAAE,KAAK,OAAO,CAAC;EAC1D,YAAY,KACV,MAAM,YACN,0CACD,CAAC,MAAM;EACT,CACF,CAAC,CACH,EACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close-connection.js","names":[],"sources":["../../../../zero-protocol/src/close-connection.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\n\n/**\n * We do not use the body yet.\n */\nexport const closeConnectionBodySchema = v.array(v.unknown());\n\n/**\n * This message gets sent as part of the close reason in the WebSocket close event.\n * The close reason is a string, so we serialize this message to JSON.\n \n * \"The value must be no longer than 123 bytes (encoded in UTF-8).\" -\n * https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close#reason\n * \n * @deprecated\n */\nexport const closeConnectionMessageSchema = v.tuple([\n v.literal('closeConnection'),\n closeConnectionBodySchema,\n]);\n\n/** @deprecated */\nexport type CloseConnectionBody = v.Infer<typeof closeConnectionBodySchema>;\n\n/** @deprecated */\nexport type CloseConnectionMessage = v.Infer<\n typeof closeConnectionMessageSchema\n>;\n"],"mappings":";;;;;AAKA,IAAa,4BAA4B,eAAE,MAAM,eAAE,
|
|
1
|
+
{"version":3,"file":"close-connection.js","names":[],"sources":["../../../../zero-protocol/src/close-connection.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\n\n/**\n * We do not use the body yet.\n */\nexport const closeConnectionBodySchema = v.array(v.unknown());\n\n/**\n * This message gets sent as part of the close reason in the WebSocket close event.\n * The close reason is a string, so we serialize this message to JSON.\n \n * \"The value must be no longer than 123 bytes (encoded in UTF-8).\" -\n * https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close#reason\n * \n * @deprecated\n */\nexport const closeConnectionMessageSchema = v.tuple([\n v.literal('closeConnection'),\n closeConnectionBodySchema,\n]);\n\n/** @deprecated */\nexport type CloseConnectionBody = v.Infer<typeof closeConnectionBodySchema>;\n\n/** @deprecated */\nexport type CloseConnectionMessage = v.Infer<\n typeof closeConnectionMessageSchema\n>;\n"],"mappings":";;;;;AAKA,IAAa,4BAA4B,eAAE,MAAM,eAAE,SAAS,CAAC;;;;;;;;;;AAW7D,IAAa,+BAA+B,eAAE,MAAM,CAClD,eAAE,QAAQ,kBAAkB,EAC5B,0BACD,CAAC"}
|
|
@@ -23,14 +23,7 @@ var initConnectionBodySchema = valita_exports.object({
|
|
|
23
23
|
userPushHeaders: valita_exports.record(valita_exports.string()).optional(),
|
|
24
24
|
userQueryURL: valita_exports.string().optional(),
|
|
25
25
|
userQueryHeaders: valita_exports.record(valita_exports.string()).optional(),
|
|
26
|
-
/**
|
|
27
|
-
* `activeClients` is an optional array of client IDs that are currently active
|
|
28
|
-
* in the client group. This is used to inform the server about the clients
|
|
29
|
-
* that are currently active (aka running, aka alive), so it can inactive
|
|
30
|
-
* queries from inactive clients.
|
|
31
|
-
*/
|
|
32
26
|
activeClients: valita_exports.array(valita_exports.string()).optional(),
|
|
33
|
-
/** W3C traceparent header for distributed tracing. */
|
|
34
27
|
traceparent: valita_exports.string().optional()
|
|
35
28
|
});
|
|
36
29
|
var initConnectionMessageSchema = valita_exports.tuple([valita_exports.literal("initConnection"), initConnectionBodySchema]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","names":[],"sources":["../../../../zero-protocol/src/connect.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {clientSchemaSchema} from './client-schema.ts';\nimport {deleteClientsBodySchema} from './delete-clients.ts';\nimport {upQueriesPatchSchema} from './queries-patch.ts';\n\n/**\n * After opening a websocket the client waits for a `connected` message\n * from the server. It then sends an `initConnection` message to the\n * server. The server waits for the `initConnection` message before\n * beginning to send pokes to the newly connected client, so as to avoid\n * syncing lots of queries which are no longer desired by the client.\n */\n\nexport const connectedBodySchema = v.object({\n wsid: v.string(),\n timestamp: v.number().optional(),\n});\n\nexport const connectedMessageSchema = v.tuple([\n v.literal('connected'),\n connectedBodySchema,\n]);\n\nconst initConnectionBodySchema = v.object({\n desiredQueriesPatch: upQueriesPatchSchema,\n // As the schema can be large, client only sends when it does not have a\n // server snapshot (i.e. a snapshot with a cookie). Once it has a server\n // snapshot it will assume the zero-cache already has the schema for this\n // client's client group in the CVR store.\n clientSchema: clientSchemaSchema.optional(),\n deleted: deleteClientsBodySchema.optional(),\n // parameters to configure the mutate endpoint\n userPushURL: v.string().optional(),\n userPushHeaders: v.record(v.string()).optional(),\n // parameters to configure the query endpoint\n userQueryURL: v.string().optional(),\n userQueryHeaders: v.record(v.string()).optional(),\n\n /**\n * `activeClients` is an optional array of client IDs that are currently active\n * in the client group. This is used to inform the server about the clients\n * that are currently active (aka running, aka alive), so it can inactive\n * queries from inactive clients.\n */\n activeClients: v.array(v.string()).optional(),\n /** W3C traceparent header for distributed tracing. */\n traceparent: v.string().optional(),\n});\n\nexport const initConnectionMessageSchema = v.tuple([\n v.literal('initConnection'),\n initConnectionBodySchema,\n]);\n\nexport type ConnectedBody = v.Infer<typeof connectedBodySchema>;\nexport type ConnectedMessage = v.Infer<typeof connectedMessageSchema>;\nexport type InitConnectionBody = v.Infer<typeof initConnectionBodySchema>;\nexport type InitConnectionMessage = v.Infer<typeof initConnectionMessageSchema>;\n\nexport function encodeSecProtocols(\n initConnectionMessage: InitConnectionMessage | undefined,\n authToken: string | undefined,\n): string {\n const protocols = {\n initConnectionMessage,\n authToken,\n };\n // WS sec protocols needs to be URI encoded. To save space, we base64 encode\n // the JSON before URI encoding it. But InitConnectionMessage can contain\n // arbitrary unicode strings, so we need to encode the JSON as UTF-8 first.\n // Phew!\n const bytes = new TextEncoder().encode(JSON.stringify(protocols));\n\n // Convert bytes to string without spreading all bytes as arguments\n // to avoid \"Maximum call stack size exceeded\" error with large data\n const s = Array.from(bytes, byte => String.fromCharCode(byte)).join('');\n\n return encodeURIComponent(btoa(s));\n}\n\nexport function decodeSecProtocols(secProtocol: string): {\n initConnectionMessage: InitConnectionMessage | undefined;\n authToken: string | undefined;\n} {\n const binString = atob(decodeURIComponent(secProtocol));\n const bytes = Uint8Array.from(binString, c => c.charCodeAt(0));\n return JSON.parse(new TextDecoder().decode(bytes));\n}\n"],"mappings":";;;;;;;;;;;;AAaA,IAAa,sBAAsB,eAAE,OAAO;CAC1C,MAAM,eAAE,
|
|
1
|
+
{"version":3,"file":"connect.js","names":[],"sources":["../../../../zero-protocol/src/connect.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {clientSchemaSchema} from './client-schema.ts';\nimport {deleteClientsBodySchema} from './delete-clients.ts';\nimport {upQueriesPatchSchema} from './queries-patch.ts';\n\n/**\n * After opening a websocket the client waits for a `connected` message\n * from the server. It then sends an `initConnection` message to the\n * server. The server waits for the `initConnection` message before\n * beginning to send pokes to the newly connected client, so as to avoid\n * syncing lots of queries which are no longer desired by the client.\n */\n\nexport const connectedBodySchema = v.object({\n wsid: v.string(),\n timestamp: v.number().optional(),\n});\n\nexport const connectedMessageSchema = v.tuple([\n v.literal('connected'),\n connectedBodySchema,\n]);\n\nconst initConnectionBodySchema = v.object({\n desiredQueriesPatch: upQueriesPatchSchema,\n // As the schema can be large, client only sends when it does not have a\n // server snapshot (i.e. a snapshot with a cookie). Once it has a server\n // snapshot it will assume the zero-cache already has the schema for this\n // client's client group in the CVR store.\n clientSchema: clientSchemaSchema.optional(),\n deleted: deleteClientsBodySchema.optional(),\n // parameters to configure the mutate endpoint\n userPushURL: v.string().optional(),\n userPushHeaders: v.record(v.string()).optional(),\n // parameters to configure the query endpoint\n userQueryURL: v.string().optional(),\n userQueryHeaders: v.record(v.string()).optional(),\n\n /**\n * `activeClients` is an optional array of client IDs that are currently active\n * in the client group. This is used to inform the server about the clients\n * that are currently active (aka running, aka alive), so it can inactive\n * queries from inactive clients.\n */\n activeClients: v.array(v.string()).optional(),\n /** W3C traceparent header for distributed tracing. */\n traceparent: v.string().optional(),\n});\n\nexport const initConnectionMessageSchema = v.tuple([\n v.literal('initConnection'),\n initConnectionBodySchema,\n]);\n\nexport type ConnectedBody = v.Infer<typeof connectedBodySchema>;\nexport type ConnectedMessage = v.Infer<typeof connectedMessageSchema>;\nexport type InitConnectionBody = v.Infer<typeof initConnectionBodySchema>;\nexport type InitConnectionMessage = v.Infer<typeof initConnectionMessageSchema>;\n\nexport function encodeSecProtocols(\n initConnectionMessage: InitConnectionMessage | undefined,\n authToken: string | undefined,\n): string {\n const protocols = {\n initConnectionMessage,\n authToken,\n };\n // WS sec protocols needs to be URI encoded. To save space, we base64 encode\n // the JSON before URI encoding it. But InitConnectionMessage can contain\n // arbitrary unicode strings, so we need to encode the JSON as UTF-8 first.\n // Phew!\n const bytes = new TextEncoder().encode(JSON.stringify(protocols));\n\n // Convert bytes to string without spreading all bytes as arguments\n // to avoid \"Maximum call stack size exceeded\" error with large data\n const s = Array.from(bytes, byte => String.fromCharCode(byte)).join('');\n\n return encodeURIComponent(btoa(s));\n}\n\nexport function decodeSecProtocols(secProtocol: string): {\n initConnectionMessage: InitConnectionMessage | undefined;\n authToken: string | undefined;\n} {\n const binString = atob(decodeURIComponent(secProtocol));\n const bytes = Uint8Array.from(binString, c => c.charCodeAt(0));\n return JSON.parse(new TextDecoder().decode(bytes));\n}\n"],"mappings":";;;;;;;;;;;;AAaA,IAAa,sBAAsB,eAAE,OAAO;CAC1C,MAAM,eAAE,QAAQ;CAChB,WAAW,eAAE,QAAQ,CAAC,UAAU;CACjC,CAAC;AAEF,IAAa,yBAAyB,eAAE,MAAM,CAC5C,eAAE,QAAQ,YAAY,EACtB,oBACD,CAAC;AAEF,IAAM,2BAA2B,eAAE,OAAO;CACxC,qBAAqB;CAKrB,cAAc,mBAAmB,UAAU;CAC3C,SAAS,wBAAwB,UAAU;CAE3C,aAAa,eAAE,QAAQ,CAAC,UAAU;CAClC,iBAAiB,eAAE,OAAO,eAAE,QAAQ,CAAC,CAAC,UAAU;CAEhD,cAAc,eAAE,QAAQ,CAAC,UAAU;CACnC,kBAAkB,eAAE,OAAO,eAAE,QAAQ,CAAC,CAAC,UAAU;CAQjD,eAAe,eAAE,MAAM,eAAE,QAAQ,CAAC,CAAC,UAAU;CAE7C,aAAa,eAAE,QAAQ,CAAC,UAAU;CACnC,CAAC;AAEF,IAAa,8BAA8B,eAAE,MAAM,CACjD,eAAE,QAAQ,iBAAiB,EAC3B,yBACD,CAAC;AAOF,SAAgB,mBACd,uBACA,WACQ;CACR,MAAM,YAAY;EAChB;EACA;EACD;CAKD,MAAM,QAAQ,IAAI,aAAa,CAAC,OAAO,KAAK,UAAU,UAAU,CAAC;CAIjE,MAAM,IAAI,MAAM,KAAK,QAAO,SAAQ,OAAO,aAAa,KAAK,CAAC,CAAC,KAAK,GAAG;AAEvE,QAAO,mBAAmB,KAAK,EAAE,CAAC;;AAGpC,SAAgB,mBAAmB,aAGjC;CACA,MAAM,YAAY,KAAK,mBAAmB,YAAY,CAAC;CACvD,MAAM,QAAQ,WAAW,KAAK,YAAW,MAAK,EAAE,WAAW,EAAE,CAAC;AAC9D,QAAO,KAAK,MAAM,IAAI,aAAa,CAAC,OAAO,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-queries.js","names":[],"sources":["../../../../zero-protocol/src/custom-queries.ts"],"sourcesContent":["import {jsonSchema} from '../../shared/src/json-schema.ts';\nimport * as v from '../../shared/src/valita.ts';\nimport {astSchema} from './ast.ts';\nimport {transformFailedBodySchema} from './error.ts';\n\nexport const transformRequestBodySchema = v.array(\n v.object({\n id: v.string(),\n name: v.string(),\n args: v.readonly(v.array(jsonSchema)),\n }),\n);\nexport type TransformRequestBody = v.Infer<typeof transformRequestBodySchema>;\n\nexport const transformedQuerySchema = v.object({\n id: v.string(),\n name: v.string(),\n ast: astSchema,\n});\n\nexport const appErroredQuerySchema = v.object({\n error: v.literal('app'),\n id: v.string(),\n name: v.string(),\n // optional for backwards compatibility\n message: v.string().optional(),\n details: jsonSchema.optional(),\n});\nexport const parseErroredQuerySchema = v.object({\n error: v.literal('parse'),\n id: v.string(),\n name: v.string(),\n message: v.string(),\n details: jsonSchema.optional(),\n});\nexport const erroredQuerySchema = v.union(\n appErroredQuerySchema,\n parseErroredQuerySchema,\n);\nexport type ErroredQuery = v.Infer<typeof erroredQuerySchema>;\n\nexport const transformResponseBodySchema = v.array(\n v.union(transformedQuerySchema, erroredQuerySchema),\n);\nexport type TransformResponseBody = v.Infer<typeof transformResponseBodySchema>;\n\nexport const transformRequestMessageSchema = v.tuple([\n v.literal('transform'),\n transformRequestBodySchema,\n]);\nexport type TransformRequestMessage = v.Infer<\n typeof transformRequestMessageSchema\n>;\nexport const transformErrorMessageSchema = v.tuple([\n v.literal('transformError'),\n v.array(erroredQuerySchema),\n]);\nexport type TransformErrorMessage = v.Infer<typeof transformErrorMessageSchema>;\n\nconst transformFailedMessageSchema = v.tuple([\n v.literal('transformFailed'),\n transformFailedBodySchema,\n]);\nconst transformOkMessageSchema = v.tuple([\n v.literal('transformed'),\n transformResponseBodySchema,\n]);\n\nexport const transformResponseMessageSchema = v.union(\n transformOkMessageSchema,\n transformFailedMessageSchema,\n);\nexport type TransformResponseMessage = v.Infer<\n typeof transformResponseMessageSchema\n>;\n"],"mappings":";;;;;AAKA,IAAa,6BAA6B,eAAE,MAC1C,eAAE,OAAO;CACP,IAAI,eAAE,
|
|
1
|
+
{"version":3,"file":"custom-queries.js","names":[],"sources":["../../../../zero-protocol/src/custom-queries.ts"],"sourcesContent":["import {jsonSchema} from '../../shared/src/json-schema.ts';\nimport * as v from '../../shared/src/valita.ts';\nimport {astSchema} from './ast.ts';\nimport {transformFailedBodySchema} from './error.ts';\n\nexport const transformRequestBodySchema = v.array(\n v.object({\n id: v.string(),\n name: v.string(),\n args: v.readonly(v.array(jsonSchema)),\n }),\n);\nexport type TransformRequestBody = v.Infer<typeof transformRequestBodySchema>;\n\nexport const transformedQuerySchema = v.object({\n id: v.string(),\n name: v.string(),\n ast: astSchema,\n});\n\nexport const appErroredQuerySchema = v.object({\n error: v.literal('app'),\n id: v.string(),\n name: v.string(),\n // optional for backwards compatibility\n message: v.string().optional(),\n details: jsonSchema.optional(),\n});\nexport const parseErroredQuerySchema = v.object({\n error: v.literal('parse'),\n id: v.string(),\n name: v.string(),\n message: v.string(),\n details: jsonSchema.optional(),\n});\nexport const erroredQuerySchema = v.union(\n appErroredQuerySchema,\n parseErroredQuerySchema,\n);\nexport type ErroredQuery = v.Infer<typeof erroredQuerySchema>;\n\nexport const transformResponseBodySchema = v.array(\n v.union(transformedQuerySchema, erroredQuerySchema),\n);\nexport type TransformResponseBody = v.Infer<typeof transformResponseBodySchema>;\n\nexport const transformRequestMessageSchema = v.tuple([\n v.literal('transform'),\n transformRequestBodySchema,\n]);\nexport type TransformRequestMessage = v.Infer<\n typeof transformRequestMessageSchema\n>;\nexport const transformErrorMessageSchema = v.tuple([\n v.literal('transformError'),\n v.array(erroredQuerySchema),\n]);\nexport type TransformErrorMessage = v.Infer<typeof transformErrorMessageSchema>;\n\nconst transformFailedMessageSchema = v.tuple([\n v.literal('transformFailed'),\n transformFailedBodySchema,\n]);\nconst transformOkMessageSchema = v.tuple([\n v.literal('transformed'),\n transformResponseBodySchema,\n]);\n\nexport const transformResponseMessageSchema = v.union(\n transformOkMessageSchema,\n transformFailedMessageSchema,\n);\nexport type TransformResponseMessage = v.Infer<\n typeof transformResponseMessageSchema\n>;\n"],"mappings":";;;;;AAKA,IAAa,6BAA6B,eAAE,MAC1C,eAAE,OAAO;CACP,IAAI,eAAE,QAAQ;CACd,MAAM,eAAE,QAAQ;CAChB,MAAM,SAAW,eAAE,MAAM,WAAW,CAAC;CACtC,CAAC,CACH;AAGD,IAAa,yBAAyB,eAAE,OAAO;CAC7C,IAAI,eAAE,QAAQ;CACd,MAAM,eAAE,QAAQ;CAChB,KAAK;CACN,CAAC;AAEF,IAAa,wBAAwB,eAAE,OAAO;CAC5C,OAAO,eAAE,QAAQ,MAAM;CACvB,IAAI,eAAE,QAAQ;CACd,MAAM,eAAE,QAAQ;CAEhB,SAAS,eAAE,QAAQ,CAAC,UAAU;CAC9B,SAAS,WAAW,UAAU;CAC/B,CAAC;AACF,IAAa,0BAA0B,eAAE,OAAO;CAC9C,OAAO,eAAE,QAAQ,QAAQ;CACzB,IAAI,eAAE,QAAQ;CACd,MAAM,eAAE,QAAQ;CAChB,SAAS,eAAE,QAAQ;CACnB,SAAS,WAAW,UAAU;CAC/B,CAAC;AACF,IAAa,qBAAqB,eAAE,MAClC,uBACA,wBACD;AAGD,IAAa,8BAA8B,eAAE,MAC3C,eAAE,MAAM,wBAAwB,mBAAmB,CACpD;AAGD,IAAa,gCAAgC,eAAE,MAAM,CACnD,eAAE,QAAQ,YAAY,EACtB,2BACD,CAAC;AAIF,IAAa,8BAA8B,eAAE,MAAM,CACjD,eAAE,QAAQ,iBAAiB,EAC3B,eAAE,MAAM,mBAAmB,CAC5B,CAAC;AAGF,IAAM,+BAA+B,eAAE,MAAM,CAC3C,eAAE,QAAQ,kBAAkB,EAC5B,0BACD,CAAC;AACF,IAAM,2BAA2B,eAAE,MAAM,CACvC,eAAE,QAAQ,cAAc,EACxB,4BACD,CAAC;AAEF,IAAa,iCAAiC,eAAE,MAC9C,0BACA,6BACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.js","names":[],"sources":["../../../../zero-protocol/src/data.ts"],"sourcesContent":["import {jsonSchema} from '../../shared/src/json-schema.ts';\nimport * as v from '../../shared/src/valita.ts';\n\nexport const valueSchema = v.union(jsonSchema, v.undefined());\n\nexport const rowSchema = v.readonlyRecord(valueSchema);\n\n/**\n * The data types that Zero can represent are limited by two things:\n *\n * 1. The underlying Replicache sync layer currently can only represent JSON\n * types. This could possibly be expanded in the future, but we do want to be\n * careful of adding encoding overhead. By using JSON, we are taking\n * advantage of IndexedDB’s fast native JSValue [de]serialization which has\n * historically been a perf advantage for us.\n *\n * 2. IDs in Zero need to be comparable because we use them for sorting and row\n * identity. We could expand the set of allowed value types (to include,\n * i.e., Objects) but we would then need to restrict IDs to only comparable\n * types.\n *\n * These two facts leave us with the following allowed types. Zero's replication\n * layer must convert other types into these for tables to be used with Zero.\n *\n * For developer convenience we also allow `undefined`, which we treat\n * equivalently to `null`.\n */\nexport type Value = v.Infer<typeof valueSchema>;\n\n/**\n * A Row is represented as a JS Object.\n *\n * We do everything in IVM as loosely typed values because these pipelines are\n * going to be constructed at runtime by other code, so type-safety can't buy us\n * anything.\n *\n * Also since the calling code on the client ultimately wants objects to work\n * with we end up with a lot less copies by using objects throughout.\n */\nexport type Row = v.Infer<typeof rowSchema>;\n"],"mappings":";;AAKA,IAAa,YAAY,eAFE,eAAE,MAAM,YAAY,eAAE,
|
|
1
|
+
{"version":3,"file":"data.js","names":[],"sources":["../../../../zero-protocol/src/data.ts"],"sourcesContent":["import {jsonSchema} from '../../shared/src/json-schema.ts';\nimport * as v from '../../shared/src/valita.ts';\n\nexport const valueSchema = v.union(jsonSchema, v.undefined());\n\nexport const rowSchema = v.readonlyRecord(valueSchema);\n\n/**\n * The data types that Zero can represent are limited by two things:\n *\n * 1. The underlying Replicache sync layer currently can only represent JSON\n * types. This could possibly be expanded in the future, but we do want to be\n * careful of adding encoding overhead. By using JSON, we are taking\n * advantage of IndexedDB’s fast native JSValue [de]serialization which has\n * historically been a perf advantage for us.\n *\n * 2. IDs in Zero need to be comparable because we use them for sorting and row\n * identity. We could expand the set of allowed value types (to include,\n * i.e., Objects) but we would then need to restrict IDs to only comparable\n * types.\n *\n * These two facts leave us with the following allowed types. Zero's replication\n * layer must convert other types into these for tables to be used with Zero.\n *\n * For developer convenience we also allow `undefined`, which we treat\n * equivalently to `null`.\n */\nexport type Value = v.Infer<typeof valueSchema>;\n\n/**\n * A Row is represented as a JS Object.\n *\n * We do everything in IVM as loosely typed values because these pipelines are\n * going to be constructed at runtime by other code, so type-safety can't buy us\n * anything.\n *\n * Also since the calling code on the client ultimately wants objects to work\n * with we end up with a lot less copies by using objects throughout.\n */\nexport type Row = v.Infer<typeof rowSchema>;\n"],"mappings":";;AAKA,IAAa,YAAY,eAFE,eAAE,MAAM,YAAY,eAAE,WAAW,CAAC,CAEP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-clients.js","names":[],"sources":["../../../../zero-protocol/src/delete-clients.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\n\nexport const deleteClientsBodySchema = v.union(\n v.readonlyObject({\n clientIDs: v.readonlyArray(v.string()).optional(),\n clientGroupIDs: v.readonlyArray(v.string()).optional(),\n }),\n);\n\nexport const deleteClientsMessageSchema = v.tuple([\n v.literal('deleteClients'),\n deleteClientsBodySchema,\n]);\n\nexport type DeleteClientsBody = v.Infer<typeof deleteClientsBodySchema>;\nexport type DeleteClientsMessage = v.Infer<typeof deleteClientsMessageSchema>;\n"],"mappings":";;AAEA,IAAa,0BAA0B,eAAE,MACvC,eAAiB;CACf,WAAW,cAAgB,eAAE,
|
|
1
|
+
{"version":3,"file":"delete-clients.js","names":[],"sources":["../../../../zero-protocol/src/delete-clients.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\n\nexport const deleteClientsBodySchema = v.union(\n v.readonlyObject({\n clientIDs: v.readonlyArray(v.string()).optional(),\n clientGroupIDs: v.readonlyArray(v.string()).optional(),\n }),\n);\n\nexport const deleteClientsMessageSchema = v.tuple([\n v.literal('deleteClients'),\n deleteClientsBodySchema,\n]);\n\nexport type DeleteClientsBody = v.Infer<typeof deleteClientsBodySchema>;\nexport type DeleteClientsMessage = v.Infer<typeof deleteClientsMessageSchema>;\n"],"mappings":";;AAEA,IAAa,0BAA0B,eAAE,MACvC,eAAiB;CACf,WAAW,cAAgB,eAAE,QAAQ,CAAC,CAAC,UAAU;CACjD,gBAAgB,cAAgB,eAAE,QAAQ,CAAC,CAAC,UAAU;CACvD,CAAC,CACH;AAED,IAAa,6BAA6B,eAAE,MAAM,CAChD,eAAE,QAAQ,gBAAgB,EAC1B,wBACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"down.js","names":[],"sources":["../../../../zero-protocol/src/down.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {connectedMessageSchema} from './connect.ts';\nimport {transformErrorMessageSchema} from './custom-queries.ts';\nimport {deleteClientsMessageSchema} from './delete-clients.ts';\nimport {errorMessageSchema} from './error.ts';\nimport {inspectDownMessageSchema} from './inspect-down.ts';\nimport {\n pokeEndMessageSchema,\n pokePartMessageSchema,\n pokeStartMessageSchema,\n} from './poke.ts';\nimport {pongMessageSchema} from './pong.ts';\nimport {pullResponseMessageSchema} from './pull.ts';\nimport {pushResponseMessageSchema} from './push.ts';\n\nexport const downstreamSchema = v.union(\n connectedMessageSchema,\n errorMessageSchema,\n pongMessageSchema,\n pokeStartMessageSchema,\n pokePartMessageSchema,\n pokeEndMessageSchema,\n pullResponseMessageSchema,\n deleteClientsMessageSchema,\n pushResponseMessageSchema,\n inspectDownMessageSchema,\n transformErrorMessageSchema,\n);\n\nexport type Downstream = v.Infer<typeof downstreamSchema>;\n"],"mappings":";;;;;;;;;;;AAeA,IAAa,mBAAmB,eAAE,MAChC,wBACA,oBACA,mBACA,wBACA,uBACA,sBACA,2BACA,4BACA,2BACA,0BACA,
|
|
1
|
+
{"version":3,"file":"down.js","names":[],"sources":["../../../../zero-protocol/src/down.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {connectedMessageSchema} from './connect.ts';\nimport {transformErrorMessageSchema} from './custom-queries.ts';\nimport {deleteClientsMessageSchema} from './delete-clients.ts';\nimport {errorMessageSchema} from './error.ts';\nimport {inspectDownMessageSchema} from './inspect-down.ts';\nimport {\n pokeEndMessageSchema,\n pokePartMessageSchema,\n pokeStartMessageSchema,\n} from './poke.ts';\nimport {pongMessageSchema} from './pong.ts';\nimport {pullResponseMessageSchema} from './pull.ts';\nimport {pushResponseMessageSchema} from './push.ts';\n\nexport const downstreamSchema = v.union(\n connectedMessageSchema,\n errorMessageSchema,\n pongMessageSchema,\n pokeStartMessageSchema,\n pokePartMessageSchema,\n pokeEndMessageSchema,\n pullResponseMessageSchema,\n deleteClientsMessageSchema,\n pushResponseMessageSchema,\n inspectDownMessageSchema,\n transformErrorMessageSchema,\n);\n\nexport type Downstream = v.Infer<typeof downstreamSchema>;\n"],"mappings":";;;;;;;;;;;AAeA,IAAa,mBAAmB,eAAE,MAChC,wBACA,oBACA,mBACA,wBACA,uBACA,sBACA,2BACA,4BACA,2BACA,0BACA,4BACD"}
|
|
@@ -26,10 +26,6 @@ var errorKindSchema = valita_exports.union(basicErrorKindSchema, backoffErrorKin
|
|
|
26
26
|
var pushFailedBaseSchema = valita_exports.object({
|
|
27
27
|
kind: pushFailedErrorKindSchema,
|
|
28
28
|
details: jsonSchema.optional(),
|
|
29
|
-
/**
|
|
30
|
-
* The mutationIDs of the mutations that failed to process.
|
|
31
|
-
* This can be a subset of the mutationIDs in the request.
|
|
32
|
-
*/
|
|
33
29
|
mutationIDs: valita_exports.array(mutationIDSchema),
|
|
34
30
|
message: valita_exports.string()
|
|
35
31
|
});
|
|
@@ -48,9 +44,6 @@ var pushFailedBodySchema = valita_exports.union(pushFailedBaseSchema.extend({
|
|
|
48
44
|
var transformFailedBaseSchema = valita_exports.object({
|
|
49
45
|
kind: transformFailedErrorKindSchema,
|
|
50
46
|
details: jsonSchema.optional(),
|
|
51
|
-
/**
|
|
52
|
-
* The queryIDs of the queries that failed to transform.
|
|
53
|
-
*/
|
|
54
47
|
queryIDs: valita_exports.array(valita_exports.string()),
|
|
55
48
|
message: valita_exports.string()
|
|
56
49
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","names":[],"sources":["../../../../zero-protocol/src/error.ts"],"sourcesContent":["import {jsonSchema} from '../../shared/src/json-schema.ts';\nimport * as v from '../../shared/src/valita.ts';\nimport {ErrorKind} from './error-kind.ts';\nimport {ErrorOrigin} from './error-origin.ts';\nimport {ErrorReason} from './error-reason.ts';\nimport {mutationIDSchema} from './mutation-id.ts';\n\nconst basicErrorKindSchema = v.literalUnion(\n ErrorKind.AuthInvalidated,\n ErrorKind.ClientNotFound,\n ErrorKind.InvalidConnectionRequest,\n ErrorKind.InvalidConnectionRequestBaseCookie,\n ErrorKind.InvalidConnectionRequestLastMutationID,\n ErrorKind.InvalidConnectionRequestClientDeleted,\n ErrorKind.InvalidMessage,\n ErrorKind.InvalidPush,\n ErrorKind.MutationRateLimited,\n ErrorKind.MutationFailed,\n ErrorKind.Unauthorized,\n ErrorKind.VersionNotSupported,\n ErrorKind.SchemaVersionNotSupported,\n ErrorKind.Internal,\n);\n\nconst basicErrorBodySchema = v.object({\n kind: basicErrorKindSchema,\n message: v.string(),\n // this is optional for backwards compatibility\n origin: v.literalUnion(ErrorOrigin.Server, ErrorOrigin.ZeroCache).optional(),\n});\n\nconst backoffErrorKindSchema = v.literalUnion(\n ErrorKind.Rebalance,\n ErrorKind.Rehome,\n ErrorKind.ServerOverloaded,\n);\n\nconst backoffBodySchema = v.object({\n kind: backoffErrorKindSchema,\n message: v.string(),\n minBackoffMs: v.number().optional(),\n maxBackoffMs: v.number().optional(),\n // Query parameters to send in the next reconnect. In the event of\n // a conflict, these will be overridden by the parameters used by\n // the client; it is the responsibility of the server to avoid\n // parameter name conflicts.\n //\n // The parameters will only be added to the immediately following\n // reconnect, and not after that.\n reconnectParams: v.record(v.string()).optional(),\n origin: v.literal(ErrorOrigin.ZeroCache).optional(),\n});\n\nconst pushFailedErrorKindSchema = v.literal(ErrorKind.PushFailed);\nconst transformFailedErrorKindSchema = v.literal(ErrorKind.TransformFailed);\n\nexport const errorKindSchema: v.Type<ErrorKind> = v.union(\n basicErrorKindSchema,\n backoffErrorKindSchema,\n pushFailedErrorKindSchema,\n transformFailedErrorKindSchema,\n);\n\nconst pushFailedBaseSchema = v.object({\n kind: pushFailedErrorKindSchema,\n details: jsonSchema.optional(),\n /**\n * The mutationIDs of the mutations that failed to process.\n * This can be a subset of the mutationIDs in the request.\n */\n mutationIDs: v.array(mutationIDSchema),\n message: v.string(),\n});\n\nexport const pushFailedBodySchema = v.union(\n pushFailedBaseSchema.extend({\n origin: v.literal(ErrorOrigin.Server),\n reason: v.literalUnion(\n ErrorReason.Database,\n ErrorReason.Parse,\n ErrorReason.OutOfOrderMutation,\n ErrorReason.UnsupportedPushVersion,\n ErrorReason.Internal,\n ),\n }),\n pushFailedBaseSchema.extend({\n origin: v.literal(ErrorOrigin.ZeroCache),\n reason: v.literal(ErrorReason.HTTP),\n status: v.number(),\n bodyPreview: v.string().optional(),\n }),\n pushFailedBaseSchema.extend({\n origin: v.literal(ErrorOrigin.ZeroCache),\n reason: v.literalUnion(\n ErrorReason.Timeout,\n ErrorReason.Parse,\n ErrorReason.Internal,\n ),\n }),\n);\n\nconst transformFailedBaseSchema = v.object({\n kind: transformFailedErrorKindSchema,\n details: jsonSchema.optional(),\n /**\n * The queryIDs of the queries that failed to transform.\n */\n queryIDs: v.array(v.string()),\n message: v.string(),\n});\n\nexport const transformFailedBodySchema = v.union(\n transformFailedBaseSchema.extend({\n origin: v.literal(ErrorOrigin.Server),\n reason: v.literalUnion(\n ErrorReason.Database,\n ErrorReason.Parse,\n ErrorReason.Internal,\n ),\n }),\n transformFailedBaseSchema.extend({\n origin: v.literal(ErrorOrigin.ZeroCache),\n reason: v.literal(ErrorReason.HTTP),\n status: v.number(),\n bodyPreview: v.string().optional(),\n }),\n transformFailedBaseSchema.extend({\n origin: v.literal(ErrorOrigin.ZeroCache),\n reason: v.literalUnion(\n ErrorReason.Timeout,\n ErrorReason.Parse,\n ErrorReason.Internal,\n ),\n }),\n);\n\nexport const errorBodySchema = v.union(\n basicErrorBodySchema,\n backoffBodySchema,\n pushFailedBodySchema,\n transformFailedBodySchema,\n);\n\nexport type BackoffBody = v.Infer<typeof backoffBodySchema>;\nexport type PushFailedBody = v.Infer<typeof pushFailedBodySchema>;\nexport type TransformFailedBody = v.Infer<typeof transformFailedBodySchema>;\nexport type ErrorBody = v.Infer<typeof errorBodySchema>;\n\nexport const errorMessageSchema: v.Type<ErrorMessage> = v.tuple([\n v.literal('error'),\n errorBodySchema,\n]);\n\nexport type ErrorMessage = ['error', ErrorBody];\n\n/**\n * Represents an error used across zero-client, zero-cache, and zero-server.\n */\nexport class ProtocolError<\n const T extends ErrorBody = ErrorBody,\n> extends Error {\n readonly errorBody: T;\n\n constructor(errorBody: T, options?: ErrorOptions) {\n super(errorBody.message, options);\n this.name = 'ProtocolError';\n this.errorBody = errorBody;\n }\n\n get kind(): T['kind'] {\n return this.errorBody.kind;\n }\n}\n\nexport function isProtocolError(error: unknown): error is ProtocolError {\n return error instanceof ProtocolError;\n}\n"],"mappings":";;;;;;;AAOA,IAAM,uBAAuB,aAC3B,iBACA,gBACA,0BACA,oCACA,wCACA,uCACA,gBACA,aACA,qBACA,gBACA,cACA,qBACA,2BACA,
|
|
1
|
+
{"version":3,"file":"error.js","names":[],"sources":["../../../../zero-protocol/src/error.ts"],"sourcesContent":["import {jsonSchema} from '../../shared/src/json-schema.ts';\nimport * as v from '../../shared/src/valita.ts';\nimport {ErrorKind} from './error-kind.ts';\nimport {ErrorOrigin} from './error-origin.ts';\nimport {ErrorReason} from './error-reason.ts';\nimport {mutationIDSchema} from './mutation-id.ts';\n\nconst basicErrorKindSchema = v.literalUnion(\n ErrorKind.AuthInvalidated,\n ErrorKind.ClientNotFound,\n ErrorKind.InvalidConnectionRequest,\n ErrorKind.InvalidConnectionRequestBaseCookie,\n ErrorKind.InvalidConnectionRequestLastMutationID,\n ErrorKind.InvalidConnectionRequestClientDeleted,\n ErrorKind.InvalidMessage,\n ErrorKind.InvalidPush,\n ErrorKind.MutationRateLimited,\n ErrorKind.MutationFailed,\n ErrorKind.Unauthorized,\n ErrorKind.VersionNotSupported,\n ErrorKind.SchemaVersionNotSupported,\n ErrorKind.Internal,\n);\n\nconst basicErrorBodySchema = v.object({\n kind: basicErrorKindSchema,\n message: v.string(),\n // this is optional for backwards compatibility\n origin: v.literalUnion(ErrorOrigin.Server, ErrorOrigin.ZeroCache).optional(),\n});\n\nconst backoffErrorKindSchema = v.literalUnion(\n ErrorKind.Rebalance,\n ErrorKind.Rehome,\n ErrorKind.ServerOverloaded,\n);\n\nconst backoffBodySchema = v.object({\n kind: backoffErrorKindSchema,\n message: v.string(),\n minBackoffMs: v.number().optional(),\n maxBackoffMs: v.number().optional(),\n // Query parameters to send in the next reconnect. In the event of\n // a conflict, these will be overridden by the parameters used by\n // the client; it is the responsibility of the server to avoid\n // parameter name conflicts.\n //\n // The parameters will only be added to the immediately following\n // reconnect, and not after that.\n reconnectParams: v.record(v.string()).optional(),\n origin: v.literal(ErrorOrigin.ZeroCache).optional(),\n});\n\nconst pushFailedErrorKindSchema = v.literal(ErrorKind.PushFailed);\nconst transformFailedErrorKindSchema = v.literal(ErrorKind.TransformFailed);\n\nexport const errorKindSchema: v.Type<ErrorKind> = v.union(\n basicErrorKindSchema,\n backoffErrorKindSchema,\n pushFailedErrorKindSchema,\n transformFailedErrorKindSchema,\n);\n\nconst pushFailedBaseSchema = v.object({\n kind: pushFailedErrorKindSchema,\n details: jsonSchema.optional(),\n /**\n * The mutationIDs of the mutations that failed to process.\n * This can be a subset of the mutationIDs in the request.\n */\n mutationIDs: v.array(mutationIDSchema),\n message: v.string(),\n});\n\nexport const pushFailedBodySchema = v.union(\n pushFailedBaseSchema.extend({\n origin: v.literal(ErrorOrigin.Server),\n reason: v.literalUnion(\n ErrorReason.Database,\n ErrorReason.Parse,\n ErrorReason.OutOfOrderMutation,\n ErrorReason.UnsupportedPushVersion,\n ErrorReason.Internal,\n ),\n }),\n pushFailedBaseSchema.extend({\n origin: v.literal(ErrorOrigin.ZeroCache),\n reason: v.literal(ErrorReason.HTTP),\n status: v.number(),\n bodyPreview: v.string().optional(),\n }),\n pushFailedBaseSchema.extend({\n origin: v.literal(ErrorOrigin.ZeroCache),\n reason: v.literalUnion(\n ErrorReason.Timeout,\n ErrorReason.Parse,\n ErrorReason.Internal,\n ),\n }),\n);\n\nconst transformFailedBaseSchema = v.object({\n kind: transformFailedErrorKindSchema,\n details: jsonSchema.optional(),\n /**\n * The queryIDs of the queries that failed to transform.\n */\n queryIDs: v.array(v.string()),\n message: v.string(),\n});\n\nexport const transformFailedBodySchema = v.union(\n transformFailedBaseSchema.extend({\n origin: v.literal(ErrorOrigin.Server),\n reason: v.literalUnion(\n ErrorReason.Database,\n ErrorReason.Parse,\n ErrorReason.Internal,\n ),\n }),\n transformFailedBaseSchema.extend({\n origin: v.literal(ErrorOrigin.ZeroCache),\n reason: v.literal(ErrorReason.HTTP),\n status: v.number(),\n bodyPreview: v.string().optional(),\n }),\n transformFailedBaseSchema.extend({\n origin: v.literal(ErrorOrigin.ZeroCache),\n reason: v.literalUnion(\n ErrorReason.Timeout,\n ErrorReason.Parse,\n ErrorReason.Internal,\n ),\n }),\n);\n\nexport const errorBodySchema = v.union(\n basicErrorBodySchema,\n backoffBodySchema,\n pushFailedBodySchema,\n transformFailedBodySchema,\n);\n\nexport type BackoffBody = v.Infer<typeof backoffBodySchema>;\nexport type PushFailedBody = v.Infer<typeof pushFailedBodySchema>;\nexport type TransformFailedBody = v.Infer<typeof transformFailedBodySchema>;\nexport type ErrorBody = v.Infer<typeof errorBodySchema>;\n\nexport const errorMessageSchema: v.Type<ErrorMessage> = v.tuple([\n v.literal('error'),\n errorBodySchema,\n]);\n\nexport type ErrorMessage = ['error', ErrorBody];\n\n/**\n * Represents an error used across zero-client, zero-cache, and zero-server.\n */\nexport class ProtocolError<\n const T extends ErrorBody = ErrorBody,\n> extends Error {\n readonly errorBody: T;\n\n constructor(errorBody: T, options?: ErrorOptions) {\n super(errorBody.message, options);\n this.name = 'ProtocolError';\n this.errorBody = errorBody;\n }\n\n get kind(): T['kind'] {\n return this.errorBody.kind;\n }\n}\n\nexport function isProtocolError(error: unknown): error is ProtocolError {\n return error instanceof ProtocolError;\n}\n"],"mappings":";;;;;;;AAOA,IAAM,uBAAuB,aAC3B,iBACA,gBACA,0BACA,oCACA,wCACA,uCACA,gBACA,aACA,qBACA,gBACA,cACA,qBACA,2BACA,SACD;AAED,IAAM,uBAAuB,eAAE,OAAO;CACpC,MAAM;CACN,SAAS,eAAE,QAAQ;CAEnB,QAAQ,aAAe,QAAoB,UAAsB,CAAC,UAAU;CAC7E,CAAC;AAEF,IAAM,yBAAyB,aAC7B,WACA,QACA,iBACD;AAED,IAAM,oBAAoB,eAAE,OAAO;CACjC,MAAM;CACN,SAAS,eAAE,QAAQ;CACnB,cAAc,eAAE,QAAQ,CAAC,UAAU;CACnC,cAAc,eAAE,QAAQ,CAAC,UAAU;CAQnC,iBAAiB,eAAE,OAAO,eAAE,QAAQ,CAAC,CAAC,UAAU;CAChD,QAAQ,eAAE,QAAQ,UAAsB,CAAC,UAAU;CACpD,CAAC;AAEF,IAAM,4BAA4B,eAAE,QAAQ,WAAqB;AACjE,IAAM,iCAAiC,eAAE,QAAQ,gBAA0B;AAE3E,IAAa,kBAAqC,eAAE,MAClD,sBACA,wBACA,2BACA,+BACD;AAED,IAAM,uBAAuB,eAAE,OAAO;CACpC,MAAM;CACN,SAAS,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QAAM,UAAU,SAAS,QAAQ;AACjC,OAAK,OAAO;AACZ,OAAK,YAAY;;CAGnB,IAAI,OAAkB;AACpB,SAAO,KAAK,UAAU;;;AAI1B,SAAgB,gBAAgB,OAAwC;AACtE,QAAO,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect-down.js","names":[],"sources":["../../../../zero-protocol/src/inspect-down.ts"],"sourcesContent":["import {jsonSchema} from '../../shared/src/json-schema.ts';\nimport {tdigestSchema} from '../../shared/src/tdigest-schema.ts';\nimport * as v from '../../shared/src/valita.ts';\nimport {analyzeQueryResultSchema} from './analyze-query-result.ts';\nimport {astSchema} from './ast.ts';\n\nconst serverMetricsSchema = v.object({\n 'query-materialization-server': tdigestSchema,\n 'query-update-server': tdigestSchema,\n});\n\nexport type ServerMetrics = v.Infer<typeof serverMetricsSchema>;\n\n/**\n * Per-query server metrics sent with each query row in the inspector protocol.\n * `query-hydration-server-ms` is a plain number (milliseconds) since each\n * query is typically hydrated only once. `query-update-server` is a TDigest\n * histogram since queries receive many incremental updates.\n */\nconst queryServerMetricsSchema = v.object({\n 'query-hydration-server-ms': v.number().optional(),\n 'query-update-server': tdigestSchema,\n});\n\nexport type QueryServerMetrics = v.Infer<typeof queryServerMetricsSchema>;\n\nconst inspectQueryRowSchema = v.object({\n clientID: v.string(),\n queryID: v.string(),\n // This is the server return AST for custom queries\n // TODO: Return server generated AST\n ast: astSchema.nullable(),\n // not null for custom queries\n name: v.string().nullable(),\n // not null for custom queries\n args: v.readonlyArray(jsonSchema).nullable(),\n got: v.boolean(),\n deleted: v.boolean(),\n ttl: v.number(),\n inactivatedAt: v.number().nullable(),\n rowCount: v.number(),\n metrics: queryServerMetricsSchema.nullable().optional(),\n});\n\nexport type InspectQueryRow = v.Infer<typeof inspectQueryRowSchema>;\n\nconst inspectBaseDownSchema = v.object({\n id: v.string(),\n});\n\nexport const inspectQueriesDownSchema = inspectBaseDownSchema.extend({\n op: v.literal('queries'),\n value: v.array(inspectQueryRowSchema),\n});\n\nexport type InspectQueriesDown = v.Infer<typeof inspectQueriesDownSchema>;\n\nexport const inspectMetricsDownSchema = inspectBaseDownSchema.extend({\n op: v.literal('metrics'),\n value: serverMetricsSchema,\n});\n\nexport type InspectMetricsDown = v.Infer<typeof inspectMetricsDownSchema>;\n\nexport const inspectVersionDownSchema = inspectBaseDownSchema.extend({\n op: v.literal('version'),\n value: v.string(),\n});\n\nexport const inspectAuthenticatedDownSchema = inspectBaseDownSchema.extend({\n op: v.literal('authenticated'),\n value: v.boolean(),\n});\n\nexport type InspectAuthenticatedDown = v.Infer<\n typeof inspectAuthenticatedDownSchema\n>;\n\nexport const inspectAnalyzeQueryDownSchema = inspectBaseDownSchema.extend({\n op: v.literal('analyze-query'),\n value: analyzeQueryResultSchema,\n});\n\nexport type InspectAnalyzeQueryDown = v.Infer<\n typeof inspectAnalyzeQueryDownSchema\n>;\n\nexport const inspectErrorDownSchema = inspectBaseDownSchema.extend({\n op: v.literal('error'),\n value: v.string(),\n});\n\nexport type InspectErrorDown = v.Infer<typeof inspectErrorDownSchema>;\n\nexport const inspectDownBodySchema = v.union(\n inspectQueriesDownSchema,\n inspectMetricsDownSchema,\n inspectVersionDownSchema,\n inspectAuthenticatedDownSchema,\n inspectAnalyzeQueryDownSchema,\n inspectErrorDownSchema,\n);\n\nexport const inspectDownMessageSchema = v.tuple([\n v.literal('inspect'),\n inspectDownBodySchema,\n]);\n\nexport type InspectDownMessage = v.Infer<typeof inspectDownMessageSchema>;\n\nexport type InspectDownBody = v.Infer<typeof inspectDownBodySchema>;\n"],"mappings":";;;;;;AAMA,IAAM,sBAAsB,eAAE,OAAO;CACnC,gCAAgC;CAChC,uBAAuB;
|
|
1
|
+
{"version":3,"file":"inspect-down.js","names":[],"sources":["../../../../zero-protocol/src/inspect-down.ts"],"sourcesContent":["import {jsonSchema} from '../../shared/src/json-schema.ts';\nimport {tdigestSchema} from '../../shared/src/tdigest-schema.ts';\nimport * as v from '../../shared/src/valita.ts';\nimport {analyzeQueryResultSchema} from './analyze-query-result.ts';\nimport {astSchema} from './ast.ts';\n\nconst serverMetricsSchema = v.object({\n 'query-materialization-server': tdigestSchema,\n 'query-update-server': tdigestSchema,\n});\n\nexport type ServerMetrics = v.Infer<typeof serverMetricsSchema>;\n\n/**\n * Per-query server metrics sent with each query row in the inspector protocol.\n * `query-hydration-server-ms` is a plain number (milliseconds) since each\n * query is typically hydrated only once. `query-update-server` is a TDigest\n * histogram since queries receive many incremental updates.\n */\nconst queryServerMetricsSchema = v.object({\n 'query-hydration-server-ms': v.number().optional(),\n 'query-update-server': tdigestSchema,\n});\n\nexport type QueryServerMetrics = v.Infer<typeof queryServerMetricsSchema>;\n\nconst inspectQueryRowSchema = v.object({\n clientID: v.string(),\n queryID: v.string(),\n // This is the server return AST for custom queries\n // TODO: Return server generated AST\n ast: astSchema.nullable(),\n // not null for custom queries\n name: v.string().nullable(),\n // not null for custom queries\n args: v.readonlyArray(jsonSchema).nullable(),\n got: v.boolean(),\n deleted: v.boolean(),\n ttl: v.number(),\n inactivatedAt: v.number().nullable(),\n rowCount: v.number(),\n metrics: queryServerMetricsSchema.nullable().optional(),\n});\n\nexport type InspectQueryRow = v.Infer<typeof inspectQueryRowSchema>;\n\nconst inspectBaseDownSchema = v.object({\n id: v.string(),\n});\n\nexport const inspectQueriesDownSchema = inspectBaseDownSchema.extend({\n op: v.literal('queries'),\n value: v.array(inspectQueryRowSchema),\n});\n\nexport type InspectQueriesDown = v.Infer<typeof inspectQueriesDownSchema>;\n\nexport const inspectMetricsDownSchema = inspectBaseDownSchema.extend({\n op: v.literal('metrics'),\n value: serverMetricsSchema,\n});\n\nexport type InspectMetricsDown = v.Infer<typeof inspectMetricsDownSchema>;\n\nexport const inspectVersionDownSchema = inspectBaseDownSchema.extend({\n op: v.literal('version'),\n value: v.string(),\n});\n\nexport const inspectAuthenticatedDownSchema = inspectBaseDownSchema.extend({\n op: v.literal('authenticated'),\n value: v.boolean(),\n});\n\nexport type InspectAuthenticatedDown = v.Infer<\n typeof inspectAuthenticatedDownSchema\n>;\n\nexport const inspectAnalyzeQueryDownSchema = inspectBaseDownSchema.extend({\n op: v.literal('analyze-query'),\n value: analyzeQueryResultSchema,\n});\n\nexport type InspectAnalyzeQueryDown = v.Infer<\n typeof inspectAnalyzeQueryDownSchema\n>;\n\nexport const inspectErrorDownSchema = inspectBaseDownSchema.extend({\n op: v.literal('error'),\n value: v.string(),\n});\n\nexport type InspectErrorDown = v.Infer<typeof inspectErrorDownSchema>;\n\nexport const inspectDownBodySchema = v.union(\n inspectQueriesDownSchema,\n inspectMetricsDownSchema,\n inspectVersionDownSchema,\n inspectAuthenticatedDownSchema,\n inspectAnalyzeQueryDownSchema,\n inspectErrorDownSchema,\n);\n\nexport const inspectDownMessageSchema = v.tuple([\n v.literal('inspect'),\n inspectDownBodySchema,\n]);\n\nexport type InspectDownMessage = v.Infer<typeof inspectDownMessageSchema>;\n\nexport type InspectDownBody = v.Infer<typeof inspectDownBodySchema>;\n"],"mappings":";;;;;;AAMA,IAAM,sBAAsB,eAAE,OAAO;CACnC,gCAAgC;CAChC,uBAAuB;CACxB,CAAC;;;;;;;AAUF,IAAM,2BAA2B,eAAE,OAAO;CACxC,6BAA6B,eAAE,QAAQ,CAAC,UAAU;CAClD,uBAAuB;CACxB,CAAC;AAIF,IAAM,wBAAwB,eAAE,OAAO;CACrC,UAAU,eAAE,QAAQ;CACpB,SAAS,eAAE,QAAQ;CAGnB,KAAK,UAAU,UAAU;CAEzB,MAAM,eAAE,QAAQ,CAAC,UAAU;CAE3B,MAAM,cAAgB,WAAW,CAAC,UAAU;CAC5C,KAAK,eAAE,SAAS;CAChB,SAAS,eAAE,SAAS;CACpB,KAAK,eAAE,QAAQ;CACf,eAAe,eAAE,QAAQ,CAAC,UAAU;CACpC,UAAU,eAAE,QAAQ;CACpB,SAAS,yBAAyB,UAAU,CAAC,UAAU;CACxD,CAAC;AAIF,IAAM,wBAAwB,eAAE,OAAO,EACrC,IAAI,eAAE,QAAQ,EACf,CAAC;AAEF,IAAa,2BAA2B,sBAAsB,OAAO;CACnE,IAAI,eAAE,QAAQ,UAAU;CACxB,OAAO,eAAE,MAAM,sBAAsB;CACtC,CAAC;AAIF,IAAa,2BAA2B,sBAAsB,OAAO;CACnE,IAAI,eAAE,QAAQ,UAAU;CACxB,OAAO;CACR,CAAC;AAIF,IAAa,2BAA2B,sBAAsB,OAAO;CACnE,IAAI,eAAE,QAAQ,UAAU;CACxB,OAAO,eAAE,QAAQ;CAClB,CAAC;AAEF,IAAa,iCAAiC,sBAAsB,OAAO;CACzE,IAAI,eAAE,QAAQ,gBAAgB;CAC9B,OAAO,eAAE,SAAS;CACnB,CAAC;AAMF,IAAa,gCAAgC,sBAAsB,OAAO;CACxE,IAAI,eAAE,QAAQ,gBAAgB;CAC9B,OAAO;CACR,CAAC;AAMF,IAAa,yBAAyB,sBAAsB,OAAO;CACjE,IAAI,eAAE,QAAQ,QAAQ;CACtB,OAAO,eAAE,QAAQ;CAClB,CAAC;AAIF,IAAa,wBAAwB,eAAE,MACrC,0BACA,0BACA,0BACA,gCACA,+BACA,uBACD;AAED,IAAa,2BAA2B,eAAE,MAAM,CAC9C,eAAE,QAAQ,UAAU,EACpB,sBACD,CAAC"}
|
|
@@ -20,7 +20,6 @@ var analyzeQueryOptionsSchema = valita_exports.object({
|
|
|
20
20
|
});
|
|
21
21
|
var inspectAnalyzeQueryUpSchema = inspectUpBase.extend({
|
|
22
22
|
op: valita_exports.literal("analyze-query"),
|
|
23
|
-
/** @deprecated Use {@linkcode ast} instead */
|
|
24
23
|
value: astSchema.optional(),
|
|
25
24
|
options: analyzeQueryOptionsSchema.optional(),
|
|
26
25
|
ast: astSchema.optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect-up.js","names":[],"sources":["../../../../zero-protocol/src/inspect-up.ts"],"sourcesContent":["import {jsonSchema} from '../../shared/src/json-schema.ts';\nimport * as v from '../../shared/src/valita.ts';\nimport {astSchema} from './ast.ts';\n\nconst inspectUpBase = v.object({\n id: v.string(),\n});\n\nconst inspectQueriesUpBodySchema = inspectUpBase.extend({\n op: v.literal('queries'),\n clientID: v.string().optional(),\n});\n\nexport type InspectQueriesUpBody = v.Infer<typeof inspectQueriesUpBodySchema>;\n\nconst inspectMetricsUpSchema = inspectUpBase.extend({\n op: v.literal('metrics'),\n});\n\nexport type InspectMetricsUpBody = v.Infer<typeof inspectMetricsUpSchema>;\n\nconst inspectVersionUpSchema = inspectUpBase.extend({\n op: v.literal('version'),\n});\n\nexport type InspectVersionUpBody = v.Infer<typeof inspectVersionUpSchema>;\n\nexport const inspectAuthenticateUpSchema = inspectUpBase.extend({\n op: v.literal('authenticate'),\n value: v.string(),\n});\n\nexport type InspectAuthenticateUpBody = v.Infer<\n typeof inspectAuthenticateUpSchema\n>;\n\nconst analyzeQueryOptionsSchema = v.object({\n vendedRows: v.boolean().optional(),\n syncedRows: v.boolean().optional(),\n joinPlans: v.boolean().optional(),\n});\n\nexport type AnalyzeQueryOptions = v.Infer<typeof analyzeQueryOptionsSchema>;\n\nexport const inspectAnalyzeQueryUpSchema = inspectUpBase.extend({\n op: v.literal('analyze-query'),\n /** @deprecated Use {@linkcode ast} instead */\n value: astSchema.optional(),\n options: analyzeQueryOptionsSchema.optional(),\n ast: astSchema.optional(),\n name: v.string().optional(),\n args: v.readonlyArray(jsonSchema).optional(),\n});\n\nexport type InspectAnalyzeQueryUpBody = v.Infer<\n typeof inspectAnalyzeQueryUpSchema\n>;\n\nconst inspectUpBodySchema = v.union(\n inspectQueriesUpBodySchema,\n inspectMetricsUpSchema,\n inspectVersionUpSchema,\n inspectAuthenticateUpSchema,\n inspectAnalyzeQueryUpSchema,\n);\n\nexport const inspectUpMessageSchema = v.tuple([\n v.literal('inspect'),\n inspectUpBodySchema,\n]);\n\nexport type InspectUpMessage = v.Infer<typeof inspectUpMessageSchema>;\n\nexport type InspectUpBody = v.Infer<typeof inspectUpBodySchema>;\n"],"mappings":";;;;AAIA,IAAM,gBAAgB,eAAE,OAAO,EAC7B,IAAI,eAAE,
|
|
1
|
+
{"version":3,"file":"inspect-up.js","names":[],"sources":["../../../../zero-protocol/src/inspect-up.ts"],"sourcesContent":["import {jsonSchema} from '../../shared/src/json-schema.ts';\nimport * as v from '../../shared/src/valita.ts';\nimport {astSchema} from './ast.ts';\n\nconst inspectUpBase = v.object({\n id: v.string(),\n});\n\nconst inspectQueriesUpBodySchema = inspectUpBase.extend({\n op: v.literal('queries'),\n clientID: v.string().optional(),\n});\n\nexport type InspectQueriesUpBody = v.Infer<typeof inspectQueriesUpBodySchema>;\n\nconst inspectMetricsUpSchema = inspectUpBase.extend({\n op: v.literal('metrics'),\n});\n\nexport type InspectMetricsUpBody = v.Infer<typeof inspectMetricsUpSchema>;\n\nconst inspectVersionUpSchema = inspectUpBase.extend({\n op: v.literal('version'),\n});\n\nexport type InspectVersionUpBody = v.Infer<typeof inspectVersionUpSchema>;\n\nexport const inspectAuthenticateUpSchema = inspectUpBase.extend({\n op: v.literal('authenticate'),\n value: v.string(),\n});\n\nexport type InspectAuthenticateUpBody = v.Infer<\n typeof inspectAuthenticateUpSchema\n>;\n\nconst analyzeQueryOptionsSchema = v.object({\n vendedRows: v.boolean().optional(),\n syncedRows: v.boolean().optional(),\n joinPlans: v.boolean().optional(),\n});\n\nexport type AnalyzeQueryOptions = v.Infer<typeof analyzeQueryOptionsSchema>;\n\nexport const inspectAnalyzeQueryUpSchema = inspectUpBase.extend({\n op: v.literal('analyze-query'),\n /** @deprecated Use {@linkcode ast} instead */\n value: astSchema.optional(),\n options: analyzeQueryOptionsSchema.optional(),\n ast: astSchema.optional(),\n name: v.string().optional(),\n args: v.readonlyArray(jsonSchema).optional(),\n});\n\nexport type InspectAnalyzeQueryUpBody = v.Infer<\n typeof inspectAnalyzeQueryUpSchema\n>;\n\nconst inspectUpBodySchema = v.union(\n inspectQueriesUpBodySchema,\n inspectMetricsUpSchema,\n inspectVersionUpSchema,\n inspectAuthenticateUpSchema,\n inspectAnalyzeQueryUpSchema,\n);\n\nexport const inspectUpMessageSchema = v.tuple([\n v.literal('inspect'),\n inspectUpBodySchema,\n]);\n\nexport type InspectUpMessage = v.Infer<typeof inspectUpMessageSchema>;\n\nexport type InspectUpBody = v.Infer<typeof inspectUpBodySchema>;\n"],"mappings":";;;;AAIA,IAAM,gBAAgB,eAAE,OAAO,EAC7B,IAAI,eAAE,QAAQ,EACf,CAAC;AAEF,IAAM,6BAA6B,cAAc,OAAO;CACtD,IAAI,eAAE,QAAQ,UAAU;CACxB,UAAU,eAAE,QAAQ,CAAC,UAAU;CAChC,CAAC;AAIF,IAAM,yBAAyB,cAAc,OAAO,EAClD,IAAI,eAAE,QAAQ,UAAU,EACzB,CAAC;AAIF,IAAM,yBAAyB,cAAc,OAAO,EAClD,IAAI,eAAE,QAAQ,UAAU,EACzB,CAAC;AAIF,IAAa,8BAA8B,cAAc,OAAO;CAC9D,IAAI,eAAE,QAAQ,eAAe;CAC7B,OAAO,eAAE,QAAQ;CAClB,CAAC;AAMF,IAAM,4BAA4B,eAAE,OAAO;CACzC,YAAY,eAAE,SAAS,CAAC,UAAU;CAClC,YAAY,eAAE,SAAS,CAAC,UAAU;CAClC,WAAW,eAAE,SAAS,CAAC,UAAU;CAClC,CAAC;AAIF,IAAa,8BAA8B,cAAc,OAAO;CAC9D,IAAI,eAAE,QAAQ,gBAAgB;CAE9B,OAAO,UAAU,UAAU;CAC3B,SAAS,0BAA0B,UAAU;CAC7C,KAAK,UAAU,UAAU;CACzB,MAAM,eAAE,QAAQ,CAAC,UAAU;CAC3B,MAAM,cAAgB,WAAW,CAAC,UAAU;CAC7C,CAAC;AAMF,IAAM,sBAAsB,eAAE,MAC5B,4BACA,wBACA,wBACA,6BACA,4BACD;AAED,IAAa,yBAAyB,eAAE,MAAM,CAC5C,eAAE,QAAQ,UAAU,EACpB,oBACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutate-server.js","names":[],"sources":["../../../../zero-protocol/src/mutate-server.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {pushFailedBodySchema} from './error.ts';\nimport {mutationResponseSchema} from './mutation.ts';\nimport {pushErrorSchema} from './push.ts';\n\nconst legacyPushSuccessSchema = v.object({\n mutations: v.array(mutationResponseSchema),\n});\n\nconst legacyPushResponseSchema = v.union(\n legacyPushSuccessSchema,\n pushErrorSchema,\n pushFailedBodySchema,\n);\n\nexport const mutateSuccessSchema = v.object({\n kind: v.literal('MutateResponse'),\n userID: v.string().nullable().optional(),\n mutations: v.array(mutationResponseSchema),\n});\nexport type MutateSuccess = v.Infer<typeof mutateSuccessSchema>;\n\nexport const mutateResponseSchema = v.union(\n mutateSuccessSchema,\n pushFailedBodySchema,\n // for backwards compatibility\n legacyPushResponseSchema,\n);\nexport type MutateResponse = v.Infer<typeof mutateResponseSchema>;\n\n/**\n * The schema for the querystring parameters of the custom mutate endpoint.\n */\nexport const mutateParamsSchema = v.object({\n schema: v.string(),\n appID: v.string(),\n});\n"],"mappings":";;;;;AAKA,IAAM,0BAA0B,eAAE,OAAO,EACvC,WAAW,eAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mutate-server.js","names":[],"sources":["../../../../zero-protocol/src/mutate-server.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {pushFailedBodySchema} from './error.ts';\nimport {mutationResponseSchema} from './mutation.ts';\nimport {pushErrorSchema} from './push.ts';\n\nconst legacyPushSuccessSchema = v.object({\n mutations: v.array(mutationResponseSchema),\n});\n\nconst legacyPushResponseSchema = v.union(\n legacyPushSuccessSchema,\n pushErrorSchema,\n pushFailedBodySchema,\n);\n\nexport const mutateSuccessSchema = v.object({\n kind: v.literal('MutateResponse'),\n userID: v.string().nullable().optional(),\n mutations: v.array(mutationResponseSchema),\n});\nexport type MutateSuccess = v.Infer<typeof mutateSuccessSchema>;\n\nexport const mutateResponseSchema = v.union(\n mutateSuccessSchema,\n pushFailedBodySchema,\n // for backwards compatibility\n legacyPushResponseSchema,\n);\nexport type MutateResponse = v.Infer<typeof mutateResponseSchema>;\n\n/**\n * The schema for the querystring parameters of the custom mutate endpoint.\n */\nexport const mutateParamsSchema = v.object({\n schema: v.string(),\n appID: v.string(),\n});\n"],"mappings":";;;;;AAKA,IAAM,0BAA0B,eAAE,OAAO,EACvC,WAAW,eAAE,MAAM,uBAAuB,EAC3C,CAAC;AAEF,IAAM,2BAA2B,eAAE,MACjC,yBACA,iBACA,qBACD;AAED,IAAa,sBAAsB,eAAE,OAAO;CAC1C,MAAM,eAAE,QAAQ,iBAAiB;CACjC,QAAQ,eAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;CACxC,WAAW,eAAE,MAAM,uBAAuB;CAC3C,CAAC;AAGF,IAAa,uBAAuB,eAAE,MACpC,qBACA,sBAEA,yBACD;;;;AAMD,IAAa,qBAAqB,eAAE,OAAO;CACzC,QAAQ,eAAE,QAAQ;CAClB,OAAO,eAAE,QAAQ;CAClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutation-id.js","names":[],"sources":["../../../../zero-protocol/src/mutation-id.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\n\nexport const mutationIDSchema = v.object({\n id: v.number(),\n clientID: v.string(),\n});\n\nexport type MutationID = v.Infer<typeof mutationIDSchema>;\n"],"mappings":";;AAEA,IAAa,mBAAmB,eAAE,OAAO;CACvC,IAAI,eAAE,
|
|
1
|
+
{"version":3,"file":"mutation-id.js","names":[],"sources":["../../../../zero-protocol/src/mutation-id.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\n\nexport const mutationIDSchema = v.object({\n id: v.number(),\n clientID: v.string(),\n});\n\nexport type MutationID = v.Infer<typeof mutationIDSchema>;\n"],"mappings":";;AAEA,IAAa,mBAAmB,eAAE,OAAO;CACvC,IAAI,eAAE,QAAQ;CACd,UAAU,eAAE,QAAQ;CACrB,CAAC"}
|