tinybase 3.1.0-beta.4 → 3.1.0-beta.5
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/{cjs-es6 → types}/checkpoints.d.ts +11 -13
- package/lib/{debug → types}/indexes.d.ts +8 -16
- package/lib/{debug → types}/metrics.d.ts +47 -50
- package/lib/{cjs → types}/persisters.d.ts +24 -30
- package/lib/{cjs-es6 → types}/queries.d.ts +472 -309
- package/lib/{debug → types}/relationships.d.ts +9 -17
- package/lib/{cjs-es6 → types}/store.d.ts +176 -1084
- package/lib/types/tinybase.d.ts +14 -0
- package/lib/{cjs-es6 → types}/tools.d.ts +7 -12
- package/lib/{debug → types}/ui-react.d.ts +11 -5
- package/lib/{checkpoints.d.ts → types/with-schemas/checkpoints.d.ts} +9 -7
- package/lib/{cjs → types/with-schemas}/indexes.d.ts +31 -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 +54 -50
- package/lib/{debug → types/with-schemas}/persisters.d.ts +4 -4
- package/lib/{debug → types/with-schemas}/queries.d.ts +607 -346
- package/lib/{cjs → types/with-schemas}/relationships.d.ts +29 -20
- package/lib/{debug → types/with-schemas}/store.d.ts +386 -829
- package/lib/types/with-schemas/tinybase.d.ts +14 -0
- package/lib/{debug → types/with-schemas}/tools.d.ts +7 -10
- package/lib/{cjs-es6 → types/with-schemas}/ui-react.d.ts +817 -1314
- package/package.json +145 -29
- package/readme.md +3 -3
- 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
package/lib/debug/ui-react.js
CHANGED
|
@@ -136,8 +136,8 @@ const useSetCallback = (
|
|
|
136
136
|
return useCallback(
|
|
137
137
|
(parameter) =>
|
|
138
138
|
ifNotUndefined(store, (store2) =>
|
|
139
|
-
ifNotUndefined(get(parameter, store2), (
|
|
140
|
-
then(store2['set' + settable](...args,
|
|
139
|
+
ifNotUndefined(get(parameter, store2), (thing) =>
|
|
140
|
+
then(store2['set' + settable](...args, thing), thing),
|
|
141
141
|
),
|
|
142
142
|
),
|
|
143
143
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import {Id, IdOrNull, Ids} from './common.d';
|
|
15
|
-
import {
|
|
15
|
+
import {Store} from './store.d';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The CheckpointIds type is a representation of the list of checkpoint Ids
|
|
@@ -177,7 +177,7 @@ export type CheckpointsListenerStats = {
|
|
|
177
177
|
* @see Drawing demo
|
|
178
178
|
* @category Checkpoints
|
|
179
179
|
*/
|
|
180
|
-
export interface Checkpoints
|
|
180
|
+
export interface Checkpoints {
|
|
181
181
|
/**
|
|
182
182
|
* The setSize method lets you specify how many checkpoints the Checkpoints
|
|
183
183
|
* object will store.
|
|
@@ -220,7 +220,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
220
220
|
* ```
|
|
221
221
|
* @category Configuration
|
|
222
222
|
*/
|
|
223
|
-
setSize(size: number): Checkpoints
|
|
223
|
+
setSize(size: number): Checkpoints;
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
226
|
* The addCheckpoint method records a checkpoint of the Store into the
|
|
@@ -320,7 +320,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
320
320
|
* ```
|
|
321
321
|
* @category Setter
|
|
322
322
|
*/
|
|
323
|
-
setCheckpoint(checkpointId: Id, label: string): Checkpoints
|
|
323
|
+
setCheckpoint(checkpointId: Id, label: string): Checkpoints;
|
|
324
324
|
|
|
325
325
|
/**
|
|
326
326
|
* The getStore method returns a reference to the underlying Store that is
|
|
@@ -341,7 +341,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
341
341
|
* ```
|
|
342
342
|
* @category Getter
|
|
343
343
|
*/
|
|
344
|
-
getStore(): Store
|
|
344
|
+
getStore(): Store;
|
|
345
345
|
|
|
346
346
|
/**
|
|
347
347
|
* The getCheckpointIds method returns an array of the checkpoint Ids being
|
|
@@ -637,7 +637,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
637
637
|
* ```
|
|
638
638
|
* @category Listener
|
|
639
639
|
*/
|
|
640
|
-
delListener(listenerId: Id): Checkpoints
|
|
640
|
+
delListener(listenerId: Id): Checkpoints;
|
|
641
641
|
|
|
642
642
|
/**
|
|
643
643
|
* The goBackward method moves the state of the underlying Store back to the
|
|
@@ -670,7 +670,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
670
670
|
* ```
|
|
671
671
|
* @category Movement
|
|
672
672
|
*/
|
|
673
|
-
goBackward(): Checkpoints
|
|
673
|
+
goBackward(): Checkpoints;
|
|
674
674
|
|
|
675
675
|
/**
|
|
676
676
|
* The goForward method moves the state of the underlying Store forwards to a
|
|
@@ -750,7 +750,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
750
750
|
* ```
|
|
751
751
|
* @category Movement
|
|
752
752
|
*/
|
|
753
|
-
goForward(): Checkpoints
|
|
753
|
+
goForward(): Checkpoints;
|
|
754
754
|
|
|
755
755
|
/**
|
|
756
756
|
* The goTo method moves the state of the underlying Store backwards or
|
|
@@ -800,7 +800,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
800
800
|
* ```
|
|
801
801
|
* @category Movement
|
|
802
802
|
*/
|
|
803
|
-
goTo(checkpointId: Id): Checkpoints
|
|
803
|
+
goTo(checkpointId: Id): Checkpoints;
|
|
804
804
|
|
|
805
805
|
/**
|
|
806
806
|
* The clear method resets this Checkpoints object to its initial state,
|
|
@@ -858,7 +858,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
858
858
|
* ```
|
|
859
859
|
* @category Lifecycle
|
|
860
860
|
*/
|
|
861
|
-
clear(): Checkpoints
|
|
861
|
+
clear(): Checkpoints;
|
|
862
862
|
|
|
863
863
|
/**
|
|
864
864
|
* The destroy method should be called when this Checkpoints object is no
|
|
@@ -956,6 +956,4 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
956
956
|
* ```
|
|
957
957
|
* @category Creation
|
|
958
958
|
*/
|
|
959
|
-
export function createCheckpoints
|
|
960
|
-
store: Store<Schemas>,
|
|
961
|
-
): Checkpoints<Schemas>;
|
|
959
|
+
export function createCheckpoints(store: Store): Checkpoints;
|
|
@@ -11,13 +11,7 @@
|
|
|
11
11
|
* @module indexes
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
GetCell,
|
|
16
|
-
NoSchemas,
|
|
17
|
-
OptionalSchemas,
|
|
18
|
-
RowCallback,
|
|
19
|
-
Store,
|
|
20
|
-
} from './store.d';
|
|
14
|
+
import {GetCell, RowCallback, Store} from './store.d';
|
|
21
15
|
import {Id, IdOrNull, Ids, SortKey} from './common.d';
|
|
22
16
|
|
|
23
17
|
/**
|
|
@@ -201,7 +195,7 @@ export type IndexesListenerStats = {
|
|
|
201
195
|
* @see Word Frequencies demo
|
|
202
196
|
* @category Indexes
|
|
203
197
|
*/
|
|
204
|
-
export interface Indexes
|
|
198
|
+
export interface Indexes {
|
|
205
199
|
/**
|
|
206
200
|
* The setIndexDefinition method lets you set the definition of an Index.
|
|
207
201
|
*
|
|
@@ -361,7 +355,7 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
361
355
|
getSortKey?: Id | ((getCell: GetCell, rowId: Id) => SortKey),
|
|
362
356
|
sliceIdSorter?: (sliceId1: Id, sliceId2: Id) => number,
|
|
363
357
|
rowIdSorter?: (sortKey1: SortKey, sortKey2: SortKey, sliceId: Id) => number,
|
|
364
|
-
): Indexes
|
|
358
|
+
): Indexes;
|
|
365
359
|
|
|
366
360
|
/**
|
|
367
361
|
* The delIndexDefinition method removes an existing Index definition.
|
|
@@ -390,7 +384,7 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
390
384
|
* ```
|
|
391
385
|
* @category Configuration
|
|
392
386
|
*/
|
|
393
|
-
delIndexDefinition(indexId: Id): Indexes
|
|
387
|
+
delIndexDefinition(indexId: Id): Indexes;
|
|
394
388
|
|
|
395
389
|
/**
|
|
396
390
|
* The getStore method returns a reference to the underlying Store that is
|
|
@@ -410,7 +404,7 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
410
404
|
* ```
|
|
411
405
|
* @category Getter
|
|
412
406
|
*/
|
|
413
|
-
getStore(): Store
|
|
407
|
+
getStore(): Store;
|
|
414
408
|
|
|
415
409
|
/**
|
|
416
410
|
* The getIndexIds method returns an array of the Index Ids registered with
|
|
@@ -581,7 +575,7 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
581
575
|
* ```
|
|
582
576
|
* @category Getter
|
|
583
577
|
*/
|
|
584
|
-
getTableId(indexId: Id): Id;
|
|
578
|
+
getTableId(indexId: Id): Id | undefined;
|
|
585
579
|
|
|
586
580
|
/**
|
|
587
581
|
* The getSliceIds method gets the list of Slice Ids in an Index.
|
|
@@ -866,7 +860,7 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
866
860
|
* ```
|
|
867
861
|
* @category Listener
|
|
868
862
|
*/
|
|
869
|
-
delListener(listenerId: Id): Indexes
|
|
863
|
+
delListener(listenerId: Id): Indexes;
|
|
870
864
|
|
|
871
865
|
/**
|
|
872
866
|
* The destroy method should be called when this Indexes object is no longer
|
|
@@ -969,6 +963,4 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
969
963
|
* ```
|
|
970
964
|
* @category Creation
|
|
971
965
|
*/
|
|
972
|
-
export function createIndexes
|
|
973
|
-
store: Store<Schemas>,
|
|
974
|
-
): Indexes<Schemas>;
|
|
966
|
+
export function createIndexes(store: Store): Indexes;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The metrics module of the TinyBase project provides the ability to create
|
|
3
|
-
*
|
|
2
|
+
* The metrics module of the TinyBase project provides the ability to create and
|
|
3
|
+
* track metrics and aggregates of the data in Store objects.
|
|
4
4
|
*
|
|
5
5
|
* The main entry point to this module is the createMetrics function, which
|
|
6
6
|
* returns a new Metrics object. From there, you can create new Metric
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @module metrics
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import {GetCell,
|
|
14
|
+
import {GetCell, Store} from './store.d';
|
|
15
15
|
import {Id, IdOrNull, Ids} from './common.d';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -37,8 +37,8 @@ export type Metric = number;
|
|
|
37
37
|
export type MetricCallback = (metricId: Id, metric?: Metric) => void;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* The
|
|
41
|
-
* and returns an aggregate that is used as a Metric.
|
|
40
|
+
* The MetricAggregate type describes a custom function that takes an array of
|
|
41
|
+
* numbers and returns an aggregate that is used as a Metric.
|
|
42
42
|
*
|
|
43
43
|
* There are a number of common predefined aggregators, such as for counting,
|
|
44
44
|
* summing, and averaging values. This type is instead used for when you wish to
|
|
@@ -50,12 +50,12 @@ export type MetricCallback = (metricId: Id, metric?: Metric) => void;
|
|
|
50
50
|
* @returns The value of the Metric.
|
|
51
51
|
* @category Aggregators
|
|
52
52
|
*/
|
|
53
|
-
export type
|
|
53
|
+
export type MetricAggregate = (numbers: number[], length: number) => Metric;
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* The
|
|
57
|
-
* custom
|
|
58
|
-
* the input values.
|
|
56
|
+
* The MetricAggregateAdd type describes a function that can be used to optimize
|
|
57
|
+
* a custom MetricAggregate by providing a shortcut for when a single value is
|
|
58
|
+
* added to the input values.
|
|
59
59
|
*
|
|
60
60
|
* Some aggregation functions do not need to recalculate the aggregation of the
|
|
61
61
|
* whole set when one value changes. For example, when adding a new number to a
|
|
@@ -65,10 +65,10 @@ export type Aggregate = (numbers: number[], length: number) => Metric;
|
|
|
65
65
|
* being added, return `undefined` and the Metric will be completely
|
|
66
66
|
* recalculated.
|
|
67
67
|
*
|
|
68
|
-
* Where possible, if you are providing a custom
|
|
69
|
-
* implementation of an
|
|
70
|
-
* cost of growing the input data set. See the setMetricDefinition
|
|
71
|
-
* more examples.
|
|
68
|
+
* Where possible, if you are providing a custom MetricAggregate, seek an
|
|
69
|
+
* implementation of an MetricAggregateAdd function that can reduce the
|
|
70
|
+
* complexity cost of growing the input data set. See the setMetricDefinition
|
|
71
|
+
* method for more examples.
|
|
72
72
|
*
|
|
73
73
|
* @param metric The current value of the Metric.
|
|
74
74
|
* @param add The number being added to the Metric's aggregation.
|
|
@@ -76,16 +76,16 @@ export type Aggregate = (numbers: number[], length: number) => Metric;
|
|
|
76
76
|
* @returns The new value of the Metric.
|
|
77
77
|
* @category Aggregators
|
|
78
78
|
*/
|
|
79
|
-
export type
|
|
79
|
+
export type MetricAggregateAdd = (
|
|
80
80
|
metric: Metric,
|
|
81
81
|
add: number,
|
|
82
82
|
length: number,
|
|
83
83
|
) => Metric | undefined;
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* The
|
|
87
|
-
* custom
|
|
88
|
-
* from the input values.
|
|
86
|
+
* The MetricAggregateRemove type describes a function that can be used to
|
|
87
|
+
* optimize a custom MetricAggregate by providing a shortcut for when a single
|
|
88
|
+
* value is removed from the input values.
|
|
89
89
|
*
|
|
90
90
|
* Some aggregation functions do not need to recalculate the aggregation of the
|
|
91
91
|
* whole set when one value changes. For example, when removing a number from a
|
|
@@ -98,10 +98,10 @@ export type AggregateAdd = (
|
|
|
98
98
|
* values, and the previous minimum is being removed. The whole of the rest of
|
|
99
99
|
* the list will need to be re-scanned to find a new minimum.
|
|
100
100
|
*
|
|
101
|
-
* Where possible, if you are providing a custom
|
|
102
|
-
* implementation of an
|
|
103
|
-
* cost of shrinking the input data set. See the setMetricDefinition
|
|
104
|
-
* more examples.
|
|
101
|
+
* Where possible, if you are providing a custom MetricAggregate, seek an
|
|
102
|
+
* implementation of an MetricAggregateRemove function that can reduce the
|
|
103
|
+
* complexity cost of shrinking the input data set. See the setMetricDefinition
|
|
104
|
+
* method for more examples.
|
|
105
105
|
*
|
|
106
106
|
* @param metric The current value of the Metric.
|
|
107
107
|
* @param remove The number being removed from the Metric's aggregation.
|
|
@@ -109,16 +109,16 @@ export type AggregateAdd = (
|
|
|
109
109
|
* @returns The new value of the Metric.
|
|
110
110
|
* @category Aggregators
|
|
111
111
|
*/
|
|
112
|
-
export type
|
|
112
|
+
export type MetricAggregateRemove = (
|
|
113
113
|
metric: Metric,
|
|
114
114
|
remove: number,
|
|
115
115
|
length: number,
|
|
116
116
|
) => Metric | undefined;
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
* The
|
|
120
|
-
* custom
|
|
121
|
-
* values is replaced with another.
|
|
119
|
+
* The MetricAggregateReplace type describes a function that can be used to
|
|
120
|
+
* optimize a custom MetricAggregate by providing a shortcut for when a single
|
|
121
|
+
* value in the input values is replaced with another.
|
|
122
122
|
*
|
|
123
123
|
* Some aggregation functions do not need to recalculate the aggregation of the
|
|
124
124
|
* whole set when one value changes. For example, when replacing a number in a
|
|
@@ -126,13 +126,12 @@ export type AggregateRemove = (
|
|
|
126
126
|
* minus the old value.
|
|
127
127
|
*
|
|
128
128
|
* If it is not possible to shortcut the aggregation based on just one value
|
|
129
|
-
* changing, return `undefined` and the Metric will be completely
|
|
130
|
-
* recalculated.
|
|
129
|
+
* changing, return `undefined` and the Metric will be completely recalculated.
|
|
131
130
|
*
|
|
132
|
-
* Where possible, if you are providing a custom
|
|
133
|
-
* implementation of an
|
|
134
|
-
* cost of changing the input data set in place. See the
|
|
135
|
-
* method for more examples.
|
|
131
|
+
* Where possible, if you are providing a custom MetricAggregate, seek an
|
|
132
|
+
* implementation of an MetricAggregateReplace function that can reduce the
|
|
133
|
+
* complexity cost of changing the input data set in place. See the
|
|
134
|
+
* setMetricDefinition method for more examples.
|
|
136
135
|
*
|
|
137
136
|
* @param metric The current value of the Metric.
|
|
138
137
|
* @param add The number being added to the Metric's aggregation.
|
|
@@ -141,7 +140,7 @@ export type AggregateRemove = (
|
|
|
141
140
|
* @returns The new value of the Metric.
|
|
142
141
|
* @category Aggregators
|
|
143
142
|
*/
|
|
144
|
-
export type
|
|
143
|
+
export type MetricAggregateReplace = (
|
|
145
144
|
metric: Metric,
|
|
146
145
|
add: number,
|
|
147
146
|
remove: number,
|
|
@@ -246,7 +245,7 @@ export type MetricsListenerStats = {
|
|
|
246
245
|
* @see Todo App demos
|
|
247
246
|
* @category Metrics
|
|
248
247
|
*/
|
|
249
|
-
export interface Metrics
|
|
248
|
+
export interface Metrics {
|
|
250
249
|
/**
|
|
251
250
|
* The setMetricDefinition method lets you set the definition of a Metric.
|
|
252
251
|
*
|
|
@@ -287,14 +286,14 @@ export interface Metrics<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
287
286
|
* that if the `aggregate` and `getNumber` parameters are both omitted, the
|
|
288
287
|
* Metric will simply be a count of the Row objects in the Table).
|
|
289
288
|
* @param aggregateAdd A function that can be used to optimize a custom
|
|
290
|
-
*
|
|
291
|
-
* input values - for example, when a Row is added to the Table.
|
|
289
|
+
* MetricAggregate by providing a shortcut for when a single value is added to
|
|
290
|
+
* the input values - for example, when a Row is added to the Table.
|
|
292
291
|
* @param aggregateRemove A function that can be used to optimize a custom
|
|
293
|
-
*
|
|
294
|
-
* the input values - for example ,when a Row is removed from the Table.
|
|
292
|
+
* MetricAggregate by providing a shortcut for when a single value is removed
|
|
293
|
+
* from the input values - for example ,when a Row is removed from the Table.
|
|
295
294
|
* @param aggregateReplace A function that can be used to optimize a custom
|
|
296
|
-
*
|
|
297
|
-
* values is replaced with another - for example, when a Row is updated.
|
|
295
|
+
* MetricAggregate by providing a shortcut for when a single value in the
|
|
296
|
+
* input values is replaced with another - for example, when a Row is updated.
|
|
298
297
|
* @returns A reference to the Metrics object.
|
|
299
298
|
* @example
|
|
300
299
|
* This example creates a Store, creates a Metrics object, and defines a
|
|
@@ -415,12 +414,12 @@ export interface Metrics<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
415
414
|
setMetricDefinition(
|
|
416
415
|
metricId: Id,
|
|
417
416
|
tableId: Id,
|
|
418
|
-
aggregate?: 'sum' | 'avg' | 'min' | 'max' |
|
|
417
|
+
aggregate?: 'sum' | 'avg' | 'min' | 'max' | MetricAggregate,
|
|
419
418
|
getNumber?: Id | ((getCell: GetCell, rowId: Id) => number),
|
|
420
|
-
aggregateAdd?:
|
|
421
|
-
aggregateRemove?:
|
|
422
|
-
aggregateReplace?:
|
|
423
|
-
): Metrics
|
|
419
|
+
aggregateAdd?: MetricAggregateAdd,
|
|
420
|
+
aggregateRemove?: MetricAggregateRemove,
|
|
421
|
+
aggregateReplace?: MetricAggregateReplace,
|
|
422
|
+
): Metrics;
|
|
424
423
|
|
|
425
424
|
/**
|
|
426
425
|
* The delMetricDefinition method removes an existing Metric definition.
|
|
@@ -449,7 +448,7 @@ export interface Metrics<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
449
448
|
* ```
|
|
450
449
|
* @category Configuration
|
|
451
450
|
*/
|
|
452
|
-
delMetricDefinition(metricId: Id): Metrics
|
|
451
|
+
delMetricDefinition(metricId: Id): Metrics;
|
|
453
452
|
|
|
454
453
|
/**
|
|
455
454
|
* The getStore method returns a reference to the underlying Store that is
|
|
@@ -469,7 +468,7 @@ export interface Metrics<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
469
468
|
* ```
|
|
470
469
|
* @category Getter
|
|
471
470
|
*/
|
|
472
|
-
getStore(): Store
|
|
471
|
+
getStore(): Store;
|
|
473
472
|
|
|
474
473
|
/**
|
|
475
474
|
* The getMetricIds method returns an array of the Metric Ids registered with
|
|
@@ -729,7 +728,7 @@ export interface Metrics<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
729
728
|
* ```
|
|
730
729
|
* @category Listener
|
|
731
730
|
*/
|
|
732
|
-
delListener(listenerId: Id): Metrics
|
|
731
|
+
delListener(listenerId: Id): Metrics;
|
|
733
732
|
|
|
734
733
|
/**
|
|
735
734
|
* The destroy method should be called when this Metrics object is no longer
|
|
@@ -824,6 +823,4 @@ export interface Metrics<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
824
823
|
* ```
|
|
825
824
|
* @category Creation
|
|
826
825
|
*/
|
|
827
|
-
export function createMetrics
|
|
828
|
-
store: Store<Schemas>,
|
|
829
|
-
): Metrics<Schemas>;
|
|
826
|
+
export function createMetrics(store: Store): Metrics;
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* @module persisters
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
import {
|
|
30
|
+
import {Store, Tables, Values} from './store.d';
|
|
31
31
|
import {Callback} from './common.d';
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -145,7 +145,7 @@ export type PersisterStats = {
|
|
|
145
145
|
* ```
|
|
146
146
|
* @category Persister
|
|
147
147
|
*/
|
|
148
|
-
export interface Persister
|
|
148
|
+
export interface Persister {
|
|
149
149
|
/**
|
|
150
150
|
* The load method gets persisted data from storage, and loads it into the
|
|
151
151
|
* Store with which the Persister is associated, once.
|
|
@@ -206,10 +206,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
206
206
|
* ```
|
|
207
207
|
* @category Load
|
|
208
208
|
*/
|
|
209
|
-
load(
|
|
210
|
-
initialTables?: Tables<Schemas[0], true>,
|
|
211
|
-
initialValues?: Values,
|
|
212
|
-
): Promise<Persister<Schemas>>;
|
|
209
|
+
load(initialTables?: Tables, initialValues?: Values): Promise<Persister>;
|
|
213
210
|
|
|
214
211
|
/**
|
|
215
212
|
* The startAutoLoad method gets persisted data from storage, and loads it
|
|
@@ -266,9 +263,9 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
266
263
|
* @category Load
|
|
267
264
|
*/
|
|
268
265
|
startAutoLoad(
|
|
269
|
-
initialTables?: Tables
|
|
266
|
+
initialTables?: Tables,
|
|
270
267
|
initialValues?: Values,
|
|
271
|
-
): Promise<Persister
|
|
268
|
+
): Promise<Persister>;
|
|
272
269
|
|
|
273
270
|
/**
|
|
274
271
|
* The stopAutoLoad method stops the automatic loading of data from storage
|
|
@@ -313,7 +310,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
313
310
|
* ```
|
|
314
311
|
* @category Load
|
|
315
312
|
*/
|
|
316
|
-
stopAutoLoad(): Persister
|
|
313
|
+
stopAutoLoad(): Persister;
|
|
317
314
|
|
|
318
315
|
/**
|
|
319
316
|
* The save method takes data from the Store with which the Persister is
|
|
@@ -342,7 +339,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
342
339
|
* ```
|
|
343
340
|
* @category Save
|
|
344
341
|
*/
|
|
345
|
-
save(): Promise<Persister
|
|
342
|
+
save(): Promise<Persister>;
|
|
346
343
|
|
|
347
344
|
/**
|
|
348
345
|
* The save method takes data from the Store with which the Persister is
|
|
@@ -380,7 +377,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
380
377
|
* ```
|
|
381
378
|
* @category Save
|
|
382
379
|
*/
|
|
383
|
-
startAutoSave(): Promise<Persister
|
|
380
|
+
startAutoSave(): Promise<Persister>;
|
|
384
381
|
|
|
385
382
|
/**
|
|
386
383
|
* The stopAutoSave method stops the automatic save of data to storage
|
|
@@ -418,7 +415,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
418
415
|
* ```
|
|
419
416
|
* @category Save
|
|
420
417
|
*/
|
|
421
|
-
stopAutoSave(): Persister
|
|
418
|
+
stopAutoSave(): Persister;
|
|
422
419
|
|
|
423
420
|
/**
|
|
424
421
|
* The getStore method returns a reference to the underlying Store that is
|
|
@@ -442,7 +439,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
442
439
|
* ```
|
|
443
440
|
* @category Getter
|
|
444
441
|
*/
|
|
445
|
-
getStore(): Store
|
|
442
|
+
getStore(): Store;
|
|
446
443
|
|
|
447
444
|
/**
|
|
448
445
|
* The destroy method should be called when this Persister object is no longer
|
|
@@ -473,7 +470,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
473
470
|
* ```
|
|
474
471
|
* @category Lifecycle
|
|
475
472
|
*/
|
|
476
|
-
destroy(): Persister
|
|
473
|
+
destroy(): Persister;
|
|
477
474
|
|
|
478
475
|
/**
|
|
479
476
|
* The getStats method provides a set of statistics about the Persister, and
|
|
@@ -549,10 +546,10 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
549
546
|
* ```
|
|
550
547
|
* @category Creation
|
|
551
548
|
*/
|
|
552
|
-
export function createSessionPersister
|
|
553
|
-
store: Store
|
|
549
|
+
export function createSessionPersister(
|
|
550
|
+
store: Store,
|
|
554
551
|
storageName: string,
|
|
555
|
-
): Persister
|
|
552
|
+
): Persister;
|
|
556
553
|
|
|
557
554
|
/**
|
|
558
555
|
* The createLocalPersister function creates a Persister object that can
|
|
@@ -582,10 +579,10 @@ export function createSessionPersister<Schemas extends OptionalSchemas>(
|
|
|
582
579
|
* ```
|
|
583
580
|
* @category Creation
|
|
584
581
|
*/
|
|
585
|
-
export function createLocalPersister
|
|
586
|
-
store: Store
|
|
582
|
+
export function createLocalPersister(
|
|
583
|
+
store: Store,
|
|
587
584
|
storageName: string,
|
|
588
|
-
): Persister
|
|
585
|
+
): Persister;
|
|
589
586
|
|
|
590
587
|
/**
|
|
591
588
|
* The createRemotePersister function creates a Persister object that can
|
|
@@ -629,12 +626,12 @@ export function createLocalPersister<Schemas extends OptionalSchemas>(
|
|
|
629
626
|
* ```
|
|
630
627
|
* @category Creation
|
|
631
628
|
*/
|
|
632
|
-
export function createRemotePersister
|
|
633
|
-
store: Store
|
|
629
|
+
export function createRemotePersister(
|
|
630
|
+
store: Store,
|
|
634
631
|
loadUrl: string,
|
|
635
632
|
saveUrl: string,
|
|
636
633
|
autoLoadIntervalSeconds: number,
|
|
637
|
-
): Persister
|
|
634
|
+
): Persister;
|
|
638
635
|
|
|
639
636
|
/**
|
|
640
637
|
* The createFilePersister function creates a Persister object that can persist
|
|
@@ -664,10 +661,7 @@ export function createRemotePersister<Schemas extends OptionalSchemas>(
|
|
|
664
661
|
* ```
|
|
665
662
|
* @category Creation
|
|
666
663
|
*/
|
|
667
|
-
export function createFilePersister
|
|
668
|
-
store: Store<Schemas>,
|
|
669
|
-
filePath: string,
|
|
670
|
-
): Persister<Schemas>;
|
|
664
|
+
export function createFilePersister(store: Store, filePath: string): Persister;
|
|
671
665
|
|
|
672
666
|
/**
|
|
673
667
|
* The createCustomPersister function creates a Persister object that you can
|
|
@@ -724,10 +718,10 @@ export function createFilePersister<Schemas extends OptionalSchemas>(
|
|
|
724
718
|
* ```
|
|
725
719
|
* @category Creation
|
|
726
720
|
*/
|
|
727
|
-
export function createCustomPersister
|
|
728
|
-
store: Store
|
|
721
|
+
export function createCustomPersister(
|
|
722
|
+
store: Store,
|
|
729
723
|
getPersisted: () => Promise<string | null | undefined>,
|
|
730
724
|
setPersisted: (json: string) => Promise<void>,
|
|
731
725
|
startListeningToPersisted: (didChange: Callback) => void,
|
|
732
726
|
stopListeningToPersisted: Callback,
|
|
733
|
-
): Persister
|
|
727
|
+
): Persister;
|