orchid-orm 1.9.25 → 1.9.27
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/codegen/index.d.ts +1 -1
- package/codegen/index.js +42 -24
- package/codegen/index.js.map +1 -1
- package/codegen/index.mjs +42 -24
- package/codegen/index.mjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/codegen/index.d.ts
CHANGED
package/codegen/index.js
CHANGED
|
@@ -395,7 +395,7 @@ const handleForeignKey = async ({
|
|
|
395
395
|
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
396
396
|
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
397
397
|
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
398
|
-
var __objRest$
|
|
398
|
+
var __objRest$3 = (source, exclude) => {
|
|
399
399
|
var target = {};
|
|
400
400
|
for (var prop in source)
|
|
401
401
|
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
@@ -414,7 +414,7 @@ const createTable = async (_a) => {
|
|
|
414
414
|
getTable,
|
|
415
415
|
relations,
|
|
416
416
|
tables
|
|
417
|
-
} = _b, params = __objRest$
|
|
417
|
+
} = _b, params = __objRest$3(_b, [
|
|
418
418
|
"ast",
|
|
419
419
|
"logger",
|
|
420
420
|
"getTable",
|
|
@@ -431,7 +431,7 @@ const createTable = async (_a) => {
|
|
|
431
431
|
path: tablePath
|
|
432
432
|
};
|
|
433
433
|
const imports = {
|
|
434
|
-
[baseTablePath]: params.baseTable.
|
|
434
|
+
[baseTablePath]: params.baseTable.exportAs
|
|
435
435
|
};
|
|
436
436
|
const props = [];
|
|
437
437
|
if (ast.schema) {
|
|
@@ -462,7 +462,7 @@ const createTable = async (_a) => {
|
|
|
462
462
|
([from, name]) => `import { ${name} } from '${from}';`
|
|
463
463
|
),
|
|
464
464
|
"",
|
|
465
|
-
`export class ${className} extends ${params.baseTable.
|
|
465
|
+
`export class ${className} extends ${params.baseTable.exportAs} {`,
|
|
466
466
|
props,
|
|
467
467
|
"}\n"
|
|
468
468
|
];
|
|
@@ -549,7 +549,7 @@ var __spreadValues$2 = (a, b) => {
|
|
|
549
549
|
}
|
|
550
550
|
return a;
|
|
551
551
|
};
|
|
552
|
-
var __objRest$
|
|
552
|
+
var __objRest$2 = (source, exclude) => {
|
|
553
553
|
var target = {};
|
|
554
554
|
for (var prop in source)
|
|
555
555
|
if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
@@ -565,7 +565,7 @@ const changeTable = async (_a) => {
|
|
|
565
565
|
var _b = _a, {
|
|
566
566
|
ast,
|
|
567
567
|
logger
|
|
568
|
-
} = _b, params = __objRest$
|
|
568
|
+
} = _b, params = __objRest$2(_b, [
|
|
569
569
|
"ast",
|
|
570
570
|
"logger"
|
|
571
571
|
]);
|
|
@@ -1033,7 +1033,7 @@ const collectObjectFromCode = (node) => {
|
|
|
1033
1033
|
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
1034
1034
|
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
1035
1035
|
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
1036
|
-
var __objRest = (source, exclude) => {
|
|
1036
|
+
var __objRest$1 = (source, exclude) => {
|
|
1037
1037
|
var target = {};
|
|
1038
1038
|
for (var prop in source)
|
|
1039
1039
|
if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
@@ -1049,7 +1049,7 @@ const renameTable = async (_a) => {
|
|
|
1049
1049
|
var _b = _a, {
|
|
1050
1050
|
ast,
|
|
1051
1051
|
logger
|
|
1052
|
-
} = _b, params = __objRest(_b, [
|
|
1052
|
+
} = _b, params = __objRest$1(_b, [
|
|
1053
1053
|
"ast",
|
|
1054
1054
|
"logger"
|
|
1055
1055
|
]);
|
|
@@ -1150,7 +1150,7 @@ const createBaseTableFile = async ({
|
|
|
1150
1150
|
baseTable.filePath,
|
|
1151
1151
|
`import { createBaseTable } from 'orchid-orm';
|
|
1152
1152
|
|
|
1153
|
-
export const ${baseTable.
|
|
1153
|
+
export const ${baseTable.exportAs} = createBaseTable();
|
|
1154
1154
|
`,
|
|
1155
1155
|
{
|
|
1156
1156
|
flag: "wx"
|
|
@@ -1308,15 +1308,34 @@ var __spreadValues = (a, b) => {
|
|
|
1308
1308
|
return a;
|
|
1309
1309
|
};
|
|
1310
1310
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1311
|
+
var __objRest = (source, exclude) => {
|
|
1312
|
+
var target = {};
|
|
1313
|
+
for (var prop in source)
|
|
1314
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1315
|
+
target[prop] = source[prop];
|
|
1316
|
+
if (source != null && __getOwnPropSymbols)
|
|
1317
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
1318
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
1319
|
+
target[prop] = source[prop];
|
|
1320
|
+
}
|
|
1321
|
+
return target;
|
|
1322
|
+
};
|
|
1311
1323
|
class AppCodeUpdaterError extends Error {
|
|
1312
1324
|
}
|
|
1313
|
-
const makeGetTable = (path2, ormExportedAs, tables) => {
|
|
1325
|
+
const makeGetTable = (path2, ormExportedAs, tables, imp) => {
|
|
1314
1326
|
let orm;
|
|
1315
1327
|
return async (tableName) => {
|
|
1316
1328
|
if (tables[tableName])
|
|
1317
1329
|
return tables[tableName];
|
|
1318
1330
|
if (!orm) {
|
|
1319
|
-
|
|
1331
|
+
const mod = await imp(path2).catch((err) => {
|
|
1332
|
+
if (err.code === "ERR_UNKNOWN_FILE_EXTENSION") {
|
|
1333
|
+
return require(path2);
|
|
1334
|
+
} else {
|
|
1335
|
+
throw err;
|
|
1336
|
+
}
|
|
1337
|
+
});
|
|
1338
|
+
orm = mod[ormExportedAs];
|
|
1320
1339
|
if (!orm) {
|
|
1321
1340
|
throw new Error(`ORM is not exported as ${ormExportedAs} from ${path2}`);
|
|
1322
1341
|
}
|
|
@@ -1340,15 +1359,9 @@ const appCodeUpdater = ({
|
|
|
1340
1359
|
ormPath,
|
|
1341
1360
|
ormExportedAs = "db"
|
|
1342
1361
|
}) => ({
|
|
1343
|
-
async process({
|
|
1344
|
-
ast,
|
|
1345
|
-
|
|
1346
|
-
basePath,
|
|
1347
|
-
cache: cacheObject,
|
|
1348
|
-
logger,
|
|
1349
|
-
baseTable
|
|
1350
|
-
}) {
|
|
1351
|
-
var _a, _b;
|
|
1362
|
+
async process(_a) {
|
|
1363
|
+
var _b = _a, { ast, options, basePath, logger, baseTable } = _b, config = __objRest(_b, ["ast", "options", "basePath", "logger", "baseTable"]);
|
|
1364
|
+
var _a2, _b2;
|
|
1352
1365
|
const params = {
|
|
1353
1366
|
tablePath(name) {
|
|
1354
1367
|
const file = tablePath(name);
|
|
@@ -1358,10 +1371,15 @@ const appCodeUpdater = ({
|
|
|
1358
1371
|
ormExportedAs,
|
|
1359
1372
|
logger
|
|
1360
1373
|
};
|
|
1361
|
-
const cache =
|
|
1362
|
-
(
|
|
1363
|
-
(
|
|
1364
|
-
const getTable = makeGetTable(
|
|
1374
|
+
const cache = config.cache;
|
|
1375
|
+
(_a2 = cache.relations) != null ? _a2 : cache.relations = {};
|
|
1376
|
+
(_b2 = cache.tables) != null ? _b2 : cache.tables = {};
|
|
1377
|
+
const getTable = makeGetTable(
|
|
1378
|
+
params.ormPath,
|
|
1379
|
+
ormExportedAs,
|
|
1380
|
+
cache.tables,
|
|
1381
|
+
config.import
|
|
1382
|
+
);
|
|
1365
1383
|
const promises = [
|
|
1366
1384
|
updateMainFile(params.ormPath, params.tablePath, ast, options, logger),
|
|
1367
1385
|
updateTableFile(__spreadProps(__spreadValues({}, params), {
|