@effect/sql-pg 4.0.0-rc.110 → 4.0.0-rc.112
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/ai-docs/package.json +2 -2
- package/dist/PgAuth.d.ts +69 -0
- package/dist/PgAuth.d.ts.map +1 -0
- package/dist/PgAuth.js +202 -0
- package/dist/PgAuth.js.map +1 -0
- package/dist/PgProtocol.d.ts +750 -0
- package/dist/PgProtocol.d.ts.map +1 -0
- package/dist/PgProtocol.js +1160 -0
- package/dist/PgProtocol.js.map +1 -0
- package/dist/PgTypes.d.ts +361 -0
- package/dist/PgTypes.d.ts.map +1 -0
- package/dist/PgTypes.js +1514 -0
- package/dist/PgTypes.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/package.json +11 -7
- package/src/PgAuth.ts +287 -0
- package/src/PgProtocol.ts +1820 -0
- package/src/PgTypes.ts +1930 -0
- package/src/index.ts +15 -0
|
@@ -0,0 +1,750 @@
|
|
|
1
|
+
import * as Result from "effect/Result";
|
|
2
|
+
/**
|
|
3
|
+
* Default `maxMessageSize` for `makeParser`: 16 MiB.
|
|
4
|
+
*
|
|
5
|
+
* @category constants
|
|
6
|
+
* @since 4.0.0
|
|
7
|
+
*/
|
|
8
|
+
export declare const defaultMaxMessageSize: number;
|
|
9
|
+
/**
|
|
10
|
+
* An incremental decoder for the post-startup backend message stream.
|
|
11
|
+
*
|
|
12
|
+
* @category models
|
|
13
|
+
* @since 4.0.0
|
|
14
|
+
*/
|
|
15
|
+
export interface Parser<A = Uint8Array | null> {
|
|
16
|
+
/**
|
|
17
|
+
* Reads each `DataRow` field, for a parser built with one. A result's
|
|
18
|
+
* columns are only known from its `RowDescription`, which arrives on the
|
|
19
|
+
* same stream, so this is settable: replace it when the columns change.
|
|
20
|
+
*/
|
|
21
|
+
readField: FieldReader<A> | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Feeds the next chunk of socket bytes and returns every message that is now
|
|
24
|
+
* complete. A partial trailing message is retained until the bytes that
|
|
25
|
+
* finish it arrive. A thrown parse or field-reader error is terminal and the
|
|
26
|
+
* parser cannot be reused afterward; any messages decoded earlier in the
|
|
27
|
+
* failing push are discarded.
|
|
28
|
+
*
|
|
29
|
+
* Byte fields on the returned messages - `DataRow` values, `CopyData` and
|
|
30
|
+
* `Unknown` payloads - are views into an internal buffer that the parser
|
|
31
|
+
* never rewrites, so they stay valid for as long as they are held. They are
|
|
32
|
+
* meant to be consumed before the next `push`: holding one keeps its whole
|
|
33
|
+
* buffer alive, so copy it if it has to outlive the row.
|
|
34
|
+
*/
|
|
35
|
+
readonly push: (chunk: Uint8Array) => ReadonlyArray<BackendMessage<A>>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates a `Parser`.
|
|
39
|
+
*
|
|
40
|
+
* Special pre-startup replies have no type byte and are not handled here; use
|
|
41
|
+
* `decodeSslResponse` for those.
|
|
42
|
+
*
|
|
43
|
+
* @category constructors
|
|
44
|
+
* @since 4.0.0
|
|
45
|
+
*/
|
|
46
|
+
export declare const makeParser: <A = Uint8Array | null>(options?: {
|
|
47
|
+
readonly maxMessageSize?: number | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Reads each `DataRow` field as it is parsed, so a client that decodes its
|
|
50
|
+
* columns never needs a view per column. Without one every field is handed
|
|
51
|
+
* out as a view, which is the default.
|
|
52
|
+
*/
|
|
53
|
+
readonly readField?: FieldReader<A> | undefined;
|
|
54
|
+
}) => Parser<A>;
|
|
55
|
+
/**
|
|
56
|
+
* Prepares a named or unnamed statement.
|
|
57
|
+
*
|
|
58
|
+
* @category models
|
|
59
|
+
* @since 4.0.0
|
|
60
|
+
*/
|
|
61
|
+
export interface Parse {
|
|
62
|
+
readonly _tag: "Parse";
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly query: string;
|
|
65
|
+
readonly parameterTypes: ReadonlyArray<number>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Binds parameter values to a prepared statement, creating a portal.
|
|
69
|
+
*
|
|
70
|
+
* Parameters and results always use the binary format code.
|
|
71
|
+
*
|
|
72
|
+
* @category models
|
|
73
|
+
* @since 4.0.0
|
|
74
|
+
*/
|
|
75
|
+
export interface Bind {
|
|
76
|
+
readonly _tag: "Bind";
|
|
77
|
+
readonly portal: string;
|
|
78
|
+
readonly statement: string;
|
|
79
|
+
readonly parameters: ReadonlyArray<Uint8Array | null>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Runs a portal, optionally limiting the number of rows returned.
|
|
83
|
+
*
|
|
84
|
+
* @category models
|
|
85
|
+
* @since 4.0.0
|
|
86
|
+
*/
|
|
87
|
+
export interface Execute {
|
|
88
|
+
readonly _tag: "Execute";
|
|
89
|
+
readonly portal: string;
|
|
90
|
+
readonly maxRows: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Which kind of object a `Describe` or `Close` message names.
|
|
94
|
+
*
|
|
95
|
+
* @category models
|
|
96
|
+
* @since 4.0.0
|
|
97
|
+
*/
|
|
98
|
+
export type DescribeTarget = "statement" | "portal";
|
|
99
|
+
/**
|
|
100
|
+
* Asks for the parameter and row shape of a statement or portal.
|
|
101
|
+
*
|
|
102
|
+
* @category models
|
|
103
|
+
* @since 4.0.0
|
|
104
|
+
*/
|
|
105
|
+
export interface Describe {
|
|
106
|
+
readonly _tag: "Describe";
|
|
107
|
+
readonly target: DescribeTarget;
|
|
108
|
+
readonly name: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Drops a prepared statement or portal.
|
|
112
|
+
*
|
|
113
|
+
* @category models
|
|
114
|
+
* @since 4.0.0
|
|
115
|
+
*/
|
|
116
|
+
export interface Close {
|
|
117
|
+
readonly _tag: "Close";
|
|
118
|
+
readonly target: DescribeTarget;
|
|
119
|
+
readonly name: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Closes the current transaction block and requests a `ReadyForQuery`.
|
|
123
|
+
*
|
|
124
|
+
* @category models
|
|
125
|
+
* @since 4.0.0
|
|
126
|
+
*/
|
|
127
|
+
export interface Sync {
|
|
128
|
+
readonly _tag: "Sync";
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Asks the backend to deliver buffered output without ending the transaction.
|
|
132
|
+
*
|
|
133
|
+
* @category models
|
|
134
|
+
* @since 4.0.0
|
|
135
|
+
*/
|
|
136
|
+
export interface Flush {
|
|
137
|
+
readonly _tag: "Flush";
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Ends the session.
|
|
141
|
+
*
|
|
142
|
+
* @category models
|
|
143
|
+
* @since 4.0.0
|
|
144
|
+
*/
|
|
145
|
+
export interface Terminate {
|
|
146
|
+
readonly _tag: "Terminate";
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Answers a cleartext or MD5 password request.
|
|
150
|
+
*
|
|
151
|
+
* @category models
|
|
152
|
+
* @since 4.0.0
|
|
153
|
+
*/
|
|
154
|
+
export interface PasswordMessage {
|
|
155
|
+
readonly _tag: "PasswordMessage";
|
|
156
|
+
readonly password: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Selects a SASL mechanism and carries its opaque initial response.
|
|
160
|
+
*
|
|
161
|
+
* @category models
|
|
162
|
+
* @since 4.0.0
|
|
163
|
+
*/
|
|
164
|
+
export interface SASLInitialResponse {
|
|
165
|
+
readonly _tag: "SASLInitialResponse";
|
|
166
|
+
readonly mechanism: string;
|
|
167
|
+
readonly initialResponse: Uint8Array | null;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Carries an opaque SASL continuation payload.
|
|
171
|
+
*
|
|
172
|
+
* @category models
|
|
173
|
+
* @since 4.0.0
|
|
174
|
+
*/
|
|
175
|
+
export interface SASLResponse {
|
|
176
|
+
readonly _tag: "SASLResponse";
|
|
177
|
+
readonly data: Uint8Array;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Any message the client sends after startup.
|
|
181
|
+
*
|
|
182
|
+
* @category models
|
|
183
|
+
* @since 4.0.0
|
|
184
|
+
*/
|
|
185
|
+
export type FrontendMessage = Parse | Bind | Execute | Describe | Close | Sync | Flush | Terminate | PasswordMessage | SASLInitialResponse | SASLResponse;
|
|
186
|
+
declare const ParseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
187
|
+
readonly _tag: "PgProtocolParseError";
|
|
188
|
+
} & Readonly<A>;
|
|
189
|
+
/**
|
|
190
|
+
* Error produced when bytes cannot be interpreted as a protocol message.
|
|
191
|
+
*
|
|
192
|
+
* @category errors
|
|
193
|
+
* @since 4.0.0
|
|
194
|
+
*/
|
|
195
|
+
export declare class ParseError extends ParseError_base<{
|
|
196
|
+
readonly message: string;
|
|
197
|
+
}> {
|
|
198
|
+
}
|
|
199
|
+
declare const EncodeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
200
|
+
readonly _tag: "PgProtocolEncodeError";
|
|
201
|
+
} & Readonly<A>;
|
|
202
|
+
/**
|
|
203
|
+
* Error returned when a frontend message cannot be encoded.
|
|
204
|
+
*
|
|
205
|
+
* @category errors
|
|
206
|
+
* @since 4.0.0
|
|
207
|
+
*/
|
|
208
|
+
export declare class EncodeError extends EncodeError_base<{
|
|
209
|
+
readonly message: string;
|
|
210
|
+
}> {
|
|
211
|
+
}
|
|
212
|
+
export declare const encodeParse: (options: Omit<Parse, "_tag">) => Result.Result<Uint8Array, EncodeError>;
|
|
213
|
+
export declare const encodeBind: (options: Omit<Bind, "_tag">) => Result.Result<Uint8Array, EncodeError>;
|
|
214
|
+
/**
|
|
215
|
+
* Where a value writes its wire bytes. `Bind` frames a parameter by leaving
|
|
216
|
+
* room for its length, letting the sink fill in the body, and backfilling the
|
|
217
|
+
* length from what was written, so a value never needs an array of its own.
|
|
218
|
+
*
|
|
219
|
+
* `PgTypes.writeParameter` is the implementation for OID-typed values.
|
|
220
|
+
*
|
|
221
|
+
* @category models
|
|
222
|
+
* @since 4.0.0
|
|
223
|
+
*/
|
|
224
|
+
export interface ValueSink {
|
|
225
|
+
readonly uint8: (value: number) => void;
|
|
226
|
+
readonly int16: (value: number) => void;
|
|
227
|
+
readonly int32: (value: number) => void;
|
|
228
|
+
readonly float32: (value: number) => void;
|
|
229
|
+
readonly float64: (value: number) => void;
|
|
230
|
+
readonly bigInt64: (value: bigint) => void;
|
|
231
|
+
readonly raw: (value: Uint8Array) => void;
|
|
232
|
+
readonly utf8: (value: string) => void;
|
|
233
|
+
/** Writes SQL NULL. The value must write nothing else. */
|
|
234
|
+
readonly sqlNull: () => void;
|
|
235
|
+
/**
|
|
236
|
+
* Leaves room for an int32 length and returns a token for `endLength`, so a
|
|
237
|
+
* value that contains other values can frame them without knowing their
|
|
238
|
+
* sizes up front. Tokens nest, and must be closed in the order they were
|
|
239
|
+
* opened.
|
|
240
|
+
*/
|
|
241
|
+
readonly beginLength: () => number;
|
|
242
|
+
/** Backfills the length of everything written since its `beginLength`. */
|
|
243
|
+
readonly endLength: (token: number) => void;
|
|
244
|
+
}
|
|
245
|
+
export declare const makeBindEncoder: <A, E = never>(writeParameter: (sink: ValueSink, value: A) => Result.Result<void, E>) => (options: {
|
|
246
|
+
readonly portal: string;
|
|
247
|
+
readonly statement: string;
|
|
248
|
+
readonly parameters: ReadonlyArray<A>;
|
|
249
|
+
}) => Result.Result<Uint8Array, EncodeError | E>;
|
|
250
|
+
/**
|
|
251
|
+
* Encodes an `Execute` message.
|
|
252
|
+
*
|
|
253
|
+
* @category encoding
|
|
254
|
+
* @since 4.0.0
|
|
255
|
+
*/
|
|
256
|
+
export declare const encodeExecute: (options: Omit<Execute, "_tag">) => Uint8Array;
|
|
257
|
+
/**
|
|
258
|
+
* Encodes a `Describe` message.
|
|
259
|
+
*
|
|
260
|
+
* @category encoding
|
|
261
|
+
* @since 4.0.0
|
|
262
|
+
*/
|
|
263
|
+
export declare const encodeDescribe: (options: Omit<Describe, "_tag">) => Uint8Array;
|
|
264
|
+
/**
|
|
265
|
+
* Encodes a `Close` message.
|
|
266
|
+
*
|
|
267
|
+
* @category encoding
|
|
268
|
+
* @since 4.0.0
|
|
269
|
+
*/
|
|
270
|
+
export declare const encodeClose: (options: Omit<Close, "_tag">) => Uint8Array;
|
|
271
|
+
/**
|
|
272
|
+
* Encodes a `Sync` message.
|
|
273
|
+
*
|
|
274
|
+
* @category encoding
|
|
275
|
+
* @since 4.0.0
|
|
276
|
+
*/
|
|
277
|
+
export declare const encodeSync: () => Uint8Array;
|
|
278
|
+
/**
|
|
279
|
+
* Encodes a `Flush` message.
|
|
280
|
+
*
|
|
281
|
+
* @category encoding
|
|
282
|
+
* @since 4.0.0
|
|
283
|
+
*/
|
|
284
|
+
export declare const encodeFlush: () => Uint8Array;
|
|
285
|
+
/**
|
|
286
|
+
* Encodes a `Terminate` message.
|
|
287
|
+
*
|
|
288
|
+
* @category encoding
|
|
289
|
+
* @since 4.0.0
|
|
290
|
+
*/
|
|
291
|
+
export declare const encodeTerminate: () => Uint8Array;
|
|
292
|
+
/**
|
|
293
|
+
* Encodes a `PasswordMessage`. The password is sent verbatim, so MD5 hashing
|
|
294
|
+
* belongs to the caller - see `PgAuth.md5Password`.
|
|
295
|
+
*
|
|
296
|
+
* @category encoding
|
|
297
|
+
* @since 4.0.0
|
|
298
|
+
*/
|
|
299
|
+
export declare const encodePasswordMessage: (options: Omit<PasswordMessage, "_tag">) => Uint8Array;
|
|
300
|
+
/**
|
|
301
|
+
* Encodes a `SASLInitialResponse` message.
|
|
302
|
+
*
|
|
303
|
+
* @category encoding
|
|
304
|
+
* @since 4.0.0
|
|
305
|
+
*/
|
|
306
|
+
export declare const encodeSASLInitialResponse: (options: Omit<SASLInitialResponse, "_tag">) => Uint8Array;
|
|
307
|
+
/**
|
|
308
|
+
* Encodes a `SASLResponse` message.
|
|
309
|
+
*
|
|
310
|
+
* @category encoding
|
|
311
|
+
* @since 4.0.0
|
|
312
|
+
*/
|
|
313
|
+
export declare const encodeSASLResponse: (options: Omit<SASLResponse, "_tag">) => Uint8Array;
|
|
314
|
+
/**
|
|
315
|
+
* Encodes any frontend message.
|
|
316
|
+
*
|
|
317
|
+
* @category encoding
|
|
318
|
+
* @since 4.0.0
|
|
319
|
+
*/
|
|
320
|
+
export declare const encode: (message: FrontendMessage) => Result.Result<Uint8Array, EncodeError>;
|
|
321
|
+
/**
|
|
322
|
+
* Startup parameters. `user` is required; any other run-time parameter the
|
|
323
|
+
* server accepts may be passed alongside it.
|
|
324
|
+
*
|
|
325
|
+
* @category models
|
|
326
|
+
* @since 4.0.0
|
|
327
|
+
*/
|
|
328
|
+
export interface StartupParameters {
|
|
329
|
+
readonly [key: string]: string | undefined;
|
|
330
|
+
readonly user: string;
|
|
331
|
+
readonly database?: string | undefined;
|
|
332
|
+
readonly application_name?: string | undefined;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Encodes an `SSLRequest`. It has no type byte and is only valid before
|
|
336
|
+
* startup.
|
|
337
|
+
*
|
|
338
|
+
* @category encoding
|
|
339
|
+
* @since 4.0.0
|
|
340
|
+
*/
|
|
341
|
+
export declare const encodeSslRequest: () => Uint8Array;
|
|
342
|
+
/**
|
|
343
|
+
* Decodes the single byte the server sends in reply to an `SSLRequest`. `"S"`
|
|
344
|
+
* means the server will speak TLS, `"N"` means it will not.
|
|
345
|
+
*
|
|
346
|
+
* @category decoding
|
|
347
|
+
* @since 4.0.0
|
|
348
|
+
*/
|
|
349
|
+
export declare const decodeSslResponse: (byte: number) => Result.Result<"S" | "N", ParseError>;
|
|
350
|
+
/**
|
|
351
|
+
* Encodes a `StartupMessage` for protocol 3.0. It has no type byte.
|
|
352
|
+
* `client_encoding` defaults to `UTF8` because this codec always writes UTF-8.
|
|
353
|
+
*
|
|
354
|
+
* @category encoding
|
|
355
|
+
* @since 4.0.0
|
|
356
|
+
*/
|
|
357
|
+
export declare const encodeStartupMessage: (parameters: StartupParameters) => Uint8Array;
|
|
358
|
+
/**
|
|
359
|
+
* Encodes a `CancelRequest`. It has no type byte and is sent on a separate
|
|
360
|
+
* connection, using the `pid` and `secret` from `BackendKeyData`.
|
|
361
|
+
*
|
|
362
|
+
* @category encoding
|
|
363
|
+
* @since 4.0.0
|
|
364
|
+
*/
|
|
365
|
+
export declare const encodeCancelRequest: (options: {
|
|
366
|
+
readonly pid: number;
|
|
367
|
+
readonly secret: number;
|
|
368
|
+
}) => Uint8Array;
|
|
369
|
+
/**
|
|
370
|
+
* Authentication succeeded.
|
|
371
|
+
*
|
|
372
|
+
* @category models
|
|
373
|
+
* @since 4.0.0
|
|
374
|
+
*/
|
|
375
|
+
export interface AuthenticationOk {
|
|
376
|
+
readonly _tag: "AuthenticationOk";
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* The server wants the password in the clear.
|
|
380
|
+
*
|
|
381
|
+
* @category models
|
|
382
|
+
* @since 4.0.0
|
|
383
|
+
*/
|
|
384
|
+
export interface AuthenticationCleartextPassword {
|
|
385
|
+
readonly _tag: "AuthenticationCleartextPassword";
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* The server wants an MD5-hashed password, salted with these four bytes.
|
|
389
|
+
*
|
|
390
|
+
* @category models
|
|
391
|
+
* @since 4.0.0
|
|
392
|
+
*/
|
|
393
|
+
export interface AuthenticationMD5Password {
|
|
394
|
+
readonly _tag: "AuthenticationMD5Password";
|
|
395
|
+
readonly salt: Uint8Array;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* The server offers these SASL mechanisms.
|
|
399
|
+
*
|
|
400
|
+
* @category models
|
|
401
|
+
* @since 4.0.0
|
|
402
|
+
*/
|
|
403
|
+
export interface AuthenticationSASL {
|
|
404
|
+
readonly _tag: "AuthenticationSASL";
|
|
405
|
+
readonly mechanisms: ReadonlyArray<string>;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* An opaque SASL challenge.
|
|
409
|
+
*
|
|
410
|
+
* @category models
|
|
411
|
+
* @since 4.0.0
|
|
412
|
+
*/
|
|
413
|
+
export interface AuthenticationSASLContinue {
|
|
414
|
+
readonly _tag: "AuthenticationSASLContinue";
|
|
415
|
+
readonly data: Uint8Array;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* The opaque final SASL payload, carrying the server signature.
|
|
419
|
+
*
|
|
420
|
+
* @category models
|
|
421
|
+
* @since 4.0.0
|
|
422
|
+
*/
|
|
423
|
+
export interface AuthenticationSASLFinal {
|
|
424
|
+
readonly _tag: "AuthenticationSASLFinal";
|
|
425
|
+
readonly data: Uint8Array;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* An authentication request this codec does not model, such as GSSAPI or
|
|
429
|
+
* SSPI. The `method` is the raw sub-type integer.
|
|
430
|
+
*
|
|
431
|
+
* @category models
|
|
432
|
+
* @since 4.0.0
|
|
433
|
+
*/
|
|
434
|
+
export interface AuthenticationUnsupported {
|
|
435
|
+
readonly _tag: "AuthenticationUnsupported";
|
|
436
|
+
readonly method: number;
|
|
437
|
+
readonly payload: Uint8Array;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Reports a run-time parameter value, at startup or whenever it changes.
|
|
441
|
+
*
|
|
442
|
+
* @category models
|
|
443
|
+
* @since 4.0.0
|
|
444
|
+
*/
|
|
445
|
+
export interface ParameterStatus {
|
|
446
|
+
readonly _tag: "ParameterStatus";
|
|
447
|
+
readonly name: string;
|
|
448
|
+
readonly value: string;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* The identity a `CancelRequest` needs.
|
|
452
|
+
*
|
|
453
|
+
* @category models
|
|
454
|
+
* @since 4.0.0
|
|
455
|
+
*/
|
|
456
|
+
export interface BackendKeyData {
|
|
457
|
+
readonly _tag: "BackendKeyData";
|
|
458
|
+
readonly pid: number;
|
|
459
|
+
readonly secret: number;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Transaction status: idle, in a transaction block, or in a failed
|
|
463
|
+
* transaction block.
|
|
464
|
+
*
|
|
465
|
+
* @category models
|
|
466
|
+
* @since 4.0.0
|
|
467
|
+
*/
|
|
468
|
+
export type TransactionStatus = "I" | "T" | "E";
|
|
469
|
+
/**
|
|
470
|
+
* The backend is ready for a new query cycle.
|
|
471
|
+
*
|
|
472
|
+
* @category models
|
|
473
|
+
* @since 4.0.0
|
|
474
|
+
*/
|
|
475
|
+
export interface ReadyForQuery {
|
|
476
|
+
readonly _tag: "ReadyForQuery";
|
|
477
|
+
readonly status: TransactionStatus;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* One column of a `RowDescription`.
|
|
481
|
+
*
|
|
482
|
+
* @category models
|
|
483
|
+
* @since 4.0.0
|
|
484
|
+
*/
|
|
485
|
+
export interface FieldDescription {
|
|
486
|
+
readonly name: string;
|
|
487
|
+
readonly tableOid: number;
|
|
488
|
+
readonly columnAttributeNumber: number;
|
|
489
|
+
readonly dataTypeOid: number;
|
|
490
|
+
readonly dataTypeSize: number;
|
|
491
|
+
readonly typeModifier: number;
|
|
492
|
+
readonly format: number;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Describes the columns a portal will return.
|
|
496
|
+
*
|
|
497
|
+
* @category models
|
|
498
|
+
* @since 4.0.0
|
|
499
|
+
*/
|
|
500
|
+
export interface RowDescription {
|
|
501
|
+
readonly _tag: "RowDescription";
|
|
502
|
+
readonly fields: ReadonlyArray<FieldDescription>;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* One result row. Values stay raw bytes; `null` is SQL NULL. Decoding them
|
|
506
|
+
* requires the OIDs from the matching `RowDescription`.
|
|
507
|
+
*
|
|
508
|
+
* @category models
|
|
509
|
+
* @since 4.0.0
|
|
510
|
+
*/
|
|
511
|
+
export interface DataRow<out A = Uint8Array | null> {
|
|
512
|
+
readonly _tag: "DataRow";
|
|
513
|
+
readonly values: ReadonlyArray<A>;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Reads one `DataRow` field out of the parser's buffer, for a parser given a
|
|
517
|
+
* `readField`. `size` is -1 for SQL NULL, and `column` is the field's position
|
|
518
|
+
* in the row.
|
|
519
|
+
*
|
|
520
|
+
* The bytes are the parser's buffer rather than a view of the field, so they
|
|
521
|
+
* are only the field's for `offset` to `offset + size`, and reading outside
|
|
522
|
+
* that reads the rest of the stream. `PgTypes.makeFieldReader` is the
|
|
523
|
+
* implementation for OID-typed columns.
|
|
524
|
+
*
|
|
525
|
+
* A reader runs inside the stateful parser. If it throws, that failure is
|
|
526
|
+
* terminal just like a `ParseError`.
|
|
527
|
+
*
|
|
528
|
+
* @category models
|
|
529
|
+
* @since 4.0.0
|
|
530
|
+
*/
|
|
531
|
+
export type FieldReader<A> = (bytes: Uint8Array, offset: number, size: number, column: number) => A;
|
|
532
|
+
/**
|
|
533
|
+
* A command finished, reporting its tag such as `SELECT 3`.
|
|
534
|
+
*
|
|
535
|
+
* @category models
|
|
536
|
+
* @since 4.0.0
|
|
537
|
+
*/
|
|
538
|
+
export interface CommandComplete {
|
|
539
|
+
readonly _tag: "CommandComplete";
|
|
540
|
+
readonly commandTag: string;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* The query string was empty.
|
|
544
|
+
*
|
|
545
|
+
* @category models
|
|
546
|
+
* @since 4.0.0
|
|
547
|
+
*/
|
|
548
|
+
export interface EmptyQueryResponse {
|
|
549
|
+
readonly _tag: "EmptyQueryResponse";
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* The statement or portal returns no rows.
|
|
553
|
+
*
|
|
554
|
+
* @category models
|
|
555
|
+
* @since 4.0.0
|
|
556
|
+
*/
|
|
557
|
+
export interface NoData {
|
|
558
|
+
readonly _tag: "NoData";
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* A `Parse` succeeded.
|
|
562
|
+
*
|
|
563
|
+
* @category models
|
|
564
|
+
* @since 4.0.0
|
|
565
|
+
*/
|
|
566
|
+
export interface ParseComplete {
|
|
567
|
+
readonly _tag: "ParseComplete";
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* A `Bind` succeeded.
|
|
571
|
+
*
|
|
572
|
+
* @category models
|
|
573
|
+
* @since 4.0.0
|
|
574
|
+
*/
|
|
575
|
+
export interface BindComplete {
|
|
576
|
+
readonly _tag: "BindComplete";
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* A `Close` succeeded.
|
|
580
|
+
*
|
|
581
|
+
* @category models
|
|
582
|
+
* @since 4.0.0
|
|
583
|
+
*/
|
|
584
|
+
export interface CloseComplete {
|
|
585
|
+
readonly _tag: "CloseComplete";
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* An `Execute` stopped at its row limit; the portal can be executed again.
|
|
589
|
+
*
|
|
590
|
+
* @category models
|
|
591
|
+
* @since 4.0.0
|
|
592
|
+
*/
|
|
593
|
+
export interface PortalSuspended {
|
|
594
|
+
readonly _tag: "PortalSuspended";
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* The parameter OIDs of a described statement.
|
|
598
|
+
*
|
|
599
|
+
* @category models
|
|
600
|
+
* @since 4.0.0
|
|
601
|
+
*/
|
|
602
|
+
export interface ParameterDescription {
|
|
603
|
+
readonly _tag: "ParameterDescription";
|
|
604
|
+
readonly parameterTypes: ReadonlyArray<number>;
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* The fields of an `ErrorResponse` or `NoticeResponse`. Unrecognised field
|
|
608
|
+
* codes are kept under their raw single-character key.
|
|
609
|
+
*
|
|
610
|
+
* @category models
|
|
611
|
+
* @since 4.0.0
|
|
612
|
+
*/
|
|
613
|
+
export interface ErrorFields {
|
|
614
|
+
readonly [key: string]: string | undefined;
|
|
615
|
+
readonly severity?: string | undefined;
|
|
616
|
+
readonly severityUnlocalized?: string | undefined;
|
|
617
|
+
readonly code?: string | undefined;
|
|
618
|
+
readonly message?: string | undefined;
|
|
619
|
+
readonly detail?: string | undefined;
|
|
620
|
+
readonly hint?: string | undefined;
|
|
621
|
+
readonly position?: string | undefined;
|
|
622
|
+
readonly internalPosition?: string | undefined;
|
|
623
|
+
readonly internalQuery?: string | undefined;
|
|
624
|
+
readonly where?: string | undefined;
|
|
625
|
+
readonly schema?: string | undefined;
|
|
626
|
+
readonly table?: string | undefined;
|
|
627
|
+
readonly column?: string | undefined;
|
|
628
|
+
readonly dataType?: string | undefined;
|
|
629
|
+
readonly constraint?: string | undefined;
|
|
630
|
+
readonly file?: string | undefined;
|
|
631
|
+
readonly line?: string | undefined;
|
|
632
|
+
readonly routine?: string | undefined;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* An error. `code` is the SQLSTATE.
|
|
636
|
+
*
|
|
637
|
+
* @category models
|
|
638
|
+
* @since 4.0.0
|
|
639
|
+
*/
|
|
640
|
+
export interface ErrorResponse {
|
|
641
|
+
readonly _tag: "ErrorResponse";
|
|
642
|
+
readonly fields: ErrorFields;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* A warning or notice. Same field set as `ErrorResponse`.
|
|
646
|
+
*
|
|
647
|
+
* @category models
|
|
648
|
+
* @since 4.0.0
|
|
649
|
+
*/
|
|
650
|
+
export interface NoticeResponse {
|
|
651
|
+
readonly _tag: "NoticeResponse";
|
|
652
|
+
readonly fields: ErrorFields;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* A `LISTEN`/`NOTIFY` message.
|
|
656
|
+
*
|
|
657
|
+
* @category models
|
|
658
|
+
* @since 4.0.0
|
|
659
|
+
*/
|
|
660
|
+
export interface NotificationResponse {
|
|
661
|
+
readonly _tag: "NotificationResponse";
|
|
662
|
+
readonly pid: number;
|
|
663
|
+
readonly channel: string;
|
|
664
|
+
readonly payload: string;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* The server speaks an older minor protocol version, or did not recognise
|
|
668
|
+
* some startup options.
|
|
669
|
+
*
|
|
670
|
+
* @category models
|
|
671
|
+
* @since 4.0.0
|
|
672
|
+
*/
|
|
673
|
+
export interface NegotiateProtocolVersion {
|
|
674
|
+
readonly _tag: "NegotiateProtocolVersion";
|
|
675
|
+
readonly minorVersion: number;
|
|
676
|
+
readonly unrecognizedOptions: ReadonlyArray<string>;
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* The server is ready to receive `COPY` data.
|
|
680
|
+
*
|
|
681
|
+
* @category models
|
|
682
|
+
* @since 4.0.0
|
|
683
|
+
*/
|
|
684
|
+
export interface CopyInResponse {
|
|
685
|
+
readonly _tag: "CopyInResponse";
|
|
686
|
+
readonly format: number;
|
|
687
|
+
readonly columnFormats: ReadonlyArray<number>;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* The server is about to send `COPY` data.
|
|
691
|
+
*
|
|
692
|
+
* @category models
|
|
693
|
+
* @since 4.0.0
|
|
694
|
+
*/
|
|
695
|
+
export interface CopyOutResponse {
|
|
696
|
+
readonly _tag: "CopyOutResponse";
|
|
697
|
+
readonly format: number;
|
|
698
|
+
readonly columnFormats: ReadonlyArray<number>;
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* The connection entered bidirectional `COPY` mode, as used by replication.
|
|
702
|
+
*
|
|
703
|
+
* @category models
|
|
704
|
+
* @since 4.0.0
|
|
705
|
+
*/
|
|
706
|
+
export interface CopyBothResponse {
|
|
707
|
+
readonly _tag: "CopyBothResponse";
|
|
708
|
+
readonly format: number;
|
|
709
|
+
readonly columnFormats: ReadonlyArray<number>;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* A chunk of `COPY` data.
|
|
713
|
+
*
|
|
714
|
+
* @category models
|
|
715
|
+
* @since 4.0.0
|
|
716
|
+
*/
|
|
717
|
+
export interface CopyData {
|
|
718
|
+
readonly _tag: "CopyData";
|
|
719
|
+
readonly data: Uint8Array;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* The `COPY` stream ended.
|
|
723
|
+
*
|
|
724
|
+
* @category models
|
|
725
|
+
* @since 4.0.0
|
|
726
|
+
*/
|
|
727
|
+
export interface CopyDone {
|
|
728
|
+
readonly _tag: "CopyDone";
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* A message whose type byte this codec does not know. The payload excludes
|
|
732
|
+
* the type byte and the length prefix.
|
|
733
|
+
*
|
|
734
|
+
* @category models
|
|
735
|
+
* @since 4.0.0
|
|
736
|
+
*/
|
|
737
|
+
export interface Unknown {
|
|
738
|
+
readonly _tag: "Unknown";
|
|
739
|
+
readonly type: number;
|
|
740
|
+
readonly payload: Uint8Array;
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Any message the server sends after startup.
|
|
744
|
+
*
|
|
745
|
+
* @category models
|
|
746
|
+
* @since 4.0.0
|
|
747
|
+
*/
|
|
748
|
+
export type BackendMessage<A = Uint8Array | null> = AuthenticationOk | AuthenticationCleartextPassword | AuthenticationMD5Password | AuthenticationSASL | AuthenticationSASLContinue | AuthenticationSASLFinal | AuthenticationUnsupported | ParameterStatus | BackendKeyData | ReadyForQuery | RowDescription | DataRow<A> | CommandComplete | EmptyQueryResponse | NoData | ParseComplete | BindComplete | CloseComplete | PortalSuspended | ParameterDescription | ErrorResponse | NoticeResponse | NotificationResponse | NegotiateProtocolVersion | CopyInResponse | CopyOutResponse | CopyBothResponse | CopyData | CopyDone | Unknown;
|
|
749
|
+
export {};
|
|
750
|
+
//# sourceMappingURL=PgProtocol.d.ts.map
|