@cdk8s/awscdk-resolver 0.0.510 → 0.0.511
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 +3 -3
- package/lib/resolve.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/package.json +1 -1
- package/node_modules/fast-xml-builder/CHANGELOG.md +13 -0
- package/node_modules/fast-xml-builder/lib/fxb.d.cts +7 -8
- package/node_modules/fast-xml-builder/package.json +2 -2
- package/node_modules/fast-xml-builder/src/fxb.d.ts +11 -3
- package/node_modules/path-expression-matcher/lib/pem.cjs +1 -0
- package/node_modules/path-expression-matcher/lib/pem.d.cts +335 -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 +32 -6
- package/node_modules/path-expression-matcher/src/index.d.ts +366 -0
- package/package.json +2 -2
package/.jsii
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"url": "https://aws.amazon.com"
|
|
8
8
|
},
|
|
9
9
|
"bundled": {
|
|
10
|
-
"@aws-sdk/client-cloudformation": "^3.
|
|
10
|
+
"@aws-sdk/client-cloudformation": "^3.1007.0"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"aws-cdk-lib": "^2.195.0",
|
|
@@ -4082,6 +4082,6 @@
|
|
|
4082
4082
|
"symbolId": "src/resolve:AwsCdkResolver"
|
|
4083
4083
|
}
|
|
4084
4084
|
},
|
|
4085
|
-
"version": "0.0.
|
|
4086
|
-
"fingerprint": "
|
|
4085
|
+
"version": "0.0.511",
|
|
4086
|
+
"fingerprint": "QHoVdVCKoozRaal/LJeMeNK582+yRvP46gko8aVA8sQ="
|
|
4087
4087
|
}
|
package/lib/resolve.js
CHANGED
|
@@ -61,5 +61,5 @@ class AwsCdkResolver {
|
|
|
61
61
|
}
|
|
62
62
|
exports.AwsCdkResolver = AwsCdkResolver;
|
|
63
63
|
_a = JSII_RTTI_SYMBOL_1;
|
|
64
|
-
AwsCdkResolver[_a] = { fqn: "@cdk8s/awscdk-resolver.AwsCdkResolver", version: "0.0.
|
|
64
|
+
AwsCdkResolver[_a] = { fqn: "@cdk8s/awscdk-resolver.AwsCdkResolver", version: "0.0.511" };
|
|
65
65
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVzb2x2ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9yZXNvbHZlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsaURBQTZDO0FBQzdDLDZCQUE2QjtBQUM3Qiw2Q0FBK0U7QUFJL0UsTUFBYSxjQUFjO0lBRWxCLE9BQU8sQ0FBQyxPQUEwQjtRQUV2QyxJQUFJLENBQUMsbUJBQUssQ0FBQyxZQUFZLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxFQUFFLENBQUM7WUFDdkMsT0FBTztRQUNULENBQUM7UUFFRCxJQUFJLE9BQU8sT0FBTyxDQUFDLEtBQUssS0FBSyxRQUFRLEVBQUUsQ0FBQztZQUN0QywrREFBK0Q7WUFDL0QsbUJBQW1CO1lBQ25CLE1BQU0sSUFBSSxLQUFLLENBQUMsdUJBQXVCLE9BQU0sQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLHNCQUFzQixDQUFDLENBQUM7UUFDdEYsQ0FBQztRQUVELE1BQU0sTUFBTSxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFDO1FBQzlDLElBQUksQ0FBQztZQUNILE1BQU0sV0FBVyxHQUFHLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxNQUFNLENBQUMsQ0FBQztZQUNsRCxPQUFPLENBQUMsWUFBWSxDQUFDLFdBQVcsQ0FBQyxDQUFDO1FBQ3BDLENBQUM7UUFBQy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GlwZSddIH0pLnRvU3RyaW5nKCkudHJpbSgpKTtcblxuICB9XG5cbn1cbiJdfQ==
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/client-cloudformation",
|
|
3
3
|
"description": "AWS SDK for JavaScript Cloudformation Client for Node.js, Browser and React Native",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.1007.0",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
|
|
7
7
|
"build:cjs": "node ../../scripts/compilation/inline client-cloudformation",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
**1.1.2** (2026-03-11)
|
|
5
|
+
- fix typings
|
|
6
|
+
|
|
7
|
+
**1.1.1** (2026-03-11)
|
|
8
|
+
- upgrade path-expression-matcher to 1.1.3
|
|
9
|
+
|
|
10
|
+
**1.1.0** (2026-03-10)
|
|
11
|
+
|
|
12
|
+
- Integrate [path-expression-matcher](https://github.com/NaturalIntelligence/path-expression-matcher)
|
|
13
|
+
|
|
@@ -157,16 +157,15 @@ type XmlBuilderOptions = {
|
|
|
157
157
|
oneListGroup?: boolean;
|
|
158
158
|
};
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
constructor(options?: XmlBuilderOptions);
|
|
160
|
+
interface XMLBuilder {
|
|
162
161
|
build(jObj: any): string;
|
|
163
162
|
}
|
|
164
163
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
XmlBuilderOptions,
|
|
169
|
-
}
|
|
164
|
+
interface XMLBuilderConstructor {
|
|
165
|
+
new(options?: XmlBuilderOptions): XMLBuilder;
|
|
166
|
+
(options?: XmlBuilderOptions): XMLBuilder;
|
|
170
167
|
}
|
|
171
168
|
|
|
172
|
-
|
|
169
|
+
declare const Builder: XMLBuilderConstructor;
|
|
170
|
+
|
|
171
|
+
export = Builder;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fast-xml-builder",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Build XML from JSON without C/C++ based libraries",
|
|
5
5
|
"main": "./lib/fxb.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -75,6 +75,6 @@
|
|
|
75
75
|
}
|
|
76
76
|
],
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"path-expression-matcher": "^1.1.
|
|
78
|
+
"path-expression-matcher": "^1.1.3"
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -156,7 +156,15 @@ export type XmlBuilderOptions = {
|
|
|
156
156
|
oneListGroup?: boolean;
|
|
157
157
|
};
|
|
158
158
|
|
|
159
|
-
export
|
|
160
|
-
constructor(options?: XmlBuilderOptions);
|
|
159
|
+
export interface XMLBuilder {
|
|
161
160
|
build(jObj: any): string;
|
|
162
|
-
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface XMLBuilderConstructor {
|
|
164
|
+
new(options?: XmlBuilderOptions): XMLBuilder;
|
|
165
|
+
(options?: XmlBuilderOptions): XMLBuilder;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
declare const Builder: XMLBuilderConstructor;
|
|
169
|
+
|
|
170
|
+
export default Builder;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Expression:()=>s,Matcher:()=>i,default:()=>n});class s{constructor(t,e={}){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let s=0,i="";for(;s<t.length;)t[s]===this.separator?s+1<t.length&&t[s+1]===this.separator?(i.trim()&&(e.push(this._parseSegment(i.trim())),i=""),e.push({type:"deep-wildcard"}),s+=2):(i.trim()&&e.push(this._parseSegment(i.trim())),i="",s++):(i+=t[s],s++);return i.trim()&&e.push(this._parseSegment(i.trim())),e}_parseSegment(t){const e={type:"tag"};let s=null,i=t;const n=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(n&&(i=n[1]+n[3],n[2])){const t=n[2].slice(1,-1);t&&(s=t)}let r,a,h=i;if(i.includes("::")){const e=i.indexOf("::");if(r=i.substring(0,e).trim(),h=i.substring(e+2).trim(),!r)throw new Error(`Invalid namespace in pattern: ${t}`)}let o=null;if(h.includes(":")){const t=h.lastIndexOf(":"),e=h.substring(0,t).trim(),s=h.substring(t+1).trim();["first","last","odd","even"].includes(s)||/^nth\(\d+\)$/.test(s)?(a=e,o=s):a=h}else a=h;if(!a)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=a,r&&(e.namespace=r),s)if(s.includes("=")){const t=s.indexOf("=");e.attrName=s.substring(0,t).trim(),e.attrValue=s.substring(t+1).trim()}else e.attrName=s.trim();if(o){const t=o.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=o}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class i{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[]}push(t,e=null,s=null){this.path.length>0&&(this.path[this.path.length-1].values=void 0);const i=this.path.length;this.siblingStacks[i]||(this.siblingStacks[i]=new Map);const n=this.siblingStacks[i],r=s?`${s}:${t}`:t,a=n.get(r)||0;let h=0;for(const t of n.values())h+=t;n.set(r,a+1);const o={tag:t,position:h,counter:a};null!=s&&(o.namespace=s),null!=e&&(o.values=e),this.path.push(o)}pop(){if(0===this.path.length)return;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0===this.path.length)return;const e=this.path[this.path.length-1];return e.values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const s=t||this.separator;return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s)}toArray(){return this.path.map(t=>t.tag)}reset(){this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++){const s=t[e],i=this.path[e],n=e===this.path.length-1;if(!this._matchSegment(s,i,n))return!1}return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,s=t.length-1;for(;s>=0&&e>=0;){const i=t[s];if("deep-wildcard"===i.type){if(s--,s<0)return!0;const i=t[s];let n=!1;for(let t=e;t>=0;t--){const r=t===this.path.length-1;if(this._matchSegment(i,this.path[t],r)){e=t-1,s--,n=!0;break}}if(!n)return!1}else{const t=e===this.path.length-1;if(!this._matchSegment(i,this.path[e],t))return!1;e--,s--}}return s<0}_matchSegment(t,e,s){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!s)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue){const s=e.values[t.attrName];if(String(s)!==String(t.attrValue))return!1}}if(void 0!==t.position){if(!s)return!1;const i=e.counter??0;if("first"===t.position&&0!==i)return!1;if("odd"===t.position&&i%2!=1)return!1;if("even"===t.position&&i%2!=0)return!1;if("nth"===t.position&&i!==t.positionValue)return!1}return!0}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>new Map(t))}}const n={Expression:s,Matcher:i};module.exports=e})();
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript definitions for path-expression-matcher (CommonJS)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options for creating an Expression
|
|
7
|
+
*/
|
|
8
|
+
declare interface ExpressionOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Path separator character
|
|
11
|
+
* @default '.'
|
|
12
|
+
*/
|
|
13
|
+
separator?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Parsed segment from an expression pattern
|
|
18
|
+
*/
|
|
19
|
+
declare interface Segment {
|
|
20
|
+
/**
|
|
21
|
+
* Type of segment
|
|
22
|
+
*/
|
|
23
|
+
type: 'tag' | 'deep-wildcard';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Tag name (e.g., "user", "*" for wildcard)
|
|
27
|
+
* Only present when type is 'tag'
|
|
28
|
+
*/
|
|
29
|
+
tag?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Namespace prefix (e.g., "ns" in "ns::user")
|
|
33
|
+
* Only present when namespace is specified
|
|
34
|
+
*/
|
|
35
|
+
namespace?: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Attribute name to match (e.g., "id" in "user[id]")
|
|
39
|
+
* Only present when attribute condition exists
|
|
40
|
+
*/
|
|
41
|
+
attrName?: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Attribute value to match (e.g., "123" in "user[id=123]")
|
|
45
|
+
* Only present when attribute value is specified
|
|
46
|
+
*/
|
|
47
|
+
attrValue?: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Position selector type
|
|
51
|
+
* Only present when position selector exists
|
|
52
|
+
*/
|
|
53
|
+
position?: 'first' | 'last' | 'odd' | 'even' | 'nth';
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Numeric value for nth() selector
|
|
57
|
+
* Only present when position is 'nth'
|
|
58
|
+
*/
|
|
59
|
+
positionValue?: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Expression - Parses and stores a tag pattern expression
|
|
64
|
+
*
|
|
65
|
+
* Patterns are parsed once and stored in an optimized structure for fast matching.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```javascript
|
|
69
|
+
* const { Expression } = require('path-expression-matcher');
|
|
70
|
+
* const expr = new Expression("root.users.user");
|
|
71
|
+
* const expr2 = new Expression("..user[id]:first");
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare class Expression {
|
|
75
|
+
/**
|
|
76
|
+
* Original pattern string
|
|
77
|
+
*/
|
|
78
|
+
readonly pattern: string;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Path separator character
|
|
82
|
+
*/
|
|
83
|
+
readonly separator: string;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Parsed segments
|
|
87
|
+
*/
|
|
88
|
+
readonly segments: Segment[];
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Create a new Expression
|
|
92
|
+
* @param pattern - Pattern string (e.g., "root.users.user", "..user[id]")
|
|
93
|
+
* @param options - Configuration options
|
|
94
|
+
*/
|
|
95
|
+
constructor(pattern: string, options?: ExpressionOptions);
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Get the number of segments
|
|
99
|
+
*/
|
|
100
|
+
get length(): number;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Check if expression contains deep wildcard (..)
|
|
104
|
+
*/
|
|
105
|
+
hasDeepWildcard(): boolean;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Check if expression has attribute conditions
|
|
109
|
+
*/
|
|
110
|
+
hasAttributeCondition(): boolean;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Check if expression has position selectors
|
|
114
|
+
*/
|
|
115
|
+
hasPositionSelector(): boolean;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Get string representation
|
|
119
|
+
*/
|
|
120
|
+
toString(): string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Options for creating a Matcher
|
|
125
|
+
*/
|
|
126
|
+
declare interface MatcherOptions {
|
|
127
|
+
/**
|
|
128
|
+
* Default path separator
|
|
129
|
+
* @default '.'
|
|
130
|
+
*/
|
|
131
|
+
separator?: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Internal node structure in the path stack
|
|
136
|
+
*/
|
|
137
|
+
declare interface PathNode {
|
|
138
|
+
/**
|
|
139
|
+
* Tag name
|
|
140
|
+
*/
|
|
141
|
+
tag: string;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Namespace (if present)
|
|
145
|
+
*/
|
|
146
|
+
namespace?: string;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Position in sibling list (child index in parent)
|
|
150
|
+
*/
|
|
151
|
+
position: number;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Counter (occurrence count of this tag name)
|
|
155
|
+
*/
|
|
156
|
+
counter: number;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Attribute key-value pairs
|
|
160
|
+
* Only present for the current (last) node in path
|
|
161
|
+
*/
|
|
162
|
+
values?: Record<string, any>;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Snapshot of matcher state
|
|
167
|
+
*/
|
|
168
|
+
declare interface MatcherSnapshot {
|
|
169
|
+
/**
|
|
170
|
+
* Copy of the path stack
|
|
171
|
+
*/
|
|
172
|
+
path: PathNode[];
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Copy of sibling tracking maps
|
|
176
|
+
*/
|
|
177
|
+
siblingStacks: Map<string, number>[];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Matcher - Tracks current path in XML/JSON tree and matches against Expressions
|
|
182
|
+
*
|
|
183
|
+
* The matcher maintains a stack of nodes representing the current path from root to
|
|
184
|
+
* current tag. It only stores attribute values for the current (top) node to minimize
|
|
185
|
+
* memory usage.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```javascript
|
|
189
|
+
* const { Matcher } = require('path-expression-matcher');
|
|
190
|
+
* const matcher = new Matcher();
|
|
191
|
+
* matcher.push("root", {});
|
|
192
|
+
* matcher.push("users", {});
|
|
193
|
+
* matcher.push("user", { id: "123", type: "admin" });
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
declare class Matcher {
|
|
197
|
+
/**
|
|
198
|
+
* Default path separator
|
|
199
|
+
*/
|
|
200
|
+
readonly separator: string;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Current path stack
|
|
204
|
+
*/
|
|
205
|
+
readonly path: PathNode[];
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Create a new Matcher
|
|
209
|
+
* @param options - Configuration options
|
|
210
|
+
*/
|
|
211
|
+
constructor(options?: MatcherOptions);
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Push a new tag onto the path
|
|
215
|
+
* @param tagName - Name of the tag
|
|
216
|
+
* @param attrValues - Attribute key-value pairs for current node (optional)
|
|
217
|
+
* @param namespace - Namespace for the tag (optional)
|
|
218
|
+
*/
|
|
219
|
+
push(tagName: string, attrValues?: Record<string, any> | null, namespace?: string | null): void;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Pop the last tag from the path
|
|
223
|
+
* @returns The popped node or undefined if path is empty
|
|
224
|
+
*/
|
|
225
|
+
pop(): PathNode | undefined;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Update current node's attribute values
|
|
229
|
+
* Useful when attributes are parsed after push
|
|
230
|
+
* @param attrValues - Attribute values
|
|
231
|
+
*/
|
|
232
|
+
updateCurrent(attrValues: Record<string, any>): void;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Get current tag name
|
|
236
|
+
* @returns Current tag name or undefined if path is empty
|
|
237
|
+
*/
|
|
238
|
+
getCurrentTag(): string | undefined;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Get current namespace
|
|
242
|
+
* @returns Current namespace or undefined if not present or path is empty
|
|
243
|
+
*/
|
|
244
|
+
getCurrentNamespace(): string | undefined;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Get current node's attribute value
|
|
248
|
+
* @param attrName - Attribute name
|
|
249
|
+
* @returns Attribute value or undefined
|
|
250
|
+
*/
|
|
251
|
+
getAttrValue(attrName: string): any;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Check if current node has an attribute
|
|
255
|
+
* @param attrName - Attribute name
|
|
256
|
+
*/
|
|
257
|
+
hasAttr(attrName: string): boolean;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Get current node's sibling position (child index in parent)
|
|
261
|
+
* @returns Position index or -1 if path is empty
|
|
262
|
+
*/
|
|
263
|
+
getPosition(): number;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Get current node's repeat counter (occurrence count of this tag name)
|
|
267
|
+
* @returns Counter value or -1 if path is empty
|
|
268
|
+
*/
|
|
269
|
+
getCounter(): number;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Get current node's sibling index (alias for getPosition for backward compatibility)
|
|
273
|
+
* @returns Index or -1 if path is empty
|
|
274
|
+
* @deprecated Use getPosition() or getCounter() instead
|
|
275
|
+
*/
|
|
276
|
+
getIndex(): number;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Get current path depth
|
|
280
|
+
* @returns Number of nodes in the path
|
|
281
|
+
*/
|
|
282
|
+
getDepth(): number;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Get path as string
|
|
286
|
+
* @param separator - Optional separator (uses default if not provided)
|
|
287
|
+
* @param includeNamespace - Whether to include namespace in output
|
|
288
|
+
* @returns Path string (e.g., "root.users.user" or "ns:root.ns:users.user")
|
|
289
|
+
*/
|
|
290
|
+
toString(separator?: string, includeNamespace?: boolean): string;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Get path as array of tag names
|
|
294
|
+
* @returns Array of tag names
|
|
295
|
+
*/
|
|
296
|
+
toArray(): string[];
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Reset the path to empty
|
|
300
|
+
*/
|
|
301
|
+
reset(): void;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Match current path against an Expression
|
|
305
|
+
* @param expression - The expression to match against
|
|
306
|
+
* @returns True if current path matches the expression
|
|
307
|
+
*/
|
|
308
|
+
matches(expression: Expression): boolean;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Create a snapshot of current state
|
|
312
|
+
* @returns State snapshot that can be restored later
|
|
313
|
+
*/
|
|
314
|
+
snapshot(): MatcherSnapshot;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Restore state from snapshot
|
|
318
|
+
* @param snapshot - State snapshot from previous snapshot() call
|
|
319
|
+
*/
|
|
320
|
+
restore(snapshot: MatcherSnapshot): void;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
declare namespace pathExpressionMatcher {
|
|
324
|
+
export {
|
|
325
|
+
Expression,
|
|
326
|
+
Matcher,
|
|
327
|
+
ExpressionOptions,
|
|
328
|
+
MatcherOptions,
|
|
329
|
+
Segment,
|
|
330
|
+
PathNode,
|
|
331
|
+
MatcherSnapshot,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export = pathExpressionMatcher;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.pem=e():t.pem=e()}(this,()=>(()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Expression:()=>s,Matcher:()=>i,default:()=>n});class s{constructor(t,e={}){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let s=0,i="";for(;s<t.length;)t[s]===this.separator?s+1<t.length&&t[s+1]===this.separator?(i.trim()&&(e.push(this._parseSegment(i.trim())),i=""),e.push({type:"deep-wildcard"}),s+=2):(i.trim()&&e.push(this._parseSegment(i.trim())),i="",s++):(i+=t[s],s++);return i.trim()&&e.push(this._parseSegment(i.trim())),e}_parseSegment(t){const e={type:"tag"};let s=null,i=t;const n=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(n&&(i=n[1]+n[3],n[2])){const t=n[2].slice(1,-1);t&&(s=t)}let r,a,h=i;if(i.includes("::")){const e=i.indexOf("::");if(r=i.substring(0,e).trim(),h=i.substring(e+2).trim(),!r)throw new Error(`Invalid namespace in pattern: ${t}`)}let o=null;if(h.includes(":")){const t=h.lastIndexOf(":"),e=h.substring(0,t).trim(),s=h.substring(t+1).trim();["first","last","odd","even"].includes(s)||/^nth\(\d+\)$/.test(s)?(a=e,o=s):a=h}else a=h;if(!a)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=a,r&&(e.namespace=r),s)if(s.includes("=")){const t=s.indexOf("=");e.attrName=s.substring(0,t).trim(),e.attrValue=s.substring(t+1).trim()}else e.attrName=s.trim();if(o){const t=o.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=o}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class i{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[]}push(t,e=null,s=null){this.path.length>0&&(this.path[this.path.length-1].values=void 0);const i=this.path.length;this.siblingStacks[i]||(this.siblingStacks[i]=new Map);const n=this.siblingStacks[i],r=s?`${s}:${t}`:t,a=n.get(r)||0;let h=0;for(const t of n.values())h+=t;n.set(r,a+1);const o={tag:t,position:h,counter:a};null!=s&&(o.namespace=s),null!=e&&(o.values=e),this.path.push(o)}pop(){if(0===this.path.length)return;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0===this.path.length)return;const e=this.path[this.path.length-1];return e.values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const s=t||this.separator;return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s)}toArray(){return this.path.map(t=>t.tag)}reset(){this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++){const s=t[e],i=this.path[e],n=e===this.path.length-1;if(!this._matchSegment(s,i,n))return!1}return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,s=t.length-1;for(;s>=0&&e>=0;){const i=t[s];if("deep-wildcard"===i.type){if(s--,s<0)return!0;const i=t[s];let n=!1;for(let t=e;t>=0;t--){const r=t===this.path.length-1;if(this._matchSegment(i,this.path[t],r)){e=t-1,s--,n=!0;break}}if(!n)return!1}else{const t=e===this.path.length-1;if(!this._matchSegment(i,this.path[e],t))return!1;e--,s--}}return s<0}_matchSegment(t,e,s){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!s)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue){const s=e.values[t.attrName];if(String(s)!==String(t.attrValue))return!1}}if(void 0!==t.position){if(!s)return!1;const i=e.counter??0;if("first"===t.position&&0!==i)return!1;if("odd"===t.position&&i%2!=1)return!1;if("even"===t.position&&i%2!=0)return!1;if("nth"===t.position&&i!==t.positionValue)return!1}return!0}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>new Map(t))}}const n={Expression:s,Matcher:i};return e})());
|
|
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CAEX,CACF,CAGA,QAAyBjC,IAArBW,EAAQR,SAAwB,CAClC,IAAK0E,EAEH,OAAO,EAGT,MAAM1B,EAAUG,EAAKH,SAAW,EAEhC,GAAyB,UAArBxC,EAAQR,UAAoC,IAAZgD,EAClC,OAAO,EACF,GAAyB,QAArBxC,EAAQR,UAAsBgD,EAAU,GAAM,EACvD,OAAO,EACF,GAAyB,SAArBxC,EAAQR,UAAuBgD,EAAU,GAAM,EACxD,OAAO,EACF,GAAyB,QAArBxC,EAAQR,UACbgD,IAAYxC,EAAQwB,cACtB,OAAO,CAGb,CAEA,OAAO,CACT,CAMAkD,QAAAA,GACE,MAAO,CACL3C,KAAMvE,KAAKuE,KAAK0B,IAAId,IAAQ,IAAMA,KAClCX,cAAexE,KAAKwE,cAAcyB,IAAIA,GAAO,IAAIpB,IAAIoB,IAEzD,CAMAkB,OAAAA,CAAQD,GACNlH,KAAKuE,KAAO2C,EAAS3C,KAAK0B,IAAId,IAAQ,IAAMA,KAC5CnF,KAAKwE,cAAgB0C,EAAS1C,cAAcyB,IAAIA,GAAO,IAAIpB,IAAIoB,GACjE,ECjYF,SAAiBhF,WAAU,EAAEqD,QAAOA,G","sources":["webpack://pem/webpack/universalModuleDefinition","webpack://pem/webpack/bootstrap","webpack://pem/webpack/runtime/define property getters","webpack://pem/webpack/runtime/hasOwnProperty shorthand","webpack://pem/webpack/runtime/make namespace object","webpack://pem/./src/Expression.js","webpack://pem/./src/Matcher.js","webpack://pem/./src/index.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"pem\"] = factory();\n\telse\n\t\troot[\"pem\"] = factory();\n})(this, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * Expression - Parses and stores a tag pattern expression\n * \n * Patterns are parsed once and stored in an optimized structure for fast matching.\n * \n * @example\n * const expr = new Expression(\"root.users.user\");\n * const expr2 = new Expression(\"..user[id]:first\");\n * const expr3 = new Expression(\"root/users/user\", { separator: '/' });\n */\nexport default class Expression {\n /**\n * Create a new Expression\n * @param {string} pattern - Pattern string (e.g., \"root.users.user\", \"..user[id]\")\n * @param {Object} options - Configuration options\n * @param {string} options.separator - Path separator (default: '.')\n */\n constructor(pattern, options = {}) {\n this.pattern = pattern;\n this.separator = options.separator || '.';\n this.segments = this._parse(pattern);\n\n // Cache expensive checks for performance (O(1) instead of O(n))\n this._hasDeepWildcard = this.segments.some(seg => seg.type === 'deep-wildcard');\n this._hasAttributeCondition = this.segments.some(seg => seg.attrName !== undefined);\n this._hasPositionSelector = this.segments.some(seg => seg.position !== undefined);\n }\n\n /**\n * Parse pattern string into segments\n * @private\n * @param {string} pattern - Pattern to parse\n * @returns {Array} Array of segment objects\n */\n _parse(pattern) {\n const segments = [];\n\n // Split by separator but handle \"..\" specially\n let i = 0;\n let currentPart = '';\n\n while (i < pattern.length) {\n if (pattern[i] === this.separator) {\n // Check if next char is also separator (deep wildcard)\n if (i + 1 < pattern.length && pattern[i + 1] === this.separator) {\n // Flush current part if any\n if (currentPart.trim()) {\n segments.push(this._parseSegment(currentPart.trim()));\n currentPart = '';\n }\n // Add deep wildcard\n segments.push({ type: 'deep-wildcard' });\n i += 2; // Skip both separators\n } else {\n // Regular separator\n if (currentPart.trim()) {\n segments.push(this._parseSegment(currentPart.trim()));\n }\n currentPart = '';\n i++;\n }\n } else {\n currentPart += pattern[i];\n i++;\n }\n }\n\n // Flush remaining part\n if (currentPart.trim()) {\n segments.push(this._parseSegment(currentPart.trim()));\n }\n\n return segments;\n }\n\n /**\n * Parse a single segment\n * @private\n * @param {string} part - Segment string (e.g., \"user\", \"ns::user\", \"user[id]\", \"ns::user:first\")\n * @returns {Object} Segment object\n */\n _parseSegment(part) {\n const segment = { type: 'tag' };\n\n // NEW NAMESPACE SYNTAX (v2.0):\n // ============================\n // Namespace uses DOUBLE colon (::)\n // Position uses SINGLE colon (:)\n // \n // Examples:\n // \"user\" → tag\n // \"user:first\" → tag + position\n // \"user[id]\" → tag + attribute\n // \"user[id]:first\" → tag + attribute + position\n // \"ns::user\" → namespace + tag\n // \"ns::user:first\" → namespace + tag + position\n // \"ns::user[id]\" → namespace + tag + attribute\n // \"ns::user[id]:first\" → namespace + tag + attribute + position\n // \"ns::first\" → namespace + tag named \"first\" (NO ambiguity!)\n //\n // This eliminates all ambiguity:\n // :: = namespace separator\n // : = position selector\n // [] = attributes\n\n // Step 1: Extract brackets [attr] or [attr=value]\n let bracketContent = null;\n let withoutBrackets = part;\n\n const bracketMatch = part.match(/^([^\\[]+)(\\[[^\\]]*\\])(.*)$/);\n if (bracketMatch) {\n withoutBrackets = bracketMatch[1] + bracketMatch[3];\n if (bracketMatch[2]) {\n const content = bracketMatch[2].slice(1, -1);\n if (content) {\n bracketContent = content;\n }\n }\n }\n\n // Step 2: Check for namespace (double colon ::)\n let namespace = undefined;\n let tagAndPosition = withoutBrackets;\n\n if (withoutBrackets.includes('::')) {\n const nsIndex = withoutBrackets.indexOf('::');\n namespace = withoutBrackets.substring(0, nsIndex).trim();\n tagAndPosition = withoutBrackets.substring(nsIndex + 2).trim(); // Skip ::\n\n if (!namespace) {\n throw new Error(`Invalid namespace in pattern: ${part}`);\n }\n }\n\n // Step 3: Parse tag and position (single colon :)\n let tag = undefined;\n let positionMatch = null;\n\n if (tagAndPosition.includes(':')) {\n const colonIndex = tagAndPosition.lastIndexOf(':'); // Use last colon for position\n const tagPart = tagAndPosition.substring(0, colonIndex).trim();\n const posPart = tagAndPosition.substring(colonIndex + 1).trim();\n\n // Verify position is a valid keyword\n const isPositionKeyword = ['first', 'last', 'odd', 'even'].includes(posPart) ||\n /^nth\\(\\d+\\)$/.test(posPart);\n\n if (isPositionKeyword) {\n tag = tagPart;\n positionMatch = posPart;\n } else {\n // Not a valid position keyword, treat whole thing as tag\n tag = tagAndPosition;\n }\n } else {\n tag = tagAndPosition;\n }\n\n if (!tag) {\n throw new Error(`Invalid segment pattern: ${part}`);\n }\n\n segment.tag = tag;\n if (namespace) {\n segment.namespace = namespace;\n }\n\n // Step 4: Parse attributes\n if (bracketContent) {\n if (bracketContent.includes('=')) {\n const eqIndex = bracketContent.indexOf('=');\n segment.attrName = bracketContent.substring(0, eqIndex).trim();\n segment.attrValue = bracketContent.substring(eqIndex + 1).trim();\n } else {\n segment.attrName = bracketContent.trim();\n }\n }\n\n // Step 5: Parse position selector\n if (positionMatch) {\n const nthMatch = positionMatch.match(/^nth\\((\\d+)\\)$/);\n if (nthMatch) {\n segment.position = 'nth';\n segment.positionValue = parseInt(nthMatch[1], 10);\n } else {\n segment.position = positionMatch;\n }\n }\n\n return segment;\n }\n\n /**\n * Get the number of segments\n * @returns {number}\n */\n get length() {\n return this.segments.length;\n }\n\n /**\n * Check if expression contains deep wildcard\n * @returns {boolean}\n */\n hasDeepWildcard() {\n return this._hasDeepWildcard;\n }\n\n /**\n * Check if expression has attribute conditions\n * @returns {boolean}\n */\n hasAttributeCondition() {\n return this._hasAttributeCondition;\n }\n\n /**\n * Check if expression has position selectors\n * @returns {boolean}\n */\n hasPositionSelector() {\n return this._hasPositionSelector;\n }\n\n /**\n * Get string representation\n * @returns {string}\n */\n toString() {\n return this.pattern;\n }\n}","/**\n * Matcher - Tracks current path in XML/JSON tree and matches against Expressions\n * \n * The matcher maintains a stack of nodes representing the current path from root to\n * current tag. It only stores attribute values for the current (top) node to minimize\n * memory usage. Sibling tracking is used to auto-calculate position and counter.\n * \n * @example\n * const matcher = new Matcher();\n * matcher.push(\"root\", {});\n * matcher.push(\"users\", {});\n * matcher.push(\"user\", { id: \"123\", type: \"admin\" });\n * \n * const expr = new Expression(\"root.users.user\");\n * matcher.matches(expr); // true\n */\nexport default class Matcher {\n /**\n * Create a new Matcher\n * @param {Object} options - Configuration options\n * @param {string} options.separator - Default path separator (default: '.')\n */\n constructor(options = {}) {\n this.separator = options.separator || '.';\n this.path = [];\n this.siblingStacks = [];\n // Each path node: { tag: string, values: object, position: number, counter: number }\n // values only present for current (last) node\n // Each siblingStacks entry: Map<tagName, count> tracking occurrences at each level\n }\n\n /**\n * Push a new tag onto the path\n * @param {string} tagName - Name of the tag\n * @param {Object} attrValues - Attribute key-value pairs for current node (optional)\n * @param {string} namespace - Namespace for the tag (optional)\n */\n push(tagName, attrValues = null, namespace = null) {\n // Remove values from previous current node (now becoming ancestor)\n if (this.path.length > 0) {\n const prev = this.path[this.path.length - 1];\n prev.values = undefined;\n }\n\n // Get or create sibling tracking for current level\n const currentLevel = this.path.length;\n if (!this.siblingStacks[currentLevel]) {\n this.siblingStacks[currentLevel] = new Map();\n }\n\n const siblings = this.siblingStacks[currentLevel];\n\n // Create a unique key for sibling tracking that includes namespace\n const siblingKey = namespace ? `${namespace}:${tagName}` : tagName;\n\n // Calculate counter (how many times this tag appeared at this level)\n const counter = siblings.get(siblingKey) || 0;\n\n // Calculate position (total children at this level so far)\n let position = 0;\n for (const count of siblings.values()) {\n position += count;\n }\n\n // Update sibling count for this tag\n siblings.set(siblingKey, counter + 1);\n\n // Create new node\n const node = {\n tag: tagName,\n position: position,\n counter: counter\n };\n\n // Store namespace if provided\n if (namespace !== null && namespace !== undefined) {\n node.namespace = namespace;\n }\n\n // Store values only for current node\n if (attrValues !== null && attrValues !== undefined) {\n node.values = attrValues;\n }\n\n this.path.push(node);\n }\n\n /**\n * Pop the last tag from the path\n * @returns {Object|undefined} The popped node\n */\n pop() {\n if (this.path.length === 0) {\n return undefined;\n }\n\n const node = this.path.pop();\n\n // Clean up sibling tracking for levels deeper than current\n // After pop, path.length is the new depth\n // We need to clean up siblingStacks[path.length + 1] and beyond\n if (this.siblingStacks.length > this.path.length + 1) {\n this.siblingStacks.length = this.path.length + 1;\n }\n\n return node;\n }\n\n /**\n * Update current node's attribute values\n * Useful when attributes are parsed after push\n * @param {Object} attrValues - Attribute values\n */\n updateCurrent(attrValues) {\n if (this.path.length > 0) {\n const current = this.path[this.path.length - 1];\n if (attrValues !== null && attrValues !== undefined) {\n current.values = attrValues;\n }\n }\n }\n\n /**\n * Get current tag name\n * @returns {string|undefined}\n */\n getCurrentTag() {\n return this.path.length > 0 ? this.path[this.path.length - 1].tag : undefined;\n }\n\n /**\n * Get current namespace\n * @returns {string|undefined}\n */\n getCurrentNamespace() {\n return this.path.length > 0 ? this.path[this.path.length - 1].namespace : undefined;\n }\n\n /**\n * Get current node's attribute value\n * @param {string} attrName - Attribute name\n * @returns {*} Attribute value or undefined\n */\n getAttrValue(attrName) {\n if (this.path.length === 0) return undefined;\n const current = this.path[this.path.length - 1];\n return current.values?.[attrName];\n }\n\n /**\n * Check if current node has an attribute\n * @param {string} attrName - Attribute name\n * @returns {boolean}\n */\n hasAttr(attrName) {\n if (this.path.length === 0) return false;\n const current = this.path[this.path.length - 1];\n return current.values !== undefined && attrName in current.values;\n }\n\n /**\n * Get current node's sibling position (child index in parent)\n * @returns {number}\n */\n getPosition() {\n if (this.path.length === 0) return -1;\n return this.path[this.path.length - 1].position ?? 0;\n }\n\n /**\n * Get current node's repeat counter (occurrence count of this tag name)\n * @returns {number}\n */\n getCounter() {\n if (this.path.length === 0) return -1;\n return this.path[this.path.length - 1].counter ?? 0;\n }\n\n /**\n * Get current node's sibling index (alias for getPosition for backward compatibility)\n * @returns {number}\n * @deprecated Use getPosition() or getCounter() instead\n */\n getIndex() {\n return this.getPosition();\n }\n\n /**\n * Get current path depth\n * @returns {number}\n */\n getDepth() {\n return this.path.length;\n }\n\n /**\n * Get path as string\n * @param {string} separator - Optional separator (uses default if not provided)\n * @param {boolean} includeNamespace - Whether to include namespace in output (default: true)\n * @returns {string}\n */\n toString(separator, includeNamespace = true) {\n const sep = separator || this.separator;\n return this.path.map(n => {\n if (includeNamespace && n.namespace) {\n return `${n.namespace}:${n.tag}`;\n }\n return n.tag;\n }).join(sep);\n }\n\n /**\n * Get path as array of tag names\n * @returns {string[]}\n */\n toArray() {\n return this.path.map(n => n.tag);\n }\n\n /**\n * Reset the path to empty\n */\n reset() {\n this.path = [];\n this.siblingStacks = [];\n }\n\n /**\n * Match current path against an Expression\n * @param {Expression} expression - The expression to match against\n * @returns {boolean} True if current path matches the expression\n */\n matches(expression) {\n const segments = expression.segments;\n\n if (segments.length === 0) {\n return false;\n }\n\n // Handle deep wildcard patterns\n if (expression.hasDeepWildcard()) {\n return this._matchWithDeepWildcard(segments);\n }\n\n // Simple path matching (no deep wildcards)\n return this._matchSimple(segments);\n }\n\n /**\n * Match simple path (no deep wildcards)\n * @private\n */\n _matchSimple(segments) {\n // Path must be same length as segments\n if (this.path.length !== segments.length) {\n return false;\n }\n\n // Match each segment bottom-to-top\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n const node = this.path[i];\n const isCurrentNode = (i === this.path.length - 1);\n\n if (!this._matchSegment(segment, node, isCurrentNode)) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Match path with deep wildcards\n * @private\n */\n _matchWithDeepWildcard(segments) {\n let pathIdx = this.path.length - 1; // Start from current node (bottom)\n let segIdx = segments.length - 1; // Start from last segment\n\n while (segIdx >= 0 && pathIdx >= 0) {\n const segment = segments[segIdx];\n\n if (segment.type === 'deep-wildcard') {\n // \"..\" matches zero or more levels\n segIdx--;\n\n if (segIdx < 0) {\n // Pattern ends with \"..\", always matches\n return true;\n }\n\n // Find where next segment matches in the path\n const nextSeg = segments[segIdx];\n let found = false;\n\n for (let i = pathIdx; i >= 0; i--) {\n const isCurrentNode = (i === this.path.length - 1);\n if (this._matchSegment(nextSeg, this.path[i], isCurrentNode)) {\n pathIdx = i - 1;\n segIdx--;\n found = true;\n break;\n }\n }\n\n if (!found) {\n return false;\n }\n } else {\n // Regular segment\n const isCurrentNode = (pathIdx === this.path.length - 1);\n if (!this._matchSegment(segment, this.path[pathIdx], isCurrentNode)) {\n return false;\n }\n pathIdx--;\n segIdx--;\n }\n }\n\n // All segments must be consumed\n return segIdx < 0;\n }\n\n /**\n * Match a single segment against a node\n * @private\n * @param {Object} segment - Segment from Expression\n * @param {Object} node - Node from path\n * @param {boolean} isCurrentNode - Whether this is the current (last) node\n * @returns {boolean}\n */\n _matchSegment(segment, node, isCurrentNode) {\n // Match tag name (* is wildcard)\n if (segment.tag !== '*' && segment.tag !== node.tag) {\n return false;\n }\n\n // Match namespace if specified in segment\n if (segment.namespace !== undefined) {\n // Segment has namespace - node must match it\n if (segment.namespace !== '*' && segment.namespace !== node.namespace) {\n return false;\n }\n }\n // If segment has no namespace, it matches nodes with or without namespace\n\n // Match attribute name (check if node has this attribute)\n // Can only check for current node since ancestors don't have values\n if (segment.attrName !== undefined) {\n if (!isCurrentNode) {\n // Can't check attributes for ancestor nodes (values not stored)\n return false;\n }\n\n if (!node.values || !(segment.attrName in node.values)) {\n return false;\n }\n\n // Match attribute value (only possible for current node)\n if (segment.attrValue !== undefined) {\n const actualValue = node.values[segment.attrName];\n // Both should be strings\n if (String(actualValue) !== String(segment.attrValue)) {\n return false;\n }\n }\n }\n\n // Match position (only for current node)\n if (segment.position !== undefined) {\n if (!isCurrentNode) {\n // Can't check position for ancestor nodes\n return false;\n }\n\n const counter = node.counter ?? 0;\n\n if (segment.position === 'first' && counter !== 0) {\n return false;\n } else if (segment.position === 'odd' && counter % 2 !== 1) {\n return false;\n } else if (segment.position === 'even' && counter % 2 !== 0) {\n return false;\n } else if (segment.position === 'nth') {\n if (counter !== segment.positionValue) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n /**\n * Create a snapshot of current state\n * @returns {Object} State snapshot\n */\n snapshot() {\n return {\n path: this.path.map(node => ({ ...node })),\n siblingStacks: this.siblingStacks.map(map => new Map(map))\n };\n }\n\n /**\n * Restore state from snapshot\n * @param {Object} snapshot - State snapshot\n */\n restore(snapshot) {\n this.path = snapshot.path.map(node => ({ ...node }));\n this.siblingStacks = snapshot.siblingStacks.map(map => new Map(map));\n }\n}","/**\n * fast-xml-tagger - XML/JSON path matching library\n * \n * Provides efficient path tracking and pattern matching for XML/JSON parsers.\n * \n * @example\n * import { Expression, Matcher } from 'fast-xml-tagger';\n * \n * // Create expression (parse once)\n * const expr = new Expression(\"root.users.user[id]\");\n * \n * // Create matcher (track path)\n * const matcher = new Matcher();\n * matcher.push(\"root\", [], {}, 0);\n * matcher.push(\"users\", [], {}, 0);\n * matcher.push(\"user\", [\"id\", \"type\"], { id: \"123\", type: \"admin\" }, 0);\n * \n * // Match\n * if (matcher.matches(expr)) {\n * console.log(\"Match found!\");\n * }\n */\n\nimport Expression from './Expression.js';\nimport Matcher from './Matcher.js';\n\nexport { Expression, Matcher };\nexport default { Expression, Matcher };\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","Expression","constructor","pattern","options","separator","segments","_parse","_hasDeepWildcard","some","seg","type","_hasAttributeCondition","undefined","attrName","_hasPositionSelector","position","i","currentPart","length","trim","push","_parseSegment","part","segment","bracketContent","withoutBrackets","bracketMatch","match","content","slice","namespace","tag","tagAndPosition","includes","nsIndex","indexOf","substring","Error","positionMatch","colonIndex","lastIndexOf","tagPart","posPart","test","eqIndex","attrValue","nthMatch","positionValue","parseInt","hasDeepWildcard","hasAttributeCondition","hasPositionSelector","toString","Matcher","path","siblingStacks","tagName","attrValues","values","currentLevel","Map","siblings","siblingKey","counter","count","set","node","pop","updateCurrent","current","getCurrentTag","getCurrentNamespace","getAttrValue","hasAttr","getPosition","getCounter","getIndex","getDepth","includeNamespace","sep","map","n","join","toArray","reset","matches","expression","_matchWithDeepWildcard","_matchSimple","isCurrentNode","_matchSegment","pathIdx","segIdx","nextSeg","found","actualValue","String","snapshot","restore"],"sourceRoot":""}
|
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "path-expression-matcher",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Efficient path tracking and pattern matching for XML/JSON parsers",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "./lib/pem.cjs",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"module": "./src/index.js",
|
|
9
|
+
"types": "./src/index.d.ts",
|
|
7
10
|
"exports": {
|
|
8
|
-
".":
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
".": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./src/index.d.ts",
|
|
14
|
+
"default": "./src/index.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./lib/pem.d.cts",
|
|
18
|
+
"default": "./lib/pem.cjs"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
11
21
|
},
|
|
12
22
|
"scripts": {
|
|
13
|
-
"test": "node test/namespace_test.js && node test/test.js"
|
|
23
|
+
"test": "c8 --reporter=lcov --reporter=text node test/namespace_test.js && c8 --reporter=lcov --reporter=text node test/test.js",
|
|
24
|
+
"bundle": "webpack --config webpack.cjs.config.js"
|
|
14
25
|
},
|
|
15
26
|
"keywords": [
|
|
16
27
|
"xml",
|
|
@@ -39,10 +50,25 @@
|
|
|
39
50
|
"node": ">=14.0.0"
|
|
40
51
|
},
|
|
41
52
|
"files": [
|
|
53
|
+
"lib",
|
|
42
54
|
"src/",
|
|
43
55
|
"README.md",
|
|
44
56
|
"LICENSE"
|
|
45
57
|
],
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@babel/core": "^7.13.10",
|
|
60
|
+
"@babel/plugin-transform-runtime": "^7.13.10",
|
|
61
|
+
"@babel/preset-env": "^7.13.10",
|
|
62
|
+
"@babel/register": "^7.13.8",
|
|
63
|
+
"@types/node": "20",
|
|
64
|
+
"babel-loader": "^8.2.2",
|
|
65
|
+
"c8": "^10.1.3",
|
|
66
|
+
"eslint": "^8.3.0",
|
|
67
|
+
"prettier": "^3.5.1",
|
|
68
|
+
"typescript": "5",
|
|
69
|
+
"webpack": "^5.64.4",
|
|
70
|
+
"webpack-cli": "^4.9.1"
|
|
71
|
+
},
|
|
46
72
|
"funding": [
|
|
47
73
|
{
|
|
48
74
|
"type": "github",
|
|
@@ -0,0 +1,366 @@
|
|
|
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
|
+
* Matcher - Tracks current path in XML/JSON tree and matches against Expressions
|
|
193
|
+
*
|
|
194
|
+
* The matcher maintains a stack of nodes representing the current path from root to
|
|
195
|
+
* current tag. It only stores attribute values for the current (top) node to minimize
|
|
196
|
+
* memory usage.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* const matcher = new Matcher();
|
|
201
|
+
* matcher.push("root", {});
|
|
202
|
+
* matcher.push("users", {});
|
|
203
|
+
* matcher.push("user", { id: "123", type: "admin" });
|
|
204
|
+
*
|
|
205
|
+
* const expr = new Expression("root.users.user");
|
|
206
|
+
* matcher.matches(expr); // true
|
|
207
|
+
*
|
|
208
|
+
* matcher.pop();
|
|
209
|
+
* matcher.matches(expr); // false
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
export class Matcher {
|
|
213
|
+
/**
|
|
214
|
+
* Default path separator
|
|
215
|
+
*/
|
|
216
|
+
readonly separator: string;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Current path stack
|
|
220
|
+
*/
|
|
221
|
+
readonly path: PathNode[];
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Create a new Matcher
|
|
225
|
+
* @param options - Configuration options
|
|
226
|
+
*/
|
|
227
|
+
constructor(options?: MatcherOptions);
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Push a new tag onto the path
|
|
231
|
+
* @param tagName - Name of the tag
|
|
232
|
+
* @param attrValues - Attribute key-value pairs for current node (optional)
|
|
233
|
+
* @param namespace - Namespace for the tag (optional)
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* matcher.push("user", { id: "123", type: "admin" });
|
|
238
|
+
* matcher.push("user", { id: "456" }, "ns");
|
|
239
|
+
* matcher.push("container", null);
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
push(tagName: string, attrValues?: Record<string, any> | null, namespace?: string | null): void;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Pop the last tag from the path
|
|
246
|
+
* @returns The popped node or undefined if path is empty
|
|
247
|
+
*/
|
|
248
|
+
pop(): PathNode | undefined;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Update current node's attribute values
|
|
252
|
+
* Useful when attributes are parsed after push
|
|
253
|
+
* @param attrValues - Attribute values
|
|
254
|
+
*/
|
|
255
|
+
updateCurrent(attrValues: Record<string, any>): void;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Get current tag name
|
|
259
|
+
* @returns Current tag name or undefined if path is empty
|
|
260
|
+
*/
|
|
261
|
+
getCurrentTag(): string | undefined;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Get current namespace
|
|
265
|
+
* @returns Current namespace or undefined if not present or path is empty
|
|
266
|
+
*/
|
|
267
|
+
getCurrentNamespace(): string | undefined;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Get current node's attribute value
|
|
271
|
+
* @param attrName - Attribute name
|
|
272
|
+
* @returns Attribute value or undefined
|
|
273
|
+
*/
|
|
274
|
+
getAttrValue(attrName: string): any;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Check if current node has an attribute
|
|
278
|
+
* @param attrName - Attribute name
|
|
279
|
+
*/
|
|
280
|
+
hasAttr(attrName: string): boolean;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Get current node's sibling position (child index in parent)
|
|
284
|
+
* @returns Position index or -1 if path is empty
|
|
285
|
+
*/
|
|
286
|
+
getPosition(): number;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Get current node's repeat counter (occurrence count of this tag name)
|
|
290
|
+
* @returns Counter value or -1 if path is empty
|
|
291
|
+
*/
|
|
292
|
+
getCounter(): number;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Get current node's sibling index (alias for getPosition for backward compatibility)
|
|
296
|
+
* @returns Index or -1 if path is empty
|
|
297
|
+
* @deprecated Use getPosition() or getCounter() instead
|
|
298
|
+
*/
|
|
299
|
+
getIndex(): number;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Get current path depth
|
|
303
|
+
* @returns Number of nodes in the path
|
|
304
|
+
*/
|
|
305
|
+
getDepth(): number;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Get path as string
|
|
309
|
+
* @param separator - Optional separator (uses default if not provided)
|
|
310
|
+
* @param includeNamespace - Whether to include namespace in output
|
|
311
|
+
* @returns Path string (e.g., "root.users.user" or "ns:root.ns:users.user")
|
|
312
|
+
*/
|
|
313
|
+
toString(separator?: string, includeNamespace?: boolean): string;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Get path as array of tag names
|
|
317
|
+
* @returns Array of tag names
|
|
318
|
+
*/
|
|
319
|
+
toArray(): string[];
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Reset the path to empty
|
|
323
|
+
*/
|
|
324
|
+
reset(): void;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Match current path against an Expression
|
|
328
|
+
* @param expression - The expression to match against
|
|
329
|
+
* @returns True if current path matches the expression
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```typescript
|
|
333
|
+
* const expr = new Expression("root.users.user[id]");
|
|
334
|
+
* const matcher = new Matcher();
|
|
335
|
+
*
|
|
336
|
+
* matcher.push("root");
|
|
337
|
+
* matcher.push("users");
|
|
338
|
+
* matcher.push("user", { id: "123" });
|
|
339
|
+
*
|
|
340
|
+
* matcher.matches(expr); // true
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
matches(expression: Expression): boolean;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Create a snapshot of current state
|
|
347
|
+
* @returns State snapshot that can be restored later
|
|
348
|
+
*/
|
|
349
|
+
snapshot(): MatcherSnapshot;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Restore state from snapshot
|
|
353
|
+
* @param snapshot - State snapshot from previous snapshot() call
|
|
354
|
+
*/
|
|
355
|
+
restore(snapshot: MatcherSnapshot): void;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Default export containing both Expression and Matcher
|
|
360
|
+
*/
|
|
361
|
+
declare const _default: {
|
|
362
|
+
Expression: typeof Expression;
|
|
363
|
+
Matcher: typeof Matcher;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"constructs": "^10.3.0"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@aws-sdk/client-cloudformation": "^3.
|
|
80
|
+
"@aws-sdk/client-cloudformation": "^3.1007.0"
|
|
81
81
|
},
|
|
82
82
|
"bundledDependencies": [
|
|
83
83
|
"@aws-sdk/client-cloudformation"
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"access": "public"
|
|
95
95
|
},
|
|
96
|
-
"version": "0.0.
|
|
96
|
+
"version": "0.0.511",
|
|
97
97
|
"jest": {
|
|
98
98
|
"coverageProvider": "v8",
|
|
99
99
|
"testMatch": [
|