@rocicorp/zero 0.26.0-canary.2 → 0.26.0-canary.3
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 +1 -1
- package/out/replicache/src/persist/collect-idb-databases.d.ts +4 -4
- package/out/replicache/src/persist/collect-idb-databases.d.ts.map +1 -1
- package/out/replicache/src/persist/collect-idb-databases.js +22 -19
- package/out/replicache/src/persist/collect-idb-databases.js.map +1 -1
- package/out/replicache/src/persist/refresh.d.ts.map +1 -1
- package/out/replicache/src/persist/refresh.js +0 -8
- package/out/replicache/src/persist/refresh.js.map +1 -1
- package/out/replicache/src/process-scheduler.d.ts +23 -0
- package/out/replicache/src/process-scheduler.d.ts.map +1 -1
- package/out/replicache/src/process-scheduler.js +50 -1
- package/out/replicache/src/process-scheduler.js.map +1 -1
- package/out/replicache/src/replicache-impl.d.ts +8 -0
- package/out/replicache/src/replicache-impl.d.ts.map +1 -1
- package/out/replicache/src/replicache-impl.js +11 -2
- package/out/replicache/src/replicache-impl.js.map +1 -1
- package/out/shared/src/falsy.d.ts +3 -0
- package/out/shared/src/falsy.d.ts.map +1 -0
- package/out/zero/package.json.js +1 -1
- package/out/zero/src/adapters/drizzle.js +1 -2
- package/out/zero/src/adapters/prisma.d.ts +2 -0
- package/out/zero/src/adapters/prisma.d.ts.map +1 -0
- package/out/zero/src/adapters/prisma.js +6 -0
- package/out/zero/src/adapters/prisma.js.map +1 -0
- package/out/zero/src/pg.js +4 -7
- package/out/zero/src/react.js +3 -1
- package/out/zero/src/react.js.map +1 -1
- package/out/zero/src/server.js +5 -8
- package/out/zero-cache/src/auth/load-permissions.d.ts +3 -2
- package/out/zero-cache/src/auth/load-permissions.d.ts.map +1 -1
- package/out/zero-cache/src/auth/load-permissions.js +14 -8
- package/out/zero-cache/src/auth/load-permissions.js.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts +6 -0
- package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.js +16 -3
- package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +44 -8
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +53 -13
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/custom/fetch.d.ts +3 -0
- package/out/zero-cache/src/custom/fetch.d.ts.map +1 -1
- package/out/zero-cache/src/custom/fetch.js +26 -0
- package/out/zero-cache/src/custom/fetch.js.map +1 -1
- package/out/zero-cache/src/db/lite-tables.js +1 -1
- package/out/zero-cache/src/db/lite-tables.js.map +1 -1
- package/out/zero-cache/src/db/migration-lite.d.ts.map +1 -1
- package/out/zero-cache/src/db/migration-lite.js +9 -3
- package/out/zero-cache/src/db/migration-lite.js.map +1 -1
- package/out/zero-cache/src/db/migration.d.ts.map +1 -1
- package/out/zero-cache/src/db/migration.js +9 -3
- package/out/zero-cache/src/db/migration.js.map +1 -1
- package/out/zero-cache/src/db/specs.d.ts +4 -3
- package/out/zero-cache/src/db/specs.d.ts.map +1 -1
- package/out/zero-cache/src/db/specs.js +4 -1
- package/out/zero-cache/src/db/specs.js.map +1 -1
- package/out/zero-cache/src/db/transaction-pool.d.ts.map +1 -1
- package/out/zero-cache/src/db/transaction-pool.js +9 -3
- package/out/zero-cache/src/db/transaction-pool.js.map +1 -1
- package/out/zero-cache/src/server/inspector-delegate.d.ts +1 -1
- package/out/zero-cache/src/server/inspector-delegate.d.ts.map +1 -1
- package/out/zero-cache/src/server/inspector-delegate.js +11 -30
- package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
- package/out/zero-cache/src/server/main.js +1 -1
- package/out/zero-cache/src/server/main.js.map +1 -1
- package/out/zero-cache/src/server/priority-op.d.ts +8 -0
- package/out/zero-cache/src/server/priority-op.d.ts.map +1 -0
- package/out/zero-cache/src/server/priority-op.js +29 -0
- package/out/zero-cache/src/server/priority-op.js.map +1 -0
- package/out/zero-cache/src/server/syncer.d.ts +0 -1
- package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/server/syncer.js +3 -21
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/services/analyze.js +1 -1
- package/out/zero-cache/src/services/analyze.js.map +1 -1
- package/out/zero-cache/src/services/change-source/custom/change-source.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/custom/change-source.js +4 -3
- package/out/zero-cache/src/services/change-source/custom/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.js +68 -13
- package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js +7 -2
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.js +7 -4
- 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/schema/ddl.d.ts +125 -180
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.js +18 -10
- package/out/zero-cache/src/services/change-source/pg/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts +36 -90
- package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/published.js +51 -14
- package/out/zero-cache/src/services/change-source/pg/schema/published.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +31 -36
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js +24 -3
- 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.d.ts +2 -2
- package/out/zero-cache/src/services/change-source/pg/schema/validation.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/validation.js +2 -4
- 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/data.d.ts +158 -53
- package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/data.js +55 -10
- package/out/zero-cache/src/services/change-source/protocol/current/data.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +210 -72
- package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current.js +4 -2
- package/out/zero-cache/src/services/change-source/replica-schema.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/replica-schema.js +19 -10
- package/out/zero-cache/src/services/change-source/replica-schema.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.js +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.d.ts +71 -25
- package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer.js +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/tables.d.ts +1 -0
- package/out/zero-cache/src/services/change-streamer/schema/tables.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/tables.js +6 -5
- package/out/zero-cache/src/services/change-streamer/schema/tables.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.js +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/subscriber.d.ts +2 -0
- package/out/zero-cache/src/services/change-streamer/subscriber.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/subscriber.js +14 -1
- package/out/zero-cache/src/services/change-streamer/subscriber.js.map +1 -1
- package/out/zero-cache/src/services/heapz.d.ts.map +1 -1
- package/out/zero-cache/src/services/heapz.js +1 -0
- package/out/zero-cache/src/services/heapz.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/error.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/error.js +4 -1
- package/out/zero-cache/src/services/mutagen/error.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js +1 -0
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.d.ts +7 -4
- package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.js +80 -8
- package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
- package/out/zero-cache/src/services/replicator/change-processor.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/change-processor.js +21 -29
- package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/change-log.d.ts +1 -2
- package/out/zero-cache/src/services/replicator/schema/change-log.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/change-log.js +2 -5
- package/out/zero-cache/src/services/replicator/schema/change-log.js.map +1 -1
- package/out/zero-cache/src/services/{change-source → replicator/schema}/column-metadata.d.ts +3 -3
- package/out/zero-cache/src/services/replicator/schema/column-metadata.d.ts.map +1 -0
- package/out/zero-cache/src/services/{change-source → replicator/schema}/column-metadata.js +3 -3
- package/out/zero-cache/src/services/replicator/schema/column-metadata.js.map +1 -0
- package/out/zero-cache/src/services/replicator/schema/replication-state.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/replication-state.js +3 -1
- package/out/zero-cache/src/services/replicator/schema/replication-state.js.map +1 -1
- package/out/zero-cache/src/services/run-ast.js +1 -1
- package/out/zero-cache/src/services/run-ast.js.map +1 -1
- package/out/zero-cache/src/services/statz.d.ts.map +1 -1
- package/out/zero-cache/src/services/statz.js +1 -0
- package/out/zero-cache/src/services/statz.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts +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 +59 -40
- package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts +0 -1
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.js +23 -6
- package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +13 -14
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +44 -56
- 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.d.ts +1 -1
- package/out/zero-cache/src/services/view-syncer/row-record-cache.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/row-record-cache.js +22 -11
- package/out/zero-cache/src/services/view-syncer/row-record-cache.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/snapshotter.js +1 -1
- package/out/zero-cache/src/services/view-syncer/snapshotter.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +6 -3
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.js +192 -217
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/lexi-version.d.ts.map +1 -1
- package/out/zero-cache/src/types/lexi-version.js +4 -1
- package/out/zero-cache/src/types/lexi-version.js.map +1 -1
- package/out/zero-cache/src/types/lite.d.ts.map +1 -1
- package/out/zero-cache/src/types/lite.js +8 -2
- package/out/zero-cache/src/types/lite.js.map +1 -1
- package/out/zero-cache/src/types/shards.js +1 -1
- package/out/zero-cache/src/types/shards.js.map +1 -1
- package/out/zero-cache/src/types/sql.d.ts +5 -0
- package/out/zero-cache/src/types/sql.d.ts.map +1 -1
- package/out/zero-cache/src/types/sql.js +5 -1
- package/out/zero-cache/src/types/sql.js.map +1 -1
- package/out/zero-cache/src/types/subscription.js +1 -1
- package/out/zero-cache/src/types/subscription.js.map +1 -1
- package/out/zero-cache/src/workers/connect-params.d.ts +1 -0
- package/out/zero-cache/src/workers/connect-params.d.ts.map +1 -1
- package/out/zero-cache/src/workers/connect-params.js +2 -1
- package/out/zero-cache/src/workers/connect-params.js.map +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts.map +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js +14 -6
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
- package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/workers/syncer.js +17 -10
- package/out/zero-cache/src/workers/syncer.js.map +1 -1
- package/out/zero-client/src/client/connection-manager.d.ts +8 -0
- package/out/zero-client/src/client/connection-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/connection-manager.js +33 -0
- package/out/zero-client/src/client/connection-manager.js.map +1 -1
- package/out/zero-client/src/client/connection.d.ts.map +1 -1
- package/out/zero-client/src/client/connection.js +6 -3
- package/out/zero-client/src/client/connection.js.map +1 -1
- package/out/zero-client/src/client/error.js +1 -1
- package/out/zero-client/src/client/error.js.map +1 -1
- package/out/zero-client/src/client/mutator-proxy.d.ts.map +1 -1
- package/out/zero-client/src/client/mutator-proxy.js +15 -1
- package/out/zero-client/src/client/mutator-proxy.js.map +1 -1
- package/out/zero-client/src/client/options.d.ts +10 -0
- package/out/zero-client/src/client/options.d.ts.map +1 -1
- package/out/zero-client/src/client/options.js.map +1 -1
- package/out/zero-client/src/client/query-manager.d.ts +4 -0
- package/out/zero-client/src/client/query-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/query-manager.js +7 -0
- package/out/zero-client/src/client/query-manager.js.map +1 -1
- package/out/zero-client/src/client/version.js +1 -1
- package/out/zero-client/src/client/zero.d.ts +3 -1
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.js +52 -7
- package/out/zero-client/src/client/zero.js.map +1 -1
- package/out/zero-client/src/mod.d.ts +1 -0
- package/out/zero-client/src/mod.d.ts.map +1 -1
- package/out/zero-protocol/src/connect.d.ts +4 -0
- package/out/zero-protocol/src/connect.d.ts.map +1 -1
- package/out/zero-protocol/src/connect.js +3 -1
- package/out/zero-protocol/src/connect.js.map +1 -1
- package/out/zero-protocol/src/protocol-version.d.ts +1 -1
- package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
- package/out/zero-protocol/src/protocol-version.js +1 -1
- package/out/zero-protocol/src/protocol-version.js.map +1 -1
- package/out/zero-protocol/src/push.d.ts +11 -2
- package/out/zero-protocol/src/push.d.ts.map +1 -1
- package/out/zero-protocol/src/push.js +22 -6
- package/out/zero-protocol/src/push.js.map +1 -1
- package/out/zero-protocol/src/up.d.ts +2 -0
- package/out/zero-protocol/src/up.d.ts.map +1 -1
- package/out/zero-react/src/mod.d.ts +3 -1
- package/out/zero-react/src/mod.d.ts.map +1 -1
- package/out/zero-react/src/paging-reducer.d.ts +61 -0
- package/out/zero-react/src/paging-reducer.d.ts.map +1 -0
- package/out/zero-react/src/paging-reducer.js +77 -0
- package/out/zero-react/src/paging-reducer.js.map +1 -0
- package/out/zero-react/src/use-query.d.ts +11 -1
- package/out/zero-react/src/use-query.d.ts.map +1 -1
- package/out/zero-react/src/use-query.js +13 -11
- package/out/zero-react/src/use-query.js.map +1 -1
- package/out/zero-react/src/use-rows.d.ts +39 -0
- package/out/zero-react/src/use-rows.d.ts.map +1 -0
- package/out/zero-react/src/use-rows.js +130 -0
- package/out/zero-react/src/use-rows.js.map +1 -0
- package/out/zero-react/src/use-zero-virtualizer.d.ts +122 -0
- package/out/zero-react/src/use-zero-virtualizer.d.ts.map +1 -0
- package/out/zero-react/src/use-zero-virtualizer.js +342 -0
- package/out/zero-react/src/use-zero-virtualizer.js.map +1 -0
- package/out/zero-react/src/zero-provider.js +1 -1
- package/out/zero-react/src/zero-provider.js.map +1 -1
- package/out/zero-server/src/adapters/drizzle.d.ts +18 -18
- package/out/zero-server/src/adapters/drizzle.d.ts.map +1 -1
- package/out/zero-server/src/adapters/drizzle.js +8 -22
- package/out/zero-server/src/adapters/drizzle.js.map +1 -1
- package/out/zero-server/src/adapters/pg.d.ts +19 -13
- package/out/zero-server/src/adapters/pg.d.ts.map +1 -1
- package/out/zero-server/src/adapters/pg.js.map +1 -1
- package/out/zero-server/src/adapters/postgresjs.d.ts +19 -13
- package/out/zero-server/src/adapters/postgresjs.d.ts.map +1 -1
- package/out/zero-server/src/adapters/postgresjs.js.map +1 -1
- package/out/zero-server/src/adapters/prisma.d.ts +66 -0
- package/out/zero-server/src/adapters/prisma.d.ts.map +1 -0
- package/out/zero-server/src/adapters/prisma.js +63 -0
- package/out/zero-server/src/adapters/prisma.js.map +1 -0
- package/out/zero-server/src/custom.js +1 -15
- package/out/zero-server/src/custom.js.map +1 -1
- package/out/zero-server/src/mod.d.ts +9 -8
- package/out/zero-server/src/mod.d.ts.map +1 -1
- package/out/zero-server/src/process-mutations.d.ts +2 -2
- package/out/zero-server/src/process-mutations.d.ts.map +1 -1
- package/out/zero-server/src/process-mutations.js +4 -8
- package/out/zero-server/src/process-mutations.js.map +1 -1
- package/out/zero-server/src/push-processor.js +1 -1
- package/out/zero-server/src/push-processor.js.map +1 -1
- package/out/zero-server/src/schema.d.ts.map +1 -1
- package/out/zero-server/src/schema.js +4 -1
- package/out/zero-server/src/schema.js.map +1 -1
- package/out/zero-server/src/zql-database.d.ts.map +1 -1
- package/out/zero-server/src/zql-database.js +17 -8
- package/out/zero-server/src/zql-database.js.map +1 -1
- package/out/zero-solid/src/mod.d.ts +1 -1
- package/out/zero-solid/src/mod.d.ts.map +1 -1
- package/out/zero-solid/src/use-query.d.ts +10 -1
- package/out/zero-solid/src/use-query.d.ts.map +1 -1
- package/out/zero-solid/src/use-query.js +21 -5
- package/out/zero-solid/src/use-query.js.map +1 -1
- package/out/zero-solid/src/use-zero.js +1 -1
- package/out/zero-solid/src/use-zero.js.map +1 -1
- package/out/zql/src/ivm/constraint.d.ts.map +1 -1
- package/out/zql/src/ivm/constraint.js +4 -1
- package/out/zql/src/ivm/constraint.js.map +1 -1
- package/out/zql/src/ivm/exists.d.ts.map +1 -1
- package/out/zql/src/ivm/exists.js +4 -1
- package/out/zql/src/ivm/exists.js.map +1 -1
- package/out/zql/src/ivm/join-utils.d.ts.map +1 -1
- package/out/zql/src/ivm/join-utils.js +8 -2
- package/out/zql/src/ivm/join-utils.js.map +1 -1
- package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
- package/out/zql/src/ivm/memory-source.js +12 -3
- package/out/zql/src/ivm/memory-source.js.map +1 -1
- package/out/zql/src/ivm/push-accumulated.d.ts.map +1 -1
- package/out/zql/src/ivm/push-accumulated.js +25 -2
- package/out/zql/src/ivm/push-accumulated.js.map +1 -1
- package/out/zql/src/ivm/take.d.ts.map +1 -1
- package/out/zql/src/ivm/take.js +24 -6
- package/out/zql/src/ivm/take.js.map +1 -1
- package/out/zql/src/ivm/union-fan-in.d.ts.map +1 -1
- package/out/zql/src/ivm/union-fan-in.js +12 -3
- package/out/zql/src/ivm/union-fan-in.js.map +1 -1
- package/out/zqlite/src/table-source.d.ts.map +1 -1
- package/out/zqlite/src/table-source.js +1 -2
- package/out/zqlite/src/table-source.js.map +1 -1
- package/package.json +6 -2
- package/out/zero-cache/src/services/change-source/column-metadata.d.ts.map +0 -1
- package/out/zero-cache/src/services/change-source/column-metadata.js.map +0 -1
|
@@ -59,6 +59,7 @@ class ViewSyncerService {
|
|
|
59
59
|
#slowHydrateThreshold;
|
|
60
60
|
#queryConfig;
|
|
61
61
|
userQueryURL;
|
|
62
|
+
userQueryHeaders;
|
|
62
63
|
// The ViewSyncerService is only started in response to a connection,
|
|
63
64
|
// so #lastConnectTime is always initialized to now(). This is necessary
|
|
64
65
|
// to handle race conditions in which, e.g. the replica is ready and the
|
|
@@ -103,6 +104,7 @@ class ViewSyncerService {
|
|
|
103
104
|
// auth and cookie headers directly
|
|
104
105
|
#authData;
|
|
105
106
|
#httpCookie;
|
|
107
|
+
#origin;
|
|
106
108
|
#expiredQueriesTimer = 0;
|
|
107
109
|
#setTimeout;
|
|
108
110
|
#customQueryTransformer;
|
|
@@ -156,7 +158,7 @@ class ViewSyncerService {
|
|
|
156
158
|
#inspectorDelegate;
|
|
157
159
|
#config;
|
|
158
160
|
#runPriorityOp;
|
|
159
|
-
constructor(config, lc, shard, taskID, clientGroupID, cvrDb,
|
|
161
|
+
constructor(config, lc, shard, taskID, clientGroupID, cvrDb, pipelineDriver, versionChanges, drainCoordinator, slowHydrateThreshold, inspectorDelegate, customQueryTransformer, runPriorityOp, keepaliveMs = DEFAULT_KEEPALIVE_MS, setTimeoutFn = setTimeout.bind(globalThis)) {
|
|
160
162
|
const queryConfig = config.query?.url ? config.query : config.getQueries;
|
|
161
163
|
this.#config = config;
|
|
162
164
|
this.id = clientGroupID;
|
|
@@ -173,7 +175,6 @@ class ViewSyncerService {
|
|
|
173
175
|
this.#cvrStore = new CVRStore(
|
|
174
176
|
lc,
|
|
175
177
|
cvrDb,
|
|
176
|
-
upstreamDb,
|
|
177
178
|
shard,
|
|
178
179
|
taskID,
|
|
179
180
|
clientGroupID,
|
|
@@ -188,8 +189,11 @@ class ViewSyncerService {
|
|
|
188
189
|
#getHeaderOptions(forwardCookie) {
|
|
189
190
|
return {
|
|
190
191
|
apiKey: this.#queryConfig.apiKey,
|
|
192
|
+
customHeaders: this.userQueryHeaders,
|
|
193
|
+
allowedClientHeaders: this.#queryConfig.allowedClientHeaders,
|
|
191
194
|
token: this.#authData?.raw,
|
|
192
|
-
cookie: forwardCookie ? this.#httpCookie : void 0
|
|
195
|
+
cookie: forwardCookie ? this.#httpCookie : void 0,
|
|
196
|
+
origin: this.#origin
|
|
193
197
|
};
|
|
194
198
|
}
|
|
195
199
|
#runInLockWithCVR(fn) {
|
|
@@ -213,8 +217,10 @@ class ViewSyncerService {
|
|
|
213
217
|
return;
|
|
214
218
|
}
|
|
215
219
|
if (!this.#cvr) {
|
|
216
|
-
this.#lc.debug?.("loading
|
|
220
|
+
this.#lc.debug?.("loading cvr");
|
|
217
221
|
this.#cvr = await this.#runPriorityOp(
|
|
222
|
+
lc,
|
|
223
|
+
"loading cvr",
|
|
218
224
|
() => this.#cvrStore.load(lc, this.#lastConnectTime)
|
|
219
225
|
);
|
|
220
226
|
this.#ttlClock = this.#cvr.ttlClock;
|
|
@@ -272,6 +278,7 @@ class ViewSyncerService {
|
|
|
272
278
|
}
|
|
273
279
|
lc.info?.(`resetting pipelines: ${result.message}`);
|
|
274
280
|
this.#pipelines.reset(clientSchema);
|
|
281
|
+
this.#pipelinesSynced = false;
|
|
275
282
|
}
|
|
276
283
|
const version2 = this.#pipelines.advanceWithoutDiff();
|
|
277
284
|
const cvrVer = versionString(cvr.version);
|
|
@@ -281,7 +288,7 @@ class ViewSyncerService {
|
|
|
281
288
|
}
|
|
282
289
|
lc.info?.(`init pipelines@${version2} (cvr@${cvrVer})`);
|
|
283
290
|
await this.#hydrateUnchangedQueries(lc, cvr);
|
|
284
|
-
await this.#syncQueryPipelineSet(lc, cvr);
|
|
291
|
+
await this.#syncQueryPipelineSet(lc, cvr, "missing");
|
|
285
292
|
this.#pipelinesSynced = true;
|
|
286
293
|
});
|
|
287
294
|
}
|
|
@@ -306,8 +313,9 @@ class ViewSyncerService {
|
|
|
306
313
|
if (hasExpiredQueries(cvr)) {
|
|
307
314
|
lc = lc.withContext("method", "#removeExpiredQueries");
|
|
308
315
|
lc.debug?.("Queries have expired");
|
|
309
|
-
|
|
310
|
-
|
|
316
|
+
if (this.#pipelinesSynced) {
|
|
317
|
+
await this.#syncQueryPipelineSet(lc, cvr, "missing");
|
|
318
|
+
}
|
|
311
319
|
}
|
|
312
320
|
this.#scheduleExpireEviction(lc, cvr);
|
|
313
321
|
};
|
|
@@ -385,16 +393,17 @@ class ViewSyncerService {
|
|
|
385
393
|
baseCookie,
|
|
386
394
|
tokenData,
|
|
387
395
|
httpCookie,
|
|
396
|
+
origin,
|
|
388
397
|
protocolVersion
|
|
389
398
|
} = ctx;
|
|
390
399
|
this.#authData = pickToken(this.#lc, this.#authData, tokenData);
|
|
391
|
-
this.#lc.debug?.(
|
|
392
|
-
`Picked auth token: ${JSON.stringify(this.#authData?.decoded)}`
|
|
393
|
-
);
|
|
400
|
+
this.#lc.debug?.(`Picked auth token for clientGroupID`);
|
|
394
401
|
this.#httpCookie = httpCookie;
|
|
395
|
-
|
|
402
|
+
this.#origin = origin;
|
|
403
|
+
const [, { userQueryURL, userQueryHeaders }] = initConnectionMessage;
|
|
396
404
|
if (this.userQueryURL === void 0) {
|
|
397
405
|
this.userQueryURL = userQueryURL;
|
|
406
|
+
this.userQueryHeaders = userQueryHeaders;
|
|
398
407
|
} else {
|
|
399
408
|
if (this.userQueryURL !== userQueryURL) {
|
|
400
409
|
this.#lc.warn?.(
|
|
@@ -451,6 +460,8 @@ class ViewSyncerService {
|
|
|
451
460
|
clientID2,
|
|
452
461
|
msg,
|
|
453
462
|
cvr,
|
|
463
|
+
"all",
|
|
464
|
+
// re transform all on new connections
|
|
454
465
|
// Until the profileID is required in the URL, default it to
|
|
455
466
|
// `cg${clientGroupID}`, as is done in the schema migration.
|
|
456
467
|
// As clients update to the zero version with the profileID logic,
|
|
@@ -465,13 +476,17 @@ class ViewSyncerService {
|
|
|
465
476
|
});
|
|
466
477
|
}
|
|
467
478
|
async changeDesiredQueries(ctx, msg) {
|
|
468
|
-
await this.#runInLockForClient(
|
|
479
|
+
await this.#runInLockForClient(
|
|
480
|
+
ctx,
|
|
481
|
+
msg,
|
|
482
|
+
(lc, clientID, msg2, cvr) => this.#handleConfigUpdate(lc, clientID, msg2, cvr, "missing")
|
|
483
|
+
);
|
|
469
484
|
}
|
|
470
485
|
async deleteClients(ctx, msg) {
|
|
471
|
-
await this.#runInLockForClient(
|
|
486
|
+
return await this.#runInLockForClient(
|
|
472
487
|
ctx,
|
|
473
488
|
[msg[0], { deleted: msg[1] }],
|
|
474
|
-
this.#handleConfigUpdate
|
|
489
|
+
(lc, clientID, msg2, cvr) => this.#handleConfigUpdate(lc, clientID, msg2, cvr, "missing")
|
|
475
490
|
);
|
|
476
491
|
}
|
|
477
492
|
#getTTLClock(now) {
|
|
@@ -489,7 +504,7 @@ class ViewSyncerService {
|
|
|
489
504
|
return ttlClock;
|
|
490
505
|
}
|
|
491
506
|
#flushUpdater(lc, updater) {
|
|
492
|
-
return this.#runPriorityOp(async () => {
|
|
507
|
+
return this.#runPriorityOp(lc, "flushing cvr", async () => {
|
|
493
508
|
const now = Date.now();
|
|
494
509
|
const ttlClock = this.#getTTLClock(now);
|
|
495
510
|
const { cvr, flushed } = await updater.flush(
|
|
@@ -516,14 +531,22 @@ class ViewSyncerService {
|
|
|
516
531
|
this.#ttlClockInterval = 0;
|
|
517
532
|
}
|
|
518
533
|
#updateTTLClockInCVRWithoutLock(lc) {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
const
|
|
522
|
-
this.#
|
|
523
|
-
|
|
534
|
+
const rid = randomID();
|
|
535
|
+
lc.debug?.("Syncing ttlClock", rid);
|
|
536
|
+
const start = Date.now();
|
|
537
|
+
const ttlClock = this.#getTTLClock(start);
|
|
538
|
+
this.#cvrStore.updateTTLClock(ttlClock, start).then(() => {
|
|
539
|
+
lc.debug?.("Synced ttlClock", rid, `in ${Date.now() - start} ms`);
|
|
540
|
+
}).catch((e) => {
|
|
541
|
+
lc.error?.(
|
|
542
|
+
"failed to update TTL clock",
|
|
543
|
+
rid,
|
|
544
|
+
`after ${Date.now() - start} ms`,
|
|
545
|
+
e
|
|
546
|
+
);
|
|
524
547
|
});
|
|
525
548
|
}
|
|
526
|
-
async #updateCVRConfig(lc, cvr, clientID, fn) {
|
|
549
|
+
async #updateCVRConfig(lc, cvr, clientID, customQueryTransformMode, fn) {
|
|
527
550
|
const updater = new CVRConfigDrivenUpdater(
|
|
528
551
|
this.#cvrStore,
|
|
529
552
|
cvr,
|
|
@@ -541,7 +564,7 @@ class ViewSyncerService {
|
|
|
541
564
|
await pokers.end(newCVR.version);
|
|
542
565
|
}
|
|
543
566
|
if (this.#pipelinesSynced) {
|
|
544
|
-
await this.#syncQueryPipelineSet(lc, this.#cvr);
|
|
567
|
+
await this.#syncQueryPipelineSet(lc, this.#cvr, customQueryTransformMode);
|
|
545
568
|
}
|
|
546
569
|
return this.#cvr;
|
|
547
570
|
}
|
|
@@ -561,8 +584,9 @@ class ViewSyncerService {
|
|
|
561
584
|
`vs.#runInLockForClient(${cmd})`,
|
|
562
585
|
async () => {
|
|
563
586
|
let client;
|
|
587
|
+
let result;
|
|
564
588
|
try {
|
|
565
|
-
await this.#runInLockWithCVR((lc, cvr) => {
|
|
589
|
+
await this.#runInLockWithCVR(async (lc, cvr) => {
|
|
566
590
|
lc = lc.withContext("clientID", clientID).withContext("wsID", wsID).withContext("cmd", cmd);
|
|
567
591
|
lc.debug?.("acquired lock for cvr");
|
|
568
592
|
client = this.#clients.get(clientID);
|
|
@@ -580,7 +604,7 @@ class ViewSyncerService {
|
|
|
580
604
|
lc.warn?.(`Processing ${cmd} before initConnection was received`);
|
|
581
605
|
}
|
|
582
606
|
lc.debug?.(cmd, body);
|
|
583
|
-
|
|
607
|
+
result = await fn(lc, clientID, body, cvr);
|
|
584
608
|
});
|
|
585
609
|
} catch (e) {
|
|
586
610
|
const lc = this.#lc.withContext("clientID", clientID).withContext("wsID", wsID).withContext("cmd", cmd);
|
|
@@ -591,6 +615,7 @@ class ViewSyncerService {
|
|
|
591
615
|
throw e;
|
|
592
616
|
}
|
|
593
617
|
}
|
|
618
|
+
return result;
|
|
594
619
|
}
|
|
595
620
|
);
|
|
596
621
|
}
|
|
@@ -606,68 +631,74 @@ class ViewSyncerService {
|
|
|
606
631
|
deleted,
|
|
607
632
|
desiredQueriesPatch,
|
|
608
633
|
activeClients
|
|
609
|
-
}, cvr, profileID) => startAsyncSpan(tracer, "vs.#patchQueries", async () => {
|
|
634
|
+
}, cvr, customQueryTransformMode, profileID) => startAsyncSpan(tracer, "vs.#patchQueries", async () => {
|
|
610
635
|
const deletedClientIDs = [];
|
|
611
636
|
const deletedClientGroupIDs = [];
|
|
612
|
-
cvr = await this.#updateCVRConfig(
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
637
|
+
cvr = await this.#updateCVRConfig(
|
|
638
|
+
lc,
|
|
639
|
+
cvr,
|
|
640
|
+
clientID,
|
|
641
|
+
customQueryTransformMode,
|
|
642
|
+
(updater) => {
|
|
643
|
+
const { ttlClock } = cvr;
|
|
644
|
+
const patches = [];
|
|
645
|
+
if (clientSchema) {
|
|
646
|
+
updater.setClientSchema(lc, clientSchema);
|
|
647
|
+
}
|
|
648
|
+
if (profileID) {
|
|
649
|
+
updater.setProfileID(lc, profileID);
|
|
650
|
+
}
|
|
651
|
+
lc.debug?.(`applying ${desiredQueriesPatch?.length} query patches`);
|
|
652
|
+
if (desiredQueriesPatch?.length) {
|
|
653
|
+
for (const patch of desiredQueriesPatch) {
|
|
654
|
+
switch (patch.op) {
|
|
655
|
+
case "put":
|
|
656
|
+
patches.push(...updater.putDesiredQueries(clientID, [patch]));
|
|
657
|
+
break;
|
|
658
|
+
case "del":
|
|
659
|
+
patches.push(
|
|
660
|
+
...updater.markDesiredQueriesAsInactive(
|
|
661
|
+
clientID,
|
|
662
|
+
[patch.hash],
|
|
663
|
+
ttlClock
|
|
664
|
+
)
|
|
665
|
+
);
|
|
666
|
+
break;
|
|
667
|
+
case "clear":
|
|
668
|
+
patches.push(...updater.clearDesiredQueries(clientID));
|
|
669
|
+
break;
|
|
670
|
+
}
|
|
640
671
|
}
|
|
641
672
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
673
|
+
const clientIDsToDelete = /* @__PURE__ */ new Set();
|
|
674
|
+
if (activeClients) {
|
|
675
|
+
const allClientIDs = Object.keys(cvr.clients);
|
|
676
|
+
const activeClientsSet = new Set(activeClients);
|
|
677
|
+
for (const id of allClientIDs) {
|
|
678
|
+
if (!activeClientsSet.has(id)) {
|
|
679
|
+
clientIDsToDelete.add(id);
|
|
680
|
+
}
|
|
650
681
|
}
|
|
651
682
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
683
|
+
if (deleted?.clientIDs?.length) {
|
|
684
|
+
for (const cid of deleted.clientIDs) {
|
|
685
|
+
assert(cid !== clientID, "cannot delete self");
|
|
686
|
+
clientIDsToDelete.add(cid);
|
|
687
|
+
}
|
|
657
688
|
}
|
|
689
|
+
for (const cid of clientIDsToDelete) {
|
|
690
|
+
const patchesDueToClient = updater.deleteClient(cid, ttlClock);
|
|
691
|
+
patches.push(...patchesDueToClient);
|
|
692
|
+
deletedClientIDs.push(cid);
|
|
693
|
+
}
|
|
694
|
+
if (deleted?.clientGroupIDs?.length) {
|
|
695
|
+
lc.debug?.(
|
|
696
|
+
`ignoring ${deleted.clientGroupIDs.length} deprecated client group deletes`
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
return patches;
|
|
658
700
|
}
|
|
659
|
-
|
|
660
|
-
const patchesDueToClient = updater.deleteClient(cid, ttlClock);
|
|
661
|
-
patches.push(...patchesDueToClient);
|
|
662
|
-
deletedClientIDs.push(cid);
|
|
663
|
-
}
|
|
664
|
-
if (deleted?.clientGroupIDs?.length) {
|
|
665
|
-
lc.debug?.(
|
|
666
|
-
`ignoring ${deleted.clientGroupIDs.length} deprecated client group deletes`
|
|
667
|
-
);
|
|
668
|
-
}
|
|
669
|
-
return patches;
|
|
670
|
-
});
|
|
701
|
+
);
|
|
671
702
|
if (deletedClientIDs.length && deleted?.clientIDs?.length || deletedClientGroupIDs.length) {
|
|
672
703
|
const clients = this.#getClients();
|
|
673
704
|
await Promise.allSettled(
|
|
@@ -681,6 +712,7 @@ class ViewSyncerService {
|
|
|
681
712
|
);
|
|
682
713
|
}
|
|
683
714
|
this.#scheduleExpireEviction(lc, cvr);
|
|
715
|
+
return deletedClientIDs;
|
|
684
716
|
});
|
|
685
717
|
#scheduleExpireEviction(lc, cvr) {
|
|
686
718
|
const { ttlClock } = cvr;
|
|
@@ -759,21 +791,25 @@ class ViewSyncerService {
|
|
|
759
791
|
"Custom/named queries were requested but no `ZERO_QUERY_URL` is configured for Zero Cache."
|
|
760
792
|
);
|
|
761
793
|
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
794
|
+
const customQueryTransformer = this.#customQueryTransformer;
|
|
795
|
+
if (customQueryTransformer && customQueries.size > 0) {
|
|
796
|
+
const transformedCustomQueries = await this.#runPriorityOp(
|
|
797
|
+
lc,
|
|
798
|
+
"#hydrateUnchangedQueries transforming custom queries",
|
|
799
|
+
() => customQueryTransformer.transform(
|
|
765
800
|
this.#getHeaderOptions(this.#queryConfig.forwardCookies),
|
|
766
801
|
customQueries.values(),
|
|
767
802
|
this.userQueryURL
|
|
768
|
-
)
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
(q)
|
|
773
|
-
|
|
774
|
-
|
|
803
|
+
)
|
|
804
|
+
);
|
|
805
|
+
if (Array.isArray(transformedCustomQueries)) {
|
|
806
|
+
for (const q of transformedCustomQueries) {
|
|
807
|
+
if (!("error" in q) && q.transformationHash === customQueries.get(q.id)?.transformationHash) {
|
|
808
|
+
transformedQueries.push(q);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
775
811
|
}
|
|
776
|
-
}
|
|
812
|
+
}
|
|
777
813
|
for (const q of otherQueries) {
|
|
778
814
|
const transformed = transformAndHashQuery(
|
|
779
815
|
lc,
|
|
@@ -794,7 +830,7 @@ class ViewSyncerService {
|
|
|
794
830
|
transformationHash,
|
|
795
831
|
transformedAst
|
|
796
832
|
} of transformedQueries) {
|
|
797
|
-
const timer = new TimeSliceTimer();
|
|
833
|
+
const timer = new TimeSliceTimer(lc);
|
|
798
834
|
let count = 0;
|
|
799
835
|
await startAsyncSpan(
|
|
800
836
|
tracer,
|
|
@@ -876,11 +912,11 @@ class ViewSyncerService {
|
|
|
876
912
|
this.#clients.get(clientId)?.sendQueryTransformApplicationErrors(errors);
|
|
877
913
|
}
|
|
878
914
|
}
|
|
879
|
-
#addQueryMaterializationServerMetric(
|
|
915
|
+
#addQueryMaterializationServerMetric(queryID, elapsed) {
|
|
880
916
|
this.#inspectorDelegate.addMetric(
|
|
881
917
|
"query-materialization-server",
|
|
882
918
|
elapsed,
|
|
883
|
-
|
|
919
|
+
queryID
|
|
884
920
|
);
|
|
885
921
|
}
|
|
886
922
|
/**
|
|
@@ -891,14 +927,12 @@ class ViewSyncerService {
|
|
|
891
927
|
*
|
|
892
928
|
* This must be called from within the #lock.
|
|
893
929
|
*/
|
|
894
|
-
#syncQueryPipelineSet(lc, cvr) {
|
|
930
|
+
#syncQueryPipelineSet(lc, cvr, customQueryTransformMode) {
|
|
895
931
|
return startAsyncSpan(tracer, "vs.#syncQueryPipelineSet", async () => {
|
|
896
932
|
assert(
|
|
897
933
|
this.#pipelines.initialized(),
|
|
898
934
|
"pipelines must be initialized (syncQueryPipelineSet)"
|
|
899
935
|
);
|
|
900
|
-
const [hydratedQueries, byOriginalHash] = this.#pipelines.addedQueries();
|
|
901
|
-
const hashToIDs = /* @__PURE__ */ new Map();
|
|
902
936
|
if (this.#ttlClock === void 0) {
|
|
903
937
|
this.#ttlClock = cvr.ttlClock;
|
|
904
938
|
}
|
|
@@ -940,14 +974,22 @@ class ViewSyncerService {
|
|
|
940
974
|
);
|
|
941
975
|
}
|
|
942
976
|
let erroredQueryIDs;
|
|
943
|
-
|
|
977
|
+
const customQueriesToTransform = customQueryTransformMode === "all" ? [...customQueries.values()] : customQueryTransformMode && [...customQueries.values()].filter(
|
|
978
|
+
(q) => !this.#pipelines.queries().has(q.id)
|
|
979
|
+
);
|
|
980
|
+
const customQueryTransformer = this.#customQueryTransformer;
|
|
981
|
+
if (customQueryTransformer && customQueriesToTransform.length > 0) {
|
|
944
982
|
const transformStart = performance.now();
|
|
945
983
|
let transformedCustomQueries;
|
|
946
984
|
try {
|
|
947
|
-
transformedCustomQueries = await this.#
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
985
|
+
transformedCustomQueries = await this.#runPriorityOp(
|
|
986
|
+
lc,
|
|
987
|
+
"#syncQueryPipelineSet transforming custom queries",
|
|
988
|
+
() => customQueryTransformer.transform(
|
|
989
|
+
this.#getHeaderOptions(true),
|
|
990
|
+
customQueriesToTransform,
|
|
991
|
+
this.userQueryURL
|
|
992
|
+
)
|
|
951
993
|
);
|
|
952
994
|
this.#queryTransformations.add(1, { result: "success" });
|
|
953
995
|
} catch (e) {
|
|
@@ -963,24 +1005,30 @@ class ViewSyncerService {
|
|
|
963
1005
|
getLogLevel(transformedCustomQueries.kind)
|
|
964
1006
|
);
|
|
965
1007
|
}
|
|
966
|
-
const
|
|
1008
|
+
const successfullyTransformedCustomQueries = /* @__PURE__ */ new Map();
|
|
967
1009
|
erroredQueryIDs = this.#processTransformedCustomQueries(
|
|
968
1010
|
lc,
|
|
969
1011
|
transformedCustomQueries,
|
|
970
1012
|
(q) => {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1013
|
+
const origQuery = customQueries.get(q.id);
|
|
1014
|
+
if (origQuery) {
|
|
1015
|
+
successfullyTransformedCustomQueries.set(q.id, q);
|
|
1016
|
+
transformedQueries.push({
|
|
1017
|
+
id: q.id,
|
|
1018
|
+
origQuery,
|
|
1019
|
+
transformed: q
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
977
1022
|
},
|
|
978
1023
|
customQueries
|
|
979
1024
|
);
|
|
980
|
-
for (const [
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1025
|
+
for (const [
|
|
1026
|
+
queryID,
|
|
1027
|
+
newTransform
|
|
1028
|
+
] of successfullyTransformedCustomQueries) {
|
|
1029
|
+
const existingTransformHash = cvr.queries[queryID]?.transformationHash;
|
|
1030
|
+
if (existingTransformHash) {
|
|
1031
|
+
const oldHash = existingTransformHash;
|
|
984
1032
|
const newHash = newTransform.transformationHash;
|
|
985
1033
|
if (oldHash !== newHash) {
|
|
986
1034
|
lc.info?.(
|
|
@@ -994,31 +1042,15 @@ class ViewSyncerService {
|
|
|
994
1042
|
}
|
|
995
1043
|
}
|
|
996
1044
|
}
|
|
997
|
-
const
|
|
998
|
-
(
|
|
999
|
-
const ids = hashToIDs.get(transformed.transformationHash);
|
|
1000
|
-
if (ids) {
|
|
1001
|
-
ids.push(id);
|
|
1002
|
-
} else {
|
|
1003
|
-
hashToIDs.set(transformed.transformationHash, [id]);
|
|
1004
|
-
}
|
|
1005
|
-
return {
|
|
1006
|
-
id,
|
|
1007
|
-
ast: transformed.transformedAst,
|
|
1008
|
-
transformationHash: transformed.transformationHash,
|
|
1009
|
-
remove: expired(ttlClock, origQuery)
|
|
1010
|
-
};
|
|
1011
|
-
}
|
|
1045
|
+
const removeQueriesQueryIds = new Set(
|
|
1046
|
+
Object.values(cvr.queries).filter((q) => expired(ttlClock, q)).map((q) => q.id).concat(erroredQueryIDs || [])
|
|
1012
1047
|
);
|
|
1013
|
-
const addQueries =
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
);
|
|
1020
|
-
const unhydrateQueries = [...hydratedQueries].filter(
|
|
1021
|
-
(transformationHash) => !desiredQueries.has(transformationHash)
|
|
1048
|
+
const addQueries = transformedQueries.map(({ id, transformed }) => ({
|
|
1049
|
+
id,
|
|
1050
|
+
ast: transformed.transformedAst,
|
|
1051
|
+
transformationHash: transformed.transformationHash
|
|
1052
|
+
})).filter(
|
|
1053
|
+
(q) => !removeQueriesQueryIds.has(q.id) && this.#pipelines.queries().get(q.id)?.transformationHash !== q.transformationHash
|
|
1022
1054
|
);
|
|
1023
1055
|
for (const q of addQueries) {
|
|
1024
1056
|
const orig = cvr.queries[q.id];
|
|
@@ -1029,33 +1061,12 @@ class ViewSyncerService {
|
|
|
1029
1061
|
orig.type === "custom" ? orig.name : orig.ast
|
|
1030
1062
|
);
|
|
1031
1063
|
}
|
|
1032
|
-
if (
|
|
1033
|
-
const successfulHashes = new Set(
|
|
1034
|
-
transformedQueries.map(
|
|
1035
|
-
({ transformed }) => transformed.transformationHash
|
|
1036
|
-
)
|
|
1037
|
-
);
|
|
1038
|
-
for (const queryID of erroredQueryIDs) {
|
|
1039
|
-
let lastKnownHash;
|
|
1040
|
-
const cvrQuery = cvr.queries[queryID];
|
|
1041
|
-
if (cvrQuery?.transformationHash) {
|
|
1042
|
-
lastKnownHash = cvrQuery.transformationHash;
|
|
1043
|
-
}
|
|
1044
|
-
const transformationHash = lastKnownHash && successfulHashes.has(lastKnownHash) ? void 0 : lastKnownHash;
|
|
1045
|
-
removeQueries.push({
|
|
1046
|
-
id: queryID,
|
|
1047
|
-
transformationHash
|
|
1048
|
-
});
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
if (addQueries.length > 0 || removeQueries.length > 0 || unhydrateQueries.length > 0) {
|
|
1064
|
+
if (addQueries.length > 0 || removeQueriesQueryIds.size > 0) {
|
|
1052
1065
|
await this.#addAndRemoveQueries(
|
|
1053
1066
|
lc,
|
|
1054
1067
|
cvr,
|
|
1055
1068
|
addQueries,
|
|
1056
|
-
|
|
1057
|
-
unhydrateQueries,
|
|
1058
|
-
hashToIDs
|
|
1069
|
+
[...removeQueriesQueryIds].map((id) => ({ id }))
|
|
1059
1070
|
);
|
|
1060
1071
|
} else {
|
|
1061
1072
|
await this.#catchupClients(lc, cvr);
|
|
@@ -1089,10 +1100,10 @@ class ViewSyncerService {
|
|
|
1089
1100
|
}
|
|
1090
1101
|
}
|
|
1091
1102
|
// This must be called from within the #lock.
|
|
1092
|
-
#addAndRemoveQueries(lc, cvr, addQueries, removeQueries
|
|
1103
|
+
#addAndRemoveQueries(lc, cvr, addQueries, removeQueries) {
|
|
1093
1104
|
return startAsyncSpan(tracer, "vs.#addAndRemoveQueries", async () => {
|
|
1094
1105
|
assert(
|
|
1095
|
-
addQueries.length > 0 || removeQueries.length > 0
|
|
1106
|
+
addQueries.length > 0 || removeQueries.length > 0,
|
|
1096
1107
|
"Must have queries to add or remove"
|
|
1097
1108
|
);
|
|
1098
1109
|
const start = performance.now();
|
|
@@ -1116,29 +1127,17 @@ class ViewSyncerService {
|
|
|
1116
1127
|
await pokers.addPatch(patch);
|
|
1117
1128
|
}
|
|
1118
1129
|
for (const q of removeQueries) {
|
|
1119
|
-
|
|
1120
|
-
this.#pipelines.removeQuery(q.transformationHash);
|
|
1121
|
-
}
|
|
1130
|
+
this.#pipelines.removeQuery(q.id);
|
|
1122
1131
|
this.#inspectorDelegate.removeQuery(q.id);
|
|
1123
1132
|
this.#queryReplacements.delete(q.id);
|
|
1124
1133
|
}
|
|
1125
|
-
for (const hash of unhydrateQueries) {
|
|
1126
|
-
this.#pipelines.removeQuery(hash);
|
|
1127
|
-
const ids = hashToIDs.get(hash);
|
|
1128
|
-
if (ids) {
|
|
1129
|
-
for (const id of ids) {
|
|
1130
|
-
this.#inspectorDelegate.removeQuery(id);
|
|
1131
|
-
this.#queryReplacements.delete(id);
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
1134
|
let totalProcessTime = 0;
|
|
1136
|
-
const timer = new TimeSliceTimer();
|
|
1135
|
+
const timer = new TimeSliceTimer(lc);
|
|
1137
1136
|
const pipelines = this.#pipelines;
|
|
1138
1137
|
const hydrations = this.#hydrations;
|
|
1139
1138
|
const hydrationTime = this.#hydrationTime;
|
|
1140
1139
|
const self = this;
|
|
1141
|
-
await yieldProcess();
|
|
1140
|
+
await yieldProcess(lc);
|
|
1142
1141
|
function* generateRowChanges(slowHydrateThreshold) {
|
|
1143
1142
|
for (const q of addQueries) {
|
|
1144
1143
|
lc = lc.withContext("hash", q.id).withContext("transformationHash", q.transformationHash);
|
|
@@ -1151,10 +1150,7 @@ class ViewSyncerService {
|
|
|
1151
1150
|
);
|
|
1152
1151
|
const elapsed = timer.stop();
|
|
1153
1152
|
totalProcessTime += elapsed;
|
|
1154
|
-
self.#addQueryMaterializationServerMetric(
|
|
1155
|
-
q.transformationHash,
|
|
1156
|
-
elapsed
|
|
1157
|
-
);
|
|
1153
|
+
self.#addQueryMaterializationServerMetric(q.id, elapsed);
|
|
1158
1154
|
if (elapsed > slowHydrateThreshold) {
|
|
1159
1155
|
lc.warn?.("Slow query materialization", elapsed, q.ast);
|
|
1160
1156
|
}
|
|
@@ -1171,8 +1167,7 @@ class ViewSyncerService {
|
|
|
1171
1167
|
timer,
|
|
1172
1168
|
generateRowChanges(this.#slowHydrateThreshold),
|
|
1173
1169
|
updater,
|
|
1174
|
-
pokers
|
|
1175
|
-
hashToIDs
|
|
1170
|
+
pokers
|
|
1176
1171
|
);
|
|
1177
1172
|
for (const patch of await updater.deleteUnreferencedRows(lc)) {
|
|
1178
1173
|
await pokers.addPatch(patch);
|
|
@@ -1232,6 +1227,8 @@ class ViewSyncerService {
|
|
|
1232
1227
|
cvr,
|
|
1233
1228
|
current
|
|
1234
1229
|
);
|
|
1230
|
+
configPatches.catch(() => {
|
|
1231
|
+
});
|
|
1235
1232
|
let rowPatchCount = 0;
|
|
1236
1233
|
for await (const rows of rowPatches) {
|
|
1237
1234
|
for (const row of rows) {
|
|
@@ -1267,7 +1264,7 @@ class ViewSyncerService {
|
|
|
1267
1264
|
}
|
|
1268
1265
|
});
|
|
1269
1266
|
}
|
|
1270
|
-
#processChanges(lc, timer, changes, updater, pokers
|
|
1267
|
+
#processChanges(lc, timer, changes, updater, pokers) {
|
|
1271
1268
|
return startAsyncSpan(tracer, "vs.#processChanges", async () => {
|
|
1272
1269
|
const start = performance.now();
|
|
1273
1270
|
const rows = new CustomKeyMap(rowIDString);
|
|
@@ -1290,24 +1287,14 @@ class ViewSyncerService {
|
|
|
1290
1287
|
await timer.yieldProcess("yield in processChanges");
|
|
1291
1288
|
continue;
|
|
1292
1289
|
}
|
|
1293
|
-
const {
|
|
1294
|
-
type,
|
|
1295
|
-
queryHash: transformationHash,
|
|
1296
|
-
table,
|
|
1297
|
-
rowKey,
|
|
1298
|
-
row
|
|
1299
|
-
} = change;
|
|
1300
|
-
const queryIDs = must(
|
|
1301
|
-
hashToIDs.get(transformationHash),
|
|
1302
|
-
"could not find the original hash for the transformation hash"
|
|
1303
|
-
);
|
|
1290
|
+
const { type, queryID, table, rowKey, row } = change;
|
|
1304
1291
|
const rowID = { schema: "", table, rowKey };
|
|
1305
1292
|
let parsedRow = rows.get(rowID);
|
|
1306
1293
|
if (!parsedRow) {
|
|
1307
1294
|
parsedRow = { refCounts: {} };
|
|
1308
1295
|
rows.set(rowID, parsedRow);
|
|
1309
1296
|
}
|
|
1310
|
-
|
|
1297
|
+
parsedRow.refCounts[queryID] ??= 0;
|
|
1311
1298
|
const updateVersion = (row2) => {
|
|
1312
1299
|
const { version: version2, contents } = contentsAndVersion(row2);
|
|
1313
1300
|
parsedRow.version = version2;
|
|
@@ -1316,13 +1303,13 @@ class ViewSyncerService {
|
|
|
1316
1303
|
switch (type) {
|
|
1317
1304
|
case "add":
|
|
1318
1305
|
updateVersion(row);
|
|
1319
|
-
|
|
1306
|
+
parsedRow.refCounts[queryID]++;
|
|
1320
1307
|
break;
|
|
1321
1308
|
case "edit":
|
|
1322
1309
|
updateVersion(row);
|
|
1323
1310
|
break;
|
|
1324
1311
|
case "remove":
|
|
1325
|
-
|
|
1312
|
+
parsedRow.refCounts[queryID]--;
|
|
1326
1313
|
break;
|
|
1327
1314
|
default:
|
|
1328
1315
|
unreachable(type);
|
|
@@ -1353,7 +1340,7 @@ class ViewSyncerService {
|
|
|
1353
1340
|
"pipelines must be initialized (advancePipelines"
|
|
1354
1341
|
);
|
|
1355
1342
|
const start = performance.now();
|
|
1356
|
-
const timer = new TimeSliceTimer();
|
|
1343
|
+
const timer = new TimeSliceTimer(lc);
|
|
1357
1344
|
const { version: version2, numChanges, changes } = this.#pipelines.advance(timer);
|
|
1358
1345
|
lc = lc.withContext("newVersion", version2);
|
|
1359
1346
|
const updater = new CVRQueryDrivenUpdater(
|
|
@@ -1367,15 +1354,13 @@ class ViewSyncerService {
|
|
|
1367
1354
|
updater.updatedVersion()
|
|
1368
1355
|
);
|
|
1369
1356
|
lc.debug?.(`applying ${numChanges} to advance to ${version2}`);
|
|
1370
|
-
const hashToIDs = createHashToIDs(cvr);
|
|
1371
1357
|
try {
|
|
1372
1358
|
await this.#processChanges(
|
|
1373
1359
|
lc,
|
|
1374
1360
|
await timer.start(),
|
|
1375
1361
|
changes,
|
|
1376
1362
|
updater,
|
|
1377
|
-
pokers
|
|
1378
|
-
hashToIDs
|
|
1363
|
+
pokers
|
|
1379
1364
|
);
|
|
1380
1365
|
} catch (e) {
|
|
1381
1366
|
if (e instanceof ResetPipelinesSignal) {
|
|
@@ -1442,22 +1427,8 @@ class ViewSyncerService {
|
|
|
1442
1427
|
}
|
|
1443
1428
|
}
|
|
1444
1429
|
const CURSOR_PAGE_SIZE = 1e4;
|
|
1445
|
-
function createHashToIDs(cvr) {
|
|
1446
|
-
const hashToIDs = /* @__PURE__ */ new Map();
|
|
1447
|
-
for (const { id, transformationHash } of Object.values(cvr.queries)) {
|
|
1448
|
-
if (!transformationHash) {
|
|
1449
|
-
continue;
|
|
1450
|
-
}
|
|
1451
|
-
if (hashToIDs.has(transformationHash)) {
|
|
1452
|
-
must(hashToIDs.get(transformationHash)).push(id);
|
|
1453
|
-
} else {
|
|
1454
|
-
hashToIDs.set(transformationHash, [id]);
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
1457
|
-
return hashToIDs;
|
|
1458
|
-
}
|
|
1459
1430
|
const timeSliceQueue = new Lock();
|
|
1460
|
-
function yieldProcess() {
|
|
1431
|
+
function yieldProcess(_lc) {
|
|
1461
1432
|
return timeSliceQueue.withLock(() => new Promise(setImmediate));
|
|
1462
1433
|
}
|
|
1463
1434
|
function contentsAndVersion(row) {
|
|
@@ -1545,8 +1516,12 @@ function hasExpiredQueries(cvr) {
|
|
|
1545
1516
|
class TimeSliceTimer {
|
|
1546
1517
|
#total = 0;
|
|
1547
1518
|
#start = 0;
|
|
1519
|
+
#lc;
|
|
1520
|
+
constructor(lc) {
|
|
1521
|
+
this.#lc = lc;
|
|
1522
|
+
}
|
|
1548
1523
|
async start() {
|
|
1549
|
-
await yieldProcess();
|
|
1524
|
+
await yieldProcess(this.#lc);
|
|
1550
1525
|
return this.startWithoutYielding();
|
|
1551
1526
|
}
|
|
1552
1527
|
startWithoutYielding() {
|
|
@@ -1556,7 +1531,7 @@ class TimeSliceTimer {
|
|
|
1556
1531
|
}
|
|
1557
1532
|
async yieldProcess(_msgForTesting) {
|
|
1558
1533
|
this.#stopLap();
|
|
1559
|
-
await yieldProcess();
|
|
1534
|
+
await yieldProcess(this.#lc);
|
|
1560
1535
|
this.#startLap();
|
|
1561
1536
|
}
|
|
1562
1537
|
#startLap() {
|