@m2k-5f/pgtx 2.7.3 → 2.8.1

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.
@@ -0,0 +1,354 @@
1
+ import { DataTypeOids } from "./constants";
2
+ const isPoint = (value) => value !== null &&
3
+ typeof value === 'object' &&
4
+ 'x' in value && typeof value.x === 'number' &&
5
+ 'y' in value && typeof value.y === 'number';
6
+ export const handlers = {
7
+ [DataTypeOids.Bool]: {
8
+ pgType: 'bool',
9
+ jsShape: 'boolean',
10
+ validate: (v) => typeof v === 'boolean',
11
+ write: (req, v) => req.writeBinaryBool(v),
12
+ read: (res) => res.readBool(),
13
+ },
14
+ [DataTypeOids.Text]: {
15
+ pgType: 'text',
16
+ jsShape: 'string',
17
+ validate: (v) => typeof v === 'string',
18
+ write: (req, v) => req.writeBinaryString(v),
19
+ read: (res, len) => res.readRawString(len),
20
+ },
21
+ [DataTypeOids.Varchar]: {
22
+ pgType: 'varchar',
23
+ jsShape: 'string',
24
+ validate: (v) => typeof v === 'string',
25
+ write: (req, v) => req.writeBinaryString(v),
26
+ read: (res, len) => res.readRawString(len),
27
+ },
28
+ [DataTypeOids.Char]: {
29
+ pgType: 'char',
30
+ jsShape: 'string',
31
+ validate: (v) => typeof v === 'string',
32
+ write: (req, v) => req.writeBinaryString(v),
33
+ read: (res, len) => res.readRawString(len),
34
+ },
35
+ [DataTypeOids.Bpchar]: {
36
+ pgType: 'bpchar',
37
+ jsShape: 'string',
38
+ validate: (v) => typeof v === 'string',
39
+ write: (req, v) => req.writeBinaryString(v),
40
+ read: (res, len) => res.readRawString(len),
41
+ },
42
+ [DataTypeOids.Name]: {
43
+ pgType: 'name',
44
+ jsShape: 'string',
45
+ validate: (v) => typeof v === 'string' && Buffer.byteLength(v, 'utf-8') <= 63,
46
+ write: (req, v) => req.writeBinaryString(v),
47
+ read: (res, len) => res.readRawString(len),
48
+ },
49
+ [DataTypeOids.Int2]: {
50
+ pgType: 'int2',
51
+ jsShape: 'number (-32768..32767)',
52
+ validate: (v) => typeof v === 'number' &&
53
+ Number.isInteger(v) &&
54
+ v >= -32768 &&
55
+ v <= 32767,
56
+ write: (req, v) => req.writeBinaryInt2(v),
57
+ read: (res) => res.readInt16(),
58
+ },
59
+ [DataTypeOids.Int4]: {
60
+ pgType: 'int4',
61
+ jsShape: 'number (-2147483648..2147483647)',
62
+ validate: (v) => typeof v === 'number' &&
63
+ Number.isInteger(v) &&
64
+ v >= -2147483648 &&
65
+ v <= 2147483647,
66
+ write: (req, v) => req.writeBinaryInt4(v),
67
+ read: (res) => res.readInt32(),
68
+ },
69
+ [DataTypeOids.Int8]: {
70
+ pgType: 'int8',
71
+ jsShape: 'bigint | number (safe integer)',
72
+ validate: (v) => typeof v === 'bigint' ||
73
+ (typeof v === 'number' && Number.isSafeInteger(v)),
74
+ write: (req, v) => typeof v === 'bigint'
75
+ ? req.writeBinaryBigInt8(v)
76
+ : req.writeBinaryInt8(v),
77
+ read: (res, _len, int8toBigint) => int8toBigint ? res.readBigInt64() : res.readInt64(),
78
+ },
79
+ [DataTypeOids.Float4]: {
80
+ pgType: 'float4',
81
+ jsShape: 'number',
82
+ validate: (v) => typeof v === 'number' && Number.isFinite(v),
83
+ write: (req, v) => req.writeBinaryFloat4(v),
84
+ read: (res) => res.readFloat32(),
85
+ },
86
+ [DataTypeOids.Float8]: {
87
+ pgType: 'float8',
88
+ jsShape: 'number',
89
+ validate: (v) => typeof v === 'number' && Number.isFinite(v),
90
+ write: (req, v) => req.writeBinaryFloat8(v),
91
+ read: (res) => res.readFloat64(),
92
+ },
93
+ [DataTypeOids.Bytea]: {
94
+ pgType: 'bytea',
95
+ jsShape: 'Buffer | Uint8Array',
96
+ validate: (v) => Buffer.isBuffer(v) || v instanceof Uint8Array,
97
+ write: (req, v) => req.writeBinaryBytea(v),
98
+ read: (res, len) => res.readBytes(len),
99
+ },
100
+ [DataTypeOids.Timestamp]: {
101
+ pgType: 'timestamp',
102
+ jsShape: 'Date',
103
+ validate: (v) => v instanceof Date,
104
+ write: (req, v) => req.writeBinaryTimestamp(v),
105
+ read: (res) => res.readBinaryTimestamp(),
106
+ },
107
+ [DataTypeOids.Timestamptz]: {
108
+ pgType: 'timestamptz',
109
+ jsShape: 'Date',
110
+ validate: (v) => v instanceof Date,
111
+ write: (req, v) => req.writeBinaryTimestamp(v),
112
+ read: (res) => res.readBinaryTimestamp(),
113
+ },
114
+ [DataTypeOids.Point]: {
115
+ pgType: 'point',
116
+ jsShape: '{ x: number, y: number }',
117
+ validate: isPoint,
118
+ write: (req, v) => req.writeBinaryPoint(v),
119
+ read: (res) => res.readBinaryPoint(),
120
+ },
121
+ [DataTypeOids.Numeric]: {
122
+ pgType: 'numeric',
123
+ jsShape: 'string ("[-]digits[.digits]")',
124
+ validate: (v) => (typeof v === 'string' && /^-?\d*\.?\d+$/.test(v)),
125
+ write: (req, v) => req.writeBinaryNumeric(v),
126
+ read: (res) => res.readBinaryNumeric(),
127
+ },
128
+ [DataTypeOids.Date]: {
129
+ pgType: 'date',
130
+ jsShape: 'Date',
131
+ validate: (v) => v instanceof Date,
132
+ write: (req, v) => req.writeBinaryDate(v),
133
+ read: (res) => res.readBinaryDate(),
134
+ },
135
+ [DataTypeOids.Time]: {
136
+ pgType: 'time',
137
+ jsShape: 'string ("HH:MM:SS.mmm")',
138
+ validate: (v) => typeof v === 'string' &&
139
+ /^(\d{2}):(\d{2}):(\d{2})\.(\d{3})$/.test(v),
140
+ write: (req, v) => req.writeBinaryTime(v),
141
+ read: (res) => res.readBinaryTime(),
142
+ },
143
+ [DataTypeOids.Timetz]: {
144
+ pgType: 'timetz',
145
+ jsShape: 'string ("HH:MM:SS.mmm±HH:MM")',
146
+ validate: (v) => typeof v === 'string' &&
147
+ /^(\d{2}):(\d{2}):(\d{2})\.(\d{3})([+-])(\d{2}):(\d{2})$/.test(v),
148
+ write: (req, v) => req.writeBinaryTimetz(v),
149
+ read: (res) => res.readBinaryTimetz(),
150
+ },
151
+ [DataTypeOids.Interval]: {
152
+ pgType: 'interval',
153
+ jsShape: '{ months: number, days: number, microseconds: number | bigint }',
154
+ validate: (v) => v !== null &&
155
+ typeof v === 'object' &&
156
+ 'months' in v && typeof v.months === 'number' &&
157
+ 'days' in v && typeof v.days === 'number' &&
158
+ 'microseconds' in v &&
159
+ (typeof v.microseconds === 'number' || typeof v.microseconds === 'bigint'),
160
+ write: (req, v) => req.writeBinaryInterval(v),
161
+ read: (res) => res.readBinaryInterval(),
162
+ },
163
+ [DataTypeOids.Json]: {
164
+ pgType: 'json',
165
+ jsShape: 'unknown (JSON-serializable)',
166
+ validate: (_v) => true,
167
+ write: (req, v) => req.writeBinaryJson(v),
168
+ read: (res, len) => res.readBinaryJson(len),
169
+ },
170
+ [DataTypeOids.Jsonb]: {
171
+ pgType: 'jsonb',
172
+ jsShape: 'unknown (JSON-serializable)',
173
+ validate: (_v) => true,
174
+ write: (req, v) => req.writeBinaryJsonb(v),
175
+ read: (res, len) => res.readBinaryJsonb(len),
176
+ },
177
+ [DataTypeOids.Uuid]: {
178
+ pgType: 'uuid',
179
+ jsShape: 'string ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")',
180
+ validate: (v) => typeof v === 'string' &&
181
+ /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v),
182
+ write: (req, v) => req.writeBinaryUuid(v),
183
+ read: (res) => res.readBinaryUuid(),
184
+ },
185
+ [DataTypeOids.Cidr]: {
186
+ pgType: 'cidr',
187
+ jsShape: 'string (IPv4/IPv6 address or CIDR)',
188
+ validate: (v) => typeof v === 'string',
189
+ write: (req, v) => req.writeBinaryCidr(v),
190
+ read: (res, len) => res.readBinaryInet(len),
191
+ },
192
+ [DataTypeOids.Inet]: {
193
+ pgType: 'inet',
194
+ jsShape: 'string (IPv4/IPv6 address or CIDR)',
195
+ validate: (v) => typeof v === 'string',
196
+ write: (req, v) => req.writeBinaryInet(v),
197
+ read: (res, len) => res.readBinaryInet(len),
198
+ },
199
+ [DataTypeOids.Macaddr]: {
200
+ pgType: 'macaddr',
201
+ jsShape: 'string ("xx:xx:xx:xx:xx:xx")',
202
+ validate: (v) => typeof v === 'string' &&
203
+ /^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i.test(v),
204
+ write: (req, v) => req.writeBinaryMacaddr(v),
205
+ read: (res) => res.readBinaryMacaddr(),
206
+ },
207
+ [DataTypeOids.Oid]: {
208
+ pgType: 'oid',
209
+ jsShape: 'number',
210
+ validate: (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0,
211
+ write: (req, v) => req.writeBinaryOid(v),
212
+ read: (res) => res.readBinaryOid(),
213
+ },
214
+ [DataTypeOids.Xid]: {
215
+ pgType: 'xid',
216
+ jsShape: 'number',
217
+ validate: (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0,
218
+ write: (req, v) => req.writeBinaryXid(v),
219
+ read: (res) => res.readBinaryXid(),
220
+ },
221
+ [DataTypeOids.Cid]: {
222
+ pgType: 'cid',
223
+ jsShape: 'number',
224
+ validate: (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0,
225
+ write: (req, v) => req.writeBinaryCid(v),
226
+ read: (res) => res.readBinaryCid(),
227
+ },
228
+ [DataTypeOids.Regproc]: {
229
+ pgType: 'regproc',
230
+ jsShape: 'number',
231
+ validate: (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0,
232
+ write: (req, v) => req.writeBinaryRegproc(v),
233
+ read: (res) => res.readBinaryRegproc(),
234
+ },
235
+ [DataTypeOids.Lseg]: {
236
+ pgType: 'lseg',
237
+ jsShape: '{ a: Point, b: Point }',
238
+ validate: (v) => v !== null && typeof v === 'object' &&
239
+ isPoint(v.a) && isPoint(v.b),
240
+ write: (req, v) => req.writeBinaryLseg(v),
241
+ read: (res) => res.readBinaryLseg(),
242
+ },
243
+ [DataTypeOids.Path]: {
244
+ pgType: 'path',
245
+ jsShape: '{ closed: boolean, points: Point[] }',
246
+ validate: (v) => v !== null && typeof v === 'object' &&
247
+ typeof v.closed === 'boolean' &&
248
+ Array.isArray(v.points) &&
249
+ v.points.every(isPoint),
250
+ write: (req, v) => req.writeBinaryPath(v),
251
+ read: (res) => res.readBinaryPath(),
252
+ },
253
+ [DataTypeOids.Box]: {
254
+ pgType: 'box',
255
+ jsShape: '{ high: Point, low: Point }',
256
+ validate: (v) => v !== null && typeof v === 'object' &&
257
+ isPoint(v.high) && isPoint(v.low),
258
+ write: (req, v) => req.writeBinaryBox(v),
259
+ read: (res) => res.readBinaryBox(),
260
+ },
261
+ [DataTypeOids.Polygon]: {
262
+ pgType: 'polygon',
263
+ jsShape: '{ points: Point[] }',
264
+ validate: (v) => v !== null && typeof v === 'object' &&
265
+ Array.isArray(v.points) &&
266
+ v.points.every(isPoint),
267
+ write: (req, v) => req.writeBinaryPolygon(v),
268
+ read: (res) => res.readBinaryPolygon(),
269
+ },
270
+ [DataTypeOids.Line]: {
271
+ pgType: 'line',
272
+ jsShape: '{ a: number, b: number, c: number }',
273
+ validate: (v) => v !== null && typeof v === 'object' &&
274
+ typeof v.a === 'number' &&
275
+ typeof v.b === 'number' &&
276
+ typeof v.c === 'number',
277
+ write: (req, v) => req.writeBinaryLine(v),
278
+ read: (res) => res.readBinaryLine(),
279
+ },
280
+ [DataTypeOids.BoolArray]: {
281
+ pgType: 'bool[]',
282
+ jsShape: '(boolean | null)[]',
283
+ validate: (v) => Array.isArray(v) && v.every(el => el == null || typeof el === 'boolean'),
284
+ write: (req, v) => req.writeBinaryBoolArray(v),
285
+ read: (res, len) => res.readBinaryArray(len, () => res.readBool()),
286
+ },
287
+ [DataTypeOids.Int2Array]: {
288
+ pgType: 'int2[]',
289
+ jsShape: '(number | null)[]',
290
+ validate: (v) => Array.isArray(v) && v.every(el => el == null || (typeof el === 'number' && Number.isInteger(el) && el >= -32768 && el <= 32767)),
291
+ write: (req, v) => req.writeBinaryInt2Array(v),
292
+ read: (res, len) => res.readBinaryArray(len, () => res.readInt16()),
293
+ },
294
+ [DataTypeOids.Int4Array]: {
295
+ pgType: 'int4[]',
296
+ jsShape: '(number | null)[]',
297
+ validate: (v) => Array.isArray(v) && v.every(el => el == null || (typeof el === 'number' && Number.isInteger(el) && el >= -2147483648 && el <= 2147483647)),
298
+ write: (req, v) => req.writeBinaryInt4Array(v),
299
+ read: (res, len) => res.readBinaryArray(len, () => res.readInt32()),
300
+ },
301
+ [DataTypeOids.Int8Array]: {
302
+ pgType: 'int8[]',
303
+ jsShape: '(number | bigint | null)[]',
304
+ validate: (v) => Array.isArray(v) && v.every(el => el == null ||
305
+ typeof el === 'bigint' ||
306
+ (typeof el === 'number' && Number.isSafeInteger(el))),
307
+ write: (req, v) => req.writeBinaryInt8Array(v),
308
+ read: (res, len, int8toBigint) => res.readBinaryArray(len, () => int8toBigint ? res.readBigInt64() : res.readInt64()),
309
+ },
310
+ [DataTypeOids.TextArray]: {
311
+ pgType: 'text[]',
312
+ jsShape: '(string | null)[]',
313
+ validate: (v) => Array.isArray(v) && v.every(el => el == null || typeof el === 'string'),
314
+ write: (req, v) => req.writeBinaryTextArray(v),
315
+ read: (res, len) => res.readBinaryArray(len, (l) => res.readRawString(l)),
316
+ },
317
+ [DataTypeOids.VarcharArray]: {
318
+ pgType: 'varchar[]',
319
+ jsShape: '(string | null)[]',
320
+ validate: (v) => Array.isArray(v) && v.every(el => el == null || typeof el === 'string'),
321
+ write: (req, v) => req.writeBinaryVarcharArray(v),
322
+ read: (res, len) => res.readBinaryArray(len, (l) => res.readRawString(l)),
323
+ },
324
+ [DataTypeOids.JsonArray]: {
325
+ pgType: 'json[]',
326
+ jsShape: 'unknown[]',
327
+ validate: (v) => Array.isArray(v),
328
+ write: (req, v) => req.writeBinaryJsonArray(v),
329
+ read: (res, len) => res.readBinaryArray(len, (l) => res.readBinaryJson(l)),
330
+ },
331
+ [DataTypeOids.JsonbArray]: {
332
+ pgType: 'jsonb[]',
333
+ jsShape: 'unknown[]',
334
+ validate: (v) => Array.isArray(v),
335
+ write: (req, v) => req.writeBinaryJsonbArray(v),
336
+ read: (res, len) => res.readBinaryArray(len, (l) => res.readBinaryJsonb(l)),
337
+ },
338
+ [DataTypeOids.UuidArray]: {
339
+ pgType: 'uuid[]',
340
+ jsShape: '(string | null)[]',
341
+ validate: (v) => Array.isArray(v) && v.every(el => el == null || (typeof el === 'string' && /^[0-9a-f-]{36}$/i.test(el))),
342
+ write: (req, v) => req.writeBinaryUuidArray(v),
343
+ read: (res, len) => res.readBinaryArray(len, () => res.readBinaryUuid()),
344
+ },
345
+ [DataTypeOids.NumericArray]: {
346
+ pgType: 'numeric[]',
347
+ jsShape: '(string | null)[]',
348
+ validate: (v) => Array.isArray(v) && v.every(el => el == null ||
349
+ (typeof el === 'number' && Number.isFinite(el)) ||
350
+ (typeof el === 'string' && /^-?\d*\.?\d+$/.test(el))),
351
+ write: (req, v) => req.writeBinaryNumericArray(v),
352
+ read: (res, len) => res.readBinaryArray(len, () => res.readBinaryNumeric()),
353
+ },
354
+ };
package/dist/query.d.ts CHANGED
@@ -1,37 +1,51 @@
1
1
  import { Future, Resolvers } from "fluent-future";
2
- import { ColumnDescription, QueryText, Row, StatementName } from "./types";
2
+ import { ColumnDescription, QueryText, Row, StatementMeta } from "./types";
3
3
  import { PostgresError } from "./error";
4
4
  export declare abstract class Query {
5
- statement: StatementName;
6
- text: QueryText;
7
- args: unknown[];
8
5
  protected _timer?: NodeJS.Timeout;
9
- constructor(statement: StatementName, text: QueryText, args: unknown[], timeout: number);
6
+ constructor(timeout: number);
10
7
  abstract error(cause: PostgresError): void;
11
8
  abstract complete(...args: any[]): void;
12
9
  }
13
10
  export declare class CollectQuery<T extends Row> extends Query {
11
+ meta: StatementMeta;
12
+ text: QueryText;
13
+ args: unknown[];
14
14
  columns: ColumnDescription[] | null;
15
15
  resolvers: Resolvers<Future<T[], PostgresError>>;
16
16
  private _rows;
17
- constructor(statement: StatementName, text: QueryText, args: unknown[], columns: ColumnDescription[] | null, timeout: number, resolvers: Resolvers<Future<T[], PostgresError>>);
17
+ constructor(meta: StatementMeta, text: QueryText, args: unknown[], columns: ColumnDescription[] | null, resolvers: Resolvers<Future<T[], PostgresError>>, timeout: number);
18
18
  push(value: T): void;
19
19
  error(cause: PostgresError): void;
20
20
  complete(): void;
21
21
  }
22
22
  export declare class ExecuteQuery extends Query {
23
+ meta: StatementMeta;
24
+ text: QueryText;
25
+ args: unknown[];
23
26
  resolvers: Resolvers<Future<void, PostgresError>>;
24
- constructor(statement: StatementName, text: QueryText, args: unknown[], timeout: number, resolvers: Resolvers<Future<void, PostgresError>>);
27
+ constructor(meta: StatementMeta, text: QueryText, args: unknown[], resolvers: Resolvers<Future<void, PostgresError>>, timeout: number);
25
28
  error(cause: PostgresError): void;
26
29
  complete(): void;
27
30
  }
28
31
  export declare class StreamQuery<T> extends Query {
32
+ meta: StatementMeta;
33
+ text: QueryText;
34
+ args: unknown[];
29
35
  controller: ReadableStreamDefaultController<T>;
30
36
  columns: ColumnDescription[] | null;
31
- constructor(statement: StatementName, text: QueryText, args: unknown[], controller: ReadableStreamDefaultController<T>, columns: ColumnDescription[] | null, timeout: number);
37
+ constructor(meta: StatementMeta, text: QueryText, args: unknown[], controller: ReadableStreamDefaultController<T>, columns: ColumnDescription[] | null, timeout: number);
32
38
  push(value: T): void;
33
39
  error(cause: PostgresError): void;
34
40
  complete(): void;
35
41
  }
36
- export type PostgresQuery = CollectQuery<any> | StreamQuery<any> | ExecuteQuery;
42
+ export declare class ParseQuery extends Query {
43
+ meta: StatementMeta;
44
+ text: QueryText;
45
+ resolvers: Resolvers<Future<StatementMeta, PostgresError>>;
46
+ constructor(meta: StatementMeta, text: QueryText, resolvers: Resolvers<Future<StatementMeta, PostgresError>>, timeout: number);
47
+ error(cause: PostgresError): void;
48
+ complete(): void;
49
+ }
50
+ export type PostgresQuery = ParseQuery | CollectQuery<any> | StreamQuery<any> | ExecuteQuery;
37
51
  //# sourceMappingURL=query.d.ts.map
@@ -1 +1 @@
1
-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nB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,OAAO,EAAE;IACf,UAAU,EAAE,+BAA+B,CAAC,CAAC,CAAC;IAC9C,OAAO,EAAE,iBAAiB,EAAE,GAAG,IAAI;gBAJnC,IAAI,EAAE,aAAa,EACnB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,OAAO,EAAE,EACf,UAAU,EAAE,+BAA+B,CAAC,CAAC,CAAC,EAC9C,OAAO,EAAE,iBAAiB,EAAE,GAAG,IAAI,EAC1C,OAAO,EAAE,MAAM;IAMnB,IAAI,CAAC,KAAK,EAAE,CAAC;IAOb,KAAK,CAAC,KAAK,EAAE,aAAa;IAM1B,QAAQ;CAMX;AAED,qBAAa,UAAW,SAAQ,KAAK;IAEtB,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,SAAS;IACf,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;gBAF1D,IAAI,EAAE,aAAa,EACnB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,EACjE,OAAO,EAAE,MAAM;IAKnB,KAAK,CAAC,KAAK,EAAE,aAAa;IAM1B,QAAQ;CAIX;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,YAAY,CAAA"}
package/dist/query.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import { ErrQueryTimeout } from "./error";
2
2
  export class Query {
3
- constructor(statement, text, args, timeout) {
4
- this.statement = statement;
5
- this.text = text;
6
- this.args = args;
3
+ constructor(timeout) {
7
4
  this._timer = setTimeout(() => {
8
5
  this.error(ErrQueryTimeout);
9
6
  }, timeout);
10
7
  }
11
8
  }
12
9
  export class CollectQuery extends Query {
13
- constructor(statement, text, args, columns, timeout, resolvers) {
14
- super(statement, text, args, timeout);
10
+ constructor(meta, text, args, columns, resolvers, timeout) {
11
+ super(timeout);
12
+ this.meta = meta;
13
+ this.text = text;
14
+ this.args = args;
15
15
  this.columns = columns;
16
16
  this.resolvers = resolvers;
17
17
  this._rows = [];
@@ -29,8 +29,11 @@ export class CollectQuery extends Query {
29
29
  }
30
30
  }
31
31
  export class ExecuteQuery extends Query {
32
- constructor(statement, text, args, timeout, resolvers) {
33
- super(statement, text, args, timeout);
32
+ constructor(meta, text, args, resolvers, timeout) {
33
+ super(timeout);
34
+ this.meta = meta;
35
+ this.text = text;
36
+ this.args = args;
34
37
  this.resolvers = resolvers;
35
38
  }
36
39
  error(cause) {
@@ -43,8 +46,11 @@ export class ExecuteQuery extends Query {
43
46
  }
44
47
  }
45
48
  export class StreamQuery extends Query {
46
- constructor(statement, text, args, controller, columns, timeout) {
47
- super(statement, text, args, timeout);
49
+ constructor(meta, text, args, controller, columns, timeout) {
50
+ super(timeout);
51
+ this.meta = meta;
52
+ this.text = text;
53
+ this.args = args;
48
54
  this.controller = controller;
49
55
  this.columns = columns;
50
56
  }
@@ -66,3 +72,19 @@ export class StreamQuery extends Query {
66
72
  catch { }
67
73
  }
68
74
  }
75
+ export class ParseQuery extends Query {
76
+ constructor(meta, text, resolvers, timeout) {
77
+ super(timeout);
78
+ this.meta = meta;
79
+ this.text = text;
80
+ this.resolvers = resolvers;
81
+ }
82
+ error(cause) {
83
+ clearTimeout(this._timer);
84
+ this.resolvers.reject(cause);
85
+ }
86
+ complete() {
87
+ clearTimeout(this._timer);
88
+ this.resolvers.resolve(this.meta);
89
+ }
90
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m2k-5f/pgtx",
3
- "version": "2.7.3",
3
+ "version": "2.8.1",
4
4
  "type": "module",
5
5
  "description": "Blazing-fast PostgreSQL driver with pipeline support.",
6
6
  "files": [