@livestore/common 0.0.0-snapshot-a2ca318cc053b3d24df8cc4e8ee8d02736ac62ee → 0.0.0-snapshot-a953343ad2d7468c6573bcb5e26f0eab4302078f
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/__tests__/fixture.d.ts +21 -21
- package/dist/derived-mutations.d.ts +1 -1
- package/dist/derived-mutations.d.ts.map +1 -1
- package/dist/derived-mutations.js.map +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-leader.d.ts +28 -28
- package/dist/query-builder/api.d.ts +1 -1
- package/dist/query-builder/api.d.ts.map +1 -1
- package/dist/schema/db-schema/ast/sqlite.d.ts +69 -0
- package/dist/schema/db-schema/ast/sqlite.d.ts.map +1 -0
- package/dist/schema/db-schema/ast/sqlite.js +71 -0
- package/dist/schema/db-schema/ast/sqlite.js.map +1 -0
- package/dist/schema/db-schema/ast/validate.d.ts +3 -0
- package/dist/schema/db-schema/ast/validate.d.ts.map +1 -0
- package/dist/schema/db-schema/ast/validate.js +12 -0
- package/dist/schema/db-schema/ast/validate.js.map +1 -0
- package/dist/schema/db-schema/dsl/field-defs.d.ts +90 -0
- package/dist/schema/db-schema/dsl/field-defs.d.ts.map +1 -0
- package/dist/schema/db-schema/dsl/field-defs.js +87 -0
- package/dist/schema/db-schema/dsl/field-defs.js.map +1 -0
- package/dist/schema/db-schema/dsl/field-defs.test.d.ts +2 -0
- package/dist/schema/db-schema/dsl/field-defs.test.d.ts.map +1 -0
- package/dist/schema/db-schema/dsl/field-defs.test.js +29 -0
- package/dist/schema/db-schema/dsl/field-defs.test.js.map +1 -0
- package/dist/schema/db-schema/dsl/mod.d.ts +88 -0
- package/dist/schema/db-schema/dsl/mod.d.ts.map +1 -0
- package/dist/schema/db-schema/dsl/mod.js +35 -0
- package/dist/schema/db-schema/dsl/mod.js.map +1 -0
- package/dist/schema/db-schema/hash.d.ts +2 -0
- package/dist/schema/db-schema/hash.d.ts.map +1 -0
- package/dist/schema/db-schema/hash.js +14 -0
- package/dist/schema/db-schema/hash.js.map +1 -0
- package/dist/schema/db-schema/mod.d.ts +3 -0
- package/dist/schema/db-schema/mod.d.ts.map +1 -0
- package/dist/schema/db-schema/mod.js +3 -0
- package/dist/schema/db-schema/mod.js.map +1 -0
- package/dist/schema/mod.d.ts +1 -0
- package/dist/schema/mod.d.ts.map +1 -1
- package/dist/schema/mod.js +1 -0
- package/dist/schema/mod.js.map +1 -1
- package/dist/schema/schema-helpers.js +1 -1
- package/dist/schema/schema-helpers.js.map +1 -1
- package/dist/schema/schema.d.ts +1 -1
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/schema/schema.js +1 -1
- package/dist/schema/schema.js.map +1 -1
- package/dist/schema/system-tables.d.ts +9 -9
- 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 +13 -12
- package/dist/schema/table-def.d.ts.map +1 -1
- package/dist/schema/table-def.js +1 -2
- package/dist/schema/table-def.js.map +1 -1
- 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 +1 -1
- package/dist/schema-management/migrations.js.map +1 -1
- 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-queries.js.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/sql-query-builder.js.map +1 -1
- package/dist/sql-queries/types.d.ts +2 -1
- package/dist/sql-queries/types.d.ts.map +1 -1
- package/dist/sql-queries/types.js.map +1 -1
- package/dist/sync/next/test/compact-events.test.js +20 -20
- package/dist/sync/next/test/compact-events.test.js.map +1 -1
- package/dist/sync/next/test/mutation-fixtures.d.ts +3 -3
- package/dist/sync/next/test/mutation-fixtures.js +3 -3
- package/dist/sync/next/test/mutation-fixtures.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -3
- package/src/derived-mutations.ts +1 -1
- package/src/query-builder/api.ts +1 -1
- package/src/schema/db-schema/ast/sqlite.ts +142 -0
- package/src/schema/db-schema/ast/validate.ts +13 -0
- package/src/schema/db-schema/dsl/__snapshots__/field-defs.test.ts.snap +206 -0
- package/src/schema/db-schema/dsl/field-defs.test.ts +35 -0
- package/src/schema/db-schema/dsl/field-defs.ts +242 -0
- package/src/schema/db-schema/dsl/mod.ts +195 -0
- package/src/schema/db-schema/hash.ts +14 -0
- package/src/schema/db-schema/mod.ts +2 -0
- package/src/schema/mod.ts +1 -0
- package/src/schema/schema-helpers.ts +1 -1
- package/src/schema/schema.ts +2 -2
- package/src/schema/system-tables.ts +1 -1
- package/src/schema/table-def.ts +11 -11
- package/src/schema-management/migrations.ts +1 -1
- package/src/sql-queries/sql-queries.ts +1 -1
- package/src/sql-queries/sql-query-builder.ts +1 -2
- package/src/sql-queries/types.ts +3 -1
- package/src/sync/next/test/compact-events.test.ts +20 -20
- package/src/sync/next/test/mutation-fixtures.ts +6 -6
- package/src/version.ts +1 -1
- package/tsconfig.json +1 -1
package/src/schema/mod.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SqliteDsl } from '@livestore/db-schema'
|
|
2
1
|
import { shouldNeverHappen } from '@livestore/utils'
|
|
3
2
|
import { pipe, ReadonlyRecord, Schema } from '@livestore/utils/effect'
|
|
4
3
|
|
|
4
|
+
import { SqliteDsl } from '../schema/db-schema/mod.js'
|
|
5
5
|
import type { TableDef, TableDefBase } from './table-def.js'
|
|
6
6
|
|
|
7
7
|
export const getDefaultValuesEncoded = <TTableDef extends TableDef>(
|
package/src/schema/schema.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { SqliteDsl } from '@livestore/db-schema'
|
|
2
|
-
import { SqliteAst } from '@livestore/db-schema'
|
|
3
1
|
import { isReadonlyArray, shouldNeverHappen } from '@livestore/utils'
|
|
4
2
|
|
|
5
3
|
import type { MigrationOptions } from '../adapter-types.js'
|
|
6
4
|
import { makeDerivedMutationDefsForTable } from '../derived-mutations.js'
|
|
5
|
+
import type { SqliteDsl } from './db-schema/mod.js'
|
|
6
|
+
import { SqliteAst } from './db-schema/mod.js'
|
|
7
7
|
import {
|
|
8
8
|
type MutationDef,
|
|
9
9
|
type MutationDefMap,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type SqliteAst as __SqliteAst, SqliteDsl } from '@livestore/db-schema'
|
|
2
1
|
import { Schema } from '@livestore/utils/effect'
|
|
3
2
|
|
|
3
|
+
import { SqliteDsl } from './db-schema/mod.js'
|
|
4
4
|
import * as EventId from './EventId.js'
|
|
5
5
|
import type { FromTable } from './table-def.js'
|
|
6
6
|
import { table } from './table-def.js'
|
package/src/schema/table-def.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import type { Nullable
|
|
2
|
-
import { SqliteDsl } from '@livestore/db-schema'
|
|
1
|
+
import type { Nullable } from '@livestore/utils'
|
|
3
2
|
import { shouldNeverHappen } from '@livestore/utils'
|
|
3
|
+
import type { Types } from '@livestore/utils/effect'
|
|
4
4
|
import { ReadonlyRecord, Schema } from '@livestore/utils/effect'
|
|
5
5
|
|
|
6
6
|
import type { DerivedMutationHelperFns } from '../derived-mutations.js'
|
|
7
7
|
import { makeDerivedMutationDefsForTable } from '../derived-mutations.js'
|
|
8
8
|
import type { QueryBuilder } from '../query-builder/mod.js'
|
|
9
9
|
import { makeQueryBuilder } from '../query-builder/mod.js'
|
|
10
|
+
import { SqliteDsl } from './db-schema/mod.js'
|
|
10
11
|
|
|
11
12
|
export const { blob, boolean, column, datetime, integer, isColumnDefinition, json, real, text } = SqliteDsl
|
|
12
13
|
|
|
13
|
-
export { SqliteDsl } from '@livestore/db-schema'
|
|
14
|
-
|
|
15
14
|
export type StateType = 'singleton' | 'dynamic'
|
|
16
15
|
|
|
17
16
|
export type DefaultSqliteTableDef = SqliteDsl.TableDefinition<string, SqliteDsl.Columns>
|
|
@@ -60,7 +59,6 @@ export type TableOptionsInput = Partial<{
|
|
|
60
59
|
deriveMutations:
|
|
61
60
|
| boolean
|
|
62
61
|
| {
|
|
63
|
-
enabled: true
|
|
64
62
|
clientOnly?: boolean
|
|
65
63
|
}
|
|
66
64
|
}>
|
|
@@ -242,6 +240,8 @@ export const tableIsSingleton = <TTableDef extends TableDefBase>(
|
|
|
242
240
|
tableDef: TTableDef,
|
|
243
241
|
): tableDef is TTableDef & { options: { isSingleton: true } } => tableDef.options.isSingleton === true
|
|
244
242
|
|
|
243
|
+
export type PrettifyFlat<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
|
|
244
|
+
|
|
245
245
|
type SqliteTableDefForInput<
|
|
246
246
|
TName extends string,
|
|
247
247
|
TColumns extends SqliteDsl.Columns | SqliteDsl.ColumnDefinition<any, any>,
|
|
@@ -268,10 +268,10 @@ type WithDefaults<
|
|
|
268
268
|
isSingleton: TOptionsInput['isSingleton'] extends true ? true : false
|
|
269
269
|
disableAutomaticIdColumn: TOptionsInput['disableAutomaticIdColumn'] extends true ? true : false
|
|
270
270
|
deriveMutations: TOptionsInput['deriveMutations'] extends true
|
|
271
|
-
? { enabled: true; clientOnly:
|
|
271
|
+
? { enabled: true; clientOnly: false }
|
|
272
272
|
: TOptionsInput['deriveMutations'] extends false
|
|
273
273
|
? { enabled: false }
|
|
274
|
-
: TOptionsInput['deriveMutations'] extends {
|
|
274
|
+
: TOptionsInput['deriveMutations'] extends { clientOnly: boolean }
|
|
275
275
|
? {
|
|
276
276
|
enabled: true
|
|
277
277
|
clientOnly: TOptionsInput['deriveMutations']['clientOnly'] extends true ? true : false
|
|
@@ -283,7 +283,7 @@ type WithDefaults<
|
|
|
283
283
|
|
|
284
284
|
export namespace FromTable {
|
|
285
285
|
// TODO this sometimes doesn't preserve the order of columns
|
|
286
|
-
export type RowDecoded<TTableDef extends TableDefBase> =
|
|
286
|
+
export type RowDecoded<TTableDef extends TableDefBase> = Types.Simplify<
|
|
287
287
|
Nullable<Pick<RowDecodedAll<TTableDef>, NullableColumnNames<TTableDef>>> &
|
|
288
288
|
Omit<RowDecodedAll<TTableDef>, NullableColumnNames<TTableDef>>
|
|
289
289
|
>
|
|
@@ -302,7 +302,7 @@ export namespace FromTable {
|
|
|
302
302
|
>
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
export type RowEncoded<TTableDef extends TableDefBase> =
|
|
305
|
+
export type RowEncoded<TTableDef extends TableDefBase> = Types.Simplify<
|
|
306
306
|
Nullable<Pick<RowEncodeNonNullable<TTableDef>, NullableColumnNames<TTableDef>>> &
|
|
307
307
|
Omit<RowEncodeNonNullable<TTableDef>, NullableColumnNames<TTableDef>>
|
|
308
308
|
>
|
|
@@ -314,7 +314,7 @@ export namespace FromTable {
|
|
|
314
314
|
|
|
315
315
|
export namespace FromColumns {
|
|
316
316
|
// TODO this sometimes doesn't preserve the order of columns
|
|
317
|
-
export type RowDecoded<TColumns extends SqliteDsl.Columns> =
|
|
317
|
+
export type RowDecoded<TColumns extends SqliteDsl.Columns> = Types.Simplify<
|
|
318
318
|
Nullable<Pick<RowDecodedAll<TColumns>, NullableColumnNames<TColumns>>> &
|
|
319
319
|
Omit<RowDecodedAll<TColumns>, NullableColumnNames<TColumns>>
|
|
320
320
|
>
|
|
@@ -323,7 +323,7 @@ export namespace FromColumns {
|
|
|
323
323
|
[K in keyof TColumns]: Schema.Schema.Type<TColumns[K]['schema']>
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
-
export type RowEncoded<TColumns extends SqliteDsl.Columns> =
|
|
326
|
+
export type RowEncoded<TColumns extends SqliteDsl.Columns> = Types.Simplify<
|
|
327
327
|
Nullable<Pick<RowEncodeNonNullable<TColumns>, NullableColumnNames<TColumns>>> &
|
|
328
328
|
Omit<RowEncodeNonNullable<TColumns>, NullableColumnNames<TColumns>>
|
|
329
329
|
>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SqliteAst, SqliteDsl } from '@livestore/db-schema'
|
|
2
1
|
import { memoizeByStringifyArgs } from '@livestore/utils'
|
|
3
2
|
import { Effect, Schema as EffectSchema } from '@livestore/utils/effect'
|
|
4
3
|
|
|
5
4
|
import type { MigrationsReport, MigrationsReportEntry, SqliteDb, UnexpectedError } from '../adapter-types.js'
|
|
5
|
+
import { SqliteAst, SqliteDsl } from '../schema/db-schema/mod.js'
|
|
6
6
|
import type { LiveStoreSchema } from '../schema/mod.js'
|
|
7
7
|
import type { SchemaMetaRow, SchemaMutationsMetaRow } from '../schema/system-tables.js'
|
|
8
8
|
import {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { SqliteDsl } from '@livestore/db-schema'
|
|
2
1
|
import { shouldNeverHappen } from '@livestore/utils'
|
|
3
2
|
import { pipe, ReadonlyArray, Schema, TreeFormatter } from '@livestore/utils/effect'
|
|
4
3
|
|
|
4
|
+
import type { SqliteDsl } from '../schema/db-schema/mod.js'
|
|
5
5
|
import { sql } from '../util.js'
|
|
6
6
|
import { objectEntries } from './misc.js'
|
|
7
7
|
import * as ClientTypes from './types.js'
|
package/src/sql-queries/types.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { Prettify
|
|
1
|
+
import type { Prettify } from '@livestore/utils'
|
|
2
2
|
import type { Schema } from '@livestore/utils/effect'
|
|
3
3
|
|
|
4
|
+
import type { SqliteDsl } from '../schema/db-schema/mod.js'
|
|
5
|
+
|
|
4
6
|
export type DecodedValuesForTableAll<TSchema extends SqliteDsl.DbSchema, TTableName extends keyof TSchema> = {
|
|
5
7
|
[K in keyof GetColumns<TSchema, TTableName>]: Schema.Schema.Type<GetColumn<TSchema, TTableName, K>['schema']>
|
|
6
8
|
}
|
|
@@ -81,17 +81,17 @@ const compact = (events: any[]) => {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
describe('compactEvents todo app', () => {
|
|
84
|
-
it('
|
|
84
|
+
it('todoCompleted', () => {
|
|
85
85
|
const expected = compact([
|
|
86
86
|
mutations.createTodo({ id: 'A', text: 'buy milk' }), // 0
|
|
87
|
-
mutations.
|
|
88
|
-
mutations.
|
|
87
|
+
mutations.todoCompleted({ id: 'A' }), // 1
|
|
88
|
+
mutations.todoCompleted({ id: 'A' }), // 2
|
|
89
89
|
])
|
|
90
90
|
|
|
91
91
|
expect(expected).toMatchInlineSnapshot(`
|
|
92
92
|
[
|
|
93
93
|
{ id: 0, parentId: -1, mutation: "createTodo", args: { id: "A", text: "buy milk" }, clientId: "client-id", sessionId: "session-id", facts: "+todo-exists-A +todo-is-writeable-A=true +todo-completed-A=false" }
|
|
94
|
-
{ id: 2, parentId: 0, mutation: "
|
|
94
|
+
{ id: 2, parentId: 0, mutation: "todoCompleted", args: { id: "A" }, clientId: "client-id", sessionId: "session-id", facts: "↖todo-exists-A ↖todo-is-writeable-A=true +todo-completed-A=true" }
|
|
95
95
|
]
|
|
96
96
|
`)
|
|
97
97
|
})
|
|
@@ -114,20 +114,20 @@ describe('compactEvents todo app', () => {
|
|
|
114
114
|
`)
|
|
115
115
|
})
|
|
116
116
|
|
|
117
|
-
it('
|
|
117
|
+
it('todoCompleted / toggleTodo', () => {
|
|
118
118
|
const expected = compact([
|
|
119
119
|
mutations.createTodo({ id: 'A', text: 'buy milk' }), // 0
|
|
120
120
|
mutations.toggleTodo({ id: 'A' }), // 1
|
|
121
121
|
mutations.toggleTodo({ id: 'A' }), // 2
|
|
122
|
-
mutations.
|
|
123
|
-
mutations.
|
|
122
|
+
mutations.todoCompleted({ id: 'A' }), // 3
|
|
123
|
+
mutations.todoCompleted({ id: 'A' }), // 4
|
|
124
124
|
mutations.toggleTodo({ id: 'A' }), // 5
|
|
125
125
|
])
|
|
126
126
|
|
|
127
127
|
expect(expected).toMatchInlineSnapshot(`
|
|
128
128
|
[
|
|
129
129
|
{ id: 0, parentId: -1, mutation: "createTodo", args: { id: "A", text: "buy milk" }, clientId: "client-id", sessionId: "session-id", facts: "+todo-exists-A +todo-is-writeable-A=true +todo-completed-A=false" }
|
|
130
|
-
{ id: 4, parentId: 0, mutation: "
|
|
130
|
+
{ id: 4, parentId: 0, mutation: "todoCompleted", args: { id: "A" }, clientId: "client-id", sessionId: "session-id", facts: "↖todo-exists-A ↖todo-is-writeable-A=true +todo-completed-A=true" }
|
|
131
131
|
{ id: 5, parentId: 4, mutation: "toggleTodo", args: { id: "A" }, clientId: "client-id", sessionId: "session-id", facts: "↖todo-exists-A ↖todo-is-writeable-A=true ?todo-completed-A +todo-completed-A=false" }
|
|
132
132
|
]
|
|
133
133
|
`)
|
|
@@ -155,7 +155,7 @@ describe('compactEvents todo app', () => {
|
|
|
155
155
|
const expected = compact([
|
|
156
156
|
mutations.createTodo({ id: 'A', text: 'buy milk' }), // 0
|
|
157
157
|
mutations.setReadonlyTodo({ id: 'A', readonly: false }), // 1
|
|
158
|
-
mutations.
|
|
158
|
+
mutations.todoCompleted({ id: 'A' }), // 2
|
|
159
159
|
mutations.setTextTodo({ id: 'A', text: 'buy soy milk' }), // 3
|
|
160
160
|
mutations.setReadonlyTodo({ id: 'A', readonly: true }), // 4
|
|
161
161
|
])
|
|
@@ -164,7 +164,7 @@ describe('compactEvents todo app', () => {
|
|
|
164
164
|
[
|
|
165
165
|
{ id: 0, parentId: -1, mutation: "createTodo", args: { id: "A", text: "buy milk" }, clientId: "client-id", sessionId: "session-id", facts: "+todo-exists-A +todo-is-writeable-A=true +todo-completed-A=false" }
|
|
166
166
|
{ id: 1, parentId: 0, mutation: "setReadonlyTodo", args: { id: "A", readonly: false }, clientId: "client-id", sessionId: "session-id", facts: "↖todo-exists-A +todo-is-writeable-A=true" }
|
|
167
|
-
{ id: 2, parentId: 1, mutation: "
|
|
167
|
+
{ id: 2, parentId: 1, mutation: "todoCompleted", args: { id: "A" }, clientId: "client-id", sessionId: "session-id", facts: "↖todo-exists-A ↖todo-is-writeable-A=true +todo-completed-A=true" }
|
|
168
168
|
{ id: 3, parentId: 2, mutation: "setTextTodo", args: { id: "A", text: "buy soy milk" }, clientId: "client-id", sessionId: "session-id", facts: "↖todo-exists-A ↖todo-is-writeable-A=true +todo-text-updated-A" }
|
|
169
169
|
{ id: 4, parentId: 3, mutation: "setReadonlyTodo", args: { id: "A", readonly: true }, clientId: "client-id", sessionId: "session-id", facts: "↖todo-exists-A +todo-is-writeable-A=false" }
|
|
170
170
|
]
|
|
@@ -188,14 +188,14 @@ describe('compactEvents todo app', () => {
|
|
|
188
188
|
`)
|
|
189
189
|
})
|
|
190
190
|
|
|
191
|
-
it('
|
|
191
|
+
it('todoCompleteds', () => {
|
|
192
192
|
const expected = compact([
|
|
193
193
|
mutations.createTodo({ id: 'A', text: 'buy milk' }), // 0
|
|
194
194
|
mutations.createTodo({ id: 'B', text: 'buy bread' }), // 1
|
|
195
195
|
mutations.createTodo({ id: 'C', text: 'buy cheese' }), // 2
|
|
196
|
-
mutations.
|
|
196
|
+
mutations.todoCompleteds({ ids: ['A', 'B', 'C'] }), // 3
|
|
197
197
|
mutations.toggleTodo({ id: 'A' }), // 4
|
|
198
|
-
mutations.
|
|
198
|
+
mutations.todoCompleted({ id: 'A' }), // 5
|
|
199
199
|
])
|
|
200
200
|
|
|
201
201
|
expect(expected).toMatchInlineSnapshot(`
|
|
@@ -203,21 +203,21 @@ describe('compactEvents todo app', () => {
|
|
|
203
203
|
{ id: 0, parentId: -1, mutation: "createTodo", args: { id: "A", text: "buy milk" }, clientId: "client-id", sessionId: "session-id", facts: "+todo-exists-A +todo-is-writeable-A=true +todo-completed-A=false" }
|
|
204
204
|
{ id: 1, parentId: 0, mutation: "createTodo", args: { id: "B", text: "buy bread" }, clientId: "client-id", sessionId: "session-id", facts: "+todo-exists-B +todo-is-writeable-B=true +todo-completed-B=false" }
|
|
205
205
|
{ id: 2, parentId: 1, mutation: "createTodo", args: { id: "C", text: "buy cheese" }, clientId: "client-id", sessionId: "session-id", facts: "+todo-exists-C +todo-is-writeable-C=true +todo-completed-C=false" }
|
|
206
|
-
{ id: 3, parentId: 2, mutation: "
|
|
207
|
-
{ id: 5, parentId: 3, mutation: "
|
|
206
|
+
{ id: 3, parentId: 2, mutation: "todoCompleteds", args: { ids: ["A", "B", "C"] }, clientId: "client-id", sessionId: "session-id", facts: "↖todo-exists-A ↖todo-is-writeable-A=true ↖todo-exists-B ↖todo-is-writeable-B=true ↖todo-exists-C ↖todo-is-writeable-C=true +todo-completed-A=true +todo-completed-B=true +todo-completed-C=true" }
|
|
207
|
+
{ id: 5, parentId: 3, mutation: "todoCompleted", args: { id: "A" }, clientId: "client-id", sessionId: "session-id", facts: "↖todo-exists-A ↖todo-is-writeable-A=true +todo-completed-A=true" }
|
|
208
208
|
]
|
|
209
209
|
`)
|
|
210
210
|
})
|
|
211
211
|
|
|
212
|
-
it('
|
|
212
|
+
it('todoCompleteds 2', () => {
|
|
213
213
|
const expected = compact([
|
|
214
214
|
mutations.createTodo({ id: 'A', text: 'buy milk' }), // 0
|
|
215
215
|
mutations.createTodo({ id: 'B', text: 'buy bread' }), // 1
|
|
216
216
|
mutations.createTodo({ id: 'C', text: 'buy cheese' }), // 2
|
|
217
217
|
mutations.toggleTodo({ id: 'A' }), // 3
|
|
218
|
-
mutations.
|
|
218
|
+
mutations.todoCompleteds({ ids: ['A', 'B', 'C'] }), // 4
|
|
219
219
|
mutations.toggleTodo({ id: 'A' }), // 5
|
|
220
|
-
mutations.
|
|
220
|
+
mutations.todoCompleted({ id: 'A' }), // 6
|
|
221
221
|
])
|
|
222
222
|
|
|
223
223
|
expect(expected).toMatchInlineSnapshot(`
|
|
@@ -225,8 +225,8 @@ describe('compactEvents todo app', () => {
|
|
|
225
225
|
{ id: 0, parentId: -1, mutation: "createTodo", args: { id: "A", text: "buy milk" }, clientId: "client-id", sessionId: "session-id", facts: "+todo-exists-A +todo-is-writeable-A=true +todo-completed-A=false" }
|
|
226
226
|
{ id: 1, parentId: 0, mutation: "createTodo", args: { id: "B", text: "buy bread" }, clientId: "client-id", sessionId: "session-id", facts: "+todo-exists-B +todo-is-writeable-B=true +todo-completed-B=false" }
|
|
227
227
|
{ id: 2, parentId: 1, mutation: "createTodo", args: { id: "C", text: "buy cheese" }, clientId: "client-id", sessionId: "session-id", facts: "+todo-exists-C +todo-is-writeable-C=true +todo-completed-C=false" }
|
|
228
|
-
{ id: 4, parentId: 2, mutation: "
|
|
229
|
-
{ id: 6, parentId: 4, mutation: "
|
|
228
|
+
{ id: 4, parentId: 2, mutation: "todoCompleteds", args: { ids: ["A", "B", "C"] }, clientId: "client-id", sessionId: "session-id", facts: "↖todo-exists-A ↖todo-is-writeable-A=true ↖todo-exists-B ↖todo-is-writeable-B=true ↖todo-exists-C ↖todo-is-writeable-C=true +todo-completed-A=true +todo-completed-B=true +todo-completed-C=true" }
|
|
229
|
+
{ id: 6, parentId: 4, mutation: "todoCompleted", args: { id: "A" }, clientId: "client-id", sessionId: "session-id", facts: "↖todo-exists-A ↖todo-is-writeable-A=true +todo-completed-A=true" }
|
|
230
230
|
]
|
|
231
231
|
`)
|
|
232
232
|
})
|
|
@@ -42,8 +42,8 @@ export const mutations = {
|
|
|
42
42
|
: { modify: { set: [facts.todoExists(id), facts.todoIsWriteable(id, true), facts.todoTextUpdated(id)] } },
|
|
43
43
|
},
|
|
44
44
|
),
|
|
45
|
-
|
|
46
|
-
'
|
|
45
|
+
todoCompleted: defineMutation(
|
|
46
|
+
'todoCompleted',
|
|
47
47
|
Schema.Struct({ id: Schema.String }),
|
|
48
48
|
// consider `RETURNING` to validate before applying facts
|
|
49
49
|
'UPDATE todos SET completed = true WHERE id = $id',
|
|
@@ -58,8 +58,8 @@ export const mutations = {
|
|
|
58
58
|
}),
|
|
59
59
|
},
|
|
60
60
|
),
|
|
61
|
-
|
|
62
|
-
'
|
|
61
|
+
todoUncompleted: defineMutation(
|
|
62
|
+
'todoUncompleted',
|
|
63
63
|
Schema.Struct({ id: Schema.String }),
|
|
64
64
|
'UPDATE todos SET completed = false WHERE id = $id',
|
|
65
65
|
{
|
|
@@ -69,8 +69,8 @@ export const mutations = {
|
|
|
69
69
|
}),
|
|
70
70
|
},
|
|
71
71
|
),
|
|
72
|
-
|
|
73
|
-
'
|
|
72
|
+
todoCompleteds: defineMutation(
|
|
73
|
+
'todoCompleteds',
|
|
74
74
|
Schema.Struct({ ids: Schema.Array(Schema.String) }),
|
|
75
75
|
'UPDATE todos SET completed = true WHERE id IN ($ids:csv)',
|
|
76
76
|
{
|
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.0-dev.
|
|
5
|
+
export const liveStoreVersion = '0.3.0-dev.15' as const
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* This version number is incremented whenever the internal storage format changes in a breaking way.
|
package/tsconfig.json
CHANGED