@geekmidas/testkit 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Factory-z2m01hMj.mjs → Factory-BFVnMMCC.mjs} +2 -2
- package/dist/Factory-BFVnMMCC.mjs.map +1 -0
- package/dist/{Factory-DE3hE0WO.d.mts → Factory-BcGJjLc8.d.mts} +24 -10
- package/dist/{Factory-WMhTNZ9S.cjs → Factory-BhjUOBWN.cjs} +2 -2
- package/dist/Factory-BhjUOBWN.cjs.map +1 -0
- package/dist/{Factory-pNV7ZQ7-.d.cts → Factory-IdfEkOeT.d.cts} +24 -10
- package/dist/Factory.cjs +1 -1
- package/dist/Factory.d.cts +3 -3
- package/dist/Factory.d.mts +3 -3
- package/dist/Factory.mjs +1 -1
- package/dist/{KyselyFactory-DaaCykWP.cjs → KyselyFactory-BFqVIn_0.cjs} +21 -4
- package/dist/KyselyFactory-BFqVIn_0.cjs.map +1 -0
- package/dist/{KyselyFactory-CPZTUuMB.d.cts → KyselyFactory-Cj-EultY.d.mts} +18 -5
- package/dist/{KyselyFactory-CXY5gJk2.mjs → KyselyFactory-DMswpwji.mjs} +21 -4
- package/dist/KyselyFactory-DMswpwji.mjs.map +1 -0
- package/dist/{KyselyFactory-RAyvZ8Cj.d.mts → KyselyFactory-Dxhi_ZkA.d.cts} +18 -5
- package/dist/KyselyFactory.cjs +2 -2
- package/dist/KyselyFactory.d.cts +3 -3
- package/dist/KyselyFactory.d.mts +3 -3
- package/dist/KyselyFactory.mjs +2 -2
- package/dist/{ObjectionFactory-BlBicEia.d.mts → ObjectionFactory-BRAkAByP.d.cts} +18 -5
- package/dist/{ObjectionFactory-Eb04AOnv.cjs → ObjectionFactory-BeFBYcan.cjs} +21 -4
- package/dist/ObjectionFactory-BeFBYcan.cjs.map +1 -0
- package/dist/{ObjectionFactory-BwpN4gMX.d.cts → ObjectionFactory-DL4qkuF1.d.mts} +18 -5
- package/dist/{ObjectionFactory-zf2fLKrL.mjs → ObjectionFactory-QCJ7u0Ql.mjs} +21 -4
- package/dist/ObjectionFactory-QCJ7u0Ql.mjs.map +1 -0
- package/dist/ObjectionFactory.cjs +2 -2
- package/dist/ObjectionFactory.d.cts +3 -3
- package/dist/ObjectionFactory.d.mts +3 -3
- package/dist/ObjectionFactory.mjs +2 -2
- package/dist/{VitestKyselyTransactionIsolator-XDL3ngs_.mjs → VitestKyselyTransactionIsolator-CNURW8y6.mjs} +2 -2
- package/dist/{VitestKyselyTransactionIsolator-XDL3ngs_.mjs.map → VitestKyselyTransactionIsolator-CNURW8y6.mjs.map} +1 -1
- package/dist/{VitestKyselyTransactionIsolator-DiskaURs.d.mts → VitestKyselyTransactionIsolator-D3EZZhjZ.d.cts} +2 -2
- package/dist/{VitestKyselyTransactionIsolator-BqrZDeaT.d.cts → VitestKyselyTransactionIsolator-Dxlp1u0f.d.mts} +2 -2
- package/dist/{VitestKyselyTransactionIsolator-DX_VPKS-.cjs → VitestKyselyTransactionIsolator-EvDLk5zg.cjs} +2 -2
- package/dist/{VitestKyselyTransactionIsolator-DX_VPKS-.cjs.map → VitestKyselyTransactionIsolator-EvDLk5zg.cjs.map} +1 -1
- package/dist/VitestKyselyTransactionIsolator.cjs +2 -2
- package/dist/VitestKyselyTransactionIsolator.d.cts +2 -2
- package/dist/VitestKyselyTransactionIsolator.d.mts +2 -2
- package/dist/VitestKyselyTransactionIsolator.mjs +2 -2
- package/dist/{VitestObjectionTransactionIsolator-CD2ucJpH.d.cts → VitestObjectionTransactionIsolator-1TpsPqfG.d.cts} +2 -2
- package/dist/{VitestObjectionTransactionIsolator-D_tlOtq8.cjs → VitestObjectionTransactionIsolator-CM5KTAFA.cjs} +2 -2
- package/dist/{VitestObjectionTransactionIsolator-D_tlOtq8.cjs.map → VitestObjectionTransactionIsolator-CM5KTAFA.cjs.map} +1 -1
- package/dist/{VitestObjectionTransactionIsolator-DhQ8XGva.d.mts → VitestObjectionTransactionIsolator-i9jIgU8Q.d.mts} +2 -2
- package/dist/{VitestObjectionTransactionIsolator-_EhJKu_O.mjs → VitestObjectionTransactionIsolator-jQFaCz0u.mjs} +2 -2
- package/dist/{VitestObjectionTransactionIsolator-_EhJKu_O.mjs.map → VitestObjectionTransactionIsolator-jQFaCz0u.mjs.map} +1 -1
- package/dist/VitestObjectionTransactionIsolator.cjs +2 -2
- package/dist/VitestObjectionTransactionIsolator.d.cts +2 -2
- package/dist/VitestObjectionTransactionIsolator.d.mts +2 -2
- package/dist/VitestObjectionTransactionIsolator.mjs +2 -2
- package/dist/{VitestTransactionIsolator-DLdQlfZ5.d.mts → VitestTransactionIsolator-BvR19bYn.d.mts} +31 -14
- package/dist/{VitestTransactionIsolator-BKIrj3Uy.cjs → VitestTransactionIsolator-CMfJXZP8.cjs} +52 -36
- package/dist/VitestTransactionIsolator-CMfJXZP8.cjs.map +1 -0
- package/dist/{VitestTransactionIsolator-DfA80g2M.d.cts → VitestTransactionIsolator-CwQaxZLP.d.cts} +31 -14
- package/dist/{VitestTransactionIsolator-BIaMs4c2.mjs → VitestTransactionIsolator-DQ7tLqgV.mjs} +52 -36
- package/dist/VitestTransactionIsolator-DQ7tLqgV.mjs.map +1 -0
- package/dist/VitestTransactionIsolator.cjs +1 -1
- package/dist/VitestTransactionIsolator.d.cts +2 -2
- package/dist/VitestTransactionIsolator.d.mts +2 -2
- package/dist/VitestTransactionIsolator.mjs +1 -1
- package/dist/benchmark.cjs +49 -0
- package/dist/benchmark.cjs.map +1 -0
- package/dist/benchmark.d.cts +35 -0
- package/dist/benchmark.d.mts +35 -0
- package/dist/benchmark.mjs +45 -0
- package/dist/benchmark.mjs.map +1 -0
- package/dist/better-auth.d.cts +2 -2
- package/dist/better-auth.d.mts +2 -2
- package/dist/{directory-Q178x53k.d.mts → directory-BXavAeJZ.d.mts} +3 -3
- package/dist/{faker-BSH1EMtg.d.cts → faker-CbYiF-8_.d.cts} +3 -3
- package/dist/{faker-D9gz7KjY.d.mts → faker-DHh7xs4u.d.mts} +3 -3
- package/dist/faker.d.cts +1 -1
- package/dist/faker.d.mts +1 -1
- package/dist/kysely.cjs +25 -31
- package/dist/kysely.cjs.map +1 -1
- package/dist/kysely.d.cts +39 -34
- package/dist/kysely.d.mts +39 -34
- package/dist/kysely.mjs +25 -31
- package/dist/kysely.mjs.map +1 -1
- package/dist/objection.cjs +25 -49
- package/dist/objection.cjs.map +1 -1
- package/dist/objection.d.cts +39 -52
- package/dist/objection.d.mts +39 -52
- package/dist/objection.mjs +25 -49
- package/dist/objection.mjs.map +1 -1
- package/dist/os/directory.d.mts +1 -1
- package/dist/os/index.d.mts +1 -1
- package/package.json +6 -1
- package/src/Factory.ts +25 -11
- package/src/KyselyFactory.ts +21 -4
- package/src/ObjectionFactory.ts +21 -4
- package/src/VitestTransactionIsolator.ts +67 -16
- package/src/__tests__/Factory.spec.ts +16 -10
- package/src/__tests__/KyselyFactory.spec.ts +16 -11
- package/src/__tests__/ObjectionFactory.spec.ts +61 -53
- package/src/__tests__/VitestObjectionTransactionIsolator.spec.ts +6 -3
- package/src/__tests__/integration.spec.ts +24 -18
- package/src/benchmark.ts +48 -0
- package/src/kysely.ts +44 -33
- package/src/objection.ts +42 -51
- package/dist/Factory-WMhTNZ9S.cjs.map +0 -1
- package/dist/Factory-z2m01hMj.mjs.map +0 -1
- package/dist/KyselyFactory-CXY5gJk2.mjs.map +0 -1
- package/dist/KyselyFactory-DaaCykWP.cjs.map +0 -1
- package/dist/ObjectionFactory-Eb04AOnv.cjs.map +0 -1
- package/dist/ObjectionFactory-zf2fLKrL.mjs.map +0 -1
- package/dist/VitestTransactionIsolator-BIaMs4c2.mjs.map +0 -1
- package/dist/VitestTransactionIsolator-BKIrj3Uy.cjs.map +0 -1
package/dist/{VitestTransactionIsolator-BKIrj3Uy.cjs → VitestTransactionIsolator-CMfJXZP8.cjs}
RENAMED
|
@@ -69,51 +69,64 @@ var VitestPostgresTransactionIsolator = class {
|
|
|
69
69
|
* Creates a wrapped version of Vitest's test API that provides transaction isolation.
|
|
70
70
|
* Each test will run within a database transaction that is automatically rolled back.
|
|
71
71
|
*
|
|
72
|
-
* @param
|
|
73
|
-
* @param setup - Optional setup function to run within the transaction before each test
|
|
74
|
-
* @param level - The transaction isolation level (defaults to REPEATABLE_READ)
|
|
72
|
+
* @param options - Configuration options for transaction wrapping
|
|
75
73
|
* @returns A wrapped test API with transaction support
|
|
76
74
|
*
|
|
77
75
|
* @example
|
|
78
76
|
* ```typescript
|
|
79
|
-
* const isolatedTest = isolator.wrapVitestWithTransaction(
|
|
80
|
-
*
|
|
81
|
-
*
|
|
77
|
+
* const isolatedTest = isolator.wrapVitestWithTransaction({
|
|
78
|
+
* connection: db,
|
|
79
|
+
* setup: async (trx) => {
|
|
80
|
+
* await trx.insert('settings', { key: 'test', value: 'true' });
|
|
81
|
+
* },
|
|
82
|
+
* fixtures: {
|
|
83
|
+
* factory: (trx) => new Factory(trx),
|
|
84
|
+
* },
|
|
82
85
|
* });
|
|
83
86
|
*
|
|
84
|
-
* isolatedTest('test with transaction', async ({ trx }) => {
|
|
85
|
-
* const user = await
|
|
87
|
+
* isolatedTest('test with transaction', async ({ trx, factory }) => {
|
|
88
|
+
* const user = await factory.insert('user', { name: 'Test' });
|
|
86
89
|
* expect(user).toBeDefined();
|
|
87
90
|
* });
|
|
88
91
|
* ```
|
|
89
92
|
*/
|
|
90
|
-
wrapVitestWithTransaction(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
await use(transaction);
|
|
105
|
-
} catch (error) {
|
|
106
|
-
testError = error;
|
|
93
|
+
wrapVitestWithTransaction(options) {
|
|
94
|
+
const { connection, setup, isolationLevel = IsolationLevel.REPEATABLE_READ, fixtures } = options;
|
|
95
|
+
const additionalFixtures = {};
|
|
96
|
+
if (fixtures) for (const [key, creator] of Object.entries(fixtures)) additionalFixtures[key] = async ({ trx }, use) => {
|
|
97
|
+
const value = await creator(trx);
|
|
98
|
+
await use(value);
|
|
99
|
+
};
|
|
100
|
+
const extendFn = this.api.extend;
|
|
101
|
+
return extendFn({
|
|
102
|
+
trx: async ({}, use) => {
|
|
103
|
+
class TestRollback extends Error {
|
|
104
|
+
constructor() {
|
|
105
|
+
super("Test rollback");
|
|
106
|
+
this.name = "TestRollback";
|
|
107
107
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
}
|
|
109
|
+
let testError;
|
|
110
|
+
const conn = await connection();
|
|
111
|
+
try {
|
|
112
|
+
await this.transact(conn, isolationLevel, async (transaction) => {
|
|
113
|
+
try {
|
|
114
|
+
await setup?.(transaction);
|
|
115
|
+
await use(transaction);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
testError = error;
|
|
118
|
+
}
|
|
119
|
+
throw new TestRollback();
|
|
120
|
+
});
|
|
121
|
+
} catch (error) {
|
|
122
|
+
if (!(error instanceof TestRollback)) throw error;
|
|
123
|
+
if (testError) throw testError;
|
|
124
|
+
} finally {
|
|
125
|
+
await this.destroy(conn);
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
...additionalFixtures
|
|
129
|
+
});
|
|
117
130
|
}
|
|
118
131
|
};
|
|
119
132
|
/**
|
|
@@ -131,7 +144,10 @@ var VitestPostgresTransactionIsolator = class {
|
|
|
131
144
|
* import { wrapVitestKyselyTransaction, extendWithFixtures } from '@geekmidas/testkit/kysely';
|
|
132
145
|
*
|
|
133
146
|
* // Create base wrapped test
|
|
134
|
-
* const baseTest = wrapVitestKyselyTransaction(test,
|
|
147
|
+
* const baseTest = wrapVitestKyselyTransaction(test, {
|
|
148
|
+
* connection: db,
|
|
149
|
+
* setup: createTestTables,
|
|
150
|
+
* });
|
|
135
151
|
*
|
|
136
152
|
* // Extend with fixtures
|
|
137
153
|
* const it = extendWithFixtures(baseTest, {
|
|
@@ -174,4 +190,4 @@ Object.defineProperty(exports, 'extendWithFixtures', {
|
|
|
174
190
|
return extendWithFixtures;
|
|
175
191
|
}
|
|
176
192
|
});
|
|
177
|
-
//# sourceMappingURL=VitestTransactionIsolator-
|
|
193
|
+
//# sourceMappingURL=VitestTransactionIsolator-CMfJXZP8.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VitestTransactionIsolator-CMfJXZP8.cjs","names":["api: TestAPI","options: TransactionWrapperOptions<TConn, Transaction, Extended>","additionalFixtures: Record<string, unknown>","use: (value: unknown) => Promise<void>","use: (value: Transaction) => Promise<void>","testError: Error | undefined","wrappedTest: T","fixtures: FixtureCreators<Transaction, Extended>","fixtureDefinitions: Record<string, any>"],"sources":["../src/VitestTransactionIsolator.ts"],"sourcesContent":["import type { TestAPI } from 'vitest';\n\n/**\n * Type definition for test fixtures that provide transaction access.\n * Used with Vitest's test.extend() API to inject transactions into tests.\n *\n * @template Transaction - The transaction type specific to the database driver\n * @template Extended - Additional context properties provided by the extend function\n */\nexport interface DatabaseFixtures<Transaction, Extended = object> {\n /**\n * The database transaction available to the test.\n * All database operations should use this transaction to ensure proper rollback.\n */\n trx: Transaction;\n}\n\n/**\n * Combined fixtures type that merges the base transaction fixture with extended context.\n */\nexport type ExtendedDatabaseFixtures<\n Transaction,\n Extended = object,\n> = DatabaseFixtures<Transaction> & Extended;\n\n/**\n * Function type for extending test context with additional properties.\n * Receives the transaction and returns additional context to be merged with { trx }.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional context to provide\n *\n * @example\n * ```typescript\n * const extendContext: ExtendContextFn<Transaction<DB>, { factory: KyselyFactory }> =\n * (trx) => ({ factory: new KyselyFactory(builders, seeds, trx) });\n * ```\n */\nexport type ExtendContextFn<Transaction, Extended> = (\n trx: Transaction,\n) => Extended | Promise<Extended>;\n\n/**\n * PostgreSQL transaction isolation levels.\n * Controls the visibility of concurrent transactions.\n *\n * @see https://www.postgresql.org/docs/current/transaction-iso.html\n */\nexport enum IsolationLevel {\n /**\n * Lowest isolation level. Allows dirty reads.\n * Not recommended for testing.\n */\n READ_UNCOMMITTED = 'READ UNCOMMITTED',\n /**\n * Default PostgreSQL isolation level.\n * Prevents dirty reads but allows non-repeatable reads.\n */\n READ_COMMITTED = 'READ COMMITTED',\n /**\n * Prevents dirty reads and non-repeatable reads.\n * Recommended for most test scenarios.\n */\n REPEATABLE_READ = 'REPEATABLE READ',\n /**\n * Highest isolation level. Prevents all phenomena.\n * May cause performance overhead in tests.\n */\n SERIALIZABLE = 'SERIALIZABLE',\n}\n\n/**\n * Abstract base class for implementing database transaction isolation in Vitest tests.\n * Provides automatic transaction rollback after each test to maintain test isolation.\n * Subclasses must implement the transact() method for their specific database driver.\n *\n * @template TConn - The database connection type\n * @template Transaction - The transaction type\n *\n * @example\n * ```typescript\n * // Implement for your database driver\n * class MyDatabaseIsolator extends VitestPostgresTransactionIsolator<MyDB, MyTx> {\n * async transact(conn: MyDB, level: IsolationLevel, fn: (tx: MyTx) => Promise<void>) {\n * await conn.transaction(level, fn);\n * }\n * }\n *\n * // Use in tests\n * const isolator = new MyDatabaseIsolator(test);\n * const isolatedTest = isolator.wrapVitestWithTransaction(db);\n *\n * isolatedTest('should create user', async ({ trx }) => {\n * await trx.insert('users', { name: 'Test' });\n * // Data is automatically rolled back after test\n * });\n * ```\n */\nexport abstract class VitestPostgresTransactionIsolator<TConn, Transaction> {\n /**\n * Abstract method to create a transaction with the specified isolation level.\n * Must be implemented by subclasses for specific database drivers.\n *\n * @param conn - The database connection\n * @param isolationLevel - The transaction isolation level\n * @param fn - The function to execute within the transaction\n * @returns Promise that resolves when the transaction completes\n */\n abstract transact(\n conn: TConn,\n isolationLevel: IsolationLevel,\n fn: (trx: Transaction) => Promise<void>,\n ): Promise<void>;\n\n abstract destroy(conn: TConn): Promise<void>;\n /**\n * Creates a new VitestPostgresTransactionIsolator instance.\n *\n * @param api - The Vitest test API (usually the `test` export from vitest)\n */\n constructor(private readonly api: TestAPI) {}\n\n /**\n * Creates a wrapped version of Vitest's test API that provides transaction isolation.\n * Each test will run within a database transaction that is automatically rolled back.\n *\n * @param options - Configuration options for transaction wrapping\n * @returns A wrapped test API with transaction support\n *\n * @example\n * ```typescript\n * const isolatedTest = isolator.wrapVitestWithTransaction({\n * connection: db,\n * setup: async (trx) => {\n * await trx.insert('settings', { key: 'test', value: 'true' });\n * },\n * fixtures: {\n * factory: (trx) => new Factory(trx),\n * },\n * });\n *\n * isolatedTest('test with transaction', async ({ trx, factory }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user).toBeDefined();\n * });\n * ```\n */\n wrapVitestWithTransaction<Extended extends Record<string, unknown> = {}>(\n options: TransactionWrapperOptions<TConn, Transaction, Extended>,\n ) {\n const {\n connection,\n setup,\n isolationLevel = IsolationLevel.REPEATABLE_READ,\n fixtures,\n } = options;\n\n // Build fixture definitions for additional fixtures that depend on trx\n const additionalFixtures: Record<string, unknown> = {};\n if (fixtures) {\n for (const [key, creator] of Object.entries(fixtures)) {\n additionalFixtures[key] = async (\n { trx }: { trx: Transaction },\n use: (value: unknown) => Promise<void>,\n ) => {\n const value = await (creator as (trx: Transaction) => unknown)(trx);\n await use(value);\n };\n }\n }\n\n type CombinedFixtures = DatabaseFixtures<Transaction> & Extended;\n\n // Cast to bypass Vitest's strict fixture typing which can't infer\n // dynamically built fixture objects\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const extendFn = this.api.extend as <T>(fixtures: any) => TestAPI<T>;\n\n return extendFn<CombinedFixtures>({\n // This fixture automatically provides a transaction to each test\n trx: async ({}, use: (value: Transaction) => Promise<void>) => {\n // Create a custom error class for rollback\n class TestRollback extends Error {\n constructor() {\n super('Test rollback');\n this.name = 'TestRollback';\n }\n }\n\n let testError: Error | undefined;\n const conn = await connection();\n try {\n await this.transact(conn, isolationLevel, async (transaction) => {\n try {\n // Provide the transaction to the test\n await setup?.(transaction);\n await use(transaction);\n } catch (error) {\n // Capture any test errors\n testError = error as Error;\n }\n\n // Always throw to trigger rollback\n throw new TestRollback();\n });\n } catch (error) {\n // Only rethrow if it's not our rollback error\n if (!(error instanceof TestRollback)) {\n throw error;\n }\n\n // If the test had an error, throw it now\n if (testError) {\n throw testError;\n }\n } finally {\n await this.destroy(conn);\n }\n },\n ...additionalFixtures,\n });\n }\n}\n\nexport type DatabaseConnectionFn<Conn> = () => Conn | Promise<Conn>;\nexport type DatabaseConnection<Conn> = DatabaseConnectionFn<Conn>;\n\n/**\n * Options for wrapping Vitest tests with database transaction isolation.\n */\nexport interface TransactionWrapperOptions<\n TConn,\n Transaction,\n Extended extends Record<string, unknown> = {},\n> {\n /** Function that creates or returns a database connection */\n connection: DatabaseConnection<TConn>;\n /** Optional setup function to run within the transaction before each test */\n setup?: (trx: Transaction) => Promise<void>;\n /** Transaction isolation level (defaults to REPEATABLE_READ) */\n isolationLevel?: IsolationLevel;\n /** Additional fixtures that depend on the transaction */\n fixtures?: FixtureCreators<Transaction, Extended>;\n}\n\n/**\n * Type for fixture creator functions that depend on the transaction.\n * Each function receives the transaction and returns the fixture value.\n */\nexport type FixtureCreators<\n Transaction,\n Extended extends Record<string, unknown>,\n> = {\n [K in keyof Extended]: (\n trx: Transaction,\n ) => Extended[K] | Promise<Extended[K]>;\n};\n\n/**\n * The test API returned by extendWithFixtures.\n * Provides access to both the transaction (trx) and all extended fixtures.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional fixtures provided\n * @template BaseTest - The base wrapped test type\n */\nexport type TestWithExtendedFixtures<\n Transaction,\n Extended extends Record<string, unknown>,\n BaseTest extends ReturnType<TestAPI['extend']> = ReturnType<\n TestAPI['extend']\n >,\n> = BaseTest & {\n <C extends object>(\n name: string,\n fn: (\n context: DatabaseFixtures<Transaction> & Extended & C,\n ) => Promise<void>,\n ): void;\n <C extends object>(\n name: string,\n options: object,\n fn: (\n context: DatabaseFixtures<Transaction> & Extended & C,\n ) => Promise<void>,\n ): void;\n};\n\n/**\n * Extends a wrapped test API with additional fixtures that depend on the transaction.\n * This allows composing test context with factories, repositories, or other helpers.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional context to provide\n * @param wrappedTest - The base wrapped test from wrapVitestWithTransaction\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 { wrapVitestKyselyTransaction, extendWithFixtures } from '@geekmidas/testkit/kysely';\n *\n * // Create base wrapped test\n * const baseTest = wrapVitestKyselyTransaction(test, {\n * connection: db,\n * setup: createTestTables,\n * });\n *\n * // Extend with fixtures\n * const it = extendWithFixtures(baseTest, {\n * factory: (trx) => new KyselyFactory(builders, seeds, trx),\n * userRepo: (trx) => new UserRepository(trx),\n * });\n *\n * // Use in tests - trx and all fixtures are available\n * it('should create user with factory', async ({ trx, factory, userRepo }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user).toBeDefined();\n * });\n * ```\n */\nexport function extendWithFixtures<\n Transaction,\n Extended extends Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends ReturnType<TestAPI['extend']> = any,\n>(\n wrappedTest: T,\n fixtures: FixtureCreators<Transaction, Extended>,\n): TestWithExtendedFixtures<Transaction, Extended, T> {\n // Build fixture definitions for Vitest's extend API\n const fixtureDefinitions: Record<string, any> = {};\n\n for (const [key, creator] of Object.entries(fixtures)) {\n fixtureDefinitions[key] = async (\n { trx }: { trx: Transaction },\n use: (value: unknown) => Promise<void>,\n ) => {\n const value = await (creator as (trx: Transaction) => unknown)(trx);\n await use(value);\n };\n }\n\n return (wrappedTest as any).extend(fixtureDefinitions);\n}\n"],"mappings":";;;;;;;;AAgDA,IAAY,4DAAL;;;;;AAKL;;;;;AAKA;;;;;AAKA;;;;;AAKA;;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BD,IAAsB,oCAAtB,MAA4E;;;;;;CAsB1E,YAA6BA,KAAc;EAAd;CAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B7C,0BACEC,SACA;EACA,MAAM,EACJ,YACA,OACA,iBAAiB,eAAe,iBAChC,UACD,GAAG;EAGJ,MAAMC,qBAA8C,CAAE;AACtD,MAAI,SACF,MAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,SAAS,CACnD,oBAAmB,OAAO,OACxB,EAAE,KAA2B,EAC7BC,QACG;GACH,MAAM,QAAQ,MAAM,AAAC,QAA0C,IAAI;AACnE,SAAM,IAAI,MAAM;EACjB;EASL,MAAM,WAAW,KAAK,IAAI;AAE1B,SAAO,SAA2B;GAEhC,KAAK,OAAO,EAAE,EAAEC,QAA+C;IAE7D,MAAM,qBAAqB,MAAM;KAC/B,cAAc;AACZ,YAAM,gBAAgB;AACtB,WAAK,OAAO;KACb;IACF;IAED,IAAIC;IACJ,MAAM,OAAO,MAAM,YAAY;AAC/B,QAAI;AACF,WAAM,KAAK,SAAS,MAAM,gBAAgB,OAAO,gBAAgB;AAC/D,UAAI;AAEF,aAAM,QAAQ,YAAY;AAC1B,aAAM,IAAI,YAAY;MACvB,SAAQ,OAAO;AAEd,mBAAY;MACb;AAGD,YAAM,IAAI;KACX,EAAC;IACH,SAAQ,OAAO;AAEd,WAAM,iBAAiB,cACrB,OAAM;AAIR,SAAI,UACF,OAAM;IAET,UAAS;AACR,WAAM,KAAK,QAAQ,KAAK;IACzB;GACF;GACD,GAAG;EACJ,EAAC;CACH;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGD,SAAgB,mBAMdC,aACAC,UACoD;CAEpD,MAAMC,qBAA0C,CAAE;AAElD,MAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,SAAS,CACnD,oBAAmB,OAAO,OACxB,EAAE,KAA2B,EAC7BL,QACG;EACH,MAAM,QAAQ,MAAM,AAAC,QAA0C,IAAI;AACnE,QAAM,IAAI,MAAM;CACjB;AAGH,QAAO,AAAC,YAAoB,OAAO,mBAAmB;AACvD"}
|
package/dist/{VitestTransactionIsolator-DfA80g2M.d.cts → VitestTransactionIsolator-CwQaxZLP.d.cts}
RENAMED
|
@@ -112,30 +112,44 @@ declare abstract class VitestPostgresTransactionIsolator<TConn, Transaction> {
|
|
|
112
112
|
* Creates a wrapped version of Vitest's test API that provides transaction isolation.
|
|
113
113
|
* Each test will run within a database transaction that is automatically rolled back.
|
|
114
114
|
*
|
|
115
|
-
* @param
|
|
116
|
-
* @param setup - Optional setup function to run within the transaction before each test
|
|
117
|
-
* @param level - The transaction isolation level (defaults to REPEATABLE_READ)
|
|
115
|
+
* @param options - Configuration options for transaction wrapping
|
|
118
116
|
* @returns A wrapped test API with transaction support
|
|
119
117
|
*
|
|
120
118
|
* @example
|
|
121
119
|
* ```typescript
|
|
122
|
-
* const isolatedTest = isolator.wrapVitestWithTransaction(
|
|
123
|
-
*
|
|
124
|
-
*
|
|
120
|
+
* const isolatedTest = isolator.wrapVitestWithTransaction({
|
|
121
|
+
* connection: db,
|
|
122
|
+
* setup: async (trx) => {
|
|
123
|
+
* await trx.insert('settings', { key: 'test', value: 'true' });
|
|
124
|
+
* },
|
|
125
|
+
* fixtures: {
|
|
126
|
+
* factory: (trx) => new Factory(trx),
|
|
127
|
+
* },
|
|
125
128
|
* });
|
|
126
129
|
*
|
|
127
|
-
* isolatedTest('test with transaction', async ({ trx }) => {
|
|
128
|
-
* const user = await
|
|
130
|
+
* isolatedTest('test with transaction', async ({ trx, factory }) => {
|
|
131
|
+
* const user = await factory.insert('user', { name: 'Test' });
|
|
129
132
|
* expect(user).toBeDefined();
|
|
130
133
|
* });
|
|
131
134
|
* ```
|
|
132
135
|
*/
|
|
133
|
-
wrapVitestWithTransaction
|
|
134
|
-
trx: Transaction;
|
|
135
|
-
}>;
|
|
136
|
+
wrapVitestWithTransaction<Extended extends Record<string, unknown> = {}>(options: TransactionWrapperOptions<TConn, Transaction, Extended>): TestAPI<DatabaseFixtures<Transaction, object> & Extended>;
|
|
136
137
|
}
|
|
137
138
|
type DatabaseConnectionFn<Conn> = () => Conn | Promise<Conn>;
|
|
138
139
|
type DatabaseConnection<Conn> = DatabaseConnectionFn<Conn>;
|
|
140
|
+
/**
|
|
141
|
+
* Options for wrapping Vitest tests with database transaction isolation.
|
|
142
|
+
*/
|
|
143
|
+
interface TransactionWrapperOptions<TConn, Transaction, Extended extends Record<string, unknown> = {}> {
|
|
144
|
+
/** Function that creates or returns a database connection */
|
|
145
|
+
connection: DatabaseConnection<TConn>;
|
|
146
|
+
/** Optional setup function to run within the transaction before each test */
|
|
147
|
+
setup?: (trx: Transaction) => Promise<void>;
|
|
148
|
+
/** Transaction isolation level (defaults to REPEATABLE_READ) */
|
|
149
|
+
isolationLevel?: IsolationLevel;
|
|
150
|
+
/** Additional fixtures that depend on the transaction */
|
|
151
|
+
fixtures?: FixtureCreators<Transaction, Extended>;
|
|
152
|
+
}
|
|
139
153
|
/**
|
|
140
154
|
* Type for fixture creator functions that depend on the transaction.
|
|
141
155
|
* Each function receives the transaction and returns the fixture value.
|
|
@@ -168,7 +182,10 @@ type TestWithExtendedFixtures<Transaction, Extended extends Record<string, unkno
|
|
|
168
182
|
* import { wrapVitestKyselyTransaction, extendWithFixtures } from '@geekmidas/testkit/kysely';
|
|
169
183
|
*
|
|
170
184
|
* // Create base wrapped test
|
|
171
|
-
* const baseTest = wrapVitestKyselyTransaction(test,
|
|
185
|
+
* const baseTest = wrapVitestKyselyTransaction(test, {
|
|
186
|
+
* connection: db,
|
|
187
|
+
* setup: createTestTables,
|
|
188
|
+
* });
|
|
172
189
|
*
|
|
173
190
|
* // Extend with fixtures
|
|
174
191
|
* const it = extendWithFixtures(baseTest, {
|
|
@@ -185,5 +202,5 @@ type TestWithExtendedFixtures<Transaction, Extended extends Record<string, unkno
|
|
|
185
202
|
*/
|
|
186
203
|
declare function extendWithFixtures<Transaction, Extended extends Record<string, unknown>, T extends ReturnType<TestAPI['extend']> = any>(wrappedTest: T, fixtures: FixtureCreators<Transaction, Extended>): TestWithExtendedFixtures<Transaction, Extended, T>;
|
|
187
204
|
//#endregion
|
|
188
|
-
export { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, VitestPostgresTransactionIsolator, extendWithFixtures };
|
|
189
|
-
//# sourceMappingURL=VitestTransactionIsolator-
|
|
205
|
+
export { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures };
|
|
206
|
+
//# sourceMappingURL=VitestTransactionIsolator-CwQaxZLP.d.cts.map
|
package/dist/{VitestTransactionIsolator-BIaMs4c2.mjs → VitestTransactionIsolator-DQ7tLqgV.mjs}
RENAMED
|
@@ -68,51 +68,64 @@ var VitestPostgresTransactionIsolator = class {
|
|
|
68
68
|
* Creates a wrapped version of Vitest's test API that provides transaction isolation.
|
|
69
69
|
* Each test will run within a database transaction that is automatically rolled back.
|
|
70
70
|
*
|
|
71
|
-
* @param
|
|
72
|
-
* @param setup - Optional setup function to run within the transaction before each test
|
|
73
|
-
* @param level - The transaction isolation level (defaults to REPEATABLE_READ)
|
|
71
|
+
* @param options - Configuration options for transaction wrapping
|
|
74
72
|
* @returns A wrapped test API with transaction support
|
|
75
73
|
*
|
|
76
74
|
* @example
|
|
77
75
|
* ```typescript
|
|
78
|
-
* const isolatedTest = isolator.wrapVitestWithTransaction(
|
|
79
|
-
*
|
|
80
|
-
*
|
|
76
|
+
* const isolatedTest = isolator.wrapVitestWithTransaction({
|
|
77
|
+
* connection: db,
|
|
78
|
+
* setup: async (trx) => {
|
|
79
|
+
* await trx.insert('settings', { key: 'test', value: 'true' });
|
|
80
|
+
* },
|
|
81
|
+
* fixtures: {
|
|
82
|
+
* factory: (trx) => new Factory(trx),
|
|
83
|
+
* },
|
|
81
84
|
* });
|
|
82
85
|
*
|
|
83
|
-
* isolatedTest('test with transaction', async ({ trx }) => {
|
|
84
|
-
* const user = await
|
|
86
|
+
* isolatedTest('test with transaction', async ({ trx, factory }) => {
|
|
87
|
+
* const user = await factory.insert('user', { name: 'Test' });
|
|
85
88
|
* expect(user).toBeDefined();
|
|
86
89
|
* });
|
|
87
90
|
* ```
|
|
88
91
|
*/
|
|
89
|
-
wrapVitestWithTransaction(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
await use(transaction);
|
|
104
|
-
} catch (error) {
|
|
105
|
-
testError = error;
|
|
92
|
+
wrapVitestWithTransaction(options) {
|
|
93
|
+
const { connection, setup, isolationLevel = IsolationLevel.REPEATABLE_READ, fixtures } = options;
|
|
94
|
+
const additionalFixtures = {};
|
|
95
|
+
if (fixtures) for (const [key, creator] of Object.entries(fixtures)) additionalFixtures[key] = async ({ trx }, use) => {
|
|
96
|
+
const value = await creator(trx);
|
|
97
|
+
await use(value);
|
|
98
|
+
};
|
|
99
|
+
const extendFn = this.api.extend;
|
|
100
|
+
return extendFn({
|
|
101
|
+
trx: async ({}, use) => {
|
|
102
|
+
class TestRollback extends Error {
|
|
103
|
+
constructor() {
|
|
104
|
+
super("Test rollback");
|
|
105
|
+
this.name = "TestRollback";
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
}
|
|
108
|
+
let testError;
|
|
109
|
+
const conn = await connection();
|
|
110
|
+
try {
|
|
111
|
+
await this.transact(conn, isolationLevel, async (transaction) => {
|
|
112
|
+
try {
|
|
113
|
+
await setup?.(transaction);
|
|
114
|
+
await use(transaction);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
testError = error;
|
|
117
|
+
}
|
|
118
|
+
throw new TestRollback();
|
|
119
|
+
});
|
|
120
|
+
} catch (error) {
|
|
121
|
+
if (!(error instanceof TestRollback)) throw error;
|
|
122
|
+
if (testError) throw testError;
|
|
123
|
+
} finally {
|
|
124
|
+
await this.destroy(conn);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
...additionalFixtures
|
|
128
|
+
});
|
|
116
129
|
}
|
|
117
130
|
};
|
|
118
131
|
/**
|
|
@@ -130,7 +143,10 @@ var VitestPostgresTransactionIsolator = class {
|
|
|
130
143
|
* import { wrapVitestKyselyTransaction, extendWithFixtures } from '@geekmidas/testkit/kysely';
|
|
131
144
|
*
|
|
132
145
|
* // Create base wrapped test
|
|
133
|
-
* const baseTest = wrapVitestKyselyTransaction(test,
|
|
146
|
+
* const baseTest = wrapVitestKyselyTransaction(test, {
|
|
147
|
+
* connection: db,
|
|
148
|
+
* setup: createTestTables,
|
|
149
|
+
* });
|
|
134
150
|
*
|
|
135
151
|
* // Extend with fixtures
|
|
136
152
|
* const it = extendWithFixtures(baseTest, {
|
|
@@ -156,4 +172,4 @@ function extendWithFixtures(wrappedTest, fixtures) {
|
|
|
156
172
|
|
|
157
173
|
//#endregion
|
|
158
174
|
export { IsolationLevel, VitestPostgresTransactionIsolator, extendWithFixtures };
|
|
159
|
-
//# sourceMappingURL=VitestTransactionIsolator-
|
|
175
|
+
//# sourceMappingURL=VitestTransactionIsolator-DQ7tLqgV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VitestTransactionIsolator-DQ7tLqgV.mjs","names":["api: TestAPI","options: TransactionWrapperOptions<TConn, Transaction, Extended>","additionalFixtures: Record<string, unknown>","use: (value: unknown) => Promise<void>","use: (value: Transaction) => Promise<void>","testError: Error | undefined","wrappedTest: T","fixtures: FixtureCreators<Transaction, Extended>","fixtureDefinitions: Record<string, any>"],"sources":["../src/VitestTransactionIsolator.ts"],"sourcesContent":["import type { TestAPI } from 'vitest';\n\n/**\n * Type definition for test fixtures that provide transaction access.\n * Used with Vitest's test.extend() API to inject transactions into tests.\n *\n * @template Transaction - The transaction type specific to the database driver\n * @template Extended - Additional context properties provided by the extend function\n */\nexport interface DatabaseFixtures<Transaction, Extended = object> {\n /**\n * The database transaction available to the test.\n * All database operations should use this transaction to ensure proper rollback.\n */\n trx: Transaction;\n}\n\n/**\n * Combined fixtures type that merges the base transaction fixture with extended context.\n */\nexport type ExtendedDatabaseFixtures<\n Transaction,\n Extended = object,\n> = DatabaseFixtures<Transaction> & Extended;\n\n/**\n * Function type for extending test context with additional properties.\n * Receives the transaction and returns additional context to be merged with { trx }.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional context to provide\n *\n * @example\n * ```typescript\n * const extendContext: ExtendContextFn<Transaction<DB>, { factory: KyselyFactory }> =\n * (trx) => ({ factory: new KyselyFactory(builders, seeds, trx) });\n * ```\n */\nexport type ExtendContextFn<Transaction, Extended> = (\n trx: Transaction,\n) => Extended | Promise<Extended>;\n\n/**\n * PostgreSQL transaction isolation levels.\n * Controls the visibility of concurrent transactions.\n *\n * @see https://www.postgresql.org/docs/current/transaction-iso.html\n */\nexport enum IsolationLevel {\n /**\n * Lowest isolation level. Allows dirty reads.\n * Not recommended for testing.\n */\n READ_UNCOMMITTED = 'READ UNCOMMITTED',\n /**\n * Default PostgreSQL isolation level.\n * Prevents dirty reads but allows non-repeatable reads.\n */\n READ_COMMITTED = 'READ COMMITTED',\n /**\n * Prevents dirty reads and non-repeatable reads.\n * Recommended for most test scenarios.\n */\n REPEATABLE_READ = 'REPEATABLE READ',\n /**\n * Highest isolation level. Prevents all phenomena.\n * May cause performance overhead in tests.\n */\n SERIALIZABLE = 'SERIALIZABLE',\n}\n\n/**\n * Abstract base class for implementing database transaction isolation in Vitest tests.\n * Provides automatic transaction rollback after each test to maintain test isolation.\n * Subclasses must implement the transact() method for their specific database driver.\n *\n * @template TConn - The database connection type\n * @template Transaction - The transaction type\n *\n * @example\n * ```typescript\n * // Implement for your database driver\n * class MyDatabaseIsolator extends VitestPostgresTransactionIsolator<MyDB, MyTx> {\n * async transact(conn: MyDB, level: IsolationLevel, fn: (tx: MyTx) => Promise<void>) {\n * await conn.transaction(level, fn);\n * }\n * }\n *\n * // Use in tests\n * const isolator = new MyDatabaseIsolator(test);\n * const isolatedTest = isolator.wrapVitestWithTransaction(db);\n *\n * isolatedTest('should create user', async ({ trx }) => {\n * await trx.insert('users', { name: 'Test' });\n * // Data is automatically rolled back after test\n * });\n * ```\n */\nexport abstract class VitestPostgresTransactionIsolator<TConn, Transaction> {\n /**\n * Abstract method to create a transaction with the specified isolation level.\n * Must be implemented by subclasses for specific database drivers.\n *\n * @param conn - The database connection\n * @param isolationLevel - The transaction isolation level\n * @param fn - The function to execute within the transaction\n * @returns Promise that resolves when the transaction completes\n */\n abstract transact(\n conn: TConn,\n isolationLevel: IsolationLevel,\n fn: (trx: Transaction) => Promise<void>,\n ): Promise<void>;\n\n abstract destroy(conn: TConn): Promise<void>;\n /**\n * Creates a new VitestPostgresTransactionIsolator instance.\n *\n * @param api - The Vitest test API (usually the `test` export from vitest)\n */\n constructor(private readonly api: TestAPI) {}\n\n /**\n * Creates a wrapped version of Vitest's test API that provides transaction isolation.\n * Each test will run within a database transaction that is automatically rolled back.\n *\n * @param options - Configuration options for transaction wrapping\n * @returns A wrapped test API with transaction support\n *\n * @example\n * ```typescript\n * const isolatedTest = isolator.wrapVitestWithTransaction({\n * connection: db,\n * setup: async (trx) => {\n * await trx.insert('settings', { key: 'test', value: 'true' });\n * },\n * fixtures: {\n * factory: (trx) => new Factory(trx),\n * },\n * });\n *\n * isolatedTest('test with transaction', async ({ trx, factory }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user).toBeDefined();\n * });\n * ```\n */\n wrapVitestWithTransaction<Extended extends Record<string, unknown> = {}>(\n options: TransactionWrapperOptions<TConn, Transaction, Extended>,\n ) {\n const {\n connection,\n setup,\n isolationLevel = IsolationLevel.REPEATABLE_READ,\n fixtures,\n } = options;\n\n // Build fixture definitions for additional fixtures that depend on trx\n const additionalFixtures: Record<string, unknown> = {};\n if (fixtures) {\n for (const [key, creator] of Object.entries(fixtures)) {\n additionalFixtures[key] = async (\n { trx }: { trx: Transaction },\n use: (value: unknown) => Promise<void>,\n ) => {\n const value = await (creator as (trx: Transaction) => unknown)(trx);\n await use(value);\n };\n }\n }\n\n type CombinedFixtures = DatabaseFixtures<Transaction> & Extended;\n\n // Cast to bypass Vitest's strict fixture typing which can't infer\n // dynamically built fixture objects\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const extendFn = this.api.extend as <T>(fixtures: any) => TestAPI<T>;\n\n return extendFn<CombinedFixtures>({\n // This fixture automatically provides a transaction to each test\n trx: async ({}, use: (value: Transaction) => Promise<void>) => {\n // Create a custom error class for rollback\n class TestRollback extends Error {\n constructor() {\n super('Test rollback');\n this.name = 'TestRollback';\n }\n }\n\n let testError: Error | undefined;\n const conn = await connection();\n try {\n await this.transact(conn, isolationLevel, async (transaction) => {\n try {\n // Provide the transaction to the test\n await setup?.(transaction);\n await use(transaction);\n } catch (error) {\n // Capture any test errors\n testError = error as Error;\n }\n\n // Always throw to trigger rollback\n throw new TestRollback();\n });\n } catch (error) {\n // Only rethrow if it's not our rollback error\n if (!(error instanceof TestRollback)) {\n throw error;\n }\n\n // If the test had an error, throw it now\n if (testError) {\n throw testError;\n }\n } finally {\n await this.destroy(conn);\n }\n },\n ...additionalFixtures,\n });\n }\n}\n\nexport type DatabaseConnectionFn<Conn> = () => Conn | Promise<Conn>;\nexport type DatabaseConnection<Conn> = DatabaseConnectionFn<Conn>;\n\n/**\n * Options for wrapping Vitest tests with database transaction isolation.\n */\nexport interface TransactionWrapperOptions<\n TConn,\n Transaction,\n Extended extends Record<string, unknown> = {},\n> {\n /** Function that creates or returns a database connection */\n connection: DatabaseConnection<TConn>;\n /** Optional setup function to run within the transaction before each test */\n setup?: (trx: Transaction) => Promise<void>;\n /** Transaction isolation level (defaults to REPEATABLE_READ) */\n isolationLevel?: IsolationLevel;\n /** Additional fixtures that depend on the transaction */\n fixtures?: FixtureCreators<Transaction, Extended>;\n}\n\n/**\n * Type for fixture creator functions that depend on the transaction.\n * Each function receives the transaction and returns the fixture value.\n */\nexport type FixtureCreators<\n Transaction,\n Extended extends Record<string, unknown>,\n> = {\n [K in keyof Extended]: (\n trx: Transaction,\n ) => Extended[K] | Promise<Extended[K]>;\n};\n\n/**\n * The test API returned by extendWithFixtures.\n * Provides access to both the transaction (trx) and all extended fixtures.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional fixtures provided\n * @template BaseTest - The base wrapped test type\n */\nexport type TestWithExtendedFixtures<\n Transaction,\n Extended extends Record<string, unknown>,\n BaseTest extends ReturnType<TestAPI['extend']> = ReturnType<\n TestAPI['extend']\n >,\n> = BaseTest & {\n <C extends object>(\n name: string,\n fn: (\n context: DatabaseFixtures<Transaction> & Extended & C,\n ) => Promise<void>,\n ): void;\n <C extends object>(\n name: string,\n options: object,\n fn: (\n context: DatabaseFixtures<Transaction> & Extended & C,\n ) => Promise<void>,\n ): void;\n};\n\n/**\n * Extends a wrapped test API with additional fixtures that depend on the transaction.\n * This allows composing test context with factories, repositories, or other helpers.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional context to provide\n * @param wrappedTest - The base wrapped test from wrapVitestWithTransaction\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 { wrapVitestKyselyTransaction, extendWithFixtures } from '@geekmidas/testkit/kysely';\n *\n * // Create base wrapped test\n * const baseTest = wrapVitestKyselyTransaction(test, {\n * connection: db,\n * setup: createTestTables,\n * });\n *\n * // Extend with fixtures\n * const it = extendWithFixtures(baseTest, {\n * factory: (trx) => new KyselyFactory(builders, seeds, trx),\n * userRepo: (trx) => new UserRepository(trx),\n * });\n *\n * // Use in tests - trx and all fixtures are available\n * it('should create user with factory', async ({ trx, factory, userRepo }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user).toBeDefined();\n * });\n * ```\n */\nexport function extendWithFixtures<\n Transaction,\n Extended extends Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends ReturnType<TestAPI['extend']> = any,\n>(\n wrappedTest: T,\n fixtures: FixtureCreators<Transaction, Extended>,\n): TestWithExtendedFixtures<Transaction, Extended, T> {\n // Build fixture definitions for Vitest's extend API\n const fixtureDefinitions: Record<string, any> = {};\n\n for (const [key, creator] of Object.entries(fixtures)) {\n fixtureDefinitions[key] = async (\n { trx }: { trx: Transaction },\n use: (value: unknown) => Promise<void>,\n ) => {\n const value = await (creator as (trx: Transaction) => unknown)(trx);\n await use(value);\n };\n }\n\n return (wrappedTest as any).extend(fixtureDefinitions);\n}\n"],"mappings":";;;;;;;AAgDA,IAAY,4DAAL;;;;;AAKL;;;;;AAKA;;;;;AAKA;;;;;AAKA;;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BD,IAAsB,oCAAtB,MAA4E;;;;;;CAsB1E,YAA6BA,KAAc;EAAd;CAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B7C,0BACEC,SACA;EACA,MAAM,EACJ,YACA,OACA,iBAAiB,eAAe,iBAChC,UACD,GAAG;EAGJ,MAAMC,qBAA8C,CAAE;AACtD,MAAI,SACF,MAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,SAAS,CACnD,oBAAmB,OAAO,OACxB,EAAE,KAA2B,EAC7BC,QACG;GACH,MAAM,QAAQ,MAAM,AAAC,QAA0C,IAAI;AACnE,SAAM,IAAI,MAAM;EACjB;EASL,MAAM,WAAW,KAAK,IAAI;AAE1B,SAAO,SAA2B;GAEhC,KAAK,OAAO,EAAE,EAAEC,QAA+C;IAE7D,MAAM,qBAAqB,MAAM;KAC/B,cAAc;AACZ,YAAM,gBAAgB;AACtB,WAAK,OAAO;KACb;IACF;IAED,IAAIC;IACJ,MAAM,OAAO,MAAM,YAAY;AAC/B,QAAI;AACF,WAAM,KAAK,SAAS,MAAM,gBAAgB,OAAO,gBAAgB;AAC/D,UAAI;AAEF,aAAM,QAAQ,YAAY;AAC1B,aAAM,IAAI,YAAY;MACvB,SAAQ,OAAO;AAEd,mBAAY;MACb;AAGD,YAAM,IAAI;KACX,EAAC;IACH,SAAQ,OAAO;AAEd,WAAM,iBAAiB,cACrB,OAAM;AAIR,SAAI,UACF,OAAM;IAET,UAAS;AACR,WAAM,KAAK,QAAQ,KAAK;IACzB;GACF;GACD,GAAG;EACJ,EAAC;CACH;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGD,SAAgB,mBAMdC,aACAC,UACoD;CAEpD,MAAMC,qBAA0C,CAAE;AAElD,MAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,SAAS,CACnD,oBAAmB,OAAO,OACxB,EAAE,KAA2B,EAC7BL,QACG;EACH,MAAM,QAAQ,MAAM,AAAC,QAA0C,IAAI;AACnE,QAAM,IAAI,MAAM;CACjB;AAGH,QAAO,AAAC,YAAoB,OAAO,mBAAmB;AACvD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_VitestTransactionIsolator = require('./VitestTransactionIsolator-
|
|
1
|
+
const require_VitestTransactionIsolator = require('./VitestTransactionIsolator-CMfJXZP8.cjs');
|
|
2
2
|
|
|
3
3
|
exports.IsolationLevel = require_VitestTransactionIsolator.IsolationLevel;
|
|
4
4
|
exports.VitestPostgresTransactionIsolator = require_VitestTransactionIsolator.VitestPostgresTransactionIsolator;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, VitestPostgresTransactionIsolator, extendWithFixtures } from "./VitestTransactionIsolator-
|
|
2
|
-
export { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, VitestPostgresTransactionIsolator, extendWithFixtures };
|
|
1
|
+
import { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures } from "./VitestTransactionIsolator-CwQaxZLP.cjs";
|
|
2
|
+
export { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, VitestPostgresTransactionIsolator, extendWithFixtures } from "./VitestTransactionIsolator-
|
|
2
|
-
export { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, VitestPostgresTransactionIsolator, extendWithFixtures };
|
|
1
|
+
import { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures } from "./VitestTransactionIsolator-BvR19bYn.mjs";
|
|
2
|
+
export { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IsolationLevel, VitestPostgresTransactionIsolator, extendWithFixtures } from "./VitestTransactionIsolator-
|
|
1
|
+
import { IsolationLevel, VitestPostgresTransactionIsolator, extendWithFixtures } from "./VitestTransactionIsolator-DQ7tLqgV.mjs";
|
|
2
2
|
|
|
3
3
|
export { IsolationLevel, VitestPostgresTransactionIsolator, extendWithFixtures };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/benchmark.ts
|
|
3
|
+
/**
|
|
4
|
+
* Generates an array of test records for benchmark data sets.
|
|
5
|
+
*
|
|
6
|
+
* @param count - Number of records to generate
|
|
7
|
+
* @returns Array of test data objects
|
|
8
|
+
*/
|
|
9
|
+
function generateTestData(count) {
|
|
10
|
+
return Array.from({ length: count }, (_, i) => ({
|
|
11
|
+
id: `id-${i}`,
|
|
12
|
+
name: `Item ${i}`,
|
|
13
|
+
value: Math.random() * 1e3
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Generates unique keys for cache benchmarks to avoid collisions.
|
|
18
|
+
*
|
|
19
|
+
* @param prefix - Key prefix
|
|
20
|
+
* @param count - Number of keys to generate
|
|
21
|
+
* @returns Array of unique cache keys
|
|
22
|
+
*/
|
|
23
|
+
function generateCacheKeys(prefix, count) {
|
|
24
|
+
return Array.from({ length: count }, (_, i) => `${prefix}:${i}`);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Generates IP addresses for rate limit benchmarks.
|
|
28
|
+
*
|
|
29
|
+
* @param count - Number of IPs to generate
|
|
30
|
+
* @param subnet - Subnet prefix (default: '192.168.1')
|
|
31
|
+
* @returns Array of IP addresses
|
|
32
|
+
*/
|
|
33
|
+
function generateIpAddresses(count, subnet = "192.168.1") {
|
|
34
|
+
return Array.from({ length: count }, (_, i) => `${subnet}.${i % 256}`);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a random IP address for rate limit benchmarks.
|
|
38
|
+
*/
|
|
39
|
+
function randomIpAddress() {
|
|
40
|
+
const octet = () => Math.floor(Math.random() * 256);
|
|
41
|
+
return `${octet()}.${octet()}.${octet()}.${octet()}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.generateCacheKeys = generateCacheKeys;
|
|
46
|
+
exports.generateIpAddresses = generateIpAddresses;
|
|
47
|
+
exports.generateTestData = generateTestData;
|
|
48
|
+
exports.randomIpAddress = randomIpAddress;
|
|
49
|
+
//# sourceMappingURL=benchmark.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"benchmark.cjs","names":["count: number","prefix: string","subnet: string"],"sources":["../src/benchmark.ts"],"sourcesContent":["/**\n * Generates an array of test records for benchmark data sets.\n *\n * @param count - Number of records to generate\n * @returns Array of test data objects\n */\nexport function generateTestData(\n count: number,\n): Array<{ id: string; name: string; value: number }> {\n return Array.from({ length: count }, (_, i) => ({\n id: `id-${i}`,\n name: `Item ${i}`,\n value: Math.random() * 1000,\n }));\n}\n\n/**\n * Generates unique keys for cache benchmarks to avoid collisions.\n *\n * @param prefix - Key prefix\n * @param count - Number of keys to generate\n * @returns Array of unique cache keys\n */\nexport function generateCacheKeys(prefix: string, count: number): string[] {\n return Array.from({ length: count }, (_, i) => `${prefix}:${i}`);\n}\n\n/**\n * Generates IP addresses for rate limit benchmarks.\n *\n * @param count - Number of IPs to generate\n * @param subnet - Subnet prefix (default: '192.168.1')\n * @returns Array of IP addresses\n */\nexport function generateIpAddresses(\n count: number,\n subnet: string = '192.168.1',\n): string[] {\n return Array.from({ length: count }, (_, i) => `${subnet}.${i % 256}`);\n}\n\n/**\n * Creates a random IP address for rate limit benchmarks.\n */\nexport function randomIpAddress(): string {\n const octet = () => Math.floor(Math.random() * 256);\n return `${octet()}.${octet()}.${octet()}.${octet()}`;\n}\n"],"mappings":";;;;;;;;AAMA,SAAgB,iBACdA,OACoD;AACpD,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO;EAC9C,KAAK,KAAK,EAAE;EACZ,OAAO,OAAO,EAAE;EAChB,OAAO,KAAK,QAAQ,GAAG;CACxB,GAAE;AACJ;;;;;;;;AASD,SAAgB,kBAAkBC,QAAgBD,OAAyB;AACzE,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO,EAAE,OAAO,GAAG,EAAE,EAAE;AACjE;;;;;;;;AASD,SAAgB,oBACdA,OACAE,SAAiB,aACP;AACV,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO,EAAE,OAAO,GAAG,IAAI,IAAI,EAAE;AACvE;;;;AAKD,SAAgB,kBAA0B;CACxC,MAAM,QAAQ,MAAM,KAAK,MAAM,KAAK,QAAQ,GAAG,IAAI;AACnD,SAAQ,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC;AACpD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/benchmark.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Generates an array of test records for benchmark data sets.
|
|
4
|
+
*
|
|
5
|
+
* @param count - Number of records to generate
|
|
6
|
+
* @returns Array of test data objects
|
|
7
|
+
*/
|
|
8
|
+
declare function generateTestData(count: number): Array<{
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
value: number;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Generates unique keys for cache benchmarks to avoid collisions.
|
|
15
|
+
*
|
|
16
|
+
* @param prefix - Key prefix
|
|
17
|
+
* @param count - Number of keys to generate
|
|
18
|
+
* @returns Array of unique cache keys
|
|
19
|
+
*/
|
|
20
|
+
declare function generateCacheKeys(prefix: string, count: number): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Generates IP addresses for rate limit benchmarks.
|
|
23
|
+
*
|
|
24
|
+
* @param count - Number of IPs to generate
|
|
25
|
+
* @param subnet - Subnet prefix (default: '192.168.1')
|
|
26
|
+
* @returns Array of IP addresses
|
|
27
|
+
*/
|
|
28
|
+
declare function generateIpAddresses(count: number, subnet?: string): string[];
|
|
29
|
+
/**
|
|
30
|
+
* Creates a random IP address for rate limit benchmarks.
|
|
31
|
+
*/
|
|
32
|
+
declare function randomIpAddress(): string;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { generateCacheKeys, generateIpAddresses, generateTestData, randomIpAddress };
|
|
35
|
+
//# sourceMappingURL=benchmark.d.cts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/benchmark.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Generates an array of test records for benchmark data sets.
|
|
4
|
+
*
|
|
5
|
+
* @param count - Number of records to generate
|
|
6
|
+
* @returns Array of test data objects
|
|
7
|
+
*/
|
|
8
|
+
declare function generateTestData(count: number): Array<{
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
value: number;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Generates unique keys for cache benchmarks to avoid collisions.
|
|
15
|
+
*
|
|
16
|
+
* @param prefix - Key prefix
|
|
17
|
+
* @param count - Number of keys to generate
|
|
18
|
+
* @returns Array of unique cache keys
|
|
19
|
+
*/
|
|
20
|
+
declare function generateCacheKeys(prefix: string, count: number): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Generates IP addresses for rate limit benchmarks.
|
|
23
|
+
*
|
|
24
|
+
* @param count - Number of IPs to generate
|
|
25
|
+
* @param subnet - Subnet prefix (default: '192.168.1')
|
|
26
|
+
* @returns Array of IP addresses
|
|
27
|
+
*/
|
|
28
|
+
declare function generateIpAddresses(count: number, subnet?: string): string[];
|
|
29
|
+
/**
|
|
30
|
+
* Creates a random IP address for rate limit benchmarks.
|
|
31
|
+
*/
|
|
32
|
+
declare function randomIpAddress(): string;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { generateCacheKeys, generateIpAddresses, generateTestData, randomIpAddress };
|
|
35
|
+
//# sourceMappingURL=benchmark.d.mts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/benchmark.ts
|
|
2
|
+
/**
|
|
3
|
+
* Generates an array of test records for benchmark data sets.
|
|
4
|
+
*
|
|
5
|
+
* @param count - Number of records to generate
|
|
6
|
+
* @returns Array of test data objects
|
|
7
|
+
*/
|
|
8
|
+
function generateTestData(count) {
|
|
9
|
+
return Array.from({ length: count }, (_, i) => ({
|
|
10
|
+
id: `id-${i}`,
|
|
11
|
+
name: `Item ${i}`,
|
|
12
|
+
value: Math.random() * 1e3
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Generates unique keys for cache benchmarks to avoid collisions.
|
|
17
|
+
*
|
|
18
|
+
* @param prefix - Key prefix
|
|
19
|
+
* @param count - Number of keys to generate
|
|
20
|
+
* @returns Array of unique cache keys
|
|
21
|
+
*/
|
|
22
|
+
function generateCacheKeys(prefix, count) {
|
|
23
|
+
return Array.from({ length: count }, (_, i) => `${prefix}:${i}`);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generates IP addresses for rate limit benchmarks.
|
|
27
|
+
*
|
|
28
|
+
* @param count - Number of IPs to generate
|
|
29
|
+
* @param subnet - Subnet prefix (default: '192.168.1')
|
|
30
|
+
* @returns Array of IP addresses
|
|
31
|
+
*/
|
|
32
|
+
function generateIpAddresses(count, subnet = "192.168.1") {
|
|
33
|
+
return Array.from({ length: count }, (_, i) => `${subnet}.${i % 256}`);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a random IP address for rate limit benchmarks.
|
|
37
|
+
*/
|
|
38
|
+
function randomIpAddress() {
|
|
39
|
+
const octet = () => Math.floor(Math.random() * 256);
|
|
40
|
+
return `${octet()}.${octet()}.${octet()}.${octet()}`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { generateCacheKeys, generateIpAddresses, generateTestData, randomIpAddress };
|
|
45
|
+
//# sourceMappingURL=benchmark.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"benchmark.mjs","names":["count: number","prefix: string","subnet: string"],"sources":["../src/benchmark.ts"],"sourcesContent":["/**\n * Generates an array of test records for benchmark data sets.\n *\n * @param count - Number of records to generate\n * @returns Array of test data objects\n */\nexport function generateTestData(\n count: number,\n): Array<{ id: string; name: string; value: number }> {\n return Array.from({ length: count }, (_, i) => ({\n id: `id-${i}`,\n name: `Item ${i}`,\n value: Math.random() * 1000,\n }));\n}\n\n/**\n * Generates unique keys for cache benchmarks to avoid collisions.\n *\n * @param prefix - Key prefix\n * @param count - Number of keys to generate\n * @returns Array of unique cache keys\n */\nexport function generateCacheKeys(prefix: string, count: number): string[] {\n return Array.from({ length: count }, (_, i) => `${prefix}:${i}`);\n}\n\n/**\n * Generates IP addresses for rate limit benchmarks.\n *\n * @param count - Number of IPs to generate\n * @param subnet - Subnet prefix (default: '192.168.1')\n * @returns Array of IP addresses\n */\nexport function generateIpAddresses(\n count: number,\n subnet: string = '192.168.1',\n): string[] {\n return Array.from({ length: count }, (_, i) => `${subnet}.${i % 256}`);\n}\n\n/**\n * Creates a random IP address for rate limit benchmarks.\n */\nexport function randomIpAddress(): string {\n const octet = () => Math.floor(Math.random() * 256);\n return `${octet()}.${octet()}.${octet()}.${octet()}`;\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,iBACdA,OACoD;AACpD,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO;EAC9C,KAAK,KAAK,EAAE;EACZ,OAAO,OAAO,EAAE;EAChB,OAAO,KAAK,QAAQ,GAAG;CACxB,GAAE;AACJ;;;;;;;;AASD,SAAgB,kBAAkBC,QAAgBD,OAAyB;AACzE,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO,EAAE,OAAO,GAAG,EAAE,EAAE;AACjE;;;;;;;;AASD,SAAgB,oBACdA,OACAE,SAAiB,aACP;AACV,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO,EAAE,OAAO,GAAG,IAAI,IAAI,EAAE;AACvE;;;;AAKD,SAAgB,kBAA0B;CACxC,MAAM,QAAQ,MAAM,KAAK,MAAM,KAAK,QAAQ,GAAG,IAAI;AACnD,SAAQ,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC;AACpD"}
|
package/dist/better-auth.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as better_auth_adapters0 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_adapters0.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_adapters0 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_adapters0.AdapterFactory & {
|
|
11
11
|
clear: () => void;
|
|
12
12
|
getAllData: () => Record<string, any[]>;
|
|
13
13
|
getStore: () => Map<any, any>;
|
|
@@ -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 {
|
|
@@ -9,4 +9,4 @@ interface DirectoryFixtures {
|
|
|
9
9
|
}
|
|
10
10
|
//#endregion
|
|
11
11
|
export { DirectoryFixtures, itWithDir };
|
|
12
|
-
//# sourceMappingURL=directory-
|
|
12
|
+
//# sourceMappingURL=directory-BXavAeJZ.d.mts.map
|