@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
@@ -0,0 +1,118 @@
1
+ const Constants = {
2
+ space: 32,
3
+ tab: 9
4
+ }
5
+ class BufferSource{
6
+ constructor(bytesArr){
7
+ this.line = 1;
8
+ this.cols = 0;
9
+ this.buffer = bytesArr;
10
+ this.startIndex = 0;
11
+ }
12
+
13
+
14
+
15
+ readCh() {
16
+ return String.fromCharCode(this.buffer[this.startIndex++]);
17
+ }
18
+
19
+ readChAt(index) {
20
+ return String.fromCharCode(this.buffer[this.startIndex+index]);
21
+ }
22
+
23
+ readStr(n,from){
24
+ if(typeof from === "undefined") from = this.startIndex;
25
+ return this.buffer.slice(from, from + n).toString();
26
+ }
27
+
28
+ readUpto(stopStr) {
29
+ const inputLength = this.buffer.length;
30
+ const stopLength = stopStr.length;
31
+ const stopBuffer = Buffer.from(stopStr);
32
+
33
+ for (let i = this.startIndex; i < inputLength; i++) {
34
+ let match = true;
35
+ for (let j = 0; j < stopLength; j++) {
36
+ if (this.buffer[i + j] !== stopBuffer[j]) {
37
+ match = false;
38
+ break;
39
+ }
40
+ }
41
+
42
+ if (match) {
43
+ const result = this.buffer.slice(this.startIndex, i).toString();
44
+ this.startIndex = i + stopLength;
45
+ return result;
46
+ }
47
+ }
48
+
49
+ throw new Error(`Unexpected end of source. Reading '${stopStr}'`);
50
+ }
51
+
52
+ readUptoCloseTag(stopStr) { //stopStr: "</tagname"
53
+ const inputLength = this.buffer.length;
54
+ const stopLength = stopStr.length;
55
+ const stopBuffer = Buffer.from(stopStr);
56
+ let stopIndex = 0;
57
+ //0: non-matching, 1: matching stop string, 2: matching closing
58
+ let match = 0;
59
+
60
+ for (let i = this.startIndex; i < inputLength; i++) {
61
+ if(match === 1){//initial part matched
62
+ if(stopIndex === 0) stopIndex = i;
63
+ if(this.buffer[i] === Constants.space || this.buffer[i] === Constants.tab) continue;
64
+ else if(this.buffer[i] === '>'){ //TODO: if it should be equivalent ASCII
65
+ match = 2;
66
+ //tag boundary found
67
+ // this.startIndex
68
+ }
69
+ }else{
70
+ match = 1;
71
+ for (let j = 0; j < stopLength; j++) {
72
+ if (this.buffer[i + j] !== stopBuffer[j]) {
73
+ match = 0;
74
+ break;
75
+ }
76
+ }
77
+ }
78
+ if (match === 2) {//matched closing part
79
+ const result = this.buffer.slice(this.startIndex, stopIndex - 1 ).toString();
80
+ this.startIndex = i + 1;
81
+ return result;
82
+ }
83
+ }
84
+
85
+ throw new Error(`Unexpected end of source. Reading '${stopStr}'`);
86
+ }
87
+
88
+ readFromBuffer(n, shouldUpdate) {
89
+ let ch;
90
+ if (n === 1) {
91
+ ch = this.buffer[this.startIndex];
92
+ if (ch === 10) {
93
+ this.line++;
94
+ this.cols = 1;
95
+ } else {
96
+ this.cols++;
97
+ }
98
+ ch = String.fromCharCode(ch);
99
+ } else {
100
+ this.cols += n;
101
+ ch = this.buffer.slice(this.startIndex, this.startIndex + n).toString();
102
+ }
103
+ if (shouldUpdate) this.updateBuffer(n);
104
+ return ch;
105
+ }
106
+
107
+ updateBufferBoundary(n = 1) { //n: number of characters read
108
+ this.startIndex += n;
109
+ }
110
+
111
+ canRead(n){
112
+ n = n || this.startIndex;
113
+ return this.buffer.length - n + 1 > 0;
114
+ }
115
+
116
+ }
117
+
118
+ module.exports = BufferSource;
@@ -0,0 +1,123 @@
1
+ const whiteSpaces = [" ", "\n", "\t"];
2
+
3
+
4
+ class StringSource{
5
+ constructor(str){
6
+ this.line = 1;
7
+ this.cols = 0;
8
+ this.buffer = str;
9
+ //a boundary pointer to indicate where from the buffer dat should be read
10
+ // data before this pointer can be deleted to free the memory
11
+ this.startIndex = 0;
12
+ }
13
+
14
+ readCh() {
15
+ return this.buffer[this.startIndex++];
16
+ }
17
+
18
+ readChAt(index) {
19
+ return this.buffer[this.startIndex+index];
20
+ }
21
+
22
+ readStr(n,from){
23
+ if(typeof from === "undefined") from = this.startIndex;
24
+ return this.buffer.substring(from, from + n);
25
+ }
26
+
27
+ readUpto(stopStr) {
28
+ const inputLength = this.buffer.length;
29
+ const stopLength = stopStr.length;
30
+
31
+ for (let i = this.startIndex; i < inputLength; i++) {
32
+ let match = true;
33
+ for (let j = 0; j < stopLength; j++) {
34
+ if (this.buffer[i + j] !== stopStr[j]) {
35
+ match = false;
36
+ break;
37
+ }
38
+ }
39
+
40
+ if (match) {
41
+ const result = this.buffer.substring(this.startIndex, i);
42
+ this.startIndex = i + stopLength;
43
+ return result;
44
+ }
45
+ }
46
+
47
+ throw new Error(`Unexpected end of source. Reading '${stopStr}'`);
48
+ }
49
+
50
+ readUptoCloseTag(stopStr) { //stopStr: "</tagname"
51
+ const inputLength = this.buffer.length;
52
+ const stopLength = stopStr.length;
53
+ let stopIndex = 0;
54
+ //0: non-matching, 1: matching stop string, 2: matching closing
55
+ let match = 0;
56
+
57
+ for (let i = this.startIndex; i < inputLength; i++) {
58
+ if(match === 1){//initial part matched
59
+ if(stopIndex === 0) stopIndex = i;
60
+ if(this.buffer[i] === ' ' || this.buffer[i] === '\t') continue;
61
+ else if(this.buffer[i] === '>'){
62
+ match = 2;
63
+ //tag boundary found
64
+ // this.startIndex
65
+ }
66
+ }else{
67
+ match = 1;
68
+ for (let j = 0; j < stopLength; j++) {
69
+ if (this.buffer[i + j] !== stopStr[j]) {
70
+ match = 0;
71
+ break;
72
+ }
73
+ }
74
+ }
75
+ if (match === 2) {//matched closing part
76
+ const result = this.buffer.substring(this.startIndex, stopIndex - 1 );
77
+ this.startIndex = i + 1;
78
+ return result;
79
+ }
80
+ }
81
+
82
+ throw new Error(`Unexpected end of source. Reading '${stopStr}'`);
83
+ }
84
+
85
+ readFromBuffer(n, updateIndex){
86
+ let ch;
87
+ if(n===1){
88
+ ch = this.buffer[this.startIndex];
89
+ // if(ch === "\n") {
90
+ // this.line++;
91
+ // this.cols = 1;
92
+ // }else{
93
+ // this.cols++;
94
+ // }
95
+ }else{
96
+ ch = this.buffer.substring(this.startIndex, this.startIndex + n);
97
+ // if("".indexOf("\n") !== -1){
98
+ // //TODO: handle the scenario when there are multiple lines
99
+ // //TODO: col should be set to number of chars after last '\n'
100
+ // // this.cols = 1;
101
+ // }else{
102
+ // this.cols += n;
103
+
104
+ // }
105
+ }
106
+ if(updateIndex) this.updateBufferBoundary(n);
107
+ return ch;
108
+ }
109
+
110
+ //TODO: rename to updateBufferReadIndex
111
+
112
+ updateBufferBoundary(n = 1) { //n: number of characters read
113
+ this.startIndex += n;
114
+ }
115
+
116
+ canRead(n){
117
+ n = n || this.startIndex;
118
+ return this.buffer.length - n + 1 > 0;
119
+ }
120
+
121
+ }
122
+
123
+ module.exports = StringSource;
@@ -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,23 @@
1
+ class boolParser{
2
+ constructor(trueList, falseList){
3
+ if(trueList)
4
+ this.trueList = trueList;
5
+ else
6
+ this.trueList = ["true"];
7
+
8
+ if(falseList)
9
+ this.falseList = falseList;
10
+ else
11
+ this.falseList = ["false"];
12
+ }
13
+ parse(val){
14
+ if (typeof val === 'string') {
15
+ //TODO: performance: don't convert
16
+ const temp = val.toLowerCase();
17
+ if(this.trueList.indexOf(temp) !== -1) return true;
18
+ else if(this.falseList.indexOf(temp) !== -1 ) return false;
19
+ }
20
+ return val;
21
+ }
22
+ }
23
+ module.exports = boolParser;
@@ -0,0 +1,20 @@
1
+ function boolParserExt(val){
2
+ if(isArray(val)){
3
+ for (let i = 0; i < val.length; i++) {
4
+ val[i] = parse(val[i])
5
+ }
6
+ }else{
7
+ val = parse(val)
8
+ }
9
+ return val;
10
+ }
11
+
12
+ function parse(val){
13
+ if (typeof val === 'string') {
14
+ const temp = val.toLowerCase();
15
+ if(temp === 'true' || temp ==="yes" || temp==="1") return true;
16
+ else if(temp === 'false' || temp ==="no" || temp==="0") return false;
17
+ }
18
+ return val;
19
+ }
20
+ module.exports = boolParserExt;
@@ -0,0 +1,40 @@
1
+ const defaultOptions = {
2
+ maxLength: 200,
3
+ // locale: "en-IN"
4
+ }
5
+ const localeMap = {
6
+ "$":"en-US",
7
+ "€":"de-DE",
8
+ "£":"en-GB",
9
+ "¥":"ja-JP",
10
+ "₹":"en-IN",
11
+ }
12
+ const sign = "(?:-|\+)?";
13
+ const digitsAndSeparator = "(?:\d+|\d{1,3}(?:,\d{3})+)";
14
+ const decimalPart = "(?:\.\d{1,2})?";
15
+ const symbol = "(?:\$|€|¥|₹)?";
16
+
17
+ const currencyCheckRegex = /^\s*(?:-|\+)?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d{1,2})?\s*(?:\$|€|¥|₹)?\s*$/u;
18
+
19
+ class CurrencyParser{
20
+ constructor(options){
21
+ this.options = options || defaultOptions;
22
+ }
23
+ parse(val){
24
+ if (typeof val === 'string' && val.length <= this.options.maxLength) {
25
+ if(val.indexOf(",,") !== -1 && val.indexOf(".." !== -1)){
26
+ const match = val.match(currencyCheckRegex);
27
+ if(match){
28
+ const locale = this.options.locale || localeMap[match[2]||match[5]||"₹"];
29
+ const formatter = new Intl.NumberFormat(locale)
30
+ val = val.replace(/[^0-9,.]/g, '').trim();
31
+ val = Number(val.replace(formatter.format(1000)[1], ''));
32
+ }
33
+ }
34
+ }
35
+ return val;
36
+ }
37
+ }
38
+ CurrencyParser.defaultOptions = defaultOptions;
39
+
40
+ module.exports = CurrencyParser;
@@ -0,0 +1,14 @@
1
+ /**
2
+ *
3
+ * @param {array} val
4
+ * @param {string} by
5
+ * @returns
6
+ */
7
+ function join(val, by=" "){
8
+ if(isArray(val)){
9
+ val.join(by)
10
+ }
11
+ return val;
12
+ }
13
+
14
+ module.exports = join;
@@ -0,0 +1,16 @@
1
+ const toNumber = require("strnum");
2
+
3
+
4
+ class numParser{
5
+ constructor(options){
6
+ this.options = options;
7
+ }
8
+ parse(val){
9
+ if (typeof val === 'string') {
10
+ val = toNumber(val,this.options);
11
+ }
12
+ return val;
13
+ }
14
+ }
15
+
16
+ module.exports = numParser;
@@ -0,0 +1,8 @@
1
+ class trimmer{
2
+ parse(val){
3
+ if(typeof val === "string") return val.trim();
4
+ else return val;
5
+ }
6
+ }
7
+
8
+ module.exports = trimmer;
@@ -103,6 +103,8 @@ exports.validate = function (xmlData, options) {
103
103
  return getErrorObject('InvalidTag', "Closing tag '"+tagName+"' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
104
104
  } else if (attrStr.trim().length > 0) {
105
105
  return getErrorObject('InvalidTag', "Closing tag '"+tagName+"' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
106
+ } else if (tags.length === 0) {
107
+ return getErrorObject('InvalidTag', "Closing tag '"+tagName+"' has not been opened.", getLineNumberForPosition(xmlData, tagStartPos));
106
108
  } else {
107
109
  const otg = tags.pop();
108
110
  if (tagName !== otg.tagName) {
@@ -79,11 +79,21 @@ Builder.prototype.j2x = function(jObj, level) {
79
79
  let attrStr = '';
80
80
  let val = '';
81
81
  for (let key in jObj) {
82
+ if(!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
82
83
  if (typeof jObj[key] === 'undefined') {
83
- // supress undefined node
84
+ // supress undefined node only if it is not an attribute
85
+ if (this.isAttribute(key)) {
86
+ val += '';
87
+ }
84
88
  } else if (jObj[key] === null) {
85
- if(key[0] === "?") val += this.indentate(level) + '<' + key + '?' + this.tagEndChar;
86
- else val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
89
+ // null attribute should be ignored by the attribute list, but should not cause the tag closing
90
+ if (this.isAttribute(key)) {
91
+ val += '';
92
+ } else if (key[0] === '?') {
93
+ val += this.indentate(level) + '<' + key + '?' + this.tagEndChar;
94
+ } else {
95
+ val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
96
+ }
87
97
  // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
88
98
  } else if (jObj[key] instanceof Date) {
89
99
  val += this.buildTextValNode(jObj[key], key, '', level);
@@ -105,6 +115,7 @@ Builder.prototype.j2x = function(jObj, level) {
105
115
  //repeated nodes
106
116
  const arrLen = jObj[key].length;
107
117
  let listTagVal = "";
118
+ let listTagAttr = "";
108
119
  for (let j = 0; j < arrLen; j++) {
109
120
  const item = jObj[key][j];
110
121
  if (typeof item === 'undefined') {
@@ -114,17 +125,27 @@ Builder.prototype.j2x = function(jObj, level) {
114
125
  else val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
115
126
  // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
116
127
  } else if (typeof item === 'object') {
117
- if(this.options.oneListGroup ){
118
- listTagVal += this.j2x(item, level + 1).val;
128
+ if(this.options.oneListGroup){
129
+ const result = this.j2x(item, level + 1);
130
+ listTagVal += result.val;
131
+ if (this.options.attributesGroupName && item.hasOwnProperty(this.options.attributesGroupName)) {
132
+ listTagAttr += result.attrStr
133
+ }
119
134
  }else{
120
135
  listTagVal += this.processTextOrObjNode(item, key, level)
121
136
  }
122
137
  } else {
123
- listTagVal += this.buildTextValNode(item, key, '', level);
138
+ if (this.options.oneListGroup) {
139
+ let textValue = this.options.tagValueProcessor(key, item);
140
+ textValue = this.replaceEntitiesValue(textValue);
141
+ listTagVal += textValue;
142
+ } else {
143
+ listTagVal += this.buildTextValNode(item, key, '', level);
144
+ }
124
145
  }
125
146
  }
126
147
  if(this.options.oneListGroup){
127
- listTagVal = this.buildObjectNode(listTagVal, key, '', level);
148
+ listTagVal = this.buildObjectNode(listTagVal, key, listTagAttr, level);
128
149
  }
129
150
  val += listTagVal;
130
151
  } else {
@@ -176,7 +197,8 @@ Builder.prototype.buildObjectNode = function(val, key, attrStr, level) {
176
197
  tagEndExp = "";
177
198
  }
178
199
 
179
- if (attrStr && val.indexOf('<') === -1) {
200
+ // attrStr is an empty string in case the attribute came as undefined or null
201
+ if ((attrStr || attrStr === '') && val.indexOf('<') === -1) {
180
202
  return ( this.indentate(level) + '<' + key + attrStr + piClosingChar + '>' + val + tagEndExp );
181
203
  } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
182
204
  return this.indentate(level) + `<!--${val}-->` + this.newLine;
@@ -249,7 +271,7 @@ function indentate(level) {
249
271
  }
250
272
 
251
273
  function isAttribute(name /*, options*/) {
252
- if (name.startsWith(this.options.attributeNamePrefix)) {
274
+ if (name.startsWith(this.options.attributeNamePrefix) && name !== this.options.textNodeName) {
253
275
  return name.substr(this.attrPrefixLen);
254
276
  } else {
255
277
  return false;
@@ -21,6 +21,8 @@ function arrToStr(arr, options, jPath, indentation) {
21
21
  for (let i = 0; i < arr.length; i++) {
22
22
  const tagObj = arr[i];
23
23
  const tagName = propName(tagObj);
24
+ if(tagName === undefined) continue;
25
+
24
26
  let newJPath = "";
25
27
  if (jPath.length === 0) newJPath = tagName
26
28
  else newJPath = `${jPath}.${tagName}`;
@@ -90,6 +92,7 @@ function propName(obj) {
90
92
  const keys = Object.keys(obj);
91
93
  for (let i = 0; i < keys.length; i++) {
92
94
  const key = keys[i];
95
+ if(!obj.hasOwnProperty(key)) continue;
93
96
  if (key !== ":@") return key;
94
97
  }
95
98
  }
@@ -98,6 +101,7 @@ function attr_to_str(attrMap, options) {
98
101
  let attrStr = "";
99
102
  if (attrMap && !options.ignoreAttributes) {
100
103
  for (let attr in attrMap) {
104
+ if(!attrMap.hasOwnProperty(attr)) continue;
101
105
  let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
102
106
  attrVal = replaceEntitiesValue(attrVal, options);
103
107
  if (attrVal === true && options.suppressBooleanAttributes) {