@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
|
@@ -1,116 +1,136 @@
|
|
|
1
1
|
import { Schema, Transferable } from '@livestore/utils/effect'
|
|
2
2
|
|
|
3
|
-
import * as LiveStoreEvent from '../schema/LiveStoreEvent.ts'
|
|
3
|
+
import * as LiveStoreEvent from '../schema/LiveStoreEvent/mod.ts'
|
|
4
4
|
import { EventSequenceNumber } from '../schema/mod.ts'
|
|
5
5
|
import * as SyncState from '../sync/syncstate.ts'
|
|
6
6
|
import { LeaderReqResMessage, LSDMessage, LSDReqResMessage, NetworkStatus } from './devtools-messages-common.ts'
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
mode: Schema.
|
|
10
|
-
})
|
|
8
|
+
export const ResetAllDataReq = LSDReqResMessage('LSD.Leader.ResetAllDataReq', {
|
|
9
|
+
mode: Schema.Literals(['all-data', 'only-app-db']),
|
|
10
|
+
})
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export const DatabaseFileInfoReq = LSDReqResMessage('LSD.Leader.DatabaseFileInfoReq', {})
|
|
13
13
|
|
|
14
|
-
export
|
|
15
|
-
fileSize: Schema.
|
|
16
|
-
persistenceInfo: Schema.Struct({ fileName: Schema.String },
|
|
17
|
-
|
|
14
|
+
export const DatabaseFileInfo = Schema.Struct({
|
|
15
|
+
fileSize: Schema.Finite,
|
|
16
|
+
persistenceInfo: Schema.StructWithRest(Schema.Struct({ fileName: Schema.String }), [
|
|
17
|
+
Schema.Record(Schema.String, Schema.Any),
|
|
18
|
+
]),
|
|
19
|
+
})
|
|
18
20
|
|
|
19
|
-
export
|
|
21
|
+
export const DatabaseFileInfoRes = LSDReqResMessage('LSD.Leader.DatabaseFileInfoRes', {
|
|
20
22
|
state: DatabaseFileInfo,
|
|
21
23
|
eventlog: DatabaseFileInfo,
|
|
22
|
-
})
|
|
24
|
+
})
|
|
23
25
|
|
|
24
|
-
export
|
|
26
|
+
export const NetworkStatusSubscribe = LSDReqResMessage('LSD.Leader.NetworkStatusSubscribe', {
|
|
25
27
|
subscriptionId: Schema.String,
|
|
26
|
-
})
|
|
27
|
-
export
|
|
28
|
+
})
|
|
29
|
+
export const NetworkStatusUnsubscribe = LSDReqResMessage('LSD.Leader.NetworkStatusUnsubscribe', {
|
|
28
30
|
subscriptionId: Schema.String,
|
|
29
|
-
})
|
|
31
|
+
})
|
|
30
32
|
|
|
31
|
-
export
|
|
33
|
+
export const NetworkStatusRes = LSDReqResMessage('LSD.Leader.NetworkStatusRes', {
|
|
32
34
|
networkStatus: NetworkStatus,
|
|
33
35
|
subscriptionId: Schema.String,
|
|
34
|
-
})
|
|
36
|
+
})
|
|
35
37
|
|
|
36
|
-
export
|
|
38
|
+
export const SyncingInfoReq = LSDReqResMessage('LSD.Leader.SyncingInfoReq', {})
|
|
37
39
|
|
|
38
|
-
export
|
|
40
|
+
export const SyncingInfo = Schema.Struct({
|
|
39
41
|
enabled: Schema.Boolean,
|
|
40
|
-
metadata: Schema.Record(
|
|
41
|
-
})
|
|
42
|
+
metadata: Schema.Record(Schema.String, Schema.Any),
|
|
43
|
+
})
|
|
42
44
|
|
|
43
|
-
export
|
|
45
|
+
export const SyncingInfoRes = LSDReqResMessage('LSD.Leader.SyncingInfoRes', {
|
|
44
46
|
syncingInfo: SyncingInfo,
|
|
45
|
-
})
|
|
47
|
+
})
|
|
46
48
|
|
|
47
|
-
export
|
|
49
|
+
export const SyncHistorySubscribe = LSDReqResMessage('LSD.Leader.SyncHistorySubscribe', {
|
|
48
50
|
subscriptionId: Schema.String,
|
|
49
|
-
})
|
|
50
|
-
export
|
|
51
|
+
})
|
|
52
|
+
export const SyncHistoryUnsubscribe = LSDReqResMessage('LSD.Leader.SyncHistoryUnsubscribe', {
|
|
51
53
|
subscriptionId: Schema.String,
|
|
52
|
-
})
|
|
53
|
-
export
|
|
54
|
-
eventEncoded: LiveStoreEvent.
|
|
55
|
-
metadata: Schema.Option(Schema.
|
|
54
|
+
})
|
|
55
|
+
export const SyncHistoryRes = LSDReqResMessage('LSD.Leader.SyncHistoryRes', {
|
|
56
|
+
eventEncoded: LiveStoreEvent.Global.Encoded,
|
|
57
|
+
metadata: Schema.Option(Schema.Json),
|
|
56
58
|
subscriptionId: Schema.String,
|
|
57
|
-
})
|
|
59
|
+
})
|
|
58
60
|
|
|
59
|
-
export
|
|
61
|
+
export const SyncHeadSubscribe = LSDReqResMessage('LSD.Leader.SyncHeadSubscribe', {
|
|
60
62
|
subscriptionId: Schema.String,
|
|
61
|
-
})
|
|
62
|
-
export
|
|
63
|
+
})
|
|
64
|
+
export const SyncHeadUnsubscribe = LSDReqResMessage('LSD.Leader.SyncHeadUnsubscribe', {
|
|
63
65
|
subscriptionId: Schema.String,
|
|
64
|
-
})
|
|
65
|
-
export
|
|
66
|
-
local: EventSequenceNumber.
|
|
67
|
-
upstream: EventSequenceNumber.
|
|
66
|
+
})
|
|
67
|
+
export const SyncHeadRes = LSDReqResMessage('LSD.Leader.SyncHeadRes', {
|
|
68
|
+
local: EventSequenceNumber.Client.Composite,
|
|
69
|
+
upstream: EventSequenceNumber.Client.Composite,
|
|
68
70
|
subscriptionId: Schema.String,
|
|
69
|
-
})
|
|
71
|
+
})
|
|
70
72
|
|
|
71
|
-
export
|
|
73
|
+
export const SnapshotReq = LSDReqResMessage('LSD.Leader.SnapshotReq', {})
|
|
72
74
|
|
|
73
|
-
export
|
|
74
|
-
snapshot: Transferable.Uint8Array as Schema.
|
|
75
|
-
})
|
|
75
|
+
export const SnapshotRes = LSDReqResMessage('LSD.Leader.SnapshotRes', {
|
|
76
|
+
snapshot: Transferable.Uint8Array as Schema.Codec<Uint8Array<ArrayBuffer>>,
|
|
77
|
+
})
|
|
76
78
|
|
|
77
79
|
export const LoadDatabaseFile = LeaderReqResMessage('LSD.Leader.LoadDatabaseFile', {
|
|
78
80
|
payload: {
|
|
79
|
-
data: Transferable.Uint8Array as Schema.
|
|
81
|
+
data: Transferable.Uint8Array as Schema.Codec<Uint8Array<ArrayBuffer>>,
|
|
82
|
+
batchId: Schema.optional(Schema.String),
|
|
80
83
|
},
|
|
81
84
|
success: {},
|
|
82
85
|
error: {
|
|
83
|
-
cause: Schema.Union(
|
|
86
|
+
cause: Schema.Union([
|
|
84
87
|
Schema.TaggedStruct('unsupported-file', {}),
|
|
85
88
|
Schema.TaggedStruct('unsupported-database', {}),
|
|
86
|
-
Schema.TaggedStruct('
|
|
87
|
-
),
|
|
89
|
+
Schema.TaggedStruct('unknown-error', { cause: Schema.Defect() }),
|
|
90
|
+
]),
|
|
88
91
|
},
|
|
89
92
|
})
|
|
90
93
|
|
|
91
94
|
// TODO refactor this to use push/pull semantics
|
|
92
|
-
export
|
|
95
|
+
export const SyncPull = LSDMessage('LSD.Leader.SyncPull', {
|
|
93
96
|
payload: SyncState.PayloadUpstream,
|
|
94
|
-
})
|
|
97
|
+
})
|
|
95
98
|
|
|
96
99
|
// TODO refactor this to use push/pull semantics
|
|
97
|
-
export
|
|
98
|
-
eventEncoded: LiveStoreEvent.
|
|
99
|
-
})
|
|
100
|
+
export const CommitEventReq = LSDReqResMessage('LSD.Leader.CommitEventReq', {
|
|
101
|
+
eventEncoded: LiveStoreEvent.Input.Encoded,
|
|
102
|
+
})
|
|
100
103
|
|
|
101
|
-
export
|
|
104
|
+
export const CommitEventRes = LSDReqResMessage('LSD.Leader.CommitEventRes', {})
|
|
102
105
|
|
|
103
|
-
export
|
|
106
|
+
export const EventlogReq = LSDReqResMessage('LSD.Leader.EventlogReq', {})
|
|
104
107
|
|
|
105
|
-
export
|
|
106
|
-
eventlog: Transferable.Uint8Array as Schema.
|
|
107
|
-
})
|
|
108
|
+
export const EventlogRes = LSDReqResMessage('LSD.Leader.EventlogRes', {
|
|
109
|
+
eventlog: Transferable.Uint8Array as Schema.Codec<Uint8Array<ArrayBuffer>>,
|
|
110
|
+
})
|
|
108
111
|
|
|
109
|
-
export
|
|
112
|
+
export const Ping = LSDReqResMessage('LSD.Leader.Ping', {
|
|
113
|
+
devtoolsProtocolVersion: Schema.optional(Schema.Finite),
|
|
114
|
+
})
|
|
110
115
|
|
|
111
|
-
export
|
|
116
|
+
export const Pong = LSDReqResMessage('LSD.Leader.Pong', {
|
|
117
|
+
devtoolsProtocolVersion: Schema.optional(Schema.Finite),
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Sent by the app when the DevTools protocol isn't compatible.
|
|
122
|
+
* Contains package versions for display and protocol versions for the actual compatibility decision.
|
|
123
|
+
*/
|
|
124
|
+
export const VersionMismatch = LSDReqResMessage('LSD.Leader.VersionMismatch', {
|
|
125
|
+
/** The version running in the app */
|
|
126
|
+
appVersion: Schema.String,
|
|
127
|
+
/** The version that was sent by DevTools (that caused the mismatch) */
|
|
128
|
+
receivedVersion: Schema.String,
|
|
129
|
+
appDevtoolsProtocolVersion: Schema.Finite,
|
|
130
|
+
receivedDevtoolsProtocolVersion: Schema.optional(Schema.Finite),
|
|
131
|
+
})
|
|
112
132
|
|
|
113
|
-
export
|
|
133
|
+
export const Disconnect = LSDReqResMessage('LSD.Leader.Disconnect', {})
|
|
114
134
|
|
|
115
135
|
export const SetSyncLatch = LeaderReqResMessage('LSD.Leader.SetSyncLatch', {
|
|
116
136
|
payload: {
|
|
@@ -121,7 +141,7 @@ export const SetSyncLatch = LeaderReqResMessage('LSD.Leader.SetSyncLatch', {
|
|
|
121
141
|
|
|
122
142
|
export const ResetAllData = LeaderReqResMessage('LSD.Leader.ResetAllData', {
|
|
123
143
|
payload: {
|
|
124
|
-
mode: Schema.
|
|
144
|
+
mode: Schema.Literals(['all-data', 'only-app-db']),
|
|
125
145
|
},
|
|
126
146
|
success: {},
|
|
127
147
|
})
|
|
@@ -133,7 +153,7 @@ export const ResetAllData = LeaderReqResMessage('LSD.Leader.ResetAllData', {
|
|
|
133
153
|
// liveStoreVersion,
|
|
134
154
|
// },
|
|
135
155
|
// success: DatabaseFileInfo,
|
|
136
|
-
// failure:
|
|
156
|
+
// failure: UnknownError,
|
|
137
157
|
// }) {}
|
|
138
158
|
|
|
139
159
|
// export class NetworkStatus_ extends Schema.TaggedRequest<NetworkStatus_>()('LSD.Leader.NetworkStatus', {
|
|
@@ -142,15 +162,15 @@ export const ResetAllData = LeaderReqResMessage('LSD.Leader.ResetAllData', {
|
|
|
142
162
|
// liveStoreVersion,
|
|
143
163
|
// },
|
|
144
164
|
// success: NetworkStatus,
|
|
145
|
-
// failure:
|
|
165
|
+
// failure: UnknownError,
|
|
146
166
|
// }) {}
|
|
147
167
|
|
|
148
|
-
// export const MessageToApp_ = Schema.Union(DatabaseFileInfo_, NetworkStatus_)
|
|
168
|
+
// export const MessageToApp_ = Schema.Union([DatabaseFileInfo_, NetworkStatus_])
|
|
149
169
|
|
|
150
170
|
// export type MessageToApp_ = typeof MessageToApp_.Type
|
|
151
171
|
//
|
|
152
172
|
|
|
153
|
-
export const MessageToApp = Schema.Union(
|
|
173
|
+
export const MessageToApp = Schema.Union([
|
|
154
174
|
SnapshotReq,
|
|
155
175
|
LoadDatabaseFile.Request,
|
|
156
176
|
EventlogReq,
|
|
@@ -167,11 +187,11 @@ export const MessageToApp = Schema.Union(
|
|
|
167
187
|
SyncHeadSubscribe,
|
|
168
188
|
SyncHeadUnsubscribe,
|
|
169
189
|
SetSyncLatch.Request,
|
|
170
|
-
).
|
|
190
|
+
]).annotate({ identifier: 'LSD.Leader.MessageToApp' })
|
|
171
191
|
|
|
172
192
|
export type MessageToApp = typeof MessageToApp.Type
|
|
173
193
|
|
|
174
|
-
export const MessageFromApp = Schema.Union(
|
|
194
|
+
export const MessageFromApp = Schema.Union([
|
|
175
195
|
SnapshotRes,
|
|
176
196
|
LoadDatabaseFile.Response,
|
|
177
197
|
EventlogRes,
|
|
@@ -180,12 +200,13 @@ export const MessageFromApp = Schema.Union(
|
|
|
180
200
|
NetworkStatusRes,
|
|
181
201
|
CommitEventRes,
|
|
182
202
|
Pong,
|
|
203
|
+
VersionMismatch,
|
|
183
204
|
DatabaseFileInfoRes,
|
|
184
205
|
SyncHistoryRes,
|
|
185
206
|
SyncingInfoRes,
|
|
186
207
|
SyncHeadRes,
|
|
187
208
|
ResetAllData.Success,
|
|
188
209
|
SetSyncLatch.Success,
|
|
189
|
-
).
|
|
210
|
+
]).annotate({ identifier: 'LSD.Leader.MessageFromApp' })
|
|
190
211
|
|
|
191
212
|
export type MessageFromApp = typeof MessageFromApp.Type
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ParseResult, Scope, WebChannel } from '@livestore/utils/effect'
|
|
2
1
|
import {
|
|
3
|
-
|
|
2
|
+
type Scope,
|
|
3
|
+
type WebChannel,
|
|
4
4
|
Duration,
|
|
5
5
|
Effect,
|
|
6
6
|
FiberMap,
|
|
@@ -21,10 +21,16 @@ export const SessionInfo = Schema.TaggedStruct('SessionInfo', {
|
|
|
21
21
|
sessionId: Schema.String,
|
|
22
22
|
schemaAlias: Schema.String,
|
|
23
23
|
isLeader: Schema.Boolean,
|
|
24
|
+
/**
|
|
25
|
+
* Browser origin that produced this SessionInfo (for example, 'http://localhost:5173').
|
|
26
|
+
* Set by browser-based publishers so DevTools can defensively filter by origin.
|
|
27
|
+
* Currently only needed by the browser extension; non‑browser publishers typically set `undefined`.
|
|
28
|
+
*/
|
|
29
|
+
origin: Schema.UndefinedOr(Schema.String),
|
|
24
30
|
})
|
|
25
31
|
export type SessionInfo = typeof SessionInfo.Type
|
|
26
32
|
|
|
27
|
-
export const Message = Schema.Union(RequestSessions, SessionInfo)
|
|
33
|
+
export const Message = Schema.Union([RequestSessions, SessionInfo])
|
|
28
34
|
export type Message = typeof Message.Type
|
|
29
35
|
|
|
30
36
|
/** Usually called in client session */
|
|
@@ -34,12 +40,12 @@ export const provideSessionInfo = ({
|
|
|
34
40
|
}: {
|
|
35
41
|
webChannel: WebChannel.WebChannel<Message, Message>
|
|
36
42
|
sessionInfo: SessionInfo
|
|
37
|
-
}): Effect.Effect<void,
|
|
43
|
+
}): Effect.Effect<void, Schema.SchemaError> =>
|
|
38
44
|
Effect.gen(function* () {
|
|
39
45
|
yield* webChannel.send(sessionInfo)
|
|
40
46
|
|
|
41
47
|
yield* webChannel.listen.pipe(
|
|
42
|
-
Stream.
|
|
48
|
+
Stream.mapEffect(Effect.fromResult),
|
|
43
49
|
Stream.filter(Schema.is(RequestSessions)),
|
|
44
50
|
Stream.tap(() => webChannel.send(sessionInfo)),
|
|
45
51
|
Stream.runDrain,
|
|
@@ -53,9 +59,9 @@ export const requestSessionInfoSubscription = ({
|
|
|
53
59
|
staleTimeout = Duration.seconds(5),
|
|
54
60
|
}: {
|
|
55
61
|
webChannel: WebChannel.WebChannel<Message, Message>
|
|
56
|
-
pollInterval?: Duration.
|
|
57
|
-
staleTimeout?: Duration.
|
|
58
|
-
}): Effect.Effect<Subscribable.Subscribable<
|
|
62
|
+
pollInterval?: Duration.Input
|
|
63
|
+
staleTimeout?: Duration.Input
|
|
64
|
+
}): Effect.Effect<Subscribable.Subscribable<HashSet.HashSet<SessionInfo>>, Schema.SchemaError, Scope.Scope> =>
|
|
59
65
|
Effect.gen(function* () {
|
|
60
66
|
yield* webChannel
|
|
61
67
|
.send(RequestSessions.make({}))
|
|
@@ -71,9 +77,8 @@ export const requestSessionInfoSubscription = ({
|
|
|
71
77
|
const sessionInfoSubRef = yield* SubscriptionRef.make<HashSet.HashSet<SessionInfo>>(HashSet.empty())
|
|
72
78
|
|
|
73
79
|
yield* webChannel.listen.pipe(
|
|
74
|
-
Stream.
|
|
80
|
+
Stream.mapEffect(Effect.fromResult),
|
|
75
81
|
Stream.filter(Schema.is(SessionInfo)),
|
|
76
|
-
Stream.map(Data.struct),
|
|
77
82
|
Stream.tap(
|
|
78
83
|
Effect.fn(function* (sessionInfo) {
|
|
79
84
|
yield* SubscriptionRef.getAndUpdate(sessionInfoSubRef, HashSet.add(sessionInfo))
|
|
@@ -95,7 +100,7 @@ export const requestSessionInfoSubscription = ({
|
|
|
95
100
|
)
|
|
96
101
|
|
|
97
102
|
return Subscribable.make({
|
|
98
|
-
get:
|
|
99
|
-
changes:
|
|
103
|
+
get: SubscriptionRef.get(sessionInfoSubRef),
|
|
104
|
+
changes: SubscriptionRef.changes(sessionInfoSubRef),
|
|
100
105
|
})
|
|
101
106
|
})
|
package/src/devtools/mod.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { Schema } from '@livestore/utils/effect'
|
|
1
|
+
import { type Effect, type Scope, type WebChannel, Schema } from '@livestore/utils/effect'
|
|
3
2
|
import { nanoid } from '@livestore/utils/nanoid'
|
|
4
3
|
import type { MeshNode } from '@livestore/webmesh'
|
|
5
4
|
|
|
@@ -8,18 +7,18 @@ import * as SessionInfo from './devtools-sessioninfo.ts'
|
|
|
8
7
|
export * from './devtools-messages.ts'
|
|
9
8
|
export * as SessionInfo from './devtools-sessioninfo.ts'
|
|
10
9
|
|
|
11
|
-
export const DevtoolsMode = Schema.Union(
|
|
10
|
+
export const DevtoolsMode = Schema.Union([
|
|
12
11
|
Schema.TaggedStruct('node', {
|
|
13
12
|
/** WebSocket URL */
|
|
14
13
|
url: Schema.String,
|
|
15
14
|
}),
|
|
16
15
|
Schema.TaggedStruct('web', {}),
|
|
17
16
|
Schema.TaggedStruct('browser-extension', {}),
|
|
18
|
-
)
|
|
17
|
+
])
|
|
19
18
|
|
|
20
19
|
export type DevtoolsMode = typeof DevtoolsMode.Type
|
|
21
20
|
|
|
22
|
-
export const DevtoolsModeTag =
|
|
21
|
+
export const DevtoolsModeTag = Schema.Literals(['node', 'web', 'browser-extension'])
|
|
23
22
|
export type DevtoolsModeTag = typeof DevtoolsModeTag.Type
|
|
24
23
|
|
|
25
24
|
export const makeNodeName = {
|
|
@@ -34,7 +33,15 @@ export const makeNodeName = {
|
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
export const makeChannelName = {
|
|
37
|
-
|
|
36
|
+
/**
|
|
37
|
+
* SessionInfo channel for DevTools discovery.
|
|
38
|
+
* When an `origin` is provided, it is incorporated into the channel name to scope
|
|
39
|
+
* broadcasts per origin (e.g. `session-info::http%3A%2F%2Flocalhost%3A5173`).
|
|
40
|
+
* The `origin` is currently required only for the browser extension path; non‑browser
|
|
41
|
+
* publishers can pass `undefined` to use the legacy global channel name.
|
|
42
|
+
*/
|
|
43
|
+
sessionInfo: ({ origin }: { origin: string | undefined }) =>
|
|
44
|
+
origin !== undefined ? `session-info::${encodeURIComponent(origin)}` : `session-info`,
|
|
38
45
|
devtoolsClientSession: ({ storeId, clientId, sessionId }: { storeId: string; clientId: string; sessionId: string }) =>
|
|
39
46
|
`devtools-channel(client-session-${storeId}-${clientId}-${sessionId})`,
|
|
40
47
|
devtoolsClientLeader: ({ storeId, clientId, sessionId }: { storeId: string; clientId: string; sessionId: string }) =>
|
|
@@ -52,8 +59,9 @@ export const isChannelName = {
|
|
|
52
59
|
|
|
53
60
|
export const makeSessionInfoBroadcastChannel = (
|
|
54
61
|
webmeshNode: MeshNode,
|
|
62
|
+
options: { origin: string | undefined },
|
|
55
63
|
): Effect.Effect<WebChannel.WebChannel<SessionInfo.Message, SessionInfo.Message>, never, Scope.Scope> =>
|
|
56
64
|
webmeshNode.makeBroadcastChannel({
|
|
57
|
-
channelName: makeChannelName.sessionInfo(),
|
|
65
|
+
channelName: makeChannelName.sessionInfo({ origin: options?.origin }),
|
|
58
66
|
schema: SessionInfo.Message,
|
|
59
67
|
})
|
package/src/errors.ts
CHANGED
|
@@ -1,69 +1,89 @@
|
|
|
1
|
-
import { Cause, Effect, Layer, Schema, Stream } from '@livestore/utils/effect'
|
|
1
|
+
import { Cause, Effect, Layer, Option, Schema, Stream, Struct } from '@livestore/utils/effect'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import * as LiveStoreEvent from './schema/LiveStoreEvent/mod.ts'
|
|
4
|
+
|
|
5
|
+
export class UnknownError extends Schema.TaggedError<UnknownError>('~@livestore/common/UnknownError')('UnknownError', {
|
|
6
|
+
cause: Schema.Defect(),
|
|
5
7
|
note: Schema.optional(Schema.String),
|
|
6
8
|
payload: Schema.optional(Schema.Any),
|
|
7
9
|
}) {
|
|
8
|
-
static
|
|
10
|
+
static mapToUnknownError = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
|
|
9
11
|
effect.pipe(
|
|
10
|
-
Effect.mapError((cause) => (Schema.is(
|
|
11
|
-
Effect.
|
|
12
|
+
Effect.mapError((cause) => (Schema.is(UnknownError)(cause) === true ? cause : new UnknownError({ cause }))),
|
|
13
|
+
Effect.catchDefect((cause) => new UnknownError({ cause })),
|
|
12
14
|
)
|
|
13
15
|
|
|
14
|
-
static
|
|
16
|
+
static mapToUnknownErrorLayer = <A, E, R>(layer: Layer.Layer<A, E, R>) =>
|
|
15
17
|
layer.pipe(
|
|
16
|
-
Layer.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
Layer.catchCause((cause) => {
|
|
19
|
+
const error = Cause.findErrorOption(cause)
|
|
20
|
+
return Option.isSome(error) === true && Schema.is(UnknownError)(error.value) === true
|
|
21
|
+
? Layer.effectContext<A, UnknownError, never>(Effect.fail(error.value))
|
|
22
|
+
: Layer.effectContext<A, UnknownError, never>(Effect.fail(new UnknownError({ cause: cause })))
|
|
23
|
+
}),
|
|
21
24
|
)
|
|
22
25
|
|
|
23
|
-
static
|
|
26
|
+
static mapToUnknownErrorStream = <A, E, R>(stream: Stream.Stream<A, E, R>) =>
|
|
24
27
|
stream.pipe(
|
|
25
|
-
Stream.mapError((cause) => (Schema.is(
|
|
28
|
+
Stream.mapError((cause) => (Schema.is(UnknownError)(cause) === true ? cause : new UnknownError({ cause }))),
|
|
26
29
|
)
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
'LiveStore.MaterializerHashMismatchError',
|
|
31
|
-
{
|
|
32
|
-
eventName: Schema.String,
|
|
33
|
-
note: Schema.optionalWith(Schema.String, {
|
|
34
|
-
default: () => 'Please make sure your event materializer is a pure function without side effects.',
|
|
35
|
-
}),
|
|
36
|
-
},
|
|
37
|
-
) {}
|
|
32
|
+
const materializerHashMismatchNote = 'Please make sure your event materializer is a pure function without side effects.'
|
|
38
33
|
|
|
39
|
-
export class
|
|
40
|
-
'
|
|
34
|
+
export class MaterializerHashMismatchError extends Schema.TaggedError<MaterializerHashMismatchError>(
|
|
35
|
+
'~@livestore/common/MaterializerHashMismatchError',
|
|
36
|
+
)('MaterializerHashMismatchError', {
|
|
37
|
+
eventName: Schema.String,
|
|
38
|
+
note: Schema.String.pipe(
|
|
39
|
+
Schema.withDecodingDefaultType(Effect.succeed(materializerHashMismatchNote)),
|
|
40
|
+
Schema.withConstructorDefault(Effect.succeed(materializerHashMismatchNote)),
|
|
41
|
+
),
|
|
42
|
+
}) {}
|
|
43
|
+
|
|
44
|
+
export class IntentionalShutdownCause extends Schema.TaggedError<IntentionalShutdownCause>(
|
|
45
|
+
'~@livestore/common/IntentionalShutdownCause',
|
|
46
|
+
)('IntentionalShutdownCause', {
|
|
47
|
+
reason: Schema.Literals(['devtools-reset', 'devtools-import', 'adapter-reset', 'manual', 'backend-id-mismatch']),
|
|
48
|
+
}) {}
|
|
49
|
+
|
|
50
|
+
export class StoreInterrupted extends Schema.TaggedError<StoreInterrupted>('~@livestore/common/StoreInterrupted')(
|
|
51
|
+
'StoreInterrupted',
|
|
41
52
|
{
|
|
42
|
-
reason: Schema.
|
|
53
|
+
reason: Schema.String,
|
|
43
54
|
},
|
|
44
55
|
) {}
|
|
45
56
|
|
|
46
|
-
export class
|
|
47
|
-
reason: Schema.String,
|
|
48
|
-
}) {}
|
|
49
|
-
|
|
50
|
-
export class SqliteError extends Schema.TaggedError<SqliteError>()('LiveStore.SqliteError', {
|
|
57
|
+
export class SqliteError extends Schema.TaggedError<SqliteError>('~@livestore/common/SqliteError')('SqliteError', {
|
|
51
58
|
query: Schema.optional(
|
|
52
59
|
Schema.Struct({
|
|
53
60
|
sql: Schema.String,
|
|
54
|
-
bindValues: Schema.Union(Schema.Record(
|
|
61
|
+
bindValues: Schema.Union([Schema.Record(Schema.String, Schema.Any), Schema.Array(Schema.Any)]),
|
|
55
62
|
}),
|
|
56
63
|
),
|
|
57
64
|
/** The SQLite result code */
|
|
58
65
|
// code: Schema.optional(Schema.Number),
|
|
59
66
|
// Added string support for Expo SQLite (we should refactor this to have a unified error type)
|
|
60
|
-
code: Schema.optional(Schema.Union(Schema.
|
|
67
|
+
code: Schema.optional(Schema.Union([Schema.Finite, Schema.String])),
|
|
61
68
|
/** The original SQLite3 error */
|
|
62
|
-
cause: Schema.Defect,
|
|
69
|
+
cause: Schema.Defect(),
|
|
63
70
|
note: Schema.optional(Schema.String),
|
|
64
71
|
}) {}
|
|
65
72
|
|
|
66
|
-
export class
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
export class UnknownEventError extends Schema.TaggedError<UnknownEventError>('~@livestore/common/UnknownEventError')(
|
|
74
|
+
'UnknownEventError',
|
|
75
|
+
{
|
|
76
|
+
event: LiveStoreEvent.Client.Encoded.mapFields(Struct.pick(['name', 'args', 'seqNum', 'clientId', 'sessionId'])),
|
|
77
|
+
reason: Schema.Literals(['event-definition-missing', 'materializer-missing']),
|
|
78
|
+
operation: Schema.String,
|
|
79
|
+
note: Schema.optional(Schema.String),
|
|
80
|
+
},
|
|
81
|
+
) {}
|
|
82
|
+
|
|
83
|
+
export class MaterializeError extends Schema.TaggedError<MaterializeError>('~@livestore/common/MaterializeError')(
|
|
84
|
+
'MaterializeError',
|
|
85
|
+
{
|
|
86
|
+
cause: Schema.Union([MaterializerHashMismatchError, SqliteError, UnknownEventError]),
|
|
87
|
+
note: Schema.optional(Schema.String),
|
|
88
|
+
},
|
|
89
|
+
) {}
|
package/src/index.ts
CHANGED
|
@@ -2,15 +2,25 @@ export * from './adapter-types.ts'
|
|
|
2
2
|
export * from './bounded-collections.ts'
|
|
3
3
|
export * from './debug-info.ts'
|
|
4
4
|
export * as Devtools from './devtools/mod.ts'
|
|
5
|
+
export * from './leader-thread/RejectedPushError.ts'
|
|
6
|
+
export * as LogConfig from './logging.ts'
|
|
5
7
|
export * from './make-client-session.ts'
|
|
8
|
+
export * as MaterializationJournal from './MaterializationJournal.ts'
|
|
6
9
|
export * from './materializer-helper.ts'
|
|
7
10
|
export * from './otel.ts'
|
|
8
11
|
export * from './rematerialize-from-eventlog.ts'
|
|
9
12
|
export * from './schema/state/sqlite/query-builder/mod.ts'
|
|
10
|
-
export * from './schema/state/sqlite/system-tables.ts'
|
|
13
|
+
export * from './schema/state/sqlite/system-tables/mod.ts'
|
|
11
14
|
export * from './schema-management/migrations.ts'
|
|
15
|
+
export {
|
|
16
|
+
resolveSessionIdSymbolInBindValues,
|
|
17
|
+
SessionIdSymbol,
|
|
18
|
+
type BindableWithSessionIdSymbol,
|
|
19
|
+
} from './session-id-symbol.ts'
|
|
12
20
|
export * as SqliteDbHelper from './sqlite-db-helper.ts'
|
|
21
|
+
export * as StateHead from './StateHead.ts'
|
|
13
22
|
export * from './sync/index.ts'
|
|
14
23
|
export * as SyncState from './sync/syncstate.ts'
|
|
15
24
|
export * from './util.ts'
|
|
16
25
|
export * from './version.ts'
|
|
26
|
+
export * from './WorkerTransportError.ts'
|