@prisma-next/driver-postgres 0.3.0-dev.7 → 0.3.0-dev.70
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/LICENSE +201 -0
- package/README.md +19 -19
- package/dist/control.d.mts +30 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +68 -0
- package/dist/control.mjs.map +1 -0
- package/dist/normalize-error-BU6yV-XB.mjs +125 -0
- package/dist/normalize-error-BU6yV-XB.mjs.map +1 -0
- package/dist/runtime.d.mts +36 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +339 -0
- package/dist/runtime.mjs.map +1 -0
- package/package.json +29 -28
- package/src/exports/control.ts +2 -1
- package/src/exports/runtime.ts +144 -20
- package/src/postgres-driver.ts +272 -104
- package/dist/callback-to-promise.d.ts +0 -7
- package/dist/callback-to-promise.d.ts.map +0 -1
- package/dist/chunk-M4WUUVS5.js +0 -116
- package/dist/chunk-M4WUUVS5.js.map +0 -1
- package/dist/core/descriptor-meta.d.ts +0 -9
- package/dist/core/descriptor-meta.d.ts.map +0 -1
- package/dist/exports/control.d.ts +0 -26
- package/dist/exports/control.d.ts.map +0 -1
- package/dist/exports/control.js +0 -66
- package/dist/exports/control.js.map +0 -1
- package/dist/exports/runtime.d.ts +0 -17
- package/dist/exports/runtime.d.ts.map +0 -1
- package/dist/exports/runtime.js +0 -189
- package/dist/exports/runtime.js.map +0 -1
- package/dist/normalize-error.d.ts +0 -60
- package/dist/normalize-error.d.ts.map +0 -1
- package/dist/postgres-driver.d.ts +0 -22
- package/dist/postgres-driver.d.ts.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2026] [Prisma Data, Inc]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ PostgreSQL driver for Prisma Next.
|
|
|
12
12
|
|
|
13
13
|
The PostgreSQL driver provides transport and connection management for PostgreSQL databases. It implements the `SqlDriver` interface for executing SQL statements, explaining queries, and managing connections.
|
|
14
14
|
|
|
15
|
-
Drivers are transport-agnostic: they own pooling, connection management, and transport protocol (TCP, HTTP, etc.), but contain no dialect-specific logic. All dialect behavior lives in adapters.
|
|
15
|
+
In Prisma Next, "driver" refers to the Prisma Next interface (not the underlying `pg` library). Drivers are transport-agnostic: they own pooling, connection management, and transport protocol (TCP, HTTP, etc.), but contain no dialect-specific logic. All dialect behavior lives in adapters. Instantiation is separate from connection; `create()` returns an unbound driver, `connect(binding)` binds at the boundary ([ADR 159](../../../../docs/architecture%20docs/adrs/ADR%20159%20-%20Driver%20Terminology%20and%20Lifecycle.md)).
|
|
16
16
|
|
|
17
17
|
This package spans multiple planes:
|
|
18
18
|
- **Migration plane** (`src/exports/control.ts`): Control plane entry point for driver descriptors
|
|
@@ -74,7 +74,7 @@ flowchart TD
|
|
|
74
74
|
|
|
75
75
|
## Dependencies
|
|
76
76
|
|
|
77
|
-
- **`@prisma-next/sql-
|
|
77
|
+
- **`@prisma-next/sql-contract`**: SQL contract types (via `@prisma-next/sql-contract/types`)
|
|
78
78
|
|
|
79
79
|
## Related Subsystems
|
|
80
80
|
|
|
@@ -82,32 +82,32 @@ flowchart TD
|
|
|
82
82
|
|
|
83
83
|
## Related ADRs
|
|
84
84
|
|
|
85
|
-
- [ADR
|
|
86
|
-
- [ADR
|
|
85
|
+
- [ADR 159 — Driver Terminology and Lifecycle](../../../../docs/architecture%20docs/adrs/ADR%20159%20-%20Driver%20Terminology%20and%20Lifecycle.md)
|
|
86
|
+
- [ADR 005 — Thin Core Fat Targets](../../../../docs/architecture%20docs/adrs/ADR%20005%20-%20Thin%20Core%20Fat%20Targets.md)
|
|
87
|
+
- [ADR 016 — Adapter SPI for Lowering](../../../../docs/architecture%20docs/adrs/ADR%20016%20-%20Adapter%20SPI%20for%20Lowering.md)
|
|
87
88
|
|
|
88
89
|
## Usage
|
|
89
90
|
|
|
91
|
+
Use the descriptor + connect lifecycle:
|
|
92
|
+
|
|
90
93
|
```typescript
|
|
91
|
-
import
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
const runtime = createRuntime({
|
|
99
|
-
contract,
|
|
100
|
-
adapter: postgresAdapter,
|
|
101
|
-
driver,
|
|
102
|
-
});
|
|
94
|
+
import postgresDriver from '@prisma-next/driver-postgres/runtime';
|
|
95
|
+
|
|
96
|
+
const driver = postgresDriver.create({ cursor: { batchSize: 100 } });
|
|
97
|
+
await driver.connect({ kind: 'url', url: process.env.DATABASE_URL });
|
|
98
|
+
// driver is now bound; use acquireConnection, query, execute, etc.
|
|
103
99
|
```
|
|
104
100
|
|
|
101
|
+
Binding variants:
|
|
102
|
+
- `{ kind: 'url', url }`: Driver creates a Pool from the connection string
|
|
103
|
+
- `{ kind: 'pgPool', pool }`: Use an existing pg Pool
|
|
104
|
+
- `{ kind: 'pgClient', client }`: Use an existing pg Client (direct connection)
|
|
105
|
+
|
|
105
106
|
## Exports
|
|
106
107
|
|
|
107
108
|
- `./runtime`: Runtime entry point for driver implementation
|
|
108
|
-
- `
|
|
109
|
-
- `
|
|
110
|
-
- Types: `PostgresDriverOptions`, `QueryResult`
|
|
109
|
+
- Default: `postgresRuntimeDriverDescriptor` — use `create()` for unbound driver, then `connect(binding)`
|
|
110
|
+
- Types: `PostgresBinding`, `PostgresDriverCreateOptions`, `QueryResult`
|
|
111
111
|
- `./control`: Control plane entry point for driver descriptors
|
|
112
112
|
- Default export: `DriverDescriptor` for use in `prisma-next.config.ts`
|
|
113
113
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Client } from "pg";
|
|
2
|
+
import { ControlDriverDescriptor, ControlDriverInstance } from "@prisma-next/core-control-plane/types";
|
|
3
|
+
|
|
4
|
+
//#region src/exports/control.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Postgres control driver instance for control-plane operations.
|
|
8
|
+
* Implements ControlDriverInstance<'sql', 'postgres'> for database queries.
|
|
9
|
+
*/
|
|
10
|
+
declare class PostgresControlDriver implements ControlDriverInstance<'sql', 'postgres'> {
|
|
11
|
+
private readonly client;
|
|
12
|
+
readonly familyId: "sql";
|
|
13
|
+
readonly targetId: "postgres";
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use targetId instead
|
|
16
|
+
*/
|
|
17
|
+
readonly target: "postgres";
|
|
18
|
+
constructor(client: Client);
|
|
19
|
+
query<Row = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<{
|
|
20
|
+
readonly rows: Row[];
|
|
21
|
+
}>;
|
|
22
|
+
close(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Postgres driver descriptor for CLI config.
|
|
26
|
+
*/
|
|
27
|
+
declare const postgresDriverDescriptor: ControlDriverDescriptor<'sql', 'postgres', PostgresControlDriver>;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { PostgresControlDriver, postgresDriverDescriptor as default };
|
|
30
|
+
//# sourceMappingURL=control.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/exports/control.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;;AAUoB,cAVP,qBAAA,YAAiC,qBAU1B,CAAA,KAAA,EAAA,UAAA,CAAA,CAAA;EAGU,iBAAA,MAAA;EAAzB,SAAA,QAAA,EAAA,KAAA;EASY,SAAA,QAAA,EAAA,UAAA;EAtB6B;;AAyB7C;;sBAjBsC;cAEnB,oEAGf;mBAAyB;;WASb;;;;;cAQX,0BAA0B,2CAA2C"}
|
package/dist/control.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { i as postgresDriverDescriptorMeta, r as normalizePgError } from "./normalize-error-BU6yV-XB.mjs";
|
|
2
|
+
import { errorRuntime } from "@prisma-next/core-control-plane/errors";
|
|
3
|
+
import { SqlQueryError } from "@prisma-next/sql-errors";
|
|
4
|
+
import { ifDefined } from "@prisma-next/utils/defined";
|
|
5
|
+
import { redactDatabaseUrl } from "@prisma-next/utils/redact-db-url";
|
|
6
|
+
import { Client } from "pg";
|
|
7
|
+
|
|
8
|
+
//#region src/exports/control.ts
|
|
9
|
+
/**
|
|
10
|
+
* Postgres control driver instance for control-plane operations.
|
|
11
|
+
* Implements ControlDriverInstance<'sql', 'postgres'> for database queries.
|
|
12
|
+
*/
|
|
13
|
+
var PostgresControlDriver = class {
|
|
14
|
+
familyId = "sql";
|
|
15
|
+
targetId = "postgres";
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use targetId instead
|
|
18
|
+
*/
|
|
19
|
+
target = "postgres";
|
|
20
|
+
constructor(client) {
|
|
21
|
+
this.client = client;
|
|
22
|
+
}
|
|
23
|
+
async query(sql, params) {
|
|
24
|
+
try {
|
|
25
|
+
return { rows: (await this.client.query(sql, params)).rows };
|
|
26
|
+
} catch (error) {
|
|
27
|
+
throw normalizePgError(error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async close() {
|
|
31
|
+
await this.client.end();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Postgres driver descriptor for CLI config.
|
|
36
|
+
*/
|
|
37
|
+
const postgresDriverDescriptor = {
|
|
38
|
+
...postgresDriverDescriptorMeta,
|
|
39
|
+
async create(url) {
|
|
40
|
+
const client = new Client({ connectionString: url });
|
|
41
|
+
try {
|
|
42
|
+
await client.connect();
|
|
43
|
+
return new PostgresControlDriver(client);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
const normalized = normalizePgError(error);
|
|
46
|
+
const redacted = redactDatabaseUrl(url);
|
|
47
|
+
try {
|
|
48
|
+
await client.end();
|
|
49
|
+
} catch {}
|
|
50
|
+
const codeFromSqlState = SqlQueryError.is(normalized) ? normalized.sqlState : void 0;
|
|
51
|
+
const causeCode = "cause" in normalized && normalized.cause ? normalized.cause.code : void 0;
|
|
52
|
+
const code = codeFromSqlState ?? causeCode;
|
|
53
|
+
throw errorRuntime("Database connection failed", {
|
|
54
|
+
why: normalized.message,
|
|
55
|
+
fix: "Verify the database URL, ensure the database is reachable, and confirm credentials/permissions",
|
|
56
|
+
meta: {
|
|
57
|
+
...ifDefined("code", code),
|
|
58
|
+
...redacted
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var control_default = postgresDriverDescriptor;
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { PostgresControlDriver, control_default as default };
|
|
68
|
+
//# sourceMappingURL=control.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.mjs","names":["client: Client","postgresDriverDescriptor: ControlDriverDescriptor<'sql', 'postgres', PostgresControlDriver>"],"sources":["../src/exports/control.ts"],"sourcesContent":["import { errorRuntime } from '@prisma-next/core-control-plane/errors';\nimport type {\n ControlDriverDescriptor,\n ControlDriverInstance,\n} from '@prisma-next/core-control-plane/types';\nimport { SqlQueryError } from '@prisma-next/sql-errors';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { redactDatabaseUrl } from '@prisma-next/utils/redact-db-url';\nimport { Client } from 'pg';\nimport { postgresDriverDescriptorMeta } from '../core/descriptor-meta';\nimport { normalizePgError } from '../normalize-error';\n\n/**\n * Postgres control driver instance for control-plane operations.\n * Implements ControlDriverInstance<'sql', 'postgres'> for database queries.\n */\nexport class PostgresControlDriver implements ControlDriverInstance<'sql', 'postgres'> {\n readonly familyId = 'sql' as const;\n readonly targetId = 'postgres' as const;\n /**\n * @deprecated Use targetId instead\n */\n readonly target = 'postgres' as const;\n\n constructor(private readonly client: Client) {}\n\n async query<Row = Record<string, unknown>>(\n sql: string,\n params?: readonly unknown[],\n ): Promise<{ readonly rows: Row[] }> {\n try {\n const result = await this.client.query(sql, params as unknown[] | undefined);\n return { rows: result.rows as Row[] };\n } catch (error) {\n throw normalizePgError(error);\n }\n }\n\n async close(): Promise<void> {\n await this.client.end();\n }\n}\n\n/**\n * Postgres driver descriptor for CLI config.\n */\nconst postgresDriverDescriptor: ControlDriverDescriptor<'sql', 'postgres', PostgresControlDriver> =\n {\n ...postgresDriverDescriptorMeta,\n async create(url: string): Promise<PostgresControlDriver> {\n const client = new Client({ connectionString: url });\n try {\n await client.connect();\n return new PostgresControlDriver(client);\n } catch (error) {\n const normalized = normalizePgError(error);\n const redacted = redactDatabaseUrl(url);\n try {\n await client.end();\n } catch {\n // ignore\n }\n\n const codeFromSqlState = SqlQueryError.is(normalized) ? normalized.sqlState : undefined;\n const causeCode =\n 'cause' in normalized && normalized.cause\n ? (normalized.cause as { code?: unknown }).code\n : undefined;\n const code = codeFromSqlState ?? causeCode;\n\n throw errorRuntime('Database connection failed', {\n why: normalized.message,\n fix: 'Verify the database URL, ensure the database is reachable, and confirm credentials/permissions',\n meta: {\n ...ifDefined('code', code),\n ...redacted,\n },\n });\n }\n },\n };\n\nexport default postgresDriverDescriptor;\n"],"mappings":";;;;;;;;;;;;AAgBA,IAAa,wBAAb,MAAuF;CACrF,AAAS,WAAW;CACpB,AAAS,WAAW;;;;CAIpB,AAAS,SAAS;CAElB,YAAY,AAAiBA,QAAgB;EAAhB;;CAE7B,MAAM,MACJ,KACA,QACmC;AACnC,MAAI;AAEF,UAAO,EAAE,OADM,MAAM,KAAK,OAAO,MAAM,KAAK,OAAgC,EACtD,MAAe;WAC9B,OAAO;AACd,SAAM,iBAAiB,MAAM;;;CAIjC,MAAM,QAAuB;AAC3B,QAAM,KAAK,OAAO,KAAK;;;;;;AAO3B,MAAMC,2BACJ;CACE,GAAG;CACH,MAAM,OAAO,KAA6C;EACxD,MAAM,SAAS,IAAI,OAAO,EAAE,kBAAkB,KAAK,CAAC;AACpD,MAAI;AACF,SAAM,OAAO,SAAS;AACtB,UAAO,IAAI,sBAAsB,OAAO;WACjC,OAAO;GACd,MAAM,aAAa,iBAAiB,MAAM;GAC1C,MAAM,WAAW,kBAAkB,IAAI;AACvC,OAAI;AACF,UAAM,OAAO,KAAK;WACZ;GAIR,MAAM,mBAAmB,cAAc,GAAG,WAAW,GAAG,WAAW,WAAW;GAC9E,MAAM,YACJ,WAAW,cAAc,WAAW,QAC/B,WAAW,MAA6B,OACzC;GACN,MAAM,OAAO,oBAAoB;AAEjC,SAAM,aAAa,8BAA8B;IAC/C,KAAK,WAAW;IAChB,KAAK;IACL,MAAM;KACJ,GAAG,UAAU,QAAQ,KAAK;KAC1B,GAAG;KACJ;IACF,CAAC;;;CAGP;AAEH,sBAAe"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { SqlConnectionError, SqlQueryError } from "@prisma-next/sql-errors";
|
|
2
|
+
|
|
3
|
+
//#region src/core/descriptor-meta.ts
|
|
4
|
+
const postgresDriverDescriptorMeta = {
|
|
5
|
+
kind: "driver",
|
|
6
|
+
familyId: "sql",
|
|
7
|
+
targetId: "postgres",
|
|
8
|
+
id: "postgres",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
capabilities: {}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/normalize-error.ts
|
|
15
|
+
/**
|
|
16
|
+
* Checks if an error is a connection-related error.
|
|
17
|
+
*/
|
|
18
|
+
function isConnectionError(error) {
|
|
19
|
+
const code = error.code;
|
|
20
|
+
if (code) {
|
|
21
|
+
if (code === "ECONNRESET" || code === "ETIMEDOUT" || code === "ECONNREFUSED" || code === "ENOTFOUND" || code === "EHOSTUNREACH") return true;
|
|
22
|
+
}
|
|
23
|
+
const message = error.message.toLowerCase();
|
|
24
|
+
if (message.includes("connection terminated") || message.includes("connection closed") || message.includes("connection refused") || message.includes("connection timeout") || message.includes("connection reset")) return true;
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Checks if a connection error is transient (might succeed on retry).
|
|
29
|
+
*/
|
|
30
|
+
function isTransientConnectionError(error) {
|
|
31
|
+
const code = error.code;
|
|
32
|
+
if (code) {
|
|
33
|
+
if (code === "ETIMEDOUT" || code === "ECONNRESET") return true;
|
|
34
|
+
if (code === "ECONNREFUSED") return false;
|
|
35
|
+
}
|
|
36
|
+
const message = error.message.toLowerCase();
|
|
37
|
+
if (message.includes("timeout") || message.includes("connection reset")) return true;
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* PostgreSQL-specific error properties that indicate an error originated from pg library.
|
|
42
|
+
* These properties are not present on Node.js system errors.
|
|
43
|
+
* Excludes generic properties like 'detail', 'file', 'line', and 'position' that could appear on any error.
|
|
44
|
+
*/
|
|
45
|
+
const PG_ERROR_PROPERTIES = [
|
|
46
|
+
"constraint",
|
|
47
|
+
"table",
|
|
48
|
+
"column",
|
|
49
|
+
"hint",
|
|
50
|
+
"internalPosition",
|
|
51
|
+
"internalQuery",
|
|
52
|
+
"where",
|
|
53
|
+
"schema",
|
|
54
|
+
"routine"
|
|
55
|
+
];
|
|
56
|
+
/**
|
|
57
|
+
* Type predicate to check if an error is a Postgres error from the pg library.
|
|
58
|
+
*
|
|
59
|
+
* Distinguishes pg library errors from Node.js system errors by checking for:
|
|
60
|
+
* - SQLSTATE codes (5-character alphanumeric codes like '23505', '42601')
|
|
61
|
+
* - pg-specific properties (constraint, table, column, hint, etc.) that Node.js errors don't have
|
|
62
|
+
*
|
|
63
|
+
* Node.js system errors (ECONNREFUSED, ETIMEDOUT, etc.) are excluded to prevent false positives.
|
|
64
|
+
*/
|
|
65
|
+
function isPostgresError(error) {
|
|
66
|
+
if (!(error instanceof Error)) return false;
|
|
67
|
+
const pgError = error;
|
|
68
|
+
if (pgError.code && isPostgresSqlState(pgError.code)) return true;
|
|
69
|
+
return PG_ERROR_PROPERTIES.some((prop) => pgError[prop] !== void 0);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Checks if an error is an "already connected" error from pg.Client.connect().
|
|
73
|
+
* When calling connect() on an already-connected client, pg throws an error that can be safely ignored.
|
|
74
|
+
*/
|
|
75
|
+
function isAlreadyConnectedError(error) {
|
|
76
|
+
if (!(error instanceof Error)) return false;
|
|
77
|
+
const message = error.message.toLowerCase();
|
|
78
|
+
return message.includes("already") && message.includes("connected");
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Checks if an error code is a Postgres SQLSTATE (5-character alphanumeric code).
|
|
82
|
+
* SQLSTATE codes are standardized SQL error codes (e.g., '23505' for unique violation).
|
|
83
|
+
*/
|
|
84
|
+
function isPostgresSqlState(code) {
|
|
85
|
+
if (!code) return false;
|
|
86
|
+
return /^[A-Z0-9]{5}$/.test(code);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Normalizes a Postgres error into a SQL-shared error type.
|
|
90
|
+
*
|
|
91
|
+
* - Postgres SQLSTATE errors (5-char codes like '23505') → SqlQueryError
|
|
92
|
+
* - Connection errors (ECONNRESET, ETIMEDOUT, etc.) → SqlConnectionError
|
|
93
|
+
* - Unknown errors → returns the original error as-is
|
|
94
|
+
*
|
|
95
|
+
* The original error is preserved via Error.cause to maintain stack traces.
|
|
96
|
+
*
|
|
97
|
+
* @param error - The error to normalize (typically from pg library)
|
|
98
|
+
* @returns SqlQueryError for query-related failures
|
|
99
|
+
* @returns SqlConnectionError for connection-related failures
|
|
100
|
+
* @returns The original error if it cannot be normalized
|
|
101
|
+
*/
|
|
102
|
+
function normalizePgError(error) {
|
|
103
|
+
if (!(error instanceof Error)) return new Error(String(error));
|
|
104
|
+
const pgError = error;
|
|
105
|
+
if (isPostgresSqlState(pgError.code)) {
|
|
106
|
+
const options = {
|
|
107
|
+
cause: error,
|
|
108
|
+
sqlState: pgError.code
|
|
109
|
+
};
|
|
110
|
+
if (pgError.constraint !== void 0) options.constraint = pgError.constraint;
|
|
111
|
+
if (pgError.table !== void 0) options.table = pgError.table;
|
|
112
|
+
if (pgError.column !== void 0) options.column = pgError.column;
|
|
113
|
+
if (pgError.detail !== void 0) options.detail = pgError.detail;
|
|
114
|
+
return new SqlQueryError(error.message, options);
|
|
115
|
+
}
|
|
116
|
+
if (isConnectionError(error)) return new SqlConnectionError(error.message, {
|
|
117
|
+
cause: error,
|
|
118
|
+
transient: isTransientConnectionError(error)
|
|
119
|
+
});
|
|
120
|
+
return error;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
export { postgresDriverDescriptorMeta as i, isPostgresError as n, normalizePgError as r, isAlreadyConnectedError as t };
|
|
125
|
+
//# sourceMappingURL=normalize-error-BU6yV-XB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-error-BU6yV-XB.mjs","names":["options: {\n cause: Error;\n sqlState: string;\n constraint?: string;\n table?: string;\n column?: string;\n detail?: string;\n }"],"sources":["../src/core/descriptor-meta.ts","../src/normalize-error.ts"],"sourcesContent":["export const postgresDriverDescriptorMeta = {\n kind: 'driver',\n familyId: 'sql',\n targetId: 'postgres',\n id: 'postgres',\n version: '0.0.1',\n capabilities: {},\n} as const;\n","import { SqlConnectionError, SqlQueryError } from '@prisma-next/sql-errors';\n\n/**\n * Postgres error shape from the pg library.\n *\n * Note: The pg library doesn't export a DatabaseError type or interface, but errors\n * thrown by pg.query() and pg.Client have this shape at runtime. We define this\n * interface to match the actual runtime structure documented in the pg library\n * (https://github.com/brianc/node-postgres/blob/master/packages/pg/lib/errors.js).\n *\n * The @types/pg package also doesn't provide comprehensive error type definitions,\n * so we define our own interface based on the runtime error properties.\n */\ninterface PostgresError extends Error {\n readonly code?: string;\n readonly constraint?: string;\n readonly table?: string;\n readonly column?: string;\n readonly detail?: string;\n readonly hint?: string;\n readonly position?: string;\n readonly internalPosition?: string;\n readonly internalQuery?: string;\n readonly where?: string;\n readonly schema?: string;\n readonly file?: string;\n readonly line?: string;\n readonly routine?: string;\n}\n\n/**\n * Checks if an error is a connection-related error.\n */\nfunction isConnectionError(error: Error): boolean {\n const code = (error as { code?: string }).code;\n if (code) {\n // Node.js error codes for connection issues\n if (\n code === 'ECONNRESET' ||\n code === 'ETIMEDOUT' ||\n code === 'ECONNREFUSED' ||\n code === 'ENOTFOUND' ||\n code === 'EHOSTUNREACH'\n ) {\n return true;\n }\n }\n\n // Check error message for connection-related strings\n const message = error.message.toLowerCase();\n if (\n message.includes('connection terminated') ||\n message.includes('connection closed') ||\n message.includes('connection refused') ||\n message.includes('connection timeout') ||\n message.includes('connection reset')\n ) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Checks if a connection error is transient (might succeed on retry).\n */\nfunction isTransientConnectionError(error: Error): boolean {\n const code = (error as { code?: string }).code;\n if (code) {\n // Timeouts and connection resets are often transient\n if (code === 'ETIMEDOUT' || code === 'ECONNRESET') {\n return true;\n }\n // Connection refused is usually not transient (server is down)\n if (code === 'ECONNREFUSED') {\n return false;\n }\n }\n\n const message = error.message.toLowerCase();\n if (message.includes('timeout') || message.includes('connection reset')) {\n return true;\n }\n\n return false;\n}\n\n/**\n * PostgreSQL-specific error properties that indicate an error originated from pg library.\n * These properties are not present on Node.js system errors.\n * Excludes generic properties like 'detail', 'file', 'line', and 'position' that could appear on any error.\n */\nconst PG_ERROR_PROPERTIES = [\n 'constraint',\n 'table',\n 'column',\n 'hint',\n 'internalPosition',\n 'internalQuery',\n 'where',\n 'schema',\n 'routine',\n] as const;\n\n/**\n * Type predicate to check if an error is a Postgres error from the pg library.\n *\n * Distinguishes pg library errors from Node.js system errors by checking for:\n * - SQLSTATE codes (5-character alphanumeric codes like '23505', '42601')\n * - pg-specific properties (constraint, table, column, hint, etc.) that Node.js errors don't have\n *\n * Node.js system errors (ECONNREFUSED, ETIMEDOUT, etc.) are excluded to prevent false positives.\n */\nexport function isPostgresError(error: unknown): error is PostgresError {\n if (!(error instanceof Error)) {\n return false;\n }\n\n const pgError = error as PostgresError;\n\n // Check for SQLSTATE code (5-character alphanumeric) - primary indicator of pg errors\n if (pgError.code && isPostgresSqlState(pgError.code)) {\n return true;\n }\n\n // Check for pg-specific properties that Node.js system errors don't have\n // These properties indicate the error originated from pg library query execution\n return PG_ERROR_PROPERTIES.some((prop) => pgError[prop] !== undefined);\n}\n\n/**\n * Checks if an error is an \"already connected\" error from pg.Client.connect().\n * When calling connect() on an already-connected client, pg throws an error that can be safely ignored.\n */\nexport function isAlreadyConnectedError(error: unknown): error is Error {\n if (!(error instanceof Error)) {\n return false;\n }\n const message = error.message.toLowerCase();\n return message.includes('already') && message.includes('connected');\n}\n\n/**\n * Checks if an error code is a Postgres SQLSTATE (5-character alphanumeric code).\n * SQLSTATE codes are standardized SQL error codes (e.g., '23505' for unique violation).\n */\nfunction isPostgresSqlState(code: string | undefined): boolean {\n if (!code) {\n return false;\n }\n // Postgres SQLSTATE codes are 5-character alphanumeric strings\n // Examples: '23505' (unique violation), '42501' (insufficient privilege), '42601' (syntax error)\n return /^[A-Z0-9]{5}$/.test(code);\n}\n\n/**\n * Normalizes a Postgres error into a SQL-shared error type.\n *\n * - Postgres SQLSTATE errors (5-char codes like '23505') → SqlQueryError\n * - Connection errors (ECONNRESET, ETIMEDOUT, etc.) → SqlConnectionError\n * - Unknown errors → returns the original error as-is\n *\n * The original error is preserved via Error.cause to maintain stack traces.\n *\n * @param error - The error to normalize (typically from pg library)\n * @returns SqlQueryError for query-related failures\n * @returns SqlConnectionError for connection-related failures\n * @returns The original error if it cannot be normalized\n */\nexport function normalizePgError(error: unknown): SqlQueryError | SqlConnectionError | Error {\n if (!(error instanceof Error)) {\n // Wrap non-Error values in an Error object\n return new Error(String(error));\n }\n\n const pgError = error as PostgresError;\n\n // Check for Postgres SQLSTATE (query errors)\n if (isPostgresSqlState(pgError.code)) {\n // isPostgresSqlState ensures code is defined and is a valid SQLSTATE\n // biome-ignore lint/style/noNonNullAssertion: isPostgresSqlState guarantees code is defined\n const sqlState = pgError.code!;\n const options: {\n cause: Error;\n sqlState: string;\n constraint?: string;\n table?: string;\n column?: string;\n detail?: string;\n } = {\n cause: error,\n sqlState,\n };\n if (pgError.constraint !== undefined) {\n options.constraint = pgError.constraint;\n }\n if (pgError.table !== undefined) {\n options.table = pgError.table;\n }\n if (pgError.column !== undefined) {\n options.column = pgError.column;\n }\n if (pgError.detail !== undefined) {\n options.detail = pgError.detail;\n }\n return new SqlQueryError(error.message, options);\n }\n\n // Check for connection errors\n if (isConnectionError(error)) {\n return new SqlConnectionError(error.message, {\n cause: error,\n transient: isTransientConnectionError(error),\n });\n }\n\n // Unknown error - return as-is to preserve original error and stack trace\n return error;\n}\n"],"mappings":";;;AAAA,MAAa,+BAA+B;CAC1C,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,EAAE;CACjB;;;;;;;AC0BD,SAAS,kBAAkB,OAAuB;CAChD,MAAM,OAAQ,MAA4B;AAC1C,KAAI,MAEF;MACE,SAAS,gBACT,SAAS,eACT,SAAS,kBACT,SAAS,eACT,SAAS,eAET,QAAO;;CAKX,MAAM,UAAU,MAAM,QAAQ,aAAa;AAC3C,KACE,QAAQ,SAAS,wBAAwB,IACzC,QAAQ,SAAS,oBAAoB,IACrC,QAAQ,SAAS,qBAAqB,IACtC,QAAQ,SAAS,qBAAqB,IACtC,QAAQ,SAAS,mBAAmB,CAEpC,QAAO;AAGT,QAAO;;;;;AAMT,SAAS,2BAA2B,OAAuB;CACzD,MAAM,OAAQ,MAA4B;AAC1C,KAAI,MAAM;AAER,MAAI,SAAS,eAAe,SAAS,aACnC,QAAO;AAGT,MAAI,SAAS,eACX,QAAO;;CAIX,MAAM,UAAU,MAAM,QAAQ,aAAa;AAC3C,KAAI,QAAQ,SAAS,UAAU,IAAI,QAAQ,SAAS,mBAAmB,CACrE,QAAO;AAGT,QAAO;;;;;;;AAQT,MAAM,sBAAsB;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;;;AAWD,SAAgB,gBAAgB,OAAwC;AACtE,KAAI,EAAE,iBAAiB,OACrB,QAAO;CAGT,MAAM,UAAU;AAGhB,KAAI,QAAQ,QAAQ,mBAAmB,QAAQ,KAAK,CAClD,QAAO;AAKT,QAAO,oBAAoB,MAAM,SAAS,QAAQ,UAAU,OAAU;;;;;;AAOxE,SAAgB,wBAAwB,OAAgC;AACtE,KAAI,EAAE,iBAAiB,OACrB,QAAO;CAET,MAAM,UAAU,MAAM,QAAQ,aAAa;AAC3C,QAAO,QAAQ,SAAS,UAAU,IAAI,QAAQ,SAAS,YAAY;;;;;;AAOrE,SAAS,mBAAmB,MAAmC;AAC7D,KAAI,CAAC,KACH,QAAO;AAIT,QAAO,gBAAgB,KAAK,KAAK;;;;;;;;;;;;;;;;AAiBnC,SAAgB,iBAAiB,OAA4D;AAC3F,KAAI,EAAE,iBAAiB,OAErB,QAAO,IAAI,MAAM,OAAO,MAAM,CAAC;CAGjC,MAAM,UAAU;AAGhB,KAAI,mBAAmB,QAAQ,KAAK,EAAE;EAIpC,MAAMA,UAOF;GACF,OAAO;GACP,UAVe,QAAQ;GAWxB;AACD,MAAI,QAAQ,eAAe,OACzB,SAAQ,aAAa,QAAQ;AAE/B,MAAI,QAAQ,UAAU,OACpB,SAAQ,QAAQ,QAAQ;AAE1B,MAAI,QAAQ,WAAW,OACrB,SAAQ,SAAS,QAAQ;AAE3B,MAAI,QAAQ,WAAW,OACrB,SAAQ,SAAS,QAAQ;AAE3B,SAAO,IAAI,cAAc,MAAM,SAAS,QAAQ;;AAIlD,KAAI,kBAAkB,MAAM,CAC1B,QAAO,IAAI,mBAAmB,MAAM,SAAS;EAC3C,OAAO;EACP,WAAW,2BAA2B,MAAM;EAC7C,CAAC;AAIJ,QAAO"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Client, Pool, QueryResult as QueryResult$1, QueryResultRow } from "pg";
|
|
2
|
+
import { RuntimeDriverDescriptor, RuntimeDriverInstance } from "@prisma-next/core-execution-plane/types";
|
|
3
|
+
import { SqlDriver } from "@prisma-next/sql-relational-core/ast";
|
|
4
|
+
|
|
5
|
+
//#region src/postgres-driver.d.ts
|
|
6
|
+
type QueryResult<T extends QueryResultRow = QueryResultRow> = QueryResult$1<T>;
|
|
7
|
+
type PostgresBinding = {
|
|
8
|
+
readonly kind: 'url';
|
|
9
|
+
readonly url: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: 'pgPool';
|
|
12
|
+
readonly pool: Pool;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: 'pgClient';
|
|
15
|
+
readonly client: Client;
|
|
16
|
+
};
|
|
17
|
+
interface PostgresCursorOptions {
|
|
18
|
+
readonly batchSize?: number;
|
|
19
|
+
readonly disabled?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface PostgresDriverOptions {
|
|
22
|
+
readonly connect: {
|
|
23
|
+
client: Client;
|
|
24
|
+
} | {
|
|
25
|
+
pool: Pool;
|
|
26
|
+
};
|
|
27
|
+
readonly cursor?: PostgresCursorOptions | undefined;
|
|
28
|
+
}
|
|
29
|
+
type PostgresDriverCreateOptions = Omit<PostgresDriverOptions, 'connect'>;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/exports/runtime.d.ts
|
|
32
|
+
type PostgresRuntimeDriver = RuntimeDriverInstance<'sql', 'postgres'> & SqlDriver<PostgresBinding>;
|
|
33
|
+
declare const postgresRuntimeDriverDescriptor: RuntimeDriverDescriptor<'sql', 'postgres', PostgresDriverCreateOptions, PostgresRuntimeDriver>;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { type PostgresBinding, type PostgresDriverCreateOptions, PostgresRuntimeDriver, type QueryResult, postgresRuntimeDriverDescriptor as default };
|
|
36
|
+
//# sourceMappingURL=runtime.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/postgres-driver.ts","../src/exports/runtime.ts"],"sourcesContent":[],"mappings":";;;;;KAsBY,sBAAsB,iBAAiB,kBAAkB,cAAc;KAEvE,eAAA;;EAFA,SAAA,GAAA,EAAW,MAAA;CAAW,GAAA;EAAiB,SAAA,IAAA,EAAA,QAAA;EAAgC,SAAA,IAAA,EAIrC,IAJqC;CAAd,GAAA;EAAa,SAAA,IAAA,EAAA,UAAA;EAEtE,SAAA,MAAA,EAGsC,MAHvB;AAK3B,CAAA;AAKU,UALO,qBAAA,CAKc;EACD,SAAA,SAAA,CAAA,EAAA,MAAA;EAAmB,SAAA,QAAA,CAAA,EAAA,OAAA;;UADvC,qBAAA,CAE+B;EAG7B,SAAA,OAAA,EAAA;YAJkB;;UAAmB;ECjBrC,CAAA;EAAwB,SAAA,MAAA,CAAA,EDkBhB,qBClBgB,GAAA,SAAA;;AAClC,KDoBU,2BAAA,GAA8B,ICpBxC,CDoB6C,qBCpB7C,EAAA,SAAA,CAAA;;;KADU,qBAAA,GAAwB,2CAClC,UAAU;cA6HN,iCAAiC,2CAGrC,6BACA"}
|