@alpha.consultings/eloquent-orm.js 1.0.10 → 1.1.0

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.
Files changed (159) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/PACKAGE-UPDATE-SUMMARY.md +10 -10
  3. package/README.md +5 -5
  4. package/dist/Model.d.ts +1 -1
  5. package/dist/Model.js +3 -3
  6. package/dist/cli/commands/cacheClear.js +12 -12
  7. package/dist/cli/commands/cacheStats.js +12 -12
  8. package/dist/cli/commands/dbSeed.d.ts +1 -1
  9. package/dist/cli/commands/dbSeed.js +23 -23
  10. package/dist/cli/commands/dbSeedBootstrapPrecheck.d.ts +1 -1
  11. package/dist/cli/commands/dbSeedBootstrapPrecheck.js +2 -2
  12. package/dist/cli/commands/dbSeedFresh.d.ts +1 -1
  13. package/dist/cli/commands/dbSeedFresh.js +10 -10
  14. package/dist/cli/commands/demoScenario.js +11 -11
  15. package/dist/cli/commands/factoryStatus.js +13 -13
  16. package/dist/cli/commands/makeController.js +11 -11
  17. package/dist/cli/commands/makeFactory.js +21 -21
  18. package/dist/cli/commands/makeMigration.d.ts +1 -1
  19. package/dist/cli/commands/makeMigration.js +19 -17
  20. package/dist/cli/commands/makeModel.js +30 -30
  21. package/dist/cli/commands/makeRegistry.d.ts +5 -8
  22. package/dist/cli/commands/makeRegistry.js +18 -68
  23. package/dist/cli/commands/makeScenario.js +49 -43
  24. package/dist/cli/commands/makeSeed.js +12 -9
  25. package/dist/cli/commands/makeService.js +10 -10
  26. package/dist/cli/commands/migrateFresh.d.ts +1 -1
  27. package/dist/cli/commands/migrateFresh.js +14 -14
  28. package/dist/cli/commands/migrateReset.d.ts +1 -1
  29. package/dist/cli/commands/migrateReset.js +4 -4
  30. package/dist/cli/commands/migrateRollback.d.ts +1 -1
  31. package/dist/cli/commands/migrateRollback.js +36 -36
  32. package/dist/cli/commands/migrateRun.d.ts +2 -2
  33. package/dist/cli/commands/migrateRun.js +34 -34
  34. package/dist/cli/commands/migrateStatus.d.ts +1 -1
  35. package/dist/cli/commands/migrateStatus.js +16 -16
  36. package/dist/cli/eloquent.d.ts +1 -1
  37. package/dist/cli/eloquent.js +30 -30
  38. package/dist/cli/utils/ArtifactRoutingReport.d.ts +1 -1
  39. package/dist/cli/utils/ArtifactRoutingReport.js +3 -3
  40. package/dist/cli/utils/ArtifactStorage.d.ts +2 -2
  41. package/dist/cli/utils/ArtifactStorage.js +30 -17
  42. package/dist/cli/utils/AuditTrail.js +2 -2
  43. package/dist/cli/utils/CliBootstrapSupport.d.ts +1 -1
  44. package/dist/cli/utils/CliCommandTargets.d.ts +2 -2
  45. package/dist/cli/utils/CliCommandTargets.js +2 -2
  46. package/dist/cli/utils/CliMakeArtifactCommandRegistration.js +15 -15
  47. package/dist/cli/utils/CliMigrationCommandRegistration.js +29 -29
  48. package/dist/cli/utils/CliProductionGuards.d.ts +1 -1
  49. package/dist/cli/utils/CliProductionGuards.js +6 -6
  50. package/dist/cli/utils/CliScaffoldCommandRegistration.js +13 -13
  51. package/dist/cli/utils/CliSeedScenarioCommandRegistration.js +23 -23
  52. package/dist/cli/utils/CliSupportCommandRegistration.js +8 -8
  53. package/dist/cli/utils/ImportResolver.d.ts +12 -3
  54. package/dist/cli/utils/ImportResolver.js +76 -17
  55. package/dist/cli/utils/ModelIntrospector.d.ts +1 -1
  56. package/dist/cli/utils/ModelIntrospector.js +4 -4
  57. package/dist/cli/utils/ScaffoldGeneratorSupport.js +2 -2
  58. package/dist/cli/utils/ScenarioMorphAliasRouting.js +8 -8
  59. package/dist/cli/utils/SeedBootstrapPrecheck.d.ts +1 -1
  60. package/dist/cli/utils/SeedBootstrapPrecheck.js +10 -10
  61. package/dist/cli/utils/TemplateEngine.js +2 -2
  62. package/dist/cli/utils/factories/Factory.d.ts +1 -1
  63. package/dist/cli/utils/factories/FactoryDisplay.d.ts +1 -1
  64. package/dist/cli/utils/factories/FactoryGraph.js +5 -5
  65. package/dist/cli/utils/factories/FactoryLoader.d.ts +1 -1
  66. package/dist/cli/utils/factories/FactoryLoader.js +4 -4
  67. package/dist/cli/utils/factories/FactoryRegistry.d.ts +3 -3
  68. package/dist/cli/utils/factories/FactoryRegistry.js +10 -10
  69. package/dist/cli/utils/migrations/MigrationLockStrategy.d.ts +1 -1
  70. package/dist/cli/utils/migrations/MigrationLockStrategy.js +2 -2
  71. package/dist/cli/utils/migrations/MigrationTracker.d.ts +2 -2
  72. package/dist/cli/utils/migrations/MigrationTracker.js +6 -6
  73. package/dist/cli/utils/migrations/MongoMigrationTracker.js +3 -3
  74. package/dist/cli/utils/resolveConnectionFlags.d.ts +1 -1
  75. package/dist/cli/utils/resolveConnectionFlags.js +3 -3
  76. package/dist/cli/utils/resolveSqlConnectionFlags.d.ts +1 -1
  77. package/dist/cli/utils/typescript/BaseCommand.d.ts +1 -1
  78. package/dist/cli/utils/typescript/BaseCommand.js +3 -3
  79. package/dist/cli/utils/typescript/TypeScriptCompiler.js +0 -1
  80. package/dist/cli/utils/typescript/tsRuntime.js +26 -4
  81. package/dist/config/database.js +9 -9
  82. package/dist/core/cache/CacheFallbackManager.d.ts +1 -1
  83. package/dist/core/cache/CacheManager.d.ts +1 -1
  84. package/dist/core/cache/CacheManager.js +2 -2
  85. package/dist/core/cache/CacheRegistry.js +4 -4
  86. package/dist/core/cache/drivers/FileCacheDriver.d.ts +1 -1
  87. package/dist/core/cache/drivers/FileCacheDriver.js +2 -2
  88. package/dist/core/cache/drivers/MemcachedCacheDriver.d.ts +1 -1
  89. package/dist/core/cache/drivers/MemcachedCacheDriver.js +2 -2
  90. package/dist/core/cache/drivers/MemoryCacheDriver.d.ts +1 -1
  91. package/dist/core/cache/drivers/MemoryCacheDriver.js +2 -2
  92. package/dist/core/cache/setupCache.js +12 -12
  93. package/dist/core/connection/ConnectionFactory.d.ts +2 -2
  94. package/dist/core/connection/ConnectionFactory.js +9 -9
  95. package/dist/core/connection/DatabaseConnection.d.ts +2 -2
  96. package/dist/core/connection/DatabaseConnection.js +4 -4
  97. package/dist/core/connection/DriverAdapter.d.ts +1 -1
  98. package/dist/core/connection/DriverAdapter.js +2 -2
  99. package/dist/core/connection/resolveConnectionName.d.ts +1 -1
  100. package/dist/core/connection/resolveConnectionName.js +7 -7
  101. package/dist/core/model/BaseModel.d.ts +31 -30
  102. package/dist/core/model/BaseModel.js +38 -38
  103. package/dist/core/model/BaseModelSafeFinderStatics.d.ts +1 -1
  104. package/dist/core/model/BaseModelSafeFinderStatics.js +19 -19
  105. package/dist/core/model/CoreModel.d.ts +6 -4
  106. package/dist/core/model/CoreModel.js +28 -28
  107. package/dist/core/model/CoreModelPersistenceState.d.ts +1 -1
  108. package/dist/core/model/CoreModelSafeFinderSupport.d.ts +2 -2
  109. package/dist/core/model/CoreModelSafeFinderSupport.js +2 -2
  110. package/dist/core/model/CoreModelValidationEvents.d.ts +2 -2
  111. package/dist/core/model/CoreModelValidationEvents.js +2 -2
  112. package/dist/core/model/SafeFinder.d.ts +1 -1
  113. package/dist/core/model/SafeFinder.js +2 -2
  114. package/dist/core/orm/mixins/CastsMixin.js +2 -2
  115. package/dist/core/orm/mixins/HooksMixin.js +8 -8
  116. package/dist/core/orm/mixins/MorphableMixin.js +4 -4
  117. package/dist/core/orm/mixins/PivotHelperMixin.js +3 -3
  118. package/dist/core/orm/mixins/QueryCacheMixin.js +20 -20
  119. package/dist/core/orm/mixins/ScopeMixin.js +2 -2
  120. package/dist/core/orm/mixins/SoftDeletesMixin.js +2 -2
  121. package/dist/core/orm/mixins/utils/HookStore.d.ts +1 -1
  122. package/dist/core/orm/mixins/utils/HookStore.js +2 -2
  123. package/dist/core/orm/mixins/utils/modelRegistration.d.ts +1 -1
  124. package/dist/core/orm/mixins/utils/modelRegistration.js +6 -6
  125. package/dist/core/orm/relations/BelongsTo.d.ts +1 -1
  126. package/dist/core/orm/relations/BelongsTo.js +2 -2
  127. package/dist/core/orm/relations/BelongsToMany.d.ts +1 -1
  128. package/dist/core/orm/relations/BelongsToMany.js +2 -2
  129. package/dist/core/orm/relations/HasMany.d.ts +1 -1
  130. package/dist/core/orm/relations/HasMany.js +2 -2
  131. package/dist/core/orm/relations/HasOne.d.ts +1 -1
  132. package/dist/core/orm/relations/HasOne.js +2 -2
  133. package/dist/core/orm/relations/MorphMany.d.ts +1 -1
  134. package/dist/core/orm/relations/MorphMany.js +2 -2
  135. package/dist/core/orm/relations/MorphOne.d.ts +1 -1
  136. package/dist/core/orm/relations/MorphOne.js +2 -2
  137. package/dist/core/orm/relations/MorphTo.d.ts +1 -1
  138. package/dist/core/orm/relations/MorphTo.js +5 -5
  139. package/dist/core/schema/SchemaBlueprint.d.ts +21 -0
  140. package/dist/core/schema/SchemaBuilder.d.ts +16 -3
  141. package/dist/core/schema/SchemaBuilder.js +191 -48
  142. package/dist/core/schema/SchemaValidator.d.ts +1 -1
  143. package/dist/core/security/AbstractSecurity.d.ts +1 -1
  144. package/dist/core/security/EnvKeySecurity.d.ts +1 -1
  145. package/dist/core/security/EnvKeySecurity.js +2 -2
  146. package/dist/core/security/NoSecurity.d.ts +1 -1
  147. package/dist/core/security/NoSecurity.js +2 -2
  148. package/dist/core/security/SecurityFactory.d.ts +1 -1
  149. package/dist/core/security/SecurityFactory.js +4 -4
  150. package/dist/core/security/index.d.ts +5 -5
  151. package/dist/core/security/index.js +5 -5
  152. package/dist/index.d.ts +10 -10
  153. package/dist/index.js +30 -30
  154. package/esm/Factory.mjs +113 -136
  155. package/esm/Model.mjs +4 -0
  156. package/esm/index.mjs +23 -28
  157. package/package.json +14 -5
  158. package/src/cli/templates/factory.tpl +1 -1
  159. package/src/cli/templates/seed.tpl +1 -1
@@ -6,17 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ModelIntrospector = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
- const PathMap_1 = require("./PathMap");
10
- const tsRuntime_1 = require("./typescript/tsRuntime");
9
+ const PathMap_js_1 = require("./PathMap.js");
10
+ const tsRuntime_js_1 = require("./typescript/tsRuntime.js");
11
11
  class ModelIntrospector {
12
12
  static async analyze(modelName, options = {}) {
13
- const modelsDir = PathMap_1.PathMap.models(!!options.test);
13
+ const modelsDir = PathMap_js_1.PathMap.models(!!options.test);
14
14
  const modelPath = path_1.default.resolve(modelsDir, `${modelName}.ts`);
15
15
  if (!fs_1.default.existsSync(modelPath)) {
16
16
  throw new Error(`Model file not found: ${modelPath}`);
17
17
  }
18
18
  this.clearModelModuleCache(modelPath);
19
- const importedModule = (0, tsRuntime_1.loadModule)(modelPath);
19
+ const importedModule = (0, tsRuntime_js_1.loadModule)(modelPath);
20
20
  const ModelClass = importedModule[modelName];
21
21
  if (!ModelClass) {
22
22
  throw new Error(`Could not load model class: ${modelName}`);
@@ -11,7 +11,7 @@ exports.logScaffoldCreated = logScaffoldCreated;
11
11
  exports.logScaffoldFailure = logScaffoldFailure;
12
12
  const path_1 = __importDefault(require("path"));
13
13
  const chalk_1 = __importDefault(require("chalk"));
14
- const PathMap_1 = require("./PathMap");
14
+ const PathMap_js_1 = require("./PathMap.js");
15
15
  function scaffoldKindLabel(kind) {
16
16
  return kind === "controller" ? "Controller" : "Service";
17
17
  }
@@ -52,7 +52,7 @@ function resolveScaffoldArtifact(kind, modelName, options = {}) {
52
52
  modelClassName,
53
53
  className,
54
54
  fileName,
55
- outputPath: path_1.default.resolve(PathMap_1.PathMap.root, relativeDir, fileName),
55
+ outputPath: path_1.default.resolve(PathMap_js_1.PathMap.root, relativeDir, fileName),
56
56
  relativePath: `${relativeDir}/${fileName}`.replace(/\\/g, "/"),
57
57
  };
58
58
  }
@@ -7,9 +7,9 @@ exports.resolveTargetedMorphAlias = resolveTargetedMorphAlias;
7
7
  exports.resolveScenarioMorphAliases = resolveScenarioMorphAliases;
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
10
- const PathMap_1 = require("./PathMap");
11
- const ArtifactStorage_1 = require("./ArtifactStorage");
12
- const tsRuntime_1 = require("./typescript/tsRuntime");
10
+ const PathMap_js_1 = require("./PathMap.js");
11
+ const ArtifactStorage_js_1 = require("./ArtifactStorage.js");
12
+ const tsRuntime_js_1 = require("./typescript/tsRuntime.js");
13
13
  function resolveExistingModelPath(modelsDir, modelName) {
14
14
  const basePath = path_1.default.join(modelsDir, modelName);
15
15
  for (const ext of [".ts", ".js"]) {
@@ -21,18 +21,18 @@ function resolveExistingModelPath(modelsDir, modelName) {
21
21
  return null;
22
22
  }
23
23
  function resolveTargetedMorphAlias(options) {
24
- const targetKind = (0, ArtifactStorage_1.targetStorageKindForConnection)(options.connectionName);
25
- const modelKind = (0, ArtifactStorage_1.resolveModelStorageKind)(options.modelName, options.isTest);
26
- if (modelKind !== "unknown" && !(0, ArtifactStorage_1.matchesTargetStorageKind)(modelKind, targetKind)) {
24
+ const targetKind = (0, ArtifactStorage_js_1.targetStorageKindForConnection)(options.connectionName);
25
+ const modelKind = (0, ArtifactStorage_js_1.resolveModelStorageKind)(options.modelName, options.isTest);
26
+ if (modelKind !== "unknown" && !(0, ArtifactStorage_js_1.matchesTargetStorageKind)(modelKind, targetKind)) {
27
27
  return options.fallback;
28
28
  }
29
- const modelsDir = PathMap_1.PathMap.models(options.isTest);
29
+ const modelsDir = PathMap_js_1.PathMap.models(options.isTest);
30
30
  const modelPath = resolveExistingModelPath(modelsDir, options.modelName);
31
31
  if (!modelPath) {
32
32
  return options.fallback;
33
33
  }
34
34
  try {
35
- const mod = (0, tsRuntime_1.loadModule)(modelPath);
35
+ const mod = (0, tsRuntime_js_1.loadModule)(modelPath);
36
36
  const modelCtor = mod[options.modelName];
37
37
  if (modelCtor && typeof modelCtor.getMorphClass === "function") {
38
38
  return String(modelCtor.getMorphClass());
@@ -1,4 +1,4 @@
1
- import { type ConnectionName } from "../../core/connection/ConnectionFactory";
1
+ import { type ConnectionName } from "../../core/connection/ConnectionFactory.js";
2
2
  export type SeedBootstrapPrecheckOptions = {
3
3
  test?: boolean;
4
4
  connectionNames?: ConnectionName[];
@@ -8,10 +8,10 @@ exports.printSeedBootstrapPrecheck = printSeedBootstrapPrecheck;
8
8
  exports.assertSeedBootstrapPrecheck = assertSeedBootstrapPrecheck;
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const chalk_1 = __importDefault(require("chalk"));
11
- const ConnectionFactory_1 = require("../../core/connection/ConnectionFactory");
12
- const resolveConnectionName_1 = require("../../core/connection/resolveConnectionName");
13
- const database_1 = require("../../config/database");
14
- const PathMap_1 = require("./PathMap");
11
+ const ConnectionFactory_js_1 = require("../../core/connection/ConnectionFactory.js");
12
+ const resolveConnectionName_js_1 = require("../../core/connection/resolveConnectionName.js");
13
+ const database_js_1 = require("../../config/database.js");
14
+ const PathMap_js_1 = require("./PathMap.js");
15
15
  function listMigrationFiles(migrationsDir) {
16
16
  return fs_1.default
17
17
  .readdirSync(migrationsDir)
@@ -19,13 +19,13 @@ function listMigrationFiles(migrationsDir) {
19
19
  .sort();
20
20
  }
21
21
  async function inspectConnection(connectionName, isTest) {
22
- const migrationsDir = PathMap_1.PathMap.migrations(isTest, connectionName);
22
+ const migrationsDir = PathMap_js_1.PathMap.migrations(isTest, connectionName);
23
23
  const reasons = [];
24
24
  let pendingMigrations = [];
25
- const driver = database_1.dbConfig.connections[connectionName]?.driver;
25
+ const driver = database_js_1.dbConfig.connections[connectionName]?.driver;
26
26
  if (driver === "mongo") {
27
27
  try {
28
- await (0, ConnectionFactory_1.getConnection)(connectionName);
28
+ await (0, ConnectionFactory_js_1.getConnection)(connectionName);
29
29
  }
30
30
  catch (error) {
31
31
  const message = error instanceof Error ? error.message : String(error);
@@ -64,7 +64,7 @@ async function inspectConnection(connectionName, isTest) {
64
64
  };
65
65
  }
66
66
  try {
67
- const db = await (0, ConnectionFactory_1.getAdapter)(connectionName);
67
+ const db = await (0, ConnectionFactory_js_1.getAdapter)(connectionName);
68
68
  const rows = await db.query("SELECT name FROM migrations ORDER BY id");
69
69
  const appliedNames = new Set(rows.map((row) => row.name));
70
70
  if (appliedNames.size === 0) {
@@ -91,7 +91,7 @@ async function runSeedBootstrapPrecheck(options = {}) {
91
91
  const isTest = !!options.test;
92
92
  const connectionNames = options.connectionNames && options.connectionNames.length > 0
93
93
  ? options.connectionNames
94
- : [(0, resolveConnectionName_1.resolveConnectionName)(undefined, { test: isTest })];
94
+ : [(0, resolveConnectionName_js_1.resolveConnectionName)(undefined, { test: isTest })];
95
95
  const checks = [];
96
96
  try {
97
97
  for (const connectionName of connectionNames) {
@@ -99,7 +99,7 @@ async function runSeedBootstrapPrecheck(options = {}) {
99
99
  }
100
100
  }
101
101
  finally {
102
- await (0, ConnectionFactory_1.closeAllConnections)();
102
+ await (0, ConnectionFactory_js_1.closeAllConnections)();
103
103
  }
104
104
  return {
105
105
  clean: checks.every((check) => check.clean),
@@ -7,7 +7,7 @@ exports.TemplateEngine = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const chalk_1 = __importDefault(require("chalk"));
10
- const PathMap_1 = require("./PathMap");
10
+ const PathMap_js_1 = require("./PathMap.js");
11
11
  /**
12
12
  * 🧩 TemplateEngine
13
13
  * Lightweight TypeScript-safe engine for .tpl rendering
@@ -21,7 +21,7 @@ const PathMap_1 = require("./PathMap");
21
21
  */
22
22
  class TemplateEngine {
23
23
  static load(templateName) {
24
- const tplPath = PathMap_1.PathMap.template(templateName);
24
+ const tplPath = PathMap_js_1.PathMap.template(templateName);
25
25
  if (!fs_1.default.existsSync(tplPath)) {
26
26
  console.error(chalk_1.default.red(`❌ Template not found: ${tplPath}`));
27
27
  throw new Error(`Template missing: ${templateName}.tpl`);
@@ -1,4 +1,4 @@
1
- import { BaseModel } from "../../../core/model/BaseModel";
1
+ import { BaseModel } from "../../../core/model/BaseModel.js";
2
2
  /** Plain object for attributes */
3
3
  export type PlainObject = Record<string, unknown>;
4
4
  /** Constructor helper */
@@ -1,4 +1,4 @@
1
- import type { RelationDefinition } from "../../../core/schema/SchemaBlueprint";
1
+ import type { RelationDefinition } from "../../../core/schema/SchemaBlueprint.js";
2
2
  export declare const FACTORY_EMPTY_MARK = "-";
3
3
  export declare const FACTORY_STATUS_FOOTER = "\nUse factories directly via FactoryRegistry.make(<name>)\n";
4
4
  export declare const FACTORY_GRAPH_HEADER = "\nModel Relationship Graph\n\n";
@@ -9,8 +9,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.generateFactoryGraph = generateFactoryGraph;
11
11
  const chalk_1 = __importDefault(require("chalk"));
12
- const FactoryDisplay_1 = require("./FactoryDisplay");
13
- const FactoryRegistry_1 = require("./FactoryRegistry");
12
+ const FactoryDisplay_js_1 = require("./FactoryDisplay.js");
13
+ const FactoryRegistry_js_1 = require("./FactoryRegistry.js");
14
14
  function hasSchema(modelCtor) {
15
15
  return (typeof modelCtor === "function" &&
16
16
  Object.prototype.hasOwnProperty.call(modelCtor, "schema"));
@@ -18,7 +18,7 @@ function hasSchema(modelCtor) {
18
18
  function collectLinks(factoryNames) {
19
19
  const links = [];
20
20
  for (const factoryName of factoryNames) {
21
- const factory = FactoryRegistry_1.FactoryRegistry.make(factoryName);
21
+ const factory = FactoryRegistry_js_1.FactoryRegistry.make(factoryName);
22
22
  const modelCtor = factory.model;
23
23
  const modelName = modelCtor.name.replace("Factory", "");
24
24
  const modelInstance = new modelCtor();
@@ -45,7 +45,7 @@ function dedupeLinks(links) {
45
45
  (candidate.from === link.to && candidate.to === link.from)));
46
46
  }
47
47
  function generateFactoryGraph(factoryNames) {
48
- let output = chalk_1.default.cyanBright(FactoryDisplay_1.FACTORY_GRAPH_HEADER);
48
+ let output = chalk_1.default.cyanBright(FactoryDisplay_js_1.FACTORY_GRAPH_HEADER);
49
49
  if (factoryNames.length === 0) {
50
50
  return output + chalk_1.default.gray("No factories registered.\n");
51
51
  }
@@ -63,7 +63,7 @@ function generateFactoryGraph(factoryNames) {
63
63
  for (const [node, relations] of grouped.entries()) {
64
64
  output += chalk_1.default.greenBright(`${node}\n`);
65
65
  for (const { to, rel } of relations) {
66
- output += `${chalk_1.default.gray(` ${(0, FactoryDisplay_1.getFactoryRelationArrow)(rel)} `)}${chalk_1.default.cyan(to)} ${chalk_1.default.gray(`(${rel})`)}\n`;
66
+ output += `${chalk_1.default.gray(` ${(0, FactoryDisplay_js_1.getFactoryRelationArrow)(rel)} `)}${chalk_1.default.cyan(to)} ${chalk_1.default.gray(`(${rel})`)}\n`;
67
67
  }
68
68
  output += "\n";
69
69
  }
@@ -1,4 +1,4 @@
1
- import type { StorageKind } from "../ArtifactStorage";
1
+ import type { StorageKind } from "../ArtifactStorage.js";
2
2
  /**
3
3
  * FactoryLoader
4
4
  * Automatically discovers and registers all factories at runtime.
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.loadFactories = loadFactories;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const FactoryRegistry_1 = require("./FactoryRegistry");
8
+ const FactoryRegistry_js_1 = require("./FactoryRegistry.js");
9
9
  /**
10
10
  * FactoryLoader
11
11
  * Automatically discovers and registers all factories at runtime.
@@ -20,9 +20,9 @@ const FactoryRegistry_1 = require("./FactoryRegistry");
20
20
  async function loadFactories(isTest = false, options = {}) {
21
21
  console.log(chalk_1.default.cyanBright("Initializing FactoryRegistry..."));
22
22
  try {
23
- FactoryRegistry_1.FactoryRegistry.clear();
24
- await FactoryRegistry_1.FactoryRegistry.autoDiscover(isTest, options);
25
- const count = FactoryRegistry_1.FactoryRegistry.list().length;
23
+ FactoryRegistry_js_1.FactoryRegistry.clear();
24
+ await FactoryRegistry_js_1.FactoryRegistry.autoDiscover(isTest, options);
25
+ const count = FactoryRegistry_js_1.FactoryRegistry.list().length;
26
26
  console.log(chalk_1.default.greenBright(`Loaded ${count} factories.`));
27
27
  }
28
28
  catch (error) {
@@ -1,6 +1,6 @@
1
- import type { BaseModel } from "../../../core/model/BaseModel";
2
- import { type StorageKind } from "../ArtifactStorage";
3
- import type { Factory } from "./Factory";
1
+ import type { BaseModel } from "../../../core/model/BaseModel.js";
2
+ import { type StorageKind } from "../ArtifactStorage.js";
3
+ import type { Factory } from "./Factory.js";
4
4
  export declare class FactoryRegistry {
5
5
  private static registry;
6
6
  static register<T extends Factory<BaseModel>>(name: string, factory: new () => T): void;
@@ -7,10 +7,10 @@ exports.FactoryRegistry = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
10
- const ArtifactRoutingReport_1 = require("../ArtifactRoutingReport");
11
- const ArtifactStorage_1 = require("../ArtifactStorage");
12
- const PathMap_1 = require("../PathMap");
13
- const tsRuntime_1 = require("../typescript/tsRuntime");
10
+ const ArtifactRoutingReport_js_1 = require("../ArtifactRoutingReport.js");
11
+ const ArtifactStorage_js_1 = require("../ArtifactStorage.js");
12
+ const PathMap_js_1 = require("../PathMap.js");
13
+ const tsRuntime_js_1 = require("../typescript/tsRuntime.js");
14
14
  class FactoryRegistry {
15
15
  static register(name, factory) {
16
16
  if (this.registry.has(name)) {
@@ -38,7 +38,7 @@ class FactoryRegistry {
38
38
  return this.make(pivotName);
39
39
  }
40
40
  static async autoDiscover(isTest = false, options = {}) {
41
- const dir = PathMap_1.PathMap.factories(isTest);
41
+ const dir = PathMap_js_1.PathMap.factories(isTest);
42
42
  if (!fs_1.default.existsSync(dir)) {
43
43
  console.log(chalk_1.default.gray(`No factories folder found at: ${dir}`));
44
44
  return;
@@ -47,17 +47,17 @@ class FactoryRegistry {
47
47
  for (const file of files) {
48
48
  const fullPath = path_1.default.join(dir, file);
49
49
  try {
50
- const importedModule = (0, tsRuntime_1.loadModule)(fullPath);
50
+ const importedModule = (0, tsRuntime_js_1.loadModule)(fullPath);
51
51
  for (const [name, exported] of Object.entries(importedModule)) {
52
52
  if (typeof exported !== "function" ||
53
53
  !exported.name.endsWith("Factory")) {
54
54
  continue;
55
55
  }
56
- const factoryStorageKind = (0, ArtifactStorage_1.resolveFactoryStorageKindFromCtor)(exported);
56
+ const factoryStorageKind = (0, ArtifactStorage_js_1.resolveFactoryStorageKindFromCtor)(exported);
57
57
  if (options.storageKind &&
58
- !(0, ArtifactStorage_1.matchesTargetStorageKind)(factoryStorageKind, options.storageKind)) {
59
- const message = (0, ArtifactRoutingReport_1.summarizeSkippedArtifacts)("factory", [
60
- (0, ArtifactRoutingReport_1.createTargetedArtifactDecision)(name, factoryStorageKind, options.storageKind),
58
+ !(0, ArtifactStorage_js_1.matchesTargetStorageKind)(factoryStorageKind, options.storageKind)) {
59
+ const message = (0, ArtifactRoutingReport_js_1.summarizeSkippedArtifacts)("factory", [
60
+ (0, ArtifactRoutingReport_js_1.createTargetedArtifactDecision)(name, factoryStorageKind, options.storageKind),
61
61
  ], options.storageKind);
62
62
  console.warn(chalk_1.default.yellow(message));
63
63
  continue;
@@ -1,4 +1,4 @@
1
- import type { DriverAdapter } from "../../../core/connection/DriverAdapter";
1
+ import type { DriverAdapter } from "../../../core/connection/DriverAdapter.js";
2
2
  export type SqlMigrationDriver = "mysql" | "pg" | "sqlite";
3
3
  export interface MigrationLockStrategy {
4
4
  ensureBootstrap(db: DriverAdapter, driver: SqlMigrationDriver): Promise<void>;
@@ -4,10 +4,10 @@ exports.NativeSqlMigrationLockStrategy = void 0;
4
4
  exports.getMigrationLockStrategy = getMigrationLockStrategy;
5
5
  exports.setMigrationLockStrategy = setMigrationLockStrategy;
6
6
  exports.resetMigrationLockStrategy = resetMigrationLockStrategy;
7
- const database_1 = require("../../../config/database");
7
+ const database_js_1 = require("../../../config/database.js");
8
8
  const SQLITE_LOCK_OWNERS = new Map();
9
9
  function resolveDriver(db) {
10
- const configuredDriver = database_1.dbConfig.connections[db.name]?.driver;
10
+ const configuredDriver = database_js_1.dbConfig.connections[db.name]?.driver;
11
11
  if (configuredDriver === "mysql" || configuredDriver === "pg" || configuredDriver === "sqlite") {
12
12
  return configuredDriver;
13
13
  }
@@ -1,5 +1,5 @@
1
- import type { DriverAdapter } from "../../../core/connection/DriverAdapter";
2
- import { type SqlMigrationDriver } from "./MigrationLockStrategy";
1
+ import type { DriverAdapter } from "../../../core/connection/DriverAdapter.js";
2
+ import { type SqlMigrationDriver } from "./MigrationLockStrategy.js";
3
3
  export type { SqlMigrationDriver };
4
4
  export type MigrationRow = {
5
5
  id?: number;
@@ -18,12 +18,12 @@ exports.validateMigrationHistory = validateMigrationHistory;
18
18
  const fs_1 = __importDefault(require("fs"));
19
19
  const crypto_1 = __importDefault(require("crypto"));
20
20
  const path_1 = __importDefault(require("path"));
21
- const database_1 = require("../../../config/database");
22
- const MigrationLockStrategy_1 = require("./MigrationLockStrategy");
21
+ const database_js_1 = require("../../../config/database.js");
22
+ const MigrationLockStrategy_js_1 = require("./MigrationLockStrategy.js");
23
23
  const AUTO_GENERATED_MIGRATION_RE = /^\d+_(create|update)_[A-Za-z0-9_]+_table\.(ts|js)$/;
24
24
  const AUTO_GENERATED_CREATE_MIGRATION_RE = /^\d+_create_([A-Za-z0-9_]+)_table\.(ts|js)$/;
25
25
  function resolveDriver(db) {
26
- const driver = database_1.dbConfig.connections[db.name]?.driver ?? db.name;
26
+ const driver = database_js_1.dbConfig.connections[db.name]?.driver ?? db.name;
27
27
  if (driver === "mysql" || driver === "pg" || driver === "sqlite") {
28
28
  return driver;
29
29
  }
@@ -94,7 +94,7 @@ async function ensureMigrationTables(db) {
94
94
  const driver = resolveDriver(db);
95
95
  await db.execute(trackerTableSQL(driver));
96
96
  await ensureChecksumColumn(db, driver);
97
- await (0, MigrationLockStrategy_1.getMigrationLockStrategy)().ensureBootstrap(db, driver);
97
+ await (0, MigrationLockStrategy_js_1.getMigrationLockStrategy)().ensureBootstrap(db, driver);
98
98
  return driver;
99
99
  }
100
100
  function computeMigrationChecksum(filePath) {
@@ -180,10 +180,10 @@ async function tryPruneStaleGeneratedCreateMigration(db, migrationName) {
180
180
  return true;
181
181
  }
182
182
  async function acquireMigrationLock(db, owner) {
183
- await (0, MigrationLockStrategy_1.getMigrationLockStrategy)().acquire(db, owner);
183
+ await (0, MigrationLockStrategy_js_1.getMigrationLockStrategy)().acquire(db, owner);
184
184
  }
185
185
  async function releaseMigrationLock(db, owner, outcome) {
186
- await (0, MigrationLockStrategy_1.getMigrationLockStrategy)().release(db, owner, outcome);
186
+ await (0, MigrationLockStrategy_js_1.getMigrationLockStrategy)().release(db, owner, outcome);
187
187
  }
188
188
  async function readAppliedMigrations(db) {
189
189
  return await db.query(`SELECT ${db.wrapId("id")} AS id, ${db.wrapId("name")} AS name, ${db.wrapId("batch")} AS batch, ${db.wrapId("checksum")} AS checksum, ${db.wrapId("run_at")} AS run_at FROM ${db.wrapId("migrations")} ORDER BY ${db.wrapId("id")}`);
@@ -14,7 +14,7 @@ exports.validateMigrationHistory = validateMigrationHistory;
14
14
  exports.doesCollectionExist = doesCollectionExist;
15
15
  const fs_1 = __importDefault(require("fs"));
16
16
  const path_1 = __importDefault(require("path"));
17
- const MigrationTracker_1 = require("./MigrationTracker");
17
+ const MigrationTracker_js_1 = require("./MigrationTracker.js");
18
18
  const MIGRATIONS_COLLECTION = "migrations";
19
19
  const HISTORY_KIND = "history";
20
20
  const LOCK_DOC_ID = "__eloquent_migration_lock__";
@@ -222,7 +222,7 @@ async function backfillMissingChecksums(db, rows, migrationsDir) {
222
222
  }
223
223
  throw new Error(`Applied migration "${row.name}" is missing from disk and cannot be checksum-validated.`);
224
224
  }
225
- const checksum = (0, MigrationTracker_1.computeMigrationChecksum)(resolved.filePath);
225
+ const checksum = (0, MigrationTracker_js_1.computeMigrationChecksum)(resolved.filePath);
226
226
  if (resolved.relinked) {
227
227
  await relinkAppliedMigration(db, row.name, resolved.fileName, checksum);
228
228
  updatedRows.push({ ...row, name: resolved.fileName, checksum });
@@ -255,7 +255,7 @@ async function validateMigrationHistory(db, migrationsDir) {
255
255
  }
256
256
  throw new Error(`Applied migration "${row.name}" is missing from disk.`);
257
257
  }
258
- const currentChecksum = (0, MigrationTracker_1.computeMigrationChecksum)(resolved.filePath);
258
+ const currentChecksum = (0, MigrationTracker_js_1.computeMigrationChecksum)(resolved.filePath);
259
259
  if (resolved.relinked) {
260
260
  await relinkAppliedMigration(db, row.name, resolved.fileName, currentChecksum);
261
261
  row.name = resolved.fileName;
@@ -1,4 +1,4 @@
1
- import type { ConnectionName } from "../../core/connection/ConnectionFactory";
1
+ import type { ConnectionName } from "../../core/connection/ConnectionFactory.js";
2
2
  export type DriverConnectionFlags = {
3
3
  mysql?: boolean;
4
4
  pg?: boolean;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveConnectionNamesFromFlags = resolveConnectionNamesFromFlags;
4
- const database_1 = require("../../config/database");
4
+ const database_js_1 = require("../../config/database.js");
5
5
  function mapDriverToConnectionName(driver, isTest) {
6
6
  if (isTest) {
7
7
  const testName = `${driver}_test`;
8
- if (Object.prototype.hasOwnProperty.call(database_1.dbConfig.connections, testName)) {
8
+ if (Object.prototype.hasOwnProperty.call(database_js_1.dbConfig.connections, testName)) {
9
9
  return testName;
10
10
  }
11
11
  }
12
- if (Object.prototype.hasOwnProperty.call(database_1.dbConfig.connections, driver)) {
12
+ if (Object.prototype.hasOwnProperty.call(database_js_1.dbConfig.connections, driver)) {
13
13
  return driver;
14
14
  }
15
15
  return null;
@@ -1,4 +1,4 @@
1
- import type { ConnectionName } from "../../core/connection/ConnectionFactory";
1
+ import type { ConnectionName } from "../../core/connection/ConnectionFactory.js";
2
2
  export type SqlConnectionFlags = {
3
3
  mysql?: boolean;
4
4
  pg?: boolean;
@@ -1,4 +1,4 @@
1
- import { TypeScriptCompiler } from "./TypeScriptCompiler";
1
+ import { TypeScriptCompiler } from "./TypeScriptCompiler.js";
2
2
  /**
3
3
  * 🧩 BaseCommand
4
4
  * Shared foundation for all Eloquent CLI commands.
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BaseCommand = void 0;
7
- const TypeScriptCompiler_1 = require("./TypeScriptCompiler");
7
+ const TypeScriptCompiler_js_1 = require("./TypeScriptCompiler.js");
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  /**
10
10
  * 🧩 BaseCommand
@@ -13,9 +13,9 @@ const chalk_1 = __importDefault(require("chalk"));
13
13
  */
14
14
  class BaseCommand {
15
15
  constructor() {
16
- this.compiler = TypeScriptCompiler_1.TypeScriptCompiler;
16
+ this.compiler = TypeScriptCompiler_js_1.TypeScriptCompiler;
17
17
  // ✅ Ensure ts-node runtime is ready for all CLI commands
18
- TypeScriptCompiler_1.TypeScriptCompiler.ensureRuntime();
18
+ TypeScriptCompiler_js_1.TypeScriptCompiler.ensureRuntime();
19
19
  }
20
20
  success(message) {
21
21
  console.log(chalk_1.default.greenBright(`✅ ${message}`));
@@ -28,7 +28,6 @@ class TypeScriptCompiler {
28
28
  compilerOptions: {
29
29
  module: "commonjs",
30
30
  target: "es2020",
31
- downlevelIteration: true,
32
31
  moduleResolution: "node",
33
32
  skipLibCheck: true,
34
33
  },
@@ -22,12 +22,26 @@ const PACKAGE_NAME = (() => {
22
22
  return "";
23
23
  }
24
24
  })();
25
+ const PACKAGE_SOURCE_ROOT = path_1.default.join(PACKAGE_ROOT, "src") + path_1.default.sep;
26
+ const PACKAGE_BIN_ROOT = path_1.default.join(PACKAGE_ROOT, "bin") + path_1.default.sep;
27
+ function isPackageSourceTreeFile(filePath) {
28
+ const normalized = path_1.default.resolve(filePath);
29
+ return (normalized.startsWith(PACKAGE_SOURCE_ROOT) ||
30
+ normalized.startsWith(PACKAGE_BIN_ROOT));
31
+ }
32
+ function isTypeScriptSourceFile(filePath) {
33
+ return /\.(?:[cm]?ts|tsx)$/i.test(filePath);
34
+ }
35
+ function runningInsideJest() {
36
+ return typeof process.env.JEST_WORKER_ID === "string";
37
+ }
25
38
  function resolveExistingModulePath(basePath) {
26
39
  const extension = path_1.default.extname(basePath).toLowerCase();
27
40
  const withoutExtension = extension.length > 0 ? basePath.slice(0, -extension.length) : basePath;
28
41
  const candidates = [];
29
42
  const seen = new Set();
30
43
  const addCandidate = (candidate) => {
44
+ /* istanbul ignore next -- defensive guard; current candidate generation is unique */
31
45
  if (seen.has(candidate)) {
32
46
  return;
33
47
  }
@@ -113,7 +127,6 @@ function ensureTsRuntime() {
113
127
  compilerOptions: {
114
128
  module: "commonjs",
115
129
  target: "es2020",
116
- downlevelIteration: true,
117
130
  moduleResolution: "node",
118
131
  skipLibCheck: true,
119
132
  },
@@ -143,7 +156,8 @@ function requireFromFile(filePath) {
143
156
  function loadTypeScriptModule(filePath, runtimeAvailable = ensureTsRuntime()) {
144
157
  const absolutePath = path_1.default.resolve(filePath);
145
158
  const forceTranspileReload = forceTranspileReloadPaths.delete(absolutePath);
146
- if (runtimeAvailable && !forceTranspileReload) {
159
+ const preferManualTranspile = isPackageSourceTreeFile(absolutePath);
160
+ if (runtimeAvailable && !forceTranspileReload && !preferManualTranspile) {
147
161
  try {
148
162
  return requireFromFile(filePath);
149
163
  }
@@ -173,7 +187,6 @@ function loadTranspiledTsModule(filePath, runtimeAvailable) {
173
187
  compilerOptions: {
174
188
  module: typescript_1.default.ModuleKind.CommonJS,
175
189
  target: typescript_1.default.ScriptTarget.ES2020,
176
- downlevelIteration: true,
177
190
  moduleResolution: typescript_1.default.ModuleResolutionKind.NodeJs,
178
191
  skipLibCheck: true,
179
192
  esModuleInterop: true,
@@ -192,7 +205,16 @@ function loadTranspiledTsModule(filePath, runtimeAvailable) {
192
205
  }
193
206
  const resolved = resolveLocalRequest(request, absolutePath);
194
207
  if (resolved) {
195
- if (resolved.endsWith(".ts")) {
208
+ if (isTypeScriptSourceFile(resolved)) {
209
+ if (runningInsideJest()) {
210
+ try {
211
+ return fallbackRequire(request);
212
+ }
213
+ catch {
214
+ // Keep the manual transpile fallback for NodeNext-style local source
215
+ // imports that Jest/ts-node cannot resolve directly.
216
+ }
217
+ }
196
218
  return loadTypeScriptModule(resolved, runtimeAvailable);
197
219
  }
198
220
  return requireFromFile(resolved);
@@ -36,16 +36,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.dbConfig = void 0;
37
37
  // src/config/database.ts
38
38
  const dotenv = __importStar(require("dotenv"));
39
- const dbRoleEnv_1 = require("./dbRoleEnv");
39
+ const dbRoleEnv_js_1 = require("./dbRoleEnv.js");
40
40
  dotenv.config();
41
- const mysqlRuntime = (0, dbRoleEnv_1.resolveMysqlEnv)(process.env, { test: false });
42
- const mysqlTest = (0, dbRoleEnv_1.resolveMysqlEnv)(process.env, { test: true });
43
- const pgRuntime = (0, dbRoleEnv_1.resolvePgEnv)(process.env, { test: false });
44
- const pgTest = (0, dbRoleEnv_1.resolvePgEnv)(process.env, { test: true });
45
- const sqliteRuntimePath = (0, dbRoleEnv_1.resolveSqlitePath)(process.env, { test: false });
46
- const sqliteTestPath = (0, dbRoleEnv_1.resolveSqlitePath)(process.env, { test: true });
47
- const mongoRuntime = (0, dbRoleEnv_1.resolveMongoEnv)(process.env, { test: false });
48
- const mongoTest = (0, dbRoleEnv_1.resolveMongoEnv)(process.env, { test: true });
41
+ const mysqlRuntime = (0, dbRoleEnv_js_1.resolveMysqlEnv)(process.env, { test: false });
42
+ const mysqlTest = (0, dbRoleEnv_js_1.resolveMysqlEnv)(process.env, { test: true });
43
+ const pgRuntime = (0, dbRoleEnv_js_1.resolvePgEnv)(process.env, { test: false });
44
+ const pgTest = (0, dbRoleEnv_js_1.resolvePgEnv)(process.env, { test: true });
45
+ const sqliteRuntimePath = (0, dbRoleEnv_js_1.resolveSqlitePath)(process.env, { test: false });
46
+ const sqliteTestPath = (0, dbRoleEnv_js_1.resolveSqlitePath)(process.env, { test: true });
47
+ const mongoRuntime = (0, dbRoleEnv_js_1.resolveMongoEnv)(process.env, { test: false });
48
+ const mongoTest = (0, dbRoleEnv_js_1.resolveMongoEnv)(process.env, { test: true });
49
49
  exports.dbConfig = {
50
50
  default: process.env.DB_CONNECTION || "mysql",
51
51
  connections: {
@@ -1,4 +1,4 @@
1
- import { CacheDriver } from "./CacheDriver";
1
+ import { CacheDriver } from "./CacheDriver.js";
2
2
  export declare class CacheFallbackManager {
3
3
  private static drivers;
4
4
  private static active;
@@ -1,4 +1,4 @@
1
- import { CacheDriver } from "./CacheDriver";
1
+ import { CacheDriver } from "./CacheDriver.js";
2
2
  export declare class CacheManager {
3
3
  private static driver;
4
4
  static use(driver: CacheDriver): void;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CacheManager = void 0;
4
- const MemoryCacheDriver_1 = require("./drivers/MemoryCacheDriver");
4
+ const MemoryCacheDriver_js_1 = require("./drivers/MemoryCacheDriver.js");
5
5
  class CacheManager {
6
6
  static use(driver) {
7
7
  this.driver = driver;
@@ -23,4 +23,4 @@ class CacheManager {
23
23
  }
24
24
  }
25
25
  exports.CacheManager = CacheManager;
26
- CacheManager.driver = new MemoryCacheDriver_1.MemoryCacheDriver();
26
+ CacheManager.driver = new MemoryCacheDriver_js_1.MemoryCacheDriver();