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 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 normalized = normalizePersistedColumnMappingsState(JSON.parse(readFileSync(filePath, "utf-8")));
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
- resolveAndApplyConfig(require(configPath));
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
- resolveAndApplyConfig(await importConfigFile(configPath));
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
- return expressionNodeToSql(expression(expressionBuilder).toExpressionNode());
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
- return applyInverseRelations(`${schemaWithEnums.trimEnd()}\n\n${block}\n`, toModelName(operation.table), operation.foreignKeys ?? [], operation.columns);
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 schemaWithEnums = ensureEnumBlocks(schema, [...operation.addColumns, ...operation.changeColumns ?? []]);
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
- return applyInverseRelations(`${schemaWithEnums.slice(0, refreshedModel.start)}${block}${schemaWithEnums.slice(refreshedModel.end)}`, model.modelName, operation.addForeignKeys ?? [], operation.addColumns);
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
- return join$1(this.resolveConfigPath("stubs", getDefaultStubsPath()), stubName);
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 outputPath = join$1(this.resolveConfigPath("factories", join$1(process.cwd(), "database", "factories")), `${factoryName}.${outputExt}`);
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 outputPath = join$1(this.resolveConfigPath("seeders", join$1(process.cwd(), "database", "seeders")), `${seederName}.${outputExt}`);
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: this.resolveConfigPath("migrations", join$1(process.cwd(), "database", "migrations")),
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 outputPath = join$1(this.resolveConfigPath("models", join$1(process.cwd(), "src", "models")), `${modelName}.${outputExt}`);
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
- writeFileSync$1(schemaPath, applyCreateTableOperation(source, {
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 = [...new Set([...existingTypes, ...enumTypes])].sort((left, right) => left.localeCompare(right));
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 registryDir = join$1(realpathSync(process.cwd()), ".arkormx");
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 runPrismaCommand([
5168
- "migrate",
5169
- "dev",
5170
- "--name",
5171
- this.option("migration-name") ? String(this.option("migration-name")) : `arkorm_cli_${Date.now()}`
5172
- ], process.cwd());
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
- writeFileSync(schemaPath, stripPrismaSchemaModelsAndEnums(readFileSync(schemaPath, "utf-8")));
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 runPrismaCommand([
5515
- "migrate",
5516
- "dev",
5517
- "--name",
5518
- this.option("migration-name") ? String(this.option("migration-name")) : `arkorm_cli_rollback_${Date.now()}`
5519
- ], process.cwd());
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
- try {
5823
- await Kernel.init(app, {
5824
- logo: logo_default,
5825
- name: "Arkormˣ CLI",
5826
- baseCommands: [
5827
- DbCommand,
5828
- InitCommand,
5829
- MakeModelCommand,
5830
- MakeFactoryCommand,
5831
- MakeSeederCommand,
5832
- MakeMigrationCommand,
5833
- ModelsSyncCommand,
5834
- SeedCommand,
5835
- MigrateCommand,
5836
- MigrateFreshCommand,
5837
- MigrateRollbackCommand,
5838
- MigrationHistoryCommand
5839
- ],
5840
- exceptionHandler(exception) {
5841
- throw exception;
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
- import { Collection } from "@h3ravel/collect.js";
2
1
  import { Kysely, Transaction } from "kysely";
3
- import { Command } from "@h3ravel/musket";
4
2
  import { PrismaClient } from "@prisma/client";
5
-
3
+ import { Collection } from "@h3ravel/collect.js";
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> } & Record<string, unknown>;
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;
@@ -679,6 +678,8 @@ declare abstract class Relation<TModel> {
679
678
  * @returns
680
679
  */
681
680
  where(where: ModelWhereInput<TModel>): this;
681
+ where(callback: (query: QueryBuilder<TModel>) => unknown): this;
682
+ where<TKey extends keyof ModelAttributes<TModel> & string>(column: TKey, value: DatabaseValue): this;
682
683
  /**
683
684
  * Adds an OR where clause to the query.
684
685
  *
@@ -686,6 +687,8 @@ declare abstract class Relation<TModel> {
686
687
  * @returns
687
688
  */
688
689
  orWhere(where: ModelWhereInput<TModel>): this;
690
+ orWhere(callback: (query: QueryBuilder<TModel>) => unknown): this;
691
+ orWhere<TKey extends keyof ModelAttributes<TModel> & string>(column: TKey, value: DatabaseValue): this;
689
692
  /**
690
693
  * Adds a NOT where clause to the query.
691
694
  *
@@ -700,6 +703,36 @@ declare abstract class Relation<TModel> {
700
703
  * @returns
701
704
  */
702
705
  orWhereNot(where: ModelWhereInput<TModel>): this;
706
+ /**
707
+ * Apply a callback when the supplied value is truthy.
708
+ *
709
+ * Keeping this on the relation avoids forcing callers to await `getQuery()`
710
+ * merely to compose optional constraints.
711
+ *
712
+ * @param value
713
+ * @param callback
714
+ * @param defaultCallback
715
+ * @returns
716
+ */
717
+ when<TValue>(value: TValue | (() => TValue), callback: (relation: this, value: TValue) => unknown, defaultCallback?: (relation: this, value: TValue) => unknown): this;
718
+ /**
719
+ * Apply a callback when the supplied value is falsy.
720
+ *
721
+ * @param value
722
+ * @param callback
723
+ * @param defaultCallback
724
+ * @returns
725
+ */
726
+ unless<TValue>(value: TValue | (() => TValue), callback: (relation: this, value: TValue) => unknown, defaultCallback?: (relation: this, value: TValue) => unknown): this;
727
+ /**
728
+ * Pass the relation through a callback and preserve the chain.
729
+ *
730
+ * @param callback
731
+ * @returns
732
+ */
733
+ tap(callback: (relation: this) => unknown): this;
734
+ /** Pass the relation into a callback and return its result. */
735
+ pipe<TResult>(callback: (relation: this) => TResult): TResult;
703
736
  /**
704
737
  * Adds a null check for a key.
705
738
  *
@@ -714,6 +747,20 @@ declare abstract class Relation<TModel> {
714
747
  * @returns
715
748
  */
716
749
  whereNotNull<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
750
+ /**
751
+ * Adds an OR null check for a key.
752
+ *
753
+ * @param key
754
+ * @returns
755
+ */
756
+ orWhereNull<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
757
+ /**
758
+ * Adds an OR not-null check for a key.
759
+ *
760
+ * @param key
761
+ * @returns
762
+ */
763
+ orWhereNotNull<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
717
764
  /**
718
765
  * Adds a between range clause for a key.
719
766
  *
@@ -1130,6 +1177,116 @@ declare abstract class Relation<TModel> {
1130
1177
  * @returns
1131
1178
  */
1132
1179
  with(relations: string | string[] | EagerLoadRelations<TModel>): this;
1180
+ /**
1181
+ * Add a relationship count/existence constraint to the related query.
1182
+ *
1183
+ * @param relation
1184
+ * @param operator
1185
+ * @param count
1186
+ * @param callback
1187
+ * @returns
1188
+ */
1189
+ has(relation: string, operator?: '>=' | '>' | '=' | '!=' | '<=' | '<', count?: number, callback?: (query: QueryBuilder<any, any>) => unknown): this;
1190
+ /**
1191
+ * Add an OR relationship count/existence constraint to the related query.
1192
+ *
1193
+ * @param relation
1194
+ * @param operator
1195
+ * @param count
1196
+ * @returns
1197
+ */
1198
+ orHas(relation: string, operator?: '>=' | '>' | '=' | '!=' | '<=' | '<', count?: number): this;
1199
+ /**
1200
+ * Require the related query's model to have a nested relationship.
1201
+ *
1202
+ * @param relation
1203
+ * @param callback
1204
+ * @param operator
1205
+ * @param count
1206
+ * @returns
1207
+ */
1208
+ whereHas(relation: string, callback?: (query: QueryBuilder<any, any>) => unknown, operator?: '>=' | '>' | '=' | '!=' | '<=' | '<', count?: number): this;
1209
+ /**
1210
+ * Add an OR nested relationship constraint to the related query.
1211
+ *
1212
+ * @param relation
1213
+ * @param callback
1214
+ * @param operator
1215
+ * @param count
1216
+ * @returns
1217
+ */
1218
+ orWhereHas(relation: string, callback?: (query: QueryBuilder<any, any>) => unknown, operator?: '>=' | '>' | '=' | '!=' | '<=' | '<', count?: number): this;
1219
+ /**
1220
+ * Require the related query's model not to have a nested relationship.
1221
+ *
1222
+ * @param relation
1223
+ * @param callback
1224
+ * @returns
1225
+ */
1226
+ doesntHave(relation: string, callback?: (query: QueryBuilder<any, any>) => unknown): this;
1227
+ /**
1228
+ * Add an OR nested relationship absence constraint.
1229
+ *
1230
+ * @param relation
1231
+ * @returns
1232
+ */
1233
+ orDoesntHave(relation: string): this;
1234
+ /**
1235
+ * Require a constrained nested relationship to be absent.
1236
+ *
1237
+ * @param relation
1238
+ * @param callback
1239
+ * @returns
1240
+ */
1241
+ whereDoesntHave(relation: string, callback?: (query: QueryBuilder<any, any>) => unknown): this;
1242
+ /**
1243
+ * Add an OR constrained nested relationship absence clause.
1244
+ *
1245
+ * @param relation
1246
+ * @param callback
1247
+ * @returns
1248
+ */
1249
+ orWhereDoesntHave(relation: string, callback?: (query: QueryBuilder<any, any>) => unknown): this;
1250
+ /**
1251
+ * Add a constrained polymorphic nested relationship clause.
1252
+ *
1253
+ * @param relation
1254
+ * @param types
1255
+ * @param callback
1256
+ * @param operator
1257
+ * @param count
1258
+ * @returns
1259
+ */
1260
+ whereHasMorph<TRelated = any>(relation: string, types: string | RelationshipModelStatic | Array<string | RelationshipModelStatic>, callback?: (query: QueryBuilder<TRelated, any>, type: string) => unknown, operator?: '>=' | '>' | '=' | '!=' | '<=' | '<', count?: number): this;
1261
+ /**
1262
+ * Add an OR constrained polymorphic nested relationship clause.
1263
+ *
1264
+ * @param relation
1265
+ * @param types
1266
+ * @param callback
1267
+ * @param operator
1268
+ * @param count
1269
+ * @returns
1270
+ */
1271
+ orWhereHasMorph<TRelated = any>(relation: string, types: string | RelationshipModelStatic | Array<string | RelationshipModelStatic>, callback?: (query: QueryBuilder<TRelated, any>, type: string) => unknown, operator?: '>=' | '>' | '=' | '!=' | '<=' | '<', count?: number): this;
1272
+ /**
1273
+ * Require a constrained polymorphic nested relationship to be absent.
1274
+ *
1275
+ * @param relation
1276
+ * @param types
1277
+ * @param callback
1278
+ * @returns
1279
+ */
1280
+ whereDoesntHaveMorph<TRelated = any>(relation: string, types: string | RelationshipModelStatic | Array<string | RelationshipModelStatic>, callback?: (query: QueryBuilder<TRelated, any>, type: string) => unknown): this;
1281
+ /**
1282
+ * Add an OR polymorphic nested relationship absence clause.
1283
+ *
1284
+ * @param relation
1285
+ * @param types
1286
+ * @param callback
1287
+ * @returns
1288
+ */
1289
+ orWhereDoesntHaveMorph<TRelated = any>(relation: string, types: string | RelationshipModelStatic | Array<string | RelationshipModelStatic>, callback?: (query: QueryBuilder<TRelated, any>, type: string) => unknown): this;
1133
1290
  /**
1134
1291
  * Add relationship count aggregates to the related-model query.
1135
1292
  *
@@ -3623,11 +3780,11 @@ declare abstract class Model<TSchema extends ModelQuerySchemaLike | Record<strin
3623
3780
  interface ArkormModelRegistry {}
3624
3781
  interface ArkormModelNameRegistry {}
3625
3782
  type LowercaseString<T extends string> = Lowercase<T>;
3626
- type Simplify<TValue> = { [TKey in keyof TValue]: TValue[TKey] } & {};
3783
+ type Simplify<TValue> = { [TKey in keyof TValue]: TValue[TKey]; } & {};
3627
3784
  type ConventionalAutoManagedKeys = 'id' | 'createdAt' | 'updatedAt' | 'deletedAt';
3628
3785
  type SingularKey<T extends string> = LowercaseString<T> extends `${infer Base}s` ? Base : LowercaseString<T>;
3629
3786
  type PluralKey<T extends string> = `${SingularKey<T>}s`;
3630
- type PrismaClientDelegates = { [TKey in keyof PrismaClient as PrismaClient[TKey] extends ModelQuerySchemaLike ? TKey : never]: PrismaClient[TKey] };
3787
+ type PrismaClientDelegates = { [TKey in keyof PrismaClient as PrismaClient[TKey] extends ModelQuerySchemaLike ? TKey : never]: PrismaClient[TKey]; };
3631
3788
  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
3789
  type AttributeScalarFilter<TValue> = Omit<PrismaLikeScalarFilter, 'equals' | 'not' | 'in' | 'notIn' | 'lt' | 'lte' | 'gt' | 'gte' | 'contains' | 'startsWith' | 'endsWith'> & {
3633
3790
  equals?: TValue;
@@ -3646,11 +3803,11 @@ type AttributeWhereInput<TAttributes extends Record<string, unknown>> = {
3646
3803
  AND?: AttributeWhereInput<TAttributes>[];
3647
3804
  OR?: AttributeWhereInput<TAttributes>[];
3648
3805
  NOT?: AttributeWhereInput<TAttributes> | AttributeWhereInput<TAttributes>[];
3649
- } & { [TKey in keyof TAttributes]?: TAttributes[TKey] | AttributeScalarFilter<NonNullable<TAttributes[TKey]>> | null };
3806
+ } & { [TKey in keyof TAttributes]?: TAttributes[TKey] | AttributeScalarFilter<NonNullable<TAttributes[TKey]>> | null; };
3650
3807
  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>> }[keyof TValue];
3808
+ type AttributeSelect<TAttributes extends Record<string, unknown>> = { [TKey in keyof TAttributes]?: boolean; };
3809
+ 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>;
3810
+ type AtLeastOne<TValue extends Record<string, unknown>> = { [TKey in keyof TValue]-?: Required<Pick<TValue, TKey>> & Partial<Omit<TValue, TKey>>; }[keyof TValue];
3654
3811
  type AttributeCreateInput<TAttributes extends Record<string, unknown>> = Simplify<Pick<TAttributes, RequiredCreateKeys<TAttributes>> & Partial<Omit<TAttributes, RequiredCreateKeys<TAttributes>>>>;
3655
3812
  type AttributeUpdateInput<TAttributes extends Record<string, unknown>> = AtLeastOne<Partial<TAttributes>>;
3656
3813
  interface AttributeQuerySchema<TAttributes extends Record<string, unknown>> extends ModelQuerySchemaLike {
@@ -3698,8 +3855,8 @@ type AttributeSchemaDelegate<TAttributes extends Record<string, unknown>> = Attr
3698
3855
  type DelegateForModelSchema<TSchema extends ModelQuerySchemaLike | Record<string, unknown> | string, TAttributes extends Record<string, unknown> = ModelAttributesOf<TSchema>> = QuerySchemaForModel<TSchema, TAttributes>;
3699
3856
  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
3857
  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] };
3858
+ type ModelDeclaredAttributeKey<TModel> = { [TKey in keyof TModel & string]: TKey extends keyof BaseModelInstance ? never : TModel[TKey] extends ((...args: any[]) => any) ? never : TKey; }[keyof TModel & string];
3859
+ type ModelDeclaredAttributes<TModel> = { [TKey in ModelDeclaredAttributeKey<TModel>]: TModel[TKey]; };
3703
3860
  type ResolveModelAttributes<TModel, TAttributes extends Record<string, unknown>> = [ModelDeclaredAttributeKey<TModel>] extends [never] ? TAttributes : string extends keyof TAttributes ? ModelDeclaredAttributes<TModel> : TAttributes & ModelDeclaredAttributes<TModel>;
3704
3861
  type ModelAttributes<TModel> = TModel extends Model<any, infer TAttributes> ? ResolveModelAttributes<TModel, TAttributes> : Record<string, any>;
3705
3862
  type QuerySchemaForModelInstance<TModel> = TModel extends Model<infer TSchema, infer TAttributes> ? TSchema extends ModelQuerySchemaLike | string ? QuerySchemaForModel<TSchema, TAttributes> : AttributeQuerySchema<ResolveModelAttributes<TModel, TAttributes>> : ModelQuerySchemaLike;
@@ -3708,7 +3865,7 @@ type ModelOrderByInput<TModel> = string extends keyof ModelAttributes<TModel> ?
3708
3865
  type RelationshipResultProvider<TResult = unknown> = {
3709
3866
  getResults: (...args: any[]) => Promise<TResult>;
3710
3867
  };
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];
3868
+ 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
3869
  type ModelRelationshipResult<TModel, TKey extends ModelRelationshipKey<TModel>> = TModel[TKey] extends ((...args: any[]) => infer TReturn) ? TReturn extends RelationshipResultProvider<infer TResult> ? TResult : never : never;
3713
3870
  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
3871
  type ModelCreateData<TModel, TDelegate extends ModelQuerySchemaLike> = TModel extends Model<any, infer TAttributes> ? TDelegate extends AttributeQuerySchema<TAttributes> ? AttributeCreateInput<TAttributes> : QuerySchemaCreateData<TDelegate> : QuerySchemaCreateData<TDelegate>;
@@ -3756,20 +3913,20 @@ interface GroupByAggregateSpec<TModel> {
3756
3913
  _min?: AggregateColumnMap<TModel>;
3757
3914
  _max?: AggregateColumnMap<TModel>;
3758
3915
  }
3759
- type SameTypeAggregate<TModel, TMap> = { [K in keyof TMap]: K extends keyof ModelAttributes<TModel> ? ModelAttributes<TModel>[K] : unknown };
3916
+ type SameTypeAggregate<TModel, TMap> = { [K in keyof TMap]: K extends keyof ModelAttributes<TModel> ? ModelAttributes<TModel>[K] : unknown; };
3760
3917
  /** 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 {
3918
+ type GroupByAggregateRow<TModel, TSpec extends GroupByAggregateSpec<TModel>> = { [K in TSpec['by'][number]]: K extends keyof ModelAttributes<TModel> ? ModelAttributes<TModel>[K] : unknown; } & (TSpec extends {
3762
3919
  _count: infer C;
3763
3920
  } ? {
3764
- _count: C extends AggregateColumnMap<TModel> ? { [K in keyof C]: number } : number;
3921
+ _count: C extends AggregateColumnMap<TModel> ? { [K in keyof C]: number; } : number;
3765
3922
  } : object) & (TSpec extends {
3766
3923
  _sum: infer S;
3767
3924
  } ? {
3768
- _sum: { [K in keyof S]: number | null };
3925
+ _sum: { [K in keyof S]: number | null; };
3769
3926
  } : object) & (TSpec extends {
3770
3927
  _avg: infer A;
3771
3928
  } ? {
3772
- _avg: { [K in keyof A]: number | null };
3929
+ _avg: { [K in keyof A]: number | null; };
3773
3930
  } : object) & (TSpec extends {
3774
3931
  _min: infer M;
3775
3932
  } ? {
@@ -6998,8 +7155,8 @@ declare class Attribute<TGet = unknown, TSet = unknown> {
6998
7155
  //#region src/casts.d.ts
6999
7156
  declare function resolveCast(definition: CastDefinition): CastHandler;
7000
7157
  //#endregion
7001
- //#region src/cli/CliApp.d.ts
7002
- type SyncedModelsResult = {
7158
+ //#region src/types/cli.d.ts
7159
+ interface SyncedModelsResult {
7003
7160
  source: 'adapter' | 'prisma' | 'registry';
7004
7161
  schemaPath?: string;
7005
7162
  modelsDir: string;
@@ -7007,14 +7164,16 @@ type SyncedModelsResult = {
7007
7164
  total: number;
7008
7165
  updated: string[];
7009
7166
  skipped: string[];
7010
- };
7167
+ }
7168
+ //#endregion
7169
+ //#region src/cli/CliApp.d.ts
7011
7170
  /**
7012
7171
  * Main application class for the Arkormˣ CLI.
7013
7172
  *
7014
7173
  * @author Legacy (3m1n3nc3)
7015
7174
  * @since 0.1.0
7016
7175
  */
7017
- declare class CliApp {
7176
+ declare class CliApp extends Application {
7018
7177
  command: Command;
7019
7178
  protected config: Partial<ArkormConfig>;
7020
7179
  constructor();
@@ -7025,6 +7184,7 @@ declare class CliApp {
7025
7184
  * @returns The entire configuration object or the value of the specified key
7026
7185
  */
7027
7186
  getConfig: GetUserConfig;
7187
+ registerMusketListeners(musket: Musket<this>): void;
7028
7188
  private isUsingPrismaAdapter;
7029
7189
  /**
7030
7190
  * Utility to ensure directory exists
@@ -8750,6 +8910,8 @@ declare const getRuntimeAdapter: () => DatabaseAdapter | undefined;
8750
8910
  * processes (the CLI) so the Node event loop drains and the process exits
8751
8911
  * promptly instead of hanging on pool idle timeouts. Teardown failures are
8752
8912
  * swallowed because the process is shutting down anyway.
8913
+ *
8914
+ * @returns
8753
8915
  */
8754
8916
  declare const disposeArkormRuntime: () => Promise<void>;
8755
8917
  declare const getActiveTransactionClient: () => RuntimeClientLike | undefined;
@@ -8784,7 +8946,7 @@ declare const isQuerySchemaLike: (value: unknown) => value is ModelQuerySchemaLi
8784
8946
  declare const isDelegateLike: (value: unknown) => value is ModelQuerySchemaLike;
8785
8947
  //#endregion
8786
8948
  //#region src/helpers/prisma.d.ts
8787
- type PrismaDelegateMap<TClient extends RuntimeClientLike> = { [K in keyof TClient as TClient[K] extends ModelQuerySchemaLike ? K : never]: TClient[K] extends ModelQuerySchemaLike ? TClient[K] : never };
8949
+ type PrismaDelegateMap<TClient extends RuntimeClientLike> = { [K in keyof TClient as TClient[K] extends ModelQuerySchemaLike ? K : never]: TClient[K] extends ModelQuerySchemaLike ? TClient[K] : never; };
8788
8950
  /**
8789
8951
  * Compatibility-only helper that exposes Prisma query schemas as a plain object map.
8790
8952
  * It is retained for migration support and tests, not as a supported runtime bootstrap path.