@cdk8s/awscdk-resolver 0.0.135 → 0.0.137
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/dist-cjs/index.js +9 -15
- package/node_modules/@aws-sdk/client-cloudformation/dist-es/CloudFormationClient.js +9 -15
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/CloudFormationClient.d.ts +2 -4
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/auth/httpAuthSchemeProvider.d.ts +4 -4
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.browser.d.ts +2 -2
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.d.ts +2 -2
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.native.d.ts +2 -2
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/CloudFormationClient.d.ts +6 -8
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.browser.d.ts +5 -5
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.d.ts +5 -5
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.native.d.ts +5 -5
- package/node_modules/@aws-sdk/client-cloudformation/package.json +18 -18
- package/node_modules/@aws-sdk/client-sso/dist-cjs/index.js +9 -15
- package/node_modules/@aws-sdk/client-sso/dist-es/SSOClient.js +9 -15
- package/node_modules/@aws-sdk/client-sso/dist-types/SSOClient.d.ts +2 -4
- package/node_modules/@aws-sdk/client-sso/dist-types/auth/httpAuthSchemeProvider.d.ts +4 -4
- package/node_modules/@aws-sdk/client-sso/dist-types/runtimeConfig.browser.d.ts +2 -2
- package/node_modules/@aws-sdk/client-sso/dist-types/runtimeConfig.d.ts +2 -2
- package/node_modules/@aws-sdk/client-sso/dist-types/runtimeConfig.native.d.ts +2 -2
- package/node_modules/@aws-sdk/client-sso/dist-types/ts3.4/SSOClient.d.ts +6 -8
- package/node_modules/@aws-sdk/client-sso/dist-types/ts3.4/runtimeConfig.browser.d.ts +5 -5
- package/node_modules/@aws-sdk/client-sso/dist-types/ts3.4/runtimeConfig.d.ts +5 -5
- package/node_modules/@aws-sdk/client-sso/dist-types/ts3.4/runtimeConfig.native.d.ts +5 -5
- package/node_modules/@aws-sdk/client-sso/package.json +15 -15
- package/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/index.js +9 -15
- package/node_modules/@aws-sdk/client-sso-oidc/dist-es/SSOOIDCClient.js +9 -15
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/SSOOIDCClient.d.ts +2 -4
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/auth/httpAuthSchemeProvider.d.ts +4 -4
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/runtimeConfig.browser.d.ts +2 -2
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/runtimeConfig.d.ts +2 -2
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/runtimeConfig.native.d.ts +2 -2
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/ts3.4/SSOOIDCClient.d.ts +6 -8
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/ts3.4/runtimeConfig.browser.d.ts +5 -5
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/ts3.4/runtimeConfig.d.ts +5 -5
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/ts3.4/runtimeConfig.native.d.ts +5 -5
- package/node_modules/@aws-sdk/client-sso-oidc/package.json +17 -17
- package/node_modules/@aws-sdk/client-sts/dist-cjs/STSClient.js +9 -15
- package/node_modules/@aws-sdk/client-sts/dist-cjs/index.js +17 -4
- package/node_modules/@aws-sdk/client-sts/dist-es/STSClient.js +9 -15
- package/node_modules/@aws-sdk/client-sts/dist-es/defaultStsRoleAssumers.js +17 -4
- package/node_modules/@aws-sdk/client-sts/dist-types/STSClient.d.ts +2 -4
- package/node_modules/@aws-sdk/client-sts/dist-types/auth/httpAuthSchemeProvider.d.ts +4 -4
- package/node_modules/@aws-sdk/client-sts/dist-types/runtimeConfig.browser.d.ts +2 -2
- package/node_modules/@aws-sdk/client-sts/dist-types/runtimeConfig.d.ts +2 -2
- package/node_modules/@aws-sdk/client-sts/dist-types/runtimeConfig.native.d.ts +2 -2
- package/node_modules/@aws-sdk/client-sts/dist-types/ts3.4/STSClient.d.ts +6 -8
- package/node_modules/@aws-sdk/client-sts/dist-types/ts3.4/runtimeConfig.browser.d.ts +5 -5
- package/node_modules/@aws-sdk/client-sts/dist-types/ts3.4/runtimeConfig.d.ts +5 -5
- package/node_modules/@aws-sdk/client-sts/dist-types/ts3.4/runtimeConfig.native.d.ts +5 -5
- package/node_modules/@aws-sdk/client-sts/package.json +17 -17
- package/node_modules/@aws-sdk/core/account-id-endpoint.js +6 -0
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/account-id-endpoint/index.js +97 -0
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/httpAuthSchemes/index.js +27 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.js +15 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/account-id-endpoint/AccountIdEndpointModeConstants.js +5 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.js +24 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/account-id-endpoint/index.js +3 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4ASigner.js +18 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js +3 -1
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/index.js +2 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.d.ts +30 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/account-id-endpoint/AccountIdEndpointModeConstants.d.ts +7 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.d.ts +14 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/account-id-endpoint/index.d.ts +3 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4ASigner.d.ts +10 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.d.ts +25 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/index.d.ts +2 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.d.ts +15 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/AccountIdEndpointModeConstants.d.ts +6 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.d.ts +7 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/index.d.ts +3 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4ASigner.d.ts +12 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.d.ts +17 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/index.d.ts +2 -1
- package/node_modules/@aws-sdk/core/package.json +18 -8
- package/node_modules/@aws-sdk/credential-provider-env/dist-cjs/index.js +6 -1
- package/node_modules/@aws-sdk/credential-provider-env/dist-es/fromEnv.js +3 -0
- package/node_modules/@aws-sdk/credential-provider-env/dist-types/fromEnv.d.ts +4 -0
- package/node_modules/@aws-sdk/credential-provider-env/dist-types/ts3.4/fromEnv.d.ts +1 -0
- package/node_modules/@aws-sdk/credential-provider-env/package.json +1 -1
- package/node_modules/@aws-sdk/credential-provider-http/package.json +6 -6
- package/node_modules/@aws-sdk/credential-provider-ini/dist-cjs/index.js +3 -2
- package/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveStaticCredentials.js +4 -2
- package/node_modules/@aws-sdk/credential-provider-ini/dist-types/resolveStaticCredentials.d.ts +1 -0
- package/node_modules/@aws-sdk/credential-provider-ini/dist-types/ts3.4/resolveStaticCredentials.d.ts +1 -0
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +8 -8
- package/node_modules/@aws-sdk/credential-provider-node/dist-cjs/index.js +30 -6
- package/node_modules/@aws-sdk/credential-provider-node/dist-es/defaultProvider.js +29 -9
- package/node_modules/@aws-sdk/credential-provider-node/package.json +8 -8
- package/node_modules/@aws-sdk/credential-provider-process/dist-cjs/index.js +9 -3
- package/node_modules/@aws-sdk/credential-provider-process/dist-es/getValidatedProcessCredentials.js +6 -1
- package/node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js +1 -1
- package/node_modules/@aws-sdk/credential-provider-process/dist-types/ProcessCredentials.d.ts +1 -0
- package/node_modules/@aws-sdk/credential-provider-process/dist-types/getValidatedProcessCredentials.d.ts +2 -2
- package/node_modules/@aws-sdk/credential-provider-process/dist-types/ts3.4/ProcessCredentials.d.ts +1 -0
- package/node_modules/@aws-sdk/credential-provider-process/dist-types/ts3.4/getValidatedProcessCredentials.d.ts +3 -2
- package/node_modules/@aws-sdk/credential-provider-process/package.json +1 -1
- package/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/index.js +11 -2
- package/node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js +9 -2
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-host-header/package.json +2 -2
- package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +2 -2
- package/node_modules/@aws-sdk/middleware-user-agent/package.json +2 -2
- package/node_modules/@smithy/core/dist-cjs/index.js +4 -2
- package/node_modules/@smithy/core/dist-es/util-identity-and-auth/httpAuthSchemes/httpApiKeyAuth.js +2 -1
- package/node_modules/@smithy/core/dist-es/util-identity-and-auth/httpAuthSchemes/httpBearerAuth.js +2 -1
- package/node_modules/@smithy/core/package.json +5 -5
- package/node_modules/@smithy/credential-provider-imds/dist-cjs/index.js +2 -1
- package/node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/ImdsCredentials.js +1 -0
- package/node_modules/@smithy/credential-provider-imds/dist-types/remoteProvider/ImdsCredentials.d.ts +1 -0
- package/node_modules/@smithy/credential-provider-imds/dist-types/ts3.4/remoteProvider/ImdsCredentials.d.ts +1 -0
- package/node_modules/@smithy/credential-provider-imds/package.json +1 -1
- package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +2 -1
- package/node_modules/@smithy/fetch-http-handler/dist-es/fetch-http-handler.js +1 -1
- package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
- package/node_modules/@smithy/middleware-content-length/package.json +3 -3
- package/node_modules/@smithy/middleware-endpoint/dist-cjs/index.js +7 -0
- package/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/createConfigValueProvider.js +7 -0
- package/node_modules/@smithy/middleware-endpoint/package.json +1 -1
- package/node_modules/@smithy/middleware-retry/package.json +4 -4
- package/node_modules/@smithy/node-http-handler/package.json +2 -2
- package/node_modules/@smithy/protocol-http/package.json +1 -1
- package/node_modules/@smithy/signature-v4/dist-cjs/index.js +4 -16
- package/node_modules/@smithy/signature-v4/dist-es/moveHeadersToQuery.js +2 -2
- package/node_modules/@smithy/signature-v4/dist-es/prepareRequest.js +2 -2
- package/node_modules/@smithy/signature-v4/dist-types/SignatureV4.d.ts +1 -1
- package/node_modules/@smithy/signature-v4/dist-types/moveHeadersToQuery.d.ts +3 -3
- package/node_modules/@smithy/signature-v4/dist-types/prepareRequest.d.ts +2 -2
- package/node_modules/@smithy/signature-v4/dist-types/ts3.4/SignatureV4.d.ts +1 -1
- package/node_modules/@smithy/signature-v4/dist-types/ts3.4/moveHeadersToQuery.d.ts +3 -3
- package/node_modules/@smithy/signature-v4/dist-types/ts3.4/prepareRequest.d.ts +2 -2
- package/node_modules/@smithy/signature-v4/package.json +2 -2
- package/node_modules/@smithy/smithy-client/dist-cjs/index.js +1 -0
- package/node_modules/@smithy/smithy-client/dist-es/command.js +1 -0
- package/node_modules/@smithy/smithy-client/package.json +4 -4
- package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -2
- package/node_modules/@smithy/util-defaults-mode-node/package.json +3 -3
- package/node_modules/@smithy/util-stream/dist-types/stream-type-check.d.ts +9 -1
- package/node_modules/@smithy/util-stream/dist-types/ts3.4/stream-type-check.d.ts +9 -1
- package/node_modules/@smithy/util-stream/package.json +4 -4
- package/node_modules/fast-xml-parser/CHANGELOG.md +349 -309
- package/node_modules/fast-xml-parser/README.md +83 -51
- package/node_modules/fast-xml-parser/package.json +8 -5
- package/node_modules/fast-xml-parser/src/fxp.d.ts +365 -71
- package/node_modules/fast-xml-parser/src/v5/CharsSymbol.js +16 -0
- package/node_modules/fast-xml-parser/src/v5/EntitiesParser.js +107 -0
- package/node_modules/fast-xml-parser/src/v5/OptionsBuilder.js +64 -0
- package/node_modules/fast-xml-parser/src/v5/OutputBuilders/BaseOutputBuilder.js +71 -0
- package/node_modules/fast-xml-parser/src/v5/OutputBuilders/JsArrBuilder.js +103 -0
- package/node_modules/fast-xml-parser/src/v5/OutputBuilders/JsMinArrBuilder.js +102 -0
- package/node_modules/fast-xml-parser/src/v5/OutputBuilders/JsObjBuilder.js +156 -0
- package/node_modules/fast-xml-parser/src/v5/OutputBuilders/ParserOptionsBuilder.js +99 -0
- package/node_modules/fast-xml-parser/src/v5/Report.js +0 -0
- package/node_modules/fast-xml-parser/src/v5/TagPath.js +81 -0
- package/node_modules/fast-xml-parser/src/v5/TagPathMatcher.js +15 -0
- package/node_modules/fast-xml-parser/src/v5/XMLParser.js +85 -0
- package/node_modules/fast-xml-parser/src/v5/Xml2JsParser.js +237 -0
- package/node_modules/fast-xml-parser/src/v5/XmlPartReader.js +212 -0
- package/node_modules/fast-xml-parser/src/v5/XmlSpecialTagsReader.js +118 -0
- package/node_modules/fast-xml-parser/src/v5/inputSource/BufferSource.js +118 -0
- package/node_modules/fast-xml-parser/src/v5/inputSource/StringSource.js +123 -0
- package/node_modules/fast-xml-parser/src/v5/valueParsers/EntitiesParser.js +107 -0
- package/node_modules/fast-xml-parser/src/v5/valueParsers/booleanParser.js +23 -0
- package/node_modules/fast-xml-parser/src/v5/valueParsers/booleanParserExt.js +20 -0
- package/node_modules/fast-xml-parser/src/v5/valueParsers/currency.js +40 -0
- package/node_modules/fast-xml-parser/src/v5/valueParsers/join.js +14 -0
- package/node_modules/fast-xml-parser/src/v5/valueParsers/number.js +16 -0
- package/node_modules/fast-xml-parser/src/v5/valueParsers/trim.js +8 -0
- package/node_modules/fast-xml-parser/src/validator.js +2 -0
- package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +31 -9
- package/node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js +4 -0
- package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +25 -12
- package/package.json +8 -8
- package/node_modules/@smithy/signature-v4/dist-cjs/cloneRequest.js +0 -1
- package/node_modules/@smithy/signature-v4/dist-es/cloneRequest.js +0 -12
- package/node_modules/@smithy/signature-v4/dist-types/cloneRequest.d.ts +0 -6
- package/node_modules/@smithy/signature-v4/dist-types/ts3.4/cloneRequest.d.ts +0 -6
@@ -0,0 +1,71 @@
|
|
1
|
+
class BaseOutputBuilder{
|
2
|
+
constructor(){
|
3
|
+
// this.attributes = {};
|
4
|
+
}
|
5
|
+
|
6
|
+
addAttribute(name, value){
|
7
|
+
if(this.options.onAttribute){
|
8
|
+
//TODO: better to pass tag path
|
9
|
+
const v = this.options.onAttribute(name, value, this.tagName);
|
10
|
+
if(v) this.attributes[v.name] = v.value;
|
11
|
+
}else{
|
12
|
+
name = this.options.attributes.prefix + name + this.options.attributes.suffix;
|
13
|
+
this.attributes[name] = this.parseValue(value, this.options.attributes.valueParsers);
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
/**
|
18
|
+
* parse value by chain of parsers
|
19
|
+
* @param {string} val
|
20
|
+
* @returns {any} parsed value if matching parser found
|
21
|
+
*/
|
22
|
+
parseValue = function(val, valParsers){
|
23
|
+
for (let i = 0; i < valParsers.length; i++) {
|
24
|
+
let valParser = valParsers[i];
|
25
|
+
if(typeof valParser === "string"){
|
26
|
+
valParser = this.registeredParsers[valParser];
|
27
|
+
}
|
28
|
+
if(valParser){
|
29
|
+
val = valParser.parse(val);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return val;
|
33
|
+
}
|
34
|
+
|
35
|
+
/**
|
36
|
+
* To add a nested empty tag.
|
37
|
+
* @param {string} key
|
38
|
+
* @param {any} val
|
39
|
+
*/
|
40
|
+
_addChild(key, val){}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* skip the comment if property is not set
|
44
|
+
*/
|
45
|
+
addComment(text){
|
46
|
+
if(this.options.nameFor.comment)
|
47
|
+
this._addChild(this.options.nameFor.comment, text);
|
48
|
+
}
|
49
|
+
|
50
|
+
//store CDATA separately if property is set
|
51
|
+
//otherwise add to tag's value
|
52
|
+
addCdata(text){
|
53
|
+
if (this.options.nameFor.cdata) {
|
54
|
+
this._addChild(this.options.nameFor.cdata, text);
|
55
|
+
} else {
|
56
|
+
this.addRawValue(text || "");
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
addRawValue = text => this.addValue(text);
|
61
|
+
|
62
|
+
addDeclaration(){
|
63
|
+
if(!this.options.declaration){
|
64
|
+
}else{
|
65
|
+
this.addPi("?xml");
|
66
|
+
}
|
67
|
+
this.attributes = {}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
module.exports = BaseOutputBuilder;
|
@@ -0,0 +1,103 @@
|
|
1
|
+
const {buildOptions,registerCommonValueParsers} = require("./ParserOptionsBuilder");
|
2
|
+
|
3
|
+
class OutputBuilder{
|
4
|
+
constructor(options){
|
5
|
+
this.options = buildOptions(options);
|
6
|
+
this.registeredParsers = registerCommonValueParsers(this.options);
|
7
|
+
}
|
8
|
+
|
9
|
+
registerValueParser(name,parserInstance){//existing name will override the parser without warning
|
10
|
+
this.registeredParsers[name] = parserInstance;
|
11
|
+
}
|
12
|
+
|
13
|
+
getInstance(parserOptions){
|
14
|
+
return new JsArrBuilder(parserOptions, this.options, this.registeredParsers);
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
const rootName = '!js_arr';
|
19
|
+
const BaseOutputBuilder = require("./BaseOutputBuilder");
|
20
|
+
|
21
|
+
class JsArrBuilder extends BaseOutputBuilder{
|
22
|
+
|
23
|
+
constructor(parserOptions, options,registeredParsers) {
|
24
|
+
super();
|
25
|
+
this.tagsStack = [];
|
26
|
+
this.parserOptions = parserOptions;
|
27
|
+
this.options = options;
|
28
|
+
this.registeredParsers = registeredParsers;
|
29
|
+
|
30
|
+
this.root = new Node(rootName);
|
31
|
+
this.currentNode = this.root;
|
32
|
+
this.attributes = {};
|
33
|
+
}
|
34
|
+
|
35
|
+
addTag(tag){
|
36
|
+
//when a new tag is added, it should be added as child of current node
|
37
|
+
//TODO: shift this check to the parser
|
38
|
+
if(tag.name === "__proto__") tag.name = "#__proto__";
|
39
|
+
|
40
|
+
this.tagsStack.push(this.currentNode);
|
41
|
+
this.currentNode = new Node(tag.name, this.attributes);
|
42
|
+
this.attributes = {};
|
43
|
+
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Check if the node should be added by checking user's preference
|
47
|
+
* @param {Node} node
|
48
|
+
* @returns boolean: true if the node should not be added
|
49
|
+
*/
|
50
|
+
closeTag(){
|
51
|
+
const node = this.currentNode;
|
52
|
+
this.currentNode = this.tagsStack.pop(); //set parent node in scope
|
53
|
+
if(this.options.onClose !== undefined){
|
54
|
+
//TODO TagPathMatcher
|
55
|
+
const resultTag = this.options.onClose(node,
|
56
|
+
new TagPathMatcher(this.tagsStack,node));
|
57
|
+
|
58
|
+
if(resultTag) return;
|
59
|
+
}
|
60
|
+
this.currentNode.child.push(node); //to parent node
|
61
|
+
}
|
62
|
+
|
63
|
+
//Called by parent class methods
|
64
|
+
_addChild(key, val){
|
65
|
+
// if(key === "__proto__") tagName = "#__proto__";
|
66
|
+
this.currentNode.child.push( {[key]: val });
|
67
|
+
// this.currentNode.leafType = false;
|
68
|
+
}
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Add text value child node
|
72
|
+
* @param {string} text
|
73
|
+
*/
|
74
|
+
addValue(text){
|
75
|
+
this.currentNode.child.push( {[this.options.nameFor.text]: this.parseValue(text, this.options.tags.valueParsers) });
|
76
|
+
}
|
77
|
+
|
78
|
+
addPi(name){
|
79
|
+
//TODO: set pi flag
|
80
|
+
if(!this.options.ignorePiTags){
|
81
|
+
const node = new Node(name, this.attributes);
|
82
|
+
this.currentNode[":@"] = this.attributes;
|
83
|
+
this.currentNode.child.push(node);
|
84
|
+
}
|
85
|
+
this.attributes = {};
|
86
|
+
}
|
87
|
+
getOutput(){
|
88
|
+
return this.root.child[0];
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
class Node{
|
95
|
+
constructor(tagname, attributes){
|
96
|
+
this.tagname = tagname;
|
97
|
+
this.child = []; //nested tags, text, cdata, comments
|
98
|
+
if(attributes && Object.keys(attributes).length > 0)
|
99
|
+
this[":@"] = attributes;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
module.exports = OutputBuilder;
|
@@ -0,0 +1,102 @@
|
|
1
|
+
const {buildOptions,registerCommonValueParsers} = require("./ParserOptionsBuilder");
|
2
|
+
|
3
|
+
class OutputBuilder{
|
4
|
+
constructor(options){
|
5
|
+
this.options = buildOptions(options);
|
6
|
+
this.registeredParsers = registerCommonValueParsers(this.options);
|
7
|
+
}
|
8
|
+
|
9
|
+
registerValueParser(name,parserInstance){//existing name will override the parser without warning
|
10
|
+
this.registeredParsers[name] = parserInstance;
|
11
|
+
}
|
12
|
+
|
13
|
+
getInstance(parserOptions){
|
14
|
+
return new JsMinArrBuilder(parserOptions, this.options, this.registeredParsers);
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
const BaseOutputBuilder = require("./BaseOutputBuilder");
|
19
|
+
const rootName = '^';
|
20
|
+
|
21
|
+
class JsMinArrBuilder extends BaseOutputBuilder{
|
22
|
+
|
23
|
+
constructor(parserOptions, options,registeredParsers) {
|
24
|
+
super();
|
25
|
+
this.tagsStack = [];
|
26
|
+
this.parserOptions = parserOptions;
|
27
|
+
this.options = options;
|
28
|
+
this.registeredParsers = registeredParsers;
|
29
|
+
|
30
|
+
this.root = {[rootName]: []};
|
31
|
+
this.currentNode = this.root;
|
32
|
+
this.currentNodeTagName = rootName;
|
33
|
+
this.attributes = {};
|
34
|
+
}
|
35
|
+
|
36
|
+
addTag(tag){
|
37
|
+
//when a new tag is added, it should be added as child of current node
|
38
|
+
//TODO: shift this check to the parser
|
39
|
+
if(tag.name === "__proto__") tag.name = "#__proto__";
|
40
|
+
|
41
|
+
this.tagsStack.push([this.currentNodeTagName,this.currentNode]); //this.currentNode is parent node here
|
42
|
+
this.currentNodeTagName = tag.name;
|
43
|
+
this.currentNode = { [tag.name]:[]}
|
44
|
+
if(Object.keys(this.attributes).length > 0){
|
45
|
+
this.currentNode[":@"] = this.attributes;
|
46
|
+
this.attributes = {};
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Check if the node should be added by checking user's preference
|
52
|
+
* @param {Node} node
|
53
|
+
* @returns boolean: true if the node should not be added
|
54
|
+
*/
|
55
|
+
closeTag(){
|
56
|
+
const node = this.currentNode;
|
57
|
+
const nodeName = this.currentNodeTagName;
|
58
|
+
const arr = this.tagsStack.pop(); //set parent node in scope
|
59
|
+
this.currentNodeTagName = arr[0];
|
60
|
+
this.currentNode = arr[1];
|
61
|
+
|
62
|
+
if(this.options.onClose !== undefined){
|
63
|
+
//TODO TagPathMatcher
|
64
|
+
const resultTag = this.options.onClose(node,
|
65
|
+
new TagPathMatcher(this.tagsStack,node));
|
66
|
+
|
67
|
+
if(resultTag) return;
|
68
|
+
}
|
69
|
+
this.currentNode[this.currentNodeTagName].push(node); //to parent node
|
70
|
+
}
|
71
|
+
|
72
|
+
//Called by parent class methods
|
73
|
+
_addChild(key, val){
|
74
|
+
// if(key === "__proto__") tagName = "#__proto__";
|
75
|
+
this.currentNode.push( {[key]: val });
|
76
|
+
// this.currentNode.leafType = false;
|
77
|
+
}
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Add text value child node
|
81
|
+
* @param {string} text
|
82
|
+
*/
|
83
|
+
addValue(text){
|
84
|
+
this.currentNode[this.currentNodeTagName].push( {[this.options.nameFor.text]: this.parseValue(text, this.options.tags.valueParsers) });
|
85
|
+
}
|
86
|
+
|
87
|
+
addPi(name){
|
88
|
+
if(!this.options.ignorePiTags){
|
89
|
+
const node = { [name]:[]}
|
90
|
+
if(this.attributes){
|
91
|
+
node[":@"] = this.attributes;
|
92
|
+
}
|
93
|
+
this.currentNode.push(node);
|
94
|
+
}
|
95
|
+
this.attributes = {};
|
96
|
+
}
|
97
|
+
getOutput(){
|
98
|
+
return this.root[rootName];
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
module.exports = OutputBuilder;
|
@@ -0,0 +1,156 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
const {buildOptions,registerCommonValueParsers} = require("./ParserOptionsBuilder");
|
4
|
+
|
5
|
+
class OutputBuilder{
|
6
|
+
constructor(builderOptions){
|
7
|
+
this.options = buildOptions(builderOptions);
|
8
|
+
this.registeredParsers = registerCommonValueParsers(this.options);
|
9
|
+
}
|
10
|
+
|
11
|
+
registerValueParser(name,parserInstance){//existing name will override the parser without warning
|
12
|
+
this.registeredParsers[name] = parserInstance;
|
13
|
+
}
|
14
|
+
|
15
|
+
getInstance(parserOptions){
|
16
|
+
return new JsObjBuilder(parserOptions, this.options, this.registeredParsers);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
const BaseOutputBuilder = require("./BaseOutputBuilder");
|
21
|
+
const rootName = '^';
|
22
|
+
|
23
|
+
class JsObjBuilder extends BaseOutputBuilder{
|
24
|
+
|
25
|
+
constructor(parserOptions, builderOptions,registeredParsers) {
|
26
|
+
super();
|
27
|
+
//hold the raw detail of a tag and sequence with reference to the output
|
28
|
+
this.tagsStack = [];
|
29
|
+
this.parserOptions = parserOptions;
|
30
|
+
this.options = builderOptions;
|
31
|
+
this.registeredParsers = registeredParsers;
|
32
|
+
|
33
|
+
this.root = {};
|
34
|
+
this.parent = this.root;
|
35
|
+
this.tagName = rootName;
|
36
|
+
this.value = {};
|
37
|
+
this.textValue = "";
|
38
|
+
this.attributes = {};
|
39
|
+
}
|
40
|
+
|
41
|
+
addTag(tag){
|
42
|
+
|
43
|
+
let value = "";
|
44
|
+
if( !isEmpty(this.attributes)){
|
45
|
+
value = {};
|
46
|
+
if(this.options.attributes.groupBy){
|
47
|
+
value[this.options.attributes.groupBy] = this.attributes;
|
48
|
+
}else{
|
49
|
+
value = this.attributes;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
this.tagsStack.push([this.tagName, this.textValue, this.value]); //parent tag, parent text value, parent tag value (jsobj)
|
54
|
+
this.tagName = tag.name;
|
55
|
+
this.value = value;
|
56
|
+
this.textValue = "";
|
57
|
+
this.attributes = {};
|
58
|
+
}
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Check if the node should be added by checking user's preference
|
62
|
+
* @param {Node} node
|
63
|
+
* @returns boolean: true if the node should not be added
|
64
|
+
*/
|
65
|
+
closeTag(){
|
66
|
+
const tagName = this.tagName;
|
67
|
+
let value = this.value;
|
68
|
+
let textValue = this.textValue;
|
69
|
+
|
70
|
+
//update tag text value
|
71
|
+
if(typeof value !== "object" && !Array.isArray(value)){
|
72
|
+
value = this.parseValue(textValue.trim(), this.options.tags.valueParsers);
|
73
|
+
}else if(textValue.length > 0){
|
74
|
+
value[this.options.nameFor.text] = this.parseValue(textValue.trim(), this.options.tags.valueParsers);
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
let resultTag= {
|
79
|
+
tagName: tagName,
|
80
|
+
value: value
|
81
|
+
};
|
82
|
+
|
83
|
+
if(this.options.onTagClose !== undefined){
|
84
|
+
//TODO TagPathMatcher
|
85
|
+
resultTag = this.options.onClose(tagName, value, this.textValue, new TagPathMatcher(this.tagsStack,node));
|
86
|
+
|
87
|
+
if(!resultTag) return;
|
88
|
+
}
|
89
|
+
|
90
|
+
//set parent node in scope
|
91
|
+
let arr = this.tagsStack.pop();
|
92
|
+
let parentTag = arr[2];
|
93
|
+
parentTag=this._addChildTo(resultTag.tagName, resultTag.value, parentTag);
|
94
|
+
|
95
|
+
this.tagName = arr[0];
|
96
|
+
this.textValue = arr[1];
|
97
|
+
this.value = parentTag;
|
98
|
+
}
|
99
|
+
|
100
|
+
_addChild(key, val){
|
101
|
+
if(typeof this.value === "string"){
|
102
|
+
this.value = { [this.options.nameFor.text] : this.value };
|
103
|
+
}
|
104
|
+
|
105
|
+
this._addChildTo(key, val, this.value);
|
106
|
+
// this.currentNode.leafType = false;
|
107
|
+
this.attributes = {};
|
108
|
+
}
|
109
|
+
|
110
|
+
_addChildTo(key, val, node){
|
111
|
+
if(typeof node === 'string') node = {};
|
112
|
+
if(!node[key]){
|
113
|
+
node[key] = val;
|
114
|
+
}else{ //Repeated
|
115
|
+
if(!Array.isArray(node[key])){ //but not stored as array
|
116
|
+
node[key] = [node[key]];
|
117
|
+
}
|
118
|
+
node[key].push(val);
|
119
|
+
}
|
120
|
+
return node;
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Add text value child node
|
126
|
+
* @param {string} text
|
127
|
+
*/
|
128
|
+
addValue(text){
|
129
|
+
//TODO: use bytes join
|
130
|
+
if(this.textValue.length > 0) this.textValue += " " + text;
|
131
|
+
else this.textValue = text;
|
132
|
+
}
|
133
|
+
|
134
|
+
addPi(name){
|
135
|
+
let value = "";
|
136
|
+
if( !isEmpty(this.attributes)){
|
137
|
+
value = {};
|
138
|
+
if(this.options.attributes.groupBy){
|
139
|
+
value[this.options.attributes.groupBy] = this.attributes;
|
140
|
+
}else{
|
141
|
+
value = this.attributes;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
this._addChild(name, value);
|
145
|
+
|
146
|
+
}
|
147
|
+
getOutput(){
|
148
|
+
return this.value;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
function isEmpty(obj) {
|
153
|
+
return Object.keys(obj).length === 0;
|
154
|
+
}
|
155
|
+
|
156
|
+
module.exports = OutputBuilder;
|
@@ -0,0 +1,99 @@
|
|
1
|
+
const trimParser = require("../valueParsers/trim")
|
2
|
+
const booleanParser = require("../valueParsers/booleanParser")
|
3
|
+
const currencyParser = require("../valueParsers/currency")
|
4
|
+
const numberParser = require("../valueParsers/number")
|
5
|
+
|
6
|
+
const defaultOptions={
|
7
|
+
nameFor:{
|
8
|
+
text: "#text",
|
9
|
+
comment: "",
|
10
|
+
cdata: "",
|
11
|
+
},
|
12
|
+
// onTagClose: () => {},
|
13
|
+
// onAttribute: () => {},
|
14
|
+
piTag: false,
|
15
|
+
declaration: false, //"?xml"
|
16
|
+
tags: {
|
17
|
+
valueParsers: [
|
18
|
+
// "trim",
|
19
|
+
// "boolean",
|
20
|
+
// "number",
|
21
|
+
// "currency",
|
22
|
+
// "date",
|
23
|
+
]
|
24
|
+
},
|
25
|
+
attributes:{
|
26
|
+
prefix: "@_",
|
27
|
+
suffix: "",
|
28
|
+
groupBy: "",
|
29
|
+
|
30
|
+
valueParsers: [
|
31
|
+
// "trim",
|
32
|
+
// "boolean",
|
33
|
+
// "number",
|
34
|
+
// "currency",
|
35
|
+
// "date",
|
36
|
+
]
|
37
|
+
},
|
38
|
+
dataType:{
|
39
|
+
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
//TODO
|
44
|
+
const withJoin = ["trim","join", /*"entities",*/"number","boolean","currency"/*, "date"*/]
|
45
|
+
const withoutJoin = ["trim", /*"entities",*/"number","boolean","currency"/*, "date"*/]
|
46
|
+
|
47
|
+
function buildOptions(options){
|
48
|
+
//clone
|
49
|
+
const finalOptions = { ... defaultOptions};
|
50
|
+
|
51
|
+
//add config missed in cloning
|
52
|
+
finalOptions.tags.valueParsers.push(...withJoin)
|
53
|
+
if(!this.preserveOrder)
|
54
|
+
finalOptions.tags.valueParsers.push(...withoutJoin);
|
55
|
+
|
56
|
+
//add config missed in cloning
|
57
|
+
finalOptions.attributes.valueParsers.push(...withJoin)
|
58
|
+
|
59
|
+
//override configuration
|
60
|
+
copyProperties(finalOptions,options);
|
61
|
+
return finalOptions;
|
62
|
+
}
|
63
|
+
|
64
|
+
function copyProperties(target, source) {
|
65
|
+
for (let key in source) {
|
66
|
+
if (source.hasOwnProperty(key)) {
|
67
|
+
if (typeof source[key] === 'object' && !Array.isArray(source[key])) {
|
68
|
+
// Recursively copy nested properties
|
69
|
+
if (typeof target[key] === 'undefined') {
|
70
|
+
target[key] = {};
|
71
|
+
}
|
72
|
+
copyProperties(target[key], source[key]);
|
73
|
+
} else {
|
74
|
+
// Copy non-nested properties
|
75
|
+
target[key] = source[key];
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
function registerCommonValueParsers(options){
|
82
|
+
return {
|
83
|
+
"trim": new trimParser(),
|
84
|
+
// "join": this.entityParser.parse,
|
85
|
+
"boolean": new booleanParser(),
|
86
|
+
"number": new numberParser({
|
87
|
+
hex: true,
|
88
|
+
leadingZeros: true,
|
89
|
+
eNotation: true
|
90
|
+
}),
|
91
|
+
"currency": new currencyParser(),
|
92
|
+
// "date": this.entityParser.parse,
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
module.exports = {
|
97
|
+
buildOptions : buildOptions,
|
98
|
+
registerCommonValueParsers: registerCommonValueParsers
|
99
|
+
}
|
File without changes
|
@@ -0,0 +1,81 @@
|
|
1
|
+
class TagPath{
|
2
|
+
constructor(pathStr){
|
3
|
+
let text = "";
|
4
|
+
let tName = "";
|
5
|
+
let pos;
|
6
|
+
let aName = "";
|
7
|
+
let aVal = "";
|
8
|
+
this.stack = []
|
9
|
+
|
10
|
+
for (let i = 0; i < pathStr.length; i++) {
|
11
|
+
let ch = pathStr[i];
|
12
|
+
if(ch === " ") {
|
13
|
+
if(text.length === 0) continue;
|
14
|
+
tName = text; text = "";
|
15
|
+
}else if(ch === "["){
|
16
|
+
if(tName.length === 0){
|
17
|
+
tName = text; text = "";
|
18
|
+
}
|
19
|
+
i++;
|
20
|
+
for (; i < pathStr.length; i++) {
|
21
|
+
ch = pathStr[i];
|
22
|
+
if(ch=== "=") continue;
|
23
|
+
else if(ch=== "]") {aName = text.trim(); text=""; break; i--;}
|
24
|
+
else if(ch === "'" || ch === '"'){
|
25
|
+
let attrEnd = pathStr.indexOf(ch,i+1);
|
26
|
+
aVal = pathStr.substring(i+1, attrEnd);
|
27
|
+
i = attrEnd;
|
28
|
+
}else{
|
29
|
+
text +=ch;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}else if(ch !== " " && text.length === 0 && tName.length > 0){//reading tagName
|
33
|
+
//save previous tag
|
34
|
+
this.stack.push(new TagPathNode(tName,pos,aName,aVal));
|
35
|
+
text = ch; tName = ""; aName = ""; aVal = "";
|
36
|
+
}else{
|
37
|
+
text+=ch;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
//last tag in the path
|
42
|
+
if(tName.length >0 || text.length>0){
|
43
|
+
this.stack.push(new TagPathNode(text||tName,pos,aName,aVal));
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
match(tagStack,node){
|
48
|
+
if(this.stack[0].name !== "*"){
|
49
|
+
if(this.stack.length !== tagStack.length +1) return false;
|
50
|
+
|
51
|
+
//loop through tagPath and tagStack and match
|
52
|
+
for (let i = 0; i < this.tagStack.length; i++) {
|
53
|
+
if(!this.stack[i].match(tagStack[i])) return false;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
if(!this.stack[this.stack.length - 1].match(node)) return false;
|
57
|
+
return true;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
class TagPathNode{
|
62
|
+
constructor(name,position,attrName,attrVal){
|
63
|
+
this.name = name;
|
64
|
+
this.position = position;
|
65
|
+
this.attrName = attrName,
|
66
|
+
this.attrVal = attrVal;
|
67
|
+
}
|
68
|
+
|
69
|
+
match(node){
|
70
|
+
let matching = true;
|
71
|
+
matching = node.name === this.name;
|
72
|
+
if(this.position) matching = node.position === this.position;
|
73
|
+
if(this.attrName) matching = node.attrs[this.attrName !== undefined];
|
74
|
+
if(this.attrVal) matching = node.attrs[this.attrName !== this.attrVal];
|
75
|
+
return matching;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
// console.log((new TagPath("* b[b]")).stack);
|
80
|
+
// console.log((new TagPath("a[a] b[b] c")).stack);
|
81
|
+
// console.log((new TagPath(" b [ b= 'cf sdadwa' ] a ")).stack);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
const TagPath = require("./TagPath");
|
2
|
+
|
3
|
+
class TagPathMatcher{
|
4
|
+
constructor(stack,node){
|
5
|
+
this.stack = stack;
|
6
|
+
this.node= node;
|
7
|
+
}
|
8
|
+
|
9
|
+
match(path){
|
10
|
+
const tagPath = new TagPath(path);
|
11
|
+
return tagPath.match(this.stack, this.node);
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
module.exports = TagPathMatcher;
|