@aws-lambda-powertools/jmespath 2.0.4 → 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.
@@ -32,6 +32,9 @@ import type { FunctionSignatureDecorator, FunctionSignatureOptions } from './typ
32
32
  * ```
33
33
  */
34
34
  declare class Functions {
35
+ /**
36
+ * A set of all the custom functions available in this and all child classes.
37
+ */
35
38
  methods: Set<string>;
36
39
  /**
37
40
  * Get the absolute value of the provided number.
@@ -211,6 +214,23 @@ declare class Functions {
211
214
  * @param arg The object to get the values of
212
215
  */
213
216
  funcValues(arg: JSONObject): JSONValue[];
217
+ /**
218
+ * Lazily introspects the methods of the class instance and all child classes
219
+ * to get the names of the methods that correspond to JMESPath functions.
220
+ *
221
+ * This method is used to get the names of the custom functions that are available
222
+ * in the class instance and all child classes. The names of the functions are used
223
+ * to create the custom function map that is passed to the JMESPath search function.
224
+ *
225
+ * The method traverses the inheritance chain going from the leaf class to the root class
226
+ * and stops when it reaches the `Functions` class, which is the root class.
227
+ *
228
+ * In doing so, it collects the names of the methods that start with `func` and adds them
229
+ * to the `methods` set. Finally, when the recursion collects back to the current instance,
230
+ * it adds the collected methods to the `this.methods` set so that they can be accessed later.
231
+ *
232
+ * @param scope The scope of the class instance to introspect
233
+ */
214
234
  introspectMethods(scope?: Functions): Set<string>;
215
235
  /**
216
236
  * Decorator to enforce the signature of a function at runtime.
@@ -1 +1 @@
1
- {"version":3,"file":"Functions.d.ts","sourceRoot":"","sources":["../../src/Functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACV,MAAM,sCAAsC,CAAC;AAM9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EAEzB,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,cAAM,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M,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;IAenE;;;;;OAKG;IAII,UAAU,CACf,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,EACtB,UAAU,EAAE,UAAU,GACrB,KAAK,CAAC,OAAO,CAAC;IAiCjB;;;;;OAKG;IAII,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAI3D;;;;OAIG;IAII,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM;IAI3C;;;;;;;OAOG;IAII,WAAW,CAChB,GAAG,EAAE,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,GAChC,KAAK,CAAC,SAAS,CAAC,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"}
@@ -42,6 +42,9 @@ const utils_js_1 = require("./utils.js");
42
42
  */
43
43
  class Functions {
44
44
  constructor() {
45
+ /**
46
+ * A set of all the custom functions available in this and all child classes.
47
+ */
45
48
  this.methods = new Set();
46
49
  }
47
50
  /**
@@ -406,15 +409,34 @@ class Functions {
406
409
  funcValues(arg) {
407
410
  return Object.values(arg);
408
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
+ */
409
429
  introspectMethods(scope) {
410
430
  const prototype = Object.getPrototypeOf(this);
411
- const ownName = prototype.constructor.name;
412
431
  const methods = new Set();
413
- if (ownName !== 'Functions') {
432
+ if (this instanceof Functions) {
414
433
  for (const method of prototype.introspectMethods(scope)) {
415
434
  methods.add(method);
416
435
  }
417
436
  }
437
+ else {
438
+ return methods;
439
+ }
418
440
  // This block is executed for every class in the inheritance chain
419
441
  for (const method of Object.getOwnPropertyNames(Object.getPrototypeOf(this))) {
420
442
  method !== 'constructor' &&
@@ -1,4 +1,4 @@
1
- import type { Node, ParsingOptions, JSONObject } from './types.js';
1
+ import type { Node, JMESPathParsingOptions, JSONObject } from './types.js';
2
2
  declare class ParsedResult {
3
3
  expression: string;
4
4
  parsed: Node;
@@ -9,7 +9,7 @@ declare class ParsedResult {
9
9
  * @param value The JSON value to search
10
10
  * @param options The parsing options to use
11
11
  */
12
- search(value: JSONObject, options?: ParsingOptions): unknown;
12
+ search(value: JSONObject, options?: JMESPathParsingOptions): unknown;
13
13
  }
14
14
  export { ParsedResult };
15
15
  //# sourceMappingURL=ParsedResult.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ParsedResult.d.ts","sourceRoot":"","sources":["../../src/ParsedResult.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEnE,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,cAAc,GAAG,OAAO;CAiBpE;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"ParsedResult.d.ts","sourceRoot":"","sources":["../../src/ParsedResult.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,sBAAsB,EAAE,UAAU,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"}
@@ -1,4 +1,4 @@
1
- import type { Node, TreeInterpreterOptions, JSONObject } from './types.js';
1
+ import type { Node, JMESPathParsingOptions, JSONObject } from './types.js';
2
2
  /**
3
3
  *
4
4
  * A tree interpreter for JMESPath ASTs.
@@ -13,7 +13,7 @@ declare class TreeInterpreter {
13
13
  /**
14
14
  * @param options The options to use for the interpreter.
15
15
  */
16
- constructor(options?: TreeInterpreterOptions);
16
+ constructor(options?: JMESPathParsingOptions);
17
17
  /**
18
18
  * Visit a node in the AST.
19
19
  *
@@ -1,4 +1,4 @@
1
- import type { ParsingOptions, JSONObject } from './types.js';
1
+ import type { JMESPathParsingOptions, JSONObject } from './types.js';
2
2
  /**
3
3
  * Searches and extracts data using JMESPath
4
4
  *
@@ -51,7 +51,7 @@ import type { ParsingOptions, JSONObject } from './types.js';
51
51
  * @param envelope The JMESPath expression to use
52
52
  * @param options The parsing options to use
53
53
  */
54
- declare const extractDataFromEnvelope: <T>(data: JSONObject, envelope: string, options?: ParsingOptions) => T;
54
+ declare const extractDataFromEnvelope: <T>(data: JSONObject, envelope: string, options?: JMESPathParsingOptions) => T;
55
55
  declare const API_GATEWAY_REST = "powertools_json(body)";
56
56
  declare const API_GATEWAY_HTTP = "powertools_json(body)";
57
57
  declare const SQS = "Records[*].powertools_json(body)";
@@ -1 +1 @@
1
- {"version":3,"file":"envelopes.d.ts","sourceRoot":"","sources":["../../src/envelopes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,QAAA,MAAM,uBAAuB,YACrB,UAAU,YACN,MAAM,YACN,cAAc,KACvB,CAMF,CAAC;AAEF,QAAA,MAAM,gBAAgB,0BAA0B,CAAC;AACjD,QAAA,MAAM,gBAAgB,0BAA0B,CAAC;AACjD,QAAA,MAAM,GAAG,qCAAqC,CAAC;AAC/C,QAAA,MAAM,GAAG,gDAAgD,CAAC;AAC1D,QAAA,MAAM,WAAW,WAAW,CAAC;AAC7B,QAAA,MAAM,2BAA2B,WAAW,CAAC;AAC7C,QAAA,MAAM,mBAAmB,gEACsC,CAAC;AAChE,QAAA,MAAM,eAAe,2EACqD,CAAC;AAC3E,QAAA,MAAM,UAAU,yEACwD,CAAC;AACzE,QAAA,MAAM,MAAM,gDAAgD,CAAC;AAC7D,QAAA,MAAM,uBAAuB,4FAC8D,CAAC;AAC5F,QAAA,MAAM,mBAAmB,mEACyC,CAAC;AACnE,QAAA,MAAM,kBAAkB,4CAA4C,CAAC;AAErE,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,GAAG,EACH,GAAG,EACH,WAAW,EACX,2BAA2B,EAC3B,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,MAAM,EACN,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GACnB,CAAC"}
1
+ {"version":3,"file":"envelopes.d.ts","sourceRoot":"","sources":["../../src/envelopes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,QAAA,MAAM,uBAAuB,YACrB,UAAU,YACN,MAAM,YACN,sBAAsB,KAC/B,CAMF,CAAC;AAEF,QAAA,MAAM,gBAAgB,0BAA0B,CAAC;AACjD,QAAA,MAAM,gBAAgB,0BAA0B,CAAC;AACjD,QAAA,MAAM,GAAG,qCAAqC,CAAC;AAC/C,QAAA,MAAM,GAAG,gDAAgD,CAAC;AAC1D,QAAA,MAAM,WAAW,WAAW,CAAC;AAC7B,QAAA,MAAM,2BAA2B,WAAW,CAAC;AAC7C,QAAA,MAAM,mBAAmB,gEACsC,CAAC;AAChE,QAAA,MAAM,eAAe,2EACqD,CAAC;AAC3E,QAAA,MAAM,UAAU,yEACwD,CAAC;AACzE,QAAA,MAAM,MAAM,gDAAgD,CAAC;AAC7D,QAAA,MAAM,uBAAuB,4FAC8D,CAAC;AAC5F,QAAA,MAAM,mBAAmB,mEACyC,CAAC;AACnE,QAAA,MAAM,kBAAkB,4CAA4C,CAAC;AAErE,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,GAAG,EACH,GAAG,EACH,WAAW,EACX,2BAA2B,EAC3B,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,MAAM,EACN,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GACnB,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ParsingOptions, JSONObject } from './types.js';
1
+ import type { JMESPathParsingOptions, JSONObject } from './types.js';
2
2
  /**
3
3
  * Search for data in a JSON object using a JMESPath expression.
4
4
  *
@@ -45,6 +45,6 @@ import type { ParsingOptions, JSONObject } from './types.js';
45
45
  * @param data The JSON object to search
46
46
  * @param options The parsing options to use
47
47
  */
48
- declare const search: (expression: string, data: JSONObject, options?: ParsingOptions) => unknown;
48
+ declare const search: (expression: string, data: JSONObject, options?: JMESPathParsingOptions) => unknown;
49
49
  export { search };
50
50
  //# sourceMappingURL=search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,QAAA,MAAM,MAAM,eACE,MAAM,QACZ,UAAU,YACN,cAAc,KACvB,OAEF,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,QAAA,MAAM,MAAM,eACE,MAAM,QACZ,UAAU,YACN,sBAAsB,KAC/B,OAEF,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -18,18 +18,6 @@ type Node = {
18
18
  children: Node[];
19
19
  value?: JSONValue;
20
20
  };
21
- /**
22
- * Options for the tree interpreter.
23
- */
24
- type TreeInterpreterOptions = {
25
- /**
26
- * The custom functions to use.
27
- *
28
- * By default, the interpreter uses the standard JMESPath functions
29
- * available in the [JMESPath specification](https://jmespath.org/specification.html).
30
- */
31
- customFunctions?: Functions;
32
- };
33
21
  /**
34
22
  * Options for parsing.
35
23
  *
@@ -50,7 +38,15 @@ type TreeInterpreterOptions = {
50
38
  * console.log(result); // { a: 1 }
51
39
  * ```
52
40
  */
53
- type ParsingOptions = TreeInterpreterOptions;
41
+ type JMESPathParsingOptions = {
42
+ /**
43
+ * The custom functions to use.
44
+ *
45
+ * By default, the interpreter uses the standard JMESPath functions
46
+ * available in the [JMESPath specification](https://jmespath.org/specification.html).
47
+ */
48
+ customFunctions?: Functions;
49
+ };
54
50
  /**
55
51
  * Decorator for function signatures.
56
52
  */
@@ -84,5 +80,5 @@ type FunctionSignatureOptions = {
84
80
  * A JSON parseable object.
85
81
  */
86
82
  type JSONObject = JSONArray | JSONValue | object;
87
- export type { FunctionSignatureDecorator, FunctionSignatureOptions, Node, ParsingOptions, Token, TreeInterpreterOptions, JSONObject, };
83
+ export type { FunctionSignatureDecorator, FunctionSignatureOptions, Node, JMESPathParsingOptions, Token, JSONObject, };
88
84
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACV,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;GAEG;AACH,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,OAAO,aAAa,CAAC;IACjC,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,KAAK,sBAAsB,GAAG;IAC5B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;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CAAC,EAAE,SAAS,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,KAAK,0BAA0B,GAAG,CAChC,MAAM,EAAE,SAAS,GAAG,OAAO,SAAS,EACpC,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,UAAU,EAAE,kBAAkB,KAC3B,IAAI,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,KAAK,wBAAwB,GAAG;IAC9B,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,KAAK,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAEjD,YAAY,EACV,0BAA0B,EAC1B,wBAAwB,EACxB,IAAI,EACJ,sBAAsB,EACtB,KAAK,EACL,UAAU,GACX,CAAC"}
@@ -32,6 +32,9 @@ import type { FunctionSignatureDecorator, FunctionSignatureOptions } from './typ
32
32
  * ```
33
33
  */
34
34
  declare class Functions {
35
+ /**
36
+ * A set of all the custom functions available in this and all child classes.
37
+ */
35
38
  methods: Set<string>;
36
39
  /**
37
40
  * Get the absolute value of the provided number.
@@ -211,6 +214,23 @@ declare class Functions {
211
214
  * @param arg The object to get the values of
212
215
  */
213
216
  funcValues(arg: JSONObject): JSONValue[];
217
+ /**
218
+ * Lazily introspects the methods of the class instance and all child classes
219
+ * to get the names of the methods that correspond to JMESPath functions.
220
+ *
221
+ * This method is used to get the names of the custom functions that are available
222
+ * in the class instance and all child classes. The names of the functions are used
223
+ * to create the custom function map that is passed to the JMESPath search function.
224
+ *
225
+ * The method traverses the inheritance chain going from the leaf class to the root class
226
+ * and stops when it reaches the `Functions` class, which is the root class.
227
+ *
228
+ * In doing so, it collects the names of the methods that start with `func` and adds them
229
+ * to the `methods` set. Finally, when the recursion collects back to the current instance,
230
+ * it adds the collected methods to the `this.methods` set so that they can be accessed later.
231
+ *
232
+ * @param scope The scope of the class instance to introspect
233
+ */
214
234
  introspectMethods(scope?: Functions): Set<string>;
215
235
  /**
216
236
  * Decorator to enforce the signature of a function at runtime.
@@ -1 +1 @@
1
- {"version":3,"file":"Functions.d.ts","sourceRoot":"","sources":["../../src/Functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACV,MAAM,sCAAsC,CAAC;AAM9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EAEzB,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,cAAM,SAAS;IACN,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;IACxC;;;;OAIG;IAEI,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIpC;;;;OAIG;IAII,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM;IAI3C;;;;OAIG;IAEI,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIrC;;;;;OAKG;IAII,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAI9D;;;;;OAKG;IAII,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAIzD;;;;OAIG;IAEI,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAItC;;;;;OAKG;IAII,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM;IAIhE;;;;OAIG;IAII,QAAQ,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,EAAE;IAI1C;;;;OAIG;IAII,UAAU,CACf,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE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AAK,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"}
@@ -39,6 +39,9 @@ import { arityCheck, typeCheck } from './utils.js';
39
39
  */
40
40
  class Functions {
41
41
  constructor() {
42
+ /**
43
+ * A set of all the custom functions available in this and all child classes.
44
+ */
42
45
  this.methods = new Set();
43
46
  }
44
47
  /**
@@ -403,15 +406,34 @@ class Functions {
403
406
  funcValues(arg) {
404
407
  return Object.values(arg);
405
408
  }
409
+ /**
410
+ * Lazily introspects the methods of the class instance and all child classes
411
+ * to get the names of the methods that correspond to JMESPath functions.
412
+ *
413
+ * This method is used to get the names of the custom functions that are available
414
+ * in the class instance and all child classes. The names of the functions are used
415
+ * to create the custom function map that is passed to the JMESPath search function.
416
+ *
417
+ * The method traverses the inheritance chain going from the leaf class to the root class
418
+ * and stops when it reaches the `Functions` class, which is the root class.
419
+ *
420
+ * In doing so, it collects the names of the methods that start with `func` and adds them
421
+ * to the `methods` set. Finally, when the recursion collects back to the current instance,
422
+ * it adds the collected methods to the `this.methods` set so that they can be accessed later.
423
+ *
424
+ * @param scope The scope of the class instance to introspect
425
+ */
406
426
  introspectMethods(scope) {
407
427
  const prototype = Object.getPrototypeOf(this);
408
- const ownName = prototype.constructor.name;
409
428
  const methods = new Set();
410
- if (ownName !== 'Functions') {
429
+ if (this instanceof Functions) {
411
430
  for (const method of prototype.introspectMethods(scope)) {
412
431
  methods.add(method);
413
432
  }
414
433
  }
434
+ else {
435
+ return methods;
436
+ }
415
437
  // This block is executed for every class in the inheritance chain
416
438
  for (const method of Object.getOwnPropertyNames(Object.getPrototypeOf(this))) {
417
439
  method !== 'constructor' &&
@@ -1,4 +1,4 @@
1
- import type { Node, ParsingOptions, JSONObject } from './types.js';
1
+ import type { Node, JMESPathParsingOptions, JSONObject } from './types.js';
2
2
  declare class ParsedResult {
3
3
  expression: string;
4
4
  parsed: Node;
@@ -9,7 +9,7 @@ declare class ParsedResult {
9
9
  * @param value The JSON value to search
10
10
  * @param options The parsing options to use
11
11
  */
12
- search(value: JSONObject, options?: ParsingOptions): unknown;
12
+ search(value: JSONObject, options?: JMESPathParsingOptions): unknown;
13
13
  }
14
14
  export { ParsedResult };
15
15
  //# sourceMappingURL=ParsedResult.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ParsedResult.d.ts","sourceRoot":"","sources":["../../src/ParsedResult.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEnE,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,cAAc,GAAG,OAAO;CAiBpE;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"ParsedResult.d.ts","sourceRoot":"","sources":["../../src/ParsedResult.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,sBAAsB,EAAE,UAAU,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"}
@@ -1,4 +1,4 @@
1
- import type { Node, TreeInterpreterOptions, JSONObject } from './types.js';
1
+ import type { Node, JMESPathParsingOptions, JSONObject } from './types.js';
2
2
  /**
3
3
  *
4
4
  * A tree interpreter for JMESPath ASTs.
@@ -13,7 +13,7 @@ declare class TreeInterpreter {
13
13
  /**
14
14
  * @param options The options to use for the interpreter.
15
15
  */
16
- constructor(options?: TreeInterpreterOptions);
16
+ constructor(options?: JMESPathParsingOptions);
17
17
  /**
18
18
  * Visit a node in the AST.
19
19
  *
@@ -1,4 +1,4 @@
1
- import type { ParsingOptions, JSONObject } from './types.js';
1
+ import type { JMESPathParsingOptions, JSONObject } from './types.js';
2
2
  /**
3
3
  * Searches and extracts data using JMESPath
4
4
  *
@@ -51,7 +51,7 @@ import type { ParsingOptions, JSONObject } from './types.js';
51
51
  * @param envelope The JMESPath expression to use
52
52
  * @param options The parsing options to use
53
53
  */
54
- declare const extractDataFromEnvelope: <T>(data: JSONObject, envelope: string, options?: ParsingOptions) => T;
54
+ declare const extractDataFromEnvelope: <T>(data: JSONObject, envelope: string, options?: JMESPathParsingOptions) => T;
55
55
  declare const API_GATEWAY_REST = "powertools_json(body)";
56
56
  declare const API_GATEWAY_HTTP = "powertools_json(body)";
57
57
  declare const SQS = "Records[*].powertools_json(body)";
@@ -1 +1 @@
1
- {"version":3,"file":"envelopes.d.ts","sourceRoot":"","sources":["../../src/envelopes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,QAAA,MAAM,uBAAuB,YACrB,UAAU,YACN,MAAM,YACN,cAAc,KACvB,CAMF,CAAC;AAEF,QAAA,MAAM,gBAAgB,0BAA0B,CAAC;AACjD,QAAA,MAAM,gBAAgB,0BAA0B,CAAC;AACjD,QAAA,MAAM,GAAG,qCAAqC,CAAC;AAC/C,QAAA,MAAM,GAAG,gDAAgD,CAAC;AAC1D,QAAA,MAAM,WAAW,WAAW,CAAC;AAC7B,QA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4FAC8D,CAAC;AAC5F,QAAA,MAAM,mBAAmB,mEACyC,CAAC;AACnE,QAAA,MAAM,kBAAkB,4CAA4C,CAAC;AAErE,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,GAAG,EACH,GAAG,EACH,WAAW,EACX,2BAA2B,EAC3B,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,MAAM,EACN,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GACnB,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ParsingOptions, JSONObject } from './types.js';
1
+ import type { JMESPathParsingOptions, JSONObject } from './types.js';
2
2
  /**
3
3
  * Search for data in a JSON object using a JMESPath expression.
4
4
  *
@@ -45,6 +45,6 @@ import type { ParsingOptions, JSONObject } from './types.js';
45
45
  * @param data The JSON object to search
46
46
  * @param options The parsing options to use
47
47
  */
48
- declare const search: (expression: string, data: JSONObject, options?: ParsingOptions) => unknown;
48
+ declare const search: (expression: string, data: JSONObject, options?: JMESPathParsingOptions) => unknown;
49
49
  export { search };
50
50
  //# sourceMappingURL=search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,QAAA,MAAM,MAAM,eACE,MAAM,QACZ,UAAU,YACN,cAAc,KACvB,OAEF,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,QAAA,MAAM,MAAM,eACE,MAAM,QACZ,UAAU,YACN,sBAAsB,KAC/B,OAEF,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -18,18 +18,6 @@ type Node = {
18
18
  children: Node[];
19
19
  value?: JSONValue;
20
20
  };
21
- /**
22
- * Options for the tree interpreter.
23
- */
24
- type TreeInterpreterOptions = {
25
- /**
26
- * The custom functions to use.
27
- *
28
- * By default, the interpreter uses the standard JMESPath functions
29
- * available in the [JMESPath specification](https://jmespath.org/specification.html).
30
- */
31
- customFunctions?: Functions;
32
- };
33
21
  /**
34
22
  * Options for parsing.
35
23
  *
@@ -50,7 +38,15 @@ type TreeInterpreterOptions = {
50
38
  * console.log(result); // { a: 1 }
51
39
  * ```
52
40
  */
53
- type ParsingOptions = TreeInterpreterOptions;
41
+ type JMESPathParsingOptions = {
42
+ /**
43
+ * The custom functions to use.
44
+ *
45
+ * By default, the interpreter uses the standard JMESPath functions
46
+ * available in the [JMESPath specification](https://jmespath.org/specification.html).
47
+ */
48
+ customFunctions?: Functions;
49
+ };
54
50
  /**
55
51
  * Decorator for function signatures.
56
52
  */
@@ -84,5 +80,5 @@ type FunctionSignatureOptions = {
84
80
  * A JSON parseable object.
85
81
  */
86
82
  type JSONObject = JSONArray | JSONValue | object;
87
- export type { FunctionSignatureDecorator, FunctionSignatureOptions, Node, ParsingOptions, Token, TreeInterpreterOptions, JSONObject, };
83
+ export type { FunctionSignatureDecorator, FunctionSignatureOptions, Node, JMESPathParsingOptions, Token, JSONObject, };
88
84
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACV,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;GAEG;AACH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AE,MAAM,gBAAgB,CAAC;AAE/C;;GAEG;AACH,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,OAAO,aAAa,CAAC;IACjC,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,KAAK,sBAAsB,GAAG;IAC5B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,KAAK,0BAA0B,GAAG,CAChC,MAAM,EAAE,SAAS,GAAG,OAAO,SAAS,EACpC,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,UAAU,EAAE,kBAAkB,KAC3B,IAAI,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,KAAK,wBAAwB,GAAG;IAC9B,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,KAAK,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAEjD,YAAY,EACV,0BAA0B,EAC1B,wBAAwB,EACxB,IAAI,EACJ,sBAAsB,EACtB,KAAK,EACL,UAAU,GACX,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-lambda-powertools/jmespath",
3
- "version": "2.0.4",
3
+ "version": "2.1.0",
4
4
  "description": "A type safe and modern jmespath module to parse and extract data from JSON documents using JMESPath",
5
5
  "author": {
6
6
  "name": "Amazon Web Services",
@@ -25,7 +25,7 @@
25
25
  "nodejs"
26
26
  ],
27
27
  "dependencies": {
28
- "@aws-lambda-powertools/commons": "^2.0.4"
28
+ "@aws-lambda-powertools/commons": "^2.1.0"
29
29
  },
30
30
  "main": "./lib/cjs/index.js",
31
31
  "types": "./lib/cjs/index.d.ts",