@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.
- package/CHANGELOG.md +17 -0
- package/PACKAGE-UPDATE-SUMMARY.md +18 -11
- package/README.md +5 -5
- package/dist/Model.d.ts +1 -1
- package/dist/Model.js +3 -3
- package/dist/cli/commands/cacheClear.js +12 -12
- package/dist/cli/commands/cacheStats.js +12 -12
- package/dist/cli/commands/dbSeed.d.ts +1 -1
- package/dist/cli/commands/dbSeed.js +23 -23
- package/dist/cli/commands/dbSeedBootstrapPrecheck.d.ts +1 -1
- package/dist/cli/commands/dbSeedBootstrapPrecheck.js +2 -2
- package/dist/cli/commands/dbSeedFresh.d.ts +1 -1
- package/dist/cli/commands/dbSeedFresh.js +10 -10
- package/dist/cli/commands/demoScenario.js +11 -11
- package/dist/cli/commands/factoryStatus.js +13 -13
- package/dist/cli/commands/makeController.js +11 -11
- package/dist/cli/commands/makeFactory.js +21 -21
- package/dist/cli/commands/makeMigration.d.ts +1 -1
- package/dist/cli/commands/makeMigration.js +31 -17
- package/dist/cli/commands/makeModel.js +30 -30
- package/dist/cli/commands/makeRegistry.d.ts +5 -8
- package/dist/cli/commands/makeRegistry.js +18 -68
- package/dist/cli/commands/makeScenario.js +49 -43
- package/dist/cli/commands/makeSeed.js +12 -9
- package/dist/cli/commands/makeService.js +10 -10
- package/dist/cli/commands/migrateFresh.d.ts +1 -1
- package/dist/cli/commands/migrateFresh.js +14 -14
- package/dist/cli/commands/migrateReset.d.ts +1 -1
- package/dist/cli/commands/migrateReset.js +4 -4
- package/dist/cli/commands/migrateRollback.d.ts +1 -1
- package/dist/cli/commands/migrateRollback.js +36 -36
- package/dist/cli/commands/migrateRun.d.ts +2 -2
- package/dist/cli/commands/migrateRun.js +34 -34
- package/dist/cli/commands/migrateStatus.d.ts +1 -1
- package/dist/cli/commands/migrateStatus.js +16 -16
- package/dist/cli/eloquent.d.ts +1 -1
- package/dist/cli/eloquent.js +30 -30
- package/dist/cli/utils/ArtifactRoutingReport.d.ts +1 -1
- package/dist/cli/utils/ArtifactRoutingReport.js +3 -3
- package/dist/cli/utils/ArtifactStorage.d.ts +2 -2
- package/dist/cli/utils/ArtifactStorage.js +17 -17
- package/dist/cli/utils/AuditTrail.js +2 -2
- package/dist/cli/utils/CliBootstrapSupport.d.ts +1 -1
- package/dist/cli/utils/CliCommandTargets.d.ts +2 -2
- package/dist/cli/utils/CliCommandTargets.js +2 -2
- package/dist/cli/utils/CliMakeArtifactCommandRegistration.js +15 -15
- package/dist/cli/utils/CliMigrationCommandRegistration.js +29 -29
- package/dist/cli/utils/CliProductionGuards.d.ts +1 -1
- package/dist/cli/utils/CliProductionGuards.js +6 -6
- package/dist/cli/utils/CliScaffoldCommandRegistration.js +13 -13
- package/dist/cli/utils/CliSeedScenarioCommandRegistration.js +23 -23
- package/dist/cli/utils/CliSupportCommandRegistration.js +8 -8
- package/dist/cli/utils/ImportResolver.d.ts +12 -3
- package/dist/cli/utils/ImportResolver.js +76 -17
- package/dist/cli/utils/ModelIntrospector.d.ts +1 -1
- package/dist/cli/utils/ModelIntrospector.js +4 -4
- package/dist/cli/utils/ScaffoldGeneratorSupport.js +2 -2
- package/dist/cli/utils/ScenarioMorphAliasRouting.js +8 -8
- package/dist/cli/utils/SeedBootstrapPrecheck.d.ts +1 -1
- package/dist/cli/utils/SeedBootstrapPrecheck.js +10 -10
- package/dist/cli/utils/TemplateEngine.js +2 -2
- package/dist/cli/utils/factories/Factory.d.ts +1 -1
- package/dist/cli/utils/factories/FactoryDisplay.d.ts +1 -1
- package/dist/cli/utils/factories/FactoryGraph.js +5 -5
- package/dist/cli/utils/factories/FactoryLoader.d.ts +1 -1
- package/dist/cli/utils/factories/FactoryLoader.js +4 -4
- package/dist/cli/utils/factories/FactoryRegistry.d.ts +3 -3
- package/dist/cli/utils/factories/FactoryRegistry.js +10 -10
- package/dist/cli/utils/migrations/MigrationLockStrategy.d.ts +1 -1
- package/dist/cli/utils/migrations/MigrationLockStrategy.js +2 -2
- package/dist/cli/utils/migrations/MigrationTracker.d.ts +2 -2
- package/dist/cli/utils/migrations/MigrationTracker.js +6 -6
- package/dist/cli/utils/migrations/MongoMigrationTracker.js +3 -3
- package/dist/cli/utils/resolveConnectionFlags.d.ts +1 -1
- package/dist/cli/utils/resolveConnectionFlags.js +3 -3
- package/dist/cli/utils/resolveSqlConnectionFlags.d.ts +1 -1
- package/dist/cli/utils/typescript/BaseCommand.d.ts +1 -1
- package/dist/cli/utils/typescript/BaseCommand.js +3 -3
- package/dist/cli/utils/typescript/tsRuntime.js +62 -9
- package/dist/config/database.js +9 -9
- package/dist/core/cache/CacheFallbackManager.d.ts +1 -1
- package/dist/core/cache/CacheManager.d.ts +1 -1
- package/dist/core/cache/CacheManager.js +2 -2
- package/dist/core/cache/CacheRegistry.js +4 -4
- package/dist/core/cache/drivers/FileCacheDriver.d.ts +1 -1
- package/dist/core/cache/drivers/FileCacheDriver.js +2 -2
- package/dist/core/cache/drivers/MemcachedCacheDriver.d.ts +1 -1
- package/dist/core/cache/drivers/MemcachedCacheDriver.js +2 -2
- package/dist/core/cache/drivers/MemoryCacheDriver.d.ts +1 -1
- package/dist/core/cache/drivers/MemoryCacheDriver.js +2 -2
- package/dist/core/cache/setupCache.js +12 -12
- package/dist/core/connection/ConnectionFactory.d.ts +2 -2
- package/dist/core/connection/ConnectionFactory.js +9 -9
- package/dist/core/connection/DatabaseConnection.d.ts +2 -2
- package/dist/core/connection/DatabaseConnection.js +4 -4
- package/dist/core/connection/DriverAdapter.d.ts +1 -1
- package/dist/core/connection/DriverAdapter.js +2 -2
- package/dist/core/connection/resolveConnectionName.d.ts +1 -1
- package/dist/core/connection/resolveConnectionName.js +7 -7
- package/dist/core/model/BaseModel.d.ts +29 -29
- package/dist/core/model/BaseModel.js +38 -38
- package/dist/core/model/BaseModelSafeFinderStatics.d.ts +1 -1
- package/dist/core/model/BaseModelSafeFinderStatics.js +19 -19
- package/dist/core/model/CoreModel.d.ts +4 -4
- package/dist/core/model/CoreModel.js +28 -28
- package/dist/core/model/CoreModelPersistenceState.d.ts +1 -1
- package/dist/core/model/CoreModelSafeFinderSupport.d.ts +2 -2
- package/dist/core/model/CoreModelSafeFinderSupport.js +2 -2
- package/dist/core/model/CoreModelValidationEvents.d.ts +2 -2
- package/dist/core/model/CoreModelValidationEvents.js +2 -2
- package/dist/core/model/SafeFinder.d.ts +1 -1
- package/dist/core/model/SafeFinder.js +2 -2
- package/dist/core/orm/mixins/CastsMixin.js +2 -2
- package/dist/core/orm/mixins/HooksMixin.js +8 -8
- package/dist/core/orm/mixins/MorphableMixin.js +4 -4
- package/dist/core/orm/mixins/PivotHelperMixin.js +3 -3
- package/dist/core/orm/mixins/QueryCacheMixin.js +20 -20
- package/dist/core/orm/mixins/ScopeMixin.js +2 -2
- package/dist/core/orm/mixins/SoftDeletesMixin.js +2 -2
- package/dist/core/orm/mixins/utils/HookStore.d.ts +1 -1
- package/dist/core/orm/mixins/utils/HookStore.js +2 -2
- package/dist/core/orm/mixins/utils/modelRegistration.d.ts +1 -1
- package/dist/core/orm/mixins/utils/modelRegistration.js +6 -6
- package/dist/core/orm/relations/BelongsTo.d.ts +1 -1
- package/dist/core/orm/relations/BelongsTo.js +2 -2
- package/dist/core/orm/relations/BelongsToMany.d.ts +1 -1
- package/dist/core/orm/relations/BelongsToMany.js +2 -2
- package/dist/core/orm/relations/HasMany.d.ts +1 -1
- package/dist/core/orm/relations/HasMany.js +2 -2
- package/dist/core/orm/relations/HasOne.d.ts +1 -1
- package/dist/core/orm/relations/HasOne.js +2 -2
- package/dist/core/orm/relations/MorphMany.d.ts +1 -1
- package/dist/core/orm/relations/MorphMany.js +2 -2
- package/dist/core/orm/relations/MorphOne.d.ts +1 -1
- package/dist/core/orm/relations/MorphOne.js +2 -2
- package/dist/core/orm/relations/MorphTo.d.ts +1 -1
- package/dist/core/orm/relations/MorphTo.js +5 -5
- package/dist/core/schema/SchemaBuilder.d.ts +2 -2
- package/dist/core/schema/SchemaBuilder.js +9 -9
- package/dist/core/schema/SchemaValidator.d.ts +1 -1
- package/dist/core/security/AbstractSecurity.d.ts +1 -1
- package/dist/core/security/EnvKeySecurity.d.ts +1 -1
- package/dist/core/security/EnvKeySecurity.js +2 -2
- package/dist/core/security/NoSecurity.d.ts +1 -1
- package/dist/core/security/NoSecurity.js +2 -2
- package/dist/core/security/SecurityFactory.d.ts +1 -1
- package/dist/core/security/SecurityFactory.js +4 -4
- package/dist/core/security/index.d.ts +5 -5
- package/dist/core/security/index.js +5 -5
- package/dist/index.d.ts +10 -10
- package/dist/index.js +30 -30
- package/esm/Factory.mjs +113 -136
- package/esm/Model.mjs +4 -0
- package/esm/index.mjs +23 -28
- package/package.json +14 -5
- package/src/cli/templates/factory.tpl +1 -1
- package/src/cli/templates/seed.tpl +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [1.0.11](https://github.com/MetalDz/Eloquent-ORM.js/compare/v1.0.10...v1.0.11) (2026-04-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* align cjs factory patch with nodenext dist emit ([8f49d00](https://github.com/MetalDz/Eloquent-ORM.js/commit/8f49d005f3fc837124650395514f9958f214b99f))
|
|
7
|
+
* emit nodenext-safe imports from generators ([2d93aef](https://github.com/MetalDz/Eloquent-ORM.js/commit/2d93aefe81d8695a5d9a6d126d78cdbcea58d032))
|
|
8
|
+
* make nodenext blocker inventory deterministic across ci and local ([ce55188](https://github.com/MetalDz/Eloquent-ORM.js/commit/ce55188f96272a28ccb3f6849df74a82ea43a143))
|
|
9
|
+
|
|
10
|
+
## [1.0.10](https://github.com/MetalDz/Eloquent-ORM.js/compare/v1.0.9...v1.0.10) (2026-03-29)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* make latest release summary mdx-safe for docs lint ([a4149bd](https://github.com/MetalDz/Eloquent-ORM.js/commit/a4149bd672972ed952c2e1d7d4092214d64ca058))
|
|
16
|
+
* support nodenext local ts imports in cli ts runtime ([27d383e](https://github.com/MetalDz/Eloquent-ORM.js/commit/27d383e547034d5ab1978872af167e15abe36376))
|
|
17
|
+
|
|
1
18
|
## [1.0.9](https://github.com/MetalDz/Eloquent-ORM.js/compare/v1.0.8...v1.0.9) (2026-03-28)
|
|
2
19
|
|
|
3
20
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Package Update Summary
|
|
2
2
|
|
|
3
|
-
Version: `1.0.
|
|
3
|
+
Version: `1.0.11`
|
|
4
4
|
|
|
5
5
|
This file is the source of truth for the release-focused quick info block that appears in `README.md`.
|
|
6
6
|
|
|
@@ -14,16 +14,22 @@ npm run docs:sync-package-metadata
|
|
|
14
14
|
|
|
15
15
|
<!-- release-lineup:start -->
|
|
16
16
|
Latest Release:
|
|
17
|
-
- `v1.0.
|
|
17
|
+
- `v1.0.11 latest`
|
|
18
18
|
|
|
19
19
|
Old Release:
|
|
20
|
-
- `v1.0.
|
|
20
|
+
- `v1.0.10`
|
|
21
21
|
<!-- release-lineup:end -->
|
|
22
22
|
|
|
23
|
+
## Latest Release Headline
|
|
24
|
+
|
|
25
|
+
<!-- latest-package-headline:start -->
|
|
26
|
+
- Patched. The published ESM surface now builds from dedicated TypeScript entrypoints, keeping CommonJS stable and removing wrapper-generation drift.
|
|
27
|
+
<!-- latest-package-headline:end -->
|
|
28
|
+
|
|
23
29
|
## Latest Release Summary
|
|
24
30
|
|
|
25
31
|
<!-- latest-package-update:start -->
|
|
26
|
-
-
|
|
32
|
+
- Replace the generated ESM wrapper script with a true TypeScript ESM build pipeline, compiling dedicated `esm-src/*.mts` entrypoints into the published `esm/*` surface while preserving the CommonJS `dist/*` runtime contract.
|
|
27
33
|
<!-- latest-package-update:end -->
|
|
28
34
|
|
|
29
35
|
## Synced Quick Info
|
|
@@ -31,11 +37,11 @@ Old Release:
|
|
|
31
37
|
<!-- package-quick-info:start -->
|
|
32
38
|
Quick info:
|
|
33
39
|
- Package: `@alpha.consultings/eloquent-orm.js`
|
|
34
|
-
- Version: `v1.0.
|
|
35
|
-
- Latest release: `v1.0.
|
|
36
|
-
- What's new:
|
|
37
|
-
- Old release: `v1.0.
|
|
38
|
-
- Latest update:
|
|
40
|
+
- Version: `v1.0.11`
|
|
41
|
+
- Latest release: `v1.0.11 latest`
|
|
42
|
+
- What's new: [Patched. The published ESM surface now builds from dedicated TypeScript entrypoints, keeping CommonJS stable and removing wrapper-generation drift.](https://alphaconsultings.mintlify.app/release/latest-release-summary)
|
|
43
|
+
- Old release: `v1.0.10`
|
|
44
|
+
- Latest update: Replace the generated ESM wrapper script with a true TypeScript ESM build pipeline, compiling dedicated `esm-src/*.mts` entrypoints into the published `esm/*` surface while preserving the CommonJS `dist/*` runtime contract.
|
|
39
45
|
- Official docs: https://alphaconsultings.mintlify.app
|
|
40
46
|
- Quick start: https://alphaconsultings.mintlify.app/getting-started/quick-start
|
|
41
47
|
- Release history: https://alphaconsultings.mintlify.app/release/history
|
|
@@ -44,6 +50,7 @@ Quick info:
|
|
|
44
50
|
|
|
45
51
|
## Update Rule
|
|
46
52
|
|
|
53
|
+
- Refresh the `latest-package-headline` summary on every fix, minor, or major release.
|
|
47
54
|
- Refresh the `latest-package-update` summary on every fix, minor, or major release.
|
|
48
|
-
- Keep the
|
|
49
|
-
- Let the sync script refresh package name, version, docs URL, and
|
|
55
|
+
- Keep the headline short and linkable, and keep the detailed update exact and release-specific.
|
|
56
|
+
- Let the sync script refresh package name, version, docs URL, README output, and the latest release summary docs page.
|
package/README.md
CHANGED
|
@@ -17,11 +17,11 @@ Laravel-inspired ORM + CLI for Node.js + TypeScript with SQL and MongoDB runtime
|
|
|
17
17
|
<!-- package-quick-info:start -->
|
|
18
18
|
Quick info:
|
|
19
19
|
- Package: `@alpha.consultings/eloquent-orm.js`
|
|
20
|
-
- Version: `v1.0.
|
|
21
|
-
- Latest release: `v1.0.
|
|
22
|
-
- What's new:
|
|
23
|
-
- Old release: `v1.0.
|
|
24
|
-
- Latest update:
|
|
20
|
+
- Version: `v1.0.11`
|
|
21
|
+
- Latest release: `v1.0.11 latest`
|
|
22
|
+
- What's new: [Patched. The published ESM surface now builds from dedicated TypeScript entrypoints, keeping CommonJS stable and removing wrapper-generation drift.](https://alphaconsultings.mintlify.app/release/latest-release-summary)
|
|
23
|
+
- Old release: `v1.0.10`
|
|
24
|
+
- Latest update: Replace the generated ESM wrapper script with a true TypeScript ESM build pipeline, compiling dedicated `esm-src/*.mts` entrypoints into the published `esm/*` surface while preserving the CommonJS `dist/*` runtime contract.
|
|
25
25
|
- Official docs: https://alphaconsultings.mintlify.app
|
|
26
26
|
- Quick start: https://alphaconsultings.mintlify.app/getting-started/quick-start
|
|
27
27
|
- Release history: https://alphaconsultings.mintlify.app/release/history
|
package/dist/Model.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { SqlModel, MongoModel, type ModelAttrs, type ModelInstance, } from "./core/model/BaseModel";
|
|
1
|
+
export { SqlModel, MongoModel, type ModelAttrs, type ModelInstance, } from "./core/model/BaseModel.js";
|
package/dist/Model.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MongoModel = exports.SqlModel = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "SqlModel", { enumerable: true, get: function () { return
|
|
6
|
-
Object.defineProperty(exports, "MongoModel", { enumerable: true, get: function () { return
|
|
4
|
+
var BaseModel_js_1 = require("./core/model/BaseModel.js");
|
|
5
|
+
Object.defineProperty(exports, "SqlModel", { enumerable: true, get: function () { return BaseModel_js_1.SqlModel; } });
|
|
6
|
+
Object.defineProperty(exports, "MongoModel", { enumerable: true, get: function () { return BaseModel_js_1.MongoModel; } });
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cacheClear = cacheClear;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
4
|
+
const CacheRegistry_js_1 = require("../../core/cache/CacheRegistry.js");
|
|
5
|
+
const CacheAnalytics_js_1 = require("../../core/cache/CacheAnalytics.js");
|
|
6
|
+
const CacheFallbackManager_js_1 = require("../../core/cache/CacheFallbackManager.js");
|
|
7
|
+
const setupCache_js_1 = require("../../core/cache/setupCache.js");
|
|
8
8
|
async function cacheClear() {
|
|
9
|
-
(0,
|
|
10
|
-
const before =
|
|
9
|
+
(0, setupCache_js_1.setupCache)();
|
|
10
|
+
const before = CacheRegistry_js_1.CacheRegistry.getStats();
|
|
11
11
|
const errors = [];
|
|
12
|
-
const fallbackDrivers =
|
|
12
|
+
const fallbackDrivers = CacheFallbackManager_js_1.CacheFallbackManager.getDrivers();
|
|
13
13
|
try {
|
|
14
|
-
await
|
|
14
|
+
await CacheRegistry_js_1.CacheRegistry.clearAll();
|
|
15
15
|
}
|
|
16
16
|
catch (err) {
|
|
17
17
|
errors.push(`CacheManager clear failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -20,20 +20,20 @@ async function cacheClear() {
|
|
|
20
20
|
let fallbackShutdownResults = [];
|
|
21
21
|
if (fallbackDrivers.length > 0) {
|
|
22
22
|
try {
|
|
23
|
-
fallbackClearResults = await
|
|
23
|
+
fallbackClearResults = await CacheFallbackManager_js_1.CacheFallbackManager.clearAllDrivers();
|
|
24
24
|
}
|
|
25
25
|
catch (err) {
|
|
26
26
|
errors.push(`Fallback clear failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
27
27
|
}
|
|
28
28
|
try {
|
|
29
|
-
fallbackShutdownResults = await
|
|
29
|
+
fallbackShutdownResults = await CacheFallbackManager_js_1.CacheFallbackManager.shutdownDrivers();
|
|
30
30
|
}
|
|
31
31
|
catch (err) {
|
|
32
32
|
errors.push(`Fallback shutdown failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
const after =
|
|
35
|
+
CacheAnalytics_js_1.CacheAnalytics.reset();
|
|
36
|
+
const after = CacheRegistry_js_1.CacheRegistry.getStats();
|
|
37
37
|
console.log("cache:clear");
|
|
38
38
|
console.log(` registry keys: ${before.keys} -> ${after.keys}`);
|
|
39
39
|
console.log(` registry groups: ${before.groups} -> ${after.groups}`);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cacheStats = cacheStats;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
const CacheManager_js_1 = require("../../core/cache/CacheManager.js");
|
|
5
|
+
const CacheRegistry_js_1 = require("../../core/cache/CacheRegistry.js");
|
|
6
|
+
const CacheAnalytics_js_1 = require("../../core/cache/CacheAnalytics.js");
|
|
7
|
+
const CacheFallbackManager_js_1 = require("../../core/cache/CacheFallbackManager.js");
|
|
8
|
+
const setupCache_js_1 = require("../../core/cache/setupCache.js");
|
|
9
9
|
function ratioPercent(hits, misses) {
|
|
10
10
|
const total = hits + misses;
|
|
11
11
|
if (total === 0)
|
|
@@ -13,12 +13,12 @@ function ratioPercent(hits, misses) {
|
|
|
13
13
|
return `${((hits / total) * 100).toFixed(2)}%`;
|
|
14
14
|
}
|
|
15
15
|
async function cacheStats() {
|
|
16
|
-
(0,
|
|
17
|
-
const driver =
|
|
18
|
-
const fallbackActive =
|
|
19
|
-
const fallbackDrivers =
|
|
20
|
-
const registry =
|
|
21
|
-
const analyticsRows =
|
|
16
|
+
(0, setupCache_js_1.setupCache)();
|
|
17
|
+
const driver = CacheManager_js_1.CacheManager.getDriver();
|
|
18
|
+
const fallbackActive = CacheFallbackManager_js_1.CacheFallbackManager.getActiveDriver();
|
|
19
|
+
const fallbackDrivers = CacheFallbackManager_js_1.CacheFallbackManager.getDrivers();
|
|
20
|
+
const registry = CacheRegistry_js_1.CacheRegistry.getStats();
|
|
21
|
+
const analyticsRows = CacheAnalytics_js_1.CacheAnalytics.getStats();
|
|
22
22
|
const totalHits = analyticsRows.reduce((sum, row) => sum + row.hits, 0);
|
|
23
23
|
const totalMisses = analyticsRows.reduce((sum, row) => sum + row.misses, 0);
|
|
24
24
|
console.log("cache:stats");
|
|
@@ -45,7 +45,7 @@ async function cacheStats() {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
if (fallbackDrivers.length > 0) {
|
|
48
|
-
const shutdownResults = await
|
|
48
|
+
const shutdownResults = await CacheFallbackManager_js_1.CacheFallbackManager.shutdownDrivers();
|
|
49
49
|
const shutdownSummary = shutdownResults
|
|
50
50
|
.map((r) => `${r.driver}:${r.closed ? "closed" : "open"}`)
|
|
51
51
|
.join(", ");
|
|
@@ -7,15 +7,15 @@ exports.dbSeed = dbSeed;
|
|
|
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
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
10
|
+
const PathMap_js_1 = require("../utils/PathMap.js");
|
|
11
|
+
const tsRuntime_js_1 = require("../utils/typescript/tsRuntime.js");
|
|
12
|
+
const ConnectionFactory_js_1 = require("../../core/connection/ConnectionFactory.js");
|
|
13
|
+
const resolveConnectionName_js_1 = require("../../core/connection/resolveConnectionName.js");
|
|
14
|
+
const AuditTrail_js_1 = require("../utils/AuditTrail.js");
|
|
15
|
+
const ConsoleSilencer_js_1 = require("../utils/ConsoleSilencer.js");
|
|
16
|
+
const ArtifactStorage_js_1 = require("../utils/ArtifactStorage.js");
|
|
17
|
+
const ArtifactCompatibility_js_1 = require("../utils/ArtifactCompatibility.js");
|
|
18
|
+
const ArtifactRoutingReport_js_1 = require("../utils/ArtifactRoutingReport.js");
|
|
19
19
|
/**
|
|
20
20
|
* db:seed
|
|
21
21
|
* Runs all seeders (or a specific seeder) in /database/seeds
|
|
@@ -27,12 +27,12 @@ async function dbSeed(options) {
|
|
|
27
27
|
const originalConnection = process.env[envKey];
|
|
28
28
|
const originalDbConnection = process.env.DB_CONNECTION;
|
|
29
29
|
const originalHooksDisabled = process.env.ELOQUENT_DISABLE_MODEL_HOOKS;
|
|
30
|
-
const restoreConsole = (0,
|
|
30
|
+
const restoreConsole = (0, ConsoleSilencer_js_1.silenceConsoleOutput)(!!options?.silent);
|
|
31
31
|
try {
|
|
32
32
|
if (options?.noHooks) {
|
|
33
33
|
process.env.ELOQUENT_DISABLE_MODEL_HOOKS = "true";
|
|
34
34
|
}
|
|
35
|
-
const seedsDir =
|
|
35
|
+
const seedsDir = PathMap_js_1.PathMap.seeds(isTest);
|
|
36
36
|
if (!fs_1.default.existsSync(seedsDir)) {
|
|
37
37
|
console.log(chalk_1.default.yellow(`No seed directory found: ${seedsDir}`));
|
|
38
38
|
return;
|
|
@@ -47,7 +47,7 @@ async function dbSeed(options) {
|
|
|
47
47
|
console.log(chalk_1.default.cyanBright(`\nRunning database seeders...\n`));
|
|
48
48
|
const connectionNames = options.connectionNames && options.connectionNames.length > 0
|
|
49
49
|
? options.connectionNames
|
|
50
|
-
: [(0,
|
|
50
|
+
: [(0, resolveConnectionName_js_1.resolveConnectionName)(undefined, { test: isTest })];
|
|
51
51
|
for (const connectionName of connectionNames) {
|
|
52
52
|
process.env[envKey] = connectionName;
|
|
53
53
|
if (isTest) {
|
|
@@ -56,10 +56,10 @@ async function dbSeed(options) {
|
|
|
56
56
|
}
|
|
57
57
|
console.log(chalk_1.default.gray(`Seeding connection: ${connectionName}`));
|
|
58
58
|
let connectionFailed = false;
|
|
59
|
-
const targetStorageKind = (0,
|
|
60
|
-
const routingDecisions = allSeedFiles.map((file) => (0,
|
|
59
|
+
const targetStorageKind = (0, ArtifactStorage_js_1.targetStorageKindForConnection)(connectionName);
|
|
60
|
+
const routingDecisions = allSeedFiles.map((file) => (0, ArtifactRoutingReport_js_1.createTargetedArtifactDecision)(file, (0, ArtifactStorage_js_1.resolveSeederStorageKindFromFile)(path_1.default.join(seedsDir, file), isTest), targetStorageKind));
|
|
61
61
|
const seedFiles = routingDecisions
|
|
62
|
-
.filter((decision) => (0,
|
|
62
|
+
.filter((decision) => (0, ArtifactStorage_js_1.matchesTargetStorageKind)(decision.kind, targetStorageKind))
|
|
63
63
|
.map((decision) => decision.name);
|
|
64
64
|
const skippedSeeders = routingDecisions.filter((decision) => !decision.matches);
|
|
65
65
|
// Run a specific seeder if requested
|
|
@@ -69,13 +69,13 @@ async function dbSeed(options) {
|
|
|
69
69
|
const incompatibleTarget = allSeedFiles.find((f) => f.toLowerCase().includes(className));
|
|
70
70
|
if (!target) {
|
|
71
71
|
if (incompatibleTarget) {
|
|
72
|
-
const incompatibleKind = (0,
|
|
73
|
-
console.log(chalk_1.default.red(`Seeder '${options.class}' is not compatible with ${targetStorageKind} connection '${connectionName}' (${(0,
|
|
72
|
+
const incompatibleKind = (0, ArtifactStorage_js_1.resolveSeederStorageKindFromFile)(path_1.default.join(seedsDir, incompatibleTarget), isTest);
|
|
73
|
+
console.log(chalk_1.default.red(`Seeder '${options.class}' is not compatible with ${targetStorageKind} connection '${connectionName}' (${(0, ArtifactCompatibility_js_1.describeArtifactCompatibilityMismatch)(incompatibleKind, targetStorageKind)}).`));
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
76
|
console.log(chalk_1.default.red(`Seeder '${options.class}' not found.`));
|
|
77
77
|
}
|
|
78
|
-
(0,
|
|
78
|
+
(0, AuditTrail_js_1.appendAuditEvent)({
|
|
79
79
|
command: options.auditCommand ?? "db:seed",
|
|
80
80
|
connectionName,
|
|
81
81
|
test: isTest,
|
|
@@ -98,7 +98,7 @@ async function dbSeed(options) {
|
|
|
98
98
|
throw error;
|
|
99
99
|
}
|
|
100
100
|
finally {
|
|
101
|
-
(0,
|
|
101
|
+
(0, AuditTrail_js_1.appendAuditEvent)({
|
|
102
102
|
command: options.auditCommand ?? "db:seed",
|
|
103
103
|
connectionName,
|
|
104
104
|
test: isTest,
|
|
@@ -114,7 +114,7 @@ async function dbSeed(options) {
|
|
|
114
114
|
try {
|
|
115
115
|
if (seedFiles.length === 0) {
|
|
116
116
|
// When no compatible seeders remain, every discovered seeder was skipped.
|
|
117
|
-
console.log(chalk_1.default.yellow((0,
|
|
117
|
+
console.log(chalk_1.default.yellow((0, ArtifactRoutingReport_js_1.summarizeSkippedArtifacts)("seeder", skippedSeeders, targetStorageKind)));
|
|
118
118
|
console.log(chalk_1.default.yellow(`No compatible seeder files found for ${connectionName}.`));
|
|
119
119
|
continue;
|
|
120
120
|
}
|
|
@@ -128,7 +128,7 @@ async function dbSeed(options) {
|
|
|
128
128
|
throw error;
|
|
129
129
|
}
|
|
130
130
|
finally {
|
|
131
|
-
(0,
|
|
131
|
+
(0, AuditTrail_js_1.appendAuditEvent)({
|
|
132
132
|
command: options.auditCommand ?? "db:seed",
|
|
133
133
|
connectionName,
|
|
134
134
|
test: isTest,
|
|
@@ -161,7 +161,7 @@ async function dbSeed(options) {
|
|
|
161
161
|
}
|
|
162
162
|
try {
|
|
163
163
|
if (options?.close !== false) {
|
|
164
|
-
await (0,
|
|
164
|
+
await (0, ConnectionFactory_js_1.closeAllConnections)();
|
|
165
165
|
if (!options?.silent) {
|
|
166
166
|
console.log(chalk_1.default.gray("All database connections closed.\n"));
|
|
167
167
|
}
|
|
@@ -182,7 +182,7 @@ async function dbSeed(options) {
|
|
|
182
182
|
* Dynamically imports and executes seeder function
|
|
183
183
|
*/
|
|
184
184
|
async function runSeederFile(filePath) {
|
|
185
|
-
const module = (0,
|
|
185
|
+
const module = (0, tsRuntime_js_1.loadModule)(filePath);
|
|
186
186
|
// Find exported seeder function (ends with "Seeder")
|
|
187
187
|
const seederFn = Object.entries(module).find(([key]) => key.endsWith("Seeder"));
|
|
188
188
|
if (!seederFn) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type SeedBootstrapPrecheckOptions } from "../utils/SeedBootstrapPrecheck";
|
|
1
|
+
import { type SeedBootstrapPrecheckOptions } from "../utils/SeedBootstrapPrecheck.js";
|
|
2
2
|
export declare function dbSeedBootstrapPrecheck(options?: SeedBootstrapPrecheckOptions): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dbSeedBootstrapPrecheck = dbSeedBootstrapPrecheck;
|
|
4
|
-
const
|
|
4
|
+
const SeedBootstrapPrecheck_js_1 = require("../utils/SeedBootstrapPrecheck.js");
|
|
5
5
|
async function dbSeedBootstrapPrecheck(options = {}) {
|
|
6
|
-
await (0,
|
|
6
|
+
await (0, SeedBootstrapPrecheck_js_1.assertSeedBootstrapPrecheck)(options);
|
|
7
7
|
}
|
|
@@ -5,17 +5,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.dbSeedFresh = dbSeedFresh;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
8
|
+
const migrateFresh_js_1 = require("./migrateFresh.js");
|
|
9
|
+
const dbSeed_js_1 = require("./dbSeed.js");
|
|
10
|
+
const ConnectionFactory_js_1 = require("../../core/connection/ConnectionFactory.js");
|
|
11
|
+
const resolveConnectionName_js_1 = require("../../core/connection/resolveConnectionName.js");
|
|
12
|
+
const ConsoleSilencer_js_1 = require("../utils/ConsoleSilencer.js");
|
|
13
13
|
/**
|
|
14
14
|
* db:seed:fresh
|
|
15
15
|
* Drops all tables, re-runs migrations, and executes seeders.
|
|
16
16
|
*/
|
|
17
17
|
async function dbSeedFresh(options) {
|
|
18
|
-
const restoreConsole = (0,
|
|
18
|
+
const restoreConsole = (0, ConsoleSilencer_js_1.silenceConsoleOutput)(!!options?.silent);
|
|
19
19
|
console.log(chalk_1.default.cyanBright("\nRunning db:seed:fresh\n"));
|
|
20
20
|
const isTest = !!options?.test;
|
|
21
21
|
const envKey = isTest ? "DB_TEST_CONNECTION" : "DB_CONNECTION";
|
|
@@ -23,7 +23,7 @@ async function dbSeedFresh(options) {
|
|
|
23
23
|
const originalDbConnection = process.env.DB_CONNECTION;
|
|
24
24
|
const connectionNames = options?.connectionNames && options.connectionNames.length > 0
|
|
25
25
|
? options.connectionNames
|
|
26
|
-
: [(0,
|
|
26
|
+
: [(0, resolveConnectionName_js_1.resolveConnectionName)(undefined, { test: isTest })];
|
|
27
27
|
let hadFailure = false;
|
|
28
28
|
try {
|
|
29
29
|
for (const connectionName of connectionNames) {
|
|
@@ -33,13 +33,13 @@ async function dbSeedFresh(options) {
|
|
|
33
33
|
process.env.DB_CONNECTION = connectionName;
|
|
34
34
|
}
|
|
35
35
|
console.log(chalk_1.default.yellow(`Rebuilding database for ${connectionName}...`));
|
|
36
|
-
await (0,
|
|
36
|
+
await (0, migrateFresh_js_1.migrateFresh)({
|
|
37
37
|
test: isTest,
|
|
38
38
|
force: !!options?.force,
|
|
39
39
|
auditCommand: "db:seed:fresh",
|
|
40
40
|
});
|
|
41
41
|
console.log(chalk_1.default.greenBright(`\nRunning seeders for ${connectionName}...\n`));
|
|
42
|
-
await (0,
|
|
42
|
+
await (0, dbSeed_js_1.dbSeed)({
|
|
43
43
|
test: isTest,
|
|
44
44
|
...(options?.class ? { class: options.class } : {}),
|
|
45
45
|
silent: !!options?.silent,
|
|
@@ -62,7 +62,7 @@ async function dbSeedFresh(options) {
|
|
|
62
62
|
process.env[envKey] = originalConnection;
|
|
63
63
|
process.env.DB_CONNECTION = originalDbConnection;
|
|
64
64
|
try {
|
|
65
|
-
await (0,
|
|
65
|
+
await (0, ConnectionFactory_js_1.closeAllConnections)();
|
|
66
66
|
if (!options?.silent) {
|
|
67
67
|
console.log(chalk_1.default.gray("All database connections closed.\n"));
|
|
68
68
|
}
|
|
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.demoScenario = demoScenario;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
8
|
+
const ConnectionFactory_js_1 = require("../../core/connection/ConnectionFactory.js");
|
|
9
|
+
const resolveConnectionName_js_1 = require("../../core/connection/resolveConnectionName.js");
|
|
10
|
+
const database_js_1 = require("../../config/database.js");
|
|
11
|
+
const ScenarioMorphAliasRouting_js_1 = require("../utils/ScenarioMorphAliasRouting.js");
|
|
12
12
|
function toNumber(value) {
|
|
13
13
|
if (typeof value === "number")
|
|
14
14
|
return value;
|
|
@@ -26,16 +26,16 @@ function buildMongoIdInFilter(values) {
|
|
|
26
26
|
}
|
|
27
27
|
async function demoScenario(options) {
|
|
28
28
|
const connectionName = options?.connectionName ??
|
|
29
|
-
(0,
|
|
29
|
+
(0, resolveConnectionName_js_1.resolveConnectionName)(undefined, { test: !!options?.test });
|
|
30
30
|
const resolvedConnectionName = connectionName;
|
|
31
|
-
const driver =
|
|
31
|
+
const driver = database_js_1.dbConfig.connections[connectionName]?.driver ??
|
|
32
32
|
connectionName;
|
|
33
33
|
try {
|
|
34
34
|
if (driver === "mongo") {
|
|
35
35
|
await runMongoDemoScenario(connectionName, options);
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
const adapter = await (0,
|
|
38
|
+
const adapter = await (0, ConnectionFactory_js_1.getAdapter)(resolvedConnectionName);
|
|
39
39
|
const usersTable = adapter.wrapId("users");
|
|
40
40
|
const postsTable = adapter.wrapId("posts");
|
|
41
41
|
const commentsTable = adapter.wrapId("comments");
|
|
@@ -69,7 +69,7 @@ async function demoScenario(options) {
|
|
|
69
69
|
console.log(chalk_1.default.gray("user:"), user);
|
|
70
70
|
const posts = await adapter.query(`SELECT * FROM ${postsTable} WHERE ${adapter.wrapId("user_id")} = ${adapter.placeholder(1)} LIMIT 3`, [user.id]);
|
|
71
71
|
console.log(chalk_1.default.gray("posts for user:"), posts.length);
|
|
72
|
-
const { userMorph, postMorph } = (0,
|
|
72
|
+
const { userMorph, postMorph } = (0, ScenarioMorphAliasRouting_js_1.resolveScenarioMorphAliases)({
|
|
73
73
|
isTest: !!options?.test,
|
|
74
74
|
connectionName,
|
|
75
75
|
});
|
|
@@ -99,15 +99,15 @@ async function demoScenario(options) {
|
|
|
99
99
|
console.error(chalk_1.default.red(err.message));
|
|
100
100
|
}
|
|
101
101
|
finally {
|
|
102
|
-
await (0,
|
|
102
|
+
await (0, ConnectionFactory_js_1.closeAllConnections)();
|
|
103
103
|
if (process.env.ELOQUENT_CLI === "true") {
|
|
104
104
|
setImmediate(() => process.exit(0));
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
async function runMongoDemoScenario(connectionName, options) {
|
|
109
|
-
const db = (await (0,
|
|
110
|
-
const { userMorph, postMorph } = (0,
|
|
109
|
+
const db = (await (0, ConnectionFactory_js_1.getConnection)(connectionName));
|
|
110
|
+
const { userMorph, postMorph } = (0, ScenarioMorphAliasRouting_js_1.resolveScenarioMorphAliases)({
|
|
111
111
|
isTest: !!options?.test,
|
|
112
112
|
connectionName,
|
|
113
113
|
});
|
|
@@ -9,16 +9,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.factoryStatus = factoryStatus;
|
|
11
11
|
const chalk_1 = __importDefault(require("chalk"));
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
12
|
+
const FactoryDisplay_js_1 = require("../utils/factories/FactoryDisplay.js");
|
|
13
|
+
const FactoryGraph_js_1 = require("../utils/factories/FactoryGraph.js");
|
|
14
|
+
const FactoryRegistry_js_1 = require("../utils/factories/FactoryRegistry.js");
|
|
15
15
|
function hasSchema(modelCtor) {
|
|
16
16
|
return (typeof modelCtor === "function" &&
|
|
17
17
|
Object.prototype.hasOwnProperty.call(modelCtor, "schema"));
|
|
18
18
|
}
|
|
19
19
|
function extractRelations(schema) {
|
|
20
20
|
if (!schema) {
|
|
21
|
-
return chalk_1.default.gray(
|
|
21
|
+
return chalk_1.default.gray(FactoryDisplay_js_1.FACTORY_EMPTY_MARK);
|
|
22
22
|
}
|
|
23
23
|
const relations = [];
|
|
24
24
|
for (const [, def] of Object.entries(schema)) {
|
|
@@ -26,18 +26,18 @@ function extractRelations(schema) {
|
|
|
26
26
|
continue;
|
|
27
27
|
}
|
|
28
28
|
const rel = def;
|
|
29
|
-
relations.push(`${(0,
|
|
29
|
+
relations.push(`${(0, FactoryDisplay_js_1.getFactoryRelationArrow)(rel.relation)} ${chalk_1.default.cyanBright(rel.model)} (${rel.relation})`);
|
|
30
30
|
}
|
|
31
31
|
return relations.length > 0
|
|
32
32
|
? relations.join(chalk_1.default.gray(", "))
|
|
33
|
-
: chalk_1.default.gray(
|
|
33
|
+
: chalk_1.default.gray(FactoryDisplay_js_1.FACTORY_EMPTY_MARK);
|
|
34
34
|
}
|
|
35
35
|
function getFactoryDetails(factory) {
|
|
36
36
|
const modelClass = factory.model?.name ?? "Unknown";
|
|
37
37
|
const modelInstance = new factory.model();
|
|
38
|
-
let tableName =
|
|
38
|
+
let tableName = FactoryDisplay_js_1.FACTORY_EMPTY_MARK;
|
|
39
39
|
let pivot = "No";
|
|
40
|
-
let relations = chalk_1.default.gray(
|
|
40
|
+
let relations = chalk_1.default.gray(FactoryDisplay_js_1.FACTORY_EMPTY_MARK);
|
|
41
41
|
if ("tableName" in modelInstance &&
|
|
42
42
|
typeof modelInstance.tableName === "string") {
|
|
43
43
|
tableName = modelInstance.tableName;
|
|
@@ -53,7 +53,7 @@ function getFactoryDetails(factory) {
|
|
|
53
53
|
async function factoryStatus(options, _command) {
|
|
54
54
|
console.log(chalk_1.default.cyanBright("\nEloquentJS Factory Status\n"));
|
|
55
55
|
try {
|
|
56
|
-
const factories =
|
|
56
|
+
const factories = FactoryRegistry_js_1.FactoryRegistry.list();
|
|
57
57
|
if (factories.length === 0) {
|
|
58
58
|
console.log(chalk_1.default.yellow("No factories are currently registered.\n"));
|
|
59
59
|
console.log(chalk_1.default.gray("Tip: Run your app or import FactoryLoader to auto-discover factories.\n"));
|
|
@@ -61,12 +61,12 @@ async function factoryStatus(options, _command) {
|
|
|
61
61
|
}
|
|
62
62
|
console.log(chalk_1.default.greenBright(`${factories.length} factories registered.\n`));
|
|
63
63
|
if (options?.graph) {
|
|
64
|
-
console.log((0,
|
|
64
|
+
console.log((0, FactoryGraph_js_1.generateFactoryGraph)(factories));
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
if (options?.details) {
|
|
68
68
|
const tableData = factories.map((name) => {
|
|
69
|
-
const instance =
|
|
69
|
+
const instance = FactoryRegistry_js_1.FactoryRegistry.make(name);
|
|
70
70
|
const details = getFactoryDetails(instance);
|
|
71
71
|
return {
|
|
72
72
|
Factory: name,
|
|
@@ -80,7 +80,7 @@ async function factoryStatus(options, _command) {
|
|
|
80
80
|
};
|
|
81
81
|
});
|
|
82
82
|
console.table(tableData);
|
|
83
|
-
console.log(chalk_1.default.gray(
|
|
83
|
+
console.log(chalk_1.default.gray(FactoryDisplay_js_1.FACTORY_STATUS_FOOTER));
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
const summaryData = factories.map((name) => ({
|
|
@@ -91,7 +91,7 @@ async function factoryStatus(options, _command) {
|
|
|
91
91
|
Status: chalk_1.default.green("Ready"),
|
|
92
92
|
}));
|
|
93
93
|
console.table(summaryData);
|
|
94
|
-
console.log(chalk_1.default.gray(
|
|
94
|
+
console.log(chalk_1.default.gray(FactoryDisplay_js_1.FACTORY_STATUS_FOOTER));
|
|
95
95
|
}
|
|
96
96
|
catch (error) {
|
|
97
97
|
console.error(chalk_1.default.red("Failed to fetch factory status."));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeController = makeController;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const TemplateEngine_js_1 = require("../utils/TemplateEngine.js");
|
|
5
|
+
const fileWriter_js_1 = require("../utils/fileWriter.js");
|
|
6
|
+
const ScaffoldGeneratorSupport_js_1 = require("../utils/ScaffoldGeneratorSupport.js");
|
|
7
7
|
/**
|
|
8
8
|
* Command: eloquent make:controller
|
|
9
9
|
* Generates a controller class with REST methods (index, show, store, update, destroy)
|
|
@@ -14,8 +14,8 @@ async function makeController(modelName, options = {}) {
|
|
|
14
14
|
const isTest = !!options.test;
|
|
15
15
|
const softDelete = !!options.soft;
|
|
16
16
|
const forceWrite = !!options.force;
|
|
17
|
-
const artifact = (0,
|
|
18
|
-
const routeName = (0,
|
|
17
|
+
const artifact = (0, ScaffoldGeneratorSupport_js_1.resolveScaffoldArtifact)("controller", modelName, { test: isTest });
|
|
18
|
+
const routeName = (0, ScaffoldGeneratorSupport_js_1.camelCaseScaffoldName)(artifact.modelClassName);
|
|
19
19
|
const serviceImportPath = `../services/${artifact.modelClassName}Service`;
|
|
20
20
|
const modelImportPath = isTest
|
|
21
21
|
? `../database/models/${artifact.modelClassName}`
|
|
@@ -39,8 +39,8 @@ async function makeController(modelName, options = {}) {
|
|
|
39
39
|
}
|
|
40
40
|
`
|
|
41
41
|
: "";
|
|
42
|
-
const template =
|
|
43
|
-
const rendered =
|
|
42
|
+
const template = TemplateEngine_js_1.TemplateEngine.load("controller");
|
|
43
|
+
const rendered = TemplateEngine_js_1.TemplateEngine.render(template, {
|
|
44
44
|
PascalCase: artifact.modelClassName,
|
|
45
45
|
camelCase: routeName,
|
|
46
46
|
serviceImportPath,
|
|
@@ -48,13 +48,13 @@ async function makeController(modelName, options = {}) {
|
|
|
48
48
|
softDeleteBlock,
|
|
49
49
|
});
|
|
50
50
|
const created = forceWrite
|
|
51
|
-
? (0,
|
|
52
|
-
: (0,
|
|
51
|
+
? (0, fileWriter_js_1.overwriteFile)(artifact.outputPath, rendered)
|
|
52
|
+
: (0, fileWriter_js_1.writeFileSafe)(artifact.outputPath, rendered);
|
|
53
53
|
if (created) {
|
|
54
|
-
(0,
|
|
54
|
+
(0, ScaffoldGeneratorSupport_js_1.logScaffoldCreated)("controller", artifact.relativePath);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
catch (err) {
|
|
58
|
-
(0,
|
|
58
|
+
(0, ScaffoldGeneratorSupport_js_1.logScaffoldFailure)("controller", modelName, err);
|
|
59
59
|
}
|
|
60
60
|
}
|