@livestore/common 0.3.2-dev.9 → 0.4.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 +2 -2
- package/dist/ClientSessionLeaderThreadProxy.d.ts.map +1 -1
- package/dist/adapter-types.d.ts +4 -4
- package/dist/adapter-types.d.ts.map +1 -1
- package/dist/debug-info.d.ts +17 -17
- package/dist/devtools/devtools-messages-client-session.d.ts +38 -38
- package/dist/devtools/devtools-messages-common.d.ts +6 -6
- package/dist/devtools/devtools-messages-leader.d.ts +28 -28
- package/dist/devtools/devtools-messages-leader.d.ts.map +1 -1
- package/dist/devtools/devtools-messages-leader.js.map +1 -1
- package/dist/leader-thread/LeaderSyncProcessor.js +3 -1
- package/dist/leader-thread/LeaderSyncProcessor.js.map +1 -1
- package/dist/leader-thread/make-leader-thread-layer.d.ts.map +1 -1
- package/dist/leader-thread/make-leader-thread-layer.js +21 -4
- package/dist/leader-thread/make-leader-thread-layer.js.map +1 -1
- package/dist/leader-thread/shutdown-channel.d.ts +2 -2
- package/dist/leader-thread/shutdown-channel.d.ts.map +1 -1
- package/dist/leader-thread/shutdown-channel.js +2 -2
- package/dist/leader-thread/shutdown-channel.js.map +1 -1
- package/dist/leader-thread/types.d.ts +1 -1
- package/dist/leader-thread/types.d.ts.map +1 -1
- package/dist/materializer-helper.d.ts +3 -3
- package/dist/materializer-helper.d.ts.map +1 -1
- package/dist/materializer-helper.js +2 -2
- package/dist/materializer-helper.js.map +1 -1
- package/dist/rematerialize-from-eventlog.js +1 -1
- package/dist/rematerialize-from-eventlog.js.map +1 -1
- package/dist/schema/EventDef.d.ts +104 -178
- package/dist/schema/EventSequenceNumber.d.ts +5 -0
- package/dist/schema/EventSequenceNumber.d.ts.map +1 -1
- package/dist/schema/EventSequenceNumber.js +7 -2
- package/dist/schema/EventSequenceNumber.js.map +1 -1
- package/dist/schema/EventSequenceNumber.test.js +2 -2
- package/dist/schema/LiveStoreEvent.d.ts +6 -5
- package/dist/schema/LiveStoreEvent.d.ts.map +1 -1
- package/dist/schema/LiveStoreEvent.js +5 -0
- package/dist/schema/LiveStoreEvent.js.map +1 -1
- package/dist/schema/schema.d.ts +3 -0
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/schema/schema.js.map +1 -1
- package/dist/schema/state/sqlite/client-document-def.d.ts +3 -2
- package/dist/schema/state/sqlite/client-document-def.d.ts.map +1 -1
- package/dist/schema/state/sqlite/client-document-def.js +6 -4
- package/dist/schema/state/sqlite/client-document-def.js.map +1 -1
- package/dist/schema/state/sqlite/client-document-def.test.js +76 -1
- package/dist/schema/state/sqlite/client-document-def.test.js.map +1 -1
- package/dist/schema/state/sqlite/column-annotations.d.ts +34 -0
- package/dist/schema/state/sqlite/column-annotations.d.ts.map +1 -0
- package/dist/schema/state/sqlite/column-annotations.js +50 -0
- package/dist/schema/state/sqlite/column-annotations.js.map +1 -0
- package/dist/schema/state/sqlite/column-annotations.test.d.ts +2 -0
- package/dist/schema/state/sqlite/column-annotations.test.d.ts.map +1 -0
- package/dist/schema/state/sqlite/column-annotations.test.js +179 -0
- package/dist/schema/state/sqlite/column-annotations.test.js.map +1 -0
- package/dist/schema/state/sqlite/column-spec.d.ts +11 -0
- package/dist/schema/state/sqlite/column-spec.d.ts.map +1 -0
- package/dist/schema/state/sqlite/column-spec.js +39 -0
- package/dist/schema/state/sqlite/column-spec.js.map +1 -0
- package/dist/schema/state/sqlite/column-spec.test.d.ts +2 -0
- package/dist/schema/state/sqlite/column-spec.test.d.ts.map +1 -0
- package/dist/schema/state/sqlite/column-spec.test.js +146 -0
- package/dist/schema/state/sqlite/column-spec.test.js.map +1 -0
- package/dist/schema/state/sqlite/db-schema/ast/sqlite.d.ts +1 -0
- package/dist/schema/state/sqlite/db-schema/ast/sqlite.d.ts.map +1 -1
- package/dist/schema/state/sqlite/db-schema/ast/sqlite.js +1 -0
- 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 +17 -4
- 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 +2 -0
- package/dist/schema/state/sqlite/db-schema/dsl/field-defs.js.map +1 -1
- package/dist/schema/state/sqlite/db-schema/dsl/mod.d.ts +65 -165
- package/dist/schema/state/sqlite/db-schema/dsl/mod.d.ts.map +1 -1
- package/dist/schema/state/sqlite/db-schema/dsl/mod.js +1 -0
- package/dist/schema/state/sqlite/db-schema/dsl/mod.js.map +1 -1
- package/dist/schema/state/sqlite/mod.d.ts +2 -0
- package/dist/schema/state/sqlite/mod.d.ts.map +1 -1
- package/dist/schema/state/sqlite/mod.js +2 -0
- package/dist/schema/state/sqlite/mod.js.map +1 -1
- package/dist/schema/state/sqlite/query-builder/api.d.ts +309 -560
- package/dist/schema/state/sqlite/query-builder/api.d.ts.map +1 -1
- package/dist/schema/state/sqlite/query-builder/astToSql.d.ts +1 -0
- package/dist/schema/state/sqlite/query-builder/astToSql.d.ts.map +1 -1
- package/dist/schema/state/sqlite/query-builder/astToSql.js +8 -6
- package/dist/schema/state/sqlite/query-builder/astToSql.js.map +1 -1
- package/dist/schema/state/sqlite/system-tables.d.ts +464 -46
- package/dist/schema/state/sqlite/system-tables.d.ts.map +1 -1
- package/dist/schema/state/sqlite/table-def.d.ts +161 -152
- package/dist/schema/state/sqlite/table-def.d.ts.map +1 -1
- package/dist/schema/state/sqlite/table-def.js +251 -5
- package/dist/schema/state/sqlite/table-def.js.map +1 -1
- package/dist/schema/state/sqlite/table-def.test.d.ts +2 -0
- package/dist/schema/state/sqlite/table-def.test.d.ts.map +1 -0
- package/dist/schema/state/sqlite/table-def.test.js +635 -0
- package/dist/schema/state/sqlite/table-def.test.js.map +1 -0
- package/dist/schema-management/common.d.ts +1 -1
- package/dist/schema-management/common.d.ts.map +1 -1
- package/dist/schema-management/common.js +11 -2
- package/dist/schema-management/common.js.map +1 -1
- package/dist/schema-management/migrations.d.ts +0 -1
- package/dist/schema-management/migrations.d.ts.map +1 -1
- package/dist/schema-management/migrations.js +4 -30
- package/dist/schema-management/migrations.js.map +1 -1
- package/dist/schema-management/migrations.test.d.ts +2 -0
- package/dist/schema-management/migrations.test.d.ts.map +1 -0
- package/dist/schema-management/migrations.test.js +52 -0
- package/dist/schema-management/migrations.test.js.map +1 -0
- package/dist/sql-queries/types.d.ts +37 -133
- package/dist/sqlite-db-helper.d.ts +3 -1
- package/dist/sqlite-db-helper.d.ts.map +1 -1
- package/dist/sqlite-db-helper.js +16 -0
- package/dist/sqlite-db-helper.js.map +1 -1
- package/dist/sqlite-types.d.ts +4 -4
- package/dist/sqlite-types.d.ts.map +1 -1
- package/dist/sync/ClientSessionSyncProcessor.d.ts +2 -2
- package/dist/sync/ClientSessionSyncProcessor.d.ts.map +1 -1
- package/dist/sync/ClientSessionSyncProcessor.js +8 -7
- package/dist/sync/ClientSessionSyncProcessor.js.map +1 -1
- package/dist/sync/sync.d.ts.map +1 -1
- package/dist/sync/sync.js.map +1 -1
- package/dist/util.d.ts +3 -3
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/src/ClientSessionLeaderThreadProxy.ts +2 -2
- package/src/adapter-types.ts +6 -4
- package/src/devtools/devtools-messages-leader.ts +3 -3
- package/src/leader-thread/LeaderSyncProcessor.ts +3 -1
- package/src/leader-thread/make-leader-thread-layer.ts +26 -7
- package/src/leader-thread/shutdown-channel.ts +2 -2
- package/src/leader-thread/types.ts +1 -1
- package/src/materializer-helper.ts +5 -11
- package/src/rematerialize-from-eventlog.ts +2 -2
- package/src/schema/EventSequenceNumber.test.ts +2 -2
- package/src/schema/EventSequenceNumber.ts +8 -2
- package/src/schema/LiveStoreEvent.ts +7 -1
- package/src/schema/schema.ts +4 -0
- package/src/schema/state/sqlite/client-document-def.test.ts +89 -1
- package/src/schema/state/sqlite/client-document-def.ts +7 -4
- package/src/schema/state/sqlite/column-annotations.test.ts +212 -0
- package/src/schema/state/sqlite/column-annotations.ts +77 -0
- package/src/schema/state/sqlite/column-spec.test.ts +223 -0
- package/src/schema/state/sqlite/column-spec.ts +42 -0
- package/src/schema/state/sqlite/db-schema/ast/sqlite.ts +2 -0
- package/src/schema/state/sqlite/db-schema/dsl/__snapshots__/field-defs.test.ts.snap +15 -0
- package/src/schema/state/sqlite/db-schema/dsl/field-defs.ts +20 -2
- package/src/schema/state/sqlite/db-schema/dsl/mod.ts +1 -0
- package/src/schema/state/sqlite/mod.ts +2 -0
- package/src/schema/state/sqlite/query-builder/api.ts +4 -3
- package/src/schema/state/sqlite/query-builder/astToSql.ts +9 -7
- package/src/schema/state/sqlite/table-def.test.ts +798 -0
- package/src/schema/state/sqlite/table-def.ts +472 -16
- package/src/schema-management/common.ts +10 -3
- package/src/schema-management/migrations.ts +4 -33
- package/src/sqlite-db-helper.ts +19 -1
- package/src/sqlite-types.ts +4 -4
- package/src/sync/ClientSessionSyncProcessor.ts +13 -8
- package/src/sync/sync.ts +2 -0
- package/src/util.ts +7 -2
- package/src/version.ts +1 -1
@@ -3,6 +3,7 @@ import { LS_DEV, shouldNeverHappen, TRACE_VERBOSE } from '@livestore/utils'
|
|
3
3
|
import {
|
4
4
|
BucketQueue,
|
5
5
|
Effect,
|
6
|
+
Exit,
|
6
7
|
FiberHandle,
|
7
8
|
Option,
|
8
9
|
Queue,
|
@@ -54,10 +55,13 @@ export const makeClientSessionSyncProcessor = ({
|
|
54
55
|
options: { otelContext: otel.Context; withChangeset: boolean; materializerHashLeader: Option.Option<number> },
|
55
56
|
) => {
|
56
57
|
writeTables: Set<string>
|
57
|
-
sessionChangeset:
|
58
|
+
sessionChangeset:
|
59
|
+
| { _tag: 'sessionChangeset'; data: Uint8Array<ArrayBuffer>; debug: any }
|
60
|
+
| { _tag: 'no-op' }
|
61
|
+
| { _tag: 'unset' }
|
58
62
|
materializerHash: Option.Option<number>
|
59
63
|
}
|
60
|
-
rollback: (changeset: Uint8Array) => void
|
64
|
+
rollback: (changeset: Uint8Array<ArrayBuffer>) => void
|
61
65
|
refreshTables: (tables: Set<string>) => void
|
62
66
|
span: otel.Span
|
63
67
|
params: {
|
@@ -316,7 +320,7 @@ export const makeClientSessionSyncProcessor = ({
|
|
316
320
|
refreshTables(writeTables)
|
317
321
|
}).pipe(
|
318
322
|
Effect.tapCauseLogPretty,
|
319
|
-
Effect.catchAllCause((cause) => clientSession.shutdown(cause)),
|
323
|
+
Effect.catchAllCause((cause) => clientSession.shutdown(Exit.failCause(cause))),
|
320
324
|
),
|
321
325
|
),
|
322
326
|
Stream.runDrain,
|
@@ -381,13 +385,14 @@ export interface ClientSessionSyncProcessor {
|
|
381
385
|
// TODO turn this into a build-time "macro" so all simulation snippets are removed for production builds
|
382
386
|
const SIMULATION_ENABLED = true
|
383
387
|
|
388
|
+
// Warning: High values for the simulation params can lead to very long test runs since those get multiplied with the number of events
|
384
389
|
export const ClientSessionSyncProcessorSimulationParams = Schema.Struct({
|
385
390
|
pull: Schema.Struct({
|
386
|
-
'1_before_leader_push_fiber_interrupt': Schema.Int.pipe(Schema.between(0,
|
387
|
-
'2_before_leader_push_queue_clear': Schema.Int.pipe(Schema.between(0,
|
388
|
-
'3_before_rebase_rollback': Schema.Int.pipe(Schema.between(0,
|
389
|
-
'4_before_leader_push_queue_offer': Schema.Int.pipe(Schema.between(0,
|
390
|
-
'5_before_leader_push_fiber_run': Schema.Int.pipe(Schema.between(0,
|
391
|
+
'1_before_leader_push_fiber_interrupt': Schema.Int.pipe(Schema.between(0, 25)),
|
392
|
+
'2_before_leader_push_queue_clear': Schema.Int.pipe(Schema.between(0, 25)),
|
393
|
+
'3_before_rebase_rollback': Schema.Int.pipe(Schema.between(0, 25)),
|
394
|
+
'4_before_leader_push_queue_offer': Schema.Int.pipe(Schema.between(0, 25)),
|
395
|
+
'5_before_leader_push_fiber_run': Schema.Int.pipe(Schema.between(0, 25)),
|
391
396
|
}),
|
392
397
|
})
|
393
398
|
type ClientSessionSyncProcessorSimulationParams = typeof ClientSessionSyncProcessorSimulationParams.Type
|
package/src/sync/sync.ts
CHANGED
@@ -31,6 +31,7 @@ export type SyncOptions = {
|
|
31
31
|
onSyncError?: 'shutdown' | 'ignore'
|
32
32
|
}
|
33
33
|
|
34
|
+
// TODO rename to `SyncProviderClientConstructor`
|
34
35
|
export type SyncBackendConstructor<TSyncMetadata = Schema.JsonValue> = (
|
35
36
|
args: MakeBackendArgs,
|
36
37
|
) => Effect.Effect<SyncBackend<TSyncMetadata>, UnexpectedError, Scope.Scope | HttpClient.HttpClient>
|
@@ -41,6 +42,7 @@ export type SyncBackendConstructor<TSyncMetadata = Schema.JsonValue> = (
|
|
41
42
|
// - dynamic sync backend data;
|
42
43
|
// - data center location (e.g. colo on CF workers)
|
43
44
|
|
45
|
+
// TODO rename to `SyncProviderClient`
|
44
46
|
export type SyncBackend<TSyncMetadata = Schema.JsonValue> = {
|
45
47
|
/**
|
46
48
|
* Can be implemented to prepare a connection to the sync backend to speed up the first pull/push.
|
package/src/util.ts
CHANGED
@@ -4,11 +4,16 @@ import type { Brand } from '@livestore/utils/effect'
|
|
4
4
|
import { Schema } from '@livestore/utils/effect'
|
5
5
|
|
6
6
|
export type ParamsObject = Record<string, SqlValue>
|
7
|
-
export type SqlValue = string | number | Uint8Array | null
|
7
|
+
export type SqlValue = string | number | Uint8Array<ArrayBuffer> | null
|
8
8
|
|
9
9
|
export type Bindable = ReadonlyArray<SqlValue> | ParamsObject
|
10
10
|
|
11
|
-
export const SqlValueSchema = Schema.Union(
|
11
|
+
export const SqlValueSchema = Schema.Union(
|
12
|
+
Schema.String,
|
13
|
+
Schema.Number,
|
14
|
+
Schema.Uint8Array as any as Schema.Schema<Uint8Array<ArrayBuffer>>,
|
15
|
+
Schema.Null,
|
16
|
+
)
|
12
17
|
|
13
18
|
export const PreparedBindValues = Schema.Union(
|
14
19
|
Schema.Array(SqlValueSchema),
|
package/src/version.ts
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
// import packageJson from '../package.json' with { type: 'json' }
|
3
3
|
// export const liveStoreVersion = packageJson.version
|
4
4
|
|
5
|
-
export const liveStoreVersion = '0.
|
5
|
+
export const liveStoreVersion = '0.4.0-dev.0' as const
|
6
6
|
|
7
7
|
/**
|
8
8
|
* This version number is incremented whenever the internal storage format changes in a breaking way.
|