@aws-lambda-powertools/jmespath 0.0.0-alpha.0 → 2.0.4

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