arkormx 2.12.7 → 2.12.9
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-CdzU8tME.d.mts → index-Lxl6NdHS.d.cts} +186 -24
- package/dist/{index-DmAEofZM.d.cts → index-O3-Mi7hj.d.mts} +186 -24
- package/dist/index.cjs +93 -50
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +93 -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-D7MhPUIX.cjs} +239 -31
- package/dist/{relationship-D1VAPbxZ.mjs → relationship-DZ4WJ0Si.mjs} +238 -30
- package/package.json +6 -6
|
@@ -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;
|
|
@@ -4817,41 +4830,82 @@ var Relation = class {
|
|
|
4817
4830
|
};
|
|
4818
4831
|
return this;
|
|
4819
4832
|
}
|
|
4833
|
+
where(whereOrColumn, value) {
|
|
4834
|
+
return this.constrain((query) => {
|
|
4835
|
+
if (typeof whereOrColumn === "function") return query.where(whereOrColumn);
|
|
4836
|
+
if (value !== void 0) return query.where(whereOrColumn, value);
|
|
4837
|
+
return query.where(whereOrColumn);
|
|
4838
|
+
});
|
|
4839
|
+
}
|
|
4840
|
+
orWhere(whereOrColumn, value) {
|
|
4841
|
+
return this.constrain((query) => {
|
|
4842
|
+
if (typeof whereOrColumn === "function") return query.orWhere(whereOrColumn);
|
|
4843
|
+
if (value !== void 0) return query.orWhere(whereOrColumn, value);
|
|
4844
|
+
return query.orWhere(whereOrColumn);
|
|
4845
|
+
});
|
|
4846
|
+
}
|
|
4820
4847
|
/**
|
|
4821
|
-
*
|
|
4848
|
+
* Adds a NOT where clause to the query.
|
|
4822
4849
|
*
|
|
4823
4850
|
* @param where
|
|
4824
4851
|
* @returns
|
|
4825
4852
|
*/
|
|
4826
|
-
|
|
4827
|
-
return this.constrain((query) => query.
|
|
4853
|
+
whereNot(where) {
|
|
4854
|
+
return this.constrain((query) => query.whereNot(where));
|
|
4828
4855
|
}
|
|
4829
4856
|
/**
|
|
4830
|
-
* Adds an OR where clause to the query.
|
|
4857
|
+
* Adds an OR NOT where clause to the query.
|
|
4831
4858
|
*
|
|
4832
4859
|
* @param where
|
|
4833
4860
|
* @returns
|
|
4834
4861
|
*/
|
|
4835
|
-
|
|
4836
|
-
return this.constrain((query) => query.
|
|
4862
|
+
orWhereNot(where) {
|
|
4863
|
+
return this.constrain((query) => query.orWhereNot(where));
|
|
4837
4864
|
}
|
|
4838
4865
|
/**
|
|
4839
|
-
*
|
|
4866
|
+
* Apply a callback when the supplied value is truthy.
|
|
4840
4867
|
*
|
|
4841
|
-
*
|
|
4868
|
+
* Keeping this on the relation avoids forcing callers to await `getQuery()`
|
|
4869
|
+
* merely to compose optional constraints.
|
|
4870
|
+
*
|
|
4871
|
+
* @param value
|
|
4872
|
+
* @param callback
|
|
4873
|
+
* @param defaultCallback
|
|
4842
4874
|
* @returns
|
|
4843
4875
|
*/
|
|
4844
|
-
|
|
4845
|
-
|
|
4876
|
+
when(value, callback, defaultCallback) {
|
|
4877
|
+
const resolved = typeof value === "function" ? value() : value;
|
|
4878
|
+
if (resolved) callback(this, resolved);
|
|
4879
|
+
else defaultCallback?.(this, resolved);
|
|
4880
|
+
return this;
|
|
4846
4881
|
}
|
|
4847
4882
|
/**
|
|
4848
|
-
*
|
|
4883
|
+
* Apply a callback when the supplied value is falsy.
|
|
4849
4884
|
*
|
|
4850
|
-
* @param
|
|
4885
|
+
* @param value
|
|
4886
|
+
* @param callback
|
|
4887
|
+
* @param defaultCallback
|
|
4851
4888
|
* @returns
|
|
4852
4889
|
*/
|
|
4853
|
-
|
|
4854
|
-
|
|
4890
|
+
unless(value, callback, defaultCallback) {
|
|
4891
|
+
const resolved = typeof value === "function" ? value() : value;
|
|
4892
|
+
if (!resolved) callback(this, resolved);
|
|
4893
|
+
else defaultCallback?.(this, resolved);
|
|
4894
|
+
return this;
|
|
4895
|
+
}
|
|
4896
|
+
/**
|
|
4897
|
+
* Pass the relation through a callback and preserve the chain.
|
|
4898
|
+
*
|
|
4899
|
+
* @param callback
|
|
4900
|
+
* @returns
|
|
4901
|
+
*/
|
|
4902
|
+
tap(callback) {
|
|
4903
|
+
callback(this);
|
|
4904
|
+
return this;
|
|
4905
|
+
}
|
|
4906
|
+
/** Pass the relation into a callback and return its result. */
|
|
4907
|
+
pipe(callback) {
|
|
4908
|
+
return callback(this);
|
|
4855
4909
|
}
|
|
4856
4910
|
/**
|
|
4857
4911
|
* Adds a null check for a key.
|
|
@@ -4872,6 +4926,24 @@ var Relation = class {
|
|
|
4872
4926
|
return this.constrain((query) => query.whereNotNull(key));
|
|
4873
4927
|
}
|
|
4874
4928
|
/**
|
|
4929
|
+
* Adds an OR null check for a key.
|
|
4930
|
+
*
|
|
4931
|
+
* @param key
|
|
4932
|
+
* @returns
|
|
4933
|
+
*/
|
|
4934
|
+
orWhereNull(key) {
|
|
4935
|
+
return this.constrain((query) => query.orWhereNull(key));
|
|
4936
|
+
}
|
|
4937
|
+
/**
|
|
4938
|
+
* Adds an OR not-null check for a key.
|
|
4939
|
+
*
|
|
4940
|
+
* @param key
|
|
4941
|
+
* @returns
|
|
4942
|
+
*/
|
|
4943
|
+
orWhereNotNull(key) {
|
|
4944
|
+
return this.constrain((query) => query.orWhereNotNull(key));
|
|
4945
|
+
}
|
|
4946
|
+
/**
|
|
4875
4947
|
* Adds a between range clause for a key.
|
|
4876
4948
|
*
|
|
4877
4949
|
* @param key
|
|
@@ -5321,6 +5393,140 @@ var Relation = class {
|
|
|
5321
5393
|
return this.constrain((query) => query.with(relations));
|
|
5322
5394
|
}
|
|
5323
5395
|
/**
|
|
5396
|
+
* Add a relationship count/existence constraint to the related query.
|
|
5397
|
+
*
|
|
5398
|
+
* @param relation
|
|
5399
|
+
* @param operator
|
|
5400
|
+
* @param count
|
|
5401
|
+
* @param callback
|
|
5402
|
+
* @returns
|
|
5403
|
+
*/
|
|
5404
|
+
has(relation, operator = ">=", count = 1, callback) {
|
|
5405
|
+
return this.constrain((query) => query.has(relation, operator, count, callback));
|
|
5406
|
+
}
|
|
5407
|
+
/**
|
|
5408
|
+
* Add an OR relationship count/existence constraint to the related query.
|
|
5409
|
+
*
|
|
5410
|
+
* @param relation
|
|
5411
|
+
* @param operator
|
|
5412
|
+
* @param count
|
|
5413
|
+
* @returns
|
|
5414
|
+
*/
|
|
5415
|
+
orHas(relation, operator = ">=", count = 1) {
|
|
5416
|
+
return this.constrain((query) => query.orHas(relation, operator, count));
|
|
5417
|
+
}
|
|
5418
|
+
/**
|
|
5419
|
+
* Require the related query's model to have a nested relationship.
|
|
5420
|
+
*
|
|
5421
|
+
* @param relation
|
|
5422
|
+
* @param callback
|
|
5423
|
+
* @param operator
|
|
5424
|
+
* @param count
|
|
5425
|
+
* @returns
|
|
5426
|
+
*/
|
|
5427
|
+
whereHas(relation, callback, operator = ">=", count = 1) {
|
|
5428
|
+
return this.constrain((query) => query.whereHas(relation, callback, operator, count));
|
|
5429
|
+
}
|
|
5430
|
+
/**
|
|
5431
|
+
* Add an OR nested relationship constraint to the related query.
|
|
5432
|
+
*
|
|
5433
|
+
* @param relation
|
|
5434
|
+
* @param callback
|
|
5435
|
+
* @param operator
|
|
5436
|
+
* @param count
|
|
5437
|
+
* @returns
|
|
5438
|
+
*/
|
|
5439
|
+
orWhereHas(relation, callback, operator = ">=", count = 1) {
|
|
5440
|
+
return this.constrain((query) => query.orWhereHas(relation, callback, operator, count));
|
|
5441
|
+
}
|
|
5442
|
+
/**
|
|
5443
|
+
* Require the related query's model not to have a nested relationship.
|
|
5444
|
+
*
|
|
5445
|
+
* @param relation
|
|
5446
|
+
* @param callback
|
|
5447
|
+
* @returns
|
|
5448
|
+
*/
|
|
5449
|
+
doesntHave(relation, callback) {
|
|
5450
|
+
return this.constrain((query) => query.doesntHave(relation, callback));
|
|
5451
|
+
}
|
|
5452
|
+
/**
|
|
5453
|
+
* Add an OR nested relationship absence constraint.
|
|
5454
|
+
*
|
|
5455
|
+
* @param relation
|
|
5456
|
+
* @returns
|
|
5457
|
+
*/
|
|
5458
|
+
orDoesntHave(relation) {
|
|
5459
|
+
return this.constrain((query) => query.orDoesntHave(relation));
|
|
5460
|
+
}
|
|
5461
|
+
/**
|
|
5462
|
+
* Require a constrained nested relationship to be absent.
|
|
5463
|
+
*
|
|
5464
|
+
* @param relation
|
|
5465
|
+
* @param callback
|
|
5466
|
+
* @returns
|
|
5467
|
+
*/
|
|
5468
|
+
whereDoesntHave(relation, callback) {
|
|
5469
|
+
return this.constrain((query) => query.whereDoesntHave(relation, callback));
|
|
5470
|
+
}
|
|
5471
|
+
/**
|
|
5472
|
+
* Add an OR constrained nested relationship absence clause.
|
|
5473
|
+
*
|
|
5474
|
+
* @param relation
|
|
5475
|
+
* @param callback
|
|
5476
|
+
* @returns
|
|
5477
|
+
*/
|
|
5478
|
+
orWhereDoesntHave(relation, callback) {
|
|
5479
|
+
return this.constrain((query) => query.orWhereDoesntHave(relation, callback));
|
|
5480
|
+
}
|
|
5481
|
+
/**
|
|
5482
|
+
* Add a constrained polymorphic nested relationship clause.
|
|
5483
|
+
*
|
|
5484
|
+
* @param relation
|
|
5485
|
+
* @param types
|
|
5486
|
+
* @param callback
|
|
5487
|
+
* @param operator
|
|
5488
|
+
* @param count
|
|
5489
|
+
* @returns
|
|
5490
|
+
*/
|
|
5491
|
+
whereHasMorph(relation, types, callback, operator = ">=", count = 1) {
|
|
5492
|
+
return this.constrain((query) => query.whereHasMorph(relation, types, callback, operator, count));
|
|
5493
|
+
}
|
|
5494
|
+
/**
|
|
5495
|
+
* Add an OR constrained polymorphic nested relationship clause.
|
|
5496
|
+
*
|
|
5497
|
+
* @param relation
|
|
5498
|
+
* @param types
|
|
5499
|
+
* @param callback
|
|
5500
|
+
* @param operator
|
|
5501
|
+
* @param count
|
|
5502
|
+
* @returns
|
|
5503
|
+
*/
|
|
5504
|
+
orWhereHasMorph(relation, types, callback, operator = ">=", count = 1) {
|
|
5505
|
+
return this.constrain((query) => query.orWhereHasMorph(relation, types, callback, operator, count));
|
|
5506
|
+
}
|
|
5507
|
+
/**
|
|
5508
|
+
* Require a constrained polymorphic nested relationship to be absent.
|
|
5509
|
+
*
|
|
5510
|
+
* @param relation
|
|
5511
|
+
* @param types
|
|
5512
|
+
* @param callback
|
|
5513
|
+
* @returns
|
|
5514
|
+
*/
|
|
5515
|
+
whereDoesntHaveMorph(relation, types, callback) {
|
|
5516
|
+
return this.constrain((query) => query.whereDoesntHaveMorph(relation, types, callback));
|
|
5517
|
+
}
|
|
5518
|
+
/**
|
|
5519
|
+
* Add an OR polymorphic nested relationship absence clause.
|
|
5520
|
+
*
|
|
5521
|
+
* @param relation
|
|
5522
|
+
* @param types
|
|
5523
|
+
* @param callback
|
|
5524
|
+
* @returns
|
|
5525
|
+
*/
|
|
5526
|
+
orWhereDoesntHaveMorph(relation, types, callback) {
|
|
5527
|
+
return this.constrain((query) => query.orWhereDoesntHaveMorph(relation, types, callback));
|
|
5528
|
+
}
|
|
5529
|
+
/**
|
|
5324
5530
|
* Add relationship count aggregates to the related-model query.
|
|
5325
5531
|
*
|
|
5326
5532
|
* @param relations
|
|
@@ -6355,11 +6561,13 @@ var BelongsToManyRelation = class BelongsToManyRelation extends Relation {
|
|
|
6355
6561
|
});
|
|
6356
6562
|
decorated.paginate = (async (perPage = 15, page, options = {}) => {
|
|
6357
6563
|
const paginator = await originalPaginate(perPage, page, options);
|
|
6358
|
-
|
|
6564
|
+
const data = this.attachPivotToResults(paginator.data, pivotRows);
|
|
6565
|
+
return new LengthAwarePaginator(data, paginator.meta.total, paginator.meta.perPage, paginator.meta.currentPage, options);
|
|
6359
6566
|
});
|
|
6360
6567
|
decorated.simplePaginate = (async (perPage = 15, page, options = {}) => {
|
|
6361
6568
|
const paginator = await originalSimplePaginate(perPage, page, options);
|
|
6362
|
-
|
|
6569
|
+
const data = this.attachPivotToResults(paginator.data, pivotRows);
|
|
6570
|
+
return new Paginator(data, paginator.meta.perPage, paginator.meta.currentPage, paginator.meta.hasMorePages, options);
|
|
6363
6571
|
});
|
|
6364
6572
|
decorated.clone = (() => {
|
|
6365
6573
|
return this.decorateQueryBuilder(originalClone(), pivotRows);
|