@rebasepro/server-postgresql 0.0.1-canary.892f711 → 0.0.1-canary.a6becfb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/index.es.js +381 -1074
  2. package/dist/index.es.js.map +1 -1
  3. package/dist/index.umd.js +312 -1005
  4. package/dist/index.umd.js.map +1 -1
  5. package/dist/server-postgresql/src/PostgresBackendDriver.d.ts +2 -1
  6. package/dist/server-postgresql/src/schema/introspect-db-inference.d.ts +5 -0
  7. package/dist/server-postgresql/src/schema/introspect-db-logic.d.ts +44 -9
  8. package/dist/server-postgresql/src/services/EntityPersistService.d.ts +9 -0
  9. package/dist/types/src/controllers/auth.d.ts +8 -2
  10. package/dist/types/src/controllers/client.d.ts +13 -0
  11. package/dist/types/src/controllers/navigation.d.ts +18 -6
  12. package/dist/types/src/controllers/registry.d.ts +9 -1
  13. package/dist/types/src/controllers/side_entity_controller.d.ts +7 -0
  14. package/dist/types/src/rebase_context.d.ts +17 -0
  15. package/dist/types/src/types/collections.d.ts +64 -1
  16. package/dist/types/src/types/component_ref.d.ts +47 -0
  17. package/dist/types/src/types/entity_views.d.ts +2 -1
  18. package/dist/types/src/types/index.d.ts +1 -0
  19. package/dist/types/src/types/properties.d.ts +3 -3
  20. package/dist/types/src/types/translations.d.ts +8 -0
  21. package/package.json +5 -5
  22. package/src/PostgresBackendDriver.ts +23 -6
  23. package/src/cli.ts +9 -1
  24. package/src/data-transformer.ts +84 -1
  25. package/src/schema/generate-drizzle-schema-logic.ts +35 -0
  26. package/src/schema/introspect-db-inference.ts +238 -0
  27. package/src/schema/introspect-db-logic.ts +337 -36
  28. package/src/schema/introspect-db.ts +66 -23
  29. package/src/services/EntityFetchService.ts +16 -0
  30. package/src/services/EntityPersistService.ts +88 -12
  31. package/test/generate-drizzle-schema.test.ts +128 -0
  32. package/test/introspect-db-generation.test.ts +5 -5
  33. package/test/property-ordering.test.ts +395 -0
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";
@@ -132,9 +132,6 @@ const toSnakeCase = (str) => {
132
132
  return regExpMatchArray.map((x) => x.toLowerCase()).join("_");
133
133
  };
134
134
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
135
- function getDefaultExportFromCjs(x) {
136
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
137
- }
138
135
  function commonjsRequire(path2) {
139
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.');
140
137
  }
@@ -921,7 +918,23 @@ var object_hash = { exports: {} };
921
918
  }, { buffer: 3, lYpoI2: 11 }] }, {}, [1])(1);
922
919
  });
923
920
  })(object_hash);
924
- 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) {
925
938
  return !!item && typeof item === "object" && !Array.isArray(item);
926
939
  }
927
940
  function isPlainObject(obj) {
@@ -932,13 +945,13 @@ function isPlainObject(obj) {
932
945
  return proto === Object.prototype;
933
946
  }
934
947
  function mergeDeep(target, source, ignoreUndefined = false) {
935
- if (!isObject$6(target)) {
948
+ if (!isObject(target)) {
936
949
  return target;
937
950
  }
938
951
  const output = {
939
952
  ...target
940
953
  };
941
- if (!isObject$6(source)) {
954
+ if (!isObject(source)) {
942
955
  return output;
943
956
  }
944
957
  for (const key in source) {
@@ -979,7 +992,7 @@ function mergeDeep(target, source, ignoreUndefined = false) {
979
992
  } else {
980
993
  output[key] = sourceValue;
981
994
  }
982
- } else if (isObject$6(sourceValue)) {
995
+ } else if (isObject(sourceValue)) {
983
996
  output[key] = sourceValue;
984
997
  } else {
985
998
  output[key] = sourceValue;
@@ -1022,6 +1035,80 @@ function generateForeignKeyName(name) {
1022
1035
  const singularName = snakeCaseName.endsWith("s") ? snakeCaseName.slice(0, -1) : snakeCaseName;
1023
1036
  return `${singularName}_id`;
1024
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
+ }
1025
1112
  function createRelationRef(id, path2) {
1026
1113
  return {
1027
1114
  id,
@@ -1228,6 +1315,17 @@ function sanitizeRelation(relation, sourceCollection) {
1228
1315
  break;
1229
1316
  }
1230
1317
  }
1318
+ if (!isManyToManyInverse && targetCollection.properties) {
1319
+ for (const [propKey, prop] of Object.entries(targetCollection.properties)) {
1320
+ if (prop.type !== "relation") continue;
1321
+ const relProp = prop;
1322
+ const relName = relProp.relationName || propKey;
1323
+ if (relName === newRelation.inverseRelationName && relProp.cardinality === "many" && (relProp.direction === "owning" || !relProp.direction)) {
1324
+ isManyToManyInverse = true;
1325
+ break;
1326
+ }
1327
+ }
1328
+ }
1231
1329
  } catch (e) {
1232
1330
  }
1233
1331
  }
@@ -1351,7 +1449,7 @@ function findRelation(resolvedRelations, key) {
1351
1449
  }
1352
1450
  var logic = { exports: {} };
1353
1451
  (function(module, exports$1) {
1354
- (function(root2, factory) {
1452
+ (function(root, factory) {
1355
1453
  {
1356
1454
  module.exports = factory();
1357
1455
  }
@@ -1719,7 +1817,7 @@ var logic = { exports: {} };
1719
1817
  });
1720
1818
  })(logic);
1721
1819
  const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
1722
- const { hasOwnProperty: hasOwnProperty$a } = Object.prototype;
1820
+ const { hasOwnProperty } = Object.prototype;
1723
1821
  function combineComparators(comparatorA, comparatorB) {
1724
1822
  return function isEqual(a, b, state) {
1725
1823
  return comparatorA(a, b, state) && comparatorB(a, b, state);
@@ -1749,12 +1847,12 @@ function getStrictProperties(object) {
1749
1847
  }
1750
1848
  const hasOwn = (
1751
1849
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1752
- Object.hasOwn || ((object, property) => hasOwnProperty$a.call(object, property))
1850
+ Object.hasOwn || ((object, property) => hasOwnProperty.call(object, property))
1753
1851
  );
1754
1852
  const PREACT_VNODE = "__v";
1755
1853
  const PREACT_OWNER = "__o";
1756
1854
  const REACT_OWNER = "_owner";
1757
- const { getOwnPropertyDescriptor, keys: keys$4 } = Object;
1855
+ const { getOwnPropertyDescriptor, keys } = Object;
1758
1856
  const sameValueEqual = (
1759
1857
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1760
1858
  Object.is || function sameValueEqual2(a, b) {
@@ -1832,9 +1930,9 @@ function areMapsEqual(a, b, state) {
1832
1930
  return true;
1833
1931
  }
1834
1932
  function areObjectsEqual(a, b, state) {
1835
- const properties = keys$4(a);
1933
+ const properties = keys(a);
1836
1934
  let index = properties.length;
1837
- if (keys$4(b).length !== index) {
1935
+ if (keys(b).length !== index) {
1838
1936
  return false;
1839
1937
  }
1840
1938
  while (index-- > 0) {
@@ -2137,982 +2235,6 @@ function createCustomEqual(options = {}) {
2137
2235
  const equals = createCustomInternalComparator ? createCustomInternalComparator(comparator) : createInternalEqualityComparator(comparator);
2138
2236
  return createIsEqual({ circular, comparator, createState, equals, strict });
2139
2237
  }
2140
- function listCacheClear$1() {
2141
- this.__data__ = [];
2142
- this.size = 0;
2143
- }
2144
- var _listCacheClear = listCacheClear$1;
2145
- function eq$2(value, other) {
2146
- return value === other || value !== value && other !== other;
2147
- }
2148
- var eq_1 = eq$2;
2149
- var eq$1 = eq_1;
2150
- function assocIndexOf$4(array, key) {
2151
- var length = array.length;
2152
- while (length--) {
2153
- if (eq$1(array[length][0], key)) {
2154
- return length;
2155
- }
2156
- }
2157
- return -1;
2158
- }
2159
- var _assocIndexOf = assocIndexOf$4;
2160
- var assocIndexOf$3 = _assocIndexOf;
2161
- var arrayProto = Array.prototype;
2162
- var splice = arrayProto.splice;
2163
- function listCacheDelete$1(key) {
2164
- var data = this.__data__, index = assocIndexOf$3(data, key);
2165
- if (index < 0) {
2166
- return false;
2167
- }
2168
- var lastIndex = data.length - 1;
2169
- if (index == lastIndex) {
2170
- data.pop();
2171
- } else {
2172
- splice.call(data, index, 1);
2173
- }
2174
- --this.size;
2175
- return true;
2176
- }
2177
- var _listCacheDelete = listCacheDelete$1;
2178
- var assocIndexOf$2 = _assocIndexOf;
2179
- function listCacheGet$1(key) {
2180
- var data = this.__data__, index = assocIndexOf$2(data, key);
2181
- return index < 0 ? void 0 : data[index][1];
2182
- }
2183
- var _listCacheGet = listCacheGet$1;
2184
- var assocIndexOf$1 = _assocIndexOf;
2185
- function listCacheHas$1(key) {
2186
- return assocIndexOf$1(this.__data__, key) > -1;
2187
- }
2188
- var _listCacheHas = listCacheHas$1;
2189
- var assocIndexOf = _assocIndexOf;
2190
- function listCacheSet$1(key, value) {
2191
- var data = this.__data__, index = assocIndexOf(data, key);
2192
- if (index < 0) {
2193
- ++this.size;
2194
- data.push([key, value]);
2195
- } else {
2196
- data[index][1] = value;
2197
- }
2198
- return this;
2199
- }
2200
- var _listCacheSet = listCacheSet$1;
2201
- var listCacheClear = _listCacheClear, listCacheDelete = _listCacheDelete, listCacheGet = _listCacheGet, listCacheHas = _listCacheHas, listCacheSet = _listCacheSet;
2202
- function ListCache$4(entries) {
2203
- var index = -1, length = entries == null ? 0 : entries.length;
2204
- this.clear();
2205
- while (++index < length) {
2206
- var entry = entries[index];
2207
- this.set(entry[0], entry[1]);
2208
- }
2209
- }
2210
- ListCache$4.prototype.clear = listCacheClear;
2211
- ListCache$4.prototype["delete"] = listCacheDelete;
2212
- ListCache$4.prototype.get = listCacheGet;
2213
- ListCache$4.prototype.has = listCacheHas;
2214
- ListCache$4.prototype.set = listCacheSet;
2215
- var _ListCache = ListCache$4;
2216
- var ListCache$3 = _ListCache;
2217
- function stackClear$1() {
2218
- this.__data__ = new ListCache$3();
2219
- this.size = 0;
2220
- }
2221
- var _stackClear = stackClear$1;
2222
- function stackDelete$1(key) {
2223
- var data = this.__data__, result = data["delete"](key);
2224
- this.size = data.size;
2225
- return result;
2226
- }
2227
- var _stackDelete = stackDelete$1;
2228
- function stackGet$1(key) {
2229
- return this.__data__.get(key);
2230
- }
2231
- var _stackGet = stackGet$1;
2232
- function stackHas$1(key) {
2233
- return this.__data__.has(key);
2234
- }
2235
- var _stackHas = stackHas$1;
2236
- var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
2237
- var _freeGlobal = freeGlobal$1;
2238
- var freeGlobal = _freeGlobal;
2239
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
2240
- var root$8 = freeGlobal || freeSelf || Function("return this")();
2241
- var _root = root$8;
2242
- var root$7 = _root;
2243
- var Symbol$4 = root$7.Symbol;
2244
- var _Symbol = Symbol$4;
2245
- var Symbol$3 = _Symbol;
2246
- var objectProto$c = Object.prototype;
2247
- var hasOwnProperty$9 = objectProto$c.hasOwnProperty;
2248
- var nativeObjectToString$1 = objectProto$c.toString;
2249
- var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
2250
- function getRawTag$1(value) {
2251
- var isOwn = hasOwnProperty$9.call(value, symToStringTag$1), tag = value[symToStringTag$1];
2252
- try {
2253
- value[symToStringTag$1] = void 0;
2254
- var unmasked = true;
2255
- } catch (e) {
2256
- }
2257
- var result = nativeObjectToString$1.call(value);
2258
- if (unmasked) {
2259
- if (isOwn) {
2260
- value[symToStringTag$1] = tag;
2261
- } else {
2262
- delete value[symToStringTag$1];
2263
- }
2264
- }
2265
- return result;
2266
- }
2267
- var _getRawTag = getRawTag$1;
2268
- var objectProto$b = Object.prototype;
2269
- var nativeObjectToString = objectProto$b.toString;
2270
- function objectToString$1(value) {
2271
- return nativeObjectToString.call(value);
2272
- }
2273
- var _objectToString = objectToString$1;
2274
- var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
2275
- var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
2276
- var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
2277
- function baseGetTag$4(value) {
2278
- if (value == null) {
2279
- return value === void 0 ? undefinedTag : nullTag;
2280
- }
2281
- return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
2282
- }
2283
- var _baseGetTag = baseGetTag$4;
2284
- function isObject$5(value) {
2285
- var type = typeof value;
2286
- return value != null && (type == "object" || type == "function");
2287
- }
2288
- var isObject_1 = isObject$5;
2289
- var baseGetTag$3 = _baseGetTag, isObject$4 = isObject_1;
2290
- var asyncTag = "[object AsyncFunction]", funcTag$2 = "[object Function]", genTag$1 = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
2291
- function isFunction$2(value) {
2292
- if (!isObject$4(value)) {
2293
- return false;
2294
- }
2295
- var tag = baseGetTag$3(value);
2296
- return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag || tag == proxyTag;
2297
- }
2298
- var isFunction_1 = isFunction$2;
2299
- var root$6 = _root;
2300
- var coreJsData$1 = root$6["__core-js_shared__"];
2301
- var _coreJsData = coreJsData$1;
2302
- var coreJsData = _coreJsData;
2303
- var maskSrcKey = function() {
2304
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
2305
- return uid ? "Symbol(src)_1." + uid : "";
2306
- }();
2307
- function isMasked$1(func) {
2308
- return !!maskSrcKey && maskSrcKey in func;
2309
- }
2310
- var _isMasked = isMasked$1;
2311
- var funcProto$1 = Function.prototype;
2312
- var funcToString$1 = funcProto$1.toString;
2313
- function toSource$2(func) {
2314
- if (func != null) {
2315
- try {
2316
- return funcToString$1.call(func);
2317
- } catch (e) {
2318
- }
2319
- try {
2320
- return func + "";
2321
- } catch (e) {
2322
- }
2323
- }
2324
- return "";
2325
- }
2326
- var _toSource = toSource$2;
2327
- var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$3 = isObject_1, toSource$1 = _toSource;
2328
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
2329
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
2330
- var funcProto = Function.prototype, objectProto$a = Object.prototype;
2331
- var funcToString = funcProto.toString;
2332
- var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
2333
- var reIsNative = RegExp(
2334
- "^" + funcToString.call(hasOwnProperty$8).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
2335
- );
2336
- function baseIsNative$1(value) {
2337
- if (!isObject$3(value) || isMasked(value)) {
2338
- return false;
2339
- }
2340
- var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
2341
- return pattern.test(toSource$1(value));
2342
- }
2343
- var _baseIsNative = baseIsNative$1;
2344
- function getValue$1(object, key) {
2345
- return object == null ? void 0 : object[key];
2346
- }
2347
- var _getValue = getValue$1;
2348
- var baseIsNative = _baseIsNative, getValue = _getValue;
2349
- function getNative$7(object, key) {
2350
- var value = getValue(object, key);
2351
- return baseIsNative(value) ? value : void 0;
2352
- }
2353
- var _getNative = getNative$7;
2354
- var getNative$6 = _getNative, root$5 = _root;
2355
- var Map$4 = getNative$6(root$5, "Map");
2356
- var _Map = Map$4;
2357
- var getNative$5 = _getNative;
2358
- var nativeCreate$4 = getNative$5(Object, "create");
2359
- var _nativeCreate = nativeCreate$4;
2360
- var nativeCreate$3 = _nativeCreate;
2361
- function hashClear$1() {
2362
- this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
2363
- this.size = 0;
2364
- }
2365
- var _hashClear = hashClear$1;
2366
- function hashDelete$1(key) {
2367
- var result = this.has(key) && delete this.__data__[key];
2368
- this.size -= result ? 1 : 0;
2369
- return result;
2370
- }
2371
- var _hashDelete = hashDelete$1;
2372
- var nativeCreate$2 = _nativeCreate;
2373
- var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
2374
- var objectProto$9 = Object.prototype;
2375
- var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
2376
- function hashGet$1(key) {
2377
- var data = this.__data__;
2378
- if (nativeCreate$2) {
2379
- var result = data[key];
2380
- return result === HASH_UNDEFINED$1 ? void 0 : result;
2381
- }
2382
- return hasOwnProperty$7.call(data, key) ? data[key] : void 0;
2383
- }
2384
- var _hashGet = hashGet$1;
2385
- var nativeCreate$1 = _nativeCreate;
2386
- var objectProto$8 = Object.prototype;
2387
- var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
2388
- function hashHas$1(key) {
2389
- var data = this.__data__;
2390
- return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty$6.call(data, key);
2391
- }
2392
- var _hashHas = hashHas$1;
2393
- var nativeCreate = _nativeCreate;
2394
- var HASH_UNDEFINED = "__lodash_hash_undefined__";
2395
- function hashSet$1(key, value) {
2396
- var data = this.__data__;
2397
- this.size += this.has(key) ? 0 : 1;
2398
- data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
2399
- return this;
2400
- }
2401
- var _hashSet = hashSet$1;
2402
- var hashClear = _hashClear, hashDelete = _hashDelete, hashGet = _hashGet, hashHas = _hashHas, hashSet = _hashSet;
2403
- function Hash$1(entries) {
2404
- var index = -1, length = entries == null ? 0 : entries.length;
2405
- this.clear();
2406
- while (++index < length) {
2407
- var entry = entries[index];
2408
- this.set(entry[0], entry[1]);
2409
- }
2410
- }
2411
- Hash$1.prototype.clear = hashClear;
2412
- Hash$1.prototype["delete"] = hashDelete;
2413
- Hash$1.prototype.get = hashGet;
2414
- Hash$1.prototype.has = hashHas;
2415
- Hash$1.prototype.set = hashSet;
2416
- var _Hash = Hash$1;
2417
- var Hash = _Hash, ListCache$2 = _ListCache, Map$3 = _Map;
2418
- function mapCacheClear$1() {
2419
- this.size = 0;
2420
- this.__data__ = {
2421
- "hash": new Hash(),
2422
- "map": new (Map$3 || ListCache$2)(),
2423
- "string": new Hash()
2424
- };
2425
- }
2426
- var _mapCacheClear = mapCacheClear$1;
2427
- function isKeyable$1(value) {
2428
- var type = typeof value;
2429
- return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
2430
- }
2431
- var _isKeyable = isKeyable$1;
2432
- var isKeyable = _isKeyable;
2433
- function getMapData$4(map, key) {
2434
- var data = map.__data__;
2435
- return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
2436
- }
2437
- var _getMapData = getMapData$4;
2438
- var getMapData$3 = _getMapData;
2439
- function mapCacheDelete$1(key) {
2440
- var result = getMapData$3(this, key)["delete"](key);
2441
- this.size -= result ? 1 : 0;
2442
- return result;
2443
- }
2444
- var _mapCacheDelete = mapCacheDelete$1;
2445
- var getMapData$2 = _getMapData;
2446
- function mapCacheGet$1(key) {
2447
- return getMapData$2(this, key).get(key);
2448
- }
2449
- var _mapCacheGet = mapCacheGet$1;
2450
- var getMapData$1 = _getMapData;
2451
- function mapCacheHas$1(key) {
2452
- return getMapData$1(this, key).has(key);
2453
- }
2454
- var _mapCacheHas = mapCacheHas$1;
2455
- var getMapData = _getMapData;
2456
- function mapCacheSet$1(key, value) {
2457
- var data = getMapData(this, key), size = data.size;
2458
- data.set(key, value);
2459
- this.size += data.size == size ? 0 : 1;
2460
- return this;
2461
- }
2462
- var _mapCacheSet = mapCacheSet$1;
2463
- var mapCacheClear = _mapCacheClear, mapCacheDelete = _mapCacheDelete, mapCacheGet = _mapCacheGet, mapCacheHas = _mapCacheHas, mapCacheSet = _mapCacheSet;
2464
- function MapCache$1(entries) {
2465
- var index = -1, length = entries == null ? 0 : entries.length;
2466
- this.clear();
2467
- while (++index < length) {
2468
- var entry = entries[index];
2469
- this.set(entry[0], entry[1]);
2470
- }
2471
- }
2472
- MapCache$1.prototype.clear = mapCacheClear;
2473
- MapCache$1.prototype["delete"] = mapCacheDelete;
2474
- MapCache$1.prototype.get = mapCacheGet;
2475
- MapCache$1.prototype.has = mapCacheHas;
2476
- MapCache$1.prototype.set = mapCacheSet;
2477
- var _MapCache = MapCache$1;
2478
- var ListCache$1 = _ListCache, Map$2 = _Map, MapCache = _MapCache;
2479
- var LARGE_ARRAY_SIZE = 200;
2480
- function stackSet$1(key, value) {
2481
- var data = this.__data__;
2482
- if (data instanceof ListCache$1) {
2483
- var pairs = data.__data__;
2484
- if (!Map$2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
2485
- pairs.push([key, value]);
2486
- this.size = ++data.size;
2487
- return this;
2488
- }
2489
- data = this.__data__ = new MapCache(pairs);
2490
- }
2491
- data.set(key, value);
2492
- this.size = data.size;
2493
- return this;
2494
- }
2495
- var _stackSet = stackSet$1;
2496
- var ListCache = _ListCache, stackClear = _stackClear, stackDelete = _stackDelete, stackGet = _stackGet, stackHas = _stackHas, stackSet = _stackSet;
2497
- function Stack$1(entries) {
2498
- var data = this.__data__ = new ListCache(entries);
2499
- this.size = data.size;
2500
- }
2501
- Stack$1.prototype.clear = stackClear;
2502
- Stack$1.prototype["delete"] = stackDelete;
2503
- Stack$1.prototype.get = stackGet;
2504
- Stack$1.prototype.has = stackHas;
2505
- Stack$1.prototype.set = stackSet;
2506
- var _Stack = Stack$1;
2507
- function arrayEach$1(array, iteratee) {
2508
- var index = -1, length = array == null ? 0 : array.length;
2509
- while (++index < length) {
2510
- if (iteratee(array[index], index, array) === false) {
2511
- break;
2512
- }
2513
- }
2514
- return array;
2515
- }
2516
- var _arrayEach = arrayEach$1;
2517
- var getNative$4 = _getNative;
2518
- var defineProperty$1 = function() {
2519
- try {
2520
- var func = getNative$4(Object, "defineProperty");
2521
- func({}, "", {});
2522
- return func;
2523
- } catch (e) {
2524
- }
2525
- }();
2526
- var _defineProperty = defineProperty$1;
2527
- var defineProperty = _defineProperty;
2528
- function baseAssignValue$2(object, key, value) {
2529
- if (key == "__proto__" && defineProperty) {
2530
- defineProperty(object, key, {
2531
- "configurable": true,
2532
- "enumerable": true,
2533
- "value": value,
2534
- "writable": true
2535
- });
2536
- } else {
2537
- object[key] = value;
2538
- }
2539
- }
2540
- var _baseAssignValue = baseAssignValue$2;
2541
- var baseAssignValue$1 = _baseAssignValue, eq = eq_1;
2542
- var objectProto$7 = Object.prototype;
2543
- var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
2544
- function assignValue$2(object, key, value) {
2545
- var objValue = object[key];
2546
- if (!(hasOwnProperty$5.call(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) {
2547
- baseAssignValue$1(object, key, value);
2548
- }
2549
- }
2550
- var _assignValue = assignValue$2;
2551
- var assignValue$1 = _assignValue, baseAssignValue = _baseAssignValue;
2552
- function copyObject$4(source, props, object, customizer) {
2553
- var isNew = !object;
2554
- object || (object = {});
2555
- var index = -1, length = props.length;
2556
- while (++index < length) {
2557
- var key = props[index];
2558
- var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
2559
- if (newValue === void 0) {
2560
- newValue = source[key];
2561
- }
2562
- if (isNew) {
2563
- baseAssignValue(object, key, newValue);
2564
- } else {
2565
- assignValue$1(object, key, newValue);
2566
- }
2567
- }
2568
- return object;
2569
- }
2570
- var _copyObject = copyObject$4;
2571
- function baseTimes$1(n, iteratee) {
2572
- var index = -1, result = Array(n);
2573
- while (++index < n) {
2574
- result[index] = iteratee(index);
2575
- }
2576
- return result;
2577
- }
2578
- var _baseTimes = baseTimes$1;
2579
- function isObjectLike$5(value) {
2580
- return value != null && typeof value == "object";
2581
- }
2582
- var isObjectLike_1 = isObjectLike$5;
2583
- var baseGetTag$2 = _baseGetTag, isObjectLike$4 = isObjectLike_1;
2584
- var argsTag$2 = "[object Arguments]";
2585
- function baseIsArguments$1(value) {
2586
- return isObjectLike$4(value) && baseGetTag$2(value) == argsTag$2;
2587
- }
2588
- var _baseIsArguments = baseIsArguments$1;
2589
- var baseIsArguments = _baseIsArguments, isObjectLike$3 = isObjectLike_1;
2590
- var objectProto$6 = Object.prototype;
2591
- var hasOwnProperty$4 = objectProto$6.hasOwnProperty;
2592
- var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
2593
- var isArguments$1 = baseIsArguments(/* @__PURE__ */ function() {
2594
- return arguments;
2595
- }()) ? baseIsArguments : function(value) {
2596
- return isObjectLike$3(value) && hasOwnProperty$4.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
2597
- };
2598
- var isArguments_1 = isArguments$1;
2599
- var isArray$3 = Array.isArray;
2600
- var isArray_1 = isArray$3;
2601
- var isBuffer$2 = { exports: {} };
2602
- function stubFalse() {
2603
- return false;
2604
- }
2605
- var stubFalse_1 = stubFalse;
2606
- isBuffer$2.exports;
2607
- (function(module, exports$1) {
2608
- var root2 = _root, stubFalse2 = stubFalse_1;
2609
- var freeExports = exports$1 && !exports$1.nodeType && exports$1;
2610
- var freeModule = freeExports && true && module && !module.nodeType && module;
2611
- var moduleExports = freeModule && freeModule.exports === freeExports;
2612
- var Buffer = moduleExports ? root2.Buffer : void 0;
2613
- var nativeIsBuffer = Buffer ? Buffer.isBuffer : void 0;
2614
- var isBuffer2 = nativeIsBuffer || stubFalse2;
2615
- module.exports = isBuffer2;
2616
- })(isBuffer$2, isBuffer$2.exports);
2617
- var isBufferExports = isBuffer$2.exports;
2618
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
2619
- var reIsUint = /^(?:0|[1-9]\d*)$/;
2620
- function isIndex$1(value, length) {
2621
- var type = typeof value;
2622
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
2623
- return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
2624
- }
2625
- var _isIndex = isIndex$1;
2626
- var MAX_SAFE_INTEGER = 9007199254740991;
2627
- function isLength$2(value) {
2628
- return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2629
- }
2630
- var isLength_1 = isLength$2;
2631
- var baseGetTag$1 = _baseGetTag, isLength$1 = isLength_1, isObjectLike$2 = isObjectLike_1;
2632
- 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]";
2633
- 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]";
2634
- var typedArrayTags = {};
2635
- 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;
2636
- 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;
2637
- function baseIsTypedArray$1(value) {
2638
- return isObjectLike$2(value) && isLength$1(value.length) && !!typedArrayTags[baseGetTag$1(value)];
2639
- }
2640
- var _baseIsTypedArray = baseIsTypedArray$1;
2641
- function baseUnary$3(func) {
2642
- return function(value) {
2643
- return func(value);
2644
- };
2645
- }
2646
- var _baseUnary = baseUnary$3;
2647
- var _nodeUtil = { exports: {} };
2648
- _nodeUtil.exports;
2649
- (function(module, exports$1) {
2650
- var freeGlobal2 = _freeGlobal;
2651
- var freeExports = exports$1 && !exports$1.nodeType && exports$1;
2652
- var freeModule = freeExports && true && module && !module.nodeType && module;
2653
- var moduleExports = freeModule && freeModule.exports === freeExports;
2654
- var freeProcess = moduleExports && freeGlobal2.process;
2655
- var nodeUtil2 = function() {
2656
- try {
2657
- var types = freeModule && freeModule.require && freeModule.require("util").types;
2658
- if (types) {
2659
- return types;
2660
- }
2661
- return freeProcess && freeProcess.binding && freeProcess.binding("util");
2662
- } catch (e) {
2663
- }
2664
- }();
2665
- module.exports = nodeUtil2;
2666
- })(_nodeUtil, _nodeUtil.exports);
2667
- var _nodeUtilExports = _nodeUtil.exports;
2668
- var baseIsTypedArray = _baseIsTypedArray, baseUnary$2 = _baseUnary, nodeUtil$2 = _nodeUtilExports;
2669
- var nodeIsTypedArray = nodeUtil$2 && nodeUtil$2.isTypedArray;
2670
- var isTypedArray$1 = nodeIsTypedArray ? baseUnary$2(nodeIsTypedArray) : baseIsTypedArray;
2671
- var isTypedArray_1 = isTypedArray$1;
2672
- var baseTimes = _baseTimes, isArguments = isArguments_1, isArray$2 = isArray_1, isBuffer$1 = isBufferExports, isIndex = _isIndex, isTypedArray = isTypedArray_1;
2673
- var objectProto$5 = Object.prototype;
2674
- var hasOwnProperty$3 = objectProto$5.hasOwnProperty;
2675
- function arrayLikeKeys$2(value, inherited) {
2676
- 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;
2677
- for (var key in value) {
2678
- if ((inherited || hasOwnProperty$3.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
2679
- (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
2680
- isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
2681
- isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
2682
- isIndex(key, length)))) {
2683
- result.push(key);
2684
- }
2685
- }
2686
- return result;
2687
- }
2688
- var _arrayLikeKeys = arrayLikeKeys$2;
2689
- var objectProto$4 = Object.prototype;
2690
- function isPrototype$3(value) {
2691
- var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$4;
2692
- return value === proto;
2693
- }
2694
- var _isPrototype = isPrototype$3;
2695
- function overArg$2(func, transform) {
2696
- return function(arg) {
2697
- return func(transform(arg));
2698
- };
2699
- }
2700
- var _overArg = overArg$2;
2701
- var overArg$1 = _overArg;
2702
- var nativeKeys$1 = overArg$1(Object.keys, Object);
2703
- var _nativeKeys = nativeKeys$1;
2704
- var isPrototype$2 = _isPrototype, nativeKeys = _nativeKeys;
2705
- var objectProto$3 = Object.prototype;
2706
- var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
2707
- function baseKeys$1(object) {
2708
- if (!isPrototype$2(object)) {
2709
- return nativeKeys(object);
2710
- }
2711
- var result = [];
2712
- for (var key in Object(object)) {
2713
- if (hasOwnProperty$2.call(object, key) && key != "constructor") {
2714
- result.push(key);
2715
- }
2716
- }
2717
- return result;
2718
- }
2719
- var _baseKeys = baseKeys$1;
2720
- var isFunction = isFunction_1, isLength = isLength_1;
2721
- function isArrayLike$2(value) {
2722
- return value != null && isLength(value.length) && !isFunction(value);
2723
- }
2724
- var isArrayLike_1 = isArrayLike$2;
2725
- var arrayLikeKeys$1 = _arrayLikeKeys, baseKeys = _baseKeys, isArrayLike$1 = isArrayLike_1;
2726
- function keys$3(object) {
2727
- return isArrayLike$1(object) ? arrayLikeKeys$1(object) : baseKeys(object);
2728
- }
2729
- var keys_1 = keys$3;
2730
- var copyObject$3 = _copyObject, keys$2 = keys_1;
2731
- function baseAssign$1(object, source) {
2732
- return object && copyObject$3(source, keys$2(source), object);
2733
- }
2734
- var _baseAssign = baseAssign$1;
2735
- function nativeKeysIn$1(object) {
2736
- var result = [];
2737
- if (object != null) {
2738
- for (var key in Object(object)) {
2739
- result.push(key);
2740
- }
2741
- }
2742
- return result;
2743
- }
2744
- var _nativeKeysIn = nativeKeysIn$1;
2745
- var isObject$2 = isObject_1, isPrototype$1 = _isPrototype, nativeKeysIn = _nativeKeysIn;
2746
- var objectProto$2 = Object.prototype;
2747
- var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
2748
- function baseKeysIn$1(object) {
2749
- if (!isObject$2(object)) {
2750
- return nativeKeysIn(object);
2751
- }
2752
- var isProto = isPrototype$1(object), result = [];
2753
- for (var key in object) {
2754
- if (!(key == "constructor" && (isProto || !hasOwnProperty$1.call(object, key)))) {
2755
- result.push(key);
2756
- }
2757
- }
2758
- return result;
2759
- }
2760
- var _baseKeysIn = baseKeysIn$1;
2761
- var arrayLikeKeys = _arrayLikeKeys, baseKeysIn = _baseKeysIn, isArrayLike = isArrayLike_1;
2762
- function keysIn$3(object) {
2763
- return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
2764
- }
2765
- var keysIn_1 = keysIn$3;
2766
- var copyObject$2 = _copyObject, keysIn$2 = keysIn_1;
2767
- function baseAssignIn$1(object, source) {
2768
- return object && copyObject$2(source, keysIn$2(source), object);
2769
- }
2770
- var _baseAssignIn = baseAssignIn$1;
2771
- var _cloneBuffer = { exports: {} };
2772
- _cloneBuffer.exports;
2773
- (function(module, exports$1) {
2774
- var root2 = _root;
2775
- var freeExports = exports$1 && !exports$1.nodeType && exports$1;
2776
- var freeModule = freeExports && true && module && !module.nodeType && module;
2777
- var moduleExports = freeModule && freeModule.exports === freeExports;
2778
- var Buffer = moduleExports ? root2.Buffer : void 0, allocUnsafe = Buffer ? Buffer.allocUnsafe : void 0;
2779
- function cloneBuffer2(buffer, isDeep) {
2780
- if (isDeep) {
2781
- return buffer.slice();
2782
- }
2783
- var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
2784
- buffer.copy(result);
2785
- return result;
2786
- }
2787
- module.exports = cloneBuffer2;
2788
- })(_cloneBuffer, _cloneBuffer.exports);
2789
- var _cloneBufferExports = _cloneBuffer.exports;
2790
- function copyArray$1(source, array) {
2791
- var index = -1, length = source.length;
2792
- array || (array = Array(length));
2793
- while (++index < length) {
2794
- array[index] = source[index];
2795
- }
2796
- return array;
2797
- }
2798
- var _copyArray = copyArray$1;
2799
- function arrayFilter$1(array, predicate) {
2800
- var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
2801
- while (++index < length) {
2802
- var value = array[index];
2803
- if (predicate(value, index, array)) {
2804
- result[resIndex++] = value;
2805
- }
2806
- }
2807
- return result;
2808
- }
2809
- var _arrayFilter = arrayFilter$1;
2810
- function stubArray$2() {
2811
- return [];
2812
- }
2813
- var stubArray_1 = stubArray$2;
2814
- var arrayFilter = _arrayFilter, stubArray$1 = stubArray_1;
2815
- var objectProto$1 = Object.prototype;
2816
- var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
2817
- var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
2818
- var getSymbols$3 = !nativeGetSymbols$1 ? stubArray$1 : function(object) {
2819
- if (object == null) {
2820
- return [];
2821
- }
2822
- object = Object(object);
2823
- return arrayFilter(nativeGetSymbols$1(object), function(symbol) {
2824
- return propertyIsEnumerable.call(object, symbol);
2825
- });
2826
- };
2827
- var _getSymbols = getSymbols$3;
2828
- var copyObject$1 = _copyObject, getSymbols$2 = _getSymbols;
2829
- function copySymbols$1(source, object) {
2830
- return copyObject$1(source, getSymbols$2(source), object);
2831
- }
2832
- var _copySymbols = copySymbols$1;
2833
- function arrayPush$2(array, values) {
2834
- var index = -1, length = values.length, offset = array.length;
2835
- while (++index < length) {
2836
- array[offset + index] = values[index];
2837
- }
2838
- return array;
2839
- }
2840
- var _arrayPush = arrayPush$2;
2841
- var overArg = _overArg;
2842
- var getPrototype$2 = overArg(Object.getPrototypeOf, Object);
2843
- var _getPrototype = getPrototype$2;
2844
- var arrayPush$1 = _arrayPush, getPrototype$1 = _getPrototype, getSymbols$1 = _getSymbols, stubArray = stubArray_1;
2845
- var nativeGetSymbols = Object.getOwnPropertySymbols;
2846
- var getSymbolsIn$2 = !nativeGetSymbols ? stubArray : function(object) {
2847
- var result = [];
2848
- while (object) {
2849
- arrayPush$1(result, getSymbols$1(object));
2850
- object = getPrototype$1(object);
2851
- }
2852
- return result;
2853
- };
2854
- var _getSymbolsIn = getSymbolsIn$2;
2855
- var copyObject = _copyObject, getSymbolsIn$1 = _getSymbolsIn;
2856
- function copySymbolsIn$1(source, object) {
2857
- return copyObject(source, getSymbolsIn$1(source), object);
2858
- }
2859
- var _copySymbolsIn = copySymbolsIn$1;
2860
- var arrayPush = _arrayPush, isArray$1 = isArray_1;
2861
- function baseGetAllKeys$2(object, keysFunc, symbolsFunc) {
2862
- var result = keysFunc(object);
2863
- return isArray$1(object) ? result : arrayPush(result, symbolsFunc(object));
2864
- }
2865
- var _baseGetAllKeys = baseGetAllKeys$2;
2866
- var baseGetAllKeys$1 = _baseGetAllKeys, getSymbols = _getSymbols, keys$1 = keys_1;
2867
- function getAllKeys$1(object) {
2868
- return baseGetAllKeys$1(object, keys$1, getSymbols);
2869
- }
2870
- var _getAllKeys = getAllKeys$1;
2871
- var baseGetAllKeys = _baseGetAllKeys, getSymbolsIn = _getSymbolsIn, keysIn$1 = keysIn_1;
2872
- function getAllKeysIn$1(object) {
2873
- return baseGetAllKeys(object, keysIn$1, getSymbolsIn);
2874
- }
2875
- var _getAllKeysIn = getAllKeysIn$1;
2876
- var getNative$3 = _getNative, root$4 = _root;
2877
- var DataView$1 = getNative$3(root$4, "DataView");
2878
- var _DataView = DataView$1;
2879
- var getNative$2 = _getNative, root$3 = _root;
2880
- var Promise$2 = getNative$2(root$3, "Promise");
2881
- var _Promise = Promise$2;
2882
- var getNative$1 = _getNative, root$2 = _root;
2883
- var Set$2 = getNative$1(root$2, "Set");
2884
- var _Set = Set$2;
2885
- var getNative = _getNative, root$1 = _root;
2886
- var WeakMap$2 = getNative(root$1, "WeakMap");
2887
- var _WeakMap = WeakMap$2;
2888
- var DataView = _DataView, Map$1 = _Map, Promise$1 = _Promise, Set$1 = _Set, WeakMap$1 = _WeakMap, baseGetTag = _baseGetTag, toSource = _toSource;
2889
- var mapTag$3 = "[object Map]", objectTag$1 = "[object Object]", promiseTag = "[object Promise]", setTag$3 = "[object Set]", weakMapTag$1 = "[object WeakMap]";
2890
- var dataViewTag$2 = "[object DataView]";
2891
- var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$1), weakMapCtorString = toSource(WeakMap$1);
2892
- var getTag$3 = baseGetTag;
2893
- 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) {
2894
- getTag$3 = function(value) {
2895
- var result = baseGetTag(value), Ctor = result == objectTag$1 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
2896
- if (ctorString) {
2897
- switch (ctorString) {
2898
- case dataViewCtorString:
2899
- return dataViewTag$2;
2900
- case mapCtorString:
2901
- return mapTag$3;
2902
- case promiseCtorString:
2903
- return promiseTag;
2904
- case setCtorString:
2905
- return setTag$3;
2906
- case weakMapCtorString:
2907
- return weakMapTag$1;
2908
- }
2909
- }
2910
- return result;
2911
- };
2912
- }
2913
- var _getTag = getTag$3;
2914
- var objectProto = Object.prototype;
2915
- var hasOwnProperty = objectProto.hasOwnProperty;
2916
- function initCloneArray$1(array) {
2917
- var length = array.length, result = new array.constructor(length);
2918
- if (length && typeof array[0] == "string" && hasOwnProperty.call(array, "index")) {
2919
- result.index = array.index;
2920
- result.input = array.input;
2921
- }
2922
- return result;
2923
- }
2924
- var _initCloneArray = initCloneArray$1;
2925
- var root = _root;
2926
- var Uint8Array$2 = root.Uint8Array;
2927
- var _Uint8Array = Uint8Array$2;
2928
- var Uint8Array$1 = _Uint8Array;
2929
- function cloneArrayBuffer$3(arrayBuffer) {
2930
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
2931
- new Uint8Array$1(result).set(new Uint8Array$1(arrayBuffer));
2932
- return result;
2933
- }
2934
- var _cloneArrayBuffer = cloneArrayBuffer$3;
2935
- var cloneArrayBuffer$2 = _cloneArrayBuffer;
2936
- function cloneDataView$1(dataView, isDeep) {
2937
- var buffer = isDeep ? cloneArrayBuffer$2(dataView.buffer) : dataView.buffer;
2938
- return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
2939
- }
2940
- var _cloneDataView = cloneDataView$1;
2941
- var reFlags = /\w*$/;
2942
- function cloneRegExp$1(regexp) {
2943
- var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
2944
- result.lastIndex = regexp.lastIndex;
2945
- return result;
2946
- }
2947
- var _cloneRegExp = cloneRegExp$1;
2948
- var Symbol$1 = _Symbol;
2949
- var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
2950
- function cloneSymbol$1(symbol) {
2951
- return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
2952
- }
2953
- var _cloneSymbol = cloneSymbol$1;
2954
- var cloneArrayBuffer$1 = _cloneArrayBuffer;
2955
- function cloneTypedArray$1(typedArray, isDeep) {
2956
- var buffer = isDeep ? cloneArrayBuffer$1(typedArray.buffer) : typedArray.buffer;
2957
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
2958
- }
2959
- var _cloneTypedArray = cloneTypedArray$1;
2960
- var cloneArrayBuffer = _cloneArrayBuffer, cloneDataView = _cloneDataView, cloneRegExp = _cloneRegExp, cloneSymbol = _cloneSymbol, cloneTypedArray = _cloneTypedArray;
2961
- 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]";
2962
- 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]";
2963
- function initCloneByTag$1(object, tag, isDeep) {
2964
- var Ctor = object.constructor;
2965
- switch (tag) {
2966
- case arrayBufferTag$1:
2967
- return cloneArrayBuffer(object);
2968
- case boolTag$1:
2969
- case dateTag$1:
2970
- return new Ctor(+object);
2971
- case dataViewTag$1:
2972
- return cloneDataView(object, isDeep);
2973
- case float32Tag$1:
2974
- case float64Tag$1:
2975
- case int8Tag$1:
2976
- case int16Tag$1:
2977
- case int32Tag$1:
2978
- case uint8Tag$1:
2979
- case uint8ClampedTag$1:
2980
- case uint16Tag$1:
2981
- case uint32Tag$1:
2982
- return cloneTypedArray(object, isDeep);
2983
- case mapTag$2:
2984
- return new Ctor();
2985
- case numberTag$1:
2986
- case stringTag$1:
2987
- return new Ctor(object);
2988
- case regexpTag$1:
2989
- return cloneRegExp(object);
2990
- case setTag$2:
2991
- return new Ctor();
2992
- case symbolTag$1:
2993
- return cloneSymbol(object);
2994
- }
2995
- }
2996
- var _initCloneByTag = initCloneByTag$1;
2997
- var isObject$1 = isObject_1;
2998
- var objectCreate = Object.create;
2999
- var baseCreate$1 = /* @__PURE__ */ function() {
3000
- function object() {
3001
- }
3002
- return function(proto) {
3003
- if (!isObject$1(proto)) {
3004
- return {};
3005
- }
3006
- if (objectCreate) {
3007
- return objectCreate(proto);
3008
- }
3009
- object.prototype = proto;
3010
- var result = new object();
3011
- object.prototype = void 0;
3012
- return result;
3013
- };
3014
- }();
3015
- var _baseCreate = baseCreate$1;
3016
- var baseCreate = _baseCreate, getPrototype = _getPrototype, isPrototype = _isPrototype;
3017
- function initCloneObject$1(object) {
3018
- return typeof object.constructor == "function" && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
3019
- }
3020
- var _initCloneObject = initCloneObject$1;
3021
- var getTag$2 = _getTag, isObjectLike$1 = isObjectLike_1;
3022
- var mapTag$1 = "[object Map]";
3023
- function baseIsMap$1(value) {
3024
- return isObjectLike$1(value) && getTag$2(value) == mapTag$1;
3025
- }
3026
- var _baseIsMap = baseIsMap$1;
3027
- var baseIsMap = _baseIsMap, baseUnary$1 = _baseUnary, nodeUtil$1 = _nodeUtilExports;
3028
- var nodeIsMap = nodeUtil$1 && nodeUtil$1.isMap;
3029
- var isMap$1 = nodeIsMap ? baseUnary$1(nodeIsMap) : baseIsMap;
3030
- var isMap_1 = isMap$1;
3031
- var getTag$1 = _getTag, isObjectLike = isObjectLike_1;
3032
- var setTag$1 = "[object Set]";
3033
- function baseIsSet$1(value) {
3034
- return isObjectLike(value) && getTag$1(value) == setTag$1;
3035
- }
3036
- var _baseIsSet = baseIsSet$1;
3037
- var baseIsSet = _baseIsSet, baseUnary = _baseUnary, nodeUtil = _nodeUtilExports;
3038
- var nodeIsSet = nodeUtil && nodeUtil.isSet;
3039
- var isSet$1 = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
3040
- var isSet_1 = isSet$1;
3041
- 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;
3042
- var CLONE_DEEP_FLAG$1 = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG$1 = 4;
3043
- 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]";
3044
- 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]";
3045
- var cloneableTags = {};
3046
- 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;
3047
- cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
3048
- function baseClone$1(value, bitmask, customizer, key, object, stack) {
3049
- var result, isDeep = bitmask & CLONE_DEEP_FLAG$1, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG$1;
3050
- if (customizer) {
3051
- result = object ? customizer(value, key, object, stack) : customizer(value);
3052
- }
3053
- if (result !== void 0) {
3054
- return result;
3055
- }
3056
- if (!isObject(value)) {
3057
- return value;
3058
- }
3059
- var isArr = isArray(value);
3060
- if (isArr) {
3061
- result = initCloneArray(value);
3062
- if (!isDeep) {
3063
- return copyArray(value, result);
3064
- }
3065
- } else {
3066
- var tag = getTag(value), isFunc = tag == funcTag || tag == genTag;
3067
- if (isBuffer(value)) {
3068
- return cloneBuffer(value, isDeep);
3069
- }
3070
- if (tag == objectTag || tag == argsTag || isFunc && !object) {
3071
- result = isFlat || isFunc ? {} : initCloneObject(value);
3072
- if (!isDeep) {
3073
- return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value));
3074
- }
3075
- } else {
3076
- if (!cloneableTags[tag]) {
3077
- return object ? value : {};
3078
- }
3079
- result = initCloneByTag(value, tag, isDeep);
3080
- }
3081
- }
3082
- stack || (stack = new Stack());
3083
- var stacked = stack.get(value);
3084
- if (stacked) {
3085
- return stacked;
3086
- }
3087
- stack.set(value, result);
3088
- if (isSet(value)) {
3089
- value.forEach(function(subValue) {
3090
- result.add(baseClone$1(subValue, bitmask, customizer, subValue, value, stack));
3091
- });
3092
- } else if (isMap(value)) {
3093
- value.forEach(function(subValue, key2) {
3094
- result.set(key2, baseClone$1(subValue, bitmask, customizer, key2, value, stack));
3095
- });
3096
- }
3097
- var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys;
3098
- var props = isArr ? void 0 : keysFunc(value);
3099
- arrayEach(props || value, function(subValue, key2) {
3100
- if (props) {
3101
- key2 = subValue;
3102
- subValue = value[key2];
3103
- }
3104
- assignValue(result, key2, baseClone$1(subValue, bitmask, customizer, key2, value, stack));
3105
- });
3106
- return result;
3107
- }
3108
- var _baseClone = baseClone$1;
3109
- var baseClone = _baseClone;
3110
- var CLONE_DEEP_FLAG = 1, CLONE_SYMBOLS_FLAG = 4;
3111
- function cloneDeep(value) {
3112
- return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
3113
- }
3114
- var cloneDeep_1 = cloneDeep;
3115
- const cloneDeep$1 = /* @__PURE__ */ getDefaultExportFromCjs(cloneDeep_1);
3116
2238
  class CollectionRegistry {
3117
2239
  // Normalized runtime layer (used by Data Grid / UI)
3118
2240
  collectionsByTableName = /* @__PURE__ */ new Map();
@@ -3160,7 +2282,7 @@ class CollectionRegistry {
3160
2282
  ...c
3161
2283
  }));
3162
2284
  normalizedCollections.forEach((c, index) => {
3163
- const raw = cloneDeep$1(collections[index]);
2285
+ const raw = deepClone(collections[index]);
3164
2286
  this.rootCollections.push(c);
3165
2287
  this.rawRootCollections.push(raw);
3166
2288
  const normalized = this.normalizeCollection(c);
@@ -3180,7 +2302,7 @@ class CollectionRegistry {
3180
2302
  if (!subCollection) return;
3181
2303
  this._registerRecursively(this.normalizeCollection({
3182
2304
  ...subCollection
3183
- }), cloneDeep$1(subCollection));
2305
+ }), deepClone(subCollection));
3184
2306
  });
3185
2307
  }
3186
2308
  });
@@ -3188,7 +2310,7 @@ class CollectionRegistry {
3188
2310
  return true;
3189
2311
  }
3190
2312
  register(collection, rawCollection) {
3191
- const raw = rawCollection ? cloneDeep$1(rawCollection) : cloneDeep$1(collection);
2313
+ const raw = rawCollection ? deepClone(rawCollection) : deepClone(collection);
3192
2314
  this.rootCollections.push(collection);
3193
2315
  this.rawRootCollections.push(raw);
3194
2316
  this._registerRecursively(collection, raw);
@@ -3212,7 +2334,7 @@ class CollectionRegistry {
3212
2334
  if (!subCollection) return;
3213
2335
  this._registerRecursively(this.normalizeCollection({
3214
2336
  ...subCollection
3215
- }), cloneDeep$1(subCollection));
2337
+ }), deepClone(subCollection));
3216
2338
  });
3217
2339
  }
3218
2340
  }
@@ -3673,7 +2795,7 @@ class DrizzleConditionBuilder {
3673
2795
  static buildSingleFilterCondition(column, op, value) {
3674
2796
  switch (op) {
3675
2797
  case "==":
3676
- return eq$3(column, value);
2798
+ return eq(column, value);
3677
2799
  case "!=":
3678
2800
  return sql`${column} != ${value}`;
3679
2801
  case ">":
@@ -3803,7 +2925,7 @@ class DrizzleConditionBuilder {
3803
2925
  throw new Error(`Join path did not result in connecting to parent table. Current: ${currentTableName}, Parent: ${parentTableName}`);
3804
2926
  }
3805
2927
  }
3806
- const finalCondition = Array.isArray(parentEntityId) ? inArray(parentIdColumn, parentEntityId) : eq$3(parentIdColumn, parentEntityId);
2928
+ const finalCondition = Array.isArray(parentEntityId) ? inArray(parentIdColumn, parentEntityId) : eq(parentIdColumn, parentEntityId);
3807
2929
  return {
3808
2930
  joins,
3809
2931
  finalCondition
@@ -3829,7 +2951,7 @@ class DrizzleConditionBuilder {
3829
2951
  throw new Error(`Join columns not found: ${fromTableName}.${fromColName} = ${toTableName}.${toColName}`);
3830
2952
  }
3831
2953
  joinTable = fromTable;
3832
- condition = eq$3(left, right);
2954
+ condition = eq(left, right);
3833
2955
  } else if (currentTable === fromTable) {
3834
2956
  const left = toTable[toColName];
3835
2957
  const right = currentTable[fromColName];
@@ -3843,7 +2965,7 @@ class DrizzleConditionBuilder {
3843
2965
  throw new Error(`Join columns not found: ${toTableName}.${toColName} = ${fromTableName}.${fromColName}`);
3844
2966
  }
3845
2967
  joinTable = toTable;
3846
- condition = eq$3(left, right);
2968
+ condition = eq(left, right);
3847
2969
  } else {
3848
2970
  throw new Error(`Join step does not match current table. Current table does not match from: ${fromTableName} or to: ${toTableName}`);
3849
2971
  }
@@ -3874,19 +2996,19 @@ class DrizzleConditionBuilder {
3874
2996
  if (currentTable === targetTable) {
3875
2997
  return {
3876
2998
  joinTable: targetTable,
3877
- condition: eq$3(targetTableIdCol, junctionTargetCol),
2999
+ condition: eq(targetTableIdCol, junctionTargetCol),
3878
3000
  additionalJoins: [{
3879
3001
  table: junctionTable,
3880
- condition: eq$3(currentTableIdCol, junctionSourceCol)
3002
+ condition: eq(currentTableIdCol, junctionSourceCol)
3881
3003
  }]
3882
3004
  };
3883
3005
  } else {
3884
3006
  return {
3885
3007
  joinTable: junctionTable,
3886
- condition: eq$3(currentTableIdCol, junctionSourceCol),
3008
+ condition: eq(currentTableIdCol, junctionSourceCol),
3887
3009
  additionalJoins: [{
3888
3010
  table: targetTable,
3889
- condition: eq$3(targetTableIdCol, junctionTargetCol)
3011
+ condition: eq(targetTableIdCol, junctionTargetCol)
3890
3012
  }]
3891
3013
  };
3892
3014
  }
@@ -3911,11 +3033,11 @@ class DrizzleConditionBuilder {
3911
3033
  if (!junctionTargetCol) {
3912
3034
  throw new Error(`Target column '${through.targetColumn}' not found in junction table '${through.table}'`);
3913
3035
  }
3914
- const condition = Array.isArray(parentEntityId) ? inArray(junctionSourceCol, parentEntityId) : eq$3(junctionSourceCol, parentEntityId);
3036
+ const condition = Array.isArray(parentEntityId) ? inArray(junctionSourceCol, parentEntityId) : eq(junctionSourceCol, parentEntityId);
3915
3037
  return {
3916
3038
  join: {
3917
3039
  table: junctionTable,
3918
- condition: eq$3(targetIdColumn, junctionTargetCol)
3040
+ condition: eq(targetIdColumn, junctionTargetCol)
3919
3041
  },
3920
3042
  condition
3921
3043
  };
@@ -3936,11 +3058,11 @@ class DrizzleConditionBuilder {
3936
3058
  if (!junctionTargetCol) {
3937
3059
  throw new Error(`Target column '${through.targetColumn}' not found in junction table '${through.table}'`);
3938
3060
  }
3939
- const condition = Array.isArray(parentEntityId) ? inArray(junctionSourceCol, parentEntityId) : eq$3(junctionSourceCol, parentEntityId);
3061
+ const condition = Array.isArray(parentEntityId) ? inArray(junctionSourceCol, parentEntityId) : eq(junctionSourceCol, parentEntityId);
3940
3062
  return {
3941
3063
  join: {
3942
3064
  table: junctionTable,
3943
- condition: eq$3(targetIdColumn, junctionTargetCol)
3065
+ condition: eq(targetIdColumn, junctionTargetCol)
3944
3066
  },
3945
3067
  condition
3946
3068
  };
@@ -3956,15 +3078,15 @@ class DrizzleConditionBuilder {
3956
3078
  if (!idCol) {
3957
3079
  throw new Error('No primary key or "id" column found in target table');
3958
3080
  }
3959
- return Array.isArray(parentEntityId) ? inArray(idCol, parentEntityId) : eq$3(idCol, parentEntityId);
3081
+ return Array.isArray(parentEntityId) ? inArray(idCol, parentEntityId) : eq(idCol, parentEntityId);
3960
3082
  }
3961
- return Array.isArray(parentEntityId) ? inArray(targetIdCol, parentEntityId) : eq$3(targetIdCol, parentEntityId);
3083
+ return Array.isArray(parentEntityId) ? inArray(targetIdCol, parentEntityId) : eq(targetIdCol, parentEntityId);
3962
3084
  } else if (relation.direction === "inverse" && relation.foreignKeyOnTarget) {
3963
3085
  const foreignKeyCol = targetTable[relation.foreignKeyOnTarget];
3964
3086
  if (!foreignKeyCol) {
3965
3087
  throw new Error(`Foreign key column '${relation.foreignKeyOnTarget}' not found in target table. This might be a many-to-many relationship that requires a junction table. Consider using 'through' property or ensure the corresponding owning relation exists with junction table configuration.`);
3966
3088
  }
3967
- return Array.isArray(parentEntityId) ? inArray(foreignKeyCol, parentEntityId) : eq$3(foreignKeyCol, parentEntityId);
3089
+ return Array.isArray(parentEntityId) ? inArray(foreignKeyCol, parentEntityId) : eq(foreignKeyCol, parentEntityId);
3968
3090
  } else if (relation.direction === "inverse" && relation.cardinality === "many" && relation.inverseRelationName) {
3969
3091
  throw new Error(`Inverse many-to-many relation '${relation.relationName}' requires a junction table. Either specify 'through' property or ensure the corresponding owning relation exists with junction table configuration.`);
3970
3092
  } else if (relation.direction === "inverse" && relation.cardinality === "one" && relation.inverseRelationName) {
@@ -3974,7 +3096,7 @@ class DrizzleConditionBuilder {
3974
3096
  throw new Error(`Auto-inferred foreign key column '${inferredForeignKeyName}' not found in target table for inverse relation '${relation.relationName}'. Please specify 'foreignKeyOnTarget' explicitly.`);
3975
3097
  }
3976
3098
  console.debug(`🔍 [DrizzleConditionBuilder] Auto-inferred foreign key '${inferredForeignKeyName}' for inverse relation '${relation.relationName}'`);
3977
- return Array.isArray(parentEntityId) ? inArray(foreignKeyCol, parentEntityId) : eq$3(foreignKeyCol, parentEntityId);
3099
+ return Array.isArray(parentEntityId) ? inArray(foreignKeyCol, parentEntityId) : eq(foreignKeyCol, parentEntityId);
3978
3100
  } else {
3979
3101
  throw new Error(`Relation '${relation.relationName}' lacks proper configuration. For many-to-many relations, use 'through' property. For simple relations, use 'localKey' or 'foreignKeyOnTarget'.`);
3980
3102
  }
@@ -4015,7 +3137,7 @@ class DrizzleConditionBuilder {
4015
3137
  * Build a unique field check condition
4016
3138
  */
4017
3139
  static buildUniqueFieldCondition(fieldColumn, value, idColumn, excludeId) {
4018
- const conditions = [eq$3(fieldColumn, value)];
3140
+ const conditions = [eq(fieldColumn, value)];
4019
3141
  if (excludeId && idColumn) {
4020
3142
  conditions.push(sql`${idColumn} != ${excludeId}`);
4021
3143
  }
@@ -4090,7 +3212,7 @@ class DrizzleConditionBuilder {
4090
3212
  if (currentTable !== parentTable) {
4091
3213
  throw new Error("Join path did not result in connecting to parent table");
4092
3214
  }
4093
- const allConditions = [eq$3(parentIdColumn, parentEntityId)];
3215
+ const allConditions = [eq(parentIdColumn, parentEntityId)];
4094
3216
  if (additionalFilters) {
4095
3217
  allConditions.push(...additionalFilters);
4096
3218
  }
@@ -4112,11 +3234,11 @@ class DrizzleConditionBuilder {
4112
3234
  if (!junctionTargetCol) {
4113
3235
  throw new Error(`Target column '${through.targetColumn}' not found in junction table '${through.table}'`);
4114
3236
  }
4115
- const baseConditions = [eq$3(junctionSourceCol, parentEntityId)];
3237
+ const baseConditions = [eq(junctionSourceCol, parentEntityId)];
4116
3238
  if (additionalFilters && additionalFilters.length > 0) {
4117
3239
  baseConditions.push(...additionalFilters);
4118
3240
  }
4119
- return baseCountQuery.innerJoin(junctionTable, eq$3(targetIdColumn, junctionTargetCol)).where(and(...baseConditions));
3241
+ return baseCountQuery.innerJoin(junctionTable, eq(targetIdColumn, junctionTargetCol)).where(and(...baseConditions));
4120
3242
  }
4121
3243
  /**
4122
3244
  * Build inverse junction table conditions for count queries
@@ -4134,11 +3256,11 @@ class DrizzleConditionBuilder {
4134
3256
  if (!junctionTargetCol) {
4135
3257
  throw new Error(`Target column '${through.targetColumn}' not found in junction table '${through.table}'`);
4136
3258
  }
4137
- const baseConditions = [eq$3(junctionSourceCol, parentEntityId)];
3259
+ const baseConditions = [eq(junctionSourceCol, parentEntityId)];
4138
3260
  if (additionalFilters && additionalFilters.length > 0) {
4139
3261
  baseConditions.push(...additionalFilters);
4140
3262
  }
4141
- return baseCountQuery.innerJoin(junctionTable, eq$3(targetIdColumn, junctionTargetCol)).where(and(...baseConditions));
3263
+ return baseCountQuery.innerJoin(junctionTable, eq(targetIdColumn, junctionTargetCol)).where(and(...baseConditions));
4142
3264
  }
4143
3265
  /**
4144
3266
  * Helper method to extract table names from columns
@@ -4478,7 +3600,25 @@ function serializePropertyToServer(value, property) {
4478
3600
  return result;
4479
3601
  }
4480
3602
  return value;
3603
+ case "string":
3604
+ if (typeof value === "string") {
3605
+ if (value.startsWith("data:application/octet-stream;base64,")) {
3606
+ const base64Data = value.split(",")[1];
3607
+ if (base64Data) {
3608
+ return Buffer.from(base64Data, "base64");
3609
+ }
3610
+ }
3611
+ }
3612
+ return value;
4481
3613
  default:
3614
+ if (typeof value === "string") {
3615
+ if (value.startsWith("data:application/octet-stream;base64,")) {
3616
+ const base64Data = value.split(",")[1];
3617
+ if (base64Data) {
3618
+ return Buffer.from(base64Data, "base64");
3619
+ }
3620
+ }
3621
+ }
4482
3622
  return value;
4483
3623
  }
4484
3624
  }
@@ -4512,7 +3652,7 @@ async function parseDataFromServer(data, collection, db, registry) {
4512
3652
  if (targetTable && currentEntityId) {
4513
3653
  const foreignKeyColumn = targetTable[relation.foreignKeyOnTarget];
4514
3654
  if (foreignKeyColumn) {
4515
- const relatedEntities = await db.select().from(targetTable).where(eq$3(foreignKeyColumn, currentEntityId)).limit(relation.cardinality === "one" ? 1 : 100);
3655
+ const relatedEntities = await db.select().from(targetTable).where(eq(foreignKeyColumn, currentEntityId)).limit(relation.cardinality === "one" ? 1 : 100);
4516
3656
  if (relatedEntities.length > 0) {
4517
3657
  if (relation.cardinality === "one") {
4518
3658
  const targetPks = getPrimaryKeys(targetCollection, registry);
@@ -4559,12 +3699,12 @@ async function parseDataFromServer(data, collection, db, registry) {
4559
3699
  console.warn(`Join columns not found: ${fromColumn} -> ${toColumn}`);
4560
3700
  break;
4561
3701
  }
4562
- query = query.innerJoin(joinTable, eq$3(fromCol, toCol));
3702
+ query = query.innerJoin(joinTable, eq(fromCol, toCol));
4563
3703
  currentTable = joinTable;
4564
3704
  }
4565
3705
  if (pks.length === 1) {
4566
3706
  const sourceIdField = sourceTable[pks[0].fieldName];
4567
- query = query.where(eq$3(sourceIdField, currentEntityId));
3707
+ query = query.where(eq(sourceIdField, currentEntityId));
4568
3708
  } else {
4569
3709
  console.warn(`Join path resolution for composite primary keys is not yet fully supported: ${collection.slug}`);
4570
3710
  }
@@ -4572,7 +3712,7 @@ async function parseDataFromServer(data, collection, db, registry) {
4572
3712
  let combinedWhere;
4573
3713
  if (pks.length === 1) {
4574
3714
  const sourceIdField = sourceTable[pks[0].fieldName];
4575
- combinedWhere = DrizzleConditionBuilder.combineConditionsWithAnd([eq$3(sourceIdField, currentEntityId), ...additionalFilters].filter(Boolean));
3715
+ combinedWhere = DrizzleConditionBuilder.combineConditionsWithAnd([eq(sourceIdField, currentEntityId), ...additionalFilters].filter(Boolean));
4576
3716
  }
4577
3717
  const joinResults = await query.where(combinedWhere).limit(relation.cardinality === "one" ? 1 : 100);
4578
3718
  if (joinResults.length > 0) {
@@ -4604,6 +3744,37 @@ function parsePropertyFromServer(value, property, collection, propertyKey) {
4604
3744
  return value;
4605
3745
  }
4606
3746
  switch (property.type) {
3747
+ case "string": {
3748
+ if (typeof value === "string") return value;
3749
+ let isBuffer = false;
3750
+ let buf = null;
3751
+ if (Buffer.isBuffer(value)) {
3752
+ isBuffer = true;
3753
+ buf = value;
3754
+ } else if (typeof value === "object" && value !== null && value.type === "Buffer" && Array.isArray(value.data)) {
3755
+ isBuffer = true;
3756
+ buf = Buffer.from(value.data);
3757
+ }
3758
+ if (isBuffer && buf) {
3759
+ let isPrintable = true;
3760
+ for (let i = 0; i < buf.length; i++) {
3761
+ const b = buf[i];
3762
+ if ((b < 32 || b > 126) && b !== 9 && b !== 10 && b !== 13) {
3763
+ isPrintable = false;
3764
+ break;
3765
+ }
3766
+ }
3767
+ return isPrintable ? buf.toString("utf8") : `data:application/octet-stream;base64,${buf.toString("base64")}`;
3768
+ }
3769
+ if (typeof value === "object" && value !== null) {
3770
+ try {
3771
+ return JSON.stringify(value);
3772
+ } catch {
3773
+ return String(value);
3774
+ }
3775
+ }
3776
+ return String(value);
3777
+ }
4607
3778
  case "relation":
4608
3779
  if (typeof value === "string" || typeof value === "number") {
4609
3780
  let relationDef = property.relation;
@@ -4687,8 +3858,29 @@ function parsePropertyFromServer(value, property, collection, propertyKey) {
4687
3858
  }
4688
3859
  return null;
4689
3860
  }
4690
- default:
3861
+ default: {
3862
+ let isBuffer = false;
3863
+ let buf = null;
3864
+ if (Buffer.isBuffer(value)) {
3865
+ isBuffer = true;
3866
+ buf = value;
3867
+ } else if (typeof value === "object" && value !== null && value.type === "Buffer" && Array.isArray(value.data)) {
3868
+ isBuffer = true;
3869
+ buf = Buffer.from(value.data);
3870
+ }
3871
+ if (isBuffer && buf) {
3872
+ let isPrintable = true;
3873
+ for (let i = 0; i < buf.length; i++) {
3874
+ const b = buf[i];
3875
+ if ((b < 32 || b > 126) && b !== 9 && b !== 10 && b !== 13) {
3876
+ isPrintable = false;
3877
+ break;
3878
+ }
3879
+ }
3880
+ return isPrintable ? buf.toString("utf8") : `data:application/octet-stream;base64,${buf.toString("base64")}`;
3881
+ }
4691
3882
  return value;
3883
+ }
4692
3884
  }
4693
3885
  }
4694
3886
  function normalizeScalarValues(data, properties, collection, resolvedRelations, options) {
@@ -4771,11 +3963,11 @@ class RelationService {
4771
3963
  if (!fromCol || !toCol) {
4772
3964
  throw new Error(`Join columns not found: ${fromColumn} -> ${toColumn}`);
4773
3965
  }
4774
- query2 = query2.innerJoin(joinTable, eq$3(fromCol, toCol));
3966
+ query2 = query2.innerJoin(joinTable, eq(fromCol, toCol));
4775
3967
  currentTable = joinTable;
4776
3968
  }
4777
3969
  const parentIdField = parentTable[getPrimaryKeys(parentCollection, this.registry)[0].fieldName];
4778
- query2 = query2.where(eq$3(parentIdField, parsedParentId));
3970
+ query2 = query2.where(eq(parentIdField, parsedParentId));
4779
3971
  if (options.limit) {
4780
3972
  query2 = query2.limit(options.limit);
4781
3973
  }
@@ -4894,7 +4086,7 @@ class RelationService {
4894
4086
  if (!fromCol || !toCol) {
4895
4087
  throw new Error(`Join columns not found: ${fromColumn} -> ${toColumn}`);
4896
4088
  }
4897
- query2 = query2.innerJoin(joinTable, eq$3(fromCol, toCol));
4089
+ query2 = query2.innerJoin(joinTable, eq(fromCol, toCol));
4898
4090
  currentTable = joinTable;
4899
4091
  }
4900
4092
  const parentIdField = parentTable[getPrimaryKeys(parentCollection, this.registry)[0].fieldName];
@@ -5025,7 +4217,7 @@ class RelationService {
5025
4217
  const fromCol = currentTable[fromColName];
5026
4218
  const toCol = joinTable[toColName];
5027
4219
  if (!fromCol || !toCol) throw new Error(`Join columns not found: ${fromColumn} -> ${toColumn}`);
5028
- query2 = query2.innerJoin(joinTable, eq$3(fromCol, toCol));
4220
+ query2 = query2.innerJoin(joinTable, eq(fromCol, toCol));
5029
4221
  currentTable = joinTable;
5030
4222
  }
5031
4223
  const parentIdField = parentTable[getPrimaryKeys(parentCollection, this.registry)[0].fieldName];
@@ -5060,7 +4252,7 @@ class RelationService {
5060
4252
  console.warn(`[batchFetchRelatedEntitiesMany] Junction columns not found in '${relation.through.table}'`);
5061
4253
  return /* @__PURE__ */ new Map();
5062
4254
  }
5063
- const query2 = this.db.select().from(junctionTable).innerJoin(targetTable, eq$3(targetJunctionCol, targetIdField)).where(inArray(sourceJunctionCol, parsedParentIds));
4255
+ const query2 = this.db.select().from(junctionTable).innerJoin(targetTable, eq(targetJunctionCol, targetIdField)).where(inArray(sourceJunctionCol, parsedParentIds));
5064
4256
  const results2 = await query2;
5065
4257
  const resultMap2 = /* @__PURE__ */ new Map();
5066
4258
  const targetTableName = getTableName(targetCollection);
@@ -5158,7 +4350,7 @@ class RelationService {
5158
4350
  const parentIdInfo = parentPks[0];
5159
4351
  const parsedParentIdObj = parseIdValues(entityId, parentPks);
5160
4352
  const parsedParentId = parsedParentIdObj[parentIdInfo.fieldName];
5161
- await tx.delete(junctionTable).where(eq$3(sourceJunctionColumn, parsedParentId));
4353
+ await tx.delete(junctionTable).where(eq(sourceJunctionColumn, parsedParentId));
5162
4354
  if (targetEntityIds.length > 0) {
5163
4355
  const targetPks = getPrimaryKeys(targetCollection, this.registry);
5164
4356
  const targetIdInfo = targetPks[0];
@@ -5187,7 +4379,7 @@ class RelationService {
5187
4379
  const parentIdInfo = parentPks[0];
5188
4380
  const parsedParentIdObj = parseIdValues(entityId, parentPks);
5189
4381
  const parsedParentId = parsedParentIdObj[parentIdInfo.fieldName];
5190
- await tx.delete(junctionTable).where(eq$3(sourceJunctionColumn, parsedParentId));
4382
+ await tx.delete(junctionTable).where(eq(sourceJunctionColumn, parsedParentId));
5191
4383
  if (targetEntityIds.length > 0) {
5192
4384
  const targetPks = getPrimaryKeys(targetCollection, this.registry);
5193
4385
  const targetIdInfo = targetPks[0];
@@ -5220,14 +4412,14 @@ class RelationService {
5220
4412
  const parsedTargetIds = targetEntityIds.map((id) => parseIdValues(id, targetPks)[targetIdInfo.fieldName]);
5221
4413
  await tx.update(targetTable).set({
5222
4414
  [relation.foreignKeyOnTarget]: null
5223
- }).where(and(eq$3(fkCol, parsedParentId), sql`${targetIdCol} NOT IN (${sql.join(parsedTargetIds)})`));
4415
+ }).where(and(eq(fkCol, parsedParentId), sql`${targetIdCol} NOT IN (${sql.join(parsedTargetIds)})`));
5224
4416
  await tx.update(targetTable).set({
5225
4417
  [relation.foreignKeyOnTarget]: parsedParentId
5226
4418
  }).where(inArray(targetIdCol, parsedTargetIds));
5227
4419
  } else {
5228
4420
  await tx.update(targetTable).set({
5229
4421
  [relation.foreignKeyOnTarget]: null
5230
- }).where(eq$3(fkCol, parsedParentId));
4422
+ }).where(eq(fkCol, parsedParentId));
5231
4423
  }
5232
4424
  } else {
5233
4425
  console.warn(`Many relation '${key}' in collection '${collection.slug}' lacks write configuration and will be skipped during save.`);
@@ -5286,17 +4478,17 @@ class RelationService {
5286
4478
  if (newValue === null || newValue === void 0) {
5287
4479
  await tx.update(targetTable).set({
5288
4480
  [relation.foreignKeyOnTarget]: null
5289
- }).where(eq$3(foreignKeyColumn, parsedSourceId));
4481
+ }).where(eq(foreignKeyColumn, parsedSourceId));
5290
4482
  } else {
5291
4483
  const parsedNewTargetIdObj = parseIdValues(newValue, targetPks);
5292
4484
  const parsedNewTargetId = parsedNewTargetIdObj[targetIdInfo.fieldName];
5293
4485
  const targetIdField = targetTable[targetIdInfo.fieldName];
5294
4486
  await tx.update(targetTable).set({
5295
4487
  [relation.foreignKeyOnTarget]: null
5296
- }).where(eq$3(foreignKeyColumn, parsedSourceId));
4488
+ }).where(eq(foreignKeyColumn, parsedSourceId));
5297
4489
  await tx.update(targetTable).set({
5298
4490
  [relation.foreignKeyOnTarget]: parsedSourceId
5299
- }).where(eq$3(targetIdField, parsedNewTargetId));
4491
+ }).where(eq(targetIdField, parsedNewTargetId));
5300
4492
  }
5301
4493
  } catch (e) {
5302
4494
  console.warn(`Failed to update inverse relation '${relation.relationName}':`, e);
@@ -5351,7 +4543,7 @@ class RelationService {
5351
4543
  const sourceIdInfo = sourcePks[0];
5352
4544
  const parsedSourceIdObj = parseIdValues(sourceEntityId, sourcePks);
5353
4545
  const parsedSourceId = parsedSourceIdObj[sourceIdInfo.fieldName];
5354
- await tx.delete(junctionTable).where(eq$3(sourceJunctionColumn, parsedSourceId));
4546
+ await tx.delete(junctionTable).where(eq(sourceJunctionColumn, parsedSourceId));
5355
4547
  if (newValue && Array.isArray(newValue) && newValue.length > 0) {
5356
4548
  const targetPks = getPrimaryKeys(targetCollection, this.registry);
5357
4549
  const targetIdInfo = targetPks[0];
@@ -5402,7 +4594,7 @@ class RelationService {
5402
4594
  const sourceIdInfo = sourcePks[0];
5403
4595
  const parsedSourceIdObj = parseIdValues(sourceEntityId, sourcePks);
5404
4596
  const parsedSourceId = parsedSourceIdObj[sourceIdInfo.fieldName];
5405
- await tx.delete(junctionTable).where(eq$3(sourceJunctionColumn, parsedSourceId));
4597
+ await tx.delete(junctionTable).where(eq(sourceJunctionColumn, parsedSourceId));
5406
4598
  if (newValue && Array.isArray(newValue) && newValue.length > 0) {
5407
4599
  const targetPks = getPrimaryKeys(targetCollection, this.registry);
5408
4600
  const targetIdInfo = targetPks[0];
@@ -5457,14 +4649,14 @@ class RelationService {
5457
4649
  }
5458
4650
  const parentRows = await tx.select({
5459
4651
  val: parentSourceCol
5460
- }).from(parentTable).where(eq$3(parentIdCol, parsedParentId)).limit(1);
4652
+ }).from(parentTable).where(eq(parentIdCol, parsedParentId)).limit(1);
5461
4653
  if (parentRows.length === 0) continue;
5462
4654
  const parentFKValue = parentRows[0].val;
5463
4655
  if (newTargetId === null || newTargetId === void 0) {
5464
4656
  if (parentFKValue !== null && parentFKValue !== void 0) {
5465
4657
  await tx.update(targetTable).set({
5466
4658
  [targetFKColName]: null
5467
- }).where(eq$3(targetFKCol, parentFKValue));
4659
+ }).where(eq(targetFKCol, parentFKValue));
5468
4660
  }
5469
4661
  continue;
5470
4662
  }
@@ -5473,14 +4665,14 @@ class RelationService {
5473
4665
  if (parentFKValue !== null && parentFKValue !== void 0) {
5474
4666
  await tx.update(targetTable).set({
5475
4667
  [targetFKColName]: null
5476
- }).where(eq$3(targetFKCol, parentFKValue));
4668
+ }).where(eq(targetFKCol, parentFKValue));
5477
4669
  } else {
5478
4670
  console.warn(`Cannot set joinPath relation '${relation.relationName}' because parent FK value is null/undefined`);
5479
4671
  continue;
5480
4672
  }
5481
4673
  await tx.update(targetTable).set({
5482
4674
  [targetFKColName]: parentFKValue
5483
- }).where(eq$3(targetIdCol, parsedTargetId));
4675
+ }).where(eq(targetIdCol, parsedTargetId));
5484
4676
  }
5485
4677
  }
5486
4678
  /**
@@ -5865,7 +5057,7 @@ class EntityFetchService {
5865
5057
  const collection = getCollectionByPath(collectionPath, this.registry);
5866
5058
  const searchConditions = DrizzleConditionBuilder.buildSearchConditions(options.searchString, collection.properties, table);
5867
5059
  if (searchConditions.length === 0) {
5868
- queryOpts.where = and(eq$3(idField, -99999999));
5060
+ queryOpts.where = and(eq(idField, -99999999));
5869
5061
  return queryOpts;
5870
5062
  }
5871
5063
  allConditions.push(DrizzleConditionBuilder.combineConditionsWithOr(searchConditions));
@@ -5912,9 +5104,9 @@ class EntityFetchService {
5912
5104
  const startAfterId = cursor.id ?? cursor[idInfo.fieldName];
5913
5105
  if (startAfterOrderValue !== void 0 && startAfterId !== void 0) {
5914
5106
  if (options.order === "asc") {
5915
- return [or(gt(orderByField, startAfterOrderValue), and(eq$3(orderByField, startAfterOrderValue), gt(idField, startAfterId)))];
5107
+ return [or(gt(orderByField, startAfterOrderValue), and(eq(orderByField, startAfterOrderValue), gt(idField, startAfterId)))];
5916
5108
  } else {
5917
- return [or(lt(orderByField, startAfterOrderValue), and(eq$3(orderByField, startAfterOrderValue), lt(idField, startAfterId)))];
5109
+ return [or(lt(orderByField, startAfterOrderValue), and(eq(orderByField, startAfterOrderValue), lt(idField, startAfterId)))];
5918
5110
  }
5919
5111
  }
5920
5112
  }
@@ -5948,7 +5140,7 @@ class EntityFetchService {
5948
5140
  try {
5949
5141
  const withConfig = this.buildWithConfig(collection);
5950
5142
  const row = await qb.findFirst({
5951
- where: eq$3(idField, parsedId),
5143
+ where: eq(idField, parsedId),
5952
5144
  with: withConfig
5953
5145
  });
5954
5146
  if (!row) return void 0;
@@ -5956,10 +5148,14 @@ class EntityFetchService {
5956
5148
  await this.resolveJoinPathRelations(entity, collection, collectionPath, parsedId, databaseId);
5957
5149
  return entity;
5958
5150
  } catch (e) {
5151
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5152
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5153
+ console.error(`Hint: This usually means a relation in your drizzle schema is missing a reciprocal 'one()' or 'many()' definition. Run 'rebase schema generate' to fix this.`);
5154
+ }
5959
5155
  console.warn(`[EntityFetchService] db.query.findFirst failed for ${collectionPath}, falling back to db.select:`, e);
5960
5156
  }
5961
5157
  }
5962
- const result = await this.db.select().from(table).where(eq$3(idField, parsedId)).limit(1);
5158
+ const result = await this.db.select().from(table).where(eq(idField, parsedId)).limit(1);
5963
5159
  if (result.length === 0) return void 0;
5964
5160
  const raw = result[0];
5965
5161
  const values = await parseDataFromServer(raw, collection, this.db, this.registry);
@@ -6016,6 +5212,10 @@ class EntityFetchService {
6016
5212
  const entities = results2.map((row) => this.drizzleResultToEntity(row, collection, collectionPath, idInfo, options.databaseId, idInfoArray));
6017
5213
  return entities;
6018
5214
  } catch (e) {
5215
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5216
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5217
+ console.error(`Hint: This usually means a relation in your drizzle schema is missing a reciprocal 'one()' or 'many()' definition. Run 'rebase schema generate' to fix this.`);
5218
+ }
6019
5219
  console.warn(`[EntityFetchService] db.query.findMany failed for ${collectionPath}, falling back to db.select:`, e);
6020
5220
  }
6021
5221
  }
@@ -6285,6 +5485,10 @@ class EntityFetchService {
6285
5485
  await this.resolveJoinPathRelationsBatchRest(restRows, collection, collectionPath, idInfoArray, include);
6286
5486
  return restRows;
6287
5487
  } catch (e) {
5488
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5489
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5490
+ console.error(`Hint: This usually means a relation in your drizzle schema is missing a reciprocal 'one()' or 'many()' definition. Run 'rebase schema generate' to fix this.`);
5491
+ }
6288
5492
  console.warn(`[fetchCollectionForRest] db.query.findMany failed for ${collectionPath}, falling back:`, e);
6289
5493
  }
6290
5494
  }
@@ -6355,7 +5559,7 @@ class EntityFetchService {
6355
5559
  try {
6356
5560
  const withConfig = include && include.length > 0 ? this.buildWithConfig(collection, include) : void 0;
6357
5561
  const row = await qb.findFirst({
6358
- where: eq$3(idField, parsedId),
5562
+ where: eq(idField, parsedId),
6359
5563
  ...withConfig ? {
6360
5564
  with: withConfig
6361
5565
  } : {}
@@ -6365,10 +5569,14 @@ class EntityFetchService {
6365
5569
  await this.resolveJoinPathRelationsBatchRest([restRow], collection, collectionPath, idInfoArray, include);
6366
5570
  return restRow;
6367
5571
  } catch (e) {
5572
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5573
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5574
+ console.error(`Hint: This usually means a relation in your drizzle schema is missing a reciprocal 'one()' or 'many()' definition. Run 'rebase schema generate' to fix this.`);
5575
+ }
6368
5576
  console.warn(`[fetchEntityForRest] db.query.findFirst failed for ${collectionPath}, falling back:`, e);
6369
5577
  }
6370
5578
  }
6371
- const result = await this.db.select().from(table).where(eq$3(idField, parsedId)).limit(1);
5579
+ const result = await this.db.select().from(table).where(eq(idField, parsedId)).limit(1);
6372
5580
  if (result.length === 0) return null;
6373
5581
  const raw = result[0];
6374
5582
  const flatEntity = {
@@ -6577,7 +5785,7 @@ class EntityPersistService {
6577
5785
  }
6578
5786
  const parsedIdObj = parseIdValues(entityId, idInfoArray);
6579
5787
  const parsedId = parsedIdObj[idInfo.fieldName];
6580
- await this.db.delete(table).where(eq$3(idField, parsedId));
5788
+ await this.db.delete(table).where(eq(idField, parsedId));
6581
5789
  }
6582
5790
  /**
6583
5791
  * Save an entity (create or update)
@@ -6701,7 +5909,7 @@ class EntityPersistService {
6701
5909
  const conditions = [];
6702
5910
  for (const info of idInfoArray) {
6703
5911
  const field = table[info.fieldName];
6704
- conditions.push(eq$3(field, idValues[info.fieldName]));
5912
+ conditions.push(eq(field, idValues[info.fieldName]));
6705
5913
  }
6706
5914
  await updateQuery.where(and(...conditions));
6707
5915
  }
@@ -6758,22 +5966,78 @@ class EntityPersistService {
6758
5966
  const pgError = this.extractPgError(error);
6759
5967
  if (pgError) {
6760
5968
  const detail = pgError.detail;
5969
+ const hint = pgError.hint;
6761
5970
  const constraint = pgError.constraint;
6762
5971
  const column = pgError.column;
6763
5972
  const table = pgError.table;
5973
+ const dataType = pgError.dataType;
5974
+ const pgMessage = pgError.message || "Unknown database error";
5975
+ const suffix = hint ? ` Hint: ${hint}` : "";
5976
+ const tableRef = table ?? collectionSlug;
6764
5977
  switch (pgError.code) {
6765
5978
  case "23503":
6766
- return new Error(detail ? `Foreign key constraint violated: ${detail}` : `Cannot save: a foreign key constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".`);
5979
+ return new Error(detail ? `Foreign key constraint violated: ${detail}${suffix}` : `Cannot save: a foreign key constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
6767
5980
  case "23505":
6768
- return new Error(detail ? `Duplicate value: ${detail}` : `Cannot save: a unique constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".`);
5981
+ return new Error(detail ? `Duplicate value: ${detail}${suffix}` : `Cannot save: a unique constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
6769
5982
  case "23502":
6770
- return new Error(`Missing required field: "${column ?? "unknown"}" in "${table ?? collectionSlug}" cannot be empty.`);
5983
+ return new Error(`Missing required field: "${column ?? "unknown"}" in "${tableRef}" cannot be empty.${suffix}`);
6771
5984
  case "23514":
6772
- return new Error(`Validation failed: a check constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".`);
5985
+ return new Error(`Validation failed: a check constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
5986
+ case "22P02":
5987
+ return new Error(`Invalid data format in "${collectionSlug}": ${pgMessage}${suffix}`);
5988
+ case "22001":
5989
+ return new Error(`Value too long for column "${column ?? "unknown"}" in "${tableRef}": ${pgMessage}${suffix}`);
5990
+ case "22003":
5991
+ return new Error(`Numeric value out of range for column "${column ?? "unknown"}" in "${tableRef}": ${pgMessage}${suffix}`);
5992
+ case "42703":
5993
+ return new Error(`Unknown column in "${tableRef}": ${pgMessage}. Check if your schema is up to date (run migrations).${suffix}`);
5994
+ case "42P01":
5995
+ return new Error(`Table not found for "${collectionSlug}": ${pgMessage}. Check if your schema is up to date (run migrations).${suffix}`);
5996
+ default: {
5997
+ const parts = [`Database error in "${collectionSlug}" [${pgError.code}]: ${pgMessage}`];
5998
+ if (detail) parts.push(`Detail: ${detail}`);
5999
+ if (column) parts.push(`Column: ${column}`);
6000
+ if (dataType) parts.push(`Data type: ${dataType}`);
6001
+ if (constraint) parts.push(`Constraint: ${constraint}`);
6002
+ if (hint) parts.push(`Hint: ${hint}`);
6003
+ return new Error(parts.join(". "));
6004
+ }
6005
+ }
6006
+ }
6007
+ const causeMessage = this.extractCauseMessage(error);
6008
+ if (causeMessage) {
6009
+ return new Error(`Database error in "${collectionSlug}": ${causeMessage}`);
6010
+ }
6011
+ if (error instanceof Error) {
6012
+ const cleaned = this.stripSqlFromMessage(error.message, collectionSlug);
6013
+ return new Error(cleaned);
6014
+ }
6015
+ return new Error(`Database error in "${collectionSlug}": ${String(error)}`);
6016
+ }
6017
+ /**
6018
+ * Walk the error cause chain and return the deepest meaningful message.
6019
+ */
6020
+ extractCauseMessage(error) {
6021
+ if (!error || typeof error !== "object") return null;
6022
+ const err = error;
6023
+ if (err.cause && typeof err.cause === "object") {
6024
+ const deeper = this.extractCauseMessage(err.cause);
6025
+ if (deeper) return deeper;
6026
+ if (err.cause instanceof Error && err.cause.message) {
6027
+ return err.cause.message;
6773
6028
  }
6774
6029
  }
6775
- if (error instanceof Error) return error;
6776
- return new Error(String(error));
6030
+ return null;
6031
+ }
6032
+ /**
6033
+ * Strip the raw SQL query from a Drizzle "Failed query: ..." message,
6034
+ * keeping only the error description.
6035
+ */
6036
+ stripSqlFromMessage(message, collectionSlug) {
6037
+ if (message.startsWith("Failed query:")) {
6038
+ return `Failed to save entity in "${collectionSlug}". Check server logs for details.`;
6039
+ }
6040
+ return message;
6777
6041
  }
6778
6042
  /**
6779
6043
  * Extract the underlying PostgreSQL error from a Drizzle wrapper.
@@ -6782,7 +6046,7 @@ class EntityPersistService {
6782
6046
  extractPgError(error) {
6783
6047
  if (!error || typeof error !== "object") return null;
6784
6048
  const err = error;
6785
- if (err.code && /^[0-9]{5}$/.test(err.code)) {
6049
+ if (err.code && /^[0-9A-Z]{5}$/.test(err.code)) {
6786
6050
  return err;
6787
6051
  }
6788
6052
  if (err.cause && typeof err.cause === "object") {
@@ -7070,6 +6334,7 @@ class PostgresBackendDriver {
7070
6334
  branchService;
7071
6335
  user;
7072
6336
  data;
6337
+ client;
7073
6338
  /**
7074
6339
  * When true, realtime notifications are deferred until after the
7075
6340
  * wrapping transaction commits. Set by `withAuth` → `withTransaction`.
@@ -7159,7 +6424,8 @@ class PostgresBackendDriver {
7159
6424
  const contextForCallback = {
7160
6425
  user: this.user,
7161
6426
  driver: this,
7162
- data: this.data
6427
+ data: this.data,
6428
+ client: this.client
7163
6429
  };
7164
6430
  return Promise.all(entities.map(async (entity) => {
7165
6431
  let fetched = entity;
@@ -7253,7 +6519,8 @@ class PostgresBackendDriver {
7253
6519
  const contextForCallback = {
7254
6520
  user: this.user,
7255
6521
  driver: this,
7256
- data: this.data
6522
+ data: this.data,
6523
+ client: this.client
7257
6524
  };
7258
6525
  if (callbacks?.afterRead) {
7259
6526
  entity = await callbacks.afterRead({
@@ -7322,7 +6589,8 @@ class PostgresBackendDriver {
7322
6589
  const contextForCallback = {
7323
6590
  user: this.user,
7324
6591
  driver: this,
7325
- data: this.data
6592
+ data: this.data,
6593
+ client: this.client
7326
6594
  };
7327
6595
  let previousValuesForHistory;
7328
6596
  if (status === "existing" && entityId) {
@@ -7357,6 +6625,14 @@ class PostgresBackendDriver {
7357
6625
  if (result) updatedValues = mergeDeep(updatedValues, result);
7358
6626
  }
7359
6627
  }
6628
+ if (resolvedCollection?.properties) {
6629
+ updatedValues = updateDateAutoValues({
6630
+ inputValues: updatedValues,
6631
+ properties: resolvedCollection.properties,
6632
+ status: status ?? "new",
6633
+ timestampNowValue: /* @__PURE__ */ new Date()
6634
+ });
6635
+ }
7360
6636
  try {
7361
6637
  let savedEntity = await this.entityService.saveEntity(path2, updatedValues, entityId, resolvedCollection?.databaseId);
7362
6638
  if (savedEntity && (callbacks?.afterRead || propertyCallbacks?.afterRead)) {
@@ -7462,7 +6738,8 @@ class PostgresBackendDriver {
7462
6738
  const contextForCallback = {
7463
6739
  user: this.user,
7464
6740
  driver: this,
7465
- data: this.data
6741
+ data: this.data,
6742
+ client: this.client
7466
6743
  };
7467
6744
  if (callbacks?.beforeDelete || propertyCallbacks?.beforeDelete) {
7468
6745
  if (callbacks?.beforeDelete) {
@@ -7789,6 +7066,7 @@ class AuthenticatedPostgresBackendDriver {
7789
7066
  txDelegate.entityService = txEntityService;
7790
7067
  txDelegate._deferNotifications = true;
7791
7068
  txDelegate._pendingNotifications = pendingNotifications;
7069
+ txDelegate.client = this.delegate.client;
7792
7070
  return await operation(txDelegate);
7793
7071
  });
7794
7072
  for (const notification of pendingNotifications) {
@@ -8188,6 +7466,9 @@ const getDrizzleColumn = (propName, prop, collection, collections) => {
8188
7466
  } else {
8189
7467
  columnDefinition = `timestamp("${colName}", { withTimezone: true, mode: 'string' })`;
8190
7468
  }
7469
+ if (dateProp.autoValue === "on_create" || dateProp.autoValue === "on_update") {
7470
+ columnDefinition += `.default(sql\`now()\`)`;
7471
+ }
8191
7472
  break;
8192
7473
  }
8193
7474
  case "map":
@@ -8591,6 +7872,32 @@ const generateSchema = async (collections, stripPolicies = false) => {
8591
7872
  console.warn(`Could not generate relation ${relationKey} for ${collection.name}:`, e);
8592
7873
  }
8593
7874
  }
7875
+ for (const otherCollection of collections) {
7876
+ if (otherCollection.slug === collection.slug) continue;
7877
+ const otherRelations = resolveCollectionRelations(otherCollection);
7878
+ for (const [otherKey, otherRel] of Object.entries(otherRelations)) {
7879
+ if (otherRel.direction === "inverse" && otherRel.foreignKeyOnTarget) {
7880
+ try {
7881
+ const otherTarget = otherRel.target();
7882
+ if (otherTarget.slug === collection.slug) {
7883
+ const drizzleRelationName = computeSharedRelationName(otherRel, otherCollection, collections);
7884
+ const deduplicationKey = `${drizzleRelationName}::owning`;
7885
+ if (!emittedRelationNames.has(deduplicationKey)) {
7886
+ const otherTableVar = getTableVarName(getTableName(otherCollection));
7887
+ const synthKey = `_synth_${otherTableVar}_${otherRel.foreignKeyOnTarget}`;
7888
+ tableRelations.push(` "${synthKey}": one(${otherTableVar}, {
7889
+ fields: [${tableVarName}.${otherRel.foreignKeyOnTarget}],
7890
+ references: [${otherTableVar}.${getPrimaryKeyName(otherCollection)}],
7891
+ relationName: "${drizzleRelationName}"
7892
+ })`);
7893
+ emittedRelationNames.add(deduplicationKey);
7894
+ }
7895
+ }
7896
+ } catch (e) {
7897
+ }
7898
+ }
7899
+ }
7900
+ }
8594
7901
  }
8595
7902
  if (tableRelations.length > 0) {
8596
7903
  const relVarName = `${tableVarName}Relations`;
@@ -10369,11 +9676,11 @@ class UserService {
10369
9676
  return user;
10370
9677
  }
10371
9678
  async getUserById(id) {
10372
- const [user] = await this.db.select().from(users).where(eq$3(users.id, id));
9679
+ const [user] = await this.db.select().from(users).where(eq(users.id, id));
10373
9680
  return user || null;
10374
9681
  }
10375
9682
  async getUserByEmail(email) {
10376
- const [user] = await this.db.select().from(users).where(eq$3(users.email, email.toLowerCase()));
9683
+ const [user] = await this.db.select().from(users).where(eq(users.email, email.toLowerCase()));
10377
9684
  return user || null;
10378
9685
  }
10379
9686
  async getUserByIdentity(provider, providerId) {
@@ -10429,11 +9736,11 @@ class UserService {
10429
9736
  const [user] = await this.db.update(users).set({
10430
9737
  ...data,
10431
9738
  updatedAt: /* @__PURE__ */ new Date()
10432
- }).where(eq$3(users.id, id)).returning();
9739
+ }).where(eq(users.id, id)).returning();
10433
9740
  return user || null;
10434
9741
  }
10435
9742
  async deleteUser(id) {
10436
- await this.db.delete(users).where(eq$3(users.id, id));
9743
+ await this.db.delete(users).where(eq(users.id, id));
10437
9744
  }
10438
9745
  async listUsers() {
10439
9746
  return this.db.select().from(users);
@@ -10502,7 +9809,7 @@ class UserService {
10502
9809
  await this.db.update(users).set({
10503
9810
  passwordHash,
10504
9811
  updatedAt: /* @__PURE__ */ new Date()
10505
- }).where(eq$3(users.id, id));
9812
+ }).where(eq(users.id, id));
10506
9813
  }
10507
9814
  /**
10508
9815
  * Set email verification status
@@ -10512,7 +9819,7 @@ class UserService {
10512
9819
  emailVerified: verified,
10513
9820
  emailVerificationToken: null,
10514
9821
  updatedAt: /* @__PURE__ */ new Date()
10515
- }).where(eq$3(users.id, id));
9822
+ }).where(eq(users.id, id));
10516
9823
  }
10517
9824
  /**
10518
9825
  * Set email verification token
@@ -10522,13 +9829,13 @@ class UserService {
10522
9829
  emailVerificationToken: token,
10523
9830
  emailVerificationSentAt: token ? /* @__PURE__ */ new Date() : null,
10524
9831
  updatedAt: /* @__PURE__ */ new Date()
10525
- }).where(eq$3(users.id, id));
9832
+ }).where(eq(users.id, id));
10526
9833
  }
10527
9834
  /**
10528
9835
  * Find user by email verification token
10529
9836
  */
10530
9837
  async getUserByVerificationToken(token) {
10531
- const [user] = await this.db.select().from(users).where(eq$3(users.emailVerificationToken, token));
9838
+ const [user] = await this.db.select().from(users).where(eq(users.emailVerificationToken, token));
10532
9839
  return user || null;
10533
9840
  }
10534
9841
  /**
@@ -10701,14 +10008,14 @@ class RefreshTokenService {
10701
10008
  createdAt: refreshTokens.createdAt,
10702
10009
  userAgent: refreshTokens.userAgent,
10703
10010
  ipAddress: refreshTokens.ipAddress
10704
- }).from(refreshTokens).where(eq$3(refreshTokens.tokenHash, tokenHash));
10011
+ }).from(refreshTokens).where(eq(refreshTokens.tokenHash, tokenHash));
10705
10012
  return token || null;
10706
10013
  }
10707
10014
  async deleteByHash(tokenHash) {
10708
- await this.db.delete(refreshTokens).where(eq$3(refreshTokens.tokenHash, tokenHash));
10015
+ await this.db.delete(refreshTokens).where(eq(refreshTokens.tokenHash, tokenHash));
10709
10016
  }
10710
10017
  async deleteAllForUser(userId) {
10711
- await this.db.delete(refreshTokens).where(eq$3(refreshTokens.userId, userId));
10018
+ await this.db.delete(refreshTokens).where(eq(refreshTokens.userId, userId));
10712
10019
  }
10713
10020
  async listForUser(userId) {
10714
10021
  const tokens = await this.db.select({
@@ -10719,7 +10026,7 @@ class RefreshTokenService {
10719
10026
  createdAt: refreshTokens.createdAt,
10720
10027
  userAgent: refreshTokens.userAgent,
10721
10028
  ipAddress: refreshTokens.ipAddress
10722
- }).from(refreshTokens).where(eq$3(refreshTokens.userId, userId)).orderBy(refreshTokens.createdAt);
10029
+ }).from(refreshTokens).where(eq(refreshTokens.userId, userId)).orderBy(refreshTokens.createdAt);
10723
10030
  return tokens;
10724
10031
  }
10725
10032
  async deleteById(id, userId) {
@@ -10751,7 +10058,7 @@ class PasswordResetTokenService {
10751
10058
  const [token] = await this.db.select({
10752
10059
  userId: passwordResetTokens.userId,
10753
10060
  expiresAt: passwordResetTokens.expiresAt
10754
- }).from(passwordResetTokens).where(eq$3(passwordResetTokens.tokenHash, tokenHash));
10061
+ }).from(passwordResetTokens).where(eq(passwordResetTokens.tokenHash, tokenHash));
10755
10062
  if (!token) return null;
10756
10063
  const result = await this.db.execute(sql`
10757
10064
  SELECT user_id, expires_at
@@ -10773,13 +10080,13 @@ class PasswordResetTokenService {
10773
10080
  async markAsUsed(tokenHash) {
10774
10081
  await this.db.update(passwordResetTokens).set({
10775
10082
  usedAt: /* @__PURE__ */ new Date()
10776
- }).where(eq$3(passwordResetTokens.tokenHash, tokenHash));
10083
+ }).where(eq(passwordResetTokens.tokenHash, tokenHash));
10777
10084
  }
10778
10085
  /**
10779
10086
  * Delete all tokens for a user
10780
10087
  */
10781
10088
  async deleteAllForUser(userId) {
10782
- await this.db.delete(passwordResetTokens).where(eq$3(passwordResetTokens.userId, userId));
10089
+ await this.db.delete(passwordResetTokens).where(eq(passwordResetTokens.userId, userId));
10783
10090
  }
10784
10091
  /**
10785
10092
  * Clean up expired tokens