data-api-client 2.1.2 → 2.1.3
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/dist/compat/pg.js +36 -6
- package/dist/params.js +35 -2
- package/dist/pg-escape.d.ts +3 -0
- package/dist/pg-escape.d.ts.map +1 -0
- package/dist/pg-escape.js +184 -0
- package/package.json +1 -3
package/dist/compat/pg.js
CHANGED
|
@@ -1,12 +1,42 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
5
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
36
|
exports.createPgClient = createPgClient;
|
|
7
37
|
exports.createPgPool = createPgPool;
|
|
8
38
|
const events_1 = require("events");
|
|
9
|
-
const
|
|
39
|
+
const pgEscape = __importStar(require("../pg-escape"));
|
|
10
40
|
const client_1 = require("../client");
|
|
11
41
|
const errors_1 = require("./errors");
|
|
12
42
|
function convertPgPlaceholders(sql, params = []) {
|
|
@@ -178,10 +208,10 @@ function createPgClient(config) {
|
|
|
178
208
|
resumeDrain() {
|
|
179
209
|
},
|
|
180
210
|
escapeIdentifier(str) {
|
|
181
|
-
return
|
|
211
|
+
return pgEscape.ident(str);
|
|
182
212
|
},
|
|
183
213
|
escapeLiteral(str) {
|
|
184
|
-
return
|
|
214
|
+
return pgEscape.literal(str);
|
|
185
215
|
},
|
|
186
216
|
setTypeParser(_oid, _format, _parseFn) {
|
|
187
217
|
},
|
package/dist/params.js
CHANGED
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
5
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
39
|
exports.formatType = exports.splitParams = exports.formatParam = exports.processParams = exports.normalizeParams = exports.prepareParams = exports.parseFormatOptions = exports.parseHydrate = exports.parseDatabase = exports.parseParams = void 0;
|
|
7
40
|
const sqlstring_1 = __importDefault(require("sqlstring"));
|
|
8
|
-
const
|
|
41
|
+
const pgEscape = __importStar(require("./pg-escape"));
|
|
9
42
|
const utils_1 = require("./utils");
|
|
10
43
|
const isPlainObject = (val) => typeof val === 'object' &&
|
|
11
44
|
val !== null &&
|
|
@@ -101,7 +134,7 @@ const processParams = (engine, sql, sqlParams, params, formatOptions, row = 0) =
|
|
|
101
134
|
else if (row === 0) {
|
|
102
135
|
const regex = new RegExp('::' + p.name + '\\b', 'g');
|
|
103
136
|
const escapedId = engine === 'pg'
|
|
104
|
-
?
|
|
137
|
+
? pgEscape.ident(p.value)
|
|
105
138
|
: sqlstring_1.default.escapeId(p.value);
|
|
106
139
|
sql = sql.replace(regex, escapedId);
|
|
107
140
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pg-escape.d.ts","sourceRoot":"","sources":["../src/pg-escape.ts"],"names":[],"mappings":"AA4MA,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMzC;AAYD,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CA8BxC"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ident = ident;
|
|
4
|
+
exports.literal = literal;
|
|
5
|
+
const POSTGRES_RESERVED_WORDS = new Set([
|
|
6
|
+
'aes128',
|
|
7
|
+
'aes256',
|
|
8
|
+
'all',
|
|
9
|
+
'allowoverwrite',
|
|
10
|
+
'analyse',
|
|
11
|
+
'analyze',
|
|
12
|
+
'and',
|
|
13
|
+
'any',
|
|
14
|
+
'array',
|
|
15
|
+
'as',
|
|
16
|
+
'asc',
|
|
17
|
+
'authorization',
|
|
18
|
+
'backup',
|
|
19
|
+
'between',
|
|
20
|
+
'binary',
|
|
21
|
+
'blanksasnull',
|
|
22
|
+
'both',
|
|
23
|
+
'bytedict',
|
|
24
|
+
'case',
|
|
25
|
+
'cast',
|
|
26
|
+
'check',
|
|
27
|
+
'collate',
|
|
28
|
+
'column',
|
|
29
|
+
'constraint',
|
|
30
|
+
'create',
|
|
31
|
+
'credentials',
|
|
32
|
+
'cross',
|
|
33
|
+
'current_date',
|
|
34
|
+
'current_time',
|
|
35
|
+
'current_timestamp',
|
|
36
|
+
'current_user',
|
|
37
|
+
'current_user_id',
|
|
38
|
+
'default',
|
|
39
|
+
'deferrable',
|
|
40
|
+
'deflate',
|
|
41
|
+
'defrag',
|
|
42
|
+
'delta',
|
|
43
|
+
'delta32k',
|
|
44
|
+
'desc',
|
|
45
|
+
'disable',
|
|
46
|
+
'distinct',
|
|
47
|
+
'do',
|
|
48
|
+
'else',
|
|
49
|
+
'emptyasnull',
|
|
50
|
+
'enable',
|
|
51
|
+
'encode',
|
|
52
|
+
'encrypt',
|
|
53
|
+
'encryption',
|
|
54
|
+
'end',
|
|
55
|
+
'except',
|
|
56
|
+
'explicit',
|
|
57
|
+
'false',
|
|
58
|
+
'for',
|
|
59
|
+
'foreign',
|
|
60
|
+
'freeze',
|
|
61
|
+
'from',
|
|
62
|
+
'full',
|
|
63
|
+
'globaldict256',
|
|
64
|
+
'globaldict64k',
|
|
65
|
+
'grant',
|
|
66
|
+
'group',
|
|
67
|
+
'gzip',
|
|
68
|
+
'having',
|
|
69
|
+
'identity',
|
|
70
|
+
'ignore',
|
|
71
|
+
'ilike',
|
|
72
|
+
'in',
|
|
73
|
+
'initially',
|
|
74
|
+
'inner',
|
|
75
|
+
'intersect',
|
|
76
|
+
'into',
|
|
77
|
+
'is',
|
|
78
|
+
'isnull',
|
|
79
|
+
'join',
|
|
80
|
+
'leading',
|
|
81
|
+
'left',
|
|
82
|
+
'like',
|
|
83
|
+
'limit',
|
|
84
|
+
'localtime',
|
|
85
|
+
'localtimestamp',
|
|
86
|
+
'lun',
|
|
87
|
+
'luns',
|
|
88
|
+
'lzo',
|
|
89
|
+
'lzop',
|
|
90
|
+
'minus',
|
|
91
|
+
'mostly13',
|
|
92
|
+
'mostly32',
|
|
93
|
+
'mostly8',
|
|
94
|
+
'natural',
|
|
95
|
+
'new',
|
|
96
|
+
'not',
|
|
97
|
+
'notnull',
|
|
98
|
+
'null',
|
|
99
|
+
'nulls',
|
|
100
|
+
'off',
|
|
101
|
+
'offline',
|
|
102
|
+
'offset',
|
|
103
|
+
'old',
|
|
104
|
+
'on',
|
|
105
|
+
'only',
|
|
106
|
+
'open',
|
|
107
|
+
'or',
|
|
108
|
+
'order',
|
|
109
|
+
'outer',
|
|
110
|
+
'overlaps',
|
|
111
|
+
'parallel',
|
|
112
|
+
'partition',
|
|
113
|
+
'percent',
|
|
114
|
+
'placing',
|
|
115
|
+
'primary',
|
|
116
|
+
'raw',
|
|
117
|
+
'readratio',
|
|
118
|
+
'recover',
|
|
119
|
+
'references',
|
|
120
|
+
'rejectlog',
|
|
121
|
+
'resort',
|
|
122
|
+
'restore',
|
|
123
|
+
'right',
|
|
124
|
+
'select',
|
|
125
|
+
'session_user',
|
|
126
|
+
'similar',
|
|
127
|
+
'some',
|
|
128
|
+
'sysdate',
|
|
129
|
+
'system',
|
|
130
|
+
'table',
|
|
131
|
+
'tag',
|
|
132
|
+
'tdes',
|
|
133
|
+
'text255',
|
|
134
|
+
'text32k',
|
|
135
|
+
'then',
|
|
136
|
+
'to',
|
|
137
|
+
'top',
|
|
138
|
+
'trailing',
|
|
139
|
+
'true',
|
|
140
|
+
'truncatecolumns',
|
|
141
|
+
'union',
|
|
142
|
+
'unique',
|
|
143
|
+
'user',
|
|
144
|
+
'using',
|
|
145
|
+
'verbose',
|
|
146
|
+
'wallet',
|
|
147
|
+
'when',
|
|
148
|
+
'where',
|
|
149
|
+
'with',
|
|
150
|
+
'without'
|
|
151
|
+
]);
|
|
152
|
+
function isValidIdentifier(id) {
|
|
153
|
+
if (POSTGRES_RESERVED_WORDS.has(id.toLowerCase())) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
return /^[a-z_][a-z0-9_$]*$/i.test(id);
|
|
157
|
+
}
|
|
158
|
+
function quoteIdentifier(id) {
|
|
159
|
+
const escaped = id.replace(/"/g, '""');
|
|
160
|
+
return `"${escaped}"`;
|
|
161
|
+
}
|
|
162
|
+
function ident(val) {
|
|
163
|
+
if (val == null) {
|
|
164
|
+
throw new Error('identifier required');
|
|
165
|
+
}
|
|
166
|
+
return isValidIdentifier(val) ? val : quoteIdentifier(val);
|
|
167
|
+
}
|
|
168
|
+
function literal(val) {
|
|
169
|
+
if (val == null) {
|
|
170
|
+
return 'NULL';
|
|
171
|
+
}
|
|
172
|
+
if (Array.isArray(val)) {
|
|
173
|
+
const escapedValues = val.map(literal);
|
|
174
|
+
return `(${escapedValues.join(', ')})`;
|
|
175
|
+
}
|
|
176
|
+
const str = String(val);
|
|
177
|
+
const hasBackslash = str.indexOf('\\') !== -1;
|
|
178
|
+
const prefix = hasBackslash ? 'E' : '';
|
|
179
|
+
let escaped = str.replace(/'/g, "''");
|
|
180
|
+
if (hasBackslash) {
|
|
181
|
+
escaped = escaped.replace(/\\/g, '\\\\');
|
|
182
|
+
}
|
|
183
|
+
return `${prefix}'${escaped}'`;
|
|
184
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "data-api-client",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "A lightweight wrapper that simplifies working with the Amazon Aurora Serverless Data API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -77,7 +77,6 @@
|
|
|
77
77
|
"@aws-sdk/client-rds-data": "^3.712.0",
|
|
78
78
|
"@types/node": "^24.6.2",
|
|
79
79
|
"@types/pg": "^8.15.5",
|
|
80
|
-
"@types/pg-escape": "^0.2.3",
|
|
81
80
|
"@types/sqlstring": "^2.3.2",
|
|
82
81
|
"@typescript-eslint/eslint-plugin": "^8.45.0",
|
|
83
82
|
"@typescript-eslint/parser": "^8.45.0",
|
|
@@ -94,7 +93,6 @@
|
|
|
94
93
|
"vitest": "^3.2.4"
|
|
95
94
|
},
|
|
96
95
|
"dependencies": {
|
|
97
|
-
"pg-escape": "^0.2.0",
|
|
98
96
|
"sqlstring": "^2.3.2"
|
|
99
97
|
},
|
|
100
98
|
"peerDependencies": {
|