@db-bridge/core 1.1.4 → 1.1.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.
package/dist/index.d.ts CHANGED
@@ -1279,6 +1279,7 @@ interface MigrationFile {
1279
1279
  path: string;
1280
1280
  timestamp: string;
1281
1281
  description: string;
1282
+ prefix?: string;
1282
1283
  }
1283
1284
  interface Migration {
1284
1285
  name: string;
@@ -1360,7 +1361,7 @@ declare class MigrationLoader {
1360
1361
  getMigrationFiles(): Promise<MigrationFile[]>;
1361
1362
  calculateChecksum(file: MigrationFile): Promise<string>;
1362
1363
  calculateAllChecksums(): Promise<Map<string, string>>;
1363
- static generateFilename(description: string): string;
1364
+ static generateFilename(description: string, prefix?: string): string;
1364
1365
  static getMigrationTemplate(name: string): string;
1365
1366
  }
1366
1367
 
@@ -1438,7 +1439,7 @@ declare class SeederLoader {
1438
1439
  loadAll(): Promise<SeederFile[]>;
1439
1440
  load(seederPath: string): Promise<Seeder>;
1440
1441
  private getSeederName;
1441
- static generateFilename(name: string): string;
1442
+ static generateFilename(name: string, prefix?: string): string;
1442
1443
  static getSeederTemplate(name: string): string;
1443
1444
  }
1444
1445
 
package/dist/index.js CHANGED
@@ -2109,7 +2109,7 @@ var MigrationRunner = class {
2109
2109
  };
2110
2110
  }
2111
2111
  };
2112
- var MIGRATION_PATTERN = /^(\d{14})_(.+)\.(ts|js|mjs)$/;
2112
+ var MIGRATION_PATTERN = /^(?:([_a-z]+)_)?(\d{14})_(.+)\.(ts|js|mjs)$/;
2113
2113
  var MigrationLoader = class {
2114
2114
  directory;
2115
2115
  extensions;
@@ -2136,12 +2136,13 @@ var MigrationLoader = class {
2136
2136
  if (!match) {
2137
2137
  continue;
2138
2138
  }
2139
- const [, timestamp, description] = match;
2139
+ const [, prefix, timestamp, description] = match;
2140
2140
  files.push({
2141
2141
  name: basename(entry.name, ext),
2142
2142
  path: join(this.directory, entry.name),
2143
2143
  timestamp,
2144
- description: description.replaceAll("_", " ")
2144
+ description: description.replaceAll("_", " "),
2145
+ prefix
2145
2146
  });
2146
2147
  }
2147
2148
  files.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
@@ -2218,8 +2219,10 @@ var MigrationLoader = class {
2218
2219
  }
2219
2220
  /**
2220
2221
  * Generate a new migration filename
2222
+ * @param description - Migration description
2223
+ * @param prefix - Optional prefix (e.g., 'auth' -> auth_20250119_xxx.ts)
2221
2224
  */
2222
- static generateFilename(description) {
2225
+ static generateFilename(description, prefix) {
2223
2226
  const now = /* @__PURE__ */ new Date();
2224
2227
  const timestamp = [
2225
2228
  now.getFullYear(),
@@ -2230,7 +2233,8 @@ var MigrationLoader = class {
2230
2233
  String(now.getSeconds()).padStart(2, "0")
2231
2234
  ].join("");
2232
2235
  const sanitizedDescription = description.toLowerCase().replaceAll(/[^\da-z]+/g, "_").replaceAll(/^_+|_+$/g, "");
2233
- return `${timestamp}_${sanitizedDescription}.ts`;
2236
+ const sanitizedPrefix = prefix ? prefix.toLowerCase().replaceAll(/[^\da-z]+/g, "_").replaceAll(/^_+|_+$/g, "") : null;
2237
+ return sanitizedPrefix ? `${sanitizedPrefix}_${timestamp}_${sanitizedDescription}.ts` : `${timestamp}_${sanitizedDescription}.ts`;
2234
2238
  }
2235
2239
  /**
2236
2240
  * Get migration template content
@@ -4512,10 +4516,13 @@ var SeederLoader = class {
4512
4516
  }
4513
4517
  /**
4514
4518
  * Generate a new seeder filename
4519
+ * @param name - Seeder name
4520
+ * @param prefix - Optional prefix (e.g., 'auth' -> auth_users_seeder.ts)
4515
4521
  */
4516
- static generateFilename(name) {
4522
+ static generateFilename(name, prefix) {
4517
4523
  const snakeName = name.replaceAll(/([a-z])([A-Z])/g, "$1_$2").replaceAll(/[\s-]+/g, "_").toLowerCase();
4518
- return `${snakeName}_seeder.ts`;
4524
+ const sanitizedPrefix = prefix ? prefix.toLowerCase().replaceAll(/[^\da-z]+/g, "_").replaceAll(/^_+|_+$/g, "") : null;
4525
+ return sanitizedPrefix ? `${sanitizedPrefix}_${snakeName}_seeder.ts` : `${snakeName}_seeder.ts`;
4519
4526
  }
4520
4527
  /**
4521
4528
  * Get seeder template