@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../../../../../zero-cache/src/services/change-source/pg/schema/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../../../../../zero-cache/src/services/change-source/pg/schema/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAWjD,OAAO,KAAK,EAAC,iCAAiC,EAAC,MAAM,gBAAgB,CAAC;AAEtE,eAAO,MAAM,yBAAyB,QAAiB,CAAC;AAQxD,wBAAgB,QAAQ,CACtB,EAAE,EAAE,UAAU,EACd,KAAK,EAAE,iCAAiC,QAyCzC;AAED,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,QAAQ,CAAC,IAAI,iCAAiC;gBAElC,GAAG,EAAE,MAAM;CAGxB"}
|
|
@@ -3,7 +3,7 @@ import { Default, Nothing, Index } from "../../../../db/postgres-replica-identit
|
|
|
3
3
|
import { ZERO_VERSION_COLUMN_NAME } from "../../../replicator/schema/constants.js";
|
|
4
4
|
const ALLOWED_TABLE_CHARS = /^[A-Za-z_]+[A-Za-z0-9_-]*$/;
|
|
5
5
|
const ALLOWED_COLUMN_CHARS = /^[A-Za-z_]+[.A-Za-z0-9_-]*$/;
|
|
6
|
-
function validate(lc, table
|
|
6
|
+
function validate(lc, table) {
|
|
7
7
|
if (ZERO_VERSION_COLUMN_NAME in table.columns) {
|
|
8
8
|
throw new UnsupportedTableSchemaError(
|
|
9
9
|
`Table "${table.name}" uses reserved column name "${ZERO_VERSION_COLUMN_NAME}"`
|
|
@@ -25,9 +25,7 @@ Table "${table.name}" needs a primary key in order to be synced to clients. Add
|
|
|
25
25
|
`Table "${table.name}" with REPLICA IDENTITY NOTHING cannot be replicated`
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
|
-
if (table.replicaIdentity === Index &&
|
|
29
|
-
(idx) => idx.schema === table.schema && idx.tableName === table.name && idx.isReplicaIdentity
|
|
30
|
-
)) {
|
|
28
|
+
if (table.replicaIdentity === Index && table.replicaIdentityColumns.length === 0) {
|
|
31
29
|
throw new UnsupportedTableSchemaError(
|
|
32
30
|
`Table "${table.name}" is missing its REPLICA IDENTITY INDEX`
|
|
33
31
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sources":["../../../../../../../../zero-cache/src/services/change-source/pg/schema/validation.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport {\n mapPostgresToLite,\n warnIfDataTypeSupported,\n} from '../../../../db/pg-to-lite.ts';\nimport {\n Default,\n Index,\n Nothing,\n} from '../../../../db/postgres-replica-identity-enum.ts';\nimport
|
|
1
|
+
{"version":3,"file":"validation.js","sources":["../../../../../../../../zero-cache/src/services/change-source/pg/schema/validation.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport {\n mapPostgresToLite,\n warnIfDataTypeSupported,\n} from '../../../../db/pg-to-lite.ts';\nimport {\n Default,\n Index,\n Nothing,\n} from '../../../../db/postgres-replica-identity-enum.ts';\nimport {ZERO_VERSION_COLUMN_NAME} from '../../../replicator/schema/constants.ts';\nimport type {PublishedTableWithReplicaIdentity} from './published.ts';\n\nexport const ALLOWED_APP_ID_CHARACTERS = /^[a-z0-9_]+$/;\n\nconst ALLOWED_TABLE_CHARS = /^[A-Za-z_]+[A-Za-z0-9_-]*$/;\n\n// Dots are allowed in column names since there is no need for\n// a schema/table delimiter when mapped to SQLite names.\nconst ALLOWED_COLUMN_CHARS = /^[A-Za-z_]+[.A-Za-z0-9_-]*$/;\n\nexport function validate(\n lc: LogContext,\n table: PublishedTableWithReplicaIdentity,\n) {\n if (ZERO_VERSION_COLUMN_NAME in table.columns) {\n throw new UnsupportedTableSchemaError(\n `Table \"${table.name}\" uses reserved column name \"${ZERO_VERSION_COLUMN_NAME}\"`,\n );\n }\n if (!table.primaryKey?.length && table.replicaIdentity === Default) {\n lc.warn?.(\n `\\n\\n\\n` +\n `Table \"${table.name}\" needs a primary key in order to be synced to clients. ` +\n `Add one with 'ALTER TABLE \"${table.name}\" ADD PRIMARY KEY (...)'.` +\n `\\n\\n\\n`,\n );\n }\n if (table.replicaIdentity === Nothing) {\n throw new UnsupportedTableSchemaError(\n `Table \"${table.name}\" with REPLICA IDENTITY NOTHING cannot be replicated`,\n );\n }\n if (\n table.replicaIdentity === Index &&\n table.replicaIdentityColumns.length === 0\n ) {\n throw new UnsupportedTableSchemaError(\n `Table \"${table.name}\" is missing its REPLICA IDENTITY INDEX`,\n );\n }\n if (!ALLOWED_TABLE_CHARS.test(table.name)) {\n throw new UnsupportedTableSchemaError(\n `Table \"${table.name}\" has invalid characters.`,\n );\n }\n for (const [col, spec] of Object.entries(mapPostgresToLite(table).columns)) {\n if (!ALLOWED_COLUMN_CHARS.test(col)) {\n throw new UnsupportedTableSchemaError(\n `Column \"${col}\" in table \"${table.name}\" has invalid characters.`,\n );\n }\n warnIfDataTypeSupported(lc, spec.dataType, table.name, col);\n }\n}\n\nexport class UnsupportedTableSchemaError extends Error {\n readonly name = 'UnsupportedTableSchemaError';\n\n constructor(msg: string) {\n super(msg);\n }\n}\n"],"names":[],"mappings":";;;AAeA,MAAM,sBAAsB;AAI5B,MAAM,uBAAuB;AAEtB,SAAS,SACd,IACA,OACA;AACA,MAAI,4BAA4B,MAAM,SAAS;AAC7C,UAAM,IAAI;AAAA,MACR,UAAU,MAAM,IAAI,gCAAgC,wBAAwB;AAAA,IAAA;AAAA,EAEhF;AACA,MAAI,CAAC,MAAM,YAAY,UAAU,MAAM,oBAAoB,SAAS;AAClE,OAAG;AAAA,MACD;AAAA;AAAA;AAAA,SACY,MAAM,IAAI,sFACU,MAAM,IAAI;AAAA;AAAA;AAAA;AAAA,IAAA;AAAA,EAG9C;AACA,MAAI,MAAM,oBAAoB,SAAS;AACrC,UAAM,IAAI;AAAA,MACR,UAAU,MAAM,IAAI;AAAA,IAAA;AAAA,EAExB;AACA,MACE,MAAM,oBAAoB,SAC1B,MAAM,uBAAuB,WAAW,GACxC;AACA,UAAM,IAAI;AAAA,MACR,UAAU,MAAM,IAAI;AAAA,IAAA;AAAA,EAExB;AACA,MAAI,CAAC,oBAAoB,KAAK,MAAM,IAAI,GAAG;AACzC,UAAM,IAAI;AAAA,MACR,UAAU,MAAM,IAAI;AAAA,IAAA;AAAA,EAExB;AACA,aAAW,CAAC,KAAK,IAAI,KAAK,OAAO,QAAQ,kBAAkB,KAAK,EAAE,OAAO,GAAG;AAC1E,QAAI,CAAC,qBAAqB,KAAK,GAAG,GAAG;AACnC,YAAM,IAAI;AAAA,QACR,WAAW,GAAG,eAAe,MAAM,IAAI;AAAA,MAAA;AAAA,IAE3C;AACA,4BAAwB,IAAI,KAAK,UAAU,MAAM,MAAM,GAAG;AAAA,EAC5D;AACF;AAEO,MAAM,oCAAoC,MAAM;AAAA,EAC5C,OAAO;AAAA,EAEhB,YAAY,KAAa;AACvB,UAAM,GAAG;AAAA,EACX;AACF;"}
|
|
@@ -16,52 +16,79 @@ export declare const commitSchema: v.ObjectType<{
|
|
|
16
16
|
export declare const rollbackSchema: v.ObjectType<{
|
|
17
17
|
tag: v.Type<"rollback">;
|
|
18
18
|
}, undefined>;
|
|
19
|
-
export declare const relationSchema: v.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
export declare const relationSchema: v.Type<{
|
|
20
|
+
rowKey: {
|
|
21
|
+
type?: "default" | "nothing" | "full" | "index" | undefined;
|
|
22
|
+
columns: string[];
|
|
23
|
+
};
|
|
24
|
+
keyColumns?: string[] | undefined;
|
|
25
|
+
replicaIdentity?: "default" | "nothing" | "full" | "index" | undefined;
|
|
26
|
+
schema: string;
|
|
27
|
+
name: string;
|
|
28
|
+
}>;
|
|
29
|
+
export declare const tableMetadataSchema: v.ObjectType<{
|
|
30
|
+
rowKey: v.ObjectType<{
|
|
31
|
+
columns: v.ArrayType<v.Type<string>>;
|
|
32
|
+
type: v.Optional<"default" | "nothing" | "full" | "index">;
|
|
33
|
+
}, undefined>;
|
|
24
34
|
}, undefined>;
|
|
35
|
+
export type TableMetadata = v.Infer<typeof tableMetadataSchema>;
|
|
25
36
|
export declare const rowSchema: v.Type<Record<string, import("../../../../../../shared/src/bigint-json.ts").JSONValue>>;
|
|
26
37
|
export declare const insertSchema: v.ObjectType<{
|
|
27
38
|
tag: v.Type<"insert">;
|
|
28
|
-
relation: v.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
relation: v.Type<{
|
|
40
|
+
rowKey: {
|
|
41
|
+
type?: "default" | "nothing" | "full" | "index" | undefined;
|
|
42
|
+
columns: string[];
|
|
43
|
+
};
|
|
44
|
+
keyColumns?: string[] | undefined;
|
|
45
|
+
replicaIdentity?: "default" | "nothing" | "full" | "index" | undefined;
|
|
46
|
+
schema: string;
|
|
47
|
+
name: string;
|
|
48
|
+
}>;
|
|
34
49
|
new: v.Type<Record<string, import("../../../../../../shared/src/bigint-json.ts").JSONValue>>;
|
|
35
50
|
}, undefined>;
|
|
36
51
|
export declare const updateSchema: v.ObjectType<{
|
|
37
52
|
tag: v.Type<"update">;
|
|
38
|
-
relation: v.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
relation: v.Type<{
|
|
54
|
+
rowKey: {
|
|
55
|
+
type?: "default" | "nothing" | "full" | "index" | undefined;
|
|
56
|
+
columns: string[];
|
|
57
|
+
};
|
|
58
|
+
keyColumns?: string[] | undefined;
|
|
59
|
+
replicaIdentity?: "default" | "nothing" | "full" | "index" | undefined;
|
|
60
|
+
schema: string;
|
|
61
|
+
name: string;
|
|
62
|
+
}>;
|
|
44
63
|
key: v.Type<Record<string, import("../../../../../../shared/src/bigint-json.ts").JSONValue> | null>;
|
|
45
64
|
new: v.Type<Record<string, import("../../../../../../shared/src/bigint-json.ts").JSONValue>>;
|
|
46
65
|
}, undefined>;
|
|
47
66
|
export declare const deleteSchema: v.ObjectType<{
|
|
48
67
|
tag: v.Type<"delete">;
|
|
49
|
-
relation: v.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
relation: v.Type<{
|
|
69
|
+
rowKey: {
|
|
70
|
+
type?: "default" | "nothing" | "full" | "index" | undefined;
|
|
71
|
+
columns: string[];
|
|
72
|
+
};
|
|
73
|
+
keyColumns?: string[] | undefined;
|
|
74
|
+
replicaIdentity?: "default" | "nothing" | "full" | "index" | undefined;
|
|
75
|
+
schema: string;
|
|
76
|
+
name: string;
|
|
77
|
+
}>;
|
|
55
78
|
key: v.Type<Record<string, import("../../../../../../shared/src/bigint-json.ts").JSONValue>>;
|
|
56
79
|
}, undefined>;
|
|
57
80
|
export declare const truncateSchema: v.ObjectType<{
|
|
58
81
|
tag: v.Type<"truncate">;
|
|
59
|
-
relations: v.ArrayType<v.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
82
|
+
relations: v.ArrayType<v.Type<{
|
|
83
|
+
rowKey: {
|
|
84
|
+
type?: "default" | "nothing" | "full" | "index" | undefined;
|
|
85
|
+
columns: string[];
|
|
86
|
+
};
|
|
87
|
+
keyColumns?: string[] | undefined;
|
|
88
|
+
replicaIdentity?: "default" | "nothing" | "full" | "index" | undefined;
|
|
89
|
+
schema: string;
|
|
90
|
+
name: string;
|
|
91
|
+
}>>;
|
|
65
92
|
}, undefined>;
|
|
66
93
|
declare const identifierSchema: v.ObjectType<{
|
|
67
94
|
schema: v.Type<string>;
|
|
@@ -85,6 +112,12 @@ export declare const createTableSchema: v.ObjectType<{
|
|
|
85
112
|
}, "schema"> & {
|
|
86
113
|
schema: v.Type<string>;
|
|
87
114
|
}, undefined>;
|
|
115
|
+
metadata: v.Optional<{
|
|
116
|
+
rowKey: {
|
|
117
|
+
type?: "default" | "nothing" | "full" | "index" | undefined;
|
|
118
|
+
columns: string[];
|
|
119
|
+
};
|
|
120
|
+
}>;
|
|
88
121
|
}, undefined>;
|
|
89
122
|
export declare const renameTableSchema: v.ObjectType<{
|
|
90
123
|
tag: v.Type<"rename-table">;
|
|
@@ -97,6 +130,25 @@ export declare const renameTableSchema: v.ObjectType<{
|
|
|
97
130
|
name: v.Type<string>;
|
|
98
131
|
}, undefined>;
|
|
99
132
|
}, undefined>;
|
|
133
|
+
export declare const updateTableMetadataSchema: v.ObjectType<{
|
|
134
|
+
tag: v.Type<"update-table-metadata">;
|
|
135
|
+
table: v.ObjectType<{
|
|
136
|
+
schema: v.Type<string>;
|
|
137
|
+
name: v.Type<string>;
|
|
138
|
+
}, undefined>;
|
|
139
|
+
old: v.ObjectType<{
|
|
140
|
+
rowKey: v.ObjectType<{
|
|
141
|
+
columns: v.ArrayType<v.Type<string>>;
|
|
142
|
+
type: v.Optional<"default" | "nothing" | "full" | "index">;
|
|
143
|
+
}, undefined>;
|
|
144
|
+
}, undefined>;
|
|
145
|
+
new: v.ObjectType<{
|
|
146
|
+
rowKey: v.ObjectType<{
|
|
147
|
+
columns: v.ArrayType<v.Type<string>>;
|
|
148
|
+
type: v.Optional<"default" | "nothing" | "full" | "index">;
|
|
149
|
+
}, undefined>;
|
|
150
|
+
}, undefined>;
|
|
151
|
+
}, undefined>;
|
|
100
152
|
export declare const addColumnSchema: v.ObjectType<{
|
|
101
153
|
tag: v.Type<"add-column">;
|
|
102
154
|
table: v.ObjectType<{
|
|
@@ -115,6 +167,12 @@ export declare const addColumnSchema: v.ObjectType<{
|
|
|
115
167
|
dflt: v.Optional<string | null>;
|
|
116
168
|
}, undefined>;
|
|
117
169
|
}, undefined>;
|
|
170
|
+
tableMetadata: v.Optional<{
|
|
171
|
+
rowKey: {
|
|
172
|
+
type?: "default" | "nothing" | "full" | "index" | undefined;
|
|
173
|
+
columns: string[];
|
|
174
|
+
};
|
|
175
|
+
}>;
|
|
118
176
|
}, undefined>;
|
|
119
177
|
export declare const updateColumnSchema: v.ObjectType<{
|
|
120
178
|
tag: v.Type<"update-column">;
|
|
@@ -190,6 +248,7 @@ export type MessageDelete = v.Infer<typeof deleteSchema>;
|
|
|
190
248
|
export type MessageTruncate = v.Infer<typeof truncateSchema>;
|
|
191
249
|
export type TableCreate = v.Infer<typeof createTableSchema>;
|
|
192
250
|
export type TableRename = v.Infer<typeof renameTableSchema>;
|
|
251
|
+
export type TableUpdateMetadata = v.Infer<typeof updateTableMetadataSchema>;
|
|
193
252
|
export type ColumnAdd = v.Infer<typeof addColumnSchema>;
|
|
194
253
|
export type ColumnUpdate = v.Infer<typeof updateColumnSchema>;
|
|
195
254
|
export type ColumnDrop = v.Infer<typeof dropColumnSchema>;
|
|
@@ -198,40 +257,56 @@ export type IndexCreate = v.Infer<typeof createIndexSchema>;
|
|
|
198
257
|
export type IndexDrop = v.Infer<typeof dropIndexSchema>;
|
|
199
258
|
export declare const dataChangeSchema: v.UnionType<[v.ObjectType<{
|
|
200
259
|
tag: v.Type<"insert">;
|
|
201
|
-
relation: v.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
260
|
+
relation: v.Type<{
|
|
261
|
+
rowKey: {
|
|
262
|
+
type?: "default" | "nothing" | "full" | "index" | undefined;
|
|
263
|
+
columns: string[];
|
|
264
|
+
};
|
|
265
|
+
keyColumns?: string[] | undefined;
|
|
266
|
+
replicaIdentity?: "default" | "nothing" | "full" | "index" | undefined;
|
|
267
|
+
schema: string;
|
|
268
|
+
name: string;
|
|
269
|
+
}>;
|
|
207
270
|
new: v.Type<Record<string, import("../../../../../../shared/src/bigint-json.ts").JSONValue>>;
|
|
208
271
|
}, undefined>, v.ObjectType<{
|
|
209
272
|
tag: v.Type<"update">;
|
|
210
|
-
relation: v.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
273
|
+
relation: v.Type<{
|
|
274
|
+
rowKey: {
|
|
275
|
+
type?: "default" | "nothing" | "full" | "index" | undefined;
|
|
276
|
+
columns: string[];
|
|
277
|
+
};
|
|
278
|
+
keyColumns?: string[] | undefined;
|
|
279
|
+
replicaIdentity?: "default" | "nothing" | "full" | "index" | undefined;
|
|
280
|
+
schema: string;
|
|
281
|
+
name: string;
|
|
282
|
+
}>;
|
|
216
283
|
key: v.Type<Record<string, import("../../../../../../shared/src/bigint-json.ts").JSONValue> | null>;
|
|
217
284
|
new: v.Type<Record<string, import("../../../../../../shared/src/bigint-json.ts").JSONValue>>;
|
|
218
285
|
}, undefined>, v.ObjectType<{
|
|
219
286
|
tag: v.Type<"delete">;
|
|
220
|
-
relation: v.
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
287
|
+
relation: v.Type<{
|
|
288
|
+
rowKey: {
|
|
289
|
+
type?: "default" | "nothing" | "full" | "index" | undefined;
|
|
290
|
+
columns: string[];
|
|
291
|
+
};
|
|
292
|
+
keyColumns?: string[] | undefined;
|
|
293
|
+
replicaIdentity?: "default" | "nothing" | "full" | "index" | undefined;
|
|
294
|
+
schema: string;
|
|
295
|
+
name: string;
|
|
296
|
+
}>;
|
|
226
297
|
key: v.Type<Record<string, import("../../../../../../shared/src/bigint-json.ts").JSONValue>>;
|
|
227
298
|
}, undefined>, v.ObjectType<{
|
|
228
299
|
tag: v.Type<"truncate">;
|
|
229
|
-
relations: v.ArrayType<v.
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
300
|
+
relations: v.ArrayType<v.Type<{
|
|
301
|
+
rowKey: {
|
|
302
|
+
type?: "default" | "nothing" | "full" | "index" | undefined;
|
|
303
|
+
columns: string[];
|
|
304
|
+
};
|
|
305
|
+
keyColumns?: string[] | undefined;
|
|
306
|
+
replicaIdentity?: "default" | "nothing" | "full" | "index" | undefined;
|
|
307
|
+
schema: string;
|
|
308
|
+
name: string;
|
|
309
|
+
}>>;
|
|
235
310
|
}, undefined>, v.ObjectType<{
|
|
236
311
|
tag: v.Type<"create-table">;
|
|
237
312
|
spec: v.ObjectType<Omit<{
|
|
@@ -249,6 +324,12 @@ export declare const dataChangeSchema: v.UnionType<[v.ObjectType<{
|
|
|
249
324
|
}, "schema"> & {
|
|
250
325
|
schema: v.Type<string>;
|
|
251
326
|
}, undefined>;
|
|
327
|
+
metadata: v.Optional<{
|
|
328
|
+
rowKey: {
|
|
329
|
+
type?: "default" | "nothing" | "full" | "index" | undefined;
|
|
330
|
+
columns: string[];
|
|
331
|
+
};
|
|
332
|
+
}>;
|
|
252
333
|
}, undefined>, v.ObjectType<{
|
|
253
334
|
tag: v.Type<"rename-table">;
|
|
254
335
|
old: v.ObjectType<{
|
|
@@ -259,6 +340,24 @@ export declare const dataChangeSchema: v.UnionType<[v.ObjectType<{
|
|
|
259
340
|
schema: v.Type<string>;
|
|
260
341
|
name: v.Type<string>;
|
|
261
342
|
}, undefined>;
|
|
343
|
+
}, undefined>, v.ObjectType<{
|
|
344
|
+
tag: v.Type<"update-table-metadata">;
|
|
345
|
+
table: v.ObjectType<{
|
|
346
|
+
schema: v.Type<string>;
|
|
347
|
+
name: v.Type<string>;
|
|
348
|
+
}, undefined>;
|
|
349
|
+
old: v.ObjectType<{
|
|
350
|
+
rowKey: v.ObjectType<{
|
|
351
|
+
columns: v.ArrayType<v.Type<string>>;
|
|
352
|
+
type: v.Optional<"default" | "nothing" | "full" | "index">;
|
|
353
|
+
}, undefined>;
|
|
354
|
+
}, undefined>;
|
|
355
|
+
new: v.ObjectType<{
|
|
356
|
+
rowKey: v.ObjectType<{
|
|
357
|
+
columns: v.ArrayType<v.Type<string>>;
|
|
358
|
+
type: v.Optional<"default" | "nothing" | "full" | "index">;
|
|
359
|
+
}, undefined>;
|
|
360
|
+
}, undefined>;
|
|
262
361
|
}, undefined>, v.ObjectType<{
|
|
263
362
|
tag: v.Type<"add-column">;
|
|
264
363
|
table: v.ObjectType<{
|
|
@@ -277,6 +376,12 @@ export declare const dataChangeSchema: v.UnionType<[v.ObjectType<{
|
|
|
277
376
|
dflt: v.Optional<string | null>;
|
|
278
377
|
}, undefined>;
|
|
279
378
|
}, undefined>;
|
|
379
|
+
tableMetadata: v.Optional<{
|
|
380
|
+
rowKey: {
|
|
381
|
+
type?: "default" | "nothing" | "full" | "index" | undefined;
|
|
382
|
+
columns: string[];
|
|
383
|
+
};
|
|
384
|
+
}>;
|
|
280
385
|
}, undefined>, v.ObjectType<{
|
|
281
386
|
tag: v.Type<"update-column">;
|
|
282
387
|
table: v.ObjectType<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../../../../../zero-cache/src/services/change-source/protocol/current/data.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,UAAU,EAChB,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../../../../../zero-cache/src/services/change-source/protocol/current/data.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,UAAU,EAChB,MAAM,6CAA6C,CAAC;AAErD,OAAO,KAAK,CAAC,MAAM,wCAAwC,CAAC;AAE5D,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gCAAgC,CAAC;AAE9D,eAAO,MAAM,WAAW;;;aAatB,CAAC;AAEH,eAAO,MAAM,YAAY;;aAEvB,CAAC;AAEH,eAAO,MAAM,cAAc;;aAEzB,CAAC;AAcH,eAAO,MAAM,cAAc;;;;;;;;;EA2BvB,CAAC;AAOL,eAAO,MAAM,mBAAmB;;;;;aAI9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,SAAS,yFAA4B,CAAC;A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AAM,UAAU,GAAG,SAAS,CAChC,UAAU,EAAE,+CAA+C;AAC3D,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CACjC,CAAC;AAEF,MAAM,MAAM,MAAM,GACd,YAAY,GACZ,UAAU,GACV,aAAa,GACb,eAAe,CAAC;AAEpB,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsonValueSchema } from "../../../../../../shared/src/bigint-json.js";
|
|
2
|
+
import { must } from "../../../../../../shared/src/must.js";
|
|
2
3
|
import { literalUnion } from "../../../../../../shared/src/valita.js";
|
|
3
4
|
import { tableSpec, columnSpec, indexSpec } from "../../../../db/specs.js";
|
|
4
5
|
import { object, literal, array, string, record, union } from "@badrap/valita";
|
|
@@ -22,17 +23,42 @@ const commitSchema = object({
|
|
|
22
23
|
const rollbackSchema = object({
|
|
23
24
|
tag: literal("rollback")
|
|
24
25
|
});
|
|
26
|
+
const rowKeySchema = object({
|
|
27
|
+
// The columns used to identify a row in insert, update, and delete changes.
|
|
28
|
+
columns: array(string()),
|
|
29
|
+
// An optional qualifier identifying how the key is chosen. Currently this
|
|
30
|
+
// is postgres-specific, describing the REPLICA IDENTITY, for which replica
|
|
31
|
+
// identity 'full' (FULL) is handled differently; the replicator handles
|
|
32
|
+
// these tables by extracting a row key from the full row based on the
|
|
33
|
+
// table's PRIMARY KEY or UNIQUE INDEX.
|
|
34
|
+
type: literalUnion("default", "nothing", "full", "index").optional()
|
|
35
|
+
});
|
|
25
36
|
const relationSchema = object({
|
|
26
37
|
schema: string(),
|
|
27
38
|
name: string(),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// The replicator handles these tables by extracting a row key from
|
|
34
|
-
// the full row based on the table's PRIMARY KEY or UNIQUE INDEX.
|
|
39
|
+
// This will become required.
|
|
40
|
+
rowKey: rowKeySchema.optional(),
|
|
41
|
+
/** Deprecated: set the rowKey.columns instead. */
|
|
42
|
+
keyColumns: array(string()).optional(),
|
|
43
|
+
/** Deprecated: set the rowKey.columns instead. */
|
|
35
44
|
replicaIdentity: literalUnion("default", "nothing", "full", "index").optional()
|
|
45
|
+
}).map((rel) => {
|
|
46
|
+
const { rowKey, ...rest } = rel;
|
|
47
|
+
if (rowKey) {
|
|
48
|
+
return { ...rest, rowKey };
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
...rest,
|
|
52
|
+
rowKey: {
|
|
53
|
+
columns: must(rel.keyColumns),
|
|
54
|
+
type: rel.replicaIdentity
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
const tableMetadataSchema = object({
|
|
59
|
+
// The rowKey is the same object sent in the `relation` message of
|
|
60
|
+
// `insert`, `update`, and `delete` messages.
|
|
61
|
+
rowKey: rowKeySchema
|
|
36
62
|
});
|
|
37
63
|
const rowSchema = record(jsonValueSchema);
|
|
38
64
|
const insertSchema = object({
|
|
@@ -67,13 +93,24 @@ const identifierSchema = object({
|
|
|
67
93
|
});
|
|
68
94
|
const createTableSchema = object({
|
|
69
95
|
tag: literal("create-table"),
|
|
70
|
-
spec: tableSpec
|
|
96
|
+
spec: tableSpec,
|
|
97
|
+
// This must be set by change source implementations that support
|
|
98
|
+
// table/column backfill.
|
|
99
|
+
//
|
|
100
|
+
// TODO: to simplify the protocol, see if we can make this required
|
|
101
|
+
metadata: tableMetadataSchema.optional()
|
|
71
102
|
});
|
|
72
103
|
const renameTableSchema = object({
|
|
73
104
|
tag: literal("rename-table"),
|
|
74
105
|
old: identifierSchema,
|
|
75
106
|
new: identifierSchema
|
|
76
107
|
});
|
|
108
|
+
const updateTableMetadataSchema = object({
|
|
109
|
+
tag: literal("update-table-metadata"),
|
|
110
|
+
table: identifierSchema,
|
|
111
|
+
old: tableMetadataSchema,
|
|
112
|
+
new: tableMetadataSchema
|
|
113
|
+
});
|
|
77
114
|
const columnSchema = object({
|
|
78
115
|
name: string(),
|
|
79
116
|
spec: columnSpec
|
|
@@ -81,7 +118,12 @@ const columnSchema = object({
|
|
|
81
118
|
const addColumnSchema = object({
|
|
82
119
|
tag: literal("add-column"),
|
|
83
120
|
table: identifierSchema,
|
|
84
|
-
column: columnSchema
|
|
121
|
+
column: columnSchema,
|
|
122
|
+
// This must be set by change source implementations that support
|
|
123
|
+
// table/column backfill.
|
|
124
|
+
//
|
|
125
|
+
// TODO: to simplify the protocol, see if we can make this required
|
|
126
|
+
tableMetadata: tableMetadataSchema.optional()
|
|
85
127
|
});
|
|
86
128
|
const updateColumnSchema = object({
|
|
87
129
|
tag: literal("update-column"),
|
|
@@ -113,6 +155,7 @@ const dataChangeSchema = union(
|
|
|
113
155
|
truncateSchema,
|
|
114
156
|
createTableSchema,
|
|
115
157
|
renameTableSchema,
|
|
158
|
+
updateTableMetadataSchema,
|
|
116
159
|
addColumnSchema,
|
|
117
160
|
updateColumnSchema,
|
|
118
161
|
dropColumnSchema,
|
|
@@ -136,8 +179,10 @@ export {
|
|
|
136
179
|
renameTableSchema,
|
|
137
180
|
rollbackSchema,
|
|
138
181
|
rowSchema,
|
|
182
|
+
tableMetadataSchema,
|
|
139
183
|
truncateSchema,
|
|
140
184
|
updateColumnSchema,
|
|
141
|
-
updateSchema
|
|
185
|
+
updateSchema,
|
|
186
|
+
updateTableMetadataSchema
|
|
142
187
|
};
|
|
143
188
|
//# sourceMappingURL=data.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.js","sources":["../../../../../../../../zero-cache/src/services/change-source/protocol/current/data.ts"],"sourcesContent":["/**\n * Data plane messages encapsulate changes that are sent by ChangeSources,\n * forwarded / fanned out to subscribers by the ChangeStreamerService, and\n * stored in the Change DB for catchup of old subscribers.\n */\n\nimport {\n jsonValueSchema,\n type JSONObject,\n} from '../../../../../../shared/src/bigint-json.ts';\nimport * as v from '../../../../../../shared/src/valita.ts';\nimport {columnSpec, indexSpec, tableSpec} from '../../../../db/specs.ts';\nimport type {Satisfies} from '../../../../types/satisfies.ts';\n\nexport const beginSchema = v.object({\n tag: v.literal('begin'),\n // The format of values of \"json\"-typed columns (e.g. \"JSON\" and \"JSONB\").\n // - 'p' is for parsed JSON, which may include JSON values or JSON objects.\n // These values are parsed and stringified at every process boundary\n // between the change-source and the replica.\n // - 's' is for stringified JSON. These values skip the parsing and\n // stringification, and are directly ferried to the replica as a JSON\n // string. For JSON values this improves performance by 20~25% in the\n // change-streamer and 25~30% in the replicator.\n //\n // If absent, the format is assumed to be 'p' (parsed JSON objects/values).\n json: v.literalUnion('p', 's').optional(),\n});\n\nexport const commitSchema = v.object({\n tag: v.literal('commit'),\n});\n\nexport const rollbackSchema = v.object({\n tag: v.literal('rollback'),\n});\n\nexport const relationSchema = v.object({\n schema: v.string(),\n name: v.string(),\n keyColumns: v.array(v.string()),\n\n // PG-specific. When replicaIdentity is 'full':\n // * `keyColumns` contain all of the columns in the table.\n // * the `key` of the Delete and Update messages represent the full row.\n //\n // The replicator handles these tables by extracting a row key from\n // the full row based on the table's PRIMARY KEY or UNIQUE INDEX.\n replicaIdentity: v\n .literalUnion('default', 'nothing', 'full', 'index')\n .optional(),\n});\n\nexport const rowSchema = v.record(jsonValueSchema);\n\nexport const insertSchema = v.object({\n tag: v.literal('insert'),\n relation: relationSchema,\n new: rowSchema,\n});\n\nexport const updateSchema = v.object({\n tag: v.literal('update'),\n relation: relationSchema,\n // `key` is present if the update changed the key of the row, or if the\n // table's replicaIdentity === 'full'\n key: rowSchema.nullable(),\n // `new` is the full row (and not just the updated columns). This is\n // necessary for \"catchup\" replication scenarios such as adding tables\n // to a publication, or resharding.\n new: rowSchema,\n});\n\nexport const deleteSchema = v.object({\n tag: v.literal('delete'),\n relation: relationSchema,\n // key is the full row if replicaIdentity === 'full'\n key: rowSchema,\n});\n\nexport const truncateSchema = v.object({\n tag: v.literal('truncate'),\n relations: v.array(relationSchema),\n});\n\nconst identifierSchema = v.object({\n schema: v.string(),\n name: v.string(),\n});\n\nexport type Identifier = v.Infer<typeof identifierSchema>;\n\nexport const createTableSchema = v.object({\n tag: v.literal('create-table'),\n spec: tableSpec,\n});\n\nexport const renameTableSchema = v.object({\n tag: v.literal('rename-table'),\n old: identifierSchema,\n new: identifierSchema,\n});\n\nconst columnSchema = v.object({\n name: v.string(),\n spec: columnSpec,\n});\n\nexport const addColumnSchema = v.object({\n tag: v.literal('add-column'),\n table: identifierSchema,\n column: columnSchema,\n});\n\nexport const updateColumnSchema = v.object({\n tag: v.literal('update-column'),\n table: identifierSchema,\n old: columnSchema,\n new: columnSchema,\n});\n\nexport const dropColumnSchema = v.object({\n tag: v.literal('drop-column'),\n table: identifierSchema,\n column: v.string(),\n});\n\nexport const dropTableSchema = v.object({\n tag: v.literal('drop-table'),\n id: identifierSchema,\n});\n\nexport const createIndexSchema = v.object({\n tag: v.literal('create-index'),\n spec: indexSpec,\n});\n\nexport const dropIndexSchema = v.object({\n tag: v.literal('drop-index'),\n id: identifierSchema,\n});\n\nexport type MessageBegin = v.Infer<typeof beginSchema>;\nexport type MessageCommit = v.Infer<typeof commitSchema>;\nexport type MessageRollback = v.Infer<typeof rollbackSchema>;\n\nexport type MessageRelation = v.Infer<typeof relationSchema>;\nexport type MessageInsert = v.Infer<typeof insertSchema>;\nexport type MessageUpdate = v.Infer<typeof updateSchema>;\nexport type MessageDelete = v.Infer<typeof deleteSchema>;\nexport type MessageTruncate = v.Infer<typeof truncateSchema>;\n\nexport type TableCreate = v.Infer<typeof createTableSchema>;\nexport type TableRename = v.Infer<typeof renameTableSchema>;\nexport type ColumnAdd = v.Infer<typeof addColumnSchema>;\nexport type ColumnUpdate = v.Infer<typeof updateColumnSchema>;\nexport type ColumnDrop = v.Infer<typeof dropColumnSchema>;\nexport type TableDrop = v.Infer<typeof dropTableSchema>;\nexport type IndexCreate = v.Infer<typeof createIndexSchema>;\nexport type IndexDrop = v.Infer<typeof dropIndexSchema>;\n\nexport const dataChangeSchema = v.union(\n insertSchema,\n updateSchema,\n deleteSchema,\n truncateSchema,\n createTableSchema,\n renameTableSchema,\n addColumnSchema,\n updateColumnSchema,\n dropColumnSchema,\n dropTableSchema,\n createIndexSchema,\n dropIndexSchema,\n);\n\nexport type DataChange = Satisfies<\n JSONObject, // guarantees serialization over IPC or network\n v.Infer<typeof dataChangeSchema>\n>;\n\nexport type Change =\n | MessageBegin\n | DataChange\n | MessageCommit\n | MessageRollback;\n\nexport type ChangeTag = Change['tag'];\n"],"names":["v.object","v.literal","v.literalUnion","v.string","v.array","v.record","v.union"],"mappings":";;;;AAcO,MAAM,cAAcA,OAAS;AAAA,EAClC,KAAKC,QAAU,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWtB,MAAMC,aAAe,KAAK,GAAG,EAAE,SAAA;AACjC,CAAC;AAEM,MAAM,eAAeF,OAAS;AAAA,EACnC,KAAKC,QAAU,QAAQ;AACzB,CAAC;AAEM,MAAM,iBAAiBD,OAAS;AAAA,EACrC,KAAKC,QAAU,UAAU;AAC3B,CAAC;AAEM,MAAM,iBAAiBD,OAAS;AAAA,EACrC,QAAQG,OAAE;AAAA,EACV,MAAMA,OAAE;AAAA,EACR,YAAYC,MAAQD,QAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ9B,iBAAiBD,aACD,WAAW,WAAW,QAAQ,OAAO,EAClD,SAAA;AACL,CAAC;AAEM,MAAM,YAAYG,OAAS,eAAe;AAE1C,MAAM,eAAeL,OAAS;AAAA,EACnC,KAAKC,QAAU,QAAQ;AAAA,EACvB,UAAU;AAAA,EACV,KAAK;AACP,CAAC;AAEM,MAAM,eAAeD,OAAS;AAAA,EACnC,KAAKC,QAAU,QAAQ;AAAA,EACvB,UAAU;AAAA;AAAA;AAAA,EAGV,KAAK,UAAU,SAAA;AAAA;AAAA;AAAA;AAAA,EAIf,KAAK;AACP,CAAC;AAEM,MAAM,eAAeD,OAAS;AAAA,EACn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AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;"}
|
|
1
|
+
{"version":3,"file":"data.js","sources":["../../../../../../../../zero-cache/src/services/change-source/protocol/current/data.ts"],"sourcesContent":["/**\n * Data plane messages encapsulate changes that are sent by ChangeSources,\n * forwarded / fanned out to subscribers by the ChangeStreamerService, and\n * stored in the Change DB for catchup of old subscribers.\n */\n\nimport {\n jsonValueSchema,\n type JSONObject,\n} from '../../../../../../shared/src/bigint-json.ts';\nimport {must} from '../../../../../../shared/src/must.ts';\nimport * as v from '../../../../../../shared/src/valita.ts';\nimport {columnSpec, indexSpec, tableSpec} from '../../../../db/specs.ts';\nimport type {Satisfies} from '../../../../types/satisfies.ts';\n\nexport const beginSchema = v.object({\n tag: v.literal('begin'),\n // The format of values of \"json\"-typed columns (e.g. \"JSON\" and \"JSONB\").\n // - 'p' is for parsed JSON, which may include JSON values or JSON objects.\n // These values are parsed and stringified at every process boundary\n // between the change-source and the replica.\n // - 's' is for stringified JSON. These values skip the parsing and\n // stringification, and are directly ferried to the replica as a JSON\n // string. For JSON values this improves performance by 20~25% in the\n // change-streamer and 25~30% in the replicator.\n //\n // If absent, the format is assumed to be 'p' (parsed JSON objects/values).\n json: v.literalUnion('p', 's').optional(),\n});\n\nexport const commitSchema = v.object({\n tag: v.literal('commit'),\n});\n\nexport const rollbackSchema = v.object({\n tag: v.literal('rollback'),\n});\n\nconst rowKeySchema = v.object({\n // The columns used to identify a row in insert, update, and delete changes.\n columns: v.array(v.string()),\n\n // An optional qualifier identifying how the key is chosen. Currently this\n // is postgres-specific, describing the REPLICA IDENTITY, for which replica\n // identity 'full' (FULL) is handled differently; the replicator handles\n // these tables by extracting a row key from the full row based on the\n // table's PRIMARY KEY or UNIQUE INDEX.\n type: v.literalUnion('default', 'nothing', 'full', 'index').optional(),\n});\n\nexport const relationSchema = v\n .object({\n schema: v.string(),\n name: v.string(),\n\n // This will become required.\n rowKey: rowKeySchema.optional(),\n\n /** Deprecated: set the rowKey.columns instead. */\n keyColumns: v.array(v.string()).optional(),\n /** Deprecated: set the rowKey.columns instead. */\n replicaIdentity: v\n .literalUnion('default', 'nothing', 'full', 'index')\n .optional(),\n })\n .map(rel => {\n const {rowKey, ...rest} = rel;\n if (rowKey) {\n return {...rest, rowKey};\n }\n return {\n ...rest,\n rowKey: {\n columns: must(rel.keyColumns),\n type: rel.replicaIdentity,\n },\n };\n });\n\n// TableMetadata contains table-related configuration that does not affect the\n// actual data in the table, but rather how the table's change messages are\n// handled.\n//\n// Changes to the metadata are sent in an `table-update-metadata` change.\nexport const tableMetadataSchema = v.object({\n // The rowKey is the same object sent in the `relation` message of\n // `insert`, `update`, and `delete` messages.\n rowKey: rowKeySchema,\n});\n\nexport type TableMetadata = v.Infer<typeof tableMetadataSchema>;\n\nexport const rowSchema = v.record(jsonValueSchema);\n\nexport const insertSchema = v.object({\n tag: v.literal('insert'),\n relation: relationSchema,\n new: rowSchema,\n});\n\nexport const updateSchema = v.object({\n tag: v.literal('update'),\n relation: relationSchema,\n // `key` is present if the update changed the key of the row, or if the\n // table's replicaIdentity === 'full'\n key: rowSchema.nullable(),\n // `new` is the full row (and not just the updated columns). This is\n // necessary for \"catchup\" replication scenarios such as adding tables\n // to a publication, or resharding.\n new: rowSchema,\n});\n\nexport const deleteSchema = v.object({\n tag: v.literal('delete'),\n relation: relationSchema,\n // key is the full row if replicaIdentity === 'full'\n key: rowSchema,\n});\n\nexport const truncateSchema = v.object({\n tag: v.literal('truncate'),\n relations: v.array(relationSchema),\n});\n\nconst identifierSchema = v.object({\n schema: v.string(),\n name: v.string(),\n});\n\nexport type Identifier = v.Infer<typeof identifierSchema>;\n\nexport const createTableSchema = v.object({\n tag: v.literal('create-table'),\n spec: tableSpec,\n\n // This must be set by change source implementations that support\n // table/column backfill.\n //\n // TODO: to simplify the protocol, see if we can make this required\n metadata: tableMetadataSchema.optional(),\n});\n\nexport const renameTableSchema = v.object({\n tag: v.literal('rename-table'),\n old: identifierSchema,\n new: identifierSchema,\n});\n\nexport const updateTableMetadataSchema = v.object({\n tag: v.literal('update-table-metadata'),\n table: identifierSchema,\n old: tableMetadataSchema,\n new: tableMetadataSchema,\n});\n\nconst columnSchema = v.object({\n name: v.string(),\n spec: columnSpec,\n});\n\nexport const addColumnSchema = v.object({\n tag: v.literal('add-column'),\n table: identifierSchema,\n column: columnSchema,\n\n // This must be set by change source implementations that support\n // table/column backfill.\n //\n // TODO: to simplify the protocol, see if we can make this required\n tableMetadata: tableMetadataSchema.optional(),\n});\n\nexport const updateColumnSchema = v.object({\n tag: v.literal('update-column'),\n table: identifierSchema,\n old: columnSchema,\n new: columnSchema,\n});\n\nexport const dropColumnSchema = v.object({\n tag: v.literal('drop-column'),\n table: identifierSchema,\n column: v.string(),\n});\n\nexport const dropTableSchema = v.object({\n tag: v.literal('drop-table'),\n id: identifierSchema,\n});\n\nexport const createIndexSchema = v.object({\n tag: v.literal('create-index'),\n spec: indexSpec,\n});\n\nexport const dropIndexSchema = v.object({\n tag: v.literal('drop-index'),\n id: identifierSchema,\n});\n\nexport type MessageBegin = v.Infer<typeof beginSchema>;\nexport type MessageCommit = v.Infer<typeof commitSchema>;\nexport type MessageRollback = v.Infer<typeof rollbackSchema>;\n\nexport type MessageRelation = v.Infer<typeof relationSchema>;\nexport type MessageInsert = v.Infer<typeof insertSchema>;\nexport type MessageUpdate = v.Infer<typeof updateSchema>;\nexport type MessageDelete = v.Infer<typeof deleteSchema>;\nexport type MessageTruncate = v.Infer<typeof truncateSchema>;\n\nexport type TableCreate = v.Infer<typeof createTableSchema>;\nexport type TableRename = v.Infer<typeof renameTableSchema>;\nexport type TableUpdateMetadata = v.Infer<typeof updateTableMetadataSchema>;\nexport type ColumnAdd = v.Infer<typeof addColumnSchema>;\nexport type ColumnUpdate = v.Infer<typeof updateColumnSchema>;\nexport type ColumnDrop = v.Infer<typeof dropColumnSchema>;\nexport type TableDrop = v.Infer<typeof dropTableSchema>;\nexport type IndexCreate = v.Infer<typeof createIndexSchema>;\nexport type IndexDrop = v.Infer<typeof dropIndexSchema>;\n\nexport const dataChangeSchema = v.union(\n insertSchema,\n updateSchema,\n deleteSchema,\n truncateSchema,\n createTableSchema,\n renameTableSchema,\n updateTableMetadataSchema,\n addColumnSchema,\n updateColumnSchema,\n dropColumnSchema,\n dropTableSchema,\n createIndexSchema,\n dropIndexSchema,\n);\n\nexport type DataChange = Satisfies<\n JSONObject, // guarantees serialization over IPC or network\n v.Infer<typeof dataChangeSchema>\n>;\n\nexport type Change =\n | MessageBegin\n | DataChange\n | MessageCommit\n | MessageRollback;\n\nexport type ChangeTag = Change['tag'];\n"],"names":["v.object","v.literal","v.literalUnion","v.array","v.string","v.record","v.union"],"mappings":";;;;;AAeO,MAAM,cAAcA,OAAS;AAAA,EAClC,KAAKC,QAAU,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWtB,MAAMC,aAAe,KAAK,GAAG,EAAE,SAAA;AACjC,CAAC;AAEM,MAAM,eAAeF,OAAS;AAAA,EACnC,KAAKC,QAAU,QAAQ;AACzB,CAAC;AAEM,MAAM,iBAAiBD,OAAS;AAAA,EACrC,KAAKC,QAAU,UAAU;AAC3B,CAAC;AAED,MAAM,eAAeD,OAAS;AAAA;AAAA,EAE5B,SAASG,MAAQC,QAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO3B,MAAMF,aAAe,WAAW,WAAW,QAAQ,OAAO,EAAE,SAAA;AAC9D,CAAC;AAEM,MAAM,iBAAiBF,OACpB;AAAA,EACN,QAAQI,OAAE;AAAA,EACV,MAAMA,OAAE;AAAA;AAAA,EAGR,QAAQ,aAAa,SAAA;AAAA;AAAA,EAGrB,YAAYD,MAAQC,OAAE,CAAQ,EAAE,SAAA;AAAA;AAAA,EAEhC,iBAAiBF,aACD,WAAW,WAAW,QAAQ,OAAO,EAClD,SAAA;AACL,CAAC,EACA,IAAI,CAA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