@geekmidas/testkit 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/{Factory-ClyZLRsO.d.mts → Factory-CVR3GdkW.d.mts} +2 -2
- package/dist/{Factory-ClyZLRsO.d.mts.map → Factory-CVR3GdkW.d.mts.map} +1 -1
- package/dist/Factory.d.mts +2 -2
- package/dist/{KyselyFactory-CTZmiGI9.d.mts → KyselyFactory-DRlMv-WT.d.mts} +3 -3
- package/dist/{KyselyFactory-CTZmiGI9.d.mts.map → KyselyFactory-DRlMv-WT.d.mts.map} +1 -1
- package/dist/KyselyFactory.d.mts +3 -3
- package/dist/{ObjectionFactory-DDrKwAoO.d.mts → ObjectionFactory-DkJUf-uM.d.mts} +3 -3
- package/dist/{ObjectionFactory-DDrKwAoO.d.mts.map → ObjectionFactory-DkJUf-uM.d.mts.map} +1 -1
- package/dist/ObjectionFactory.d.mts +3 -3
- package/dist/{PostgresKyselyMigrator-6sE1KOni.mjs → PostgresKyselyMigrator-B4pScubb.mjs} +2 -2
- package/dist/{PostgresKyselyMigrator-6sE1KOni.mjs.map → PostgresKyselyMigrator-B4pScubb.mjs.map} +1 -1
- package/dist/{PostgresKyselyMigrator-D6IbPq8t.cjs → PostgresKyselyMigrator-C7ljZYvq.cjs} +2 -2
- package/dist/{PostgresKyselyMigrator-D6IbPq8t.cjs.map → PostgresKyselyMigrator-C7ljZYvq.cjs.map} +1 -1
- package/dist/PostgresKyselyMigrator.cjs +2 -2
- package/dist/PostgresKyselyMigrator.mjs +2 -2
- package/dist/PostgresMigrator-Bres0U6E.d.cts.map +1 -1
- package/dist/{PostgresMigrator-D6dQn0x2.cjs → PostgresMigrator-CHiBYEg_.cjs} +7 -2
- package/dist/PostgresMigrator-CHiBYEg_.cjs.map +1 -0
- package/dist/{PostgresMigrator-BjjenqSd.mjs → PostgresMigrator-DcP1o-T6.mjs} +7 -2
- package/dist/PostgresMigrator-DcP1o-T6.mjs.map +1 -0
- package/dist/PostgresMigrator-S-YYosAC.d.mts.map +1 -1
- package/dist/PostgresMigrator.cjs +1 -1
- package/dist/PostgresMigrator.mjs +1 -1
- package/dist/{PostgresObjectionMigrator-D_QxXbIN.mjs → PostgresObjectionMigrator-BJ5X48U8.mjs} +2 -2
- package/dist/{PostgresObjectionMigrator-D_QxXbIN.mjs.map → PostgresObjectionMigrator-BJ5X48U8.mjs.map} +1 -1
- package/dist/{PostgresObjectionMigrator-DK8ODIHQ.cjs → PostgresObjectionMigrator-BXLAVVwm.cjs} +2 -2
- package/dist/{PostgresObjectionMigrator-DK8ODIHQ.cjs.map → PostgresObjectionMigrator-BXLAVVwm.cjs.map} +1 -1
- package/dist/PostgresObjectionMigrator.cjs +2 -2
- package/dist/PostgresObjectionMigrator.mjs +2 -2
- package/dist/better-auth.d.mts +2 -2
- package/dist/{directory-CVrfTq1I.d.mts → directory-DGOcVlKD.d.cts} +1 -1
- package/dist/{directory-CVrfTq1I.d.mts.map → directory-DGOcVlKD.d.cts.map} +1 -1
- package/dist/{directory-DAnMWi50.d.cts → directory-YzQUGC5g.d.mts} +3 -3
- package/dist/{directory-DAnMWi50.d.cts.map → directory-YzQUGC5g.d.mts.map} +1 -1
- package/dist/{faker-BcjUfHxx.d.mts → faker-DsYCplsG.d.mts} +3 -3
- package/dist/{faker-BcjUfHxx.d.mts.map → faker-DsYCplsG.d.mts.map} +1 -1
- package/dist/faker.d.mts +1 -1
- package/dist/initScript.cjs +95 -0
- package/dist/initScript.cjs.map +1 -0
- package/dist/initScript.d.cts +45 -0
- package/dist/initScript.d.cts.map +1 -0
- package/dist/initScript.d.mts +45 -0
- package/dist/initScript.d.mts.map +1 -0
- package/dist/initScript.mjs +93 -0
- package/dist/initScript.mjs.map +1 -0
- package/dist/kysely.cjs +2 -2
- package/dist/kysely.d.mts +3 -3
- package/dist/kysely.mjs +2 -2
- package/dist/objection.cjs +2 -2
- package/dist/objection.d.mts +3 -3
- package/dist/objection.mjs +2 -2
- package/dist/os/directory.d.cts +1 -1
- package/dist/os/directory.d.mts +1 -1
- package/dist/os/index.d.cts +1 -1
- package/dist/os/index.d.mts +1 -1
- package/package.json +9 -4
- package/src/PostgresMigrator.ts +9 -1
- package/src/__tests__/initScript.spec.ts +308 -0
- package/src/initScript.ts +119 -0
- package/dist/PostgresMigrator-BjjenqSd.mjs.map +0 -1
- package/dist/PostgresMigrator-D6dQn0x2.cjs.map +0 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import pg from 'pg';
|
|
3
|
+
|
|
4
|
+
const { Client } = pg;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Parse a shell init script (like docker/postgres/init.sh) and extract
|
|
8
|
+
* SQL blocks from heredoc sections (<<-EOSQL ... EOSQL).
|
|
9
|
+
*
|
|
10
|
+
* @param content - The shell script content
|
|
11
|
+
* @param env - Environment variables to substitute ($VAR_NAME references)
|
|
12
|
+
* @returns Array of SQL strings ready to execute
|
|
13
|
+
* @internal Exported for testing
|
|
14
|
+
*/
|
|
15
|
+
export function parseInitScript(
|
|
16
|
+
content: string,
|
|
17
|
+
env: Record<string, string>,
|
|
18
|
+
): string[] {
|
|
19
|
+
const blocks: string[] = [];
|
|
20
|
+
const lines = content.split('\n');
|
|
21
|
+
let inHeredoc = false;
|
|
22
|
+
let currentBlock: string[] = [];
|
|
23
|
+
|
|
24
|
+
for (const line of lines) {
|
|
25
|
+
if (inHeredoc) {
|
|
26
|
+
// Check for heredoc terminator (EOSQL at start of line, with optional leading whitespace)
|
|
27
|
+
if (/^\s*EOSQL\s*$/.test(line)) {
|
|
28
|
+
const sql = substituteEnvVars(currentBlock.join('\n'), env);
|
|
29
|
+
blocks.push(sql);
|
|
30
|
+
currentBlock = [];
|
|
31
|
+
inHeredoc = false;
|
|
32
|
+
} else {
|
|
33
|
+
currentBlock.push(line);
|
|
34
|
+
}
|
|
35
|
+
} else if (
|
|
36
|
+
line.includes('<<-EOSQL') ||
|
|
37
|
+
line.includes('<< EOSQL') ||
|
|
38
|
+
line.includes('<<EOSQL')
|
|
39
|
+
) {
|
|
40
|
+
inHeredoc = true;
|
|
41
|
+
currentBlock = [];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return blocks;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Replace shell variable references ($VAR_NAME and ${VAR_NAME})
|
|
50
|
+
* with values from the provided env object.
|
|
51
|
+
*/
|
|
52
|
+
function substituteEnvVars(sql: string, env: Record<string, string>): string {
|
|
53
|
+
// Replace ${VAR_NAME} syntax
|
|
54
|
+
let result = sql.replace(/\$\{(\w+)\}/g, (_, name) => env[name] ?? '');
|
|
55
|
+
// Replace $VAR_NAME syntax (word boundary after)
|
|
56
|
+
result = result.replace(/\$(\w+)/g, (_, name) => env[name] ?? '');
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Read a postgres init script, parse out the SQL blocks,
|
|
62
|
+
* substitute environment variables, and execute against a database.
|
|
63
|
+
*
|
|
64
|
+
* This is intended to run `docker/postgres/init.sh` against a test database
|
|
65
|
+
* so that per-app users and schemas are created (matching what Docker does
|
|
66
|
+
* on first volume initialization).
|
|
67
|
+
*
|
|
68
|
+
* Uses `CREATE ... IF NOT EXISTS` and `DO $$ ... END $$` wrappers where
|
|
69
|
+
* needed so the script is idempotent.
|
|
70
|
+
*
|
|
71
|
+
* @param scriptPath - Path to the init.sh file
|
|
72
|
+
* @param databaseUrl - PostgreSQL connection URL (should point to the test database)
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* // In your globalSetup.ts
|
|
77
|
+
* import { runInitScript } from '@geekmidas/testkit/postgres';
|
|
78
|
+
* import { Credentials } from '@geekmidas/envkit/credentials';
|
|
79
|
+
*
|
|
80
|
+
* const cleanup = await migrator.start();
|
|
81
|
+
*
|
|
82
|
+
* // Create per-app users in the test database
|
|
83
|
+
* await runInitScript('docker/postgres/init.sh', Credentials.DATABASE_URL, {
|
|
84
|
+
* ...process.env,
|
|
85
|
+
* ...Credentials,
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export async function runInitScript(
|
|
90
|
+
scriptPath: string,
|
|
91
|
+
databaseUrl: string,
|
|
92
|
+
env?: Record<string, string>,
|
|
93
|
+
): Promise<void> {
|
|
94
|
+
const content = readFileSync(scriptPath, 'utf-8');
|
|
95
|
+
const resolvedEnv = env ?? ({ ...process.env } as Record<string, string>);
|
|
96
|
+
const blocks = parseInitScript(content, resolvedEnv);
|
|
97
|
+
|
|
98
|
+
if (blocks.length === 0) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const url = new URL(databaseUrl);
|
|
103
|
+
const client = new Client({
|
|
104
|
+
user: url.username,
|
|
105
|
+
password: decodeURIComponent(url.password),
|
|
106
|
+
host: url.hostname,
|
|
107
|
+
port: parseInt(url.port, 10),
|
|
108
|
+
database: url.pathname.slice(1),
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
await client.connect();
|
|
113
|
+
for (const sql of blocks) {
|
|
114
|
+
await client.query(sql);
|
|
115
|
+
}
|
|
116
|
+
} finally {
|
|
117
|
+
await client.end();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresMigrator-BjjenqSd.mjs","names":["uri: string"],"sources":["../src/PostgresMigrator.ts"],"sourcesContent":["import pg from 'pg';\n\nconst { Client } = pg;\n\n/**\n * Creates a PostgreSQL client connected to the 'postgres' database.\n * Extracts connection details from the provided URI.\n *\n * @param uri - PostgreSQL connection URI\n * @returns Object containing the target database name and client instance\n *\n * @example\n * ```typescript\n * const { database, db } = await setupClient('postgresql://user:pass@localhost:5432/mydb');\n * // database = 'mydb'\n * // db = Client instance connected to 'postgres' database\n * ```\n */\nasync function setupClient(uri: string) {\n\tconst url = new URL(uri);\n\n\tconst db = new Client({\n\t\tuser: url.username,\n\t\tpassword: url.password,\n\t\thost: url.hostname,\n\t\tport: parseInt(url.port, 10),\n\t\tdatabase: 'postgres',\n\t});\n\n\tlet database = url.pathname.slice(1);\n\tif (database.includes('?')) {\n\t\tdatabase = database.substring(0, database.indexOf('?'));\n\t}\n\treturn { database, db };\n}\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * Abstract base class for PostgreSQL database migration utilities.\n * Provides database creation, migration, and cleanup functionality for testing.\n * Subclasses must implement the migrate() method to define migration logic.\n *\n * @example\n * ```typescript\n * class MyMigrator extends PostgresMigrator {\n * async migrate(): Promise<void> {\n * // Run your migrations here\n * await this.runMigrations();\n * }\n * }\n *\n * // Use in tests\n * const migrator = new MyMigrator('postgresql://localhost:5432/test_db');\n * const cleanup = await migrator.start();\n *\n * // Run tests...\n *\n * // Clean up\n * await cleanup();\n * ```\n */\nexport abstract class PostgresMigrator {\n\t/**\n\t * Creates a new PostgresMigrator instance.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t */\n\tconstructor(private uri: string) {}\n\n\t/**\n\t * Abstract method to be implemented by subclasses.\n\t * Should contain the migration logic for setting up database schema.\n\t *\n\t * @returns Promise that resolves when migrations are complete\n\t */\n\tabstract migrate(): Promise<void>;\n\n\t/**\n\t * Creates a PostgreSQL database if it doesn't already exist.\n\t * Connects to the 'postgres' database to check and create the target database.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t * @returns Object indicating whether the database already existed\n\t * @private\n\t */\n\tprivate static async create(\n\t\turi: string,\n\t): Promise<{ alreadyExisted: boolean }> {\n\t\tconst { database, db } = await setupClient(uri);\n\t\ttry {\n\t\t\tawait db.connect();\n\t\t\tconst result = await db.query(\n\t\t\t\t`SELECT * FROM pg_catalog.pg_database WHERE datname = '${database}'`,\n\t\t\t);\n\n\t\t\tif (result.rowCount === 0) {\n\t\t\t\tawait db.query(`CREATE DATABASE \"${database}\"`);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\talreadyExisted: result.rowCount ? result.rowCount > 0 : false,\n\t\t\t};\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\t}\n\n\t/**\n\t * Drops a PostgreSQL database.\n\t * Used for cleanup after tests are complete.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t * @throws Error if database cannot be dropped\n\t * @private\n\t */\n\tprivate static async drop(uri: string): Promise<void> {\n\t\tconst { database, db } = await setupClient(uri);\n\t\ttry {\n\t\t\tawait db.connect();\n\t\t\tawait db.query(`DROP DATABASE \"${database}\"`);\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\t}\n\n\t/**\n\t * Starts the migration process by creating the database and running migrations.\n\t * Returns a cleanup function that will drop the database when called.\n\t *\n\t * @returns Async cleanup function that drops the created database\n\t *\n\t * @example\n\t * ```typescript\n\t * const migrator = new MyMigrator('postgresql://localhost:5432/test_db');\n\t *\n\t * // Start migrations and get cleanup function\n\t * const cleanup = await migrator.start();\n\t *\n\t * try {\n\t * // Run your tests here\n\t * await runTests();\n\t * } finally {\n\t * // Always clean up\n\t * await cleanup();\n\t * }\n\t * ```\n\t */\n\tasync start() {\n\t\tconst { database, db } = await setupClient(this.uri);\n\t\ttry {\n\t\t\tawait PostgresMigrator.create(this.uri);\n\t\t\t// Implement migration logic here\n\t\t\tawait this.migrate();\n\t\t\tlogger.log(`Migrating database: ${database}`);\n\t\t\t// Example: await db.query('CREATE TABLE example (id SERIAL PRIMARY KEY)');\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\n\t\treturn async () => {\n\t\t\tawait PostgresMigrator.drop(this.uri);\n\t\t};\n\t}\n}\n"],"mappings":";;;AAEA,MAAM,EAAE,QAAQ,GAAG;;;;;;;;;;;;;;;AAgBnB,eAAe,YAAYA,KAAa;CACvC,MAAM,MAAM,IAAI,I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7C,UAAS;AACT,SAAM,GAAG,KAAK;EACd;AAED,SAAO,YAAY;AAClB,SAAM,iBAAiB,KAAK,KAAK,IAAI;EACrC;CACD;AACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresMigrator-D6dQn0x2.cjs","names":["uri: string"],"sources":["../src/PostgresMigrator.ts"],"sourcesContent":["import pg from 'pg';\n\nconst { Client } = pg;\n\n/**\n * Creates a PostgreSQL client connected to the 'postgres' database.\n * Extracts connection details from the provided URI.\n *\n * @param uri - PostgreSQL connection URI\n * @returns Object containing the target database name and client instance\n *\n * @example\n * ```typescript\n * const { database, db } = await setupClient('postgresql://user:pass@localhost:5432/mydb');\n * // database = 'mydb'\n * // db = Client instance connected to 'postgres' database\n * ```\n */\nasync function setupClient(uri: string) {\n\tconst url = new URL(uri);\n\n\tconst db = new Client({\n\t\tuser: url.username,\n\t\tpassword: url.password,\n\t\thost: url.hostname,\n\t\tport: parseInt(url.port, 10),\n\t\tdatabase: 'postgres',\n\t});\n\n\tlet database = url.pathname.slice(1);\n\tif (database.includes('?')) {\n\t\tdatabase = database.substring(0, database.indexOf('?'));\n\t}\n\treturn { database, db };\n}\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * Abstract base class for PostgreSQL database migration utilities.\n * Provides database creation, migration, and cleanup functionality for testing.\n * Subclasses must implement the migrate() method to define migration logic.\n *\n * @example\n * ```typescript\n * class MyMigrator extends PostgresMigrator {\n * async migrate(): Promise<void> {\n * // Run your migrations here\n * await this.runMigrations();\n * }\n * }\n *\n * // Use in tests\n * const migrator = new MyMigrator('postgresql://localhost:5432/test_db');\n * const cleanup = await migrator.start();\n *\n * // Run tests...\n *\n * // Clean up\n * await cleanup();\n * ```\n */\nexport abstract class PostgresMigrator {\n\t/**\n\t * Creates a new PostgresMigrator instance.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t */\n\tconstructor(private uri: string) {}\n\n\t/**\n\t * Abstract method to be implemented by subclasses.\n\t * Should contain the migration logic for setting up database schema.\n\t *\n\t * @returns Promise that resolves when migrations are complete\n\t */\n\tabstract migrate(): Promise<void>;\n\n\t/**\n\t * Creates a PostgreSQL database if it doesn't already exist.\n\t * Connects to the 'postgres' database to check and create the target database.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t * @returns Object indicating whether the database already existed\n\t * @private\n\t */\n\tprivate static async create(\n\t\turi: string,\n\t): Promise<{ alreadyExisted: boolean }> {\n\t\tconst { database, db } = await setupClient(uri);\n\t\ttry {\n\t\t\tawait db.connect();\n\t\t\tconst result = await db.query(\n\t\t\t\t`SELECT * FROM pg_catalog.pg_database WHERE datname = '${database}'`,\n\t\t\t);\n\n\t\t\tif (result.rowCount === 0) {\n\t\t\t\tawait db.query(`CREATE DATABASE \"${database}\"`);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\talreadyExisted: result.rowCount ? result.rowCount > 0 : false,\n\t\t\t};\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\t}\n\n\t/**\n\t * Drops a PostgreSQL database.\n\t * Used for cleanup after tests are complete.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t * @throws Error if database cannot be dropped\n\t * @private\n\t */\n\tprivate static async drop(uri: string): Promise<void> {\n\t\tconst { database, db } = await setupClient(uri);\n\t\ttry {\n\t\t\tawait db.connect();\n\t\t\tawait db.query(`DROP DATABASE \"${database}\"`);\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\t}\n\n\t/**\n\t * Starts the migration process by creating the database and running migrations.\n\t * Returns a cleanup function that will drop the database when called.\n\t *\n\t * @returns Async cleanup function that drops the created database\n\t *\n\t * @example\n\t * ```typescript\n\t * const migrator = new MyMigrator('postgresql://localhost:5432/test_db');\n\t *\n\t * // Start migrations and get cleanup function\n\t * const cleanup = await migrator.start();\n\t *\n\t * try {\n\t * // Run your tests here\n\t * await runTests();\n\t * } finally {\n\t * // Always clean up\n\t * await cleanup();\n\t * }\n\t * ```\n\t */\n\tasync start() {\n\t\tconst { database, db } = await setupClient(this.uri);\n\t\ttry {\n\t\t\tawait PostgresMigrator.create(this.uri);\n\t\t\t// Implement migration logic here\n\t\t\tawait this.migrate();\n\t\t\tlogger.log(`Migrating database: ${database}`);\n\t\t\t// Example: await db.query('CREATE TABLE example (id SERIAL PRIMARY KEY)');\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\n\t\treturn async () => {\n\t\t\tawait PostgresMigrator.drop(this.uri);\n\t\t};\n\t}\n}\n"],"mappings":";;;;AAEA,MAAM,EAAE,QAAQ,GAAG;;;;;;;;;;;;;;;AAgBnB,eAAe,YAAYA,KAAa;CACvC,MAAM,MAAM,IAAI,IAAI;CAEpB,MAAM,KAAK,IAAI,OAAO;EACrB,MAAM,IAAI;EACV,UAAU,IAAI;EACd,MAAM,IAAI;EACV,MAAM,SAAS,IAAI,MAAM,GAAG;EAC5B,UAAU;CACV;CAED,IAAI,WAAW,IAAI,SAAS,MAAM,EAAE;AACpC,KAAI,SAAS,SAAS,IAAI,CACzB,YAAW,SAAS,UAAU,GAAG,SAAS,QAAQ,IAAI,CAAC;AAExD,QAAO;EAAE;EAAU;CAAI;AACvB;;;;AAKD,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;AA0Bf,IAAsB,mBAAtB,MAAsB,iBAAiB;;;;;;CAMtC,YAAoBA,KAAa;EAAb;CAAe;;;;;;;;;CAkBnC,aAAqB,OACpBA,KACuC;EACvC,MAAM,EAAE,UAAU,IAAI,GAAG,MAAM,YAAY,IAAI;AAC/C,MAAI;AACH,SAAM,GAAG,SAAS;GAClB,MAAM,SAAS,MAAM,GAAG,OACtB,wDAAwD,SAAS,GAClE;AAED,OAAI,OAAO,aAAa,EACvB,OAAM,GAAG,OAAO,mBAAmB,SAAS,GAAG;AAGhD,UAAO,EACN,gBAAgB,OAAO,WAAW,OAAO,WAAW,IAAI,MACxD;EACD,UAAS;AACT,SAAM,GAAG,KAAK;EACd;CACD;;;;;;;;;CAUD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