@rebasepro/server-postgresql 0.0.1-canary.94dff14 → 0.0.1-canary.a6becfb

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 (60) hide show
  1. package/dist/index.es.js +561 -1256
  2. package/dist/index.es.js.map +1 -1
  3. package/dist/index.umd.js +492 -1187
  4. package/dist/index.umd.js.map +1 -1
  5. package/dist/server-postgresql/src/PostgresBackendDriver.d.ts +8 -1
  6. package/dist/server-postgresql/src/schema/introspect-db-inference.d.ts +5 -0
  7. package/dist/server-postgresql/src/schema/introspect-db-logic.d.ts +44 -9
  8. package/dist/server-postgresql/src/services/EntityPersistService.d.ts +9 -0
  9. package/dist/types/src/controllers/auth.d.ts +8 -2
  10. package/dist/types/src/controllers/client.d.ts +13 -0
  11. package/dist/types/src/controllers/collection_registry.d.ts +2 -1
  12. package/dist/types/src/controllers/data_driver.d.ts +36 -1
  13. package/dist/types/src/controllers/navigation.d.ts +18 -6
  14. package/dist/types/src/controllers/registry.d.ts +9 -1
  15. package/dist/types/src/controllers/side_entity_controller.d.ts +7 -0
  16. package/dist/types/src/rebase_context.d.ts +17 -0
  17. package/dist/types/src/types/backend_hooks.d.ts +187 -0
  18. package/dist/types/src/types/collections.d.ts +75 -11
  19. package/dist/types/src/types/component_ref.d.ts +47 -0
  20. package/dist/types/src/types/cron.d.ts +1 -1
  21. package/dist/types/src/types/entity_views.d.ts +6 -7
  22. package/dist/types/src/types/formex.d.ts +40 -0
  23. package/dist/types/src/types/index.d.ts +3 -0
  24. package/dist/types/src/types/plugins.d.ts +6 -3
  25. package/dist/types/src/types/properties.d.ts +72 -88
  26. package/dist/types/src/types/slots.d.ts +20 -10
  27. package/dist/types/src/types/translations.d.ts +12 -0
  28. package/package.json +5 -5
  29. package/src/PostgresBackendDriver.ts +32 -6
  30. package/src/cli.ts +10 -2
  31. package/src/data-transformer.ts +84 -1
  32. package/src/schema/doctor.ts +14 -2
  33. package/src/schema/generate-drizzle-schema-logic.ts +59 -30
  34. package/src/schema/introspect-db-inference.ts +238 -0
  35. package/src/schema/introspect-db-logic.ts +365 -61
  36. package/src/schema/introspect-db.ts +66 -23
  37. package/src/services/EntityFetchService.ts +16 -0
  38. package/src/services/EntityPersistService.ts +95 -13
  39. package/test/generate-drizzle-schema.test.ts +342 -0
  40. package/test/introspect-db-generation.test.ts +32 -10
  41. package/test/property-ordering.test.ts +395 -0
  42. package/test/relations.test.ts +4 -4
  43. package/jest-all.log +0 -3128
  44. package/jest.log +0 -49
  45. package/scratch.ts +0 -41
  46. package/test-drizzle-bug.ts +0 -18
  47. package/test-drizzle-out/0000_cultured_freak.sql +0 -7
  48. package/test-drizzle-out/0001_tiresome_professor_monster.sql +0 -1
  49. package/test-drizzle-out/meta/0000_snapshot.json +0 -55
  50. package/test-drizzle-out/meta/0001_snapshot.json +0 -63
  51. package/test-drizzle-out/meta/_journal.json +0 -20
  52. package/test-drizzle-prompt.sh +0 -2
  53. package/test-policy-prompt.sh +0 -3
  54. package/test-programmatic.ts +0 -30
  55. package/test-programmatic2.ts +0 -59
  56. package/test-schema-no-policies.ts +0 -12
  57. package/test_drizzle_mock.js +0 -3
  58. package/test_find_changed.mjs +0 -32
  59. package/test_hash.js +0 -14
  60. package/test_output.txt +0 -3145
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Pool, Client } from "pg";
2
2
  import { drizzle } from "drizzle-orm/node-postgres";
3
- import { sql, inArray, eq as eq$3, and, or, ilike, asc, desc, gt, lt, getTableName as getTableName$1, count, relations, isTable } from "drizzle-orm";
3
+ import { sql, inArray, eq, and, or, ilike, asc, desc, gt, lt, getTableName as getTableName$1, count, relations, isTable } from "drizzle-orm";
4
4
  import { pgSchema, timestamp, varchar, boolean, uuid, jsonb, primaryKey, unique } from "drizzle-orm/pg-core";
5
5
  import { createHash, randomUUID } from "crypto";
6
6
  import * as fs from "fs";
@@ -124,16 +124,14 @@ function getDataSourceCapabilities(driver) {
124
124
  }
125
125
  const DEFAULT_ONE_OF_TYPE = "type";
126
126
  const DEFAULT_ONE_OF_VALUE = "value";
127
- const snakeCaseRegex = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;
127
+ const tokenizeRegex = /[A-Z]{2,}(?=[A-Z][a-z]|\b)|[A-Z]?[a-z]+|[0-9]+(?:[a-z](?![a-z]))?|[A-Z]/g;
128
+ const snakeCaseRegex = tokenizeRegex;
128
129
  const toSnakeCase = (str) => {
129
130
  const regExpMatchArray = str.match(snakeCaseRegex);
130
131
  if (!regExpMatchArray) return "";
131
132
  return regExpMatchArray.map((x) => x.toLowerCase()).join("_");
132
133
  };
133
134
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
134
- function getDefaultExportFromCjs(x) {
135
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
136
- }
137
135
  function commonjsRequire(path2) {
138
136
  throw new Error('Could not dynamically require "' + path2 + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
139
137
  }
@@ -920,7 +918,23 @@ var object_hash = { exports: {} };
920
918
  }, { buffer: 3, lYpoI2: 11 }] }, {}, [1])(1);
921
919
  });
922
920
  })(object_hash);
923
- function isObject$6(item) {
921
+ function deepClone(value) {
922
+ if (value === null || value === void 0) return value;
923
+ if (typeof value === "function") return value;
924
+ if (typeof value !== "object") return value;
925
+ if (Array.isArray(value)) {
926
+ return value.map((item) => deepClone(item));
927
+ }
928
+ if (Object.getPrototypeOf(value) !== Object.prototype) {
929
+ return value;
930
+ }
931
+ const result = {};
932
+ for (const key of Object.keys(value)) {
933
+ result[key] = deepClone(value[key]);
934
+ }
935
+ return result;
936
+ }
937
+ function isObject(item) {
924
938
  return !!item && typeof item === "object" && !Array.isArray(item);
925
939
  }
926
940
  function isPlainObject(obj) {
@@ -931,13 +945,13 @@ function isPlainObject(obj) {
931
945
  return proto === Object.prototype;
932
946
  }
933
947
  function mergeDeep(target, source, ignoreUndefined = false) {
934
- if (!isObject$6(target)) {
948
+ if (!isObject(target)) {
935
949
  return target;
936
950
  }
937
951
  const output = {
938
952
  ...target
939
953
  };
940
- if (!isObject$6(source)) {
954
+ if (!isObject(source)) {
941
955
  return output;
942
956
  }
943
957
  for (const key in source) {
@@ -978,7 +992,7 @@ function mergeDeep(target, source, ignoreUndefined = false) {
978
992
  } else {
979
993
  output[key] = sourceValue;
980
994
  }
981
- } else if (isObject$6(sourceValue)) {
995
+ } else if (isObject(sourceValue)) {
982
996
  output[key] = sourceValue;
983
997
  } else {
984
998
  output[key] = sourceValue;
@@ -1021,6 +1035,80 @@ function generateForeignKeyName(name) {
1021
1035
  const singularName = snakeCaseName.endsWith("s") ? snakeCaseName.slice(0, -1) : snakeCaseName;
1022
1036
  return `${singularName}_id`;
1023
1037
  }
1038
+ function updateDateAutoValues({
1039
+ inputValues,
1040
+ properties,
1041
+ status,
1042
+ timestampNowValue
1043
+ }) {
1044
+ return traverseValuesProperties(inputValues, properties, (inputValue, property) => {
1045
+ if (property.type === "date") {
1046
+ if (status === "existing" && property.autoValue === "on_update") {
1047
+ return timestampNowValue;
1048
+ } else if ((status === "new" || status === "copy") && (property.autoValue === "on_update" || property.autoValue === "on_create")) {
1049
+ return timestampNowValue;
1050
+ } else {
1051
+ return inputValue;
1052
+ }
1053
+ } else {
1054
+ return inputValue;
1055
+ }
1056
+ }) ?? {};
1057
+ }
1058
+ function traverseValuesProperties(inputValues, properties, operation) {
1059
+ const safeInputValues = inputValues ?? {};
1060
+ const updatedValues = Object.entries(properties).map(([key, property]) => {
1061
+ const inputValue = safeInputValues && safeInputValues[key];
1062
+ const updatedValue = traverseValueProperty(inputValue, property, operation);
1063
+ if (updatedValue === null) return null;
1064
+ if (updatedValue === void 0) return void 0;
1065
+ return {
1066
+ [key]: updatedValue
1067
+ };
1068
+ }).reduce((a, b) => ({
1069
+ ...a,
1070
+ ...b
1071
+ }), {});
1072
+ const result = mergeDeep(safeInputValues, updatedValues);
1073
+ if (!result || Object.keys(result).length === 0) return void 0;
1074
+ return result;
1075
+ }
1076
+ function traverseValueProperty(inputValue, property, operation) {
1077
+ let value;
1078
+ if (property.type === "map" && property.properties) {
1079
+ value = traverseValuesProperties(inputValue, property.properties, operation);
1080
+ } else if (property.type === "array") {
1081
+ const of = property.of;
1082
+ if (of && Array.isArray(inputValue) && !Array.isArray(of)) {
1083
+ value = inputValue.map((e) => traverseValueProperty(e, of, operation));
1084
+ } else if (of && Array.isArray(inputValue) && Array.isArray(of)) {
1085
+ value = inputValue.map((e, i) => {
1086
+ if (i < of.length) return traverseValueProperty(e, of[i], operation);
1087
+ return null;
1088
+ }).filter(Boolean);
1089
+ } else if (property.oneOf && Array.isArray(inputValue)) {
1090
+ const typeField = property.oneOf?.typeField ?? DEFAULT_ONE_OF_TYPE;
1091
+ const valueField = property.oneOf?.valueField ?? DEFAULT_ONE_OF_VALUE;
1092
+ value = inputValue.map((e) => {
1093
+ if (e === null) return null;
1094
+ if (typeof e !== "object") return e;
1095
+ const rec = e;
1096
+ const type = rec[typeField];
1097
+ const childProperty = property.oneOf?.properties[type];
1098
+ if (!type || !childProperty) return e;
1099
+ return {
1100
+ [typeField]: type,
1101
+ [valueField]: traverseValueProperty(rec[valueField], childProperty, operation)
1102
+ };
1103
+ });
1104
+ } else {
1105
+ value = inputValue;
1106
+ }
1107
+ } else {
1108
+ value = operation(inputValue, property);
1109
+ }
1110
+ return value;
1111
+ }
1024
1112
  function createRelationRef(id, path2) {
1025
1113
  return {
1026
1114
  id,
@@ -1227,6 +1315,17 @@ function sanitizeRelation(relation, sourceCollection) {
1227
1315
  break;
1228
1316
  }
1229
1317
  }
1318
+ if (!isManyToManyInverse && targetCollection.properties) {
1319
+ for (const [propKey, prop] of Object.entries(targetCollection.properties)) {
1320
+ if (prop.type !== "relation") continue;
1321
+ const relProp = prop;
1322
+ const relName = relProp.relationName || propKey;
1323
+ if (relName === newRelation.inverseRelationName && relProp.cardinality === "many" && (relProp.direction === "owning" || !relProp.direction)) {
1324
+ isManyToManyInverse = true;
1325
+ break;
1326
+ }
1327
+ }
1328
+ }
1230
1329
  } catch (e) {
1231
1330
  }
1232
1331
  }
@@ -1350,7 +1449,7 @@ function findRelation(resolvedRelations, key) {
1350
1449
  }
1351
1450
  var logic = { exports: {} };
1352
1451
  (function(module, exports$1) {
1353
- (function(root2, factory) {
1452
+ (function(root, factory) {
1354
1453
  {
1355
1454
  module.exports = factory();
1356
1455
  }
@@ -1717,8 +1816,8 @@ var logic = { exports: {} };
1717
1816
  return jsonLogic;
1718
1817
  });
1719
1818
  })(logic);
1720
- var getOwnPropertyNames = Object.getOwnPropertyNames, getOwnPropertySymbols = Object.getOwnPropertySymbols;
1721
- var hasOwnProperty$a = Object.prototype.hasOwnProperty;
1819
+ const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
1820
+ const { hasOwnProperty } = Object.prototype;
1722
1821
  function combineComparators(comparatorA, comparatorB) {
1723
1822
  return function isEqual(a, b, state) {
1724
1823
  return comparatorA(a, b, state) && comparatorB(a, b, state);
@@ -1729,38 +1828,45 @@ function createIsCircular(areItemsEqual) {
1729
1828
  if (!a || !b || typeof a !== "object" || typeof b !== "object") {
1730
1829
  return areItemsEqual(a, b, state);
1731
1830
  }
1732
- var cache = state.cache;
1733
- var cachedA = cache.get(a);
1734
- var cachedB = cache.get(b);
1831
+ const { cache } = state;
1832
+ const cachedA = cache.get(a);
1833
+ const cachedB = cache.get(b);
1735
1834
  if (cachedA && cachedB) {
1736
1835
  return cachedA === b && cachedB === a;
1737
1836
  }
1738
1837
  cache.set(a, b);
1739
1838
  cache.set(b, a);
1740
- var result = areItemsEqual(a, b, state);
1839
+ const result = areItemsEqual(a, b, state);
1741
1840
  cache.delete(a);
1742
1841
  cache.delete(b);
1743
1842
  return result;
1744
1843
  };
1745
1844
  }
1746
- function getShortTag(value) {
1747
- return value != null ? value[Symbol.toStringTag] : void 0;
1748
- }
1749
1845
  function getStrictProperties(object) {
1750
1846
  return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
1751
1847
  }
1752
- var hasOwn = Object.hasOwn || function(object, property) {
1753
- return hasOwnProperty$a.call(object, property);
1754
- };
1755
- function sameValueZeroEqual(a, b) {
1756
- return a === b || !a && !b && a !== a && b !== b;
1848
+ const hasOwn = (
1849
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1850
+ Object.hasOwn || ((object, property) => hasOwnProperty.call(object, property))
1851
+ );
1852
+ const PREACT_VNODE = "__v";
1853
+ const PREACT_OWNER = "__o";
1854
+ const REACT_OWNER = "_owner";
1855
+ const { getOwnPropertyDescriptor, keys } = Object;
1856
+ const sameValueEqual = (
1857
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1858
+ Object.is || function sameValueEqual2(a, b) {
1859
+ return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
1860
+ }
1861
+ );
1862
+ function strictEqual(a, b) {
1863
+ return a === b;
1864
+ }
1865
+ function areArrayBuffersEqual(a, b) {
1866
+ return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a), new Uint8Array(b));
1757
1867
  }
1758
- var PREACT_VNODE = "__v";
1759
- var PREACT_OWNER = "__o";
1760
- var REACT_OWNER = "_owner";
1761
- var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, keys$4 = Object.keys;
1762
1868
  function areArraysEqual(a, b, state) {
1763
- var index = a.length;
1869
+ let index = a.length;
1764
1870
  if (b.length !== index) {
1765
1871
  return false;
1766
1872
  }
@@ -1771,35 +1877,35 @@ function areArraysEqual(a, b, state) {
1771
1877
  }
1772
1878
  return true;
1773
1879
  }
1880
+ function areDataViewsEqual(a, b) {
1881
+ return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a.buffer, a.byteOffset, a.byteLength), new Uint8Array(b.buffer, b.byteOffset, b.byteLength));
1882
+ }
1774
1883
  function areDatesEqual(a, b) {
1775
- return sameValueZeroEqual(a.getTime(), b.getTime());
1884
+ return sameValueEqual(a.getTime(), b.getTime());
1776
1885
  }
1777
1886
  function areErrorsEqual(a, b) {
1778
1887
  return a.name === b.name && a.message === b.message && a.cause === b.cause && a.stack === b.stack;
1779
1888
  }
1780
- function areFunctionsEqual(a, b) {
1781
- return a === b;
1782
- }
1783
1889
  function areMapsEqual(a, b, state) {
1784
- var size = a.size;
1890
+ const size = a.size;
1785
1891
  if (size !== b.size) {
1786
1892
  return false;
1787
1893
  }
1788
1894
  if (!size) {
1789
1895
  return true;
1790
1896
  }
1791
- var matchedIndices = new Array(size);
1792
- var aIterable = a.entries();
1793
- var aResult;
1794
- var bResult;
1795
- var index = 0;
1897
+ const matchedIndices = new Array(size);
1898
+ const aIterable = a.entries();
1899
+ let aResult;
1900
+ let bResult;
1901
+ let index = 0;
1796
1902
  while (aResult = aIterable.next()) {
1797
1903
  if (aResult.done) {
1798
1904
  break;
1799
1905
  }
1800
- var bIterable = b.entries();
1801
- var hasMatch = false;
1802
- var matchIndex = 0;
1906
+ const bIterable = b.entries();
1907
+ let hasMatch = false;
1908
+ let matchIndex = 0;
1803
1909
  while (bResult = bIterable.next()) {
1804
1910
  if (bResult.done) {
1805
1911
  break;
@@ -1808,8 +1914,8 @@ function areMapsEqual(a, b, state) {
1808
1914
  matchIndex++;
1809
1915
  continue;
1810
1916
  }
1811
- var aEntry = aResult.value;
1812
- var bEntry = bResult.value;
1917
+ const aEntry = aResult.value;
1918
+ const bEntry = bResult.value;
1813
1919
  if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state) && state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {
1814
1920
  hasMatch = matchedIndices[matchIndex] = true;
1815
1921
  break;
@@ -1823,11 +1929,10 @@ function areMapsEqual(a, b, state) {
1823
1929
  }
1824
1930
  return true;
1825
1931
  }
1826
- var areNumbersEqual = sameValueZeroEqual;
1827
1932
  function areObjectsEqual(a, b, state) {
1828
- var properties = keys$4(a);
1829
- var index = properties.length;
1830
- if (keys$4(b).length !== index) {
1933
+ const properties = keys(a);
1934
+ let index = properties.length;
1935
+ if (keys(b).length !== index) {
1831
1936
  return false;
1832
1937
  }
1833
1938
  while (index-- > 0) {
@@ -1838,14 +1943,14 @@ function areObjectsEqual(a, b, state) {
1838
1943
  return true;
1839
1944
  }
1840
1945
  function areObjectsEqualStrict(a, b, state) {
1841
- var properties = getStrictProperties(a);
1842
- var index = properties.length;
1946
+ const properties = getStrictProperties(a);
1947
+ let index = properties.length;
1843
1948
  if (getStrictProperties(b).length !== index) {
1844
1949
  return false;
1845
1950
  }
1846
- var property;
1847
- var descriptorA;
1848
- var descriptorB;
1951
+ let property;
1952
+ let descriptorA;
1953
+ let descriptorB;
1849
1954
  while (index-- > 0) {
1850
1955
  property = properties[index];
1851
1956
  if (!isPropertyEqual(a, b, state, property)) {
@@ -1860,30 +1965,30 @@ function areObjectsEqualStrict(a, b, state) {
1860
1965
  return true;
1861
1966
  }
1862
1967
  function arePrimitiveWrappersEqual(a, b) {
1863
- return sameValueZeroEqual(a.valueOf(), b.valueOf());
1968
+ return sameValueEqual(a.valueOf(), b.valueOf());
1864
1969
  }
1865
1970
  function areRegExpsEqual(a, b) {
1866
1971
  return a.source === b.source && a.flags === b.flags;
1867
1972
  }
1868
1973
  function areSetsEqual(a, b, state) {
1869
- var size = a.size;
1974
+ const size = a.size;
1870
1975
  if (size !== b.size) {
1871
1976
  return false;
1872
1977
  }
1873
1978
  if (!size) {
1874
1979
  return true;
1875
1980
  }
1876
- var matchedIndices = new Array(size);
1877
- var aIterable = a.values();
1878
- var aResult;
1879
- var bResult;
1981
+ const matchedIndices = new Array(size);
1982
+ const aIterable = a.values();
1983
+ let aResult;
1984
+ let bResult;
1880
1985
  while (aResult = aIterable.next()) {
1881
1986
  if (aResult.done) {
1882
1987
  break;
1883
1988
  }
1884
- var bIterable = b.values();
1885
- var hasMatch = false;
1886
- var matchIndex = 0;
1989
+ const bIterable = b.values();
1990
+ let hasMatch = false;
1991
+ let matchIndex = 0;
1887
1992
  while (bResult = bIterable.next()) {
1888
1993
  if (bResult.done) {
1889
1994
  break;
@@ -1901,8 +2006,8 @@ function areSetsEqual(a, b, state) {
1901
2006
  return true;
1902
2007
  }
1903
2008
  function areTypedArraysEqual(a, b) {
1904
- var index = a.length;
1905
- if (b.length !== index) {
2009
+ let index = a.byteLength;
2010
+ if (b.byteLength !== index || a.byteOffset !== b.byteOffset) {
1906
2011
  return false;
1907
2012
  }
1908
2013
  while (index-- > 0) {
@@ -1921,23 +2026,10 @@ function isPropertyEqual(a, b, state, property) {
1921
2026
  }
1922
2027
  return hasOwn(b, property) && state.equals(a[property], b[property], property, property, a, b, state);
1923
2028
  }
1924
- var ARGUMENTS_TAG = "[object Arguments]";
1925
- var BOOLEAN_TAG = "[object Boolean]";
1926
- var DATE_TAG = "[object Date]";
1927
- var ERROR_TAG = "[object Error]";
1928
- var MAP_TAG = "[object Map]";
1929
- var NUMBER_TAG = "[object Number]";
1930
- var OBJECT_TAG = "[object Object]";
1931
- var REG_EXP_TAG = "[object RegExp]";
1932
- var SET_TAG = "[object Set]";
1933
- var STRING_TAG = "[object String]";
1934
- var URL_TAG = "[object URL]";
1935
- var isArray$4 = Array.isArray;
1936
- var isTypedArray$2 = typeof ArrayBuffer === "function" && ArrayBuffer.isView ? ArrayBuffer.isView : null;
1937
- var assign = Object.assign;
1938
- var getTag$4 = Object.prototype.toString.call.bind(Object.prototype.toString);
1939
- function createEqualityComparator(_a) {
1940
- var areArraysEqual2 = _a.areArraysEqual, areDatesEqual2 = _a.areDatesEqual, areErrorsEqual2 = _a.areErrorsEqual, areFunctionsEqual2 = _a.areFunctionsEqual, areMapsEqual2 = _a.areMapsEqual, areNumbersEqual2 = _a.areNumbersEqual, areObjectsEqual2 = _a.areObjectsEqual, arePrimitiveWrappersEqual2 = _a.arePrimitiveWrappersEqual, areRegExpsEqual2 = _a.areRegExpsEqual, areSetsEqual2 = _a.areSetsEqual, areTypedArraysEqual2 = _a.areTypedArraysEqual, areUrlsEqual2 = _a.areUrlsEqual, unknownTagComparators = _a.unknownTagComparators;
2029
+ const toString = Object.prototype.toString;
2030
+ function createEqualityComparator(config) {
2031
+ const supportedComparatorMap = createSupportedComparatorMap(config);
2032
+ const { areArraysEqual: areArraysEqual2, areDatesEqual: areDatesEqual2, areFunctionsEqual, areMapsEqual: areMapsEqual2, areNumbersEqual, areObjectsEqual: areObjectsEqual2, areRegExpsEqual: areRegExpsEqual2, areSetsEqual: areSetsEqual2, getUnsupportedCustomComparator } = config;
1941
2033
  return function comparator(a, b, state) {
1942
2034
  if (a === b) {
1943
2035
  return true;
@@ -1945,32 +2037,29 @@ function createEqualityComparator(_a) {
1945
2037
  if (a == null || b == null) {
1946
2038
  return false;
1947
2039
  }
1948
- var type = typeof a;
2040
+ const type = typeof a;
1949
2041
  if (type !== typeof b) {
1950
2042
  return false;
1951
2043
  }
1952
2044
  if (type !== "object") {
1953
- if (type === "number") {
1954
- return areNumbersEqual2(a, b, state);
2045
+ if (type === "number" || type === "bigint") {
2046
+ return areNumbersEqual(a, b, state);
1955
2047
  }
1956
2048
  if (type === "function") {
1957
- return areFunctionsEqual2(a, b, state);
2049
+ return areFunctionsEqual(a, b, state);
1958
2050
  }
1959
2051
  return false;
1960
2052
  }
1961
- var constructor = a.constructor;
2053
+ const constructor = a.constructor;
1962
2054
  if (constructor !== b.constructor) {
1963
2055
  return false;
1964
2056
  }
1965
2057
  if (constructor === Object) {
1966
2058
  return areObjectsEqual2(a, b, state);
1967
2059
  }
1968
- if (isArray$4(a)) {
2060
+ if (constructor === Array) {
1969
2061
  return areArraysEqual2(a, b, state);
1970
2062
  }
1971
- if (isTypedArray$2 != null && isTypedArray$2(a)) {
1972
- return areTypedArraysEqual2(a, b, state);
1973
- }
1974
2063
  if (constructor === Date) {
1975
2064
  return areDatesEqual2(a, b, state);
1976
2065
  }
@@ -1983,79 +2072,55 @@ function createEqualityComparator(_a) {
1983
2072
  if (constructor === Set) {
1984
2073
  return areSetsEqual2(a, b, state);
1985
2074
  }
1986
- var tag = getTag$4(a);
1987
- if (tag === DATE_TAG) {
1988
- return areDatesEqual2(a, b, state);
1989
- }
1990
- if (tag === REG_EXP_TAG) {
1991
- return areRegExpsEqual2(a, b, state);
1992
- }
1993
- if (tag === MAP_TAG) {
1994
- return areMapsEqual2(a, b, state);
1995
- }
1996
- if (tag === SET_TAG) {
1997
- return areSetsEqual2(a, b, state);
1998
- }
1999
- if (tag === OBJECT_TAG) {
2000
- return typeof a.then !== "function" && typeof b.then !== "function" && areObjectsEqual2(a, b, state);
2001
- }
2002
- if (tag === URL_TAG) {
2003
- return areUrlsEqual2(a, b, state);
2004
- }
2005
- if (tag === ERROR_TAG) {
2006
- return areErrorsEqual2(a, b, state);
2075
+ if (constructor === Promise) {
2076
+ return false;
2007
2077
  }
2008
- if (tag === ARGUMENTS_TAG) {
2009
- return areObjectsEqual2(a, b, state);
2078
+ if (Array.isArray(a)) {
2079
+ return areArraysEqual2(a, b, state);
2010
2080
  }
2011
- if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {
2012
- return arePrimitiveWrappersEqual2(a, b, state);
2081
+ const tag = toString.call(a);
2082
+ const supportedComparator = supportedComparatorMap[tag];
2083
+ if (supportedComparator) {
2084
+ return supportedComparator(a, b, state);
2013
2085
  }
2014
- if (unknownTagComparators) {
2015
- var unknownTagComparator = unknownTagComparators[tag];
2016
- if (!unknownTagComparator) {
2017
- var shortTag = getShortTag(a);
2018
- if (shortTag) {
2019
- unknownTagComparator = unknownTagComparators[shortTag];
2020
- }
2021
- }
2022
- if (unknownTagComparator) {
2023
- return unknownTagComparator(a, b, state);
2024
- }
2086
+ const unsupportedCustomComparator = getUnsupportedCustomComparator && getUnsupportedCustomComparator(a, b, state, tag);
2087
+ if (unsupportedCustomComparator) {
2088
+ return unsupportedCustomComparator(a, b, state);
2025
2089
  }
2026
2090
  return false;
2027
2091
  };
2028
2092
  }
2029
- function createEqualityComparatorConfig(_a) {
2030
- var circular = _a.circular, createCustomConfig = _a.createCustomConfig, strict = _a.strict;
2031
- var config = {
2093
+ function createEqualityComparatorConfig({ circular, createCustomConfig, strict }) {
2094
+ let config = {
2095
+ areArrayBuffersEqual,
2032
2096
  areArraysEqual: strict ? areObjectsEqualStrict : areArraysEqual,
2097
+ areDataViewsEqual,
2033
2098
  areDatesEqual,
2034
2099
  areErrorsEqual,
2035
- areFunctionsEqual,
2100
+ areFunctionsEqual: strictEqual,
2036
2101
  areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,
2037
- areNumbersEqual,
2102
+ areNumbersEqual: sameValueEqual,
2038
2103
  areObjectsEqual: strict ? areObjectsEqualStrict : areObjectsEqual,
2039
2104
  arePrimitiveWrappersEqual,
2040
2105
  areRegExpsEqual,
2041
2106
  areSetsEqual: strict ? combineComparators(areSetsEqual, areObjectsEqualStrict) : areSetsEqual,
2042
- areTypedArraysEqual: strict ? areObjectsEqualStrict : areTypedArraysEqual,
2107
+ areTypedArraysEqual: strict ? combineComparators(areTypedArraysEqual, areObjectsEqualStrict) : areTypedArraysEqual,
2043
2108
  areUrlsEqual,
2044
- unknownTagComparators: void 0
2109
+ getUnsupportedCustomComparator: void 0
2045
2110
  };
2046
2111
  if (createCustomConfig) {
2047
- config = assign({}, config, createCustomConfig(config));
2112
+ config = Object.assign({}, config, createCustomConfig(config));
2048
2113
  }
2049
2114
  if (circular) {
2050
- var areArraysEqual$1 = createIsCircular(config.areArraysEqual);
2051
- var areMapsEqual$1 = createIsCircular(config.areMapsEqual);
2052
- var areObjectsEqual$1 = createIsCircular(config.areObjectsEqual);
2053
- var areSetsEqual$1 = createIsCircular(config.areSetsEqual);
2054
- config = assign({}, config, {
2055
- areArraysEqual: areArraysEqual$1,
2056
- areMapsEqual: areMapsEqual$1,
2057
- areObjectsEqual: areObjectsEqual$1,
2058
- areSetsEqual: areSetsEqual$1
2115
+ const areArraysEqual2 = createIsCircular(config.areArraysEqual);
2116
+ const areMapsEqual2 = createIsCircular(config.areMapsEqual);
2117
+ const areObjectsEqual2 = createIsCircular(config.areObjectsEqual);
2118
+ const areSetsEqual2 = createIsCircular(config.areSetsEqual);
2119
+ config = Object.assign({}, config, {
2120
+ areArraysEqual: areArraysEqual2,
2121
+ areMapsEqual: areMapsEqual2,
2122
+ areObjectsEqual: areObjectsEqual2,
2123
+ areSetsEqual: areSetsEqual2
2059
2124
  });
2060
2125
  }
2061
2126
  return config;
@@ -2065,11 +2130,10 @@ function createInternalEqualityComparator(compare) {
2065
2130
  return compare(a, b, state);
2066
2131
  };
2067
2132
  }
2068
- function createIsEqual(_a) {
2069
- var circular = _a.circular, comparator = _a.comparator, createState = _a.createState, equals = _a.equals, strict = _a.strict;
2133
+ function createIsEqual({ circular, comparator, createState, equals, strict }) {
2070
2134
  if (createState) {
2071
2135
  return function isEqual(a, b) {
2072
- var _a2 = createState(), _b = _a2.cache, cache = _b === void 0 ? circular ? /* @__PURE__ */ new WeakMap() : void 0 : _b, meta = _a2.meta;
2136
+ const { cache = circular ? /* @__PURE__ */ new WeakMap() : void 0, meta } = createState();
2073
2137
  return comparator(a, b, {
2074
2138
  cache,
2075
2139
  equals,
@@ -2088,7 +2152,7 @@ function createIsEqual(_a) {
2088
2152
  });
2089
2153
  };
2090
2154
  }
2091
- var state = {
2155
+ const state = {
2092
2156
  cache: void 0,
2093
2157
  equals,
2094
2158
  meta: void 0,
@@ -2098,7 +2162,50 @@ function createIsEqual(_a) {
2098
2162
  return comparator(a, b, state);
2099
2163
  };
2100
2164
  }
2101
- var deepEqual = createCustomEqual();
2165
+ function createSupportedComparatorMap({ areArrayBuffersEqual: areArrayBuffersEqual2, areArraysEqual: areArraysEqual2, areDataViewsEqual: areDataViewsEqual2, areDatesEqual: areDatesEqual2, areErrorsEqual: areErrorsEqual2, areFunctionsEqual, areMapsEqual: areMapsEqual2, areNumbersEqual, areObjectsEqual: areObjectsEqual2, arePrimitiveWrappersEqual: arePrimitiveWrappersEqual2, areRegExpsEqual: areRegExpsEqual2, areSetsEqual: areSetsEqual2, areTypedArraysEqual: areTypedArraysEqual2, areUrlsEqual: areUrlsEqual2 }) {
2166
+ return {
2167
+ "[object Arguments]": areObjectsEqual2,
2168
+ "[object Array]": areArraysEqual2,
2169
+ "[object ArrayBuffer]": areArrayBuffersEqual2,
2170
+ "[object AsyncGeneratorFunction]": areFunctionsEqual,
2171
+ "[object BigInt]": areNumbersEqual,
2172
+ "[object BigInt64Array]": areTypedArraysEqual2,
2173
+ "[object BigUint64Array]": areTypedArraysEqual2,
2174
+ "[object Boolean]": arePrimitiveWrappersEqual2,
2175
+ "[object DataView]": areDataViewsEqual2,
2176
+ "[object Date]": areDatesEqual2,
2177
+ // If an error tag, it should be tested explicitly. Like RegExp, the properties are not
2178
+ // enumerable, and therefore will give false positives if tested like a standard object.
2179
+ "[object Error]": areErrorsEqual2,
2180
+ "[object Float16Array]": areTypedArraysEqual2,
2181
+ "[object Float32Array]": areTypedArraysEqual2,
2182
+ "[object Float64Array]": areTypedArraysEqual2,
2183
+ "[object Function]": areFunctionsEqual,
2184
+ "[object GeneratorFunction]": areFunctionsEqual,
2185
+ "[object Int8Array]": areTypedArraysEqual2,
2186
+ "[object Int16Array]": areTypedArraysEqual2,
2187
+ "[object Int32Array]": areTypedArraysEqual2,
2188
+ "[object Map]": areMapsEqual2,
2189
+ "[object Number]": arePrimitiveWrappersEqual2,
2190
+ "[object Object]": (a, b, state) => (
2191
+ // The exception for value comparison is custom `Promise`-like class instances. These should
2192
+ // be treated the same as standard `Promise` objects, which means strict equality, and if
2193
+ // it reaches this point then that strict equality comparison has already failed.
2194
+ typeof a.then !== "function" && typeof b.then !== "function" && areObjectsEqual2(a, b, state)
2195
+ ),
2196
+ // For RegExp, the properties are not enumerable, and therefore will give false positives if
2197
+ // tested like a standard object.
2198
+ "[object RegExp]": areRegExpsEqual2,
2199
+ "[object Set]": areSetsEqual2,
2200
+ "[object String]": arePrimitiveWrappersEqual2,
2201
+ "[object URL]": areUrlsEqual2,
2202
+ "[object Uint8Array]": areTypedArraysEqual2,
2203
+ "[object Uint8ClampedArray]": areTypedArraysEqual2,
2204
+ "[object Uint16Array]": areTypedArraysEqual2,
2205
+ "[object Uint32Array]": areTypedArraysEqual2
2206
+ };
2207
+ }
2208
+ const deepEqual = createCustomEqual();
2102
2209
  createCustomEqual({ strict: true });
2103
2210
  createCustomEqual({ circular: true });
2104
2211
  createCustomEqual({
@@ -2106,1015 +2213,28 @@ createCustomEqual({
2106
2213
  strict: true
2107
2214
  });
2108
2215
  createCustomEqual({
2109
- createInternalComparator: function() {
2110
- return sameValueZeroEqual;
2111
- }
2216
+ createInternalComparator: () => sameValueEqual
2112
2217
  });
2113
2218
  createCustomEqual({
2114
2219
  strict: true,
2115
- createInternalComparator: function() {
2116
- return sameValueZeroEqual;
2117
- }
2220
+ createInternalComparator: () => sameValueEqual
2118
2221
  });
2119
2222
  createCustomEqual({
2120
2223
  circular: true,
2121
- createInternalComparator: function() {
2122
- return sameValueZeroEqual;
2123
- }
2224
+ createInternalComparator: () => sameValueEqual
2124
2225
  });
2125
2226
  createCustomEqual({
2126
2227
  circular: true,
2127
- createInternalComparator: function() {
2128
- return sameValueZeroEqual;
2129
- },
2228
+ createInternalComparator: () => sameValueEqual,
2130
2229
  strict: true
2131
2230
  });
2132
- function createCustomEqual(options) {
2133
- if (options === void 0) {
2134
- options = {};
2135
- }
2136
- var _a = options.circular, circular = _a === void 0 ? false : _a, createCustomInternalComparator = options.createInternalComparator, createState = options.createState, _b = options.strict, strict = _b === void 0 ? false : _b;
2137
- var config = createEqualityComparatorConfig(options);
2138
- var comparator = createEqualityComparator(config);
2139
- var equals = createCustomInternalComparator ? createCustomInternalComparator(comparator) : createInternalEqualityComparator(comparator);
2231
+ function createCustomEqual(options = {}) {
2232
+ const { circular = false, createInternalComparator: createCustomInternalComparator, createState, strict = false } = options;
2233
+ const config = createEqualityComparatorConfig(options);
2234
+ const comparator = createEqualityComparator(config);
2235
+ const equals = createCustomInternalComparator ? createCustomInternalComparator(comparator) : createInternalEqualityComparator(comparator);
2140
2236
  return createIsEqual({ circular, comparator, createState, equals, strict });
2141
2237
  }
2142
- function listCacheClear$1() {
2143
- this.__data__ = [];
2144
- this.size = 0;
2145
- }
2146
- var _listCacheClear = listCacheClear$1;
2147
- function eq$2(value, other) {
2148
- return value === other || value !== value && other !== other;
2149
- }
2150
- var eq_1 = eq$2;
2151
- var eq$1 = eq_1;
2152
- function assocIndexOf$4(array, key) {
2153
- var length = array.length;
2154
- while (length--) {
2155
- if (eq$1(array[length][0], key)) {
2156
- return length;
2157
- }
2158
- }
2159
- return -1;
2160
- }
2161
- var _assocIndexOf = assocIndexOf$4;
2162
- var assocIndexOf$3 = _assocIndexOf;
2163
- var arrayProto = Array.prototype;
2164
- var splice = arrayProto.splice;
2165
- function listCacheDelete$1(key) {
2166
- var data = this.__data__, index = assocIndexOf$3(data, key);
2167
- if (index < 0) {
2168
- return false;
2169
- }
2170
- var lastIndex = data.length - 1;
2171
- if (index == lastIndex) {
2172
- data.pop();
2173
- } else {
2174
- splice.call(data, index, 1);
2175
- }
2176
- --this.size;
2177
- return true;
2178
- }
2179
- var _listCacheDelete = listCacheDelete$1;
2180
- var assocIndexOf$2 = _assocIndexOf;
2181
- function listCacheGet$1(key) {
2182
- var data = this.__data__, index = assocIndexOf$2(data, key);
2183
- return index < 0 ? void 0 : data[index][1];
2184
- }
2185
- var _listCacheGet = listCacheGet$1;
2186
- var assocIndexOf$1 = _assocIndexOf;
2187
- function listCacheHas$1(key) {
2188
- return assocIndexOf$1(this.__data__, key) > -1;
2189
- }
2190
- var _listCacheHas = listCacheHas$1;
2191
- var assocIndexOf = _assocIndexOf;
2192
- function listCacheSet$1(key, value) {
2193
- var data = this.__data__, index = assocIndexOf(data, key);
2194
- if (index < 0) {
2195
- ++this.size;
2196
- data.push([key, value]);
2197
- } else {
2198
- data[index][1] = value;
2199
- }
2200
- return this;
2201
- }
2202
- var _listCacheSet = listCacheSet$1;
2203
- var listCacheClear = _listCacheClear, listCacheDelete = _listCacheDelete, listCacheGet = _listCacheGet, listCacheHas = _listCacheHas, listCacheSet = _listCacheSet;
2204
- function ListCache$4(entries) {
2205
- var index = -1, length = entries == null ? 0 : entries.length;
2206
- this.clear();
2207
- while (++index < length) {
2208
- var entry = entries[index];
2209
- this.set(entry[0], entry[1]);
2210
- }
2211
- }
2212
- ListCache$4.prototype.clear = listCacheClear;
2213
- ListCache$4.prototype["delete"] = listCacheDelete;
2214
- ListCache$4.prototype.get = listCacheGet;
2215
- ListCache$4.prototype.has = listCacheHas;
2216
- ListCache$4.prototype.set = listCacheSet;
2217
- var _ListCache = ListCache$4;
2218
- var ListCache$3 = _ListCache;
2219
- function stackClear$1() {
2220
- this.__data__ = new ListCache$3();
2221
- this.size = 0;
2222
- }
2223
- var _stackClear = stackClear$1;
2224
- function stackDelete$1(key) {
2225
- var data = this.__data__, result = data["delete"](key);
2226
- this.size = data.size;
2227
- return result;
2228
- }
2229
- var _stackDelete = stackDelete$1;
2230
- function stackGet$1(key) {
2231
- return this.__data__.get(key);
2232
- }
2233
- var _stackGet = stackGet$1;
2234
- function stackHas$1(key) {
2235
- return this.__data__.has(key);
2236
- }
2237
- var _stackHas = stackHas$1;
2238
- var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
2239
- var _freeGlobal = freeGlobal$1;
2240
- var freeGlobal = _freeGlobal;
2241
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
2242
- var root$8 = freeGlobal || freeSelf || Function("return this")();
2243
- var _root = root$8;
2244
- var root$7 = _root;
2245
- var Symbol$4 = root$7.Symbol;
2246
- var _Symbol = Symbol$4;
2247
- var Symbol$3 = _Symbol;
2248
- var objectProto$c = Object.prototype;
2249
- var hasOwnProperty$9 = objectProto$c.hasOwnProperty;
2250
- var nativeObjectToString$1 = objectProto$c.toString;
2251
- var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
2252
- function getRawTag$1(value) {
2253
- var isOwn = hasOwnProperty$9.call(value, symToStringTag$1), tag = value[symToStringTag$1];
2254
- try {
2255
- value[symToStringTag$1] = void 0;
2256
- var unmasked = true;
2257
- } catch (e) {
2258
- }
2259
- var result = nativeObjectToString$1.call(value);
2260
- if (unmasked) {
2261
- if (isOwn) {
2262
- value[symToStringTag$1] = tag;
2263
- } else {
2264
- delete value[symToStringTag$1];
2265
- }
2266
- }
2267
- return result;
2268
- }
2269
- var _getRawTag = getRawTag$1;
2270
- var objectProto$b = Object.prototype;
2271
- var nativeObjectToString = objectProto$b.toString;
2272
- function objectToString$1(value) {
2273
- return nativeObjectToString.call(value);
2274
- }
2275
- var _objectToString = objectToString$1;
2276
- var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
2277
- var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
2278
- var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
2279
- function baseGetTag$4(value) {
2280
- if (value == null) {
2281
- return value === void 0 ? undefinedTag : nullTag;
2282
- }
2283
- return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
2284
- }
2285
- var _baseGetTag = baseGetTag$4;
2286
- function isObject$5(value) {
2287
- var type = typeof value;
2288
- return value != null && (type == "object" || type == "function");
2289
- }
2290
- var isObject_1 = isObject$5;
2291
- var baseGetTag$3 = _baseGetTag, isObject$4 = isObject_1;
2292
- var asyncTag = "[object AsyncFunction]", funcTag$2 = "[object Function]", genTag$1 = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
2293
- function isFunction$2(value) {
2294
- if (!isObject$4(value)) {
2295
- return false;
2296
- }
2297
- var tag = baseGetTag$3(value);
2298
- return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag || tag == proxyTag;
2299
- }
2300
- var isFunction_1 = isFunction$2;
2301
- var root$6 = _root;
2302
- var coreJsData$1 = root$6["__core-js_shared__"];
2303
- var _coreJsData = coreJsData$1;
2304
- var coreJsData = _coreJsData;
2305
- var maskSrcKey = function() {
2306
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
2307
- return uid ? "Symbol(src)_1." + uid : "";
2308
- }();
2309
- function isMasked$1(func) {
2310
- return !!maskSrcKey && maskSrcKey in func;
2311
- }
2312
- var _isMasked = isMasked$1;
2313
- var funcProto$1 = Function.prototype;
2314
- var funcToString$1 = funcProto$1.toString;
2315
- function toSource$2(func) {
2316
- if (func != null) {
2317
- try {
2318
- return funcToString$1.call(func);
2319
- } catch (e) {
2320
- }
2321
- try {
2322
- return func + "";
2323
- } catch (e) {
2324
- }
2325
- }
2326
- return "";
2327
- }
2328
- var _toSource = toSource$2;
2329
- var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$3 = isObject_1, toSource$1 = _toSource;
2330
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
2331
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
2332
- var funcProto = Function.prototype, objectProto$a = Object.prototype;
2333
- var funcToString = funcProto.toString;
2334
- var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
2335
- var reIsNative = RegExp(
2336
- "^" + funcToString.call(hasOwnProperty$8).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
2337
- );
2338
- function baseIsNative$1(value) {
2339
- if (!isObject$3(value) || isMasked(value)) {
2340
- return false;
2341
- }
2342
- var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
2343
- return pattern.test(toSource$1(value));
2344
- }
2345
- var _baseIsNative = baseIsNative$1;
2346
- function getValue$1(object, key) {
2347
- return object == null ? void 0 : object[key];
2348
- }
2349
- var _getValue = getValue$1;
2350
- var baseIsNative = _baseIsNative, getValue = _getValue;
2351
- function getNative$7(object, key) {
2352
- var value = getValue(object, key);
2353
- return baseIsNative(value) ? value : void 0;
2354
- }
2355
- var _getNative = getNative$7;
2356
- var getNative$6 = _getNative, root$5 = _root;
2357
- var Map$4 = getNative$6(root$5, "Map");
2358
- var _Map = Map$4;
2359
- var getNative$5 = _getNative;
2360
- var nativeCreate$4 = getNative$5(Object, "create");
2361
- var _nativeCreate = nativeCreate$4;
2362
- var nativeCreate$3 = _nativeCreate;
2363
- function hashClear$1() {
2364
- this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
2365
- this.size = 0;
2366
- }
2367
- var _hashClear = hashClear$1;
2368
- function hashDelete$1(key) {
2369
- var result = this.has(key) && delete this.__data__[key];
2370
- this.size -= result ? 1 : 0;
2371
- return result;
2372
- }
2373
- var _hashDelete = hashDelete$1;
2374
- var nativeCreate$2 = _nativeCreate;
2375
- var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
2376
- var objectProto$9 = Object.prototype;
2377
- var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
2378
- function hashGet$1(key) {
2379
- var data = this.__data__;
2380
- if (nativeCreate$2) {
2381
- var result = data[key];
2382
- return result === HASH_UNDEFINED$1 ? void 0 : result;
2383
- }
2384
- return hasOwnProperty$7.call(data, key) ? data[key] : void 0;
2385
- }
2386
- var _hashGet = hashGet$1;
2387
- var nativeCreate$1 = _nativeCreate;
2388
- var objectProto$8 = Object.prototype;
2389
- var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
2390
- function hashHas$1(key) {
2391
- var data = this.__data__;
2392
- return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty$6.call(data, key);
2393
- }
2394
- var _hashHas = hashHas$1;
2395
- var nativeCreate = _nativeCreate;
2396
- var HASH_UNDEFINED = "__lodash_hash_undefined__";
2397
- function hashSet$1(key, value) {
2398
- var data = this.__data__;
2399
- this.size += this.has(key) ? 0 : 1;
2400
- data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
2401
- return this;
2402
- }
2403
- var _hashSet = hashSet$1;
2404
- var hashClear = _hashClear, hashDelete = _hashDelete, hashGet = _hashGet, hashHas = _hashHas, hashSet = _hashSet;
2405
- function Hash$1(entries) {
2406
- var index = -1, length = entries == null ? 0 : entries.length;
2407
- this.clear();
2408
- while (++index < length) {
2409
- var entry = entries[index];
2410
- this.set(entry[0], entry[1]);
2411
- }
2412
- }
2413
- Hash$1.prototype.clear = hashClear;
2414
- Hash$1.prototype["delete"] = hashDelete;
2415
- Hash$1.prototype.get = hashGet;
2416
- Hash$1.prototype.has = hashHas;
2417
- Hash$1.prototype.set = hashSet;
2418
- var _Hash = Hash$1;
2419
- var Hash = _Hash, ListCache$2 = _ListCache, Map$3 = _Map;
2420
- function mapCacheClear$1() {
2421
- this.size = 0;
2422
- this.__data__ = {
2423
- "hash": new Hash(),
2424
- "map": new (Map$3 || ListCache$2)(),
2425
- "string": new Hash()
2426
- };
2427
- }
2428
- var _mapCacheClear = mapCacheClear$1;
2429
- function isKeyable$1(value) {
2430
- var type = typeof value;
2431
- return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
2432
- }
2433
- var _isKeyable = isKeyable$1;
2434
- var isKeyable = _isKeyable;
2435
- function getMapData$4(map, key) {
2436
- var data = map.__data__;
2437
- return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
2438
- }
2439
- var _getMapData = getMapData$4;
2440
- var getMapData$3 = _getMapData;
2441
- function mapCacheDelete$1(key) {
2442
- var result = getMapData$3(this, key)["delete"](key);
2443
- this.size -= result ? 1 : 0;
2444
- return result;
2445
- }
2446
- var _mapCacheDelete = mapCacheDelete$1;
2447
- var getMapData$2 = _getMapData;
2448
- function mapCacheGet$1(key) {
2449
- return getMapData$2(this, key).get(key);
2450
- }
2451
- var _mapCacheGet = mapCacheGet$1;
2452
- var getMapData$1 = _getMapData;
2453
- function mapCacheHas$1(key) {
2454
- return getMapData$1(this, key).has(key);
2455
- }
2456
- var _mapCacheHas = mapCacheHas$1;
2457
- var getMapData = _getMapData;
2458
- function mapCacheSet$1(key, value) {
2459
- var data = getMapData(this, key), size = data.size;
2460
- data.set(key, value);
2461
- this.size += data.size == size ? 0 : 1;
2462
- return this;
2463
- }
2464
- var _mapCacheSet = mapCacheSet$1;
2465
- var mapCacheClear = _mapCacheClear, mapCacheDelete = _mapCacheDelete, mapCacheGet = _mapCacheGet, mapCacheHas = _mapCacheHas, mapCacheSet = _mapCacheSet;
2466
- function MapCache$1(entries) {
2467
- var index = -1, length = entries == null ? 0 : entries.length;
2468
- this.clear();
2469
- while (++index < length) {
2470
- var entry = entries[index];
2471
- this.set(entry[0], entry[1]);
2472
- }
2473
- }
2474
- MapCache$1.prototype.clear = mapCacheClear;
2475
- MapCache$1.prototype["delete"] = mapCacheDelete;
2476
- MapCache$1.prototype.get = mapCacheGet;
2477
- MapCache$1.prototype.has = mapCacheHas;
2478
- MapCache$1.prototype.set = mapCacheSet;
2479
- var _MapCache = MapCache$1;
2480
- var ListCache$1 = _ListCache, Map$2 = _Map, MapCache = _MapCache;
2481
- var LARGE_ARRAY_SIZE = 200;
2482
- function stackSet$1(key, value) {
2483
- var data = this.__data__;
2484
- if (data instanceof ListCache$1) {
2485
- var pairs = data.__data__;
2486
- if (!Map$2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
2487
- pairs.push([key, value]);
2488
- this.size = ++data.size;
2489
- return this;
2490
- }
2491
- data = this.__data__ = new MapCache(pairs);
2492
- }
2493
- data.set(key, value);
2494
- this.size = data.size;
2495
- return this;
2496
- }
2497
- var _stackSet = stackSet$1;
2498
- var ListCache = _ListCache, stackClear = _stackClear, stackDelete = _stackDelete, stackGet = _stackGet, stackHas = _stackHas, stackSet = _stackSet;
2499
- function Stack$1(entries) {
2500
- var data = this.__data__ = new ListCache(entries);
2501
- this.size = data.size;
2502
- }
2503
- Stack$1.prototype.clear = stackClear;
2504
- Stack$1.prototype["delete"] = stackDelete;
2505
- Stack$1.prototype.get = stackGet;
2506
- Stack$1.prototype.has = stackHas;
2507
- Stack$1.prototype.set = stackSet;
2508
- var _Stack = Stack$1;
2509
- function arrayEach$1(array, iteratee) {
2510
- var index = -1, length = array == null ? 0 : array.length;
2511
- while (++index < length) {
2512
- if (iteratee(array[index], index, array) === false) {
2513
- break;
2514
- }
2515
- }
2516
- return array;
2517
- }
2518
- var _arrayEach = arrayEach$1;
2519
- var getNative$4 = _getNative;
2520
- var defineProperty$1 = function() {
2521
- try {
2522
- var func = getNative$4(Object, "defineProperty");
2523
- func({}, "", {});
2524
- return func;
2525
- } catch (e) {
2526
- }
2527
- }();
2528
- var _defineProperty = defineProperty$1;
2529
- var defineProperty = _defineProperty;
2530
- function baseAssignValue$2(object, key, value) {
2531
- if (key == "__proto__" && defineProperty) {
2532
- defineProperty(object, key, {
2533
- "configurable": true,
2534
- "enumerable": true,
2535
- "value": value,
2536
- "writable": true
2537
- });
2538
- } else {
2539
- object[key] = value;
2540
- }
2541
- }
2542
- var _baseAssignValue = baseAssignValue$2;
2543
- var baseAssignValue$1 = _baseAssignValue, eq = eq_1;
2544
- var objectProto$7 = Object.prototype;
2545
- var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
2546
- function assignValue$2(object, key, value) {
2547
- var objValue = object[key];
2548
- if (!(hasOwnProperty$5.call(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) {
2549
- baseAssignValue$1(object, key, value);
2550
- }
2551
- }
2552
- var _assignValue = assignValue$2;
2553
- var assignValue$1 = _assignValue, baseAssignValue = _baseAssignValue;
2554
- function copyObject$4(source, props, object, customizer) {
2555
- var isNew = !object;
2556
- object || (object = {});
2557
- var index = -1, length = props.length;
2558
- while (++index < length) {
2559
- var key = props[index];
2560
- var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
2561
- if (newValue === void 0) {
2562
- newValue = source[key];
2563
- }
2564
- if (isNew) {
2565
- baseAssignValue(object, key, newValue);
2566
- } else {
2567
- assignValue$1(object, key, newValue);
2568
- }
2569
- }
2570
- return object;
2571
- }
2572
- var _copyObject = copyObject$4;
2573
- function baseTimes$1(n, iteratee) {
2574
- var index = -1, result = Array(n);
2575
- while (++index < n) {
2576
- result[index] = iteratee(index);
2577
- }
2578
- return result;
2579
- }
2580
- var _baseTimes = baseTimes$1;
2581
- function isObjectLike$5(value) {
2582
- return value != null && typeof value == "object";
2583
- }
2584
- var isObjectLike_1 = isObjectLike$5;
2585
- var baseGetTag$2 = _baseGetTag, isObjectLike$4 = isObjectLike_1;
2586
- var argsTag$2 = "[object Arguments]";
2587
- function baseIsArguments$1(value) {
2588
- return isObjectLike$4(value) && baseGetTag$2(value) == argsTag$2;
2589
- }
2590
- var _baseIsArguments = baseIsArguments$1;
2591
- var baseIsArguments = _baseIsArguments, isObjectLike$3 = isObjectLike_1;
2592
- var objectProto$6 = Object.prototype;
2593
- var hasOwnProperty$4 = objectProto$6.hasOwnProperty;
2594
- var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
2595
- var isArguments$1 = baseIsArguments(/* @__PURE__ */ function() {
2596
- return arguments;
2597
- }()) ? baseIsArguments : function(value) {
2598
- return isObjectLike$3(value) && hasOwnProperty$4.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
2599
- };
2600
- var isArguments_1 = isArguments$1;
2601
- var isArray$3 = Array.isArray;
2602
- var isArray_1 = isArray$3;
2603
- var isBuffer$2 = { exports: {} };
2604
- function stubFalse() {
2605
- return false;
2606
- }
2607
- var stubFalse_1 = stubFalse;
2608
- isBuffer$2.exports;
2609
- (function(module, exports$1) {
2610
- var root2 = _root, stubFalse2 = stubFalse_1;
2611
- var freeExports = exports$1 && !exports$1.nodeType && exports$1;
2612
- var freeModule = freeExports && true && module && !module.nodeType && module;
2613
- var moduleExports = freeModule && freeModule.exports === freeExports;
2614
- var Buffer = moduleExports ? root2.Buffer : void 0;
2615
- var nativeIsBuffer = Buffer ? Buffer.isBuffer : void 0;
2616
- var isBuffer2 = nativeIsBuffer || stubFalse2;
2617
- module.exports = isBuffer2;
2618
- })(isBuffer$2, isBuffer$2.exports);
2619
- var isBufferExports = isBuffer$2.exports;
2620
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
2621
- var reIsUint = /^(?:0|[1-9]\d*)$/;
2622
- function isIndex$1(value, length) {
2623
- var type = typeof value;
2624
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
2625
- return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
2626
- }
2627
- var _isIndex = isIndex$1;
2628
- var MAX_SAFE_INTEGER = 9007199254740991;
2629
- function isLength$2(value) {
2630
- return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2631
- }
2632
- var isLength_1 = isLength$2;
2633
- var baseGetTag$1 = _baseGetTag, isLength$1 = isLength_1, isObjectLike$2 = isObjectLike_1;
2634
- var argsTag$1 = "[object Arguments]", arrayTag$1 = "[object Array]", boolTag$2 = "[object Boolean]", dateTag$2 = "[object Date]", errorTag$1 = "[object Error]", funcTag$1 = "[object Function]", mapTag$4 = "[object Map]", numberTag$2 = "[object Number]", objectTag$2 = "[object Object]", regexpTag$2 = "[object RegExp]", setTag$4 = "[object Set]", stringTag$2 = "[object String]", weakMapTag$2 = "[object WeakMap]";
2635
- var arrayBufferTag$2 = "[object ArrayBuffer]", dataViewTag$3 = "[object DataView]", float32Tag$2 = "[object Float32Array]", float64Tag$2 = "[object Float64Array]", int8Tag$2 = "[object Int8Array]", int16Tag$2 = "[object Int16Array]", int32Tag$2 = "[object Int32Array]", uint8Tag$2 = "[object Uint8Array]", uint8ClampedTag$2 = "[object Uint8ClampedArray]", uint16Tag$2 = "[object Uint16Array]", uint32Tag$2 = "[object Uint32Array]";
2636
- var typedArrayTags = {};
2637
- typedArrayTags[float32Tag$2] = typedArrayTags[float64Tag$2] = typedArrayTags[int8Tag$2] = typedArrayTags[int16Tag$2] = typedArrayTags[int32Tag$2] = typedArrayTags[uint8Tag$2] = typedArrayTags[uint8ClampedTag$2] = typedArrayTags[uint16Tag$2] = typedArrayTags[uint32Tag$2] = true;
2638
- typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$2] = typedArrayTags[boolTag$2] = typedArrayTags[dataViewTag$3] = typedArrayTags[dateTag$2] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] = typedArrayTags[mapTag$4] = typedArrayTags[numberTag$2] = typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$2] = typedArrayTags[setTag$4] = typedArrayTags[stringTag$2] = typedArrayTags[weakMapTag$2] = false;
2639
- function baseIsTypedArray$1(value) {
2640
- return isObjectLike$2(value) && isLength$1(value.length) && !!typedArrayTags[baseGetTag$1(value)];
2641
- }
2642
- var _baseIsTypedArray = baseIsTypedArray$1;
2643
- function baseUnary$3(func) {
2644
- return function(value) {
2645
- return func(value);
2646
- };
2647
- }
2648
- var _baseUnary = baseUnary$3;
2649
- var _nodeUtil = { exports: {} };
2650
- _nodeUtil.exports;
2651
- (function(module, exports$1) {
2652
- var freeGlobal2 = _freeGlobal;
2653
- var freeExports = exports$1 && !exports$1.nodeType && exports$1;
2654
- var freeModule = freeExports && true && module && !module.nodeType && module;
2655
- var moduleExports = freeModule && freeModule.exports === freeExports;
2656
- var freeProcess = moduleExports && freeGlobal2.process;
2657
- var nodeUtil2 = function() {
2658
- try {
2659
- var types = freeModule && freeModule.require && freeModule.require("util").types;
2660
- if (types) {
2661
- return types;
2662
- }
2663
- return freeProcess && freeProcess.binding && freeProcess.binding("util");
2664
- } catch (e) {
2665
- }
2666
- }();
2667
- module.exports = nodeUtil2;
2668
- })(_nodeUtil, _nodeUtil.exports);
2669
- var _nodeUtilExports = _nodeUtil.exports;
2670
- var baseIsTypedArray = _baseIsTypedArray, baseUnary$2 = _baseUnary, nodeUtil$2 = _nodeUtilExports;
2671
- var nodeIsTypedArray = nodeUtil$2 && nodeUtil$2.isTypedArray;
2672
- var isTypedArray$1 = nodeIsTypedArray ? baseUnary$2(nodeIsTypedArray) : baseIsTypedArray;
2673
- var isTypedArray_1 = isTypedArray$1;
2674
- var baseTimes = _baseTimes, isArguments = isArguments_1, isArray$2 = isArray_1, isBuffer$1 = isBufferExports, isIndex = _isIndex, isTypedArray = isTypedArray_1;
2675
- var objectProto$5 = Object.prototype;
2676
- var hasOwnProperty$3 = objectProto$5.hasOwnProperty;
2677
- function arrayLikeKeys$2(value, inherited) {
2678
- var isArr = isArray$2(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer$1(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
2679
- for (var key in value) {
2680
- if ((inherited || hasOwnProperty$3.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
2681
- (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
2682
- isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
2683
- isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
2684
- isIndex(key, length)))) {
2685
- result.push(key);
2686
- }
2687
- }
2688
- return result;
2689
- }
2690
- var _arrayLikeKeys = arrayLikeKeys$2;
2691
- var objectProto$4 = Object.prototype;
2692
- function isPrototype$3(value) {
2693
- var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$4;
2694
- return value === proto;
2695
- }
2696
- var _isPrototype = isPrototype$3;
2697
- function overArg$2(func, transform) {
2698
- return function(arg) {
2699
- return func(transform(arg));
2700
- };
2701
- }
2702
- var _overArg = overArg$2;
2703
- var overArg$1 = _overArg;
2704
- var nativeKeys$1 = overArg$1(Object.keys, Object);
2705
- var _nativeKeys = nativeKeys$1;
2706
- var isPrototype$2 = _isPrototype, nativeKeys = _nativeKeys;
2707
- var objectProto$3 = Object.prototype;
2708
- var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
2709
- function baseKeys$1(object) {
2710
- if (!isPrototype$2(object)) {
2711
- return nativeKeys(object);
2712
- }
2713
- var result = [];
2714
- for (var key in Object(object)) {
2715
- if (hasOwnProperty$2.call(object, key) && key != "constructor") {
2716
- result.push(key);
2717
- }
2718
- }
2719
- return result;
2720
- }
2721
- var _baseKeys = baseKeys$1;
2722
- var isFunction = isFunction_1, isLength = isLength_1;
2723
- function isArrayLike$2(value) {
2724
- return value != null && isLength(value.length) && !isFunction(value);
2725
- }
2726
- var isArrayLike_1 = isArrayLike$2;
2727
- var arrayLikeKeys$1 = _arrayLikeKeys, baseKeys = _baseKeys, isArrayLike$1 = isArrayLike_1;
2728
- function keys$3(object) {
2729
- return isArrayLike$1(object) ? arrayLikeKeys$1(object) : baseKeys(object);
2730
- }
2731
- var keys_1 = keys$3;
2732
- var copyObject$3 = _copyObject, keys$2 = keys_1;
2733
- function baseAssign$1(object, source) {
2734
- return object && copyObject$3(source, keys$2(source), object);
2735
- }
2736
- var _baseAssign = baseAssign$1;
2737
- function nativeKeysIn$1(object) {
2738
- var result = [];
2739
- if (object != null) {
2740
- for (var key in Object(object)) {
2741
- result.push(key);
2742
- }
2743
- }
2744
- return result;
2745
- }
2746
- var _nativeKeysIn = nativeKeysIn$1;
2747
- var isObject$2 = isObject_1, isPrototype$1 = _isPrototype, nativeKeysIn = _nativeKeysIn;
2748
- var objectProto$2 = Object.prototype;
2749
- var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
2750
- function baseKeysIn$1(object) {
2751
- if (!isObject$2(object)) {
2752
- return nativeKeysIn(object);
2753
- }
2754
- var isProto = isPrototype$1(object), result = [];
2755
- for (var key in object) {
2756
- if (!(key == "constructor" && (isProto || !hasOwnProperty$1.call(object, key)))) {
2757
- result.push(key);
2758
- }
2759
- }
2760
- return result;
2761
- }
2762
- var _baseKeysIn = baseKeysIn$1;
2763
- var arrayLikeKeys = _arrayLikeKeys, baseKeysIn = _baseKeysIn, isArrayLike = isArrayLike_1;
2764
- function keysIn$3(object) {
2765
- return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
2766
- }
2767
- var keysIn_1 = keysIn$3;
2768
- var copyObject$2 = _copyObject, keysIn$2 = keysIn_1;
2769
- function baseAssignIn$1(object, source) {
2770
- return object && copyObject$2(source, keysIn$2(source), object);
2771
- }
2772
- var _baseAssignIn = baseAssignIn$1;
2773
- var _cloneBuffer = { exports: {} };
2774
- _cloneBuffer.exports;
2775
- (function(module, exports$1) {
2776
- var root2 = _root;
2777
- var freeExports = exports$1 && !exports$1.nodeType && exports$1;
2778
- var freeModule = freeExports && true && module && !module.nodeType && module;
2779
- var moduleExports = freeModule && freeModule.exports === freeExports;
2780
- var Buffer = moduleExports ? root2.Buffer : void 0, allocUnsafe = Buffer ? Buffer.allocUnsafe : void 0;
2781
- function cloneBuffer2(buffer, isDeep) {
2782
- if (isDeep) {
2783
- return buffer.slice();
2784
- }
2785
- var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
2786
- buffer.copy(result);
2787
- return result;
2788
- }
2789
- module.exports = cloneBuffer2;
2790
- })(_cloneBuffer, _cloneBuffer.exports);
2791
- var _cloneBufferExports = _cloneBuffer.exports;
2792
- function copyArray$1(source, array) {
2793
- var index = -1, length = source.length;
2794
- array || (array = Array(length));
2795
- while (++index < length) {
2796
- array[index] = source[index];
2797
- }
2798
- return array;
2799
- }
2800
- var _copyArray = copyArray$1;
2801
- function arrayFilter$1(array, predicate) {
2802
- var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
2803
- while (++index < length) {
2804
- var value = array[index];
2805
- if (predicate(value, index, array)) {
2806
- result[resIndex++] = value;
2807
- }
2808
- }
2809
- return result;
2810
- }
2811
- var _arrayFilter = arrayFilter$1;
2812
- function stubArray$2() {
2813
- return [];
2814
- }
2815
- var stubArray_1 = stubArray$2;
2816
- var arrayFilter = _arrayFilter, stubArray$1 = stubArray_1;
2817
- var objectProto$1 = Object.prototype;
2818
- var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
2819
- var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
2820
- var getSymbols$3 = !nativeGetSymbols$1 ? stubArray$1 : function(object) {
2821
- if (object == null) {
2822
- return [];
2823
- }
2824
- object = Object(object);
2825
- return arrayFilter(nativeGetSymbols$1(object), function(symbol) {
2826
- return propertyIsEnumerable.call(object, symbol);
2827
- });
2828
- };
2829
- var _getSymbols = getSymbols$3;
2830
- var copyObject$1 = _copyObject, getSymbols$2 = _getSymbols;
2831
- function copySymbols$1(source, object) {
2832
- return copyObject$1(source, getSymbols$2(source), object);
2833
- }
2834
- var _copySymbols = copySymbols$1;
2835
- function arrayPush$2(array, values) {
2836
- var index = -1, length = values.length, offset = array.length;
2837
- while (++index < length) {
2838
- array[offset + index] = values[index];
2839
- }
2840
- return array;
2841
- }
2842
- var _arrayPush = arrayPush$2;
2843
- var overArg = _overArg;
2844
- var getPrototype$2 = overArg(Object.getPrototypeOf, Object);
2845
- var _getPrototype = getPrototype$2;
2846
- var arrayPush$1 = _arrayPush, getPrototype$1 = _getPrototype, getSymbols$1 = _getSymbols, stubArray = stubArray_1;
2847
- var nativeGetSymbols = Object.getOwnPropertySymbols;
2848
- var getSymbolsIn$2 = !nativeGetSymbols ? stubArray : function(object) {
2849
- var result = [];
2850
- while (object) {
2851
- arrayPush$1(result, getSymbols$1(object));
2852
- object = getPrototype$1(object);
2853
- }
2854
- return result;
2855
- };
2856
- var _getSymbolsIn = getSymbolsIn$2;
2857
- var copyObject = _copyObject, getSymbolsIn$1 = _getSymbolsIn;
2858
- function copySymbolsIn$1(source, object) {
2859
- return copyObject(source, getSymbolsIn$1(source), object);
2860
- }
2861
- var _copySymbolsIn = copySymbolsIn$1;
2862
- var arrayPush = _arrayPush, isArray$1 = isArray_1;
2863
- function baseGetAllKeys$2(object, keysFunc, symbolsFunc) {
2864
- var result = keysFunc(object);
2865
- return isArray$1(object) ? result : arrayPush(result, symbolsFunc(object));
2866
- }
2867
- var _baseGetAllKeys = baseGetAllKeys$2;
2868
- var baseGetAllKeys$1 = _baseGetAllKeys, getSymbols = _getSymbols, keys$1 = keys_1;
2869
- function getAllKeys$1(object) {
2870
- return baseGetAllKeys$1(object, keys$1, getSymbols);
2871
- }
2872
- var _getAllKeys = getAllKeys$1;
2873
- var baseGetAllKeys = _baseGetAllKeys, getSymbolsIn = _getSymbolsIn, keysIn$1 = keysIn_1;
2874
- function getAllKeysIn$1(object) {
2875
- return baseGetAllKeys(object, keysIn$1, getSymbolsIn);
2876
- }
2877
- var _getAllKeysIn = getAllKeysIn$1;
2878
- var getNative$3 = _getNative, root$4 = _root;
2879
- var DataView$1 = getNative$3(root$4, "DataView");
2880
- var _DataView = DataView$1;
2881
- var getNative$2 = _getNative, root$3 = _root;
2882
- var Promise$2 = getNative$2(root$3, "Promise");
2883
- var _Promise = Promise$2;
2884
- var getNative$1 = _getNative, root$2 = _root;
2885
- var Set$2 = getNative$1(root$2, "Set");
2886
- var _Set = Set$2;
2887
- var getNative = _getNative, root$1 = _root;
2888
- var WeakMap$2 = getNative(root$1, "WeakMap");
2889
- var _WeakMap = WeakMap$2;
2890
- var DataView = _DataView, Map$1 = _Map, Promise$1 = _Promise, Set$1 = _Set, WeakMap$1 = _WeakMap, baseGetTag = _baseGetTag, toSource = _toSource;
2891
- var mapTag$3 = "[object Map]", objectTag$1 = "[object Object]", promiseTag = "[object Promise]", setTag$3 = "[object Set]", weakMapTag$1 = "[object WeakMap]";
2892
- var dataViewTag$2 = "[object DataView]";
2893
- var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$1), weakMapCtorString = toSource(WeakMap$1);
2894
- var getTag$3 = baseGetTag;
2895
- if (DataView && getTag$3(new DataView(new ArrayBuffer(1))) != dataViewTag$2 || Map$1 && getTag$3(new Map$1()) != mapTag$3 || Promise$1 && getTag$3(Promise$1.resolve()) != promiseTag || Set$1 && getTag$3(new Set$1()) != setTag$3 || WeakMap$1 && getTag$3(new WeakMap$1()) != weakMapTag$1) {
2896
- getTag$3 = function(value) {
2897
- var result = baseGetTag(value), Ctor = result == objectTag$1 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
2898
- if (ctorString) {
2899
- switch (ctorString) {
2900
- case dataViewCtorString:
2901
- return dataViewTag$2;
2902
- case mapCtorString:
2903
- return mapTag$3;
2904
- case promiseCtorString:
2905
- return promiseTag;
2906
- case setCtorString:
2907
- return setTag$3;
2908
- case weakMapCtorString:
2909
- return weakMapTag$1;
2910
- }
2911
- }
2912
- return result;
2913
- };
2914
- }
2915
- var _getTag = getTag$3;
2916
- var objectProto = Object.prototype;
2917
- var hasOwnProperty = objectProto.hasOwnProperty;
2918
- function initCloneArray$1(array) {
2919
- var length = array.length, result = new array.constructor(length);
2920
- if (length && typeof array[0] == "string" && hasOwnProperty.call(array, "index")) {
2921
- result.index = array.index;
2922
- result.input = array.input;
2923
- }
2924
- return result;
2925
- }
2926
- var _initCloneArray = initCloneArray$1;
2927
- var root = _root;
2928
- var Uint8Array$2 = root.Uint8Array;
2929
- var _Uint8Array = Uint8Array$2;
2930
- var Uint8Array$1 = _Uint8Array;
2931
- function cloneArrayBuffer$3(arrayBuffer) {
2932
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
2933
- new Uint8Array$1(result).set(new Uint8Array$1(arrayBuffer));
2934
- return result;
2935
- }
2936
- var _cloneArrayBuffer = cloneArrayBuffer$3;
2937
- var cloneArrayBuffer$2 = _cloneArrayBuffer;
2938
- function cloneDataView$1(dataView, isDeep) {
2939
- var buffer = isDeep ? cloneArrayBuffer$2(dataView.buffer) : dataView.buffer;
2940
- return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
2941
- }
2942
- var _cloneDataView = cloneDataView$1;
2943
- var reFlags = /\w*$/;
2944
- function cloneRegExp$1(regexp) {
2945
- var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
2946
- result.lastIndex = regexp.lastIndex;
2947
- return result;
2948
- }
2949
- var _cloneRegExp = cloneRegExp$1;
2950
- var Symbol$1 = _Symbol;
2951
- var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
2952
- function cloneSymbol$1(symbol) {
2953
- return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
2954
- }
2955
- var _cloneSymbol = cloneSymbol$1;
2956
- var cloneArrayBuffer$1 = _cloneArrayBuffer;
2957
- function cloneTypedArray$1(typedArray, isDeep) {
2958
- var buffer = isDeep ? cloneArrayBuffer$1(typedArray.buffer) : typedArray.buffer;
2959
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
2960
- }
2961
- var _cloneTypedArray = cloneTypedArray$1;
2962
- var cloneArrayBuffer = _cloneArrayBuffer, cloneDataView = _cloneDataView, cloneRegExp = _cloneRegExp, cloneSymbol = _cloneSymbol, cloneTypedArray = _cloneTypedArray;
2963
- var boolTag$1 = "[object Boolean]", dateTag$1 = "[object Date]", mapTag$2 = "[object Map]", numberTag$1 = "[object Number]", regexpTag$1 = "[object RegExp]", setTag$2 = "[object Set]", stringTag$1 = "[object String]", symbolTag$1 = "[object Symbol]";
2964
- var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$1 = "[object DataView]", float32Tag$1 = "[object Float32Array]", float64Tag$1 = "[object Float64Array]", int8Tag$1 = "[object Int8Array]", int16Tag$1 = "[object Int16Array]", int32Tag$1 = "[object Int32Array]", uint8Tag$1 = "[object Uint8Array]", uint8ClampedTag$1 = "[object Uint8ClampedArray]", uint16Tag$1 = "[object Uint16Array]", uint32Tag$1 = "[object Uint32Array]";
2965
- function initCloneByTag$1(object, tag, isDeep) {
2966
- var Ctor = object.constructor;
2967
- switch (tag) {
2968
- case arrayBufferTag$1:
2969
- return cloneArrayBuffer(object);
2970
- case boolTag$1:
2971
- case dateTag$1:
2972
- return new Ctor(+object);
2973
- case dataViewTag$1:
2974
- return cloneDataView(object, isDeep);
2975
- case float32Tag$1:
2976
- case float64Tag$1:
2977
- case int8Tag$1:
2978
- case int16Tag$1:
2979
- case int32Tag$1:
2980
- case uint8Tag$1:
2981
- case uint8ClampedTag$1:
2982
- case uint16Tag$1:
2983
- case uint32Tag$1:
2984
- return cloneTypedArray(object, isDeep);
2985
- case mapTag$2:
2986
- return new Ctor();
2987
- case numberTag$1:
2988
- case stringTag$1:
2989
- return new Ctor(object);
2990
- case regexpTag$1:
2991
- return cloneRegExp(object);
2992
- case setTag$2:
2993
- return new Ctor();
2994
- case symbolTag$1:
2995
- return cloneSymbol(object);
2996
- }
2997
- }
2998
- var _initCloneByTag = initCloneByTag$1;
2999
- var isObject$1 = isObject_1;
3000
- var objectCreate = Object.create;
3001
- var baseCreate$1 = /* @__PURE__ */ function() {
3002
- function object() {
3003
- }
3004
- return function(proto) {
3005
- if (!isObject$1(proto)) {
3006
- return {};
3007
- }
3008
- if (objectCreate) {
3009
- return objectCreate(proto);
3010
- }
3011
- object.prototype = proto;
3012
- var result = new object();
3013
- object.prototype = void 0;
3014
- return result;
3015
- };
3016
- }();
3017
- var _baseCreate = baseCreate$1;
3018
- var baseCreate = _baseCreate, getPrototype = _getPrototype, isPrototype = _isPrototype;
3019
- function initCloneObject$1(object) {
3020
- return typeof object.constructor == "function" && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
3021
- }
3022
- var _initCloneObject = initCloneObject$1;
3023
- var getTag$2 = _getTag, isObjectLike$1 = isObjectLike_1;
3024
- var mapTag$1 = "[object Map]";
3025
- function baseIsMap$1(value) {
3026
- return isObjectLike$1(value) && getTag$2(value) == mapTag$1;
3027
- }
3028
- var _baseIsMap = baseIsMap$1;
3029
- var baseIsMap = _baseIsMap, baseUnary$1 = _baseUnary, nodeUtil$1 = _nodeUtilExports;
3030
- var nodeIsMap = nodeUtil$1 && nodeUtil$1.isMap;
3031
- var isMap$1 = nodeIsMap ? baseUnary$1(nodeIsMap) : baseIsMap;
3032
- var isMap_1 = isMap$1;
3033
- var getTag$1 = _getTag, isObjectLike = isObjectLike_1;
3034
- var setTag$1 = "[object Set]";
3035
- function baseIsSet$1(value) {
3036
- return isObjectLike(value) && getTag$1(value) == setTag$1;
3037
- }
3038
- var _baseIsSet = baseIsSet$1;
3039
- var baseIsSet = _baseIsSet, baseUnary = _baseUnary, nodeUtil = _nodeUtilExports;
3040
- var nodeIsSet = nodeUtil && nodeUtil.isSet;
3041
- var isSet$1 = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
3042
- var isSet_1 = isSet$1;
3043
- var Stack = _Stack, arrayEach = _arrayEach, assignValue = _assignValue, baseAssign = _baseAssign, baseAssignIn = _baseAssignIn, cloneBuffer = _cloneBufferExports, copyArray = _copyArray, copySymbols = _copySymbols, copySymbolsIn = _copySymbolsIn, getAllKeys = _getAllKeys, getAllKeysIn = _getAllKeysIn, getTag = _getTag, initCloneArray = _initCloneArray, initCloneByTag = _initCloneByTag, initCloneObject = _initCloneObject, isArray = isArray_1, isBuffer = isBufferExports, isMap = isMap_1, isObject = isObject_1, isSet = isSet_1, keys = keys_1, keysIn = keysIn_1;
3044
- var CLONE_DEEP_FLAG$1 = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG$1 = 4;
3045
- var argsTag = "[object Arguments]", arrayTag = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag = "[object Map]", numberTag = "[object Number]", objectTag = "[object Object]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]", weakMapTag = "[object WeakMap]";
3046
- var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
3047
- var cloneableTags = {};
3048
- cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
3049
- cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
3050
- function baseClone$1(value, bitmask, customizer, key, object, stack) {
3051
- var result, isDeep = bitmask & CLONE_DEEP_FLAG$1, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG$1;
3052
- if (customizer) {
3053
- result = object ? customizer(value, key, object, stack) : customizer(value);
3054
- }
3055
- if (result !== void 0) {
3056
- return result;
3057
- }
3058
- if (!isObject(value)) {
3059
- return value;
3060
- }
3061
- var isArr = isArray(value);
3062
- if (isArr) {
3063
- result = initCloneArray(value);
3064
- if (!isDeep) {
3065
- return copyArray(value, result);
3066
- }
3067
- } else {
3068
- var tag = getTag(value), isFunc = tag == funcTag || tag == genTag;
3069
- if (isBuffer(value)) {
3070
- return cloneBuffer(value, isDeep);
3071
- }
3072
- if (tag == objectTag || tag == argsTag || isFunc && !object) {
3073
- result = isFlat || isFunc ? {} : initCloneObject(value);
3074
- if (!isDeep) {
3075
- return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value));
3076
- }
3077
- } else {
3078
- if (!cloneableTags[tag]) {
3079
- return object ? value : {};
3080
- }
3081
- result = initCloneByTag(value, tag, isDeep);
3082
- }
3083
- }
3084
- stack || (stack = new Stack());
3085
- var stacked = stack.get(value);
3086
- if (stacked) {
3087
- return stacked;
3088
- }
3089
- stack.set(value, result);
3090
- if (isSet(value)) {
3091
- value.forEach(function(subValue) {
3092
- result.add(baseClone$1(subValue, bitmask, customizer, subValue, value, stack));
3093
- });
3094
- } else if (isMap(value)) {
3095
- value.forEach(function(subValue, key2) {
3096
- result.set(key2, baseClone$1(subValue, bitmask, customizer, key2, value, stack));
3097
- });
3098
- }
3099
- var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys;
3100
- var props = isArr ? void 0 : keysFunc(value);
3101
- arrayEach(props || value, function(subValue, key2) {
3102
- if (props) {
3103
- key2 = subValue;
3104
- subValue = value[key2];
3105
- }
3106
- assignValue(result, key2, baseClone$1(subValue, bitmask, customizer, key2, value, stack));
3107
- });
3108
- return result;
3109
- }
3110
- var _baseClone = baseClone$1;
3111
- var baseClone = _baseClone;
3112
- var CLONE_DEEP_FLAG = 1, CLONE_SYMBOLS_FLAG = 4;
3113
- function cloneDeep(value) {
3114
- return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
3115
- }
3116
- var cloneDeep_1 = cloneDeep;
3117
- const cloneDeep$1 = /* @__PURE__ */ getDefaultExportFromCjs(cloneDeep_1);
3118
2238
  class CollectionRegistry {
3119
2239
  // Normalized runtime layer (used by Data Grid / UI)
3120
2240
  collectionsByTableName = /* @__PURE__ */ new Map();
@@ -3162,7 +2282,7 @@ class CollectionRegistry {
3162
2282
  ...c
3163
2283
  }));
3164
2284
  normalizedCollections.forEach((c, index) => {
3165
- const raw = cloneDeep$1(collections[index]);
2285
+ const raw = deepClone(collections[index]);
3166
2286
  this.rootCollections.push(c);
3167
2287
  this.rawRootCollections.push(raw);
3168
2288
  const normalized = this.normalizeCollection(c);
@@ -3182,7 +2302,7 @@ class CollectionRegistry {
3182
2302
  if (!subCollection) return;
3183
2303
  this._registerRecursively(this.normalizeCollection({
3184
2304
  ...subCollection
3185
- }), cloneDeep$1(subCollection));
2305
+ }), deepClone(subCollection));
3186
2306
  });
3187
2307
  }
3188
2308
  });
@@ -3190,7 +2310,7 @@ class CollectionRegistry {
3190
2310
  return true;
3191
2311
  }
3192
2312
  register(collection, rawCollection) {
3193
- const raw = rawCollection ? cloneDeep$1(rawCollection) : cloneDeep$1(collection);
2313
+ const raw = rawCollection ? deepClone(rawCollection) : deepClone(collection);
3194
2314
  this.rootCollections.push(collection);
3195
2315
  this.rawRootCollections.push(raw);
3196
2316
  this._registerRecursively(collection, raw);
@@ -3214,7 +2334,7 @@ class CollectionRegistry {
3214
2334
  if (!subCollection) return;
3215
2335
  this._registerRecursively(this.normalizeCollection({
3216
2336
  ...subCollection
3217
- }), cloneDeep$1(subCollection));
2337
+ }), deepClone(subCollection));
3218
2338
  });
3219
2339
  }
3220
2340
  }
@@ -3386,7 +2506,10 @@ class CollectionRegistry {
3386
2506
  if (!relation) {
3387
2507
  throw new Error(`Relation '${relationKey}' not found in collection '${currentCollection.slug}'`);
3388
2508
  }
3389
- currentCollection = relation.target();
2509
+ const target = relation.target();
2510
+ const targetRelationKey = relation.relationName || target.slug;
2511
+ const targetSlug = relation.overrides?.slug ?? targetRelationKey;
2512
+ currentCollection = this.get(targetSlug) || this.normalizeCollection(target);
3390
2513
  if (i + 1 < pathSegments.length) ;
3391
2514
  }
3392
2515
  return currentCollection;
@@ -3435,7 +2558,7 @@ class CollectionRegistry {
3435
2558
  if (!subcollection) {
3436
2559
  throw new Error(`Subcollection '${subcollectionSlug}' not found in ${currentCollection.slug}`);
3437
2560
  }
3438
- currentCollection = subcollection;
2561
+ currentCollection = this.get(subcollection.slug) || this.normalizeCollection(subcollection);
3439
2562
  collections.push(currentCollection);
3440
2563
  }
3441
2564
  }
@@ -3672,7 +2795,7 @@ class DrizzleConditionBuilder {
3672
2795
  static buildSingleFilterCondition(column, op, value) {
3673
2796
  switch (op) {
3674
2797
  case "==":
3675
- return eq$3(column, value);
2798
+ return eq(column, value);
3676
2799
  case "!=":
3677
2800
  return sql`${column} != ${value}`;
3678
2801
  case ">":
@@ -3802,7 +2925,7 @@ class DrizzleConditionBuilder {
3802
2925
  throw new Error(`Join path did not result in connecting to parent table. Current: ${currentTableName}, Parent: ${parentTableName}`);
3803
2926
  }
3804
2927
  }
3805
- const finalCondition = Array.isArray(parentEntityId) ? inArray(parentIdColumn, parentEntityId) : eq$3(parentIdColumn, parentEntityId);
2928
+ const finalCondition = Array.isArray(parentEntityId) ? inArray(parentIdColumn, parentEntityId) : eq(parentIdColumn, parentEntityId);
3806
2929
  return {
3807
2930
  joins,
3808
2931
  finalCondition
@@ -3828,7 +2951,7 @@ class DrizzleConditionBuilder {
3828
2951
  throw new Error(`Join columns not found: ${fromTableName}.${fromColName} = ${toTableName}.${toColName}`);
3829
2952
  }
3830
2953
  joinTable = fromTable;
3831
- condition = eq$3(left, right);
2954
+ condition = eq(left, right);
3832
2955
  } else if (currentTable === fromTable) {
3833
2956
  const left = toTable[toColName];
3834
2957
  const right = currentTable[fromColName];
@@ -3842,7 +2965,7 @@ class DrizzleConditionBuilder {
3842
2965
  throw new Error(`Join columns not found: ${toTableName}.${toColName} = ${fromTableName}.${fromColName}`);
3843
2966
  }
3844
2967
  joinTable = toTable;
3845
- condition = eq$3(left, right);
2968
+ condition = eq(left, right);
3846
2969
  } else {
3847
2970
  throw new Error(`Join step does not match current table. Current table does not match from: ${fromTableName} or to: ${toTableName}`);
3848
2971
  }
@@ -3873,19 +2996,19 @@ class DrizzleConditionBuilder {
3873
2996
  if (currentTable === targetTable) {
3874
2997
  return {
3875
2998
  joinTable: targetTable,
3876
- condition: eq$3(targetTableIdCol, junctionTargetCol),
2999
+ condition: eq(targetTableIdCol, junctionTargetCol),
3877
3000
  additionalJoins: [{
3878
3001
  table: junctionTable,
3879
- condition: eq$3(currentTableIdCol, junctionSourceCol)
3002
+ condition: eq(currentTableIdCol, junctionSourceCol)
3880
3003
  }]
3881
3004
  };
3882
3005
  } else {
3883
3006
  return {
3884
3007
  joinTable: junctionTable,
3885
- condition: eq$3(currentTableIdCol, junctionSourceCol),
3008
+ condition: eq(currentTableIdCol, junctionSourceCol),
3886
3009
  additionalJoins: [{
3887
3010
  table: targetTable,
3888
- condition: eq$3(targetTableIdCol, junctionTargetCol)
3011
+ condition: eq(targetTableIdCol, junctionTargetCol)
3889
3012
  }]
3890
3013
  };
3891
3014
  }
@@ -3910,11 +3033,11 @@ class DrizzleConditionBuilder {
3910
3033
  if (!junctionTargetCol) {
3911
3034
  throw new Error(`Target column '${through.targetColumn}' not found in junction table '${through.table}'`);
3912
3035
  }
3913
- const condition = Array.isArray(parentEntityId) ? inArray(junctionSourceCol, parentEntityId) : eq$3(junctionSourceCol, parentEntityId);
3036
+ const condition = Array.isArray(parentEntityId) ? inArray(junctionSourceCol, parentEntityId) : eq(junctionSourceCol, parentEntityId);
3914
3037
  return {
3915
3038
  join: {
3916
3039
  table: junctionTable,
3917
- condition: eq$3(targetIdColumn, junctionTargetCol)
3040
+ condition: eq(targetIdColumn, junctionTargetCol)
3918
3041
  },
3919
3042
  condition
3920
3043
  };
@@ -3935,11 +3058,11 @@ class DrizzleConditionBuilder {
3935
3058
  if (!junctionTargetCol) {
3936
3059
  throw new Error(`Target column '${through.targetColumn}' not found in junction table '${through.table}'`);
3937
3060
  }
3938
- const condition = Array.isArray(parentEntityId) ? inArray(junctionSourceCol, parentEntityId) : eq$3(junctionSourceCol, parentEntityId);
3061
+ const condition = Array.isArray(parentEntityId) ? inArray(junctionSourceCol, parentEntityId) : eq(junctionSourceCol, parentEntityId);
3939
3062
  return {
3940
3063
  join: {
3941
3064
  table: junctionTable,
3942
- condition: eq$3(targetIdColumn, junctionTargetCol)
3065
+ condition: eq(targetIdColumn, junctionTargetCol)
3943
3066
  },
3944
3067
  condition
3945
3068
  };
@@ -3955,15 +3078,15 @@ class DrizzleConditionBuilder {
3955
3078
  if (!idCol) {
3956
3079
  throw new Error('No primary key or "id" column found in target table');
3957
3080
  }
3958
- return Array.isArray(parentEntityId) ? inArray(idCol, parentEntityId) : eq$3(idCol, parentEntityId);
3081
+ return Array.isArray(parentEntityId) ? inArray(idCol, parentEntityId) : eq(idCol, parentEntityId);
3959
3082
  }
3960
- return Array.isArray(parentEntityId) ? inArray(targetIdCol, parentEntityId) : eq$3(targetIdCol, parentEntityId);
3083
+ return Array.isArray(parentEntityId) ? inArray(targetIdCol, parentEntityId) : eq(targetIdCol, parentEntityId);
3961
3084
  } else if (relation.direction === "inverse" && relation.foreignKeyOnTarget) {
3962
3085
  const foreignKeyCol = targetTable[relation.foreignKeyOnTarget];
3963
3086
  if (!foreignKeyCol) {
3964
3087
  throw new Error(`Foreign key column '${relation.foreignKeyOnTarget}' not found in target table. This might be a many-to-many relationship that requires a junction table. Consider using 'through' property or ensure the corresponding owning relation exists with junction table configuration.`);
3965
3088
  }
3966
- return Array.isArray(parentEntityId) ? inArray(foreignKeyCol, parentEntityId) : eq$3(foreignKeyCol, parentEntityId);
3089
+ return Array.isArray(parentEntityId) ? inArray(foreignKeyCol, parentEntityId) : eq(foreignKeyCol, parentEntityId);
3967
3090
  } else if (relation.direction === "inverse" && relation.cardinality === "many" && relation.inverseRelationName) {
3968
3091
  throw new Error(`Inverse many-to-many relation '${relation.relationName}' requires a junction table. Either specify 'through' property or ensure the corresponding owning relation exists with junction table configuration.`);
3969
3092
  } else if (relation.direction === "inverse" && relation.cardinality === "one" && relation.inverseRelationName) {
@@ -3973,7 +3096,7 @@ class DrizzleConditionBuilder {
3973
3096
  throw new Error(`Auto-inferred foreign key column '${inferredForeignKeyName}' not found in target table for inverse relation '${relation.relationName}'. Please specify 'foreignKeyOnTarget' explicitly.`);
3974
3097
  }
3975
3098
  console.debug(`🔍 [DrizzleConditionBuilder] Auto-inferred foreign key '${inferredForeignKeyName}' for inverse relation '${relation.relationName}'`);
3976
- return Array.isArray(parentEntityId) ? inArray(foreignKeyCol, parentEntityId) : eq$3(foreignKeyCol, parentEntityId);
3099
+ return Array.isArray(parentEntityId) ? inArray(foreignKeyCol, parentEntityId) : eq(foreignKeyCol, parentEntityId);
3977
3100
  } else {
3978
3101
  throw new Error(`Relation '${relation.relationName}' lacks proper configuration. For many-to-many relations, use 'through' property. For simple relations, use 'localKey' or 'foreignKeyOnTarget'.`);
3979
3102
  }
@@ -4014,7 +3137,7 @@ class DrizzleConditionBuilder {
4014
3137
  * Build a unique field check condition
4015
3138
  */
4016
3139
  static buildUniqueFieldCondition(fieldColumn, value, idColumn, excludeId) {
4017
- const conditions = [eq$3(fieldColumn, value)];
3140
+ const conditions = [eq(fieldColumn, value)];
4018
3141
  if (excludeId && idColumn) {
4019
3142
  conditions.push(sql`${idColumn} != ${excludeId}`);
4020
3143
  }
@@ -4089,7 +3212,7 @@ class DrizzleConditionBuilder {
4089
3212
  if (currentTable !== parentTable) {
4090
3213
  throw new Error("Join path did not result in connecting to parent table");
4091
3214
  }
4092
- const allConditions = [eq$3(parentIdColumn, parentEntityId)];
3215
+ const allConditions = [eq(parentIdColumn, parentEntityId)];
4093
3216
  if (additionalFilters) {
4094
3217
  allConditions.push(...additionalFilters);
4095
3218
  }
@@ -4111,11 +3234,11 @@ class DrizzleConditionBuilder {
4111
3234
  if (!junctionTargetCol) {
4112
3235
  throw new Error(`Target column '${through.targetColumn}' not found in junction table '${through.table}'`);
4113
3236
  }
4114
- const baseConditions = [eq$3(junctionSourceCol, parentEntityId)];
3237
+ const baseConditions = [eq(junctionSourceCol, parentEntityId)];
4115
3238
  if (additionalFilters && additionalFilters.length > 0) {
4116
3239
  baseConditions.push(...additionalFilters);
4117
3240
  }
4118
- return baseCountQuery.innerJoin(junctionTable, eq$3(targetIdColumn, junctionTargetCol)).where(and(...baseConditions));
3241
+ return baseCountQuery.innerJoin(junctionTable, eq(targetIdColumn, junctionTargetCol)).where(and(...baseConditions));
4119
3242
  }
4120
3243
  /**
4121
3244
  * Build inverse junction table conditions for count queries
@@ -4133,11 +3256,11 @@ class DrizzleConditionBuilder {
4133
3256
  if (!junctionTargetCol) {
4134
3257
  throw new Error(`Target column '${through.targetColumn}' not found in junction table '${through.table}'`);
4135
3258
  }
4136
- const baseConditions = [eq$3(junctionSourceCol, parentEntityId)];
3259
+ const baseConditions = [eq(junctionSourceCol, parentEntityId)];
4137
3260
  if (additionalFilters && additionalFilters.length > 0) {
4138
3261
  baseConditions.push(...additionalFilters);
4139
3262
  }
4140
- return baseCountQuery.innerJoin(junctionTable, eq$3(targetIdColumn, junctionTargetCol)).where(and(...baseConditions));
3263
+ return baseCountQuery.innerJoin(junctionTable, eq(targetIdColumn, junctionTargetCol)).where(and(...baseConditions));
4141
3264
  }
4142
3265
  /**
4143
3266
  * Helper method to extract table names from columns
@@ -4477,7 +3600,25 @@ function serializePropertyToServer(value, property) {
4477
3600
  return result;
4478
3601
  }
4479
3602
  return value;
3603
+ case "string":
3604
+ if (typeof value === "string") {
3605
+ if (value.startsWith("data:application/octet-stream;base64,")) {
3606
+ const base64Data = value.split(",")[1];
3607
+ if (base64Data) {
3608
+ return Buffer.from(base64Data, "base64");
3609
+ }
3610
+ }
3611
+ }
3612
+ return value;
4480
3613
  default:
3614
+ if (typeof value === "string") {
3615
+ if (value.startsWith("data:application/octet-stream;base64,")) {
3616
+ const base64Data = value.split(",")[1];
3617
+ if (base64Data) {
3618
+ return Buffer.from(base64Data, "base64");
3619
+ }
3620
+ }
3621
+ }
4481
3622
  return value;
4482
3623
  }
4483
3624
  }
@@ -4511,7 +3652,7 @@ async function parseDataFromServer(data, collection, db, registry) {
4511
3652
  if (targetTable && currentEntityId) {
4512
3653
  const foreignKeyColumn = targetTable[relation.foreignKeyOnTarget];
4513
3654
  if (foreignKeyColumn) {
4514
- const relatedEntities = await db.select().from(targetTable).where(eq$3(foreignKeyColumn, currentEntityId)).limit(relation.cardinality === "one" ? 1 : 100);
3655
+ const relatedEntities = await db.select().from(targetTable).where(eq(foreignKeyColumn, currentEntityId)).limit(relation.cardinality === "one" ? 1 : 100);
4515
3656
  if (relatedEntities.length > 0) {
4516
3657
  if (relation.cardinality === "one") {
4517
3658
  const targetPks = getPrimaryKeys(targetCollection, registry);
@@ -4558,12 +3699,12 @@ async function parseDataFromServer(data, collection, db, registry) {
4558
3699
  console.warn(`Join columns not found: ${fromColumn} -> ${toColumn}`);
4559
3700
  break;
4560
3701
  }
4561
- query = query.innerJoin(joinTable, eq$3(fromCol, toCol));
3702
+ query = query.innerJoin(joinTable, eq(fromCol, toCol));
4562
3703
  currentTable = joinTable;
4563
3704
  }
4564
3705
  if (pks.length === 1) {
4565
3706
  const sourceIdField = sourceTable[pks[0].fieldName];
4566
- query = query.where(eq$3(sourceIdField, currentEntityId));
3707
+ query = query.where(eq(sourceIdField, currentEntityId));
4567
3708
  } else {
4568
3709
  console.warn(`Join path resolution for composite primary keys is not yet fully supported: ${collection.slug}`);
4569
3710
  }
@@ -4571,7 +3712,7 @@ async function parseDataFromServer(data, collection, db, registry) {
4571
3712
  let combinedWhere;
4572
3713
  if (pks.length === 1) {
4573
3714
  const sourceIdField = sourceTable[pks[0].fieldName];
4574
- combinedWhere = DrizzleConditionBuilder.combineConditionsWithAnd([eq$3(sourceIdField, currentEntityId), ...additionalFilters].filter(Boolean));
3715
+ combinedWhere = DrizzleConditionBuilder.combineConditionsWithAnd([eq(sourceIdField, currentEntityId), ...additionalFilters].filter(Boolean));
4575
3716
  }
4576
3717
  const joinResults = await query.where(combinedWhere).limit(relation.cardinality === "one" ? 1 : 100);
4577
3718
  if (joinResults.length > 0) {
@@ -4603,6 +3744,37 @@ function parsePropertyFromServer(value, property, collection, propertyKey) {
4603
3744
  return value;
4604
3745
  }
4605
3746
  switch (property.type) {
3747
+ case "string": {
3748
+ if (typeof value === "string") return value;
3749
+ let isBuffer = false;
3750
+ let buf = null;
3751
+ if (Buffer.isBuffer(value)) {
3752
+ isBuffer = true;
3753
+ buf = value;
3754
+ } else if (typeof value === "object" && value !== null && value.type === "Buffer" && Array.isArray(value.data)) {
3755
+ isBuffer = true;
3756
+ buf = Buffer.from(value.data);
3757
+ }
3758
+ if (isBuffer && buf) {
3759
+ let isPrintable = true;
3760
+ for (let i = 0; i < buf.length; i++) {
3761
+ const b = buf[i];
3762
+ if ((b < 32 || b > 126) && b !== 9 && b !== 10 && b !== 13) {
3763
+ isPrintable = false;
3764
+ break;
3765
+ }
3766
+ }
3767
+ return isPrintable ? buf.toString("utf8") : `data:application/octet-stream;base64,${buf.toString("base64")}`;
3768
+ }
3769
+ if (typeof value === "object" && value !== null) {
3770
+ try {
3771
+ return JSON.stringify(value);
3772
+ } catch {
3773
+ return String(value);
3774
+ }
3775
+ }
3776
+ return String(value);
3777
+ }
4606
3778
  case "relation":
4607
3779
  if (typeof value === "string" || typeof value === "number") {
4608
3780
  let relationDef = property.relation;
@@ -4686,8 +3858,29 @@ function parsePropertyFromServer(value, property, collection, propertyKey) {
4686
3858
  }
4687
3859
  return null;
4688
3860
  }
4689
- default:
3861
+ default: {
3862
+ let isBuffer = false;
3863
+ let buf = null;
3864
+ if (Buffer.isBuffer(value)) {
3865
+ isBuffer = true;
3866
+ buf = value;
3867
+ } else if (typeof value === "object" && value !== null && value.type === "Buffer" && Array.isArray(value.data)) {
3868
+ isBuffer = true;
3869
+ buf = Buffer.from(value.data);
3870
+ }
3871
+ if (isBuffer && buf) {
3872
+ let isPrintable = true;
3873
+ for (let i = 0; i < buf.length; i++) {
3874
+ const b = buf[i];
3875
+ if ((b < 32 || b > 126) && b !== 9 && b !== 10 && b !== 13) {
3876
+ isPrintable = false;
3877
+ break;
3878
+ }
3879
+ }
3880
+ return isPrintable ? buf.toString("utf8") : `data:application/octet-stream;base64,${buf.toString("base64")}`;
3881
+ }
4690
3882
  return value;
3883
+ }
4691
3884
  }
4692
3885
  }
4693
3886
  function normalizeScalarValues(data, properties, collection, resolvedRelations, options) {
@@ -4770,11 +3963,11 @@ class RelationService {
4770
3963
  if (!fromCol || !toCol) {
4771
3964
  throw new Error(`Join columns not found: ${fromColumn} -> ${toColumn}`);
4772
3965
  }
4773
- query2 = query2.innerJoin(joinTable, eq$3(fromCol, toCol));
3966
+ query2 = query2.innerJoin(joinTable, eq(fromCol, toCol));
4774
3967
  currentTable = joinTable;
4775
3968
  }
4776
3969
  const parentIdField = parentTable[getPrimaryKeys(parentCollection, this.registry)[0].fieldName];
4777
- query2 = query2.where(eq$3(parentIdField, parsedParentId));
3970
+ query2 = query2.where(eq(parentIdField, parsedParentId));
4778
3971
  if (options.limit) {
4779
3972
  query2 = query2.limit(options.limit);
4780
3973
  }
@@ -4893,7 +4086,7 @@ class RelationService {
4893
4086
  if (!fromCol || !toCol) {
4894
4087
  throw new Error(`Join columns not found: ${fromColumn} -> ${toColumn}`);
4895
4088
  }
4896
- query2 = query2.innerJoin(joinTable, eq$3(fromCol, toCol));
4089
+ query2 = query2.innerJoin(joinTable, eq(fromCol, toCol));
4897
4090
  currentTable = joinTable;
4898
4091
  }
4899
4092
  const parentIdField = parentTable[getPrimaryKeys(parentCollection, this.registry)[0].fieldName];
@@ -5024,7 +4217,7 @@ class RelationService {
5024
4217
  const fromCol = currentTable[fromColName];
5025
4218
  const toCol = joinTable[toColName];
5026
4219
  if (!fromCol || !toCol) throw new Error(`Join columns not found: ${fromColumn} -> ${toColumn}`);
5027
- query2 = query2.innerJoin(joinTable, eq$3(fromCol, toCol));
4220
+ query2 = query2.innerJoin(joinTable, eq(fromCol, toCol));
5028
4221
  currentTable = joinTable;
5029
4222
  }
5030
4223
  const parentIdField = parentTable[getPrimaryKeys(parentCollection, this.registry)[0].fieldName];
@@ -5059,7 +4252,7 @@ class RelationService {
5059
4252
  console.warn(`[batchFetchRelatedEntitiesMany] Junction columns not found in '${relation.through.table}'`);
5060
4253
  return /* @__PURE__ */ new Map();
5061
4254
  }
5062
- const query2 = this.db.select().from(junctionTable).innerJoin(targetTable, eq$3(targetJunctionCol, targetIdField)).where(inArray(sourceJunctionCol, parsedParentIds));
4255
+ const query2 = this.db.select().from(junctionTable).innerJoin(targetTable, eq(targetJunctionCol, targetIdField)).where(inArray(sourceJunctionCol, parsedParentIds));
5063
4256
  const results2 = await query2;
5064
4257
  const resultMap2 = /* @__PURE__ */ new Map();
5065
4258
  const targetTableName = getTableName(targetCollection);
@@ -5157,7 +4350,7 @@ class RelationService {
5157
4350
  const parentIdInfo = parentPks[0];
5158
4351
  const parsedParentIdObj = parseIdValues(entityId, parentPks);
5159
4352
  const parsedParentId = parsedParentIdObj[parentIdInfo.fieldName];
5160
- await tx.delete(junctionTable).where(eq$3(sourceJunctionColumn, parsedParentId));
4353
+ await tx.delete(junctionTable).where(eq(sourceJunctionColumn, parsedParentId));
5161
4354
  if (targetEntityIds.length > 0) {
5162
4355
  const targetPks = getPrimaryKeys(targetCollection, this.registry);
5163
4356
  const targetIdInfo = targetPks[0];
@@ -5186,7 +4379,7 @@ class RelationService {
5186
4379
  const parentIdInfo = parentPks[0];
5187
4380
  const parsedParentIdObj = parseIdValues(entityId, parentPks);
5188
4381
  const parsedParentId = parsedParentIdObj[parentIdInfo.fieldName];
5189
- await tx.delete(junctionTable).where(eq$3(sourceJunctionColumn, parsedParentId));
4382
+ await tx.delete(junctionTable).where(eq(sourceJunctionColumn, parsedParentId));
5190
4383
  if (targetEntityIds.length > 0) {
5191
4384
  const targetPks = getPrimaryKeys(targetCollection, this.registry);
5192
4385
  const targetIdInfo = targetPks[0];
@@ -5219,14 +4412,14 @@ class RelationService {
5219
4412
  const parsedTargetIds = targetEntityIds.map((id) => parseIdValues(id, targetPks)[targetIdInfo.fieldName]);
5220
4413
  await tx.update(targetTable).set({
5221
4414
  [relation.foreignKeyOnTarget]: null
5222
- }).where(and(eq$3(fkCol, parsedParentId), sql`${targetIdCol} NOT IN (${sql.join(parsedTargetIds)})`));
4415
+ }).where(and(eq(fkCol, parsedParentId), sql`${targetIdCol} NOT IN (${sql.join(parsedTargetIds)})`));
5223
4416
  await tx.update(targetTable).set({
5224
4417
  [relation.foreignKeyOnTarget]: parsedParentId
5225
4418
  }).where(inArray(targetIdCol, parsedTargetIds));
5226
4419
  } else {
5227
4420
  await tx.update(targetTable).set({
5228
4421
  [relation.foreignKeyOnTarget]: null
5229
- }).where(eq$3(fkCol, parsedParentId));
4422
+ }).where(eq(fkCol, parsedParentId));
5230
4423
  }
5231
4424
  } else {
5232
4425
  console.warn(`Many relation '${key}' in collection '${collection.slug}' lacks write configuration and will be skipped during save.`);
@@ -5285,17 +4478,17 @@ class RelationService {
5285
4478
  if (newValue === null || newValue === void 0) {
5286
4479
  await tx.update(targetTable).set({
5287
4480
  [relation.foreignKeyOnTarget]: null
5288
- }).where(eq$3(foreignKeyColumn, parsedSourceId));
4481
+ }).where(eq(foreignKeyColumn, parsedSourceId));
5289
4482
  } else {
5290
4483
  const parsedNewTargetIdObj = parseIdValues(newValue, targetPks);
5291
4484
  const parsedNewTargetId = parsedNewTargetIdObj[targetIdInfo.fieldName];
5292
4485
  const targetIdField = targetTable[targetIdInfo.fieldName];
5293
4486
  await tx.update(targetTable).set({
5294
4487
  [relation.foreignKeyOnTarget]: null
5295
- }).where(eq$3(foreignKeyColumn, parsedSourceId));
4488
+ }).where(eq(foreignKeyColumn, parsedSourceId));
5296
4489
  await tx.update(targetTable).set({
5297
4490
  [relation.foreignKeyOnTarget]: parsedSourceId
5298
- }).where(eq$3(targetIdField, parsedNewTargetId));
4491
+ }).where(eq(targetIdField, parsedNewTargetId));
5299
4492
  }
5300
4493
  } catch (e) {
5301
4494
  console.warn(`Failed to update inverse relation '${relation.relationName}':`, e);
@@ -5350,7 +4543,7 @@ class RelationService {
5350
4543
  const sourceIdInfo = sourcePks[0];
5351
4544
  const parsedSourceIdObj = parseIdValues(sourceEntityId, sourcePks);
5352
4545
  const parsedSourceId = parsedSourceIdObj[sourceIdInfo.fieldName];
5353
- await tx.delete(junctionTable).where(eq$3(sourceJunctionColumn, parsedSourceId));
4546
+ await tx.delete(junctionTable).where(eq(sourceJunctionColumn, parsedSourceId));
5354
4547
  if (newValue && Array.isArray(newValue) && newValue.length > 0) {
5355
4548
  const targetPks = getPrimaryKeys(targetCollection, this.registry);
5356
4549
  const targetIdInfo = targetPks[0];
@@ -5401,7 +4594,7 @@ class RelationService {
5401
4594
  const sourceIdInfo = sourcePks[0];
5402
4595
  const parsedSourceIdObj = parseIdValues(sourceEntityId, sourcePks);
5403
4596
  const parsedSourceId = parsedSourceIdObj[sourceIdInfo.fieldName];
5404
- await tx.delete(junctionTable).where(eq$3(sourceJunctionColumn, parsedSourceId));
4597
+ await tx.delete(junctionTable).where(eq(sourceJunctionColumn, parsedSourceId));
5405
4598
  if (newValue && Array.isArray(newValue) && newValue.length > 0) {
5406
4599
  const targetPks = getPrimaryKeys(targetCollection, this.registry);
5407
4600
  const targetIdInfo = targetPks[0];
@@ -5456,14 +4649,14 @@ class RelationService {
5456
4649
  }
5457
4650
  const parentRows = await tx.select({
5458
4651
  val: parentSourceCol
5459
- }).from(parentTable).where(eq$3(parentIdCol, parsedParentId)).limit(1);
4652
+ }).from(parentTable).where(eq(parentIdCol, parsedParentId)).limit(1);
5460
4653
  if (parentRows.length === 0) continue;
5461
4654
  const parentFKValue = parentRows[0].val;
5462
4655
  if (newTargetId === null || newTargetId === void 0) {
5463
4656
  if (parentFKValue !== null && parentFKValue !== void 0) {
5464
4657
  await tx.update(targetTable).set({
5465
4658
  [targetFKColName]: null
5466
- }).where(eq$3(targetFKCol, parentFKValue));
4659
+ }).where(eq(targetFKCol, parentFKValue));
5467
4660
  }
5468
4661
  continue;
5469
4662
  }
@@ -5472,14 +4665,14 @@ class RelationService {
5472
4665
  if (parentFKValue !== null && parentFKValue !== void 0) {
5473
4666
  await tx.update(targetTable).set({
5474
4667
  [targetFKColName]: null
5475
- }).where(eq$3(targetFKCol, parentFKValue));
4668
+ }).where(eq(targetFKCol, parentFKValue));
5476
4669
  } else {
5477
4670
  console.warn(`Cannot set joinPath relation '${relation.relationName}' because parent FK value is null/undefined`);
5478
4671
  continue;
5479
4672
  }
5480
4673
  await tx.update(targetTable).set({
5481
4674
  [targetFKColName]: parentFKValue
5482
- }).where(eq$3(targetIdCol, parsedTargetId));
4675
+ }).where(eq(targetIdCol, parsedTargetId));
5483
4676
  }
5484
4677
  }
5485
4678
  /**
@@ -5864,7 +5057,7 @@ class EntityFetchService {
5864
5057
  const collection = getCollectionByPath(collectionPath, this.registry);
5865
5058
  const searchConditions = DrizzleConditionBuilder.buildSearchConditions(options.searchString, collection.properties, table);
5866
5059
  if (searchConditions.length === 0) {
5867
- queryOpts.where = and(eq$3(idField, -99999999));
5060
+ queryOpts.where = and(eq(idField, -99999999));
5868
5061
  return queryOpts;
5869
5062
  }
5870
5063
  allConditions.push(DrizzleConditionBuilder.combineConditionsWithOr(searchConditions));
@@ -5911,9 +5104,9 @@ class EntityFetchService {
5911
5104
  const startAfterId = cursor.id ?? cursor[idInfo.fieldName];
5912
5105
  if (startAfterOrderValue !== void 0 && startAfterId !== void 0) {
5913
5106
  if (options.order === "asc") {
5914
- return [or(gt(orderByField, startAfterOrderValue), and(eq$3(orderByField, startAfterOrderValue), gt(idField, startAfterId)))];
5107
+ return [or(gt(orderByField, startAfterOrderValue), and(eq(orderByField, startAfterOrderValue), gt(idField, startAfterId)))];
5915
5108
  } else {
5916
- return [or(lt(orderByField, startAfterOrderValue), and(eq$3(orderByField, startAfterOrderValue), lt(idField, startAfterId)))];
5109
+ return [or(lt(orderByField, startAfterOrderValue), and(eq(orderByField, startAfterOrderValue), lt(idField, startAfterId)))];
5917
5110
  }
5918
5111
  }
5919
5112
  }
@@ -5947,7 +5140,7 @@ class EntityFetchService {
5947
5140
  try {
5948
5141
  const withConfig = this.buildWithConfig(collection);
5949
5142
  const row = await qb.findFirst({
5950
- where: eq$3(idField, parsedId),
5143
+ where: eq(idField, parsedId),
5951
5144
  with: withConfig
5952
5145
  });
5953
5146
  if (!row) return void 0;
@@ -5955,10 +5148,14 @@ class EntityFetchService {
5955
5148
  await this.resolveJoinPathRelations(entity, collection, collectionPath, parsedId, databaseId);
5956
5149
  return entity;
5957
5150
  } catch (e) {
5151
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5152
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5153
+ console.error(`Hint: This usually means a relation in your drizzle schema is missing a reciprocal 'one()' or 'many()' definition. Run 'rebase schema generate' to fix this.`);
5154
+ }
5958
5155
  console.warn(`[EntityFetchService] db.query.findFirst failed for ${collectionPath}, falling back to db.select:`, e);
5959
5156
  }
5960
5157
  }
5961
- const result = await this.db.select().from(table).where(eq$3(idField, parsedId)).limit(1);
5158
+ const result = await this.db.select().from(table).where(eq(idField, parsedId)).limit(1);
5962
5159
  if (result.length === 0) return void 0;
5963
5160
  const raw = result[0];
5964
5161
  const values = await parseDataFromServer(raw, collection, this.db, this.registry);
@@ -6015,6 +5212,10 @@ class EntityFetchService {
6015
5212
  const entities = results2.map((row) => this.drizzleResultToEntity(row, collection, collectionPath, idInfo, options.databaseId, idInfoArray));
6016
5213
  return entities;
6017
5214
  } catch (e) {
5215
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5216
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5217
+ console.error(`Hint: This usually means a relation in your drizzle schema is missing a reciprocal 'one()' or 'many()' definition. Run 'rebase schema generate' to fix this.`);
5218
+ }
6018
5219
  console.warn(`[EntityFetchService] db.query.findMany failed for ${collectionPath}, falling back to db.select:`, e);
6019
5220
  }
6020
5221
  }
@@ -6284,6 +5485,10 @@ class EntityFetchService {
6284
5485
  await this.resolveJoinPathRelationsBatchRest(restRows, collection, collectionPath, idInfoArray, include);
6285
5486
  return restRows;
6286
5487
  } catch (e) {
5488
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5489
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5490
+ console.error(`Hint: This usually means a relation in your drizzle schema is missing a reciprocal 'one()' or 'many()' definition. Run 'rebase schema generate' to fix this.`);
5491
+ }
6287
5492
  console.warn(`[fetchCollectionForRest] db.query.findMany failed for ${collectionPath}, falling back:`, e);
6288
5493
  }
6289
5494
  }
@@ -6354,7 +5559,7 @@ class EntityFetchService {
6354
5559
  try {
6355
5560
  const withConfig = include && include.length > 0 ? this.buildWithConfig(collection, include) : void 0;
6356
5561
  const row = await qb.findFirst({
6357
- where: eq$3(idField, parsedId),
5562
+ where: eq(idField, parsedId),
6358
5563
  ...withConfig ? {
6359
5564
  with: withConfig
6360
5565
  } : {}
@@ -6364,10 +5569,14 @@ class EntityFetchService {
6364
5569
  await this.resolveJoinPathRelationsBatchRest([restRow], collection, collectionPath, idInfoArray, include);
6365
5570
  return restRow;
6366
5571
  } catch (e) {
5572
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5573
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5574
+ console.error(`Hint: This usually means a relation in your drizzle schema is missing a reciprocal 'one()' or 'many()' definition. Run 'rebase schema generate' to fix this.`);
5575
+ }
6367
5576
  console.warn(`[fetchEntityForRest] db.query.findFirst failed for ${collectionPath}, falling back:`, e);
6368
5577
  }
6369
5578
  }
6370
- const result = await this.db.select().from(table).where(eq$3(idField, parsedId)).limit(1);
5579
+ const result = await this.db.select().from(table).where(eq(idField, parsedId)).limit(1);
6371
5580
  if (result.length === 0) return null;
6372
5581
  const raw = result[0];
6373
5582
  const flatEntity = {
@@ -6576,7 +5785,7 @@ class EntityPersistService {
6576
5785
  }
6577
5786
  const parsedIdObj = parseIdValues(entityId, idInfoArray);
6578
5787
  const parsedId = parsedIdObj[idInfo.fieldName];
6579
- await this.db.delete(table).where(eq$3(idField, parsedId));
5788
+ await this.db.delete(table).where(eq(idField, parsedId));
6580
5789
  }
6581
5790
  /**
6582
5791
  * Save an entity (create or update)
@@ -6622,7 +5831,7 @@ class EntityPersistService {
6622
5831
  targetColumnName = relation.localKey;
6623
5832
  } else if (relation.foreignKeyOnTarget) {
6624
5833
  targetColumnName = relation.foreignKeyOnTarget;
6625
- } else if (relation.joinPath && relation.joinPath.length > 0) {
5834
+ } else if (relation.joinPath && relation.joinPath.length === 1) {
6626
5835
  const targetTableName = getTableName(targetCollection);
6627
5836
  const relevantJoinStep = relation.joinPath.find((joinStep) => joinStep.table === targetTableName);
6628
5837
  if (relevantJoinStep) {
@@ -6633,6 +5842,8 @@ class EntityPersistService {
6633
5842
  const targetColumnNames = DrizzleConditionBuilder.getColumnNamesFromColumns(relation.joinPath[0].on.to);
6634
5843
  targetColumnName = targetColumnNames[0];
6635
5844
  }
5845
+ } else if (relation.joinPath && relation.joinPath.length > 1) {
5846
+ break;
6636
5847
  } else {
6637
5848
  throw new Error(`Relation '${relationKey}' lacks configuration for path-based saving.`);
6638
5849
  }
@@ -6698,7 +5909,7 @@ class EntityPersistService {
6698
5909
  const conditions = [];
6699
5910
  for (const info of idInfoArray) {
6700
5911
  const field = table[info.fieldName];
6701
- conditions.push(eq$3(field, idValues[info.fieldName]));
5912
+ conditions.push(eq(field, idValues[info.fieldName]));
6702
5913
  }
6703
5914
  await updateQuery.where(and(...conditions));
6704
5915
  }
@@ -6755,22 +5966,78 @@ class EntityPersistService {
6755
5966
  const pgError = this.extractPgError(error);
6756
5967
  if (pgError) {
6757
5968
  const detail = pgError.detail;
5969
+ const hint = pgError.hint;
6758
5970
  const constraint = pgError.constraint;
6759
5971
  const column = pgError.column;
6760
5972
  const table = pgError.table;
5973
+ const dataType = pgError.dataType;
5974
+ const pgMessage = pgError.message || "Unknown database error";
5975
+ const suffix = hint ? ` Hint: ${hint}` : "";
5976
+ const tableRef = table ?? collectionSlug;
6761
5977
  switch (pgError.code) {
6762
5978
  case "23503":
6763
- return new Error(detail ? `Foreign key constraint violated: ${detail}` : `Cannot save: a foreign key constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".`);
5979
+ return new Error(detail ? `Foreign key constraint violated: ${detail}${suffix}` : `Cannot save: a foreign key constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
6764
5980
  case "23505":
6765
- return new Error(detail ? `Duplicate value: ${detail}` : `Cannot save: a unique constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".`);
5981
+ return new Error(detail ? `Duplicate value: ${detail}${suffix}` : `Cannot save: a unique constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
6766
5982
  case "23502":
6767
- return new Error(`Missing required field: "${column ?? "unknown"}" in "${table ?? collectionSlug}" cannot be empty.`);
5983
+ return new Error(`Missing required field: "${column ?? "unknown"}" in "${tableRef}" cannot be empty.${suffix}`);
6768
5984
  case "23514":
6769
- return new Error(`Validation failed: a check constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".`);
5985
+ return new Error(`Validation failed: a check constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
5986
+ case "22P02":
5987
+ return new Error(`Invalid data format in "${collectionSlug}": ${pgMessage}${suffix}`);
5988
+ case "22001":
5989
+ return new Error(`Value too long for column "${column ?? "unknown"}" in "${tableRef}": ${pgMessage}${suffix}`);
5990
+ case "22003":
5991
+ return new Error(`Numeric value out of range for column "${column ?? "unknown"}" in "${tableRef}": ${pgMessage}${suffix}`);
5992
+ case "42703":
5993
+ return new Error(`Unknown column in "${tableRef}": ${pgMessage}. Check if your schema is up to date (run migrations).${suffix}`);
5994
+ case "42P01":
5995
+ return new Error(`Table not found for "${collectionSlug}": ${pgMessage}. Check if your schema is up to date (run migrations).${suffix}`);
5996
+ default: {
5997
+ const parts = [`Database error in "${collectionSlug}" [${pgError.code}]: ${pgMessage}`];
5998
+ if (detail) parts.push(`Detail: ${detail}`);
5999
+ if (column) parts.push(`Column: ${column}`);
6000
+ if (dataType) parts.push(`Data type: ${dataType}`);
6001
+ if (constraint) parts.push(`Constraint: ${constraint}`);
6002
+ if (hint) parts.push(`Hint: ${hint}`);
6003
+ return new Error(parts.join(". "));
6004
+ }
6005
+ }
6006
+ }
6007
+ const causeMessage = this.extractCauseMessage(error);
6008
+ if (causeMessage) {
6009
+ return new Error(`Database error in "${collectionSlug}": ${causeMessage}`);
6010
+ }
6011
+ if (error instanceof Error) {
6012
+ const cleaned = this.stripSqlFromMessage(error.message, collectionSlug);
6013
+ return new Error(cleaned);
6014
+ }
6015
+ return new Error(`Database error in "${collectionSlug}": ${String(error)}`);
6016
+ }
6017
+ /**
6018
+ * Walk the error cause chain and return the deepest meaningful message.
6019
+ */
6020
+ extractCauseMessage(error) {
6021
+ if (!error || typeof error !== "object") return null;
6022
+ const err = error;
6023
+ if (err.cause && typeof err.cause === "object") {
6024
+ const deeper = this.extractCauseMessage(err.cause);
6025
+ if (deeper) return deeper;
6026
+ if (err.cause instanceof Error && err.cause.message) {
6027
+ return err.cause.message;
6770
6028
  }
6771
6029
  }
6772
- if (error instanceof Error) return error;
6773
- return new Error(String(error));
6030
+ return null;
6031
+ }
6032
+ /**
6033
+ * Strip the raw SQL query from a Drizzle "Failed query: ..." message,
6034
+ * keeping only the error description.
6035
+ */
6036
+ stripSqlFromMessage(message, collectionSlug) {
6037
+ if (message.startsWith("Failed query:")) {
6038
+ return `Failed to save entity in "${collectionSlug}". Check server logs for details.`;
6039
+ }
6040
+ return message;
6774
6041
  }
6775
6042
  /**
6776
6043
  * Extract the underlying PostgreSQL error from a Drizzle wrapper.
@@ -6779,7 +6046,7 @@ class EntityPersistService {
6779
6046
  extractPgError(error) {
6780
6047
  if (!error || typeof error !== "object") return null;
6781
6048
  const err = error;
6782
- if (err.code && /^[0-9]{5}$/.test(err.code)) {
6049
+ if (err.code && /^[0-9A-Z]{5}$/.test(err.code)) {
6783
6050
  return err;
6784
6051
  }
6785
6052
  if (err.cause && typeof err.cause === "object") {
@@ -7067,6 +6334,7 @@ class PostgresBackendDriver {
7067
6334
  branchService;
7068
6335
  user;
7069
6336
  data;
6337
+ client;
7070
6338
  /**
7071
6339
  * When true, realtime notifications are deferred until after the
7072
6340
  * wrapping transaction commits. Set by `withAuth` → `withTransaction`.
@@ -7095,6 +6363,14 @@ class PostgresBackendDriver {
7095
6363
  } : {}
7096
6364
  };
7097
6365
  }
6366
+ /**
6367
+ * REST-optimised fetch service (include-aware eager-loading).
6368
+ * Delegates to the underlying EntityFetchService which already
6369
+ * implements the matching method signatures.
6370
+ */
6371
+ get restFetchService() {
6372
+ return this.entityService.getFetchService();
6373
+ }
7098
6374
  resolveCollectionCallbacks(collection, path2) {
7099
6375
  if (!collection && !path2) return {
7100
6376
  collection: void 0,
@@ -7148,7 +6424,8 @@ class PostgresBackendDriver {
7148
6424
  const contextForCallback = {
7149
6425
  user: this.user,
7150
6426
  driver: this,
7151
- data: this.data
6427
+ data: this.data,
6428
+ client: this.client
7152
6429
  };
7153
6430
  return Promise.all(entities.map(async (entity) => {
7154
6431
  let fetched = entity;
@@ -7242,7 +6519,8 @@ class PostgresBackendDriver {
7242
6519
  const contextForCallback = {
7243
6520
  user: this.user,
7244
6521
  driver: this,
7245
- data: this.data
6522
+ data: this.data,
6523
+ client: this.client
7246
6524
  };
7247
6525
  if (callbacks?.afterRead) {
7248
6526
  entity = await callbacks.afterRead({
@@ -7311,7 +6589,8 @@ class PostgresBackendDriver {
7311
6589
  const contextForCallback = {
7312
6590
  user: this.user,
7313
6591
  driver: this,
7314
- data: this.data
6592
+ data: this.data,
6593
+ client: this.client
7315
6594
  };
7316
6595
  let previousValuesForHistory;
7317
6596
  if (status === "existing" && entityId) {
@@ -7346,6 +6625,14 @@ class PostgresBackendDriver {
7346
6625
  if (result) updatedValues = mergeDeep(updatedValues, result);
7347
6626
  }
7348
6627
  }
6628
+ if (resolvedCollection?.properties) {
6629
+ updatedValues = updateDateAutoValues({
6630
+ inputValues: updatedValues,
6631
+ properties: resolvedCollection.properties,
6632
+ status: status ?? "new",
6633
+ timestampNowValue: /* @__PURE__ */ new Date()
6634
+ });
6635
+ }
7349
6636
  try {
7350
6637
  let savedEntity = await this.entityService.saveEntity(path2, updatedValues, entityId, resolvedCollection?.databaseId);
7351
6638
  if (savedEntity && (callbacks?.afterRead || propertyCallbacks?.afterRead)) {
@@ -7451,7 +6738,8 @@ class PostgresBackendDriver {
7451
6738
  const contextForCallback = {
7452
6739
  user: this.user,
7453
6740
  driver: this,
7454
- data: this.data
6741
+ data: this.data,
6742
+ client: this.client
7455
6743
  };
7456
6744
  if (callbacks?.beforeDelete || propertyCallbacks?.beforeDelete) {
7457
6745
  if (callbacks?.beforeDelete) {
@@ -7778,6 +7066,7 @@ class AuthenticatedPostgresBackendDriver {
7778
7066
  txDelegate.entityService = txEntityService;
7779
7067
  txDelegate._deferNotifications = true;
7780
7068
  txDelegate._pendingNotifications = pendingNotifications;
7069
+ txDelegate.client = this.delegate.client;
7781
7070
  return await operation(txDelegate);
7782
7071
  });
7783
7072
  for (const notification of pendingNotifications) {
@@ -8059,6 +7348,12 @@ const userIdentitiesRelations = relations(userIdentities, ({
8059
7348
  references: [users.id]
8060
7349
  })
8061
7350
  }));
7351
+ const resolveColumnName = (propName, prop) => {
7352
+ if (prop && "columnName" in prop && typeof prop.columnName === "string") {
7353
+ return prop.columnName;
7354
+ }
7355
+ return toSnakeCase(propName);
7356
+ };
8062
7357
  const getPrimaryKeyProp = (collection) => {
8063
7358
  if (collection.properties) {
8064
7359
  const idPropEntry = Object.entries(collection.properties).find(([_, prop]) => "isId" in prop && Boolean(prop.isId));
@@ -8099,7 +7394,7 @@ const isIdProperty = (propName, prop, collection) => {
8099
7394
  return !hasExplicitId && propName === "id";
8100
7395
  };
8101
7396
  const getDrizzleColumn = (propName, prop, collection, collections) => {
8102
- const colName = toSnakeCase(propName);
7397
+ const colName = resolveColumnName(propName, prop);
8103
7398
  let columnDefinition;
8104
7399
  switch (prop.type) {
8105
7400
  case "string": {
@@ -8171,6 +7466,9 @@ const getDrizzleColumn = (propName, prop, collection, collections) => {
8171
7466
  } else {
8172
7467
  columnDefinition = `timestamp("${colName}", { withTimezone: true, mode: 'string' })`;
8173
7468
  }
7469
+ if (dateProp.autoValue === "on_create" || dateProp.autoValue === "on_update") {
7470
+ columnDefinition += `.default(sql\`now()\`)`;
7471
+ }
8174
7472
  break;
8175
7473
  }
8176
7474
  case "map":
@@ -8203,7 +7501,7 @@ const getDrizzleColumn = (propName, prop, collection, collections) => {
8203
7501
  } catch {
8204
7502
  return null;
8205
7503
  }
8206
- const fkColumnName = toSnakeCase(relation.localKey);
7504
+ const fkColumnName = relation.localKey;
8207
7505
  const targetTableVar = getTableVarName(getTableName(targetCollection));
8208
7506
  const pkProp = getPrimaryKeyProp(targetCollection);
8209
7507
  const targetIdField = pkProp.name;
@@ -8391,7 +7689,7 @@ const generateSchema = async (collections, stripPolicies = false) => {
8391
7689
  Object.entries(collection.properties ?? {}).forEach(([propName, prop]) => {
8392
7690
  if ("enum" in prop && (prop.type === "string" || prop.type === "number") && prop.enum) {
8393
7691
  const enumVarName = getEnumVarName(collectionPath, propName);
8394
- const enumDbName = `${collectionPath}_${toSnakeCase(propName)}`;
7692
+ const enumDbName = `${collectionPath}_${resolveColumnName(propName, prop)}`;
8395
7693
  const values = Array.isArray(prop.enum) ? prop.enum.map((v) => String(v.id ?? v)) : Object.keys(prop.enum);
8396
7694
  if (values.length > 0) {
8397
7695
  schemaContent += `export const ${enumVarName} = pgEnum("${enumDbName}", [${values.map((v) => `'${v}'`).join(", ")}]);
@@ -8448,9 +7746,9 @@ const generateSchema = async (collections, stripPolicies = false) => {
8448
7746
  const targetId = getPrimaryKeyName(targetCollection);
8449
7747
  schemaContent += `export const ${tableVarName} = pgTable("${tableName}", {
8450
7748
  `;
8451
- schemaContent += ` ${sourceColumn}: ${sourceColType}("${toSnakeCase(sourceColumn)}").notNull().references(() => ${getTableVarName(getTableName(sourceCollection))}.${sourceId}, ${refOptions}),
7749
+ schemaContent += ` ${sourceColumn}: ${sourceColType}("${sourceColumn}").notNull().references(() => ${getTableVarName(getTableName(sourceCollection))}.${sourceId}, ${refOptions}),
8452
7750
  `;
8453
- schemaContent += ` ${targetColumn}: ${targetColType}("${toSnakeCase(targetColumn)}").notNull().references(() => ${getTableVarName(getTableName(targetCollection))}.${targetId}, ${refOptions}),
7751
+ schemaContent += ` ${targetColumn}: ${targetColType}("${targetColumn}").notNull().references(() => ${getTableVarName(getTableName(targetCollection))}.${targetId}, ${refOptions}),
8454
7752
  `;
8455
7753
  schemaContent += "}, (table) => ({\n";
8456
7754
  schemaContent += ` pk: primaryKey({ columns: [table.${sourceColumn}, table.${targetColumn}] })
@@ -8543,29 +7841,10 @@ const generateSchema = async (collections, stripPolicies = false) => {
8543
7841
  references: [${targetTableVar}.${getPrimaryKeyName(target)}],
8544
7842
  relationName: "${drizzleRelationName}"
8545
7843
  })`);
8546
- } else if (rel.direction === "inverse" && rel.foreignKeyOnTarget) {
8547
- const sourceIdField = getPrimaryKeyName(collection);
7844
+ } else if (rel.direction === "inverse") {
8548
7845
  tableRelations.push(` "${relationKey}": one(${targetTableVar}, {
8549
- fields: [${tableVarName}.${sourceIdField}],
8550
- references: [${targetTableVar}.${rel.foreignKeyOnTarget}],
8551
- relationName: "${drizzleRelationName}"
8552
- })`);
8553
- } else if (rel.direction === "inverse" && !rel.foreignKeyOnTarget) {
8554
- try {
8555
- const targetCollection = rel.target();
8556
- const targetResolvedRelations = resolveCollectionRelations(targetCollection);
8557
- const correspondingRelation = Object.values(targetResolvedRelations).find((targetRel) => targetRel.direction === "owning" && targetRel.cardinality === "one" && targetRel.target().slug === collection.slug);
8558
- if (correspondingRelation && correspondingRelation.localKey) {
8559
- const sourceIdField = getPrimaryKeyName(collection);
8560
- tableRelations.push(` "${relationKey}": one(${targetTableVar}, {
8561
- fields: [${tableVarName}.${sourceIdField}],
8562
- references: [${targetTableVar}.${correspondingRelation.localKey}],
8563
7846
  relationName: "${drizzleRelationName}"
8564
7847
  })`);
8565
- }
8566
- } catch (e) {
8567
- console.warn(`Could not resolve inverse one-to-one relation '${relationKey}':`, e);
8568
- }
8569
7848
  }
8570
7849
  } else if (rel.cardinality === "many") {
8571
7850
  if (rel.direction === "inverse" && rel.foreignKeyOnTarget) {
@@ -8593,6 +7872,32 @@ const generateSchema = async (collections, stripPolicies = false) => {
8593
7872
  console.warn(`Could not generate relation ${relationKey} for ${collection.name}:`, e);
8594
7873
  }
8595
7874
  }
7875
+ for (const otherCollection of collections) {
7876
+ if (otherCollection.slug === collection.slug) continue;
7877
+ const otherRelations = resolveCollectionRelations(otherCollection);
7878
+ for (const [otherKey, otherRel] of Object.entries(otherRelations)) {
7879
+ if (otherRel.direction === "inverse" && otherRel.foreignKeyOnTarget) {
7880
+ try {
7881
+ const otherTarget = otherRel.target();
7882
+ if (otherTarget.slug === collection.slug) {
7883
+ const drizzleRelationName = computeSharedRelationName(otherRel, otherCollection, collections);
7884
+ const deduplicationKey = `${drizzleRelationName}::owning`;
7885
+ if (!emittedRelationNames.has(deduplicationKey)) {
7886
+ const otherTableVar = getTableVarName(getTableName(otherCollection));
7887
+ const synthKey = `_synth_${otherTableVar}_${otherRel.foreignKeyOnTarget}`;
7888
+ tableRelations.push(` "${synthKey}": one(${otherTableVar}, {
7889
+ fields: [${tableVarName}.${otherRel.foreignKeyOnTarget}],
7890
+ references: [${otherTableVar}.${getPrimaryKeyName(otherCollection)}],
7891
+ relationName: "${drizzleRelationName}"
7892
+ })`);
7893
+ emittedRelationNames.add(deduplicationKey);
7894
+ }
7895
+ }
7896
+ } catch (e) {
7897
+ }
7898
+ }
7899
+ }
7900
+ }
8596
7901
  }
8597
7902
  if (tableRelations.length > 0) {
8598
7903
  const relVarName = `${tableVarName}Relations`;
@@ -10371,11 +9676,11 @@ class UserService {
10371
9676
  return user;
10372
9677
  }
10373
9678
  async getUserById(id) {
10374
- const [user] = await this.db.select().from(users).where(eq$3(users.id, id));
9679
+ const [user] = await this.db.select().from(users).where(eq(users.id, id));
10375
9680
  return user || null;
10376
9681
  }
10377
9682
  async getUserByEmail(email) {
10378
- const [user] = await this.db.select().from(users).where(eq$3(users.email, email.toLowerCase()));
9683
+ const [user] = await this.db.select().from(users).where(eq(users.email, email.toLowerCase()));
10379
9684
  return user || null;
10380
9685
  }
10381
9686
  async getUserByIdentity(provider, providerId) {
@@ -10431,11 +9736,11 @@ class UserService {
10431
9736
  const [user] = await this.db.update(users).set({
10432
9737
  ...data,
10433
9738
  updatedAt: /* @__PURE__ */ new Date()
10434
- }).where(eq$3(users.id, id)).returning();
9739
+ }).where(eq(users.id, id)).returning();
10435
9740
  return user || null;
10436
9741
  }
10437
9742
  async deleteUser(id) {
10438
- await this.db.delete(users).where(eq$3(users.id, id));
9743
+ await this.db.delete(users).where(eq(users.id, id));
10439
9744
  }
10440
9745
  async listUsers() {
10441
9746
  return this.db.select().from(users);
@@ -10504,7 +9809,7 @@ class UserService {
10504
9809
  await this.db.update(users).set({
10505
9810
  passwordHash,
10506
9811
  updatedAt: /* @__PURE__ */ new Date()
10507
- }).where(eq$3(users.id, id));
9812
+ }).where(eq(users.id, id));
10508
9813
  }
10509
9814
  /**
10510
9815
  * Set email verification status
@@ -10514,7 +9819,7 @@ class UserService {
10514
9819
  emailVerified: verified,
10515
9820
  emailVerificationToken: null,
10516
9821
  updatedAt: /* @__PURE__ */ new Date()
10517
- }).where(eq$3(users.id, id));
9822
+ }).where(eq(users.id, id));
10518
9823
  }
10519
9824
  /**
10520
9825
  * Set email verification token
@@ -10524,13 +9829,13 @@ class UserService {
10524
9829
  emailVerificationToken: token,
10525
9830
  emailVerificationSentAt: token ? /* @__PURE__ */ new Date() : null,
10526
9831
  updatedAt: /* @__PURE__ */ new Date()
10527
- }).where(eq$3(users.id, id));
9832
+ }).where(eq(users.id, id));
10528
9833
  }
10529
9834
  /**
10530
9835
  * Find user by email verification token
10531
9836
  */
10532
9837
  async getUserByVerificationToken(token) {
10533
- const [user] = await this.db.select().from(users).where(eq$3(users.emailVerificationToken, token));
9838
+ const [user] = await this.db.select().from(users).where(eq(users.emailVerificationToken, token));
10534
9839
  return user || null;
10535
9840
  }
10536
9841
  /**
@@ -10703,14 +10008,14 @@ class RefreshTokenService {
10703
10008
  createdAt: refreshTokens.createdAt,
10704
10009
  userAgent: refreshTokens.userAgent,
10705
10010
  ipAddress: refreshTokens.ipAddress
10706
- }).from(refreshTokens).where(eq$3(refreshTokens.tokenHash, tokenHash));
10011
+ }).from(refreshTokens).where(eq(refreshTokens.tokenHash, tokenHash));
10707
10012
  return token || null;
10708
10013
  }
10709
10014
  async deleteByHash(tokenHash) {
10710
- await this.db.delete(refreshTokens).where(eq$3(refreshTokens.tokenHash, tokenHash));
10015
+ await this.db.delete(refreshTokens).where(eq(refreshTokens.tokenHash, tokenHash));
10711
10016
  }
10712
10017
  async deleteAllForUser(userId) {
10713
- await this.db.delete(refreshTokens).where(eq$3(refreshTokens.userId, userId));
10018
+ await this.db.delete(refreshTokens).where(eq(refreshTokens.userId, userId));
10714
10019
  }
10715
10020
  async listForUser(userId) {
10716
10021
  const tokens = await this.db.select({
@@ -10721,7 +10026,7 @@ class RefreshTokenService {
10721
10026
  createdAt: refreshTokens.createdAt,
10722
10027
  userAgent: refreshTokens.userAgent,
10723
10028
  ipAddress: refreshTokens.ipAddress
10724
- }).from(refreshTokens).where(eq$3(refreshTokens.userId, userId)).orderBy(refreshTokens.createdAt);
10029
+ }).from(refreshTokens).where(eq(refreshTokens.userId, userId)).orderBy(refreshTokens.createdAt);
10725
10030
  return tokens;
10726
10031
  }
10727
10032
  async deleteById(id, userId) {
@@ -10753,7 +10058,7 @@ class PasswordResetTokenService {
10753
10058
  const [token] = await this.db.select({
10754
10059
  userId: passwordResetTokens.userId,
10755
10060
  expiresAt: passwordResetTokens.expiresAt
10756
- }).from(passwordResetTokens).where(eq$3(passwordResetTokens.tokenHash, tokenHash));
10061
+ }).from(passwordResetTokens).where(eq(passwordResetTokens.tokenHash, tokenHash));
10757
10062
  if (!token) return null;
10758
10063
  const result = await this.db.execute(sql`
10759
10064
  SELECT user_id, expires_at
@@ -10775,13 +10080,13 @@ class PasswordResetTokenService {
10775
10080
  async markAsUsed(tokenHash) {
10776
10081
  await this.db.update(passwordResetTokens).set({
10777
10082
  usedAt: /* @__PURE__ */ new Date()
10778
- }).where(eq$3(passwordResetTokens.tokenHash, tokenHash));
10083
+ }).where(eq(passwordResetTokens.tokenHash, tokenHash));
10779
10084
  }
10780
10085
  /**
10781
10086
  * Delete all tokens for a user
10782
10087
  */
10783
10088
  async deleteAllForUser(userId) {
10784
- await this.db.delete(passwordResetTokens).where(eq$3(passwordResetTokens.userId, userId));
10089
+ await this.db.delete(passwordResetTokens).where(eq(passwordResetTokens.userId, userId));
10785
10090
  }
10786
10091
  /**
10787
10092
  * Clean up expired tokens