@cdk8s/awscdk-resolver 0.0.134 → 0.0.136

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/.jsii +4 -4
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/index.js +9 -15
  4. package/node_modules/@aws-sdk/client-cloudformation/dist-es/CloudFormationClient.js +9 -15
  5. package/node_modules/@aws-sdk/client-cloudformation/dist-types/CloudFormationClient.d.ts +2 -4
  6. package/node_modules/@aws-sdk/client-cloudformation/dist-types/auth/httpAuthSchemeProvider.d.ts +4 -4
  7. package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.browser.d.ts +2 -2
  8. package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.d.ts +2 -2
  9. package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.native.d.ts +2 -2
  10. package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/CloudFormationClient.d.ts +6 -8
  11. package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.browser.d.ts +5 -5
  12. package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.d.ts +5 -5
  13. package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.native.d.ts +5 -5
  14. package/node_modules/@aws-sdk/client-cloudformation/package.json +18 -18
  15. package/node_modules/@aws-sdk/client-sso/dist-cjs/index.js +9 -15
  16. package/node_modules/@aws-sdk/client-sso/dist-es/SSOClient.js +9 -15
  17. package/node_modules/@aws-sdk/client-sso/dist-types/SSOClient.d.ts +2 -4
  18. package/node_modules/@aws-sdk/client-sso/dist-types/auth/httpAuthSchemeProvider.d.ts +4 -4
  19. package/node_modules/@aws-sdk/client-sso/dist-types/runtimeConfig.browser.d.ts +2 -2
  20. package/node_modules/@aws-sdk/client-sso/dist-types/runtimeConfig.d.ts +2 -2
  21. package/node_modules/@aws-sdk/client-sso/dist-types/runtimeConfig.native.d.ts +2 -2
  22. package/node_modules/@aws-sdk/client-sso/dist-types/ts3.4/SSOClient.d.ts +6 -8
  23. package/node_modules/@aws-sdk/client-sso/dist-types/ts3.4/runtimeConfig.browser.d.ts +5 -5
  24. package/node_modules/@aws-sdk/client-sso/dist-types/ts3.4/runtimeConfig.d.ts +5 -5
  25. package/node_modules/@aws-sdk/client-sso/dist-types/ts3.4/runtimeConfig.native.d.ts +5 -5
  26. package/node_modules/@aws-sdk/client-sso/package.json +15 -15
  27. package/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/index.js +9 -15
  28. package/node_modules/@aws-sdk/client-sso-oidc/dist-es/SSOOIDCClient.js +9 -15
  29. package/node_modules/@aws-sdk/client-sso-oidc/dist-types/SSOOIDCClient.d.ts +2 -4
  30. package/node_modules/@aws-sdk/client-sso-oidc/dist-types/auth/httpAuthSchemeProvider.d.ts +4 -4
  31. package/node_modules/@aws-sdk/client-sso-oidc/dist-types/runtimeConfig.browser.d.ts +2 -2
  32. package/node_modules/@aws-sdk/client-sso-oidc/dist-types/runtimeConfig.d.ts +2 -2
  33. package/node_modules/@aws-sdk/client-sso-oidc/dist-types/runtimeConfig.native.d.ts +2 -2
  34. package/node_modules/@aws-sdk/client-sso-oidc/dist-types/ts3.4/SSOOIDCClient.d.ts +6 -8
  35. package/node_modules/@aws-sdk/client-sso-oidc/dist-types/ts3.4/runtimeConfig.browser.d.ts +5 -5
  36. package/node_modules/@aws-sdk/client-sso-oidc/dist-types/ts3.4/runtimeConfig.d.ts +5 -5
  37. package/node_modules/@aws-sdk/client-sso-oidc/dist-types/ts3.4/runtimeConfig.native.d.ts +5 -5
  38. package/node_modules/@aws-sdk/client-sso-oidc/package.json +17 -17
  39. package/node_modules/@aws-sdk/client-sts/dist-cjs/STSClient.js +9 -15
  40. package/node_modules/@aws-sdk/client-sts/dist-cjs/index.js +17 -4
  41. package/node_modules/@aws-sdk/client-sts/dist-es/STSClient.js +9 -15
  42. package/node_modules/@aws-sdk/client-sts/dist-es/defaultStsRoleAssumers.js +17 -4
  43. package/node_modules/@aws-sdk/client-sts/dist-types/STSClient.d.ts +2 -4
  44. package/node_modules/@aws-sdk/client-sts/dist-types/auth/httpAuthSchemeProvider.d.ts +4 -4
  45. package/node_modules/@aws-sdk/client-sts/dist-types/runtimeConfig.browser.d.ts +2 -2
  46. package/node_modules/@aws-sdk/client-sts/dist-types/runtimeConfig.d.ts +2 -2
  47. package/node_modules/@aws-sdk/client-sts/dist-types/runtimeConfig.native.d.ts +2 -2
  48. package/node_modules/@aws-sdk/client-sts/dist-types/ts3.4/STSClient.d.ts +6 -8
  49. package/node_modules/@aws-sdk/client-sts/dist-types/ts3.4/runtimeConfig.browser.d.ts +5 -5
  50. package/node_modules/@aws-sdk/client-sts/dist-types/ts3.4/runtimeConfig.d.ts +5 -5
  51. package/node_modules/@aws-sdk/client-sts/dist-types/ts3.4/runtimeConfig.native.d.ts +5 -5
  52. package/node_modules/@aws-sdk/client-sts/package.json +17 -17
  53. package/node_modules/@aws-sdk/core/account-id-endpoint.js +6 -0
  54. package/node_modules/@aws-sdk/core/dist-cjs/submodules/account-id-endpoint/index.js +97 -0
  55. package/node_modules/@aws-sdk/core/dist-es/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.js +15 -0
  56. package/node_modules/@aws-sdk/core/dist-es/submodules/account-id-endpoint/AccountIdEndpointModeConstants.js +5 -0
  57. package/node_modules/@aws-sdk/core/dist-es/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.js +24 -0
  58. package/node_modules/@aws-sdk/core/dist-es/submodules/account-id-endpoint/index.js +3 -0
  59. package/node_modules/@aws-sdk/core/dist-types/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.d.ts +30 -0
  60. package/node_modules/@aws-sdk/core/dist-types/submodules/account-id-endpoint/AccountIdEndpointModeConstants.d.ts +7 -0
  61. package/node_modules/@aws-sdk/core/dist-types/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.d.ts +14 -0
  62. package/node_modules/@aws-sdk/core/dist-types/submodules/account-id-endpoint/index.d.ts +3 -0
  63. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.d.ts +15 -0
  64. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/AccountIdEndpointModeConstants.d.ts +6 -0
  65. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.d.ts +7 -0
  66. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/index.d.ts +3 -0
  67. package/node_modules/@aws-sdk/core/package.json +18 -8
  68. package/node_modules/@aws-sdk/credential-provider-env/dist-cjs/index.js +6 -1
  69. package/node_modules/@aws-sdk/credential-provider-env/dist-es/fromEnv.js +3 -0
  70. package/node_modules/@aws-sdk/credential-provider-env/dist-types/fromEnv.d.ts +4 -0
  71. package/node_modules/@aws-sdk/credential-provider-env/dist-types/ts3.4/fromEnv.d.ts +1 -0
  72. package/node_modules/@aws-sdk/credential-provider-env/package.json +1 -1
  73. package/node_modules/@aws-sdk/credential-provider-http/package.json +6 -6
  74. package/node_modules/@aws-sdk/credential-provider-ini/dist-cjs/index.js +3 -2
  75. package/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveStaticCredentials.js +4 -2
  76. package/node_modules/@aws-sdk/credential-provider-ini/dist-types/resolveStaticCredentials.d.ts +1 -0
  77. package/node_modules/@aws-sdk/credential-provider-ini/dist-types/ts3.4/resolveStaticCredentials.d.ts +1 -0
  78. package/node_modules/@aws-sdk/credential-provider-ini/package.json +8 -8
  79. package/node_modules/@aws-sdk/credential-provider-node/dist-cjs/index.js +30 -6
  80. package/node_modules/@aws-sdk/credential-provider-node/dist-es/defaultProvider.js +29 -9
  81. package/node_modules/@aws-sdk/credential-provider-node/package.json +8 -8
  82. package/node_modules/@aws-sdk/credential-provider-process/dist-cjs/index.js +9 -3
  83. package/node_modules/@aws-sdk/credential-provider-process/dist-es/getValidatedProcessCredentials.js +6 -1
  84. package/node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js +1 -1
  85. package/node_modules/@aws-sdk/credential-provider-process/dist-types/ProcessCredentials.d.ts +1 -0
  86. package/node_modules/@aws-sdk/credential-provider-process/dist-types/getValidatedProcessCredentials.d.ts +2 -2
  87. package/node_modules/@aws-sdk/credential-provider-process/dist-types/ts3.4/ProcessCredentials.d.ts +1 -0
  88. package/node_modules/@aws-sdk/credential-provider-process/dist-types/ts3.4/getValidatedProcessCredentials.d.ts +3 -2
  89. package/node_modules/@aws-sdk/credential-provider-process/package.json +1 -1
  90. package/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/index.js +11 -2
  91. package/node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js +9 -2
  92. package/node_modules/@aws-sdk/credential-provider-sso/package.json +3 -3
  93. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  94. package/node_modules/@aws-sdk/middleware-host-header/package.json +2 -2
  95. package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +2 -2
  96. package/node_modules/@aws-sdk/middleware-user-agent/package.json +2 -2
  97. package/node_modules/@smithy/core/dist-cjs/index.js +4 -2
  98. package/node_modules/@smithy/core/dist-es/util-identity-and-auth/httpAuthSchemes/httpApiKeyAuth.js +2 -1
  99. package/node_modules/@smithy/core/dist-es/util-identity-and-auth/httpAuthSchemes/httpBearerAuth.js +2 -1
  100. package/node_modules/@smithy/core/package.json +5 -5
  101. package/node_modules/@smithy/credential-provider-imds/dist-cjs/index.js +2 -1
  102. package/node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/ImdsCredentials.js +1 -0
  103. package/node_modules/@smithy/credential-provider-imds/dist-types/remoteProvider/ImdsCredentials.d.ts +1 -0
  104. package/node_modules/@smithy/credential-provider-imds/dist-types/ts3.4/remoteProvider/ImdsCredentials.d.ts +1 -0
  105. package/node_modules/@smithy/credential-provider-imds/package.json +1 -1
  106. package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +2 -1
  107. package/node_modules/@smithy/fetch-http-handler/dist-es/fetch-http-handler.js +1 -1
  108. package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
  109. package/node_modules/@smithy/middleware-content-length/package.json +3 -3
  110. package/node_modules/@smithy/middleware-endpoint/dist-cjs/index.js +7 -0
  111. package/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/createConfigValueProvider.js +7 -0
  112. package/node_modules/@smithy/middleware-endpoint/package.json +1 -1
  113. package/node_modules/@smithy/middleware-retry/package.json +4 -4
  114. package/node_modules/@smithy/node-http-handler/package.json +2 -2
  115. package/node_modules/@smithy/protocol-http/package.json +1 -1
  116. package/node_modules/@smithy/signature-v4/dist-cjs/index.js +4 -16
  117. package/node_modules/@smithy/signature-v4/dist-es/moveHeadersToQuery.js +2 -2
  118. package/node_modules/@smithy/signature-v4/dist-es/prepareRequest.js +2 -2
  119. package/node_modules/@smithy/signature-v4/dist-types/SignatureV4.d.ts +1 -1
  120. package/node_modules/@smithy/signature-v4/dist-types/moveHeadersToQuery.d.ts +3 -3
  121. package/node_modules/@smithy/signature-v4/dist-types/prepareRequest.d.ts +2 -2
  122. package/node_modules/@smithy/signature-v4/dist-types/ts3.4/SignatureV4.d.ts +1 -1
  123. package/node_modules/@smithy/signature-v4/dist-types/ts3.4/moveHeadersToQuery.d.ts +3 -3
  124. package/node_modules/@smithy/signature-v4/dist-types/ts3.4/prepareRequest.d.ts +2 -2
  125. package/node_modules/@smithy/signature-v4/package.json +2 -2
  126. package/node_modules/@smithy/smithy-client/dist-cjs/index.js +1 -0
  127. package/node_modules/@smithy/smithy-client/dist-es/command.js +1 -0
  128. package/node_modules/@smithy/smithy-client/package.json +4 -4
  129. package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -2
  130. package/node_modules/@smithy/util-defaults-mode-node/package.json +3 -3
  131. package/node_modules/@smithy/util-stream/dist-types/stream-type-check.d.ts +9 -1
  132. package/node_modules/@smithy/util-stream/dist-types/ts3.4/stream-type-check.d.ts +9 -1
  133. package/node_modules/@smithy/util-stream/package.json +4 -4
  134. package/node_modules/fast-xml-parser/CHANGELOG.md +349 -309
  135. package/node_modules/fast-xml-parser/README.md +83 -51
  136. package/node_modules/fast-xml-parser/package.json +8 -5
  137. package/node_modules/fast-xml-parser/src/fxp.d.ts +365 -71
  138. package/node_modules/fast-xml-parser/src/v5/CharsSymbol.js +16 -0
  139. package/node_modules/fast-xml-parser/src/v5/EntitiesParser.js +107 -0
  140. package/node_modules/fast-xml-parser/src/v5/OptionsBuilder.js +64 -0
  141. package/node_modules/fast-xml-parser/src/v5/OutputBuilders/BaseOutputBuilder.js +71 -0
  142. package/node_modules/fast-xml-parser/src/v5/OutputBuilders/JsArrBuilder.js +103 -0
  143. package/node_modules/fast-xml-parser/src/v5/OutputBuilders/JsMinArrBuilder.js +102 -0
  144. package/node_modules/fast-xml-parser/src/v5/OutputBuilders/JsObjBuilder.js +156 -0
  145. package/node_modules/fast-xml-parser/src/v5/OutputBuilders/ParserOptionsBuilder.js +99 -0
  146. package/node_modules/fast-xml-parser/src/v5/Report.js +0 -0
  147. package/node_modules/fast-xml-parser/src/v5/TagPath.js +81 -0
  148. package/node_modules/fast-xml-parser/src/v5/TagPathMatcher.js +15 -0
  149. package/node_modules/fast-xml-parser/src/v5/XMLParser.js +85 -0
  150. package/node_modules/fast-xml-parser/src/v5/Xml2JsParser.js +237 -0
  151. package/node_modules/fast-xml-parser/src/v5/XmlPartReader.js +212 -0
  152. package/node_modules/fast-xml-parser/src/v5/XmlSpecialTagsReader.js +118 -0
  153. package/node_modules/fast-xml-parser/src/v5/inputSource/BufferSource.js +118 -0
  154. package/node_modules/fast-xml-parser/src/v5/inputSource/StringSource.js +123 -0
  155. package/node_modules/fast-xml-parser/src/v5/valueParsers/EntitiesParser.js +107 -0
  156. package/node_modules/fast-xml-parser/src/v5/valueParsers/booleanParser.js +23 -0
  157. package/node_modules/fast-xml-parser/src/v5/valueParsers/booleanParserExt.js +20 -0
  158. package/node_modules/fast-xml-parser/src/v5/valueParsers/currency.js +40 -0
  159. package/node_modules/fast-xml-parser/src/v5/valueParsers/join.js +14 -0
  160. package/node_modules/fast-xml-parser/src/v5/valueParsers/number.js +16 -0
  161. package/node_modules/fast-xml-parser/src/v5/valueParsers/trim.js +8 -0
  162. package/node_modules/fast-xml-parser/src/validator.js +2 -0
  163. package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +31 -9
  164. package/node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js +4 -0
  165. package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +25 -12
  166. package/package.json +9 -9
  167. package/node_modules/@smithy/signature-v4/dist-cjs/cloneRequest.js +0 -1
  168. package/node_modules/@smithy/signature-v4/dist-es/cloneRequest.js +0 -12
  169. package/node_modules/@smithy/signature-v4/dist-types/cloneRequest.d.ts +0 -6
  170. package/node_modules/@smithy/signature-v4/dist-types/ts3.4/cloneRequest.d.ts +0 -6
@@ -1,81 +1,375 @@
1
1
  type X2jOptions = {
2
- preserveOrder: boolean;
3
- attributeNamePrefix: string;
4
- attributesGroupName: false | string;
5
- textNodeName: string;
6
- ignoreAttributes: boolean;
7
- removeNSPrefix: boolean;
8
- allowBooleanAttributes: boolean;
9
- parseTagValue: boolean;
10
- parseAttributeValue: boolean;
11
- trimValues: boolean;
12
- cdataPropName: false | string;
13
- commentPropName: false | string;
14
- /**
15
- Control how tag value should be parsed. Called only if tag value is not empty
16
-
17
- @returns {undefined|null} `undefined` or `null` to set original value.
18
- @returns {unknown}
19
- 1. Different value or value with different data type to set new value. <br>
20
- 2. Same value to set parsed value if `parseTagValue: true`.
21
- */
22
- tagValueProcessor: (tagName: string, tagValue: string, jPath: string, hasAttributes: boolean, isLeafNode: boolean) => unknown;
23
- attributeValueProcessor: (attrName: string, attrValue: string, jPath: string) => unknown;
24
- numberParseOptions: strnumOptions;
25
- stopNodes: string[];
26
- unpairedTags: string[];
27
- alwaysCreateTextNode: boolean;
28
- isArray: (tagName: string, jPath: string, isLeafNode: boolean, isAttribute: boolean) => boolean;
29
- processEntities: boolean;
30
- htmlEntities: boolean;
31
- ignoreDeclaration: boolean;
32
- ignorePiTags: boolean;
33
- transformTagName: ((tagName: string) => string) | false;
34
- transformAttributeName: ((attributeName: string) => string) | false;
35
- /**
36
- Change the tag name when a different name is returned. Skip the tag from parsed result when false is returned.
37
- Modify `attrs` object to control attributes for the given tag.
38
-
39
- @returns {string} new tag name.
40
- @returns false to skip the tag
41
- */
42
- updateTag: (tagName: string, jPath: string, attrs: {[k: string]: string}) => string | boolean;
2
+ /**
3
+ * Preserve the order of tags in resulting JS object
4
+ *
5
+ * Defaults to `false`
6
+ */
7
+ preserveOrder?: boolean;
8
+
9
+ /**
10
+ * Give a prefix to the attribute name in the resulting JS object
11
+ *
12
+ * Defaults to '@_'
13
+ */
14
+ attributeNamePrefix?: string;
15
+
16
+ /**
17
+ * A name to group all attributes of a tag under, or `false` to disable
18
+ *
19
+ * Defaults to `false`
20
+ */
21
+ attributesGroupName?: false | string;
22
+
23
+ /**
24
+ * The name of the next node in the resulting JS
25
+ *
26
+ * Defaults to `#text`
27
+ */
28
+ textNodeName?: string;
29
+
30
+ /**
31
+ * Whether to ignore attributes when parsing
32
+ *
33
+ * Defaults to `true`
34
+ */
35
+ ignoreAttributes?: boolean;
36
+
37
+ /**
38
+ * Whether to remove namespace string from tag and attribute names
39
+ *
40
+ * Defaults to `false`
41
+ */
42
+ removeNSPrefix?: boolean;
43
+
44
+ /**
45
+ * Whether to allow attributes without value
46
+ *
47
+ * Defaults to `false`
48
+ */
49
+ allowBooleanAttributes?: boolean;
50
+
51
+ /**
52
+ * Whether to parse tag value with `strnum` package
53
+ *
54
+ * Defaults to `true`
55
+ */
56
+ parseTagValue?: boolean;
57
+
58
+ /**
59
+ * Whether to parse tag value with `strnum` package
60
+ *
61
+ * Defaults to `false`
62
+ */
63
+ parseAttributeValue?: boolean;
64
+
65
+ /**
66
+ * Whether to remove surrounding whitespace from tag or attribute value
67
+ *
68
+ * Defaults to `true`
69
+ */
70
+ trimValues?: boolean;
71
+
72
+ /**
73
+ * Give a property name to set CDATA values to instead of merging to tag's text value
74
+ *
75
+ * Defaults to `false`
76
+ */
77
+ cdataPropName?: false | string;
78
+
79
+ /**
80
+ * If set, parse comments and set as this property
81
+ *
82
+ * Defaults to `false`
83
+ */
84
+ commentPropName?: false | string;
85
+
86
+ /**
87
+ * Control how tag value should be parsed. Called only if tag value is not empty
88
+ *
89
+ * @returns {undefined|null} `undefined` or `null` to set original value.
90
+ * @returns {unknown}
91
+ *
92
+ * 1. Different value or value with different data type to set new value.
93
+ * 2. Same value to set parsed value if `parseTagValue: true`.
94
+ *
95
+ * Defaults to `(tagName, val, jPath, hasAttributes, isLeafNode) => val`
96
+ */
97
+ tagValueProcessor?: (tagName: string, tagValue: string, jPath: string, hasAttributes: boolean, isLeafNode: boolean) => unknown;
98
+
99
+ /**
100
+ * Control how attribute value should be parsed
101
+ *
102
+ * @param attrName
103
+ * @param attrValue
104
+ * @param jPath
105
+ * @returns {undefined|null} `undefined` or `null` to set original value
106
+ * @returns {unknown}
107
+ *
108
+ * Defaults to `(attrName, val, jPath) => val`
109
+ */
110
+ attributeValueProcessor?: (attrName: string, attrValue: string, jPath: string) => unknown;
111
+
112
+ /**
113
+ * Options to pass to `strnum` for parsing numbers
114
+ *
115
+ * Defaults to `{ hex: true, leadingZeros: true, eNotation: true }`
116
+ */
117
+ numberParseOptions?: strnumOptions;
118
+
119
+ /**
120
+ * Nodes to stop parsing at
121
+ *
122
+ * Defaults to `[]`
123
+ */
124
+ stopNodes?: string[];
125
+
126
+ /**
127
+ * List of tags without closing tags
128
+ *
129
+ * Defaults to `[]`
130
+ */
131
+ unpairedTags?: string[];
132
+
133
+ /**
134
+ * Whether to always create a text node
135
+ *
136
+ * Defaults to `false`
137
+ */
138
+ alwaysCreateTextNode?: boolean;
139
+
140
+ /**
141
+ * Determine whether a tag should be parsed as an array
142
+ *
143
+ * @param tagName
144
+ * @param jPath
145
+ * @param isLeafNode
146
+ * @param isAttribute
147
+ * @returns {boolean}
148
+ *
149
+ * Defaults to `() => false`
150
+ */
151
+ isArray?: (tagName: string, jPath: string, isLeafNode: boolean, isAttribute: boolean) => boolean;
152
+
153
+ /**
154
+ * Whether to process default and DOCTYPE entities
155
+ *
156
+ * Defaults to `true`
157
+ */
158
+ processEntities?: boolean;
159
+
160
+ /**
161
+ * Whether to process HTML entities
162
+ *
163
+ * Defaults to `false`
164
+ */
165
+ htmlEntities?: boolean;
166
+
167
+ /**
168
+ * Whether to ignore the declaration tag from output
169
+ *
170
+ * Defaults to `false`
171
+ */
172
+ ignoreDeclaration?: boolean;
173
+
174
+ /**
175
+ * Whether to ignore Pi tags
176
+ *
177
+ * Defaults to `false`
178
+ */
179
+ ignorePiTags?: boolean;
180
+
181
+ /**
182
+ * Transform tag names
183
+ *
184
+ * Defaults to `false`
185
+ */
186
+ transformTagName?: ((tagName: string) => string) | false;
187
+
188
+ /**
189
+ * Transform attribute names
190
+ *
191
+ * Defaults to `false`
192
+ */
193
+ transformAttributeName?: ((attributeName: string) => string) | false;
194
+
195
+ /**
196
+ * Change the tag name when a different name is returned. Skip the tag from parsed result when false is returned.
197
+ * Modify `attrs` object to control attributes for the given tag.
198
+ *
199
+ * @returns {string} new tag name.
200
+ * @returns false to skip the tag
201
+ *
202
+ * Defaults to `(tagName, jPath, attrs) => tagName`
203
+ */
204
+ updateTag?: (tagName: string, jPath: string, attrs: {[k: string]: string}) => string | boolean;
43
205
  };
206
+
44
207
  type strnumOptions = {
45
208
  hex: boolean;
46
209
  leadingZeros: boolean,
47
210
  skipLike?: RegExp,
48
211
  eNotation?: boolean
49
212
  }
50
- type X2jOptionsOptional = Partial<X2jOptions>;
213
+
51
214
  type validationOptions = {
52
- allowBooleanAttributes: boolean;
53
- unpairedTags: string[];
215
+ /**
216
+ * Whether to allow attributes without value
217
+ *
218
+ * Defaults to `false`
219
+ */
220
+ allowBooleanAttributes?: boolean;
221
+
222
+ /**
223
+ * List of tags without closing tags
224
+ *
225
+ * Defaults to `[]`
226
+ */
227
+ unpairedTags?: string[];
54
228
  };
55
- type validationOptionsOptional = Partial<validationOptions>;
56
229
 
57
230
  type XmlBuilderOptions = {
58
- attributeNamePrefix: string;
59
- attributesGroupName: false | string;
60
- textNodeName: string;
61
- ignoreAttributes: boolean;
62
- cdataPropName: false | string;
63
- commentPropName: false | string;
64
- format: boolean;
65
- indentBy: string;
66
- arrayNodeName: string;
67
- suppressEmptyNode: boolean;
68
- suppressUnpairedNode: boolean;
69
- suppressBooleanAttributes: boolean;
70
- preserveOrder: boolean;
71
- unpairedTags: string[];
72
- stopNodes: string[];
73
- tagValueProcessor: (name: string, value: unknown) => string;
74
- attributeValueProcessor: (name: string, value: unknown) => string;
75
- processEntities: boolean;
76
- oneListGroup: boolean;
231
+ /**
232
+ * Give a prefix to the attribute name in the resulting JS object
233
+ *
234
+ * Defaults to '@_'
235
+ */
236
+ attributeNamePrefix?: string;
237
+
238
+ /**
239
+ * A name to group all attributes of a tag under, or `false` to disable
240
+ *
241
+ * Defaults to `false`
242
+ */
243
+ attributesGroupName?: false | string;
244
+
245
+ /**
246
+ * The name of the next node in the resulting JS
247
+ *
248
+ * Defaults to `#text`
249
+ */
250
+ textNodeName?: string;
251
+
252
+ /**
253
+ * Whether to ignore attributes when parsing
254
+ *
255
+ * Defaults to `true`
256
+ */
257
+ ignoreAttributes?: boolean;
258
+
259
+ /**
260
+ * Give a property name to set CDATA values to instead of merging to tag's text value
261
+ *
262
+ * Defaults to `false`
263
+ */
264
+ cdataPropName?: false | string;
265
+
266
+ /**
267
+ * If set, parse comments and set as this property
268
+ *
269
+ * Defaults to `false`
270
+ */
271
+ commentPropName?: false | string;
272
+
273
+ /**
274
+ * Whether to make output pretty instead of single line
275
+ *
276
+ * Defaults to `false`
277
+ */
278
+ format?: boolean;
279
+
280
+
281
+ /**
282
+ * If `format` is set to `true`, sets the indent string
283
+ *
284
+ * Defaults to ` `
285
+ */
286
+ indentBy?: string;
287
+
288
+ /**
289
+ * Give a name to a top-level array
290
+ *
291
+ * Defaults to `undefined`
292
+ */
293
+ arrayNodeName?: string;
294
+
295
+ /**
296
+ * Create empty tags for tags with no text value
297
+ *
298
+ * Defaults to `false`
299
+ */
300
+ suppressEmptyNode?: boolean;
301
+
302
+ /**
303
+ * Suppress an unpaired tag
304
+ *
305
+ * Defaults to `true`
306
+ */
307
+ suppressUnpairedNode?: boolean;
308
+
309
+ /**
310
+ * Don't put a value for boolean attributes
311
+ *
312
+ * Defaults to `true`
313
+ */
314
+ suppressBooleanAttributes?: boolean;
315
+
316
+ /**
317
+ * Preserve the order of tags in resulting JS object
318
+ *
319
+ * Defaults to `false`
320
+ */
321
+ preserveOrder?: boolean;
322
+
323
+ /**
324
+ * List of tags without closing tags
325
+ *
326
+ * Defaults to `[]`
327
+ */
328
+ unpairedTags?: string[];
329
+
330
+ /**
331
+ * Nodes to stop parsing at
332
+ *
333
+ * Defaults to `[]`
334
+ */
335
+ stopNodes?: string[];
336
+
337
+ /**
338
+ * Control how tag value should be parsed. Called only if tag value is not empty
339
+ *
340
+ * @returns {undefined|null} `undefined` or `null` to set original value.
341
+ * @returns {unknown}
342
+ *
343
+ * 1. Different value or value with different data type to set new value.
344
+ * 2. Same value to set parsed value if `parseTagValue: true`.
345
+ *
346
+ * Defaults to `(tagName, val, jPath, hasAttributes, isLeafNode) => val`
347
+ */
348
+ tagValueProcessor?: (name: string, value: unknown) => unknown;
349
+
350
+ /**
351
+ * Control how attribute value should be parsed
352
+ *
353
+ * @param attrName
354
+ * @param attrValue
355
+ * @param jPath
356
+ * @returns {undefined|null} `undefined` or `null` to set original value
357
+ * @returns {unknown}
358
+ *
359
+ * Defaults to `(attrName, val, jPath) => val`
360
+ */
361
+ attributeValueProcessor?: (name: string, value: unknown) => unknown;
362
+
363
+ /**
364
+ * Whether to process default and DOCTYPE entities
365
+ *
366
+ * Defaults to `true`
367
+ */
368
+ processEntities?: boolean;
369
+
370
+
371
+ oneListGroup?: boolean;
77
372
  };
78
- type XmlBuilderOptionsOptional = Partial<XmlBuilderOptions>;
79
373
 
80
374
  type ESchema = string | object | Array<string|object>;
81
375
 
@@ -89,20 +383,20 @@ type ValidationError = {
89
383
  };
90
384
 
91
385
  export class XMLParser {
92
- constructor(options?: X2jOptionsOptional);
93
- parse(xmlData: string | Buffer ,validationOptions?: validationOptionsOptional | boolean): any;
386
+ constructor(options?: X2jOptions);
387
+ parse(xmlData: string | Buffer ,validationOptions?: validationOptions | boolean): any;
94
388
  /**
95
389
  * Add Entity which is not by default supported by this library
96
- * @param entityIndentifier {string} Eg: 'ent' for &ent;
390
+ * @param entityIdentifier {string} Eg: 'ent' for &ent;
97
391
  * @param entityValue {string} Eg: '\r'
98
392
  */
99
- addEntity(entityIndentifier: string, entityValue: string): void;
393
+ addEntity(entityIdentifier: string, entityValue: string): void;
100
394
  }
101
395
 
102
396
  export class XMLValidator{
103
- static validate( xmlData: string, options?: validationOptionsOptional): true | ValidationError;
397
+ static validate( xmlData: string, options?: validationOptions): true | ValidationError;
104
398
  }
105
399
  export class XMLBuilder {
106
- constructor(options?: XmlBuilderOptionsOptional);
400
+ constructor(options?: XmlBuilderOptions);
107
401
  build(jObj: any): any;
108
402
  }
@@ -0,0 +1,16 @@
1
+ modules.export = {
2
+ "<" : "<", //tag start
3
+ ">" : ">", //tag end
4
+ "/" : "/", //close tag
5
+ "!" : "!", //comment or docttype
6
+ "!--" : "!--", //comment
7
+ "-->" : "-->", //comment end
8
+ "?" : "?", //pi
9
+ "?>" : "?>", //pi end
10
+ "?xml" : "?xml", //pi end
11
+ "![" : "![", //cdata
12
+ "]]>" : "]]>", //cdata end
13
+ "[" : "[",
14
+ "-" : "-",
15
+ "D" : "D",
16
+ }
@@ -0,0 +1,107 @@
1
+ const ampEntity = { regex: /&(amp|#38|#x26);/g, val : "&"};
2
+ const htmlEntities = {
3
+ "space": { regex: /&(nbsp|#160);/g, val: " " },
4
+ // "lt" : { regex: /&(lt|#60);/g, val: "<" },
5
+ // "gt" : { regex: /&(gt|#62);/g, val: ">" },
6
+ // "amp" : { regex: /&(amp|#38);/g, val: "&" },
7
+ // "quot" : { regex: /&(quot|#34);/g, val: "\"" },
8
+ // "apos" : { regex: /&(apos|#39);/g, val: "'" },
9
+ "cent" : { regex: /&(cent|#162);/g, val: "¢" },
10
+ "pound" : { regex: /&(pound|#163);/g, val: "£" },
11
+ "yen" : { regex: /&(yen|#165);/g, val: "¥" },
12
+ "euro" : { regex: /&(euro|#8364);/g, val: "€" },
13
+ "copyright" : { regex: /&(copy|#169);/g, val: "©" },
14
+ "reg" : { regex: /&(reg|#174);/g, val: "®" },
15
+ "inr" : { regex: /&(inr|#8377);/g, val: "₹" },
16
+ "num_dec": { regex: /&#([0-9]{1,7});/g, val : (_, str) => String.fromCharCode(Number.parseInt(str, 10)) },
17
+ "num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val : (_, str) => String.fromCharCode(Number.parseInt(str, 16)) },
18
+ };
19
+
20
+ class EntitiesParser{
21
+ constructor(replaceHtmlEntities) {
22
+ this.replaceHtmlEntities = replaceHtmlEntities;
23
+ this.docTypeEntities = {};
24
+ this.lastEntities = {
25
+ "apos" : { regex: /&(apos|#39|#x27);/g, val : "'"},
26
+ "gt" : { regex: /&(gt|#62|#x3E);/g, val : ">"},
27
+ "lt" : { regex: /&(lt|#60|#x3C);/g, val : "<"},
28
+ "quot" : { regex: /&(quot|#34|#x22);/g, val : "\""},
29
+ };
30
+ }
31
+
32
+ addExternalEntities(externalEntities){
33
+ const entKeys = Object.keys(externalEntities);
34
+ for (let i = 0; i < entKeys.length; i++) {
35
+ const ent = entKeys[i];
36
+ this.addExternalEntity(ent,externalEntities[ent])
37
+ }
38
+ }
39
+ addExternalEntity(key,val){
40
+ validateEntityName(key);
41
+ if(val.indexOf("&") !== -1) {
42
+ reportWarning(`Entity ${key} is not added as '&' is found in value;`)
43
+ return;
44
+ }else{
45
+ this.lastEntities[ent] = {
46
+ regex: new RegExp("&"+key+";","g"),
47
+ val : val
48
+ }
49
+ }
50
+ }
51
+
52
+ addDocTypeEntities(entities){
53
+ const entKeys = Object.keys(entities);
54
+ for (let i = 0; i < entKeys.length; i++) {
55
+ const ent = entKeys[i];
56
+ this.docTypeEntities[ent] = {
57
+ regex: new RegExp("&"+ent+";","g"),
58
+ val : entities[ent]
59
+ }
60
+ }
61
+ }
62
+
63
+ parse(val){
64
+ return this.replaceEntitiesValue(val)
65
+ }
66
+
67
+ /**
68
+ * 1. Replace DOCTYPE entities
69
+ * 2. Replace external entities
70
+ * 3. Replace HTML entities if asked
71
+ * @param {string} val
72
+ */
73
+ replaceEntitiesValue(val){
74
+ if(typeof val === "string" && val.length > 0){
75
+ for(let entityName in this.docTypeEntities){
76
+ const entity = this.docTypeEntities[entityName];
77
+ val = val.replace( entity.regx, entity.val);
78
+ }
79
+ for(let entityName in this.lastEntities){
80
+ const entity = this.lastEntities[entityName];
81
+ val = val.replace( entity.regex, entity.val);
82
+ }
83
+ if(this.replaceHtmlEntities){
84
+ for(let entityName in htmlEntities){
85
+ const entity = htmlEntities[entityName];
86
+ val = val.replace( entity.regex, entity.val);
87
+ }
88
+ }
89
+ val = val.replace( ampEntity.regex, ampEntity.val);
90
+ }
91
+ return val;
92
+ }
93
+ };
94
+
95
+ //an entity name should not contains special characters that may be used in regex
96
+ //Eg !?\\\/[]$%{}^&*()<>
97
+ const specialChar = "!?\\\/[]$%{}^&*()<>|+";
98
+
99
+ function validateEntityName(name){
100
+ for (let i = 0; i < specialChar.length; i++) {
101
+ const ch = specialChar[i];
102
+ if(name.indexOf(ch) !== -1) throw new Error(`Invalid character ${ch} in entity name`);
103
+ }
104
+ return name;
105
+ }
106
+
107
+ module.exports = EntitiesParser;
@@ -0,0 +1,64 @@
1
+
2
+ const JsObjOutputBuilder = require("./OutputBuilders/JsObjBuilder");
3
+
4
+ const defaultOptions = {
5
+ preserveOrder: false,
6
+ removeNSPrefix: false, // remove NS from tag name or attribute name if true
7
+ //ignoreRootElement : false,
8
+ stopNodes: [], //nested tags will not be parsed even for errors
9
+ // isArray: () => false, //User will set it
10
+ htmlEntities: false,
11
+ // skipEmptyListItem: false
12
+ tags:{
13
+ unpaired: [],
14
+ nameFor:{
15
+ cdata: false,
16
+ comment: false,
17
+ text: '#text'
18
+ },
19
+ separateTextProperty: false,
20
+ },
21
+ attributes:{
22
+ ignore: false,
23
+ booleanType: true,
24
+ entities: true,
25
+ },
26
+
27
+ // select: ["img[src]"],
28
+ // stop: ["anim", "[ads]"]
29
+ only: [], // rest tags will be skipped. It will result in flat array
30
+ hierarchy: false, //will be used when a particular tag is set to be parsed.
31
+ skip: [], // will be skipped from parse result. on('skip') will be triggered
32
+
33
+ select: [], // on('select', tag => tag ) will be called if match
34
+ stop: [], //given tagPath will not be parsed. innerXML will be set as string value
35
+ OutputBuilder: new JsObjOutputBuilder(),
36
+ };
37
+
38
+ const buildOptions = function(options) {
39
+ const finalOptions = { ... defaultOptions};
40
+ copyProperties(finalOptions,options)
41
+ return finalOptions;
42
+ };
43
+
44
+ function copyProperties(target, source) {
45
+ for (let key in source) {
46
+ if (source.hasOwnProperty(key)) {
47
+ if (key === 'OutputBuilder') {
48
+ target[key] = source[key];
49
+ }else if (typeof source[key] === 'object' && !Array.isArray(source[key])) {
50
+ // Recursively copy nested properties
51
+ if (typeof target[key] === 'undefined') {
52
+ target[key] = {};
53
+ }
54
+ copyProperties(target[key], source[key]);
55
+ } else {
56
+ // Copy non-nested properties
57
+ target[key] = source[key];
58
+ }
59
+ }
60
+ }
61
+ }
62
+
63
+ exports.buildOptions = buildOptions;
64
+ exports.defaultOptions = defaultOptions;