@geekmidas/testkit 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/{Factory-C6W78ulZ.d.mts → Factory-CVR3GdkW.d.mts} +2 -2
  3. package/dist/{Factory-C6W78ulZ.d.mts.map → Factory-CVR3GdkW.d.mts.map} +1 -1
  4. package/dist/{Factory-D28yjUj5.d.cts → Factory-Cwzho3c8.d.cts} +2 -2
  5. package/dist/{Factory-D28yjUj5.d.cts.map → Factory-Cwzho3c8.d.cts.map} +1 -1
  6. package/dist/Factory.d.cts +2 -2
  7. package/dist/Factory.d.mts +2 -2
  8. package/dist/{KyselyFactory-Cc2UmOJk.d.mts → KyselyFactory-DRlMv-WT.d.mts} +3 -3
  9. package/dist/{KyselyFactory-Cc2UmOJk.d.mts.map → KyselyFactory-DRlMv-WT.d.mts.map} +1 -1
  10. package/dist/{KyselyFactory-OUH03l2q.d.cts → KyselyFactory-hMcVtvJq.d.cts} +3 -3
  11. package/dist/{KyselyFactory-OUH03l2q.d.cts.map → KyselyFactory-hMcVtvJq.d.cts.map} +1 -1
  12. package/dist/KyselyFactory.d.cts +3 -3
  13. package/dist/KyselyFactory.d.mts +3 -3
  14. package/dist/{ObjectionFactory-B1WkcfZY.d.cts → ObjectionFactory-DW-qwnqO.d.cts} +3 -3
  15. package/dist/{ObjectionFactory-B1WkcfZY.d.cts.map → ObjectionFactory-DW-qwnqO.d.cts.map} +1 -1
  16. package/dist/{ObjectionFactory-BYnPr9ZP.d.mts → ObjectionFactory-DkJUf-uM.d.mts} +3 -3
  17. package/dist/{ObjectionFactory-BYnPr9ZP.d.mts.map → ObjectionFactory-DkJUf-uM.d.mts.map} +1 -1
  18. package/dist/ObjectionFactory.d.cts +3 -3
  19. package/dist/ObjectionFactory.d.mts +3 -3
  20. package/dist/{PostgresKyselyMigrator-B4pScubb.mjs → PostgresKyselyMigrator-BIKd7G5C.mjs} +16 -3
  21. package/dist/PostgresKyselyMigrator-BIKd7G5C.mjs.map +1 -0
  22. package/dist/{PostgresKyselyMigrator-CBltSOq5.d.cts → PostgresKyselyMigrator-CTNftoZK.d.cts} +16 -2
  23. package/dist/PostgresKyselyMigrator-CTNftoZK.d.cts.map +1 -0
  24. package/dist/{PostgresKyselyMigrator-C7ljZYvq.cjs → PostgresKyselyMigrator-CqNs3qX8.cjs} +16 -3
  25. package/dist/PostgresKyselyMigrator-CqNs3qX8.cjs.map +1 -0
  26. package/dist/{PostgresKyselyMigrator-DrVWncqd.d.mts → PostgresKyselyMigrator-x0uvWs3U.d.mts} +16 -2
  27. package/dist/PostgresKyselyMigrator-x0uvWs3U.d.mts.map +1 -0
  28. package/dist/PostgresKyselyMigrator.cjs +2 -2
  29. package/dist/PostgresKyselyMigrator.d.cts +2 -2
  30. package/dist/PostgresKyselyMigrator.d.mts +2 -2
  31. package/dist/PostgresKyselyMigrator.mjs +2 -2
  32. package/dist/{PostgresMigrator-Bres0U6E.d.cts → PostgresMigrator-C_QQ6q35.d.mts} +15 -2
  33. package/dist/PostgresMigrator-C_QQ6q35.d.mts.map +1 -0
  34. package/dist/{PostgresMigrator-S-YYosAC.d.mts → PostgresMigrator-CeYy-eHF.d.cts} +15 -2
  35. package/dist/PostgresMigrator-CeYy-eHF.d.cts.map +1 -0
  36. package/dist/{PostgresMigrator-DcP1o-T6.mjs → PostgresMigrator-DVAY04qN.mjs} +16 -2
  37. package/dist/PostgresMigrator-DVAY04qN.mjs.map +1 -0
  38. package/dist/{PostgresMigrator-CHiBYEg_.cjs → PostgresMigrator-M9jpzOvN.cjs} +16 -2
  39. package/dist/PostgresMigrator-M9jpzOvN.cjs.map +1 -0
  40. package/dist/PostgresMigrator.cjs +1 -1
  41. package/dist/PostgresMigrator.d.cts +1 -1
  42. package/dist/PostgresMigrator.d.mts +1 -1
  43. package/dist/PostgresMigrator.mjs +1 -1
  44. package/dist/{PostgresObjectionMigrator-CPfBAP7r.d.cts → PostgresObjectionMigrator-1j6YIB1c.d.mts} +2 -2
  45. package/dist/{PostgresObjectionMigrator-CPfBAP7r.d.cts.map → PostgresObjectionMigrator-1j6YIB1c.d.mts.map} +1 -1
  46. package/dist/{PostgresObjectionMigrator-DVEqB5tp.d.mts → PostgresObjectionMigrator-DHVC9h_P.d.cts} +2 -2
  47. package/dist/{PostgresObjectionMigrator-DVEqB5tp.d.mts.map → PostgresObjectionMigrator-DHVC9h_P.d.cts.map} +1 -1
  48. package/dist/{PostgresObjectionMigrator-BXLAVVwm.cjs → PostgresObjectionMigrator-DSaPhwjY.cjs} +2 -2
  49. package/dist/{PostgresObjectionMigrator-BXLAVVwm.cjs.map → PostgresObjectionMigrator-DSaPhwjY.cjs.map} +1 -1
  50. package/dist/{PostgresObjectionMigrator-BJ5X48U8.mjs → PostgresObjectionMigrator-DjPKdUbm.mjs} +2 -2
  51. package/dist/{PostgresObjectionMigrator-BJ5X48U8.mjs.map → PostgresObjectionMigrator-DjPKdUbm.mjs.map} +1 -1
  52. package/dist/PostgresObjectionMigrator.cjs +2 -2
  53. package/dist/PostgresObjectionMigrator.d.cts +2 -2
  54. package/dist/PostgresObjectionMigrator.d.mts +2 -2
  55. package/dist/PostgresObjectionMigrator.mjs +2 -2
  56. package/dist/better-auth.d.cts +2 -2
  57. package/dist/better-auth.d.mts +2 -2
  58. package/dist/{directory-CVrfTq1I.d.mts → directory-CYXmolu1.d.mts} +3 -3
  59. package/dist/{directory-CVrfTq1I.d.mts.map → directory-CYXmolu1.d.mts.map} +1 -1
  60. package/dist/{directory-DGOcVlKD.d.cts → directory-DAnMWi50.d.cts} +3 -3
  61. package/dist/{directory-DGOcVlKD.d.cts.map → directory-DAnMWi50.d.cts.map} +1 -1
  62. package/dist/{faker-CbYiF-8_.d.cts → faker-Dg3trU4a.d.cts} +3 -3
  63. package/dist/{faker-CbYiF-8_.d.cts.map → faker-Dg3trU4a.d.cts.map} +1 -1
  64. package/dist/{faker-D9gz7KjY.d.mts → faker-DsYCplsG.d.mts} +3 -3
  65. package/dist/{faker-D9gz7KjY.d.mts.map → faker-DsYCplsG.d.mts.map} +1 -1
  66. package/dist/faker.d.cts +1 -1
  67. package/dist/faker.d.mts +1 -1
  68. package/dist/initScript.cjs +95 -0
  69. package/dist/initScript.cjs.map +1 -0
  70. package/dist/initScript.d.cts +45 -0
  71. package/dist/initScript.d.cts.map +1 -0
  72. package/dist/initScript.d.mts +45 -0
  73. package/dist/initScript.d.mts.map +1 -0
  74. package/dist/initScript.mjs +93 -0
  75. package/dist/initScript.mjs.map +1 -0
  76. package/dist/kysely.cjs +2 -2
  77. package/dist/kysely.d.cts +5 -5
  78. package/dist/kysely.d.mts +5 -5
  79. package/dist/kysely.mjs +2 -2
  80. package/dist/objection.cjs +2 -2
  81. package/dist/objection.d.cts +5 -5
  82. package/dist/objection.d.mts +5 -5
  83. package/dist/objection.mjs +2 -2
  84. package/dist/os/directory.d.cts +1 -1
  85. package/dist/os/directory.d.mts +1 -1
  86. package/dist/os/index.d.cts +1 -1
  87. package/dist/os/index.d.mts +1 -1
  88. package/package.json +6 -1
  89. package/src/PostgresKyselyMigrator.ts +15 -1
  90. package/src/PostgresMigrator.ts +19 -2
  91. package/src/__tests__/PostgresKyselyMigrator.spec.ts +104 -0
  92. package/src/__tests__/PostgresMigrator.spec.ts +109 -0
  93. package/src/__tests__/initScript.spec.ts +308 -0
  94. package/src/initScript.ts +119 -0
  95. package/dist/PostgresKyselyMigrator-B4pScubb.mjs.map +0 -1
  96. package/dist/PostgresKyselyMigrator-C7ljZYvq.cjs.map +0 -1
  97. package/dist/PostgresKyselyMigrator-CBltSOq5.d.cts.map +0 -1
  98. package/dist/PostgresKyselyMigrator-DrVWncqd.d.mts.map +0 -1
  99. package/dist/PostgresMigrator-Bres0U6E.d.cts.map +0 -1
  100. package/dist/PostgresMigrator-CHiBYEg_.cjs.map +0 -1
  101. package/dist/PostgresMigrator-DcP1o-T6.mjs.map +0 -1
  102. package/dist/PostgresMigrator-S-YYosAC.d.mts.map +0 -1
@@ -55,6 +55,17 @@ const logger = console;
55
55
  * const migrator = new MyMigrator('postgresql://localhost:5432/test_db');
56
56
  * const cleanup = await migrator.start();
57
57
  *
58
+ * // With afterCreate hook (e.g. run init script to create per-app users)
59
+ * import { runInitScript } from '@geekmidas/testkit/postgres';
60
+ *
61
+ * const migrator = new MyMigrator(
62
+ * 'postgresql://localhost:5432/test_db',
63
+ * async (uri) => {
64
+ * await runInitScript('docker/postgres/init.sh', uri, env);
65
+ * },
66
+ * );
67
+ * const cleanup = await migrator.start();
68
+ *
58
69
  * // Run tests...
59
70
  *
60
71
  * // Clean up
@@ -66,9 +77,11 @@ var PostgresMigrator = class PostgresMigrator {
66
77
  * Creates a new PostgresMigrator instance.
67
78
  *
68
79
  * @param uri - PostgreSQL connection URI
80
+ * @param afterCreate - Optional hook called after database creation but before migrations
69
81
  */
70
- constructor(uri) {
82
+ constructor(uri, afterCreate) {
71
83
  this.uri = uri;
84
+ this.afterCreate = afterCreate;
72
85
  }
73
86
  /**
74
87
  * Creates a PostgreSQL database if it doesn't already exist.
@@ -137,6 +150,7 @@ var PostgresMigrator = class PostgresMigrator {
137
150
  const { database, db } = await setupClient(this.uri);
138
151
  try {
139
152
  await PostgresMigrator.create(this.uri);
153
+ if (this.afterCreate) await this.afterCreate(this.uri);
140
154
  await this.migrate();
141
155
  logger.log(`Migrating database: ${database}`);
142
156
  } finally {
@@ -155,4 +169,4 @@ Object.defineProperty(exports, 'PostgresMigrator', {
155
169
  return PostgresMigrator;
156
170
  }
157
171
  });
158
- //# sourceMappingURL=PostgresMigrator-CHiBYEg_.cjs.map
172
+ //# sourceMappingURL=PostgresMigrator-M9jpzOvN.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PostgresMigrator-M9jpzOvN.cjs","names":["uri: string","afterCreate?: (uri: string) => Promise<void>","error: any"],"sources":["../src/PostgresMigrator.ts"],"sourcesContent":["import pg from 'pg';\n\nconst { Client } = pg;\n\n/**\n * Creates a PostgreSQL client connected to the 'postgres' database.\n * Extracts connection details from the provided URI.\n *\n * @param uri - PostgreSQL connection URI\n * @returns Object containing the target database name and client instance\n *\n * @example\n * ```typescript\n * const { database, db } = await setupClient('postgresql://user:pass@localhost:5432/mydb');\n * // database = 'mydb'\n * // db = Client instance connected to 'postgres' database\n * ```\n */\nasync function setupClient(uri: string) {\n\tconst url = new URL(uri);\n\n\tconst db = new Client({\n\t\tuser: url.username,\n\t\tpassword: url.password,\n\t\thost: url.hostname,\n\t\tport: parseInt(url.port, 10),\n\t\tdatabase: 'postgres',\n\t});\n\n\tlet database = url.pathname.slice(1);\n\tif (database.includes('?')) {\n\t\tdatabase = database.substring(0, database.indexOf('?'));\n\t}\n\treturn { database, db };\n}\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * Abstract base class for PostgreSQL database migration utilities.\n * Provides database creation, migration, and cleanup functionality for testing.\n * Subclasses must implement the migrate() method to define migration logic.\n *\n * @example\n * ```typescript\n * class MyMigrator extends PostgresMigrator {\n * async migrate(): Promise<void> {\n * // Run your migrations here\n * await this.runMigrations();\n * }\n * }\n *\n * // Use in tests\n * const migrator = new MyMigrator('postgresql://localhost:5432/test_db');\n * const cleanup = await migrator.start();\n *\n * // With afterCreate hook (e.g. run init script to create per-app users)\n * import { runInitScript } from '@geekmidas/testkit/postgres';\n *\n * const migrator = new MyMigrator(\n * 'postgresql://localhost:5432/test_db',\n * async (uri) => {\n * await runInitScript('docker/postgres/init.sh', uri, env);\n * },\n * );\n * const cleanup = await migrator.start();\n *\n * // Run tests...\n *\n * // Clean up\n * await cleanup();\n * ```\n */\nexport abstract class PostgresMigrator {\n\t/**\n\t * Creates a new PostgresMigrator instance.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t * @param afterCreate - Optional hook called after database creation but before migrations\n\t */\n\tconstructor(\n\t\tprivate uri: string,\n\t\tprivate afterCreate?: (uri: string) => Promise<void>,\n\t) {}\n\n\t/**\n\t * Abstract method to be implemented by subclasses.\n\t * Should contain the migration logic for setting up database schema.\n\t *\n\t * @returns Promise that resolves when migrations are complete\n\t */\n\tabstract migrate(): Promise<void>;\n\n\t/**\n\t * Creates a PostgreSQL database if it doesn't already exist.\n\t * Connects to the 'postgres' database to check and create the target database.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t * @returns Object indicating whether the database already existed\n\t * @private\n\t */\n\tprivate static async create(\n\t\turi: string,\n\t): Promise<{ alreadyExisted: boolean }> {\n\t\tconst { database, db } = await setupClient(uri);\n\t\ttry {\n\t\t\tawait db.connect();\n\t\t\tconst result = await db.query(\n\t\t\t\t`SELECT * FROM pg_catalog.pg_database WHERE datname = '${database}'`,\n\t\t\t);\n\n\t\t\tif (result.rowCount === 0) {\n\t\t\t\ttry {\n\t\t\t\t\tawait db.query(`CREATE DATABASE \"${database}\"`);\n\t\t\t\t} catch (error: any) {\n\t\t\t\t\t// 42P04 = duplicate_database — another process created it between our check and create\n\t\t\t\t\tif (error?.code === '42P04') {\n\t\t\t\t\t\treturn { alreadyExisted: true };\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\talreadyExisted: result.rowCount ? result.rowCount > 0 : false,\n\t\t\t};\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\t}\n\n\t/**\n\t * Drops a PostgreSQL database.\n\t * Used for cleanup after tests are complete.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t * @throws Error if database cannot be dropped\n\t * @private\n\t */\n\tprivate static async drop(uri: string): Promise<void> {\n\t\tconst { database, db } = await setupClient(uri);\n\t\ttry {\n\t\t\tawait db.connect();\n\t\t\tawait db.query(`DROP DATABASE \"${database}\"`);\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\t}\n\n\t/**\n\t * Starts the migration process by creating the database and running migrations.\n\t * Returns a cleanup function that will drop the database when called.\n\t *\n\t * @returns Async cleanup function that drops the created database\n\t *\n\t * @example\n\t * ```typescript\n\t * const migrator = new MyMigrator('postgresql://localhost:5432/test_db');\n\t *\n\t * // Start migrations and get cleanup function\n\t * const cleanup = await migrator.start();\n\t *\n\t * try {\n\t * // Run your tests here\n\t * await runTests();\n\t * } finally {\n\t * // Always clean up\n\t * await cleanup();\n\t * }\n\t * ```\n\t */\n\tasync start() {\n\t\tconst { database, db } = await setupClient(this.uri);\n\t\ttry {\n\t\t\tawait PostgresMigrator.create(this.uri);\n\t\t\tif (this.afterCreate) {\n\t\t\t\tawait this.afterCreate(this.uri);\n\t\t\t}\n\t\t\tawait this.migrate();\n\t\t\tlogger.log(`Migrating database: ${database}`);\n\t\t\t// Example: await db.query('CREATE TABLE example (id SERIAL PRIMARY KEY)');\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\n\t\treturn async () => {\n\t\t\tawait PostgresMigrator.drop(this.uri);\n\t\t};\n\t}\n}\n"],"mappings":";;;;AAEA,MAAM,EAAE,QAAQ,GAAG;;;;;;;;;;;;;;;AAgBnB,eAAe,YAAYA,KAAa;CACvC,MAAM,MAAM,IAAI,IAAI;CAEpB,MAAM,KAAK,IAAI,OAAO;EACrB,MAAM,IAAI;EACV,UAAU,IAAI;EACd,MAAM,IAAI;EACV,MAAM,SAAS,IAAI,MAAM,GAAG;EAC5B,UAAU;CACV;CAED,IAAI,WAAW,IAAI,SAAS,MAAM,EAAE;AACpC,KAAI,SAAS,SAAS,IAAI,CACzB,YAAW,SAAS,UAAU,GAAG,SAAS,QAAQ,IAAI,CAAC;AAExD,QAAO;EAAE;EAAU;CAAI;AACvB;;;;AAKD,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCf,IAAsB,mBAAtB,MAAsB,iBAAiB;;;;;;;CAOtC,YACSA,KACAC,aACP;EAFO;EACA;CACL;;;;;;;;;CAkBJ,aAAqB,OACpBD,KACuC;EACvC,MAAM,EAAE,UAAU,IAAI,GAAG,MAAM,YAAY,IAAI;AAC/C,MAAI;AACH,SAAM,GAAG,SAAS;GAClB,MAAM,SAAS,MAAM,GAAG,OACtB,wDAAwD,SAAS,GAClE;AAED,OAAI,OAAO,aAAa,EACvB,KAAI;AACH,UAAM,GAAG,OAAO,mBAAmB,SAAS,GAAG;GAC/C,SAAQE,OAAY;AAEpB,QAAI,OAAO,SAAS,QACnB,QAAO,EAAE,gBAAgB,KAAM;AAEhC,UAAM;GACN;AAGF,UAAO,EACN,gBAAgB,OAAO,WAAW,OAAO,WAAW,IAAI,MACxD;EACD,UAAS;AACT,SAAM,GAAG,KAAK;EACd;CACD;;;;;;;;;CAUD,aAAqB,KAAKF,KAA4B;EACrD,MAAM,EAAE,UAAU,IAAI,GAAG,MAAM,YAAY,IAAI;AAC/C,MAAI;AACH,SAAM,GAAG,SAAS;AAClB,SAAM,GAAG,OAAO,iBAAiB,SAAS,GAAG;EAC7C,UAAS;AACT,SAAM,GAAG,KAAK;EACd;CACD;;;;;;;;;;;;;;;;;;;;;;;CAwBD,MAAM,QAAQ;EACb,MAAM,EAAE,UAAU,IAAI,GAAG,MAAM,YAAY,KAAK,IAAI;AACpD,MAAI;AACH,SAAM,iBAAiB,OAAO,KAAK,IAAI;AACvC,OAAI,KAAK,YACR,OAAM,KAAK,YAAY,KAAK,IAAI;AAEjC,SAAM,KAAK,SAAS;AACpB,UAAO,KAAK,sBAAsB,SAAS,EAAE;EAE7C,UAAS;AACT,SAAM,GAAG,KAAK;EACd;AAED,SAAO,YAAY;AAClB,SAAM,iBAAiB,KAAK,KAAK,IAAI;EACrC;CACD;AACD"}
@@ -1,3 +1,3 @@
1
- const require_PostgresMigrator = require('./PostgresMigrator-CHiBYEg_.cjs');
1
+ const require_PostgresMigrator = require('./PostgresMigrator-M9jpzOvN.cjs');
2
2
 
3
3
  exports.PostgresMigrator = require_PostgresMigrator.PostgresMigrator;
@@ -1,2 +1,2 @@
1
- import { PostgresMigrator } from "./PostgresMigrator-Bres0U6E.cjs";
1
+ import { PostgresMigrator } from "./PostgresMigrator-CeYy-eHF.cjs";
2
2
  export { PostgresMigrator };
@@ -1,2 +1,2 @@
1
- import { PostgresMigrator } from "./PostgresMigrator-S-YYosAC.mjs";
1
+ import { PostgresMigrator } from "./PostgresMigrator-C_QQ6q35.mjs";
2
2
  export { PostgresMigrator };
@@ -1,3 +1,3 @@
1
- import { PostgresMigrator } from "./PostgresMigrator-DcP1o-T6.mjs";
1
+ import { PostgresMigrator } from "./PostgresMigrator-DVAY04qN.mjs";
2
2
 
3
3
  export { PostgresMigrator };
@@ -1,4 +1,4 @@
1
- import { PostgresMigrator } from "./PostgresMigrator-Bres0U6E.cjs";
1
+ import { PostgresMigrator } from "./PostgresMigrator-C_QQ6q35.mjs";
2
2
  import { Knex } from "knex";
3
3
 
4
4
  //#region src/PostgresObjectionMigrator.d.ts
@@ -76,4 +76,4 @@ declare class PostgresObjectionMigrator extends PostgresMigrator {
76
76
  //# sourceMappingURL=PostgresObjectionMigrator.d.ts.map
77
77
  //#endregion
78
78
  export { PostgresObjectionMigrator };
79
- //# sourceMappingURL=PostgresObjectionMigrator-CPfBAP7r.d.cts.map
79
+ //# sourceMappingURL=PostgresObjectionMigrator-1j6YIB1c.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PostgresObjectionMigrator-CPfBAP7r.d.cts","names":[],"sources":["../src/PostgresObjectionMigrator.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuCA;;;;;;;AAA+D;;;;;;;;;;;;;;;;;;;;;;cAAlD,yBAAA,SAAkC,gBAAA;;;;;;;;;;;UAWtC;;;;;;;;;aAaS;;;;;;;cA8BC;;;;;;;YA4BF"}
1
+ {"version":3,"file":"PostgresObjectionMigrator-1j6YIB1c.d.mts","names":[],"sources":["../src/PostgresObjectionMigrator.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuCA;;;;;;;AAA+D;;;;;;;;;;;;;;;;;;;;;;cAAlD,yBAAA,SAAkC,gBAAA;;;;;;;;;;;UAWtC;;;;;;;;;aAaS;;;;;;;cA8BC;;;;;;;YA4BF"}
@@ -1,4 +1,4 @@
1
- import { PostgresMigrator } from "./PostgresMigrator-S-YYosAC.mjs";
1
+ import { PostgresMigrator } from "./PostgresMigrator-CeYy-eHF.cjs";
2
2
  import { Knex } from "knex";
3
3
 
4
4
  //#region src/PostgresObjectionMigrator.d.ts
@@ -76,4 +76,4 @@ declare class PostgresObjectionMigrator extends PostgresMigrator {
76
76
  //# sourceMappingURL=PostgresObjectionMigrator.d.ts.map
77
77
  //#endregion
78
78
  export { PostgresObjectionMigrator };
79
- //# sourceMappingURL=PostgresObjectionMigrator-DVEqB5tp.d.mts.map
79
+ //# sourceMappingURL=PostgresObjectionMigrator-DHVC9h_P.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PostgresObjectionMigrator-DVEqB5tp.d.mts","names":[],"sources":["../src/PostgresObjectionMigrator.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuCA;;;;;;;AAA+D;;;;;;;;;;;;;;;;;;;;;;cAAlD,yBAAA,SAAkC,gBAAA;;;;;;;;;;;UAWtC;;;;;;;;;aAaS;;;;;;;cA8BC;;;;;;;YA4BF"}
1
+ {"version":3,"file":"PostgresObjectionMigrator-DHVC9h_P.d.cts","names":[],"sources":["../src/PostgresObjectionMigrator.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuCA;;;;;;;AAA+D;;;;;;;;;;;;;;;;;;;;;;cAAlD,yBAAA,SAAkC,gBAAA;;;;;;;;;;;UAWtC;;;;;;;;;aAaS;;;;;;;cA8BC;;;;;;;YA4BF"}
@@ -1,4 +1,4 @@
1
- const require_PostgresMigrator = require('./PostgresMigrator-CHiBYEg_.cjs');
1
+ const require_PostgresMigrator = require('./PostgresMigrator-M9jpzOvN.cjs');
2
2
 
3
3
  //#region src/PostgresObjectionMigrator.ts
4
4
  /**
@@ -120,4 +120,4 @@ Object.defineProperty(exports, 'PostgresObjectionMigrator', {
120
120
  return PostgresObjectionMigrator;
121
121
  }
122
122
  });
123
- //# sourceMappingURL=PostgresObjectionMigrator-BXLAVVwm.cjs.map
123
+ //# sourceMappingURL=PostgresObjectionMigrator-DSaPhwjY.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PostgresObjectionMigrator-BXLAVVwm.cjs","names":["PostgresMigrator","options: {\n\t\t\turi: string;\n\t\t\tknex: Knex;\n\t\t}","migration: string"],"sources":["../src/PostgresObjectionMigrator.ts"],"sourcesContent":["import type { Knex } from 'knex';\nimport { PostgresMigrator } from './PostgresMigrator';\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * PostgreSQL migrator implementation for Objection.js ORM with Knex.\n * Extends PostgresMigrator to provide Knex-specific migration functionality.\n * Automatically creates test databases and applies migrations for testing environments.\n *\n * @example\n * ```typescript\n * import knex from 'knex';\n * import { PostgresObjectionMigrator } from '@geekmidas/testkit';\n *\n * // Create Knex instance\n * const db = knex({\n * client: 'pg',\n * connection: uri,\n * migrations: {\n * directory: path.join(__dirname, 'migrations'),\n * extension: 'ts'\n * }\n * });\n *\n * // Create and use migrator\n * const migrator = new PostgresObjectionMigrator({\n * uri: 'postgresql://localhost:5432/test_db',\n * knex: db\n * });\n *\n * const cleanup = await migrator.start();\n * // Run tests...\n * await cleanup();\n * ```\n */\nexport class PostgresObjectionMigrator extends PostgresMigrator {\n\t/**\n\t * Creates a new PostgresObjectionMigrator instance.\n\t *\n\t * @param options - Configuration options\n\t * @param options.uri - PostgreSQL connection URI\n\t * @param options.knex - Knex database instance configured with migrations\n\t */\n\tconstructor(\n\t\tprivate options: {\n\t\t\turi: string;\n\t\t\tknex: Knex;\n\t\t},\n\t) {\n\t\tsuper(options.uri);\n\t}\n\n\t/**\n\t * Executes Knex migrations to the latest version.\n\t * Implements the abstract migrate() method from PostgresMigrator.\n\t *\n\t * @throws Error if migrations fail to apply\n\t * @returns Promise that resolves when all migrations are applied\n\t */\n\tasync migrate(): Promise<void> {\n\t\ttry {\n\t\t\t// Run migrations to latest\n\t\t\tconst [batchNo, migrations] = await this.options.knex.migrate.latest();\n\n\t\t\tif (migrations.length > 0) {\n\t\t\t\tlogger.log(\n\t\t\t\t\t`Applied batch ${batchNo} with ${migrations.length} migrations:`,\n\t\t\t\t);\n\t\t\t\tmigrations.forEach((migration: string) => {\n\t\t\t\t\tlogger.log(` - ${migration}`);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tlogger.log('No pending migrations to apply');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlogger.error('Failed to apply migrations:', error);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\t// Always destroy the connection pool\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n\n\t/**\n\t * Rolls back the last batch of migrations.\n\t * Useful for testing migration rollback scenarios.\n\t *\n\t * @returns Promise that resolves when rollback is complete\n\t */\n\tasync rollback(): Promise<void> {\n\t\ttry {\n\t\t\tconst [batchNo, migrations] = await this.options.knex.migrate.rollback();\n\n\t\t\tif (migrations.length > 0) {\n\t\t\t\tlogger.log(\n\t\t\t\t\t`Rolled back batch ${batchNo} with ${migrations.length} migrations:`,\n\t\t\t\t);\n\t\t\t\tmigrations.forEach((migration: string) => {\n\t\t\t\t\tlogger.log(` - ${migration}`);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tlogger.log('No migrations to rollback');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlogger.error('Failed to rollback migrations:', error);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n\n\t/**\n\t * Gets the current migration status.\n\t * Returns information about completed and pending migrations.\n\t *\n\t * @returns Promise with migration status information\n\t */\n\tasync status(): Promise<{\n\t\tcompleted: string[];\n\t\tpending: string[];\n\t}> {\n\t\ttry {\n\t\t\tconst completed = await this.options.knex.migrate.list();\n\t\t\tconst [, pending] = await this.options.knex.migrate.currentVersion();\n\n\t\t\treturn {\n\t\t\t\tcompleted: Array.isArray(completed[0]) ? completed[0] : [],\n\t\t\t\tpending: Array.isArray(pending) ? pending : [],\n\t\t\t};\n\t\t} finally {\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;AAMA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCf,IAAa,4BAAb,cAA+CA,0CAAiB;;;;;;;;CAQ/D,YACSC,SAIP;AACD,QAAM,QAAQ,IAAI;EALV;CAMR;;;;;;;;CASD,MAAM,UAAyB;AAC9B,MAAI;GAEH,MAAM,CAAC,SAAS,WAAW,GAAG,MAAM,KAAK,QAAQ,KAAK,QAAQ,QAAQ;AAEtE,OAAI,WAAW,SAAS,GAAG;AAC1B,WAAO,KACL,gBAAgB,QAAQ,QAAQ,WAAW,OAAO,cACnD;AACD,eAAW,QAAQ,CAACC,cAAsB;AACzC,YAAO,KAAK,MAAM,UAAU,EAAE;IAC9B,EAAC;GACF,MACA,QAAO,IAAI,iCAAiC;EAE7C,SAAQ,OAAO;AACf,UAAO,MAAM,+BAA+B,MAAM;AAClD,SAAM;EACN,UAAS;AAET,SAAM,KAAK,QAAQ,KAAK,SAAS;EACjC;CACD;;;;;;;CAQD,MAAM,WAA0B;AAC/B,MAAI;GACH,MAAM,CAAC,SAAS,WAAW,GAAG,MAAM,KAAK,QAAQ,KAAK,QAAQ,UAAU;AAExE,OAAI,WAAW,SAAS,GAAG;AAC1B,WAAO,KACL,oBAAoB,QAAQ,QAAQ,WAAW,OAAO,cACvD;AACD,eAAW,QAAQ,CAACA,cAAsB;AACzC,YAAO,KAAK,MAAM,UAAU,EAAE;IAC9B,EAAC;GACF,MACA,QAAO,IAAI,4BAA4B;EAExC,SAAQ,OAAO;AACf,UAAO,MAAM,kCAAkC,MAAM;AACrD,SAAM;EACN,UAAS;AACT,SAAM,KAAK,QAAQ,KAAK,SAAS;EACjC;CACD;;;;;;;CAQD,MAAM,SAGH;AACF,MAAI;GACH,MAAM,YAAY,MAAM,KAAK,QAAQ,KAAK,QAAQ,MAAM;GACxD,MAAM,GAAG,QAAQ,GAAG,MAAM,KAAK,QAAQ,KAAK,QAAQ,gBAAgB;AAEpE,UAAO;IACN,WAAW,MAAM,QAAQ,UAAU,GAAG,GAAG,UAAU,KAAK,CAAE;IAC1D,SAAS,MAAM,QAAQ,QAAQ,GAAG,UAAU,CAAE;GAC9C;EACD,UAAS;AACT,SAAM,KAAK,QAAQ,KAAK,SAAS;EACjC;CACD;AACD"}
1
+ {"version":3,"file":"PostgresObjectionMigrator-DSaPhwjY.cjs","names":["PostgresMigrator","options: {\n\t\t\turi: string;\n\t\t\tknex: Knex;\n\t\t}","migration: string"],"sources":["../src/PostgresObjectionMigrator.ts"],"sourcesContent":["import type { Knex } from 'knex';\nimport { PostgresMigrator } from './PostgresMigrator';\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * PostgreSQL migrator implementation for Objection.js ORM with Knex.\n * Extends PostgresMigrator to provide Knex-specific migration functionality.\n * Automatically creates test databases and applies migrations for testing environments.\n *\n * @example\n * ```typescript\n * import knex from 'knex';\n * import { PostgresObjectionMigrator } from '@geekmidas/testkit';\n *\n * // Create Knex instance\n * const db = knex({\n * client: 'pg',\n * connection: uri,\n * migrations: {\n * directory: path.join(__dirname, 'migrations'),\n * extension: 'ts'\n * }\n * });\n *\n * // Create and use migrator\n * const migrator = new PostgresObjectionMigrator({\n * uri: 'postgresql://localhost:5432/test_db',\n * knex: db\n * });\n *\n * const cleanup = await migrator.start();\n * // Run tests...\n * await cleanup();\n * ```\n */\nexport class PostgresObjectionMigrator extends PostgresMigrator {\n\t/**\n\t * Creates a new PostgresObjectionMigrator instance.\n\t *\n\t * @param options - Configuration options\n\t * @param options.uri - PostgreSQL connection URI\n\t * @param options.knex - Knex database instance configured with migrations\n\t */\n\tconstructor(\n\t\tprivate options: {\n\t\t\turi: string;\n\t\t\tknex: Knex;\n\t\t},\n\t) {\n\t\tsuper(options.uri);\n\t}\n\n\t/**\n\t * Executes Knex migrations to the latest version.\n\t * Implements the abstract migrate() method from PostgresMigrator.\n\t *\n\t * @throws Error if migrations fail to apply\n\t * @returns Promise that resolves when all migrations are applied\n\t */\n\tasync migrate(): Promise<void> {\n\t\ttry {\n\t\t\t// Run migrations to latest\n\t\t\tconst [batchNo, migrations] = await this.options.knex.migrate.latest();\n\n\t\t\tif (migrations.length > 0) {\n\t\t\t\tlogger.log(\n\t\t\t\t\t`Applied batch ${batchNo} with ${migrations.length} migrations:`,\n\t\t\t\t);\n\t\t\t\tmigrations.forEach((migration: string) => {\n\t\t\t\t\tlogger.log(` - ${migration}`);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tlogger.log('No pending migrations to apply');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlogger.error('Failed to apply migrations:', error);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\t// Always destroy the connection pool\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n\n\t/**\n\t * Rolls back the last batch of migrations.\n\t * Useful for testing migration rollback scenarios.\n\t *\n\t * @returns Promise that resolves when rollback is complete\n\t */\n\tasync rollback(): Promise<void> {\n\t\ttry {\n\t\t\tconst [batchNo, migrations] = await this.options.knex.migrate.rollback();\n\n\t\t\tif (migrations.length > 0) {\n\t\t\t\tlogger.log(\n\t\t\t\t\t`Rolled back batch ${batchNo} with ${migrations.length} migrations:`,\n\t\t\t\t);\n\t\t\t\tmigrations.forEach((migration: string) => {\n\t\t\t\t\tlogger.log(` - ${migration}`);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tlogger.log('No migrations to rollback');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlogger.error('Failed to rollback migrations:', error);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n\n\t/**\n\t * Gets the current migration status.\n\t * Returns information about completed and pending migrations.\n\t *\n\t * @returns Promise with migration status information\n\t */\n\tasync status(): Promise<{\n\t\tcompleted: string[];\n\t\tpending: string[];\n\t}> {\n\t\ttry {\n\t\t\tconst completed = await this.options.knex.migrate.list();\n\t\t\tconst [, pending] = await this.options.knex.migrate.currentVersion();\n\n\t\t\treturn {\n\t\t\t\tcompleted: Array.isArray(completed[0]) ? completed[0] : [],\n\t\t\t\tpending: Array.isArray(pending) ? pending : [],\n\t\t\t};\n\t\t} finally {\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;AAMA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCf,IAAa,4BAAb,cAA+CA,0CAAiB;;;;;;;;CAQ/D,YACSC,SAIP;AACD,QAAM,QAAQ,IAAI;EALV;CAMR;;;;;;;;CASD,MAAM,UAAyB;AAC9B,MAAI;GAEH,MAAM,CAAC,SAAS,WAAW,GAAG,MAAM,KAAK,QAAQ,KAAK,QAAQ,QAAQ;AAEtE,OAAI,WAAW,SAAS,GAAG;AAC1B,WAAO,KACL,gBAAgB,QAAQ,QAAQ,WAAW,OAAO,cACnD;AACD,eAAW,QAAQ,CAACC,cAAsB;AACzC,YAAO,KAAK,MAAM,UAAU,EAAE;IAC9B,EAAC;GACF,MACA,QAAO,IAAI,iCAAiC;EAE7C,SAAQ,OAAO;AACf,UAAO,MAAM,+BAA+B,MAAM;AAClD,SAAM;EACN,UAAS;AAET,SAAM,KAAK,QAAQ,KAAK,SAAS;EACjC;CACD;;;;;;;CAQD,MAAM,WAA0B;AAC/B,MAAI;GACH,MAAM,CAAC,SAAS,WAAW,GAAG,MAAM,KAAK,QAAQ,KAAK,QAAQ,UAAU;AAExE,OAAI,WAAW,SAAS,GAAG;AAC1B,WAAO,KACL,oBAAoB,QAAQ,QAAQ,WAAW,OAAO,cACvD;AACD,eAAW,QAAQ,CAACA,cAAsB;AACzC,YAAO,KAAK,MAAM,UAAU,EAAE;IAC9B,EAAC;GACF,MACA,QAAO,IAAI,4BAA4B;EAExC,SAAQ,OAAO;AACf,UAAO,MAAM,kCAAkC,MAAM;AACrD,SAAM;EACN,UAAS;AACT,SAAM,KAAK,QAAQ,KAAK,SAAS;EACjC;CACD;;;;;;;CAQD,MAAM,SAGH;AACF,MAAI;GACH,MAAM,YAAY,MAAM,KAAK,QAAQ,KAAK,QAAQ,MAAM;GACxD,MAAM,GAAG,QAAQ,GAAG,MAAM,KAAK,QAAQ,KAAK,QAAQ,gBAAgB;AAEpE,UAAO;IACN,WAAW,MAAM,QAAQ,UAAU,GAAG,GAAG,UAAU,KAAK,CAAE;IAC1D,SAAS,MAAM,QAAQ,QAAQ,GAAG,UAAU,CAAE;GAC9C;EACD,UAAS;AACT,SAAM,KAAK,QAAQ,KAAK,SAAS;EACjC;CACD;AACD"}
@@ -1,4 +1,4 @@
1
- import { PostgresMigrator } from "./PostgresMigrator-DcP1o-T6.mjs";
1
+ import { PostgresMigrator } from "./PostgresMigrator-DVAY04qN.mjs";
2
2
 
3
3
  //#region src/PostgresObjectionMigrator.ts
4
4
  /**
@@ -115,4 +115,4 @@ var PostgresObjectionMigrator = class extends PostgresMigrator {
115
115
 
116
116
  //#endregion
117
117
  export { PostgresObjectionMigrator };
118
- //# sourceMappingURL=PostgresObjectionMigrator-BJ5X48U8.mjs.map
118
+ //# sourceMappingURL=PostgresObjectionMigrator-DjPKdUbm.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PostgresObjectionMigrator-BJ5X48U8.mjs","names":["options: {\n\t\t\turi: string;\n\t\t\tknex: Knex;\n\t\t}","migration: string"],"sources":["../src/PostgresObjectionMigrator.ts"],"sourcesContent":["import type { Knex } from 'knex';\nimport { PostgresMigrator } from './PostgresMigrator';\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * PostgreSQL migrator implementation for Objection.js ORM with Knex.\n * Extends PostgresMigrator to provide Knex-specific migration functionality.\n * Automatically creates test databases and applies migrations for testing environments.\n *\n * @example\n * ```typescript\n * import knex from 'knex';\n * import { PostgresObjectionMigrator } from '@geekmidas/testkit';\n *\n * // Create Knex instance\n * const db = knex({\n * client: 'pg',\n * connection: uri,\n * migrations: {\n * directory: path.join(__dirname, 'migrations'),\n * extension: 'ts'\n * }\n * });\n *\n * // Create and use migrator\n * const migrator = new PostgresObjectionMigrator({\n * uri: 'postgresql://localhost:5432/test_db',\n * knex: db\n * });\n *\n * const cleanup = await migrator.start();\n * // Run tests...\n * await cleanup();\n * ```\n */\nexport class PostgresObjectionMigrator extends PostgresMigrator {\n\t/**\n\t * Creates a new PostgresObjectionMigrator instance.\n\t *\n\t * @param options - Configuration options\n\t * @param options.uri - PostgreSQL connection URI\n\t * @param options.knex - Knex database instance configured with migrations\n\t */\n\tconstructor(\n\t\tprivate options: {\n\t\t\turi: string;\n\t\t\tknex: Knex;\n\t\t},\n\t) {\n\t\tsuper(options.uri);\n\t}\n\n\t/**\n\t * Executes Knex migrations to the latest version.\n\t * Implements the abstract migrate() method from PostgresMigrator.\n\t *\n\t * @throws Error if migrations fail to apply\n\t * @returns Promise that resolves when all migrations are applied\n\t */\n\tasync migrate(): Promise<void> {\n\t\ttry {\n\t\t\t// Run migrations to latest\n\t\t\tconst [batchNo, migrations] = await this.options.knex.migrate.latest();\n\n\t\t\tif (migrations.length > 0) {\n\t\t\t\tlogger.log(\n\t\t\t\t\t`Applied batch ${batchNo} with ${migrations.length} migrations:`,\n\t\t\t\t);\n\t\t\t\tmigrations.forEach((migration: string) => {\n\t\t\t\t\tlogger.log(` - ${migration}`);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tlogger.log('No pending migrations to apply');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlogger.error('Failed to apply migrations:', error);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\t// Always destroy the connection pool\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n\n\t/**\n\t * Rolls back the last batch of migrations.\n\t * Useful for testing migration rollback scenarios.\n\t *\n\t * @returns Promise that resolves when rollback is complete\n\t */\n\tasync rollback(): Promise<void> {\n\t\ttry {\n\t\t\tconst [batchNo, migrations] = await this.options.knex.migrate.rollback();\n\n\t\t\tif (migrations.length > 0) {\n\t\t\t\tlogger.log(\n\t\t\t\t\t`Rolled back batch ${batchNo} with ${migrations.length} migrations:`,\n\t\t\t\t);\n\t\t\t\tmigrations.forEach((migration: string) => {\n\t\t\t\t\tlogger.log(` - ${migration}`);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tlogger.log('No migrations to rollback');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlogger.error('Failed to rollback migrations:', error);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n\n\t/**\n\t * Gets the current migration status.\n\t * Returns information about completed and pending migrations.\n\t *\n\t * @returns Promise with migration status information\n\t */\n\tasync status(): Promise<{\n\t\tcompleted: string[];\n\t\tpending: string[];\n\t}> {\n\t\ttry {\n\t\t\tconst completed = await this.options.knex.migrate.list();\n\t\t\tconst [, pending] = await this.options.knex.migrate.currentVersion();\n\n\t\t\treturn {\n\t\t\t\tcompleted: Array.isArray(completed[0]) ? completed[0] : [],\n\t\t\t\tpending: Array.isArray(pending) ? pending : [],\n\t\t\t};\n\t\t} finally {\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;AAMA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCf,IAAa,4BAAb,cAA+C,iBAAiB;;;;;;;;CAQ/D,YACSA,SAIP;AACD,QAAM,QAAQ,IAAI;EALV;CAMR;;;;;;;;CASD,MAAM,UAAyB;AAC9B,MAAI;GAEH,MAAM,CAAC,SAAS,WAAW,GAAG,MAAM,KAAK,QAAQ,KAAK,QAAQ,QAAQ;AAEtE,OAAI,WAAW,SAAS,GAAG;AAC1B,WAAO,KACL,gBAAgB,QAAQ,QAAQ,WAAW,OAAO,cACnD;AACD,eAAW,QAAQ,CAACC,cAAsB;AACzC,YAAO,KAAK,MAAM,UAAU,EAAE;IAC9B,EAAC;GACF,MACA,QAAO,IAAI,iCAAiC;EAE7C,SAAQ,OAAO;AACf,UAAO,MAAM,+BAA+B,MAAM;AAClD,SAAM;EACN,UAAS;AAET,SAAM,KAAK,QAAQ,KAAK,SAAS;EACjC;CACD;;;;;;;CAQD,MAAM,WAA0B;AAC/B,MAAI;GACH,MAAM,CAAC,SAAS,WAAW,GAAG,MAAM,KAAK,QAAQ,KAAK,QAAQ,UAAU;AAExE,OAAI,WAAW,SAAS,GAAG;AAC1B,WAAO,KACL,oBAAoB,QAAQ,QAAQ,WAAW,OAAO,cACvD;AACD,eAAW,QAAQ,CAACA,cAAsB;AACzC,YAAO,KAAK,MAAM,UAAU,EAAE;IAC9B,EAAC;GACF,MACA,QAAO,IAAI,4BAA4B;EAExC,SAAQ,OAAO;AACf,UAAO,MAAM,kCAAkC,MAAM;AACrD,SAAM;EACN,UAAS;AACT,SAAM,KAAK,QAAQ,KAAK,SAAS;EACjC;CACD;;;;;;;CAQD,MAAM,SAGH;AACF,MAAI;GACH,MAAM,YAAY,MAAM,KAAK,QAAQ,KAAK,QAAQ,MAAM;GACxD,MAAM,GAAG,QAAQ,GAAG,MAAM,KAAK,QAAQ,KAAK,QAAQ,gBAAgB;AAEpE,UAAO;IACN,WAAW,MAAM,QAAQ,UAAU,GAAG,GAAG,UAAU,KAAK,CAAE;IAC1D,SAAS,MAAM,QAAQ,QAAQ,GAAG,UAAU,CAAE;GAC9C;EACD,UAAS;AACT,SAAM,KAAK,QAAQ,KAAK,SAAS;EACjC;CACD;AACD"}
1
+ {"version":3,"file":"PostgresObjectionMigrator-DjPKdUbm.mjs","names":["options: {\n\t\t\turi: string;\n\t\t\tknex: Knex;\n\t\t}","migration: string"],"sources":["../src/PostgresObjectionMigrator.ts"],"sourcesContent":["import type { Knex } from 'knex';\nimport { PostgresMigrator } from './PostgresMigrator';\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * PostgreSQL migrator implementation for Objection.js ORM with Knex.\n * Extends PostgresMigrator to provide Knex-specific migration functionality.\n * Automatically creates test databases and applies migrations for testing environments.\n *\n * @example\n * ```typescript\n * import knex from 'knex';\n * import { PostgresObjectionMigrator } from '@geekmidas/testkit';\n *\n * // Create Knex instance\n * const db = knex({\n * client: 'pg',\n * connection: uri,\n * migrations: {\n * directory: path.join(__dirname, 'migrations'),\n * extension: 'ts'\n * }\n * });\n *\n * // Create and use migrator\n * const migrator = new PostgresObjectionMigrator({\n * uri: 'postgresql://localhost:5432/test_db',\n * knex: db\n * });\n *\n * const cleanup = await migrator.start();\n * // Run tests...\n * await cleanup();\n * ```\n */\nexport class PostgresObjectionMigrator extends PostgresMigrator {\n\t/**\n\t * Creates a new PostgresObjectionMigrator instance.\n\t *\n\t * @param options - Configuration options\n\t * @param options.uri - PostgreSQL connection URI\n\t * @param options.knex - Knex database instance configured with migrations\n\t */\n\tconstructor(\n\t\tprivate options: {\n\t\t\turi: string;\n\t\t\tknex: Knex;\n\t\t},\n\t) {\n\t\tsuper(options.uri);\n\t}\n\n\t/**\n\t * Executes Knex migrations to the latest version.\n\t * Implements the abstract migrate() method from PostgresMigrator.\n\t *\n\t * @throws Error if migrations fail to apply\n\t * @returns Promise that resolves when all migrations are applied\n\t */\n\tasync migrate(): Promise<void> {\n\t\ttry {\n\t\t\t// Run migrations to latest\n\t\t\tconst [batchNo, migrations] = await this.options.knex.migrate.latest();\n\n\t\t\tif (migrations.length > 0) {\n\t\t\t\tlogger.log(\n\t\t\t\t\t`Applied batch ${batchNo} with ${migrations.length} migrations:`,\n\t\t\t\t);\n\t\t\t\tmigrations.forEach((migration: string) => {\n\t\t\t\t\tlogger.log(` - ${migration}`);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tlogger.log('No pending migrations to apply');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlogger.error('Failed to apply migrations:', error);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\t// Always destroy the connection pool\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n\n\t/**\n\t * Rolls back the last batch of migrations.\n\t * Useful for testing migration rollback scenarios.\n\t *\n\t * @returns Promise that resolves when rollback is complete\n\t */\n\tasync rollback(): Promise<void> {\n\t\ttry {\n\t\t\tconst [batchNo, migrations] = await this.options.knex.migrate.rollback();\n\n\t\t\tif (migrations.length > 0) {\n\t\t\t\tlogger.log(\n\t\t\t\t\t`Rolled back batch ${batchNo} with ${migrations.length} migrations:`,\n\t\t\t\t);\n\t\t\t\tmigrations.forEach((migration: string) => {\n\t\t\t\t\tlogger.log(` - ${migration}`);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tlogger.log('No migrations to rollback');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlogger.error('Failed to rollback migrations:', error);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n\n\t/**\n\t * Gets the current migration status.\n\t * Returns information about completed and pending migrations.\n\t *\n\t * @returns Promise with migration status information\n\t */\n\tasync status(): Promise<{\n\t\tcompleted: string[];\n\t\tpending: string[];\n\t}> {\n\t\ttry {\n\t\t\tconst completed = await this.options.knex.migrate.list();\n\t\t\tconst [, pending] = await this.options.knex.migrate.currentVersion();\n\n\t\t\treturn {\n\t\t\t\tcompleted: Array.isArray(completed[0]) ? completed[0] : [],\n\t\t\t\tpending: Array.isArray(pending) ? pending : [],\n\t\t\t};\n\t\t} finally {\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;AAMA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCf,IAAa,4BAAb,cAA+C,iBAAiB;;;;;;;;CAQ/D,YACSA,SAIP;AACD,QAAM,QAAQ,IAAI;EALV;CAMR;;;;;;;;CASD,MAAM,UAAyB;AAC9B,MAAI;GAEH,MAAM,CAAC,SAAS,WAAW,GAAG,MAAM,KAAK,QAAQ,KAAK,QAAQ,QAAQ;AAEtE,OAAI,WAAW,SAAS,GAAG;AAC1B,WAAO,KACL,gBAAgB,QAAQ,QAAQ,WAAW,OAAO,cACnD;AACD,eAAW,QAAQ,CAACC,cAAsB;AACzC,YAAO,KAAK,MAAM,UAAU,EAAE;IAC9B,EAAC;GACF,MACA,QAAO,IAAI,iCAAiC;EAE7C,SAAQ,OAAO;AACf,UAAO,MAAM,+BAA+B,MAAM;AAClD,SAAM;EACN,UAAS;AAET,SAAM,KAAK,QAAQ,KAAK,SAAS;EACjC;CACD;;;;;;;CAQD,MAAM,WAA0B;AAC/B,MAAI;GACH,MAAM,CAAC,SAAS,WAAW,GAAG,MAAM,KAAK,QAAQ,KAAK,QAAQ,UAAU;AAExE,OAAI,WAAW,SAAS,GAAG;AAC1B,WAAO,KACL,oBAAoB,QAAQ,QAAQ,WAAW,OAAO,cACvD;AACD,eAAW,QAAQ,CAACA,cAAsB;AACzC,YAAO,KAAK,MAAM,UAAU,EAAE;IAC9B,EAAC;GACF,MACA,QAAO,IAAI,4BAA4B;EAExC,SAAQ,OAAO;AACf,UAAO,MAAM,kCAAkC,MAAM;AACrD,SAAM;EACN,UAAS;AACT,SAAM,KAAK,QAAQ,KAAK,SAAS;EACjC;CACD;;;;;;;CAQD,MAAM,SAGH;AACF,MAAI;GACH,MAAM,YAAY,MAAM,KAAK,QAAQ,KAAK,QAAQ,MAAM;GACxD,MAAM,GAAG,QAAQ,GAAG,MAAM,KAAK,QAAQ,KAAK,QAAQ,gBAAgB;AAEpE,UAAO;IACN,WAAW,MAAM,QAAQ,UAAU,GAAG,GAAG,UAAU,KAAK,CAAE;IAC1D,SAAS,MAAM,QAAQ,QAAQ,GAAG,UAAU,CAAE;GAC9C;EACD,UAAS;AACT,SAAM,KAAK,QAAQ,KAAK,SAAS;EACjC;CACD;AACD"}
@@ -1,4 +1,4 @@
1
- require('./PostgresMigrator-CHiBYEg_.cjs');
2
- const require_PostgresObjectionMigrator = require('./PostgresObjectionMigrator-BXLAVVwm.cjs');
1
+ require('./PostgresMigrator-M9jpzOvN.cjs');
2
+ const require_PostgresObjectionMigrator = require('./PostgresObjectionMigrator-DSaPhwjY.cjs');
3
3
 
4
4
  exports.PostgresObjectionMigrator = require_PostgresObjectionMigrator.PostgresObjectionMigrator;
@@ -1,3 +1,3 @@
1
- import "./PostgresMigrator-Bres0U6E.cjs";
2
- import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-CPfBAP7r.cjs";
1
+ import "./PostgresMigrator-CeYy-eHF.cjs";
2
+ import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-DHVC9h_P.cjs";
3
3
  export { PostgresObjectionMigrator };
@@ -1,3 +1,3 @@
1
- import "./PostgresMigrator-S-YYosAC.mjs";
2
- import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-DVEqB5tp.mjs";
1
+ import "./PostgresMigrator-C_QQ6q35.mjs";
2
+ import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-1j6YIB1c.mjs";
3
3
  export { PostgresObjectionMigrator };
@@ -1,4 +1,4 @@
1
- import "./PostgresMigrator-DcP1o-T6.mjs";
2
- import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-BJ5X48U8.mjs";
1
+ import "./PostgresMigrator-DVAY04qN.mjs";
2
+ import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-DjPKdUbm.mjs";
3
3
 
4
4
  export { PostgresObjectionMigrator };
@@ -1,4 +1,4 @@
1
- import * as better_auth_adapters2 from "better-auth/adapters";
1
+ import * as better_auth_adapters5 from "better-auth/adapters";
2
2
  import { DBAdapterDebugLogOption } from "better-auth/adapters";
3
3
 
4
4
  //#region src/better-auth.d.ts
@@ -7,7 +7,7 @@ interface MemoryAdapterConfig {
7
7
  usePlural?: boolean;
8
8
  initialData?: Record<string, any[]>;
9
9
  }
10
- declare const memoryAdapter: (config?: MemoryAdapterConfig, store?: Map<any, any>) => better_auth_adapters2.AdapterFactory & {
10
+ declare const memoryAdapter: (config?: MemoryAdapterConfig, store?: Map<any, any>) => better_auth_adapters5.AdapterFactory & {
11
11
  clear: () => void;
12
12
  getAllData: () => Record<string, any[]>;
13
13
  getStore: () => Map<any, any>;
@@ -1,4 +1,4 @@
1
- import * as better_auth_adapters3 from "better-auth/adapters";
1
+ import * as better_auth_adapters5 from "better-auth/adapters";
2
2
  import { DBAdapterDebugLogOption } from "better-auth/adapters";
3
3
 
4
4
  //#region src/better-auth.d.ts
@@ -7,7 +7,7 @@ interface MemoryAdapterConfig {
7
7
  usePlural?: boolean;
8
8
  initialData?: Record<string, any[]>;
9
9
  }
10
- declare const memoryAdapter: (config?: MemoryAdapterConfig, store?: Map<any, any>) => better_auth_adapters3.AdapterFactory & {
10
+ declare const memoryAdapter: (config?: MemoryAdapterConfig, store?: Map<any, any>) => better_auth_adapters5.AdapterFactory & {
11
11
  clear: () => void;
12
12
  getAllData: () => Record<string, any[]>;
13
13
  getStore: () => Map<any, any>;
@@ -1,7 +1,7 @@
1
- import * as vitest6 from "vitest";
1
+ import * as vitest4 from "vitest";
2
2
 
3
3
  //#region src/os/directory.d.ts
4
- declare const itWithDir: vitest6.TestAPI<{
4
+ declare const itWithDir: vitest4.TestAPI<{
5
5
  dir: string;
6
6
  }>;
7
7
  interface DirectoryFixtures {
@@ -10,4 +10,4 @@ interface DirectoryFixtures {
10
10
  //# sourceMappingURL=directory.d.ts.map
11
11
  //#endregion
12
12
  export { DirectoryFixtures, itWithDir };
13
- //# sourceMappingURL=directory-CVrfTq1I.d.mts.map
13
+ //# sourceMappingURL=directory-CYXmolu1.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"directory-CVrfTq1I.d.mts","names":[],"sources":["../src/os/directory.ts"],"sourcesContent":[],"mappings":";;;cAMa,WAeX,OAAA,CAfoB;;;AAAT,UAiBI,iBAAA,CAjBK;EAiBL,GAAA,EAAA,MAAA"}
1
+ {"version":3,"file":"directory-CYXmolu1.d.mts","names":[],"sources":["../src/os/directory.ts"],"sourcesContent":[],"mappings":";;;cAMa,WAeX,OAAA,CAfoB;;;AAAT,UAiBI,iBAAA,CAjBK;EAiBL,GAAA,EAAA,MAAA"}
@@ -1,7 +1,7 @@
1
- import * as vitest6 from "vitest";
1
+ import * as vitest4 from "vitest";
2
2
 
3
3
  //#region src/os/directory.d.ts
4
- declare const itWithDir: vitest6.TestAPI<{
4
+ declare const itWithDir: vitest4.TestAPI<{
5
5
  dir: string;
6
6
  }>;
7
7
  interface DirectoryFixtures {
@@ -10,4 +10,4 @@ interface DirectoryFixtures {
10
10
  //# sourceMappingURL=directory.d.ts.map
11
11
  //#endregion
12
12
  export { DirectoryFixtures, itWithDir };
13
- //# sourceMappingURL=directory-DGOcVlKD.d.cts.map
13
+ //# sourceMappingURL=directory-DAnMWi50.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"directory-DGOcVlKD.d.cts","names":[],"sources":["../src/os/directory.ts"],"sourcesContent":[],"mappings":";;;cAMa,WAeX,OAAA,CAfoB;;;AAAT,UAiBI,iBAAA,CAjBK;EAiBL,GAAA,EAAA,MAAA"}
1
+ {"version":3,"file":"directory-DAnMWi50.d.cts","names":[],"sources":["../src/os/directory.ts"],"sourcesContent":[],"mappings":";;;cAMa,WAeX,OAAA,CAfoB;;;AAAT,UAiBI,iBAAA,CAjBK;EAiBL,GAAA,EAAA,MAAA"}
@@ -1,4 +1,4 @@
1
- import * as _faker_js_faker3 from "@faker-js/faker";
1
+ import * as _faker_js_faker6 from "@faker-js/faker";
2
2
 
3
3
  //#region src/faker.d.ts
4
4
 
@@ -134,7 +134,7 @@ declare function coordinateOutsideRadius(center: Coordinate, minRadiusMeters: nu
134
134
  * const productPrice = faker.price();
135
135
  * ```
136
136
  */
137
- declare const faker: Readonly<_faker_js_faker3.Faker & {
137
+ declare const faker: Readonly<_faker_js_faker6.Faker & {
138
138
  timestamps: typeof timestamps;
139
139
  identifier: typeof identifier;
140
140
  sequence: typeof sequence;
@@ -163,4 +163,4 @@ type Timestamps = {
163
163
  type FakerFactory = typeof faker;
164
164
  //#endregion
165
165
  export { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps };
166
- //# sourceMappingURL=faker-CbYiF-8_.d.cts.map
166
+ //# sourceMappingURL=faker-Dg3trU4a.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"faker-CbYiF-8_.d.cts","names":[],"sources":["../src/faker.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkFA;AA2BA;AAmCA;AA2BA;AA0BA;AAEC;AAca;AASd;;;;AAGa;AA4BZ;;;;AAMY;AA2DA,iBA5OG,UAAA,CAAA,CAyPf,EAzP6B,UAyP7B;;;;;;;;;;;;AAbiB;AAmBlB;;AAEY,iBAtOI,UAAA,CAsOJ,MAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;AAEI;AAOhB;;;;;;;;;;;;;;;;;;iBA5MgB,QAAA;;;;;;;;;;;;;;;;;;;iBA2BA,aAAA;;;;;;;;;;;;;;;;;;iBA0BA,iBAAA,CAAA;;;;;;;;;;;;;iBAgBP,KAAA,CAAA;KAIJ,UAAA;;;;iBAKW,kBAAA,SACP,6BAEN;iBA8BM,uBAAA,SACA,+DAGN;;;;;;;;;;;;;;;;;;;;cA2DU,OAAK,SAajB,gBAAA,CAbiB,KAAA;qBAAA;;;;;;;;;;;;;;;KAmBN,UAAA;;aAEA;;aAEA;;;;;;KAOA,YAAA,UAAsB"}
1
+ {"version":3,"file":"faker-Dg3trU4a.d.cts","names":[],"sources":["../src/faker.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkFA;AA2BA;AAmCA;AA2BA;AA0BA;AAEC;AAca;AASd;;;;AAGa;AA4BZ;;;;AAMY;AA2DA,iBA5OG,UAAA,CAAA,CAyPf,EAzP6B,UAyP7B;;;;;;;;;;;;AAbiB;AAmBlB;;AAEY,iBAtOI,UAAA,CAsOJ,MAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;AAEI;AAOhB;;;;;;;;;;;;;;;;;;iBA5MgB,QAAA;;;;;;;;;;;;;;;;;;;iBA2BA,aAAA;;;;;;;;;;;;;;;;;;iBA0BA,iBAAA,CAAA;;;;;;;;;;;;;iBAgBP,KAAA,CAAA;KAIJ,UAAA;;;;iBAKW,kBAAA,SACP,6BAEN;iBA8BM,uBAAA,SACA,+DAGN;;;;;;;;;;;;;;;;;;;;cA2DU,OAAK,SAajB,gBAAA,CAbiB,KAAA;qBAAA;;;;;;;;;;;;;;;KAmBN,UAAA;;aAEA;;aAEA;;;;;;KAOA,YAAA,UAAsB"}
@@ -1,4 +1,4 @@
1
- import * as _faker_js_faker0 from "@faker-js/faker";
1
+ import * as _faker_js_faker6 from "@faker-js/faker";
2
2
 
3
3
  //#region src/faker.d.ts
4
4
 
@@ -134,7 +134,7 @@ declare function coordinateOutsideRadius(center: Coordinate, minRadiusMeters: nu
134
134
  * const productPrice = faker.price();
135
135
  * ```
136
136
  */
137
- declare const faker$1: Readonly<_faker_js_faker0.Faker & {
137
+ declare const faker$1: Readonly<_faker_js_faker6.Faker & {
138
138
  timestamps: typeof timestamps;
139
139
  identifier: typeof identifier;
140
140
  sequence: typeof sequence;
@@ -163,4 +163,4 @@ type Timestamps = {
163
163
  type FakerFactory = typeof faker$1;
164
164
  //#endregion
165
165
  export { FakerFactory, Timestamps, coordinateInRadius, faker$1 as faker, identifier, resetAllSequences, resetSequence, sequence, timestamps };
166
- //# sourceMappingURL=faker-D9gz7KjY.d.mts.map
166
+ //# sourceMappingURL=faker-DsYCplsG.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"faker-D9gz7KjY.d.mts","names":[],"sources":["../src/faker.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkFA;AA2BA;AAmCA;AA2BA;AA0BA;AAEC;AAca;AASd;;;;AAGa;AA4BZ;;;;AAMY;AA2DA,iBA5OG,UAAA,CAAA,CAyPf,EAzP6B,UAyP7B;;;;;;;;;;;;AAbiB;AAmBlB;;AAEY,iBAtOI,UAAA,CAsOJ,MAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;AAEI;AAOhB;;;;;;;;;;;;;;;;;;iBA5MgB,QAAA;;;;;;;;;;;;;;;;;;;iBA2BA,aAAA;;;;;;;;;;;;;;;;;;iBA0BA,iBAAA,CAAA;;;;;;;;;;;;;iBAgBP,KAAA,CAAA;KAIJ,UAAA;;;;iBAKW,kBAAA,SACP,6BAEN;iBA8BM,uBAAA,SACA,+DAGN;;;;;;;;;;;;;;;;;;;;cA2DU,SAAK,SAajB,gBAAA,CAbiB,KAAA;qBAAA;;;;;;;;;;;;;;;KAmBN,UAAA;;aAEA;;aAEA;;;;;;KAOA,YAAA,UAAsB"}
1
+ {"version":3,"file":"faker-DsYCplsG.d.mts","names":[],"sources":["../src/faker.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkFA;AA2BA;AAmCA;AA2BA;AA0BA;AAEC;AAca;AASd;;;;AAGa;AA4BZ;;;;AAMY;AA2DA,iBA5OG,UAAA,CAAA,CAyPf,EAzP6B,UAyP7B;;;;;;;;;;;;AAbiB;AAmBlB;;AAEY,iBAtOI,UAAA,CAsOJ,MAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;AAEI;AAOhB;;;;;;;;;;;;;;;;;;iBA5MgB,QAAA;;;;;;;;;;;;;;;;;;;iBA2BA,aAAA;;;;;;;;;;;;;;;;;;iBA0BA,iBAAA,CAAA;;;;;;;;;;;;;iBAgBP,KAAA,CAAA;KAIJ,UAAA;;;;iBAKW,kBAAA,SACP,6BAEN;iBA8BM,uBAAA,SACA,+DAGN;;;;;;;;;;;;;;;;;;;;cA2DU,SAAK,SAajB,gBAAA,CAbiB,KAAA;qBAAA;;;;;;;;;;;;;;;KAmBN,UAAA;;aAEA;;aAEA;;;;;;KAOA,YAAA,UAAsB"}
package/dist/faker.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps } from "./faker-CbYiF-8_.cjs";
1
+ import { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps } from "./faker-Dg3trU4a.cjs";
2
2
  export { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps };
package/dist/faker.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps } from "./faker-D9gz7KjY.mjs";
1
+ import { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps } from "./faker-DsYCplsG.mjs";
2
2
  export { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps };
@@ -0,0 +1,95 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const pg = require_chunk.__toESM(require("pg"));
3
+ const node_fs = require_chunk.__toESM(require("node:fs"));
4
+
5
+ //#region src/initScript.ts
6
+ const { Client } = pg.default;
7
+ /**
8
+ * Parse a shell init script (like docker/postgres/init.sh) and extract
9
+ * SQL blocks from heredoc sections (<<-EOSQL ... EOSQL).
10
+ *
11
+ * @param content - The shell script content
12
+ * @param env - Environment variables to substitute ($VAR_NAME references)
13
+ * @returns Array of SQL strings ready to execute
14
+ * @internal Exported for testing
15
+ */
16
+ function parseInitScript(content, env) {
17
+ const blocks = [];
18
+ const lines = content.split("\n");
19
+ let inHeredoc = false;
20
+ let currentBlock = [];
21
+ for (const line of lines) if (inHeredoc) if (/^\s*EOSQL\s*$/.test(line)) {
22
+ const sql = substituteEnvVars(currentBlock.join("\n"), env);
23
+ blocks.push(sql);
24
+ currentBlock = [];
25
+ inHeredoc = false;
26
+ } else currentBlock.push(line);
27
+ else if (line.includes("<<-EOSQL") || line.includes("<< EOSQL") || line.includes("<<EOSQL")) {
28
+ inHeredoc = true;
29
+ currentBlock = [];
30
+ }
31
+ return blocks;
32
+ }
33
+ /**
34
+ * Replace shell variable references ($VAR_NAME and ${VAR_NAME})
35
+ * with values from the provided env object.
36
+ */
37
+ function substituteEnvVars(sql, env) {
38
+ let result = sql.replace(/\$\{(\w+)\}/g, (_, name) => env[name] ?? "");
39
+ result = result.replace(/\$(\w+)/g, (_, name) => env[name] ?? "");
40
+ return result;
41
+ }
42
+ /**
43
+ * Read a postgres init script, parse out the SQL blocks,
44
+ * substitute environment variables, and execute against a database.
45
+ *
46
+ * This is intended to run `docker/postgres/init.sh` against a test database
47
+ * so that per-app users and schemas are created (matching what Docker does
48
+ * on first volume initialization).
49
+ *
50
+ * Uses `CREATE ... IF NOT EXISTS` and `DO $$ ... END $$` wrappers where
51
+ * needed so the script is idempotent.
52
+ *
53
+ * @param scriptPath - Path to the init.sh file
54
+ * @param databaseUrl - PostgreSQL connection URL (should point to the test database)
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * // In your globalSetup.ts
59
+ * import { runInitScript } from '@geekmidas/testkit/postgres';
60
+ * import { Credentials } from '@geekmidas/envkit/credentials';
61
+ *
62
+ * const cleanup = await migrator.start();
63
+ *
64
+ * // Create per-app users in the test database
65
+ * await runInitScript('docker/postgres/init.sh', Credentials.DATABASE_URL, {
66
+ * ...process.env,
67
+ * ...Credentials,
68
+ * });
69
+ * ```
70
+ */
71
+ async function runInitScript(scriptPath, databaseUrl, env) {
72
+ const content = (0, node_fs.readFileSync)(scriptPath, "utf-8");
73
+ const resolvedEnv = env ?? { ...process.env };
74
+ const blocks = parseInitScript(content, resolvedEnv);
75
+ if (blocks.length === 0) return;
76
+ const url = new URL(databaseUrl);
77
+ const client = new Client({
78
+ user: url.username,
79
+ password: decodeURIComponent(url.password),
80
+ host: url.hostname,
81
+ port: parseInt(url.port, 10),
82
+ database: url.pathname.slice(1)
83
+ });
84
+ try {
85
+ await client.connect();
86
+ for (const sql of blocks) await client.query(sql);
87
+ } finally {
88
+ await client.end();
89
+ }
90
+ }
91
+
92
+ //#endregion
93
+ exports.parseInitScript = parseInitScript;
94
+ exports.runInitScript = runInitScript;
95
+ //# sourceMappingURL=initScript.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initScript.cjs","names":["content: string","env: Record<string, string>","blocks: string[]","currentBlock: string[]","sql: string","scriptPath: string","databaseUrl: string","env?: Record<string, string>"],"sources":["../src/initScript.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport pg from 'pg';\n\nconst { Client } = pg;\n\n/**\n * Parse a shell init script (like docker/postgres/init.sh) and extract\n * SQL blocks from heredoc sections (<<-EOSQL ... EOSQL).\n *\n * @param content - The shell script content\n * @param env - Environment variables to substitute ($VAR_NAME references)\n * @returns Array of SQL strings ready to execute\n * @internal Exported for testing\n */\nexport function parseInitScript(\n\tcontent: string,\n\tenv: Record<string, string>,\n): string[] {\n\tconst blocks: string[] = [];\n\tconst lines = content.split('\\n');\n\tlet inHeredoc = false;\n\tlet currentBlock: string[] = [];\n\n\tfor (const line of lines) {\n\t\tif (inHeredoc) {\n\t\t\t// Check for heredoc terminator (EOSQL at start of line, with optional leading whitespace)\n\t\t\tif (/^\\s*EOSQL\\s*$/.test(line)) {\n\t\t\t\tconst sql = substituteEnvVars(currentBlock.join('\\n'), env);\n\t\t\t\tblocks.push(sql);\n\t\t\t\tcurrentBlock = [];\n\t\t\t\tinHeredoc = false;\n\t\t\t} else {\n\t\t\t\tcurrentBlock.push(line);\n\t\t\t}\n\t\t} else if (\n\t\t\tline.includes('<<-EOSQL') ||\n\t\t\tline.includes('<< EOSQL') ||\n\t\t\tline.includes('<<EOSQL')\n\t\t) {\n\t\t\tinHeredoc = true;\n\t\t\tcurrentBlock = [];\n\t\t}\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Replace shell variable references ($VAR_NAME and ${VAR_NAME})\n * with values from the provided env object.\n */\nfunction substituteEnvVars(sql: string, env: Record<string, string>): string {\n\t// Replace ${VAR_NAME} syntax\n\tlet result = sql.replace(/\\$\\{(\\w+)\\}/g, (_, name) => env[name] ?? '');\n\t// Replace $VAR_NAME syntax (word boundary after)\n\tresult = result.replace(/\\$(\\w+)/g, (_, name) => env[name] ?? '');\n\treturn result;\n}\n\n/**\n * Read a postgres init script, parse out the SQL blocks,\n * substitute environment variables, and execute against a database.\n *\n * This is intended to run `docker/postgres/init.sh` against a test database\n * so that per-app users and schemas are created (matching what Docker does\n * on first volume initialization).\n *\n * Uses `CREATE ... IF NOT EXISTS` and `DO $$ ... END $$` wrappers where\n * needed so the script is idempotent.\n *\n * @param scriptPath - Path to the init.sh file\n * @param databaseUrl - PostgreSQL connection URL (should point to the test database)\n *\n * @example\n * ```typescript\n * // In your globalSetup.ts\n * import { runInitScript } from '@geekmidas/testkit/postgres';\n * import { Credentials } from '@geekmidas/envkit/credentials';\n *\n * const cleanup = await migrator.start();\n *\n * // Create per-app users in the test database\n * await runInitScript('docker/postgres/init.sh', Credentials.DATABASE_URL, {\n * ...process.env,\n * ...Credentials,\n * });\n * ```\n */\nexport async function runInitScript(\n\tscriptPath: string,\n\tdatabaseUrl: string,\n\tenv?: Record<string, string>,\n): Promise<void> {\n\tconst content = readFileSync(scriptPath, 'utf-8');\n\tconst resolvedEnv = env ?? ({ ...process.env } as Record<string, string>);\n\tconst blocks = parseInitScript(content, resolvedEnv);\n\n\tif (blocks.length === 0) {\n\t\treturn;\n\t}\n\n\tconst url = new URL(databaseUrl);\n\tconst client = new Client({\n\t\tuser: url.username,\n\t\tpassword: decodeURIComponent(url.password),\n\t\thost: url.hostname,\n\t\tport: parseInt(url.port, 10),\n\t\tdatabase: url.pathname.slice(1),\n\t});\n\n\ttry {\n\t\tawait client.connect();\n\t\tfor (const sql of blocks) {\n\t\t\tawait client.query(sql);\n\t\t}\n\t} finally {\n\t\tawait client.end();\n\t}\n}\n"],"mappings":";;;;;AAGA,MAAM,EAAE,QAAQ,GAAG;;;;;;;;;;AAWnB,SAAgB,gBACfA,SACAC,KACW;CACX,MAAMC,SAAmB,CAAE;CAC3B,MAAM,QAAQ,QAAQ,MAAM,KAAK;CACjC,IAAI,YAAY;CAChB,IAAIC,eAAyB,CAAE;AAE/B,MAAK,MAAM,QAAQ,MAClB,KAAI,UAEH,KAAI,gBAAgB,KAAK,KAAK,EAAE;EAC/B,MAAM,MAAM,kBAAkB,aAAa,KAAK,KAAK,EAAE,IAAI;AAC3D,SAAO,KAAK,IAAI;AAChB,iBAAe,CAAE;AACjB,cAAY;CACZ,MACA,cAAa,KAAK,KAAK;UAGxB,KAAK,SAAS,WAAW,IACzB,KAAK,SAAS,WAAW,IACzB,KAAK,SAAS,UAAU,EACvB;AACD,cAAY;AACZ,iBAAe,CAAE;CACjB;AAGF,QAAO;AACP;;;;;AAMD,SAAS,kBAAkBC,KAAaH,KAAqC;CAE5E,IAAI,SAAS,IAAI,QAAQ,gBAAgB,CAAC,GAAG,SAAS,IAAI,SAAS,GAAG;AAEtE,UAAS,OAAO,QAAQ,YAAY,CAAC,GAAG,SAAS,IAAI,SAAS,GAAG;AACjE,QAAO;AACP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BD,eAAsB,cACrBI,YACAC,aACAC,KACgB;CAChB,MAAM,UAAU,0BAAa,YAAY,QAAQ;CACjD,MAAM,cAAc,OAAQ,EAAE,GAAG,QAAQ,IAAK;CAC9C,MAAM,SAAS,gBAAgB,SAAS,YAAY;AAEpD,KAAI,OAAO,WAAW,EACrB;CAGD,MAAM,MAAM,IAAI,IAAI;CACpB,MAAM,SAAS,IAAI,OAAO;EACzB,MAAM,IAAI;EACV,UAAU,mBAAmB,IAAI,SAAS;EAC1C,MAAM,IAAI;EACV,MAAM,SAAS,IAAI,MAAM,GAAG;EAC5B,UAAU,IAAI,SAAS,MAAM,EAAE;CAC/B;AAED,KAAI;AACH,QAAM,OAAO,SAAS;AACtB,OAAK,MAAM,OAAO,OACjB,OAAM,OAAO,MAAM,IAAI;CAExB,UAAS;AACT,QAAM,OAAO,KAAK;CAClB;AACD"}
@@ -0,0 +1,45 @@
1
+ //#region src/initScript.d.ts
2
+ /**
3
+ * Parse a shell init script (like docker/postgres/init.sh) and extract
4
+ * SQL blocks from heredoc sections (<<-EOSQL ... EOSQL).
5
+ *
6
+ * @param content - The shell script content
7
+ * @param env - Environment variables to substitute ($VAR_NAME references)
8
+ * @returns Array of SQL strings ready to execute
9
+ * @internal Exported for testing
10
+ */
11
+ declare function parseInitScript(content: string, env: Record<string, string>): string[];
12
+ /**
13
+ * Read a postgres init script, parse out the SQL blocks,
14
+ * substitute environment variables, and execute against a database.
15
+ *
16
+ * This is intended to run `docker/postgres/init.sh` against a test database
17
+ * so that per-app users and schemas are created (matching what Docker does
18
+ * on first volume initialization).
19
+ *
20
+ * Uses `CREATE ... IF NOT EXISTS` and `DO $$ ... END $$` wrappers where
21
+ * needed so the script is idempotent.
22
+ *
23
+ * @param scriptPath - Path to the init.sh file
24
+ * @param databaseUrl - PostgreSQL connection URL (should point to the test database)
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * // In your globalSetup.ts
29
+ * import { runInitScript } from '@geekmidas/testkit/postgres';
30
+ * import { Credentials } from '@geekmidas/envkit/credentials';
31
+ *
32
+ * const cleanup = await migrator.start();
33
+ *
34
+ * // Create per-app users in the test database
35
+ * await runInitScript('docker/postgres/init.sh', Credentials.DATABASE_URL, {
36
+ * ...process.env,
37
+ * ...Credentials,
38
+ * });
39
+ * ```
40
+ */
41
+ declare function runInitScript(scriptPath: string, databaseUrl: string, env?: Record<string, string>): Promise<void>;
42
+ //# sourceMappingURL=initScript.d.ts.map
43
+ //#endregion
44
+ export { parseInitScript, runInitScript };
45
+ //# sourceMappingURL=initScript.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initScript.d.cts","names":[],"sources":["../src/initScript.ts"],"sourcesContent":[],"mappings":";;AAcA;AA0EA;;;;AAIU;;;iBA9EM,eAAA,uBAEV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwEgB,aAAA,gDAGf,yBACJ"}
@@ -0,0 +1,45 @@
1
+ //#region src/initScript.d.ts
2
+ /**
3
+ * Parse a shell init script (like docker/postgres/init.sh) and extract
4
+ * SQL blocks from heredoc sections (<<-EOSQL ... EOSQL).
5
+ *
6
+ * @param content - The shell script content
7
+ * @param env - Environment variables to substitute ($VAR_NAME references)
8
+ * @returns Array of SQL strings ready to execute
9
+ * @internal Exported for testing
10
+ */
11
+ declare function parseInitScript(content: string, env: Record<string, string>): string[];
12
+ /**
13
+ * Read a postgres init script, parse out the SQL blocks,
14
+ * substitute environment variables, and execute against a database.
15
+ *
16
+ * This is intended to run `docker/postgres/init.sh` against a test database
17
+ * so that per-app users and schemas are created (matching what Docker does
18
+ * on first volume initialization).
19
+ *
20
+ * Uses `CREATE ... IF NOT EXISTS` and `DO $$ ... END $$` wrappers where
21
+ * needed so the script is idempotent.
22
+ *
23
+ * @param scriptPath - Path to the init.sh file
24
+ * @param databaseUrl - PostgreSQL connection URL (should point to the test database)
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * // In your globalSetup.ts
29
+ * import { runInitScript } from '@geekmidas/testkit/postgres';
30
+ * import { Credentials } from '@geekmidas/envkit/credentials';
31
+ *
32
+ * const cleanup = await migrator.start();
33
+ *
34
+ * // Create per-app users in the test database
35
+ * await runInitScript('docker/postgres/init.sh', Credentials.DATABASE_URL, {
36
+ * ...process.env,
37
+ * ...Credentials,
38
+ * });
39
+ * ```
40
+ */
41
+ declare function runInitScript(scriptPath: string, databaseUrl: string, env?: Record<string, string>): Promise<void>;
42
+ //# sourceMappingURL=initScript.d.ts.map
43
+ //#endregion
44
+ export { parseInitScript, runInitScript };
45
+ //# sourceMappingURL=initScript.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initScript.d.mts","names":[],"sources":["../src/initScript.ts"],"sourcesContent":[],"mappings":";;AAcA;AA0EA;;;;AAIU;;;iBA9EM,eAAA,uBAEV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwEgB,aAAA,gDAGf,yBACJ"}