arkormx 2.12.6 → 2.12.8
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/cli.mjs +82 -57
- package/dist/{index-BjSGgOHU.d.cts → index-BTOZxFaD.d.cts} +44 -23
- package/dist/{index-CuQUg7wQ.d.mts → index-CO0QpdRB.d.mts} +44 -23
- package/dist/index.cjs +114 -50
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +114 -50
- package/dist/relationship/index.cjs +1 -1
- package/dist/relationship/index.d.cts +1 -1
- package/dist/relationship/index.d.mts +1 -1
- package/dist/relationship/index.mjs +1 -1
- package/dist/{relationship-BuHgK3wO.cjs → relationship-BMHIbxB3.cjs} +32 -17
- package/dist/{relationship-D1VAPbxZ.mjs → relationship-CMAr0Ggg.mjs} +31 -16
- package/package.json +6 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Cs as Relation, Ss as BelongsToManyRelation, _s as HasOneRelation, bs as BelongsToRelation, ds as MorphToRelation, fs as MorphedByManyRelation, gs as HasOneThroughRelation, hs as MorphManyRelation, ms as MorphOneRelation, ps as MorphToManyRelation, us as SetBasedEagerLoader, vs as HasManyThroughRelation, ws as RelationTableLoader, xs as SingleResultRelation, ys as HasManyRelation } from "../index-
|
|
1
|
+
import { Cs as Relation, Ss as BelongsToManyRelation, _s as HasOneRelation, bs as BelongsToRelation, ds as MorphToRelation, fs as MorphedByManyRelation, gs as HasOneThroughRelation, hs as MorphManyRelation, ms as MorphOneRelation, ps as MorphToManyRelation, us as SetBasedEagerLoader, vs as HasManyThroughRelation, ws as RelationTableLoader, xs as SingleResultRelation, ys as HasManyRelation } from "../index-CO0QpdRB.mjs";
|
|
2
2
|
export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, MorphToRelation, MorphedByManyRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as SetBasedEagerLoader, a as MorphManyRelation, c as HasManyThroughRelation, d as SingleResultRelation, f as BelongsToManyRelation, i as MorphOneRelation, l as HasManyRelation, n as MorphedByManyRelation, o as HasOneThroughRelation, p as Relation, r as MorphToManyRelation, s as HasOneRelation, t as MorphToRelation, u as BelongsToRelation, v as RelationTableLoader } from "../relationship-
|
|
1
|
+
import { _ as SetBasedEagerLoader, a as MorphManyRelation, c as HasManyThroughRelation, d as SingleResultRelation, f as BelongsToManyRelation, i as MorphOneRelation, l as HasManyRelation, n as MorphedByManyRelation, o as HasOneThroughRelation, p as Relation, r as MorphToManyRelation, s as HasOneRelation, t as MorphToRelation, u as BelongsToRelation, v as RelationTableLoader } from "../relationship-CMAr0Ggg.mjs";
|
|
2
2
|
|
|
3
3
|
export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, MorphToRelation, MorphedByManyRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
|
|
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
}
|
|
20
20
|
return to;
|
|
21
21
|
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
23
23
|
value: mod,
|
|
24
24
|
enumerable: true
|
|
25
25
|
}) : target, mod));
|
|
@@ -871,7 +871,8 @@ const loadRuntimeConfigSync = () => {
|
|
|
871
871
|
for (const configPath of syncConfigPaths) {
|
|
872
872
|
if (!(0, fs.existsSync)(configPath)) continue;
|
|
873
873
|
try {
|
|
874
|
-
|
|
874
|
+
const imported = require(configPath);
|
|
875
|
+
resolveAndApplyConfig(imported);
|
|
875
876
|
return true;
|
|
876
877
|
} catch {
|
|
877
878
|
continue;
|
|
@@ -899,7 +900,8 @@ const loadArkormConfig = async () => {
|
|
|
899
900
|
for (const configPath of configPaths) {
|
|
900
901
|
if (!(0, fs.existsSync)(configPath)) continue;
|
|
901
902
|
try {
|
|
902
|
-
|
|
903
|
+
const imported = await importConfigFile(configPath);
|
|
904
|
+
resolveAndApplyConfig(imported);
|
|
903
905
|
await awaitConfiguredModelsRegistration();
|
|
904
906
|
return;
|
|
905
907
|
} catch {
|
|
@@ -960,6 +962,8 @@ const getRuntimeAdapter = () => {
|
|
|
960
962
|
* processes (the CLI) so the Node event loop drains and the process exits
|
|
961
963
|
* promptly instead of hanging on pool idle timeouts. Teardown failures are
|
|
962
964
|
* swallowed because the process is shutting down anyway.
|
|
965
|
+
*
|
|
966
|
+
* @returns
|
|
963
967
|
*/
|
|
964
968
|
const disposeArkormRuntime = async () => {
|
|
965
969
|
let adapterDisposed = false;
|
|
@@ -1414,7 +1418,8 @@ const expressionBuilder = {
|
|
|
1414
1418
|
*/
|
|
1415
1419
|
const resolveGeneratedExpression = (expression) => {
|
|
1416
1420
|
if (typeof expression === "string") return expression;
|
|
1417
|
-
|
|
1421
|
+
const built = expression(expressionBuilder);
|
|
1422
|
+
return expressionNodeToSql(built.toExpressionNode());
|
|
1418
1423
|
};
|
|
1419
1424
|
const quoteIdentifier = (name) => name.split(".").map((part) => `"${part.replace(/"/g, "\"\"")}"`).join(".");
|
|
1420
1425
|
const quoteLiteral = (value) => {
|
|
@@ -2902,7 +2907,8 @@ const applyCreateTableOperation = (schema, operation) => {
|
|
|
2902
2907
|
if (findModelBlock(schema, operation.table)) throw new ArkormException(`Prisma model for table [${operation.table}] already exists.`);
|
|
2903
2908
|
const schemaWithEnums = ensureEnumBlocks(schema, operation.columns);
|
|
2904
2909
|
const block = buildModelBlock(operation);
|
|
2905
|
-
|
|
2910
|
+
const nextSchema = `${schemaWithEnums.trimEnd()}\n\n${block}\n`;
|
|
2911
|
+
return applyInverseRelations(nextSchema, toModelName(operation.table), operation.foreignKeys ?? [], operation.columns);
|
|
2906
2912
|
};
|
|
2907
2913
|
/**
|
|
2908
2914
|
* Apply an alter table operation to a Prisma schema string, modifying the model
|
|
@@ -2915,7 +2921,8 @@ const applyCreateTableOperation = (schema, operation) => {
|
|
|
2915
2921
|
const applyAlterTableOperation = (schema, operation) => {
|
|
2916
2922
|
const model = findModelBlock(schema, operation.table);
|
|
2917
2923
|
if (!model) throw new ArkormException(`Prisma model for table [${operation.table}] was not found.`);
|
|
2918
|
-
const
|
|
2924
|
+
const enumColumns = [...operation.addColumns, ...operation.changeColumns ?? []];
|
|
2925
|
+
const schemaWithEnums = ensureEnumBlocks(schema, enumColumns);
|
|
2919
2926
|
const refreshedModel = findModelBlock(schemaWithEnums, operation.table);
|
|
2920
2927
|
if (!refreshedModel) throw new ArkormException(`Prisma model for table [${operation.table}] was not found.`);
|
|
2921
2928
|
let block = refreshedModel.block;
|
|
@@ -2967,7 +2974,8 @@ const applyAlterTableOperation = (schema, operation) => {
|
|
|
2967
2974
|
injectLineIntoModelBody(bodyLines, relationLine, (line) => relationRegex.test(line));
|
|
2968
2975
|
}
|
|
2969
2976
|
block = bodyLines.join("\n");
|
|
2970
|
-
|
|
2977
|
+
const nextSchema = `${schemaWithEnums.slice(0, refreshedModel.start)}${block}${schemaWithEnums.slice(refreshedModel.end)}`;
|
|
2978
|
+
return applyInverseRelations(nextSchema, model.modelName, operation.addForeignKeys ?? [], operation.addColumns);
|
|
2971
2979
|
};
|
|
2972
2980
|
/**
|
|
2973
2981
|
* Apply a drop table operation to a Prisma schema string, removing the model block
|
|
@@ -3222,8 +3230,9 @@ const applyMigrationRollbackToPrismaSchema = async (migration, options = {}) =>
|
|
|
3222
3230
|
*/
|
|
3223
3231
|
const runMigrationWithPrisma = async (migration, options = {}) => {
|
|
3224
3232
|
const cwd = options.cwd ?? process.cwd();
|
|
3233
|
+
const schemaPath = options.schemaPath ?? (0, node_path.join)(cwd, "prisma", "schema.prisma");
|
|
3225
3234
|
const applied = await applyMigrationToPrismaSchema(migration, {
|
|
3226
|
-
schemaPath
|
|
3235
|
+
schemaPath,
|
|
3227
3236
|
write: options.write
|
|
3228
3237
|
});
|
|
3229
3238
|
const shouldGenerate = options.runGenerate ?? true;
|
|
@@ -3231,12 +3240,15 @@ const runMigrationWithPrisma = async (migration, options = {}) => {
|
|
|
3231
3240
|
const mode = options.migrateMode ?? "dev";
|
|
3232
3241
|
if (shouldGenerate) runPrismaCommand(["generate"], cwd);
|
|
3233
3242
|
if (shouldMigrate) if (mode === "deploy") runPrismaCommand(["migrate", "deploy"], cwd);
|
|
3234
|
-
else
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3243
|
+
else {
|
|
3244
|
+
const migrationName = options.migrationName ?? `arkorm_${createMigrationTimestamp()}`;
|
|
3245
|
+
runPrismaCommand([
|
|
3246
|
+
"migrate",
|
|
3247
|
+
"dev",
|
|
3248
|
+
"--name",
|
|
3249
|
+
migrationName
|
|
3250
|
+
], cwd);
|
|
3251
|
+
}
|
|
3240
3252
|
return {
|
|
3241
3253
|
schemaPath: applied.schemaPath,
|
|
3242
3254
|
operations: applied.operations
|
|
@@ -3365,7 +3377,8 @@ const readPersistedColumnMappingsState = (filePath) => {
|
|
|
3365
3377
|
return empty;
|
|
3366
3378
|
}
|
|
3367
3379
|
try {
|
|
3368
|
-
const
|
|
3380
|
+
const parsed = JSON.parse((0, node_fs.readFileSync)(filePath, "utf-8"));
|
|
3381
|
+
const normalized = normalizePersistedColumnMappingsState(parsed);
|
|
3369
3382
|
cachedColumnMappingsPath = filePath;
|
|
3370
3383
|
cachedColumnMappingsState = normalized;
|
|
3371
3384
|
return normalized;
|
|
@@ -6355,11 +6368,13 @@ var BelongsToManyRelation = class BelongsToManyRelation extends Relation {
|
|
|
6355
6368
|
});
|
|
6356
6369
|
decorated.paginate = (async (perPage = 15, page, options = {}) => {
|
|
6357
6370
|
const paginator = await originalPaginate(perPage, page, options);
|
|
6358
|
-
|
|
6371
|
+
const data = this.attachPivotToResults(paginator.data, pivotRows);
|
|
6372
|
+
return new LengthAwarePaginator(data, paginator.meta.total, paginator.meta.perPage, paginator.meta.currentPage, options);
|
|
6359
6373
|
});
|
|
6360
6374
|
decorated.simplePaginate = (async (perPage = 15, page, options = {}) => {
|
|
6361
6375
|
const paginator = await originalSimplePaginate(perPage, page, options);
|
|
6362
|
-
|
|
6376
|
+
const data = this.attachPivotToResults(paginator.data, pivotRows);
|
|
6377
|
+
return new Paginator(data, paginator.meta.perPage, paginator.meta.currentPage, paginator.meta.hasMorePages, options);
|
|
6363
6378
|
});
|
|
6364
6379
|
decorated.clone = (() => {
|
|
6365
6380
|
return this.decorateQueryBuilder(originalClone(), pivotRows);
|
|
@@ -843,7 +843,8 @@ const loadRuntimeConfigSync = () => {
|
|
|
843
843
|
for (const configPath of syncConfigPaths) {
|
|
844
844
|
if (!existsSync$1(configPath)) continue;
|
|
845
845
|
try {
|
|
846
|
-
|
|
846
|
+
const imported = require(configPath);
|
|
847
|
+
resolveAndApplyConfig(imported);
|
|
847
848
|
return true;
|
|
848
849
|
} catch {
|
|
849
850
|
continue;
|
|
@@ -871,7 +872,8 @@ const loadArkormConfig = async () => {
|
|
|
871
872
|
for (const configPath of configPaths) {
|
|
872
873
|
if (!existsSync$1(configPath)) continue;
|
|
873
874
|
try {
|
|
874
|
-
|
|
875
|
+
const imported = await importConfigFile(configPath);
|
|
876
|
+
resolveAndApplyConfig(imported);
|
|
875
877
|
await awaitConfiguredModelsRegistration();
|
|
876
878
|
return;
|
|
877
879
|
} catch {
|
|
@@ -932,6 +934,8 @@ const getRuntimeAdapter = () => {
|
|
|
932
934
|
* processes (the CLI) so the Node event loop drains and the process exits
|
|
933
935
|
* promptly instead of hanging on pool idle timeouts. Teardown failures are
|
|
934
936
|
* swallowed because the process is shutting down anyway.
|
|
937
|
+
*
|
|
938
|
+
* @returns
|
|
935
939
|
*/
|
|
936
940
|
const disposeArkormRuntime = async () => {
|
|
937
941
|
let adapterDisposed = false;
|
|
@@ -1386,7 +1390,8 @@ const expressionBuilder = {
|
|
|
1386
1390
|
*/
|
|
1387
1391
|
const resolveGeneratedExpression = (expression) => {
|
|
1388
1392
|
if (typeof expression === "string") return expression;
|
|
1389
|
-
|
|
1393
|
+
const built = expression(expressionBuilder);
|
|
1394
|
+
return expressionNodeToSql(built.toExpressionNode());
|
|
1390
1395
|
};
|
|
1391
1396
|
const quoteIdentifier = (name) => name.split(".").map((part) => `"${part.replace(/"/g, "\"\"")}"`).join(".");
|
|
1392
1397
|
const quoteLiteral = (value) => {
|
|
@@ -2874,7 +2879,8 @@ const applyCreateTableOperation = (schema, operation) => {
|
|
|
2874
2879
|
if (findModelBlock(schema, operation.table)) throw new ArkormException(`Prisma model for table [${operation.table}] already exists.`);
|
|
2875
2880
|
const schemaWithEnums = ensureEnumBlocks(schema, operation.columns);
|
|
2876
2881
|
const block = buildModelBlock(operation);
|
|
2877
|
-
|
|
2882
|
+
const nextSchema = `${schemaWithEnums.trimEnd()}\n\n${block}\n`;
|
|
2883
|
+
return applyInverseRelations(nextSchema, toModelName(operation.table), operation.foreignKeys ?? [], operation.columns);
|
|
2878
2884
|
};
|
|
2879
2885
|
/**
|
|
2880
2886
|
* Apply an alter table operation to a Prisma schema string, modifying the model
|
|
@@ -2887,7 +2893,8 @@ const applyCreateTableOperation = (schema, operation) => {
|
|
|
2887
2893
|
const applyAlterTableOperation = (schema, operation) => {
|
|
2888
2894
|
const model = findModelBlock(schema, operation.table);
|
|
2889
2895
|
if (!model) throw new ArkormException(`Prisma model for table [${operation.table}] was not found.`);
|
|
2890
|
-
const
|
|
2896
|
+
const enumColumns = [...operation.addColumns, ...operation.changeColumns ?? []];
|
|
2897
|
+
const schemaWithEnums = ensureEnumBlocks(schema, enumColumns);
|
|
2891
2898
|
const refreshedModel = findModelBlock(schemaWithEnums, operation.table);
|
|
2892
2899
|
if (!refreshedModel) throw new ArkormException(`Prisma model for table [${operation.table}] was not found.`);
|
|
2893
2900
|
let block = refreshedModel.block;
|
|
@@ -2939,7 +2946,8 @@ const applyAlterTableOperation = (schema, operation) => {
|
|
|
2939
2946
|
injectLineIntoModelBody(bodyLines, relationLine, (line) => relationRegex.test(line));
|
|
2940
2947
|
}
|
|
2941
2948
|
block = bodyLines.join("\n");
|
|
2942
|
-
|
|
2949
|
+
const nextSchema = `${schemaWithEnums.slice(0, refreshedModel.start)}${block}${schemaWithEnums.slice(refreshedModel.end)}`;
|
|
2950
|
+
return applyInverseRelations(nextSchema, model.modelName, operation.addForeignKeys ?? [], operation.addColumns);
|
|
2943
2951
|
};
|
|
2944
2952
|
/**
|
|
2945
2953
|
* Apply a drop table operation to a Prisma schema string, removing the model block
|
|
@@ -3194,8 +3202,9 @@ const applyMigrationRollbackToPrismaSchema = async (migration, options = {}) =>
|
|
|
3194
3202
|
*/
|
|
3195
3203
|
const runMigrationWithPrisma = async (migration, options = {}) => {
|
|
3196
3204
|
const cwd = options.cwd ?? process.cwd();
|
|
3205
|
+
const schemaPath = options.schemaPath ?? join(cwd, "prisma", "schema.prisma");
|
|
3197
3206
|
const applied = await applyMigrationToPrismaSchema(migration, {
|
|
3198
|
-
schemaPath
|
|
3207
|
+
schemaPath,
|
|
3199
3208
|
write: options.write
|
|
3200
3209
|
});
|
|
3201
3210
|
const shouldGenerate = options.runGenerate ?? true;
|
|
@@ -3203,12 +3212,15 @@ const runMigrationWithPrisma = async (migration, options = {}) => {
|
|
|
3203
3212
|
const mode = options.migrateMode ?? "dev";
|
|
3204
3213
|
if (shouldGenerate) runPrismaCommand(["generate"], cwd);
|
|
3205
3214
|
if (shouldMigrate) if (mode === "deploy") runPrismaCommand(["migrate", "deploy"], cwd);
|
|
3206
|
-
else
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3215
|
+
else {
|
|
3216
|
+
const migrationName = options.migrationName ?? `arkorm_${createMigrationTimestamp()}`;
|
|
3217
|
+
runPrismaCommand([
|
|
3218
|
+
"migrate",
|
|
3219
|
+
"dev",
|
|
3220
|
+
"--name",
|
|
3221
|
+
migrationName
|
|
3222
|
+
], cwd);
|
|
3223
|
+
}
|
|
3212
3224
|
return {
|
|
3213
3225
|
schemaPath: applied.schemaPath,
|
|
3214
3226
|
operations: applied.operations
|
|
@@ -3337,7 +3349,8 @@ const readPersistedColumnMappingsState = (filePath) => {
|
|
|
3337
3349
|
return empty;
|
|
3338
3350
|
}
|
|
3339
3351
|
try {
|
|
3340
|
-
const
|
|
3352
|
+
const parsed = JSON.parse(readFileSync(filePath, "utf-8"));
|
|
3353
|
+
const normalized = normalizePersistedColumnMappingsState(parsed);
|
|
3341
3354
|
cachedColumnMappingsPath = filePath;
|
|
3342
3355
|
cachedColumnMappingsState = normalized;
|
|
3343
3356
|
return normalized;
|
|
@@ -6327,11 +6340,13 @@ var BelongsToManyRelation = class BelongsToManyRelation extends Relation {
|
|
|
6327
6340
|
});
|
|
6328
6341
|
decorated.paginate = (async (perPage = 15, page, options = {}) => {
|
|
6329
6342
|
const paginator = await originalPaginate(perPage, page, options);
|
|
6330
|
-
|
|
6343
|
+
const data = this.attachPivotToResults(paginator.data, pivotRows);
|
|
6344
|
+
return new LengthAwarePaginator(data, paginator.meta.total, paginator.meta.perPage, paginator.meta.currentPage, options);
|
|
6331
6345
|
});
|
|
6332
6346
|
decorated.simplePaginate = (async (perPage = 15, page, options = {}) => {
|
|
6333
6347
|
const paginator = await originalSimplePaginate(perPage, page, options);
|
|
6334
|
-
|
|
6348
|
+
const data = this.attachPivotToResults(paginator.data, pivotRows);
|
|
6349
|
+
return new Paginator(data, paginator.meta.perPage, paginator.meta.currentPage, paginator.meta.hasMorePages, options);
|
|
6335
6350
|
});
|
|
6336
6351
|
decorated.clone = (() => {
|
|
6337
6352
|
return this.decorateQueryBuilder(originalClone(), pivotRows);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkormx",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.8",
|
|
4
4
|
"description": "Modern TypeScript-first ORM for Node.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"orm",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"eslint": "^10.3.0",
|
|
67
67
|
"prisma": "^7.6.0",
|
|
68
68
|
"reflect-metadata": "^0.2.2",
|
|
69
|
-
"tsdown": "^0.22.
|
|
69
|
+
"tsdown": "^0.22.2",
|
|
70
70
|
"typescript": "^6.0.0",
|
|
71
71
|
"typescript-eslint": "^8.59.2",
|
|
72
72
|
"unplugin-swc": "^1.5.9",
|
|
@@ -78,13 +78,13 @@
|
|
|
78
78
|
"vitest": "^4.1.8"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
|
-
"node": ">=
|
|
81
|
+
"node": ">=22.0.0"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@h3ravel/collect.js": "^5.4.0",
|
|
85
|
-
"@h3ravel/musket": "^2.2.
|
|
86
|
-
"@h3ravel/shared": "^2.2.
|
|
87
|
-
"@h3ravel/support": "^2.2.
|
|
85
|
+
"@h3ravel/musket": "^2.2.13",
|
|
86
|
+
"@h3ravel/shared": "^2.2.7",
|
|
87
|
+
"@h3ravel/support": "^2.2.7",
|
|
88
88
|
"dotenv": "^17.3.1",
|
|
89
89
|
"jiti": "^2.7.0",
|
|
90
90
|
"kysely": "^0.28.15",
|