@rebasepro/server-postgresql 0.0.1-canary.ca2cb6e → 0.0.1-canary.cbdd980

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 (63) hide show
  1. package/dist/index.es.js +550 -1256
  2. package/dist/index.es.js.map +1 -1
  3. package/dist/index.umd.js +481 -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 +117 -0
  8. package/dist/server-postgresql/src/schema/introspect-db.d.ts +1 -0
  9. package/dist/server-postgresql/src/services/EntityPersistService.d.ts +9 -0
  10. package/dist/types/src/controllers/auth.d.ts +8 -2
  11. package/dist/types/src/controllers/client.d.ts +13 -0
  12. package/dist/types/src/controllers/collection_registry.d.ts +2 -1
  13. package/dist/types/src/controllers/data_driver.d.ts +36 -1
  14. package/dist/types/src/controllers/navigation.d.ts +18 -6
  15. package/dist/types/src/controllers/registry.d.ts +9 -1
  16. package/dist/types/src/controllers/side_entity_controller.d.ts +7 -0
  17. package/dist/types/src/rebase_context.d.ts +17 -0
  18. package/dist/types/src/types/backend_hooks.d.ts +187 -0
  19. package/dist/types/src/types/collections.d.ts +31 -11
  20. package/dist/types/src/types/component_ref.d.ts +47 -0
  21. package/dist/types/src/types/cron.d.ts +1 -1
  22. package/dist/types/src/types/entity_views.d.ts +6 -7
  23. package/dist/types/src/types/formex.d.ts +40 -0
  24. package/dist/types/src/types/index.d.ts +3 -0
  25. package/dist/types/src/types/plugins.d.ts +6 -3
  26. package/dist/types/src/types/properties.d.ts +72 -88
  27. package/dist/types/src/types/slots.d.ts +20 -10
  28. package/dist/types/src/types/translations.d.ts +6 -0
  29. package/package.json +6 -5
  30. package/src/PostgresBackendDriver.ts +32 -6
  31. package/src/cli.ts +68 -2
  32. package/src/data-transformer.ts +84 -1
  33. package/src/schema/doctor.ts +14 -2
  34. package/src/schema/generate-drizzle-schema-logic.ts +59 -30
  35. package/src/schema/introspect-db-inference.ts +238 -0
  36. package/src/schema/introspect-db-logic.ts +896 -0
  37. package/src/schema/introspect-db.ts +254 -0
  38. package/src/services/EntityFetchService.ts +16 -0
  39. package/src/services/EntityPersistService.ts +95 -13
  40. package/test/generate-drizzle-schema.test.ts +342 -0
  41. package/test/introspect-db-generation.test.ts +458 -0
  42. package/test/introspect-db-utils.test.ts +392 -0
  43. package/test/property-ordering.test.ts +395 -0
  44. package/test/relations.test.ts +4 -4
  45. package/test/unmapped-tables-safety.test.ts +345 -0
  46. package/jest-all.log +0 -3128
  47. package/jest.log +0 -49
  48. package/scratch.ts +0 -41
  49. package/test-drizzle-bug.ts +0 -18
  50. package/test-drizzle-out/0000_cultured_freak.sql +0 -7
  51. package/test-drizzle-out/0001_tiresome_professor_monster.sql +0 -1
  52. package/test-drizzle-out/meta/0000_snapshot.json +0 -55
  53. package/test-drizzle-out/meta/0001_snapshot.json +0 -63
  54. package/test-drizzle-out/meta/_journal.json +0 -20
  55. package/test-drizzle-prompt.sh +0 -2
  56. package/test-policy-prompt.sh +0 -3
  57. package/test-programmatic.ts +0 -30
  58. package/test-programmatic2.ts +0 -59
  59. package/test-schema-no-policies.ts +0 -12
  60. package/test_drizzle_mock.js +0 -3
  61. package/test_find_changed.mjs +0 -32
  62. package/test_hash.js +0 -14
  63. 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,
@@ -1350,7 +1438,7 @@ function findRelation(resolvedRelations, key) {
1350
1438
  }
1351
1439
  var logic = { exports: {} };
1352
1440
  (function(module, exports$1) {
1353
- (function(root2, factory) {
1441
+ (function(root, factory) {
1354
1442
  {
1355
1443
  module.exports = factory();
1356
1444
  }
@@ -1717,8 +1805,8 @@ var logic = { exports: {} };
1717
1805
  return jsonLogic;
1718
1806
  });
1719
1807
  })(logic);
1720
- var getOwnPropertyNames = Object.getOwnPropertyNames, getOwnPropertySymbols = Object.getOwnPropertySymbols;
1721
- var hasOwnProperty$a = Object.prototype.hasOwnProperty;
1808
+ const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
1809
+ const { hasOwnProperty } = Object.prototype;
1722
1810
  function combineComparators(comparatorA, comparatorB) {
1723
1811
  return function isEqual(a, b, state) {
1724
1812
  return comparatorA(a, b, state) && comparatorB(a, b, state);
@@ -1729,38 +1817,45 @@ function createIsCircular(areItemsEqual) {
1729
1817
  if (!a || !b || typeof a !== "object" || typeof b !== "object") {
1730
1818
  return areItemsEqual(a, b, state);
1731
1819
  }
1732
- var cache = state.cache;
1733
- var cachedA = cache.get(a);
1734
- var cachedB = cache.get(b);
1820
+ const { cache } = state;
1821
+ const cachedA = cache.get(a);
1822
+ const cachedB = cache.get(b);
1735
1823
  if (cachedA && cachedB) {
1736
1824
  return cachedA === b && cachedB === a;
1737
1825
  }
1738
1826
  cache.set(a, b);
1739
1827
  cache.set(b, a);
1740
- var result = areItemsEqual(a, b, state);
1828
+ const result = areItemsEqual(a, b, state);
1741
1829
  cache.delete(a);
1742
1830
  cache.delete(b);
1743
1831
  return result;
1744
1832
  };
1745
1833
  }
1746
- function getShortTag(value) {
1747
- return value != null ? value[Symbol.toStringTag] : void 0;
1748
- }
1749
1834
  function getStrictProperties(object) {
1750
1835
  return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
1751
1836
  }
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;
1837
+ const hasOwn = (
1838
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1839
+ Object.hasOwn || ((object, property) => hasOwnProperty.call(object, property))
1840
+ );
1841
+ const PREACT_VNODE = "__v";
1842
+ const PREACT_OWNER = "__o";
1843
+ const REACT_OWNER = "_owner";
1844
+ const { getOwnPropertyDescriptor, keys } = Object;
1845
+ const sameValueEqual = (
1846
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1847
+ Object.is || function sameValueEqual2(a, b) {
1848
+ return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
1849
+ }
1850
+ );
1851
+ function strictEqual(a, b) {
1852
+ return a === b;
1853
+ }
1854
+ function areArrayBuffersEqual(a, b) {
1855
+ return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a), new Uint8Array(b));
1757
1856
  }
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
1857
  function areArraysEqual(a, b, state) {
1763
- var index = a.length;
1858
+ let index = a.length;
1764
1859
  if (b.length !== index) {
1765
1860
  return false;
1766
1861
  }
@@ -1771,35 +1866,35 @@ function areArraysEqual(a, b, state) {
1771
1866
  }
1772
1867
  return true;
1773
1868
  }
1869
+ function areDataViewsEqual(a, b) {
1870
+ return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a.buffer, a.byteOffset, a.byteLength), new Uint8Array(b.buffer, b.byteOffset, b.byteLength));
1871
+ }
1774
1872
  function areDatesEqual(a, b) {
1775
- return sameValueZeroEqual(a.getTime(), b.getTime());
1873
+ return sameValueEqual(a.getTime(), b.getTime());
1776
1874
  }
1777
1875
  function areErrorsEqual(a, b) {
1778
1876
  return a.name === b.name && a.message === b.message && a.cause === b.cause && a.stack === b.stack;
1779
1877
  }
1780
- function areFunctionsEqual(a, b) {
1781
- return a === b;
1782
- }
1783
1878
  function areMapsEqual(a, b, state) {
1784
- var size = a.size;
1879
+ const size = a.size;
1785
1880
  if (size !== b.size) {
1786
1881
  return false;
1787
1882
  }
1788
1883
  if (!size) {
1789
1884
  return true;
1790
1885
  }
1791
- var matchedIndices = new Array(size);
1792
- var aIterable = a.entries();
1793
- var aResult;
1794
- var bResult;
1795
- var index = 0;
1886
+ const matchedIndices = new Array(size);
1887
+ const aIterable = a.entries();
1888
+ let aResult;
1889
+ let bResult;
1890
+ let index = 0;
1796
1891
  while (aResult = aIterable.next()) {
1797
1892
  if (aResult.done) {
1798
1893
  break;
1799
1894
  }
1800
- var bIterable = b.entries();
1801
- var hasMatch = false;
1802
- var matchIndex = 0;
1895
+ const bIterable = b.entries();
1896
+ let hasMatch = false;
1897
+ let matchIndex = 0;
1803
1898
  while (bResult = bIterable.next()) {
1804
1899
  if (bResult.done) {
1805
1900
  break;
@@ -1808,8 +1903,8 @@ function areMapsEqual(a, b, state) {
1808
1903
  matchIndex++;
1809
1904
  continue;
1810
1905
  }
1811
- var aEntry = aResult.value;
1812
- var bEntry = bResult.value;
1906
+ const aEntry = aResult.value;
1907
+ const bEntry = bResult.value;
1813
1908
  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
1909
  hasMatch = matchedIndices[matchIndex] = true;
1815
1910
  break;
@@ -1823,11 +1918,10 @@ function areMapsEqual(a, b, state) {
1823
1918
  }
1824
1919
  return true;
1825
1920
  }
1826
- var areNumbersEqual = sameValueZeroEqual;
1827
1921
  function areObjectsEqual(a, b, state) {
1828
- var properties = keys$4(a);
1829
- var index = properties.length;
1830
- if (keys$4(b).length !== index) {
1922
+ const properties = keys(a);
1923
+ let index = properties.length;
1924
+ if (keys(b).length !== index) {
1831
1925
  return false;
1832
1926
  }
1833
1927
  while (index-- > 0) {
@@ -1838,14 +1932,14 @@ function areObjectsEqual(a, b, state) {
1838
1932
  return true;
1839
1933
  }
1840
1934
  function areObjectsEqualStrict(a, b, state) {
1841
- var properties = getStrictProperties(a);
1842
- var index = properties.length;
1935
+ const properties = getStrictProperties(a);
1936
+ let index = properties.length;
1843
1937
  if (getStrictProperties(b).length !== index) {
1844
1938
  return false;
1845
1939
  }
1846
- var property;
1847
- var descriptorA;
1848
- var descriptorB;
1940
+ let property;
1941
+ let descriptorA;
1942
+ let descriptorB;
1849
1943
  while (index-- > 0) {
1850
1944
  property = properties[index];
1851
1945
  if (!isPropertyEqual(a, b, state, property)) {
@@ -1860,30 +1954,30 @@ function areObjectsEqualStrict(a, b, state) {
1860
1954
  return true;
1861
1955
  }
1862
1956
  function arePrimitiveWrappersEqual(a, b) {
1863
- return sameValueZeroEqual(a.valueOf(), b.valueOf());
1957
+ return sameValueEqual(a.valueOf(), b.valueOf());
1864
1958
  }
1865
1959
  function areRegExpsEqual(a, b) {
1866
1960
  return a.source === b.source && a.flags === b.flags;
1867
1961
  }
1868
1962
  function areSetsEqual(a, b, state) {
1869
- var size = a.size;
1963
+ const size = a.size;
1870
1964
  if (size !== b.size) {
1871
1965
  return false;
1872
1966
  }
1873
1967
  if (!size) {
1874
1968
  return true;
1875
1969
  }
1876
- var matchedIndices = new Array(size);
1877
- var aIterable = a.values();
1878
- var aResult;
1879
- var bResult;
1970
+ const matchedIndices = new Array(size);
1971
+ const aIterable = a.values();
1972
+ let aResult;
1973
+ let bResult;
1880
1974
  while (aResult = aIterable.next()) {
1881
1975
  if (aResult.done) {
1882
1976
  break;
1883
1977
  }
1884
- var bIterable = b.values();
1885
- var hasMatch = false;
1886
- var matchIndex = 0;
1978
+ const bIterable = b.values();
1979
+ let hasMatch = false;
1980
+ let matchIndex = 0;
1887
1981
  while (bResult = bIterable.next()) {
1888
1982
  if (bResult.done) {
1889
1983
  break;
@@ -1901,8 +1995,8 @@ function areSetsEqual(a, b, state) {
1901
1995
  return true;
1902
1996
  }
1903
1997
  function areTypedArraysEqual(a, b) {
1904
- var index = a.length;
1905
- if (b.length !== index) {
1998
+ let index = a.byteLength;
1999
+ if (b.byteLength !== index || a.byteOffset !== b.byteOffset) {
1906
2000
  return false;
1907
2001
  }
1908
2002
  while (index-- > 0) {
@@ -1921,23 +2015,10 @@ function isPropertyEqual(a, b, state, property) {
1921
2015
  }
1922
2016
  return hasOwn(b, property) && state.equals(a[property], b[property], property, property, a, b, state);
1923
2017
  }
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;
2018
+ const toString = Object.prototype.toString;
2019
+ function createEqualityComparator(config) {
2020
+ const supportedComparatorMap = createSupportedComparatorMap(config);
2021
+ const { areArraysEqual: areArraysEqual2, areDatesEqual: areDatesEqual2, areFunctionsEqual, areMapsEqual: areMapsEqual2, areNumbersEqual, areObjectsEqual: areObjectsEqual2, areRegExpsEqual: areRegExpsEqual2, areSetsEqual: areSetsEqual2, getUnsupportedCustomComparator } = config;
1941
2022
  return function comparator(a, b, state) {
1942
2023
  if (a === b) {
1943
2024
  return true;
@@ -1945,32 +2026,29 @@ function createEqualityComparator(_a) {
1945
2026
  if (a == null || b == null) {
1946
2027
  return false;
1947
2028
  }
1948
- var type = typeof a;
2029
+ const type = typeof a;
1949
2030
  if (type !== typeof b) {
1950
2031
  return false;
1951
2032
  }
1952
2033
  if (type !== "object") {
1953
- if (type === "number") {
1954
- return areNumbersEqual2(a, b, state);
2034
+ if (type === "number" || type === "bigint") {
2035
+ return areNumbersEqual(a, b, state);
1955
2036
  }
1956
2037
  if (type === "function") {
1957
- return areFunctionsEqual2(a, b, state);
2038
+ return areFunctionsEqual(a, b, state);
1958
2039
  }
1959
2040
  return false;
1960
2041
  }
1961
- var constructor = a.constructor;
2042
+ const constructor = a.constructor;
1962
2043
  if (constructor !== b.constructor) {
1963
2044
  return false;
1964
2045
  }
1965
2046
  if (constructor === Object) {
1966
2047
  return areObjectsEqual2(a, b, state);
1967
2048
  }
1968
- if (isArray$4(a)) {
2049
+ if (constructor === Array) {
1969
2050
  return areArraysEqual2(a, b, state);
1970
2051
  }
1971
- if (isTypedArray$2 != null && isTypedArray$2(a)) {
1972
- return areTypedArraysEqual2(a, b, state);
1973
- }
1974
2052
  if (constructor === Date) {
1975
2053
  return areDatesEqual2(a, b, state);
1976
2054
  }
@@ -1983,79 +2061,55 @@ function createEqualityComparator(_a) {
1983
2061
  if (constructor === Set) {
1984
2062
  return areSetsEqual2(a, b, state);
1985
2063
  }
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);
2064
+ if (constructor === Promise) {
2065
+ return false;
2007
2066
  }
2008
- if (tag === ARGUMENTS_TAG) {
2009
- return areObjectsEqual2(a, b, state);
2067
+ if (Array.isArray(a)) {
2068
+ return areArraysEqual2(a, b, state);
2010
2069
  }
2011
- if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {
2012
- return arePrimitiveWrappersEqual2(a, b, state);
2070
+ const tag = toString.call(a);
2071
+ const supportedComparator = supportedComparatorMap[tag];
2072
+ if (supportedComparator) {
2073
+ return supportedComparator(a, b, state);
2013
2074
  }
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
- }
2075
+ const unsupportedCustomComparator = getUnsupportedCustomComparator && getUnsupportedCustomComparator(a, b, state, tag);
2076
+ if (unsupportedCustomComparator) {
2077
+ return unsupportedCustomComparator(a, b, state);
2025
2078
  }
2026
2079
  return false;
2027
2080
  };
2028
2081
  }
2029
- function createEqualityComparatorConfig(_a) {
2030
- var circular = _a.circular, createCustomConfig = _a.createCustomConfig, strict = _a.strict;
2031
- var config = {
2082
+ function createEqualityComparatorConfig({ circular, createCustomConfig, strict }) {
2083
+ let config = {
2084
+ areArrayBuffersEqual,
2032
2085
  areArraysEqual: strict ? areObjectsEqualStrict : areArraysEqual,
2086
+ areDataViewsEqual,
2033
2087
  areDatesEqual,
2034
2088
  areErrorsEqual,
2035
- areFunctionsEqual,
2089
+ areFunctionsEqual: strictEqual,
2036
2090
  areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,
2037
- areNumbersEqual,
2091
+ areNumbersEqual: sameValueEqual,
2038
2092
  areObjectsEqual: strict ? areObjectsEqualStrict : areObjectsEqual,
2039
2093
  arePrimitiveWrappersEqual,
2040
2094
  areRegExpsEqual,
2041
2095
  areSetsEqual: strict ? combineComparators(areSetsEqual, areObjectsEqualStrict) : areSetsEqual,
2042
- areTypedArraysEqual: strict ? areObjectsEqualStrict : areTypedArraysEqual,
2096
+ areTypedArraysEqual: strict ? combineComparators(areTypedArraysEqual, areObjectsEqualStrict) : areTypedArraysEqual,
2043
2097
  areUrlsEqual,
2044
- unknownTagComparators: void 0
2098
+ getUnsupportedCustomComparator: void 0
2045
2099
  };
2046
2100
  if (createCustomConfig) {
2047
- config = assign({}, config, createCustomConfig(config));
2101
+ config = Object.assign({}, config, createCustomConfig(config));
2048
2102
  }
2049
2103
  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
2104
+ const areArraysEqual2 = createIsCircular(config.areArraysEqual);
2105
+ const areMapsEqual2 = createIsCircular(config.areMapsEqual);
2106
+ const areObjectsEqual2 = createIsCircular(config.areObjectsEqual);
2107
+ const areSetsEqual2 = createIsCircular(config.areSetsEqual);
2108
+ config = Object.assign({}, config, {
2109
+ areArraysEqual: areArraysEqual2,
2110
+ areMapsEqual: areMapsEqual2,
2111
+ areObjectsEqual: areObjectsEqual2,
2112
+ areSetsEqual: areSetsEqual2
2059
2113
  });
2060
2114
  }
2061
2115
  return config;
@@ -2065,11 +2119,10 @@ function createInternalEqualityComparator(compare) {
2065
2119
  return compare(a, b, state);
2066
2120
  };
2067
2121
  }
2068
- function createIsEqual(_a) {
2069
- var circular = _a.circular, comparator = _a.comparator, createState = _a.createState, equals = _a.equals, strict = _a.strict;
2122
+ function createIsEqual({ circular, comparator, createState, equals, strict }) {
2070
2123
  if (createState) {
2071
2124
  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;
2125
+ const { cache = circular ? /* @__PURE__ */ new WeakMap() : void 0, meta } = createState();
2073
2126
  return comparator(a, b, {
2074
2127
  cache,
2075
2128
  equals,
@@ -2088,7 +2141,7 @@ function createIsEqual(_a) {
2088
2141
  });
2089
2142
  };
2090
2143
  }
2091
- var state = {
2144
+ const state = {
2092
2145
  cache: void 0,
2093
2146
  equals,
2094
2147
  meta: void 0,
@@ -2098,7 +2151,50 @@ function createIsEqual(_a) {
2098
2151
  return comparator(a, b, state);
2099
2152
  };
2100
2153
  }
2101
- var deepEqual = createCustomEqual();
2154
+ 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 }) {
2155
+ return {
2156
+ "[object Arguments]": areObjectsEqual2,
2157
+ "[object Array]": areArraysEqual2,
2158
+ "[object ArrayBuffer]": areArrayBuffersEqual2,
2159
+ "[object AsyncGeneratorFunction]": areFunctionsEqual,
2160
+ "[object BigInt]": areNumbersEqual,
2161
+ "[object BigInt64Array]": areTypedArraysEqual2,
2162
+ "[object BigUint64Array]": areTypedArraysEqual2,
2163
+ "[object Boolean]": arePrimitiveWrappersEqual2,
2164
+ "[object DataView]": areDataViewsEqual2,
2165
+ "[object Date]": areDatesEqual2,
2166
+ // If an error tag, it should be tested explicitly. Like RegExp, the properties are not
2167
+ // enumerable, and therefore will give false positives if tested like a standard object.
2168
+ "[object Error]": areErrorsEqual2,
2169
+ "[object Float16Array]": areTypedArraysEqual2,
2170
+ "[object Float32Array]": areTypedArraysEqual2,
2171
+ "[object Float64Array]": areTypedArraysEqual2,
2172
+ "[object Function]": areFunctionsEqual,
2173
+ "[object GeneratorFunction]": areFunctionsEqual,
2174
+ "[object Int8Array]": areTypedArraysEqual2,
2175
+ "[object Int16Array]": areTypedArraysEqual2,
2176
+ "[object Int32Array]": areTypedArraysEqual2,
2177
+ "[object Map]": areMapsEqual2,
2178
+ "[object Number]": arePrimitiveWrappersEqual2,
2179
+ "[object Object]": (a, b, state) => (
2180
+ // The exception for value comparison is custom `Promise`-like class instances. These should
2181
+ // be treated the same as standard `Promise` objects, which means strict equality, and if
2182
+ // it reaches this point then that strict equality comparison has already failed.
2183
+ typeof a.then !== "function" && typeof b.then !== "function" && areObjectsEqual2(a, b, state)
2184
+ ),
2185
+ // For RegExp, the properties are not enumerable, and therefore will give false positives if
2186
+ // tested like a standard object.
2187
+ "[object RegExp]": areRegExpsEqual2,
2188
+ "[object Set]": areSetsEqual2,
2189
+ "[object String]": arePrimitiveWrappersEqual2,
2190
+ "[object URL]": areUrlsEqual2,
2191
+ "[object Uint8Array]": areTypedArraysEqual2,
2192
+ "[object Uint8ClampedArray]": areTypedArraysEqual2,
2193
+ "[object Uint16Array]": areTypedArraysEqual2,
2194
+ "[object Uint32Array]": areTypedArraysEqual2
2195
+ };
2196
+ }
2197
+ const deepEqual = createCustomEqual();
2102
2198
  createCustomEqual({ strict: true });
2103
2199
  createCustomEqual({ circular: true });
2104
2200
  createCustomEqual({
@@ -2106,1015 +2202,28 @@ createCustomEqual({
2106
2202
  strict: true
2107
2203
  });
2108
2204
  createCustomEqual({
2109
- createInternalComparator: function() {
2110
- return sameValueZeroEqual;
2111
- }
2205
+ createInternalComparator: () => sameValueEqual
2112
2206
  });
2113
2207
  createCustomEqual({
2114
2208
  strict: true,
2115
- createInternalComparator: function() {
2116
- return sameValueZeroEqual;
2117
- }
2209
+ createInternalComparator: () => sameValueEqual
2118
2210
  });
2119
2211
  createCustomEqual({
2120
2212
  circular: true,
2121
- createInternalComparator: function() {
2122
- return sameValueZeroEqual;
2123
- }
2213
+ createInternalComparator: () => sameValueEqual
2124
2214
  });
2125
2215
  createCustomEqual({
2126
2216
  circular: true,
2127
- createInternalComparator: function() {
2128
- return sameValueZeroEqual;
2129
- },
2217
+ createInternalComparator: () => sameValueEqual,
2130
2218
  strict: true
2131
2219
  });
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);
2220
+ function createCustomEqual(options = {}) {
2221
+ const { circular = false, createInternalComparator: createCustomInternalComparator, createState, strict = false } = options;
2222
+ const config = createEqualityComparatorConfig(options);
2223
+ const comparator = createEqualityComparator(config);
2224
+ const equals = createCustomInternalComparator ? createCustomInternalComparator(comparator) : createInternalEqualityComparator(comparator);
2140
2225
  return createIsEqual({ circular, comparator, createState, equals, strict });
2141
2226
  }
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
2227
  class CollectionRegistry {
3119
2228
  // Normalized runtime layer (used by Data Grid / UI)
3120
2229
  collectionsByTableName = /* @__PURE__ */ new Map();
@@ -3162,7 +2271,7 @@ class CollectionRegistry {
3162
2271
  ...c
3163
2272
  }));
3164
2273
  normalizedCollections.forEach((c, index) => {
3165
- const raw = cloneDeep$1(collections[index]);
2274
+ const raw = deepClone(collections[index]);
3166
2275
  this.rootCollections.push(c);
3167
2276
  this.rawRootCollections.push(raw);
3168
2277
  const normalized = this.normalizeCollection(c);
@@ -3182,7 +2291,7 @@ class CollectionRegistry {
3182
2291
  if (!subCollection) return;
3183
2292
  this._registerRecursively(this.normalizeCollection({
3184
2293
  ...subCollection
3185
- }), cloneDeep$1(subCollection));
2294
+ }), deepClone(subCollection));
3186
2295
  });
3187
2296
  }
3188
2297
  });
@@ -3190,7 +2299,7 @@ class CollectionRegistry {
3190
2299
  return true;
3191
2300
  }
3192
2301
  register(collection, rawCollection) {
3193
- const raw = rawCollection ? cloneDeep$1(rawCollection) : cloneDeep$1(collection);
2302
+ const raw = rawCollection ? deepClone(rawCollection) : deepClone(collection);
3194
2303
  this.rootCollections.push(collection);
3195
2304
  this.rawRootCollections.push(raw);
3196
2305
  this._registerRecursively(collection, raw);
@@ -3214,7 +2323,7 @@ class CollectionRegistry {
3214
2323
  if (!subCollection) return;
3215
2324
  this._registerRecursively(this.normalizeCollection({
3216
2325
  ...subCollection
3217
- }), cloneDeep$1(subCollection));
2326
+ }), deepClone(subCollection));
3218
2327
  });
3219
2328
  }
3220
2329
  }
@@ -3386,7 +2495,10 @@ class CollectionRegistry {
3386
2495
  if (!relation) {
3387
2496
  throw new Error(`Relation '${relationKey}' not found in collection '${currentCollection.slug}'`);
3388
2497
  }
3389
- currentCollection = relation.target();
2498
+ const target = relation.target();
2499
+ const targetRelationKey = relation.relationName || target.slug;
2500
+ const targetSlug = relation.overrides?.slug ?? targetRelationKey;
2501
+ currentCollection = this.get(targetSlug) || this.normalizeCollection(target);
3390
2502
  if (i + 1 < pathSegments.length) ;
3391
2503
  }
3392
2504
  return currentCollection;
@@ -3435,7 +2547,7 @@ class CollectionRegistry {
3435
2547
  if (!subcollection) {
3436
2548
  throw new Error(`Subcollection '${subcollectionSlug}' not found in ${currentCollection.slug}`);
3437
2549
  }
3438
- currentCollection = subcollection;
2550
+ currentCollection = this.get(subcollection.slug) || this.normalizeCollection(subcollection);
3439
2551
  collections.push(currentCollection);
3440
2552
  }
3441
2553
  }
@@ -3672,7 +2784,7 @@ class DrizzleConditionBuilder {
3672
2784
  static buildSingleFilterCondition(column, op, value) {
3673
2785
  switch (op) {
3674
2786
  case "==":
3675
- return eq$3(column, value);
2787
+ return eq(column, value);
3676
2788
  case "!=":
3677
2789
  return sql`${column} != ${value}`;
3678
2790
  case ">":
@@ -3802,7 +2914,7 @@ class DrizzleConditionBuilder {
3802
2914
  throw new Error(`Join path did not result in connecting to parent table. Current: ${currentTableName}, Parent: ${parentTableName}`);
3803
2915
  }
3804
2916
  }
3805
- const finalCondition = Array.isArray(parentEntityId) ? inArray(parentIdColumn, parentEntityId) : eq$3(parentIdColumn, parentEntityId);
2917
+ const finalCondition = Array.isArray(parentEntityId) ? inArray(parentIdColumn, parentEntityId) : eq(parentIdColumn, parentEntityId);
3806
2918
  return {
3807
2919
  joins,
3808
2920
  finalCondition
@@ -3828,7 +2940,7 @@ class DrizzleConditionBuilder {
3828
2940
  throw new Error(`Join columns not found: ${fromTableName}.${fromColName} = ${toTableName}.${toColName}`);
3829
2941
  }
3830
2942
  joinTable = fromTable;
3831
- condition = eq$3(left, right);
2943
+ condition = eq(left, right);
3832
2944
  } else if (currentTable === fromTable) {
3833
2945
  const left = toTable[toColName];
3834
2946
  const right = currentTable[fromColName];
@@ -3842,7 +2954,7 @@ class DrizzleConditionBuilder {
3842
2954
  throw new Error(`Join columns not found: ${toTableName}.${toColName} = ${fromTableName}.${fromColName}`);
3843
2955
  }
3844
2956
  joinTable = toTable;
3845
- condition = eq$3(left, right);
2957
+ condition = eq(left, right);
3846
2958
  } else {
3847
2959
  throw new Error(`Join step does not match current table. Current table does not match from: ${fromTableName} or to: ${toTableName}`);
3848
2960
  }
@@ -3873,19 +2985,19 @@ class DrizzleConditionBuilder {
3873
2985
  if (currentTable === targetTable) {
3874
2986
  return {
3875
2987
  joinTable: targetTable,
3876
- condition: eq$3(targetTableIdCol, junctionTargetCol),
2988
+ condition: eq(targetTableIdCol, junctionTargetCol),
3877
2989
  additionalJoins: [{
3878
2990
  table: junctionTable,
3879
- condition: eq$3(currentTableIdCol, junctionSourceCol)
2991
+ condition: eq(currentTableIdCol, junctionSourceCol)
3880
2992
  }]
3881
2993
  };
3882
2994
  } else {
3883
2995
  return {
3884
2996
  joinTable: junctionTable,
3885
- condition: eq$3(currentTableIdCol, junctionSourceCol),
2997
+ condition: eq(currentTableIdCol, junctionSourceCol),
3886
2998
  additionalJoins: [{
3887
2999
  table: targetTable,
3888
- condition: eq$3(targetTableIdCol, junctionTargetCol)
3000
+ condition: eq(targetTableIdCol, junctionTargetCol)
3889
3001
  }]
3890
3002
  };
3891
3003
  }
@@ -3910,11 +3022,11 @@ class DrizzleConditionBuilder {
3910
3022
  if (!junctionTargetCol) {
3911
3023
  throw new Error(`Target column '${through.targetColumn}' not found in junction table '${through.table}'`);
3912
3024
  }
3913
- const condition = Array.isArray(parentEntityId) ? inArray(junctionSourceCol, parentEntityId) : eq$3(junctionSourceCol, parentEntityId);
3025
+ const condition = Array.isArray(parentEntityId) ? inArray(junctionSourceCol, parentEntityId) : eq(junctionSourceCol, parentEntityId);
3914
3026
  return {
3915
3027
  join: {
3916
3028
  table: junctionTable,
3917
- condition: eq$3(targetIdColumn, junctionTargetCol)
3029
+ condition: eq(targetIdColumn, junctionTargetCol)
3918
3030
  },
3919
3031
  condition
3920
3032
  };
@@ -3935,11 +3047,11 @@ class DrizzleConditionBuilder {
3935
3047
  if (!junctionTargetCol) {
3936
3048
  throw new Error(`Target column '${through.targetColumn}' not found in junction table '${through.table}'`);
3937
3049
  }
3938
- const condition = Array.isArray(parentEntityId) ? inArray(junctionSourceCol, parentEntityId) : eq$3(junctionSourceCol, parentEntityId);
3050
+ const condition = Array.isArray(parentEntityId) ? inArray(junctionSourceCol, parentEntityId) : eq(junctionSourceCol, parentEntityId);
3939
3051
  return {
3940
3052
  join: {
3941
3053
  table: junctionTable,
3942
- condition: eq$3(targetIdColumn, junctionTargetCol)
3054
+ condition: eq(targetIdColumn, junctionTargetCol)
3943
3055
  },
3944
3056
  condition
3945
3057
  };
@@ -3955,15 +3067,15 @@ class DrizzleConditionBuilder {
3955
3067
  if (!idCol) {
3956
3068
  throw new Error('No primary key or "id" column found in target table');
3957
3069
  }
3958
- return Array.isArray(parentEntityId) ? inArray(idCol, parentEntityId) : eq$3(idCol, parentEntityId);
3070
+ return Array.isArray(parentEntityId) ? inArray(idCol, parentEntityId) : eq(idCol, parentEntityId);
3959
3071
  }
3960
- return Array.isArray(parentEntityId) ? inArray(targetIdCol, parentEntityId) : eq$3(targetIdCol, parentEntityId);
3072
+ return Array.isArray(parentEntityId) ? inArray(targetIdCol, parentEntityId) : eq(targetIdCol, parentEntityId);
3961
3073
  } else if (relation.direction === "inverse" && relation.foreignKeyOnTarget) {
3962
3074
  const foreignKeyCol = targetTable[relation.foreignKeyOnTarget];
3963
3075
  if (!foreignKeyCol) {
3964
3076
  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
3077
  }
3966
- return Array.isArray(parentEntityId) ? inArray(foreignKeyCol, parentEntityId) : eq$3(foreignKeyCol, parentEntityId);
3078
+ return Array.isArray(parentEntityId) ? inArray(foreignKeyCol, parentEntityId) : eq(foreignKeyCol, parentEntityId);
3967
3079
  } else if (relation.direction === "inverse" && relation.cardinality === "many" && relation.inverseRelationName) {
3968
3080
  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
3081
  } else if (relation.direction === "inverse" && relation.cardinality === "one" && relation.inverseRelationName) {
@@ -3973,7 +3085,7 @@ class DrizzleConditionBuilder {
3973
3085
  throw new Error(`Auto-inferred foreign key column '${inferredForeignKeyName}' not found in target table for inverse relation '${relation.relationName}'. Please specify 'foreignKeyOnTarget' explicitly.`);
3974
3086
  }
3975
3087
  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);
3088
+ return Array.isArray(parentEntityId) ? inArray(foreignKeyCol, parentEntityId) : eq(foreignKeyCol, parentEntityId);
3977
3089
  } else {
3978
3090
  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
3091
  }
@@ -4014,7 +3126,7 @@ class DrizzleConditionBuilder {
4014
3126
  * Build a unique field check condition
4015
3127
  */
4016
3128
  static buildUniqueFieldCondition(fieldColumn, value, idColumn, excludeId) {
4017
- const conditions = [eq$3(fieldColumn, value)];
3129
+ const conditions = [eq(fieldColumn, value)];
4018
3130
  if (excludeId && idColumn) {
4019
3131
  conditions.push(sql`${idColumn} != ${excludeId}`);
4020
3132
  }
@@ -4089,7 +3201,7 @@ class DrizzleConditionBuilder {
4089
3201
  if (currentTable !== parentTable) {
4090
3202
  throw new Error("Join path did not result in connecting to parent table");
4091
3203
  }
4092
- const allConditions = [eq$3(parentIdColumn, parentEntityId)];
3204
+ const allConditions = [eq(parentIdColumn, parentEntityId)];
4093
3205
  if (additionalFilters) {
4094
3206
  allConditions.push(...additionalFilters);
4095
3207
  }
@@ -4111,11 +3223,11 @@ class DrizzleConditionBuilder {
4111
3223
  if (!junctionTargetCol) {
4112
3224
  throw new Error(`Target column '${through.targetColumn}' not found in junction table '${through.table}'`);
4113
3225
  }
4114
- const baseConditions = [eq$3(junctionSourceCol, parentEntityId)];
3226
+ const baseConditions = [eq(junctionSourceCol, parentEntityId)];
4115
3227
  if (additionalFilters && additionalFilters.length > 0) {
4116
3228
  baseConditions.push(...additionalFilters);
4117
3229
  }
4118
- return baseCountQuery.innerJoin(junctionTable, eq$3(targetIdColumn, junctionTargetCol)).where(and(...baseConditions));
3230
+ return baseCountQuery.innerJoin(junctionTable, eq(targetIdColumn, junctionTargetCol)).where(and(...baseConditions));
4119
3231
  }
4120
3232
  /**
4121
3233
  * Build inverse junction table conditions for count queries
@@ -4133,11 +3245,11 @@ class DrizzleConditionBuilder {
4133
3245
  if (!junctionTargetCol) {
4134
3246
  throw new Error(`Target column '${through.targetColumn}' not found in junction table '${through.table}'`);
4135
3247
  }
4136
- const baseConditions = [eq$3(junctionSourceCol, parentEntityId)];
3248
+ const baseConditions = [eq(junctionSourceCol, parentEntityId)];
4137
3249
  if (additionalFilters && additionalFilters.length > 0) {
4138
3250
  baseConditions.push(...additionalFilters);
4139
3251
  }
4140
- return baseCountQuery.innerJoin(junctionTable, eq$3(targetIdColumn, junctionTargetCol)).where(and(...baseConditions));
3252
+ return baseCountQuery.innerJoin(junctionTable, eq(targetIdColumn, junctionTargetCol)).where(and(...baseConditions));
4141
3253
  }
4142
3254
  /**
4143
3255
  * Helper method to extract table names from columns
@@ -4477,7 +3589,25 @@ function serializePropertyToServer(value, property) {
4477
3589
  return result;
4478
3590
  }
4479
3591
  return value;
3592
+ case "string":
3593
+ if (typeof value === "string") {
3594
+ if (value.startsWith("data:application/octet-stream;base64,")) {
3595
+ const base64Data = value.split(",")[1];
3596
+ if (base64Data) {
3597
+ return Buffer.from(base64Data, "base64");
3598
+ }
3599
+ }
3600
+ }
3601
+ return value;
4480
3602
  default:
3603
+ if (typeof value === "string") {
3604
+ if (value.startsWith("data:application/octet-stream;base64,")) {
3605
+ const base64Data = value.split(",")[1];
3606
+ if (base64Data) {
3607
+ return Buffer.from(base64Data, "base64");
3608
+ }
3609
+ }
3610
+ }
4481
3611
  return value;
4482
3612
  }
4483
3613
  }
@@ -4511,7 +3641,7 @@ async function parseDataFromServer(data, collection, db, registry) {
4511
3641
  if (targetTable && currentEntityId) {
4512
3642
  const foreignKeyColumn = targetTable[relation.foreignKeyOnTarget];
4513
3643
  if (foreignKeyColumn) {
4514
- const relatedEntities = await db.select().from(targetTable).where(eq$3(foreignKeyColumn, currentEntityId)).limit(relation.cardinality === "one" ? 1 : 100);
3644
+ const relatedEntities = await db.select().from(targetTable).where(eq(foreignKeyColumn, currentEntityId)).limit(relation.cardinality === "one" ? 1 : 100);
4515
3645
  if (relatedEntities.length > 0) {
4516
3646
  if (relation.cardinality === "one") {
4517
3647
  const targetPks = getPrimaryKeys(targetCollection, registry);
@@ -4558,12 +3688,12 @@ async function parseDataFromServer(data, collection, db, registry) {
4558
3688
  console.warn(`Join columns not found: ${fromColumn} -> ${toColumn}`);
4559
3689
  break;
4560
3690
  }
4561
- query = query.innerJoin(joinTable, eq$3(fromCol, toCol));
3691
+ query = query.innerJoin(joinTable, eq(fromCol, toCol));
4562
3692
  currentTable = joinTable;
4563
3693
  }
4564
3694
  if (pks.length === 1) {
4565
3695
  const sourceIdField = sourceTable[pks[0].fieldName];
4566
- query = query.where(eq$3(sourceIdField, currentEntityId));
3696
+ query = query.where(eq(sourceIdField, currentEntityId));
4567
3697
  } else {
4568
3698
  console.warn(`Join path resolution for composite primary keys is not yet fully supported: ${collection.slug}`);
4569
3699
  }
@@ -4571,7 +3701,7 @@ async function parseDataFromServer(data, collection, db, registry) {
4571
3701
  let combinedWhere;
4572
3702
  if (pks.length === 1) {
4573
3703
  const sourceIdField = sourceTable[pks[0].fieldName];
4574
- combinedWhere = DrizzleConditionBuilder.combineConditionsWithAnd([eq$3(sourceIdField, currentEntityId), ...additionalFilters].filter(Boolean));
3704
+ combinedWhere = DrizzleConditionBuilder.combineConditionsWithAnd([eq(sourceIdField, currentEntityId), ...additionalFilters].filter(Boolean));
4575
3705
  }
4576
3706
  const joinResults = await query.where(combinedWhere).limit(relation.cardinality === "one" ? 1 : 100);
4577
3707
  if (joinResults.length > 0) {
@@ -4603,6 +3733,37 @@ function parsePropertyFromServer(value, property, collection, propertyKey) {
4603
3733
  return value;
4604
3734
  }
4605
3735
  switch (property.type) {
3736
+ case "string": {
3737
+ if (typeof value === "string") return value;
3738
+ let isBuffer = false;
3739
+ let buf = null;
3740
+ if (Buffer.isBuffer(value)) {
3741
+ isBuffer = true;
3742
+ buf = value;
3743
+ } else if (typeof value === "object" && value !== null && value.type === "Buffer" && Array.isArray(value.data)) {
3744
+ isBuffer = true;
3745
+ buf = Buffer.from(value.data);
3746
+ }
3747
+ if (isBuffer && buf) {
3748
+ let isPrintable = true;
3749
+ for (let i = 0; i < buf.length; i++) {
3750
+ const b = buf[i];
3751
+ if ((b < 32 || b > 126) && b !== 9 && b !== 10 && b !== 13) {
3752
+ isPrintable = false;
3753
+ break;
3754
+ }
3755
+ }
3756
+ return isPrintable ? buf.toString("utf8") : `data:application/octet-stream;base64,${buf.toString("base64")}`;
3757
+ }
3758
+ if (typeof value === "object" && value !== null) {
3759
+ try {
3760
+ return JSON.stringify(value);
3761
+ } catch {
3762
+ return String(value);
3763
+ }
3764
+ }
3765
+ return String(value);
3766
+ }
4606
3767
  case "relation":
4607
3768
  if (typeof value === "string" || typeof value === "number") {
4608
3769
  let relationDef = property.relation;
@@ -4686,8 +3847,29 @@ function parsePropertyFromServer(value, property, collection, propertyKey) {
4686
3847
  }
4687
3848
  return null;
4688
3849
  }
4689
- default:
3850
+ default: {
3851
+ let isBuffer = false;
3852
+ let buf = null;
3853
+ if (Buffer.isBuffer(value)) {
3854
+ isBuffer = true;
3855
+ buf = value;
3856
+ } else if (typeof value === "object" && value !== null && value.type === "Buffer" && Array.isArray(value.data)) {
3857
+ isBuffer = true;
3858
+ buf = Buffer.from(value.data);
3859
+ }
3860
+ if (isBuffer && buf) {
3861
+ let isPrintable = true;
3862
+ for (let i = 0; i < buf.length; i++) {
3863
+ const b = buf[i];
3864
+ if ((b < 32 || b > 126) && b !== 9 && b !== 10 && b !== 13) {
3865
+ isPrintable = false;
3866
+ break;
3867
+ }
3868
+ }
3869
+ return isPrintable ? buf.toString("utf8") : `data:application/octet-stream;base64,${buf.toString("base64")}`;
3870
+ }
4690
3871
  return value;
3872
+ }
4691
3873
  }
4692
3874
  }
4693
3875
  function normalizeScalarValues(data, properties, collection, resolvedRelations, options) {
@@ -4770,11 +3952,11 @@ class RelationService {
4770
3952
  if (!fromCol || !toCol) {
4771
3953
  throw new Error(`Join columns not found: ${fromColumn} -> ${toColumn}`);
4772
3954
  }
4773
- query2 = query2.innerJoin(joinTable, eq$3(fromCol, toCol));
3955
+ query2 = query2.innerJoin(joinTable, eq(fromCol, toCol));
4774
3956
  currentTable = joinTable;
4775
3957
  }
4776
3958
  const parentIdField = parentTable[getPrimaryKeys(parentCollection, this.registry)[0].fieldName];
4777
- query2 = query2.where(eq$3(parentIdField, parsedParentId));
3959
+ query2 = query2.where(eq(parentIdField, parsedParentId));
4778
3960
  if (options.limit) {
4779
3961
  query2 = query2.limit(options.limit);
4780
3962
  }
@@ -4893,7 +4075,7 @@ class RelationService {
4893
4075
  if (!fromCol || !toCol) {
4894
4076
  throw new Error(`Join columns not found: ${fromColumn} -> ${toColumn}`);
4895
4077
  }
4896
- query2 = query2.innerJoin(joinTable, eq$3(fromCol, toCol));
4078
+ query2 = query2.innerJoin(joinTable, eq(fromCol, toCol));
4897
4079
  currentTable = joinTable;
4898
4080
  }
4899
4081
  const parentIdField = parentTable[getPrimaryKeys(parentCollection, this.registry)[0].fieldName];
@@ -5024,7 +4206,7 @@ class RelationService {
5024
4206
  const fromCol = currentTable[fromColName];
5025
4207
  const toCol = joinTable[toColName];
5026
4208
  if (!fromCol || !toCol) throw new Error(`Join columns not found: ${fromColumn} -> ${toColumn}`);
5027
- query2 = query2.innerJoin(joinTable, eq$3(fromCol, toCol));
4209
+ query2 = query2.innerJoin(joinTable, eq(fromCol, toCol));
5028
4210
  currentTable = joinTable;
5029
4211
  }
5030
4212
  const parentIdField = parentTable[getPrimaryKeys(parentCollection, this.registry)[0].fieldName];
@@ -5059,7 +4241,7 @@ class RelationService {
5059
4241
  console.warn(`[batchFetchRelatedEntitiesMany] Junction columns not found in '${relation.through.table}'`);
5060
4242
  return /* @__PURE__ */ new Map();
5061
4243
  }
5062
- const query2 = this.db.select().from(junctionTable).innerJoin(targetTable, eq$3(targetJunctionCol, targetIdField)).where(inArray(sourceJunctionCol, parsedParentIds));
4244
+ const query2 = this.db.select().from(junctionTable).innerJoin(targetTable, eq(targetJunctionCol, targetIdField)).where(inArray(sourceJunctionCol, parsedParentIds));
5063
4245
  const results2 = await query2;
5064
4246
  const resultMap2 = /* @__PURE__ */ new Map();
5065
4247
  const targetTableName = getTableName(targetCollection);
@@ -5157,7 +4339,7 @@ class RelationService {
5157
4339
  const parentIdInfo = parentPks[0];
5158
4340
  const parsedParentIdObj = parseIdValues(entityId, parentPks);
5159
4341
  const parsedParentId = parsedParentIdObj[parentIdInfo.fieldName];
5160
- await tx.delete(junctionTable).where(eq$3(sourceJunctionColumn, parsedParentId));
4342
+ await tx.delete(junctionTable).where(eq(sourceJunctionColumn, parsedParentId));
5161
4343
  if (targetEntityIds.length > 0) {
5162
4344
  const targetPks = getPrimaryKeys(targetCollection, this.registry);
5163
4345
  const targetIdInfo = targetPks[0];
@@ -5186,7 +4368,7 @@ class RelationService {
5186
4368
  const parentIdInfo = parentPks[0];
5187
4369
  const parsedParentIdObj = parseIdValues(entityId, parentPks);
5188
4370
  const parsedParentId = parsedParentIdObj[parentIdInfo.fieldName];
5189
- await tx.delete(junctionTable).where(eq$3(sourceJunctionColumn, parsedParentId));
4371
+ await tx.delete(junctionTable).where(eq(sourceJunctionColumn, parsedParentId));
5190
4372
  if (targetEntityIds.length > 0) {
5191
4373
  const targetPks = getPrimaryKeys(targetCollection, this.registry);
5192
4374
  const targetIdInfo = targetPks[0];
@@ -5219,14 +4401,14 @@ class RelationService {
5219
4401
  const parsedTargetIds = targetEntityIds.map((id) => parseIdValues(id, targetPks)[targetIdInfo.fieldName]);
5220
4402
  await tx.update(targetTable).set({
5221
4403
  [relation.foreignKeyOnTarget]: null
5222
- }).where(and(eq$3(fkCol, parsedParentId), sql`${targetIdCol} NOT IN (${sql.join(parsedTargetIds)})`));
4404
+ }).where(and(eq(fkCol, parsedParentId), sql`${targetIdCol} NOT IN (${sql.join(parsedTargetIds)})`));
5223
4405
  await tx.update(targetTable).set({
5224
4406
  [relation.foreignKeyOnTarget]: parsedParentId
5225
4407
  }).where(inArray(targetIdCol, parsedTargetIds));
5226
4408
  } else {
5227
4409
  await tx.update(targetTable).set({
5228
4410
  [relation.foreignKeyOnTarget]: null
5229
- }).where(eq$3(fkCol, parsedParentId));
4411
+ }).where(eq(fkCol, parsedParentId));
5230
4412
  }
5231
4413
  } else {
5232
4414
  console.warn(`Many relation '${key}' in collection '${collection.slug}' lacks write configuration and will be skipped during save.`);
@@ -5285,17 +4467,17 @@ class RelationService {
5285
4467
  if (newValue === null || newValue === void 0) {
5286
4468
  await tx.update(targetTable).set({
5287
4469
  [relation.foreignKeyOnTarget]: null
5288
- }).where(eq$3(foreignKeyColumn, parsedSourceId));
4470
+ }).where(eq(foreignKeyColumn, parsedSourceId));
5289
4471
  } else {
5290
4472
  const parsedNewTargetIdObj = parseIdValues(newValue, targetPks);
5291
4473
  const parsedNewTargetId = parsedNewTargetIdObj[targetIdInfo.fieldName];
5292
4474
  const targetIdField = targetTable[targetIdInfo.fieldName];
5293
4475
  await tx.update(targetTable).set({
5294
4476
  [relation.foreignKeyOnTarget]: null
5295
- }).where(eq$3(foreignKeyColumn, parsedSourceId));
4477
+ }).where(eq(foreignKeyColumn, parsedSourceId));
5296
4478
  await tx.update(targetTable).set({
5297
4479
  [relation.foreignKeyOnTarget]: parsedSourceId
5298
- }).where(eq$3(targetIdField, parsedNewTargetId));
4480
+ }).where(eq(targetIdField, parsedNewTargetId));
5299
4481
  }
5300
4482
  } catch (e) {
5301
4483
  console.warn(`Failed to update inverse relation '${relation.relationName}':`, e);
@@ -5350,7 +4532,7 @@ class RelationService {
5350
4532
  const sourceIdInfo = sourcePks[0];
5351
4533
  const parsedSourceIdObj = parseIdValues(sourceEntityId, sourcePks);
5352
4534
  const parsedSourceId = parsedSourceIdObj[sourceIdInfo.fieldName];
5353
- await tx.delete(junctionTable).where(eq$3(sourceJunctionColumn, parsedSourceId));
4535
+ await tx.delete(junctionTable).where(eq(sourceJunctionColumn, parsedSourceId));
5354
4536
  if (newValue && Array.isArray(newValue) && newValue.length > 0) {
5355
4537
  const targetPks = getPrimaryKeys(targetCollection, this.registry);
5356
4538
  const targetIdInfo = targetPks[0];
@@ -5401,7 +4583,7 @@ class RelationService {
5401
4583
  const sourceIdInfo = sourcePks[0];
5402
4584
  const parsedSourceIdObj = parseIdValues(sourceEntityId, sourcePks);
5403
4585
  const parsedSourceId = parsedSourceIdObj[sourceIdInfo.fieldName];
5404
- await tx.delete(junctionTable).where(eq$3(sourceJunctionColumn, parsedSourceId));
4586
+ await tx.delete(junctionTable).where(eq(sourceJunctionColumn, parsedSourceId));
5405
4587
  if (newValue && Array.isArray(newValue) && newValue.length > 0) {
5406
4588
  const targetPks = getPrimaryKeys(targetCollection, this.registry);
5407
4589
  const targetIdInfo = targetPks[0];
@@ -5456,14 +4638,14 @@ class RelationService {
5456
4638
  }
5457
4639
  const parentRows = await tx.select({
5458
4640
  val: parentSourceCol
5459
- }).from(parentTable).where(eq$3(parentIdCol, parsedParentId)).limit(1);
4641
+ }).from(parentTable).where(eq(parentIdCol, parsedParentId)).limit(1);
5460
4642
  if (parentRows.length === 0) continue;
5461
4643
  const parentFKValue = parentRows[0].val;
5462
4644
  if (newTargetId === null || newTargetId === void 0) {
5463
4645
  if (parentFKValue !== null && parentFKValue !== void 0) {
5464
4646
  await tx.update(targetTable).set({
5465
4647
  [targetFKColName]: null
5466
- }).where(eq$3(targetFKCol, parentFKValue));
4648
+ }).where(eq(targetFKCol, parentFKValue));
5467
4649
  }
5468
4650
  continue;
5469
4651
  }
@@ -5472,14 +4654,14 @@ class RelationService {
5472
4654
  if (parentFKValue !== null && parentFKValue !== void 0) {
5473
4655
  await tx.update(targetTable).set({
5474
4656
  [targetFKColName]: null
5475
- }).where(eq$3(targetFKCol, parentFKValue));
4657
+ }).where(eq(targetFKCol, parentFKValue));
5476
4658
  } else {
5477
4659
  console.warn(`Cannot set joinPath relation '${relation.relationName}' because parent FK value is null/undefined`);
5478
4660
  continue;
5479
4661
  }
5480
4662
  await tx.update(targetTable).set({
5481
4663
  [targetFKColName]: parentFKValue
5482
- }).where(eq$3(targetIdCol, parsedTargetId));
4664
+ }).where(eq(targetIdCol, parsedTargetId));
5483
4665
  }
5484
4666
  }
5485
4667
  /**
@@ -5864,7 +5046,7 @@ class EntityFetchService {
5864
5046
  const collection = getCollectionByPath(collectionPath, this.registry);
5865
5047
  const searchConditions = DrizzleConditionBuilder.buildSearchConditions(options.searchString, collection.properties, table);
5866
5048
  if (searchConditions.length === 0) {
5867
- queryOpts.where = and(eq$3(idField, -99999999));
5049
+ queryOpts.where = and(eq(idField, -99999999));
5868
5050
  return queryOpts;
5869
5051
  }
5870
5052
  allConditions.push(DrizzleConditionBuilder.combineConditionsWithOr(searchConditions));
@@ -5911,9 +5093,9 @@ class EntityFetchService {
5911
5093
  const startAfterId = cursor.id ?? cursor[idInfo.fieldName];
5912
5094
  if (startAfterOrderValue !== void 0 && startAfterId !== void 0) {
5913
5095
  if (options.order === "asc") {
5914
- return [or(gt(orderByField, startAfterOrderValue), and(eq$3(orderByField, startAfterOrderValue), gt(idField, startAfterId)))];
5096
+ return [or(gt(orderByField, startAfterOrderValue), and(eq(orderByField, startAfterOrderValue), gt(idField, startAfterId)))];
5915
5097
  } else {
5916
- return [or(lt(orderByField, startAfterOrderValue), and(eq$3(orderByField, startAfterOrderValue), lt(idField, startAfterId)))];
5098
+ return [or(lt(orderByField, startAfterOrderValue), and(eq(orderByField, startAfterOrderValue), lt(idField, startAfterId)))];
5917
5099
  }
5918
5100
  }
5919
5101
  }
@@ -5947,7 +5129,7 @@ class EntityFetchService {
5947
5129
  try {
5948
5130
  const withConfig = this.buildWithConfig(collection);
5949
5131
  const row = await qb.findFirst({
5950
- where: eq$3(idField, parsedId),
5132
+ where: eq(idField, parsedId),
5951
5133
  with: withConfig
5952
5134
  });
5953
5135
  if (!row) return void 0;
@@ -5955,10 +5137,14 @@ class EntityFetchService {
5955
5137
  await this.resolveJoinPathRelations(entity, collection, collectionPath, parsedId, databaseId);
5956
5138
  return entity;
5957
5139
  } catch (e) {
5140
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5141
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5142
+ 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.`);
5143
+ }
5958
5144
  console.warn(`[EntityFetchService] db.query.findFirst failed for ${collectionPath}, falling back to db.select:`, e);
5959
5145
  }
5960
5146
  }
5961
- const result = await this.db.select().from(table).where(eq$3(idField, parsedId)).limit(1);
5147
+ const result = await this.db.select().from(table).where(eq(idField, parsedId)).limit(1);
5962
5148
  if (result.length === 0) return void 0;
5963
5149
  const raw = result[0];
5964
5150
  const values = await parseDataFromServer(raw, collection, this.db, this.registry);
@@ -6015,6 +5201,10 @@ class EntityFetchService {
6015
5201
  const entities = results2.map((row) => this.drizzleResultToEntity(row, collection, collectionPath, idInfo, options.databaseId, idInfoArray));
6016
5202
  return entities;
6017
5203
  } catch (e) {
5204
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5205
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5206
+ 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.`);
5207
+ }
6018
5208
  console.warn(`[EntityFetchService] db.query.findMany failed for ${collectionPath}, falling back to db.select:`, e);
6019
5209
  }
6020
5210
  }
@@ -6284,6 +5474,10 @@ class EntityFetchService {
6284
5474
  await this.resolveJoinPathRelationsBatchRest(restRows, collection, collectionPath, idInfoArray, include);
6285
5475
  return restRows;
6286
5476
  } catch (e) {
5477
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5478
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5479
+ 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.`);
5480
+ }
6287
5481
  console.warn(`[fetchCollectionForRest] db.query.findMany failed for ${collectionPath}, falling back:`, e);
6288
5482
  }
6289
5483
  }
@@ -6354,7 +5548,7 @@ class EntityFetchService {
6354
5548
  try {
6355
5549
  const withConfig = include && include.length > 0 ? this.buildWithConfig(collection, include) : void 0;
6356
5550
  const row = await qb.findFirst({
6357
- where: eq$3(idField, parsedId),
5551
+ where: eq(idField, parsedId),
6358
5552
  ...withConfig ? {
6359
5553
  with: withConfig
6360
5554
  } : {}
@@ -6364,10 +5558,14 @@ class EntityFetchService {
6364
5558
  await this.resolveJoinPathRelationsBatchRest([restRow], collection, collectionPath, idInfoArray, include);
6365
5559
  return restRow;
6366
5560
  } catch (e) {
5561
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5562
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5563
+ 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.`);
5564
+ }
6367
5565
  console.warn(`[fetchEntityForRest] db.query.findFirst failed for ${collectionPath}, falling back:`, e);
6368
5566
  }
6369
5567
  }
6370
- const result = await this.db.select().from(table).where(eq$3(idField, parsedId)).limit(1);
5568
+ const result = await this.db.select().from(table).where(eq(idField, parsedId)).limit(1);
6371
5569
  if (result.length === 0) return null;
6372
5570
  const raw = result[0];
6373
5571
  const flatEntity = {
@@ -6576,7 +5774,7 @@ class EntityPersistService {
6576
5774
  }
6577
5775
  const parsedIdObj = parseIdValues(entityId, idInfoArray);
6578
5776
  const parsedId = parsedIdObj[idInfo.fieldName];
6579
- await this.db.delete(table).where(eq$3(idField, parsedId));
5777
+ await this.db.delete(table).where(eq(idField, parsedId));
6580
5778
  }
6581
5779
  /**
6582
5780
  * Save an entity (create or update)
@@ -6622,7 +5820,7 @@ class EntityPersistService {
6622
5820
  targetColumnName = relation.localKey;
6623
5821
  } else if (relation.foreignKeyOnTarget) {
6624
5822
  targetColumnName = relation.foreignKeyOnTarget;
6625
- } else if (relation.joinPath && relation.joinPath.length > 0) {
5823
+ } else if (relation.joinPath && relation.joinPath.length === 1) {
6626
5824
  const targetTableName = getTableName(targetCollection);
6627
5825
  const relevantJoinStep = relation.joinPath.find((joinStep) => joinStep.table === targetTableName);
6628
5826
  if (relevantJoinStep) {
@@ -6633,6 +5831,8 @@ class EntityPersistService {
6633
5831
  const targetColumnNames = DrizzleConditionBuilder.getColumnNamesFromColumns(relation.joinPath[0].on.to);
6634
5832
  targetColumnName = targetColumnNames[0];
6635
5833
  }
5834
+ } else if (relation.joinPath && relation.joinPath.length > 1) {
5835
+ break;
6636
5836
  } else {
6637
5837
  throw new Error(`Relation '${relationKey}' lacks configuration for path-based saving.`);
6638
5838
  }
@@ -6698,7 +5898,7 @@ class EntityPersistService {
6698
5898
  const conditions = [];
6699
5899
  for (const info of idInfoArray) {
6700
5900
  const field = table[info.fieldName];
6701
- conditions.push(eq$3(field, idValues[info.fieldName]));
5901
+ conditions.push(eq(field, idValues[info.fieldName]));
6702
5902
  }
6703
5903
  await updateQuery.where(and(...conditions));
6704
5904
  }
@@ -6755,22 +5955,78 @@ class EntityPersistService {
6755
5955
  const pgError = this.extractPgError(error);
6756
5956
  if (pgError) {
6757
5957
  const detail = pgError.detail;
5958
+ const hint = pgError.hint;
6758
5959
  const constraint = pgError.constraint;
6759
5960
  const column = pgError.column;
6760
5961
  const table = pgError.table;
5962
+ const dataType = pgError.dataType;
5963
+ const pgMessage = pgError.message || "Unknown database error";
5964
+ const suffix = hint ? ` Hint: ${hint}` : "";
5965
+ const tableRef = table ?? collectionSlug;
6761
5966
  switch (pgError.code) {
6762
5967
  case "23503":
6763
- return new Error(detail ? `Foreign key constraint violated: ${detail}` : `Cannot save: a foreign key constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".`);
5968
+ return new Error(detail ? `Foreign key constraint violated: ${detail}${suffix}` : `Cannot save: a foreign key constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
6764
5969
  case "23505":
6765
- return new Error(detail ? `Duplicate value: ${detail}` : `Cannot save: a unique constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".`);
5970
+ return new Error(detail ? `Duplicate value: ${detail}${suffix}` : `Cannot save: a unique constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
6766
5971
  case "23502":
6767
- return new Error(`Missing required field: "${column ?? "unknown"}" in "${table ?? collectionSlug}" cannot be empty.`);
5972
+ return new Error(`Missing required field: "${column ?? "unknown"}" in "${tableRef}" cannot be empty.${suffix}`);
6768
5973
  case "23514":
6769
- return new Error(`Validation failed: a check constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".`);
5974
+ return new Error(`Validation failed: a check constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
5975
+ case "22P02":
5976
+ return new Error(`Invalid data format in "${collectionSlug}": ${pgMessage}${suffix}`);
5977
+ case "22001":
5978
+ return new Error(`Value too long for column "${column ?? "unknown"}" in "${tableRef}": ${pgMessage}${suffix}`);
5979
+ case "22003":
5980
+ return new Error(`Numeric value out of range for column "${column ?? "unknown"}" in "${tableRef}": ${pgMessage}${suffix}`);
5981
+ case "42703":
5982
+ return new Error(`Unknown column in "${tableRef}": ${pgMessage}. Check if your schema is up to date (run migrations).${suffix}`);
5983
+ case "42P01":
5984
+ return new Error(`Table not found for "${collectionSlug}": ${pgMessage}. Check if your schema is up to date (run migrations).${suffix}`);
5985
+ default: {
5986
+ const parts = [`Database error in "${collectionSlug}" [${pgError.code}]: ${pgMessage}`];
5987
+ if (detail) parts.push(`Detail: ${detail}`);
5988
+ if (column) parts.push(`Column: ${column}`);
5989
+ if (dataType) parts.push(`Data type: ${dataType}`);
5990
+ if (constraint) parts.push(`Constraint: ${constraint}`);
5991
+ if (hint) parts.push(`Hint: ${hint}`);
5992
+ return new Error(parts.join(". "));
5993
+ }
5994
+ }
5995
+ }
5996
+ const causeMessage = this.extractCauseMessage(error);
5997
+ if (causeMessage) {
5998
+ return new Error(`Database error in "${collectionSlug}": ${causeMessage}`);
5999
+ }
6000
+ if (error instanceof Error) {
6001
+ const cleaned = this.stripSqlFromMessage(error.message, collectionSlug);
6002
+ return new Error(cleaned);
6003
+ }
6004
+ return new Error(`Database error in "${collectionSlug}": ${String(error)}`);
6005
+ }
6006
+ /**
6007
+ * Walk the error cause chain and return the deepest meaningful message.
6008
+ */
6009
+ extractCauseMessage(error) {
6010
+ if (!error || typeof error !== "object") return null;
6011
+ const err = error;
6012
+ if (err.cause && typeof err.cause === "object") {
6013
+ const deeper = this.extractCauseMessage(err.cause);
6014
+ if (deeper) return deeper;
6015
+ if (err.cause instanceof Error && err.cause.message) {
6016
+ return err.cause.message;
6770
6017
  }
6771
6018
  }
6772
- if (error instanceof Error) return error;
6773
- return new Error(String(error));
6019
+ return null;
6020
+ }
6021
+ /**
6022
+ * Strip the raw SQL query from a Drizzle "Failed query: ..." message,
6023
+ * keeping only the error description.
6024
+ */
6025
+ stripSqlFromMessage(message, collectionSlug) {
6026
+ if (message.startsWith("Failed query:")) {
6027
+ return `Failed to save entity in "${collectionSlug}". Check server logs for details.`;
6028
+ }
6029
+ return message;
6774
6030
  }
6775
6031
  /**
6776
6032
  * Extract the underlying PostgreSQL error from a Drizzle wrapper.
@@ -6779,7 +6035,7 @@ class EntityPersistService {
6779
6035
  extractPgError(error) {
6780
6036
  if (!error || typeof error !== "object") return null;
6781
6037
  const err = error;
6782
- if (err.code && /^[0-9]{5}$/.test(err.code)) {
6038
+ if (err.code && /^[0-9A-Z]{5}$/.test(err.code)) {
6783
6039
  return err;
6784
6040
  }
6785
6041
  if (err.cause && typeof err.cause === "object") {
@@ -7067,6 +6323,7 @@ class PostgresBackendDriver {
7067
6323
  branchService;
7068
6324
  user;
7069
6325
  data;
6326
+ client;
7070
6327
  /**
7071
6328
  * When true, realtime notifications are deferred until after the
7072
6329
  * wrapping transaction commits. Set by `withAuth` → `withTransaction`.
@@ -7095,6 +6352,14 @@ class PostgresBackendDriver {
7095
6352
  } : {}
7096
6353
  };
7097
6354
  }
6355
+ /**
6356
+ * REST-optimised fetch service (include-aware eager-loading).
6357
+ * Delegates to the underlying EntityFetchService which already
6358
+ * implements the matching method signatures.
6359
+ */
6360
+ get restFetchService() {
6361
+ return this.entityService.getFetchService();
6362
+ }
7098
6363
  resolveCollectionCallbacks(collection, path2) {
7099
6364
  if (!collection && !path2) return {
7100
6365
  collection: void 0,
@@ -7148,7 +6413,8 @@ class PostgresBackendDriver {
7148
6413
  const contextForCallback = {
7149
6414
  user: this.user,
7150
6415
  driver: this,
7151
- data: this.data
6416
+ data: this.data,
6417
+ client: this.client
7152
6418
  };
7153
6419
  return Promise.all(entities.map(async (entity) => {
7154
6420
  let fetched = entity;
@@ -7242,7 +6508,8 @@ class PostgresBackendDriver {
7242
6508
  const contextForCallback = {
7243
6509
  user: this.user,
7244
6510
  driver: this,
7245
- data: this.data
6511
+ data: this.data,
6512
+ client: this.client
7246
6513
  };
7247
6514
  if (callbacks?.afterRead) {
7248
6515
  entity = await callbacks.afterRead({
@@ -7311,7 +6578,8 @@ class PostgresBackendDriver {
7311
6578
  const contextForCallback = {
7312
6579
  user: this.user,
7313
6580
  driver: this,
7314
- data: this.data
6581
+ data: this.data,
6582
+ client: this.client
7315
6583
  };
7316
6584
  let previousValuesForHistory;
7317
6585
  if (status === "existing" && entityId) {
@@ -7346,6 +6614,14 @@ class PostgresBackendDriver {
7346
6614
  if (result) updatedValues = mergeDeep(updatedValues, result);
7347
6615
  }
7348
6616
  }
6617
+ if (resolvedCollection?.properties) {
6618
+ updatedValues = updateDateAutoValues({
6619
+ inputValues: updatedValues,
6620
+ properties: resolvedCollection.properties,
6621
+ status: status ?? "new",
6622
+ timestampNowValue: /* @__PURE__ */ new Date()
6623
+ });
6624
+ }
7349
6625
  try {
7350
6626
  let savedEntity = await this.entityService.saveEntity(path2, updatedValues, entityId, resolvedCollection?.databaseId);
7351
6627
  if (savedEntity && (callbacks?.afterRead || propertyCallbacks?.afterRead)) {
@@ -7451,7 +6727,8 @@ class PostgresBackendDriver {
7451
6727
  const contextForCallback = {
7452
6728
  user: this.user,
7453
6729
  driver: this,
7454
- data: this.data
6730
+ data: this.data,
6731
+ client: this.client
7455
6732
  };
7456
6733
  if (callbacks?.beforeDelete || propertyCallbacks?.beforeDelete) {
7457
6734
  if (callbacks?.beforeDelete) {
@@ -7778,6 +7055,7 @@ class AuthenticatedPostgresBackendDriver {
7778
7055
  txDelegate.entityService = txEntityService;
7779
7056
  txDelegate._deferNotifications = true;
7780
7057
  txDelegate._pendingNotifications = pendingNotifications;
7058
+ txDelegate.client = this.delegate.client;
7781
7059
  return await operation(txDelegate);
7782
7060
  });
7783
7061
  for (const notification of pendingNotifications) {
@@ -8059,6 +7337,12 @@ const userIdentitiesRelations = relations(userIdentities, ({
8059
7337
  references: [users.id]
8060
7338
  })
8061
7339
  }));
7340
+ const resolveColumnName = (propName, prop) => {
7341
+ if (prop && "columnName" in prop && typeof prop.columnName === "string") {
7342
+ return prop.columnName;
7343
+ }
7344
+ return toSnakeCase(propName);
7345
+ };
8062
7346
  const getPrimaryKeyProp = (collection) => {
8063
7347
  if (collection.properties) {
8064
7348
  const idPropEntry = Object.entries(collection.properties).find(([_, prop]) => "isId" in prop && Boolean(prop.isId));
@@ -8099,7 +7383,7 @@ const isIdProperty = (propName, prop, collection) => {
8099
7383
  return !hasExplicitId && propName === "id";
8100
7384
  };
8101
7385
  const getDrizzleColumn = (propName, prop, collection, collections) => {
8102
- const colName = toSnakeCase(propName);
7386
+ const colName = resolveColumnName(propName, prop);
8103
7387
  let columnDefinition;
8104
7388
  switch (prop.type) {
8105
7389
  case "string": {
@@ -8171,6 +7455,9 @@ const getDrizzleColumn = (propName, prop, collection, collections) => {
8171
7455
  } else {
8172
7456
  columnDefinition = `timestamp("${colName}", { withTimezone: true, mode: 'string' })`;
8173
7457
  }
7458
+ if (dateProp.autoValue === "on_create" || dateProp.autoValue === "on_update") {
7459
+ columnDefinition += `.default(sql\`now()\`)`;
7460
+ }
8174
7461
  break;
8175
7462
  }
8176
7463
  case "map":
@@ -8203,7 +7490,7 @@ const getDrizzleColumn = (propName, prop, collection, collections) => {
8203
7490
  } catch {
8204
7491
  return null;
8205
7492
  }
8206
- const fkColumnName = toSnakeCase(relation.localKey);
7493
+ const fkColumnName = relation.localKey;
8207
7494
  const targetTableVar = getTableVarName(getTableName(targetCollection));
8208
7495
  const pkProp = getPrimaryKeyProp(targetCollection);
8209
7496
  const targetIdField = pkProp.name;
@@ -8391,7 +7678,7 @@ const generateSchema = async (collections, stripPolicies = false) => {
8391
7678
  Object.entries(collection.properties ?? {}).forEach(([propName, prop]) => {
8392
7679
  if ("enum" in prop && (prop.type === "string" || prop.type === "number") && prop.enum) {
8393
7680
  const enumVarName = getEnumVarName(collectionPath, propName);
8394
- const enumDbName = `${collectionPath}_${toSnakeCase(propName)}`;
7681
+ const enumDbName = `${collectionPath}_${resolveColumnName(propName, prop)}`;
8395
7682
  const values = Array.isArray(prop.enum) ? prop.enum.map((v) => String(v.id ?? v)) : Object.keys(prop.enum);
8396
7683
  if (values.length > 0) {
8397
7684
  schemaContent += `export const ${enumVarName} = pgEnum("${enumDbName}", [${values.map((v) => `'${v}'`).join(", ")}]);
@@ -8448,9 +7735,9 @@ const generateSchema = async (collections, stripPolicies = false) => {
8448
7735
  const targetId = getPrimaryKeyName(targetCollection);
8449
7736
  schemaContent += `export const ${tableVarName} = pgTable("${tableName}", {
8450
7737
  `;
8451
- schemaContent += ` ${sourceColumn}: ${sourceColType}("${toSnakeCase(sourceColumn)}").notNull().references(() => ${getTableVarName(getTableName(sourceCollection))}.${sourceId}, ${refOptions}),
7738
+ schemaContent += ` ${sourceColumn}: ${sourceColType}("${sourceColumn}").notNull().references(() => ${getTableVarName(getTableName(sourceCollection))}.${sourceId}, ${refOptions}),
8452
7739
  `;
8453
- schemaContent += ` ${targetColumn}: ${targetColType}("${toSnakeCase(targetColumn)}").notNull().references(() => ${getTableVarName(getTableName(targetCollection))}.${targetId}, ${refOptions}),
7740
+ schemaContent += ` ${targetColumn}: ${targetColType}("${targetColumn}").notNull().references(() => ${getTableVarName(getTableName(targetCollection))}.${targetId}, ${refOptions}),
8454
7741
  `;
8455
7742
  schemaContent += "}, (table) => ({\n";
8456
7743
  schemaContent += ` pk: primaryKey({ columns: [table.${sourceColumn}, table.${targetColumn}] })
@@ -8543,29 +7830,10 @@ const generateSchema = async (collections, stripPolicies = false) => {
8543
7830
  references: [${targetTableVar}.${getPrimaryKeyName(target)}],
8544
7831
  relationName: "${drizzleRelationName}"
8545
7832
  })`);
8546
- } else if (rel.direction === "inverse" && rel.foreignKeyOnTarget) {
8547
- const sourceIdField = getPrimaryKeyName(collection);
7833
+ } else if (rel.direction === "inverse") {
8548
7834
  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
7835
  relationName: "${drizzleRelationName}"
8564
7836
  })`);
8565
- }
8566
- } catch (e) {
8567
- console.warn(`Could not resolve inverse one-to-one relation '${relationKey}':`, e);
8568
- }
8569
7837
  }
8570
7838
  } else if (rel.cardinality === "many") {
8571
7839
  if (rel.direction === "inverse" && rel.foreignKeyOnTarget) {
@@ -8593,6 +7861,32 @@ const generateSchema = async (collections, stripPolicies = false) => {
8593
7861
  console.warn(`Could not generate relation ${relationKey} for ${collection.name}:`, e);
8594
7862
  }
8595
7863
  }
7864
+ for (const otherCollection of collections) {
7865
+ if (otherCollection.slug === collection.slug) continue;
7866
+ const otherRelations = resolveCollectionRelations(otherCollection);
7867
+ for (const [otherKey, otherRel] of Object.entries(otherRelations)) {
7868
+ if (otherRel.direction === "inverse" && otherRel.foreignKeyOnTarget) {
7869
+ try {
7870
+ const otherTarget = otherRel.target();
7871
+ if (otherTarget.slug === collection.slug) {
7872
+ const drizzleRelationName = computeSharedRelationName(otherRel, otherCollection, collections);
7873
+ const deduplicationKey = `${drizzleRelationName}::owning`;
7874
+ if (!emittedRelationNames.has(deduplicationKey)) {
7875
+ const otherTableVar = getTableVarName(getTableName(otherCollection));
7876
+ const synthKey = `_synth_${otherTableVar}_${otherRel.foreignKeyOnTarget}`;
7877
+ tableRelations.push(` "${synthKey}": one(${otherTableVar}, {
7878
+ fields: [${tableVarName}.${otherRel.foreignKeyOnTarget}],
7879
+ references: [${otherTableVar}.${getPrimaryKeyName(otherCollection)}],
7880
+ relationName: "${drizzleRelationName}"
7881
+ })`);
7882
+ emittedRelationNames.add(deduplicationKey);
7883
+ }
7884
+ }
7885
+ } catch (e) {
7886
+ }
7887
+ }
7888
+ }
7889
+ }
8596
7890
  }
8597
7891
  if (tableRelations.length > 0) {
8598
7892
  const relVarName = `${tableVarName}Relations`;
@@ -10371,11 +9665,11 @@ class UserService {
10371
9665
  return user;
10372
9666
  }
10373
9667
  async getUserById(id) {
10374
- const [user] = await this.db.select().from(users).where(eq$3(users.id, id));
9668
+ const [user] = await this.db.select().from(users).where(eq(users.id, id));
10375
9669
  return user || null;
10376
9670
  }
10377
9671
  async getUserByEmail(email) {
10378
- const [user] = await this.db.select().from(users).where(eq$3(users.email, email.toLowerCase()));
9672
+ const [user] = await this.db.select().from(users).where(eq(users.email, email.toLowerCase()));
10379
9673
  return user || null;
10380
9674
  }
10381
9675
  async getUserByIdentity(provider, providerId) {
@@ -10431,11 +9725,11 @@ class UserService {
10431
9725
  const [user] = await this.db.update(users).set({
10432
9726
  ...data,
10433
9727
  updatedAt: /* @__PURE__ */ new Date()
10434
- }).where(eq$3(users.id, id)).returning();
9728
+ }).where(eq(users.id, id)).returning();
10435
9729
  return user || null;
10436
9730
  }
10437
9731
  async deleteUser(id) {
10438
- await this.db.delete(users).where(eq$3(users.id, id));
9732
+ await this.db.delete(users).where(eq(users.id, id));
10439
9733
  }
10440
9734
  async listUsers() {
10441
9735
  return this.db.select().from(users);
@@ -10504,7 +9798,7 @@ class UserService {
10504
9798
  await this.db.update(users).set({
10505
9799
  passwordHash,
10506
9800
  updatedAt: /* @__PURE__ */ new Date()
10507
- }).where(eq$3(users.id, id));
9801
+ }).where(eq(users.id, id));
10508
9802
  }
10509
9803
  /**
10510
9804
  * Set email verification status
@@ -10514,7 +9808,7 @@ class UserService {
10514
9808
  emailVerified: verified,
10515
9809
  emailVerificationToken: null,
10516
9810
  updatedAt: /* @__PURE__ */ new Date()
10517
- }).where(eq$3(users.id, id));
9811
+ }).where(eq(users.id, id));
10518
9812
  }
10519
9813
  /**
10520
9814
  * Set email verification token
@@ -10524,13 +9818,13 @@ class UserService {
10524
9818
  emailVerificationToken: token,
10525
9819
  emailVerificationSentAt: token ? /* @__PURE__ */ new Date() : null,
10526
9820
  updatedAt: /* @__PURE__ */ new Date()
10527
- }).where(eq$3(users.id, id));
9821
+ }).where(eq(users.id, id));
10528
9822
  }
10529
9823
  /**
10530
9824
  * Find user by email verification token
10531
9825
  */
10532
9826
  async getUserByVerificationToken(token) {
10533
- const [user] = await this.db.select().from(users).where(eq$3(users.emailVerificationToken, token));
9827
+ const [user] = await this.db.select().from(users).where(eq(users.emailVerificationToken, token));
10534
9828
  return user || null;
10535
9829
  }
10536
9830
  /**
@@ -10703,14 +9997,14 @@ class RefreshTokenService {
10703
9997
  createdAt: refreshTokens.createdAt,
10704
9998
  userAgent: refreshTokens.userAgent,
10705
9999
  ipAddress: refreshTokens.ipAddress
10706
- }).from(refreshTokens).where(eq$3(refreshTokens.tokenHash, tokenHash));
10000
+ }).from(refreshTokens).where(eq(refreshTokens.tokenHash, tokenHash));
10707
10001
  return token || null;
10708
10002
  }
10709
10003
  async deleteByHash(tokenHash) {
10710
- await this.db.delete(refreshTokens).where(eq$3(refreshTokens.tokenHash, tokenHash));
10004
+ await this.db.delete(refreshTokens).where(eq(refreshTokens.tokenHash, tokenHash));
10711
10005
  }
10712
10006
  async deleteAllForUser(userId) {
10713
- await this.db.delete(refreshTokens).where(eq$3(refreshTokens.userId, userId));
10007
+ await this.db.delete(refreshTokens).where(eq(refreshTokens.userId, userId));
10714
10008
  }
10715
10009
  async listForUser(userId) {
10716
10010
  const tokens = await this.db.select({
@@ -10721,7 +10015,7 @@ class RefreshTokenService {
10721
10015
  createdAt: refreshTokens.createdAt,
10722
10016
  userAgent: refreshTokens.userAgent,
10723
10017
  ipAddress: refreshTokens.ipAddress
10724
- }).from(refreshTokens).where(eq$3(refreshTokens.userId, userId)).orderBy(refreshTokens.createdAt);
10018
+ }).from(refreshTokens).where(eq(refreshTokens.userId, userId)).orderBy(refreshTokens.createdAt);
10725
10019
  return tokens;
10726
10020
  }
10727
10021
  async deleteById(id, userId) {
@@ -10753,7 +10047,7 @@ class PasswordResetTokenService {
10753
10047
  const [token] = await this.db.select({
10754
10048
  userId: passwordResetTokens.userId,
10755
10049
  expiresAt: passwordResetTokens.expiresAt
10756
- }).from(passwordResetTokens).where(eq$3(passwordResetTokens.tokenHash, tokenHash));
10050
+ }).from(passwordResetTokens).where(eq(passwordResetTokens.tokenHash, tokenHash));
10757
10051
  if (!token) return null;
10758
10052
  const result = await this.db.execute(sql`
10759
10053
  SELECT user_id, expires_at
@@ -10775,13 +10069,13 @@ class PasswordResetTokenService {
10775
10069
  async markAsUsed(tokenHash) {
10776
10070
  await this.db.update(passwordResetTokens).set({
10777
10071
  usedAt: /* @__PURE__ */ new Date()
10778
- }).where(eq$3(passwordResetTokens.tokenHash, tokenHash));
10072
+ }).where(eq(passwordResetTokens.tokenHash, tokenHash));
10779
10073
  }
10780
10074
  /**
10781
10075
  * Delete all tokens for a user
10782
10076
  */
10783
10077
  async deleteAllForUser(userId) {
10784
- await this.db.delete(passwordResetTokens).where(eq$3(passwordResetTokens.userId, userId));
10078
+ await this.db.delete(passwordResetTokens).where(eq(passwordResetTokens.userId, userId));
10785
10079
  }
10786
10080
  /**
10787
10081
  * Clean up expired tokens