arkormx 2.11.13 → 2.12.1

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/index.mjs CHANGED
@@ -1,10 +1,12 @@
1
- import { $ as registerSeeders, $n as supportsDatabaseMigrationState, $t as resolveEnumName, A as getRuntimePaginationCurrentPageResolver, An as min, At as buildFieldLine, B as getRegisteredFactories, Bn as createEmptyAppliedMigrationsState, Bt as deriveInverseRelationAlias, C as ensureArkormConfigLoading, Cn as col, Ct as applyDropTableOperation, D as getRuntimeAdapter, Dn as fromExpressionNode, Dt as applyMigrationToPrismaSchema, E as getDefaultStubsPath, En as fn, Et as applyMigrationToDatabase, F as isQuerySchemaLike, Fn as PrimaryKeyGenerationPlanner, Ft as buildPrimaryKeyLine, G as loadFactoriesFrom, Gn as getLatestAppliedMigrations, Gt as findEnumBlock, H as getRegisteredModels, Hn as findAppliedMigration, Ht as deriveRelationFieldName, I as isTransactionCapableClient, In as ForeignKeyBuilder, It as buildRelationLine, J as loadSeedersFrom, Jn as markMigrationRun, Jt as formatEnumDefaultValue, K as loadMigrationsFrom, Kn as isMigrationApplied, Kt as findModelBlock, L as loadArkormConfig, Ln as buildMigrationIdentity, Lt as buildUniqueConstraintLine, M as getRuntimePrismaClient, Mn as sum, Mt as buildInverseRelationLine, N as getUserConfig, Nn as val, Nt as buildMigrationSource, O as getRuntimeClient, On as json, Ot as applyOperationsToPrismaSchema, P as isDelegateLike, Pn as where, Pt as buildModelBlock, Q as registerPaths, Qn as resolveMigrationStateFilePath, Qt as pad, R as resetArkormRuntimeForTests, Rn as buildMigrationRunId, Rt as createMigrationTimestamp, S as emitRuntimeDebugEvent, Sn as coalesce, St as applyCreateTableOperation, T as getActiveTransactionClient, Tn as expressionBuilder, Tt as applyMigrationRollbackToPrismaSchema, U as getRegisteredPaths, Un as getLastBatchMigrations, Ut as deriveSingularFieldName, V as getRegisteredMigrations, Vn as deleteAppliedMigrationsStateFromStore, Vt as deriveRelationAlias, W as getRegisteredSeeders, Wn as getLastMigrationRun, Wt as escapeRegex, X as registerMigrations, Xn as readAppliedMigrationsStateFromStore, Xt as generateMigrationFile, Y as registerFactories, Yn as readAppliedMigrationsState, Yt as formatRelationAction, Z as registerModels, Zn as removeAppliedMigration, Zt as getMigrationPlan, _ as awaitConfiguredModelsRegistration, _n as CaseExpression, _t as writePersistedColumnMappingsState, a as MorphedByManyRelation, an as supportsDatabaseCreation, at as getPersistedEnumMap, b as defineConfig, bn as avg, bt as PRISMA_MODEL_REGEX, c as HasManyThroughRelation, cn as toMigrationFileSlug, cr as ArkormException, ct as getPersistedTableMetadata, dn as runInMigrationPlanning, dt as rebuildPersistedColumnMappingsState, en as resolveMigrationClassName, er as writeAppliedMigrationsState, et as resetRuntimeRegistryForTests, f as BelongsToManyRelation, fn as SchemaBuilder, ft as resetPersistedColumnMappingsCache, g as URLDriver, gn as AggregateExpression, gt as validatePersistedMetadataFeaturesForMigrations, h as Paginator, hn as resolveGeneratedExpression, ht as syncPersistedColumnMappingsFromState, i as MorphManyRelation, in as stripPrismaSchemaModelsAndEnums, ir as SetBasedEagerLoader, it as getPersistedColumnMap, j as getRuntimePaginationURLDriverFactory, jn as raw, jt as buildIndexLine, k as getRuntimeDebugHandler, kn as max, kt as buildEnumBlock, l as HasManyRelation, ln as toModelName, lt as getPersistedTimestampColumns, m as LengthAwarePaginator, mn as TableBuilder, mt as resolvePersistedMetadataFeatures, n as MorphToManyRelation, nn as runMigrationWithPrisma, nr as RuntimeModuleLoader, nt as createEmptyPersistedColumnMappingsState, o as HasOneThroughRelation, on as supportsDatabaseMigrationExecution, or as RelationResolutionException, ot as getPersistedEnumTsType, p as Relation, pn as EnumBuilder, pt as resolveColumnMappingsFilePath, q as loadModelsFrom, qn as markMigrationApplied, qt as formatDefaultValue, r as MorphOneRelation, rn as runPrismaCommand, rr as UnsupportedAdapterFeatureException, rt as deletePersistedColumnMappingsState, s as HasOneRelation, sn as supportsDatabaseReset, sr as ArkormCollection, st as getPersistedPrimaryKeyGeneration, t as MorphToRelation, tn as resolvePrismaType, tr as writeAppliedMigrationsStateToStore, tt as applyOperationsToPersistedColumnMappingsState, u as BelongsToRelation, un as isMigrationPlanningActive, ut as readPersistedColumnMappingsState, v as bindAdapterToModels, vn as Expression, vt as PRISMA_ENUM_MEMBER_REGEX, w as getActiveTransactionAdapter, wn as count, wt as applyMigrationRollbackToDatabase, x as disposeArkormRuntime, xn as caseWhen, xt as applyAlterTableOperation, y as configureArkormRuntime, yn as JsonExpression, yt as PRISMA_ENUM_REGEX, z as runArkormTransaction, zn as computeMigrationChecksum, zt as deriveCollectionFieldName } from "./relationship-DYMxYzUD.mjs";
1
+ import { $ as buildPrimaryKeyLine, $n as readAppliedMigrationsState, $t as bindAdapterToModels, A as resetPersistedColumnMappingsCache, An as registerFactories, At as EnumBuilder, B as applyCreateTableOperation, Bn as ForeignKeyBuilder, Bt as col, C as getPersistedEnumMap, Cn as getRegisteredModels, Ct as supportsDatabaseCreation, D as getPersistedTimestampColumns, Dn as loadMigrationsFrom, Dt as toModelName, E as getPersistedTableMetadata, En as loadFactoriesFrom, Et as toMigrationFileSlug, F as writePersistedColumnMappingsState, Fn as resetRuntimeRegistryForTests, Ft as Expression, G as applyMigrationToPrismaSchema, Gn as deleteAppliedMigrationsStateFromStore, Gt as json, H as applyMigrationRollbackToDatabase, Hn as buildMigrationRunId, Ht as expressionBuilder, I as PRISMA_ENUM_MEMBER_REGEX, In as resolveRegisteredModel, It as JsonExpression, J as buildFieldLine, Jn as getLastMigrationRun, Jt as raw, K as applyOperationsToPrismaSchema, Kn as findAppliedMigration, Kt as max, L as PRISMA_ENUM_REGEX, Ln as UnsupportedAdapterFeatureException, Lt as avg, M as resolvePersistedMetadataFeatures, Mn as registerModels, Mt as resolveGeneratedExpression, N as syncPersistedColumnMappingsFromState, Nn as registerPaths, Nt as AggregateExpression, O as readPersistedColumnMappingsState, On as loadModelsFrom, Ot as isMigrationPlanningActive, P as validatePersistedMetadataFeaturesForMigrations, Pn as registerSeeders, Pt as CaseExpression, Q as buildModelBlock, Qn as markMigrationRun, Qt as awaitConfiguredModelsRegistration, R as PRISMA_MODEL_REGEX, Rn as RuntimeModuleLoader, Rt as caseWhen, S as getPersistedColumnMap, Sn as getRegisteredMigrations, St as stripPrismaSchemaModelsAndEnums, T as getPersistedPrimaryKeyGeneration, Tn as getRegisteredSeeders, Tt as supportsDatabaseReset, U as applyMigrationRollbackToPrismaSchema, Un as computeMigrationChecksum, Ut as fn, V as applyDropTableOperation, Vn as buildMigrationIdentity, Vt as count, W as applyMigrationToDatabase, Wn as createEmptyAppliedMigrationsState, Wt as fromExpressionNode, X as buildInverseRelationLine, Xn as isMigrationApplied, Xt as val, Y as buildIndexLine, Yn as getLatestAppliedMigrations, Yt as sum, Z as buildMigrationSource, Zn as markMigrationApplied, Zt as where, _ as SetBasedEagerLoader, _n as isTransactionCapableClient, _t as resolveEnumName, a as MorphManyRelation, an as getActiveTransactionAdapter, ar as writeAppliedMigrationsStateToStore, at as deriveRelationAlias, b as createEmptyPersistedColumnMappingsState, bn as runArkormTransaction, bt as runMigrationWithPrisma, c as HasManyThroughRelation, cn as getRuntimeAdapter, cr as ArkormException, ct as escapeRegex, dn as getRuntimePaginationCurrentPageResolver, dt as formatDefaultValue, en as configureArkormRuntime, er as readAppliedMigrationsStateFromStore, et as buildRelationLine, f as BelongsToManyRelation, fn as getRuntimePaginationURLDriverFactory, ft as formatEnumDefaultValue, g as URLDriver, gn as isQuerySchemaLike, gt as pad, h as Paginator, hn as isDelegateLike, ht as getMigrationPlan, i as MorphOneRelation, in as ensureArkormConfigLoading, ir as writeAppliedMigrationsState, it as deriveInverseRelationAlias, j as resolveColumnMappingsFilePath, jn as registerMigrations, jt as TableBuilder, k as rebuildPersistedColumnMappingsState, kn as loadSeedersFrom, kt as SchemaBuilder, l as HasManyRelation, ln as getRuntimeClient, lt as findEnumBlock, m as LengthAwarePaginator, mn as getUserConfig, mt as generateMigrationFile, n as MorphedByManyRelation, nn as disposeArkormRuntime, nr as resolveMigrationStateFilePath, nt as createMigrationTimestamp, o as HasOneThroughRelation, on as getActiveTransactionClient, or as RelationResolutionException, ot as deriveRelationFieldName, p as Relation, pn as getRuntimePrismaClient, pt as formatRelationAction, q as buildEnumBlock, qn as getLastBatchMigrations, qt as min, r as MorphToManyRelation, rn as emitRuntimeDebugEvent, rr as supportsDatabaseMigrationState, rt as deriveCollectionFieldName, s as HasOneRelation, sn as getDefaultStubsPath, sr as ArkormCollection, st as deriveSingularFieldName, t as MorphToRelation, tn as defineConfig, tr as removeAppliedMigration, tt as buildUniqueConstraintLine, u as BelongsToRelation, un as getRuntimeDebugHandler, ut as findModelBlock, vn as loadArkormConfig, vt as resolveMigrationClassName, w as getPersistedEnumTsType, wn as getRegisteredPaths, wt as supportsDatabaseMigrationExecution, x as deletePersistedColumnMappingsState, xn as getRegisteredFactories, xt as runPrismaCommand, y as applyOperationsToPersistedColumnMappingsState, yn as resetArkormRuntimeForTests, yt as resolvePrismaType, z as applyAlterTableOperation, zn as PrimaryKeyGenerationPlanner, zt as coalesce } from "./relationship-CrNsvYto.mjs";
2
2
  import { Pool } from "pg";
3
- import { join, resolve } from "node:path";
3
+ import { extname, isAbsolute, join, relative, resolve } from "node:path";
4
+ import { existsSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
5
+ import { createJiti } from "jiti";
6
+ import { pathToFileURL } from "node:url";
4
7
  import { createRequire } from "module";
5
- import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "fs";
6
- import { dirname as dirname$1, extname as extname$1, join as join$1, relative } from "path";
7
- import { existsSync as existsSync$1, readFileSync as readFileSync$1, readdirSync as readdirSync$1, rmSync as rmSync$1, writeFileSync as writeFileSync$1 } from "node:fs";
8
+ import { copyFileSync, existsSync as existsSync$1, mkdirSync as mkdirSync$1, readFileSync as readFileSync$1, readdirSync as readdirSync$1, realpathSync, rmSync as rmSync$1, writeFileSync as writeFileSync$1 } from "fs";
9
+ import { dirname as dirname$1, extname as extname$1, join as join$1, relative as relative$1 } from "path";
8
10
  import { DateTime, str } from "@h3ravel/support";
9
11
  import { AsyncLocalStorage } from "node:async_hooks";
10
12
  import { sql } from "kysely";
@@ -2379,6 +2381,92 @@ const createPrismaDatabaseAdapter = (prisma, mapping = {}) => {
2379
2381
  */
2380
2382
  const createPrismaCompatibilityAdapter = createPrismaDatabaseAdapter;
2381
2383
 
2384
+ //#endregion
2385
+ //#region src/helpers/model-resolver.ts
2386
+ const modelExtensions = [
2387
+ ".ts",
2388
+ ".tsx",
2389
+ ".mts",
2390
+ ".cts",
2391
+ ".js",
2392
+ ".mjs",
2393
+ ".cjs"
2394
+ ];
2395
+ const isModelModule = (value) => typeof value === "object" && value !== null;
2396
+ const isModelConstructor = (value) => {
2397
+ if (typeof value !== "function") return false;
2398
+ const candidate = value;
2399
+ return typeof candidate.query === "function" && typeof candidate.hydrate === "function" && typeof candidate.getTable === "function" && typeof candidate.getPrimaryKey === "function";
2400
+ };
2401
+ const resolveModelExport = (module, modelName) => {
2402
+ if (!isModelModule(module)) return module;
2403
+ return module.default ?? module[modelName] ?? module;
2404
+ };
2405
+ const resolveRuntimeDirectory = (directory) => {
2406
+ if (existsSync(directory)) return directory;
2407
+ const buildOutput = getUserConfig("paths")?.buildOutput;
2408
+ if (typeof buildOutput !== "string" || buildOutput.trim().length === 0) return directory;
2409
+ const relativeSource = relative(process.cwd(), directory);
2410
+ if (!relativeSource || relativeSource.startsWith("..")) return directory;
2411
+ const mappedDirectory = join(buildOutput, relativeSource);
2412
+ return existsSync(mappedDirectory) ? mappedDirectory : directory;
2413
+ };
2414
+ const resolveRuntimeModelPath = (sourcePath) => {
2415
+ const extension = extname(sourcePath).toLowerCase();
2416
+ const candidates = [];
2417
+ if (modelExtensions.includes(extension)) candidates.push(sourcePath);
2418
+ else candidates.push(...modelExtensions.map((modelExtension) => `${sourcePath}${modelExtension}`));
2419
+ const buildOutput = getUserConfig("paths")?.buildOutput;
2420
+ if (typeof buildOutput === "string" && buildOutput.trim().length > 0) candidates.slice().forEach((candidate) => {
2421
+ const relativeSource = relative(process.cwd(), candidate);
2422
+ if (!relativeSource || relativeSource.startsWith("..")) return;
2423
+ const mappedFile = join(buildOutput, relativeSource);
2424
+ const mappedExtension = extname(mappedFile).toLowerCase();
2425
+ if ([
2426
+ ".ts",
2427
+ ".tsx",
2428
+ ".mts",
2429
+ ".cts"
2430
+ ].includes(mappedExtension)) {
2431
+ const base = mappedFile.slice(0, -mappedExtension.length);
2432
+ candidates.push(`${base}.js`, `${base}.mjs`, `${base}.cjs`);
2433
+ return;
2434
+ }
2435
+ candidates.push(mappedFile);
2436
+ });
2437
+ return candidates.find((candidate) => existsSync(candidate)) ?? sourcePath;
2438
+ };
2439
+ const getModelDirectories = () => {
2440
+ const configured = getUserConfig("paths")?.models;
2441
+ const registered = getRegisteredPaths("models");
2442
+ return [...typeof configured === "string" ? [configured] : [], ...registered].map((directory) => resolveRuntimeDirectory(isAbsolute(directory) ? directory : resolve(directory))).filter((directory, index, all) => all.indexOf(directory) === index);
2443
+ };
2444
+ const loadModel = (modelName, exportName) => {
2445
+ const jiti = createJiti(`${pathToFileURL(resolve(".")).href}/`, {
2446
+ interopDefault: false,
2447
+ tsconfigPaths: true,
2448
+ sourceMaps: true
2449
+ });
2450
+ for (const directory of getModelDirectories()) {
2451
+ const modulePath = resolveRuntimeModelPath(join(directory, modelName));
2452
+ if (!existsSync(modulePath)) continue;
2453
+ const model = resolveModelExport(jiti(modulePath), exportName);
2454
+ if (!isModelConstructor(model)) continue;
2455
+ registerModels(model);
2456
+ return model;
2457
+ }
2458
+ };
2459
+ function getModel(modelName) {
2460
+ const normalized = modelName.trim();
2461
+ const exportName = normalized.replace(/\\/g, "/").split("/").pop()?.replace(/\.[^.]+$/, "");
2462
+ if (!normalized || !exportName) throw new Error("Model name is required.");
2463
+ const registeredModel = getRegisteredModels().find((model) => model.name === exportName);
2464
+ if (registeredModel) return registeredModel;
2465
+ const model = loadModel(normalized, exportName);
2466
+ if (model) return model;
2467
+ throw new Error(`Model "${modelName}" not found.`);
2468
+ }
2469
+
2382
2470
  //#endregion
2383
2471
  //#region src/Arkorm.ts
2384
2472
  var Arkorm = class Arkorm {
@@ -2398,6 +2486,7 @@ var Arkorm = class Arkorm {
2398
2486
  this.getRegisteredMigrations = Arkorm.getRegisteredMigrations;
2399
2487
  this.getRegisteredSeeders = Arkorm.getRegisteredSeeders;
2400
2488
  this.getRegisteredModels = Arkorm.getRegisteredModels;
2489
+ this.getModel = Arkorm.getModel;
2401
2490
  this.getRegisteredFactories = Arkorm.getRegisteredFactories;
2402
2491
  }
2403
2492
  /**
@@ -2525,6 +2614,9 @@ var Arkorm = class Arkorm {
2525
2614
  static getRegisteredModels() {
2526
2615
  return getRegisteredModels();
2527
2616
  }
2617
+ static {
2618
+ this.getModel = getModel;
2619
+ }
2528
2620
  /**
2529
2621
  * Get registered factory constructors or instances.
2530
2622
  *
@@ -2652,7 +2744,7 @@ var CliApp = class {
2652
2744
  */
2653
2745
  ensureDirectory(filePath) {
2654
2746
  const dir = dirname$1(filePath);
2655
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
2747
+ if (!existsSync$1(dir)) mkdirSync$1(dir, { recursive: true });
2656
2748
  }
2657
2749
  /**
2658
2750
  * Convert absolute paths under current working directory into relative display paths.
@@ -2661,7 +2753,7 @@ var CliApp = class {
2661
2753
  * @returns
2662
2754
  */
2663
2755
  formatPathForLog(filePath) {
2664
- const relPath = relative(process.cwd(), filePath);
2756
+ const relPath = relative$1(process.cwd(), filePath);
2665
2757
  if (!relPath) return ".";
2666
2758
  if (relPath.startsWith("..")) return filePath;
2667
2759
  return relPath;
@@ -2701,13 +2793,13 @@ var CliApp = class {
2701
2793
  * @returns
2702
2794
  */
2703
2795
  resolveRuntimeDirectoryPath(directoryPath) {
2704
- if (existsSync(directoryPath)) return directoryPath;
2796
+ if (existsSync$1(directoryPath)) return directoryPath;
2705
2797
  const { buildOutput } = this.getConfig("paths") || {};
2706
2798
  if (typeof buildOutput !== "string" || buildOutput.trim().length === 0) return directoryPath;
2707
- const relativeSource = relative(process.cwd(), directoryPath);
2799
+ const relativeSource = relative$1(process.cwd(), directoryPath);
2708
2800
  if (!relativeSource || relativeSource.startsWith("..")) return directoryPath;
2709
2801
  const mappedDirectory = join$1(buildOutput, relativeSource);
2710
- return existsSync(mappedDirectory) ? mappedDirectory : directoryPath;
2802
+ return existsSync$1(mappedDirectory) ? mappedDirectory : directoryPath;
2711
2803
  }
2712
2804
  /**
2713
2805
  * Resolve a script file path for runtime execution.
@@ -2727,7 +2819,7 @@ var CliApp = class {
2727
2819
  }
2728
2820
  const { buildOutput } = this.getConfig("paths") ?? {};
2729
2821
  if (typeof buildOutput === "string" && buildOutput.trim().length > 0) {
2730
- const relativeSource = relative(process.cwd(), filePath);
2822
+ const relativeSource = relative$1(process.cwd(), filePath);
2731
2823
  if (relativeSource && !relativeSource.startsWith("..")) {
2732
2824
  const mappedFile = join$1(buildOutput, relativeSource);
2733
2825
  const mappedExtension = extname$1(mappedFile).toLowerCase();
@@ -2737,7 +2829,7 @@ var CliApp = class {
2737
2829
  } else candidates.push(mappedFile);
2738
2830
  }
2739
2831
  }
2740
- const runtimeMatch = candidates.find((path) => existsSync(path));
2832
+ const runtimeMatch = candidates.find((path) => existsSync$1(path));
2741
2833
  if (runtimeMatch) return runtimeMatch;
2742
2834
  return filePath;
2743
2835
  }
@@ -2749,14 +2841,14 @@ var CliApp = class {
2749
2841
  * @param replacements
2750
2842
  */
2751
2843
  generateFile(stubPath, outputPath, replacements, options) {
2752
- if (existsSync(outputPath) && !options?.force) {
2844
+ if (existsSync$1(outputPath) && !options?.force) {
2753
2845
  this.command.error(`Error: ${this.formatPathForLog(outputPath)} already exists.`);
2754
2846
  process.exit(1);
2755
- } else if (existsSync(outputPath) && options?.force) rmSync(outputPath);
2756
- let content = readFileSync(stubPath, "utf-8");
2847
+ } else if (existsSync$1(outputPath) && options?.force) rmSync$1(outputPath);
2848
+ let content = readFileSync$1(stubPath, "utf-8");
2757
2849
  for (const [key, value] of Object.entries(replacements)) content = content.replace(new RegExp(`{{${key}}}`, "g"), value);
2758
2850
  this.ensureDirectory(outputPath);
2759
- writeFileSync(outputPath, content);
2851
+ writeFileSync$1(outputPath, content);
2760
2852
  return outputPath;
2761
2853
  }
2762
2854
  /**
@@ -2794,7 +2886,7 @@ var CliApp = class {
2794
2886
  const outputExt = this.resolveOutputExt();
2795
2887
  const outputPath = join$1(this.resolveConfigPath("factories", join$1(process.cwd(), "database", "factories")), `${factoryName}.${outputExt}`);
2796
2888
  const modelPath = join$1(this.resolveConfigPath("models", join$1(process.cwd(), "src", "models")), `${modelName}.${outputExt}`);
2797
- const relativeImport = options.modelImportPath ?? `./${this.stripKnownSourceExtension(relative(dirname$1(outputPath), modelPath).replace(/\\/g, "/"))}${outputExt === "js" ? ".js" : ""}`;
2889
+ const relativeImport = options.modelImportPath ?? `./${this.stripKnownSourceExtension(relative$1(dirname$1(outputPath), modelPath).replace(/\\/g, "/"))}${outputExt === "js" ? ".js" : ""}`;
2798
2890
  const stubPath = this.resolveStubPath(outputExt === "js" ? "factory.js.stub" : "factory.stub");
2799
2891
  return {
2800
2892
  name: factoryName,
@@ -2856,7 +2948,7 @@ var CliApp = class {
2856
2948
  const shouldBuildMigration = options.all || options.migration;
2857
2949
  const factoryName = `${baseName}Factory`;
2858
2950
  const factoryPath = join$1(this.resolveConfigPath("factories", join$1(process.cwd(), "database", "factories")), `${factoryName}.${outputExt}`);
2859
- const factoryImportPath = `./${relative(dirname$1(outputPath), factoryPath).replace(/\\/g, "/").replace(/\.(ts|tsx|mts|cts|js|mjs|cjs)$/i, "")}${outputExt === "js" ? ".js" : ""}`;
2951
+ const factoryImportPath = `./${relative$1(dirname$1(outputPath), factoryPath).replace(/\\/g, "/").replace(/\.(ts|tsx|mts|cts|js|mjs|cjs)$/i, "")}${outputExt === "js" ? ".js" : ""}`;
2860
2952
  let stubPath;
2861
2953
  if (options.pivot) stubPath = this.resolveStubPath("pivot-model.stub");
2862
2954
  else stubPath = this.resolveStubPath(outputExt === "js" ? "model.js.stub" : "model.stub");
@@ -2880,7 +2972,7 @@ var CliApp = class {
2880
2972
  if (shouldBuildFactory) created.factory = this.makeFactory(baseName, {
2881
2973
  force: options.force,
2882
2974
  modelName,
2883
- modelImportPath: `./${relative(dirname$1(factoryPath), outputPath).replace(/\\/g, "/").replace(/\.(ts|tsx|mts|cts|js|mjs|cjs)$/i, "")}${outputExt === "js" ? ".js" : ""}`
2975
+ modelImportPath: `./${relative$1(dirname$1(factoryPath), outputPath).replace(/\\/g, "/").replace(/\.(ts|tsx|mts|cts|js|mjs|cjs)$/i, "")}${outputExt === "js" ? ".js" : ""}`
2884
2976
  });
2885
2977
  if (shouldBuildSeeder) created.seeder = this.makeSeeder(baseName, { force: options.force });
2886
2978
  if (shouldBuildMigration) created.migration = this.makeMigration(`create ${tableName} table`);
@@ -2896,15 +2988,15 @@ var CliApp = class {
2896
2988
  */
2897
2989
  ensurePrismaModelEntry(modelName, tableName) {
2898
2990
  const schemaPath = join$1(process.cwd(), "prisma", "schema.prisma");
2899
- if (!existsSync(schemaPath)) return void 0;
2900
- const source = readFileSync(schemaPath, "utf-8");
2991
+ if (!existsSync$1(schemaPath)) return void 0;
2992
+ const source = readFileSync$1(schemaPath, "utf-8");
2901
2993
  const existingByTable = findModelBlock(source, tableName);
2902
2994
  const existingByName = new RegExp(`model\\s+${modelName}\\s*\\{`, "m").test(source);
2903
2995
  if (existingByTable || existingByName) return {
2904
2996
  path: schemaPath,
2905
2997
  updated: false
2906
2998
  };
2907
- writeFileSync(schemaPath, applyCreateTableOperation(source, {
2999
+ writeFileSync$1(schemaPath, applyCreateTableOperation(source, {
2908
3000
  type: "createTable",
2909
3001
  table: tableName,
2910
3002
  columns: [{
@@ -3122,7 +3214,7 @@ var CliApp = class {
3122
3214
  return lines.join("\n");
3123
3215
  }
3124
3216
  parseModelSyncSource(modelSource) {
3125
- const classMatch = modelSource.match(/export\s+class\s+(\w+)\s+extends\s+Model(?:<[^\n]+>)?\s*\{/);
3217
+ const classMatch = modelSource.match(/export\s+(?:abstract\s+)?class\s+(\w+)\s+extends\s+/);
3126
3218
  if (!classMatch) return null;
3127
3219
  const className = classMatch[1];
3128
3220
  const tableMatch = modelSource.match(/protected\s+static\s+override\s+table\s*=\s*['"]([^'"]+)['"]/) ?? modelSource.match(/static\s+table\s*=\s*['"]([^'"]+)['"]/);
@@ -3136,7 +3228,7 @@ var CliApp = class {
3136
3228
  const updated = [];
3137
3229
  const skipped = [];
3138
3230
  modelFiles.forEach((filePath) => {
3139
- const source = readFileSync(filePath, "utf-8");
3231
+ const source = readFileSync$1(filePath, "utf-8");
3140
3232
  const structure = resolveStructure(filePath, source);
3141
3233
  if (!structure || structure.fields.length === 0) {
3142
3234
  skipped.push(filePath);
@@ -3147,7 +3239,7 @@ var CliApp = class {
3147
3239
  skipped.push(filePath);
3148
3240
  return;
3149
3241
  }
3150
- writeFileSync(filePath, synced.content);
3242
+ writeFileSync$1(filePath, synced.content);
3151
3243
  updated.push(filePath);
3152
3244
  });
3153
3245
  return {
@@ -3155,6 +3247,58 @@ var CliApp = class {
3155
3247
  skipped
3156
3248
  };
3157
3249
  }
3250
+ resolveModelFiles(modelsDir) {
3251
+ if (!existsSync$1(modelsDir)) throw new Error(`Models directory not found: ${modelsDir}`);
3252
+ return readdirSync$1(modelsDir).filter((file) => file.endsWith(".ts")).map((file) => join$1(modelsDir, file));
3253
+ }
3254
+ syncModelRegistryTypes(modelFiles) {
3255
+ const registryDir = join$1(realpathSync(process.cwd()), ".arkormx");
3256
+ const registryPath = join$1(registryDir, "models.d.ts");
3257
+ const models = modelFiles.map((filePath) => {
3258
+ const parsed = this.parseModelSyncSource(readFileSync$1(filePath, "utf-8"));
3259
+ if (!parsed) return null;
3260
+ return {
3261
+ className: parsed.className,
3262
+ importPath: this.resolveModelRegistryImportPath(registryPath, filePath)
3263
+ };
3264
+ }).filter((model) => model !== null).sort((left, right) => left.className.localeCompare(right.className));
3265
+ const importLines = models.map((model) => {
3266
+ return `import type { ${model.className} } from '${model.importPath}'`;
3267
+ });
3268
+ const registryLines = models.map((model) => {
3269
+ return ` ${model.className}: typeof ${model.className}`;
3270
+ });
3271
+ const content = [
3272
+ "/* eslint-disable */",
3273
+ "// This file is generated by `arkorm models:sync`.",
3274
+ ...importLines,
3275
+ "",
3276
+ "declare module 'arkormx' {",
3277
+ " interface ArkormModelRegistry {",
3278
+ ...registryLines,
3279
+ " }",
3280
+ "}",
3281
+ "",
3282
+ "export {}",
3283
+ ""
3284
+ ].join("\n");
3285
+ if ((existsSync$1(registryPath) ? readFileSync$1(registryPath, "utf-8") : null) === content) return {
3286
+ path: registryPath,
3287
+ updated: false
3288
+ };
3289
+ mkdirSync$1(registryDir, { recursive: true });
3290
+ writeFileSync$1(registryPath, content);
3291
+ return {
3292
+ path: registryPath,
3293
+ updated: true
3294
+ };
3295
+ }
3296
+ resolveModelRegistryImportPath(registryPath, modelPath) {
3297
+ const realModelPath = realpathSync(modelPath);
3298
+ const withoutExtension = realModelPath.slice(0, -extname$1(realModelPath).length);
3299
+ const relativePath = relative$1(dirname$1(registryPath), withoutExtension).replace(/\\/g, "/");
3300
+ return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
3301
+ }
3158
3302
  applyPersistedFieldMetadata(structure) {
3159
3303
  const persistedMetadata = getPersistedTableMetadata(structure.table, {
3160
3304
  features: resolvePersistedMetadataFeatures(this.getConfig("features")),
@@ -3332,12 +3476,11 @@ var CliApp = class {
3332
3476
  }
3333
3477
  async syncModels(options = {}) {
3334
3478
  const modelsDir = options.modelsDir ?? this.resolveConfigPath("models", join$1(process.cwd(), "src", "models"));
3335
- if (!existsSync(modelsDir)) throw new Error(`Models directory not found: ${modelsDir}`);
3336
- const modelFiles = readdirSync(modelsDir).filter((file) => file.endsWith(".ts")).map((file) => join$1(modelsDir, file));
3479
+ const modelFiles = this.resolveModelFiles(modelsDir);
3337
3480
  const adapter = this.getConfig("adapter");
3338
3481
  if (adapter && typeof adapter.introspectModels === "function") {
3339
3482
  const sources = modelFiles.reduce((all, filePath) => {
3340
- const parsed = this.parseModelSyncSource(readFileSync(filePath, "utf-8"));
3483
+ const parsed = this.parseModelSyncSource(readFileSync$1(filePath, "utf-8"));
3341
3484
  if (parsed) all.set(filePath, parsed);
3342
3485
  return all;
3343
3486
  }, /* @__PURE__ */ new Map());
@@ -3350,11 +3493,13 @@ var CliApp = class {
3350
3493
  const parsed = sources.get(filePath);
3351
3494
  return parsed ? structuresByTable.get(parsed.table) : void 0;
3352
3495
  }, /* @__PURE__ */ new Map());
3496
+ const modelTypes = this.syncModelRegistryTypes(modelFiles);
3353
3497
  return {
3354
3498
  source: "adapter",
3355
3499
  modelsDir,
3500
+ modelTypesPath: modelTypes.path,
3356
3501
  total: modelFiles.length,
3357
- updated: result.updated,
3502
+ updated: modelTypes.updated ? [...result.updated, modelTypes.path] : result.updated,
3358
3503
  skipped: result.skipped
3359
3504
  };
3360
3505
  }
@@ -3363,6 +3508,19 @@ var CliApp = class {
3363
3508
  ...this.syncModelsFromPrisma(options)
3364
3509
  };
3365
3510
  }
3511
+ syncModelRegistry(options = {}) {
3512
+ const modelsDir = options.modelsDir ?? this.resolveConfigPath("models", join$1(process.cwd(), "src", "models"));
3513
+ const modelFiles = this.resolveModelFiles(modelsDir);
3514
+ const modelTypes = this.syncModelRegistryTypes(modelFiles);
3515
+ return {
3516
+ source: "registry",
3517
+ modelsDir,
3518
+ modelTypesPath: modelTypes.path,
3519
+ total: modelFiles.length,
3520
+ updated: modelTypes.updated ? [modelTypes.path] : [],
3521
+ skipped: []
3522
+ };
3523
+ }
3366
3524
  /**
3367
3525
  * Sync model attribute declarations in model files based on the Prisma schema.
3368
3526
  * This method reads the Prisma schema to extract model definitions and their
@@ -3377,22 +3535,23 @@ var CliApp = class {
3377
3535
  syncModelsFromPrisma(options = {}) {
3378
3536
  const schemaPath = options.schemaPath ?? join$1(process.cwd(), "prisma", "schema.prisma");
3379
3537
  const modelsDir = options.modelsDir ?? this.resolveConfigPath("models", join$1(process.cwd(), "src", "models"));
3380
- if (!existsSync(schemaPath)) throw new Error(`Prisma schema file not found: ${schemaPath}`);
3381
- if (!existsSync(modelsDir)) throw new Error(`Models directory not found: ${modelsDir}`);
3382
- const schema = readFileSync(schemaPath, "utf-8");
3538
+ if (!existsSync$1(schemaPath)) throw new Error(`Prisma schema file not found: ${schemaPath}`);
3539
+ const schema = readFileSync$1(schemaPath, "utf-8");
3383
3540
  const prismaEnums = this.parsePrismaEnums(schema);
3384
3541
  const prismaModels = this.parsePrismaModels(schema);
3385
- const modelFiles = readdirSync(modelsDir).filter((file) => file.endsWith(".ts")).map((file) => join$1(modelsDir, file));
3542
+ const modelFiles = this.resolveModelFiles(modelsDir);
3386
3543
  const result = this.syncModelFiles(modelFiles, (filePath, source) => {
3387
3544
  const parsed = this.parseModelSyncSource(source);
3388
3545
  if (!parsed) return void 0;
3389
3546
  return prismaModels.find((model) => model.table === parsed.table) ?? prismaModels.find((model) => model.name === parsed.className);
3390
3547
  }, prismaEnums);
3548
+ const modelTypes = this.syncModelRegistryTypes(modelFiles);
3391
3549
  return {
3392
3550
  schemaPath,
3393
3551
  modelsDir,
3552
+ modelTypesPath: modelTypes.path,
3394
3553
  total: modelFiles.length,
3395
- updated: result.updated,
3554
+ updated: modelTypes.updated ? [...result.updated, modelTypes.path] : result.updated,
3396
3555
  skipped: result.skipped
3397
3556
  };
3398
3557
  }
@@ -3502,11 +3661,11 @@ var DbCommand = class extends Command {
3502
3661
  const filePath = this.option("file") ? String(this.option("file")) : void 0;
3503
3662
  if (filePath) {
3504
3663
  const resolved = resolve(filePath);
3505
- if (!existsSync$1(resolved)) {
3664
+ if (!existsSync(resolved)) {
3506
3665
  this.error(`Error: SQL file not found: ${this.app.formatPathForLog(resolved)}`);
3507
3666
  return null;
3508
3667
  }
3509
- return readFileSync$1(resolved, "utf-8");
3668
+ return readFileSync(resolved, "utf-8");
3510
3669
  }
3511
3670
  return await this.multiline("Query", "Enter the SQL to execute");
3512
3671
  }
@@ -3592,18 +3751,18 @@ var InitCommand = class extends Command {
3592
3751
  const stubsDir = typeof stubs === "string" && stubs.trim().length > 0 ? stubs : getDefaultStubsPath();
3593
3752
  const preferredStubPath = join(stubsDir, "arkormx.config.stub");
3594
3753
  const legacyStubPath = join(stubsDir, "arkorm.config.stub");
3595
- const stubPath = existsSync(preferredStubPath) ? preferredStubPath : legacyStubPath;
3596
- if (existsSync(outputDir) && !this.option("force")) {
3754
+ const stubPath = existsSync$1(preferredStubPath) ? preferredStubPath : legacyStubPath;
3755
+ if (existsSync$1(outputDir) && !this.option("force")) {
3597
3756
  this.error("Error: Arkormˣ has already been initialized. Use --force to reinitialize.");
3598
3757
  process.exit(1);
3599
3758
  }
3600
3759
  this.app.ensureDirectory(outputDir);
3601
- if (existsSync(outputDir) && this.option("force")) copyFileSync(outputDir, outputDir.replace(/\.js$/, `.backup.${Date.now()}.js`));
3602
- if (!existsSync(stubPath)) {
3760
+ if (existsSync$1(outputDir) && this.option("force")) copyFileSync(outputDir, outputDir.replace(/\.js$/, `.backup.${Date.now()}.js`));
3761
+ if (!existsSync$1(stubPath)) {
3603
3762
  this.error(`Error: Missing config stub at ${preferredStubPath} (or ${legacyStubPath})`);
3604
3763
  process.exit(1);
3605
3764
  }
3606
- writeFileSync(outputDir, readFileSync(stubPath, "utf-8"));
3765
+ writeFileSync$1(outputDir, readFileSync$1(stubPath, "utf-8"));
3607
3766
  this.success("Arkormˣ initialized successfully!");
3608
3767
  }
3609
3768
  };
@@ -3785,6 +3944,7 @@ var MigrateCommand = class extends Command {
3785
3944
  {--deploy : Use prisma migrate deploy instead of migrate dev (Prisma compatibility driver only)}
3786
3945
  {--skip-generate : Skip prisma generate (Prisma compatibility driver only)}
3787
3946
  {--skip-migrate : Skip prisma migrate command}
3947
+ {--r|registry : Sync the generated model registry type augmentation after a successful migration}
3788
3948
  {--state-file= : Path to applied migration state file}
3789
3949
  {--schema= : Explicit prisma schema path (Prisma compatibility driver only)}
3790
3950
  {--migration-name= : Name for prisma migrate dev (Prisma compatibility driver only)}
@@ -3841,6 +4001,7 @@ var MigrateCommand = class extends Command {
3841
4001
  this.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
3842
4002
  return;
3843
4003
  }
4004
+ if (!this.syncModelRegistryIfRequested()) return;
3844
4005
  this.success("No pending migration classes to apply.");
3845
4006
  return;
3846
4007
  }
@@ -3899,6 +4060,18 @@ var MigrateCommand = class extends Command {
3899
4060
  ], process.cwd());
3900
4061
  this.success(`Applied ${pending.length} migration(s).`);
3901
4062
  pending.forEach(([_, file]) => this.success(this.app.splitLogger("Migrated", file)));
4063
+ this.syncModelRegistryIfRequested();
4064
+ }
4065
+ syncModelRegistryIfRequested() {
4066
+ if (!this.option("registry") && !this.option("r")) return true;
4067
+ try {
4068
+ const result = this.app.syncModelRegistry();
4069
+ this.success(this.app.splitLogger("Model Types", result.modelTypesPath ?? "none"));
4070
+ return true;
4071
+ } catch (error) {
4072
+ this.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
4073
+ return false;
4074
+ }
3902
4075
  }
3903
4076
  /**
3904
4077
  * Load all migration classes from the specified directory.
@@ -3906,10 +4079,10 @@ var MigrateCommand = class extends Command {
3906
4079
  * @param migrationsDir The directory to load migration classes from.
3907
4080
  */
3908
4081
  resolveMigrationDirectories(configuredMigrationsDir) {
3909
- return [this.app.resolveRuntimeDirectoryPath(configuredMigrationsDir), ...getRegisteredPaths("migrations").map((directory) => this.app.resolveRuntimeDirectoryPath(directory))].filter((directory, index, all) => existsSync$1(directory) && all.indexOf(directory) === index);
4082
+ return [this.app.resolveRuntimeDirectoryPath(configuredMigrationsDir), ...getRegisteredPaths("migrations").map((directory) => this.app.resolveRuntimeDirectoryPath(directory))].filter((directory, index, all) => existsSync(directory) && all.indexOf(directory) === index);
3910
4083
  }
3911
4084
  async loadAllMigrations(migrationsDirs) {
3912
- const files = migrationsDirs.flatMap((migrationsDir) => readdirSync$1(migrationsDir).filter((file) => /\.(ts|js|mjs|cjs)$/i.test(file)).sort((left, right) => left.localeCompare(right)).map((file) => this.app.resolveRuntimeScriptPath(join(migrationsDir, file))));
4085
+ const files = migrationsDirs.flatMap((migrationsDir) => readdirSync(migrationsDir).filter((file) => /\.(ts|js|mjs|cjs)$/i.test(file)).sort((left, right) => left.localeCompare(right)).map((file) => this.app.resolveRuntimeScriptPath(join(migrationsDir, file))));
3913
4086
  return [...(await Promise.all(files.map(async (file) => (await this.loadMigrationClassesFromFile(file)).map((cls) => [cls, file])))).flat(), ...getRegisteredMigrations().map((cls) => [cls, `registered:${cls.name}`])];
3914
4087
  }
3915
4088
  /**
@@ -3933,7 +4106,7 @@ var MigrateCommand = class extends Command {
3933
4106
  `${base}Migration.js`,
3934
4107
  `${base}Migration.mjs`,
3935
4108
  `${base}Migration.cjs`
3936
- ].map((file) => join(migrationsDir, file))).find((file) => existsSync$1(file));
4109
+ ].map((file) => join(migrationsDir, file))).find((file) => existsSync(file));
3937
4110
  if (!target) return [[void 0, name]];
3938
4111
  const runtimeTarget = this.app.resolveRuntimeScriptPath(target);
3939
4112
  return (await this.loadMigrationClassesFromFile(runtimeTarget)).map((cls) => [cls, runtimeTarget]);
@@ -4040,8 +4213,8 @@ var MigrateFreshCommand = class extends Command {
4040
4213
  }
4041
4214
  if (!(await this.runWithDatabaseCreationRetry(adapter, () => adapter.resetDatabase())).ok) return;
4042
4215
  } else {
4043
- if (!existsSync$1(schemaPath)) return void this.error(`Error: Prisma schema file not found: ${this.app.formatPathForLog(schemaPath)}`);
4044
- writeFileSync$1(schemaPath, stripPrismaSchemaModelsAndEnums(readFileSync$1(schemaPath, "utf-8")));
4216
+ if (!existsSync(schemaPath)) return void this.error(`Error: Prisma schema file not found: ${this.app.formatPathForLog(schemaPath)}`);
4217
+ writeFileSync(schemaPath, stripPrismaSchemaModelsAndEnums(readFileSync(schemaPath, "utf-8")));
4045
4218
  }
4046
4219
  let appliedState = createEmptyAppliedMigrationsState();
4047
4220
  if (!(await this.runWithDatabaseCreationRetry(adapter, () => writeAppliedMigrationsStateToStore(adapter, stateFilePath, appliedState))).ok) return;
@@ -4088,10 +4261,10 @@ var MigrateFreshCommand = class extends Command {
4088
4261
  migrations.forEach(([_, file]) => this.success(this.app.splitLogger("Migrated", file)));
4089
4262
  }
4090
4263
  resolveMigrationDirectories(configuredMigrationsDir) {
4091
- return [this.app.resolveRuntimeDirectoryPath(configuredMigrationsDir), ...getRegisteredPaths("migrations").map((directory) => this.app.resolveRuntimeDirectoryPath(directory))].filter((directory, index, all) => existsSync$1(directory) && all.indexOf(directory) === index);
4264
+ return [this.app.resolveRuntimeDirectoryPath(configuredMigrationsDir), ...getRegisteredPaths("migrations").map((directory) => this.app.resolveRuntimeDirectoryPath(directory))].filter((directory, index, all) => existsSync(directory) && all.indexOf(directory) === index);
4092
4265
  }
4093
4266
  async loadAllMigrations(migrationsDirs) {
4094
- const files = migrationsDirs.flatMap((migrationsDir) => readdirSync$1(migrationsDir).filter((file) => /\.(ts|js|mjs|cjs)$/i.test(file)).sort((left, right) => left.localeCompare(right)).map((file) => this.app.resolveRuntimeScriptPath(join(migrationsDir, file))));
4267
+ const files = migrationsDirs.flatMap((migrationsDir) => readdirSync(migrationsDir).filter((file) => /\.(ts|js|mjs|cjs)$/i.test(file)).sort((left, right) => left.localeCompare(right)).map((file) => this.app.resolveRuntimeScriptPath(join(migrationsDir, file))));
4095
4268
  return [...(await Promise.all(files.map(async (file) => (await this.loadMigrationClassesFromFile(file)).map((cls) => [cls, file])))).flat(), ...getRegisteredMigrations().map((cls) => [cls, `registered:${cls.name}`])];
4096
4269
  }
4097
4270
  async loadMigrationClassesFromFile(filePath) {
@@ -4236,10 +4409,10 @@ var MigrateRollbackCommand = class extends Command {
4236
4409
  rollbackClasses.forEach(([_, file]) => this.success(this.app.splitLogger("RolledBack", file)));
4237
4410
  }
4238
4411
  resolveMigrationDirectories(configuredMigrationsDir) {
4239
- return [this.app.resolveRuntimeDirectoryPath(configuredMigrationsDir), ...getRegisteredPaths("migrations").map((directory) => this.app.resolveRuntimeDirectoryPath(directory))].filter((directory, index, all) => existsSync$1(directory) && all.indexOf(directory) === index);
4412
+ return [this.app.resolveRuntimeDirectoryPath(configuredMigrationsDir), ...getRegisteredPaths("migrations").map((directory) => this.app.resolveRuntimeDirectoryPath(directory))].filter((directory, index, all) => existsSync(directory) && all.indexOf(directory) === index);
4240
4413
  }
4241
4414
  async loadAllMigrations(migrationsDirs) {
4242
- const files = migrationsDirs.flatMap((migrationsDir) => readdirSync$1(migrationsDir).filter((file) => /\.(ts|js|mjs|cjs)$/i.test(file)).sort((left, right) => left.localeCompare(right)).map((file) => this.app.resolveRuntimeScriptPath(join(migrationsDir, file))));
4415
+ const files = migrationsDirs.flatMap((migrationsDir) => readdirSync(migrationsDir).filter((file) => /\.(ts|js|mjs|cjs)$/i.test(file)).sort((left, right) => left.localeCompare(right)).map((file) => this.app.resolveRuntimeScriptPath(join(migrationsDir, file))));
4243
4416
  return [...(await Promise.all(files.map(async (file) => (await this.loadMigrationClassesFromFile(file)).map((cls) => [cls, file])))).flat(), ...getRegisteredMigrations().map((cls) => [cls, `registered:${cls.name}`])];
4244
4417
  }
4245
4418
  async loadMigrationClassesFromFile(filePath) {
@@ -4285,11 +4458,11 @@ var MigrationHistoryCommand = class extends Command {
4285
4458
  this.success("Deleted tracked migration state from database.");
4286
4459
  return;
4287
4460
  }
4288
- if (!existsSync$1(stateFilePath)) {
4461
+ if (!existsSync(stateFilePath)) {
4289
4462
  this.success(`No migration state file found at ${this.app.formatPathForLog(stateFilePath)}`);
4290
4463
  return;
4291
4464
  }
4292
- rmSync$1(stateFilePath);
4465
+ rmSync(stateFilePath);
4293
4466
  deletePersistedColumnMappingsState(resolveColumnMappingsFilePath(process.cwd()));
4294
4467
  this.success(`Deleted migration state file: ${this.app.formatPathForLog(stateFilePath)}`);
4295
4468
  return;
@@ -4328,6 +4501,7 @@ var ModelsSyncCommand = class extends Command {
4328
4501
  this.signature = `models:sync
4329
4502
  {--schema= : Path to prisma schema file used when adapter introspection is unavailable}
4330
4503
  {--models= : Path to models directory}
4504
+ {--r|registry-only : Only sync the generated model registry type augmentation}
4331
4505
  `;
4332
4506
  this.description = "Sync model declare attributes from the active adapter when supported";
4333
4507
  }
@@ -4336,10 +4510,11 @@ var ModelsSyncCommand = class extends Command {
4336
4510
  await loadArkormConfig();
4337
4511
  let result;
4338
4512
  try {
4339
- result = await this.app.syncModels({
4513
+ const options = {
4340
4514
  schemaPath: this.option("schema") ? resolve(String(this.option("schema"))) : void 0,
4341
4515
  modelsDir: this.option("models") ? resolve(String(this.option("models"))) : void 0
4342
- });
4516
+ };
4517
+ result = this.option("registryOnly") || this.option("registry-only") || this.option("r") ? this.app.syncModelRegistry({ modelsDir: options.modelsDir }) : await this.app.syncModels(options);
4343
4518
  } catch (error) {
4344
4519
  this.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
4345
4520
  return;
@@ -4347,9 +4522,10 @@ var ModelsSyncCommand = class extends Command {
4347
4522
  const updatedLines = result.updated.length === 0 ? [this.app.splitLogger("Updated", "none")] : result.updated.map((path) => this.app.splitLogger("Updated", path));
4348
4523
  this.success("SUCCESS: Model sync completed with the following results:");
4349
4524
  [
4350
- this.app.splitLogger("Source", result.source === "adapter" ? "adapter introspection" : "prisma schema"),
4525
+ this.app.splitLogger("Source", result.source === "adapter" ? "adapter introspection" : result.source === "registry" ? "model registry" : "prisma schema"),
4351
4526
  ...result.schemaPath ? [this.app.splitLogger("Schema", result.schemaPath)] : [],
4352
4527
  this.app.splitLogger("Models", result.modelsDir),
4528
+ ...result.modelTypesPath ? [this.app.splitLogger("Model Types", result.modelTypesPath)] : [],
4353
4529
  this.app.splitLogger("Processed", String(result.total)),
4354
4530
  ...updatedLines,
4355
4531
  this.app.splitLogger("Skipped", String(result.skipped.length))
@@ -4469,10 +4645,10 @@ var SeedCommand = class extends Command {
4469
4645
  * @returns
4470
4646
  */
4471
4647
  resolveSeederDirectories(configuredSeedersDir) {
4472
- return [this.app.resolveRuntimeDirectoryPath(configuredSeedersDir), ...getRegisteredPaths("seeders").map((directory) => this.app.resolveRuntimeDirectoryPath(directory))].filter((directory, index, all) => existsSync$1(directory) && all.indexOf(directory) === index);
4648
+ return [this.app.resolveRuntimeDirectoryPath(configuredSeedersDir), ...getRegisteredPaths("seeders").map((directory) => this.app.resolveRuntimeDirectoryPath(directory))].filter((directory, index, all) => existsSync(directory) && all.indexOf(directory) === index);
4473
4649
  }
4474
4650
  async loadAllSeeders(seedersDirs) {
4475
- const files = seedersDirs.flatMap((seedersDir) => readdirSync$1(seedersDir).filter((file) => /\.(ts|js|mjs|cjs)$/i.test(file)).map((file) => this.app.resolveRuntimeScriptPath(join(seedersDir, file))));
4651
+ const files = seedersDirs.flatMap((seedersDir) => readdirSync(seedersDir).filter((file) => /\.(ts|js|mjs|cjs)$/i.test(file)).map((file) => this.app.resolveRuntimeScriptPath(join(seedersDir, file))));
4476
4652
  return [...(await Promise.all(files.map(async (file) => await this.loadSeederClassesFromFile(file)))).flat(), ...getRegisteredSeeders()];
4477
4653
  }
4478
4654
  /**
@@ -4495,7 +4671,7 @@ var SeedCommand = class extends Command {
4495
4671
  `${base}Seeder.js`,
4496
4672
  `${base}Seeder.mjs`,
4497
4673
  `${base}Seeder.cjs`
4498
- ].map((file) => join(seedersDir, file))).find((file) => existsSync$1(file));
4674
+ ].map((file) => join(seedersDir, file))).find((file) => existsSync(file));
4499
4675
  if (!target) return [];
4500
4676
  const runtimeTarget = this.app.resolveRuntimeScriptPath(target);
4501
4677
  return await this.loadSeederClassesFromFile(runtimeTarget);
@@ -9664,115 +9840,50 @@ var Model = class Model {
9664
9840
  isNotSame(model) {
9665
9841
  return !this.isSame(model);
9666
9842
  }
9667
- /**
9668
- * Define a has one relationship.
9669
- *
9670
- * @param related
9671
- * @param foreignKey
9672
- * @param localKey
9673
- * @returns
9674
- */
9675
9843
  hasOne(related, foreignKey, localKey) {
9676
9844
  const constructor = this.constructor;
9677
- return new HasOneRelation(this, related, foreignKey, localKey ?? constructor.getPrimaryKey());
9845
+ const relatedModel = this.resolveRelationshipModel(related, "hasOne");
9846
+ const resolvedLocalKey = localKey ?? constructor.getPrimaryKey();
9847
+ return new HasOneRelation(this, relatedModel, foreignKey ?? this.resolveDefaultHasForeignKey(constructor, resolvedLocalKey), resolvedLocalKey);
9678
9848
  }
9679
- /**
9680
- * Define a has many relationship.
9681
- *
9682
- * @param related
9683
- * @param foreignKey
9684
- * @param localKey
9685
- * @returns
9686
- */
9687
9849
  hasMany(related, foreignKey, localKey) {
9688
9850
  const constructor = this.constructor;
9689
- return new HasManyRelation(this, related, foreignKey, localKey ?? constructor.getPrimaryKey());
9851
+ const relatedModel = this.resolveRelationshipModel(related, "hasMany");
9852
+ const resolvedLocalKey = localKey ?? constructor.getPrimaryKey();
9853
+ return new HasManyRelation(this, relatedModel, foreignKey ?? this.resolveDefaultHasForeignKey(constructor, resolvedLocalKey), resolvedLocalKey);
9690
9854
  }
9691
- /**
9692
- * Define a belongs to relationship.
9693
- *
9694
- * @param related
9695
- * @param foreignKey
9696
- * @param ownerKey
9697
- * @returns
9698
- */
9699
9855
  belongsTo(related, foreignKey, ownerKey) {
9700
- return new BelongsToRelation(this, related, foreignKey, ownerKey ?? related.getPrimaryKey());
9856
+ const relatedModel = this.resolveRelationshipModel(related, "belongsTo");
9857
+ const resolvedOwnerKey = ownerKey ?? relatedModel.getPrimaryKey();
9858
+ return new BelongsToRelation(this, relatedModel, foreignKey ?? this.resolveDefaultBelongsToForeignKey(relatedModel, resolvedOwnerKey), resolvedOwnerKey);
9701
9859
  }
9702
- /**
9703
- * Define a belongs to many relationship.
9704
- *
9705
- * @param related
9706
- * @param throughTable
9707
- * @param foreignPivotKey
9708
- * @param relatedPivotKey
9709
- * @param parentKey
9710
- * @param relatedKey
9711
- * @returns
9712
- */
9713
9860
  belongsToMany(related, throughTable, foreignPivotKey, relatedPivotKey, parentKey, relatedKey) {
9714
9861
  const constructor = this.constructor;
9715
- return new BelongsToManyRelation(this, related, throughTable, foreignPivotKey, relatedPivotKey, parentKey ?? constructor.getPrimaryKey(), relatedKey ?? related.getPrimaryKey());
9862
+ const relatedModel = this.resolveRelationshipModel(related, "belongsToMany");
9863
+ const resolvedRelatedKey = relatedKey ?? relatedModel.getPrimaryKey();
9864
+ return new BelongsToManyRelation(this, relatedModel, throughTable, foreignPivotKey, relatedPivotKey, parentKey ?? constructor.getPrimaryKey(), resolvedRelatedKey);
9716
9865
  }
9717
- /**
9718
- * Define a has one through relationship.
9719
- *
9720
- * @param related
9721
- * @param throughTable
9722
- * @param firstKey
9723
- * @param secondKey
9724
- * @param localKey
9725
- * @param secondLocalKey
9726
- * @returns
9727
- */
9728
- hasOneThrough(related, throughTable, firstKey, secondKey, localKey, secondLocalKey = "id") {
9866
+ hasOneThrough(related, throughTable, firstKey, secondKey, localKey, secondLocalKey) {
9729
9867
  const constructor = this.constructor;
9730
- return new HasOneThroughRelation(this, related, throughTable, firstKey, secondKey, localKey ?? constructor.getPrimaryKey(), secondLocalKey);
9868
+ const relatedModel = this.resolveRelationshipModel(related, "hasOneThrough");
9869
+ return new HasOneThroughRelation(this, relatedModel, throughTable, firstKey, secondKey, localKey ?? constructor.getPrimaryKey(), secondLocalKey ?? "id");
9731
9870
  }
9732
- /**
9733
- * Define a has many through relationship.
9734
- *
9735
- * @param related
9736
- * @param throughTable
9737
- * @param firstKey
9738
- * @param secondKey
9739
- * @param localKey
9740
- * @param secondLocalKey
9741
- * @returns
9742
- */
9743
9871
  hasManyThrough(related, throughTable, firstKey, secondKey, localKey, secondLocalKey = "id") {
9744
9872
  const constructor = this.constructor;
9745
- return new HasManyThroughRelation(this, related, throughTable, firstKey, secondKey, localKey ?? constructor.getPrimaryKey(), secondLocalKey);
9873
+ const relatedModel = this.resolveRelationshipModel(related, "hasManyThrough");
9874
+ return new HasManyThroughRelation(this, relatedModel, throughTable, firstKey, secondKey, localKey ?? constructor.getPrimaryKey(), secondLocalKey);
9746
9875
  }
9747
- /**
9748
- * Define a polymorphic one to one relationship.
9749
- *
9750
- * @param related
9751
- * @param morphName
9752
- * @param idColumn
9753
- * @param typeColumn
9754
- * @param localKey
9755
- * @returns
9756
- */
9757
9876
  morphOne(related, morphName, idColumn, typeColumn, localKey) {
9758
9877
  const constructor = this.constructor;
9878
+ const relatedModel = this.resolveRelationshipModel(related, "morphOne");
9759
9879
  const columns = this.resolveMorphColumns(morphName, idColumn, typeColumn);
9760
- return new MorphOneRelation(this, related, morphName, columns.idColumn, columns.typeColumn, localKey ?? constructor.getPrimaryKey());
9880
+ return new MorphOneRelation(this, relatedModel, morphName, columns.idColumn, columns.typeColumn, localKey ?? constructor.getPrimaryKey());
9761
9881
  }
9762
- /**
9763
- * Define a polymorphic one to many relationship.
9764
- *
9765
- * @param related
9766
- * @param morphName
9767
- * @param idColumn
9768
- * @param typeColumn
9769
- * @param localKey
9770
- * @returns
9771
- */
9772
9882
  morphMany(related, morphName, idColumn, typeColumn, localKey) {
9773
9883
  const constructor = this.constructor;
9884
+ const relatedModel = this.resolveRelationshipModel(related, "morphMany");
9774
9885
  const columns = this.resolveMorphColumns(morphName, idColumn, typeColumn);
9775
- return new MorphManyRelation(this, related, morphName, columns.idColumn, columns.typeColumn, localKey ?? constructor.getPrimaryKey());
9886
+ return new MorphManyRelation(this, relatedModel, morphName, columns.idColumn, columns.typeColumn, localKey ?? constructor.getPrimaryKey());
9776
9887
  }
9777
9888
  morphTo(morphName, typeColumnOrRelated, idColumn, ownerKey) {
9778
9889
  const related = typeof typeColumnOrRelated === "function" ? typeColumnOrRelated : void 0;
@@ -9780,51 +9891,37 @@ var Model = class Model {
9780
9891
  const columns = this.resolveMorphColumns(morphName, idColumn, typeColumn);
9781
9892
  return new MorphToRelation(this, morphName, columns.typeColumn, columns.idColumn, ownerKey, related);
9782
9893
  }
9783
- /**
9784
- * Define a polymorphic many to many relationship.
9785
- *
9786
- * @param related
9787
- * @param morphName
9788
- * @param throughTable
9789
- * @param foreignPivotKey
9790
- * @param morphTypeColumn
9791
- * @param relatedPivotKey
9792
- * @param parentKey
9793
- * @param relatedKey
9794
- * @returns
9795
- */
9796
9894
  morphToMany(related, morphName, throughTable, foreignPivotKey, morphTypeColumn, relatedPivotKey, parentKey, relatedKey) {
9797
9895
  const constructor = this.constructor;
9798
9896
  const namingCase = Model.getNamingCase();
9799
- const resolvedRelatedKey = relatedKey ?? related.getPrimaryKey();
9897
+ const relatedModel = this.resolveRelationshipModel(related, "morphToMany");
9898
+ const resolvedRelatedKey = relatedKey ?? relatedModel.getPrimaryKey();
9800
9899
  const resolvedTable = throughTable ?? this.formatConventionName(`${str(morphName).plural()}`, namingCase);
9801
- const resolvedRelatedPivotKey = relatedPivotKey ?? this.formatConventionName(`${str(related.getTable()).singular()}_${resolvedRelatedKey}`, namingCase);
9900
+ const resolvedRelatedPivotKey = relatedPivotKey ?? this.formatConventionName(`${str(relatedModel.getTable()).singular()}_${resolvedRelatedKey}`, namingCase);
9802
9901
  const morphIdColumn = foreignPivotKey ?? this.formatConventionName(`${morphName}_id`, namingCase);
9803
9902
  const resolvedMorphTypeColumn = morphTypeColumn ?? this.formatConventionName(`${morphName}_type`, namingCase);
9804
- return new MorphToManyRelation(this, related, resolvedTable, morphName, morphIdColumn, resolvedMorphTypeColumn, resolvedRelatedPivotKey, parentKey ?? constructor.getPrimaryKey(), resolvedRelatedKey);
9903
+ return new MorphToManyRelation(this, relatedModel, resolvedTable, morphName, morphIdColumn, resolvedMorphTypeColumn, resolvedRelatedPivotKey, parentKey ?? constructor.getPrimaryKey(), resolvedRelatedKey);
9805
9904
  }
9806
- /**
9807
- * Define the inverse side of a polymorphic many-to-many relationship.
9808
- *
9809
- * @param related
9810
- * @param morphName
9811
- * @param throughTable
9812
- * @param foreignPivotKey
9813
- * @param morphTypeColumn
9814
- * @param relatedPivotKey
9815
- * @param parentKey
9816
- * @param relatedKey
9817
- * @returns
9818
- */
9819
9905
  morphedByMany(related, morphName, throughTable, foreignPivotKey, morphTypeColumn, relatedPivotKey, parentKey, relatedKey) {
9820
9906
  const constructor = this.constructor;
9821
9907
  const namingCase = Model.getNamingCase();
9822
- const resolvedRelatedKey = relatedKey ?? related.getPrimaryKey();
9908
+ const relatedModel = this.resolveRelationshipModel(related, "morphedByMany");
9909
+ const resolvedRelatedKey = relatedKey ?? relatedModel.getPrimaryKey();
9823
9910
  const resolvedTable = throughTable ?? this.formatConventionName(`${str(morphName).plural()}`, namingCase);
9824
9911
  const resolvedForeignPivotKey = foreignPivotKey ?? this.formatConventionName(`${str(constructor.getTable()).singular()}_${parentKey ?? constructor.getPrimaryKey()}`, namingCase);
9825
9912
  const resolvedMorphTypeColumn = morphTypeColumn ?? this.formatConventionName(`${morphName}_type`, namingCase);
9826
9913
  const resolvedRelatedPivotKey = relatedPivotKey ?? this.formatConventionName(`${morphName}_id`, namingCase);
9827
- return new MorphedByManyRelation(this, related, resolvedTable, morphName, resolvedForeignPivotKey, resolvedMorphTypeColumn, resolvedRelatedPivotKey, parentKey ?? constructor.getPrimaryKey(), resolvedRelatedKey);
9914
+ return new MorphedByManyRelation(this, relatedModel, resolvedTable, morphName, resolvedForeignPivotKey, resolvedMorphTypeColumn, resolvedRelatedPivotKey, parentKey ?? constructor.getPrimaryKey(), resolvedRelatedKey);
9915
+ }
9916
+ resolveRelationshipModel(related, operation) {
9917
+ if (typeof related === "function") return related;
9918
+ return resolveRegisteredModel(related, { operation });
9919
+ }
9920
+ resolveDefaultHasForeignKey(parent, localKey) {
9921
+ return this.formatConventionName(`${str(parent.getTable()).singular()}_${localKey}`, Model.getNamingCase());
9922
+ }
9923
+ resolveDefaultBelongsToForeignKey(related, ownerKey) {
9924
+ return this.formatConventionName(`${str(related.getTable()).singular()}_${ownerKey}`, Model.getNamingCase());
9828
9925
  }
9829
9926
  resolveMorphColumns(morphName, idColumn, typeColumn) {
9830
9927
  const namingCase = Model.getNamingCase();
@@ -10774,4 +10871,4 @@ var PivotModel = class extends Model {
10774
10871
  };
10775
10872
 
10776
10873
  //#endregion
10777
- export { AggregateExpression, Arkorm, ArkormCollection, ArkormException, Arkormx, Attribute, CaseExpression, CliApp, DB, DbCommand, EnumBuilder, Expression, ForeignKeyBuilder, InitCommand, InlineFactory, JoinClause, JsonExpression, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateFreshCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PivotModel, PrimaryKeyGenerationPlanner, PrismaDatabaseAdapter, QueryBuilder, QueryConstraintException, QueryExecutionException, RelationResolutionException, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToDatabase, applyMigrationRollbackToPrismaSchema, applyMigrationToDatabase, applyMigrationToPrismaSchema, applyOperationsToPersistedColumnMappingsState, applyOperationsToPrismaSchema, avg, awaitConfiguredModelsRegistration, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildPrimaryKeyLine, buildRelationLine, buildUniqueConstraintLine, caseWhen, coalesce, col, computeMigrationChecksum, configureArkormRuntime, count, createEmptyAppliedMigrationsState, createEmptyPersistedColumnMappingsState, createKyselyAdapter, createMigrationTimestamp, createPrismaAdapter, createPrismaCompatibilityAdapter, createPrismaDatabaseAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deleteAppliedMigrationsStateFromStore, deletePersistedColumnMappingsState, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, disposeArkormRuntime, emitRuntimeDebugEvent, ensureArkormConfigLoading, escapeRegex, expressionBuilder, findAppliedMigration, findEnumBlock, findModelBlock, fn, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, fromExpressionNode, generateMigrationFile, getActiveTransactionAdapter, getActiveTransactionClient, getDefaultStubsPath, getLastBatchMigrations, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getPersistedColumnMap, getPersistedEnumMap, getPersistedEnumTsType, getPersistedPrimaryKeyGeneration, getPersistedTableMetadata, getPersistedTimestampColumns, getRegisteredFactories, getRegisteredMigrations, getRegisteredModels, getRegisteredPaths, getRegisteredSeeders, getRuntimeAdapter, getRuntimeClient, getRuntimeCompatibilityAdapter, getRuntimeDebugHandler, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isMigrationPlanningActive, isQuerySchemaLike, isTransactionCapableClient, json, loadArkormConfig, loadFactoriesFrom, loadMigrationsFrom, loadModelsFrom, loadSeedersFrom, markMigrationApplied, markMigrationRun, max, min, pad, raw, readAppliedMigrationsState, readAppliedMigrationsStateFromStore, readPersistedColumnMappingsState, rebuildPersistedColumnMappingsState, registerFactories, registerMigrations, registerModels, registerPaths, registerSeeders, removeAppliedMigration, resetArkormRuntimeForTests, resetPersistedColumnMappingsCache, resetRuntimeRegistryForTests, resolveCast, resolveColumnMappingsFilePath, resolveEnumName, resolveGeneratedExpression, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePersistedMetadataFeatures, resolvePrismaType, resolveRuntimeCompatibilityQuerySchema, resolveRuntimeCompatibilityQuerySchemaOrThrow, runArkormTransaction, runInMigrationPlanning, runMigrationWithPrisma, runPrismaCommand, stripPrismaSchemaModelsAndEnums, sum, supportsDatabaseCreation, supportsDatabaseMigrationExecution, supportsDatabaseMigrationState, supportsDatabaseReset, syncPersistedColumnMappingsFromState, toMigrationFileSlug, toModelName, val, validatePersistedMetadataFeaturesForMigrations, where, writeAppliedMigrationsState, writeAppliedMigrationsStateToStore, writePersistedColumnMappingsState };
10874
+ export { AggregateExpression, Arkorm, ArkormCollection, ArkormException, Arkormx, Attribute, CaseExpression, CliApp, DB, DbCommand, EnumBuilder, Expression, ForeignKeyBuilder, InitCommand, InlineFactory, JoinClause, JsonExpression, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateFreshCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PivotModel, PrimaryKeyGenerationPlanner, PrismaDatabaseAdapter, QueryBuilder, QueryConstraintException, QueryExecutionException, RelationResolutionException, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToDatabase, applyMigrationRollbackToPrismaSchema, applyMigrationToDatabase, applyMigrationToPrismaSchema, applyOperationsToPersistedColumnMappingsState, applyOperationsToPrismaSchema, avg, awaitConfiguredModelsRegistration, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildPrimaryKeyLine, buildRelationLine, buildUniqueConstraintLine, caseWhen, coalesce, col, computeMigrationChecksum, configureArkormRuntime, count, createEmptyAppliedMigrationsState, createEmptyPersistedColumnMappingsState, createKyselyAdapter, createMigrationTimestamp, createPrismaAdapter, createPrismaCompatibilityAdapter, createPrismaDatabaseAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deleteAppliedMigrationsStateFromStore, deletePersistedColumnMappingsState, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, disposeArkormRuntime, emitRuntimeDebugEvent, ensureArkormConfigLoading, escapeRegex, expressionBuilder, findAppliedMigration, findEnumBlock, findModelBlock, fn, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, fromExpressionNode, generateMigrationFile, getActiveTransactionAdapter, getActiveTransactionClient, getDefaultStubsPath, getLastBatchMigrations, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getModel, getPersistedColumnMap, getPersistedEnumMap, getPersistedEnumTsType, getPersistedPrimaryKeyGeneration, getPersistedTableMetadata, getPersistedTimestampColumns, getRegisteredFactories, getRegisteredMigrations, getRegisteredModels, getRegisteredPaths, getRegisteredSeeders, getRuntimeAdapter, getRuntimeClient, getRuntimeCompatibilityAdapter, getRuntimeDebugHandler, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isQuerySchemaLike, isTransactionCapableClient, json, loadArkormConfig, loadFactoriesFrom, loadMigrationsFrom, loadModelsFrom, loadSeedersFrom, markMigrationApplied, markMigrationRun, max, min, pad, raw, readAppliedMigrationsState, readAppliedMigrationsStateFromStore, readPersistedColumnMappingsState, rebuildPersistedColumnMappingsState, registerFactories, registerMigrations, registerModels, registerPaths, registerSeeders, removeAppliedMigration, resetArkormRuntimeForTests, resetPersistedColumnMappingsCache, resetRuntimeRegistryForTests, resolveCast, resolveColumnMappingsFilePath, resolveEnumName, resolveGeneratedExpression, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePersistedMetadataFeatures, resolvePrismaType, resolveRegisteredModel, resolveRuntimeCompatibilityQuerySchema, resolveRuntimeCompatibilityQuerySchemaOrThrow, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, stripPrismaSchemaModelsAndEnums, sum, supportsDatabaseCreation, supportsDatabaseMigrationExecution, supportsDatabaseMigrationState, supportsDatabaseReset, syncPersistedColumnMappingsFromState, toMigrationFileSlug, toModelName, val, validatePersistedMetadataFeaturesForMigrations, where, writeAppliedMigrationsState, writeAppliedMigrationsStateToStore, writePersistedColumnMappingsState };