tinybase 8.6.0-beta.0 → 9.0.0-beta.1
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/@types/_internal/queries/with-schemas/index.d.ts +1 -2
- package/@types/_internal/ui/with-schemas/index.d.ts +8 -16
- package/@types/mergeable-store/index.d.ts +4 -4
- package/@types/mergeable-store/with-schemas/index.d.ts +41 -17
- package/@types/persisters/index.d.ts +34 -13
- package/@types/persisters/persister-durable-object-sql-storage/index.d.ts +9 -8
- package/@types/persisters/persister-durable-object-sql-storage/with-schemas/index.d.ts +10 -10
- package/@types/persisters/with-schemas/index.d.ts +72 -30
- package/@types/queries/index.d.ts +5 -7
- package/@types/queries/with-schemas/index.d.ts +9 -15
- package/@types/store/index.d.ts +1 -2
- package/@types/store/with-schemas/index.d.ts +19 -29
- package/@types/synchronizers/synchronizer-ws-client/index.d.ts +9 -3
- package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.ts +10 -3
- package/@types/synchronizers/synchronizer-ws-server/index.d.ts +15 -2
- package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.ts +17 -2
- package/@types/synchronizers/synchronizer-ws-server-durable-object/index.d.ts +51 -0
- package/@types/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.ts +51 -0
- package/@types/ui-react/with-schemas/index.d.ts +3 -6
- package/@types/ui-react-dom/with-schemas/index.d.ts +6 -12
- package/@types/ui-react-dom-charts/with-schemas/index.d.ts +3 -4
- package/@types/ui-solid/with-schemas/index.d.ts +4 -8
- package/@types/ui-solid-dom/with-schemas/index.d.ts +6 -12
- package/@types/ui-svelte-dom/with-schemas/index.d.ts +6 -12
- package/index.js +67 -25
- package/indexes/index.js +6 -8
- package/indexes/with-schemas/index.js +6 -8
- package/mergeable-store/index.js +46 -6
- package/mergeable-store/with-schemas/index.js +46 -6
- package/metrics/index.js +6 -8
- package/metrics/with-schemas/index.js +6 -8
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/mergeable-store/index.js +1 -1
- package/min/mergeable-store/index.js.gz +0 -0
- package/min/mergeable-store/with-schemas/index.js +1 -1
- package/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/persisters/index.js +1 -1
- package/min/persisters/index.js.gz +0 -0
- package/min/persisters/persister-automerge/index.js +1 -1
- package/min/persisters/persister-automerge/index.js.gz +0 -0
- package/min/persisters/persister-automerge/with-schemas/index.js +1 -1
- package/min/persisters/persister-automerge/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-browser/index.js +1 -1
- package/min/persisters/persister-browser/index.js.gz +0 -0
- package/min/persisters/persister-browser/with-schemas/index.js +1 -1
- package/min/persisters/persister-browser/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-cr-sqlite-wasm/index.js +1 -1
- package/min/persisters/persister-cr-sqlite-wasm/index.js.gz +0 -0
- package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +1 -1
- package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-sql-storage/index.js +1 -1
- package/min/persisters/persister-durable-object-sql-storage/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js +1 -1
- package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-storage/index.js +1 -1
- package/min/persisters/persister-durable-object-storage/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-storage/with-schemas/index.js +1 -1
- package/min/persisters/persister-durable-object-storage/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-electric-sql/index.js +1 -1
- package/min/persisters/persister-electric-sql/index.js.gz +0 -0
- package/min/persisters/persister-electric-sql/with-schemas/index.js +1 -1
- package/min/persisters/persister-electric-sql/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-expo-sqlite/index.js +1 -1
- package/min/persisters/persister-expo-sqlite/index.js.gz +0 -0
- package/min/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
- package/min/persisters/persister-expo-sqlite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-file/index.js +1 -1
- package/min/persisters/persister-file/index.js.gz +0 -0
- package/min/persisters/persister-file/with-schemas/index.js +1 -1
- package/min/persisters/persister-file/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-indexed-db/index.js +1 -1
- package/min/persisters/persister-indexed-db/index.js.gz +0 -0
- package/min/persisters/persister-indexed-db/with-schemas/index.js +1 -1
- package/min/persisters/persister-indexed-db/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-libsql/index.js +1 -1
- package/min/persisters/persister-libsql/index.js.gz +0 -0
- package/min/persisters/persister-libsql/with-schemas/index.js +1 -1
- package/min/persisters/persister-libsql/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-partykit-client/index.js +1 -1
- package/min/persisters/persister-partykit-client/index.js.gz +0 -0
- package/min/persisters/persister-partykit-client/with-schemas/index.js +1 -1
- package/min/persisters/persister-partykit-client/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-pglite/index.js +1 -1
- package/min/persisters/persister-pglite/index.js.gz +0 -0
- package/min/persisters/persister-pglite/with-schemas/index.js +1 -1
- package/min/persisters/persister-pglite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-postgres/index.js +1 -1
- package/min/persisters/persister-postgres/index.js.gz +0 -0
- package/min/persisters/persister-postgres/with-schemas/index.js +1 -1
- package/min/persisters/persister-postgres/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-powersync/index.js +1 -1
- package/min/persisters/persister-powersync/index.js.gz +0 -0
- package/min/persisters/persister-powersync/with-schemas/index.js +1 -1
- package/min/persisters/persister-powersync/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-react-native-mmkv/index.js +1 -1
- package/min/persisters/persister-react-native-mmkv/index.js.gz +0 -0
- package/min/persisters/persister-react-native-mmkv/with-schemas/index.js +1 -1
- package/min/persisters/persister-react-native-mmkv/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-react-native-sqlite/index.js +1 -1
- package/min/persisters/persister-react-native-sqlite/index.js.gz +0 -0
- package/min/persisters/persister-react-native-sqlite/with-schemas/index.js +1 -1
- package/min/persisters/persister-react-native-sqlite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-remote/index.js +1 -1
- package/min/persisters/persister-remote/index.js.gz +0 -0
- package/min/persisters/persister-remote/with-schemas/index.js +1 -1
- package/min/persisters/persister-remote/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-bun/index.js +1 -1
- package/min/persisters/persister-sqlite-bun/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-bun/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite-bun/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-wasm/index.js +1 -1
- package/min/persisters/persister-sqlite-wasm/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-wasm/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite-wasm/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite3/index.js +1 -1
- package/min/persisters/persister-sqlite3/index.js.gz +0 -0
- package/min/persisters/persister-sqlite3/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite3/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-yjs/index.js +1 -1
- package/min/persisters/persister-yjs/index.js.gz +0 -0
- package/min/persisters/persister-yjs/with-schemas/index.js +1 -1
- package/min/persisters/persister-yjs/with-schemas/index.js.gz +0 -0
- package/min/persisters/with-schemas/index.js +1 -1
- package/min/persisters/with-schemas/index.js.gz +0 -0
- package/min/queries/index.js +1 -1
- package/min/queries/index.js.gz +0 -0
- package/min/queries/with-schemas/index.js +1 -1
- package/min/queries/with-schemas/index.js.gz +0 -0
- package/min/store/index.js +1 -1
- package/min/store/index.js.gz +0 -0
- package/min/store/with-schemas/index.js +1 -1
- package/min/store/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/index.js +1 -1
- package/min/synchronizers/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-broadcast-channel/index.js +1 -1
- package/min/synchronizers/synchronizer-broadcast-channel/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-local/index.js +1 -1
- package/min/synchronizers/synchronizer-local/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-local/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/with-schemas/index.js +1 -1
- package/min/synchronizers/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/min/ui-solid-inspector/index.js +1 -1
- package/min/ui-solid-inspector/index.js.gz +0 -0
- package/min/ui-solid-inspector/with-schemas/index.js +1 -1
- package/min/ui-solid-inspector/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte-inspector/index.js +1 -1
- package/min/ui-svelte-inspector/index.js.gz +0 -0
- package/min/ui-svelte-inspector/with-schemas/index.js +1 -1
- package/min/ui-svelte-inspector/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/omni/index.js +364 -155
- package/omni/with-schemas/index.js +364 -155
- package/package.json +8 -8
- package/persisters/index.js +133 -40
- package/persisters/persister-automerge/index.js +4 -3
- package/persisters/persister-automerge/with-schemas/index.js +4 -3
- package/persisters/persister-browser/index.js +4 -3
- package/persisters/persister-browser/with-schemas/index.js +4 -3
- package/persisters/persister-cr-sqlite-wasm/index.js +133 -40
- package/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +133 -40
- package/persisters/persister-durable-object-sql-storage/index.js +275 -113
- package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +275 -113
- package/persisters/persister-durable-object-storage/index.js +4 -3
- package/persisters/persister-durable-object-storage/with-schemas/index.js +4 -3
- package/persisters/persister-electric-sql/index.js +133 -40
- package/persisters/persister-electric-sql/with-schemas/index.js +133 -40
- package/persisters/persister-expo-sqlite/index.js +133 -40
- package/persisters/persister-expo-sqlite/with-schemas/index.js +133 -40
- package/persisters/persister-file/index.js +4 -3
- package/persisters/persister-file/with-schemas/index.js +4 -3
- package/persisters/persister-indexed-db/index.js +4 -3
- package/persisters/persister-indexed-db/with-schemas/index.js +4 -3
- package/persisters/persister-libsql/index.js +133 -40
- package/persisters/persister-libsql/with-schemas/index.js +133 -40
- package/persisters/persister-partykit-client/index.js +4 -3
- package/persisters/persister-partykit-client/with-schemas/index.js +4 -3
- package/persisters/persister-pglite/index.js +134 -40
- package/persisters/persister-pglite/with-schemas/index.js +134 -40
- package/persisters/persister-postgres/index.js +134 -40
- package/persisters/persister-postgres/with-schemas/index.js +134 -40
- package/persisters/persister-powersync/index.js +186 -120
- package/persisters/persister-powersync/with-schemas/index.js +186 -120
- package/persisters/persister-react-native-mmkv/index.js +4 -3
- package/persisters/persister-react-native-mmkv/with-schemas/index.js +4 -3
- package/persisters/persister-react-native-sqlite/index.js +133 -40
- package/persisters/persister-react-native-sqlite/with-schemas/index.js +133 -40
- package/persisters/persister-remote/index.js +4 -3
- package/persisters/persister-remote/with-schemas/index.js +4 -3
- package/persisters/persister-sqlite-bun/index.js +133 -40
- package/persisters/persister-sqlite-bun/with-schemas/index.js +133 -40
- package/persisters/persister-sqlite-wasm/index.js +133 -40
- package/persisters/persister-sqlite-wasm/with-schemas/index.js +133 -40
- package/persisters/persister-sqlite3/index.js +133 -40
- package/persisters/persister-sqlite3/with-schemas/index.js +133 -40
- package/persisters/persister-yjs/index.js +4 -3
- package/persisters/persister-yjs/with-schemas/index.js +4 -3
- package/persisters/with-schemas/index.js +133 -40
- package/queries/index.js +21 -19
- package/queries/with-schemas/index.js +21 -19
- package/readme.md +14 -14
- package/relationships/index.js +6 -8
- package/relationships/with-schemas/index.js +6 -8
- package/releases.md +72 -57
- package/store/index.js +33 -2
- package/store/with-schemas/index.js +33 -2
- package/synchronizers/index.js +4 -3
- package/synchronizers/synchronizer-broadcast-channel/index.js +4 -3
- package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +4 -3
- package/synchronizers/synchronizer-local/index.js +4 -3
- package/synchronizers/synchronizer-local/with-schemas/index.js +4 -3
- package/synchronizers/synchronizer-ws-client/index.js +120 -45
- package/synchronizers/synchronizer-ws-client/with-schemas/index.js +120 -45
- package/synchronizers/synchronizer-ws-server/index.js +116 -36
- package/synchronizers/synchronizer-ws-server/with-schemas/index.js +116 -36
- package/synchronizers/synchronizer-ws-server-durable-object/index.js +125 -41
- package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +125 -41
- package/synchronizers/with-schemas/index.js +4 -3
- package/ui-react-inspector/index.js +36 -5
- package/ui-react-inspector/with-schemas/index.js +36 -5
- package/ui-solid-inspector/index.js +36 -5
- package/ui-solid-inspector/with-schemas/index.js +36 -5
- package/ui-svelte/index.js +1 -1
- package/ui-svelte/with-schemas/index.js +1 -1
- package/ui-svelte-dom/index.js +2 -2
- package/ui-svelte-dom/with-schemas/index.js +2 -2
- package/ui-svelte-inspector/index.js +38 -7
- package/ui-svelte-inspector/with-schemas/index.js +38 -7
- package/with-schemas/index.js +67 -25
|
@@ -12,8 +12,7 @@ import type {
|
|
|
12
12
|
export type JoinedCellIdOrId<
|
|
13
13
|
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
14
14
|
JoinedTableId extends TableIdFromSchema<Schema> | Id =
|
|
15
|
-
|
|
16
|
-
| Id,
|
|
15
|
+
TableIdFromSchema<Schema> | Id,
|
|
17
16
|
> =
|
|
18
17
|
JoinedTableId extends TableIdFromSchema<Schema>
|
|
19
18
|
? CellIdFromSchema<Schema, JoinedTableId>
|
|
@@ -15,33 +15,25 @@ import type {
|
|
|
15
15
|
import type {Synchronizer} from '../../../synchronizers/with-schemas/index.d.ts';
|
|
16
16
|
|
|
17
17
|
export type StoreOrStoreId<Schemas extends OptionalSchemas> =
|
|
18
|
-
|
|
19
|
-
| Id;
|
|
18
|
+
Store<Schemas> | Id;
|
|
20
19
|
|
|
21
20
|
export type MetricsOrMetricsId<Schemas extends OptionalSchemas> =
|
|
22
|
-
|
|
23
|
-
| Id;
|
|
21
|
+
Metrics<Schemas> | Id;
|
|
24
22
|
|
|
25
23
|
export type IndexesOrIndexesId<Schemas extends OptionalSchemas> =
|
|
26
|
-
|
|
27
|
-
| Id;
|
|
24
|
+
Indexes<Schemas> | Id;
|
|
28
25
|
|
|
29
26
|
export type RelationshipsOrRelationshipsId<Schemas extends OptionalSchemas> =
|
|
30
|
-
|
|
31
|
-
| Id;
|
|
27
|
+
Relationships<Schemas> | Id;
|
|
32
28
|
|
|
33
29
|
export type QueriesOrQueriesId<Schemas extends OptionalSchemas> =
|
|
34
|
-
|
|
35
|
-
| Id;
|
|
30
|
+
Queries<Schemas> | Id;
|
|
36
31
|
|
|
37
32
|
export type CheckpointsOrCheckpointsId<Schemas extends OptionalSchemas> =
|
|
38
|
-
|
|
39
|
-
| Id;
|
|
33
|
+
Checkpoints<Schemas> | Id;
|
|
40
34
|
|
|
41
35
|
export type PersisterOrPersisterId<Schemas extends OptionalSchemas> =
|
|
42
|
-
|
|
43
|
-
| Id;
|
|
36
|
+
Persister<Schemas, Persists.StoreOrMergeableStore> | Id;
|
|
44
37
|
|
|
45
38
|
export type SynchronizerOrSynchronizerId<Schemas extends OptionalSchemas> =
|
|
46
|
-
|
|
47
|
-
| Id;
|
|
39
|
+
Synchronizer<Schemas> | Id;
|
|
@@ -1097,19 +1097,19 @@ export interface MergeableStore extends Store {
|
|
|
1097
1097
|
* {
|
|
1098
1098
|
* fido: [
|
|
1099
1099
|
* {
|
|
1100
|
-
* sold: [false, '
|
|
1100
|
+
* sold: [false, '', 3177411910],
|
|
1101
1101
|
* species: ['dog', 'Nn1JUF----1FnHIC', 2817056260],
|
|
1102
1102
|
* },
|
|
1103
1103
|
* '',
|
|
1104
|
-
*
|
|
1104
|
+
* 3078067457,
|
|
1105
1105
|
* ],
|
|
1106
1106
|
* },
|
|
1107
1107
|
* '',
|
|
1108
|
-
*
|
|
1108
|
+
* 1137907280,
|
|
1109
1109
|
* ],
|
|
1110
1110
|
* },
|
|
1111
1111
|
* '',
|
|
1112
|
-
*
|
|
1112
|
+
* 401719767,
|
|
1113
1113
|
* ],
|
|
1114
1114
|
* [{}, '', 0],
|
|
1115
1115
|
* ];
|
|
@@ -91,12 +91,14 @@ export type ContentHashes = [tablesHash: Hash, valuesHash: Hash];
|
|
|
91
91
|
export type TablesStamp<
|
|
92
92
|
Schema extends OptionalTablesSchema,
|
|
93
93
|
Hashed extends boolean = false,
|
|
94
|
+
WhenSet extends boolean = false,
|
|
94
95
|
> = Stamp<
|
|
95
96
|
{
|
|
96
97
|
[TableId in TableIdFromSchema<Schema>]?: TableStamp<
|
|
97
98
|
Schema,
|
|
98
99
|
TableId,
|
|
99
|
-
Hashed
|
|
100
|
+
Hashed,
|
|
101
|
+
WhenSet
|
|
100
102
|
>;
|
|
101
103
|
},
|
|
102
104
|
Hashed
|
|
@@ -146,7 +148,8 @@ export type TableStamp<
|
|
|
146
148
|
Schema extends OptionalTablesSchema,
|
|
147
149
|
TableId extends TableIdFromSchema<Schema>,
|
|
148
150
|
Hashed extends boolean = false,
|
|
149
|
-
|
|
151
|
+
WhenSet extends boolean = false,
|
|
152
|
+
> = Stamp<{[rowId: Id]: RowStamp<Schema, TableId, Hashed, WhenSet>}, Hashed>;
|
|
150
153
|
|
|
151
154
|
/**
|
|
152
155
|
* The RowHashes type is used to quickly compare the content of two sets of Row
|
|
@@ -192,13 +195,15 @@ export type RowStamp<
|
|
|
192
195
|
Schema extends OptionalTablesSchema,
|
|
193
196
|
TableId extends TableIdFromSchema<Schema>,
|
|
194
197
|
Hashed extends boolean = false,
|
|
198
|
+
WhenSet extends boolean = false,
|
|
195
199
|
> = Stamp<
|
|
196
200
|
{
|
|
197
201
|
[CellId in CellIdFromSchema<Schema, TableId>]?: CellStamp<
|
|
198
202
|
Schema,
|
|
199
203
|
TableId,
|
|
200
204
|
CellId,
|
|
201
|
-
Hashed
|
|
205
|
+
Hashed,
|
|
206
|
+
WhenSet
|
|
202
207
|
>;
|
|
203
208
|
},
|
|
204
209
|
Hashed
|
|
@@ -251,7 +256,13 @@ export type CellStamp<
|
|
|
251
256
|
TableId extends TableIdFromSchema<Schema>,
|
|
252
257
|
CellId extends CellIdFromSchema<Schema, TableId>,
|
|
253
258
|
Hashed extends boolean = false,
|
|
254
|
-
|
|
259
|
+
WhenSet extends boolean = false,
|
|
260
|
+
> = Stamp<
|
|
261
|
+
WhenSet extends true
|
|
262
|
+
? CellOrUndefined<Schema, TableId, CellId>
|
|
263
|
+
: CellOrUndefined<Schema, TableId, CellId>,
|
|
264
|
+
Hashed
|
|
265
|
+
>;
|
|
255
266
|
|
|
256
267
|
/**
|
|
257
268
|
* The ValuesStamp type is used as metadata to decide how to merge two different
|
|
@@ -274,12 +285,14 @@ export type CellStamp<
|
|
|
274
285
|
export type ValuesStamp<
|
|
275
286
|
Schema extends OptionalValuesSchema,
|
|
276
287
|
Hashed extends boolean = false,
|
|
288
|
+
WhenSet extends boolean = false,
|
|
277
289
|
> = Stamp<
|
|
278
290
|
{
|
|
279
291
|
[ValueId in ValueIdFromSchema<Schema>]?: ValueStamp<
|
|
280
292
|
Schema,
|
|
281
293
|
ValueId,
|
|
282
|
-
Hashed
|
|
294
|
+
Hashed,
|
|
295
|
+
WhenSet
|
|
283
296
|
>;
|
|
284
297
|
},
|
|
285
298
|
Hashed
|
|
@@ -329,7 +342,13 @@ export type ValueStamp<
|
|
|
329
342
|
Schema extends OptionalValuesSchema,
|
|
330
343
|
ValueId extends ValueIdFromSchema<Schema>,
|
|
331
344
|
Hashed extends boolean = false,
|
|
332
|
-
|
|
345
|
+
WhenSet extends boolean = false,
|
|
346
|
+
> = Stamp<
|
|
347
|
+
WhenSet extends true
|
|
348
|
+
? ValueOrUndefined<Schema, ValueId>
|
|
349
|
+
: ValueOrUndefined<Schema, ValueId>,
|
|
350
|
+
Hashed
|
|
351
|
+
>;
|
|
333
352
|
|
|
334
353
|
/**
|
|
335
354
|
* The MergeableContent type represents the content of a MergeableStore and the
|
|
@@ -352,9 +371,12 @@ export type ValueStamp<
|
|
|
352
371
|
* @category Mergeable
|
|
353
372
|
* @since v5.0.0
|
|
354
373
|
*/
|
|
355
|
-
export type MergeableContent<
|
|
356
|
-
|
|
357
|
-
|
|
374
|
+
export type MergeableContent<
|
|
375
|
+
Schemas extends OptionalSchemas,
|
|
376
|
+
WhenSet extends boolean = false,
|
|
377
|
+
> = [
|
|
378
|
+
mergeableTables: TablesStamp<Schemas[0], true, WhenSet>,
|
|
379
|
+
mergeableValues: ValuesStamp<Schemas[1], true, WhenSet>,
|
|
358
380
|
];
|
|
359
381
|
|
|
360
382
|
/**
|
|
@@ -384,9 +406,10 @@ export type MergeableContent<Schemas extends OptionalSchemas> = [
|
|
|
384
406
|
export type MergeableChanges<
|
|
385
407
|
Schemas extends OptionalSchemas,
|
|
386
408
|
Hashed extends boolean = false,
|
|
409
|
+
WhenSet extends boolean = false,
|
|
387
410
|
> = [
|
|
388
|
-
mergeableTables: TablesStamp<Schemas[0], Hashed>,
|
|
389
|
-
mergeableValues: ValuesStamp<Schemas[1], Hashed>,
|
|
411
|
+
mergeableTables: TablesStamp<Schemas[0], Hashed, WhenSet>,
|
|
412
|
+
mergeableValues: ValuesStamp<Schemas[1], Hashed, WhenSet>,
|
|
390
413
|
isChanges: 1,
|
|
391
414
|
];
|
|
392
415
|
|
|
@@ -1017,7 +1040,7 @@ export interface MergeableStore<
|
|
|
1017
1040
|
* @since v5.0.0
|
|
1018
1041
|
*/
|
|
1019
1042
|
setMergeableContent(
|
|
1020
|
-
mergeableContent: MergeableContent<Schemas>,
|
|
1043
|
+
mergeableContent: MergeableContent<Schemas, true>,
|
|
1021
1044
|
): MergeableStore<Schemas>;
|
|
1022
1045
|
|
|
1023
1046
|
/**
|
|
@@ -1161,7 +1184,8 @@ export interface MergeableStore<
|
|
|
1161
1184
|
* @since v5.0.0
|
|
1162
1185
|
*/
|
|
1163
1186
|
applyMergeableChanges(
|
|
1164
|
-
mergeableChanges:
|
|
1187
|
+
mergeableChanges:
|
|
1188
|
+
MergeableChanges<Schemas, false, true> | MergeableContent<Schemas, true>,
|
|
1165
1189
|
): MergeableStore<Schemas>;
|
|
1166
1190
|
|
|
1167
1191
|
/**
|
|
@@ -1590,19 +1614,19 @@ export interface MergeableStore<
|
|
|
1590
1614
|
* {
|
|
1591
1615
|
* fido: [
|
|
1592
1616
|
* {
|
|
1593
|
-
* sold: [false, '
|
|
1617
|
+
* sold: [false, '', 3177411910],
|
|
1594
1618
|
* species: ['dog', 'Nn1JUF----1FnHIC', 2817056260],
|
|
1595
1619
|
* },
|
|
1596
1620
|
* '',
|
|
1597
|
-
*
|
|
1621
|
+
* 3078067457,
|
|
1598
1622
|
* ],
|
|
1599
1623
|
* },
|
|
1600
1624
|
* '',
|
|
1601
|
-
*
|
|
1625
|
+
* 1137907280,
|
|
1602
1626
|
* ],
|
|
1603
1627
|
* },
|
|
1604
1628
|
* '',
|
|
1605
|
-
*
|
|
1629
|
+
* 401719767,
|
|
1606
1630
|
* ],
|
|
1607
1631
|
* [{}, '', 0],
|
|
1608
1632
|
* ];
|
|
@@ -205,10 +205,10 @@ export type PersistedChanges<
|
|
|
205
205
|
* neither are present, the content will be loaded using the Persister's load
|
|
206
206
|
* method. Prior to v5.0, these parameters were callbacks and the overall type
|
|
207
207
|
* was non-generic.
|
|
208
|
-
* @param content If provided, this is a Content object from the Persister
|
|
209
|
-
*
|
|
210
|
-
* @param changes If provided, this is a Changes object from the Persister
|
|
211
|
-
*
|
|
208
|
+
* @param content If provided, this is a Content object from the Persister that
|
|
209
|
+
* will be used to immediately wholesale update the Store.
|
|
210
|
+
* @param changes If provided, this is a Changes object from the Persister that
|
|
211
|
+
* will be used to immediately incrementally update the Store. This takes
|
|
212
212
|
* priority over the content argument above if present.
|
|
213
213
|
* @category Creation
|
|
214
214
|
* @since v4.0.0
|
|
@@ -801,12 +801,15 @@ export type DpcTabularSave = {
|
|
|
801
801
|
* Note that both loading and saving of Values from and to the database are
|
|
802
802
|
* disabled by default.
|
|
803
803
|
*
|
|
804
|
+
* The `load` and `save` properties can be set to `true` to persist all Values,
|
|
805
|
+
* or to a DpcTabularValuesIn array to persist just a subset of Value Ids.
|
|
806
|
+
*
|
|
804
807
|
* The 'Dpc' prefix indicates that this type is used within the
|
|
805
808
|
* DatabasePersisterConfig type.
|
|
806
809
|
* @example
|
|
807
810
|
* When applied to a database Persister, this DatabasePersisterConfig will load
|
|
808
|
-
* and save the data of
|
|
809
|
-
*
|
|
811
|
+
* and save the data of two Store Values into a database table called
|
|
812
|
+
* 'my_tinybase_values'.
|
|
810
813
|
*
|
|
811
814
|
* ```js
|
|
812
815
|
* import type {DatabasePersisterConfig} from 'tinybase';
|
|
@@ -814,8 +817,8 @@ export type DpcTabularSave = {
|
|
|
814
817
|
* export const databasePersisterConfig: DatabasePersisterConfig = {
|
|
815
818
|
* mode: 'tabular',
|
|
816
819
|
* values: {
|
|
817
|
-
* load:
|
|
818
|
-
* save:
|
|
820
|
+
* load: ['selectedPet', 'open'],
|
|
821
|
+
* save: ['selectedPet', 'open'],
|
|
819
822
|
* tableName: 'my_tinybase_values',
|
|
820
823
|
* },
|
|
821
824
|
* };
|
|
@@ -825,17 +828,19 @@ export type DpcTabularSave = {
|
|
|
825
828
|
*/
|
|
826
829
|
export type DpcTabularValues = {
|
|
827
830
|
/**
|
|
828
|
-
* Whether Store Values will be loaded from a database table
|
|
831
|
+
* Whether Store Values will be loaded from a database table, or the subset of
|
|
832
|
+
* Value Ids that will be loaded.
|
|
829
833
|
* @category Configuration
|
|
830
834
|
* @since v4.0.0
|
|
831
835
|
*/
|
|
832
|
-
load?: boolean;
|
|
836
|
+
load?: boolean | DpcTabularValuesIn;
|
|
833
837
|
/**
|
|
834
|
-
* Whether Store Values will be saved to a database table
|
|
838
|
+
* Whether Store Values will be saved to a database table, or the subset of
|
|
839
|
+
* Value Ids that will be saved.
|
|
835
840
|
* @category Configuration
|
|
836
841
|
* @since v4.0.0
|
|
837
842
|
*/
|
|
838
|
-
save?: boolean;
|
|
843
|
+
save?: boolean | DpcTabularValuesIn;
|
|
839
844
|
/**
|
|
840
845
|
* The optional name of the database table from and to which the Store Values
|
|
841
846
|
* should be loaded or saved, defaulting to `tinybase_values`.
|
|
@@ -845,6 +850,21 @@ export type DpcTabularValues = {
|
|
|
845
850
|
tableName?: string;
|
|
846
851
|
};
|
|
847
852
|
|
|
853
|
+
/**
|
|
854
|
+
* The DpcTabularValuesIn type describes the subset of Store Values that are
|
|
855
|
+
* persisted by the DpcTabularValues type.
|
|
856
|
+
*
|
|
857
|
+
* When used as the DpcTabularValues `load` or `save` property, only the listed
|
|
858
|
+
* Value Ids will be loaded from or saved to the database table. Unlisted
|
|
859
|
+
* database columns are ignored on load and left untouched on save.
|
|
860
|
+
*
|
|
861
|
+
* The 'Dpc' prefix indicates that this type is used within the
|
|
862
|
+
* DatabasePersisterConfig type.
|
|
863
|
+
* @category Configuration
|
|
864
|
+
* @since v9.0.0
|
|
865
|
+
*/
|
|
866
|
+
export type DpcTabularValuesIn = Id[];
|
|
867
|
+
|
|
848
868
|
/**
|
|
849
869
|
* A Persister object lets you save and load Store data to and from different
|
|
850
870
|
* locations, or underlying storage types.
|
|
@@ -1740,7 +1760,8 @@ export type DatabaseChangeListener = (tableName: string) => void;
|
|
|
1740
1760
|
* `stopListeningToPersisted` has been renamed `delPersisterListener`.
|
|
1741
1761
|
* @param store The Store to persist.
|
|
1742
1762
|
* @param getPersisted An asynchronous function which will fetch content from
|
|
1743
|
-
* the persistence layer
|
|
1763
|
+
* the persistence layer. If it returns `undefined`, the load will use the
|
|
1764
|
+
* provided initial content if present, and otherwise leave the Store unchanged.
|
|
1744
1765
|
* @param setPersisted An asynchronous function which will send content to the
|
|
1745
1766
|
* persistence layer. Since v4.0, it receives functions for getting the Store
|
|
1746
1767
|
* content and information about the changes made during a transaction. Since
|
|
@@ -30,10 +30,10 @@ import type {DpcJson, Persister, Persists} from '../index.d.ts';
|
|
|
30
30
|
* The DpcFragmented type represents the configuration for fragmented
|
|
31
31
|
* persistence mode in a DurableObjectSqlStoragePersister.
|
|
32
32
|
*
|
|
33
|
-
* This mode stores each table, row
|
|
34
|
-
* avoiding Cloudflare's 2MB row limit that can be hit with
|
|
35
|
-
* mode. While this creates more database writes
|
|
36
|
-
* for larger datasets.
|
|
33
|
+
* This mode stores each table's metadata, row data, and values as separate
|
|
34
|
+
* database rows, avoiding Cloudflare's 2MB row limit that can be hit with
|
|
35
|
+
* large stores in JSON mode. While this creates more database writes than JSON
|
|
36
|
+
* mode, it provides better scalability for larger datasets.
|
|
37
37
|
* @example
|
|
38
38
|
* This example shows how to configure a DurableObjectSqlStoragePersister to use
|
|
39
39
|
* fragmented mode with a custom storage prefix.
|
|
@@ -220,10 +220,11 @@ export interface DurableObjectSqlStoragePersister extends Persister<Persists.Mer
|
|
|
220
220
|
* database row. This is efficient for smaller stores but may hit Cloudflare's
|
|
221
221
|
* 2MB row limit for very large stores and uses fewer database writes.
|
|
222
222
|
*
|
|
223
|
-
* - **Fragmented Mode**: Stores each table, row
|
|
224
|
-
* database rows. Use this mode if you're concerned about hitting
|
|
225
|
-
* 2MB row limit with large stores in JSON mode. This mode
|
|
226
|
-
* database writes but avoids row size
|
|
223
|
+
* - **Fragmented Mode**: Stores each table's metadata, row data, and values as
|
|
224
|
+
* separate database rows. Use this mode if you're concerned about hitting
|
|
225
|
+
* Cloudflare's 2MB row limit with large stores in JSON mode. This mode
|
|
226
|
+
* creates more database writes than JSON mode but avoids row size
|
|
227
|
+
* limitations.
|
|
227
228
|
*
|
|
228
229
|
* The third argument is a DatabasePersisterConfig object that configures which
|
|
229
230
|
* of those modes to use, and settings for each. If the third argument is simply
|
|
@@ -38,10 +38,10 @@ import type {
|
|
|
38
38
|
* The DpcFragmented type represents the configuration for fragmented
|
|
39
39
|
* persistence mode in a DurableObjectSqlStoragePersister.
|
|
40
40
|
*
|
|
41
|
-
* This mode stores each table, row
|
|
42
|
-
* avoiding Cloudflare's 2MB row limit that can be hit with
|
|
43
|
-
* mode. While this creates more database writes
|
|
44
|
-
* for larger datasets.
|
|
41
|
+
* This mode stores each table's metadata, row data, and values as separate
|
|
42
|
+
* database rows, avoiding Cloudflare's 2MB row limit that can be hit with
|
|
43
|
+
* large stores in JSON mode. While this creates more database writes than JSON
|
|
44
|
+
* mode, it provides better scalability for larger datasets.
|
|
45
45
|
* @example
|
|
46
46
|
* This example shows how to configure a DurableObjectSqlStoragePersister to use
|
|
47
47
|
* fragmented mode with a custom storage prefix.
|
|
@@ -250,10 +250,11 @@ export interface DurableObjectSqlStoragePersister<
|
|
|
250
250
|
* database row. This is efficient for smaller stores but may hit Cloudflare's
|
|
251
251
|
* 2MB row limit for very large stores and uses fewer database writes.
|
|
252
252
|
*
|
|
253
|
-
* - **Fragmented Mode**: Stores each table, row
|
|
254
|
-
* database rows. Use this mode if you're concerned about hitting
|
|
255
|
-
* 2MB row limit with large stores in JSON mode. This mode
|
|
256
|
-
* database writes but avoids row size
|
|
253
|
+
* - **Fragmented Mode**: Stores each table's metadata, row data, and values as
|
|
254
|
+
* separate database rows. Use this mode if you're concerned about hitting
|
|
255
|
+
* Cloudflare's 2MB row limit with large stores in JSON mode. This mode
|
|
256
|
+
* creates more database writes than JSON mode but avoids row size
|
|
257
|
+
* limitations.
|
|
257
258
|
*
|
|
258
259
|
* The third argument is a DatabasePersisterConfig object that configures which
|
|
259
260
|
* of those modes to use, and settings for each. If the third argument is simply
|
|
@@ -379,8 +380,7 @@ export function createDurableObjectSqlStoragePersister<
|
|
|
379
380
|
store: Store<Schemas> | MergeableStore<Schemas>,
|
|
380
381
|
sqlStorage: SqlStorage,
|
|
381
382
|
configOrStoreTableName?:
|
|
382
|
-
|
|
383
|
-
| string,
|
|
383
|
+
DurableObjectSqlDatabasePersisterConfig<Schemas> | string,
|
|
384
384
|
onSqlCommand?: (sql: string, params?: any[]) => void,
|
|
385
385
|
onIgnoredError?: (error: any) => void,
|
|
386
386
|
): DurableObjectSqlStoragePersister<Schemas>;
|
|
@@ -55,7 +55,10 @@
|
|
|
55
55
|
* @module persisters
|
|
56
56
|
* @since v1.0.0
|
|
57
57
|
*/
|
|
58
|
-
import type {
|
|
58
|
+
import type {
|
|
59
|
+
TableIdFromSchema,
|
|
60
|
+
ValueIdFromSchema,
|
|
61
|
+
} from '../../_internal/store/with-schemas/index.d.ts';
|
|
59
62
|
import type {
|
|
60
63
|
MergeableChanges,
|
|
61
64
|
MergeableContent,
|
|
@@ -66,6 +69,7 @@ import type {
|
|
|
66
69
|
Content,
|
|
67
70
|
OptionalSchemas,
|
|
68
71
|
OptionalTablesSchema,
|
|
72
|
+
OptionalValuesSchema,
|
|
69
73
|
Store,
|
|
70
74
|
} from '../../store/with-schemas/index.d.ts';
|
|
71
75
|
import type {Id} from '../../with-schemas/index.d.ts';
|
|
@@ -198,11 +202,12 @@ export type PersistedStore<
|
|
|
198
202
|
export type PersistedContent<
|
|
199
203
|
Schemas extends OptionalSchemas,
|
|
200
204
|
Persist extends Persists = Persists.StoreOnly,
|
|
205
|
+
WhenSet extends boolean = false,
|
|
201
206
|
> = Persist extends Persists.StoreOrMergeableStore
|
|
202
|
-
? Content<Schemas> | MergeableContent<Schemas>
|
|
207
|
+
? Content<Schemas, WhenSet> | MergeableContent<Schemas, WhenSet>
|
|
203
208
|
: Persist extends Persists.MergeableStoreOnly
|
|
204
|
-
? MergeableContent<Schemas>
|
|
205
|
-
: Content<Schemas>;
|
|
209
|
+
? MergeableContent<Schemas, WhenSet>
|
|
210
|
+
: Content<Schemas, WhenSet>;
|
|
206
211
|
|
|
207
212
|
/**
|
|
208
213
|
* The PersistedChanges type is a generic representation of changes made to the
|
|
@@ -231,10 +236,11 @@ export type PersistedContent<
|
|
|
231
236
|
export type PersistedChanges<
|
|
232
237
|
Schemas extends OptionalSchemas,
|
|
233
238
|
Persist extends Persists = Persists.StoreOnly,
|
|
239
|
+
WhenSet extends boolean = false,
|
|
234
240
|
> = Persist extends Persists.StoreOrMergeableStore
|
|
235
|
-
? Changes<Schemas> | MergeableChanges<Schemas>
|
|
241
|
+
? Changes<Schemas> | MergeableChanges<Schemas, false, WhenSet>
|
|
236
242
|
: Persist extends Persists.MergeableStoreOnly
|
|
237
|
-
? MergeableChanges<Schemas>
|
|
243
|
+
? MergeableChanges<Schemas, false, WhenSet>
|
|
238
244
|
: Changes<Schemas>;
|
|
239
245
|
|
|
240
246
|
/**
|
|
@@ -260,10 +266,10 @@ export type PersistedChanges<
|
|
|
260
266
|
* neither are present, the content will be loaded using the Persister's load
|
|
261
267
|
* method. Prior to v5.0, these parameters were callbacks and the overall type
|
|
262
268
|
* was non-generic.
|
|
263
|
-
* @param content If provided, this is a Content object from the Persister
|
|
264
|
-
*
|
|
265
|
-
* @param changes If provided, this is a Changes object from the Persister
|
|
266
|
-
*
|
|
269
|
+
* @param content If provided, this is a Content object from the Persister that
|
|
270
|
+
* will be used to immediately wholesale update the Store.
|
|
271
|
+
* @param changes If provided, this is a Changes object from the Persister that
|
|
272
|
+
* will be used to immediately incrementally update the Store. This takes
|
|
267
273
|
* priority over the content argument above if present.
|
|
268
274
|
* @category Creation
|
|
269
275
|
* @since v4.0.0
|
|
@@ -271,9 +277,10 @@ export type PersistedChanges<
|
|
|
271
277
|
export type PersisterListener<
|
|
272
278
|
Schemas extends OptionalSchemas,
|
|
273
279
|
Persist extends Persists = Persists.StoreOnly,
|
|
280
|
+
WhenSet extends boolean = false,
|
|
274
281
|
> = (
|
|
275
|
-
content?: PersistedContent<Schemas, Persist>,
|
|
276
|
-
changes?: PersistedChanges<Schemas, Persist>,
|
|
282
|
+
content?: PersistedContent<Schemas, Persist, WhenSet>,
|
|
283
|
+
changes?: PersistedChanges<Schemas, Persist, WhenSet>,
|
|
277
284
|
) => void;
|
|
278
285
|
|
|
279
286
|
/**
|
|
@@ -394,8 +401,7 @@ export type PersisterStats = {
|
|
|
394
401
|
* @since v4.0.0
|
|
395
402
|
*/
|
|
396
403
|
export type DatabasePersisterConfig<Schemas extends OptionalSchemas> =
|
|
397
|
-
|
|
|
398
|
-
| DpcTabular<Schemas[0]>;
|
|
404
|
+
DpcJson | DpcTabular<Schemas[0], Schemas[1]>;
|
|
399
405
|
|
|
400
406
|
/**
|
|
401
407
|
* The DpcJson type describes the configuration of a database-oriented Persister
|
|
@@ -552,7 +558,10 @@ export type DpcJson = {
|
|
|
552
558
|
* @category Configuration
|
|
553
559
|
* @since v4.0.0
|
|
554
560
|
*/
|
|
555
|
-
export type DpcTabular<
|
|
561
|
+
export type DpcTabular<
|
|
562
|
+
TablesSchema extends OptionalTablesSchema,
|
|
563
|
+
ValuesSchema extends OptionalValuesSchema = OptionalValuesSchema,
|
|
564
|
+
> = {
|
|
556
565
|
/**
|
|
557
566
|
* The mode to be used for persisting the Store to the database, in this case
|
|
558
567
|
* tabular mapping. See the DpcJson type for the alternative JSON
|
|
@@ -573,21 +582,21 @@ export type DpcTabular<Schema extends OptionalTablesSchema> = {
|
|
|
573
582
|
* @category Configuration
|
|
574
583
|
* @since v4.0.0
|
|
575
584
|
*/
|
|
576
|
-
load?: DpcTabularLoad<
|
|
585
|
+
load?: DpcTabularLoad<TablesSchema>;
|
|
577
586
|
/**
|
|
578
587
|
* The settings for how the Store Tables are mapped out to the database
|
|
579
588
|
* tables when saving.
|
|
580
589
|
* @category Configuration
|
|
581
590
|
* @since v4.0.0
|
|
582
591
|
*/
|
|
583
|
-
save?: DpcTabularSave<
|
|
592
|
+
save?: DpcTabularSave<TablesSchema>;
|
|
584
593
|
};
|
|
585
594
|
/**
|
|
586
595
|
* The settings for how the Store Values are mapped to and from the database.
|
|
587
596
|
* @category Configuration
|
|
588
597
|
* @since v4.0.0
|
|
589
598
|
*/
|
|
590
|
-
values?: DpcTabularValues
|
|
599
|
+
values?: DpcTabularValues<ValuesSchema>;
|
|
591
600
|
/**
|
|
592
601
|
* How often the Persister should poll the database for any changes made to it
|
|
593
602
|
* by other clients, defaulting to 1 second.
|
|
@@ -876,12 +885,15 @@ export type DpcTabularSave<Schema extends OptionalTablesSchema> = {
|
|
|
876
885
|
* Note that both loading and saving of Values from and to the database are
|
|
877
886
|
* disabled by default.
|
|
878
887
|
*
|
|
888
|
+
* The `load` and `save` properties can be set to `true` to persist all Values,
|
|
889
|
+
* or to a DpcTabularValuesIn array to persist just a subset of Value Ids.
|
|
890
|
+
*
|
|
879
891
|
* The 'Dpc' prefix indicates that this type is used within the
|
|
880
892
|
* DatabasePersisterConfig type.
|
|
881
893
|
* @example
|
|
882
894
|
* When applied to a database Persister, this DatabasePersisterConfig will load
|
|
883
|
-
* and save the data of
|
|
884
|
-
*
|
|
895
|
+
* and save the data of two Store Values into a database table called
|
|
896
|
+
* 'my_tinybase_values'.
|
|
885
897
|
*
|
|
886
898
|
* ```js
|
|
887
899
|
* import type {DatabasePersisterConfig} from 'tinybase';
|
|
@@ -889,8 +901,8 @@ export type DpcTabularSave<Schema extends OptionalTablesSchema> = {
|
|
|
889
901
|
* export const databasePersisterConfig: DatabasePersisterConfig = {
|
|
890
902
|
* mode: 'tabular',
|
|
891
903
|
* values: {
|
|
892
|
-
* load:
|
|
893
|
-
* save:
|
|
904
|
+
* load: ['selectedPet', 'open'],
|
|
905
|
+
* save: ['selectedPet', 'open'],
|
|
894
906
|
* tableName: 'my_tinybase_values',
|
|
895
907
|
* },
|
|
896
908
|
* };
|
|
@@ -898,19 +910,23 @@ export type DpcTabularSave<Schema extends OptionalTablesSchema> = {
|
|
|
898
910
|
* @category Configuration
|
|
899
911
|
* @since v4.0.0
|
|
900
912
|
*/
|
|
901
|
-
export type DpcTabularValues
|
|
913
|
+
export type DpcTabularValues<
|
|
914
|
+
Schema extends OptionalValuesSchema = OptionalValuesSchema,
|
|
915
|
+
> = {
|
|
902
916
|
/**
|
|
903
|
-
* Whether Store Values will be loaded from a database table
|
|
917
|
+
* Whether Store Values will be loaded from a database table, or the subset of
|
|
918
|
+
* Value Ids that will be loaded.
|
|
904
919
|
* @category Configuration
|
|
905
920
|
* @since v4.0.0
|
|
906
921
|
*/
|
|
907
|
-
load?: boolean
|
|
922
|
+
load?: boolean | DpcTabularValuesIn<Schema>;
|
|
908
923
|
/**
|
|
909
|
-
* Whether Store Values will be saved to a database table
|
|
924
|
+
* Whether Store Values will be saved to a database table, or the subset of
|
|
925
|
+
* Value Ids that will be saved.
|
|
910
926
|
* @category Configuration
|
|
911
927
|
* @since v4.0.0
|
|
912
928
|
*/
|
|
913
|
-
save?: boolean
|
|
929
|
+
save?: boolean | DpcTabularValuesIn<Schema>;
|
|
914
930
|
/**
|
|
915
931
|
* The optional name of the database table from and to which the Store Values
|
|
916
932
|
* should be loaded or saved, defaulting to `tinybase_values`.
|
|
@@ -920,6 +936,29 @@ export type DpcTabularValues = {
|
|
|
920
936
|
tableName?: string;
|
|
921
937
|
};
|
|
922
938
|
|
|
939
|
+
/**
|
|
940
|
+
* The DpcTabularValuesIn type describes the subset of Store Values that are
|
|
941
|
+
* persisted by the DpcTabularValues type.
|
|
942
|
+
*
|
|
943
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
944
|
+
*
|
|
945
|
+
* ```ts override
|
|
946
|
+
* Id[];
|
|
947
|
+
* ```
|
|
948
|
+
*
|
|
949
|
+
* When used as the DpcTabularValues `load` or `save` property, only the listed
|
|
950
|
+
* Value Ids will be loaded from or saved to the database table. Unlisted
|
|
951
|
+
* database columns are ignored on load and left untouched on save.
|
|
952
|
+
*
|
|
953
|
+
* The 'Dpc' prefix indicates that this type is used within the
|
|
954
|
+
* DatabasePersisterConfig type.
|
|
955
|
+
* @category Configuration
|
|
956
|
+
* @since v9.0.0
|
|
957
|
+
*/
|
|
958
|
+
export type DpcTabularValuesIn<
|
|
959
|
+
Schema extends OptionalValuesSchema = OptionalValuesSchema,
|
|
960
|
+
> = ValueIdFromSchema<Schema>[];
|
|
961
|
+
|
|
923
962
|
/**
|
|
924
963
|
* A Persister object lets you save and load Store data to and from different
|
|
925
964
|
* locations, or underlying storage types.
|
|
@@ -1880,7 +1919,8 @@ export type DatabaseChangeListener = (tableName: string) => void;
|
|
|
1880
1919
|
* `stopListeningToPersisted` has been renamed `delPersisterListener`.
|
|
1881
1920
|
* @param store The Store to persist.
|
|
1882
1921
|
* @param getPersisted An asynchronous function which will fetch content from
|
|
1883
|
-
* the persistence layer
|
|
1922
|
+
* the persistence layer. If it returns `undefined`, the load will use the
|
|
1923
|
+
* provided initial content if present, and otherwise leave the Store unchanged.
|
|
1884
1924
|
* @param setPersisted An asynchronous function which will send content to the
|
|
1885
1925
|
* persistence layer. Since v4.0, it receives functions for getting the Store
|
|
1886
1926
|
* content and information about the changes made during a transaction. Since
|
|
@@ -2016,13 +2056,15 @@ export function createCustomPersister<
|
|
|
2016
2056
|
Persist extends Persists = Persists.StoreOnly,
|
|
2017
2057
|
>(
|
|
2018
2058
|
store: PersistedStore<Schemas, Persist>,
|
|
2019
|
-
getPersisted: () => Promise<
|
|
2059
|
+
getPersisted: () => Promise<
|
|
2060
|
+
PersistedContent<Schemas, Persist, true> | undefined
|
|
2061
|
+
>,
|
|
2020
2062
|
setPersisted: (
|
|
2021
2063
|
getContent: () => PersistedContent<Schemas, Persist>,
|
|
2022
2064
|
changes?: PersistedChanges<Schemas, Persist>,
|
|
2023
2065
|
) => Promise<void>,
|
|
2024
2066
|
addPersisterListener: (
|
|
2025
|
-
listener: PersisterListener<Schemas, Persist>,
|
|
2067
|
+
listener: PersisterListener<Schemas, Persist, true>,
|
|
2026
2068
|
) => ListenerHandle | Promise<ListenerHandle>,
|
|
2027
2069
|
delPersisterListener: (
|
|
2028
2070
|
listenerHandle: ListenerHandle,
|
|
@@ -42,13 +42,7 @@ import type {
|
|
|
42
42
|
* @since v7.2.0
|
|
43
43
|
*/
|
|
44
44
|
export type ParamValue =
|
|
45
|
-
| string
|
|
46
|
-
| number
|
|
47
|
-
| boolean
|
|
48
|
-
| null
|
|
49
|
-
| string[]
|
|
50
|
-
| number[]
|
|
51
|
-
| boolean[];
|
|
45
|
+
string | number | boolean | null | string[] | number[] | boolean[];
|
|
52
46
|
|
|
53
47
|
/**
|
|
54
48
|
* The ParamValues type describes an object of param values, keyed by param Id,
|
|
@@ -861,6 +855,10 @@ export type Param = (paramId: Id) => ParamValue | undefined;
|
|
|
861
855
|
* The Select function is provided to the third `query` parameter of the
|
|
862
856
|
* setQueryDefinition method. A query definition must call the Select function
|
|
863
857
|
* at least once, otherwise it will be meaningless and return no data.
|
|
858
|
+
*
|
|
859
|
+
* A Row will only appear in the ResultTable if at least one Select clause
|
|
860
|
+
* produces a defined value for it. If all selected Cells or calculated values
|
|
861
|
+
* resolve to `undefined`, no ResultRow is created for that Row.
|
|
864
862
|
* @example
|
|
865
863
|
* This example shows a query that selects two Cells from the main query Table.
|
|
866
864
|
*
|