@m2k-5f/pgtx 2.7.3 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,264 @@
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
+ validate: (v) => typeof v === 'boolean',
9
+ write: (req, v) => req.writeBinaryBool(v),
10
+ read: (res) => res.readBool(),
11
+ },
12
+ [DataTypeOids.Text]: {
13
+ validate: (v) => typeof v === 'string',
14
+ write: (req, v) => req.writeBinaryString(v),
15
+ read: (res, len) => res.readRawString(len),
16
+ },
17
+ [DataTypeOids.Varchar]: {
18
+ validate: (v) => typeof v === 'string',
19
+ write: (req, v) => req.writeBinaryString(v),
20
+ read: (res, len) => res.readRawString(len),
21
+ },
22
+ [DataTypeOids.Char]: {
23
+ validate: (v) => typeof v === 'string',
24
+ write: (req, v) => req.writeBinaryString(v),
25
+ read: (res, len) => res.readRawString(len),
26
+ },
27
+ [DataTypeOids.Bpchar]: {
28
+ validate: (v) => typeof v === 'string',
29
+ write: (req, v) => req.writeBinaryString(v),
30
+ read: (res, len) => res.readRawString(len),
31
+ },
32
+ [DataTypeOids.Name]: {
33
+ validate: (v) => typeof v === 'string' && Buffer.byteLength(v, 'utf-8') <= 63,
34
+ write: (req, v) => req.writeBinaryString(v),
35
+ read: (res, len) => res.readRawString(len),
36
+ },
37
+ [DataTypeOids.Int2]: {
38
+ validate: (v) => typeof v === 'number' &&
39
+ Number.isInteger(v) &&
40
+ v >= -32768 &&
41
+ v <= 32767,
42
+ write: (req, v) => req.writeBinaryInt2(v),
43
+ read: (res) => res.readInt16(),
44
+ },
45
+ [DataTypeOids.Int4]: {
46
+ validate: (v) => typeof v === 'number' &&
47
+ Number.isInteger(v) &&
48
+ v >= -2147483648 &&
49
+ v <= 2147483647,
50
+ write: (req, v) => req.writeBinaryInt4(v),
51
+ read: (res) => res.readInt32(),
52
+ },
53
+ [DataTypeOids.Int8]: {
54
+ validate: (v) => typeof v === 'bigint' ||
55
+ (typeof v === 'number' && Number.isSafeInteger(v)),
56
+ write: (req, v) => typeof v === 'bigint'
57
+ ? req.writeBinaryBigInt8(v)
58
+ : req.writeBinaryInt8(v),
59
+ read: (res, _len, int8toBigint) => int8toBigint ? res.readBigInt64() : res.readInt64(),
60
+ },
61
+ [DataTypeOids.Float4]: {
62
+ validate: (v) => typeof v === 'number' && Number.isFinite(v),
63
+ write: (req, v) => req.writeBinaryFloat4(v),
64
+ read: (res) => res.readFloat32(),
65
+ },
66
+ [DataTypeOids.Float8]: {
67
+ validate: (v) => typeof v === 'number' && Number.isFinite(v),
68
+ write: (req, v) => req.writeBinaryFloat8(v),
69
+ read: (res) => res.readFloat64(),
70
+ },
71
+ [DataTypeOids.Bytea]: {
72
+ validate: (v) => Buffer.isBuffer(v) || v instanceof Uint8Array,
73
+ write: (req, v) => req.writeBinaryBytea(v),
74
+ read: (res, len) => res.readBytes(len),
75
+ },
76
+ [DataTypeOids.Timestamp]: {
77
+ validate: (v) => v instanceof Date,
78
+ write: (req, v) => req.writeBinaryTimestamp(v),
79
+ read: (res) => res.readBinaryTimestamp(),
80
+ },
81
+ [DataTypeOids.Timestamptz]: {
82
+ validate: (v) => v instanceof Date,
83
+ write: (req, v) => req.writeBinaryTimestamp(v),
84
+ read: (res) => res.readBinaryTimestamp(),
85
+ },
86
+ [DataTypeOids.Point]: {
87
+ validate: isPoint,
88
+ write: (req, v) => req.writeBinaryPoint(v),
89
+ read: (res) => res.readBinaryPoint(),
90
+ },
91
+ [DataTypeOids.Numeric]: {
92
+ validate: (v) => (typeof v === 'string' && /^-?\d*\.?\d+$/.test(v)),
93
+ write: (req, v) => req.writeBinaryNumeric(v),
94
+ read: (res) => res.readBinaryNumeric(),
95
+ },
96
+ [DataTypeOids.Date]: {
97
+ validate: (v) => v instanceof Date,
98
+ write: (req, v) => req.writeBinaryDate(v),
99
+ read: (res) => res.readBinaryDate(),
100
+ },
101
+ [DataTypeOids.Time]: {
102
+ validate: (v) => typeof v === 'string' &&
103
+ /^(\d{2}):(\d{2}):(\d{2})\.(\d{3})$/.test(v),
104
+ write: (req, v) => req.writeBinaryTime(v),
105
+ read: (res) => res.readBinaryTime(),
106
+ },
107
+ [DataTypeOids.Timetz]: {
108
+ validate: (v) => typeof v === 'string' &&
109
+ /^(\d{2}):(\d{2}):(\d{2})\.(\d{3})([+-])(\d{2}):(\d{2})$/.test(v),
110
+ write: (req, v) => req.writeBinaryTimetz(v),
111
+ read: (res) => res.readBinaryTimetz(),
112
+ },
113
+ [DataTypeOids.Interval]: {
114
+ validate: (v) => v !== null &&
115
+ typeof v === 'object' &&
116
+ 'months' in v && typeof v.months === 'number' &&
117
+ 'days' in v && typeof v.days === 'number' &&
118
+ 'microseconds' in v &&
119
+ (typeof v.microseconds === 'number' || typeof v.microseconds === 'bigint'),
120
+ write: (req, v) => req.writeBinaryInterval(v),
121
+ read: (res) => res.readBinaryInterval(),
122
+ },
123
+ [DataTypeOids.Json]: {
124
+ validate: (_v) => true,
125
+ write: (req, v) => req.writeBinaryJson(v),
126
+ read: (res, len) => res.readBinaryJson(len),
127
+ },
128
+ [DataTypeOids.Jsonb]: {
129
+ validate: (_v) => true,
130
+ write: (req, v) => req.writeBinaryJsonb(v),
131
+ read: (res, len) => res.readBinaryJsonb(len),
132
+ },
133
+ [DataTypeOids.Uuid]: {
134
+ validate: (v) => typeof v === 'string' &&
135
+ /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v),
136
+ write: (req, v) => req.writeBinaryUuid(v),
137
+ read: (res) => res.readBinaryUuid(),
138
+ },
139
+ [DataTypeOids.Cidr]: {
140
+ validate: (v) => typeof v === 'string',
141
+ write: (req, v) => req.writeBinaryCidr(v),
142
+ read: (res, len) => res.readBinaryInet(len),
143
+ },
144
+ [DataTypeOids.Inet]: {
145
+ validate: (v) => typeof v === 'string',
146
+ write: (req, v) => req.writeBinaryInet(v),
147
+ read: (res, len) => res.readBinaryInet(len),
148
+ },
149
+ [DataTypeOids.Macaddr]: {
150
+ validate: (v) => typeof v === 'string' &&
151
+ /^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i.test(v),
152
+ write: (req, v) => req.writeBinaryMacaddr(v),
153
+ read: (res) => res.readBinaryMacaddr(),
154
+ },
155
+ [DataTypeOids.Oid]: {
156
+ validate: (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0,
157
+ write: (req, v) => req.writeBinaryOid(v),
158
+ read: (res) => res.readBinaryOid(),
159
+ },
160
+ [DataTypeOids.Xid]: {
161
+ validate: (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0,
162
+ write: (req, v) => req.writeBinaryXid(v),
163
+ read: (res) => res.readBinaryXid(),
164
+ },
165
+ [DataTypeOids.Cid]: {
166
+ validate: (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0,
167
+ write: (req, v) => req.writeBinaryCid(v),
168
+ read: (res) => res.readBinaryCid(),
169
+ },
170
+ [DataTypeOids.Regproc]: {
171
+ validate: (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0,
172
+ write: (req, v) => req.writeBinaryRegproc(v),
173
+ read: (res) => res.readBinaryRegproc(),
174
+ },
175
+ [DataTypeOids.Lseg]: {
176
+ validate: (v) => v !== null && typeof v === 'object' &&
177
+ isPoint(v.a) && isPoint(v.b),
178
+ write: (req, v) => req.writeBinaryLseg(v),
179
+ read: (res) => res.readBinaryLseg(),
180
+ },
181
+ [DataTypeOids.Path]: {
182
+ validate: (v) => v !== null && typeof v === 'object' &&
183
+ typeof v.closed === 'boolean' &&
184
+ Array.isArray(v.points) &&
185
+ v.points.every(isPoint),
186
+ write: (req, v) => req.writeBinaryPath(v),
187
+ read: (res) => res.readBinaryPath(),
188
+ },
189
+ [DataTypeOids.Box]: {
190
+ validate: (v) => v !== null && typeof v === 'object' &&
191
+ isPoint(v.high) && isPoint(v.low),
192
+ write: (req, v) => req.writeBinaryBox(v),
193
+ read: (res) => res.readBinaryBox(),
194
+ },
195
+ [DataTypeOids.Polygon]: {
196
+ validate: (v) => v !== null && typeof v === 'object' &&
197
+ Array.isArray(v.points) &&
198
+ v.points.every(isPoint),
199
+ write: (req, v) => req.writeBinaryPolygon(v),
200
+ read: (res) => res.readBinaryPolygon(),
201
+ },
202
+ [DataTypeOids.Line]: {
203
+ validate: (v) => v !== null && typeof v === 'object' &&
204
+ typeof v.a === 'number' &&
205
+ typeof v.b === 'number' &&
206
+ typeof v.c === 'number',
207
+ write: (req, v) => req.writeBinaryLine(v),
208
+ read: (res) => res.readBinaryLine(),
209
+ },
210
+ [DataTypeOids.BoolArray]: {
211
+ validate: (v) => Array.isArray(v) && v.every(el => el == null || typeof el === 'boolean'),
212
+ write: (req, v) => req.writeBinaryBoolArray(v),
213
+ read: (res, len) => res.readBinaryArray(len, () => res.readBool()),
214
+ },
215
+ [DataTypeOids.Int2Array]: {
216
+ validate: (v) => Array.isArray(v) && v.every(el => el == null || (typeof el === 'number' && Number.isInteger(el) && el >= -32768 && el <= 32767)),
217
+ write: (req, v) => req.writeBinaryInt2Array(v),
218
+ read: (res, len) => res.readBinaryArray(len, () => res.readInt16()),
219
+ },
220
+ [DataTypeOids.Int4Array]: {
221
+ validate: (v) => Array.isArray(v) && v.every(el => el == null || (typeof el === 'number' && Number.isInteger(el) && el >= -2147483648 && el <= 2147483647)),
222
+ write: (req, v) => req.writeBinaryInt4Array(v),
223
+ read: (res, len) => res.readBinaryArray(len, () => res.readInt32()),
224
+ },
225
+ [DataTypeOids.Int8Array]: {
226
+ validate: (v) => Array.isArray(v) && v.every(el => el == null ||
227
+ typeof el === 'bigint' ||
228
+ (typeof el === 'number' && Number.isSafeInteger(el))),
229
+ write: (req, v) => req.writeBinaryInt8Array(v),
230
+ read: (res, len, int8toBigint) => res.readBinaryArray(len, () => int8toBigint ? res.readBigInt64() : res.readInt64()),
231
+ },
232
+ [DataTypeOids.TextArray]: {
233
+ validate: (v) => Array.isArray(v) && v.every(el => el == null || typeof el === 'string'),
234
+ write: (req, v) => req.writeBinaryTextArray(v),
235
+ read: (res, len) => res.readBinaryArray(len, (l) => res.readRawString(l)),
236
+ },
237
+ [DataTypeOids.VarcharArray]: {
238
+ validate: (v) => Array.isArray(v) && v.every(el => el == null || typeof el === 'string'),
239
+ write: (req, v) => req.writeBinaryVarcharArray(v),
240
+ read: (res, len) => res.readBinaryArray(len, (l) => res.readRawString(l)),
241
+ },
242
+ [DataTypeOids.JsonArray]: {
243
+ validate: (v) => Array.isArray(v),
244
+ write: (req, v) => req.writeBinaryJsonArray(v),
245
+ read: (res, len) => res.readBinaryArray(len, (l) => res.readBinaryJson(l)),
246
+ },
247
+ [DataTypeOids.JsonbArray]: {
248
+ validate: (v) => Array.isArray(v),
249
+ write: (req, v) => req.writeBinaryJsonbArray(v),
250
+ read: (res, len) => res.readBinaryArray(len, (l) => res.readBinaryJsonb(l)),
251
+ },
252
+ [DataTypeOids.UuidArray]: {
253
+ validate: (v) => Array.isArray(v) && v.every(el => el == null || (typeof el === 'string' && /^[0-9a-f-]{36}$/i.test(el))),
254
+ write: (req, v) => req.writeBinaryUuidArray(v),
255
+ read: (res, len) => res.readBinaryArray(len, () => res.readBinaryUuid()),
256
+ },
257
+ [DataTypeOids.NumericArray]: {
258
+ validate: (v) => Array.isArray(v) && v.every(el => el == null ||
259
+ (typeof el === 'number' && Number.isFinite(el)) ||
260
+ (typeof el === 'string' && /^-?\d*\.?\d+$/.test(el))),
261
+ write: (req, v) => req.writeBinaryNumericArray(v),
262
+ read: (res, len) => res.readBinaryArray(len, () => res.readBinaryNumeric()),
263
+ },
264
+ };
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
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAmB,aAAa,EAAE,MAAM,SAAS,CAAC;AAGzD,8BAAsB,KAAK;IAIZ,SAAS,EAAE,aAAa;IACxB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,OAAO,EAAE;IAL1B,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,CAAA;gBAGtB,SAAS,EAAE,aAAa,EACxB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,OAAO,EAAE,EACtB,OAAO,EAAE,MAAM;IAQnB,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAE1C,QAAQ,CAAC,QAAQ,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAC1C;AAGD,qBAAa,YAAY,CAAC,CAAC,SAAS,GAAG,CAAE,SAAQ,KAAK;IAOvC,O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AAC,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.0",
4
4
  "type": "module",
5
5
  "description": "Blazing-fast PostgreSQL driver with pipeline support.",
6
6
  "files": [