@geekmidas/testkit 10.0.0-alpha.4 → 10.0.0-alpha.40
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 +17 -8
- package/dist/better-auth.cjs.map +1 -1
- package/dist/better-auth.d.cts +13142 -5
- package/dist/better-auth.d.cts.map +1 -1
- package/dist/better-auth.d.mts +13142 -5
- package/dist/better-auth.d.mts.map +1 -1
- package/dist/better-auth.mjs +15 -6
- 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 +276 -8
- package/dist/faker.cjs.map +1 -0
- package/dist/faker.d.cts +145 -2
- package/dist/faker.d.cts.map +1 -0
- package/dist/faker.d.mts +145 -2
- package/dist/faker.d.mts.map +1 -0
- package/dist/faker.mjs +269 -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 +51 -8
- package/dist/Factory-AWn1IulI.d.cts +0 -147
- package/dist/Factory-AWn1IulI.d.cts.map +0 -1
- package/dist/Factory-BFVnMMCC.mjs +0 -51
- package/dist/Factory-BFVnMMCC.mjs.map +0 -1
- package/dist/Factory-BhjUOBWN.cjs +0 -57
- package/dist/Factory-BhjUOBWN.cjs.map +0 -1
- package/dist/Factory-C15SSK8_.d.mts +0 -147
- package/dist/Factory-C15SSK8_.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-C9Snz24z.d.mts +0 -228
- package/dist/KyselyFactory-C9Snz24z.d.mts.map +0 -1
- package/dist/KyselyFactory-CxUJCi--.d.cts +0 -228
- package/dist/KyselyFactory-CxUJCi--.d.cts.map +0 -1
- package/dist/KyselyFactory-DMswpwji.mjs +0 -241
- package/dist/KyselyFactory-DMswpwji.mjs.map +0 -1
- package/dist/ObjectionFactory-BeFBYcan.cjs +0 -272
- package/dist/ObjectionFactory-BeFBYcan.cjs.map +0 -1
- package/dist/ObjectionFactory-CYvaa0kU.d.cts +0 -241
- package/dist/ObjectionFactory-CYvaa0kU.d.cts.map +0 -1
- package/dist/ObjectionFactory-Cf2WI4o_.d.mts +0 -241
- package/dist/ObjectionFactory-Cf2WI4o_.d.mts.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-DiQ_DkaF.d.mts +0 -13
- package/dist/directory-DiQ_DkaF.d.mts.map +0 -1
- package/dist/directory-zIEh5ZPl.d.cts +0 -13
- package/dist/directory-zIEh5ZPl.d.cts.map +0 -1
- package/dist/faker-B14IEMIN.cjs +0 -304
- package/dist/faker-B14IEMIN.cjs.map +0 -1
- package/dist/faker-B6bmbGCM.d.mts +0 -166
- package/dist/faker-B6bmbGCM.d.mts.map +0 -1
- package/dist/faker-BGKYFoCT.mjs +0 -262
- package/dist/faker-BGKYFoCT.mjs.map +0 -1
- package/dist/faker-DvxiCtxc.d.cts +0 -166
- package/dist/faker-DvxiCtxc.d.cts.map +0 -1
|
@@ -1,3 +1,176 @@
|
|
|
1
|
-
import
|
|
1
|
+
import pg from "pg";
|
|
2
|
+
//#region src/PostgresMigrator.ts
|
|
3
|
+
const { Client } = pg;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a PostgreSQL client connected to the 'postgres' database.
|
|
6
|
+
* Extracts connection details from the provided URI.
|
|
7
|
+
*
|
|
8
|
+
* @param uri - PostgreSQL connection URI
|
|
9
|
+
* @returns Object containing the target database name and client instance
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const { database, db } = await setupClient('postgresql://user:pass@localhost:5432/mydb');
|
|
14
|
+
* // database = 'mydb'
|
|
15
|
+
* // db = Client instance connected to 'postgres' database
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
async function setupClient(uri) {
|
|
19
|
+
const url = new URL(uri);
|
|
20
|
+
const db = new Client({
|
|
21
|
+
user: url.username,
|
|
22
|
+
password: url.password,
|
|
23
|
+
host: url.hostname,
|
|
24
|
+
port: parseInt(url.port, 10),
|
|
25
|
+
database: "postgres"
|
|
26
|
+
});
|
|
27
|
+
let database = url.pathname.slice(1);
|
|
28
|
+
if (database.includes("?")) database = database.substring(0, database.indexOf("?"));
|
|
29
|
+
return {
|
|
30
|
+
database,
|
|
31
|
+
db
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Default logger instance for migration operations.
|
|
36
|
+
*/
|
|
37
|
+
const logger = console;
|
|
38
|
+
/**
|
|
39
|
+
* Abstract base class for PostgreSQL database migration utilities.
|
|
40
|
+
* Provides database creation, migration, and cleanup functionality for testing.
|
|
41
|
+
* Subclasses must implement the migrate() method to define migration logic.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* class MyMigrator extends PostgresMigrator {
|
|
46
|
+
* async migrate(): Promise<void> {
|
|
47
|
+
* // Run your migrations here
|
|
48
|
+
* await this.runMigrations();
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* // Use in tests
|
|
53
|
+
* const migrator = new MyMigrator('postgresql://localhost:5432/test_db');
|
|
54
|
+
* const cleanup = await migrator.start();
|
|
55
|
+
*
|
|
56
|
+
* // With afterCreate hook (e.g. run init script to create per-app users)
|
|
57
|
+
* import { runInitScript } from '@geekmidas/testkit/postgres';
|
|
58
|
+
*
|
|
59
|
+
* const migrator = new MyMigrator(
|
|
60
|
+
* 'postgresql://localhost:5432/test_db',
|
|
61
|
+
* async (uri) => {
|
|
62
|
+
* await runInitScript('docker/postgres/init.sh', uri, env);
|
|
63
|
+
* },
|
|
64
|
+
* );
|
|
65
|
+
* const cleanup = await migrator.start();
|
|
66
|
+
*
|
|
67
|
+
* // Run tests...
|
|
68
|
+
*
|
|
69
|
+
* // Clean up
|
|
70
|
+
* await cleanup();
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
var PostgresMigrator = class PostgresMigrator {
|
|
74
|
+
uri;
|
|
75
|
+
afterCreate;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a new PostgresMigrator instance.
|
|
78
|
+
*
|
|
79
|
+
* @param uri - PostgreSQL connection URI
|
|
80
|
+
* @param afterCreate - Optional hook called after database creation but before migrations
|
|
81
|
+
*/
|
|
82
|
+
constructor(uri, afterCreate) {
|
|
83
|
+
this.uri = uri;
|
|
84
|
+
this.afterCreate = afterCreate;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Creates a PostgreSQL database if it doesn't already exist.
|
|
88
|
+
* Connects to the 'postgres' database to check and create the target database.
|
|
89
|
+
*
|
|
90
|
+
* @param uri - PostgreSQL connection URI
|
|
91
|
+
* @returns Object indicating whether the database already existed
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
static async create(uri) {
|
|
95
|
+
const { database, db } = await setupClient(uri);
|
|
96
|
+
try {
|
|
97
|
+
await db.connect();
|
|
98
|
+
const result = await db.query(`SELECT * FROM pg_catalog.pg_database WHERE datname = '${database}'`);
|
|
99
|
+
if (result.rowCount === 0) try {
|
|
100
|
+
await db.query(`CREATE DATABASE "${database}"`);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
if (error?.code === "42P04" || error?.code === "23505" && error?.constraint === "pg_database_datname_index") return { alreadyExisted: true };
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
return { alreadyExisted: result.rowCount ? result.rowCount > 0 : false };
|
|
106
|
+
} finally {
|
|
107
|
+
await db.end();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Drops a PostgreSQL database.
|
|
112
|
+
* Used for cleanup after tests are complete.
|
|
113
|
+
*
|
|
114
|
+
* @param uri - PostgreSQL connection URI
|
|
115
|
+
* @throws Error if database cannot be dropped
|
|
116
|
+
* @private
|
|
117
|
+
*/
|
|
118
|
+
static async drop(uri) {
|
|
119
|
+
const { database, db } = await setupClient(uri);
|
|
120
|
+
try {
|
|
121
|
+
await db.connect();
|
|
122
|
+
await db.query(`DROP DATABASE "${database}"`);
|
|
123
|
+
} finally {
|
|
124
|
+
await db.end();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Starts the migration process by creating the database and running migrations.
|
|
129
|
+
* Returns a cleanup function that drops the database — if this call created
|
|
130
|
+
* it.
|
|
131
|
+
*
|
|
132
|
+
* A database that was already there belongs to whoever made it, and the
|
|
133
|
+
* cleanup leaves it alone. `gkm test` provisions the test database before
|
|
134
|
+
* the suite starts, with an owner role that may migrate it but not drop it:
|
|
135
|
+
* dropping it was never the suite's to do, and failed there as a permission
|
|
136
|
+
* error on the way out of an otherwise green run.
|
|
137
|
+
*
|
|
138
|
+
* @returns Async cleanup function that drops the database if it created it
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const migrator = new MyMigrator('postgresql://localhost:5432/test_db');
|
|
143
|
+
*
|
|
144
|
+
* // Start migrations and get cleanup function
|
|
145
|
+
* const cleanup = await migrator.start();
|
|
146
|
+
*
|
|
147
|
+
* try {
|
|
148
|
+
* // Run your tests here
|
|
149
|
+
* await runTests();
|
|
150
|
+
* } finally {
|
|
151
|
+
* // Always clean up
|
|
152
|
+
* await cleanup();
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
async start() {
|
|
157
|
+
const { database, db } = await setupClient(this.uri);
|
|
158
|
+
let created = false;
|
|
159
|
+
try {
|
|
160
|
+
const { alreadyExisted } = await PostgresMigrator.create(this.uri);
|
|
161
|
+
created = !alreadyExisted;
|
|
162
|
+
if (this.afterCreate) await this.afterCreate(this.uri);
|
|
163
|
+
await this.migrate();
|
|
164
|
+
logger.log(`Migrating database: ${database}`);
|
|
165
|
+
} finally {
|
|
166
|
+
await db.end();
|
|
167
|
+
}
|
|
168
|
+
return async () => {
|
|
169
|
+
if (created) await PostgresMigrator.drop(this.uri);
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
//#endregion
|
|
174
|
+
export { PostgresMigrator };
|
|
2
175
|
|
|
3
|
-
|
|
176
|
+
//# sourceMappingURL=PostgresMigrator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresMigrator.mjs","names":[],"sources":["../src/PostgresMigrator.ts"],"sourcesContent":["import pg from 'pg';\n\nconst { Client } = pg;\n\n/**\n * Creates a PostgreSQL client connected to the 'postgres' database.\n * Extracts connection details from the provided URI.\n *\n * @param uri - PostgreSQL connection URI\n * @returns Object containing the target database name and client instance\n *\n * @example\n * ```typescript\n * const { database, db } = await setupClient('postgresql://user:pass@localhost:5432/mydb');\n * // database = 'mydb'\n * // db = Client instance connected to 'postgres' database\n * ```\n */\nasync function setupClient(uri: string) {\n\tconst url = new URL(uri);\n\n\tconst db = new Client({\n\t\tuser: url.username,\n\t\tpassword: url.password,\n\t\thost: url.hostname,\n\t\tport: parseInt(url.port, 10),\n\t\tdatabase: 'postgres',\n\t});\n\n\tlet database = url.pathname.slice(1);\n\tif (database.includes('?')) {\n\t\tdatabase = database.substring(0, database.indexOf('?'));\n\t}\n\treturn { database, db };\n}\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * Abstract base class for PostgreSQL database migration utilities.\n * Provides database creation, migration, and cleanup functionality for testing.\n * Subclasses must implement the migrate() method to define migration logic.\n *\n * @example\n * ```typescript\n * class MyMigrator extends PostgresMigrator {\n * async migrate(): Promise<void> {\n * // Run your migrations here\n * await this.runMigrations();\n * }\n * }\n *\n * // Use in tests\n * const migrator = new MyMigrator('postgresql://localhost:5432/test_db');\n * const cleanup = await migrator.start();\n *\n * // With afterCreate hook (e.g. run init script to create per-app users)\n * import { runInitScript } from '@geekmidas/testkit/postgres';\n *\n * const migrator = new MyMigrator(\n * 'postgresql://localhost:5432/test_db',\n * async (uri) => {\n * await runInitScript('docker/postgres/init.sh', uri, env);\n * },\n * );\n * const cleanup = await migrator.start();\n *\n * // Run tests...\n *\n * // Clean up\n * await cleanup();\n * ```\n */\nexport abstract class PostgresMigrator {\n\t/**\n\t * Creates a new PostgresMigrator instance.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t * @param afterCreate - Optional hook called after database creation but before migrations\n\t */\n\tconstructor(\n\t\tprivate uri: string,\n\t\tprivate afterCreate?: (uri: string) => Promise<void>,\n\t) {}\n\n\t/**\n\t * Abstract method to be implemented by subclasses.\n\t * Should contain the migration logic for setting up database schema.\n\t *\n\t * @returns Promise that resolves when migrations are complete\n\t */\n\tabstract migrate(): Promise<void>;\n\n\t/**\n\t * Creates a PostgreSQL database if it doesn't already exist.\n\t * Connects to the 'postgres' database to check and create the target database.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t * @returns Object indicating whether the database already existed\n\t * @private\n\t */\n\tprivate static async create(\n\t\turi: string,\n\t): Promise<{ alreadyExisted: boolean }> {\n\t\tconst { database, db } = await setupClient(uri);\n\t\ttry {\n\t\t\tawait db.connect();\n\t\t\tconst result = await db.query(\n\t\t\t\t`SELECT * FROM pg_catalog.pg_database WHERE datname = '${database}'`,\n\t\t\t);\n\n\t\t\tif (result.rowCount === 0) {\n\t\t\t\ttry {\n\t\t\t\t\tawait db.query(`CREATE DATABASE \"${database}\"`);\n\t\t\t\t} catch (error: any) {\n\t\t\t\t\t// Another process created it between our check and our create. Postgres\n\t\t\t\t\t// reports that as 42P04 (duplicate_database) — or, when the two creates\n\t\t\t\t\t// race inside the catalog itself, as 23505 on pg_database's name index.\n\t\t\t\t\tif (\n\t\t\t\t\t\terror?.code === '42P04' ||\n\t\t\t\t\t\t(error?.code === '23505' &&\n\t\t\t\t\t\t\terror?.constraint === 'pg_database_datname_index')\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn { alreadyExisted: true };\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\talreadyExisted: result.rowCount ? result.rowCount > 0 : false,\n\t\t\t};\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\t}\n\n\t/**\n\t * Drops a PostgreSQL database.\n\t * Used for cleanup after tests are complete.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t * @throws Error if database cannot be dropped\n\t * @private\n\t */\n\tprivate static async drop(uri: string): Promise<void> {\n\t\tconst { database, db } = await setupClient(uri);\n\t\ttry {\n\t\t\tawait db.connect();\n\t\t\tawait db.query(`DROP DATABASE \"${database}\"`);\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\t}\n\n\t/**\n\t * Starts the migration process by creating the database and running migrations.\n\t * Returns a cleanup function that drops the database — if this call created\n\t * it.\n\t *\n\t * A database that was already there belongs to whoever made it, and the\n\t * cleanup leaves it alone. `gkm test` provisions the test database before\n\t * the suite starts, with an owner role that may migrate it but not drop it:\n\t * dropping it was never the suite's to do, and failed there as a permission\n\t * error on the way out of an otherwise green run.\n\t *\n\t * @returns Async cleanup function that drops the database if it created it\n\t *\n\t * @example\n\t * ```typescript\n\t * const migrator = new MyMigrator('postgresql://localhost:5432/test_db');\n\t *\n\t * // Start migrations and get cleanup function\n\t * const cleanup = await migrator.start();\n\t *\n\t * try {\n\t * // Run your tests here\n\t * await runTests();\n\t * } finally {\n\t * // Always clean up\n\t * await cleanup();\n\t * }\n\t * ```\n\t */\n\tasync start() {\n\t\tconst { database, db } = await setupClient(this.uri);\n\t\tlet created = false;\n\t\ttry {\n\t\t\tconst { alreadyExisted } = await PostgresMigrator.create(this.uri);\n\t\t\tcreated = !alreadyExisted;\n\t\t\tif (this.afterCreate) {\n\t\t\t\tawait this.afterCreate(this.uri);\n\t\t\t}\n\t\t\tawait this.migrate();\n\t\t\tlogger.log(`Migrating database: ${database}`);\n\t\t\t// Example: await db.query('CREATE TABLE example (id SERIAL PRIMARY KEY)');\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\n\t\treturn async () => {\n\t\t\tif (created) await PostgresMigrator.drop(this.uri);\n\t\t};\n\t}\n}\n"],"mappings":";;AAEA,MAAM,EAAE,WAAW;;;;;;;;;;;;;;;AAgBnB,eAAe,YAAY,KAAa;CACvC,MAAM,MAAM,IAAI,IAAI,GAAG;CAEvB,MAAM,KAAK,IAAI,OAAO;EACrB,MAAM,IAAI;EACV,UAAU,IAAI;EACd,MAAM,IAAI;EACV,MAAM,SAAS,IAAI,MAAM,EAAE;EAC3B,UAAU;CACX,CAAC;CAED,IAAI,WAAW,IAAI,SAAS,MAAM,CAAC;CACnC,IAAI,SAAS,SAAS,GAAG,GACxB,WAAW,SAAS,UAAU,GAAG,SAAS,QAAQ,GAAG,CAAC;CAEvD,OAAO;EAAE;EAAU;CAAG;AACvB;;;;AAKA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCf,IAAsB,mBAAtB,MAAsB,iBAAiB;CAQ7B;CACA;;;;;;;CAFT,YACC,KACA,aACC;EAFO,KAAA,MAAA;EACA,KAAA,cAAA;CACN;;;;;;;;;CAkBH,aAAqB,OACpB,KACuC;EACvC,MAAM,EAAE,UAAU,OAAO,MAAM,YAAY,GAAG;EAC9C,IAAI;GACH,MAAM,GAAG,QAAQ;GACjB,MAAM,SAAS,MAAM,GAAG,MACvB,yDAAyD,SAAS,EACnE;GAEA,IAAI,OAAO,aAAa,GACvB,IAAI;IACH,MAAM,GAAG,MAAM,oBAAoB,SAAS,EAAE;GAC/C,SAAS,OAAY;IAIpB,IACC,OAAO,SAAS,WACf,OAAO,SAAS,WAChB,OAAO,eAAe,6BAEvB,OAAO,EAAE,gBAAgB,KAAK;IAE/B,MAAM;GACP;GAGD,OAAO,EACN,gBAAgB,OAAO,WAAW,OAAO,WAAW,IAAI,MACzD;EACD,UAAU;GACT,MAAM,GAAG,IAAI;EACd;CACD;;;;;;;;;CAUA,aAAqB,KAAK,KAA4B;EACrD,MAAM,EAAE,UAAU,OAAO,MAAM,YAAY,GAAG;EAC9C,IAAI;GACH,MAAM,GAAG,QAAQ;GACjB,MAAM,GAAG,MAAM,kBAAkB,SAAS,EAAE;EAC7C,UAAU;GACT,MAAM,GAAG,IAAI;EACd;CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BA,MAAM,QAAQ;EACb,MAAM,EAAE,UAAU,OAAO,MAAM,YAAY,KAAK,GAAG;EACnD,IAAI,UAAU;EACd,IAAI;GACH,MAAM,EAAE,mBAAmB,MAAM,iBAAiB,OAAO,KAAK,GAAG;GACjE,UAAU,CAAC;GACX,IAAI,KAAK,aACR,MAAM,KAAK,YAAY,KAAK,GAAG;GAEhC,MAAM,KAAK,QAAQ;GACnB,OAAO,IAAI,uBAAuB,UAAU;EAE7C,UAAU;GACT,MAAM,GAAG,IAAI;EACd;EAEA,OAAO,YAAY;GAClB,IAAI,SAAS,MAAM,iBAAiB,KAAK,KAAK,GAAG;EAClD;CACD;AACD"}
|
|
@@ -1,4 +1,119 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_PostgresMigrator = require("./PostgresMigrator.cjs");
|
|
3
|
+
//#region src/PostgresObjectionMigrator.ts
|
|
4
|
+
/**
|
|
5
|
+
* Default logger instance for migration operations.
|
|
6
|
+
*/
|
|
7
|
+
const logger = console;
|
|
8
|
+
/**
|
|
9
|
+
* PostgreSQL migrator implementation for Objection.js ORM with Knex.
|
|
10
|
+
* Extends PostgresMigrator to provide Knex-specific migration functionality.
|
|
11
|
+
* Automatically creates test databases and applies migrations for testing environments.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import knex from 'knex';
|
|
16
|
+
* import { PostgresObjectionMigrator } from '@geekmidas/testkit';
|
|
17
|
+
*
|
|
18
|
+
* // Create Knex instance
|
|
19
|
+
* const db = knex({
|
|
20
|
+
* client: 'pg',
|
|
21
|
+
* connection: uri,
|
|
22
|
+
* migrations: {
|
|
23
|
+
* directory: path.join(__dirname, 'migrations'),
|
|
24
|
+
* extension: 'ts'
|
|
25
|
+
* }
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // Create and use migrator
|
|
29
|
+
* const migrator = new PostgresObjectionMigrator({
|
|
30
|
+
* uri: 'postgresql://localhost:5432/test_db',
|
|
31
|
+
* knex: db
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* const cleanup = await migrator.start();
|
|
35
|
+
* // Run tests...
|
|
36
|
+
* await cleanup();
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
var PostgresObjectionMigrator = class extends require_PostgresMigrator.PostgresMigrator {
|
|
40
|
+
options;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new PostgresObjectionMigrator instance.
|
|
43
|
+
*
|
|
44
|
+
* @param options - Configuration options
|
|
45
|
+
* @param options.uri - PostgreSQL connection URI
|
|
46
|
+
* @param options.knex - Knex database instance configured with migrations
|
|
47
|
+
*/
|
|
48
|
+
constructor(options) {
|
|
49
|
+
super(options.uri);
|
|
50
|
+
this.options = options;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Executes Knex migrations to the latest version.
|
|
54
|
+
* Implements the abstract migrate() method from PostgresMigrator.
|
|
55
|
+
*
|
|
56
|
+
* @throws Error if migrations fail to apply
|
|
57
|
+
* @returns Promise that resolves when all migrations are applied
|
|
58
|
+
*/
|
|
59
|
+
async migrate() {
|
|
60
|
+
try {
|
|
61
|
+
const [batchNo, migrations] = await this.options.knex.migrate.latest();
|
|
62
|
+
if (migrations.length > 0) {
|
|
63
|
+
logger.log(`Applied batch ${batchNo} with ${migrations.length} migrations:`);
|
|
64
|
+
migrations.forEach((migration) => {
|
|
65
|
+
logger.log(` - ${migration}`);
|
|
66
|
+
});
|
|
67
|
+
} else logger.log("No pending migrations to apply");
|
|
68
|
+
} catch (error) {
|
|
69
|
+
logger.error("Failed to apply migrations:", error);
|
|
70
|
+
throw error;
|
|
71
|
+
} finally {
|
|
72
|
+
await this.options.knex.destroy();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Rolls back the last batch of migrations.
|
|
77
|
+
* Useful for testing migration rollback scenarios.
|
|
78
|
+
*
|
|
79
|
+
* @returns Promise that resolves when rollback is complete
|
|
80
|
+
*/
|
|
81
|
+
async rollback() {
|
|
82
|
+
try {
|
|
83
|
+
const [batchNo, migrations] = await this.options.knex.migrate.rollback();
|
|
84
|
+
if (migrations.length > 0) {
|
|
85
|
+
logger.log(`Rolled back batch ${batchNo} with ${migrations.length} migrations:`);
|
|
86
|
+
migrations.forEach((migration) => {
|
|
87
|
+
logger.log(` - ${migration}`);
|
|
88
|
+
});
|
|
89
|
+
} else logger.log("No migrations to rollback");
|
|
90
|
+
} catch (error) {
|
|
91
|
+
logger.error("Failed to rollback migrations:", error);
|
|
92
|
+
throw error;
|
|
93
|
+
} finally {
|
|
94
|
+
await this.options.knex.destroy();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Gets the current migration status.
|
|
99
|
+
* Returns information about completed and pending migrations.
|
|
100
|
+
*
|
|
101
|
+
* @returns Promise with migration status information
|
|
102
|
+
*/
|
|
103
|
+
async status() {
|
|
104
|
+
try {
|
|
105
|
+
const completed = await this.options.knex.migrate.list();
|
|
106
|
+
const [, pending] = await this.options.knex.migrate.currentVersion();
|
|
107
|
+
return {
|
|
108
|
+
completed: Array.isArray(completed[0]) ? completed[0] : [],
|
|
109
|
+
pending: Array.isArray(pending) ? pending : []
|
|
110
|
+
};
|
|
111
|
+
} finally {
|
|
112
|
+
await this.options.knex.destroy();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
//#endregion
|
|
117
|
+
exports.PostgresObjectionMigrator = PostgresObjectionMigrator;
|
|
3
118
|
|
|
4
|
-
|
|
119
|
+
//# sourceMappingURL=PostgresObjectionMigrator.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresObjectionMigrator.cjs","names":["PostgresMigrator"],"sources":["../src/PostgresObjectionMigrator.ts"],"sourcesContent":["import type { Knex } from 'knex';\nimport { PostgresMigrator } from './PostgresMigrator';\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * PostgreSQL migrator implementation for Objection.js ORM with Knex.\n * Extends PostgresMigrator to provide Knex-specific migration functionality.\n * Automatically creates test databases and applies migrations for testing environments.\n *\n * @example\n * ```typescript\n * import knex from 'knex';\n * import { PostgresObjectionMigrator } from '@geekmidas/testkit';\n *\n * // Create Knex instance\n * const db = knex({\n * client: 'pg',\n * connection: uri,\n * migrations: {\n * directory: path.join(__dirname, 'migrations'),\n * extension: 'ts'\n * }\n * });\n *\n * // Create and use migrator\n * const migrator = new PostgresObjectionMigrator({\n * uri: 'postgresql://localhost:5432/test_db',\n * knex: db\n * });\n *\n * const cleanup = await migrator.start();\n * // Run tests...\n * await cleanup();\n * ```\n */\nexport class PostgresObjectionMigrator extends PostgresMigrator {\n\t/**\n\t * Creates a new PostgresObjectionMigrator instance.\n\t *\n\t * @param options - Configuration options\n\t * @param options.uri - PostgreSQL connection URI\n\t * @param options.knex - Knex database instance configured with migrations\n\t */\n\tconstructor(\n\t\tprivate options: {\n\t\t\turi: string;\n\t\t\tknex: Knex;\n\t\t},\n\t) {\n\t\tsuper(options.uri);\n\t}\n\n\t/**\n\t * Executes Knex migrations to the latest version.\n\t * Implements the abstract migrate() method from PostgresMigrator.\n\t *\n\t * @throws Error if migrations fail to apply\n\t * @returns Promise that resolves when all migrations are applied\n\t */\n\tasync migrate(): Promise<void> {\n\t\ttry {\n\t\t\t// Run migrations to latest\n\t\t\tconst [batchNo, migrations] = await this.options.knex.migrate.latest();\n\n\t\t\tif (migrations.length > 0) {\n\t\t\t\tlogger.log(\n\t\t\t\t\t`Applied batch ${batchNo} with ${migrations.length} migrations:`,\n\t\t\t\t);\n\t\t\t\tmigrations.forEach((migration: string) => {\n\t\t\t\t\tlogger.log(` - ${migration}`);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tlogger.log('No pending migrations to apply');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlogger.error('Failed to apply migrations:', error);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\t// Always destroy the connection pool\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n\n\t/**\n\t * Rolls back the last batch of migrations.\n\t * Useful for testing migration rollback scenarios.\n\t *\n\t * @returns Promise that resolves when rollback is complete\n\t */\n\tasync rollback(): Promise<void> {\n\t\ttry {\n\t\t\tconst [batchNo, migrations] = await this.options.knex.migrate.rollback();\n\n\t\t\tif (migrations.length > 0) {\n\t\t\t\tlogger.log(\n\t\t\t\t\t`Rolled back batch ${batchNo} with ${migrations.length} migrations:`,\n\t\t\t\t);\n\t\t\t\tmigrations.forEach((migration: string) => {\n\t\t\t\t\tlogger.log(` - ${migration}`);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tlogger.log('No migrations to rollback');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlogger.error('Failed to rollback migrations:', error);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n\n\t/**\n\t * Gets the current migration status.\n\t * Returns information about completed and pending migrations.\n\t *\n\t * @returns Promise with migration status information\n\t */\n\tasync status(): Promise<{\n\t\tcompleted: string[];\n\t\tpending: string[];\n\t}> {\n\t\ttry {\n\t\t\tconst completed = await this.options.knex.migrate.list();\n\t\t\tconst [, pending] = await this.options.knex.migrate.currentVersion();\n\n\t\t\treturn {\n\t\t\t\tcompleted: Array.isArray(completed[0]) ? completed[0] : [],\n\t\t\t\tpending: Array.isArray(pending) ? pending : [],\n\t\t\t};\n\t\t} finally {\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;AAMA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCf,IAAa,4BAAb,cAA+CA,yBAAAA,iBAAiB;CAStD;;;;;;;;CADT,YACC,SAIC;EACD,MAAM,QAAQ,GAAG;EALT,KAAA,UAAA;CAMT;;;;;;;;CASA,MAAM,UAAyB;EAC9B,IAAI;GAEH,MAAM,CAAC,SAAS,cAAc,MAAM,KAAK,QAAQ,KAAK,QAAQ,OAAO;GAErE,IAAI,WAAW,SAAS,GAAG;IAC1B,OAAO,IACN,iBAAiB,QAAQ,QAAQ,WAAW,OAAO,aACpD;IACA,WAAW,SAAS,cAAsB;KACzC,OAAO,IAAI,OAAO,WAAW;IAC9B,CAAC;GACF,OACC,OAAO,IAAI,gCAAgC;EAE7C,SAAS,OAAO;GACf,OAAO,MAAM,+BAA+B,KAAK;GACjD,MAAM;EACP,UAAU;GAET,MAAM,KAAK,QAAQ,KAAK,QAAQ;EACjC;CACD;;;;;;;CAQA,MAAM,WAA0B;EAC/B,IAAI;GACH,MAAM,CAAC,SAAS,cAAc,MAAM,KAAK,QAAQ,KAAK,QAAQ,SAAS;GAEvE,IAAI,WAAW,SAAS,GAAG;IAC1B,OAAO,IACN,qBAAqB,QAAQ,QAAQ,WAAW,OAAO,aACxD;IACA,WAAW,SAAS,cAAsB;KACzC,OAAO,IAAI,OAAO,WAAW;IAC9B,CAAC;GACF,OACC,OAAO,IAAI,2BAA2B;EAExC,SAAS,OAAO;GACf,OAAO,MAAM,kCAAkC,KAAK;GACpD,MAAM;EACP,UAAU;GACT,MAAM,KAAK,QAAQ,KAAK,QAAQ;EACjC;CACD;;;;;;;CAQA,MAAM,SAGH;EACF,IAAI;GACH,MAAM,YAAY,MAAM,KAAK,QAAQ,KAAK,QAAQ,KAAK;GACvD,MAAM,GAAG,WAAW,MAAM,KAAK,QAAQ,KAAK,QAAQ,eAAe;GAEnE,OAAO;IACN,WAAW,MAAM,QAAQ,UAAU,EAAE,IAAI,UAAU,KAAK,CAAC;IACzD,SAAS,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC;GAC9C;EACD,UAAU;GACT,MAAM,KAAK,QAAQ,KAAK,QAAQ;EACjC;CACD;AACD"}
|
|
@@ -1,3 +1,75 @@
|
|
|
1
|
-
import "./PostgresMigrator-
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { t as PostgresMigrator } from "./PostgresMigrator-CDPnnwMJ.cjs";
|
|
2
|
+
import { Knex } from "knex";
|
|
3
|
+
//#region src/PostgresObjectionMigrator.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* PostgreSQL migrator implementation for Objection.js ORM with Knex.
|
|
6
|
+
* Extends PostgresMigrator to provide Knex-specific migration functionality.
|
|
7
|
+
* Automatically creates test databases and applies migrations for testing environments.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import knex from 'knex';
|
|
12
|
+
* import { PostgresObjectionMigrator } from '@geekmidas/testkit';
|
|
13
|
+
*
|
|
14
|
+
* // Create Knex instance
|
|
15
|
+
* const db = knex({
|
|
16
|
+
* client: 'pg',
|
|
17
|
+
* connection: uri,
|
|
18
|
+
* migrations: {
|
|
19
|
+
* directory: path.join(__dirname, 'migrations'),
|
|
20
|
+
* extension: 'ts'
|
|
21
|
+
* }
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Create and use migrator
|
|
25
|
+
* const migrator = new PostgresObjectionMigrator({
|
|
26
|
+
* uri: 'postgresql://localhost:5432/test_db',
|
|
27
|
+
* knex: db
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* const cleanup = await migrator.start();
|
|
31
|
+
* // Run tests...
|
|
32
|
+
* await cleanup();
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare class PostgresObjectionMigrator extends PostgresMigrator {
|
|
36
|
+
private options;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new PostgresObjectionMigrator instance.
|
|
39
|
+
*
|
|
40
|
+
* @param options - Configuration options
|
|
41
|
+
* @param options.uri - PostgreSQL connection URI
|
|
42
|
+
* @param options.knex - Knex database instance configured with migrations
|
|
43
|
+
*/
|
|
44
|
+
constructor(options: {
|
|
45
|
+
uri: string;
|
|
46
|
+
knex: Knex;
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Executes Knex migrations to the latest version.
|
|
50
|
+
* Implements the abstract migrate() method from PostgresMigrator.
|
|
51
|
+
*
|
|
52
|
+
* @throws Error if migrations fail to apply
|
|
53
|
+
* @returns Promise that resolves when all migrations are applied
|
|
54
|
+
*/
|
|
55
|
+
migrate(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Rolls back the last batch of migrations.
|
|
58
|
+
* Useful for testing migration rollback scenarios.
|
|
59
|
+
*
|
|
60
|
+
* @returns Promise that resolves when rollback is complete
|
|
61
|
+
*/
|
|
62
|
+
rollback(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the current migration status.
|
|
65
|
+
* Returns information about completed and pending migrations.
|
|
66
|
+
*
|
|
67
|
+
* @returns Promise with migration status information
|
|
68
|
+
*/
|
|
69
|
+
status(): Promise<{
|
|
70
|
+
completed: string[];
|
|
71
|
+
pending: string[];
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//# sourceMappingURL=PostgresObjectionMigrator.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresObjectionMigrator.d.cts","names":[],"sources":["../src/PostgresObjectionMigrator.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAuCa,kCAAkC;UASrC;;;;;;;;EADT,YACS;IACP;IACA,MAAM;;;;;;;;;EAaF,WAAW;;;;;;;EA8BX,YAAY;;;;;;;EA4BZ,UAAU;IACf;IACA"}
|
|
@@ -1,3 +1,75 @@
|
|
|
1
|
-
import "./PostgresMigrator-
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { t as PostgresMigrator } from "./PostgresMigrator-CDPnnwMJ.mjs";
|
|
2
|
+
import { Knex } from "knex";
|
|
3
|
+
//#region src/PostgresObjectionMigrator.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* PostgreSQL migrator implementation for Objection.js ORM with Knex.
|
|
6
|
+
* Extends PostgresMigrator to provide Knex-specific migration functionality.
|
|
7
|
+
* Automatically creates test databases and applies migrations for testing environments.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import knex from 'knex';
|
|
12
|
+
* import { PostgresObjectionMigrator } from '@geekmidas/testkit';
|
|
13
|
+
*
|
|
14
|
+
* // Create Knex instance
|
|
15
|
+
* const db = knex({
|
|
16
|
+
* client: 'pg',
|
|
17
|
+
* connection: uri,
|
|
18
|
+
* migrations: {
|
|
19
|
+
* directory: path.join(__dirname, 'migrations'),
|
|
20
|
+
* extension: 'ts'
|
|
21
|
+
* }
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Create and use migrator
|
|
25
|
+
* const migrator = new PostgresObjectionMigrator({
|
|
26
|
+
* uri: 'postgresql://localhost:5432/test_db',
|
|
27
|
+
* knex: db
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* const cleanup = await migrator.start();
|
|
31
|
+
* // Run tests...
|
|
32
|
+
* await cleanup();
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare class PostgresObjectionMigrator extends PostgresMigrator {
|
|
36
|
+
private options;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new PostgresObjectionMigrator instance.
|
|
39
|
+
*
|
|
40
|
+
* @param options - Configuration options
|
|
41
|
+
* @param options.uri - PostgreSQL connection URI
|
|
42
|
+
* @param options.knex - Knex database instance configured with migrations
|
|
43
|
+
*/
|
|
44
|
+
constructor(options: {
|
|
45
|
+
uri: string;
|
|
46
|
+
knex: Knex;
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Executes Knex migrations to the latest version.
|
|
50
|
+
* Implements the abstract migrate() method from PostgresMigrator.
|
|
51
|
+
*
|
|
52
|
+
* @throws Error if migrations fail to apply
|
|
53
|
+
* @returns Promise that resolves when all migrations are applied
|
|
54
|
+
*/
|
|
55
|
+
migrate(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Rolls back the last batch of migrations.
|
|
58
|
+
* Useful for testing migration rollback scenarios.
|
|
59
|
+
*
|
|
60
|
+
* @returns Promise that resolves when rollback is complete
|
|
61
|
+
*/
|
|
62
|
+
rollback(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the current migration status.
|
|
65
|
+
* Returns information about completed and pending migrations.
|
|
66
|
+
*
|
|
67
|
+
* @returns Promise with migration status information
|
|
68
|
+
*/
|
|
69
|
+
status(): Promise<{
|
|
70
|
+
completed: string[];
|
|
71
|
+
pending: string[];
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//# sourceMappingURL=PostgresObjectionMigrator.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresObjectionMigrator.d.mts","names":[],"sources":["../src/PostgresObjectionMigrator.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAuCa,kCAAkC;UASrC;;;;;;;;EADT,YACS;IACP;IACA,MAAM;;;;;;;;;EAaF,WAAW;;;;;;;EA8BX,YAAY;;;;;;;EA4BZ,UAAU;IACf;IACA"}
|
|
@@ -1,4 +1,118 @@
|
|
|
1
|
-
import "./PostgresMigrator
|
|
2
|
-
|
|
1
|
+
import { PostgresMigrator } from "./PostgresMigrator.mjs";
|
|
2
|
+
//#region src/PostgresObjectionMigrator.ts
|
|
3
|
+
/**
|
|
4
|
+
* Default logger instance for migration operations.
|
|
5
|
+
*/
|
|
6
|
+
const logger = console;
|
|
7
|
+
/**
|
|
8
|
+
* PostgreSQL migrator implementation for Objection.js ORM with Knex.
|
|
9
|
+
* Extends PostgresMigrator to provide Knex-specific migration functionality.
|
|
10
|
+
* Automatically creates test databases and applies migrations for testing environments.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import knex from 'knex';
|
|
15
|
+
* import { PostgresObjectionMigrator } from '@geekmidas/testkit';
|
|
16
|
+
*
|
|
17
|
+
* // Create Knex instance
|
|
18
|
+
* const db = knex({
|
|
19
|
+
* client: 'pg',
|
|
20
|
+
* connection: uri,
|
|
21
|
+
* migrations: {
|
|
22
|
+
* directory: path.join(__dirname, 'migrations'),
|
|
23
|
+
* extension: 'ts'
|
|
24
|
+
* }
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Create and use migrator
|
|
28
|
+
* const migrator = new PostgresObjectionMigrator({
|
|
29
|
+
* uri: 'postgresql://localhost:5432/test_db',
|
|
30
|
+
* knex: db
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* const cleanup = await migrator.start();
|
|
34
|
+
* // Run tests...
|
|
35
|
+
* await cleanup();
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
var PostgresObjectionMigrator = class extends PostgresMigrator {
|
|
39
|
+
options;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new PostgresObjectionMigrator instance.
|
|
42
|
+
*
|
|
43
|
+
* @param options - Configuration options
|
|
44
|
+
* @param options.uri - PostgreSQL connection URI
|
|
45
|
+
* @param options.knex - Knex database instance configured with migrations
|
|
46
|
+
*/
|
|
47
|
+
constructor(options) {
|
|
48
|
+
super(options.uri);
|
|
49
|
+
this.options = options;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Executes Knex migrations to the latest version.
|
|
53
|
+
* Implements the abstract migrate() method from PostgresMigrator.
|
|
54
|
+
*
|
|
55
|
+
* @throws Error if migrations fail to apply
|
|
56
|
+
* @returns Promise that resolves when all migrations are applied
|
|
57
|
+
*/
|
|
58
|
+
async migrate() {
|
|
59
|
+
try {
|
|
60
|
+
const [batchNo, migrations] = await this.options.knex.migrate.latest();
|
|
61
|
+
if (migrations.length > 0) {
|
|
62
|
+
logger.log(`Applied batch ${batchNo} with ${migrations.length} migrations:`);
|
|
63
|
+
migrations.forEach((migration) => {
|
|
64
|
+
logger.log(` - ${migration}`);
|
|
65
|
+
});
|
|
66
|
+
} else logger.log("No pending migrations to apply");
|
|
67
|
+
} catch (error) {
|
|
68
|
+
logger.error("Failed to apply migrations:", error);
|
|
69
|
+
throw error;
|
|
70
|
+
} finally {
|
|
71
|
+
await this.options.knex.destroy();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Rolls back the last batch of migrations.
|
|
76
|
+
* Useful for testing migration rollback scenarios.
|
|
77
|
+
*
|
|
78
|
+
* @returns Promise that resolves when rollback is complete
|
|
79
|
+
*/
|
|
80
|
+
async rollback() {
|
|
81
|
+
try {
|
|
82
|
+
const [batchNo, migrations] = await this.options.knex.migrate.rollback();
|
|
83
|
+
if (migrations.length > 0) {
|
|
84
|
+
logger.log(`Rolled back batch ${batchNo} with ${migrations.length} migrations:`);
|
|
85
|
+
migrations.forEach((migration) => {
|
|
86
|
+
logger.log(` - ${migration}`);
|
|
87
|
+
});
|
|
88
|
+
} else logger.log("No migrations to rollback");
|
|
89
|
+
} catch (error) {
|
|
90
|
+
logger.error("Failed to rollback migrations:", error);
|
|
91
|
+
throw error;
|
|
92
|
+
} finally {
|
|
93
|
+
await this.options.knex.destroy();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets the current migration status.
|
|
98
|
+
* Returns information about completed and pending migrations.
|
|
99
|
+
*
|
|
100
|
+
* @returns Promise with migration status information
|
|
101
|
+
*/
|
|
102
|
+
async status() {
|
|
103
|
+
try {
|
|
104
|
+
const completed = await this.options.knex.migrate.list();
|
|
105
|
+
const [, pending] = await this.options.knex.migrate.currentVersion();
|
|
106
|
+
return {
|
|
107
|
+
completed: Array.isArray(completed[0]) ? completed[0] : [],
|
|
108
|
+
pending: Array.isArray(pending) ? pending : []
|
|
109
|
+
};
|
|
110
|
+
} finally {
|
|
111
|
+
await this.options.knex.destroy();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
//#endregion
|
|
116
|
+
export { PostgresObjectionMigrator };
|
|
3
117
|
|
|
4
|
-
|
|
118
|
+
//# sourceMappingURL=PostgresObjectionMigrator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresObjectionMigrator.mjs","names":[],"sources":["../src/PostgresObjectionMigrator.ts"],"sourcesContent":["import type { Knex } from 'knex';\nimport { PostgresMigrator } from './PostgresMigrator';\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * PostgreSQL migrator implementation for Objection.js ORM with Knex.\n * Extends PostgresMigrator to provide Knex-specific migration functionality.\n * Automatically creates test databases and applies migrations for testing environments.\n *\n * @example\n * ```typescript\n * import knex from 'knex';\n * import { PostgresObjectionMigrator } from '@geekmidas/testkit';\n *\n * // Create Knex instance\n * const db = knex({\n * client: 'pg',\n * connection: uri,\n * migrations: {\n * directory: path.join(__dirname, 'migrations'),\n * extension: 'ts'\n * }\n * });\n *\n * // Create and use migrator\n * const migrator = new PostgresObjectionMigrator({\n * uri: 'postgresql://localhost:5432/test_db',\n * knex: db\n * });\n *\n * const cleanup = await migrator.start();\n * // Run tests...\n * await cleanup();\n * ```\n */\nexport class PostgresObjectionMigrator extends PostgresMigrator {\n\t/**\n\t * Creates a new PostgresObjectionMigrator instance.\n\t *\n\t * @param options - Configuration options\n\t * @param options.uri - PostgreSQL connection URI\n\t * @param options.knex - Knex database instance configured with migrations\n\t */\n\tconstructor(\n\t\tprivate options: {\n\t\t\turi: string;\n\t\t\tknex: Knex;\n\t\t},\n\t) {\n\t\tsuper(options.uri);\n\t}\n\n\t/**\n\t * Executes Knex migrations to the latest version.\n\t * Implements the abstract migrate() method from PostgresMigrator.\n\t *\n\t * @throws Error if migrations fail to apply\n\t * @returns Promise that resolves when all migrations are applied\n\t */\n\tasync migrate(): Promise<void> {\n\t\ttry {\n\t\t\t// Run migrations to latest\n\t\t\tconst [batchNo, migrations] = await this.options.knex.migrate.latest();\n\n\t\t\tif (migrations.length > 0) {\n\t\t\t\tlogger.log(\n\t\t\t\t\t`Applied batch ${batchNo} with ${migrations.length} migrations:`,\n\t\t\t\t);\n\t\t\t\tmigrations.forEach((migration: string) => {\n\t\t\t\t\tlogger.log(` - ${migration}`);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tlogger.log('No pending migrations to apply');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlogger.error('Failed to apply migrations:', error);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\t// Always destroy the connection pool\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n\n\t/**\n\t * Rolls back the last batch of migrations.\n\t * Useful for testing migration rollback scenarios.\n\t *\n\t * @returns Promise that resolves when rollback is complete\n\t */\n\tasync rollback(): Promise<void> {\n\t\ttry {\n\t\t\tconst [batchNo, migrations] = await this.options.knex.migrate.rollback();\n\n\t\t\tif (migrations.length > 0) {\n\t\t\t\tlogger.log(\n\t\t\t\t\t`Rolled back batch ${batchNo} with ${migrations.length} migrations:`,\n\t\t\t\t);\n\t\t\t\tmigrations.forEach((migration: string) => {\n\t\t\t\t\tlogger.log(` - ${migration}`);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tlogger.log('No migrations to rollback');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlogger.error('Failed to rollback migrations:', error);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n\n\t/**\n\t * Gets the current migration status.\n\t * Returns information about completed and pending migrations.\n\t *\n\t * @returns Promise with migration status information\n\t */\n\tasync status(): Promise<{\n\t\tcompleted: string[];\n\t\tpending: string[];\n\t}> {\n\t\ttry {\n\t\t\tconst completed = await this.options.knex.migrate.list();\n\t\t\tconst [, pending] = await this.options.knex.migrate.currentVersion();\n\n\t\t\treturn {\n\t\t\t\tcompleted: Array.isArray(completed[0]) ? completed[0] : [],\n\t\t\t\tpending: Array.isArray(pending) ? pending : [],\n\t\t\t};\n\t\t} finally {\n\t\t\tawait this.options.knex.destroy();\n\t\t}\n\t}\n}\n"],"mappings":";;;;;AAMA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCf,IAAa,4BAAb,cAA+C,iBAAiB;CAStD;;;;;;;;CADT,YACC,SAIC;EACD,MAAM,QAAQ,GAAG;EALT,KAAA,UAAA;CAMT;;;;;;;;CASA,MAAM,UAAyB;EAC9B,IAAI;GAEH,MAAM,CAAC,SAAS,cAAc,MAAM,KAAK,QAAQ,KAAK,QAAQ,OAAO;GAErE,IAAI,WAAW,SAAS,GAAG;IAC1B,OAAO,IACN,iBAAiB,QAAQ,QAAQ,WAAW,OAAO,aACpD;IACA,WAAW,SAAS,cAAsB;KACzC,OAAO,IAAI,OAAO,WAAW;IAC9B,CAAC;GACF,OACC,OAAO,IAAI,gCAAgC;EAE7C,SAAS,OAAO;GACf,OAAO,MAAM,+BAA+B,KAAK;GACjD,MAAM;EACP,UAAU;GAET,MAAM,KAAK,QAAQ,KAAK,QAAQ;EACjC;CACD;;;;;;;CAQA,MAAM,WAA0B;EAC/B,IAAI;GACH,MAAM,CAAC,SAAS,cAAc,MAAM,KAAK,QAAQ,KAAK,QAAQ,SAAS;GAEvE,IAAI,WAAW,SAAS,GAAG;IAC1B,OAAO,IACN,qBAAqB,QAAQ,QAAQ,WAAW,OAAO,aACxD;IACA,WAAW,SAAS,cAAsB;KACzC,OAAO,IAAI,OAAO,WAAW;IAC9B,CAAC;GACF,OACC,OAAO,IAAI,2BAA2B;EAExC,SAAS,OAAO;GACf,OAAO,MAAM,kCAAkC,KAAK;GACpD,MAAM;EACP,UAAU;GACT,MAAM,KAAK,QAAQ,KAAK,QAAQ;EACjC;CACD;;;;;;;CAQA,MAAM,SAGH;EACF,IAAI;GACH,MAAM,YAAY,MAAM,KAAK,QAAQ,KAAK,QAAQ,KAAK;GACvD,MAAM,GAAG,WAAW,MAAM,KAAK,QAAQ,KAAK,QAAQ,eAAe;GAEnE,OAAO;IACN,WAAW,MAAM,QAAQ,UAAU,EAAE,IAAI,UAAU,KAAK,CAAC;IACzD,SAAS,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC;GAC9C;EACD,UAAU;GACT,MAAM,KAAK,QAAQ,KAAK,QAAQ;EACjC;CACD;AACD"}
|