tinybase 6.2.0-beta.2 → 6.2.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 (76) hide show
  1. package/@types/common/index.d.ts +295 -0
  2. package/@types/common/with-schemas/index.d.ts +375 -0
  3. package/@types/mergeable-store/index.d.ts +5 -34
  4. package/@types/mergeable-store/with-schemas/index.d.ts +5 -34
  5. package/@types/omni/with-schemas/index.d.ts +3 -3
  6. package/common/index.js +62 -3
  7. package/common/with-schemas/index.js +62 -3
  8. package/index.js +133 -86
  9. package/mergeable-store/index.js +102 -94
  10. package/mergeable-store/with-schemas/index.js +102 -94
  11. package/min/common/index.js +1 -1
  12. package/min/common/index.js.gz +0 -0
  13. package/min/common/with-schemas/index.js +1 -1
  14. package/min/common/with-schemas/index.js.gz +0 -0
  15. package/min/index.js +1 -1
  16. package/min/index.js.gz +0 -0
  17. package/min/mergeable-store/index.js +1 -1
  18. package/min/mergeable-store/index.js.gz +0 -0
  19. package/min/mergeable-store/with-schemas/index.js +1 -1
  20. package/min/mergeable-store/with-schemas/index.js.gz +0 -0
  21. package/min/omni/index.js +1 -1
  22. package/min/omni/index.js.gz +0 -0
  23. package/min/omni/with-schemas/index.js +1 -1
  24. package/min/omni/with-schemas/index.js.gz +0 -0
  25. package/min/persisters/index.js +1 -1
  26. package/min/persisters/index.js.gz +0 -0
  27. package/min/persisters/persister-pglite/index.js +1 -1
  28. package/min/persisters/persister-pglite/index.js.gz +0 -0
  29. package/min/persisters/persister-pglite/with-schemas/index.js +1 -1
  30. package/min/persisters/persister-pglite/with-schemas/index.js.gz +0 -0
  31. package/min/persisters/persister-postgres/index.js +1 -1
  32. package/min/persisters/persister-postgres/index.js.gz +0 -0
  33. package/min/persisters/persister-postgres/with-schemas/index.js +1 -1
  34. package/min/persisters/persister-postgres/with-schemas/index.js.gz +0 -0
  35. package/min/persisters/with-schemas/index.js +1 -1
  36. package/min/persisters/with-schemas/index.js.gz +0 -0
  37. package/min/store/index.js +1 -1
  38. package/min/store/index.js.gz +0 -0
  39. package/min/store/with-schemas/index.js +1 -1
  40. package/min/store/with-schemas/index.js.gz +0 -0
  41. package/min/ui-react-inspector/index.js +1 -1
  42. package/min/ui-react-inspector/index.js.gz +0 -0
  43. package/min/ui-react-inspector/with-schemas/index.js +1 -1
  44. package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  45. package/min/with-schemas/index.js +1 -1
  46. package/min/with-schemas/index.js.gz +0 -0
  47. package/omni/index.js +2537 -307
  48. package/omni/with-schemas/index.js +2537 -307
  49. package/package.json +3 -3
  50. package/persisters/index.js +9 -9
  51. package/persisters/persister-durable-object-storage/index.js +12 -12
  52. package/persisters/persister-durable-object-storage/with-schemas/index.js +12 -12
  53. package/persisters/persister-pglite/index.js +11 -11
  54. package/persisters/persister-pglite/with-schemas/index.js +11 -11
  55. package/persisters/persister-postgres/index.js +11 -11
  56. package/persisters/persister-postgres/with-schemas/index.js +11 -11
  57. package/persisters/with-schemas/index.js +9 -9
  58. package/readme.md +2 -2
  59. package/releases.md +14 -1
  60. package/store/index.js +4 -4
  61. package/store/with-schemas/index.js +4 -4
  62. package/synchronizers/index.js +7 -7
  63. package/synchronizers/synchronizer-broadcast-channel/index.js +7 -7
  64. package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +7 -7
  65. package/synchronizers/synchronizer-local/index.js +7 -7
  66. package/synchronizers/synchronizer-local/with-schemas/index.js +7 -7
  67. package/synchronizers/synchronizer-ws-client/index.js +7 -7
  68. package/synchronizers/synchronizer-ws-client/with-schemas/index.js +7 -7
  69. package/synchronizers/synchronizer-ws-server/index.js +7 -7
  70. package/synchronizers/synchronizer-ws-server/with-schemas/index.js +7 -7
  71. package/synchronizers/synchronizer-ws-server-durable-object/index.js +7 -7
  72. package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +7 -7
  73. package/synchronizers/with-schemas/index.js +7 -7
  74. package/ui-react-inspector/index.js +1 -1
  75. package/ui-react-inspector/with-schemas/index.js +1 -1
  76. package/with-schemas/index.js +133 -86
@@ -6,6 +6,8 @@
6
6
  * @since v1.0.0
7
7
  */
8
8
 
9
+ import type {CellOrUndefined, ValueOrUndefined} from '../store/index.d.ts';
10
+
9
11
  /**
10
12
  * The Json type is a simple alias for a string, but is used to indicate that
11
13
  * the string should be considered to be a JSON serialization of an object.
@@ -93,6 +95,19 @@ export type GetNow = () => number;
93
95
  */
94
96
  export type Hlc = string;
95
97
 
98
+ /**
99
+ * The Hash type is used within TinyBase (for example in the mergeable-store
100
+ * module) to quickly compare the content of two objects.
101
+ *
102
+ * This is simply an alias for a JavaScript `number`.
103
+ *
104
+ * This type is mostly utilized internally within TinyBase itself and is
105
+ * generally assumed to be opaque to applications that use it.
106
+ * @category Stamps
107
+ * @since v6.2.0
108
+ */
109
+ export type Hash = number;
110
+
96
111
  /**
97
112
  * The defaultSorter function is provided as a convenience to sort keys
98
113
  * alphanumerically, and can be provided to the `sliceIdSorter` and
@@ -280,3 +295,283 @@ export function getHlcFunctions(
280
295
  getLastCounter: () => number,
281
296
  getClientId: () => Id,
282
297
  ];
298
+
299
+ /**
300
+ * The getHash function returns a deterministic hash of a string, which can be
301
+ * used to quickly compare the content of two entities.
302
+ *
303
+ * This is used internally within TinyBase (for example in the mergeable-store
304
+ * module) to quickly compare the content of two objects, but is also useful for
305
+ * applications that need to represent strings in a deterministic (though not
306
+ * cryptographically safe) way.
307
+ *
308
+ * The hash uses the Fowler–Noll–Vo hash approach, producing a JavaScript
309
+ * number. It is not guaranteed to be unique by any means, but small changes in
310
+ * input generally produce large changes in output, so it should be sufficient
311
+ * for most purposes.
312
+ * @param string The string to hash.
313
+ * @returns A hash of the string.
314
+ * @example
315
+ * This example gets the hash of two similar strings.
316
+ * ```js
317
+ * import {getHash} from 'tinybase';
318
+ * console.log(getHash('Hello, world!'));
319
+ * // -> 3985698964
320
+ * console.log(getHash('Hello, world?'));
321
+ * // -> 3549480870
322
+ * ```
323
+ * @category Hash
324
+ * @since v6.2.0
325
+ */
326
+ export function getHash(string: string): Hash;
327
+
328
+ /**
329
+ * The addOrRemoveHash function combines two hashes together, which, because it
330
+ * is a simple alias for bitwise XOR, serves both as addition and removal of one
331
+ * hash from the other.
332
+ *
333
+ * This is used internally within TinyBase to collate hashes of objects, such as
334
+ * producing a hash for a Table which is composed of the hashes of its Rows.
335
+ * @param hash1 A first hash.
336
+ * @param hash2 A second hash to add or remove from the first.
337
+ * @returns The resulting hash of the two hashes added to or removed from each
338
+ * other.
339
+ * @example
340
+ * This example adds two hashes together.
341
+ * ```js
342
+ * import {addOrRemoveHash} from 'tinybase';
343
+ *
344
+ * const hash1 = 123456789;
345
+ * const hash2 = 987654321;
346
+ * console.log(addOrRemoveHash(hash1, hash2));
347
+ * // -> 1032168868
348
+ *
349
+ * console.log(addOrRemoveHash(1032168868, hash1));
350
+ * // -> 987654321
351
+ * console.log(addOrRemoveHash(1032168868, hash2));
352
+ * // -> 123456789
353
+ * ```
354
+ * @category Hash
355
+ * @since v6.2.0
356
+ */
357
+ export function addOrRemoveHash(hash1: Hash, hash2: Hash): Hash;
358
+
359
+ /**
360
+ * The getTablesHash function returns a hash for the tabular part of a Store,
361
+ * based on each Table Id and hash.
362
+ * @param tableHashes An object containing each Table Id and its hash.
363
+ * @returns A hash of the Tables.
364
+ * @example
365
+ * This example gets the hash of the tabular part of a Store.
366
+ * ```js
367
+ * import {getTablesHash} from 'tinybase';
368
+ *
369
+ * const tableHashes = {
370
+ * pets: 4262151841, // hash of its contents
371
+ * };
372
+ *
373
+ * console.log(getTablesHash(tableHashes));
374
+ * // -> 278115833
375
+ * ```
376
+ * @category Hash
377
+ * @since v6.2.0
378
+ */
379
+ export function getTablesHash(tableHashes: {[tableId: Id]: Hash}): Hash;
380
+
381
+ /**
382
+ * The getTableInTablesHash function returns a hash for a single Table in a
383
+ * Store, based on its Id and hash (in turn produced from its Rows).
384
+ * @param tableId The Id of the Table.
385
+ * @param tableHash The hash of the Table.
386
+ * @returns A hash of the Table based on its content and Id.
387
+ * @example
388
+ * This example gets the hash of a Table and its Id.
389
+ * ```js
390
+ * import {getTableInTablesHash} from 'tinybase';
391
+ *
392
+ * const tableId = 'pets';
393
+ * const tableHash = 4262151841; // hash of its contents
394
+ *
395
+ * console.log(getTableInTablesHash(tableId, tableHash));
396
+ * // -> 278115833
397
+ * ```
398
+ * @category Hash
399
+ * @since v6.2.0
400
+ */
401
+ export function getTableInTablesHash(tableId: Id, tableHash: Hash): Hash;
402
+
403
+ /**
404
+ * The getTableHash function returns a hash for a single Table in a Store, based
405
+ * on each Row Id and hash.
406
+ * @param rowHashes An object containing each Row Id and its hash.
407
+ * @returns A hash of the Table.
408
+ * @example
409
+ * This example gets the hash of a Table.
410
+ * ```js
411
+ * import {getTableHash} from 'tinybase';
412
+ *
413
+ * const rowHashes = {
414
+ * fido: 1810444343, // hash of its contents
415
+ * };
416
+ *
417
+ * console.log(getTableHash(rowHashes));
418
+ * // -> 4262151841
419
+ * ```
420
+ * @category Hash
421
+ * @since v6.2.0
422
+ */
423
+ export function getTableHash(rowHashes: {[rowId: Id]: Hash}): Hash;
424
+
425
+ /**
426
+ * The getRowInTableHash function returns a hash for a single Row in a Table,
427
+ * based on its Id and hash (in turn produced from its Cells).
428
+ * @param rowId The Id of the Row.
429
+ * @param rowHash The hash of the Row.
430
+ * @returns A hash of the Row based on its content and Id.
431
+ * @example
432
+ * This example gets the hash of a Row and its Id.
433
+ * ```js
434
+ * import {getRowInTableHash} from 'tinybase';
435
+ *
436
+ * const rowId = 'fido';
437
+ * const rowHash = 1810444343; // hash of its contents
438
+ *
439
+ * console.log(getRowInTableHash(rowId, rowHash));
440
+ * // -> 4262151841
441
+ * ```
442
+ * @category Hash
443
+ * @since v6.2.0
444
+ */
445
+ export function getRowInTableHash(rowId: Id, rowHash: Hash): Hash;
446
+
447
+ /**
448
+ * The getRowHash function returns a hash for a single Row in a Table, based on
449
+ * each Cell Id and hash.
450
+ * @param cellHashes An object containing each Cell Id and its hash.
451
+ * @returns A hash of the Row.
452
+ * @example
453
+ * This example gets the hash of a Row.
454
+ * ```js
455
+ * import {getRowHash} from 'tinybase';
456
+ *
457
+ * const cellHashes = {
458
+ * 'species': 3002200796, // hash of 'dog' and '03E3B------mmxrx'
459
+ * };
460
+ *
461
+ * console.log(getRowHash(cellHashes));
462
+ * // -> 1810444343
463
+ * ```
464
+ * @category Hash
465
+ * @since v6.2.0
466
+ */
467
+ export function getRowHash(cellHashes: {[cellId: Id]: Hash}): Hash;
468
+
469
+ /**
470
+ * The getCellInRowHash function returns a hash for a single Cell in a Row,
471
+ * based on its Id and hash (in turn produced from its value).
472
+ * @param cellId The Id of the Cell.
473
+ * @param cellHash The hash of the Cell.
474
+ * @returns A hash of the Cell based on its content and Id.
475
+ * @example
476
+ * This example gets the hash of a Cell and its Id.
477
+ * ```js
478
+ * import {getCellInRowHash} from 'tinybase';
479
+ *
480
+ * const cellId = 'species';
481
+ * const cellHash = '3002200796'; // hash of 'dog' and '03E3B------mmxrx'
482
+ *
483
+ * console.log(getCellInRowHash(cellId, cellHash));
484
+ * // -> 3777304796
485
+ * ```
486
+ * @category Hash
487
+ * @since v6.2.0
488
+ */
489
+ export function getCellInRowHash(cellId: Id, cellHash: Hash): Hash;
490
+
491
+ /**
492
+ * The getCellHash function returns a hash for a single Cell, based on its value
493
+ * and the HLC of the Cell.
494
+ * @param cell The Cell's value (or `undefined`).
495
+ * @param cellHlc The HLC of the Cell.
496
+ * @returns A hash of the Cell.
497
+ * @example
498
+ * This example gets the hash of a Cell and its HLC.
499
+ * ```js
500
+ * import {getCellHash} from 'tinybase';
501
+ *
502
+ * const cell = 'dog';
503
+ * const cellHlc = '03E3B------mmxrx';
504
+ *
505
+ * console.log(getCellHash(cell, cellHlc));
506
+ * // -> 3002200796
507
+ * ```
508
+ * @category Hash
509
+ * @since v6.2.0
510
+ */
511
+ export function getCellHash(cell: CellOrUndefined, cellHlc: Hlc): Hash;
512
+
513
+ /**
514
+ * The getValuesHash function returns a hash for a Values object, based on each
515
+ * Value Id and hash.
516
+ * @param valueHashes An object containing each Value Id and its hash.
517
+ * @returns A hash of the Values.
518
+ * @example
519
+ * This example gets the hash of a Values object.
520
+ * ```js
521
+ * import {getValuesHash} from 'tinybase';
522
+ *
523
+ * const valueHashes = {
524
+ * meaningOfLife: 312420374, // hash of 42 and '03E3B------mmxrx'
525
+ * };
526
+ *
527
+ * console.log(getValuesHash(valueHashes));
528
+ * // -> 4229195646
529
+ * ```
530
+ * @category Hash
531
+ * @since v6.2.0
532
+ */
533
+ export function getValuesHash(valueHashes: {[valueId: Id]: Hash}): Hash;
534
+
535
+ /**
536
+ * The getValueInValuesHash function returns a hash for a single Value in a
537
+ * Values object, based on its Id and hash (in turn produced from its value).
538
+ * @param valueId The Id of the Value.
539
+ * @param valueHash The hash of the Value.
540
+ * @returns A hash of the Value based on its content and Id.
541
+ * @example
542
+ * This example gets the hash of a Value and its Id.
543
+ * ```js
544
+ * import {getValueInValuesHash} from 'tinybase';
545
+ *
546
+ * const valueId = 'meaningOfLife';
547
+ * const valueHash = 312420374; // hash of 42 and '03E3B------mmxrx'
548
+ *
549
+ * console.log(getValueInValuesHash(valueId, valueHash));
550
+ * // -> 330198963
551
+ * ```
552
+ * @category Hash
553
+ * @since v6.2.0
554
+ */
555
+ export function getValueInValuesHash(valueId: Id, valueHash: Hash): Hash;
556
+
557
+ /**
558
+ * The getValueHash function returns a hash for a single Value, based on its
559
+ * value and the HLC of the Value.
560
+ * @param value The Value (or `undefined`).
561
+ * @param valueHlc The HLC of the Value.
562
+ * @returns A hash of the Value.
563
+ * @example
564
+ * This example gets the hash of a Value and its HLC.
565
+ * ```js
566
+ * import {getValueHash} from 'tinybase';
567
+ *
568
+ * const value = 42;
569
+ * const valueHlc = '03E3B------mmxrx';
570
+ *
571
+ * console.log(getValueHash(value, valueHlc));
572
+ * // -> 312420374
573
+ * ```
574
+ * @category Hash
575
+ * @since v6.2.0
576
+ */
577
+ export function getValueHash(value: ValueOrUndefined, valueHlc: Hlc): Hash;
@@ -6,6 +6,20 @@
6
6
  * @since v1.0.0
7
7
  */
8
8
 
9
+ import type {
10
+ CellIdFromSchema,
11
+ TableIdFromSchema,
12
+ ValueIdFromSchema,
13
+ } from '../../_internal/store/with-schemas/index.d.ts';
14
+ import type {
15
+ CellOrUndefined,
16
+ NoTablesSchema,
17
+ NoValuesSchema,
18
+ OptionalTablesSchema,
19
+ OptionalValuesSchema,
20
+ ValueOrUndefined,
21
+ } from '../../store/with-schemas/index.d.ts';
22
+
9
23
  /**
10
24
  * The Json type is a simple alias for a string, but is used to indicate that
11
25
  * the string should be considered to be a JSON serialization of an object.
@@ -93,6 +107,19 @@ export type GetNow = () => number;
93
107
  */
94
108
  export type Hlc = string;
95
109
 
110
+ /**
111
+ * The Hash type is used within TinyBase (for example in the mergeable-store
112
+ * module) to quickly compare the content of two objects.
113
+ *
114
+ * This is simply an alias for a JavaScript `number`.
115
+ *
116
+ * This type is mostly utilized internally within TinyBase itself and is
117
+ * generally assumed to be opaque to applications that use it.
118
+ * @category Stamps
119
+ * @since v6.2.0
120
+ */
121
+ export type Hash = number;
122
+
96
123
  /**
97
124
  * The defaultSorter function is provided as a convenience to sort keys
98
125
  * alphanumerically, and can be provided to the `sliceIdSorter` and
@@ -280,3 +307,351 @@ export function getHlcFunctions(
280
307
  getLastCounter: () => number,
281
308
  getClientId: () => Id,
282
309
  ];
310
+
311
+ /**
312
+ * The getHash function returns a deterministic hash of a string, which can be
313
+ * used to quickly compare the content of two entities.
314
+ *
315
+ * This is used internally within TinyBase (for example in the mergeable-store
316
+ * module) to quickly compare the content of two objects, but is also useful for
317
+ * applications that need to represent strings in a deterministic (though not
318
+ * cryptographically safe) way.
319
+ *
320
+ * The hash uses the Fowler–Noll–Vo hash approach, producing a JavaScript
321
+ * number. It is not guaranteed to be unique by any means, but small changes in
322
+ * input generally produce large changes in output, so it should be sufficient
323
+ * for most purposes.
324
+ * @param string The string to hash.
325
+ * @returns A hash of the string.
326
+ * @example
327
+ * This example gets the hash of two similar strings.
328
+ * ```js
329
+ * import {getHash} from 'tinybase';
330
+ * console.log(getHash('Hello, world!'));
331
+ * // -> 3985698964
332
+ * console.log(getHash('Hello, world?'));
333
+ * // -> 3549480870
334
+ * ```
335
+ * @category Hash
336
+ * @since v6.2.0
337
+ */
338
+ export function getHash(string: string): Hash;
339
+
340
+ /**
341
+ * The addOrRemoveHash function combines two hashes together, which, because it
342
+ * is a simple alias for bitwise XOR, serves both as addition and removal of one
343
+ * hash from the other.
344
+ *
345
+ * This is used internally within TinyBase to collate hashes of objects, such as
346
+ * producing a hash for a Table which is composed of the hashes of its Rows.
347
+ * @param hash1 A first hash.
348
+ * @param hash2 A second hash to add or remove from the first.
349
+ * @returns The resulting hash of the two hashes added to or removed from each
350
+ * other.
351
+ * @example
352
+ * This example adds two hashes together.
353
+ * ```js
354
+ * import {addOrRemoveHash} from 'tinybase';
355
+ *
356
+ * const hash1 = 123456789;
357
+ * const hash2 = 987654321;
358
+ * console.log(addOrRemoveHash(hash1, hash2));
359
+ * // -> 1032168868
360
+ *
361
+ * console.log(addOrRemoveHash(1032168868, hash1));
362
+ * // -> 987654321
363
+ * console.log(addOrRemoveHash(1032168868, hash2));
364
+ * // -> 123456789
365
+ * ```
366
+ * @category Hash
367
+ * @since v6.2.0
368
+ */
369
+ export function addOrRemoveHash(hash1: Hash, hash2: Hash): Hash;
370
+
371
+ /**
372
+ * The getTablesHash function returns a hash for the tabular part of a Store,
373
+ * based on each Table Id and hash.
374
+ * @param tableHashes An object containing each Table Id and its hash.
375
+ * @returns A hash of the Tables.
376
+ * @example
377
+ * This example gets the hash of the tabular part of a Store.
378
+ * ```js
379
+ * import {getTablesHash} from 'tinybase';
380
+ *
381
+ * This has schema-based typing. The following is a simplified representation:
382
+ *
383
+ * ```ts override
384
+ * getTablesHash(tableHashes: {[tableId: Id]: Hash}): Hash;
385
+ * ```
386
+ *
387
+ * const tableHashes = {
388
+ * pets: 4262151841, // hash of its contents
389
+ * };
390
+ *
391
+ * console.log(getTablesHash(tableHashes));
392
+ * // -> 278115833
393
+ * ```
394
+ * @category Hash
395
+ * @since v6.2.0
396
+ */
397
+ export function getTablesHash<
398
+ Schema extends OptionalTablesSchema = NoTablesSchema,
399
+ >(tableHashes: {[TableId in TableIdFromSchema<Schema>]: Hash}): Hash;
400
+
401
+ /**
402
+ * The getTableInTablesHash function returns a hash for a single Table in a
403
+ * Store, based on its Id and hash (in turn produced from its Rows).
404
+ * @param tableId The Id of the Table.
405
+ * @param tableHash The hash of the Table.
406
+ * @returns A hash of the Table based on its content and Id.
407
+ * @example
408
+ * This example gets the hash of a Table and its Id.
409
+ * ```js
410
+ * import {getTableInTablesHash} from 'tinybase';
411
+ *
412
+ * This has schema-based typing. The following is a simplified representation:
413
+ *
414
+ * ```ts override
415
+ * getTableInTablesHash(tableId: Id, tableHash: Hash): Hash;
416
+ * ```
417
+ *
418
+ * const tableId = 'pets';
419
+ * const tableHash = 4262151841; // hash of its contents
420
+ *
421
+ * console.log(getTableInTablesHash(tableId, tableHash));
422
+ * // -> 278115833
423
+ * ```
424
+ * @category Hash
425
+ * @since v6.2.0
426
+ */
427
+ export function getTableInTablesHash<
428
+ Schema extends OptionalTablesSchema = NoTablesSchema,
429
+ >(tableId: TableIdFromSchema<Schema>, tableHash: Hash): Hash;
430
+
431
+ /**
432
+ * The getTableHash function returns a hash for a single Table in a Store, based
433
+ * on each Row Id and hash.
434
+ * @param rowHashes An object containing each Row Id and its hash.
435
+ * @returns A hash of the Table.
436
+ * @example
437
+ * This example gets the hash of a Table.
438
+ * ```js
439
+ * import {getTableHash} from 'tinybase';
440
+ *
441
+ * const rowHashes = {
442
+ * fido: 1810444343, // hash of its contents
443
+ * };
444
+ *
445
+ * console.log(getTableHash(rowHashes));
446
+ * // -> 4262151841
447
+ * ```
448
+ * @category Hash
449
+ * @since v6.2.0
450
+ */
451
+ export function getTableHash(rowHashes: {[rowId: Id]: Hash}): Hash;
452
+
453
+ /**
454
+ * The getRowInTableHash function returns a hash for a single Row in a Table,
455
+ * based on its Id and hash (in turn produced from its Cells).
456
+ * @param rowId The Id of the Row.
457
+ * @param rowHash The hash of the Row.
458
+ * @returns A hash of the Row based on its content and Id.
459
+ * @example
460
+ * This example gets the hash of a Row and its Id.
461
+ * ```js
462
+ * import {getRowInTableHash} from 'tinybase';
463
+ *
464
+ * const rowId = 'fido';
465
+ * const rowHash = 1810444343; // hash of its contents
466
+ *
467
+ * console.log(getRowInTableHash(rowId, rowHash));
468
+ * // -> 4262151841
469
+ * ```
470
+ * @category Hash
471
+ * @since v6.2.0
472
+ */
473
+ export function getRowInTableHash(rowId: Id, rowHash: Hash): Hash;
474
+
475
+ /**
476
+ * The getRowHash function returns a hash for a single Row in a Table, based on
477
+ * each Cell Id and hash.
478
+ * @param cellHashes An object containing each Cell Id and its hash.
479
+ * @returns A hash of the Row.
480
+ * @example
481
+ * This example gets the hash of a Row.
482
+ * ```js
483
+ * import {getRowHash} from 'tinybase';
484
+ *
485
+ * This has schema-based typing. The following is a simplified representation:
486
+ *
487
+ * ```ts override
488
+ * getRowHash(cellHashes: {[cellId: Id]: Hash}): Hash;
489
+ * ```
490
+ *
491
+ * const cellHashes = {
492
+ * 'species': 3002200796, // hash of 'dog' and '03E3B------mmxrx'
493
+ * };
494
+ *
495
+ * console.log(getRowHash(cellHashes));
496
+ * // -> 1810444343
497
+ * ```
498
+ * @category Hash
499
+ * @since v6.2.0
500
+ */
501
+ export function getRowHash<
502
+ Schema extends OptionalTablesSchema = NoTablesSchema,
503
+ TableId extends TableIdFromSchema<Schema> = Id,
504
+ >(cellHashes: {[CellId in CellIdFromSchema<Schema, TableId>]?: Hash}): Hash;
505
+
506
+ /**
507
+ * The getCellInRowHash function returns a hash for a single Cell in a Row,
508
+ * based on its Id and hash (in turn produced from its value).
509
+ * @param cellId The Id of the Cell.
510
+ * @param cellHash The hash of the Cell.
511
+ * @returns A hash of the Cell based on its content and Id.
512
+ * @example
513
+ * This example gets the hash of a Cell and its Id.
514
+ * ```js
515
+ * import {getCellInRowHash} from 'tinybase';
516
+ *
517
+ * This has schema-based typing. The following is a simplified representation:
518
+ *
519
+ * ```ts override
520
+ * getCellInRowHash(cellId: Id, cellHash: Hash): Hash;
521
+ * ```
522
+ *
523
+ * const cellId = 'species';
524
+ * const cellHash = '3002200796'; // hash of 'dog' and '03E3B------mmxrx'
525
+ *
526
+ * console.log(getCellInRowHash(cellId, cellHash));
527
+ * // -> 3777304796
528
+ * ```
529
+ * @category Hash
530
+ * @since v6.2.0
531
+ */
532
+ export function getCellInRowHash<
533
+ Schema extends OptionalTablesSchema = NoTablesSchema,
534
+ TableId extends TableIdFromSchema<Schema> = Id,
535
+ >(cellId: CellIdFromSchema<Schema, TableId>, cellHash: Hash): Hash;
536
+
537
+ /**
538
+ * The getCellHash function returns a hash for a single Cell, based on its value
539
+ * and the HLC of the Cell.
540
+ * @param cell The Cell's value (or `undefined`).
541
+ * @param cellHlc The HLC of the Cell.
542
+ * @returns A hash of the Cell.
543
+ * @example
544
+ * This example gets the hash of a Cell and its HLC.
545
+ * ```js
546
+ * import {getCellHash} from 'tinybase';
547
+ *
548
+ * This has schema-based typing. The following is a simplified representation:
549
+ *
550
+ * ```ts override
551
+ * getCellHash(cell: CellOrUndefined, cellHlc: Hlc): Hash;
552
+ * ```
553
+ *
554
+ * const cell = 'dog';
555
+ * const cellHlc = '03E3B------mmxrx';
556
+ *
557
+ * console.log(getCellHash(cell, cellHlc));
558
+ * // -> 3002200796
559
+ * ```
560
+ * @category Hash
561
+ * @since v6.2.0
562
+ */
563
+ export function getCellHash<
564
+ Schema extends OptionalTablesSchema = NoTablesSchema,
565
+ TableId extends TableIdFromSchema<Schema> = Id,
566
+ CellId extends CellIdFromSchema<Schema, TableId> = Id,
567
+ >(cell: CellOrUndefined<Schema, TableId, CellId>, cellHlc: Hlc): Hash;
568
+
569
+ /**
570
+ * The getValuesHash function returns a hash for a Values object, based on each
571
+ * Value Id and hash.
572
+ * @param valueHashes An object containing each Value Id and its hash.
573
+ * @returns A hash of the Values.
574
+ * @example
575
+ * This example gets the hash of a Values object.
576
+ * ```js
577
+ * import {getValuesHash} from 'tinybase';
578
+ *
579
+ * This has schema-based typing. The following is a simplified representation:
580
+ *
581
+ * ```ts override
582
+ * getValuesHash(valueHashes: {[valueId: Id]: Hash}): Hash;
583
+ * ```
584
+ *
585
+ * const valueHashes = {
586
+ * meaningOfLife: 312420374, // hash of 42 and '03E3B------mmxrx'
587
+ * };
588
+ *
589
+ * console.log(getValuesHash(valueHashes));
590
+ * // -> 4229195646
591
+ * ```
592
+ * @category Hash
593
+ * @since v6.2.0
594
+ */
595
+ export function getValuesHash<
596
+ Schema extends OptionalValuesSchema = NoValuesSchema,
597
+ >(valueHashes: {[ValueId in ValueIdFromSchema<Schema>]?: Hash}): Hash;
598
+
599
+ /**
600
+ * The getValueInValuesHash function returns a hash for a single Value in a
601
+ * Values object, based on its Id and hash (in turn produced from its value).
602
+ * @param valueId The Id of the Value.
603
+ * @param valueHash The hash of the Value.
604
+ * @returns A hash of the Value based on its content and Id.
605
+ * @example
606
+ * This example gets the hash of a Value and its Id.
607
+ * ```js
608
+ * import {getValueInValuesHash} from 'tinybase';
609
+ *
610
+ * This has schema-based typing. The following is a simplified representation:
611
+ *
612
+ * ```ts override
613
+ * getValueInValuesHash(valueId: Id, valueHash: Hash): Hash;
614
+ * ```
615
+ *
616
+ * const valueId = 'meaningOfLife';
617
+ * const valueHash = 312420374; // hash of 42 and '03E3B------mmxrx'
618
+ *
619
+ * console.log(getValueInValuesHash(valueId, valueHash));
620
+ * // -> 330198963
621
+ * ```
622
+ * @category Hash
623
+ * @since v6.2.0
624
+ */
625
+ export function getValueInValuesHash<
626
+ Schema extends OptionalValuesSchema = NoValuesSchema,
627
+ >(valueId: ValueIdFromSchema<Schema>, valueHash: Hash): Hash;
628
+
629
+ /**
630
+ * The getValueHash function returns a hash for a single Value, based on its
631
+ * value and the HLC of the Value.
632
+ * @param value The Value (or `undefined`).
633
+ * @param valueHlc The HLC of the Value.
634
+ * @returns A hash of the Value.
635
+ * @example
636
+ * This example gets the hash of a Value and its HLC.
637
+ * ```js
638
+ * import {getValueHash} from 'tinybase';
639
+ *
640
+ * This has schema-based typing. The following is a simplified representation:
641
+ *
642
+ * ```ts override
643
+ * getValueHash(value: ValueOrUndefined, valueHlc: Hlc): Hash;
644
+ * ```
645
+ *
646
+ * const value = 42;
647
+ * const valueHlc = '03E3B------mmxrx';
648
+ *
649
+ * console.log(getValueHash(value, valueHlc));
650
+ * // -> 312420374
651
+ * ```
652
+ * @category Hash
653
+ * @since v6.2.0
654
+ */
655
+ export function getValueHash<
656
+ Schema extends OptionalValuesSchema = NoValuesSchema,
657
+ >(value: ValueOrUndefined<Schema, Id>, valueHlc: Hlc): Hash;