orchid-orm 1.6.24 → 1.6.29
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/bin.js +1 -1
- package/dist/bin.js.map +1 -1
- package/dist/index.d.ts +23 -13
- package/dist/index.js +165 -52
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -348,21 +348,21 @@ const hasRelationHandleUpdate = (q, ctx, set, key, primaryKey, nestedUpdate) =>
|
|
|
348
348
|
});
|
|
349
349
|
};
|
|
350
350
|
|
|
351
|
-
var __defProp$
|
|
351
|
+
var __defProp$7 = Object.defineProperty;
|
|
352
352
|
var __defProps$5 = Object.defineProperties;
|
|
353
353
|
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
354
354
|
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
355
355
|
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
356
356
|
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
357
|
-
var __defNormalProp$
|
|
358
|
-
var __spreadValues$
|
|
357
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
358
|
+
var __spreadValues$7 = (a, b) => {
|
|
359
359
|
for (var prop in b || (b = {}))
|
|
360
360
|
if (__hasOwnProp$9.call(b, prop))
|
|
361
|
-
__defNormalProp$
|
|
361
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
362
362
|
if (__getOwnPropSymbols$9)
|
|
363
363
|
for (var prop of __getOwnPropSymbols$9(b)) {
|
|
364
364
|
if (__propIsEnum$9.call(b, prop))
|
|
365
|
-
__defNormalProp$
|
|
365
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
366
366
|
}
|
|
367
367
|
return a;
|
|
368
368
|
};
|
|
@@ -499,7 +499,7 @@ const nestedInsert$2 = ({ query, primaryKey, foreignKey }) => {
|
|
|
499
499
|
);
|
|
500
500
|
if (create.length) {
|
|
501
501
|
await t._count()._createMany(
|
|
502
|
-
create.map(([selfData, item]) => __spreadValues$
|
|
502
|
+
create.map(([selfData, item]) => __spreadValues$7({
|
|
503
503
|
[foreignKey]: selfData[primaryKey]
|
|
504
504
|
}, "create" in item ? item.create : item.connectOrCreate.create))
|
|
505
505
|
);
|
|
@@ -520,7 +520,7 @@ const nestedUpdate$2 = ({ query, primaryKey, foreignKey }) => {
|
|
|
520
520
|
if (params.create || params.disconnect || params.set) {
|
|
521
521
|
await currentRelationsQuery._update({ [foreignKey]: null });
|
|
522
522
|
if (params.create) {
|
|
523
|
-
await t._count()._create(__spreadProps$5(__spreadValues$
|
|
523
|
+
await t._count()._create(__spreadProps$5(__spreadValues$7({}, params.create), {
|
|
524
524
|
[foreignKey]: data[0][primaryKey]
|
|
525
525
|
}));
|
|
526
526
|
}
|
|
@@ -536,7 +536,7 @@ const nestedUpdate$2 = ({ query, primaryKey, foreignKey }) => {
|
|
|
536
536
|
const updatedIds = await currentRelationsQuery._pluck(foreignKey)._update(update);
|
|
537
537
|
if (updatedIds.length < ids.length) {
|
|
538
538
|
await t.createMany(
|
|
539
|
-
ids.filter((id) => !updatedIds.includes(id)).map((id) => __spreadProps$5(__spreadValues$
|
|
539
|
+
ids.filter((id) => !updatedIds.includes(id)).map((id) => __spreadProps$5(__spreadValues$7({}, create), {
|
|
540
540
|
[foreignKey]: id
|
|
541
541
|
}))
|
|
542
542
|
);
|
|
@@ -545,21 +545,21 @@ const nestedUpdate$2 = ({ query, primaryKey, foreignKey }) => {
|
|
|
545
545
|
};
|
|
546
546
|
};
|
|
547
547
|
|
|
548
|
-
var __defProp$
|
|
548
|
+
var __defProp$6 = Object.defineProperty;
|
|
549
549
|
var __defProps$4 = Object.defineProperties;
|
|
550
550
|
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
551
551
|
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
552
552
|
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
553
553
|
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
554
|
-
var __defNormalProp$
|
|
555
|
-
var __spreadValues$
|
|
554
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
555
|
+
var __spreadValues$6 = (a, b) => {
|
|
556
556
|
for (var prop in b || (b = {}))
|
|
557
557
|
if (__hasOwnProp$8.call(b, prop))
|
|
558
|
-
__defNormalProp$
|
|
558
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
559
559
|
if (__getOwnPropSymbols$8)
|
|
560
560
|
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
561
561
|
if (__propIsEnum$8.call(b, prop))
|
|
562
|
-
__defNormalProp$
|
|
562
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
563
563
|
}
|
|
564
564
|
return a;
|
|
565
565
|
};
|
|
@@ -729,10 +729,10 @@ const nestedInsert$1 = ({ query, primaryKey, foreignKey }) => {
|
|
|
729
729
|
await t._createMany(
|
|
730
730
|
create.flatMap(([selfData, { create: create2 = [], connectOrCreate: connectOrCreate2 = [] }]) => {
|
|
731
731
|
return [
|
|
732
|
-
...create2.map((item) => __spreadValues$
|
|
732
|
+
...create2.map((item) => __spreadValues$6({
|
|
733
733
|
[foreignKey]: selfData[primaryKey]
|
|
734
734
|
}, item)),
|
|
735
|
-
...connectOrCreate2.filter(() => connected[connectedI++] === 0).map((item) => __spreadValues$
|
|
735
|
+
...connectOrCreate2.filter(() => connected[connectedI++] === 0).map((item) => __spreadValues$6({
|
|
736
736
|
[foreignKey]: selfData[primaryKey]
|
|
737
737
|
}, item.create))
|
|
738
738
|
];
|
|
@@ -751,7 +751,7 @@ const nestedUpdate$1 = ({ query, primaryKey, foreignKey }) => {
|
|
|
751
751
|
const t = query.transacting(q);
|
|
752
752
|
if (params.create) {
|
|
753
753
|
await t._count()._createMany(
|
|
754
|
-
params.create.map((create) => __spreadProps$4(__spreadValues$
|
|
754
|
+
params.create.map((create) => __spreadProps$4(__spreadValues$6({}, create), {
|
|
755
755
|
[foreignKey]: data[0][primaryKey]
|
|
756
756
|
}))
|
|
757
757
|
);
|
|
@@ -794,21 +794,21 @@ const nestedUpdate$1 = ({ query, primaryKey, foreignKey }) => {
|
|
|
794
794
|
};
|
|
795
795
|
};
|
|
796
796
|
|
|
797
|
-
var __defProp$
|
|
797
|
+
var __defProp$5 = Object.defineProperty;
|
|
798
798
|
var __defProps$3 = Object.defineProperties;
|
|
799
799
|
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
800
800
|
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
801
801
|
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
802
802
|
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
803
|
-
var __defNormalProp$
|
|
804
|
-
var __spreadValues$
|
|
803
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
804
|
+
var __spreadValues$5 = (a, b) => {
|
|
805
805
|
for (var prop in b || (b = {}))
|
|
806
806
|
if (__hasOwnProp$7.call(b, prop))
|
|
807
|
-
__defNormalProp$
|
|
807
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
808
808
|
if (__getOwnPropSymbols$7)
|
|
809
809
|
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
810
810
|
if (__propIsEnum$7.call(b, prop))
|
|
811
|
-
__defNormalProp$
|
|
811
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
812
812
|
}
|
|
813
813
|
return a;
|
|
814
814
|
};
|
|
@@ -847,7 +847,7 @@ const removeColumnName = (column) => {
|
|
|
847
847
|
if (!column.data.name)
|
|
848
848
|
return column;
|
|
849
849
|
const cloned = Object.create(column);
|
|
850
|
-
cloned.data = __spreadProps$3(__spreadValues$
|
|
850
|
+
cloned.data = __spreadProps$3(__spreadValues$5({}, column.data), { name: void 0 });
|
|
851
851
|
return cloned;
|
|
852
852
|
};
|
|
853
853
|
const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query) => {
|
|
@@ -868,7 +868,7 @@ const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query)
|
|
|
868
868
|
[fk]: removeColumnName(table.shape[pk]),
|
|
869
869
|
[afk]: removeColumnName(query.shape[apk])
|
|
870
870
|
};
|
|
871
|
-
baseQuery.query = __spreadProps$3(__spreadValues$
|
|
871
|
+
baseQuery.query = __spreadProps$3(__spreadValues$5({}, baseQuery.query), {
|
|
872
872
|
shape: baseQuery.shape
|
|
873
873
|
});
|
|
874
874
|
const subQuery = Object.create(baseQuery);
|
|
@@ -903,7 +903,7 @@ const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query)
|
|
|
903
903
|
subQuery,
|
|
904
904
|
(q) => q._on(associationForeignKeyFull, `${pqb.getQueryAs(toQuery)}.${apk}`)._on(foreignKeyFull, `${pqb.getQueryAs(fromQuery)}.${pk}`)
|
|
905
905
|
);
|
|
906
|
-
join.query.joinedShapes = __spreadProps$3(__spreadValues$
|
|
906
|
+
join.query.joinedShapes = __spreadProps$3(__spreadValues$5({}, join.query.joinedShapes), {
|
|
907
907
|
[fromQuery.query.as || fromQuery.table]: fromQuery.query.shape
|
|
908
908
|
});
|
|
909
909
|
return join;
|
|
@@ -930,7 +930,7 @@ const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query)
|
|
|
930
930
|
}
|
|
931
931
|
);
|
|
932
932
|
if (createdCount === 0) {
|
|
933
|
-
throw new pqb.NotFoundError();
|
|
933
|
+
throw new pqb.NotFoundError(fromQuery);
|
|
934
934
|
}
|
|
935
935
|
}
|
|
936
936
|
);
|
|
@@ -1316,21 +1316,21 @@ function transaction(fn) {
|
|
|
1316
1316
|
});
|
|
1317
1317
|
}
|
|
1318
1318
|
|
|
1319
|
-
var __defProp$
|
|
1319
|
+
var __defProp$4 = Object.defineProperty;
|
|
1320
1320
|
var __defProps$2 = Object.defineProperties;
|
|
1321
1321
|
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
1322
1322
|
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
1323
1323
|
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
1324
1324
|
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
1325
|
-
var __defNormalProp$
|
|
1326
|
-
var __spreadValues$
|
|
1325
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1326
|
+
var __spreadValues$4 = (a, b) => {
|
|
1327
1327
|
for (var prop in b || (b = {}))
|
|
1328
1328
|
if (__hasOwnProp$6.call(b, prop))
|
|
1329
|
-
__defNormalProp$
|
|
1329
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
1330
1330
|
if (__getOwnPropSymbols$6)
|
|
1331
1331
|
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
1332
1332
|
if (__propIsEnum$6.call(b, prop))
|
|
1333
|
-
__defNormalProp$
|
|
1333
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
1334
1334
|
}
|
|
1335
1335
|
return a;
|
|
1336
1336
|
};
|
|
@@ -1389,7 +1389,7 @@ const orchidORM = (_a, tables) => {
|
|
|
1389
1389
|
}
|
|
1390
1390
|
const table = new tables[key]();
|
|
1391
1391
|
tableInstances[key] = table;
|
|
1392
|
-
const options2 = __spreadProps$2(__spreadValues$
|
|
1392
|
+
const options2 = __spreadProps$2(__spreadValues$4({}, commonOptions), {
|
|
1393
1393
|
schema: table.schema
|
|
1394
1394
|
});
|
|
1395
1395
|
if (table.noPrimaryKey)
|
|
@@ -1410,24 +1410,24 @@ const orchidORM = (_a, tables) => {
|
|
|
1410
1410
|
return result;
|
|
1411
1411
|
};
|
|
1412
1412
|
|
|
1413
|
-
var __defProp$
|
|
1413
|
+
var __defProp$3 = Object.defineProperty;
|
|
1414
1414
|
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
1415
1415
|
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
1416
1416
|
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
1417
|
-
var __defNormalProp$
|
|
1418
|
-
var __spreadValues$
|
|
1417
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1418
|
+
var __spreadValues$3 = (a, b) => {
|
|
1419
1419
|
for (var prop in b || (b = {}))
|
|
1420
1420
|
if (__hasOwnProp$5.call(b, prop))
|
|
1421
|
-
__defNormalProp$
|
|
1421
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1422
1422
|
if (__getOwnPropSymbols$5)
|
|
1423
1423
|
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
1424
1424
|
if (__propIsEnum$5.call(b, prop))
|
|
1425
|
-
__defNormalProp$
|
|
1425
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1426
1426
|
}
|
|
1427
1427
|
return a;
|
|
1428
1428
|
};
|
|
1429
1429
|
const createRepo = (table, methods) => {
|
|
1430
|
-
const queryMethods = __spreadValues$
|
|
1430
|
+
const queryMethods = __spreadValues$3(__spreadValues$3(__spreadValues$3(__spreadValues$3({}, methods.queryMethods), methods.queryOneMethods), methods.queryWithWhereMethods), methods.queryOneWithWhereMethods);
|
|
1431
1431
|
const plainMethods = methods.methods;
|
|
1432
1432
|
const repo = (q2) => {
|
|
1433
1433
|
const proto = Object.create(q2.baseQuery);
|
|
@@ -1839,9 +1839,22 @@ const createTable = async (_a) => {
|
|
|
1839
1839
|
}
|
|
1840
1840
|
};
|
|
1841
1841
|
|
|
1842
|
+
var __defProp$2 = Object.defineProperty;
|
|
1842
1843
|
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
1843
1844
|
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
1844
1845
|
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
1846
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1847
|
+
var __spreadValues$2 = (a, b) => {
|
|
1848
|
+
for (var prop in b || (b = {}))
|
|
1849
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
1850
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1851
|
+
if (__getOwnPropSymbols$3)
|
|
1852
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
1853
|
+
if (__propIsEnum$3.call(b, prop))
|
|
1854
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1855
|
+
}
|
|
1856
|
+
return a;
|
|
1857
|
+
};
|
|
1845
1858
|
var __objRest$1 = (source, exclude) => {
|
|
1846
1859
|
var target = {};
|
|
1847
1860
|
for (var prop in source)
|
|
@@ -1985,7 +1998,11 @@ const applySchemaChanges = (context) => {
|
|
|
1985
1998
|
} else if (name === "index") {
|
|
1986
1999
|
dropMatchingIndexes(context, prop, i, call, drop.indexes);
|
|
1987
2000
|
} else if (name === "foreignKey") {
|
|
1988
|
-
dropMatchingForeignKey(context, prop, i, call, drop.
|
|
2001
|
+
dropMatchingForeignKey(context, prop, i, call, drop.constraints);
|
|
2002
|
+
} else if (name === "check") {
|
|
2003
|
+
dropMatchingCheck(context, prop, i, call, drop.constraints);
|
|
2004
|
+
} else if (name === "constraint") {
|
|
2005
|
+
dropMatchingConstraint(context, prop, i, call, drop.constraints);
|
|
1989
2006
|
}
|
|
1990
2007
|
} else if (ts.is.propertyAssignment(prop)) {
|
|
1991
2008
|
const name = ts.prop.getName(prop);
|
|
@@ -2111,15 +2128,19 @@ const addTableData = ({ add, changes, object, t, spaces }) => {
|
|
|
2111
2128
|
changes.add(end, ` ${code.trim()}
|
|
2112
2129
|
${spaces}`);
|
|
2113
2130
|
}
|
|
2114
|
-
|
|
2115
|
-
const
|
|
2116
|
-
|
|
2131
|
+
if (add.indexes) {
|
|
2132
|
+
for (const item of add.indexes) {
|
|
2133
|
+
const code = orchidCore.codeToString(pqb.indexToCode(item, t), spaces + " ", " ");
|
|
2134
|
+
changes.add(end, ` ${code.trim()}
|
|
2117
2135
|
${spaces}`);
|
|
2136
|
+
}
|
|
2118
2137
|
}
|
|
2119
|
-
|
|
2120
|
-
const
|
|
2121
|
-
|
|
2138
|
+
if (add.constraints) {
|
|
2139
|
+
for (const item of add.constraints) {
|
|
2140
|
+
const code = orchidCore.codeToString(pqb.constraintToCode(item, t), spaces + " ", " ");
|
|
2141
|
+
changes.add(end, ` ${code.trim()}
|
|
2122
2142
|
${spaces}`);
|
|
2143
|
+
}
|
|
2123
2144
|
}
|
|
2124
2145
|
};
|
|
2125
2146
|
const getColumnMethodArgs = (t, to, key) => {
|
|
@@ -2147,7 +2168,7 @@ const getColumnMethodArgs = (t, to, key) => {
|
|
|
2147
2168
|
return code;
|
|
2148
2169
|
};
|
|
2149
2170
|
const dropMatchingIndexes = (context, prop, i, call, items) => {
|
|
2150
|
-
if (!items.length)
|
|
2171
|
+
if (!(items == null ? void 0 : items.length))
|
|
2151
2172
|
return;
|
|
2152
2173
|
const [columnsNode, optionsNode] = call.arguments;
|
|
2153
2174
|
const columns = [];
|
|
@@ -2175,9 +2196,17 @@ const dropMatchingIndexes = (context, prop, i, call, items) => {
|
|
|
2175
2196
|
}
|
|
2176
2197
|
};
|
|
2177
2198
|
const dropMatchingForeignKey = (context, prop, i, call, items) => {
|
|
2178
|
-
if (!items.length)
|
|
2199
|
+
if (!(items == null ? void 0 : items.length))
|
|
2200
|
+
return;
|
|
2201
|
+
const existing = parseReferencesArgs(context, call.arguments);
|
|
2202
|
+
if (!existing)
|
|
2179
2203
|
return;
|
|
2180
|
-
const
|
|
2204
|
+
for (const item of items) {
|
|
2205
|
+
if (compareReferences(existing, item.references))
|
|
2206
|
+
removeProp(context, prop, i);
|
|
2207
|
+
}
|
|
2208
|
+
};
|
|
2209
|
+
const parseReferencesArgs = (context, args) => {
|
|
2181
2210
|
const columns = collectStringArrayFromCode(args[0]);
|
|
2182
2211
|
if (!columns)
|
|
2183
2212
|
return;
|
|
@@ -2194,14 +2223,83 @@ const dropMatchingForeignKey = (context, prop, i, call, items) => {
|
|
|
2194
2223
|
if (!foreignColumns)
|
|
2195
2224
|
return;
|
|
2196
2225
|
const options = ts.is.objectLiteral(args[3]) && collectObjectFromCode(args[3]) || {};
|
|
2197
|
-
|
|
2198
|
-
|
|
2226
|
+
return { columns, fnOrTable, foreignColumns, options };
|
|
2227
|
+
};
|
|
2228
|
+
const compareReferences = (existing, item) => {
|
|
2229
|
+
if (!item)
|
|
2230
|
+
return;
|
|
2231
|
+
const itemOptions = item.options ? __spreadValues$2({}, item.options) : void 0;
|
|
2232
|
+
if (itemOptions) {
|
|
2199
2233
|
delete itemOptions.dropMode;
|
|
2200
|
-
|
|
2234
|
+
}
|
|
2235
|
+
return deepCompare(existing == null ? void 0 : existing.columns, item == null ? void 0 : item.columns) && deepCompare(existing == null ? void 0 : existing.fnOrTable, item == null ? void 0 : item.fnOrTable.toString()) && deepCompare(existing == null ? void 0 : existing.foreignColumns, item == null ? void 0 : item.foreignColumns) && deepCompare(existing == null ? void 0 : existing.options, itemOptions);
|
|
2236
|
+
};
|
|
2237
|
+
const dropMatchingCheck = (context, prop, i, call, items) => {
|
|
2238
|
+
if (!(items == null ? void 0 : items.length))
|
|
2239
|
+
return;
|
|
2240
|
+
const sql = parseCheckArg(context, call.arguments[0]);
|
|
2241
|
+
for (const item of items) {
|
|
2242
|
+
const { check } = item;
|
|
2243
|
+
if (!check)
|
|
2244
|
+
continue;
|
|
2245
|
+
if (check.__raw === sql) {
|
|
2201
2246
|
removeProp(context, prop, i);
|
|
2202
2247
|
}
|
|
2203
2248
|
}
|
|
2204
2249
|
};
|
|
2250
|
+
const parseCheckArg = (context, arg) => {
|
|
2251
|
+
if (!arg || !ts.is.call(arg))
|
|
2252
|
+
return;
|
|
2253
|
+
const { expression } = arg;
|
|
2254
|
+
if (!ts.is.propertyAccess(expression) || !ts.is.identifier(expression.expression) || expression.expression.escapedText !== context.t || expression.name.escapedText !== "raw")
|
|
2255
|
+
return;
|
|
2256
|
+
const [sqlArg] = arg.arguments;
|
|
2257
|
+
if (!sqlArg || !ts.is.stringLiteral(sqlArg))
|
|
2258
|
+
return;
|
|
2259
|
+
return sqlArg.text;
|
|
2260
|
+
};
|
|
2261
|
+
const dropMatchingConstraint = (context, prop, i, call, items) => {
|
|
2262
|
+
var _a;
|
|
2263
|
+
if (!(items == null ? void 0 : items.length))
|
|
2264
|
+
return;
|
|
2265
|
+
const {
|
|
2266
|
+
arguments: [arg]
|
|
2267
|
+
} = call;
|
|
2268
|
+
if (!arg || !ts.is.objectLiteral(arg))
|
|
2269
|
+
return;
|
|
2270
|
+
const existing = {};
|
|
2271
|
+
for (const prop2 of arg.properties) {
|
|
2272
|
+
if (!ts.is.propertyAssignment(prop2))
|
|
2273
|
+
return;
|
|
2274
|
+
const name = ts.prop.getName(prop2);
|
|
2275
|
+
if (!name)
|
|
2276
|
+
return;
|
|
2277
|
+
const init = prop2.initializer;
|
|
2278
|
+
if (name === "name") {
|
|
2279
|
+
if (!ts.is.stringLiteral(init))
|
|
2280
|
+
return;
|
|
2281
|
+
existing.name = init.text;
|
|
2282
|
+
} else if (name === "references") {
|
|
2283
|
+
if (!ts.is.arrayLiteral(init))
|
|
2284
|
+
return;
|
|
2285
|
+
const refs = parseReferencesArgs(context, init.elements);
|
|
2286
|
+
if (!refs)
|
|
2287
|
+
return;
|
|
2288
|
+
existing.references = refs;
|
|
2289
|
+
} else if (name === "check") {
|
|
2290
|
+
existing.check = parseCheckArg(context, init);
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
for (const item of items) {
|
|
2294
|
+
if (existing.name !== item.name)
|
|
2295
|
+
continue;
|
|
2296
|
+
if (existing.check !== ((_a = item.check) == null ? void 0 : _a.__raw))
|
|
2297
|
+
continue;
|
|
2298
|
+
if ((existing.references || item.references) && !compareReferences(existing.references, item.references))
|
|
2299
|
+
continue;
|
|
2300
|
+
removeProp(context, prop, i);
|
|
2301
|
+
}
|
|
2302
|
+
};
|
|
2205
2303
|
const collectStringArrayFromCode = (node) => {
|
|
2206
2304
|
if (!ts.is.arrayLiteral(node))
|
|
2207
2305
|
return;
|
|
@@ -2228,8 +2326,15 @@ const collectObjectFromCode = (node) => {
|
|
|
2228
2326
|
return object;
|
|
2229
2327
|
};
|
|
2230
2328
|
const deepCompare = (a, b) => {
|
|
2231
|
-
if (typeof a !== typeof b)
|
|
2232
|
-
|
|
2329
|
+
if (typeof a !== typeof b) {
|
|
2330
|
+
if (a === void 0 && typeof b === "object") {
|
|
2331
|
+
a = orchidCore.emptyObject;
|
|
2332
|
+
} else if (typeof a === "object" && b === void 0) {
|
|
2333
|
+
b = orchidCore.emptyObject;
|
|
2334
|
+
} else {
|
|
2335
|
+
return false;
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2233
2338
|
if (a === b)
|
|
2234
2339
|
return true;
|
|
2235
2340
|
if (typeof a === "object") {
|
|
@@ -2439,6 +2544,14 @@ const appCodeUpdater = ({
|
|
|
2439
2544
|
};
|
|
2440
2545
|
const resolvePath = (basePath, filePath) => path__namespace.isAbsolute(filePath) ? filePath : path__namespace.resolve(basePath, filePath);
|
|
2441
2546
|
|
|
2547
|
+
Object.defineProperty(exports, 'OrchidOrmError', {
|
|
2548
|
+
enumerable: true,
|
|
2549
|
+
get: function () { return pqb.OrchidOrmError; }
|
|
2550
|
+
});
|
|
2551
|
+
Object.defineProperty(exports, 'OrchidOrmInternalError', {
|
|
2552
|
+
enumerable: true,
|
|
2553
|
+
get: function () { return pqb.OrchidOrmInternalError; }
|
|
2554
|
+
});
|
|
2442
2555
|
Object.defineProperty(exports, 'columnTypes', {
|
|
2443
2556
|
enumerable: true,
|
|
2444
2557
|
get: function () { return pqb.columnTypes; }
|