@voxpelli/pg-utils 2.0.0 → 2.2.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/lib/test-helpers.d.ts
CHANGED
|
@@ -4,12 +4,13 @@ export class PgTestHelpers {
|
|
|
4
4
|
initTables(): Promise<void>;
|
|
5
5
|
insertFixtures(): Promise<void>;
|
|
6
6
|
removeTables(): Promise<void>;
|
|
7
|
+
end(): Promise<void>;
|
|
7
8
|
#private;
|
|
8
9
|
}
|
|
9
10
|
export type PgTestHelpersOptions = {
|
|
10
11
|
connectionString: string;
|
|
11
12
|
fixtureFolder?: string | URL;
|
|
12
|
-
schema: string | URL | (() => import("umzug").Umzug<import("umzeption").UmzeptionContext<"pg", import("umzeption").FastifyPostgresStyleDb>>);
|
|
13
|
+
schema: string | URL | ((pool: Pool) => import("umzug").Umzug<import("umzeption").UmzeptionContext<"pg", import("umzeption").FastifyPostgresStyleDb>>);
|
|
13
14
|
tablesWithDependencies?: Array<string[] | string>;
|
|
14
15
|
};
|
|
15
16
|
import type { Pool } from 'pg';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["test-helpers.js"],"names":[],"mappings":"AAoBA;IAaE,qBADY,oBAAoB,EAiC/B;IAnCD,cADW,IAAI,CAAC,OAAO,CAAC,CACX;IAoEb,cADc,OAAO,CAAC,IAAI,CAAC,CAiB1B;IAGD,kBADc,OAAO,CAAC,IAAI,CAAC,CAM1B;IAGD,gBADc,OAAO,CAAC,IAAI,CAAC,CAM1B;;CACF;;
|
|
1
|
+
{"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["test-helpers.js"],"names":[],"mappings":"AAoBA;IAaE,qBADY,oBAAoB,EAiC/B;IAnCD,cADW,IAAI,CAAC,OAAO,CAAC,CACX;IAoEb,cADc,OAAO,CAAC,IAAI,CAAC,CAiB1B;IAGD,kBADc,OAAO,CAAC,IAAI,CAAC,CAM1B;IAGD,gBADc,OAAO,CAAC,IAAI,CAAC,CAM1B;IAGD,OADc,OAAO,CAAC,IAAI,CAAC,CAG1B;;CACF;;sBA1Ha,MAAM;oBACN,MAAM,GAAG,GAAG;YACZ,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,OAAO,EAAE,KAAK,CAAC,OAAO,WAAW,EAAE,gBAAgB,CAAC,IAAI,EAAE,OAAO,WAAW,EAAE,sBAAsB,CAAC,CAAC,CAAC;6BAC9I,KAAK,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC;;0BAPZ,IAAI"}
|
package/lib/test-helpers.js
CHANGED
|
@@ -14,7 +14,7 @@ import { createPgPool, isStringArray, TypeNeverError } from './utils.js';
|
|
|
14
14
|
* @typedef PgTestHelpersOptions
|
|
15
15
|
* @property {string} connectionString
|
|
16
16
|
* @property {string | URL} [fixtureFolder]
|
|
17
|
-
* @property {string | URL | (() => import('umzug').Umzug<import('umzeption').UmzeptionContext<'pg', import('umzeption').FastifyPostgresStyleDb>>)} schema
|
|
17
|
+
* @property {string | URL | ((pool: Pool) => import('umzug').Umzug<import('umzeption').UmzeptionContext<'pg', import('umzeption').FastifyPostgresStyleDb>>)} schema
|
|
18
18
|
* @property {Array<string[] | string>} [tablesWithDependencies]
|
|
19
19
|
*/
|
|
20
20
|
|
|
@@ -88,8 +88,8 @@ export class PgTestHelpers {
|
|
|
88
88
|
Array.isArray(name)
|
|
89
89
|
? this.#removeTablesByName(name)
|
|
90
90
|
: this.queryPromise('DROP TABLE IF EXISTS ' + name + ' CASCADE').catch(cause => {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
throw new Error(`Failed to drop table: ${name}`, { cause });
|
|
92
|
+
})
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -99,7 +99,7 @@ export class PgTestHelpers {
|
|
|
99
99
|
async initTables () {
|
|
100
100
|
try {
|
|
101
101
|
if (typeof this.#schema === 'function') {
|
|
102
|
-
await this.#schema().up();
|
|
102
|
+
await this.#schema(this.#pool).up();
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -129,4 +129,9 @@ export class PgTestHelpers {
|
|
|
129
129
|
}
|
|
130
130
|
await this.#removeTablesByName(await this.#getTableNames());
|
|
131
131
|
}
|
|
132
|
+
|
|
133
|
+
/** @returns {Promise<void>} */
|
|
134
|
+
async end () {
|
|
135
|
+
await this.#pool.end();
|
|
136
|
+
}
|
|
132
137
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voxpelli/pg-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": " My personal database utils / helpers for Postgres",
|
|
5
5
|
"homepage": "http://github.com/voxpelli/pg-utils",
|
|
6
6
|
"repository": {
|
|
@@ -47,22 +47,22 @@
|
|
|
47
47
|
"@types/chai": "^4.3.20",
|
|
48
48
|
"@types/chai-as-promised": "^7.1.8",
|
|
49
49
|
"@types/mocha": "^10.0.10",
|
|
50
|
-
"@types/node": "^20.17.
|
|
50
|
+
"@types/node": "^20.17.31",
|
|
51
51
|
"@types/pg-copy-streams": "^1.2.5",
|
|
52
|
-
"@voxpelli/eslint-config": "^
|
|
53
|
-
"@voxpelli/tsconfig": "^15.1.
|
|
52
|
+
"@voxpelli/eslint-config": "^23.0.0",
|
|
53
|
+
"@voxpelli/tsconfig": "^15.1.2",
|
|
54
54
|
"c8": "^10.1.3",
|
|
55
55
|
"chai": "^4.5.0",
|
|
56
56
|
"chai-as-promised": "^7.1.2",
|
|
57
|
-
"dotenv": "^16.
|
|
58
|
-
"eslint": "^9.
|
|
57
|
+
"dotenv": "^16.5.0",
|
|
58
|
+
"eslint": "^9.25.1",
|
|
59
59
|
"husky": "^9.1.7",
|
|
60
60
|
"installed-check": "^9.3.0",
|
|
61
|
-
"knip": "^5.
|
|
61
|
+
"knip": "^5.50.5",
|
|
62
62
|
"mocha": "^11.1.0",
|
|
63
63
|
"npm-run-all2": "^7.0.2",
|
|
64
64
|
"type-coverage": "^2.29.7",
|
|
65
|
-
"typescript": "~5.
|
|
65
|
+
"typescript": "~5.8.3",
|
|
66
66
|
"validate-conventional-commit": "^1.0.4"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|