@livestore/common 0.3.0-dev.32 → 0.3.0-dev.34
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/adapter-types.d.ts +5 -9
- package/dist/adapter-types.d.ts.map +1 -1
- package/dist/adapter-types.js.map +1 -1
- package/dist/devtools/devtools-messages-client-session.d.ts +22 -21
- package/dist/devtools/devtools-messages-client-session.d.ts.map +1 -1
- package/dist/devtools/devtools-messages-client-session.js +1 -0
- package/dist/devtools/devtools-messages-client-session.js.map +1 -1
- package/dist/devtools/devtools-messages-common.d.ts +6 -6
- package/dist/devtools/devtools-messages-leader.d.ts +25 -25
- package/dist/devtools/devtools-messages-leader.js +1 -1
- package/dist/devtools/devtools-messages-leader.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/leader-thread/LeaderSyncProcessor.d.ts +4 -4
- package/dist/leader-thread/LeaderSyncProcessor.d.ts.map +1 -1
- package/dist/leader-thread/LeaderSyncProcessor.js +21 -17
- package/dist/leader-thread/LeaderSyncProcessor.js.map +1 -1
- package/dist/leader-thread/apply-event.d.ts +4 -4
- package/dist/leader-thread/apply-event.d.ts.map +1 -1
- package/dist/leader-thread/apply-event.js +9 -9
- package/dist/leader-thread/apply-event.js.map +1 -1
- package/dist/leader-thread/eventlog.d.ts.map +1 -1
- package/dist/leader-thread/eventlog.js +11 -15
- package/dist/leader-thread/eventlog.js.map +1 -1
- package/dist/leader-thread/leader-worker-devtools.js +13 -12
- package/dist/leader-thread/leader-worker-devtools.js.map +1 -1
- package/dist/leader-thread/make-leader-thread-layer.d.ts +2 -2
- package/dist/leader-thread/make-leader-thread-layer.d.ts.map +1 -1
- package/dist/leader-thread/make-leader-thread-layer.js +11 -18
- package/dist/leader-thread/make-leader-thread-layer.js.map +1 -1
- package/dist/leader-thread/materialize-event.d.ts +16 -0
- package/dist/leader-thread/materialize-event.d.ts.map +1 -0
- package/dist/leader-thread/materialize-event.js +103 -0
- package/dist/leader-thread/materialize-event.js.map +1 -0
- package/dist/leader-thread/recreate-db.d.ts.map +1 -1
- package/dist/leader-thread/recreate-db.js +9 -17
- package/dist/leader-thread/recreate-db.js.map +1 -1
- package/dist/leader-thread/types.d.ts +5 -5
- package/dist/leader-thread/types.d.ts.map +1 -1
- package/dist/materializer-helper.d.ts.map +1 -1
- package/dist/materializer-helper.js +1 -1
- package/dist/materializer-helper.js.map +1 -1
- package/dist/query-builder/api.d.ts +4 -4
- package/dist/query-builder/api.d.ts.map +1 -1
- package/dist/query-builder/impl.d.ts +2 -2
- package/dist/query-builder/impl.test.d.ts +5 -5
- package/dist/query-builder/mod.d.ts +2 -2
- package/dist/rehydrate-from-eventlog.d.ts +1 -1
- package/dist/rehydrate-from-eventlog.d.ts.map +1 -1
- package/dist/rehydrate-from-eventlog.js +6 -7
- package/dist/rehydrate-from-eventlog.js.map +1 -1
- package/dist/rematerialize-from-eventlog.d.ts +14 -0
- package/dist/rematerialize-from-eventlog.d.ts.map +1 -0
- package/dist/rematerialize-from-eventlog.js +64 -0
- package/dist/rematerialize-from-eventlog.js.map +1 -0
- package/dist/schema/EventDef.d.ts +1 -1
- package/dist/schema/EventDef.d.ts.map +1 -1
- package/dist/schema/EventId.test.js +1 -1
- package/dist/schema/EventId.test.js.map +1 -1
- package/dist/schema/client-document-def.d.ts +2 -2
- package/dist/schema/db-schema/dsl/mod.d.ts +3 -3
- package/dist/schema/db-schema/mod.d.ts +2 -2
- package/dist/schema/mod.d.ts +4 -4
- package/dist/schema/mod.d.ts.map +1 -1
- package/dist/schema/mod.js +4 -4
- package/dist/schema/mod.js.map +1 -1
- package/dist/schema/schema-helpers.d.ts +1 -1
- package/dist/schema/schema.d.ts +12 -14
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/schema/schema.js +5 -28
- package/dist/schema/schema.js.map +1 -1
- package/dist/schema/state/mod.d.ts +3 -0
- package/dist/schema/state/mod.d.ts.map +1 -0
- package/dist/schema/state/mod.js +3 -0
- package/dist/schema/state/mod.js.map +1 -0
- package/dist/schema/state/sqlite/client-document-def.d.ts +223 -0
- package/dist/schema/state/sqlite/client-document-def.d.ts.map +1 -0
- package/dist/schema/state/sqlite/client-document-def.js +170 -0
- package/dist/schema/state/sqlite/client-document-def.js.map +1 -0
- package/dist/schema/state/sqlite/client-document-def.test.d.ts +2 -0
- package/dist/schema/state/sqlite/client-document-def.test.d.ts.map +1 -0
- package/dist/schema/state/sqlite/client-document-def.test.js +201 -0
- package/dist/schema/state/sqlite/client-document-def.test.js.map +1 -0
- package/dist/schema/state/sqlite/db-schema/ast/sqlite.d.ts +69 -0
- package/dist/schema/state/sqlite/db-schema/ast/sqlite.d.ts.map +1 -0
- package/dist/schema/state/sqlite/db-schema/ast/sqlite.js +71 -0
- package/dist/schema/state/sqlite/db-schema/ast/sqlite.js.map +1 -0
- package/dist/schema/state/sqlite/db-schema/ast/validate.d.ts +3 -0
- package/dist/schema/state/sqlite/db-schema/ast/validate.d.ts.map +1 -0
- package/dist/schema/state/sqlite/db-schema/ast/validate.js +12 -0
- package/dist/schema/state/sqlite/db-schema/ast/validate.js.map +1 -0
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.d.ts +90 -0
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.d.ts.map +1 -0
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.js +87 -0
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.js.map +1 -0
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.test.d.ts +2 -0
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.test.d.ts.map +1 -0
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.test.js +29 -0
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.test.js.map +1 -0
- package/dist/schema/state/sqlite/db-schema/dsl/mod.d.ts +90 -0
- package/dist/schema/state/sqlite/db-schema/dsl/mod.d.ts.map +1 -0
- package/dist/schema/state/sqlite/db-schema/dsl/mod.js +41 -0
- package/dist/schema/state/sqlite/db-schema/dsl/mod.js.map +1 -0
- package/dist/schema/state/sqlite/db-schema/hash.d.ts +2 -0
- package/dist/schema/state/sqlite/db-schema/hash.d.ts.map +1 -0
- package/dist/schema/state/sqlite/db-schema/hash.js +14 -0
- package/dist/schema/state/sqlite/db-schema/hash.js.map +1 -0
- package/dist/schema/state/sqlite/db-schema/mod.d.ts +3 -0
- package/dist/schema/state/sqlite/db-schema/mod.d.ts.map +1 -0
- package/dist/schema/state/sqlite/db-schema/mod.js +3 -0
- package/dist/schema/state/sqlite/db-schema/mod.js.map +1 -0
- package/dist/schema/state/sqlite/mod.d.ts +17 -0
- package/dist/schema/state/sqlite/mod.d.ts.map +1 -0
- package/dist/schema/state/sqlite/mod.js +41 -0
- package/dist/schema/state/sqlite/mod.js.map +1 -0
- package/dist/schema/state/sqlite/query-builder/api.d.ts +293 -0
- package/dist/schema/state/sqlite/query-builder/api.d.ts.map +1 -0
- package/dist/schema/state/sqlite/query-builder/api.js +6 -0
- package/dist/schema/state/sqlite/query-builder/api.js.map +1 -0
- package/dist/schema/state/sqlite/query-builder/astToSql.d.ts +7 -0
- package/dist/schema/state/sqlite/query-builder/astToSql.d.ts.map +1 -0
- package/dist/schema/state/sqlite/query-builder/astToSql.js +190 -0
- package/dist/schema/state/sqlite/query-builder/astToSql.js.map +1 -0
- package/dist/schema/state/sqlite/query-builder/impl.d.ts +7 -0
- package/dist/schema/state/sqlite/query-builder/impl.d.ts.map +1 -0
- package/dist/schema/state/sqlite/query-builder/impl.js +286 -0
- package/dist/schema/state/sqlite/query-builder/impl.js.map +1 -0
- package/dist/schema/state/sqlite/query-builder/impl.test.d.ts +87 -0
- package/dist/schema/state/sqlite/query-builder/impl.test.d.ts.map +1 -0
- package/dist/schema/state/sqlite/query-builder/impl.test.js +554 -0
- package/dist/schema/state/sqlite/query-builder/impl.test.js.map +1 -0
- package/dist/schema/state/sqlite/query-builder/mod.d.ts +17 -0
- package/dist/schema/state/sqlite/query-builder/mod.d.ts.map +1 -0
- package/dist/schema/state/sqlite/query-builder/mod.js +17 -0
- package/dist/schema/state/sqlite/query-builder/mod.js.map +1 -0
- package/dist/schema/state/sqlite/schema-helpers.d.ts +4 -0
- package/dist/schema/state/sqlite/schema-helpers.d.ts.map +1 -0
- package/dist/schema/state/sqlite/schema-helpers.js +30 -0
- package/dist/schema/state/sqlite/schema-helpers.js.map +1 -0
- package/dist/schema/state/sqlite/sqlite-state.d.ts +12 -0
- package/dist/schema/state/sqlite/sqlite-state.d.ts.map +1 -0
- package/dist/schema/state/sqlite/sqlite-state.js +36 -0
- package/dist/schema/state/sqlite/sqlite-state.js.map +1 -0
- package/dist/schema/state/sqlite/system-tables.d.ts +574 -0
- package/dist/schema/state/sqlite/system-tables.d.ts.map +1 -0
- package/dist/schema/state/sqlite/system-tables.js +87 -0
- package/dist/schema/state/sqlite/system-tables.js.map +1 -0
- package/dist/schema/state/sqlite/table-def.d.ts +84 -0
- package/dist/schema/state/sqlite/table-def.d.ts.map +1 -0
- package/dist/schema/state/sqlite/table-def.js +36 -0
- package/dist/schema/state/sqlite/table-def.js.map +1 -0
- package/dist/schema/state/state.d.ts +3 -0
- package/dist/schema/state/state.d.ts.map +1 -0
- package/dist/schema/state/state.js +3 -0
- package/dist/schema/state/state.js.map +1 -0
- package/dist/schema/state.d.ts +3 -0
- package/dist/schema/state.d.ts.map +1 -0
- package/dist/schema/state.js +3 -0
- package/dist/schema/state.js.map +1 -0
- package/dist/schema/system-tables.d.ts +7 -433
- package/dist/schema/system-tables.d.ts.map +1 -1
- package/dist/schema/system-tables.js +1 -1
- package/dist/schema/system-tables.js.map +1 -1
- package/dist/schema/table-def.d.ts +2 -2
- package/dist/schema-management/migrations.d.ts +1 -1
- package/dist/schema-management/migrations.d.ts.map +1 -1
- package/dist/schema-management/migrations.js +14 -12
- package/dist/schema-management/migrations.js.map +1 -1
- package/dist/schema-management/validate-schema.d.ts +8 -0
- package/dist/schema-management/validate-schema.d.ts.map +1 -0
- package/dist/schema-management/validate-schema.js +39 -0
- package/dist/schema-management/validate-schema.js.map +1 -0
- package/dist/sql-queries/sql-queries.d.ts +1 -1
- package/dist/sql-queries/sql-queries.d.ts.map +1 -1
- package/dist/sql-queries/sql-query-builder.d.ts +1 -1
- package/dist/sql-queries/sql-query-builder.d.ts.map +1 -1
- package/dist/sql-queries/types.d.ts +1 -1
- package/dist/sql-queries/types.d.ts.map +1 -1
- package/dist/sync/ClientSessionSyncProcessor.d.ts +3 -3
- package/dist/sync/ClientSessionSyncProcessor.d.ts.map +1 -1
- package/dist/sync/ClientSessionSyncProcessor.js +6 -6
- package/dist/sync/ClientSessionSyncProcessor.js.map +1 -1
- package/dist/sync/syncstate.d.ts +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -3
- package/src/adapter-types.ts +4 -10
- package/src/devtools/devtools-messages-client-session.ts +1 -0
- package/src/devtools/devtools-messages-leader.ts +1 -1
- package/src/index.ts +3 -3
- package/src/leader-thread/LeaderSyncProcessor.ts +28 -30
- package/src/leader-thread/eventlog.ts +12 -17
- package/src/leader-thread/leader-worker-devtools.ts +15 -12
- package/src/leader-thread/make-leader-thread-layer.ts +15 -21
- package/src/leader-thread/{apply-event.ts → materialize-event.ts} +22 -28
- package/src/leader-thread/recreate-db.ts +9 -21
- package/src/leader-thread/types.ts +5 -5
- package/src/materializer-helper.ts +1 -1
- package/src/{rehydrate-from-eventlog.ts → rematerialize-from-eventlog.ts} +41 -38
- package/src/schema/EventDef.ts +1 -1
- package/src/schema/EventId.test.ts +1 -1
- package/src/schema/mod.ts +4 -4
- package/src/schema/schema.ts +18 -52
- package/src/schema/state/mod.ts +2 -0
- package/src/schema/{client-document-def.test.ts → state/sqlite/client-document-def.test.ts} +2 -2
- package/src/schema/{client-document-def.ts → state/sqlite/client-document-def.ts} +6 -6
- package/src/schema/{sqlite-state.ts → state/sqlite/mod.ts} +17 -6
- package/src/{query-builder → schema/state/sqlite/query-builder}/api.ts +21 -22
- package/src/{query-builder → schema/state/sqlite/query-builder}/astToSql.ts +3 -3
- package/src/{query-builder → schema/state/sqlite/query-builder}/impl.test.ts +1 -1
- package/src/{query-builder → schema/state/sqlite/query-builder}/impl.ts +3 -4
- package/src/schema/{schema-helpers.ts → state/sqlite/schema-helpers.ts} +1 -1
- package/src/schema/{system-tables.ts → state/sqlite/system-tables.ts} +6 -5
- package/src/schema/{table-def.ts → state/sqlite/table-def.ts} +2 -2
- package/src/schema-management/migrations.ts +17 -15
- package/src/sql-queries/sql-queries.ts +1 -1
- package/src/sql-queries/sql-query-builder.ts +1 -1
- package/src/sql-queries/types.ts +1 -1
- package/src/sync/ClientSessionSyncProcessor.ts +7 -7
- package/src/version.ts +1 -1
- package/src/schema/view.ts +0 -2
- package/tmp/pack.tgz +0 -0
- package/tsconfig.json +0 -12
- /package/src/schema/{db-schema → state/sqlite/db-schema}/ast/sqlite.ts +0 -0
- /package/src/schema/{db-schema → state/sqlite/db-schema}/ast/validate.ts +0 -0
- /package/src/schema/{db-schema → state/sqlite/db-schema}/dsl/__snapshots__/field-defs.test.ts.snap +0 -0
- /package/src/schema/{db-schema → state/sqlite/db-schema}/dsl/field-defs.test.ts +0 -0
- /package/src/schema/{db-schema → state/sqlite/db-schema}/dsl/field-defs.ts +0 -0
- /package/src/schema/{db-schema → state/sqlite/db-schema}/dsl/mod.ts +0 -0
- /package/src/schema/{db-schema → state/sqlite/db-schema}/hash.ts +0 -0
- /package/src/schema/{db-schema → state/sqlite/db-schema}/mod.ts +0 -0
- /package/src/{query-builder → schema/state/sqlite/query-builder}/mod.ts +0 -0
- /package/src/schema-management/{validate-mutation-defs.ts → validate-schema.ts} +0 -0
@@ -2,7 +2,7 @@ import { Effect, FiberMap, Option, Stream, SubscriptionRef } from '@livestore/ut
|
|
2
2
|
import { nanoid } from '@livestore/utils/nanoid'
|
3
3
|
|
4
4
|
import { Devtools, IntentionalShutdownCause, liveStoreVersion, UnexpectedError } from '../index.js'
|
5
|
-
import {
|
5
|
+
import { SystemTables } from '../schema/mod.js'
|
6
6
|
import type { DevtoolsOptions, PersistenceInfoPair } from './types.js'
|
7
7
|
import { LeaderThreadCtx } from './types.js'
|
8
8
|
|
@@ -62,7 +62,7 @@ const listenToDevtools = ({
|
|
62
62
|
const {
|
63
63
|
syncBackend,
|
64
64
|
makeSqliteDb,
|
65
|
-
|
65
|
+
dbState,
|
66
66
|
dbEventlog,
|
67
67
|
shutdownStateSubRef,
|
68
68
|
shutdownChannel,
|
@@ -109,7 +109,7 @@ const listenToDevtools = ({
|
|
109
109
|
return
|
110
110
|
}
|
111
111
|
case 'LSD.Leader.SnapshotReq': {
|
112
|
-
const snapshot =
|
112
|
+
const snapshot = dbState.export()
|
113
113
|
|
114
114
|
yield* sendMessage(Devtools.Leader.SnapshotRes.make({ snapshot, ...reqPayload }))
|
115
115
|
|
@@ -143,18 +143,21 @@ const listenToDevtools = ({
|
|
143
143
|
}
|
144
144
|
|
145
145
|
try {
|
146
|
-
if (tableNames.has(EVENTLOG_META_TABLE)) {
|
147
|
-
// Is eventlog
|
146
|
+
if (tableNames.has(SystemTables.EVENTLOG_META_TABLE)) {
|
147
|
+
// Is eventlog db
|
148
148
|
yield* SubscriptionRef.set(shutdownStateSubRef, 'shutting-down')
|
149
149
|
|
150
150
|
dbEventlog.import(data)
|
151
151
|
|
152
|
-
|
153
|
-
} else if (
|
154
|
-
|
152
|
+
dbState.destroy()
|
153
|
+
} else if (
|
154
|
+
tableNames.has(SystemTables.SCHEMA_META_TABLE) &&
|
155
|
+
tableNames.has(SystemTables.SCHEMA_EVENT_DEFS_META_TABLE)
|
156
|
+
) {
|
157
|
+
// Is state db
|
155
158
|
yield* SubscriptionRef.set(shutdownStateSubRef, 'shutting-down')
|
156
159
|
|
157
|
-
|
160
|
+
dbState.import(data)
|
158
161
|
|
159
162
|
dbEventlog.destroy()
|
160
163
|
} else {
|
@@ -187,7 +190,7 @@ const listenToDevtools = ({
|
|
187
190
|
|
188
191
|
yield* SubscriptionRef.set(shutdownStateSubRef, 'shutting-down')
|
189
192
|
|
190
|
-
|
193
|
+
dbState.destroy()
|
191
194
|
|
192
195
|
if (mode === 'all-data') {
|
193
196
|
dbEventlog.destroy()
|
@@ -206,12 +209,12 @@ const listenToDevtools = ({
|
|
206
209
|
}
|
207
210
|
|
208
211
|
const dbSizeQuery = `SELECT page_count * page_size as size FROM pragma_page_count(), pragma_page_size();`
|
209
|
-
const dbFileSize =
|
212
|
+
const dbFileSize = dbState.select<{ size: number }>(dbSizeQuery, undefined)[0]!.size
|
210
213
|
const eventlogFileSize = dbEventlog.select<{ size: number }>(dbSizeQuery, undefined)[0]!.size
|
211
214
|
|
212
215
|
yield* sendMessage(
|
213
216
|
Devtools.Leader.DatabaseFileInfoRes.make({
|
214
|
-
|
217
|
+
state: { fileSize: dbFileSize, persistenceInfo: persistenceInfo.state },
|
215
218
|
eventlog: { fileSize: eventlogFileSize, persistenceInfo: persistenceInfo.eventlog },
|
216
219
|
...reqPayload,
|
217
220
|
}),
|
@@ -1,17 +1,17 @@
|
|
1
1
|
import type { HttpClient, Schema, Scope } from '@livestore/utils/effect'
|
2
2
|
import { Deferred, Effect, Layer, Queue, SubscriptionRef } from '@livestore/utils/effect'
|
3
3
|
|
4
|
-
import type { BootStatus, MakeSqliteDb,
|
4
|
+
import type { BootStatus, MakeSqliteDb, SqliteError } from '../adapter-types.js'
|
5
5
|
import { UnexpectedError } from '../adapter-types.js'
|
6
6
|
import type * as Devtools from '../devtools/mod.js'
|
7
7
|
import type { LiveStoreSchema } from '../schema/mod.js'
|
8
8
|
import { LiveStoreEvent } from '../schema/mod.js'
|
9
9
|
import type { InvalidPullError, IsOfflineError, SyncOptions } from '../sync/sync.js'
|
10
10
|
import { sql } from '../util.js'
|
11
|
-
import { makeApplyEvent } from './apply-event.js'
|
12
11
|
import * as Eventlog from './eventlog.js'
|
13
12
|
import { bootDevtools } from './leader-worker-devtools.js'
|
14
13
|
import { makeLeaderSyncProcessor } from './LeaderSyncProcessor.js'
|
14
|
+
import { makeMaterializeEvent } from './materialize-event.js'
|
15
15
|
import { recreateDb } from './recreate-db.js'
|
16
16
|
import type { ShutdownChannel } from './shutdown-channel.js'
|
17
17
|
import type {
|
@@ -30,7 +30,7 @@ export interface MakeLeaderThreadLayerParams {
|
|
30
30
|
schema: LiveStoreSchema
|
31
31
|
makeSqliteDb: MakeSqliteDb
|
32
32
|
syncOptions: SyncOptions | undefined
|
33
|
-
|
33
|
+
dbState: LeaderSqliteDb
|
34
34
|
dbEventlog: LeaderSqliteDb
|
35
35
|
devtoolsOptions: DevtoolsOptions
|
36
36
|
shutdownChannel: ShutdownChannel
|
@@ -54,7 +54,7 @@ export const makeLeaderThreadLayer = ({
|
|
54
54
|
syncPayload,
|
55
55
|
makeSqliteDb,
|
56
56
|
syncOptions,
|
57
|
-
|
57
|
+
dbState,
|
58
58
|
dbEventlog,
|
59
59
|
devtoolsOptions,
|
60
60
|
shutdownChannel,
|
@@ -69,8 +69,8 @@ export const makeLeaderThreadLayer = ({
|
|
69
69
|
const dbEventlogMissing =
|
70
70
|
dbEventlog.select<{ count: number }>(sql`select count(*) as count from sqlite_master`)[0]!.count === 0
|
71
71
|
|
72
|
-
const
|
73
|
-
|
72
|
+
const dbStateMissing =
|
73
|
+
dbState.select<{ count: number }>(sql`select count(*) as count from sqlite_master`)[0]!.count === 0
|
74
74
|
|
75
75
|
const syncBackend =
|
76
76
|
syncOptions?.backend === undefined
|
@@ -91,8 +91,8 @@ export const makeLeaderThreadLayer = ({
|
|
91
91
|
schema,
|
92
92
|
dbEventlogMissing,
|
93
93
|
dbEventlog,
|
94
|
-
|
95
|
-
|
94
|
+
dbState,
|
95
|
+
dbStateMissing,
|
96
96
|
initialBlockingSyncContext,
|
97
97
|
onError: syncOptions?.onSyncError ?? 'ignore',
|
98
98
|
params: {
|
@@ -116,14 +116,14 @@ export const makeLeaderThreadLayer = ({
|
|
116
116
|
}
|
117
117
|
: { enabled: false as const }
|
118
118
|
|
119
|
-
const
|
119
|
+
const materializeEvent = yield* makeMaterializeEvent({ schema, dbState, dbEventlog })
|
120
120
|
|
121
121
|
const ctx = {
|
122
122
|
schema,
|
123
123
|
bootStatusQueue,
|
124
124
|
storeId,
|
125
125
|
clientId,
|
126
|
-
|
126
|
+
dbState,
|
127
127
|
dbEventlog,
|
128
128
|
makeSqliteDb,
|
129
129
|
eventSchema: LiveStoreEvent.makeEventDefSchema(schema),
|
@@ -131,7 +131,7 @@ export const makeLeaderThreadLayer = ({
|
|
131
131
|
shutdownChannel,
|
132
132
|
syncBackend,
|
133
133
|
syncProcessor,
|
134
|
-
|
134
|
+
materializeEvent,
|
135
135
|
extraIncomingMessagesQueue,
|
136
136
|
devtools: devtoolsContext,
|
137
137
|
// State will be set during `bootLeaderThread`
|
@@ -144,7 +144,7 @@ export const makeLeaderThreadLayer = ({
|
|
144
144
|
const layer = Layer.succeed(LeaderThreadCtx, ctx)
|
145
145
|
|
146
146
|
ctx.initialState = yield* bootLeaderThread({
|
147
|
-
|
147
|
+
dbStateMissing,
|
148
148
|
initialBlockingSyncContext,
|
149
149
|
devtoolsOptions,
|
150
150
|
}).pipe(Effect.provide(layer))
|
@@ -210,11 +210,11 @@ const makeInitialBlockingSyncContext = ({
|
|
210
210
|
* It also starts various background processes (e.g. syncing)
|
211
211
|
*/
|
212
212
|
const bootLeaderThread = ({
|
213
|
-
|
213
|
+
dbStateMissing,
|
214
214
|
initialBlockingSyncContext,
|
215
215
|
devtoolsOptions,
|
216
216
|
}: {
|
217
|
-
|
217
|
+
dbStateMissing: boolean
|
218
218
|
initialBlockingSyncContext: InitialBlockingSyncContext
|
219
219
|
devtoolsOptions: DevtoolsOptions
|
220
220
|
}): Effect.Effect<
|
@@ -227,13 +227,7 @@ const bootLeaderThread = ({
|
|
227
227
|
|
228
228
|
yield* Eventlog.initEventlogDb(dbEventlog)
|
229
229
|
|
230
|
-
|
231
|
-
if (dbReadModelMissing) {
|
232
|
-
const recreateResult = yield* recreateDb
|
233
|
-
migrationsReport = recreateResult.migrationsReport
|
234
|
-
} else {
|
235
|
-
migrationsReport = { migrations: [] }
|
236
|
-
}
|
230
|
+
const { migrationsReport } = dbStateMissing ? yield* recreateDb : { migrationsReport: { migrations: [] } }
|
237
231
|
|
238
232
|
// NOTE the sync processor depends on the dbs being initialized properly
|
239
233
|
const { initialLeaderHead } = yield* syncProcessor.boot
|
@@ -3,29 +3,23 @@ import { Effect, ReadonlyArray, Schema } from '@livestore/utils/effect'
|
|
3
3
|
|
4
4
|
import type { SqliteDb } from '../adapter-types.js'
|
5
5
|
import { getExecArgsFromEvent } from '../materializer-helper.js'
|
6
|
-
import type { LiveStoreSchema
|
7
|
-
import {
|
8
|
-
EventId,
|
9
|
-
EVENTLOG_META_TABLE,
|
10
|
-
getEventDef,
|
11
|
-
SESSION_CHANGESET_META_TABLE,
|
12
|
-
sessionChangesetMetaTable,
|
13
|
-
} from '../schema/mod.js'
|
6
|
+
import type { LiveStoreSchema } from '../schema/mod.js'
|
7
|
+
import { EventId, getEventDef, SystemTables } from '../schema/mod.js'
|
14
8
|
import { insertRow } from '../sql-queries/index.js'
|
15
9
|
import { sql } from '../util.js'
|
16
10
|
import { execSql, execSqlPrepared } from './connection.js'
|
17
11
|
import * as Eventlog from './eventlog.js'
|
18
|
-
import type {
|
12
|
+
import type { MaterializeEvent } from './types.js'
|
19
13
|
|
20
|
-
export const
|
14
|
+
export const makeMaterializeEvent = ({
|
21
15
|
schema,
|
22
|
-
|
16
|
+
dbState: db,
|
23
17
|
dbEventlog,
|
24
18
|
}: {
|
25
19
|
schema: LiveStoreSchema
|
26
|
-
|
20
|
+
dbState: SqliteDb
|
27
21
|
dbEventlog: SqliteDb
|
28
|
-
}): Effect.Effect<
|
22
|
+
}): Effect.Effect<MaterializeEvent, never> =>
|
29
23
|
Effect.gen(function* () {
|
30
24
|
const eventDefSchemaHashMap = new Map(
|
31
25
|
// TODO Running `Schema.hash` can be a bottleneck for larger schemas. There is an opportunity to run this
|
@@ -55,7 +49,7 @@ export const makeApplyEvent = ({
|
|
55
49
|
// },
|
56
50
|
// })
|
57
51
|
|
58
|
-
// console.group('[@livestore/common:leader-thread:
|
52
|
+
// console.group('[@livestore/common:leader-thread:materializeEvent]', { eventName })
|
59
53
|
|
60
54
|
const session = db.session()
|
61
55
|
|
@@ -72,8 +66,8 @@ export const makeApplyEvent = ({
|
|
72
66
|
yield* execSql(
|
73
67
|
db,
|
74
68
|
...insertRow({
|
75
|
-
tableName: SESSION_CHANGESET_META_TABLE,
|
76
|
-
columns: sessionChangesetMetaTable.sqliteDef.columns,
|
69
|
+
tableName: SystemTables.SESSION_CHANGESET_META_TABLE,
|
70
|
+
columns: SystemTables.sessionChangesetMetaTable.sqliteDef.columns,
|
77
71
|
values: {
|
78
72
|
idGlobal: eventEncoded.id.global,
|
79
73
|
idClient: eventEncoded.id.client,
|
@@ -113,30 +107,30 @@ export const makeApplyEvent = ({
|
|
113
107
|
: { _tag: 'no-op' as const },
|
114
108
|
}
|
115
109
|
}).pipe(
|
116
|
-
Effect.withSpan(`@livestore/common:leader-thread:
|
110
|
+
Effect.withSpan(`@livestore/common:leader-thread:materializeEvent`, {
|
117
111
|
attributes: {
|
118
112
|
eventName: eventEncoded.name,
|
119
|
-
|
113
|
+
eventId: eventEncoded.id,
|
120
114
|
'span.label': `${EventId.toString(eventEncoded.id)} ${eventEncoded.name}`,
|
121
115
|
},
|
122
116
|
}),
|
123
|
-
// Effect.logDuration('@livestore/common:leader-thread:
|
117
|
+
// Effect.logDuration('@livestore/common:leader-thread:materializeEvent'),
|
124
118
|
)
|
125
119
|
})
|
126
120
|
|
127
121
|
export const rollback = ({
|
128
|
-
|
122
|
+
dbState,
|
129
123
|
dbEventlog,
|
130
124
|
eventIdsToRollback,
|
131
125
|
}: {
|
132
|
-
|
126
|
+
dbState: SqliteDb
|
133
127
|
dbEventlog: SqliteDb
|
134
128
|
eventIdsToRollback: EventId.EventId[]
|
135
129
|
}) =>
|
136
130
|
Effect.gen(function* () {
|
137
|
-
const rollbackEvents =
|
138
|
-
.select<SessionChangesetMetaRow>(
|
139
|
-
sql`SELECT * FROM ${SESSION_CHANGESET_META_TABLE} WHERE (idGlobal, idClient) IN (${eventIdsToRollback.map((id) => `(${id.global}, ${id.client})`).join(', ')})`,
|
131
|
+
const rollbackEvents = dbState
|
132
|
+
.select<SystemTables.SessionChangesetMetaRow>(
|
133
|
+
sql`SELECT * FROM ${SystemTables.SESSION_CHANGESET_META_TABLE} WHERE (idGlobal, idClient) IN (${eventIdsToRollback.map((id) => `(${id.global}, ${id.client})`).join(', ')})`,
|
140
134
|
)
|
141
135
|
.map((_) => ({ id: { global: _.idGlobal, client: _.idClient }, changeset: _.changeset, debug: _.debug }))
|
142
136
|
.toSorted((a, b) => EventId.compare(a.id, b.id))
|
@@ -145,7 +139,7 @@ export const rollback = ({
|
|
145
139
|
for (let i = rollbackEvents.length - 1; i >= 0; i--) {
|
146
140
|
const { changeset } = rollbackEvents[i]!
|
147
141
|
if (changeset !== null) {
|
148
|
-
|
142
|
+
dbState.makeChangeset(changeset).invert().apply()
|
149
143
|
}
|
150
144
|
}
|
151
145
|
|
@@ -155,15 +149,15 @@ export const rollback = ({
|
|
155
149
|
|
156
150
|
// Delete the changeset rows
|
157
151
|
for (const eventIdPairChunk of eventIdPairChunks) {
|
158
|
-
|
159
|
-
sql`DELETE FROM ${SESSION_CHANGESET_META_TABLE} WHERE (idGlobal, idClient) IN (${eventIdPairChunk.join(', ')})`,
|
152
|
+
dbState.execute(
|
153
|
+
sql`DELETE FROM ${SystemTables.SESSION_CHANGESET_META_TABLE} WHERE (idGlobal, idClient) IN (${eventIdPairChunk.join(', ')})`,
|
160
154
|
)
|
161
155
|
}
|
162
156
|
|
163
157
|
// Delete the eventlog rows
|
164
158
|
for (const eventIdPairChunk of eventIdPairChunks) {
|
165
159
|
dbEventlog.execute(
|
166
|
-
sql`DELETE FROM ${EVENTLOG_META_TABLE} WHERE (idGlobal, idClient) IN (${eventIdPairChunk.join(', ')})`,
|
160
|
+
sql`DELETE FROM ${SystemTables.EVENTLOG_META_TABLE} WHERE (idGlobal, idClient) IN (${eventIdPairChunk.join(', ')})`,
|
167
161
|
)
|
168
162
|
}
|
169
163
|
}).pipe(
|
@@ -3,7 +3,7 @@ import type { HttpClient } from '@livestore/utils/effect'
|
|
3
3
|
import { Effect, Queue } from '@livestore/utils/effect'
|
4
4
|
|
5
5
|
import type { InvalidPullError, IsOfflineError, MigrationHooks, MigrationsReport, SqliteError } from '../index.js'
|
6
|
-
import { migrateDb,
|
6
|
+
import { migrateDb, rematerializeFromEventlog, UnexpectedError } from '../index.js'
|
7
7
|
import { configureConnection } from './connection.js'
|
8
8
|
import { LeaderThreadCtx } from './types.js'
|
9
9
|
|
@@ -12,14 +12,14 @@ export const recreateDb: Effect.Effect<
|
|
12
12
|
UnexpectedError | SqliteError | IsOfflineError | InvalidPullError,
|
13
13
|
LeaderThreadCtx | HttpClient.HttpClient
|
14
14
|
> = Effect.gen(function* () {
|
15
|
-
const {
|
15
|
+
const { dbState, dbEventlog, schema, bootStatusQueue, materializeEvent } = yield* LeaderThreadCtx
|
16
16
|
|
17
|
-
const migrationOptions = schema.
|
17
|
+
const migrationOptions = schema.state.sqlite.migrations
|
18
18
|
let migrationsReport: MigrationsReport
|
19
19
|
|
20
20
|
yield* Effect.addFinalizer(
|
21
21
|
Effect.fn('recreateDb:finalizer')(function* (ex) {
|
22
|
-
if (ex._tag === 'Failure')
|
22
|
+
if (ex._tag === 'Failure') dbState.destroy()
|
23
23
|
}),
|
24
24
|
)
|
25
25
|
|
@@ -27,7 +27,7 @@ export const recreateDb: Effect.Effect<
|
|
27
27
|
// and later we'll overwrite the persisted database with the new data
|
28
28
|
// TODO bring back this optimization
|
29
29
|
// const tmpDb = yield* makeSqliteDb({ _tag: 'in-memory' })
|
30
|
-
const tmpDb =
|
30
|
+
const tmpDb = dbState
|
31
31
|
yield* configureConnection(tmpDb, { foreignKeys: true })
|
32
32
|
|
33
33
|
const initDb = (hooks: Partial<MigrationHooks> | undefined) =>
|
@@ -47,17 +47,17 @@ export const recreateDb: Effect.Effect<
|
|
47
47
|
})
|
48
48
|
|
49
49
|
switch (migrationOptions.strategy) {
|
50
|
-
case '
|
50
|
+
case 'auto': {
|
51
51
|
const hooks = migrationOptions.hooks
|
52
52
|
const initResult = yield* initDb(hooks)
|
53
53
|
|
54
54
|
migrationsReport = initResult.migrationsReport
|
55
55
|
|
56
|
-
yield*
|
56
|
+
yield* rematerializeFromEventlog({
|
57
57
|
// db: initResult.tmpDb,
|
58
58
|
dbEventlog,
|
59
59
|
schema,
|
60
|
-
|
60
|
+
materializeEvent,
|
61
61
|
onProgress: ({ done, total }) =>
|
62
62
|
Queue.offer(bootStatusQueue, { stage: 'rehydrating', progress: { done, total } }),
|
63
63
|
})
|
@@ -66,20 +66,8 @@ export const recreateDb: Effect.Effect<
|
|
66
66
|
|
67
67
|
break
|
68
68
|
}
|
69
|
-
case 'hard-reset': {
|
70
|
-
const hooks = migrationOptions.hooks
|
71
|
-
const initResult = yield* initDb(hooks)
|
72
|
-
|
73
|
-
migrationsReport = initResult.migrationsReport
|
74
|
-
|
75
|
-
// The database is migrated but empty now, so nothing else to do
|
76
|
-
|
77
|
-
yield* Effect.tryAll(() => hooks?.post?.(initResult.tmpDb)).pipe(UnexpectedError.mapToUnexpectedError)
|
78
|
-
|
79
|
-
break
|
80
|
-
}
|
81
69
|
case 'manual': {
|
82
|
-
const oldDbData =
|
70
|
+
const oldDbData = dbState.export()
|
83
71
|
|
84
72
|
migrationsReport = { migrations: [] }
|
85
73
|
|
@@ -52,7 +52,7 @@ export type InitialSyncInfo = Option.Option<{
|
|
52
52
|
// | { _tag: 'Reuse'; syncInfo: InitialSyncInfo }
|
53
53
|
|
54
54
|
export type LeaderSqliteDb = SqliteDb<{ dbPointer: number; persistenceInfo: PersistenceInfo }>
|
55
|
-
export type PersistenceInfoPair = {
|
55
|
+
export type PersistenceInfoPair = { state: PersistenceInfo; eventlog: PersistenceInfo }
|
56
56
|
|
57
57
|
export type DevtoolsOptions =
|
58
58
|
| {
|
@@ -89,7 +89,7 @@ export class LeaderThreadCtx extends Context.Tag('LeaderThreadCtx')<
|
|
89
89
|
storeId: string
|
90
90
|
clientId: string
|
91
91
|
makeSqliteDb: MakeSqliteDb
|
92
|
-
|
92
|
+
dbState: LeaderSqliteDb
|
93
93
|
dbEventlog: LeaderSqliteDb
|
94
94
|
bootStatusQueue: Queue.Queue<BootStatus>
|
95
95
|
// TODO we should find a more elegant way to handle cases which need this ref for their implementation
|
@@ -99,7 +99,7 @@ export class LeaderThreadCtx extends Context.Tag('LeaderThreadCtx')<
|
|
99
99
|
devtools: DevtoolsContext
|
100
100
|
syncBackend: SyncBackend | undefined
|
101
101
|
syncProcessor: LeaderSyncProcessor
|
102
|
-
|
102
|
+
materializeEvent: MaterializeEvent
|
103
103
|
initialState: {
|
104
104
|
leaderHead: EventId.EventId
|
105
105
|
migrationsReport: MigrationsReport
|
@@ -113,10 +113,10 @@ export class LeaderThreadCtx extends Context.Tag('LeaderThreadCtx')<
|
|
113
113
|
}
|
114
114
|
>() {}
|
115
115
|
|
116
|
-
export type
|
116
|
+
export type MaterializeEvent = (
|
117
117
|
eventEncoded: LiveStoreEvent.EncodedWithMeta,
|
118
118
|
options?: {
|
119
|
-
/** Needed for
|
119
|
+
/** Needed for rematerializeFromEventlog */
|
120
120
|
skipEventlog?: boolean
|
121
121
|
},
|
122
122
|
) => Effect.Effect<
|
@@ -2,9 +2,9 @@ import { isReadonlyArray } from '@livestore/utils'
|
|
2
2
|
import { Schema } from '@livestore/utils/effect'
|
3
3
|
|
4
4
|
import { SessionIdSymbol } from './adapter-types.js'
|
5
|
-
import { isQueryBuilder } from './query-builder/api.js'
|
6
5
|
import type { EventDef, Materializer, MaterializerResult } from './schema/EventDef.js'
|
7
6
|
import type * as LiveStoreEvent from './schema/LiveStoreEvent.js'
|
7
|
+
import { isQueryBuilder } from './schema/state/sqlite/query-builder/api.js'
|
8
8
|
import type { BindValues } from './sql-queries/sql-queries.js'
|
9
9
|
import type { PreparedBindValues } from './util.js'
|
10
10
|
import { prepareBindValues } from './util.js'
|
@@ -2,38 +2,41 @@ import { memoizeByRef } from '@livestore/utils'
|
|
2
2
|
import { Chunk, Effect, Option, Schema, Stream } from '@livestore/utils/effect'
|
3
3
|
|
4
4
|
import { type SqliteDb, UnexpectedError } from './adapter-types.js'
|
5
|
-
import type {
|
6
|
-
import type { EventDef,
|
7
|
-
import { EventId,
|
5
|
+
import type { MaterializeEvent } from './leader-thread/mod.js'
|
6
|
+
import type { EventDef, LiveStoreSchema } from './schema/mod.js'
|
7
|
+
import { EventId, getEventDef, LiveStoreEvent, SystemTables } from './schema/mod.js'
|
8
8
|
import type { PreparedBindValues } from './util.js'
|
9
9
|
import { sql } from './util.js'
|
10
10
|
|
11
|
-
export const
|
11
|
+
export const rematerializeFromEventlog = ({
|
12
12
|
dbEventlog,
|
13
13
|
// TODO re-use this db when bringing back the boot in-memory db implementation
|
14
14
|
// db,
|
15
15
|
schema,
|
16
16
|
onProgress,
|
17
|
-
|
17
|
+
materializeEvent,
|
18
18
|
}: {
|
19
19
|
dbEventlog: SqliteDb
|
20
20
|
// db: SqliteDb
|
21
21
|
schema: LiveStoreSchema
|
22
22
|
onProgress: (_: { done: number; total: number }) => Effect.Effect<void>
|
23
|
-
|
23
|
+
materializeEvent: MaterializeEvent
|
24
24
|
}) =>
|
25
25
|
Effect.gen(function* () {
|
26
|
-
const eventsCount = dbEventlog.select<{ count: number }>(
|
27
|
-
.
|
26
|
+
const eventsCount = dbEventlog.select<{ count: number }>(
|
27
|
+
`SELECT COUNT(*) AS count FROM ${SystemTables.EVENTLOG_META_TABLE}`,
|
28
|
+
)[0]!.count
|
28
29
|
|
29
30
|
const hashEvent = memoizeByRef((event: EventDef.AnyWithoutFn) => Schema.hash(event.schema))
|
30
31
|
|
31
|
-
const processEvent = (row: EventlogMetaRow) =>
|
32
|
+
const processEvent = (row: SystemTables.EventlogMetaRow) =>
|
32
33
|
Effect.gen(function* () {
|
33
34
|
const eventDef = getEventDef(schema, row.name)
|
34
35
|
|
35
36
|
if (hashEvent(eventDef.eventDef) !== row.schemaHash) {
|
36
|
-
yield* Effect.logWarning(
|
37
|
+
yield* Effect.logWarning(
|
38
|
+
`Schema hash mismatch for event definition ${row.name}. Trying to materialize event anyway.`,
|
39
|
+
)
|
37
40
|
}
|
38
41
|
|
39
42
|
const args = JSON.parse(row.argsJson)
|
@@ -44,8 +47,8 @@ export const rehydrateFromEventlog = ({
|
|
44
47
|
UnexpectedError.make({
|
45
48
|
cause,
|
46
49
|
note: `\
|
47
|
-
There was an error during
|
48
|
-
the persisted
|
50
|
+
There was an error during rematerializing from the eventlog while decoding
|
51
|
+
the persisted event args for event definition "${row.name}".
|
49
52
|
This likely means the schema has changed in an incompatible way.
|
50
53
|
`,
|
51
54
|
}),
|
@@ -61,13 +64,13 @@ This likely means the schema has changed in an incompatible way.
|
|
61
64
|
sessionId: row.sessionId,
|
62
65
|
})
|
63
66
|
|
64
|
-
yield*
|
65
|
-
}).pipe(Effect.withSpan(`@livestore/common:
|
67
|
+
yield* materializeEvent(eventEncoded, { skipEventlog: true })
|
68
|
+
}).pipe(Effect.withSpan(`@livestore/common:rematerializeFromEventlog:processEvent`))
|
66
69
|
|
67
70
|
const CHUNK_SIZE = 100
|
68
71
|
|
69
72
|
const stmt = dbEventlog.prepare(sql`\
|
70
|
-
SELECT * FROM ${EVENTLOG_META_TABLE}
|
73
|
+
SELECT * FROM ${SystemTables.EVENTLOG_META_TABLE}
|
71
74
|
WHERE idGlobal > $idGlobal OR (idGlobal = $idGlobal AND idClient > $idClient)
|
72
75
|
ORDER BY idGlobal ASC, idClient ASC
|
73
76
|
LIMIT ${CHUNK_SIZE}
|
@@ -75,28 +78,28 @@ LIMIT ${CHUNK_SIZE}
|
|
75
78
|
|
76
79
|
let processedEvents = 0
|
77
80
|
|
78
|
-
yield* Stream.unfoldChunk<
|
79
|
-
{ _tag: 'Initial ' },
|
80
|
-
|
81
|
-
|
82
|
-
|
81
|
+
yield* Stream.unfoldChunk<
|
82
|
+
Chunk.Chunk<SystemTables.EventlogMetaRow> | { _tag: 'Initial ' },
|
83
|
+
SystemTables.EventlogMetaRow
|
84
|
+
>({ _tag: 'Initial ' }, (item) => {
|
85
|
+
// End stream if no more rows
|
86
|
+
if (Chunk.isChunk(item) && item.length === 0) return Option.none()
|
83
87
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
).pipe(
|
88
|
+
const lastId = Chunk.isChunk(item)
|
89
|
+
? Chunk.last(item).pipe(
|
90
|
+
Option.map((_) => ({ global: _.idGlobal, client: _.idClient })),
|
91
|
+
Option.getOrElse(() => EventId.ROOT),
|
92
|
+
)
|
93
|
+
: EventId.ROOT
|
94
|
+
const nextItem = Chunk.fromIterable(
|
95
|
+
stmt.select<SystemTables.EventlogMetaRow>({
|
96
|
+
$idGlobal: lastId?.global,
|
97
|
+
$idClient: lastId?.client,
|
98
|
+
} as any as PreparedBindValues),
|
99
|
+
)
|
100
|
+
const prevItem = Chunk.isChunk(item) ? item : Chunk.empty()
|
101
|
+
return Option.some([prevItem, nextItem])
|
102
|
+
}).pipe(
|
100
103
|
Stream.bufferChunks({ capacity: 2 }),
|
101
104
|
Stream.tap((row) =>
|
102
105
|
Effect.gen(function* () {
|
@@ -109,6 +112,6 @@ LIMIT ${CHUNK_SIZE}
|
|
109
112
|
Stream.runDrain,
|
110
113
|
)
|
111
114
|
}).pipe(
|
112
|
-
Effect.withPerformanceMeasure('@livestore/common:
|
113
|
-
Effect.withSpan('@livestore/common:
|
115
|
+
Effect.withPerformanceMeasure('@livestore/common:rematerializeFromEventlog'),
|
116
|
+
Effect.withSpan('@livestore/common:rematerializeFromEventlog'),
|
114
117
|
)
|
package/src/schema/EventDef.ts
CHANGED
@@ -2,8 +2,8 @@ import type { SingleOrReadonlyArray } from '@livestore/utils'
|
|
2
2
|
import { shouldNeverHappen } from '@livestore/utils'
|
3
3
|
import { Schema } from '@livestore/utils/effect'
|
4
4
|
|
5
|
-
import type { QueryBuilder } from '../query-builder/mod.js'
|
6
5
|
import type { BindValues } from '../sql-queries/sql-queries.js'
|
6
|
+
import type { QueryBuilder } from './state/sqlite/query-builder/mod.js'
|
7
7
|
|
8
8
|
export type EventDefMap = {
|
9
9
|
map: Map<string | 'livestore.RawSql', EventDef.Any>
|
package/src/schema/mod.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
export * from './system-tables.js'
|
2
|
-
export { SqliteAst, SqliteDsl } from './db-schema/mod.js'
|
1
|
+
export * as SystemTables from './state/sqlite/system-tables.js'
|
2
|
+
export { SqliteAst, SqliteDsl } from './state/sqlite/db-schema/mod.js'
|
3
3
|
export * from './EventDef.js'
|
4
|
-
export * from './schema-helpers.js'
|
4
|
+
export * from './state/sqlite/schema-helpers.js'
|
5
5
|
export * from './schema.js'
|
6
|
-
export * as State from './
|
6
|
+
export * as State from './state/mod.js'
|
7
7
|
export * as LiveStoreEvent from './LiveStoreEvent.js'
|
8
8
|
export * as EventId from './EventId.js'
|
9
9
|
export * as Events from './events.js'
|