@aws-lambda-powertools/jmespath 2.4.0 → 2.6.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.
- package/lib/cjs/Functions.d.ts.map +1 -1
- package/lib/cjs/Functions.js +26 -39
- package/lib/cjs/Lexer.d.ts.map +1 -1
- package/lib/cjs/Lexer.js +10 -18
- package/lib/cjs/ParsedResult.d.ts +1 -1
- package/lib/cjs/ParsedResult.d.ts.map +1 -1
- package/lib/cjs/Parser.d.ts.map +1 -1
- package/lib/cjs/Parser.js +51 -74
- package/lib/cjs/TreeInterpreter.d.ts +1 -1
- package/lib/cjs/TreeInterpreter.d.ts.map +1 -1
- package/lib/cjs/TreeInterpreter.js +8 -14
- package/lib/cjs/constants.js +2 -2
- package/lib/cjs/envelopes.js +2 -5
- package/lib/cjs/types.d.ts +2 -2
- package/lib/cjs/types.d.ts.map +1 -1
- package/lib/cjs/utils.d.ts.map +1 -1
- package/lib/cjs/utils.js +12 -11
- package/lib/esm/Functions.d.ts.map +1 -1
- package/lib/esm/Functions.js +26 -39
- package/lib/esm/Lexer.d.ts.map +1 -1
- package/lib/esm/Lexer.js +10 -18
- package/lib/esm/ParsedResult.d.ts +1 -1
- package/lib/esm/ParsedResult.d.ts.map +1 -1
- package/lib/esm/Parser.d.ts.map +1 -1
- package/lib/esm/Parser.js +52 -75
- package/lib/esm/TreeInterpreter.d.ts +1 -1
- package/lib/esm/TreeInterpreter.d.ts.map +1 -1
- package/lib/esm/TreeInterpreter.js +8 -14
- package/lib/esm/constants.js +2 -2
- package/lib/esm/envelopes.js +2 -5
- package/lib/esm/types.d.ts +2 -2
- package/lib/esm/types.d.ts.map +1 -1
- package/lib/esm/utils.d.ts.map +1 -1
- package/lib/esm/utils.js +13 -12
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Functions.d.ts","sourceRoot":"","sources":["../../src/Functions.ts"],"names":[],"mappings":"AAAA,OAAO,KA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AC,GAAG,SAAS;IAI/B;;;;;;;;;OASG;IAII,YAAY,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI;IAYlD;;;;;;;OAOG;IAII,YAAY,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM;IAI3C;;;;OAIG;IAII,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM;IAIvC;;;;OAIG;IAII,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,EAAE;IAI/C;;;;;;;;;;;;;;;;OAgBG;IACI,iBAAiB,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC;IA8BxD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;WACW,SAAS,CACrB,OAAO,EAAE,wBAAwB,GAChC,0BAA0B;CAiB9B;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/lib/cjs/Functions.js
CHANGED
|
@@ -121,9 +121,7 @@ class Functions {
|
|
|
121
121
|
if ((0, typeutils_1.isRecord)(arg)) {
|
|
122
122
|
return Object.keys(arg).length;
|
|
123
123
|
}
|
|
124
|
-
|
|
125
|
-
return arg.length;
|
|
126
|
-
}
|
|
124
|
+
return arg.length;
|
|
127
125
|
}
|
|
128
126
|
/**
|
|
129
127
|
* Map the provided function over the provided array.
|
|
@@ -146,13 +144,11 @@ class Functions {
|
|
|
146
144
|
return null;
|
|
147
145
|
// The signature decorator already enforces that all elements are of the same type
|
|
148
146
|
}
|
|
149
|
-
|
|
147
|
+
if ((0, typeutils_1.isNumber)(arg[0])) {
|
|
150
148
|
return Math.max(...arg);
|
|
151
149
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return arg.reduce((a, b) => (a > b ? a : b));
|
|
155
|
-
}
|
|
150
|
+
// local compare function to handle string comparison
|
|
151
|
+
return arg.reduce((a, b) => (a > b ? a : b));
|
|
156
152
|
}
|
|
157
153
|
/**
|
|
158
154
|
* Get the item in the provided array that has the maximum value when the provided expression is evaluated.
|
|
@@ -180,14 +176,12 @@ class Functions {
|
|
|
180
176
|
if (max.visited === current.visited) {
|
|
181
177
|
return max;
|
|
182
178
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
: current;
|
|
190
|
-
}
|
|
179
|
+
// We can safely cast visited to number | string here because we've already
|
|
180
|
+
// checked the type at runtime above and we know that it's either a number or a string
|
|
181
|
+
return max.visited >
|
|
182
|
+
current.visited
|
|
183
|
+
? max
|
|
184
|
+
: current;
|
|
191
185
|
}, visitedArgs[0]);
|
|
192
186
|
return max.arg;
|
|
193
187
|
}
|
|
@@ -199,6 +193,7 @@ class Functions {
|
|
|
199
193
|
* @param args The objects to merge
|
|
200
194
|
*/
|
|
201
195
|
funcMerge(...args) {
|
|
196
|
+
// biome-ignore lint/performance/noAccumulatingSpread: This is a shallow merge so the tradeoff is acceptable
|
|
202
197
|
return args.reduce((a, b) => ({ ...a, ...b }), {});
|
|
203
198
|
}
|
|
204
199
|
/**
|
|
@@ -211,12 +206,10 @@ class Functions {
|
|
|
211
206
|
return null;
|
|
212
207
|
// The signature decorator already enforces that all elements are of the same type
|
|
213
208
|
}
|
|
214
|
-
|
|
209
|
+
if ((0, typeutils_1.isNumber)(arg[0])) {
|
|
215
210
|
return Math.min(...arg);
|
|
216
211
|
}
|
|
217
|
-
|
|
218
|
-
return arg.reduce((a, b) => (a < b ? a : b));
|
|
219
|
-
}
|
|
212
|
+
return arg.reduce((a, b) => (a < b ? a : b));
|
|
220
213
|
}
|
|
221
214
|
/**
|
|
222
215
|
* Get the item in the provided array that has the minimum value when the provided expression is evaluated.
|
|
@@ -244,14 +237,12 @@ class Functions {
|
|
|
244
237
|
if (min.visited === current.visited) {
|
|
245
238
|
return min;
|
|
246
239
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
: current;
|
|
254
|
-
}
|
|
240
|
+
// We can safely cast visited to number | string here because we've already
|
|
241
|
+
// checked the type at runtime above and we know that it's either a number or a string
|
|
242
|
+
return min.visited <
|
|
243
|
+
current.visited
|
|
244
|
+
? min
|
|
245
|
+
: current;
|
|
255
246
|
}, visitedArgs[0]);
|
|
256
247
|
return min.arg;
|
|
257
248
|
}
|
|
@@ -320,13 +311,11 @@ class Functions {
|
|
|
320
311
|
if (a.visited === b.visited) {
|
|
321
312
|
return a.index - b.index; // Make the sort stable
|
|
322
313
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
: -1;
|
|
329
|
-
}
|
|
314
|
+
// We can safely cast visited to number | string here because we've already
|
|
315
|
+
// checked the type at runtime above and we know that it's either a number or a string
|
|
316
|
+
return a.visited > b.visited
|
|
317
|
+
? 1
|
|
318
|
+
: -1;
|
|
330
319
|
})
|
|
331
320
|
.map(({ value }) => value); // Extract the original values
|
|
332
321
|
}
|
|
@@ -372,13 +361,11 @@ class Functions {
|
|
|
372
361
|
if (typeof arg === 'number') {
|
|
373
362
|
return arg;
|
|
374
363
|
}
|
|
375
|
-
|
|
364
|
+
if (typeof arg === 'string') {
|
|
376
365
|
const num = Number(arg);
|
|
377
366
|
return Number.isNaN(num) ? null : num;
|
|
378
367
|
}
|
|
379
|
-
|
|
380
|
-
return null;
|
|
381
|
-
}
|
|
368
|
+
return null;
|
|
382
369
|
}
|
|
383
370
|
/**
|
|
384
371
|
* Convert the provided value to a string.
|
package/lib/cjs/Lexer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lexer.d.ts","sourceRoot":"","sources":["../../src/Lexer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;GAIG;AACH,cAAM,KAAK;;IAOT;;;;;;OAMG;IACK,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"Lexer.d.ts","sourceRoot":"","sources":["../../src/Lexer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;GAIG;AACH,cAAM,KAAK;;IAOT;;;;;;OAMG;IACK,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC;CA4UvD;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
package/lib/cjs/Lexer.js
CHANGED
|
@@ -26,9 +26,7 @@ class Lexer {
|
|
|
26
26
|
while (this.#current !== '' && this.#current !== undefined) {
|
|
27
27
|
if (constants_js_1.SIMPLE_TOKENS.has(this.#current)) {
|
|
28
28
|
yield {
|
|
29
|
-
// We know that SIMPLE_TOKENS has this.#current as a key because
|
|
30
|
-
// we checked for that above.
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
29
|
+
// biome-ignore lint/style/noNonNullAssertion: We know that SIMPLE_TOKENS has this.#current as a key because we checked for that above.
|
|
32
30
|
type: constants_js_1.SIMPLE_TOKENS.get(this.#current),
|
|
33
31
|
value: this.#current,
|
|
34
32
|
start: this.#position,
|
|
@@ -56,7 +54,7 @@ class Lexer {
|
|
|
56
54
|
const buff = this.#consumeNumber();
|
|
57
55
|
yield {
|
|
58
56
|
type: 'number',
|
|
59
|
-
value: parseInt(buff),
|
|
57
|
+
value: Number.parseInt(buff),
|
|
60
58
|
start: start,
|
|
61
59
|
end: start + buff.length,
|
|
62
60
|
};
|
|
@@ -116,9 +114,7 @@ class Lexer {
|
|
|
116
114
|
end: this.#position,
|
|
117
115
|
};
|
|
118
116
|
}
|
|
119
|
-
|
|
120
|
-
throw new errors_js_1.LexerError(this.#position - 1, '=');
|
|
121
|
-
}
|
|
117
|
+
throw new errors_js_1.LexerError(this.#position - 1, '=');
|
|
122
118
|
}
|
|
123
119
|
/**
|
|
124
120
|
* Consume an unquoted identifier.
|
|
@@ -152,15 +148,13 @@ class Lexer {
|
|
|
152
148
|
if (buff.length > 1) {
|
|
153
149
|
return {
|
|
154
150
|
type: 'number',
|
|
155
|
-
value: parseInt(buff),
|
|
151
|
+
value: Number.parseInt(buff),
|
|
156
152
|
start: start,
|
|
157
153
|
end: start + buff.length,
|
|
158
154
|
};
|
|
159
155
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
throw new errors_js_1.LexerError(start, 'Unknown token after "-"');
|
|
163
|
-
}
|
|
156
|
+
// If the negative sign is not followed by a number, it is an error.
|
|
157
|
+
throw new errors_js_1.LexerError(start, 'Unknown token after "-"');
|
|
164
158
|
}
|
|
165
159
|
/**
|
|
166
160
|
* Consume a raw string that is a number.
|
|
@@ -186,17 +180,15 @@ class Lexer {
|
|
|
186
180
|
#consumeSquareBracket() {
|
|
187
181
|
const start = this.#position;
|
|
188
182
|
const nextChar = this.#next();
|
|
189
|
-
if (nextChar
|
|
183
|
+
if (nextChar === ']') {
|
|
190
184
|
this.#next();
|
|
191
185
|
return { type: 'flatten', value: '[]', start: start, end: start + 2 };
|
|
192
186
|
}
|
|
193
|
-
|
|
187
|
+
if (nextChar === '?') {
|
|
194
188
|
this.#next();
|
|
195
189
|
return { type: 'filter', value: '[?', start: start, end: start + 2 };
|
|
196
190
|
}
|
|
197
|
-
|
|
198
|
-
return { type: 'lbracket', value: '[', start: start, end: start + 1 };
|
|
199
|
-
}
|
|
191
|
+
return { type: 'lbracket', value: '[', start: start, end: start + 1 };
|
|
200
192
|
}
|
|
201
193
|
/**
|
|
202
194
|
* Initializes the lexer for the given expression.
|
|
@@ -286,7 +278,7 @@ class Lexer {
|
|
|
286
278
|
*/
|
|
287
279
|
#consumeQuotedIdentifier() {
|
|
288
280
|
const start = this.#position;
|
|
289
|
-
const lexeme =
|
|
281
|
+
const lexeme = `"${this.#consumeUntil('"')}"`;
|
|
290
282
|
const tokenLen = this.#position - start;
|
|
291
283
|
return {
|
|
292
284
|
type: 'quoted_identifier',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParsedResult.d.ts","sourceRoot":"","sources":["../../src/ParsedResult.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ParsedResult.d.ts","sourceRoot":"","sources":["../../src/ParsedResult.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAE3E,cAAM,YAAY;IACT,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,IAAI,CAAC;gBAED,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI;IAKnD;;;;;OAKG;IACI,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO;CAiB5E;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/lib/cjs/Parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../src/Parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA6BjD;;;;;;;;;;;;;GAaG;AACH,cAAM,MAAM;;gBAkBS,SAAS,SAAI;IAIhC;;;;;;;;OAQG;IACI,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY;IAc9C;;OAEG;IACI,UAAU,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../src/Parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA6BjD;;;;;;;;;;;;;GAaG;AACH,cAAM,MAAM;;gBAkBS,SAAS,SAAI;IAIhC;;;;;;;;OAQG;IACI,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY;IAc9C;;OAEG;IACI,UAAU,IAAI,IAAI;CAutB1B;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/lib/cjs/Parser.js
CHANGED
|
@@ -141,13 +141,13 @@ class Parser {
|
|
|
141
141
|
case 'flatten':
|
|
142
142
|
return this.#processFlattenTokenNud();
|
|
143
143
|
case 'not':
|
|
144
|
-
return (0, ast_js_1.notExpression)(this.#expression(constants_js_1.BINDING_POWER
|
|
144
|
+
return (0, ast_js_1.notExpression)(this.#expression(constants_js_1.BINDING_POWER.not));
|
|
145
145
|
case 'lbracket':
|
|
146
146
|
return this.#processLBracketTokenNud();
|
|
147
147
|
case 'current':
|
|
148
148
|
return (0, ast_js_1.currentNode)();
|
|
149
149
|
case 'expref':
|
|
150
|
-
return (0, ast_js_1.expref)(this.#expression(constants_js_1.BINDING_POWER
|
|
150
|
+
return (0, ast_js_1.expref)(this.#expression(constants_js_1.BINDING_POWER.expref));
|
|
151
151
|
default:
|
|
152
152
|
return this.#processDefaultToken(token);
|
|
153
153
|
}
|
|
@@ -186,7 +186,7 @@ class Parser {
|
|
|
186
186
|
right = (0, ast_js_1.identity)();
|
|
187
187
|
}
|
|
188
188
|
else {
|
|
189
|
-
right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER
|
|
189
|
+
right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER.star);
|
|
190
190
|
}
|
|
191
191
|
return (0, ast_js_1.valueProjection)(left, right);
|
|
192
192
|
}
|
|
@@ -213,7 +213,7 @@ class Parser {
|
|
|
213
213
|
*/
|
|
214
214
|
#processFlattenTokenNud() {
|
|
215
215
|
const left = (0, ast_js_1.flatten)((0, ast_js_1.identity)());
|
|
216
|
-
const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER
|
|
216
|
+
const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER.flatten);
|
|
217
217
|
return (0, ast_js_1.projection)(left, right);
|
|
218
218
|
}
|
|
219
219
|
/**
|
|
@@ -229,16 +229,13 @@ class Parser {
|
|
|
229
229
|
const right = this.#parseIndexExpression();
|
|
230
230
|
return this.#projectIfSlice((0, ast_js_1.identity)(), right);
|
|
231
231
|
}
|
|
232
|
-
|
|
233
|
-
this.#lookahead(1) === 'rbracket') {
|
|
232
|
+
if (this.#currentToken() === 'star' && this.#lookahead(1) === 'rbracket') {
|
|
234
233
|
this.#advance();
|
|
235
234
|
this.#advance();
|
|
236
|
-
const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER
|
|
235
|
+
const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER.star);
|
|
237
236
|
return (0, ast_js_1.projection)((0, ast_js_1.identity)(), right);
|
|
238
237
|
}
|
|
239
|
-
|
|
240
|
-
return this.#parseMultiSelectList();
|
|
241
|
-
}
|
|
238
|
+
return this.#parseMultiSelectList();
|
|
242
239
|
}
|
|
243
240
|
/**
|
|
244
241
|
* Process a default token.
|
|
@@ -310,21 +307,17 @@ class Parser {
|
|
|
310
307
|
*/
|
|
311
308
|
#processDotToken(leftNode) {
|
|
312
309
|
if (this.#currentToken() !== 'star') {
|
|
313
|
-
const right = this.#parseDotRhs(constants_js_1.BINDING_POWER
|
|
310
|
+
const right = this.#parseDotRhs(constants_js_1.BINDING_POWER.dot);
|
|
314
311
|
if (leftNode.type === 'subexpression') {
|
|
315
312
|
leftNode.children.push(right);
|
|
316
313
|
return leftNode;
|
|
317
314
|
}
|
|
318
|
-
|
|
319
|
-
return (0, ast_js_1.subexpression)([leftNode, right]);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
// We are creating a value projection
|
|
324
|
-
this.#advance();
|
|
325
|
-
const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER['dot']);
|
|
326
|
-
return (0, ast_js_1.valueProjection)(leftNode, right);
|
|
315
|
+
return (0, ast_js_1.subexpression)([leftNode, right]);
|
|
327
316
|
}
|
|
317
|
+
// We are creating a value projection
|
|
318
|
+
this.#advance();
|
|
319
|
+
const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER.dot);
|
|
320
|
+
return (0, ast_js_1.valueProjection)(leftNode, right);
|
|
328
321
|
}
|
|
329
322
|
/**
|
|
330
323
|
* Process a pipe token.
|
|
@@ -337,7 +330,7 @@ class Parser {
|
|
|
337
330
|
* @param leftNode The left hand side of the expression.
|
|
338
331
|
*/
|
|
339
332
|
#processPipeToken(leftNode) {
|
|
340
|
-
const right = this.#expression(constants_js_1.BINDING_POWER
|
|
333
|
+
const right = this.#expression(constants_js_1.BINDING_POWER.pipe);
|
|
341
334
|
return (0, ast_js_1.pipe)(leftNode, right);
|
|
342
335
|
}
|
|
343
336
|
/**
|
|
@@ -351,7 +344,7 @@ class Parser {
|
|
|
351
344
|
* @param leftNode The left hand side of the expression.
|
|
352
345
|
*/
|
|
353
346
|
#processOrToken(leftNode) {
|
|
354
|
-
const right = this.#expression(constants_js_1.BINDING_POWER
|
|
347
|
+
const right = this.#expression(constants_js_1.BINDING_POWER.or);
|
|
355
348
|
return (0, ast_js_1.orExpression)(leftNode, right);
|
|
356
349
|
}
|
|
357
350
|
/**
|
|
@@ -365,7 +358,7 @@ class Parser {
|
|
|
365
358
|
* @param leftNode The left hand side of the expression.
|
|
366
359
|
*/
|
|
367
360
|
#processAndToken(leftNode) {
|
|
368
|
-
const right = this.#expression(constants_js_1.BINDING_POWER
|
|
361
|
+
const right = this.#expression(constants_js_1.BINDING_POWER.and);
|
|
369
362
|
return (0, ast_js_1.andExpression)(leftNode, right);
|
|
370
363
|
}
|
|
371
364
|
#processLParenToken(leftNode) {
|
|
@@ -390,13 +383,13 @@ class Parser {
|
|
|
390
383
|
right = (0, ast_js_1.identity)();
|
|
391
384
|
}
|
|
392
385
|
else {
|
|
393
|
-
right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER
|
|
386
|
+
right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER.flatten);
|
|
394
387
|
}
|
|
395
388
|
return (0, ast_js_1.filterProjection)(leftNode, right, condition);
|
|
396
389
|
}
|
|
397
390
|
#processFlattenToken(leftNode) {
|
|
398
391
|
const left = (0, ast_js_1.flatten)(leftNode);
|
|
399
|
-
const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER
|
|
392
|
+
const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER.flatten);
|
|
400
393
|
return (0, ast_js_1.projection)(left, right);
|
|
401
394
|
}
|
|
402
395
|
#processLBracketToken(leftNode) {
|
|
@@ -410,17 +403,13 @@ class Parser {
|
|
|
410
403
|
leftNode.children.push(right);
|
|
411
404
|
return leftNode;
|
|
412
405
|
}
|
|
413
|
-
|
|
414
|
-
return this.#projectIfSlice(leftNode, right);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
else {
|
|
418
|
-
// We have a projection
|
|
419
|
-
this.#match('star');
|
|
420
|
-
this.#match('rbracket');
|
|
421
|
-
const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER['star']);
|
|
422
|
-
return (0, ast_js_1.projection)(leftNode, right);
|
|
406
|
+
return this.#projectIfSlice(leftNode, right);
|
|
423
407
|
}
|
|
408
|
+
// We have a projection
|
|
409
|
+
this.#match('star');
|
|
410
|
+
this.#match('rbracket');
|
|
411
|
+
const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER.star);
|
|
412
|
+
return (0, ast_js_1.projection)(leftNode, right);
|
|
424
413
|
}
|
|
425
414
|
/**
|
|
426
415
|
* Throw a parse error.
|
|
@@ -458,13 +447,11 @@ class Parser {
|
|
|
458
447
|
if (this.#lookahead(0) === 'colon' || this.#lookahead(1) === 'colon') {
|
|
459
448
|
return this.#parseSliceExpression();
|
|
460
449
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
return node;
|
|
467
|
-
}
|
|
450
|
+
// Parse the syntax [number]
|
|
451
|
+
const node = (0, ast_js_1.index)(this.#lookaheadToken(0).value);
|
|
452
|
+
this.#advance();
|
|
453
|
+
this.#match('rbracket');
|
|
454
|
+
return node;
|
|
468
455
|
}
|
|
469
456
|
/**
|
|
470
457
|
* Process a slice expression.
|
|
@@ -522,11 +509,9 @@ class Parser {
|
|
|
522
509
|
#projectIfSlice(left, right) {
|
|
523
510
|
const idxExpression = (0, ast_js_1.indexExpression)([left, right]);
|
|
524
511
|
if (right.type === 'slice') {
|
|
525
|
-
return (0, ast_js_1.projection)(idxExpression, this.#parseProjectionRhs(constants_js_1.BINDING_POWER
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
return idxExpression;
|
|
512
|
+
return (0, ast_js_1.projection)(idxExpression, this.#parseProjectionRhs(constants_js_1.BINDING_POWER.star));
|
|
529
513
|
}
|
|
514
|
+
return idxExpression;
|
|
530
515
|
}
|
|
531
516
|
/**
|
|
532
517
|
* Process a comparator.
|
|
@@ -556,9 +541,7 @@ class Parser {
|
|
|
556
541
|
if (this.#currentToken() === 'rbracket') {
|
|
557
542
|
break;
|
|
558
543
|
}
|
|
559
|
-
|
|
560
|
-
this.#match('comma');
|
|
561
|
-
}
|
|
544
|
+
this.#match('comma');
|
|
562
545
|
}
|
|
563
546
|
this.#match('rbracket');
|
|
564
547
|
return (0, ast_js_1.multiSelectList)(expressions);
|
|
@@ -578,15 +561,15 @@ class Parser {
|
|
|
578
561
|
// Before getting the token value, verify it's
|
|
579
562
|
// an identifier.
|
|
580
563
|
this.#matchMultipleTokens(['quoted_identifier', 'unquoted_identifier']); // token types
|
|
581
|
-
const keyName = keyToken
|
|
564
|
+
const keyName = keyToken.value;
|
|
582
565
|
this.#match('colon');
|
|
583
566
|
const value = this.#expression(0);
|
|
584
567
|
const node = (0, ast_js_1.keyValPair)(keyName, value);
|
|
585
568
|
pairs.push(node);
|
|
586
|
-
if (this.#currentToken()
|
|
569
|
+
if (this.#currentToken() === 'comma') {
|
|
587
570
|
this.#match('comma');
|
|
588
571
|
}
|
|
589
|
-
else if (this.#currentToken()
|
|
572
|
+
else if (this.#currentToken() === 'rbrace') {
|
|
590
573
|
this.#match('rbrace');
|
|
591
574
|
break;
|
|
592
575
|
}
|
|
@@ -605,13 +588,13 @@ class Parser {
|
|
|
605
588
|
// BP of 10 are all the tokens that stop a projection.
|
|
606
589
|
right = (0, ast_js_1.identity)();
|
|
607
590
|
}
|
|
608
|
-
else if (this.#currentToken()
|
|
591
|
+
else if (this.#currentToken() === 'lbracket') {
|
|
609
592
|
right = this.#expression(bindingPower);
|
|
610
593
|
}
|
|
611
|
-
else if (this.#currentToken()
|
|
594
|
+
else if (this.#currentToken() === 'filter') {
|
|
612
595
|
right = this.#expression(bindingPower);
|
|
613
596
|
}
|
|
614
|
-
else if (this.#currentToken()
|
|
597
|
+
else if (this.#currentToken() === 'dot') {
|
|
615
598
|
this.#match('dot');
|
|
616
599
|
right = this.#parseDotRhs(bindingPower);
|
|
617
600
|
}
|
|
@@ -639,17 +622,15 @@ class Parser {
|
|
|
639
622
|
if (['quoted_identifier', 'unquoted_identifier', 'star'].includes(lookahead)) {
|
|
640
623
|
return this.#expression(bindingPower);
|
|
641
624
|
}
|
|
642
|
-
|
|
625
|
+
if (lookahead === 'lbracket') {
|
|
643
626
|
this.#match('lbracket');
|
|
644
627
|
return this.#parseMultiSelectList();
|
|
645
628
|
}
|
|
646
|
-
|
|
629
|
+
if (lookahead === 'lbrace') {
|
|
647
630
|
this.#match('lbrace');
|
|
648
631
|
return this.#parseMultiSelectHash();
|
|
649
632
|
}
|
|
650
|
-
|
|
651
|
-
this.#throwParseError();
|
|
652
|
-
}
|
|
633
|
+
this.#throwParseError();
|
|
653
634
|
}
|
|
654
635
|
/**
|
|
655
636
|
* Process a token and throw an error if it doesn't match the expected token.
|
|
@@ -670,13 +651,11 @@ class Parser {
|
|
|
670
651
|
tokenType: token.type,
|
|
671
652
|
});
|
|
672
653
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
});
|
|
679
|
-
}
|
|
654
|
+
throw new errors_js_1.ParseError({
|
|
655
|
+
lexPosition: token.start,
|
|
656
|
+
tokenValue: token.value,
|
|
657
|
+
tokenType: token.type,
|
|
658
|
+
});
|
|
680
659
|
}
|
|
681
660
|
}
|
|
682
661
|
/**
|
|
@@ -695,13 +674,11 @@ class Parser {
|
|
|
695
674
|
tokenType: token.type,
|
|
696
675
|
});
|
|
697
676
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
});
|
|
704
|
-
}
|
|
677
|
+
throw new errors_js_1.ParseError({
|
|
678
|
+
lexPosition: token.start,
|
|
679
|
+
tokenValue: token.value,
|
|
680
|
+
tokenType: token.type,
|
|
681
|
+
});
|
|
705
682
|
}
|
|
706
683
|
this.#advance();
|
|
707
684
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeInterpreter.d.ts","sourceRoot":"","sources":["../../src/TreeInterpreter.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"TreeInterpreter.d.ts","sourceRoot":"","sources":["../../src/TreeInterpreter.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAG3E;;;;;;;;GAQG;AACH,cAAM,eAAe;;IAGnB;;OAEG;gBACgB,OAAO,CAAC,EAAE,sBAAsB;IASnD;;;;;;;OAOG;IACI,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;CA2b/D;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TreeInterpreter = void 0;
|
|
4
4
|
const typeutils_1 = require("@aws-lambda-powertools/commons/typeutils");
|
|
5
|
-
const errors_js_1 = require("./errors.js");
|
|
6
5
|
const Expression_js_1 = require("./Expression.js");
|
|
7
6
|
const Functions_js_1 = require("./Functions.js");
|
|
7
|
+
const errors_js_1 = require("./errors.js");
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
@@ -67,9 +67,7 @@ class TreeInterpreter {
|
|
|
67
67
|
if (visitMethod) {
|
|
68
68
|
return visitMethod.call(this, node, value);
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
throw new errors_js_1.JMESPathError(`Not Implemented: Invalid node type: ${node.type}`);
|
|
72
|
-
}
|
|
70
|
+
throw new errors_js_1.JMESPathError(`Not Implemented: Invalid node type: ${node.type}`);
|
|
73
71
|
}
|
|
74
72
|
/**
|
|
75
73
|
* Visit a subexpression, index expression, or pipe node.
|
|
@@ -103,9 +101,7 @@ class TreeInterpreter {
|
|
|
103
101
|
node.value in value) {
|
|
104
102
|
return value[node.value];
|
|
105
103
|
}
|
|
106
|
-
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
104
|
+
return null;
|
|
109
105
|
}
|
|
110
106
|
/**
|
|
111
107
|
* Visit a comparator node.
|
|
@@ -123,24 +119,22 @@ class TreeInterpreter {
|
|
|
123
119
|
if (comparator === 'eq') {
|
|
124
120
|
return (0, typeutils_1.isStrictEqual)(left, right);
|
|
125
121
|
}
|
|
126
|
-
|
|
122
|
+
if (comparator === 'ne') {
|
|
127
123
|
return !(0, typeutils_1.isStrictEqual)(left, right);
|
|
128
124
|
}
|
|
129
|
-
|
|
125
|
+
if (typeof left === 'number' && typeof right === 'number') {
|
|
130
126
|
// Ordering operators only work on numbers. Evaluating them on other
|
|
131
127
|
// types will return null.
|
|
132
128
|
if (comparator === 'lt') {
|
|
133
129
|
return left < right;
|
|
134
130
|
}
|
|
135
|
-
|
|
131
|
+
if (comparator === 'lte') {
|
|
136
132
|
return left <= right;
|
|
137
133
|
}
|
|
138
|
-
|
|
134
|
+
if (comparator === 'gt') {
|
|
139
135
|
return left > right;
|
|
140
136
|
}
|
|
141
|
-
|
|
142
|
-
return left >= right;
|
|
143
|
-
}
|
|
137
|
+
return left >= right;
|
|
144
138
|
}
|
|
145
139
|
}
|
|
146
140
|
else {
|
package/lib/cjs/constants.js
CHANGED
|
@@ -60,12 +60,12 @@ const DIGITS = '0123456789';
|
|
|
60
60
|
/**
|
|
61
61
|
* The set of ASCII letters and digits allowed in JMESPath identifiers.
|
|
62
62
|
*/
|
|
63
|
-
const START_IDENTIFIER = new Set(ASCII_LETTERS
|
|
63
|
+
const START_IDENTIFIER = new Set(`${ASCII_LETTERS}_`);
|
|
64
64
|
exports.START_IDENTIFIER = START_IDENTIFIER;
|
|
65
65
|
/**
|
|
66
66
|
* The set of ASCII letters and digits allowed in JMESPath identifiers.
|
|
67
67
|
*/
|
|
68
|
-
const VALID_IDENTIFIER = new Set(ASCII_LETTERS
|
|
68
|
+
const VALID_IDENTIFIER = new Set(`${ASCII_LETTERS}${DIGITS}_`);
|
|
69
69
|
exports.VALID_IDENTIFIER = VALID_IDENTIFIER;
|
|
70
70
|
/**
|
|
71
71
|
* The set of ASCII digits allowed in JMESPath identifiers.
|
package/lib/cjs/envelopes.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.S3_EVENTBRIDGE_SQS = exports.S3_KINESIS_FIREHOSE = exports.S3_SNS_KINESIS_FIREHOSE = exports.S3_SQS = exports.S3_SNS_SQS = exports.CLOUDWATCH_LOGS = exports.KINESIS_DATA_STREAM = exports.CLOUDWATCH_EVENTS_SCHEDULED = exports.EVENTBRIDGE = exports.SNS = exports.SQS = exports.API_GATEWAY_HTTP = exports.API_GATEWAY_REST = exports.extractDataFromEnvelope = void 0;
|
|
4
|
-
const search_js_1 = require("./search.js");
|
|
5
4
|
const PowertoolsFunctions_js_1 = require("./PowertoolsFunctions.js");
|
|
5
|
+
const search_js_1 = require("./search.js");
|
|
6
6
|
/**
|
|
7
7
|
* Searches and extracts data using JMESPath
|
|
8
8
|
*
|
|
@@ -56,10 +56,7 @@ const PowertoolsFunctions_js_1 = require("./PowertoolsFunctions.js");
|
|
|
56
56
|
* @param options The parsing options to use
|
|
57
57
|
*/
|
|
58
58
|
const extractDataFromEnvelope = (data, envelope, options) => {
|
|
59
|
-
|
|
60
|
-
options = { customFunctions: new PowertoolsFunctions_js_1.PowertoolsFunctions() };
|
|
61
|
-
}
|
|
62
|
-
return (0, search_js_1.search)(envelope, data, options);
|
|
59
|
+
return (0, search_js_1.search)(envelope, data, options || { customFunctions: new PowertoolsFunctions_js_1.PowertoolsFunctions() });
|
|
63
60
|
};
|
|
64
61
|
exports.extractDataFromEnvelope = extractDataFromEnvelope;
|
|
65
62
|
const API_GATEWAY_REST = 'powertools_json(body)';
|
package/lib/cjs/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JSONArray, JSONValue } from '@aws-lambda-powertools/commons/types';
|
|
2
2
|
import type { Functions } from './Functions.js';
|
|
3
|
-
import { BINDING_POWER } from './constants.js';
|
|
3
|
+
import type { BINDING_POWER } from './constants.js';
|
|
4
4
|
/**
|
|
5
5
|
* A token in the JMESPath AST.
|
|
6
6
|
*/
|