Initial
This commit is contained in:
86
resources/app/node_modules/@aws-sdk/xml-builder/dist-es/XmlNode.js
generated
vendored
Normal file
86
resources/app/node_modules/@aws-sdk/xml-builder/dist-es/XmlNode.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
import { escapeAttribute } from "./escape-attribute";
|
||||
import { XmlText } from "./XmlText";
|
||||
export class XmlNode {
|
||||
static of(name, childText, withName) {
|
||||
const node = new XmlNode(name);
|
||||
if (childText !== undefined) {
|
||||
node.addChildNode(new XmlText(childText));
|
||||
}
|
||||
if (withName !== undefined) {
|
||||
node.withName(withName);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
constructor(name, children = []) {
|
||||
this.name = name;
|
||||
this.children = children;
|
||||
this.attributes = {};
|
||||
}
|
||||
withName(name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
addAttribute(name, value) {
|
||||
this.attributes[name] = value;
|
||||
return this;
|
||||
}
|
||||
addChildNode(child) {
|
||||
this.children.push(child);
|
||||
return this;
|
||||
}
|
||||
removeAttribute(name) {
|
||||
delete this.attributes[name];
|
||||
return this;
|
||||
}
|
||||
n(name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
c(child) {
|
||||
this.children.push(child);
|
||||
return this;
|
||||
}
|
||||
a(name, value) {
|
||||
if (value != null) {
|
||||
this.attributes[name] = value;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
cc(input, field, withName = field) {
|
||||
if (input[field] != null) {
|
||||
const node = XmlNode.of(field, input[field]).withName(withName);
|
||||
this.c(node);
|
||||
}
|
||||
}
|
||||
l(input, listName, memberName, valueProvider) {
|
||||
if (input[listName] != null) {
|
||||
const nodes = valueProvider();
|
||||
nodes.map((node) => {
|
||||
node.withName(memberName);
|
||||
this.c(node);
|
||||
});
|
||||
}
|
||||
}
|
||||
lc(input, listName, memberName, valueProvider) {
|
||||
if (input[listName] != null) {
|
||||
const nodes = valueProvider();
|
||||
const containerNode = new XmlNode(memberName);
|
||||
nodes.map((node) => {
|
||||
containerNode.c(node);
|
||||
});
|
||||
this.c(containerNode);
|
||||
}
|
||||
}
|
||||
toString() {
|
||||
const hasChildren = Boolean(this.children.length);
|
||||
let xmlText = `<${this.name}`;
|
||||
const attributes = this.attributes;
|
||||
for (const attributeName of Object.keys(attributes)) {
|
||||
const attribute = attributes[attributeName];
|
||||
if (attribute != null) {
|
||||
xmlText += ` ${attributeName}="${escapeAttribute("" + attribute)}"`;
|
||||
}
|
||||
}
|
||||
return (xmlText += !hasChildren ? "/>" : `>${this.children.map((c) => c.toString()).join("")}</${this.name}>`);
|
||||
}
|
||||
}
|
||||
9
resources/app/node_modules/@aws-sdk/xml-builder/dist-es/XmlText.js
generated
vendored
Normal file
9
resources/app/node_modules/@aws-sdk/xml-builder/dist-es/XmlText.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { escapeElement } from "./escape-element";
|
||||
export class XmlText {
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
toString() {
|
||||
return escapeElement("" + this.value);
|
||||
}
|
||||
}
|
||||
3
resources/app/node_modules/@aws-sdk/xml-builder/dist-es/escape-attribute.js
generated
vendored
Normal file
3
resources/app/node_modules/@aws-sdk/xml-builder/dist-es/escape-attribute.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export function escapeAttribute(value) {
|
||||
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
||||
}
|
||||
12
resources/app/node_modules/@aws-sdk/xml-builder/dist-es/escape-element.js
generated
vendored
Normal file
12
resources/app/node_modules/@aws-sdk/xml-builder/dist-es/escape-element.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
export function escapeElement(value) {
|
||||
return value
|
||||
.replace(/&/g, "&")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/\r/g, "
")
|
||||
.replace(/\n/g, "
")
|
||||
.replace(/\u0085/g, "…")
|
||||
.replace(/\u2028/, "
");
|
||||
}
|
||||
2
resources/app/node_modules/@aws-sdk/xml-builder/dist-es/index.js
generated
vendored
Normal file
2
resources/app/node_modules/@aws-sdk/xml-builder/dist-es/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./XmlNode";
|
||||
export * from "./XmlText";
|
||||
1
resources/app/node_modules/@aws-sdk/xml-builder/dist-es/stringable.js
generated
vendored
Normal file
1
resources/app/node_modules/@aws-sdk/xml-builder/dist-es/stringable.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user