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
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,8 @@ 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
183
|
* The setSize method lets you specify how many checkpoints the Checkpoints
|
|
183
184
|
* object will store.
|
|
@@ -220,7 +221,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
220
221
|
* ```
|
|
221
222
|
* @category Configuration
|
|
222
223
|
*/
|
|
223
|
-
setSize(size: number): Checkpoints
|
|
224
|
+
setSize(size: number): Checkpoints;
|
|
224
225
|
|
|
225
226
|
/**
|
|
226
227
|
* The addCheckpoint method records a checkpoint of the Store into the
|
|
@@ -320,7 +321,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
320
321
|
* ```
|
|
321
322
|
* @category Setter
|
|
322
323
|
*/
|
|
323
|
-
setCheckpoint(checkpointId: Id, label: string): Checkpoints
|
|
324
|
+
setCheckpoint(checkpointId: Id, label: string): Checkpoints;
|
|
324
325
|
|
|
325
326
|
/**
|
|
326
327
|
* The getStore method returns a reference to the underlying Store that is
|
|
@@ -341,7 +342,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
341
342
|
* ```
|
|
342
343
|
* @category Getter
|
|
343
344
|
*/
|
|
344
|
-
getStore(): Store
|
|
345
|
+
getStore(): Store;
|
|
345
346
|
|
|
346
347
|
/**
|
|
347
348
|
* The getCheckpointIds method returns an array of the checkpoint Ids being
|
|
@@ -637,7 +638,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
637
638
|
* ```
|
|
638
639
|
* @category Listener
|
|
639
640
|
*/
|
|
640
|
-
delListener(listenerId: Id): Checkpoints
|
|
641
|
+
delListener(listenerId: Id): Checkpoints;
|
|
641
642
|
|
|
642
643
|
/**
|
|
643
644
|
* The goBackward method moves the state of the underlying Store back to the
|
|
@@ -670,7 +671,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
670
671
|
* ```
|
|
671
672
|
* @category Movement
|
|
672
673
|
*/
|
|
673
|
-
goBackward(): Checkpoints
|
|
674
|
+
goBackward(): Checkpoints;
|
|
674
675
|
|
|
675
676
|
/**
|
|
676
677
|
* The goForward method moves the state of the underlying Store forwards to a
|
|
@@ -750,7 +751,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
750
751
|
* ```
|
|
751
752
|
* @category Movement
|
|
752
753
|
*/
|
|
753
|
-
goForward(): Checkpoints
|
|
754
|
+
goForward(): Checkpoints;
|
|
754
755
|
|
|
755
756
|
/**
|
|
756
757
|
* The goTo method moves the state of the underlying Store backwards or
|
|
@@ -800,7 +801,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
800
801
|
* ```
|
|
801
802
|
* @category Movement
|
|
802
803
|
*/
|
|
803
|
-
goTo(checkpointId: Id): Checkpoints
|
|
804
|
+
goTo(checkpointId: Id): Checkpoints;
|
|
804
805
|
|
|
805
806
|
/**
|
|
806
807
|
* The clear method resets this Checkpoints object to its initial state,
|
|
@@ -858,7 +859,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
858
859
|
* ```
|
|
859
860
|
* @category Lifecycle
|
|
860
861
|
*/
|
|
861
|
-
clear(): Checkpoints
|
|
862
|
+
clear(): Checkpoints;
|
|
862
863
|
|
|
863
864
|
/**
|
|
864
865
|
* The destroy method should be called when this Checkpoints object is no
|
|
@@ -922,6 +923,7 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
922
923
|
* @category Development
|
|
923
924
|
*/
|
|
924
925
|
getListenerStats(): CheckpointsListenerStats;
|
|
926
|
+
//
|
|
925
927
|
}
|
|
926
928
|
|
|
927
929
|
/**
|
|
@@ -956,6 +958,4 @@ export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
956
958
|
* ```
|
|
957
959
|
* @category Creation
|
|
958
960
|
*/
|
|
959
|
-
export function createCheckpoints
|
|
960
|
-
store: Store<Schemas>,
|
|
961
|
-
): Checkpoints<Schemas>;
|
|
961
|
+
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,8 @@ export type IndexesListenerStats = {
|
|
|
201
195
|
* @see Word Frequencies demo
|
|
202
196
|
* @category Indexes
|
|
203
197
|
*/
|
|
204
|
-
export interface Indexes
|
|
198
|
+
export interface Indexes {
|
|
199
|
+
//
|
|
205
200
|
/**
|
|
206
201
|
* The setIndexDefinition method lets you set the definition of an Index.
|
|
207
202
|
*
|
|
@@ -361,7 +356,7 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
361
356
|
getSortKey?: Id | ((getCell: GetCell, rowId: Id) => SortKey),
|
|
362
357
|
sliceIdSorter?: (sliceId1: Id, sliceId2: Id) => number,
|
|
363
358
|
rowIdSorter?: (sortKey1: SortKey, sortKey2: SortKey, sliceId: Id) => number,
|
|
364
|
-
): Indexes
|
|
359
|
+
): Indexes;
|
|
365
360
|
|
|
366
361
|
/**
|
|
367
362
|
* The delIndexDefinition method removes an existing Index definition.
|
|
@@ -390,7 +385,7 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
390
385
|
* ```
|
|
391
386
|
* @category Configuration
|
|
392
387
|
*/
|
|
393
|
-
delIndexDefinition(indexId: Id): Indexes
|
|
388
|
+
delIndexDefinition(indexId: Id): Indexes;
|
|
394
389
|
|
|
395
390
|
/**
|
|
396
391
|
* The getStore method returns a reference to the underlying Store that is
|
|
@@ -410,7 +405,7 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
410
405
|
* ```
|
|
411
406
|
* @category Getter
|
|
412
407
|
*/
|
|
413
|
-
getStore(): Store
|
|
408
|
+
getStore(): Store;
|
|
414
409
|
|
|
415
410
|
/**
|
|
416
411
|
* The getIndexIds method returns an array of the Index Ids registered with
|
|
@@ -581,7 +576,7 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
581
576
|
* ```
|
|
582
577
|
* @category Getter
|
|
583
578
|
*/
|
|
584
|
-
getTableId(indexId: Id): Id;
|
|
579
|
+
getTableId(indexId: Id): Id | undefined;
|
|
585
580
|
|
|
586
581
|
/**
|
|
587
582
|
* The getSliceIds method gets the list of Slice Ids in an Index.
|
|
@@ -866,7 +861,7 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
866
861
|
* ```
|
|
867
862
|
* @category Listener
|
|
868
863
|
*/
|
|
869
|
-
delListener(listenerId: Id): Indexes
|
|
864
|
+
delListener(listenerId: Id): Indexes;
|
|
870
865
|
|
|
871
866
|
/**
|
|
872
867
|
* The destroy method should be called when this Indexes object is no longer
|
|
@@ -935,6 +930,7 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
935
930
|
* @category Development
|
|
936
931
|
*/
|
|
937
932
|
getListenerStats(): IndexesListenerStats;
|
|
933
|
+
//
|
|
938
934
|
}
|
|
939
935
|
|
|
940
936
|
/**
|
|
@@ -969,6 +965,4 @@ export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
969
965
|
* ```
|
|
970
966
|
* @category Creation
|
|
971
967
|
*/
|
|
972
|
-
export function createIndexes
|
|
973
|
-
store: Store<Schemas>,
|
|
974
|
-
): Indexes<Schemas>;
|
|
968
|
+
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,8 @@ export type MetricsListenerStats = {
|
|
|
246
245
|
* @see Todo App demos
|
|
247
246
|
* @category Metrics
|
|
248
247
|
*/
|
|
249
|
-
export interface Metrics
|
|
248
|
+
export interface Metrics {
|
|
249
|
+
//
|
|
250
250
|
/**
|
|
251
251
|
* The setMetricDefinition method lets you set the definition of a Metric.
|
|
252
252
|
*
|
|
@@ -287,14 +287,14 @@ export interface Metrics<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
287
287
|
* that if the `aggregate` and `getNumber` parameters are both omitted, the
|
|
288
288
|
* Metric will simply be a count of the Row objects in the Table).
|
|
289
289
|
* @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.
|
|
290
|
+
* MetricAggregate by providing a shortcut for when a single value is added to
|
|
291
|
+
* the input values - for example, when a Row is added to the Table.
|
|
292
292
|
* @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.
|
|
293
|
+
* MetricAggregate by providing a shortcut for when a single value is removed
|
|
294
|
+
* from the input values - for example ,when a Row is removed from the Table.
|
|
295
295
|
* @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.
|
|
296
|
+
* MetricAggregate by providing a shortcut for when a single value in the
|
|
297
|
+
* input values is replaced with another - for example, when a Row is updated.
|
|
298
298
|
* @returns A reference to the Metrics object.
|
|
299
299
|
* @example
|
|
300
300
|
* This example creates a Store, creates a Metrics object, and defines a
|
|
@@ -415,12 +415,12 @@ export interface Metrics<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
415
415
|
setMetricDefinition(
|
|
416
416
|
metricId: Id,
|
|
417
417
|
tableId: Id,
|
|
418
|
-
aggregate?: 'sum' | 'avg' | 'min' | 'max' |
|
|
418
|
+
aggregate?: 'sum' | 'avg' | 'min' | 'max' | MetricAggregate,
|
|
419
419
|
getNumber?: Id | ((getCell: GetCell, rowId: Id) => number),
|
|
420
|
-
aggregateAdd?:
|
|
421
|
-
aggregateRemove?:
|
|
422
|
-
aggregateReplace?:
|
|
423
|
-
): Metrics
|
|
420
|
+
aggregateAdd?: MetricAggregateAdd,
|
|
421
|
+
aggregateRemove?: MetricAggregateRemove,
|
|
422
|
+
aggregateReplace?: MetricAggregateReplace,
|
|
423
|
+
): Metrics;
|
|
424
424
|
|
|
425
425
|
/**
|
|
426
426
|
* The delMetricDefinition method removes an existing Metric definition.
|
|
@@ -449,7 +449,7 @@ export interface Metrics<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
449
449
|
* ```
|
|
450
450
|
* @category Configuration
|
|
451
451
|
*/
|
|
452
|
-
delMetricDefinition(metricId: Id): Metrics
|
|
452
|
+
delMetricDefinition(metricId: Id): Metrics;
|
|
453
453
|
|
|
454
454
|
/**
|
|
455
455
|
* The getStore method returns a reference to the underlying Store that is
|
|
@@ -469,7 +469,7 @@ export interface Metrics<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
469
469
|
* ```
|
|
470
470
|
* @category Getter
|
|
471
471
|
*/
|
|
472
|
-
getStore(): Store
|
|
472
|
+
getStore(): Store;
|
|
473
473
|
|
|
474
474
|
/**
|
|
475
475
|
* The getMetricIds method returns an array of the Metric Ids registered with
|
|
@@ -729,7 +729,7 @@ export interface Metrics<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
729
729
|
* ```
|
|
730
730
|
* @category Listener
|
|
731
731
|
*/
|
|
732
|
-
delListener(listenerId: Id): Metrics
|
|
732
|
+
delListener(listenerId: Id): Metrics;
|
|
733
733
|
|
|
734
734
|
/**
|
|
735
735
|
* The destroy method should be called when this Metrics object is no longer
|
|
@@ -790,6 +790,7 @@ export interface Metrics<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
790
790
|
* @category Development
|
|
791
791
|
*/
|
|
792
792
|
getListenerStats(): MetricsListenerStats;
|
|
793
|
+
//
|
|
793
794
|
}
|
|
794
795
|
|
|
795
796
|
/**
|
|
@@ -824,6 +825,4 @@ export interface Metrics<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
824
825
|
* ```
|
|
825
826
|
* @category Creation
|
|
826
827
|
*/
|
|
827
|
-
export function createMetrics
|
|
828
|
-
store: Store<Schemas>,
|
|
829
|
-
): Metrics<Schemas>;
|
|
828
|
+
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,8 @@ export type PersisterStats = {
|
|
|
145
145
|
* ```
|
|
146
146
|
* @category Persister
|
|
147
147
|
*/
|
|
148
|
-
export interface Persister
|
|
148
|
+
export interface Persister {
|
|
149
|
+
//
|
|
149
150
|
/**
|
|
150
151
|
* The load method gets persisted data from storage, and loads it into the
|
|
151
152
|
* Store with which the Persister is associated, once.
|
|
@@ -206,10 +207,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
206
207
|
* ```
|
|
207
208
|
* @category Load
|
|
208
209
|
*/
|
|
209
|
-
load(
|
|
210
|
-
initialTables?: Tables<Schemas[0], true>,
|
|
211
|
-
initialValues?: Values,
|
|
212
|
-
): Promise<Persister<Schemas>>;
|
|
210
|
+
load(initialTables?: Tables, initialValues?: Values): Promise<Persister>;
|
|
213
211
|
|
|
214
212
|
/**
|
|
215
213
|
* The startAutoLoad method gets persisted data from storage, and loads it
|
|
@@ -266,9 +264,9 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
266
264
|
* @category Load
|
|
267
265
|
*/
|
|
268
266
|
startAutoLoad(
|
|
269
|
-
initialTables?: Tables
|
|
267
|
+
initialTables?: Tables,
|
|
270
268
|
initialValues?: Values,
|
|
271
|
-
): Promise<Persister
|
|
269
|
+
): Promise<Persister>;
|
|
272
270
|
|
|
273
271
|
/**
|
|
274
272
|
* The stopAutoLoad method stops the automatic loading of data from storage
|
|
@@ -313,7 +311,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
313
311
|
* ```
|
|
314
312
|
* @category Load
|
|
315
313
|
*/
|
|
316
|
-
stopAutoLoad(): Persister
|
|
314
|
+
stopAutoLoad(): Persister;
|
|
317
315
|
|
|
318
316
|
/**
|
|
319
317
|
* The save method takes data from the Store with which the Persister is
|
|
@@ -342,7 +340,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
342
340
|
* ```
|
|
343
341
|
* @category Save
|
|
344
342
|
*/
|
|
345
|
-
save(): Promise<Persister
|
|
343
|
+
save(): Promise<Persister>;
|
|
346
344
|
|
|
347
345
|
/**
|
|
348
346
|
* The save method takes data from the Store with which the Persister is
|
|
@@ -380,7 +378,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
380
378
|
* ```
|
|
381
379
|
* @category Save
|
|
382
380
|
*/
|
|
383
|
-
startAutoSave(): Promise<Persister
|
|
381
|
+
startAutoSave(): Promise<Persister>;
|
|
384
382
|
|
|
385
383
|
/**
|
|
386
384
|
* The stopAutoSave method stops the automatic save of data to storage
|
|
@@ -418,7 +416,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
418
416
|
* ```
|
|
419
417
|
* @category Save
|
|
420
418
|
*/
|
|
421
|
-
stopAutoSave(): Persister
|
|
419
|
+
stopAutoSave(): Persister;
|
|
422
420
|
|
|
423
421
|
/**
|
|
424
422
|
* The getStore method returns a reference to the underlying Store that is
|
|
@@ -442,7 +440,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
442
440
|
* ```
|
|
443
441
|
* @category Getter
|
|
444
442
|
*/
|
|
445
|
-
getStore(): Store
|
|
443
|
+
getStore(): Store;
|
|
446
444
|
|
|
447
445
|
/**
|
|
448
446
|
* The destroy method should be called when this Persister object is no longer
|
|
@@ -473,7 +471,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
473
471
|
* ```
|
|
474
472
|
* @category Lifecycle
|
|
475
473
|
*/
|
|
476
|
-
destroy(): Persister
|
|
474
|
+
destroy(): Persister;
|
|
477
475
|
|
|
478
476
|
/**
|
|
479
477
|
* The getStats method provides a set of statistics about the Persister, and
|
|
@@ -519,6 +517,7 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
519
517
|
* @category Development
|
|
520
518
|
*/
|
|
521
519
|
getStats(): PersisterStats;
|
|
520
|
+
//
|
|
522
521
|
}
|
|
523
522
|
|
|
524
523
|
/**
|
|
@@ -549,10 +548,10 @@ export interface Persister<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
549
548
|
* ```
|
|
550
549
|
* @category Creation
|
|
551
550
|
*/
|
|
552
|
-
export function createSessionPersister
|
|
553
|
-
store: Store
|
|
551
|
+
export function createSessionPersister(
|
|
552
|
+
store: Store,
|
|
554
553
|
storageName: string,
|
|
555
|
-
): Persister
|
|
554
|
+
): Persister;
|
|
556
555
|
|
|
557
556
|
/**
|
|
558
557
|
* The createLocalPersister function creates a Persister object that can
|
|
@@ -582,10 +581,10 @@ export function createSessionPersister<Schemas extends OptionalSchemas>(
|
|
|
582
581
|
* ```
|
|
583
582
|
* @category Creation
|
|
584
583
|
*/
|
|
585
|
-
export function createLocalPersister
|
|
586
|
-
store: Store
|
|
584
|
+
export function createLocalPersister(
|
|
585
|
+
store: Store,
|
|
587
586
|
storageName: string,
|
|
588
|
-
): Persister
|
|
587
|
+
): Persister;
|
|
589
588
|
|
|
590
589
|
/**
|
|
591
590
|
* The createRemotePersister function creates a Persister object that can
|
|
@@ -629,12 +628,12 @@ export function createLocalPersister<Schemas extends OptionalSchemas>(
|
|
|
629
628
|
* ```
|
|
630
629
|
* @category Creation
|
|
631
630
|
*/
|
|
632
|
-
export function createRemotePersister
|
|
633
|
-
store: Store
|
|
631
|
+
export function createRemotePersister(
|
|
632
|
+
store: Store,
|
|
634
633
|
loadUrl: string,
|
|
635
634
|
saveUrl: string,
|
|
636
635
|
autoLoadIntervalSeconds: number,
|
|
637
|
-
): Persister
|
|
636
|
+
): Persister;
|
|
638
637
|
|
|
639
638
|
/**
|
|
640
639
|
* The createFilePersister function creates a Persister object that can persist
|
|
@@ -664,10 +663,7 @@ export function createRemotePersister<Schemas extends OptionalSchemas>(
|
|
|
664
663
|
* ```
|
|
665
664
|
* @category Creation
|
|
666
665
|
*/
|
|
667
|
-
export function createFilePersister
|
|
668
|
-
store: Store<Schemas>,
|
|
669
|
-
filePath: string,
|
|
670
|
-
): Persister<Schemas>;
|
|
666
|
+
export function createFilePersister(store: Store, filePath: string): Persister;
|
|
671
667
|
|
|
672
668
|
/**
|
|
673
669
|
* The createCustomPersister function creates a Persister object that you can
|
|
@@ -724,10 +720,10 @@ export function createFilePersister<Schemas extends OptionalSchemas>(
|
|
|
724
720
|
* ```
|
|
725
721
|
* @category Creation
|
|
726
722
|
*/
|
|
727
|
-
export function createCustomPersister
|
|
728
|
-
store: Store
|
|
723
|
+
export function createCustomPersister(
|
|
724
|
+
store: Store,
|
|
729
725
|
getPersisted: () => Promise<string | null | undefined>,
|
|
730
726
|
setPersisted: (json: string) => Promise<void>,
|
|
731
727
|
startListeningToPersisted: (didChange: Callback) => void,
|
|
732
728
|
stopListeningToPersisted: Callback,
|
|
733
|
-
): Persister
|
|
729
|
+
): Persister;
|