tinybase 3.1.0-beta.2 → 3.1.0-beta.4
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/bin/cli.js +1 -1
- package/lib/checkpoints.d.ts +13 -11
- package/lib/cjs/checkpoints.d.ts +13 -11
- package/lib/cjs/indexes.d.ts +15 -7
- package/lib/cjs/metrics.d.ts +9 -7
- package/lib/cjs/persisters.d.ts +30 -24
- package/lib/cjs/queries.d.ts +10 -6
- package/lib/cjs/relationships.d.ts +15 -7
- package/lib/cjs/store.d.ts +1190 -291
- package/lib/cjs/tools.cjs +1 -1
- package/lib/cjs/tools.cjs.gz +0 -0
- package/lib/cjs/tools.d.ts +31 -31
- package/lib/cjs-es6/checkpoints.d.ts +13 -11
- package/lib/cjs-es6/indexes.d.ts +15 -7
- package/lib/cjs-es6/metrics.d.ts +9 -7
- package/lib/cjs-es6/persisters.d.ts +30 -24
- package/lib/cjs-es6/queries.d.ts +10 -6
- package/lib/cjs-es6/relationships.d.ts +15 -7
- package/lib/cjs-es6/store.d.ts +1190 -291
- package/lib/cjs-es6/tools.cjs +1 -1
- package/lib/cjs-es6/tools.cjs.gz +0 -0
- package/lib/cjs-es6/tools.d.ts +31 -31
- package/lib/debug/checkpoints.d.ts +13 -11
- package/lib/debug/indexes.d.ts +15 -7
- package/lib/debug/metrics.d.ts +9 -7
- package/lib/debug/persisters.d.ts +30 -24
- package/lib/debug/queries.d.ts +10 -6
- package/lib/debug/relationships.d.ts +15 -7
- package/lib/debug/store.d.ts +1190 -291
- package/lib/debug/tools.d.ts +31 -31
- package/lib/debug/tools.js +692 -484
- package/lib/es6/checkpoints.d.ts +13 -11
- package/lib/es6/indexes.d.ts +15 -7
- package/lib/es6/metrics.d.ts +9 -7
- package/lib/es6/persisters.d.ts +30 -24
- package/lib/es6/queries.d.ts +10 -6
- package/lib/es6/relationships.d.ts +15 -7
- package/lib/es6/store.d.ts +1190 -291
- package/lib/es6/tools.d.ts +31 -31
- package/lib/es6/tools.js +1 -1
- package/lib/es6/tools.js.gz +0 -0
- package/lib/indexes.d.ts +15 -7
- package/lib/metrics.d.ts +9 -7
- package/lib/persisters.d.ts +30 -24
- package/lib/queries.d.ts +10 -6
- package/lib/relationships.d.ts +15 -7
- package/lib/store.d.ts +1190 -291
- package/lib/tools.d.ts +31 -31
- package/lib/tools.js +1 -1
- package/lib/tools.js.gz +0 -0
- package/lib/umd/checkpoints.d.ts +13 -11
- package/lib/umd/indexes.d.ts +15 -7
- package/lib/umd/metrics.d.ts +9 -7
- package/lib/umd/persisters.d.ts +30 -24
- package/lib/umd/queries.d.ts +10 -6
- package/lib/umd/relationships.d.ts +15 -7
- package/lib/umd/store.d.ts +1190 -291
- package/lib/umd/tools.d.ts +31 -31
- package/lib/umd/tools.js +1 -1
- package/lib/umd/tools.js.gz +0 -0
- package/lib/umd-es6/checkpoints.d.ts +13 -11
- package/lib/umd-es6/indexes.d.ts +15 -7
- package/lib/umd-es6/metrics.d.ts +9 -7
- package/lib/umd-es6/persisters.d.ts +30 -24
- package/lib/umd-es6/queries.d.ts +10 -6
- package/lib/umd-es6/relationships.d.ts +15 -7
- package/lib/umd-es6/store.d.ts +1190 -291
- package/lib/umd-es6/tools.d.ts +31 -31
- package/lib/umd-es6/tools.js +1 -1
- package/lib/umd-es6/tools.js.gz +0 -0
- package/package.json +23 -23
- package/readme.md +1 -1
package/lib/cjs-es6/store.d.ts
CHANGED
|
@@ -13,10 +13,173 @@
|
|
|
13
13
|
|
|
14
14
|
import {Id, IdOrNull, Ids, Json} from './common.d';
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* The TablesSchema type describes the tabular structure of a Store in terms of
|
|
18
|
+
* valid Table Ids and the types of Cell that can exist within them.
|
|
19
|
+
*
|
|
20
|
+
* A TablesSchema comprises a JavaScript object describing each Table, in turn a
|
|
21
|
+
* nested JavaScript object containing information about each Cell and its
|
|
22
|
+
* CellSchema. It is provided to the setTablesSchema method.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* When applied to a Store, this TablesSchema only allows one Table called
|
|
26
|
+
* `pets`, in which each Row may contain a string `species` Cell, and is
|
|
27
|
+
* guaranteed to contain a boolean `sold` Cell that defaults to `false`.
|
|
28
|
+
*
|
|
29
|
+
*```js
|
|
30
|
+
* const tableSchema: TablesSchema = {
|
|
31
|
+
* pets: {
|
|
32
|
+
* species: {type: 'string'},
|
|
33
|
+
* sold: {type: 'boolean', default: false},
|
|
34
|
+
* },
|
|
35
|
+
* };
|
|
36
|
+
* ```
|
|
37
|
+
* @category Schema
|
|
38
|
+
*/
|
|
39
|
+
export type TablesSchema = {[tableId: Id]: {[cellId: Id]: CellSchema}};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The CellSchema type describes what values are allowed for each Cell in a
|
|
43
|
+
* Table.
|
|
44
|
+
*
|
|
45
|
+
* A CellSchema specifies the type of the Cell (`string`, `boolean`, or
|
|
46
|
+
* `number`), and what the default value can be when an explicit value is not
|
|
47
|
+
* specified.
|
|
48
|
+
*
|
|
49
|
+
* If a default value is provided (and its type is correct), you can be certain
|
|
50
|
+
* that that Cell will always be present in a Row.
|
|
51
|
+
*
|
|
52
|
+
* If the default value is _not_ provided (or its type is incorrect), the Cell
|
|
53
|
+
* may be missing from the Row, but when present you can be guaranteed it is of
|
|
54
|
+
* the correct type.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* When applied to a Store, this CellSchema ensures a boolean Cell is always
|
|
58
|
+
* present, and defaults it to `false`.
|
|
59
|
+
*
|
|
60
|
+
*```js
|
|
61
|
+
* const requiredBoolean: CellSchema = {type: 'boolean', default: false};
|
|
62
|
+
* ```
|
|
63
|
+
* @category Schema
|
|
64
|
+
*/
|
|
65
|
+
export type CellSchema =
|
|
66
|
+
| {type: 'string'; default?: string}
|
|
67
|
+
| {type: 'number'; default?: number}
|
|
68
|
+
| {type: 'boolean'; default?: boolean};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The ValuesSchema type describes the keyed Values that can be set in a Store
|
|
72
|
+
* and their types.
|
|
73
|
+
*
|
|
74
|
+
* A ValuesSchema comprises a JavaScript object describing each Value and its
|
|
75
|
+
* ValueSchema. It is provided to the setValuesSchema method.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* When applied to a Store, this ValuesSchema only allows one boolean Value
|
|
79
|
+
* called `open`, that defaults to `false`.
|
|
80
|
+
*
|
|
81
|
+
*```js
|
|
82
|
+
* const valuesSchema: ValuesSchema = {
|
|
83
|
+
* open: {type: 'boolean', default: false},
|
|
84
|
+
* };
|
|
85
|
+
* ```
|
|
86
|
+
* @category Schema
|
|
87
|
+
* @since v3.0.0
|
|
88
|
+
*/
|
|
89
|
+
export type ValuesSchema = {[valueId: Id]: ValueSchema};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The ValueSchema type describes what values are allowed for keyed Values in a
|
|
93
|
+
* Store.
|
|
94
|
+
*
|
|
95
|
+
* A ValueSchema specifies the type of the Value (`string`, `boolean`, or
|
|
96
|
+
* `number`), and what the default value can be when an explicit value is not
|
|
97
|
+
* specified.
|
|
98
|
+
*
|
|
99
|
+
* If a default value is provided (and its type is correct), you can be certain
|
|
100
|
+
* that the Value will always be present in a Store.
|
|
101
|
+
*
|
|
102
|
+
* If the default value is _not_ provided (or its type is incorrect), the Value
|
|
103
|
+
* may not be present in the Store, but when present you can be guaranteed it is
|
|
104
|
+
* of the correct type.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* When applied to a Store, this ValueSchema ensures a boolean Value is always
|
|
108
|
+
* present, and defaults it to `false`.
|
|
109
|
+
*
|
|
110
|
+
*```js
|
|
111
|
+
* const requiredBoolean: ValueSchema = {type: 'boolean', default: false};
|
|
112
|
+
* ```
|
|
113
|
+
* @category Schema
|
|
114
|
+
* @since v3.0.0
|
|
115
|
+
*/
|
|
116
|
+
export type ValueSchema =
|
|
117
|
+
| {type: 'string'; default?: string}
|
|
118
|
+
| {type: 'number'; default?: number}
|
|
119
|
+
| {type: 'boolean'; default?: boolean};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The NoTablesSchema type is a TablesSchema-like type for when one has not been
|
|
123
|
+
* provided.
|
|
124
|
+
*
|
|
125
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
126
|
+
* expected to need to use it directly.
|
|
127
|
+
*
|
|
128
|
+
* @category Internal
|
|
129
|
+
*/
|
|
130
|
+
export type NoTablesSchema = {[tableId: Id]: {[cellId: Id]: {type: 'any'}}};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The NoValuesSchema type is a ValuesSchema-like type for when one has not been
|
|
134
|
+
* provided.
|
|
135
|
+
*
|
|
136
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
137
|
+
* expected to need to use it directly.
|
|
138
|
+
*
|
|
139
|
+
* @category Internal
|
|
140
|
+
*/
|
|
141
|
+
export type NoValuesSchema = {[valueId: Id]: {type: 'any'}};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The OptionalTablesSchema type is used by generic types that can optionally
|
|
145
|
+
* take a TablesSchema.
|
|
146
|
+
*
|
|
147
|
+
* @category Schema
|
|
148
|
+
*/
|
|
149
|
+
export type OptionalTablesSchema = TablesSchema | NoTablesSchema;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The OptionalValuesSchema type is used by generic types that can optionally
|
|
153
|
+
* take a ValuesSchema.
|
|
154
|
+
*
|
|
155
|
+
* @category Schema
|
|
156
|
+
*/
|
|
157
|
+
export type OptionalValuesSchema = ValuesSchema | NoValuesSchema;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The OptionalSchemas type is used by generic types that can optionally take
|
|
161
|
+
* either or both of a TablesSchema and ValuesSchema.
|
|
162
|
+
*
|
|
163
|
+
* @category Schema
|
|
164
|
+
*/
|
|
165
|
+
export type OptionalSchemas = [OptionalTablesSchema, OptionalValuesSchema];
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The NoSchemas type is used as a default by generic types that can optionally
|
|
169
|
+
* take either or both of a TablesSchema and ValuesSchema.
|
|
170
|
+
*
|
|
171
|
+
* @category Schema
|
|
172
|
+
*/
|
|
173
|
+
export type NoSchemas = [NoTablesSchema, NoValuesSchema];
|
|
174
|
+
|
|
16
175
|
/**
|
|
17
176
|
* The Tables type is the data structure representing all of the data in a
|
|
18
177
|
* Store.
|
|
19
178
|
*
|
|
179
|
+
* ```ts override
|
|
180
|
+
* {[tableId: Id]: Table}
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
20
183
|
* A Tables object is used when setting all of the tables together with the
|
|
21
184
|
* setTables method, and when getting them back out again with the getTables
|
|
22
185
|
* method. A Tables object is a regular JavaScript object containing individual
|
|
@@ -37,11 +200,18 @@ import {Id, IdOrNull, Ids, Json} from './common.d';
|
|
|
37
200
|
* ```
|
|
38
201
|
* @category Store
|
|
39
202
|
*/
|
|
40
|
-
export type Tables
|
|
203
|
+
export type Tables<
|
|
204
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
205
|
+
WhenSet extends boolean = false,
|
|
206
|
+
> = TablesFromSchema<Schema, WhenSet>;
|
|
41
207
|
|
|
42
208
|
/**
|
|
43
209
|
* The Table type is the data structure representing the data in a single table.
|
|
44
210
|
*
|
|
211
|
+
* ```ts override
|
|
212
|
+
* {[rowId: Id]: Row}
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
45
215
|
* A Table is used when setting a table with the setTable method, and when
|
|
46
216
|
* getting it back out again with the getTable method. A Table object is a
|
|
47
217
|
* regular JavaScript object containing individual Row objects, keyed by their
|
|
@@ -56,11 +226,19 @@ export type Tables = {[tableId: Id]: Table};
|
|
|
56
226
|
* ```
|
|
57
227
|
* @category Store
|
|
58
228
|
*/
|
|
59
|
-
export type Table
|
|
229
|
+
export type Table<
|
|
230
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
231
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
232
|
+
WhenSet extends boolean = false,
|
|
233
|
+
> = TableFromSchema<Schema, TableId, WhenSet>;
|
|
60
234
|
|
|
61
235
|
/**
|
|
62
236
|
* The Row type is the data structure representing the data in a single row.
|
|
63
237
|
*
|
|
238
|
+
* ```ts override
|
|
239
|
+
* {[cellId: Id]: Cell}
|
|
240
|
+
* ```
|
|
241
|
+
*
|
|
64
242
|
* A Row is used when setting a row with the setRow method, and when getting it
|
|
65
243
|
* back out again with the getRow method. A Row object is a regular JavaScript
|
|
66
244
|
* object containing individual Cell objects, keyed by their Id.
|
|
@@ -71,11 +249,19 @@ export type Table = {[rowId: Id]: Row};
|
|
|
71
249
|
* ```
|
|
72
250
|
* @category Store
|
|
73
251
|
*/
|
|
74
|
-
export type Row
|
|
252
|
+
export type Row<
|
|
253
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
254
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
255
|
+
WhenSet extends boolean = false,
|
|
256
|
+
> = RowFromSchema<Schema, TableId, WhenSet>;
|
|
75
257
|
|
|
76
258
|
/**
|
|
77
259
|
* The Cell type is the data structure representing the data in a single cell.
|
|
78
260
|
*
|
|
261
|
+
* ```ts override
|
|
262
|
+
* string | number | boolean
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
79
265
|
* A Cell is used when setting a cell with the setCell method, and when getting
|
|
80
266
|
* it back out again with the getCell method. A Cell is a JavaScript string,
|
|
81
267
|
* number, or boolean.
|
|
@@ -86,7 +272,14 @@ export type Row = {[cellId: Id]: Cell};
|
|
|
86
272
|
* ```
|
|
87
273
|
* @category Store
|
|
88
274
|
*/
|
|
89
|
-
export type Cell
|
|
275
|
+
export type Cell<
|
|
276
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
277
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
278
|
+
CellId extends CellIdFromSchema<Schema, TableId> = CellIdFromSchema<
|
|
279
|
+
Schema,
|
|
280
|
+
TableId
|
|
281
|
+
>,
|
|
282
|
+
> = CellFromSchema<Schema, TableId, CellId>;
|
|
90
283
|
|
|
91
284
|
/**
|
|
92
285
|
* The CellOrUndefined type is a data structure representing the data in a
|
|
@@ -98,12 +291,24 @@ export type Cell = string | number | boolean;
|
|
|
98
291
|
*
|
|
99
292
|
* @category Store
|
|
100
293
|
*/
|
|
101
|
-
export type CellOrUndefined
|
|
294
|
+
export type CellOrUndefined<
|
|
295
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
296
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
297
|
+
CellId extends CellIdFromSchema<Schema, TableId> = CellIdFromSchema<
|
|
298
|
+
Schema,
|
|
299
|
+
TableId
|
|
300
|
+
>,
|
|
301
|
+
Cell = CellFromSchema<Schema, TableId, CellId>,
|
|
302
|
+
> = Cell | undefined;
|
|
102
303
|
|
|
103
304
|
/**
|
|
104
305
|
* The Values type is the data structure representing all the keyed values in a
|
|
105
306
|
* Store.
|
|
106
307
|
*
|
|
308
|
+
* ```ts override
|
|
309
|
+
* {[valueId: Id]: Value}
|
|
310
|
+
* ```
|
|
311
|
+
*
|
|
107
312
|
* A Values object is used when setting values with the setValues method, and
|
|
108
313
|
* when getting them back out again with the getValues method. A Values object
|
|
109
314
|
* is a regular JavaScript object containing individual Value objects, keyed by
|
|
@@ -116,12 +321,19 @@ export type CellOrUndefined = Cell | undefined;
|
|
|
116
321
|
* @category Store
|
|
117
322
|
* @since v3.0.0
|
|
118
323
|
*/
|
|
119
|
-
export type Values
|
|
324
|
+
export type Values<
|
|
325
|
+
Schema extends OptionalValuesSchema = NoValuesSchema,
|
|
326
|
+
WhenSet extends boolean = false,
|
|
327
|
+
> = ValuesFromSchema<Schema, WhenSet>;
|
|
120
328
|
|
|
121
329
|
/**
|
|
122
330
|
* The Value type is the data structure representing the data in a single keyed
|
|
123
331
|
* value.
|
|
124
332
|
*
|
|
333
|
+
* ```ts override
|
|
334
|
+
* string | number | boolean
|
|
335
|
+
* ```
|
|
336
|
+
*
|
|
125
337
|
* A Value is used when setting a value with the setValue method, and when
|
|
126
338
|
* getting it back out again with the getValue method. A Value is a JavaScript
|
|
127
339
|
* string, number, or boolean.
|
|
@@ -133,7 +345,10 @@ export type Values = {[valueId: Id]: Value};
|
|
|
133
345
|
* @category Store
|
|
134
346
|
* @since v3.0.0
|
|
135
347
|
*/
|
|
136
|
-
export type Value
|
|
348
|
+
export type Value<
|
|
349
|
+
Schema extends OptionalValuesSchema = NoValuesSchema,
|
|
350
|
+
ValueId extends ValueIdFromSchema<Schema> = ValueIdFromSchema<Schema>,
|
|
351
|
+
> = ValueFromSchema<Schema, ValueId>;
|
|
137
352
|
|
|
138
353
|
/**
|
|
139
354
|
* The ValueOrUndefined type is a data structure representing the data in a
|
|
@@ -146,7 +361,11 @@ export type Value = string | number | boolean;
|
|
|
146
361
|
* @category Store
|
|
147
362
|
* @since v3.0.0
|
|
148
363
|
*/
|
|
149
|
-
export type ValueOrUndefined
|
|
364
|
+
export type ValueOrUndefined<
|
|
365
|
+
Schema extends OptionalValuesSchema = NoValuesSchema,
|
|
366
|
+
ValueId extends ValueIdFromSchema<Schema> = ValueIdFromSchema<Schema>,
|
|
367
|
+
Value = ValueFromSchema<Schema, ValueId>,
|
|
368
|
+
> = Value | undefined;
|
|
150
369
|
|
|
151
370
|
/**
|
|
152
371
|
* The TableCallback type describes a function that takes a Table's Id and a
|
|
@@ -161,9 +380,12 @@ export type ValueOrUndefined = Value | undefined;
|
|
|
161
380
|
* in this Table.
|
|
162
381
|
* @category Callback
|
|
163
382
|
*/
|
|
164
|
-
export type TableCallback
|
|
165
|
-
|
|
166
|
-
|
|
383
|
+
export type TableCallback<
|
|
384
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
385
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
386
|
+
> = (
|
|
387
|
+
tableId: TableId,
|
|
388
|
+
forEachRow: (rowCallback: RowCallback<Schema, TableId>) => void,
|
|
167
389
|
) => void;
|
|
168
390
|
|
|
169
391
|
/**
|
|
@@ -179,9 +401,12 @@ export type TableCallback = (
|
|
|
179
401
|
* in this Row.
|
|
180
402
|
* @category Callback
|
|
181
403
|
*/
|
|
182
|
-
export type RowCallback
|
|
404
|
+
export type RowCallback<
|
|
405
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
406
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
407
|
+
> = (
|
|
183
408
|
rowId: Id,
|
|
184
|
-
forEachCell: (cellCallback: CellCallback) => void,
|
|
409
|
+
forEachCell: (cellCallback: CellCallback<Schema, TableId>) => void,
|
|
185
410
|
) => void;
|
|
186
411
|
|
|
187
412
|
/**
|
|
@@ -196,7 +421,14 @@ export type RowCallback = (
|
|
|
196
421
|
* @param cell The value of the Cell.
|
|
197
422
|
* @category Callback
|
|
198
423
|
*/
|
|
199
|
-
export type CellCallback
|
|
424
|
+
export type CellCallback<
|
|
425
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
426
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
427
|
+
CellId extends CellIdFromSchema<Schema, TableId> = CellIdFromSchema<
|
|
428
|
+
Schema,
|
|
429
|
+
TableId
|
|
430
|
+
>,
|
|
431
|
+
> = (cellId: CellId, cell: Cell<Schema, TableId, CellId>) => void;
|
|
200
432
|
|
|
201
433
|
/**
|
|
202
434
|
* The ValueCallback type describes a function that takes a Value's Id and its
|
|
@@ -211,7 +443,10 @@ export type CellCallback = (cellId: Id, cell: Cell) => void;
|
|
|
211
443
|
* @category Callback
|
|
212
444
|
* @since v3.0.0
|
|
213
445
|
*/
|
|
214
|
-
export type ValueCallback
|
|
446
|
+
export type ValueCallback<
|
|
447
|
+
Schema extends OptionalValuesSchema = NoValuesSchema,
|
|
448
|
+
ValueId extends ValueIdFromSchema<Schema> = ValueIdFromSchema<Schema>,
|
|
449
|
+
> = (valueId: ValueId, value: Value<Schema, ValueId>) => void;
|
|
215
450
|
|
|
216
451
|
/**
|
|
217
452
|
* The MapCell type describes a function that takes an existing Cell value and
|
|
@@ -224,7 +459,16 @@ export type ValueCallback = (valueId: Id, value: Value) => void;
|
|
|
224
459
|
* @param cell The current value of the Cell to map to a new value.
|
|
225
460
|
* @category Callback
|
|
226
461
|
*/
|
|
227
|
-
export type MapCell
|
|
462
|
+
export type MapCell<
|
|
463
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
464
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
465
|
+
CellId extends CellIdFromSchema<Schema, TableId> = CellIdFromSchema<
|
|
466
|
+
Schema,
|
|
467
|
+
TableId
|
|
468
|
+
>,
|
|
469
|
+
> = (
|
|
470
|
+
cell: CellOrUndefined<Schema, TableId, CellId>,
|
|
471
|
+
) => Cell<Schema, TableId, CellId>;
|
|
228
472
|
|
|
229
473
|
/**
|
|
230
474
|
* The MapValue type describes a function that takes an existing Value and
|
|
@@ -238,7 +482,10 @@ export type MapCell = (cell: CellOrUndefined) => Cell;
|
|
|
238
482
|
* @category Callback
|
|
239
483
|
* @since v3.0.0
|
|
240
484
|
*/
|
|
241
|
-
export type MapValue
|
|
485
|
+
export type MapValue<
|
|
486
|
+
Schema extends OptionalValuesSchema = NoValuesSchema,
|
|
487
|
+
ValueId extends ValueIdFromSchema<Schema> = ValueIdFromSchema<Schema>,
|
|
488
|
+
> = (value: ValueOrUndefined<Schema, ValueId>) => Value<Schema, ValueId>;
|
|
242
489
|
|
|
243
490
|
/**
|
|
244
491
|
* The GetCell type describes a function that takes a Id and returns the Cell
|
|
@@ -251,7 +498,14 @@ export type MapValue = (value: ValueOrUndefined) => Value;
|
|
|
251
498
|
* @param cellId The Id of the Cell to fetch the value for.
|
|
252
499
|
* @category Callback
|
|
253
500
|
*/
|
|
254
|
-
export type GetCell
|
|
501
|
+
export type GetCell<
|
|
502
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
503
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
504
|
+
CellId extends CellIdFromSchema<Schema, TableId> = CellIdFromSchema<
|
|
505
|
+
Schema,
|
|
506
|
+
TableId
|
|
507
|
+
>,
|
|
508
|
+
> = (cellId: CellId) => CellOrUndefined<Schema, TableId, CellId>;
|
|
255
509
|
|
|
256
510
|
/**
|
|
257
511
|
* The DoRollback type describes a function that you can use to rollback the
|
|
@@ -272,10 +526,14 @@ export type GetCell = (cellId: Id) => CellOrUndefined;
|
|
|
272
526
|
* @param invalidValues Any invalid attempts to change Values, since v3.0.0.
|
|
273
527
|
* @category Callback
|
|
274
528
|
*/
|
|
275
|
-
export type DoRollback
|
|
276
|
-
|
|
529
|
+
export type DoRollback<
|
|
530
|
+
Schemas extends OptionalSchemas = NoSchemas,
|
|
531
|
+
TablesSchema extends OptionalTablesSchema = Schemas[0],
|
|
532
|
+
ValuesSchema extends OptionalValuesSchema = Schemas[1],
|
|
533
|
+
> = (
|
|
534
|
+
changedCells: ChangedCells<TablesSchema>,
|
|
277
535
|
invalidCells: InvalidCells,
|
|
278
|
-
changedValues: ChangedValues
|
|
536
|
+
changedValues: ChangedValues<ValuesSchema>,
|
|
279
537
|
invalidValues: InvalidValues,
|
|
280
538
|
) => boolean;
|
|
281
539
|
|
|
@@ -301,12 +559,12 @@ export type DoRollback = (
|
|
|
301
559
|
* @param store A reference to the Store that is completing a transaction.
|
|
302
560
|
* @param cellsTouched Whether Cell values have been touched during the
|
|
303
561
|
* transaction.
|
|
304
|
-
* @param valuesTouched Whether Values have been touched during the
|
|
305
|
-
*
|
|
562
|
+
* @param valuesTouched Whether Values have been touched during the transaction,
|
|
563
|
+
* since v3.0.0.
|
|
306
564
|
* @category Listener
|
|
307
565
|
*/
|
|
308
|
-
export type TransactionListener = (
|
|
309
|
-
store: Store
|
|
566
|
+
export type TransactionListener<Schemas extends OptionalSchemas = NoSchemas> = (
|
|
567
|
+
store: Store<Schemas>,
|
|
310
568
|
cellsTouched: boolean,
|
|
311
569
|
valuesTouched: boolean,
|
|
312
570
|
) => void;
|
|
@@ -331,9 +589,12 @@ export type TransactionListener = (
|
|
|
331
589
|
* changes.
|
|
332
590
|
* @category Listener
|
|
333
591
|
*/
|
|
334
|
-
export type TablesListener
|
|
335
|
-
|
|
336
|
-
|
|
592
|
+
export type TablesListener<
|
|
593
|
+
Schemas extends OptionalSchemas = NoSchemas,
|
|
594
|
+
TablesSchema extends OptionalTablesSchema = Schemas[0],
|
|
595
|
+
> = (
|
|
596
|
+
store: Store<Schemas>,
|
|
597
|
+
getCellChange: GetCellChange<TablesSchema> | undefined,
|
|
337
598
|
) => void;
|
|
338
599
|
|
|
339
600
|
/**
|
|
@@ -348,7 +609,9 @@ export type TablesListener = (
|
|
|
348
609
|
* @param store A reference to the Store that changed.
|
|
349
610
|
* @category Listener
|
|
350
611
|
*/
|
|
351
|
-
export type TableIdsListener =
|
|
612
|
+
export type TableIdsListener<Schemas extends OptionalSchemas = NoSchemas> = (
|
|
613
|
+
store: Store<Schemas>,
|
|
614
|
+
) => void;
|
|
352
615
|
|
|
353
616
|
/**
|
|
354
617
|
* The TableListener type describes a function that is used to listen to changes
|
|
@@ -371,10 +634,19 @@ export type TableIdsListener = (store: Store) => void;
|
|
|
371
634
|
* changes.
|
|
372
635
|
* @category Listener
|
|
373
636
|
*/
|
|
374
|
-
export type TableListener
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
637
|
+
export type TableListener<
|
|
638
|
+
Schemas extends OptionalSchemas = NoSchemas,
|
|
639
|
+
TableIdOrNull extends TableIdFromSchema<
|
|
640
|
+
Schemas[0]
|
|
641
|
+
> | null = TableIdFromSchema<Schemas[0]> | null,
|
|
642
|
+
TableId = TableIdOrNull extends null
|
|
643
|
+
? TableIdFromSchema<Schemas[0]>
|
|
644
|
+
: TableIdOrNull,
|
|
645
|
+
TablesSchema extends OptionalTablesSchema = Schemas[0],
|
|
646
|
+
> = (
|
|
647
|
+
store: Store<Schemas>,
|
|
648
|
+
tableId: TableId,
|
|
649
|
+
getCellChange: GetCellChange<TablesSchema> | undefined,
|
|
378
650
|
) => void;
|
|
379
651
|
|
|
380
652
|
/**
|
|
@@ -391,7 +663,15 @@ export type TableListener = (
|
|
|
391
663
|
* @param tableId The Id of the Table that changed.
|
|
392
664
|
* @category Listener
|
|
393
665
|
*/
|
|
394
|
-
export type RowIdsListener
|
|
666
|
+
export type RowIdsListener<
|
|
667
|
+
Schemas extends OptionalSchemas = NoSchemas,
|
|
668
|
+
TableIdOrNull extends TableIdFromSchema<
|
|
669
|
+
Schemas[0]
|
|
670
|
+
> | null = TableIdFromSchema<Schemas[0]> | null,
|
|
671
|
+
TableId = TableIdOrNull extends null
|
|
672
|
+
? TableIdFromSchema<Schemas[0]>
|
|
673
|
+
: TableIdOrNull,
|
|
674
|
+
> = (store: Store<Schemas>, tableId: TableId) => void;
|
|
395
675
|
|
|
396
676
|
/**
|
|
397
677
|
* The SortedRowIdsListener type describes a function that is used to listen to
|
|
@@ -417,13 +697,22 @@ export type RowIdsListener = (store: Store, tableId: Id) => void;
|
|
|
417
697
|
* @category Listener
|
|
418
698
|
* @since v2.0.0
|
|
419
699
|
*/
|
|
420
|
-
export type SortedRowIdsListener
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
700
|
+
export type SortedRowIdsListener<
|
|
701
|
+
Schemas extends OptionalSchemas = NoSchemas,
|
|
702
|
+
TableId extends TableIdFromSchema<Schemas[0]> = TableIdFromSchema<Schemas[0]>,
|
|
703
|
+
CellId extends CellIdFromSchema<Schemas[0], TableId> | undefined =
|
|
704
|
+
| CellIdFromSchema<Schemas[0], TableId>
|
|
705
|
+
| undefined,
|
|
706
|
+
Descending extends boolean = boolean,
|
|
707
|
+
Offset extends number = number,
|
|
708
|
+
Limit extends number | undefined = number | undefined,
|
|
709
|
+
> = (
|
|
710
|
+
store: Store<Schemas>,
|
|
711
|
+
tableId: TableId,
|
|
712
|
+
cellId: CellId,
|
|
713
|
+
descending: Descending,
|
|
714
|
+
offset: Offset,
|
|
715
|
+
limit: Limit,
|
|
427
716
|
sortedRowIds: Ids,
|
|
428
717
|
) => void;
|
|
429
718
|
|
|
@@ -450,11 +739,22 @@ export type SortedRowIdsListener = (
|
|
|
450
739
|
* changes.
|
|
451
740
|
* @category Listener
|
|
452
741
|
*/
|
|
453
|
-
export type RowListener
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
742
|
+
export type RowListener<
|
|
743
|
+
Schemas extends OptionalSchemas = NoSchemas,
|
|
744
|
+
TableIdOrNull extends TableIdFromSchema<
|
|
745
|
+
Schemas[0]
|
|
746
|
+
> | null = TableIdFromSchema<Schemas[0]> | null,
|
|
747
|
+
RowIdOrNull extends IdOrNull = IdOrNull,
|
|
748
|
+
TableId = TableIdOrNull extends null
|
|
749
|
+
? TableIdFromSchema<Schemas[0]>
|
|
750
|
+
: TableIdOrNull,
|
|
751
|
+
RowId = RowIdOrNull extends null ? Id : RowIdOrNull,
|
|
752
|
+
TablesSchema extends OptionalTablesSchema = Schemas[0],
|
|
753
|
+
> = (
|
|
754
|
+
store: Store<Schemas>,
|
|
755
|
+
tableId: TableId,
|
|
756
|
+
rowId: RowId,
|
|
757
|
+
getCellChange: GetCellChange<TablesSchema> | undefined,
|
|
458
758
|
) => void;
|
|
459
759
|
|
|
460
760
|
/**
|
|
@@ -472,7 +772,17 @@ export type RowListener = (
|
|
|
472
772
|
* @param rowId The Id of the Row that changed.
|
|
473
773
|
* @category Listener
|
|
474
774
|
*/
|
|
475
|
-
export type CellIdsListener
|
|
775
|
+
export type CellIdsListener<
|
|
776
|
+
Schemas extends OptionalSchemas = NoSchemas,
|
|
777
|
+
TableIdOrNull extends TableIdFromSchema<
|
|
778
|
+
Schemas[0]
|
|
779
|
+
> | null = TableIdFromSchema<Schemas[0]> | null,
|
|
780
|
+
RowIdOrNull extends IdOrNull = null,
|
|
781
|
+
TableId = TableIdOrNull extends null
|
|
782
|
+
? TableIdFromSchema<Schemas[0]>
|
|
783
|
+
: TableIdOrNull,
|
|
784
|
+
RowId = RowIdOrNull extends null ? Id : RowIdOrNull,
|
|
785
|
+
> = (store: Store<Schemas>, tableId: TableId, rowId: RowId) => void;
|
|
476
786
|
|
|
477
787
|
/**
|
|
478
788
|
* The CellListener type describes a function that is used to listen to changes
|
|
@@ -502,14 +812,40 @@ export type CellIdsListener = (store: Store, tableId: Id, rowId: Id) => void;
|
|
|
502
812
|
* changes.
|
|
503
813
|
* @category Listener
|
|
504
814
|
*/
|
|
505
|
-
export type CellListener
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
815
|
+
export type CellListener<
|
|
816
|
+
Schemas extends OptionalSchemas = NoSchemas,
|
|
817
|
+
TableIdOrNull extends TableIdFromSchema<
|
|
818
|
+
Schemas[0]
|
|
819
|
+
> | null = TableIdFromSchema<Schemas[0]> | null,
|
|
820
|
+
RowIdOrNull extends IdOrNull = IdOrNull,
|
|
821
|
+
CellIdOrNull extends
|
|
822
|
+
| (TableIdOrNull extends TableIdFromSchema<Schemas[0]>
|
|
823
|
+
? CellIdFromSchema<Schemas[0], TableIdOrNull>
|
|
824
|
+
: AllCellIdFromSchema<Schemas[0]>)
|
|
825
|
+
| null =
|
|
826
|
+
| (TableIdOrNull extends TableIdFromSchema<Schemas[0]>
|
|
827
|
+
? CellIdFromSchema<Schemas[0], TableIdOrNull>
|
|
828
|
+
: AllCellIdFromSchema<Schemas[0]>)
|
|
829
|
+
| null,
|
|
830
|
+
TableId extends Id = TableIdOrNull extends null
|
|
831
|
+
? TableIdFromSchema<Schemas[0]>
|
|
832
|
+
: TableIdOrNull,
|
|
833
|
+
RowId = RowIdOrNull extends null ? Id : RowIdOrNull,
|
|
834
|
+
CellId extends Id = CellIdOrNull extends null
|
|
835
|
+
? TableIdOrNull extends TableIdFromSchema<Schemas[0]>
|
|
836
|
+
? CellIdFromSchema<Schemas[0], TableIdOrNull>
|
|
837
|
+
: AllCellIdFromSchema<Schemas[0]>
|
|
838
|
+
: CellIdOrNull,
|
|
839
|
+
Cell = CellFromSchema<Schemas[0], TableId, CellId>,
|
|
840
|
+
TablesSchema extends OptionalTablesSchema = Schemas[0],
|
|
841
|
+
> = (
|
|
842
|
+
store: Store<Schemas>,
|
|
843
|
+
tableId: TableId,
|
|
844
|
+
rowId: RowId,
|
|
845
|
+
cellId: CellId,
|
|
510
846
|
newCell: Cell,
|
|
511
847
|
oldCell: Cell,
|
|
512
|
-
getCellChange: GetCellChange | undefined,
|
|
848
|
+
getCellChange: GetCellChange<TablesSchema> | undefined,
|
|
513
849
|
) => void;
|
|
514
850
|
|
|
515
851
|
/**
|
|
@@ -532,9 +868,12 @@ export type CellListener = (
|
|
|
532
868
|
* changes.
|
|
533
869
|
* @category Listener
|
|
534
870
|
*/
|
|
535
|
-
export type ValuesListener
|
|
536
|
-
|
|
537
|
-
|
|
871
|
+
export type ValuesListener<
|
|
872
|
+
Schemas extends OptionalSchemas = NoSchemas,
|
|
873
|
+
ValuesSchema extends OptionalValuesSchema = Schemas[1],
|
|
874
|
+
> = (
|
|
875
|
+
store: Store<Schemas>,
|
|
876
|
+
getValueChange: GetValueChange<ValuesSchema> | undefined,
|
|
538
877
|
) => void;
|
|
539
878
|
|
|
540
879
|
/**
|
|
@@ -549,7 +888,9 @@ export type ValuesListener = (
|
|
|
549
888
|
* @param store A reference to the Store that changed.
|
|
550
889
|
* @category Listener
|
|
551
890
|
*/
|
|
552
|
-
export type ValueIdsListener =
|
|
891
|
+
export type ValueIdsListener<Schemas extends OptionalSchemas = NoSchemas> = (
|
|
892
|
+
store: Store<Schemas>,
|
|
893
|
+
) => void;
|
|
553
894
|
|
|
554
895
|
/**
|
|
555
896
|
* The ValueListener type describes a function that is used to listen to changes
|
|
@@ -577,12 +918,22 @@ export type ValueIdsListener = (store: Store) => void;
|
|
|
577
918
|
* @category Listener
|
|
578
919
|
* @since v3.0.0
|
|
579
920
|
*/
|
|
580
|
-
export type ValueListener
|
|
581
|
-
|
|
582
|
-
|
|
921
|
+
export type ValueListener<
|
|
922
|
+
Schemas extends OptionalSchemas = NoSchemas,
|
|
923
|
+
ValueIdOrNull extends ValueIdFromSchema<
|
|
924
|
+
Schemas[1]
|
|
925
|
+
> | null = ValueIdFromSchema<Schemas[1]> | null,
|
|
926
|
+
ValueId extends Id = ValueIdOrNull extends null
|
|
927
|
+
? ValueIdFromSchema<Schemas[1]>
|
|
928
|
+
: ValueIdOrNull,
|
|
929
|
+
Value = ValueFromSchema<Schemas[1], ValueId>,
|
|
930
|
+
ValuesSchema extends OptionalValuesSchema = Schemas[1],
|
|
931
|
+
> = (
|
|
932
|
+
store: Store<Schemas>,
|
|
933
|
+
valueId: ValueId,
|
|
583
934
|
newValue: Value,
|
|
584
935
|
oldValue: Value,
|
|
585
|
-
getValueChange: GetValueChange | undefined,
|
|
936
|
+
getValueChange: GetValueChange<ValuesSchema> | undefined,
|
|
586
937
|
) => void;
|
|
587
938
|
|
|
588
939
|
/**
|
|
@@ -607,8 +958,8 @@ export type ValueListener = (
|
|
|
607
958
|
* @category Listener
|
|
608
959
|
* @since v1.1.0
|
|
609
960
|
*/
|
|
610
|
-
export type InvalidCellListener = (
|
|
611
|
-
store: Store
|
|
961
|
+
export type InvalidCellListener<Schemas extends OptionalSchemas = NoSchemas> = (
|
|
962
|
+
store: Store<Schemas>,
|
|
612
963
|
tableId: Id,
|
|
613
964
|
rowId: Id,
|
|
614
965
|
cellId: Id,
|
|
@@ -635,11 +986,8 @@ export type InvalidCellListener = (
|
|
|
635
986
|
* @category Listener
|
|
636
987
|
* @since v3.0.0
|
|
637
988
|
*/
|
|
638
|
-
export type InvalidValueListener =
|
|
639
|
-
store: Store,
|
|
640
|
-
valueId: Id,
|
|
641
|
-
invalidValues: any[],
|
|
642
|
-
) => void;
|
|
989
|
+
export type InvalidValueListener<Schemas extends OptionalSchemas = NoSchemas> =
|
|
990
|
+
(store: Store<Schemas>, valueId: Id, invalidValues: any[]) => void;
|
|
643
991
|
|
|
644
992
|
/**
|
|
645
993
|
* The GetCellChange type describes a function that returns information about
|
|
@@ -656,7 +1004,16 @@ export type InvalidValueListener = (
|
|
|
656
1004
|
* @returns A CellChange array containing information about the Cell's changes.
|
|
657
1005
|
* @category Listener
|
|
658
1006
|
*/
|
|
659
|
-
export type GetCellChange
|
|
1007
|
+
export type GetCellChange<
|
|
1008
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
1009
|
+
> = <
|
|
1010
|
+
TableId extends TableIdFromSchema<Schema>,
|
|
1011
|
+
CellId extends CellIdFromSchema<Schema, TableId>,
|
|
1012
|
+
>(
|
|
1013
|
+
tableId: TableId,
|
|
1014
|
+
rowId: Id,
|
|
1015
|
+
cellId: CellId,
|
|
1016
|
+
) => CellChange<Schema, TableId, CellId>;
|
|
660
1017
|
|
|
661
1018
|
/**
|
|
662
1019
|
* The CellChange type describes a Cell's changes during a transaction.
|
|
@@ -668,11 +1025,15 @@ export type GetCellChange = (tableId: Id, rowId: Id, cellId: Id) => CellChange;
|
|
|
668
1025
|
*
|
|
669
1026
|
* @category Listener
|
|
670
1027
|
*/
|
|
671
|
-
export type CellChange
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
1028
|
+
export type CellChange<
|
|
1029
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
1030
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
1031
|
+
CellId extends CellIdFromSchema<Schema, TableId> = CellIdFromSchema<
|
|
1032
|
+
Schema,
|
|
1033
|
+
TableId
|
|
1034
|
+
>,
|
|
1035
|
+
CellOrUndefined = Cell<Schema, TableId, CellId> | undefined,
|
|
1036
|
+
> = [changed: boolean, oldCell: CellOrUndefined, newCell: CellOrUndefined];
|
|
676
1037
|
|
|
677
1038
|
/**
|
|
678
1039
|
* The GetValueChange type describes a function that returns information about
|
|
@@ -688,7 +1049,11 @@ export type CellChange = [
|
|
|
688
1049
|
* changes.
|
|
689
1050
|
* @category Listener
|
|
690
1051
|
*/
|
|
691
|
-
export type GetValueChange
|
|
1052
|
+
export type GetValueChange<
|
|
1053
|
+
Schema extends OptionalValuesSchema = NoValuesSchema,
|
|
1054
|
+
> = <ValueId extends ValueIdFromSchema<Schema>>(
|
|
1055
|
+
valueId: ValueId,
|
|
1056
|
+
) => ValueChange<Schema, ValueId>;
|
|
692
1057
|
|
|
693
1058
|
/**
|
|
694
1059
|
* The ValueChange type describes a Value's changes during a transaction.
|
|
@@ -700,128 +1065,27 @@ export type GetValueChange = (valueId: Id) => ValueChange;
|
|
|
700
1065
|
*
|
|
701
1066
|
* @category Listener
|
|
702
1067
|
*/
|
|
703
|
-
export type ValueChange
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
];
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
* The TablesSchema type describes the tabular structure of a Store in terms of
|
|
711
|
-
* valid Table Ids and the types of Cell that can exist within them.
|
|
712
|
-
*
|
|
713
|
-
* A TablesSchema comprises a JavaScript object describing each Table, in turn a
|
|
714
|
-
* nested JavaScript object containing information about each Cell and its
|
|
715
|
-
* CellSchema. It is provided to the setTablesSchema method.
|
|
716
|
-
*
|
|
717
|
-
* @example
|
|
718
|
-
* When applied to a Store, this TablesSchema only allows one Table called
|
|
719
|
-
* `pets`, in which each Row may contain a string `species` Cell, and is
|
|
720
|
-
* guaranteed to contain a boolean `sold` Cell that defaults to `false`.
|
|
721
|
-
*
|
|
722
|
-
*```js
|
|
723
|
-
* const tableSchema: TablesSchema = {
|
|
724
|
-
* pets: {
|
|
725
|
-
* species: {type: 'string'},
|
|
726
|
-
* sold: {type: 'boolean', default: false},
|
|
727
|
-
* },
|
|
728
|
-
* };
|
|
729
|
-
* ```
|
|
730
|
-
* @category Schema
|
|
731
|
-
*/
|
|
732
|
-
export type TablesSchema = {
|
|
733
|
-
[tableId: Id]: {
|
|
734
|
-
[cellId: Id]: CellSchema;
|
|
735
|
-
};
|
|
736
|
-
};
|
|
737
|
-
|
|
738
|
-
/**
|
|
739
|
-
* The CellSchema type describes what values are allowed for each Cell in a
|
|
740
|
-
* Table.
|
|
741
|
-
*
|
|
742
|
-
* A CellSchema specifies the type of the Cell (`string`, `boolean`, or
|
|
743
|
-
* `number`), and what the default value can be when an explicit value is not
|
|
744
|
-
* specified.
|
|
745
|
-
*
|
|
746
|
-
* If a default value is provided (and its type is correct), you can be certain
|
|
747
|
-
* that that Cell will always be present in a Row.
|
|
748
|
-
*
|
|
749
|
-
* If the default value is _not_ provided (or its type is incorrect), the Cell
|
|
750
|
-
* may be missing from the Row, but when present you can be guaranteed it is of
|
|
751
|
-
* the correct type.
|
|
752
|
-
*
|
|
753
|
-
* @example
|
|
754
|
-
* When applied to a Store, this CellSchema ensures a boolean Cell is always
|
|
755
|
-
* present, and defaults it to `false`.
|
|
756
|
-
*
|
|
757
|
-
*```js
|
|
758
|
-
* const requiredBoolean: CellSchema = {type: 'boolean', default: false};
|
|
759
|
-
* ```
|
|
760
|
-
* @category Schema
|
|
761
|
-
*/
|
|
762
|
-
export type CellSchema =
|
|
763
|
-
| {type: 'string'; default?: string}
|
|
764
|
-
| {type: 'number'; default?: number}
|
|
765
|
-
| {type: 'boolean'; default?: boolean};
|
|
766
|
-
|
|
767
|
-
/**
|
|
768
|
-
* The ValuesSchema type describes the keyed Values that can be set in a Store
|
|
769
|
-
* and their types.
|
|
770
|
-
*
|
|
771
|
-
* A ValuesSchema comprises a JavaScript object describing each Value and its
|
|
772
|
-
* ValueSchema. It is provided to the setValuesSchema method.
|
|
773
|
-
*
|
|
774
|
-
* @example
|
|
775
|
-
* When applied to a Store, this ValuesSchema only allows one boolean Value
|
|
776
|
-
* called `open`, that defaults to `false`.
|
|
777
|
-
*
|
|
778
|
-
*```js
|
|
779
|
-
* const valuesSchema: ValuesSchema = {
|
|
780
|
-
* open: {type: 'boolean', default: false},
|
|
781
|
-
* };
|
|
782
|
-
* ```
|
|
783
|
-
* @category Schema
|
|
784
|
-
* @since v3.0.0
|
|
785
|
-
*/
|
|
786
|
-
export type ValuesSchema = {
|
|
787
|
-
[valueId: Id]: ValueSchema;
|
|
788
|
-
};
|
|
789
|
-
|
|
790
|
-
/**
|
|
791
|
-
* The ValueSchema type describes what values are allowed for keyed Values in a
|
|
792
|
-
* Store.
|
|
793
|
-
*
|
|
794
|
-
* A ValueSchema specifies the type of the Value (`string`, `boolean`, or
|
|
795
|
-
* `number`), and what the default value can be when an explicit value is not
|
|
796
|
-
* specified.
|
|
797
|
-
*
|
|
798
|
-
* If a default value is provided (and its type is correct), you can be certain
|
|
799
|
-
* that the Value will always be present in a Store.
|
|
800
|
-
*
|
|
801
|
-
* If the default value is _not_ provided (or its type is incorrect), the Value
|
|
802
|
-
* may not be present in the Store, but when present you can be guaranteed it is
|
|
803
|
-
* of the correct type.
|
|
804
|
-
*
|
|
805
|
-
* @example
|
|
806
|
-
* When applied to a Store, this ValueSchema ensures a boolean Value is always
|
|
807
|
-
* present, and defaults it to `false`.
|
|
808
|
-
*
|
|
809
|
-
*```js
|
|
810
|
-
* const requiredBoolean: ValueSchema = {type: 'boolean', default: false};
|
|
811
|
-
* ```
|
|
812
|
-
* @category Schema
|
|
813
|
-
* @since v3.0.0
|
|
814
|
-
*/
|
|
815
|
-
export type ValueSchema =
|
|
816
|
-
| {type: 'string'; default?: string}
|
|
817
|
-
| {type: 'number'; default?: number}
|
|
818
|
-
| {type: 'boolean'; default?: boolean};
|
|
1068
|
+
export type ValueChange<
|
|
1069
|
+
Schema extends OptionalValuesSchema = NoValuesSchema,
|
|
1070
|
+
ValueId extends ValueIdFromSchema<Schema> = ValueIdFromSchema<Schema>,
|
|
1071
|
+
ValueOrUndefined = Value<Schema, ValueId> | undefined,
|
|
1072
|
+
> = [changed: boolean, oldValue: ValueOrUndefined, newValue: ValueOrUndefined];
|
|
819
1073
|
|
|
820
1074
|
/**
|
|
821
1075
|
* The ChangedCells type describes the Cell values that have been changed during
|
|
822
1076
|
* a transaction, primarily used so that you can indicate whether the
|
|
823
1077
|
* transaction should be rolled back.
|
|
824
1078
|
*
|
|
1079
|
+
* ```ts override
|
|
1080
|
+
* {
|
|
1081
|
+
* [tableId: Id]: {
|
|
1082
|
+
* [rowId: Id]: {
|
|
1083
|
+
* [cellId: Id]: [CellOrUndefined, CellOrUndefined],
|
|
1084
|
+
* },
|
|
1085
|
+
* },
|
|
1086
|
+
* }
|
|
1087
|
+
* ```
|
|
1088
|
+
*
|
|
825
1089
|
* A ChangedCells object is provided to the `doRollback` callback when using the
|
|
826
1090
|
* transaction method and the finishTransaction method. See those methods for
|
|
827
1091
|
* specific examples.
|
|
@@ -842,13 +1106,17 @@ export type ValueSchema =
|
|
|
842
1106
|
* @category Transaction
|
|
843
1107
|
* @since v1.2.0
|
|
844
1108
|
*/
|
|
845
|
-
export type ChangedCells =
|
|
846
|
-
|
|
847
|
-
[
|
|
848
|
-
[
|
|
1109
|
+
export type ChangedCells<Schema extends OptionalTablesSchema = NoTablesSchema> =
|
|
1110
|
+
{
|
|
1111
|
+
[TableId in TableIdFromSchema<Schema>]?: {
|
|
1112
|
+
[rowId: Id]: {
|
|
1113
|
+
[CellId in CellIdFromSchema<Schema, TableId>]?: [
|
|
1114
|
+
CellOrUndefined<Schema, TableId, CellId>,
|
|
1115
|
+
CellOrUndefined<Schema, TableId, CellId>,
|
|
1116
|
+
];
|
|
1117
|
+
};
|
|
849
1118
|
};
|
|
850
1119
|
};
|
|
851
|
-
};
|
|
852
1120
|
|
|
853
1121
|
/**
|
|
854
1122
|
* The InvalidCells type describes the invalid Cell values that have been
|
|
@@ -880,6 +1148,10 @@ export type InvalidCells = {
|
|
|
880
1148
|
* transaction, primarily used so that you can indicate whether the transaction
|
|
881
1149
|
* should be rolled back.
|
|
882
1150
|
*
|
|
1151
|
+
* ```ts override
|
|
1152
|
+
* {[valueId: Id]: [ValueOrUndefined, ValueOrUndefined]}
|
|
1153
|
+
* ```
|
|
1154
|
+
*
|
|
883
1155
|
* A ChangedValues object is provided to the `doRollback` callback when using
|
|
884
1156
|
* the transaction method and the finishTransaction method. See those methods
|
|
885
1157
|
* for specific examples.
|
|
@@ -899,8 +1171,13 @@ export type InvalidCells = {
|
|
|
899
1171
|
* @category Transaction
|
|
900
1172
|
* @since v3.0.0
|
|
901
1173
|
*/
|
|
902
|
-
export type ChangedValues
|
|
903
|
-
|
|
1174
|
+
export type ChangedValues<
|
|
1175
|
+
Schema extends OptionalValuesSchema = NoValuesSchema,
|
|
1176
|
+
> = {
|
|
1177
|
+
[ValueId in ValueIdFromSchema<Schema>]?: [
|
|
1178
|
+
ValueOrUndefined<Schema, ValueId>,
|
|
1179
|
+
ValueOrUndefined<Schema, ValueId>,
|
|
1180
|
+
];
|
|
904
1181
|
};
|
|
905
1182
|
/**
|
|
906
1183
|
* The InvalidValues type describes the invalid Values that have been attempted
|
|
@@ -1125,9 +1402,16 @@ export type StoreListenerStats = {
|
|
|
1125
1402
|
* requires its type to be specified, and can also take a default value for when
|
|
1126
1403
|
* it's not specified.
|
|
1127
1404
|
*
|
|
1128
|
-
* You can also get a serialization of the schemas out of the Store with
|
|
1129
|
-
*
|
|
1130
|
-
*
|
|
1405
|
+
* You can also get a serialization of the schemas out of the Store with the
|
|
1406
|
+
* getSchemaJson method, and remove the schemas altogether with the
|
|
1407
|
+
* delValuesSchema method and delTablesSchema method.
|
|
1408
|
+
*
|
|
1409
|
+
* Throughout this API documentation, you will see the generic type parameter
|
|
1410
|
+
* `Schemas`, which refers to a pair of TablesSchema and ValuesSchema
|
|
1411
|
+
* respectively. These can be used on the Store interface to constrain its
|
|
1412
|
+
* methods, for example. This type parameter is defaulted if not provided, and
|
|
1413
|
+
* so if you are using a Store without schemas, you can ignore it and use the
|
|
1414
|
+
* Store type bare.
|
|
1131
1415
|
*
|
|
1132
1416
|
* Read more about schemas in the Using Schemas guide.
|
|
1133
1417
|
*
|
|
@@ -1175,7 +1459,7 @@ export type StoreListenerStats = {
|
|
|
1175
1459
|
* @see Todo App demos
|
|
1176
1460
|
* @category Store
|
|
1177
1461
|
*/
|
|
1178
|
-
export interface Store {
|
|
1462
|
+
export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
|
|
1179
1463
|
/**
|
|
1180
1464
|
* The getTables method returns a Tables object containing the entire data of
|
|
1181
1465
|
* the Store.
|
|
@@ -1211,7 +1495,7 @@ export interface Store {
|
|
|
1211
1495
|
* @see Indexes
|
|
1212
1496
|
* @category Getter
|
|
1213
1497
|
*/
|
|
1214
|
-
getTables(): Tables;
|
|
1498
|
+
getTables<Tables = TablesFromSchema<Schemas[0]>>(): Tables;
|
|
1215
1499
|
|
|
1216
1500
|
/**
|
|
1217
1501
|
* The getTableIds method returns the Ids of every Table in the Store.
|
|
@@ -1242,7 +1526,7 @@ export interface Store {
|
|
|
1242
1526
|
* ```
|
|
1243
1527
|
* @category Getter
|
|
1244
1528
|
*/
|
|
1245
|
-
getTableIds(): Ids;
|
|
1529
|
+
getTableIds<Ids = TableIdFromSchema<Schemas[0]>[]>(): Ids;
|
|
1246
1530
|
|
|
1247
1531
|
/**
|
|
1248
1532
|
* The getTable method returns an object containing the entire data of a
|
|
@@ -1276,7 +1560,12 @@ export interface Store {
|
|
|
1276
1560
|
* ```
|
|
1277
1561
|
* @category Getter
|
|
1278
1562
|
*/
|
|
1279
|
-
getTable
|
|
1563
|
+
getTable<
|
|
1564
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
1565
|
+
Table = TableFromSchema<Schemas[0]>,
|
|
1566
|
+
>(
|
|
1567
|
+
tableId: TableId,
|
|
1568
|
+
): Table;
|
|
1280
1569
|
|
|
1281
1570
|
/**
|
|
1282
1571
|
* The getRowIds method returns the Ids of every Row in a given Table.
|
|
@@ -1310,7 +1599,9 @@ export interface Store {
|
|
|
1310
1599
|
* ```
|
|
1311
1600
|
* @category Getter
|
|
1312
1601
|
*/
|
|
1313
|
-
getRowIds
|
|
1602
|
+
getRowIds<TableId extends TableIdFromSchema<Schemas[0]>>(
|
|
1603
|
+
tableId: TableId,
|
|
1604
|
+
): Ids;
|
|
1314
1605
|
|
|
1315
1606
|
/**
|
|
1316
1607
|
* The getSortedRowIds method returns the Ids of every Row in a given Table,
|
|
@@ -1411,9 +1702,12 @@ export interface Store {
|
|
|
1411
1702
|
* @category Getter
|
|
1412
1703
|
* @since v2.0.0
|
|
1413
1704
|
*/
|
|
1414
|
-
getSortedRowIds
|
|
1415
|
-
|
|
1416
|
-
|
|
1705
|
+
getSortedRowIds<
|
|
1706
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
1707
|
+
CellId extends CellIdFromSchema<Schemas[0], TableId>,
|
|
1708
|
+
>(
|
|
1709
|
+
tableId: TableId,
|
|
1710
|
+
cellId?: CellId,
|
|
1417
1711
|
descending?: boolean,
|
|
1418
1712
|
offset?: number,
|
|
1419
1713
|
limit?: number,
|
|
@@ -1454,7 +1748,13 @@ export interface Store {
|
|
|
1454
1748
|
* ```
|
|
1455
1749
|
* @category Getter
|
|
1456
1750
|
*/
|
|
1457
|
-
getRow
|
|
1751
|
+
getRow<
|
|
1752
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
1753
|
+
Row = RowFromSchema<Schemas[0], TableId>,
|
|
1754
|
+
>(
|
|
1755
|
+
tableId: TableId,
|
|
1756
|
+
rowId: Id,
|
|
1757
|
+
): Row;
|
|
1458
1758
|
|
|
1459
1759
|
/**
|
|
1460
1760
|
* The getCellIds method returns the Ids of every Cell in a given Row, in a
|
|
@@ -1489,7 +1789,13 @@ export interface Store {
|
|
|
1489
1789
|
* ```
|
|
1490
1790
|
* @category Getter
|
|
1491
1791
|
*/
|
|
1492
|
-
getCellIds
|
|
1792
|
+
getCellIds<
|
|
1793
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
1794
|
+
Ids extends CellIdFromSchema<Schemas[0], TableId>[],
|
|
1795
|
+
>(
|
|
1796
|
+
tableId: TableId,
|
|
1797
|
+
rowId: Id,
|
|
1798
|
+
): Ids;
|
|
1493
1799
|
|
|
1494
1800
|
/**
|
|
1495
1801
|
* The getCell method returns the value of a single Cell in a given Row, in a
|
|
@@ -1519,7 +1825,15 @@ export interface Store {
|
|
|
1519
1825
|
* ```
|
|
1520
1826
|
* @category Getter
|
|
1521
1827
|
*/
|
|
1522
|
-
getCell
|
|
1828
|
+
getCell<
|
|
1829
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
1830
|
+
CellId extends CellIdFromSchema<Schemas[0], TableId>,
|
|
1831
|
+
CellOrUndefined = CellFromSchema<Schemas[0], TableId, CellId> | undefined,
|
|
1832
|
+
>(
|
|
1833
|
+
tableId: TableId,
|
|
1834
|
+
rowId: Id,
|
|
1835
|
+
cellId: CellId,
|
|
1836
|
+
): CellOrUndefined;
|
|
1523
1837
|
|
|
1524
1838
|
/**
|
|
1525
1839
|
* The getValues method returns an object containing the entire set of keyed
|
|
@@ -1550,7 +1864,7 @@ export interface Store {
|
|
|
1550
1864
|
* @category Getter
|
|
1551
1865
|
* @since v3.0.0
|
|
1552
1866
|
*/
|
|
1553
|
-
getValues(): Values;
|
|
1867
|
+
getValues<Values = ValuesFromSchema<Schemas[1]>>(): Values;
|
|
1554
1868
|
|
|
1555
1869
|
/**
|
|
1556
1870
|
* The getValueIds method returns the Ids of every Value in a Store.
|
|
@@ -1579,7 +1893,7 @@ export interface Store {
|
|
|
1579
1893
|
* @category Getter
|
|
1580
1894
|
* @since v3.0.0
|
|
1581
1895
|
*/
|
|
1582
|
-
getValueIds(): Ids;
|
|
1896
|
+
getValueIds<Ids = ValueIdFromSchema<Schemas[1]>[]>(): Ids;
|
|
1583
1897
|
|
|
1584
1898
|
/**
|
|
1585
1899
|
* The getValue method returns a single keyed Value in the Store.
|
|
@@ -1605,7 +1919,12 @@ export interface Store {
|
|
|
1605
1919
|
* @category Getter
|
|
1606
1920
|
* @since v3.0.0
|
|
1607
1921
|
*/
|
|
1608
|
-
getValue
|
|
1922
|
+
getValue<
|
|
1923
|
+
ValueId extends ValueIdFromSchema<Schemas[1]>,
|
|
1924
|
+
ValueOrUndefined = ValueFromSchema<Schemas[1], ValueId> | undefined,
|
|
1925
|
+
>(
|
|
1926
|
+
valueId: ValueId,
|
|
1927
|
+
): ValueOrUndefined;
|
|
1609
1928
|
|
|
1610
1929
|
/**
|
|
1611
1930
|
* The hasTables method returns a boolean indicating whether any Table objects
|
|
@@ -1645,7 +1964,9 @@ export interface Store {
|
|
|
1645
1964
|
* ```
|
|
1646
1965
|
* @category Getter
|
|
1647
1966
|
*/
|
|
1648
|
-
hasTable
|
|
1967
|
+
hasTable<TableId extends TableIdFromSchema<Schemas[0]>>(
|
|
1968
|
+
tableId: TableId,
|
|
1969
|
+
): boolean;
|
|
1649
1970
|
|
|
1650
1971
|
/**
|
|
1651
1972
|
* The hasRow method returns a boolean indicating whether a given Row exists
|
|
@@ -1666,7 +1987,10 @@ export interface Store {
|
|
|
1666
1987
|
* ```
|
|
1667
1988
|
* @category Getter
|
|
1668
1989
|
*/
|
|
1669
|
-
hasRow
|
|
1990
|
+
hasRow<TableId extends TableIdFromSchema<Schemas[0]>>(
|
|
1991
|
+
tableId: TableId,
|
|
1992
|
+
rowId: Id,
|
|
1993
|
+
): boolean;
|
|
1670
1994
|
|
|
1671
1995
|
/**
|
|
1672
1996
|
* The hasCell method returns a boolean indicating whether a given Cell exists
|
|
@@ -1688,7 +2012,14 @@ export interface Store {
|
|
|
1688
2012
|
* ```
|
|
1689
2013
|
* @category Getter
|
|
1690
2014
|
*/
|
|
1691
|
-
hasCell
|
|
2015
|
+
hasCell<
|
|
2016
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
2017
|
+
CellId extends CellIdFromSchema<Schemas[0], TableId>,
|
|
2018
|
+
>(
|
|
2019
|
+
tableId: TableId,
|
|
2020
|
+
rowId: Id,
|
|
2021
|
+
cellId: CellId,
|
|
2022
|
+
): boolean;
|
|
1692
2023
|
|
|
1693
2024
|
/**
|
|
1694
2025
|
* The hasTables method returns a boolean indicating whether any Values exist
|
|
@@ -1730,7 +2061,9 @@ export interface Store {
|
|
|
1730
2061
|
* @category Getter
|
|
1731
2062
|
* @since v3.0.0
|
|
1732
2063
|
*/
|
|
1733
|
-
hasValue
|
|
2064
|
+
hasValue<ValueId extends ValueIdFromSchema<Schemas[1]>>(
|
|
2065
|
+
valueId: ValueId,
|
|
2066
|
+
): boolean;
|
|
1734
2067
|
|
|
1735
2068
|
/**
|
|
1736
2069
|
* The getTablesJson method returns a string serialization of all of the
|
|
@@ -1759,8 +2092,8 @@ export interface Store {
|
|
|
1759
2092
|
getTablesJson(): Json;
|
|
1760
2093
|
|
|
1761
2094
|
/**
|
|
1762
|
-
* The getValuesJson method returns a string serialization of all of the
|
|
1763
|
-
*
|
|
2095
|
+
* The getValuesJson method returns a string serialization of all of the keyed
|
|
2096
|
+
* Values in the Store.
|
|
1764
2097
|
*
|
|
1765
2098
|
* @returns A string serialization of all of the Values in the Store.
|
|
1766
2099
|
* @example
|
|
@@ -1969,7 +2302,9 @@ export interface Store {
|
|
|
1969
2302
|
* ```
|
|
1970
2303
|
* @category Setter
|
|
1971
2304
|
*/
|
|
1972
|
-
setTables
|
|
2305
|
+
setTables<Tables = TablesFromSchema<Schemas[0], true>>(
|
|
2306
|
+
tables: Tables,
|
|
2307
|
+
): Store<Schemas>;
|
|
1973
2308
|
|
|
1974
2309
|
/**
|
|
1975
2310
|
* The setTable method takes an object and sets the entire data of a single
|
|
@@ -2020,7 +2355,13 @@ export interface Store {
|
|
|
2020
2355
|
* ```
|
|
2021
2356
|
* @category Setter
|
|
2022
2357
|
*/
|
|
2023
|
-
setTable
|
|
2358
|
+
setTable<
|
|
2359
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
2360
|
+
Table = TableFromSchema<Schemas[0], TableId, true>,
|
|
2361
|
+
>(
|
|
2362
|
+
tableId: TableId,
|
|
2363
|
+
table: Table,
|
|
2364
|
+
): Store<Schemas>;
|
|
2024
2365
|
|
|
2025
2366
|
/**
|
|
2026
2367
|
* The setRow method takes an object and sets the entire data of a single Row
|
|
@@ -2070,7 +2411,14 @@ export interface Store {
|
|
|
2070
2411
|
* ```
|
|
2071
2412
|
* @category Setter
|
|
2072
2413
|
*/
|
|
2073
|
-
setRow
|
|
2414
|
+
setRow<
|
|
2415
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
2416
|
+
Row = RowFromSchema<Schemas[0], TableId, true>,
|
|
2417
|
+
>(
|
|
2418
|
+
tableId: TableId,
|
|
2419
|
+
rowId: Id,
|
|
2420
|
+
row: Row,
|
|
2421
|
+
): Store<Schemas>;
|
|
2074
2422
|
|
|
2075
2423
|
/**
|
|
2076
2424
|
* The addRow method takes an object and creates a new Row in the Store,
|
|
@@ -2123,7 +2471,13 @@ export interface Store {
|
|
|
2123
2471
|
* ```
|
|
2124
2472
|
* @category Setter
|
|
2125
2473
|
*/
|
|
2126
|
-
addRow
|
|
2474
|
+
addRow<
|
|
2475
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
2476
|
+
Row = RowFromSchema<Schemas[0], TableId, true>,
|
|
2477
|
+
>(
|
|
2478
|
+
tableId: TableId,
|
|
2479
|
+
row: Row,
|
|
2480
|
+
): Id | undefined;
|
|
2127
2481
|
|
|
2128
2482
|
/**
|
|
2129
2483
|
* The setPartialRow method takes an object and sets partial data of a single
|
|
@@ -2175,7 +2529,14 @@ export interface Store {
|
|
|
2175
2529
|
* ```
|
|
2176
2530
|
* @category Setter
|
|
2177
2531
|
*/
|
|
2178
|
-
setPartialRow
|
|
2532
|
+
setPartialRow<
|
|
2533
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
2534
|
+
Row = RowFromSchema<Schemas[0], TableId, true>,
|
|
2535
|
+
>(
|
|
2536
|
+
tableId: TableId,
|
|
2537
|
+
rowId: Id,
|
|
2538
|
+
partialRow: Row,
|
|
2539
|
+
): Store<Schemas>;
|
|
2179
2540
|
|
|
2180
2541
|
/**
|
|
2181
2542
|
* The setCell method sets the value of a single Cell in the Store.
|
|
@@ -2233,7 +2594,17 @@ export interface Store {
|
|
|
2233
2594
|
* ```
|
|
2234
2595
|
* @category Setter
|
|
2235
2596
|
*/
|
|
2236
|
-
setCell
|
|
2597
|
+
setCell<
|
|
2598
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
2599
|
+
CellId extends CellIdFromSchema<Schemas[0], TableId>,
|
|
2600
|
+
Cell = CellFromSchema<Schemas[0], TableId, CellId>,
|
|
2601
|
+
MapCell = (cell: Cell | undefined) => Cell,
|
|
2602
|
+
>(
|
|
2603
|
+
tableId: TableId,
|
|
2604
|
+
rowId: Id,
|
|
2605
|
+
cellId: CellId,
|
|
2606
|
+
cell: Cell | MapCell,
|
|
2607
|
+
): Store<Schemas>;
|
|
2237
2608
|
|
|
2238
2609
|
/**
|
|
2239
2610
|
* The setValues method takes an object and sets all the Values in the Store.
|
|
@@ -2281,7 +2652,9 @@ export interface Store {
|
|
|
2281
2652
|
* @category Setter
|
|
2282
2653
|
* @since v3.0.0
|
|
2283
2654
|
*/
|
|
2284
|
-
setValues
|
|
2655
|
+
setValues<Values = ValuesFromSchema<Schemas[1], true>>(
|
|
2656
|
+
values: Values,
|
|
2657
|
+
): Store<Schemas>;
|
|
2285
2658
|
|
|
2286
2659
|
/**
|
|
2287
2660
|
* The setPartialValues method takes an object and sets its Values in the
|
|
@@ -2331,7 +2704,9 @@ export interface Store {
|
|
|
2331
2704
|
* @category Setter
|
|
2332
2705
|
* @since v3.0.0
|
|
2333
2706
|
*/
|
|
2334
|
-
setPartialValues
|
|
2707
|
+
setPartialValues<Values = ValuesFromSchema<Schemas[1], true>>(
|
|
2708
|
+
partialValues: Values,
|
|
2709
|
+
): Store<Schemas>;
|
|
2335
2710
|
|
|
2336
2711
|
/**
|
|
2337
2712
|
* The setValue method sets a single keyed Value in the Store.
|
|
@@ -2385,7 +2760,14 @@ export interface Store {
|
|
|
2385
2760
|
* @category Setter
|
|
2386
2761
|
* @since v3.0.0
|
|
2387
2762
|
*/
|
|
2388
|
-
setValue
|
|
2763
|
+
setValue<
|
|
2764
|
+
ValueId extends ValueIdFromSchema<Schemas[1]>,
|
|
2765
|
+
Value = ValueFromSchema<Schemas[1], ValueId>,
|
|
2766
|
+
MapValue = (value: Value | undefined) => Value,
|
|
2767
|
+
>(
|
|
2768
|
+
valueId: ValueId,
|
|
2769
|
+
value: Value | MapValue,
|
|
2770
|
+
): Store<Schemas>;
|
|
2389
2771
|
|
|
2390
2772
|
/**
|
|
2391
2773
|
* The setTablesJson method takes a string serialization of all of the Tables
|
|
@@ -2420,7 +2802,7 @@ export interface Store {
|
|
|
2420
2802
|
* @category Setter
|
|
2421
2803
|
* @since v3.0.0
|
|
2422
2804
|
*/
|
|
2423
|
-
setTablesJson(tablesJson: Json): Store
|
|
2805
|
+
setTablesJson(tablesJson: Json): Store<Schemas>;
|
|
2424
2806
|
|
|
2425
2807
|
/**
|
|
2426
2808
|
* The setValuesJson method takes a string serialization of all of the Values
|
|
@@ -2455,7 +2837,7 @@ export interface Store {
|
|
|
2455
2837
|
* @category Setter
|
|
2456
2838
|
* @since v3.0.0
|
|
2457
2839
|
*/
|
|
2458
|
-
setValuesJson(valuesJson: Json): Store
|
|
2840
|
+
setValuesJson(valuesJson: Json): Store<Schemas>;
|
|
2459
2841
|
|
|
2460
2842
|
/**
|
|
2461
2843
|
* The setJson method takes a string serialization of all of the Tables and
|
|
@@ -2514,16 +2896,24 @@ export interface Store {
|
|
|
2514
2896
|
* ```
|
|
2515
2897
|
* @category Setter
|
|
2516
2898
|
*/
|
|
2517
|
-
setJson(tablesAndValuesJson: Json): Store
|
|
2899
|
+
setJson(tablesAndValuesJson: Json): Store<Schemas>;
|
|
2518
2900
|
|
|
2519
2901
|
/**
|
|
2520
2902
|
* The setTablesSchema method lets you specify the TablesSchema of the tabular
|
|
2521
2903
|
* part of the Store.
|
|
2522
2904
|
*
|
|
2905
|
+
* ```ts override
|
|
2906
|
+
* setTablesSchema(tablesSchema: TablesSchema): Store<Schemas>
|
|
2907
|
+
* ```
|
|
2908
|
+
*
|
|
2523
2909
|
* Note that this may result in a change to data in the Store, as defaults are
|
|
2524
2910
|
* applied or as invalid Table, Row, or Cell objects are removed. These
|
|
2525
2911
|
* changes will fire any listeners to that data, as expected.
|
|
2526
2912
|
*
|
|
2913
|
+
* This method will return a Store that is typed according to the schema that
|
|
2914
|
+
* you provided. To benefit from that, you may wish to assign it to a new
|
|
2915
|
+
* variable so that TypeScript is able to reason about its subsequent usage.
|
|
2916
|
+
*
|
|
2527
2917
|
* When no longer needed, you can also completely remove an existing
|
|
2528
2918
|
* TablesSchema with the delTablesSchema method.
|
|
2529
2919
|
*
|
|
@@ -2547,16 +2937,29 @@ export interface Store {
|
|
|
2547
2937
|
* @category Setter
|
|
2548
2938
|
* @since v3.0.0
|
|
2549
2939
|
*/
|
|
2550
|
-
setTablesSchema
|
|
2940
|
+
setTablesSchema<
|
|
2941
|
+
TablesSchema extends TablesSchemaAlias,
|
|
2942
|
+
ValuesSchema extends OptionalValuesSchema = Schemas[1],
|
|
2943
|
+
>(
|
|
2944
|
+
tablesSchema: TablesSchema,
|
|
2945
|
+
): Store<[typeof tablesSchema, ValuesSchema]>;
|
|
2551
2946
|
|
|
2552
2947
|
/**
|
|
2553
2948
|
* The setValuesSchema method lets you specify the ValuesSchema of the keyed
|
|
2554
2949
|
* Values part of the Store.
|
|
2555
2950
|
*
|
|
2951
|
+
* ```ts override
|
|
2952
|
+
* setValuesSchema(valuesSchema: ValuesSchema): Store<Schemas>
|
|
2953
|
+
* ```
|
|
2954
|
+
*
|
|
2556
2955
|
* Note that this may result in a change to data in the Store, as defaults are
|
|
2557
2956
|
* applied or as invalid Values are removed. These changes will fire any
|
|
2558
2957
|
* listeners to that data, as expected.
|
|
2559
2958
|
*
|
|
2959
|
+
* This method will return a Store that is typed according to the schema that
|
|
2960
|
+
* you provided. To benefit from that, you may wish to assign it to a new
|
|
2961
|
+
* variable so that TypeScript is able to reason about its subsequent usage.
|
|
2962
|
+
*
|
|
2560
2963
|
* When no longer needed, you can also completely remove an existing
|
|
2561
2964
|
* ValuesSchema with the delValuesSchema method.
|
|
2562
2965
|
*
|
|
@@ -2577,16 +2980,32 @@ export interface Store {
|
|
|
2577
2980
|
* @category Setter
|
|
2578
2981
|
* @since v3.0.0
|
|
2579
2982
|
*/
|
|
2580
|
-
setValuesSchema
|
|
2983
|
+
setValuesSchema<
|
|
2984
|
+
ValuesSchema extends ValuesSchemaAlias,
|
|
2985
|
+
TablesSchema extends OptionalTablesSchema = Schemas[0],
|
|
2986
|
+
>(
|
|
2987
|
+
valuesSchema: ValuesSchema,
|
|
2988
|
+
): Store<[TablesSchema, typeof valuesSchema]>;
|
|
2581
2989
|
|
|
2582
2990
|
/**
|
|
2583
2991
|
* The setSchema method lets you specify the TablesSchema and ValuesSchema of
|
|
2584
2992
|
* the Store.
|
|
2585
2993
|
*
|
|
2994
|
+
* ```ts override
|
|
2995
|
+
* setSchema(
|
|
2996
|
+
* tablesSchema: TablesSchema,
|
|
2997
|
+
* valuesSchema?: ValuesSchema,
|
|
2998
|
+
* ): Store<Schemas>
|
|
2999
|
+
* ```
|
|
3000
|
+
*
|
|
2586
3001
|
* Note that this may result in a change to data in the Store, as defaults are
|
|
2587
3002
|
* applied or as invalid Table, Row, Cell, or Value objects are removed. These
|
|
2588
3003
|
* changes will fire any listeners to that data, as expected.
|
|
2589
3004
|
*
|
|
3005
|
+
* This method will return a Store that is typed according to the schemas that
|
|
3006
|
+
* you provided. To benefit from that, you may wish to assign it to a new
|
|
3007
|
+
* variable so that TypeScript is able to reason about its subsequent usage.
|
|
3008
|
+
*
|
|
2590
3009
|
* From v3.0.0 onwards, this method takes two arguments. The first is the
|
|
2591
3010
|
* TablesSchema object, the second the ValuesSchema. In previous versions
|
|
2592
3011
|
* (before the existence of the ValuesSchema data structure), only the first
|
|
@@ -2636,7 +3055,20 @@ export interface Store {
|
|
|
2636
3055
|
* ```
|
|
2637
3056
|
* @category Setter
|
|
2638
3057
|
*/
|
|
2639
|
-
setSchema
|
|
3058
|
+
setSchema<
|
|
3059
|
+
TablesSchema extends TablesSchemaAlias,
|
|
3060
|
+
ValuesSchema extends ValuesSchemaAlias,
|
|
3061
|
+
>(
|
|
3062
|
+
tablesSchema: TablesSchema,
|
|
3063
|
+
valuesSchema?: ValuesSchema,
|
|
3064
|
+
): Store<
|
|
3065
|
+
[
|
|
3066
|
+
typeof tablesSchema,
|
|
3067
|
+
Exclude<ValuesSchemaAlias, typeof valuesSchema> extends never
|
|
3068
|
+
? NoValuesSchema
|
|
3069
|
+
: NonNullable<typeof valuesSchema>,
|
|
3070
|
+
]
|
|
3071
|
+
>;
|
|
2640
3072
|
|
|
2641
3073
|
/**
|
|
2642
3074
|
* The delTables method lets you remove all of the data in a Store.
|
|
@@ -2654,7 +3086,7 @@ export interface Store {
|
|
|
2654
3086
|
* ```
|
|
2655
3087
|
* @category Deleter
|
|
2656
3088
|
*/
|
|
2657
|
-
delTables(): Store
|
|
3089
|
+
delTables(): Store<Schemas>;
|
|
2658
3090
|
|
|
2659
3091
|
/**
|
|
2660
3092
|
* The delTable method lets you remove a single Table from the Store.
|
|
@@ -2676,7 +3108,9 @@ export interface Store {
|
|
|
2676
3108
|
* ```
|
|
2677
3109
|
* @category Deleter
|
|
2678
3110
|
*/
|
|
2679
|
-
delTable
|
|
3111
|
+
delTable<TableId extends TableIdFromSchema<Schemas[0]>>(
|
|
3112
|
+
tableId: TableId,
|
|
3113
|
+
): Store<Schemas>;
|
|
2680
3114
|
|
|
2681
3115
|
/**
|
|
2682
3116
|
* The delRow method lets you remove a single Row from a Table.
|
|
@@ -2700,7 +3134,10 @@ export interface Store {
|
|
|
2700
3134
|
* ```
|
|
2701
3135
|
* @category Deleter
|
|
2702
3136
|
*/
|
|
2703
|
-
delRow
|
|
3137
|
+
delRow<TableId extends TableIdFromSchema<Schemas[0]>>(
|
|
3138
|
+
tableId: TableId,
|
|
3139
|
+
rowId: Id,
|
|
3140
|
+
): Store<Schemas>;
|
|
2704
3141
|
|
|
2705
3142
|
/**
|
|
2706
3143
|
* The delCell method lets you remove a single Cell from a Row.
|
|
@@ -2784,7 +3221,15 @@ export interface Store {
|
|
|
2784
3221
|
* ```
|
|
2785
3222
|
* @category Deleter
|
|
2786
3223
|
*/
|
|
2787
|
-
delCell
|
|
3224
|
+
delCell<
|
|
3225
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
3226
|
+
CellId extends CellIdFromSchema<Schemas[0], TableId>,
|
|
3227
|
+
>(
|
|
3228
|
+
tableId: TableId,
|
|
3229
|
+
rowId: Id,
|
|
3230
|
+
cellId: CellId,
|
|
3231
|
+
forceDel?: boolean,
|
|
3232
|
+
): Store<Schemas>;
|
|
2788
3233
|
|
|
2789
3234
|
/**
|
|
2790
3235
|
* The delValues method lets you remove all the Values from a Store.
|
|
@@ -2823,7 +3268,7 @@ export interface Store {
|
|
|
2823
3268
|
* @category Deleter
|
|
2824
3269
|
* @since v3.0.0
|
|
2825
3270
|
*/
|
|
2826
|
-
delValues(): Store
|
|
3271
|
+
delValues(): Store<Schemas>;
|
|
2827
3272
|
|
|
2828
3273
|
/**
|
|
2829
3274
|
* The delValue method lets you remove a single Value from a Store.
|
|
@@ -2863,7 +3308,9 @@ export interface Store {
|
|
|
2863
3308
|
* @category Deleter
|
|
2864
3309
|
* @since v3.0.0
|
|
2865
3310
|
*/
|
|
2866
|
-
delValue
|
|
3311
|
+
delValue<ValueId extends ValueIdFromSchema<Schemas[1]>>(
|
|
3312
|
+
valueId: ValueId,
|
|
3313
|
+
): Store<Schemas>;
|
|
2867
3314
|
|
|
2868
3315
|
/**
|
|
2869
3316
|
* The delTablesSchema method lets you remove the TablesSchema of the Store.
|
|
@@ -2882,7 +3329,9 @@ export interface Store {
|
|
|
2882
3329
|
* ```
|
|
2883
3330
|
* @category Deleter
|
|
2884
3331
|
*/
|
|
2885
|
-
delTablesSchema
|
|
3332
|
+
delTablesSchema<
|
|
3333
|
+
ValuesSchema extends OptionalValuesSchema = Schemas[1],
|
|
3334
|
+
>(): Store<[NoTablesSchema, ValuesSchema]>;
|
|
2886
3335
|
|
|
2887
3336
|
/**
|
|
2888
3337
|
* The delValuesSchema method lets you remove the ValuesSchema of the Store.
|
|
@@ -2902,7 +3351,9 @@ export interface Store {
|
|
|
2902
3351
|
* @category Deleter
|
|
2903
3352
|
* @since v3.0.0
|
|
2904
3353
|
*/
|
|
2905
|
-
delValuesSchema
|
|
3354
|
+
delValuesSchema<
|
|
3355
|
+
TablesSchema extends OptionalTablesSchema = Schemas[0],
|
|
3356
|
+
>(): Store<[TablesSchema, NoValuesSchema]>;
|
|
2906
3357
|
|
|
2907
3358
|
/**
|
|
2908
3359
|
* The delSchema method lets you remove both the TablesSchema and ValuesSchema
|
|
@@ -2929,7 +3380,7 @@ export interface Store {
|
|
|
2929
3380
|
* @category Deleter
|
|
2930
3381
|
* @since v3.0.0
|
|
2931
3382
|
*/
|
|
2932
|
-
delSchema(): Store
|
|
3383
|
+
delSchema(): Store<NoSchemas>;
|
|
2933
3384
|
|
|
2934
3385
|
/**
|
|
2935
3386
|
* The transaction method takes a function that makes multiple mutations to
|
|
@@ -3057,7 +3508,10 @@ export interface Store {
|
|
|
3057
3508
|
* ```
|
|
3058
3509
|
* @category Transaction
|
|
3059
3510
|
*/
|
|
3060
|
-
transaction<Return>(
|
|
3511
|
+
transaction<Return>(
|
|
3512
|
+
actions: () => Return,
|
|
3513
|
+
doRollback?: DoRollback<Schemas>,
|
|
3514
|
+
): Return;
|
|
3061
3515
|
|
|
3062
3516
|
/**
|
|
3063
3517
|
* The startTransaction method allows you to explicitly start a transaction
|
|
@@ -3108,7 +3562,7 @@ export interface Store {
|
|
|
3108
3562
|
* @category Transaction
|
|
3109
3563
|
* @since v1.3.0
|
|
3110
3564
|
*/
|
|
3111
|
-
startTransaction(): Store
|
|
3565
|
+
startTransaction(): Store<Schemas>;
|
|
3112
3566
|
|
|
3113
3567
|
/**
|
|
3114
3568
|
* The finishTransaction method allows you to explicitly finish a transaction
|
|
@@ -3132,8 +3586,8 @@ export interface Store {
|
|
|
3132
3586
|
* been a corresponding startTransaction method that this completes, of
|
|
3133
3587
|
* course, otherwise this function has no effect.
|
|
3134
3588
|
*
|
|
3135
|
-
* The optional parameter, `doRollback` is a DoRollback callback that
|
|
3136
|
-
*
|
|
3589
|
+
* The optional parameter, `doRollback` is a DoRollback callback that you can
|
|
3590
|
+
* use to rollback the transaction if it did not complete to your
|
|
3137
3591
|
* satisfaction. It is called with `changedCells`, `invalidCells`,
|
|
3138
3592
|
* `changedValues`, and `invalidValues` parameters, which inform you of the
|
|
3139
3593
|
* net changes that have been made during the transaction, and any invalid
|
|
@@ -3206,7 +3660,7 @@ export interface Store {
|
|
|
3206
3660
|
* @category Transaction
|
|
3207
3661
|
* @since v1.3.0
|
|
3208
3662
|
*/
|
|
3209
|
-
finishTransaction(doRollback?: DoRollback): Store
|
|
3663
|
+
finishTransaction(doRollback?: DoRollback<Schemas>): Store<Schemas>;
|
|
3210
3664
|
|
|
3211
3665
|
/**
|
|
3212
3666
|
* The forEachTable method takes a function that it will then call for each
|
|
@@ -3239,7 +3693,9 @@ export interface Store {
|
|
|
3239
3693
|
* ```
|
|
3240
3694
|
* @category Iterator
|
|
3241
3695
|
*/
|
|
3242
|
-
forEachTable
|
|
3696
|
+
forEachTable<TableCallback = TableCallbackAlias<Schemas[0]>>(
|
|
3697
|
+
tableCallback: TableCallback,
|
|
3698
|
+
): void;
|
|
3243
3699
|
|
|
3244
3700
|
/**
|
|
3245
3701
|
* The forEachRow method takes a function that it will then call for each Row
|
|
@@ -3274,7 +3730,13 @@ export interface Store {
|
|
|
3274
3730
|
* ```
|
|
3275
3731
|
* @category Iterator
|
|
3276
3732
|
*/
|
|
3277
|
-
forEachRow
|
|
3733
|
+
forEachRow<
|
|
3734
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
3735
|
+
RowCallback = RowCallbackAlias<Schemas[0], TableId>,
|
|
3736
|
+
>(
|
|
3737
|
+
tableId: TableId,
|
|
3738
|
+
rowCallback: RowCallback,
|
|
3739
|
+
): void;
|
|
3278
3740
|
|
|
3279
3741
|
/**
|
|
3280
3742
|
* The forEachCell method takes a function that it will then call for each
|
|
@@ -3302,7 +3764,14 @@ export interface Store {
|
|
|
3302
3764
|
* ```
|
|
3303
3765
|
* @category Iterator
|
|
3304
3766
|
*/
|
|
3305
|
-
forEachCell
|
|
3767
|
+
forEachCell<
|
|
3768
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
3769
|
+
CellCallback = CellCallbackAlias<Schemas[0], TableId>,
|
|
3770
|
+
>(
|
|
3771
|
+
tableId: TableId,
|
|
3772
|
+
rowId: Id,
|
|
3773
|
+
cellCallback: CellCallback,
|
|
3774
|
+
): void;
|
|
3306
3775
|
|
|
3307
3776
|
/**
|
|
3308
3777
|
* The forEachValue method takes a function that it will then call for each
|
|
@@ -3327,7 +3796,9 @@ export interface Store {
|
|
|
3327
3796
|
* @category Iterator
|
|
3328
3797
|
* @since v3.0.0
|
|
3329
3798
|
*/
|
|
3330
|
-
forEachValue
|
|
3799
|
+
forEachValue<ValueCallback = ValueCallbackAlias<Schemas[1]>>(
|
|
3800
|
+
valueCallback: ValueCallback,
|
|
3801
|
+
): void;
|
|
3331
3802
|
|
|
3332
3803
|
/**
|
|
3333
3804
|
* The addTablesListener method registers a listener function with the Store
|
|
@@ -3391,7 +3862,7 @@ export interface Store {
|
|
|
3391
3862
|
* ```
|
|
3392
3863
|
* @category Listener
|
|
3393
3864
|
*/
|
|
3394
|
-
addTablesListener(listener: TablesListener
|
|
3865
|
+
addTablesListener(listener: TablesListener<Schemas>, mutator?: boolean): Id;
|
|
3395
3866
|
|
|
3396
3867
|
/**
|
|
3397
3868
|
* The addTableIdsListener method registers a listener function with the Store
|
|
@@ -3454,7 +3925,10 @@ export interface Store {
|
|
|
3454
3925
|
* ```
|
|
3455
3926
|
* @category Listener
|
|
3456
3927
|
*/
|
|
3457
|
-
addTableIdsListener(
|
|
3928
|
+
addTableIdsListener(
|
|
3929
|
+
listener: TableIdsListener<Schemas>,
|
|
3930
|
+
mutator?: boolean,
|
|
3931
|
+
): Id;
|
|
3458
3932
|
|
|
3459
3933
|
/**
|
|
3460
3934
|
* The addTableListener method registers a listener function with the Store
|
|
@@ -3547,9 +4021,9 @@ export interface Store {
|
|
|
3547
4021
|
* ```
|
|
3548
4022
|
* @category Listener
|
|
3549
4023
|
*/
|
|
3550
|
-
addTableListener(
|
|
3551
|
-
tableId:
|
|
3552
|
-
listener: TableListener,
|
|
4024
|
+
addTableListener<TableIdOrNull extends TableIdFromSchema<Schemas[0]> | null>(
|
|
4025
|
+
tableId: TableIdOrNull,
|
|
4026
|
+
listener: TableListener<Schemas, TableIdOrNull>,
|
|
3553
4027
|
mutator?: boolean,
|
|
3554
4028
|
): Id;
|
|
3555
4029
|
|
|
@@ -3639,9 +4113,9 @@ export interface Store {
|
|
|
3639
4113
|
* ```
|
|
3640
4114
|
* @category Listener
|
|
3641
4115
|
*/
|
|
3642
|
-
addRowIdsListener(
|
|
3643
|
-
tableId:
|
|
3644
|
-
listener: RowIdsListener,
|
|
4116
|
+
addRowIdsListener<TableIdOrNull extends TableIdFromSchema<Schemas[0]> | null>(
|
|
4117
|
+
tableId: TableIdOrNull,
|
|
4118
|
+
listener: RowIdsListener<Schemas, TableIdOrNull>,
|
|
3645
4119
|
mutator?: boolean,
|
|
3646
4120
|
): Id;
|
|
3647
4121
|
|
|
@@ -3861,13 +4335,26 @@ export interface Store {
|
|
|
3861
4335
|
* @category Listener
|
|
3862
4336
|
* @since v2.0.0
|
|
3863
4337
|
*/
|
|
3864
|
-
addSortedRowIdsListener
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
4338
|
+
addSortedRowIdsListener<
|
|
4339
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
4340
|
+
CellId extends CellIdFromSchema<Schemas[0], TableId> | undefined,
|
|
4341
|
+
Descending extends boolean,
|
|
4342
|
+
Offset extends number,
|
|
4343
|
+
Limit extends number | undefined,
|
|
4344
|
+
>(
|
|
4345
|
+
tableId: TableId,
|
|
4346
|
+
cellId: CellId,
|
|
4347
|
+
descending: Descending,
|
|
4348
|
+
offset: Offset,
|
|
4349
|
+
limit: Limit,
|
|
4350
|
+
listener: SortedRowIdsListener<
|
|
4351
|
+
Schemas,
|
|
4352
|
+
TableId,
|
|
4353
|
+
CellId,
|
|
4354
|
+
Descending,
|
|
4355
|
+
Offset,
|
|
4356
|
+
Limit
|
|
4357
|
+
>,
|
|
3871
4358
|
mutator?: boolean,
|
|
3872
4359
|
): Id;
|
|
3873
4360
|
|
|
@@ -3974,10 +4461,13 @@ export interface Store {
|
|
|
3974
4461
|
* ```
|
|
3975
4462
|
* @category Listener
|
|
3976
4463
|
*/
|
|
3977
|
-
addRowListener
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
4464
|
+
addRowListener<
|
|
4465
|
+
TableIdOrNull extends TableIdFromSchema<Schemas[0]> | null,
|
|
4466
|
+
RowIdOrNull extends IdOrNull,
|
|
4467
|
+
>(
|
|
4468
|
+
tableId: TableIdOrNull,
|
|
4469
|
+
rowId: RowIdOrNull,
|
|
4470
|
+
listener: RowListener<Schemas, TableIdOrNull, RowIdOrNull>,
|
|
3981
4471
|
mutator?: boolean,
|
|
3982
4472
|
): Id;
|
|
3983
4473
|
|
|
@@ -4080,10 +4570,13 @@ export interface Store {
|
|
|
4080
4570
|
* ```
|
|
4081
4571
|
* @category Listener
|
|
4082
4572
|
*/
|
|
4083
|
-
addCellIdsListener
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4573
|
+
addCellIdsListener<
|
|
4574
|
+
TableIdOrNull extends TableIdFromSchema<Schemas[0]> | null,
|
|
4575
|
+
RowIdOrNull extends IdOrNull,
|
|
4576
|
+
>(
|
|
4577
|
+
tableId: TableIdOrNull,
|
|
4578
|
+
rowId: RowIdOrNull,
|
|
4579
|
+
listener: CellIdsListener<Schemas, TableIdOrNull, RowIdOrNull>,
|
|
4087
4580
|
mutator?: boolean,
|
|
4088
4581
|
): Id;
|
|
4089
4582
|
|
|
@@ -4199,10 +4692,24 @@ export interface Store {
|
|
|
4199
4692
|
* ```
|
|
4200
4693
|
* @category Listener
|
|
4201
4694
|
*/
|
|
4202
|
-
addCellListener
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4695
|
+
addCellListener<
|
|
4696
|
+
TableIdOrNull extends TableIdFromSchema<Schemas[0]> | null,
|
|
4697
|
+
RowIdOrNull extends IdOrNull,
|
|
4698
|
+
CellIdOrNull extends
|
|
4699
|
+
| (TableIdOrNull extends TableIdFromSchema<Schemas[0]>
|
|
4700
|
+
? CellIdFromSchema<Schemas[0], TableIdOrNull>
|
|
4701
|
+
: AllCellIdFromSchema<Schemas[0]>)
|
|
4702
|
+
| null,
|
|
4703
|
+
CellListener extends CellListenerAlias<
|
|
4704
|
+
Schemas,
|
|
4705
|
+
TableIdOrNull,
|
|
4706
|
+
RowIdOrNull,
|
|
4707
|
+
CellIdOrNull
|
|
4708
|
+
>,
|
|
4709
|
+
>(
|
|
4710
|
+
tableId: TableIdOrNull,
|
|
4711
|
+
rowId: RowIdOrNull,
|
|
4712
|
+
cellId: CellIdOrNull,
|
|
4206
4713
|
listener: CellListener,
|
|
4207
4714
|
mutator?: boolean,
|
|
4208
4715
|
): Id;
|
|
@@ -4266,7 +4773,7 @@ export interface Store {
|
|
|
4266
4773
|
* @category Listener
|
|
4267
4774
|
* @since v3.0.0
|
|
4268
4775
|
*/
|
|
4269
|
-
addValuesListener(listener: ValuesListener
|
|
4776
|
+
addValuesListener(listener: ValuesListener<Schemas>, mutator?: boolean): Id;
|
|
4270
4777
|
|
|
4271
4778
|
/**
|
|
4272
4779
|
* The addValueIdsListener method registers a listener function with the Store
|
|
@@ -4330,7 +4837,10 @@ export interface Store {
|
|
|
4330
4837
|
* @category Listener
|
|
4331
4838
|
* @since v3.0.0
|
|
4332
4839
|
*/
|
|
4333
|
-
addValueIdsListener(
|
|
4840
|
+
addValueIdsListener(
|
|
4841
|
+
listener: ValueIdsListener<Schemas>,
|
|
4842
|
+
mutator?: boolean,
|
|
4843
|
+
): Id;
|
|
4334
4844
|
|
|
4335
4845
|
/**
|
|
4336
4846
|
* The addValueListener method registers a listener function with the Store
|
|
@@ -4419,8 +4929,11 @@ export interface Store {
|
|
|
4419
4929
|
* @category Listener
|
|
4420
4930
|
* @since v3.0.0
|
|
4421
4931
|
*/
|
|
4422
|
-
addValueListener
|
|
4423
|
-
|
|
4932
|
+
addValueListener<
|
|
4933
|
+
ValueIdOrNull extends ValueIdFromSchema<Schemas[1]> | null,
|
|
4934
|
+
ValueListener = ValueListenerAlias<Schemas, ValueIdOrNull>,
|
|
4935
|
+
>(
|
|
4936
|
+
valueId: ValueIdOrNull,
|
|
4424
4937
|
listener: ValueListener,
|
|
4425
4938
|
mutator?: boolean,
|
|
4426
4939
|
): Id;
|
|
@@ -4652,7 +5165,7 @@ export interface Store {
|
|
|
4652
5165
|
tableId: IdOrNull,
|
|
4653
5166
|
rowId: IdOrNull,
|
|
4654
5167
|
cellId: IdOrNull,
|
|
4655
|
-
listener: InvalidCellListener
|
|
5168
|
+
listener: InvalidCellListener<Schemas>,
|
|
4656
5169
|
mutator?: boolean,
|
|
4657
5170
|
): Id;
|
|
4658
5171
|
|
|
@@ -4828,7 +5341,7 @@ export interface Store {
|
|
|
4828
5341
|
*/
|
|
4829
5342
|
addInvalidValueListener(
|
|
4830
5343
|
valueId: IdOrNull,
|
|
4831
|
-
listener: InvalidValueListener
|
|
5344
|
+
listener: InvalidValueListener<Schemas>,
|
|
4832
5345
|
mutator?: boolean,
|
|
4833
5346
|
): Id;
|
|
4834
5347
|
|
|
@@ -4922,7 +5435,7 @@ export interface Store {
|
|
|
4922
5435
|
* @category Listener
|
|
4923
5436
|
* @since v1.3.0
|
|
4924
5437
|
*/
|
|
4925
|
-
addWillFinishTransactionListener(listener: TransactionListener): Id;
|
|
5438
|
+
addWillFinishTransactionListener(listener: TransactionListener<Schemas>): Id;
|
|
4926
5439
|
|
|
4927
5440
|
/**
|
|
4928
5441
|
* The addDidFinishTransactionListener method registers a listener function
|
|
@@ -5015,7 +5528,7 @@ export interface Store {
|
|
|
5015
5528
|
* @category Listener
|
|
5016
5529
|
* @since v1.3.0
|
|
5017
5530
|
*/
|
|
5018
|
-
addDidFinishTransactionListener(listener: TransactionListener): Id;
|
|
5531
|
+
addDidFinishTransactionListener(listener: TransactionListener<Schemas>): Id;
|
|
5019
5532
|
|
|
5020
5533
|
/**
|
|
5021
5534
|
* The callListener method provides a way for you to manually provoke a
|
|
@@ -5132,7 +5645,7 @@ export interface Store {
|
|
|
5132
5645
|
* ```
|
|
5133
5646
|
* @category Listener
|
|
5134
5647
|
*/
|
|
5135
|
-
callListener(listenerId: Id): Store
|
|
5648
|
+
callListener(listenerId: Id): Store<Schemas>;
|
|
5136
5649
|
|
|
5137
5650
|
/**
|
|
5138
5651
|
* The delListener method removes a listener that was previously added to the
|
|
@@ -5165,7 +5678,7 @@ export interface Store {
|
|
|
5165
5678
|
* ```
|
|
5166
5679
|
* @category Listener
|
|
5167
5680
|
*/
|
|
5168
|
-
delListener(listenerId: Id): Store
|
|
5681
|
+
delListener(listenerId: Id): Store<Schemas>;
|
|
5169
5682
|
|
|
5170
5683
|
/**
|
|
5171
5684
|
* The getListenerStats method provides a set of statistics about the
|
|
@@ -5242,3 +5755,389 @@ export interface Store {
|
|
|
5242
5755
|
* @category Creation
|
|
5243
5756
|
*/
|
|
5244
5757
|
export function createStore(): Store;
|
|
5758
|
+
|
|
5759
|
+
/**
|
|
5760
|
+
* The TablesFromSchema type is a utility for determining a Tables structure
|
|
5761
|
+
* from a provided TablesSchema.
|
|
5762
|
+
*
|
|
5763
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
5764
|
+
* expected to need to use it directly.
|
|
5765
|
+
*
|
|
5766
|
+
* @category Internal
|
|
5767
|
+
*/
|
|
5768
|
+
export type TablesFromSchema<
|
|
5769
|
+
Schema extends OptionalTablesSchema,
|
|
5770
|
+
WhenSet extends boolean = false,
|
|
5771
|
+
> = {
|
|
5772
|
+
-readonly [TableId in TableIdFromSchema<Schema>]?: TableFromSchema<
|
|
5773
|
+
Schema,
|
|
5774
|
+
TableId,
|
|
5775
|
+
WhenSet
|
|
5776
|
+
>;
|
|
5777
|
+
};
|
|
5778
|
+
|
|
5779
|
+
/**
|
|
5780
|
+
* The TableIdFromSchema type is a utility for determining the Id of Tables from
|
|
5781
|
+
* a provided TablesSchema.
|
|
5782
|
+
*
|
|
5783
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
5784
|
+
* expected to need to use it directly.
|
|
5785
|
+
*
|
|
5786
|
+
* @category Internal
|
|
5787
|
+
*/
|
|
5788
|
+
export type TableIdFromSchema<Schema extends OptionalTablesSchema> = AsId<
|
|
5789
|
+
keyof Schema
|
|
5790
|
+
>;
|
|
5791
|
+
|
|
5792
|
+
/**
|
|
5793
|
+
* The TableFromSchema type is a utility for determining a Table structure from
|
|
5794
|
+
* a provided TablesSchema.
|
|
5795
|
+
*
|
|
5796
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
5797
|
+
* expected to need to use it directly.
|
|
5798
|
+
*
|
|
5799
|
+
* @category Internal
|
|
5800
|
+
*/
|
|
5801
|
+
export type TableFromSchema<
|
|
5802
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
5803
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
5804
|
+
WhenSet extends boolean = false,
|
|
5805
|
+
> = {[rowId: Id]: RowFromSchema<Schema, TableId, WhenSet>};
|
|
5806
|
+
|
|
5807
|
+
/**
|
|
5808
|
+
* The RowFromSchema type is a utility for determining a Row structure from a
|
|
5809
|
+
* provided TablesSchema.
|
|
5810
|
+
*
|
|
5811
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
5812
|
+
* expected to need to use it directly.
|
|
5813
|
+
*
|
|
5814
|
+
* @category Internal
|
|
5815
|
+
*/
|
|
5816
|
+
export type RowFromSchema<
|
|
5817
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
5818
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
5819
|
+
WhenSet extends boolean = false,
|
|
5820
|
+
> = (WhenSet extends true
|
|
5821
|
+
? {
|
|
5822
|
+
-readonly [CellId in DefaultCellIdFromSchema<
|
|
5823
|
+
Schema,
|
|
5824
|
+
TableId
|
|
5825
|
+
>]?: CellFromSchema<Schema, TableId, CellId>;
|
|
5826
|
+
}
|
|
5827
|
+
: {
|
|
5828
|
+
-readonly [CellId in DefaultCellIdFromSchema<
|
|
5829
|
+
Schema,
|
|
5830
|
+
TableId
|
|
5831
|
+
>]: CellFromSchema<Schema, TableId, CellId>;
|
|
5832
|
+
}) & {
|
|
5833
|
+
-readonly [CellId in DefaultCellIdFromSchema<
|
|
5834
|
+
Schema,
|
|
5835
|
+
TableId,
|
|
5836
|
+
false
|
|
5837
|
+
>]?: CellFromSchema<Schema, TableId, CellId>;
|
|
5838
|
+
};
|
|
5839
|
+
|
|
5840
|
+
/**
|
|
5841
|
+
* The CellIdFromSchema type is a utility for determining the Id of Cells from a
|
|
5842
|
+
* provided TablesSchema.
|
|
5843
|
+
*
|
|
5844
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
5845
|
+
* expected to need to use it directly.
|
|
5846
|
+
*
|
|
5847
|
+
* @category Internal
|
|
5848
|
+
*/
|
|
5849
|
+
export type CellIdFromSchema<
|
|
5850
|
+
Schema extends OptionalTablesSchema,
|
|
5851
|
+
TableId extends TableIdFromSchema<Schema>,
|
|
5852
|
+
> = AsId<keyof Schema[TableId]>;
|
|
5853
|
+
|
|
5854
|
+
/**
|
|
5855
|
+
* The DefaultCellIdFromSchema type is a utility for determining Cells with or
|
|
5856
|
+
* without default status from a provided TablesSchema.
|
|
5857
|
+
*
|
|
5858
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
5859
|
+
* expected to need to use it directly.
|
|
5860
|
+
*
|
|
5861
|
+
* @category Internal
|
|
5862
|
+
*/
|
|
5863
|
+
export type DefaultCellIdFromSchema<
|
|
5864
|
+
Schema extends OptionalTablesSchema,
|
|
5865
|
+
TableId extends TableIdFromSchema<Schema>,
|
|
5866
|
+
IsDefaulted extends boolean = true,
|
|
5867
|
+
> = AsId<
|
|
5868
|
+
{
|
|
5869
|
+
[CellId in CellIdFromSchema<
|
|
5870
|
+
Schema,
|
|
5871
|
+
TableId
|
|
5872
|
+
>]: Schema[TableId][CellId] extends {
|
|
5873
|
+
default: string | number | boolean;
|
|
5874
|
+
}
|
|
5875
|
+
? IsDefaulted extends true
|
|
5876
|
+
? CellId
|
|
5877
|
+
: never
|
|
5878
|
+
: IsDefaulted extends true
|
|
5879
|
+
? never
|
|
5880
|
+
: CellId;
|
|
5881
|
+
}[CellIdFromSchema<Schema, TableId>]
|
|
5882
|
+
>;
|
|
5883
|
+
|
|
5884
|
+
/**
|
|
5885
|
+
* The AllCellIdFromSchema type is a utility for determining the Id of Cells
|
|
5886
|
+
* across all Tables, from a provided TablesSchema.
|
|
5887
|
+
*
|
|
5888
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
5889
|
+
* expected to need to use it directly.
|
|
5890
|
+
*
|
|
5891
|
+
* @category Internal
|
|
5892
|
+
*/
|
|
5893
|
+
export type AllCellIdFromSchema<
|
|
5894
|
+
Schema extends OptionalTablesSchema,
|
|
5895
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
5896
|
+
> = TableId extends TableIdFromSchema<Schema>
|
|
5897
|
+
? CellIdFromSchema<Schema, TableId>
|
|
5898
|
+
: never;
|
|
5899
|
+
|
|
5900
|
+
/**
|
|
5901
|
+
* The CellFromSchema type is a utility for determining a Cell type from a
|
|
5902
|
+
* provided TablesSchema.
|
|
5903
|
+
*
|
|
5904
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
5905
|
+
* expected to need to use it directly.
|
|
5906
|
+
*
|
|
5907
|
+
* @category Internal
|
|
5908
|
+
*/
|
|
5909
|
+
export type CellFromSchema<
|
|
5910
|
+
Schema extends OptionalTablesSchema,
|
|
5911
|
+
TableId extends TableIdFromSchema<Schema>,
|
|
5912
|
+
CellId extends CellIdFromSchema<Schema, TableId>,
|
|
5913
|
+
CellType = Schema[TableId][CellId]['type'],
|
|
5914
|
+
> = CellType extends 'string'
|
|
5915
|
+
? string
|
|
5916
|
+
: CellType extends 'number'
|
|
5917
|
+
? number
|
|
5918
|
+
: CellType extends 'boolean'
|
|
5919
|
+
? boolean
|
|
5920
|
+
: string | number | boolean;
|
|
5921
|
+
|
|
5922
|
+
/**
|
|
5923
|
+
* The ValuesFromSchema type is a utility for determining a Values structure
|
|
5924
|
+
* from a provided ValuesSchema.
|
|
5925
|
+
*
|
|
5926
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
5927
|
+
* expected to need to use it directly.
|
|
5928
|
+
*
|
|
5929
|
+
* @category Internal
|
|
5930
|
+
*/
|
|
5931
|
+
export type ValuesFromSchema<
|
|
5932
|
+
Schema extends OptionalValuesSchema,
|
|
5933
|
+
WhenSet extends boolean = false,
|
|
5934
|
+
> = (WhenSet extends true
|
|
5935
|
+
? {
|
|
5936
|
+
-readonly [ValueId in DefaultValueIdFromSchema<Schema>]?: ValueFromSchema<
|
|
5937
|
+
Schema,
|
|
5938
|
+
ValueId
|
|
5939
|
+
>;
|
|
5940
|
+
}
|
|
5941
|
+
: {
|
|
5942
|
+
-readonly [ValueId in DefaultValueIdFromSchema<Schema>]: ValueFromSchema<
|
|
5943
|
+
Schema,
|
|
5944
|
+
ValueId
|
|
5945
|
+
>;
|
|
5946
|
+
}) & {
|
|
5947
|
+
-readonly [ValueId in DefaultValueIdFromSchema<
|
|
5948
|
+
Schema,
|
|
5949
|
+
false
|
|
5950
|
+
>]?: ValueFromSchema<Schema, ValueId>;
|
|
5951
|
+
};
|
|
5952
|
+
|
|
5953
|
+
/**
|
|
5954
|
+
* The ValueIdFromSchema type is a utility for determining the Id of Values from
|
|
5955
|
+
* a provided ValuesSchema.
|
|
5956
|
+
*
|
|
5957
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
5958
|
+
* expected to need to use it directly.
|
|
5959
|
+
*
|
|
5960
|
+
* @category Internal
|
|
5961
|
+
*/
|
|
5962
|
+
export type ValueIdFromSchema<Schema extends OptionalValuesSchema> = AsId<
|
|
5963
|
+
keyof Schema
|
|
5964
|
+
>;
|
|
5965
|
+
|
|
5966
|
+
/**
|
|
5967
|
+
* The DefaultValueIdFromSchema type is a utility for determining Values with or
|
|
5968
|
+
* without default status from a provided ValuesSchema.
|
|
5969
|
+
*
|
|
5970
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
5971
|
+
* expected to need to use it directly.
|
|
5972
|
+
*
|
|
5973
|
+
* @category Internal
|
|
5974
|
+
*/
|
|
5975
|
+
export type DefaultValueIdFromSchema<
|
|
5976
|
+
Schema extends OptionalValuesSchema,
|
|
5977
|
+
IsDefaulted extends boolean = true,
|
|
5978
|
+
> = {
|
|
5979
|
+
[ValueId in ValueIdFromSchema<Schema>]: Schema[ValueId] extends {
|
|
5980
|
+
default: string | number | boolean;
|
|
5981
|
+
}
|
|
5982
|
+
? IsDefaulted extends true
|
|
5983
|
+
? ValueId
|
|
5984
|
+
: never
|
|
5985
|
+
: IsDefaulted extends true
|
|
5986
|
+
? never
|
|
5987
|
+
: ValueId;
|
|
5988
|
+
}[ValueIdFromSchema<Schema>];
|
|
5989
|
+
|
|
5990
|
+
/**
|
|
5991
|
+
* The ValueFromSchema type is a utility for determining a Value type from a
|
|
5992
|
+
* provided ValuesSchema.
|
|
5993
|
+
*
|
|
5994
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
5995
|
+
* expected to need to use it directly.
|
|
5996
|
+
*
|
|
5997
|
+
* @category Internal
|
|
5998
|
+
*/
|
|
5999
|
+
export type ValueFromSchema<
|
|
6000
|
+
Schema extends OptionalValuesSchema,
|
|
6001
|
+
ValueId extends ValueIdFromSchema<Schema>,
|
|
6002
|
+
ValueType = Schema[ValueId]['type'],
|
|
6003
|
+
> = ValueType extends 'string'
|
|
6004
|
+
? string
|
|
6005
|
+
: ValueType extends 'number'
|
|
6006
|
+
? number
|
|
6007
|
+
: ValueType extends 'boolean'
|
|
6008
|
+
? boolean
|
|
6009
|
+
: string | number | boolean;
|
|
6010
|
+
|
|
6011
|
+
/**
|
|
6012
|
+
* The AsId type is a utility for coercing keys to be Id-like.
|
|
6013
|
+
*
|
|
6014
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
6015
|
+
* expected to need to use it directly.
|
|
6016
|
+
*
|
|
6017
|
+
* @category Internal
|
|
6018
|
+
*/
|
|
6019
|
+
export type AsId<Key> = Exclude<Key & Id, number>;
|
|
6020
|
+
|
|
6021
|
+
/**
|
|
6022
|
+
* The TablesSchemaAlias type is a duplicate of TablesSchema, used to mask
|
|
6023
|
+
* complex generics from documentation.
|
|
6024
|
+
*
|
|
6025
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
6026
|
+
* expected to need to use it directly.
|
|
6027
|
+
*
|
|
6028
|
+
* @category Internal
|
|
6029
|
+
*/
|
|
6030
|
+
export type TablesSchemaAlias = TablesSchema;
|
|
6031
|
+
|
|
6032
|
+
/**
|
|
6033
|
+
* The ValuesSchemaAlias type is a duplicate of ValuesSchema, used to mask
|
|
6034
|
+
* complex generics from documentation.
|
|
6035
|
+
*
|
|
6036
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
6037
|
+
* expected to need to use it directly.
|
|
6038
|
+
*
|
|
6039
|
+
* @category Internal
|
|
6040
|
+
*/
|
|
6041
|
+
export type ValuesSchemaAlias = ValuesSchema;
|
|
6042
|
+
|
|
6043
|
+
/**
|
|
6044
|
+
* The TableCallbackAlias type is a duplicate of TableCallback, used to mask
|
|
6045
|
+
* complex generics from documentation.
|
|
6046
|
+
*
|
|
6047
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
6048
|
+
* expected to need to use it directly.
|
|
6049
|
+
*
|
|
6050
|
+
* @category Internal
|
|
6051
|
+
*/
|
|
6052
|
+
export type TableCallbackAlias<
|
|
6053
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
6054
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
6055
|
+
> = TableCallback<Schema, TableId>;
|
|
6056
|
+
|
|
6057
|
+
/**
|
|
6058
|
+
* The RowCallbackAlias type is a duplicate of RowCallback, used to mask complex
|
|
6059
|
+
* generics from documentation.
|
|
6060
|
+
*
|
|
6061
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
6062
|
+
* expected to need to use it directly.
|
|
6063
|
+
*
|
|
6064
|
+
* @category Internal
|
|
6065
|
+
*/
|
|
6066
|
+
export type RowCallbackAlias<
|
|
6067
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
6068
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
6069
|
+
> = RowCallback<Schema, TableId>;
|
|
6070
|
+
|
|
6071
|
+
/**
|
|
6072
|
+
* The CellCallbackAlias type is a duplicate of CellCallback, used to mask
|
|
6073
|
+
* complex generics from documentation.
|
|
6074
|
+
*
|
|
6075
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
6076
|
+
* expected to need to use it directly.
|
|
6077
|
+
*
|
|
6078
|
+
* @category Internal
|
|
6079
|
+
*/
|
|
6080
|
+
export type CellCallbackAlias<
|
|
6081
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
6082
|
+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
6083
|
+
CellId extends CellIdFromSchema<Schema, TableId> = CellIdFromSchema<
|
|
6084
|
+
Schema,
|
|
6085
|
+
TableId
|
|
6086
|
+
>,
|
|
6087
|
+
> = CellCallback<Schema, TableId, CellId>;
|
|
6088
|
+
|
|
6089
|
+
/**
|
|
6090
|
+
* The ValueCallbackAlias type is a duplicate of ValueCallback, used to mask
|
|
6091
|
+
* complex generics from documentation.
|
|
6092
|
+
*
|
|
6093
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
6094
|
+
* expected to need to use it directly.
|
|
6095
|
+
*
|
|
6096
|
+
* @category Internal
|
|
6097
|
+
*/
|
|
6098
|
+
export type ValueCallbackAlias<
|
|
6099
|
+
Schema extends OptionalValuesSchema = NoValuesSchema,
|
|
6100
|
+
ValueId extends ValueIdFromSchema<Schema> = ValueIdFromSchema<Schema>,
|
|
6101
|
+
> = ValueCallback<Schema, ValueId>;
|
|
6102
|
+
|
|
6103
|
+
/**
|
|
6104
|
+
* The CellListenerAlias type is a duplicate of CellListener, used to mask
|
|
6105
|
+
* complex generics from documentation.
|
|
6106
|
+
*
|
|
6107
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
6108
|
+
* expected to need to use it directly.
|
|
6109
|
+
*
|
|
6110
|
+
* @category Internal
|
|
6111
|
+
*/
|
|
6112
|
+
export type CellListenerAlias<
|
|
6113
|
+
Schemas extends OptionalSchemas = NoSchemas,
|
|
6114
|
+
TableIdOrNull extends TableIdFromSchema<
|
|
6115
|
+
Schemas[0]
|
|
6116
|
+
> | null = TableIdFromSchema<Schemas[0]> | null,
|
|
6117
|
+
RowIdOrNull extends IdOrNull = IdOrNull,
|
|
6118
|
+
CellIdOrNull extends
|
|
6119
|
+
| (TableIdOrNull extends TableIdFromSchema<Schemas[0]>
|
|
6120
|
+
? CellIdFromSchema<Schemas[0], TableIdOrNull>
|
|
6121
|
+
: AllCellIdFromSchema<Schemas[0]>)
|
|
6122
|
+
| null =
|
|
6123
|
+
| (TableIdOrNull extends TableIdFromSchema<Schemas[0]>
|
|
6124
|
+
? CellIdFromSchema<Schemas[0], TableIdOrNull>
|
|
6125
|
+
: AllCellIdFromSchema<Schemas[0]>)
|
|
6126
|
+
| null,
|
|
6127
|
+
> = CellListener<Schemas, TableIdOrNull, RowIdOrNull, CellIdOrNull>;
|
|
6128
|
+
|
|
6129
|
+
/**
|
|
6130
|
+
* The ValueListenerAlias type is a duplicate of ValueListener, used to mask
|
|
6131
|
+
* complex generics from documentation.
|
|
6132
|
+
*
|
|
6133
|
+
* This type is used internally to the TinyBase type system and you are not
|
|
6134
|
+
* expected to need to use it directly.
|
|
6135
|
+
*
|
|
6136
|
+
* @category Internal
|
|
6137
|
+
*/
|
|
6138
|
+
export type ValueListenerAlias<
|
|
6139
|
+
Schemas extends OptionalSchemas = NoSchemas,
|
|
6140
|
+
ValueIdOrNull extends ValueIdFromSchema<
|
|
6141
|
+
Schemas[1]
|
|
6142
|
+
> | null = ValueIdFromSchema<Schemas[1]> | null,
|
|
6143
|
+
> = ValueListener<Schemas, ValueIdOrNull>;
|