postgrejs 2.22.9 → 2.23.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.
Files changed (216) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/{esm/connection → connection}/bind-param.js +2 -0
  3. package/{esm/connection → connection}/connection.js +4 -2
  4. package/{esm/connection → connection}/cursor.js +8 -3
  5. package/{esm/connection → connection}/intl-connection.js +6 -3
  6. package/{esm/connection → connection}/pool.js +4 -1
  7. package/{esm/connection → connection}/portal.js +3 -1
  8. package/{esm/connection → connection}/prepared-statement.js +6 -3
  9. package/{esm/constants.js → constants.js} +1 -1
  10. package/{esm/data-type-map.js → data-type-map.js} +2 -2
  11. package/package.json +12 -31
  12. package/{esm/protocol → protocol}/backend.js +1 -0
  13. package/{esm/protocol → protocol}/buffer-reader.js +2 -1
  14. package/{esm/protocol → protocol}/database-error.js +16 -0
  15. package/{esm/protocol → protocol}/frontend.js +1 -0
  16. package/{esm/protocol → protocol}/pg-socket.js +9 -3
  17. package/{esm/protocol → protocol}/smart-buffer.js +9 -5
  18. package/{esm/util → util}/bigint-methods.js +1 -0
  19. package/cjs/connection/bind-param.js +0 -10
  20. package/cjs/connection/connection.js +0 -295
  21. package/cjs/connection/cursor.js +0 -91
  22. package/cjs/connection/intl-connection.js +0 -258
  23. package/cjs/connection/pool.js +0 -236
  24. package/cjs/connection/portal.js +0 -157
  25. package/cjs/connection/prepared-statement.js +0 -226
  26. package/cjs/constants.js +0 -249
  27. package/cjs/data-type-map.js +0 -131
  28. package/cjs/data-types/bool-type.js +0 -33
  29. package/cjs/data-types/box-type.js +0 -52
  30. package/cjs/data-types/bytea-type.js +0 -28
  31. package/cjs/data-types/char-type.js +0 -27
  32. package/cjs/data-types/circle-type.js +0 -51
  33. package/cjs/data-types/date-type.js +0 -75
  34. package/cjs/data-types/float4-type.js +0 -25
  35. package/cjs/data-types/float8-type.js +0 -25
  36. package/cjs/data-types/int2-type.js +0 -26
  37. package/cjs/data-types/int2-vector-type.js +0 -42
  38. package/cjs/data-types/int4-type.js +0 -28
  39. package/cjs/data-types/int8-type.js +0 -36
  40. package/cjs/data-types/json-type.js +0 -40
  41. package/cjs/data-types/jsonb-type.js +0 -44
  42. package/cjs/data-types/lseg-type.js +0 -55
  43. package/cjs/data-types/numeric-type.js +0 -125
  44. package/cjs/data-types/oid-type.js +0 -32
  45. package/cjs/data-types/point-type.js +0 -42
  46. package/cjs/data-types/time-type.js +0 -66
  47. package/cjs/data-types/timestamp-type.js +0 -89
  48. package/cjs/data-types/timestamptz-type.js +0 -76
  49. package/cjs/data-types/uuid-type.js +0 -39
  50. package/cjs/data-types/varchar-type.js +0 -27
  51. package/cjs/index.js +0 -28
  52. package/cjs/interfaces/command-result.js +0 -2
  53. package/cjs/interfaces/data-mapping-options.js +0 -2
  54. package/cjs/interfaces/data-type.js +0 -2
  55. package/cjs/interfaces/database-connection-params.js +0 -2
  56. package/cjs/interfaces/field-info.js +0 -2
  57. package/cjs/interfaces/query-options.js +0 -2
  58. package/cjs/interfaces/query-result.js +0 -2
  59. package/cjs/interfaces/script-execute-options.js +0 -2
  60. package/cjs/interfaces/script-result.js +0 -2
  61. package/cjs/interfaces/statement-prepare-options.js +0 -2
  62. package/cjs/package.json +0 -3
  63. package/cjs/protocol/backend.js +0 -262
  64. package/cjs/protocol/buffer-reader.js +0 -78
  65. package/cjs/protocol/database-error.js +0 -17
  66. package/cjs/protocol/frontend.js +0 -255
  67. package/cjs/protocol/pg-socket.js +0 -367
  68. package/cjs/protocol/protocol.js +0 -71
  69. package/cjs/protocol/sasl.js +0 -108
  70. package/cjs/protocol/smart-buffer.js +0 -178
  71. package/cjs/safe-event-emitter.js +0 -17
  72. package/cjs/tsconfig-build-cjs.tsbuildinfo +0 -1
  73. package/cjs/types.js +0 -2
  74. package/cjs/util/array-calculatedim.js +0 -18
  75. package/cjs/util/bigint-methods.js +0 -44
  76. package/cjs/util/config-from-env.js +0 -29
  77. package/cjs/util/connection-config.js +0 -61
  78. package/cjs/util/convert-row-to-object.js +0 -12
  79. package/cjs/util/decode-binaryarray.js +0 -38
  80. package/cjs/util/encode-binaryarray.js +0 -44
  81. package/cjs/util/escape-literal.js +0 -26
  82. package/cjs/util/fast-parseint.js +0 -31
  83. package/cjs/util/get-parsers.js +0 -41
  84. package/cjs/util/parse-array.js +0 -60
  85. package/cjs/util/parse-datetime.js +0 -37
  86. package/cjs/util/parse-row.js +0 -11
  87. package/cjs/util/parse-time.js +0 -30
  88. package/cjs/util/stringify-arrayliteral.js +0 -37
  89. package/cjs/util/stringify-for-sql.js +0 -29
  90. package/cjs/util/wrap-row-description.js +0 -34
  91. package/esm/package.json +0 -3
  92. package/types/index.d.cts +0 -25
  93. /package/{types/connection → connection}/bind-param.d.ts +0 -0
  94. /package/{types/connection → connection}/connection.d.ts +0 -0
  95. /package/{types/connection → connection}/cursor.d.ts +0 -0
  96. /package/{types/connection → connection}/intl-connection.d.ts +0 -0
  97. /package/{types/connection → connection}/pool.d.ts +0 -0
  98. /package/{types/connection → connection}/portal.d.ts +0 -0
  99. /package/{types/connection → connection}/prepared-statement.d.ts +0 -0
  100. /package/{types/constants.d.ts → constants.d.ts} +0 -0
  101. /package/{types/data-type-map.d.ts → data-type-map.d.ts} +0 -0
  102. /package/{types/data-types → data-types}/bool-type.d.ts +0 -0
  103. /package/{esm/data-types → data-types}/bool-type.js +0 -0
  104. /package/{types/data-types → data-types}/box-type.d.ts +0 -0
  105. /package/{esm/data-types → data-types}/box-type.js +0 -0
  106. /package/{types/data-types → data-types}/bytea-type.d.ts +0 -0
  107. /package/{esm/data-types → data-types}/bytea-type.js +0 -0
  108. /package/{types/data-types → data-types}/char-type.d.ts +0 -0
  109. /package/{esm/data-types → data-types}/char-type.js +0 -0
  110. /package/{types/data-types → data-types}/circle-type.d.ts +0 -0
  111. /package/{esm/data-types → data-types}/circle-type.js +0 -0
  112. /package/{types/data-types → data-types}/date-type.d.ts +0 -0
  113. /package/{esm/data-types → data-types}/date-type.js +0 -0
  114. /package/{types/data-types → data-types}/float4-type.d.ts +0 -0
  115. /package/{esm/data-types → data-types}/float4-type.js +0 -0
  116. /package/{types/data-types → data-types}/float8-type.d.ts +0 -0
  117. /package/{esm/data-types → data-types}/float8-type.js +0 -0
  118. /package/{types/data-types → data-types}/int2-type.d.ts +0 -0
  119. /package/{esm/data-types → data-types}/int2-type.js +0 -0
  120. /package/{types/data-types → data-types}/int2-vector-type.d.ts +0 -0
  121. /package/{esm/data-types → data-types}/int2-vector-type.js +0 -0
  122. /package/{types/data-types → data-types}/int4-type.d.ts +0 -0
  123. /package/{esm/data-types → data-types}/int4-type.js +0 -0
  124. /package/{types/data-types → data-types}/int8-type.d.ts +0 -0
  125. /package/{esm/data-types → data-types}/int8-type.js +0 -0
  126. /package/{types/data-types → data-types}/json-type.d.ts +0 -0
  127. /package/{esm/data-types → data-types}/json-type.js +0 -0
  128. /package/{types/data-types → data-types}/jsonb-type.d.ts +0 -0
  129. /package/{esm/data-types → data-types}/jsonb-type.js +0 -0
  130. /package/{types/data-types → data-types}/lseg-type.d.ts +0 -0
  131. /package/{esm/data-types → data-types}/lseg-type.js +0 -0
  132. /package/{types/data-types → data-types}/numeric-type.d.ts +0 -0
  133. /package/{esm/data-types → data-types}/numeric-type.js +0 -0
  134. /package/{types/data-types → data-types}/oid-type.d.ts +0 -0
  135. /package/{esm/data-types → data-types}/oid-type.js +0 -0
  136. /package/{types/data-types → data-types}/point-type.d.ts +0 -0
  137. /package/{esm/data-types → data-types}/point-type.js +0 -0
  138. /package/{types/data-types → data-types}/time-type.d.ts +0 -0
  139. /package/{esm/data-types → data-types}/time-type.js +0 -0
  140. /package/{types/data-types → data-types}/timestamp-type.d.ts +0 -0
  141. /package/{esm/data-types → data-types}/timestamp-type.js +0 -0
  142. /package/{types/data-types → data-types}/timestamptz-type.d.ts +0 -0
  143. /package/{esm/data-types → data-types}/timestamptz-type.js +0 -0
  144. /package/{types/data-types → data-types}/uuid-type.d.ts +0 -0
  145. /package/{esm/data-types → data-types}/uuid-type.js +0 -0
  146. /package/{types/data-types → data-types}/varchar-type.d.ts +0 -0
  147. /package/{esm/data-types → data-types}/varchar-type.js +0 -0
  148. /package/{types/index.d.ts → index.d.ts} +0 -0
  149. /package/{esm/index.js → index.js} +0 -0
  150. /package/{types/interfaces → interfaces}/command-result.d.ts +0 -0
  151. /package/{esm/interfaces → interfaces}/command-result.js +0 -0
  152. /package/{types/interfaces → interfaces}/data-mapping-options.d.ts +0 -0
  153. /package/{esm/interfaces → interfaces}/data-mapping-options.js +0 -0
  154. /package/{types/interfaces → interfaces}/data-type.d.ts +0 -0
  155. /package/{esm/interfaces → interfaces}/data-type.js +0 -0
  156. /package/{types/interfaces → interfaces}/database-connection-params.d.ts +0 -0
  157. /package/{esm/interfaces → interfaces}/database-connection-params.js +0 -0
  158. /package/{types/interfaces → interfaces}/field-info.d.ts +0 -0
  159. /package/{esm/interfaces → interfaces}/field-info.js +0 -0
  160. /package/{types/interfaces → interfaces}/query-options.d.ts +0 -0
  161. /package/{esm/interfaces → interfaces}/query-options.js +0 -0
  162. /package/{types/interfaces → interfaces}/query-result.d.ts +0 -0
  163. /package/{esm/interfaces → interfaces}/query-result.js +0 -0
  164. /package/{types/interfaces → interfaces}/script-execute-options.d.ts +0 -0
  165. /package/{esm/interfaces → interfaces}/script-execute-options.js +0 -0
  166. /package/{types/interfaces → interfaces}/script-result.d.ts +0 -0
  167. /package/{esm/interfaces → interfaces}/script-result.js +0 -0
  168. /package/{types/interfaces → interfaces}/statement-prepare-options.d.ts +0 -0
  169. /package/{esm/interfaces → interfaces}/statement-prepare-options.js +0 -0
  170. /package/{types/protocol → protocol}/backend.d.ts +0 -0
  171. /package/{types/protocol → protocol}/buffer-reader.d.ts +0 -0
  172. /package/{types/protocol → protocol}/database-error.d.ts +0 -0
  173. /package/{types/protocol → protocol}/frontend.d.ts +0 -0
  174. /package/{types/protocol → protocol}/pg-socket.d.ts +0 -0
  175. /package/{types/protocol → protocol}/protocol.d.ts +0 -0
  176. /package/{esm/protocol → protocol}/protocol.js +0 -0
  177. /package/{types/protocol → protocol}/sasl.d.ts +0 -0
  178. /package/{esm/protocol → protocol}/sasl.js +0 -0
  179. /package/{types/protocol → protocol}/smart-buffer.d.ts +0 -0
  180. /package/{types/safe-event-emitter.d.ts → safe-event-emitter.d.ts} +0 -0
  181. /package/{esm/safe-event-emitter.js → safe-event-emitter.js} +0 -0
  182. /package/{types/types.d.ts → types.d.ts} +0 -0
  183. /package/{esm/types.js → types.js} +0 -0
  184. /package/{types/util → util}/array-calculatedim.d.ts +0 -0
  185. /package/{esm/util → util}/array-calculatedim.js +0 -0
  186. /package/{types/util → util}/bigint-methods.d.ts +0 -0
  187. /package/{types/util → util}/config-from-env.d.ts +0 -0
  188. /package/{esm/util → util}/config-from-env.js +0 -0
  189. /package/{types/util → util}/connection-config.d.ts +0 -0
  190. /package/{esm/util → util}/connection-config.js +0 -0
  191. /package/{types/util → util}/convert-row-to-object.d.ts +0 -0
  192. /package/{esm/util → util}/convert-row-to-object.js +0 -0
  193. /package/{types/util → util}/decode-binaryarray.d.ts +0 -0
  194. /package/{esm/util → util}/decode-binaryarray.js +0 -0
  195. /package/{types/util → util}/encode-binaryarray.d.ts +0 -0
  196. /package/{esm/util → util}/encode-binaryarray.js +0 -0
  197. /package/{types/util → util}/escape-literal.d.ts +0 -0
  198. /package/{esm/util → util}/escape-literal.js +0 -0
  199. /package/{types/util → util}/fast-parseint.d.ts +0 -0
  200. /package/{esm/util → util}/fast-parseint.js +0 -0
  201. /package/{types/util → util}/get-parsers.d.ts +0 -0
  202. /package/{esm/util → util}/get-parsers.js +0 -0
  203. /package/{types/util → util}/parse-array.d.ts +0 -0
  204. /package/{esm/util → util}/parse-array.js +0 -0
  205. /package/{types/util → util}/parse-datetime.d.ts +0 -0
  206. /package/{esm/util → util}/parse-datetime.js +0 -0
  207. /package/{types/util → util}/parse-row.d.ts +0 -0
  208. /package/{esm/util → util}/parse-row.js +0 -0
  209. /package/{types/util → util}/parse-time.d.ts +0 -0
  210. /package/{esm/util → util}/parse-time.js +0 -0
  211. /package/{types/util → util}/stringify-arrayliteral.d.ts +0 -0
  212. /package/{esm/util → util}/stringify-arrayliteral.js +0 -0
  213. /package/{types/util → util}/stringify-for-sql.d.ts +0 -0
  214. /package/{esm/util → util}/stringify-for-sql.js +0 -0
  215. /package/{types/util → util}/wrap-row-description.d.ts +0 -0
  216. /package/{esm/util → util}/wrap-row-description.js +0 -0
@@ -1,131 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GlobalTypeMap = exports.DataTypeMap = void 0;
4
- const constants_js_1 = require("./constants.js");
5
- const bool_type_js_1 = require("./data-types/bool-type.js");
6
- const box_type_js_1 = require("./data-types/box-type.js");
7
- const bytea_type_js_1 = require("./data-types/bytea-type.js");
8
- const char_type_js_1 = require("./data-types/char-type.js");
9
- const circle_type_js_1 = require("./data-types/circle-type.js");
10
- const date_type_js_1 = require("./data-types/date-type.js");
11
- const float4_type_js_1 = require("./data-types/float4-type.js");
12
- const float8_type_js_1 = require("./data-types/float8-type.js");
13
- const int2_type_js_1 = require("./data-types/int2-type.js");
14
- const int2_vector_type_js_1 = require("./data-types/int2-vector-type.js");
15
- const int4_type_js_1 = require("./data-types/int4-type.js");
16
- const int8_type_js_1 = require("./data-types/int8-type.js");
17
- const json_type_js_1 = require("./data-types/json-type.js");
18
- const jsonb_type_js_1 = require("./data-types/jsonb-type.js");
19
- const lseg_type_js_1 = require("./data-types/lseg-type.js");
20
- const numeric_type_js_1 = require("./data-types/numeric-type.js");
21
- const oid_type_js_1 = require("./data-types/oid-type.js");
22
- const point_type_js_1 = require("./data-types/point-type.js");
23
- const time_type_js_1 = require("./data-types/time-type.js");
24
- const timestamp_type_js_1 = require("./data-types/timestamp-type.js");
25
- const timestamptz_type_js_1 = require("./data-types/timestamptz-type.js");
26
- const uuid_type_js_1 = require("./data-types/uuid-type.js");
27
- const varchar_type_js_1 = require("./data-types/varchar-type.js");
28
- class DataTypeMap {
29
- constructor(other) {
30
- this._itemsByOID = {};
31
- this._items = [];
32
- if (other instanceof DataTypeMap)
33
- Object.assign(this._items, other._items);
34
- }
35
- get(oid) {
36
- return this._itemsByOID[oid];
37
- }
38
- register(dataTypes) {
39
- dataTypes = Array.isArray(dataTypes) ? dataTypes : [dataTypes];
40
- for (const t of dataTypes) {
41
- this._itemsByOID[t.oid] = t;
42
- const i = this._items.findIndex(tt => tt.oid === t.oid);
43
- if (i >= 0)
44
- this._items[i] = t;
45
- else
46
- this._items.push(t);
47
- }
48
- }
49
- determine(value) {
50
- if (value == null)
51
- return constants_js_1.DataTypeOIDs.unknown;
52
- const valueIsArray = Array.isArray(value);
53
- let i;
54
- let t;
55
- for (i = this._items.length - 1; i >= 0; i--) {
56
- t = this._items[i];
57
- if (valueIsArray) {
58
- if (t.elementsOID && t.isType(value[0]))
59
- return t.oid;
60
- }
61
- else if (!t.elementsOID && t.isType(value))
62
- return t.oid;
63
- }
64
- return constants_js_1.DataTypeOIDs.unknown;
65
- }
66
- }
67
- exports.DataTypeMap = DataTypeMap;
68
- exports.GlobalTypeMap = new DataTypeMap();
69
- exports.GlobalTypeMap.register([oid_type_js_1.OidType, oid_type_js_1.VectorOidType, oid_type_js_1.ArrayOidType]);
70
- exports.GlobalTypeMap.register([jsonb_type_js_1.JsonbType, jsonb_type_js_1.ArrayJsonbType]);
71
- exports.GlobalTypeMap.register([json_type_js_1.JsonType, json_type_js_1.ArrayJsonType]);
72
- exports.GlobalTypeMap.register([bool_type_js_1.BoolType, bool_type_js_1.ArrayBoolType]);
73
- exports.GlobalTypeMap.register([numeric_type_js_1.NumericType, numeric_type_js_1.ArrayNumericType]);
74
- exports.GlobalTypeMap.register([float4_type_js_1.Float4Type, float4_type_js_1.ArrayFloat4Type]);
75
- exports.GlobalTypeMap.register([float8_type_js_1.Float8Type, float8_type_js_1.ArrayFloat8Type]);
76
- exports.GlobalTypeMap.register([int2_type_js_1.Int2Type, int2_type_js_1.ArrayInt2Type]);
77
- exports.GlobalTypeMap.register([int4_type_js_1.Int4Type, int4_type_js_1.ArrayInt4Type]);
78
- exports.GlobalTypeMap.register([int8_type_js_1.Int8Type, int8_type_js_1.ArrayInt8Type]);
79
- exports.GlobalTypeMap.register([bytea_type_js_1.ByteaType, bytea_type_js_1.ArrayByteaType]);
80
- exports.GlobalTypeMap.register([circle_type_js_1.CircleType, circle_type_js_1.ArrayCircleType]);
81
- exports.GlobalTypeMap.register([point_type_js_1.PointType, point_type_js_1.ArrayPointType]);
82
- exports.GlobalTypeMap.register([lseg_type_js_1.LsegType, lseg_type_js_1.ArrayLsegType]);
83
- exports.GlobalTypeMap.register([box_type_js_1.BoxType, box_type_js_1.ArrayBoxType]);
84
- exports.GlobalTypeMap.register([int2_vector_type_js_1.Int2VectorType, int2_vector_type_js_1.ArrayInt2VectorType]);
85
- exports.GlobalTypeMap.register({
86
- ...varchar_type_js_1.VarcharType,
87
- name: 'bpchar',
88
- oid: constants_js_1.DataTypeOIDs.bpchar,
89
- });
90
- exports.GlobalTypeMap.register({
91
- ...varchar_type_js_1.ArrayVarcharType,
92
- name: '_bpchar',
93
- oid: constants_js_1.DataTypeOIDs._bpchar,
94
- elementsOID: constants_js_1.DataTypeOIDs.bpchar,
95
- });
96
- exports.GlobalTypeMap.register({
97
- ...varchar_type_js_1.VarcharType,
98
- name: 'name',
99
- oid: constants_js_1.DataTypeOIDs.name,
100
- });
101
- exports.GlobalTypeMap.register({
102
- ...varchar_type_js_1.ArrayVarcharType,
103
- name: '_name',
104
- oid: constants_js_1.DataTypeOIDs._name,
105
- elementsOID: constants_js_1.DataTypeOIDs.name,
106
- });
107
- exports.GlobalTypeMap.register({
108
- ...varchar_type_js_1.VarcharType,
109
- name: 'text',
110
- oid: constants_js_1.DataTypeOIDs.text,
111
- });
112
- exports.GlobalTypeMap.register({
113
- ...varchar_type_js_1.ArrayVarcharType,
114
- name: '_text',
115
- oid: constants_js_1.DataTypeOIDs._text,
116
- elementsOID: constants_js_1.DataTypeOIDs.text,
117
- });
118
- exports.GlobalTypeMap.register({ ...varchar_type_js_1.VarcharType, name: 'xml', oid: constants_js_1.DataTypeOIDs.xml });
119
- exports.GlobalTypeMap.register({
120
- ...varchar_type_js_1.ArrayVarcharType,
121
- name: '_xml',
122
- oid: constants_js_1.DataTypeOIDs._xml,
123
- elementsOID: constants_js_1.DataTypeOIDs.xml,
124
- });
125
- exports.GlobalTypeMap.register([varchar_type_js_1.VarcharType, varchar_type_js_1.ArrayVarcharType]);
126
- exports.GlobalTypeMap.register([uuid_type_js_1.UuidType, uuid_type_js_1.ArrayUuidType]);
127
- exports.GlobalTypeMap.register([char_type_js_1.CharType, char_type_js_1.ArrayCharType]);
128
- exports.GlobalTypeMap.register([timestamptz_type_js_1.TimestamptzType, timestamptz_type_js_1.ArrayTimestamptzType]);
129
- exports.GlobalTypeMap.register([time_type_js_1.TimeType, time_type_js_1.ArrayTimeType]);
130
- exports.GlobalTypeMap.register([date_type_js_1.DateType, date_type_js_1.ArrayDateType]);
131
- exports.GlobalTypeMap.register([timestamp_type_js_1.TimestampType, timestamp_type_js_1.ArrayTimestampType]);
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayBoolType = exports.BoolType = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- exports.BoolType = {
6
- name: 'bool',
7
- oid: constants_js_1.DataTypeOIDs.bool,
8
- jsType: 'boolean',
9
- parseBinary(v) {
10
- return !!v.readUInt8();
11
- },
12
- encodeBinary(buf, v) {
13
- buf.writeInt8(v ? 1 : 0);
14
- },
15
- parseText(v) {
16
- return (v === 'TRUE' ||
17
- v === 't' ||
18
- v === 'true' ||
19
- v === 'y' ||
20
- v === 'yes' ||
21
- v === 'on' ||
22
- v === '1');
23
- },
24
- isType(v) {
25
- return typeof v === 'boolean';
26
- },
27
- };
28
- exports.ArrayBoolType = {
29
- ...exports.BoolType,
30
- name: '_bool',
31
- oid: constants_js_1.DataTypeOIDs._bool,
32
- elementsOID: constants_js_1.DataTypeOIDs.bool,
33
- };
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayBoxType = exports.BoxType = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const BOX_PATTERN1 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *\)$/;
6
- const BOX_PATTERN2 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\)$/;
7
- const BOX_PATTERN3 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
8
- exports.BoxType = {
9
- name: 'box',
10
- oid: constants_js_1.DataTypeOIDs.box,
11
- jsType: 'object',
12
- arraySeparator: ';',
13
- parseBinary(v) {
14
- return {
15
- x1: v.readDoubleBE(0),
16
- y1: v.readDoubleBE(8),
17
- x2: v.readDoubleBE(16),
18
- y2: v.readDoubleBE(24),
19
- };
20
- },
21
- encodeBinary(buf, v) {
22
- buf.writeDoubleBE(v.x1);
23
- buf.writeDoubleBE(v.y1);
24
- buf.writeDoubleBE(v.x2);
25
- buf.writeDoubleBE(v.y2);
26
- },
27
- parseText(v) {
28
- const m = v.match(BOX_PATTERN1) || v.match(BOX_PATTERN2) || v.match(BOX_PATTERN3);
29
- if (!m)
30
- return undefined;
31
- return {
32
- x1: parseFloat(m[1]),
33
- y1: parseFloat(m[2]),
34
- x2: parseFloat(m[3]),
35
- y2: parseFloat(m[4]),
36
- };
37
- },
38
- isType(v) {
39
- return (typeof v === 'object' &&
40
- Object.keys(v).length === 4 &&
41
- typeof v.x1 === 'number' &&
42
- typeof v.y1 === 'number' &&
43
- typeof v.x2 === 'number' &&
44
- typeof v.y2 === 'number');
45
- },
46
- };
47
- exports.ArrayBoxType = {
48
- ...exports.BoxType,
49
- name: '_box',
50
- oid: constants_js_1.DataTypeOIDs._box,
51
- elementsOID: constants_js_1.DataTypeOIDs.box,
52
- };
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayByteaType = exports.ByteaType = void 0;
4
- const tslib_1 = require("tslib");
5
- // @ts-ignore -- no type definitions for decodeBytea
6
- const postgres_bytea_1 = tslib_1.__importDefault(require("postgres-bytea"));
7
- const constants_js_1 = require("../constants.js");
8
- exports.ByteaType = {
9
- name: 'bytea',
10
- oid: constants_js_1.DataTypeOIDs.bytea,
11
- jsType: 'Buffer',
12
- parseBinary(v) {
13
- return v;
14
- },
15
- encodeBinary(buf, v) {
16
- buf.writeBuffer(v);
17
- },
18
- parseText: postgres_bytea_1.default,
19
- isType(v) {
20
- return v instanceof Buffer;
21
- },
22
- };
23
- exports.ArrayByteaType = {
24
- ...exports.ByteaType,
25
- name: '_bytea',
26
- oid: constants_js_1.DataTypeOIDs._bytea,
27
- elementsOID: constants_js_1.DataTypeOIDs.bytea,
28
- };
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayCharType = exports.CharType = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- exports.CharType = {
6
- name: 'char',
7
- oid: constants_js_1.DataTypeOIDs.char,
8
- jsType: 'string',
9
- parseBinary(v) {
10
- return v.toString('utf8');
11
- },
12
- encodeBinary(buf, v) {
13
- buf.writeString((v ? '' + v : ' ')[0], 'utf8');
14
- },
15
- parseText(v) {
16
- return '' + v;
17
- },
18
- isType(v) {
19
- return typeof v === 'string' && v.length === 1;
20
- },
21
- };
22
- exports.ArrayCharType = {
23
- ...exports.CharType,
24
- name: '_char',
25
- oid: constants_js_1.DataTypeOIDs._char,
26
- elementsOID: constants_js_1.DataTypeOIDs.char,
27
- };
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayCircleType = exports.CircleType = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const CIRCLE_PATTERN1 = /^< *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*) *>$/;
6
- const CIRCLE_PATTERN2 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*) *\)$/;
7
- const CIRCLE_PATTERN3 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*)$/;
8
- const CIRCLE_PATTERN4 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
9
- exports.CircleType = {
10
- name: 'circle',
11
- oid: constants_js_1.DataTypeOIDs.circle,
12
- jsType: 'object',
13
- parseBinary(v) {
14
- return {
15
- x: v.readDoubleBE(0),
16
- y: v.readDoubleBE(8),
17
- r: v.readDoubleBE(16),
18
- };
19
- },
20
- encodeBinary(buf, v) {
21
- buf.writeDoubleBE(v.x);
22
- buf.writeDoubleBE(v.y);
23
- buf.writeDoubleBE(v.r);
24
- },
25
- parseText(v) {
26
- const m = v.match(CIRCLE_PATTERN1) ||
27
- v.match(CIRCLE_PATTERN2) ||
28
- v.match(CIRCLE_PATTERN3) ||
29
- v.match(CIRCLE_PATTERN4);
30
- if (!m)
31
- return undefined;
32
- return {
33
- x: parseFloat(m[1]),
34
- y: parseFloat(m[2]),
35
- r: parseFloat(m[3]),
36
- };
37
- },
38
- isType(v) {
39
- return (typeof v === 'object' &&
40
- Object.keys(v).length === 3 &&
41
- typeof v.x === 'number' &&
42
- typeof v.y === 'number' &&
43
- typeof v.r === 'number');
44
- },
45
- };
46
- exports.ArrayCircleType = {
47
- ...exports.CircleType,
48
- name: '_circle',
49
- oid: constants_js_1.DataTypeOIDs._circle,
50
- elementsOID: constants_js_1.DataTypeOIDs.circle,
51
- };
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayDateType = exports.DateType = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const parse_datetime_js_1 = require("../util/parse-datetime.js");
6
- const timeShift = 946684800000;
7
- exports.DateType = {
8
- name: 'date',
9
- oid: constants_js_1.DataTypeOIDs.date,
10
- jsType: 'Date',
11
- parseBinary(v, options) {
12
- const fetchAsString = options.fetchAsString &&
13
- options.fetchAsString.includes(constants_js_1.DataTypeOIDs.date);
14
- const t = v.readInt32BE();
15
- if (t === 0x7fffffff)
16
- return fetchAsString ? 'infinity' : Infinity;
17
- if (t === -0x80000000)
18
- return fetchAsString ? '-infinity' : -Infinity;
19
- // Shift from 2000 to 1970
20
- let d = new Date(t * 1000 * 86400 + timeShift);
21
- if (fetchAsString || !options.utcDates)
22
- d = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
23
- return fetchAsString ? dateToDateString(d) : d;
24
- },
25
- encodeBinary(buf, v, options) {
26
- if (typeof v === 'string')
27
- v = (0, parse_datetime_js_1.parseDateTime)(v, false, false, options.utcDates);
28
- if (v === Infinity) {
29
- buf.writeInt32BE(0x7fffffff);
30
- return;
31
- }
32
- if (v === -Infinity) {
33
- buf.writeInt32BE(-0x80000000);
34
- return;
35
- }
36
- if (!(v instanceof Date))
37
- v = new Date(v);
38
- let n = options.utcDates
39
- ? v.getTime()
40
- : v.getTime() - v.getTimezoneOffset() * 60 * 1000;
41
- n = (n - timeShift) / 1000 / 86400;
42
- const t = Math.trunc(n + Number.EPSILON);
43
- buf.writeInt32BE(t);
44
- },
45
- parseText(v, options) {
46
- const fetchAsString = options.fetchAsString &&
47
- options.fetchAsString.includes(constants_js_1.DataTypeOIDs.date);
48
- if (fetchAsString)
49
- return v;
50
- return (0, parse_datetime_js_1.parseDateTime)(v, false, false, options.utcDates);
51
- },
52
- isType(v) {
53
- return (v instanceof Date &&
54
- v.getHours() === 0 &&
55
- v.getMinutes() === 0 &&
56
- v.getSeconds() === 0 &&
57
- v.getMilliseconds() === 0);
58
- },
59
- };
60
- function padZero(v) {
61
- return v < 9 ? '0' + v : '' + v;
62
- }
63
- function dateToDateString(d) {
64
- return (d.getFullYear() +
65
- '-' +
66
- padZero(d.getMonth() + 1) +
67
- '-' +
68
- padZero(d.getDate()));
69
- }
70
- exports.ArrayDateType = {
71
- ...exports.DateType,
72
- name: '_date',
73
- oid: constants_js_1.DataTypeOIDs._date,
74
- elementsOID: constants_js_1.DataTypeOIDs.date,
75
- };
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayFloat4Type = exports.Float4Type = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- exports.Float4Type = {
6
- name: 'float4',
7
- oid: constants_js_1.DataTypeOIDs.float4,
8
- jsType: 'number',
9
- parseBinary(v) {
10
- return Math.round((v.readFloatBE(0) + Number.EPSILON) * 100) / 100;
11
- },
12
- encodeBinary(buf, v) {
13
- buf.writeFloatBE(typeof v === 'number' ? v : parseFloat(v));
14
- },
15
- parseText: parseFloat,
16
- isType(v) {
17
- return typeof v === 'number';
18
- },
19
- };
20
- exports.ArrayFloat4Type = {
21
- ...exports.Float4Type,
22
- name: '_float4',
23
- oid: constants_js_1.DataTypeOIDs._float4,
24
- elementsOID: constants_js_1.DataTypeOIDs.float4,
25
- };
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayFloat8Type = exports.Float8Type = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- exports.Float8Type = {
6
- name: 'float8',
7
- oid: constants_js_1.DataTypeOIDs.float8,
8
- jsType: 'number',
9
- parseBinary(v) {
10
- return v.readDoubleBE(0);
11
- },
12
- encodeBinary(buf, v) {
13
- buf.writeDoubleBE(typeof v === 'number' ? v : parseFloat(v));
14
- },
15
- parseText: parseFloat,
16
- isType(v) {
17
- return typeof v === 'number';
18
- },
19
- };
20
- exports.ArrayFloat8Type = {
21
- ...exports.Float8Type,
22
- name: '_float8',
23
- oid: constants_js_1.DataTypeOIDs._float8,
24
- elementsOID: constants_js_1.DataTypeOIDs.float8,
25
- };
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayInt2Type = exports.Int2Type = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const fast_parseint_js_1 = require("../util/fast-parseint.js");
6
- exports.Int2Type = {
7
- name: 'int2',
8
- oid: constants_js_1.DataTypeOIDs.int2,
9
- jsType: 'number',
10
- parseBinary(v) {
11
- return v.readInt16BE(0);
12
- },
13
- encodeBinary(buf, v) {
14
- buf.writeInt16BE((0, fast_parseint_js_1.fastParseInt)(v));
15
- },
16
- parseText: fast_parseint_js_1.fastParseInt,
17
- isType(v) {
18
- return (typeof v === 'number' && Number.isInteger(v) && v >= -32768 && v <= 32767);
19
- },
20
- };
21
- exports.ArrayInt2Type = {
22
- ...exports.Int2Type,
23
- name: '_int2',
24
- oid: constants_js_1.DataTypeOIDs._int2,
25
- elementsOID: constants_js_1.DataTypeOIDs.int2,
26
- };
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayInt2VectorType = exports.Int2VectorType = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const decode_binaryarray_js_1 = require("../util/decode-binaryarray.js");
6
- const encode_binaryarray_js_1 = require("../util/encode-binaryarray.js");
7
- const fast_parseint_js_1 = require("../util/fast-parseint.js");
8
- exports.Int2VectorType = {
9
- name: 'int2vector',
10
- oid: constants_js_1.DataTypeOIDs.int2vector,
11
- jsType: 'array',
12
- parseBinary(v) {
13
- return (0, decode_binaryarray_js_1.decodeBinaryArray)(v, b => b.readInt16BE()) || undefined;
14
- },
15
- encodeBinary(buf, v) {
16
- (0, encode_binaryarray_js_1.encodeBinaryArray)(buf, v, constants_js_1.DataTypeOIDs.int2, {}, (io, x) => {
17
- io.writeInt16BE(x);
18
- });
19
- },
20
- encodeCalculateDim(v) {
21
- return [v.length];
22
- },
23
- parseText(str) {
24
- return str.split(' ').map(fast_parseint_js_1.fastParseInt);
25
- },
26
- encodeText(v) {
27
- return v.join(' ');
28
- },
29
- isType(v) {
30
- return (Array.isArray(v) &&
31
- !v.find(x => !(typeof x === 'number' &&
32
- Number.isInteger(x) &&
33
- x >= -32768 &&
34
- x <= 32767)));
35
- },
36
- };
37
- exports.ArrayInt2VectorType = {
38
- ...exports.Int2VectorType,
39
- name: '_int2vector',
40
- oid: constants_js_1.DataTypeOIDs._int2vector,
41
- elementsOID: constants_js_1.DataTypeOIDs.int2vector,
42
- };
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayInt4Type = exports.Int4Type = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const fast_parseint_js_1 = require("../util/fast-parseint.js");
6
- exports.Int4Type = {
7
- name: 'int4',
8
- oid: constants_js_1.DataTypeOIDs.int4,
9
- jsType: 'number',
10
- parseBinary(v) {
11
- return v.readInt32BE(0);
12
- },
13
- encodeBinary(buf, v) {
14
- buf.writeInt32BE((0, fast_parseint_js_1.fastParseInt)(v));
15
- },
16
- parseText: fast_parseint_js_1.fastParseInt,
17
- isType(v) {
18
- return (typeof v === 'number' &&
19
- Number.isInteger(v) &&
20
- v <= Number.MAX_SAFE_INTEGER);
21
- },
22
- };
23
- exports.ArrayInt4Type = {
24
- ...exports.Int4Type,
25
- name: '_int4',
26
- oid: constants_js_1.DataTypeOIDs._int4,
27
- elementsOID: constants_js_1.DataTypeOIDs.int4,
28
- };
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayInt8Type = exports.Int8Type = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const bigint_methods_js_1 = require("../util/bigint-methods.js");
6
- const maxSafeInteger = BigInt(Number.MAX_SAFE_INTEGER);
7
- exports.Int8Type = {
8
- name: 'int8',
9
- oid: constants_js_1.DataTypeOIDs.int8,
10
- jsType: 'BigInt',
11
- parseBinary(buf) {
12
- const v = typeof buf.readBigInt64BE === 'function'
13
- ? buf.readBigInt64BE(0)
14
- : (0, bigint_methods_js_1.readBigInt64BE)(buf);
15
- return v >= -maxSafeInteger && v <= maxSafeInteger ? Number(v) : v;
16
- },
17
- encodeBinary(buf, v) {
18
- buf.writeBigInt64BE(v);
19
- },
20
- parseText(s) {
21
- const v = BigInt(s);
22
- return v >= -maxSafeInteger && v <= maxSafeInteger ? Number(v) : v;
23
- },
24
- isType(v) {
25
- return (typeof v === 'bigint' ||
26
- (typeof v === 'number' &&
27
- Number.isInteger(v) &&
28
- v > Number.MAX_SAFE_INTEGER));
29
- },
30
- };
31
- exports.ArrayInt8Type = {
32
- ...exports.Int8Type,
33
- name: '_int8',
34
- oid: constants_js_1.DataTypeOIDs._int8,
35
- elementsOID: constants_js_1.DataTypeOIDs.int8,
36
- };
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayJsonType = exports.JsonType = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- exports.JsonType = {
6
- name: 'json',
7
- oid: constants_js_1.DataTypeOIDs.json,
8
- jsType: 'string',
9
- parseBinary(v, options) {
10
- const content = v.toString('utf8');
11
- const fetchAsString = options.fetchAsString &&
12
- options.fetchAsString.includes(constants_js_1.DataTypeOIDs.jsonb);
13
- if (fetchAsString)
14
- return content;
15
- return content ? JSON.parse(content) : undefined;
16
- },
17
- encodeText(v) {
18
- if (typeof v === 'object' || typeof v === 'bigint')
19
- return JSON.stringify(v);
20
- if (typeof v === 'boolean')
21
- return v ? 'true' : 'false';
22
- return '' + v;
23
- },
24
- parseText(v, options) {
25
- const fetchAsString = options.fetchAsString &&
26
- options.fetchAsString.includes(constants_js_1.DataTypeOIDs.jsonb);
27
- if (fetchAsString)
28
- return v;
29
- return v ? JSON.parse(v) : null;
30
- },
31
- isType(v) {
32
- return v && typeof v === 'object';
33
- },
34
- };
35
- exports.ArrayJsonType = {
36
- ...exports.JsonType,
37
- name: '_json',
38
- oid: constants_js_1.DataTypeOIDs._json,
39
- elementsOID: constants_js_1.DataTypeOIDs.json,
40
- };
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayJsonbType = exports.JsonbType = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const buffer_reader_js_1 = require("../protocol/buffer-reader.js");
6
- exports.JsonbType = {
7
- name: 'jsonb',
8
- oid: constants_js_1.DataTypeOIDs.jsonb,
9
- jsType: 'string',
10
- parseBinary(v, options) {
11
- const buf = new buffer_reader_js_1.BufferReader(v);
12
- if (buf.readUInt8() !== 1)
13
- throw new Error('Unexpected Jsonb version value in header');
14
- const fetchAsString = options.fetchAsString &&
15
- options.fetchAsString.includes(constants_js_1.DataTypeOIDs.json);
16
- const content = buf.readLString(buf.length - buf.offset);
17
- if (fetchAsString)
18
- return content;
19
- return content ? JSON.parse(content) : undefined;
20
- },
21
- encodeText(v) {
22
- if (typeof v === 'object' || typeof v === 'bigint')
23
- return JSON.stringify(v);
24
- if (typeof v === 'boolean')
25
- return v ? 'true' : 'false';
26
- return '\x0001' + v;
27
- },
28
- parseText(v, options) {
29
- const fetchAsString = options.fetchAsString &&
30
- options.fetchAsString.includes(constants_js_1.DataTypeOIDs.json);
31
- if (fetchAsString)
32
- return v;
33
- return v ? JSON.parse(v) : null;
34
- },
35
- isType(v) {
36
- return v && typeof v === 'object';
37
- },
38
- };
39
- exports.ArrayJsonbType = {
40
- ...exports.JsonbType,
41
- name: '_jsonb',
42
- oid: constants_js_1.DataTypeOIDs._jsonb,
43
- elementsOID: constants_js_1.DataTypeOIDs.jsonb,
44
- };