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
@@ -10,7 +10,13 @@
10
10
  * @since v2.2.0
11
11
  */
12
12
 
13
- import {Store, TablesSchema, ValuesSchema} from './store.d';
13
+ import {
14
+ NoSchemas,
15
+ OptionalSchemas,
16
+ Store,
17
+ TablesSchema,
18
+ ValuesSchema,
19
+ } from './store.d';
14
20
  import {Id} from './common.d';
15
21
 
16
22
  /**
@@ -109,7 +115,7 @@ export type StoreStatsRowDetail = {
109
115
  * @category Tools
110
116
  * @since v2.2.0
111
117
  */
112
- export interface Tools {
118
+ export interface Tools<Schemas extends OptionalSchemas = NoSchemas> {
113
119
  /* eslint-disable max-len */
114
120
  /**
115
121
  * The getStoreStats method provides a set of statistics about the Store, and
@@ -272,9 +278,9 @@ export interface Tools {
272
278
  getStoreValuesSchema(): ValuesSchema;
273
279
 
274
280
  /**
275
- * The getStoreApi method returns code-generated .d.ts and .ts(x) files that
276
- * describe the schema of a Store and React bindings (since v3.1.0) in an ORM
277
- * style.
281
+ * The getStoreApi method returns code-generated `.d.ts` and `.ts(x)` files
282
+ * that describe the schema of a Store and React bindings (since v3.1.0) in an
283
+ * ORM style.
278
284
  *
279
285
  * If the Store does not already have an explicit TablesSchema or ValuesSchema
280
286
  * associated with it, the data in the Store will be scanned to attempt to
@@ -290,12 +296,12 @@ export interface Tools {
290
296
  * - `[storeName]-ui-react.d.ts`
291
297
  * - `[storeName]-ui-react.tsx`
292
298
  *
293
- * Also you should save these alongside each other so that the .ts(x) files
294
- * can import types from the .d.ts files.
299
+ * Also you should save these alongside each other so that the `.ts(x)` files
300
+ * can import types from the `.d.ts` files.
295
301
  *
296
- * The .d.ts and .ts(x) files that are generated are designed to resemble the
297
- * main TinyBase Store and React binding files, but provide named types and
298
- * methods that describe the domain of the schema in the store.
302
+ * The `.d.ts` and `.ts(x)` files that are generated are designed to resemble
303
+ * the main TinyBase Store and React binding files, but provide named types
304
+ * and methods that describe the domain of the schema in the Store.
299
305
  *
300
306
  * For example, from a Store that has a `pets` Table, you will get methods
301
307
  * like `getPetsTable`, types like `PetsRow`, and hooks and components that
@@ -347,9 +353,7 @@ export interface Tools {
347
353
  *
348
354
  * const dTsLines = dTs.split('\n');
349
355
  * console.log(dTsLines[3]);
350
- * // -> 'export type PetsTable = {[rowId: Id]: PetsRow};'
351
- * console.log(dTsLines[6]);
352
- * // -> 'export type PetsRow = {\'price\'?: number;};'
356
+ * // -> `export type Tables = {'pets'?: {[rowId: Id]: {'price'?: number}}};`
353
357
  *
354
358
  * const tsLines = ts.split('\n');
355
359
  * console.log(tsLines[39]);
@@ -368,9 +372,7 @@ export interface Tools {
368
372
  *
369
373
  * const dTsLines = dTs.split('\n');
370
374
  * console.log(dTsLines[3]);
371
- * // -> 'export type PetsTable = {[rowId: Id]: PetsRow};'
372
- * console.log(dTsLines[6]);
373
- * // -> 'export type PetsRow = {\'price\': number;};'
375
+ * // -> `export type Tables = {'pets'?: {[rowId: Id]: {'price': number}}};`
374
376
  *
375
377
  * const tsLines = ts.split('\n');
376
378
  * console.log(tsLines[41]);
@@ -382,9 +384,9 @@ export interface Tools {
382
384
  getStoreApi(storeName: string): [string, string, string, string];
383
385
 
384
386
  /**
385
- * The getPrettyStoreApi method attempts to returns a prettified
386
- * code-generated .d.ts and .ts(x) files that describe the schema of a Store
387
- * and React bindings (since v3.1.0) in an ORM style.
387
+ * The getPrettyStoreApi method attempts to return prettified code-generated
388
+ * `.d.ts` and `.ts(x)` files that describe the schema of a Store and React
389
+ * bindings (since v3.1.0) in an ORM style.
388
390
  *
389
391
  * This is simply a wrapper around the getStoreApi method that attempts to
390
392
  * invoke the `prettier` module (which it hopes you have installed) to format
@@ -403,8 +405,8 @@ export interface Tools {
403
405
  * - `[storeName]-ui-react.d.ts`
404
406
  * - `[storeName]-ui-react.tsx`
405
407
  *
406
- * Also you should save these alongside each other so that the .ts(x) files
407
- * can import types from the .d.ts files.
408
+ * Also you should save these alongside each other so that the `.ts(x)` files
409
+ * can import types from the `.d.ts` files.
408
410
  *
409
411
  * See the documentation for the getStoreApi method for details of the content
410
412
  * of the generated files.
@@ -429,12 +431,10 @@ export interface Tools {
429
431
  *
430
432
  * const dTsLines = dTs.split('\n');
431
433
  * console.log(dTsLines[5]);
432
- * // -> 'export type PetsTable = {[rowId: Id]: PetsRow};'
433
- * console.log(dTsLines[10]);
434
- * // -> 'export type PetsRow = {price?: number};'
434
+ * // -> `export type Tables = {pets?: {[rowId: Id]: {price?: number}}};`
435
435
  *
436
436
  * const tsLines = ts.split('\n');
437
- * console.log(tsLines[75]);
437
+ * console.log(tsLines[79]);
438
438
  * // -> ' hasPetsTable: (): boolean => store.hasTable(PETS),'
439
439
  * ```
440
440
  * @example
@@ -452,12 +452,10 @@ export interface Tools {
452
452
  *
453
453
  * const dTsLines = dTs.split('\n');
454
454
  * console.log(dTsLines[5]);
455
- * // -> 'export type PetsTable = {[rowId: Id]: PetsRow};'
456
- * console.log(dTsLines[10]);
457
- * // -> 'export type PetsRow = {price: number};'
455
+ * // -> 'export type Tables = {pets?: {[rowId: Id]: {price: number}}};'
458
456
  *
459
457
  * const tsLines = ts.split('\n');
460
- * console.log(tsLines[77]);
458
+ * console.log(tsLines[81]);
461
459
  * // -> ' hasPetsTable: (): boolean => store.hasTable(PETS),'
462
460
  * ```
463
461
  * @category Modelling
@@ -485,7 +483,7 @@ export interface Tools {
485
483
  * @category Getter
486
484
  * @since v3.0.0
487
485
  */
488
- getStore(): Store;
486
+ getStore(): Store<Schemas>;
489
487
  }
490
488
 
491
489
  /* eslint-disable max-len */
@@ -532,5 +530,7 @@ export interface Tools {
532
530
  * @category Creation
533
531
  * @since v2.2.0
534
532
  */
535
- export function createTools(store: Store): Tools;
533
+ export function createTools<Schemas extends OptionalSchemas>(
534
+ store: Store<Schemas>,
535
+ ): Tools<Schemas>;
536
536
  /* eslint-enable max-len */