tinybase 9.5.0-beta.0 → 9.5.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 (130) hide show
  1. package/@types/_internal/store/with-schemas/index.d.ts +43 -8
  2. package/@types/mergeable-store/with-schemas/index.d.ts +30 -11
  3. package/@types/queries/index.d.ts +11 -11
  4. package/@types/queries/with-schemas/index.d.ts +17 -3
  5. package/@types/schematizers/index.d.ts +6 -4
  6. package/@types/schematizers/schematizer-arktype/index.d.ts +6 -6
  7. package/@types/schematizers/schematizer-arktype/with-schemas/index.d.ts +112 -1
  8. package/@types/schematizers/schematizer-effect/index.d.ts +9 -11
  9. package/@types/schematizers/schematizer-effect/with-schemas/index.d.ts +114 -1
  10. package/@types/schematizers/schematizer-typebox/index.d.ts +7 -7
  11. package/@types/schematizers/schematizer-typebox/with-schemas/index.d.ts +114 -1
  12. package/@types/schematizers/schematizer-valibot/index.d.ts +6 -6
  13. package/@types/schematizers/schematizer-valibot/with-schemas/index.d.ts +112 -1
  14. package/@types/schematizers/schematizer-yup/index.d.ts +5 -4
  15. package/@types/schematizers/schematizer-yup/with-schemas/index.d.ts +112 -1
  16. package/@types/schematizers/schematizer-zod/index.d.ts +6 -6
  17. package/@types/schematizers/schematizer-zod/with-schemas/index.d.ts +112 -1
  18. package/@types/schematizers/with-schemas/index.d.ts +113 -4
  19. package/@types/store/index.d.ts +175 -16
  20. package/@types/store/with-schemas/index.d.ts +238 -55
  21. package/@types/synchronizers/with-schemas/index.d.ts +12 -2
  22. package/@types/ui-react/with-schemas/index.d.ts +576 -7
  23. package/@types/ui-react-dom/index.d.ts +10 -10
  24. package/@types/ui-react-dom/with-schemas/index.d.ts +94 -10
  25. package/@types/ui-react-dom-charts/index.d.ts +7 -7
  26. package/@types/ui-react-dom-charts/with-schemas/index.d.ts +7 -7
  27. package/@types/ui-react-inspector/index.d.ts +1 -1
  28. package/@types/ui-react-inspector/with-schemas/index.d.ts +1 -1
  29. package/@types/ui-solid/with-schemas/index.d.ts +340 -7
  30. package/@types/ui-solid-dom/index.d.ts +10 -10
  31. package/@types/ui-solid-dom/with-schemas/index.d.ts +94 -10
  32. package/@types/ui-solid-inspector/index.d.ts +1 -1
  33. package/@types/ui-solid-inspector/with-schemas/index.d.ts +1 -1
  34. package/@types/ui-svelte/with-schemas/index.d.ts +30 -0
  35. package/@types/ui-svelte-dom/index.d.ts +10 -10
  36. package/@types/ui-svelte-dom/with-schemas/index.d.ts +94 -10
  37. package/@types/ui-svelte-inspector/index.d.ts +1 -1
  38. package/@types/ui-svelte-inspector/with-schemas/index.d.ts +1 -1
  39. package/agents.md +4 -0
  40. package/index.js +76 -22
  41. package/mergeable-store/index.js +76 -22
  42. package/mergeable-store/with-schemas/index.js +76 -22
  43. package/min/index.js +1 -1
  44. package/min/index.js.gz +0 -0
  45. package/min/mergeable-store/index.js +1 -1
  46. package/min/mergeable-store/index.js.gz +0 -0
  47. package/min/mergeable-store/with-schemas/index.js +1 -1
  48. package/min/mergeable-store/with-schemas/index.js.gz +0 -0
  49. package/min/omni/index.js +1 -1
  50. package/min/omni/index.js.gz +0 -0
  51. package/min/omni/with-schemas/index.js +1 -1
  52. package/min/omni/with-schemas/index.js.gz +0 -0
  53. package/min/schematizers/index.js +1 -1
  54. package/min/schematizers/index.js.gz +0 -0
  55. package/min/schematizers/schematizer-arktype/index.js +1 -1
  56. package/min/schematizers/schematizer-arktype/index.js.gz +0 -0
  57. package/min/schematizers/schematizer-arktype/with-schemas/index.js +1 -1
  58. package/min/schematizers/schematizer-arktype/with-schemas/index.js.gz +0 -0
  59. package/min/schematizers/schematizer-effect/index.js +1 -1
  60. package/min/schematizers/schematizer-effect/index.js.gz +0 -0
  61. package/min/schematizers/schematizer-effect/with-schemas/index.js +1 -1
  62. package/min/schematizers/schematizer-effect/with-schemas/index.js.gz +0 -0
  63. package/min/schematizers/schematizer-typebox/index.js +1 -1
  64. package/min/schematizers/schematizer-typebox/index.js.gz +0 -0
  65. package/min/schematizers/schematizer-typebox/with-schemas/index.js +1 -1
  66. package/min/schematizers/schematizer-typebox/with-schemas/index.js.gz +0 -0
  67. package/min/schematizers/schematizer-valibot/index.js +1 -1
  68. package/min/schematizers/schematizer-valibot/index.js.gz +0 -0
  69. package/min/schematizers/schematizer-valibot/with-schemas/index.js +1 -1
  70. package/min/schematizers/schematizer-valibot/with-schemas/index.js.gz +0 -0
  71. package/min/schematizers/schematizer-yup/index.js +1 -1
  72. package/min/schematizers/schematizer-yup/index.js.gz +0 -0
  73. package/min/schematizers/schematizer-yup/with-schemas/index.js +1 -1
  74. package/min/schematizers/schematizer-yup/with-schemas/index.js.gz +0 -0
  75. package/min/schematizers/schematizer-zod/index.js +1 -1
  76. package/min/schematizers/schematizer-zod/index.js.gz +0 -0
  77. package/min/schematizers/schematizer-zod/with-schemas/index.js +1 -1
  78. package/min/schematizers/schematizer-zod/with-schemas/index.js.gz +0 -0
  79. package/min/schematizers/with-schemas/index.js +1 -1
  80. package/min/schematizers/with-schemas/index.js.gz +0 -0
  81. package/min/store/index.js +1 -1
  82. package/min/store/index.js.gz +0 -0
  83. package/min/store/with-schemas/index.js +1 -1
  84. package/min/store/with-schemas/index.js.gz +0 -0
  85. package/min/ui-react-inspector/index.js +1 -1
  86. package/min/ui-react-inspector/index.js.gz +0 -0
  87. package/min/ui-react-inspector/with-schemas/index.js +1 -1
  88. package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  89. package/min/ui-solid-inspector/index.js +1 -1
  90. package/min/ui-solid-inspector/index.js.gz +0 -0
  91. package/min/ui-solid-inspector/with-schemas/index.js +1 -1
  92. package/min/ui-solid-inspector/with-schemas/index.js.gz +0 -0
  93. package/min/ui-svelte-inspector/index.js +1 -1
  94. package/min/ui-svelte-inspector/index.js.gz +0 -0
  95. package/min/ui-svelte-inspector/with-schemas/index.js +1 -1
  96. package/min/ui-svelte-inspector/with-schemas/index.js.gz +0 -0
  97. package/min/with-schemas/index.js +1 -1
  98. package/min/with-schemas/index.js.gz +0 -0
  99. package/omni/index.js +76 -22
  100. package/omni/with-schemas/index.js +76 -22
  101. package/package.json +5 -5
  102. package/readme.md +3 -3
  103. package/releases.md +32 -2
  104. package/schematizers/index.js +54 -6
  105. package/schematizers/schematizer-arktype/index.js +99 -19
  106. package/schematizers/schematizer-arktype/with-schemas/index.js +99 -19
  107. package/schematizers/schematizer-effect/index.js +101 -11
  108. package/schematizers/schematizer-effect/with-schemas/index.js +101 -11
  109. package/schematizers/schematizer-typebox/index.js +87 -11
  110. package/schematizers/schematizer-typebox/with-schemas/index.js +87 -11
  111. package/schematizers/schematizer-valibot/index.js +125 -21
  112. package/schematizers/schematizer-valibot/with-schemas/index.js +125 -21
  113. package/schematizers/schematizer-yup/index.js +58 -14
  114. package/schematizers/schematizer-yup/with-schemas/index.js +58 -14
  115. package/schematizers/schematizer-zod/index.js +131 -12
  116. package/schematizers/schematizer-zod/with-schemas/index.js +131 -12
  117. package/schematizers/with-schemas/index.js +54 -6
  118. package/store/index.js +76 -22
  119. package/store/with-schemas/index.js +76 -22
  120. package/ui-react-inspector/index.js +76 -22
  121. package/ui-react-inspector/with-schemas/index.js +76 -22
  122. package/ui-solid-inspector/index.js +76 -22
  123. package/ui-solid-inspector/with-schemas/index.js +76 -22
  124. package/ui-svelte/index.js +1 -1
  125. package/ui-svelte/with-schemas/index.js +1 -1
  126. package/ui-svelte-dom/index.js +2 -2
  127. package/ui-svelte-dom/with-schemas/index.js +2 -2
  128. package/ui-svelte-inspector/index.js +78 -24
  129. package/ui-svelte-inspector/with-schemas/index.js +78 -24
  130. package/with-schemas/index.js +76 -22
@@ -15,6 +15,7 @@ const FUNCTION = getTypeOf(getTypeOf);
15
15
  const OBJECT = 'object';
16
16
  const ARRAY = 'array';
17
17
  const TYPE = 'type';
18
+ const ENUM = 'enum';
18
19
  const DEFAULT = 'default';
19
20
  const ALLOW_NULL = 'allowNull';
20
21
  const NULL = 'null';
@@ -1457,6 +1458,14 @@ const getCellOrValueType = (cellOrValue) => {
1457
1458
  : void 0;
1458
1459
  };
1459
1460
  const isJsonType = (type) => type == OBJECT || type == ARRAY;
1461
+ const isCellOrValueSchemaType = (type) =>
1462
+ isTypeStringOrBoolean(type) || type == NUMBER || isJsonType(type);
1463
+ const isCellOrValueSchemaTypes = (types) =>
1464
+ isArray(types)
1465
+ ? !isUndefined(types[0]) && arrayEvery(types, isCellOrValueSchemaType)
1466
+ : isCellOrValueSchemaType(types);
1467
+ const cellOrValueSchemaTypeIncludes = (types, type) =>
1468
+ isArray(types) ? arrayHas(types, type) : types == type;
1460
1469
  const encodeIfJson = (value) =>
1461
1470
  isObject(value) || isArray(value) ? JSON_PREFIX + jsonString(value) : value;
1462
1471
  const isEncodedJson = (value) => isString(value) && value[0] == JSON_PREFIX;
@@ -1612,13 +1621,29 @@ const createStore = () => {
1612
1621
  const validateCellOrValueSchema = (schema) => {
1613
1622
  if (
1614
1623
  !objValidate(schema, (_child, id2) =>
1615
- arrayHas([TYPE, DEFAULT, ALLOW_NULL, REQUIRED], id2),
1624
+ arrayHas([TYPE, ENUM, DEFAULT, ALLOW_NULL, REQUIRED], id2),
1616
1625
  )
1617
1626
  ) {
1618
1627
  return false;
1619
1628
  }
1620
1629
  const type = schema[TYPE];
1621
- if (!isTypeStringOrBoolean(type) && type != NUMBER && !isJsonType(type)) {
1630
+ const enumValues = schema[ENUM];
1631
+ if (
1632
+ isUndefined(enumValues)
1633
+ ? !isCellOrValueSchemaTypes(type)
1634
+ : !isUndefined(type) ||
1635
+ !isArray(enumValues) ||
1636
+ isUndefined(enumValues[0]) ||
1637
+ !arrayEvery(enumValues, (enumValue) => {
1638
+ const enumType = getCellOrValueType(enumValue);
1639
+ return (
1640
+ !isNull(enumValue) &&
1641
+ !isUndefined(enumType) &&
1642
+ !isJsonType(enumType) &&
1643
+ !isReservedString(enumValue)
1644
+ );
1645
+ })
1646
+ ) {
1622
1647
  return false;
1623
1648
  }
1624
1649
  const defaultValue = schema[DEFAULT];
@@ -1627,7 +1652,12 @@ const createStore = () => {
1627
1652
  }
1628
1653
  if (!isNull(defaultValue)) {
1629
1654
  if (
1630
- getCellOrValueType(defaultValue) != type ||
1655
+ (isUndefined(enumValues)
1656
+ ? !cellOrValueSchemaTypeIncludes(
1657
+ type,
1658
+ getCellOrValueType(defaultValue),
1659
+ )
1660
+ : !arrayHas(enumValues, defaultValue)) ||
1631
1661
  isReservedString(defaultValue)
1632
1662
  ) {
1633
1663
  objDel(schema, DEFAULT);
@@ -1654,13 +1684,15 @@ const createStore = () => {
1654
1684
  isObject(tables) ? objMap(tables, cloneTable) : tables;
1655
1685
  const cloneValues = (values) =>
1656
1686
  isObject(values) ? objMap(values, getArg) : values;
1657
- const isValidEncodedJson = (cellOrValue, type) =>
1687
+ const isValidEncodedJson = (cellOrValue, types) =>
1658
1688
  acceptingEncodedData == 1 &&
1659
1689
  isEncodedJson(cellOrValue) &&
1660
1690
  tryReturn(() => {
1661
1691
  const encodedType = getCellOrValueType(decodeIfJson(cellOrValue));
1662
1692
  return (
1663
- isJsonType(encodedType) && (isUndefined(type) || type == encodedType)
1693
+ isJsonType(encodedType) &&
1694
+ (isUndefined(types) ||
1695
+ cellOrValueSchemaTypeIncludes(types, encodedType))
1664
1696
  );
1665
1697
  }, false) == true;
1666
1698
  const validateContent = isArray;
@@ -1713,7 +1745,8 @@ const createStore = () => {
1713
1745
  : isReservedString(cell, acceptingEncodedData)
1714
1746
  ? cellInvalid(tableId, rowId, cellId, cell, cellSchema[DEFAULT])
1715
1747
  : isEncodedJson(cell)
1716
- ? isValidEncodedJson(cell, cellSchema[TYPE])
1748
+ ? isUndefined(cellSchema[ENUM]) &&
1749
+ isValidEncodedJson(cell, cellSchema[TYPE])
1717
1750
  ? cell
1718
1751
  : cellInvalid(
1719
1752
  tableId,
@@ -1722,23 +1755,36 @@ const createStore = () => {
1722
1755
  cell,
1723
1756
  cellSchema[DEFAULT],
1724
1757
  )
1725
- : getCellOrValueType(cell) === cellSchema[TYPE]
1726
- ? encodeValid(cell, () =>
1727
- cellInvalid(
1758
+ : isUndefined(cellSchema[ENUM])
1759
+ ? cellOrValueSchemaTypeIncludes(
1760
+ cellSchema[TYPE],
1761
+ getCellOrValueType(cell),
1762
+ )
1763
+ ? encodeValid(cell, () =>
1764
+ cellInvalid(
1765
+ tableId,
1766
+ rowId,
1767
+ cellId,
1768
+ cell,
1769
+ cellSchema[DEFAULT],
1770
+ ),
1771
+ )
1772
+ : cellInvalid(
1773
+ tableId,
1774
+ rowId,
1775
+ cellId,
1776
+ cell,
1777
+ cellSchema[DEFAULT],
1778
+ )
1779
+ : arrayHas(cellSchema[ENUM], cell)
1780
+ ? cell
1781
+ : cellInvalid(
1728
1782
  tableId,
1729
1783
  rowId,
1730
1784
  cellId,
1731
1785
  cell,
1732
1786
  cellSchema[DEFAULT],
1733
1787
  ),
1734
- )
1735
- : cellInvalid(
1736
- tableId,
1737
- rowId,
1738
- cellId,
1739
- cell,
1740
- cellSchema[DEFAULT],
1741
- ),
1742
1788
  () => cellInvalid(tableId, rowId, cellId, cell),
1743
1789
  )
1744
1790
  : isUndefined(getCellOrValueType(cell)) ||
@@ -1783,14 +1829,22 @@ const createStore = () => {
1783
1829
  : isReservedString(value, acceptingEncodedData)
1784
1830
  ? valueInvalid(valueId, value, valueSchema[DEFAULT])
1785
1831
  : isEncodedJson(value)
1786
- ? isValidEncodedJson(value, valueSchema[TYPE])
1832
+ ? isUndefined(valueSchema[ENUM]) &&
1833
+ isValidEncodedJson(value, valueSchema[TYPE])
1787
1834
  ? value
1788
1835
  : valueInvalid(valueId, value, valueSchema[DEFAULT])
1789
- : getCellOrValueType(value) === valueSchema[TYPE]
1790
- ? encodeValid(value, () =>
1791
- valueInvalid(valueId, value, valueSchema[DEFAULT]),
1836
+ : isUndefined(valueSchema[ENUM])
1837
+ ? cellOrValueSchemaTypeIncludes(
1838
+ valueSchema[TYPE],
1839
+ getCellOrValueType(value),
1792
1840
  )
1793
- : valueInvalid(valueId, value, valueSchema[DEFAULT]),
1841
+ ? encodeValid(value, () =>
1842
+ valueInvalid(valueId, value, valueSchema[DEFAULT]),
1843
+ )
1844
+ : valueInvalid(valueId, value, valueSchema[DEFAULT])
1845
+ : arrayHas(valueSchema[ENUM], value)
1846
+ ? value
1847
+ : valueInvalid(valueId, value, valueSchema[DEFAULT]),
1794
1848
  () => valueInvalid(valueId, value),
1795
1849
  )
1796
1850
  : isUndefined(getCellOrValueType(value)) ||
@@ -3565,7 +3619,7 @@ const createStore = () => {
3565
3619
 
3566
3620
  const TINYBASE_CONTEXT_KEY = TINYBASE + '_uisc';
3567
3621
 
3568
- /* functions.svelte.ts generated by Svelte v5.56.8 */
3622
+ /* functions.svelte.ts generated by Svelte v5.56.9 */
3569
3623
 
3570
3624
  class ReactiveHandle {
3571
3625
  #get;
@@ -5435,7 +5489,7 @@ function SortedTablePaginator($$anchor, $$props) {
5435
5489
 
5436
5490
  $.delegate(['click']);
5437
5491
 
5438
- /* sortingAndPagination.svelte.ts generated by Svelte v5.56.8 */
5492
+ /* sortingAndPagination.svelte.ts generated by Svelte v5.56.9 */
5439
5493
 
5440
5494
  const createSortingAndPagination = (
5441
5495
  getCellId,
@@ -15,6 +15,7 @@ const FUNCTION = getTypeOf(getTypeOf);
15
15
  const OBJECT = 'object';
16
16
  const ARRAY = 'array';
17
17
  const TYPE = 'type';
18
+ const ENUM = 'enum';
18
19
  const DEFAULT = 'default';
19
20
  const ALLOW_NULL = 'allowNull';
20
21
  const NULL = 'null';
@@ -1457,6 +1458,14 @@ const getCellOrValueType = (cellOrValue) => {
1457
1458
  : void 0;
1458
1459
  };
1459
1460
  const isJsonType = (type) => type == OBJECT || type == ARRAY;
1461
+ const isCellOrValueSchemaType = (type) =>
1462
+ isTypeStringOrBoolean(type) || type == NUMBER || isJsonType(type);
1463
+ const isCellOrValueSchemaTypes = (types) =>
1464
+ isArray(types)
1465
+ ? !isUndefined(types[0]) && arrayEvery(types, isCellOrValueSchemaType)
1466
+ : isCellOrValueSchemaType(types);
1467
+ const cellOrValueSchemaTypeIncludes = (types, type) =>
1468
+ isArray(types) ? arrayHas(types, type) : types == type;
1460
1469
  const encodeIfJson = (value) =>
1461
1470
  isObject(value) || isArray(value) ? JSON_PREFIX + jsonString(value) : value;
1462
1471
  const isEncodedJson = (value) => isString(value) && value[0] == JSON_PREFIX;
@@ -1612,13 +1621,29 @@ const createStore = () => {
1612
1621
  const validateCellOrValueSchema = (schema) => {
1613
1622
  if (
1614
1623
  !objValidate(schema, (_child, id2) =>
1615
- arrayHas([TYPE, DEFAULT, ALLOW_NULL, REQUIRED], id2),
1624
+ arrayHas([TYPE, ENUM, DEFAULT, ALLOW_NULL, REQUIRED], id2),
1616
1625
  )
1617
1626
  ) {
1618
1627
  return false;
1619
1628
  }
1620
1629
  const type = schema[TYPE];
1621
- if (!isTypeStringOrBoolean(type) && type != NUMBER && !isJsonType(type)) {
1630
+ const enumValues = schema[ENUM];
1631
+ if (
1632
+ isUndefined(enumValues)
1633
+ ? !isCellOrValueSchemaTypes(type)
1634
+ : !isUndefined(type) ||
1635
+ !isArray(enumValues) ||
1636
+ isUndefined(enumValues[0]) ||
1637
+ !arrayEvery(enumValues, (enumValue) => {
1638
+ const enumType = getCellOrValueType(enumValue);
1639
+ return (
1640
+ !isNull(enumValue) &&
1641
+ !isUndefined(enumType) &&
1642
+ !isJsonType(enumType) &&
1643
+ !isReservedString(enumValue)
1644
+ );
1645
+ })
1646
+ ) {
1622
1647
  return false;
1623
1648
  }
1624
1649
  const defaultValue = schema[DEFAULT];
@@ -1627,7 +1652,12 @@ const createStore = () => {
1627
1652
  }
1628
1653
  if (!isNull(defaultValue)) {
1629
1654
  if (
1630
- getCellOrValueType(defaultValue) != type ||
1655
+ (isUndefined(enumValues)
1656
+ ? !cellOrValueSchemaTypeIncludes(
1657
+ type,
1658
+ getCellOrValueType(defaultValue),
1659
+ )
1660
+ : !arrayHas(enumValues, defaultValue)) ||
1631
1661
  isReservedString(defaultValue)
1632
1662
  ) {
1633
1663
  objDel(schema, DEFAULT);
@@ -1654,13 +1684,15 @@ const createStore = () => {
1654
1684
  isObject(tables) ? objMap(tables, cloneTable) : tables;
1655
1685
  const cloneValues = (values) =>
1656
1686
  isObject(values) ? objMap(values, getArg) : values;
1657
- const isValidEncodedJson = (cellOrValue, type) =>
1687
+ const isValidEncodedJson = (cellOrValue, types) =>
1658
1688
  acceptingEncodedData == 1 &&
1659
1689
  isEncodedJson(cellOrValue) &&
1660
1690
  tryReturn(() => {
1661
1691
  const encodedType = getCellOrValueType(decodeIfJson(cellOrValue));
1662
1692
  return (
1663
- isJsonType(encodedType) && (isUndefined(type) || type == encodedType)
1693
+ isJsonType(encodedType) &&
1694
+ (isUndefined(types) ||
1695
+ cellOrValueSchemaTypeIncludes(types, encodedType))
1664
1696
  );
1665
1697
  }, false) == true;
1666
1698
  const validateContent = isArray;
@@ -1713,7 +1745,8 @@ const createStore = () => {
1713
1745
  : isReservedString(cell, acceptingEncodedData)
1714
1746
  ? cellInvalid(tableId, rowId, cellId, cell, cellSchema[DEFAULT])
1715
1747
  : isEncodedJson(cell)
1716
- ? isValidEncodedJson(cell, cellSchema[TYPE])
1748
+ ? isUndefined(cellSchema[ENUM]) &&
1749
+ isValidEncodedJson(cell, cellSchema[TYPE])
1717
1750
  ? cell
1718
1751
  : cellInvalid(
1719
1752
  tableId,
@@ -1722,23 +1755,36 @@ const createStore = () => {
1722
1755
  cell,
1723
1756
  cellSchema[DEFAULT],
1724
1757
  )
1725
- : getCellOrValueType(cell) === cellSchema[TYPE]
1726
- ? encodeValid(cell, () =>
1727
- cellInvalid(
1758
+ : isUndefined(cellSchema[ENUM])
1759
+ ? cellOrValueSchemaTypeIncludes(
1760
+ cellSchema[TYPE],
1761
+ getCellOrValueType(cell),
1762
+ )
1763
+ ? encodeValid(cell, () =>
1764
+ cellInvalid(
1765
+ tableId,
1766
+ rowId,
1767
+ cellId,
1768
+ cell,
1769
+ cellSchema[DEFAULT],
1770
+ ),
1771
+ )
1772
+ : cellInvalid(
1773
+ tableId,
1774
+ rowId,
1775
+ cellId,
1776
+ cell,
1777
+ cellSchema[DEFAULT],
1778
+ )
1779
+ : arrayHas(cellSchema[ENUM], cell)
1780
+ ? cell
1781
+ : cellInvalid(
1728
1782
  tableId,
1729
1783
  rowId,
1730
1784
  cellId,
1731
1785
  cell,
1732
1786
  cellSchema[DEFAULT],
1733
1787
  ),
1734
- )
1735
- : cellInvalid(
1736
- tableId,
1737
- rowId,
1738
- cellId,
1739
- cell,
1740
- cellSchema[DEFAULT],
1741
- ),
1742
1788
  () => cellInvalid(tableId, rowId, cellId, cell),
1743
1789
  )
1744
1790
  : isUndefined(getCellOrValueType(cell)) ||
@@ -1783,14 +1829,22 @@ const createStore = () => {
1783
1829
  : isReservedString(value, acceptingEncodedData)
1784
1830
  ? valueInvalid(valueId, value, valueSchema[DEFAULT])
1785
1831
  : isEncodedJson(value)
1786
- ? isValidEncodedJson(value, valueSchema[TYPE])
1832
+ ? isUndefined(valueSchema[ENUM]) &&
1833
+ isValidEncodedJson(value, valueSchema[TYPE])
1787
1834
  ? value
1788
1835
  : valueInvalid(valueId, value, valueSchema[DEFAULT])
1789
- : getCellOrValueType(value) === valueSchema[TYPE]
1790
- ? encodeValid(value, () =>
1791
- valueInvalid(valueId, value, valueSchema[DEFAULT]),
1836
+ : isUndefined(valueSchema[ENUM])
1837
+ ? cellOrValueSchemaTypeIncludes(
1838
+ valueSchema[TYPE],
1839
+ getCellOrValueType(value),
1792
1840
  )
1793
- : valueInvalid(valueId, value, valueSchema[DEFAULT]),
1841
+ ? encodeValid(value, () =>
1842
+ valueInvalid(valueId, value, valueSchema[DEFAULT]),
1843
+ )
1844
+ : valueInvalid(valueId, value, valueSchema[DEFAULT])
1845
+ : arrayHas(valueSchema[ENUM], value)
1846
+ ? value
1847
+ : valueInvalid(valueId, value, valueSchema[DEFAULT]),
1794
1848
  () => valueInvalid(valueId, value),
1795
1849
  )
1796
1850
  : isUndefined(getCellOrValueType(value)) ||
@@ -3565,7 +3619,7 @@ const createStore = () => {
3565
3619
 
3566
3620
  const TINYBASE_CONTEXT_KEY = TINYBASE + '_uisc';
3567
3621
 
3568
- /* functions.svelte.ts generated by Svelte v5.56.8 */
3622
+ /* functions.svelte.ts generated by Svelte v5.56.9 */
3569
3623
 
3570
3624
  class ReactiveHandle {
3571
3625
  #get;
@@ -5435,7 +5489,7 @@ function SortedTablePaginator($$anchor, $$props) {
5435
5489
 
5436
5490
  $.delegate(['click']);
5437
5491
 
5438
- /* sortingAndPagination.svelte.ts generated by Svelte v5.56.8 */
5492
+ /* sortingAndPagination.svelte.ts generated by Svelte v5.56.9 */
5439
5493
 
5440
5494
  const createSortingAndPagination = (
5441
5495
  getCellId,
@@ -8,6 +8,7 @@ const FUNCTION = getTypeOf(getTypeOf);
8
8
  const OBJECT = 'object';
9
9
  const ARRAY = 'array';
10
10
  const TYPE = 'type';
11
+ const ENUM = 'enum';
11
12
  const DEFAULT = 'default';
12
13
  const ALLOW_NULL = 'allowNull';
13
14
  const NULL = 'null';
@@ -226,6 +227,14 @@ const getCellOrValueType = (cellOrValue) => {
226
227
  const isCellOrValueOrUndefined = (cellOrValue) =>
227
228
  isUndefined(cellOrValue) || !isUndefined(getCellOrValueType(cellOrValue));
228
229
  const isJsonType = (type) => type == OBJECT || type == ARRAY;
230
+ const isCellOrValueSchemaType = (type) =>
231
+ isTypeStringOrBoolean(type) || type == NUMBER || isJsonType(type);
232
+ const isCellOrValueSchemaTypes = (types) =>
233
+ isArray(types)
234
+ ? !isUndefined(types[0]) && arrayEvery(types, isCellOrValueSchemaType)
235
+ : isCellOrValueSchemaType(types);
236
+ const cellOrValueSchemaTypeIncludes = (types, type) =>
237
+ isArray(types) ? arrayHas(types, type) : types == type;
229
238
  const encodeIfJson = (value) =>
230
239
  isObject(value) || isArray(value) ? JSON_PREFIX + jsonString(value) : value;
231
240
  const isEncodedJson = (value) => isString(value) && value[0] == JSON_PREFIX;
@@ -1512,13 +1521,29 @@ const createStore = () => {
1512
1521
  const validateCellOrValueSchema = (schema) => {
1513
1522
  if (
1514
1523
  !objValidate(schema, (_child, id2) =>
1515
- arrayHas([TYPE, DEFAULT, ALLOW_NULL, REQUIRED], id2),
1524
+ arrayHas([TYPE, ENUM, DEFAULT, ALLOW_NULL, REQUIRED], id2),
1516
1525
  )
1517
1526
  ) {
1518
1527
  return false;
1519
1528
  }
1520
1529
  const type = schema[TYPE];
1521
- if (!isTypeStringOrBoolean(type) && type != NUMBER && !isJsonType(type)) {
1530
+ const enumValues = schema[ENUM];
1531
+ if (
1532
+ isUndefined(enumValues)
1533
+ ? !isCellOrValueSchemaTypes(type)
1534
+ : !isUndefined(type) ||
1535
+ !isArray(enumValues) ||
1536
+ isUndefined(enumValues[0]) ||
1537
+ !arrayEvery(enumValues, (enumValue) => {
1538
+ const enumType = getCellOrValueType(enumValue);
1539
+ return (
1540
+ !isNull(enumValue) &&
1541
+ !isUndefined(enumType) &&
1542
+ !isJsonType(enumType) &&
1543
+ !isReservedString(enumValue)
1544
+ );
1545
+ })
1546
+ ) {
1522
1547
  return false;
1523
1548
  }
1524
1549
  const defaultValue = schema[DEFAULT];
@@ -1527,7 +1552,12 @@ const createStore = () => {
1527
1552
  }
1528
1553
  if (!isNull(defaultValue)) {
1529
1554
  if (
1530
- getCellOrValueType(defaultValue) != type ||
1555
+ (isUndefined(enumValues)
1556
+ ? !cellOrValueSchemaTypeIncludes(
1557
+ type,
1558
+ getCellOrValueType(defaultValue),
1559
+ )
1560
+ : !arrayHas(enumValues, defaultValue)) ||
1531
1561
  isReservedString(defaultValue)
1532
1562
  ) {
1533
1563
  objDel(schema, DEFAULT);
@@ -1554,13 +1584,15 @@ const createStore = () => {
1554
1584
  isObject(tables) ? objMap(tables, cloneTable) : tables;
1555
1585
  const cloneValues = (values) =>
1556
1586
  isObject(values) ? objMap(values, getArg) : values;
1557
- const isValidEncodedJson = (cellOrValue, type) =>
1587
+ const isValidEncodedJson = (cellOrValue, types) =>
1558
1588
  acceptingEncodedData == 1 &&
1559
1589
  isEncodedJson(cellOrValue) &&
1560
1590
  tryReturn(() => {
1561
1591
  const encodedType = getCellOrValueType(decodeIfJson(cellOrValue));
1562
1592
  return (
1563
- isJsonType(encodedType) && (isUndefined(type) || type == encodedType)
1593
+ isJsonType(encodedType) &&
1594
+ (isUndefined(types) ||
1595
+ cellOrValueSchemaTypeIncludes(types, encodedType))
1564
1596
  );
1565
1597
  }, false) == true;
1566
1598
  const validateContent = isArray;
@@ -1613,7 +1645,8 @@ const createStore = () => {
1613
1645
  : isReservedString(cell, acceptingEncodedData)
1614
1646
  ? cellInvalid(tableId, rowId, cellId, cell, cellSchema[DEFAULT])
1615
1647
  : isEncodedJson(cell)
1616
- ? isValidEncodedJson(cell, cellSchema[TYPE])
1648
+ ? isUndefined(cellSchema[ENUM]) &&
1649
+ isValidEncodedJson(cell, cellSchema[TYPE])
1617
1650
  ? cell
1618
1651
  : cellInvalid(
1619
1652
  tableId,
@@ -1622,23 +1655,36 @@ const createStore = () => {
1622
1655
  cell,
1623
1656
  cellSchema[DEFAULT],
1624
1657
  )
1625
- : getCellOrValueType(cell) === cellSchema[TYPE]
1626
- ? encodeValid(cell, () =>
1627
- cellInvalid(
1658
+ : isUndefined(cellSchema[ENUM])
1659
+ ? cellOrValueSchemaTypeIncludes(
1660
+ cellSchema[TYPE],
1661
+ getCellOrValueType(cell),
1662
+ )
1663
+ ? encodeValid(cell, () =>
1664
+ cellInvalid(
1665
+ tableId,
1666
+ rowId,
1667
+ cellId,
1668
+ cell,
1669
+ cellSchema[DEFAULT],
1670
+ ),
1671
+ )
1672
+ : cellInvalid(
1673
+ tableId,
1674
+ rowId,
1675
+ cellId,
1676
+ cell,
1677
+ cellSchema[DEFAULT],
1678
+ )
1679
+ : arrayHas(cellSchema[ENUM], cell)
1680
+ ? cell
1681
+ : cellInvalid(
1628
1682
  tableId,
1629
1683
  rowId,
1630
1684
  cellId,
1631
1685
  cell,
1632
1686
  cellSchema[DEFAULT],
1633
1687
  ),
1634
- )
1635
- : cellInvalid(
1636
- tableId,
1637
- rowId,
1638
- cellId,
1639
- cell,
1640
- cellSchema[DEFAULT],
1641
- ),
1642
1688
  () => cellInvalid(tableId, rowId, cellId, cell),
1643
1689
  )
1644
1690
  : isUndefined(getCellOrValueType(cell)) ||
@@ -1683,14 +1729,22 @@ const createStore = () => {
1683
1729
  : isReservedString(value, acceptingEncodedData)
1684
1730
  ? valueInvalid(valueId, value, valueSchema[DEFAULT])
1685
1731
  : isEncodedJson(value)
1686
- ? isValidEncodedJson(value, valueSchema[TYPE])
1732
+ ? isUndefined(valueSchema[ENUM]) &&
1733
+ isValidEncodedJson(value, valueSchema[TYPE])
1687
1734
  ? value
1688
1735
  : valueInvalid(valueId, value, valueSchema[DEFAULT])
1689
- : getCellOrValueType(value) === valueSchema[TYPE]
1690
- ? encodeValid(value, () =>
1691
- valueInvalid(valueId, value, valueSchema[DEFAULT]),
1736
+ : isUndefined(valueSchema[ENUM])
1737
+ ? cellOrValueSchemaTypeIncludes(
1738
+ valueSchema[TYPE],
1739
+ getCellOrValueType(value),
1692
1740
  )
1693
- : valueInvalid(valueId, value, valueSchema[DEFAULT]),
1741
+ ? encodeValid(value, () =>
1742
+ valueInvalid(valueId, value, valueSchema[DEFAULT]),
1743
+ )
1744
+ : valueInvalid(valueId, value, valueSchema[DEFAULT])
1745
+ : arrayHas(valueSchema[ENUM], value)
1746
+ ? value
1747
+ : valueInvalid(valueId, value, valueSchema[DEFAULT]),
1694
1748
  () => valueInvalid(valueId, value),
1695
1749
  )
1696
1750
  : isUndefined(getCellOrValueType(value)) ||