@ac-kit/format-jsonpath 0.0.0-stage → 0.1.1

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 (52) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/LICENSE +28 -0
  3. package/README.md +169 -2
  4. package/dist/_costs.d.ts +26 -0
  5. package/dist/_costs.d.ts.map +1 -0
  6. package/dist/_costs.js +36 -0
  7. package/dist/_costs.js.map +1 -0
  8. package/dist/_evaluate.d.ts +41 -0
  9. package/dist/_evaluate.d.ts.map +1 -0
  10. package/dist/_evaluate.js +512 -0
  11. package/dist/_evaluate.js.map +1 -0
  12. package/dist/_functions.d.ts +12 -0
  13. package/dist/_functions.d.ts.map +1 -0
  14. package/dist/_functions.js +17 -0
  15. package/dist/_functions.js.map +1 -0
  16. package/dist/_json-equal.d.ts +19 -0
  17. package/dist/_json-equal.d.ts.map +1 -0
  18. package/dist/_json-equal.js +91 -0
  19. package/dist/_json-equal.js.map +1 -0
  20. package/dist/_parse.d.ts +17 -0
  21. package/dist/_parse.d.ts.map +1 -0
  22. package/dist/_parse.js +617 -0
  23. package/dist/_parse.js.map +1 -0
  24. package/dist/ast.d.ts +133 -0
  25. package/dist/ast.d.ts.map +1 -0
  26. package/dist/ast.js +2 -0
  27. package/dist/ast.js.map +1 -0
  28. package/dist/compile-jsonpath.d.ts +108 -0
  29. package/dist/compile-jsonpath.d.ts.map +1 -0
  30. package/dist/compile-jsonpath.js +103 -0
  31. package/dist/compile-jsonpath.js.map +1 -0
  32. package/dist/errors.d.ts +64 -0
  33. package/dist/errors.d.ts.map +1 -0
  34. package/dist/errors.js +34 -0
  35. package/dist/errors.js.map +1 -0
  36. package/dist/index.d.ts +7 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +7 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/limits.d.ts +108 -0
  41. package/dist/limits.d.ts.map +1 -0
  42. package/dist/limits.js +86 -0
  43. package/dist/limits.js.map +1 -0
  44. package/dist/normalized-path.d.ts +67 -0
  45. package/dist/normalized-path.d.ts.map +1 -0
  46. package/dist/normalized-path.js +269 -0
  47. package/dist/normalized-path.js.map +1 -0
  48. package/dist/parse-jsonpath.d.ts +60 -0
  49. package/dist/parse-jsonpath.d.ts.map +1 -0
  50. package/dist/parse-jsonpath.js +66 -0
  51. package/dist/parse-jsonpath.js.map +1 -0
  52. package/package.json +65 -3
package/dist/ast.d.ts ADDED
@@ -0,0 +1,133 @@
1
+ /**
2
+ * A JSONPath query (RFC 9535 §2.1). `$` starts an absolute query, the only kind
3
+ * {@link parseJsonPath} returns at top level; `@` starts a relative one, found
4
+ * only inside a filter.
5
+ */
6
+ export type JsonPathQuery = {
7
+ readonly kind: "query";
8
+ readonly identifier: "$" | "@";
9
+ readonly segments: readonly JsonPathSegment[];
10
+ };
11
+ /**
12
+ * A segment (RFC 9535 §2.5). `child` applies its selectors to each input node's
13
+ * children; `descendant` (`..`) applies them to each input node and to all of
14
+ * its descendants, in pre-order.
15
+ */
16
+ export type JsonPathSegment = {
17
+ readonly kind: "child" | "descendant";
18
+ readonly selectors: readonly [JsonPathSelector, ...JsonPathSelector[]];
19
+ };
20
+ /** A selector (RFC 9535 §2.3). */
21
+ export type JsonPathSelector = JsonPathNameSelector | JsonPathWildcardSelector | JsonPathIndexSelector | JsonPathSliceSelector | JsonPathFilterSelector;
22
+ /** Selects the member of an object with this exact name (`.a`, `['a']`). */
23
+ export type JsonPathNameSelector = {
24
+ readonly kind: "name";
25
+ readonly name: string;
26
+ };
27
+ /** Selects every element of an array or member value of an object (`*`). */
28
+ export type JsonPathWildcardSelector = {
29
+ readonly kind: "wildcard";
30
+ };
31
+ /**
32
+ * Selects one array element; a negative index counts from the end (`[-1]` is
33
+ * the last). A safe integer.
34
+ */
35
+ export type JsonPathIndexSelector = {
36
+ readonly kind: "index";
37
+ readonly index: number;
38
+ };
39
+ /**
40
+ * Selects array elements from `start` (included) to `end` (excluded) every
41
+ * `step` (`[1:5:2]`). `null` is an omitted part, with the RFC 9535 §2.3.4.2
42
+ * default; a step of `0` selects nothing. Safe integers.
43
+ */
44
+ export type JsonPathSliceSelector = {
45
+ readonly kind: "slice";
46
+ readonly start: number | null;
47
+ readonly end: number | null;
48
+ readonly step: number | null;
49
+ };
50
+ /**
51
+ * Selects the children of an array or object for which `expression` holds
52
+ * (`[?@.price < 10]`).
53
+ */
54
+ export type JsonPathFilterSelector = {
55
+ readonly kind: "filter";
56
+ readonly expression: JsonPathLogicalExpression;
57
+ };
58
+ /**
59
+ * A logical expression (RFC 9535 §2.3.5). Parentheses are not kept: the tree's
60
+ * nesting is the grouping.
61
+ */
62
+ export type JsonPathLogicalExpression = JsonPathOrExpression | JsonPathAndExpression | JsonPathNotExpression | JsonPathTestExpression | JsonPathComparisonExpression;
63
+ /** `a || b || …`: true when one operand is. */
64
+ export type JsonPathOrExpression = {
65
+ readonly kind: "or";
66
+ readonly operands: readonly [
67
+ JsonPathLogicalExpression,
68
+ JsonPathLogicalExpression,
69
+ ...JsonPathLogicalExpression[]
70
+ ];
71
+ };
72
+ /** `a && b && …`: true when every operand is. */
73
+ export type JsonPathAndExpression = {
74
+ readonly kind: "and";
75
+ readonly operands: readonly [
76
+ JsonPathLogicalExpression,
77
+ JsonPathLogicalExpression,
78
+ ...JsonPathLogicalExpression[]
79
+ ];
80
+ };
81
+ /** `!a`. */
82
+ export type JsonPathNotExpression = {
83
+ readonly kind: "not";
84
+ readonly operand: JsonPathLogicalExpression;
85
+ };
86
+ /**
87
+ * A test: a query is true when it selects at least one node; a function call
88
+ * returns a logical result (`match`, `search`) or a nodelist tested the same
89
+ * way.
90
+ */
91
+ export type JsonPathTestExpression = {
92
+ readonly kind: "test";
93
+ readonly operand: JsonPathQuery | JsonPathFunctionCall;
94
+ };
95
+ /** A comparison between two values (RFC 9535 §2.3.5.2.2). */
96
+ export type JsonPathComparisonExpression = {
97
+ readonly kind: "comparison";
98
+ readonly operator: JsonPathComparisonOperator;
99
+ readonly left: JsonPathComparable;
100
+ readonly right: JsonPathComparable;
101
+ };
102
+ /** The six comparison operators. */
103
+ export type JsonPathComparisonOperator = "==" | "!=" | "<" | "<=" | ">" | ">=";
104
+ /**
105
+ * One side of a comparison. A query here is singular (see
106
+ * {@link isSingularJsonPath}) and a function call returns a value (`length`,
107
+ * `count`, `value`).
108
+ */
109
+ export type JsonPathComparable = JsonPathLiteral | JsonPathQuery | JsonPathFunctionCall;
110
+ /**
111
+ * A literal. A number is an IEEE 754 double: a literal beyond its range, such
112
+ * as `1e400`, is `Infinity`.
113
+ */
114
+ export type JsonPathLiteral = {
115
+ readonly kind: "literal";
116
+ readonly value: string | number | boolean | null;
117
+ };
118
+ /**
119
+ * A function call (RFC 9535 §2.4): one of `length`, `count`, `match`, `search`
120
+ * and `value`.
121
+ */
122
+ export type JsonPathFunctionCall = {
123
+ readonly kind: "function";
124
+ readonly name: string;
125
+ readonly arguments: readonly JsonPathFunctionArgument[];
126
+ };
127
+ /**
128
+ * A function argument. A bare literal, query or call is kept as such; anything
129
+ * with an operator or parentheses is a logical expression. The parameter's
130
+ * declared type decides how it is read (RFC 9535 §2.4.3).
131
+ */
132
+ export type JsonPathFunctionArgument = JsonPathLiteral | JsonPathQuery | JsonPathFunctionCall | JsonPathLogicalExpression;
133
+ //# sourceMappingURL=ast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,GAAG,GAAG,GAAG,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,YAAY,CAAC;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,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;CACjD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,SAAS,wBAAwB,EAAE,CAAC;CACxD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,GACjC,eAAe,GACf,aAAa,GACb,oBAAoB,GACpB,yBAAyB,CAAC"}
package/dist/ast.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.js","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":""}
@@ -0,0 +1,108 @@
1
+ import { type WorkBudget } from "@ac-kit/core";
2
+ import type { JsonValue } from "type-fest";
3
+ import type { JsonPathQuery } from "./ast.js";
4
+ import type { JsonPathNormalizedPath } from "./normalized-path.js";
5
+ import type { JsonPathOptions } from "./parse-jsonpath.js";
6
+ /** A node of a nodelist: its value and where it is in the document. */
7
+ export type JsonPathNode = {
8
+ readonly value: JsonValue;
9
+ /** Its location; print it with `printNormalizedPath`. */
10
+ readonly path: JsonPathNormalizedPath;
11
+ };
12
+ /** A query compiled once, to evaluate over any number of documents. */
13
+ export type CompiledJsonPath = {
14
+ /** The query text it was compiled from. */
15
+ readonly source: string;
16
+ /** Its syntax tree. */
17
+ readonly query: JsonPathQuery;
18
+ /** Whether it selects at most one node (see `isSingularJsonPath`). */
19
+ readonly singular: boolean;
20
+ /**
21
+ * The values of the nodes the query selects in `document`, in RFC 9535 order:
22
+ * object members in `Object.keys` order (integer-like names first, ascending,
23
+ * then insertion order), descendants in pre-order, and a node selected twice
24
+ * listed twice. Unbound, so it can be passed around without its object.
25
+ *
26
+ * The document is read as plain JSON: arrays are `Array.isArray`, objects any
27
+ * other non-null object, read through own enumerable string keys only, so
28
+ * `$.constructor` selects nothing on `{}`. Anything outside JSON gives
29
+ * unspecified results but stays within the budget and never touches a
30
+ * prototype.
31
+ *
32
+ * Complexity: bounded by the work allowance. Each segment costs the nodes it
33
+ * visits (a descendant segment its input's whole subtree, a filter its
34
+ * expression per child); nested descendants or filters multiply, which the
35
+ * allowance stops. Neither the document's depth nor the query's nesting
36
+ * reaches the native call stack. Each object's member names are listed in one
37
+ * uninterruptible native call, charged as it returns, once per evaluation.
38
+ *
39
+ * @param budget Charged instead of a fresh {@link JsonPathLimits.maxWork}
40
+ * allowance; see {@link JsonPathLimits.maxWork} for what costs a unit.
41
+ * @throws {JsonPathLimitExceededError} Of kind `"work"` when the evaluation
42
+ * outgrows `maxWork` and no `budget` was passed.
43
+ * @throws Whatever `budget.spend` throws, unchanged.
44
+ * @throws {RegexLimitExceededError} If a pattern of `match()`/`search()` read
45
+ * from the document outgrows the regex program size or nesting limits.
46
+ */
47
+ readonly select: (document: JsonValue, budget?: WorkBudget) => JsonValue[];
48
+ /**
49
+ * {@link CompiledJsonPath.select}, with each node's normalized path. Paths are
50
+ * built for every node selected, at one unit per path segment.
51
+ */
52
+ readonly selectNodes: (document: JsonValue, budget?: WorkBudget) => JsonPathNode[];
53
+ };
54
+ /**
55
+ * Parses, checks and compiles a query (RFC 9535) for repeated evaluation.
56
+ *
57
+ * The patterns of `match()` and `search()` calls given as string literals are
58
+ * compiled here, once; a literal that is not an I-Regexp (RFC 9485) makes its
59
+ * call false. Patterns read from the document are compiled once per evaluation,
60
+ * charged to it. See the README for the `^`/`$` deviation.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const titles = compileJsonPath("$.books[?@.price < 10].title");
65
+ * titles.select({ books: [{ title: "A", price: 8 }, { title: "B", price: 12 }] }); // ["A"]
66
+ * ```;
67
+ *
68
+ * @param source The query text.
69
+ * @param options Limits, and a budget charged for the parse (one unit per
70
+ * character) and for compiling literal patterns.
71
+ * @returns Complexity: O(source length), plus each literal pattern's
72
+ * compilation.
73
+ * @throws {JsonPathSyntaxError} If `source` is not a valid query.
74
+ * @throws {JsonPathLimitExceededError} On `queryLength`, `nestingDepth`, or
75
+ * `work` when compiling outgrows `maxWork` without a `budget`.
76
+ * @throws {RegexLimitExceededError} If a literal pattern outgrows the regex
77
+ * limits.
78
+ * @throws {RangeError} If a limit is out of its range.
79
+ */
80
+ export declare function compileJsonPath(source: string, options?: JsonPathOptions): CompiledJsonPath;
81
+ /**
82
+ * Selects from `document` with a query used once: {@link compileJsonPath} then
83
+ * {@link CompiledJsonPath.select}. Compile once instead when reusing a query.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * selectJsonPath({ a: [1, 2, 3] }, "$.a[-1]"); // [3]
88
+ * ```;
89
+ *
90
+ * @param options `budget` is charged for both the compilation and the
91
+ * evaluation.
92
+ * @throws As {@link compileJsonPath} and {@link CompiledJsonPath.select}.
93
+ */
94
+ export declare function selectJsonPath(document: JsonValue, source: string, options?: JsonPathOptions): JsonValue[];
95
+ /**
96
+ * {@link selectJsonPath} with each node's normalized path, as
97
+ * {@link CompiledJsonPath.selectNodes}.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * selectJsonPathNodes({ a: [1, 2] }, "$.a[*]");
102
+ * // [{ value: 1, path: ["a", 0] }, { value: 2, path: ["a", 1] }]
103
+ * ```;
104
+ *
105
+ * @throws As {@link compileJsonPath} and {@link CompiledJsonPath.selectNodes}.
106
+ */
107
+ export declare function selectJsonPathNodes(document: JsonValue, source: string, options?: JsonPathOptions): JsonPathNode[];
108
+ //# sourceMappingURL=compile-jsonpath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-jsonpath.d.ts","sourceRoot":"","sources":["../src/compile-jsonpath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAkB,MAAM,cAAc,CAAC;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAW3C,OAAO,KAAK,EAAE,aAAa,EAA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AY,EAAE,CAKhB"}
@@ -0,0 +1,103 @@
1
+ import { withWorkBudget } from "@ac-kit/core";
2
+ import { tryCompileIRegexp } from "@ac-kit/format-regex";
3
+ import { STEP_COST_ } from "./_costs.js";
4
+ import { evaluate_, inlineSubtreesOf_, literalPatternsOf_, } from "./_evaluate.js";
5
+ import { isSingularQuery_, parseJsonPathBounded_ } from "./_parse.js";
6
+ import { JsonPathLimitExceededError, jsonPathLimits } from "./limits.js";
7
+ function pathOf(node, budget) {
8
+ const path = [];
9
+ for (let at = node; at?.parent != null; at = at.parent) {
10
+ budget.spend(STEP_COST_);
11
+ path.push(at.key);
12
+ }
13
+ return path.reverse();
14
+ }
15
+ /**
16
+ * Parses, checks and compiles a query (RFC 9535) for repeated evaluation.
17
+ *
18
+ * The patterns of `match()` and `search()` calls given as string literals are
19
+ * compiled here, once; a literal that is not an I-Regexp (RFC 9485) makes its
20
+ * call false. Patterns read from the document are compiled once per evaluation,
21
+ * charged to it. See the README for the `^`/`$` deviation.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const titles = compileJsonPath("$.books[?@.price < 10].title");
26
+ * titles.select({ books: [{ title: "A", price: 8 }, { title: "B", price: 12 }] }); // ["A"]
27
+ * ```;
28
+ *
29
+ * @param source The query text.
30
+ * @param options Limits, and a budget charged for the parse (one unit per
31
+ * character) and for compiling literal patterns.
32
+ * @returns Complexity: O(source length), plus each literal pattern's
33
+ * compilation.
34
+ * @throws {JsonPathSyntaxError} If `source` is not a valid query.
35
+ * @throws {JsonPathLimitExceededError} On `queryLength`, `nestingDepth`, or
36
+ * `work` when compiling outgrows `maxWork` without a `budget`.
37
+ * @throws {RegexLimitExceededError} If a literal pattern outgrows the regex
38
+ * limits.
39
+ * @throws {RangeError} If a limit is out of its range.
40
+ */
41
+ export function compileJsonPath(source, options) {
42
+ const limits = jsonPathLimits(options?.limits);
43
+ const onExhausted = (cause) => new JsonPathLimitExceededError("work", limits.maxWork, { cause });
44
+ const compiled = withWorkBudget(options?.budget ?? limits.maxWork, (budget) => {
45
+ budget.spend(Math.min(source.length, limits.maxQueryLength) + 1);
46
+ const parsed = parseJsonPathBounded_(source, limits);
47
+ const patterns = new Map();
48
+ for (const pattern of literalPatternsOf_(parsed)) {
49
+ if (!patterns.has(pattern)) {
50
+ patterns.set(pattern, tryCompileIRegexp(pattern, limits.regex, budget));
51
+ }
52
+ }
53
+ return {
54
+ query: parsed,
55
+ inline: inlineSubtreesOf_(parsed),
56
+ literalPatterns: patterns,
57
+ regexLimits: limits.regex,
58
+ };
59
+ }, onExhausted);
60
+ const { query } = compiled;
61
+ return {
62
+ source,
63
+ query,
64
+ singular: isSingularQuery_(query),
65
+ select: (document, budget) => withWorkBudget(budget ?? limits.maxWork, (work) => evaluate_(compiled, document, work).map((node) => node.value), onExhausted),
66
+ selectNodes: (document, budget) => withWorkBudget(budget ?? limits.maxWork, (work) => evaluate_(compiled, document, work).map((node) => ({
67
+ value: node.value,
68
+ path: pathOf(node, work),
69
+ })), onExhausted),
70
+ };
71
+ }
72
+ /**
73
+ * Selects from `document` with a query used once: {@link compileJsonPath} then
74
+ * {@link CompiledJsonPath.select}. Compile once instead when reusing a query.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * selectJsonPath({ a: [1, 2, 3] }, "$.a[-1]"); // [3]
79
+ * ```;
80
+ *
81
+ * @param options `budget` is charged for both the compilation and the
82
+ * evaluation.
83
+ * @throws As {@link compileJsonPath} and {@link CompiledJsonPath.select}.
84
+ */
85
+ export function selectJsonPath(document, source, options) {
86
+ return compileJsonPath(source, options).select(document, options?.budget);
87
+ }
88
+ /**
89
+ * {@link selectJsonPath} with each node's normalized path, as
90
+ * {@link CompiledJsonPath.selectNodes}.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * selectJsonPathNodes({ a: [1, 2] }, "$.a[*]");
95
+ * // [{ value: 1, path: ["a", 0] }, { value: 2, path: ["a", 1] }]
96
+ * ```;
97
+ *
98
+ * @throws As {@link compileJsonPath} and {@link CompiledJsonPath.selectNodes}.
99
+ */
100
+ export function selectJsonPathNodes(document, source, options) {
101
+ return compileJsonPath(source, options).selectNodes(document, options?.budget);
102
+ }
103
+ //# sourceMappingURL=compile-jsonpath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-jsonpath.js","sourceRoot":"","sources":["../src/compile-jsonpath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAgB,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGvE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAEN,SAAS,EACT,iBAAiB,EAEjB,kBAAkB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA6DzE,SAAS,MAAM,CAAC,IAAc,EAAE,MAAkB;IACjD,MAAM,IAAI,GAAwB,EAAE,CAAC;IACrC,KAAK,IAAI,EAAE,GAAoB,IAAI,EAAE,EAAE,EAAE,MAAM,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;QACzE,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;AACvB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,eAAe,CAC9B,MAAc,EACd,OAAyB;IAEzB,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/C,MAAM,WAAW,GAAG,CAAC,KAAY,EAAS,EAAE,CAC3C,IAAI,0BAA0B,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,EAA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,CACjC,EACF,WAAW,CACX;QACF,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CACjC,cAAc,CACb,MAAM,IAAI,MAAM,CAAC,OAAO,EACxB,CAAC,IAAI,EAAE,EAAE,CACR,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAClD,KAAK,EAAE,IAAI,CAAC,KAAkB;YAC9B,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC;SACxB,CAAC,CAAC,EACJ,WAAW,CACX;KACF,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,cAAc,CAC7B,QAAmB,EACnB,MAAc,EACd,OAAyB;IAEzB,OAAO,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CAClC,QAAmB,EACnB,MAAc,EACd,OAAyB;IAEzB,OAAO,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,WAAW,CAClD,QAAQ,EACR,OAAO,EAAE,MAAM,CACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,64 @@
1
+ /** Why a query or a normalized path was rejected. */
2
+ export type JsonPathErrorCode =
3
+ /**
4
+ * A character the grammar does not allow here, including blank space at
5
+ * either end.
6
+ */
7
+ "unexpected-character"
8
+ /** The text stops before the construct it started is complete. */
9
+ | "unexpected-end"
10
+ /** An index or slice bound with a leading zero, or `-0`. */
11
+ | "invalid-integer"
12
+ /** An index or slice bound outside ±(2⁵³−1) (RFC 9535 §2.1). */
13
+ | "integer-out-of-range"
14
+ /** A backslash escape the grammar does not define. */
15
+ | "invalid-escape"
16
+ /** A surrogate code unit, raw or escaped, not paired with its partner. */
17
+ | "unpaired-surrogate"
18
+ /** A raw control character (U+0000 to U+001F) inside a string literal. */
19
+ | "control-character"
20
+ /** A function other than `length`, `count`, `match`, `search` and `value`. */
21
+ | "unknown-function"
22
+ /** A function called with the wrong number of arguments. */
23
+ | "argument-count"
24
+ /**
25
+ * An argument the parameter's declared type does not accept (RFC 9535
26
+ * §2.4.3).
27
+ */
28
+ | "argument-type"
29
+ /** A function whose result type does not fit where it is called. */
30
+ | "result-type"
31
+ /** A query selecting possibly several nodes used as a comparison operand. */
32
+ | "non-singular-query"
33
+ /** A literal used where a test is expected, as in `[?true]`. */
34
+ | "literal-test"
35
+ /** A normalized path not in the RFC 9535 §2.7 canonical spelling. */
36
+ | "not-normalized";
37
+ /**
38
+ * Thrown for a query that is not well-formed or not valid (RFC 9535 §2.1), and
39
+ * for a malformed normalized path.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * try {
44
+ * parseJsonPath("$[01]");
45
+ * } catch (error) {
46
+ * if (error instanceof JsonPathSyntaxError) {
47
+ * console.log(error.code, error.position); // "invalid-integer" 2
48
+ * }
49
+ * }
50
+ * ```;
51
+ */
52
+ export declare class JsonPathSyntaxError extends SyntaxError {
53
+ readonly code: JsonPathErrorCode;
54
+ readonly source: string;
55
+ readonly position: number;
56
+ /**
57
+ * @param code What is wrong.
58
+ * @param source The text that was being parsed.
59
+ * @param position The UTF-16 offset in `source` where parsing gave up.
60
+ * @param detail A sentence for a human.
61
+ */
62
+ constructor(code: JsonPathErrorCode, source: string, position: number, detail: string);
63
+ }
64
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,MAAM,iBAAiB;AAC5B;;;GAGG;AACD,sBAAsB;AACxB,kEAAkE;GAChE,gBAAgB;AAClB,4DAA4D;GAC1D,iBAAiB;AACnB,gEAAgE;GAC9D,sBAAsB;AACxB,sDAAsD;GACpD,gBAAgB;AAClB,0EAA0E;GACxE,oBAAoB;AACtB,0EAA0E;GACxE,mBAAmB;AACrB,8EAA8E;GAC5E,kBAAkB;AACpB,4DAA4D;GAC1D,gBAAgB;AAClB;;;GAGG;GACD,eAAe;AACjB,oEAAoE;GAClE,aAAa;AACf,6EAA6E;GAC3E,oBAAoB;AACtB,gEAAgE;GAC9D,cAAc;AAChB,qEAAqE;GACnE,gBAAgB,CAAC;AAEpB;;;;;;;;;;;;;;GAcG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAQlD,QAAQ,CAAC,IAAI,EAAE,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAT1B;;;;;OAKG;IACH,YACU,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EACzB,MAAM,EAAE,MAAM,EAId;CACD"}
package/dist/errors.js ADDED
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Thrown for a query that is not well-formed or not valid (RFC 9535 §2.1), and
3
+ * for a malformed normalized path.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * try {
8
+ * parseJsonPath("$[01]");
9
+ * } catch (error) {
10
+ * if (error instanceof JsonPathSyntaxError) {
11
+ * console.log(error.code, error.position); // "invalid-integer" 2
12
+ * }
13
+ * }
14
+ * ```;
15
+ */
16
+ export class JsonPathSyntaxError extends SyntaxError {
17
+ code;
18
+ source;
19
+ position;
20
+ /**
21
+ * @param code What is wrong.
22
+ * @param source The text that was being parsed.
23
+ * @param position The UTF-16 offset in `source` where parsing gave up.
24
+ * @param detail A sentence for a human.
25
+ */
26
+ constructor(code, source, position, detail) {
27
+ super(`${detail} at position ${position}`);
28
+ this.code = code;
29
+ this.source = source;
30
+ this.position = position;
31
+ this.name = "JsonPathSyntaxError";
32
+ }
33
+ }
34
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,mBAAoB,SAAQ,WAAW;IAQzC,IAAI;IACJ,MAAM;IACN,QAAQ;IATlB;;;;;OAKG;IACH,YACU,IAAuB,EACvB,MAAc,EACd,QAAgB,EACzB,MAAc;QAEd,KAAK,CAAC,GAAG,MAAM,gBAAgB,QAAQ,EAAE,CAAC,CAAC;oBALlC,IAAI;sBACJ,MAAM;wBACN,QAAQ;QAIjB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACnC,CAAC;CACD"}
@@ -0,0 +1,7 @@
1
+ export * from "./ast.js";
2
+ export * from "./compile-jsonpath.js";
3
+ export * from "./errors.js";
4
+ export * from "./limits.js";
5
+ export * from "./normalized-path.js";
6
+ export * from "./parse-jsonpath.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export * from "./ast.js";
2
+ export * from "./compile-jsonpath.js";
3
+ export * from "./errors.js";
4
+ export * from "./limits.js";
5
+ export * from "./normalized-path.js";
6
+ export * from "./parse-jsonpath.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,108 @@
1
+ import { type RegexLimits } from "@ac-kit/format-regex";
2
+ /**
3
+ * The `@ac-kit/format-regex` bounds JSONPath passes through for the patterns of
4
+ * `match()` and `search()`. There is no `maxSteps`: every regex step is charged
5
+ * to the JSONPath work allowance ({@link JsonPathLimits.maxWork} or the
6
+ * caller's budget), which owns all step accounting.
7
+ */
8
+ export type JsonPathRegexLimits = Pick<RegexLimits, "maxProgramSize" | "maxNestingDepth">;
9
+ /**
10
+ * Bounds on what a query may cost to parse and to evaluate.
11
+ *
12
+ * A query and the document it runs over may both come from outside the program,
13
+ * so neither author bounds the cost. These limits do: the query's size and
14
+ * nesting are checked while parsing, and every evaluation runs within one work
15
+ * allowance, charged by what it actually does.
16
+ */
17
+ export type JsonPathLimits = {
18
+ /**
19
+ * Longest query accepted, in UTF-16 code units; checked before anything is
20
+ * parsed. A positive safe integer or `Infinity`. Default 4096.
21
+ */
22
+ readonly maxQueryLength?: number;
23
+ /**
24
+ * Deepest nesting of brackets, parentheses and function calls, counted
25
+ * together: `$[?(@[?count(@.*) > 1])]` is four deep. Parsing and evaluation
26
+ * keep nested constructs on an explicit stack, so this bounds memory and the
27
+ * size of the syntax tree handed out, not the native call stack. A positive
28
+ * integer up to {@link MAX_JSONPATH_NESTING_DEPTH}. Default 64.
29
+ */
30
+ readonly maxNestingDepth?: number;
31
+ /**
32
+ * Most work units one compilation, or one evaluation, may spend when the
33
+ * caller passes no `WorkBudget` of its own (`@ac-kit/core`).
34
+ *
35
+ * Units are charged before the work they pay for, weighted so that a unit
36
+ * costs about the same time (roughly 25 ns) whatever the query does: a query
37
+ * character parsed; a segment applied, a selector tried, a node visited, a
38
+ * logical operator applied, a node appended (1); a node listed (3); a member
39
+ * name listed (4); a container pair tracked by a deep comparison (6) and each
40
+ * of its steps and expanded elements or members (1); 512 code units compared
41
+ * for equality, 16 ordered by code point, or 1 measured by `length()` (1); a
42
+ * segment of a normalized path (1); and every compilation unit and step
43
+ * `@ac-kit/format-regex` spends on the patterns of `match()` and `search()`.
44
+ *
45
+ * One exception cannot be preempted: listing an object's member names is a
46
+ * single native call, charged as soon as it returns. Each object is listed at
47
+ * most once per evaluation, so an evaluation overruns its allowance by at
48
+ * most one listing of the widest object in the document; a caller that needs
49
+ * a hard bound on that bounds the document's size when parsing it.
50
+ *
51
+ * A positive safe integer or `Infinity`; exceeding it throws
52
+ * {@link JsonPathLimitExceededError} of kind `"work"`. Default 3 Mi: about
53
+ * 100 ms of the costliest evaluations (wide `$..*` with paths, deep equality,
54
+ * nested filters) on a typical machine.
55
+ */
56
+ readonly maxWork?: number;
57
+ /**
58
+ * Bounds on each pattern of `match()` and `search()`, passed to
59
+ * `@ac-kit/format-regex`; see {@link JsonPathRegexLimits}. A pattern beyond
60
+ * them throws `RegexLimitExceededError`.
61
+ */
62
+ readonly regex?: JsonPathRegexLimits;
63
+ };
64
+ /** Every bound in {@link JsonPathLimits}, filled in. */
65
+ export type ResolvedJsonPathLimits = Required<Omit<JsonPathLimits, "regex">> & {
66
+ readonly regex: Required<JsonPathRegexLimits>;
67
+ };
68
+ /**
69
+ * The highest {@link JsonPathLimits.maxNestingDepth} accepted. Parsing and
70
+ * evaluation never use the native stack for nesting, so this bounds the depth
71
+ * of the syntax tree {@link parseJsonPath} hands out, for a caller walking it
72
+ * recursively.
73
+ */
74
+ export declare const MAX_JSONPATH_NESTING_DEPTH = 256;
75
+ /**
76
+ * Defaults, chosen so no hand-written query over a realistic document reaches
77
+ * them: 4 Ki characters is two orders of magnitude above any query written by
78
+ * hand, 64 levels of nesting is an order above, and 3 Mi work units list every
79
+ * node of a document of half a million nodes (`$..*`).
80
+ */
81
+ export declare const DEFAULT_JSONPATH_LIMITS: ResolvedJsonPathLimits;
82
+ /** Which bound a {@link JsonPathLimitExceededError} reports. */
83
+ export type JsonPathLimitKind = "queryLength" | "nestingDepth" | "work" | "pathLength";
84
+ /**
85
+ * Thrown when a query or an evaluation exceeds one of the
86
+ * {@link JsonPathLimits}.
87
+ */
88
+ export declare class JsonPathLimitExceededError extends Error {
89
+ readonly kind: JsonPathLimitKind;
90
+ readonly limit: number;
91
+ /**
92
+ * @param kind The bound that was exceeded.
93
+ * @param limit Its value.
94
+ * @param options `cause` holds the `WorkBudgetExceededError` behind a
95
+ * `"work"` error.
96
+ */
97
+ constructor(kind: JsonPathLimitKind, limit: number, options?: ErrorOptions);
98
+ }
99
+ /**
100
+ * Fills in the unset bounds from {@link DEFAULT_JSONPATH_LIMITS}, including the
101
+ * nested `@ac-kit/format-regex` ones.
102
+ *
103
+ * @throws {RangeError} When `maxQueryLength` or `maxWork` is not a positive
104
+ * safe integer or `Infinity`, or `maxNestingDepth` is not an integer from 1
105
+ * to {@link MAX_JSONPATH_NESTING_DEPTH}.
106
+ */
107
+ export declare function jsonPathLimits(limits?: JsonPathLimits): ResolvedJsonPathLimits;
108
+ //# sourceMappingURL=limits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACrC,WAAW,EACX,gBAAgB,GAAG,iBAAiB,CACpC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAEjC;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAElC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,mBAAmB,CAAC;CACrC,CAAC;AAEF,wDAAwD;AACxD,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,GAAG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