@geekmidas/testkit 1.0.3 → 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 (79) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/{Factory-BOX312yd.d.cts → Factory-Cwzho3c8.d.cts} +2 -2
  3. package/dist/{Factory-BOX312yd.d.cts.map → Factory-Cwzho3c8.d.cts.map} +1 -1
  4. package/dist/Factory.d.cts +2 -2
  5. package/dist/{KyselyFactory-Dy5zzV4B.d.cts → KyselyFactory-hMcVtvJq.d.cts} +3 -3
  6. package/dist/{KyselyFactory-Dy5zzV4B.d.cts.map → KyselyFactory-hMcVtvJq.d.cts.map} +1 -1
  7. package/dist/KyselyFactory.d.cts +3 -3
  8. package/dist/{ObjectionFactory-CD-WFuMJ.d.cts → ObjectionFactory-DW-qwnqO.d.cts} +3 -3
  9. package/dist/{ObjectionFactory-CD-WFuMJ.d.cts.map → ObjectionFactory-DW-qwnqO.d.cts.map} +1 -1
  10. package/dist/ObjectionFactory.d.cts +3 -3
  11. package/dist/{PostgresKyselyMigrator-B4pScubb.mjs → PostgresKyselyMigrator-BIKd7G5C.mjs} +16 -3
  12. package/dist/PostgresKyselyMigrator-BIKd7G5C.mjs.map +1 -0
  13. package/dist/{PostgresKyselyMigrator-CBltSOq5.d.cts → PostgresKyselyMigrator-CTNftoZK.d.cts} +16 -2
  14. package/dist/PostgresKyselyMigrator-CTNftoZK.d.cts.map +1 -0
  15. package/dist/{PostgresKyselyMigrator-C7ljZYvq.cjs → PostgresKyselyMigrator-CqNs3qX8.cjs} +16 -3
  16. package/dist/PostgresKyselyMigrator-CqNs3qX8.cjs.map +1 -0
  17. package/dist/{PostgresKyselyMigrator-DrVWncqd.d.mts → PostgresKyselyMigrator-x0uvWs3U.d.mts} +16 -2
  18. package/dist/PostgresKyselyMigrator-x0uvWs3U.d.mts.map +1 -0
  19. package/dist/PostgresKyselyMigrator.cjs +2 -2
  20. package/dist/PostgresKyselyMigrator.d.cts +2 -2
  21. package/dist/PostgresKyselyMigrator.d.mts +2 -2
  22. package/dist/PostgresKyselyMigrator.mjs +2 -2
  23. package/dist/{PostgresMigrator-S-YYosAC.d.mts → PostgresMigrator-C_QQ6q35.d.mts} +15 -2
  24. package/dist/PostgresMigrator-C_QQ6q35.d.mts.map +1 -0
  25. package/dist/{PostgresMigrator-Bres0U6E.d.cts → PostgresMigrator-CeYy-eHF.d.cts} +15 -2
  26. package/dist/PostgresMigrator-CeYy-eHF.d.cts.map +1 -0
  27. package/dist/{PostgresMigrator-DcP1o-T6.mjs → PostgresMigrator-DVAY04qN.mjs} +16 -2
  28. package/dist/PostgresMigrator-DVAY04qN.mjs.map +1 -0
  29. package/dist/{PostgresMigrator-CHiBYEg_.cjs → PostgresMigrator-M9jpzOvN.cjs} +16 -2
  30. package/dist/PostgresMigrator-M9jpzOvN.cjs.map +1 -0
  31. package/dist/PostgresMigrator.cjs +1 -1
  32. package/dist/PostgresMigrator.d.cts +1 -1
  33. package/dist/PostgresMigrator.d.mts +1 -1
  34. package/dist/PostgresMigrator.mjs +1 -1
  35. package/dist/{PostgresObjectionMigrator-CPfBAP7r.d.cts → PostgresObjectionMigrator-1j6YIB1c.d.mts} +2 -2
  36. package/dist/{PostgresObjectionMigrator-CPfBAP7r.d.cts.map → PostgresObjectionMigrator-1j6YIB1c.d.mts.map} +1 -1
  37. package/dist/{PostgresObjectionMigrator-DVEqB5tp.d.mts → PostgresObjectionMigrator-DHVC9h_P.d.cts} +2 -2
  38. package/dist/{PostgresObjectionMigrator-DVEqB5tp.d.mts.map → PostgresObjectionMigrator-DHVC9h_P.d.cts.map} +1 -1
  39. package/dist/{PostgresObjectionMigrator-BXLAVVwm.cjs → PostgresObjectionMigrator-DSaPhwjY.cjs} +2 -2
  40. package/dist/{PostgresObjectionMigrator-BXLAVVwm.cjs.map → PostgresObjectionMigrator-DSaPhwjY.cjs.map} +1 -1
  41. package/dist/{PostgresObjectionMigrator-BJ5X48U8.mjs → PostgresObjectionMigrator-DjPKdUbm.mjs} +2 -2
  42. package/dist/{PostgresObjectionMigrator-BJ5X48U8.mjs.map → PostgresObjectionMigrator-DjPKdUbm.mjs.map} +1 -1
  43. package/dist/PostgresObjectionMigrator.cjs +2 -2
  44. package/dist/PostgresObjectionMigrator.d.cts +2 -2
  45. package/dist/PostgresObjectionMigrator.d.mts +2 -2
  46. package/dist/PostgresObjectionMigrator.mjs +2 -2
  47. package/dist/better-auth.d.cts +2 -2
  48. package/dist/{directory-DGOcVlKD.d.cts → directory-CYXmolu1.d.mts} +3 -3
  49. package/dist/{directory-DGOcVlKD.d.cts.map → directory-CYXmolu1.d.mts.map} +1 -1
  50. package/dist/{directory-YzQUGC5g.d.mts → directory-DAnMWi50.d.cts} +3 -3
  51. package/dist/{directory-YzQUGC5g.d.mts.map → directory-DAnMWi50.d.cts.map} +1 -1
  52. package/dist/{faker-Cg76aFNO.d.cts → faker-Dg3trU4a.d.cts} +3 -3
  53. package/dist/{faker-Cg76aFNO.d.cts.map → faker-Dg3trU4a.d.cts.map} +1 -1
  54. package/dist/faker.d.cts +1 -1
  55. package/dist/kysely.cjs +2 -2
  56. package/dist/kysely.d.cts +5 -5
  57. package/dist/kysely.d.mts +2 -2
  58. package/dist/kysely.mjs +2 -2
  59. package/dist/objection.cjs +2 -2
  60. package/dist/objection.d.cts +5 -5
  61. package/dist/objection.d.mts +2 -2
  62. package/dist/objection.mjs +2 -2
  63. package/dist/os/directory.d.cts +1 -1
  64. package/dist/os/directory.d.mts +1 -1
  65. package/dist/os/index.d.cts +1 -1
  66. package/dist/os/index.d.mts +1 -1
  67. package/package.json +3 -3
  68. package/src/PostgresKyselyMigrator.ts +15 -1
  69. package/src/PostgresMigrator.ts +19 -2
  70. package/src/__tests__/PostgresKyselyMigrator.spec.ts +104 -0
  71. package/src/__tests__/PostgresMigrator.spec.ts +109 -0
  72. package/dist/PostgresKyselyMigrator-B4pScubb.mjs.map +0 -1
  73. package/dist/PostgresKyselyMigrator-C7ljZYvq.cjs.map +0 -1
  74. package/dist/PostgresKyselyMigrator-CBltSOq5.d.cts.map +0 -1
  75. package/dist/PostgresKyselyMigrator-DrVWncqd.d.mts.map +0 -1
  76. package/dist/PostgresMigrator-Bres0U6E.d.cts.map +0 -1
  77. package/dist/PostgresMigrator-CHiBYEg_.cjs.map +0 -1
  78. package/dist/PostgresMigrator-DcP1o-T6.mjs.map +0 -1
  79. package/dist/PostgresMigrator-S-YYosAC.d.mts.map +0 -1
@@ -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_adapters0 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_adapters0.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-DGOcVlKD.d.cts.map
13
+ //# sourceMappingURL=directory-CYXmolu1.d.mts.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-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 vitest2 from "vitest";
1
+ import * as vitest4 from "vitest";
2
2
 
3
3
  //#region src/os/directory.d.ts
4
- declare const itWithDir: vitest2.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-YzQUGC5g.d.mts.map
13
+ //# sourceMappingURL=directory-DAnMWi50.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"directory-YzQUGC5g.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-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_faker1 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_faker1.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-Cg76aFNO.d.cts.map
166
+ //# sourceMappingURL=faker-Dg3trU4a.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"faker-Cg76aFNO.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"}
package/dist/faker.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps } from "./faker-Cg76aFNO.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/kysely.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  require('./Factory-BhjUOBWN.cjs');
2
2
  const require_faker = require('./faker-B14IEMIN.cjs');
3
3
  const require_KyselyFactory = require('./KyselyFactory-BFqVIn_0.cjs');
4
- require('./PostgresMigrator-CHiBYEg_.cjs');
5
- const require_PostgresKyselyMigrator = require('./PostgresKyselyMigrator-C7ljZYvq.cjs');
4
+ require('./PostgresMigrator-M9jpzOvN.cjs');
5
+ const require_PostgresKyselyMigrator = require('./PostgresKyselyMigrator-CqNs3qX8.cjs');
6
6
  const require_VitestTransactionIsolator = require('./VitestTransactionIsolator-CMfJXZP8.cjs');
7
7
  const require_VitestKyselyTransactionIsolator = require('./VitestKyselyTransactionIsolator-D7RRXOBa.cjs');
8
8
 
package/dist/kysely.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { FakerFactory, faker } from "./faker-Cg76aFNO.cjs";
2
- import { ExtractSeedAttrs, FactorySeed } from "./Factory-BOX312yd.cjs";
3
- import { KyselyFactory } from "./KyselyFactory-Dy5zzV4B.cjs";
4
- import "./PostgresMigrator-Bres0U6E.cjs";
5
- import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-CBltSOq5.cjs";
1
+ import { FakerFactory, faker } from "./faker-Dg3trU4a.cjs";
2
+ import { ExtractSeedAttrs, FactorySeed } from "./Factory-Cwzho3c8.cjs";
3
+ import { KyselyFactory } from "./KyselyFactory-hMcVtvJq.cjs";
4
+ import "./PostgresMigrator-CeYy-eHF.cjs";
5
+ import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-CTNftoZK.cjs";
6
6
  import { DatabaseConnection, DatabaseFixtures, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions } from "./VitestTransactionIsolator-CSroc7Df.cjs";
7
7
  import { VitestKyselyTransactionIsolator } from "./VitestKyselyTransactionIsolator-CduJlHoT.cjs";
8
8
  import { Kysely, Transaction } from "kysely";
package/dist/kysely.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { FakerFactory, faker } from "./faker-DsYCplsG.mjs";
2
2
  import { ExtractSeedAttrs, FactorySeed } from "./Factory-CVR3GdkW.mjs";
3
3
  import { KyselyFactory } from "./KyselyFactory-DRlMv-WT.mjs";
4
- import "./PostgresMigrator-S-YYosAC.mjs";
5
- import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-DrVWncqd.mjs";
4
+ import "./PostgresMigrator-C_QQ6q35.mjs";
5
+ import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-x0uvWs3U.mjs";
6
6
  import { DatabaseConnection, DatabaseFixtures, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions } from "./VitestTransactionIsolator-BNWJqh9f.mjs";
7
7
  import { VitestKyselyTransactionIsolator } from "./VitestKyselyTransactionIsolator-Cswnnj0k.mjs";
8
8
  import { Kysely, Transaction } from "kysely";
package/dist/kysely.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import "./Factory-BFVnMMCC.mjs";
2
2
  import { faker } from "./faker-BGKYFoCT.mjs";
3
3
  import { KyselyFactory } from "./KyselyFactory-DMswpwji.mjs";
4
- import "./PostgresMigrator-DcP1o-T6.mjs";
5
- import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-B4pScubb.mjs";
4
+ import "./PostgresMigrator-DVAY04qN.mjs";
5
+ import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-BIKd7G5C.mjs";
6
6
  import { IsolationLevel, extendWithFixtures } from "./VitestTransactionIsolator-DQ7tLqgV.mjs";
7
7
  import { VitestKyselyTransactionIsolator } from "./VitestKyselyTransactionIsolator-DceyIqr4.mjs";
8
8
 
@@ -1,8 +1,8 @@
1
1
  require('./Factory-BhjUOBWN.cjs');
2
2
  const require_faker = require('./faker-B14IEMIN.cjs');
3
3
  const require_ObjectionFactory = require('./ObjectionFactory-BeFBYcan.cjs');
4
- require('./PostgresMigrator-CHiBYEg_.cjs');
5
- const require_PostgresObjectionMigrator = require('./PostgresObjectionMigrator-BXLAVVwm.cjs');
4
+ require('./PostgresMigrator-M9jpzOvN.cjs');
5
+ const require_PostgresObjectionMigrator = require('./PostgresObjectionMigrator-DSaPhwjY.cjs');
6
6
  const require_VitestTransactionIsolator = require('./VitestTransactionIsolator-CMfJXZP8.cjs');
7
7
  const require_VitestObjectionTransactionIsolator = require('./VitestObjectionTransactionIsolator-CdLRrzNf.cjs');
8
8
 
@@ -1,8 +1,8 @@
1
- import { FakerFactory, faker } from "./faker-Cg76aFNO.cjs";
2
- import { ExtractSeedAttrs, FactorySeed } from "./Factory-BOX312yd.cjs";
3
- import { ObjectionFactory } from "./ObjectionFactory-CD-WFuMJ.cjs";
4
- import "./PostgresMigrator-Bres0U6E.cjs";
5
- import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-CPfBAP7r.cjs";
1
+ import { FakerFactory, faker } from "./faker-Dg3trU4a.cjs";
2
+ import { ExtractSeedAttrs, FactorySeed } from "./Factory-Cwzho3c8.cjs";
3
+ import { ObjectionFactory } from "./ObjectionFactory-DW-qwnqO.cjs";
4
+ import "./PostgresMigrator-CeYy-eHF.cjs";
5
+ import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-DHVC9h_P.cjs";
6
6
  import { DatabaseConnection, DatabaseFixtures, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions } from "./VitestTransactionIsolator-CSroc7Df.cjs";
7
7
  import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator-BXoR6xdG.cjs";
8
8
  import { Knex } from "knex";
@@ -1,8 +1,8 @@
1
1
  import { FakerFactory, faker } from "./faker-DsYCplsG.mjs";
2
2
  import { ExtractSeedAttrs, FactorySeed } from "./Factory-CVR3GdkW.mjs";
3
3
  import { ObjectionFactory } from "./ObjectionFactory-DkJUf-uM.mjs";
4
- import "./PostgresMigrator-S-YYosAC.mjs";
5
- import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-DVEqB5tp.mjs";
4
+ import "./PostgresMigrator-C_QQ6q35.mjs";
5
+ import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-1j6YIB1c.mjs";
6
6
  import { DatabaseConnection, DatabaseFixtures, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions } from "./VitestTransactionIsolator-BNWJqh9f.mjs";
7
7
  import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator-x6hY5j4u.mjs";
8
8
  import { TestAPI } from "vitest";
@@ -1,8 +1,8 @@
1
1
  import "./Factory-BFVnMMCC.mjs";
2
2
  import { faker } from "./faker-BGKYFoCT.mjs";
3
3
  import { ObjectionFactory } from "./ObjectionFactory-QCJ7u0Ql.mjs";
4
- import "./PostgresMigrator-DcP1o-T6.mjs";
5
- import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-BJ5X48U8.mjs";
4
+ import "./PostgresMigrator-DVAY04qN.mjs";
5
+ import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-DjPKdUbm.mjs";
6
6
  import { IsolationLevel, extendWithFixtures } from "./VitestTransactionIsolator-DQ7tLqgV.mjs";
7
7
  import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator-OF2osYY5.mjs";
8
8
 
@@ -1,2 +1,2 @@
1
- import { DirectoryFixtures, itWithDir } from "../directory-DGOcVlKD.cjs";
1
+ import { DirectoryFixtures, itWithDir } from "../directory-DAnMWi50.cjs";
2
2
  export { DirectoryFixtures, itWithDir };
@@ -1,2 +1,2 @@
1
- import { DirectoryFixtures, itWithDir } from "../directory-YzQUGC5g.mjs";
1
+ import { DirectoryFixtures, itWithDir } from "../directory-CYXmolu1.mjs";
2
2
  export { DirectoryFixtures, itWithDir };
@@ -1,2 +1,2 @@
1
- import { itWithDir } from "../directory-DGOcVlKD.cjs";
1
+ import { itWithDir } from "../directory-DAnMWi50.cjs";
2
2
  export { itWithDir };
@@ -1,2 +1,2 @@
1
- import { itWithDir } from "../directory-YzQUGC5g.mjs";
1
+ import { itWithDir } from "../directory-CYXmolu1.mjs";
2
2
  export { itWithDir };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/testkit",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -80,8 +80,8 @@
80
80
  "vitest": "~3.2.4",
81
81
  "@types/aws-lambda": ">=8.10.92",
82
82
  "better-auth": ">=1.3.34",
83
- "@geekmidas/logger": "^1.0.0",
84
- "@geekmidas/envkit": "^1.0.3"
83
+ "@geekmidas/envkit": "^1.0.3",
84
+ "@geekmidas/logger": "^1.0.0"
85
85
  },
86
86
  "peerDependenciesMeta": {
87
87
  "@geekmidas/envkit": {
@@ -40,6 +40,18 @@ const logger = console;
40
40
  * const cleanup = await migrator.start();
41
41
  * // Run tests...
42
42
  * await cleanup();
43
+ *
44
+ * // With afterCreate hook to create per-app users
45
+ * import { runInitScript } from '@geekmidas/testkit/postgres';
46
+ *
47
+ * const migrator = new PostgresKyselyMigrator({
48
+ * uri: 'postgresql://localhost:5432/test_db',
49
+ * db,
50
+ * provider,
51
+ * afterCreate: async (uri) => {
52
+ * await runInitScript('docker/postgres/init.sh', uri, env);
53
+ * },
54
+ * });
43
55
  * ```
44
56
  */
45
57
  export class PostgresKyselyMigrator extends PostgresMigrator {
@@ -50,15 +62,17 @@ export class PostgresKyselyMigrator extends PostgresMigrator {
50
62
  * @param options.uri - PostgreSQL connection URI
51
63
  * @param options.db - Kysely database instance
52
64
  * @param options.provider - Migration provider for locating migration files
65
+ * @param options.afterCreate - Optional hook called after database creation but before migrations
53
66
  */
54
67
  constructor(
55
68
  private options: {
56
69
  uri: string;
57
70
  db: Kysely<any>;
58
71
  provider: MigrationProvider;
72
+ afterCreate?: (uri: string) => Promise<void>;
59
73
  },
60
74
  ) {
61
- super(options.uri);
75
+ super(options.uri, options.afterCreate);
62
76
  }
63
77
 
64
78
  /**
@@ -57,6 +57,17 @@ const logger = console;
57
57
  * const migrator = new MyMigrator('postgresql://localhost:5432/test_db');
58
58
  * const cleanup = await migrator.start();
59
59
  *
60
+ * // With afterCreate hook (e.g. run init script to create per-app users)
61
+ * import { runInitScript } from '@geekmidas/testkit/postgres';
62
+ *
63
+ * const migrator = new MyMigrator(
64
+ * 'postgresql://localhost:5432/test_db',
65
+ * async (uri) => {
66
+ * await runInitScript('docker/postgres/init.sh', uri, env);
67
+ * },
68
+ * );
69
+ * const cleanup = await migrator.start();
70
+ *
60
71
  * // Run tests...
61
72
  *
62
73
  * // Clean up
@@ -68,8 +79,12 @@ export abstract class PostgresMigrator {
68
79
  * Creates a new PostgresMigrator instance.
69
80
  *
70
81
  * @param uri - PostgreSQL connection URI
82
+ * @param afterCreate - Optional hook called after database creation but before migrations
71
83
  */
72
- constructor(private uri: string) {}
84
+ constructor(
85
+ private uri: string,
86
+ private afterCreate?: (uri: string) => Promise<void>,
87
+ ) {}
73
88
 
74
89
  /**
75
90
  * Abstract method to be implemented by subclasses.
@@ -161,7 +176,9 @@ export abstract class PostgresMigrator {
161
176
  const { database, db } = await setupClient(this.uri);
162
177
  try {
163
178
  await PostgresMigrator.create(this.uri);
164
- // Implement migration logic here
179
+ if (this.afterCreate) {
180
+ await this.afterCreate(this.uri);
181
+ }
165
182
  await this.migrate();
166
183
  logger.log(`Migrating database: ${database}`);
167
184
  // Example: await db.query('CREATE TABLE example (id SERIAL PRIMARY KEY)');
@@ -577,6 +577,110 @@ describe('PostgresKyselyMigrator', () => {
577
577
  });
578
578
  });
579
579
 
580
+ describe('afterCreate hook', () => {
581
+ it('should call afterCreate before migrations run', async () => {
582
+ const hookDbName = `test_kysely_hook_${Date.now()}`;
583
+ const uri = `postgresql://geekmidas:geekmidas@localhost:5432/${hookDbName}`;
584
+ const callOrder: string[] = [];
585
+
586
+ const db = new Kysely<TestSchema>({
587
+ dialect: new PostgresDialect({
588
+ pool: new Pool({
589
+ host: 'localhost',
590
+ port: 5432,
591
+ user: 'geekmidas',
592
+ password: 'geekmidas',
593
+ database: hookDbName,
594
+ }),
595
+ }),
596
+ });
597
+
598
+ const provider = new TestMigrationProvider();
599
+ provider.addMigration('001_create_table', {
600
+ up: async (db) => {
601
+ callOrder.push('migrate');
602
+ await db.schema
603
+ .createTable('items')
604
+ .addColumn('id', 'serial', (col) => col.primaryKey())
605
+ .execute();
606
+ },
607
+ });
608
+
609
+ const migrator = new PostgresKyselyMigrator({
610
+ uri,
611
+ db,
612
+ provider,
613
+ afterCreate: async (receivedUri) => {
614
+ callOrder.push('afterCreate');
615
+ expect(receivedUri).toBe(uri);
616
+ },
617
+ });
618
+
619
+ const cleanup = await migrator.start();
620
+
621
+ expect(callOrder).toEqual(['afterCreate', 'migrate']);
622
+
623
+ await cleanup();
624
+ });
625
+
626
+ it('should allow creating users and schemas before migrations', async () => {
627
+ const schemaDbName = `test_kysely_schema_hook_${Date.now()}`;
628
+ const uri = `postgresql://geekmidas:geekmidas@localhost:5432/${schemaDbName}`;
629
+
630
+ const db = new Kysely<TestSchema>({
631
+ dialect: new PostgresDialect({
632
+ pool: new Pool({
633
+ host: 'localhost',
634
+ port: 5432,
635
+ user: 'geekmidas',
636
+ password: 'geekmidas',
637
+ database: schemaDbName,
638
+ }),
639
+ }),
640
+ });
641
+
642
+ const provider = new TestMigrationProvider();
643
+ provider.addMigration('001_use_schema', {
644
+ up: async (db) => {
645
+ // Verify schema exists (created by afterCreate)
646
+ const result =
647
+ await sql`SELECT schema_name FROM information_schema.schemata WHERE schema_name = 'app'`.execute(
648
+ db,
649
+ );
650
+ if (result.rows.length === 0) {
651
+ throw new Error('Expected app schema to exist');
652
+ }
653
+ await db.schema
654
+ .createTable('items')
655
+ .addColumn('id', 'serial', (col) => col.primaryKey())
656
+ .execute();
657
+ },
658
+ });
659
+
660
+ const migrator = new PostgresKyselyMigrator({
661
+ uri,
662
+ db,
663
+ provider,
664
+ afterCreate: async () => {
665
+ const client = new Client({
666
+ host: 'localhost',
667
+ port: 5432,
668
+ user: 'geekmidas',
669
+ password: 'geekmidas',
670
+ database: schemaDbName,
671
+ });
672
+ await client.connect();
673
+ await client.query('CREATE SCHEMA IF NOT EXISTS app');
674
+ await client.end();
675
+ },
676
+ });
677
+
678
+ const cleanup = await migrator.start();
679
+
680
+ await cleanup();
681
+ });
682
+ });
683
+
580
684
  describe('error scenarios', () => {
581
685
  it('should handle provider errors', async () => {
582
686
  const providerErrorDbName = `test_provider_error_${Date.now()}`;