orchid-orm 1.9.22 → 1.9.24
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/codegen.d.ts +41 -0
- package/dist/codegen.js +1398 -0
- package/dist/codegen.js.map +1 -0
- package/dist/codegen.mjs +1377 -0
- package/dist/codegen.mjs.map +1 -0
- package/dist/index.d.ts +1 -39
- package/dist/index.js +89 -1481
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -1464
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -2
package/dist/index.js
CHANGED
|
@@ -3,29 +3,6 @@
|
|
|
3
3
|
var pqb = require('pqb');
|
|
4
4
|
var orchidCore = require('orchid-core');
|
|
5
5
|
var node_async_hooks = require('node:async_hooks');
|
|
6
|
-
var path = require('path');
|
|
7
|
-
var fs = require('fs/promises');
|
|
8
|
-
var typescript = require('typescript');
|
|
9
|
-
var inflection = require('inflection');
|
|
10
|
-
|
|
11
|
-
function _interopNamespaceDefault(e) {
|
|
12
|
-
var n = Object.create(null);
|
|
13
|
-
if (e) {
|
|
14
|
-
Object.keys(e).forEach(function (k) {
|
|
15
|
-
if (k !== 'default') {
|
|
16
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return e[k]; }
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
n.default = e;
|
|
25
|
-
return Object.freeze(n);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
29
6
|
|
|
30
7
|
const createBaseTable = ({
|
|
31
8
|
columnTypes,
|
|
@@ -356,25 +333,25 @@ const hasRelationHandleUpdate = (q, ctx, set, key, primaryKey, nestedUpdate) =>
|
|
|
356
333
|
});
|
|
357
334
|
};
|
|
358
335
|
|
|
359
|
-
var __defProp$
|
|
360
|
-
var __defProps$
|
|
361
|
-
var __getOwnPropDescs$
|
|
362
|
-
var __getOwnPropSymbols$
|
|
363
|
-
var __hasOwnProp$
|
|
364
|
-
var __propIsEnum$
|
|
365
|
-
var __defNormalProp$
|
|
366
|
-
var __spreadValues$
|
|
336
|
+
var __defProp$4 = Object.defineProperty;
|
|
337
|
+
var __defProps$3 = Object.defineProperties;
|
|
338
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
339
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
340
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
341
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
342
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
343
|
+
var __spreadValues$4 = (a, b) => {
|
|
367
344
|
for (var prop in b || (b = {}))
|
|
368
|
-
if (__hasOwnProp$
|
|
369
|
-
__defNormalProp$
|
|
370
|
-
if (__getOwnPropSymbols$
|
|
371
|
-
for (var prop of __getOwnPropSymbols$
|
|
372
|
-
if (__propIsEnum$
|
|
373
|
-
__defNormalProp$
|
|
345
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
346
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
347
|
+
if (__getOwnPropSymbols$4)
|
|
348
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
349
|
+
if (__propIsEnum$4.call(b, prop))
|
|
350
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
374
351
|
}
|
|
375
352
|
return a;
|
|
376
353
|
};
|
|
377
|
-
var __spreadProps$
|
|
354
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
378
355
|
class HasOneVirtualColumn extends pqb.VirtualColumn {
|
|
379
356
|
constructor(key, state) {
|
|
380
357
|
super();
|
|
@@ -507,7 +484,7 @@ const nestedInsert$2 = ({ query, primaryKey, foreignKey }) => {
|
|
|
507
484
|
);
|
|
508
485
|
if (create.length) {
|
|
509
486
|
await t._count()._createMany(
|
|
510
|
-
create.map(([selfData, item]) => __spreadValues$
|
|
487
|
+
create.map(([selfData, item]) => __spreadValues$4({
|
|
511
488
|
[foreignKey]: selfData[primaryKey]
|
|
512
489
|
}, "create" in item ? item.create : item.connectOrCreate.create))
|
|
513
490
|
);
|
|
@@ -528,7 +505,7 @@ const nestedUpdate$2 = ({ query, primaryKey, foreignKey }) => {
|
|
|
528
505
|
if (params.create || params.disconnect || params.set) {
|
|
529
506
|
await currentRelationsQuery._update({ [foreignKey]: null });
|
|
530
507
|
if (params.create) {
|
|
531
|
-
await t._count()._create(__spreadProps$
|
|
508
|
+
await t._count()._create(__spreadProps$3(__spreadValues$4({}, params.create), {
|
|
532
509
|
[foreignKey]: data[0][primaryKey]
|
|
533
510
|
}));
|
|
534
511
|
}
|
|
@@ -545,7 +522,7 @@ const nestedUpdate$2 = ({ query, primaryKey, foreignKey }) => {
|
|
|
545
522
|
if (updatedIds.length < ids.length) {
|
|
546
523
|
const data2 = typeof create === "function" ? create() : create;
|
|
547
524
|
await t.createMany(
|
|
548
|
-
ids.filter((id) => !updatedIds.includes(id)).map((id) => __spreadProps$
|
|
525
|
+
ids.filter((id) => !updatedIds.includes(id)).map((id) => __spreadProps$3(__spreadValues$4({}, data2), {
|
|
549
526
|
[foreignKey]: id
|
|
550
527
|
}))
|
|
551
528
|
);
|
|
@@ -554,25 +531,25 @@ const nestedUpdate$2 = ({ query, primaryKey, foreignKey }) => {
|
|
|
554
531
|
};
|
|
555
532
|
};
|
|
556
533
|
|
|
557
|
-
var __defProp$
|
|
558
|
-
var __defProps$
|
|
559
|
-
var __getOwnPropDescs$
|
|
560
|
-
var __getOwnPropSymbols$
|
|
561
|
-
var __hasOwnProp$
|
|
562
|
-
var __propIsEnum$
|
|
563
|
-
var __defNormalProp$
|
|
564
|
-
var __spreadValues$
|
|
534
|
+
var __defProp$3 = Object.defineProperty;
|
|
535
|
+
var __defProps$2 = Object.defineProperties;
|
|
536
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
537
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
538
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
539
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
540
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
541
|
+
var __spreadValues$3 = (a, b) => {
|
|
565
542
|
for (var prop in b || (b = {}))
|
|
566
|
-
if (__hasOwnProp$
|
|
567
|
-
__defNormalProp$
|
|
568
|
-
if (__getOwnPropSymbols$
|
|
569
|
-
for (var prop of __getOwnPropSymbols$
|
|
570
|
-
if (__propIsEnum$
|
|
571
|
-
__defNormalProp$
|
|
543
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
544
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
545
|
+
if (__getOwnPropSymbols$3)
|
|
546
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
547
|
+
if (__propIsEnum$3.call(b, prop))
|
|
548
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
572
549
|
}
|
|
573
550
|
return a;
|
|
574
551
|
};
|
|
575
|
-
var __spreadProps$
|
|
552
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
576
553
|
class HasManyVirtualColumn extends pqb.VirtualColumn {
|
|
577
554
|
constructor(key, state) {
|
|
578
555
|
super();
|
|
@@ -738,10 +715,10 @@ const nestedInsert$1 = ({ query, primaryKey, foreignKey }) => {
|
|
|
738
715
|
await t._createMany(
|
|
739
716
|
create.flatMap(([selfData, { create: create2 = [], connectOrCreate: connectOrCreate2 = [] }]) => {
|
|
740
717
|
return [
|
|
741
|
-
...create2.map((item) => __spreadValues$
|
|
718
|
+
...create2.map((item) => __spreadValues$3({
|
|
742
719
|
[foreignKey]: selfData[primaryKey]
|
|
743
720
|
}, item)),
|
|
744
|
-
...connectOrCreate2.filter(() => connected[connectedI++] === 0).map((item) => __spreadValues$
|
|
721
|
+
...connectOrCreate2.filter(() => connected[connectedI++] === 0).map((item) => __spreadValues$3({
|
|
745
722
|
[foreignKey]: selfData[primaryKey]
|
|
746
723
|
}, item.create))
|
|
747
724
|
];
|
|
@@ -760,7 +737,7 @@ const nestedUpdate$1 = ({ query, primaryKey, foreignKey }) => {
|
|
|
760
737
|
const t = query.clone();
|
|
761
738
|
if (params.create) {
|
|
762
739
|
await t._count()._createMany(
|
|
763
|
-
params.create.map((create) => __spreadProps$
|
|
740
|
+
params.create.map((create) => __spreadProps$2(__spreadValues$3({}, create), {
|
|
764
741
|
[foreignKey]: data[0][primaryKey]
|
|
765
742
|
}))
|
|
766
743
|
);
|
|
@@ -803,25 +780,25 @@ const nestedUpdate$1 = ({ query, primaryKey, foreignKey }) => {
|
|
|
803
780
|
};
|
|
804
781
|
};
|
|
805
782
|
|
|
806
|
-
var __defProp$
|
|
807
|
-
var __defProps$
|
|
808
|
-
var __getOwnPropDescs$
|
|
809
|
-
var __getOwnPropSymbols$
|
|
810
|
-
var __hasOwnProp$
|
|
811
|
-
var __propIsEnum$
|
|
812
|
-
var __defNormalProp$
|
|
813
|
-
var __spreadValues$
|
|
783
|
+
var __defProp$2 = Object.defineProperty;
|
|
784
|
+
var __defProps$1 = Object.defineProperties;
|
|
785
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
786
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
787
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
788
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
789
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
790
|
+
var __spreadValues$2 = (a, b) => {
|
|
814
791
|
for (var prop in b || (b = {}))
|
|
815
|
-
if (__hasOwnProp$
|
|
816
|
-
__defNormalProp$
|
|
817
|
-
if (__getOwnPropSymbols$
|
|
818
|
-
for (var prop of __getOwnPropSymbols$
|
|
819
|
-
if (__propIsEnum$
|
|
820
|
-
__defNormalProp$
|
|
792
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
793
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
794
|
+
if (__getOwnPropSymbols$2)
|
|
795
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
796
|
+
if (__propIsEnum$2.call(b, prop))
|
|
797
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
821
798
|
}
|
|
822
799
|
return a;
|
|
823
800
|
};
|
|
824
|
-
var __spreadProps$
|
|
801
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
825
802
|
class HasAndBelongsToManyVirtualColumn extends pqb.VirtualColumn {
|
|
826
803
|
constructor(key, state) {
|
|
827
804
|
super();
|
|
@@ -856,7 +833,7 @@ const removeColumnName = (column) => {
|
|
|
856
833
|
if (!column.data.name)
|
|
857
834
|
return column;
|
|
858
835
|
const cloned = Object.create(column);
|
|
859
|
-
cloned.data = __spreadProps$
|
|
836
|
+
cloned.data = __spreadProps$1(__spreadValues$2({}, column.data), { name: void 0 });
|
|
860
837
|
return cloned;
|
|
861
838
|
};
|
|
862
839
|
const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query) => {
|
|
@@ -877,7 +854,7 @@ const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query)
|
|
|
877
854
|
[fk]: removeColumnName(table.shape[pk]),
|
|
878
855
|
[afk]: removeColumnName(query.shape[apk])
|
|
879
856
|
};
|
|
880
|
-
baseQuery.query = __spreadProps$
|
|
857
|
+
baseQuery.query = __spreadProps$1(__spreadValues$2({}, baseQuery.query), {
|
|
881
858
|
shape: baseQuery.shape
|
|
882
859
|
});
|
|
883
860
|
const subQuery = Object.create(baseQuery);
|
|
@@ -910,7 +887,7 @@ const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query)
|
|
|
910
887
|
subQuery,
|
|
911
888
|
(q) => q._on(associationForeignKeyFull, `${pqb.getQueryAs(toQuery)}.${apk}`)._on(foreignKeyFull, `${pqb.getQueryAs(fromQuery)}.${pk}`)
|
|
912
889
|
);
|
|
913
|
-
join.query.joinedShapes = __spreadProps$
|
|
890
|
+
join.query.joinedShapes = __spreadProps$1(__spreadValues$2({}, join.query.joinedShapes), {
|
|
914
891
|
[fromQuery.query.as || fromQuery.table]: fromQuery.query.shape
|
|
915
892
|
});
|
|
916
893
|
return join;
|
|
@@ -1326,33 +1303,33 @@ function transaction(fnOrOptions, fn) {
|
|
|
1326
1303
|
);
|
|
1327
1304
|
}
|
|
1328
1305
|
|
|
1329
|
-
var __defProp$
|
|
1330
|
-
var __defProps
|
|
1331
|
-
var __getOwnPropDescs
|
|
1332
|
-
var __getOwnPropSymbols$
|
|
1333
|
-
var __hasOwnProp$
|
|
1334
|
-
var __propIsEnum$
|
|
1335
|
-
var __defNormalProp$
|
|
1336
|
-
var __spreadValues$
|
|
1306
|
+
var __defProp$1 = Object.defineProperty;
|
|
1307
|
+
var __defProps = Object.defineProperties;
|
|
1308
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
1309
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
1310
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
1311
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
1312
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1313
|
+
var __spreadValues$1 = (a, b) => {
|
|
1337
1314
|
for (var prop in b || (b = {}))
|
|
1338
|
-
if (__hasOwnProp$
|
|
1339
|
-
__defNormalProp$
|
|
1340
|
-
if (__getOwnPropSymbols$
|
|
1341
|
-
for (var prop of __getOwnPropSymbols$
|
|
1342
|
-
if (__propIsEnum$
|
|
1343
|
-
__defNormalProp$
|
|
1315
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
1316
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
1317
|
+
if (__getOwnPropSymbols$1)
|
|
1318
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
1319
|
+
if (__propIsEnum$1.call(b, prop))
|
|
1320
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
1344
1321
|
}
|
|
1345
1322
|
return a;
|
|
1346
1323
|
};
|
|
1347
|
-
var __spreadProps
|
|
1348
|
-
var __objRest
|
|
1324
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1325
|
+
var __objRest = (source, exclude) => {
|
|
1349
1326
|
var target = {};
|
|
1350
1327
|
for (var prop in source)
|
|
1351
|
-
if (__hasOwnProp$
|
|
1328
|
+
if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1352
1329
|
target[prop] = source[prop];
|
|
1353
|
-
if (source != null && __getOwnPropSymbols$
|
|
1354
|
-
for (var prop of __getOwnPropSymbols$
|
|
1355
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
1330
|
+
if (source != null && __getOwnPropSymbols$1)
|
|
1331
|
+
for (var prop of __getOwnPropSymbols$1(source)) {
|
|
1332
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
|
|
1356
1333
|
target[prop] = source[prop];
|
|
1357
1334
|
}
|
|
1358
1335
|
return target;
|
|
@@ -1363,7 +1340,7 @@ const orchidORM = (_a, tables) => {
|
|
|
1363
1340
|
logger,
|
|
1364
1341
|
autoPreparedStatements,
|
|
1365
1342
|
noPrimaryKey = "error"
|
|
1366
|
-
} = _b, options = __objRest
|
|
1343
|
+
} = _b, options = __objRest(_b, [
|
|
1367
1344
|
"log",
|
|
1368
1345
|
"logger",
|
|
1369
1346
|
"autoPreparedStatements",
|
|
@@ -1410,7 +1387,7 @@ const orchidORM = (_a, tables) => {
|
|
|
1410
1387
|
}
|
|
1411
1388
|
const table = new tables[key]();
|
|
1412
1389
|
tableInstances[key] = table;
|
|
1413
|
-
const options2 = __spreadProps
|
|
1390
|
+
const options2 = __spreadProps(__spreadValues$1({}, commonOptions), {
|
|
1414
1391
|
schema: table.schema
|
|
1415
1392
|
});
|
|
1416
1393
|
if (table.noPrimaryKey)
|
|
@@ -1435,24 +1412,24 @@ const orchidORM = (_a, tables) => {
|
|
|
1435
1412
|
return result;
|
|
1436
1413
|
};
|
|
1437
1414
|
|
|
1438
|
-
var __defProp
|
|
1439
|
-
var __getOwnPropSymbols
|
|
1440
|
-
var __hasOwnProp
|
|
1441
|
-
var __propIsEnum
|
|
1442
|
-
var __defNormalProp
|
|
1443
|
-
var __spreadValues
|
|
1415
|
+
var __defProp = Object.defineProperty;
|
|
1416
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1417
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1418
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
1419
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1420
|
+
var __spreadValues = (a, b) => {
|
|
1444
1421
|
for (var prop in b || (b = {}))
|
|
1445
|
-
if (__hasOwnProp
|
|
1446
|
-
__defNormalProp
|
|
1447
|
-
if (__getOwnPropSymbols
|
|
1448
|
-
for (var prop of __getOwnPropSymbols
|
|
1449
|
-
if (__propIsEnum
|
|
1450
|
-
__defNormalProp
|
|
1422
|
+
if (__hasOwnProp.call(b, prop))
|
|
1423
|
+
__defNormalProp(a, prop, b[prop]);
|
|
1424
|
+
if (__getOwnPropSymbols)
|
|
1425
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
1426
|
+
if (__propIsEnum.call(b, prop))
|
|
1427
|
+
__defNormalProp(a, prop, b[prop]);
|
|
1451
1428
|
}
|
|
1452
1429
|
return a;
|
|
1453
1430
|
};
|
|
1454
1431
|
const createRepo = (table, methods) => {
|
|
1455
|
-
const queryMethods = __spreadValues
|
|
1432
|
+
const queryMethods = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, methods.queryMethods), methods.queryOneMethods), methods.queryWithWhereMethods), methods.queryOneWithWhereMethods);
|
|
1456
1433
|
const plainMethods = methods.methods;
|
|
1457
1434
|
const repo = (q2) => {
|
|
1458
1435
|
const proto = Object.create(q2.baseQuery);
|
|
@@ -1478,1373 +1455,6 @@ const createRepo = (table, methods) => {
|
|
|
1478
1455
|
});
|
|
1479
1456
|
};
|
|
1480
1457
|
|
|
1481
|
-
class FileChanges {
|
|
1482
|
-
constructor(content) {
|
|
1483
|
-
this.content = content;
|
|
1484
|
-
this.ranges = [];
|
|
1485
|
-
}
|
|
1486
|
-
add(at, text, end = at) {
|
|
1487
|
-
if (this.ranges.length === 0) {
|
|
1488
|
-
this.ranges.push([0, at], text, [end, this.content.length]);
|
|
1489
|
-
} else {
|
|
1490
|
-
const last = this.ranges[this.ranges.length - 1];
|
|
1491
|
-
last[1] = at;
|
|
1492
|
-
this.ranges.push(text, [end, this.content.length]);
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
replace(from, to, text) {
|
|
1496
|
-
this.add(from, text, to);
|
|
1497
|
-
}
|
|
1498
|
-
remove(from, to) {
|
|
1499
|
-
if (this.ranges.length === 0) {
|
|
1500
|
-
this.ranges.push([0, from], [to, this.content.length]);
|
|
1501
|
-
} else {
|
|
1502
|
-
const last = this.ranges[this.ranges.length - 1];
|
|
1503
|
-
last[1] = from;
|
|
1504
|
-
this.ranges.push([to, this.content.length]);
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
apply() {
|
|
1508
|
-
return this.ranges.length ? this.ranges.map(
|
|
1509
|
-
(item) => typeof item === "string" ? item : this.content.slice(item[0], item[1])
|
|
1510
|
-
).join("") : this.content;
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
const { createSourceFile, ScriptTarget, SyntaxKind } = typescript;
|
|
1515
|
-
const iterate = (kind) => {
|
|
1516
|
-
return function* (statements) {
|
|
1517
|
-
for (const node of statements) {
|
|
1518
|
-
if (node.kind === kind) {
|
|
1519
|
-
yield node;
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
};
|
|
1523
|
-
};
|
|
1524
|
-
const isNode = (kind) => {
|
|
1525
|
-
return (node) => {
|
|
1526
|
-
return (node == null ? void 0 : node.kind) === kind;
|
|
1527
|
-
};
|
|
1528
|
-
};
|
|
1529
|
-
const ts = {
|
|
1530
|
-
getStatements(content) {
|
|
1531
|
-
const { statements } = createSourceFile(
|
|
1532
|
-
"file.ts",
|
|
1533
|
-
content,
|
|
1534
|
-
ScriptTarget.Latest,
|
|
1535
|
-
true
|
|
1536
|
-
);
|
|
1537
|
-
return statements;
|
|
1538
|
-
},
|
|
1539
|
-
is: {
|
|
1540
|
-
call: isNode(SyntaxKind.CallExpression),
|
|
1541
|
-
objectLiteral: isNode(
|
|
1542
|
-
SyntaxKind.ObjectLiteralExpression
|
|
1543
|
-
),
|
|
1544
|
-
propertyAssignment: isNode(
|
|
1545
|
-
SyntaxKind.PropertyAssignment
|
|
1546
|
-
),
|
|
1547
|
-
shorthandPropertyAssignment: isNode(
|
|
1548
|
-
SyntaxKind.ShorthandPropertyAssignment
|
|
1549
|
-
),
|
|
1550
|
-
identifier: isNode(SyntaxKind.Identifier),
|
|
1551
|
-
stringLiteral: isNode(SyntaxKind.StringLiteral),
|
|
1552
|
-
arrayLiteral: isNode(
|
|
1553
|
-
SyntaxKind.ArrayLiteralExpression
|
|
1554
|
-
),
|
|
1555
|
-
numericLiteral: isNode(SyntaxKind.NumericLiteral),
|
|
1556
|
-
computedPropertyName: isNode(
|
|
1557
|
-
SyntaxKind.ComputedPropertyName
|
|
1558
|
-
),
|
|
1559
|
-
privateIdentifier: isNode(SyntaxKind.PrivateIdentifier),
|
|
1560
|
-
this: isNode(SyntaxKind.ThisKeyword),
|
|
1561
|
-
propertyAccess: isNode(
|
|
1562
|
-
SyntaxKind.PropertyAccessExpression
|
|
1563
|
-
),
|
|
1564
|
-
arrowFunction: isNode(SyntaxKind.ArrowFunction),
|
|
1565
|
-
parenthesizedExpression: isNode(
|
|
1566
|
-
SyntaxKind.ParenthesizedExpression
|
|
1567
|
-
),
|
|
1568
|
-
spreadAssignment: isNode(SyntaxKind.SpreadAssignment)
|
|
1569
|
-
},
|
|
1570
|
-
import: {
|
|
1571
|
-
iterate: iterate(SyntaxKind.ImportDeclaration),
|
|
1572
|
-
*iterateWithSource(statements, path) {
|
|
1573
|
-
for (const node of ts.import.iterate(statements)) {
|
|
1574
|
-
if (ts.import.getSource(node) !== path)
|
|
1575
|
-
continue;
|
|
1576
|
-
yield node;
|
|
1577
|
-
}
|
|
1578
|
-
},
|
|
1579
|
-
getSource(node) {
|
|
1580
|
-
return node.moduleSpecifier.getText().slice(1, -1);
|
|
1581
|
-
},
|
|
1582
|
-
getEndPos(statements) {
|
|
1583
|
-
let end = 0;
|
|
1584
|
-
for (const node of ts.import.iterate(statements)) {
|
|
1585
|
-
end = node.end;
|
|
1586
|
-
}
|
|
1587
|
-
return end;
|
|
1588
|
-
},
|
|
1589
|
-
getStatementsImportedName(statements, path, key) {
|
|
1590
|
-
for (const node of ts.import.iterateWithSource(statements, path)) {
|
|
1591
|
-
const name = ts.import.getImportName(node, key);
|
|
1592
|
-
if (name)
|
|
1593
|
-
return name;
|
|
1594
|
-
}
|
|
1595
|
-
return;
|
|
1596
|
-
},
|
|
1597
|
-
getImportName(node, key) {
|
|
1598
|
-
var _a, _b;
|
|
1599
|
-
if (!node.importClause)
|
|
1600
|
-
return;
|
|
1601
|
-
const elements = (_a = node.importClause.namedBindings) == null ? void 0 : _a.elements;
|
|
1602
|
-
if (!elements)
|
|
1603
|
-
return;
|
|
1604
|
-
for (const element of elements) {
|
|
1605
|
-
if (((_b = element.propertyName) == null ? void 0 : _b.escapedText) === key || element.name.escapedText === key) {
|
|
1606
|
-
return element.name.escapedText.toString();
|
|
1607
|
-
}
|
|
1608
|
-
}
|
|
1609
|
-
return;
|
|
1610
|
-
}
|
|
1611
|
-
},
|
|
1612
|
-
variable: {
|
|
1613
|
-
iterate: iterate(SyntaxKind.VariableStatement),
|
|
1614
|
-
*iterateDeclarations(statements) {
|
|
1615
|
-
for (const node of ts.variable.iterate(statements)) {
|
|
1616
|
-
for (const dec of node.declarationList.declarations) {
|
|
1617
|
-
yield dec;
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
},
|
|
1622
|
-
class: {
|
|
1623
|
-
iterate: iterate(SyntaxKind.ClassDeclaration)
|
|
1624
|
-
},
|
|
1625
|
-
prop: {
|
|
1626
|
-
getName({ name }) {
|
|
1627
|
-
if (ts.is.identifier(name)) {
|
|
1628
|
-
return name.escapedText;
|
|
1629
|
-
} else {
|
|
1630
|
-
return name == null ? void 0 : name.getText();
|
|
1631
|
-
}
|
|
1632
|
-
},
|
|
1633
|
-
getValue(prop) {
|
|
1634
|
-
if (ts.is.propertyAssignment(prop)) {
|
|
1635
|
-
return prop.initializer.getText();
|
|
1636
|
-
} else if (ts.is.shorthandPropertyAssignment(prop)) {
|
|
1637
|
-
return prop.name.escapedText.toString();
|
|
1638
|
-
} else {
|
|
1639
|
-
return;
|
|
1640
|
-
}
|
|
1641
|
-
}
|
|
1642
|
-
},
|
|
1643
|
-
spaces: {
|
|
1644
|
-
getAtLine(content, pos) {
|
|
1645
|
-
var _a;
|
|
1646
|
-
const lines = content.slice(0, pos).split("\n");
|
|
1647
|
-
const last = lines[lines.length - 1];
|
|
1648
|
-
return ((_a = last.match(/^\s+/)) == null ? void 0 : _a[0]) || "";
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
};
|
|
1652
|
-
|
|
1653
|
-
const libraryName = "orchid-orm";
|
|
1654
|
-
const importKey = "orchidORM";
|
|
1655
|
-
const newFile = (options) => `import { orchidORM } from 'orchid-orm';
|
|
1656
|
-
|
|
1657
|
-
export const db = orchidORM(
|
|
1658
|
-
{
|
|
1659
|
-
${optionsToString(options)}
|
|
1660
|
-
},
|
|
1661
|
-
{
|
|
1662
|
-
}
|
|
1663
|
-
);
|
|
1664
|
-
`;
|
|
1665
|
-
const optionsToString = (options) => {
|
|
1666
|
-
const lines = [];
|
|
1667
|
-
for (const key in options) {
|
|
1668
|
-
const value = options[key];
|
|
1669
|
-
if (typeof value !== "object" && typeof value !== "function") {
|
|
1670
|
-
lines.push(
|
|
1671
|
-
`${key}: ${typeof value === "string" ? orchidCore.singleQuote(value) : value},`
|
|
1672
|
-
);
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
return lines.join("\n ");
|
|
1676
|
-
};
|
|
1677
|
-
const updateMainFile = async (filePath, tablePath, ast, options, logger) => {
|
|
1678
|
-
const result = await fs.readFile(filePath, "utf-8").then(
|
|
1679
|
-
(content2) => ({ error: void 0, content: content2 }),
|
|
1680
|
-
(error) => {
|
|
1681
|
-
return { error, content: void 0 };
|
|
1682
|
-
}
|
|
1683
|
-
);
|
|
1684
|
-
if (result.error && result.error.code !== "ENOENT")
|
|
1685
|
-
throw result.error;
|
|
1686
|
-
const content = result.content || newFile(options);
|
|
1687
|
-
const statements = ts.getStatements(content);
|
|
1688
|
-
const importName = ts.import.getStatementsImportedName(
|
|
1689
|
-
statements,
|
|
1690
|
-
libraryName,
|
|
1691
|
-
importKey
|
|
1692
|
-
);
|
|
1693
|
-
if (!importName) {
|
|
1694
|
-
throw new AppCodeUpdaterError(
|
|
1695
|
-
`Main file does not contain import of orchid-orm`
|
|
1696
|
-
);
|
|
1697
|
-
}
|
|
1698
|
-
const object = getTablesListObject(importName, statements);
|
|
1699
|
-
if (!object) {
|
|
1700
|
-
throw new Error("List of tables is not found in main file");
|
|
1701
|
-
}
|
|
1702
|
-
const spaces = ts.spaces.getAtLine(content, object.end);
|
|
1703
|
-
const context = {
|
|
1704
|
-
filePath,
|
|
1705
|
-
tablePath,
|
|
1706
|
-
statements,
|
|
1707
|
-
object,
|
|
1708
|
-
content,
|
|
1709
|
-
spaces
|
|
1710
|
-
};
|
|
1711
|
-
let write;
|
|
1712
|
-
if (ast.type === "table") {
|
|
1713
|
-
if (ast.action === "create") {
|
|
1714
|
-
write = createTable$1(context, ast);
|
|
1715
|
-
} else {
|
|
1716
|
-
write = dropTable(context, ast);
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
if (write) {
|
|
1720
|
-
if (result.error) {
|
|
1721
|
-
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
1722
|
-
}
|
|
1723
|
-
await fs.writeFile(filePath, write);
|
|
1724
|
-
logger == null ? void 0 : logger.log(
|
|
1725
|
-
`${result.content ? "Updated" : "Created"} ${orchidCore.pathToLog(filePath)}`
|
|
1726
|
-
);
|
|
1727
|
-
}
|
|
1728
|
-
};
|
|
1729
|
-
const createTable$1 = ({ filePath, tablePath, statements, object, content, spaces }, ast) => {
|
|
1730
|
-
const key = orchidCore.toCamelCase(ast.name);
|
|
1731
|
-
const value = `${orchidCore.toPascalCase(ast.name)}Table`;
|
|
1732
|
-
const changes = new FileChanges(content);
|
|
1733
|
-
const importPath = orchidCore.getImportPath(filePath, tablePath(orchidCore.toCamelCase(ast.name)));
|
|
1734
|
-
const existing = Array.from(
|
|
1735
|
-
ts.import.iterateWithSource(statements, importPath)
|
|
1736
|
-
);
|
|
1737
|
-
if (existing.length)
|
|
1738
|
-
return;
|
|
1739
|
-
for (const prop of object.properties) {
|
|
1740
|
-
if (key === ts.prop.getName(prop)) {
|
|
1741
|
-
return;
|
|
1742
|
-
}
|
|
1743
|
-
}
|
|
1744
|
-
const importPos = ts.import.getEndPos(statements);
|
|
1745
|
-
changes.add(
|
|
1746
|
-
importPos,
|
|
1747
|
-
`${importPos === 0 ? "" : "\n"}import { ${value} } from '${importPath}';`
|
|
1748
|
-
);
|
|
1749
|
-
let insert = `
|
|
1750
|
-
${spaces} ${key}: ${value},`;
|
|
1751
|
-
if (object.properties.length && !object.properties.hasTrailingComma) {
|
|
1752
|
-
insert = `,${insert}`;
|
|
1753
|
-
}
|
|
1754
|
-
if (!content.slice(object.properties.end, object.end).includes("\n")) {
|
|
1755
|
-
insert += `
|
|
1756
|
-
${spaces}`;
|
|
1757
|
-
}
|
|
1758
|
-
changes.add(object.properties.end, insert);
|
|
1759
|
-
return changes.apply();
|
|
1760
|
-
};
|
|
1761
|
-
const dropTable = ({ filePath, tablePath, statements, object, content }, ast) => {
|
|
1762
|
-
const changes = new FileChanges(content);
|
|
1763
|
-
const importPath = orchidCore.getImportPath(filePath, tablePath(orchidCore.toCamelCase(ast.name)));
|
|
1764
|
-
const tableClassName = `${orchidCore.toPascalCase(ast.name)}Table`;
|
|
1765
|
-
const importNames = [];
|
|
1766
|
-
for (const node of ts.import.iterateWithSource(statements, importPath)) {
|
|
1767
|
-
changes.remove(node.pos, node.end);
|
|
1768
|
-
const name = ts.import.getImportName(node, tableClassName);
|
|
1769
|
-
if (name && !importNames.includes(name)) {
|
|
1770
|
-
importNames.push(name);
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
for (const prop of object.properties) {
|
|
1774
|
-
const name = ts.prop.getValue(prop);
|
|
1775
|
-
if (!name || !importNames.includes(name))
|
|
1776
|
-
continue;
|
|
1777
|
-
let { end } = prop;
|
|
1778
|
-
if (content[end] === ",")
|
|
1779
|
-
end++;
|
|
1780
|
-
changes.remove(prop.pos, end);
|
|
1781
|
-
}
|
|
1782
|
-
return changes.apply();
|
|
1783
|
-
};
|
|
1784
|
-
const getTablesListObject = (importName, statements) => {
|
|
1785
|
-
for (const node of ts.variable.iterateDeclarations(statements)) {
|
|
1786
|
-
const call = node.initializer;
|
|
1787
|
-
if (!ts.is.call(call))
|
|
1788
|
-
continue;
|
|
1789
|
-
if (call.expression.getText() !== importName)
|
|
1790
|
-
continue;
|
|
1791
|
-
if (call.arguments.length !== 2) {
|
|
1792
|
-
throw new Error(
|
|
1793
|
-
"Invalid number of arguments when initializing orchid orm"
|
|
1794
|
-
);
|
|
1795
|
-
}
|
|
1796
|
-
const object = call.arguments[1];
|
|
1797
|
-
if (!ts.is.objectLiteral(object)) {
|
|
1798
|
-
throw new Error("Second argument of orchidORM must be an object literal");
|
|
1799
|
-
}
|
|
1800
|
-
return object;
|
|
1801
|
-
}
|
|
1802
|
-
return;
|
|
1803
|
-
};
|
|
1804
|
-
|
|
1805
|
-
const handleForeignKey = async ({
|
|
1806
|
-
getTable,
|
|
1807
|
-
relations,
|
|
1808
|
-
tableName,
|
|
1809
|
-
columns,
|
|
1810
|
-
foreignTableName,
|
|
1811
|
-
foreignColumns,
|
|
1812
|
-
skipBelongsTo
|
|
1813
|
-
}) => {
|
|
1814
|
-
var _a, _b;
|
|
1815
|
-
const table = await getTable(tableName);
|
|
1816
|
-
if (!table)
|
|
1817
|
-
return;
|
|
1818
|
-
const foreignTable = await getTable(foreignTableName);
|
|
1819
|
-
if (!foreignTable)
|
|
1820
|
-
return;
|
|
1821
|
-
if (!skipBelongsTo) {
|
|
1822
|
-
(_a = relations[tableName]) != null ? _a : relations[tableName] = {
|
|
1823
|
-
path: table.path,
|
|
1824
|
-
relations: []
|
|
1825
|
-
};
|
|
1826
|
-
relations[tableName].relations.push({
|
|
1827
|
-
kind: "belongsTo",
|
|
1828
|
-
columns,
|
|
1829
|
-
className: foreignTable.name,
|
|
1830
|
-
path: foreignTable.path,
|
|
1831
|
-
foreignColumns
|
|
1832
|
-
});
|
|
1833
|
-
}
|
|
1834
|
-
(_b = relations[foreignTableName]) != null ? _b : relations[foreignTableName] = {
|
|
1835
|
-
path: foreignTable.path,
|
|
1836
|
-
relations: []
|
|
1837
|
-
};
|
|
1838
|
-
relations[foreignTableName].relations.push({
|
|
1839
|
-
kind: "hasMany",
|
|
1840
|
-
columns: foreignColumns,
|
|
1841
|
-
className: table.name,
|
|
1842
|
-
path: table.path,
|
|
1843
|
-
foreignColumns: columns
|
|
1844
|
-
});
|
|
1845
|
-
};
|
|
1846
|
-
|
|
1847
|
-
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
1848
|
-
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
1849
|
-
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
1850
|
-
var __objRest$2 = (source, exclude) => {
|
|
1851
|
-
var target = {};
|
|
1852
|
-
for (var prop in source)
|
|
1853
|
-
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1854
|
-
target[prop] = source[prop];
|
|
1855
|
-
if (source != null && __getOwnPropSymbols$4)
|
|
1856
|
-
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
1857
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
1858
|
-
target[prop] = source[prop];
|
|
1859
|
-
}
|
|
1860
|
-
return target;
|
|
1861
|
-
};
|
|
1862
|
-
const createTable = async (_a) => {
|
|
1863
|
-
var _b = _a, {
|
|
1864
|
-
ast,
|
|
1865
|
-
logger,
|
|
1866
|
-
getTable,
|
|
1867
|
-
relations,
|
|
1868
|
-
tables
|
|
1869
|
-
} = _b, params = __objRest$2(_b, [
|
|
1870
|
-
"ast",
|
|
1871
|
-
"logger",
|
|
1872
|
-
"getTable",
|
|
1873
|
-
"relations",
|
|
1874
|
-
"tables"
|
|
1875
|
-
]);
|
|
1876
|
-
const key = orchidCore.toCamelCase(ast.name);
|
|
1877
|
-
const tablePath = params.tablePath(key);
|
|
1878
|
-
const baseTablePath = orchidCore.getImportPath(tablePath, params.baseTable.filePath);
|
|
1879
|
-
const className = `${orchidCore.toPascalCase(ast.name)}Table`;
|
|
1880
|
-
tables[ast.name] = {
|
|
1881
|
-
key,
|
|
1882
|
-
name: className,
|
|
1883
|
-
path: tablePath
|
|
1884
|
-
};
|
|
1885
|
-
const imports = {
|
|
1886
|
-
[baseTablePath]: params.baseTable.name
|
|
1887
|
-
};
|
|
1888
|
-
const props = [];
|
|
1889
|
-
if (ast.schema) {
|
|
1890
|
-
props.push(`schema = ${orchidCore.singleQuote(ast.schema)};`);
|
|
1891
|
-
}
|
|
1892
|
-
props.push(`readonly table = ${orchidCore.singleQuote(ast.name)};`);
|
|
1893
|
-
if (ast.noPrimaryKey === "ignore") {
|
|
1894
|
-
props.push("noPrimaryKey = true;");
|
|
1895
|
-
}
|
|
1896
|
-
props.push(
|
|
1897
|
-
"columns = this.setColumns((t) => ({",
|
|
1898
|
-
pqb.columnsShapeToCode(ast.shape, ast, "t"),
|
|
1899
|
-
"}));"
|
|
1900
|
-
);
|
|
1901
|
-
const relCode = await getRelations(
|
|
1902
|
-
ast,
|
|
1903
|
-
getTable,
|
|
1904
|
-
tablePath,
|
|
1905
|
-
imports,
|
|
1906
|
-
relations,
|
|
1907
|
-
ast.name
|
|
1908
|
-
);
|
|
1909
|
-
if (relCode) {
|
|
1910
|
-
props.push("", ...relCode);
|
|
1911
|
-
}
|
|
1912
|
-
const code = [
|
|
1913
|
-
...Object.entries(imports).map(
|
|
1914
|
-
([from, name]) => `import { ${name} } from '${from}';`
|
|
1915
|
-
),
|
|
1916
|
-
"",
|
|
1917
|
-
`export class ${className} extends ${params.baseTable.name} {`,
|
|
1918
|
-
props,
|
|
1919
|
-
"}\n"
|
|
1920
|
-
];
|
|
1921
|
-
await fs.mkdir(path.dirname(tablePath), { recursive: true });
|
|
1922
|
-
try {
|
|
1923
|
-
await fs.writeFile(tablePath, orchidCore.codeToString(code, "", " "), { flag: "wx" });
|
|
1924
|
-
logger == null ? void 0 : logger.log(`Created ${orchidCore.pathToLog(tablePath)}`);
|
|
1925
|
-
} catch (err) {
|
|
1926
|
-
if (err.code !== "EEXIST") {
|
|
1927
|
-
throw err;
|
|
1928
|
-
}
|
|
1929
|
-
}
|
|
1930
|
-
};
|
|
1931
|
-
const getRelations = async (ast, getTable, tablePath, imports, relations, tableName) => {
|
|
1932
|
-
const refs = [];
|
|
1933
|
-
for (const key in ast.shape) {
|
|
1934
|
-
const item = ast.shape[key];
|
|
1935
|
-
if (!(item instanceof pqb.ColumnType) || !item.data.foreignKeys)
|
|
1936
|
-
continue;
|
|
1937
|
-
for (const fkey of item.data.foreignKeys) {
|
|
1938
|
-
if ("table" in fkey) {
|
|
1939
|
-
refs.push({
|
|
1940
|
-
table: fkey.table,
|
|
1941
|
-
columns: [key],
|
|
1942
|
-
foreignColumns: fkey.columns
|
|
1943
|
-
});
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
if (ast.constraints) {
|
|
1948
|
-
for (const { references: ref } of ast.constraints) {
|
|
1949
|
-
if (ref && typeof ref.fnOrTable === "string") {
|
|
1950
|
-
refs.push({
|
|
1951
|
-
table: ref.fnOrTable,
|
|
1952
|
-
columns: ref.columns,
|
|
1953
|
-
foreignColumns: ref.foreignColumns
|
|
1954
|
-
});
|
|
1955
|
-
}
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
if (!refs.length)
|
|
1959
|
-
return;
|
|
1960
|
-
const code = [];
|
|
1961
|
-
for (const ref of refs) {
|
|
1962
|
-
const { columns, foreignColumns } = ref;
|
|
1963
|
-
if (columns.length > 1 || foreignColumns.length > 1)
|
|
1964
|
-
continue;
|
|
1965
|
-
const info = await getTable(ref.table);
|
|
1966
|
-
if (!info)
|
|
1967
|
-
continue;
|
|
1968
|
-
const path2 = orchidCore.getImportPath(tablePath, info.path);
|
|
1969
|
-
imports[path2] = info.name;
|
|
1970
|
-
code.push(
|
|
1971
|
-
`${info.key}: this.belongsTo(() => ${info.name}, {`,
|
|
1972
|
-
[`primaryKey: '${foreignColumns[0]}',`, `foreignKey: '${columns[0]}',`],
|
|
1973
|
-
"}),"
|
|
1974
|
-
);
|
|
1975
|
-
await handleForeignKey({
|
|
1976
|
-
getTable,
|
|
1977
|
-
relations,
|
|
1978
|
-
tableName,
|
|
1979
|
-
columns: ref.columns,
|
|
1980
|
-
foreignTableName: ref.table,
|
|
1981
|
-
foreignColumns: ref.foreignColumns,
|
|
1982
|
-
skipBelongsTo: true
|
|
1983
|
-
});
|
|
1984
|
-
}
|
|
1985
|
-
return code.length ? ["relations = {", code, "};"] : void 0;
|
|
1986
|
-
};
|
|
1987
|
-
|
|
1988
|
-
var __defProp$2 = Object.defineProperty;
|
|
1989
|
-
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
1990
|
-
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
1991
|
-
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
1992
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1993
|
-
var __spreadValues$2 = (a, b) => {
|
|
1994
|
-
for (var prop in b || (b = {}))
|
|
1995
|
-
if (__hasOwnProp$3.call(b, prop))
|
|
1996
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
1997
|
-
if (__getOwnPropSymbols$3)
|
|
1998
|
-
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
1999
|
-
if (__propIsEnum$3.call(b, prop))
|
|
2000
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
2001
|
-
}
|
|
2002
|
-
return a;
|
|
2003
|
-
};
|
|
2004
|
-
var __objRest$1 = (source, exclude) => {
|
|
2005
|
-
var target = {};
|
|
2006
|
-
for (var prop in source)
|
|
2007
|
-
if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2008
|
-
target[prop] = source[prop];
|
|
2009
|
-
if (source != null && __getOwnPropSymbols$3)
|
|
2010
|
-
for (var prop of __getOwnPropSymbols$3(source)) {
|
|
2011
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
|
|
2012
|
-
target[prop] = source[prop];
|
|
2013
|
-
}
|
|
2014
|
-
return target;
|
|
2015
|
-
};
|
|
2016
|
-
const changeTable = async (_a) => {
|
|
2017
|
-
var _b = _a, {
|
|
2018
|
-
ast,
|
|
2019
|
-
logger
|
|
2020
|
-
} = _b, params = __objRest$1(_b, [
|
|
2021
|
-
"ast",
|
|
2022
|
-
"logger"
|
|
2023
|
-
]);
|
|
2024
|
-
const tablePath = params.tablePath(orchidCore.toCamelCase(ast.name));
|
|
2025
|
-
const content = await fs.readFile(tablePath, "utf-8").catch(() => void 0);
|
|
2026
|
-
if (!content)
|
|
2027
|
-
return;
|
|
2028
|
-
const changes = new FileChanges(content);
|
|
2029
|
-
const statements = ts.getStatements(content);
|
|
2030
|
-
const className = orchidCore.toPascalCase(ast.name) + "Table";
|
|
2031
|
-
for (const { t, object } of iterateColumnsShapes(statements, className)) {
|
|
2032
|
-
const context = makeChangeContext(changes, ast, content, object, t);
|
|
2033
|
-
prependSpaces(context);
|
|
2034
|
-
applySchemaChanges(context);
|
|
2035
|
-
appendTrailingComma(context);
|
|
2036
|
-
addColumns(context);
|
|
2037
|
-
addTableData(context);
|
|
2038
|
-
}
|
|
2039
|
-
await fs.writeFile(tablePath, changes.apply());
|
|
2040
|
-
logger == null ? void 0 : logger.log(`Updated ${orchidCore.pathToLog(tablePath)}`);
|
|
2041
|
-
};
|
|
2042
|
-
function* iterateColumnsShapes(statements, className) {
|
|
2043
|
-
var _a, _b;
|
|
2044
|
-
for (const node of ts.class.iterate(statements)) {
|
|
2045
|
-
if (((_a = node.name) == null ? void 0 : _a.escapedText) !== className)
|
|
2046
|
-
continue;
|
|
2047
|
-
for (const member of node.members) {
|
|
2048
|
-
const name = ts.prop.getName(member);
|
|
2049
|
-
const { initializer: call } = member;
|
|
2050
|
-
if (name !== "columns" || !call || !ts.is.call(call))
|
|
2051
|
-
continue;
|
|
2052
|
-
const { expression } = call;
|
|
2053
|
-
if (!ts.is.propertyAccess(expression) || !ts.is.this(expression.expression) || expression.name.escapedText !== "setColumns")
|
|
2054
|
-
continue;
|
|
2055
|
-
const [arg] = call.arguments;
|
|
2056
|
-
if (!ts.is.arrowFunction(arg))
|
|
2057
|
-
continue;
|
|
2058
|
-
const { parameters, body } = arg;
|
|
2059
|
-
const param = (_b = parameters[0]) == null ? void 0 : _b.name;
|
|
2060
|
-
if (!ts.is.identifier(param) || !ts.is.parenthesizedExpression(body))
|
|
2061
|
-
continue;
|
|
2062
|
-
const { expression: object } = body;
|
|
2063
|
-
if (!ts.is.objectLiteral(object))
|
|
2064
|
-
continue;
|
|
2065
|
-
yield { t: param.escapedText.toString(), object };
|
|
2066
|
-
}
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
const makeChangeContext = (changes, ast, content, object, t) => {
|
|
2070
|
-
const add = {};
|
|
2071
|
-
const drop = {};
|
|
2072
|
-
const change = {};
|
|
2073
|
-
const { properties: props } = object;
|
|
2074
|
-
const existingColumns = getExistingColumns(props);
|
|
2075
|
-
for (const key in ast.shape) {
|
|
2076
|
-
const item = ast.shape[key];
|
|
2077
|
-
if (item.type === "add" && !existingColumns[key]) {
|
|
2078
|
-
add[key] = item.item;
|
|
2079
|
-
}
|
|
2080
|
-
if (!existingColumns[key])
|
|
2081
|
-
continue;
|
|
2082
|
-
if (item.type === "drop" && existingColumns[key]) {
|
|
2083
|
-
drop[key] = true;
|
|
2084
|
-
} else if (item.type === "change" && existingColumns[key]) {
|
|
2085
|
-
change[key] = item;
|
|
2086
|
-
}
|
|
2087
|
-
}
|
|
2088
|
-
const spaces = ts.spaces.getAtLine(content, object.end);
|
|
2089
|
-
const shape = { add, drop, change };
|
|
2090
|
-
return {
|
|
2091
|
-
changes,
|
|
2092
|
-
props,
|
|
2093
|
-
shape,
|
|
2094
|
-
spaces,
|
|
2095
|
-
t,
|
|
2096
|
-
object,
|
|
2097
|
-
add: ast.add,
|
|
2098
|
-
drop: ast.drop
|
|
2099
|
-
};
|
|
2100
|
-
};
|
|
2101
|
-
const getExistingColumns = (props) => {
|
|
2102
|
-
const existingColumns = {};
|
|
2103
|
-
props.map((prop) => ts.is.propertyAssignment(prop) && ts.prop.getName(prop)).filter((name) => !!name).forEach((name) => existingColumns[name] = true);
|
|
2104
|
-
for (const prop of props) {
|
|
2105
|
-
if (!ts.is.propertyAssignment(prop))
|
|
2106
|
-
continue;
|
|
2107
|
-
const name = ts.prop.getName(prop);
|
|
2108
|
-
if (name)
|
|
2109
|
-
existingColumns[name] = true;
|
|
2110
|
-
}
|
|
2111
|
-
return existingColumns;
|
|
2112
|
-
};
|
|
2113
|
-
const prependSpaces = ({
|
|
2114
|
-
props,
|
|
2115
|
-
shape: { add },
|
|
2116
|
-
changes,
|
|
2117
|
-
spaces
|
|
2118
|
-
}) => {
|
|
2119
|
-
if (Object.keys(add).length && props.pos === props.end) {
|
|
2120
|
-
changes.add(props.pos, `
|
|
2121
|
-
${spaces}`);
|
|
2122
|
-
}
|
|
2123
|
-
};
|
|
2124
|
-
const applySchemaChanges = (context) => {
|
|
2125
|
-
const {
|
|
2126
|
-
props,
|
|
2127
|
-
shape: { drop: dropColumns, change: changeColumns },
|
|
2128
|
-
add,
|
|
2129
|
-
drop
|
|
2130
|
-
} = context;
|
|
2131
|
-
props.forEach((prop, i) => {
|
|
2132
|
-
if (ts.is.spreadAssignment(prop)) {
|
|
2133
|
-
const call = prop.expression;
|
|
2134
|
-
if (!ts.is.call(call))
|
|
2135
|
-
return;
|
|
2136
|
-
const access = call.expression;
|
|
2137
|
-
if (!ts.is.propertyAccess(access))
|
|
2138
|
-
return;
|
|
2139
|
-
const name = access.name.escapedText.toString();
|
|
2140
|
-
if (name === "primaryKey") {
|
|
2141
|
-
if (drop.primaryKey || add.primaryKey) {
|
|
2142
|
-
removeProp(context, prop, i);
|
|
2143
|
-
}
|
|
2144
|
-
} else if (name === "index") {
|
|
2145
|
-
dropMatchingIndexes(context, prop, i, call, drop.indexes);
|
|
2146
|
-
} else if (name === "foreignKey") {
|
|
2147
|
-
dropMatchingForeignKey(context, prop, i, call, drop.constraints);
|
|
2148
|
-
} else if (name === "check") {
|
|
2149
|
-
dropMatchingCheck(context, prop, i, call, drop.constraints);
|
|
2150
|
-
} else if (name === "constraint") {
|
|
2151
|
-
dropMatchingConstraint(context, prop, i, call, drop.constraints);
|
|
2152
|
-
}
|
|
2153
|
-
} else if (ts.is.propertyAssignment(prop)) {
|
|
2154
|
-
const name = ts.prop.getName(prop);
|
|
2155
|
-
if (!name)
|
|
2156
|
-
return;
|
|
2157
|
-
if (dropColumns[name]) {
|
|
2158
|
-
removeProp(context, prop, i);
|
|
2159
|
-
} else {
|
|
2160
|
-
const changeItem = changeColumns[name];
|
|
2161
|
-
if (changeItem) {
|
|
2162
|
-
changeColumn(context, changeItem, prop);
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
}
|
|
2166
|
-
});
|
|
2167
|
-
};
|
|
2168
|
-
const removeProp = ({ props, changes }, prop, i) => {
|
|
2169
|
-
var _a;
|
|
2170
|
-
const end = ((_a = props[i + 1]) == null ? void 0 : _a.pos) || props.end;
|
|
2171
|
-
changes.remove(prop.pos, end);
|
|
2172
|
-
};
|
|
2173
|
-
const changeColumn = ({ changes, t, spaces }, changeItem, prop) => {
|
|
2174
|
-
const { from, to } = changeItem;
|
|
2175
|
-
if ((from.type !== to.type || !!from.identity !== !!to.identity) && to.column) {
|
|
2176
|
-
changes.replace(
|
|
2177
|
-
prop.initializer.pos,
|
|
2178
|
-
prop.end,
|
|
2179
|
-
` ${orchidCore.codeToString(to.column.toCode(t), spaces + " ", " ").trim()}`
|
|
2180
|
-
);
|
|
2181
|
-
return;
|
|
2182
|
-
}
|
|
2183
|
-
const items = [];
|
|
2184
|
-
let chain = prop.initializer;
|
|
2185
|
-
while (ts.is.call(chain) && ts.is.propertyAccess(chain.expression)) {
|
|
2186
|
-
items.push(chain);
|
|
2187
|
-
chain = chain.expression.expression;
|
|
2188
|
-
}
|
|
2189
|
-
const propsToChange = {};
|
|
2190
|
-
for (const key in from) {
|
|
2191
|
-
if (to[key] !== from[key]) {
|
|
2192
|
-
propsToChange[key] = true;
|
|
2193
|
-
}
|
|
2194
|
-
}
|
|
2195
|
-
for (const key in to) {
|
|
2196
|
-
if (to[key] !== from[key]) {
|
|
2197
|
-
propsToChange[key] = true;
|
|
2198
|
-
}
|
|
2199
|
-
}
|
|
2200
|
-
const changedProps = {};
|
|
2201
|
-
const replaced = {};
|
|
2202
|
-
for (const item of items.reverse()) {
|
|
2203
|
-
if (!ts.is.propertyAccess(item.expression))
|
|
2204
|
-
continue;
|
|
2205
|
-
const { name } = item.expression;
|
|
2206
|
-
let key = name.escapedText.toString();
|
|
2207
|
-
if (key === "index")
|
|
2208
|
-
key = "indexes";
|
|
2209
|
-
else if (key === "foreignKey")
|
|
2210
|
-
key = "foreignKeys";
|
|
2211
|
-
if (!propsToChange[key])
|
|
2212
|
-
continue;
|
|
2213
|
-
let remove = true;
|
|
2214
|
-
if (!replaced[key]) {
|
|
2215
|
-
let code = getColumnMethodArgs(t, to, key, to.type);
|
|
2216
|
-
if (!code && key === "identity" && to.type) {
|
|
2217
|
-
code = [`.${to.type}()`];
|
|
2218
|
-
}
|
|
2219
|
-
if (code) {
|
|
2220
|
-
changes.replace(
|
|
2221
|
-
item.expression.expression.end,
|
|
2222
|
-
item.end,
|
|
2223
|
-
orchidCore.codeToString(code, spaces + " ", " ").trim()
|
|
2224
|
-
);
|
|
2225
|
-
replaced[key] = true;
|
|
2226
|
-
remove = false;
|
|
2227
|
-
}
|
|
2228
|
-
}
|
|
2229
|
-
if (remove) {
|
|
2230
|
-
changes.remove(item.expression.expression.end, item.end);
|
|
2231
|
-
}
|
|
2232
|
-
changedProps[key] = true;
|
|
2233
|
-
}
|
|
2234
|
-
let append = "";
|
|
2235
|
-
for (const key in propsToChange) {
|
|
2236
|
-
if (changedProps[key])
|
|
2237
|
-
continue;
|
|
2238
|
-
const code = getColumnMethodArgs(t, to, key);
|
|
2239
|
-
if (code) {
|
|
2240
|
-
append += orchidCore.codeToString(code, spaces + " ", " ").trim();
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
if (append) {
|
|
2244
|
-
changes.add(prop.end, append);
|
|
2245
|
-
}
|
|
2246
|
-
};
|
|
2247
|
-
const appendTrailingComma = ({ props, changes }) => {
|
|
2248
|
-
if (!props.hasTrailingComma) {
|
|
2249
|
-
const last = props[props.length - 1];
|
|
2250
|
-
if (last) {
|
|
2251
|
-
changes.add(last.end, ",");
|
|
2252
|
-
}
|
|
2253
|
-
}
|
|
2254
|
-
};
|
|
2255
|
-
const addColumns = ({
|
|
2256
|
-
shape: { add },
|
|
2257
|
-
changes,
|
|
2258
|
-
object,
|
|
2259
|
-
t,
|
|
2260
|
-
spaces
|
|
2261
|
-
}) => {
|
|
2262
|
-
const end = object.end - 1;
|
|
2263
|
-
for (const key in add) {
|
|
2264
|
-
const code = orchidCore.codeToString(add[key].toCode(t), spaces + " ", " ");
|
|
2265
|
-
changes.add(end, ` ${orchidCore.quoteObjectKey(key)}: ${code.trim()},
|
|
2266
|
-
${spaces}`);
|
|
2267
|
-
}
|
|
2268
|
-
};
|
|
2269
|
-
const addTableData = ({ add, changes, object, t, spaces }) => {
|
|
2270
|
-
const end = object.end - 1;
|
|
2271
|
-
if (add.primaryKey) {
|
|
2272
|
-
const code = orchidCore.codeToString(
|
|
2273
|
-
pqb.primaryKeyToCode(add.primaryKey, t),
|
|
2274
|
-
spaces,
|
|
2275
|
-
" "
|
|
2276
|
-
);
|
|
2277
|
-
changes.add(end, ` ${code.trim()}
|
|
2278
|
-
${spaces}`);
|
|
2279
|
-
}
|
|
2280
|
-
if (add.indexes) {
|
|
2281
|
-
for (const item of add.indexes) {
|
|
2282
|
-
const code = orchidCore.codeToString(pqb.indexToCode(item, t), spaces + " ", " ");
|
|
2283
|
-
changes.add(end, ` ${code.trim()}
|
|
2284
|
-
${spaces}`);
|
|
2285
|
-
}
|
|
2286
|
-
}
|
|
2287
|
-
if (add.constraints) {
|
|
2288
|
-
for (const item of add.constraints) {
|
|
2289
|
-
const code = orchidCore.codeToString(pqb.constraintToCode(item, t), spaces + " ", " ");
|
|
2290
|
-
changes.add(end, ` ${code.trim()}
|
|
2291
|
-
${spaces}`);
|
|
2292
|
-
}
|
|
2293
|
-
}
|
|
2294
|
-
};
|
|
2295
|
-
const getColumnMethodArgs = (t, to, key, dataType) => {
|
|
2296
|
-
const value = to[key];
|
|
2297
|
-
if (!value)
|
|
2298
|
-
return;
|
|
2299
|
-
if (key === "indexes") {
|
|
2300
|
-
return pqb.columnIndexesToCode(
|
|
2301
|
-
value
|
|
2302
|
-
);
|
|
2303
|
-
}
|
|
2304
|
-
if (key === "foreignKeys") {
|
|
2305
|
-
return pqb.columnForeignKeysToCode(value);
|
|
2306
|
-
}
|
|
2307
|
-
if (key === "check") {
|
|
2308
|
-
return [pqb.columnCheckToCode(t, value)];
|
|
2309
|
-
}
|
|
2310
|
-
if (key === "identity") {
|
|
2311
|
-
const code2 = pqb.identityToCode(value, dataType);
|
|
2312
|
-
code2[0] = `.${code2[0]}`;
|
|
2313
|
-
return code2;
|
|
2314
|
-
}
|
|
2315
|
-
const code = [`.${key}(`];
|
|
2316
|
-
if (key === "collate" || key === "compression") {
|
|
2317
|
-
orchidCore.addCode(code, orchidCore.singleQuote(value));
|
|
2318
|
-
} else if (key === "default") {
|
|
2319
|
-
orchidCore.addCode(code, orchidCore.columnDefaultArgumentToCode(t, value));
|
|
2320
|
-
} else if (key !== "nullable" && key !== "primaryKey") {
|
|
2321
|
-
return;
|
|
2322
|
-
}
|
|
2323
|
-
orchidCore.addCode(code, ")");
|
|
2324
|
-
return code;
|
|
2325
|
-
};
|
|
2326
|
-
const dropMatchingIndexes = (context, prop, i, call, items) => {
|
|
2327
|
-
if (!(items == null ? void 0 : items.length))
|
|
2328
|
-
return;
|
|
2329
|
-
const [columnsNode, optionsNode] = call.arguments;
|
|
2330
|
-
const columns = [];
|
|
2331
|
-
if (ts.is.stringLiteral(columnsNode)) {
|
|
2332
|
-
columns.push({ column: columnsNode.text });
|
|
2333
|
-
} else if (ts.is.arrayLiteral(columnsNode)) {
|
|
2334
|
-
for (const node of columnsNode.elements) {
|
|
2335
|
-
if (ts.is.stringLiteral(node)) {
|
|
2336
|
-
columns.push({ column: node.text });
|
|
2337
|
-
} else if (ts.is.objectLiteral(node)) {
|
|
2338
|
-
const object = collectObjectFromCode(node);
|
|
2339
|
-
if (!object)
|
|
2340
|
-
return;
|
|
2341
|
-
columns.push(object);
|
|
2342
|
-
}
|
|
2343
|
-
}
|
|
2344
|
-
} else {
|
|
2345
|
-
return;
|
|
2346
|
-
}
|
|
2347
|
-
const options = ts.is.objectLiteral(optionsNode) && collectObjectFromCode(optionsNode) || {};
|
|
2348
|
-
for (const item of items) {
|
|
2349
|
-
if (orchidCore.deepCompare(columns, item.columns) && orchidCore.deepCompare(options, item.options)) {
|
|
2350
|
-
removeProp(context, prop, i);
|
|
2351
|
-
}
|
|
2352
|
-
}
|
|
2353
|
-
};
|
|
2354
|
-
const dropMatchingForeignKey = (context, prop, i, call, items) => {
|
|
2355
|
-
if (!(items == null ? void 0 : items.length))
|
|
2356
|
-
return;
|
|
2357
|
-
const existing = parseReferencesArgs(context, call.arguments);
|
|
2358
|
-
if (!existing)
|
|
2359
|
-
return;
|
|
2360
|
-
for (const item of items) {
|
|
2361
|
-
if (compareReferences(existing, item.references))
|
|
2362
|
-
removeProp(context, prop, i);
|
|
2363
|
-
}
|
|
2364
|
-
};
|
|
2365
|
-
const parseReferencesArgs = (context, args) => {
|
|
2366
|
-
const columns = collectStringArrayFromCode(args[0]);
|
|
2367
|
-
if (!columns)
|
|
2368
|
-
return;
|
|
2369
|
-
const fnOrTableNode = args[1];
|
|
2370
|
-
let fnOrTable;
|
|
2371
|
-
if (ts.is.stringLiteral(fnOrTableNode)) {
|
|
2372
|
-
fnOrTable = fnOrTableNode.text;
|
|
2373
|
-
} else if (ts.is.arrowFunction(fnOrTableNode)) {
|
|
2374
|
-
fnOrTable = context.changes.content.slice(fnOrTableNode.pos, fnOrTableNode.end).replaceAll(/\s/g, "");
|
|
2375
|
-
} else {
|
|
2376
|
-
return;
|
|
2377
|
-
}
|
|
2378
|
-
const foreignColumns = collectStringArrayFromCode(args[2]);
|
|
2379
|
-
if (!foreignColumns)
|
|
2380
|
-
return;
|
|
2381
|
-
const options = ts.is.objectLiteral(args[3]) && collectObjectFromCode(args[3]) || {};
|
|
2382
|
-
return { columns, fnOrTable, foreignColumns, options };
|
|
2383
|
-
};
|
|
2384
|
-
const compareReferences = (existing, item) => {
|
|
2385
|
-
if (!item)
|
|
2386
|
-
return;
|
|
2387
|
-
const itemOptions = item.options ? __spreadValues$2({}, item.options) : void 0;
|
|
2388
|
-
if (itemOptions) {
|
|
2389
|
-
delete itemOptions.dropMode;
|
|
2390
|
-
}
|
|
2391
|
-
return orchidCore.deepCompare(existing == null ? void 0 : existing.columns, item == null ? void 0 : item.columns) && orchidCore.deepCompare(existing == null ? void 0 : existing.fnOrTable, item == null ? void 0 : item.fnOrTable.toString()) && orchidCore.deepCompare(existing == null ? void 0 : existing.foreignColumns, item == null ? void 0 : item.foreignColumns) && orchidCore.deepCompare(existing == null ? void 0 : existing.options, itemOptions);
|
|
2392
|
-
};
|
|
2393
|
-
const dropMatchingCheck = (context, prop, i, call, items) => {
|
|
2394
|
-
if (!(items == null ? void 0 : items.length))
|
|
2395
|
-
return;
|
|
2396
|
-
const sql = parseCheckArg(context, call.arguments[0]);
|
|
2397
|
-
for (const item of items) {
|
|
2398
|
-
const { check } = item;
|
|
2399
|
-
if (!check)
|
|
2400
|
-
continue;
|
|
2401
|
-
if (check.__raw === sql) {
|
|
2402
|
-
removeProp(context, prop, i);
|
|
2403
|
-
}
|
|
2404
|
-
}
|
|
2405
|
-
};
|
|
2406
|
-
const parseCheckArg = (context, arg) => {
|
|
2407
|
-
if (!arg || !ts.is.call(arg))
|
|
2408
|
-
return;
|
|
2409
|
-
const { expression } = arg;
|
|
2410
|
-
if (!ts.is.propertyAccess(expression) || !ts.is.identifier(expression.expression) || expression.expression.escapedText !== context.t || expression.name.escapedText !== "raw")
|
|
2411
|
-
return;
|
|
2412
|
-
const [sqlArg] = arg.arguments;
|
|
2413
|
-
if (!sqlArg || !ts.is.stringLiteral(sqlArg))
|
|
2414
|
-
return;
|
|
2415
|
-
return sqlArg.text;
|
|
2416
|
-
};
|
|
2417
|
-
const dropMatchingConstraint = (context, prop, i, call, items) => {
|
|
2418
|
-
var _a;
|
|
2419
|
-
if (!(items == null ? void 0 : items.length))
|
|
2420
|
-
return;
|
|
2421
|
-
const {
|
|
2422
|
-
arguments: [arg]
|
|
2423
|
-
} = call;
|
|
2424
|
-
if (!arg || !ts.is.objectLiteral(arg))
|
|
2425
|
-
return;
|
|
2426
|
-
const existing = {};
|
|
2427
|
-
for (const prop2 of arg.properties) {
|
|
2428
|
-
if (!ts.is.propertyAssignment(prop2))
|
|
2429
|
-
return;
|
|
2430
|
-
const name = ts.prop.getName(prop2);
|
|
2431
|
-
if (!name)
|
|
2432
|
-
return;
|
|
2433
|
-
const init = prop2.initializer;
|
|
2434
|
-
if (name === "name") {
|
|
2435
|
-
if (!ts.is.stringLiteral(init))
|
|
2436
|
-
return;
|
|
2437
|
-
existing.name = init.text;
|
|
2438
|
-
} else if (name === "references") {
|
|
2439
|
-
if (!ts.is.arrayLiteral(init))
|
|
2440
|
-
return;
|
|
2441
|
-
const refs = parseReferencesArgs(context, init.elements);
|
|
2442
|
-
if (!refs)
|
|
2443
|
-
return;
|
|
2444
|
-
existing.references = refs;
|
|
2445
|
-
} else if (name === "check") {
|
|
2446
|
-
existing.check = parseCheckArg(context, init);
|
|
2447
|
-
}
|
|
2448
|
-
}
|
|
2449
|
-
for (const item of items) {
|
|
2450
|
-
if (existing.name !== item.name)
|
|
2451
|
-
continue;
|
|
2452
|
-
if (existing.check !== ((_a = item.check) == null ? void 0 : _a.__raw))
|
|
2453
|
-
continue;
|
|
2454
|
-
if ((existing.references || item.references) && !compareReferences(existing.references, item.references))
|
|
2455
|
-
continue;
|
|
2456
|
-
removeProp(context, prop, i);
|
|
2457
|
-
}
|
|
2458
|
-
};
|
|
2459
|
-
const collectStringArrayFromCode = (node) => {
|
|
2460
|
-
if (!ts.is.arrayLiteral(node))
|
|
2461
|
-
return;
|
|
2462
|
-
const result = node.elements.filter(ts.is.stringLiteral).map((item) => item.text);
|
|
2463
|
-
return result.length === node.elements.length ? result : void 0;
|
|
2464
|
-
};
|
|
2465
|
-
const collectObjectFromCode = (node) => {
|
|
2466
|
-
const object = {};
|
|
2467
|
-
for (const prop of node.properties) {
|
|
2468
|
-
if (!ts.is.propertyAssignment(prop))
|
|
2469
|
-
return;
|
|
2470
|
-
const name = ts.prop.getName(prop);
|
|
2471
|
-
if (!name)
|
|
2472
|
-
return;
|
|
2473
|
-
const init = prop.initializer;
|
|
2474
|
-
if (ts.is.stringLiteral(init)) {
|
|
2475
|
-
object[name] = init.text;
|
|
2476
|
-
} else if (ts.is.numericLiteral(init)) {
|
|
2477
|
-
object[name] = parseFloat(init.text);
|
|
2478
|
-
} else {
|
|
2479
|
-
return;
|
|
2480
|
-
}
|
|
2481
|
-
}
|
|
2482
|
-
return object;
|
|
2483
|
-
};
|
|
2484
|
-
|
|
2485
|
-
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
2486
|
-
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
2487
|
-
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
2488
|
-
var __objRest = (source, exclude) => {
|
|
2489
|
-
var target = {};
|
|
2490
|
-
for (var prop in source)
|
|
2491
|
-
if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2492
|
-
target[prop] = source[prop];
|
|
2493
|
-
if (source != null && __getOwnPropSymbols$2)
|
|
2494
|
-
for (var prop of __getOwnPropSymbols$2(source)) {
|
|
2495
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
|
|
2496
|
-
target[prop] = source[prop];
|
|
2497
|
-
}
|
|
2498
|
-
return target;
|
|
2499
|
-
};
|
|
2500
|
-
const renameTable = async (_a) => {
|
|
2501
|
-
var _b = _a, {
|
|
2502
|
-
ast,
|
|
2503
|
-
logger
|
|
2504
|
-
} = _b, params = __objRest(_b, [
|
|
2505
|
-
"ast",
|
|
2506
|
-
"logger"
|
|
2507
|
-
]);
|
|
2508
|
-
var _a2;
|
|
2509
|
-
const tablePath = params.tablePath(orchidCore.toCamelCase(ast.from));
|
|
2510
|
-
const content = await fs.readFile(tablePath, "utf-8").catch(() => void 0);
|
|
2511
|
-
if (!content)
|
|
2512
|
-
return;
|
|
2513
|
-
const changes = new FileChanges(content);
|
|
2514
|
-
const statements = ts.getStatements(content);
|
|
2515
|
-
const className = orchidCore.toPascalCase(ast.from) + "Table";
|
|
2516
|
-
const changeSchema = ast.fromSchema !== ast.toSchema;
|
|
2517
|
-
for (const node of ts.class.iterate(statements)) {
|
|
2518
|
-
if (((_a2 = node.name) == null ? void 0 : _a2.escapedText) !== className)
|
|
2519
|
-
continue;
|
|
2520
|
-
const addSchema = changeSchema && ast.toSchema && !node.members.some((member) => ts.prop.getName(member) === "schema");
|
|
2521
|
-
if (addSchema && ast.toSchema) {
|
|
2522
|
-
changes.add(
|
|
2523
|
-
node.members.pos,
|
|
2524
|
-
`
|
|
2525
|
-
schema = ${orchidCore.singleQuote(ast.toSchema)};`
|
|
2526
|
-
);
|
|
2527
|
-
}
|
|
2528
|
-
for (const member of node.members) {
|
|
2529
|
-
const name = ts.prop.getName(member);
|
|
2530
|
-
if (name !== "table" && !(changeSchema && name === "schema"))
|
|
2531
|
-
continue;
|
|
2532
|
-
const { initializer: value } = member;
|
|
2533
|
-
if (!value)
|
|
2534
|
-
continue;
|
|
2535
|
-
if (name === "schema") {
|
|
2536
|
-
if (ast.toSchema) {
|
|
2537
|
-
changes.replace(
|
|
2538
|
-
value.pos,
|
|
2539
|
-
value.end,
|
|
2540
|
-
` ${orchidCore.singleQuote(ast.toSchema)}`
|
|
2541
|
-
);
|
|
2542
|
-
} else {
|
|
2543
|
-
changes.remove(member.pos, member.end);
|
|
2544
|
-
}
|
|
2545
|
-
} else {
|
|
2546
|
-
changes.replace(value.pos, value.end, ` ${orchidCore.singleQuote(ast.to)}`);
|
|
2547
|
-
}
|
|
2548
|
-
}
|
|
2549
|
-
}
|
|
2550
|
-
await fs.writeFile(tablePath, changes.apply());
|
|
2551
|
-
logger == null ? void 0 : logger.log(`Updated ${orchidCore.pathToLog(tablePath)}`);
|
|
2552
|
-
};
|
|
2553
|
-
|
|
2554
|
-
var __defProp$1 = Object.defineProperty;
|
|
2555
|
-
var __defProps$1 = Object.defineProperties;
|
|
2556
|
-
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
2557
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
2558
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
2559
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
2560
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2561
|
-
var __spreadValues$1 = (a, b) => {
|
|
2562
|
-
for (var prop in b || (b = {}))
|
|
2563
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
2564
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
2565
|
-
if (__getOwnPropSymbols$1)
|
|
2566
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
2567
|
-
if (__propIsEnum$1.call(b, prop))
|
|
2568
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
2569
|
-
}
|
|
2570
|
-
return a;
|
|
2571
|
-
};
|
|
2572
|
-
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
2573
|
-
const updateTableFile = async (params) => {
|
|
2574
|
-
const { ast } = params;
|
|
2575
|
-
if (ast.type === "table" && ast.action === "create") {
|
|
2576
|
-
await createTable(__spreadProps$1(__spreadValues$1({}, params), { ast }));
|
|
2577
|
-
} else if (ast.type === "changeTable") {
|
|
2578
|
-
await changeTable(__spreadProps$1(__spreadValues$1({}, params), { ast }));
|
|
2579
|
-
} else if (ast.type === "renameTable") {
|
|
2580
|
-
await renameTable(__spreadProps$1(__spreadValues$1({}, params), { ast }));
|
|
2581
|
-
} else if (ast.type === "constraint" && ast.references) {
|
|
2582
|
-
const ref = ast.references;
|
|
2583
|
-
if (typeof ref.fnOrTable === "string") {
|
|
2584
|
-
await handleForeignKey({
|
|
2585
|
-
getTable: params.getTable,
|
|
2586
|
-
relations: params.relations,
|
|
2587
|
-
tableName: ast.tableName,
|
|
2588
|
-
columns: ref.columns,
|
|
2589
|
-
foreignTableName: ref.fnOrTable,
|
|
2590
|
-
foreignColumns: ref.foreignColumns
|
|
2591
|
-
});
|
|
2592
|
-
}
|
|
2593
|
-
}
|
|
2594
|
-
};
|
|
2595
|
-
|
|
2596
|
-
const createBaseTableFile = async ({
|
|
2597
|
-
baseTable,
|
|
2598
|
-
logger
|
|
2599
|
-
}) => {
|
|
2600
|
-
await fs.mkdir(path.dirname(baseTable.filePath), { recursive: true });
|
|
2601
|
-
await fs.writeFile(
|
|
2602
|
-
baseTable.filePath,
|
|
2603
|
-
`import { createBaseTable } from 'orchid-orm';
|
|
2604
|
-
|
|
2605
|
-
export const ${baseTable.name} = createBaseTable();
|
|
2606
|
-
`,
|
|
2607
|
-
{
|
|
2608
|
-
flag: "wx"
|
|
2609
|
-
}
|
|
2610
|
-
).then(() => {
|
|
2611
|
-
logger == null ? void 0 : logger.log(`Created ${orchidCore.pathToLog(baseTable.filePath)}`);
|
|
2612
|
-
}).catch((err) => {
|
|
2613
|
-
if (err.code === "EEXIST")
|
|
2614
|
-
return;
|
|
2615
|
-
throw err;
|
|
2616
|
-
});
|
|
2617
|
-
};
|
|
2618
|
-
|
|
2619
|
-
const updateRelations = async ({
|
|
2620
|
-
relations,
|
|
2621
|
-
logger
|
|
2622
|
-
}) => {
|
|
2623
|
-
await Promise.all(
|
|
2624
|
-
Object.entries(relations).map(
|
|
2625
|
-
([tableName, item]) => updateRelationItem(tableName, item, logger)
|
|
2626
|
-
)
|
|
2627
|
-
);
|
|
2628
|
-
};
|
|
2629
|
-
const updateRelationItem = async (tableName, item, logger) => {
|
|
2630
|
-
var _a;
|
|
2631
|
-
const content = await fs.readFile(item.path, "utf-8").catch(() => void 0);
|
|
2632
|
-
if (!content)
|
|
2633
|
-
return;
|
|
2634
|
-
const changes = new FileChanges(content);
|
|
2635
|
-
const statements = ts.getStatements(content);
|
|
2636
|
-
const dirName = path.dirname(item.path);
|
|
2637
|
-
const imports = {};
|
|
2638
|
-
for (const relation of item.relations) {
|
|
2639
|
-
if (!imports[relation.path]) {
|
|
2640
|
-
imports[relation.path] = relation.className;
|
|
2641
|
-
}
|
|
2642
|
-
}
|
|
2643
|
-
let importsEnd = 0;
|
|
2644
|
-
for (const node of ts.import.iterate(statements)) {
|
|
2645
|
-
const source = ts.import.getSource(node);
|
|
2646
|
-
const full = path.join(dirName, source + ".ts");
|
|
2647
|
-
if (imports[full]) {
|
|
2648
|
-
delete imports[full];
|
|
2649
|
-
}
|
|
2650
|
-
importsEnd = node.end;
|
|
2651
|
-
}
|
|
2652
|
-
const addImports = Object.entries(imports).map(
|
|
2653
|
-
([path2, name]) => `import { ${name} } from '${orchidCore.getImportPath(item.path, path2)}';`
|
|
2654
|
-
).join("\n");
|
|
2655
|
-
if (addImports) {
|
|
2656
|
-
changes.add(importsEnd, `
|
|
2657
|
-
${addImports}`);
|
|
2658
|
-
}
|
|
2659
|
-
const targetClass = findClassByTableName(statements, tableName);
|
|
2660
|
-
if (targetClass) {
|
|
2661
|
-
const relationsMember = findRelationsMember(targetClass.members);
|
|
2662
|
-
if (relationsMember) {
|
|
2663
|
-
const { initializer } = relationsMember;
|
|
2664
|
-
const takenKeys = {};
|
|
2665
|
-
if (ts.is.objectLiteral(initializer)) {
|
|
2666
|
-
const props = initializer.properties;
|
|
2667
|
-
for (const prop of props) {
|
|
2668
|
-
const name = (_a = prop.name) == null ? void 0 : _a.getText();
|
|
2669
|
-
if (name)
|
|
2670
|
-
takenKeys[name] = true;
|
|
2671
|
-
}
|
|
2672
|
-
const addRelations = [];
|
|
2673
|
-
for (const rel of item.relations) {
|
|
2674
|
-
if (!checkRelation(rel))
|
|
2675
|
-
continue;
|
|
2676
|
-
const name = makeRelationName(rel);
|
|
2677
|
-
if (takenKeys[name])
|
|
2678
|
-
continue;
|
|
2679
|
-
addRelations.push(relationToCode(rel));
|
|
2680
|
-
}
|
|
2681
|
-
if (addRelations.length) {
|
|
2682
|
-
const pos = props.end;
|
|
2683
|
-
changes.add(pos, addRelations.join(""));
|
|
2684
|
-
}
|
|
2685
|
-
}
|
|
2686
|
-
} else {
|
|
2687
|
-
changes.add(
|
|
2688
|
-
targetClass.end - 1,
|
|
2689
|
-
`
|
|
2690
|
-
relations = {${item.relations.filter(checkRelation).map((rel) => relationToCode(rel)).join("")}
|
|
2691
|
-
};
|
|
2692
|
-
`
|
|
2693
|
-
);
|
|
2694
|
-
}
|
|
2695
|
-
}
|
|
2696
|
-
await fs.writeFile(item.path, changes.apply());
|
|
2697
|
-
logger == null ? void 0 : logger.log(`Updated ${orchidCore.pathToLog(item.path)}`);
|
|
2698
|
-
};
|
|
2699
|
-
const findClassByTableName = (statements, tableName) => {
|
|
2700
|
-
for (const node of ts.class.iterate(statements)) {
|
|
2701
|
-
for (const member of node.members) {
|
|
2702
|
-
const name = ts.prop.getName(member);
|
|
2703
|
-
if (name !== "table")
|
|
2704
|
-
continue;
|
|
2705
|
-
const { initializer: value } = member;
|
|
2706
|
-
if (!value || !ts.is.stringLiteral(value))
|
|
2707
|
-
continue;
|
|
2708
|
-
if (value.text === tableName) {
|
|
2709
|
-
return node;
|
|
2710
|
-
}
|
|
2711
|
-
}
|
|
2712
|
-
}
|
|
2713
|
-
return;
|
|
2714
|
-
};
|
|
2715
|
-
const findRelationsMember = (members) => {
|
|
2716
|
-
for (const member of members) {
|
|
2717
|
-
const name = ts.prop.getName(member);
|
|
2718
|
-
if (name === "relations")
|
|
2719
|
-
return member;
|
|
2720
|
-
}
|
|
2721
|
-
return;
|
|
2722
|
-
};
|
|
2723
|
-
const checkRelation = (rel) => {
|
|
2724
|
-
return rel.columns.length === 1 && rel.foreignColumns.length === 1;
|
|
2725
|
-
};
|
|
2726
|
-
const makeRelationName = (rel) => {
|
|
2727
|
-
return inflection.pluralize(
|
|
2728
|
-
rel.className[0].toLowerCase() + rel.className.slice(1).replace(/Table$/, "")
|
|
2729
|
-
);
|
|
2730
|
-
};
|
|
2731
|
-
const relationToCode = (rel, name = makeRelationName(rel)) => {
|
|
2732
|
-
const code = [`
|
|
2733
|
-
${name}: this.${rel.kind}(() => ${rel.className}, {`];
|
|
2734
|
-
const pk = rel[rel.kind === "hasMany" ? "columns" : "foreignColumns"][0];
|
|
2735
|
-
const fk = rel[rel.kind === "hasMany" ? "foreignColumns" : "columns"][0];
|
|
2736
|
-
code.push(
|
|
2737
|
-
` primaryKey: '${pk}',`,
|
|
2738
|
-
` foreignKey: '${fk}',`,
|
|
2739
|
-
" }),"
|
|
2740
|
-
);
|
|
2741
|
-
return code.join("\n");
|
|
2742
|
-
};
|
|
2743
|
-
|
|
2744
|
-
var __defProp = Object.defineProperty;
|
|
2745
|
-
var __defProps = Object.defineProperties;
|
|
2746
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2747
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
2748
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2749
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
2750
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2751
|
-
var __spreadValues = (a, b) => {
|
|
2752
|
-
for (var prop in b || (b = {}))
|
|
2753
|
-
if (__hasOwnProp.call(b, prop))
|
|
2754
|
-
__defNormalProp(a, prop, b[prop]);
|
|
2755
|
-
if (__getOwnPropSymbols)
|
|
2756
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
2757
|
-
if (__propIsEnum.call(b, prop))
|
|
2758
|
-
__defNormalProp(a, prop, b[prop]);
|
|
2759
|
-
}
|
|
2760
|
-
return a;
|
|
2761
|
-
};
|
|
2762
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
2763
|
-
class AppCodeUpdaterError extends Error {
|
|
2764
|
-
}
|
|
2765
|
-
const makeGetTable = (path2, ormExportedAs, tables) => {
|
|
2766
|
-
let orm;
|
|
2767
|
-
return async (tableName) => {
|
|
2768
|
-
if (tables[tableName])
|
|
2769
|
-
return tables[tableName];
|
|
2770
|
-
if (!orm) {
|
|
2771
|
-
orm = (await import(path2))[ormExportedAs];
|
|
2772
|
-
if (!orm) {
|
|
2773
|
-
throw new Error(`ORM is not exported as ${ormExportedAs} from ${path2}`);
|
|
2774
|
-
}
|
|
2775
|
-
}
|
|
2776
|
-
for (const key in orm) {
|
|
2777
|
-
const table = orm[key];
|
|
2778
|
-
if (table && typeof table === "object" && table instanceof pqb.Db && table.table === tableName) {
|
|
2779
|
-
const tableInfo = {
|
|
2780
|
-
key,
|
|
2781
|
-
name: table.name,
|
|
2782
|
-
path: table.filePath
|
|
2783
|
-
};
|
|
2784
|
-
return tables[tableName] = tableInfo;
|
|
2785
|
-
}
|
|
2786
|
-
}
|
|
2787
|
-
return;
|
|
2788
|
-
};
|
|
2789
|
-
};
|
|
2790
|
-
const appCodeUpdater = ({
|
|
2791
|
-
tablePath,
|
|
2792
|
-
ormPath,
|
|
2793
|
-
ormExportedAs = "db"
|
|
2794
|
-
}) => ({
|
|
2795
|
-
async process({
|
|
2796
|
-
ast,
|
|
2797
|
-
options,
|
|
2798
|
-
basePath,
|
|
2799
|
-
cache: cacheObject,
|
|
2800
|
-
logger,
|
|
2801
|
-
baseTable
|
|
2802
|
-
}) {
|
|
2803
|
-
var _a, _b;
|
|
2804
|
-
const params = {
|
|
2805
|
-
tablePath(name) {
|
|
2806
|
-
const file = tablePath(name);
|
|
2807
|
-
return resolvePath(basePath, file);
|
|
2808
|
-
},
|
|
2809
|
-
ormPath: resolvePath(basePath, ormPath),
|
|
2810
|
-
ormExportedAs,
|
|
2811
|
-
logger
|
|
2812
|
-
};
|
|
2813
|
-
const cache = cacheObject;
|
|
2814
|
-
(_a = cache.relations) != null ? _a : cache.relations = {};
|
|
2815
|
-
(_b = cache.tables) != null ? _b : cache.tables = {};
|
|
2816
|
-
const getTable = makeGetTable(params.ormPath, ormExportedAs, cache.tables);
|
|
2817
|
-
const promises = [
|
|
2818
|
-
updateMainFile(params.ormPath, params.tablePath, ast, options, logger),
|
|
2819
|
-
updateTableFile(__spreadProps(__spreadValues({}, params), {
|
|
2820
|
-
ast,
|
|
2821
|
-
baseTable,
|
|
2822
|
-
getTable,
|
|
2823
|
-
relations: cache.relations,
|
|
2824
|
-
tables: cache.tables
|
|
2825
|
-
}))
|
|
2826
|
-
];
|
|
2827
|
-
if (!cache.createdBaseTable) {
|
|
2828
|
-
promises.push(
|
|
2829
|
-
createBaseTableFile({ logger: params.logger, baseTable }).then(() => {
|
|
2830
|
-
cache.createdBaseTable = true;
|
|
2831
|
-
})
|
|
2832
|
-
);
|
|
2833
|
-
}
|
|
2834
|
-
await Promise.all(promises);
|
|
2835
|
-
},
|
|
2836
|
-
async afterAll({ cache, logger }) {
|
|
2837
|
-
const { relations } = cache;
|
|
2838
|
-
if (!relations)
|
|
2839
|
-
return;
|
|
2840
|
-
await updateRelations({
|
|
2841
|
-
relations,
|
|
2842
|
-
logger
|
|
2843
|
-
});
|
|
2844
|
-
}
|
|
2845
|
-
});
|
|
2846
|
-
const resolvePath = (basePath, filePath) => path__namespace.isAbsolute(filePath) ? filePath : path__namespace.resolve(basePath, filePath);
|
|
2847
|
-
|
|
2848
1458
|
Object.defineProperty(exports, 'OrchidOrmError', {
|
|
2849
1459
|
enumerable: true,
|
|
2850
1460
|
get: function () { return pqb.OrchidOrmError; }
|
|
@@ -2861,8 +1471,6 @@ Object.defineProperty(exports, 'testTransaction', {
|
|
|
2861
1471
|
enumerable: true,
|
|
2862
1472
|
get: function () { return pqb.testTransaction; }
|
|
2863
1473
|
});
|
|
2864
|
-
exports.AppCodeUpdaterError = AppCodeUpdaterError;
|
|
2865
|
-
exports.appCodeUpdater = appCodeUpdater;
|
|
2866
1474
|
exports.createBaseTable = createBaseTable;
|
|
2867
1475
|
exports.createRepo = createRepo;
|
|
2868
1476
|
exports.orchidORM = orchidORM;
|