@btc-embedded/cdk-extensions 0.23.4 → 0.23.6
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.
- package/.jsii +5 -5
- package/CHANGELOG.md +21 -0
- package/assets/cli/catnip.js +154 -166
- package/lib/constructs/EventPipe.js +1 -1
- package/lib/constructs/ExportedService.js +1 -1
- package/lib/constructs/S3Bucket.js +1 -1
- package/lib/constructs/SecureRestApi.js +1 -1
- package/lib/constructs/SecureRestApiV2.js +1 -1
- package/lib/constructs/api-keys/ApiKeyClientAuthorization.js +1 -1
- package/lib/constructs/api-keys/ApiKeyManagement.js +1 -1
- package/lib/constructs/api-keys/ApiKeyPreTokenHandler.js +1 -1
- package/lib/constructs/api-keys/ApiKeyStore.js +1 -1
- package/lib/extensions/ApiGatewayExtension.js +1 -1
- package/lib/extensions/ApplicationContainer.js +1 -1
- package/lib/extensions/ApplicationLoadBalancerExtension.js +1 -1
- package/lib/extensions/ApplicationLoadBalancerExtensionV2.js +1 -1
- package/lib/extensions/CloudMapExtension.js +1 -1
- package/lib/extensions/DeactivatableServiceExtension.js +1 -1
- package/lib/extensions/DeploymentConfigExtension.js +1 -1
- package/lib/extensions/DocumentDbAccessExtension.js +1 -1
- package/lib/extensions/DomainEventMessagingExtension.js +1 -1
- package/lib/extensions/EfsMountExtension.js +1 -1
- package/lib/extensions/ExtraContainerExtension.js +1 -1
- package/lib/extensions/HTTPApiExtension.js +1 -1
- package/lib/extensions/LogExtension.js +1 -1
- package/lib/extensions/ModifyContainerDefinitionExtension.js +1 -1
- package/lib/extensions/ModifyTaskDefinitionExtension.js +1 -1
- package/lib/extensions/OpenIdExtension.js +1 -1
- package/lib/extensions/OpenTelemetryExtension.js +1 -1
- package/lib/extensions/PostgresDbAccessExtension.js +1 -1
- package/lib/extensions/SharedVolumeExtension.js +1 -1
- package/lib/extensions/TcpKeepAliveExtension.js +1 -1
- package/lib/platform/ApiGateway.js +1 -1
- package/lib/platform/ApiGatewayVpcLink.js +2 -2
- package/lib/platform/ApplicationLoadBalancer.js +1 -1
- package/lib/platform/ApplicationLoadBalancerV2.d.ts +2 -0
- package/lib/platform/ApplicationLoadBalancerV2.js +17 -3
- package/lib/platform/AuroraPostgresDB.js +2 -2
- package/lib/platform/BTCLogGroup.js +1 -1
- package/lib/platform/CognitoUserPool.js +2 -2
- package/lib/platform/DefaultUserPoolClients.js +1 -1
- package/lib/platform/DocumentDB.js +2 -2
- package/lib/platform/EcsCluster.js +1 -1
- package/lib/platform/EfsFileSystem.js +1 -1
- package/lib/platform/HostedZone.js +1 -1
- package/lib/platform/PrivateDnsNamespace.js +1 -1
- package/lib/platform/ResourceServer.js +1 -1
- package/lib/platform/Vpc.js +1 -1
- package/lib/platform/VpcV2.js +1 -1
- package/lib/stacks/ApplicationStack.js +1 -1
- package/lib/utils/BasePlatformStackResolver.js +1 -1
- package/lib/utils/StackParameter.js +1 -1
- package/node_modules/@nodable/entities/README.md +41 -0
- package/node_modules/@nodable/entities/package.json +54 -0
- package/node_modules/@nodable/entities/src/EntityDecoder.js +543 -0
- package/node_modules/@nodable/entities/src/EntityEncoder.js +194 -0
- package/node_modules/@nodable/entities/src/entities.js +1177 -0
- package/node_modules/@nodable/entities/src/entityTries.js +49 -0
- package/node_modules/@nodable/entities/src/index.d.ts +264 -0
- package/node_modules/@nodable/entities/src/index.js +29 -0
- package/node_modules/fast-xml-builder/CHANGELOG.md +40 -0
- package/node_modules/fast-xml-builder/LICENSE +21 -0
- package/node_modules/fast-xml-builder/README.md +74 -0
- package/node_modules/fast-xml-builder/lib/fxb.cjs +1 -0
- package/node_modules/fast-xml-builder/lib/fxb.d.cts +270 -0
- package/node_modules/fast-xml-builder/lib/fxb.min.js +2 -0
- package/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -0
- package/node_modules/fast-xml-builder/package.json +81 -0
- package/node_modules/fast-xml-builder/src/fxb.d.ts +270 -0
- package/node_modules/fast-xml-builder/src/fxb.js +599 -0
- package/node_modules/fast-xml-builder/src/ignoreAttributes.js +18 -0
- package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +359 -0
- package/node_modules/fast-xml-builder/src/util.js +16 -0
- package/node_modules/fast-xml-parser/CHANGELOG.md +165 -0
- package/node_modules/fast-xml-parser/README.md +21 -44
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +1 -1
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -1
- package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -1
- package/node_modules/fast-xml-parser/lib/fxp.d.cts +343 -31
- package/node_modules/fast-xml-parser/lib/fxp.min.js +1 -1
- package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -1
- package/node_modules/fast-xml-parser/lib/fxparser.min.js +1 -1
- package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -1
- package/node_modules/fast-xml-parser/lib/fxvalidator.min.js +1 -1
- package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -1
- package/node_modules/fast-xml-parser/package.json +13 -8
- package/node_modules/fast-xml-parser/src/fxp.d.ts +335 -30
- package/node_modules/fast-xml-parser/src/fxp.js +1 -1
- package/node_modules/fast-xml-parser/src/util.js +18 -25
- package/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +89 -87
- package/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +10 -10
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +23 -23
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +29 -29
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +1 -1
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +39 -39
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +21 -21
- package/node_modules/fast-xml-parser/src/v6/XMLParser.js +22 -22
- package/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +85 -85
- package/node_modules/fast-xml-parser/src/validator.js +34 -34
- package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +5 -284
- package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +335 -293
- package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +160 -43
- package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +540 -308
- package/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +26 -26
- package/node_modules/fast-xml-parser/src/xmlparser/node2json.js +99 -41
- package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +10 -10
- package/node_modules/path-expression-matcher/LICENSE +21 -0
- package/node_modules/path-expression-matcher/README.md +872 -0
- package/node_modules/path-expression-matcher/lib/pem.cjs +1 -0
- package/node_modules/path-expression-matcher/lib/pem.d.cts +634 -0
- package/node_modules/path-expression-matcher/lib/pem.min.js +2 -0
- package/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -0
- package/node_modules/path-expression-matcher/package.json +78 -0
- package/node_modules/path-expression-matcher/src/Expression.js +232 -0
- package/node_modules/path-expression-matcher/src/ExpressionSet.js +209 -0
- package/node_modules/path-expression-matcher/src/Matcher.js +570 -0
- package/node_modules/path-expression-matcher/src/index.d.ts +523 -0
- package/node_modules/path-expression-matcher/src/index.js +29 -0
- package/node_modules/strnum/CHANGELOG.md +12 -2
- package/node_modules/strnum/README.md +1 -0
- package/node_modules/strnum/package.json +5 -4
- package/node_modules/strnum/strnum.js +99 -65
- package/node_modules/xml-naming/README.md +189 -0
- package/node_modules/xml-naming/package.json +54 -0
- package/node_modules/xml-naming/src/index.d.ts +74 -0
- package/node_modules/xml-naming/src/index.js +270 -0
- package/package.json +3 -2
- package/renovate.json5 +1 -0
- package/node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js +0 -134
- package/node_modules/strnum/.github/SECURITY.md +0 -5
- package/node_modules/strnum/.vscode/launch.json +0 -25
- package/node_modules/strnum/algo.stflow +0 -84
- package/node_modules/strnum/strnum.test.js +0 -173
- package/node_modules/strnum/test.js +0 -9
- /package/node_modules/{fast-xml-parser/src/xmlbuilder → fast-xml-builder/src}/prettifyJs2Xml.js +0 -0
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript definitions for path-expression-matcher
|
|
3
|
+
*
|
|
4
|
+
* Provides efficient path tracking and pattern matching for XML/JSON parsers.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Options for creating an Expression
|
|
9
|
+
*/
|
|
10
|
+
export interface ExpressionOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Path separator character
|
|
13
|
+
* @default '.'
|
|
14
|
+
*/
|
|
15
|
+
separator?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Parsed segment from an expression pattern
|
|
20
|
+
*/
|
|
21
|
+
export interface Segment {
|
|
22
|
+
/**
|
|
23
|
+
* Type of segment
|
|
24
|
+
*/
|
|
25
|
+
type: 'tag' | 'deep-wildcard';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Tag name (e.g., "user", "*" for wildcard)
|
|
29
|
+
* Only present when type is 'tag'
|
|
30
|
+
*/
|
|
31
|
+
tag?: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Namespace prefix (e.g., "ns" in "ns::user")
|
|
35
|
+
* Only present when namespace is specified
|
|
36
|
+
*/
|
|
37
|
+
namespace?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Attribute name to match (e.g., "id" in "user[id]")
|
|
41
|
+
* Only present when attribute condition exists
|
|
42
|
+
*/
|
|
43
|
+
attrName?: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Attribute value to match (e.g., "123" in "user[id=123]")
|
|
47
|
+
* Only present when attribute value is specified
|
|
48
|
+
*/
|
|
49
|
+
attrValue?: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Position selector type
|
|
53
|
+
* Only present when position selector exists
|
|
54
|
+
*/
|
|
55
|
+
position?: 'first' | 'last' | 'odd' | 'even' | 'nth';
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Numeric value for nth() selector
|
|
59
|
+
* Only present when position is 'nth'
|
|
60
|
+
*/
|
|
61
|
+
positionValue?: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Expression - Parses and stores a tag pattern expression
|
|
66
|
+
*
|
|
67
|
+
* Patterns are parsed once and stored in an optimized structure for fast matching.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const expr = new Expression("root.users.user");
|
|
72
|
+
* const expr2 = new Expression("..user[id]:first");
|
|
73
|
+
* const expr3 = new Expression("root/users/user", { separator: '/' });
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* Pattern Syntax:
|
|
77
|
+
* - `root.users.user` - Match exact path
|
|
78
|
+
* - `..user` - Match "user" at any depth (deep wildcard)
|
|
79
|
+
* - `user[id]` - Match user tag with "id" attribute
|
|
80
|
+
* - `user[id=123]` - Match user tag where id="123"
|
|
81
|
+
* - `user:first` - Match first occurrence of user tag
|
|
82
|
+
* - `ns::user` - Match user tag with namespace "ns"
|
|
83
|
+
* - `ns::user[id]:first` - Combine namespace, attribute, and position
|
|
84
|
+
*/
|
|
85
|
+
export class Expression {
|
|
86
|
+
/**
|
|
87
|
+
* Original pattern string
|
|
88
|
+
*/
|
|
89
|
+
readonly pattern: string;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Path separator character
|
|
93
|
+
*/
|
|
94
|
+
readonly separator: string;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Parsed segments
|
|
98
|
+
*/
|
|
99
|
+
readonly segments: Segment[];
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Create a new Expression
|
|
103
|
+
* @param pattern - Pattern string (e.g., "root.users.user", "..user[id]")
|
|
104
|
+
* @param options - Configuration options
|
|
105
|
+
*/
|
|
106
|
+
constructor(pattern: string, options?: ExpressionOptions);
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Get the number of segments
|
|
110
|
+
*/
|
|
111
|
+
get length(): number;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Check if expression contains deep wildcard (..)
|
|
115
|
+
*/
|
|
116
|
+
hasDeepWildcard(): boolean;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Check if expression has attribute conditions
|
|
120
|
+
*/
|
|
121
|
+
hasAttributeCondition(): boolean;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Check if expression has position selectors
|
|
125
|
+
*/
|
|
126
|
+
hasPositionSelector(): boolean;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Get string representation
|
|
130
|
+
*/
|
|
131
|
+
toString(): string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Options for creating a Matcher
|
|
136
|
+
*/
|
|
137
|
+
export interface MatcherOptions {
|
|
138
|
+
/**
|
|
139
|
+
* Default path separator
|
|
140
|
+
* @default '.'
|
|
141
|
+
*/
|
|
142
|
+
separator?: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Internal node structure in the path stack
|
|
147
|
+
*/
|
|
148
|
+
export interface PathNode {
|
|
149
|
+
/**
|
|
150
|
+
* Tag name
|
|
151
|
+
*/
|
|
152
|
+
tag: string;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Namespace (if present)
|
|
156
|
+
*/
|
|
157
|
+
namespace?: string;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Position in sibling list (child index in parent)
|
|
161
|
+
*/
|
|
162
|
+
position: number;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Counter (occurrence count of this tag name)
|
|
166
|
+
*/
|
|
167
|
+
counter: number;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Attribute key-value pairs
|
|
171
|
+
* Only present for the current (last) node in path
|
|
172
|
+
*/
|
|
173
|
+
values?: Record<string, any>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Snapshot of matcher state
|
|
178
|
+
*/
|
|
179
|
+
export interface MatcherSnapshot {
|
|
180
|
+
/**
|
|
181
|
+
* Copy of the path stack
|
|
182
|
+
*/
|
|
183
|
+
path: PathNode[];
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Copy of sibling tracking maps
|
|
187
|
+
*/
|
|
188
|
+
siblingStacks: Map<string, number>[];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* MatcherView - A lightweight read-only view over a {@link Matcher} instance.
|
|
193
|
+
*
|
|
194
|
+
* Created once by {@link Matcher} and reused across all callbacks — no allocation
|
|
195
|
+
* on every invocation. Holds a direct reference to the parent Matcher's internal
|
|
196
|
+
* state so it always reflects the current parser position with zero copying or
|
|
197
|
+
* freezing overhead.
|
|
198
|
+
*
|
|
199
|
+
* Mutation methods (`push`, `pop`, `reset`, `updateCurrent`, `restore`) are simply
|
|
200
|
+
* absent from this class, so misuse is caught at compile time by TypeScript rather
|
|
201
|
+
* than at runtime.
|
|
202
|
+
*
|
|
203
|
+
* Obtain via {@link Matcher#readOnly} — the same instance is returned every time.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* const matcher = new Matcher();
|
|
208
|
+
* const view: MatcherView = matcher.readOnly();
|
|
209
|
+
*
|
|
210
|
+
* matcher.push("root", {});
|
|
211
|
+
* matcher.push("users", {});
|
|
212
|
+
* matcher.push("user", { id: "123" });
|
|
213
|
+
*
|
|
214
|
+
* view.matches(expr); // ✓ true
|
|
215
|
+
* view.getCurrentTag(); // ✓ "user"
|
|
216
|
+
* view.getDepth(); // ✓ 3
|
|
217
|
+
* // view.push(...) // ✗ Property 'push' does not exist on type 'MatcherView'
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
export class MatcherView {
|
|
221
|
+
/**
|
|
222
|
+
* Default path separator (read-only, delegates to parent Matcher)
|
|
223
|
+
*/
|
|
224
|
+
readonly separator: string;
|
|
225
|
+
|
|
226
|
+
getCurrentTag(): string | undefined;
|
|
227
|
+
getCurrentNamespace(): string | undefined;
|
|
228
|
+
getAttrValue(attrName: string): any;
|
|
229
|
+
hasAttr(attrName: string): boolean;
|
|
230
|
+
getPosition(): number;
|
|
231
|
+
getCounter(): number;
|
|
232
|
+
/** @deprecated Use getPosition() or getCounter() instead */
|
|
233
|
+
getIndex(): number;
|
|
234
|
+
getDepth(): number;
|
|
235
|
+
toString(separator?: string, includeNamespace?: boolean): string;
|
|
236
|
+
toArray(): string[];
|
|
237
|
+
matches(expression: Expression): boolean;
|
|
238
|
+
matchesAny(exprSet: ExpressionSet): boolean;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* @deprecated Use {@link MatcherView} instead.
|
|
243
|
+
* Alias kept for backward compatibility with code that references `ReadOnlyMatcher`.
|
|
244
|
+
*/
|
|
245
|
+
export type ReadOnlyMatcher = MatcherView;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Matcher - Tracks current path in XML/JSON tree and matches against Expressions.
|
|
249
|
+
*
|
|
250
|
+
* The matcher maintains a stack of nodes representing the current path from root to
|
|
251
|
+
* current tag. It only stores attribute values for the current (top) node to minimize
|
|
252
|
+
* memory usage.
|
|
253
|
+
*
|
|
254
|
+
* Use {@link Matcher#readOnly} to obtain a {@link MatcherView} safe to pass to
|
|
255
|
+
* user callbacks — the same instance is reused on every call with no allocation overhead.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```typescript
|
|
259
|
+
* const matcher = new Matcher();
|
|
260
|
+
* matcher.push("root", {});
|
|
261
|
+
* matcher.push("users", {});
|
|
262
|
+
* matcher.push("user", { id: "123", type: "admin" });
|
|
263
|
+
*
|
|
264
|
+
* const expr = new Expression("root.users.user");
|
|
265
|
+
* matcher.matches(expr); // true
|
|
266
|
+
*
|
|
267
|
+
* matcher.pop();
|
|
268
|
+
* matcher.matches(expr); // false
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
export class Matcher {
|
|
272
|
+
/**
|
|
273
|
+
* Default path separator
|
|
274
|
+
*/
|
|
275
|
+
readonly separator: string;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Create a new Matcher
|
|
279
|
+
* @param options - Configuration options
|
|
280
|
+
*/
|
|
281
|
+
constructor(options?: MatcherOptions);
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Push a new tag onto the path.
|
|
285
|
+
* @param tagName - Name of the tag
|
|
286
|
+
* @param attrValues - Attribute key-value pairs for current node (optional)
|
|
287
|
+
* @param namespace - Namespace for the tag (optional)
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* matcher.push("user", { id: "123", type: "admin" });
|
|
292
|
+
* matcher.push("user", { id: "456" }, "ns");
|
|
293
|
+
* matcher.push("container", null);
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
push(tagName: string, attrValues?: Record<string, any> | null, namespace?: string | null): void;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Pop the last tag from the path.
|
|
300
|
+
* @returns The popped node or undefined if path is empty
|
|
301
|
+
*/
|
|
302
|
+
pop(): PathNode | undefined;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Update current node's attribute values.
|
|
306
|
+
* Useful when attributes are parsed after push.
|
|
307
|
+
* @param attrValues - Attribute values
|
|
308
|
+
*/
|
|
309
|
+
updateCurrent(attrValues: Record<string, any>): void;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Reset the path to empty.
|
|
313
|
+
*/
|
|
314
|
+
reset(): void;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Create a snapshot of current state.
|
|
318
|
+
* @returns State snapshot that can be restored later
|
|
319
|
+
*/
|
|
320
|
+
snapshot(): MatcherSnapshot;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Restore state from snapshot.
|
|
324
|
+
* @param snapshot - State snapshot from previous snapshot() call
|
|
325
|
+
*/
|
|
326
|
+
restore(snapshot: MatcherSnapshot): void;
|
|
327
|
+
|
|
328
|
+
getCurrentTag(): string | undefined;
|
|
329
|
+
getCurrentNamespace(): string | undefined;
|
|
330
|
+
getAttrValue(attrName: string): any;
|
|
331
|
+
hasAttr(attrName: string): boolean;
|
|
332
|
+
getPosition(): number;
|
|
333
|
+
getCounter(): number;
|
|
334
|
+
/** @deprecated Use getPosition() or getCounter() instead */
|
|
335
|
+
getIndex(): number;
|
|
336
|
+
getDepth(): number;
|
|
337
|
+
toString(separator?: string, includeNamespace?: boolean): string;
|
|
338
|
+
toArray(): string[];
|
|
339
|
+
matches(expression: Expression): boolean;
|
|
340
|
+
matchesAny(exprSet: ExpressionSet): boolean;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Return the read-only {@link MatcherView} for this matcher.
|
|
344
|
+
*
|
|
345
|
+
* The same instance is returned on every call — no allocation occurs.
|
|
346
|
+
* Pass this to user callbacks; it always reflects current parser state.
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```typescript
|
|
350
|
+
* const view = matcher.readOnly();
|
|
351
|
+
* // same reference every time — safe to cache
|
|
352
|
+
* view === matcher.readOnly(); // true
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
readOnly(): MatcherView;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* ExpressionSet - An indexed collection of Expressions for efficient bulk matching
|
|
360
|
+
*
|
|
361
|
+
* Pre-indexes expressions at insertion time by depth and terminal tag name so
|
|
362
|
+
* that `matchesAny()` performs an O(1) bucket lookup rather than a full O(E)
|
|
363
|
+
* linear scan on every tag.
|
|
364
|
+
*
|
|
365
|
+
* Three internal buckets are maintained automatically:
|
|
366
|
+
* - **exact** — expressions with a fixed depth and a concrete terminal tag
|
|
367
|
+
* - **depth-wildcard** — fixed depth but terminal tag is `*`
|
|
368
|
+
* - **deep-wildcard** — expressions containing `..` (cannot be depth-indexed)
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```typescript
|
|
372
|
+
* import { Expression, ExpressionSet, Matcher } from 'fast-xml-tagger';
|
|
373
|
+
*
|
|
374
|
+
* // Build once at config time
|
|
375
|
+
* const stopNodes = new ExpressionSet();
|
|
376
|
+
* stopNodes
|
|
377
|
+
* .add(new Expression('root.users.user'))
|
|
378
|
+
* .add(new Expression('root.config.*'))
|
|
379
|
+
* .add(new Expression('..script'))
|
|
380
|
+
* .seal(); // prevent accidental mutation during parsing
|
|
381
|
+
*
|
|
382
|
+
* // Query on every tag — hot path
|
|
383
|
+
* if (stopNodes.matchesAny(matcher)) {
|
|
384
|
+
* // handle stop node
|
|
385
|
+
* }
|
|
386
|
+
* ```
|
|
387
|
+
*/
|
|
388
|
+
export class ExpressionSet {
|
|
389
|
+
/**
|
|
390
|
+
* Create an empty ExpressionSet.
|
|
391
|
+
*/
|
|
392
|
+
constructor();
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Number of expressions currently in the set.
|
|
396
|
+
*/
|
|
397
|
+
readonly size: number;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Whether the set has been sealed against further modifications.
|
|
401
|
+
*/
|
|
402
|
+
readonly isSealed: boolean;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Add a single Expression to the set.
|
|
406
|
+
*
|
|
407
|
+
* Duplicate patterns (same `expression.pattern` string) are silently ignored.
|
|
408
|
+
*
|
|
409
|
+
* @param expression - A pre-constructed Expression instance
|
|
410
|
+
* @returns `this` — for chaining
|
|
411
|
+
* @throws {TypeError} if the set has been sealed
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* ```typescript
|
|
415
|
+
* set.add(new Expression('root.users.user'));
|
|
416
|
+
* set.add(new Expression('..script'));
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
add(expression: Expression): this;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Add multiple expressions at once.
|
|
423
|
+
*
|
|
424
|
+
* @param expressions - Array of Expression instances
|
|
425
|
+
* @returns `this` — for chaining
|
|
426
|
+
* @throws {TypeError} if the set has been sealed
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* ```typescript
|
|
430
|
+
* set.addAll([
|
|
431
|
+
* new Expression('root.users.user'),
|
|
432
|
+
* new Expression('root.config.setting'),
|
|
433
|
+
* ]);
|
|
434
|
+
* ```
|
|
435
|
+
*/
|
|
436
|
+
addAll(expressions: Expression[]): this;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Check whether an Expression with the same pattern is already present.
|
|
440
|
+
*
|
|
441
|
+
* @param expression - Expression to look up
|
|
442
|
+
* @returns `true` if the pattern was already added
|
|
443
|
+
*/
|
|
444
|
+
has(expression: Expression): boolean;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Seal the set against further modifications.
|
|
448
|
+
*
|
|
449
|
+
* After calling `seal()`, any call to `add()` or `addAll()` will throw a
|
|
450
|
+
* `TypeError`. This is useful to prevent accidental mutation once the config
|
|
451
|
+
* has been fully built and parsing has started.
|
|
452
|
+
*
|
|
453
|
+
* @returns `this` — for chaining
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* ```typescript
|
|
457
|
+
* const stopNodes = new ExpressionSet();
|
|
458
|
+
* stopNodes.addAll(patterns.map(p => new Expression(p))).seal();
|
|
459
|
+
*
|
|
460
|
+
* // Later — safe: reads are still allowed
|
|
461
|
+
* stopNodes.matchesAny(matcher);
|
|
462
|
+
*
|
|
463
|
+
* // Later — throws TypeError: ExpressionSet is sealed
|
|
464
|
+
* stopNodes.add(new Expression('root.extra'));
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
seal(): this;
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Test whether the matcher's current path matches **any** expression in the set.
|
|
471
|
+
*
|
|
472
|
+
* Uses the pre-built index to evaluate only the relevant bucket(s):
|
|
473
|
+
* 1. Exact depth + tag — O(1) lookup
|
|
474
|
+
* 2. Depth-matched wildcard tag — O(1) lookup
|
|
475
|
+
* 3. Deep-wildcard expressions — always scanned (typically a small list)
|
|
476
|
+
*
|
|
477
|
+
* @param matcher - A `Matcher` instance or a `ReadOnlyMatcher` view
|
|
478
|
+
* @returns `true` if at least one expression matches the current path
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* ```typescript
|
|
482
|
+
* // Replaces:
|
|
483
|
+
* // for (const expr of stopNodeExpressions) {
|
|
484
|
+
* // if (matcher.matches(expr)) return true;
|
|
485
|
+
* // }
|
|
486
|
+
*
|
|
487
|
+
* if (stopNodes.matchesAny(matcher)) {
|
|
488
|
+
* // current tag is a stop node
|
|
489
|
+
* }
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
matchesAny(matcher: Matcher | MatcherView): boolean;
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Find the first expression in the set that matches the matcher's current path.
|
|
496
|
+
*
|
|
497
|
+
* Uses the pre-built index to evaluate only the relevant bucket(s):
|
|
498
|
+
* 1. Exact depth + tag — O(1) lookup
|
|
499
|
+
* 2. Depth-matched wildcard tag — O(1) lookup
|
|
500
|
+
* 3. Deep-wildcard expressions — always scanned (typically a small list)
|
|
501
|
+
*
|
|
502
|
+
* @param matcher - A `Matcher` instance or a `ReadOnlyMatcher` view
|
|
503
|
+
* @returns Expression if at least one expression matches the current path
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
* ```typescript
|
|
507
|
+
* const node = stopNodes.findMatch(matcher);
|
|
508
|
+
* ```
|
|
509
|
+
*/
|
|
510
|
+
findMatch(matcher: Matcher | MatcherView): Expression;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Default export containing Expression, Matcher, and ExpressionSet
|
|
515
|
+
*/
|
|
516
|
+
declare const _default: {
|
|
517
|
+
Expression: typeof Expression;
|
|
518
|
+
Matcher: typeof Matcher;
|
|
519
|
+
MatcherView: typeof MatcherView;
|
|
520
|
+
ExpressionSet: typeof ExpressionSet;
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fast-xml-tagger - XML/JSON path matching library
|
|
3
|
+
*
|
|
4
|
+
* Provides efficient path tracking and pattern matching for XML/JSON parsers.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* import { Expression, Matcher } from 'fast-xml-tagger';
|
|
8
|
+
*
|
|
9
|
+
* // Create expression (parse once)
|
|
10
|
+
* const expr = new Expression("root.users.user[id]");
|
|
11
|
+
*
|
|
12
|
+
* // Create matcher (track path)
|
|
13
|
+
* const matcher = new Matcher();
|
|
14
|
+
* matcher.push("root", [], {}, 0);
|
|
15
|
+
* matcher.push("users", [], {}, 0);
|
|
16
|
+
* matcher.push("user", ["id", "type"], { id: "123", type: "admin" }, 0);
|
|
17
|
+
*
|
|
18
|
+
* // Match
|
|
19
|
+
* if (matcher.matches(expr)) {
|
|
20
|
+
* console.log("Match found!");
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import Expression from './Expression.js';
|
|
25
|
+
import Matcher from './Matcher.js';
|
|
26
|
+
import ExpressionSet from './ExpressionSet.js';
|
|
27
|
+
|
|
28
|
+
export { Expression, Matcher, ExpressionSet };
|
|
29
|
+
export default { Expression, Matcher, ExpressionSet };
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
**2.
|
|
3
|
-
- remove unnecessary
|
|
2
|
+
**2.2.3 / 2026-04-07**
|
|
3
|
+
- remove unnecessary files from npm package
|
|
4
|
+
|
|
5
|
+
**2.2.2 / 2026-03-23**
|
|
6
|
+
- fix for space string
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
**2.2.1 / 2026-03-19**
|
|
10
|
+
- fix false positive for eNotation when no leading zeros
|
|
11
|
+
|
|
12
|
+
**2.2.0 / 2026-02-28**
|
|
13
|
+
- support infinity
|
|
4
14
|
|
|
5
15
|
**2.1.0 / 2025-05-01**
|
|
6
16
|
- fix e-notation
|
|
@@ -94,6 +94,7 @@ hex: true, //when hexadecimal string should be parsed
|
|
|
94
94
|
leadingZeros: true, //when number with leading zeros like 08 should be parsed. 0.0 is not impacted
|
|
95
95
|
eNotation: true, //when number with eNotation or number parsed in eNotation should be considered
|
|
96
96
|
skipLike: /regex/ //when string should not be parsed when it matches the specified regular expression
|
|
97
|
+
infinity: "original", // "null", "infinity" (Infinity type), "string" ("Infinity" (the string literal))
|
|
97
98
|
```
|
|
98
99
|
|
|
99
100
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strnum",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Parse String to Number based on configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "strnum.js",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "jasmine
|
|
8
|
+
"test": "jasmine tests/*_test.js"
|
|
9
9
|
},
|
|
10
10
|
"keywords": [
|
|
11
11
|
"string",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"type": "git",
|
|
18
18
|
"url": "https://github.com/NaturalIntelligence/strnum"
|
|
19
19
|
},
|
|
20
|
-
"author": "Amit Gupta (https://
|
|
20
|
+
"author": "Amit Gupta (https://solothought.work/)",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"funding": [
|
|
23
23
|
{
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
}
|
|
27
27
|
],
|
|
28
28
|
"devDependencies": {
|
|
29
|
+
"@byspec/numbers": "^0.1.1",
|
|
29
30
|
"jasmine": "^5.6.0"
|
|
30
31
|
}
|
|
31
|
-
}
|
|
32
|
+
}
|