@livestore/common 0.3.2-dev.1 → 0.3.2-dev.10
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/devtools/devtools-messages-client-session.d.ts +21 -21
- package/dist/devtools/devtools-messages-common.d.ts +6 -6
- package/dist/devtools/devtools-messages-common.d.ts.map +1 -1
- package/dist/devtools/devtools-messages-leader.d.ts +24 -24
- package/dist/schema/EventDef.d.ts +178 -132
- package/dist/schema/EventDef.d.ts.map +1 -1
- package/dist/schema/EventDef.js +0 -15
- package/dist/schema/EventDef.js.map +1 -1
- package/dist/schema/schema.d.ts +1 -5
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/schema/schema.js +0 -2
- package/dist/schema/schema.js.map +1 -1
- package/dist/schema/state/sqlite/client-document-def.d.ts +12 -0
- package/dist/schema/state/sqlite/client-document-def.d.ts.map +1 -1
- package/dist/schema/state/sqlite/client-document-def.js +12 -0
- package/dist/schema/state/sqlite/client-document-def.js.map +1 -1
- package/dist/schema/state/sqlite/db-schema/dsl/mod.d.ts +165 -65
- package/dist/schema/state/sqlite/mod.d.ts +1 -1
- package/dist/schema/state/sqlite/mod.d.ts.map +1 -1
- package/dist/schema/state/sqlite/mod.js +0 -2
- package/dist/schema/state/sqlite/mod.js.map +1 -1
- package/dist/schema/state/sqlite/query-builder/api.d.ts +560 -307
- package/dist/schema/state/sqlite/table-def.d.ts +152 -70
- package/dist/schema-management/validate-schema.d.ts +1 -1
- package/dist/schema-management/validate-schema.d.ts.map +1 -1
- package/dist/schema-management/validate-schema.js +1 -1
- package/dist/schema-management/validate-schema.js.map +1 -1
- package/dist/sql-queries/types.d.ts +133 -37
- package/dist/version.d.ts +2 -2
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +2 -2
- package/dist/version.js.map +1 -1
- package/package.json +10 -49
- package/src/schema/EventDef.ts +1 -21
- package/src/schema/schema.ts +3 -6
- package/src/schema/state/sqlite/client-document-def.ts +12 -0
- package/src/schema/state/sqlite/mod.ts +1 -3
- package/src/schema-management/validate-schema.ts +1 -1
- package/src/version.ts +2 -2
package/src/schema/schema.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
import { isReadonlyArray, shouldNeverHappen } from '@livestore/utils'
|
2
2
|
|
3
3
|
import type { MigrationOptions } from '../adapter-types.ts'
|
4
|
-
import type { EventDef, EventDefRecord, Materializer
|
5
|
-
import { rawSqlEvent } from './EventDef.ts'
|
4
|
+
import type { EventDef, EventDefRecord, Materializer } from './EventDef.ts'
|
6
5
|
import { tableIsClientDocumentTable } from './state/sqlite/client-document-def.ts'
|
7
6
|
import type { SqliteDsl } from './state/sqlite/db-schema/mod.ts'
|
8
7
|
import { stateSystemTables } from './state/sqlite/system-tables.ts'
|
@@ -80,8 +79,6 @@ export const makeSchema = <TInputSchema extends InputSchema>(
|
|
80
79
|
}
|
81
80
|
}
|
82
81
|
|
83
|
-
eventsDefsMap.set(rawSqlEvent.name, rawSqlEvent)
|
84
|
-
|
85
82
|
for (const tableDef of tables.values()) {
|
86
83
|
if (tableIsClientDocumentTable(tableDef) && eventsDefsMap.has(tableDef.set.name) === false) {
|
87
84
|
eventsDefsMap.set(tableDef.set.name, tableDef.set)
|
@@ -138,8 +135,8 @@ export namespace FromInputSchema {
|
|
138
135
|
|
139
136
|
type EventDefRecordFromInputSchemaEvents<TEvents extends InputSchema['events']> =
|
140
137
|
TEvents extends ReadonlyArray<EventDef.Any>
|
141
|
-
? { [K in TEvents[number] as K['name']]: K }
|
138
|
+
? { [K in TEvents[number] as K['name']]: K }
|
142
139
|
: TEvents extends { [name: string]: EventDef.Any }
|
143
|
-
? { [K in keyof TEvents as TEvents[K]['name']]: TEvents[K] }
|
140
|
+
? { [K in keyof TEvents as TEvents[K]['name']]: TEvents[K] }
|
144
141
|
: never
|
145
142
|
}
|
@@ -23,6 +23,18 @@ import { table } from './table-def.ts'
|
|
23
23
|
* Careful:
|
24
24
|
* - When changing the table definitions in a non-backwards compatible way, the state might be lost without
|
25
25
|
* explicit reducers to handle the old auto-generated events
|
26
|
+
*
|
27
|
+
* Usage:
|
28
|
+
*
|
29
|
+
* ```ts
|
30
|
+
* // Querying data
|
31
|
+
* // `'some-id'` can be ommited for SessionIdSymbol
|
32
|
+
* store.queryDb(clientDocumentTable.get('some-id'))
|
33
|
+
*
|
34
|
+
* // Setting data
|
35
|
+
* // Again, `'some-id'` can be ommited for SessionIdSymbol
|
36
|
+
* store.commit(clientDocumentTable.set({ someField: 'some-value' }, 'some-id'))
|
37
|
+
* ```
|
26
38
|
*/
|
27
39
|
export const clientDocument = <
|
28
40
|
TName extends string,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { shouldNeverHappen } from '@livestore/utils'
|
2
2
|
|
3
3
|
import type { MigrationOptions } from '../../../adapter-types.ts'
|
4
|
-
import {
|
4
|
+
import type { Materializer } from '../../EventDef.ts'
|
5
5
|
import type { InternalState } from '../../schema.ts'
|
6
6
|
import { ClientDocumentTableDefSymbol, tableIsClientDocumentTable } from './client-document-def.ts'
|
7
7
|
import { SqliteAst } from './db-schema/mod.ts'
|
@@ -44,8 +44,6 @@ export const makeState = <TStateInput extends InputState>(inputSchema: TStateInp
|
|
44
44
|
materializers.set(name, materializer)
|
45
45
|
}
|
46
46
|
|
47
|
-
materializers.set(rawSqlEvent.name, rawSqlMaterializer)
|
48
|
-
|
49
47
|
for (const tableDef of inputTables) {
|
50
48
|
if (tableIsClientDocumentTable(tableDef)) {
|
51
49
|
materializers.set(
|
@@ -15,7 +15,7 @@ export const validateSchema = (schema: LiveStoreSchema, schemaManager: SchemaMan
|
|
15
15
|
)
|
16
16
|
|
17
17
|
if (missingEventDefs.length > 0) {
|
18
|
-
yield* new UnexpectedError({
|
18
|
+
return yield* new UnexpectedError({
|
19
19
|
cause: `Missing mutation definitions: ${missingEventDefs.map((info) => info.eventName).join(', ')}`,
|
20
20
|
})
|
21
21
|
}
|
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.3.2-dev.
|
5
|
+
export const liveStoreVersion = '0.3.2-dev.10' as const
|
6
6
|
|
7
7
|
/**
|
8
8
|
* This version number is incremented whenever the internal storage format changes in a breaking way.
|
@@ -11,4 +11,4 @@ export const liveStoreVersion = '0.3.2-dev.1' as const
|
|
11
11
|
* While LiveStore is in beta, this might happen more frequently.
|
12
12
|
* In the future, LiveStore will provide a migration path for older database files to avoid the impression of data loss.
|
13
13
|
*/
|
14
|
-
export const liveStoreStorageFormatVersion =
|
14
|
+
export const liveStoreStorageFormatVersion = 5
|