tinybase 3.1.0-beta.4 → 3.1.0

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.
Files changed (85) hide show
  1. package/lib/debug/ui-react.js +2 -2
  2. package/lib/{checkpoints.d.ts → types/checkpoints.d.ts} +13 -13
  3. package/lib/{debug → types}/indexes.d.ts +10 -16
  4. package/lib/{debug → types}/metrics.d.ts +49 -50
  5. package/lib/{debug → types}/persisters.d.ts +26 -30
  6. package/lib/{cjs-es6 → types}/queries.d.ts +474 -309
  7. package/lib/{debug → types}/relationships.d.ts +11 -17
  8. package/lib/{debug → types}/store.d.ts +180 -1038
  9. package/lib/types/tinybase.d.ts +14 -0
  10. package/lib/{debug → types}/tools.d.ts +12 -12
  11. package/lib/{debug → types}/ui-react.d.ts +11 -5
  12. package/lib/{cjs-es6 → types/with-schemas}/checkpoints.d.ts +93 -7
  13. package/lib/{cjs → types/with-schemas}/indexes.d.ts +136 -18
  14. package/lib/types/with-schemas/internal/queries.d.ts +15 -0
  15. package/lib/types/with-schemas/internal/store.d.ts +101 -0
  16. package/lib/types/with-schemas/internal/ui-react.d.ts +776 -0
  17. package/lib/{cjs → types/with-schemas}/metrics.d.ts +115 -50
  18. package/lib/{cjs → types/with-schemas}/persisters.d.ts +102 -4
  19. package/lib/{debug → types/with-schemas}/queries.d.ts +865 -346
  20. package/lib/{cjs → types/with-schemas}/relationships.d.ts +151 -20
  21. package/lib/{cjs-es6 → types/with-schemas}/store.d.ts +1082 -801
  22. package/lib/types/with-schemas/tinybase.d.ts +14 -0
  23. package/lib/{cjs-es6 → types/with-schemas}/tools.d.ts +21 -10
  24. package/lib/{cjs-es6 → types/with-schemas}/ui-react.d.ts +1871 -1314
  25. package/package.json +145 -29
  26. package/readme.md +14 -14
  27. package/lib/cjs/checkpoints.d.ts +0 -961
  28. package/lib/cjs/queries.d.ts +0 -3028
  29. package/lib/cjs/store.d.ts +0 -6143
  30. package/lib/cjs/tinybase.d.ts +0 -14
  31. package/lib/cjs/tools.d.ts +0 -536
  32. package/lib/cjs/ui-react.d.ts +0 -10921
  33. package/lib/cjs-es6/indexes.d.ts +0 -974
  34. package/lib/cjs-es6/metrics.d.ts +0 -829
  35. package/lib/cjs-es6/persisters.d.ts +0 -733
  36. package/lib/cjs-es6/relationships.d.ts +0 -1209
  37. package/lib/cjs-es6/tinybase.d.ts +0 -14
  38. package/lib/common.d.ts +0 -115
  39. package/lib/debug/checkpoints.d.ts +0 -961
  40. package/lib/debug/common.d.ts +0 -115
  41. package/lib/debug/tinybase.d.ts +0 -14
  42. package/lib/es6/checkpoints.d.ts +0 -961
  43. package/lib/es6/common.d.ts +0 -115
  44. package/lib/es6/indexes.d.ts +0 -974
  45. package/lib/es6/metrics.d.ts +0 -829
  46. package/lib/es6/persisters.d.ts +0 -733
  47. package/lib/es6/queries.d.ts +0 -3028
  48. package/lib/es6/relationships.d.ts +0 -1209
  49. package/lib/es6/store.d.ts +0 -6143
  50. package/lib/es6/tinybase.d.ts +0 -14
  51. package/lib/es6/tools.d.ts +0 -536
  52. package/lib/es6/ui-react.d.ts +0 -10921
  53. package/lib/indexes.d.ts +0 -974
  54. package/lib/metrics.d.ts +0 -829
  55. package/lib/persisters.d.ts +0 -733
  56. package/lib/queries.d.ts +0 -3028
  57. package/lib/relationships.d.ts +0 -1209
  58. package/lib/store.d.ts +0 -6143
  59. package/lib/tinybase.d.ts +0 -14
  60. package/lib/tools.d.ts +0 -536
  61. package/lib/ui-react.d.ts +0 -10921
  62. package/lib/umd/checkpoints.d.ts +0 -961
  63. package/lib/umd/common.d.ts +0 -115
  64. package/lib/umd/indexes.d.ts +0 -974
  65. package/lib/umd/metrics.d.ts +0 -829
  66. package/lib/umd/persisters.d.ts +0 -733
  67. package/lib/umd/queries.d.ts +0 -3028
  68. package/lib/umd/relationships.d.ts +0 -1209
  69. package/lib/umd/store.d.ts +0 -6143
  70. package/lib/umd/tinybase.d.ts +0 -14
  71. package/lib/umd/tools.d.ts +0 -536
  72. package/lib/umd/ui-react.d.ts +0 -10921
  73. package/lib/umd-es6/checkpoints.d.ts +0 -961
  74. package/lib/umd-es6/common.d.ts +0 -115
  75. package/lib/umd-es6/indexes.d.ts +0 -974
  76. package/lib/umd-es6/metrics.d.ts +0 -829
  77. package/lib/umd-es6/persisters.d.ts +0 -733
  78. package/lib/umd-es6/queries.d.ts +0 -3028
  79. package/lib/umd-es6/relationships.d.ts +0 -1209
  80. package/lib/umd-es6/store.d.ts +0 -6143
  81. package/lib/umd-es6/tinybase.d.ts +0 -14
  82. package/lib/umd-es6/tools.d.ts +0 -536
  83. package/lib/umd-es6/ui-react.d.ts +0 -10921
  84. /package/lib/{cjs-es6 → types}/common.d.ts +0 -0
  85. /package/lib/{cjs → types/with-schemas}/common.d.ts +0 -0
@@ -11,6 +11,17 @@
11
11
  * @module store
12
12
  */
13
13
 
14
+ import {
15
+ AllCellIdFromSchema,
16
+ CellIdFromSchema,
17
+ DefaultCellIdFromSchema,
18
+ DefaultValueIdFromSchema,
19
+ DefaultedCellFromSchema,
20
+ DefaultedValueFromSchema,
21
+ TableIdFromSchema,
22
+ Truncate,
23
+ ValueIdFromSchema,
24
+ } from './internal/store';
14
25
  import {Id, IdOrNull, Ids, Json} from './common.d';
15
26
 
16
27
  /**
@@ -26,7 +37,7 @@ import {Id, IdOrNull, Ids, Json} from './common.d';
26
37
  * `pets`, in which each Row may contain a string `species` Cell, and is
27
38
  * guaranteed to contain a boolean `sold` Cell that defaults to `false`.
28
39
  *
29
- *```js
40
+ * ```js
30
41
  * const tableSchema: TablesSchema = {
31
42
  * pets: {
32
43
  * species: {type: 'string'},
@@ -57,7 +68,7 @@ export type TablesSchema = {[tableId: Id]: {[cellId: Id]: CellSchema}};
57
68
  * When applied to a Store, this CellSchema ensures a boolean Cell is always
58
69
  * present, and defaults it to `false`.
59
70
  *
60
- *```js
71
+ * ```js
61
72
  * const requiredBoolean: CellSchema = {type: 'boolean', default: false};
62
73
  * ```
63
74
  * @category Schema
@@ -78,7 +89,7 @@ export type CellSchema =
78
89
  * When applied to a Store, this ValuesSchema only allows one boolean Value
79
90
  * called `open`, that defaults to `false`.
80
91
  *
81
- *```js
92
+ * ```js
82
93
  * const valuesSchema: ValuesSchema = {
83
94
  * open: {type: 'boolean', default: false},
84
95
  * };
@@ -107,7 +118,7 @@ export type ValuesSchema = {[valueId: Id]: ValueSchema};
107
118
  * When applied to a Store, this ValueSchema ensures a boolean Value is always
108
119
  * present, and defaults it to `false`.
109
120
  *
110
- *```js
121
+ * ```js
111
122
  * const requiredBoolean: ValueSchema = {type: 'boolean', default: false};
112
123
  * ```
113
124
  * @category Schema
@@ -122,10 +133,7 @@ export type ValueSchema =
122
133
  * The NoTablesSchema type is a TablesSchema-like type for when one has not been
123
134
  * provided.
124
135
  *
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
136
+ * @category Schema
129
137
  */
130
138
  export type NoTablesSchema = {[tableId: Id]: {[cellId: Id]: {type: 'any'}}};
131
139
 
@@ -133,10 +141,7 @@ export type NoTablesSchema = {[tableId: Id]: {[cellId: Id]: {type: 'any'}}};
133
141
  * The NoValuesSchema type is a ValuesSchema-like type for when one has not been
134
142
  * provided.
135
143
  *
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
144
+ * @category Schema
140
145
  */
141
146
  export type NoValuesSchema = {[valueId: Id]: {type: 'any'}};
142
147
 
@@ -176,8 +181,10 @@ export type NoSchemas = [NoTablesSchema, NoValuesSchema];
176
181
  * The Tables type is the data structure representing all of the data in a
177
182
  * Store.
178
183
  *
184
+ * This has schema-based typing. The following is a simplified representation:
185
+ *
179
186
  * ```ts override
180
- * {[tableId: Id]: Table}
187
+ * {[tableId: Id]: Table};
181
188
  * ```
182
189
  *
183
190
  * A Tables object is used when setting all of the tables together with the
@@ -201,15 +208,23 @@ export type NoSchemas = [NoTablesSchema, NoValuesSchema];
201
208
  * @category Store
202
209
  */
203
210
  export type Tables<
204
- Schema extends OptionalTablesSchema = NoTablesSchema,
211
+ Schema extends OptionalTablesSchema,
205
212
  WhenSet extends boolean = false,
206
- > = TablesFromSchema<Schema, WhenSet>;
213
+ > = {
214
+ -readonly [TableId in TableIdFromSchema<Schema>]?: Table<
215
+ Schema,
216
+ TableId,
217
+ WhenSet
218
+ >;
219
+ };
207
220
 
208
221
  /**
209
222
  * The Table type is the data structure representing the data in a single table.
210
223
  *
224
+ * This has schema-based typing. The following is a simplified representation:
225
+ *
211
226
  * ```ts override
212
- * {[rowId: Id]: Row}
227
+ * {[rowId: Id]: Row};
213
228
  * ```
214
229
  *
215
230
  * A Table is used when setting a table with the setTable method, and when
@@ -227,16 +242,18 @@ export type Tables<
227
242
  * @category Store
228
243
  */
229
244
  export type Table<
230
- Schema extends OptionalTablesSchema = NoTablesSchema,
231
- TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
245
+ Schema extends OptionalTablesSchema,
246
+ TableId extends TableIdFromSchema<Schema>,
232
247
  WhenSet extends boolean = false,
233
- > = TableFromSchema<Schema, TableId, WhenSet>;
248
+ > = {[rowId: Id]: Row<Schema, TableId, WhenSet>};
234
249
 
235
250
  /**
236
251
  * The Row type is the data structure representing the data in a single row.
237
252
  *
253
+ * This has schema-based typing. The following is a simplified representation:
254
+ *
238
255
  * ```ts override
239
- * {[cellId: Id]: Cell}
256
+ * {[cellId: Id]: Cell};
240
257
  * ```
241
258
  *
242
259
  * A Row is used when setting a row with the setRow method, and when getting it
@@ -250,16 +267,38 @@ export type Table<
250
267
  * @category Store
251
268
  */
252
269
  export type Row<
253
- Schema extends OptionalTablesSchema = NoTablesSchema,
254
- TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
270
+ Schema extends OptionalTablesSchema,
271
+ TableId extends TableIdFromSchema<Schema>,
255
272
  WhenSet extends boolean = false,
256
- > = RowFromSchema<Schema, TableId, WhenSet>;
273
+ > = (WhenSet extends true
274
+ ? {
275
+ -readonly [CellId in DefaultCellIdFromSchema<Schema, TableId>]?: Cell<
276
+ Schema,
277
+ TableId,
278
+ CellId
279
+ >;
280
+ }
281
+ : {
282
+ -readonly [CellId in DefaultCellIdFromSchema<Schema, TableId>]: Cell<
283
+ Schema,
284
+ TableId,
285
+ CellId
286
+ >;
287
+ }) & {
288
+ -readonly [CellId in DefaultCellIdFromSchema<Schema, TableId, false>]?: Cell<
289
+ Schema,
290
+ TableId,
291
+ CellId
292
+ >;
293
+ };
257
294
 
258
295
  /**
259
296
  * The Cell type is the data structure representing the data in a single cell.
260
297
  *
298
+ * This has schema-based typing. The following is a simplified representation:
299
+ *
261
300
  * ```ts override
262
- * string | number | boolean
301
+ * string | number | boolean;
263
302
  * ```
264
303
  *
265
304
  * A Cell is used when setting a cell with the setCell method, and when getting
@@ -273,18 +312,28 @@ export type Row<
273
312
  * @category Store
274
313
  */
275
314
  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>;
315
+ Schema extends OptionalTablesSchema,
316
+ TableId extends TableIdFromSchema<Schema>,
317
+ CellId extends CellIdFromSchema<Schema, TableId>,
318
+ CellType = Schema[TableId][CellId]['type'],
319
+ > = CellType extends 'string'
320
+ ? string
321
+ : CellType extends 'number'
322
+ ? number
323
+ : CellType extends 'boolean'
324
+ ? boolean
325
+ : string | number | boolean;
283
326
 
284
327
  /**
285
328
  * The CellOrUndefined type is a data structure representing the data in a
286
329
  * single cell, or the value `undefined`.
287
330
  *
331
+ * This has schema-based typing. The following is a simplified representation:
332
+ *
333
+ * ```ts override
334
+ * Cell | undefined;
335
+ * ```
336
+ *
288
337
  * This is used when describing a Cell that is present _or_ that is not present,
289
338
  * such as when it has been deleted, or when describing a previous state where
290
339
  * the Cell value has since been added.
@@ -292,21 +341,19 @@ export type Cell<
292
341
  * @category Store
293
342
  */
294
343
  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;
344
+ Schema extends OptionalTablesSchema,
345
+ TableId extends TableIdFromSchema<Schema>,
346
+ CellId extends CellIdFromSchema<Schema, TableId>,
347
+ > = Cell<Schema, TableId, CellId> | undefined;
303
348
 
304
349
  /**
305
350
  * The Values type is the data structure representing all the keyed values in a
306
351
  * Store.
307
352
  *
353
+ * This has schema-based typing. The following is a simplified representation:
354
+ *
308
355
  * ```ts override
309
- * {[valueId: Id]: Value}
356
+ * {[valueId: Id]: Value};
310
357
  * ```
311
358
  *
312
359
  * A Values object is used when setting values with the setValues method, and
@@ -322,16 +369,35 @@ export type CellOrUndefined<
322
369
  * @since v3.0.0
323
370
  */
324
371
  export type Values<
325
- Schema extends OptionalValuesSchema = NoValuesSchema,
372
+ Schema extends OptionalValuesSchema,
326
373
  WhenSet extends boolean = false,
327
- > = ValuesFromSchema<Schema, WhenSet>;
374
+ > = (WhenSet extends true
375
+ ? {
376
+ -readonly [ValueId in DefaultValueIdFromSchema<Schema>]?: Value<
377
+ Schema,
378
+ ValueId
379
+ >;
380
+ }
381
+ : {
382
+ -readonly [ValueId in DefaultValueIdFromSchema<Schema>]: Value<
383
+ Schema,
384
+ ValueId
385
+ >;
386
+ }) & {
387
+ -readonly [ValueId in DefaultValueIdFromSchema<Schema, false>]?: Value<
388
+ Schema,
389
+ ValueId
390
+ >;
391
+ };
328
392
 
329
393
  /**
330
394
  * The Value type is the data structure representing the data in a single keyed
331
395
  * value.
332
396
  *
397
+ * This has schema-based typing. The following is a simplified representation:
398
+ *
333
399
  * ```ts override
334
- * string | number | boolean
400
+ * string | number | boolean;
335
401
  * ```
336
402
  *
337
403
  * A Value is used when setting a value with the setValue method, and when
@@ -346,14 +412,27 @@ export type Values<
346
412
  * @since v3.0.0
347
413
  */
348
414
  export type Value<
349
- Schema extends OptionalValuesSchema = NoValuesSchema,
350
- ValueId extends ValueIdFromSchema<Schema> = ValueIdFromSchema<Schema>,
351
- > = ValueFromSchema<Schema, ValueId>;
415
+ Schema extends OptionalValuesSchema,
416
+ ValueId extends ValueIdFromSchema<Schema>,
417
+ ValueType = Schema[ValueId]['type'],
418
+ > = ValueType extends 'string'
419
+ ? string
420
+ : ValueType extends 'number'
421
+ ? number
422
+ : ValueType extends 'boolean'
423
+ ? boolean
424
+ : string | number | boolean;
352
425
 
353
426
  /**
354
427
  * The ValueOrUndefined type is a data structure representing the data in a
355
428
  * single value, or the value `undefined`.
356
429
  *
430
+ * This has schema-based typing. The following is a simplified representation:
431
+ *
432
+ * ```ts override
433
+ * Value | undefined;
434
+ * ```
435
+ *
357
436
  * This is used when describing a Value that is present _or_ that is not
358
437
  * present, such as when it has been deleted, or when describing a previous
359
438
  * state where the Value has since been added.
@@ -362,15 +441,23 @@ export type Value<
362
441
  * @since v3.0.0
363
442
  */
364
443
  export type ValueOrUndefined<
365
- Schema extends OptionalValuesSchema = NoValuesSchema,
366
- ValueId extends ValueIdFromSchema<Schema> = ValueIdFromSchema<Schema>,
367
- Value = ValueFromSchema<Schema, ValueId>,
368
- > = Value | undefined;
444
+ Schema extends OptionalValuesSchema,
445
+ ValueId extends ValueIdFromSchema<Schema>,
446
+ > = Value<Schema, ValueId> | undefined;
369
447
 
370
448
  /**
371
449
  * The TableCallback type describes a function that takes a Table's Id and a
372
450
  * callback to loop over each Row within it.
373
451
  *
452
+ * This has schema-based typing. The following is a simplified representation:
453
+ *
454
+ * ```ts override
455
+ * (
456
+ * tableId: Id,
457
+ * forEachRow: (rowCallback: RowCallback) => void,
458
+ * ) => void;
459
+ * ```
460
+ *
374
461
  * A TableCallback is provided when using the forEachTable method, so that you
375
462
  * can do something based on every Table in the Store. See that method for
376
463
  * specific examples.
@@ -381,17 +468,32 @@ export type ValueOrUndefined<
381
468
  * @category Callback
382
469
  */
383
470
  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,
389
- ) => void;
471
+ Schema extends OptionalTablesSchema,
472
+ Params extends any[] = TableIdFromSchema<Schema> extends infer TableId
473
+ ? TableId extends TableIdFromSchema<Schema>
474
+ ? [
475
+ tableId: TableId,
476
+ forEachRow: (rowCallback: RowCallback<Schema, TableId>) => void,
477
+ ]
478
+ : never
479
+ : never,
480
+ Params2 extends any[] = Params | [tableId: never, forEachRow: never],
481
+ Params1 extends any[] = Truncate<Params2>,
482
+ > = ((...params: Params2) => void) | ((...params: Params1) => void);
390
483
 
391
484
  /**
392
485
  * The RowCallback type describes a function that takes a Row's Id and a
393
486
  * callback to loop over each Cell within it.
394
487
  *
488
+ * This has schema-based typing. The following is a simplified representation:
489
+ *
490
+ * ```ts override
491
+ * (
492
+ * rowId: Id,
493
+ * forEachCell: (cellCallback: CellCallback) => void,
494
+ * ) => void;
495
+ * ```
496
+ *
395
497
  * A RowCallback is provided when using the forEachRow method, so that you can
396
498
  * do something based on every Row in a Table. See that method for specific
397
499
  * examples.
@@ -402,17 +504,27 @@ export type TableCallback<
402
504
  * @category Callback
403
505
  */
404
506
  export type RowCallback<
405
- Schema extends OptionalTablesSchema = NoTablesSchema,
406
- TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
407
- > = (
408
- rowId: Id,
409
- forEachCell: (cellCallback: CellCallback<Schema, TableId>) => void,
410
- ) => void;
507
+ Schema extends OptionalTablesSchema,
508
+ TableIdOrNull extends TableIdFromSchema<Schema> | null = null,
509
+ Params extends any[] = [
510
+ rowId: Id,
511
+ forEachCell: (cellCallback: CellCallback<Schema, TableIdOrNull>) => void,
512
+ ],
513
+ Params2 extends any[] = Params | [rowId: never, forEachCell: never],
514
+ // Params1 extends any[] = Truncate<Params2>,
515
+ > = Params extends any[] ? (...params: Params2) => void : never;
516
+ // | ((...params: Params1) => void)
411
517
 
412
518
  /**
413
519
  * The CellCallback type describes a function that takes a Cell's Id and its
414
520
  * value.
415
521
  *
522
+ * This has schema-based typing. The following is a simplified representation:
523
+ *
524
+ * ```ts override
525
+ * (cellId: Id, cell: Cell) => void;
526
+ * ```
527
+ *
416
528
  * A CellCallback is provided when using the forEachCell method, so that you can
417
529
  * do something based on every Cell in a Row. See that method for specific
418
530
  * examples.
@@ -422,18 +534,35 @@ export type RowCallback<
422
534
  * @category Callback
423
535
  */
424
536
  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;
537
+ Schema extends OptionalTablesSchema,
538
+ TableIdOrNull extends TableIdFromSchema<Schema> | null = null,
539
+ Params extends any[] = (
540
+ TableIdOrNull extends null ? TableIdFromSchema<Schema> : TableIdOrNull
541
+ ) extends infer TableId
542
+ ? TableId extends TableIdFromSchema<Schema>
543
+ ? CellIdFromSchema<Schema, TableId> extends infer CellId
544
+ ? CellId extends CellIdFromSchema<Schema, TableId>
545
+ ? [cellId: CellId, cell: Cell<Schema, TableId, CellId>]
546
+ : never
547
+ : never
548
+ : never
549
+ : never,
550
+ Params2 extends any[] = Params | [cellId: never, cell: never],
551
+ Params1 extends any[] = Truncate<Params2>,
552
+ > = Params extends any[]
553
+ ? ((...params: Params2) => void) | ((...params: Params1) => void)
554
+ : never;
432
555
 
433
556
  /**
434
557
  * The ValueCallback type describes a function that takes a Value's Id and its
435
558
  * actual value.
436
559
  *
560
+ * This has schema-based typing. The following is a simplified representation:
561
+ *
562
+ * ```ts override
563
+ * (valueId: Id, value: Value) => void;
564
+ * ```
565
+ *
437
566
  * A ValueCallback is provided when using the forEachValue method, so that you
438
567
  * can do something based on every Value in a Store. See that method for
439
568
  * specific examples.
@@ -444,14 +573,30 @@ export type CellCallback<
444
573
  * @since v3.0.0
445
574
  */
446
575
  export type ValueCallback<
447
- Schema extends OptionalValuesSchema = NoValuesSchema,
448
- ValueId extends ValueIdFromSchema<Schema> = ValueIdFromSchema<Schema>,
449
- > = (valueId: ValueId, value: Value<Schema, ValueId>) => void;
576
+ Schema extends OptionalValuesSchema,
577
+ Params extends any[] = ValueIdFromSchema<Schema> extends infer ValueId
578
+ ? ValueId extends ValueIdFromSchema<Schema>
579
+ ?
580
+ | [valueId: ValueId, value: Value<Schema, ValueId>]
581
+ | [valueId: never, value: never]
582
+ : never
583
+ : never,
584
+ Params2 extends any[] = Params | [valueId: never, value: never],
585
+ Params1 extends any[] = Truncate<Params2>,
586
+ > = Params extends any[]
587
+ ? ((...params: Params2) => void) | ((...params: Params1) => void)
588
+ : never;
450
589
 
451
590
  /**
452
591
  * The MapCell type describes a function that takes an existing Cell value and
453
592
  * returns another.
454
593
  *
594
+ * This has schema-based typing. The following is a simplified representation:
595
+ *
596
+ * ```ts override
597
+ * (cell: CellOrUndefined) => Cell;
598
+ * ```
599
+ *
455
600
  * A MapCell can be provided in the setCell method to map an existing value to a
456
601
  * new one, such as when incrementing a number. See that method for specific
457
602
  * examples.
@@ -460,12 +605,9 @@ export type ValueCallback<
460
605
  * @category Callback
461
606
  */
462
607
  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
- >,
608
+ Schema extends OptionalTablesSchema,
609
+ TableId extends TableIdFromSchema<Schema>,
610
+ CellId extends CellIdFromSchema<Schema, TableId>,
469
611
  > = (
470
612
  cell: CellOrUndefined<Schema, TableId, CellId>,
471
613
  ) => Cell<Schema, TableId, CellId>;
@@ -474,6 +616,12 @@ export type MapCell<
474
616
  * The MapValue type describes a function that takes an existing Value and
475
617
  * returns another.
476
618
  *
619
+ * This has schema-based typing. The following is a simplified representation:
620
+ *
621
+ * ```ts override
622
+ * (value: ValueOrUndefined) => Value;
623
+ * ```
624
+ *
477
625
  * A MapValue can be provided in the setValue method to map an existing Value to
478
626
  * a new one, such as when incrementing a number. See that method for specific
479
627
  * examples.
@@ -483,7 +631,7 @@ export type MapCell<
483
631
  * @since v3.0.0
484
632
  */
485
633
  export type MapValue<
486
- Schema extends OptionalValuesSchema = NoValuesSchema,
634
+ Schema extends OptionalValuesSchema,
487
635
  ValueId extends ValueIdFromSchema<Schema> = ValueIdFromSchema<Schema>,
488
636
  > = (value: ValueOrUndefined<Schema, ValueId>) => Value<Schema, ValueId>;
489
637
 
@@ -491,6 +639,12 @@ export type MapValue<
491
639
  * The GetCell type describes a function that takes a Id and returns the Cell
492
640
  * value for a particular Row.
493
641
  *
642
+ * This has schema-based typing. The following is a simplified representation:
643
+ *
644
+ * ```ts override
645
+ * (cellId: Id) => CellOrUndefined;
646
+ * ```
647
+ *
494
648
  * A GetCell can be provided when setting definitions, as in the
495
649
  * setMetricDefinition method of a Metrics object, or the setIndexDefinition
496
650
  * method of an Indexes object. See those methods for specific examples.
@@ -499,18 +653,27 @@ export type MapValue<
499
653
  * @category Callback
500
654
  */
501
655
  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>;
656
+ Schema extends OptionalTablesSchema,
657
+ TableId extends TableIdFromSchema<Schema>,
658
+ > = <CellId extends CellIdFromSchema<Schema, TableId>>(
659
+ cellId: CellId,
660
+ ) => DefaultedCellFromSchema<Schema, TableId, CellId>;
509
661
 
510
662
  /**
511
663
  * The DoRollback type describes a function that you can use to rollback the
512
664
  * transaction if it did not complete to your satisfaction.
513
665
  *
666
+ * This has schema-based typing. The following is a simplified representation:
667
+ *
668
+ * ```ts override
669
+ * (
670
+ * changedCells: ChangedCells,
671
+ * invalidCells: InvalidCells,
672
+ * changedValues: ChangedValues,
673
+ * invalidValues: InvalidValues,
674
+ * ) => boolean;
675
+ * ```
676
+ *
514
677
  * A DoRollback can be provided when calling the transaction method or the
515
678
  * finishTransaction method. See those methods for specific examples.
516
679
  *
@@ -526,14 +689,10 @@ export type GetCell<
526
689
  * @param invalidValues Any invalid attempts to change Values, since v3.0.0.
527
690
  * @category Callback
528
691
  */
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>,
692
+ export type DoRollback<Schemas extends OptionalSchemas> = (
693
+ changedCells: ChangedCells<Schemas[0]>,
535
694
  invalidCells: InvalidCells,
536
- changedValues: ChangedValues<ValuesSchema>,
695
+ changedValues: ChangedValues<Schemas[1]>,
537
696
  invalidValues: InvalidValues,
538
697
  ) => boolean;
539
698
 
@@ -541,6 +700,16 @@ export type DoRollback<
541
700
  * The TransactionListener type describes a function that is used to listen to
542
701
  * the completion of a transaction for the Store.
543
702
  *
703
+ * This has schema-based typing. The following is a simplified representation:
704
+ *
705
+ * ```ts override
706
+ * (
707
+ * store: Store,
708
+ * cellsTouched: boolean,
709
+ * valuesTouched: boolean,
710
+ * ) => void;
711
+ * ```
712
+ *
544
713
  * A TransactionListener is provided when using the
545
714
  * addWillFinishTransactionListener and addDidFinishTransactionListener methods.
546
715
  * See those methods for specific examples.
@@ -563,7 +732,7 @@ export type DoRollback<
563
732
  * since v3.0.0.
564
733
  * @category Listener
565
734
  */
566
- export type TransactionListener<Schemas extends OptionalSchemas = NoSchemas> = (
735
+ export type TransactionListener<Schemas extends OptionalSchemas> = (
567
736
  store: Store<Schemas>,
568
737
  cellsTouched: boolean,
569
738
  valuesTouched: boolean,
@@ -573,6 +742,15 @@ export type TransactionListener<Schemas extends OptionalSchemas = NoSchemas> = (
573
742
  * The TablesListener type describes a function that is used to listen to
574
743
  * changes to the whole Store.
575
744
  *
745
+ * This has schema-based typing. The following is a simplified representation:
746
+ *
747
+ * ```ts override
748
+ * (
749
+ * store: Store,
750
+ * getCellChange: GetCellChange | undefined,
751
+ * ) => void;
752
+ * ```
753
+ *
576
754
  * A TablesListener is provided when using the addTablesListener method. See
577
755
  * that method for specific examples.
578
756
  *
@@ -589,18 +767,21 @@ export type TransactionListener<Schemas extends OptionalSchemas = NoSchemas> = (
589
767
  * changes.
590
768
  * @category Listener
591
769
  */
592
- export type TablesListener<
593
- Schemas extends OptionalSchemas = NoSchemas,
594
- TablesSchema extends OptionalTablesSchema = Schemas[0],
595
- > = (
770
+ export type TablesListener<Schemas extends OptionalSchemas> = (
596
771
  store: Store<Schemas>,
597
- getCellChange: GetCellChange<TablesSchema> | undefined,
772
+ getCellChange: GetCellChange<Schemas[0]> | undefined,
598
773
  ) => void;
599
774
 
600
775
  /**
601
776
  * The TableIdsListener type describes a function that is used to listen to
602
777
  * changes to the Table Ids in the Store.
603
778
  *
779
+ * This has schema-based typing. The following is a simplified representation:
780
+ *
781
+ * ```ts override
782
+ * (store: Store) => void;
783
+ * ```
784
+ *
604
785
  * A TableIdsListener is provided when using the addTableIdsListener method. See
605
786
  * that method for specific examples.
606
787
  *
@@ -609,7 +790,7 @@ export type TablesListener<
609
790
  * @param store A reference to the Store that changed.
610
791
  * @category Listener
611
792
  */
612
- export type TableIdsListener<Schemas extends OptionalSchemas = NoSchemas> = (
793
+ export type TableIdsListener<Schemas extends OptionalSchemas> = (
613
794
  store: Store<Schemas>,
614
795
  ) => void;
615
796
 
@@ -617,6 +798,16 @@ export type TableIdsListener<Schemas extends OptionalSchemas = NoSchemas> = (
617
798
  * The TableListener type describes a function that is used to listen to changes
618
799
  * to a Table.
619
800
  *
801
+ * This has schema-based typing. The following is a simplified representation:
802
+ *
803
+ * ```ts override
804
+ * (
805
+ * store: Store,
806
+ * tableId: Id,
807
+ * getCellChange: GetCellChange | undefined,
808
+ * ) => void;
809
+ * ```
810
+ *
620
811
  * A TableListener is provided when using the addTableListener method. See that
621
812
  * method for specific examples.
622
813
  *
@@ -635,24 +826,26 @@ export type TableIdsListener<Schemas extends OptionalSchemas = NoSchemas> = (
635
826
  * @category Listener
636
827
  */
637
828
  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],
829
+ Schemas extends OptionalSchemas,
830
+ TableIdOrNull extends TableIdFromSchema<Schemas[0]> | null,
646
831
  > = (
647
832
  store: Store<Schemas>,
648
- tableId: TableId,
649
- getCellChange: GetCellChange<TablesSchema> | undefined,
833
+ tableId: TableIdOrNull extends null
834
+ ? TableIdFromSchema<Schemas[0]>
835
+ : TableIdOrNull,
836
+ getCellChange: GetCellChange<Schemas[0]> | undefined,
650
837
  ) => void;
651
838
 
652
839
  /**
653
840
  * The RowIdsListener type describes a function that is used to listen to
654
841
  * changes to the Row Ids in a Table.
655
842
  *
843
+ * This has schema-based typing. The following is a simplified representation:
844
+ *
845
+ * ```ts override
846
+ * (store: Store, tableId: Id) => void;
847
+ * ```
848
+ *
656
849
  * A RowIdsListener is provided when using the addRowIdsListener method. See
657
850
  * that method for specific examples.
658
851
  *
@@ -664,19 +857,33 @@ export type TableListener<
664
857
  * @category Listener
665
858
  */
666
859
  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
860
+ Schemas extends OptionalSchemas,
861
+ TableIdOrNull extends TableIdFromSchema<Schemas[0]> | null,
862
+ > = (
863
+ store: Store<Schemas>,
864
+ tableId: TableIdOrNull extends null
672
865
  ? TableIdFromSchema<Schemas[0]>
673
866
  : TableIdOrNull,
674
- > = (store: Store<Schemas>, tableId: TableId) => void;
867
+ ) => void;
675
868
 
676
869
  /**
677
870
  * The SortedRowIdsListener type describes a function that is used to listen to
678
871
  * changes to sorted Row Ids in a Table.
679
872
  *
873
+ * This has schema-based typing. The following is a simplified representation:
874
+ *
875
+ * ```ts override
876
+ * (
877
+ * store: Store,
878
+ * tableId: Id,
879
+ * cellId: Id | undefined,
880
+ * descending: boolean,
881
+ * offset: number,
882
+ * limit: number | undefined,
883
+ * sortedRowIds: Ids,
884
+ * ) => void;
885
+ * ```
886
+ *
680
887
  * A SortedRowIdsListener is provided when using the addSortedRowIdsListener
681
888
  * method. See that method for specific examples.
682
889
  *
@@ -698,14 +905,12 @@ export type RowIdsListener<
698
905
  * @since v2.0.0
699
906
  */
700
907
  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,
908
+ Schemas extends OptionalSchemas,
909
+ TableId extends TableIdFromSchema<Schemas[0]>,
910
+ CellId extends CellIdFromSchema<Schemas[0], TableId> | undefined,
911
+ Descending extends boolean,
912
+ Offset extends number,
913
+ Limit extends number | undefined,
709
914
  > = (
710
915
  store: Store<Schemas>,
711
916
  tableId: TableId,
@@ -720,6 +925,17 @@ export type SortedRowIdsListener<
720
925
  * The RowListener type describes a function that is used to listen to changes
721
926
  * to a Row.
722
927
  *
928
+ * This has schema-based typing. The following is a simplified representation:
929
+ *
930
+ * ```ts override
931
+ * (
932
+ * store: Store,
933
+ * tableId: Id,
934
+ * rowId: Id,
935
+ * getCellChange: GetCellChange | undefined,
936
+ * ) => void;
937
+ * ```
938
+ *
723
939
  * A RowListener is provided when using the addRowListener method. See that
724
940
  * method for specific examples.
725
941
  *
@@ -740,27 +956,28 @@ export type SortedRowIdsListener<
740
956
  * @category Listener
741
957
  */
742
958
  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],
959
+ Schemas extends OptionalSchemas,
960
+ TableIdOrNull extends TableIdFromSchema<Schemas[0]> | null,
961
+ RowIdOrNull extends IdOrNull,
753
962
  > = (
754
963
  store: Store<Schemas>,
755
- tableId: TableId,
756
- rowId: RowId,
757
- getCellChange: GetCellChange<TablesSchema> | undefined,
964
+ tableId: TableIdOrNull extends null
965
+ ? TableIdFromSchema<Schemas[0]>
966
+ : TableIdOrNull,
967
+ rowId: RowIdOrNull extends null ? Id : RowIdOrNull,
968
+ getCellChange: GetCellChange<Schemas[0]> | undefined,
758
969
  ) => void;
759
970
 
760
971
  /**
761
972
  * The CellIdsListener type describes a function that is used to listen to
762
973
  * changes to the Cell Ids in a Row.
763
974
  *
975
+ * This has schema-based typing. The following is a simplified representation:
976
+ *
977
+ * ```ts override
978
+ * (store: Store, tableId: Id, rowId: Id) => void;
979
+ * ```
980
+ *
764
981
  * A CellIdsListener is provided when using the addCellIdsListener method. See
765
982
  * that method for specific examples.
766
983
  *
@@ -773,21 +990,35 @@ export type RowListener<
773
990
  * @category Listener
774
991
  */
775
992
  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
993
+ Schemas extends OptionalSchemas,
994
+ TableIdOrNull extends TableIdFromSchema<Schemas[0]> | null,
995
+ RowIdOrNull extends IdOrNull,
996
+ > = (
997
+ store: Store<Schemas>,
998
+ tableId: TableIdOrNull extends null
782
999
  ? TableIdFromSchema<Schemas[0]>
783
1000
  : TableIdOrNull,
784
- RowId = RowIdOrNull extends null ? Id : RowIdOrNull,
785
- > = (store: Store<Schemas>, tableId: TableId, rowId: RowId) => void;
1001
+ rowId: RowIdOrNull extends null ? Id : RowIdOrNull,
1002
+ ) => void;
786
1003
 
787
1004
  /**
788
1005
  * The CellListener type describes a function that is used to listen to changes
789
1006
  * to a Cell.
790
1007
  *
1008
+ * This has schema-based typing. The following is a simplified representation:
1009
+ *
1010
+ * ```ts override
1011
+ * (
1012
+ * store: Store,
1013
+ * tableId: Id,
1014
+ * rowId: Id,
1015
+ * cellId: Id,
1016
+ * newCell: Cell,
1017
+ * oldCell: Cell,
1018
+ * getCellChange: GetCellChange | undefined,
1019
+ * ) => void;
1020
+ * ```
1021
+ *
791
1022
  * A CellListener is provided when using the addCellListener method. See that
792
1023
  * method for specific examples.
793
1024
  *
@@ -813,45 +1044,80 @@ export type CellIdsListener<
813
1044
  * @category Listener
814
1045
  */
815
1046
  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,
1047
+ Schemas extends OptionalSchemas,
1048
+ TableIdOrNull extends TableIdFromSchema<Schemas[0]> | null,
1049
+ RowIdOrNull extends IdOrNull,
821
1050
  CellIdOrNull extends
822
- | (TableIdOrNull extends TableIdFromSchema<Schemas[0]>
823
- ? CellIdFromSchema<Schemas[0], TableIdOrNull>
824
- : AllCellIdFromSchema<Schemas[0]>)
825
- | null =
826
1051
  | (TableIdOrNull extends TableIdFromSchema<Schemas[0]>
827
1052
  ? CellIdFromSchema<Schemas[0], TableIdOrNull>
828
1053
  : AllCellIdFromSchema<Schemas[0]>)
829
1054
  | 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,
846
- newCell: Cell,
847
- oldCell: Cell,
848
- getCellChange: GetCellChange<TablesSchema> | undefined,
849
- ) => void;
1055
+ Params extends any[] = (
1056
+ TableIdOrNull extends null ? TableIdFromSchema<Schemas[0]> : TableIdOrNull
1057
+ ) extends infer TableId
1058
+ ? TableId extends TableIdFromSchema<Schemas[0]>
1059
+ ? (
1060
+ CellIdOrNull extends null
1061
+ ? CellIdFromSchema<Schemas[0], TableId>
1062
+ : CellIdOrNull
1063
+ ) extends infer CellId
1064
+ ? CellId extends CellIdFromSchema<Schemas[0], TableId>
1065
+ ? [
1066
+ store: Store<Schemas>,
1067
+ tableId: TableId,
1068
+ rowId: RowIdOrNull extends null ? Id : RowIdOrNull,
1069
+ cellId: CellId,
1070
+ newCell: Cell<Schemas[0], TableId, CellId>,
1071
+ oldCell: Cell<Schemas[0], TableId, CellId>,
1072
+ getCellChange: GetCellChange<Schemas[0]> | undefined,
1073
+ ]
1074
+ : never
1075
+ : never
1076
+ : never
1077
+ : never,
1078
+ Params7 extends any[] =
1079
+ | Params
1080
+ | [
1081
+ store: never,
1082
+ tableId: never,
1083
+ rowId: never,
1084
+ cellId: never,
1085
+ newCell: never,
1086
+ oldCell: never,
1087
+ getCellChange: never,
1088
+ ],
1089
+ Params6 extends any[] = Truncate<Params7>,
1090
+ Params5 extends any[] = Truncate<Params6>,
1091
+ Params4 extends any[] = Truncate<Params5>,
1092
+ // Params3 extends any[] = Truncate<Params4>,
1093
+ // Params2 extends any[] = Truncate<Params3>,
1094
+ // Params1 extends any[] = Truncate<Params2>,
1095
+ > = Params extends any
1096
+ ?
1097
+ | ((...params: Params7) => void)
1098
+ | ((...params: Params6) => void)
1099
+ | ((...params: Params5) => void)
1100
+ | ((...params: Params4) => void)
1101
+ : // The unions may no longer be discriminatory with fewer parameters, and
1102
+ // TypeScript fails to resolve callback signatures in some cases.
1103
+ // | ((...params: Params3) => void)
1104
+ // | ((...params: Params2) => void)
1105
+ // | ((...params: Params1) => void)
1106
+ never;
850
1107
 
851
1108
  /**
852
1109
  * The ValuesListener type describes a function that is used to listen to
853
1110
  * changes to all the Values in a Store.
854
1111
  *
1112
+ * This has schema-based typing. The following is a simplified representation:
1113
+ *
1114
+ * ```ts override
1115
+ * (
1116
+ * store: Store,
1117
+ * getValueChange: GetValueChange | undefined,
1118
+ * ) => void;
1119
+ * ```
1120
+ *
855
1121
  * A ValuesListener is provided when using the addValuesListener method. See
856
1122
  * that method for specific examples.
857
1123
  *
@@ -868,18 +1134,21 @@ export type CellListener<
868
1134
  * changes.
869
1135
  * @category Listener
870
1136
  */
871
- export type ValuesListener<
872
- Schemas extends OptionalSchemas = NoSchemas,
873
- ValuesSchema extends OptionalValuesSchema = Schemas[1],
874
- > = (
1137
+ export type ValuesListener<Schemas extends OptionalSchemas> = (
875
1138
  store: Store<Schemas>,
876
- getValueChange: GetValueChange<ValuesSchema> | undefined,
1139
+ getValueChange: GetValueChange<Schemas[1]> | undefined,
877
1140
  ) => void;
878
1141
 
879
1142
  /**
880
1143
  * The ValueIdsListener type describes a function that is used to listen to
881
1144
  * changes to the Value Ids in a Store.
882
1145
  *
1146
+ * This has schema-based typing. The following is a simplified representation:
1147
+ *
1148
+ * ```ts override
1149
+ * (store: Store) => void;
1150
+ * ```
1151
+ *
883
1152
  * A ValueIdsListener is provided when using the addValueIdsListener method. See
884
1153
  * that method for specific examples.
885
1154
  *
@@ -888,7 +1157,7 @@ export type ValuesListener<
888
1157
  * @param store A reference to the Store that changed.
889
1158
  * @category Listener
890
1159
  */
891
- export type ValueIdsListener<Schemas extends OptionalSchemas = NoSchemas> = (
1160
+ export type ValueIdsListener<Schemas extends OptionalSchemas> = (
892
1161
  store: Store<Schemas>,
893
1162
  ) => void;
894
1163
 
@@ -896,6 +1165,18 @@ export type ValueIdsListener<Schemas extends OptionalSchemas = NoSchemas> = (
896
1165
  * The ValueListener type describes a function that is used to listen to changes
897
1166
  * to a Value.
898
1167
  *
1168
+ * This has schema-based typing. The following is a simplified representation:
1169
+ *
1170
+ * ```ts override
1171
+ * (
1172
+ * store: Store,
1173
+ * valueId: Id,
1174
+ * newValue: Value,
1175
+ * oldValue: Value,
1176
+ * getValueChange: GetValueChange | undefined,
1177
+ * ) => void;
1178
+ * ```
1179
+ *
899
1180
  * A ValueListener is provided when using the addValueListener method. See that
900
1181
  * method for specific examples.
901
1182
  *
@@ -919,27 +1200,59 @@ export type ValueIdsListener<Schemas extends OptionalSchemas = NoSchemas> = (
919
1200
  * @since v3.0.0
920
1201
  */
921
1202
  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,
934
- newValue: Value,
935
- oldValue: Value,
936
- getValueChange: GetValueChange<ValuesSchema> | undefined,
937
- ) => void;
1203
+ Schemas extends OptionalSchemas,
1204
+ ValueIdOrNull extends ValueIdFromSchema<Schemas[1]> | null,
1205
+ Params extends any[] = (
1206
+ ValueIdOrNull extends null ? ValueIdFromSchema<Schemas[1]> : ValueIdOrNull
1207
+ ) extends infer ValueId
1208
+ ? ValueId extends ValueIdFromSchema<Schemas[1]>
1209
+ ? [
1210
+ store: Store<Schemas>,
1211
+ valueId: ValueId,
1212
+ newValue: Value<Schemas[1], ValueId>,
1213
+ oldValue: Value<Schemas[1], ValueId>,
1214
+ getValueChange: GetValueChange<Schemas[1]> | undefined,
1215
+ ]
1216
+ : never
1217
+ : never,
1218
+ Params5 extends any[] =
1219
+ | Params
1220
+ | [
1221
+ store: never,
1222
+ valueId: never,
1223
+ newValue: never,
1224
+ oldValue: never,
1225
+ getValueChange: never,
1226
+ ],
1227
+ Params4 extends any[] = Truncate<Params5>,
1228
+ Params3 extends any[] = Truncate<Params4>,
1229
+ Params2 extends any[] = Truncate<Params3>,
1230
+ // Params1 extends any[] = Truncate<Params2>,
1231
+ > = Params extends any
1232
+ ?
1233
+ | ((...params: Params5) => void)
1234
+ | ((...params: Params4) => void)
1235
+ | ((...params: Params3) => void)
1236
+ | ((...params: Params2) => void)
1237
+ : // | ((...params: Params1) => void)
1238
+ never;
938
1239
 
939
1240
  /**
940
1241
  * The InvalidCellListener type describes a function that is used to listen to
941
1242
  * attempts to set invalid data to a Cell.
942
1243
  *
1244
+ * This has schema-based typing. The following is a simplified representation:
1245
+ *
1246
+ * ```ts override
1247
+ * (
1248
+ * store: Store,
1249
+ * tableId: Id,
1250
+ * rowId: Id,
1251
+ * cellId: Id,
1252
+ * invalidCells: any[],
1253
+ * ) => void;
1254
+ * ```
1255
+ *
943
1256
  * A InvalidCellListener is provided when using the addInvalidCellListener
944
1257
  * method. See that method for specific examples.
945
1258
  *
@@ -958,7 +1271,7 @@ export type ValueListener<
958
1271
  * @category Listener
959
1272
  * @since v1.1.0
960
1273
  */
961
- export type InvalidCellListener<Schemas extends OptionalSchemas = NoSchemas> = (
1274
+ export type InvalidCellListener<Schemas extends OptionalSchemas> = (
962
1275
  store: Store<Schemas>,
963
1276
  tableId: Id,
964
1277
  rowId: Id,
@@ -970,6 +1283,16 @@ export type InvalidCellListener<Schemas extends OptionalSchemas = NoSchemas> = (
970
1283
  * The InvalidValueListener type describes a function that is used to listen to
971
1284
  * attempts to set invalid data to a Value.
972
1285
  *
1286
+ * This has schema-based typing. The following is a simplified representation:
1287
+ *
1288
+ * ```ts override
1289
+ * (
1290
+ * store: Store,
1291
+ * valueId: Id,
1292
+ * invalidValues: any[],
1293
+ * ) => void;
1294
+ * ```
1295
+ *
973
1296
  * A InvalidValueListener is provided when using the addInvalidValueListener
974
1297
  * method. See that method for specific examples.
975
1298
  *
@@ -986,13 +1309,22 @@ export type InvalidCellListener<Schemas extends OptionalSchemas = NoSchemas> = (
986
1309
  * @category Listener
987
1310
  * @since v3.0.0
988
1311
  */
989
- export type InvalidValueListener<Schemas extends OptionalSchemas = NoSchemas> =
990
- (store: Store<Schemas>, valueId: Id, invalidValues: any[]) => void;
1312
+ export type InvalidValueListener<Schemas extends OptionalSchemas> = (
1313
+ store: Store<Schemas>,
1314
+ valueId: Id,
1315
+ invalidValues: any[],
1316
+ ) => void;
991
1317
 
992
1318
  /**
993
1319
  * The GetCellChange type describes a function that returns information about
994
1320
  * any Cell's changes during a transaction.
995
1321
  *
1322
+ * This has schema-based typing. The following is a simplified representation:
1323
+ *
1324
+ * ```ts override
1325
+ * (tableId: Id, rowId: Id, cellId: Id) => CellChange;
1326
+ * ```
1327
+ *
996
1328
  * A GetCellChange function is provided to every listener when called due the
997
1329
  * Store changing. The listener can then fetch the previous value of a Cell
998
1330
  * before the current transaction, the new value after it, and a convenience
@@ -1004,9 +1336,7 @@ export type InvalidValueListener<Schemas extends OptionalSchemas = NoSchemas> =
1004
1336
  * @returns A CellChange array containing information about the Cell's changes.
1005
1337
  * @category Listener
1006
1338
  */
1007
- export type GetCellChange<
1008
- Schema extends OptionalTablesSchema = NoTablesSchema,
1009
- > = <
1339
+ export type GetCellChange<Schema extends OptionalTablesSchema> = <
1010
1340
  TableId extends TableIdFromSchema<Schema>,
1011
1341
  CellId extends CellIdFromSchema<Schema, TableId>,
1012
1342
  >(
@@ -1018,6 +1348,16 @@ export type GetCellChange<
1018
1348
  /**
1019
1349
  * The CellChange type describes a Cell's changes during a transaction.
1020
1350
  *
1351
+ * This has schema-based typing. The following is a simplified representation:
1352
+ *
1353
+ * ```ts override
1354
+ * [
1355
+ * changed: boolean,
1356
+ * oldCell: CellOrUndefined,
1357
+ * newCell: CellOrUndefined,
1358
+ * ];
1359
+ * ```
1360
+ *
1021
1361
  * This is returned by the GetCellChange function that is provided to every
1022
1362
  * listener when called. This array contains the previous value of a Cell before
1023
1363
  * the current transaction, the new value after it, and a convenience flag that
@@ -1026,12 +1366,9 @@ export type GetCellChange<
1026
1366
  * @category Listener
1027
1367
  */
1028
1368
  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
- >,
1369
+ Schema extends OptionalTablesSchema,
1370
+ TableId extends TableIdFromSchema<Schema>,
1371
+ CellId extends CellIdFromSchema<Schema, TableId>,
1035
1372
  CellOrUndefined = Cell<Schema, TableId, CellId> | undefined,
1036
1373
  > = [changed: boolean, oldCell: CellOrUndefined, newCell: CellOrUndefined];
1037
1374
 
@@ -1039,6 +1376,12 @@ export type CellChange<
1039
1376
  * The GetValueChange type describes a function that returns information about
1040
1377
  * any Value's changes during a transaction.
1041
1378
  *
1379
+ * This has schema-based typing. The following is a simplified representation:
1380
+ *
1381
+ * ```ts override
1382
+ * (valueId: Id) => ValueChange;
1383
+ * ```
1384
+ *
1042
1385
  * A GetValueChange function is provided to every listener when called due the
1043
1386
  * Store changing. The listener can then fetch the previous value of a Value
1044
1387
  * before the current transaction, the new value after it, and a convenience
@@ -1049,15 +1392,25 @@ export type CellChange<
1049
1392
  * changes.
1050
1393
  * @category Listener
1051
1394
  */
1052
- export type GetValueChange<
1053
- Schema extends OptionalValuesSchema = NoValuesSchema,
1054
- > = <ValueId extends ValueIdFromSchema<Schema>>(
1395
+ export type GetValueChange<Schema extends OptionalValuesSchema> = <
1396
+ ValueId extends ValueIdFromSchema<Schema>,
1397
+ >(
1055
1398
  valueId: ValueId,
1056
1399
  ) => ValueChange<Schema, ValueId>;
1057
1400
 
1058
1401
  /**
1059
1402
  * The ValueChange type describes a Value's changes during a transaction.
1060
1403
  *
1404
+ * This has schema-based typing. The following is a simplified representation:
1405
+ *
1406
+ * ```ts override
1407
+ * [
1408
+ * changed: boolean,
1409
+ * oldValue: ValueOrUndefined,
1410
+ * newValue: ValueOrUndefined,
1411
+ * ];
1412
+ * ```
1413
+ *
1061
1414
  * This is returned by the GetValueChange function that is provided to every
1062
1415
  * listener when called. This array contains the previous value of a Value
1063
1416
  * before the current transaction, the new value after it, and a convenience
@@ -1066,8 +1419,8 @@ export type GetValueChange<
1066
1419
  * @category Listener
1067
1420
  */
1068
1421
  export type ValueChange<
1069
- Schema extends OptionalValuesSchema = NoValuesSchema,
1070
- ValueId extends ValueIdFromSchema<Schema> = ValueIdFromSchema<Schema>,
1422
+ Schema extends OptionalValuesSchema,
1423
+ ValueId extends ValueIdFromSchema<Schema>,
1071
1424
  ValueOrUndefined = Value<Schema, ValueId> | undefined,
1072
1425
  > = [changed: boolean, oldValue: ValueOrUndefined, newValue: ValueOrUndefined];
1073
1426
 
@@ -1076,14 +1429,16 @@ export type ValueChange<
1076
1429
  * a transaction, primarily used so that you can indicate whether the
1077
1430
  * transaction should be rolled back.
1078
1431
  *
1432
+ * This has schema-based typing. The following is a simplified representation:
1433
+ *
1079
1434
  * ```ts override
1080
1435
  * {
1081
1436
  * [tableId: Id]: {
1082
1437
  * [rowId: Id]: {
1083
- * [cellId: Id]: [CellOrUndefined, CellOrUndefined],
1084
- * },
1085
- * },
1086
- * }
1438
+ * [cellId: Id]: [CellOrUndefined, CellOrUndefined];
1439
+ * };
1440
+ * };
1441
+ * };
1087
1442
  * ```
1088
1443
  *
1089
1444
  * A ChangedCells object is provided to the `doRollback` callback when using the
@@ -1106,17 +1461,16 @@ export type ValueChange<
1106
1461
  * @category Transaction
1107
1462
  * @since v1.2.0
1108
1463
  */
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
- };
1464
+ export type ChangedCells<Schema extends OptionalTablesSchema> = {
1465
+ [TableId in TableIdFromSchema<Schema>]?: {
1466
+ [rowId: Id]: {
1467
+ [CellId in CellIdFromSchema<Schema, TableId>]?: [
1468
+ CellOrUndefined<Schema, TableId, CellId>,
1469
+ CellOrUndefined<Schema, TableId, CellId>,
1470
+ ];
1118
1471
  };
1119
1472
  };
1473
+ };
1120
1474
 
1121
1475
  /**
1122
1476
  * The InvalidCells type describes the invalid Cell values that have been
@@ -1148,8 +1502,12 @@ export type InvalidCells = {
1148
1502
  * transaction, primarily used so that you can indicate whether the transaction
1149
1503
  * should be rolled back.
1150
1504
  *
1505
+ * This has schema-based typing. The following is a simplified representation:
1506
+ *
1151
1507
  * ```ts override
1152
- * {[valueId: Id]: [ValueOrUndefined, ValueOrUndefined]}
1508
+ * {
1509
+ * [valueId: Id]: [ValueOrUndefined, ValueOrUndefined];
1510
+ * };
1153
1511
  * ```
1154
1512
  *
1155
1513
  * A ChangedValues object is provided to the `doRollback` callback when using
@@ -1171,14 +1529,13 @@ export type InvalidCells = {
1171
1529
  * @category Transaction
1172
1530
  * @since v3.0.0
1173
1531
  */
1174
- export type ChangedValues<
1175
- Schema extends OptionalValuesSchema = NoValuesSchema,
1176
- > = {
1532
+ export type ChangedValues<Schema extends OptionalValuesSchema> = {
1177
1533
  [ValueId in ValueIdFromSchema<Schema>]?: [
1178
- ValueOrUndefined<Schema, ValueId>,
1179
- ValueOrUndefined<Schema, ValueId>,
1534
+ DefaultedValueFromSchema<Schema, ValueId>,
1535
+ DefaultedValueFromSchema<Schema, ValueId>,
1180
1536
  ];
1181
1537
  };
1538
+
1182
1539
  /**
1183
1540
  * The InvalidValues type describes the invalid Values that have been attempted
1184
1541
  * during a transaction, primarily used so that you can indicate whether the
@@ -1406,13 +1763,6 @@ export type StoreListenerStats = {
1406
1763
  * getSchemaJson method, and remove the schemas altogether with the
1407
1764
  * delValuesSchema method and delTablesSchema method.
1408
1765
  *
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.
1415
- *
1416
1766
  * Read more about schemas in the Using Schemas guide.
1417
1767
  *
1418
1768
  * # Convenience methods
@@ -1459,11 +1809,17 @@ export type StoreListenerStats = {
1459
1809
  * @see Todo App demos
1460
1810
  * @category Store
1461
1811
  */
1462
- export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1812
+ export interface Store<in out Schemas extends OptionalSchemas> {
1463
1813
  /**
1464
1814
  * The getTables method returns a Tables object containing the entire data of
1465
1815
  * the Store.
1466
1816
  *
1817
+ * This has schema-based typing. The following is a simplified representation:
1818
+ *
1819
+ * ```ts override
1820
+ * getTables(): Tables;
1821
+ * ```
1822
+ *
1467
1823
  * Note that this returns a copy of, rather than a reference to the underlying
1468
1824
  * data, so changes made to the returned object are not made to the Store
1469
1825
  * itself.
@@ -1489,17 +1845,19 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1489
1845
  * console.log(store.getTables());
1490
1846
  * // -> {}
1491
1847
  * ```
1492
- * @see
1493
- * # Guides
1494
- * Creating a Store
1495
- * @see Indexes
1496
1848
  * @category Getter
1497
1849
  */
1498
- getTables<Tables = TablesFromSchema<Schemas[0]>>(): Tables;
1850
+ getTables(): Tables<Schemas[0]>;
1499
1851
 
1500
1852
  /**
1501
1853
  * The getTableIds method returns the Ids of every Table in the Store.
1502
1854
  *
1855
+ * This has schema-based typing. The following is a simplified representation:
1856
+ *
1857
+ * ```ts override
1858
+ * getTableIds(): Ids;
1859
+ * ```
1860
+ *
1503
1861
  * Note that this returns a copy of, rather than a reference, to the list of
1504
1862
  * Ids, so changes made to the list are not made to the Store itself.
1505
1863
  *
@@ -1526,12 +1884,18 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1526
1884
  * ```
1527
1885
  * @category Getter
1528
1886
  */
1529
- getTableIds<Ids = TableIdFromSchema<Schemas[0]>[]>(): Ids;
1887
+ getTableIds(): TableIdFromSchema<Schemas[0]>[];
1530
1888
 
1531
1889
  /**
1532
1890
  * The getTable method returns an object containing the entire data of a
1533
1891
  * single Table in the Store.
1534
1892
  *
1893
+ * This has schema-based typing. The following is a simplified representation:
1894
+ *
1895
+ * ```ts override
1896
+ * getTable(tableId: Id): Table;
1897
+ * ```
1898
+ *
1535
1899
  * Note that this returns a copy of, rather than a reference to the underlying
1536
1900
  * data, so changes made to the returned object are not made to the Store
1537
1901
  * itself.
@@ -1560,16 +1924,19 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1560
1924
  * ```
1561
1925
  * @category Getter
1562
1926
  */
1563
- getTable<
1564
- TableId extends TableIdFromSchema<Schemas[0]>,
1565
- Table = TableFromSchema<Schemas[0]>,
1566
- >(
1927
+ getTable<TableId extends TableIdFromSchema<Schemas[0]>>(
1567
1928
  tableId: TableId,
1568
- ): Table;
1929
+ ): Table<Schemas[0], TableId>;
1569
1930
 
1570
1931
  /**
1571
1932
  * The getRowIds method returns the Ids of every Row in a given Table.
1572
1933
  *
1934
+ * This has schema-based typing. The following is a simplified representation:
1935
+ *
1936
+ * ```ts override
1937
+ * getRowIds(tableId: Id): Ids;
1938
+ * ```
1939
+ *
1573
1940
  * Note that this returns a copy of, rather than a reference, to the list of
1574
1941
  * Ids, so changes made to the list are not made to the Store itself.
1575
1942
  *
@@ -1599,14 +1966,24 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1599
1966
  * ```
1600
1967
  * @category Getter
1601
1968
  */
1602
- getRowIds<TableId extends TableIdFromSchema<Schemas[0]>>(
1603
- tableId: TableId,
1604
- ): Ids;
1969
+ getRowIds(tableId: TableIdFromSchema<Schemas[0]>): Ids;
1605
1970
 
1606
1971
  /**
1607
1972
  * The getSortedRowIds method returns the Ids of every Row in a given Table,
1608
1973
  * sorted according to the values in a specified Cell.
1609
1974
  *
1975
+ * This has schema-based typing. The following is a simplified representation:
1976
+ *
1977
+ * ```ts override
1978
+ * getSortedRowIds(
1979
+ * tableId: Id,
1980
+ * cellId?: Id,
1981
+ * descending?: boolean,
1982
+ * offset?: number,
1983
+ * limit?: number,
1984
+ * ): Ids;
1985
+ * ```
1986
+ *
1610
1987
  * The sorting of the rows is alphanumeric, and you can indicate whether it
1611
1988
  * should be in descending order. The `offset` and `limit` parameters are used
1612
1989
  * to paginate results, but default to `0` and `undefined` to return all
@@ -1702,12 +2079,9 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1702
2079
  * @category Getter
1703
2080
  * @since v2.0.0
1704
2081
  */
1705
- getSortedRowIds<
1706
- TableId extends TableIdFromSchema<Schemas[0]>,
1707
- CellId extends CellIdFromSchema<Schemas[0], TableId>,
1708
- >(
2082
+ getSortedRowIds<TableId extends TableIdFromSchema<Schemas[0]>>(
1709
2083
  tableId: TableId,
1710
- cellId?: CellId,
2084
+ cellId?: CellIdFromSchema<Schemas[0], TableId>,
1711
2085
  descending?: boolean,
1712
2086
  offset?: number,
1713
2087
  limit?: number,
@@ -1717,6 +2091,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1717
2091
  * The getRow method returns an object containing the entire data of a single
1718
2092
  * Row in a given Table.
1719
2093
  *
2094
+ * This has schema-based typing. The following is a simplified representation:
2095
+ *
2096
+ * ```ts override
2097
+ * getRow(tableId: Id, rowId: Id): Row;
2098
+ * ```
2099
+ *
1720
2100
  * Note that this returns a copy of, rather than a reference to the underlying
1721
2101
  * data, so changes made to the returned object are not made to the Store
1722
2102
  * itself.
@@ -1748,18 +2128,21 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1748
2128
  * ```
1749
2129
  * @category Getter
1750
2130
  */
1751
- getRow<
1752
- TableId extends TableIdFromSchema<Schemas[0]>,
1753
- Row = RowFromSchema<Schemas[0], TableId>,
1754
- >(
2131
+ getRow<TableId extends TableIdFromSchema<Schemas[0]>>(
1755
2132
  tableId: TableId,
1756
2133
  rowId: Id,
1757
- ): Row;
2134
+ ): Row<Schemas[0], TableId>;
1758
2135
 
1759
2136
  /**
1760
2137
  * The getCellIds method returns the Ids of every Cell in a given Row, in a
1761
2138
  * given Table.
1762
2139
  *
2140
+ * This has schema-based typing. The following is a simplified representation:
2141
+ *
2142
+ * ```ts override
2143
+ * getCellIds(tableId: Id, rowId: Id): Ids;
2144
+ * ```
2145
+ *
1763
2146
  * Note that this returns a copy of, rather than a reference, to the list of
1764
2147
  * Ids, so changes made to the list are not made to the Store itself.
1765
2148
  *
@@ -1789,18 +2172,21 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1789
2172
  * ```
1790
2173
  * @category Getter
1791
2174
  */
1792
- getCellIds<
1793
- TableId extends TableIdFromSchema<Schemas[0]>,
1794
- Ids extends CellIdFromSchema<Schemas[0], TableId>[],
1795
- >(
2175
+ getCellIds<TableId extends TableIdFromSchema<Schemas[0]>>(
1796
2176
  tableId: TableId,
1797
2177
  rowId: Id,
1798
- ): Ids;
2178
+ ): CellIdFromSchema<Schemas[0], TableId>[];
1799
2179
 
1800
2180
  /**
1801
2181
  * The getCell method returns the value of a single Cell in a given Row, in a
1802
2182
  * given Table.
1803
2183
  *
2184
+ * This has schema-based typing. The following is a simplified representation:
2185
+ *
2186
+ * ```ts override
2187
+ * getCell(tableId: Id, rowId: Id, cellId: Id): CellOrUndefined;
2188
+ * ```
2189
+ *
1804
2190
  * @param tableId The Id of the Table in the Store.
1805
2191
  * @param rowId The Id of the Row in the Table.
1806
2192
  * @param cellId The Id of the Cell in the Row.
@@ -1828,17 +2214,22 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1828
2214
  getCell<
1829
2215
  TableId extends TableIdFromSchema<Schemas[0]>,
1830
2216
  CellId extends CellIdFromSchema<Schemas[0], TableId>,
1831
- CellOrUndefined = CellFromSchema<Schemas[0], TableId, CellId> | undefined,
1832
2217
  >(
1833
2218
  tableId: TableId,
1834
2219
  rowId: Id,
1835
2220
  cellId: CellId,
1836
- ): CellOrUndefined;
2221
+ ): CellOrUndefined<Schemas[0], TableId, CellId>;
1837
2222
 
1838
2223
  /**
1839
2224
  * The getValues method returns an object containing the entire set of keyed
1840
2225
  * Values in the Store.
1841
2226
  *
2227
+ * This has schema-based typing. The following is a simplified representation:
2228
+ *
2229
+ * ```ts override
2230
+ * getValues(): Values;
2231
+ * ```
2232
+ *
1842
2233
  * Note that this returns a copy of, rather than a reference to the underlying
1843
2234
  * data, so changes made to the returned object are not made to the Store
1844
2235
  * itself.
@@ -1864,11 +2255,17 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1864
2255
  * @category Getter
1865
2256
  * @since v3.0.0
1866
2257
  */
1867
- getValues<Values = ValuesFromSchema<Schemas[1]>>(): Values;
2258
+ getValues(): Values<Schemas[1]>;
1868
2259
 
1869
2260
  /**
1870
2261
  * The getValueIds method returns the Ids of every Value in a Store.
1871
2262
  *
2263
+ * This has schema-based typing. The following is a simplified representation:
2264
+ *
2265
+ * ```ts override
2266
+ * getValueIds(): Ids;
2267
+ * ```
2268
+ *
1872
2269
  * Note that this returns a copy of, rather than a reference, to the list of
1873
2270
  * Ids, so changes made to the list are not made to the Store itself.
1874
2271
  *
@@ -1893,11 +2290,17 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1893
2290
  * @category Getter
1894
2291
  * @since v3.0.0
1895
2292
  */
1896
- getValueIds<Ids = ValueIdFromSchema<Schemas[1]>[]>(): Ids;
2293
+ getValueIds(): ValueIdFromSchema<Schemas[1]>[];
1897
2294
 
1898
2295
  /**
1899
2296
  * The getValue method returns a single keyed Value in the Store.
1900
2297
  *
2298
+ * This has schema-based typing. The following is a simplified representation:
2299
+ *
2300
+ * ```ts override
2301
+ * getValue(valueId: Id): ValueOrUndefined;
2302
+ * ```
2303
+ *
1901
2304
  * @param valueId The Id of the Value in the Store.
1902
2305
  * @returns The Value, or `undefined`.
1903
2306
  * @example
@@ -1919,12 +2322,9 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1919
2322
  * @category Getter
1920
2323
  * @since v3.0.0
1921
2324
  */
1922
- getValue<
1923
- ValueId extends ValueIdFromSchema<Schemas[1]>,
1924
- ValueOrUndefined = ValueFromSchema<Schemas[1], ValueId> | undefined,
1925
- >(
2325
+ getValue<ValueId extends ValueIdFromSchema<Schemas[1]>>(
1926
2326
  valueId: ValueId,
1927
- ): ValueOrUndefined;
2327
+ ): DefaultedValueFromSchema<Schemas[1], ValueId>;
1928
2328
 
1929
2329
  /**
1930
2330
  * The hasTables method returns a boolean indicating whether any Table objects
@@ -1950,6 +2350,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1950
2350
  * The hasTable method returns a boolean indicating whether a given Table
1951
2351
  * exists in the Store.
1952
2352
  *
2353
+ * This has schema-based typing. The following is a simplified representation:
2354
+ *
2355
+ * ```ts override
2356
+ * hasTable(tableId: Id): boolean;
2357
+ * ```
2358
+ *
1953
2359
  * @param tableId The Id of a possible Table in the Store.
1954
2360
  * @returns Whether a Table with that Id exists.
1955
2361
  * @example
@@ -1964,14 +2370,18 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1964
2370
  * ```
1965
2371
  * @category Getter
1966
2372
  */
1967
- hasTable<TableId extends TableIdFromSchema<Schemas[0]>>(
1968
- tableId: TableId,
1969
- ): boolean;
2373
+ hasTable(tableId: TableIdFromSchema<Schemas[0]>): boolean;
1970
2374
 
1971
2375
  /**
1972
2376
  * The hasRow method returns a boolean indicating whether a given Row exists
1973
2377
  * in the Store.
1974
2378
  *
2379
+ * This has schema-based typing. The following is a simplified representation:
2380
+ *
2381
+ * ```ts override
2382
+ * hasRow(tableId: Id, rowId: Id): boolean;
2383
+ * ```
2384
+ *
1975
2385
  * @param tableId The Id of a possible Table in the Store.
1976
2386
  * @param rowId The Id of a possible Row in the Table.
1977
2387
  * @returns Whether a Row with that Id exists in that Table.
@@ -1987,15 +2397,18 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
1987
2397
  * ```
1988
2398
  * @category Getter
1989
2399
  */
1990
- hasRow<TableId extends TableIdFromSchema<Schemas[0]>>(
1991
- tableId: TableId,
1992
- rowId: Id,
1993
- ): boolean;
2400
+ hasRow(tableId: TableIdFromSchema<Schemas[0]>, rowId: Id): boolean;
1994
2401
 
1995
2402
  /**
1996
2403
  * The hasCell method returns a boolean indicating whether a given Cell exists
1997
2404
  * in the Store.
1998
2405
  *
2406
+ * This has schema-based typing. The following is a simplified representation:
2407
+ *
2408
+ * ```ts override
2409
+ * hasCell(tableId: Id, rowId: Id, cellId: Id): boolean;
2410
+ * ```
2411
+ *
1999
2412
  * @param tableId The Id of a possible Table in the Store.
2000
2413
  * @param rowId The Id of a possible Row in the Table.
2001
2414
  * @param cellId The Id of a possible Cell in the Row.
@@ -2012,13 +2425,10 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2012
2425
  * ```
2013
2426
  * @category Getter
2014
2427
  */
2015
- hasCell<
2016
- TableId extends TableIdFromSchema<Schemas[0]>,
2017
- CellId extends CellIdFromSchema<Schemas[0], TableId>,
2018
- >(
2428
+ hasCell<TableId extends TableIdFromSchema<Schemas[0]>>(
2019
2429
  tableId: TableId,
2020
2430
  rowId: Id,
2021
- cellId: CellId,
2431
+ cellId: CellIdFromSchema<Schemas[0], TableId>,
2022
2432
  ): boolean;
2023
2433
 
2024
2434
  /**
@@ -2046,6 +2456,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2046
2456
  * The hasValue method returns a boolean indicating whether a given Value
2047
2457
  * exists in the Store.
2048
2458
  *
2459
+ * This has schema-based typing. The following is a simplified representation:
2460
+ *
2461
+ * ```ts override
2462
+ * hasValue(valueId: Id): boolean;
2463
+ * ```
2464
+ *
2049
2465
  * @param valueId The Id of a possible Value in the Store.
2050
2466
  * @returns Whether a Value with that Id exists in the Store.
2051
2467
  * @example
@@ -2061,9 +2477,7 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2061
2477
  * @category Getter
2062
2478
  * @since v3.0.0
2063
2479
  */
2064
- hasValue<ValueId extends ValueIdFromSchema<Schemas[1]>>(
2065
- valueId: ValueId,
2066
- ): boolean;
2480
+ hasValue(valueId: ValueIdFromSchema<Schemas[1]>): boolean;
2067
2481
 
2068
2482
  /**
2069
2483
  * The getTablesJson method returns a string serialization of all of the
@@ -2259,6 +2673,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2259
2673
  /**
2260
2674
  * The setTables method takes an object and sets the entire data of the Store.
2261
2675
  *
2676
+ * This has schema-based typing. The following is a simplified representation:
2677
+ *
2678
+ * ```ts override
2679
+ * setTables(tables: Tables): Store;
2680
+ * ```
2681
+ *
2262
2682
  * This method will cause listeners to be called for any Table, Row, Cell, or
2263
2683
  * Id changes resulting from it.
2264
2684
  *
@@ -2302,14 +2722,18 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2302
2722
  * ```
2303
2723
  * @category Setter
2304
2724
  */
2305
- setTables<Tables = TablesFromSchema<Schemas[0], true>>(
2306
- tables: Tables,
2307
- ): Store<Schemas>;
2725
+ setTables(tables: Tables<Schemas[0], true>): Store<Schemas>;
2308
2726
 
2309
2727
  /**
2310
2728
  * The setTable method takes an object and sets the entire data of a single
2311
2729
  * Table in the Store.
2312
2730
  *
2731
+ * This has schema-based typing. The following is a simplified representation:
2732
+ *
2733
+ * ```ts override
2734
+ * setTable(tableId: Id, table: Table): Store;
2735
+ * ```
2736
+ *
2313
2737
  * This method will cause listeners to be called for any Table, Row, Cell, or
2314
2738
  * Id changes resulting from it.
2315
2739
  *
@@ -2355,18 +2779,21 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2355
2779
  * ```
2356
2780
  * @category Setter
2357
2781
  */
2358
- setTable<
2359
- TableId extends TableIdFromSchema<Schemas[0]>,
2360
- Table = TableFromSchema<Schemas[0], TableId, true>,
2361
- >(
2782
+ setTable<TableId extends TableIdFromSchema<Schemas[0]>>(
2362
2783
  tableId: TableId,
2363
- table: Table,
2784
+ table: Table<Schemas[0], TableId, true>,
2364
2785
  ): Store<Schemas>;
2365
2786
 
2366
2787
  /**
2367
2788
  * The setRow method takes an object and sets the entire data of a single Row
2368
2789
  * in the Store.
2369
2790
  *
2791
+ * This has schema-based typing. The following is a simplified representation:
2792
+ *
2793
+ * ```ts override
2794
+ * setRow(tableId: Id, rowId: Id, row: Row): Store;
2795
+ * ```
2796
+ *
2370
2797
  * This method will cause listeners to be called for any Table, Row, Cell, or
2371
2798
  * Id changes resulting from it.
2372
2799
  *
@@ -2411,19 +2838,22 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2411
2838
  * ```
2412
2839
  * @category Setter
2413
2840
  */
2414
- setRow<
2415
- TableId extends TableIdFromSchema<Schemas[0]>,
2416
- Row = RowFromSchema<Schemas[0], TableId, true>,
2417
- >(
2841
+ setRow<TableId extends TableIdFromSchema<Schemas[0]>>(
2418
2842
  tableId: TableId,
2419
2843
  rowId: Id,
2420
- row: Row,
2844
+ row: Row<Schemas[0], TableId, true>,
2421
2845
  ): Store<Schemas>;
2422
2846
 
2423
2847
  /**
2424
2848
  * The addRow method takes an object and creates a new Row in the Store,
2425
2849
  * returning the unique Id assigned to it.
2426
2850
  *
2851
+ * This has schema-based typing. The following is a simplified representation:
2852
+ *
2853
+ * ```ts override
2854
+ * addRow(tableId: Id, row: Row): Id | undefined;
2855
+ * ```
2856
+ *
2427
2857
  * This method will cause listeners to be called for any Table, Row, Cell, or
2428
2858
  * Id changes resulting from it.
2429
2859
  *
@@ -2471,18 +2901,21 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2471
2901
  * ```
2472
2902
  * @category Setter
2473
2903
  */
2474
- addRow<
2475
- TableId extends TableIdFromSchema<Schemas[0]>,
2476
- Row = RowFromSchema<Schemas[0], TableId, true>,
2477
- >(
2904
+ addRow<TableId extends TableIdFromSchema<Schemas[0]>>(
2478
2905
  tableId: TableId,
2479
- row: Row,
2906
+ row: Row<Schemas[0], TableId, true>,
2480
2907
  ): Id | undefined;
2481
2908
 
2482
2909
  /**
2483
2910
  * The setPartialRow method takes an object and sets partial data of a single
2484
2911
  * Row in the Store, leaving other Cell values unaffected.
2485
2912
  *
2913
+ * This has schema-based typing. The following is a simplified representation:
2914
+ *
2915
+ * ```ts override
2916
+ * setPartialRow(tableId: Id, rowId: Id, partialRow: Row): Store;
2917
+ * ```
2918
+ *
2486
2919
  * This method will cause listeners to be called for any Table, Row, Cell, or
2487
2920
  * Id changes resulting from it.
2488
2921
  *
@@ -2529,18 +2962,21 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2529
2962
  * ```
2530
2963
  * @category Setter
2531
2964
  */
2532
- setPartialRow<
2533
- TableId extends TableIdFromSchema<Schemas[0]>,
2534
- Row = RowFromSchema<Schemas[0], TableId, true>,
2535
- >(
2965
+ setPartialRow<TableId extends TableIdFromSchema<Schemas[0]>>(
2536
2966
  tableId: TableId,
2537
2967
  rowId: Id,
2538
- partialRow: Row,
2968
+ partialRow: Row<Schemas[0], TableId, true>,
2539
2969
  ): Store<Schemas>;
2540
2970
 
2541
2971
  /**
2542
2972
  * The setCell method sets the value of a single Cell in the Store.
2543
2973
  *
2974
+ * This has schema-based typing. The following is a simplified representation:
2975
+ *
2976
+ * ```ts override
2977
+ * setCell(tableId: Id, rowId: Id, cellId: Id, cell: Cell | MapCell): Store;
2978
+ * ```
2979
+ *
2544
2980
  * This method will cause listeners to be called for any Table, Row, Cell, or
2545
2981
  * Id changes resulting from it.
2546
2982
  *
@@ -2597,18 +3033,24 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2597
3033
  setCell<
2598
3034
  TableId extends TableIdFromSchema<Schemas[0]>,
2599
3035
  CellId extends CellIdFromSchema<Schemas[0], TableId>,
2600
- Cell = CellFromSchema<Schemas[0], TableId, CellId>,
2601
- MapCell = (cell: Cell | undefined) => Cell,
2602
3036
  >(
2603
3037
  tableId: TableId,
2604
3038
  rowId: Id,
2605
3039
  cellId: CellId,
2606
- cell: Cell | MapCell,
3040
+ cell:
3041
+ | Cell<Schemas[0], TableId, CellId>
3042
+ | MapCell<Schemas[0], TableId, CellId>,
2607
3043
  ): Store<Schemas>;
2608
3044
 
2609
3045
  /**
2610
3046
  * The setValues method takes an object and sets all the Values in the Store.
2611
3047
  *
3048
+ * This has schema-based typing. The following is a simplified representation:
3049
+ *
3050
+ * ```ts override
3051
+ * setValues(values: Values): Store;
3052
+ * ```
3053
+ *
2612
3054
  * This method will cause listeners to be called for any Value or Id changes
2613
3055
  * resulting from it.
2614
3056
  *
@@ -2652,14 +3094,18 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2652
3094
  * @category Setter
2653
3095
  * @since v3.0.0
2654
3096
  */
2655
- setValues<Values = ValuesFromSchema<Schemas[1], true>>(
2656
- values: Values,
2657
- ): Store<Schemas>;
3097
+ setValues(values: Values<Schemas[1], true>): Store<Schemas>;
2658
3098
 
2659
3099
  /**
2660
3100
  * The setPartialValues method takes an object and sets its Values in the
2661
3101
  * Store, but leaving existing Values unaffected.
2662
3102
  *
3103
+ * This has schema-based typing. The following is a simplified representation:
3104
+ *
3105
+ * ```ts override
3106
+ * setPartialValues(partialValues: Values): Store;
3107
+ * ```
3108
+ *
2663
3109
  * This method will cause listeners to be called for any Values or Id changes
2664
3110
  * resulting from it.
2665
3111
  *
@@ -2704,13 +3150,17 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2704
3150
  * @category Setter
2705
3151
  * @since v3.0.0
2706
3152
  */
2707
- setPartialValues<Values = ValuesFromSchema<Schemas[1], true>>(
2708
- partialValues: Values,
2709
- ): Store<Schemas>;
3153
+ setPartialValues(partialValues: Values<Schemas[1], true>): Store<Schemas>;
2710
3154
 
2711
3155
  /**
2712
3156
  * The setValue method sets a single keyed Value in the Store.
2713
3157
  *
3158
+ * This has schema-based typing. The following is a simplified representation:
3159
+ *
3160
+ * ```ts override
3161
+ * setValue(valueId: Id, value: Value | MapValue): Store;
3162
+ * ```
3163
+ *
2714
3164
  * This method will cause listeners to be called for any Value, or Id changes
2715
3165
  * resulting from it.
2716
3166
  *
@@ -2760,19 +3210,21 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2760
3210
  * @category Setter
2761
3211
  * @since v3.0.0
2762
3212
  */
2763
- setValue<
2764
- ValueId extends ValueIdFromSchema<Schemas[1]>,
2765
- Value = ValueFromSchema<Schemas[1], ValueId>,
2766
- MapValue = (value: Value | undefined) => Value,
2767
- >(
3213
+ setValue<ValueId extends ValueIdFromSchema<Schemas[1]>>(
2768
3214
  valueId: ValueId,
2769
- value: Value | MapValue,
3215
+ value: Value<Schemas[1], ValueId> | MapValue<Schemas[1], ValueId>,
2770
3216
  ): Store<Schemas>;
2771
3217
 
2772
3218
  /**
2773
3219
  * The setTablesJson method takes a string serialization of all of the Tables
2774
3220
  * in the Store and attempts to update them to that.
2775
3221
  *
3222
+ * This has schema-based typing. The following is a simplified representation:
3223
+ *
3224
+ * ```ts override
3225
+ * setTablesJson(tablesJson: Json): Store;
3226
+ * ```
3227
+ *
2776
3228
  * If the JSON cannot be parsed, this will fail silently. If it can be parsed,
2777
3229
  * it will then be subject to the same validation rules as the setTables
2778
3230
  * method (according to the Tables type, and matching any TablesSchema
@@ -2808,6 +3260,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2808
3260
  * The setValuesJson method takes a string serialization of all of the Values
2809
3261
  * in the Store and attempts to update them to those values.
2810
3262
  *
3263
+ * This has schema-based typing. The following is a simplified representation:
3264
+ *
3265
+ * ```ts override
3266
+ * setValuesJson(valuesJson: Json): Store;
3267
+ * ```
3268
+ *
2811
3269
  * If the JSON cannot be parsed, this will fail silently. If it can be parsed,
2812
3270
  * it will then be subject to the same validation rules as the setValues
2813
3271
  * method (according to the Values type, and matching any ValuesSchema
@@ -2843,6 +3301,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2843
3301
  * The setJson method takes a string serialization of all of the Tables and
2844
3302
  * Values in the Store and attempts to update them to those values.
2845
3303
  *
3304
+ * This has schema-based typing. The following is a simplified representation:
3305
+ *
3306
+ * ```ts override
3307
+ * setJson(tablesAndValuesJson: Json): Store;
3308
+ * ```
3309
+ *
2846
3310
  * From v3.0.0 onwards, the serialization should be of an array with two
2847
3311
  * entries. The first is the Tables object, the second the Values. In previous
2848
3312
  * versions (before the existence of the Values data structure), it was a sole
@@ -2902,18 +3366,16 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2902
3366
  * The setTablesSchema method lets you specify the TablesSchema of the tabular
2903
3367
  * part of the Store.
2904
3368
  *
3369
+ * This has schema-based typing. The following is a simplified representation:
3370
+ *
2905
3371
  * ```ts override
2906
- * setTablesSchema(tablesSchema: TablesSchema): Store<Schemas>
3372
+ * setTablesSchema(tablesSchema: TablesSchema): Store;
2907
3373
  * ```
2908
3374
  *
2909
3375
  * Note that this may result in a change to data in the Store, as defaults are
2910
3376
  * applied or as invalid Table, Row, or Cell objects are removed. These
2911
3377
  * changes will fire any listeners to that data, as expected.
2912
3378
  *
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
- *
2917
3379
  * When no longer needed, you can also completely remove an existing
2918
3380
  * TablesSchema with the delTablesSchema method.
2919
3381
  *
@@ -2937,29 +3399,24 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2937
3399
  * @category Setter
2938
3400
  * @since v3.0.0
2939
3401
  */
2940
- setTablesSchema<
2941
- TablesSchema extends TablesSchemaAlias,
2942
- ValuesSchema extends OptionalValuesSchema = Schemas[1],
2943
- >(
2944
- tablesSchema: TablesSchema,
2945
- ): Store<[typeof tablesSchema, ValuesSchema]>;
3402
+ setTablesSchema<TS extends TablesSchema>(
3403
+ tablesSchema: TS,
3404
+ ): Store<[typeof tablesSchema, Schemas[1]]>;
2946
3405
 
2947
3406
  /**
2948
3407
  * The setValuesSchema method lets you specify the ValuesSchema of the keyed
2949
3408
  * Values part of the Store.
2950
3409
  *
3410
+ * This has schema-based typing. The following is a simplified representation:
3411
+ *
2951
3412
  * ```ts override
2952
- * setValuesSchema(valuesSchema: ValuesSchema): Store<Schemas>
3413
+ * setValuesSchema(valuesSchema: ValuesSchema): Store;
2953
3414
  * ```
2954
3415
  *
2955
3416
  * Note that this may result in a change to data in the Store, as defaults are
2956
3417
  * applied or as invalid Values are removed. These changes will fire any
2957
3418
  * listeners to that data, as expected.
2958
3419
  *
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
- *
2963
3420
  * When no longer needed, you can also completely remove an existing
2964
3421
  * ValuesSchema with the delValuesSchema method.
2965
3422
  *
@@ -2980,32 +3437,24 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
2980
3437
  * @category Setter
2981
3438
  * @since v3.0.0
2982
3439
  */
2983
- setValuesSchema<
2984
- ValuesSchema extends ValuesSchemaAlias,
2985
- TablesSchema extends OptionalTablesSchema = Schemas[0],
2986
- >(
2987
- valuesSchema: ValuesSchema,
2988
- ): Store<[TablesSchema, typeof valuesSchema]>;
3440
+ setValuesSchema<VS extends ValuesSchema>(
3441
+ valuesSchema: VS,
3442
+ ): Store<[Schemas[0], typeof valuesSchema]>;
2989
3443
 
2990
3444
  /**
2991
3445
  * The setSchema method lets you specify the TablesSchema and ValuesSchema of
2992
3446
  * the Store.
2993
3447
  *
3448
+ * This has schema-based typing. The following is a simplified representation:
3449
+ *
2994
3450
  * ```ts override
2995
- * setSchema(
2996
- * tablesSchema: TablesSchema,
2997
- * valuesSchema?: ValuesSchema,
2998
- * ): Store<Schemas>
3451
+ * setSchema(tablesSchema: TablesSchema, valuesSchema?: ValuesSchema): Store;
2999
3452
  * ```
3000
3453
  *
3001
3454
  * Note that this may result in a change to data in the Store, as defaults are
3002
3455
  * applied or as invalid Table, Row, Cell, or Value objects are removed. These
3003
3456
  * changes will fire any listeners to that data, as expected.
3004
3457
  *
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
- *
3009
3458
  * From v3.0.0 onwards, this method takes two arguments. The first is the
3010
3459
  * TablesSchema object, the second the ValuesSchema. In previous versions
3011
3460
  * (before the existence of the ValuesSchema data structure), only the first
@@ -3055,16 +3504,13 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3055
3504
  * ```
3056
3505
  * @category Setter
3057
3506
  */
3058
- setSchema<
3059
- TablesSchema extends TablesSchemaAlias,
3060
- ValuesSchema extends ValuesSchemaAlias,
3061
- >(
3062
- tablesSchema: TablesSchema,
3063
- valuesSchema?: ValuesSchema,
3507
+ setSchema<TS extends TablesSchema, VS extends ValuesSchema>(
3508
+ tablesSchema: TS,
3509
+ valuesSchema?: VS,
3064
3510
  ): Store<
3065
3511
  [
3066
3512
  typeof tablesSchema,
3067
- Exclude<ValuesSchemaAlias, typeof valuesSchema> extends never
3513
+ Exclude<ValuesSchema, typeof valuesSchema> extends never
3068
3514
  ? NoValuesSchema
3069
3515
  : NonNullable<typeof valuesSchema>,
3070
3516
  ]
@@ -3073,6 +3519,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3073
3519
  /**
3074
3520
  * The delTables method lets you remove all of the data in a Store.
3075
3521
  *
3522
+ * This has schema-based typing. The following is a simplified representation:
3523
+ *
3524
+ * ```ts override
3525
+ * delTables(): Store;
3526
+ * ```
3527
+ *
3076
3528
  * @returns A reference to the Store.
3077
3529
  * @example
3078
3530
  * This example removes the data of a Store.
@@ -3091,6 +3543,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3091
3543
  /**
3092
3544
  * The delTable method lets you remove a single Table from the Store.
3093
3545
  *
3546
+ * This has schema-based typing. The following is a simplified representation:
3547
+ *
3548
+ * ```ts override
3549
+ * delTable(tableId: Id): Store;
3550
+ * ```
3551
+ *
3094
3552
  * @param tableId The Id of the Table in the Store.
3095
3553
  * @returns A reference to the Store.
3096
3554
  * @example
@@ -3108,13 +3566,17 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3108
3566
  * ```
3109
3567
  * @category Deleter
3110
3568
  */
3111
- delTable<TableId extends TableIdFromSchema<Schemas[0]>>(
3112
- tableId: TableId,
3113
- ): Store<Schemas>;
3569
+ delTable(tableId: TableIdFromSchema<Schemas[0]>): Store<Schemas>;
3114
3570
 
3115
3571
  /**
3116
3572
  * The delRow method lets you remove a single Row from a Table.
3117
3573
  *
3574
+ * This has schema-based typing. The following is a simplified representation:
3575
+ *
3576
+ * ```ts override
3577
+ * delRow(tableId: Id, rowId: Id): Store;
3578
+ * ```
3579
+ *
3118
3580
  * If this is the last Row in its Table, then that Table will be removed.
3119
3581
  *
3120
3582
  * @param tableId The Id of the Table in the Store.
@@ -3134,14 +3596,17 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3134
3596
  * ```
3135
3597
  * @category Deleter
3136
3598
  */
3137
- delRow<TableId extends TableIdFromSchema<Schemas[0]>>(
3138
- tableId: TableId,
3139
- rowId: Id,
3140
- ): Store<Schemas>;
3599
+ delRow(tableId: TableIdFromSchema<Schemas[0]>, rowId: Id): Store<Schemas>;
3141
3600
 
3142
3601
  /**
3143
3602
  * The delCell method lets you remove a single Cell from a Row.
3144
3603
  *
3604
+ * This has schema-based typing. The following is a simplified representation:
3605
+ *
3606
+ * ```ts override
3607
+ * delCell(tableId: Id, rowId: Id, cellId: Id, forceDel?: boolean): Store;
3608
+ * ```
3609
+ *
3145
3610
  * When there is no TablesSchema applied to the Store, then if this is the
3146
3611
  * last Cell in its Row, then that Row will be removed. If, in turn, that is
3147
3612
  * the last Row in its Table, then that Table will be removed.
@@ -3221,19 +3686,22 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3221
3686
  * ```
3222
3687
  * @category Deleter
3223
3688
  */
3224
- delCell<
3225
- TableId extends TableIdFromSchema<Schemas[0]>,
3226
- CellId extends CellIdFromSchema<Schemas[0], TableId>,
3227
- >(
3689
+ delCell<TableId extends TableIdFromSchema<Schemas[0]>>(
3228
3690
  tableId: TableId,
3229
3691
  rowId: Id,
3230
- cellId: CellId,
3692
+ cellId: CellIdFromSchema<Schemas[0], TableId>,
3231
3693
  forceDel?: boolean,
3232
3694
  ): Store<Schemas>;
3233
3695
 
3234
3696
  /**
3235
3697
  * The delValues method lets you remove all the Values from a Store.
3236
3698
  *
3699
+ * This has schema-based typing. The following is a simplified representation:
3700
+ *
3701
+ * ```ts override
3702
+ * delValues(): Store;
3703
+ * ```
3704
+ *
3237
3705
  * If there is a ValuesSchema applied to the Store and it specifies a default
3238
3706
  * value for any Value Id, then deletion will result in it being set back to
3239
3707
  * its default value.
@@ -3273,6 +3741,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3273
3741
  /**
3274
3742
  * The delValue method lets you remove a single Value from a Store.
3275
3743
  *
3744
+ * This has schema-based typing. The following is a simplified representation:
3745
+ *
3746
+ * ```ts override
3747
+ * delValue(valueId: Id): Store;
3748
+ * ```
3749
+ *
3276
3750
  * If there is a ValuesSchema applied to the Store and it specifies a default
3277
3751
  * value for this Value Id, then deletion will result in it being set back to
3278
3752
  * its default value.
@@ -3308,13 +3782,17 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3308
3782
  * @category Deleter
3309
3783
  * @since v3.0.0
3310
3784
  */
3311
- delValue<ValueId extends ValueIdFromSchema<Schemas[1]>>(
3312
- valueId: ValueId,
3313
- ): Store<Schemas>;
3785
+ delValue(valueId: ValueIdFromSchema<Schemas[1]>): Store<Schemas>;
3314
3786
 
3315
3787
  /**
3316
3788
  * The delTablesSchema method lets you remove the TablesSchema of the Store.
3317
3789
  *
3790
+ * This has schema-based typing. The following is a simplified representation:
3791
+ *
3792
+ * ```ts override
3793
+ * delTablesSchema(): Store;
3794
+ * ```
3795
+ *
3318
3796
  * @returns A reference to the Store.
3319
3797
  * @example
3320
3798
  * This example removes the TablesSchema of a Store.
@@ -3336,6 +3814,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3336
3814
  /**
3337
3815
  * The delValuesSchema method lets you remove the ValuesSchema of the Store.
3338
3816
  *
3817
+ * This has schema-based typing. The following is a simplified representation:
3818
+ *
3819
+ * ```ts override
3820
+ * delValuesSchema(): Store;
3821
+ * ```
3822
+ *
3339
3823
  * @returns A reference to the Store.
3340
3824
  * @example
3341
3825
  * This example removes the ValuesSchema of a Store.
@@ -3359,6 +3843,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3359
3843
  * The delSchema method lets you remove both the TablesSchema and ValuesSchema
3360
3844
  * of the Store.
3361
3845
  *
3846
+ * This has schema-based typing. The following is a simplified representation:
3847
+ *
3848
+ * ```ts override
3849
+ * delSchema(): Store;
3850
+ * ```
3851
+ *
3362
3852
  * Prior to v3.0.0, this method removed the TablesSchema only.
3363
3853
  *
3364
3854
  * @returns A reference to the Store.
@@ -3387,6 +3877,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3387
3877
  * the Store, buffering all calls to the relevant listeners until it
3388
3878
  * completes.
3389
3879
  *
3880
+ * This has schema-based typing. The following is a simplified representation:
3881
+ *
3882
+ * ```ts override
3883
+ * transaction<Return>(actions: () => Return, doRollback?: DoRollback): Return;
3884
+ * ```
3885
+ *
3390
3886
  * This method is useful for making bulk changes to the data in a Store, and
3391
3887
  * when you don't want listeners to be called as you make each change. Changes
3392
3888
  * are made silently during the transaction, and listeners relevant to the
@@ -3519,6 +4015,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3519
4015
  * relevant listeners until it completes when you call the finishTransaction
3520
4016
  * method.
3521
4017
  *
4018
+ * This has schema-based typing. The following is a simplified representation:
4019
+ *
4020
+ * ```ts override
4021
+ * startTransaction(): Store;
4022
+ * ```
4023
+ *
3522
4024
  * Transactions are useful for making bulk changes to the data in a Store, and
3523
4025
  * when you don't want listeners to be called as you make each change. Changes
3524
4026
  * are made silently during the transaction, and listeners relevant to the
@@ -3569,6 +4071,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3569
4071
  * that has made multiple mutations to the Store, triggering all calls to the
3570
4072
  * relevant listeners.
3571
4073
  *
4074
+ * This has schema-based typing. The following is a simplified representation:
4075
+ *
4076
+ * ```ts override
4077
+ * finishTransaction(doRollback?: DoRollback): Store;
4078
+ * ```
4079
+ *
3572
4080
  * Transactions are useful for making bulk changes to the data in a Store, and
3573
4081
  * when you don't want listeners to be called as you make each change. Changes
3574
4082
  * are made silently during the transaction, and listeners relevant to the
@@ -3666,6 +4174,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3666
4174
  * The forEachTable method takes a function that it will then call for each
3667
4175
  * Table in the Store.
3668
4176
  *
4177
+ * This has schema-based typing. The following is a simplified representation:
4178
+ *
4179
+ * ```ts override
4180
+ * forEachTable(tableCallback: TableCallback): void;
4181
+ * ```
4182
+ *
3669
4183
  * This method is useful for iterating over the Table structure of the Store
3670
4184
  * in a functional style. The `tableCallback` parameter is a TableCallback
3671
4185
  * function that will be called with the Id of each Table, and with a function
@@ -3693,14 +4207,18 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3693
4207
  * ```
3694
4208
  * @category Iterator
3695
4209
  */
3696
- forEachTable<TableCallback = TableCallbackAlias<Schemas[0]>>(
3697
- tableCallback: TableCallback,
3698
- ): void;
4210
+ forEachTable(tableCallback: TableCallback<Schemas[0]>): void;
3699
4211
 
3700
4212
  /**
3701
4213
  * The forEachRow method takes a function that it will then call for each Row
3702
4214
  * in a specified Table.
3703
4215
  *
4216
+ * This has schema-based typing. The following is a simplified representation:
4217
+ *
4218
+ * ```ts override
4219
+ * forEachRow(tableId: Id, rowCallback: RowCallback): void;
4220
+ * ```
4221
+ *
3704
4222
  * This method is useful for iterating over the Row structure of the Table in
3705
4223
  * a functional style. The `rowCallback` parameter is a RowCallback function
3706
4224
  * that will be called with the Id of each Row, and with a function that can
@@ -3730,18 +4248,21 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3730
4248
  * ```
3731
4249
  * @category Iterator
3732
4250
  */
3733
- forEachRow<
3734
- TableId extends TableIdFromSchema<Schemas[0]>,
3735
- RowCallback = RowCallbackAlias<Schemas[0], TableId>,
3736
- >(
4251
+ forEachRow<TableId extends TableIdFromSchema<Schemas[0]>>(
3737
4252
  tableId: TableId,
3738
- rowCallback: RowCallback,
4253
+ rowCallback: RowCallback<Schemas[0], TableId>,
3739
4254
  ): void;
3740
4255
 
3741
4256
  /**
3742
4257
  * The forEachCell method takes a function that it will then call for each
3743
4258
  * Cell in a specified Row.
3744
4259
  *
4260
+ * This has schema-based typing. The following is a simplified representation:
4261
+ *
4262
+ * ```ts override
4263
+ * forEachCell(tableId: Id, rowId: Id, cellCallback: CellCallback): void;
4264
+ * ```
4265
+ *
3745
4266
  * This method is useful for iterating over the Cell structure of the Row in a
3746
4267
  * functional style. The `cellCallback` parameter is a CellCallback function
3747
4268
  * that will be called with the Id and value of each Cell.
@@ -3764,19 +4285,22 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3764
4285
  * ```
3765
4286
  * @category Iterator
3766
4287
  */
3767
- forEachCell<
3768
- TableId extends TableIdFromSchema<Schemas[0]>,
3769
- CellCallback = CellCallbackAlias<Schemas[0], TableId>,
3770
- >(
4288
+ forEachCell<TableId extends TableIdFromSchema<Schemas[0]>>(
3771
4289
  tableId: TableId,
3772
4290
  rowId: Id,
3773
- cellCallback: CellCallback,
4291
+ cellCallback: CellCallback<Schemas[0], TableId>,
3774
4292
  ): void;
3775
4293
 
3776
4294
  /**
3777
4295
  * The forEachValue method takes a function that it will then call for each
3778
4296
  * Value in a Store.
3779
4297
  *
4298
+ * This has schema-based typing. The following is a simplified representation:
4299
+ *
4300
+ * ```ts override
4301
+ * forEachValue(valueCallback: ValueCallback): void;
4302
+ * ```
4303
+ *
3780
4304
  * This method is useful for iterating over the Value structure of the Store
3781
4305
  * in a functional style. The `valueCallback` parameter is a ValueCallback
3782
4306
  * function that will be called with the Id and value of each Value.
@@ -3796,14 +4320,18 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3796
4320
  * @category Iterator
3797
4321
  * @since v3.0.0
3798
4322
  */
3799
- forEachValue<ValueCallback = ValueCallbackAlias<Schemas[1]>>(
3800
- valueCallback: ValueCallback,
3801
- ): void;
4323
+ forEachValue(valueCallback: ValueCallback<Schemas[1]>): void;
3802
4324
 
3803
4325
  /**
3804
4326
  * The addTablesListener method registers a listener function with the Store
3805
4327
  * that will be called whenever data in the Store changes.
3806
4328
  *
4329
+ * This has schema-based typing. The following is a simplified representation:
4330
+ *
4331
+ * ```ts override
4332
+ * addTablesListener(listener: TablesListener, mutator?: boolean): Id;
4333
+ * ```
4334
+ *
3807
4335
  * The provided listener is a TablesListener function, and will be called with
3808
4336
  * a reference to the Store and a GetCellChange function in case you need to
3809
4337
  * inspect any changes that occurred.
@@ -3868,6 +4396,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3868
4396
  * The addTableIdsListener method registers a listener function with the Store
3869
4397
  * that will be called whenever the Table Ids in the Store change.
3870
4398
  *
4399
+ * This has schema-based typing. The following is a simplified representation:
4400
+ *
4401
+ * ```ts override
4402
+ * addTableIdsListener(listener: TableIdsListener, mutator?: boolean): Id;
4403
+ * ```
4404
+ *
3871
4405
  * The provided listener is a TableIdsListener function, and will be called
3872
4406
  * with a reference to the Store.
3873
4407
  *
@@ -3934,6 +4468,16 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
3934
4468
  * The addTableListener method registers a listener function with the Store
3935
4469
  * that will be called whenever data in a Table changes.
3936
4470
  *
4471
+ * This has schema-based typing. The following is a simplified representation:
4472
+ *
4473
+ * ```ts override
4474
+ * addTableListener(
4475
+ * tableId: IdOrNull,
4476
+ * listener: TableListener,
4477
+ * mutator?: boolean,
4478
+ * ): Id;
4479
+ * ```
4480
+ *
3937
4481
  * The provided listener is a TableListener function, and will be called with
3938
4482
  * a reference to the Store, the Id of the Table that changed, and a
3939
4483
  * GetCellChange function in case you need to inspect any changes that
@@ -4031,6 +4575,16 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
4031
4575
  * The addRowIdsListener method registers a listener function with the Store
4032
4576
  * that will be called whenever the Row Ids in a Table change.
4033
4577
  *
4578
+ * This has schema-based typing. The following is a simplified representation:
4579
+ *
4580
+ * ```ts override
4581
+ * addRowIdsListener(
4582
+ * tableId: IdOrNull,
4583
+ * listener: RowIdsListener,
4584
+ * mutator?: boolean,
4585
+ * ): Id;
4586
+ * ```
4587
+ *
4034
4588
  * The provided listener is a RowIdsListener function, and will be called with
4035
4589
  * a reference to the Store and the Id of the Table that changed.
4036
4590
  *
@@ -4124,6 +4678,20 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
4124
4678
  * Store that will be called whenever sorted (and optionally, paginated) Row
4125
4679
  * Ids in a Table change.
4126
4680
  *
4681
+ * This has schema-based typing. The following is a simplified representation:
4682
+ *
4683
+ * ```ts override
4684
+ * addSortedRowIdsListener(
4685
+ * tableId: Id,
4686
+ * cellId: Id | undefined,
4687
+ * descending: boolean,
4688
+ * offset: number,
4689
+ * limit: number | undefined,
4690
+ * listener: SortedRowIdsListener,
4691
+ * mutator?: boolean,
4692
+ * ): Id;
4693
+ * ```
4694
+ *
4127
4695
  * The provided listener is a SortedRowIdsListener function, and will be
4128
4696
  * called with a reference to the Store, the Id of the Table whose Row Ids
4129
4697
  * sorting changed, the Cell Id being used to sort them, whether descending or
@@ -4337,20 +4905,20 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
4337
4905
  */
4338
4906
  addSortedRowIdsListener<
4339
4907
  TableId extends TableIdFromSchema<Schemas[0]>,
4340
- CellId extends CellIdFromSchema<Schemas[0], TableId> | undefined,
4908
+ CellIdOrUndefined extends CellIdFromSchema<Schemas[0], TableId> | undefined,
4341
4909
  Descending extends boolean,
4342
4910
  Offset extends number,
4343
4911
  Limit extends number | undefined,
4344
4912
  >(
4345
4913
  tableId: TableId,
4346
- cellId: CellId,
4914
+ cellId: CellIdOrUndefined,
4347
4915
  descending: Descending,
4348
4916
  offset: Offset,
4349
4917
  limit: Limit,
4350
4918
  listener: SortedRowIdsListener<
4351
4919
  Schemas,
4352
4920
  TableId,
4353
- CellId,
4921
+ CellIdOrUndefined,
4354
4922
  Descending,
4355
4923
  Offset,
4356
4924
  Limit
@@ -4362,6 +4930,17 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
4362
4930
  * The addRowListener method registers a listener function with the Store that
4363
4931
  * will be called whenever data in a Row changes.
4364
4932
  *
4933
+ * This has schema-based typing. The following is a simplified representation:
4934
+ *
4935
+ * ```ts override
4936
+ * addRowListener(
4937
+ * tableId: IdOrNull,
4938
+ * rowId: IdOrNull,
4939
+ * listener: RowListener,
4940
+ * mutator?: boolean,
4941
+ * ): Id;
4942
+ * ```
4943
+ *
4365
4944
  * The provided listener is a RowListener function, and will be called with a
4366
4945
  * reference to the Store, the Id of the Table that changed, the Id of the Row
4367
4946
  * that changed, and a GetCellChange function in case you need to inspect any
@@ -4475,6 +5054,17 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
4475
5054
  * The addCellIdsListener method registers a listener function with the Store
4476
5055
  * that will be called whenever the Cell Ids in a Row change.
4477
5056
  *
5057
+ * This has schema-based typing. The following is a simplified representation:
5058
+ *
5059
+ * ```ts override
5060
+ * addCellIdsListener(
5061
+ * tableId: IdOrNull,
5062
+ * rowId: IdOrNull,
5063
+ * listener: CellIdsListener,
5064
+ * mutator?: boolean,
5065
+ * ): Id;
5066
+ * ```
5067
+ *
4478
5068
  * The provided listener is a CellIdsListener function, and will be called
4479
5069
  * with a reference to the Store, the Id of the Table, and the Id of the Row
4480
5070
  * that changed.
@@ -4584,6 +5174,18 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
4584
5174
  * The addCellListener method registers a listener function with the Store
4585
5175
  * that will be called whenever data in a Cell changes.
4586
5176
  *
5177
+ * This has schema-based typing. The following is a simplified representation:
5178
+ *
5179
+ * ```ts override
5180
+ * addCellListener(
5181
+ * tableId: IdOrNull,
5182
+ * rowId: IdOrNull,
5183
+ * cellId: IdOrNull,
5184
+ * listener: CellListener,
5185
+ * mutator?: boolean,
5186
+ * ): Id;
5187
+ * ```
5188
+ *
4587
5189
  * The provided listener is a CellListener function, and will be called with a
4588
5190
  * reference to the Store, the Id of the Table that changed, the Id of the Row
4589
5191
  * that changed, the Id of the Cell that changed, the new Cell value, the old
@@ -4700,17 +5302,11 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
4700
5302
  ? CellIdFromSchema<Schemas[0], TableIdOrNull>
4701
5303
  : AllCellIdFromSchema<Schemas[0]>)
4702
5304
  | null,
4703
- CellListener extends CellListenerAlias<
4704
- Schemas,
4705
- TableIdOrNull,
4706
- RowIdOrNull,
4707
- CellIdOrNull
4708
- >,
4709
5305
  >(
4710
5306
  tableId: TableIdOrNull,
4711
5307
  rowId: RowIdOrNull,
4712
5308
  cellId: CellIdOrNull,
4713
- listener: CellListener,
5309
+ listener: CellListener<Schemas, TableIdOrNull, RowIdOrNull, CellIdOrNull>,
4714
5310
  mutator?: boolean,
4715
5311
  ): Id;
4716
5312
 
@@ -4718,6 +5314,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
4718
5314
  * The addValuesListener method registers a listener function with the Store
4719
5315
  * that will be called whenever the Values change.
4720
5316
  *
5317
+ * This has schema-based typing. The following is a simplified representation:
5318
+ *
5319
+ * ```ts override
5320
+ * addValuesListener(listener: ValuesListener, mutator?: boolean): Id;
5321
+ * ```
5322
+ *
4721
5323
  * The provided listener is a ValuesListener function, and will be called with
4722
5324
  * a reference to the Store and a GetValueChange function in case you need to
4723
5325
  * inspect any changes that occurred.
@@ -4779,6 +5381,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
4779
5381
  * The addValueIdsListener method registers a listener function with the Store
4780
5382
  * that will be called whenever the Value Ids in a Store change.
4781
5383
  *
5384
+ * This has schema-based typing. The following is a simplified representation:
5385
+ *
5386
+ * ```ts override
5387
+ * addValueIdsListener(listener: ValueIdsListener, mutator?: boolean): Id;
5388
+ * ```
5389
+ *
4782
5390
  * The provided listener is a ValueIdsListener function, and will be called
4783
5391
  * with a reference to the Store.
4784
5392
  *
@@ -4846,6 +5454,16 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
4846
5454
  * The addValueListener method registers a listener function with the Store
4847
5455
  * that will be called whenever data in a Value changes.
4848
5456
  *
5457
+ * This has schema-based typing. The following is a simplified representation:
5458
+ *
5459
+ * ```ts override
5460
+ * addValueListener(
5461
+ * valueId: IdOrNull,
5462
+ * listener: ValueListener,
5463
+ * mutator?: boolean,
5464
+ * ): Id;
5465
+ * ```
5466
+ *
4849
5467
  * The provided listener is a ValueListener function, and will be called with
4850
5468
  * a reference to the Store, the Id of the Value that changed, the new Value
4851
5469
  * value, the old Value, and a GetValueChange function in case you need to
@@ -4929,12 +5547,9 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
4929
5547
  * @category Listener
4930
5548
  * @since v3.0.0
4931
5549
  */
4932
- addValueListener<
4933
- ValueIdOrNull extends ValueIdFromSchema<Schemas[1]> | null,
4934
- ValueListener = ValueListenerAlias<Schemas, ValueIdOrNull>,
4935
- >(
5550
+ addValueListener<ValueIdOrNull extends ValueIdFromSchema<Schemas[1]> | null>(
4936
5551
  valueId: ValueIdOrNull,
4937
- listener: ValueListener,
5552
+ listener: ValueListener<Schemas, ValueIdOrNull>,
4938
5553
  mutator?: boolean,
4939
5554
  ): Id;
4940
5555
 
@@ -4943,6 +5558,18 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
4943
5558
  * Store that will be called whenever invalid data was attempted to be written
4944
5559
  * to a Cell.
4945
5560
  *
5561
+ * This has schema-based typing. The following is a simplified representation:
5562
+ *
5563
+ * ```ts override
5564
+ * addInvalidCellListener(
5565
+ * tableId: IdOrNull,
5566
+ * rowId: IdOrNull,
5567
+ * cellId: IdOrNull,
5568
+ * listener: InvalidCellListener,
5569
+ * mutator?: boolean,
5570
+ * ): Id;
5571
+ * ```
5572
+ *
4946
5573
  * The provided listener is an InvalidCellListener function, and will be
4947
5574
  * called with a reference to the Store, the Id of the Table, the Id of the
4948
5575
  * Row, and the Id of Cell that was being attempted to be changed. It is also
@@ -5174,6 +5801,16 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
5174
5801
  * Store that will be called whenever invalid data was attempted to be written
5175
5802
  * to a Value.
5176
5803
  *
5804
+ * This has schema-based typing. The following is a simplified representation:
5805
+ *
5806
+ * ```ts override
5807
+ * addInvalidValueListener(
5808
+ * valueId: IdOrNull,
5809
+ * listener: InvalidValueListener,
5810
+ * mutator?: boolean,
5811
+ * ): Id;
5812
+ * ```
5813
+ *
5177
5814
  * The provided listener is an InvalidValueListener function, and will be
5178
5815
  * called with a reference to the Store and the Id of Value that was being
5179
5816
  * attempted to be changed. It is also given the invalid value of the Value,
@@ -5350,6 +5987,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
5350
5987
  * with the Store that will be called just before other non-mutating listeners
5351
5988
  * are called at the end of the transaction.
5352
5989
  *
5990
+ * This has schema-based typing. The following is a simplified representation:
5991
+ *
5992
+ * ```ts override
5993
+ * addWillFinishTransactionListener(listener: TransactionListener): Id;
5994
+ * ```
5995
+ *
5353
5996
  * This is useful if you need to know that a set of listeners are about to be
5354
5997
  * called at the end of a transaction, perhaps to batch _their_ consequences
5355
5998
  * together.
@@ -5442,6 +6085,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
5442
6085
  * with the Store that will be called just after other non-mutating listeners
5443
6086
  * are called at the end of the transaction.
5444
6087
  *
6088
+ * This has schema-based typing. The following is a simplified representation:
6089
+ *
6090
+ * ```ts override
6091
+ * addDidFinishTransactionListener(listener: TransactionListener): Id;
6092
+ * ```
6093
+ *
5445
6094
  * This is useful if you need to know that a set of listeners have just been
5446
6095
  * called at the end of a transaction, perhaps to batch _their_ consequences
5447
6096
  * together.
@@ -5534,6 +6183,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
5534
6183
  * The callListener method provides a way for you to manually provoke a
5535
6184
  * listener to be called, even if the underlying data hasn't changed.
5536
6185
  *
6186
+ * This has schema-based typing. The following is a simplified representation:
6187
+ *
6188
+ * ```ts override
6189
+ * callListener(listenerId: Id): Store;
6190
+ * ```
6191
+ *
5537
6192
  * This is useful when you are using mutator listeners to guarantee that data
5538
6193
  * conforms to programmatic conditions, and those conditions change such that
5539
6194
  * you need to update the Store in bulk.
@@ -5651,6 +6306,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
5651
6306
  * The delListener method removes a listener that was previously added to the
5652
6307
  * Store.
5653
6308
  *
6309
+ * This has schema-based typing. The following is a simplified representation:
6310
+ *
6311
+ * ```ts override
6312
+ * delListener(listenerId: Id): Store;
6313
+ * ```
6314
+ *
5654
6315
  * Use the Id returned by whichever method was used to add the listener. Note
5655
6316
  * that the Store may re-use this Id for future listeners added to it.
5656
6317
  *
@@ -5716,6 +6377,12 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
5716
6377
  * The createStore function creates a Store, and is the main entry point into
5717
6378
  * the store module.
5718
6379
  *
6380
+ * This has schema-based typing. The following is a simplified representation:
6381
+ *
6382
+ * ```ts override
6383
+ * createStore(): Store;
6384
+ * ```
6385
+ *
5719
6386
  * Since (or perhaps _because_) it is the most important function in the whole
5720
6387
  * module, it is trivially simple.
5721
6388
  *
@@ -5754,390 +6421,4 @@ export interface Store<Schemas extends OptionalSchemas = NoSchemas> {
5754
6421
  * @see The Basics guides
5755
6422
  * @category Creation
5756
6423
  */
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>;
6424
+ export function createStore(): Store<NoSchemas>;