pgsql-test 2.21.0 → 2.22.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/esm/index.js +1 -1
- package/esm/utils.js +18 -0
- package/index.d.ts +1 -1
- package/index.js +2 -1
- package/package.json +5 -5
- package/utils.d.ts +16 -0
- package/utils.js +19 -0
package/esm/index.js
CHANGED
package/esm/utils.js
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import { extractPgErrorFields, formatPgErrorFields, formatPgError } from '@pgpmjs/types';
|
|
2
2
|
// Re-export PostgreSQL error formatting utilities
|
|
3
3
|
export { extractPgErrorFields, formatPgErrorFields, formatPgError };
|
|
4
|
+
/**
|
|
5
|
+
* Extract the error code from an error message.
|
|
6
|
+
*
|
|
7
|
+
* Enhanced error messages from PgTestClient include additional context on subsequent lines
|
|
8
|
+
* (Where, Query, Values, etc.). This function returns only the first line, which contains
|
|
9
|
+
* the actual error code raised by PostgreSQL.
|
|
10
|
+
*
|
|
11
|
+
* @param message - The error message (may contain multiple lines with debug context)
|
|
12
|
+
* @returns The first line of the error message (the error code)
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Error message with enhanced context:
|
|
16
|
+
* // "NONEXISTENT_TYPE\nWhere: PL/pgSQL function...\nQuery: INSERT INTO..."
|
|
17
|
+
* getErrorCode(err.message) // => "NONEXISTENT_TYPE"
|
|
18
|
+
*/
|
|
19
|
+
export function getErrorCode(message) {
|
|
20
|
+
return message.split('\n')[0];
|
|
21
|
+
}
|
|
4
22
|
const uuidRegexp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
5
23
|
const idReplacement = (v, idHash) => {
|
|
6
24
|
if (!v)
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.snapshot = void 0;
|
|
17
|
+
exports.getErrorCode = exports.snapshot = void 0;
|
|
18
18
|
__exportStar(require("./admin"), exports);
|
|
19
19
|
__exportStar(require("./connect"), exports);
|
|
20
20
|
__exportStar(require("./manager"), exports);
|
|
@@ -22,3 +22,4 @@ __exportStar(require("./seed"), exports);
|
|
|
22
22
|
__exportStar(require("./test-client"), exports);
|
|
23
23
|
var utils_1 = require("./utils");
|
|
24
24
|
Object.defineProperty(exports, "snapshot", { enumerable: true, get: function () { return utils_1.snapshot; } });
|
|
25
|
+
Object.defineProperty(exports, "getErrorCode", { enumerable: true, get: function () { return utils_1.getErrorCode; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgsql-test",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "pgsql-test offers isolated, role-aware, and rollback-friendly PostgreSQL environments for integration tests — giving developers realistic test coverage without external state pollution",
|
|
6
6
|
"main": "index.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"test:watch": "jest --watch"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@pgpmjs/core": "4.7.
|
|
58
|
+
"@pgpmjs/core": "4.7.1",
|
|
59
59
|
"@types/pg": "^8.16.0",
|
|
60
60
|
"@types/pg-copy-streams": "^1.2.5",
|
|
61
61
|
"makage": "^0.1.10"
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"pg": "^8.16.3",
|
|
69
69
|
"pg-cache": "^1.6.14",
|
|
70
70
|
"pg-env": "^1.2.5",
|
|
71
|
-
"pgsql-client": "^1.1.
|
|
72
|
-
"pgsql-seed": "^0.2.
|
|
71
|
+
"pgsql-client": "^1.1.10",
|
|
72
|
+
"pgsql-seed": "^0.2.12"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "acb072b93704ad5218dd2c38306680f3750ead09"
|
|
75
75
|
}
|
package/utils.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { extractPgErrorFields, formatPgErrorFields, formatPgError, type PgErrorFields, type PgErrorContext } from '@pgpmjs/types';
|
|
2
2
|
export { extractPgErrorFields, formatPgErrorFields, formatPgError, type PgErrorFields, type PgErrorContext };
|
|
3
|
+
/**
|
|
4
|
+
* Extract the error code from an error message.
|
|
5
|
+
*
|
|
6
|
+
* Enhanced error messages from PgTestClient include additional context on subsequent lines
|
|
7
|
+
* (Where, Query, Values, etc.). This function returns only the first line, which contains
|
|
8
|
+
* the actual error code raised by PostgreSQL.
|
|
9
|
+
*
|
|
10
|
+
* @param message - The error message (may contain multiple lines with debug context)
|
|
11
|
+
* @returns The first line of the error message (the error code)
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Error message with enhanced context:
|
|
15
|
+
* // "NONEXISTENT_TYPE\nWhere: PL/pgSQL function...\nQuery: INSERT INTO..."
|
|
16
|
+
* getErrorCode(err.message) // => "NONEXISTENT_TYPE"
|
|
17
|
+
*/
|
|
18
|
+
export declare function getErrorCode(message: string): string;
|
|
3
19
|
export type IdHash = Record<string, number | string>;
|
|
4
20
|
type AnyObject = Record<string, any>;
|
|
5
21
|
export declare const pruneDates: (row: AnyObject) => AnyObject;
|
package/utils.js
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.snapshot = exports.createSnapshot = exports.prune = exports.defaultPruners = exports.composePruners = exports.pruneTokens = exports.prunePeoplestamps = exports.pruneSchemas = exports.pruneHashes = exports.pruneUUIDs = exports.pruneIdArrays = exports.pruneIds = exports.pruneDates = exports.formatPgError = exports.formatPgErrorFields = exports.extractPgErrorFields = void 0;
|
|
4
|
+
exports.getErrorCode = getErrorCode;
|
|
4
5
|
const types_1 = require("@pgpmjs/types");
|
|
5
6
|
Object.defineProperty(exports, "extractPgErrorFields", { enumerable: true, get: function () { return types_1.extractPgErrorFields; } });
|
|
6
7
|
Object.defineProperty(exports, "formatPgErrorFields", { enumerable: true, get: function () { return types_1.formatPgErrorFields; } });
|
|
7
8
|
Object.defineProperty(exports, "formatPgError", { enumerable: true, get: function () { return types_1.formatPgError; } });
|
|
9
|
+
/**
|
|
10
|
+
* Extract the error code from an error message.
|
|
11
|
+
*
|
|
12
|
+
* Enhanced error messages from PgTestClient include additional context on subsequent lines
|
|
13
|
+
* (Where, Query, Values, etc.). This function returns only the first line, which contains
|
|
14
|
+
* the actual error code raised by PostgreSQL.
|
|
15
|
+
*
|
|
16
|
+
* @param message - The error message (may contain multiple lines with debug context)
|
|
17
|
+
* @returns The first line of the error message (the error code)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Error message with enhanced context:
|
|
21
|
+
* // "NONEXISTENT_TYPE\nWhere: PL/pgSQL function...\nQuery: INSERT INTO..."
|
|
22
|
+
* getErrorCode(err.message) // => "NONEXISTENT_TYPE"
|
|
23
|
+
*/
|
|
24
|
+
function getErrorCode(message) {
|
|
25
|
+
return message.split('\n')[0];
|
|
26
|
+
}
|
|
8
27
|
const uuidRegexp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
9
28
|
const idReplacement = (v, idHash) => {
|
|
10
29
|
if (!v)
|