@btc-embedded/cdk-extensions 0.23.4 → 0.23.6

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 (135) hide show
  1. package/.jsii +5 -5
  2. package/CHANGELOG.md +21 -0
  3. package/assets/cli/catnip.js +154 -166
  4. package/lib/constructs/EventPipe.js +1 -1
  5. package/lib/constructs/ExportedService.js +1 -1
  6. package/lib/constructs/S3Bucket.js +1 -1
  7. package/lib/constructs/SecureRestApi.js +1 -1
  8. package/lib/constructs/SecureRestApiV2.js +1 -1
  9. package/lib/constructs/api-keys/ApiKeyClientAuthorization.js +1 -1
  10. package/lib/constructs/api-keys/ApiKeyManagement.js +1 -1
  11. package/lib/constructs/api-keys/ApiKeyPreTokenHandler.js +1 -1
  12. package/lib/constructs/api-keys/ApiKeyStore.js +1 -1
  13. package/lib/extensions/ApiGatewayExtension.js +1 -1
  14. package/lib/extensions/ApplicationContainer.js +1 -1
  15. package/lib/extensions/ApplicationLoadBalancerExtension.js +1 -1
  16. package/lib/extensions/ApplicationLoadBalancerExtensionV2.js +1 -1
  17. package/lib/extensions/CloudMapExtension.js +1 -1
  18. package/lib/extensions/DeactivatableServiceExtension.js +1 -1
  19. package/lib/extensions/DeploymentConfigExtension.js +1 -1
  20. package/lib/extensions/DocumentDbAccessExtension.js +1 -1
  21. package/lib/extensions/DomainEventMessagingExtension.js +1 -1
  22. package/lib/extensions/EfsMountExtension.js +1 -1
  23. package/lib/extensions/ExtraContainerExtension.js +1 -1
  24. package/lib/extensions/HTTPApiExtension.js +1 -1
  25. package/lib/extensions/LogExtension.js +1 -1
  26. package/lib/extensions/ModifyContainerDefinitionExtension.js +1 -1
  27. package/lib/extensions/ModifyTaskDefinitionExtension.js +1 -1
  28. package/lib/extensions/OpenIdExtension.js +1 -1
  29. package/lib/extensions/OpenTelemetryExtension.js +1 -1
  30. package/lib/extensions/PostgresDbAccessExtension.js +1 -1
  31. package/lib/extensions/SharedVolumeExtension.js +1 -1
  32. package/lib/extensions/TcpKeepAliveExtension.js +1 -1
  33. package/lib/platform/ApiGateway.js +1 -1
  34. package/lib/platform/ApiGatewayVpcLink.js +2 -2
  35. package/lib/platform/ApplicationLoadBalancer.js +1 -1
  36. package/lib/platform/ApplicationLoadBalancerV2.d.ts +2 -0
  37. package/lib/platform/ApplicationLoadBalancerV2.js +17 -3
  38. package/lib/platform/AuroraPostgresDB.js +2 -2
  39. package/lib/platform/BTCLogGroup.js +1 -1
  40. package/lib/platform/CognitoUserPool.js +2 -2
  41. package/lib/platform/DefaultUserPoolClients.js +1 -1
  42. package/lib/platform/DocumentDB.js +2 -2
  43. package/lib/platform/EcsCluster.js +1 -1
  44. package/lib/platform/EfsFileSystem.js +1 -1
  45. package/lib/platform/HostedZone.js +1 -1
  46. package/lib/platform/PrivateDnsNamespace.js +1 -1
  47. package/lib/platform/ResourceServer.js +1 -1
  48. package/lib/platform/Vpc.js +1 -1
  49. package/lib/platform/VpcV2.js +1 -1
  50. package/lib/stacks/ApplicationStack.js +1 -1
  51. package/lib/utils/BasePlatformStackResolver.js +1 -1
  52. package/lib/utils/StackParameter.js +1 -1
  53. package/node_modules/@nodable/entities/README.md +41 -0
  54. package/node_modules/@nodable/entities/package.json +54 -0
  55. package/node_modules/@nodable/entities/src/EntityDecoder.js +543 -0
  56. package/node_modules/@nodable/entities/src/EntityEncoder.js +194 -0
  57. package/node_modules/@nodable/entities/src/entities.js +1177 -0
  58. package/node_modules/@nodable/entities/src/entityTries.js +49 -0
  59. package/node_modules/@nodable/entities/src/index.d.ts +264 -0
  60. package/node_modules/@nodable/entities/src/index.js +29 -0
  61. package/node_modules/fast-xml-builder/CHANGELOG.md +40 -0
  62. package/node_modules/fast-xml-builder/LICENSE +21 -0
  63. package/node_modules/fast-xml-builder/README.md +74 -0
  64. package/node_modules/fast-xml-builder/lib/fxb.cjs +1 -0
  65. package/node_modules/fast-xml-builder/lib/fxb.d.cts +270 -0
  66. package/node_modules/fast-xml-builder/lib/fxb.min.js +2 -0
  67. package/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -0
  68. package/node_modules/fast-xml-builder/package.json +81 -0
  69. package/node_modules/fast-xml-builder/src/fxb.d.ts +270 -0
  70. package/node_modules/fast-xml-builder/src/fxb.js +599 -0
  71. package/node_modules/fast-xml-builder/src/ignoreAttributes.js +18 -0
  72. package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +359 -0
  73. package/node_modules/fast-xml-builder/src/util.js +16 -0
  74. package/node_modules/fast-xml-parser/CHANGELOG.md +165 -0
  75. package/node_modules/fast-xml-parser/README.md +21 -44
  76. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +1 -1
  77. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -1
  78. package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -1
  79. package/node_modules/fast-xml-parser/lib/fxp.d.cts +343 -31
  80. package/node_modules/fast-xml-parser/lib/fxp.min.js +1 -1
  81. package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -1
  82. package/node_modules/fast-xml-parser/lib/fxparser.min.js +1 -1
  83. package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -1
  84. package/node_modules/fast-xml-parser/lib/fxvalidator.min.js +1 -1
  85. package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -1
  86. package/node_modules/fast-xml-parser/package.json +13 -8
  87. package/node_modules/fast-xml-parser/src/fxp.d.ts +335 -30
  88. package/node_modules/fast-xml-parser/src/fxp.js +1 -1
  89. package/node_modules/fast-xml-parser/src/util.js +18 -25
  90. package/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +89 -87
  91. package/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +10 -10
  92. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +23 -23
  93. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +29 -29
  94. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +1 -1
  95. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +39 -39
  96. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +21 -21
  97. package/node_modules/fast-xml-parser/src/v6/XMLParser.js +22 -22
  98. package/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +85 -85
  99. package/node_modules/fast-xml-parser/src/validator.js +34 -34
  100. package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +5 -284
  101. package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +335 -293
  102. package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +160 -43
  103. package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +540 -308
  104. package/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +26 -26
  105. package/node_modules/fast-xml-parser/src/xmlparser/node2json.js +99 -41
  106. package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +10 -10
  107. package/node_modules/path-expression-matcher/LICENSE +21 -0
  108. package/node_modules/path-expression-matcher/README.md +872 -0
  109. package/node_modules/path-expression-matcher/lib/pem.cjs +1 -0
  110. package/node_modules/path-expression-matcher/lib/pem.d.cts +634 -0
  111. package/node_modules/path-expression-matcher/lib/pem.min.js +2 -0
  112. package/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -0
  113. package/node_modules/path-expression-matcher/package.json +78 -0
  114. package/node_modules/path-expression-matcher/src/Expression.js +232 -0
  115. package/node_modules/path-expression-matcher/src/ExpressionSet.js +209 -0
  116. package/node_modules/path-expression-matcher/src/Matcher.js +570 -0
  117. package/node_modules/path-expression-matcher/src/index.d.ts +523 -0
  118. package/node_modules/path-expression-matcher/src/index.js +29 -0
  119. package/node_modules/strnum/CHANGELOG.md +12 -2
  120. package/node_modules/strnum/README.md +1 -0
  121. package/node_modules/strnum/package.json +5 -4
  122. package/node_modules/strnum/strnum.js +99 -65
  123. package/node_modules/xml-naming/README.md +189 -0
  124. package/node_modules/xml-naming/package.json +54 -0
  125. package/node_modules/xml-naming/src/index.d.ts +74 -0
  126. package/node_modules/xml-naming/src/index.js +270 -0
  127. package/package.json +3 -2
  128. package/renovate.json5 +1 -0
  129. package/node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js +0 -134
  130. package/node_modules/strnum/.github/SECURITY.md +0 -5
  131. package/node_modules/strnum/.vscode/launch.json +0 -25
  132. package/node_modules/strnum/algo.stflow +0 -84
  133. package/node_modules/strnum/strnum.test.js +0 -173
  134. package/node_modules/strnum/test.js +0 -9
  135. /package/node_modules/{fast-xml-parser/src/xmlbuilder → fast-xml-builder/src}/prettifyJs2Xml.js +0 -0
@@ -1,104 +1,106 @@
1
- const ampEntity = { regex: /&(amp|#38|#x26);/g, val : "&"};
1
+ const ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" };
2
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.fromCodePoint(Number.parseInt(str, 10)) },
17
- "num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val : (_, str) => String.fromCodePoint(Number.parseInt(str, 16)) },
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.fromCodePoint(Number.parseInt(str, 10)) },
17
+ "num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) => String.fromCodePoint(Number.parseInt(str, 16)) },
18
18
  };
19
- export default class EntitiesParser{
20
- constructor(replaceHtmlEntities) {
21
- this.replaceHtmlEntities = replaceHtmlEntities;
22
- this.docTypeEntities = {};
23
- this.lastEntities = {
24
- "apos" : { regex: /&(apos|#39|#x27);/g, val : "'"},
25
- "gt" : { regex: /&(gt|#62|#x3E);/g, val : ">"},
26
- "lt" : { regex: /&(lt|#60|#x3C);/g, val : "<"},
27
- "quot" : { regex: /&(quot|#34|#x22);/g, val : "\""},
28
- };
29
- }
19
+ export default class EntitiesParser {
20
+ constructor(replaceHtmlEntities) {
21
+ this.replaceHtmlEntities = replaceHtmlEntities;
22
+ this.docTypeEntities = {};
23
+ this.lastEntities = {
24
+ "apos": { regex: /&(apos|#39|#x27);/g, val: "'" },
25
+ "gt": { regex: /&(gt|#62|#x3E);/g, val: ">" },
26
+ "lt": { regex: /&(lt|#60|#x3C);/g, val: "<" },
27
+ "quot": { regex: /&(quot|#34|#x22);/g, val: "\"" },
28
+ };
29
+ }
30
30
 
31
- addExternalEntities(externalEntities){
32
- const entKeys = Object.keys(externalEntities);
33
- for (let i = 0; i < entKeys.length; i++) {
34
- const ent = entKeys[i];
35
- this.addExternalEntity(ent,externalEntities[ent])
36
- }
31
+ addExternalEntities(externalEntities) {
32
+ const entKeys = Object.keys(externalEntities);
33
+ for (let i = 0; i < entKeys.length; i++) {
34
+ const ent = entKeys[i];
35
+ this.addExternalEntity(ent, externalEntities[ent])
37
36
  }
38
- addExternalEntity(key,val){
39
- validateEntityName(key);
40
- if(val.indexOf("&") !== -1) {
41
- reportWarning(`Entity ${key} is not added as '&' is found in value;`)
42
- return;
43
- }else{
44
- this.lastEntities[ent] = {
45
- regex: new RegExp("&"+key+";","g"),
46
- val : val
47
- }
37
+ }
38
+ addExternalEntity(key, val) {
39
+ validateEntityName(key);
40
+ const escaped = key.replace(/[.\-+*:]/g, '\\.');
41
+ if (val.indexOf("&") !== -1) {
42
+ reportWarning(`Entity ${key} is not added as '&' is found in value;`)
43
+ return;
44
+ } else {
45
+ this.lastEntities[key] = {
46
+ regex: new RegExp("&" + escaped + ";", "g"),
47
+ val: val
48
48
  }
49
49
  }
50
+ }
50
51
 
51
- addDocTypeEntities(entities){
52
- const entKeys = Object.keys(entities);
53
- for (let i = 0; i < entKeys.length; i++) {
54
- const ent = entKeys[i];
55
- this.docTypeEntities[ent] = {
56
- regex: new RegExp("&"+ent+";","g"),
57
- val : entities[ent]
58
- }
59
- }
52
+ addDocTypeEntities(entities) {
53
+ const entKeys = Object.keys(entities);
54
+ for (let i = 0; i < entKeys.length; i++) {
55
+ const ent = entKeys[i];
56
+ const escaped = ent.replace(/[.\-+*:]/g, '\\.');
57
+ this.docTypeEntities[ent] = {
58
+ regex: new RegExp("&" + escaped + ";", "g"),
59
+ val: entities[ent]
60
+ }
60
61
  }
62
+ }
61
63
 
62
- parse(val){
63
- return this.replaceEntitiesValue(val)
64
- }
64
+ parse(val) {
65
+ return this.replaceEntitiesValue(val)
66
+ }
65
67
 
66
- /**
67
- * 1. Replace DOCTYPE entities
68
- * 2. Replace external entities
69
- * 3. Replace HTML entities if asked
70
- * @param {string} val
71
- */
72
- replaceEntitiesValue(val){
73
- if(typeof val === "string" && val.length > 0){
74
- for(let entityName in this.docTypeEntities){
75
- const entity = this.docTypeEntities[entityName];
76
- val = val.replace( entity.regx, entity.val);
77
- }
78
- for(let entityName in this.lastEntities){
79
- const entity = this.lastEntities[entityName];
80
- val = val.replace( entity.regex, entity.val);
81
- }
82
- if(this.replaceHtmlEntities){
83
- for(let entityName in htmlEntities){
84
- const entity = htmlEntities[entityName];
85
- val = val.replace( entity.regex, entity.val);
86
- }
87
- }
88
- val = val.replace( ampEntity.regex, ampEntity.val);
68
+ /**
69
+ * 1. Replace DOCTYPE entities
70
+ * 2. Replace external entities
71
+ * 3. Replace HTML entities if asked
72
+ * @param {string} val
73
+ */
74
+ replaceEntitiesValue(val) {
75
+ if (typeof val === "string" && val.length > 0) {
76
+ for (let entityName in this.docTypeEntities) {
77
+ const entity = this.docTypeEntities[entityName];
78
+ val = val.replace(entity.regx, entity.val);
79
+ }
80
+ for (let entityName in this.lastEntities) {
81
+ const entity = this.lastEntities[entityName];
82
+ val = val.replace(entity.regex, entity.val);
83
+ }
84
+ if (this.replaceHtmlEntities) {
85
+ for (let entityName in htmlEntities) {
86
+ const entity = htmlEntities[entityName];
87
+ val = val.replace(entity.regex, entity.val);
89
88
  }
90
- return val;
89
+ }
90
+ val = val.replace(ampEntity.regex, ampEntity.val);
91
91
  }
92
- };
92
+ return val;
93
+ }
94
+ }
93
95
 
94
96
  //an entity name should not contains special characters that may be used in regex
95
97
  //Eg !?\\\/[]$%{}^&*()<>
96
- const specialChar = "!?\\\/[]$%{}^&*()<>|+";
98
+ const specialChar = "!?\\/[]$%{}^&*()<>|+";
97
99
 
98
- function validateEntityName(name){
99
- for (let i = 0; i < specialChar.length; i++) {
100
- const ch = specialChar[i];
101
- if(name.indexOf(ch) !== -1) throw new Error(`Invalid character ${ch} in entity name`);
102
- }
103
- return name;
100
+ function validateEntityName(name) {
101
+ for (let i = 0; i < specialChar.length; i++) {
102
+ const ch = specialChar[i];
103
+ if (name.indexOf(ch) !== -1) throw new Error(`Invalid character ${ch} in entity name`);
104
+ }
105
+ return name;
104
106
  }
@@ -1,5 +1,5 @@
1
1
 
2
- import {JsObjOutputBuilder} from './OutputBuilders/JsObjBuilder.js';
2
+ import { JsObjOutputBuilder } from './OutputBuilders/JsObjBuilder.js';
3
3
 
4
4
  export const defaultOptions = {
5
5
  preserveOrder: false,
@@ -9,16 +9,16 @@ export const defaultOptions = {
9
9
  // isArray: () => false, //User will set it
10
10
  htmlEntities: false,
11
11
  // skipEmptyListItem: false
12
- tags:{
12
+ tags: {
13
13
  unpaired: [],
14
- nameFor:{
14
+ nameFor: {
15
15
  cdata: false,
16
16
  comment: false,
17
17
  text: '#text'
18
18
  },
19
19
  separateTextProperty: false,
20
20
  },
21
- attributes:{
21
+ attributes: {
22
22
  ignore: false,
23
23
  booleanType: true,
24
24
  entities: true,
@@ -34,19 +34,19 @@ export const defaultOptions = {
34
34
  stop: [], //given tagPath will not be parsed. innerXML will be set as string value
35
35
  OutputBuilder: new JsObjOutputBuilder(),
36
36
  };
37
-
38
- export const buildOptions = function(options) {
39
- const finalOptions = { ... defaultOptions};
40
- copyProperties(finalOptions,options)
37
+
38
+ export const buildOptions = function (options) {
39
+ const finalOptions = { ...defaultOptions };
40
+ copyProperties(finalOptions, options)
41
41
  return finalOptions;
42
42
  };
43
43
 
44
44
  function copyProperties(target, source) {
45
45
  for (let key in source) {
46
- if (source.hasOwnProperty(key)) {
46
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
47
47
  if (key === 'OutputBuilder') {
48
48
  target[key] = source[key];
49
- }else if (typeof source[key] === 'object' && !Array.isArray(source[key])) {
49
+ } else if (typeof source[key] === 'object' && !Array.isArray(source[key])) {
50
50
  // Recursively copy nested properties
51
51
  if (typeof target[key] === 'undefined') {
52
52
  target[key] = {};
@@ -1,14 +1,14 @@
1
- export default class BaseOutputBuilder{
2
- constructor(){
1
+ export default class BaseOutputBuilder {
2
+ constructor() {
3
3
  // this.attributes = {};
4
4
  }
5
5
 
6
- addAttribute(name, value){
7
- if(this.options.onAttribute){
6
+ addAttribute(name, value) {
7
+ if (this.options.onAttribute) {
8
8
  //TODO: better to pass tag path
9
9
  const v = this.options.onAttribute(name, value, this.tagName);
10
- if(v) this.attributes[v.name] = v.value;
11
- }else{
10
+ if (v) this.attributes[v.name] = v.value;
11
+ } else {
12
12
  name = this.options.attributes.prefix + name + this.options.attributes.suffix;
13
13
  this.attributes[name] = this.parseValue(value, this.options.attributes.valueParsers);
14
14
  }
@@ -19,37 +19,37 @@ export default class BaseOutputBuilder{
19
19
  * @param {string} val
20
20
  * @returns {any} parsed value if matching parser found
21
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
- }
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);
31
30
  }
32
- return val;
33
31
  }
32
+ return val;
33
+ }
34
34
 
35
35
  /**
36
36
  * To add a nested empty tag.
37
37
  * @param {string} key
38
38
  * @param {any} val
39
39
  */
40
- _addChild(key, val){}
40
+ _addChild(key, val) { }
41
41
 
42
42
  /**
43
43
  * skip the comment if property is not set
44
44
  */
45
- addComment(text){
46
- if(this.options.nameFor.comment)
45
+ addComment(text) {
46
+ if (this.options.nameFor.comment)
47
47
  this._addChild(this.options.nameFor.comment, text);
48
48
  }
49
49
 
50
50
  //store CDATA separately if property is set
51
51
  //otherwise add to tag's value
52
- addCdata(text){
52
+ addCdata(text) {
53
53
  if (this.options.nameFor.cdata) {
54
54
  this._addChild(this.options.nameFor.cdata, text);
55
55
  } else {
@@ -59,9 +59,9 @@ export default class BaseOutputBuilder{
59
59
 
60
60
  addRawValue = text => this.addValue(text);
61
61
 
62
- addDeclaration(){
63
- if(!this.options.declaration){
64
- }else{
62
+ addDeclaration() {
63
+ if (!this.options.declaration) {
64
+ } else {
65
65
  this.addPi("?xml");
66
66
  }
67
67
  this.attributes = {}
@@ -1,16 +1,16 @@
1
- import {buildOptions,registerCommonValueParsers} from './ParserOptionsBuilder.js';
1
+ import { buildOptions, registerCommonValueParsers } from './ParserOptionsBuilder.js';
2
2
 
3
- export default class OutputBuilder{
4
- constructor(options){
3
+ export default class OutputBuilder {
4
+ constructor(options) {
5
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
- }
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
12
 
13
- getInstance(parserOptions){
13
+ getInstance(parserOptions) {
14
14
  return new JsArrBuilder(parserOptions, this.options, this.registeredParsers);
15
15
  }
16
16
  }
@@ -18,9 +18,9 @@ export default class OutputBuilder{
18
18
  const rootName = '!js_arr';
19
19
  import BaseOutputBuilder from './BaseOutputBuilder.js';
20
20
 
21
- class JsArrBuilder extends BaseOutputBuilder{
21
+ class JsArrBuilder extends BaseOutputBuilder {
22
22
 
23
- constructor(parserOptions, options,registeredParsers) {
23
+ constructor(parserOptions, options, registeredParsers) {
24
24
  super();
25
25
  this.tagsStack = [];
26
26
  this.parserOptions = parserOptions;
@@ -32,10 +32,10 @@ class JsArrBuilder extends BaseOutputBuilder{
32
32
  this.attributes = {};
33
33
  }
34
34
 
35
- addTag(tag){
35
+ addTag(tag) {
36
36
  //when a new tag is added, it should be added as child of current node
37
37
  //TODO: shift this check to the parser
38
- if(tag.name === "__proto__") tag.name = "#__proto__";
38
+ if (tag.name === "__proto__") tag.name = "#__proto__";
39
39
 
40
40
  this.tagsStack.push(this.currentNode);
41
41
  this.currentNode = new Node(tag.name, this.attributes);
@@ -47,23 +47,23 @@ class JsArrBuilder extends BaseOutputBuilder{
47
47
  * @param {Node} node
48
48
  * @returns boolean: true if the node should not be added
49
49
  */
50
- closeTag(){
50
+ closeTag() {
51
51
  const node = this.currentNode;
52
52
  this.currentNode = this.tagsStack.pop(); //set parent node in scope
53
- if(this.options.onClose !== undefined){
53
+ if (this.options.onClose !== undefined) {
54
54
  //TODO TagPathMatcher
55
- const resultTag = this.options.onClose(node,
56
- new TagPathMatcher(this.tagsStack,node));
55
+ const resultTag = this.options.onClose(node,
56
+ new TagPathMatcher(this.tagsStack, node));
57
57
 
58
- if(resultTag) return;
58
+ if (resultTag) return;
59
59
  }
60
60
  this.currentNode.child.push(node); //to parent node
61
61
  }
62
62
 
63
63
  //Called by parent class methods
64
- _addChild(key, val){
64
+ _addChild(key, val) {
65
65
  // if(key === "__proto__") tagName = "#__proto__";
66
- this.currentNode.child.push( {[key]: val });
66
+ this.currentNode.child.push({ [key]: val });
67
67
  // this.currentNode.leafType = false;
68
68
  }
69
69
 
@@ -71,31 +71,31 @@ class JsArrBuilder extends BaseOutputBuilder{
71
71
  * Add text value child node
72
72
  * @param {string} text
73
73
  */
74
- addValue(text){
75
- this.currentNode.child.push( {[this.options.nameFor.text]: this.parseValue(text, this.options.tags.valueParsers) });
74
+ addValue(text) {
75
+ this.currentNode.child.push({ [this.options.nameFor.text]: this.parseValue(text, this.options.tags.valueParsers) });
76
76
  }
77
77
 
78
- addPi(name){
78
+ addPi(name) {
79
79
  //TODO: set pi flag
80
- if(!this.options.ignorePiTags){
80
+ if (!this.options.ignorePiTags) {
81
81
  const node = new Node(name, this.attributes);
82
82
  this.currentNode[":@"] = this.attributes;
83
83
  this.currentNode.child.push(node);
84
84
  }
85
85
  this.attributes = {};
86
86
  }
87
- getOutput(){
87
+ getOutput() {
88
88
  return this.root.child[0];
89
89
  }
90
90
  }
91
91
 
92
92
 
93
93
 
94
- class Node{
95
- constructor(tagname, attributes){
94
+ class Node {
95
+ constructor(tagname, attributes) {
96
96
  this.tagname = tagname;
97
97
  this.child = []; //nested tags, text, cdata, comments
98
- if(attributes && Object.keys(attributes).length > 0)
98
+ if (attributes && Object.keys(attributes).length > 0)
99
99
  this[":@"] = attributes;
100
100
  }
101
101
  }
@@ -1,4 +1,4 @@
1
- import {buildOptions,registerCommonValueParsers} from"./ParserOptionsBuilder";
1
+ import {buildOptions,registerCommonValueParsers} from"./ParserOptionsBuilder.js";
2
2
 
3
3
  export default class OutputBuilder{
4
4
  constructor(options){
@@ -1,18 +1,18 @@
1
1
 
2
2
 
3
- import {buildOptions,registerCommonValueParsers} from './ParserOptionsBuilder.js';
3
+ import { buildOptions, registerCommonValueParsers } from './ParserOptionsBuilder.js';
4
4
 
5
- export default class OutputBuilder{
6
- constructor(builderOptions){
7
- this.options = buildOptions(builderOptions);
8
- this.registeredParsers = registerCommonValueParsers(this.options);
5
+ export default class OutputBuilder {
6
+ constructor(builderOptions) {
7
+ this.options = buildOptions(builderOptions);
8
+ this.registeredParsers = registerCommonValueParsers(this.options);
9
9
  }
10
10
 
11
- registerValueParser(name,parserInstance){//existing name will override the parser without warning
11
+ registerValueParser(name, parserInstance) {//existing name will override the parser without warning
12
12
  this.registeredParsers[name] = parserInstance;
13
13
  }
14
14
 
15
- getInstance(parserOptions){
15
+ getInstance(parserOptions) {
16
16
  return new JsObjBuilder(parserOptions, this.options, this.registeredParsers);
17
17
  }
18
18
  }
@@ -20,9 +20,9 @@ export default class OutputBuilder{
20
20
  import BaseOutputBuilder from './BaseOutputBuilder.js';
21
21
  const rootName = '^';
22
22
 
23
- class JsObjBuilder extends BaseOutputBuilder{
23
+ class JsObjBuilder extends BaseOutputBuilder {
24
24
 
25
- constructor(parserOptions, builderOptions,registeredParsers) {
25
+ constructor(parserOptions, builderOptions, registeredParsers) {
26
26
  super();
27
27
  //hold the raw detail of a tag and sequence with reference to the output
28
28
  this.tagsStack = [];
@@ -38,14 +38,14 @@ class JsObjBuilder extends BaseOutputBuilder{
38
38
  this.attributes = {};
39
39
  }
40
40
 
41
- addTag(tag){
41
+ addTag(tag) {
42
42
 
43
43
  let value = "";
44
- if( !isEmpty(this.attributes)){
44
+ if (!isEmpty(this.attributes)) {
45
45
  value = {};
46
- if(this.options.attributes.groupBy){
46
+ if (this.options.attributes.groupBy) {
47
47
  value[this.options.attributes.groupBy] = this.attributes;
48
- }else{
48
+ } else {
49
49
  value = this.attributes;
50
50
  }
51
51
  }
@@ -62,44 +62,44 @@ class JsObjBuilder extends BaseOutputBuilder{
62
62
  * @param {Node} node
63
63
  * @returns boolean: true if the node should not be added
64
64
  */
65
- closeTag(){
65
+ closeTag() {
66
66
  const tagName = this.tagName;
67
67
  let value = this.value;
68
68
  let textValue = this.textValue;
69
69
 
70
70
  //update tag text value
71
- if(typeof value !== "object" && !Array.isArray(value)){
71
+ if (typeof value !== "object" && !Array.isArray(value)) {
72
72
  value = this.parseValue(textValue.trim(), this.options.tags.valueParsers);
73
- }else if(textValue.length > 0){
73
+ } else if (textValue.length > 0) {
74
74
  value[this.options.nameFor.text] = this.parseValue(textValue.trim(), this.options.tags.valueParsers);
75
75
  }
76
76
 
77
-
78
- let resultTag= {
77
+
78
+ let resultTag = {
79
79
  tagName: tagName,
80
80
  value: value
81
81
  };
82
82
 
83
- if(this.options.onTagClose !== undefined){
83
+ if (this.options.onTagClose !== undefined) {
84
84
  //TODO TagPathMatcher
85
- resultTag = this.options.onClose(tagName, value, this.textValue, new TagPathMatcher(this.tagsStack,node));
85
+ resultTag = this.options.onClose(tagName, value, this.textValue, new TagPathMatcher(this.tagsStack, node));
86
86
 
87
- if(!resultTag) return;
87
+ if (!resultTag) return;
88
88
  }
89
89
 
90
90
  //set parent node in scope
91
- let arr = this.tagsStack.pop();
91
+ let arr = this.tagsStack.pop();
92
92
  let parentTag = arr[2];
93
- parentTag=this._addChildTo(resultTag.tagName, resultTag.value, parentTag);
93
+ parentTag = this._addChildTo(resultTag.tagName, resultTag.value, parentTag);
94
94
 
95
95
  this.tagName = arr[0];
96
96
  this.textValue = arr[1];
97
97
  this.value = parentTag;
98
98
  }
99
99
 
100
- _addChild(key, val){
101
- if(typeof this.value === "string"){
102
- this.value = { [this.options.nameFor.text] : this.value };
100
+ _addChild(key, val) {
101
+ if (typeof this.value === "string") {
102
+ this.value = { [this.options.nameFor.text]: this.value };
103
103
  }
104
104
 
105
105
  this._addChildTo(key, val, this.value);
@@ -107,12 +107,12 @@ class JsObjBuilder extends BaseOutputBuilder{
107
107
  this.attributes = {};
108
108
  }
109
109
 
110
- _addChildTo(key, val, node){
111
- if(typeof node === 'string') node = {};
112
- if(!node[key]){
110
+ _addChildTo(key, val, node) {
111
+ if (typeof node === 'string') node = {};
112
+ if (!node[key]) {
113
113
  node[key] = val;
114
- }else{ //Repeated
115
- if(!Array.isArray(node[key])){ //but not stored as array
114
+ } else { //Repeated
115
+ if (!Array.isArray(node[key])) { //but not stored as array
116
116
  node[key] = [node[key]];
117
117
  }
118
118
  node[key].push(val);
@@ -125,26 +125,26 @@ class JsObjBuilder extends BaseOutputBuilder{
125
125
  * Add text value child node
126
126
  * @param {string} text
127
127
  */
128
- addValue(text){
128
+ addValue(text) {
129
129
  //TODO: use bytes join
130
- if(this.textValue.length > 0) this.textValue += " " + text;
130
+ if (this.textValue.length > 0) this.textValue += " " + text;
131
131
  else this.textValue = text;
132
132
  }
133
133
 
134
- addPi(name){
134
+ addPi(name) {
135
135
  let value = "";
136
- if( !isEmpty(this.attributes)){
136
+ if (!isEmpty(this.attributes)) {
137
137
  value = {};
138
- if(this.options.attributes.groupBy){
138
+ if (this.options.attributes.groupBy) {
139
139
  value[this.options.attributes.groupBy] = this.attributes;
140
- }else{
140
+ } else {
141
141
  value = this.attributes;
142
142
  }
143
143
  }
144
144
  this._addChild(name, value);
145
-
145
+
146
146
  }
147
- getOutput(){
147
+ getOutput() {
148
148
  return this.value;
149
149
  }
150
150
  }