@alpha.consultings/eloquent-orm.js 1.0.10 → 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 +9 -0
- package/PACKAGE-UPDATE-SUMMARY.md +10 -10
- 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 +18 -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 +26 -2
- 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
|
@@ -8,16 +8,16 @@ exports.migrateRun = migrateRun;
|
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
exports.resolveMigrationConnectionNames =
|
|
11
|
+
const ConnectionFactory_js_1 = require("../../core/connection/ConnectionFactory.js");
|
|
12
|
+
const PathMap_js_1 = require("../utils/PathMap.js");
|
|
13
|
+
const database_js_1 = require("../../config/database.js");
|
|
14
|
+
const resolveConnectionName_js_1 = require("../../core/connection/resolveConnectionName.js");
|
|
15
|
+
const MigrationTracker_js_1 = require("../utils/migrations/MigrationTracker.js");
|
|
16
|
+
const MongoMigrationTracker_js_1 = require("../utils/migrations/MongoMigrationTracker.js");
|
|
17
|
+
const tsRuntime_js_1 = require("../utils/typescript/tsRuntime.js");
|
|
18
|
+
const resolveSqlConnectionFlags_js_1 = require("../utils/resolveSqlConnectionFlags.js");
|
|
19
|
+
const AuditTrail_js_1 = require("../utils/AuditTrail.js");
|
|
20
|
+
exports.resolveMigrationConnectionNames = resolveSqlConnectionFlags_js_1.resolveSqlConnectionNames;
|
|
21
21
|
function createMongoMigrationContext(db, dryRun, operations) {
|
|
22
22
|
const collectionExists = async (name) => {
|
|
23
23
|
const rows = await db
|
|
@@ -75,15 +75,15 @@ function createMongoMigrationContext(db, dryRun, operations) {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
async function getMongoConnection(connectionName) {
|
|
78
|
-
if (typeof
|
|
79
|
-
return (await (0,
|
|
78
|
+
if (typeof ConnectionFactory_js_1.getConnection === "function") {
|
|
79
|
+
return (await (0, ConnectionFactory_js_1.getConnection)(connectionName));
|
|
80
80
|
}
|
|
81
81
|
// Test harness compatibility: some command-level mocks only provide getAdapter.
|
|
82
|
-
return (await
|
|
82
|
+
return (await ConnectionFactory_js_1.getAdapter(connectionName));
|
|
83
83
|
}
|
|
84
84
|
async function runMigrationsForConnection(connectionName, isTest, modelName, dryRun) {
|
|
85
85
|
console.log(chalk_1.default.cyan(`\nRunning migrations in ${isTest ? "TEST" : "DEVELOPMENT"} mode on "${connectionName}"${modelName ? ` for model "${modelName}"` : ""}...\n`));
|
|
86
|
-
const migrationsDir =
|
|
86
|
+
const migrationsDir = PathMap_js_1.PathMap.migrations(isTest, connectionName);
|
|
87
87
|
if (!fs_1.default.existsSync(migrationsDir)) {
|
|
88
88
|
console.log(chalk_1.default.yellow(`No migrations directory found for ${connectionName}.`));
|
|
89
89
|
return true;
|
|
@@ -91,15 +91,15 @@ async function runMigrationsForConnection(connectionName, isTest, modelName, dry
|
|
|
91
91
|
if (process.env.ELOQUENT_DEBUG === "true") {
|
|
92
92
|
console.log("[migrate:run] connectionName", connectionName);
|
|
93
93
|
}
|
|
94
|
-
const driver =
|
|
94
|
+
const driver = database_js_1.dbConfig.connections[connectionName]?.driver ?? connectionName;
|
|
95
95
|
if (driver === "mongo") {
|
|
96
96
|
const db = await getMongoConnection(connectionName);
|
|
97
97
|
console.log(chalk_1.default.gray(`Connected to ${connectionName}.`));
|
|
98
98
|
const lockOwner = `migrate:run:${connectionName}:${process.pid}:${Date.now()}`;
|
|
99
99
|
let completedWithoutError = false;
|
|
100
|
-
await (0,
|
|
100
|
+
await (0, MongoMigrationTracker_js_1.ensureMigrationCollection)(db);
|
|
101
101
|
if (!dryRun) {
|
|
102
|
-
await (0,
|
|
102
|
+
await (0, MongoMigrationTracker_js_1.acquireMigrationLock)(db, lockOwner);
|
|
103
103
|
}
|
|
104
104
|
try {
|
|
105
105
|
let files = fs_1.default
|
|
@@ -115,7 +115,7 @@ async function runMigrationsForConnection(connectionName, isTest, modelName, dry
|
|
|
115
115
|
return true;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
const appliedRows = await (0,
|
|
118
|
+
const appliedRows = await (0, MongoMigrationTracker_js_1.validateMigrationHistory)(db, migrationsDir);
|
|
119
119
|
const executed = appliedRows.map((row) => row.name);
|
|
120
120
|
const pending = files.filter((f) => !executed.includes(f));
|
|
121
121
|
if (pending.length === 0) {
|
|
@@ -124,12 +124,12 @@ async function runMigrationsForConnection(connectionName, isTest, modelName, dry
|
|
|
124
124
|
return true;
|
|
125
125
|
}
|
|
126
126
|
console.log(chalk_1.default.gray(`Pending migrations: ${pending.length}`));
|
|
127
|
-
const lastBatch = await (0,
|
|
127
|
+
const lastBatch = await (0, MongoMigrationTracker_js_1.readLastBatch)(db);
|
|
128
128
|
const newBatch = lastBatch + 1;
|
|
129
129
|
let applied = 0;
|
|
130
130
|
for (const file of pending) {
|
|
131
131
|
const filePath = path_1.default.join(migrationsDir, file);
|
|
132
|
-
const migrationModule = (0,
|
|
132
|
+
const migrationModule = (0, tsRuntime_js_1.loadModule)(path_1.default.resolve(filePath));
|
|
133
133
|
if (typeof migrationModule.up !== "function") {
|
|
134
134
|
console.log(chalk_1.default.red(`Invalid migration: ${file}`));
|
|
135
135
|
continue;
|
|
@@ -145,7 +145,7 @@ async function runMigrationsForConnection(connectionName, isTest, modelName, dry
|
|
|
145
145
|
continue;
|
|
146
146
|
}
|
|
147
147
|
if (!dryRun) {
|
|
148
|
-
await (0,
|
|
148
|
+
await (0, MongoMigrationTracker_js_1.recordAppliedMigration)(db, file, newBatch, (0, MigrationTracker_js_1.computeMigrationChecksum)(filePath));
|
|
149
149
|
}
|
|
150
150
|
console.log(chalk_1.default.green(`Migration applied: ${file}`));
|
|
151
151
|
applied++;
|
|
@@ -162,8 +162,8 @@ async function runMigrationsForConnection(connectionName, isTest, modelName, dry
|
|
|
162
162
|
/* c8 ignore next 4 -- ts-jest/v8 records a synthetic single-location branch on this finally block */
|
|
163
163
|
}
|
|
164
164
|
finally {
|
|
165
|
-
await (0,
|
|
166
|
-
await (0,
|
|
165
|
+
await (0, MongoMigrationTracker_js_1.releaseMigrationLock)(db, lockOwner);
|
|
166
|
+
await (0, ConnectionFactory_js_1.closeAllConnections)();
|
|
167
167
|
console.log(chalk_1.default.gray("\nAll database connections closed.\n"));
|
|
168
168
|
}
|
|
169
169
|
}
|
|
@@ -174,16 +174,16 @@ async function runMigrationsForConnection(connectionName, isTest, modelName, dry
|
|
|
174
174
|
if (process.env.ELOQUENT_DEBUG === "true") {
|
|
175
175
|
console.log("[migrate:run] before getAdapter");
|
|
176
176
|
}
|
|
177
|
-
const db = await (0,
|
|
177
|
+
const db = await (0, ConnectionFactory_js_1.getAdapter)(connectionName);
|
|
178
178
|
if (process.env.ELOQUENT_DEBUG === "true") {
|
|
179
179
|
console.log("[migrate:run] after getAdapter");
|
|
180
180
|
}
|
|
181
181
|
console.log(chalk_1.default.gray(`Connected to ${connectionName}.`));
|
|
182
182
|
const lockOwner = `migrate:run:${connectionName}:${process.pid}:${Date.now()}`;
|
|
183
183
|
let completedWithoutError = false;
|
|
184
|
-
await (0,
|
|
184
|
+
await (0, MigrationTracker_js_1.ensureMigrationTables)(db);
|
|
185
185
|
if (!dryRun) {
|
|
186
|
-
await (0,
|
|
186
|
+
await (0, MigrationTracker_js_1.acquireMigrationLock)(db, lockOwner);
|
|
187
187
|
}
|
|
188
188
|
try {
|
|
189
189
|
let files = fs_1.default
|
|
@@ -199,7 +199,7 @@ async function runMigrationsForConnection(connectionName, isTest, modelName, dry
|
|
|
199
199
|
return true;
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
const appliedRows = await (0,
|
|
202
|
+
const appliedRows = await (0, MigrationTracker_js_1.validateMigrationHistory)(db, migrationsDir);
|
|
203
203
|
const executed = appliedRows.map((row) => row.name);
|
|
204
204
|
const pending = files.filter((f) => !executed.includes(f));
|
|
205
205
|
if (pending.length === 0) {
|
|
@@ -208,12 +208,12 @@ async function runMigrationsForConnection(connectionName, isTest, modelName, dry
|
|
|
208
208
|
return true;
|
|
209
209
|
}
|
|
210
210
|
console.log(chalk_1.default.gray(`Pending migrations: ${pending.length}`));
|
|
211
|
-
const lastBatch = await (0,
|
|
211
|
+
const lastBatch = await (0, MigrationTracker_js_1.readLastBatch)(db);
|
|
212
212
|
const newBatch = lastBatch + 1;
|
|
213
213
|
let applied = 0;
|
|
214
214
|
for (const file of pending) {
|
|
215
215
|
const filePath = path_1.default.join(migrationsDir, file);
|
|
216
|
-
const migrationModule = (0,
|
|
216
|
+
const migrationModule = (0, tsRuntime_js_1.loadModule)(path_1.default.resolve(filePath));
|
|
217
217
|
if (typeof migrationModule.up !== "function") {
|
|
218
218
|
console.log(chalk_1.default.red(`Invalid migration: ${file}`));
|
|
219
219
|
continue;
|
|
@@ -236,7 +236,7 @@ async function runMigrationsForConnection(connectionName, isTest, modelName, dry
|
|
|
236
236
|
continue;
|
|
237
237
|
}
|
|
238
238
|
if (!dryRun) {
|
|
239
|
-
await (0,
|
|
239
|
+
await (0, MigrationTracker_js_1.recordAppliedMigration)(db, file, newBatch, (0, MigrationTracker_js_1.computeMigrationChecksum)(filePath));
|
|
240
240
|
}
|
|
241
241
|
console.log(chalk_1.default.green(`Migration applied: ${file}`));
|
|
242
242
|
applied++;
|
|
@@ -253,8 +253,8 @@ async function runMigrationsForConnection(connectionName, isTest, modelName, dry
|
|
|
253
253
|
/* c8 ignore next 4 -- ts-jest/v8 records a synthetic single-location branch on this finally block */
|
|
254
254
|
}
|
|
255
255
|
finally {
|
|
256
|
-
await (0,
|
|
257
|
-
await (0,
|
|
256
|
+
await (0, MigrationTracker_js_1.releaseMigrationLock)(db, lockOwner, { success: completedWithoutError });
|
|
257
|
+
await (0, ConnectionFactory_js_1.closeAllConnections)();
|
|
258
258
|
console.log(chalk_1.default.gray("\nAll database connections closed.\n"));
|
|
259
259
|
}
|
|
260
260
|
}
|
|
@@ -274,12 +274,12 @@ async function migrateRun(isTest = false, modelName, dryRun = false, exitOnFinis
|
|
|
274
274
|
}
|
|
275
275
|
const connectionNames = options.connectionNames && options.connectionNames.length > 0
|
|
276
276
|
? options.connectionNames
|
|
277
|
-
: [(0,
|
|
277
|
+
: [(0, resolveConnectionName_js_1.resolveConnectionName)(undefined, { test: isTest })];
|
|
278
278
|
let hadFailure = false;
|
|
279
279
|
const auditCommand = options.auditCommand ?? "migrate:run";
|
|
280
280
|
for (const connectionName of connectionNames) {
|
|
281
281
|
const success = await runMigrationsForConnection(connectionName, isTest, modelName, dryRun);
|
|
282
|
-
(0,
|
|
282
|
+
(0, AuditTrail_js_1.appendAuditEvent)({
|
|
283
283
|
command: auditCommand,
|
|
284
284
|
connectionName,
|
|
285
285
|
test: isTest,
|
|
@@ -6,30 +6,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.migrateStatus = migrateStatus;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
9
|
+
const ConnectionFactory_js_1 = require("../../core/connection/ConnectionFactory.js");
|
|
10
|
+
const PathMap_js_1 = require("../utils/PathMap.js");
|
|
11
|
+
const resolveConnectionName_js_1 = require("../../core/connection/resolveConnectionName.js");
|
|
12
|
+
const database_js_1 = require("../../config/database.js");
|
|
13
|
+
const MongoMigrationTracker_js_1 = require("../utils/migrations/MongoMigrationTracker.js");
|
|
14
14
|
async function getMongoConnection(connectionName) {
|
|
15
|
-
if (typeof
|
|
16
|
-
return (await (0,
|
|
15
|
+
if (typeof ConnectionFactory_js_1.getConnection === "function") {
|
|
16
|
+
return (await (0, ConnectionFactory_js_1.getConnection)(connectionName));
|
|
17
17
|
}
|
|
18
18
|
// Test harness compatibility: some command-level mocks only provide getAdapter.
|
|
19
|
-
return (await
|
|
19
|
+
return (await ConnectionFactory_js_1.getAdapter(connectionName));
|
|
20
20
|
}
|
|
21
21
|
async function finalizeStatusResult(connectionName, success, error) {
|
|
22
22
|
if (!success) {
|
|
23
23
|
console.error(chalk_1.default.red(`Failed to fetch migration status for "${connectionName}".`));
|
|
24
24
|
console.error(error);
|
|
25
25
|
}
|
|
26
|
-
await (0,
|
|
26
|
+
await (0, ConnectionFactory_js_1.closeAllConnections)();
|
|
27
27
|
return success;
|
|
28
28
|
}
|
|
29
29
|
async function showStatusForConnection(connectionName, isTest) {
|
|
30
|
-
const driver =
|
|
30
|
+
const driver = database_js_1.dbConfig.connections[connectionName]?.driver ?? connectionName;
|
|
31
31
|
if (driver === "mongo") {
|
|
32
|
-
const migrationsDir =
|
|
32
|
+
const migrationsDir = PathMap_js_1.PathMap.migrations(isTest, connectionName);
|
|
33
33
|
if (!fs_1.default.existsSync(migrationsDir)) {
|
|
34
34
|
console.log(chalk_1.default.yellow(`No migrations directory found for ${connectionName}.`));
|
|
35
35
|
return true;
|
|
@@ -39,12 +39,12 @@ async function showStatusForConnection(connectionName, isTest) {
|
|
|
39
39
|
try {
|
|
40
40
|
const db = await getMongoConnection(connectionName);
|
|
41
41
|
console.log(chalk_1.default.gray(`Connected to ${connectionName}.`));
|
|
42
|
-
await (0,
|
|
42
|
+
await (0, MongoMigrationTracker_js_1.ensureMigrationCollection)(db);
|
|
43
43
|
const files = fs_1.default
|
|
44
44
|
.readdirSync(migrationsDir)
|
|
45
45
|
.filter((f) => f.endsWith(".ts") || f.endsWith(".js"))
|
|
46
46
|
.sort();
|
|
47
|
-
const applied = await (0,
|
|
47
|
+
const applied = await (0, MongoMigrationTracker_js_1.readAppliedMigrations)(db);
|
|
48
48
|
const appliedNames = applied.map((row) => row.name);
|
|
49
49
|
console.log(chalk_1.default.cyan(`\nMigration Status (${connectionName}):\n`));
|
|
50
50
|
console.table(files.map((file) => ({
|
|
@@ -64,7 +64,7 @@ async function showStatusForConnection(connectionName, isTest) {
|
|
|
64
64
|
console.warn(chalk_1.default.yellow(`Status skipped: "${connectionName}" has unsupported driver "${driver}".`));
|
|
65
65
|
return true;
|
|
66
66
|
}
|
|
67
|
-
const migrationsDir =
|
|
67
|
+
const migrationsDir = PathMap_js_1.PathMap.migrations(isTest, connectionName);
|
|
68
68
|
if (!fs_1.default.existsSync(migrationsDir)) {
|
|
69
69
|
console.log(chalk_1.default.yellow(`No migrations directory found for ${connectionName}.`));
|
|
70
70
|
return true;
|
|
@@ -72,7 +72,7 @@ async function showStatusForConnection(connectionName, isTest) {
|
|
|
72
72
|
let success = false;
|
|
73
73
|
let failure;
|
|
74
74
|
try {
|
|
75
|
-
const db = await (0,
|
|
75
|
+
const db = await (0, ConnectionFactory_js_1.getAdapter)(connectionName);
|
|
76
76
|
console.log(chalk_1.default.gray(`Connected to ${connectionName}.`));
|
|
77
77
|
const files = fs_1.default
|
|
78
78
|
.readdirSync(migrationsDir)
|
|
@@ -105,7 +105,7 @@ async function migrateStatus(options = {}) {
|
|
|
105
105
|
const isTest = !!normalizedOptions.test;
|
|
106
106
|
const connectionNames = normalizedOptions.connectionNames && normalizedOptions.connectionNames.length > 0
|
|
107
107
|
? normalizedOptions.connectionNames
|
|
108
|
-
: [(0,
|
|
108
|
+
: [(0, resolveConnectionName_js_1.resolveConnectionName)(undefined, { test: isTest })];
|
|
109
109
|
let hadFailure = false;
|
|
110
110
|
for (const connectionName of connectionNames) {
|
|
111
111
|
const success = await showStatusForConnection(connectionName, isTest);
|
package/dist/cli/eloquent.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* services, migrations, seeds, and manages caches & factories.
|
|
8
8
|
*/
|
|
9
9
|
import { Command } from "commander";
|
|
10
|
-
import { type CliBootstrapEnv } from "./utils/CliBootstrapSupport";
|
|
10
|
+
import { type CliBootstrapEnv } from "./utils/CliBootstrapSupport.js";
|
|
11
11
|
export declare function installCliLogging(argv?: string[], env?: CliBootstrapEnv, loggerConsole?: typeof console): void;
|
|
12
12
|
export declare function initializeCliTypeScriptRuntime(argv?: string[], env?: CliBootstrapEnv): void;
|
|
13
13
|
export declare function autoLoadCliFactories(argv?: string[], env?: CliBootstrapEnv): Promise<void>;
|
package/dist/cli/eloquent.js
CHANGED
|
@@ -22,26 +22,26 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
22
22
|
const commander_1 = require("commander");
|
|
23
23
|
const fs_1 = __importDefault(require("fs"));
|
|
24
24
|
const path_1 = __importDefault(require("path"));
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
25
|
+
const TypeScriptCompiler_js_1 = require("./utils/typescript/TypeScriptCompiler.js");
|
|
26
|
+
const RuntimeDetector_js_1 = require("./utils/typescript/RuntimeDetector.js");
|
|
27
|
+
const FactoryLoader_js_1 = require("./utils/factories/FactoryLoader.js");
|
|
28
|
+
const SecretRedactor_js_1 = require("../core/security/SecretRedactor.js");
|
|
29
|
+
const StructuredLogger_js_1 = require("./utils/StructuredLogger.js");
|
|
30
|
+
const CliBootstrapSupport_js_1 = require("./utils/CliBootstrapSupport.js");
|
|
31
|
+
const CliPresentation_js_1 = require("./utils/CliPresentation.js");
|
|
32
|
+
const CliSupportCommandRegistration_js_1 = require("./utils/CliSupportCommandRegistration.js");
|
|
33
|
+
const CliScaffoldCommandRegistration_js_1 = require("./utils/CliScaffoldCommandRegistration.js");
|
|
34
|
+
const CliMakeArtifactCommandRegistration_js_1 = require("./utils/CliMakeArtifactCommandRegistration.js");
|
|
35
|
+
const CliSeedScenarioCommandRegistration_js_1 = require("./utils/CliSeedScenarioCommandRegistration.js");
|
|
36
|
+
const CliMigrationCommandRegistration_js_1 = require("./utils/CliMigrationCommandRegistration.js");
|
|
37
37
|
function resolveCommandName(argv) {
|
|
38
38
|
return (argv[2] ?? "unknown").replace(/[^a-z0-9_-]/gi, "_").toLowerCase();
|
|
39
39
|
}
|
|
40
40
|
function installCliLogging(argv = process.argv, env = process.env, loggerConsole = console) {
|
|
41
41
|
const commandName = resolveCommandName(argv);
|
|
42
42
|
const logsDir = path_1.default.join(process.cwd(), "src", "test", "logs");
|
|
43
|
-
const jsonLogs = (0,
|
|
44
|
-
const minLogLevel = (0,
|
|
43
|
+
const jsonLogs = (0, StructuredLogger_js_1.isJsonLogFormat)(env);
|
|
44
|
+
const minLogLevel = (0, StructuredLogger_js_1.resolveLogLevel)(env);
|
|
45
45
|
try {
|
|
46
46
|
if (env.ELOQUENT_DEBUG === "true") {
|
|
47
47
|
loggerConsole.log("[cli] before runtime init");
|
|
@@ -49,7 +49,7 @@ function installCliLogging(argv = process.argv, env = process.env, loggerConsole
|
|
|
49
49
|
fs_1.default.mkdirSync(logsDir, { recursive: true });
|
|
50
50
|
const logFile = path_1.default.join(logsDir, `${commandName}.log`);
|
|
51
51
|
const writeLog = (level, args) => {
|
|
52
|
-
const redactedArgs = (0,
|
|
52
|
+
const redactedArgs = (0, SecretRedactor_js_1.redactSecretsInArgs)(args);
|
|
53
53
|
const message = redactedArgs
|
|
54
54
|
.map((arg) => {
|
|
55
55
|
if (typeof arg === "string")
|
|
@@ -71,12 +71,12 @@ function installCliLogging(argv = process.argv, env = process.env, loggerConsole
|
|
|
71
71
|
const originalError = loggerConsole.error.bind(loggerConsole);
|
|
72
72
|
const originalInfo = loggerConsole.info.bind(loggerConsole);
|
|
73
73
|
const emitLog = (level, args, writer) => {
|
|
74
|
-
if (!(0,
|
|
74
|
+
if (!(0, StructuredLogger_js_1.shouldLogAtLevel)(level, minLogLevel)) {
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
|
-
const safeArgs = (0,
|
|
77
|
+
const safeArgs = (0, SecretRedactor_js_1.redactSecretsInArgs)(args);
|
|
78
78
|
if (jsonLogs) {
|
|
79
|
-
const jsonLine = (0,
|
|
79
|
+
const jsonLine = (0, StructuredLogger_js_1.buildStructuredLogLine)(level, safeArgs, {
|
|
80
80
|
command: commandName,
|
|
81
81
|
pid: process.pid,
|
|
82
82
|
});
|
|
@@ -98,9 +98,9 @@ function installCliLogging(argv = process.argv, env = process.env, loggerConsole
|
|
|
98
98
|
}
|
|
99
99
|
function initializeCliTypeScriptRuntime(argv = process.argv, env = process.env) {
|
|
100
100
|
try {
|
|
101
|
-
const runtimeNeeded =
|
|
101
|
+
const runtimeNeeded = RuntimeDetector_js_1.RuntimeDetector.needsTypeScriptRuntime(argv);
|
|
102
102
|
if (runtimeNeeded) {
|
|
103
|
-
|
|
103
|
+
TypeScriptCompiler_js_1.TypeScriptCompiler.ensureRuntime();
|
|
104
104
|
if (env.ELOQUENT_RUNTIME_LOG !== "false") {
|
|
105
105
|
console.log(chalk_1.default.gray("TypeScript runtime enabled (ts-node)."));
|
|
106
106
|
}
|
|
@@ -125,12 +125,12 @@ async function autoLoadCliFactories(argv = process.argv, env = process.env) {
|
|
|
125
125
|
if (env.ELOQUENT_DEBUG === "true") {
|
|
126
126
|
console.log("[cli] factory auto-load check");
|
|
127
127
|
}
|
|
128
|
-
if (!(0,
|
|
128
|
+
if (!(0, CliBootstrapSupport_js_1.shouldAutoLoadFactoriesForCli)(argv)) {
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
try {
|
|
132
|
-
await (0,
|
|
133
|
-
storageKind: (0,
|
|
132
|
+
await (0, FactoryLoader_js_1.loadFactories)((0, CliBootstrapSupport_js_1.isCliTestArgv)(argv), {
|
|
133
|
+
storageKind: (0, CliBootstrapSupport_js_1.resolveCliRequestedStorageKind)(argv, env),
|
|
134
134
|
});
|
|
135
135
|
if (env.DEBUG === "true") {
|
|
136
136
|
console.log(chalk_1.default.gray("Factories loaded successfully."));
|
|
@@ -145,16 +145,16 @@ async function autoLoadCliFactories(argv = process.argv, env = process.env) {
|
|
|
145
145
|
}
|
|
146
146
|
function createCliProgram() {
|
|
147
147
|
const program = new commander_1.Command();
|
|
148
|
-
(0,
|
|
148
|
+
(0, CliPresentation_js_1.printCliBanner)();
|
|
149
149
|
program
|
|
150
150
|
.name("eloquent")
|
|
151
151
|
.description("Eloquent ORM JS Command Line Interface (Artisan-like tool)")
|
|
152
152
|
.version("1.0.0");
|
|
153
|
-
(0,
|
|
154
|
-
(0,
|
|
155
|
-
(0,
|
|
156
|
-
(0,
|
|
157
|
-
(0,
|
|
153
|
+
(0, CliScaffoldCommandRegistration_js_1.registerCliScaffoldCommands)(program);
|
|
154
|
+
(0, CliMakeArtifactCommandRegistration_js_1.registerCliMakeArtifactCommands)(program);
|
|
155
|
+
(0, CliSeedScenarioCommandRegistration_js_1.registerCliSeedScenarioCommands)(program);
|
|
156
|
+
(0, CliMigrationCommandRegistration_js_1.registerCliMigrationCommands)(program);
|
|
157
|
+
(0, CliSupportCommandRegistration_js_1.registerCliSupportCommands)(program);
|
|
158
158
|
return program;
|
|
159
159
|
}
|
|
160
160
|
async function runCli(argv = process.argv, env = process.env) {
|
|
@@ -163,7 +163,7 @@ async function runCli(argv = process.argv, env = process.env) {
|
|
|
163
163
|
}
|
|
164
164
|
env.ELOQUENT_CLI = "true";
|
|
165
165
|
installCliLogging(argv, env);
|
|
166
|
-
(0,
|
|
166
|
+
(0, CliBootstrapSupport_js_1.applyCliTestConnectionOverride)(argv, env);
|
|
167
167
|
initializeCliTypeScriptRuntime(argv, env);
|
|
168
168
|
void autoLoadCliFactories(argv, env);
|
|
169
169
|
const program = createCliProgram();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ArtifactCompatibilityReason, type StorageKind, type TargetStorageKind } from "./ArtifactCompatibility";
|
|
1
|
+
import { type ArtifactCompatibilityReason, type StorageKind, type TargetStorageKind } from "./ArtifactCompatibility.js";
|
|
2
2
|
export type TargetedArtifactDecision = {
|
|
3
3
|
name: string;
|
|
4
4
|
kind: StorageKind;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createTargetedArtifactDecision = createTargetedArtifactDecision;
|
|
4
4
|
exports.summarizeSkippedArtifacts = summarizeSkippedArtifacts;
|
|
5
|
-
const
|
|
5
|
+
const ArtifactCompatibility_js_1 = require("./ArtifactCompatibility.js");
|
|
6
6
|
function createTargetedArtifactDecision(name, kind, targetKind) {
|
|
7
|
-
const compatibility = (0,
|
|
7
|
+
const compatibility = (0, ArtifactCompatibility_js_1.resolveArtifactCompatibility)(kind, targetKind);
|
|
8
8
|
return {
|
|
9
9
|
name,
|
|
10
10
|
kind,
|
|
@@ -18,7 +18,7 @@ function summarizeSkippedArtifacts(label, decisions, targetKind) {
|
|
|
18
18
|
}
|
|
19
19
|
const pluralLabel = decisions.length === 1 ? label : `${label}s`;
|
|
20
20
|
const details = decisions
|
|
21
|
-
.map((decision) => `${decision.name} (${(0,
|
|
21
|
+
.map((decision) => `${decision.name} (${(0, ArtifactCompatibility_js_1.describeArtifactCompatibilityMismatch)(decision.kind, targetKind)})`)
|
|
22
22
|
.join("; ");
|
|
23
23
|
return `Skipping incompatible ${pluralLabel} for ${targetKind}: ${details}`;
|
|
24
24
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type StorageKind, type TargetStorageKind } from "./ArtifactCompatibility";
|
|
2
|
-
export type { ArtifactCompatibilityReason, StorageKind, TargetStorageKind } from "./ArtifactCompatibility";
|
|
1
|
+
import { type StorageKind, type TargetStorageKind } from "./ArtifactCompatibility.js";
|
|
2
|
+
export type { ArtifactCompatibilityReason, StorageKind, TargetStorageKind } from "./ArtifactCompatibility.js";
|
|
3
3
|
export declare function resolveModelStorageKindFromCtor(modelCtor: unknown): StorageKind;
|
|
4
4
|
export declare function resolveFactoryStorageKindFromCtor(factoryCtor: unknown): StorageKind;
|
|
5
5
|
export declare function resolveModelStorageKind(modelName: string, isTest: boolean): StorageKind;
|
|
@@ -12,11 +12,11 @@ exports.targetStorageKindForConnection = targetStorageKindForConnection;
|
|
|
12
12
|
exports.matchesTargetStorageKind = matchesTargetStorageKind;
|
|
13
13
|
const fs_1 = __importDefault(require("fs"));
|
|
14
14
|
const path_1 = __importDefault(require("path"));
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
15
|
+
const database_js_1 = require("../../config/database.js");
|
|
16
|
+
const BaseModel_js_1 = require("../../core/model/BaseModel.js");
|
|
17
|
+
const PathMap_js_1 = require("./PathMap.js");
|
|
18
|
+
const tsRuntime_js_1 = require("./typescript/tsRuntime.js");
|
|
19
|
+
const ArtifactCompatibility_js_1 = require("./ArtifactCompatibility.js");
|
|
20
20
|
function resolveExistingPath(filePath) {
|
|
21
21
|
if (fs_1.default.existsSync(filePath)) {
|
|
22
22
|
return filePath;
|
|
@@ -41,7 +41,7 @@ function resolveStorageKindFromConnectionName(connectionName) {
|
|
|
41
41
|
if (typeof connectionName !== "string") {
|
|
42
42
|
return "unknown";
|
|
43
43
|
}
|
|
44
|
-
const driver =
|
|
44
|
+
const driver = database_js_1.dbConfig.connections[connectionName]?.driver;
|
|
45
45
|
return driver === "mongo" ? "mongo" : driver ? "sql" : "unknown";
|
|
46
46
|
}
|
|
47
47
|
function resolveModelStorageKindFromContent(content) {
|
|
@@ -61,10 +61,10 @@ function isCtor(value) {
|
|
|
61
61
|
return typeof value === "function";
|
|
62
62
|
}
|
|
63
63
|
function isMongoModelCtor(value) {
|
|
64
|
-
return isCtor(value) && value.prototype instanceof
|
|
64
|
+
return isCtor(value) && value.prototype instanceof BaseModel_js_1.MongoModel;
|
|
65
65
|
}
|
|
66
66
|
function isSqlModelCtor(value) {
|
|
67
|
-
return isCtor(value) && value.prototype instanceof
|
|
67
|
+
return isCtor(value) && value.prototype instanceof BaseModel_js_1.SqlModel;
|
|
68
68
|
}
|
|
69
69
|
function resolveModelStorageKindFromCtor(modelCtor) {
|
|
70
70
|
if (isMongoModelCtor(modelCtor)) {
|
|
@@ -92,7 +92,7 @@ function resolveFactoryStorageKindFromCtor(factoryCtor) {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
function resolveModelStorageKind(modelName, isTest) {
|
|
95
|
-
const modelsDir =
|
|
95
|
+
const modelsDir = PathMap_js_1.PathMap.models(isTest);
|
|
96
96
|
const modelPath = resolveExistingPath(path_1.default.join(modelsDir, modelName));
|
|
97
97
|
if (!modelPath) {
|
|
98
98
|
return "unknown";
|
|
@@ -104,7 +104,7 @@ function resolveModelStorageKind(modelName, isTest) {
|
|
|
104
104
|
return staticKind;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
const importedModule = (0,
|
|
107
|
+
const importedModule = (0, tsRuntime_js_1.loadModule)(modelPath);
|
|
108
108
|
return resolveModelStorageKindFromCtor(importedModule[modelName]);
|
|
109
109
|
}
|
|
110
110
|
function collectModelImportBasenames(filePath) {
|
|
@@ -127,7 +127,7 @@ function resolveFactoryStorageKindFromFile(filePath, isTest) {
|
|
|
127
127
|
if (!fs_1.default.existsSync(filePath)) {
|
|
128
128
|
return "unknown";
|
|
129
129
|
}
|
|
130
|
-
const modelsDir =
|
|
130
|
+
const modelsDir = PathMap_js_1.PathMap.models(isTest);
|
|
131
131
|
const importedModels = collectModelImportBasenames(filePath);
|
|
132
132
|
if (importedModels.length > 0) {
|
|
133
133
|
const kinds = new Set();
|
|
@@ -144,9 +144,9 @@ function resolveFactoryStorageKindFromFile(filePath, isTest) {
|
|
|
144
144
|
}
|
|
145
145
|
kinds.add(resolveModelStorageKindFromContent(content));
|
|
146
146
|
}
|
|
147
|
-
return (0,
|
|
147
|
+
return (0, ArtifactCompatibility_js_1.collapseStorageKinds)(kinds);
|
|
148
148
|
}
|
|
149
|
-
const importedModule = (0,
|
|
149
|
+
const importedModule = (0, tsRuntime_js_1.loadModule)(filePath);
|
|
150
150
|
const exportName = Object.keys(importedModule).find((name) => name.endsWith("Factory"));
|
|
151
151
|
return resolveFactoryStorageKindFromCtor(exportName ? importedModule[exportName] : undefined);
|
|
152
152
|
}
|
|
@@ -167,7 +167,7 @@ function resolveSeederStorageKindFromFile(filePath, isTest) {
|
|
|
167
167
|
if (!fs_1.default.existsSync(filePath)) {
|
|
168
168
|
return "unknown";
|
|
169
169
|
}
|
|
170
|
-
const factoriesDir =
|
|
170
|
+
const factoriesDir = PathMap_js_1.PathMap.factories(isTest);
|
|
171
171
|
const importedFactories = collectFactoryImportBasenames(filePath);
|
|
172
172
|
if (importedFactories.length === 0) {
|
|
173
173
|
return "unknown";
|
|
@@ -181,12 +181,12 @@ function resolveSeederStorageKindFromFile(filePath, isTest) {
|
|
|
181
181
|
}
|
|
182
182
|
kinds.add(resolveFactoryStorageKindFromFile(factoryPath, isTest));
|
|
183
183
|
}
|
|
184
|
-
return (0,
|
|
184
|
+
return (0, ArtifactCompatibility_js_1.collapseStorageKinds)(kinds);
|
|
185
185
|
}
|
|
186
186
|
function targetStorageKindForConnection(connectionName) {
|
|
187
|
-
const driver =
|
|
187
|
+
const driver = database_js_1.dbConfig.connections[connectionName]?.driver;
|
|
188
188
|
return driver === "mongo" ? "mongo" : "sql";
|
|
189
189
|
}
|
|
190
190
|
function matchesTargetStorageKind(artifactKind, targetKind) {
|
|
191
|
-
return (0,
|
|
191
|
+
return (0, ArtifactCompatibility_js_1.resolveArtifactCompatibility)(artifactKind, targetKind).matches;
|
|
192
192
|
}
|
|
@@ -10,7 +10,7 @@ exports.buildAuditEvent = buildAuditEvent;
|
|
|
10
10
|
exports.appendAuditEvent = appendAuditEvent;
|
|
11
11
|
const fs_1 = __importDefault(require("fs"));
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
13
|
-
const
|
|
13
|
+
const SecretRedactor_js_1 = require("../../core/security/SecretRedactor.js");
|
|
14
14
|
function isTruthy(value) {
|
|
15
15
|
if (!value)
|
|
16
16
|
return false;
|
|
@@ -51,7 +51,7 @@ function buildAuditEvent(input) {
|
|
|
51
51
|
mode: input.test ? "test" : "app",
|
|
52
52
|
result: input.result,
|
|
53
53
|
metadata: input.metadata
|
|
54
|
-
? (0,
|
|
54
|
+
? (0, SecretRedactor_js_1.redactSecretsInValue)(input.metadata)
|
|
55
55
|
: undefined,
|
|
56
56
|
};
|
|
57
57
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ConnectionName } from "../../core/connection/ConnectionFactory";
|
|
2
|
-
import { type DriverConnectionFlags, type ResolveConnectionFlagsOptions } from "./resolveConnectionFlags";
|
|
1
|
+
import type { ConnectionName } from "../../core/connection/ConnectionFactory.js";
|
|
2
|
+
import { type DriverConnectionFlags, type ResolveConnectionFlagsOptions } from "./resolveConnectionFlags.js";
|
|
3
3
|
export type CliConnectionTargetOptions = Partial<DriverConnectionFlags> & {
|
|
4
4
|
test?: boolean;
|
|
5
5
|
};
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveCliConnectionNames = resolveCliConnectionNames;
|
|
4
4
|
exports.resolveCliPrimaryConnectionName = resolveCliPrimaryConnectionName;
|
|
5
|
-
const
|
|
5
|
+
const resolveConnectionFlags_js_1 = require("./resolveConnectionFlags.js");
|
|
6
6
|
function resolveCliConnectionNames(options, resolveOptions = {}) {
|
|
7
7
|
const normalized = options ?? {};
|
|
8
|
-
return (0,
|
|
8
|
+
return (0, resolveConnectionFlags_js_1.resolveConnectionNamesFromFlags)(normalized.test === true, {
|
|
9
9
|
mysql: normalized.mysql === true,
|
|
10
10
|
pg: normalized.pg === true,
|
|
11
11
|
sqlite: normalized.sqlite === true,
|