tinybase 3.1.0-beta.2 → 3.1.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.
Files changed (72) hide show
  1. package/bin/cli.js +1 -1
  2. package/lib/checkpoints.d.ts +13 -11
  3. package/lib/cjs/checkpoints.d.ts +13 -11
  4. package/lib/cjs/indexes.d.ts +15 -7
  5. package/lib/cjs/metrics.d.ts +9 -7
  6. package/lib/cjs/persisters.d.ts +30 -24
  7. package/lib/cjs/queries.d.ts +10 -6
  8. package/lib/cjs/relationships.d.ts +15 -7
  9. package/lib/cjs/store.d.ts +1190 -291
  10. package/lib/cjs/tools.cjs +1 -1
  11. package/lib/cjs/tools.cjs.gz +0 -0
  12. package/lib/cjs/tools.d.ts +31 -31
  13. package/lib/cjs-es6/checkpoints.d.ts +13 -11
  14. package/lib/cjs-es6/indexes.d.ts +15 -7
  15. package/lib/cjs-es6/metrics.d.ts +9 -7
  16. package/lib/cjs-es6/persisters.d.ts +30 -24
  17. package/lib/cjs-es6/queries.d.ts +10 -6
  18. package/lib/cjs-es6/relationships.d.ts +15 -7
  19. package/lib/cjs-es6/store.d.ts +1190 -291
  20. package/lib/cjs-es6/tools.cjs +1 -1
  21. package/lib/cjs-es6/tools.cjs.gz +0 -0
  22. package/lib/cjs-es6/tools.d.ts +31 -31
  23. package/lib/debug/checkpoints.d.ts +13 -11
  24. package/lib/debug/indexes.d.ts +15 -7
  25. package/lib/debug/metrics.d.ts +9 -7
  26. package/lib/debug/persisters.d.ts +30 -24
  27. package/lib/debug/queries.d.ts +10 -6
  28. package/lib/debug/relationships.d.ts +15 -7
  29. package/lib/debug/store.d.ts +1190 -291
  30. package/lib/debug/tools.d.ts +31 -31
  31. package/lib/debug/tools.js +692 -484
  32. package/lib/es6/checkpoints.d.ts +13 -11
  33. package/lib/es6/indexes.d.ts +15 -7
  34. package/lib/es6/metrics.d.ts +9 -7
  35. package/lib/es6/persisters.d.ts +30 -24
  36. package/lib/es6/queries.d.ts +10 -6
  37. package/lib/es6/relationships.d.ts +15 -7
  38. package/lib/es6/store.d.ts +1190 -291
  39. package/lib/es6/tools.d.ts +31 -31
  40. package/lib/es6/tools.js +1 -1
  41. package/lib/es6/tools.js.gz +0 -0
  42. package/lib/indexes.d.ts +15 -7
  43. package/lib/metrics.d.ts +9 -7
  44. package/lib/persisters.d.ts +30 -24
  45. package/lib/queries.d.ts +10 -6
  46. package/lib/relationships.d.ts +15 -7
  47. package/lib/store.d.ts +1190 -291
  48. package/lib/tools.d.ts +31 -31
  49. package/lib/tools.js +1 -1
  50. package/lib/tools.js.gz +0 -0
  51. package/lib/umd/checkpoints.d.ts +13 -11
  52. package/lib/umd/indexes.d.ts +15 -7
  53. package/lib/umd/metrics.d.ts +9 -7
  54. package/lib/umd/persisters.d.ts +30 -24
  55. package/lib/umd/queries.d.ts +10 -6
  56. package/lib/umd/relationships.d.ts +15 -7
  57. package/lib/umd/store.d.ts +1190 -291
  58. package/lib/umd/tools.d.ts +31 -31
  59. package/lib/umd/tools.js +1 -1
  60. package/lib/umd/tools.js.gz +0 -0
  61. package/lib/umd-es6/checkpoints.d.ts +13 -11
  62. package/lib/umd-es6/indexes.d.ts +15 -7
  63. package/lib/umd-es6/metrics.d.ts +9 -7
  64. package/lib/umd-es6/persisters.d.ts +30 -24
  65. package/lib/umd-es6/queries.d.ts +10 -6
  66. package/lib/umd-es6/relationships.d.ts +15 -7
  67. package/lib/umd-es6/store.d.ts +1190 -291
  68. package/lib/umd-es6/tools.d.ts +31 -31
  69. package/lib/umd-es6/tools.js +1 -1
  70. package/lib/umd-es6/tools.js.gz +0 -0
  71. package/package.json +23 -23
  72. package/readme.md +1 -1
@@ -27,7 +27,7 @@
27
27
  * @module persisters
28
28
  */
29
29
 
30
- import {Store, Tables, Values} from './store.d';
30
+ import {NoSchemas, OptionalSchemas, 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<Schemas extends OptionalSchemas = NoSchemas> {
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,7 +206,10 @@ export interface Persister {
206
206
  * ```
207
207
  * @category Load
208
208
  */
209
- load(initialTables?: Tables, initialValues?: Values): Promise<Persister>;
209
+ load(
210
+ initialTables?: Tables<Schemas[0], true>,
211
+ initialValues?: Values,
212
+ ): Promise<Persister<Schemas>>;
210
213
 
211
214
  /**
212
215
  * The startAutoLoad method gets persisted data from storage, and loads it
@@ -263,9 +266,9 @@ export interface Persister {
263
266
  * @category Load
264
267
  */
265
268
  startAutoLoad(
266
- initialTables?: Tables,
269
+ initialTables?: Tables<Schemas[0], true>,
267
270
  initialValues?: Values,
268
- ): Promise<Persister>;
271
+ ): Promise<Persister<Schemas>>;
269
272
 
270
273
  /**
271
274
  * The stopAutoLoad method stops the automatic loading of data from storage
@@ -310,7 +313,7 @@ export interface Persister {
310
313
  * ```
311
314
  * @category Load
312
315
  */
313
- stopAutoLoad(): Persister;
316
+ stopAutoLoad(): Persister<Schemas>;
314
317
 
315
318
  /**
316
319
  * The save method takes data from the Store with which the Persister is
@@ -339,7 +342,7 @@ export interface Persister {
339
342
  * ```
340
343
  * @category Save
341
344
  */
342
- save(): Promise<Persister>;
345
+ save(): Promise<Persister<Schemas>>;
343
346
 
344
347
  /**
345
348
  * The save method takes data from the Store with which the Persister is
@@ -377,7 +380,7 @@ export interface Persister {
377
380
  * ```
378
381
  * @category Save
379
382
  */
380
- startAutoSave(): Promise<Persister>;
383
+ startAutoSave(): Promise<Persister<Schemas>>;
381
384
 
382
385
  /**
383
386
  * The stopAutoSave method stops the automatic save of data to storage
@@ -415,7 +418,7 @@ export interface Persister {
415
418
  * ```
416
419
  * @category Save
417
420
  */
418
- stopAutoSave(): Persister;
421
+ stopAutoSave(): Persister<Schemas>;
419
422
 
420
423
  /**
421
424
  * The getStore method returns a reference to the underlying Store that is
@@ -439,7 +442,7 @@ export interface Persister {
439
442
  * ```
440
443
  * @category Getter
441
444
  */
442
- getStore(): Store;
445
+ getStore(): Store<Schemas>;
443
446
 
444
447
  /**
445
448
  * The destroy method should be called when this Persister object is no longer
@@ -470,7 +473,7 @@ export interface Persister {
470
473
  * ```
471
474
  * @category Lifecycle
472
475
  */
473
- destroy(): Persister;
476
+ destroy(): Persister<Schemas>;
474
477
 
475
478
  /**
476
479
  * The getStats method provides a set of statistics about the Persister, and
@@ -546,10 +549,10 @@ export interface Persister {
546
549
  * ```
547
550
  * @category Creation
548
551
  */
549
- export function createSessionPersister(
550
- store: Store,
552
+ export function createSessionPersister<Schemas extends OptionalSchemas>(
553
+ store: Store<Schemas>,
551
554
  storageName: string,
552
- ): Persister;
555
+ ): Persister<Schemas>;
553
556
 
554
557
  /**
555
558
  * The createLocalPersister function creates a Persister object that can
@@ -579,10 +582,10 @@ export function createSessionPersister(
579
582
  * ```
580
583
  * @category Creation
581
584
  */
582
- export function createLocalPersister(
583
- store: Store,
585
+ export function createLocalPersister<Schemas extends OptionalSchemas>(
586
+ store: Store<Schemas>,
584
587
  storageName: string,
585
- ): Persister;
588
+ ): Persister<Schemas>;
586
589
 
587
590
  /**
588
591
  * The createRemotePersister function creates a Persister object that can
@@ -626,12 +629,12 @@ export function createLocalPersister(
626
629
  * ```
627
630
  * @category Creation
628
631
  */
629
- export function createRemotePersister(
630
- store: Store,
632
+ export function createRemotePersister<Schemas extends OptionalSchemas>(
633
+ store: Store<Schemas>,
631
634
  loadUrl: string,
632
635
  saveUrl: string,
633
636
  autoLoadIntervalSeconds: number,
634
- ): Persister;
637
+ ): Persister<Schemas>;
635
638
 
636
639
  /**
637
640
  * The createFilePersister function creates a Persister object that can persist
@@ -661,7 +664,10 @@ export function createRemotePersister(
661
664
  * ```
662
665
  * @category Creation
663
666
  */
664
- export function createFilePersister(store: Store, filePath: string): Persister;
667
+ export function createFilePersister<Schemas extends OptionalSchemas>(
668
+ store: Store<Schemas>,
669
+ filePath: string,
670
+ ): Persister<Schemas>;
665
671
 
666
672
  /**
667
673
  * The createCustomPersister function creates a Persister object that you can
@@ -718,10 +724,10 @@ export function createFilePersister(store: Store, filePath: string): Persister;
718
724
  * ```
719
725
  * @category Creation
720
726
  */
721
- export function createCustomPersister(
722
- store: Store,
727
+ export function createCustomPersister<Schemas extends OptionalSchemas>(
728
+ store: Store<Schemas>,
723
729
  getPersisted: () => Promise<string | null | undefined>,
724
730
  setPersisted: (json: string) => Promise<void>,
725
731
  startListeningToPersisted: (didChange: Callback) => void,
726
732
  stopListeningToPersisted: Callback,
727
- ): Persister;
733
+ ): Persister<Schemas>;
@@ -18,6 +18,8 @@ import {
18
18
  CellOrUndefined,
19
19
  GetCell,
20
20
  GetCellChange,
21
+ NoSchemas,
22
+ OptionalSchemas,
21
23
  Row,
22
24
  RowCallback,
23
25
  Store,
@@ -1427,7 +1429,7 @@ export type Having = {
1427
1429
  * @category Queries
1428
1430
  * @since v2.0.0
1429
1431
  */
1430
- export interface Queries {
1432
+ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
1431
1433
  /**
1432
1434
  * The setQueryDefinition method lets you set the definition of a query.
1433
1435
  *
@@ -1501,7 +1503,7 @@ export interface Queries {
1501
1503
  group: Group;
1502
1504
  having: Having;
1503
1505
  }) => void,
1504
- ): Queries;
1506
+ ): Queries<Schemas>;
1505
1507
 
1506
1508
  /**
1507
1509
  * The delQueryDefinition method removes an existing query definition.
@@ -1534,7 +1536,7 @@ export interface Queries {
1534
1536
  * @category Configuration
1535
1537
  * @since v2.0.0
1536
1538
  */
1537
- delQueryDefinition(queryId: Id): Queries;
1539
+ delQueryDefinition(queryId: Id): Queries<Schemas>;
1538
1540
 
1539
1541
  /**
1540
1542
  * The getStore method returns a reference to the underlying Store that is
@@ -1560,7 +1562,7 @@ export interface Queries {
1560
1562
  * @category Getter
1561
1563
  * @since v2.0.0
1562
1564
  */
1563
- getStore(): Store;
1565
+ getStore(): Store<Schemas>;
1564
1566
 
1565
1567
  /**
1566
1568
  * The getQueryIds method returns an array of the query Ids registered with
@@ -2919,7 +2921,7 @@ export interface Queries {
2919
2921
  * @category Listener
2920
2922
  * @since v2.0.0
2921
2923
  */
2922
- delListener(listenerId: Id): Queries;
2924
+ delListener(listenerId: Id): Queries<Schemas>;
2923
2925
 
2924
2926
  /**
2925
2927
  * The destroy method should be called when this Queries object is no longer
@@ -3021,4 +3023,6 @@ export interface Queries {
3021
3023
  * @category Creation
3022
3024
  * @since v2.0.0
3023
3025
  */
3024
- export function createQueries(store: Store): Queries;
3026
+ export function createQueries<Schemas extends OptionalSchemas>(
3027
+ store: Store<Schemas>,
3028
+ ): Queries<Schemas>;
@@ -11,7 +11,13 @@
11
11
  * @module relationships
12
12
  */
13
13
 
14
- import {GetCell, RowCallback, Store} from './store.d';
14
+ import {
15
+ GetCell,
16
+ NoSchemas,
17
+ OptionalSchemas,
18
+ RowCallback,
19
+ Store,
20
+ } from './store.d';
15
21
  import {Id, IdOrNull, Ids} from './common.d';
16
22
 
17
23
  /**
@@ -247,7 +253,7 @@ export type RelationshipsListenerStats = {
247
253
  * @see Drawing demo
248
254
  * @category Relationships
249
255
  */
250
- export interface Relationships {
256
+ export interface Relationships<Schemas extends OptionalSchemas = NoSchemas> {
251
257
  /**
252
258
  * The setRelationshipDefinition method lets you set the definition of a
253
259
  * Relationship.
@@ -339,7 +345,7 @@ export interface Relationships {
339
345
  localTableId: Id,
340
346
  remoteTableId: Id,
341
347
  getRemoteRowId: Id | ((getCell: GetCell, localRowId: Id) => Id),
342
- ): Relationships;
348
+ ): Relationships<Schemas>;
343
349
 
344
350
  /**
345
351
  * The delRelationshipDefinition method removes an existing Relationship
@@ -379,7 +385,7 @@ export interface Relationships {
379
385
  * ```
380
386
  * @category Configuration
381
387
  */
382
- delRelationshipDefinition(relationshipId: Id): Relationships;
388
+ delRelationshipDefinition(relationshipId: Id): Relationships<Schemas>;
383
389
 
384
390
  /**
385
391
  * The getStore method returns a reference to the underlying Store that is
@@ -404,7 +410,7 @@ export interface Relationships {
404
410
  * ```
405
411
  * @category Getter
406
412
  */
407
- getStore(): Store;
413
+ getStore(): Store<Schemas>;
408
414
 
409
415
  /**
410
416
  * The getRelationshipIds method returns an array of the Relationship Ids
@@ -1081,7 +1087,7 @@ export interface Relationships {
1081
1087
  * ```
1082
1088
  * @category Listener
1083
1089
  */
1084
- delListener(listenerId: Id): Relationships;
1090
+ delListener(listenerId: Id): Relationships<Schemas>;
1085
1091
 
1086
1092
  /**
1087
1093
  * The destroy method should be called when this Relationships object is no
@@ -1198,4 +1204,6 @@ export interface Relationships {
1198
1204
  * ```
1199
1205
  * @category Creation
1200
1206
  */
1201
- export function createRelationships(store: Store): Relationships;
1207
+ export function createRelationships<Schemas extends OptionalSchemas>(
1208
+ store: Store<Schemas>,
1209
+ ): Relationships<Schemas>;