@livestore/common 0.4.0-dev.9 → 0.5.0-dev.0
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/dist/.tsbuildinfo +1 -1
- package/dist/ClientSessionLeaderThreadProxy.d.ts +27 -12
- package/dist/ClientSessionLeaderThreadProxy.d.ts.map +1 -1
- package/dist/ClientSessionLeaderThreadProxy.js.map +1 -1
- package/dist/MaterializationJournal.d.ts +44 -0
- package/dist/MaterializationJournal.d.ts.map +1 -0
- package/dist/MaterializationJournal.js +112 -0
- package/dist/MaterializationJournal.js.map +1 -0
- package/dist/StateHead.d.ts +26 -0
- package/dist/StateHead.d.ts.map +1 -0
- package/dist/StateHead.js +50 -0
- package/dist/StateHead.js.map +1 -0
- package/dist/WorkerTransportError.d.ts +11 -0
- package/dist/WorkerTransportError.d.ts.map +1 -0
- package/dist/WorkerTransportError.js +11 -0
- package/dist/WorkerTransportError.js.map +1 -0
- package/dist/__tests__/fixture.d.ts +1 -1
- package/dist/__tests__/fixture.d.ts.map +1 -1
- package/dist/__tests__/fixture.js +3 -3
- package/dist/__tests__/fixture.js.map +1 -1
- package/dist/adapter-types.d.ts +59 -57
- package/dist/adapter-types.d.ts.map +1 -1
- package/dist/adapter-types.js +31 -22
- package/dist/adapter-types.js.map +1 -1
- package/dist/bounded-collections.d.ts.map +1 -1
- package/dist/bounded-collections.js +6 -4
- package/dist/bounded-collections.js.map +1 -1
- package/dist/debug-info.d.ts +56 -56
- package/dist/debug-info.d.ts.map +1 -1
- package/dist/debug-info.js +46 -32
- package/dist/debug-info.js.map +1 -1
- package/dist/defs.d.ts +9 -9
- package/dist/defs.js +2 -2
- package/dist/devtools/devtools-compatibility.test.d.ts +2 -0
- package/dist/devtools/devtools-compatibility.test.d.ts.map +1 -0
- package/dist/devtools/devtools-compatibility.test.js +16 -0
- package/dist/devtools/devtools-compatibility.test.js.map +1 -0
- package/dist/devtools/devtools-messages-client-session.d.ts +531 -312
- package/dist/devtools/devtools-messages-client-session.d.ts.map +1 -1
- package/dist/devtools/devtools-messages-client-session.js +86 -67
- package/dist/devtools/devtools-messages-client-session.js.map +1 -1
- package/dist/devtools/devtools-messages-common.d.ts +32 -35
- package/dist/devtools/devtools-messages-common.d.ts.map +1 -1
- package/dist/devtools/devtools-messages-common.js +12 -14
- package/dist/devtools/devtools-messages-common.js.map +1 -1
- package/dist/devtools/devtools-messages-leader.d.ts +417 -320
- package/dist/devtools/devtools-messages-leader.d.ts.map +1 -1
- package/dist/devtools/devtools-messages-leader.js +117 -87
- package/dist/devtools/devtools-messages-leader.js.map +1 -1
- package/dist/devtools/devtools-sessioninfo.d.ts +28 -17
- package/dist/devtools/devtools-sessioninfo.d.ts.map +1 -1
- package/dist/devtools/devtools-sessioninfo.js +12 -6
- package/dist/devtools/devtools-sessioninfo.js.map +1 -1
- package/dist/devtools/mod.d.ts +17 -7
- package/dist/devtools/mod.d.ts.map +1 -1
- package/dist/devtools/mod.js +19 -8
- package/dist/devtools/mod.js.map +1 -1
- package/dist/errors.d.ts +52 -46
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +31 -21
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/leader-thread/LeaderSyncProcessor.d.ts +116 -21
- package/dist/leader-thread/LeaderSyncProcessor.d.ts.map +1 -1
- package/dist/leader-thread/LeaderSyncProcessor.js +596 -470
- package/dist/leader-thread/LeaderSyncProcessor.js.map +1 -1
- package/dist/leader-thread/RejectedPushError.d.ts +138 -0
- package/dist/leader-thread/RejectedPushError.d.ts.map +1 -0
- package/dist/leader-thread/RejectedPushError.js +97 -0
- package/dist/leader-thread/RejectedPushError.js.map +1 -0
- package/dist/leader-thread/connection.d.ts +1 -0
- package/dist/leader-thread/connection.d.ts.map +1 -1
- package/dist/leader-thread/connection.js +10 -9
- package/dist/leader-thread/connection.js.map +1 -1
- package/dist/leader-thread/eventlog.d.ts +20 -15
- package/dist/leader-thread/eventlog.d.ts.map +1 -1
- package/dist/leader-thread/eventlog.js +80 -20
- package/dist/leader-thread/eventlog.js.map +1 -1
- package/dist/leader-thread/leader-worker-devtools.d.ts +1 -2
- package/dist/leader-thread/leader-worker-devtools.d.ts.map +1 -1
- package/dist/leader-thread/leader-worker-devtools.js +110 -62
- package/dist/leader-thread/leader-worker-devtools.js.map +1 -1
- package/dist/leader-thread/make-leader-thread-layer.d.ts +19 -7
- package/dist/leader-thread/make-leader-thread-layer.d.ts.map +1 -1
- package/dist/leader-thread/make-leader-thread-layer.js +67 -45
- package/dist/leader-thread/make-leader-thread-layer.js.map +1 -1
- package/dist/leader-thread/make-leader-thread-layer.test.d.ts +2 -0
- package/dist/leader-thread/make-leader-thread-layer.test.d.ts.map +1 -0
- package/dist/leader-thread/make-leader-thread-layer.test.js +32 -0
- package/dist/leader-thread/make-leader-thread-layer.test.js.map +1 -0
- package/dist/leader-thread/materialize-event.d.ts +3 -2
- package/dist/leader-thread/materialize-event.d.ts.map +1 -1
- package/dist/leader-thread/materialize-event.js +32 -9
- package/dist/leader-thread/materialize-event.js.map +1 -1
- package/dist/leader-thread/mod.d.ts +1 -0
- package/dist/leader-thread/mod.d.ts.map +1 -1
- package/dist/leader-thread/mod.js +1 -0
- package/dist/leader-thread/mod.js.map +1 -1
- package/dist/leader-thread/recreate-db.d.ts +2 -2
- package/dist/leader-thread/recreate-db.d.ts.map +1 -1
- package/dist/leader-thread/recreate-db.js +19 -40
- package/dist/leader-thread/recreate-db.js.map +1 -1
- package/dist/leader-thread/shutdown-channel.d.ts +3 -7
- package/dist/leader-thread/shutdown-channel.d.ts.map +1 -1
- package/dist/leader-thread/shutdown-channel.js +2 -3
- package/dist/leader-thread/shutdown-channel.js.map +1 -1
- package/dist/leader-thread/stream-events.d.ts +53 -0
- package/dist/leader-thread/stream-events.d.ts.map +1 -0
- package/dist/leader-thread/stream-events.js +164 -0
- package/dist/leader-thread/stream-events.js.map +1 -0
- package/dist/leader-thread/types.d.ts +92 -51
- package/dist/leader-thread/types.d.ts.map +1 -1
- package/dist/leader-thread/types.js +17 -4
- package/dist/leader-thread/types.js.map +1 -1
- package/dist/logging.d.ts +15 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +2 -0
- package/dist/logging.js.map +1 -0
- package/dist/make-client-session.d.ts +6 -5
- package/dist/make-client-session.d.ts.map +1 -1
- package/dist/make-client-session.js +10 -7
- package/dist/make-client-session.js.map +1 -1
- package/dist/materializer-helper.d.ts +6 -7
- package/dist/materializer-helper.d.ts.map +1 -1
- package/dist/materializer-helper.js +22 -40
- package/dist/materializer-helper.js.map +1 -1
- package/dist/otel.d.ts +4 -4
- package/dist/otel.d.ts.map +1 -1
- package/dist/otel.js +8 -8
- package/dist/otel.js.map +1 -1
- package/dist/rematerialize-from-eventlog.d.ts +3 -3
- package/dist/rematerialize-from-eventlog.d.ts.map +1 -1
- package/dist/rematerialize-from-eventlog.js +52 -39
- package/dist/rematerialize-from-eventlog.js.map +1 -1
- package/dist/schema/EventDef/define.d.ts +161 -0
- package/dist/schema/EventDef/define.d.ts.map +1 -0
- package/dist/schema/EventDef/define.js +140 -0
- package/dist/schema/EventDef/define.js.map +1 -0
- package/dist/schema/EventDef/define.test.d.ts +2 -0
- package/dist/schema/EventDef/define.test.d.ts.map +1 -0
- package/dist/schema/EventDef/define.test.js +23 -0
- package/dist/schema/EventDef/define.test.js.map +1 -0
- package/dist/schema/EventDef/deprecated.d.ts +94 -0
- package/dist/schema/EventDef/deprecated.d.ts.map +1 -0
- package/dist/schema/EventDef/deprecated.js +143 -0
- package/dist/schema/EventDef/deprecated.js.map +1 -0
- package/dist/schema/EventDef/deprecated.test.d.ts +2 -0
- package/dist/schema/EventDef/deprecated.test.d.ts.map +1 -0
- package/dist/schema/EventDef/deprecated.test.js +95 -0
- package/dist/schema/EventDef/deprecated.test.js.map +1 -0
- package/dist/schema/EventDef/event-def.d.ts +110 -0
- package/dist/schema/EventDef/event-def.d.ts.map +1 -0
- package/dist/schema/EventDef/event-def.js +2 -0
- package/dist/schema/EventDef/event-def.js.map +1 -0
- package/dist/schema/EventDef/facts.d.ts +118 -0
- package/dist/schema/EventDef/facts.d.ts.map +1 -0
- package/dist/schema/EventDef/facts.js +53 -0
- package/dist/schema/EventDef/facts.js.map +1 -0
- package/dist/schema/EventDef/materializer.d.ts +155 -0
- package/dist/schema/EventDef/materializer.d.ts.map +1 -0
- package/dist/schema/EventDef/materializer.js +83 -0
- package/dist/schema/EventDef/materializer.js.map +1 -0
- package/dist/schema/EventDef/mod.d.ts +6 -0
- package/dist/schema/EventDef/mod.d.ts.map +1 -0
- package/dist/schema/EventDef/mod.js +6 -0
- package/dist/schema/EventDef/mod.js.map +1 -0
- package/dist/schema/EventSequenceNumber/client.d.ts +136 -0
- package/dist/schema/EventSequenceNumber/client.d.ts.map +1 -0
- package/dist/schema/EventSequenceNumber/client.js +192 -0
- package/dist/schema/EventSequenceNumber/client.js.map +1 -0
- package/dist/schema/EventSequenceNumber/global.d.ts +15 -0
- package/dist/schema/EventSequenceNumber/global.d.ts.map +1 -0
- package/dist/schema/EventSequenceNumber/global.js +14 -0
- package/dist/schema/EventSequenceNumber/global.js.map +1 -0
- package/dist/schema/EventSequenceNumber/mod.d.ts +37 -0
- package/dist/schema/EventSequenceNumber/mod.d.ts.map +1 -0
- package/dist/schema/EventSequenceNumber/mod.js +37 -0
- package/dist/schema/EventSequenceNumber/mod.js.map +1 -0
- package/dist/schema/EventSequenceNumber.test.js +44 -44
- package/dist/schema/EventSequenceNumber.test.js.map +1 -1
- package/dist/schema/LiveStoreEvent/client.d.ts +168 -0
- package/dist/schema/LiveStoreEvent/client.d.ts.map +1 -0
- package/dist/schema/LiveStoreEvent/client.js +179 -0
- package/dist/schema/LiveStoreEvent/client.js.map +1 -0
- package/dist/schema/LiveStoreEvent/client.test.d.ts +2 -0
- package/dist/schema/LiveStoreEvent/client.test.d.ts.map +1 -0
- package/dist/schema/LiveStoreEvent/client.test.js +120 -0
- package/dist/schema/LiveStoreEvent/client.test.js.map +1 -0
- package/dist/schema/LiveStoreEvent/for-event-def.d.ts +52 -0
- package/dist/schema/LiveStoreEvent/for-event-def.d.ts.map +1 -0
- package/dist/schema/LiveStoreEvent/for-event-def.js +2 -0
- package/dist/schema/LiveStoreEvent/for-event-def.js.map +1 -0
- package/dist/schema/LiveStoreEvent/global.d.ts +36 -0
- package/dist/schema/LiveStoreEvent/global.d.ts.map +1 -0
- package/dist/schema/LiveStoreEvent/global.js +31 -0
- package/dist/schema/LiveStoreEvent/global.js.map +1 -0
- package/dist/schema/LiveStoreEvent/input.d.ts +46 -0
- package/dist/schema/LiveStoreEvent/input.d.ts.map +1 -0
- package/dist/schema/LiveStoreEvent/input.js +26 -0
- package/dist/schema/LiveStoreEvent/input.js.map +1 -0
- package/dist/schema/LiveStoreEvent/mod.d.ts +5 -0
- package/dist/schema/LiveStoreEvent/mod.d.ts.map +1 -0
- package/dist/schema/LiveStoreEvent/mod.js +5 -0
- package/dist/schema/LiveStoreEvent/mod.js.map +1 -0
- package/dist/schema/events.d.ts +1 -1
- package/dist/schema/events.d.ts.map +1 -1
- package/dist/schema/events.js +1 -1
- package/dist/schema/events.js.map +1 -1
- package/dist/schema/mod.d.ts +7 -4
- package/dist/schema/mod.d.ts.map +1 -1
- package/dist/schema/mod.js +6 -4
- package/dist/schema/mod.js.map +1 -1
- package/dist/schema/schema.d.ts +16 -1
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/schema/schema.js +34 -5
- package/dist/schema/schema.js.map +1 -1
- package/dist/schema/state/sqlite/client-document-def.d.ts +14 -18
- package/dist/schema/state/sqlite/client-document-def.d.ts.map +1 -1
- package/dist/schema/state/sqlite/client-document-def.js +54 -30
- package/dist/schema/state/sqlite/client-document-def.js.map +1 -1
- package/dist/schema/state/sqlite/client-document-def.test.js +146 -6
- package/dist/schema/state/sqlite/client-document-def.test.js.map +1 -1
- package/dist/schema/state/sqlite/column-annotations.d.ts +13 -13
- package/dist/schema/state/sqlite/column-annotations.d.ts.map +1 -1
- package/dist/schema/state/sqlite/column-annotations.js +13 -15
- package/dist/schema/state/sqlite/column-annotations.js.map +1 -1
- package/dist/schema/state/sqlite/column-annotations.test.js +19 -43
- package/dist/schema/state/sqlite/column-annotations.test.js.map +1 -1
- package/dist/schema/state/sqlite/column-def.d.ts +1 -1
- package/dist/schema/state/sqlite/column-def.d.ts.map +1 -1
- package/dist/schema/state/sqlite/column-def.js +132 -57
- package/dist/schema/state/sqlite/column-def.js.map +1 -1
- package/dist/schema/state/sqlite/column-def.test.js +155 -70
- package/dist/schema/state/sqlite/column-def.test.js.map +1 -1
- package/dist/schema/state/sqlite/column-spec.d.ts.map +1 -1
- package/dist/schema/state/sqlite/column-spec.js +30 -12
- package/dist/schema/state/sqlite/column-spec.js.map +1 -1
- package/dist/schema/state/sqlite/column-spec.test.js +26 -17
- package/dist/schema/state/sqlite/column-spec.test.js.map +1 -1
- package/dist/schema/state/sqlite/db-schema/ast/sqlite.d.ts +2 -2
- package/dist/schema/state/sqlite/db-schema/ast/sqlite.d.ts.map +1 -1
- package/dist/schema/state/sqlite/db-schema/ast/sqlite.js +15 -6
- package/dist/schema/state/sqlite/db-schema/ast/sqlite.js.map +1 -1
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.d.ts +25 -19
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.d.ts.map +1 -1
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.js +22 -16
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.js.map +1 -1
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.test.js +28 -17
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.test.js.map +1 -1
- package/dist/schema/state/sqlite/db-schema/dsl/mod.d.ts +14 -12
- package/dist/schema/state/sqlite/db-schema/dsl/mod.d.ts.map +1 -1
- package/dist/schema/state/sqlite/db-schema/dsl/mod.js +6 -4
- package/dist/schema/state/sqlite/db-schema/dsl/mod.js.map +1 -1
- package/dist/schema/state/sqlite/mod.d.ts +3 -5
- package/dist/schema/state/sqlite/mod.d.ts.map +1 -1
- package/dist/schema/state/sqlite/mod.js +6 -8
- package/dist/schema/state/sqlite/mod.js.map +1 -1
- package/dist/schema/state/sqlite/persistence.d.ts +11 -0
- package/dist/schema/state/sqlite/persistence.d.ts.map +1 -0
- package/dist/schema/state/sqlite/persistence.js +10 -0
- package/dist/schema/state/sqlite/persistence.js.map +1 -0
- package/dist/schema/state/sqlite/query-builder/api.d.ts +58 -29
- package/dist/schema/state/sqlite/query-builder/api.d.ts.map +1 -1
- package/dist/schema/state/sqlite/query-builder/astToSql.d.ts.map +1 -1
- package/dist/schema/state/sqlite/query-builder/astToSql.js +105 -24
- package/dist/schema/state/sqlite/query-builder/astToSql.js.map +1 -1
- package/dist/schema/state/sqlite/query-builder/impl.d.ts +4 -2
- package/dist/schema/state/sqlite/query-builder/impl.d.ts.map +1 -1
- package/dist/schema/state/sqlite/query-builder/impl.js +42 -27
- package/dist/schema/state/sqlite/query-builder/impl.js.map +1 -1
- package/dist/schema/state/sqlite/query-builder/impl.test.js +402 -498
- package/dist/schema/state/sqlite/query-builder/impl.test.js.map +1 -1
- package/dist/schema/state/sqlite/schema-helpers.d.ts +2 -2
- package/dist/schema/state/sqlite/schema-helpers.d.ts.map +1 -1
- package/dist/schema/state/sqlite/schema-helpers.js +24 -14
- package/dist/schema/state/sqlite/schema-helpers.js.map +1 -1
- package/dist/schema/state/sqlite/schema-helpers.test.d.ts +2 -0
- package/dist/schema/state/sqlite/schema-helpers.test.d.ts.map +1 -0
- package/dist/schema/state/sqlite/schema-helpers.test.js +36 -0
- package/dist/schema/state/sqlite/schema-helpers.test.js.map +1 -0
- package/dist/schema/state/sqlite/system-tables/eventlog-tables.d.ts +515 -0
- package/dist/schema/state/sqlite/system-tables/eventlog-tables.d.ts.map +1 -0
- package/dist/schema/state/sqlite/system-tables/eventlog-tables.js +54 -0
- package/dist/schema/state/sqlite/system-tables/eventlog-tables.js.map +1 -0
- package/dist/schema/state/sqlite/system-tables/mod.d.ts +3 -0
- package/dist/schema/state/sqlite/system-tables/mod.d.ts.map +1 -0
- package/dist/schema/state/sqlite/system-tables/mod.js +3 -0
- package/dist/schema/state/sqlite/system-tables/mod.js.map +1 -0
- package/dist/schema/state/sqlite/system-tables/state-tables.d.ts +678 -0
- package/dist/schema/state/sqlite/system-tables/state-tables.d.ts.map +1 -0
- package/dist/schema/state/sqlite/system-tables/state-tables.js +87 -0
- package/dist/schema/state/sqlite/system-tables/state-tables.js.map +1 -0
- package/dist/schema/state/sqlite/table-def.d.ts +19 -20
- package/dist/schema/state/sqlite/table-def.d.ts.map +1 -1
- package/dist/schema/state/sqlite/table-def.js +54 -4
- package/dist/schema/state/sqlite/table-def.js.map +1 -1
- package/dist/schema/state/sqlite/table-def.test.js +226 -20
- package/dist/schema/state/sqlite/table-def.test.js.map +1 -1
- package/dist/schema/unknown-events.d.ts +47 -0
- package/dist/schema/unknown-events.d.ts.map +1 -0
- package/dist/schema/unknown-events.js +70 -0
- package/dist/schema/unknown-events.js.map +1 -0
- package/dist/schema-management/__tests__/migrations-autoincrement-quoting.test.d.ts +2 -0
- package/dist/schema-management/__tests__/migrations-autoincrement-quoting.test.d.ts.map +1 -0
- package/dist/schema-management/__tests__/migrations-autoincrement-quoting.test.js +73 -0
- package/dist/schema-management/__tests__/migrations-autoincrement-quoting.test.js.map +1 -0
- package/dist/schema-management/common.js +2 -2
- package/dist/schema-management/common.js.map +1 -1
- package/dist/schema-management/migrations.d.ts +32 -2
- package/dist/schema-management/migrations.d.ts.map +1 -1
- package/dist/schema-management/migrations.js +38 -6
- package/dist/schema-management/migrations.js.map +1 -1
- package/dist/schema-management/validate-schema.d.ts +3 -3
- package/dist/schema-management/validate-schema.d.ts.map +1 -1
- package/dist/schema-management/validate-schema.js +2 -2
- package/dist/schema-management/validate-schema.js.map +1 -1
- package/dist/session-id-symbol.d.ts +29 -0
- package/dist/session-id-symbol.d.ts.map +1 -0
- package/dist/session-id-symbol.js +44 -0
- package/dist/session-id-symbol.js.map +1 -0
- package/dist/sql-queries/sql-queries.d.ts.map +1 -1
- package/dist/sql-queries/sql-queries.js +26 -16
- package/dist/sql-queries/sql-queries.js.map +1 -1
- package/dist/sql-queries/sql-query-builder.d.ts.map +1 -1
- package/dist/sql-queries/sql-query-builder.js.map +1 -1
- package/dist/sql-queries/types.d.ts +6 -7
- package/dist/sql-queries/types.d.ts.map +1 -1
- package/dist/sql-queries/types.js.map +1 -1
- package/dist/sqlite-db-helper.d.ts +21 -1
- package/dist/sqlite-db-helper.d.ts.map +1 -1
- package/dist/sqlite-db-helper.js +40 -5
- package/dist/sqlite-db-helper.js.map +1 -1
- package/dist/sqlite-types.d.ts +8 -11
- package/dist/sqlite-types.d.ts.map +1 -1
- package/dist/sqlite-types.js +3 -3
- package/dist/sqlite-types.js.map +1 -1
- package/dist/sync/ClientSessionSyncProcessor.d.ts +47 -25
- package/dist/sync/ClientSessionSyncProcessor.d.ts.map +1 -1
- package/dist/sync/ClientSessionSyncProcessor.js +269 -154
- package/dist/sync/ClientSessionSyncProcessor.js.map +1 -1
- package/dist/sync/errors.d.ts +12 -51
- package/dist/sync/errors.d.ts.map +1 -1
- package/dist/sync/errors.js +7 -24
- package/dist/sync/errors.js.map +1 -1
- package/dist/sync/index.d.ts +2 -0
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +2 -0
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/mock-sync-backend.d.ts +11 -10
- package/dist/sync/mock-sync-backend.d.ts.map +1 -1
- package/dist/sync/mock-sync-backend.js +97 -74
- package/dist/sync/mock-sync-backend.js.map +1 -1
- package/dist/sync/mock-sync-backend.test.d.ts +2 -0
- package/dist/sync/mock-sync-backend.test.d.ts.map +1 -0
- package/dist/sync/mock-sync-backend.test.js +49 -0
- package/dist/sync/mock-sync-backend.test.js.map +1 -0
- package/dist/sync/next/compact-events.d.ts.map +1 -1
- package/dist/sync/next/compact-events.js +11 -12
- package/dist/sync/next/compact-events.js.map +1 -1
- package/dist/sync/next/facts.d.ts +5 -5
- package/dist/sync/next/facts.d.ts.map +1 -1
- package/dist/sync/next/facts.js +7 -8
- package/dist/sync/next/facts.js.map +1 -1
- package/dist/sync/next/history-dag-common.d.ts +58 -15
- package/dist/sync/next/history-dag-common.d.ts.map +1 -1
- package/dist/sync/next/history-dag-common.js +219 -9
- package/dist/sync/next/history-dag-common.js.map +1 -1
- package/dist/sync/next/history-dag.d.ts.map +1 -1
- package/dist/sync/next/history-dag.js +12 -11
- package/dist/sync/next/history-dag.js.map +1 -1
- package/dist/sync/next/rebase-events.d.ts +5 -5
- package/dist/sync/next/rebase-events.d.ts.map +1 -1
- package/dist/sync/next/rebase-events.js +6 -6
- package/dist/sync/next/rebase-events.js.map +1 -1
- package/dist/sync/next/test/compact-events.calculator.test.js +4 -4
- package/dist/sync/next/test/compact-events.calculator.test.js.map +1 -1
- package/dist/sync/next/test/compact-events.test.d.ts.map +1 -1
- package/dist/sync/next/test/compact-events.test.js +2 -2
- package/dist/sync/next/test/compact-events.test.js.map +1 -1
- package/dist/sync/next/test/event-fixtures.d.ts +9 -9
- package/dist/sync/next/test/event-fixtures.d.ts.map +1 -1
- package/dist/sync/next/test/event-fixtures.js +12 -12
- package/dist/sync/next/test/event-fixtures.js.map +1 -1
- package/dist/sync/next/test/history-dag-common.test.d.ts +2 -0
- package/dist/sync/next/test/history-dag-common.test.d.ts.map +1 -0
- package/dist/sync/next/test/history-dag-common.test.js +73 -0
- package/dist/sync/next/test/history-dag-common.test.js.map +1 -0
- package/dist/sync/sync-backend-kv.d.ts +3 -3
- package/dist/sync/sync-backend-kv.d.ts.map +1 -1
- package/dist/sync/sync-backend-kv.js +6 -4
- package/dist/sync/sync-backend-kv.js.map +1 -1
- package/dist/sync/sync-backend.d.ts +41 -21
- package/dist/sync/sync-backend.d.ts.map +1 -1
- package/dist/sync/sync-backend.js +45 -4
- package/dist/sync/sync-backend.js.map +1 -1
- package/dist/sync/sync.d.ts +23 -2
- package/dist/sync/sync.d.ts.map +1 -1
- package/dist/sync/syncstate.d.ts +115 -191
- package/dist/sync/syncstate.d.ts.map +1 -1
- package/dist/sync/syncstate.js +108 -129
- package/dist/sync/syncstate.js.map +1 -1
- package/dist/sync/syncstate.test.js +289 -161
- package/dist/sync/syncstate.test.js.map +1 -1
- package/dist/sync/transport-chunking.d.ts +35 -0
- package/dist/sync/transport-chunking.d.ts.map +1 -0
- package/dist/sync/transport-chunking.js +47 -0
- package/dist/sync/transport-chunking.js.map +1 -0
- package/dist/sync/validate-push-payload.d.ts +2 -2
- package/dist/sync/validate-push-payload.d.ts.map +1 -1
- package/dist/sync/validate-push-payload.js +4 -6
- package/dist/sync/validate-push-payload.js.map +1 -1
- package/dist/testing/event-factory.d.ts +3 -3
- package/dist/testing/event-factory.d.ts.map +1 -1
- package/dist/testing/event-factory.js +5 -7
- package/dist/testing/event-factory.js.map +1 -1
- package/dist/util.d.ts +11 -4
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +21 -4
- package/dist/util.js.map +1 -1
- package/dist/version.d.ts +24 -5
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +25 -8
- package/dist/version.js.map +1 -1
- package/package.json +50 -16
- package/src/ClientSessionLeaderThreadProxy.ts +27 -12
- package/src/MaterializationJournal.ts +184 -0
- package/src/StateHead.ts +80 -0
- package/src/WorkerTransportError.ts +12 -0
- package/src/__tests__/fixture.ts +3 -3
- package/src/adapter-types.ts +62 -56
- package/src/bounded-collections.ts +6 -5
- package/src/debug-info.ts +54 -43
- package/src/defs.ts +2 -2
- package/src/devtools/devtools-compatibility.test.ts +19 -0
- package/src/devtools/devtools-messages-client-session.ts +72 -63
- package/src/devtools/devtools-messages-common.ts +18 -22
- package/src/devtools/devtools-messages-leader.ts +89 -68
- package/src/devtools/devtools-sessioninfo.ts +17 -12
- package/src/devtools/mod.ts +15 -7
- package/src/errors.ts +58 -38
- package/src/index.ts +11 -1
- package/src/leader-thread/LeaderSyncProcessor.ts +927 -674
- package/src/leader-thread/RejectedPushError.ts +119 -0
- package/src/leader-thread/connection.ts +13 -9
- package/src/leader-thread/eventlog.ts +114 -41
- package/src/leader-thread/leader-worker-devtools.ts +223 -124
- package/src/leader-thread/make-leader-thread-layer.test.ts +44 -0
- package/src/leader-thread/make-leader-thread-layer.ts +170 -82
- package/src/leader-thread/materialize-event.ts +51 -16
- package/src/leader-thread/mod.ts +1 -0
- package/src/leader-thread/recreate-db.ts +26 -61
- package/src/leader-thread/shutdown-channel.ts +3 -18
- package/src/leader-thread/stream-events.ts +209 -0
- package/src/leader-thread/types.ts +77 -65
- package/src/logging.ts +15 -0
- package/src/make-client-session.ts +16 -10
- package/src/materializer-helper.ts +31 -49
- package/src/otel.ts +15 -13
- package/src/rematerialize-from-eventlog.ts +106 -93
- package/src/schema/EventDef/define.test.ts +28 -0
- package/src/schema/EventDef/define.ts +218 -0
- package/src/schema/EventDef/deprecated.test.ts +122 -0
- package/src/schema/EventDef/deprecated.ts +172 -0
- package/src/schema/EventDef/event-def.ts +123 -0
- package/src/schema/EventDef/facts.ts +135 -0
- package/src/schema/EventDef/materializer.ts +172 -0
- package/src/schema/EventDef/mod.ts +5 -0
- package/src/schema/EventSequenceNumber/client.ts +256 -0
- package/src/schema/EventSequenceNumber/global.ts +19 -0
- package/src/schema/EventSequenceNumber/mod.ts +37 -0
- package/src/schema/EventSequenceNumber.test.ts +72 -53
- package/src/schema/LiveStoreEvent/client.test.ts +142 -0
- package/src/schema/LiveStoreEvent/client.ts +236 -0
- package/src/schema/LiveStoreEvent/for-event-def.ts +60 -0
- package/src/schema/LiveStoreEvent/global.ts +45 -0
- package/src/schema/LiveStoreEvent/input.ts +63 -0
- package/src/schema/LiveStoreEvent/mod.ts +4 -0
- package/src/schema/events.ts +1 -1
- package/src/schema/mod.ts +7 -4
- package/src/schema/schema.ts +48 -6
- package/src/schema/state/sqlite/client-document-def.test.ts +172 -14
- package/src/schema/state/sqlite/client-document-def.ts +126 -98
- package/src/schema/state/sqlite/column-annotations.test.ts +27 -45
- package/src/schema/state/sqlite/column-annotations.ts +27 -30
- package/src/schema/state/sqlite/column-def.test.ts +186 -77
- package/src/schema/state/sqlite/column-def.ts +169 -62
- package/src/schema/state/sqlite/column-spec.test.ts +34 -19
- package/src/schema/state/sqlite/column-spec.ts +38 -11
- package/src/schema/state/sqlite/db-schema/ast/sqlite.ts +17 -7
- package/src/schema/state/sqlite/db-schema/dsl/__snapshots__/field-defs.test.ts.snap +123 -63
- package/src/schema/state/sqlite/db-schema/dsl/field-defs.test.ts +37 -17
- package/src/schema/state/sqlite/db-schema/dsl/field-defs.ts +65 -45
- package/src/schema/state/sqlite/db-schema/dsl/mod.ts +48 -40
- package/src/schema/state/sqlite/mod.ts +9 -12
- package/src/schema/state/sqlite/persistence.ts +11 -0
- package/src/schema/state/sqlite/query-builder/api.ts +61 -23
- package/src/schema/state/sqlite/query-builder/astToSql.ts +117 -23
- package/src/schema/state/sqlite/query-builder/impl.test.ts +489 -551
- package/src/schema/state/sqlite/query-builder/impl.ts +43 -26
- package/src/schema/state/sqlite/schema-helpers.test.ts +44 -0
- package/src/schema/state/sqlite/schema-helpers.ts +30 -22
- package/src/schema/state/sqlite/system-tables/eventlog-tables.ts +64 -0
- package/src/schema/state/sqlite/system-tables/mod.ts +2 -0
- package/src/schema/state/sqlite/system-tables/state-tables.ts +109 -0
- package/src/schema/state/sqlite/table-def.test.ts +295 -46
- package/src/schema/state/sqlite/table-def.ts +109 -64
- package/src/schema/unknown-events.ts +132 -0
- package/src/schema-management/__tests__/migrations-autoincrement-quoting.test.ts +88 -0
- package/src/schema-management/common.ts +2 -2
- package/src/schema-management/migrations.ts +42 -9
- package/src/schema-management/validate-schema.ts +3 -3
- package/src/session-id-symbol.ts +59 -0
- package/src/sql-queries/sql-queries.ts +26 -18
- package/src/sql-queries/sql-query-builder.ts +1 -0
- package/src/sql-queries/types.ts +6 -7
- package/src/sqlite-db-helper.ts +67 -5
- package/src/sqlite-types.ts +9 -11
- package/src/sync/ClientSessionSyncProcessor.ts +388 -194
- package/src/sync/errors.ts +18 -28
- package/src/sync/index.ts +2 -0
- package/src/sync/mock-sync-backend.test.ts +78 -0
- package/src/sync/mock-sync-backend.ts +196 -108
- package/src/sync/next/compact-events.ts +10 -11
- package/src/sync/next/facts.ts +13 -14
- package/src/sync/next/history-dag-common.ts +306 -26
- package/src/sync/next/history-dag.ts +20 -13
- package/src/sync/next/rebase-events.ts +12 -12
- package/src/sync/next/test/compact-events.calculator.test.ts +5 -4
- package/src/sync/next/test/compact-events.test.ts +4 -3
- package/src/sync/next/test/event-fixtures.ts +14 -14
- package/src/sync/next/test/history-dag-common.test.ts +87 -0
- package/src/sync/sync-backend-kv.ts +7 -4
- package/src/sync/sync-backend.ts +75 -26
- package/src/sync/sync.ts +24 -2
- package/src/sync/syncstate.test.ts +657 -442
- package/src/sync/syncstate.ts +175 -160
- package/src/sync/transport-chunking.ts +85 -0
- package/src/sync/validate-push-payload.ts +6 -8
- package/src/testing/event-factory.ts +10 -12
- package/src/util.ts +20 -11
- package/src/version.ts +32 -8
- package/dist/schema/EventDef.d.ts +0 -126
- package/dist/schema/EventDef.d.ts.map +0 -1
- package/dist/schema/EventDef.js +0 -46
- package/dist/schema/EventDef.js.map +0 -1
- package/dist/schema/EventSequenceNumber.d.ts +0 -80
- package/dist/schema/EventSequenceNumber.d.ts.map +0 -1
- package/dist/schema/EventSequenceNumber.js +0 -139
- package/dist/schema/EventSequenceNumber.js.map +0 -1
- package/dist/schema/LiveStoreEvent.d.ts +0 -306
- package/dist/schema/LiveStoreEvent.d.ts.map +0 -1
- package/dist/schema/LiveStoreEvent.js +0 -147
- package/dist/schema/LiveStoreEvent.js.map +0 -1
- package/dist/schema/state/sqlite/system-tables.d.ts +0 -976
- package/dist/schema/state/sqlite/system-tables.d.ts.map +0 -1
- package/dist/schema/state/sqlite/system-tables.js +0 -81
- package/dist/schema/state/sqlite/system-tables.js.map +0 -1
- package/dist/sql-queries/misc.d.ts +0 -2
- package/dist/sql-queries/misc.d.ts.map +0 -1
- package/dist/sql-queries/misc.js +0 -2
- package/dist/sql-queries/misc.js.map +0 -1
- package/dist/sync/next/graphology.d.ts +0 -8
- package/dist/sync/next/graphology.d.ts.map +0 -1
- package/dist/sync/next/graphology.js +0 -30
- package/dist/sync/next/graphology.js.map +0 -1
- package/dist/sync/next/graphology_.d.ts +0 -3
- package/dist/sync/next/graphology_.d.ts.map +0 -1
- package/dist/sync/next/graphology_.js +0 -3
- package/dist/sync/next/graphology_.js.map +0 -1
- package/src/schema/EventDef.ts +0 -222
- package/src/schema/EventSequenceNumber.ts +0 -199
- package/src/schema/LiveStoreEvent.ts +0 -286
- package/src/schema/state/sqlite/system-tables.ts +0 -106
- package/src/sql-queries/misc.ts +0 -2
- package/src/sync/next/ambient.d.ts +0 -3
- package/src/sync/next/graphology.ts +0 -41
- package/src/sync/next/graphology_.ts +0 -2
|
@@ -12,27 +12,28 @@ import { SqliteDsl } from './db-schema/mod.ts'
|
|
|
12
12
|
* Fields with both null and undefined will emit a warning as this is a lossy conversion.
|
|
13
13
|
*/
|
|
14
14
|
export const getColumnDefForSchema = (
|
|
15
|
-
schema: Schema.
|
|
15
|
+
schema: Schema.Top,
|
|
16
16
|
propertySignature?: SchemaAST.PropertySignature,
|
|
17
17
|
forceNullable = false,
|
|
18
18
|
): SqliteDsl.ColumnDefinition.Any => {
|
|
19
19
|
const ast = schema.ast
|
|
20
20
|
|
|
21
21
|
// Extract annotations
|
|
22
|
-
const getAnnotation = <T>(annotationId:
|
|
23
|
-
propertySignature
|
|
22
|
+
const getAnnotation = <T>(annotationId: string): Option.Option<T> =>
|
|
23
|
+
propertySignature !== undefined
|
|
24
24
|
? hasPropertyAnnotation<T>(propertySignature, annotationId)
|
|
25
|
-
: SchemaAST.
|
|
25
|
+
: Option.fromUndefinedOr(SchemaAST.resolveAt<T>(annotationId)(ast))
|
|
26
26
|
|
|
27
|
-
const columnType = SchemaAST.
|
|
27
|
+
const columnType = Option.fromUndefinedOr(SchemaAST.resolveAt<SqliteDsl.FieldColumnType>(ColumnType)(ast))
|
|
28
28
|
|
|
29
29
|
// Check if schema has null (e.g., Schema.NullOr) or undefined or if it's forced nullable (optional field)
|
|
30
|
-
const isNullable = forceNullable || hasNull(ast) || hasUndefined(ast)
|
|
30
|
+
const isNullable = forceNullable === true || hasNull(ast) === true || hasUndefined(ast) === true
|
|
31
31
|
|
|
32
32
|
// Get base column definition with nullable flag
|
|
33
|
-
const baseColumn =
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const baseColumn =
|
|
34
|
+
Option.isSome(columnType) === true
|
|
35
|
+
? getColumnForType(columnType.value, isNullable)
|
|
36
|
+
: getColumnForSchema(schema, isNullable)
|
|
36
37
|
|
|
37
38
|
// Apply annotations
|
|
38
39
|
const primaryKey = getAnnotation<boolean>(PrimaryKeyId).pipe(Option.getOrElse(() => false))
|
|
@@ -41,21 +42,21 @@ export const getColumnDefForSchema = (
|
|
|
41
42
|
|
|
42
43
|
return {
|
|
43
44
|
...baseColumn,
|
|
44
|
-
...(primaryKey
|
|
45
|
-
...(autoIncrement
|
|
46
|
-
...(Option.isSome(defaultValue)
|
|
45
|
+
...(primaryKey === true ? { primaryKey: true } : {}),
|
|
46
|
+
...(autoIncrement === true ? { autoIncrement: true } : {}),
|
|
47
|
+
...(Option.isSome(defaultValue) === true ? { default: Option.some(defaultValue.value) } : {}),
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
const hasPropertyAnnotation = <T>(
|
|
51
52
|
propertySignature: SchemaAST.PropertySignature,
|
|
52
|
-
annotationId:
|
|
53
|
+
annotationId: string,
|
|
53
54
|
): Option.Option<T> => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
const keyAnnotation = propertySignature.type.context?.annotations?.[annotationId] as T | undefined
|
|
56
|
+
if (keyAnnotation !== undefined) {
|
|
57
|
+
return Option.some(keyAnnotation)
|
|
57
58
|
}
|
|
58
|
-
return SchemaAST.
|
|
59
|
+
return Option.fromUndefinedOr(SchemaAST.resolveAt<T>(annotationId)(propertySignature.type))
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
/**
|
|
@@ -71,18 +72,19 @@ export const schemaFieldsToColumns = (
|
|
|
71
72
|
for (const prop of propertySignatures) {
|
|
72
73
|
if (typeof prop.name !== 'string') continue
|
|
73
74
|
|
|
74
|
-
const
|
|
75
|
+
const isOptional = SchemaAST.isOptional(prop.type)
|
|
76
|
+
const fieldSchema = Schema.make<Schema.Top>(prop.type)
|
|
75
77
|
|
|
76
78
|
// Warn about lossy conversion for fields with both null and undefined
|
|
77
|
-
if (
|
|
79
|
+
if (isOptional === true) {
|
|
78
80
|
const { hasNull, hasUndefined } = checkNullUndefined(fieldSchema.ast)
|
|
79
|
-
if (hasNull && hasUndefined) {
|
|
81
|
+
if (hasNull === true && hasUndefined === true) {
|
|
80
82
|
console.warn(`Field '${prop.name}' has both null and undefined - treating | undefined as | null`)
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
// Get column definition - pass nullable flag for optional fields
|
|
85
|
-
const columnDef = getColumnDefForSchema(fieldSchema, prop,
|
|
87
|
+
const columnDef = getColumnDefForSchema(fieldSchema, prop, isOptional === true)
|
|
86
88
|
|
|
87
89
|
// Check for primary key and unique annotations
|
|
88
90
|
const hasPrimaryKey = hasPropertyAnnotation<boolean>(prop, PrimaryKeyId).pipe(Option.getOrElse(() => false))
|
|
@@ -91,16 +93,16 @@ export const schemaFieldsToColumns = (
|
|
|
91
93
|
// Build final column
|
|
92
94
|
columns[prop.name] = {
|
|
93
95
|
...columnDef,
|
|
94
|
-
...(hasPrimaryKey
|
|
96
|
+
...(hasPrimaryKey === true ? { primaryKey: true } : {}),
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
// Validate primary key + nullable
|
|
98
100
|
const column = columns[prop.name]
|
|
99
|
-
if (column?.primaryKey && column.nullable) {
|
|
101
|
+
if (column?.primaryKey === true && column.nullable === true) {
|
|
100
102
|
throw new Error('Primary key columns cannot be nullable')
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
if (hasUnique) uniqueColumns.push(prop.name)
|
|
105
|
+
if (hasUnique === true) uniqueColumns.push(prop.name)
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
return { columns, uniqueColumns }
|
|
@@ -111,9 +113,9 @@ const checkNullUndefined = (ast: SchemaAST.AST): { hasNull: boolean; hasUndefine
|
|
|
111
113
|
let hasUndefined = false
|
|
112
114
|
|
|
113
115
|
const visit = (type: SchemaAST.AST): void => {
|
|
114
|
-
if (SchemaAST.
|
|
115
|
-
else if (SchemaAST.
|
|
116
|
-
else if (SchemaAST.isUnion(type)) type.types.forEach(visit)
|
|
116
|
+
if (SchemaAST.isUndefined(type) === true) hasUndefined = true
|
|
117
|
+
else if (SchemaAST.isNull(type) === true) hasNull = true
|
|
118
|
+
else if (SchemaAST.isUnion(type) === true) type.types.forEach(visit)
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
visit(ast)
|
|
@@ -121,16 +123,16 @@ const checkNullUndefined = (ast: SchemaAST.AST): { hasNull: boolean; hasUndefine
|
|
|
121
123
|
}
|
|
122
124
|
|
|
123
125
|
const hasNull = (ast: SchemaAST.AST): boolean => {
|
|
124
|
-
if (SchemaAST.
|
|
125
|
-
if (SchemaAST.isUnion(ast)) {
|
|
126
|
+
if (SchemaAST.isNull(ast) === true) return true
|
|
127
|
+
if (SchemaAST.isUnion(ast) === true) {
|
|
126
128
|
return ast.types.some((type) => hasNull(type))
|
|
127
129
|
}
|
|
128
130
|
return false
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
const hasUndefined = (ast: SchemaAST.AST): boolean => {
|
|
132
|
-
if (SchemaAST.
|
|
133
|
-
if (SchemaAST.isUnion(ast)) {
|
|
134
|
+
if (SchemaAST.isUndefined(ast) === true) return true
|
|
135
|
+
if (SchemaAST.isUnion(ast) === true) {
|
|
134
136
|
return ast.types.some((type) => hasUndefined(type))
|
|
135
137
|
}
|
|
136
138
|
return false
|
|
@@ -151,65 +153,170 @@ const getColumnForType = (columnType: string, nullable = false): SqliteDsl.Colum
|
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
|
|
154
|
-
const getColumnForSchema = (schema: Schema.
|
|
156
|
+
const getColumnForSchema = (schema: Schema.Top, nullable = false): SqliteDsl.ColumnDefinition.Any => {
|
|
155
157
|
const ast = schema.ast
|
|
156
158
|
// Strip nullable wrapper to get core type
|
|
157
159
|
const coreAst = stripNullable(ast)
|
|
158
|
-
const coreSchema = stripNullable(ast) === ast ? schema : Schema.make(coreAst)
|
|
160
|
+
const coreSchema = (stripNullable(ast) === ast ? schema : Schema.make(coreAst)) as Schema.Codec<any, any>
|
|
159
161
|
|
|
160
162
|
// Special case: Boolean is transformed to integer in SQLite
|
|
161
|
-
if (SchemaAST.
|
|
163
|
+
if (SchemaAST.isBoolean(coreAst) === true) {
|
|
162
164
|
return SqliteDsl.boolean({ nullable })
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
// Get the encoded AST - what actually gets stored in SQLite
|
|
166
|
-
const encodedAst = Schema.
|
|
168
|
+
const encodedAst = Schema.toEncoded(coreSchema).ast
|
|
167
169
|
|
|
168
170
|
// Check if the encoded type matches SQLite native types
|
|
169
|
-
if (SchemaAST.
|
|
171
|
+
if (SchemaAST.isString(encodedAst) === true) {
|
|
170
172
|
return SqliteDsl.text({ schema: coreSchema, nullable })
|
|
171
173
|
}
|
|
172
174
|
|
|
173
|
-
if (SchemaAST.
|
|
174
|
-
|
|
175
|
-
const id = SchemaAST.getIdentifierAnnotation(coreAst).pipe(Option.getOrElse(() => ''))
|
|
176
|
-
if (id === 'Int' || id === 'DateFromNumber') {
|
|
175
|
+
if (SchemaAST.isNumber(encodedAst) === true) {
|
|
176
|
+
if (hasCheck(coreAst.checks, 'effect/schema/isInt') === true || hasDateRepresentation(coreAst) === true) {
|
|
177
177
|
return SqliteDsl.integer({ schema: coreSchema, nullable })
|
|
178
178
|
}
|
|
179
179
|
return SqliteDsl.real({ schema: coreSchema, nullable })
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const value = coreAst.literal
|
|
185
|
-
if (typeof value === 'boolean') return SqliteDsl.boolean({ nullable })
|
|
182
|
+
if (isUint8ArraySchema(coreAst) === true || isUint8ArraySchema(encodedAst) === true) {
|
|
183
|
+
return SqliteDsl.blob({ schema: coreSchema, nullable })
|
|
186
184
|
}
|
|
187
185
|
|
|
188
|
-
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const id = SchemaAST.getIdentifierAnnotation(coreAst).pipe(Option.getOrElse(() => ''))
|
|
195
|
-
if (id === 'Int') {
|
|
196
|
-
return SqliteDsl.integer({ schema: coreSchema, nullable })
|
|
197
|
-
}
|
|
198
|
-
return SqliteDsl.real({ schema: coreSchema, nullable })
|
|
199
|
-
}
|
|
200
|
-
}
|
|
186
|
+
const literalColumn = getLiteralColumnDefinition(encodedAst, coreSchema, nullable, coreAst)
|
|
187
|
+
if (literalColumn !== null) return literalColumn
|
|
188
|
+
|
|
189
|
+
// Fallback to checking the original AST in case the encoded schema differs
|
|
190
|
+
const coreLiteralColumn = getLiteralColumnDefinition(coreAst, coreSchema, nullable, coreAst)
|
|
191
|
+
if (coreLiteralColumn !== null) return coreLiteralColumn
|
|
201
192
|
|
|
202
193
|
// Everything else needs JSON encoding
|
|
203
194
|
return SqliteDsl.json({ schema: coreSchema, nullable })
|
|
204
195
|
}
|
|
205
196
|
|
|
206
197
|
const stripNullable = (ast: SchemaAST.AST): SchemaAST.AST => {
|
|
207
|
-
if (
|
|
198
|
+
if (SchemaAST.isUnion(ast) === false) return ast
|
|
208
199
|
|
|
209
|
-
//
|
|
210
|
-
const
|
|
211
|
-
(type) =>
|
|
200
|
+
// Filter out null/undefined members while preserving any annotations on the union
|
|
201
|
+
const coreTypes = ast.types.filter(
|
|
202
|
+
(type) => SchemaAST.isNull(type) === false && SchemaAST.isUndefined(type) === false,
|
|
212
203
|
)
|
|
213
204
|
|
|
214
|
-
|
|
205
|
+
if (coreTypes.length === 0 || coreTypes.length === ast.types.length) {
|
|
206
|
+
return ast
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (coreTypes.length === 1) {
|
|
210
|
+
return coreTypes[0]!
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return new SchemaAST.Union(coreTypes, ast.mode, ast.annotations)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const getLiteralColumnDefinition = (
|
|
217
|
+
ast: SchemaAST.AST,
|
|
218
|
+
schema: Schema.Codec<any, any>,
|
|
219
|
+
nullable: boolean,
|
|
220
|
+
sourceAst: SchemaAST.AST,
|
|
221
|
+
): SqliteDsl.ColumnDefinition.Any | null => {
|
|
222
|
+
const literalValues = extractLiteralValues(ast)
|
|
223
|
+
if (literalValues == null) return null
|
|
224
|
+
|
|
225
|
+
const literalType = getLiteralValueType(literalValues)
|
|
226
|
+
switch (literalType) {
|
|
227
|
+
case 'string':
|
|
228
|
+
return SqliteDsl.text({ schema, nullable })
|
|
229
|
+
case 'number': {
|
|
230
|
+
if (hasCheck(sourceAst.checks, 'effect/schema/isInt') === true || hasDateRepresentation(sourceAst) === true) {
|
|
231
|
+
return SqliteDsl.integer({ schema, nullable })
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const useIntegerColumn =
|
|
235
|
+
literalValues.length > 1 && literalValues.every((value) => typeof value === 'number' && Number.isInteger(value))
|
|
236
|
+
|
|
237
|
+
return useIntegerColumn === true ? SqliteDsl.integer({ schema, nullable }) : SqliteDsl.real({ schema, nullable })
|
|
238
|
+
}
|
|
239
|
+
case 'boolean':
|
|
240
|
+
return SqliteDsl.boolean({ nullable })
|
|
241
|
+
case 'bigint':
|
|
242
|
+
return SqliteDsl.integer({ schema, nullable })
|
|
243
|
+
default:
|
|
244
|
+
return null
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** Effect's built-in date codecs expose their semantic type through the Date representation annotation. */
|
|
249
|
+
const hasDateRepresentation = (ast: SchemaAST.AST): boolean => hasRepresentation(ast, 'effect/schema/Date')
|
|
250
|
+
|
|
251
|
+
const extractLiteralValues = (ast: SchemaAST.AST): ReadonlyArray<SchemaAST.LiteralValue> | null => {
|
|
252
|
+
if (SchemaAST.isLiteral(ast) === true) return [ast.literal]
|
|
253
|
+
|
|
254
|
+
if (
|
|
255
|
+
SchemaAST.isUnion(ast) === true &&
|
|
256
|
+
ast.types.length > 0 &&
|
|
257
|
+
ast.types.every((type) => SchemaAST.isLiteral(type)) === true
|
|
258
|
+
) {
|
|
259
|
+
return ast.types.map((type) => type.literal)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return null
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const getLiteralValueType = (
|
|
266
|
+
literals: ReadonlyArray<SchemaAST.LiteralValue>,
|
|
267
|
+
): 'string' | 'number' | 'boolean' | 'bigint' | null => {
|
|
268
|
+
const literalTypes = new Set(literals.map((value) => typeof value))
|
|
269
|
+
if (literalTypes.size !== 1) return null
|
|
270
|
+
|
|
271
|
+
const [literalType] = literalTypes
|
|
272
|
+
return literalType === 'string' || literalType === 'number' || literalType === 'boolean' || literalType === 'bigint'
|
|
273
|
+
? literalType
|
|
274
|
+
: null
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Recursively checks for Effect built-in check metadata.
|
|
279
|
+
*
|
|
280
|
+
* Checks can be attached directly as `Filter`s or nested in `FilterGroup`s when
|
|
281
|
+
* schemas compose multiple refinements, e.g. `Schema.Int.check(...)`.
|
|
282
|
+
*
|
|
283
|
+
* Effect rc.109 replaced the closed `meta` annotation with the open `representation`
|
|
284
|
+
* identity, so built-in checks are matched by their representation id.
|
|
285
|
+
*/
|
|
286
|
+
const hasCheck = (checks: ReadonlyArray<SchemaAST.Check<unknown>> | undefined, representationId: string): boolean => {
|
|
287
|
+
return (
|
|
288
|
+
checks?.some((check) => {
|
|
289
|
+
switch (check._tag) {
|
|
290
|
+
case 'Filter':
|
|
291
|
+
return check.annotations?.representation?.id === representationId
|
|
292
|
+
case 'FilterGroup':
|
|
293
|
+
return hasCheck(check.checks, representationId)
|
|
294
|
+
}
|
|
295
|
+
}) === true
|
|
296
|
+
)
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const isUint8ArraySchema = (ast: SchemaAST.AST): boolean => {
|
|
300
|
+
// `resolveAt` reads the last check's annotations, which can mask the declaration's representation.
|
|
301
|
+
if (hasRepresentation(ast, 'effect/schema/Uint8Array') === true) {
|
|
302
|
+
return true
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const identifier = SchemaAST.resolveIdentifier(ast)
|
|
306
|
+
if (identifier !== undefined && identifier.includes('Uint8Array') === true) {
|
|
307
|
+
return true
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (SchemaAST.isArrays(ast) === true) {
|
|
311
|
+
return ast.elements.length === 0 && ast.rest.length === 1 && SchemaAST.isNumber(ast.rest[0]!)
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return false
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const hasRepresentation = (ast: SchemaAST.AST, id: string): boolean => {
|
|
318
|
+
const representation = ast.annotations?.representation
|
|
319
|
+
return (
|
|
320
|
+
typeof representation === 'object' && representation !== null && 'id' in representation && representation.id === id
|
|
321
|
+
)
|
|
215
322
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Option, Schema } from '@livestore/utils/effect'
|
|
2
1
|
import { describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { Option, Schema } from '@livestore/utils/effect'
|
|
4
|
+
|
|
3
5
|
import { makeColumnSpec } from './column-spec.ts'
|
|
4
6
|
import { SqliteAst } from './db-schema/mod.ts'
|
|
5
7
|
|
|
@@ -26,9 +28,9 @@ const createColumn = (
|
|
|
26
28
|
case 'text':
|
|
27
29
|
return Schema.String
|
|
28
30
|
case 'integer':
|
|
29
|
-
return options.defaultValue === true || options.defaultValue === false ? Schema.Boolean : Schema.
|
|
31
|
+
return options.defaultValue === true || options.defaultValue === false ? Schema.Boolean : Schema.Finite
|
|
30
32
|
case 'real':
|
|
31
|
-
return Schema.
|
|
33
|
+
return Schema.Finite
|
|
32
34
|
case 'blob':
|
|
33
35
|
return Schema.Uint8ArrayFromBase64
|
|
34
36
|
default:
|
|
@@ -56,9 +58,9 @@ describe('makeColumnSpec', () => {
|
|
|
56
58
|
)
|
|
57
59
|
|
|
58
60
|
const result = makeColumnSpec(table)
|
|
59
|
-
expect(result).toMatchInlineSnapshot(`"
|
|
60
|
-
expect(result).toContain("
|
|
61
|
-
expect(result).toContain("
|
|
61
|
+
expect(result).toMatchInlineSnapshot(`""order" integer not null , "group" text "`)
|
|
62
|
+
expect(result).toContain('"order"')
|
|
63
|
+
expect(result).toContain('"group"')
|
|
62
64
|
})
|
|
63
65
|
|
|
64
66
|
it('should handle basic columns with primary keys', () => {
|
|
@@ -69,8 +71,7 @@ describe('makeColumnSpec', () => {
|
|
|
69
71
|
)
|
|
70
72
|
|
|
71
73
|
const result = makeColumnSpec(table)
|
|
72
|
-
expect(result).toMatchInlineSnapshot(`"
|
|
73
|
-
expect(result).toContain("PRIMARY KEY ('id')")
|
|
74
|
+
expect(result).toMatchInlineSnapshot(`""id" text primary key , "name" text "`)
|
|
74
75
|
})
|
|
75
76
|
|
|
76
77
|
it('should handle multi-column primary keys', () => {
|
|
@@ -85,9 +86,9 @@ describe('makeColumnSpec', () => {
|
|
|
85
86
|
|
|
86
87
|
const result = makeColumnSpec(table)
|
|
87
88
|
expect(result).toMatchInlineSnapshot(
|
|
88
|
-
`"
|
|
89
|
+
`""tenant_id" text not null , "user_id" text not null , PRIMARY KEY ("tenant_id", "user_id")"`,
|
|
89
90
|
)
|
|
90
|
-
expect(result).toContain(
|
|
91
|
+
expect(result).toContain('PRIMARY KEY ("tenant_id", "user_id")')
|
|
91
92
|
})
|
|
92
93
|
|
|
93
94
|
it('should handle auto-increment columns', () => {
|
|
@@ -101,9 +102,9 @@ describe('makeColumnSpec', () => {
|
|
|
101
102
|
)
|
|
102
103
|
|
|
103
104
|
const result = makeColumnSpec(table)
|
|
104
|
-
expect(result).toMatchInlineSnapshot(`"
|
|
105
|
+
expect(result).toMatchInlineSnapshot(`""id" integer primary key autoincrement , "title" text "`)
|
|
105
106
|
expect(result).toContain('autoincrement')
|
|
106
|
-
expect(result).toContain("PRIMARY KEY ('id')")
|
|
107
|
+
expect(result).not.toContain("PRIMARY KEY ('id')")
|
|
107
108
|
})
|
|
108
109
|
|
|
109
110
|
it('should handle columns with default values', () => {
|
|
@@ -121,7 +122,7 @@ describe('makeColumnSpec', () => {
|
|
|
121
122
|
|
|
122
123
|
const result = makeColumnSpec(table)
|
|
123
124
|
expect(result).toMatchInlineSnapshot(
|
|
124
|
-
`"
|
|
125
|
+
`""id" integer primary key , "name" text not null , "price" real default 0, "active" integer default true, "description" text default 'No description'"`,
|
|
125
126
|
)
|
|
126
127
|
expect(result).toContain('default 0')
|
|
127
128
|
expect(result).toContain('default true')
|
|
@@ -141,12 +142,28 @@ describe('makeColumnSpec', () => {
|
|
|
141
142
|
|
|
142
143
|
const result = makeColumnSpec(table)
|
|
143
144
|
expect(result).toMatchInlineSnapshot(
|
|
144
|
-
`"
|
|
145
|
+
`""id" integer primary key , "created_at" text default CURRENT_TIMESTAMP, "random_value" real default RANDOM()"`,
|
|
145
146
|
)
|
|
146
147
|
expect(result).toContain('default CURRENT_TIMESTAMP')
|
|
147
148
|
expect(result).toContain('default RANDOM()')
|
|
148
149
|
})
|
|
149
150
|
|
|
151
|
+
it('should omit default clause for thunk defaults', () => {
|
|
152
|
+
const table = SqliteAst.table(
|
|
153
|
+
'thunks',
|
|
154
|
+
[
|
|
155
|
+
createColumn('id', 'integer', { nullable: false, primaryKey: true }),
|
|
156
|
+
createColumn('token', 'text', { defaultValue: () => 'dynamic-token' }),
|
|
157
|
+
],
|
|
158
|
+
[],
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
const result = makeColumnSpec(table)
|
|
162
|
+
expect(result).toMatchInlineSnapshot(`""id" integer primary key , "token" text "`)
|
|
163
|
+
expect(result).not.toContain('dynamic-token')
|
|
164
|
+
expect(result).not.toMatch(/token" text\s+default/i)
|
|
165
|
+
})
|
|
166
|
+
|
|
150
167
|
it('should handle null default values', () => {
|
|
151
168
|
const table = SqliteAst.table(
|
|
152
169
|
'nullable_defaults',
|
|
@@ -158,9 +175,7 @@ describe('makeColumnSpec', () => {
|
|
|
158
175
|
)
|
|
159
176
|
|
|
160
177
|
const result = makeColumnSpec(table)
|
|
161
|
-
expect(result).toMatchInlineSnapshot(
|
|
162
|
-
`"'id' integer not null , 'optional_text' text default null, PRIMARY KEY ('id')"`,
|
|
163
|
-
)
|
|
178
|
+
expect(result).toMatchInlineSnapshot(`""id" integer primary key , "optional_text" text default null"`)
|
|
164
179
|
expect(result).toContain('default null')
|
|
165
180
|
})
|
|
166
181
|
|
|
@@ -190,7 +205,7 @@ describe('makeColumnSpec', () => {
|
|
|
190
205
|
|
|
191
206
|
const result = makeColumnSpec(table)
|
|
192
207
|
expect(result).toMatchInlineSnapshot(
|
|
193
|
-
`"
|
|
208
|
+
`""id" integer primary key autoincrement , "name" text not null default 'Unnamed', "created_at" text not null default CURRENT_TIMESTAMP, "status" text default 'pending'"`,
|
|
194
209
|
)
|
|
195
210
|
})
|
|
196
211
|
|
|
@@ -213,7 +228,7 @@ describe('makeColumnSpec', () => {
|
|
|
213
228
|
const result = makeColumnSpec(table)
|
|
214
229
|
// The makeColumnSpec function only generates column specifications, not indexes
|
|
215
230
|
expect(result).toMatchInlineSnapshot(
|
|
216
|
-
`"
|
|
231
|
+
`""id" integer primary key autoincrement , "email" text not null , "username" text not null , "created_at" text default CURRENT_TIMESTAMP"`,
|
|
217
232
|
)
|
|
218
233
|
// Verify the table has the indexes (even though they're not in the column spec)
|
|
219
234
|
expect(table.indexes).toHaveLength(3)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema } from '@livestore/utils/effect'
|
|
2
|
+
|
|
2
3
|
import { type SqliteAst, SqliteDsl } from './db-schema/mod.ts'
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -10,33 +11,59 @@ import { type SqliteAst, SqliteDsl } from './db-schema/mod.ts'
|
|
|
10
11
|
* ```
|
|
11
12
|
*/
|
|
12
13
|
export const makeColumnSpec = (tableAst: SqliteAst.Table) => {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
14
|
+
const pkColumns = tableAst.columns.filter((_) => _.primaryKey)
|
|
15
|
+
const hasSinglePk = pkColumns.length === 1
|
|
16
|
+
const pkColumn = hasSinglePk === true ? pkColumns[0] : undefined
|
|
17
|
+
|
|
18
|
+
// Build column definitions, handling the special SQLite rule that AUTOINCREMENT
|
|
19
|
+
// is only valid on a single column declared as INTEGER PRIMARY KEY (column-level).
|
|
20
|
+
const columnDefStrs = tableAst.columns.map((column) =>
|
|
21
|
+
toSqliteColumnSpec(column, {
|
|
22
|
+
inlinePrimaryKey: hasSinglePk && column === pkColumn && column.primaryKey,
|
|
23
|
+
}),
|
|
24
|
+
)
|
|
15
25
|
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
// For composite primary keys, add a table-level PRIMARY KEY clause.
|
|
27
|
+
if (pkColumns.length > 1) {
|
|
28
|
+
const quotedPkCols = pkColumns.map((_) => `"${_.name}"`)
|
|
29
|
+
columnDefStrs.push(`PRIMARY KEY (${quotedPkCols.join(', ')})`)
|
|
18
30
|
}
|
|
19
31
|
|
|
20
32
|
return columnDefStrs.join(', ')
|
|
21
33
|
}
|
|
22
34
|
|
|
23
35
|
/** NOTE primary keys are applied on a table level not on a column level to account for multi-column primary keys */
|
|
24
|
-
const toSqliteColumnSpec = (column: SqliteAst.Column) => {
|
|
36
|
+
const toSqliteColumnSpec = (column: SqliteAst.Column, opts: { inlinePrimaryKey: boolean }) => {
|
|
25
37
|
const columnTypeStr = column.type._tag
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
// When PRIMARY KEY is declared inline, NOT NULL is implied and should not be emitted,
|
|
39
|
+
// and AUTOINCREMENT must immediately follow PRIMARY KEY within the same constraint.
|
|
40
|
+
const nullableStr = opts.inlinePrimaryKey === true ? '' : column.nullable === false ? 'not null' : ''
|
|
41
|
+
|
|
42
|
+
// Only include AUTOINCREMENT when it's valid: single-column INTEGER PRIMARY KEY
|
|
43
|
+
const includeAutoIncrement =
|
|
44
|
+
opts.inlinePrimaryKey === true && column.type._tag === 'integer' && column.autoIncrement === true
|
|
45
|
+
|
|
46
|
+
const pkStr = opts.inlinePrimaryKey === true ? 'primary key' : ''
|
|
47
|
+
const autoIncrementStr = includeAutoIncrement === true ? 'autoincrement' : ''
|
|
48
|
+
|
|
28
49
|
const defaultValueStr = (() => {
|
|
29
50
|
if (column.default._tag === 'None') return ''
|
|
30
51
|
|
|
31
|
-
|
|
32
|
-
if (SqliteDsl.
|
|
52
|
+
const defaultValue = column.default.value
|
|
53
|
+
if (SqliteDsl.isDefaultThunk(defaultValue) === true) return ''
|
|
54
|
+
|
|
55
|
+
const resolvedDefault = SqliteDsl.resolveColumnDefault(defaultValue)
|
|
56
|
+
|
|
57
|
+
if (resolvedDefault === null) return 'default null'
|
|
58
|
+
if (SqliteDsl.isSqlDefaultValue(resolvedDefault) === true) return `default ${resolvedDefault.sql}`
|
|
33
59
|
|
|
34
60
|
const encodeValue = Schema.encodeSync(column.schema)
|
|
35
|
-
const encodedDefaultValue = encodeValue(
|
|
61
|
+
const encodedDefaultValue = encodeValue(resolvedDefault)
|
|
36
62
|
|
|
37
63
|
if (columnTypeStr === 'text') return `default '${encodedDefaultValue}'`
|
|
38
64
|
return `default ${encodedDefaultValue}`
|
|
39
65
|
})()
|
|
40
66
|
|
|
41
|
-
|
|
67
|
+
// Ensure order: PRIMARY KEY [AUTOINCREMENT] [NOT NULL] ...
|
|
68
|
+
return `"${column.name}" ${columnTypeStr} ${pkStr} ${autoIncrementStr} ${nullableStr} ${defaultValueStr}`
|
|
42
69
|
}
|
|
@@ -25,7 +25,7 @@ export type Column = {
|
|
|
25
25
|
nullable: boolean
|
|
26
26
|
autoIncrement: boolean
|
|
27
27
|
default: Option.Option<any>
|
|
28
|
-
schema: Schema.
|
|
28
|
+
schema: Schema.Codec<any, any>
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export const column = (props: Omit<Column, '_tag'>): Column => ({ _tag: 'column', ...props })
|
|
@@ -84,14 +84,24 @@ export type DbSchema = {
|
|
|
84
84
|
export const dbSchema = (tables: Table[]): DbSchema => ({ _tag: 'dbSchema', tables })
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
|
-
* Helper to detect if a column is a JSON column (
|
|
87
|
+
* Helper to detect if a column is a JSON column (encoded as a JSON string)
|
|
88
88
|
*/
|
|
89
89
|
const isJsonColumn = (column: Column): boolean => {
|
|
90
90
|
if (column.type._tag !== 'text') return false
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
return hasJsonStringEncoding(column.schema.ast)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* `SchemaTransformation.fromJsonString` is a factory since Effect rc.109, so encoding links can no
|
|
97
|
+
* longer be matched by identity. `Schema.fromJsonString` annotates its encoded side as
|
|
98
|
+
* `application/json`, which identifies the link regardless of the reviver/replacer/space options.
|
|
99
|
+
*/
|
|
100
|
+
const hasJsonStringEncoding = (ast: SchemaAST.AST): boolean => {
|
|
101
|
+
if (ast.encoding?.some((link) => link.to.annotations?.contentMediaType === 'application/json') === true) {
|
|
102
|
+
return true
|
|
103
|
+
}
|
|
104
|
+
return SchemaAST.isUnion(ast) === true && ast.types.some(hasJsonStringEncoding)
|
|
95
105
|
}
|
|
96
106
|
|
|
97
107
|
/**
|
|
@@ -124,7 +134,7 @@ const trimInfoForHasing = (obj: Table | Column | Index | ForeignKey | DbSchema):
|
|
|
124
134
|
|
|
125
135
|
// NEW: Include schema hash for JSON columns
|
|
126
136
|
// This ensures that changes to the JSON schema are detected
|
|
127
|
-
if (isJsonColumn(obj) && obj.schema) {
|
|
137
|
+
if (isJsonColumn(obj) === true && obj.schema !== undefined) {
|
|
128
138
|
// Use Effect's Schema.hash for consistent hashing
|
|
129
139
|
baseInfo.jsonSchemaHash = Schema.hash(obj.schema)
|
|
130
140
|
}
|
|
@@ -155,7 +165,7 @@ const trimInfoForHasing = (obj: Table | Column | Index | ForeignKey | DbSchema):
|
|
|
155
165
|
}
|
|
156
166
|
}
|
|
157
167
|
default: {
|
|
158
|
-
throw new Error(`Unreachable: ${obj}`)
|
|
168
|
+
throw new Error(`Unreachable: ${String(obj)}`)
|
|
159
169
|
}
|
|
160
170
|
}
|
|
161
171
|
}
|