@livestore/common 0.3.2-dev.13 → 0.3.2-dev.14
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 +1 -1
- 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/types.d.ts +1 -1
- package/dist/leader-thread/types.d.ts.map +1 -1
- package/dist/schema/LiveStoreEvent.d.ts +5 -5
- package/dist/schema/LiveStoreEvent.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.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/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 +100 -9
- package/dist/schema/state/sqlite/table-def.d.ts.map +1 -1
- package/dist/schema/state/sqlite/table-def.js +227 -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 +625 -0
- package/dist/schema/state/sqlite/table-def.test.js.map +1 -0
- 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 +3 -29
- package/dist/schema-management/migrations.js.map +1 -1
- package/dist/sqlite-db-helper.d.ts +1 -1
- package/dist/sqlite-db-helper.d.ts.map +1 -1
- 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.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 +3 -1
- package/src/devtools/devtools-messages-leader.ts +3 -3
- package/src/leader-thread/types.ts +1 -1
- package/src/schema/LiveStoreEvent.ts +1 -1
- 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/table-def.test.ts +783 -0
- package/src/schema/state/sqlite/table-def.ts +440 -16
- package/src/schema-management/migrations.ts +3 -32
- package/src/sqlite-db-helper.ts +1 -1
- package/src/sqlite-types.ts +4 -4
- package/src/sync/ClientSessionSyncProcessor.ts +5 -2
- package/src/util.ts +7 -2
- package/src/version.ts +1 -1
- package/src/schema-management/migrations.test.ts +0 -65
@@ -1,65 +0,0 @@
|
|
1
|
-
import { Option, Schema } from '@livestore/utils/effect'
|
2
|
-
import { describe, expect, it } from 'vitest'
|
3
|
-
import type { SqliteAst } from '../schema/state/sqlite/db-schema/mod.ts'
|
4
|
-
import { makeColumnSpec } from './migrations.js'
|
5
|
-
|
6
|
-
const createColumn = (
|
7
|
-
name: string,
|
8
|
-
type: 'text' | 'integer',
|
9
|
-
options: { nullable?: boolean; primaryKey?: boolean } = {},
|
10
|
-
) => ({
|
11
|
-
_tag: 'column' as const,
|
12
|
-
name,
|
13
|
-
type: { _tag: type },
|
14
|
-
nullable: options.nullable ?? true,
|
15
|
-
primaryKey: options.primaryKey ?? false,
|
16
|
-
default: Option.none(),
|
17
|
-
schema: type === 'text' ? Schema.String : Schema.Number,
|
18
|
-
})
|
19
|
-
|
20
|
-
describe('makeColumnSpec', () => {
|
21
|
-
it('should quote column names properly for reserved keywords', () => {
|
22
|
-
const table: SqliteAst.Table = {
|
23
|
-
_tag: 'table',
|
24
|
-
name: 'blocks',
|
25
|
-
columns: [createColumn('order', 'integer', { nullable: false }), createColumn('group', 'text')],
|
26
|
-
indexes: [],
|
27
|
-
}
|
28
|
-
|
29
|
-
const result = makeColumnSpec(table)
|
30
|
-
expect(result).toMatchInlineSnapshot(`"'order' integer not null , 'group' text "`)
|
31
|
-
expect(result).toContain("'order'")
|
32
|
-
expect(result).toContain("'group'")
|
33
|
-
})
|
34
|
-
|
35
|
-
it('should handle basic columns with primary keys', () => {
|
36
|
-
const table: SqliteAst.Table = {
|
37
|
-
_tag: 'table',
|
38
|
-
name: 'users',
|
39
|
-
columns: [createColumn('id', 'text', { nullable: false, primaryKey: true }), createColumn('name', 'text')],
|
40
|
-
indexes: [],
|
41
|
-
}
|
42
|
-
|
43
|
-
const result = makeColumnSpec(table)
|
44
|
-
expect(result).toMatchInlineSnapshot(`"'id' text not null , 'name' text , PRIMARY KEY ('id')"`)
|
45
|
-
expect(result).toContain("PRIMARY KEY ('id')")
|
46
|
-
})
|
47
|
-
|
48
|
-
it('should handle multi-column primary keys', () => {
|
49
|
-
const table: SqliteAst.Table = {
|
50
|
-
_tag: 'table',
|
51
|
-
name: 'composite',
|
52
|
-
columns: [
|
53
|
-
createColumn('tenant_id', 'text', { nullable: false, primaryKey: true }),
|
54
|
-
createColumn('user_id', 'text', { nullable: false, primaryKey: true }),
|
55
|
-
],
|
56
|
-
indexes: [],
|
57
|
-
}
|
58
|
-
|
59
|
-
const result = makeColumnSpec(table)
|
60
|
-
expect(result).toMatchInlineSnapshot(
|
61
|
-
`"'tenant_id' text not null , 'user_id' text not null , PRIMARY KEY ('tenant_id', 'user_id')"`,
|
62
|
-
)
|
63
|
-
expect(result).toContain("PRIMARY KEY ('tenant_id', 'user_id')")
|
64
|
-
})
|
65
|
-
})
|