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
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { Application, Command, Kernel } from "@h3ravel/musket";
|
|
2
3
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
3
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
5
|
import { AsyncLocalStorage } from "async_hooks";
|
|
@@ -13,7 +14,6 @@ import { str } from "@h3ravel/support";
|
|
|
13
14
|
import { AsyncLocalStorage as AsyncLocalStorage$1 } from "node:async_hooks";
|
|
14
15
|
import { spawnSync } from "node:child_process";
|
|
15
16
|
import { Logger } from "@h3ravel/shared";
|
|
16
|
-
import { Command, Kernel } from "@h3ravel/musket";
|
|
17
17
|
|
|
18
18
|
//#region src/Exceptions/ArkormException.ts
|
|
19
19
|
var ArkormException = class extends Error {
|
|
@@ -474,7 +474,8 @@ const readPersistedColumnMappingsState = (filePath) => {
|
|
|
474
474
|
return empty;
|
|
475
475
|
}
|
|
476
476
|
try {
|
|
477
|
-
const
|
|
477
|
+
const parsed = JSON.parse(readFileSync(filePath, "utf-8"));
|
|
478
|
+
const normalized = normalizePersistedColumnMappingsState(parsed);
|
|
478
479
|
cachedColumnMappingsPath = filePath;
|
|
479
480
|
cachedColumnMappingsState = normalized;
|
|
480
481
|
return normalized;
|
|
@@ -985,7 +986,8 @@ const loadRuntimeConfigSync = () => {
|
|
|
985
986
|
for (const configPath of syncConfigPaths) {
|
|
986
987
|
if (!existsSync$1(configPath)) continue;
|
|
987
988
|
try {
|
|
988
|
-
|
|
989
|
+
const imported = require(configPath);
|
|
990
|
+
resolveAndApplyConfig(imported);
|
|
989
991
|
return true;
|
|
990
992
|
} catch {
|
|
991
993
|
continue;
|
|
@@ -1013,7 +1015,8 @@ const loadArkormConfig = async () => {
|
|
|
1013
1015
|
for (const configPath of configPaths) {
|
|
1014
1016
|
if (!existsSync$1(configPath)) continue;
|
|
1015
1017
|
try {
|
|
1016
|
-
|
|
1018
|
+
const imported = await importConfigFile(configPath);
|
|
1019
|
+
resolveAndApplyConfig(imported);
|
|
1017
1020
|
await awaitConfiguredModelsRegistration();
|
|
1018
1021
|
return;
|
|
1019
1022
|
} catch {
|
|
@@ -1059,6 +1062,8 @@ const getRuntimeAdapter = () => {
|
|
|
1059
1062
|
* processes (the CLI) so the Node event loop drains and the process exits
|
|
1060
1063
|
* promptly instead of hanging on pool idle timeouts. Teardown failures are
|
|
1061
1064
|
* swallowed because the process is shutting down anyway.
|
|
1065
|
+
*
|
|
1066
|
+
* @returns
|
|
1062
1067
|
*/
|
|
1063
1068
|
const disposeArkormRuntime = async () => {
|
|
1064
1069
|
let adapterDisposed = false;
|
|
@@ -1488,7 +1493,8 @@ const expressionBuilder = {
|
|
|
1488
1493
|
*/
|
|
1489
1494
|
const resolveGeneratedExpression = (expression) => {
|
|
1490
1495
|
if (typeof expression === "string") return expression;
|
|
1491
|
-
|
|
1496
|
+
const built = expression(expressionBuilder);
|
|
1497
|
+
return expressionNodeToSql(built.toExpressionNode());
|
|
1492
1498
|
};
|
|
1493
1499
|
const quoteIdentifier = (name) => name.split(".").map((part) => `"${part.replace(/"/g, "\"\"")}"`).join(".");
|
|
1494
1500
|
const quoteLiteral = (value) => {
|
|
@@ -2971,7 +2977,8 @@ const applyCreateTableOperation = (schema, operation) => {
|
|
|
2971
2977
|
if (findModelBlock(schema, operation.table)) throw new ArkormException(`Prisma model for table [${operation.table}] already exists.`);
|
|
2972
2978
|
const schemaWithEnums = ensureEnumBlocks(schema, operation.columns);
|
|
2973
2979
|
const block = buildModelBlock(operation);
|
|
2974
|
-
|
|
2980
|
+
const nextSchema = `${schemaWithEnums.trimEnd()}\n\n${block}\n`;
|
|
2981
|
+
return applyInverseRelations(nextSchema, toModelName(operation.table), operation.foreignKeys ?? [], operation.columns);
|
|
2975
2982
|
};
|
|
2976
2983
|
/**
|
|
2977
2984
|
* Apply an alter table operation to a Prisma schema string, modifying the model
|
|
@@ -2984,7 +2991,8 @@ const applyCreateTableOperation = (schema, operation) => {
|
|
|
2984
2991
|
const applyAlterTableOperation = (schema, operation) => {
|
|
2985
2992
|
const model = findModelBlock(schema, operation.table);
|
|
2986
2993
|
if (!model) throw new ArkormException(`Prisma model for table [${operation.table}] was not found.`);
|
|
2987
|
-
const
|
|
2994
|
+
const enumColumns = [...operation.addColumns, ...operation.changeColumns ?? []];
|
|
2995
|
+
const schemaWithEnums = ensureEnumBlocks(schema, enumColumns);
|
|
2988
2996
|
const refreshedModel = findModelBlock(schemaWithEnums, operation.table);
|
|
2989
2997
|
if (!refreshedModel) throw new ArkormException(`Prisma model for table [${operation.table}] was not found.`);
|
|
2990
2998
|
let block = refreshedModel.block;
|
|
@@ -3036,7 +3044,8 @@ const applyAlterTableOperation = (schema, operation) => {
|
|
|
3036
3044
|
injectLineIntoModelBody(bodyLines, relationLine, (line) => relationRegex.test(line));
|
|
3037
3045
|
}
|
|
3038
3046
|
block = bodyLines.join("\n");
|
|
3039
|
-
|
|
3047
|
+
const nextSchema = `${schemaWithEnums.slice(0, refreshedModel.start)}${block}${schemaWithEnums.slice(refreshedModel.end)}`;
|
|
3048
|
+
return applyInverseRelations(nextSchema, model.modelName, operation.addForeignKeys ?? [], operation.addColumns);
|
|
3040
3049
|
};
|
|
3041
3050
|
/**
|
|
3042
3051
|
* Apply a drop table operation to a Prisma schema string, removing the model block
|
|
@@ -3857,12 +3866,18 @@ const createPrismaCompatibilityAdapter = createPrismaDatabaseAdapter;
|
|
|
3857
3866
|
* @author Legacy (3m1n3nc3)
|
|
3858
3867
|
* @since 0.1.0
|
|
3859
3868
|
*/
|
|
3860
|
-
var CliApp = class {
|
|
3869
|
+
var CliApp = class extends Application {
|
|
3861
3870
|
constructor() {
|
|
3871
|
+
super();
|
|
3862
3872
|
this.config = {};
|
|
3863
3873
|
this.getConfig = getUserConfig;
|
|
3864
3874
|
this.config = getUserConfig();
|
|
3865
3875
|
}
|
|
3876
|
+
registerMusketListeners(musket) {
|
|
3877
|
+
musket.afterHandle.on(async () => {
|
|
3878
|
+
await disposeArkormRuntime();
|
|
3879
|
+
});
|
|
3880
|
+
}
|
|
3866
3881
|
isUsingPrismaAdapter() {
|
|
3867
3882
|
return this.getConfig("adapter") instanceof PrismaDatabaseAdapter;
|
|
3868
3883
|
}
|
|
@@ -3999,7 +4014,8 @@ var CliApp = class {
|
|
|
3999
4014
|
* @returns
|
|
4000
4015
|
*/
|
|
4001
4016
|
resolveStubPath(stubName) {
|
|
4002
|
-
|
|
4017
|
+
const stubsDir = this.resolveConfigPath("stubs", getDefaultStubsPath());
|
|
4018
|
+
return join$1(stubsDir, stubName);
|
|
4003
4019
|
}
|
|
4004
4020
|
/**
|
|
4005
4021
|
* Generate a factory file for a given model name.
|
|
@@ -4013,7 +4029,8 @@ var CliApp = class {
|
|
|
4013
4029
|
const factoryName = `${baseName}Factory`;
|
|
4014
4030
|
const modelName = options.modelName ? str(options.modelName).pascal() : baseName;
|
|
4015
4031
|
const outputExt = this.resolveOutputExt();
|
|
4016
|
-
const
|
|
4032
|
+
const factoriesDir = this.resolveConfigPath("factories", join$1(process.cwd(), "database", "factories"));
|
|
4033
|
+
const outputPath = join$1(factoriesDir, `${factoryName}.${outputExt}`);
|
|
4017
4034
|
const modelPath = join$1(this.resolveConfigPath("models", join$1(process.cwd(), "src", "models")), `${modelName}.${outputExt}`);
|
|
4018
4035
|
const relativeImport = options.modelImportPath ?? `./${this.stripKnownSourceExtension(relative(dirname$1(outputPath), modelPath).replace(/\\/g, "/"))}${outputExt === "js" ? ".js" : ""}`;
|
|
4019
4036
|
const stubPath = this.resolveStubPath(outputExt === "js" ? "factory.js.stub" : "factory.stub");
|
|
@@ -4036,7 +4053,8 @@ var CliApp = class {
|
|
|
4036
4053
|
makeSeeder(name, options = {}) {
|
|
4037
4054
|
const seederName = `${str(name.replace(/Seeder$/, "")).pascal()}Seeder`;
|
|
4038
4055
|
const outputExt = this.resolveOutputExt();
|
|
4039
|
-
const
|
|
4056
|
+
const seedersDir = this.resolveConfigPath("seeders", join$1(process.cwd(), "database", "seeders"));
|
|
4057
|
+
const outputPath = join$1(seedersDir, `${seederName}.${outputExt}`);
|
|
4040
4058
|
const stubPath = this.resolveStubPath(outputExt === "js" ? "seeder.js.stub" : "seeder.stub");
|
|
4041
4059
|
return {
|
|
4042
4060
|
name: seederName,
|
|
@@ -4050,8 +4068,9 @@ var CliApp = class {
|
|
|
4050
4068
|
* @returns An object containing the name and path of the generated migration file.
|
|
4051
4069
|
*/
|
|
4052
4070
|
makeMigration(name) {
|
|
4071
|
+
const migrationsDir = this.resolveConfigPath("migrations", join$1(process.cwd(), "database", "migrations"));
|
|
4053
4072
|
const generated = generateMigrationFile(name, {
|
|
4054
|
-
directory:
|
|
4073
|
+
directory: migrationsDir,
|
|
4055
4074
|
extension: this.resolveOutputExt()
|
|
4056
4075
|
});
|
|
4057
4076
|
return {
|
|
@@ -4071,7 +4090,8 @@ var CliApp = class {
|
|
|
4071
4090
|
const modelName = `${baseName}`;
|
|
4072
4091
|
const tableName = str(baseName).camel().plural().toString();
|
|
4073
4092
|
const outputExt = this.resolveOutputExt();
|
|
4074
|
-
const
|
|
4093
|
+
const modelsDir = this.resolveConfigPath("models", join$1(process.cwd(), "src", "models"));
|
|
4094
|
+
const outputPath = join$1(modelsDir, `${modelName}.${outputExt}`);
|
|
4075
4095
|
const shouldBuildFactory = options.all || options.factory;
|
|
4076
4096
|
const shouldBuildSeeder = options.all || options.seeder;
|
|
4077
4097
|
const shouldBuildMigration = options.all || options.migration;
|
|
@@ -4125,7 +4145,7 @@ var CliApp = class {
|
|
|
4125
4145
|
path: schemaPath,
|
|
4126
4146
|
updated: false
|
|
4127
4147
|
};
|
|
4128
|
-
|
|
4148
|
+
const updated = applyCreateTableOperation(source, {
|
|
4129
4149
|
type: "createTable",
|
|
4130
4150
|
table: tableName,
|
|
4131
4151
|
columns: [{
|
|
@@ -4135,7 +4155,8 @@ var CliApp = class {
|
|
|
4135
4155
|
}],
|
|
4136
4156
|
indexes: [],
|
|
4137
4157
|
foreignKeys: []
|
|
4138
|
-
})
|
|
4158
|
+
});
|
|
4159
|
+
writeFileSync$1(schemaPath, updated);
|
|
4139
4160
|
return {
|
|
4140
4161
|
path: schemaPath,
|
|
4141
4162
|
updated: true
|
|
@@ -4333,7 +4354,7 @@ var CliApp = class {
|
|
|
4333
4354
|
const existingImport = modelSource.match(importRegex);
|
|
4334
4355
|
if (existingImport) {
|
|
4335
4356
|
const existingTypes = existingImport[1].split(",").map((value) => value.trim()).filter(Boolean);
|
|
4336
|
-
const mergedTypes = [
|
|
4357
|
+
const mergedTypes = [.../* @__PURE__ */ new Set([...existingTypes, ...enumTypes])].sort((left, right) => left.localeCompare(right));
|
|
4337
4358
|
return modelSource.replace(importRegex, `import type { ${mergedTypes.join(", ")} } from '@prisma/client'`);
|
|
4338
4359
|
}
|
|
4339
4360
|
const lines = modelSource.split("\n");
|
|
@@ -4381,7 +4402,8 @@ var CliApp = class {
|
|
|
4381
4402
|
return readdirSync$1(modelsDir).filter((file) => file.endsWith(".ts")).map((file) => join$1(modelsDir, file));
|
|
4382
4403
|
}
|
|
4383
4404
|
syncModelRegistryTypes(modelFiles) {
|
|
4384
|
-
const
|
|
4405
|
+
const cwd = realpathSync(process.cwd());
|
|
4406
|
+
const registryDir = join$1(cwd, ".arkormx");
|
|
4385
4407
|
const registryPath = join$1(registryDir, "models.d.ts");
|
|
4386
4408
|
const models = modelFiles.map((filePath) => {
|
|
4387
4409
|
const parsed = this.parseModelSyncSource(readFileSync$1(filePath, "utf-8"));
|
|
@@ -4500,7 +4522,7 @@ var CliApp = class {
|
|
|
4500
4522
|
const models = [];
|
|
4501
4523
|
const enumDefinitions = this.parsePrismaEnums(schema);
|
|
4502
4524
|
const modelRegex = /model\s+(\w+)\s*\{([\s\S]*?)\n\}/g;
|
|
4503
|
-
const scalarTypes = new Set([
|
|
4525
|
+
const scalarTypes = /* @__PURE__ */ new Set([
|
|
4504
4526
|
"Int",
|
|
4505
4527
|
"Float",
|
|
4506
4528
|
"Decimal",
|
|
@@ -5164,12 +5186,15 @@ var MigrateCommand = class extends Command {
|
|
|
5164
5186
|
}
|
|
5165
5187
|
if (!useDatabaseMigrations && !this.option("skip-generate")) runPrismaCommand(["generate"], process.cwd());
|
|
5166
5188
|
if (!useDatabaseMigrations && !this.option("skip-migrate")) if (this.option("deploy")) runPrismaCommand(["migrate", "deploy"], process.cwd());
|
|
5167
|
-
else
|
|
5168
|
-
"
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5189
|
+
else {
|
|
5190
|
+
const name = this.option("migration-name") ? String(this.option("migration-name")) : `arkorm_cli_${Date.now()}`;
|
|
5191
|
+
runPrismaCommand([
|
|
5192
|
+
"migrate",
|
|
5193
|
+
"dev",
|
|
5194
|
+
"--name",
|
|
5195
|
+
name
|
|
5196
|
+
], process.cwd());
|
|
5197
|
+
}
|
|
5173
5198
|
this.success(`Applied ${pending.length} migration(s).`);
|
|
5174
5199
|
pending.forEach(([_, file]) => this.success(this.app.splitLogger("Migrated", file)));
|
|
5175
5200
|
this.syncModelRegistryIfRequested();
|
|
@@ -5326,7 +5351,8 @@ var MigrateFreshCommand = class extends Command {
|
|
|
5326
5351
|
if (!(await this.runWithDatabaseCreationRetry(adapter, () => adapter.resetDatabase())).ok) return;
|
|
5327
5352
|
} else {
|
|
5328
5353
|
if (!existsSync(schemaPath)) return void this.error(`Error: Prisma schema file not found: ${this.app.formatPathForLog(schemaPath)}`);
|
|
5329
|
-
|
|
5354
|
+
const source = readFileSync(schemaPath, "utf-8");
|
|
5355
|
+
writeFileSync(schemaPath, stripPrismaSchemaModelsAndEnums(source));
|
|
5330
5356
|
}
|
|
5331
5357
|
let appliedState = createEmptyAppliedMigrationsState();
|
|
5332
5358
|
if (!(await this.runWithDatabaseCreationRetry(adapter, () => writeAppliedMigrationsStateToStore(adapter, stateFilePath, appliedState))).ok) return;
|
|
@@ -5511,12 +5537,15 @@ var MigrateRollbackCommand = class extends Command {
|
|
|
5511
5537
|
}
|
|
5512
5538
|
if (!useDatabaseMigrations && !this.option("skip-generate")) runPrismaCommand(["generate"], process.cwd());
|
|
5513
5539
|
if (!useDatabaseMigrations && !this.option("skip-migrate")) if (this.option("deploy")) runPrismaCommand(["migrate", "deploy"], process.cwd());
|
|
5514
|
-
else
|
|
5515
|
-
"
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5540
|
+
else {
|
|
5541
|
+
const name = this.option("migration-name") ? String(this.option("migration-name")) : `arkorm_cli_rollback_${Date.now()}`;
|
|
5542
|
+
runPrismaCommand([
|
|
5543
|
+
"migrate",
|
|
5544
|
+
"dev",
|
|
5545
|
+
"--name",
|
|
5546
|
+
name
|
|
5547
|
+
], process.cwd());
|
|
5548
|
+
}
|
|
5520
5549
|
this.success(`Rolled back ${rollbackClasses.length} migration(s).`);
|
|
5521
5550
|
rollbackClasses.forEach(([_, file]) => this.success(this.app.splitLogger("RolledBack", file)));
|
|
5522
5551
|
}
|
|
@@ -5819,31 +5848,27 @@ var logo_default = String.raw`
|
|
|
5819
5848
|
//#endregion
|
|
5820
5849
|
//#region src/cli/index.ts
|
|
5821
5850
|
const app = new CliApp();
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
});
|
|
5844
|
-
} finally {
|
|
5845
|
-
await disposeArkormRuntime();
|
|
5846
|
-
}
|
|
5851
|
+
await Kernel.init(app, {
|
|
5852
|
+
logo: logo_default,
|
|
5853
|
+
name: "Arkormˣ CLI",
|
|
5854
|
+
baseCommands: [
|
|
5855
|
+
DbCommand,
|
|
5856
|
+
InitCommand,
|
|
5857
|
+
MakeModelCommand,
|
|
5858
|
+
MakeFactoryCommand,
|
|
5859
|
+
MakeSeederCommand,
|
|
5860
|
+
MakeMigrationCommand,
|
|
5861
|
+
ModelsSyncCommand,
|
|
5862
|
+
SeedCommand,
|
|
5863
|
+
MigrateCommand,
|
|
5864
|
+
MigrateFreshCommand,
|
|
5865
|
+
MigrateRollbackCommand,
|
|
5866
|
+
MigrationHistoryCommand
|
|
5867
|
+
],
|
|
5868
|
+
exceptionHandler(exception) {
|
|
5869
|
+
throw exception;
|
|
5870
|
+
}
|
|
5871
|
+
});
|
|
5847
5872
|
|
|
5848
5873
|
//#endregion
|
|
5849
5874
|
export { };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Kysely, Transaction } from "kysely";
|
|
2
2
|
import { PrismaClient } from "@prisma/client";
|
|
3
3
|
import { Collection } from "@h3ravel/collect.js";
|
|
4
|
-
import { Command } from "@h3ravel/musket";
|
|
5
|
-
|
|
4
|
+
import { Application, Command, Musket } from "@h3ravel/musket";
|
|
6
5
|
//#region src/types/migrations.d.ts
|
|
7
6
|
type SchemaColumnType = 'id' | 'uuid' | 'enum' | 'string' | 'text' | 'integer' | 'bigInteger' | 'float' | 'decimal' | 'boolean' | 'json' | 'date' | 'dateTime' | 'timestamp';
|
|
8
7
|
interface PrimaryKeyGeneration {
|
|
@@ -368,7 +367,7 @@ interface FactoryRelationshipResolver {
|
|
|
368
367
|
getModelConstructor: () => FactoryModelConstructor<unknown>;
|
|
369
368
|
}
|
|
370
369
|
type FactoryAttributeResolver<TAttributes extends FactoryAttributes> = (attributes: TAttributes) => MaybePromise<unknown>;
|
|
371
|
-
type FactoryDefinitionAttributes<TAttributes extends FactoryAttributes> = { [TKey in keyof TAttributes]?: TAttributes[TKey] | FactoryRelationshipResolver | FactoryAttributeResolver<TAttributes
|
|
370
|
+
type FactoryDefinitionAttributes<TAttributes extends FactoryAttributes> = { [TKey in keyof TAttributes]?: TAttributes[TKey] | FactoryRelationshipResolver | FactoryAttributeResolver<TAttributes>; } & Record<string, unknown>;
|
|
372
371
|
type FactoryDefinition<TAttributes extends FactoryAttributes> = (sequence: number) => MaybePromise<FactoryDefinitionAttributes<TAttributes>>;
|
|
373
372
|
type FactoryState<TAttributes extends FactoryAttributes> = (attributes: TAttributes, sequence: number) => MaybePromise<FactoryDefinitionAttributes<TAttributes>>;
|
|
374
373
|
type FactoryCallback<TModel> = (model: TModel) => MaybePromise<void>;
|
|
@@ -579,7 +578,7 @@ type JoinSource = QueryBuilder<any, any> | string;
|
|
|
579
578
|
* A callback that builds a parenthesized group of nested where conditions.
|
|
580
579
|
*/
|
|
581
580
|
type WhereCallback<TModel, TDelegate extends ModelQuerySchemaLike> = (query: QueryBuilder<TModel, TDelegate>) => QueryBuilder<any, any> | void;
|
|
582
|
-
type EagerLoadRelations<TModel> = { [TKey in ModelRelationshipKey<TModel>]?: true | EagerLoadConstraint<EagerLoadQueryForRelationship<TModel, TKey
|
|
581
|
+
type EagerLoadRelations<TModel> = { [TKey in ModelRelationshipKey<TModel>]?: true | EagerLoadConstraint<EagerLoadQueryForRelationship<TModel, TKey>>; };
|
|
583
582
|
//#endregion
|
|
584
583
|
//#region src/types/relationship.d.ts
|
|
585
584
|
type RelationResult = unknown[] | unknown | null;
|
|
@@ -3623,11 +3622,11 @@ declare abstract class Model<TSchema extends ModelQuerySchemaLike | Record<strin
|
|
|
3623
3622
|
interface ArkormModelRegistry {}
|
|
3624
3623
|
interface ArkormModelNameRegistry {}
|
|
3625
3624
|
type LowercaseString<T extends string> = Lowercase<T>;
|
|
3626
|
-
type Simplify<TValue> = { [TKey in keyof TValue]: TValue[TKey] } & {};
|
|
3625
|
+
type Simplify<TValue> = { [TKey in keyof TValue]: TValue[TKey]; } & {};
|
|
3627
3626
|
type ConventionalAutoManagedKeys = 'id' | 'createdAt' | 'updatedAt' | 'deletedAt';
|
|
3628
3627
|
type SingularKey<T extends string> = LowercaseString<T> extends `${infer Base}s` ? Base : LowercaseString<T>;
|
|
3629
3628
|
type PluralKey<T extends string> = `${SingularKey<T>}s`;
|
|
3630
|
-
type PrismaClientDelegates = { [TKey in keyof PrismaClient as PrismaClient[TKey] extends ModelQuerySchemaLike ? TKey : never]: PrismaClient[TKey] };
|
|
3629
|
+
type PrismaClientDelegates = { [TKey in keyof PrismaClient as PrismaClient[TKey] extends ModelQuerySchemaLike ? TKey : never]: PrismaClient[TKey]; };
|
|
3631
3630
|
type DelegateFromPrismaClient<TKey extends string> = LowercaseString<TKey> extends keyof PrismaClientDelegates ? PrismaClientDelegates[LowercaseString<TKey>] : SingularKey<TKey> extends keyof PrismaClientDelegates ? PrismaClientDelegates[SingularKey<TKey>] : PluralKey<TKey> extends keyof PrismaClientDelegates ? PrismaClientDelegates[PluralKey<TKey>] : never;
|
|
3632
3631
|
type AttributeScalarFilter<TValue> = Omit<PrismaLikeScalarFilter, 'equals' | 'not' | 'in' | 'notIn' | 'lt' | 'lte' | 'gt' | 'gte' | 'contains' | 'startsWith' | 'endsWith'> & {
|
|
3633
3632
|
equals?: TValue;
|
|
@@ -3646,11 +3645,11 @@ type AttributeWhereInput<TAttributes extends Record<string, unknown>> = {
|
|
|
3646
3645
|
AND?: AttributeWhereInput<TAttributes>[];
|
|
3647
3646
|
OR?: AttributeWhereInput<TAttributes>[];
|
|
3648
3647
|
NOT?: AttributeWhereInput<TAttributes> | AttributeWhereInput<TAttributes>[];
|
|
3649
|
-
} & { [TKey in keyof TAttributes]?: TAttributes[TKey] | AttributeScalarFilter<NonNullable<TAttributes[TKey]>> | null };
|
|
3648
|
+
} & { [TKey in keyof TAttributes]?: TAttributes[TKey] | AttributeScalarFilter<NonNullable<TAttributes[TKey]>> | null; };
|
|
3650
3649
|
type AttributeOrderBy<TAttributes extends Record<string, unknown>> = Partial<Record<keyof TAttributes & string, PrismaLikeSortOrder>> | Array<Partial<Record<keyof TAttributes & string, PrismaLikeSortOrder>>>;
|
|
3651
|
-
type AttributeSelect<TAttributes extends Record<string, unknown>> = { [TKey in keyof TAttributes]?: boolean };
|
|
3652
|
-
type RequiredCreateKeys<TAttributes extends Record<string, unknown>> = Exclude<{ [TKey in keyof TAttributes]-?: undefined extends TAttributes[TKey] ? never : null extends TAttributes[TKey] ? never : TKey }[keyof TAttributes], ConventionalAutoManagedKeys>;
|
|
3653
|
-
type AtLeastOne<TValue extends Record<string, unknown>> = { [TKey in keyof TValue]-?: Required<Pick<TValue, TKey>> & Partial<Omit<TValue, TKey
|
|
3650
|
+
type AttributeSelect<TAttributes extends Record<string, unknown>> = { [TKey in keyof TAttributes]?: boolean; };
|
|
3651
|
+
type RequiredCreateKeys<TAttributes extends Record<string, unknown>> = Exclude<{ [TKey in keyof TAttributes]-?: undefined extends TAttributes[TKey] ? never : null extends TAttributes[TKey] ? never : TKey; }[keyof TAttributes], ConventionalAutoManagedKeys>;
|
|
3652
|
+
type AtLeastOne<TValue extends Record<string, unknown>> = { [TKey in keyof TValue]-?: Required<Pick<TValue, TKey>> & Partial<Omit<TValue, TKey>>; }[keyof TValue];
|
|
3654
3653
|
type AttributeCreateInput<TAttributes extends Record<string, unknown>> = Simplify<Pick<TAttributes, RequiredCreateKeys<TAttributes>> & Partial<Omit<TAttributes, RequiredCreateKeys<TAttributes>>>>;
|
|
3655
3654
|
type AttributeUpdateInput<TAttributes extends Record<string, unknown>> = AtLeastOne<Partial<TAttributes>>;
|
|
3656
3655
|
interface AttributeQuerySchema<TAttributes extends Record<string, unknown>> extends ModelQuerySchemaLike {
|
|
@@ -3698,8 +3697,8 @@ type AttributeSchemaDelegate<TAttributes extends Record<string, unknown>> = Attr
|
|
|
3698
3697
|
type DelegateForModelSchema<TSchema extends ModelQuerySchemaLike | Record<string, unknown> | string, TAttributes extends Record<string, unknown> = ModelAttributesOf<TSchema>> = QuerySchemaForModel<TSchema, TAttributes>;
|
|
3699
3698
|
type ModelAttributesOf<TSchema extends ModelQuerySchemaLike | Record<string, unknown> | string> = TSchema extends ModelQuerySchemaLike ? QuerySchemaRow<TSchema> extends Record<string, unknown> ? QuerySchemaRow<TSchema> : Record<string, any> : TSchema extends string ? DelegateFromPrismaClient<TSchema> extends ModelQuerySchemaLike ? QuerySchemaRow<DelegateFromPrismaClient<TSchema>> extends Record<string, unknown> ? QuerySchemaRow<DelegateFromPrismaClient<TSchema>> : Record<string, any> : Record<string, any> : TSchema extends Record<string, unknown> ? TSchema : Record<string, any>;
|
|
3700
3699
|
type BaseModelInstance = Model<any, any>;
|
|
3701
|
-
type ModelDeclaredAttributeKey<TModel> = { [TKey in keyof TModel & string]: TKey extends keyof BaseModelInstance ? never : TModel[TKey] extends ((...args: any[]) => any) ? never : TKey }[keyof TModel & string];
|
|
3702
|
-
type ModelDeclaredAttributes<TModel> = { [TKey in ModelDeclaredAttributeKey<TModel>]: TModel[TKey] };
|
|
3700
|
+
type ModelDeclaredAttributeKey<TModel> = { [TKey in keyof TModel & string]: TKey extends keyof BaseModelInstance ? never : TModel[TKey] extends ((...args: any[]) => any) ? never : TKey; }[keyof TModel & string];
|
|
3701
|
+
type ModelDeclaredAttributes<TModel> = { [TKey in ModelDeclaredAttributeKey<TModel>]: TModel[TKey]; };
|
|
3703
3702
|
type ResolveModelAttributes<TModel, TAttributes extends Record<string, unknown>> = [ModelDeclaredAttributeKey<TModel>] extends [never] ? TAttributes : string extends keyof TAttributes ? ModelDeclaredAttributes<TModel> : TAttributes & ModelDeclaredAttributes<TModel>;
|
|
3704
3703
|
type ModelAttributes<TModel> = TModel extends Model<any, infer TAttributes> ? ResolveModelAttributes<TModel, TAttributes> : Record<string, any>;
|
|
3705
3704
|
type QuerySchemaForModelInstance<TModel> = TModel extends Model<infer TSchema, infer TAttributes> ? TSchema extends ModelQuerySchemaLike | string ? QuerySchemaForModel<TSchema, TAttributes> : AttributeQuerySchema<ResolveModelAttributes<TModel, TAttributes>> : ModelQuerySchemaLike;
|
|
@@ -3708,7 +3707,7 @@ type ModelOrderByInput<TModel> = string extends keyof ModelAttributes<TModel> ?
|
|
|
3708
3707
|
type RelationshipResultProvider<TResult = unknown> = {
|
|
3709
3708
|
getResults: (...args: any[]) => Promise<TResult>;
|
|
3710
3709
|
};
|
|
3711
|
-
type ModelRelationshipKey<TModel> = { [TKey in keyof TModel & string]: TKey extends keyof BaseModelInstance ? never : TModel[TKey] extends ((...args: any[]) => infer TReturn) ? Parameters<TModel[TKey]> extends [] ? TReturn extends RelationshipResultProvider<any> ? TKey : never : never : never }[keyof TModel & string];
|
|
3710
|
+
type ModelRelationshipKey<TModel> = { [TKey in keyof TModel & string]: TKey extends keyof BaseModelInstance ? never : TModel[TKey] extends ((...args: any[]) => infer TReturn) ? Parameters<TModel[TKey]> extends [] ? TReturn extends RelationshipResultProvider<any> ? TKey : never : never : never; }[keyof TModel & string];
|
|
3712
3711
|
type ModelRelationshipResult<TModel, TKey extends ModelRelationshipKey<TModel>> = TModel[TKey] extends ((...args: any[]) => infer TReturn) ? TReturn extends RelationshipResultProvider<infer TResult> ? TResult : never : never;
|
|
3713
3712
|
type ModelAttributeValue<TModel, TAttributes extends Record<string, unknown>, TKey extends string> = TKey extends ModelRelationshipKey<TModel> ? ModelRelationshipResult<TModel, TKey> : TKey extends ModelDeclaredAttributeKey<TModel> ? TModel[TKey] : TKey extends keyof TAttributes & string ? TAttributes[TKey] : unknown;
|
|
3714
3713
|
type ModelCreateData<TModel, TDelegate extends ModelQuerySchemaLike> = TModel extends Model<any, infer TAttributes> ? TDelegate extends AttributeQuerySchema<TAttributes> ? AttributeCreateInput<TAttributes> : QuerySchemaCreateData<TDelegate> : QuerySchemaCreateData<TDelegate>;
|
|
@@ -3756,20 +3755,20 @@ interface GroupByAggregateSpec<TModel> {
|
|
|
3756
3755
|
_min?: AggregateColumnMap<TModel>;
|
|
3757
3756
|
_max?: AggregateColumnMap<TModel>;
|
|
3758
3757
|
}
|
|
3759
|
-
type SameTypeAggregate<TModel, TMap> = { [K in keyof TMap]: K extends keyof ModelAttributes<TModel> ? ModelAttributes<TModel>[K] : unknown };
|
|
3758
|
+
type SameTypeAggregate<TModel, TMap> = { [K in keyof TMap]: K extends keyof ModelAttributes<TModel> ? ModelAttributes<TModel>[K] : unknown; };
|
|
3760
3759
|
/** The typed plain row returned for a {@link GroupByAggregateSpec} query. */
|
|
3761
|
-
type GroupByAggregateRow<TModel, TSpec extends GroupByAggregateSpec<TModel>> = { [K in TSpec['by'][number]]: K extends keyof ModelAttributes<TModel> ? ModelAttributes<TModel>[K] : unknown } & (TSpec extends {
|
|
3760
|
+
type GroupByAggregateRow<TModel, TSpec extends GroupByAggregateSpec<TModel>> = { [K in TSpec['by'][number]]: K extends keyof ModelAttributes<TModel> ? ModelAttributes<TModel>[K] : unknown; } & (TSpec extends {
|
|
3762
3761
|
_count: infer C;
|
|
3763
3762
|
} ? {
|
|
3764
|
-
_count: C extends AggregateColumnMap<TModel> ? { [K in keyof C]: number } : number;
|
|
3763
|
+
_count: C extends AggregateColumnMap<TModel> ? { [K in keyof C]: number; } : number;
|
|
3765
3764
|
} : object) & (TSpec extends {
|
|
3766
3765
|
_sum: infer S;
|
|
3767
3766
|
} ? {
|
|
3768
|
-
_sum: { [K in keyof S]: number | null };
|
|
3767
|
+
_sum: { [K in keyof S]: number | null; };
|
|
3769
3768
|
} : object) & (TSpec extends {
|
|
3770
3769
|
_avg: infer A;
|
|
3771
3770
|
} ? {
|
|
3772
|
-
_avg: { [K in keyof A]: number | null };
|
|
3771
|
+
_avg: { [K in keyof A]: number | null; };
|
|
3773
3772
|
} : object) & (TSpec extends {
|
|
3774
3773
|
_min: infer M;
|
|
3775
3774
|
} ? {
|
|
@@ -3901,6 +3900,23 @@ declare class QueryBuilder<TModel, TDelegate extends ModelQuerySchemaLike = Mode
|
|
|
3901
3900
|
* @returns
|
|
3902
3901
|
*/
|
|
3903
3902
|
whereNotNull<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
|
|
3903
|
+
/**
|
|
3904
|
+
* Adds an OR null check for a key.
|
|
3905
|
+
*
|
|
3906
|
+
* The OR counterpart of {@link whereNull}, so a null check can be combined
|
|
3907
|
+
* inside a grouped `where` callback, e.g. `q.whereFuture('expiresAt').orWhereNull('expiresAt')`.
|
|
3908
|
+
*
|
|
3909
|
+
* @param key
|
|
3910
|
+
* @returns
|
|
3911
|
+
*/
|
|
3912
|
+
orWhereNull<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
|
|
3913
|
+
/**
|
|
3914
|
+
* Adds an OR not-null check for a key. The OR counterpart of {@link whereNotNull}.
|
|
3915
|
+
*
|
|
3916
|
+
* @param key
|
|
3917
|
+
* @returns
|
|
3918
|
+
*/
|
|
3919
|
+
orWhereNotNull<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
|
|
3904
3920
|
/**
|
|
3905
3921
|
* Adds a between range clause for a key.
|
|
3906
3922
|
*
|
|
@@ -6981,8 +6997,8 @@ declare class Attribute<TGet = unknown, TSet = unknown> {
|
|
|
6981
6997
|
//#region src/casts.d.ts
|
|
6982
6998
|
declare function resolveCast(definition: CastDefinition): CastHandler;
|
|
6983
6999
|
//#endregion
|
|
6984
|
-
//#region src/cli
|
|
6985
|
-
|
|
7000
|
+
//#region src/types/cli.d.ts
|
|
7001
|
+
interface SyncedModelsResult {
|
|
6986
7002
|
source: 'adapter' | 'prisma' | 'registry';
|
|
6987
7003
|
schemaPath?: string;
|
|
6988
7004
|
modelsDir: string;
|
|
@@ -6990,14 +7006,16 @@ type SyncedModelsResult = {
|
|
|
6990
7006
|
total: number;
|
|
6991
7007
|
updated: string[];
|
|
6992
7008
|
skipped: string[];
|
|
6993
|
-
}
|
|
7009
|
+
}
|
|
7010
|
+
//#endregion
|
|
7011
|
+
//#region src/cli/CliApp.d.ts
|
|
6994
7012
|
/**
|
|
6995
7013
|
* Main application class for the Arkormˣ CLI.
|
|
6996
7014
|
*
|
|
6997
7015
|
* @author Legacy (3m1n3nc3)
|
|
6998
7016
|
* @since 0.1.0
|
|
6999
7017
|
*/
|
|
7000
|
-
declare class CliApp {
|
|
7018
|
+
declare class CliApp extends Application {
|
|
7001
7019
|
command: Command;
|
|
7002
7020
|
protected config: Partial<ArkormConfig>;
|
|
7003
7021
|
constructor();
|
|
@@ -7008,6 +7026,7 @@ declare class CliApp {
|
|
|
7008
7026
|
* @returns The entire configuration object or the value of the specified key
|
|
7009
7027
|
*/
|
|
7010
7028
|
getConfig: GetUserConfig;
|
|
7029
|
+
registerMusketListeners(musket: Musket<this>): void;
|
|
7011
7030
|
private isUsingPrismaAdapter;
|
|
7012
7031
|
/**
|
|
7013
7032
|
* Utility to ensure directory exists
|
|
@@ -8733,6 +8752,8 @@ declare const getRuntimeAdapter: () => DatabaseAdapter | undefined;
|
|
|
8733
8752
|
* processes (the CLI) so the Node event loop drains and the process exits
|
|
8734
8753
|
* promptly instead of hanging on pool idle timeouts. Teardown failures are
|
|
8735
8754
|
* swallowed because the process is shutting down anyway.
|
|
8755
|
+
*
|
|
8756
|
+
* @returns
|
|
8736
8757
|
*/
|
|
8737
8758
|
declare const disposeArkormRuntime: () => Promise<void>;
|
|
8738
8759
|
declare const getActiveTransactionClient: () => RuntimeClientLike | undefined;
|
|
@@ -8767,7 +8788,7 @@ declare const isQuerySchemaLike: (value: unknown) => value is ModelQuerySchemaLi
|
|
|
8767
8788
|
declare const isDelegateLike: (value: unknown) => value is ModelQuerySchemaLike;
|
|
8768
8789
|
//#endregion
|
|
8769
8790
|
//#region src/helpers/prisma.d.ts
|
|
8770
|
-
type PrismaDelegateMap<TClient extends RuntimeClientLike> = { [K in keyof TClient as TClient[K] extends ModelQuerySchemaLike ? K : never]: TClient[K] extends ModelQuerySchemaLike ? TClient[K] : never };
|
|
8791
|
+
type PrismaDelegateMap<TClient extends RuntimeClientLike> = { [K in keyof TClient as TClient[K] extends ModelQuerySchemaLike ? K : never]: TClient[K] extends ModelQuerySchemaLike ? TClient[K] : never; };
|
|
8771
8792
|
/**
|
|
8772
8793
|
* Compatibility-only helper that exposes Prisma query schemas as a plain object map.
|
|
8773
8794
|
* It is retained for migration support and tests, not as a supported runtime bootstrap path.
|