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.
- package/lib/debug/ui-react.js +2 -2
- package/lib/{checkpoints.d.ts → types/checkpoints.d.ts} +13 -13
- package/lib/{debug → types}/indexes.d.ts +10 -16
- package/lib/{debug → types}/metrics.d.ts +49 -50
- package/lib/{debug → types}/persisters.d.ts +26 -30
- package/lib/{cjs-es6 → types}/queries.d.ts +474 -309
- package/lib/{debug → types}/relationships.d.ts +11 -17
- package/lib/{debug → types}/store.d.ts +180 -1038
- package/lib/types/tinybase.d.ts +14 -0
- package/lib/{debug → types}/tools.d.ts +12 -12
- package/lib/{debug → types}/ui-react.d.ts +11 -5
- package/lib/{cjs-es6 → types/with-schemas}/checkpoints.d.ts +93 -7
- package/lib/{cjs → types/with-schemas}/indexes.d.ts +136 -18
- package/lib/types/with-schemas/internal/queries.d.ts +15 -0
- package/lib/types/with-schemas/internal/store.d.ts +101 -0
- package/lib/types/with-schemas/internal/ui-react.d.ts +776 -0
- package/lib/{cjs → types/with-schemas}/metrics.d.ts +115 -50
- package/lib/{cjs → types/with-schemas}/persisters.d.ts +102 -4
- package/lib/{debug → types/with-schemas}/queries.d.ts +865 -346
- package/lib/{cjs → types/with-schemas}/relationships.d.ts +151 -20
- package/lib/{cjs-es6 → types/with-schemas}/store.d.ts +1082 -801
- package/lib/types/with-schemas/tinybase.d.ts +14 -0
- package/lib/{cjs-es6 → types/with-schemas}/tools.d.ts +21 -10
- package/lib/{cjs-es6 → types/with-schemas}/ui-react.d.ts +1871 -1314
- package/package.json +145 -29
- package/readme.md +14 -14
- package/lib/cjs/checkpoints.d.ts +0 -961
- package/lib/cjs/queries.d.ts +0 -3028
- package/lib/cjs/store.d.ts +0 -6143
- package/lib/cjs/tinybase.d.ts +0 -14
- package/lib/cjs/tools.d.ts +0 -536
- package/lib/cjs/ui-react.d.ts +0 -10921
- package/lib/cjs-es6/indexes.d.ts +0 -974
- package/lib/cjs-es6/metrics.d.ts +0 -829
- package/lib/cjs-es6/persisters.d.ts +0 -733
- package/lib/cjs-es6/relationships.d.ts +0 -1209
- package/lib/cjs-es6/tinybase.d.ts +0 -14
- package/lib/common.d.ts +0 -115
- package/lib/debug/checkpoints.d.ts +0 -961
- package/lib/debug/common.d.ts +0 -115
- package/lib/debug/tinybase.d.ts +0 -14
- package/lib/es6/checkpoints.d.ts +0 -961
- package/lib/es6/common.d.ts +0 -115
- package/lib/es6/indexes.d.ts +0 -974
- package/lib/es6/metrics.d.ts +0 -829
- package/lib/es6/persisters.d.ts +0 -733
- package/lib/es6/queries.d.ts +0 -3028
- package/lib/es6/relationships.d.ts +0 -1209
- package/lib/es6/store.d.ts +0 -6143
- package/lib/es6/tinybase.d.ts +0 -14
- package/lib/es6/tools.d.ts +0 -536
- package/lib/es6/ui-react.d.ts +0 -10921
- package/lib/indexes.d.ts +0 -974
- package/lib/metrics.d.ts +0 -829
- package/lib/persisters.d.ts +0 -733
- package/lib/queries.d.ts +0 -3028
- package/lib/relationships.d.ts +0 -1209
- package/lib/store.d.ts +0 -6143
- package/lib/tinybase.d.ts +0 -14
- package/lib/tools.d.ts +0 -536
- package/lib/ui-react.d.ts +0 -10921
- package/lib/umd/checkpoints.d.ts +0 -961
- package/lib/umd/common.d.ts +0 -115
- package/lib/umd/indexes.d.ts +0 -974
- package/lib/umd/metrics.d.ts +0 -829
- package/lib/umd/persisters.d.ts +0 -733
- package/lib/umd/queries.d.ts +0 -3028
- package/lib/umd/relationships.d.ts +0 -1209
- package/lib/umd/store.d.ts +0 -6143
- package/lib/umd/tinybase.d.ts +0 -14
- package/lib/umd/tools.d.ts +0 -536
- package/lib/umd/ui-react.d.ts +0 -10921
- package/lib/umd-es6/checkpoints.d.ts +0 -961
- package/lib/umd-es6/common.d.ts +0 -115
- package/lib/umd-es6/indexes.d.ts +0 -974
- package/lib/umd-es6/metrics.d.ts +0 -829
- package/lib/umd-es6/persisters.d.ts +0 -733
- package/lib/umd-es6/queries.d.ts +0 -3028
- package/lib/umd-es6/relationships.d.ts +0 -1209
- package/lib/umd-es6/store.d.ts +0 -6143
- package/lib/umd-es6/tinybase.d.ts +0 -14
- package/lib/umd-es6/tools.d.ts +0 -536
- package/lib/umd-es6/ui-react.d.ts +0 -10921
- /package/lib/{cjs-es6 → types}/common.d.ts +0 -0
- /package/lib/{cjs → types/with-schemas}/common.d.ts +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is everything.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export * from './checkpoints.d';
|
|
8
|
+
export * from './common.d';
|
|
9
|
+
export * from './indexes.d';
|
|
10
|
+
export * from './metrics.d';
|
|
11
|
+
export * from './persisters.d';
|
|
12
|
+
export * from './queries.d';
|
|
13
|
+
export * from './relationships.d';
|
|
14
|
+
export * from './store.d';
|
|
@@ -10,13 +10,7 @@
|
|
|
10
10
|
* @since v2.2.0
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
NoSchemas,
|
|
15
|
-
OptionalSchemas,
|
|
16
|
-
Store,
|
|
17
|
-
TablesSchema,
|
|
18
|
-
ValuesSchema,
|
|
19
|
-
} from './store.d';
|
|
13
|
+
import {Store, TablesSchema, ValuesSchema} from './store.d';
|
|
20
14
|
import {Id} from './common.d';
|
|
21
15
|
|
|
22
16
|
/**
|
|
@@ -90,6 +84,9 @@ export type StoreStatsTableDetail = {
|
|
|
90
84
|
* The number of Cell objects in the Table, across all Row objects.
|
|
91
85
|
*/
|
|
92
86
|
tableCells: number;
|
|
87
|
+
/**
|
|
88
|
+
* Detail about the Table object.
|
|
89
|
+
*/
|
|
93
90
|
rows: {[rowId: Id]: StoreStatsRowDetail};
|
|
94
91
|
};
|
|
95
92
|
|
|
@@ -115,7 +112,8 @@ export type StoreStatsRowDetail = {
|
|
|
115
112
|
* @category Tools
|
|
116
113
|
* @since v2.2.0
|
|
117
114
|
*/
|
|
118
|
-
export interface Tools
|
|
115
|
+
export interface Tools {
|
|
116
|
+
//
|
|
119
117
|
/* eslint-disable max-len */
|
|
120
118
|
/**
|
|
121
119
|
* The getStoreStats method provides a set of statistics about the Store, and
|
|
@@ -174,6 +172,7 @@ export interface Tools<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
174
172
|
* @since v2.2.0
|
|
175
173
|
*/
|
|
176
174
|
getStoreStats(detail?: boolean): StoreStats;
|
|
175
|
+
|
|
177
176
|
/* eslint-enable max-len */
|
|
178
177
|
|
|
179
178
|
/**
|
|
@@ -483,7 +482,8 @@ export interface Tools<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
483
482
|
* @category Getter
|
|
484
483
|
* @since v3.0.0
|
|
485
484
|
*/
|
|
486
|
-
getStore(): Store
|
|
485
|
+
getStore(): Store;
|
|
486
|
+
//
|
|
487
487
|
}
|
|
488
488
|
|
|
489
489
|
/* eslint-disable max-len */
|
|
@@ -530,7 +530,7 @@ export interface Tools<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
530
530
|
* @category Creation
|
|
531
531
|
* @since v2.2.0
|
|
532
532
|
*/
|
|
533
|
-
export function createTools
|
|
534
|
-
|
|
535
|
-
|
|
533
|
+
export function createTools(store: Store): Tools;
|
|
534
|
+
//
|
|
535
|
+
|
|
536
536
|
/* eslint-enable max-len */
|
|
@@ -28,7 +28,9 @@ import {
|
|
|
28
28
|
Cell,
|
|
29
29
|
CellIdsListener,
|
|
30
30
|
CellListener,
|
|
31
|
+
CellOrUndefined,
|
|
31
32
|
MapCell,
|
|
33
|
+
MapValue,
|
|
32
34
|
Row,
|
|
33
35
|
RowIdsListener,
|
|
34
36
|
RowListener,
|
|
@@ -42,6 +44,7 @@ import {
|
|
|
42
44
|
Value,
|
|
43
45
|
ValueIdsListener,
|
|
44
46
|
ValueListener,
|
|
47
|
+
ValueOrUndefined,
|
|
45
48
|
Values,
|
|
46
49
|
ValuesListener,
|
|
47
50
|
} from './store.d';
|
|
@@ -1036,7 +1039,7 @@ export function useCell(
|
|
|
1036
1039
|
rowId: Id,
|
|
1037
1040
|
cellId: Id,
|
|
1038
1041
|
storeOrStoreId?: StoreOrStoreId,
|
|
1039
|
-
):
|
|
1042
|
+
): CellOrUndefined;
|
|
1040
1043
|
|
|
1041
1044
|
/**
|
|
1042
1045
|
* The useValues hook returns a Values object containing the keyed value data of
|
|
@@ -1272,7 +1275,10 @@ export function useValueIds(storeOrStoreId?: StoreOrStoreId): Ids;
|
|
|
1272
1275
|
* @category Store hooks
|
|
1273
1276
|
* @since v3.0.0
|
|
1274
1277
|
*/
|
|
1275
|
-
export function useValue(
|
|
1278
|
+
export function useValue(
|
|
1279
|
+
valueId: Id,
|
|
1280
|
+
storeOrStoreId?: StoreOrStoreId,
|
|
1281
|
+
): ValueOrUndefined;
|
|
1276
1282
|
|
|
1277
1283
|
/**
|
|
1278
1284
|
* The useSetTablesCallback hook returns a parameterized callback that can be
|
|
@@ -2088,10 +2094,10 @@ export function useSetPartialValuesCallback<Parameter>(
|
|
|
2088
2094
|
*/
|
|
2089
2095
|
export function useSetValueCallback<Parameter>(
|
|
2090
2096
|
valueId: Id,
|
|
2091
|
-
getValue: (parameter: Parameter, store: Store) => Value,
|
|
2097
|
+
getValue: (parameter: Parameter, store: Store) => Value | MapValue,
|
|
2092
2098
|
getValueDeps?: React.DependencyList,
|
|
2093
2099
|
storeOrStoreId?: StoreOrStoreId,
|
|
2094
|
-
then?: (store: Store, value: Value) => void,
|
|
2100
|
+
then?: (store: Store, value: Value | MapValue) => void,
|
|
2095
2101
|
thenDeps?: React.DependencyList,
|
|
2096
2102
|
): ParameterizedCallback<Parameter>;
|
|
2097
2103
|
|
|
@@ -7767,7 +7773,7 @@ export type IndexProps = {
|
|
|
7767
7773
|
};
|
|
7768
7774
|
|
|
7769
7775
|
/**
|
|
7770
|
-
*
|
|
7776
|
+
* SliceProps props are used for components that refer to a single Slice in an
|
|
7771
7777
|
* Index object, such as the SliceView component.
|
|
7772
7778
|
*
|
|
7773
7779
|
* @category Props
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import {Id, IdOrNull, Ids} from './common.d';
|
|
15
|
-
import {
|
|
15
|
+
import {OptionalSchemas, Store} from './store.d';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The CheckpointIds type is a representation of the list of checkpoint Ids
|
|
@@ -51,6 +51,12 @@ export type CheckpointCallback = (checkpointId: Id, label?: string) => void;
|
|
|
51
51
|
* The CheckpointIdsListener type describes a function that is used to listen to
|
|
52
52
|
* changes to the checkpoint Ids in a Checkpoints object.
|
|
53
53
|
*
|
|
54
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
55
|
+
*
|
|
56
|
+
* ```ts override
|
|
57
|
+
* (checkpoints: Checkpoints) => void;
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
54
60
|
* A CheckpointIdsListener is provided when using the addCheckpointIdsListener
|
|
55
61
|
* method. See that method for specific examples.
|
|
56
62
|
*
|
|
@@ -60,12 +66,23 @@ export type CheckpointCallback = (checkpointId: Id, label?: string) => void;
|
|
|
60
66
|
* @param checkpoints A reference to the Checkpoints object that changed.
|
|
61
67
|
* @category Listener
|
|
62
68
|
*/
|
|
63
|
-
export type CheckpointIdsListener = (
|
|
69
|
+
export type CheckpointIdsListener<Schemas extends OptionalSchemas> = (
|
|
70
|
+
checkpoints: Checkpoints<Schemas>,
|
|
71
|
+
) => void;
|
|
64
72
|
|
|
65
73
|
/**
|
|
66
74
|
* The CheckpointListener type describes a function that is used to listen to
|
|
67
75
|
* changes to a checkpoint's label in a Checkpoints object.
|
|
68
76
|
*
|
|
77
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
78
|
+
*
|
|
79
|
+
* ```ts override
|
|
80
|
+
* (
|
|
81
|
+
* checkpoints: Checkpoints,
|
|
82
|
+
* checkpointId: Id,
|
|
83
|
+
* ) => void;
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
69
86
|
* A CheckpointListener is provided when using the addCheckpointListener method.
|
|
70
87
|
* See that method for specific examples.
|
|
71
88
|
*
|
|
@@ -76,8 +93,8 @@ export type CheckpointIdsListener = (checkpoints: Checkpoints) => void;
|
|
|
76
93
|
* @param checkpointId The Id of the checkpoint that changed.
|
|
77
94
|
* @category Listener
|
|
78
95
|
*/
|
|
79
|
-
export type CheckpointListener = (
|
|
80
|
-
checkpoints: Checkpoints
|
|
96
|
+
export type CheckpointListener<Schemas extends OptionalSchemas> = (
|
|
97
|
+
checkpoints: Checkpoints<Schemas>,
|
|
81
98
|
checkpointId: Id,
|
|
82
99
|
) => void;
|
|
83
100
|
|
|
@@ -177,11 +194,17 @@ export type CheckpointsListenerStats = {
|
|
|
177
194
|
* @see Drawing demo
|
|
178
195
|
* @category Checkpoints
|
|
179
196
|
*/
|
|
180
|
-
export interface Checkpoints<Schemas extends OptionalSchemas
|
|
197
|
+
export interface Checkpoints<in out Schemas extends OptionalSchemas> {
|
|
181
198
|
/**
|
|
182
199
|
* The setSize method lets you specify how many checkpoints the Checkpoints
|
|
183
200
|
* object will store.
|
|
184
201
|
*
|
|
202
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
203
|
+
*
|
|
204
|
+
* ```ts override
|
|
205
|
+
* setSize(size: number): Checkpoints;
|
|
206
|
+
* ```
|
|
207
|
+
*
|
|
185
208
|
* If you set more checkpoints than this size, the oldest checkpoints will be
|
|
186
209
|
* pruned to make room for more recent ones.
|
|
187
210
|
*
|
|
@@ -271,6 +294,12 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
271
294
|
* The setCheckpoint method updates the label for a checkpoint in the
|
|
272
295
|
* Checkpoints object after it has been created
|
|
273
296
|
*
|
|
297
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
298
|
+
*
|
|
299
|
+
* ```ts override
|
|
300
|
+
* setCheckpoint(checkpointId: Id, label: string): Checkpoints;
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
274
303
|
* The `label` parameter can be used to describe the actions that changed the
|
|
275
304
|
* Store before the given checkpoint. This can be useful for interfaces that
|
|
276
305
|
* let users 'Undo [last action]'.
|
|
@@ -326,6 +355,12 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
326
355
|
* The getStore method returns a reference to the underlying Store that is
|
|
327
356
|
* backing this Checkpoints object.
|
|
328
357
|
*
|
|
358
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
359
|
+
*
|
|
360
|
+
* ```ts override
|
|
361
|
+
* getStore(): Store;
|
|
362
|
+
* ```
|
|
363
|
+
*
|
|
329
364
|
* @returns A reference to the Store.
|
|
330
365
|
* @example
|
|
331
366
|
* This example creates a Checkpoints object against a newly-created Store
|
|
@@ -491,6 +526,12 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
491
526
|
* Checkpoints object that will be called whenever its set of checkpoints
|
|
492
527
|
* changes.
|
|
493
528
|
*
|
|
529
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
530
|
+
*
|
|
531
|
+
* ```ts override
|
|
532
|
+
* addCheckpointIdsListener(listener: CheckpointIdsListener): Id;
|
|
533
|
+
* ```
|
|
534
|
+
*
|
|
494
535
|
* The provided listener is a CheckpointIdsListener function, and will be
|
|
495
536
|
* called with a reference to the Checkpoints object.
|
|
496
537
|
*
|
|
@@ -534,13 +575,22 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
534
575
|
* ```
|
|
535
576
|
* @category Listener
|
|
536
577
|
*/
|
|
537
|
-
addCheckpointIdsListener(listener: CheckpointIdsListener): Id;
|
|
578
|
+
addCheckpointIdsListener(listener: CheckpointIdsListener<Schemas>): Id;
|
|
538
579
|
|
|
539
580
|
/**
|
|
540
581
|
* The addCheckpointListener method registers a listener function with the
|
|
541
582
|
* Checkpoints object that will be called whenever the label of a checkpoint
|
|
542
583
|
* changes.
|
|
543
584
|
*
|
|
585
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
586
|
+
*
|
|
587
|
+
* ```ts override
|
|
588
|
+
* addCheckpointListener(
|
|
589
|
+
* checkpointId: IdOrNull,
|
|
590
|
+
* listener: CheckpointListener,
|
|
591
|
+
* ): Id;
|
|
592
|
+
* ```
|
|
593
|
+
*
|
|
544
594
|
* You can either listen to a single checkpoint label (by specifying the
|
|
545
595
|
* checkpoint Id as the method's first parameter), or changes to any
|
|
546
596
|
* checkpoint label (by providing a `null` wildcard).
|
|
@@ -596,13 +646,19 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
596
646
|
*/
|
|
597
647
|
addCheckpointListener(
|
|
598
648
|
checkpointId: IdOrNull,
|
|
599
|
-
listener: CheckpointListener
|
|
649
|
+
listener: CheckpointListener<Schemas>,
|
|
600
650
|
): Id;
|
|
601
651
|
|
|
602
652
|
/**
|
|
603
653
|
* The delListener method removes a listener that was previously added to the
|
|
604
654
|
* Checkpoints object.
|
|
605
655
|
*
|
|
656
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
657
|
+
*
|
|
658
|
+
* ```ts override
|
|
659
|
+
* delListener(listenerId: Id): Checkpoints;
|
|
660
|
+
* ```
|
|
661
|
+
*
|
|
606
662
|
* Use the Id returned by the addCheckpointIdsListener method. Note that the
|
|
607
663
|
* Checkpoints object may re-use this Id for future listeners added to it.
|
|
608
664
|
*
|
|
@@ -643,6 +699,12 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
643
699
|
* The goBackward method moves the state of the underlying Store back to the
|
|
644
700
|
* previous checkpoint, effectively performing an 'undo' on the Store data.
|
|
645
701
|
*
|
|
702
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
703
|
+
*
|
|
704
|
+
* ```ts override
|
|
705
|
+
* goBackward(): Checkpoints;
|
|
706
|
+
* ```
|
|
707
|
+
*
|
|
646
708
|
* If there is no previous checkpoint to return to, this method has no effect.
|
|
647
709
|
*
|
|
648
710
|
* @returns A reference to the Checkpoints object.
|
|
@@ -676,6 +738,12 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
676
738
|
* The goForward method moves the state of the underlying Store forwards to a
|
|
677
739
|
* future checkpoint, effectively performing an 'redo' on the Store data.
|
|
678
740
|
*
|
|
741
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
742
|
+
*
|
|
743
|
+
* ```ts override
|
|
744
|
+
* goForward(): Checkpoints;
|
|
745
|
+
* ```
|
|
746
|
+
*
|
|
679
747
|
* If there is no future checkpoint to return to, this method has no effect.
|
|
680
748
|
*
|
|
681
749
|
* Note that if you have previously used the goBackward method to undo
|
|
@@ -756,6 +824,12 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
756
824
|
* The goTo method moves the state of the underlying Store backwards or
|
|
757
825
|
* forwards to a specified checkpoint.
|
|
758
826
|
*
|
|
827
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
828
|
+
*
|
|
829
|
+
* ```ts override
|
|
830
|
+
* goTo(checkpointId: Id): Checkpoints;
|
|
831
|
+
* ```
|
|
832
|
+
*
|
|
759
833
|
* If there is no checkpoint with the Id specified, this method has no effect.
|
|
760
834
|
*
|
|
761
835
|
* @param checkpointId The Id of the checkpoint to move to.
|
|
@@ -806,6 +880,12 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
806
880
|
* The clear method resets this Checkpoints object to its initial state,
|
|
807
881
|
* removing all the checkpoints it has been managing.
|
|
808
882
|
*
|
|
883
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
884
|
+
*
|
|
885
|
+
* ```ts override
|
|
886
|
+
* clear(): Checkpoints;
|
|
887
|
+
* ```
|
|
888
|
+
*
|
|
809
889
|
* Obviously this method should be used with caution as it destroys the
|
|
810
890
|
* ability to undo recent changes to the Store (though of course the Store
|
|
811
891
|
* itself is not reset by this method).
|
|
@@ -928,6 +1008,12 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
928
1008
|
* The createCheckpoints function creates a Checkpoints object, and is the main
|
|
929
1009
|
* entry point into the checkpoints module.
|
|
930
1010
|
*
|
|
1011
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
1012
|
+
*
|
|
1013
|
+
* ```ts override
|
|
1014
|
+
* createCheckpoints(store: Store): Checkpoints;
|
|
1015
|
+
* ```
|
|
1016
|
+
*
|
|
931
1017
|
* A given Store can only have one Checkpoints object associated with it. If you
|
|
932
1018
|
* call this function twice on the same Store, your second call will return a
|
|
933
1019
|
* reference to the Checkpoints object created by the first.
|
|
@@ -11,10 +11,11 @@
|
|
|
11
11
|
* @module indexes
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
import {CellIdFromSchema, TableIdFromSchema} from './internal/store';
|
|
14
15
|
import {
|
|
15
16
|
GetCell,
|
|
16
|
-
NoSchemas,
|
|
17
17
|
OptionalSchemas,
|
|
18
|
+
OptionalTablesSchema,
|
|
18
19
|
RowCallback,
|
|
19
20
|
Store,
|
|
20
21
|
} from './store.d';
|
|
@@ -53,6 +54,15 @@ export type Slice = Ids;
|
|
|
53
54
|
* The IndexCallback type describes a function that takes an Index's Id and a
|
|
54
55
|
* callback to loop over each Slice within it.
|
|
55
56
|
*
|
|
57
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
58
|
+
*
|
|
59
|
+
* ```ts override
|
|
60
|
+
* (
|
|
61
|
+
* indexId: Id,
|
|
62
|
+
* forEachSlice: (sliceCallback: SliceCallback) => void,
|
|
63
|
+
* ) => void;
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
56
66
|
* A IndexCallback is provided when using the forEachIndex method, so that you
|
|
57
67
|
* can do something based on every Index in the Indexes object. See that method
|
|
58
68
|
* for specific examples.
|
|
@@ -62,15 +72,24 @@ export type Slice = Ids;
|
|
|
62
72
|
* in this Index.
|
|
63
73
|
* @category Callback
|
|
64
74
|
*/
|
|
65
|
-
export type IndexCallback = (
|
|
75
|
+
export type IndexCallback<Schema extends OptionalTablesSchema> = (
|
|
66
76
|
indexId: Id,
|
|
67
|
-
forEachSlice: (sliceCallback: SliceCallback) => void,
|
|
77
|
+
forEachSlice: (sliceCallback: SliceCallback<Schema>) => void,
|
|
68
78
|
) => void;
|
|
69
79
|
|
|
70
80
|
/**
|
|
71
81
|
* The SliceCallback type describes a function that takes a Slice's Id and a
|
|
72
82
|
* callback to loop over each Row within it.
|
|
73
83
|
*
|
|
84
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
85
|
+
*
|
|
86
|
+
* ```ts override
|
|
87
|
+
* (
|
|
88
|
+
* sliceId: Id,
|
|
89
|
+
* forEachRow: (rowCallback: RowCallback) => void,
|
|
90
|
+
* ) => void;
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
74
93
|
* A SliceCallback is provided when using the forEachSlice method, so that you
|
|
75
94
|
* can do something based on every Slice in an Index. See that method for
|
|
76
95
|
* specific examples.
|
|
@@ -80,15 +99,21 @@ export type IndexCallback = (
|
|
|
80
99
|
* in this Slice.
|
|
81
100
|
* @category Callback
|
|
82
101
|
*/
|
|
83
|
-
export type SliceCallback = (
|
|
102
|
+
export type SliceCallback<Schema extends OptionalTablesSchema> = (
|
|
84
103
|
sliceId: Id,
|
|
85
|
-
forEachRow: (rowCallback: RowCallback) => void,
|
|
104
|
+
forEachRow: (rowCallback: RowCallback<Schema>) => void,
|
|
86
105
|
) => void;
|
|
87
106
|
|
|
88
107
|
/**
|
|
89
108
|
* The SliceIdsListener type describes a function that is used to listen to
|
|
90
109
|
* changes to the Slice Ids in an Index.
|
|
91
110
|
*
|
|
111
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
112
|
+
*
|
|
113
|
+
* ```ts override
|
|
114
|
+
* (indexes: Indexes, indexId: Id) => void;
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
92
117
|
* A SliceIdsListener is provided when using the addSliceIdsListener method. See
|
|
93
118
|
* that method for specific examples.
|
|
94
119
|
*
|
|
@@ -99,12 +124,25 @@ export type SliceCallback = (
|
|
|
99
124
|
* @param indexId The Id of the Index that changed.
|
|
100
125
|
* @category Listener
|
|
101
126
|
*/
|
|
102
|
-
export type SliceIdsListener = (
|
|
127
|
+
export type SliceIdsListener<Schemas extends OptionalSchemas> = (
|
|
128
|
+
indexes: Indexes<Schemas>,
|
|
129
|
+
indexId: Id,
|
|
130
|
+
) => void;
|
|
103
131
|
|
|
104
132
|
/**
|
|
105
133
|
* The SliceRowIdsListener type describes a function that is used to listen to
|
|
106
134
|
* changes to the Row Ids in a Slice.
|
|
107
135
|
*
|
|
136
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
137
|
+
*
|
|
138
|
+
* ```ts override
|
|
139
|
+
* (
|
|
140
|
+
* indexes: Indexes,
|
|
141
|
+
* indexId: Id,
|
|
142
|
+
* sliceId: Id,
|
|
143
|
+
* ) => void;
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
108
146
|
* A SliceRowIdsListener is provided when using the addSliceRowIdsListener
|
|
109
147
|
* method. See that method for specific examples.
|
|
110
148
|
*
|
|
@@ -117,8 +155,8 @@ export type SliceIdsListener = (indexes: Indexes, indexId: Id) => void;
|
|
|
117
155
|
* @param sliceId The Id of the Slice that changed.
|
|
118
156
|
* @category Listener
|
|
119
157
|
*/
|
|
120
|
-
export type SliceRowIdsListener = (
|
|
121
|
-
indexes: Indexes
|
|
158
|
+
export type SliceRowIdsListener<Schemas extends OptionalSchemas> = (
|
|
159
|
+
indexes: Indexes<Schemas>,
|
|
122
160
|
indexId: Id,
|
|
123
161
|
sliceId: Id,
|
|
124
162
|
) => void;
|
|
@@ -201,10 +239,23 @@ export type IndexesListenerStats = {
|
|
|
201
239
|
* @see Word Frequencies demo
|
|
202
240
|
* @category Indexes
|
|
203
241
|
*/
|
|
204
|
-
export interface Indexes<Schemas extends OptionalSchemas
|
|
242
|
+
export interface Indexes<in out Schemas extends OptionalSchemas> {
|
|
205
243
|
/**
|
|
206
244
|
* The setIndexDefinition method lets you set the definition of an Index.
|
|
207
245
|
*
|
|
246
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
247
|
+
*
|
|
248
|
+
* ```ts override
|
|
249
|
+
* setIndexDefinition(
|
|
250
|
+
* indexId: Id,
|
|
251
|
+
* tableId: Id,
|
|
252
|
+
* getSliceIdOrIds?: Id | ((getCell: GetCell, rowId: Id) => Id | Ids),
|
|
253
|
+
* getSortKey?: Id | ((getCell: GetCell, rowId: Id) => SortKey),
|
|
254
|
+
* sliceIdSorter?: (sliceId1: Id, sliceId2: Id) => number,
|
|
255
|
+
* rowIdSorter?: (sortKey1: SortKey, sortKey2: SortKey, sliceId: Id) => number,
|
|
256
|
+
* ): Indexes;
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
208
259
|
* Every Index definition is identified by a unique Id, and if you re-use an
|
|
209
260
|
* existing Id with this method, the previous definition is overwritten.
|
|
210
261
|
*
|
|
@@ -354,11 +405,15 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
354
405
|
* ```
|
|
355
406
|
* @category Configuration
|
|
356
407
|
*/
|
|
357
|
-
setIndexDefinition(
|
|
408
|
+
setIndexDefinition<TableId extends TableIdFromSchema<Schemas[0]>>(
|
|
358
409
|
indexId: Id,
|
|
359
|
-
tableId:
|
|
360
|
-
getSliceIdOrIds?:
|
|
361
|
-
|
|
410
|
+
tableId: TableId,
|
|
411
|
+
getSliceIdOrIds?:
|
|
412
|
+
| CellIdFromSchema<Schemas[0], TableId>
|
|
413
|
+
| ((getCell: GetCell<Schemas[0], TableId>, rowId: Id) => Id | Ids),
|
|
414
|
+
getSortKey?:
|
|
415
|
+
| CellIdFromSchema<Schemas[0], TableId>
|
|
416
|
+
| ((getCell: GetCell<Schemas[0], TableId>, rowId: Id) => SortKey),
|
|
362
417
|
sliceIdSorter?: (sliceId1: Id, sliceId2: Id) => number,
|
|
363
418
|
rowIdSorter?: (sortKey1: SortKey, sortKey2: SortKey, sliceId: Id) => number,
|
|
364
419
|
): Indexes<Schemas>;
|
|
@@ -366,6 +421,12 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
366
421
|
/**
|
|
367
422
|
* The delIndexDefinition method removes an existing Index definition.
|
|
368
423
|
*
|
|
424
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
425
|
+
*
|
|
426
|
+
* ```ts override
|
|
427
|
+
* delIndexDefinition(indexId: Id): Indexes;
|
|
428
|
+
* ```
|
|
429
|
+
*
|
|
369
430
|
* @param indexId The Id of the Index to remove.
|
|
370
431
|
* @returns A reference to the Indexes object.
|
|
371
432
|
* @example
|
|
@@ -396,6 +457,12 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
396
457
|
* The getStore method returns a reference to the underlying Store that is
|
|
397
458
|
* backing this Indexes object.
|
|
398
459
|
*
|
|
460
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
461
|
+
*
|
|
462
|
+
* ```ts override
|
|
463
|
+
* getStore(): Store;
|
|
464
|
+
* ```
|
|
465
|
+
*
|
|
399
466
|
* @returns A reference to the Store.
|
|
400
467
|
* @example
|
|
401
468
|
* This example creates an Indexes object against a newly-created Store and
|
|
@@ -437,6 +504,12 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
437
504
|
* The forEachIndex method takes a function that it will then call for each
|
|
438
505
|
* Index in a specified Indexes object.
|
|
439
506
|
*
|
|
507
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
508
|
+
*
|
|
509
|
+
* ```ts override
|
|
510
|
+
* forEachIndex(indexCallback: IndexCallback): void;
|
|
511
|
+
* ```
|
|
512
|
+
*
|
|
440
513
|
* This method is useful for iterating over the structure of the Indexes
|
|
441
514
|
* object in a functional style. The `indexCallback` parameter is a
|
|
442
515
|
* IndexCallback function that will be called with the Id of each Index, and
|
|
@@ -471,12 +544,18 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
471
544
|
* ```
|
|
472
545
|
* @category Iterator
|
|
473
546
|
*/
|
|
474
|
-
forEachIndex(indexCallback: IndexCallback): void;
|
|
547
|
+
forEachIndex(indexCallback: IndexCallback<Schemas[0]>): void;
|
|
475
548
|
|
|
476
549
|
/**
|
|
477
550
|
* The forEachSlice method takes a function that it will then call for each
|
|
478
551
|
* Slice in a specified Index.
|
|
479
552
|
*
|
|
553
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
554
|
+
*
|
|
555
|
+
* ```ts override
|
|
556
|
+
* forEachSlice(indexId: Id, sliceCallback: SliceCallback): void;
|
|
557
|
+
* ```
|
|
558
|
+
*
|
|
480
559
|
* This method is useful for iterating over the Slice structure of the Index
|
|
481
560
|
* in a functional style. The `rowCallback` parameter is a RowCallback
|
|
482
561
|
* function that will be called with the Id and value of each Row in the
|
|
@@ -508,7 +587,7 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
508
587
|
* ```
|
|
509
588
|
* @category Iterator
|
|
510
589
|
*/
|
|
511
|
-
forEachSlice(indexId: Id, sliceCallback: SliceCallback): void;
|
|
590
|
+
forEachSlice(indexId: Id, sliceCallback: SliceCallback<Schemas[0]>): void;
|
|
512
591
|
|
|
513
592
|
/**
|
|
514
593
|
* The hasIndex method returns a boolean indicating whether a given Index
|
|
@@ -562,6 +641,12 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
562
641
|
* The getTableId method returns the Id of the underlying Table that is
|
|
563
642
|
* backing an Index.
|
|
564
643
|
*
|
|
644
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
645
|
+
*
|
|
646
|
+
* ```ts override
|
|
647
|
+
* getTableId(indexId: Id): Id | undefined;
|
|
648
|
+
* ```
|
|
649
|
+
*
|
|
565
650
|
* If the Index Id is invalid, the method returns `undefined`.
|
|
566
651
|
*
|
|
567
652
|
* @param indexId The Id of an Index.
|
|
@@ -581,7 +666,9 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
581
666
|
* ```
|
|
582
667
|
* @category Getter
|
|
583
668
|
*/
|
|
584
|
-
getTableId
|
|
669
|
+
getTableId<TableId extends TableIdFromSchema<Schemas[0]>>(
|
|
670
|
+
indexId: Id,
|
|
671
|
+
): TableId | undefined;
|
|
585
672
|
|
|
586
673
|
/**
|
|
587
674
|
* The getSliceIds method gets the list of Slice Ids in an Index.
|
|
@@ -656,6 +743,12 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
656
743
|
* Indexes object that will be called whenever the Slice Ids in an Index
|
|
657
744
|
* change.
|
|
658
745
|
*
|
|
746
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
747
|
+
*
|
|
748
|
+
* ```ts override
|
|
749
|
+
* addSliceIdsListener(indexId: IdOrNull, listener: SliceIdsListener): Id;
|
|
750
|
+
* ```
|
|
751
|
+
*
|
|
659
752
|
* You can either listen to a single Index (by specifying the Index Id as the
|
|
660
753
|
* method's first parameter), or changes to any Index (by providing a `null`
|
|
661
754
|
* wildcard).
|
|
@@ -729,12 +822,25 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
729
822
|
* ```
|
|
730
823
|
* @category Listener
|
|
731
824
|
*/
|
|
732
|
-
addSliceIdsListener(
|
|
825
|
+
addSliceIdsListener(
|
|
826
|
+
indexId: IdOrNull,
|
|
827
|
+
listener: SliceIdsListener<Schemas>,
|
|
828
|
+
): Id;
|
|
733
829
|
|
|
734
830
|
/**
|
|
735
831
|
* The addSliceRowIdsListener method registers a listener function with the
|
|
736
832
|
* Indexes object that will be called whenever the Row Ids in a Slice change.
|
|
737
833
|
*
|
|
834
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
835
|
+
*
|
|
836
|
+
* ```ts override
|
|
837
|
+
* addSliceRowIdsListener(
|
|
838
|
+
* indexId: IdOrNull,
|
|
839
|
+
* sliceId: IdOrNull,
|
|
840
|
+
* listener: SliceRowIdsListener,
|
|
841
|
+
* ): Id;
|
|
842
|
+
* ```
|
|
843
|
+
*
|
|
738
844
|
* You can either listen to a single Slice (by specifying the Index Id and
|
|
739
845
|
* Slice Id as the method's first two parameters), or changes to any Slice (by
|
|
740
846
|
* providing `null` wildcards).
|
|
@@ -821,13 +927,19 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
821
927
|
addSliceRowIdsListener(
|
|
822
928
|
indexId: IdOrNull,
|
|
823
929
|
sliceId: IdOrNull,
|
|
824
|
-
listener: SliceRowIdsListener
|
|
930
|
+
listener: SliceRowIdsListener<Schemas>,
|
|
825
931
|
): Id;
|
|
826
932
|
|
|
827
933
|
/**
|
|
828
934
|
* The delListener method removes a listener that was previously added to the
|
|
829
935
|
* Indexes object.
|
|
830
936
|
*
|
|
937
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
938
|
+
*
|
|
939
|
+
* ```ts override
|
|
940
|
+
* delListener(listenerId: Id): Indexes;
|
|
941
|
+
* ```
|
|
942
|
+
*
|
|
831
943
|
* Use the Id returned by whichever method was used to add the listener. Note
|
|
832
944
|
* that the Indexes object may re-use this Id for future listeners added to
|
|
833
945
|
* it.
|
|
@@ -941,6 +1053,12 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
941
1053
|
* The createIndexes function creates an Indexes object, and is the main entry
|
|
942
1054
|
* point into the indexes module.
|
|
943
1055
|
*
|
|
1056
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
1057
|
+
*
|
|
1058
|
+
* ```ts override
|
|
1059
|
+
* createIndexes(store: Store): Indexes;
|
|
1060
|
+
* ```
|
|
1061
|
+
*
|
|
944
1062
|
* A given Store can only have one Indexes object associated with it. If you
|
|
945
1063
|
* call this function twice on the same Store, your second call will return a
|
|
946
1064
|
* reference to the Indexes object created by the first.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {CellIdFromSchema, TableIdFromSchema} from './store';
|
|
2
|
+
import {NoTablesSchema, OptionalTablesSchema} from '../store';
|
|
3
|
+
import {Id} from '../common';
|
|
4
|
+
import {ResultCell} from '../queries';
|
|
5
|
+
|
|
6
|
+
export type JoinedCellIdOrId<
|
|
7
|
+
Schema extends OptionalTablesSchema = NoTablesSchema,
|
|
8
|
+
JoinedTableId extends TableIdFromSchema<Schema> | Id =
|
|
9
|
+
| TableIdFromSchema<Schema>
|
|
10
|
+
| Id,
|
|
11
|
+
> = JoinedTableId extends TableIdFromSchema<Schema>
|
|
12
|
+
? CellIdFromSchema<Schema, JoinedTableId>
|
|
13
|
+
: Id;
|
|
14
|
+
|
|
15
|
+
export type GetResultCell = (cellId: Id) => ResultCell;
|