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.
Files changed (85) hide show
  1. package/lib/debug/ui-react.js +2 -2
  2. package/lib/{checkpoints.d.ts → types/checkpoints.d.ts} +13 -13
  3. package/lib/{debug → types}/indexes.d.ts +10 -16
  4. package/lib/{debug → types}/metrics.d.ts +49 -50
  5. package/lib/{debug → types}/persisters.d.ts +26 -30
  6. package/lib/{cjs-es6 → types}/queries.d.ts +474 -309
  7. package/lib/{debug → types}/relationships.d.ts +11 -17
  8. package/lib/{debug → types}/store.d.ts +180 -1038
  9. package/lib/types/tinybase.d.ts +14 -0
  10. package/lib/{debug → types}/tools.d.ts +12 -12
  11. package/lib/{debug → types}/ui-react.d.ts +11 -5
  12. package/lib/{cjs-es6 → types/with-schemas}/checkpoints.d.ts +93 -7
  13. package/lib/{cjs → types/with-schemas}/indexes.d.ts +136 -18
  14. package/lib/types/with-schemas/internal/queries.d.ts +15 -0
  15. package/lib/types/with-schemas/internal/store.d.ts +101 -0
  16. package/lib/types/with-schemas/internal/ui-react.d.ts +776 -0
  17. package/lib/{cjs → types/with-schemas}/metrics.d.ts +115 -50
  18. package/lib/{cjs → types/with-schemas}/persisters.d.ts +102 -4
  19. package/lib/{debug → types/with-schemas}/queries.d.ts +865 -346
  20. package/lib/{cjs → types/with-schemas}/relationships.d.ts +151 -20
  21. package/lib/{cjs-es6 → types/with-schemas}/store.d.ts +1082 -801
  22. package/lib/types/with-schemas/tinybase.d.ts +14 -0
  23. package/lib/{cjs-es6 → types/with-schemas}/tools.d.ts +21 -10
  24. package/lib/{cjs-es6 → types/with-schemas}/ui-react.d.ts +1871 -1314
  25. package/package.json +145 -29
  26. package/readme.md +14 -14
  27. package/lib/cjs/checkpoints.d.ts +0 -961
  28. package/lib/cjs/queries.d.ts +0 -3028
  29. package/lib/cjs/store.d.ts +0 -6143
  30. package/lib/cjs/tinybase.d.ts +0 -14
  31. package/lib/cjs/tools.d.ts +0 -536
  32. package/lib/cjs/ui-react.d.ts +0 -10921
  33. package/lib/cjs-es6/indexes.d.ts +0 -974
  34. package/lib/cjs-es6/metrics.d.ts +0 -829
  35. package/lib/cjs-es6/persisters.d.ts +0 -733
  36. package/lib/cjs-es6/relationships.d.ts +0 -1209
  37. package/lib/cjs-es6/tinybase.d.ts +0 -14
  38. package/lib/common.d.ts +0 -115
  39. package/lib/debug/checkpoints.d.ts +0 -961
  40. package/lib/debug/common.d.ts +0 -115
  41. package/lib/debug/tinybase.d.ts +0 -14
  42. package/lib/es6/checkpoints.d.ts +0 -961
  43. package/lib/es6/common.d.ts +0 -115
  44. package/lib/es6/indexes.d.ts +0 -974
  45. package/lib/es6/metrics.d.ts +0 -829
  46. package/lib/es6/persisters.d.ts +0 -733
  47. package/lib/es6/queries.d.ts +0 -3028
  48. package/lib/es6/relationships.d.ts +0 -1209
  49. package/lib/es6/store.d.ts +0 -6143
  50. package/lib/es6/tinybase.d.ts +0 -14
  51. package/lib/es6/tools.d.ts +0 -536
  52. package/lib/es6/ui-react.d.ts +0 -10921
  53. package/lib/indexes.d.ts +0 -974
  54. package/lib/metrics.d.ts +0 -829
  55. package/lib/persisters.d.ts +0 -733
  56. package/lib/queries.d.ts +0 -3028
  57. package/lib/relationships.d.ts +0 -1209
  58. package/lib/store.d.ts +0 -6143
  59. package/lib/tinybase.d.ts +0 -14
  60. package/lib/tools.d.ts +0 -536
  61. package/lib/ui-react.d.ts +0 -10921
  62. package/lib/umd/checkpoints.d.ts +0 -961
  63. package/lib/umd/common.d.ts +0 -115
  64. package/lib/umd/indexes.d.ts +0 -974
  65. package/lib/umd/metrics.d.ts +0 -829
  66. package/lib/umd/persisters.d.ts +0 -733
  67. package/lib/umd/queries.d.ts +0 -3028
  68. package/lib/umd/relationships.d.ts +0 -1209
  69. package/lib/umd/store.d.ts +0 -6143
  70. package/lib/umd/tinybase.d.ts +0 -14
  71. package/lib/umd/tools.d.ts +0 -536
  72. package/lib/umd/ui-react.d.ts +0 -10921
  73. package/lib/umd-es6/checkpoints.d.ts +0 -961
  74. package/lib/umd-es6/common.d.ts +0 -115
  75. package/lib/umd-es6/indexes.d.ts +0 -974
  76. package/lib/umd-es6/metrics.d.ts +0 -829
  77. package/lib/umd-es6/persisters.d.ts +0 -733
  78. package/lib/umd-es6/queries.d.ts +0 -3028
  79. package/lib/umd-es6/relationships.d.ts +0 -1209
  80. package/lib/umd-es6/store.d.ts +0 -6143
  81. package/lib/umd-es6/tinybase.d.ts +0 -14
  82. package/lib/umd-es6/tools.d.ts +0 -536
  83. package/lib/umd-es6/ui-react.d.ts +0 -10921
  84. /package/lib/{cjs-es6 → types}/common.d.ts +0 -0
  85. /package/lib/{cjs → types/with-schemas}/common.d.ts +0 -0
package/lib/tinybase.d.ts DELETED
@@ -1,14 +0,0 @@
1
- /**
2
- * This is everything.
3
- *
4
- * @packageDocumentation
5
- */
6
-
7
- export * from './checkpoints';
8
- export * from './common';
9
- export * from './indexes';
10
- export * from './metrics';
11
- export * from './persisters';
12
- export * from './queries';
13
- export * from './relationships';
14
- export * from './store';
package/lib/tools.d.ts DELETED
@@ -1,536 +0,0 @@
1
- /**
2
- * The tools module of the TinyBase project provides utilities for working with
3
- * TinyBase during development.
4
- *
5
- * This module is not intended to be directly used at runtime in a production
6
- * environment.
7
- *
8
- * @packageDocumentation
9
- * @module tools
10
- * @since v2.2.0
11
- */
12
-
13
- import {
14
- NoSchemas,
15
- OptionalSchemas,
16
- Store,
17
- TablesSchema,
18
- ValuesSchema,
19
- } from './store.d';
20
- import {Id} from './common.d';
21
-
22
- /**
23
- * The StoreStats type describes a set of statistics about the Store, and
24
- * is used for debugging purposes.
25
- *
26
- * A StoreStats object is returned from the getStoreStats method.
27
- *
28
- * @category Statistics
29
- * @since v2.2.0
30
- */
31
- export type StoreStats = {
32
- /**
33
- * The number of Table objects in the Store.
34
- */
35
- totalTables: number;
36
- /**
37
- * The number of Row objects in the Store, across all Table objects.
38
- */
39
- totalRows: number;
40
- /**
41
- * The number of Cell objects in the Store, across all Row objects, across all
42
- * Table objects.
43
- */
44
- totalCells: number;
45
- /**
46
- * The number of Value objects in the Store, since v3.0.0.
47
- */
48
- totalValues: number;
49
- /**
50
- * The string length of the Store when serialized to JSON.
51
- */
52
- jsonLength: number;
53
- /**
54
- * Additional detailed statistics about the Store if the `detail` flag is
55
- * specified in the getStoreStats method.
56
- */
57
- detail?: StoreStatsDetail;
58
- };
59
-
60
- /**
61
- * The StoreStatsDetail type describes a more detailed set of statistics about
62
- * the Store, and is used for debugging purposes.
63
- *
64
- * A StoreStatsDetail object is added to the StoreStats object (returned from
65
- * the getStoreStats method) when the `detail` flag is specified.
66
- *
67
- * @category Statistics
68
- * @since v2.2.0
69
- */
70
- export type StoreStatsDetail = {
71
- /**
72
- * Information about each Table in the Store.
73
- */
74
- tables: {[tableId: Id]: StoreStatsTableDetail};
75
- };
76
-
77
- /**
78
- * The StoreStatsTableDetail type describes a detailed set of statistics about a
79
- * single Table in the Store, and is used for debugging purposes.
80
- *
81
- * @category Statistics
82
- * @since v2.2.0
83
- */
84
- export type StoreStatsTableDetail = {
85
- /**
86
- * The number of Row objects in the Table.
87
- */
88
- tableRows: number;
89
- /**
90
- * The number of Cell objects in the Table, across all Row objects.
91
- */
92
- tableCells: number;
93
- rows: {[rowId: Id]: StoreStatsRowDetail};
94
- };
95
-
96
- /**
97
- * The StoreStatsRowDetail type describes statistics about a single Row in the
98
- * Store, and is used for debugging purposes.
99
- *
100
- * @category Statistics
101
- * @since v2.2.0
102
- */
103
- export type StoreStatsRowDetail = {
104
- /**
105
- * The number of Cell objects in the Row.
106
- */
107
- rowCells: number;
108
- };
109
-
110
- /**
111
- * A Tools object lets you run various utilities on, and get certain information
112
- * about, Store objects in development.
113
- *
114
- * @see Developer Tools guides
115
- * @category Tools
116
- * @since v2.2.0
117
- */
118
- export interface Tools<Schemas extends OptionalSchemas = NoSchemas> {
119
- /* eslint-disable max-len */
120
- /**
121
- * The getStoreStats method provides a set of statistics about the Store, and
122
- * is used for debugging purposes.
123
- *
124
- * @param detail An optional boolean that indicates more detailed stats about
125
- * the inner structure of the Store should be returned.
126
- * @returns A StoreStats object containing statistics about the Store.
127
- * @example
128
- * This example creates a Tools object and gets basic statistics about it.
129
- * ```js
130
- * const store = createStore()
131
- * .setTable('pets', {
132
- * fido: {species: 'dog', color: 'brown'},
133
- * felix: {species: 'cat', color: 'black'},
134
- * cujo: {species: 'dog', color: 'black'},
135
- * })
136
- * .setTable('species', {
137
- * dog: {price: 5},
138
- * cat: {price: 4},
139
- * })
140
- * .setValues({open: true, employees: 3});
141
- * const tools = createTools(store);
142
- * console.log(tools.getStoreStats());
143
- * // -> {totalTables: 2, totalRows: 5, totalCells: 8, totalValues: 2, jsonLength: 212}
144
- * ```
145
- * @example
146
- * This example creates a Tools object and gets detailed statistics about it.
147
- * ```js
148
- * const store = createStore()
149
- * .setTable('pets', {
150
- * fido: {species: 'dog', color: 'brown'},
151
- * felix: {species: 'cat', color: 'black'},
152
- * cujo: {species: 'dog', color: 'black'},
153
- * })
154
- * .setTable('species', {
155
- * dog: {price: 5},
156
- * cat: {price: 4},
157
- * });
158
- * const stats = createTools(store).getStoreStats(true);
159
- *
160
- * console.log(stats.totalTables);
161
- * // -> 2
162
- * console.log(stats.totalRows);
163
- * // -> 5
164
- * console.log(stats.totalCells);
165
- * // -> 8
166
- * console.log(stats.detail.tables.pets.tableRows);
167
- * // -> 3
168
- * console.log(stats.detail.tables.pets.tableCells);
169
- * // -> 6
170
- * console.log(stats.detail.tables.pets.rows);
171
- * // -> {fido: {rowCells: 2}, felix: {rowCells: 2}, cujo: {rowCells: 2}}
172
- * ```
173
- * @category Statistics
174
- * @since v2.2.0
175
- */
176
- getStoreStats(detail?: boolean): StoreStats;
177
- /* eslint-enable max-len */
178
-
179
- /**
180
- * The getStoreTablesSchema method returns the TablesSchema of the Store as an
181
- * object.
182
- *
183
- * If the Store does not already have an explicit TablesSchema associated with
184
- * it, the data in the Store will be scanned to attempt to infer a new
185
- * TablesSchema.
186
- *
187
- * To be successful, this requires all the values of a given Cell across a
188
- * Table object's Row objects to have a consistent type. If a given Cell Id
189
- * appears in every Row, then a `default` for that Cell is specified in the
190
- * TablesSchema, based on the most common value found.
191
- *
192
- * @returns A TablesSchema object for the Store.
193
- * @example
194
- * This example creates a Tools object and gets the schema of a Store that
195
- * already has a TablesSchema.
196
- * ```js
197
- * const store = createStore().setTablesSchema({
198
- * pets: {
199
- * species: {type: 'string'},
200
- * color: {type: 'string'},
201
- * },
202
- * species: {
203
- * price: {type: 'number'},
204
- * },
205
- * });
206
- * const schema = createTools(store).getStoreTablesSchema();
207
- * console.log(schema.pets);
208
- * // -> {species: {type: 'string'}, color: {type: 'string'}}
209
- * ```
210
- * @example
211
- * This example creates a Tools object and infers the schema of a Store that
212
- * doesn't already have a TablesSchema.
213
- * ```js
214
- * const store = createStore()
215
- * .setTable('pets', {
216
- * fido: {species: 'dog', color: 'brown'},
217
- * felix: {species: 'cat', color: 'black'},
218
- * cujo: {species: 'dog', color: 'black'},
219
- * })
220
- * .setTable('species', {
221
- * dog: {price: 5, barks: true},
222
- * cat: {price: 4, purrs: true},
223
- * });
224
- * const schema = createTools(store).getStoreTablesSchema();
225
- * console.log(schema.pets.species);
226
- * // -> {type: 'string', default: 'dog'}
227
- * console.log(schema.pets.color);
228
- * // -> {type: 'string', default: 'black'}
229
- * console.log(schema.species.price);
230
- * // -> {type: 'number', default: 5}
231
- * console.log(schema.species.barks);
232
- * // -> {type: 'boolean'}
233
- * console.log(schema.species.purrs);
234
- * // -> {type: 'boolean'}
235
- * ```
236
- * @category Modelling
237
- * @since v3.0.0
238
- */
239
- getStoreTablesSchema(): TablesSchema;
240
-
241
- /**
242
- * The getStoreValuesSchema method returns the ValuesSchema of the Store as an
243
- * object.
244
- *
245
- * If the Store does not already have an explicit ValuesSchema associated with
246
- * it, the data in the Store will be scanned to infer a new ValuesSchema,
247
- * based on the types of the Values present. Note that, unlike the inference
248
- * of Cell values in the TablesSchema, it is not able to determine whether a
249
- * Value should have a default or not.
250
- *
251
- * @returns A ValuesSchema object for the Store.
252
- * @example
253
- * This example creates a Tools object and gets the schema of a Store that
254
- * already has a ValuesSchema.
255
- * ```js
256
- * const store = createStore().setValuesSchema({
257
- * open: {type: 'boolean', default: true},
258
- * employees: {type: 'number'},
259
- * });
260
- *
261
- * const schema = createTools(store).getStoreValuesSchema();
262
- * console.log(schema);
263
- * // -> {open: {type: 'boolean', default: true}, employees: {type: 'number'}}
264
- * ```
265
- * @example
266
- * This example creates a Tools object and infers the schema of a Store that
267
- * doesn't already have a ValuesSchema.
268
- * ```js
269
- * const store = createStore().setValues({open: true, employees: 3});
270
- * const schema = createTools(store).getStoreValuesSchema();
271
- *
272
- * console.log(schema);
273
- * // -> {open: {type: 'boolean'}, employees: {type: 'number'}}
274
- * ```
275
- * @category Modelling
276
- * @since v3.0.0
277
- */
278
- getStoreValuesSchema(): ValuesSchema;
279
-
280
- /**
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.
284
- *
285
- * If the Store does not already have an explicit TablesSchema or ValuesSchema
286
- * associated with it, the data in the Store will be scanned to attempt to
287
- * infer new schemas. The method returns four strings (which should be saved
288
- * as files) though if no schema can be inferred, the strings will be empty.
289
- *
290
- * The method takes a single argument which represents the name you want the
291
- * generated store object to have in code. You are expected to save the four
292
- * files yourself, as, respectively:
293
- *
294
- * - `[storeName].d.ts`
295
- * - `[storeName].ts`
296
- * - `[storeName]-ui-react.d.ts`
297
- * - `[storeName]-ui-react.tsx`
298
- *
299
- * Also you should save these alongside each other so that the `.ts(x)` files
300
- * can import types from the `.d.ts` files.
301
- *
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.
305
- *
306
- * For example, from a Store that has a `pets` Table, you will get methods
307
- * like `getPetsTable`, types like `PetsRow`, and hooks and components that
308
- * are more specific versions of the underlying getTable method or the Row
309
- * type, and so on. For example:
310
- *
311
- * |Store type|Equivalent generated type|
312
- * |-|-|
313
- * |Table|[Table]Table|
314
- * |Row|[Table]Row|
315
- * |(Cell) Id|[Table]CellId|
316
- * |CellCallback|[Table]CellCallback|
317
- * |...|...|
318
- *
319
- * |Store method|Equivalent generated method|
320
- * |-|-|
321
- * |setTable|set[Table]Table|
322
- * |hasRow|has[Table]Row|
323
- * |getCell|get[Table][Cell]Cell|
324
- * |...|...|
325
- *
326
- * Equivalent to the TinyBase createStore function, a `create[StoreName]`
327
- * function will also be created. This acts as the main entry point to the
328
- * generated implementation.
329
- *
330
- * Each method is refined correctly to take, or return, the types specified by
331
- * the schema. For example, if the `pets` Table has a numeric `price` Cell in
332
- * the schema, the `getPetsPriceCell` method will be typed to return a number.
333
- *
334
- * The tables above include just a sample of the generated output. For the
335
- * full set of methods and types generated by this method, inspect the output
336
- * directly.
337
- *
338
- * @param storeName The name you want to provide to the generated Store, which
339
- * should also be used to save the `.d.ts`, `.ts`, and `.tsx` files.
340
- * @returns A set of four strings representing the contents of the `.d.ts`,
341
- * `.ts`, and `.tsx` files for the generated Store and React modules.
342
- * @example
343
- * This example creates a Tools object and generates code for a Store that
344
- * already has a TablesSchema.
345
- * ```js
346
- * const store = createStore().setTablesSchema({
347
- * pets: {
348
- * price: {type: 'number'},
349
- * },
350
- * });
351
- * const [dTs, ts, uiReactDTs, uiReactTsx] =
352
- * createTools(store).getStoreApi('shop');
353
- *
354
- * const dTsLines = dTs.split('\n');
355
- * console.log(dTsLines[3]);
356
- * // -> `export type Tables = {'pets'?: {[rowId: Id]: {'price'?: number}}};`
357
- *
358
- * const tsLines = ts.split('\n');
359
- * console.log(tsLines[39]);
360
- * // -> 'getPetsTable: (): PetsTable => store.getTable(PETS) as PetsTable,'
361
- * ```
362
- * @example
363
- * This example creates a Tools object and generates code for a Store that
364
- * doesn't already have a TablesSchema.
365
- * ```js
366
- * const store = createStore().setTable('pets', {
367
- * fido: {price: 5},
368
- * felix: {price: 4},
369
- * });
370
- * const [dTs, ts, uiReactDTs, uiReactTsx] =
371
- * createTools(store).getStoreApi('shop');
372
- *
373
- * const dTsLines = dTs.split('\n');
374
- * console.log(dTsLines[3]);
375
- * // -> `export type Tables = {'pets'?: {[rowId: Id]: {'price': number}}};`
376
- *
377
- * const tsLines = ts.split('\n');
378
- * console.log(tsLines[41]);
379
- * // -> 'getPetsTable: (): PetsTable => store.getTable(PETS) as PetsTable,'
380
- * ```
381
- * @category Modelling
382
- * @since v2.2.0
383
- */
384
- getStoreApi(storeName: string): [string, string, string, string];
385
-
386
- /**
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.
390
- *
391
- * This is simply a wrapper around the getStoreApi method that attempts to
392
- * invoke the `prettier` module (which it hopes you have installed) to format
393
- * the generated code. If `prettier` is not present, the output will resemble
394
- * that of the underlying getStoreApi method.
395
- *
396
- * The method is asynchronous, so you should use the `await` keyword or handle
397
- * the results as a promise.
398
- *
399
- * The method takes a single argument which represents the name you want the
400
- * generated store object to have in code. You are expected to save the four
401
- * files yourself, as, respectively:
402
- *
403
- * - `[storeName].d.ts`
404
- * - `[storeName].ts`
405
- * - `[storeName]-ui-react.d.ts`
406
- * - `[storeName]-ui-react.tsx`
407
- *
408
- * Also you should save these alongside each other so that the `.ts(x)` files
409
- * can import types from the `.d.ts` files.
410
- *
411
- * See the documentation for the getStoreApi method for details of the content
412
- * of the generated files.
413
- *
414
- * @param storeName The name you want to provide to the generated Store, which
415
- * should also be used to save the `.d.ts`, `.ts`, and `.tsx` files.
416
- * @returns A set of four strings representing the contents of the `.d.ts`,
417
- * `.ts`, and `.tsx` files for the generated Store and React modules.
418
- * @example
419
- * This example creates a Tools object and generates code for a Store that
420
- * already has a TablesSchema.
421
- * ```js
422
- * const store = createStore().setTablesSchema({
423
- * pets: {
424
- * price: {type: 'number'},
425
- * },
426
- * });
427
- * const tools = createTools(store);
428
- * const [dTs, ts, uiReactDTs, uiReactTsx] = await createTools(
429
- * store,
430
- * ).getPrettyStoreApi('shop');
431
- *
432
- * const dTsLines = dTs.split('\n');
433
- * console.log(dTsLines[5]);
434
- * // -> `export type Tables = {pets?: {[rowId: Id]: {price?: number}}};`
435
- *
436
- * const tsLines = ts.split('\n');
437
- * console.log(tsLines[79]);
438
- * // -> ' hasPetsTable: (): boolean => store.hasTable(PETS),'
439
- * ```
440
- * @example
441
- * This example creates a Tools object and generates code for a Store that
442
- * doesn't already have a TablesSchema.
443
- * ```js
444
- * const store = createStore().setTable('pets', {
445
- * fido: {price: 5},
446
- * felix: {price: 4},
447
- * });
448
- * const tools = createTools(store);
449
- * const [dTs, ts, uiReactDTs, uiReactTsx] = await createTools(
450
- * store,
451
- * ).getPrettyStoreApi('shop');
452
- *
453
- * const dTsLines = dTs.split('\n');
454
- * console.log(dTsLines[5]);
455
- * // -> 'export type Tables = {pets?: {[rowId: Id]: {price: number}}};'
456
- *
457
- * const tsLines = ts.split('\n');
458
- * console.log(tsLines[81]);
459
- * // -> ' hasPetsTable: (): boolean => store.hasTable(PETS),'
460
- * ```
461
- * @category Modelling
462
- * @since v2.2.0
463
- */
464
- getPrettyStoreApi(
465
- storeName: string,
466
- ): Promise<[string, string, string, string]>;
467
-
468
- /**
469
- * The getStore method returns a reference to the underlying Store that is
470
- * backing this Tools object.
471
- *
472
- * @returns A reference to the Store.
473
- * @example
474
- * This example creates a Tools object against a newly-created Store and
475
- * then gets its reference in order to update its data.
476
- *
477
- * ```js
478
- * const tools = createTools(createStore());
479
- * tools.getStore().setCell('species', 'dog', 'price', 5);
480
- * console.log(tools.getStoreStats().totalCells);
481
- * // -> 1
482
- * ```
483
- * @category Getter
484
- * @since v3.0.0
485
- */
486
- getStore(): Store<Schemas>;
487
- }
488
-
489
- /* eslint-disable max-len */
490
- /**
491
- * The createTools function creates a Tools object, and is the main entry point
492
- * into the tools module.
493
- *
494
- * A given Store can only have one Tools object associated with it. If you call
495
- * this function twice on the same Store, your second call will return a
496
- * reference to the Tools object created by the first.
497
- *
498
- * @param store The Store for which to register tools.
499
- * @returns A reference to the new Tools object.
500
- * @example
501
- * This example creates a Tools object.
502
- *
503
- * ```js
504
- * const store = createStore()
505
- * .setTable('pets', {
506
- * fido: {species: 'dog', color: 'brown'},
507
- * felix: {species: 'cat', color: 'black'},
508
- * cujo: {species: 'dog', color: 'black'},
509
- * })
510
- * .setTable('species', {
511
- * dog: {price: 5},
512
- * cat: {price: 4},
513
- * })
514
- * .setValues({open: true, employees: 3});
515
- * const tools = createTools(store);
516
- * console.log(tools.getStoreStats());
517
- * // -> {totalTables: 2, totalRows: 5, totalCells: 8, totalValues: 2, jsonLength: 212}
518
- * ```
519
- * @example
520
- * This example creates a Tools object, and calls the method a second time
521
- * for the same Store to return the same object.
522
- *
523
- * ```js
524
- * const store = createStore();
525
- * const tools1 = createTools(store);
526
- * const tools2 = createTools(store);
527
- * console.log(tools1 === tools2);
528
- * // -> true
529
- * ```
530
- * @category Creation
531
- * @since v2.2.0
532
- */
533
- export function createTools<Schemas extends OptionalSchemas>(
534
- store: Store<Schemas>,
535
- ): Tools<Schemas>;
536
- /* eslint-enable max-len */