@rebasepro/server-postgresql 0.0.1-canary.d44c30b → 0.0.1-canary.e17585f
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.
- package/dist/index.es.js +683 -1362
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +614 -1293
- package/dist/index.umd.js.map +1 -1
- package/dist/server-postgresql/src/PostgresAdapter.d.ts +6 -0
- package/dist/server-postgresql/src/PostgresBackendDriver.d.ts +8 -1
- package/dist/server-postgresql/src/PostgresBootstrapper.d.ts +0 -5
- package/dist/server-postgresql/src/index.d.ts +1 -0
- package/dist/server-postgresql/src/schema/introspect-db-inference.d.ts +5 -0
- package/dist/server-postgresql/src/schema/introspect-db-logic.d.ts +117 -0
- package/dist/server-postgresql/src/schema/introspect-db.d.ts +1 -0
- package/dist/server-postgresql/src/services/EntityPersistService.d.ts +9 -0
- package/dist/server-postgresql/src/services/realtimeService.d.ts +12 -0
- package/dist/server-postgresql/src/websocket.d.ts +2 -1
- package/dist/types/src/controllers/auth.d.ts +8 -2
- package/dist/types/src/controllers/client.d.ts +13 -0
- package/dist/types/src/controllers/collection_registry.d.ts +2 -1
- package/dist/types/src/controllers/data_driver.d.ts +36 -1
- package/dist/types/src/controllers/navigation.d.ts +18 -6
- package/dist/types/src/controllers/registry.d.ts +9 -1
- package/dist/types/src/controllers/side_entity_controller.d.ts +7 -0
- package/dist/types/src/rebase_context.d.ts +17 -0
- package/dist/types/src/types/auth_adapter.d.ts +354 -0
- package/dist/types/src/types/backend_hooks.d.ts +187 -0
- package/dist/types/src/types/collections.d.ts +75 -11
- package/dist/types/src/types/component_ref.d.ts +47 -0
- package/dist/types/src/types/cron.d.ts +1 -1
- package/dist/types/src/types/database_adapter.d.ts +90 -0
- package/dist/types/src/types/entity_views.d.ts +6 -7
- package/dist/types/src/types/formex.d.ts +40 -0
- package/dist/types/src/types/index.d.ts +5 -0
- package/dist/types/src/types/plugins.d.ts +6 -3
- package/dist/types/src/types/properties.d.ts +72 -88
- package/dist/types/src/types/slots.d.ts +20 -10
- package/dist/types/src/types/translations.d.ts +12 -0
- package/package.json +6 -5
- package/src/PostgresAdapter.ts +52 -0
- package/src/PostgresBackendDriver.ts +49 -7
- package/src/PostgresBootstrapper.ts +4 -7
- package/src/auth/ensure-tables.ts +3 -121
- package/src/cli.ts +68 -2
- package/src/data-transformer.ts +84 -1
- package/src/index.ts +1 -0
- package/src/schema/doctor.ts +14 -2
- package/src/schema/generate-drizzle-schema-logic.ts +59 -30
- package/src/schema/introspect-db-inference.ts +238 -0
- package/src/schema/introspect-db-logic.ts +896 -0
- package/src/schema/introspect-db.ts +254 -0
- package/src/services/EntityFetchService.ts +16 -0
- package/src/services/EntityPersistService.ts +95 -13
- package/src/services/realtimeService.ts +35 -0
- package/src/utils/drizzle-conditions.ts +6 -0
- package/src/websocket.ts +60 -11
- package/test/generate-drizzle-schema.test.ts +342 -0
- package/test/introspect-db-generation.test.ts +458 -0
- package/test/introspect-db-utils.test.ts +392 -0
- package/test/property-ordering.test.ts +395 -0
- package/test/relations.test.ts +4 -4
- package/test/unmapped-tables-safety.test.ts +345 -0
- package/jest-all.log +0 -3128
- package/jest.log +0 -49
- package/scratch.ts +0 -41
- package/test-drizzle-bug.ts +0 -18
- package/test-drizzle-out/0000_cultured_freak.sql +0 -7
- package/test-drizzle-out/0001_tiresome_professor_monster.sql +0 -1
- package/test-drizzle-out/meta/0000_snapshot.json +0 -55
- package/test-drizzle-out/meta/0001_snapshot.json +0 -63
- package/test-drizzle-out/meta/_journal.json +0 -20
- package/test-drizzle-prompt.sh +0 -2
- package/test-policy-prompt.sh +0 -3
- package/test-programmatic.ts +0 -30
- package/test-programmatic2.ts +0 -59
- package/test-schema-no-policies.ts +0 -12
- package/test_drizzle_mock.js +0 -3
- package/test_find_changed.mjs +0 -32
- package/test_hash.js +0 -14
- 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
|
|
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
|
|
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
|
|
956
|
+
if (!isObject(target)) {
|
|
943
957
|
return target;
|
|
944
958
|
}
|
|
945
959
|
const output = {
|
|
946
960
|
...target
|
|
947
961
|
};
|
|
948
|
-
if (!isObject
|
|
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
|
|
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,
|
|
@@ -1235,6 +1323,17 @@
|
|
|
1235
1323
|
break;
|
|
1236
1324
|
}
|
|
1237
1325
|
}
|
|
1326
|
+
if (!isManyToManyInverse && targetCollection.properties) {
|
|
1327
|
+
for (const [propKey, prop] of Object.entries(targetCollection.properties)) {
|
|
1328
|
+
if (prop.type !== "relation") continue;
|
|
1329
|
+
const relProp = prop;
|
|
1330
|
+
const relName = relProp.relationName || propKey;
|
|
1331
|
+
if (relName === newRelation.inverseRelationName && relProp.cardinality === "many" && (relProp.direction === "owning" || !relProp.direction)) {
|
|
1332
|
+
isManyToManyInverse = true;
|
|
1333
|
+
break;
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1238
1337
|
} catch (e) {
|
|
1239
1338
|
}
|
|
1240
1339
|
}
|
|
@@ -1358,7 +1457,7 @@
|
|
|
1358
1457
|
}
|
|
1359
1458
|
var logic = { exports: {} };
|
|
1360
1459
|
(function(module2, exports$1) {
|
|
1361
|
-
(function(
|
|
1460
|
+
(function(root, factory) {
|
|
1362
1461
|
{
|
|
1363
1462
|
module2.exports = factory();
|
|
1364
1463
|
}
|
|
@@ -1725,8 +1824,8 @@
|
|
|
1725
1824
|
return jsonLogic;
|
|
1726
1825
|
});
|
|
1727
1826
|
})(logic);
|
|
1728
|
-
|
|
1729
|
-
|
|
1827
|
+
const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
|
|
1828
|
+
const { hasOwnProperty } = Object.prototype;
|
|
1730
1829
|
function combineComparators(comparatorA, comparatorB) {
|
|
1731
1830
|
return function isEqual(a, b, state) {
|
|
1732
1831
|
return comparatorA(a, b, state) && comparatorB(a, b, state);
|
|
@@ -1737,38 +1836,45 @@
|
|
|
1737
1836
|
if (!a || !b || typeof a !== "object" || typeof b !== "object") {
|
|
1738
1837
|
return areItemsEqual(a, b, state);
|
|
1739
1838
|
}
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1839
|
+
const { cache } = state;
|
|
1840
|
+
const cachedA = cache.get(a);
|
|
1841
|
+
const cachedB = cache.get(b);
|
|
1743
1842
|
if (cachedA && cachedB) {
|
|
1744
1843
|
return cachedA === b && cachedB === a;
|
|
1745
1844
|
}
|
|
1746
1845
|
cache.set(a, b);
|
|
1747
1846
|
cache.set(b, a);
|
|
1748
|
-
|
|
1847
|
+
const result = areItemsEqual(a, b, state);
|
|
1749
1848
|
cache.delete(a);
|
|
1750
1849
|
cache.delete(b);
|
|
1751
1850
|
return result;
|
|
1752
1851
|
};
|
|
1753
1852
|
}
|
|
1754
|
-
function getShortTag(value) {
|
|
1755
|
-
return value != null ? value[Symbol.toStringTag] : void 0;
|
|
1756
|
-
}
|
|
1757
1853
|
function getStrictProperties(object) {
|
|
1758
1854
|
return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
|
|
1759
1855
|
}
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1856
|
+
const hasOwn = (
|
|
1857
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1858
|
+
Object.hasOwn || ((object, property) => hasOwnProperty.call(object, property))
|
|
1859
|
+
);
|
|
1860
|
+
const PREACT_VNODE = "__v";
|
|
1861
|
+
const PREACT_OWNER = "__o";
|
|
1862
|
+
const REACT_OWNER = "_owner";
|
|
1863
|
+
const { getOwnPropertyDescriptor, keys } = Object;
|
|
1864
|
+
const sameValueEqual = (
|
|
1865
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1866
|
+
Object.is || function sameValueEqual2(a, b) {
|
|
1867
|
+
return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
|
|
1868
|
+
}
|
|
1869
|
+
);
|
|
1870
|
+
function strictEqual(a, b) {
|
|
1871
|
+
return a === b;
|
|
1872
|
+
}
|
|
1873
|
+
function areArrayBuffersEqual(a, b) {
|
|
1874
|
+
return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a), new Uint8Array(b));
|
|
1765
1875
|
}
|
|
1766
|
-
var PREACT_VNODE = "__v";
|
|
1767
|
-
var PREACT_OWNER = "__o";
|
|
1768
|
-
var REACT_OWNER = "_owner";
|
|
1769
|
-
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, keys$4 = Object.keys;
|
|
1770
1876
|
function areArraysEqual(a, b, state) {
|
|
1771
|
-
|
|
1877
|
+
let index = a.length;
|
|
1772
1878
|
if (b.length !== index) {
|
|
1773
1879
|
return false;
|
|
1774
1880
|
}
|
|
@@ -1779,35 +1885,35 @@
|
|
|
1779
1885
|
}
|
|
1780
1886
|
return true;
|
|
1781
1887
|
}
|
|
1888
|
+
function areDataViewsEqual(a, b) {
|
|
1889
|
+
return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a.buffer, a.byteOffset, a.byteLength), new Uint8Array(b.buffer, b.byteOffset, b.byteLength));
|
|
1890
|
+
}
|
|
1782
1891
|
function areDatesEqual(a, b) {
|
|
1783
|
-
return
|
|
1892
|
+
return sameValueEqual(a.getTime(), b.getTime());
|
|
1784
1893
|
}
|
|
1785
1894
|
function areErrorsEqual(a, b) {
|
|
1786
1895
|
return a.name === b.name && a.message === b.message && a.cause === b.cause && a.stack === b.stack;
|
|
1787
1896
|
}
|
|
1788
|
-
function areFunctionsEqual(a, b) {
|
|
1789
|
-
return a === b;
|
|
1790
|
-
}
|
|
1791
1897
|
function areMapsEqual(a, b, state) {
|
|
1792
|
-
|
|
1898
|
+
const size = a.size;
|
|
1793
1899
|
if (size !== b.size) {
|
|
1794
1900
|
return false;
|
|
1795
1901
|
}
|
|
1796
1902
|
if (!size) {
|
|
1797
1903
|
return true;
|
|
1798
1904
|
}
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1905
|
+
const matchedIndices = new Array(size);
|
|
1906
|
+
const aIterable = a.entries();
|
|
1907
|
+
let aResult;
|
|
1908
|
+
let bResult;
|
|
1909
|
+
let index = 0;
|
|
1804
1910
|
while (aResult = aIterable.next()) {
|
|
1805
1911
|
if (aResult.done) {
|
|
1806
1912
|
break;
|
|
1807
1913
|
}
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1914
|
+
const bIterable = b.entries();
|
|
1915
|
+
let hasMatch = false;
|
|
1916
|
+
let matchIndex = 0;
|
|
1811
1917
|
while (bResult = bIterable.next()) {
|
|
1812
1918
|
if (bResult.done) {
|
|
1813
1919
|
break;
|
|
@@ -1816,8 +1922,8 @@
|
|
|
1816
1922
|
matchIndex++;
|
|
1817
1923
|
continue;
|
|
1818
1924
|
}
|
|
1819
|
-
|
|
1820
|
-
|
|
1925
|
+
const aEntry = aResult.value;
|
|
1926
|
+
const bEntry = bResult.value;
|
|
1821
1927
|
if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state) && state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {
|
|
1822
1928
|
hasMatch = matchedIndices[matchIndex] = true;
|
|
1823
1929
|
break;
|
|
@@ -1831,11 +1937,10 @@
|
|
|
1831
1937
|
}
|
|
1832
1938
|
return true;
|
|
1833
1939
|
}
|
|
1834
|
-
var areNumbersEqual = sameValueZeroEqual;
|
|
1835
1940
|
function areObjectsEqual(a, b, state) {
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
if (keys
|
|
1941
|
+
const properties = keys(a);
|
|
1942
|
+
let index = properties.length;
|
|
1943
|
+
if (keys(b).length !== index) {
|
|
1839
1944
|
return false;
|
|
1840
1945
|
}
|
|
1841
1946
|
while (index-- > 0) {
|
|
@@ -1846,14 +1951,14 @@
|
|
|
1846
1951
|
return true;
|
|
1847
1952
|
}
|
|
1848
1953
|
function areObjectsEqualStrict(a, b, state) {
|
|
1849
|
-
|
|
1850
|
-
|
|
1954
|
+
const properties = getStrictProperties(a);
|
|
1955
|
+
let index = properties.length;
|
|
1851
1956
|
if (getStrictProperties(b).length !== index) {
|
|
1852
1957
|
return false;
|
|
1853
1958
|
}
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1959
|
+
let property;
|
|
1960
|
+
let descriptorA;
|
|
1961
|
+
let descriptorB;
|
|
1857
1962
|
while (index-- > 0) {
|
|
1858
1963
|
property = properties[index];
|
|
1859
1964
|
if (!isPropertyEqual(a, b, state, property)) {
|
|
@@ -1868,30 +1973,30 @@
|
|
|
1868
1973
|
return true;
|
|
1869
1974
|
}
|
|
1870
1975
|
function arePrimitiveWrappersEqual(a, b) {
|
|
1871
|
-
return
|
|
1976
|
+
return sameValueEqual(a.valueOf(), b.valueOf());
|
|
1872
1977
|
}
|
|
1873
1978
|
function areRegExpsEqual(a, b) {
|
|
1874
1979
|
return a.source === b.source && a.flags === b.flags;
|
|
1875
1980
|
}
|
|
1876
1981
|
function areSetsEqual(a, b, state) {
|
|
1877
|
-
|
|
1982
|
+
const size = a.size;
|
|
1878
1983
|
if (size !== b.size) {
|
|
1879
1984
|
return false;
|
|
1880
1985
|
}
|
|
1881
1986
|
if (!size) {
|
|
1882
1987
|
return true;
|
|
1883
1988
|
}
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1989
|
+
const matchedIndices = new Array(size);
|
|
1990
|
+
const aIterable = a.values();
|
|
1991
|
+
let aResult;
|
|
1992
|
+
let bResult;
|
|
1888
1993
|
while (aResult = aIterable.next()) {
|
|
1889
1994
|
if (aResult.done) {
|
|
1890
1995
|
break;
|
|
1891
1996
|
}
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1997
|
+
const bIterable = b.values();
|
|
1998
|
+
let hasMatch = false;
|
|
1999
|
+
let matchIndex = 0;
|
|
1895
2000
|
while (bResult = bIterable.next()) {
|
|
1896
2001
|
if (bResult.done) {
|
|
1897
2002
|
break;
|
|
@@ -1909,8 +2014,8 @@
|
|
|
1909
2014
|
return true;
|
|
1910
2015
|
}
|
|
1911
2016
|
function areTypedArraysEqual(a, b) {
|
|
1912
|
-
|
|
1913
|
-
if (b.
|
|
2017
|
+
let index = a.byteLength;
|
|
2018
|
+
if (b.byteLength !== index || a.byteOffset !== b.byteOffset) {
|
|
1914
2019
|
return false;
|
|
1915
2020
|
}
|
|
1916
2021
|
while (index-- > 0) {
|
|
@@ -1929,23 +2034,10 @@
|
|
|
1929
2034
|
}
|
|
1930
2035
|
return hasOwn(b, property) && state.equals(a[property], b[property], property, property, a, b, state);
|
|
1931
2036
|
}
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
var MAP_TAG = "[object Map]";
|
|
1937
|
-
var NUMBER_TAG = "[object Number]";
|
|
1938
|
-
var OBJECT_TAG = "[object Object]";
|
|
1939
|
-
var REG_EXP_TAG = "[object RegExp]";
|
|
1940
|
-
var SET_TAG = "[object Set]";
|
|
1941
|
-
var STRING_TAG = "[object String]";
|
|
1942
|
-
var URL_TAG = "[object URL]";
|
|
1943
|
-
var isArray$4 = Array.isArray;
|
|
1944
|
-
var isTypedArray$2 = typeof ArrayBuffer === "function" && ArrayBuffer.isView ? ArrayBuffer.isView : null;
|
|
1945
|
-
var assign = Object.assign;
|
|
1946
|
-
var getTag$4 = Object.prototype.toString.call.bind(Object.prototype.toString);
|
|
1947
|
-
function createEqualityComparator(_a) {
|
|
1948
|
-
var areArraysEqual2 = _a.areArraysEqual, areDatesEqual2 = _a.areDatesEqual, areErrorsEqual2 = _a.areErrorsEqual, areFunctionsEqual2 = _a.areFunctionsEqual, areMapsEqual2 = _a.areMapsEqual, areNumbersEqual2 = _a.areNumbersEqual, areObjectsEqual2 = _a.areObjectsEqual, arePrimitiveWrappersEqual2 = _a.arePrimitiveWrappersEqual, areRegExpsEqual2 = _a.areRegExpsEqual, areSetsEqual2 = _a.areSetsEqual, areTypedArraysEqual2 = _a.areTypedArraysEqual, areUrlsEqual2 = _a.areUrlsEqual, unknownTagComparators = _a.unknownTagComparators;
|
|
2037
|
+
const toString = Object.prototype.toString;
|
|
2038
|
+
function createEqualityComparator(config) {
|
|
2039
|
+
const supportedComparatorMap = createSupportedComparatorMap(config);
|
|
2040
|
+
const { areArraysEqual: areArraysEqual2, areDatesEqual: areDatesEqual2, areFunctionsEqual, areMapsEqual: areMapsEqual2, areNumbersEqual, areObjectsEqual: areObjectsEqual2, areRegExpsEqual: areRegExpsEqual2, areSetsEqual: areSetsEqual2, getUnsupportedCustomComparator } = config;
|
|
1949
2041
|
return function comparator(a, b, state) {
|
|
1950
2042
|
if (a === b) {
|
|
1951
2043
|
return true;
|
|
@@ -1953,32 +2045,29 @@
|
|
|
1953
2045
|
if (a == null || b == null) {
|
|
1954
2046
|
return false;
|
|
1955
2047
|
}
|
|
1956
|
-
|
|
2048
|
+
const type = typeof a;
|
|
1957
2049
|
if (type !== typeof b) {
|
|
1958
2050
|
return false;
|
|
1959
2051
|
}
|
|
1960
2052
|
if (type !== "object") {
|
|
1961
|
-
if (type === "number") {
|
|
1962
|
-
return
|
|
2053
|
+
if (type === "number" || type === "bigint") {
|
|
2054
|
+
return areNumbersEqual(a, b, state);
|
|
1963
2055
|
}
|
|
1964
2056
|
if (type === "function") {
|
|
1965
|
-
return
|
|
2057
|
+
return areFunctionsEqual(a, b, state);
|
|
1966
2058
|
}
|
|
1967
2059
|
return false;
|
|
1968
2060
|
}
|
|
1969
|
-
|
|
2061
|
+
const constructor = a.constructor;
|
|
1970
2062
|
if (constructor !== b.constructor) {
|
|
1971
2063
|
return false;
|
|
1972
2064
|
}
|
|
1973
2065
|
if (constructor === Object) {
|
|
1974
2066
|
return areObjectsEqual2(a, b, state);
|
|
1975
2067
|
}
|
|
1976
|
-
if (
|
|
2068
|
+
if (constructor === Array) {
|
|
1977
2069
|
return areArraysEqual2(a, b, state);
|
|
1978
2070
|
}
|
|
1979
|
-
if (isTypedArray$2 != null && isTypedArray$2(a)) {
|
|
1980
|
-
return areTypedArraysEqual2(a, b, state);
|
|
1981
|
-
}
|
|
1982
2071
|
if (constructor === Date) {
|
|
1983
2072
|
return areDatesEqual2(a, b, state);
|
|
1984
2073
|
}
|
|
@@ -1991,79 +2080,55 @@
|
|
|
1991
2080
|
if (constructor === Set) {
|
|
1992
2081
|
return areSetsEqual2(a, b, state);
|
|
1993
2082
|
}
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
return areDatesEqual2(a, b, state);
|
|
1997
|
-
}
|
|
1998
|
-
if (tag === REG_EXP_TAG) {
|
|
1999
|
-
return areRegExpsEqual2(a, b, state);
|
|
2000
|
-
}
|
|
2001
|
-
if (tag === MAP_TAG) {
|
|
2002
|
-
return areMapsEqual2(a, b, state);
|
|
2003
|
-
}
|
|
2004
|
-
if (tag === SET_TAG) {
|
|
2005
|
-
return areSetsEqual2(a, b, state);
|
|
2006
|
-
}
|
|
2007
|
-
if (tag === OBJECT_TAG) {
|
|
2008
|
-
return typeof a.then !== "function" && typeof b.then !== "function" && areObjectsEqual2(a, b, state);
|
|
2083
|
+
if (constructor === Promise) {
|
|
2084
|
+
return false;
|
|
2009
2085
|
}
|
|
2010
|
-
if (
|
|
2011
|
-
return
|
|
2086
|
+
if (Array.isArray(a)) {
|
|
2087
|
+
return areArraysEqual2(a, b, state);
|
|
2012
2088
|
}
|
|
2013
|
-
|
|
2014
|
-
|
|
2089
|
+
const tag = toString.call(a);
|
|
2090
|
+
const supportedComparator = supportedComparatorMap[tag];
|
|
2091
|
+
if (supportedComparator) {
|
|
2092
|
+
return supportedComparator(a, b, state);
|
|
2015
2093
|
}
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {
|
|
2020
|
-
return arePrimitiveWrappersEqual2(a, b, state);
|
|
2021
|
-
}
|
|
2022
|
-
if (unknownTagComparators) {
|
|
2023
|
-
var unknownTagComparator = unknownTagComparators[tag];
|
|
2024
|
-
if (!unknownTagComparator) {
|
|
2025
|
-
var shortTag = getShortTag(a);
|
|
2026
|
-
if (shortTag) {
|
|
2027
|
-
unknownTagComparator = unknownTagComparators[shortTag];
|
|
2028
|
-
}
|
|
2029
|
-
}
|
|
2030
|
-
if (unknownTagComparator) {
|
|
2031
|
-
return unknownTagComparator(a, b, state);
|
|
2032
|
-
}
|
|
2094
|
+
const unsupportedCustomComparator = getUnsupportedCustomComparator && getUnsupportedCustomComparator(a, b, state, tag);
|
|
2095
|
+
if (unsupportedCustomComparator) {
|
|
2096
|
+
return unsupportedCustomComparator(a, b, state);
|
|
2033
2097
|
}
|
|
2034
2098
|
return false;
|
|
2035
2099
|
};
|
|
2036
2100
|
}
|
|
2037
|
-
function createEqualityComparatorConfig(
|
|
2038
|
-
|
|
2039
|
-
|
|
2101
|
+
function createEqualityComparatorConfig({ circular, createCustomConfig, strict }) {
|
|
2102
|
+
let config = {
|
|
2103
|
+
areArrayBuffersEqual,
|
|
2040
2104
|
areArraysEqual: strict ? areObjectsEqualStrict : areArraysEqual,
|
|
2105
|
+
areDataViewsEqual,
|
|
2041
2106
|
areDatesEqual,
|
|
2042
2107
|
areErrorsEqual,
|
|
2043
|
-
areFunctionsEqual,
|
|
2108
|
+
areFunctionsEqual: strictEqual,
|
|
2044
2109
|
areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,
|
|
2045
|
-
areNumbersEqual,
|
|
2110
|
+
areNumbersEqual: sameValueEqual,
|
|
2046
2111
|
areObjectsEqual: strict ? areObjectsEqualStrict : areObjectsEqual,
|
|
2047
2112
|
arePrimitiveWrappersEqual,
|
|
2048
2113
|
areRegExpsEqual,
|
|
2049
2114
|
areSetsEqual: strict ? combineComparators(areSetsEqual, areObjectsEqualStrict) : areSetsEqual,
|
|
2050
|
-
areTypedArraysEqual: strict ? areObjectsEqualStrict : areTypedArraysEqual,
|
|
2115
|
+
areTypedArraysEqual: strict ? combineComparators(areTypedArraysEqual, areObjectsEqualStrict) : areTypedArraysEqual,
|
|
2051
2116
|
areUrlsEqual,
|
|
2052
|
-
|
|
2117
|
+
getUnsupportedCustomComparator: void 0
|
|
2053
2118
|
};
|
|
2054
2119
|
if (createCustomConfig) {
|
|
2055
|
-
config = assign({}, config, createCustomConfig(config));
|
|
2120
|
+
config = Object.assign({}, config, createCustomConfig(config));
|
|
2056
2121
|
}
|
|
2057
2122
|
if (circular) {
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
config = assign({}, config, {
|
|
2063
|
-
areArraysEqual:
|
|
2064
|
-
areMapsEqual:
|
|
2065
|
-
areObjectsEqual:
|
|
2066
|
-
areSetsEqual:
|
|
2123
|
+
const areArraysEqual2 = createIsCircular(config.areArraysEqual);
|
|
2124
|
+
const areMapsEqual2 = createIsCircular(config.areMapsEqual);
|
|
2125
|
+
const areObjectsEqual2 = createIsCircular(config.areObjectsEqual);
|
|
2126
|
+
const areSetsEqual2 = createIsCircular(config.areSetsEqual);
|
|
2127
|
+
config = Object.assign({}, config, {
|
|
2128
|
+
areArraysEqual: areArraysEqual2,
|
|
2129
|
+
areMapsEqual: areMapsEqual2,
|
|
2130
|
+
areObjectsEqual: areObjectsEqual2,
|
|
2131
|
+
areSetsEqual: areSetsEqual2
|
|
2067
2132
|
});
|
|
2068
2133
|
}
|
|
2069
2134
|
return config;
|
|
@@ -2073,11 +2138,10 @@
|
|
|
2073
2138
|
return compare(a, b, state);
|
|
2074
2139
|
};
|
|
2075
2140
|
}
|
|
2076
|
-
function createIsEqual(
|
|
2077
|
-
var circular = _a.circular, comparator = _a.comparator, createState = _a.createState, equals = _a.equals, strict = _a.strict;
|
|
2141
|
+
function createIsEqual({ circular, comparator, createState, equals, strict }) {
|
|
2078
2142
|
if (createState) {
|
|
2079
2143
|
return function isEqual(a, b) {
|
|
2080
|
-
|
|
2144
|
+
const { cache = circular ? /* @__PURE__ */ new WeakMap() : void 0, meta } = createState();
|
|
2081
2145
|
return comparator(a, b, {
|
|
2082
2146
|
cache,
|
|
2083
2147
|
equals,
|
|
@@ -2096,7 +2160,7 @@
|
|
|
2096
2160
|
});
|
|
2097
2161
|
};
|
|
2098
2162
|
}
|
|
2099
|
-
|
|
2163
|
+
const state = {
|
|
2100
2164
|
cache: void 0,
|
|
2101
2165
|
equals,
|
|
2102
2166
|
meta: void 0,
|
|
@@ -2106,7 +2170,50 @@
|
|
|
2106
2170
|
return comparator(a, b, state);
|
|
2107
2171
|
};
|
|
2108
2172
|
}
|
|
2109
|
-
|
|
2173
|
+
function createSupportedComparatorMap({ areArrayBuffersEqual: areArrayBuffersEqual2, areArraysEqual: areArraysEqual2, areDataViewsEqual: areDataViewsEqual2, areDatesEqual: areDatesEqual2, areErrorsEqual: areErrorsEqual2, areFunctionsEqual, areMapsEqual: areMapsEqual2, areNumbersEqual, areObjectsEqual: areObjectsEqual2, arePrimitiveWrappersEqual: arePrimitiveWrappersEqual2, areRegExpsEqual: areRegExpsEqual2, areSetsEqual: areSetsEqual2, areTypedArraysEqual: areTypedArraysEqual2, areUrlsEqual: areUrlsEqual2 }) {
|
|
2174
|
+
return {
|
|
2175
|
+
"[object Arguments]": areObjectsEqual2,
|
|
2176
|
+
"[object Array]": areArraysEqual2,
|
|
2177
|
+
"[object ArrayBuffer]": areArrayBuffersEqual2,
|
|
2178
|
+
"[object AsyncGeneratorFunction]": areFunctionsEqual,
|
|
2179
|
+
"[object BigInt]": areNumbersEqual,
|
|
2180
|
+
"[object BigInt64Array]": areTypedArraysEqual2,
|
|
2181
|
+
"[object BigUint64Array]": areTypedArraysEqual2,
|
|
2182
|
+
"[object Boolean]": arePrimitiveWrappersEqual2,
|
|
2183
|
+
"[object DataView]": areDataViewsEqual2,
|
|
2184
|
+
"[object Date]": areDatesEqual2,
|
|
2185
|
+
// If an error tag, it should be tested explicitly. Like RegExp, the properties are not
|
|
2186
|
+
// enumerable, and therefore will give false positives if tested like a standard object.
|
|
2187
|
+
"[object Error]": areErrorsEqual2,
|
|
2188
|
+
"[object Float16Array]": areTypedArraysEqual2,
|
|
2189
|
+
"[object Float32Array]": areTypedArraysEqual2,
|
|
2190
|
+
"[object Float64Array]": areTypedArraysEqual2,
|
|
2191
|
+
"[object Function]": areFunctionsEqual,
|
|
2192
|
+
"[object GeneratorFunction]": areFunctionsEqual,
|
|
2193
|
+
"[object Int8Array]": areTypedArraysEqual2,
|
|
2194
|
+
"[object Int16Array]": areTypedArraysEqual2,
|
|
2195
|
+
"[object Int32Array]": areTypedArraysEqual2,
|
|
2196
|
+
"[object Map]": areMapsEqual2,
|
|
2197
|
+
"[object Number]": arePrimitiveWrappersEqual2,
|
|
2198
|
+
"[object Object]": (a, b, state) => (
|
|
2199
|
+
// The exception for value comparison is custom `Promise`-like class instances. These should
|
|
2200
|
+
// be treated the same as standard `Promise` objects, which means strict equality, and if
|
|
2201
|
+
// it reaches this point then that strict equality comparison has already failed.
|
|
2202
|
+
typeof a.then !== "function" && typeof b.then !== "function" && areObjectsEqual2(a, b, state)
|
|
2203
|
+
),
|
|
2204
|
+
// For RegExp, the properties are not enumerable, and therefore will give false positives if
|
|
2205
|
+
// tested like a standard object.
|
|
2206
|
+
"[object RegExp]": areRegExpsEqual2,
|
|
2207
|
+
"[object Set]": areSetsEqual2,
|
|
2208
|
+
"[object String]": arePrimitiveWrappersEqual2,
|
|
2209
|
+
"[object URL]": areUrlsEqual2,
|
|
2210
|
+
"[object Uint8Array]": areTypedArraysEqual2,
|
|
2211
|
+
"[object Uint8ClampedArray]": areTypedArraysEqual2,
|
|
2212
|
+
"[object Uint16Array]": areTypedArraysEqual2,
|
|
2213
|
+
"[object Uint32Array]": areTypedArraysEqual2
|
|
2214
|
+
};
|
|
2215
|
+
}
|
|
2216
|
+
const deepEqual = createCustomEqual();
|
|
2110
2217
|
createCustomEqual({ strict: true });
|
|
2111
2218
|
createCustomEqual({ circular: true });
|
|
2112
2219
|
createCustomEqual({
|
|
@@ -2114,1015 +2221,28 @@
|
|
|
2114
2221
|
strict: true
|
|
2115
2222
|
});
|
|
2116
2223
|
createCustomEqual({
|
|
2117
|
-
createInternalComparator:
|
|
2118
|
-
return sameValueZeroEqual;
|
|
2119
|
-
}
|
|
2224
|
+
createInternalComparator: () => sameValueEqual
|
|
2120
2225
|
});
|
|
2121
2226
|
createCustomEqual({
|
|
2122
2227
|
strict: true,
|
|
2123
|
-
createInternalComparator:
|
|
2124
|
-
return sameValueZeroEqual;
|
|
2125
|
-
}
|
|
2228
|
+
createInternalComparator: () => sameValueEqual
|
|
2126
2229
|
});
|
|
2127
2230
|
createCustomEqual({
|
|
2128
2231
|
circular: true,
|
|
2129
|
-
createInternalComparator:
|
|
2130
|
-
return sameValueZeroEqual;
|
|
2131
|
-
}
|
|
2232
|
+
createInternalComparator: () => sameValueEqual
|
|
2132
2233
|
});
|
|
2133
2234
|
createCustomEqual({
|
|
2134
2235
|
circular: true,
|
|
2135
|
-
createInternalComparator:
|
|
2136
|
-
return sameValueZeroEqual;
|
|
2137
|
-
},
|
|
2236
|
+
createInternalComparator: () => sameValueEqual,
|
|
2138
2237
|
strict: true
|
|
2139
2238
|
});
|
|
2140
|
-
function createCustomEqual(options) {
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
var config = createEqualityComparatorConfig(options);
|
|
2146
|
-
var comparator = createEqualityComparator(config);
|
|
2147
|
-
var equals = createCustomInternalComparator ? createCustomInternalComparator(comparator) : createInternalEqualityComparator(comparator);
|
|
2239
|
+
function createCustomEqual(options = {}) {
|
|
2240
|
+
const { circular = false, createInternalComparator: createCustomInternalComparator, createState, strict = false } = options;
|
|
2241
|
+
const config = createEqualityComparatorConfig(options);
|
|
2242
|
+
const comparator = createEqualityComparator(config);
|
|
2243
|
+
const equals = createCustomInternalComparator ? createCustomInternalComparator(comparator) : createInternalEqualityComparator(comparator);
|
|
2148
2244
|
return createIsEqual({ circular, comparator, createState, equals, strict });
|
|
2149
2245
|
}
|
|
2150
|
-
function listCacheClear$1() {
|
|
2151
|
-
this.__data__ = [];
|
|
2152
|
-
this.size = 0;
|
|
2153
|
-
}
|
|
2154
|
-
var _listCacheClear = listCacheClear$1;
|
|
2155
|
-
function eq$2(value, other) {
|
|
2156
|
-
return value === other || value !== value && other !== other;
|
|
2157
|
-
}
|
|
2158
|
-
var eq_1 = eq$2;
|
|
2159
|
-
var eq$1 = eq_1;
|
|
2160
|
-
function assocIndexOf$4(array, key) {
|
|
2161
|
-
var length = array.length;
|
|
2162
|
-
while (length--) {
|
|
2163
|
-
if (eq$1(array[length][0], key)) {
|
|
2164
|
-
return length;
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
return -1;
|
|
2168
|
-
}
|
|
2169
|
-
var _assocIndexOf = assocIndexOf$4;
|
|
2170
|
-
var assocIndexOf$3 = _assocIndexOf;
|
|
2171
|
-
var arrayProto = Array.prototype;
|
|
2172
|
-
var splice = arrayProto.splice;
|
|
2173
|
-
function listCacheDelete$1(key) {
|
|
2174
|
-
var data = this.__data__, index = assocIndexOf$3(data, key);
|
|
2175
|
-
if (index < 0) {
|
|
2176
|
-
return false;
|
|
2177
|
-
}
|
|
2178
|
-
var lastIndex = data.length - 1;
|
|
2179
|
-
if (index == lastIndex) {
|
|
2180
|
-
data.pop();
|
|
2181
|
-
} else {
|
|
2182
|
-
splice.call(data, index, 1);
|
|
2183
|
-
}
|
|
2184
|
-
--this.size;
|
|
2185
|
-
return true;
|
|
2186
|
-
}
|
|
2187
|
-
var _listCacheDelete = listCacheDelete$1;
|
|
2188
|
-
var assocIndexOf$2 = _assocIndexOf;
|
|
2189
|
-
function listCacheGet$1(key) {
|
|
2190
|
-
var data = this.__data__, index = assocIndexOf$2(data, key);
|
|
2191
|
-
return index < 0 ? void 0 : data[index][1];
|
|
2192
|
-
}
|
|
2193
|
-
var _listCacheGet = listCacheGet$1;
|
|
2194
|
-
var assocIndexOf$1 = _assocIndexOf;
|
|
2195
|
-
function listCacheHas$1(key) {
|
|
2196
|
-
return assocIndexOf$1(this.__data__, key) > -1;
|
|
2197
|
-
}
|
|
2198
|
-
var _listCacheHas = listCacheHas$1;
|
|
2199
|
-
var assocIndexOf = _assocIndexOf;
|
|
2200
|
-
function listCacheSet$1(key, value) {
|
|
2201
|
-
var data = this.__data__, index = assocIndexOf(data, key);
|
|
2202
|
-
if (index < 0) {
|
|
2203
|
-
++this.size;
|
|
2204
|
-
data.push([key, value]);
|
|
2205
|
-
} else {
|
|
2206
|
-
data[index][1] = value;
|
|
2207
|
-
}
|
|
2208
|
-
return this;
|
|
2209
|
-
}
|
|
2210
|
-
var _listCacheSet = listCacheSet$1;
|
|
2211
|
-
var listCacheClear = _listCacheClear, listCacheDelete = _listCacheDelete, listCacheGet = _listCacheGet, listCacheHas = _listCacheHas, listCacheSet = _listCacheSet;
|
|
2212
|
-
function ListCache$4(entries) {
|
|
2213
|
-
var index = -1, length = entries == null ? 0 : entries.length;
|
|
2214
|
-
this.clear();
|
|
2215
|
-
while (++index < length) {
|
|
2216
|
-
var entry = entries[index];
|
|
2217
|
-
this.set(entry[0], entry[1]);
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
ListCache$4.prototype.clear = listCacheClear;
|
|
2221
|
-
ListCache$4.prototype["delete"] = listCacheDelete;
|
|
2222
|
-
ListCache$4.prototype.get = listCacheGet;
|
|
2223
|
-
ListCache$4.prototype.has = listCacheHas;
|
|
2224
|
-
ListCache$4.prototype.set = listCacheSet;
|
|
2225
|
-
var _ListCache = ListCache$4;
|
|
2226
|
-
var ListCache$3 = _ListCache;
|
|
2227
|
-
function stackClear$1() {
|
|
2228
|
-
this.__data__ = new ListCache$3();
|
|
2229
|
-
this.size = 0;
|
|
2230
|
-
}
|
|
2231
|
-
var _stackClear = stackClear$1;
|
|
2232
|
-
function stackDelete$1(key) {
|
|
2233
|
-
var data = this.__data__, result = data["delete"](key);
|
|
2234
|
-
this.size = data.size;
|
|
2235
|
-
return result;
|
|
2236
|
-
}
|
|
2237
|
-
var _stackDelete = stackDelete$1;
|
|
2238
|
-
function stackGet$1(key) {
|
|
2239
|
-
return this.__data__.get(key);
|
|
2240
|
-
}
|
|
2241
|
-
var _stackGet = stackGet$1;
|
|
2242
|
-
function stackHas$1(key) {
|
|
2243
|
-
return this.__data__.has(key);
|
|
2244
|
-
}
|
|
2245
|
-
var _stackHas = stackHas$1;
|
|
2246
|
-
var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
2247
|
-
var _freeGlobal = freeGlobal$1;
|
|
2248
|
-
var freeGlobal = _freeGlobal;
|
|
2249
|
-
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
2250
|
-
var root$8 = freeGlobal || freeSelf || Function("return this")();
|
|
2251
|
-
var _root = root$8;
|
|
2252
|
-
var root$7 = _root;
|
|
2253
|
-
var Symbol$4 = root$7.Symbol;
|
|
2254
|
-
var _Symbol = Symbol$4;
|
|
2255
|
-
var Symbol$3 = _Symbol;
|
|
2256
|
-
var objectProto$c = Object.prototype;
|
|
2257
|
-
var hasOwnProperty$9 = objectProto$c.hasOwnProperty;
|
|
2258
|
-
var nativeObjectToString$1 = objectProto$c.toString;
|
|
2259
|
-
var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
|
|
2260
|
-
function getRawTag$1(value) {
|
|
2261
|
-
var isOwn = hasOwnProperty$9.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
2262
|
-
try {
|
|
2263
|
-
value[symToStringTag$1] = void 0;
|
|
2264
|
-
var unmasked = true;
|
|
2265
|
-
} catch (e) {
|
|
2266
|
-
}
|
|
2267
|
-
var result = nativeObjectToString$1.call(value);
|
|
2268
|
-
if (unmasked) {
|
|
2269
|
-
if (isOwn) {
|
|
2270
|
-
value[symToStringTag$1] = tag;
|
|
2271
|
-
} else {
|
|
2272
|
-
delete value[symToStringTag$1];
|
|
2273
|
-
}
|
|
2274
|
-
}
|
|
2275
|
-
return result;
|
|
2276
|
-
}
|
|
2277
|
-
var _getRawTag = getRawTag$1;
|
|
2278
|
-
var objectProto$b = Object.prototype;
|
|
2279
|
-
var nativeObjectToString = objectProto$b.toString;
|
|
2280
|
-
function objectToString$1(value) {
|
|
2281
|
-
return nativeObjectToString.call(value);
|
|
2282
|
-
}
|
|
2283
|
-
var _objectToString = objectToString$1;
|
|
2284
|
-
var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
|
|
2285
|
-
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
2286
|
-
var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
|
|
2287
|
-
function baseGetTag$4(value) {
|
|
2288
|
-
if (value == null) {
|
|
2289
|
-
return value === void 0 ? undefinedTag : nullTag;
|
|
2290
|
-
}
|
|
2291
|
-
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
2292
|
-
}
|
|
2293
|
-
var _baseGetTag = baseGetTag$4;
|
|
2294
|
-
function isObject$5(value) {
|
|
2295
|
-
var type = typeof value;
|
|
2296
|
-
return value != null && (type == "object" || type == "function");
|
|
2297
|
-
}
|
|
2298
|
-
var isObject_1 = isObject$5;
|
|
2299
|
-
var baseGetTag$3 = _baseGetTag, isObject$4 = isObject_1;
|
|
2300
|
-
var asyncTag = "[object AsyncFunction]", funcTag$2 = "[object Function]", genTag$1 = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
|
|
2301
|
-
function isFunction$2(value) {
|
|
2302
|
-
if (!isObject$4(value)) {
|
|
2303
|
-
return false;
|
|
2304
|
-
}
|
|
2305
|
-
var tag = baseGetTag$3(value);
|
|
2306
|
-
return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag || tag == proxyTag;
|
|
2307
|
-
}
|
|
2308
|
-
var isFunction_1 = isFunction$2;
|
|
2309
|
-
var root$6 = _root;
|
|
2310
|
-
var coreJsData$1 = root$6["__core-js_shared__"];
|
|
2311
|
-
var _coreJsData = coreJsData$1;
|
|
2312
|
-
var coreJsData = _coreJsData;
|
|
2313
|
-
var maskSrcKey = function() {
|
|
2314
|
-
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
|
|
2315
|
-
return uid ? "Symbol(src)_1." + uid : "";
|
|
2316
|
-
}();
|
|
2317
|
-
function isMasked$1(func) {
|
|
2318
|
-
return !!maskSrcKey && maskSrcKey in func;
|
|
2319
|
-
}
|
|
2320
|
-
var _isMasked = isMasked$1;
|
|
2321
|
-
var funcProto$1 = Function.prototype;
|
|
2322
|
-
var funcToString$1 = funcProto$1.toString;
|
|
2323
|
-
function toSource$2(func) {
|
|
2324
|
-
if (func != null) {
|
|
2325
|
-
try {
|
|
2326
|
-
return funcToString$1.call(func);
|
|
2327
|
-
} catch (e) {
|
|
2328
|
-
}
|
|
2329
|
-
try {
|
|
2330
|
-
return func + "";
|
|
2331
|
-
} catch (e) {
|
|
2332
|
-
}
|
|
2333
|
-
}
|
|
2334
|
-
return "";
|
|
2335
|
-
}
|
|
2336
|
-
var _toSource = toSource$2;
|
|
2337
|
-
var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$3 = isObject_1, toSource$1 = _toSource;
|
|
2338
|
-
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
2339
|
-
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
2340
|
-
var funcProto = Function.prototype, objectProto$a = Object.prototype;
|
|
2341
|
-
var funcToString = funcProto.toString;
|
|
2342
|
-
var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
|
|
2343
|
-
var reIsNative = RegExp(
|
|
2344
|
-
"^" + funcToString.call(hasOwnProperty$8).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
2345
|
-
);
|
|
2346
|
-
function baseIsNative$1(value) {
|
|
2347
|
-
if (!isObject$3(value) || isMasked(value)) {
|
|
2348
|
-
return false;
|
|
2349
|
-
}
|
|
2350
|
-
var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
|
|
2351
|
-
return pattern.test(toSource$1(value));
|
|
2352
|
-
}
|
|
2353
|
-
var _baseIsNative = baseIsNative$1;
|
|
2354
|
-
function getValue$1(object, key) {
|
|
2355
|
-
return object == null ? void 0 : object[key];
|
|
2356
|
-
}
|
|
2357
|
-
var _getValue = getValue$1;
|
|
2358
|
-
var baseIsNative = _baseIsNative, getValue = _getValue;
|
|
2359
|
-
function getNative$7(object, key) {
|
|
2360
|
-
var value = getValue(object, key);
|
|
2361
|
-
return baseIsNative(value) ? value : void 0;
|
|
2362
|
-
}
|
|
2363
|
-
var _getNative = getNative$7;
|
|
2364
|
-
var getNative$6 = _getNative, root$5 = _root;
|
|
2365
|
-
var Map$4 = getNative$6(root$5, "Map");
|
|
2366
|
-
var _Map = Map$4;
|
|
2367
|
-
var getNative$5 = _getNative;
|
|
2368
|
-
var nativeCreate$4 = getNative$5(Object, "create");
|
|
2369
|
-
var _nativeCreate = nativeCreate$4;
|
|
2370
|
-
var nativeCreate$3 = _nativeCreate;
|
|
2371
|
-
function hashClear$1() {
|
|
2372
|
-
this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
|
|
2373
|
-
this.size = 0;
|
|
2374
|
-
}
|
|
2375
|
-
var _hashClear = hashClear$1;
|
|
2376
|
-
function hashDelete$1(key) {
|
|
2377
|
-
var result = this.has(key) && delete this.__data__[key];
|
|
2378
|
-
this.size -= result ? 1 : 0;
|
|
2379
|
-
return result;
|
|
2380
|
-
}
|
|
2381
|
-
var _hashDelete = hashDelete$1;
|
|
2382
|
-
var nativeCreate$2 = _nativeCreate;
|
|
2383
|
-
var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
|
|
2384
|
-
var objectProto$9 = Object.prototype;
|
|
2385
|
-
var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
|
|
2386
|
-
function hashGet$1(key) {
|
|
2387
|
-
var data = this.__data__;
|
|
2388
|
-
if (nativeCreate$2) {
|
|
2389
|
-
var result = data[key];
|
|
2390
|
-
return result === HASH_UNDEFINED$1 ? void 0 : result;
|
|
2391
|
-
}
|
|
2392
|
-
return hasOwnProperty$7.call(data, key) ? data[key] : void 0;
|
|
2393
|
-
}
|
|
2394
|
-
var _hashGet = hashGet$1;
|
|
2395
|
-
var nativeCreate$1 = _nativeCreate;
|
|
2396
|
-
var objectProto$8 = Object.prototype;
|
|
2397
|
-
var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
|
|
2398
|
-
function hashHas$1(key) {
|
|
2399
|
-
var data = this.__data__;
|
|
2400
|
-
return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty$6.call(data, key);
|
|
2401
|
-
}
|
|
2402
|
-
var _hashHas = hashHas$1;
|
|
2403
|
-
var nativeCreate = _nativeCreate;
|
|
2404
|
-
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
2405
|
-
function hashSet$1(key, value) {
|
|
2406
|
-
var data = this.__data__;
|
|
2407
|
-
this.size += this.has(key) ? 0 : 1;
|
|
2408
|
-
data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
|
|
2409
|
-
return this;
|
|
2410
|
-
}
|
|
2411
|
-
var _hashSet = hashSet$1;
|
|
2412
|
-
var hashClear = _hashClear, hashDelete = _hashDelete, hashGet = _hashGet, hashHas = _hashHas, hashSet = _hashSet;
|
|
2413
|
-
function Hash$1(entries) {
|
|
2414
|
-
var index = -1, length = entries == null ? 0 : entries.length;
|
|
2415
|
-
this.clear();
|
|
2416
|
-
while (++index < length) {
|
|
2417
|
-
var entry = entries[index];
|
|
2418
|
-
this.set(entry[0], entry[1]);
|
|
2419
|
-
}
|
|
2420
|
-
}
|
|
2421
|
-
Hash$1.prototype.clear = hashClear;
|
|
2422
|
-
Hash$1.prototype["delete"] = hashDelete;
|
|
2423
|
-
Hash$1.prototype.get = hashGet;
|
|
2424
|
-
Hash$1.prototype.has = hashHas;
|
|
2425
|
-
Hash$1.prototype.set = hashSet;
|
|
2426
|
-
var _Hash = Hash$1;
|
|
2427
|
-
var Hash = _Hash, ListCache$2 = _ListCache, Map$3 = _Map;
|
|
2428
|
-
function mapCacheClear$1() {
|
|
2429
|
-
this.size = 0;
|
|
2430
|
-
this.__data__ = {
|
|
2431
|
-
"hash": new Hash(),
|
|
2432
|
-
"map": new (Map$3 || ListCache$2)(),
|
|
2433
|
-
"string": new Hash()
|
|
2434
|
-
};
|
|
2435
|
-
}
|
|
2436
|
-
var _mapCacheClear = mapCacheClear$1;
|
|
2437
|
-
function isKeyable$1(value) {
|
|
2438
|
-
var type = typeof value;
|
|
2439
|
-
return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
|
|
2440
|
-
}
|
|
2441
|
-
var _isKeyable = isKeyable$1;
|
|
2442
|
-
var isKeyable = _isKeyable;
|
|
2443
|
-
function getMapData$4(map, key) {
|
|
2444
|
-
var data = map.__data__;
|
|
2445
|
-
return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
|
|
2446
|
-
}
|
|
2447
|
-
var _getMapData = getMapData$4;
|
|
2448
|
-
var getMapData$3 = _getMapData;
|
|
2449
|
-
function mapCacheDelete$1(key) {
|
|
2450
|
-
var result = getMapData$3(this, key)["delete"](key);
|
|
2451
|
-
this.size -= result ? 1 : 0;
|
|
2452
|
-
return result;
|
|
2453
|
-
}
|
|
2454
|
-
var _mapCacheDelete = mapCacheDelete$1;
|
|
2455
|
-
var getMapData$2 = _getMapData;
|
|
2456
|
-
function mapCacheGet$1(key) {
|
|
2457
|
-
return getMapData$2(this, key).get(key);
|
|
2458
|
-
}
|
|
2459
|
-
var _mapCacheGet = mapCacheGet$1;
|
|
2460
|
-
var getMapData$1 = _getMapData;
|
|
2461
|
-
function mapCacheHas$1(key) {
|
|
2462
|
-
return getMapData$1(this, key).has(key);
|
|
2463
|
-
}
|
|
2464
|
-
var _mapCacheHas = mapCacheHas$1;
|
|
2465
|
-
var getMapData = _getMapData;
|
|
2466
|
-
function mapCacheSet$1(key, value) {
|
|
2467
|
-
var data = getMapData(this, key), size = data.size;
|
|
2468
|
-
data.set(key, value);
|
|
2469
|
-
this.size += data.size == size ? 0 : 1;
|
|
2470
|
-
return this;
|
|
2471
|
-
}
|
|
2472
|
-
var _mapCacheSet = mapCacheSet$1;
|
|
2473
|
-
var mapCacheClear = _mapCacheClear, mapCacheDelete = _mapCacheDelete, mapCacheGet = _mapCacheGet, mapCacheHas = _mapCacheHas, mapCacheSet = _mapCacheSet;
|
|
2474
|
-
function MapCache$1(entries) {
|
|
2475
|
-
var index = -1, length = entries == null ? 0 : entries.length;
|
|
2476
|
-
this.clear();
|
|
2477
|
-
while (++index < length) {
|
|
2478
|
-
var entry = entries[index];
|
|
2479
|
-
this.set(entry[0], entry[1]);
|
|
2480
|
-
}
|
|
2481
|
-
}
|
|
2482
|
-
MapCache$1.prototype.clear = mapCacheClear;
|
|
2483
|
-
MapCache$1.prototype["delete"] = mapCacheDelete;
|
|
2484
|
-
MapCache$1.prototype.get = mapCacheGet;
|
|
2485
|
-
MapCache$1.prototype.has = mapCacheHas;
|
|
2486
|
-
MapCache$1.prototype.set = mapCacheSet;
|
|
2487
|
-
var _MapCache = MapCache$1;
|
|
2488
|
-
var ListCache$1 = _ListCache, Map$2 = _Map, MapCache = _MapCache;
|
|
2489
|
-
var LARGE_ARRAY_SIZE = 200;
|
|
2490
|
-
function stackSet$1(key, value) {
|
|
2491
|
-
var data = this.__data__;
|
|
2492
|
-
if (data instanceof ListCache$1) {
|
|
2493
|
-
var pairs = data.__data__;
|
|
2494
|
-
if (!Map$2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
|
|
2495
|
-
pairs.push([key, value]);
|
|
2496
|
-
this.size = ++data.size;
|
|
2497
|
-
return this;
|
|
2498
|
-
}
|
|
2499
|
-
data = this.__data__ = new MapCache(pairs);
|
|
2500
|
-
}
|
|
2501
|
-
data.set(key, value);
|
|
2502
|
-
this.size = data.size;
|
|
2503
|
-
return this;
|
|
2504
|
-
}
|
|
2505
|
-
var _stackSet = stackSet$1;
|
|
2506
|
-
var ListCache = _ListCache, stackClear = _stackClear, stackDelete = _stackDelete, stackGet = _stackGet, stackHas = _stackHas, stackSet = _stackSet;
|
|
2507
|
-
function Stack$1(entries) {
|
|
2508
|
-
var data = this.__data__ = new ListCache(entries);
|
|
2509
|
-
this.size = data.size;
|
|
2510
|
-
}
|
|
2511
|
-
Stack$1.prototype.clear = stackClear;
|
|
2512
|
-
Stack$1.prototype["delete"] = stackDelete;
|
|
2513
|
-
Stack$1.prototype.get = stackGet;
|
|
2514
|
-
Stack$1.prototype.has = stackHas;
|
|
2515
|
-
Stack$1.prototype.set = stackSet;
|
|
2516
|
-
var _Stack = Stack$1;
|
|
2517
|
-
function arrayEach$1(array, iteratee) {
|
|
2518
|
-
var index = -1, length = array == null ? 0 : array.length;
|
|
2519
|
-
while (++index < length) {
|
|
2520
|
-
if (iteratee(array[index], index, array) === false) {
|
|
2521
|
-
break;
|
|
2522
|
-
}
|
|
2523
|
-
}
|
|
2524
|
-
return array;
|
|
2525
|
-
}
|
|
2526
|
-
var _arrayEach = arrayEach$1;
|
|
2527
|
-
var getNative$4 = _getNative;
|
|
2528
|
-
var defineProperty$1 = function() {
|
|
2529
|
-
try {
|
|
2530
|
-
var func = getNative$4(Object, "defineProperty");
|
|
2531
|
-
func({}, "", {});
|
|
2532
|
-
return func;
|
|
2533
|
-
} catch (e) {
|
|
2534
|
-
}
|
|
2535
|
-
}();
|
|
2536
|
-
var _defineProperty = defineProperty$1;
|
|
2537
|
-
var defineProperty = _defineProperty;
|
|
2538
|
-
function baseAssignValue$2(object, key, value) {
|
|
2539
|
-
if (key == "__proto__" && defineProperty) {
|
|
2540
|
-
defineProperty(object, key, {
|
|
2541
|
-
"configurable": true,
|
|
2542
|
-
"enumerable": true,
|
|
2543
|
-
"value": value,
|
|
2544
|
-
"writable": true
|
|
2545
|
-
});
|
|
2546
|
-
} else {
|
|
2547
|
-
object[key] = value;
|
|
2548
|
-
}
|
|
2549
|
-
}
|
|
2550
|
-
var _baseAssignValue = baseAssignValue$2;
|
|
2551
|
-
var baseAssignValue$1 = _baseAssignValue, eq = eq_1;
|
|
2552
|
-
var objectProto$7 = Object.prototype;
|
|
2553
|
-
var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
|
|
2554
|
-
function assignValue$2(object, key, value) {
|
|
2555
|
-
var objValue = object[key];
|
|
2556
|
-
if (!(hasOwnProperty$5.call(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) {
|
|
2557
|
-
baseAssignValue$1(object, key, value);
|
|
2558
|
-
}
|
|
2559
|
-
}
|
|
2560
|
-
var _assignValue = assignValue$2;
|
|
2561
|
-
var assignValue$1 = _assignValue, baseAssignValue = _baseAssignValue;
|
|
2562
|
-
function copyObject$4(source, props, object, customizer) {
|
|
2563
|
-
var isNew = !object;
|
|
2564
|
-
object || (object = {});
|
|
2565
|
-
var index = -1, length = props.length;
|
|
2566
|
-
while (++index < length) {
|
|
2567
|
-
var key = props[index];
|
|
2568
|
-
var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
|
|
2569
|
-
if (newValue === void 0) {
|
|
2570
|
-
newValue = source[key];
|
|
2571
|
-
}
|
|
2572
|
-
if (isNew) {
|
|
2573
|
-
baseAssignValue(object, key, newValue);
|
|
2574
|
-
} else {
|
|
2575
|
-
assignValue$1(object, key, newValue);
|
|
2576
|
-
}
|
|
2577
|
-
}
|
|
2578
|
-
return object;
|
|
2579
|
-
}
|
|
2580
|
-
var _copyObject = copyObject$4;
|
|
2581
|
-
function baseTimes$1(n, iteratee) {
|
|
2582
|
-
var index = -1, result = Array(n);
|
|
2583
|
-
while (++index < n) {
|
|
2584
|
-
result[index] = iteratee(index);
|
|
2585
|
-
}
|
|
2586
|
-
return result;
|
|
2587
|
-
}
|
|
2588
|
-
var _baseTimes = baseTimes$1;
|
|
2589
|
-
function isObjectLike$5(value) {
|
|
2590
|
-
return value != null && typeof value == "object";
|
|
2591
|
-
}
|
|
2592
|
-
var isObjectLike_1 = isObjectLike$5;
|
|
2593
|
-
var baseGetTag$2 = _baseGetTag, isObjectLike$4 = isObjectLike_1;
|
|
2594
|
-
var argsTag$2 = "[object Arguments]";
|
|
2595
|
-
function baseIsArguments$1(value) {
|
|
2596
|
-
return isObjectLike$4(value) && baseGetTag$2(value) == argsTag$2;
|
|
2597
|
-
}
|
|
2598
|
-
var _baseIsArguments = baseIsArguments$1;
|
|
2599
|
-
var baseIsArguments = _baseIsArguments, isObjectLike$3 = isObjectLike_1;
|
|
2600
|
-
var objectProto$6 = Object.prototype;
|
|
2601
|
-
var hasOwnProperty$4 = objectProto$6.hasOwnProperty;
|
|
2602
|
-
var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
|
|
2603
|
-
var isArguments$1 = baseIsArguments(/* @__PURE__ */ function() {
|
|
2604
|
-
return arguments;
|
|
2605
|
-
}()) ? baseIsArguments : function(value) {
|
|
2606
|
-
return isObjectLike$3(value) && hasOwnProperty$4.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
|
|
2607
|
-
};
|
|
2608
|
-
var isArguments_1 = isArguments$1;
|
|
2609
|
-
var isArray$3 = Array.isArray;
|
|
2610
|
-
var isArray_1 = isArray$3;
|
|
2611
|
-
var isBuffer$2 = { exports: {} };
|
|
2612
|
-
function stubFalse() {
|
|
2613
|
-
return false;
|
|
2614
|
-
}
|
|
2615
|
-
var stubFalse_1 = stubFalse;
|
|
2616
|
-
isBuffer$2.exports;
|
|
2617
|
-
(function(module2, exports$1) {
|
|
2618
|
-
var root2 = _root, stubFalse2 = stubFalse_1;
|
|
2619
|
-
var freeExports = exports$1 && !exports$1.nodeType && exports$1;
|
|
2620
|
-
var freeModule = freeExports && true && module2 && !module2.nodeType && module2;
|
|
2621
|
-
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
2622
|
-
var Buffer = moduleExports ? root2.Buffer : void 0;
|
|
2623
|
-
var nativeIsBuffer = Buffer ? Buffer.isBuffer : void 0;
|
|
2624
|
-
var isBuffer2 = nativeIsBuffer || stubFalse2;
|
|
2625
|
-
module2.exports = isBuffer2;
|
|
2626
|
-
})(isBuffer$2, isBuffer$2.exports);
|
|
2627
|
-
var isBufferExports = isBuffer$2.exports;
|
|
2628
|
-
var MAX_SAFE_INTEGER$1 = 9007199254740991;
|
|
2629
|
-
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
2630
|
-
function isIndex$1(value, length) {
|
|
2631
|
-
var type = typeof value;
|
|
2632
|
-
length = length == null ? MAX_SAFE_INTEGER$1 : length;
|
|
2633
|
-
return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
|
|
2634
|
-
}
|
|
2635
|
-
var _isIndex = isIndex$1;
|
|
2636
|
-
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
2637
|
-
function isLength$2(value) {
|
|
2638
|
-
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
2639
|
-
}
|
|
2640
|
-
var isLength_1 = isLength$2;
|
|
2641
|
-
var baseGetTag$1 = _baseGetTag, isLength$1 = isLength_1, isObjectLike$2 = isObjectLike_1;
|
|
2642
|
-
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]";
|
|
2643
|
-
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]";
|
|
2644
|
-
var typedArrayTags = {};
|
|
2645
|
-
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;
|
|
2646
|
-
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;
|
|
2647
|
-
function baseIsTypedArray$1(value) {
|
|
2648
|
-
return isObjectLike$2(value) && isLength$1(value.length) && !!typedArrayTags[baseGetTag$1(value)];
|
|
2649
|
-
}
|
|
2650
|
-
var _baseIsTypedArray = baseIsTypedArray$1;
|
|
2651
|
-
function baseUnary$3(func) {
|
|
2652
|
-
return function(value) {
|
|
2653
|
-
return func(value);
|
|
2654
|
-
};
|
|
2655
|
-
}
|
|
2656
|
-
var _baseUnary = baseUnary$3;
|
|
2657
|
-
var _nodeUtil = { exports: {} };
|
|
2658
|
-
_nodeUtil.exports;
|
|
2659
|
-
(function(module2, exports$1) {
|
|
2660
|
-
var freeGlobal2 = _freeGlobal;
|
|
2661
|
-
var freeExports = exports$1 && !exports$1.nodeType && exports$1;
|
|
2662
|
-
var freeModule = freeExports && true && module2 && !module2.nodeType && module2;
|
|
2663
|
-
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
2664
|
-
var freeProcess = moduleExports && freeGlobal2.process;
|
|
2665
|
-
var nodeUtil2 = function() {
|
|
2666
|
-
try {
|
|
2667
|
-
var types = freeModule && freeModule.require && freeModule.require("util").types;
|
|
2668
|
-
if (types) {
|
|
2669
|
-
return types;
|
|
2670
|
-
}
|
|
2671
|
-
return freeProcess && freeProcess.binding && freeProcess.binding("util");
|
|
2672
|
-
} catch (e) {
|
|
2673
|
-
}
|
|
2674
|
-
}();
|
|
2675
|
-
module2.exports = nodeUtil2;
|
|
2676
|
-
})(_nodeUtil, _nodeUtil.exports);
|
|
2677
|
-
var _nodeUtilExports = _nodeUtil.exports;
|
|
2678
|
-
var baseIsTypedArray = _baseIsTypedArray, baseUnary$2 = _baseUnary, nodeUtil$2 = _nodeUtilExports;
|
|
2679
|
-
var nodeIsTypedArray = nodeUtil$2 && nodeUtil$2.isTypedArray;
|
|
2680
|
-
var isTypedArray$1 = nodeIsTypedArray ? baseUnary$2(nodeIsTypedArray) : baseIsTypedArray;
|
|
2681
|
-
var isTypedArray_1 = isTypedArray$1;
|
|
2682
|
-
var baseTimes = _baseTimes, isArguments = isArguments_1, isArray$2 = isArray_1, isBuffer$1 = isBufferExports, isIndex = _isIndex, isTypedArray = isTypedArray_1;
|
|
2683
|
-
var objectProto$5 = Object.prototype;
|
|
2684
|
-
var hasOwnProperty$3 = objectProto$5.hasOwnProperty;
|
|
2685
|
-
function arrayLikeKeys$2(value, inherited) {
|
|
2686
|
-
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;
|
|
2687
|
-
for (var key in value) {
|
|
2688
|
-
if ((inherited || hasOwnProperty$3.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
|
|
2689
|
-
(key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
|
|
2690
|
-
isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
2691
|
-
isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
|
|
2692
|
-
isIndex(key, length)))) {
|
|
2693
|
-
result.push(key);
|
|
2694
|
-
}
|
|
2695
|
-
}
|
|
2696
|
-
return result;
|
|
2697
|
-
}
|
|
2698
|
-
var _arrayLikeKeys = arrayLikeKeys$2;
|
|
2699
|
-
var objectProto$4 = Object.prototype;
|
|
2700
|
-
function isPrototype$3(value) {
|
|
2701
|
-
var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$4;
|
|
2702
|
-
return value === proto;
|
|
2703
|
-
}
|
|
2704
|
-
var _isPrototype = isPrototype$3;
|
|
2705
|
-
function overArg$2(func, transform) {
|
|
2706
|
-
return function(arg) {
|
|
2707
|
-
return func(transform(arg));
|
|
2708
|
-
};
|
|
2709
|
-
}
|
|
2710
|
-
var _overArg = overArg$2;
|
|
2711
|
-
var overArg$1 = _overArg;
|
|
2712
|
-
var nativeKeys$1 = overArg$1(Object.keys, Object);
|
|
2713
|
-
var _nativeKeys = nativeKeys$1;
|
|
2714
|
-
var isPrototype$2 = _isPrototype, nativeKeys = _nativeKeys;
|
|
2715
|
-
var objectProto$3 = Object.prototype;
|
|
2716
|
-
var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
|
|
2717
|
-
function baseKeys$1(object) {
|
|
2718
|
-
if (!isPrototype$2(object)) {
|
|
2719
|
-
return nativeKeys(object);
|
|
2720
|
-
}
|
|
2721
|
-
var result = [];
|
|
2722
|
-
for (var key in Object(object)) {
|
|
2723
|
-
if (hasOwnProperty$2.call(object, key) && key != "constructor") {
|
|
2724
|
-
result.push(key);
|
|
2725
|
-
}
|
|
2726
|
-
}
|
|
2727
|
-
return result;
|
|
2728
|
-
}
|
|
2729
|
-
var _baseKeys = baseKeys$1;
|
|
2730
|
-
var isFunction = isFunction_1, isLength = isLength_1;
|
|
2731
|
-
function isArrayLike$2(value) {
|
|
2732
|
-
return value != null && isLength(value.length) && !isFunction(value);
|
|
2733
|
-
}
|
|
2734
|
-
var isArrayLike_1 = isArrayLike$2;
|
|
2735
|
-
var arrayLikeKeys$1 = _arrayLikeKeys, baseKeys = _baseKeys, isArrayLike$1 = isArrayLike_1;
|
|
2736
|
-
function keys$3(object) {
|
|
2737
|
-
return isArrayLike$1(object) ? arrayLikeKeys$1(object) : baseKeys(object);
|
|
2738
|
-
}
|
|
2739
|
-
var keys_1 = keys$3;
|
|
2740
|
-
var copyObject$3 = _copyObject, keys$2 = keys_1;
|
|
2741
|
-
function baseAssign$1(object, source) {
|
|
2742
|
-
return object && copyObject$3(source, keys$2(source), object);
|
|
2743
|
-
}
|
|
2744
|
-
var _baseAssign = baseAssign$1;
|
|
2745
|
-
function nativeKeysIn$1(object) {
|
|
2746
|
-
var result = [];
|
|
2747
|
-
if (object != null) {
|
|
2748
|
-
for (var key in Object(object)) {
|
|
2749
|
-
result.push(key);
|
|
2750
|
-
}
|
|
2751
|
-
}
|
|
2752
|
-
return result;
|
|
2753
|
-
}
|
|
2754
|
-
var _nativeKeysIn = nativeKeysIn$1;
|
|
2755
|
-
var isObject$2 = isObject_1, isPrototype$1 = _isPrototype, nativeKeysIn = _nativeKeysIn;
|
|
2756
|
-
var objectProto$2 = Object.prototype;
|
|
2757
|
-
var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
|
|
2758
|
-
function baseKeysIn$1(object) {
|
|
2759
|
-
if (!isObject$2(object)) {
|
|
2760
|
-
return nativeKeysIn(object);
|
|
2761
|
-
}
|
|
2762
|
-
var isProto = isPrototype$1(object), result = [];
|
|
2763
|
-
for (var key in object) {
|
|
2764
|
-
if (!(key == "constructor" && (isProto || !hasOwnProperty$1.call(object, key)))) {
|
|
2765
|
-
result.push(key);
|
|
2766
|
-
}
|
|
2767
|
-
}
|
|
2768
|
-
return result;
|
|
2769
|
-
}
|
|
2770
|
-
var _baseKeysIn = baseKeysIn$1;
|
|
2771
|
-
var arrayLikeKeys = _arrayLikeKeys, baseKeysIn = _baseKeysIn, isArrayLike = isArrayLike_1;
|
|
2772
|
-
function keysIn$3(object) {
|
|
2773
|
-
return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
|
|
2774
|
-
}
|
|
2775
|
-
var keysIn_1 = keysIn$3;
|
|
2776
|
-
var copyObject$2 = _copyObject, keysIn$2 = keysIn_1;
|
|
2777
|
-
function baseAssignIn$1(object, source) {
|
|
2778
|
-
return object && copyObject$2(source, keysIn$2(source), object);
|
|
2779
|
-
}
|
|
2780
|
-
var _baseAssignIn = baseAssignIn$1;
|
|
2781
|
-
var _cloneBuffer = { exports: {} };
|
|
2782
|
-
_cloneBuffer.exports;
|
|
2783
|
-
(function(module2, exports$1) {
|
|
2784
|
-
var root2 = _root;
|
|
2785
|
-
var freeExports = exports$1 && !exports$1.nodeType && exports$1;
|
|
2786
|
-
var freeModule = freeExports && true && module2 && !module2.nodeType && module2;
|
|
2787
|
-
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
2788
|
-
var Buffer = moduleExports ? root2.Buffer : void 0, allocUnsafe = Buffer ? Buffer.allocUnsafe : void 0;
|
|
2789
|
-
function cloneBuffer2(buffer, isDeep) {
|
|
2790
|
-
if (isDeep) {
|
|
2791
|
-
return buffer.slice();
|
|
2792
|
-
}
|
|
2793
|
-
var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
|
|
2794
|
-
buffer.copy(result);
|
|
2795
|
-
return result;
|
|
2796
|
-
}
|
|
2797
|
-
module2.exports = cloneBuffer2;
|
|
2798
|
-
})(_cloneBuffer, _cloneBuffer.exports);
|
|
2799
|
-
var _cloneBufferExports = _cloneBuffer.exports;
|
|
2800
|
-
function copyArray$1(source, array) {
|
|
2801
|
-
var index = -1, length = source.length;
|
|
2802
|
-
array || (array = Array(length));
|
|
2803
|
-
while (++index < length) {
|
|
2804
|
-
array[index] = source[index];
|
|
2805
|
-
}
|
|
2806
|
-
return array;
|
|
2807
|
-
}
|
|
2808
|
-
var _copyArray = copyArray$1;
|
|
2809
|
-
function arrayFilter$1(array, predicate) {
|
|
2810
|
-
var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
|
|
2811
|
-
while (++index < length) {
|
|
2812
|
-
var value = array[index];
|
|
2813
|
-
if (predicate(value, index, array)) {
|
|
2814
|
-
result[resIndex++] = value;
|
|
2815
|
-
}
|
|
2816
|
-
}
|
|
2817
|
-
return result;
|
|
2818
|
-
}
|
|
2819
|
-
var _arrayFilter = arrayFilter$1;
|
|
2820
|
-
function stubArray$2() {
|
|
2821
|
-
return [];
|
|
2822
|
-
}
|
|
2823
|
-
var stubArray_1 = stubArray$2;
|
|
2824
|
-
var arrayFilter = _arrayFilter, stubArray$1 = stubArray_1;
|
|
2825
|
-
var objectProto$1 = Object.prototype;
|
|
2826
|
-
var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
|
|
2827
|
-
var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
|
|
2828
|
-
var getSymbols$3 = !nativeGetSymbols$1 ? stubArray$1 : function(object) {
|
|
2829
|
-
if (object == null) {
|
|
2830
|
-
return [];
|
|
2831
|
-
}
|
|
2832
|
-
object = Object(object);
|
|
2833
|
-
return arrayFilter(nativeGetSymbols$1(object), function(symbol) {
|
|
2834
|
-
return propertyIsEnumerable.call(object, symbol);
|
|
2835
|
-
});
|
|
2836
|
-
};
|
|
2837
|
-
var _getSymbols = getSymbols$3;
|
|
2838
|
-
var copyObject$1 = _copyObject, getSymbols$2 = _getSymbols;
|
|
2839
|
-
function copySymbols$1(source, object) {
|
|
2840
|
-
return copyObject$1(source, getSymbols$2(source), object);
|
|
2841
|
-
}
|
|
2842
|
-
var _copySymbols = copySymbols$1;
|
|
2843
|
-
function arrayPush$2(array, values) {
|
|
2844
|
-
var index = -1, length = values.length, offset = array.length;
|
|
2845
|
-
while (++index < length) {
|
|
2846
|
-
array[offset + index] = values[index];
|
|
2847
|
-
}
|
|
2848
|
-
return array;
|
|
2849
|
-
}
|
|
2850
|
-
var _arrayPush = arrayPush$2;
|
|
2851
|
-
var overArg = _overArg;
|
|
2852
|
-
var getPrototype$2 = overArg(Object.getPrototypeOf, Object);
|
|
2853
|
-
var _getPrototype = getPrototype$2;
|
|
2854
|
-
var arrayPush$1 = _arrayPush, getPrototype$1 = _getPrototype, getSymbols$1 = _getSymbols, stubArray = stubArray_1;
|
|
2855
|
-
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
|
2856
|
-
var getSymbolsIn$2 = !nativeGetSymbols ? stubArray : function(object) {
|
|
2857
|
-
var result = [];
|
|
2858
|
-
while (object) {
|
|
2859
|
-
arrayPush$1(result, getSymbols$1(object));
|
|
2860
|
-
object = getPrototype$1(object);
|
|
2861
|
-
}
|
|
2862
|
-
return result;
|
|
2863
|
-
};
|
|
2864
|
-
var _getSymbolsIn = getSymbolsIn$2;
|
|
2865
|
-
var copyObject = _copyObject, getSymbolsIn$1 = _getSymbolsIn;
|
|
2866
|
-
function copySymbolsIn$1(source, object) {
|
|
2867
|
-
return copyObject(source, getSymbolsIn$1(source), object);
|
|
2868
|
-
}
|
|
2869
|
-
var _copySymbolsIn = copySymbolsIn$1;
|
|
2870
|
-
var arrayPush = _arrayPush, isArray$1 = isArray_1;
|
|
2871
|
-
function baseGetAllKeys$2(object, keysFunc, symbolsFunc) {
|
|
2872
|
-
var result = keysFunc(object);
|
|
2873
|
-
return isArray$1(object) ? result : arrayPush(result, symbolsFunc(object));
|
|
2874
|
-
}
|
|
2875
|
-
var _baseGetAllKeys = baseGetAllKeys$2;
|
|
2876
|
-
var baseGetAllKeys$1 = _baseGetAllKeys, getSymbols = _getSymbols, keys$1 = keys_1;
|
|
2877
|
-
function getAllKeys$1(object) {
|
|
2878
|
-
return baseGetAllKeys$1(object, keys$1, getSymbols);
|
|
2879
|
-
}
|
|
2880
|
-
var _getAllKeys = getAllKeys$1;
|
|
2881
|
-
var baseGetAllKeys = _baseGetAllKeys, getSymbolsIn = _getSymbolsIn, keysIn$1 = keysIn_1;
|
|
2882
|
-
function getAllKeysIn$1(object) {
|
|
2883
|
-
return baseGetAllKeys(object, keysIn$1, getSymbolsIn);
|
|
2884
|
-
}
|
|
2885
|
-
var _getAllKeysIn = getAllKeysIn$1;
|
|
2886
|
-
var getNative$3 = _getNative, root$4 = _root;
|
|
2887
|
-
var DataView$1 = getNative$3(root$4, "DataView");
|
|
2888
|
-
var _DataView = DataView$1;
|
|
2889
|
-
var getNative$2 = _getNative, root$3 = _root;
|
|
2890
|
-
var Promise$2 = getNative$2(root$3, "Promise");
|
|
2891
|
-
var _Promise = Promise$2;
|
|
2892
|
-
var getNative$1 = _getNative, root$2 = _root;
|
|
2893
|
-
var Set$2 = getNative$1(root$2, "Set");
|
|
2894
|
-
var _Set = Set$2;
|
|
2895
|
-
var getNative = _getNative, root$1 = _root;
|
|
2896
|
-
var WeakMap$2 = getNative(root$1, "WeakMap");
|
|
2897
|
-
var _WeakMap = WeakMap$2;
|
|
2898
|
-
var DataView = _DataView, Map$1 = _Map, Promise$1 = _Promise, Set$1 = _Set, WeakMap$1 = _WeakMap, baseGetTag = _baseGetTag, toSource = _toSource;
|
|
2899
|
-
var mapTag$3 = "[object Map]", objectTag$1 = "[object Object]", promiseTag = "[object Promise]", setTag$3 = "[object Set]", weakMapTag$1 = "[object WeakMap]";
|
|
2900
|
-
var dataViewTag$2 = "[object DataView]";
|
|
2901
|
-
var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$1), weakMapCtorString = toSource(WeakMap$1);
|
|
2902
|
-
var getTag$3 = baseGetTag;
|
|
2903
|
-
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) {
|
|
2904
|
-
getTag$3 = function(value) {
|
|
2905
|
-
var result = baseGetTag(value), Ctor = result == objectTag$1 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
|
|
2906
|
-
if (ctorString) {
|
|
2907
|
-
switch (ctorString) {
|
|
2908
|
-
case dataViewCtorString:
|
|
2909
|
-
return dataViewTag$2;
|
|
2910
|
-
case mapCtorString:
|
|
2911
|
-
return mapTag$3;
|
|
2912
|
-
case promiseCtorString:
|
|
2913
|
-
return promiseTag;
|
|
2914
|
-
case setCtorString:
|
|
2915
|
-
return setTag$3;
|
|
2916
|
-
case weakMapCtorString:
|
|
2917
|
-
return weakMapTag$1;
|
|
2918
|
-
}
|
|
2919
|
-
}
|
|
2920
|
-
return result;
|
|
2921
|
-
};
|
|
2922
|
-
}
|
|
2923
|
-
var _getTag = getTag$3;
|
|
2924
|
-
var objectProto = Object.prototype;
|
|
2925
|
-
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
2926
|
-
function initCloneArray$1(array) {
|
|
2927
|
-
var length = array.length, result = new array.constructor(length);
|
|
2928
|
-
if (length && typeof array[0] == "string" && hasOwnProperty.call(array, "index")) {
|
|
2929
|
-
result.index = array.index;
|
|
2930
|
-
result.input = array.input;
|
|
2931
|
-
}
|
|
2932
|
-
return result;
|
|
2933
|
-
}
|
|
2934
|
-
var _initCloneArray = initCloneArray$1;
|
|
2935
|
-
var root = _root;
|
|
2936
|
-
var Uint8Array$2 = root.Uint8Array;
|
|
2937
|
-
var _Uint8Array = Uint8Array$2;
|
|
2938
|
-
var Uint8Array$1 = _Uint8Array;
|
|
2939
|
-
function cloneArrayBuffer$3(arrayBuffer) {
|
|
2940
|
-
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
|
2941
|
-
new Uint8Array$1(result).set(new Uint8Array$1(arrayBuffer));
|
|
2942
|
-
return result;
|
|
2943
|
-
}
|
|
2944
|
-
var _cloneArrayBuffer = cloneArrayBuffer$3;
|
|
2945
|
-
var cloneArrayBuffer$2 = _cloneArrayBuffer;
|
|
2946
|
-
function cloneDataView$1(dataView, isDeep) {
|
|
2947
|
-
var buffer = isDeep ? cloneArrayBuffer$2(dataView.buffer) : dataView.buffer;
|
|
2948
|
-
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
|
|
2949
|
-
}
|
|
2950
|
-
var _cloneDataView = cloneDataView$1;
|
|
2951
|
-
var reFlags = /\w*$/;
|
|
2952
|
-
function cloneRegExp$1(regexp) {
|
|
2953
|
-
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
|
|
2954
|
-
result.lastIndex = regexp.lastIndex;
|
|
2955
|
-
return result;
|
|
2956
|
-
}
|
|
2957
|
-
var _cloneRegExp = cloneRegExp$1;
|
|
2958
|
-
var Symbol$1 = _Symbol;
|
|
2959
|
-
var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
|
|
2960
|
-
function cloneSymbol$1(symbol) {
|
|
2961
|
-
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
|
|
2962
|
-
}
|
|
2963
|
-
var _cloneSymbol = cloneSymbol$1;
|
|
2964
|
-
var cloneArrayBuffer$1 = _cloneArrayBuffer;
|
|
2965
|
-
function cloneTypedArray$1(typedArray, isDeep) {
|
|
2966
|
-
var buffer = isDeep ? cloneArrayBuffer$1(typedArray.buffer) : typedArray.buffer;
|
|
2967
|
-
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
|
2968
|
-
}
|
|
2969
|
-
var _cloneTypedArray = cloneTypedArray$1;
|
|
2970
|
-
var cloneArrayBuffer = _cloneArrayBuffer, cloneDataView = _cloneDataView, cloneRegExp = _cloneRegExp, cloneSymbol = _cloneSymbol, cloneTypedArray = _cloneTypedArray;
|
|
2971
|
-
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]";
|
|
2972
|
-
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]";
|
|
2973
|
-
function initCloneByTag$1(object, tag, isDeep) {
|
|
2974
|
-
var Ctor = object.constructor;
|
|
2975
|
-
switch (tag) {
|
|
2976
|
-
case arrayBufferTag$1:
|
|
2977
|
-
return cloneArrayBuffer(object);
|
|
2978
|
-
case boolTag$1:
|
|
2979
|
-
case dateTag$1:
|
|
2980
|
-
return new Ctor(+object);
|
|
2981
|
-
case dataViewTag$1:
|
|
2982
|
-
return cloneDataView(object, isDeep);
|
|
2983
|
-
case float32Tag$1:
|
|
2984
|
-
case float64Tag$1:
|
|
2985
|
-
case int8Tag$1:
|
|
2986
|
-
case int16Tag$1:
|
|
2987
|
-
case int32Tag$1:
|
|
2988
|
-
case uint8Tag$1:
|
|
2989
|
-
case uint8ClampedTag$1:
|
|
2990
|
-
case uint16Tag$1:
|
|
2991
|
-
case uint32Tag$1:
|
|
2992
|
-
return cloneTypedArray(object, isDeep);
|
|
2993
|
-
case mapTag$2:
|
|
2994
|
-
return new Ctor();
|
|
2995
|
-
case numberTag$1:
|
|
2996
|
-
case stringTag$1:
|
|
2997
|
-
return new Ctor(object);
|
|
2998
|
-
case regexpTag$1:
|
|
2999
|
-
return cloneRegExp(object);
|
|
3000
|
-
case setTag$2:
|
|
3001
|
-
return new Ctor();
|
|
3002
|
-
case symbolTag$1:
|
|
3003
|
-
return cloneSymbol(object);
|
|
3004
|
-
}
|
|
3005
|
-
}
|
|
3006
|
-
var _initCloneByTag = initCloneByTag$1;
|
|
3007
|
-
var isObject$1 = isObject_1;
|
|
3008
|
-
var objectCreate = Object.create;
|
|
3009
|
-
var baseCreate$1 = /* @__PURE__ */ function() {
|
|
3010
|
-
function object() {
|
|
3011
|
-
}
|
|
3012
|
-
return function(proto) {
|
|
3013
|
-
if (!isObject$1(proto)) {
|
|
3014
|
-
return {};
|
|
3015
|
-
}
|
|
3016
|
-
if (objectCreate) {
|
|
3017
|
-
return objectCreate(proto);
|
|
3018
|
-
}
|
|
3019
|
-
object.prototype = proto;
|
|
3020
|
-
var result = new object();
|
|
3021
|
-
object.prototype = void 0;
|
|
3022
|
-
return result;
|
|
3023
|
-
};
|
|
3024
|
-
}();
|
|
3025
|
-
var _baseCreate = baseCreate$1;
|
|
3026
|
-
var baseCreate = _baseCreate, getPrototype = _getPrototype, isPrototype = _isPrototype;
|
|
3027
|
-
function initCloneObject$1(object) {
|
|
3028
|
-
return typeof object.constructor == "function" && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
|
|
3029
|
-
}
|
|
3030
|
-
var _initCloneObject = initCloneObject$1;
|
|
3031
|
-
var getTag$2 = _getTag, isObjectLike$1 = isObjectLike_1;
|
|
3032
|
-
var mapTag$1 = "[object Map]";
|
|
3033
|
-
function baseIsMap$1(value) {
|
|
3034
|
-
return isObjectLike$1(value) && getTag$2(value) == mapTag$1;
|
|
3035
|
-
}
|
|
3036
|
-
var _baseIsMap = baseIsMap$1;
|
|
3037
|
-
var baseIsMap = _baseIsMap, baseUnary$1 = _baseUnary, nodeUtil$1 = _nodeUtilExports;
|
|
3038
|
-
var nodeIsMap = nodeUtil$1 && nodeUtil$1.isMap;
|
|
3039
|
-
var isMap$1 = nodeIsMap ? baseUnary$1(nodeIsMap) : baseIsMap;
|
|
3040
|
-
var isMap_1 = isMap$1;
|
|
3041
|
-
var getTag$1 = _getTag, isObjectLike = isObjectLike_1;
|
|
3042
|
-
var setTag$1 = "[object Set]";
|
|
3043
|
-
function baseIsSet$1(value) {
|
|
3044
|
-
return isObjectLike(value) && getTag$1(value) == setTag$1;
|
|
3045
|
-
}
|
|
3046
|
-
var _baseIsSet = baseIsSet$1;
|
|
3047
|
-
var baseIsSet = _baseIsSet, baseUnary = _baseUnary, nodeUtil = _nodeUtilExports;
|
|
3048
|
-
var nodeIsSet = nodeUtil && nodeUtil.isSet;
|
|
3049
|
-
var isSet$1 = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
|
|
3050
|
-
var isSet_1 = isSet$1;
|
|
3051
|
-
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;
|
|
3052
|
-
var CLONE_DEEP_FLAG$1 = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG$1 = 4;
|
|
3053
|
-
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]";
|
|
3054
|
-
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]";
|
|
3055
|
-
var cloneableTags = {};
|
|
3056
|
-
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;
|
|
3057
|
-
cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
|
|
3058
|
-
function baseClone$1(value, bitmask, customizer, key, object, stack) {
|
|
3059
|
-
var result, isDeep = bitmask & CLONE_DEEP_FLAG$1, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG$1;
|
|
3060
|
-
if (customizer) {
|
|
3061
|
-
result = object ? customizer(value, key, object, stack) : customizer(value);
|
|
3062
|
-
}
|
|
3063
|
-
if (result !== void 0) {
|
|
3064
|
-
return result;
|
|
3065
|
-
}
|
|
3066
|
-
if (!isObject(value)) {
|
|
3067
|
-
return value;
|
|
3068
|
-
}
|
|
3069
|
-
var isArr = isArray(value);
|
|
3070
|
-
if (isArr) {
|
|
3071
|
-
result = initCloneArray(value);
|
|
3072
|
-
if (!isDeep) {
|
|
3073
|
-
return copyArray(value, result);
|
|
3074
|
-
}
|
|
3075
|
-
} else {
|
|
3076
|
-
var tag = getTag(value), isFunc = tag == funcTag || tag == genTag;
|
|
3077
|
-
if (isBuffer(value)) {
|
|
3078
|
-
return cloneBuffer(value, isDeep);
|
|
3079
|
-
}
|
|
3080
|
-
if (tag == objectTag || tag == argsTag || isFunc && !object) {
|
|
3081
|
-
result = isFlat || isFunc ? {} : initCloneObject(value);
|
|
3082
|
-
if (!isDeep) {
|
|
3083
|
-
return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value));
|
|
3084
|
-
}
|
|
3085
|
-
} else {
|
|
3086
|
-
if (!cloneableTags[tag]) {
|
|
3087
|
-
return object ? value : {};
|
|
3088
|
-
}
|
|
3089
|
-
result = initCloneByTag(value, tag, isDeep);
|
|
3090
|
-
}
|
|
3091
|
-
}
|
|
3092
|
-
stack || (stack = new Stack());
|
|
3093
|
-
var stacked = stack.get(value);
|
|
3094
|
-
if (stacked) {
|
|
3095
|
-
return stacked;
|
|
3096
|
-
}
|
|
3097
|
-
stack.set(value, result);
|
|
3098
|
-
if (isSet(value)) {
|
|
3099
|
-
value.forEach(function(subValue) {
|
|
3100
|
-
result.add(baseClone$1(subValue, bitmask, customizer, subValue, value, stack));
|
|
3101
|
-
});
|
|
3102
|
-
} else if (isMap(value)) {
|
|
3103
|
-
value.forEach(function(subValue, key2) {
|
|
3104
|
-
result.set(key2, baseClone$1(subValue, bitmask, customizer, key2, value, stack));
|
|
3105
|
-
});
|
|
3106
|
-
}
|
|
3107
|
-
var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys;
|
|
3108
|
-
var props = isArr ? void 0 : keysFunc(value);
|
|
3109
|
-
arrayEach(props || value, function(subValue, key2) {
|
|
3110
|
-
if (props) {
|
|
3111
|
-
key2 = subValue;
|
|
3112
|
-
subValue = value[key2];
|
|
3113
|
-
}
|
|
3114
|
-
assignValue(result, key2, baseClone$1(subValue, bitmask, customizer, key2, value, stack));
|
|
3115
|
-
});
|
|
3116
|
-
return result;
|
|
3117
|
-
}
|
|
3118
|
-
var _baseClone = baseClone$1;
|
|
3119
|
-
var baseClone = _baseClone;
|
|
3120
|
-
var CLONE_DEEP_FLAG = 1, CLONE_SYMBOLS_FLAG = 4;
|
|
3121
|
-
function cloneDeep$1(value) {
|
|
3122
|
-
return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
|
|
3123
|
-
}
|
|
3124
|
-
var cloneDeep_1 = cloneDeep$1;
|
|
3125
|
-
const cloneDeep = /* @__PURE__ */ getDefaultExportFromCjs(cloneDeep_1);
|
|
3126
2246
|
class CollectionRegistry {
|
|
3127
2247
|
// Normalized runtime layer (used by Data Grid / UI)
|
|
3128
2248
|
collectionsByTableName = /* @__PURE__ */ new Map();
|
|
@@ -3170,7 +2290,7 @@
|
|
|
3170
2290
|
...c
|
|
3171
2291
|
}));
|
|
3172
2292
|
normalizedCollections.forEach((c, index) => {
|
|
3173
|
-
const raw =
|
|
2293
|
+
const raw = deepClone(collections[index]);
|
|
3174
2294
|
this.rootCollections.push(c);
|
|
3175
2295
|
this.rawRootCollections.push(raw);
|
|
3176
2296
|
const normalized = this.normalizeCollection(c);
|
|
@@ -3190,7 +2310,7 @@
|
|
|
3190
2310
|
if (!subCollection) return;
|
|
3191
2311
|
this._registerRecursively(this.normalizeCollection({
|
|
3192
2312
|
...subCollection
|
|
3193
|
-
}),
|
|
2313
|
+
}), deepClone(subCollection));
|
|
3194
2314
|
});
|
|
3195
2315
|
}
|
|
3196
2316
|
});
|
|
@@ -3198,7 +2318,7 @@
|
|
|
3198
2318
|
return true;
|
|
3199
2319
|
}
|
|
3200
2320
|
register(collection, rawCollection) {
|
|
3201
|
-
const raw = rawCollection ?
|
|
2321
|
+
const raw = rawCollection ? deepClone(rawCollection) : deepClone(collection);
|
|
3202
2322
|
this.rootCollections.push(collection);
|
|
3203
2323
|
this.rawRootCollections.push(raw);
|
|
3204
2324
|
this._registerRecursively(collection, raw);
|
|
@@ -3222,7 +2342,7 @@
|
|
|
3222
2342
|
if (!subCollection) return;
|
|
3223
2343
|
this._registerRecursively(this.normalizeCollection({
|
|
3224
2344
|
...subCollection
|
|
3225
|
-
}),
|
|
2345
|
+
}), deepClone(subCollection));
|
|
3226
2346
|
});
|
|
3227
2347
|
}
|
|
3228
2348
|
}
|
|
@@ -3394,7 +2514,10 @@
|
|
|
3394
2514
|
if (!relation) {
|
|
3395
2515
|
throw new Error(`Relation '${relationKey}' not found in collection '${currentCollection.slug}'`);
|
|
3396
2516
|
}
|
|
3397
|
-
|
|
2517
|
+
const target = relation.target();
|
|
2518
|
+
const targetRelationKey = relation.relationName || target.slug;
|
|
2519
|
+
const targetSlug = relation.overrides?.slug ?? targetRelationKey;
|
|
2520
|
+
currentCollection = this.get(targetSlug) || this.normalizeCollection(target);
|
|
3398
2521
|
if (i + 1 < pathSegments.length) ;
|
|
3399
2522
|
}
|
|
3400
2523
|
return currentCollection;
|
|
@@ -3443,7 +2566,7 @@
|
|
|
3443
2566
|
if (!subcollection) {
|
|
3444
2567
|
throw new Error(`Subcollection '${subcollectionSlug}' not found in ${currentCollection.slug}`);
|
|
3445
2568
|
}
|
|
3446
|
-
currentCollection = subcollection;
|
|
2569
|
+
currentCollection = this.get(subcollection.slug) || this.normalizeCollection(subcollection);
|
|
3447
2570
|
collections.push(currentCollection);
|
|
3448
2571
|
}
|
|
3449
2572
|
}
|
|
@@ -3680,8 +2803,14 @@
|
|
|
3680
2803
|
static buildSingleFilterCondition(column, op, value) {
|
|
3681
2804
|
switch (op) {
|
|
3682
2805
|
case "==":
|
|
2806
|
+
if (value === null || value === void 0) {
|
|
2807
|
+
return drizzleOrm.sql`${column} IS NULL`;
|
|
2808
|
+
}
|
|
3683
2809
|
return drizzleOrm.eq(column, value);
|
|
3684
2810
|
case "!=":
|
|
2811
|
+
if (value === null || value === void 0) {
|
|
2812
|
+
return drizzleOrm.sql`${column} IS NOT NULL`;
|
|
2813
|
+
}
|
|
3685
2814
|
return drizzleOrm.sql`${column} != ${value}`;
|
|
3686
2815
|
case ">":
|
|
3687
2816
|
return drizzleOrm.sql`${column} > ${value}`;
|
|
@@ -4485,7 +3614,25 @@
|
|
|
4485
3614
|
return result;
|
|
4486
3615
|
}
|
|
4487
3616
|
return value;
|
|
3617
|
+
case "string":
|
|
3618
|
+
if (typeof value === "string") {
|
|
3619
|
+
if (value.startsWith("data:application/octet-stream;base64,")) {
|
|
3620
|
+
const base64Data = value.split(",")[1];
|
|
3621
|
+
if (base64Data) {
|
|
3622
|
+
return Buffer.from(base64Data, "base64");
|
|
3623
|
+
}
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
return value;
|
|
4488
3627
|
default:
|
|
3628
|
+
if (typeof value === "string") {
|
|
3629
|
+
if (value.startsWith("data:application/octet-stream;base64,")) {
|
|
3630
|
+
const base64Data = value.split(",")[1];
|
|
3631
|
+
if (base64Data) {
|
|
3632
|
+
return Buffer.from(base64Data, "base64");
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
}
|
|
4489
3636
|
return value;
|
|
4490
3637
|
}
|
|
4491
3638
|
}
|
|
@@ -4611,6 +3758,37 @@
|
|
|
4611
3758
|
return value;
|
|
4612
3759
|
}
|
|
4613
3760
|
switch (property.type) {
|
|
3761
|
+
case "string": {
|
|
3762
|
+
if (typeof value === "string") return value;
|
|
3763
|
+
let isBuffer = false;
|
|
3764
|
+
let buf = null;
|
|
3765
|
+
if (Buffer.isBuffer(value)) {
|
|
3766
|
+
isBuffer = true;
|
|
3767
|
+
buf = value;
|
|
3768
|
+
} else if (typeof value === "object" && value !== null && value.type === "Buffer" && Array.isArray(value.data)) {
|
|
3769
|
+
isBuffer = true;
|
|
3770
|
+
buf = Buffer.from(value.data);
|
|
3771
|
+
}
|
|
3772
|
+
if (isBuffer && buf) {
|
|
3773
|
+
let isPrintable = true;
|
|
3774
|
+
for (let i = 0; i < buf.length; i++) {
|
|
3775
|
+
const b = buf[i];
|
|
3776
|
+
if ((b < 32 || b > 126) && b !== 9 && b !== 10 && b !== 13) {
|
|
3777
|
+
isPrintable = false;
|
|
3778
|
+
break;
|
|
3779
|
+
}
|
|
3780
|
+
}
|
|
3781
|
+
return isPrintable ? buf.toString("utf8") : `data:application/octet-stream;base64,${buf.toString("base64")}`;
|
|
3782
|
+
}
|
|
3783
|
+
if (typeof value === "object" && value !== null) {
|
|
3784
|
+
try {
|
|
3785
|
+
return JSON.stringify(value);
|
|
3786
|
+
} catch {
|
|
3787
|
+
return String(value);
|
|
3788
|
+
}
|
|
3789
|
+
}
|
|
3790
|
+
return String(value);
|
|
3791
|
+
}
|
|
4614
3792
|
case "relation":
|
|
4615
3793
|
if (typeof value === "string" || typeof value === "number") {
|
|
4616
3794
|
let relationDef = property.relation;
|
|
@@ -4694,8 +3872,29 @@
|
|
|
4694
3872
|
}
|
|
4695
3873
|
return null;
|
|
4696
3874
|
}
|
|
4697
|
-
default:
|
|
3875
|
+
default: {
|
|
3876
|
+
let isBuffer = false;
|
|
3877
|
+
let buf = null;
|
|
3878
|
+
if (Buffer.isBuffer(value)) {
|
|
3879
|
+
isBuffer = true;
|
|
3880
|
+
buf = value;
|
|
3881
|
+
} else if (typeof value === "object" && value !== null && value.type === "Buffer" && Array.isArray(value.data)) {
|
|
3882
|
+
isBuffer = true;
|
|
3883
|
+
buf = Buffer.from(value.data);
|
|
3884
|
+
}
|
|
3885
|
+
if (isBuffer && buf) {
|
|
3886
|
+
let isPrintable = true;
|
|
3887
|
+
for (let i = 0; i < buf.length; i++) {
|
|
3888
|
+
const b = buf[i];
|
|
3889
|
+
if ((b < 32 || b > 126) && b !== 9 && b !== 10 && b !== 13) {
|
|
3890
|
+
isPrintable = false;
|
|
3891
|
+
break;
|
|
3892
|
+
}
|
|
3893
|
+
}
|
|
3894
|
+
return isPrintable ? buf.toString("utf8") : `data:application/octet-stream;base64,${buf.toString("base64")}`;
|
|
3895
|
+
}
|
|
4698
3896
|
return value;
|
|
3897
|
+
}
|
|
4699
3898
|
}
|
|
4700
3899
|
}
|
|
4701
3900
|
function normalizeScalarValues(data, properties, collection, resolvedRelations, options) {
|
|
@@ -5963,6 +5162,10 @@
|
|
|
5963
5162
|
await this.resolveJoinPathRelations(entity, collection, collectionPath, parsedId, databaseId);
|
|
5964
5163
|
return entity;
|
|
5965
5164
|
} catch (e) {
|
|
5165
|
+
if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
|
|
5166
|
+
console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
|
|
5167
|
+
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.`);
|
|
5168
|
+
}
|
|
5966
5169
|
console.warn(`[EntityFetchService] db.query.findFirst failed for ${collectionPath}, falling back to db.select:`, e);
|
|
5967
5170
|
}
|
|
5968
5171
|
}
|
|
@@ -6023,6 +5226,10 @@
|
|
|
6023
5226
|
const entities = results2.map((row) => this.drizzleResultToEntity(row, collection, collectionPath, idInfo, options.databaseId, idInfoArray));
|
|
6024
5227
|
return entities;
|
|
6025
5228
|
} catch (e) {
|
|
5229
|
+
if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
|
|
5230
|
+
console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
|
|
5231
|
+
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.`);
|
|
5232
|
+
}
|
|
6026
5233
|
console.warn(`[EntityFetchService] db.query.findMany failed for ${collectionPath}, falling back to db.select:`, e);
|
|
6027
5234
|
}
|
|
6028
5235
|
}
|
|
@@ -6292,6 +5499,10 @@
|
|
|
6292
5499
|
await this.resolveJoinPathRelationsBatchRest(restRows, collection, collectionPath, idInfoArray, include);
|
|
6293
5500
|
return restRows;
|
|
6294
5501
|
} catch (e) {
|
|
5502
|
+
if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
|
|
5503
|
+
console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
|
|
5504
|
+
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.`);
|
|
5505
|
+
}
|
|
6295
5506
|
console.warn(`[fetchCollectionForRest] db.query.findMany failed for ${collectionPath}, falling back:`, e);
|
|
6296
5507
|
}
|
|
6297
5508
|
}
|
|
@@ -6372,6 +5583,10 @@
|
|
|
6372
5583
|
await this.resolveJoinPathRelationsBatchRest([restRow], collection, collectionPath, idInfoArray, include);
|
|
6373
5584
|
return restRow;
|
|
6374
5585
|
} catch (e) {
|
|
5586
|
+
if (e instanceof Error && e.message.includes("not enough information to infer relation")) {
|
|
5587
|
+
console.error(`[EntityFetchService] Relation inference error for collection '${collectionPath}': ${e.message}`);
|
|
5588
|
+
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.`);
|
|
5589
|
+
}
|
|
6375
5590
|
console.warn(`[fetchEntityForRest] db.query.findFirst failed for ${collectionPath}, falling back:`, e);
|
|
6376
5591
|
}
|
|
6377
5592
|
}
|
|
@@ -6630,7 +5845,7 @@
|
|
|
6630
5845
|
targetColumnName = relation.localKey;
|
|
6631
5846
|
} else if (relation.foreignKeyOnTarget) {
|
|
6632
5847
|
targetColumnName = relation.foreignKeyOnTarget;
|
|
6633
|
-
} else if (relation.joinPath && relation.joinPath.length
|
|
5848
|
+
} else if (relation.joinPath && relation.joinPath.length === 1) {
|
|
6634
5849
|
const targetTableName = getTableName(targetCollection);
|
|
6635
5850
|
const relevantJoinStep = relation.joinPath.find((joinStep) => joinStep.table === targetTableName);
|
|
6636
5851
|
if (relevantJoinStep) {
|
|
@@ -6641,6 +5856,8 @@
|
|
|
6641
5856
|
const targetColumnNames = DrizzleConditionBuilder.getColumnNamesFromColumns(relation.joinPath[0].on.to);
|
|
6642
5857
|
targetColumnName = targetColumnNames[0];
|
|
6643
5858
|
}
|
|
5859
|
+
} else if (relation.joinPath && relation.joinPath.length > 1) {
|
|
5860
|
+
break;
|
|
6644
5861
|
} else {
|
|
6645
5862
|
throw new Error(`Relation '${relationKey}' lacks configuration for path-based saving.`);
|
|
6646
5863
|
}
|
|
@@ -6763,22 +5980,78 @@
|
|
|
6763
5980
|
const pgError = this.extractPgError(error);
|
|
6764
5981
|
if (pgError) {
|
|
6765
5982
|
const detail = pgError.detail;
|
|
5983
|
+
const hint = pgError.hint;
|
|
6766
5984
|
const constraint = pgError.constraint;
|
|
6767
5985
|
const column = pgError.column;
|
|
6768
5986
|
const table = pgError.table;
|
|
5987
|
+
const dataType = pgError.dataType;
|
|
5988
|
+
const pgMessage = pgError.message || "Unknown database error";
|
|
5989
|
+
const suffix = hint ? ` Hint: ${hint}` : "";
|
|
5990
|
+
const tableRef = table ?? collectionSlug;
|
|
6769
5991
|
switch (pgError.code) {
|
|
6770
5992
|
case "23503":
|
|
6771
|
-
return new Error(detail ? `Foreign key constraint violated: ${detail}` : `Cannot save: a foreign key constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}"
|
|
5993
|
+
return new Error(detail ? `Foreign key constraint violated: ${detail}${suffix}` : `Cannot save: a foreign key constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
|
|
6772
5994
|
case "23505":
|
|
6773
|
-
return new Error(detail ? `Duplicate value: ${detail}` : `Cannot save: a unique constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}"
|
|
5995
|
+
return new Error(detail ? `Duplicate value: ${detail}${suffix}` : `Cannot save: a unique constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
|
|
6774
5996
|
case "23502":
|
|
6775
|
-
return new Error(`Missing required field: "${column ?? "unknown"}" in "${
|
|
5997
|
+
return new Error(`Missing required field: "${column ?? "unknown"}" in "${tableRef}" cannot be empty.${suffix}`);
|
|
6776
5998
|
case "23514":
|
|
6777
|
-
return new Error(`Validation failed: a check constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}"
|
|
5999
|
+
return new Error(`Validation failed: a check constraint${constraint ? ` (${constraint})` : ""} was violated in "${collectionSlug}".${suffix}`);
|
|
6000
|
+
case "22P02":
|
|
6001
|
+
return new Error(`Invalid data format in "${collectionSlug}": ${pgMessage}${suffix}`);
|
|
6002
|
+
case "22001":
|
|
6003
|
+
return new Error(`Value too long for column "${column ?? "unknown"}" in "${tableRef}": ${pgMessage}${suffix}`);
|
|
6004
|
+
case "22003":
|
|
6005
|
+
return new Error(`Numeric value out of range for column "${column ?? "unknown"}" in "${tableRef}": ${pgMessage}${suffix}`);
|
|
6006
|
+
case "42703":
|
|
6007
|
+
return new Error(`Unknown column in "${tableRef}": ${pgMessage}. Check if your schema is up to date (run migrations).${suffix}`);
|
|
6008
|
+
case "42P01":
|
|
6009
|
+
return new Error(`Table not found for "${collectionSlug}": ${pgMessage}. Check if your schema is up to date (run migrations).${suffix}`);
|
|
6010
|
+
default: {
|
|
6011
|
+
const parts = [`Database error in "${collectionSlug}" [${pgError.code}]: ${pgMessage}`];
|
|
6012
|
+
if (detail) parts.push(`Detail: ${detail}`);
|
|
6013
|
+
if (column) parts.push(`Column: ${column}`);
|
|
6014
|
+
if (dataType) parts.push(`Data type: ${dataType}`);
|
|
6015
|
+
if (constraint) parts.push(`Constraint: ${constraint}`);
|
|
6016
|
+
if (hint) parts.push(`Hint: ${hint}`);
|
|
6017
|
+
return new Error(parts.join(". "));
|
|
6018
|
+
}
|
|
6019
|
+
}
|
|
6020
|
+
}
|
|
6021
|
+
const causeMessage = this.extractCauseMessage(error);
|
|
6022
|
+
if (causeMessage) {
|
|
6023
|
+
return new Error(`Database error in "${collectionSlug}": ${causeMessage}`);
|
|
6024
|
+
}
|
|
6025
|
+
if (error instanceof Error) {
|
|
6026
|
+
const cleaned = this.stripSqlFromMessage(error.message, collectionSlug);
|
|
6027
|
+
return new Error(cleaned);
|
|
6028
|
+
}
|
|
6029
|
+
return new Error(`Database error in "${collectionSlug}": ${String(error)}`);
|
|
6030
|
+
}
|
|
6031
|
+
/**
|
|
6032
|
+
* Walk the error cause chain and return the deepest meaningful message.
|
|
6033
|
+
*/
|
|
6034
|
+
extractCauseMessage(error) {
|
|
6035
|
+
if (!error || typeof error !== "object") return null;
|
|
6036
|
+
const err = error;
|
|
6037
|
+
if (err.cause && typeof err.cause === "object") {
|
|
6038
|
+
const deeper = this.extractCauseMessage(err.cause);
|
|
6039
|
+
if (deeper) return deeper;
|
|
6040
|
+
if (err.cause instanceof Error && err.cause.message) {
|
|
6041
|
+
return err.cause.message;
|
|
6778
6042
|
}
|
|
6779
6043
|
}
|
|
6780
|
-
|
|
6781
|
-
|
|
6044
|
+
return null;
|
|
6045
|
+
}
|
|
6046
|
+
/**
|
|
6047
|
+
* Strip the raw SQL query from a Drizzle "Failed query: ..." message,
|
|
6048
|
+
* keeping only the error description.
|
|
6049
|
+
*/
|
|
6050
|
+
stripSqlFromMessage(message, collectionSlug) {
|
|
6051
|
+
if (message.startsWith("Failed query:")) {
|
|
6052
|
+
return `Failed to save entity in "${collectionSlug}". Check server logs for details.`;
|
|
6053
|
+
}
|
|
6054
|
+
return message;
|
|
6782
6055
|
}
|
|
6783
6056
|
/**
|
|
6784
6057
|
* Extract the underlying PostgreSQL error from a Drizzle wrapper.
|
|
@@ -6787,7 +6060,7 @@
|
|
|
6787
6060
|
extractPgError(error) {
|
|
6788
6061
|
if (!error || typeof error !== "object") return null;
|
|
6789
6062
|
const err = error;
|
|
6790
|
-
if (err.code && /^[0-
|
|
6063
|
+
if (err.code && /^[0-9A-Z]{5}$/.test(err.code)) {
|
|
6791
6064
|
return err;
|
|
6792
6065
|
}
|
|
6793
6066
|
if (err.cause && typeof err.cause === "object") {
|
|
@@ -7075,6 +6348,7 @@
|
|
|
7075
6348
|
branchService;
|
|
7076
6349
|
user;
|
|
7077
6350
|
data;
|
|
6351
|
+
client;
|
|
7078
6352
|
/**
|
|
7079
6353
|
* When true, realtime notifications are deferred until after the
|
|
7080
6354
|
* wrapping transaction commits. Set by `withAuth` → `withTransaction`.
|
|
@@ -7103,6 +6377,14 @@
|
|
|
7103
6377
|
} : {}
|
|
7104
6378
|
};
|
|
7105
6379
|
}
|
|
6380
|
+
/**
|
|
6381
|
+
* REST-optimised fetch service (include-aware eager-loading).
|
|
6382
|
+
* Delegates to the underlying EntityFetchService which already
|
|
6383
|
+
* implements the matching method signatures.
|
|
6384
|
+
*/
|
|
6385
|
+
get restFetchService() {
|
|
6386
|
+
return this.entityService.getFetchService();
|
|
6387
|
+
}
|
|
7106
6388
|
resolveCollectionCallbacks(collection, path2) {
|
|
7107
6389
|
if (!collection && !path2) return {
|
|
7108
6390
|
collection: void 0,
|
|
@@ -7156,7 +6438,8 @@
|
|
|
7156
6438
|
const contextForCallback = {
|
|
7157
6439
|
user: this.user,
|
|
7158
6440
|
driver: this,
|
|
7159
|
-
data: this.data
|
|
6441
|
+
data: this.data,
|
|
6442
|
+
client: this.client
|
|
7160
6443
|
};
|
|
7161
6444
|
return Promise.all(entities.map(async (entity) => {
|
|
7162
6445
|
let fetched = entity;
|
|
@@ -7250,7 +6533,8 @@
|
|
|
7250
6533
|
const contextForCallback = {
|
|
7251
6534
|
user: this.user,
|
|
7252
6535
|
driver: this,
|
|
7253
|
-
data: this.data
|
|
6536
|
+
data: this.data,
|
|
6537
|
+
client: this.client
|
|
7254
6538
|
};
|
|
7255
6539
|
if (callbacks?.afterRead) {
|
|
7256
6540
|
entity = await callbacks.afterRead({
|
|
@@ -7319,7 +6603,8 @@
|
|
|
7319
6603
|
const contextForCallback = {
|
|
7320
6604
|
user: this.user,
|
|
7321
6605
|
driver: this,
|
|
7322
|
-
data: this.data
|
|
6606
|
+
data: this.data,
|
|
6607
|
+
client: this.client
|
|
7323
6608
|
};
|
|
7324
6609
|
let previousValuesForHistory;
|
|
7325
6610
|
if (status === "existing" && entityId) {
|
|
@@ -7354,6 +6639,14 @@
|
|
|
7354
6639
|
if (result) updatedValues = mergeDeep(updatedValues, result);
|
|
7355
6640
|
}
|
|
7356
6641
|
}
|
|
6642
|
+
if (resolvedCollection?.properties) {
|
|
6643
|
+
updatedValues = updateDateAutoValues({
|
|
6644
|
+
inputValues: updatedValues,
|
|
6645
|
+
properties: resolvedCollection.properties,
|
|
6646
|
+
status: status ?? "new",
|
|
6647
|
+
timestampNowValue: /* @__PURE__ */ new Date()
|
|
6648
|
+
});
|
|
6649
|
+
}
|
|
7357
6650
|
try {
|
|
7358
6651
|
let savedEntity = await this.entityService.saveEntity(path2, updatedValues, entityId, resolvedCollection?.databaseId);
|
|
7359
6652
|
if (savedEntity && (callbacks?.afterRead || propertyCallbacks?.afterRead)) {
|
|
@@ -7459,7 +6752,8 @@
|
|
|
7459
6752
|
const contextForCallback = {
|
|
7460
6753
|
user: this.user,
|
|
7461
6754
|
driver: this,
|
|
7462
|
-
data: this.data
|
|
6755
|
+
data: this.data,
|
|
6756
|
+
client: this.client
|
|
7463
6757
|
};
|
|
7464
6758
|
if (callbacks?.beforeDelete || propertyCallbacks?.beforeDelete) {
|
|
7465
6759
|
if (callbacks?.beforeDelete) {
|
|
@@ -7551,7 +6845,17 @@
|
|
|
7551
6845
|
}
|
|
7552
6846
|
const targetDb = this.getTargetDb(options?.database);
|
|
7553
6847
|
try {
|
|
7554
|
-
|
|
6848
|
+
let needsRoleSwitch = false;
|
|
6849
|
+
if (options?.role && process.env.DISABLE_DB_ROLE_SWITCHING !== "true") {
|
|
6850
|
+
try {
|
|
6851
|
+
const currentRoleResult = await targetDb.execute(drizzleOrm.sql.raw("SELECT current_user AS role"));
|
|
6852
|
+
const currentRole = currentRoleResult.rows?.[0]?.role;
|
|
6853
|
+
needsRoleSwitch = !!currentRole && currentRole !== options.role;
|
|
6854
|
+
} catch {
|
|
6855
|
+
needsRoleSwitch = true;
|
|
6856
|
+
}
|
|
6857
|
+
}
|
|
6858
|
+
if (needsRoleSwitch && options?.role) {
|
|
7555
6859
|
const safeRole = options.role.replace(/"/g, '""');
|
|
7556
6860
|
return await targetDb.transaction(async (tx) => {
|
|
7557
6861
|
await tx.execute(drizzleOrm.sql.raw(`SET LOCAL ROLE "${safeRole}"`));
|
|
@@ -7786,6 +7090,7 @@
|
|
|
7786
7090
|
txDelegate.entityService = txEntityService;
|
|
7787
7091
|
txDelegate._deferNotifications = true;
|
|
7788
7092
|
txDelegate._pendingNotifications = pendingNotifications;
|
|
7093
|
+
txDelegate.client = this.delegate.client;
|
|
7789
7094
|
return await operation(txDelegate);
|
|
7790
7095
|
});
|
|
7791
7096
|
for (const notification of pendingNotifications) {
|
|
@@ -8067,6 +7372,12 @@
|
|
|
8067
7372
|
references: [users.id]
|
|
8068
7373
|
})
|
|
8069
7374
|
}));
|
|
7375
|
+
const resolveColumnName = (propName, prop) => {
|
|
7376
|
+
if (prop && "columnName" in prop && typeof prop.columnName === "string") {
|
|
7377
|
+
return prop.columnName;
|
|
7378
|
+
}
|
|
7379
|
+
return toSnakeCase(propName);
|
|
7380
|
+
};
|
|
8070
7381
|
const getPrimaryKeyProp = (collection) => {
|
|
8071
7382
|
if (collection.properties) {
|
|
8072
7383
|
const idPropEntry = Object.entries(collection.properties).find(([_, prop]) => "isId" in prop && Boolean(prop.isId));
|
|
@@ -8107,7 +7418,7 @@
|
|
|
8107
7418
|
return !hasExplicitId && propName === "id";
|
|
8108
7419
|
};
|
|
8109
7420
|
const getDrizzleColumn = (propName, prop, collection, collections) => {
|
|
8110
|
-
const colName =
|
|
7421
|
+
const colName = resolveColumnName(propName, prop);
|
|
8111
7422
|
let columnDefinition;
|
|
8112
7423
|
switch (prop.type) {
|
|
8113
7424
|
case "string": {
|
|
@@ -8179,6 +7490,9 @@
|
|
|
8179
7490
|
} else {
|
|
8180
7491
|
columnDefinition = `timestamp("${colName}", { withTimezone: true, mode: 'string' })`;
|
|
8181
7492
|
}
|
|
7493
|
+
if (dateProp.autoValue === "on_create" || dateProp.autoValue === "on_update") {
|
|
7494
|
+
columnDefinition += `.default(sql\`now()\`)`;
|
|
7495
|
+
}
|
|
8182
7496
|
break;
|
|
8183
7497
|
}
|
|
8184
7498
|
case "map":
|
|
@@ -8211,7 +7525,7 @@
|
|
|
8211
7525
|
} catch {
|
|
8212
7526
|
return null;
|
|
8213
7527
|
}
|
|
8214
|
-
const fkColumnName =
|
|
7528
|
+
const fkColumnName = relation.localKey;
|
|
8215
7529
|
const targetTableVar = getTableVarName(getTableName(targetCollection));
|
|
8216
7530
|
const pkProp = getPrimaryKeyProp(targetCollection);
|
|
8217
7531
|
const targetIdField = pkProp.name;
|
|
@@ -8399,7 +7713,7 @@
|
|
|
8399
7713
|
Object.entries(collection.properties ?? {}).forEach(([propName, prop]) => {
|
|
8400
7714
|
if ("enum" in prop && (prop.type === "string" || prop.type === "number") && prop.enum) {
|
|
8401
7715
|
const enumVarName = getEnumVarName(collectionPath, propName);
|
|
8402
|
-
const enumDbName = `${collectionPath}_${
|
|
7716
|
+
const enumDbName = `${collectionPath}_${resolveColumnName(propName, prop)}`;
|
|
8403
7717
|
const values = Array.isArray(prop.enum) ? prop.enum.map((v) => String(v.id ?? v)) : Object.keys(prop.enum);
|
|
8404
7718
|
if (values.length > 0) {
|
|
8405
7719
|
schemaContent += `export const ${enumVarName} = pgEnum("${enumDbName}", [${values.map((v) => `'${v}'`).join(", ")}]);
|
|
@@ -8456,9 +7770,9 @@
|
|
|
8456
7770
|
const targetId = getPrimaryKeyName(targetCollection);
|
|
8457
7771
|
schemaContent += `export const ${tableVarName} = pgTable("${tableName}", {
|
|
8458
7772
|
`;
|
|
8459
|
-
schemaContent += ` ${sourceColumn}: ${sourceColType}("${
|
|
7773
|
+
schemaContent += ` ${sourceColumn}: ${sourceColType}("${sourceColumn}").notNull().references(() => ${getTableVarName(getTableName(sourceCollection))}.${sourceId}, ${refOptions}),
|
|
8460
7774
|
`;
|
|
8461
|
-
schemaContent += ` ${targetColumn}: ${targetColType}("${
|
|
7775
|
+
schemaContent += ` ${targetColumn}: ${targetColType}("${targetColumn}").notNull().references(() => ${getTableVarName(getTableName(targetCollection))}.${targetId}, ${refOptions}),
|
|
8462
7776
|
`;
|
|
8463
7777
|
schemaContent += "}, (table) => ({\n";
|
|
8464
7778
|
schemaContent += ` pk: primaryKey({ columns: [table.${sourceColumn}, table.${targetColumn}] })
|
|
@@ -8551,29 +7865,10 @@
|
|
|
8551
7865
|
references: [${targetTableVar}.${getPrimaryKeyName(target)}],
|
|
8552
7866
|
relationName: "${drizzleRelationName}"
|
|
8553
7867
|
})`);
|
|
8554
|
-
} else if (rel.direction === "inverse"
|
|
8555
|
-
const sourceIdField = getPrimaryKeyName(collection);
|
|
7868
|
+
} else if (rel.direction === "inverse") {
|
|
8556
7869
|
tableRelations.push(` "${relationKey}": one(${targetTableVar}, {
|
|
8557
|
-
fields: [${tableVarName}.${sourceIdField}],
|
|
8558
|
-
references: [${targetTableVar}.${rel.foreignKeyOnTarget}],
|
|
8559
7870
|
relationName: "${drizzleRelationName}"
|
|
8560
7871
|
})`);
|
|
8561
|
-
} else if (rel.direction === "inverse" && !rel.foreignKeyOnTarget) {
|
|
8562
|
-
try {
|
|
8563
|
-
const targetCollection = rel.target();
|
|
8564
|
-
const targetResolvedRelations = resolveCollectionRelations(targetCollection);
|
|
8565
|
-
const correspondingRelation = Object.values(targetResolvedRelations).find((targetRel) => targetRel.direction === "owning" && targetRel.cardinality === "one" && targetRel.target().slug === collection.slug);
|
|
8566
|
-
if (correspondingRelation && correspondingRelation.localKey) {
|
|
8567
|
-
const sourceIdField = getPrimaryKeyName(collection);
|
|
8568
|
-
tableRelations.push(` "${relationKey}": one(${targetTableVar}, {
|
|
8569
|
-
fields: [${tableVarName}.${sourceIdField}],
|
|
8570
|
-
references: [${targetTableVar}.${correspondingRelation.localKey}],
|
|
8571
|
-
relationName: "${drizzleRelationName}"
|
|
8572
|
-
})`);
|
|
8573
|
-
}
|
|
8574
|
-
} catch (e) {
|
|
8575
|
-
console.warn(`Could not resolve inverse one-to-one relation '${relationKey}':`, e);
|
|
8576
|
-
}
|
|
8577
7872
|
}
|
|
8578
7873
|
} else if (rel.cardinality === "many") {
|
|
8579
7874
|
if (rel.direction === "inverse" && rel.foreignKeyOnTarget) {
|
|
@@ -8601,6 +7896,32 @@
|
|
|
8601
7896
|
console.warn(`Could not generate relation ${relationKey} for ${collection.name}:`, e);
|
|
8602
7897
|
}
|
|
8603
7898
|
}
|
|
7899
|
+
for (const otherCollection of collections) {
|
|
7900
|
+
if (otherCollection.slug === collection.slug) continue;
|
|
7901
|
+
const otherRelations = resolveCollectionRelations(otherCollection);
|
|
7902
|
+
for (const [otherKey, otherRel] of Object.entries(otherRelations)) {
|
|
7903
|
+
if (otherRel.direction === "inverse" && otherRel.foreignKeyOnTarget) {
|
|
7904
|
+
try {
|
|
7905
|
+
const otherTarget = otherRel.target();
|
|
7906
|
+
if (otherTarget.slug === collection.slug) {
|
|
7907
|
+
const drizzleRelationName = computeSharedRelationName(otherRel, otherCollection, collections);
|
|
7908
|
+
const deduplicationKey = `${drizzleRelationName}::owning`;
|
|
7909
|
+
if (!emittedRelationNames.has(deduplicationKey)) {
|
|
7910
|
+
const otherTableVar = getTableVarName(getTableName(otherCollection));
|
|
7911
|
+
const synthKey = `_synth_${otherTableVar}_${otherRel.foreignKeyOnTarget}`;
|
|
7912
|
+
tableRelations.push(` "${synthKey}": one(${otherTableVar}, {
|
|
7913
|
+
fields: [${tableVarName}.${otherRel.foreignKeyOnTarget}],
|
|
7914
|
+
references: [${otherTableVar}.${getPrimaryKeyName(otherCollection)}],
|
|
7915
|
+
relationName: "${drizzleRelationName}"
|
|
7916
|
+
})`);
|
|
7917
|
+
emittedRelationNames.add(deduplicationKey);
|
|
7918
|
+
}
|
|
7919
|
+
}
|
|
7920
|
+
} catch (e) {
|
|
7921
|
+
}
|
|
7922
|
+
}
|
|
7923
|
+
}
|
|
7924
|
+
}
|
|
8604
7925
|
}
|
|
8605
7926
|
if (tableRelations.length > 0) {
|
|
8606
7927
|
const relVarName = `${tableVarName}Relations`;
|
|
@@ -9380,6 +8701,31 @@ ${tableRelations.join(",\n")}
|
|
|
9380
8701
|
return parentPaths;
|
|
9381
8702
|
}
|
|
9382
8703
|
// =============================================================================
|
|
8704
|
+
// Lifecycle / Cleanup
|
|
8705
|
+
// =============================================================================
|
|
8706
|
+
/**
|
|
8707
|
+
* Gracefully tear down all realtime resources.
|
|
8708
|
+
*
|
|
8709
|
+
* This MUST be called during process shutdown, **before** `pool.end()`.
|
|
8710
|
+
* It ensures:
|
|
8711
|
+
* 1. All debounced refetch timers are cancelled (prevents queries after pool closes).
|
|
8712
|
+
* 2. All subscription state and callbacks are cleared.
|
|
8713
|
+
* 3. The dedicated LISTEN client (outside the pool) is disconnected.
|
|
8714
|
+
* 4. All WebSocket clients are removed (but not forcefully closed — the
|
|
8715
|
+
* HTTP server close will handle that).
|
|
8716
|
+
*/
|
|
8717
|
+
async destroy() {
|
|
8718
|
+
for (const [key, timer] of this.refetchTimers) {
|
|
8719
|
+
clearTimeout(timer);
|
|
8720
|
+
this.refetchTimers.delete(key);
|
|
8721
|
+
}
|
|
8722
|
+
this._subscriptions.clear();
|
|
8723
|
+
this.subscriptionCallbacks.clear();
|
|
8724
|
+
await this.stopListening();
|
|
8725
|
+
this.clients.clear();
|
|
8726
|
+
this.debugLog("🧹 [RealtimeService] destroy() complete — all resources released.");
|
|
8727
|
+
}
|
|
8728
|
+
// =============================================================================
|
|
9383
8729
|
// Cross-Instance LISTEN/NOTIFY
|
|
9384
8730
|
// =============================================================================
|
|
9385
8731
|
/**
|
|
@@ -9521,7 +8867,9 @@ ${tableRelations.join(",\n")}
|
|
|
9521
8867
|
const WS_RATE_WINDOW_MS = 6e4;
|
|
9522
8868
|
const ADMIN_ONLY_TYPES = /* @__PURE__ */ new Set(["EXECUTE_SQL", "FETCH_DATABASES", "FETCH_ROLES", "FETCH_UNMAPPED_TABLES", "FETCH_TABLE_METADATA", "FETCH_CURRENT_DATABASE", "CREATE_BRANCH", "DELETE_BRANCH", "LIST_BRANCHES"]);
|
|
9523
8869
|
function isAdminSession(session) {
|
|
9524
|
-
if (!session?.user
|
|
8870
|
+
if (!session?.user) return false;
|
|
8871
|
+
if (session.user.isAdmin) return true;
|
|
8872
|
+
if (!session.user.roles) return false;
|
|
9525
8873
|
return session.user.roles.some((r) => {
|
|
9526
8874
|
if (typeof r === "string") return r === "admin";
|
|
9527
8875
|
if (r && typeof r === "object" && "isAdmin" in r) return r.isAdmin;
|
|
@@ -9529,7 +8877,7 @@ ${tableRelations.join(",\n")}
|
|
|
9529
8877
|
return false;
|
|
9530
8878
|
});
|
|
9531
8879
|
}
|
|
9532
|
-
function createPostgresWebSocket(server, realtimeService, driver, authConfig) {
|
|
8880
|
+
function createPostgresWebSocket(server, realtimeService, driver, authConfig, authAdapter) {
|
|
9533
8881
|
const isProduction = process.env.NODE_ENV === "production";
|
|
9534
8882
|
const wsDebug = (...args) => {
|
|
9535
8883
|
if (!isProduction) console.debug(...args);
|
|
@@ -9543,7 +8891,7 @@ ${tableRelations.join(",\n")}
|
|
|
9543
8891
|
}
|
|
9544
8892
|
console.error("❌ [WebSocket Server] Error:", err);
|
|
9545
8893
|
});
|
|
9546
|
-
const requireAuth = authConfig?.requireAuth !== false && authConfig?.jwtSecret;
|
|
8894
|
+
const requireAuth = authAdapter ? true : authConfig?.requireAuth !== false && !!authConfig?.jwtSecret;
|
|
9547
8895
|
wss.on("connection", (ws2) => {
|
|
9548
8896
|
const clientId = `client_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
9549
8897
|
wsDebug(`WebSocket client connected: ${clientId}`);
|
|
@@ -9588,11 +8936,37 @@ ${tableRelations.join(",\n")}
|
|
|
9588
8936
|
sendError("AUTH_ERROR", "INVALID_INPUT", "Token is required");
|
|
9589
8937
|
return;
|
|
9590
8938
|
}
|
|
9591
|
-
|
|
9592
|
-
if (
|
|
8939
|
+
let verifiedUser = null;
|
|
8940
|
+
if (authAdapter) {
|
|
8941
|
+
try {
|
|
8942
|
+
const adapterUser = authAdapter.verifyToken ? await authAdapter.verifyToken(token) : await authAdapter.verifyRequest(new Request("http://localhost/_ws_auth", {
|
|
8943
|
+
headers: {
|
|
8944
|
+
Authorization: `Bearer ${token}`
|
|
8945
|
+
}
|
|
8946
|
+
}));
|
|
8947
|
+
if (adapterUser) {
|
|
8948
|
+
verifiedUser = {
|
|
8949
|
+
userId: adapterUser.uid,
|
|
8950
|
+
roles: adapterUser.roles,
|
|
8951
|
+
isAdmin: adapterUser.isAdmin
|
|
8952
|
+
};
|
|
8953
|
+
}
|
|
8954
|
+
} catch {
|
|
8955
|
+
}
|
|
8956
|
+
} else {
|
|
8957
|
+
const jwtPayload = serverCore.extractUserFromToken(token);
|
|
8958
|
+
if (jwtPayload) {
|
|
8959
|
+
verifiedUser = {
|
|
8960
|
+
userId: jwtPayload.userId,
|
|
8961
|
+
roles: jwtPayload.roles ?? [],
|
|
8962
|
+
isAdmin: (jwtPayload.roles ?? []).some((r) => r === "admin")
|
|
8963
|
+
};
|
|
8964
|
+
}
|
|
8965
|
+
}
|
|
8966
|
+
if (verifiedUser) {
|
|
9593
8967
|
const session = clientSessions.get(clientId);
|
|
9594
8968
|
if (session) {
|
|
9595
|
-
session.user =
|
|
8969
|
+
session.user = verifiedUser;
|
|
9596
8970
|
session.authenticated = true;
|
|
9597
8971
|
}
|
|
9598
8972
|
wsDebug(`[WS] replying AUTH_SUCCESS for requestId ${requestId}`);
|
|
@@ -9600,11 +8974,11 @@ ${tableRelations.join(",\n")}
|
|
|
9600
8974
|
type: "AUTH_SUCCESS",
|
|
9601
8975
|
requestId,
|
|
9602
8976
|
payload: {
|
|
9603
|
-
userId:
|
|
9604
|
-
roles:
|
|
8977
|
+
userId: verifiedUser.userId,
|
|
8978
|
+
roles: verifiedUser.roles
|
|
9605
8979
|
}
|
|
9606
8980
|
}));
|
|
9607
|
-
wsDebug(`🔐 [WebSocket Server] Client ${clientId} authenticated as ${
|
|
8981
|
+
wsDebug(`🔐 [WebSocket Server] Client ${clientId} authenticated as ${verifiedUser.userId}`);
|
|
9608
8982
|
} else {
|
|
9609
8983
|
wsDebug(`[WS] replying AUTH_ERROR for requestId ${requestId} (invalid token)`);
|
|
9610
8984
|
sendError("AUTH_ERROR", "INVALID_TOKEN", "Invalid or expired token");
|
|
@@ -10133,6 +9507,9 @@ ${tableRelations.join(",\n")}
|
|
|
10133
9507
|
password_hash TEXT,
|
|
10134
9508
|
display_name TEXT,
|
|
10135
9509
|
photo_url TEXT,
|
|
9510
|
+
email_verified BOOLEAN DEFAULT FALSE,
|
|
9511
|
+
email_verification_token TEXT,
|
|
9512
|
+
email_verification_sent_at TIMESTAMP WITH TIME ZONE,
|
|
10136
9513
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
10137
9514
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
10138
9515
|
)
|
|
@@ -10224,7 +9601,6 @@ ${tableRelations.join(",\n")}
|
|
|
10224
9601
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
10225
9602
|
)
|
|
10226
9603
|
`);
|
|
10227
|
-
await applyInternalMigrations(db);
|
|
10228
9604
|
await db.execute(drizzleOrm.sql`CREATE SCHEMA IF NOT EXISTS auth`);
|
|
10229
9605
|
await db.transaction(async (tx) => {
|
|
10230
9606
|
await tx.execute(drizzleOrm.sql`SELECT pg_advisory_xact_lock(hashtext('rebase_auth_functions_init'))`);
|
|
@@ -10277,99 +9653,6 @@ ${tableRelations.join(",\n")}
|
|
|
10277
9653
|
}
|
|
10278
9654
|
console.log("✅ Default roles created: admin, editor, viewer");
|
|
10279
9655
|
}
|
|
10280
|
-
async function applyInternalMigrations(db) {
|
|
10281
|
-
try {
|
|
10282
|
-
await db.execute(drizzleOrm.sql`
|
|
10283
|
-
ALTER TABLE rebase.users
|
|
10284
|
-
ADD COLUMN IF NOT EXISTS email_verified BOOLEAN DEFAULT FALSE,
|
|
10285
|
-
ADD COLUMN IF NOT EXISTS email_verification_token TEXT,
|
|
10286
|
-
ADD COLUMN IF NOT EXISTS email_verification_sent_at TIMESTAMP WITH TIME ZONE
|
|
10287
|
-
`);
|
|
10288
|
-
const columnsCheck = await db.execute(drizzleOrm.sql`
|
|
10289
|
-
SELECT column_name
|
|
10290
|
-
FROM information_schema.columns
|
|
10291
|
-
WHERE table_schema='rebase' AND table_name='users' AND column_name IN ('google_id', 'linkedin_id', 'provider')
|
|
10292
|
-
`);
|
|
10293
|
-
const existingColumns = columnsCheck.rows.map((r) => r.column_name);
|
|
10294
|
-
if (existingColumns.includes("google_id")) {
|
|
10295
|
-
await db.execute(drizzleOrm.sql`
|
|
10296
|
-
INSERT INTO rebase.user_identities (user_id, provider, provider_id)
|
|
10297
|
-
SELECT id, 'google', google_id
|
|
10298
|
-
FROM rebase.users
|
|
10299
|
-
WHERE google_id IS NOT NULL
|
|
10300
|
-
ON CONFLICT (provider, provider_id) DO NOTHING
|
|
10301
|
-
`);
|
|
10302
|
-
}
|
|
10303
|
-
if (existingColumns.includes("linkedin_id")) {
|
|
10304
|
-
await db.execute(drizzleOrm.sql`
|
|
10305
|
-
INSERT INTO rebase.user_identities (user_id, provider, provider_id)
|
|
10306
|
-
SELECT id, 'linkedin', linkedin_id
|
|
10307
|
-
FROM rebase.users
|
|
10308
|
-
WHERE linkedin_id IS NOT NULL
|
|
10309
|
-
ON CONFLICT (provider, provider_id) DO NOTHING
|
|
10310
|
-
`);
|
|
10311
|
-
}
|
|
10312
|
-
if (existingColumns.length > 0) {
|
|
10313
|
-
await db.execute(drizzleOrm.sql`
|
|
10314
|
-
ALTER TABLE rebase.users
|
|
10315
|
-
DROP COLUMN IF EXISTS provider,
|
|
10316
|
-
DROP COLUMN IF EXISTS google_id,
|
|
10317
|
-
DROP COLUMN IF EXISTS linkedin_id
|
|
10318
|
-
`);
|
|
10319
|
-
await db.execute(drizzleOrm.sql`DROP INDEX IF EXISTS rebase.idx_users_google_id`);
|
|
10320
|
-
await db.execute(drizzleOrm.sql`DROP INDEX IF EXISTS rebase.idx_users_linkedin_id`);
|
|
10321
|
-
console.log("✅ Migrated to user_identities and dropped legacy columns.");
|
|
10322
|
-
}
|
|
10323
|
-
await db.execute(drizzleOrm.sql`
|
|
10324
|
-
ALTER TABLE rebase.roles
|
|
10325
|
-
ADD COLUMN IF NOT EXISTS collection_permissions JSONB
|
|
10326
|
-
`);
|
|
10327
|
-
await db.execute(drizzleOrm.sql`
|
|
10328
|
-
ALTER TABLE rebase.refresh_tokens
|
|
10329
|
-
ADD COLUMN IF NOT EXISTS user_agent TEXT,
|
|
10330
|
-
ADD COLUMN IF NOT EXISTS ip_address TEXT
|
|
10331
|
-
`);
|
|
10332
|
-
const constraintCheck = await db.execute(drizzleOrm.sql`
|
|
10333
|
-
SELECT 1 FROM information_schema.table_constraints
|
|
10334
|
-
WHERE constraint_name = 'unique_device_session'
|
|
10335
|
-
AND table_schema = 'rebase'
|
|
10336
|
-
AND table_name = 'refresh_tokens'
|
|
10337
|
-
`);
|
|
10338
|
-
if (constraintCheck.rows.length === 0) {
|
|
10339
|
-
try {
|
|
10340
|
-
await db.execute(drizzleOrm.sql`
|
|
10341
|
-
ALTER TABLE rebase.refresh_tokens
|
|
10342
|
-
ADD CONSTRAINT unique_device_session UNIQUE (user_id, user_agent, ip_address)
|
|
10343
|
-
`);
|
|
10344
|
-
console.log("✅ Added unique_device_session constraint");
|
|
10345
|
-
} catch (e) {
|
|
10346
|
-
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
10347
|
-
if (errorMessage.includes("could not create unique index")) {
|
|
10348
|
-
console.warn("⚠️ Duplicate sessions found, cleaning up before adding constraint...");
|
|
10349
|
-
await db.execute(drizzleOrm.sql`
|
|
10350
|
-
DELETE FROM rebase.refresh_tokens a
|
|
10351
|
-
USING rebase.refresh_tokens b
|
|
10352
|
-
WHERE a.user_id = b.user_id
|
|
10353
|
-
AND COALESCE(a.user_agent, '') = COALESCE(b.user_agent, '')
|
|
10354
|
-
AND COALESCE(a.ip_address, '') = COALESCE(b.ip_address, '')
|
|
10355
|
-
AND a.created_at < b.created_at
|
|
10356
|
-
`);
|
|
10357
|
-
await db.execute(drizzleOrm.sql`
|
|
10358
|
-
ALTER TABLE rebase.refresh_tokens
|
|
10359
|
-
ADD CONSTRAINT unique_device_session UNIQUE (user_id, user_agent, ip_address)
|
|
10360
|
-
`).catch((retryErr) => {
|
|
10361
|
-
const retryMessage = retryErr instanceof Error ? retryErr.message : String(retryErr);
|
|
10362
|
-
console.error("Failed to add unique_device_session constraint after cleanup:", retryMessage);
|
|
10363
|
-
});
|
|
10364
|
-
} else {
|
|
10365
|
-
console.error("Constraint migration issue:", errorMessage);
|
|
10366
|
-
}
|
|
10367
|
-
}
|
|
10368
|
-
}
|
|
10369
|
-
} catch (error) {
|
|
10370
|
-
console.error("❌ Failed to run internal migrations:", error);
|
|
10371
|
-
}
|
|
10372
|
-
}
|
|
10373
9656
|
class UserService {
|
|
10374
9657
|
constructor(db) {
|
|
10375
9658
|
this.db = db;
|
|
@@ -11266,11 +10549,48 @@ ${tableRelations.join(",\n")}
|
|
|
11266
10549
|
},
|
|
11267
10550
|
mountRoutes(app, basePath, driverResult) {
|
|
11268
10551
|
},
|
|
11269
|
-
async initializeWebsockets(server, realtimeService, driver, config) {
|
|
10552
|
+
async initializeWebsockets(server, realtimeService, driver, config, adapter) {
|
|
11270
10553
|
const {
|
|
11271
10554
|
createPostgresWebSocket: createPostgresWebSocket2
|
|
11272
10555
|
} = await Promise.resolve().then(() => websocket);
|
|
11273
|
-
createPostgresWebSocket2(server, realtimeService, driver, config);
|
|
10556
|
+
createPostgresWebSocket2(server, realtimeService, driver, config, adapter);
|
|
10557
|
+
}
|
|
10558
|
+
};
|
|
10559
|
+
}
|
|
10560
|
+
function createPostgresAdapter(pgConfig) {
|
|
10561
|
+
const bootstrapper = createPostgresBootstrapper(pgConfig);
|
|
10562
|
+
return {
|
|
10563
|
+
type: bootstrapper.type,
|
|
10564
|
+
async initializeDriver(config) {
|
|
10565
|
+
return bootstrapper.initializeDriver(config);
|
|
10566
|
+
},
|
|
10567
|
+
async initializeRealtime(driverResult) {
|
|
10568
|
+
if (bootstrapper.initializeRealtime) {
|
|
10569
|
+
return bootstrapper.initializeRealtime({}, driverResult);
|
|
10570
|
+
}
|
|
10571
|
+
return void 0;
|
|
10572
|
+
},
|
|
10573
|
+
async initializeHistory(config, driverResult) {
|
|
10574
|
+
if (bootstrapper.initializeHistory) {
|
|
10575
|
+
return bootstrapper.initializeHistory(config, driverResult);
|
|
10576
|
+
}
|
|
10577
|
+
return void 0;
|
|
10578
|
+
},
|
|
10579
|
+
initializeWebsockets(server, realtimeService, driver, config) {
|
|
10580
|
+
if (bootstrapper.initializeWebsockets) {
|
|
10581
|
+
return bootstrapper.initializeWebsockets(server, realtimeService, driver, config);
|
|
10582
|
+
}
|
|
10583
|
+
},
|
|
10584
|
+
getAdmin(driverResult) {
|
|
10585
|
+
if (bootstrapper.getAdmin) {
|
|
10586
|
+
return bootstrapper.getAdmin(driverResult);
|
|
10587
|
+
}
|
|
10588
|
+
return void 0;
|
|
10589
|
+
},
|
|
10590
|
+
mountRoutes(app, basePath, driverResult) {
|
|
10591
|
+
if (bootstrapper.mountRoutes) {
|
|
10592
|
+
bootstrapper.mountRoutes(app, basePath, driverResult);
|
|
10593
|
+
}
|
|
11274
10594
|
}
|
|
11275
10595
|
};
|
|
11276
10596
|
}
|
|
@@ -11284,6 +10604,7 @@ ${tableRelations.join(",\n")}
|
|
|
11284
10604
|
exports2.PostgresRealtimeProvider = PostgresRealtimeProvider;
|
|
11285
10605
|
exports2.RealtimeService = RealtimeService;
|
|
11286
10606
|
exports2.appConfig = appConfig;
|
|
10607
|
+
exports2.createPostgresAdapter = createPostgresAdapter;
|
|
11287
10608
|
exports2.createPostgresBootstrapper = createPostgresBootstrapper;
|
|
11288
10609
|
exports2.createPostgresDatabaseConnection = createPostgresDatabaseConnection;
|
|
11289
10610
|
exports2.createPostgresWebSocket = createPostgresWebSocket;
|