@azure/core-xml 1.5.1-alpha.20260305.6 → 1.5.1

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.
@@ -32,3 +32,4 @@ var import_xml_common = require("./xml.common.js");
32
32
  parseXML,
33
33
  stringifyXML
34
34
  });
35
+ //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-xml/src/index.ts"],
3
+ "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport { stringifyXML, parseXML } from \"./xml.js\";\nexport { XML_ATTRKEY, XML_CHARKEY, type XmlOptions } from \"./xml.common.js\";\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAuC;AACvC,wBAA0D;",
6
6
  "names": []
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.57.6"
8
+ "packageVersion": "7.58.1"
9
9
  }
10
10
  ]
11
11
  }
@@ -28,3 +28,4 @@ const XML_CHARKEY = "_";
28
28
  XML_ATTRKEY,
29
29
  XML_CHARKEY
30
30
  });
31
+ //# sourceMappingURL=xml.common.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-xml/src/xml.common.ts"],
3
+ "sources": ["../../src/xml.common.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Default key used to access the XML attributes.\n */\nexport const XML_ATTRKEY = \"$\";\n/**\n * Default key used to access the XML value content.\n */\nexport const XML_CHARKEY = \"_\";\n\n/**\n * Options to govern behavior of xml parser and builder.\n */\nexport interface XmlOptions {\n /**\n * indicates the name of the root element in the resulting XML when building XML.\n */\n rootName?: string;\n /**\n * indicates whether the root element is to be included or not in the output when parsing XML.\n */\n includeRoot?: boolean;\n /**\n * key used to access the XML value content when parsing XML.\n */\n xmlCharKey?: string;\n\n /**\n * property name for a CDATA section.\n */\n cdataPropName?: string;\n\n /**\n * XML nodes to exclude from parsing.\n */\n stopNodes?: string[];\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,MAAM,cAAc;AAIpB,MAAM,cAAc;",
6
6
  "names": []
@@ -86,3 +86,4 @@ async function parseXML(str, opts = {}) {
86
86
  parseXML,
87
87
  stringifyXML
88
88
  });
89
+ //# sourceMappingURL=xml.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-xml/src/xml.ts"],
3
+ "sources": ["../../src/xml.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { XMLBuilder, XMLParser, XMLValidator } from \"fast-xml-parser\";\nimport { XML_ATTRKEY, XML_CHARKEY, type XmlOptions } from \"./xml.common.js\";\n\nfunction getCommonOptions(options: XmlOptions): {\n attributesGroupName: string;\n textNodeName: string;\n ignoreAttributes: boolean;\n suppressBooleanAttributes: boolean;\n} {\n return {\n attributesGroupName: XML_ATTRKEY,\n textNodeName: options.xmlCharKey ?? XML_CHARKEY,\n ignoreAttributes: false,\n suppressBooleanAttributes: false,\n };\n}\n\nfunction getSerializerOptions(options: XmlOptions = {}): {\n attributesGroupName: string;\n textNodeName: string;\n ignoreAttributes: boolean;\n suppressBooleanAttributes: boolean;\n attributeNamePrefix: string;\n format: boolean;\n suppressEmptyNode: boolean;\n indentBy: string;\n rootNodeName: string;\n cdataPropName: string;\n} {\n return {\n ...getCommonOptions(options),\n attributeNamePrefix: \"@_\",\n format: true,\n suppressEmptyNode: true,\n indentBy: \"\",\n rootNodeName: options.rootName ?? \"root\",\n cdataPropName: options.cdataPropName ?? \"__cdata\",\n };\n}\n\nfunction getParserOptions(options: XmlOptions = {}): {\n attributesGroupName: string;\n textNodeName: string;\n ignoreAttributes: boolean;\n suppressBooleanAttributes: boolean;\n parseAttributeValue: boolean;\n parseTagValue: boolean;\n attributeNamePrefix: string;\n stopNodes?: string[];\n processEntities: boolean;\n trimValues: boolean;\n} {\n return {\n ...getCommonOptions(options),\n parseAttributeValue: false,\n parseTagValue: false,\n attributeNamePrefix: \"\",\n stopNodes: options.stopNodes,\n processEntities: true,\n trimValues: false,\n };\n}\n/**\n * Converts given JSON object to XML string\n * @param obj - JSON object to be converted into XML string\n * @param opts - Options that govern the XML building of given JSON object\n * `rootName` indicates the name of the root element in the resulting XML\n */\nexport function stringifyXML(obj: unknown, opts: XmlOptions = {}): string {\n const parserOptions = getSerializerOptions(opts);\n const j2x = new XMLBuilder(parserOptions);\n\n const node = { [parserOptions.rootNodeName]: obj };\n\n const xmlData: string = j2x.build(node);\n return `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>${xmlData}`.replace(/\\n/g, \"\");\n}\n\n/**\n * Converts given XML string into JSON\n * @param str - String containing the XML content to be parsed into JSON\n * @param opts - Options that govern the parsing of given xml string\n * `includeRoot` indicates whether the root element is to be included or not in the output\n */\nexport async function parseXML(str: string, opts: XmlOptions = {}): Promise<any> {\n if (!str) {\n throw new Error(\"Document is empty\");\n }\n\n const validation = XMLValidator.validate(str);\n\n if (validation !== true) {\n throw validation;\n }\n\n const parser = new XMLParser(getParserOptions(opts));\n const parsedXml = parser.parse(str);\n\n // Remove the <?xml version=\"...\" ?> node.\n // This is a change in behavior on fxp v4. Issue #424\n if (parsedXml[\"?xml\"]) {\n delete parsedXml[\"?xml\"];\n }\n\n if (!opts.includeRoot) {\n for (const key of Object.keys(parsedXml)) {\n const value = parsedXml[key];\n return typeof value === \"object\" ? { ...value } : value;\n }\n }\n\n return parsedXml;\n}\n"],
5
5
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,QAAM,YAAY,OAAO,MAAM,GAAG;AAIlC,MAAI,UAAU,MAAM,GAAG;AACrB,WAAO,UAAU,MAAM;AAAA,EACzB;AAEA,MAAI,CAAC,KAAK,aAAa;AACrB,eAAW,OAAO,OAAO,KAAK,SAAS,GAAG;AACxC,YAAM,QAAQ,UAAU,GAAG;AAC3B,aAAO,OAAO,UAAU,WAAW,EAAE,GAAG,MAAM,IAAI;AAAA,IACpD;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
package/dist/esm/index.js CHANGED
@@ -1,8 +1,5 @@
1
- import { stringifyXML, parseXML } from "./xml.js";
2
- import { XML_ATTRKEY, XML_CHARKEY } from "./xml.common.js";
3
- export {
4
- XML_ATTRKEY,
5
- XML_CHARKEY,
6
- parseXML,
7
- stringifyXML
8
- };
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export { stringifyXML, parseXML } from "./xml.js";
4
+ export { XML_ATTRKEY, XML_CHARKEY } from "./xml.common.js";
5
+ //# sourceMappingURL=index.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-xml/src/index.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport { stringifyXML, parseXML } from \"./xml.js\";\nexport { XML_ATTRKEY, XML_CHARKEY, type XmlOptions } from \"./xml.common.js\";\n"],
5
- "mappings": "AAGA,SAAS,cAAc,gBAAgB;AACvC,SAAS,aAAa,mBAAoC;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAmB,MAAM,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport { stringifyXML, parseXML } from \"./xml.js\";\nexport { XML_ATTRKEY, XML_CHARKEY, type XmlOptions } from \"./xml.common.js\";\n"]}
@@ -1,6 +1,11 @@
1
- const XML_ATTRKEY = "$";
2
- const XML_CHARKEY = "_";
3
- export {
4
- XML_ATTRKEY,
5
- XML_CHARKEY
6
- };
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ /**
4
+ * Default key used to access the XML attributes.
5
+ */
6
+ export const XML_ATTRKEY = "$";
7
+ /**
8
+ * Default key used to access the XML value content.
9
+ */
10
+ export const XML_CHARKEY = "_";
11
+ //# sourceMappingURL=xml.common.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-xml/src/xml.common.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Default key used to access the XML attributes.\n */\nexport const XML_ATTRKEY = \"$\";\n/**\n * Default key used to access the XML value content.\n */\nexport const XML_CHARKEY = \"_\";\n\n/**\n * Options to govern behavior of xml parser and builder.\n */\nexport interface XmlOptions {\n /**\n * indicates the name of the root element in the resulting XML when building XML.\n */\n rootName?: string;\n /**\n * indicates whether the root element is to be included or not in the output when parsing XML.\n */\n includeRoot?: boolean;\n /**\n * key used to access the XML value content when parsing XML.\n */\n xmlCharKey?: string;\n\n /**\n * property name for a CDATA section.\n */\n cdataPropName?: string;\n\n /**\n * XML nodes to exclude from parsing.\n */\n stopNodes?: string[];\n}\n"],
5
- "mappings": "AAMO,MAAM,cAAc;AAIpB,MAAM,cAAc;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"xml.common.js","sourceRoot":"","sources":["../../src/xml.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAC/B;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Default key used to access the XML attributes.\n */\nexport const XML_ATTRKEY = \"$\";\n/**\n * Default key used to access the XML value content.\n */\nexport const XML_CHARKEY = \"_\";\n\n/**\n * Options to govern behavior of xml parser and builder.\n */\nexport interface XmlOptions {\n /**\n * indicates the name of the root element in the resulting XML when building XML.\n */\n rootName?: string;\n /**\n * indicates whether the root element is to be included or not in the output when parsing XML.\n */\n includeRoot?: boolean;\n /**\n * key used to access the XML value content when parsing XML.\n */\n xmlCharKey?: string;\n\n /**\n * property name for a CDATA section.\n */\n cdataPropName?: string;\n\n /**\n * XML nodes to exclude from parsing.\n */\n stopNodes?: string[];\n}\n"]}
package/dist/esm/xml.js CHANGED
@@ -1,64 +1,77 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
1
3
  import { XMLBuilder, XMLParser, XMLValidator } from "fast-xml-parser";
2
4
  import { XML_ATTRKEY, XML_CHARKEY } from "./xml.common.js";
3
5
  function getCommonOptions(options) {
4
- return {
5
- attributesGroupName: XML_ATTRKEY,
6
- textNodeName: options.xmlCharKey ?? XML_CHARKEY,
7
- ignoreAttributes: false,
8
- suppressBooleanAttributes: false
9
- };
6
+ return {
7
+ attributesGroupName: XML_ATTRKEY,
8
+ textNodeName: options.xmlCharKey ?? XML_CHARKEY,
9
+ ignoreAttributes: false,
10
+ suppressBooleanAttributes: false,
11
+ };
10
12
  }
11
13
  function getSerializerOptions(options = {}) {
12
- return {
13
- ...getCommonOptions(options),
14
- attributeNamePrefix: "@_",
15
- format: true,
16
- suppressEmptyNode: true,
17
- indentBy: "",
18
- rootNodeName: options.rootName ?? "root",
19
- cdataPropName: options.cdataPropName ?? "__cdata"
20
- };
14
+ return {
15
+ ...getCommonOptions(options),
16
+ attributeNamePrefix: "@_",
17
+ format: true,
18
+ suppressEmptyNode: true,
19
+ indentBy: "",
20
+ rootNodeName: options.rootName ?? "root",
21
+ cdataPropName: options.cdataPropName ?? "__cdata",
22
+ };
21
23
  }
22
24
  function getParserOptions(options = {}) {
23
- return {
24
- ...getCommonOptions(options),
25
- parseAttributeValue: false,
26
- parseTagValue: false,
27
- attributeNamePrefix: "",
28
- stopNodes: options.stopNodes,
29
- processEntities: true,
30
- trimValues: false
31
- };
25
+ return {
26
+ ...getCommonOptions(options),
27
+ parseAttributeValue: false,
28
+ parseTagValue: false,
29
+ attributeNamePrefix: "",
30
+ stopNodes: options.stopNodes,
31
+ processEntities: true,
32
+ trimValues: false,
33
+ };
32
34
  }
33
- function stringifyXML(obj, opts = {}) {
34
- const parserOptions = getSerializerOptions(opts);
35
- const j2x = new XMLBuilder(parserOptions);
36
- const node = { [parserOptions.rootNodeName]: obj };
37
- const xmlData = j2x.build(node);
38
- return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${xmlData}`.replace(/\n/g, "");
35
+ /**
36
+ * Converts given JSON object to XML string
37
+ * @param obj - JSON object to be converted into XML string
38
+ * @param opts - Options that govern the XML building of given JSON object
39
+ * `rootName` indicates the name of the root element in the resulting XML
40
+ */
41
+ export function stringifyXML(obj, opts = {}) {
42
+ const parserOptions = getSerializerOptions(opts);
43
+ const j2x = new XMLBuilder(parserOptions);
44
+ const node = { [parserOptions.rootNodeName]: obj };
45
+ const xmlData = j2x.build(node);
46
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${xmlData}`.replace(/\n/g, "");
39
47
  }
40
- async function parseXML(str, opts = {}) {
41
- if (!str) {
42
- throw new Error("Document is empty");
43
- }
44
- const validation = XMLValidator.validate(str);
45
- if (validation !== true) {
46
- throw validation;
47
- }
48
- const parser = new XMLParser(getParserOptions(opts));
49
- const parsedXml = parser.parse(str);
50
- if (parsedXml["?xml"]) {
51
- delete parsedXml["?xml"];
52
- }
53
- if (!opts.includeRoot) {
54
- for (const key of Object.keys(parsedXml)) {
55
- const value = parsedXml[key];
56
- return typeof value === "object" ? { ...value } : value;
48
+ /**
49
+ * Converts given XML string into JSON
50
+ * @param str - String containing the XML content to be parsed into JSON
51
+ * @param opts - Options that govern the parsing of given xml string
52
+ * `includeRoot` indicates whether the root element is to be included or not in the output
53
+ */
54
+ export async function parseXML(str, opts = {}) {
55
+ if (!str) {
56
+ throw new Error("Document is empty");
57
57
  }
58
- }
59
- return parsedXml;
58
+ const validation = XMLValidator.validate(str);
59
+ if (validation !== true) {
60
+ throw validation;
61
+ }
62
+ const parser = new XMLParser(getParserOptions(opts));
63
+ const parsedXml = parser.parse(str);
64
+ // Remove the <?xml version="..." ?> node.
65
+ // This is a change in behavior on fxp v4. Issue #424
66
+ if (parsedXml["?xml"]) {
67
+ delete parsedXml["?xml"];
68
+ }
69
+ if (!opts.includeRoot) {
70
+ for (const key of Object.keys(parsedXml)) {
71
+ const value = parsedXml[key];
72
+ return typeof value === "object" ? { ...value } : value;
73
+ }
74
+ }
75
+ return parsedXml;
60
76
  }
61
- export {
62
- parseXML,
63
- stringifyXML
64
- };
77
+ //# sourceMappingURL=xml.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-xml/src/xml.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { XMLBuilder, XMLParser, XMLValidator } from \"fast-xml-parser\";\nimport { XML_ATTRKEY, XML_CHARKEY, type XmlOptions } from \"./xml.common.js\";\n\nfunction getCommonOptions(options: XmlOptions): {\n attributesGroupName: string;\n textNodeName: string;\n ignoreAttributes: boolean;\n suppressBooleanAttributes: boolean;\n} {\n return {\n attributesGroupName: XML_ATTRKEY,\n textNodeName: options.xmlCharKey ?? XML_CHARKEY,\n ignoreAttributes: false,\n suppressBooleanAttributes: false,\n };\n}\n\nfunction getSerializerOptions(options: XmlOptions = {}): {\n attributesGroupName: string;\n textNodeName: string;\n ignoreAttributes: boolean;\n suppressBooleanAttributes: boolean;\n attributeNamePrefix: string;\n format: boolean;\n suppressEmptyNode: boolean;\n indentBy: string;\n rootNodeName: string;\n cdataPropName: string;\n} {\n return {\n ...getCommonOptions(options),\n attributeNamePrefix: \"@_\",\n format: true,\n suppressEmptyNode: true,\n indentBy: \"\",\n rootNodeName: options.rootName ?? \"root\",\n cdataPropName: options.cdataPropName ?? \"__cdata\",\n };\n}\n\nfunction getParserOptions(options: XmlOptions = {}): {\n attributesGroupName: string;\n textNodeName: string;\n ignoreAttributes: boolean;\n suppressBooleanAttributes: boolean;\n parseAttributeValue: boolean;\n parseTagValue: boolean;\n attributeNamePrefix: string;\n stopNodes?: string[];\n processEntities: boolean;\n trimValues: boolean;\n} {\n return {\n ...getCommonOptions(options),\n parseAttributeValue: false,\n parseTagValue: false,\n attributeNamePrefix: \"\",\n stopNodes: options.stopNodes,\n processEntities: true,\n trimValues: false,\n };\n}\n/**\n * Converts given JSON object to XML string\n * @param obj - JSON object to be converted into XML string\n * @param opts - Options that govern the XML building of given JSON object\n * `rootName` indicates the name of the root element in the resulting XML\n */\nexport function stringifyXML(obj: unknown, opts: XmlOptions = {}): string {\n const parserOptions = getSerializerOptions(opts);\n const j2x = new XMLBuilder(parserOptions);\n\n const node = { [parserOptions.rootNodeName]: obj };\n\n const xmlData: string = j2x.build(node);\n return `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>${xmlData}`.replace(/\\n/g, \"\");\n}\n\n/**\n * Converts given XML string into JSON\n * @param str - String containing the XML content to be parsed into JSON\n * @param opts - Options that govern the parsing of given xml string\n * `includeRoot` indicates whether the root element is to be included or not in the output\n */\nexport async function parseXML(str: string, opts: XmlOptions = {}): Promise<any> {\n if (!str) {\n throw new Error(\"Document is empty\");\n }\n\n const validation = XMLValidator.validate(str);\n\n if (validation !== true) {\n throw validation;\n }\n\n const parser = new XMLParser(getParserOptions(opts));\n const parsedXml = parser.parse(str);\n\n // Remove the <?xml version=\"...\" ?> node.\n // This is a change in behavior on fxp v4. Issue #424\n if (parsedXml[\"?xml\"]) {\n delete parsedXml[\"?xml\"];\n }\n\n if (!opts.includeRoot) {\n for (const key of Object.keys(parsedXml)) {\n const value = parsedXml[key];\n return typeof value === \"object\" ? { ...value } : value;\n }\n }\n\n return parsedXml;\n}\n"],
5
- "mappings": "AAGA,SAAS,YAAY,WAAW,oBAAoB;AACpD,SAAS,aAAa,mBAAoC;AAE1D,SAAS,iBAAiB,SAKxB;AACA,SAAO;AAAA,IACL,qBAAqB;AAAA,IACrB,cAAc,QAAQ,cAAc;AAAA,IACpC,kBAAkB;AAAA,IAClB,2BAA2B;AAAA,EAC7B;AACF;AAEA,SAAS,qBAAqB,UAAsB,CAAC,GAWnD;AACA,SAAO;AAAA,IACL,GAAG,iBAAiB,OAAO;AAAA,IAC3B,qBAAqB;AAAA,IACrB,QAAQ;AAAA,IACR,mBAAmB;AAAA,IACnB,UAAU;AAAA,IACV,cAAc,QAAQ,YAAY;AAAA,IAClC,eAAe,QAAQ,iBAAiB;AAAA,EAC1C;AACF;AAEA,SAAS,iBAAiB,UAAsB,CAAC,GAW/C;AACA,SAAO;AAAA,IACL,GAAG,iBAAiB,OAAO;AAAA,IAC3B,qBAAqB;AAAA,IACrB,eAAe;AAAA,IACf,qBAAqB;AAAA,IACrB,WAAW,QAAQ;AAAA,IACnB,iBAAiB;AAAA,IACjB,YAAY;AAAA,EACd;AACF;AAOO,SAAS,aAAa,KAAc,OAAmB,CAAC,GAAW;AACxE,QAAM,gBAAgB,qBAAqB,IAAI;AAC/C,QAAM,MAAM,IAAI,WAAW,aAAa;AAExC,QAAM,OAAO,EAAE,CAAC,cAAc,YAAY,GAAG,IAAI;AAEjD,QAAM,UAAkB,IAAI,MAAM,IAAI;AACtC,SAAO,0DAA0D,OAAO,GAAG,QAAQ,OAAO,EAAE;AAC9F;AAQA,eAAsB,SAAS,KAAa,OAAmB,CAAC,GAAiB;AAC/E,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,mBAAmB;AAAA,EACrC;AAEA,QAAM,aAAa,aAAa,SAA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M,CAAC,CAAC;IAC3B,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACzC,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;YAC7B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { XMLBuilder, XMLParser, XMLValidator } from \"fast-xml-parser\";\nimport { XML_ATTRKEY, XML_CHARKEY, type XmlOptions } from \"./xml.common.js\";\n\nfunction getCommonOptions(options: XmlOptions): {\n attributesGroupName: string;\n textNodeName: string;\n ignoreAttributes: boolean;\n suppressBooleanAttributes: boolean;\n} {\n return {\n attributesGroupName: XML_ATTRKEY,\n textNodeName: options.xmlCharKey ?? XML_CHARKEY,\n ignoreAttributes: false,\n suppressBooleanAttributes: false,\n };\n}\n\nfunction getSerializerOptions(options: XmlOptions = {}): {\n attributesGroupName: string;\n textNodeName: string;\n ignoreAttributes: boolean;\n suppressBooleanAttributes: boolean;\n attributeNamePrefix: string;\n format: boolean;\n suppressEmptyNode: boolean;\n indentBy: string;\n rootNodeName: string;\n cdataPropName: string;\n} {\n return {\n ...getCommonOptions(options),\n attributeNamePrefix: \"@_\",\n format: true,\n suppressEmptyNode: true,\n indentBy: \"\",\n rootNodeName: options.rootName ?? \"root\",\n cdataPropName: options.cdataPropName ?? \"__cdata\",\n };\n}\n\nfunction getParserOptions(options: XmlOptions = {}): {\n attributesGroupName: string;\n textNodeName: string;\n ignoreAttributes: boolean;\n suppressBooleanAttributes: boolean;\n parseAttributeValue: boolean;\n parseTagValue: boolean;\n attributeNamePrefix: string;\n stopNodes?: string[];\n processEntities: boolean;\n trimValues: boolean;\n} {\n return {\n ...getCommonOptions(options),\n parseAttributeValue: false,\n parseTagValue: false,\n attributeNamePrefix: \"\",\n stopNodes: options.stopNodes,\n processEntities: true,\n trimValues: false,\n };\n}\n/**\n * Converts given JSON object to XML string\n * @param obj - JSON object to be converted into XML string\n * @param opts - Options that govern the XML building of given JSON object\n * `rootName` indicates the name of the root element in the resulting XML\n */\nexport function stringifyXML(obj: unknown, opts: XmlOptions = {}): string {\n const parserOptions = getSerializerOptions(opts);\n const j2x = new XMLBuilder(parserOptions);\n\n const node = { [parserOptions.rootNodeName]: obj };\n\n const xmlData: string = j2x.build(node);\n return `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>${xmlData}`.replace(/\\n/g, \"\");\n}\n\n/**\n * Converts given XML string into JSON\n * @param str - String containing the XML content to be parsed into JSON\n * @param opts - Options that govern the parsing of given xml string\n * `includeRoot` indicates whether the root element is to be included or not in the output\n */\nexport async function parseXML(str: string, opts: XmlOptions = {}): Promise<any> {\n if (!str) {\n throw new Error(\"Document is empty\");\n }\n\n const validation = XMLValidator.validate(str);\n\n if (validation !== true) {\n throw validation;\n }\n\n const parser = new XMLParser(getParserOptions(opts));\n const parsedXml = parser.parse(str);\n\n // Remove the <?xml version=\"...\" ?> node.\n // This is a change in behavior on fxp v4. Issue #424\n if (parsedXml[\"?xml\"]) {\n delete parsedXml[\"?xml\"];\n }\n\n if (!opts.includeRoot) {\n for (const key of Object.keys(parsedXml)) {\n const value = parsedXml[key];\n return typeof value === \"object\" ? { ...value } : value;\n }\n }\n\n return parsedXml;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/core-xml",
3
- "version": "1.5.1-alpha.20260305.6",
3
+ "version": "1.5.1",
4
4
  "description": "Core library for interacting with XML payloads",
5
5
  "sdk-type": "client",
6
6
  "type": "module",
@@ -52,23 +52,23 @@
52
52
  "sideEffects": false,
53
53
  "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
54
54
  "dependencies": {
55
- "fast-xml-parser": "^5.0.7",
55
+ "fast-xml-parser": "^5.5.9",
56
56
  "tslib": "^2.8.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/node": "^20.19.25",
60
60
  "@types/trusted-types": "^2.0.0",
61
- "@vitest/browser-playwright": "^4.0.8",
62
- "@vitest/coverage-istanbul": "^4.0.8",
61
+ "@vitest/browser-playwright": "^4.1.2",
62
+ "@vitest/coverage-istanbul": "^4.1.2",
63
63
  "cross-env": "^10.1.0",
64
64
  "eslint": "^9.39.1",
65
- "playwright": "^1.56.1",
65
+ "playwright": "^1.58.2",
66
66
  "prettier": "^3.6.2",
67
67
  "rimraf": "^6.1.0",
68
- "typescript": "~5.9.3",
69
- "vitest": "^4.0.8",
70
- "@azure/dev-tool": "^1.0.0",
71
- "@azure/eslint-plugin-azure-sdk": "^3.0.0"
68
+ "typescript": "~6.0.2",
69
+ "vitest": "^4.1.2",
70
+ "@azure/eslint-plugin-azure-sdk": "^3.0.0",
71
+ "@azure/dev-tool": "^1.0.0"
72
72
  },
73
73
  "//metadata": {
74
74
  "migrationDate": "2023-03-08T18:36:03.000Z"