tinybase 9.7.0-beta.1 → 9.7.1

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 (66) hide show
  1. package/@types/indexes/index.d.ts +3 -3
  2. package/@types/indexes/with-schemas/index.d.ts +3 -3
  3. package/@types/persisters/persister-electric-sql/index.d.ts +12 -0
  4. package/@types/persisters/persister-electric-sql/with-schemas/index.d.ts +12 -0
  5. package/@types/persisters/persister-sqlite3/index.d.ts +12 -0
  6. package/@types/persisters/persister-sqlite3/with-schemas/index.d.ts +12 -0
  7. package/@types/ui-react-dom/index.d.ts +10 -10
  8. package/@types/ui-react-dom/with-schemas/index.d.ts +10 -10
  9. package/@types/ui-react-dom-charts/index.d.ts +7 -7
  10. package/@types/ui-react-dom-charts/with-schemas/index.d.ts +7 -7
  11. package/@types/ui-react-inspector/index.d.ts +1 -1
  12. package/@types/ui-react-inspector/with-schemas/index.d.ts +1 -1
  13. package/@types/ui-solid-dom/index.d.ts +10 -10
  14. package/@types/ui-solid-dom/with-schemas/index.d.ts +10 -10
  15. package/@types/ui-solid-inspector/index.d.ts +1 -1
  16. package/@types/ui-solid-inspector/with-schemas/index.d.ts +1 -1
  17. package/@types/ui-svelte-dom/index.d.ts +10 -10
  18. package/@types/ui-svelte-dom/with-schemas/index.d.ts +10 -10
  19. package/@types/ui-svelte-inspector/index.d.ts +1 -1
  20. package/@types/ui-svelte-inspector/with-schemas/index.d.ts +1 -1
  21. package/agents.md +7 -0
  22. package/checkpoints/index.js +4 -2
  23. package/checkpoints/with-schemas/index.js +4 -2
  24. package/index.js +37 -4
  25. package/metrics/index.js +2 -1
  26. package/metrics/with-schemas/index.js +2 -1
  27. package/min/checkpoints/index.js +1 -1
  28. package/min/checkpoints/index.js.gz +0 -0
  29. package/min/checkpoints/with-schemas/index.js +1 -1
  30. package/min/checkpoints/with-schemas/index.js.gz +0 -0
  31. package/min/index.js +1 -1
  32. package/min/index.js.gz +0 -0
  33. package/min/metrics/index.js +1 -1
  34. package/min/metrics/index.js.gz +0 -0
  35. package/min/metrics/with-schemas/index.js +1 -1
  36. package/min/metrics/with-schemas/index.js.gz +0 -0
  37. package/min/omni/index.js +1 -1
  38. package/min/omni/index.js.gz +0 -0
  39. package/min/omni/with-schemas/index.js +1 -1
  40. package/min/omni/with-schemas/index.js.gz +0 -0
  41. package/min/queries/index.js +1 -1
  42. package/min/queries/index.js.gz +0 -0
  43. package/min/queries/with-schemas/index.js +1 -1
  44. package/min/queries/with-schemas/index.js.gz +0 -0
  45. package/min/relationships/index.js +1 -1
  46. package/min/relationships/index.js.gz +0 -0
  47. package/min/relationships/with-schemas/index.js +1 -1
  48. package/min/relationships/with-schemas/index.js.gz +0 -0
  49. package/min/synchronizers/synchronizer-local/index.js +1 -1
  50. package/min/synchronizers/synchronizer-local/index.js.gz +0 -0
  51. package/min/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
  52. package/min/synchronizers/synchronizer-local/with-schemas/index.js.gz +0 -0
  53. package/min/with-schemas/index.js +1 -1
  54. package/min/with-schemas/index.js.gz +0 -0
  55. package/omni/index.js +38 -5
  56. package/omni/with-schemas/index.js +38 -5
  57. package/package.json +5 -5
  58. package/queries/index.js +2 -1
  59. package/queries/with-schemas/index.js +2 -1
  60. package/readme.md +14 -14
  61. package/relationships/index.js +39 -9
  62. package/relationships/with-schemas/index.js +39 -9
  63. package/releases.md +72 -72
  64. package/synchronizers/synchronizer-local/index.js +1 -1
  65. package/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
  66. package/with-schemas/index.js +37 -4
@@ -17,6 +17,14 @@ const isArray = (thing) => Array.isArray(thing);
17
17
  const size = (thing) => thing.length;
18
18
  const test = (regex, subject) => regex.test(subject);
19
19
 
20
+ const arrayEvery = (array, cb) => array.every(cb);
21
+ const arrayIsEqual = (array1, array2) =>
22
+ size(array1) === size(array2) &&
23
+ arrayEvery(array1, (value1, index) => array2[index] === value1);
24
+ const arrayForEach = (array, cb) => array.forEach(cb);
25
+ const arrayPush = (array, ...values) => array.push(...values);
26
+ const arrayShift = (array) => array.shift();
27
+
20
28
  const collSizeN = (collSizer) => (coll) => {
21
29
  let total = 0;
22
30
  for (const child of coll.values()) {
@@ -34,14 +42,6 @@ const collClear = (coll) => coll.clear();
34
42
  const collForEach = (coll, cb) => coll?.forEach(cb);
35
43
  const collDel = (coll, keyOrValue) => coll?.delete(keyOrValue);
36
44
 
37
- const arrayEvery = (array, cb) => array.every(cb);
38
- const arrayIsEqual = (array1, array2) =>
39
- size(array1) === size(array2) &&
40
- arrayEvery(array1, (value1, index) => array2[index] === value1);
41
- const arrayForEach = (array, cb) => array.forEach(cb);
42
- const arrayPush = (array, ...values) => array.push(...values);
43
- const arrayShift = (array) => array.shift();
44
-
45
45
  const tryCatchSync = (action, onError) => {
46
46
  try {
47
47
  return action();
@@ -467,11 +467,21 @@ const createRelationships = getCreateFunction((store) => {
467
467
  remoteTableId,
468
468
  getRemoteRowId2,
469
469
  ) => {
470
+ mapForEach(mapGet(linkedRowIdsListeners, relationshipId), (firstRowId) =>
471
+ getLinkedRowIdsCache(relationshipId, firstRowId),
472
+ );
470
473
  mapSet(remoteTableIds, relationshipId, remoteTableId);
471
474
  setDefinitionAndListen(
472
475
  relationshipId,
473
476
  localTableId,
474
- (change, changedRemoteRowIds) => {
477
+ (
478
+ change,
479
+ changedRemoteRowIds,
480
+ _changedSortKeys,
481
+ _rowValues,
482
+ _sortKeys,
483
+ force,
484
+ ) => {
475
485
  const changedLocalRows = setNew();
476
486
  const changedRemoteRows = setNew();
477
487
  const changedLinkedRows = setNew();
@@ -516,6 +526,26 @@ const createRelationships = getCreateFunction((store) => {
516
526
  },
517
527
  );
518
528
  change();
529
+ if (force) {
530
+ mapForEach(
531
+ mapGet(linkedRowIdsListeners, relationshipId),
532
+ (firstRowId) => {
533
+ const oldLinkedRowIds = getLinkedRowIds(
534
+ relationshipId,
535
+ firstRowId,
536
+ );
537
+ delLinkedRowIdsCache(relationshipId, firstRowId);
538
+ if (
539
+ !arrayIsEqual(
540
+ oldLinkedRowIds,
541
+ getLinkedRowIds(relationshipId, firstRowId),
542
+ )
543
+ ) {
544
+ setAdd(changedLinkedRows, firstRowId);
545
+ }
546
+ },
547
+ );
548
+ }
519
549
  collForEach(changedLocalRows, (localRowId) =>
520
550
  callListeners(remoteRowIdListeners, [relationshipId, localRowId]),
521
551
  );
@@ -17,6 +17,14 @@ const isArray = (thing) => Array.isArray(thing);
17
17
  const size = (thing) => thing.length;
18
18
  const test = (regex, subject) => regex.test(subject);
19
19
 
20
+ const arrayEvery = (array, cb) => array.every(cb);
21
+ const arrayIsEqual = (array1, array2) =>
22
+ size(array1) === size(array2) &&
23
+ arrayEvery(array1, (value1, index) => array2[index] === value1);
24
+ const arrayForEach = (array, cb) => array.forEach(cb);
25
+ const arrayPush = (array, ...values) => array.push(...values);
26
+ const arrayShift = (array) => array.shift();
27
+
20
28
  const collSizeN = (collSizer) => (coll) => {
21
29
  let total = 0;
22
30
  for (const child of coll.values()) {
@@ -34,14 +42,6 @@ const collClear = (coll) => coll.clear();
34
42
  const collForEach = (coll, cb) => coll?.forEach(cb);
35
43
  const collDel = (coll, keyOrValue) => coll?.delete(keyOrValue);
36
44
 
37
- const arrayEvery = (array, cb) => array.every(cb);
38
- const arrayIsEqual = (array1, array2) =>
39
- size(array1) === size(array2) &&
40
- arrayEvery(array1, (value1, index) => array2[index] === value1);
41
- const arrayForEach = (array, cb) => array.forEach(cb);
42
- const arrayPush = (array, ...values) => array.push(...values);
43
- const arrayShift = (array) => array.shift();
44
-
45
45
  const tryCatchSync = (action, onError) => {
46
46
  try {
47
47
  return action();
@@ -467,11 +467,21 @@ const createRelationships = getCreateFunction((store) => {
467
467
  remoteTableId,
468
468
  getRemoteRowId2,
469
469
  ) => {
470
+ mapForEach(mapGet(linkedRowIdsListeners, relationshipId), (firstRowId) =>
471
+ getLinkedRowIdsCache(relationshipId, firstRowId),
472
+ );
470
473
  mapSet(remoteTableIds, relationshipId, remoteTableId);
471
474
  setDefinitionAndListen(
472
475
  relationshipId,
473
476
  localTableId,
474
- (change, changedRemoteRowIds) => {
477
+ (
478
+ change,
479
+ changedRemoteRowIds,
480
+ _changedSortKeys,
481
+ _rowValues,
482
+ _sortKeys,
483
+ force,
484
+ ) => {
475
485
  const changedLocalRows = setNew();
476
486
  const changedRemoteRows = setNew();
477
487
  const changedLinkedRows = setNew();
@@ -516,6 +526,26 @@ const createRelationships = getCreateFunction((store) => {
516
526
  },
517
527
  );
518
528
  change();
529
+ if (force) {
530
+ mapForEach(
531
+ mapGet(linkedRowIdsListeners, relationshipId),
532
+ (firstRowId) => {
533
+ const oldLinkedRowIds = getLinkedRowIds(
534
+ relationshipId,
535
+ firstRowId,
536
+ );
537
+ delLinkedRowIdsCache(relationshipId, firstRowId);
538
+ if (
539
+ !arrayIsEqual(
540
+ oldLinkedRowIds,
541
+ getLinkedRowIds(relationshipId, firstRowId),
542
+ )
543
+ ) {
544
+ setAdd(changedLinkedRows, firstRowId);
545
+ }
546
+ },
547
+ );
548
+ }
519
549
  collForEach(changedLocalRows, (localRowId) =>
520
550
  callListeners(remoteRowIdListeners, [relationshipId, localRowId]),
521
551
  );