@aws-lambda-powertools/jmespath 0.0.0-alpha.0 → 2.1.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 (97) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +214 -5
  3. package/lib/cjs/Expression.d.ts +19 -0
  4. package/lib/cjs/Expression.d.ts.map +1 -0
  5. package/lib/cjs/Expression.js +38 -0
  6. package/lib/cjs/Functions.d.ts +262 -0
  7. package/lib/cjs/Functions.d.ts.map +1 -0
  8. package/lib/cjs/Functions.js +619 -0
  9. package/lib/cjs/Lexer.d.ts +19 -0
  10. package/lib/cjs/Lexer.d.ts.map +1 -0
  11. package/lib/cjs/Lexer.js +271 -0
  12. package/lib/cjs/ParsedResult.d.ts +15 -0
  13. package/lib/cjs/ParsedResult.d.ts.map +1 -0
  14. package/lib/cjs/ParsedResult.js +33 -0
  15. package/lib/cjs/Parser.d.ts +35 -0
  16. package/lib/cjs/Parser.d.ts.map +1 -0
  17. package/lib/cjs/Parser.js +506 -0
  18. package/lib/cjs/PowertoolsFunctions.d.ts +36 -0
  19. package/lib/cjs/PowertoolsFunctions.d.ts.map +1 -0
  20. package/lib/cjs/PowertoolsFunctions.js +69 -0
  21. package/lib/cjs/TreeInterpreter.d.ts +28 -0
  22. package/lib/cjs/TreeInterpreter.d.ts.map +1 -0
  23. package/lib/cjs/TreeInterpreter.js +313 -0
  24. package/lib/cjs/ast.d.ts +185 -0
  25. package/lib/cjs/ast.d.ts.map +1 -0
  26. package/lib/cjs/ast.js +275 -0
  27. package/lib/cjs/constants.d.ts +60 -0
  28. package/lib/cjs/constants.d.ts.map +1 -0
  29. package/lib/cjs/constants.js +96 -0
  30. package/lib/cjs/envelopes.d.ts +69 -0
  31. package/lib/cjs/envelopes.d.ts.map +1 -0
  32. package/lib/cjs/envelopes.js +90 -0
  33. package/lib/cjs/errors.d.ts +183 -0
  34. package/lib/cjs/errors.d.ts.map +1 -0
  35. package/lib/cjs/errors.js +206 -0
  36. package/lib/cjs/index.d.ts +3 -0
  37. package/lib/cjs/index.d.ts.map +1 -0
  38. package/lib/cjs/index.js +15 -0
  39. package/lib/cjs/package.json +1 -0
  40. package/lib/cjs/search.d.ts +50 -0
  41. package/lib/cjs/search.d.ts.map +1 -0
  42. package/lib/cjs/search.js +55 -0
  43. package/lib/cjs/types.d.ts +84 -0
  44. package/lib/cjs/types.d.ts.map +1 -0
  45. package/lib/cjs/types.js +2 -0
  46. package/lib/cjs/utils.d.ts +87 -0
  47. package/lib/cjs/utils.d.ts.map +1 -0
  48. package/lib/cjs/utils.js +282 -0
  49. package/lib/esm/Expression.d.ts +19 -0
  50. package/lib/esm/Expression.d.ts.map +1 -0
  51. package/lib/esm/Expression.js +35 -0
  52. package/lib/esm/Functions.d.ts +262 -0
  53. package/lib/esm/Functions.d.ts.map +1 -0
  54. package/lib/esm/Functions.js +616 -0
  55. package/lib/esm/Lexer.d.ts +19 -0
  56. package/lib/esm/Lexer.d.ts.map +1 -0
  57. package/lib/esm/Lexer.js +268 -0
  58. package/lib/esm/ParsedResult.d.ts +15 -0
  59. package/lib/esm/ParsedResult.d.ts.map +1 -0
  60. package/lib/esm/ParsedResult.js +30 -0
  61. package/lib/esm/Parser.d.ts +35 -0
  62. package/lib/esm/Parser.d.ts.map +1 -0
  63. package/lib/esm/Parser.js +503 -0
  64. package/lib/esm/PowertoolsFunctions.d.ts +36 -0
  65. package/lib/esm/PowertoolsFunctions.d.ts.map +1 -0
  66. package/lib/esm/PowertoolsFunctions.js +66 -0
  67. package/lib/esm/TreeInterpreter.d.ts +28 -0
  68. package/lib/esm/TreeInterpreter.d.ts.map +1 -0
  69. package/lib/esm/TreeInterpreter.js +310 -0
  70. package/lib/esm/ast.d.ts +185 -0
  71. package/lib/esm/ast.d.ts.map +1 -0
  72. package/lib/esm/ast.js +251 -0
  73. package/lib/esm/constants.d.ts +60 -0
  74. package/lib/esm/constants.d.ts.map +1 -0
  75. package/lib/esm/constants.js +88 -0
  76. package/lib/esm/envelopes.d.ts +69 -0
  77. package/lib/esm/envelopes.d.ts.map +1 -0
  78. package/lib/esm/envelopes.js +74 -0
  79. package/lib/esm/errors.d.ts +183 -0
  80. package/lib/esm/errors.d.ts.map +1 -0
  81. package/lib/esm/errors.js +195 -0
  82. package/lib/esm/index.d.ts +3 -0
  83. package/lib/esm/index.d.ts.map +1 -0
  84. package/lib/esm/index.js +2 -0
  85. package/lib/esm/package.json +1 -0
  86. package/lib/esm/search.d.ts +50 -0
  87. package/lib/esm/search.d.ts.map +1 -0
  88. package/lib/esm/search.js +52 -0
  89. package/lib/esm/types.d.ts +84 -0
  90. package/lib/esm/types.d.ts.map +1 -0
  91. package/lib/esm/types.js +1 -0
  92. package/lib/esm/utils.d.ts +87 -0
  93. package/lib/esm/utils.d.ts.map +1 -0
  94. package/lib/esm/utils.js +275 -0
  95. package/package.json +51 -12
  96. package/lib/index.d.ts +0 -0
  97. package/lib/index.js +0 -4
@@ -0,0 +1,619 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.Functions = void 0;
10
+ const typeutils_1 = require("@aws-lambda-powertools/commons/typeutils");
11
+ const errors_js_1 = require("./errors.js");
12
+ const utils_js_1 = require("./utils.js");
13
+ /**
14
+ * A class that contains the built-in JMESPath functions.
15
+ *
16
+ * The built-in functions are implemented as methods on the Functions class.
17
+ * Each method is decorated with the `@Function.signature()` decorator to enforce the
18
+ * arity and types of the arguments passed to the function at runtime.
19
+ *
20
+ * You can extend the Functions class to add custom functions by creating a new class
21
+ * that extends Functions and adding new methods to it.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * import { search } from '@aws-lambda-powertools/jmespath';
26
+ * import { Functions } from '@aws-lambda-powertools/jmespath/functions';
27
+ *
28
+ * class MyFunctions extends Functions {
29
+ * ⁣@Functions.signature({
30
+ * argumentsSpecs: [['number'], ['number']],
31
+ * variadic: true,
32
+ * })
33
+ * public funcMyMethod(args: Array<number>): unknown {
34
+ * // ...
35
+ * }
36
+ * }
37
+ *
38
+ * const myFunctions = new MyFunctions();
39
+ *
40
+ * search('myMethod(@)', {}, { customFunctions: new MyFunctions() });
41
+ * ```
42
+ */
43
+ class Functions {
44
+ constructor() {
45
+ /**
46
+ * A set of all the custom functions available in this and all child classes.
47
+ */
48
+ this.methods = new Set();
49
+ }
50
+ /**
51
+ * Get the absolute value of the provided number.
52
+ *
53
+ * @param args The number to get the absolute value of
54
+ */
55
+ funcAbs(args) {
56
+ return Math.abs(args);
57
+ }
58
+ /**
59
+ * Calculate the average of the numbers in the provided array.
60
+ *
61
+ * @param args The numbers to average
62
+ */
63
+ funcAvg(args) {
64
+ return args.reduce((a, b) => a + b, 0) / args.length;
65
+ }
66
+ /**
67
+ * Get the ceiling of the provided number.
68
+ *
69
+ * @param args The number to get the ceiling of
70
+ */
71
+ funcCeil(args) {
72
+ return Math.ceil(args);
73
+ }
74
+ /**
75
+ * Determine if the given value is contained in the provided array or string.
76
+ *
77
+ * @param haystack The array or string to check
78
+ * @param needle The value to check for
79
+ */
80
+ funcContains(haystack, needle) {
81
+ return haystack.includes(needle);
82
+ }
83
+ /**
84
+ * Determines if the provided string ends with the provided suffix.
85
+ *
86
+ * @param str The string to check
87
+ * @param suffix The suffix to check for
88
+ */
89
+ funcEndsWith(str, suffix) {
90
+ return str.endsWith(suffix);
91
+ }
92
+ /**
93
+ * Get the floor of the provided number.
94
+ *
95
+ * @param args The number to get the floor of
96
+ */
97
+ funcFloor(args) {
98
+ return Math.floor(args);
99
+ }
100
+ /**
101
+ * Join the provided array into a single string.
102
+ *
103
+ * @param separator The separator to use
104
+ * @param items The array of itmes to join
105
+ */
106
+ funcJoin(separator, items) {
107
+ return items.join(separator);
108
+ }
109
+ /**
110
+ * Get the keys of the provided object.
111
+ *
112
+ * @param arg The object to get the keys of
113
+ */
114
+ funcKeys(arg) {
115
+ return Object.keys(arg);
116
+ }
117
+ /**
118
+ * Get the number of items in the provided item.
119
+ *
120
+ * @param arg The array to get the length of
121
+ */
122
+ funcLength(arg) {
123
+ if ((0, typeutils_1.isRecord)(arg)) {
124
+ return Object.keys(arg).length;
125
+ }
126
+ else {
127
+ return arg.length;
128
+ }
129
+ }
130
+ /**
131
+ * Map the provided function over the provided array.
132
+ *
133
+ * @param expression The expression to map over the array
134
+ * @param args The array to map the expression over
135
+ */
136
+ funcMap(expression, args) {
137
+ return args.map((arg) => {
138
+ return expression.visit(arg) || null;
139
+ });
140
+ }
141
+ /**
142
+ * Get the maximum value in the provided array.
143
+ *
144
+ * @param arg The array to get the maximum value of
145
+ */
146
+ funcMax(arg) {
147
+ if (arg.length === 0) {
148
+ return null;
149
+ // The signature decorator already enforces that all elements are of the same type
150
+ }
151
+ else if ((0, typeutils_1.isNumber)(arg[0])) {
152
+ return Math.max(...arg);
153
+ }
154
+ else {
155
+ // local compare function to handle string comparison
156
+ return arg.reduce((a, b) => (a > b ? a : b));
157
+ }
158
+ }
159
+ /**
160
+ * Get the item in the provided array that has the maximum value when the provided expression is evaluated.
161
+ *
162
+ * @param args The array of items to get the maximum value of
163
+ * @param expression The expression to evaluate for each item in the array
164
+ */
165
+ funcMaxBy(args, expression) {
166
+ if (args.length === 0) {
167
+ return null;
168
+ }
169
+ const visitedArgs = args.map((arg) => ({
170
+ arg,
171
+ visited: expression.visit(arg),
172
+ }));
173
+ const max = visitedArgs.reduce((max, current) => {
174
+ const type = (0, typeutils_1.getType)(current.visited);
175
+ if (type !== 'string' && type !== 'number') {
176
+ throw new errors_js_1.JMESPathTypeError({
177
+ currentValue: current.visited,
178
+ expectedTypes: ['string'],
179
+ actualType: type,
180
+ });
181
+ }
182
+ if (max.visited === current.visited) {
183
+ return max;
184
+ }
185
+ else {
186
+ // We can safely cast visited to number | string here because we've already
187
+ // checked the type at runtime above and we know that it's either a number or a string
188
+ return max.visited >
189
+ current.visited
190
+ ? max
191
+ : current;
192
+ }
193
+ }, visitedArgs[0]);
194
+ return max.arg;
195
+ }
196
+ /**
197
+ * Merge the provided objects into a single object.
198
+ *
199
+ * Note that this is a shallow merge and will not merge nested objects.
200
+ *
201
+ * @param args The objects to merge
202
+ */
203
+ funcMerge(...args) {
204
+ return args.reduce((a, b) => ({ ...a, ...b }), {});
205
+ }
206
+ /**
207
+ * Get the minimum value in the provided array.
208
+ *
209
+ * @param arg The array to get the minimum value of
210
+ */
211
+ funcMin(arg) {
212
+ if (arg.length === 0) {
213
+ return null;
214
+ // The signature decorator already enforces that all elements are of the same type
215
+ }
216
+ else if ((0, typeutils_1.isNumber)(arg[0])) {
217
+ return Math.min(...arg);
218
+ }
219
+ else {
220
+ return arg.reduce((a, b) => (a < b ? a : b));
221
+ }
222
+ }
223
+ /**
224
+ * Get the item in the provided array that has the minimum value when the provided expression is evaluated.
225
+ *
226
+ * @param args The array of items to get the minimum value of
227
+ * @param expression The expression to evaluate for each item in the array
228
+ */
229
+ funcMinBy(args, expression) {
230
+ if (args.length === 0) {
231
+ return null;
232
+ }
233
+ const visitedArgs = args.map((arg) => ({
234
+ arg,
235
+ visited: expression.visit(arg),
236
+ }));
237
+ const min = visitedArgs.reduce((min, current) => {
238
+ const type = (0, typeutils_1.getType)(current.visited);
239
+ if (type !== 'string' && type !== 'number') {
240
+ throw new errors_js_1.JMESPathTypeError({
241
+ currentValue: current.visited,
242
+ expectedTypes: ['string'],
243
+ actualType: type,
244
+ });
245
+ }
246
+ if (min.visited === current.visited) {
247
+ return min;
248
+ }
249
+ else {
250
+ // We can safely cast visited to number | string here because we've already
251
+ // checked the type at runtime above and we know that it's either a number or a string
252
+ return min.visited <
253
+ current.visited
254
+ ? min
255
+ : current;
256
+ }
257
+ }, visitedArgs[0]);
258
+ return min.arg;
259
+ }
260
+ /**
261
+ * Get the first argument that does not evaluate to null.
262
+ * If all arguments evaluate to null, then null is returned.
263
+ *
264
+ * @param args The keys of the items to check
265
+ */
266
+ funcNotNull(...args) {
267
+ return args.find((arg) => !Object.is(arg, null)) || null;
268
+ }
269
+ /**
270
+ * Reverses the provided string or array.
271
+ *
272
+ * @param arg The string or array to reverse
273
+ */
274
+ funcReverse(arg) {
275
+ return Array.isArray(arg)
276
+ ? arg.reverse()
277
+ : arg.split('').reverse().join('');
278
+ }
279
+ /**
280
+ * Sort the provided array.
281
+ *
282
+ * @param arg The array to sort
283
+ */
284
+ funcSort(arg) {
285
+ return arg.sort((a, b) => {
286
+ if (typeof a === 'string') {
287
+ // We can safely cast a and b to string here because the signature decorator
288
+ // already enforces that all elements are of the same type
289
+ return a.localeCompare(b);
290
+ }
291
+ // We can safely cast a and b to number here because the signature decorator
292
+ // already enforces that all elements are of the same type, so if they're not strings
293
+ // then they must be numbers
294
+ return a - b;
295
+ });
296
+ }
297
+ /**
298
+ * Sort the provided array by the provided expression.
299
+ *
300
+ * @param args The array to sort
301
+ * @param expression The expression to sort by
302
+ */
303
+ funcSortBy(args, expression) {
304
+ return args
305
+ .map((value, index) => {
306
+ const visited = expression.visit(value);
307
+ const type = (0, typeutils_1.getType)(visited);
308
+ if (type !== 'string' && type !== 'number') {
309
+ throw new errors_js_1.JMESPathTypeError({
310
+ currentValue: visited,
311
+ expectedTypes: ['string'],
312
+ actualType: (0, typeutils_1.getType)(visited),
313
+ });
314
+ }
315
+ return {
316
+ value,
317
+ index,
318
+ visited,
319
+ };
320
+ })
321
+ .sort((a, b) => {
322
+ if (a.visited === b.visited) {
323
+ return a.index - b.index; // Make the sort stable
324
+ }
325
+ else {
326
+ // We can safely cast visited to number | string here because we've already
327
+ // checked the type at runtime above and we know that it's either a number or a string
328
+ return a.visited > b.visited
329
+ ? 1
330
+ : -1;
331
+ }
332
+ })
333
+ .map(({ value }) => value); // Extract the original values
334
+ }
335
+ /**
336
+ * Determines if the provided string starts with the provided prefix.
337
+ *
338
+ * @param str The string to check
339
+ * @param prefix The prefix to check for
340
+ */
341
+ funcStartsWith(str, prefix) {
342
+ return str.startsWith(prefix);
343
+ }
344
+ /**
345
+ * Sum the provided numbers.
346
+ *
347
+ * @param args The numbers to sum
348
+ */
349
+ funcSum(args) {
350
+ return args.reduce((a, b) => a + b, 0);
351
+ }
352
+ /**
353
+ * Convert the provided value to an array.
354
+ *
355
+ * If the provided value is an array, then it is returned.
356
+ * Otherwise, the value is wrapped in an array and returned.
357
+ *
358
+ * @param arg The items to convert to an array
359
+ */
360
+ funcToArray(arg) {
361
+ return Array.isArray(arg) ? arg : [arg];
362
+ }
363
+ /**
364
+ * Convert the provided value to a number.
365
+ *
366
+ * If the provided value is a number, then it is returned.
367
+ * Otherwise, the value is converted to a number and returned.
368
+ *
369
+ * If the value cannot be converted to a number, then null is returned.
370
+ *
371
+ * @param arg The value to convert to a number
372
+ */
373
+ funcToNumber(arg) {
374
+ if (typeof arg === 'number') {
375
+ return arg;
376
+ }
377
+ else if (typeof arg === 'string') {
378
+ const num = Number(arg);
379
+ return Number.isNaN(num) ? null : num;
380
+ }
381
+ else {
382
+ return null;
383
+ }
384
+ }
385
+ /**
386
+ * Convert the provided value to a string.
387
+ *
388
+ * If the provided value is a string, then it is returned.
389
+ * Otherwise, the value is converted to a string and returned.
390
+ *
391
+ * @param arg The value to convert to a string
392
+ */
393
+ funcToString(arg) {
394
+ return typeof arg === 'string' ? arg : JSON.stringify(arg);
395
+ }
396
+ /**
397
+ * Get the type of the provided value.
398
+ *
399
+ * @param arg The value to check the type of
400
+ */
401
+ funcType(arg) {
402
+ return (0, typeutils_1.getType)(arg);
403
+ }
404
+ /**
405
+ * Get the values of the provided object.
406
+ *
407
+ * @param arg The object to get the values of
408
+ */
409
+ funcValues(arg) {
410
+ return Object.values(arg);
411
+ }
412
+ /**
413
+ * Lazily introspects the methods of the class instance and all child classes
414
+ * to get the names of the methods that correspond to JMESPath functions.
415
+ *
416
+ * This method is used to get the names of the custom functions that are available
417
+ * in the class instance and all child classes. The names of the functions are used
418
+ * to create the custom function map that is passed to the JMESPath search function.
419
+ *
420
+ * The method traverses the inheritance chain going from the leaf class to the root class
421
+ * and stops when it reaches the `Functions` class, which is the root class.
422
+ *
423
+ * In doing so, it collects the names of the methods that start with `func` and adds them
424
+ * to the `methods` set. Finally, when the recursion collects back to the current instance,
425
+ * it adds the collected methods to the `this.methods` set so that they can be accessed later.
426
+ *
427
+ * @param scope The scope of the class instance to introspect
428
+ */
429
+ introspectMethods(scope) {
430
+ const prototype = Object.getPrototypeOf(this);
431
+ const methods = new Set();
432
+ if (this instanceof Functions) {
433
+ for (const method of prototype.introspectMethods(scope)) {
434
+ methods.add(method);
435
+ }
436
+ }
437
+ else {
438
+ return methods;
439
+ }
440
+ // This block is executed for every class in the inheritance chain
441
+ for (const method of Object.getOwnPropertyNames(Object.getPrototypeOf(this))) {
442
+ method !== 'constructor' &&
443
+ method.startsWith('func') &&
444
+ methods.add(method);
445
+ }
446
+ // This block will be executed only if the scope is the outermost class
447
+ if (this.methods) {
448
+ for (const method of methods) {
449
+ this.methods.add(method);
450
+ }
451
+ }
452
+ return methods;
453
+ }
454
+ /**
455
+ * Decorator to enforce the signature of a function at runtime.
456
+ *
457
+ * The signature decorator enforces the arity and types of the arguments
458
+ * passed to a function at runtime. If the arguments do not match the
459
+ * expected arity or types errors are thrown.
460
+ *
461
+ * @example
462
+ * ```typescript
463
+ * import { PowertoolsFunctions } from '@aws-lambda-powertools/jmespath/functions';
464
+ *
465
+ * class MyFunctions extends Functions {
466
+ * ⁣@Functions.signature({
467
+ * argumentsSpecs: [['number'], ['number']],
468
+ * variadic: true,
469
+ * })
470
+ * public funcMyMethod(args: Array<number>): unknown {
471
+ * // ...
472
+ * }
473
+ * }
474
+ * ```
475
+ *
476
+ * @param options The options for the signature decorator
477
+ */
478
+ static signature(options) {
479
+ return (_target, _propertyKey, descriptor) => {
480
+ const originalMethod = descriptor.value;
481
+ // Use a function() {} instead of an () => {} arrow function so that we can
482
+ // access `myClass` as `this` in a decorated `myClass.myMethod()`.
483
+ descriptor.value = function (args) {
484
+ const { variadic, argumentsSpecs } = options;
485
+ (0, utils_js_1.arityCheck)(args, argumentsSpecs, variadic);
486
+ (0, utils_js_1.typeCheck)(args, argumentsSpecs);
487
+ return originalMethod.apply(this, args);
488
+ };
489
+ return descriptor;
490
+ };
491
+ }
492
+ }
493
+ exports.Functions = Functions;
494
+ __decorate([
495
+ Functions.signature({ argumentsSpecs: [['number']] })
496
+ ], Functions.prototype, "funcAbs", null);
497
+ __decorate([
498
+ Functions.signature({
499
+ argumentsSpecs: [['array-number']],
500
+ })
501
+ ], Functions.prototype, "funcAvg", null);
502
+ __decorate([
503
+ Functions.signature({ argumentsSpecs: [['number']] })
504
+ ], Functions.prototype, "funcCeil", null);
505
+ __decorate([
506
+ Functions.signature({
507
+ argumentsSpecs: [['array', 'string'], ['any']],
508
+ })
509
+ ], Functions.prototype, "funcContains", null);
510
+ __decorate([
511
+ Functions.signature({
512
+ argumentsSpecs: [['string'], ['string']],
513
+ })
514
+ ], Functions.prototype, "funcEndsWith", null);
515
+ __decorate([
516
+ Functions.signature({ argumentsSpecs: [['number']] })
517
+ ], Functions.prototype, "funcFloor", null);
518
+ __decorate([
519
+ Functions.signature({
520
+ argumentsSpecs: [['string'], ['array-string']],
521
+ })
522
+ ], Functions.prototype, "funcJoin", null);
523
+ __decorate([
524
+ Functions.signature({
525
+ argumentsSpecs: [['object']],
526
+ })
527
+ ], Functions.prototype, "funcKeys", null);
528
+ __decorate([
529
+ Functions.signature({
530
+ argumentsSpecs: [['array', 'string', 'object']],
531
+ })
532
+ ], Functions.prototype, "funcLength", null);
533
+ __decorate([
534
+ Functions.signature({
535
+ argumentsSpecs: [['any'], ['array']],
536
+ })
537
+ ], Functions.prototype, "funcMap", null);
538
+ __decorate([
539
+ Functions.signature({
540
+ argumentsSpecs: [['array-number', 'array-string']],
541
+ })
542
+ ], Functions.prototype, "funcMax", null);
543
+ __decorate([
544
+ Functions.signature({
545
+ argumentsSpecs: [['array'], ['expression']],
546
+ })
547
+ ], Functions.prototype, "funcMaxBy", null);
548
+ __decorate([
549
+ Functions.signature({
550
+ argumentsSpecs: [['object']],
551
+ variadic: true,
552
+ })
553
+ ], Functions.prototype, "funcMerge", null);
554
+ __decorate([
555
+ Functions.signature({
556
+ argumentsSpecs: [['array-number', 'array-string']],
557
+ })
558
+ ], Functions.prototype, "funcMin", null);
559
+ __decorate([
560
+ Functions.signature({
561
+ argumentsSpecs: [['array'], ['expression']],
562
+ })
563
+ ], Functions.prototype, "funcMinBy", null);
564
+ __decorate([
565
+ Functions.signature({
566
+ argumentsSpecs: [[]],
567
+ variadic: true,
568
+ })
569
+ ], Functions.prototype, "funcNotNull", null);
570
+ __decorate([
571
+ Functions.signature({
572
+ argumentsSpecs: [['string', 'array']],
573
+ })
574
+ ], Functions.prototype, "funcReverse", null);
575
+ __decorate([
576
+ Functions.signature({
577
+ argumentsSpecs: [['array-number', 'array-string']],
578
+ })
579
+ ], Functions.prototype, "funcSort", null);
580
+ __decorate([
581
+ Functions.signature({
582
+ argumentsSpecs: [['array'], ['expression']],
583
+ })
584
+ ], Functions.prototype, "funcSortBy", null);
585
+ __decorate([
586
+ Functions.signature({
587
+ argumentsSpecs: [['string'], ['string']],
588
+ })
589
+ ], Functions.prototype, "funcStartsWith", null);
590
+ __decorate([
591
+ Functions.signature({
592
+ argumentsSpecs: [['array-number']],
593
+ })
594
+ ], Functions.prototype, "funcSum", null);
595
+ __decorate([
596
+ Functions.signature({
597
+ argumentsSpecs: [['any']],
598
+ })
599
+ ], Functions.prototype, "funcToArray", null);
600
+ __decorate([
601
+ Functions.signature({
602
+ argumentsSpecs: [['any']],
603
+ })
604
+ ], Functions.prototype, "funcToNumber", null);
605
+ __decorate([
606
+ Functions.signature({
607
+ argumentsSpecs: [['any']],
608
+ })
609
+ ], Functions.prototype, "funcToString", null);
610
+ __decorate([
611
+ Functions.signature({
612
+ argumentsSpecs: [['any']],
613
+ })
614
+ ], Functions.prototype, "funcType", null);
615
+ __decorate([
616
+ Functions.signature({
617
+ argumentsSpecs: [['object']],
618
+ })
619
+ ], Functions.prototype, "funcValues", null);
@@ -0,0 +1,19 @@
1
+ import type { Token } from './types.js';
2
+ /**
3
+ * A lexer for JMESPath expressions.
4
+ *
5
+ * This lexer tokenizes a JMESPath expression into a sequence of tokens.
6
+ */
7
+ declare class Lexer {
8
+ #private;
9
+ /**
10
+ * Tokenize a JMESPath expression.
11
+ *
12
+ * This method is a generator that yields tokens for the given expression.
13
+ *
14
+ * @param expression The JMESPath expression to tokenize.
15
+ */
16
+ tokenize(expression: string): Generator<Token>;
17
+ }
18
+ export { Lexer };
19
+ //# sourceMappingURL=Lexer.d.ts.map
@@ -0,0 +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;CAgVvD;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}