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.mjs
CHANGED
|
@@ -375,7 +375,7 @@ const handleForeignKey = async ({
|
|
|
375
375
|
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
376
376
|
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
377
377
|
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
378
|
-
var __objRest$
|
|
378
|
+
var __objRest$3 = (source, exclude) => {
|
|
379
379
|
var target = {};
|
|
380
380
|
for (var prop in source)
|
|
381
381
|
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
@@ -394,7 +394,7 @@ const createTable = async (_a) => {
|
|
|
394
394
|
getTable,
|
|
395
395
|
relations,
|
|
396
396
|
tables
|
|
397
|
-
} = _b, params = __objRest$
|
|
397
|
+
} = _b, params = __objRest$3(_b, [
|
|
398
398
|
"ast",
|
|
399
399
|
"logger",
|
|
400
400
|
"getTable",
|
|
@@ -411,7 +411,7 @@ const createTable = async (_a) => {
|
|
|
411
411
|
path: tablePath
|
|
412
412
|
};
|
|
413
413
|
const imports = {
|
|
414
|
-
[baseTablePath]: params.baseTable.
|
|
414
|
+
[baseTablePath]: params.baseTable.exportAs
|
|
415
415
|
};
|
|
416
416
|
const props = [];
|
|
417
417
|
if (ast.schema) {
|
|
@@ -442,7 +442,7 @@ const createTable = async (_a) => {
|
|
|
442
442
|
([from, name]) => `import { ${name} } from '${from}';`
|
|
443
443
|
),
|
|
444
444
|
"",
|
|
445
|
-
`export class ${className} extends ${params.baseTable.
|
|
445
|
+
`export class ${className} extends ${params.baseTable.exportAs} {`,
|
|
446
446
|
props,
|
|
447
447
|
"}\n"
|
|
448
448
|
];
|
|
@@ -529,7 +529,7 @@ var __spreadValues$2 = (a, b) => {
|
|
|
529
529
|
}
|
|
530
530
|
return a;
|
|
531
531
|
};
|
|
532
|
-
var __objRest$
|
|
532
|
+
var __objRest$2 = (source, exclude) => {
|
|
533
533
|
var target = {};
|
|
534
534
|
for (var prop in source)
|
|
535
535
|
if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
@@ -545,7 +545,7 @@ const changeTable = async (_a) => {
|
|
|
545
545
|
var _b = _a, {
|
|
546
546
|
ast,
|
|
547
547
|
logger
|
|
548
|
-
} = _b, params = __objRest$
|
|
548
|
+
} = _b, params = __objRest$2(_b, [
|
|
549
549
|
"ast",
|
|
550
550
|
"logger"
|
|
551
551
|
]);
|
|
@@ -1013,7 +1013,7 @@ const collectObjectFromCode = (node) => {
|
|
|
1013
1013
|
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
1014
1014
|
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
1015
1015
|
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
1016
|
-
var __objRest = (source, exclude) => {
|
|
1016
|
+
var __objRest$1 = (source, exclude) => {
|
|
1017
1017
|
var target = {};
|
|
1018
1018
|
for (var prop in source)
|
|
1019
1019
|
if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
@@ -1029,7 +1029,7 @@ const renameTable = async (_a) => {
|
|
|
1029
1029
|
var _b = _a, {
|
|
1030
1030
|
ast,
|
|
1031
1031
|
logger
|
|
1032
|
-
} = _b, params = __objRest(_b, [
|
|
1032
|
+
} = _b, params = __objRest$1(_b, [
|
|
1033
1033
|
"ast",
|
|
1034
1034
|
"logger"
|
|
1035
1035
|
]);
|
|
@@ -1130,7 +1130,7 @@ const createBaseTableFile = async ({
|
|
|
1130
1130
|
baseTable.filePath,
|
|
1131
1131
|
`import { createBaseTable } from 'orchid-orm';
|
|
1132
1132
|
|
|
1133
|
-
export const ${baseTable.
|
|
1133
|
+
export const ${baseTable.exportAs} = createBaseTable();
|
|
1134
1134
|
`,
|
|
1135
1135
|
{
|
|
1136
1136
|
flag: "wx"
|
|
@@ -1288,15 +1288,34 @@ var __spreadValues = (a, b) => {
|
|
|
1288
1288
|
return a;
|
|
1289
1289
|
};
|
|
1290
1290
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1291
|
+
var __objRest = (source, exclude) => {
|
|
1292
|
+
var target = {};
|
|
1293
|
+
for (var prop in source)
|
|
1294
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1295
|
+
target[prop] = source[prop];
|
|
1296
|
+
if (source != null && __getOwnPropSymbols)
|
|
1297
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
1298
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
1299
|
+
target[prop] = source[prop];
|
|
1300
|
+
}
|
|
1301
|
+
return target;
|
|
1302
|
+
};
|
|
1291
1303
|
class AppCodeUpdaterError extends Error {
|
|
1292
1304
|
}
|
|
1293
|
-
const makeGetTable = (path2, ormExportedAs, tables) => {
|
|
1305
|
+
const makeGetTable = (path2, ormExportedAs, tables, imp) => {
|
|
1294
1306
|
let orm;
|
|
1295
1307
|
return async (tableName) => {
|
|
1296
1308
|
if (tables[tableName])
|
|
1297
1309
|
return tables[tableName];
|
|
1298
1310
|
if (!orm) {
|
|
1299
|
-
|
|
1311
|
+
const mod = await imp(path2).catch((err) => {
|
|
1312
|
+
if (err.code === "ERR_UNKNOWN_FILE_EXTENSION") {
|
|
1313
|
+
return require(path2);
|
|
1314
|
+
} else {
|
|
1315
|
+
throw err;
|
|
1316
|
+
}
|
|
1317
|
+
});
|
|
1318
|
+
orm = mod[ormExportedAs];
|
|
1300
1319
|
if (!orm) {
|
|
1301
1320
|
throw new Error(`ORM is not exported as ${ormExportedAs} from ${path2}`);
|
|
1302
1321
|
}
|
|
@@ -1320,15 +1339,9 @@ const appCodeUpdater = ({
|
|
|
1320
1339
|
ormPath,
|
|
1321
1340
|
ormExportedAs = "db"
|
|
1322
1341
|
}) => ({
|
|
1323
|
-
async process({
|
|
1324
|
-
ast,
|
|
1325
|
-
|
|
1326
|
-
basePath,
|
|
1327
|
-
cache: cacheObject,
|
|
1328
|
-
logger,
|
|
1329
|
-
baseTable
|
|
1330
|
-
}) {
|
|
1331
|
-
var _a, _b;
|
|
1342
|
+
async process(_a) {
|
|
1343
|
+
var _b = _a, { ast, options, basePath, logger, baseTable } = _b, config = __objRest(_b, ["ast", "options", "basePath", "logger", "baseTable"]);
|
|
1344
|
+
var _a2, _b2;
|
|
1332
1345
|
const params = {
|
|
1333
1346
|
tablePath(name) {
|
|
1334
1347
|
const file = tablePath(name);
|
|
@@ -1338,10 +1351,15 @@ const appCodeUpdater = ({
|
|
|
1338
1351
|
ormExportedAs,
|
|
1339
1352
|
logger
|
|
1340
1353
|
};
|
|
1341
|
-
const cache =
|
|
1342
|
-
(
|
|
1343
|
-
(
|
|
1344
|
-
const getTable = makeGetTable(
|
|
1354
|
+
const cache = config.cache;
|
|
1355
|
+
(_a2 = cache.relations) != null ? _a2 : cache.relations = {};
|
|
1356
|
+
(_b2 = cache.tables) != null ? _b2 : cache.tables = {};
|
|
1357
|
+
const getTable = makeGetTable(
|
|
1358
|
+
params.ormPath,
|
|
1359
|
+
ormExportedAs,
|
|
1360
|
+
cache.tables,
|
|
1361
|
+
config.import
|
|
1362
|
+
);
|
|
1345
1363
|
const promises = [
|
|
1346
1364
|
updateMainFile(params.ormPath, params.tablePath, ast, options, logger),
|
|
1347
1365
|
updateTableFile(__spreadProps(__spreadValues({}, params), {
|