@alpha.consultings/eloquent-orm.js 1.0.9 → 1.0.11

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 (157) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/PACKAGE-UPDATE-SUMMARY.md +18 -11
  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 +31 -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 +17 -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/tsRuntime.js +62 -9
  80. package/dist/config/database.js +9 -9
  81. package/dist/core/cache/CacheFallbackManager.d.ts +1 -1
  82. package/dist/core/cache/CacheManager.d.ts +1 -1
  83. package/dist/core/cache/CacheManager.js +2 -2
  84. package/dist/core/cache/CacheRegistry.js +4 -4
  85. package/dist/core/cache/drivers/FileCacheDriver.d.ts +1 -1
  86. package/dist/core/cache/drivers/FileCacheDriver.js +2 -2
  87. package/dist/core/cache/drivers/MemcachedCacheDriver.d.ts +1 -1
  88. package/dist/core/cache/drivers/MemcachedCacheDriver.js +2 -2
  89. package/dist/core/cache/drivers/MemoryCacheDriver.d.ts +1 -1
  90. package/dist/core/cache/drivers/MemoryCacheDriver.js +2 -2
  91. package/dist/core/cache/setupCache.js +12 -12
  92. package/dist/core/connection/ConnectionFactory.d.ts +2 -2
  93. package/dist/core/connection/ConnectionFactory.js +9 -9
  94. package/dist/core/connection/DatabaseConnection.d.ts +2 -2
  95. package/dist/core/connection/DatabaseConnection.js +4 -4
  96. package/dist/core/connection/DriverAdapter.d.ts +1 -1
  97. package/dist/core/connection/DriverAdapter.js +2 -2
  98. package/dist/core/connection/resolveConnectionName.d.ts +1 -1
  99. package/dist/core/connection/resolveConnectionName.js +7 -7
  100. package/dist/core/model/BaseModel.d.ts +29 -29
  101. package/dist/core/model/BaseModel.js +38 -38
  102. package/dist/core/model/BaseModelSafeFinderStatics.d.ts +1 -1
  103. package/dist/core/model/BaseModelSafeFinderStatics.js +19 -19
  104. package/dist/core/model/CoreModel.d.ts +4 -4
  105. package/dist/core/model/CoreModel.js +28 -28
  106. package/dist/core/model/CoreModelPersistenceState.d.ts +1 -1
  107. package/dist/core/model/CoreModelSafeFinderSupport.d.ts +2 -2
  108. package/dist/core/model/CoreModelSafeFinderSupport.js +2 -2
  109. package/dist/core/model/CoreModelValidationEvents.d.ts +2 -2
  110. package/dist/core/model/CoreModelValidationEvents.js +2 -2
  111. package/dist/core/model/SafeFinder.d.ts +1 -1
  112. package/dist/core/model/SafeFinder.js +2 -2
  113. package/dist/core/orm/mixins/CastsMixin.js +2 -2
  114. package/dist/core/orm/mixins/HooksMixin.js +8 -8
  115. package/dist/core/orm/mixins/MorphableMixin.js +4 -4
  116. package/dist/core/orm/mixins/PivotHelperMixin.js +3 -3
  117. package/dist/core/orm/mixins/QueryCacheMixin.js +20 -20
  118. package/dist/core/orm/mixins/ScopeMixin.js +2 -2
  119. package/dist/core/orm/mixins/SoftDeletesMixin.js +2 -2
  120. package/dist/core/orm/mixins/utils/HookStore.d.ts +1 -1
  121. package/dist/core/orm/mixins/utils/HookStore.js +2 -2
  122. package/dist/core/orm/mixins/utils/modelRegistration.d.ts +1 -1
  123. package/dist/core/orm/mixins/utils/modelRegistration.js +6 -6
  124. package/dist/core/orm/relations/BelongsTo.d.ts +1 -1
  125. package/dist/core/orm/relations/BelongsTo.js +2 -2
  126. package/dist/core/orm/relations/BelongsToMany.d.ts +1 -1
  127. package/dist/core/orm/relations/BelongsToMany.js +2 -2
  128. package/dist/core/orm/relations/HasMany.d.ts +1 -1
  129. package/dist/core/orm/relations/HasMany.js +2 -2
  130. package/dist/core/orm/relations/HasOne.d.ts +1 -1
  131. package/dist/core/orm/relations/HasOne.js +2 -2
  132. package/dist/core/orm/relations/MorphMany.d.ts +1 -1
  133. package/dist/core/orm/relations/MorphMany.js +2 -2
  134. package/dist/core/orm/relations/MorphOne.d.ts +1 -1
  135. package/dist/core/orm/relations/MorphOne.js +2 -2
  136. package/dist/core/orm/relations/MorphTo.d.ts +1 -1
  137. package/dist/core/orm/relations/MorphTo.js +5 -5
  138. package/dist/core/schema/SchemaBuilder.d.ts +2 -2
  139. package/dist/core/schema/SchemaBuilder.js +9 -9
  140. package/dist/core/schema/SchemaValidator.d.ts +1 -1
  141. package/dist/core/security/AbstractSecurity.d.ts +1 -1
  142. package/dist/core/security/EnvKeySecurity.d.ts +1 -1
  143. package/dist/core/security/EnvKeySecurity.js +2 -2
  144. package/dist/core/security/NoSecurity.d.ts +1 -1
  145. package/dist/core/security/NoSecurity.js +2 -2
  146. package/dist/core/security/SecurityFactory.d.ts +1 -1
  147. package/dist/core/security/SecurityFactory.js +4 -4
  148. package/dist/core/security/index.d.ts +5 -5
  149. package/dist/core/security/index.js +5 -5
  150. package/dist/index.d.ts +10 -10
  151. package/dist/index.js +30 -30
  152. package/esm/Factory.mjs +113 -136
  153. package/esm/Model.mjs +4 -0
  154. package/esm/index.mjs +23 -28
  155. package/package.json +14 -5
  156. package/src/cli/templates/factory.tpl +1 -1
  157. package/src/cli/templates/seed.tpl +1 -1
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerCliMakeArtifactCommands = registerCliMakeArtifactCommands;
4
- const makeSeed_1 = require("../commands/makeSeed");
5
- const makeFactory_1 = require("../commands/makeFactory");
6
- const makeScenario_1 = require("../commands/makeScenario");
7
- const CliProductionGuards_1 = require("./CliProductionGuards");
8
- const CliActionRuntime_1 = require("./CliActionRuntime");
4
+ const makeSeed_js_1 = require("../commands/makeSeed.js");
5
+ const makeFactory_js_1 = require("../commands/makeFactory.js");
6
+ const makeScenario_js_1 = require("../commands/makeScenario.js");
7
+ const CliProductionGuards_js_1 = require("./CliProductionGuards.js");
8
+ const CliActionRuntime_js_1 = require("./CliActionRuntime.js");
9
9
  function registerCliMakeArtifactCommands(program) {
10
10
  program
11
11
  .command("make:seed <model>")
@@ -16,16 +16,16 @@ function registerCliMakeArtifactCommands(program) {
16
16
  .option("--yes", "Acknowledge production override for this destructive command")
17
17
  .description("Generate a seeder file linked to a model factory")
18
18
  .action(async (model, options) => {
19
- if (!(0, CliProductionGuards_1.ensureCliProductionTestOnly)("make:seed", { test: !!options.test })) {
19
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionTestOnly)("make:seed", { test: !!options.test })) {
20
20
  return;
21
21
  }
22
- if (!(0, CliProductionGuards_1.ensureCliProductionOverride)("make:seed", {
22
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionOverride)("make:seed", {
23
23
  force: !!options.force,
24
24
  yes: !!options.yes,
25
25
  })) {
26
26
  return;
27
27
  }
28
- await (0, makeSeed_1.makeSeed)(model, {
28
+ await (0, makeSeed_js_1.makeSeed)(model, {
29
29
  count: Number(options.count),
30
30
  test: !!options.test,
31
31
  force: !!options.force,
@@ -41,17 +41,17 @@ function registerCliMakeArtifactCommands(program) {
41
41
  .option("--yes", "Acknowledge production override for this destructive command")
42
42
  .description("Generate a factory for a model")
43
43
  .action(async (name, options) => {
44
- if (!(0, CliProductionGuards_1.ensureCliProductionTestOnly)("make:factory", { test: !!options.test })) {
44
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionTestOnly)("make:factory", { test: !!options.test })) {
45
45
  return;
46
46
  }
47
- if (!(0, CliProductionGuards_1.ensureCliProductionOverride)("make:factory", {
47
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionOverride)("make:factory", {
48
48
  force: !!options.force,
49
49
  yes: !!options.yes,
50
50
  })) {
51
51
  return;
52
52
  }
53
53
  const modelName = options.model ?? name;
54
- await (0, makeFactory_1.makeFactory)(modelName, {
54
+ await (0, makeFactory_js_1.makeFactory)(modelName, {
55
55
  test: !!options.test,
56
56
  force: !!options.force,
57
57
  mongo: !!options.mongo,
@@ -69,17 +69,17 @@ function registerCliMakeArtifactCommands(program) {
69
69
  .option("--yes", "Acknowledge production override for this destructive command")
70
70
  .description("Generate an automated scenario (models, migrations, factories, seeds)")
71
71
  .action(async (name, options) => {
72
- return (0, CliActionRuntime_1.runCliAction)(async () => {
73
- if (!(0, CliProductionGuards_1.ensureCliProductionTestOnly)("make:scenario", { test: !!options.test })) {
72
+ return (0, CliActionRuntime_js_1.runCliAction)(async () => {
73
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionTestOnly)("make:scenario", { test: !!options.test })) {
74
74
  return;
75
75
  }
76
- if (!(0, CliProductionGuards_1.ensureCliProductionOverride)("make:scenario", {
76
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionOverride)("make:scenario", {
77
77
  force: !!options.force,
78
78
  yes: !!options.yes,
79
79
  })) {
80
80
  return;
81
81
  }
82
- await (0, makeScenario_1.makeScenario)(name, {
82
+ await (0, makeScenario_js_1.makeScenario)(name, {
83
83
  test: !!options.test,
84
84
  mongo: !!options.mongo,
85
85
  preset: options.preset,
@@ -5,15 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.registerCliMigrationCommands = registerCliMigrationCommands;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const makeMigration_1 = require("../commands/makeMigration");
9
- const migrateRun_1 = require("../commands/migrateRun");
10
- const migrateRollback_1 = require("../commands/migrateRollback");
11
- const migrateStatus_1 = require("../commands/migrateStatus");
12
- const migrateFresh_1 = require("../commands/migrateFresh");
13
- const migrateReset_1 = require("../commands/migrateReset");
14
- const CliCommandTargets_1 = require("./CliCommandTargets");
15
- const CliActionRuntime_1 = require("./CliActionRuntime");
16
- const CliProductionGuards_1 = require("./CliProductionGuards");
8
+ const makeMigration_js_1 = require("../commands/makeMigration.js");
9
+ const migrateRun_js_1 = require("../commands/migrateRun.js");
10
+ const migrateRollback_js_1 = require("../commands/migrateRollback.js");
11
+ const migrateStatus_js_1 = require("../commands/migrateStatus.js");
12
+ const migrateFresh_js_1 = require("../commands/migrateFresh.js");
13
+ const migrateReset_js_1 = require("../commands/migrateReset.js");
14
+ const CliCommandTargets_js_1 = require("./CliCommandTargets.js");
15
+ const CliActionRuntime_js_1 = require("./CliActionRuntime.js");
16
+ const CliProductionGuards_js_1 = require("./CliProductionGuards.js");
17
17
  function registerCliMigrationCommands(program) {
18
18
  program
19
19
  .command("make:migration [model]")
@@ -29,7 +29,7 @@ function registerCliMigrationCommands(program) {
29
29
  .option("--yes", "Acknowledge production override for this destructive command")
30
30
  .description("Generate migration from a model or all models")
31
31
  .action(async (model, options) => {
32
- if (!(0, CliProductionGuards_1.ensureCliProductionOverride)("make:migration", {
32
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionOverride)("make:migration", {
33
33
  force: !!options.force,
34
34
  yes: !!options.yes,
35
35
  })) {
@@ -41,10 +41,10 @@ function registerCliMigrationCommands(program) {
41
41
  console.error(chalk_1.default.red("ERROR: Please provide a model name or use --all"));
42
42
  return;
43
43
  }
44
- return (0, CliActionRuntime_1.runCliAction)(async () => {
45
- const connectionNames = (0, CliCommandTargets_1.resolveCliConnectionNames)(options);
44
+ return (0, CliActionRuntime_js_1.runCliAction)(async () => {
45
+ const connectionNames = (0, CliCommandTargets_js_1.resolveCliConnectionNames)(options);
46
46
  if (connectionNames.length === 0) {
47
- await (0, makeMigration_1.makeMigration)(target, {
47
+ await (0, makeMigration_js_1.makeMigration)(target, {
48
48
  test: !!options.test,
49
49
  pivotSeparate: !!options.pivotSeparate,
50
50
  exit: false,
@@ -52,7 +52,7 @@ function registerCliMigrationCommands(program) {
52
52
  return;
53
53
  }
54
54
  for (const connectionName of connectionNames) {
55
- await (0, makeMigration_1.makeMigration)(target, {
55
+ await (0, makeMigration_js_1.makeMigration)(target, {
56
56
  test: !!options.test,
57
57
  pivotSeparate: !!options.pivotSeparate,
58
58
  connectionName,
@@ -73,11 +73,11 @@ function registerCliMigrationCommands(program) {
73
73
  .option("--all-migrations", "Auto-generate migrations for all models before running")
74
74
  .option("--pivot-separate", "Emit pivot tables as separate migration files (with --all-migrations)")
75
75
  .action(async (model, options) => {
76
- return (0, CliActionRuntime_1.runCliAction)(async () => {
77
- const connectionNames = (0, CliCommandTargets_1.resolveCliConnectionNames)(options);
76
+ return (0, CliActionRuntime_js_1.runCliAction)(async () => {
77
+ const connectionNames = (0, CliCommandTargets_js_1.resolveCliConnectionNames)(options);
78
78
  if (options?.allMigrations) {
79
79
  if (connectionNames.length === 0) {
80
- await (0, makeMigration_1.makeMigration)("all", {
80
+ await (0, makeMigration_js_1.makeMigration)("all", {
81
81
  test: !!options.test,
82
82
  exit: false,
83
83
  pivotSeparate: !!options.pivotSeparate,
@@ -85,7 +85,7 @@ function registerCliMigrationCommands(program) {
85
85
  }
86
86
  else {
87
87
  for (const connectionName of connectionNames) {
88
- await (0, makeMigration_1.makeMigration)("all", {
88
+ await (0, makeMigration_js_1.makeMigration)("all", {
89
89
  test: !!options.test,
90
90
  exit: false,
91
91
  pivotSeparate: !!options.pivotSeparate,
@@ -94,7 +94,7 @@ function registerCliMigrationCommands(program) {
94
94
  }
95
95
  }
96
96
  }
97
- return (0, migrateRun_1.migrateRun)(!!options?.test, model, false, true, {
97
+ return (0, migrateRun_js_1.migrateRun)(!!options?.test, model, false, true, {
98
98
  connectionNames,
99
99
  });
100
100
  });
@@ -112,8 +112,8 @@ function registerCliMigrationCommands(program) {
112
112
  .description("Rollback the latest migration(s)")
113
113
  .action(async (options) => {
114
114
  const stepNumber = Number(options.step ?? 1);
115
- const connectionNames = (0, CliCommandTargets_1.resolveCliConnectionNames)(options);
116
- await (0, migrateRollback_1.migrateRollback)({
115
+ const connectionNames = (0, CliCommandTargets_js_1.resolveCliConnectionNames)(options);
116
+ await (0, migrateRollback_js_1.migrateRollback)({
117
117
  test: !!options.test,
118
118
  step: stepNumber,
119
119
  allMigrations: !!options.allMigrations,
@@ -131,8 +131,8 @@ function registerCliMigrationCommands(program) {
131
131
  .option("--all-connections", "Show status for mysql, pg, and sqlite")
132
132
  .option("--all-migrations", "Accepted for parity; status already covers all migration files")
133
133
  .action((options) => {
134
- const connectionNames = (0, CliCommandTargets_1.resolveCliConnectionNames)(options);
135
- return (0, migrateStatus_1.migrateStatus)({
134
+ const connectionNames = (0, CliCommandTargets_js_1.resolveCliConnectionNames)(options);
135
+ return (0, migrateStatus_js_1.migrateStatus)({
136
136
  test: !!options.test,
137
137
  allMigrations: !!options.allMigrations,
138
138
  connectionNames,
@@ -151,14 +151,14 @@ function registerCliMigrationCommands(program) {
151
151
  .option("--force", "Skip confirmation prompt")
152
152
  .option("--yes", "Acknowledge production override for this destructive command")
153
153
  .action((options) => {
154
- if (!(0, CliProductionGuards_1.ensureCliProductionOverride)("migrate:fresh", {
154
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionOverride)("migrate:fresh", {
155
155
  force: !!options.force,
156
156
  yes: !!options.yes,
157
157
  })) {
158
158
  return;
159
159
  }
160
- const connectionNames = (0, CliCommandTargets_1.resolveCliConnectionNames)(options);
161
- return (0, migrateFresh_1.migrateFresh)({
160
+ const connectionNames = (0, CliCommandTargets_js_1.resolveCliConnectionNames)(options);
161
+ return (0, migrateFresh_js_1.migrateFresh)({
162
162
  test: !!options.test,
163
163
  force: !!options.force,
164
164
  allMigrations: !!options.allMigrations,
@@ -178,14 +178,14 @@ function registerCliMigrationCommands(program) {
178
178
  .option("--force", "Required override flag in production mode")
179
179
  .option("--yes", "Acknowledge production override for this destructive command")
180
180
  .action((options) => {
181
- if (!(0, CliProductionGuards_1.ensureCliProductionOverride)("migrate:reset", {
181
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionOverride)("migrate:reset", {
182
182
  force: !!options.force,
183
183
  yes: !!options.yes,
184
184
  })) {
185
185
  return;
186
186
  }
187
- const connectionNames = (0, CliCommandTargets_1.resolveCliConnectionNames)(options);
188
- return (0, migrateReset_1.migrateReset)({
187
+ const connectionNames = (0, CliCommandTargets_js_1.resolveCliConnectionNames)(options);
188
+ return (0, migrateReset_js_1.migrateReset)({
189
189
  test: !!options.test,
190
190
  connectionNames,
191
191
  allMigrations: !!options.allMigrations,
@@ -1,4 +1,4 @@
1
- import { type CliActionErrorRenderer } from "./CliActionRuntime";
1
+ import { type CliActionErrorRenderer } from "./CliActionRuntime.js";
2
2
  export type CliProductionOverrideOptions = {
3
3
  force?: boolean;
4
4
  yes?: boolean;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ensureCliProductionOverride = ensureCliProductionOverride;
4
4
  exports.ensureCliProductionTestOnly = ensureCliProductionTestOnly;
5
- const ProductionSafety_1 = require("./ProductionSafety");
6
- const CliActionRuntime_1 = require("./CliActionRuntime");
7
- function ensureCliProductionOverride(commandName, options, renderError = CliActionRuntime_1.defaultCliActionErrorRenderer) {
8
- const verdict = (0, ProductionSafety_1.checkProductionDestructiveCommand)({
5
+ const ProductionSafety_js_1 = require("./ProductionSafety.js");
6
+ const CliActionRuntime_js_1 = require("./CliActionRuntime.js");
7
+ function ensureCliProductionOverride(commandName, options, renderError = CliActionRuntime_js_1.defaultCliActionErrorRenderer) {
8
+ const verdict = (0, ProductionSafety_js_1.checkProductionDestructiveCommand)({
9
9
  command: commandName,
10
10
  force: options.force === true,
11
11
  yes: options.yes === true,
@@ -18,8 +18,8 @@ function ensureCliProductionOverride(commandName, options, renderError = CliActi
18
18
  process.exitCode = 1;
19
19
  return false;
20
20
  }
21
- function ensureCliProductionTestOnly(commandName, options, renderError = CliActionRuntime_1.defaultCliActionErrorRenderer) {
22
- const verdict = (0, ProductionSafety_1.checkProductionTestOnlyCommand)({
21
+ function ensureCliProductionTestOnly(commandName, options, renderError = CliActionRuntime_js_1.defaultCliActionErrorRenderer) {
22
+ const verdict = (0, ProductionSafety_js_1.checkProductionTestOnlyCommand)({
23
23
  command: commandName,
24
24
  test: options.test === true,
25
25
  });
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerCliScaffoldCommands = registerCliScaffoldCommands;
4
- const makeModel_1 = require("../commands/makeModel");
5
- const makeController_1 = require("../commands/makeController");
6
- const makeService_1 = require("../commands/makeService");
7
- const makeRegistry_1 = require("../commands/makeRegistry");
8
- const CliProductionGuards_1 = require("./CliProductionGuards");
4
+ const makeModel_js_1 = require("../commands/makeModel.js");
5
+ const makeController_js_1 = require("../commands/makeController.js");
6
+ const makeService_js_1 = require("../commands/makeService.js");
7
+ const makeRegistry_js_1 = require("../commands/makeRegistry.js");
8
+ const CliProductionGuards_js_1 = require("./CliProductionGuards.js");
9
9
  function registerCliScaffoldCommands(program) {
10
10
  program
11
11
  .command("make:model <name>")
@@ -17,13 +17,13 @@ function registerCliScaffoldCommands(program) {
17
17
  .option("--yes", "Acknowledge production override for this destructive command")
18
18
  .description("Generate a new model (with optional migration)")
19
19
  .action(async (name, options) => {
20
- if (!(0, CliProductionGuards_1.ensureCliProductionOverride)("make:model", {
20
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionOverride)("make:model", {
21
21
  force: !!options.force,
22
22
  yes: !!options.yes,
23
23
  })) {
24
24
  return;
25
25
  }
26
- await (0, makeModel_1.makeModel)(name, {
26
+ await (0, makeModel_js_1.makeModel)(name, {
27
27
  ...options,
28
28
  test: !!options.test,
29
29
  mongo: !!options.mongo,
@@ -36,13 +36,13 @@ function registerCliScaffoldCommands(program) {
36
36
  .option("--yes", "Acknowledge production override for this destructive command")
37
37
  .description("Generate a registerModels bootstrap helper from discovered models")
38
38
  .action((options) => {
39
- if (!(0, CliProductionGuards_1.ensureCliProductionOverride)("make:registry", {
39
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionOverride)("make:registry", {
40
40
  force: !!options.force,
41
41
  yes: !!options.yes,
42
42
  })) {
43
43
  return;
44
44
  }
45
- return (0, makeRegistry_1.makeRegistry)({
45
+ return (0, makeRegistry_js_1.makeRegistry)({
46
46
  test: !!options.test,
47
47
  force: !!options.force,
48
48
  });
@@ -55,13 +55,13 @@ function registerCliScaffoldCommands(program) {
55
55
  .option("--yes", "Acknowledge production override for this destructive command")
56
56
  .description("Create a new controller (linked to service)")
57
57
  .action((name, options) => {
58
- if (!(0, CliProductionGuards_1.ensureCliProductionOverride)("make:controller", {
58
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionOverride)("make:controller", {
59
59
  force: !!options.force,
60
60
  yes: !!options.yes,
61
61
  })) {
62
62
  return;
63
63
  }
64
- return (0, makeController_1.makeController)(name, {
64
+ return (0, makeController_js_1.makeController)(name, {
65
65
  test: !!options.test,
66
66
  soft: !!options.soft,
67
67
  force: !!options.force,
@@ -74,13 +74,13 @@ function registerCliScaffoldCommands(program) {
74
74
  .option("--yes", "Acknowledge production override for this destructive command")
75
75
  .description("Create a new service (business logic layer)")
76
76
  .action((name, options) => {
77
- if (!(0, CliProductionGuards_1.ensureCliProductionOverride)("make:service", {
77
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionOverride)("make:service", {
78
78
  force: !!options.force,
79
79
  yes: !!options.yes,
80
80
  })) {
81
81
  return;
82
82
  }
83
- return (0, makeService_1.makeService)(name, {
83
+ return (0, makeService_js_1.makeService)(name, {
84
84
  test: !!options.test,
85
85
  force: !!options.force,
86
86
  });
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerCliSeedScenarioCommands = registerCliSeedScenarioCommands;
4
- const SeedBootstrapPrecheck_1 = require("./SeedBootstrapPrecheck");
5
- const dbSeed_1 = require("../commands/dbSeed");
6
- const dbSeedFresh_1 = require("../commands/dbSeedFresh");
7
- const demoScenario_1 = require("../commands/demoScenario");
8
- const dbSeedBootstrapPrecheck_1 = require("../commands/dbSeedBootstrapPrecheck");
9
- const CliProductionGuards_1 = require("./CliProductionGuards");
10
- const CliCommandTargets_1 = require("./CliCommandTargets");
11
- const CliActionRuntime_1 = require("./CliActionRuntime");
4
+ const SeedBootstrapPrecheck_js_1 = require("./SeedBootstrapPrecheck.js");
5
+ const dbSeed_js_1 = require("../commands/dbSeed.js");
6
+ const dbSeedFresh_js_1 = require("../commands/dbSeedFresh.js");
7
+ const demoScenario_js_1 = require("../commands/demoScenario.js");
8
+ const dbSeedBootstrapPrecheck_js_1 = require("../commands/dbSeedBootstrapPrecheck.js");
9
+ const CliProductionGuards_js_1 = require("./CliProductionGuards.js");
10
+ const CliCommandTargets_js_1 = require("./CliCommandTargets.js");
11
+ const CliActionRuntime_js_1 = require("./CliActionRuntime.js");
12
12
  function registerCliSeedScenarioCommands(program) {
13
13
  program
14
14
  .command("db:seed")
@@ -23,13 +23,13 @@ function registerCliSeedScenarioCommands(program) {
23
23
  .option("--no-hooks", "Disable model validation/lifecycle hooks during seeding")
24
24
  .description("Run database seeders (all or specific)")
25
25
  .action(async (options) => {
26
- return (0, CliActionRuntime_1.runCliAction)(async () => {
27
- if (!(0, CliProductionGuards_1.ensureCliProductionTestOnly)("db:seed", { test: !!options.test })) {
26
+ return (0, CliActionRuntime_js_1.runCliAction)(async () => {
27
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionTestOnly)("db:seed", { test: !!options.test })) {
28
28
  return;
29
29
  }
30
- const connectionNames = (0, CliCommandTargets_1.resolveCliConnectionNames)(options);
30
+ const connectionNames = (0, CliCommandTargets_js_1.resolveCliConnectionNames)(options);
31
31
  if (options.allConnections) {
32
- const cleanBootstrap = await (0, SeedBootstrapPrecheck_1.assertSeedBootstrapPrecheck)({
32
+ const cleanBootstrap = await (0, SeedBootstrapPrecheck_js_1.assertSeedBootstrapPrecheck)({
33
33
  test: !!options.test,
34
34
  connectionNames,
35
35
  });
@@ -37,7 +37,7 @@ function registerCliSeedScenarioCommands(program) {
37
37
  throw new Error("All-connections seed precheck failed. Run migrate:run (with optional --test) first, then retry db:seed.");
38
38
  }
39
39
  }
40
- await (0, dbSeed_1.dbSeed)({
40
+ await (0, dbSeed_js_1.dbSeed)({
41
41
  test: !!options.test,
42
42
  class: options.class,
43
43
  silent: !!options.silent,
@@ -56,9 +56,9 @@ function registerCliSeedScenarioCommands(program) {
56
56
  .option("--all-connections", "Check mysql, pg, and sqlite")
57
57
  .description("Validate migration bootstrap state before running db:seed")
58
58
  .action(async (options) => {
59
- return (0, CliActionRuntime_1.runCliAction)(async () => {
60
- const connectionNames = (0, CliCommandTargets_1.resolveCliConnectionNames)(options);
61
- await (0, dbSeedBootstrapPrecheck_1.dbSeedBootstrapPrecheck)({
59
+ return (0, CliActionRuntime_js_1.runCliAction)(async () => {
60
+ const connectionNames = (0, CliCommandTargets_js_1.resolveCliConnectionNames)(options);
61
+ await (0, dbSeedBootstrapPrecheck_js_1.dbSeedBootstrapPrecheck)({
62
62
  test: !!options.test,
63
63
  connectionNames,
64
64
  });
@@ -79,18 +79,18 @@ function registerCliSeedScenarioCommands(program) {
79
79
  .option("--yes", "Acknowledge production override for this destructive command")
80
80
  .description("Drop all tables, rerun migrations, and seed the database")
81
81
  .action(async (options) => {
82
- return (0, CliActionRuntime_1.runCliAction)(async () => {
83
- if (!(0, CliProductionGuards_1.ensureCliProductionTestOnly)("db:seed:fresh", { test: !!options.test })) {
82
+ return (0, CliActionRuntime_js_1.runCliAction)(async () => {
83
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionTestOnly)("db:seed:fresh", { test: !!options.test })) {
84
84
  return;
85
85
  }
86
- if (!(0, CliProductionGuards_1.ensureCliProductionOverride)("db:seed:fresh", {
86
+ if (!(0, CliProductionGuards_js_1.ensureCliProductionOverride)("db:seed:fresh", {
87
87
  force: !!options.force,
88
88
  yes: !!options.yes,
89
89
  })) {
90
90
  return;
91
91
  }
92
- const connectionNames = (0, CliCommandTargets_1.resolveCliConnectionNames)(options);
93
- await (0, dbSeedFresh_1.dbSeedFresh)({
92
+ const connectionNames = (0, CliCommandTargets_js_1.resolveCliConnectionNames)(options);
93
+ await (0, dbSeedFresh_js_1.dbSeedFresh)({
94
94
  test: !!options.test,
95
95
  class: options.class,
96
96
  force: !!options.force,
@@ -112,11 +112,11 @@ function registerCliSeedScenarioCommands(program) {
112
112
  .option("--mongo", "Run scenario only for the mongo connection")
113
113
  .action(async (options) => {
114
114
  const userId = options.user ? Number(options.user) : undefined;
115
- await (0, demoScenario_1.demoScenario)({
115
+ await (0, demoScenario_js_1.demoScenario)({
116
116
  user: Number.isFinite(userId) ? userId : undefined,
117
117
  random: !!options.random,
118
118
  test: !!options.test,
119
- connectionName: (0, CliCommandTargets_1.resolveCliPrimaryConnectionName)(options),
119
+ connectionName: (0, CliCommandTargets_js_1.resolveCliPrimaryConnectionName)(options),
120
120
  });
121
121
  });
122
122
  }
@@ -5,19 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.registerCliSupportCommands = registerCliSupportCommands;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const cacheClear_1 = require("../commands/cacheClear");
9
- const cacheStats_1 = require("../commands/cacheStats");
10
- const factoryStatus_1 = require("../commands/factoryStatus");
11
- const CliCommandCatalog_1 = require("./CliCommandCatalog");
8
+ const cacheClear_js_1 = require("../commands/cacheClear.js");
9
+ const cacheStats_js_1 = require("../commands/cacheStats.js");
10
+ const factoryStatus_js_1 = require("../commands/factoryStatus.js");
11
+ const CliCommandCatalog_js_1 = require("./CliCommandCatalog.js");
12
12
  function registerCliSupportCommands(program) {
13
13
  program
14
14
  .command("cache:clear")
15
15
  .description("Clear all ORM cache data and registry")
16
- .action(cacheClear_1.cacheClear);
16
+ .action(cacheClear_js_1.cacheClear);
17
17
  program
18
18
  .command("cache:stats")
19
19
  .description("Show current cache performance analytics")
20
- .action(cacheStats_1.cacheStats);
20
+ .action(cacheStats_js_1.cacheStats);
21
21
  program
22
22
  .command("factory:status")
23
23
  .option("--test", "Inspect factories from test environment")
@@ -30,7 +30,7 @@ function registerCliSupportCommands(program) {
30
30
  .option("--graph", "Display an ASCII diagram of model relationships")
31
31
  .description("Show all registered factories (model + pivot + relations)")
32
32
  .action(async (options) => {
33
- await (0, factoryStatus_1.factoryStatus)(options);
33
+ await (0, factoryStatus_js_1.factoryStatus)(options);
34
34
  });
35
35
  program
36
36
  .command("list")
@@ -38,6 +38,6 @@ function registerCliSupportCommands(program) {
38
38
  .action(() => {
39
39
  console.log(chalk_1.default.green("\nAvailable Commands:\n"));
40
40
  console.log(chalk_1.default.gray("Tip: use --test to run supported commands in test mode.\n"));
41
- console.table(CliCommandCatalog_1.CLI_COMMAND_CATALOG);
41
+ console.table(CliCommandCatalog_js_1.CLI_COMMAND_CATALOG);
42
42
  });
43
43
  }
@@ -1,3 +1,5 @@
1
+ declare function stripJsonComments(raw: string): string;
2
+ declare function readJsonFile<T>(filePath: string): T | null;
1
3
  export declare class ImportResolver {
2
4
  private static readonly PACKAGE_ROOT;
3
5
  private static readonly SOURCE_INDEX_PATH;
@@ -5,11 +7,18 @@ export declare class ImportResolver {
5
7
  private static readonly PACKAGE_NAME;
6
8
  private static readPackageName;
7
9
  private static usingInstalledPackage;
10
+ static usesNodeEsmRuntime(rootDir?: string): boolean;
11
+ static withRuntimeRelativeImportExtension(importPath: string, rootDir?: string): string;
8
12
  /**
9
13
  * Resolves correct relative import path for generated files
10
14
  * depending on whether it's in app/ or test/ mode.
11
15
  */
12
- static coreImportPath(isTest: boolean): string;
13
- static schemaImportPath(isTest: boolean): string;
14
- static publicApiImportPath(fromFilePath?: string): string;
16
+ static coreImportPath(isTest: boolean, rootDir?: string): string;
17
+ static schemaImportPath(isTest: boolean, rootDir?: string): string;
18
+ static publicApiImportPath(fromFilePath?: string, rootDir?: string): string;
15
19
  }
20
+ export declare const __importResolverInternals: {
21
+ stripJsonComments: typeof stripJsonComments;
22
+ readJsonFile: typeof readJsonFile;
23
+ };
24
+ export {};
@@ -3,9 +3,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ImportResolver = void 0;
6
+ exports.__importResolverInternals = exports.ImportResolver = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
+ function stripJsonComments(raw) {
10
+ return raw
11
+ .replace(/\/\*[\s\S]*?\*\//g, "")
12
+ .replace(/^\s*\/\/.*$/gm, "");
13
+ }
14
+ function readJsonFile(filePath) {
15
+ if (!fs_1.default.existsSync(filePath)) {
16
+ return null;
17
+ }
18
+ try {
19
+ const raw = fs_1.default.readFileSync(filePath, "utf8");
20
+ return JSON.parse(stripJsonComments(raw));
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ }
9
26
  class ImportResolver {
10
27
  static readPackageName() {
11
28
  const packageJsonPath = path_1.default.join(this.PACKAGE_ROOT, "package.json");
@@ -18,35 +35,73 @@ class ImportResolver {
18
35
  return this.FALLBACK_PACKAGE_NAME;
19
36
  }
20
37
  }
21
- static usingInstalledPackage() {
22
- return path_1.default.resolve(process.cwd()) !== this.PACKAGE_ROOT;
38
+ static usingInstalledPackage(rootDir = process.cwd()) {
39
+ return path_1.default.resolve(rootDir) !== this.PACKAGE_ROOT;
40
+ }
41
+ static usesNodeEsmRuntime(rootDir = process.cwd()) {
42
+ const packageJson = readJsonFile(path_1.default.join(rootDir, "package.json"));
43
+ const packageType = typeof packageJson?.type === "string" ? packageJson.type.trim() : "";
44
+ if (packageType === "module") {
45
+ return true;
46
+ }
47
+ const tsconfig = readJsonFile(path_1.default.join(rootDir, "tsconfig.json"));
48
+ const compilerOptions = tsconfig && typeof tsconfig === "object" ? tsconfig.compilerOptions : undefined;
49
+ const moduleName = typeof compilerOptions?.module === "string"
50
+ ? compilerOptions.module.trim().toLowerCase()
51
+ : "";
52
+ const moduleResolution = typeof compilerOptions?.moduleResolution === "string"
53
+ ? compilerOptions.moduleResolution.trim().toLowerCase()
54
+ : "";
55
+ return (moduleName === "nodenext" ||
56
+ moduleName === "node16" ||
57
+ moduleResolution === "nodenext" ||
58
+ moduleResolution === "node16");
59
+ }
60
+ static withRuntimeRelativeImportExtension(importPath, rootDir = process.cwd()) {
61
+ if (!this.usesNodeEsmRuntime(rootDir)) {
62
+ return importPath;
63
+ }
64
+ if (!importPath.startsWith(".")) {
65
+ return importPath;
66
+ }
67
+ if (/\.(?:[cm]?js|json)$/i.test(importPath)) {
68
+ return importPath;
69
+ }
70
+ return `${importPath}.js`;
23
71
  }
24
72
  /**
25
73
  * Resolves correct relative import path for generated files
26
74
  * depending on whether it's in app/ or test/ mode.
27
75
  */
28
- static coreImportPath(isTest) {
29
- if (this.usingInstalledPackage())
76
+ static coreImportPath(isTest, rootDir = process.cwd()) {
77
+ if (this.usingInstalledPackage(rootDir))
30
78
  return this.PACKAGE_NAME;
31
- return isTest ? "../../../core/model/BaseModel" : "../../core/model/BaseModel";
79
+ const importPath = isTest
80
+ ? "../../../core/model/BaseModel"
81
+ : "../../core/model/BaseModel";
82
+ return this.withRuntimeRelativeImportExtension(importPath, rootDir);
32
83
  }
33
- static schemaImportPath(isTest) {
34
- if (this.usingInstalledPackage())
84
+ static schemaImportPath(isTest, rootDir = process.cwd()) {
85
+ if (this.usingInstalledPackage(rootDir))
35
86
  return this.PACKAGE_NAME;
36
- return isTest ? "../../../core/schema/SchemaBlueprint" : "../../core/schema/SchemaBlueprint";
87
+ const importPath = isTest
88
+ ? "../../../core/schema/SchemaBlueprint"
89
+ : "../../core/schema/SchemaBlueprint";
90
+ return this.withRuntimeRelativeImportExtension(importPath, rootDir);
37
91
  }
38
- static publicApiImportPath(fromFilePath) {
39
- if (this.usingInstalledPackage())
92
+ static publicApiImportPath(fromFilePath, rootDir = process.cwd()) {
93
+ if (this.usingInstalledPackage(rootDir))
40
94
  return this.PACKAGE_NAME;
41
- if (!fromFilePath)
42
- return "../index";
95
+ if (!fromFilePath) {
96
+ return this.withRuntimeRelativeImportExtension("../index", rootDir);
97
+ }
43
98
  const relativePath = path_1.default
44
99
  .relative(path_1.default.dirname(path_1.default.resolve(fromFilePath)), this.SOURCE_INDEX_PATH)
45
100
  .replace(/\\/g, "/");
46
- if (relativePath.startsWith(".")) {
47
- return relativePath;
48
- }
49
- return `./${relativePath}`;
101
+ const importPath = relativePath.startsWith(".")
102
+ ? relativePath
103
+ : `./${relativePath}`;
104
+ return this.withRuntimeRelativeImportExtension(importPath, rootDir);
50
105
  }
51
106
  }
52
107
  exports.ImportResolver = ImportResolver;
@@ -54,3 +109,7 @@ ImportResolver.PACKAGE_ROOT = path_1.default.resolve(__dirname, "..", "..", ".."
54
109
  ImportResolver.SOURCE_INDEX_PATH = path_1.default.join(ImportResolver.PACKAGE_ROOT, "src", "index");
55
110
  ImportResolver.FALLBACK_PACKAGE_NAME = "@alpha.consultings/eloquent-orm.js";
56
111
  ImportResolver.PACKAGE_NAME = ImportResolver.readPackageName();
112
+ exports.__importResolverInternals = {
113
+ stripJsonComments,
114
+ readJsonFile,
115
+ };
@@ -1,4 +1,4 @@
1
- import type { RelationType } from "../../core/schema/SchemaBlueprint";
1
+ import type { RelationType } from "../../core/schema/SchemaBlueprint.js";
2
2
  export interface IntrospectedField {
3
3
  name: string;
4
4
  type: string;