donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
30 lines • 1.26 kB
TypeScript
/**
* A minimal, safe JSONPath evaluator that replaces the `jsonpath` npm package.
*
* The `jsonpath` library (v1.2.1) has CVE GHSA-87r5-mp6g-5w5j due to its use
* of `eval()` for script expressions. This implementation covers the subset of
* JSONPath used by this project with NO dynamic code execution.
*
* Supported features:
* - Property access: $.user.name
* - Array indexing (positive & negative): $.calls[0], $.calls[-1]
* - Slice notation: $.calls[-2:], $.calls[1:], $.calls[0:2]
* - Filter expressions: $.books[?(@.price < 10)]
* - Logical AND in filters: [?(@.a < 5 && @.b == "x")]
* - Property existence filters: [?(@.isbn)]
* - Filter + index: $.books[?(@.price < 10)][0]
* - Recursive descent: $..author
* - Wildcards: $[*], $..books[*].title
*/
/**
* Evaluate a JSONPath expression against a data object.
*
* Drop-in replacement for `jsonpath.query()` covering the subset of JSONPath
* used by this project. Uses no `eval()` or dynamic code execution.
*
* @param data - The data to query
* @param expression - A JSONPath expression (must start with $)
* @returns An array of matching values
*/
export declare function queryJsonPath(data: unknown, expression: string): unknown[];
//# sourceMappingURL=JsonPath.d.ts.map