@pgxsinkit/pgwasm 0.6.0 → 0.6.2
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 +8 -0
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/seam.d.ts.map +1 -1
- package/dist/{chunk-jnmd6w7f.js → chunk-4eb2pcfr.js} +18 -3
- package/dist/chunk-4eb2pcfr.js.map +10 -0
- package/dist/{chunk-garmxqte.js → chunk-82r7js5b.js} +101 -21
- package/dist/chunk-82r7js5b.js.map +16 -0
- package/dist/{chunk-c06zjbcj.js → chunk-cgt5pdan.js} +2 -290
- package/dist/chunk-cgt5pdan.js.map +13 -0
- package/dist/{chunk-cpsnmzrf.js → chunk-jwz46twh.js} +14 -2
- package/dist/chunk-jwz46twh.js.map +10 -0
- package/dist/{chunk-d2kpv98r.js → chunk-rqykg4gj.js} +1 -1
- package/dist/{chunk-10ebj4re.js → chunk-rsenqaz0.js} +2 -2
- package/dist/chunk-ryjxx1c8.js +303 -0
- package/dist/chunk-ryjxx1c8.js.map +10 -0
- package/dist/core/data-dir-archive.d.ts.map +1 -1
- package/dist/core/internals.d.ts.map +1 -1
- package/dist/core/marker.d.ts.map +1 -1
- package/dist/core/mutex.d.ts.map +1 -1
- package/dist/core/names.d.ts.map +1 -1
- package/dist/core/parse.d.ts.map +1 -1
- package/dist/core/pgwasm.d.ts.map +1 -1
- package/dist/core/storage.d.ts.map +1 -1
- package/dist/create.d.ts.map +1 -1
- package/dist/drizzle/codecs.d.ts.map +1 -1
- package/dist/drizzle/driver.d.ts.map +1 -1
- package/dist/drizzle/index.d.ts.map +1 -1
- package/dist/drizzle/index.js +2 -2
- package/dist/drizzle/session.d.ts.map +1 -1
- package/dist/errors.d.ts +5 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/fs/base-filesystem.d.ts.map +1 -1
- package/dist/fs/index.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/interface.d.ts +4 -1
- package/dist/interface.d.ts.map +1 -1
- package/dist/live/debounce-mutex.d.ts.map +1 -1
- package/dist/live/format-query.d.ts.map +1 -1
- package/dist/live/index.d.ts.map +1 -1
- package/dist/live/index.js +5 -5
- package/dist/live/index.js.map +3 -3
- package/dist/live/interface.d.ts.map +1 -1
- package/dist/opfs/broker/client.d.ts.map +1 -1
- package/dist/opfs/broker/protocol.d.ts.map +1 -1
- package/dist/opfs/broker/server.d.ts.map +1 -1
- package/dist/opfs/core/checksum.d.ts.map +1 -1
- package/dist/opfs/core/codec.d.ts.map +1 -1
- package/dist/opfs/core/errors.d.ts.map +1 -1
- package/dist/opfs/core/limits.d.ts.map +1 -1
- package/dist/opfs/core/memory-port.d.ts.map +1 -1
- package/dist/opfs/core/metadata-store.d.ts.map +1 -1
- package/dist/opfs/core/mounted-vfs.d.ts.map +1 -1
- package/dist/opfs/core/path.d.ts.map +1 -1
- package/dist/opfs/core/port.d.ts.map +1 -1
- package/dist/opfs/core/repacked-vfs.d.ts.map +1 -1
- package/dist/opfs/core/state-machine.d.ts.map +1 -1
- package/dist/opfs/create.d.ts.map +1 -1
- package/dist/opfs/file-port.d.ts.map +1 -1
- package/dist/opfs/index.d.ts.map +1 -1
- package/dist/opfs/index.js +3 -3
- package/dist/opfs/opfs-port.d.ts.map +1 -1
- package/dist/opfs/opfs-repacked-fs.d.ts.map +1 -1
- package/dist/opfs/wasi/preview1.d.ts.map +1 -1
- package/dist/protocol/index.d.ts.map +1 -1
- package/dist/protocol/index.js +6 -4
- package/dist/protocol/index.js.map +2 -2
- package/dist/protocol/wire/buffer-reader.d.ts.map +1 -1
- package/dist/protocol/wire/buffer-writer.d.ts.map +1 -1
- package/dist/protocol/wire/index.d.ts.map +1 -1
- package/dist/protocol/wire/messages.d.ts.map +1 -1
- package/dist/protocol/wire/parser.d.ts.map +1 -1
- package/dist/protocol/wire/serializer.d.ts.map +1 -1
- package/dist/protocol/wire/string-utils.d.ts.map +1 -1
- package/dist/protocol/wire/types.d.ts.map +1 -1
- package/dist/tar/gzip.d.ts.map +1 -1
- package/dist/tar/tar.d.ts.map +1 -1
- package/dist/templating.d.ts.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/opfs/SKILL.md +1 -1
- package/src/core/pgwasm.ts +101 -14
- package/src/errors.ts +10 -1
- package/src/index.ts +1 -0
- package/src/interface.ts +4 -1
- package/src/live/format-query.ts +2 -1
- package/src/templating.ts +3 -1
- package/src/types.ts +15 -1
- package/dist/chunk-c06zjbcj.js.map +0 -14
- package/dist/chunk-cpsnmzrf.js.map +0 -10
- package/dist/chunk-garmxqte.js.map +0 -16
- package/dist/chunk-jnmd6w7f.js.map +0 -10
- package/dist/chunk-kb3rsr7n.js +0 -19
- package/dist/chunk-kb3rsr7n.js.map +0 -9
- /package/dist/{chunk-d2kpv98r.js.map → chunk-rqykg4gj.js.map} +0 -0
- /package/dist/{chunk-10ebj4re.js.map → chunk-rsenqaz0.js.map} +0 -0
|
@@ -1,292 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import {
|
|
3
|
-
__export
|
|
4
|
-
} from "./chunk-kb3rsr7n.js";
|
|
5
|
-
|
|
6
|
-
// packages/pgwasm/src/protocol/wire/messages.ts
|
|
7
|
-
var exports_messages = {};
|
|
8
|
-
__export(exports_messages, {
|
|
9
|
-
AuthenticationCleartextPassword: () => AuthenticationCleartextPassword,
|
|
10
|
-
AuthenticationMD5Password: () => AuthenticationMD5Password,
|
|
11
|
-
AuthenticationOk: () => AuthenticationOk,
|
|
12
|
-
AuthenticationSASL: () => AuthenticationSASL,
|
|
13
|
-
AuthenticationSASLContinue: () => AuthenticationSASLContinue,
|
|
14
|
-
AuthenticationSASLFinal: () => AuthenticationSASLFinal,
|
|
15
|
-
BackendKeyDataMessage: () => BackendKeyDataMessage,
|
|
16
|
-
CommandCompleteMessage: () => CommandCompleteMessage,
|
|
17
|
-
CopyDataMessage: () => CopyDataMessage,
|
|
18
|
-
CopyResponse: () => CopyResponse,
|
|
19
|
-
DataRowMessage: () => DataRowMessage,
|
|
20
|
-
DatabaseError: () => DatabaseError2,
|
|
21
|
-
Field: () => Field,
|
|
22
|
-
NoticeMessage: () => NoticeMessage,
|
|
23
|
-
NotificationResponseMessage: () => NotificationResponseMessage,
|
|
24
|
-
ParameterDescriptionMessage: () => ParameterDescriptionMessage,
|
|
25
|
-
ParameterStatusMessage: () => ParameterStatusMessage,
|
|
26
|
-
ReadyForQueryMessage: () => ReadyForQueryMessage,
|
|
27
|
-
RowDescriptionMessage: () => RowDescriptionMessage,
|
|
28
|
-
bindComplete: () => bindComplete,
|
|
29
|
-
closeComplete: () => closeComplete,
|
|
30
|
-
copyDone: () => copyDone,
|
|
31
|
-
emptyQuery: () => emptyQuery,
|
|
32
|
-
noData: () => noData,
|
|
33
|
-
parseComplete: () => parseComplete,
|
|
34
|
-
portalSuspended: () => portalSuspended,
|
|
35
|
-
replicationStart: () => replicationStart
|
|
36
|
-
});
|
|
37
|
-
var parseComplete = { name: "parseComplete", length: 5 };
|
|
38
|
-
var bindComplete = { name: "bindComplete", length: 5 };
|
|
39
|
-
var closeComplete = { name: "closeComplete", length: 5 };
|
|
40
|
-
var noData = { name: "noData", length: 5 };
|
|
41
|
-
var portalSuspended = { name: "portalSuspended", length: 5 };
|
|
42
|
-
var replicationStart = { name: "replicationStart", length: 4 };
|
|
43
|
-
var emptyQuery = { name: "emptyQuery", length: 4 };
|
|
44
|
-
var copyDone = { name: "copyDone", length: 4 };
|
|
45
|
-
|
|
46
|
-
class AuthenticationOk {
|
|
47
|
-
name = "authenticationOk";
|
|
48
|
-
length;
|
|
49
|
-
constructor(length) {
|
|
50
|
-
this.length = length;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
class AuthenticationCleartextPassword {
|
|
55
|
-
name = "authenticationCleartextPassword";
|
|
56
|
-
length;
|
|
57
|
-
constructor(length) {
|
|
58
|
-
this.length = length;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
class AuthenticationMD5Password {
|
|
63
|
-
name = "authenticationMD5Password";
|
|
64
|
-
length;
|
|
65
|
-
salt;
|
|
66
|
-
constructor(length, salt) {
|
|
67
|
-
this.length = length;
|
|
68
|
-
this.salt = salt;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
class AuthenticationSASL {
|
|
73
|
-
name = "authenticationSASL";
|
|
74
|
-
length;
|
|
75
|
-
mechanisms;
|
|
76
|
-
constructor(length, mechanisms) {
|
|
77
|
-
this.length = length;
|
|
78
|
-
this.mechanisms = mechanisms;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
class AuthenticationSASLContinue {
|
|
83
|
-
name = "authenticationSASLContinue";
|
|
84
|
-
length;
|
|
85
|
-
data;
|
|
86
|
-
constructor(length, data) {
|
|
87
|
-
this.length = length;
|
|
88
|
-
this.data = data;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
class AuthenticationSASLFinal {
|
|
93
|
-
name = "authenticationSASLFinal";
|
|
94
|
-
length;
|
|
95
|
-
data;
|
|
96
|
-
constructor(length, data) {
|
|
97
|
-
this.length = length;
|
|
98
|
-
this.data = data;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
class DatabaseError2 extends Error {
|
|
103
|
-
severity;
|
|
104
|
-
code;
|
|
105
|
-
detail;
|
|
106
|
-
hint;
|
|
107
|
-
position;
|
|
108
|
-
internalPosition;
|
|
109
|
-
internalQuery;
|
|
110
|
-
where;
|
|
111
|
-
schema;
|
|
112
|
-
table;
|
|
113
|
-
column;
|
|
114
|
-
dataType;
|
|
115
|
-
constraint;
|
|
116
|
-
file;
|
|
117
|
-
line;
|
|
118
|
-
routine;
|
|
119
|
-
length;
|
|
120
|
-
name;
|
|
121
|
-
constructor(message, length, name) {
|
|
122
|
-
super(message);
|
|
123
|
-
this.length = length;
|
|
124
|
-
this.name = name;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
class CopyDataMessage {
|
|
129
|
-
name = "copyData";
|
|
130
|
-
length;
|
|
131
|
-
chunk;
|
|
132
|
-
constructor(length, chunk) {
|
|
133
|
-
this.length = length;
|
|
134
|
-
this.chunk = chunk;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
class CopyResponse {
|
|
139
|
-
length;
|
|
140
|
-
name;
|
|
141
|
-
binary;
|
|
142
|
-
columnTypes;
|
|
143
|
-
constructor(length, name, binary, columnCount) {
|
|
144
|
-
this.length = length;
|
|
145
|
-
this.name = name;
|
|
146
|
-
this.binary = binary;
|
|
147
|
-
this.columnTypes = Array.from({ length: columnCount }, () => 0);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
class Field {
|
|
152
|
-
name;
|
|
153
|
-
tableID;
|
|
154
|
-
columnID;
|
|
155
|
-
dataTypeID;
|
|
156
|
-
dataTypeSize;
|
|
157
|
-
dataTypeModifier;
|
|
158
|
-
format;
|
|
159
|
-
constructor(name, tableID, columnID, dataTypeID, dataTypeSize, dataTypeModifier, format) {
|
|
160
|
-
this.name = name;
|
|
161
|
-
this.tableID = tableID;
|
|
162
|
-
this.columnID = columnID;
|
|
163
|
-
this.dataTypeID = dataTypeID;
|
|
164
|
-
this.dataTypeSize = dataTypeSize;
|
|
165
|
-
this.dataTypeModifier = dataTypeModifier;
|
|
166
|
-
this.format = format;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
class RowDescriptionMessage {
|
|
171
|
-
name = "rowDescription";
|
|
172
|
-
length;
|
|
173
|
-
fieldCount;
|
|
174
|
-
fields;
|
|
175
|
-
constructor(length, fields) {
|
|
176
|
-
this.length = length;
|
|
177
|
-
this.fieldCount = fields.length;
|
|
178
|
-
this.fields = fields;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
class ParameterDescriptionMessage {
|
|
183
|
-
name = "parameterDescription";
|
|
184
|
-
length;
|
|
185
|
-
parameterCount;
|
|
186
|
-
dataTypeIDs;
|
|
187
|
-
constructor(length, dataTypeIDs) {
|
|
188
|
-
this.length = length;
|
|
189
|
-
this.parameterCount = dataTypeIDs.length;
|
|
190
|
-
this.dataTypeIDs = dataTypeIDs;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
class ParameterStatusMessage {
|
|
195
|
-
name = "parameterStatus";
|
|
196
|
-
length;
|
|
197
|
-
parameterName;
|
|
198
|
-
parameterValue;
|
|
199
|
-
constructor(length, parameterName, parameterValue) {
|
|
200
|
-
this.length = length;
|
|
201
|
-
this.parameterName = parameterName;
|
|
202
|
-
this.parameterValue = parameterValue;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
class BackendKeyDataMessage {
|
|
207
|
-
name = "backendKeyData";
|
|
208
|
-
length;
|
|
209
|
-
processID;
|
|
210
|
-
secretKey;
|
|
211
|
-
constructor(length, processID, secretKey) {
|
|
212
|
-
this.length = length;
|
|
213
|
-
this.processID = processID;
|
|
214
|
-
this.secretKey = secretKey;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
class NotificationResponseMessage {
|
|
219
|
-
name = "notification";
|
|
220
|
-
length;
|
|
221
|
-
processId;
|
|
222
|
-
channel;
|
|
223
|
-
payload;
|
|
224
|
-
constructor(length, processId, channel, payload) {
|
|
225
|
-
this.length = length;
|
|
226
|
-
this.processId = processId;
|
|
227
|
-
this.channel = channel;
|
|
228
|
-
this.payload = payload;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
class ReadyForQueryMessage {
|
|
233
|
-
name = "readyForQuery";
|
|
234
|
-
length;
|
|
235
|
-
status;
|
|
236
|
-
constructor(length, status) {
|
|
237
|
-
this.length = length;
|
|
238
|
-
this.status = status;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
class CommandCompleteMessage {
|
|
243
|
-
name = "commandComplete";
|
|
244
|
-
length;
|
|
245
|
-
text;
|
|
246
|
-
constructor(length, text) {
|
|
247
|
-
this.length = length;
|
|
248
|
-
this.text = text;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
class DataRowMessage {
|
|
253
|
-
name = "dataRow";
|
|
254
|
-
length;
|
|
255
|
-
fieldCount;
|
|
256
|
-
fields;
|
|
257
|
-
constructor(length, fields) {
|
|
258
|
-
this.length = length;
|
|
259
|
-
this.fields = fields;
|
|
260
|
-
this.fieldCount = fields.length;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
class NoticeMessage {
|
|
265
|
-
name = "notice";
|
|
266
|
-
length;
|
|
267
|
-
message;
|
|
268
|
-
severity;
|
|
269
|
-
code;
|
|
270
|
-
detail;
|
|
271
|
-
hint;
|
|
272
|
-
position;
|
|
273
|
-
internalPosition;
|
|
274
|
-
internalQuery;
|
|
275
|
-
where;
|
|
276
|
-
schema;
|
|
277
|
-
table;
|
|
278
|
-
column;
|
|
279
|
-
dataType;
|
|
280
|
-
constraint;
|
|
281
|
-
file;
|
|
282
|
-
line;
|
|
283
|
-
routine;
|
|
284
|
-
constructor(length, message) {
|
|
285
|
-
this.length = length;
|
|
286
|
-
this.message = message;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
2
|
// packages/pgwasm/src/protocol/wire/string-utils.ts
|
|
291
3
|
function byteLengthUtf8(str) {
|
|
292
4
|
let byteLength = str.length;
|
|
@@ -575,6 +287,6 @@ function strictSyncOf(pg) {
|
|
|
575
287
|
return strictSyncs.get(pg);
|
|
576
288
|
}
|
|
577
289
|
|
|
578
|
-
export {
|
|
290
|
+
export { serialize2, registerProtocolAccess, protocolAccessOf, registerStrictSync, strictSyncOf };
|
|
579
291
|
|
|
580
|
-
//# debugId=
|
|
292
|
+
//# debugId=7E0D86EE8810921364756E2164756E21
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/protocol/wire/string-utils.ts", "../src/protocol/wire/buffer-writer.ts", "../src/protocol/wire/serializer.ts", "../src/core/internals.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"// Began as a copy of `@electric-sql/pg-protocol`, itself adapted from node-postgres' `pg-protocol`\n// (MIT, © Brian Carlson; ElectricSQL's changes taken under the PostgreSQL License — see NOTICE).\n// Owned outright (ADR-0062); compatibility with PGlite is an anti-goal — evolve freely.\n\n/**\n * The byte length of a string once UTF-8 encoded.\n * Adapted from https://stackoverflow.com/a/23329386\n */\nexport function byteLengthUtf8(str: string): number {\n let byteLength = str.length;\n for (let i = str.length - 1; i >= 0; i--) {\n const code = str.charCodeAt(i);\n if (code > 0x7f && code <= 0x7ff) byteLength++;\n else if (code > 0x7ff && code <= 0xffff) byteLength += 2;\n if (code >= 0xdc00 && code <= 0xdfff) {\n const previous = str.charCodeAt(i - 1);\n // Only a valid pair shares four bytes; an unpaired surrogate encodes as U+FFFD.\n if (previous >= 0xd800 && previous <= 0xdbff) i--;\n }\n }\n return byteLength;\n}\n",
|
|
6
|
+
"// Began as a copy of `@electric-sql/pg-protocol`, itself adapted from node-postgres' `pg-protocol`\n// (MIT, © Brian Carlson; ElectricSQL's changes taken under the PostgreSQL License — see NOTICE).\n// Owned outright (ADR-0062); compatibility with PGlite is an anti-goal — evolve freely.\n\nimport { byteLengthUtf8 } from \"./string-utils\";\n\n/** Builds frontend messages: a 5-byte header slot (code + length) followed by the body. */\nexport class Writer {\n readonly #size: number;\n #bufferView: DataView<ArrayBuffer>;\n #offset = 5;\n readonly #encoder = new TextEncoder();\n readonly #headerPosition = 0;\n\n constructor(size = 256) {\n this.#size = size;\n this.#bufferView = this.#allocateBuffer(size);\n }\n\n #allocateBuffer(size: number): DataView<ArrayBuffer> {\n return new DataView(new ArrayBuffer(size));\n }\n\n #ensure(size: number): void {\n const remaining = this.#bufferView.byteLength - this.#offset;\n if (remaining < size) {\n const oldBuffer = this.#bufferView.buffer;\n // Grow by ~1.5x (https://stackoverflow.com/questions/2269063/buffer-growth-strategy).\n const newSize = oldBuffer.byteLength + (oldBuffer.byteLength >> 1) + size;\n this.#bufferView = this.#allocateBuffer(newSize);\n new Uint8Array(this.#bufferView.buffer).set(new Uint8Array(oldBuffer));\n }\n }\n\n addInt32(num: number): Writer {\n this.#ensure(4);\n this.#bufferView.setInt32(this.#offset, num, false);\n this.#offset += 4;\n return this;\n }\n\n addInt16(num: number): Writer {\n this.#ensure(2);\n this.#bufferView.setInt16(this.#offset, num, false);\n this.#offset += 2;\n return this;\n }\n\n addUint16(num: number): Writer {\n this.#ensure(2);\n this.#bufferView.setUint16(this.#offset, num, false);\n this.#offset += 2;\n return this;\n }\n\n addCString(string: string): Writer {\n if (string) {\n this.addString(string);\n }\n this.#ensure(1);\n this.#bufferView.setUint8(this.#offset, 0);\n this.#offset++;\n return this;\n }\n\n addString(string = \"\"): Writer {\n const length = byteLengthUtf8(string);\n this.#ensure(length);\n this.#encoder.encodeInto(string, new Uint8Array(this.#bufferView.buffer, this.#offset));\n this.#offset += length;\n return this;\n }\n\n add(otherBuffer: ArrayBuffer | ArrayBufferView): Writer {\n const bytes = ArrayBuffer.isView(otherBuffer)\n ? new Uint8Array(otherBuffer.buffer, otherBuffer.byteOffset, otherBuffer.byteLength)\n : new Uint8Array(otherBuffer);\n this.#ensure(bytes.byteLength);\n new Uint8Array(this.#bufferView.buffer).set(bytes, this.#offset);\n this.#offset += bytes.byteLength;\n return this;\n }\n\n #join(code?: number): ArrayBuffer {\n if (code) {\n this.#bufferView.setUint8(this.#headerPosition, code);\n // The length counts everything in the message but the code byte.\n const length = this.#offset - (this.#headerPosition + 1);\n this.#bufferView.setInt32(this.#headerPosition + 1, length, false);\n }\n return this.#bufferView.buffer.slice(code ? 0 : 5, this.#offset);\n }\n\n flush(code?: number): Uint8Array<ArrayBuffer> {\n const result = this.#join(code);\n this.#offset = 5;\n this.#bufferView = this.#allocateBuffer(this.#size);\n return new Uint8Array(result);\n }\n}\n",
|
|
7
|
+
"// Began as a copy of `@electric-sql/pg-protocol`, itself adapted from node-postgres' `pg-protocol`\n// (MIT, © Brian Carlson; ElectricSQL's changes taken under the PostgreSQL License — see NOTICE).\n// Owned outright (ADR-0062); compatibility with PGlite is an anti-goal — evolve freely.\n\nimport { Writer } from \"./buffer-writer\";\nimport { byteLengthUtf8 } from \"./string-utils\";\n\nconst code = {\n startup: 0x70,\n query: 0x51,\n parse: 0x50,\n bind: 0x42,\n execute: 0x45,\n flush: 0x48,\n sync: 0x53,\n end: 0x58,\n close: 0x43,\n describe: 0x44,\n copyFromChunk: 0x64,\n copyDone: 0x63,\n copyFail: 0x66,\n} as const;\n\ntype Code = (typeof code)[keyof typeof code];\n\n/** A bind parameter: text, raw bytes (sent as binary), or SQL NULL. */\nexport type LegalValue = string | ArrayBuffer | ArrayBufferView | null;\n\nconst writer = new Writer();\n\nfunction startup(opts: Record<string, string>): Uint8Array<ArrayBuffer> {\n // protocol version 3.0\n writer.addInt16(3).addInt16(0);\n for (const [key, value] of Object.entries(opts)) {\n writer.addCString(key).addCString(value);\n }\n writer.addCString(\"client_encoding\").addCString(\"UTF8\");\n // The startup message is sent without a type byte.\n const bodyBuffer = writer.addCString(\"\").flush();\n const length = bodyBuffer.byteLength + 4;\n return new Writer().addInt32(length).add(bodyBuffer).flush();\n}\n\nfunction requestSsl(): Uint8Array<ArrayBuffer> {\n const bufferView = new DataView(new ArrayBuffer(8));\n bufferView.setInt32(0, 8, false);\n bufferView.setInt32(4, 80877103, false);\n return new Uint8Array(bufferView.buffer);\n}\n\nfunction password(value: string): Uint8Array<ArrayBuffer> {\n return writer.addCString(value).flush(code.startup);\n}\n\nfunction sendSASLInitialResponseMessage(mechanism: string, initialResponse: string): Uint8Array<ArrayBuffer> {\n writer.addCString(mechanism).addInt32(byteLengthUtf8(initialResponse)).addString(initialResponse);\n return writer.flush(code.startup);\n}\n\nfunction sendSCRAMClientFinalMessage(additionalData: string): Uint8Array<ArrayBuffer> {\n return writer.addString(additionalData).flush(code.startup);\n}\n\nfunction query(text: string): Uint8Array<ArrayBuffer> {\n return writer.addCString(text).flush(code.query);\n}\n\nexport interface ParseOpts {\n name?: string;\n types?: readonly number[];\n text: string;\n}\n\nconst emptyValueArray: LegalValue[] = [];\n\nfunction assertParameterCount(count: number): void {\n if (count > 65_535) {\n throw new RangeError(`Postgres messages support at most 65535 parameters (received ${count})`);\n }\n}\n\nfunction parse(opts: ParseOpts): Uint8Array<ArrayBuffer> {\n const name = opts.name ?? \"\";\n if (name.length > 63) {\n throw new RangeError(`Postgres statement names are at most 63 characters: \"${name}\" (${name.length})`);\n }\n const typeCount = opts.types?.length ?? 0;\n assertParameterCount(typeCount);\n const buffer = writer.addCString(name).addCString(opts.text).addUint16(typeCount);\n opts.types?.forEach((type) => buffer.addInt32(type));\n return writer.flush(code.parse);\n}\n\ntype ValueMapper = (param: unknown, index: number) => LegalValue;\n\nexport interface BindOpts {\n portal?: string;\n binary?: boolean;\n statement?: string;\n values?: readonly LegalValue[];\n /** Optional map from a JS value to the value sent, per parameter. */\n valueMapper?: ValueMapper;\n}\n\nconst paramWriter = new Writer();\n\nconst ParamType = { STRING: 0, BINARY: 1 } as const;\n\nfunction writeValues(values: readonly LegalValue[], valueMapper?: ValueMapper): void {\n for (let i = 0; i < values.length; i++) {\n const value = values[i] ?? null;\n const mappedVal = valueMapper ? valueMapper(value, i) : value;\n if (mappedVal === null) {\n writer.addInt16(ParamType.STRING);\n // -1 is SQL NULL.\n paramWriter.addInt32(-1);\n } else if (mappedVal instanceof ArrayBuffer || ArrayBuffer.isView(mappedVal)) {\n const byteLength = mappedVal.byteLength;\n writer.addInt16(ParamType.BINARY);\n paramWriter.addInt32(byteLength);\n paramWriter.add(mappedVal);\n } else {\n writer.addInt16(ParamType.STRING);\n paramWriter.addInt32(byteLengthUtf8(mappedVal));\n paramWriter.addString(mappedVal);\n }\n }\n}\n\nfunction bind(config: BindOpts = {}): Uint8Array<ArrayBuffer> {\n const portal = config.portal ?? \"\";\n const statement = config.statement ?? \"\";\n const binary = config.binary ?? false;\n const values = config.values ?? emptyValueArray;\n const len = values.length;\n assertParameterCount(len);\n\n writer.addCString(portal).addCString(statement);\n writer.addUint16(len);\n writeValues(values, config.valueMapper);\n writer.addUint16(len);\n writer.add(paramWriter.flush());\n // result format code\n writer.addInt16(binary ? ParamType.BINARY : ParamType.STRING);\n return writer.flush(code.bind);\n}\n\nexport interface ExecOpts {\n portal?: string;\n rows?: number;\n}\n\nconst emptyExecute = new Uint8Array([code.execute, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00]);\n\nfunction execute(config?: ExecOpts): Uint8Array<ArrayBuffer> {\n if (!config || (!config.portal && !config.rows)) {\n return emptyExecute;\n }\n const portal = config.portal ?? \"\";\n const rows = config.rows ?? 0;\n const portalLength = byteLengthUtf8(portal);\n const len = 4 + portalLength + 1 + 4;\n const bufferView = new DataView(new ArrayBuffer(1 + len));\n bufferView.setUint8(0, code.execute);\n bufferView.setInt32(1, len, false);\n new TextEncoder().encodeInto(portal, new Uint8Array(bufferView.buffer, 5));\n bufferView.setUint8(portalLength + 5, 0); // the portal name's terminator\n bufferView.setUint32(bufferView.byteLength - 4, rows, false);\n return new Uint8Array(bufferView.buffer);\n}\n\nfunction cancel(processID: number, secretKey: number): Uint8Array<ArrayBuffer> {\n const bufferView = new DataView(new ArrayBuffer(16));\n bufferView.setInt32(0, 16, false);\n bufferView.setInt16(4, 1234, false);\n bufferView.setInt16(6, 5678, false);\n bufferView.setInt32(8, processID, false);\n bufferView.setInt32(12, secretKey, false);\n return new Uint8Array(bufferView.buffer);\n}\n\nexport interface PortalOpts {\n type: \"S\" | \"P\";\n name?: string;\n}\n\nfunction cstringMessage(messageCode: Code, string: string): Uint8Array<ArrayBuffer> {\n return new Writer().addCString(string).flush(messageCode);\n}\n\nconst emptyDescribePortal = writer.addCString(\"P\").flush(code.describe);\nconst emptyDescribeStatement = writer.addCString(\"S\").flush(code.describe);\n\nfunction describe(msg: PortalOpts): Uint8Array<ArrayBuffer> {\n if (msg.name) return cstringMessage(code.describe, `${msg.type}${msg.name}`);\n return msg.type === \"P\" ? emptyDescribePortal : emptyDescribeStatement;\n}\n\nfunction close(msg: PortalOpts): Uint8Array<ArrayBuffer> {\n return cstringMessage(code.close, `${msg.type}${msg.name ?? \"\"}`);\n}\n\nfunction copyData(chunk: ArrayBuffer | ArrayBufferView): Uint8Array<ArrayBuffer> {\n return writer.add(chunk).flush(code.copyFromChunk);\n}\n\nfunction copyFail(message: string): Uint8Array<ArrayBuffer> {\n return cstringMessage(code.copyFail, message);\n}\n\nconst codeOnlyBuffer = (messageCode: Code): Uint8Array<ArrayBuffer> =>\n new Uint8Array([messageCode, 0x00, 0x00, 0x00, 0x04]);\n\nconst flushBuffer = codeOnlyBuffer(code.flush);\nconst syncBuffer = codeOnlyBuffer(code.sync);\nconst endBuffer = codeOnlyBuffer(code.end);\nconst copyDoneBuffer = codeOnlyBuffer(code.copyDone);\n\n/** Frontend message builders. */\nexport const serialize = {\n startup,\n password,\n requestSsl,\n sendSASLInitialResponseMessage,\n sendSCRAMClientFinalMessage,\n query,\n parse,\n bind,\n execute,\n describe,\n close,\n flush: (): Uint8Array<ArrayBuffer> => flushBuffer,\n sync: (): Uint8Array<ArrayBuffer> => syncBuffer,\n end: (): Uint8Array<ArrayBuffer> => endBuffer,\n copyData,\n copyDone: (): Uint8Array<ArrayBuffer> => copyDoneBuffer,\n copyFail,\n cancel,\n};\n",
|
|
8
|
+
"/**\n * Wire-level access to a pgwasm instance, kept off its public type. `@pgxsinkit/pgwasm/protocol` and the\n * `live` extension reach it through this registry; pgwasm is bundled with code splitting, so every\n * entry point shares this one module and its map.\n */\n\nimport type { BuildCapabilities } from \"../build/seam\";\nimport type { BackendMessage, NoticeMessage } from \"../protocol/wire/messages\";\n\nexport interface ExecProtocolOptions {\n /** Persist storage after the message, as a statement does. Defaults to `true`. */\n readonly persist?: boolean;\n /** Throw the first ErrorResponse. Defaults to `true`. */\n readonly throwOnError?: boolean;\n readonly onNotice?: (notice: NoticeMessage) => void;\n}\n\nexport interface ExecProtocolStreamOptions {\n /** Persist storage after the message. Defaults to `true`. */\n readonly persist?: boolean;\n /** Every backend byte, as it arrives. A chunk is only valid during the call: copy it to keep it. */\n readonly onRawData: (data: Uint8Array) => void;\n}\n\nexport interface ExecProtocolResult {\n readonly messages: BackendMessage[];\n readonly data: Uint8Array;\n}\n\n/** What `protocol(pg)` returns. */\nexport interface PgwasmProtocol {\n /** Run frontend message bytes; the parsed backend messages and the raw reply. */\n execProtocol(message: Uint8Array, options?: ExecProtocolOptions): Promise<ExecProtocolResult>;\n /** Run frontend message bytes; the parsed backend messages only. */\n execProtocolStream(message: Uint8Array, options?: ExecProtocolOptions): Promise<BackendMessage[]>;\n /** Run frontend message bytes; the raw reply. Notifications and errors are still dispatched. */\n execProtocolRaw(message: Uint8Array, options?: Pick<ExecProtocolOptions, \"persist\">): Promise<Uint8Array>;\n /**\n * Run frontend message bytes and stream the raw reply. When nothing is pending and the build has\n * `synchronousExchange`, the whole reply is delivered before this call returns its promise — what a\n * tool driving it from inside a blocking wasm callback (pg_dump) needs.\n */\n execProtocolRawStream(message: Uint8Array, options: ExecProtocolStreamOptions): Promise<void>;\n /**\n * Run `fn` with the database's session to itself, for a tool whose exchanges must not interleave with\n * anything else (pg_dump). It waits for, then holds, the locks a `transaction()` holds, and the query\n * lock: no query, exec, transaction, listen, live-query refresh or Store backup of this database runs\n * until `fn` settles.\n *\n * What `fn` sends with the `execProtocol*` methods is its own responsibility: no transaction is begun\n * or ended around it, and a message is persisted only as its options say. Inside `fn`, use only these\n * wire methods: the database's query methods wait for the locks `fn` holds, so awaiting one deadlocks.\n */\n runExclusiveSession<T>(fn: () => Promise<T>): Promise<T>;\n /** The build's capabilities, e.g. to check `synchronousExchange` before relying on it. */\n readonly capabilities: BuildCapabilities;\n}\n\nconst registry = new WeakMap<object, PgwasmProtocol>();\n\nexport function registerProtocolAccess(pg: object, access: PgwasmProtocol): void {\n registry.set(pg, access);\n}\n\n/** The wire-level access of a pgwasm instance. Throws for anything else. */\nexport function protocolAccessOf(pg: object): PgwasmProtocol {\n const access = registry.get(pg);\n if (access === undefined) {\n throw new TypeError(\"Not a pgwasm instance (created by createPgwasm).\");\n }\n return access;\n}\n\n/**\n * The strict sync of a database whose data directory is an OPFS-repacked store, registered by\n * `createOpfsPgwasm` and run by `strictSync(pg)` from `@pgxsinkit/pgwasm/opfs`.\n */\nconst strictSyncs = new WeakMap<object, () => void>();\n\nexport function registerStrictSync(pg: object, strictSync: () => void): void {\n strictSyncs.set(pg, strictSync);\n}\n\n/** The registered strict sync of `pg`, or `undefined` when it has none (not an OPFS-repacked store). */\nexport function strictSyncOf(pg: object): (() => void) | undefined {\n return strictSyncs.get(pg);\n}\n"
|
|
9
|
+
],
|
|
10
|
+
"mappings": ";;AAQO,SAAS,cAAc,CAAC,KAAqB;AAAA,EAClD,IAAI,aAAa,IAAI;AAAA,EACrB,SAAS,IAAI,IAAI,SAAS,EAAG,KAAK,GAAG,KAAK;AAAA,IACxC,MAAM,OAAO,IAAI,WAAW,CAAC;AAAA,IAC7B,IAAI,OAAO,OAAQ,QAAQ;AAAA,MAAO;AAAA,IAClC,KAAK,IAAI,OAAO,QAAS,QAAQ;AAAA,MAAQ,cAAc;AAAA,IACvD,IAAI,QAAQ,SAAU,QAAQ,OAAQ;AAAA,MACpC,MAAM,WAAW,IAAI,WAAW,IAAI,CAAC;AAAA,MAErC,IAAI,YAAY,SAAU,YAAY;AAAA,QAAQ;AAAA,IAChD;AAAA,EACF;AAAA,EACA,OAAO;AAAA;;;ACbF,MAAM,OAAO;AAAA,EACT;AAAA,EACT;AAAA,EACA,UAA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|
4
|
+
} from "./chunk-ryjxx1c8.js";
|
|
5
|
+
|
|
2
6
|
// packages/pgwasm/src/errors.ts
|
|
7
|
+
class TransactionAbortedError2 extends DatabaseError2 {
|
|
8
|
+
constructor() {
|
|
9
|
+
super("Transaction was rolled back instead of committed", 0, "error");
|
|
10
|
+
this.severity = "ERROR";
|
|
11
|
+
this.code = "25P02";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
class PgwasmError2 extends Error {
|
|
4
16
|
name = "PgwasmError";
|
|
5
17
|
}
|
|
@@ -121,6 +133,6 @@ function makeQueryError(data) {
|
|
|
121
133
|
return Object.assign(data.error, { query: data.query, params: data.params, queryOptions: data.options });
|
|
122
134
|
}
|
|
123
135
|
|
|
124
|
-
export { PgwasmError2, UnsupportedDataDirError2, OpfsAhpRemovedError2, UnsupportedFilesystemError2, CrossOriginIsolationRequiredError2, ExtensionBuildMismatchError2, BuildMismatchError2, DataFormatMismatchError2, BuildMarkerUnreadableError2, DataDirExistsError2, BackupFormatError2, StorageInUseError2, PgwasmClosedError2, PgwasmFailedError2, UnsupportedFeatureError2, makeQueryError };
|
|
136
|
+
export { TransactionAbortedError2, PgwasmError2, UnsupportedDataDirError2, OpfsAhpRemovedError2, UnsupportedFilesystemError2, CrossOriginIsolationRequiredError2, ExtensionBuildMismatchError2, BuildMismatchError2, DataFormatMismatchError2, BuildMarkerUnreadableError2, DataDirExistsError2, BackupFormatError2, StorageInUseError2, PgwasmClosedError2, PgwasmFailedError2, UnsupportedFeatureError2, makeQueryError };
|
|
125
137
|
|
|
126
|
-
//# debugId=
|
|
138
|
+
//# debugId=DD5A44BC9B659C3864756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/errors.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"// Began as a copy of `@electric-sql/pglite` (taken under its PostgreSQL License option, © ElectricSQL\n// — see NOTICE): `makeQueryError` began as its `makePGliteError`. Owned outright (ADR-0062);\n// compatibility with PGlite is an anti-goal — evolve freely.\n\nimport type { BuildIdentity, FilesystemKind } from \"./build/seam\";\nimport type { QueryOptions } from \"./interface\";\nimport { DatabaseError } from \"./protocol/wire/messages\";\n\n/** COMMIT ended an aborted transaction with ROLLBACK instead of committing its writes. */\nexport class TransactionAbortedError extends DatabaseError {\n constructor() {\n super(\"Transaction was rolled back instead of committed\", 0, \"error\");\n this.severity = \"ERROR\";\n this.code = \"25P02\";\n }\n}\n\n/** The base of every error pgwasm itself raises (SQL errors are {@link DatabaseError}). */\nexport class PgwasmError extends Error {\n override name = \"PgwasmError\";\n}\n\n/** A `dataDir` pgwasm does not accept: an unknown scheme, a bare path, or `dataDir` with `fs`. */\nexport class UnsupportedDataDirError extends PgwasmError {\n override name = \"UnsupportedDataDirError\";\n readonly dataDir: string;\n\n constructor(dataDir: string, reason: string) {\n super(`Unsupported dataDir \"${dataDir}\": ${reason}`);\n this.dataDir = dataDir;\n }\n}\n\n/** An `opfs-ahp://` dataDir: that filesystem is gone (ADR-0062 decision 6). */\nexport class OpfsAhpRemovedError extends UnsupportedDataDirError {\n override name = \"OpfsAhpRemovedError\";\n /** Where the OPFS store lives now. */\n readonly replacement = \"@pgxsinkit/pgwasm/opfs\";\n\n constructor(dataDir: string) {\n super(\n dataDir,\n \"the opfs-ahp filesystem has been removed; the OPFS store is @pgxsinkit/pgwasm/opfs, passed in \" +\n \"explicitly as the `fs` option\",\n );\n }\n}\n\n/** The build does not mount the requested kind of storage. */\nexport class UnsupportedFilesystemError extends PgwasmError {\n override name = \"UnsupportedFilesystemError\";\n readonly kind: FilesystemKind;\n readonly build: string;\n\n constructor(kind: FilesystemKind, build: BuildIdentity, supported: readonly FilesystemKind[]) {\n super(\n `The \"${build.name}\" Postgres build does not support ${kind} storage (it supports: ${supported.join(\", \")}).`,\n );\n this.kind = kind;\n this.build = build.name;\n }\n}\n\n/** The build needs a cross-origin-isolated context, and this one is not. */\nexport class CrossOriginIsolationRequiredError extends PgwasmError {\n override name = \"CrossOriginIsolationRequiredError\";\n\n constructor(build: BuildIdentity) {\n super(\n `The \"${build.name}\" Postgres build needs a cross-origin-isolated context (SharedArrayBuffer); serve the ` +\n \"page with Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp.\",\n );\n }\n}\n\n/** A server extension compiled for another build. */\nexport class ExtensionBuildMismatchError extends PgwasmError {\n override name = \"ExtensionBuildMismatchError\";\n\n constructor(extension: string, extensionBuild: string, build: BuildIdentity) {\n super(\n `The \"${extension}\" extension was compiled for the \"${extensionBuild}\" Postgres build and cannot load into ` +\n `the \"${build.name}\" build.`,\n );\n }\n}\n\n/** The build a data directory (or a Store backup) records. `\"unmarked\"` predates build markers. */\nexport type RecordedBuild = { readonly build: string; readonly dataFormat: number } | \"unmarked\";\n\nfunction describeRecorded(recorded: RecordedBuild): string {\n return recorded === \"unmarked\"\n ? \"an unmarked data directory (created before builds were recorded, by the C build)\"\n : `the \"${recorded.build}\" Postgres build (data format ${recorded.dataFormat})`;\n}\n\n/**\n * A data directory or Store backup made by another Postgres build. A store's build is fixed when it is\n * created (ADR-0063 build permanence); nothing was written.\n */\nexport class BuildMismatchError extends PgwasmError {\n override name = \"BuildMismatchError\";\n readonly expected: { readonly build: string; readonly dataFormat: number };\n readonly found: RecordedBuild;\n readonly source: \"data-directory\" | \"backup\";\n\n constructor(build: BuildIdentity, found: RecordedBuild, source: \"data-directory\" | \"backup\") {\n const what = source === \"backup\" ? \"This Store backup\" : \"This data directory\";\n super(\n `${what} was created by ${describeRecorded(found)} and cannot be opened with the \"${build.name}\" build. A ` +\n \"store's Postgres build is fixed when it is created: open it with that build, or destroy the store and \" +\n \"re-sync it.\",\n );\n this.expected = { build: build.name, dataFormat: build.dataFormat };\n this.found = found;\n this.source = source;\n }\n}\n\n/** A data directory or backup of the same build in a data format this release does not read. */\nexport class DataFormatMismatchError extends PgwasmError {\n override name = \"DataFormatMismatchError\";\n readonly expected: number;\n readonly found: number;\n readonly source: \"data-directory\" | \"backup\";\n\n constructor(build: BuildIdentity, found: number, source: \"data-directory\" | \"backup\") {\n super(\n `This ${source === \"backup\" ? \"Store backup\" : \"data directory\"} is in data format ${found} of the ` +\n `\"${build.name}\" Postgres build; this release of the build reads format ${build.dataFormat}.`,\n );\n this.expected = build.dataFormat;\n this.found = found;\n this.source = source;\n }\n}\n\n/** A build marker that cannot be read: corrupt, or written by a newer pgwasm. Nothing was written. */\nexport class BuildMarkerUnreadableError extends PgwasmError {\n override name = \"BuildMarkerUnreadableError\";\n readonly raw: string;\n\n constructor(raw: string, reason: string) {\n super(`The data directory's build marker cannot be read (${reason}): ${JSON.stringify(raw)}`);\n this.raw = raw;\n }\n}\n\n/** `loadDataDir` was given for a data directory that already holds a database. */\nexport class DataDirExistsError extends PgwasmError {\n override name = \"DataDirExistsError\";\n\n constructor() {\n super(\"The data directory already holds a database; a Store backup restores only into an empty one.\");\n }\n}\n\n/** A Store backup that cannot be restored: not a tarball, or a member outside the data directory. */\nexport class BackupFormatError extends PgwasmError {\n override name = \"BackupFormatError\";\n}\n\n/** The storage is held by another open database (an IndexedDB store open in another context). */\nexport class StorageInUseError extends PgwasmError {\n override name = \"StorageInUseError\";\n\n constructor(message: string) {\n super(message);\n }\n}\n\n/** The database is closing or closed. */\nexport class PgwasmClosedError extends PgwasmError {\n override name = \"PgwasmClosedError\";\n\n constructor(state: \"closing\" | \"closed\") {\n super(`pgwasm is ${state}`);\n }\n}\n\n/**\n * The Postgres build failed underneath a statement (an exception that is not an SQL error: a storage\n * failure thrown into the engine, a PANIC's abort). The instance is failed: every later statement\n * throws this same error, and `close()` releases resources and rejects with it.\n */\nexport class PgwasmFailedError extends PgwasmError {\n override name = \"PgwasmFailedError\";\n}\n\n/** A feature the build does not have (see its capabilities). */\nexport class UnsupportedFeatureError extends PgwasmError {\n override name = \"UnsupportedFeatureError\";\n}\n\n/** An SQL error from a query, with the query that raised it. */\nexport interface QueryError extends DatabaseError {\n query: string | undefined;\n params: readonly unknown[] | undefined;\n queryOptions: QueryOptions | undefined;\n}\n\n/** Attach the query to the SQL error it raised. */\nexport function makeQueryError(data: {\n error: DatabaseError;\n query: string;\n params: readonly unknown[] | undefined;\n options: QueryOptions | undefined;\n}): QueryError {\n return Object.assign(data.error, { query: data.query, params: data.params, queryOptions: data.options });\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;AASO,MAAM,iCAAgC,eAAc;AAAA,EACzD,WAAW,GAAG;AAAA,IACZ,MAAM,oDAAoD,GAAG,OAAO;AAAA,IACpE,KAAK,WAAW;AAAA,IAChB,KAAK,OAAO;AAAA;AAEhB;AAAA;AAGO,MAAM,qBAAoB,MAAM;AAAA,EAC5B,OAAO;AAClB;AAAA;AAGO,MAAM,iCAAgC,aAAY;AAAA,EAC9C,OAAO;AAAA,EACP;AAAA,EAET,WAAW,CAAC,SAAiB,QAAgB;AAAA,IAC3C,MAAM,wBAAwB,aAAa,QAAQ;AAAA,IACnD,KAAK,UAAU;AAAA;AAEnB;AAAA;AAGO,MAAM,6BAA4B,yBAAwB;AAAA,EACtD,OAAO;AAAA,EAEP,cAAc;AAAA,EAEvB,WAAW,CAAC,SAAiB;AAAA,IAC3B,MACE,SACA,mGACE,+BACJ;AAAA;AAEJ;AAAA;AAGO,MAAM,oCAAmC,aAAY;AAAA,EACjD,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EAET,WAAW,CAAC,MAAsB,OAAsB,WAAsC;AAAA,IAC5F,MACE,QAAQ,MAAM,yCAAyC,8BAA8B,UAAU,KAAK,IAAI,KAC1G;AAAA,IACA,KAAK,OAAO;AAAA,IACZ,KAAK,QAAQ,MAAM;AAAA;AAEvB;AAAA;AAGO,MAAM,2CAA0C,aAAY;AAAA,EACxD,OAAO;AAAA,EAEhB,WAAW,CAAC,OAAsB;AAAA,IAChC,MACE,QAAQ,MAAM,+FACZ,mGACJ;AAAA;AAEJ;AAAA;AAGO,MAAM,qC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A8F;AAAA;AAExG;AAAA;AAGO,MAAM,2BAA0B,aAAY;AAAA,EACxC,OAAO;AAClB;AAAA;AAGO,MAAM,2BAA0B,aAAY;AAAA,EACxC,OAAO;AAAA,EAEhB,WAAW,CAAC,SAAiB;AAAA,IAC3B,MAAM,OAAO;AAAA;AAEjB;AAAA;AAGO,MAAM,2BAA0B,aAAY;AAAA,EACxC,OAAO;AAAA,EAEhB,WAAW,CAAC,OAA6B;AAAA,IACvC,MAAM,aAAa,OAAO;AAAA;AAE9B;AAAA;AAOO,MAAM,2BAA0B,aAAY;AAAA,EACxC,OAAO;AAClB;AAAA;AAGO,MAAM,iCAAgC,aAAY;AAAA,EAC9C,OAAO;AAClB;AAUO,SAAS,cAAc,CAAC,MAKhB;AAAA,EACb,OAAO,OAAO,OAAO,KAAK,OAAO,EAAE,OAAO,KAAK,OAAO,QAAQ,KAAK,QAAQ,cAAc,KAAK,QAAQ,CAAC;AAAA;",
|
|
8
|
+
"debugId": "DD5A44BC9B659C3864756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
parseType
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4eb2pcfr.js";
|
|
5
5
|
import {
|
|
6
6
|
RowDescriptionMessage,
|
|
7
7
|
ParameterDescriptionMessage,
|
|
8
8
|
CommandCompleteMessage,
|
|
9
9
|
DataRowMessage
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ryjxx1c8.js";
|
|
11
11
|
|
|
12
12
|
// packages/pgwasm/src/core/names.ts
|
|
13
13
|
function toPostgresName(input) {
|