@voxpelli/pg-utils 1.2.0 → 2.0.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 +1 -1
- package/lib/test-helpers.d.ts.map +1 -1
- package/lib/test-helpers.js +7 -7
- package/package.json +10 -10
package/lib/test-helpers.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export class PgTestHelpers {
|
|
|
9
9
|
export type PgTestHelpersOptions = {
|
|
10
10
|
connectionString: string;
|
|
11
11
|
fixtureFolder?: string | URL;
|
|
12
|
-
schema: string | URL | import("umzug").Umzug<import("umzeption").UmzeptionContext<"pg", import("umzeption").FastifyPostgresStyleDb
|
|
12
|
+
schema: string | URL | (() => import("umzug").Umzug<import("umzeption").UmzeptionContext<"pg", import("umzeption").FastifyPostgresStyleDb>>);
|
|
13
13
|
tablesWithDependencies?: Array<string[] | string>;
|
|
14
14
|
};
|
|
15
15
|
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;;sBArHa,MAAM;oBACN,MAAM,GAAG,GAAG;YACZ,MAAM,GAAG,GAAG,GAAG,OAAO,OAAO,EAAE,KAAK,CAAC,OAAO,WAAW,EAAE,gBAAgB,CAAC,IAAI,EAAE,OAAO,WAAW,EAAE,sBAAsB,CAAC,CAAC;
|
|
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;;sBArHa,MAAM;oBACN,MAAM,GAAG,GAAG;YACZ,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,OAAO,OAAO,EAAE,KAAK,CAAC,OAAO,WAAW,EAAE,gBAAgB,CAAC,IAAI,EAAE,OAAO,WAAW,EAAE,sBAAsB,CAAC,CAAC,CAAC;6BACpI,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 | (() => import('umzug').Umzug<import('umzeption').UmzeptionContext<'pg', import('umzeption').FastifyPostgresStyleDb>>)} schema
|
|
18
18
|
* @property {Array<string[] | string>} [tablesWithDependencies]
|
|
19
19
|
*/
|
|
20
20
|
|
|
@@ -49,8 +49,8 @@ export class PgTestHelpers {
|
|
|
49
49
|
if (fixtureFolder && typeof fixtureFolder !== 'string' && !(fixtureFolder instanceof URL)) {
|
|
50
50
|
throw new TypeNeverError(fixtureFolder, 'Invalid fixtureFolder, expected a string');
|
|
51
51
|
}
|
|
52
|
-
if (typeof schema !== 'string' && typeof schema !== 'object') {
|
|
53
|
-
throw new TypeNeverError(schema, 'Invalid schema, expected a string or
|
|
52
|
+
if (typeof schema !== 'string' && typeof schema !== 'object' && typeof schema !== 'function') {
|
|
53
|
+
throw new TypeNeverError(schema, 'Invalid schema, expected a string, object or function');
|
|
54
54
|
}
|
|
55
55
|
if (tablesWithDependencies && !Array.isArray(tablesWithDependencies)) {
|
|
56
56
|
throw new TypeNeverError(tablesWithDependencies, 'Invalid tablesWithDependencies, expected an array');
|
|
@@ -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
|
}
|
|
@@ -98,8 +98,8 @@ export class PgTestHelpers {
|
|
|
98
98
|
/** @returns {Promise<void>} */
|
|
99
99
|
async initTables () {
|
|
100
100
|
try {
|
|
101
|
-
if (typeof this.#schema === '
|
|
102
|
-
await this.#schema.up();
|
|
101
|
+
if (typeof this.#schema === 'function') {
|
|
102
|
+
await this.#schema().up();
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
105
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voxpelli/pg-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.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.17",
|
|
51
51
|
"@types/pg-copy-streams": "^1.2.5",
|
|
52
52
|
"@voxpelli/eslint-config": "^22.2.0",
|
|
53
|
-
"@voxpelli/tsconfig": "^15.1.
|
|
54
|
-
"c8": "^10.1.
|
|
53
|
+
"@voxpelli/tsconfig": "^15.1.1",
|
|
54
|
+
"c8": "^10.1.3",
|
|
55
55
|
"chai": "^4.5.0",
|
|
56
56
|
"chai-as-promised": "^7.1.2",
|
|
57
|
-
"dotenv": "^16.4.
|
|
58
|
-
"eslint": "^9.
|
|
57
|
+
"dotenv": "^16.4.7",
|
|
58
|
+
"eslint": "^9.19.0",
|
|
59
59
|
"husky": "^9.1.7",
|
|
60
60
|
"installed-check": "^9.3.0",
|
|
61
|
-
"knip": "^5.
|
|
62
|
-
"mocha": "^
|
|
63
|
-
"npm-run-all2": "^7.0.
|
|
61
|
+
"knip": "^5.43.6",
|
|
62
|
+
"mocha": "^11.1.0",
|
|
63
|
+
"npm-run-all2": "^7.0.2",
|
|
64
64
|
"type-coverage": "^2.29.7",
|
|
65
|
-
"typescript": "~5.7.
|
|
65
|
+
"typescript": "~5.7.3",
|
|
66
66
|
"validate-conventional-commit": "^1.0.4"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|