arkormx 1.3.0 → 1.3.2

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.cjs CHANGED
@@ -33,13 +33,14 @@ let _h3ravel_support = require("@h3ravel/support");
33
33
  let path = require("path");
34
34
  path = __toESM(path);
35
35
  let fs = require("fs");
36
- let url = require("url");
37
36
  let async_hooks = require("async_hooks");
37
+ let _rexxars_jiti = require("@rexxars/jiti");
38
+ let node_url = require("node:url");
38
39
  let module$1 = require("module");
40
+ let url = require("url");
39
41
  let _h3ravel_shared = require("@h3ravel/shared");
40
42
  let _h3ravel_musket = require("@h3ravel/musket");
41
43
  let node_crypto = require("node:crypto");
42
- let node_url = require("node:url");
43
44
  let _h3ravel_collect_js = require("@h3ravel/collect.js");
44
45
 
45
46
  //#region src/Attribute.ts
@@ -1554,6 +1555,18 @@ const runMigrationWithPrisma = async (migration, options = {}) => {
1554
1555
  };
1555
1556
  };
1556
1557
 
1558
+ //#endregion
1559
+ //#region src/helpers/runtime-module-loader.ts
1560
+ var RuntimeModuleLoader = class {
1561
+ static async load(filePath) {
1562
+ const resolvedPath = (0, node_path.resolve)(filePath);
1563
+ return await (0, _rexxars_jiti.createJiti)((0, node_url.pathToFileURL)(resolvedPath).href, {
1564
+ interopDefault: false,
1565
+ tsconfigPaths: true
1566
+ }).import(resolvedPath);
1567
+ }
1568
+ };
1569
+
1557
1570
  //#endregion
1558
1571
  //#region src/Exceptions/UnsupportedAdapterFeatureException.ts
1559
1572
  var UnsupportedAdapterFeatureException = class extends ArkormException {
@@ -1706,7 +1719,7 @@ const resolveAndApplyConfig = (imported) => {
1706
1719
  * @returns A promise that resolves to the imported configuration module.
1707
1720
  */
1708
1721
  const importConfigFile = (configPath) => {
1709
- return import(`${(0, url.pathToFileURL)(configPath).href}?arkorm_runtime=${Date.now()}`);
1722
+ return RuntimeModuleLoader.load(configPath);
1710
1723
  };
1711
1724
  const loadRuntimeConfigSync = () => {
1712
1725
  const require = (0, module$1.createRequire)(require("url").pathToFileURL(__filename).href);
@@ -2146,10 +2159,225 @@ var CliApp = class {
2146
2159
  if (value === "String") return "string";
2147
2160
  if (value === "Boolean") return "boolean";
2148
2161
  if (value === "DateTime") return "Date";
2149
- if (value === "Json") return "Record<string, unknown>";
2162
+ if (value === "Json") return "Record<string, unknown> | unknown[]";
2150
2163
  if (value === "Bytes") return "Buffer";
2151
2164
  return "unknown";
2152
2165
  }
2166
+ splitTopLevel(value, delimiter) {
2167
+ const parts = [];
2168
+ let start = 0;
2169
+ let angleDepth = 0;
2170
+ let parenthesisDepth = 0;
2171
+ let quote = null;
2172
+ for (let index = 0; index < value.length; index += 1) {
2173
+ const character = value[index];
2174
+ const previous = index > 0 ? value[index - 1] : "";
2175
+ if (quote) {
2176
+ if (character === quote && previous !== "\\") quote = null;
2177
+ continue;
2178
+ }
2179
+ if (character === "'" || character === "\"") {
2180
+ quote = character;
2181
+ continue;
2182
+ }
2183
+ if (character === "<") {
2184
+ angleDepth += 1;
2185
+ continue;
2186
+ }
2187
+ if (character === ">") {
2188
+ angleDepth = Math.max(0, angleDepth - 1);
2189
+ continue;
2190
+ }
2191
+ if (character === "(") {
2192
+ parenthesisDepth += 1;
2193
+ continue;
2194
+ }
2195
+ if (character === ")") {
2196
+ parenthesisDepth = Math.max(0, parenthesisDepth - 1);
2197
+ continue;
2198
+ }
2199
+ if (character === delimiter && angleDepth === 0 && parenthesisDepth === 0) {
2200
+ parts.push(value.slice(start, index).trim());
2201
+ start = index + 1;
2202
+ }
2203
+ }
2204
+ parts.push(value.slice(start).trim());
2205
+ return parts.filter(Boolean);
2206
+ }
2207
+ hasWrappedParentheses(value) {
2208
+ if (!value.startsWith("(") || !value.endsWith(")")) return false;
2209
+ let depth = 0;
2210
+ let quote = null;
2211
+ for (let index = 0; index < value.length; index += 1) {
2212
+ const character = value[index];
2213
+ const previous = index > 0 ? value[index - 1] : "";
2214
+ if (quote) {
2215
+ if (character === quote && previous !== "\\") quote = null;
2216
+ continue;
2217
+ }
2218
+ if (character === "'" || character === "\"") {
2219
+ quote = character;
2220
+ continue;
2221
+ }
2222
+ if (character === "(") depth += 1;
2223
+ if (character === ")") {
2224
+ depth -= 1;
2225
+ if (depth === 0 && index < value.length - 1) return false;
2226
+ }
2227
+ }
2228
+ return depth === 0;
2229
+ }
2230
+ stripWrappedParentheses(value) {
2231
+ let nextValue = value.trim();
2232
+ while (this.hasWrappedParentheses(nextValue)) nextValue = nextValue.slice(1, -1).trim();
2233
+ return nextValue;
2234
+ }
2235
+ parseDeclarationType(value) {
2236
+ const trimmed = this.stripWrappedParentheses(value.trim());
2237
+ if (!trimmed) return null;
2238
+ const unionParts = this.splitTopLevel(trimmed, "|");
2239
+ if (unionParts.length > 1) {
2240
+ const types = unionParts.map((part) => this.parseDeclarationType(part)).filter((part) => part !== null);
2241
+ if (types.length !== unionParts.length) return null;
2242
+ return {
2243
+ kind: "union",
2244
+ types: types.flatMap((type) => type.kind === "union" ? type.types : [type])
2245
+ };
2246
+ }
2247
+ if (trimmed.endsWith("[]")) {
2248
+ const element = this.parseDeclarationType(trimmed.slice(0, -2));
2249
+ if (!element) return null;
2250
+ return {
2251
+ kind: "array",
2252
+ element
2253
+ };
2254
+ }
2255
+ const arrayMatch = trimmed.match(/^(Array|ReadonlyArray)<([\s\S]+)>$/);
2256
+ if (arrayMatch) {
2257
+ const element = this.parseDeclarationType(arrayMatch[2]);
2258
+ if (!element) return null;
2259
+ return {
2260
+ kind: "array",
2261
+ element
2262
+ };
2263
+ }
2264
+ if (trimmed === "null") return { kind: "null" };
2265
+ if (trimmed.startsWith("'") && trimmed.endsWith("'") || trimmed.startsWith("\"") && trimmed.endsWith("\"")) return {
2266
+ kind: "string-literal",
2267
+ value: trimmed.slice(1, -1)
2268
+ };
2269
+ if (trimmed === "Record<string, unknown>") return {
2270
+ kind: "named",
2271
+ name: trimmed
2272
+ };
2273
+ if (/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(trimmed)) return {
2274
+ kind: "named",
2275
+ name: trimmed
2276
+ };
2277
+ return null;
2278
+ }
2279
+ expandUnion(node) {
2280
+ return node.kind === "union" ? node.types : [node];
2281
+ }
2282
+ isEnumTypeName(value, enums) {
2283
+ return enums.has(value);
2284
+ }
2285
+ isDeclarationNodeAssignable(actual, expected, enums) {
2286
+ if (expected.kind === "named") {
2287
+ if (expected.name === "unknown") return true;
2288
+ if (actual.kind === "named") {
2289
+ if (actual.name === expected.name) return true;
2290
+ if (expected.name === "string" && this.isEnumTypeName(actual.name, enums)) return true;
2291
+ }
2292
+ if (actual.kind === "string-literal") {
2293
+ if (expected.name === "string") return true;
2294
+ if (enums.get(expected.name)?.includes(actual.value)) return true;
2295
+ }
2296
+ return false;
2297
+ }
2298
+ if (expected.kind === "array") return actual.kind === "array" && this.isDeclarationAssignable(actual.element, expected.element, enums);
2299
+ if (expected.kind === "null") return actual.kind === "null";
2300
+ if (expected.kind === "string-literal") return actual.kind === "string-literal" && actual.value === expected.value;
2301
+ return false;
2302
+ }
2303
+ isDeclarationAssignable(actual, expected, enums) {
2304
+ const actualTypes = this.expandUnion(actual);
2305
+ const expectedTypes = this.expandUnion(expected);
2306
+ return actualTypes.every((actualType) => {
2307
+ return expectedTypes.some((expectedType) => {
2308
+ return this.isDeclarationNodeAssignable(actualType, expectedType, enums);
2309
+ });
2310
+ });
2311
+ }
2312
+ isCompatibleDeclarationType(actualType, expectedType, enums) {
2313
+ const actual = this.parseDeclarationType(actualType);
2314
+ const expected = this.parseDeclarationType(expectedType);
2315
+ if (!actual || !expected) return actualType.replace(/\s+/g, " ").trim() === expectedType.replace(/\s+/g, " ").trim();
2316
+ return this.isDeclarationAssignable(actual, expected, enums);
2317
+ }
2318
+ collectEnumReferencesFromNode(node, enums, collected) {
2319
+ if (node.kind === "named" && enums.has(node.name)) {
2320
+ collected.add(node.name);
2321
+ return;
2322
+ }
2323
+ if (node.kind === "array") {
2324
+ this.collectEnumReferencesFromNode(node.element, enums, collected);
2325
+ return;
2326
+ }
2327
+ if (node.kind === "union") node.types.forEach((type) => this.collectEnumReferencesFromNode(type, enums, collected));
2328
+ }
2329
+ collectEnumReferences(type, enums) {
2330
+ const parsed = this.parseDeclarationType(type);
2331
+ if (!parsed) return [];
2332
+ const collected = /* @__PURE__ */ new Set();
2333
+ this.collectEnumReferencesFromNode(parsed, enums, collected);
2334
+ return [...collected].sort((left, right) => left.localeCompare(right));
2335
+ }
2336
+ syncPrismaEnumImports(modelSource, enumTypes) {
2337
+ if (enumTypes.length === 0) return modelSource;
2338
+ const importRegex = /^import\s+type\s+\{([^}]+)\}\s+from\s+['"]@prisma\/client['"]\s*;?$/m;
2339
+ const existingImport = modelSource.match(importRegex);
2340
+ if (existingImport) {
2341
+ const existingTypes = existingImport[1].split(",").map((value) => value.trim()).filter(Boolean);
2342
+ const mergedTypes = [...new Set([...existingTypes, ...enumTypes])].sort((left, right) => left.localeCompare(right));
2343
+ return modelSource.replace(importRegex, `import type { ${mergedTypes.join(", ")} } from '@prisma/client'`);
2344
+ }
2345
+ const lines = modelSource.split("\n");
2346
+ let insertionIndex = 0;
2347
+ while (insertionIndex < lines.length && lines[insertionIndex].trim().startsWith("import ")) insertionIndex += 1;
2348
+ lines.splice(insertionIndex, 0, `import type { ${enumTypes.join(", ")} } from '@prisma/client'`);
2349
+ return lines.join("\n");
2350
+ }
2351
+ /**
2352
+ * Parse Prisma enum definitions from a schema and return their member names.
2353
+ *
2354
+ * @param schema The Prisma schema source.
2355
+ * @returns A map of enum names to their declared member names.
2356
+ */
2357
+ parsePrismaEnums(schema) {
2358
+ const enums = /* @__PURE__ */ new Map();
2359
+ for (const match of schema.matchAll(PRISMA_ENUM_REGEX)) {
2360
+ const enumName = match[1];
2361
+ const values = match[0].split("\n").slice(1, -1).map((line) => line.trim()).filter((line) => Boolean(line) && !line.startsWith("//")).map((line) => {
2362
+ return line.match(/^([A-Za-z][A-Za-z0-9_]*)\b/)?.[1];
2363
+ }).filter((value) => Boolean(value));
2364
+ enums.set(enumName, values);
2365
+ }
2366
+ return enums;
2367
+ }
2368
+ /**
2369
+ * Resolve the generated TypeScript declaration type for a Prisma field.
2370
+ *
2371
+ * @param fieldType The Prisma field type token.
2372
+ * @param isList Whether the field is declared as a Prisma list.
2373
+ * @param enums Known Prisma enum definitions.
2374
+ * @returns The declaration type to emit, or null when unsupported.
2375
+ */
2376
+ prismaFieldTypeToTs(fieldType, isList, enums) {
2377
+ const baseType = enums.has(fieldType) ? fieldType : this.prismaTypeToTs(fieldType);
2378
+ if (baseType === "unknown" && !enums.has(fieldType)) return null;
2379
+ return isList ? `Array<${baseType}>` : baseType;
2380
+ }
2153
2381
  /**
2154
2382
  * Parse the Prisma schema to extract model definitions and their fields, focusing
2155
2383
  * on scalar types.
@@ -2159,6 +2387,7 @@ var CliApp = class {
2159
2387
  */
2160
2388
  parsePrismaModels(schema) {
2161
2389
  const models = [];
2390
+ const enumDefinitions = this.parsePrismaEnums(schema);
2162
2391
  const modelRegex = /model\s+(\w+)\s*\{([\s\S]*?)\n\}/g;
2163
2392
  const scalarTypes = new Set([
2164
2393
  "Int",
@@ -2179,14 +2408,16 @@ var CliApp = class {
2179
2408
  body.split("\n").forEach((rawLine) => {
2180
2409
  const line = rawLine.trim();
2181
2410
  if (!line || line.startsWith("@@") || line.startsWith("//")) return;
2182
- const fieldMatch = line.match(/^(\w+)\s+([A-Za-z]+)(\?)?(?:\s|$)/);
2411
+ const fieldMatch = line.match(/^(\w+)\s+([A-Za-z][A-Za-z0-9_]*)(\[\])?(\?)?(?:\s|$)/);
2183
2412
  if (!fieldMatch) return;
2184
2413
  const fieldType = fieldMatch[2];
2185
- if (!scalarTypes.has(fieldType)) return;
2414
+ if (!scalarTypes.has(fieldType) && !enumDefinitions.has(fieldType)) return;
2415
+ const declarationType = this.prismaFieldTypeToTs(fieldType, Boolean(fieldMatch[3]), enumDefinitions);
2416
+ if (!declarationType) return;
2186
2417
  fields.push({
2187
2418
  name: fieldMatch[1],
2188
- type: this.prismaTypeToTs(fieldType),
2189
- nullable: Boolean(fieldMatch[3])
2419
+ type: declarationType,
2420
+ nullable: Boolean(fieldMatch[4])
2190
2421
  });
2191
2422
  });
2192
2423
  models.push({
@@ -2207,7 +2438,7 @@ var CliApp = class {
2207
2438
  * @param declarations A list of attribute declarations to sync.
2208
2439
  * @returns An object containing the updated content and a flag indicating if it was updated.
2209
2440
  */
2210
- syncModelDeclarations(modelSource, declarations) {
2441
+ syncModelDeclarations(modelSource, declarations, enums) {
2211
2442
  const lines = modelSource.split("\n");
2212
2443
  const classIndex = lines.findIndex((line) => /export\s+class\s+\w+\s+extends\s+Model<.+>\s*\{/.test(line));
2213
2444
  if (classIndex < 0) return {
@@ -2229,16 +2460,38 @@ var CliApp = class {
2229
2460
  content: modelSource,
2230
2461
  updated: false
2231
2462
  };
2232
- const withoutDeclares = lines.slice(classIndex + 1, classEndIndex).filter((line) => !/^\s*declare\s+\w+\??:\s*[^\n]+$/.test(line));
2233
- const rebuiltClass = [...declarations.map((declaration) => ` ${declaration}`), ...withoutDeclares];
2463
+ const withinClass = lines.slice(classIndex + 1, classEndIndex);
2464
+ const existingDeclarations = /* @__PURE__ */ new Map();
2465
+ withinClass.forEach((line) => {
2466
+ const declarationMatch = line.match(/^\s*declare\s+(\w+)\??:\s*([^;\n]+);?\s*$/);
2467
+ if (!declarationMatch) return;
2468
+ existingDeclarations.set(declarationMatch[1], {
2469
+ name: declarationMatch[1],
2470
+ raw: line.trim(),
2471
+ type: declarationMatch[2].trim()
2472
+ });
2473
+ });
2474
+ const withoutDeclares = withinClass.filter((line) => !/^\s*declare\s+\w+\??:\s*[^\n]+$/.test(line));
2475
+ const chosenDeclarations = declarations.map((declaration) => {
2476
+ const expectedType = `${declaration.type}${declaration.nullable ? " | null" : ""}`;
2477
+ const existingDeclaration = existingDeclarations.get(declaration.name);
2478
+ if (existingDeclaration && this.isCompatibleDeclarationType(existingDeclaration.type, expectedType, enums)) return existingDeclaration.raw;
2479
+ return `declare ${declaration.name}: ${expectedType}`;
2480
+ });
2481
+ const rebuiltClass = [...chosenDeclarations.map((declaration) => ` ${declaration}`), ...withoutDeclares];
2234
2482
  const content = [
2235
2483
  ...lines.slice(0, classIndex + 1),
2236
2484
  ...rebuiltClass,
2237
2485
  ...lines.slice(classEndIndex)
2238
2486
  ].join("\n");
2487
+ const enumImports = [...new Set(chosenDeclarations.flatMap((declaration) => {
2488
+ const type = declaration.replace(/^declare\s+\w+\??:\s*/, "").replace(/;$/, "").trim();
2489
+ return this.collectEnumReferences(type, enums);
2490
+ }))].sort((left, right) => left.localeCompare(right));
2491
+ const contentWithImports = this.syncPrismaEnumImports(content, enumImports);
2239
2492
  return {
2240
- content,
2241
- updated: content !== modelSource
2493
+ content: contentWithImports,
2494
+ updated: contentWithImports !== modelSource
2242
2495
  };
2243
2496
  }
2244
2497
  /**
@@ -2258,6 +2511,7 @@ var CliApp = class {
2258
2511
  if (!(0, fs.existsSync)(schemaPath)) throw new Error(`Prisma schema file not found: ${schemaPath}`);
2259
2512
  if (!(0, fs.existsSync)(modelsDir)) throw new Error(`Models directory not found: ${modelsDir}`);
2260
2513
  const schema = (0, fs.readFileSync)(schemaPath, "utf-8");
2514
+ const prismaEnums = this.parsePrismaEnums(schema);
2261
2515
  const prismaModels = this.parsePrismaModels(schema);
2262
2516
  const modelFiles = (0, fs.readdirSync)(modelsDir).filter((file) => file.endsWith(".ts"));
2263
2517
  const updated = [];
@@ -2277,8 +2531,7 @@ var CliApp = class {
2277
2531
  skipped.push(filePath);
2278
2532
  return;
2279
2533
  }
2280
- const declarations = prismaModel.fields.map((field) => `declare ${field.name}: ${field.type}${field.nullable ? " | null" : ""}`);
2281
- const synced = this.syncModelDeclarations(source, declarations);
2534
+ const synced = this.syncModelDeclarations(source, prismaModel.fields, prismaEnums);
2282
2535
  if (!synced.updated) {
2283
2536
  skipped.push(filePath);
2284
2537
  return;
@@ -2700,7 +2953,7 @@ var MigrateCommand = class extends _h3ravel_musket.Command {
2700
2953
  * @returns
2701
2954
  */
2702
2955
  async loadMigrationClassesFromFile(filePath) {
2703
- const imported = await import(`${(0, node_url.pathToFileURL)((0, node_path.resolve)(filePath)).href}?arkorm_migrate=${Date.now()}`);
2956
+ const imported = await RuntimeModuleLoader.load(filePath);
2704
2957
  return Object.values(imported).filter((value) => {
2705
2958
  if (typeof value !== "function") return false;
2706
2959
  const candidate = value;
@@ -2785,7 +3038,7 @@ var MigrateRollbackCommand = class extends _h3ravel_musket.Command {
2785
3038
  return (await Promise.all(files.map(async (file) => (await this.loadMigrationClassesFromFile(file)).map((cls) => [cls, file])))).flat();
2786
3039
  }
2787
3040
  async loadMigrationClassesFromFile(filePath) {
2788
- const imported = await import(`${(0, node_url.pathToFileURL)((0, node_path.resolve)(filePath)).href}?arkorm_rollback=${Date.now()}`);
3041
+ const imported = await RuntimeModuleLoader.load(filePath);
2789
3042
  return Object.values(imported).filter((value) => {
2790
3043
  if (typeof value !== "function") return false;
2791
3044
  const candidate = value;
@@ -2995,7 +3248,7 @@ var SeedCommand = class extends _h3ravel_musket.Command {
2995
3248
  * @returns An array of seeder classes.
2996
3249
  */
2997
3250
  async loadSeederClassesFromFile(filePath) {
2998
- const imported = await import(`${(0, node_url.pathToFileURL)((0, node_path.resolve)(filePath)).href}?arkorm_seed=${Date.now()}`);
3251
+ const imported = await RuntimeModuleLoader.load(filePath);
2999
3252
  return Object.values(imported).filter((value) => {
3000
3253
  if (typeof value !== "function") return false;
3001
3254
  const candidate = value;
@@ -6564,6 +6817,7 @@ exports.Paginator = Paginator;
6564
6817
  exports.QueryBuilder = QueryBuilder;
6565
6818
  exports.QueryConstraintException = QueryConstraintException;
6566
6819
  exports.RelationResolutionException = RelationResolutionException;
6820
+ exports.RuntimeModuleLoader = RuntimeModuleLoader;
6567
6821
  exports.SEEDER_BRAND = SEEDER_BRAND;
6568
6822
  exports.SchemaBuilder = SchemaBuilder;
6569
6823
  exports.ScopeNotDefinedException = ScopeNotDefinedException;
package/dist/index.d.cts CHANGED
@@ -2470,6 +2470,34 @@ declare class CliApp {
2470
2470
  * @returns The corresponding TypeScript type.
2471
2471
  */
2472
2472
  private prismaTypeToTs;
2473
+ private splitTopLevel;
2474
+ private hasWrappedParentheses;
2475
+ private stripWrappedParentheses;
2476
+ private parseDeclarationType;
2477
+ private expandUnion;
2478
+ private isEnumTypeName;
2479
+ private isDeclarationNodeAssignable;
2480
+ private isDeclarationAssignable;
2481
+ private isCompatibleDeclarationType;
2482
+ private collectEnumReferencesFromNode;
2483
+ private collectEnumReferences;
2484
+ private syncPrismaEnumImports;
2485
+ /**
2486
+ * Parse Prisma enum definitions from a schema and return their member names.
2487
+ *
2488
+ * @param schema The Prisma schema source.
2489
+ * @returns A map of enum names to their declared member names.
2490
+ */
2491
+ private parsePrismaEnums;
2492
+ /**
2493
+ * Resolve the generated TypeScript declaration type for a Prisma field.
2494
+ *
2495
+ * @param fieldType The Prisma field type token.
2496
+ * @param isList Whether the field is declared as a Prisma list.
2497
+ * @param enums Known Prisma enum definitions.
2498
+ * @returns The declaration type to emit, or null when unsupported.
2499
+ */
2500
+ private prismaFieldTypeToTs;
2473
2501
  /**
2474
2502
  * Parse the Prisma schema to extract model definitions and their fields, focusing
2475
2503
  * on scalar types.
@@ -3684,6 +3712,11 @@ declare function createPrismaDelegateMap(prisma: PrismaClientLike): Record<strin
3684
3712
  */
3685
3713
  declare function inferDelegateName(modelName: string): string;
3686
3714
  //#endregion
3715
+ //#region src/helpers/runtime-module-loader.d.ts
3716
+ declare class RuntimeModuleLoader {
3717
+ static load<T = unknown>(filePath: string): Promise<T>;
3718
+ }
3719
+ //#endregion
3687
3720
  //#region src/URLDriver.d.ts
3688
3721
  /**
3689
3722
  * URLDriver builds pagination URLs from paginator options.
@@ -3702,4 +3735,4 @@ declare class URLDriver {
3702
3735
  url(page: number): string;
3703
3736
  }
3704
3737
  //#endregion
3705
- export { ArkormCollection, ArkormErrorContext, ArkormException, Attribute, AttributeOptions, CliApp, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, QueryConstraintException, RelationResolutionException, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToPrismaSchema, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, removeAppliedMigration, resetArkormRuntimeForTests, resolveCast, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName, writeAppliedMigrationsState };
3738
+ export { ArkormCollection, ArkormErrorContext, ArkormException, Attribute, AttributeOptions, CliApp, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, QueryConstraintException, RelationResolutionException, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToPrismaSchema, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, removeAppliedMigration, resetArkormRuntimeForTests, resolveCast, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName, writeAppliedMigrationsState };
package/dist/index.d.mts CHANGED
@@ -2470,6 +2470,34 @@ declare class CliApp {
2470
2470
  * @returns The corresponding TypeScript type.
2471
2471
  */
2472
2472
  private prismaTypeToTs;
2473
+ private splitTopLevel;
2474
+ private hasWrappedParentheses;
2475
+ private stripWrappedParentheses;
2476
+ private parseDeclarationType;
2477
+ private expandUnion;
2478
+ private isEnumTypeName;
2479
+ private isDeclarationNodeAssignable;
2480
+ private isDeclarationAssignable;
2481
+ private isCompatibleDeclarationType;
2482
+ private collectEnumReferencesFromNode;
2483
+ private collectEnumReferences;
2484
+ private syncPrismaEnumImports;
2485
+ /**
2486
+ * Parse Prisma enum definitions from a schema and return their member names.
2487
+ *
2488
+ * @param schema The Prisma schema source.
2489
+ * @returns A map of enum names to their declared member names.
2490
+ */
2491
+ private parsePrismaEnums;
2492
+ /**
2493
+ * Resolve the generated TypeScript declaration type for a Prisma field.
2494
+ *
2495
+ * @param fieldType The Prisma field type token.
2496
+ * @param isList Whether the field is declared as a Prisma list.
2497
+ * @param enums Known Prisma enum definitions.
2498
+ * @returns The declaration type to emit, or null when unsupported.
2499
+ */
2500
+ private prismaFieldTypeToTs;
2473
2501
  /**
2474
2502
  * Parse the Prisma schema to extract model definitions and their fields, focusing
2475
2503
  * on scalar types.
@@ -3684,6 +3712,11 @@ declare function createPrismaDelegateMap(prisma: PrismaClientLike): Record<strin
3684
3712
  */
3685
3713
  declare function inferDelegateName(modelName: string): string;
3686
3714
  //#endregion
3715
+ //#region src/helpers/runtime-module-loader.d.ts
3716
+ declare class RuntimeModuleLoader {
3717
+ static load<T = unknown>(filePath: string): Promise<T>;
3718
+ }
3719
+ //#endregion
3687
3720
  //#region src/URLDriver.d.ts
3688
3721
  /**
3689
3722
  * URLDriver builds pagination URLs from paginator options.
@@ -3702,4 +3735,4 @@ declare class URLDriver {
3702
3735
  url(page: number): string;
3703
3736
  }
3704
3737
  //#endregion
3705
- export { ArkormCollection, ArkormErrorContext, ArkormException, Attribute, AttributeOptions, CliApp, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, QueryConstraintException, RelationResolutionException, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToPrismaSchema, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, removeAppliedMigration, resetArkormRuntimeForTests, resolveCast, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName, writeAppliedMigrationsState };
3738
+ export { ArkormCollection, ArkormErrorContext, ArkormException, Attribute, AttributeOptions, CliApp, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, QueryConstraintException, RelationResolutionException, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToPrismaSchema, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, removeAppliedMigration, resetArkormRuntimeForTests, resolveCast, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName, writeAppliedMigrationsState };