@pgpmjs/types 2.12.8 → 2.14.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/README.md +5 -22
- package/esm/index.js +1 -0
- package/esm/pg-error-format.js +121 -0
- package/esm/pgpm.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +4 -4
- package/pg-error-format.d.ts +77 -0
- package/pg-error-format.js +126 -0
- package/pgpm.d.ts +7 -1
- package/pgpm.js +1 -0
package/README.md
CHANGED
|
@@ -39,9 +39,14 @@ Common issues and solutions for pgpm, PostgreSQL, and testing.
|
|
|
39
39
|
|
|
40
40
|
## Related Constructive Tooling
|
|
41
41
|
|
|
42
|
+
### 📦 Package Management
|
|
43
|
+
|
|
44
|
+
* [pgpm](https://github.com/constructive-io/constructive/tree/main/pgpm/pgpm): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
|
|
45
|
+
|
|
42
46
|
### 🧪 Testing
|
|
43
47
|
|
|
44
48
|
* [pgsql-test](https://github.com/constructive-io/constructive/tree/main/postgres/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
|
|
49
|
+
* [pgsql-seed](https://github.com/constructive-io/constructive/tree/main/postgres/pgsql-seed): **🌱 PostgreSQL seeding utilities** for CSV, JSON, SQL data loading, and pgpm deployment.
|
|
45
50
|
* [supabase-test](https://github.com/constructive-io/constructive/tree/main/postgres/supabase-test): **🧪 Supabase-native test harness** preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.
|
|
46
51
|
* [graphile-test](https://github.com/constructive-io/constructive/tree/main/graphile/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts.
|
|
47
52
|
* [pg-query-context](https://github.com/constructive-io/constructive/tree/main/postgres/pg-query-context): **🔒 Session context injection** to add session-local context (e.g., `SET LOCAL`) into queries—ideal for setting `role`, `jwt.claims`, and other session settings.
|
|
@@ -55,28 +60,6 @@ Common issues and solutions for pgpm, PostgreSQL, and testing.
|
|
|
55
60
|
* [@pgsql/types](https://www.npmjs.com/package/@pgsql/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript.
|
|
56
61
|
* [@pgsql/utils](https://www.npmjs.com/package/@pgsql/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees.
|
|
57
62
|
|
|
58
|
-
### 🚀 API & Dev Tools
|
|
59
|
-
|
|
60
|
-
* [@constructive-io/graphql-server](https://github.com/constructive-io/constructive/tree/main/graphql/server): **⚡ Express-based API server** powered by PostGraphile to expose a secure, scalable GraphQL API over your Postgres database.
|
|
61
|
-
* [@constructive-io/graphql-explorer](https://github.com/constructive-io/constructive/tree/main/graphql/explorer): **🔎 Visual API explorer** with GraphiQL for browsing across all databases and schemas—useful for debugging, documentation, and API prototyping.
|
|
62
|
-
|
|
63
|
-
### 🔁 Streaming & Uploads
|
|
64
|
-
|
|
65
|
-
* [etag-hash](https://github.com/constructive-io/constructive/tree/main/streaming/etag-hash): **🏷️ S3-compatible ETags** created by streaming and hashing file uploads in chunks.
|
|
66
|
-
* [etag-stream](https://github.com/constructive-io/constructive/tree/main/streaming/etag-stream): **🔄 ETag computation** via Node stream transformer during upload or transfer.
|
|
67
|
-
* [uuid-hash](https://github.com/constructive-io/constructive/tree/main/streaming/uuid-hash): **🆔 Deterministic UUIDs** generated from hashed content, great for deduplication and asset referencing.
|
|
68
|
-
* [uuid-stream](https://github.com/constructive-io/constructive/tree/main/streaming/uuid-stream): **🌊 Streaming UUID generation** based on piped file content—ideal for upload pipelines.
|
|
69
|
-
* [@constructive-io/s3-streamer](https://github.com/constructive-io/constructive/tree/main/streaming/s3-streamer): **📤 Direct S3 streaming** for large files with support for metadata injection and content validation.
|
|
70
|
-
* [@constructive-io/upload-names](https://github.com/constructive-io/constructive/tree/main/streaming/upload-names): **📂 Collision-resistant filenames** utility for structured and unique file names for uploads.
|
|
71
|
-
|
|
72
|
-
### 🧰 CLI & Codegen
|
|
73
|
-
|
|
74
|
-
* [pgpm](https://github.com/constructive-io/constructive/tree/main/pgpm/pgpm): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
|
|
75
|
-
* [@constructive-io/cli](https://github.com/constructive-io/constructive/tree/main/packages/cli): **🖥️ Command-line toolkit** for managing Constructive projects—supports database scaffolding, migrations, seeding, code generation, and automation.
|
|
76
|
-
* [@constructive-io/graphql-codegen](https://github.com/constructive-io/constructive/tree/main/graphql/codegen): **✨ GraphQL code generation** (types, operations, SDK) from schema/endpoint introspection.
|
|
77
|
-
* [@constructive-io/query-builder](https://github.com/constructive-io/constructive/tree/main/packages/query-builder): **🏗️ SQL constructor** providing a robust TypeScript-based query builder for dynamic generation of `SELECT`, `INSERT`, `UPDATE`, `DELETE`, and stored procedure calls—supports advanced SQL features like `JOIN`, `GROUP BY`, and schema-qualified queries.
|
|
78
|
-
* [@constructive-io/graphql-query](https://github.com/constructive-io/constructive/tree/main/graphql/query): **🧩 Fluent GraphQL builder** for PostGraphile schemas. ⚡ Schema-aware via introspection, 🧩 composable and ergonomic for building deeply nested queries.
|
|
79
|
-
|
|
80
63
|
## Credits
|
|
81
64
|
|
|
82
65
|
**🛠 Built by the [Constructive](https://constructive.io) team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on [GitHub](https://github.com/constructive-io).**
|
package/esm/index.js
CHANGED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL Error Formatting Utilities
|
|
3
|
+
*
|
|
4
|
+
* Extracts and formats extended PostgreSQL error fields from pg library errors.
|
|
5
|
+
* These fields provide additional context for debugging database errors.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Extract PostgreSQL error fields from an error object.
|
|
9
|
+
* Returns null if the error doesn't appear to be a PostgreSQL error.
|
|
10
|
+
*
|
|
11
|
+
* @param err - The error object to extract fields from
|
|
12
|
+
* @returns PgErrorFields if the error has PG fields, null otherwise
|
|
13
|
+
*/
|
|
14
|
+
export function extractPgErrorFields(err) {
|
|
15
|
+
if (!err || typeof err !== 'object') {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const e = err;
|
|
19
|
+
// Check if this looks like a PostgreSQL error (has code or detail)
|
|
20
|
+
if (!e.code && !e.detail && !e.where) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const fields = {};
|
|
24
|
+
if (typeof e.code === 'string')
|
|
25
|
+
fields.code = e.code;
|
|
26
|
+
if (typeof e.detail === 'string')
|
|
27
|
+
fields.detail = e.detail;
|
|
28
|
+
if (typeof e.hint === 'string')
|
|
29
|
+
fields.hint = e.hint;
|
|
30
|
+
if (typeof e.where === 'string')
|
|
31
|
+
fields.where = e.where;
|
|
32
|
+
if (typeof e.position === 'string')
|
|
33
|
+
fields.position = e.position;
|
|
34
|
+
if (typeof e.internalPosition === 'string')
|
|
35
|
+
fields.internalPosition = e.internalPosition;
|
|
36
|
+
if (typeof e.internalQuery === 'string')
|
|
37
|
+
fields.internalQuery = e.internalQuery;
|
|
38
|
+
if (typeof e.schema === 'string')
|
|
39
|
+
fields.schema = e.schema;
|
|
40
|
+
if (typeof e.table === 'string')
|
|
41
|
+
fields.table = e.table;
|
|
42
|
+
if (typeof e.column === 'string')
|
|
43
|
+
fields.column = e.column;
|
|
44
|
+
if (typeof e.dataType === 'string')
|
|
45
|
+
fields.dataType = e.dataType;
|
|
46
|
+
if (typeof e.constraint === 'string')
|
|
47
|
+
fields.constraint = e.constraint;
|
|
48
|
+
if (typeof e.file === 'string')
|
|
49
|
+
fields.file = e.file;
|
|
50
|
+
if (typeof e.line === 'string')
|
|
51
|
+
fields.line = e.line;
|
|
52
|
+
if (typeof e.routine === 'string')
|
|
53
|
+
fields.routine = e.routine;
|
|
54
|
+
return fields;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Format PostgreSQL error fields into an array of human-readable lines.
|
|
58
|
+
* Only includes fields that are present and non-empty.
|
|
59
|
+
*
|
|
60
|
+
* @param fields - The PostgreSQL error fields to format
|
|
61
|
+
* @returns Array of formatted lines
|
|
62
|
+
*/
|
|
63
|
+
export function formatPgErrorFields(fields) {
|
|
64
|
+
const lines = [];
|
|
65
|
+
if (fields.detail)
|
|
66
|
+
lines.push(`Detail: ${fields.detail}`);
|
|
67
|
+
if (fields.hint)
|
|
68
|
+
lines.push(`Hint: ${fields.hint}`);
|
|
69
|
+
if (fields.where)
|
|
70
|
+
lines.push(`Where: ${fields.where}`);
|
|
71
|
+
if (fields.schema)
|
|
72
|
+
lines.push(`Schema: ${fields.schema}`);
|
|
73
|
+
if (fields.table)
|
|
74
|
+
lines.push(`Table: ${fields.table}`);
|
|
75
|
+
if (fields.column)
|
|
76
|
+
lines.push(`Column: ${fields.column}`);
|
|
77
|
+
if (fields.dataType)
|
|
78
|
+
lines.push(`Data Type: ${fields.dataType}`);
|
|
79
|
+
if (fields.constraint)
|
|
80
|
+
lines.push(`Constraint: ${fields.constraint}`);
|
|
81
|
+
if (fields.position)
|
|
82
|
+
lines.push(`Position: ${fields.position}`);
|
|
83
|
+
if (fields.internalQuery)
|
|
84
|
+
lines.push(`Internal Query: ${fields.internalQuery}`);
|
|
85
|
+
if (fields.internalPosition)
|
|
86
|
+
lines.push(`Internal Position: ${fields.internalPosition}`);
|
|
87
|
+
return lines;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Format a PostgreSQL error with full context for debugging.
|
|
91
|
+
* Combines the original error message with extended PostgreSQL fields
|
|
92
|
+
* and optional query context.
|
|
93
|
+
*
|
|
94
|
+
* @param err - The error object
|
|
95
|
+
* @param context - Optional query context (SQL and parameters)
|
|
96
|
+
* @returns Formatted error string with all available information
|
|
97
|
+
*/
|
|
98
|
+
export function formatPgError(err, context) {
|
|
99
|
+
if (!err || typeof err !== 'object') {
|
|
100
|
+
return String(err);
|
|
101
|
+
}
|
|
102
|
+
const e = err;
|
|
103
|
+
const message = typeof e.message === 'string' ? e.message : String(err);
|
|
104
|
+
const lines = [message];
|
|
105
|
+
// Add PostgreSQL error fields
|
|
106
|
+
const pgFields = extractPgErrorFields(err);
|
|
107
|
+
if (pgFields) {
|
|
108
|
+
const fieldLines = formatPgErrorFields(pgFields);
|
|
109
|
+
if (fieldLines.length > 0) {
|
|
110
|
+
lines.push(...fieldLines);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Add query context
|
|
114
|
+
if (context?.query) {
|
|
115
|
+
lines.push(`Query: ${context.query}`);
|
|
116
|
+
}
|
|
117
|
+
if (context?.values !== undefined) {
|
|
118
|
+
lines.push(`Values: ${JSON.stringify(context.values)}`);
|
|
119
|
+
}
|
|
120
|
+
return lines.join('\n');
|
|
121
|
+
}
|
package/esm/pgpm.js
CHANGED
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./error"), exports);
|
|
18
18
|
__exportStar(require("./error-factory"), exports);
|
|
19
|
+
__exportStar(require("./pg-error-format"), exports);
|
|
19
20
|
__exportStar(require("./pgpm"), exports);
|
|
20
21
|
__exportStar(require("./jobs"), exports);
|
|
21
22
|
__exportStar(require("./update"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpmjs/types",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "PGPM types",
|
|
6
6
|
"main": "index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"test:watch": "jest --watch"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"pg-env": "^1.2.
|
|
32
|
+
"pg-env": "^1.2.5"
|
|
33
33
|
},
|
|
34
34
|
"keywords": [
|
|
35
35
|
"types",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"migrations"
|
|
41
41
|
],
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"makage": "^0.1.
|
|
43
|
+
"makage": "^0.1.10"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "f2f9c9851beff3214790dfca371e4ca7f6c1373f"
|
|
46
46
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL Error Formatting Utilities
|
|
3
|
+
*
|
|
4
|
+
* Extracts and formats extended PostgreSQL error fields from pg library errors.
|
|
5
|
+
* These fields provide additional context for debugging database errors.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Extended PostgreSQL error fields available from pg-protocol.
|
|
9
|
+
* These fields are populated by PostgreSQL when an error occurs.
|
|
10
|
+
*/
|
|
11
|
+
export interface PgErrorFields {
|
|
12
|
+
/** PostgreSQL error code (e.g., '42P01' for undefined table) */
|
|
13
|
+
code?: string;
|
|
14
|
+
/** Additional detail about the error */
|
|
15
|
+
detail?: string;
|
|
16
|
+
/** Suggestion for fixing the error */
|
|
17
|
+
hint?: string;
|
|
18
|
+
/** PL/pgSQL call stack or context */
|
|
19
|
+
where?: string;
|
|
20
|
+
/** Character position in the query where the error occurred */
|
|
21
|
+
position?: string;
|
|
22
|
+
/** Position in internal query */
|
|
23
|
+
internalPosition?: string;
|
|
24
|
+
/** Internal query that caused the error */
|
|
25
|
+
internalQuery?: string;
|
|
26
|
+
/** Schema name related to the error */
|
|
27
|
+
schema?: string;
|
|
28
|
+
/** Table name related to the error */
|
|
29
|
+
table?: string;
|
|
30
|
+
/** Column name related to the error */
|
|
31
|
+
column?: string;
|
|
32
|
+
/** Data type name related to the error */
|
|
33
|
+
dataType?: string;
|
|
34
|
+
/** Constraint name related to the error */
|
|
35
|
+
constraint?: string;
|
|
36
|
+
/** Source file in PostgreSQL where error was generated */
|
|
37
|
+
file?: string;
|
|
38
|
+
/** Line number in PostgreSQL source file */
|
|
39
|
+
line?: string;
|
|
40
|
+
/** PostgreSQL routine that generated the error */
|
|
41
|
+
routine?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Context about the query that caused the error.
|
|
45
|
+
*/
|
|
46
|
+
export interface PgErrorContext {
|
|
47
|
+
/** The SQL query that was executed */
|
|
48
|
+
query?: string;
|
|
49
|
+
/** Parameter values passed to the query */
|
|
50
|
+
values?: any[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Extract PostgreSQL error fields from an error object.
|
|
54
|
+
* Returns null if the error doesn't appear to be a PostgreSQL error.
|
|
55
|
+
*
|
|
56
|
+
* @param err - The error object to extract fields from
|
|
57
|
+
* @returns PgErrorFields if the error has PG fields, null otherwise
|
|
58
|
+
*/
|
|
59
|
+
export declare function extractPgErrorFields(err: unknown): PgErrorFields | null;
|
|
60
|
+
/**
|
|
61
|
+
* Format PostgreSQL error fields into an array of human-readable lines.
|
|
62
|
+
* Only includes fields that are present and non-empty.
|
|
63
|
+
*
|
|
64
|
+
* @param fields - The PostgreSQL error fields to format
|
|
65
|
+
* @returns Array of formatted lines
|
|
66
|
+
*/
|
|
67
|
+
export declare function formatPgErrorFields(fields: PgErrorFields): string[];
|
|
68
|
+
/**
|
|
69
|
+
* Format a PostgreSQL error with full context for debugging.
|
|
70
|
+
* Combines the original error message with extended PostgreSQL fields
|
|
71
|
+
* and optional query context.
|
|
72
|
+
*
|
|
73
|
+
* @param err - The error object
|
|
74
|
+
* @param context - Optional query context (SQL and parameters)
|
|
75
|
+
* @returns Formatted error string with all available information
|
|
76
|
+
*/
|
|
77
|
+
export declare function formatPgError(err: unknown, context?: PgErrorContext): string;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PostgreSQL Error Formatting Utilities
|
|
4
|
+
*
|
|
5
|
+
* Extracts and formats extended PostgreSQL error fields from pg library errors.
|
|
6
|
+
* These fields provide additional context for debugging database errors.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.extractPgErrorFields = extractPgErrorFields;
|
|
10
|
+
exports.formatPgErrorFields = formatPgErrorFields;
|
|
11
|
+
exports.formatPgError = formatPgError;
|
|
12
|
+
/**
|
|
13
|
+
* Extract PostgreSQL error fields from an error object.
|
|
14
|
+
* Returns null if the error doesn't appear to be a PostgreSQL error.
|
|
15
|
+
*
|
|
16
|
+
* @param err - The error object to extract fields from
|
|
17
|
+
* @returns PgErrorFields if the error has PG fields, null otherwise
|
|
18
|
+
*/
|
|
19
|
+
function extractPgErrorFields(err) {
|
|
20
|
+
if (!err || typeof err !== 'object') {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const e = err;
|
|
24
|
+
// Check if this looks like a PostgreSQL error (has code or detail)
|
|
25
|
+
if (!e.code && !e.detail && !e.where) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const fields = {};
|
|
29
|
+
if (typeof e.code === 'string')
|
|
30
|
+
fields.code = e.code;
|
|
31
|
+
if (typeof e.detail === 'string')
|
|
32
|
+
fields.detail = e.detail;
|
|
33
|
+
if (typeof e.hint === 'string')
|
|
34
|
+
fields.hint = e.hint;
|
|
35
|
+
if (typeof e.where === 'string')
|
|
36
|
+
fields.where = e.where;
|
|
37
|
+
if (typeof e.position === 'string')
|
|
38
|
+
fields.position = e.position;
|
|
39
|
+
if (typeof e.internalPosition === 'string')
|
|
40
|
+
fields.internalPosition = e.internalPosition;
|
|
41
|
+
if (typeof e.internalQuery === 'string')
|
|
42
|
+
fields.internalQuery = e.internalQuery;
|
|
43
|
+
if (typeof e.schema === 'string')
|
|
44
|
+
fields.schema = e.schema;
|
|
45
|
+
if (typeof e.table === 'string')
|
|
46
|
+
fields.table = e.table;
|
|
47
|
+
if (typeof e.column === 'string')
|
|
48
|
+
fields.column = e.column;
|
|
49
|
+
if (typeof e.dataType === 'string')
|
|
50
|
+
fields.dataType = e.dataType;
|
|
51
|
+
if (typeof e.constraint === 'string')
|
|
52
|
+
fields.constraint = e.constraint;
|
|
53
|
+
if (typeof e.file === 'string')
|
|
54
|
+
fields.file = e.file;
|
|
55
|
+
if (typeof e.line === 'string')
|
|
56
|
+
fields.line = e.line;
|
|
57
|
+
if (typeof e.routine === 'string')
|
|
58
|
+
fields.routine = e.routine;
|
|
59
|
+
return fields;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Format PostgreSQL error fields into an array of human-readable lines.
|
|
63
|
+
* Only includes fields that are present and non-empty.
|
|
64
|
+
*
|
|
65
|
+
* @param fields - The PostgreSQL error fields to format
|
|
66
|
+
* @returns Array of formatted lines
|
|
67
|
+
*/
|
|
68
|
+
function formatPgErrorFields(fields) {
|
|
69
|
+
const lines = [];
|
|
70
|
+
if (fields.detail)
|
|
71
|
+
lines.push(`Detail: ${fields.detail}`);
|
|
72
|
+
if (fields.hint)
|
|
73
|
+
lines.push(`Hint: ${fields.hint}`);
|
|
74
|
+
if (fields.where)
|
|
75
|
+
lines.push(`Where: ${fields.where}`);
|
|
76
|
+
if (fields.schema)
|
|
77
|
+
lines.push(`Schema: ${fields.schema}`);
|
|
78
|
+
if (fields.table)
|
|
79
|
+
lines.push(`Table: ${fields.table}`);
|
|
80
|
+
if (fields.column)
|
|
81
|
+
lines.push(`Column: ${fields.column}`);
|
|
82
|
+
if (fields.dataType)
|
|
83
|
+
lines.push(`Data Type: ${fields.dataType}`);
|
|
84
|
+
if (fields.constraint)
|
|
85
|
+
lines.push(`Constraint: ${fields.constraint}`);
|
|
86
|
+
if (fields.position)
|
|
87
|
+
lines.push(`Position: ${fields.position}`);
|
|
88
|
+
if (fields.internalQuery)
|
|
89
|
+
lines.push(`Internal Query: ${fields.internalQuery}`);
|
|
90
|
+
if (fields.internalPosition)
|
|
91
|
+
lines.push(`Internal Position: ${fields.internalPosition}`);
|
|
92
|
+
return lines;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Format a PostgreSQL error with full context for debugging.
|
|
96
|
+
* Combines the original error message with extended PostgreSQL fields
|
|
97
|
+
* and optional query context.
|
|
98
|
+
*
|
|
99
|
+
* @param err - The error object
|
|
100
|
+
* @param context - Optional query context (SQL and parameters)
|
|
101
|
+
* @returns Formatted error string with all available information
|
|
102
|
+
*/
|
|
103
|
+
function formatPgError(err, context) {
|
|
104
|
+
if (!err || typeof err !== 'object') {
|
|
105
|
+
return String(err);
|
|
106
|
+
}
|
|
107
|
+
const e = err;
|
|
108
|
+
const message = typeof e.message === 'string' ? e.message : String(err);
|
|
109
|
+
const lines = [message];
|
|
110
|
+
// Add PostgreSQL error fields
|
|
111
|
+
const pgFields = extractPgErrorFields(err);
|
|
112
|
+
if (pgFields) {
|
|
113
|
+
const fieldLines = formatPgErrorFields(pgFields);
|
|
114
|
+
if (fieldLines.length > 0) {
|
|
115
|
+
lines.push(...fieldLines);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Add query context
|
|
119
|
+
if (context?.query) {
|
|
120
|
+
lines.push(`Query: ${context.query}`);
|
|
121
|
+
}
|
|
122
|
+
if (context?.values !== undefined) {
|
|
123
|
+
lines.push(`Values: ${JSON.stringify(context.values)}`);
|
|
124
|
+
}
|
|
125
|
+
return lines.join('\n');
|
|
126
|
+
}
|
package/pgpm.d.ts
CHANGED
|
@@ -96,10 +96,16 @@ export interface ServerOptions {
|
|
|
96
96
|
/** Whether to enforce strict authentication */
|
|
97
97
|
strictAuth?: boolean;
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Storage provider type for CDN/bucket operations
|
|
101
|
+
*/
|
|
102
|
+
export type BucketProvider = 's3' | 'minio' | 'gcs';
|
|
99
103
|
/**
|
|
100
104
|
* CDN and file storage configuration
|
|
101
105
|
*/
|
|
102
106
|
export interface CDNOptions {
|
|
107
|
+
/** Storage provider type (s3, minio, gcs). Defaults to 'minio' for local dev */
|
|
108
|
+
provider?: BucketProvider;
|
|
103
109
|
/** S3 bucket name for file storage */
|
|
104
110
|
bucketName?: string;
|
|
105
111
|
/** AWS region for S3 bucket */
|
|
@@ -108,7 +114,7 @@ export interface CDNOptions {
|
|
|
108
114
|
awsAccessKey?: string;
|
|
109
115
|
/** AWS secret key for S3 */
|
|
110
116
|
awsSecretKey?: string;
|
|
111
|
-
/** MinIO endpoint URL for local development */
|
|
117
|
+
/** MinIO endpoint URL for local development (only used when provider is 'minio') */
|
|
112
118
|
minioEndpoint?: string;
|
|
113
119
|
}
|
|
114
120
|
/**
|