@geekmidas/testkit 10.0.0-alpha.3 → 10.0.0-alpha.31
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/README.md +74 -0
- package/dist/Factory.cjs +51 -2
- package/dist/Factory.cjs.map +1 -0
- package/dist/Factory.d.cts +143 -3
- package/dist/Factory.d.cts.map +1 -0
- package/dist/Factory.d.mts +143 -3
- package/dist/Factory.d.mts.map +1 -0
- package/dist/Factory.mjs +50 -2
- package/dist/Factory.mjs.map +1 -0
- package/dist/KyselyFactory.cjs +237 -4
- package/dist/KyselyFactory.cjs.map +1 -0
- package/dist/KyselyFactory.d.cts +224 -4
- package/dist/KyselyFactory.d.cts.map +1 -0
- package/dist/KyselyFactory.d.mts +224 -4
- package/dist/KyselyFactory.d.mts.map +1 -0
- package/dist/KyselyFactory.mjs +236 -4
- package/dist/KyselyFactory.mjs.map +1 -0
- package/dist/ObjectionFactory.cjs +265 -4
- package/dist/ObjectionFactory.cjs.map +1 -0
- package/dist/ObjectionFactory.d.cts +237 -4
- package/dist/ObjectionFactory.d.cts.map +1 -0
- package/dist/ObjectionFactory.d.mts +237 -4
- package/dist/ObjectionFactory.d.mts.map +1 -0
- package/dist/ObjectionFactory.mjs +264 -4
- package/dist/ObjectionFactory.mjs.map +1 -0
- package/dist/PostgresKyselyMigrator.cjs +94 -3
- package/dist/PostgresKyselyMigrator.cjs.map +1 -0
- package/dist/PostgresKyselyMigrator.d.cts +80 -3
- package/dist/PostgresKyselyMigrator.d.cts.map +1 -0
- package/dist/PostgresKyselyMigrator.d.mts +80 -3
- package/dist/PostgresKyselyMigrator.d.mts.map +1 -0
- package/dist/PostgresKyselyMigrator.mjs +93 -3
- package/dist/PostgresKyselyMigrator.mjs.map +1 -0
- package/dist/{PostgresMigrator-C_QQ6q35.d.mts → PostgresMigrator-CDPnnwMJ.d.cts} +11 -5
- package/dist/PostgresMigrator-CDPnnwMJ.d.cts.map +1 -0
- package/dist/{PostgresMigrator-CeYy-eHF.d.cts → PostgresMigrator-CDPnnwMJ.d.mts} +11 -5
- package/dist/PostgresMigrator-CDPnnwMJ.d.mts.map +1 -0
- package/dist/PostgresMigrator.cjs +178 -2
- package/dist/PostgresMigrator.cjs.map +1 -0
- package/dist/PostgresMigrator.d.cts +1 -1
- package/dist/PostgresMigrator.d.mts +1 -1
- package/dist/PostgresMigrator.mjs +175 -2
- package/dist/PostgresMigrator.mjs.map +1 -0
- package/dist/PostgresObjectionMigrator.cjs +118 -3
- package/dist/PostgresObjectionMigrator.cjs.map +1 -0
- package/dist/PostgresObjectionMigrator.d.cts +75 -3
- package/dist/PostgresObjectionMigrator.d.cts.map +1 -0
- package/dist/PostgresObjectionMigrator.d.mts +75 -3
- package/dist/PostgresObjectionMigrator.d.mts.map +1 -0
- package/dist/PostgresObjectionMigrator.mjs +117 -3
- package/dist/PostgresObjectionMigrator.mjs.map +1 -0
- package/dist/VitestKyselyTransactionIsolator.cjs +66 -3
- package/dist/VitestKyselyTransactionIsolator.cjs.map +1 -0
- package/dist/VitestKyselyTransactionIsolator.d.cts +60 -3
- package/dist/VitestKyselyTransactionIsolator.d.cts.map +1 -0
- package/dist/VitestKyselyTransactionIsolator.d.mts +60 -3
- package/dist/VitestKyselyTransactionIsolator.d.mts.map +1 -0
- package/dist/VitestKyselyTransactionIsolator.mjs +65 -3
- package/dist/VitestKyselyTransactionIsolator.mjs.map +1 -0
- package/dist/VitestObjectionTransactionIsolator.cjs +62 -3
- package/dist/VitestObjectionTransactionIsolator.cjs.map +1 -0
- package/dist/VitestObjectionTransactionIsolator.d.cts +56 -3
- package/dist/VitestObjectionTransactionIsolator.d.cts.map +1 -0
- package/dist/VitestObjectionTransactionIsolator.d.mts +56 -3
- package/dist/VitestObjectionTransactionIsolator.d.mts.map +1 -0
- package/dist/VitestObjectionTransactionIsolator.mjs +61 -3
- package/dist/VitestObjectionTransactionIsolator.mjs.map +1 -0
- package/dist/VitestTransactionIsolator.cjs +187 -4
- package/dist/VitestTransactionIsolator.cjs.map +1 -0
- package/dist/VitestTransactionIsolator.d.cts +219 -2
- package/dist/VitestTransactionIsolator.d.cts.map +1 -0
- package/dist/VitestTransactionIsolator.d.mts +219 -2
- package/dist/VitestTransactionIsolator.d.mts.map +1 -0
- package/dist/VitestTransactionIsolator.mjs +184 -2
- package/dist/VitestTransactionIsolator.mjs.map +1 -0
- package/dist/aws.cjs +3 -4
- package/dist/aws.cjs.map +1 -1
- package/dist/aws.d.cts +3 -8
- package/dist/aws.d.cts.map +1 -1
- package/dist/aws.d.mts +3 -8
- package/dist/aws.d.mts.map +1 -1
- package/dist/aws.mjs +1 -2
- package/dist/aws.mjs.map +1 -1
- package/dist/benchmark.cjs +2 -2
- package/dist/benchmark.cjs.map +1 -1
- package/dist/benchmark.d.cts +4 -6
- package/dist/benchmark.d.cts.map +1 -1
- package/dist/benchmark.d.mts +4 -6
- package/dist/benchmark.d.mts.map +1 -1
- package/dist/benchmark.mjs +1 -1
- package/dist/benchmark.mjs.map +1 -1
- package/dist/better-auth.cjs +31 -15
- package/dist/better-auth.cjs.map +1 -1
- package/dist/better-auth.d.cts +13142 -4
- package/dist/better-auth.d.cts.map +1 -1
- package/dist/better-auth.d.mts +13142 -4
- package/dist/better-auth.d.mts.map +1 -1
- package/dist/better-auth.mjs +29 -13
- package/dist/better-auth.mjs.map +1 -1
- package/dist/browser.cjs +127 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +47 -0
- package/dist/browser.d.cts.map +1 -0
- package/dist/browser.d.mts +47 -0
- package/dist/browser.d.mts.map +1 -0
- package/dist/browser.mjs +125 -0
- package/dist/browser.mjs.map +1 -0
- package/dist/context.cjs +80 -0
- package/dist/context.cjs.map +1 -0
- package/dist/context.d.cts +55 -0
- package/dist/context.d.cts.map +1 -0
- package/dist/context.d.mts +55 -0
- package/dist/context.d.mts.map +1 -0
- package/dist/context.mjs +73 -0
- package/dist/context.mjs.map +1 -0
- package/dist/faker.cjs +262 -8
- package/dist/faker.cjs.map +1 -0
- package/dist/faker.d.cts +162 -2
- package/dist/faker.d.cts.map +1 -0
- package/dist/faker.d.mts +162 -2
- package/dist/faker.d.mts.map +1 -0
- package/dist/faker.mjs +255 -2
- package/dist/faker.mjs.map +1 -0
- package/dist/helpers.cjs +6 -5
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +1 -5
- package/dist/helpers.d.cts.map +1 -1
- package/dist/helpers.d.mts +1 -5
- package/dist/helpers.d.mts.map +1 -1
- package/dist/helpers.mjs +1 -2
- package/dist/helpers.mjs.map +1 -1
- package/dist/initScript.cjs +15 -15
- package/dist/initScript.cjs.map +1 -1
- package/dist/initScript.d.cts +2 -4
- package/dist/initScript.d.cts.map +1 -1
- package/dist/initScript.d.mts +2 -4
- package/dist/initScript.d.mts.map +1 -1
- package/dist/initScript.mjs +10 -12
- package/dist/initScript.mjs.map +1 -1
- package/dist/kysely.cjs +10 -13
- package/dist/kysely.cjs.map +1 -1
- package/dist/kysely.d.cts +10 -14
- package/dist/kysely.d.cts.map +1 -1
- package/dist/kysely.d.mts +10 -14
- package/dist/kysely.d.mts.map +1 -1
- package/dist/kysely.mjs +10 -14
- package/dist/kysely.mjs.map +1 -1
- package/dist/logger.cjs +3 -4
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.d.cts +1 -5
- package/dist/logger.d.cts.map +1 -1
- package/dist/logger.d.mts +1 -5
- package/dist/logger.d.mts.map +1 -1
- package/dist/logger.mjs +1 -2
- package/dist/logger.mjs.map +1 -1
- package/dist/mailbox.cjs +95 -0
- package/dist/mailbox.cjs.map +1 -0
- package/dist/mailbox.d.cts +58 -0
- package/dist/mailbox.d.cts.map +1 -0
- package/dist/mailbox.d.mts +58 -0
- package/dist/mailbox.d.mts.map +1 -0
- package/dist/mailbox.mjs +92 -0
- package/dist/mailbox.mjs.map +1 -0
- package/dist/objection.cjs +10 -13
- package/dist/objection.cjs.map +1 -1
- package/dist/objection.d.cts +10 -14
- package/dist/objection.d.cts.map +1 -1
- package/dist/objection.d.mts +10 -14
- package/dist/objection.d.mts.map +1 -1
- package/dist/objection.mjs +10 -14
- package/dist/objection.mjs.map +1 -1
- package/dist/os/directory.cjs +31 -2
- package/dist/os/directory.cjs.map +1 -0
- package/dist/os/directory.d.cts +9 -2
- package/dist/os/directory.d.cts.map +1 -0
- package/dist/os/directory.d.mts +9 -2
- package/dist/os/directory.d.mts.map +1 -0
- package/dist/os/directory.mjs +25 -2
- package/dist/os/directory.mjs.map +1 -0
- package/dist/os/index.cjs +3 -3
- package/dist/os/index.d.cts +1 -1
- package/dist/os/index.d.mts +1 -1
- package/dist/os/index.mjs +2 -3
- package/dist/requestContext.cjs +10 -11
- package/dist/requestContext.cjs.map +1 -1
- package/dist/requestContext.d.cts +4 -8
- package/dist/requestContext.d.cts.map +1 -1
- package/dist/requestContext.d.mts +4 -8
- package/dist/requestContext.d.mts.map +1 -1
- package/dist/requestContext.mjs +1 -2
- package/dist/requestContext.mjs.map +1 -1
- package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-VH7oDXx4.cjs} +8 -10
- package/dist/timer.cjs +2 -2
- package/dist/timer.cjs.map +1 -1
- package/dist/timer.d.cts +1 -4
- package/dist/timer.d.cts.map +1 -1
- package/dist/timer.d.mts +1 -4
- package/dist/timer.d.mts.map +1 -1
- package/dist/timer.mjs +1 -1
- package/dist/timer.mjs.map +1 -1
- package/dist/transactions.cjs +123 -0
- package/dist/transactions.cjs.map +1 -0
- package/dist/transactions.d.cts +44 -0
- package/dist/transactions.d.cts.map +1 -0
- package/dist/transactions.d.mts +44 -0
- package/dist/transactions.d.mts.map +1 -0
- package/dist/transactions.mjs +118 -0
- package/dist/transactions.mjs.map +1 -0
- package/package.json +59 -16
- package/dist/Factory-BFVnMMCC.mjs +0 -51
- package/dist/Factory-BFVnMMCC.mjs.map +0 -1
- package/dist/Factory-BOX312yd.d.cts +0 -147
- package/dist/Factory-BOX312yd.d.cts.map +0 -1
- package/dist/Factory-BhjUOBWN.cjs +0 -57
- package/dist/Factory-BhjUOBWN.cjs.map +0 -1
- package/dist/Factory-C6W78ulZ.d.mts +0 -147
- package/dist/Factory-C6W78ulZ.d.mts.map +0 -1
- package/dist/KyselyFactory-BFqVIn_0.cjs +0 -246
- package/dist/KyselyFactory-BFqVIn_0.cjs.map +0 -1
- package/dist/KyselyFactory-Cc2UmOJk.d.mts +0 -228
- package/dist/KyselyFactory-Cc2UmOJk.d.mts.map +0 -1
- package/dist/KyselyFactory-DMswpwji.mjs +0 -241
- package/dist/KyselyFactory-DMswpwji.mjs.map +0 -1
- package/dist/KyselyFactory-Dy5zzV4B.d.cts +0 -228
- package/dist/KyselyFactory-Dy5zzV4B.d.cts.map +0 -1
- package/dist/ObjectionFactory-BYnPr9ZP.d.mts +0 -241
- package/dist/ObjectionFactory-BYnPr9ZP.d.mts.map +0 -1
- package/dist/ObjectionFactory-BeFBYcan.cjs +0 -272
- package/dist/ObjectionFactory-BeFBYcan.cjs.map +0 -1
- package/dist/ObjectionFactory-CD-WFuMJ.d.cts +0 -241
- package/dist/ObjectionFactory-CD-WFuMJ.d.cts.map +0 -1
- package/dist/ObjectionFactory-QCJ7u0Ql.mjs +0 -267
- package/dist/ObjectionFactory-QCJ7u0Ql.mjs.map +0 -1
- package/dist/PostgresKyselyMigrator-B2M6Gjvv.d.cts +0 -84
- package/dist/PostgresKyselyMigrator-B2M6Gjvv.d.cts.map +0 -1
- package/dist/PostgresKyselyMigrator-BGBxjnFv.cjs +0 -101
- package/dist/PostgresKyselyMigrator-BGBxjnFv.cjs.map +0 -1
- package/dist/PostgresKyselyMigrator-CvwXycJE.d.mts +0 -84
- package/dist/PostgresKyselyMigrator-CvwXycJE.d.mts.map +0 -1
- package/dist/PostgresKyselyMigrator-PI0QhvB1.mjs +0 -95
- package/dist/PostgresKyselyMigrator-PI0QhvB1.mjs.map +0 -1
- package/dist/PostgresMigrator-C_QQ6q35.d.mts.map +0 -1
- package/dist/PostgresMigrator-CeYy-eHF.d.cts.map +0 -1
- package/dist/PostgresMigrator-DVAY04qN.mjs +0 -166
- package/dist/PostgresMigrator-DVAY04qN.mjs.map +0 -1
- package/dist/PostgresMigrator-M9jpzOvN.cjs +0 -172
- package/dist/PostgresMigrator-M9jpzOvN.cjs.map +0 -1
- package/dist/PostgresObjectionMigrator-1j6YIB1c.d.mts +0 -79
- package/dist/PostgresObjectionMigrator-1j6YIB1c.d.mts.map +0 -1
- package/dist/PostgresObjectionMigrator-DHVC9h_P.d.cts +0 -79
- package/dist/PostgresObjectionMigrator-DHVC9h_P.d.cts.map +0 -1
- package/dist/PostgresObjectionMigrator-DSaPhwjY.cjs +0 -123
- package/dist/PostgresObjectionMigrator-DSaPhwjY.cjs.map +0 -1
- package/dist/PostgresObjectionMigrator-DjPKdUbm.mjs +0 -118
- package/dist/PostgresObjectionMigrator-DjPKdUbm.mjs.map +0 -1
- package/dist/VitestKyselyTransactionIsolator-1Saieke7.mjs +0 -67
- package/dist/VitestKyselyTransactionIsolator-1Saieke7.mjs.map +0 -1
- package/dist/VitestKyselyTransactionIsolator-BjJSXryR.cjs +0 -72
- package/dist/VitestKyselyTransactionIsolator-BjJSXryR.cjs.map +0 -1
- package/dist/VitestKyselyTransactionIsolator-CwlTo6yf.d.mts +0 -64
- package/dist/VitestKyselyTransactionIsolator-CwlTo6yf.d.mts.map +0 -1
- package/dist/VitestKyselyTransactionIsolator-DJasVuIZ.d.cts +0 -64
- package/dist/VitestKyselyTransactionIsolator-DJasVuIZ.d.cts.map +0 -1
- package/dist/VitestObjectionTransactionIsolator-B_VSWFum.mjs +0 -63
- package/dist/VitestObjectionTransactionIsolator-B_VSWFum.mjs.map +0 -1
- package/dist/VitestObjectionTransactionIsolator-CTTjvTPO.d.cts +0 -60
- package/dist/VitestObjectionTransactionIsolator-CTTjvTPO.d.cts.map +0 -1
- package/dist/VitestObjectionTransactionIsolator-CyZG6nq4.d.mts +0 -60
- package/dist/VitestObjectionTransactionIsolator-CyZG6nq4.d.mts.map +0 -1
- package/dist/VitestObjectionTransactionIsolator-DDoJTu7e.cjs +0 -68
- package/dist/VitestObjectionTransactionIsolator-DDoJTu7e.cjs.map +0 -1
- package/dist/VitestTransactionIsolator-BLaw80cx.d.mts +0 -223
- package/dist/VitestTransactionIsolator-BLaw80cx.d.mts.map +0 -1
- package/dist/VitestTransactionIsolator-CvwPecpl.mjs +0 -188
- package/dist/VitestTransactionIsolator-CvwPecpl.mjs.map +0 -1
- package/dist/VitestTransactionIsolator-DyiX-QtK.cjs +0 -206
- package/dist/VitestTransactionIsolator-DyiX-QtK.cjs.map +0 -1
- package/dist/VitestTransactionIsolator-glcxyS_R.d.cts +0 -223
- package/dist/VitestTransactionIsolator-glcxyS_R.d.cts.map +0 -1
- package/dist/directory-BxjqmtCT.mjs +0 -27
- package/dist/directory-BxjqmtCT.mjs.map +0 -1
- package/dist/directory-DD_xQoSh.cjs +0 -33
- package/dist/directory-DD_xQoSh.cjs.map +0 -1
- package/dist/directory-DGOcVlKD.d.cts +0 -13
- package/dist/directory-DGOcVlKD.d.cts.map +0 -1
- package/dist/directory-DiQ_DkaF.d.mts +0 -13
- package/dist/directory-DiQ_DkaF.d.mts.map +0 -1
- package/dist/faker-B14IEMIN.cjs +0 -304
- package/dist/faker-B14IEMIN.cjs.map +0 -1
- package/dist/faker-BGKYFoCT.mjs +0 -262
- package/dist/faker-BGKYFoCT.mjs.map +0 -1
- package/dist/faker-Cg76aFNO.d.cts +0 -166
- package/dist/faker-Cg76aFNO.d.cts.map +0 -1
- package/dist/faker-D9gz7KjY.d.mts +0 -166
- package/dist/faker-D9gz7KjY.d.mts.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/mailbox.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The mail a test sent, read from Mailpit.
|
|
4
|
+
*
|
|
5
|
+
* Locally, mail goes over real SMTP to Mailpit — the same client, the same
|
|
6
|
+
* message, only the host differs. A test reads what arrived through Mailpit's
|
|
7
|
+
* HTTP API, so a magic link is signed in with by opening the email that was
|
|
8
|
+
* actually sent rather than a token pulled from somewhere else.
|
|
9
|
+
*
|
|
10
|
+
* Mailpit has one inbox for everything, and transactions do not reach it, so a
|
|
11
|
+
* test keeps to its own mail by address: a unique recipient per test, read by
|
|
12
|
+
* `to:`, and cleared afterwards.
|
|
13
|
+
*/
|
|
14
|
+
export interface MailboxOptions {
|
|
15
|
+
/** Mailpit's HTTP address — what `gkm test` injects as `<ID>_INBOX_URL`. */
|
|
16
|
+
inbox: string;
|
|
17
|
+
/** The `fetch` to read it with. Defaults to the global one. */
|
|
18
|
+
fetch?: typeof fetch;
|
|
19
|
+
/** How long `last()` waits for mail to arrive. */
|
|
20
|
+
timeout?: number;
|
|
21
|
+
}
|
|
22
|
+
/** One email, as it arrived. */
|
|
23
|
+
export interface Email {
|
|
24
|
+
id: string;
|
|
25
|
+
from: string;
|
|
26
|
+
to: string[];
|
|
27
|
+
subject: string;
|
|
28
|
+
text: string;
|
|
29
|
+
html: string;
|
|
30
|
+
/** Every `http(s)` link in the email, in order. */
|
|
31
|
+
links: string[];
|
|
32
|
+
/** The first link — the one a sign-in or confirmation email is about. */
|
|
33
|
+
link: string | undefined;
|
|
34
|
+
}
|
|
35
|
+
export interface Mailbox {
|
|
36
|
+
/** The newest email to this address, waiting for one if none has arrived. */
|
|
37
|
+
last(): Promise<Email>;
|
|
38
|
+
/** Every email to this address, newest first. */
|
|
39
|
+
all(): Promise<Email[]>;
|
|
40
|
+
/** Delete every email to this address. */
|
|
41
|
+
clear(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
/** A way to read the mail sent to one address. */
|
|
44
|
+
export declare function createMailbox(options: MailboxOptions): (address: string) => Mailbox;
|
|
45
|
+
/** No email to an address arrived in time. */
|
|
46
|
+
export declare class NoMail extends Error {
|
|
47
|
+
readonly address: string;
|
|
48
|
+
readonly timeout: number;
|
|
49
|
+
constructor(address: string, timeout: number);
|
|
50
|
+
}
|
|
51
|
+
/** Mailpit did not answer. */
|
|
52
|
+
export declare class InboxUnreachable extends Error {
|
|
53
|
+
readonly inbox: string;
|
|
54
|
+
readonly status: number;
|
|
55
|
+
constructor(inbox: string, status: number);
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//# sourceMappingURL=mailbox.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailbox.d.cts","names":[],"sources":["../src/mailbox.ts"],"mappings":";;;;;;;;;;;;;iBAiBiB;;EAEhB;;EAEA,eAAe;;EAEf;;;iBAIgB;EAChB;EACA;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;iBAGgB;;EAEhB,QAAQ,QAAQ;;EAEhB,OAAO,QAAQ;;EAEf,SAAS;;;wBAIM,cACf,SAAS,kBACN,oBAAoB;;qBA0FX,eAAe;WAEjB;WACA;EAFV,YACU,iBACA;;;qBAWE,yBAAyB;WAE3B;WACA;EAFV,YACU,eACA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/mailbox.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The mail a test sent, read from Mailpit.
|
|
4
|
+
*
|
|
5
|
+
* Locally, mail goes over real SMTP to Mailpit — the same client, the same
|
|
6
|
+
* message, only the host differs. A test reads what arrived through Mailpit's
|
|
7
|
+
* HTTP API, so a magic link is signed in with by opening the email that was
|
|
8
|
+
* actually sent rather than a token pulled from somewhere else.
|
|
9
|
+
*
|
|
10
|
+
* Mailpit has one inbox for everything, and transactions do not reach it, so a
|
|
11
|
+
* test keeps to its own mail by address: a unique recipient per test, read by
|
|
12
|
+
* `to:`, and cleared afterwards.
|
|
13
|
+
*/
|
|
14
|
+
export interface MailboxOptions {
|
|
15
|
+
/** Mailpit's HTTP address — what `gkm test` injects as `<ID>_INBOX_URL`. */
|
|
16
|
+
inbox: string;
|
|
17
|
+
/** The `fetch` to read it with. Defaults to the global one. */
|
|
18
|
+
fetch?: typeof fetch;
|
|
19
|
+
/** How long `last()` waits for mail to arrive. */
|
|
20
|
+
timeout?: number;
|
|
21
|
+
}
|
|
22
|
+
/** One email, as it arrived. */
|
|
23
|
+
export interface Email {
|
|
24
|
+
id: string;
|
|
25
|
+
from: string;
|
|
26
|
+
to: string[];
|
|
27
|
+
subject: string;
|
|
28
|
+
text: string;
|
|
29
|
+
html: string;
|
|
30
|
+
/** Every `http(s)` link in the email, in order. */
|
|
31
|
+
links: string[];
|
|
32
|
+
/** The first link — the one a sign-in or confirmation email is about. */
|
|
33
|
+
link: string | undefined;
|
|
34
|
+
}
|
|
35
|
+
export interface Mailbox {
|
|
36
|
+
/** The newest email to this address, waiting for one if none has arrived. */
|
|
37
|
+
last(): Promise<Email>;
|
|
38
|
+
/** Every email to this address, newest first. */
|
|
39
|
+
all(): Promise<Email[]>;
|
|
40
|
+
/** Delete every email to this address. */
|
|
41
|
+
clear(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
/** A way to read the mail sent to one address. */
|
|
44
|
+
export declare function createMailbox(options: MailboxOptions): (address: string) => Mailbox;
|
|
45
|
+
/** No email to an address arrived in time. */
|
|
46
|
+
export declare class NoMail extends Error {
|
|
47
|
+
readonly address: string;
|
|
48
|
+
readonly timeout: number;
|
|
49
|
+
constructor(address: string, timeout: number);
|
|
50
|
+
}
|
|
51
|
+
/** Mailpit did not answer. */
|
|
52
|
+
export declare class InboxUnreachable extends Error {
|
|
53
|
+
readonly inbox: string;
|
|
54
|
+
readonly status: number;
|
|
55
|
+
constructor(inbox: string, status: number);
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//# sourceMappingURL=mailbox.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailbox.d.mts","names":[],"sources":["../src/mailbox.ts"],"mappings":";;;;;;;;;;;;;iBAiBiB;;EAEhB;;EAEA,eAAe;;EAEf;;;iBAIgB;EAChB;EACA;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;iBAGgB;;EAEhB,QAAQ,QAAQ;;EAEhB,OAAO,QAAQ;;EAEf,SAAS;;;wBAIM,cACf,SAAS,kBACN,oBAAoB;;qBA0FX,eAAe;WAEjB;WACA;EAFV,YACU,iBACA;;;qBAWE,yBAAyB;WAE3B;WACA;EAFV,YACU,eACA"}
|
package/dist/mailbox.mjs
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//#region src/mailbox.ts
|
|
2
|
+
/**
|
|
3
|
+
* The mail a test sent, read from Mailpit.
|
|
4
|
+
*
|
|
5
|
+
* Locally, mail goes over real SMTP to Mailpit — the same client, the same
|
|
6
|
+
* message, only the host differs. A test reads what arrived through Mailpit's
|
|
7
|
+
* HTTP API, so a magic link is signed in with by opening the email that was
|
|
8
|
+
* actually sent rather than a token pulled from somewhere else.
|
|
9
|
+
*
|
|
10
|
+
* Mailpit has one inbox for everything, and transactions do not reach it, so a
|
|
11
|
+
* test keeps to its own mail by address: a unique recipient per test, read by
|
|
12
|
+
* `to:`, and cleared afterwards.
|
|
13
|
+
*/
|
|
14
|
+
/** How long `last()` waits for mail that is still on its way. */
|
|
15
|
+
const DEFAULT_TIMEOUT = 5e3;
|
|
16
|
+
const POLL_INTERVAL = 50;
|
|
17
|
+
/** A way to read the mail sent to one address. */
|
|
18
|
+
function createMailbox(options) {
|
|
19
|
+
const inbox = options.inbox.replace(/\/$/, "");
|
|
20
|
+
const timeout = options.timeout ?? DEFAULT_TIMEOUT;
|
|
21
|
+
const get = (path, init) => (options.fetch ?? globalThis.fetch)(`${inbox}${path}`, init);
|
|
22
|
+
return (address) => {
|
|
23
|
+
const query = `?query=${encodeURIComponent(`to:"${address}"`)}`;
|
|
24
|
+
const all = async () => {
|
|
25
|
+
const found = await json(await get(`/api/v1/search${query}`), inbox);
|
|
26
|
+
return Promise.all(found.messages.map(async ({ ID }) => email(await json(await get(`/api/v1/message/${ID}`), inbox))));
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
all,
|
|
30
|
+
async last() {
|
|
31
|
+
const deadline = Date.now() + timeout;
|
|
32
|
+
for (;;) {
|
|
33
|
+
const [newest] = await all();
|
|
34
|
+
if (newest) return newest;
|
|
35
|
+
if (Date.now() >= deadline) throw new NoMail(address, timeout);
|
|
36
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL));
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
async clear() {
|
|
40
|
+
const response = await get(`/api/v1/search${query}`, { method: "DELETE" });
|
|
41
|
+
if (!response.ok) throw new InboxUnreachable(inbox, response.status);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async function json(response, inbox) {
|
|
47
|
+
if (!response.ok) throw new InboxUnreachable(inbox, response.status);
|
|
48
|
+
return await response.json();
|
|
49
|
+
}
|
|
50
|
+
function email(message) {
|
|
51
|
+
const links = [...new Set([...(message.HTML ?? "").matchAll(/href="(https?:\/\/[^"]+)"/g), ...(message.Text ?? "").matchAll(/(https?:\/\/[^\s<>"]+)/g)].map(([, url]) => decodeEntities(url)))];
|
|
52
|
+
return {
|
|
53
|
+
id: message.ID,
|
|
54
|
+
from: message.From.Address,
|
|
55
|
+
to: message.To.map(({ Address }) => Address),
|
|
56
|
+
subject: message.Subject,
|
|
57
|
+
text: message.Text ?? "",
|
|
58
|
+
html: message.HTML ?? "",
|
|
59
|
+
links,
|
|
60
|
+
link: links[0]
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** `&` in an HTML attribute is `&` in the URL it names. */
|
|
64
|
+
function decodeEntities(url) {
|
|
65
|
+
return url.replaceAll("&", "&");
|
|
66
|
+
}
|
|
67
|
+
/** No email to an address arrived in time. */
|
|
68
|
+
var NoMail = class extends Error {
|
|
69
|
+
address;
|
|
70
|
+
timeout;
|
|
71
|
+
constructor(address, timeout) {
|
|
72
|
+
super(`No email to ${address} arrived within ${timeout}ms. Check that the code under test sends it, and to that address.`);
|
|
73
|
+
this.address = address;
|
|
74
|
+
this.timeout = timeout;
|
|
75
|
+
this.name = "NoMail";
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
/** Mailpit did not answer. */
|
|
79
|
+
var InboxUnreachable = class extends Error {
|
|
80
|
+
inbox;
|
|
81
|
+
status;
|
|
82
|
+
constructor(inbox, status) {
|
|
83
|
+
super(`Mailpit at ${inbox} answered ${status}. Is it running? \`gkm test\` starts it when the app declares an Email construct.`);
|
|
84
|
+
this.inbox = inbox;
|
|
85
|
+
this.status = status;
|
|
86
|
+
this.name = "InboxUnreachable";
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
export { InboxUnreachable, NoMail, createMailbox };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=mailbox.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailbox.mjs","names":[],"sources":["../src/mailbox.ts"],"sourcesContent":["/**\n * The mail a test sent, read from Mailpit.\n *\n * Locally, mail goes over real SMTP to Mailpit — the same client, the same\n * message, only the host differs. A test reads what arrived through Mailpit's\n * HTTP API, so a magic link is signed in with by opening the email that was\n * actually sent rather than a token pulled from somewhere else.\n *\n * Mailpit has one inbox for everything, and transactions do not reach it, so a\n * test keeps to its own mail by address: a unique recipient per test, read by\n * `to:`, and cleared afterwards.\n */\n\n/** How long `last()` waits for mail that is still on its way. */\nconst DEFAULT_TIMEOUT = 5_000;\nconst POLL_INTERVAL = 50;\n\nexport interface MailboxOptions {\n\t/** Mailpit's HTTP address — what `gkm test` injects as `<ID>_INBOX_URL`. */\n\tinbox: string;\n\t/** The `fetch` to read it with. Defaults to the global one. */\n\tfetch?: typeof fetch;\n\t/** How long `last()` waits for mail to arrive. */\n\ttimeout?: number;\n}\n\n/** One email, as it arrived. */\nexport interface Email {\n\tid: string;\n\tfrom: string;\n\tto: string[];\n\tsubject: string;\n\ttext: string;\n\thtml: string;\n\t/** Every `http(s)` link in the email, in order. */\n\tlinks: string[];\n\t/** The first link — the one a sign-in or confirmation email is about. */\n\tlink: string | undefined;\n}\n\nexport interface Mailbox {\n\t/** The newest email to this address, waiting for one if none has arrived. */\n\tlast(): Promise<Email>;\n\t/** Every email to this address, newest first. */\n\tall(): Promise<Email[]>;\n\t/** Delete every email to this address. */\n\tclear(): Promise<void>;\n}\n\n/** A way to read the mail sent to one address. */\nexport function createMailbox(\n\toptions: MailboxOptions,\n): (address: string) => Mailbox {\n\tconst inbox = options.inbox.replace(/\\/$/, '');\n\tconst timeout = options.timeout ?? DEFAULT_TIMEOUT;\n\tconst get = (path: string, init?: RequestInit) =>\n\t\t(options.fetch ?? globalThis.fetch)(`${inbox}${path}`, init);\n\n\treturn (address) => {\n\t\tconst query = `?query=${encodeURIComponent(`to:\"${address}\"`)}`;\n\n\t\tconst all = async (): Promise<Email[]> => {\n\t\t\tconst found = await json<SearchResult>(\n\t\t\t\tawait get(`/api/v1/search${query}`),\n\t\t\t\tinbox,\n\t\t\t);\n\t\t\treturn Promise.all(\n\t\t\t\tfound.messages.map(async ({ ID }) =>\n\t\t\t\t\temail(await json<Message>(await get(`/api/v1/message/${ID}`), inbox)),\n\t\t\t\t),\n\t\t\t);\n\t\t};\n\n\t\treturn {\n\t\t\tall,\n\t\t\tasync last() {\n\t\t\t\tconst deadline = Date.now() + timeout;\n\t\t\t\tfor (;;) {\n\t\t\t\t\tconst [newest] = await all();\n\t\t\t\t\tif (newest) return newest;\n\t\t\t\t\tif (Date.now() >= deadline) throw new NoMail(address, timeout);\n\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL));\n\t\t\t\t}\n\t\t\t},\n\t\t\tasync clear() {\n\t\t\t\tconst response = await get(`/api/v1/search${query}`, {\n\t\t\t\t\tmethod: 'DELETE',\n\t\t\t\t});\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new InboxUnreachable(inbox, response.status);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t};\n}\n\ninterface SearchResult {\n\tmessages: { ID: string }[];\n}\n\ninterface Message {\n\tID: string;\n\tFrom: { Address: string };\n\tTo: { Address: string }[];\n\tSubject: string;\n\tText: string;\n\tHTML: string;\n}\n\nasync function json<T>(response: Response, inbox: string): Promise<T> {\n\tif (!response.ok) throw new InboxUnreachable(inbox, response.status);\n\treturn (await response.json()) as T;\n}\n\nfunction email(message: Message): Email {\n\tconst links = [\n\t\t...new Set(\n\t\t\t[\n\t\t\t\t...(message.HTML ?? '').matchAll(/href=\"(https?:\\/\\/[^\"]+)\"/g),\n\t\t\t\t...(message.Text ?? '').matchAll(/(https?:\\/\\/[^\\s<>\"]+)/g),\n\t\t\t].map(([, url]) => decodeEntities(url!)),\n\t\t),\n\t];\n\n\treturn {\n\t\tid: message.ID,\n\t\tfrom: message.From.Address,\n\t\tto: message.To.map(({ Address }) => Address),\n\t\tsubject: message.Subject,\n\t\ttext: message.Text ?? '',\n\t\thtml: message.HTML ?? '',\n\t\tlinks,\n\t\tlink: links[0],\n\t};\n}\n\n/** `&` in an HTML attribute is `&` in the URL it names. */\nfunction decodeEntities(url: string): string {\n\treturn url.replaceAll('&', '&');\n}\n\n/** No email to an address arrived in time. */\nexport class NoMail extends Error {\n\tconstructor(\n\t\treadonly address: string,\n\t\treadonly timeout: number,\n\t) {\n\t\tsuper(\n\t\t\t`No email to ${address} arrived within ${timeout}ms. Check that the ` +\n\t\t\t\t`code under test sends it, and to that address.`,\n\t\t);\n\t\tthis.name = 'NoMail';\n\t}\n}\n\n/** Mailpit did not answer. */\nexport class InboxUnreachable extends Error {\n\tconstructor(\n\t\treadonly inbox: string,\n\t\treadonly status: number,\n\t) {\n\t\tsuper(\n\t\t\t`Mailpit at ${inbox} answered ${status}. Is it running? \\`gkm test\\` ` +\n\t\t\t\t`starts it when the app declares an Email construct.`,\n\t\t);\n\t\tthis.name = 'InboxUnreachable';\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;;AAmCtB,SAAgB,cACf,SAC+B;CAC/B,MAAM,QAAQ,QAAQ,MAAM,QAAQ,OAAO,EAAE;CAC7C,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,OAAO,MAAc,UACzB,QAAQ,SAAS,WAAW,MAAA,CAAO,GAAG,QAAQ,QAAQ,IAAI;CAE5D,QAAQ,YAAY;EACnB,MAAM,QAAQ,UAAU,mBAAmB,OAAO,QAAQ,EAAE;EAE5D,MAAM,MAAM,YAA8B;GACzC,MAAM,QAAQ,MAAM,KACnB,MAAM,IAAI,iBAAiB,OAAO,GAClC,KACD;GACA,OAAO,QAAQ,IACd,MAAM,SAAS,IAAI,OAAO,EAAE,SAC3B,MAAM,MAAM,KAAc,MAAM,IAAI,mBAAmB,IAAI,GAAG,KAAK,CAAC,CACrE,CACD;EACD;EAEA,OAAO;GACN;GACA,MAAM,OAAO;IACZ,MAAM,WAAW,KAAK,IAAI,IAAI;IAC9B,SAAS;KACR,MAAM,CAAC,UAAU,MAAM,IAAI;KAC3B,IAAI,QAAQ,OAAO;KACnB,IAAI,KAAK,IAAI,KAAK,UAAU,MAAM,IAAI,OAAO,SAAS,OAAO;KAC7D,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,aAAa,CAAC;IAClE;GACD;GACA,MAAM,QAAQ;IACb,MAAM,WAAW,MAAM,IAAI,iBAAiB,SAAS,EACpD,QAAQ,SACT,CAAC;IACD,IAAI,CAAC,SAAS,IACb,MAAM,IAAI,iBAAiB,OAAO,SAAS,MAAM;GAEnD;EACD;CACD;AACD;AAeA,eAAe,KAAQ,UAAoB,OAA2B;CACrE,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,iBAAiB,OAAO,SAAS,MAAM;CACnE,OAAQ,MAAM,SAAS,KAAK;AAC7B;AAEA,SAAS,MAAM,SAAyB;CACvC,MAAM,QAAQ,CACb,GAAG,IAAI,IACN,CACC,IAAI,QAAQ,QAAQ,GAAA,CAAI,SAAS,4BAA4B,GAC7D,IAAI,QAAQ,QAAQ,GAAA,CAAI,SAAS,yBAAyB,CAC3D,CAAC,CAAC,KAAK,GAAG,SAAS,eAAe,GAAI,CAAC,CACxC,CACD;CAEA,OAAO;EACN,IAAI,QAAQ;EACZ,MAAM,QAAQ,KAAK;EACnB,IAAI,QAAQ,GAAG,KAAK,EAAE,cAAc,OAAO;EAC3C,SAAS,QAAQ;EACjB,MAAM,QAAQ,QAAQ;EACtB,MAAM,QAAQ,QAAQ;EACtB;EACA,MAAM,MAAM;CACb;AACD;;AAGA,SAAS,eAAe,KAAqB;CAC5C,OAAO,IAAI,WAAW,SAAS,GAAG;AACnC;;AAGA,IAAa,SAAb,cAA4B,MAAM;CAEvB;CACA;CAFV,YACC,SACA,SACC;EACD,MACC,eAAe,QAAQ,kBAAkB,QAAQ,kEAElD;EANS,KAAA,UAAA;EACA,KAAA,UAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,mBAAb,cAAsC,MAAM;CAEjC;CACA;CAFV,YACC,OACA,QACC;EACD,MACC,cAAc,MAAM,YAAY,OAAO,kFAExC;EANS,KAAA,QAAA;EACA,KAAA,SAAA;EAMT,KAAK,OAAO;CACb;AACD"}
|
package/dist/objection.cjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
const require_faker = require(
|
|
3
|
-
const require_ObjectionFactory = require(
|
|
4
|
-
require(
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const require_VitestObjectionTransactionIsolator = require('./VitestObjectionTransactionIsolator-DDoJTu7e.cjs');
|
|
8
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_faker = require("./faker.cjs");
|
|
3
|
+
const require_ObjectionFactory = require("./ObjectionFactory.cjs");
|
|
4
|
+
const require_PostgresObjectionMigrator = require("./PostgresObjectionMigrator.cjs");
|
|
5
|
+
const require_VitestTransactionIsolator = require("./VitestTransactionIsolator.cjs");
|
|
6
|
+
const require_VitestObjectionTransactionIsolator = require("./VitestObjectionTransactionIsolator.cjs");
|
|
9
7
|
//#region src/objection.ts
|
|
10
8
|
/**
|
|
11
9
|
* Creates a wrapped Vitest test API with automatic transaction rollback for Objection.js.
|
|
@@ -52,8 +50,7 @@ const require_VitestObjectionTransactionIsolator = require('./VitestObjectionTra
|
|
|
52
50
|
* ```
|
|
53
51
|
*/
|
|
54
52
|
function wrapVitestObjectionTransaction(api, options) {
|
|
55
|
-
|
|
56
|
-
return wrapper.wrapVitestWithTransaction(options);
|
|
53
|
+
return new require_VitestObjectionTransactionIsolator.VitestObjectionTransactionIsolator(api).wrapVitestWithTransaction(options);
|
|
57
54
|
}
|
|
58
55
|
/**
|
|
59
56
|
* Extends an Objection.js transaction-wrapped test with additional fixtures.
|
|
@@ -103,16 +100,16 @@ function wrapVitestObjectionTransaction(api, options) {
|
|
|
103
100
|
* });
|
|
104
101
|
* ```
|
|
105
102
|
*/
|
|
106
|
-
function extendWithFixtures
|
|
103
|
+
function extendWithFixtures(wrappedTest, fixtures) {
|
|
107
104
|
return require_VitestTransactionIsolator.extendWithFixtures(wrappedTest, fixtures);
|
|
108
105
|
}
|
|
109
|
-
|
|
110
106
|
//#endregion
|
|
111
107
|
exports.IsolationLevel = require_VitestTransactionIsolator.IsolationLevel;
|
|
112
108
|
exports.ObjectionFactory = require_ObjectionFactory.ObjectionFactory;
|
|
113
109
|
exports.PostgresObjectionMigrator = require_PostgresObjectionMigrator.PostgresObjectionMigrator;
|
|
114
110
|
exports.VitestObjectionTransactionIsolator = require_VitestObjectionTransactionIsolator.VitestObjectionTransactionIsolator;
|
|
115
|
-
exports.extendWithFixtures = extendWithFixtures
|
|
111
|
+
exports.extendWithFixtures = extendWithFixtures;
|
|
116
112
|
exports.faker = require_faker.faker;
|
|
117
113
|
exports.wrapVitestObjectionTransaction = wrapVitestObjectionTransaction;
|
|
114
|
+
|
|
118
115
|
//# sourceMappingURL=objection.cjs.map
|
package/dist/objection.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objection.cjs","names":["
|
|
1
|
+
{"version":3,"file":"objection.cjs","names":["VitestObjectionTransactionIsolator","baseExtendWithFixtures"],"sources":["../src/objection.ts"],"sourcesContent":["import type { Knex } from 'knex';\nimport type { TestAPI } from 'vitest';\nimport { VitestObjectionTransactionIsolator } from './VitestObjectionTransactionIsolator';\nimport {\n\textendWithFixtures as baseExtendWithFixtures,\n\ttype DatabaseConnection,\n\ttype FixtureCreators,\n\ttype IsolationLevel,\n} from './VitestTransactionIsolator';\n\n/**\n * Objection.js-specific exports for test utilities.\n * Provides factory implementation for creating test data with Objection.js ORM\n * and transaction isolation for test suites.\n */\n\nexport type { ExtractSeedAttrs, FactorySeed } from './Factory';\nexport { ObjectionFactory } from './ObjectionFactory';\nexport { PostgresObjectionMigrator } from './PostgresObjectionMigrator';\nexport { VitestObjectionTransactionIsolator } from './VitestObjectionTransactionIsolator';\nexport type {\n\tDatabaseFixtures,\n\tExtendedDatabaseFixtures,\n\tFixtureCreators,\n\tTestWithExtendedFixtures,\n\tTransactionWrapperOptions,\n} from './VitestTransactionIsolator';\nexport { IsolationLevel } from './VitestTransactionIsolator';\n\n/**\n * Objection.js-specific options for transaction wrapping.\n */\nexport interface ObjectionTransactionOptions<\n\tExtended extends Record<string, unknown> = {},\n> {\n\t/** Function that creates or returns a Knex database connection */\n\tconnection: DatabaseConnection<Knex>;\n\t/** Optional setup function to run within the transaction before each test */\n\tsetup?: (trx: Knex.Transaction) => Promise<void>;\n\t/** Transaction isolation level (defaults to REPEATABLE_READ) */\n\tisolationLevel?: IsolationLevel;\n\t/** Additional fixtures that depend on the transaction */\n\tfixtures?: FixtureCreators<Knex.Transaction, Extended>;\n}\n\n// Re-export faker and FakerFactory for type portability in declaration files\nexport { type FakerFactory, faker } from './faker';\n\n/**\n * Creates a wrapped Vitest test API with automatic transaction rollback for Objection.js.\n * Each test runs in an isolated database transaction that is rolled back after completion.\n * This ensures tests don't affect each other's data and run faster than truncating tables.\n *\n * @template Extended - Additional fixtures to provide\n * @param api - The Vitest test API (usually `test` from vitest)\n * @param options - Configuration options for transaction wrapping\n * @returns A wrapped test API that provides transaction isolation\n *\n * @example\n * ```typescript\n * import { test } from 'vitest';\n * import { wrapVitestObjectionTransaction } from '@geekmidas/testkit/objection';\n * import { knex } from './database';\n * import { User } from './models';\n *\n * // Create isolated test with automatic rollback\n * const isolatedTest = wrapVitestObjectionTransaction(test, {\n * connection: knex,\n * });\n *\n * // Use in tests - each test gets its own transaction\n * isolatedTest('should create user', async ({ trx }) => {\n * const user = await User.query(trx)\n * .insert({ name: 'Test User', email: 'test@example.com' });\n *\n * expect(user).toBeDefined();\n * });\n *\n * // With fixtures for factories\n * const it = wrapVitestObjectionTransaction<{ factory: Factory }>(test, {\n * connection: knex,\n * fixtures: {\n * factory: (trx) => new Factory(trx),\n * },\n * });\n *\n * it('should create user with factory', async ({ trx, factory }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user.id).toBeDefined();\n * });\n * ```\n */\nexport function wrapVitestObjectionTransaction<\n\tExtended extends Record<string, unknown> = {},\n>(api: TestAPI, options: ObjectionTransactionOptions<Extended>) {\n\tconst wrapper = new VitestObjectionTransactionIsolator(api);\n\n\treturn wrapper.wrapVitestWithTransaction(options);\n}\n\n/**\n * Extends an Objection.js transaction-wrapped test with additional fixtures.\n * Each fixture receives the transaction and can create dependencies like factories or repositories.\n *\n * @template Extended - The type of additional fixtures to provide\n * @param wrappedTest - The base wrapped test from wrapVitestObjectionTransaction\n * @param fixtures - Object mapping fixture names to creator functions\n * @returns An extended test API with both trx and the additional fixtures\n *\n * @example\n * ```typescript\n * import { test } from 'vitest';\n * import { wrapVitestObjectionTransaction, extendWithFixtures, ObjectionFactory } from '@geekmidas/testkit/objection';\n * import { User } from './models';\n *\n * // Define your builders\n * const builders = {\n * user: ObjectionFactory.createBuilder(User, ({ faker }) => ({\n * name: faker.person.fullName(),\n * email: faker.internet.email(),\n * })),\n * };\n *\n * // Create base wrapped test\n * const baseTest = wrapVitestObjectionTransaction(test, {\n * connection: knex,\n * setup: createTestTables,\n * });\n *\n * // Extend with fixtures - each fixture receives the transaction\n * const it = extendWithFixtures<{ factory: ObjectionFactory<typeof builders, {}> }>(\n * baseTest,\n * {\n * factory: (trx) => new ObjectionFactory(builders, {}, trx),\n * }\n * );\n *\n * // Use in tests - both trx and factory are available\n * it('should create user with factory', async ({ trx, factory }) => {\n * const user = await factory.insert('user', { name: 'Test User' });\n * expect(user.id).toBeDefined();\n *\n * // Verify in database\n * const found = await User.query(trx).findById(user.id);\n * expect(found?.name).toBe('Test User');\n * });\n * ```\n */\nexport function extendWithFixtures<\n\tExtended extends Record<string, unknown>,\n\tT extends ReturnType<TestAPI['extend']> = ReturnType<TestAPI['extend']>,\n>(wrappedTest: T, fixtures: FixtureCreators<Knex.Transaction, Extended>) {\n\treturn baseExtendWithFixtures<Knex.Transaction, Extended, T>(\n\t\twrappedTest,\n\t\tfixtures,\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,SAAgB,+BAEd,KAAc,SAAgD;CAG/D,OAAO,IAFaA,2CAAAA,mCAAmC,GAE1C,CAAC,CAAC,0BAA0B,OAAO;AACjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,mBAGd,aAAgB,UAAuD;CACxE,OAAOC,kCAAAA,mBACN,aACA,QACD;AACD"}
|
package/dist/objection.d.cts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { FakerFactory, faker } from "./faker
|
|
2
|
-
import { ExtractSeedAttrs, FactorySeed } from "./Factory
|
|
3
|
-
import { ObjectionFactory } from "./ObjectionFactory
|
|
4
|
-
import "./
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator-CTTjvTPO.cjs";
|
|
1
|
+
import { FakerFactory, faker } from "./faker.cjs";
|
|
2
|
+
import { ExtractSeedAttrs, FactorySeed } from "./Factory.cjs";
|
|
3
|
+
import { ObjectionFactory } from "./ObjectionFactory.cjs";
|
|
4
|
+
import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator.cjs";
|
|
5
|
+
import { DatabaseConnection, DatabaseFixtures, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions } from "./VitestTransactionIsolator.cjs";
|
|
6
|
+
import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator.cjs";
|
|
8
7
|
import { Knex } from "knex";
|
|
9
8
|
import { TestAPI } from "vitest";
|
|
10
|
-
|
|
11
9
|
//#region src/objection.d.ts
|
|
12
|
-
|
|
13
10
|
/**
|
|
14
11
|
* Objection.js-specific options for transaction wrapping.
|
|
15
12
|
*/
|
|
16
|
-
interface ObjectionTransactionOptions<Extended extends Record<string, unknown> = {}> {
|
|
13
|
+
export interface ObjectionTransactionOptions<Extended extends Record<string, unknown> = {}> {
|
|
17
14
|
/** Function that creates or returns a Knex database connection */
|
|
18
15
|
connection: DatabaseConnection<Knex>;
|
|
19
16
|
/** Optional setup function to run within the transaction before each test */
|
|
@@ -67,7 +64,7 @@ interface ObjectionTransactionOptions<Extended extends Record<string, unknown> =
|
|
|
67
64
|
* });
|
|
68
65
|
* ```
|
|
69
66
|
*/
|
|
70
|
-
declare function wrapVitestObjectionTransaction<Extended extends Record<string, unknown> = {}>(api: TestAPI, options: ObjectionTransactionOptions<Extended>): TestAPI<DatabaseFixtures<Knex.Transaction<any, any[]>, object> & Extended>;
|
|
67
|
+
export declare function wrapVitestObjectionTransaction<Extended extends Record<string, unknown> = {}>(api: TestAPI, options: ObjectionTransactionOptions<Extended>): TestAPI<DatabaseFixtures<Knex.Transaction<any, any[]>, object> & Extended>;
|
|
71
68
|
/**
|
|
72
69
|
* Extends an Objection.js transaction-wrapped test with additional fixtures.
|
|
73
70
|
* Each fixture receives the transaction and can create dependencies like factories or repositories.
|
|
@@ -116,8 +113,7 @@ declare function wrapVitestObjectionTransaction<Extended extends Record<string,
|
|
|
116
113
|
* });
|
|
117
114
|
* ```
|
|
118
115
|
*/
|
|
119
|
-
declare function extendWithFixtures<Extended extends Record<string, unknown>, T extends ReturnType<TestAPI['extend']> = ReturnType<TestAPI['extend']>>(wrappedTest: T, fixtures: FixtureCreators<Knex.Transaction, Extended>): TestWithExtendedFixtures<Knex.Transaction<any, any[]>, Extended, T>;
|
|
120
|
-
//# sourceMappingURL=objection.d.ts.map
|
|
116
|
+
export declare function extendWithFixtures<Extended extends Record<string, unknown>, T extends ReturnType<TestAPI['extend']> = ReturnType<TestAPI['extend']>>(wrappedTest: T, fixtures: FixtureCreators<Knex.Transaction, Extended>): TestWithExtendedFixtures<Knex.Transaction<any, any[]>, Extended, T>;
|
|
121
117
|
//#endregion
|
|
122
|
-
export { DatabaseFixtures, ExtendedDatabaseFixtures, ExtractSeedAttrs, FactorySeed, FakerFactory, FixtureCreators, IsolationLevel, ObjectionFactory,
|
|
118
|
+
export { type DatabaseFixtures, type ExtendedDatabaseFixtures, type ExtractSeedAttrs, type FactorySeed, type FakerFactory, type FixtureCreators, IsolationLevel, ObjectionFactory, PostgresObjectionMigrator, type TestWithExtendedFixtures, type TransactionWrapperOptions, VitestObjectionTransactionIsolator, faker };
|
|
123
119
|
//# sourceMappingURL=objection.d.cts.map
|
package/dist/objection.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objection.d.cts","names":[],"sources":["../src/objection.ts"],"
|
|
1
|
+
{"version":3,"file":"objection.d.cts","names":["_$__VitestTransactionIsolator0.DatabaseFixtures","_$__VitestTransactionIsolator0.TestWithExtendedFixtures"],"sources":["../src/objection.ts"],"mappings":";;;;;;;;;;;;iBAgCiB,4BAChB,iBAAiB;;EAGjB,YAAY,mBAAmB;;EAE/B,SAAS,KAAK,KAAK,gBAAgB;;EAEnC,iBAAiB;;EAEjB,WAAW,gBAAgB,KAAK,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkD9B,+BACf,iBAAiB,8BAChB,KAAK,SAAS,SAAS,4BAA4B,YAAS,QAAAA,iBAAA,KAAA,mCAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAsD9C,mBACf,iBAAiB,yBACjB,UAAU,WAAW,qBAAqB,WAAW,oBACpD,aAAa,GAAG,UAAU,gBAAgB,KAAK,aAAa,YAASC,yBAAA,KAAA,yBAAA,UAAA"}
|
package/dist/objection.d.mts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { FakerFactory, faker } from "./faker
|
|
2
|
-
import { ExtractSeedAttrs, FactorySeed } from "./Factory
|
|
3
|
-
import { ObjectionFactory } from "./ObjectionFactory
|
|
4
|
-
import "./
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator-CyZG6nq4.mjs";
|
|
1
|
+
import { FakerFactory, faker } from "./faker.mjs";
|
|
2
|
+
import { ExtractSeedAttrs, FactorySeed } from "./Factory.mjs";
|
|
3
|
+
import { ObjectionFactory } from "./ObjectionFactory.mjs";
|
|
4
|
+
import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator.mjs";
|
|
5
|
+
import { DatabaseConnection, DatabaseFixtures, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions } from "./VitestTransactionIsolator.mjs";
|
|
6
|
+
import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator.mjs";
|
|
8
7
|
import { TestAPI } from "vitest";
|
|
9
8
|
import { Knex } from "knex";
|
|
10
|
-
|
|
11
9
|
//#region src/objection.d.ts
|
|
12
|
-
|
|
13
10
|
/**
|
|
14
11
|
* Objection.js-specific options for transaction wrapping.
|
|
15
12
|
*/
|
|
16
|
-
interface ObjectionTransactionOptions<Extended extends Record<string, unknown> = {}> {
|
|
13
|
+
export interface ObjectionTransactionOptions<Extended extends Record<string, unknown> = {}> {
|
|
17
14
|
/** Function that creates or returns a Knex database connection */
|
|
18
15
|
connection: DatabaseConnection<Knex>;
|
|
19
16
|
/** Optional setup function to run within the transaction before each test */
|
|
@@ -67,7 +64,7 @@ interface ObjectionTransactionOptions<Extended extends Record<string, unknown> =
|
|
|
67
64
|
* });
|
|
68
65
|
* ```
|
|
69
66
|
*/
|
|
70
|
-
declare function wrapVitestObjectionTransaction<Extended extends Record<string, unknown> = {}>(api: TestAPI, options: ObjectionTransactionOptions<Extended>): TestAPI<DatabaseFixtures<Knex.Transaction<any, any[]>, object> & Extended>;
|
|
67
|
+
export declare function wrapVitestObjectionTransaction<Extended extends Record<string, unknown> = {}>(api: TestAPI, options: ObjectionTransactionOptions<Extended>): TestAPI<DatabaseFixtures<Knex.Transaction<any, any[]>, object> & Extended>;
|
|
71
68
|
/**
|
|
72
69
|
* Extends an Objection.js transaction-wrapped test with additional fixtures.
|
|
73
70
|
* Each fixture receives the transaction and can create dependencies like factories or repositories.
|
|
@@ -116,8 +113,7 @@ declare function wrapVitestObjectionTransaction<Extended extends Record<string,
|
|
|
116
113
|
* });
|
|
117
114
|
* ```
|
|
118
115
|
*/
|
|
119
|
-
declare function extendWithFixtures<Extended extends Record<string, unknown>, T extends ReturnType<TestAPI['extend']> = ReturnType<TestAPI['extend']>>(wrappedTest: T, fixtures: FixtureCreators<Knex.Transaction, Extended>): TestWithExtendedFixtures<Knex.Transaction<any, any[]>, Extended, T>;
|
|
120
|
-
//# sourceMappingURL=objection.d.ts.map
|
|
116
|
+
export declare function extendWithFixtures<Extended extends Record<string, unknown>, T extends ReturnType<TestAPI['extend']> = ReturnType<TestAPI['extend']>>(wrappedTest: T, fixtures: FixtureCreators<Knex.Transaction, Extended>): TestWithExtendedFixtures<Knex.Transaction<any, any[]>, Extended, T>;
|
|
121
117
|
//#endregion
|
|
122
|
-
export { DatabaseFixtures, ExtendedDatabaseFixtures, ExtractSeedAttrs, FactorySeed, FakerFactory, FixtureCreators, IsolationLevel, ObjectionFactory,
|
|
118
|
+
export { type DatabaseFixtures, type ExtendedDatabaseFixtures, type ExtractSeedAttrs, type FactorySeed, type FakerFactory, type FixtureCreators, IsolationLevel, ObjectionFactory, PostgresObjectionMigrator, type TestWithExtendedFixtures, type TransactionWrapperOptions, VitestObjectionTransactionIsolator, faker };
|
|
123
119
|
//# sourceMappingURL=objection.d.mts.map
|
package/dist/objection.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objection.d.mts","names":[],"sources":["../src/objection.ts"],"
|
|
1
|
+
{"version":3,"file":"objection.d.mts","names":["_$__VitestTransactionIsolator0.DatabaseFixtures","_$__VitestTransactionIsolator0.TestWithExtendedFixtures"],"sources":["../src/objection.ts"],"mappings":";;;;;;;;;;;;iBAgCiB,4BAChB,iBAAiB;;EAGjB,YAAY,mBAAmB;;EAE/B,SAAS,KAAK,KAAK,gBAAgB;;EAEnC,iBAAiB;;EAEjB,WAAW,gBAAgB,KAAK,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkD9B,+BACf,iBAAiB,8BAChB,KAAK,SAAS,SAAS,4BAA4B,YAAS,QAAAA,iBAAA,KAAA,mCAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAsD9C,mBACf,iBAAiB,yBACjB,UAAU,WAAW,qBAAqB,WAAW,oBACpD,aAAa,GAAG,UAAU,gBAAgB,KAAK,aAAa,YAASC,yBAAA,KAAA,yBAAA,UAAA"}
|
package/dist/objection.mjs
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import "./
|
|
5
|
-
import {
|
|
6
|
-
import { IsolationLevel, extendWithFixtures } from "./VitestTransactionIsolator-CvwPecpl.mjs";
|
|
7
|
-
import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator-B_VSWFum.mjs";
|
|
8
|
-
|
|
1
|
+
import { faker } from "./faker.mjs";
|
|
2
|
+
import { ObjectionFactory } from "./ObjectionFactory.mjs";
|
|
3
|
+
import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator.mjs";
|
|
4
|
+
import { IsolationLevel, extendWithFixtures as extendWithFixtures$1 } from "./VitestTransactionIsolator.mjs";
|
|
5
|
+
import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator.mjs";
|
|
9
6
|
//#region src/objection.ts
|
|
10
7
|
/**
|
|
11
8
|
* Creates a wrapped Vitest test API with automatic transaction rollback for Objection.js.
|
|
@@ -52,8 +49,7 @@ import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransaction
|
|
|
52
49
|
* ```
|
|
53
50
|
*/
|
|
54
51
|
function wrapVitestObjectionTransaction(api, options) {
|
|
55
|
-
|
|
56
|
-
return wrapper.wrapVitestWithTransaction(options);
|
|
52
|
+
return new VitestObjectionTransactionIsolator(api).wrapVitestWithTransaction(options);
|
|
57
53
|
}
|
|
58
54
|
/**
|
|
59
55
|
* Extends an Objection.js transaction-wrapped test with additional fixtures.
|
|
@@ -103,10 +99,10 @@ function wrapVitestObjectionTransaction(api, options) {
|
|
|
103
99
|
* });
|
|
104
100
|
* ```
|
|
105
101
|
*/
|
|
106
|
-
function extendWithFixtures
|
|
107
|
-
return extendWithFixtures(wrappedTest, fixtures);
|
|
102
|
+
function extendWithFixtures(wrappedTest, fixtures) {
|
|
103
|
+
return extendWithFixtures$1(wrappedTest, fixtures);
|
|
108
104
|
}
|
|
109
|
-
|
|
110
105
|
//#endregion
|
|
111
|
-
export { IsolationLevel, ObjectionFactory, PostgresObjectionMigrator, VitestObjectionTransactionIsolator, extendWithFixtures
|
|
106
|
+
export { IsolationLevel, ObjectionFactory, PostgresObjectionMigrator, VitestObjectionTransactionIsolator, extendWithFixtures, faker, wrapVitestObjectionTransaction };
|
|
107
|
+
|
|
112
108
|
//# sourceMappingURL=objection.mjs.map
|
package/dist/objection.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objection.mjs","names":["
|
|
1
|
+
{"version":3,"file":"objection.mjs","names":["baseExtendWithFixtures"],"sources":["../src/objection.ts"],"sourcesContent":["import type { Knex } from 'knex';\nimport type { TestAPI } from 'vitest';\nimport { VitestObjectionTransactionIsolator } from './VitestObjectionTransactionIsolator';\nimport {\n\textendWithFixtures as baseExtendWithFixtures,\n\ttype DatabaseConnection,\n\ttype FixtureCreators,\n\ttype IsolationLevel,\n} from './VitestTransactionIsolator';\n\n/**\n * Objection.js-specific exports for test utilities.\n * Provides factory implementation for creating test data with Objection.js ORM\n * and transaction isolation for test suites.\n */\n\nexport type { ExtractSeedAttrs, FactorySeed } from './Factory';\nexport { ObjectionFactory } from './ObjectionFactory';\nexport { PostgresObjectionMigrator } from './PostgresObjectionMigrator';\nexport { VitestObjectionTransactionIsolator } from './VitestObjectionTransactionIsolator';\nexport type {\n\tDatabaseFixtures,\n\tExtendedDatabaseFixtures,\n\tFixtureCreators,\n\tTestWithExtendedFixtures,\n\tTransactionWrapperOptions,\n} from './VitestTransactionIsolator';\nexport { IsolationLevel } from './VitestTransactionIsolator';\n\n/**\n * Objection.js-specific options for transaction wrapping.\n */\nexport interface ObjectionTransactionOptions<\n\tExtended extends Record<string, unknown> = {},\n> {\n\t/** Function that creates or returns a Knex database connection */\n\tconnection: DatabaseConnection<Knex>;\n\t/** Optional setup function to run within the transaction before each test */\n\tsetup?: (trx: Knex.Transaction) => Promise<void>;\n\t/** Transaction isolation level (defaults to REPEATABLE_READ) */\n\tisolationLevel?: IsolationLevel;\n\t/** Additional fixtures that depend on the transaction */\n\tfixtures?: FixtureCreators<Knex.Transaction, Extended>;\n}\n\n// Re-export faker and FakerFactory for type portability in declaration files\nexport { type FakerFactory, faker } from './faker';\n\n/**\n * Creates a wrapped Vitest test API with automatic transaction rollback for Objection.js.\n * Each test runs in an isolated database transaction that is rolled back after completion.\n * This ensures tests don't affect each other's data and run faster than truncating tables.\n *\n * @template Extended - Additional fixtures to provide\n * @param api - The Vitest test API (usually `test` from vitest)\n * @param options - Configuration options for transaction wrapping\n * @returns A wrapped test API that provides transaction isolation\n *\n * @example\n * ```typescript\n * import { test } from 'vitest';\n * import { wrapVitestObjectionTransaction } from '@geekmidas/testkit/objection';\n * import { knex } from './database';\n * import { User } from './models';\n *\n * // Create isolated test with automatic rollback\n * const isolatedTest = wrapVitestObjectionTransaction(test, {\n * connection: knex,\n * });\n *\n * // Use in tests - each test gets its own transaction\n * isolatedTest('should create user', async ({ trx }) => {\n * const user = await User.query(trx)\n * .insert({ name: 'Test User', email: 'test@example.com' });\n *\n * expect(user).toBeDefined();\n * });\n *\n * // With fixtures for factories\n * const it = wrapVitestObjectionTransaction<{ factory: Factory }>(test, {\n * connection: knex,\n * fixtures: {\n * factory: (trx) => new Factory(trx),\n * },\n * });\n *\n * it('should create user with factory', async ({ trx, factory }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user.id).toBeDefined();\n * });\n * ```\n */\nexport function wrapVitestObjectionTransaction<\n\tExtended extends Record<string, unknown> = {},\n>(api: TestAPI, options: ObjectionTransactionOptions<Extended>) {\n\tconst wrapper = new VitestObjectionTransactionIsolator(api);\n\n\treturn wrapper.wrapVitestWithTransaction(options);\n}\n\n/**\n * Extends an Objection.js transaction-wrapped test with additional fixtures.\n * Each fixture receives the transaction and can create dependencies like factories or repositories.\n *\n * @template Extended - The type of additional fixtures to provide\n * @param wrappedTest - The base wrapped test from wrapVitestObjectionTransaction\n * @param fixtures - Object mapping fixture names to creator functions\n * @returns An extended test API with both trx and the additional fixtures\n *\n * @example\n * ```typescript\n * import { test } from 'vitest';\n * import { wrapVitestObjectionTransaction, extendWithFixtures, ObjectionFactory } from '@geekmidas/testkit/objection';\n * import { User } from './models';\n *\n * // Define your builders\n * const builders = {\n * user: ObjectionFactory.createBuilder(User, ({ faker }) => ({\n * name: faker.person.fullName(),\n * email: faker.internet.email(),\n * })),\n * };\n *\n * // Create base wrapped test\n * const baseTest = wrapVitestObjectionTransaction(test, {\n * connection: knex,\n * setup: createTestTables,\n * });\n *\n * // Extend with fixtures - each fixture receives the transaction\n * const it = extendWithFixtures<{ factory: ObjectionFactory<typeof builders, {}> }>(\n * baseTest,\n * {\n * factory: (trx) => new ObjectionFactory(builders, {}, trx),\n * }\n * );\n *\n * // Use in tests - both trx and factory are available\n * it('should create user with factory', async ({ trx, factory }) => {\n * const user = await factory.insert('user', { name: 'Test User' });\n * expect(user.id).toBeDefined();\n *\n * // Verify in database\n * const found = await User.query(trx).findById(user.id);\n * expect(found?.name).toBe('Test User');\n * });\n * ```\n */\nexport function extendWithFixtures<\n\tExtended extends Record<string, unknown>,\n\tT extends ReturnType<TestAPI['extend']> = ReturnType<TestAPI['extend']>,\n>(wrappedTest: T, fixtures: FixtureCreators<Knex.Transaction, Extended>) {\n\treturn baseExtendWithFixtures<Knex.Transaction, Extended, T>(\n\t\twrappedTest,\n\t\tfixtures,\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,SAAgB,+BAEd,KAAc,SAAgD;CAG/D,OAAO,IAFa,mCAAmC,GAE1C,CAAC,CAAC,0BAA0B,OAAO;AACjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,mBAGd,aAAgB,UAAuD;CACxE,OAAOA,qBACN,aACA,QACD;AACD"}
|
package/dist/os/directory.cjs
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("../rolldown-runtime-VH7oDXx4.cjs");
|
|
3
|
+
let vitest = require("vitest");
|
|
4
|
+
let node_crypto = require("node:crypto");
|
|
5
|
+
node_crypto = require_rolldown_runtime.__toESM(node_crypto, 1);
|
|
6
|
+
let node_fs_promises = require("node:fs/promises");
|
|
7
|
+
node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises, 1);
|
|
8
|
+
let node_os = require("node:os");
|
|
9
|
+
node_os = require_rolldown_runtime.__toESM(node_os, 1);
|
|
10
|
+
let node_path = require("node:path");
|
|
11
|
+
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
12
|
+
//#region src/os/directory.ts
|
|
13
|
+
const itWithDir = vitest.it.extend({ dir: async ({}, use) => {
|
|
14
|
+
const tempDir = node_os.default.tmpdir();
|
|
15
|
+
const directoryName = node_crypto.default.randomUUID().replace(/-/g, "").toUpperCase();
|
|
16
|
+
const dir = node_path.default.join(tempDir, directoryName);
|
|
17
|
+
await node_fs_promises.default.mkdir(dir, { recursive: true });
|
|
18
|
+
await use(dir);
|
|
19
|
+
await node_fs_promises.default.rm(dir, {
|
|
20
|
+
recursive: true,
|
|
21
|
+
force: true
|
|
22
|
+
});
|
|
23
|
+
const keystoreDir = node_path.default.join(node_os.default.homedir(), ".gkm", directoryName);
|
|
24
|
+
await node_fs_promises.default.rm(keystoreDir, {
|
|
25
|
+
recursive: true,
|
|
26
|
+
force: true
|
|
27
|
+
});
|
|
28
|
+
} });
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.itWithDir = itWithDir;
|
|
2
31
|
|
|
3
|
-
|
|
32
|
+
//# sourceMappingURL=directory.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.cjs","names":["it","os","crypto","path","fs"],"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,YAAYA,OAAAA,GAAG,OAA0B,EAGrD,KAAK,OAAO,IAAI,QAAQ;CACvB,MAAM,UAAUC,QAAAA,QAAG,OAAO;CAC1B,MAAM,gBAAgBC,YAAAA,QAAO,WAAW,CAAC,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC,YAAY;CACxE,MAAM,MAAMC,UAAAA,QAAK,KAAK,SAAS,aAAa;CAC5C,MAAMC,iBAAAA,QAAG,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;CACvC,MAAM,IAAI,GAAG;CACb,MAAMA,iBAAAA,QAAG,GAAG,KAAK;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;CAGjD,MAAM,cAAcD,UAAAA,QAAK,KAAKF,QAAAA,QAAG,QAAQ,GAAG,QAAQ,aAAa;CACjE,MAAMG,iBAAAA,QAAG,GAAG,aAAa;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;AAC1D,EACD,CAAC"}
|
package/dist/os/directory.d.cts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
//#region src/os/directory.d.ts
|
|
2
|
+
export declare const itWithDir: import("vitest").TestAPI<{
|
|
3
|
+
dir: string;
|
|
4
|
+
}>;
|
|
5
|
+
export interface DirectoryFixtures {
|
|
6
|
+
dir: string;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//# sourceMappingURL=directory.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.d.cts","names":[],"sources":["../../src/os/directory.ts"],"mappings":";qBAMa,4BAAS;EAAA;;iBAiBL;EAChB"}
|
package/dist/os/directory.d.mts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
//#region src/os/directory.d.ts
|
|
2
|
+
export declare const itWithDir: import("vitest").TestAPI<{
|
|
3
|
+
dir: string;
|
|
4
|
+
}>;
|
|
5
|
+
export interface DirectoryFixtures {
|
|
6
|
+
dir: string;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//# sourceMappingURL=directory.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.d.mts","names":[],"sources":["../../src/os/directory.ts"],"mappings":";qBAMa,4BAAS;EAAA;;iBAiBL;EAChB"}
|
package/dist/os/directory.mjs
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { it } from "vitest";
|
|
2
|
+
import crypto from "node:crypto";
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
//#region src/os/directory.ts
|
|
7
|
+
const itWithDir = it.extend({ dir: async ({}, use) => {
|
|
8
|
+
const tempDir = os.tmpdir();
|
|
9
|
+
const directoryName = crypto.randomUUID().replace(/-/g, "").toUpperCase();
|
|
10
|
+
const dir = path.join(tempDir, directoryName);
|
|
11
|
+
await fs.mkdir(dir, { recursive: true });
|
|
12
|
+
await use(dir);
|
|
13
|
+
await fs.rm(dir, {
|
|
14
|
+
recursive: true,
|
|
15
|
+
force: true
|
|
16
|
+
});
|
|
17
|
+
const keystoreDir = path.join(os.homedir(), ".gkm", directoryName);
|
|
18
|
+
await fs.rm(keystoreDir, {
|
|
19
|
+
recursive: true,
|
|
20
|
+
force: true
|
|
21
|
+
});
|
|
22
|
+
} });
|
|
23
|
+
//#endregion
|
|
24
|
+
export { itWithDir };
|
|
2
25
|
|
|
3
|
-
|
|
26
|
+
//# sourceMappingURL=directory.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.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,IAAI,QAAQ;CACvB,MAAM,UAAU,GAAG,OAAO;CAC1B,MAAM,gBAAgB,OAAO,WAAW,CAAC,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC,YAAY;CACxE,MAAM,MAAM,KAAK,KAAK,SAAS,aAAa;CAC5C,MAAM,GAAG,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;CACvC,MAAM,IAAI,GAAG;CACb,MAAM,GAAG,GAAG,KAAK;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;CAGjD,MAAM,cAAc,KAAK,KAAK,GAAG,QAAQ,GAAG,QAAQ,aAAa;CACjE,MAAM,GAAG,GAAG,aAAa;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;AAC1D,EACD,CAAC"}
|