tinybase 2.0.0-beta.3 → 2.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -159,7 +159,7 @@ export type CheckpointsListenerStats = {
159
159
  * ```
160
160
  * @see Relationships And Checkpoints guides
161
161
  * @see Todo App demos
162
- * @see TinyDraw demo
162
+ * @see Drawing demo
163
163
  * @category Checkpoints
164
164
  */
165
165
  export interface Checkpoints {
@@ -159,7 +159,7 @@ export type CheckpointsListenerStats = {
159
159
  * ```
160
160
  * @see Relationships And Checkpoints guides
161
161
  * @see Todo App demos
162
- * @see TinyDraw demo
162
+ * @see Drawing demo
163
163
  * @category Checkpoints
164
164
  */
165
165
  export interface Checkpoints {
@@ -22,7 +22,7 @@
22
22
  * @see Persisting Data guide
23
23
  * @see Countries demo
24
24
  * @see Todo App demos
25
- * @see TinyDraw demo
25
+ * @see Drawing demo
26
26
  * @packageDocumentation
27
27
  * @module persisters
28
28
  */
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * @packageDocumentation
11
11
  * @module queries
12
- * @since v2.0.0-beta
12
+ * @since v2.0.0
13
13
  */
14
14
 
15
15
  import {
@@ -38,7 +38,7 @@ import {Id, IdOrNull, Ids} from './common.d';
38
38
  * @param length The length of the array of Cell values to be aggregated.
39
39
  * @returns The value of the aggregation.
40
40
  * @category Aggregators
41
- * @since v2.0.0-beta
41
+ * @since v2.0.0
42
42
  */
43
43
  export type Aggregate = (cells: Cell[], length: number) => Cell;
44
44
 
@@ -64,7 +64,7 @@ export type Aggregate = (cells: Cell[], length: number) => Cell;
64
64
  * @param length The length of the array of Cell values in the aggregation.
65
65
  * @returns The new value of the aggregation.
66
66
  * @category Aggregators
67
- * @since v2.0.0-beta
67
+ * @since v2.0.0
68
68
  */
69
69
  export type AggregateAdd = (
70
70
  current: Cell,
@@ -97,7 +97,7 @@ export type AggregateAdd = (
97
97
  * @param length The length of the array of Cell values in the aggregation.
98
98
  * @returns The new value of the aggregation.
99
99
  * @category Aggregators
100
- * @since v2.0.0-beta
100
+ * @since v2.0.0
101
101
  */
102
102
  export type AggregateRemove = (
103
103
  current: Cell,
@@ -129,7 +129,7 @@ export type AggregateRemove = (
129
129
  * @param length The length of the array of Cell values in the aggregation.
130
130
  * @returns The new value of the aggregation.
131
131
  * @category Aggregators
132
- * @since v2.0.0-beta
132
+ * @since v2.0.0
133
133
  */
134
134
  export type AggregateReplace = (
135
135
  current: Cell,
@@ -147,7 +147,7 @@ export type AggregateReplace = (
147
147
  *
148
148
  * @param queryId The Id of the query that the callback can operate on.
149
149
  * @category Callback
150
- * @since v2.0.0-beta
150
+ * @since v2.0.0
151
151
  */
152
152
  export type QueryCallback = (queryId: Id) => void;
153
153
 
@@ -168,7 +168,7 @@ export type QueryCallback = (queryId: Id) => void;
168
168
  * @param getCellChange A function that returns information about any Cell's
169
169
  * changes.
170
170
  * @category Listener
171
- * @since v2.0.0-beta
171
+ * @since v2.0.0
172
172
  */
173
173
  export type ResultTableListener = (
174
174
  queries: Queries,
@@ -190,7 +190,7 @@ export type ResultTableListener = (
190
190
  * @param queries A reference to the Queries object that changed.
191
191
  * @param tableId The Id of the Table that changed, which is also the query Id.
192
192
  * @category Listener
193
- * @since v2.0.0-beta
193
+ * @since v2.0.0
194
194
  */
195
195
  export type ResultRowIdsListener = (queries: Queries, tableId: Id) => void;
196
196
 
@@ -217,7 +217,7 @@ export type ResultRowIdsListener = (queries: Queries, tableId: Id) => void;
217
217
  * @param limit The maximum number of Row Ids returned.
218
218
  * @param sortedRowIds The sorted Row Ids themselves.
219
219
  * @category Listener
220
- * @since v2.0.0-beta
220
+ * @since v2.0.0
221
221
  */
222
222
  export type ResultSortedRowIdsListener = (
223
223
  queries: Queries,
@@ -247,7 +247,7 @@ export type ResultSortedRowIdsListener = (
247
247
  * @param getCellChange A function that returns information about any Cell's
248
248
  * changes.
249
249
  * @category Listener
250
- * @since v2.0.0-beta
250
+ * @since v2.0.0
251
251
  */
252
252
  export type ResultRowListener = (
253
253
  queries: Queries,
@@ -271,7 +271,7 @@ export type ResultRowListener = (
271
271
  * @param tableId The Id of the Table that changed, which is also the query Id.
272
272
  * @param rowId The Id of the Row that changed.
273
273
  * @category Listener
274
- * @since v2.0.0-beta
274
+ * @since v2.0.0
275
275
  */
276
276
  export type ResultCellIdsListener = (
277
277
  queries: Queries,
@@ -301,7 +301,7 @@ export type ResultCellIdsListener = (
301
301
  * @param getCellChange A function that returns information about any Cell's
302
302
  * changes.
303
303
  * @category Listener
304
- * @since v2.0.0-beta
304
+ * @since v2.0.0
305
305
  */
306
306
  export type ResultCellListener = (
307
307
  queries: Queries,
@@ -321,7 +321,7 @@ export type ResultCellListener = (
321
321
  * and is only populated in a debug build.
322
322
  *
323
323
  * @category Development
324
- * @since v2.0.0-beta
324
+ * @since v2.0.0
325
325
  */
326
326
  export type QueriesListenerStats = {
327
327
  /**
@@ -355,7 +355,7 @@ export type QueriesListenerStats = {
355
355
  * calculated values. See those methods for specific examples.
356
356
  *
357
357
  * @category Callback
358
- * @since v2.0.0-beta
358
+ * @since v2.0.0
359
359
  */
360
360
  export type GetTableCell = {
361
361
  /**
@@ -476,7 +476,7 @@ export type GetTableCell = {
476
476
  * // -> {cujo: {description: 'dog for Carol'}}
477
477
  * ```
478
478
  * @category Definition
479
- * @since v2.0.0-beta
479
+ * @since v2.0.0
480
480
  */
481
481
  export type Select = {
482
482
  /**
@@ -561,7 +561,7 @@ export type Select = {
561
561
  * // -> {cujo: {petSpecies: 'dog', ownerName: 'Carol'}}
562
562
  * ```
563
563
  * @category Definition
564
- * @since v2.0.0-beta
564
+ * @since v2.0.0
565
565
  */
566
566
  export type SelectedAs = {
567
567
  /**
@@ -734,7 +734,7 @@ export type SelectedAs = {
734
734
  * // -> {cujo: {description: 'dog in Washington'}}
735
735
  * ```
736
736
  * @category Definition
737
- * @since v2.0.0-beta
737
+ * @since v2.0.0
738
738
  */
739
739
  export type Join = {
740
740
  /**
@@ -848,7 +848,7 @@ export type Join = {
848
848
  * // -> {cujo: {buyer: 'Carol', seller: 'Alice'}}
849
849
  * ```
850
850
  * @category Definition
851
- * @since v2.0.0-beta
851
+ * @since v2.0.0
852
852
  */
853
853
  export type JoinedAs = {as: (joinedTableId: Id) => void};
854
854
 
@@ -966,7 +966,7 @@ export type JoinedAs = {as: (joinedTableId: Id) => void};
966
966
  * // -> {cujo: {species: 'dog', state: 'WA'}}
967
967
  * ```
968
968
  * @category Definition
969
- * @since v2.0.0-beta
969
+ * @since v2.0.0
970
970
  */
971
971
  export type Where = {
972
972
  /**
@@ -1171,6 +1171,8 @@ export type Where = {
1171
1171
  * // -> {1: {owner: 'bob', lowestPriceOver2: 3}}
1172
1172
  * // Both have a parrot at 3. Alice's worm at 1 is excluded from aggregation.
1173
1173
  * ```
1174
+ * @category Definition
1175
+ * @since v2.0.0
1174
1176
  */
1175
1177
  export type Group = (
1176
1178
  selectedCellId: Id,
@@ -1215,7 +1217,7 @@ export type Group = (
1215
1217
  * // -> {1: {species: 'cat', minPrice: 3, maxPrice: 4}}
1216
1218
  * ```
1217
1219
  * @category Definition
1218
- * @since v2.0.0-beta
1220
+ * @since v2.0.0
1219
1221
  */
1220
1222
  export type GroupedAs = {as: (groupedCellId: Id) => void};
1221
1223
 
@@ -1305,7 +1307,7 @@ export type GroupedAs = {as: (groupedCellId: Id) => void};
1305
1307
  * // Parrots are filtered out because they have zero range in price.
1306
1308
  * ```
1307
1309
  * @category Definition
1308
- * @since v2.0.0-beta
1310
+ * @since v2.0.0
1309
1311
  */
1310
1312
  export type Having = {
1311
1313
  /**
@@ -1421,7 +1423,7 @@ export type Having = {
1421
1423
  * ```
1422
1424
  * @see Queries guides
1423
1425
  * @category Queries
1424
- * @since v2.0.0-beta
1426
+ * @since v2.0.0
1425
1427
  */
1426
1428
  export interface Queries {
1427
1429
  /**
@@ -1485,7 +1487,7 @@ export interface Queries {
1485
1487
  * // -> {fido: {color: 'brown'}, cujo: {color: 'black'}}
1486
1488
  * ```
1487
1489
  * @category Configuration
1488
- * @since v2.0.0-beta
1490
+ * @since v2.0.0
1489
1491
  */
1490
1492
  setQueryDefinition(
1491
1493
  queryId: Id,
@@ -1528,7 +1530,7 @@ export interface Queries {
1528
1530
  * // -> []
1529
1531
  * ```
1530
1532
  * @category Configuration
1531
- * @since v2.0.0-beta
1533
+ * @since v2.0.0
1532
1534
  */
1533
1535
  delQueryDefinition(queryId: Id): Queries;
1534
1536
 
@@ -1554,7 +1556,7 @@ export interface Queries {
1554
1556
  * // -> {fido: {color: 'brown'}}
1555
1557
  * ```
1556
1558
  * @category Getter
1557
- * @since v2.0.0-beta
1559
+ * @since v2.0.0
1558
1560
  */
1559
1561
  getStore(): Store;
1560
1562
 
@@ -1582,7 +1584,7 @@ export interface Queries {
1582
1584
  * // -> ['dogColors', 'catColors']
1583
1585
  * ```
1584
1586
  * @category Getter
1585
- * @since v2.0.0-beta
1587
+ * @since v2.0.0
1586
1588
  */
1587
1589
  getQueryIds(): Ids;
1588
1590
 
@@ -1616,7 +1618,7 @@ export interface Queries {
1616
1618
  * // -> 'catColors'
1617
1619
  * ```
1618
1620
  * @category Iterator
1619
- * @since v2.0.0-beta
1621
+ * @since v2.0.0
1620
1622
  */
1621
1623
  forEachQuery(queryCallback: QueryCallback): void;
1622
1624
 
@@ -1645,7 +1647,7 @@ export interface Queries {
1645
1647
  * // -> false
1646
1648
  * ```
1647
1649
  * @category Getter
1648
- * @since v2.0.0-beta
1650
+ * @since v2.0.0
1649
1651
  */
1650
1652
  hasQuery(queryId: Id): boolean;
1651
1653
 
@@ -1678,7 +1680,7 @@ export interface Queries {
1678
1680
  * // -> undefined
1679
1681
  * ```
1680
1682
  * @category Getter
1681
- * @since v2.0.0-beta
1683
+ * @since v2.0.0
1682
1684
  */
1683
1685
  getTableId(queryId: Id): Id | undefined;
1684
1686
 
@@ -1724,7 +1726,7 @@ export interface Queries {
1724
1726
  * // -> {}
1725
1727
  * ```
1726
1728
  * @category Result
1727
- * @since v2.0.0-beta
1729
+ * @since v2.0.0
1728
1730
  */
1729
1731
  getResultTable(queryId: Id): Table;
1730
1732
 
@@ -1767,7 +1769,7 @@ export interface Queries {
1767
1769
  * // -> []
1768
1770
  * ```
1769
1771
  * @category Result
1770
- * @since v2.0.0-beta
1772
+ * @since v2.0.0
1771
1773
  */
1772
1774
  getResultRowIds(queryId: Id): Ids;
1773
1775
 
@@ -1827,7 +1829,7 @@ export interface Queries {
1827
1829
  * // -> []
1828
1830
  * ```
1829
1831
  * @category Result
1830
- * @since v2.0.0-beta
1832
+ * @since v2.0.0
1831
1833
  */
1832
1834
  getResultSortedRowIds(
1833
1835
  queryId: Id,
@@ -1879,7 +1881,7 @@ export interface Queries {
1879
1881
  * // -> {}
1880
1882
  * ```
1881
1883
  * @category Result
1882
- * @since v2.0.0-beta
1884
+ * @since v2.0.0
1883
1885
  */
1884
1886
  getResultRow(queryId: Id, rowId: Id): Row;
1885
1887
 
@@ -1925,7 +1927,7 @@ export interface Queries {
1925
1927
  * // -> []
1926
1928
  * ```
1927
1929
  * @category Result
1928
- * @since v2.0.0-beta
1930
+ * @since v2.0.0
1929
1931
  */
1930
1932
  getResultCellIds(queryId: Id, rowId: Id): Ids;
1931
1933
 
@@ -1968,7 +1970,7 @@ export interface Queries {
1968
1970
  * // -> undefined
1969
1971
  * ```
1970
1972
  * @category Result
1971
- * @since v2.0.0-beta
1973
+ * @since v2.0.0
1972
1974
  */
1973
1975
  getResultCell(queryId: Id, rowId: Id, cellId: Id): CellOrUndefined;
1974
1976
 
@@ -2003,7 +2005,7 @@ export interface Queries {
2003
2005
  * // -> false
2004
2006
  * ```
2005
2007
  * @category Result
2006
- * @since v2.0.0-beta
2008
+ * @since v2.0.0
2007
2009
  */
2008
2010
  hasResultTable(queryId: Id): boolean;
2009
2011
 
@@ -2039,7 +2041,7 @@ export interface Queries {
2039
2041
  * // -> false
2040
2042
  * ```
2041
2043
  * @category Result
2042
- * @since v2.0.0-beta
2044
+ * @since v2.0.0
2043
2045
  */
2044
2046
  hasResultRow(queryId: Id, rowId: Id): boolean;
2045
2047
 
@@ -2076,7 +2078,7 @@ export interface Queries {
2076
2078
  * // -> false
2077
2079
  * ```
2078
2080
  * @category Result
2079
- * @since v2.0.0-beta
2081
+ * @since v2.0.0
2080
2082
  */
2081
2083
  hasResultCell(queryId: Id, rowId: Id, cellId: Id): boolean;
2082
2084
 
@@ -2123,7 +2125,7 @@ export interface Queries {
2123
2125
  * // -> '- felix'
2124
2126
  * ```
2125
2127
  * @category Iterator
2126
- * @since v2.0.0-beta
2128
+ * @since v2.0.0
2127
2129
  */
2128
2130
  forEachResultTable(tableCallback: TableCallback): void;
2129
2131
 
@@ -2169,7 +2171,7 @@ export interface Queries {
2169
2171
  * // -> '- color'
2170
2172
  * ```
2171
2173
  * @category Iterator
2172
- * @since v2.0.0-beta
2174
+ * @since v2.0.0
2173
2175
  */
2174
2176
  forEachResultRow(queryId: Id, rowCallback: RowCallback): void;
2175
2177
 
@@ -2212,7 +2214,7 @@ export interface Queries {
2212
2214
  * // -> 'color: brown'
2213
2215
  * ```
2214
2216
  * @category Iterator
2215
- * @since v2.0.0-beta
2217
+ * @since v2.0.0
2216
2218
  */
2217
2219
  forEachResultCell(queryId: Id, rowId: Id, cellCallback: CellCallback): void;
2218
2220
 
@@ -2303,6 +2305,7 @@ export interface Queries {
2303
2305
  * store.delListener(listenerId);
2304
2306
  * ```
2305
2307
  * @category Listener
2308
+ * @since v2.0.0
2306
2309
  */
2307
2310
  addResultTableListener(queryId: IdOrNull, listener: ResultTableListener): Id;
2308
2311
 
@@ -2397,6 +2400,7 @@ export interface Queries {
2397
2400
  * store.delListener(listenerId);
2398
2401
  * ```
2399
2402
  * @category Listener
2403
+ * @since v2.0.0
2400
2404
  */
2401
2405
  addResultRowIdsListener(
2402
2406
  queryId: IdOrNull,
@@ -2523,6 +2527,7 @@ export interface Queries {
2523
2527
  * store.delListener(listenerId);
2524
2528
  * ```
2525
2529
  * @category Listener
2530
+ * @since v2.0.0
2526
2531
  */
2527
2532
  addResultSortedRowIdsListener(
2528
2533
  queryId: Id,
@@ -2629,6 +2634,7 @@ export interface Queries {
2629
2634
  * store.delListener(listenerId);
2630
2635
  * ```
2631
2636
  * @category Listener
2637
+ * @since v2.0.0
2632
2638
  */
2633
2639
  addResultRowListener(
2634
2640
  queryId: IdOrNull,
@@ -2741,6 +2747,7 @@ export interface Queries {
2741
2747
  * store.delListener(listenerId);
2742
2748
  * ```
2743
2749
  * @category Listener
2750
+ * @since v2.0.0
2744
2751
  */
2745
2752
  addResultCellIdsListener(
2746
2753
  queryId: IdOrNull,
@@ -2857,6 +2864,7 @@ export interface Queries {
2857
2864
  * store.delListener(listenerId);
2858
2865
  * ```
2859
2866
  * @category Listener
2867
+ * @since v2.0.0
2860
2868
  */
2861
2869
  addResultCellListener(
2862
2870
  queryId: IdOrNull,
@@ -2907,7 +2915,7 @@ export interface Queries {
2907
2915
  * // The listener is not called.
2908
2916
  * ```
2909
2917
  * @category Listener
2910
- * @since v2.0.0-beta
2918
+ * @since v2.0.0
2911
2919
  */
2912
2920
  delListener(listenerId: Id): Queries;
2913
2921
 
@@ -2943,7 +2951,7 @@ export interface Queries {
2943
2951
  * // -> 0
2944
2952
  * ```
2945
2953
  * @category Lifecycle
2946
- * @since v2.0.0-beta
2954
+ * @since v2.0.0
2947
2955
  */
2948
2956
  destroy(): void;
2949
2957
 
@@ -2973,7 +2981,7 @@ export interface Queries {
2973
2981
  * // -> 0
2974
2982
  * ```
2975
2983
  * @category Development
2976
- * @since v2.0.0-beta
2984
+ * @since v2.0.0
2977
2985
  */
2978
2986
  getListenerStats(): QueriesListenerStats;
2979
2987
  }
@@ -3011,6 +3019,6 @@ export interface Queries {
3011
3019
  * // -> true
3012
3020
  * ```
3013
3021
  * @category Creation
3014
- * @since v2.0.0-beta
3022
+ * @since v2.0.0
3015
3023
  */
3016
3024
  export function createQueries(store: Store): Queries;
@@ -347,8 +347,14 @@ const createQueries = getCreateFunction((store) => {
347
347
  listenerId,
348
348
  ),
349
349
  );
350
- const cleanPreStores = (queryId) =>
350
+ const resetPreStores = (queryId) => {
351
+ mapForEach(mapGet(preStoreListenerIds, queryId), (preStore2, listenerIds) =>
352
+ collForEach(listenerIds, (listenerId) =>
353
+ preStore2.delListener(listenerId),
354
+ ),
355
+ );
351
356
  arrayForEach([resultStore, preStore], (store2) => store2.delTable(queryId));
357
+ };
352
358
  const synchronizeTransactions = (queryId, fromStore, toStore) =>
353
359
  addPreStoreListener(
354
360
  fromStore,
@@ -360,7 +366,7 @@ const createQueries = getCreateFunction((store) => {
360
366
  );
361
367
  const setQueryDefinition = (queryId, tableId, build) => {
362
368
  setDefinition(queryId, tableId);
363
- cleanPreStores(queryId);
369
+ resetPreStores(queryId);
364
370
  const selectEntries = [];
365
371
  const joinEntries = [[null, [tableId, null, null, [], mapNew()]]];
366
372
  const wheres = [];
@@ -694,12 +700,7 @@ const createQueries = getCreateFunction((store) => {
694
700
  return queries;
695
701
  };
696
702
  const delQueryDefinition = (queryId) => {
697
- mapForEach(mapGet(preStoreListenerIds, queryId), (preStore2, listenerIds) =>
698
- collForEach(listenerIds, (listenerId) =>
699
- preStore2.delListener(listenerId),
700
- ),
701
- );
702
- cleanPreStores(queryId);
703
+ resetPreStores(queryId);
703
704
  delDefinition(queryId);
704
705
  return queries;
705
706
  };
@@ -244,7 +244,7 @@ export type RelationshipsListenerStats = {
244
244
  * relationships.destroy();
245
245
  * ```
246
246
  * @see Relationships And Checkpoints guides
247
- * @see TinyDraw demo
247
+ * @see Drawing demo
248
248
  * @category Relationships
249
249
  */
250
250
  export interface Relationships {
@@ -1122,8 +1122,14 @@ const createQueries = getCreateFunction((store) => {
1122
1122
  listenerId,
1123
1123
  ),
1124
1124
  );
1125
- const cleanPreStores = (queryId) =>
1125
+ const resetPreStores = (queryId) => {
1126
+ mapForEach(mapGet(preStoreListenerIds, queryId), (preStore2, listenerIds) =>
1127
+ collForEach(listenerIds, (listenerId) =>
1128
+ preStore2.delListener(listenerId),
1129
+ ),
1130
+ );
1126
1131
  arrayForEach([resultStore, preStore], (store2) => store2.delTable(queryId));
1132
+ };
1127
1133
  const synchronizeTransactions = (queryId, fromStore, toStore) =>
1128
1134
  addPreStoreListener(
1129
1135
  fromStore,
@@ -1135,7 +1141,7 @@ const createQueries = getCreateFunction((store) => {
1135
1141
  );
1136
1142
  const setQueryDefinition = (queryId, tableId, build) => {
1137
1143
  setDefinition(queryId, tableId);
1138
- cleanPreStores(queryId);
1144
+ resetPreStores(queryId);
1139
1145
  const selectEntries = [];
1140
1146
  const joinEntries = [[null, [tableId, null, null, [], mapNew()]]];
1141
1147
  const wheres = [];
@@ -1469,12 +1475,7 @@ const createQueries = getCreateFunction((store) => {
1469
1475
  return queries;
1470
1476
  };
1471
1477
  const delQueryDefinition = (queryId) => {
1472
- mapForEach(mapGet(preStoreListenerIds, queryId), (preStore2, listenerIds) =>
1473
- collForEach(listenerIds, (listenerId) =>
1474
- preStore2.delListener(listenerId),
1475
- ),
1476
- );
1477
- cleanPreStores(queryId);
1478
+ resetPreStores(queryId);
1478
1479
  delDefinition(queryId);
1479
1480
  return queries;
1480
1481
  };