@safeaccess/inline 0.1.1 → 0.1.3

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 (179) hide show
  1. package/.gitattributes +1 -1
  2. package/CHANGELOG.md +23 -5
  3. package/LICENSE +1 -1
  4. package/README.md +79 -21
  5. package/dist/accessors/abstract-accessor.d.ts +24 -10
  6. package/dist/accessors/abstract-accessor.js +21 -8
  7. package/dist/accessors/abstract-integration-accessor.d.ts +22 -0
  8. package/dist/accessors/abstract-integration-accessor.js +23 -0
  9. package/dist/accessors/formats/any-accessor.d.ts +10 -8
  10. package/dist/accessors/formats/any-accessor.js +9 -8
  11. package/dist/accessors/formats/array-accessor.d.ts +2 -0
  12. package/dist/accessors/formats/array-accessor.js +2 -0
  13. package/dist/accessors/formats/env-accessor.d.ts +2 -0
  14. package/dist/accessors/formats/env-accessor.js +2 -0
  15. package/dist/accessors/formats/ini-accessor.d.ts +2 -0
  16. package/dist/accessors/formats/ini-accessor.js +2 -0
  17. package/dist/accessors/formats/json-accessor.d.ts +2 -0
  18. package/dist/accessors/formats/json-accessor.js +2 -0
  19. package/dist/accessors/formats/ndjson-accessor.d.ts +2 -0
  20. package/dist/accessors/formats/ndjson-accessor.js +2 -0
  21. package/dist/accessors/formats/object-accessor.d.ts +2 -0
  22. package/dist/accessors/formats/object-accessor.js +2 -0
  23. package/dist/accessors/formats/xml-accessor.d.ts +2 -0
  24. package/dist/accessors/formats/xml-accessor.js +2 -0
  25. package/dist/accessors/formats/yaml-accessor.d.ts +3 -1
  26. package/dist/accessors/formats/yaml-accessor.js +4 -2
  27. package/dist/cache/simple-path-cache.d.ts +51 -0
  28. package/dist/cache/simple-path-cache.js +72 -0
  29. package/dist/contracts/accessors-interface.d.ts +2 -0
  30. package/dist/contracts/factory-accessors-interface.d.ts +2 -0
  31. package/dist/contracts/filter-evaluator-interface.d.ts +28 -0
  32. package/dist/contracts/filter-evaluator-interface.js +1 -0
  33. package/dist/contracts/parse-integration-interface.d.ts +2 -0
  34. package/dist/contracts/parser-interface.d.ts +92 -0
  35. package/dist/contracts/parser-interface.js +1 -0
  36. package/dist/contracts/path-cache-interface.d.ts +7 -6
  37. package/dist/contracts/readable-accessors-interface.d.ts +11 -6
  38. package/dist/contracts/security-guard-interface.d.ts +2 -0
  39. package/dist/contracts/security-parser-interface.d.ts +2 -0
  40. package/dist/contracts/validatable-parser-interface.d.ts +59 -0
  41. package/dist/contracts/validatable-parser-interface.js +1 -0
  42. package/dist/contracts/writable-accessors-interface.d.ts +5 -0
  43. package/dist/core/accessor-factory.d.ts +124 -0
  44. package/dist/core/accessor-factory.js +157 -0
  45. package/dist/core/dot-notation-parser.d.ts +34 -5
  46. package/dist/core/dot-notation-parser.js +51 -10
  47. package/dist/core/inline-builder-accessor.d.ts +82 -0
  48. package/dist/core/inline-builder-accessor.js +107 -0
  49. package/dist/exceptions/accessor-exception.d.ts +9 -0
  50. package/dist/exceptions/accessor-exception.js +9 -0
  51. package/dist/exceptions/invalid-format-exception.d.ts +5 -0
  52. package/dist/exceptions/invalid-format-exception.js +5 -0
  53. package/dist/exceptions/parser-exception.d.ts +4 -0
  54. package/dist/exceptions/parser-exception.js +4 -0
  55. package/dist/exceptions/path-not-found-exception.d.ts +4 -0
  56. package/dist/exceptions/path-not-found-exception.js +4 -0
  57. package/dist/exceptions/readonly-violation-exception.d.ts +4 -0
  58. package/dist/exceptions/readonly-violation-exception.js +4 -0
  59. package/dist/exceptions/security-exception.d.ts +6 -0
  60. package/dist/exceptions/security-exception.js +6 -0
  61. package/dist/exceptions/unsupported-type-exception.d.ts +4 -0
  62. package/dist/exceptions/unsupported-type-exception.js +4 -0
  63. package/dist/exceptions/yaml-parse-exception.d.ts +4 -0
  64. package/dist/exceptions/yaml-parse-exception.js +4 -0
  65. package/dist/index.js +2 -1
  66. package/dist/inline.d.ts +26 -56
  67. package/dist/inline.js +43 -111
  68. package/dist/parser/xml-parser.js +23 -10
  69. package/dist/parser/yaml-parser.d.ts +54 -7
  70. package/dist/parser/yaml-parser.js +268 -51
  71. package/dist/path-query/segment-filter-parser.d.ts +142 -0
  72. package/dist/path-query/segment-filter-parser.js +384 -0
  73. package/dist/path-query/segment-parser.d.ts +98 -0
  74. package/dist/path-query/segment-parser.js +283 -0
  75. package/dist/path-query/segment-path-resolver.d.ts +149 -0
  76. package/dist/path-query/segment-path-resolver.js +351 -0
  77. package/dist/path-query/segment-type.d.ts +85 -0
  78. package/dist/path-query/segment-type.js +35 -0
  79. package/dist/security/forbidden-keys.d.ts +2 -2
  80. package/dist/security/forbidden-keys.js +5 -5
  81. package/dist/security/security-guard.d.ts +4 -1
  82. package/dist/security/security-guard.js +7 -2
  83. package/dist/security/security-parser.d.ts +10 -1
  84. package/dist/security/security-parser.js +10 -1
  85. package/dist/type-format.d.ts +2 -0
  86. package/dist/type-format.js +2 -0
  87. package/package.json +11 -3
  88. package/src/accessors/abstract-accessor.ts +25 -19
  89. package/src/accessors/abstract-integration-accessor.ts +27 -0
  90. package/src/accessors/formats/any-accessor.ts +11 -11
  91. package/src/accessors/formats/array-accessor.ts +2 -0
  92. package/src/accessors/formats/env-accessor.ts +2 -0
  93. package/src/accessors/formats/ini-accessor.ts +2 -0
  94. package/src/accessors/formats/json-accessor.ts +2 -0
  95. package/src/accessors/formats/ndjson-accessor.ts +2 -0
  96. package/src/accessors/formats/object-accessor.ts +2 -0
  97. package/src/accessors/formats/xml-accessor.ts +2 -0
  98. package/src/accessors/formats/yaml-accessor.ts +4 -2
  99. package/src/cache/simple-path-cache.ts +77 -0
  100. package/src/contracts/accessors-interface.ts +2 -0
  101. package/src/contracts/factory-accessors-interface.ts +2 -0
  102. package/src/contracts/filter-evaluator-interface.ts +30 -0
  103. package/src/contracts/parse-integration-interface.ts +2 -0
  104. package/src/contracts/parser-interface.ts +114 -0
  105. package/src/contracts/path-cache-interface.ts +8 -6
  106. package/src/contracts/readable-accessors-interface.ts +11 -6
  107. package/src/contracts/security-guard-interface.ts +2 -0
  108. package/src/contracts/security-parser-interface.ts +2 -0
  109. package/src/contracts/validatable-parser-interface.ts +64 -0
  110. package/src/contracts/writable-accessors-interface.ts +5 -0
  111. package/src/core/accessor-factory.ts +173 -0
  112. package/src/core/dot-notation-parser.ts +74 -11
  113. package/src/core/inline-builder-accessor.ts +163 -0
  114. package/src/exceptions/accessor-exception.ts +9 -0
  115. package/src/exceptions/invalid-format-exception.ts +5 -0
  116. package/src/exceptions/parser-exception.ts +4 -0
  117. package/src/exceptions/path-not-found-exception.ts +4 -0
  118. package/src/exceptions/readonly-violation-exception.ts +4 -0
  119. package/src/exceptions/security-exception.ts +6 -0
  120. package/src/exceptions/unsupported-type-exception.ts +4 -0
  121. package/src/exceptions/yaml-parse-exception.ts +4 -0
  122. package/src/index.ts +3 -1
  123. package/src/inline.ts +46 -120
  124. package/src/parser/xml-parser.ts +31 -10
  125. package/src/parser/yaml-parser.ts +310 -45
  126. package/src/path-query/segment-filter-parser.ts +444 -0
  127. package/src/path-query/segment-parser.ts +321 -0
  128. package/src/path-query/segment-path-resolver.ts +521 -0
  129. package/src/path-query/segment-type.ts +82 -0
  130. package/src/security/forbidden-keys.ts +5 -5
  131. package/src/security/security-guard.ts +10 -2
  132. package/src/security/security-parser.ts +18 -3
  133. package/src/type-format.ts +2 -0
  134. package/stryker.config.json +8 -10
  135. package/tests/accessors/abstract-accessor.test.ts +217 -0
  136. package/tests/accessors/abstract-integration-accessor.test.ts +37 -0
  137. package/tests/accessors/formats/any-accessor.test.ts +57 -0
  138. package/tests/accessors/formats/array-accessor.test.ts +42 -0
  139. package/tests/accessors/formats/env-accessor.test.ts +103 -0
  140. package/tests/accessors/formats/ini-accessor.test.ts +186 -0
  141. package/tests/accessors/{json-accessor.test.ts → formats/json-accessor.test.ts} +6 -6
  142. package/tests/accessors/formats/ndjson-accessor.test.ts +49 -0
  143. package/tests/accessors/formats/object-accessor.test.ts +172 -0
  144. package/tests/accessors/formats/xml-accessor.test.ts +162 -0
  145. package/tests/accessors/formats/yaml-accessor.test.ts +36 -0
  146. package/tests/cache/simple-path-cache.test.ts +168 -0
  147. package/tests/core/accessor-factory.test.ts +157 -0
  148. package/tests/core/dot-notation-parser-edge-cases.test.ts +415 -0
  149. package/tests/core/dot-notation-parser.test.ts +0 -288
  150. package/tests/core/inline-builder-accessor.test.ts +114 -0
  151. package/tests/exceptions/accessor-exception.test.ts +28 -0
  152. package/tests/exceptions/invalid-format-exception.test.ts +31 -0
  153. package/tests/exceptions/path-not-found-exception.test.ts +33 -0
  154. package/tests/exceptions/readonly-violation-exception.test.ts +35 -0
  155. package/tests/exceptions/security-exception.test.ts +33 -0
  156. package/tests/exceptions/unsupported-type-exception.test.ts +33 -0
  157. package/tests/exceptions/yaml-parse-exception.test.ts +38 -0
  158. package/tests/mocks/fake-path-cache.ts +4 -3
  159. package/tests/parity-from.test.ts +118 -0
  160. package/tests/parity.test.ts +227 -10
  161. package/tests/parser/xml-parser-mutations.test.ts +579 -0
  162. package/tests/parser/xml-parser-scanner.test.ts +379 -0
  163. package/tests/parser/xml-parser.test.ts +17 -330
  164. package/tests/parser/yaml-parser-mutations.test.ts +750 -0
  165. package/tests/parser/yaml-parser.test.ts +844 -18
  166. package/tests/path-query/segment-filter-parser-mutations.test.ts +735 -0
  167. package/tests/path-query/segment-filter-parser.test.ts +1091 -0
  168. package/tests/path-query/segment-parser-mutations.test.ts +539 -0
  169. package/tests/path-query/segment-parser.test.ts +606 -0
  170. package/tests/path-query/segment-path-resolver-mutations.test.ts +626 -0
  171. package/tests/path-query/segment-path-resolver.test.ts +1009 -0
  172. package/tests/security/security-guard-advanced.test.ts +413 -0
  173. package/tests/security/security-guard-forbidden-keys.test.ts +87 -0
  174. package/tests/security/security-guard.test.ts +8 -479
  175. package/tests/security/security-parser.test.ts +18 -14
  176. package/vitest.config.ts +3 -3
  177. package/benchmarks/get.bench.ts +0 -26
  178. package/benchmarks/parse.bench.ts +0 -41
  179. package/tests/accessors/accessors.test.ts +0 -1017
@@ -0,0 +1,283 @@
1
+ import { InvalidFormatException } from '../exceptions/invalid-format-exception.js';
2
+ import { SegmentType } from './segment-type.js';
3
+ /**
4
+ * Parse dot-notation path strings into typed segment arrays.
5
+ *
6
+ * Converts path expressions (e.g. "users[0].address..city") into ordered
7
+ * segment arrays with {@link SegmentType} metadata for resolution by
8
+ * {@link SegmentPathResolver}. Supports key, index, wildcard, descent,
9
+ * multi-key/index, filter, slice, and projection segment types.
10
+ *
11
+ * @internal
12
+ *
13
+ * @see SegmentType Enum of all segment types produced.
14
+ * @see SegmentPathResolver Consumer that resolves segments against data.
15
+ * @see FilterEvaluatorInterface Delegate for filter expression parsing.
16
+ */
17
+ export class SegmentParser {
18
+ segmentFilterParser;
19
+ /**
20
+ * Create a segment parser with a filter evaluator.
21
+ *
22
+ * @param segmentFilterParser - Delegate for [?filter] parsing.
23
+ */
24
+ constructor(segmentFilterParser) {
25
+ this.segmentFilterParser = segmentFilterParser;
26
+ }
27
+ /**
28
+ * Parse a dot-notation path into an ordered array of typed segments.
29
+ *
30
+ * @param path - Dot-notation path expression.
31
+ * @returns Typed segment array.
32
+ *
33
+ * @throws {InvalidFormatException} When slice step is zero.
34
+ */
35
+ parseSegments(path) {
36
+ const segments = [];
37
+ const len = path.length;
38
+ const pos = { i: 0 };
39
+ if (path[0] === '$') {
40
+ pos.i = 1;
41
+ if (path[pos.i] === '.') {
42
+ pos.i++;
43
+ }
44
+ }
45
+ while (pos.i < len) {
46
+ if (path[pos.i] === '.') {
47
+ if (path[pos.i + 1] === '.') {
48
+ pos.i += 2;
49
+ segments.push(this.parseDescent(path, pos, len));
50
+ continue;
51
+ }
52
+ pos.i++;
53
+ const segment = this.parseProjection(path, pos, len);
54
+ if (segment !== null) {
55
+ segments.push(segment);
56
+ }
57
+ continue;
58
+ }
59
+ if (path[pos.i] === '[' && path[pos.i + 1] === '?') {
60
+ segments.push(this.parseFilter(path, pos, len));
61
+ continue;
62
+ }
63
+ if (path[pos.i] === '[') {
64
+ segments.push(this.parseBracket(path, pos, len));
65
+ continue;
66
+ }
67
+ if (path[pos.i] === '*') {
68
+ segments.push({ type: SegmentType.Wildcard });
69
+ pos.i++;
70
+ continue;
71
+ }
72
+ segments.push(this.parseKey(path, pos, len));
73
+ }
74
+ return segments;
75
+ }
76
+ /**
77
+ * Parse a recursive descent segment (`..key` or `..[...]`).
78
+ *
79
+ * @param path - Full path string.
80
+ * @param pos - Current position (mutated in place).
81
+ * @param len - Total path length.
82
+ * @returns Parsed descent segment.
83
+ */
84
+ parseDescent(path, pos, len) {
85
+ if (path[pos.i] === '[') {
86
+ let j = pos.i + 1;
87
+ while (j < len && path[j] !== ']') {
88
+ j++;
89
+ }
90
+ const inner = path.substring(pos.i + 1, j);
91
+ pos.i = j + 1;
92
+ if (inner.includes(',') && this.allQuoted(inner.split(','))) {
93
+ const parts = inner.split(',').map((p) => p.trim());
94
+ const keys = parts.map((p) => p.substring(1, p.length - 1));
95
+ return { type: SegmentType.DescentMulti, keys };
96
+ }
97
+ const quotedMatch = inner.match(/^(['"])(.*?)\1$/);
98
+ if (quotedMatch) {
99
+ return { type: SegmentType.Descent, key: quotedMatch[2] };
100
+ }
101
+ return { type: SegmentType.Descent, key: inner };
102
+ }
103
+ let key = '';
104
+ while (pos.i < len && path[pos.i] !== '.' && path[pos.i] !== '[') {
105
+ if (path[pos.i] === '\\' && path[pos.i + 1] === '.') {
106
+ key += '.';
107
+ pos.i += 2;
108
+ }
109
+ else {
110
+ key += path[pos.i];
111
+ pos.i++;
112
+ }
113
+ }
114
+ return { type: SegmentType.Descent, key };
115
+ }
116
+ /**
117
+ * Parse a projection segment (`.{field1, field2}` or `.{alias: field}`).
118
+ *
119
+ * @param path - Full path string.
120
+ * @param pos - Current position (mutated in place).
121
+ * @param len - Total path length.
122
+ * @returns Parsed projection segment, or null if not a projection.
123
+ */
124
+ parseProjection(path, pos, len) {
125
+ if (path[pos.i] !== '{') {
126
+ return null;
127
+ }
128
+ let j = pos.i + 1;
129
+ while (j < len && path[j] !== '}') {
130
+ j++;
131
+ }
132
+ const inner = path.substring(pos.i + 1, j);
133
+ pos.i = j + 1;
134
+ const fields = [];
135
+ for (const entry of inner
136
+ .split(',')
137
+ .map((e) => e.trim())
138
+ .filter((e) => e !== '')) {
139
+ const colonIdx = entry.indexOf(':');
140
+ if (colonIdx !== -1) {
141
+ fields.push({
142
+ alias: entry.substring(0, colonIdx).trim(),
143
+ source: entry.substring(colonIdx + 1).trim(),
144
+ });
145
+ }
146
+ else {
147
+ fields.push({ alias: entry, source: entry });
148
+ }
149
+ }
150
+ return { type: SegmentType.Projection, fields };
151
+ }
152
+ /**
153
+ * Parse a filter segment (`[?expression]`).
154
+ *
155
+ * @param path - Full path string.
156
+ * @param pos - Current position (mutated in place).
157
+ * @param len - Total path length.
158
+ * @returns Parsed filter segment.
159
+ */
160
+ parseFilter(path, pos, len) {
161
+ let depth = 1;
162
+ let j = pos.i + 1;
163
+ while (j < len && depth > 0) {
164
+ j++;
165
+ if (path[j] === '[') {
166
+ depth++;
167
+ }
168
+ if (path[j] === ']') {
169
+ depth--;
170
+ }
171
+ }
172
+ const filterExpr = path.substring(pos.i + 2, j);
173
+ pos.i = j + 1;
174
+ return { type: SegmentType.Filter, expression: this.segmentFilterParser.parse(filterExpr) };
175
+ }
176
+ /**
177
+ * Parse a bracket segment (`[0]`, `[0,1,2]`, `[0:5]`, `['key']`, `[*]`).
178
+ *
179
+ * @param path - Full path string.
180
+ * @param pos - Current position (mutated in place).
181
+ * @param len - Total path length.
182
+ * @returns Parsed bracket segment.
183
+ *
184
+ * @throws {InvalidFormatException} When slice step is zero.
185
+ */
186
+ parseBracket(path, pos, len) {
187
+ let j = pos.i + 1;
188
+ while (j < len && path[j] !== ']') {
189
+ j++;
190
+ }
191
+ const inner = path.substring(pos.i + 1, j);
192
+ pos.i = j + 1;
193
+ if (inner.includes(',')) {
194
+ const parts = inner.split(',').map((p) => p.trim());
195
+ if (this.allQuoted(parts)) {
196
+ const keys = parts.map((p) => p.substring(1, p.length - 1));
197
+ return { type: SegmentType.MultiKey, keys };
198
+ }
199
+ let allNumeric = true;
200
+ for (const p of parts) {
201
+ if (isNaN(Number(p.trim())) || p.trim() === '') {
202
+ allNumeric = false;
203
+ break;
204
+ }
205
+ }
206
+ if (allNumeric) {
207
+ return { type: SegmentType.MultiIndex, indices: parts.map((p) => parseInt(p, 10)) };
208
+ }
209
+ }
210
+ const quotedMatch = inner.match(/^(['"])(.*?)\1$/);
211
+ if (quotedMatch) {
212
+ return { type: SegmentType.Key, value: quotedMatch[2] };
213
+ }
214
+ if (inner.includes(':')) {
215
+ const sliceParts = inner.split(':');
216
+ const start = sliceParts[0] !== '' ? parseInt(sliceParts[0], 10) : null;
217
+ const end = sliceParts.length > 1 && sliceParts[1] !== '' ? parseInt(sliceParts[1], 10) : null;
218
+ const rawStep = sliceParts.length > 2 && sliceParts[2] !== '' ? parseInt(sliceParts[2], 10) : null;
219
+ if (rawStep === 0) {
220
+ throw new InvalidFormatException('Slice step cannot be zero.');
221
+ }
222
+ return { type: SegmentType.Slice, start, end, step: rawStep };
223
+ }
224
+ if (inner === '*') {
225
+ return { type: SegmentType.Wildcard };
226
+ }
227
+ return { type: SegmentType.Key, value: inner };
228
+ }
229
+ /**
230
+ * Parse a regular dot-separated key with escaped-dot support.
231
+ *
232
+ * @param path - Full path string.
233
+ * @param pos - Current position (mutated in place).
234
+ * @param len - Total path length.
235
+ * @returns Parsed key segment.
236
+ */
237
+ parseKey(path, pos, len) {
238
+ let key = '';
239
+ while (pos.i < len && path[pos.i] !== '.' && path[pos.i] !== '[') {
240
+ if (path[pos.i] === '\\' && path[pos.i + 1] === '.') {
241
+ key += '.';
242
+ pos.i += 2;
243
+ }
244
+ else {
245
+ key += path[pos.i];
246
+ pos.i++;
247
+ }
248
+ }
249
+ return { type: SegmentType.Key, value: key };
250
+ }
251
+ /**
252
+ * Check if all parts in a comma-separated list are quoted strings.
253
+ *
254
+ * @param parts - Raw parts from split.
255
+ * @returns True if every part is single- or double-quoted.
256
+ */
257
+ allQuoted(parts) {
258
+ for (const raw of parts) {
259
+ const p = raw.trim();
260
+ if (!(p.startsWith("'") && p.endsWith("'")) &&
261
+ !(p.startsWith('"') && p.endsWith('"'))) {
262
+ return false;
263
+ }
264
+ }
265
+ return true;
266
+ }
267
+ /**
268
+ * Parse a simple dot-notation path into plain string keys.
269
+ *
270
+ * Handles bracket notation and escaped dots. Does not produce typed
271
+ * segments - used for set/remove operations via {@link DotNotationParser}.
272
+ *
273
+ * @param path - Simple dot-notation path.
274
+ * @returns Ordered list of key strings.
275
+ */
276
+ parseKeys(path) {
277
+ let normalized = path.replace(/\[([^\]]+)\]/g, '.$1');
278
+ const placeholder = '\x00ESC_DOT\x00';
279
+ normalized = normalized.replace(/\\\./g, placeholder);
280
+ const keys = normalized.split('.');
281
+ return keys.map((k) => k.replace(new RegExp(placeholder.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), '.'));
282
+ }
283
+ }
@@ -0,0 +1,149 @@
1
+ import type { FilterEvaluatorInterface } from '../contracts/filter-evaluator-interface.js';
2
+ import type { Segment } from './segment-type.js';
3
+ /**
4
+ * Resolve typed path segments against nested data structures.
5
+ *
6
+ * Traverses data using segment arrays produced by {@link SegmentParser},
7
+ * dispatching to segment-type-specific handlers for key, wildcard,
8
+ * descent, filter, slice, multi-key/index, and projection operations.
9
+ *
10
+ * @internal
11
+ *
12
+ * @see SegmentParser Produces the segment arrays this resolver consumes.
13
+ * @see SegmentType Enum governing which handler is dispatched.
14
+ * @see FilterEvaluatorInterface Delegate for filter predicate evaluation.
15
+ * @see DotNotationParser Invokes this resolver for path queries.
16
+ */
17
+ export declare class SegmentPathResolver {
18
+ private readonly segmentFilterParser;
19
+ /**
20
+ * Create a resolver with a filter evaluator.
21
+ *
22
+ * @param segmentFilterParser - Delegate for filter evaluation.
23
+ */
24
+ constructor(segmentFilterParser: FilterEvaluatorInterface);
25
+ /**
26
+ * Resolve a value by walking segments starting at the given index.
27
+ *
28
+ * @param current - Current data node.
29
+ * @param segments - Typed segment array from {@link SegmentParser}.
30
+ * @param index - Current segment index.
31
+ * @param defaultValue - Fallback value when resolution fails.
32
+ * @param maxDepth - Maximum recursion depth.
33
+ * @returns Resolved value or the default.
34
+ *
35
+ * @throws {SecurityException} When recursion depth exceeds the limit.
36
+ */
37
+ resolve(current: unknown, segments: ReadonlyArray<Segment>, index: number, defaultValue: unknown, maxDepth: number): unknown;
38
+ /**
39
+ * Resolve a simple key/index segment.
40
+ *
41
+ * @param current - Current data node.
42
+ * @param segments - Typed segment array.
43
+ * @param index - Current segment index.
44
+ * @param defaultValue - Fallback value when resolution fails.
45
+ * @param maxDepth - Maximum recursion depth.
46
+ * @returns Resolved value or the default.
47
+ */
48
+ private segmentAny;
49
+ /**
50
+ * Resolve a recursive descent segment for a single key.
51
+ *
52
+ * @param current - Current data node.
53
+ * @param segments - Typed segment array.
54
+ * @param index - Current segment index.
55
+ * @param defaultValue - Fallback value when resolution fails.
56
+ * @param maxDepth - Maximum recursion depth.
57
+ * @returns Array of all values matching the descent key.
58
+ */
59
+ private segmentDescent;
60
+ /**
61
+ * Resolve a recursive descent segment for multiple keys.
62
+ *
63
+ * @param current - Current data node.
64
+ * @param segments - Typed segment array.
65
+ * @param index - Current segment index.
66
+ * @param defaultValue - Fallback value when resolution fails.
67
+ * @param maxDepth - Maximum recursion depth.
68
+ * @returns Array of all values matching any of the descent keys.
69
+ */
70
+ private segmentDescentMulti;
71
+ /**
72
+ * Resolve a wildcard segment, expanding all children.
73
+ *
74
+ * @param current - Current data node.
75
+ * @param segments - Typed segment array.
76
+ * @param index - Current segment index.
77
+ * @param defaultValue - Fallback value when resolution fails.
78
+ * @param maxDepth - Maximum recursion depth.
79
+ * @returns Array of resolved values for all children.
80
+ */
81
+ private segmentWildcard;
82
+ /**
83
+ * Resolve a filter segment, applying predicates to array items.
84
+ *
85
+ * @param current - Current data node.
86
+ * @param segments - Typed segment array.
87
+ * @param index - Current segment index.
88
+ * @param defaultValue - Fallback value when resolution fails.
89
+ * @param maxDepth - Maximum recursion depth.
90
+ * @returns Array of items passing the filter predicate.
91
+ */
92
+ private segmentFilter;
93
+ /**
94
+ * Resolve a multi-key segment, selecting values by multiple keys.
95
+ *
96
+ * @param current - Current data node.
97
+ * @param segments - Typed segment array.
98
+ * @param index - Current segment index.
99
+ * @param defaultValue - Fallback value when resolution fails.
100
+ * @param maxDepth - Maximum recursion depth.
101
+ * @returns Array of resolved values for each key.
102
+ */
103
+ private segmentMultiKey;
104
+ /**
105
+ * Resolve a multi-index segment, selecting values by multiple indices.
106
+ *
107
+ * @param current - Current data node.
108
+ * @param segments - Typed segment array.
109
+ * @param index - Current segment index.
110
+ * @param defaultValue - Fallback value when resolution fails.
111
+ * @param maxDepth - Maximum recursion depth.
112
+ * @returns Array of resolved values for each index.
113
+ */
114
+ private segmentMultiIndex;
115
+ /**
116
+ * Resolve a slice segment on an array (start:end:step).
117
+ *
118
+ * @param current - Current data node.
119
+ * @param segments - Typed segment array.
120
+ * @param index - Current segment index.
121
+ * @param defaultValue - Fallback value when resolution fails.
122
+ * @param maxDepth - Maximum recursion depth.
123
+ * @returns Array of resolved values matching the slice range.
124
+ */
125
+ private segmentSlice;
126
+ /**
127
+ * Resolve a projection segment, selecting specific fields from items.
128
+ *
129
+ * @param current - Current data node.
130
+ * @param segments - Typed segment array.
131
+ * @param index - Current segment index.
132
+ * @param defaultValue - Fallback value when resolution fails.
133
+ * @param maxDepth - Maximum recursion depth.
134
+ * @returns Projected item(s) with only the specified fields.
135
+ */
136
+ private segmentProjection;
137
+ /**
138
+ * Recursively collect values matching a descent key from nested data.
139
+ *
140
+ * @param current - Current data node.
141
+ * @param key - Key to search for recursively.
142
+ * @param segments - Typed segment array.
143
+ * @param nextIndex - Next segment index after the descent.
144
+ * @param defaultValue - Fallback value.
145
+ * @param results - Collector array (mutated in place).
146
+ * @param maxDepth - Maximum recursion depth.
147
+ */
148
+ private collectDescent;
149
+ }