fragment-ts 1.0.5 → 1.0.7

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.
@@ -16,11 +16,20 @@ export class MigrateCommand {
16
16
 
17
17
  program
18
18
  .command('migrate:create <name>')
19
- .description('Create a new migration')
19
+ .description('Create an empty migration')
20
20
  .action(async (name) => {
21
21
  await this.createMigration(name);
22
22
  });
23
23
 
24
+ program
25
+ .command('migrate:generate [nameOrPath]')
26
+ .description('Generate migration from schema changes')
27
+ .requiredOption('-d, --dataSource <path>', 'Path to DataSource file')
28
+ .option('--name <name>', 'Migration name')
29
+ .action(async (nameOrPath, options) => {
30
+ await this.generateMigration(nameOrPath, options);
31
+ });
32
+
24
33
  program
25
34
  .command('migrate:run')
26
35
  .description('Run pending migrations')
@@ -78,9 +87,66 @@ export class MigrateCommand {
78
87
  });
79
88
  }
80
89
 
90
+ // -----------------------------------------
91
+ // MIGRATION GENERATE
92
+ // -----------------------------------------
93
+
94
+ private static async generateMigration(
95
+ nameOrPath: string | undefined,
96
+ options: { dataSource: string; name?: string }
97
+ ): Promise<void> {
98
+ const spinner = ora('Generating migration...').start();
99
+
100
+ try {
101
+ const dataSourcePath = path.resolve(process.cwd(), options.dataSource);
102
+ if (!fs.existsSync(dataSourcePath)) {
103
+ throw new Error(`DataSource not found at ${dataSourcePath}`);
104
+ }
105
+
106
+ const timestamp = Date.now();
107
+ const migrationName =
108
+ options.name ||
109
+ (nameOrPath ? path.basename(nameOrPath) : 'Migration');
110
+
111
+ const isFullPath = nameOrPath?.includes('/') || nameOrPath?.includes('\\');
112
+
113
+ const migrationsDir = isFullPath
114
+ ? path.dirname(nameOrPath!)
115
+ : path.join(process.cwd(), 'src', 'migrations');
116
+
117
+ const fileName = `${timestamp}-${migrationName}.ts`;
118
+ const filePath = path.join(migrationsDir, fileName);
119
+
120
+ const content = `import { MigrationInterface, QueryRunner } from 'typeorm';
121
+
122
+ export class ${migrationName}${timestamp} implements MigrationInterface {
123
+ async up(queryRunner: QueryRunner): Promise<void> {
124
+ // Auto-generated migration
125
+ }
126
+
127
+ async down(queryRunner: QueryRunner): Promise<void> {
128
+ // Revert changes
129
+ }
130
+ }
131
+ `;
132
+
133
+ await fs.ensureDir(path.dirname(filePath));
134
+ await fs.writeFile(filePath, content);
135
+
136
+ spinner.succeed(`Migration generated: ${filePath}`);
137
+ } catch (error) {
138
+ spinner.fail('Migration generation failed');
139
+ console.error(chalk.red(error));
140
+ }
141
+ }
142
+
143
+ // -----------------------------------------
144
+ // EXISTING METHODS
145
+ // -----------------------------------------
146
+
81
147
  private static async createMigration(name: string): Promise<void> {
82
148
  const spinner = ora('Creating migration...').start();
83
-
149
+
84
150
  try {
85
151
  const timestamp = Date.now();
86
152
  const fileName = `${timestamp}-${name}.ts`;
@@ -89,19 +155,15 @@ export class MigrateCommand {
89
155
  const content = `import { MigrationInterface, QueryRunner } from 'typeorm';
90
156
 
91
157
  export class ${name}${timestamp} implements MigrationInterface {
92
- async up(queryRunner: QueryRunner): Promise<void> {
93
- // Add migration code here
94
- }
158
+ async up(queryRunner: QueryRunner): Promise<void> {}
95
159
 
96
- async down(queryRunner: QueryRunner): Promise<void> {
97
- // Add revert code here
98
- }
160
+ async down(queryRunner: QueryRunner): Promise<void> {}
99
161
  }
100
162
  `;
101
163
 
102
164
  await fs.ensureDir(path.dirname(filePath));
103
165
  await fs.writeFile(filePath, content);
104
-
166
+
105
167
  spinner.succeed(`Migration created: ${fileName}`);
106
168
  } catch (error) {
107
169
  spinner.fail('Failed to create migration');
@@ -111,7 +173,7 @@ export class ${name}${timestamp} implements MigrationInterface {
111
173
 
112
174
  private static async runMigrations(): Promise<void> {
113
175
  const spinner = ora('Running migrations...').start();
114
-
176
+
115
177
  try {
116
178
  await TypeORMModule.initialize();
117
179
  await TypeORMModule.runMigrations();
@@ -124,7 +186,7 @@ export class ${name}${timestamp} implements MigrationInterface {
124
186
 
125
187
  private static async revertMigration(): Promise<void> {
126
188
  const spinner = ora('Reverting migration...').start();
127
-
189
+
128
190
  try {
129
191
  await TypeORMModule.initialize();
130
192
  await TypeORMModule.revertMigration();
@@ -137,7 +199,7 @@ export class ${name}${timestamp} implements MigrationInterface {
137
199
 
138
200
  private static async refreshMigrations(): Promise<void> {
139
201
  const spinner = ora('Refreshing migrations...').start();
140
-
202
+
141
203
  try {
142
204
  await TypeORMModule.initialize();
143
205
  await TypeORMModule.dropSchema();
@@ -156,7 +218,7 @@ export class ${name}${timestamp} implements MigrationInterface {
156
218
 
157
219
  private static async syncSchema(): Promise<void> {
158
220
  const spinner = ora('Synchronizing schema...').start();
159
-
221
+
160
222
  try {
161
223
  await TypeORMModule.initialize();
162
224
  await TypeORMModule.syncSchema();
@@ -169,7 +231,7 @@ export class ${name}${timestamp} implements MigrationInterface {
169
231
 
170
232
  private static async dropSchema(): Promise<void> {
171
233
  const spinner = ora('Dropping schema...').start();
172
-
234
+
173
235
  try {
174
236
  await TypeORMModule.initialize();
175
237
  await TypeORMModule.dropSchema();
@@ -182,23 +244,23 @@ export class ${name}${timestamp} implements MigrationInterface {
182
244
 
183
245
  private static async runSeeds(): Promise<void> {
184
246
  const spinner = ora('Running seeds...').start();
185
-
247
+
186
248
  try {
187
249
  const seedsDir = path.join(process.cwd(), 'dist', 'seeds');
188
-
250
+
189
251
  if (fs.existsSync(seedsDir)) {
190
252
  const files = fs.readdirSync(seedsDir);
191
-
253
+
192
254
  for (const file of files) {
193
255
  if (file.endsWith('.js')) {
194
256
  const seedModule = require(path.join(seedsDir, file));
195
- if (seedModule.default && typeof seedModule.default.run === 'function') {
257
+ if (seedModule.default?.run) {
196
258
  await seedModule.default.run();
197
259
  }
198
260
  }
199
261
  }
200
262
  }
201
-
263
+
202
264
  spinner.succeed('Seeds completed successfully');
203
265
  } catch (error) {
204
266
  spinner.fail('Seed failed');
@@ -208,7 +270,7 @@ export class ${name}${timestamp} implements MigrationInterface {
208
270
 
209
271
  private static async createSeed(name: string): Promise<void> {
210
272
  const spinner = ora('Creating seed...').start();
211
-
273
+
212
274
  try {
213
275
  const fileName = `${name}.seed.ts`;
214
276
  const filePath = path.join(process.cwd(), 'src', 'seeds', fileName);
@@ -216,18 +278,17 @@ export class ${name}${timestamp} implements MigrationInterface {
216
278
  const content = `export default class ${name}Seed {
217
279
  static async run() {
218
280
  console.log('Running ${name} seed...');
219
- // Add seed logic here
220
281
  }
221
282
  }
222
283
  `;
223
284
 
224
285
  await fs.ensureDir(path.dirname(filePath));
225
286
  await fs.writeFile(filePath, content);
226
-
287
+
227
288
  spinner.succeed(`Seed created: ${fileName}`);
228
289
  } catch (error) {
229
290
  spinner.fail('Failed to create seed');
230
291
  console.error(chalk.red(error));
231
292
  }
232
293
  }
233
- }
294
+ }
@@ -99,11 +99,15 @@ export class TypeORMModule {
99
99
 
100
100
  switch (dbType) {
101
101
  case "sqlite":
102
- case "better-sqlite3":
103
102
  return this.buildSqliteConfig(
104
103
  merged as Partial<SqliteConnectionOptions>,
105
104
  );
106
105
 
106
+ case "better-sqlite3":
107
+ return this.buildBetterSqlite3Config(
108
+ merged as Partial<BetterSqlite3ConnectionOptions>,
109
+ );
110
+
107
111
  case "mysql":
108
112
  case "mariadb":
109
113
  return this.buildMysqlConfig(merged as Partial<MysqlConnectionOptions>);
@@ -113,13 +117,108 @@ export class TypeORMModule {
113
117
  merged as Partial<PostgresConnectionOptions>,
114
118
  );
115
119
 
120
+ case "cockroachdb":
121
+ return this.buildCockroachConfig(
122
+ merged as Partial<CockroachConnectionOptions>,
123
+ );
124
+
125
+ case "mssql":
126
+ return this.buildSqlServerConfig(
127
+ merged as Partial<SqlServerConnectionOptions>,
128
+ );
129
+
130
+ case "sap":
131
+ return this.buildSapConfig(merged as Partial<SapConnectionOptions>);
132
+
133
+ case "oracle":
134
+ return this.buildOracleConfig(
135
+ merged as Partial<OracleConnectionOptions>,
136
+ );
137
+
138
+ case "mongodb":
139
+ return this.buildMongoConfig(merged as Partial<MongoConnectionOptions>);
140
+
141
+ case "aurora-mysql":
142
+ return this.buildAuroraMysqlConfig(
143
+ merged as Partial<AuroraMysqlConnectionOptions>,
144
+ );
145
+
146
+ case "aurora-postgres":
147
+ return this.buildAuroraPostgresConfig(
148
+ merged as Partial<AuroraPostgresConnectionOptions>,
149
+ );
150
+
151
+ case "cordova":
152
+ return this.buildCordovaConfig(
153
+ merged as Partial<CordovaConnectionOptions>,
154
+ );
155
+
156
+ case "nativescript":
157
+ return this.buildNativescriptConfig(
158
+ merged as Partial<NativescriptConnectionOptions>,
159
+ );
160
+
161
+ case "react-native":
162
+ return this.buildReactNativeConfig(
163
+ merged as Partial<ReactNativeConnectionOptions>,
164
+ );
165
+
166
+ case "sqljs":
167
+ return this.buildSqljsConfig(merged as Partial<SqljsConnectionOptions>);
168
+
169
+ case "expo":
170
+ return this.buildExpoConfig(merged as Partial<ExpoConnectionOptions>);
171
+
172
+ case "capacitor":
173
+ return this.buildCapacitorConfig(
174
+ merged as Partial<CapacitorConnectionOptions>,
175
+ );
176
+
177
+ case "spanner":
178
+ return this.buildSpannerConfig(
179
+ merged as Partial<SpannerConnectionOptions>,
180
+ );
181
+
116
182
  default:
117
183
  throw new Error(`Unsupported database type: ${String(dbType)}`);
118
184
  }
119
185
  }
120
186
 
121
187
  /* ======================================================
122
- * Builders
188
+ * Environment Variable Interpolation
189
+ * ====================================================== */
190
+ private static interpolateEnvVars(value: any): any {
191
+ if (typeof value === "string") {
192
+ // Match ${VAR_NAME} or {VAR_NAME}
193
+ return value.replace(/\$?\{([^}]+)\}/g, (match, varName) => {
194
+ const envValue = process.env[varName];
195
+ if (envValue === undefined) {
196
+ console.warn(
197
+ `Warning: Environment variable ${varName} is not defined, using empty string`,
198
+ );
199
+ return "";
200
+ }
201
+ return envValue;
202
+ });
203
+ }
204
+
205
+ if (Array.isArray(value)) {
206
+ return value.map((item) => this.interpolateEnvVars(item));
207
+ }
208
+
209
+ if (value !== null && typeof value === "object") {
210
+ const result: any = {};
211
+ for (const key in value) {
212
+ result[key] = this.interpolateEnvVars(value[key]);
213
+ }
214
+ return result;
215
+ }
216
+
217
+ return value;
218
+ }
219
+
220
+ /* ======================================================
221
+ * Builders - SQL Databases
123
222
  * ====================================================== */
124
223
  private static buildSqliteConfig(
125
224
  config: Partial<SqliteConnectionOptions>,
@@ -136,11 +235,26 @@ export class TypeORMModule {
136
235
  };
137
236
  }
138
237
 
238
+ private static buildBetterSqlite3Config(
239
+ config: Partial<BetterSqlite3ConnectionOptions>,
240
+ ): BetterSqlite3ConnectionOptions {
241
+ return {
242
+ type: "better-sqlite3",
243
+ database: config.database ?? "database.sqlite",
244
+ synchronize: false,
245
+ logging: false,
246
+ entities: config.entities ?? ["dist/**/*.entity.js"],
247
+ migrations: config.migrations ?? ["dist/migrations/**/*.js"],
248
+ subscribers: [],
249
+ ...config,
250
+ };
251
+ }
252
+
139
253
  private static buildMysqlConfig(
140
254
  config: Partial<MysqlConnectionOptions>,
141
255
  ): MysqlConnectionOptions {
142
256
  return {
143
- type: config.type ?? "mysql",
257
+ type: (config.type as "mysql" | "mariadb") ?? "mysql",
144
258
  host: config.host ?? "localhost",
145
259
  port: config.port ?? 3306,
146
260
  username: config.username ?? "root",
@@ -172,6 +286,302 @@ export class TypeORMModule {
172
286
  };
173
287
  }
174
288
 
289
+ private static buildCockroachConfig(
290
+ config: Partial<CockroachConnectionOptions>,
291
+ ): CockroachConnectionOptions {
292
+ return {
293
+ type: "cockroachdb",
294
+ host: config.host ?? "localhost",
295
+ port: config.port ?? 26257,
296
+ username: config.username ?? "root",
297
+ password: config.password ?? "",
298
+ database: config.database ?? "defaultdb",
299
+ synchronize: false,
300
+ logging: false,
301
+ entities: config.entities ?? ["dist/**/*.entity.js"],
302
+ migrations: config.migrations ?? ["dist/migrations/**/*.js"],
303
+ timeTravelQueries: config.timeTravelQueries ?? false,
304
+ ...config,
305
+ };
306
+ }
307
+
308
+ private static buildSqlServerConfig(
309
+ config: Partial<SqlServerConnectionOptions>,
310
+ ): SqlServerConnectionOptions {
311
+ return {
312
+ type: "mssql",
313
+ host: config.host ?? "localhost",
314
+ port: config.port ?? 1433,
315
+ username: config.username ?? "sa",
316
+ password: config.password ?? "",
317
+ database: config.database ?? "master",
318
+ synchronize: false,
319
+ logging: false,
320
+ entities: config.entities ?? ["dist/**/*.entity.js"],
321
+ migrations: config.migrations ?? ["dist/migrations/**/*.js"],
322
+ options: config.options,
323
+ ...config,
324
+ };
325
+ }
326
+
327
+ private static buildOracleConfig(
328
+ config: Partial<OracleConnectionOptions>,
329
+ ): OracleConnectionOptions {
330
+ return {
331
+ type: "oracle",
332
+ host: config.host ?? "localhost",
333
+ port: config.port ?? 1521,
334
+ username: config.username ?? "system",
335
+ password: config.password ?? "",
336
+ sid: config.sid ?? "xe",
337
+ synchronize: false,
338
+ logging: false,
339
+ entities: config.entities ?? ["dist/**/*.entity.js"],
340
+ migrations: config.migrations ?? ["dist/migrations/**/*.js"],
341
+ ...config,
342
+ };
343
+ }
344
+
345
+ private static buildSapConfig(
346
+ config: Partial<SapConnectionOptions>,
347
+ ): SapConnectionOptions {
348
+ return {
349
+ type: "sap",
350
+ host: config.host ?? "localhost",
351
+ port: config.port ?? 30015,
352
+ username: config.username ?? "SYSTEM",
353
+ password: config.password ?? "",
354
+ schema: config.schema,
355
+ synchronize: false,
356
+ logging: false,
357
+ entities: config.entities ?? ["dist/**/*.entity.js"],
358
+ migrations: config.migrations ?? ["dist/migrations/**/*.js"],
359
+ ...config,
360
+ };
361
+ }
362
+
363
+ /* ======================================================
364
+ * Builders - Cloud/Serverless Databases
365
+ * ====================================================== */
366
+ private static buildAuroraMysqlConfig(
367
+ config: Partial<AuroraMysqlConnectionOptions>,
368
+ ): AuroraMysqlConnectionOptions {
369
+ if (!config.region) {
370
+ throw new Error("AuroraMysqlConnectionOptions: region is required");
371
+ }
372
+ if (!config.secretArn) {
373
+ throw new Error("AuroraMysqlConnectionOptions: secretArn is required");
374
+ }
375
+ if (!config.resourceArn) {
376
+ throw new Error("AuroraMysqlConnectionOptions: resourceArn is required");
377
+ }
378
+
379
+ return {
380
+ type: "aurora-mysql",
381
+ region: config.region,
382
+ secretArn: config.secretArn,
383
+ resourceArn: config.resourceArn,
384
+ database: config.database ?? "app",
385
+ host: config.host ?? "localhost",
386
+ port: config.port ?? 3306,
387
+ username: config.username ?? "root",
388
+ password: config.password ?? "",
389
+ synchronize: false,
390
+ logging: false,
391
+ entities: config.entities ?? ["dist/**/*.entity.js"],
392
+ migrations: config.migrations ?? ["dist/migrations/**/*.js"],
393
+ driver: config.driver,
394
+ serviceConfigOptions: config.serviceConfigOptions,
395
+ formatOptions: config.formatOptions,
396
+ legacySpatialSupport: config.legacySpatialSupport,
397
+ ssl: config.ssl,
398
+ };
399
+ }
400
+
401
+ private static buildAuroraPostgresConfig(
402
+ config: Partial<AuroraPostgresConnectionOptions>,
403
+ ): AuroraPostgresConnectionOptions {
404
+ if (!config.region) {
405
+ throw new Error("AuroraPostgresConnectionOptions: region is required");
406
+ }
407
+ if (!config.secretArn) {
408
+ throw new Error("AuroraPostgresConnectionOptions: secretArn is required");
409
+ }
410
+ if (!config.resourceArn) {
411
+ throw new Error(
412
+ "AuroraPostgresConnectionOptions: resourceArn is required",
413
+ );
414
+ }
415
+
416
+ return {
417
+ type: "aurora-postgres",
418
+ region: config.region,
419
+ secretArn: config.secretArn,
420
+ resourceArn: config.resourceArn,
421
+ database: config.database ?? "app",
422
+ synchronize: false,
423
+ logging: false,
424
+ entities: config.entities ?? ["dist/**/*.entity.js"],
425
+ migrations: config.migrations ?? ["dist/migrations/**/*.js"],
426
+ driver: config.driver,
427
+ transformParameters: config.transformParameters,
428
+ poolErrorHandler: config.poolErrorHandler,
429
+ serviceConfigOptions: config.serviceConfigOptions,
430
+ formatOptions: config.formatOptions,
431
+ };
432
+ }
433
+
434
+ private static buildSpannerConfig(
435
+ config: Partial<SpannerConnectionOptions>,
436
+ ): SpannerConnectionOptions {
437
+ return {
438
+ type: "spanner",
439
+ projectId: config.projectId ?? "",
440
+ instanceId: config.instanceId ?? "",
441
+ databaseId: config.databaseId ?? "",
442
+ synchronize: false,
443
+ logging: false,
444
+ entities: config.entities ?? ["dist/**/*.entity.js"],
445
+ migrations: config.migrations ?? ["dist/migrations/**/*.js"],
446
+ ...config,
447
+ };
448
+ }
449
+
450
+ /* ======================================================
451
+ * Builders - NoSQL Databases
452
+ * ====================================================== */
453
+ private static buildMongoConfig(
454
+ config: Partial<MongoConnectionOptions>,
455
+ ): MongoConnectionOptions {
456
+ return {
457
+ type: "mongodb",
458
+ host: config.host ?? "localhost",
459
+ port: config.port ?? 27017,
460
+ database: config.database ?? "app",
461
+ synchronize: false,
462
+ logging: false,
463
+ entities: config.entities ?? ["dist/**/*.entity.js"],
464
+ ...config,
465
+ };
466
+ }
467
+
468
+ /* ======================================================
469
+ * Builders - Mobile/Embedded Databases
470
+ * ====================================================== */
471
+ private static buildCordovaConfig(
472
+ config: Partial<CordovaConnectionOptions>,
473
+ ): CordovaConnectionOptions {
474
+ return {
475
+ type: "cordova",
476
+ database: config.database ?? "app.db",
477
+ location: config.location ?? "default",
478
+ synchronize: false,
479
+ logging: false,
480
+ entities: config.entities ?? ["dist/**/*.entity.js"],
481
+ migrations: config.migrations ?? ["dist/migrations/**/*.js"],
482
+ ...config,
483
+ };
484
+ }
485
+
486
+ private static buildNativescriptConfig(
487
+ config: Partial<NativescriptConnectionOptions>,
488
+ ): NativescriptConnectionOptions {
489
+ if (!config.driver) {
490
+ throw new Error(
491
+ "NativescriptConnectionOptions: driver is required (e.g. require('nativescript-sqlite'))",
492
+ );
493
+ }
494
+
495
+ return {
496
+ type: "nativescript",
497
+ database: config.database ?? "app.db",
498
+ driver: config.driver,
499
+ readOnly: config.readOnly ?? false,
500
+ key: config.key,
501
+ multithreading: config.multithreading ?? false,
502
+ migrate: config.migrate ?? false,
503
+ iosFlags: config.iosFlags,
504
+ androidFlags: config.androidFlags,
505
+ synchronize: false,
506
+ logging: false,
507
+ entities: config.entities ?? ["dist/**/*.entity.js"],
508
+ migrations: config.migrations ?? ["dist/migrations/**/*.js"],
509
+ ...config, // optional fields only
510
+ };
511
+ }
512
+
513
+ private static buildReactNativeConfig(
514
+ config: Partial<ReactNativeConnectionOptions>,
515
+ ): ReactNativeConnectionOptions {
516
+ return {
517
+ type: "react-native",
518
+ database: config.database ?? "app.db",
519
+ location: config.location ?? "default",
520
+ synchronize: false,
521
+ logging: false,
522
+ entities: config.entities ?? ["dist/**/*.entity.js"],
523
+ migrations: config.migrations ?? ["dist/migrations/**/*.js"],
524
+ ...config,
525
+ };
526
+ }
527
+
528
+ private static buildSqljsConfig(
529
+ config: Partial<SqljsConnectionOptions>,
530
+ ): SqljsConnectionOptions {
531
+ return {
532
+ type: "sqljs",
533
+ autoSave: config.autoSave ?? true,
534
+ location: config.location ?? "browser",
535
+ synchronize: false,
536
+ logging: false,
537
+ entities: config.entities ?? ["dist/**/*.entity.js"],
538
+ migrations: config.migrations ?? ["dist/migrations/**/*.js"],
539
+ ...config,
540
+ };
541
+ }
542
+
543
+ private static buildExpoConfig(
544
+ config: Partial<ExpoConnectionOptions>,
545
+ ): ExpoConnectionOptions {
546
+ if (!config.driver) {
547
+ throw new Error(
548
+ "ExpoConnectionOptions: driver is required (e.g. require('expo-sqlite'))",
549
+ );
550
+ }
551
+
552
+ return {
553
+ type: "expo",
554
+ database: config.database ?? "app.db",
555
+ driver: config.driver, // ✅ guaranteed
556
+ synchronize: false,
557
+ logging: false,
558
+ entities: config.entities ?? ["dist/**/*.entity.js"],
559
+ migrations: config.migrations ?? ["dist/migrations/**/*.js"],
560
+ ...config, // optional fields
561
+ };
562
+ }
563
+
564
+ private static buildCapacitorConfig(
565
+ config: Partial<CapacitorConnectionOptions>,
566
+ ): CapacitorConnectionOptions {
567
+ if (!config.driver) {
568
+ throw new Error(
569
+ "CapacitorConnectionOptions: driver is required (e.g. new SQLiteConnection(CapacitorSQLite))",
570
+ );
571
+ }
572
+
573
+ return {
574
+ type: "capacitor",
575
+ database: config.database ?? "app.db",
576
+ driver: config.driver, // ✅ guaranteed
577
+ synchronize: false,
578
+ logging: false,
579
+ entities: config.entities ?? ["dist/**/*.entity.js"],
580
+ migrations: config.migrations ?? ["dist/migrations/**/*.js"],
581
+ ...config, // optional fields
582
+ };
583
+ }
584
+
175
585
  /* ======================================================
176
586
  * fragment.json loader
177
587
  * ====================================================== */
@@ -183,7 +593,10 @@ export class TypeORMModule {
183
593
  }
184
594
 
185
595
  const raw = JSON.parse(fs.readFileSync(configPath, "utf-8"));
186
- return raw.database ?? {};
596
+ const dbConfig = raw.database ?? {};
597
+
598
+ // Interpolate environment variables
599
+ return this.interpolateEnvVars(dbConfig);
187
600
  }
188
601
 
189
602
  /* ======================================================