@geekmidas/testkit 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/{Factory-BOX312yd.d.cts → Factory-C6W78ulZ.d.mts} +2 -2
- package/dist/{Factory-BOX312yd.d.cts.map → Factory-C6W78ulZ.d.mts.map} +1 -1
- package/dist/{Factory-SFupxRC2.d.mts → Factory-D28yjUj5.d.cts} +2 -2
- package/dist/{Factory-SFupxRC2.d.mts.map → Factory-D28yjUj5.d.cts.map} +1 -1
- package/dist/Factory.d.cts +2 -2
- package/dist/Factory.d.mts +2 -2
- package/dist/{KyselyFactory-Dy5zzV4B.d.cts → KyselyFactory-Cc2UmOJk.d.mts} +3 -3
- package/dist/{KyselyFactory-Dy5zzV4B.d.cts.map → KyselyFactory-Cc2UmOJk.d.mts.map} +1 -1
- package/dist/{KyselyFactory-vAxYodck.d.mts → KyselyFactory-OUH03l2q.d.cts} +3 -3
- package/dist/{KyselyFactory-vAxYodck.d.mts.map → KyselyFactory-OUH03l2q.d.cts.map} +1 -1
- package/dist/KyselyFactory.d.cts +3 -3
- package/dist/KyselyFactory.d.mts +3 -3
- package/dist/{ObjectionFactory-BWjB49-i.d.mts → ObjectionFactory-B1WkcfZY.d.cts} +3 -3
- package/dist/{ObjectionFactory-BWjB49-i.d.mts.map → ObjectionFactory-B1WkcfZY.d.cts.map} +1 -1
- package/dist/{ObjectionFactory-CD-WFuMJ.d.cts → ObjectionFactory-BYnPr9ZP.d.mts} +3 -3
- package/dist/{ObjectionFactory-CD-WFuMJ.d.cts.map → ObjectionFactory-BYnPr9ZP.d.mts.map} +1 -1
- package/dist/ObjectionFactory.d.cts +3 -3
- package/dist/ObjectionFactory.d.mts +3 -3
- package/dist/{PostgresKyselyMigrator-6sE1KOni.mjs → PostgresKyselyMigrator-B4pScubb.mjs} +2 -2
- package/dist/{PostgresKyselyMigrator-6sE1KOni.mjs.map → PostgresKyselyMigrator-B4pScubb.mjs.map} +1 -1
- package/dist/{PostgresKyselyMigrator-D6IbPq8t.cjs → PostgresKyselyMigrator-C7ljZYvq.cjs} +2 -2
- package/dist/{PostgresKyselyMigrator-D6IbPq8t.cjs.map → PostgresKyselyMigrator-C7ljZYvq.cjs.map} +1 -1
- package/dist/PostgresKyselyMigrator.cjs +2 -2
- package/dist/PostgresKyselyMigrator.mjs +2 -2
- package/dist/PostgresMigrator-Bres0U6E.d.cts.map +1 -1
- package/dist/{PostgresMigrator-D6dQn0x2.cjs → PostgresMigrator-CHiBYEg_.cjs} +7 -2
- package/dist/PostgresMigrator-CHiBYEg_.cjs.map +1 -0
- package/dist/{PostgresMigrator-BjjenqSd.mjs → PostgresMigrator-DcP1o-T6.mjs} +7 -2
- package/dist/PostgresMigrator-DcP1o-T6.mjs.map +1 -0
- package/dist/PostgresMigrator-S-YYosAC.d.mts.map +1 -1
- package/dist/PostgresMigrator.cjs +1 -1
- package/dist/PostgresMigrator.mjs +1 -1
- package/dist/{PostgresObjectionMigrator-D_QxXbIN.mjs → PostgresObjectionMigrator-BJ5X48U8.mjs} +2 -2
- package/dist/{PostgresObjectionMigrator-D_QxXbIN.mjs.map → PostgresObjectionMigrator-BJ5X48U8.mjs.map} +1 -1
- package/dist/{PostgresObjectionMigrator-DK8ODIHQ.cjs → PostgresObjectionMigrator-BXLAVVwm.cjs} +2 -2
- package/dist/{PostgresObjectionMigrator-DK8ODIHQ.cjs.map → PostgresObjectionMigrator-BXLAVVwm.cjs.map} +1 -1
- package/dist/PostgresObjectionMigrator.cjs +2 -2
- package/dist/PostgresObjectionMigrator.mjs +2 -2
- package/dist/better-auth.d.cts +2 -2
- package/dist/better-auth.d.mts +2 -2
- package/dist/{directory-B-Ozljzk.mjs → directory-BxjqmtCT.mjs} +6 -1
- package/dist/directory-BxjqmtCT.mjs.map +1 -0
- package/dist/directory-CVrfTq1I.d.mts.map +1 -1
- package/dist/{directory-BVC8g7cX.cjs → directory-DD_xQoSh.cjs} +6 -1
- package/dist/directory-DD_xQoSh.cjs.map +1 -0
- package/dist/{directory-DAnMWi50.d.cts → directory-DGOcVlKD.d.cts} +3 -3
- package/dist/directory-DGOcVlKD.d.cts.map +1 -0
- package/dist/{faker-Cg76aFNO.d.cts → faker-CbYiF-8_.d.cts} +3 -3
- package/dist/{faker-Cg76aFNO.d.cts.map → faker-CbYiF-8_.d.cts.map} +1 -1
- package/dist/{faker-DHh7xs4u.d.mts → faker-D9gz7KjY.d.mts} +3 -3
- package/dist/{faker-DHh7xs4u.d.mts.map → faker-D9gz7KjY.d.mts.map} +1 -1
- package/dist/faker.d.cts +1 -1
- package/dist/faker.d.mts +1 -1
- package/dist/kysely.cjs +2 -2
- package/dist/kysely.d.cts +3 -3
- package/dist/kysely.d.mts +3 -3
- package/dist/kysely.mjs +2 -2
- package/dist/objection.cjs +2 -2
- package/dist/objection.d.cts +3 -3
- package/dist/objection.d.mts +3 -3
- package/dist/objection.mjs +2 -2
- package/dist/os/directory.cjs +1 -1
- package/dist/os/directory.d.cts +1 -1
- package/dist/os/directory.mjs +1 -1
- package/dist/os/index.cjs +1 -1
- package/dist/os/index.d.cts +1 -1
- package/dist/os/index.mjs +1 -1
- package/package.json +3 -3
- package/src/PostgresMigrator.ts +9 -1
- package/src/os/directory.ts +4 -0
- package/dist/PostgresMigrator-BjjenqSd.mjs.map +0 -1
- package/dist/PostgresMigrator-D6dQn0x2.cjs.map +0 -1
- package/dist/directory-B-Ozljzk.mjs.map +0 -1
- package/dist/directory-BVC8g7cX.cjs.map +0 -1
- package/dist/directory-DAnMWi50.d.cts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @geekmidas/testkit
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ✨ [`83a24de`](https://github.com/geekmidas/toolbox/commit/83a24de902b3fadd98444cab552ecd84f32b6661) Thanks [@geekmidas](https://github.com/geekmidas)! - Add pg-boss event publisher/subscriber, CLI setup and upgrade commands, and secrets sync via AWS SSM
|
|
8
|
+
- ✨ **@geekmidas/events**: Add pg-boss backend for event publishing and subscribing with connection string support
|
|
9
|
+
- ✨ **@geekmidas/cli**: Add `gkm setup` command for dev environment initialization, `gkm upgrade` command with workspace detection, and secrets push/pull via AWS SSM Parameter Store
|
|
10
|
+
- 🐛 **@geekmidas/testkit**: Fix database creation race condition in PostgresMigrator
|
|
11
|
+
- ✨ **@geekmidas/constructs**: Add integration tests for pg-boss with HonoEndpoint
|
|
12
|
+
|
|
13
|
+
## 1.0.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- ✨ [`3b6d7d9`](https://github.com/geekmidas/toolbox/commit/3b6d7d9ed41dc08675395d937248a8ab754af9e1) Thanks [@geekmidas](https://github.com/geekmidas)! - Add state provider configuration to workspace config
|
|
18
|
+
|
|
3
19
|
## 1.0.0
|
|
4
20
|
|
|
5
21
|
### Major Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FakerFactory } from "./faker-
|
|
1
|
+
import { FakerFactory } from "./faker-D9gz7KjY.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/Factory.d.ts
|
|
4
4
|
|
|
@@ -144,4 +144,4 @@ type ExtractSeedAttrs<T> = T extends ((context: {
|
|
|
144
144
|
//# sourceMappingURL=Factory.d.ts.map
|
|
145
145
|
//#endregion
|
|
146
146
|
export { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder };
|
|
147
|
-
//# sourceMappingURL=Factory-
|
|
147
|
+
//# sourceMappingURL=Factory-C6W78ulZ.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Factory-
|
|
1
|
+
{"version":3,"file":"Factory-C6W78ulZ.d.mts","names":[],"sources":["../src/Factory.ts"],"sourcesContent":[],"mappings":";;;;;;AA2BA;;;;;;;;;;;;;;;;;;;;;;;AAiD6B,uBAjDP,OAiDO,CAAA,iBAhDX,MAgDW,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cA/Cd,MA+Cc,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA;EAAQ;;;;;;;;;;;;;;;;EAavB,OAAA,UAAA,CAAA,aA1CkB,WA0ClB,CAAA,CAAA,MAAA,EA1CuC,IA0CvC,CAAA,EA1C8C,IA0C9C;EA8BF;;;;;;EAK0C,SAAW,MAAA,CAAA,UAAA,MApEhC,QAoEgC,CAAA,CAAA,WAAA,EAnElD,CAmEkD,EAAA,KAAA,CAAA,EAlEvD,UAkEuD,CAlE5C,QAkE4C,CAlEnC,CAkEmC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAjE7D,OAiE6D,CAjErD,OAiEqD,CAjE7C,UAiE6C,CAjElC,QAiEkC,CAjEzB,CAiEyB,CAAA,CAAA,CAAA,CAAA;EAAM;AAAP;AAgChE;;;;;EAKsD,SAAe,UAAA,CAAA,UAAA,MA7FhC,QA6FgC,CAAA,CAAA,KAAA,EAAA,MAAA,EAAA,WAAA,EA3FtD,CA2FsD,EAAA,KAAA,CAAA,EAzFhE,UAyFgE,CAzFrD,QAyFqD,CAzF5C,CAyF4C,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,GAAA,EAAA,MAAA,EAAA,KAAA,EAtFzD,YAsFyD,EAAA,GArF3D,OAqF2D,CArFnD,UAqFmD,CArFxC,QAqFwC,CArF/B,CAqF+B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EApFjE,OAoFiE,CApFzD,OAoFyD,CApFjD,UAoFiD,CApFtC,QAoFsC,CApF7B,CAoF6B,CAAA,CAAA,CAAA,EAAA,CAAA;EAAM;AAAP;AAMpE;;;;AAKI;gCAtF2B,iBACnB,WACF,iBAAiB,MAAM,MAC7B,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BT,kFAKA,gBAAgB,aAAa,OAAO,SAAS,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgCrD;SAKW;WAAgB;MAAa;MAAS,QAAQ;;;;;KAMzD,sBAAsB;;;;aAK/B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FakerFactory } from "./faker-
|
|
1
|
+
import { FakerFactory } from "./faker-CbYiF-8_.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/Factory.d.ts
|
|
4
4
|
|
|
@@ -144,4 +144,4 @@ type ExtractSeedAttrs<T> = T extends ((context: {
|
|
|
144
144
|
//# sourceMappingURL=Factory.d.ts.map
|
|
145
145
|
//#endregion
|
|
146
146
|
export { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder };
|
|
147
|
-
//# sourceMappingURL=Factory-
|
|
147
|
+
//# sourceMappingURL=Factory-D28yjUj5.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Factory-
|
|
1
|
+
{"version":3,"file":"Factory-D28yjUj5.d.cts","names":[],"sources":["../src/Factory.ts"],"sourcesContent":[],"mappings":";;;;;;AA2BA;;;;;;;;;;;;;;;;;;;;;;;AAiD6B,uBAjDP,OAiDO,CAAA,iBAhDX,MAgDW,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cA/Cd,MA+Cc,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA;EAAQ;;;;;;;;;;;;;;;;EAavB,OAAA,UAAA,CAAA,aA1CkB,WA0ClB,CAAA,CAAA,MAAA,EA1CuC,IA0CvC,CAAA,EA1C8C,IA0C9C;EA8BF;;;;;;EAK0C,SAAW,MAAA,CAAA,UAAA,MApEhC,QAoEgC,CAAA,CAAA,WAAA,EAnElD,CAmEkD,EAAA,KAAA,CAAA,EAlEvD,UAkEuD,CAlE5C,QAkE4C,CAlEnC,CAkEmC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAjE7D,OAiE6D,CAjErD,OAiEqD,CAjE7C,UAiE6C,CAjElC,QAiEkC,CAjEzB,CAiEyB,CAAA,CAAA,CAAA,CAAA;EAAM;AAAP;AAgChE;;;;;EAKsD,SAAe,UAAA,CAAA,UAAA,MA7FhC,QA6FgC,CAAA,CAAA,KAAA,EAAA,MAAA,EAAA,WAAA,EA3FtD,CA2FsD,EAAA,KAAA,CAAA,EAzFhE,UAyFgE,CAzFrD,QAyFqD,CAzF5C,CAyF4C,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,GAAA,EAAA,MAAA,EAAA,KAAA,EAtFzD,YAsFyD,EAAA,GArF3D,OAqF2D,CArFnD,UAqFmD,CArFxC,QAqFwC,CArF/B,CAqF+B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EApFjE,OAoFiE,CApFzD,OAoFyD,CApFjD,UAoFiD,CApFtC,QAoFsC,CApF7B,CAoF6B,CAAA,CAAA,CAAA,EAAA,CAAA;EAAM;AAAP;AAMpE;;;;AAKI;gCAtF2B,iBACnB,WACF,iBAAiB,MAAM,MAC7B,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BT,kFAKA,gBAAgB,aAAa,OAAO,SAAS,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgCrD;SAKW;WAAgB;MAAa;MAAS,QAAQ;;;;;KAMzD,sBAAsB;;;;aAK/B"}
|
package/dist/Factory.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder } from "./Factory-
|
|
1
|
+
import "./faker-CbYiF-8_.cjs";
|
|
2
|
+
import { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder } from "./Factory-D28yjUj5.cjs";
|
|
3
3
|
export { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder };
|
package/dist/Factory.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder } from "./Factory-
|
|
1
|
+
import "./faker-D9gz7KjY.mjs";
|
|
2
|
+
import { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder } from "./Factory-C6W78ulZ.mjs";
|
|
3
3
|
export { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FakerFactory } from "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-
|
|
1
|
+
import { FakerFactory } from "./faker-D9gz7KjY.mjs";
|
|
2
|
+
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-C6W78ulZ.mjs";
|
|
3
3
|
import { ControlledTransaction, Insertable, Kysely, Selectable } from "kysely";
|
|
4
4
|
|
|
5
5
|
//#region src/KyselyFactory.d.ts
|
|
@@ -225,4 +225,4 @@ declare class KyselyFactory<DB, Builders extends Record<string, any>, Seeds exte
|
|
|
225
225
|
//# sourceMappingURL=KyselyFactory.d.ts.map
|
|
226
226
|
//#endregion
|
|
227
227
|
export { KyselyFactory };
|
|
228
|
-
//# sourceMappingURL=KyselyFactory-
|
|
228
|
+
//# sourceMappingURL=KyselyFactory-Cc2UmOJk.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KyselyFactory-
|
|
1
|
+
{"version":3,"file":"KyselyFactory-Cc2UmOJk.d.mts","names":[],"sources":["../src/KyselyFactory.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA+CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GK,cA5GQ,aA4GR,CAAA,EAAA,EAAA,iBA1Ga,MA0Gb,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cAzGU,MAyGV,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,SAxGK,OAwGL,CAxGa,QAwGb,EAxGuB,KAwGvB,CAAA,CAAA;EAAO,QACoB,QAAA;EAAE,QAAC,KAAA;EAAS,QAAvB,EAAA;EAAU;;;;;;;;;;;;;;;;;;;;;EAwJf,OACK,UAAA,CAAA,aA5OoB,WA4OpB,CAAA,CAAA,MAAA,EA5OyC,IA4OzC,CAAA,EA5OgD,IA4OhD;EAAQ;;;;;;;EAClB,WACuB,CAAA,QAAA,EAlOd,QAkOc,EAAA,KAAA,EAjOjB,KAiOiB,EAAA,EAAA,EAhOpB,MAgOoB,CAhOb,EAgOa,CAAA,GAhOP,qBAgOO,CAhOe,EAgOf,EAAA,EAAA,CAAA;EAAQ;;;;;;;;;;;;;;;;;;;;;;;AApQzB;;;;;;;;;;;;;;;;;;;;;;;;mDA0FS,2BACV,QAAQ,WAAW,GAAG,eAAe,QAClD,WAAW,GAAG,sCAGN,WAAW,GAAG,oBAEhB;WAEC;aACE;QACL,OAAO;WACJ;QAEL,QAAQ,WAAW,GAAG,eACtB,QAAQ,QAAQ,WAAW,GAAG,8CAG1B,gBACE,aACL,OAAO,YACJ,iBACH,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAuEgB,uBACf,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAqEN,sCAEnB,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;6BACN,sCAEnB,+BAGL,iBACH,WAAW,SAAS,SAAS,QAAQ,WAAW,SAAS,UAC5D,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAsDlB,iBACV,WACF,iBAAiB,MAAM,MAC7B,WAAW,MAAM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FakerFactory } from "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-
|
|
1
|
+
import { FakerFactory } from "./faker-CbYiF-8_.cjs";
|
|
2
|
+
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-D28yjUj5.cjs";
|
|
3
3
|
import { ControlledTransaction, Insertable, Kysely, Selectable } from "kysely";
|
|
4
4
|
|
|
5
5
|
//#region src/KyselyFactory.d.ts
|
|
@@ -225,4 +225,4 @@ declare class KyselyFactory<DB, Builders extends Record<string, any>, Seeds exte
|
|
|
225
225
|
//# sourceMappingURL=KyselyFactory.d.ts.map
|
|
226
226
|
//#endregion
|
|
227
227
|
export { KyselyFactory };
|
|
228
|
-
//# sourceMappingURL=KyselyFactory-
|
|
228
|
+
//# sourceMappingURL=KyselyFactory-OUH03l2q.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KyselyFactory-
|
|
1
|
+
{"version":3,"file":"KyselyFactory-OUH03l2q.d.cts","names":[],"sources":["../src/KyselyFactory.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA+CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GK,cA5GQ,aA4GR,CAAA,EAAA,EAAA,iBA1Ga,MA0Gb,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cAzGU,MAyGV,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,SAxGK,OAwGL,CAxGa,QAwGb,EAxGuB,KAwGvB,CAAA,CAAA;EAAO,QACoB,QAAA;EAAE,QAAC,KAAA;EAAS,QAAvB,EAAA;EAAU;;;;;;;;;;;;;;;;;;;;;EAwJf,OACK,UAAA,CAAA,aA5OoB,WA4OpB,CAAA,CAAA,MAAA,EA5OyC,IA4OzC,CAAA,EA5OgD,IA4OhD;EAAQ;;;;;;;EAClB,WACuB,CAAA,QAAA,EAlOd,QAkOc,EAAA,KAAA,EAjOjB,KAiOiB,EAAA,EAAA,EAhOpB,MAgOoB,CAhOb,EAgOa,CAAA,GAhOP,qBAgOO,CAhOe,EAgOf,EAAA,EAAA,CAAA;EAAQ;;;;;;;;;;;;;;;;;;;;;;;AApQzB;;;;;;;;;;;;;;;;;;;;;;;;mDA0FS,2BACV,QAAQ,WAAW,GAAG,eAAe,QAClD,WAAW,GAAG,sCAGN,WAAW,GAAG,oBAEhB;WAEC;aACE;QACL,OAAO;WACJ;QAEL,QAAQ,WAAW,GAAG,eACtB,QAAQ,QAAQ,WAAW,GAAG,8CAG1B,gBACE,aACL,OAAO,YACJ,iBACH,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAuEgB,uBACf,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAqEN,sCAEnB,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;6BACN,sCAEnB,+BAGL,iBACH,WAAW,SAAS,SAAS,QAAQ,WAAW,SAAS,UAC5D,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAsDlB,iBACV,WACF,iBAAiB,MAAM,MAC7B,WAAW,MAAM"}
|
package/dist/KyselyFactory.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./faker-
|
|
2
|
-
import "./Factory-
|
|
3
|
-
import { KyselyFactory } from "./KyselyFactory-
|
|
1
|
+
import "./faker-CbYiF-8_.cjs";
|
|
2
|
+
import "./Factory-D28yjUj5.cjs";
|
|
3
|
+
import { KyselyFactory } from "./KyselyFactory-OUH03l2q.cjs";
|
|
4
4
|
export { KyselyFactory };
|
package/dist/KyselyFactory.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./faker-
|
|
2
|
-
import "./Factory-
|
|
3
|
-
import { KyselyFactory } from "./KyselyFactory-
|
|
1
|
+
import "./faker-D9gz7KjY.mjs";
|
|
2
|
+
import "./Factory-C6W78ulZ.mjs";
|
|
3
|
+
import { KyselyFactory } from "./KyselyFactory-Cc2UmOJk.mjs";
|
|
4
4
|
export { KyselyFactory };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FakerFactory } from "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-
|
|
1
|
+
import { FakerFactory } from "./faker-CbYiF-8_.cjs";
|
|
2
|
+
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-D28yjUj5.cjs";
|
|
3
3
|
import { Knex } from "knex";
|
|
4
4
|
import { Model } from "objection";
|
|
5
5
|
|
|
@@ -238,4 +238,4 @@ declare class ObjectionFactory<Builders extends Record<string, any>, Seeds exten
|
|
|
238
238
|
//# sourceMappingURL=ObjectionFactory.d.ts.map
|
|
239
239
|
//#endregion
|
|
240
240
|
export { ObjectionFactory };
|
|
241
|
-
//# sourceMappingURL=ObjectionFactory-
|
|
241
|
+
//# sourceMappingURL=ObjectionFactory-B1WkcfZY.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectionFactory-
|
|
1
|
+
{"version":3,"file":"ObjectionFactory-B1WkcfZY.d.cts","names":[],"sources":["../src/ObjectionFactory.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAyCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0Gc,cA1GD,gBA0GC,CAAA,iBAzGI,MAyGJ,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cAxGC,MAwGD,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,SAvGJ,OAuGI,CAvGI,QAuGJ,EAvGc,KAuGd,CAAA,CAAA;EAAM,QAAd,QAAA;EAAO,QAqDO,KAAA;EAAQ,QACX,EAAA;EAAK;;;;;;;;;;;;;;;;;;;;;EA2GX,OACuB,UAAA,CAAA,aAnPO,WAmPP,CAAA,CAAA,MAAA,EAnP4B,IAmP5B,CAAA,EAnPmC,IAmPnC;EAAQ;;;;;;;;;;;;;;;;;;;AAzQzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAmFO,qBACR,QAAQ,aAAa,WAAW,QAAQ,aAAa,kCAE1D,aAAa,qBAEV;WAEJ;aACE;QACL;WACG;QAEL,QAAQ,aAAa,WACrB,QAAQ,QAAQ,aAAa,0CAGzB,gBACE,aACL,aACG,iBACH,QAAQ;;;;;;;;wBAqDM,iBACH,WACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAoCgB,uBACf,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA+DN,sCAEnB,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;6BACN,sCAEnB,+BACe,iBAAiB,WAAW,SAAS,SAC/D,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAgFlB,iBACV,WACF,iBAAiB,MAAM,MAC7B,WAAW,MAAM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FakerFactory } from "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-
|
|
1
|
+
import { FakerFactory } from "./faker-D9gz7KjY.mjs";
|
|
2
|
+
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-C6W78ulZ.mjs";
|
|
3
3
|
import { Knex } from "knex";
|
|
4
4
|
import { Model } from "objection";
|
|
5
5
|
|
|
@@ -238,4 +238,4 @@ declare class ObjectionFactory<Builders extends Record<string, any>, Seeds exten
|
|
|
238
238
|
//# sourceMappingURL=ObjectionFactory.d.ts.map
|
|
239
239
|
//#endregion
|
|
240
240
|
export { ObjectionFactory };
|
|
241
|
-
//# sourceMappingURL=ObjectionFactory-
|
|
241
|
+
//# sourceMappingURL=ObjectionFactory-BYnPr9ZP.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectionFactory-
|
|
1
|
+
{"version":3,"file":"ObjectionFactory-BYnPr9ZP.d.mts","names":[],"sources":["../src/ObjectionFactory.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAyCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0Gc,cA1GD,gBA0GC,CAAA,iBAzGI,MAyGJ,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cAxGC,MAwGD,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,SAvGJ,OAuGI,CAvGI,QAuGJ,EAvGc,KAuGd,CAAA,CAAA;EAAM,QAAd,QAAA;EAAO,QAqDO,KAAA;EAAQ,QACX,EAAA;EAAK;;;;;;;;;;;;;;;;;;;;;EA2GX,OACuB,UAAA,CAAA,aAnPO,WAmPP,CAAA,CAAA,MAAA,EAnP4B,IAmP5B,CAAA,EAnPmC,IAmPnC;EAAQ;;;;;;;;;;;;;;;;;;;AAzQzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAmFO,qBACR,QAAQ,aAAa,WAAW,QAAQ,aAAa,kCAE1D,aAAa,qBAEV;WAEJ;aACE;QACL;WACG;QAEL,QAAQ,aAAa,WACrB,QAAQ,QAAQ,aAAa,0CAGzB,gBACE,aACL,aACG,iBACH,QAAQ;;;;;;;;wBAqDM,iBACH,WACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAoCgB,uBACf,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA+DN,sCAEnB,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;6BACN,sCAEnB,+BACe,iBAAiB,WAAW,SAAS,SAC/D,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAgFlB,iBACV,WACF,iBAAiB,MAAM,MAC7B,WAAW,MAAM"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./faker-
|
|
2
|
-
import "./Factory-
|
|
3
|
-
import { ObjectionFactory } from "./ObjectionFactory-
|
|
1
|
+
import "./faker-CbYiF-8_.cjs";
|
|
2
|
+
import "./Factory-D28yjUj5.cjs";
|
|
3
|
+
import { ObjectionFactory } from "./ObjectionFactory-B1WkcfZY.cjs";
|
|
4
4
|
export { ObjectionFactory };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./faker-
|
|
2
|
-
import "./Factory-
|
|
3
|
-
import { ObjectionFactory } from "./ObjectionFactory-
|
|
1
|
+
import "./faker-D9gz7KjY.mjs";
|
|
2
|
+
import "./Factory-C6W78ulZ.mjs";
|
|
3
|
+
import { ObjectionFactory } from "./ObjectionFactory-BYnPr9ZP.mjs";
|
|
4
4
|
export { ObjectionFactory };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PostgresMigrator } from "./PostgresMigrator-
|
|
1
|
+
import { PostgresMigrator } from "./PostgresMigrator-DcP1o-T6.mjs";
|
|
2
2
|
import { Migrator } from "kysely";
|
|
3
3
|
|
|
4
4
|
//#region src/PostgresKyselyMigrator.ts
|
|
@@ -79,4 +79,4 @@ var PostgresKyselyMigrator = class extends PostgresMigrator {
|
|
|
79
79
|
|
|
80
80
|
//#endregion
|
|
81
81
|
export { PostgresKyselyMigrator };
|
|
82
|
-
//# sourceMappingURL=PostgresKyselyMigrator-
|
|
82
|
+
//# sourceMappingURL=PostgresKyselyMigrator-B4pScubb.mjs.map
|
package/dist/{PostgresKyselyMigrator-6sE1KOni.mjs.map → PostgresKyselyMigrator-B4pScubb.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresKyselyMigrator-
|
|
1
|
+
{"version":3,"file":"PostgresKyselyMigrator-B4pScubb.mjs","names":["options: {\n\t\t\turi: string;\n\t\t\tdb: Kysely<any>;\n\t\t\tprovider: MigrationProvider;\n\t\t}"],"sources":["../src/PostgresKyselyMigrator.ts"],"sourcesContent":["import { type Kysely, type MigrationProvider, Migrator } from 'kysely';\nimport { PostgresMigrator } from './PostgresMigrator';\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * PostgreSQL migrator implementation for Kysely ORM.\n * Extends PostgresMigrator to provide Kysely-specific migration functionality.\n * Automatically creates test databases and applies migrations for testing environments.\n *\n * @example\n * ```typescript\n * import { FileMigrationProvider } from 'kysely';\n * import { PostgresKyselyMigrator } from '@geekmidas/testkit';\n *\n * // Create migration provider\n * const provider = new FileMigrationProvider({\n * fs: require('fs'),\n * path: require('path'),\n * migrationFolder: path.join(__dirname, 'migrations')\n * });\n *\n * // Create Kysely instance\n * const db = new Kysely<Database>({\n * dialect: new PostgresDialect({\n * pool: new Pool({ connectionString: uri })\n * })\n * });\n *\n * // Create and use migrator\n * const migrator = new PostgresKyselyMigrator({\n * uri: 'postgresql://localhost:5432/test_db',\n * db,\n * provider\n * });\n *\n * const cleanup = await migrator.start();\n * // Run tests...\n * await cleanup();\n * ```\n */\nexport class PostgresKyselyMigrator extends PostgresMigrator {\n\t/**\n\t * Creates a new PostgresKyselyMigrator instance.\n\t *\n\t * @param options - Configuration options\n\t * @param options.uri - PostgreSQL connection URI\n\t * @param options.db - Kysely database instance\n\t * @param options.provider - Migration provider for locating migration files\n\t */\n\tconstructor(\n\t\tprivate options: {\n\t\t\turi: string;\n\t\t\tdb: Kysely<any>;\n\t\t\tprovider: MigrationProvider;\n\t\t},\n\t) {\n\t\tsuper(options.uri);\n\t}\n\n\t/**\n\t * Executes Kysely 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\tconst migrator = new Migrator({\n\t\t\tdb: this.options.db,\n\t\t\tprovider: this.options.provider,\n\t\t});\n\t\tconst migrations = await migrator.migrateToLatest();\n\n\t\tif (migrations.error) {\n\t\t\tlogger.error(migrations.error, `Failed to apply migrations`);\n\t\t\tthrow migrations.error;\n\t\t}\n\n\t\tawait this.options.db.destroy();\n\n\t\tlogger.log(`Applied ${migrations.results?.length} migrations successfully`);\n\t}\n}\n"],"mappings":";;;;;;;AAMA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCf,IAAa,yBAAb,cAA4C,iBAAiB;;;;;;;;;CAS5D,YACSA,SAKP;AACD,QAAM,QAAQ,IAAI;EANV;CAOR;;;;;;;;CASD,MAAM,UAAyB;EAC9B,MAAM,WAAW,IAAI,SAAS;GAC7B,IAAI,KAAK,QAAQ;GACjB,UAAU,KAAK,QAAQ;EACvB;EACD,MAAM,aAAa,MAAM,SAAS,iBAAiB;AAEnD,MAAI,WAAW,OAAO;AACrB,UAAO,MAAM,WAAW,QAAQ,4BAA4B;AAC5D,SAAM,WAAW;EACjB;AAED,QAAM,KAAK,QAAQ,GAAG,SAAS;AAE/B,SAAO,KAAK,UAAU,WAAW,SAAS,OAAO,0BAA0B;CAC3E;AACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_PostgresMigrator = require('./PostgresMigrator-
|
|
2
|
+
const require_PostgresMigrator = require('./PostgresMigrator-CHiBYEg_.cjs');
|
|
3
3
|
const kysely = require_chunk.__toESM(require("kysely"));
|
|
4
4
|
|
|
5
5
|
//#region src/PostgresKyselyMigrator.ts
|
|
@@ -85,4 +85,4 @@ Object.defineProperty(exports, 'PostgresKyselyMigrator', {
|
|
|
85
85
|
return PostgresKyselyMigrator;
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
|
-
//# sourceMappingURL=PostgresKyselyMigrator-
|
|
88
|
+
//# sourceMappingURL=PostgresKyselyMigrator-C7ljZYvq.cjs.map
|
package/dist/{PostgresKyselyMigrator-D6IbPq8t.cjs.map → PostgresKyselyMigrator-C7ljZYvq.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresKyselyMigrator-
|
|
1
|
+
{"version":3,"file":"PostgresKyselyMigrator-C7ljZYvq.cjs","names":["PostgresMigrator","options: {\n\t\t\turi: string;\n\t\t\tdb: Kysely<any>;\n\t\t\tprovider: MigrationProvider;\n\t\t}","Migrator"],"sources":["../src/PostgresKyselyMigrator.ts"],"sourcesContent":["import { type Kysely, type MigrationProvider, Migrator } from 'kysely';\nimport { PostgresMigrator } from './PostgresMigrator';\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * PostgreSQL migrator implementation for Kysely ORM.\n * Extends PostgresMigrator to provide Kysely-specific migration functionality.\n * Automatically creates test databases and applies migrations for testing environments.\n *\n * @example\n * ```typescript\n * import { FileMigrationProvider } from 'kysely';\n * import { PostgresKyselyMigrator } from '@geekmidas/testkit';\n *\n * // Create migration provider\n * const provider = new FileMigrationProvider({\n * fs: require('fs'),\n * path: require('path'),\n * migrationFolder: path.join(__dirname, 'migrations')\n * });\n *\n * // Create Kysely instance\n * const db = new Kysely<Database>({\n * dialect: new PostgresDialect({\n * pool: new Pool({ connectionString: uri })\n * })\n * });\n *\n * // Create and use migrator\n * const migrator = new PostgresKyselyMigrator({\n * uri: 'postgresql://localhost:5432/test_db',\n * db,\n * provider\n * });\n *\n * const cleanup = await migrator.start();\n * // Run tests...\n * await cleanup();\n * ```\n */\nexport class PostgresKyselyMigrator extends PostgresMigrator {\n\t/**\n\t * Creates a new PostgresKyselyMigrator instance.\n\t *\n\t * @param options - Configuration options\n\t * @param options.uri - PostgreSQL connection URI\n\t * @param options.db - Kysely database instance\n\t * @param options.provider - Migration provider for locating migration files\n\t */\n\tconstructor(\n\t\tprivate options: {\n\t\t\turi: string;\n\t\t\tdb: Kysely<any>;\n\t\t\tprovider: MigrationProvider;\n\t\t},\n\t) {\n\t\tsuper(options.uri);\n\t}\n\n\t/**\n\t * Executes Kysely 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\tconst migrator = new Migrator({\n\t\t\tdb: this.options.db,\n\t\t\tprovider: this.options.provider,\n\t\t});\n\t\tconst migrations = await migrator.migrateToLatest();\n\n\t\tif (migrations.error) {\n\t\t\tlogger.error(migrations.error, `Failed to apply migrations`);\n\t\t\tthrow migrations.error;\n\t\t}\n\n\t\tawait this.options.db.destroy();\n\n\t\tlogger.log(`Applied ${migrations.results?.length} migrations successfully`);\n\t}\n}\n"],"mappings":";;;;;;;;AAMA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCf,IAAa,yBAAb,cAA4CA,0CAAiB;;;;;;;;;CAS5D,YACSC,SAKP;AACD,QAAM,QAAQ,IAAI;EANV;CAOR;;;;;;;;CASD,MAAM,UAAyB;EAC9B,MAAM,WAAW,IAAIC,gBAAS;GAC7B,IAAI,KAAK,QAAQ;GACjB,UAAU,KAAK,QAAQ;EACvB;EACD,MAAM,aAAa,MAAM,SAAS,iBAAiB;AAEnD,MAAI,WAAW,OAAO;AACrB,UAAO,MAAM,WAAW,QAAQ,4BAA4B;AAC5D,SAAM,WAAW;EACjB;AAED,QAAM,KAAK,QAAQ,GAAG,SAAS;AAE/B,SAAO,KAAK,UAAU,WAAW,SAAS,OAAO,0BAA0B;CAC3E;AACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require('./PostgresMigrator-
|
|
2
|
-
const require_PostgresKyselyMigrator = require('./PostgresKyselyMigrator-
|
|
1
|
+
require('./PostgresMigrator-CHiBYEg_.cjs');
|
|
2
|
+
const require_PostgresKyselyMigrator = require('./PostgresKyselyMigrator-C7ljZYvq.cjs');
|
|
3
3
|
|
|
4
4
|
exports.PostgresKyselyMigrator = require_PostgresKyselyMigrator.PostgresKyselyMigrator;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./PostgresMigrator-
|
|
2
|
-
import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-
|
|
1
|
+
import "./PostgresMigrator-DcP1o-T6.mjs";
|
|
2
|
+
import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-B4pScubb.mjs";
|
|
3
3
|
|
|
4
4
|
export { PostgresKyselyMigrator };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresMigrator-Bres0U6E.d.cts","names":[],"sources":["../src/PostgresMigrator.ts"],"sourcesContent":[],"mappings":";;AAiEA;;;;;
|
|
1
|
+
{"version":3,"file":"PostgresMigrator-Bres0U6E.d.cts","names":[],"sources":["../src/PostgresMigrator.ts"],"sourcesContent":[],"mappings":";;AAiEA;;;;;AA8FY;;;;;;;;;;;;;;;;;;uBA9FU,gBAAA;;;;;;;;;;;;;;sBAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAgFT,cAAA"}
|
|
@@ -83,7 +83,12 @@ var PostgresMigrator = class PostgresMigrator {
|
|
|
83
83
|
try {
|
|
84
84
|
await db.connect();
|
|
85
85
|
const result = await db.query(`SELECT * FROM pg_catalog.pg_database WHERE datname = '${database}'`);
|
|
86
|
-
if (result.rowCount === 0)
|
|
86
|
+
if (result.rowCount === 0) try {
|
|
87
|
+
await db.query(`CREATE DATABASE "${database}"`);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (error?.code === "42P04") return { alreadyExisted: true };
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
87
92
|
return { alreadyExisted: result.rowCount ? result.rowCount > 0 : false };
|
|
88
93
|
} finally {
|
|
89
94
|
await db.end();
|
|
@@ -150,4 +155,4 @@ Object.defineProperty(exports, 'PostgresMigrator', {
|
|
|
150
155
|
return PostgresMigrator;
|
|
151
156
|
}
|
|
152
157
|
});
|
|
153
|
-
//# sourceMappingURL=PostgresMigrator-
|
|
158
|
+
//# sourceMappingURL=PostgresMigrator-CHiBYEg_.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresMigrator-CHiBYEg_.cjs","names":["uri: string","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 * // 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 */\n\tconstructor(private uri: string) {}\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\t// Implement migration logic here\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;;;;;;;;;;;;;;;;;;;;;;;;;AA0Bf,IAAsB,mBAAtB,MAAsB,iBAAiB;;;;;;CAMtC,YAAoBA,KAAa;EAAb;CAAe;;;;;;;;;CAkBnC,aAAqB,OACpBA,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,SAAQC,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,KAAKD,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;AAEvC,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"}
|
|
@@ -82,7 +82,12 @@ var PostgresMigrator = class PostgresMigrator {
|
|
|
82
82
|
try {
|
|
83
83
|
await db.connect();
|
|
84
84
|
const result = await db.query(`SELECT * FROM pg_catalog.pg_database WHERE datname = '${database}'`);
|
|
85
|
-
if (result.rowCount === 0)
|
|
85
|
+
if (result.rowCount === 0) try {
|
|
86
|
+
await db.query(`CREATE DATABASE "${database}"`);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (error?.code === "42P04") return { alreadyExisted: true };
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
86
91
|
return { alreadyExisted: result.rowCount ? result.rowCount > 0 : false };
|
|
87
92
|
} finally {
|
|
88
93
|
await db.end();
|
|
@@ -144,4 +149,4 @@ var PostgresMigrator = class PostgresMigrator {
|
|
|
144
149
|
|
|
145
150
|
//#endregion
|
|
146
151
|
export { PostgresMigrator };
|
|
147
|
-
//# sourceMappingURL=PostgresMigrator-
|
|
152
|
+
//# sourceMappingURL=PostgresMigrator-DcP1o-T6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresMigrator-DcP1o-T6.mjs","names":["uri: string","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 * // 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 */\n\tconstructor(private uri: string) {}\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\t// Implement migration logic here\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;;;;;;;;;;;;;;;;;;;;;;;;;AA0Bf,IAAsB,mBAAtB,MAAsB,iBAAiB;;;;;;CAMtC,YAAoBA,KAAa;EAAb;CAAe;;;;;;;;;CAkBnC,aAAqB,OACpBA,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,SAAQC,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,KAAKD,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;AAEvC,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresMigrator-S-YYosAC.d.mts","names":[],"sources":["../src/PostgresMigrator.ts"],"sourcesContent":[],"mappings":";;AAiEA;;;;;
|
|
1
|
+
{"version":3,"file":"PostgresMigrator-S-YYosAC.d.mts","names":[],"sources":["../src/PostgresMigrator.ts"],"sourcesContent":[],"mappings":";;AAiEA;;;;;AA8FY;;;;;;;;;;;;;;;;;;uBA9FU,gBAAA;;;;;;;;;;;;;;sBAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAgFT,cAAA"}
|
package/dist/{PostgresObjectionMigrator-D_QxXbIN.mjs → PostgresObjectionMigrator-BJ5X48U8.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PostgresMigrator } from "./PostgresMigrator-
|
|
1
|
+
import { PostgresMigrator } from "./PostgresMigrator-DcP1o-T6.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-
|
|
118
|
+
//# sourceMappingURL=PostgresObjectionMigrator-BJ5X48U8.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresObjectionMigrator-
|
|
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"}
|
package/dist/{PostgresObjectionMigrator-DK8ODIHQ.cjs → PostgresObjectionMigrator-BXLAVVwm.cjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_PostgresMigrator = require('./PostgresMigrator-
|
|
1
|
+
const require_PostgresMigrator = require('./PostgresMigrator-CHiBYEg_.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-
|
|
123
|
+
//# sourceMappingURL=PostgresObjectionMigrator-BXLAVVwm.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresObjectionMigrator-
|
|
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,4 +1,4 @@
|
|
|
1
|
-
require('./PostgresMigrator-
|
|
2
|
-
const require_PostgresObjectionMigrator = require('./PostgresObjectionMigrator-
|
|
1
|
+
require('./PostgresMigrator-CHiBYEg_.cjs');
|
|
2
|
+
const require_PostgresObjectionMigrator = require('./PostgresObjectionMigrator-BXLAVVwm.cjs');
|
|
3
3
|
|
|
4
4
|
exports.PostgresObjectionMigrator = require_PostgresObjectionMigrator.PostgresObjectionMigrator;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./PostgresMigrator-
|
|
2
|
-
import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-
|
|
1
|
+
import "./PostgresMigrator-DcP1o-T6.mjs";
|
|
2
|
+
import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-BJ5X48U8.mjs";
|
|
3
3
|
|
|
4
4
|
export { PostgresObjectionMigrator };
|
package/dist/better-auth.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as better_auth_adapters2 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>) =>
|
|
10
|
+
declare const memoryAdapter: (config?: MemoryAdapterConfig, store?: Map<any, any>) => better_auth_adapters2.AdapterFactory & {
|
|
11
11
|
clear: () => void;
|
|
12
12
|
getAllData: () => Record<string, any[]>;
|
|
13
13
|
getStore: () => Map<any, any>;
|
package/dist/better-auth.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as better_auth_adapters3 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>) =>
|
|
10
|
+
declare const memoryAdapter: (config?: MemoryAdapterConfig, store?: Map<any, any>) => better_auth_adapters3.AdapterFactory & {
|
|
11
11
|
clear: () => void;
|
|
12
12
|
getAllData: () => Record<string, any[]>;
|
|
13
13
|
getStore: () => Map<any, any>;
|
|
@@ -15,8 +15,13 @@ const itWithDir = it.extend({ dir: async ({}, use) => {
|
|
|
15
15
|
recursive: true,
|
|
16
16
|
force: true
|
|
17
17
|
});
|
|
18
|
+
const keystoreDir = path.join(os.homedir(), ".gkm", directoryName);
|
|
19
|
+
await fs.rm(keystoreDir, {
|
|
20
|
+
recursive: true,
|
|
21
|
+
force: true
|
|
22
|
+
});
|
|
18
23
|
} });
|
|
19
24
|
|
|
20
25
|
//#endregion
|
|
21
26
|
export { itWithDir };
|
|
22
|
-
//# sourceMappingURL=directory-
|
|
27
|
+
//# sourceMappingURL=directory-BxjqmtCT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-BxjqmtCT.mjs","names":[],"sources":["../src/os/directory.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { it } from 'vitest';\n\nexport const itWithDir = it.extend<DirectoryFixtures>({\n\t// This fixture automatically provides a transaction to each test\n\t// biome-ignore lint/correctness/noEmptyPattern: this has to be like this to satisfy Biome\n\tdir: async ({}, use) => {\n\t\tconst tempDir = os.tmpdir();\n\t\tconst directoryName = crypto.randomUUID().replace(/-/g, '').toUpperCase();\n\t\tconst dir = path.join(tempDir, directoryName);\n\t\tawait fs.mkdir(dir, { recursive: true });\n\t\tawait use(dir);\n\t\tawait fs.rm(dir, { recursive: true, force: true });\n\n\t\t// Clean up keystore directory that may have been created at ~/.gkm/{directoryName}\n\t\tconst keystoreDir = path.join(os.homedir(), '.gkm', directoryName);\n\t\tawait fs.rm(keystoreDir, { recursive: true, force: true });\n\t},\n});\n\nexport interface DirectoryFixtures {\n\tdir: string;\n}\n"],"mappings":";;;;;;;AAMA,MAAa,YAAY,GAAG,OAA0B,EAGrD,KAAK,OAAO,EAAE,EAAE,QAAQ;CACvB,MAAM,UAAU,GAAG,QAAQ;CAC3B,MAAM,gBAAgB,OAAO,YAAY,CAAC,QAAQ,MAAM,GAAG,CAAC,aAAa;CACzE,MAAM,MAAM,KAAK,KAAK,SAAS,cAAc;AAC7C,OAAM,GAAG,MAAM,KAAK,EAAE,WAAW,KAAM,EAAC;AACxC,OAAM,IAAI,IAAI;AACd,OAAM,GAAG,GAAG,KAAK;EAAE,WAAW;EAAM,OAAO;CAAM,EAAC;CAGlD,MAAM,cAAc,KAAK,KAAK,GAAG,SAAS,EAAE,QAAQ,cAAc;AAClE,OAAM,GAAG,GAAG,aAAa;EAAE,WAAW;EAAM,OAAO;CAAM,EAAC;AAC1D,EACD,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory-CVrfTq1I.d.mts","names":[],"sources":["../src/os/directory.ts"],"sourcesContent":[],"mappings":";;;cAMa,
|
|
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"}
|
|
@@ -16,6 +16,11 @@ const itWithDir = vitest.it.extend({ dir: async ({}, use) => {
|
|
|
16
16
|
recursive: true,
|
|
17
17
|
force: true
|
|
18
18
|
});
|
|
19
|
+
const keystoreDir = node_path.default.join(node_os.default.homedir(), ".gkm", directoryName);
|
|
20
|
+
await node_fs_promises.default.rm(keystoreDir, {
|
|
21
|
+
recursive: true,
|
|
22
|
+
force: true
|
|
23
|
+
});
|
|
19
24
|
} });
|
|
20
25
|
|
|
21
26
|
//#endregion
|
|
@@ -25,4 +30,4 @@ Object.defineProperty(exports, 'itWithDir', {
|
|
|
25
30
|
return itWithDir;
|
|
26
31
|
}
|
|
27
32
|
});
|
|
28
|
-
//# sourceMappingURL=directory-
|
|
33
|
+
//# sourceMappingURL=directory-DD_xQoSh.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-DD_xQoSh.cjs","names":[],"sources":["../src/os/directory.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { it } from 'vitest';\n\nexport const itWithDir = it.extend<DirectoryFixtures>({\n\t// This fixture automatically provides a transaction to each test\n\t// biome-ignore lint/correctness/noEmptyPattern: this has to be like this to satisfy Biome\n\tdir: async ({}, use) => {\n\t\tconst tempDir = os.tmpdir();\n\t\tconst directoryName = crypto.randomUUID().replace(/-/g, '').toUpperCase();\n\t\tconst dir = path.join(tempDir, directoryName);\n\t\tawait fs.mkdir(dir, { recursive: true });\n\t\tawait use(dir);\n\t\tawait fs.rm(dir, { recursive: true, force: true });\n\n\t\t// Clean up keystore directory that may have been created at ~/.gkm/{directoryName}\n\t\tconst keystoreDir = path.join(os.homedir(), '.gkm', directoryName);\n\t\tawait fs.rm(keystoreDir, { recursive: true, force: true });\n\t},\n});\n\nexport interface DirectoryFixtures {\n\tdir: string;\n}\n"],"mappings":";;;;;;;;AAMA,MAAa,YAAY,UAAG,OAA0B,EAGrD,KAAK,OAAO,EAAE,EAAE,QAAQ;CACvB,MAAM,UAAU,gBAAG,QAAQ;CAC3B,MAAM,gBAAgB,oBAAO,YAAY,CAAC,QAAQ,MAAM,GAAG,CAAC,aAAa;CACzE,MAAM,MAAM,kBAAK,KAAK,SAAS,cAAc;AAC7C,OAAM,yBAAG,MAAM,KAAK,EAAE,WAAW,KAAM,EAAC;AACxC,OAAM,IAAI,IAAI;AACd,OAAM,yBAAG,GAAG,KAAK;EAAE,WAAW;EAAM,OAAO;CAAM,EAAC;CAGlD,MAAM,cAAc,kBAAK,KAAK,gBAAG,SAAS,EAAE,QAAQ,cAAc;AAClE,OAAM,yBAAG,GAAG,aAAa;EAAE,WAAW;EAAM,OAAO;CAAM,EAAC;AAC1D,EACD,EAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as vitest6 from "vitest";
|
|
2
2
|
|
|
3
3
|
//#region src/os/directory.d.ts
|
|
4
|
-
declare const itWithDir:
|
|
4
|
+
declare const itWithDir: vitest6.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-
|
|
13
|
+
//# sourceMappingURL=directory-DGOcVlKD.d.cts.map
|
|
@@ -0,0 +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,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _faker_js_faker3 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<
|
|
137
|
+
declare const faker: Readonly<_faker_js_faker3.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-
|
|
166
|
+
//# sourceMappingURL=faker-CbYiF-8_.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faker-
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _faker_js_faker0 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<
|
|
137
|
+
declare const faker$1: Readonly<_faker_js_faker0.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-
|
|
166
|
+
//# sourceMappingURL=faker-D9gz7KjY.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faker-
|
|
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"}
|
package/dist/faker.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps } from "./faker-
|
|
1
|
+
import { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps } from "./faker-CbYiF-8_.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-
|
|
1
|
+
import { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps } from "./faker-D9gz7KjY.mjs";
|
|
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-
|
|
5
|
-
const require_PostgresKyselyMigrator = require('./PostgresKyselyMigrator-
|
|
4
|
+
require('./PostgresMigrator-CHiBYEg_.cjs');
|
|
5
|
+
const require_PostgresKyselyMigrator = require('./PostgresKyselyMigrator-C7ljZYvq.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,6 +1,6 @@
|
|
|
1
|
-
import { FakerFactory, faker } from "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, FactorySeed } from "./Factory-
|
|
3
|
-
import { KyselyFactory } from "./KyselyFactory-
|
|
1
|
+
import { FakerFactory, faker } from "./faker-CbYiF-8_.cjs";
|
|
2
|
+
import { ExtractSeedAttrs, FactorySeed } from "./Factory-D28yjUj5.cjs";
|
|
3
|
+
import { KyselyFactory } from "./KyselyFactory-OUH03l2q.cjs";
|
|
4
4
|
import "./PostgresMigrator-Bres0U6E.cjs";
|
|
5
5
|
import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-CBltSOq5.cjs";
|
|
6
6
|
import { DatabaseConnection, DatabaseFixtures, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions } from "./VitestTransactionIsolator-CSroc7Df.cjs";
|
package/dist/kysely.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FakerFactory, faker } from "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, FactorySeed } from "./Factory-
|
|
3
|
-
import { KyselyFactory } from "./KyselyFactory-
|
|
1
|
+
import { FakerFactory, faker } from "./faker-D9gz7KjY.mjs";
|
|
2
|
+
import { ExtractSeedAttrs, FactorySeed } from "./Factory-C6W78ulZ.mjs";
|
|
3
|
+
import { KyselyFactory } from "./KyselyFactory-Cc2UmOJk.mjs";
|
|
4
4
|
import "./PostgresMigrator-S-YYosAC.mjs";
|
|
5
5
|
import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-DrVWncqd.mjs";
|
|
6
6
|
import { DatabaseConnection, DatabaseFixtures, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions } from "./VitestTransactionIsolator-BNWJqh9f.mjs";
|
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-
|
|
5
|
-
import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-
|
|
4
|
+
import "./PostgresMigrator-DcP1o-T6.mjs";
|
|
5
|
+
import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-B4pScubb.mjs";
|
|
6
6
|
import { IsolationLevel, extendWithFixtures } from "./VitestTransactionIsolator-DQ7tLqgV.mjs";
|
|
7
7
|
import { VitestKyselyTransactionIsolator } from "./VitestKyselyTransactionIsolator-DceyIqr4.mjs";
|
|
8
8
|
|
package/dist/objection.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_ObjectionFactory = require('./ObjectionFactory-BeFBYcan.cjs');
|
|
4
|
-
require('./PostgresMigrator-
|
|
5
|
-
const require_PostgresObjectionMigrator = require('./PostgresObjectionMigrator-
|
|
4
|
+
require('./PostgresMigrator-CHiBYEg_.cjs');
|
|
5
|
+
const require_PostgresObjectionMigrator = require('./PostgresObjectionMigrator-BXLAVVwm.cjs');
|
|
6
6
|
const require_VitestTransactionIsolator = require('./VitestTransactionIsolator-CMfJXZP8.cjs');
|
|
7
7
|
const require_VitestObjectionTransactionIsolator = require('./VitestObjectionTransactionIsolator-CdLRrzNf.cjs');
|
|
8
8
|
|
package/dist/objection.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FakerFactory, faker } from "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, FactorySeed } from "./Factory-
|
|
3
|
-
import { ObjectionFactory } from "./ObjectionFactory-
|
|
1
|
+
import { FakerFactory, faker } from "./faker-CbYiF-8_.cjs";
|
|
2
|
+
import { ExtractSeedAttrs, FactorySeed } from "./Factory-D28yjUj5.cjs";
|
|
3
|
+
import { ObjectionFactory } from "./ObjectionFactory-B1WkcfZY.cjs";
|
|
4
4
|
import "./PostgresMigrator-Bres0U6E.cjs";
|
|
5
5
|
import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-CPfBAP7r.cjs";
|
|
6
6
|
import { DatabaseConnection, DatabaseFixtures, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions } from "./VitestTransactionIsolator-CSroc7Df.cjs";
|
package/dist/objection.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FakerFactory, faker } from "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, FactorySeed } from "./Factory-
|
|
3
|
-
import { ObjectionFactory } from "./ObjectionFactory-
|
|
1
|
+
import { FakerFactory, faker } from "./faker-D9gz7KjY.mjs";
|
|
2
|
+
import { ExtractSeedAttrs, FactorySeed } from "./Factory-C6W78ulZ.mjs";
|
|
3
|
+
import { ObjectionFactory } from "./ObjectionFactory-BYnPr9ZP.mjs";
|
|
4
4
|
import "./PostgresMigrator-S-YYosAC.mjs";
|
|
5
5
|
import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-DVEqB5tp.mjs";
|
|
6
6
|
import { DatabaseConnection, DatabaseFixtures, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions } from "./VitestTransactionIsolator-BNWJqh9f.mjs";
|
package/dist/objection.mjs
CHANGED
|
@@ -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-
|
|
5
|
-
import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-
|
|
4
|
+
import "./PostgresMigrator-DcP1o-T6.mjs";
|
|
5
|
+
import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-BJ5X48U8.mjs";
|
|
6
6
|
import { IsolationLevel, extendWithFixtures } from "./VitestTransactionIsolator-DQ7tLqgV.mjs";
|
|
7
7
|
import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator-OF2osYY5.mjs";
|
|
8
8
|
|
package/dist/os/directory.cjs
CHANGED
package/dist/os/directory.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DirectoryFixtures, itWithDir } from "../directory-
|
|
1
|
+
import { DirectoryFixtures, itWithDir } from "../directory-DGOcVlKD.cjs";
|
|
2
2
|
export { DirectoryFixtures, itWithDir };
|
package/dist/os/directory.mjs
CHANGED
package/dist/os/index.cjs
CHANGED
package/dist/os/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { itWithDir } from "../directory-
|
|
1
|
+
import { itWithDir } from "../directory-DGOcVlKD.cjs";
|
|
2
2
|
export { itWithDir };
|
package/dist/os/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/testkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/pg": "~8.15.4",
|
|
58
|
-
"@geekmidas/envkit": "^1.0.
|
|
58
|
+
"@geekmidas/envkit": "^1.0.3",
|
|
59
59
|
"@geekmidas/logger": "^1.0.0"
|
|
60
60
|
},
|
|
61
61
|
"repository": {
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"vitest": "~3.2.4",
|
|
76
76
|
"@types/aws-lambda": ">=8.10.92",
|
|
77
77
|
"better-auth": ">=1.3.34",
|
|
78
|
-
"@geekmidas/envkit": "^1.0.
|
|
78
|
+
"@geekmidas/envkit": "^1.0.3",
|
|
79
79
|
"@geekmidas/logger": "^1.0.0"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
package/src/PostgresMigrator.ts
CHANGED
|
@@ -98,7 +98,15 @@ export abstract class PostgresMigrator {
|
|
|
98
98
|
);
|
|
99
99
|
|
|
100
100
|
if (result.rowCount === 0) {
|
|
101
|
-
|
|
101
|
+
try {
|
|
102
|
+
await db.query(`CREATE DATABASE "${database}"`);
|
|
103
|
+
} catch (error: any) {
|
|
104
|
+
// 42P04 = duplicate_database — another process created it between our check and create
|
|
105
|
+
if (error?.code === '42P04') {
|
|
106
|
+
return { alreadyExisted: true };
|
|
107
|
+
}
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
102
110
|
}
|
|
103
111
|
|
|
104
112
|
return {
|
package/src/os/directory.ts
CHANGED
|
@@ -14,6 +14,10 @@ export const itWithDir = it.extend<DirectoryFixtures>({
|
|
|
14
14
|
await fs.mkdir(dir, { recursive: true });
|
|
15
15
|
await use(dir);
|
|
16
16
|
await fs.rm(dir, { recursive: true, force: true });
|
|
17
|
+
|
|
18
|
+
// Clean up keystore directory that may have been created at ~/.gkm/{directoryName}
|
|
19
|
+
const keystoreDir = path.join(os.homedir(), '.gkm', directoryName);
|
|
20
|
+
await fs.rm(keystoreDir, { recursive: true, force: true });
|
|
17
21
|
},
|
|
18
22
|
});
|
|
19
23
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresMigrator-BjjenqSd.mjs","names":["uri: string"],"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 * // 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 */\n\tconstructor(private uri: string) {}\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\tawait db.query(`CREATE DATABASE \"${database}\"`);\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\t// Implement migration logic here\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;;;;;;;;;;;;;;;;;;;;;;;;;AA0Bf,IAAsB,mBAAtB,MAAsB,iBAAiB;;;;;;CAMtC,YAAoBA,KAAa;EAAb;CAAe;;;;;;;;;CAkBnC,aAAqB,OACpBA,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,OAAM,GAAG,OAAO,mBAAmB,SAAS,GAAG;AAGhD,UAAO,EACN,gBAAgB,OAAO,WAAW,OAAO,WAAW,IAAI,MACxD;EACD,UAAS;AACT,SAAM,GAAG,KAAK;EACd;CACD;;;;;;;;;CAUD,aAAqB,KAAKA,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;AAEvC,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresMigrator-D6dQn0x2.cjs","names":["uri: string"],"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 * // 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 */\n\tconstructor(private uri: string) {}\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\tawait db.query(`CREATE DATABASE \"${database}\"`);\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\t// Implement migration logic here\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;;;;;;;;;;;;;;;;;;;;;;;;;AA0Bf,IAAsB,mBAAtB,MAAsB,iBAAiB;;;;;;CAMtC,YAAoBA,KAAa;EAAb;CAAe;;;;;;;;;CAkBnC,aAAqB,OACpBA,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,OAAM,GAAG,OAAO,mBAAmB,SAAS,GAAG;AAGhD,UAAO,EACN,gBAAgB,OAAO,WAAW,OAAO,WAAW,IAAI,MACxD;EACD,UAAS;AACT,SAAM,GAAG,KAAK;EACd;CACD;;;;;;;;;CAUD,aAAqB,KAAKA,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;AAEvC,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directory-B-Ozljzk.mjs","names":[],"sources":["../src/os/directory.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { it } from 'vitest';\n\nexport const itWithDir = it.extend<DirectoryFixtures>({\n\t// This fixture automatically provides a transaction to each test\n\t// biome-ignore lint/correctness/noEmptyPattern: this has to be like this to satisfy Biome\n\tdir: async ({}, use) => {\n\t\tconst tempDir = os.tmpdir();\n\t\tconst directoryName = crypto.randomUUID().replace(/-/g, '').toUpperCase();\n\t\tconst dir = path.join(tempDir, directoryName);\n\t\tawait fs.mkdir(dir, { recursive: true });\n\t\tawait use(dir);\n\t\tawait fs.rm(dir, { recursive: true, force: true });\n\t},\n});\n\nexport interface DirectoryFixtures {\n\tdir: string;\n}\n"],"mappings":";;;;;;;AAMA,MAAa,YAAY,GAAG,OAA0B,EAGrD,KAAK,OAAO,EAAE,EAAE,QAAQ;CACvB,MAAM,UAAU,GAAG,QAAQ;CAC3B,MAAM,gBAAgB,OAAO,YAAY,CAAC,QAAQ,MAAM,GAAG,CAAC,aAAa;CACzE,MAAM,MAAM,KAAK,KAAK,SAAS,cAAc;AAC7C,OAAM,GAAG,MAAM,KAAK,EAAE,WAAW,KAAM,EAAC;AACxC,OAAM,IAAI,IAAI;AACd,OAAM,GAAG,GAAG,KAAK;EAAE,WAAW;EAAM,OAAO;CAAM,EAAC;AAClD,EACD,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directory-BVC8g7cX.cjs","names":[],"sources":["../src/os/directory.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { it } from 'vitest';\n\nexport const itWithDir = it.extend<DirectoryFixtures>({\n\t// This fixture automatically provides a transaction to each test\n\t// biome-ignore lint/correctness/noEmptyPattern: this has to be like this to satisfy Biome\n\tdir: async ({}, use) => {\n\t\tconst tempDir = os.tmpdir();\n\t\tconst directoryName = crypto.randomUUID().replace(/-/g, '').toUpperCase();\n\t\tconst dir = path.join(tempDir, directoryName);\n\t\tawait fs.mkdir(dir, { recursive: true });\n\t\tawait use(dir);\n\t\tawait fs.rm(dir, { recursive: true, force: true });\n\t},\n});\n\nexport interface DirectoryFixtures {\n\tdir: string;\n}\n"],"mappings":";;;;;;;;AAMA,MAAa,YAAY,UAAG,OAA0B,EAGrD,KAAK,OAAO,EAAE,EAAE,QAAQ;CACvB,MAAM,UAAU,gBAAG,QAAQ;CAC3B,MAAM,gBAAgB,oBAAO,YAAY,CAAC,QAAQ,MAAM,GAAG,CAAC,aAAa;CACzE,MAAM,MAAM,kBAAK,KAAK,SAAS,cAAc;AAC7C,OAAM,yBAAG,MAAM,KAAK,EAAE,WAAW,KAAM,EAAC;AACxC,OAAM,IAAI,IAAI;AACd,OAAM,yBAAG,GAAG,KAAK;EAAE,WAAW;EAAM,OAAO;CAAM,EAAC;AAClD,EACD,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directory-DAnMWi50.d.cts","names":[],"sources":["../src/os/directory.ts"],"sourcesContent":[],"mappings":";;;cAMa,WAWX,OAAA,CAXoB;;;AAAT,UAaI,iBAAA,CAbK;EAaL,GAAA,EAAA,MAAA"}
|