@rebasepro/server-postgresql 0.0.1-canary.f81da60 → 0.1.2

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 (52) hide show
  1. package/dist/index.es.js +383 -1080
  2. package/dist/index.es.js.map +1 -1
  3. package/dist/index.umd.js +314 -1011
  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 +20 -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 +15 -3
  20. package/dist/types/src/types/translations.d.ts +2 -0
  21. package/package.json +5 -5
  22. package/src/PostgresBackendDriver.ts +23 -6
  23. package/src/cli.ts +10 -2
  24. package/src/data-transformer.ts +84 -1
  25. package/src/schema/doctor.ts +14 -2
  26. package/src/schema/generate-drizzle-schema-logic.ts +52 -5
  27. package/src/schema/introspect-db-inference.ts +238 -0
  28. package/src/schema/introspect-db-logic.ts +365 -61
  29. package/src/schema/introspect-db.ts +66 -23
  30. package/src/services/EntityFetchService.ts +16 -0
  31. package/src/services/EntityPersistService.ts +88 -12
  32. package/test/generate-drizzle-schema.test.ts +295 -0
  33. package/test/introspect-db-generation.test.ts +32 -10
  34. package/test/property-ordering.test.ts +395 -0
  35. package/jest-all.log +0 -3128
  36. package/jest.log +0 -49
  37. package/scratch.ts +0 -41
  38. package/test-drizzle-bug.ts +0 -18
  39. package/test-drizzle-out/0000_cultured_freak.sql +0 -7
  40. package/test-drizzle-out/0001_tiresome_professor_monster.sql +0 -1
  41. package/test-drizzle-out/meta/0000_snapshot.json +0 -55
  42. package/test-drizzle-out/meta/0001_snapshot.json +0 -63
  43. package/test-drizzle-out/meta/_journal.json +0 -20
  44. package/test-drizzle-prompt.sh +0 -2
  45. package/test-policy-prompt.sh +0 -3
  46. package/test-programmatic.ts +0 -30
  47. package/test-programmatic2.ts +0 -59
  48. package/test-schema-no-policies.ts +0 -12
  49. package/test_drizzle_mock.js +0 -3
  50. package/test_find_changed.mjs +0 -32
  51. package/test_hash.js +0 -14
  52. package/test_output.txt +0 -3145
package/dist/index.umd.js CHANGED
@@ -132,16 +132,14 @@
132
132
  }
133
133
  const DEFAULT_ONE_OF_TYPE = "type";
134
134
  const DEFAULT_ONE_OF_VALUE = "value";
135
- const snakeCaseRegex = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;
135
+ const tokenizeRegex = /[A-Z]{2,}(?=[A-Z][a-z]|\b)|[A-Z]?[a-z]+|[0-9]+(?:[a-z](?![a-z]))?|[A-Z]/g;
136
+ const snakeCaseRegex = tokenizeRegex;
136
137
  const toSnakeCase = (str) => {
137
138
  const regExpMatchArray = str.match(snakeCaseRegex);
138
139
  if (!regExpMatchArray) return "";
139
140
  return regExpMatchArray.map((x) => x.toLowerCase()).join("_");
140
141
  };
141
142
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
142
- function getDefaultExportFromCjs(x) {
143
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
144
- }
145
143
  function commonjsRequire(path2) {
146
144
  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.');
147
145
  }
@@ -928,7 +926,23 @@
928
926
  }, { buffer: 3, lYpoI2: 11 }] }, {}, [1])(1);
929
927
  });
930
928
  })(object_hash);
931
- function isObject$6(item) {
929
+ function deepClone(value) {
930
+ if (value === null || value === void 0) return value;
931
+ if (typeof value === "function") return value;
932
+ if (typeof value !== "object") return value;
933
+ if (Array.isArray(value)) {
934
+ return value.map((item) => deepClone(item));
935
+ }
936
+ if (Object.getPrototypeOf(value) !== Object.prototype) {
937
+ return value;
938
+ }
939
+ const result = {};
940
+ for (const key of Object.keys(value)) {
941
+ result[key] = deepClone(value[key]);
942
+ }
943
+ return result;
944
+ }
945
+ function isObject(item) {
932
946
  return !!item && typeof item === "object" && !Array.isArray(item);
933
947
  }
934
948
  function isPlainObject(obj) {
@@ -939,13 +953,13 @@
939
953
  return proto === Object.prototype;
940
954
  }
941
955
  function mergeDeep(target, source, ignoreUndefined = false) {
942
- if (!isObject$6(target)) {
956
+ if (!isObject(target)) {
943
957
  return target;
944
958
  }
945
959
  const output = {
946
960
  ...target
947
961
  };
948
- if (!isObject$6(source)) {
962
+ if (!isObject(source)) {
949
963
  return output;
950
964
  }
951
965
  for (const key in source) {
@@ -986,7 +1000,7 @@
986
1000
  } else {
987
1001
  output[key] = sourceValue;
988
1002
  }
989
- } else if (isObject$6(sourceValue)) {
1003
+ } else if (isObject(sourceValue)) {
990
1004
  output[key] = sourceValue;
991
1005
  } else {
992
1006
  output[key] = sourceValue;
@@ -1029,6 +1043,80 @@
1029
1043
  const singularName = snakeCaseName.endsWith("s") ? snakeCaseName.slice(0, -1) : snakeCaseName;
1030
1044
  return `${singularName}_id`;
1031
1045
  }
1046
+ function updateDateAutoValues({
1047
+ inputValues,
1048
+ properties,
1049
+ status,
1050
+ timestampNowValue
1051
+ }) {
1052
+ return traverseValuesProperties(inputValues, properties, (inputValue, property) => {
1053
+ if (property.type === "date") {
1054
+ if (status === "existing" && property.autoValue === "on_update") {
1055
+ return timestampNowValue;
1056
+ } else if ((status === "new" || status === "copy") && (property.autoValue === "on_update" || property.autoValue === "on_create")) {
1057
+ return timestampNowValue;
1058
+ } else {
1059
+ return inputValue;
1060
+ }
1061
+ } else {
1062
+ return inputValue;
1063
+ }
1064
+ }) ?? {};
1065
+ }
1066
+ function traverseValuesProperties(inputValues, properties, operation) {
1067
+ const safeInputValues = inputValues ?? {};
1068
+ const updatedValues = Object.entries(properties).map(([key, property]) => {
1069
+ const inputValue = safeInputValues && safeInputValues[key];
1070
+ const updatedValue = traverseValueProperty(inputValue, property, operation);
1071
+ if (updatedValue === null) return null;
1072
+ if (updatedValue === void 0) return void 0;
1073
+ return {
1074
+ [key]: updatedValue
1075
+ };
1076
+ }).reduce((a, b) => ({
1077
+ ...a,
1078
+ ...b
1079
+ }), {});
1080
+ const result = mergeDeep(safeInputValues, updatedValues);
1081
+ if (!result || Object.keys(result).length === 0) return void 0;
1082
+ return result;
1083
+ }
1084
+ function traverseValueProperty(inputValue, property, operation) {
1085
+ let value;
1086
+ if (property.type === "map" && property.properties) {
1087
+ value = traverseValuesProperties(inputValue, property.properties, operation);
1088
+ } else if (property.type === "array") {
1089
+ const of = property.of;
1090
+ if (of && Array.isArray(inputValue) && !Array.isArray(of)) {
1091
+ value = inputValue.map((e) => traverseValueProperty(e, of, operation));
1092
+ } else if (of && Array.isArray(inputValue) && Array.isArray(of)) {
1093
+ value = inputValue.map((e, i) => {
1094
+ if (i < of.length) return traverseValueProperty(e, of[i], operation);
1095
+ return null;
1096
+ }).filter(Boolean);
1097
+ } else if (property.oneOf && Array.isArray(inputValue)) {
1098
+ const typeField = property.oneOf?.typeField ?? DEFAULT_ONE_OF_TYPE;
1099
+ const valueField = property.oneOf?.valueField ?? DEFAULT_ONE_OF_VALUE;
1100
+ value = inputValue.map((e) => {
1101
+ if (e === null) return null;
1102
+ if (typeof e !== "object") return e;
1103
+ const rec = e;
1104
+ const type = rec[typeField];
1105
+ const childProperty = property.oneOf?.properties[type];
1106
+ if (!type || !childProperty) return e;
1107
+ return {
1108
+ [typeField]: type,
1109
+ [valueField]: traverseValueProperty(rec[valueField], childProperty, operation)
1110
+ };
1111
+ });
1112
+ } else {
1113
+ value = inputValue;
1114
+ }
1115
+ } else {
1116
+ value = operation(inputValue, property);
1117
+ }
1118
+ return value;
1119
+ }
1032
1120
  function createRelationRef(id, path2) {
1033
1121
  return {
1034
1122
  id,
@@ -1358,7 +1446,7 @@
1358
1446
  }
1359
1447
  var logic = { exports: {} };
1360
1448
  (function(module2, exports$1) {
1361
- (function(root2, factory) {
1449
+ (function(root, factory) {
1362
1450
  {
1363
1451
  module2.exports = factory();
1364
1452
  }
@@ -1726,7 +1814,7 @@
1726
1814
  });
1727
1815
  })(logic);
1728
1816
  const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
1729
- const { hasOwnProperty: hasOwnProperty$a } = Object.prototype;
1817
+ const { hasOwnProperty } = Object.prototype;
1730
1818
  function combineComparators(comparatorA, comparatorB) {
1731
1819
  return function isEqual(a, b, state) {
1732
1820
  return comparatorA(a, b, state) && comparatorB(a, b, state);
@@ -1756,12 +1844,12 @@
1756
1844
  }
1757
1845
  const hasOwn = (
1758
1846
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1759
- Object.hasOwn || ((object, property) => hasOwnProperty$a.call(object, property))
1847
+ Object.hasOwn || ((object, property) => hasOwnProperty.call(object, property))
1760
1848
  );
1761
1849
  const PREACT_VNODE = "__v";
1762
1850
  const PREACT_OWNER = "__o";
1763
1851
  const REACT_OWNER = "_owner";
1764
- const { getOwnPropertyDescriptor, keys: keys$4 } = Object;
1852
+ const { getOwnPropertyDescriptor, keys } = Object;
1765
1853
  const sameValueEqual = (
1766
1854
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1767
1855
  Object.is || function sameValueEqual2(a, b) {
@@ -1839,9 +1927,9 @@
1839
1927
  return true;
1840
1928
  }
1841
1929
  function areObjectsEqual(a, b, state) {
1842
- const properties = keys$4(a);
1930
+ const properties = keys(a);
1843
1931
  let index = properties.length;
1844
- if (keys$4(b).length !== index) {
1932
+ if (keys(b).length !== index) {
1845
1933
  return false;
1846
1934
  }
1847
1935
  while (index-- > 0) {
@@ -2144,982 +2232,6 @@
2144
2232
  const equals = createCustomInternalComparator ? createCustomInternalComparator(comparator) : createInternalEqualityComparator(comparator);
2145
2233
  return createIsEqual({ circular, comparator, createState, equals, strict });
2146
2234
  }
2147
- function listCacheClear$1() {
2148
- this.__data__ = [];
2149
- this.size = 0;
2150
- }
2151
- var _listCacheClear = listCacheClear$1;
2152
- function eq$2(value, other) {
2153
- return value === other || value !== value && other !== other;
2154
- }
2155
- var eq_1 = eq$2;
2156
- var eq$1 = eq_1;
2157
- function assocIndexOf$4(array, key) {
2158
- var length = array.length;
2159
- while (length--) {
2160
- if (eq$1(array[length][0], key)) {
2161
- return length;
2162
- }
2163
- }
2164
- return -1;
2165
- }
2166
- var _assocIndexOf = assocIndexOf$4;
2167
- var assocIndexOf$3 = _assocIndexOf;
2168
- var arrayProto = Array.prototype;
2169
- var splice = arrayProto.splice;
2170
- function listCacheDelete$1(key) {
2171
- var data = this.__data__, index = assocIndexOf$3(data, key);
2172
- if (index < 0) {
2173
- return false;
2174
- }
2175
- var lastIndex = data.length - 1;
2176
- if (index == lastIndex) {
2177
- data.pop();
2178
- } else {
2179
- splice.call(data, index, 1);
2180
- }
2181
- --this.size;
2182
- return true;
2183
- }
2184
- var _listCacheDelete = listCacheDelete$1;
2185
- var assocIndexOf$2 = _assocIndexOf;
2186
- function listCacheGet$1(key) {
2187
- var data = this.__data__, index = assocIndexOf$2(data, key);
2188
- return index < 0 ? void 0 : data[index][1];
2189
- }
2190
- var _listCacheGet = listCacheGet$1;
2191
- var assocIndexOf$1 = _assocIndexOf;
2192
- function listCacheHas$1(key) {
2193
- return assocIndexOf$1(this.__data__, key) > -1;
2194
- }
2195
- var _listCacheHas = listCacheHas$1;
2196
- var assocIndexOf = _assocIndexOf;
2197
- function listCacheSet$1(key, value) {
2198
- var data = this.__data__, index = assocIndexOf(data, key);
2199
- if (index < 0) {
2200
- ++this.size;
2201
- data.push([key, value]);
2202
- } else {
2203
- data[index][1] = value;
2204
- }
2205
- return this;
2206
- }
2207
- var _listCacheSet = listCacheSet$1;
2208
- var listCacheClear = _listCacheClear, listCacheDelete = _listCacheDelete, listCacheGet = _listCacheGet, listCacheHas = _listCacheHas, listCacheSet = _listCacheSet;
2209
- function ListCache$4(entries) {
2210
- var index = -1, length = entries == null ? 0 : entries.length;
2211
- this.clear();
2212
- while (++index < length) {
2213
- var entry = entries[index];
2214
- this.set(entry[0], entry[1]);
2215
- }
2216
- }
2217
- ListCache$4.prototype.clear = listCacheClear;
2218
- ListCache$4.prototype["delete"] = listCacheDelete;
2219
- ListCache$4.prototype.get = listCacheGet;
2220
- ListCache$4.prototype.has = listCacheHas;
2221
- ListCache$4.prototype.set = listCacheSet;
2222
- var _ListCache = ListCache$4;
2223
- var ListCache$3 = _ListCache;
2224
- function stackClear$1() {
2225
- this.__data__ = new ListCache$3();
2226
- this.size = 0;
2227
- }
2228
- var _stackClear = stackClear$1;
2229
- function stackDelete$1(key) {
2230
- var data = this.__data__, result = data["delete"](key);
2231
- this.size = data.size;
2232
- return result;
2233
- }
2234
- var _stackDelete = stackDelete$1;
2235
- function stackGet$1(key) {
2236
- return this.__data__.get(key);
2237
- }
2238
- var _stackGet = stackGet$1;
2239
- function stackHas$1(key) {
2240
- return this.__data__.has(key);
2241
- }
2242
- var _stackHas = stackHas$1;
2243
- var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
2244
- var _freeGlobal = freeGlobal$1;
2245
- var freeGlobal = _freeGlobal;
2246
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
2247
- var root$8 = freeGlobal || freeSelf || Function("return this")();
2248
- var _root = root$8;
2249
- var root$7 = _root;
2250
- var Symbol$4 = root$7.Symbol;
2251
- var _Symbol = Symbol$4;
2252
- var Symbol$3 = _Symbol;
2253
- var objectProto$c = Object.prototype;
2254
- var hasOwnProperty$9 = objectProto$c.hasOwnProperty;
2255
- var nativeObjectToString$1 = objectProto$c.toString;
2256
- var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
2257
- function getRawTag$1(value) {
2258
- var isOwn = hasOwnProperty$9.call(value, symToStringTag$1), tag = value[symToStringTag$1];
2259
- try {
2260
- value[symToStringTag$1] = void 0;
2261
- var unmasked = true;
2262
- } catch (e) {
2263
- }
2264
- var result = nativeObjectToString$1.call(value);
2265
- if (unmasked) {
2266
- if (isOwn) {
2267
- value[symToStringTag$1] = tag;
2268
- } else {
2269
- delete value[symToStringTag$1];
2270
- }
2271
- }
2272
- return result;
2273
- }
2274
- var _getRawTag = getRawTag$1;
2275
- var objectProto$b = Object.prototype;
2276
- var nativeObjectToString = objectProto$b.toString;
2277
- function objectToString$1(value) {
2278
- return nativeObjectToString.call(value);
2279
- }
2280
- var _objectToString = objectToString$1;
2281
- var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
2282
- var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
2283
- var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
2284
- function baseGetTag$4(value) {
2285
- if (value == null) {
2286
- return value === void 0 ? undefinedTag : nullTag;
2287
- }
2288
- return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
2289
- }
2290
- var _baseGetTag = baseGetTag$4;
2291
- function isObject$5(value) {
2292
- var type = typeof value;
2293
- return value != null && (type == "object" || type == "function");
2294
- }
2295
- var isObject_1 = isObject$5;
2296
- var baseGetTag$3 = _baseGetTag, isObject$4 = isObject_1;
2297
- var asyncTag = "[object AsyncFunction]", funcTag$2 = "[object Function]", genTag$1 = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
2298
- function isFunction$2(value) {
2299
- if (!isObject$4(value)) {
2300
- return false;
2301
- }
2302
- var tag = baseGetTag$3(value);
2303
- return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag || tag == proxyTag;
2304
- }
2305
- var isFunction_1 = isFunction$2;
2306
- var root$6 = _root;
2307
- var coreJsData$1 = root$6["__core-js_shared__"];
2308
- var _coreJsData = coreJsData$1;
2309
- var coreJsData = _coreJsData;
2310
- var maskSrcKey = function() {
2311
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
2312
- return uid ? "Symbol(src)_1." + uid : "";
2313
- }();
2314
- function isMasked$1(func) {
2315
- return !!maskSrcKey && maskSrcKey in func;
2316
- }
2317
- var _isMasked = isMasked$1;
2318
- var funcProto$1 = Function.prototype;
2319
- var funcToString$1 = funcProto$1.toString;
2320
- function toSource$2(func) {
2321
- if (func != null) {
2322
- try {
2323
- return funcToString$1.call(func);
2324
- } catch (e) {
2325
- }
2326
- try {
2327
- return func + "";
2328
- } catch (e) {
2329
- }
2330
- }
2331
- return "";
2332
- }
2333
- var _toSource = toSource$2;
2334
- var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$3 = isObject_1, toSource$1 = _toSource;
2335
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
2336
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
2337
- var funcProto = Function.prototype, objectProto$a = Object.prototype;
2338
- var funcToString = funcProto.toString;
2339
- var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
2340
- var reIsNative = RegExp(
2341
- "^" + funcToString.call(hasOwnProperty$8).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
2342
- );
2343
- function baseIsNative$1(value) {
2344
- if (!isObject$3(value) || isMasked(value)) {
2345
- return false;
2346
- }
2347
- var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
2348
- return pattern.test(toSource$1(value));
2349
- }
2350
- var _baseIsNative = baseIsNative$1;
2351
- function getValue$1(object, key) {
2352
- return object == null ? void 0 : object[key];
2353
- }
2354
- var _getValue = getValue$1;
2355
- var baseIsNative = _baseIsNative, getValue = _getValue;
2356
- function getNative$7(object, key) {
2357
- var value = getValue(object, key);
2358
- return baseIsNative(value) ? value : void 0;
2359
- }
2360
- var _getNative = getNative$7;
2361
- var getNative$6 = _getNative, root$5 = _root;
2362
- var Map$4 = getNative$6(root$5, "Map");
2363
- var _Map = Map$4;
2364
- var getNative$5 = _getNative;
2365
- var nativeCreate$4 = getNative$5(Object, "create");
2366
- var _nativeCreate = nativeCreate$4;
2367
- var nativeCreate$3 = _nativeCreate;
2368
- function hashClear$1() {
2369
- this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
2370
- this.size = 0;
2371
- }
2372
- var _hashClear = hashClear$1;
2373
- function hashDelete$1(key) {
2374
- var result = this.has(key) && delete this.__data__[key];
2375
- this.size -= result ? 1 : 0;
2376
- return result;
2377
- }
2378
- var _hashDelete = hashDelete$1;
2379
- var nativeCreate$2 = _nativeCreate;
2380
- var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
2381
- var objectProto$9 = Object.prototype;
2382
- var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
2383
- function hashGet$1(key) {
2384
- var data = this.__data__;
2385
- if (nativeCreate$2) {
2386
- var result = data[key];
2387
- return result === HASH_UNDEFINED$1 ? void 0 : result;
2388
- }
2389
- return hasOwnProperty$7.call(data, key) ? data[key] : void 0;
2390
- }
2391
- var _hashGet = hashGet$1;
2392
- var nativeCreate$1 = _nativeCreate;
2393
- var objectProto$8 = Object.prototype;
2394
- var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
2395
- function hashHas$1(key) {
2396
- var data = this.__data__;
2397
- return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty$6.call(data, key);
2398
- }
2399
- var _hashHas = hashHas$1;
2400
- var nativeCreate = _nativeCreate;
2401
- var HASH_UNDEFINED = "__lodash_hash_undefined__";
2402
- function hashSet$1(key, value) {
2403
- var data = this.__data__;
2404
- this.size += this.has(key) ? 0 : 1;
2405
- data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
2406
- return this;
2407
- }
2408
- var _hashSet = hashSet$1;
2409
- var hashClear = _hashClear, hashDelete = _hashDelete, hashGet = _hashGet, hashHas = _hashHas, hashSet = _hashSet;
2410
- function Hash$1(entries) {
2411
- var index = -1, length = entries == null ? 0 : entries.length;
2412
- this.clear();
2413
- while (++index < length) {
2414
- var entry = entries[index];
2415
- this.set(entry[0], entry[1]);
2416
- }
2417
- }
2418
- Hash$1.prototype.clear = hashClear;
2419
- Hash$1.prototype["delete"] = hashDelete;
2420
- Hash$1.prototype.get = hashGet;
2421
- Hash$1.prototype.has = hashHas;
2422
- Hash$1.prototype.set = hashSet;
2423
- var _Hash = Hash$1;
2424
- var Hash = _Hash, ListCache$2 = _ListCache, Map$3 = _Map;
2425
- function mapCacheClear$1() {
2426
- this.size = 0;
2427
- this.__data__ = {
2428
- "hash": new Hash(),
2429
- "map": new (Map$3 || ListCache$2)(),
2430
- "string": new Hash()
2431
- };
2432
- }
2433
- var _mapCacheClear = mapCacheClear$1;
2434
- function isKeyable$1(value) {
2435
- var type = typeof value;
2436
- return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
2437
- }
2438
- var _isKeyable = isKeyable$1;
2439
- var isKeyable = _isKeyable;
2440
- function getMapData$4(map, key) {
2441
- var data = map.__data__;
2442
- return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
2443
- }
2444
- var _getMapData = getMapData$4;
2445
- var getMapData$3 = _getMapData;
2446
- function mapCacheDelete$1(key) {
2447
- var result = getMapData$3(this, key)["delete"](key);
2448
- this.size -= result ? 1 : 0;
2449
- return result;
2450
- }
2451
- var _mapCacheDelete = mapCacheDelete$1;
2452
- var getMapData$2 = _getMapData;
2453
- function mapCacheGet$1(key) {
2454
- return getMapData$2(this, key).get(key);
2455
- }
2456
- var _mapCacheGet = mapCacheGet$1;
2457
- var getMapData$1 = _getMapData;
2458
- function mapCacheHas$1(key) {
2459
- return getMapData$1(this, key).has(key);
2460
- }
2461
- var _mapCacheHas = mapCacheHas$1;
2462
- var getMapData = _getMapData;
2463
- function mapCacheSet$1(key, value) {
2464
- var data = getMapData(this, key), size = data.size;
2465
- data.set(key, value);
2466
- this.size += data.size == size ? 0 : 1;
2467
- return this;
2468
- }
2469
- var _mapCacheSet = mapCacheSet$1;
2470
- var mapCacheClear = _mapCacheClear, mapCacheDelete = _mapCacheDelete, mapCacheGet = _mapCacheGet, mapCacheHas = _mapCacheHas, mapCacheSet = _mapCacheSet;
2471
- function MapCache$1(entries) {
2472
- var index = -1, length = entries == null ? 0 : entries.length;
2473
- this.clear();
2474
- while (++index < length) {
2475
- var entry = entries[index];
2476
- this.set(entry[0], entry[1]);
2477
- }
2478
- }
2479
- MapCache$1.prototype.clear = mapCacheClear;
2480
- MapCache$1.prototype["delete"] = mapCacheDelete;
2481
- MapCache$1.prototype.get = mapCacheGet;
2482
- MapCache$1.prototype.has = mapCacheHas;
2483
- MapCache$1.prototype.set = mapCacheSet;
2484
- var _MapCache = MapCache$1;
2485
- var ListCache$1 = _ListCache, Map$2 = _Map, MapCache = _MapCache;
2486
- var LARGE_ARRAY_SIZE = 200;
2487
- function stackSet$1(key, value) {
2488
- var data = this.__data__;
2489
- if (data instanceof ListCache$1) {
2490
- var pairs = data.__data__;
2491
- if (!Map$2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
2492
- pairs.push([key, value]);
2493
- this.size = ++data.size;
2494
- return this;
2495
- }
2496
- data = this.__data__ = new MapCache(pairs);
2497
- }
2498
- data.set(key, value);
2499
- this.size = data.size;
2500
- return this;
2501
- }
2502
- var _stackSet = stackSet$1;
2503
- var ListCache = _ListCache, stackClear = _stackClear, stackDelete = _stackDelete, stackGet = _stackGet, stackHas = _stackHas, stackSet = _stackSet;
2504
- function Stack$1(entries) {
2505
- var data = this.__data__ = new ListCache(entries);
2506
- this.size = data.size;
2507
- }
2508
- Stack$1.prototype.clear = stackClear;
2509
- Stack$1.prototype["delete"] = stackDelete;
2510
- Stack$1.prototype.get = stackGet;
2511
- Stack$1.prototype.has = stackHas;
2512
- Stack$1.prototype.set = stackSet;
2513
- var _Stack = Stack$1;
2514
- function arrayEach$1(array, iteratee) {
2515
- var index = -1, length = array == null ? 0 : array.length;
2516
- while (++index < length) {
2517
- if (iteratee(array[index], index, array) === false) {
2518
- break;
2519
- }
2520
- }
2521
- return array;
2522
- }
2523
- var _arrayEach = arrayEach$1;
2524
- var getNative$4 = _getNative;
2525
- var defineProperty$1 = function() {
2526
- try {
2527
- var func = getNative$4(Object, "defineProperty");
2528
- func({}, "", {});
2529
- return func;
2530
- } catch (e) {
2531
- }
2532
- }();
2533
- var _defineProperty = defineProperty$1;
2534
- var defineProperty = _defineProperty;
2535
- function baseAssignValue$2(object, key, value) {
2536
- if (key == "__proto__" && defineProperty) {
2537
- defineProperty(object, key, {
2538
- "configurable": true,
2539
- "enumerable": true,
2540
- "value": value,
2541
- "writable": true
2542
- });
2543
- } else {
2544
- object[key] = value;
2545
- }
2546
- }
2547
- var _baseAssignValue = baseAssignValue$2;
2548
- var baseAssignValue$1 = _baseAssignValue, eq = eq_1;
2549
- var objectProto$7 = Object.prototype;
2550
- var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
2551
- function assignValue$2(object, key, value) {
2552
- var objValue = object[key];
2553
- if (!(hasOwnProperty$5.call(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) {
2554
- baseAssignValue$1(object, key, value);
2555
- }
2556
- }
2557
- var _assignValue = assignValue$2;
2558
- var assignValue$1 = _assignValue, baseAssignValue = _baseAssignValue;
2559
- function copyObject$4(source, props, object, customizer) {
2560
- var isNew = !object;
2561
- object || (object = {});
2562
- var index = -1, length = props.length;
2563
- while (++index < length) {
2564
- var key = props[index];
2565
- var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
2566
- if (newValue === void 0) {
2567
- newValue = source[key];
2568
- }
2569
- if (isNew) {
2570
- baseAssignValue(object, key, newValue);
2571
- } else {
2572
- assignValue$1(object, key, newValue);
2573
- }
2574
- }
2575
- return object;
2576
- }
2577
- var _copyObject = copyObject$4;
2578
- function baseTimes$1(n, iteratee) {
2579
- var index = -1, result = Array(n);
2580
- while (++index < n) {
2581
- result[index] = iteratee(index);
2582
- }
2583
- return result;
2584
- }
2585
- var _baseTimes = baseTimes$1;
2586
- function isObjectLike$5(value) {
2587
- return value != null && typeof value == "object";
2588
- }
2589
- var isObjectLike_1 = isObjectLike$5;
2590
- var baseGetTag$2 = _baseGetTag, isObjectLike$4 = isObjectLike_1;
2591
- var argsTag$2 = "[object Arguments]";
2592
- function baseIsArguments$1(value) {
2593
- return isObjectLike$4(value) && baseGetTag$2(value) == argsTag$2;
2594
- }
2595
- var _baseIsArguments = baseIsArguments$1;
2596
- var baseIsArguments = _baseIsArguments, isObjectLike$3 = isObjectLike_1;
2597
- var objectProto$6 = Object.prototype;
2598
- var hasOwnProperty$4 = objectProto$6.hasOwnProperty;
2599
- var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
2600
- var isArguments$1 = baseIsArguments(/* @__PURE__ */ function() {
2601
- return arguments;
2602
- }()) ? baseIsArguments : function(value) {
2603
- return isObjectLike$3(value) && hasOwnProperty$4.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
2604
- };
2605
- var isArguments_1 = isArguments$1;
2606
- var isArray$3 = Array.isArray;
2607
- var isArray_1 = isArray$3;
2608
- var isBuffer$2 = { exports: {} };
2609
- function stubFalse() {
2610
- return false;
2611
- }
2612
- var stubFalse_1 = stubFalse;
2613
- isBuffer$2.exports;
2614
- (function(module2, exports$1) {
2615
- var root2 = _root, stubFalse2 = stubFalse_1;
2616
- var freeExports = exports$1 && !exports$1.nodeType && exports$1;
2617
- var freeModule = freeExports && true && module2 && !module2.nodeType && module2;
2618
- var moduleExports = freeModule && freeModule.exports === freeExports;
2619
- var Buffer = moduleExports ? root2.Buffer : void 0;
2620
- var nativeIsBuffer = Buffer ? Buffer.isBuffer : void 0;
2621
- var isBuffer2 = nativeIsBuffer || stubFalse2;
2622
- module2.exports = isBuffer2;
2623
- })(isBuffer$2, isBuffer$2.exports);
2624
- var isBufferExports = isBuffer$2.exports;
2625
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
2626
- var reIsUint = /^(?:0|[1-9]\d*)$/;
2627
- function isIndex$1(value, length) {
2628
- var type = typeof value;
2629
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
2630
- return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
2631
- }
2632
- var _isIndex = isIndex$1;
2633
- var MAX_SAFE_INTEGER = 9007199254740991;
2634
- function isLength$2(value) {
2635
- return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2636
- }
2637
- var isLength_1 = isLength$2;
2638
- var baseGetTag$1 = _baseGetTag, isLength$1 = isLength_1, isObjectLike$2 = isObjectLike_1;
2639
- 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]";
2640
- 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]";
2641
- var typedArrayTags = {};
2642
- 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;
2643
- 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;
2644
- function baseIsTypedArray$1(value) {
2645
- return isObjectLike$2(value) && isLength$1(value.length) && !!typedArrayTags[baseGetTag$1(value)];
2646
- }
2647
- var _baseIsTypedArray = baseIsTypedArray$1;
2648
- function baseUnary$3(func) {
2649
- return function(value) {
2650
- return func(value);
2651
- };
2652
- }
2653
- var _baseUnary = baseUnary$3;
2654
- var _nodeUtil = { exports: {} };
2655
- _nodeUtil.exports;
2656
- (function(module2, exports$1) {
2657
- var freeGlobal2 = _freeGlobal;
2658
- var freeExports = exports$1 && !exports$1.nodeType && exports$1;
2659
- var freeModule = freeExports && true && module2 && !module2.nodeType && module2;
2660
- var moduleExports = freeModule && freeModule.exports === freeExports;
2661
- var freeProcess = moduleExports && freeGlobal2.process;
2662
- var nodeUtil2 = function() {
2663
- try {
2664
- var types = freeModule && freeModule.require && freeModule.require("util").types;
2665
- if (types) {
2666
- return types;
2667
- }
2668
- return freeProcess && freeProcess.binding && freeProcess.binding("util");
2669
- } catch (e) {
2670
- }
2671
- }();
2672
- module2.exports = nodeUtil2;
2673
- })(_nodeUtil, _nodeUtil.exports);
2674
- var _nodeUtilExports = _nodeUtil.exports;
2675
- var baseIsTypedArray = _baseIsTypedArray, baseUnary$2 = _baseUnary, nodeUtil$2 = _nodeUtilExports;
2676
- var nodeIsTypedArray = nodeUtil$2 && nodeUtil$2.isTypedArray;
2677
- var isTypedArray$1 = nodeIsTypedArray ? baseUnary$2(nodeIsTypedArray) : baseIsTypedArray;
2678
- var isTypedArray_1 = isTypedArray$1;
2679
- var baseTimes = _baseTimes, isArguments = isArguments_1, isArray$2 = isArray_1, isBuffer$1 = isBufferExports, isIndex = _isIndex, isTypedArray = isTypedArray_1;
2680
- var objectProto$5 = Object.prototype;
2681
- var hasOwnProperty$3 = objectProto$5.hasOwnProperty;
2682
- function arrayLikeKeys$2(value, inherited) {
2683
- 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;
2684
- for (var key in value) {
2685
- if ((inherited || hasOwnProperty$3.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
2686
- (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
2687
- isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
2688
- isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
2689
- isIndex(key, length)))) {
2690
- result.push(key);
2691
- }
2692
- }
2693
- return result;
2694
- }
2695
- var _arrayLikeKeys = arrayLikeKeys$2;
2696
- var objectProto$4 = Object.prototype;
2697
- function isPrototype$3(value) {
2698
- var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$4;
2699
- return value === proto;
2700
- }
2701
- var _isPrototype = isPrototype$3;
2702
- function overArg$2(func, transform) {
2703
- return function(arg) {
2704
- return func(transform(arg));
2705
- };
2706
- }
2707
- var _overArg = overArg$2;
2708
- var overArg$1 = _overArg;
2709
- var nativeKeys$1 = overArg$1(Object.keys, Object);
2710
- var _nativeKeys = nativeKeys$1;
2711
- var isPrototype$2 = _isPrototype, nativeKeys = _nativeKeys;
2712
- var objectProto$3 = Object.prototype;
2713
- var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
2714
- function baseKeys$1(object) {
2715
- if (!isPrototype$2(object)) {
2716
- return nativeKeys(object);
2717
- }
2718
- var result = [];
2719
- for (var key in Object(object)) {
2720
- if (hasOwnProperty$2.call(object, key) && key != "constructor") {
2721
- result.push(key);
2722
- }
2723
- }
2724
- return result;
2725
- }
2726
- var _baseKeys = baseKeys$1;
2727
- var isFunction = isFunction_1, isLength = isLength_1;
2728
- function isArrayLike$2(value) {
2729
- return value != null && isLength(value.length) && !isFunction(value);
2730
- }
2731
- var isArrayLike_1 = isArrayLike$2;
2732
- var arrayLikeKeys$1 = _arrayLikeKeys, baseKeys = _baseKeys, isArrayLike$1 = isArrayLike_1;
2733
- function keys$3(object) {
2734
- return isArrayLike$1(object) ? arrayLikeKeys$1(object) : baseKeys(object);
2735
- }
2736
- var keys_1 = keys$3;
2737
- var copyObject$3 = _copyObject, keys$2 = keys_1;
2738
- function baseAssign$1(object, source) {
2739
- return object && copyObject$3(source, keys$2(source), object);
2740
- }
2741
- var _baseAssign = baseAssign$1;
2742
- function nativeKeysIn$1(object) {
2743
- var result = [];
2744
- if (object != null) {
2745
- for (var key in Object(object)) {
2746
- result.push(key);
2747
- }
2748
- }
2749
- return result;
2750
- }
2751
- var _nativeKeysIn = nativeKeysIn$1;
2752
- var isObject$2 = isObject_1, isPrototype$1 = _isPrototype, nativeKeysIn = _nativeKeysIn;
2753
- var objectProto$2 = Object.prototype;
2754
- var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
2755
- function baseKeysIn$1(object) {
2756
- if (!isObject$2(object)) {
2757
- return nativeKeysIn(object);
2758
- }
2759
- var isProto = isPrototype$1(object), result = [];
2760
- for (var key in object) {
2761
- if (!(key == "constructor" && (isProto || !hasOwnProperty$1.call(object, key)))) {
2762
- result.push(key);
2763
- }
2764
- }
2765
- return result;
2766
- }
2767
- var _baseKeysIn = baseKeysIn$1;
2768
- var arrayLikeKeys = _arrayLikeKeys, baseKeysIn = _baseKeysIn, isArrayLike = isArrayLike_1;
2769
- function keysIn$3(object) {
2770
- return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
2771
- }
2772
- var keysIn_1 = keysIn$3;
2773
- var copyObject$2 = _copyObject, keysIn$2 = keysIn_1;
2774
- function baseAssignIn$1(object, source) {
2775
- return object && copyObject$2(source, keysIn$2(source), object);
2776
- }
2777
- var _baseAssignIn = baseAssignIn$1;
2778
- var _cloneBuffer = { exports: {} };
2779
- _cloneBuffer.exports;
2780
- (function(module2, exports$1) {
2781
- var root2 = _root;
2782
- var freeExports = exports$1 && !exports$1.nodeType && exports$1;
2783
- var freeModule = freeExports && true && module2 && !module2.nodeType && module2;
2784
- var moduleExports = freeModule && freeModule.exports === freeExports;
2785
- var Buffer = moduleExports ? root2.Buffer : void 0, allocUnsafe = Buffer ? Buffer.allocUnsafe : void 0;
2786
- function cloneBuffer2(buffer, isDeep) {
2787
- if (isDeep) {
2788
- return buffer.slice();
2789
- }
2790
- var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
2791
- buffer.copy(result);
2792
- return result;
2793
- }
2794
- module2.exports = cloneBuffer2;
2795
- })(_cloneBuffer, _cloneBuffer.exports);
2796
- var _cloneBufferExports = _cloneBuffer.exports;
2797
- function copyArray$1(source, array) {
2798
- var index = -1, length = source.length;
2799
- array || (array = Array(length));
2800
- while (++index < length) {
2801
- array[index] = source[index];
2802
- }
2803
- return array;
2804
- }
2805
- var _copyArray = copyArray$1;
2806
- function arrayFilter$1(array, predicate) {
2807
- var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
2808
- while (++index < length) {
2809
- var value = array[index];
2810
- if (predicate(value, index, array)) {
2811
- result[resIndex++] = value;
2812
- }
2813
- }
2814
- return result;
2815
- }
2816
- var _arrayFilter = arrayFilter$1;
2817
- function stubArray$2() {
2818
- return [];
2819
- }
2820
- var stubArray_1 = stubArray$2;
2821
- var arrayFilter = _arrayFilter, stubArray$1 = stubArray_1;
2822
- var objectProto$1 = Object.prototype;
2823
- var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
2824
- var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
2825
- var getSymbols$3 = !nativeGetSymbols$1 ? stubArray$1 : function(object) {
2826
- if (object == null) {
2827
- return [];
2828
- }
2829
- object = Object(object);
2830
- return arrayFilter(nativeGetSymbols$1(object), function(symbol) {
2831
- return propertyIsEnumerable.call(object, symbol);
2832
- });
2833
- };
2834
- var _getSymbols = getSymbols$3;
2835
- var copyObject$1 = _copyObject, getSymbols$2 = _getSymbols;
2836
- function copySymbols$1(source, object) {
2837
- return copyObject$1(source, getSymbols$2(source), object);
2838
- }
2839
- var _copySymbols = copySymbols$1;
2840
- function arrayPush$2(array, values) {
2841
- var index = -1, length = values.length, offset = array.length;
2842
- while (++index < length) {
2843
- array[offset + index] = values[index];
2844
- }
2845
- return array;
2846
- }
2847
- var _arrayPush = arrayPush$2;
2848
- var overArg = _overArg;
2849
- var getPrototype$2 = overArg(Object.getPrototypeOf, Object);
2850
- var _getPrototype = getPrototype$2;
2851
- var arrayPush$1 = _arrayPush, getPrototype$1 = _getPrototype, getSymbols$1 = _getSymbols, stubArray = stubArray_1;
2852
- var nativeGetSymbols = Object.getOwnPropertySymbols;
2853
- var getSymbolsIn$2 = !nativeGetSymbols ? stubArray : function(object) {
2854
- var result = [];
2855
- while (object) {
2856
- arrayPush$1(result, getSymbols$1(object));
2857
- object = getPrototype$1(object);
2858
- }
2859
- return result;
2860
- };
2861
- var _getSymbolsIn = getSymbolsIn$2;
2862
- var copyObject = _copyObject, getSymbolsIn$1 = _getSymbolsIn;
2863
- function copySymbolsIn$1(source, object) {
2864
- return copyObject(source, getSymbolsIn$1(source), object);
2865
- }
2866
- var _copySymbolsIn = copySymbolsIn$1;
2867
- var arrayPush = _arrayPush, isArray$1 = isArray_1;
2868
- function baseGetAllKeys$2(object, keysFunc, symbolsFunc) {
2869
- var result = keysFunc(object);
2870
- return isArray$1(object) ? result : arrayPush(result, symbolsFunc(object));
2871
- }
2872
- var _baseGetAllKeys = baseGetAllKeys$2;
2873
- var baseGetAllKeys$1 = _baseGetAllKeys, getSymbols = _getSymbols, keys$1 = keys_1;
2874
- function getAllKeys$1(object) {
2875
- return baseGetAllKeys$1(object, keys$1, getSymbols);
2876
- }
2877
- var _getAllKeys = getAllKeys$1;
2878
- var baseGetAllKeys = _baseGetAllKeys, getSymbolsIn = _getSymbolsIn, keysIn$1 = keysIn_1;
2879
- function getAllKeysIn$1(object) {
2880
- return baseGetAllKeys(object, keysIn$1, getSymbolsIn);
2881
- }
2882
- var _getAllKeysIn = getAllKeysIn$1;
2883
- var getNative$3 = _getNative, root$4 = _root;
2884
- var DataView$1 = getNative$3(root$4, "DataView");
2885
- var _DataView = DataView$1;
2886
- var getNative$2 = _getNative, root$3 = _root;
2887
- var Promise$2 = getNative$2(root$3, "Promise");
2888
- var _Promise = Promise$2;
2889
- var getNative$1 = _getNative, root$2 = _root;
2890
- var Set$2 = getNative$1(root$2, "Set");
2891
- var _Set = Set$2;
2892
- var getNative = _getNative, root$1 = _root;
2893
- var WeakMap$2 = getNative(root$1, "WeakMap");
2894
- var _WeakMap = WeakMap$2;
2895
- var DataView = _DataView, Map$1 = _Map, Promise$1 = _Promise, Set$1 = _Set, WeakMap$1 = _WeakMap, baseGetTag = _baseGetTag, toSource = _toSource;
2896
- var mapTag$3 = "[object Map]", objectTag$1 = "[object Object]", promiseTag = "[object Promise]", setTag$3 = "[object Set]", weakMapTag$1 = "[object WeakMap]";
2897
- var dataViewTag$2 = "[object DataView]";
2898
- var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$1), weakMapCtorString = toSource(WeakMap$1);
2899
- var getTag$3 = baseGetTag;
2900
- 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) {
2901
- getTag$3 = function(value) {
2902
- var result = baseGetTag(value), Ctor = result == objectTag$1 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
2903
- if (ctorString) {
2904
- switch (ctorString) {
2905
- case dataViewCtorString:
2906
- return dataViewTag$2;
2907
- case mapCtorString:
2908
- return mapTag$3;
2909
- case promiseCtorString:
2910
- return promiseTag;
2911
- case setCtorString:
2912
- return setTag$3;
2913
- case weakMapCtorString:
2914
- return weakMapTag$1;
2915
- }
2916
- }
2917
- return result;
2918
- };
2919
- }
2920
- var _getTag = getTag$3;
2921
- var objectProto = Object.prototype;
2922
- var hasOwnProperty = objectProto.hasOwnProperty;
2923
- function initCloneArray$1(array) {
2924
- var length = array.length, result = new array.constructor(length);
2925
- if (length && typeof array[0] == "string" && hasOwnProperty.call(array, "index")) {
2926
- result.index = array.index;
2927
- result.input = array.input;
2928
- }
2929
- return result;
2930
- }
2931
- var _initCloneArray = initCloneArray$1;
2932
- var root = _root;
2933
- var Uint8Array$2 = root.Uint8Array;
2934
- var _Uint8Array = Uint8Array$2;
2935
- var Uint8Array$1 = _Uint8Array;
2936
- function cloneArrayBuffer$3(arrayBuffer) {
2937
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
2938
- new Uint8Array$1(result).set(new Uint8Array$1(arrayBuffer));
2939
- return result;
2940
- }
2941
- var _cloneArrayBuffer = cloneArrayBuffer$3;
2942
- var cloneArrayBuffer$2 = _cloneArrayBuffer;
2943
- function cloneDataView$1(dataView, isDeep) {
2944
- var buffer = isDeep ? cloneArrayBuffer$2(dataView.buffer) : dataView.buffer;
2945
- return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
2946
- }
2947
- var _cloneDataView = cloneDataView$1;
2948
- var reFlags = /\w*$/;
2949
- function cloneRegExp$1(regexp) {
2950
- var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
2951
- result.lastIndex = regexp.lastIndex;
2952
- return result;
2953
- }
2954
- var _cloneRegExp = cloneRegExp$1;
2955
- var Symbol$1 = _Symbol;
2956
- var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
2957
- function cloneSymbol$1(symbol) {
2958
- return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
2959
- }
2960
- var _cloneSymbol = cloneSymbol$1;
2961
- var cloneArrayBuffer$1 = _cloneArrayBuffer;
2962
- function cloneTypedArray$1(typedArray, isDeep) {
2963
- var buffer = isDeep ? cloneArrayBuffer$1(typedArray.buffer) : typedArray.buffer;
2964
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
2965
- }
2966
- var _cloneTypedArray = cloneTypedArray$1;
2967
- var cloneArrayBuffer = _cloneArrayBuffer, cloneDataView = _cloneDataView, cloneRegExp = _cloneRegExp, cloneSymbol = _cloneSymbol, cloneTypedArray = _cloneTypedArray;
2968
- 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]";
2969
- 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]";
2970
- function initCloneByTag$1(object, tag, isDeep) {
2971
- var Ctor = object.constructor;
2972
- switch (tag) {
2973
- case arrayBufferTag$1:
2974
- return cloneArrayBuffer(object);
2975
- case boolTag$1:
2976
- case dateTag$1:
2977
- return new Ctor(+object);
2978
- case dataViewTag$1:
2979
- return cloneDataView(object, isDeep);
2980
- case float32Tag$1:
2981
- case float64Tag$1:
2982
- case int8Tag$1:
2983
- case int16Tag$1:
2984
- case int32Tag$1:
2985
- case uint8Tag$1:
2986
- case uint8ClampedTag$1:
2987
- case uint16Tag$1:
2988
- case uint32Tag$1:
2989
- return cloneTypedArray(object, isDeep);
2990
- case mapTag$2:
2991
- return new Ctor();
2992
- case numberTag$1:
2993
- case stringTag$1:
2994
- return new Ctor(object);
2995
- case regexpTag$1:
2996
- return cloneRegExp(object);
2997
- case setTag$2:
2998
- return new Ctor();
2999
- case symbolTag$1:
3000
- return cloneSymbol(object);
3001
- }
3002
- }
3003
- var _initCloneByTag = initCloneByTag$1;
3004
- var isObject$1 = isObject_1;
3005
- var objectCreate = Object.create;
3006
- var baseCreate$1 = /* @__PURE__ */ function() {
3007
- function object() {
3008
- }
3009
- return function(proto) {
3010
- if (!isObject$1(proto)) {
3011
- return {};
3012
- }
3013
- if (objectCreate) {
3014
- return objectCreate(proto);
3015
- }
3016
- object.prototype = proto;
3017
- var result = new object();
3018
- object.prototype = void 0;
3019
- return result;
3020
- };
3021
- }();
3022
- var _baseCreate = baseCreate$1;
3023
- var baseCreate = _baseCreate, getPrototype = _getPrototype, isPrototype = _isPrototype;
3024
- function initCloneObject$1(object) {
3025
- return typeof object.constructor == "function" && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
3026
- }
3027
- var _initCloneObject = initCloneObject$1;
3028
- var getTag$2 = _getTag, isObjectLike$1 = isObjectLike_1;
3029
- var mapTag$1 = "[object Map]";
3030
- function baseIsMap$1(value) {
3031
- return isObjectLike$1(value) && getTag$2(value) == mapTag$1;
3032
- }
3033
- var _baseIsMap = baseIsMap$1;
3034
- var baseIsMap = _baseIsMap, baseUnary$1 = _baseUnary, nodeUtil$1 = _nodeUtilExports;
3035
- var nodeIsMap = nodeUtil$1 && nodeUtil$1.isMap;
3036
- var isMap$1 = nodeIsMap ? baseUnary$1(nodeIsMap) : baseIsMap;
3037
- var isMap_1 = isMap$1;
3038
- var getTag$1 = _getTag, isObjectLike = isObjectLike_1;
3039
- var setTag$1 = "[object Set]";
3040
- function baseIsSet$1(value) {
3041
- return isObjectLike(value) && getTag$1(value) == setTag$1;
3042
- }
3043
- var _baseIsSet = baseIsSet$1;
3044
- var baseIsSet = _baseIsSet, baseUnary = _baseUnary, nodeUtil = _nodeUtilExports;
3045
- var nodeIsSet = nodeUtil && nodeUtil.isSet;
3046
- var isSet$1 = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
3047
- var isSet_1 = isSet$1;
3048
- 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;
3049
- var CLONE_DEEP_FLAG$1 = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG$1 = 4;
3050
- 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]";
3051
- 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]";
3052
- var cloneableTags = {};
3053
- 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;
3054
- cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
3055
- function baseClone$1(value, bitmask, customizer, key, object, stack) {
3056
- var result, isDeep = bitmask & CLONE_DEEP_FLAG$1, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG$1;
3057
- if (customizer) {
3058
- result = object ? customizer(value, key, object, stack) : customizer(value);
3059
- }
3060
- if (result !== void 0) {
3061
- return result;
3062
- }
3063
- if (!isObject(value)) {
3064
- return value;
3065
- }
3066
- var isArr = isArray(value);
3067
- if (isArr) {
3068
- result = initCloneArray(value);
3069
- if (!isDeep) {
3070
- return copyArray(value, result);
3071
- }
3072
- } else {
3073
- var tag = getTag(value), isFunc = tag == funcTag || tag == genTag;
3074
- if (isBuffer(value)) {
3075
- return cloneBuffer(value, isDeep);
3076
- }
3077
- if (tag == objectTag || tag == argsTag || isFunc && !object) {
3078
- result = isFlat || isFunc ? {} : initCloneObject(value);
3079
- if (!isDeep) {
3080
- return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value));
3081
- }
3082
- } else {
3083
- if (!cloneableTags[tag]) {
3084
- return object ? value : {};
3085
- }
3086
- result = initCloneByTag(value, tag, isDeep);
3087
- }
3088
- }
3089
- stack || (stack = new Stack());
3090
- var stacked = stack.get(value);
3091
- if (stacked) {
3092
- return stacked;
3093
- }
3094
- stack.set(value, result);
3095
- if (isSet(value)) {
3096
- value.forEach(function(subValue) {
3097
- result.add(baseClone$1(subValue, bitmask, customizer, subValue, value, stack));
3098
- });
3099
- } else if (isMap(value)) {
3100
- value.forEach(function(subValue, key2) {
3101
- result.set(key2, baseClone$1(subValue, bitmask, customizer, key2, value, stack));
3102
- });
3103
- }
3104
- var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys;
3105
- var props = isArr ? void 0 : keysFunc(value);
3106
- arrayEach(props || value, function(subValue, key2) {
3107
- if (props) {
3108
- key2 = subValue;
3109
- subValue = value[key2];
3110
- }
3111
- assignValue(result, key2, baseClone$1(subValue, bitmask, customizer, key2, value, stack));
3112
- });
3113
- return result;
3114
- }
3115
- var _baseClone = baseClone$1;
3116
- var baseClone = _baseClone;
3117
- var CLONE_DEEP_FLAG = 1, CLONE_SYMBOLS_FLAG = 4;
3118
- function cloneDeep$1(value) {
3119
- return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
3120
- }
3121
- var cloneDeep_1 = cloneDeep$1;
3122
- const cloneDeep = /* @__PURE__ */ getDefaultExportFromCjs(cloneDeep_1);
3123
2235
  class CollectionRegistry {
3124
2236
  // Normalized runtime layer (used by Data Grid / UI)
3125
2237
  collectionsByTableName = /* @__PURE__ */ new Map();
@@ -3167,7 +2279,7 @@
3167
2279
  ...c
3168
2280
  }));
3169
2281
  normalizedCollections.forEach((c, index) => {
3170
- const raw = cloneDeep(collections[index]);
2282
+ const raw = deepClone(collections[index]);
3171
2283
  this.rootCollections.push(c);
3172
2284
  this.rawRootCollections.push(raw);
3173
2285
  const normalized = this.normalizeCollection(c);
@@ -3187,7 +2299,7 @@
3187
2299
  if (!subCollection) return;
3188
2300
  this._registerRecursively(this.normalizeCollection({
3189
2301
  ...subCollection
3190
- }), cloneDeep(subCollection));
2302
+ }), deepClone(subCollection));
3191
2303
  });
3192
2304
  }
3193
2305
  });
@@ -3195,7 +2307,7 @@
3195
2307
  return true;
3196
2308
  }
3197
2309
  register(collection, rawCollection) {
3198
- const raw = rawCollection ? cloneDeep(rawCollection) : cloneDeep(collection);
2310
+ const raw = rawCollection ? deepClone(rawCollection) : deepClone(collection);
3199
2311
  this.rootCollections.push(collection);
3200
2312
  this.rawRootCollections.push(raw);
3201
2313
  this._registerRecursively(collection, raw);
@@ -3219,7 +2331,7 @@
3219
2331
  if (!subCollection) return;
3220
2332
  this._registerRecursively(this.normalizeCollection({
3221
2333
  ...subCollection
3222
- }), cloneDeep(subCollection));
2334
+ }), deepClone(subCollection));
3223
2335
  });
3224
2336
  }
3225
2337
  }
@@ -4485,7 +3597,25 @@
4485
3597
  return result;
4486
3598
  }
4487
3599
  return value;
3600
+ case "string":
3601
+ if (typeof value === "string") {
3602
+ if (value.startsWith("data:application/octet-stream;base64,")) {
3603
+ const base64Data = value.split(",")[1];
3604
+ if (base64Data) {
3605
+ return Buffer.from(base64Data, "base64");
3606
+ }
3607
+ }
3608
+ }
3609
+ return value;
4488
3610
  default:
3611
+ if (typeof value === "string") {
3612
+ if (value.startsWith("data:application/octet-stream;base64,")) {
3613
+ const base64Data = value.split(",")[1];
3614
+ if (base64Data) {
3615
+ return Buffer.from(base64Data, "base64");
3616
+ }
3617
+ }
3618
+ }
4489
3619
  return value;
4490
3620
  }
4491
3621
  }
@@ -4611,6 +3741,37 @@
4611
3741
  return value;
4612
3742
  }
4613
3743
  switch (property.type) {
3744
+ case "string": {
3745
+ if (typeof value === "string") return value;
3746
+ let isBuffer = false;
3747
+ let buf = null;
3748
+ if (Buffer.isBuffer(value)) {
3749
+ isBuffer = true;
3750
+ buf = value;
3751
+ } else if (typeof value === "object" && value !== null && value.type === "Buffer" && Array.isArray(value.data)) {
3752
+ isBuffer = true;
3753
+ buf = Buffer.from(value.data);
3754
+ }
3755
+ if (isBuffer && buf) {
3756
+ let isPrintable = true;
3757
+ for (let i = 0; i < buf.length; i++) {
3758
+ const b = buf[i];
3759
+ if ((b < 32 || b > 126) && b !== 9 && b !== 10 && b !== 13) {
3760
+ isPrintable = false;
3761
+ break;
3762
+ }
3763
+ }
3764
+ return isPrintable ? buf.toString("utf8") : `data:application/octet-stream;base64,${buf.toString("base64")}`;
3765
+ }
3766
+ if (typeof value === "object" && value !== null) {
3767
+ try {
3768
+ return JSON.stringify(value);
3769
+ } catch {
3770
+ return String(value);
3771
+ }
3772
+ }
3773
+ return String(value);
3774
+ }
4614
3775
  case "relation":
4615
3776
  if (typeof value === "string" || typeof value === "number") {
4616
3777
  let relationDef = property.relation;
@@ -4694,8 +3855,29 @@
4694
3855
  }
4695
3856
  return null;
4696
3857
  }
4697
- default:
3858
+ default: {
3859
+ let isBuffer = false;
3860
+ let buf = null;
3861
+ if (Buffer.isBuffer(value)) {
3862
+ isBuffer = true;
3863
+ buf = value;
3864
+ } else if (typeof value === "object" && value !== null && value.type === "Buffer" && Array.isArray(value.data)) {
3865
+ isBuffer = true;
3866
+ buf = Buffer.from(value.data);
3867
+ }
3868
+ if (isBuffer && buf) {
3869
+ let isPrintable = true;
3870
+ for (let i = 0; i < buf.length; i++) {
3871
+ const b = buf[i];
3872
+ if ((b < 32 || b > 126) && b !== 9 && b !== 10 && b !== 13) {
3873
+ isPrintable = false;
3874
+ break;
3875
+ }
3876
+ }
3877
+ return isPrintable ? buf.toString("utf8") : `data:application/octet-stream;base64,${buf.toString("base64")}`;
3878
+ }
4698
3879
  return value;
3880
+ }
4699
3881
  }
4700
3882
  }
4701
3883
  function normalizeScalarValues(data, properties, collection, resolvedRelations, options) {
@@ -5963,6 +5145,10 @@
5963
5145
  await this.resolveJoinPathRelations(entity, collection, collectionPath, parsedId, databaseId);
5964
5146
  return entity;
5965
5147
  } catch (e) {
5148
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5149
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5150
+ 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.`);
5151
+ }
5966
5152
  console.warn(`[EntityFetchService] db.query.findFirst failed for ${collectionPath}, falling back to db.select:`, e);
5967
5153
  }
5968
5154
  }
@@ -6023,6 +5209,10 @@
6023
5209
  const entities = results2.map((row) => this.drizzleResultToEntity(row, collection, collectionPath, idInfo, options.databaseId, idInfoArray));
6024
5210
  return entities;
6025
5211
  } catch (e) {
5212
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5213
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5214
+ 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.`);
5215
+ }
6026
5216
  console.warn(`[EntityFetchService] db.query.findMany failed for ${collectionPath}, falling back to db.select:`, e);
6027
5217
  }
6028
5218
  }
@@ -6292,6 +5482,10 @@
6292
5482
  await this.resolveJoinPathRelationsBatchRest(restRows, collection, collectionPath, idInfoArray, include);
6293
5483
  return restRows;
6294
5484
  } catch (e) {
5485
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5486
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5487
+ 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.`);
5488
+ }
6295
5489
  console.warn(`[fetchCollectionForRest] db.query.findMany failed for ${collectionPath}, falling back:`, e);
6296
5490
  }
6297
5491
  }
@@ -6372,6 +5566,10 @@
6372
5566
  await this.resolveJoinPathRelationsBatchRest([restRow], collection, collectionPath, idInfoArray, include);
6373
5567
  return restRow;
6374
5568
  } catch (e) {
5569
+ if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
5570
+ console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
5571
+ 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.`);
5572
+ }
6375
5573
  console.warn(`[fetchEntityForRest] db.query.findFirst failed for ${collectionPath}, falling back:`, e);
6376
5574
  }
6377
5575
  }
@@ -6765,22 +5963,78 @@
6765
5963
  const pgError = this.extractPgError(error);
6766
5964
  if (pgError) {
6767
5965
  const detail = pgError.detail;
5966
+ const hint = pgError.hint;
6768
5967
  const constraint = pgError.constraint;
6769
5968
  const column = pgError.column;
6770
5969
  const table = pgError.table;
5970
+ const dataType = pgError.dataType;
5971
+ const pgMessage = pgError.message || "Unknown database error";
5972
+ const suffix = hint ? ` Hint: ${hint}` : "";
5973
+ const tableRef = table ?? collectionSlug;
6771
5974
  switch (pgError.code) {
6772
5975
  case "23503":
6773
- return new Error(detail ? `Foreign key constraint violated: ${detail}` : `Cannot save: a foreign key constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".`);
5976
+ return new Error(detail ? `Foreign key constraint violated: ${detail}${suffix}` : `Cannot save: a foreign key constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
6774
5977
  case "23505":
6775
- return new Error(detail ? `Duplicate value: ${detail}` : `Cannot save: a unique constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".`);
5978
+ return new Error(detail ? `Duplicate value: ${detail}${suffix}` : `Cannot save: a unique constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
6776
5979
  case "23502":
6777
- return new Error(`Missing required field: "${column ?? "unknown"}" in "${table ?? collectionSlug}" cannot be empty.`);
5980
+ return new Error(`Missing required field: "${column ?? "unknown"}" in "${tableRef}" cannot be empty.${suffix}`);
6778
5981
  case "23514":
6779
- return new Error(`Validation failed: a check constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".`);
5982
+ return new Error(`Validation failed: a check constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
5983
+ case "22P02":
5984
+ return new Error(`Invalid data format in "${collectionSlug}": ${pgMessage}${suffix}`);
5985
+ case "22001":
5986
+ return new Error(`Value too long for column "${column ?? "unknown"}" in "${tableRef}": ${pgMessage}${suffix}`);
5987
+ case "22003":
5988
+ return new Error(`Numeric value out of range for column "${column ?? "unknown"}" in "${tableRef}": ${pgMessage}${suffix}`);
5989
+ case "42703":
5990
+ return new Error(`Unknown column in "${tableRef}": ${pgMessage}. Check if your schema is up to date (run migrations).${suffix}`);
5991
+ case "42P01":
5992
+ return new Error(`Table not found for "${collectionSlug}": ${pgMessage}. Check if your schema is up to date (run migrations).${suffix}`);
5993
+ default: {
5994
+ const parts = [`Database error in "${collectionSlug}" [${pgError.code}]: ${pgMessage}`];
5995
+ if (detail) parts.push(`Detail: ${detail}`);
5996
+ if (column) parts.push(`Column: ${column}`);
5997
+ if (dataType) parts.push(`Data type: ${dataType}`);
5998
+ if (constraint) parts.push(`Constraint: ${constraint}`);
5999
+ if (hint) parts.push(`Hint: ${hint}`);
6000
+ return new Error(parts.join(". "));
6001
+ }
6002
+ }
6003
+ }
6004
+ const causeMessage = this.extractCauseMessage(error);
6005
+ if (causeMessage) {
6006
+ return new Error(`Database error in "${collectionSlug}": ${causeMessage}`);
6007
+ }
6008
+ if (error instanceof Error) {
6009
+ const cleaned = this.stripSqlFromMessage(error.message, collectionSlug);
6010
+ return new Error(cleaned);
6011
+ }
6012
+ return new Error(`Database error in "${collectionSlug}": ${String(error)}`);
6013
+ }
6014
+ /**
6015
+ * Walk the error cause chain and return the deepest meaningful message.
6016
+ */
6017
+ extractCauseMessage(error) {
6018
+ if (!error || typeof error !== "object") return null;
6019
+ const err = error;
6020
+ if (err.cause && typeof err.cause === "object") {
6021
+ const deeper = this.extractCauseMessage(err.cause);
6022
+ if (deeper) return deeper;
6023
+ if (err.cause instanceof Error && err.cause.message) {
6024
+ return err.cause.message;
6780
6025
  }
6781
6026
  }
6782
- if (error instanceof Error) return error;
6783
- return new Error(String(error));
6027
+ return null;
6028
+ }
6029
+ /**
6030
+ * Strip the raw SQL query from a Drizzle "Failed query: ..." message,
6031
+ * keeping only the error description.
6032
+ */
6033
+ stripSqlFromMessage(message, collectionSlug) {
6034
+ if (message.startsWith("Failed query:")) {
6035
+ return `Failed to save entity in "${collectionSlug}". Check server logs for details.`;
6036
+ }
6037
+ return message;
6784
6038
  }
6785
6039
  /**
6786
6040
  * Extract the underlying PostgreSQL error from a Drizzle wrapper.
@@ -6789,7 +6043,7 @@
6789
6043
  extractPgError(error) {
6790
6044
  if (!error || typeof error !== "object") return null;
6791
6045
  const err = error;
6792
- if (err.code && /^[0-9]{5}$/.test(err.code)) {
6046
+ if (err.code && /^[0-9A-Z]{5}$/.test(err.code)) {
6793
6047
  return err;
6794
6048
  }
6795
6049
  if (err.cause && typeof err.cause === "object") {
@@ -7077,6 +6331,7 @@
7077
6331
  branchService;
7078
6332
  user;
7079
6333
  data;
6334
+ client;
7080
6335
  /**
7081
6336
  * When true, realtime notifications are deferred until after the
7082
6337
  * wrapping transaction commits. Set by `withAuth` → `withTransaction`.
@@ -7166,7 +6421,8 @@
7166
6421
  const contextForCallback = {
7167
6422
  user: this.user,
7168
6423
  driver: this,
7169
- data: this.data
6424
+ data: this.data,
6425
+ client: this.client
7170
6426
  };
7171
6427
  return Promise.all(entities.map(async (entity) => {
7172
6428
  let fetched = entity;
@@ -7260,7 +6516,8 @@
7260
6516
  const contextForCallback = {
7261
6517
  user: this.user,
7262
6518
  driver: this,
7263
- data: this.data
6519
+ data: this.data,
6520
+ client: this.client
7264
6521
  };
7265
6522
  if (callbacks?.afterRead) {
7266
6523
  entity = await callbacks.afterRead({
@@ -7329,7 +6586,8 @@
7329
6586
  const contextForCallback = {
7330
6587
  user: this.user,
7331
6588
  driver: this,
7332
- data: this.data
6589
+ data: this.data,
6590
+ client: this.client
7333
6591
  };
7334
6592
  let previousValuesForHistory;
7335
6593
  if (status === "existing" && entityId) {
@@ -7364,6 +6622,14 @@
7364
6622
  if (result) updatedValues = mergeDeep(updatedValues, result);
7365
6623
  }
7366
6624
  }
6625
+ if (resolvedCollection?.properties) {
6626
+ updatedValues = updateDateAutoValues({
6627
+ inputValues: updatedValues,
6628
+ properties: resolvedCollection.properties,
6629
+ status: status ?? "new",
6630
+ timestampNowValue: /* @__PURE__ */ new Date()
6631
+ });
6632
+ }
7367
6633
  try {
7368
6634
  let savedEntity = await this.entityService.saveEntity(path2, updatedValues, entityId, resolvedCollection?.databaseId);
7369
6635
  if (savedEntity && (callbacks?.afterRead || propertyCallbacks?.afterRead)) {
@@ -7469,7 +6735,8 @@
7469
6735
  const contextForCallback = {
7470
6736
  user: this.user,
7471
6737
  driver: this,
7472
- data: this.data
6738
+ data: this.data,
6739
+ client: this.client
7473
6740
  };
7474
6741
  if (callbacks?.beforeDelete || propertyCallbacks?.beforeDelete) {
7475
6742
  if (callbacks?.beforeDelete) {
@@ -7796,6 +7063,7 @@
7796
7063
  txDelegate.entityService = txEntityService;
7797
7064
  txDelegate._deferNotifications = true;
7798
7065
  txDelegate._pendingNotifications = pendingNotifications;
7066
+ txDelegate.client = this.delegate.client;
7799
7067
  return await operation(txDelegate);
7800
7068
  });
7801
7069
  for (const notification of pendingNotifications) {
@@ -8077,6 +7345,12 @@
8077
7345
  references: [users.id]
8078
7346
  })
8079
7347
  }));
7348
+ const resolveColumnName = (propName, prop) => {
7349
+ if (prop && "columnName" in prop && typeof prop.columnName === "string") {
7350
+ return prop.columnName;
7351
+ }
7352
+ return toSnakeCase(propName);
7353
+ };
8080
7354
  const getPrimaryKeyProp = (collection) => {
8081
7355
  if (collection.properties) {
8082
7356
  const idPropEntry = Object.entries(collection.properties).find(([_, prop]) => "isId" in prop && Boolean(prop.isId));
@@ -8117,7 +7391,7 @@
8117
7391
  return !hasExplicitId && propName === "id";
8118
7392
  };
8119
7393
  const getDrizzleColumn = (propName, prop, collection, collections) => {
8120
- const colName = toSnakeCase(propName);
7394
+ const colName = resolveColumnName(propName, prop);
8121
7395
  let columnDefinition;
8122
7396
  switch (prop.type) {
8123
7397
  case "string": {
@@ -8189,6 +7463,9 @@
8189
7463
  } else {
8190
7464
  columnDefinition = `timestamp("${colName}", { withTimezone: true, mode: 'string' })`;
8191
7465
  }
7466
+ if (dateProp.autoValue === "on_create" || dateProp.autoValue === "on_update") {
7467
+ columnDefinition += `.default(sql\`now()\`)`;
7468
+ }
8192
7469
  break;
8193
7470
  }
8194
7471
  case "map":
@@ -8221,7 +7498,7 @@
8221
7498
  } catch {
8222
7499
  return null;
8223
7500
  }
8224
- const fkColumnName = toSnakeCase(relation.localKey);
7501
+ const fkColumnName = relation.localKey;
8225
7502
  const targetTableVar = getTableVarName(getTableName(targetCollection));
8226
7503
  const pkProp = getPrimaryKeyProp(targetCollection);
8227
7504
  const targetIdField = pkProp.name;
@@ -8409,7 +7686,7 @@
8409
7686
  Object.entries(collection.properties ?? {}).forEach(([propName, prop]) => {
8410
7687
  if ("enum" in prop && (prop.type === "string" || prop.type === "number") && prop.enum) {
8411
7688
  const enumVarName = getEnumVarName(collectionPath, propName);
8412
- const enumDbName = `${collectionPath}_${toSnakeCase(propName)}`;
7689
+ const enumDbName = `${collectionPath}_${resolveColumnName(propName, prop)}`;
8413
7690
  const values = Array.isArray(prop.enum) ? prop.enum.map((v) => String(v.id ?? v)) : Object.keys(prop.enum);
8414
7691
  if (values.length > 0) {
8415
7692
  schemaContent += `export const ${enumVarName} = pgEnum("${enumDbName}", [${values.map((v) => `'${v}'`).join(", ")}]);
@@ -8466,9 +7743,9 @@
8466
7743
  const targetId = getPrimaryKeyName(targetCollection);
8467
7744
  schemaContent += `export const ${tableVarName} = pgTable("${tableName}", {
8468
7745
  `;
8469
- schemaContent += ` ${sourceColumn}: ${sourceColType}("${toSnakeCase(sourceColumn)}").notNull().references(() => ${getTableVarName(getTableName(sourceCollection))}.${sourceId}, ${refOptions}),
7746
+ schemaContent += ` ${sourceColumn}: ${sourceColType}("${sourceColumn}").notNull().references(() => ${getTableVarName(getTableName(sourceCollection))}.${sourceId}, ${refOptions}),
8470
7747
  `;
8471
- schemaContent += ` ${targetColumn}: ${targetColType}("${toSnakeCase(targetColumn)}").notNull().references(() => ${getTableVarName(getTableName(targetCollection))}.${targetId}, ${refOptions}),
7748
+ schemaContent += ` ${targetColumn}: ${targetColType}("${targetColumn}").notNull().references(() => ${getTableVarName(getTableName(targetCollection))}.${targetId}, ${refOptions}),
8472
7749
  `;
8473
7750
  schemaContent += "}, (table) => ({\n";
8474
7751
  schemaContent += ` pk: primaryKey({ columns: [table.${sourceColumn}, table.${targetColumn}] })
@@ -8592,6 +7869,32 @@
8592
7869
  console.warn(`Could not generate relation ${relationKey} for ${collection.name}:`, e);
8593
7870
  }
8594
7871
  }
7872
+ for (const otherCollection of collections) {
7873
+ if (otherCollection.slug === collection.slug) continue;
7874
+ const otherRelations = resolveCollectionRelations(otherCollection);
7875
+ for (const [otherKey, otherRel] of Object.entries(otherRelations)) {
7876
+ if (otherRel.direction === "inverse" && otherRel.foreignKeyOnTarget) {
7877
+ try {
7878
+ const otherTarget = otherRel.target();
7879
+ if (otherTarget.slug === collection.slug) {
7880
+ const drizzleRelationName = computeSharedRelationName(otherRel, otherCollection, collections);
7881
+ const deduplicationKey = `${drizzleRelationName}::owning`;
7882
+ if (!emittedRelationNames.has(deduplicationKey)) {
7883
+ const otherTableVar = getTableVarName(getTableName(otherCollection));
7884
+ const synthKey = `_synth_${otherTableVar}_${otherRel.foreignKeyOnTarget}`;
7885
+ tableRelations.push(` "${synthKey}": one(${otherTableVar}, {
7886
+ fields: [${tableVarName}.${otherRel.foreignKeyOnTarget}],
7887
+ references: [${otherTableVar}.${getPrimaryKeyName(otherCollection)}],
7888
+ relationName: "${drizzleRelationName}"
7889
+ })`);
7890
+ emittedRelationNames.add(deduplicationKey);
7891
+ }
7892
+ }
7893
+ } catch (e) {
7894
+ }
7895
+ }
7896
+ }
7897
+ }
8595
7898
  }
8596
7899
  if (tableRelations.length > 0) {
8597
7900
  const relVarName = `${tableVarName}Relations`;