@btc-embedded/cdk-extensions 0.23.3 → 0.23.5
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 +41 -41
- package/CHANGELOG.md +14 -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 +1 -0
- package/lib/platform/ApplicationLoadBalancerV2.js +10 -3
- package/lib/platform/AuroraPostgresDB.js +5 -4
- 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
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { buildOptions} from './OptionsBuilder.js';
|
|
1
|
+
import { buildOptions } from './OptionsBuilder.js';
|
|
2
2
|
import OrderedObjParser from './OrderedObjParser.js';
|
|
3
3
|
import prettify from './node2json.js';
|
|
4
|
-
import {validate} from "../validator.js";
|
|
4
|
+
import { validate } from "../validator.js";
|
|
5
5
|
import XmlNode from './xmlNode.js';
|
|
6
6
|
|
|
7
|
-
export default class XMLParser{
|
|
8
|
-
|
|
9
|
-
constructor(options){
|
|
7
|
+
export default class XMLParser {
|
|
8
|
+
|
|
9
|
+
constructor(options) {
|
|
10
10
|
this.externalEntities = {};
|
|
11
11
|
this.options = buildOptions(options);
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Parse XML dats to JS object
|
|
16
|
-
* @param {string|
|
|
16
|
+
* @param {string|Uint8Array} xmlData
|
|
17
17
|
* @param {boolean|Object} validationOption
|
|
18
18
|
*/
|
|
19
|
-
parse(xmlData,validationOption){
|
|
20
|
-
if(typeof xmlData
|
|
21
|
-
}else if( xmlData.toString){
|
|
19
|
+
parse(xmlData, validationOption) {
|
|
20
|
+
if (typeof xmlData !== "string" && xmlData.toString) {
|
|
22
21
|
xmlData = xmlData.toString();
|
|
23
|
-
}else{
|
|
22
|
+
} else if (typeof xmlData !== "string") {
|
|
24
23
|
throw new Error("XML data is accepted in String or Bytes[] form.")
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
|
|
26
|
+
if (validationOption) {
|
|
27
|
+
if (validationOption === true) validationOption = {}; //validate with default options
|
|
28
|
+
|
|
29
29
|
const result = validate(xmlData, validationOption);
|
|
30
30
|
if (result !== true) {
|
|
31
|
-
|
|
31
|
+
throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`)
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
const orderedObjParser = new OrderedObjParser(this.options);
|
|
35
|
-
orderedObjParser.
|
|
33
|
+
}
|
|
34
|
+
const orderedObjParser = new OrderedObjParser(this.options, this.externalEntities);
|
|
35
|
+
// orderedObjParser.entityDecoder.setExternalEntities(this.externalEntities);
|
|
36
36
|
const orderedResult = orderedObjParser.parseXml(xmlData);
|
|
37
|
-
if(this.options.preserveOrder || orderedResult === undefined) return orderedResult;
|
|
38
|
-
else return prettify(orderedResult, this.options);
|
|
37
|
+
if (this.options.preserveOrder || orderedResult === undefined) return orderedResult;
|
|
38
|
+
else return prettify(orderedResult, this.options, orderedObjParser.matcher, orderedObjParser.readonlyMatcher);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -43,14 +43,14 @@ export default class XMLParser{
|
|
|
43
43
|
* @param {string} key
|
|
44
44
|
* @param {string} value
|
|
45
45
|
*/
|
|
46
|
-
addEntity(key, value){
|
|
47
|
-
if(value.indexOf("&") !== -1){
|
|
46
|
+
addEntity(key, value) {
|
|
47
|
+
if (value.indexOf("&") !== -1) {
|
|
48
48
|
throw new Error("Entity value can't have '&'")
|
|
49
|
-
}else if(key.indexOf("&") !== -1 || key.indexOf(";") !== -1){
|
|
49
|
+
} else if (key.indexOf("&") !== -1 || key.indexOf(";") !== -1) {
|
|
50
50
|
throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'")
|
|
51
|
-
}else if(value === "&"){
|
|
51
|
+
} else if (value === "&") {
|
|
52
52
|
throw new Error("An entity with value '&' is not permitted");
|
|
53
|
-
}else{
|
|
53
|
+
} else {
|
|
54
54
|
this.externalEntities[key] = value;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -68,4 +68,4 @@ export default class XMLParser{
|
|
|
68
68
|
static getMetaDataSymbol() {
|
|
69
69
|
return XmlNode.getMetaDataSymbol();
|
|
70
70
|
}
|
|
71
|
-
}
|
|
71
|
+
}
|
|
@@ -1,98 +1,156 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
import XmlNode from './xmlNode.js';
|
|
4
|
+
import { Matcher } from 'path-expression-matcher';
|
|
4
5
|
|
|
5
6
|
const METADATA_SYMBOL = XmlNode.getMetaDataSymbol();
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Helper function to strip attribute prefix from attribute map
|
|
10
|
+
* @param {object} attrs - Attributes with prefix (e.g., {"@_class": "code"})
|
|
11
|
+
* @param {string} prefix - Attribute prefix to remove (e.g., "@_")
|
|
12
|
+
* @returns {object} Attributes without prefix (e.g., {"class": "code"})
|
|
13
|
+
*/
|
|
14
|
+
function stripAttributePrefix(attrs, prefix) {
|
|
15
|
+
if (!attrs || typeof attrs !== 'object') return {};
|
|
16
|
+
if (!prefix) return attrs;
|
|
17
|
+
|
|
18
|
+
const rawAttrs = {};
|
|
19
|
+
for (const key in attrs) {
|
|
20
|
+
if (key.startsWith(prefix)) {
|
|
21
|
+
const rawName = key.substring(prefix.length);
|
|
22
|
+
rawAttrs[rawName] = attrs[key];
|
|
23
|
+
} else {
|
|
24
|
+
// Attribute without prefix (shouldn't normally happen, but be safe)
|
|
25
|
+
rawAttrs[key] = attrs[key];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return rawAttrs;
|
|
29
|
+
}
|
|
30
|
+
|
|
7
31
|
/**
|
|
8
32
|
*
|
|
9
33
|
* @param {array} node
|
|
10
34
|
* @param {any} options
|
|
35
|
+
* @param {Matcher} matcher - Path matcher instance
|
|
11
36
|
* @returns
|
|
12
37
|
*/
|
|
13
|
-
export default function prettify(node, options){
|
|
14
|
-
return compress(
|
|
38
|
+
export default function prettify(node, options, matcher, readonlyMatcher) {
|
|
39
|
+
return compress(node, options, matcher, readonlyMatcher);
|
|
15
40
|
}
|
|
16
41
|
|
|
17
42
|
/**
|
|
18
|
-
*
|
|
19
43
|
* @param {array} arr
|
|
20
44
|
* @param {object} options
|
|
21
|
-
* @param {
|
|
45
|
+
* @param {Matcher} matcher - Path matcher instance
|
|
22
46
|
* @returns object
|
|
23
47
|
*/
|
|
24
|
-
function compress(arr, options,
|
|
48
|
+
function compress(arr, options, matcher, readonlyMatcher) {
|
|
25
49
|
let text;
|
|
26
|
-
const compressedObj = {};
|
|
50
|
+
const compressedObj = {}; //This is intended to be a plain object
|
|
27
51
|
for (let i = 0; i < arr.length; i++) {
|
|
28
52
|
const tagObj = arr[i];
|
|
29
53
|
const property = propName(tagObj);
|
|
30
|
-
let newJpath = "";
|
|
31
|
-
if(jPath === undefined) newJpath = property;
|
|
32
|
-
else newJpath = jPath + "." + property;
|
|
33
54
|
|
|
34
|
-
|
|
35
|
-
|
|
55
|
+
// Push current property to matcher WITH RAW ATTRIBUTES (no prefix)
|
|
56
|
+
if (property !== undefined && property !== options.textNodeName) {
|
|
57
|
+
const rawAttrs = stripAttributePrefix(
|
|
58
|
+
tagObj[":@"] || {},
|
|
59
|
+
options.attributeNamePrefix
|
|
60
|
+
);
|
|
61
|
+
matcher.push(property, rawAttrs);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (property === options.textNodeName) {
|
|
65
|
+
if (text === undefined) text = tagObj[property];
|
|
36
66
|
else text += "" + tagObj[property];
|
|
37
|
-
}else if(property === undefined){
|
|
67
|
+
} else if (property === undefined) {
|
|
38
68
|
continue;
|
|
39
|
-
}else if(tagObj[property]){
|
|
40
|
-
|
|
41
|
-
let val = compress(tagObj[property], options,
|
|
69
|
+
} else if (tagObj[property]) {
|
|
70
|
+
|
|
71
|
+
let val = compress(tagObj[property], options, matcher, readonlyMatcher);
|
|
42
72
|
const isLeaf = isLeafTag(val, options);
|
|
43
|
-
|
|
44
|
-
|
|
73
|
+
|
|
74
|
+
if (Object.keys(val).length === 0 && options.alwaysCreateTextNode) {
|
|
75
|
+
val[options.textNodeName] = "";
|
|
45
76
|
}
|
|
46
77
|
|
|
47
|
-
if(tagObj[":@"]){
|
|
48
|
-
assignAttributes(
|
|
49
|
-
}else if(Object.keys(val).length === 1 && val[options.textNodeName] !== undefined && !options.alwaysCreateTextNode){
|
|
78
|
+
if (tagObj[":@"]) {
|
|
79
|
+
assignAttributes(val, tagObj[":@"], readonlyMatcher, options);
|
|
80
|
+
} else if (Object.keys(val).length === 1 && val[options.textNodeName] !== undefined && !options.alwaysCreateTextNode) {
|
|
50
81
|
val = val[options.textNodeName];
|
|
51
|
-
}else if(Object.keys(val).length === 0){
|
|
52
|
-
if(options.alwaysCreateTextNode) val[options.textNodeName] = "";
|
|
82
|
+
} else if (Object.keys(val).length === 0) {
|
|
83
|
+
if (options.alwaysCreateTextNode) val[options.textNodeName] = "";
|
|
53
84
|
else val = "";
|
|
54
85
|
}
|
|
55
86
|
|
|
56
|
-
if(
|
|
57
|
-
|
|
58
|
-
|
|
87
|
+
if (tagObj[METADATA_SYMBOL] !== undefined && typeof val === "object" && val !== null) {
|
|
88
|
+
val[METADATA_SYMBOL] = tagObj[METADATA_SYMBOL]; // copy over metadata
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
if (compressedObj[property] !== undefined && Object.prototype.hasOwnProperty.call(compressedObj, property)) {
|
|
93
|
+
if (!Array.isArray(compressedObj[property])) {
|
|
94
|
+
compressedObj[property] = [compressedObj[property]];
|
|
59
95
|
}
|
|
60
96
|
compressedObj[property].push(val);
|
|
61
|
-
}else{
|
|
97
|
+
} else {
|
|
62
98
|
//TODO: if a node is not an array, then check if it should be an array
|
|
63
99
|
//also determine if it is a leaf node
|
|
64
|
-
|
|
100
|
+
|
|
101
|
+
// Pass jPath string or readonlyMatcher based on options.jPath setting
|
|
102
|
+
const jPathOrMatcher = options.jPath ? readonlyMatcher.toString() : readonlyMatcher;
|
|
103
|
+
if (options.isArray(property, jPathOrMatcher, isLeaf)) {
|
|
65
104
|
compressedObj[property] = [val];
|
|
66
|
-
}else{
|
|
105
|
+
} else {
|
|
67
106
|
compressedObj[property] = val;
|
|
68
107
|
}
|
|
69
108
|
}
|
|
109
|
+
|
|
110
|
+
// Pop property from matcher after processing
|
|
111
|
+
if (property !== undefined && property !== options.textNodeName) {
|
|
112
|
+
matcher.pop();
|
|
113
|
+
}
|
|
70
114
|
}
|
|
71
|
-
|
|
115
|
+
|
|
72
116
|
}
|
|
73
117
|
// if(text && text.length > 0) compressedObj[options.textNodeName] = text;
|
|
74
|
-
if(typeof text === "string"){
|
|
75
|
-
if(text.length > 0) compressedObj[options.textNodeName] = text;
|
|
76
|
-
}else if(text !== undefined) compressedObj[options.textNodeName] = text;
|
|
118
|
+
if (typeof text === "string") {
|
|
119
|
+
if (text.length > 0) compressedObj[options.textNodeName] = text;
|
|
120
|
+
} else if (text !== undefined) compressedObj[options.textNodeName] = text;
|
|
121
|
+
|
|
122
|
+
|
|
77
123
|
return compressedObj;
|
|
78
124
|
}
|
|
79
125
|
|
|
80
|
-
function propName(obj){
|
|
126
|
+
function propName(obj) {
|
|
81
127
|
const keys = Object.keys(obj);
|
|
82
128
|
for (let i = 0; i < keys.length; i++) {
|
|
83
129
|
const key = keys[i];
|
|
84
|
-
if(key !== ":@") return key;
|
|
130
|
+
if (key !== ":@") return key;
|
|
85
131
|
}
|
|
86
132
|
}
|
|
87
133
|
|
|
88
|
-
function assignAttributes(obj, attrMap,
|
|
134
|
+
function assignAttributes(obj, attrMap, readonlyMatcher, options) {
|
|
89
135
|
if (attrMap) {
|
|
90
136
|
const keys = Object.keys(attrMap);
|
|
91
137
|
const len = keys.length; //don't make it inline
|
|
92
138
|
for (let i = 0; i < len; i++) {
|
|
93
|
-
const atrrName = keys[i];
|
|
94
|
-
|
|
95
|
-
|
|
139
|
+
const atrrName = keys[i]; // This is the PREFIXED name (e.g., "@_class")
|
|
140
|
+
|
|
141
|
+
// Strip prefix for matcher path (for isArray callback)
|
|
142
|
+
const rawAttrName = atrrName.startsWith(options.attributeNamePrefix)
|
|
143
|
+
? atrrName.substring(options.attributeNamePrefix.length)
|
|
144
|
+
: atrrName;
|
|
145
|
+
|
|
146
|
+
// For attributes, we need to create a temporary path
|
|
147
|
+
// Pass jPath string or matcher based on options.jPath setting
|
|
148
|
+
const jPathOrMatcher = options.jPath
|
|
149
|
+
? readonlyMatcher.toString() + "." + rawAttrName
|
|
150
|
+
: readonlyMatcher;
|
|
151
|
+
|
|
152
|
+
if (options.isArray(atrrName, jPathOrMatcher, true, true)) {
|
|
153
|
+
obj[atrrName] = [attrMap[atrrName]];
|
|
96
154
|
} else {
|
|
97
155
|
obj[atrrName] = attrMap[atrrName];
|
|
98
156
|
}
|
|
@@ -100,10 +158,10 @@ function assignAttributes(obj, attrMap, jpath, options){
|
|
|
100
158
|
}
|
|
101
159
|
}
|
|
102
160
|
|
|
103
|
-
function isLeafTag(obj, options){
|
|
161
|
+
function isLeafTag(obj, options) {
|
|
104
162
|
const { textNodeName } = options;
|
|
105
163
|
const propCount = Object.keys(obj).length;
|
|
106
|
-
|
|
164
|
+
|
|
107
165
|
if (propCount === 0) {
|
|
108
166
|
return true;
|
|
109
167
|
}
|
|
@@ -116,4 +174,4 @@ function isLeafTag(obj, options){
|
|
|
116
174
|
}
|
|
117
175
|
|
|
118
176
|
return false;
|
|
119
|
-
}
|
|
177
|
+
}
|
|
@@ -8,23 +8,23 @@ if (typeof Symbol !== "function") {
|
|
|
8
8
|
METADATA_SYMBOL = Symbol("XML Node Metadata");
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export default class XmlNode{
|
|
11
|
+
export default class XmlNode {
|
|
12
12
|
constructor(tagname) {
|
|
13
13
|
this.tagname = tagname;
|
|
14
14
|
this.child = []; //nested tags, text, cdata, comments in order
|
|
15
|
-
this[":@"] =
|
|
15
|
+
this[":@"] = Object.create(null); //attributes map
|
|
16
16
|
}
|
|
17
|
-
add(key,val){
|
|
17
|
+
add(key, val) {
|
|
18
18
|
// this.child.push( {name : key, val: val, isCdata: isCdata });
|
|
19
|
-
if(key === "__proto__") key = "#__proto__";
|
|
20
|
-
this.child.push(
|
|
19
|
+
if (key === "__proto__") key = "#__proto__";
|
|
20
|
+
this.child.push({ [key]: val });
|
|
21
21
|
}
|
|
22
22
|
addChild(node, startIndex) {
|
|
23
|
-
if(node.tagname === "__proto__") node.tagname = "#__proto__";
|
|
24
|
-
if(node[":@"] && Object.keys(node[":@"]).length > 0){
|
|
25
|
-
this.child.push(
|
|
26
|
-
}else{
|
|
27
|
-
this.child.push(
|
|
23
|
+
if (node.tagname === "__proto__") node.tagname = "#__proto__";
|
|
24
|
+
if (node[":@"] && Object.keys(node[":@"]).length > 0) {
|
|
25
|
+
this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
|
|
26
|
+
} else {
|
|
27
|
+
this.child.push({ [node.tagname]: node.child });
|
|
28
28
|
}
|
|
29
29
|
// if requested, add the startIndex
|
|
30
30
|
if (startIndex !== undefined) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|