@amazon/vinyl-xml 3.2.2 → 3.2.3-next.20261001224604

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.
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/xlink/actuateValidator.ts", "../src/xml/mappedXmlRules.ts", "../src/xml/xmlRules.ts", "../src/xml/mergeXmlRules.ts", "../src/xml/parseXml.ts", "../src/xml/ParseXmlHandlerImpl.ts", "../src/xml/XmlSchemaError.ts", "../src/xml/QName.ts", "../src/xml/stringifyXml.ts"],
4
- "sourcesContent": ["/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { isOneOf, type Validator } from '@amazon/vinyl-validation'\nimport type { actuateType } from '../xmlns/org/w3/1999/xlink'\nimport { ErrorOrigin } from '@amazon/vinyl-util'\n\nconst actuateValidator: Validator<actuateType> = /* @__PURE__ */ isOneOf('onLoad', 'onRequest')\n\nexport function assertActuateEnum(str: string): actuateType {\n actuateValidator.assert(str, ErrorOrigin.PARSING)\n return str\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n type AnyRecord,\n IllegalArgumentError,\n invariant,\n type Invariant,\n memoize,\n} from '@amazon/vinyl-util'\n\nimport type { XmlRule, XmlRules } from './xmlRules'\nimport { XmlRuleType } from './xmlRules'\nimport type { Uri } from '../xmlns/org/w3/2001/XmlSchema'\n\n/**\n * A machine-readable representation of parse rules for random access based on qualified namespace\n * keys.\n *\n * Rule keys will either be `namespaceUri:localPart` or just `localPart` for wildcard rules if\n * namespaceUri is not defined in the handler.\n */\nexport interface MappedXmlRules<T> {\n /**\n * Enforces that this rule set can only be used to parse the expected type T.\n */\n readonly __type: Invariant<T>\n readonly attributes: ReadonlyMap<string, MappedAttributeRule>\n readonly elements: ReadonlyMap<string, MappedElementsRule>\n readonly characters: MappedCharactersRule | undefined\n}\n\nexport interface MappedAttributeRule {\n /**\n * The property name.\n */\n readonly property: keyof any\n\n /**\n * If true, a parsing error will be thrown if the value is undefined.\n */\n readonly required: boolean\n\n /**\n * If the current element has no matching attribute, default will be used.\n */\n readonly default: any\n\n /**\n * Parses the attribute value.\n */\n readonly parse: (value: string) => any\n\n /**\n * Converts the attribute value to a string.\n */\n readonly stringify: (value: any) => string\n\n /**\n * The local part of the QName.\n */\n readonly localPart: string\n\n /**\n * The namespace uri that must match.\n */\n readonly namespaceUri: Uri | null\n}\n\nexport interface MappedElementsRule {\n /**\n * The name of the property to set on the parent element.\n */\n readonly property: keyof any\n\n /**\n * True if the parsed elements should populate into an array.\n */\n readonly array: boolean\n\n /**\n * The minimum number of elements.\n */\n readonly minOccurs: number\n\n /**\n * The maximum number of elements. Use null for unbounded.\n */\n readonly maxOccurs: number | null\n\n /**\n * If true and there are 0 occurrences of the element, the parsed value will be an empty array\n * instead of undefined.\n */\n readonly useEmptyArrays: boolean\n\n /**\n * Returns the mappings for matched element(s).\n */\n readonly rules: () => MappedXmlRules<any>\n\n /**\n * The local part of the QName.\n */\n readonly localPart: string\n\n /**\n * The namespace uri that must match.\n */\n readonly namespaceUri: Uri | null\n}\n\nexport interface MappedCharactersRule {\n readonly property: keyof any\n\n /**\n * Parses the unescaped/processed characters.\n * This will always be called, but characters may be an empty string if the element has no\n * text content.\n */\n readonly parse: (characters: string) => any\n\n /**\n * Converts the value to a string.\n */\n readonly stringify: (value: any) => string\n}\n\n/**\n * An empty rules map, used when there was no match for the started element.\n * @private\n */\nexport const EmptyRules: MappedXmlRules<AnyRecord> = {\n __type: /* @__PURE__ */ invariant(),\n attributes: /* @__PURE__ */ new Map(),\n elements: /* @__PURE__ */ new Map(),\n characters: undefined,\n} as const\n\n/**\n * Creates machine-friendly content handler rules from the given {@link XmlRules}.\n *\n * @param rules The {@link XmlRules} to convert.\n * @param parentNamespaceUri\n */\nexport function mapXmlRules<T extends object>(\n rules: XmlRules<T>,\n parentNamespaceUri: Uri | null = null\n): MappedXmlRules<T> {\n const attributeRules = new Map<string, MappedAttributeRule>()\n const elementRules = new Map<string, MappedElementsRule>()\n let charactersRule: MappedCharactersRule | undefined = undefined\n\n for (const property in rules) {\n const handlerOrFunction = rules[property as keyof typeof rules]\n let handler: XmlRule<any>\n if (typeof handlerOrFunction === 'function') {\n handler = handlerOrFunction()\n } else {\n handler = handlerOrFunction\n }\n let key: string\n switch (handler.type) {\n case XmlRuleType.CHARACTERS:\n if (charactersRule !== undefined)\n throw new IllegalArgumentError(\n 'characters handler already defined'\n )\n charactersRule = {\n property,\n parse: handler.parse,\n stringify: handler.stringify,\n }\n break\n case XmlRuleType.ELEMENT:\n case XmlRuleType.ELEMENTS: {\n const localPart = handler.localPart ?? property\n const namespaceUri: Uri | null =\n handler.namespaceUri === undefined\n ? parentNamespaceUri\n : handler.namespaceUri\n key = xmlRuleKey(localPart, namespaceUri)\n if (elementRules.has(key)) {\n throw new IllegalArgumentError(\n `Multiple element rules for ${key}`\n )\n }\n if (handler.type === XmlRuleType.ELEMENT) {\n const rules = handler.rules\n elementRules.set(key, {\n array: false,\n property,\n minOccurs: handler.required ? 1 : 0,\n maxOccurs: 1,\n rules: memoize(() => mapXmlRules(rules, namespaceUri)),\n useEmptyArrays: false,\n localPart,\n namespaceUri,\n })\n } else {\n const rules = handler.rules\n elementRules.set(key, {\n array: true,\n property,\n maxOccurs: handler.maxOccurs,\n minOccurs: handler.minOccurs,\n rules: memoize(() => mapXmlRules(rules, namespaceUri)),\n useEmptyArrays: handler.useEmptyArrays,\n localPart,\n namespaceUri,\n })\n }\n break\n }\n case XmlRuleType.ATTRIBUTE: {\n // Attributes should not inherit the namespace of the parent element.\n const namespaceUri = handler.namespaceUri\n const localPart = handler.localPart ?? property\n key = xmlRuleKey(localPart, namespaceUri)\n if (attributeRules.has(key)) {\n throw new IllegalArgumentError(\n `Multiple attribute rules for ${key}`\n )\n }\n attributeRules.set(key, {\n property,\n default: handler.default,\n parse: handler.parse,\n stringify: handler.stringify,\n required: handler.required,\n localPart,\n namespaceUri: handler.namespaceUri ?? null,\n })\n break\n }\n }\n }\n return {\n __type: invariant(),\n attributes: attributeRules,\n elements: elementRules,\n characters: charactersRule,\n }\n}\n\n/**\n * Creates a rule key for mapped xml rules.\n *\n * @private\n * @param localPart The {@link QName.localPart}\n * @param namespaceUri The `namespaceUri` of the element.\n */\nexport function xmlRuleKey(\n localPart: string,\n namespaceUri: Uri | null = null\n): string {\n return `${namespaceUri ?? ''}:${localPart}`\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * A set of utilities for easily writing schema-based rule definitions to be used with the\n * `parseXml` parser.\n *\n * @module\n */\n\nimport {\n parseDate,\n stringifyDate,\n parseBoolean,\n stringify,\n type Invariant,\n type Maybe,\n type ReadonlyDate,\n} from '@amazon/vinyl-util'\n\nimport type { Uri } from '../xmlns/org/w3/2001/XmlSchema'\n\nexport enum XmlRuleType {\n CHARACTERS = 'characters',\n ATTRIBUTE = 'attribute',\n ELEMENT = 'element',\n ELEMENTS = 'elements',\n}\n\n/**\n * Reserved keys that may not be used in XmlRules.\n *\n * If a schema uses a reserved word, set `localPart` in the rule options to associate.\n */\nexport type ReservedXmlRuleKeys = 'parent' | 'clone' | 'toJSON'\n\n/**\n * A schema for XML serialization and deserialization.\n *\n * The parser values may be lazy, represented as a function that returns a property parser.\n * @typeParam T The object type these parsing rules model.\n */\nexport type XmlRules<T extends object> = {\n readonly [P in Exclude<keyof T, ReservedXmlRuleKeys>]-?:\n XmlRule<T[P]> | LazyXmlRule<T[P]>\n}\n\n/**\n * A union of the supported parsing types.\n */\nexport type XmlRule<T> =\n | AttributeRule<T>\n | CharactersRule<T>\n | ElementsRule<T & (readonly object[] | undefined)>\n | ElementRule<T & (object | undefined)>\n\n/**\n * A function that returns a property handler.\n * Useful when there are recursive rules.\n */\nexport type LazyXmlRule<T> = () => XmlRule<T>\n\nexport interface NamespacedRuleOptions {\n /**\n * Matches the `QName.localPart` of the element. If undefined, this will match against\n * the property name from {@link XmlRules}.\n */\n readonly localPart?: string | undefined\n\n /**\n * Matches the `namespaceUri` of the element or attribute.\n *\n * If null, this will only match against a null namespace.\n * If undefined, this will default to the namespace of the parent element for elements, or\n * null for attributes.\n *\n * Note that attributes do not inherit default namespaces as elements do.\n */\n readonly namespaceUri?: Maybe<Uri>\n}\n\n/**\n * A rule definition for a list of elements.\n */\nexport interface ElementsRule<\n T extends readonly object[] | undefined,\n> extends Required<ElementsRuleOptions> {\n readonly type: XmlRuleType.ELEMENTS\n\n /**\n * Prevents rule from losing nullable type information.\n */\n readonly __invariant?: Invariant<T>\n\n /**\n * Returns the schema for matched elements.\n * These rules will be applied per element, collecting into an array.\n */\n readonly rules: XmlRules<NonNullable<T>[number]>\n}\n\nexport interface ElementsRuleOptions extends NamespacedRuleOptions {\n /**\n * The minimum number of elements.\n */\n readonly minOccurs?: number\n\n /**\n * The maximum number of elements. Use null for unbounded.\n */\n readonly maxOccurs?: number | null\n\n /**\n * If true and there are 0 occurrences of the element, the parsed value will be an empty array\n * instead of undefined.\n */\n readonly useEmptyArrays?: boolean\n}\n\n/**\n * A rule definition for a single element.\n */\nexport interface ElementRule<\n T extends object | undefined,\n> extends Required<ElementRuleOptions> {\n /**\n * Prevents rule from losing nullable type information.\n */\n readonly __invariant?: Invariant<T>\n\n readonly type: XmlRuleType.ELEMENT\n\n /**\n * Returns the schema for the matched element.\n */\n readonly rules: XmlRules<NonNullable<T>>\n}\n\nexport interface ElementRuleOptions extends NamespacedRuleOptions {\n /**\n * If true, a parsing error will be thrown if the value is undefined.\n */\n readonly required?: boolean\n}\n\n/**\n * A rule definition for an attribute.\n */\nexport interface AttributeRule<T> extends Required<AttributeRuleOptions<T>> {\n readonly type: XmlRuleType.ATTRIBUTE\n\n /**\n * Parses the attribute value.\n */\n readonly parse: (value: string) => T\n\n /**\n * Stringifies the value.\n */\n readonly stringify: (value: NonNullable<T>) => string\n}\n\nexport interface AttributeRuleOptions<T> extends NamespacedRuleOptions {\n /**\n * If true, a parsing error will be thrown if the value is undefined.\n */\n readonly required?: boolean\n\n /**\n * If the current element has no matching attribute, default will be used.\n */\n readonly default?: T | undefined\n\n /**\n * Matches the `namespaceUri` of the attribute.\n *\n * If null, this will only match against a null namespace.\n *\n * Note that attributes do not inherit default namespaces as elements do.\n */\n readonly namespaceUri?: Uri | null\n}\n\n/**\n * A rule definition for an element's text content.\n */\nexport interface CharactersRule<T> {\n readonly type: XmlRuleType.CHARACTERS\n\n /**\n * Parses the unescaped/processed characters.\n * This will always be called, but characters may be an empty string if the element has no\n * text content.\n */\n readonly parse: (characters: string) => T\n\n /**\n * Stringifies the value.\n */\n readonly stringify: (value: NonNullable<T>) => string\n}\n\nexport interface RequiredElementRuleOptions extends ElementRuleOptions {\n readonly required: true\n}\n\nexport function element<T extends object>(\n rules: XmlRules<T>,\n options: RequiredElementRuleOptions\n): ElementRule<T>\n\nexport function element<T extends object | undefined>(\n rules: XmlRules<NonNullable<T>>,\n options?: ElementRuleOptions\n): ElementRule<T | undefined>\n\n/**\n * Returns a schema for a single object based on a map of rules.\n *\n * If more than one element is found with a matching name, a `ParseError` is thrown.\n */\nexport function element<T extends object | undefined>(\n rules: XmlRules<NonNullable<T>>,\n options?: ElementRuleOptions\n): ElementRule<T | undefined> {\n return {\n type: XmlRuleType.ELEMENT,\n localPart: undefined,\n namespaceUri: undefined,\n required: false,\n ...options,\n rules,\n }\n}\n\n/**\n * Elements options that guarantee that there is a non-null array.\n * For minOccurs types greater than 10, a type cast is required.\n */\nexport type RequiredElementsOptions =\n | (ElementsRuleOptions & { readonly useEmptyArrays: true })\n | (ElementsRuleOptions & {\n readonly minOccurs: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10\n })\n\nexport function elements<T extends object>(\n rules: XmlRules<T>,\n options: RequiredElementsOptions\n): ElementsRule<readonly T[]>\n\nexport function elements<T extends object>(\n rules: XmlRules<T>,\n options?: ElementsRuleOptions\n): ElementsRule<readonly T[] | undefined>\n\n/**\n * Handles a list of child nodes where each matching child node is parsed into a corresponding\n * object represented by the given rules.\n *\n * @param rules The parsing rules to use for each element.\n * @param options\n * @see parseChildNodes\n */\nexport function elements<T extends object>(\n rules: XmlRules<T>,\n options?: ElementsRuleOptions\n): ElementsRule<readonly T[] | undefined> | ElementsRule<readonly T[]> {\n return {\n type: XmlRuleType.ELEMENTS,\n localPart: undefined,\n namespaceUri: undefined,\n minOccurs: 0,\n maxOccurs: null,\n useEmptyArrays: false,\n ...options,\n rules,\n }\n}\n\n/**\n * Parses the text content of the current element via the given parse and stringify functions.\n *\n * Does not currently support mixing text and element nodes.\n * E.g. the XML `<note>Dear <name>John</name>, I regret to inform you...</note>` could not be\n * serialized or deserialized using xml rule mappings.\n *\n * @param parse The string passed to this parser is the processed text content of the current\n * element.\n * @param stringify Serializes the value.\n *\n * @see processCharacters\n */\nexport function characters<T>(\n parse: (str: string) => T,\n stringify: (value: T) => string\n): CharactersRule<T> {\n return { type: XmlRuleType.CHARACTERS, parse, stringify }\n}\n\n/**\n * Handles the processed text content without any modification.\n *\n * @see characters\n */\nexport const charactersString = /* @__PURE__ */ characters((i) => i, stringify)\n\nexport type RequiredAttributeOptions<T> = AttributeRuleOptions<T> &\n ({ required: true } | { default: T })\n\nexport function attr<T>(\n parse: (value: string) => T,\n stringify: (value: T) => string,\n options: RequiredAttributeOptions<T>\n): AttributeRule<T>\n\nexport function attr<T>(\n parse: (value: string) => T,\n stringify: (value: NonNullable<T>) => string,\n options?: AttributeRuleOptions<T>\n): AttributeRule<T | undefined>\n\n/**\n * Handles an attribute using the given parse and stringify functions.\n *\n * @param parse\n * @param stringify\n * @param options\n */\nexport function attr<T>(\n parse: (value: string) => T,\n stringify: (value: T) => string,\n options?: AttributeRuleOptions<T>\n): AttributeRule<T> | AttributeRule<T | undefined> {\n return {\n type: XmlRuleType.ATTRIBUTE,\n localPart: undefined,\n namespaceUri: null,\n required: false,\n default: undefined,\n ...options,\n parse,\n stringify,\n }\n}\n\nexport function attrString(\n options: RequiredAttributeOptions<string>\n): AttributeRule<string>\n\nexport function attrString(\n options?: AttributeRuleOptions<string>\n): AttributeRule<string | undefined>\n\n/**\n * Keeps an attribute's string value as is.\n *\n * @param options\n */\nexport function attrString(\n options?: AttributeRuleOptions<string>\n): AttributeRule<string> | AttributeRule<string | undefined> {\n return attr((i) => i, stringify, options)\n}\n\nexport function attrInt(\n options: RequiredAttributeOptions<number>\n): AttributeRule<number>\n\nexport function attrInt(\n options?: AttributeRuleOptions<number>\n): AttributeRule<number | undefined>\n\n/**\n * Parses an attribute's value using `parseInt`\n *\n * @param options\n */\nexport function attrInt(\n options?: AttributeRuleOptions<number>\n): AttributeRule<number> | AttributeRule<number | undefined> {\n return attr(parseInt, stringify, options)\n}\n\nexport function attrFloat(\n options: RequiredAttributeOptions<number>\n): AttributeRule<number>\n\nexport function attrFloat(\n options?: AttributeRuleOptions<number>\n): AttributeRule<number | undefined>\n\n/**\n * Parses an attribute using `parseFloat`\n *\n * @param options\n */\nexport function attrFloat(\n options?: AttributeRuleOptions<number>\n): AttributeRule<number> | AttributeRule<number | undefined> {\n return attr(parseFloat, stringify, options)\n}\n\nexport function attrBoolean(\n options: RequiredAttributeOptions<boolean>\n): AttributeRule<boolean>\n\nexport function attrBoolean(\n options?: AttributeRuleOptions<boolean>\n): AttributeRule<boolean | undefined>\n\n/**\n * Parses an attribute's value `\"true\"` or `\"1\"` as `true`.\n *\n * @param options\n */\nexport function attrBoolean(\n options?: AttributeRuleOptions<boolean>\n): AttributeRule<boolean> | AttributeRule<boolean | undefined> {\n return attr(parseBoolean, stringify, options)\n}\n\nexport function attrDateTime(\n options: RequiredAttributeOptions<Date>\n): AttributeRule<ReadonlyDate>\n\nexport function attrDateTime(\n options?: AttributeRuleOptions<ReadonlyDate>\n): AttributeRule<ReadonlyDate | undefined>\n\n/**\n * Parses an attribute using `Date.parse`\n *\n * @param options\n */\nexport function attrDateTime(\n options?: AttributeRuleOptions<ReadonlyDate>\n): AttributeRule<ReadonlyDate> | AttributeRule<ReadonlyDate | undefined> {\n return attr(parseDate, stringifyDate, options)\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n type Fun,\n plainObjectMergeRule,\n substitute,\n ValidationError,\n} from '@amazon/vinyl-util'\n\nimport {\n type AttributeRule,\n type ElementRule,\n type ElementsRule,\n type LazyXmlRule,\n type XmlRule,\n type XmlRules,\n XmlRuleType,\n} from './xmlRules'\n\nconst locale = {\n illegalRuleOverrideTypeError:\n 'Cannot override the rule {property} of type {sourceType} with a rule of type {overrideType}',\n illegalQNameOverrideError:\n 'Cannot override the rule {property} with a different localPart or namespace',\n} as const\n\n/**\n * Recursively merges array types so that S[] & T[] becomes (S & T)[]\n * When two array elements parsing rules are merged, the result is an array with intersected\n * element types.\n */\nexport type Merged<T> = T extends readonly any[]\n ? MergedTupleOrArray<T>\n : T extends Fun\n ? T\n : T extends object\n ? {\n [P in keyof T]: Merged<T[P]>\n }\n : T\n\n/**\n * `[S0, T0] & [S1, T1]` cannot be converted to `[S0 & S1, T0 & T1]`, but we can at least preserve\n * the tuple when not intersected.\n *\n * Intersected tuples become arrays. E.g. `[S0, T0] & [S1, T1]` becomes `Array<S0 | S1 | T0 | T1>`\n */\nexport type MergedTupleOrArray<T extends readonly any[]> = T extends [infer V0]\n ? // Support tuples up to 5 in length\n [Merged<V0>]\n : T extends [infer V0, infer V1]\n ? [Merged<V0>, Merged<V1>]\n : T extends [infer V0, infer V1, infer V2]\n ? [Merged<V0>, Merged<V1>, Merged<V2>]\n : T extends [infer V0, infer V1, infer V2, infer V3]\n ? [Merged<V0>, Merged<V1>, Merged<V2>, Merged<V3>]\n : T extends [infer V0, infer V1, infer V2, infer V3, infer V4]\n ? [Merged<V0>, Merged<V1>, Merged<V2>, Merged<V3>, Merged<V4>]\n : T extends any[]\n ? Array<Merged<T[number]>>\n : T extends readonly [infer V0]\n ? readonly [Merged<V0>]\n : T extends readonly [infer V0, infer V1]\n ? readonly [Merged<V0>, Merged<V1>]\n : T extends readonly [infer V0, infer V1, infer V2]\n ? readonly [Merged<V0>, Merged<V1>, Merged<V2>]\n : T extends readonly [\n infer V0,\n infer V1,\n infer V2,\n infer V3,\n ]\n ? readonly [\n Merged<V0>,\n Merged<V1>,\n Merged<V2>,\n Merged<V3>,\n ]\n : T extends readonly [\n infer V0,\n infer V1,\n infer V2,\n infer V3,\n infer V4,\n ]\n ? readonly [\n Merged<V0>,\n Merged<V1>,\n Merged<V2>,\n Merged<V3>,\n Merged<V4>,\n ]\n : ReadonlyArray<Merged<T[number]>>\n\n/**\n * Merges the given two xml rule sets into one.\n */\nexport function mergeXmlRules<A extends object, B extends object>(\n a: XmlRules<A>,\n b: XmlRules<B>\n): XmlRules<Merged<A & B>>\n\n/**\n * Merges the given three xml rule sets into one.\n */\nexport function mergeXmlRules<\n A extends object,\n B extends object,\n C extends object,\n>(a: XmlRules<A>, b: XmlRules<B>, c: XmlRules<C>): XmlRules<Merged<A & B & C>>\n\n/**\n * Merges the given four xml rule sets into one.\n */\nexport function mergeXmlRules<\n A extends object,\n B extends object,\n C extends object,\n D extends object,\n>(\n a: XmlRules<A>,\n b: XmlRules<B>,\n c: XmlRules<C>,\n d: XmlRules<D>\n): XmlRules<Merged<A & B & C & D>>\n\n/**\n * Merges the given five xml rule sets into one.\n */\nexport function mergeXmlRules<\n A extends object,\n B extends object,\n C extends object,\n D extends object,\n E extends object,\n>(\n a: XmlRules<A>,\n b: XmlRules<B>,\n c: XmlRules<C>,\n d: XmlRules<D>,\n e: XmlRules<E>\n): XmlRules<Merged<A & B & C & D & E>>\n\n/**\n * Merges the given six xml rule sets into one.\n */\nexport function mergeXmlRules<\n A extends object,\n B extends object,\n C extends object,\n D extends object,\n E extends object,\n F extends object,\n>(\n a: XmlRules<A>,\n b: XmlRules<B>,\n c: XmlRules<C>,\n d: XmlRules<D>,\n e: XmlRules<E>,\n f: XmlRules<F>\n): XmlRules<Merged<A & B & C & D & E & F>>\n\n/**\n * Merges the given rules into one ruleset.\n *\n * @param rules\n * @return A new XmlRules map with the merged rules.\n */\nexport function mergeXmlRules(\n ...rules: XmlRules<any>[]\n): XmlRules<Merged<any>> {\n let finalRule = rules[0]\n for (let i = 1; i < rules.length; i++) {\n finalRule = plainObjectMergeRule.merge(\n finalRule,\n rules[i],\n mergeXmlRule\n ) as XmlRules<any>\n }\n return finalRule\n}\n\nfunction mergeXmlRule(\n sourceA: XmlRule<any> | undefined,\n sourceB: XmlRule<any>,\n prop: string | number\n): XmlRule<any>\n\nfunction mergeXmlRule(\n sourceA: XmlRule<any> | LazyXmlRule<any> | undefined,\n sourceB: XmlRule<any> | LazyXmlRule<any>,\n prop: string | number\n): XmlRule<any> | LazyXmlRule<any>\n\nfunction mergeXmlRule(\n sourceA: XmlRule<any> | LazyXmlRule<any> | undefined,\n sourceB: XmlRule<any> | LazyXmlRule<any>,\n prop: string | number\n): XmlRule<any> | LazyXmlRule<any> {\n if (sourceA == null) return sourceB\n const sourceAIsLazy = typeof sourceA === 'function'\n const sourceBIsLazy = typeof sourceB === 'function'\n if (sourceAIsLazy || sourceBIsLazy) {\n return () => {\n const a = sourceAIsLazy ? sourceA() : sourceA\n const b = sourceBIsLazy ? sourceB() : sourceB\n return mergeXmlRule(a, b, prop)\n }\n }\n if (sourceA.type !== sourceB.type) {\n throw new ValidationError(\n substitute(locale.illegalRuleOverrideTypeError, {\n property: prop,\n sourceType: sourceA.type,\n overrideType: sourceB.type,\n })\n )\n }\n switch (sourceA.type) {\n case XmlRuleType.ATTRIBUTE:\n case XmlRuleType.ELEMENT:\n case XmlRuleType.ELEMENTS: {\n const b = sourceB as ElementRule<any>\n if (\n sourceA.namespaceUri !== b.namespaceUri ||\n (sourceA.localPart ?? prop) !== (b.localPart ?? prop)\n ) {\n throw new ValidationError(\n substitute(locale.illegalQNameOverrideError, {\n property: prop,\n })\n )\n }\n break\n }\n }\n\n switch (sourceA.type) {\n case XmlRuleType.ATTRIBUTE: {\n const b = sourceB as AttributeRule<any>\n return {\n ...b,\n default: b.default ?? sourceA.default,\n }\n }\n case XmlRuleType.CHARACTERS:\n return sourceB\n case XmlRuleType.ELEMENT: {\n const b = sourceB as ElementRule<any>\n return {\n ...b,\n required: sourceA.required || b.required,\n rules: mergeXmlRules(sourceA.rules, b.rules),\n }\n }\n case XmlRuleType.ELEMENTS: {\n const b = sourceB as ElementsRule<any>\n const maxOccurs =\n sourceA.maxOccurs != null && b.maxOccurs != null\n ? Math.min(sourceA.maxOccurs, b.maxOccurs)\n : (sourceA.maxOccurs ?? b.maxOccurs)\n return {\n ...b,\n minOccurs: Math.max(sourceA.minOccurs, b.minOccurs),\n maxOccurs,\n useEmptyArrays: sourceA.useEmptyArrays || b.useEmptyArrays,\n rules: mergeXmlRules(sourceA.rules, b.rules),\n }\n }\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n char,\n decodeEntities,\n last,\n type MutableDeep,\n StringReader,\n} from '@amazon/vinyl-util'\n\nimport type { Uri } from '../xmlns/org/w3/2001/XmlSchema'\nimport type { Attributes, ParseXmlHandler } from './ParseXmlHandler'\nimport type { QName } from './QName'\nimport type { XmlElement } from './ParseXmlHandlerImpl'\n\nexport const XMLNS = 'http://www.w3.org/2000/xmlns/'\n\nconst LT = /* @__PURE__ */ char('<')\nconst GT = /* @__PURE__ */ char('>')\nconst EQ = /* @__PURE__ */ char('=')\nconst SLASH = /* @__PURE__ */ char('/')\nconst COLON = /* @__PURE__ */ char(':')\nconst QMARK = /* @__PURE__ */ char('?')\nconst EXCL = /* @__PURE__ */ char('!')\nconst APOS = /* @__PURE__ */ char(\"'\")\nconst QUOT = /* @__PURE__ */ char('\"')\nconst QUOTES = /* @__PURE__ */ new Set([APOS, QUOT])\n\n/**\n * Nested xml elements push current namespace information onto a stack.\n *\n * @private\n */\nexport interface StackElement {\n /**\n * The qualified name of the current element on the stack. Used to validate expected closing\n * element.\n */\n readonly qName: string\n\n /**\n * The (mutable) namespaces map for the current stack.\n */\n readonly namespaceMap: Namespaces\n\n /**\n * The default namespace.\n */\n defaultNamespaceUri: Uri | null\n}\n\n/**\n * Parses an XML document using a partial sax-style content handler.\n * This allows for parsing without the entire document being read into memory first.\n *\n * XML Documents are mapped to data structures through content handlers instead of needing an\n * intermediate model.\n */\nexport function parseXml<T>(\n str: string,\n handler: ParseXmlHandler<T>\n): T & XmlElement<T> {\n const c = new StringReader(str)\n let current: StackElement = {\n qName: '#document',\n namespaceMap: new Map(),\n defaultNamespaceUri: null,\n }\n const stack: StackElement[] = [current]\n\n /**\n * Provides the namespace uri for the given prefix on the current stack.\n * @param prefix\n */\n const namespaceLookup = (prefix: string | null): Uri | null => {\n if (!prefix) return current.defaultNamespaceUri\n for (let i = stack.length - 1; i >= 0; i--) {\n const map = stack[i].namespaceMap\n if (map.has(prefix)) return stack[i].namespaceMap.get(prefix)!\n }\n return null\n }\n\n try {\n handler.startDocument()\n } catch (e: any) {\n c.err(e.message)\n }\n while (c.hasNext()) {\n const charsStart = c.untilChar(LT)\n if (charsStart < c.position) {\n const chars = str.substring(charsStart, c.position)\n try {\n handler.textNode(chars)\n } catch (e: any) {\n c.err(e.message)\n }\n }\n if (!c.hasNext()) break // eos\n c.next() // <\n if (c.charIf(SLASH)) {\n // </ prepare for ending the element.\n c.white()\n const name = readQName(c)\n if (name.qName !== current.qName)\n c.err(`Expected </${current.qName}> but was </${name.qName}>`)\n stack.pop()\n current = last(stack)!\n c.white()\n c.readChar(GT)\n try {\n handler.endElement()\n } catch (e: any) {\n c.err(e.message)\n }\n } else if (c.charIf(QMARK)) {\n // <? Processing instruction\n untilTagClose(c)\n } else if (c.charIf(EXCL)) {\n // <! Declaration\n if (c.charIf(0x2d /* - */)) {\n c.readChar(0x2d)\n // <!-- Comment\n c.untilString('-->')\n c.read('-->')\n } else if (c.stringIf('[CDATA[')) {\n // <![CDATA[\n const charsStart = c.untilString(']]>')\n try {\n handler.cDataNode(str.substring(charsStart, c.position))\n } catch (e: any) {\n c.err(e.message)\n }\n c.read(']]>')\n } else {\n // <! Declaration\n untilTagClose(c)\n }\n } else {\n // < Prepare for beginning the element\n // Create a new stack element, inheriting the namespaces of the parent.\n const name: MutableDeep<QName> = readQName(c)\n current = {\n qName: name.qName,\n namespaceMap: new Map(),\n defaultNamespaceUri: current.defaultNamespaceUri,\n }\n stack.push(current)\n const attributes = xmlAttributes(c, current)\n // The namespaces can only be looked up after all attributes are parsed;\n // a namespace prefix may be defined after it's used on the same element.\n name.namespaceUri = namespaceLookup(name.prefix)\n for (const attributesKey in attributes) {\n const value = attributes[attributesKey]!\n const name = value.name\n // Attributes do not inherit the default namespace.\n if (name.prefix && !name.namespaceUri) {\n name.namespaceUri = namespaceLookup(name.prefix)\n }\n }\n\n try {\n handler.startElement(name, attributes)\n } catch (e: any) {\n c.err(e.message)\n }\n if (c.charIf(SLASH)) {\n c.readChar(GT)\n stack.pop()\n current = last(stack)!\n // Closed tag <example/>\n try {\n handler.endElement()\n } catch (e: any) {\n c.err(e.message)\n }\n } else {\n c.readChar(GT)\n }\n }\n }\n try {\n return handler.endDocument()\n } catch (e: any) {\n return c.err(e.message)\n }\n}\n\n/**\n * @private\n */\nexport type Namespaces = Map<string, Uri | null>\n\n// noinspection GrazieInspection\n/**\n * Given that the cursor is at a ' or \", reads the sequence of characters until an end quote is\n * reached.\n * The returned unescaped string is the text within the quotes.\n * @private\n */\nexport function readAttributeValue(c: StringReader): string {\n const quote = c.next()\n if (!QUOTES.has(quote)) c.err('Expected \\' or \"')\n const value = c.substringUntil((charCode) => charCode === quote)\n c.readChar(quote)\n return decodeEntities(value)\n}\n\n/**\n * Reads until the end of the tag >\n * @private\n */\nexport function untilTagClose(c: StringReader): void {\n while (true) {\n c.until((c) => c === APOS || c === QUOT || c === GT)\n const char = c.next()\n if (QUOTES.has(char)) {\n c.untilChar(char)\n c.next()\n } else {\n // >\n break\n }\n }\n}\n\n/**\n * Returns true if the char code is a valid xml name character.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-NameChar\n * @param charCode\n * @private\n */\nexport function isNameChar(charCode: number): boolean {\n if (charCode >= 0x61 /* a */) {\n if (charCode >= 0xb7 /* \u00B7 */) {\n if (charCode >= 0x300) {\n if (charCode >= 0x203f) {\n return charCode <= 0x2040\n } else {\n return charCode <= 0x36f\n }\n } else {\n return charCode === 0xb7 /* \u00B7 */\n }\n } else {\n return charCode <= 0x7a /* z */\n }\n } else {\n if (charCode >= 0x5f /* _ */) {\n return charCode === 0x5f\n } else {\n if (charCode >= 0x41 /* A */) {\n return charCode <= 0x5a /* Z */\n } else {\n if (charCode >= 0x2d /* - */) {\n if (charCode >= 0x30 /* 0 */) {\n return charCode <= 0x39 /* 9 */\n } else {\n return charCode <= 0x2e /* . */\n }\n } else {\n return false\n }\n }\n }\n }\n}\n\n/**\n * Reads an xml {@link QName}.\n * The {@link QName.namespaceUri} returned will be null; it must be separately looked up.\n *\n * @param reader The current string reader.\n * @private\n */\nexport function readQName(reader: StringReader): MutableDeep<QName> {\n const prefixOrLocalName = reader.substringWhile(isNameChar)\n let prefix: string | null, localPart: string, name: string\n if (reader.charIf(COLON)) {\n prefix = prefixOrLocalName\n localPart = reader.substringWhile(isNameChar)\n name = `${prefix}:${localPart}`\n } else {\n prefix = null\n localPart = prefixOrLocalName\n name = localPart\n }\n return { prefix, localPart, qName: name, namespaceUri: null }\n}\n\n/**\n * Reads a series of xml attributes, separated by whitespace.\n * Example: `ns1:key1=\"value1\" key2 key3='value3'`\n * Note: consumes all whitespace before and after attributes series.\n *\n * @return Returns a map of attribute `qName:string` to `Attribute` objects.\n *\n * @private\n */\nexport function xmlAttributes(\n reader: StringReader,\n stackElement: StackElement\n): MutableDeep<Attributes> {\n const attributes: MutableDeep<Attributes> = {}\n while (true) {\n reader.white()\n if (!isNameChar(reader.peek)) break\n const name = readQName(reader)\n reader.white()\n let value = ''\n if (reader.charIf(EQ)) {\n reader.white()\n value = readAttributeValue(reader)\n } else {\n // Attributes without values are valid in html, but not xml\n }\n\n if (name.prefix === 'xmlns') {\n name.namespaceUri = XMLNS\n stackElement.namespaceMap.set(\n name.localPart,\n value === '' ? null : value\n )\n } else if (!name.prefix && name.localPart === 'xmlns') {\n name.namespaceUri = XMLNS\n stackElement.defaultNamespaceUri = !value ? null : value\n }\n if (attributes[name.qName] != null)\n reader.err(`Attribute '${name.qName}' is already specified.`)\n attributes[name.qName] = { name, value }\n }\n return attributes\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n clone,\n type Cloneable,\n decodeEntities,\n IllegalStateError,\n last,\n substitute,\n toJson,\n} from '@amazon/vinyl-util'\n\nimport type { XmlRules } from './xmlRules'\nimport type { MappedXmlRules } from './mappedXmlRules'\nimport { EmptyRules, mapXmlRules, xmlRuleKey } from './mappedXmlRules'\nimport type { Attributes, ParseXmlHandler } from './ParseXmlHandler'\nimport type { QName } from './QName'\nimport { XmlSchemaError, xmlSchemaErrorLocale } from './XmlSchemaError'\n\ninterface StackElement {\n /**\n * The current object being built.\n */\n readonly element: any\n\n /**\n * The current element's text content. This will be appended to on every {@link characters}\n * callback.\n */\n characters: string\n\n /**\n * The current element rules.\n */\n readonly rules: MappedXmlRules<any>\n}\n\n/**\n * Choose the rule using namespaces first, if there is no match, query the wildcard namespace rules.\n */\nfunction getRule<T>(\n name: QName,\n rules: ReadonlyMap<string, T | undefined>\n): T | undefined {\n return rules.get(xmlRuleKey(name.localPart, name.namespaceUri))\n}\n\nexport interface ParseXmlHandlerOptions {\n readonly validateRules: boolean\n}\n\n/**\n * A {@link ParseXmlHandler} implementation that follows {@link XmlRules}, building an object of\n * the parameterized type.\n */\nexport class ParseXmlHandlerImpl<T> implements ParseXmlHandler<T> {\n private stack: StackElement[] = []\n\n private options: ParseXmlHandlerOptions\n private busy = false\n\n constructor(\n private readonly rules: MappedXmlRules<T>,\n options?: Partial<ParseXmlHandlerOptions>\n ) {\n this.options = { validateRules: true, ...options }\n }\n\n startDocument(): void {\n if (this.busy)\n throw new IllegalStateError('XML content handler is busy')\n this.busy = true\n const rules = this.rules\n this.stack.push({\n element: new XmlElementImpl(),\n rules,\n characters: '',\n })\n }\n\n startElement(name: QName, attributes: Attributes): void {\n const parent = last(this.stack)!\n let element: any = null\n const elementRule = getRule(name, parent.rules.elements)\n const rules = elementRule?.rules() ?? EmptyRules\n if (elementRule) {\n const prop = elementRule.property\n element = new XmlElementImpl(parent.element)\n if (elementRule.array) {\n const arr = parent.element[prop]\n if (Array.isArray(arr)) {\n arr.push(element)\n } else {\n parent.element[prop] = [element]\n }\n } else {\n if (parent.element[prop]) {\n throw new XmlSchemaError(\n `Expected single element with name ${name.qName}`\n )\n } else {\n parent.element[prop] = element\n }\n }\n\n const attributeRules = rules.attributes\n for (const k in attributes) {\n const attribute = attributes[k]!\n const name = attribute.name\n const attributeRule = getRule(name, attributeRules)\n if (attributeRule) {\n element[attributeRule.property] = attributeRule.parse(\n attribute.value\n )\n }\n }\n\n // Set attribute defaults:\n attributeRules.forEach((_value, key) => {\n const rule = attributeRules.get(key)!\n if (!(rule.property in element)) {\n if (rule.default != null) {\n element[rule.property] = rule.default\n } else if (this.options.validateRules && rule.required) {\n throw new XmlSchemaError(\n substitute(xmlSchemaErrorLocale.requiredAttribute, {\n property: rule.property,\n })\n )\n }\n }\n })\n }\n this.stack.push({\n element,\n rules,\n characters: '',\n })\n }\n\n textNode(str: string): void {\n const current = last(this.stack)!\n if (!current.rules.characters) return\n current.characters += decodeEntities(str.trim())\n }\n\n cDataNode(str: string): void {\n const current = last(this.stack)!\n if (!current.rules.characters) return\n current.characters += str\n }\n\n endElement(): void {\n const lastEl = this.stack.pop()!\n const charactersRule = lastEl.rules.characters\n if (charactersRule)\n lastEl.element[charactersRule.property] = charactersRule.parse(\n lastEl.characters\n )\n lastEl.rules.elements.forEach((rule) => {\n if (rule.array && !(rule.property in lastEl.element)) {\n if (rule.useEmptyArrays) {\n lastEl.element[rule.property] = []\n }\n }\n })\n this.validate(lastEl)\n }\n\n endDocument(): T & XmlElement<T> {\n this.busy = false\n const last = this.stack.pop()!\n this.validate(last)\n return last.element\n }\n\n private validate(current: StackElement) {\n if (!this.options.validateRules) return\n current.rules.elements.forEach((rule) => {\n const length = rule.array\n ? (current.element[rule.property]?.length ?? 0)\n : current.element[rule.property]\n ? 1\n : 0\n if (length < rule.minOccurs) {\n throw new XmlSchemaError(\n substitute(xmlSchemaErrorLocale.atLeastElements, {\n property: rule.property,\n expected: rule.minOccurs,\n actual: length,\n })\n )\n }\n if (rule.maxOccurs != null && length > rule.maxOccurs) {\n throw new XmlSchemaError(\n substitute(xmlSchemaErrorLocale.atMostElements, {\n property: rule.property,\n expected: rule.maxOccurs,\n actual: length,\n })\n )\n }\n })\n }\n}\n\n/**\n * Creates an XML content handler for the given parsing rules.\n *\n * @param rules\n * @param options\n */\nexport function parseXmlHandler<T extends object>(\n rules: XmlRules<T>,\n options?: Partial<ParseXmlHandlerOptions>\n): ParseXmlHandlerImpl<T> {\n return new ParseXmlHandlerImpl<T>(mapXmlRules(rules), options)\n}\n\n// Use a symbol to prevent parent from inclusion in property enumeration.\nconst parentSymbol = /* @__PURE__ */ Symbol('parent')\n\nexport interface XmlElement<T = any> extends Cloneable<T & XmlElement<T>> {\n get parent(): XmlElement | null\n toJSON(): any\n}\n\nexport class XmlElementImpl<T> implements XmlElement<T> {\n [prop: keyof any]: any\n\n private [parentSymbol]: XmlElement | null\n\n constructor(parent: XmlElement | null = null) {\n this[parentSymbol] = parent\n }\n\n get parent(): XmlElement | null {\n return this[parentSymbol]\n }\n\n set parent(value: XmlElement | null) {\n this[parentSymbol] = value\n }\n\n clone(): T & XmlElementImpl<T> {\n const out: any = new XmlElementImpl(this.parent)\n for (const key in this) {\n // Clone all children, setting their parent references to the new cloned parent.\n const child: any = clone(this[key])\n if (Array.isArray(child)) {\n for (const e of child) {\n if (typeof e === 'object' && 'parent' in e) e.parent = out\n }\n } else if (typeof child === 'object' && 'parent' in child) {\n child.parent = out\n }\n out[key] = child\n }\n return out\n }\n\n toJSON(): any {\n const out: any = {}\n for (const key in this) {\n out[key] = toJson(this[key])\n }\n return out\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ErrorOrigin, ReportableError } from '@amazon/vinyl-util'\n\n/**\n * @private\n */\nexport const xmlSchemaErrorLocale = {\n atLeastElements:\n 'Expected at least {expected} occurrences of {property} but was {actual}',\n atMostElements:\n 'Expected at most {expected} occurrences of {property} but was {actual}',\n cyclicReferences: 'Cyclic reference detected',\n requiredAttribute: `Attribute '{property}' is required`,\n} as const\n\nexport class XmlSchemaError extends ReportableError {\n get [Symbol.toStringTag](): string {\n return 'XmlSchemaError'\n }\n\n constructor(message: string) {\n super(message, ErrorOrigin.PARSING)\n Object.setPrototypeOf(this, XmlSchemaError.prototype)\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Uri } from '../xmlns/org/w3/2001/XmlSchema'\n\n/**\n * An XML name for an element or attribute.\n */\nexport interface QName {\n /**\n * The fully qualified name.\n * This will be the prefixed name or the unprefixed name if the prefix is empty.\n * The prefixed name will be `prefix ':' localPart`\n */\n readonly qName: string\n\n /**\n * The xmlns prefix.\n */\n readonly prefix: string | null\n\n /**\n * The local part of this name.\n */\n readonly localPart: string\n\n /**\n * The resolved xmlns uri for the associated prefix.\n */\n readonly namespaceUri: Uri | null\n}\n\n/**\n * Creates a new {@link QName} object.\n *\n * @param localPart\n * @param prefix\n * @param namespaceUri\n */\nexport function qName(\n localPart: string,\n prefix: string | null = null,\n namespaceUri: Uri | null = null\n): QName {\n return {\n localPart,\n prefix,\n namespaceUri,\n qName: prefix ? `${prefix}:${localPart}` : localPart,\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n encodeEntities,\n equalDeep,\n getOrSet,\n type OptionalDeep,\n substitute,\n} from '@amazon/vinyl-util'\n\nimport type { Uri } from '../xmlns/org/w3/2001/XmlSchema'\nimport type {\n MappedAttributeRule,\n MappedCharactersRule,\n MappedElementsRule,\n MappedXmlRules,\n} from './mappedXmlRules'\nimport { XmlSchemaError, xmlSchemaErrorLocale } from './XmlSchemaError'\nimport type { ReservedXmlRuleKeys } from './xmlRules'\n\n/**\n * @private\n */\nconst locale = {\n /**\n * When a namespace binding is generated, if the prefix was not provided in the stringifier\n * options, it will be generated from this template.\n */\n prefixTemplate: 'ns_{value}',\n} as const\n\nexport interface StringifyOptions {\n /**\n * The indentation. Default: 4 spaces\n */\n readonly indent: string\n\n /**\n * The character(s) between lines. Default: \\n\n */\n readonly newline: string\n\n /**\n * A map of namespace uri to prefix strings.\n * If a namespace is not found, a prefix will be generated.\n */\n readonly prefixMap: ReadonlyMap<Uri, string>\n\n /**\n * If true, will include the XML declaration at the beginning of the stringified document.\n * `<?xml version=\"1.0\"?>`\n */\n readonly includeXmlDeclaration: boolean\n}\n\nconst defaultStringifyOptions: StringifyOptions = {\n indent: ' ',\n newline: '\\n',\n prefixMap: /* @__PURE__ */ new Map(),\n includeXmlDeclaration: true,\n}\n\nexport class XmlWriter<T> {\n private readonly options: StringifyOptions\n private readonly usedPrefixes = /* @__PURE__ */ new Map<Uri, string>()\n private readonly traversed = /* @__PURE__ */ new Set()\n\n constructor(\n private readonly rules: MappedXmlRules<T>,\n options?: Partial<StringifyOptions>\n ) {\n this.options = {\n ...defaultStringifyOptions,\n ...options,\n }\n }\n\n stringify(object: OptionalDeep<T, ReservedXmlRuleKeys>): string {\n let str = this.options.includeXmlDeclaration\n ? '<?xml version=\"1.0\"?>' + this.options.newline\n : ''\n const state = new StringifyState()\n str += this.stringifyChildren(object, this.rules.elements, state)\n this.usedPrefixes.clear()\n this.traversed.clear()\n\n return str\n }\n\n private qName(localPart: string, namespaceUri: Uri | null): string {\n if (!namespaceUri) return localPart\n const prefixMap = this.options.prefixMap\n const prefix = getOrSet(this.usedPrefixes, namespaceUri, () => {\n if (prefixMap.has(namespaceUri)) {\n return prefixMap.get(namespaceUri)!\n }\n return substitute(locale.prefixTemplate, {\n value: (this.usedPrefixes.size + 1).toString(36),\n })\n })\n return `${prefix}:${localPart}`\n }\n\n /**\n * Stringifies an element.\n *\n * @param object\n * @param rule\n * @param state\n */\n private stringifyElement(\n object: any,\n rule: MappedElementsRule,\n state: StringifyState\n ): string {\n if (this.traversed.has(object))\n throw new XmlSchemaError(xmlSchemaErrorLocale.cyclicReferences)\n this.traversed.add(object)\n const nl = this.options.newline\n const isDocument = state.depth === 0\n let namespaces = ''\n\n let xmlns = state.xmlns\n if (\n xmlns !== rule.namespaceUri &&\n (xmlns == null || !rule.namespaceUri)\n ) {\n // The element's namespace is different from the parent.\n // Change the default namespace if moving to or from a null namespace.\n xmlns = rule.namespaceUri\n namespaces += ` xmlns=\"${rule.namespaceUri ?? ''}\"`\n }\n\n const childState = state.createChild(xmlns, this.options.indent)\n const rules = rule.rules()\n const attributes = this.stringifyAttributes(object, rules.attributes)\n const children = this.stringifyChildren(\n object,\n rules.elements,\n childState\n )\n const text = this.stringifyCharacters(object, rules.characters)\n\n if (isDocument) {\n this.usedPrefixes.forEach((prefix, uri) => {\n namespaces += ` xmlns:${prefix}=\"${uri}\"`\n })\n }\n\n const indent = state.indent\n const childIndent = childState.indent\n const qName =\n rule.namespaceUri === xmlns\n ? rule.localPart\n : this.qName(rule.localPart, rule.namespaceUri)\n let str = `${indent}<${qName}${namespaces}${attributes}`\n if (children) {\n str += `>`\n if (text) str += `${nl}${childIndent}${text}`\n str += nl + children\n str += `${nl}${indent}</${qName}>`\n } else if (text) {\n str += `>${text}</${qName}>`\n } else {\n str += '/>'\n }\n return str\n }\n\n /**\n * Stringifies an element's attributes.\n *\n * @param object\n * @param attributes\n * @return Returns the attributes string. This will include a leading space if there are any\n * found attributes.\n */\n private stringifyAttributes(\n object: any,\n attributes: ReadonlyMap<string, MappedAttributeRule>\n ): string {\n let str = ''\n attributes.forEach((attributeRule) => {\n const propertyValue = object[attributeRule.property]\n if (propertyValue !== undefined) {\n const attributeValue = attributeRule.stringify(propertyValue)\n if (\n attributeRule.default === undefined ||\n !equalDeep(propertyValue, attributeRule.default)\n ) {\n str += ` ${this.qName(\n attributeRule.localPart,\n attributeRule.namespaceUri\n )}=\"${encodeEntities(attributeValue)}\"`\n }\n } else {\n if (attributeRule.required) {\n throw new XmlSchemaError(\n substitute(xmlSchemaErrorLocale.requiredAttribute, {\n property: attributeRule.property,\n })\n )\n }\n }\n })\n return str\n }\n\n /**\n * Stringifies a property as a CDATA node.\n *\n * @param object\n * @param charactersRule\n */\n private stringifyCharacters(\n object: any,\n charactersRule: MappedCharactersRule | undefined\n ): string | null {\n if (!charactersRule) return null\n const str = charactersRule.stringify(object[charactersRule.property])\n if (!str) return ''\n return `<![CDATA[${str}]]>`\n }\n\n /**\n * Stringifies an element's child elements.\n *\n * @param object\n * @param elements\n * @param state\n */\n private stringifyChildren(\n object: any,\n elements: ReadonlyMap<string, MappedElementsRule>,\n state: StringifyState\n ): string {\n let str = ''\n elements.forEach((elementsRule) => {\n const child: any = object[elementsRule.property]\n if (child) {\n if (elementsRule.array) {\n const arr: any[] = child\n if (elementsRule.minOccurs > arr.length) {\n throw new XmlSchemaError(\n substitute(xmlSchemaErrorLocale.atLeastElements, {\n property: elementsRule.property,\n expected: elementsRule.minOccurs,\n actual: arr.length,\n })\n )\n }\n if (\n elementsRule.maxOccurs != null &&\n elementsRule.maxOccurs < arr.length\n ) {\n throw new XmlSchemaError(\n substitute(xmlSchemaErrorLocale.atMostElements, {\n property: elementsRule.property,\n expected: elementsRule.maxOccurs,\n actual: arr.length,\n })\n )\n }\n for (const element of arr) {\n if (str) str += this.options.newline\n str += this.stringifyElement(\n element,\n elementsRule,\n state\n )\n }\n } else {\n if (str) str += this.options.newline\n str += this.stringifyElement(child, elementsRule, state)\n }\n } else {\n if (elementsRule.minOccurs > 0) {\n throw new XmlSchemaError(\n substitute(xmlSchemaErrorLocale.atLeastElements, {\n property: elementsRule.property,\n expected: elementsRule.minOccurs,\n actual: 0,\n })\n )\n }\n }\n })\n return str\n }\n}\n\nclass StringifyState {\n constructor(\n readonly depth: number = 0,\n readonly xmlns: Uri | null = null,\n readonly indent: string = ''\n ) {}\n\n createChild(xmlns: Uri | null, indent: string): StringifyState {\n return new StringifyState(this.depth + 1, xmlns, this.indent + indent)\n }\n}\n\nexport function stringifyXml<T>(\n object: OptionalDeep<T, ReservedXmlRuleKeys>,\n rules: MappedXmlRules<T>,\n options?: Partial<StringifyOptions>\n): string {\n const writer = new XmlWriter(rules, options)\n return writer.stringify(object)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,eAA+B;AAExC,SAAS,mBAAmB;AAE5B,IAAM,mBAA2D,wBAAQ,UAAU,WAAW;AAEvF,SAAS,kBAAkB,KAA0B;AACxD,mBAAiB,OAAO,KAAK,YAAY,OAAO;AAChD,SAAO;AACX;;;ACTA;AAAA,EAEI;AAAA,EACA;AAAA,EAEA;AAAA,OACG;;;ACCP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIG;AAIA,IAAK,cAAL,kBAAKA,iBAAL;AACH,EAAAA,aAAA,gBAAa;AACb,EAAAA,aAAA,eAAY;AACZ,EAAAA,aAAA,aAAU;AACV,EAAAA,aAAA,cAAW;AAJH,SAAAA;AAAA,GAAA;AAuML,SAAS,QACZ,OACA,SAC0B;AAC1B,SAAO;AAAA,IACH,MAAM;AAAA,IACN,WAAW;AAAA,IACX,cAAc;AAAA,IACd,UAAU;AAAA,KACP,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B,gBAAM,IAAI;AAAA,YACNJ,YAAW,qBAAqB,iBAAiB;AAAA,cAC7C,UAAU,aAAa;AAAA,cACvB,UAAU,aAAa;AAAA,cACvB,QAAQ;AAAA,YACZ,CAAC;AAAA,UACL;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ,CAAC;AACD,WAAO;AAAA,EACX;AACJ;AAEA,IAAM,iBAAN,MAAM,gBAAe;AAAA,EACjB,YACa,QAAgB,GAChB,QAAoB,MACpB,SAAiB,IAC5B;AAHW;AACA;AACA;AAAA,EACV;AAAA,EAEH,YAAY,OAAmB,QAAgC;AAC3D,WAAO,IAAI,gBAAe,KAAK,QAAQ,GAAG,OAAO,KAAK,SAAS,MAAM;AAAA,EACzE;AACJ;AAEO,SAAS,aACZ,QACA,OACA,SACM;AACN,QAAM,SAAS,IAAI,UAAU,OAAO,OAAO;AAC3C,SAAO,OAAO,UAAU,MAAM;AAClC;",
4
+ "sourcesContent": ["/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { isOneOf, type Validator } from '@amazon/vinyl-validation'\nimport type { actuateType } from '../xmlns/org/w3/1999/xlink'\nimport { ErrorOrigin } from '@amazon/vinyl-util'\n\nconst actuateValidator: Validator<actuateType> = /* @__PURE__ */ isOneOf('onLoad', 'onRequest')\n\nexport function assertActuateEnum(str: string): actuateType {\n actuateValidator.assert(str, ErrorOrigin.PARSING)\n return str\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n type AnyRecord,\n IllegalArgumentError,\n invariant,\n type Invariant,\n memoize,\n} from '@amazon/vinyl-util'\n\nimport type { XmlRule, XmlRules } from './xmlRules'\nimport { XmlRuleType } from './xmlRules'\nimport type { Uri } from '../xmlns/org/w3/2001/XmlSchema'\n\n/**\n * A machine-readable representation of parse rules for random access based on qualified namespace\n * keys.\n *\n * Rule keys will either be `namespaceUri:localPart` or just `localPart` for wildcard rules if\n * namespaceUri is not defined in the handler.\n */\nexport interface MappedXmlRules<T> {\n /**\n * Enforces that this rule set can only be used to parse the expected type T.\n */\n readonly __type: Invariant<T>\n readonly attributes: ReadonlyMap<string, MappedAttributeRule>\n readonly elements: ReadonlyMap<string, MappedElementsRule>\n readonly characters: MappedCharactersRule | undefined\n}\n\nexport interface MappedAttributeRule {\n /**\n * The property name.\n */\n readonly property: keyof any\n\n /**\n * If true, a parsing error will be thrown if the value is undefined.\n */\n readonly required: boolean\n\n /**\n * If the current element has no matching attribute, default will be used.\n */\n readonly default: any\n\n /**\n * Parses the attribute value.\n */\n readonly parse: (value: string) => any\n\n /**\n * Converts the attribute value to a string.\n */\n readonly stringify: (value: any) => string\n\n /**\n * The local part of the QName.\n */\n readonly localPart: string\n\n /**\n * The namespace uri that must match.\n */\n readonly namespaceUri: Uri | null\n}\n\nexport interface MappedElementsRule {\n /**\n * The name of the property to set on the parent element.\n */\n readonly property: keyof any\n\n /**\n * True if the parsed elements should populate into an array.\n */\n readonly array: boolean\n\n /**\n * The minimum number of elements.\n */\n readonly minOccurs: number\n\n /**\n * The maximum number of elements. Use null for unbounded.\n */\n readonly maxOccurs: number | null\n\n /**\n * If true and there are 0 occurrences of the element, the parsed value will be an empty array\n * instead of undefined.\n */\n readonly useEmptyArrays: boolean\n\n /**\n * Returns the mappings for matched element(s).\n */\n readonly rules: () => MappedXmlRules<any>\n\n /**\n * The local part of the QName.\n */\n readonly localPart: string\n\n /**\n * The namespace uri that must match.\n */\n readonly namespaceUri: Uri | null\n}\n\nexport interface MappedCharactersRule {\n readonly property: keyof any\n\n /**\n * Parses the unescaped/processed characters.\n * This will always be called, but characters may be an empty string if the element has no\n * text content.\n */\n readonly parse: (characters: string) => any\n\n /**\n * Converts the value to a string.\n */\n readonly stringify: (value: any) => string\n}\n\n/**\n * An empty rules map, used when there was no match for the started element.\n * @private\n */\nexport const EmptyRules: MappedXmlRules<AnyRecord> = {\n __type: /* @__PURE__ */ invariant(),\n attributes: /* @__PURE__ */ new Map(),\n elements: /* @__PURE__ */ new Map(),\n characters: undefined,\n} as const\n\n/**\n * Creates machine-friendly content handler rules from the given {@link XmlRules}.\n *\n * @param rules The {@link XmlRules} to convert.\n * @param parentNamespaceUri\n */\nexport function mapXmlRules<T extends object>(\n rules: XmlRules<T>,\n parentNamespaceUri: Uri | null = null\n): MappedXmlRules<T> {\n const attributeRules = new Map<string, MappedAttributeRule>()\n const elementRules = new Map<string, MappedElementsRule>()\n let charactersRule: MappedCharactersRule | undefined = undefined\n\n for (const property in rules) {\n const handlerOrFunction = rules[property as keyof typeof rules]\n let handler: XmlRule<any>\n if (typeof handlerOrFunction === 'function') {\n handler = handlerOrFunction()\n } else {\n handler = handlerOrFunction\n }\n let key: string\n switch (handler.type) {\n case XmlRuleType.CHARACTERS:\n if (charactersRule !== undefined)\n throw new IllegalArgumentError(\n 'characters handler already defined'\n )\n charactersRule = {\n property,\n parse: handler.parse,\n stringify: handler.stringify,\n }\n break\n case XmlRuleType.ELEMENT:\n case XmlRuleType.ELEMENTS: {\n const localPart = handler.localPart ?? property\n const namespaceUri: Uri | null =\n handler.namespaceUri === undefined\n ? parentNamespaceUri\n : handler.namespaceUri\n key = xmlRuleKey(localPart, namespaceUri)\n if (elementRules.has(key)) {\n throw new IllegalArgumentError(\n `Multiple element rules for ${key}`\n )\n }\n if (handler.type === XmlRuleType.ELEMENT) {\n const rules = handler.rules\n elementRules.set(key, {\n array: false,\n property,\n minOccurs: handler.required ? 1 : 0,\n maxOccurs: 1,\n rules: memoize(() => mapXmlRules(rules, namespaceUri)),\n useEmptyArrays: false,\n localPart,\n namespaceUri,\n })\n } else {\n const rules = handler.rules\n elementRules.set(key, {\n array: true,\n property,\n maxOccurs: handler.maxOccurs,\n minOccurs: handler.minOccurs,\n rules: memoize(() => mapXmlRules(rules, namespaceUri)),\n useEmptyArrays: handler.useEmptyArrays,\n localPart,\n namespaceUri,\n })\n }\n break\n }\n case XmlRuleType.ATTRIBUTE: {\n // Attributes should not inherit the namespace of the parent element.\n const namespaceUri = handler.namespaceUri\n const localPart = handler.localPart ?? property\n key = xmlRuleKey(localPart, namespaceUri)\n if (attributeRules.has(key)) {\n throw new IllegalArgumentError(\n `Multiple attribute rules for ${key}`\n )\n }\n attributeRules.set(key, {\n property,\n default: handler.default,\n parse: handler.parse,\n stringify: handler.stringify,\n required: handler.required,\n localPart,\n namespaceUri: handler.namespaceUri ?? null,\n })\n break\n }\n }\n }\n return {\n __type: invariant(),\n attributes: attributeRules,\n elements: elementRules,\n characters: charactersRule,\n }\n}\n\n/**\n * Creates a rule key for mapped xml rules.\n *\n * @private\n * @param localPart The {@link QName.localPart}\n * @param namespaceUri The `namespaceUri` of the element.\n */\nexport function xmlRuleKey(\n localPart: string,\n namespaceUri: Uri | null = null\n): string {\n return `${namespaceUri ?? ''}:${localPart}`\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * A set of utilities for easily writing schema-based rule definitions to be used with the\n * `parseXml` parser.\n *\n * @module\n */\n\nimport {\n parseDate,\n stringifyDate,\n parseBoolean,\n stringify,\n type Invariant,\n type Maybe,\n type ReadonlyDate,\n} from '@amazon/vinyl-util'\n\nimport type { Uri } from '../xmlns/org/w3/2001/XmlSchema'\n\nexport enum XmlRuleType {\n CHARACTERS = 'characters',\n ATTRIBUTE = 'attribute',\n ELEMENT = 'element',\n ELEMENTS = 'elements',\n}\n\n/**\n * Reserved keys that may not be used in XmlRules.\n *\n * If a schema uses a reserved word, set `localPart` in the rule options to associate.\n */\nexport type ReservedXmlRuleKeys = 'parent' | 'clone' | 'toJSON'\n\n/**\n * A schema for XML serialization and deserialization.\n *\n * The parser values may be lazy, represented as a function that returns a property parser.\n * @typeParam T The object type these parsing rules model.\n */\nexport type XmlRules<T extends object> = {\n readonly [P in Exclude<keyof T, ReservedXmlRuleKeys>]-?:\n XmlRule<T[P]> | LazyXmlRule<T[P]>\n}\n\n/**\n * A union of the supported parsing types.\n */\nexport type XmlRule<T> =\n | AttributeRule<T>\n | CharactersRule<T>\n | ElementsRule<T & (readonly object[] | undefined)>\n | ElementRule<T & (object | undefined)>\n\n/**\n * A function that returns a property handler.\n * Useful when there are recursive rules.\n */\nexport type LazyXmlRule<T> = () => XmlRule<T>\n\nexport interface NamespacedRuleOptions {\n /**\n * Matches the `QName.localPart` of the element. If undefined, this will match against\n * the property name from {@link XmlRules}.\n */\n readonly localPart?: string | undefined\n\n /**\n * Matches the `namespaceUri` of the element or attribute.\n *\n * If null, this will only match against a null namespace.\n * If undefined, this will default to the namespace of the parent element for elements, or\n * null for attributes.\n *\n * Note that attributes do not inherit default namespaces as elements do.\n */\n readonly namespaceUri?: Maybe<Uri>\n}\n\n/**\n * A rule definition for a list of elements.\n */\nexport interface ElementsRule<\n T extends readonly object[] | undefined,\n> extends Required<ElementsRuleOptions> {\n readonly type: XmlRuleType.ELEMENTS\n\n /**\n * Prevents rule from losing nullable type information.\n */\n readonly __invariant?: Invariant<T>\n\n /**\n * Returns the schema for matched elements.\n * These rules will be applied per element, collecting into an array.\n */\n readonly rules: XmlRules<NonNullable<T>[number]>\n}\n\nexport interface ElementsRuleOptions extends NamespacedRuleOptions {\n /**\n * The minimum number of elements.\n */\n readonly minOccurs?: number\n\n /**\n * The maximum number of elements. Use null for unbounded.\n */\n readonly maxOccurs?: number | null\n\n /**\n * If true and there are 0 occurrences of the element, the parsed value will be an empty array\n * instead of undefined.\n */\n readonly useEmptyArrays?: boolean\n}\n\n/**\n * A rule definition for a single element.\n */\nexport interface ElementRule<\n T extends object | undefined,\n> extends Required<ElementRuleOptions> {\n /**\n * Prevents rule from losing nullable type information.\n */\n readonly __invariant?: Invariant<T>\n\n readonly type: XmlRuleType.ELEMENT\n\n /**\n * Returns the schema for the matched element.\n */\n readonly rules: XmlRules<NonNullable<T>>\n}\n\nexport interface ElementRuleOptions extends NamespacedRuleOptions {\n /**\n * If true, a parsing error will be thrown if the value is undefined.\n */\n readonly required?: boolean\n}\n\n/**\n * A rule definition for an attribute.\n */\nexport interface AttributeRule<T> extends Required<AttributeRuleOptions<T>> {\n readonly type: XmlRuleType.ATTRIBUTE\n\n /**\n * Parses the attribute value.\n */\n readonly parse: (value: string) => T\n\n /**\n * Stringifies the value.\n */\n readonly stringify: (value: NonNullable<T>) => string\n}\n\nexport interface AttributeRuleOptions<T> extends NamespacedRuleOptions {\n /**\n * If true, a parsing error will be thrown if the value is undefined.\n */\n readonly required?: boolean\n\n /**\n * If the current element has no matching attribute, default will be used.\n */\n readonly default?: T | undefined\n\n /**\n * Matches the `namespaceUri` of the attribute.\n *\n * If null, this will only match against a null namespace.\n *\n * Note that attributes do not inherit default namespaces as elements do.\n */\n readonly namespaceUri?: Uri | null\n}\n\n/**\n * A rule definition for an element's text content.\n */\nexport interface CharactersRule<T> {\n readonly type: XmlRuleType.CHARACTERS\n\n /**\n * Parses the unescaped/processed characters.\n * This will always be called, but characters may be an empty string if the element has no\n * text content.\n */\n readonly parse: (characters: string) => T\n\n /**\n * Stringifies the value.\n */\n readonly stringify: (value: NonNullable<T>) => string\n}\n\nexport interface RequiredElementRuleOptions extends ElementRuleOptions {\n readonly required: true\n}\n\nexport function element<T extends object>(\n rules: XmlRules<T>,\n options: RequiredElementRuleOptions\n): ElementRule<T>\n\nexport function element<T extends object | undefined>(\n rules: XmlRules<NonNullable<T>>,\n options?: ElementRuleOptions\n): ElementRule<T | undefined>\n\n/**\n * Returns a schema for a single object based on a map of rules.\n *\n * If more than one element is found with a matching name, a `ParseError` is thrown.\n */\nexport function element<T extends object | undefined>(\n rules: XmlRules<NonNullable<T>>,\n options?: ElementRuleOptions\n): ElementRule<T | undefined> {\n return {\n type: XmlRuleType.ELEMENT,\n localPart: undefined,\n namespaceUri: undefined,\n required: false,\n ...options,\n rules,\n }\n}\n\n/**\n * Elements options that guarantee that there is a non-null array.\n * For minOccurs types greater than 10, a type cast is required.\n */\nexport type RequiredElementsOptions =\n | (ElementsRuleOptions & { readonly useEmptyArrays: true })\n | (ElementsRuleOptions & {\n readonly minOccurs: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10\n })\n\nexport function elements<T extends object>(\n rules: XmlRules<T>,\n options: RequiredElementsOptions\n): ElementsRule<readonly T[]>\n\nexport function elements<T extends object>(\n rules: XmlRules<T>,\n options?: ElementsRuleOptions\n): ElementsRule<readonly T[] | undefined>\n\n/**\n * Handles a list of child nodes where each matching child node is parsed into a corresponding\n * object represented by the given rules.\n *\n * @param rules The parsing rules to use for each element.\n * @param options\n * @see parseChildNodes\n */\nexport function elements<T extends object>(\n rules: XmlRules<T>,\n options?: ElementsRuleOptions\n): ElementsRule<readonly T[] | undefined> | ElementsRule<readonly T[]> {\n return {\n type: XmlRuleType.ELEMENTS,\n localPart: undefined,\n namespaceUri: undefined,\n minOccurs: 0,\n maxOccurs: null,\n useEmptyArrays: false,\n ...options,\n rules,\n }\n}\n\n/**\n * Parses the text content of the current element via the given parse and stringify functions.\n *\n * Does not currently support mixing text and element nodes.\n * E.g. the XML `<note>Dear <name>John</name>, I regret to inform you...</note>` could not be\n * serialized or deserialized using xml rule mappings.\n *\n * @param parse The string passed to this parser is the processed text content of the current\n * element.\n * @param stringify Serializes the value.\n *\n * @see processCharacters\n */\nexport function characters<T>(\n parse: (str: string) => T,\n stringify: (value: T) => string\n): CharactersRule<T> {\n return { type: XmlRuleType.CHARACTERS, parse, stringify }\n}\n\n/**\n * Handles the processed text content without any modification.\n *\n * @see characters\n */\nexport const charactersString = /* @__PURE__ */ characters((i) => i, stringify)\n\nexport type RequiredAttributeOptions<T> = AttributeRuleOptions<T> &\n ({ required: true } | { default: T })\n\nexport function attr<T>(\n parse: (value: string) => T,\n stringify: (value: T) => string,\n options: RequiredAttributeOptions<T>\n): AttributeRule<T>\n\nexport function attr<T>(\n parse: (value: string) => T,\n stringify: (value: NonNullable<T>) => string,\n options?: AttributeRuleOptions<T>\n): AttributeRule<T | undefined>\n\n/**\n * Handles an attribute using the given parse and stringify functions.\n *\n * @param parse\n * @param stringify\n * @param options\n */\nexport function attr<T>(\n parse: (value: string) => T,\n stringify: (value: T) => string,\n options?: AttributeRuleOptions<T>\n): AttributeRule<T> | AttributeRule<T | undefined> {\n return {\n type: XmlRuleType.ATTRIBUTE,\n localPart: undefined,\n namespaceUri: null,\n required: false,\n default: undefined,\n ...options,\n parse,\n stringify,\n }\n}\n\nexport function attrString(\n options: RequiredAttributeOptions<string>\n): AttributeRule<string>\n\nexport function attrString(\n options?: AttributeRuleOptions<string>\n): AttributeRule<string | undefined>\n\n/**\n * Keeps an attribute's string value as is.\n *\n * @param options\n */\nexport function attrString(\n options?: AttributeRuleOptions<string>\n): AttributeRule<string> | AttributeRule<string | undefined> {\n return attr((i) => i, stringify, options)\n}\n\nexport function attrInt(\n options: RequiredAttributeOptions<number>\n): AttributeRule<number>\n\nexport function attrInt(\n options?: AttributeRuleOptions<number>\n): AttributeRule<number | undefined>\n\n/**\n * Parses an attribute's value using `parseInt`\n *\n * @param options\n */\nexport function attrInt(\n options?: AttributeRuleOptions<number>\n): AttributeRule<number> | AttributeRule<number | undefined> {\n return attr(parseInt, stringify, options)\n}\n\nexport function attrFloat(\n options: RequiredAttributeOptions<number>\n): AttributeRule<number>\n\nexport function attrFloat(\n options?: AttributeRuleOptions<number>\n): AttributeRule<number | undefined>\n\n/**\n * Parses an attribute using `parseFloat`\n *\n * @param options\n */\nexport function attrFloat(\n options?: AttributeRuleOptions<number>\n): AttributeRule<number> | AttributeRule<number | undefined> {\n return attr(parseFloat, stringify, options)\n}\n\nexport function attrBoolean(\n options: RequiredAttributeOptions<boolean>\n): AttributeRule<boolean>\n\nexport function attrBoolean(\n options?: AttributeRuleOptions<boolean>\n): AttributeRule<boolean | undefined>\n\n/**\n * Parses an attribute's value `\"true\"` or `\"1\"` as `true`.\n *\n * @param options\n */\nexport function attrBoolean(\n options?: AttributeRuleOptions<boolean>\n): AttributeRule<boolean> | AttributeRule<boolean | undefined> {\n return attr(parseBoolean, stringify, options)\n}\n\nexport function attrDateTime(\n options: RequiredAttributeOptions<Date>\n): AttributeRule<ReadonlyDate>\n\nexport function attrDateTime(\n options?: AttributeRuleOptions<ReadonlyDate>\n): AttributeRule<ReadonlyDate | undefined>\n\n/**\n * Parses an attribute using `Date.parse`\n *\n * @param options\n */\nexport function attrDateTime(\n options?: AttributeRuleOptions<ReadonlyDate>\n): AttributeRule<ReadonlyDate> | AttributeRule<ReadonlyDate | undefined> {\n return attr(parseDate, stringifyDate, options)\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n type Fun,\n plainObjectMergeRule,\n substitute,\n ValidationError,\n} from '@amazon/vinyl-util'\n\nimport {\n type AttributeRule,\n type ElementRule,\n type ElementsRule,\n type LazyXmlRule,\n type XmlRule,\n type XmlRules,\n XmlRuleType,\n} from './xmlRules'\n\nconst locale = {\n illegalRuleOverrideTypeError:\n 'Cannot override the rule {property} of type {sourceType} with a rule of type {overrideType}',\n illegalQNameOverrideError:\n 'Cannot override the rule {property} with a different localPart or namespace',\n} as const\n\n/**\n * Recursively merges array types so that S[] & T[] becomes (S & T)[]\n * When two array elements parsing rules are merged, the result is an array with intersected\n * element types.\n */\nexport type Merged<T> = T extends readonly any[]\n ? MergedTupleOrArray<T>\n : T extends Fun\n ? T\n : T extends object\n ? {\n [P in keyof T]: Merged<T[P]>\n }\n : T\n\n/**\n * `[S0, T0] & [S1, T1]` cannot be converted to `[S0 & S1, T0 & T1]`, but we can at least preserve\n * the tuple when not intersected.\n *\n * Intersected tuples become arrays. E.g. `[S0, T0] & [S1, T1]` becomes `Array<S0 | S1 | T0 | T1>`\n */\nexport type MergedTupleOrArray<T extends readonly any[]> = T extends [infer V0]\n ? // Support tuples up to 5 in length\n [Merged<V0>]\n : T extends [infer V0, infer V1]\n ? [Merged<V0>, Merged<V1>]\n : T extends [infer V0, infer V1, infer V2]\n ? [Merged<V0>, Merged<V1>, Merged<V2>]\n : T extends [infer V0, infer V1, infer V2, infer V3]\n ? [Merged<V0>, Merged<V1>, Merged<V2>, Merged<V3>]\n : T extends [infer V0, infer V1, infer V2, infer V3, infer V4]\n ? [Merged<V0>, Merged<V1>, Merged<V2>, Merged<V3>, Merged<V4>]\n : T extends any[]\n ? Array<Merged<T[number]>>\n : T extends readonly [infer V0]\n ? readonly [Merged<V0>]\n : T extends readonly [infer V0, infer V1]\n ? readonly [Merged<V0>, Merged<V1>]\n : T extends readonly [infer V0, infer V1, infer V2]\n ? readonly [Merged<V0>, Merged<V1>, Merged<V2>]\n : T extends readonly [\n infer V0,\n infer V1,\n infer V2,\n infer V3,\n ]\n ? readonly [\n Merged<V0>,\n Merged<V1>,\n Merged<V2>,\n Merged<V3>,\n ]\n : T extends readonly [\n infer V0,\n infer V1,\n infer V2,\n infer V3,\n infer V4,\n ]\n ? readonly [\n Merged<V0>,\n Merged<V1>,\n Merged<V2>,\n Merged<V3>,\n Merged<V4>,\n ]\n : ReadonlyArray<Merged<T[number]>>\n\n/**\n * Merges the given two xml rule sets into one.\n */\nexport function mergeXmlRules<A extends object, B extends object>(\n a: XmlRules<A>,\n b: XmlRules<B>\n): XmlRules<Merged<A & B>>\n\n/**\n * Merges the given three xml rule sets into one.\n */\nexport function mergeXmlRules<\n A extends object,\n B extends object,\n C extends object,\n>(a: XmlRules<A>, b: XmlRules<B>, c: XmlRules<C>): XmlRules<Merged<A & B & C>>\n\n/**\n * Merges the given four xml rule sets into one.\n */\nexport function mergeXmlRules<\n A extends object,\n B extends object,\n C extends object,\n D extends object,\n>(\n a: XmlRules<A>,\n b: XmlRules<B>,\n c: XmlRules<C>,\n d: XmlRules<D>\n): XmlRules<Merged<A & B & C & D>>\n\n/**\n * Merges the given five xml rule sets into one.\n */\nexport function mergeXmlRules<\n A extends object,\n B extends object,\n C extends object,\n D extends object,\n E extends object,\n>(\n a: XmlRules<A>,\n b: XmlRules<B>,\n c: XmlRules<C>,\n d: XmlRules<D>,\n e: XmlRules<E>\n): XmlRules<Merged<A & B & C & D & E>>\n\n/**\n * Merges the given six xml rule sets into one.\n */\nexport function mergeXmlRules<\n A extends object,\n B extends object,\n C extends object,\n D extends object,\n E extends object,\n F extends object,\n>(\n a: XmlRules<A>,\n b: XmlRules<B>,\n c: XmlRules<C>,\n d: XmlRules<D>,\n e: XmlRules<E>,\n f: XmlRules<F>\n): XmlRules<Merged<A & B & C & D & E & F>>\n\n/**\n * Merges the given rules into one ruleset.\n *\n * @param rules\n * @return A new XmlRules map with the merged rules.\n */\nexport function mergeXmlRules(\n ...rules: XmlRules<any>[]\n): XmlRules<Merged<any>> {\n let finalRule = rules[0]\n for (let i = 1; i < rules.length; i++) {\n finalRule = plainObjectMergeRule.merge(\n finalRule,\n rules[i],\n mergeXmlRule\n ) as XmlRules<any>\n }\n return finalRule\n}\n\nfunction mergeXmlRule(\n sourceA: XmlRule<any> | undefined,\n sourceB: XmlRule<any>,\n prop: string | number\n): XmlRule<any>\n\nfunction mergeXmlRule(\n sourceA: XmlRule<any> | LazyXmlRule<any> | undefined,\n sourceB: XmlRule<any> | LazyXmlRule<any>,\n prop: string | number\n): XmlRule<any> | LazyXmlRule<any>\n\nfunction mergeXmlRule(\n sourceA: XmlRule<any> | LazyXmlRule<any> | undefined,\n sourceB: XmlRule<any> | LazyXmlRule<any>,\n prop: string | number\n): XmlRule<any> | LazyXmlRule<any> {\n if (sourceA == null) return sourceB\n const sourceAIsLazy = typeof sourceA === 'function'\n const sourceBIsLazy = typeof sourceB === 'function'\n if (sourceAIsLazy || sourceBIsLazy) {\n return () => {\n const a = sourceAIsLazy ? sourceA() : sourceA\n const b = sourceBIsLazy ? sourceB() : sourceB\n return mergeXmlRule(a, b, prop)\n }\n }\n if (sourceA.type !== sourceB.type) {\n throw new ValidationError(\n substitute(locale.illegalRuleOverrideTypeError, {\n property: prop,\n sourceType: sourceA.type,\n overrideType: sourceB.type,\n })\n )\n }\n switch (sourceA.type) {\n case XmlRuleType.ATTRIBUTE:\n case XmlRuleType.ELEMENT:\n case XmlRuleType.ELEMENTS: {\n const b = sourceB as ElementRule<any>\n if (\n sourceA.namespaceUri !== b.namespaceUri ||\n (sourceA.localPart ?? prop) !== (b.localPart ?? prop)\n ) {\n throw new ValidationError(\n substitute(locale.illegalQNameOverrideError, {\n property: prop,\n })\n )\n }\n break\n }\n }\n\n switch (sourceA.type) {\n case XmlRuleType.ATTRIBUTE: {\n const b = sourceB as AttributeRule<any>\n return {\n ...b,\n default: b.default ?? sourceA.default,\n }\n }\n case XmlRuleType.CHARACTERS:\n return sourceB\n case XmlRuleType.ELEMENT: {\n const b = sourceB as ElementRule<any>\n return {\n ...b,\n required: sourceA.required || b.required,\n rules: mergeXmlRules(sourceA.rules, b.rules),\n }\n }\n case XmlRuleType.ELEMENTS: {\n const b = sourceB as ElementsRule<any>\n const maxOccurs =\n sourceA.maxOccurs != null && b.maxOccurs != null\n ? Math.min(sourceA.maxOccurs, b.maxOccurs)\n : (sourceA.maxOccurs ?? b.maxOccurs)\n return {\n ...b,\n minOccurs: Math.max(sourceA.minOccurs, b.minOccurs),\n maxOccurs,\n useEmptyArrays: sourceA.useEmptyArrays || b.useEmptyArrays,\n rules: mergeXmlRules(sourceA.rules, b.rules),\n }\n }\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n char,\n decodeEntities,\n last,\n type MutableDeep,\n StringReader,\n} from '@amazon/vinyl-util'\n\nimport type { Uri } from '../xmlns/org/w3/2001/XmlSchema'\nimport type { Attributes, ParseXmlHandler } from './ParseXmlHandler'\nimport type { QName } from './QName'\nimport type { XmlElement } from './ParseXmlHandlerImpl'\n\nexport const XMLNS = 'http://www.w3.org/2000/xmlns/'\n\nconst LT = /* @__PURE__ */ char('<')\nconst GT = /* @__PURE__ */ char('>')\nconst EQ = /* @__PURE__ */ char('=')\nconst SLASH = /* @__PURE__ */ char('/')\nconst COLON = /* @__PURE__ */ char(':')\nconst QMARK = /* @__PURE__ */ char('?')\nconst EXCL = /* @__PURE__ */ char('!')\nconst APOS = /* @__PURE__ */ char(\"'\")\nconst QUOT = /* @__PURE__ */ char('\"')\nconst QUOTES = /* @__PURE__ */ new Set([APOS, QUOT])\n\n/**\n * Nested xml elements push current namespace information onto a stack.\n *\n * @private\n */\nexport interface StackElement {\n /**\n * The qualified name of the current element on the stack. Used to validate expected closing\n * element.\n */\n readonly qName: string\n\n /**\n * The (mutable) namespaces map for the current stack.\n */\n readonly namespaceMap: Namespaces\n\n /**\n * The default namespace.\n */\n defaultNamespaceUri: Uri | null\n}\n\n/**\n * Parses an XML document using a partial sax-style content handler.\n * This allows for parsing without the entire document being read into memory first.\n *\n * XML Documents are mapped to data structures through content handlers instead of needing an\n * intermediate model.\n */\nexport function parseXml<T>(\n str: string,\n handler: ParseXmlHandler<T>\n): T & XmlElement<T> {\n const c = new StringReader(str)\n let current: StackElement = {\n qName: '#document',\n namespaceMap: new Map(),\n defaultNamespaceUri: null,\n }\n const stack: StackElement[] = [current]\n\n /**\n * Provides the namespace uri for the given prefix on the current stack.\n * @param prefix\n */\n const namespaceLookup = (prefix: string | null): Uri | null => {\n if (!prefix) return current.defaultNamespaceUri\n for (let i = stack.length - 1; i >= 0; i--) {\n const map = stack[i].namespaceMap\n if (map.has(prefix)) return stack[i].namespaceMap.get(prefix)!\n }\n return null\n }\n\n try {\n handler.startDocument()\n } catch (e: any) {\n c.err(e.message)\n }\n while (c.hasNext()) {\n const charsStart = c.untilChar(LT)\n if (charsStart < c.position) {\n const chars = str.substring(charsStart, c.position)\n try {\n handler.textNode(chars)\n } catch (e: any) {\n c.err(e.message)\n }\n }\n if (!c.hasNext()) break // eos\n c.next() // <\n if (c.charIf(SLASH)) {\n // </ prepare for ending the element.\n c.white()\n const name = readQName(c)\n if (name.qName !== current.qName)\n c.err(`Expected </${current.qName}> but was </${name.qName}>`)\n stack.pop()\n current = last(stack)!\n c.white()\n c.readChar(GT)\n try {\n handler.endElement()\n } catch (e: any) {\n c.err(e.message)\n }\n } else if (c.charIf(QMARK)) {\n // <? Processing instruction\n untilTagClose(c)\n } else if (c.charIf(EXCL)) {\n // <! Declaration\n if (c.charIf(0x2d /* - */)) {\n c.readChar(0x2d)\n // <!-- Comment\n c.untilString('-->')\n c.read('-->')\n } else if (c.stringIf('[CDATA[')) {\n // <![CDATA[\n const charsStart = c.untilString(']]>')\n try {\n handler.cDataNode(str.substring(charsStart, c.position))\n } catch (e: any) {\n c.err(e.message)\n }\n c.read(']]>')\n } else {\n // <! Declaration\n untilTagClose(c)\n }\n } else {\n // < Prepare for beginning the element\n // Create a new stack element, inheriting the namespaces of the parent.\n const name: MutableDeep<QName> = readQName(c)\n current = {\n qName: name.qName,\n namespaceMap: new Map(),\n defaultNamespaceUri: current.defaultNamespaceUri,\n }\n stack.push(current)\n const attributes = xmlAttributes(c, current)\n // The namespaces can only be looked up after all attributes are parsed;\n // a namespace prefix may be defined after it's used on the same element.\n name.namespaceUri = namespaceLookup(name.prefix)\n for (const attributesKey in attributes) {\n const value = attributes[attributesKey]!\n const name = value.name\n // Attributes do not inherit the default namespace.\n if (name.prefix && !name.namespaceUri) {\n name.namespaceUri = namespaceLookup(name.prefix)\n }\n }\n\n try {\n handler.startElement(name, attributes)\n } catch (e: any) {\n c.err(e.message)\n }\n if (c.charIf(SLASH)) {\n c.readChar(GT)\n stack.pop()\n current = last(stack)!\n // Closed tag <example/>\n try {\n handler.endElement()\n } catch (e: any) {\n c.err(e.message)\n }\n } else {\n c.readChar(GT)\n }\n }\n }\n try {\n return handler.endDocument()\n } catch (e: any) {\n return c.err(e.message)\n }\n}\n\n/**\n * @private\n */\nexport type Namespaces = Map<string, Uri | null>\n\n// noinspection GrazieInspection\n/**\n * Given that the cursor is at a ' or \", reads the sequence of characters until an end quote is\n * reached.\n * The returned unescaped string is the text within the quotes.\n * @private\n */\nexport function readAttributeValue(c: StringReader): string {\n const quote = c.next()\n if (!QUOTES.has(quote)) c.err('Expected \\' or \"')\n const value = c.substringUntil((charCode) => charCode === quote)\n c.readChar(quote)\n return decodeEntities(value)\n}\n\n/**\n * Reads until the end of the tag >\n * @private\n */\nexport function untilTagClose(c: StringReader): void {\n while (true) {\n c.until((c) => c === APOS || c === QUOT || c === GT)\n const char = c.next()\n if (QUOTES.has(char)) {\n c.untilChar(char)\n c.next()\n } else {\n // >\n break\n }\n }\n}\n\n/**\n * Returns true if the char code is a valid xml name character.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-NameChar\n * @param charCode\n * @private\n */\nexport function isNameChar(charCode: number): boolean {\n if (charCode >= 0x61 /* a */) {\n if (charCode >= 0xb7 /* \u00B7 */) {\n if (charCode >= 0x300) {\n if (charCode >= 0x203f) {\n return charCode <= 0x2040\n } else {\n return charCode <= 0x36f\n }\n } else {\n return charCode === 0xb7 /* \u00B7 */\n }\n } else {\n return charCode <= 0x7a /* z */\n }\n } else {\n if (charCode >= 0x5f /* _ */) {\n return charCode === 0x5f\n } else {\n if (charCode >= 0x41 /* A */) {\n return charCode <= 0x5a /* Z */\n } else {\n if (charCode >= 0x2d /* - */) {\n if (charCode >= 0x30 /* 0 */) {\n return charCode <= 0x39 /* 9 */\n } else {\n return charCode <= 0x2e /* . */\n }\n } else {\n return false\n }\n }\n }\n }\n}\n\n/**\n * Reads an xml {@link QName}.\n * The {@link QName.namespaceUri} returned will be null; it must be separately looked up.\n *\n * @param reader The current string reader.\n * @private\n */\nexport function readQName(reader: StringReader): MutableDeep<QName> {\n const prefixOrLocalName = reader.substringWhile(isNameChar)\n let prefix: string | null, localPart: string, name: string\n if (reader.charIf(COLON)) {\n prefix = prefixOrLocalName\n localPart = reader.substringWhile(isNameChar)\n name = `${prefix}:${localPart}`\n } else {\n prefix = null\n localPart = prefixOrLocalName\n name = localPart\n }\n return { prefix, localPart, qName: name, namespaceUri: null }\n}\n\n/**\n * Reads a series of xml attributes, separated by whitespace.\n * Example: `ns1:key1=\"value1\" key2 key3='value3'`\n * Note: consumes all whitespace before and after attributes series.\n *\n * @return Returns a map of attribute `qName:string` to `Attribute` objects.\n *\n * @private\n */\nexport function xmlAttributes(\n reader: StringReader,\n stackElement: StackElement\n): MutableDeep<Attributes> {\n const attributes: MutableDeep<Attributes> = {}\n while (true) {\n reader.white()\n if (!isNameChar(reader.peek)) break\n const name = readQName(reader)\n reader.white()\n let value = ''\n if (reader.charIf(EQ)) {\n reader.white()\n value = readAttributeValue(reader)\n } else {\n // Attributes without values are valid in html, but not xml\n }\n\n if (name.prefix === 'xmlns') {\n name.namespaceUri = XMLNS\n stackElement.namespaceMap.set(\n name.localPart,\n value === '' ? null : value\n )\n } else if (!name.prefix && name.localPart === 'xmlns') {\n name.namespaceUri = XMLNS\n stackElement.defaultNamespaceUri = !value ? null : value\n }\n if (attributes[name.qName] != null)\n reader.err(`Attribute '${name.qName}' is already specified.`)\n attributes[name.qName] = { name, value }\n }\n return attributes\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n clone,\n type Cloneable,\n decodeEntities,\n IllegalStateError,\n last,\n substitute,\n toJson,\n} from '@amazon/vinyl-util'\n\nimport type { XmlRules } from './xmlRules'\nimport type { MappedXmlRules } from './mappedXmlRules'\nimport { EmptyRules, mapXmlRules, xmlRuleKey } from './mappedXmlRules'\nimport type { Attributes, ParseXmlHandler } from './ParseXmlHandler'\nimport type { QName } from './QName'\nimport { XmlSchemaError, xmlSchemaErrorLocale } from './XmlSchemaError'\n\ninterface StackElement {\n /**\n * The current object being built.\n */\n readonly element: any\n\n /**\n * The current element's text content. This will be appended to on every {@link characters}\n * callback.\n */\n characters: string\n\n /**\n * The current element rules.\n */\n readonly rules: MappedXmlRules<any>\n}\n\n/**\n * Choose the rule using namespaces first, if there is no match, query the wildcard namespace rules.\n */\nfunction getRule<T>(\n name: QName,\n rules: ReadonlyMap<string, T | undefined>\n): T | undefined {\n return rules.get(xmlRuleKey(name.localPart, name.namespaceUri))\n}\n\nexport interface ParseXmlHandlerOptions {\n readonly validateRules: boolean\n}\n\n/**\n * A {@link ParseXmlHandler} implementation that follows {@link XmlRules}, building an object of\n * the parameterized type.\n */\nexport class ParseXmlHandlerImpl<T> implements ParseXmlHandler<T> {\n private stack: StackElement[] = []\n\n private options: ParseXmlHandlerOptions\n private busy = false\n\n constructor(\n private readonly rules: MappedXmlRules<T>,\n options?: Partial<ParseXmlHandlerOptions>\n ) {\n this.options = { validateRules: true, ...options }\n }\n\n startDocument(): void {\n if (this.busy)\n throw new IllegalStateError('XML content handler is busy')\n this.busy = true\n const rules = this.rules\n this.stack.push({\n element: new XmlElementImpl(),\n rules,\n characters: '',\n })\n }\n\n startElement(name: QName, attributes: Attributes): void {\n const parent = last(this.stack)!\n let element: any = null\n const elementRule = getRule(name, parent.rules.elements)\n const rules = elementRule?.rules() ?? EmptyRules\n if (elementRule) {\n const prop = elementRule.property\n element = new XmlElementImpl(parent.element)\n if (elementRule.array) {\n const arr = parent.element[prop]\n if (Array.isArray(arr)) {\n arr.push(element)\n } else {\n parent.element[prop] = [element]\n }\n } else {\n if (parent.element[prop]) {\n throw new XmlSchemaError(\n `Expected single element with name ${name.qName}`\n )\n } else {\n parent.element[prop] = element\n }\n }\n\n const attributeRules = rules.attributes\n for (const k in attributes) {\n const attribute = attributes[k]!\n const name = attribute.name\n const attributeRule = getRule(name, attributeRules)\n if (attributeRule) {\n element[attributeRule.property] = attributeRule.parse(\n attribute.value\n )\n }\n }\n\n // Set attribute defaults:\n attributeRules.forEach((_value, key) => {\n const rule = attributeRules.get(key)!\n if (!(rule.property in element)) {\n if (rule.default != null) {\n element[rule.property] = rule.default\n } else if (this.options.validateRules && rule.required) {\n throw new XmlSchemaError(\n substitute(xmlSchemaErrorLocale.requiredAttribute, {\n property: rule.property,\n })\n )\n }\n }\n })\n }\n this.stack.push({\n element,\n rules,\n characters: '',\n })\n }\n\n textNode(str: string): void {\n const current = last(this.stack)!\n if (!current.rules.characters) return\n current.characters += decodeEntities(str.trim())\n }\n\n cDataNode(str: string): void {\n const current = last(this.stack)!\n if (!current.rules.characters) return\n current.characters += str\n }\n\n endElement(): void {\n const lastEl = this.stack.pop()!\n const charactersRule = lastEl.rules.characters\n if (charactersRule)\n lastEl.element[charactersRule.property] = charactersRule.parse(\n lastEl.characters\n )\n lastEl.rules.elements.forEach((rule) => {\n if (rule.array && !(rule.property in lastEl.element)) {\n if (rule.useEmptyArrays) {\n lastEl.element[rule.property] = []\n }\n }\n })\n this.validate(lastEl)\n }\n\n endDocument(): T & XmlElement<T> {\n this.busy = false\n const last = this.stack.pop()!\n this.validate(last)\n return last.element\n }\n\n private validate(current: StackElement) {\n if (!this.options.validateRules) return\n current.rules.elements.forEach((rule) => {\n const length = rule.array\n ? (current.element[rule.property]?.length ?? 0)\n : current.element[rule.property]\n ? 1\n : 0\n if (length < rule.minOccurs) {\n throw new XmlSchemaError(\n substitute(xmlSchemaErrorLocale.atLeastElements, {\n property: rule.property,\n expected: rule.minOccurs,\n actual: length,\n })\n )\n }\n if (rule.maxOccurs != null && length > rule.maxOccurs) {\n throw new XmlSchemaError(\n substitute(xmlSchemaErrorLocale.atMostElements, {\n property: rule.property,\n expected: rule.maxOccurs,\n actual: length,\n })\n )\n }\n })\n }\n}\n\n/**\n * Creates an XML content handler for the given parsing rules.\n *\n * @param rules\n * @param options\n */\nexport function parseXmlHandler<T extends object>(\n rules: XmlRules<T>,\n options?: Partial<ParseXmlHandlerOptions>\n): ParseXmlHandlerImpl<T> {\n return new ParseXmlHandlerImpl<T>(mapXmlRules(rules), options)\n}\n\n// Use a symbol to prevent parent from inclusion in property enumeration.\nconst parentSymbol = /* @__PURE__ */ Symbol('parent')\n\nexport interface XmlElement<T = any> extends Cloneable<T & XmlElement<T>> {\n get parent(): XmlElement | null\n toJSON(): any\n}\n\nexport class XmlElementImpl<T> implements XmlElement<T> {\n [prop: keyof any]: any\n\n private [parentSymbol]: XmlElement | null\n\n constructor(parent: XmlElement | null = null) {\n this[parentSymbol] = parent\n }\n\n get parent(): XmlElement | null {\n return this[parentSymbol]\n }\n\n set parent(value: XmlElement | null) {\n this[parentSymbol] = value\n }\n\n clone(): T & XmlElementImpl<T> {\n const out: any = new XmlElementImpl(this.parent)\n for (const key in this) {\n // Clone all children, setting their parent references to the new cloned parent.\n const child: any = clone(this[key])\n if (Array.isArray(child)) {\n for (const e of child) {\n if (typeof e === 'object' && 'parent' in e) e.parent = out\n }\n } else if (typeof child === 'object' && 'parent' in child) {\n child.parent = out\n }\n out[key] = child\n }\n return out\n }\n\n toJSON(): any {\n const out: any = {}\n for (const key in this) {\n out[key] = toJson(this[key])\n }\n return out\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ErrorOrigin, ReportableError } from '@amazon/vinyl-util'\n\n/**\n * @private\n */\nexport const xmlSchemaErrorLocale = {\n atLeastElements:\n 'Expected at least {expected} occurrences of {property} but was {actual}',\n atMostElements:\n 'Expected at most {expected} occurrences of {property} but was {actual}',\n cyclicReferences: 'Cyclic reference detected',\n requiredAttribute: `Attribute '{property}' is required`,\n} as const\n\nexport class XmlSchemaError extends ReportableError {\n get [Symbol.toStringTag](): string {\n return 'XmlSchemaError'\n }\n\n constructor(message: string) {\n super(message, ErrorOrigin.PARSING)\n Object.setPrototypeOf(this, XmlSchemaError.prototype)\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Uri } from '../xmlns/org/w3/2001/XmlSchema'\n\n/**\n * An XML name for an element or attribute.\n */\nexport interface QName {\n /**\n * The fully qualified name.\n * This will be the prefixed name or the unprefixed name if the prefix is empty.\n * The prefixed name will be `prefix ':' localPart`\n */\n readonly qName: string\n\n /**\n * The xmlns prefix.\n */\n readonly prefix: string | null\n\n /**\n * The local part of this name.\n */\n readonly localPart: string\n\n /**\n * The resolved xmlns uri for the associated prefix.\n */\n readonly namespaceUri: Uri | null\n}\n\n/**\n * Creates a new {@link QName} object.\n *\n * @param localPart\n * @param prefix\n * @param namespaceUri\n */\nexport function qName(\n localPart: string,\n prefix: string | null = null,\n namespaceUri: Uri | null = null\n): QName {\n return {\n localPart,\n prefix,\n namespaceUri,\n qName: prefix ? `${prefix}:${localPart}` : localPart,\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n encodeEntities,\n equalDeep,\n getOrSet,\n type OptionalDeep,\n substitute,\n} from '@amazon/vinyl-util'\n\nimport type { Uri } from '../xmlns/org/w3/2001/XmlSchema'\nimport type {\n MappedAttributeRule,\n MappedCharactersRule,\n MappedElementsRule,\n MappedXmlRules,\n} from './mappedXmlRules'\nimport { XmlSchemaError, xmlSchemaErrorLocale } from './XmlSchemaError'\nimport type { ReservedXmlRuleKeys } from './xmlRules'\n\n/**\n * @private\n */\nconst locale = {\n /**\n * When a namespace binding is generated, if the prefix was not provided in the stringifier\n * options, it will be generated from this template.\n */\n prefixTemplate: 'ns_{value}',\n} as const\n\nexport interface StringifyOptions {\n /**\n * The indentation. Default: 4 spaces\n */\n readonly indent: string\n\n /**\n * The character(s) between lines. Default: \\n\n */\n readonly newline: string\n\n /**\n * A map of namespace uri to prefix strings.\n * If a namespace is not found, a prefix will be generated.\n */\n readonly prefixMap: ReadonlyMap<Uri, string>\n\n /**\n * If true, will include the XML declaration at the beginning of the stringified document.\n * `<?xml version=\"1.0\"?>`\n */\n readonly includeXmlDeclaration: boolean\n}\n\nconst defaultStringifyOptions: StringifyOptions = {\n indent: ' ',\n newline: '\\n',\n prefixMap: /* @__PURE__ */ new Map(),\n includeXmlDeclaration: true,\n}\n\nexport class XmlWriter<T> {\n private readonly options: StringifyOptions\n private readonly usedPrefixes = /* @__PURE__ */ new Map<Uri, string>()\n private readonly traversed = /* @__PURE__ */ new Set()\n\n constructor(\n private readonly rules: MappedXmlRules<T>,\n options?: Partial<StringifyOptions>\n ) {\n this.options = {\n ...defaultStringifyOptions,\n ...options,\n }\n }\n\n stringify(object: OptionalDeep<T, ReservedXmlRuleKeys>): string {\n let str = this.options.includeXmlDeclaration\n ? '<?xml version=\"1.0\"?>' + this.options.newline\n : ''\n const state = new StringifyState()\n str += this.stringifyChildren(object, this.rules.elements, state)\n this.usedPrefixes.clear()\n this.traversed.clear()\n\n return str\n }\n\n private qName(localPart: string, namespaceUri: Uri | null): string {\n if (!namespaceUri) return localPart\n const prefixMap = this.options.prefixMap\n const prefix = getOrSet(this.usedPrefixes, namespaceUri, () => {\n if (prefixMap.has(namespaceUri)) {\n return prefixMap.get(namespaceUri)!\n }\n return substitute(locale.prefixTemplate, {\n value: (this.usedPrefixes.size + 1).toString(36),\n })\n })\n return `${prefix}:${localPart}`\n }\n\n /**\n * Stringifies an element.\n *\n * @param object\n * @param rule\n * @param state\n */\n private stringifyElement(\n object: any,\n rule: MappedElementsRule,\n state: StringifyState\n ): string {\n if (this.traversed.has(object))\n throw new XmlSchemaError(xmlSchemaErrorLocale.cyclicReferences)\n this.traversed.add(object)\n const nl = this.options.newline\n const isDocument = state.depth === 0\n let namespaces = ''\n\n let xmlns = state.xmlns\n if (\n xmlns !== rule.namespaceUri &&\n (xmlns == null || !rule.namespaceUri)\n ) {\n // The element's namespace is different from the parent.\n // Change the default namespace if moving to or from a null namespace.\n xmlns = rule.namespaceUri\n namespaces += ` xmlns=\"${rule.namespaceUri ?? ''}\"`\n }\n\n const childState = state.createChild(xmlns, this.options.indent)\n const rules = rule.rules()\n const attributes = this.stringifyAttributes(object, rules.attributes)\n const children = this.stringifyChildren(\n object,\n rules.elements,\n childState\n )\n const text = this.stringifyCharacters(object, rules.characters)\n\n if (isDocument) {\n this.usedPrefixes.forEach((prefix, uri) => {\n namespaces += ` xmlns:${prefix}=\"${uri}\"`\n })\n }\n\n const indent = state.indent\n const childIndent = childState.indent\n const qName =\n rule.namespaceUri === xmlns\n ? rule.localPart\n : this.qName(rule.localPart, rule.namespaceUri)\n let str = `${indent}<${qName}${namespaces}${attributes}`\n if (children) {\n str += `>`\n if (text) str += `${nl}${childIndent}${text}`\n str += nl + children\n str += `${nl}${indent}</${qName}>`\n } else if (text) {\n str += `>${text}</${qName}>`\n } else {\n str += '/>'\n }\n return str\n }\n\n /**\n * Stringifies an element's attributes.\n *\n * @param object\n * @param attributes\n * @return Returns the attributes string. This will include a leading space if there are any\n * found attributes.\n */\n private stringifyAttributes(\n object: any,\n attributes: ReadonlyMap<string, MappedAttributeRule>\n ): string {\n let str = ''\n attributes.forEach((attributeRule) => {\n const propertyValue = object[attributeRule.property]\n if (propertyValue !== undefined) {\n const attributeValue = attributeRule.stringify(propertyValue)\n if (\n attributeRule.default === undefined ||\n !equalDeep(propertyValue, attributeRule.default)\n ) {\n str += ` ${this.qName(\n attributeRule.localPart,\n attributeRule.namespaceUri\n )}=\"${encodeEntities(attributeValue)}\"`\n }\n } else {\n if (attributeRule.required) {\n throw new XmlSchemaError(\n substitute(xmlSchemaErrorLocale.requiredAttribute, {\n property: attributeRule.property,\n })\n )\n }\n }\n })\n return str\n }\n\n /**\n * Stringifies a property as a CDATA node.\n *\n * @param object\n * @param charactersRule\n */\n private stringifyCharacters(\n object: any,\n charactersRule: MappedCharactersRule | undefined\n ): string | null {\n if (!charactersRule) return null\n const str = charactersRule.stringify(object[charactersRule.property])\n if (!str) return ''\n // `]]>` would close the section early, so it is split across two of them.\n return `<![CDATA[${str.split(']]>').join(']]]]><![CDATA[>')}]]>`\n }\n\n /**\n * Stringifies an element's child elements.\n *\n * @param object\n * @param elements\n * @param state\n */\n private stringifyChildren(\n object: any,\n elements: ReadonlyMap<string, MappedElementsRule>,\n state: StringifyState\n ): string {\n let str = ''\n elements.forEach((elementsRule) => {\n const child: any = object[elementsRule.property]\n if (child) {\n if (elementsRule.array) {\n const arr: any[] = child\n if (elementsRule.minOccurs > arr.length) {\n throw new XmlSchemaError(\n substitute(xmlSchemaErrorLocale.atLeastElements, {\n property: elementsRule.property,\n expected: elementsRule.minOccurs,\n actual: arr.length,\n })\n )\n }\n if (\n elementsRule.maxOccurs != null &&\n elementsRule.maxOccurs < arr.length\n ) {\n throw new XmlSchemaError(\n substitute(xmlSchemaErrorLocale.atMostElements, {\n property: elementsRule.property,\n expected: elementsRule.maxOccurs,\n actual: arr.length,\n })\n )\n }\n for (const element of arr) {\n if (str) str += this.options.newline\n str += this.stringifyElement(\n element,\n elementsRule,\n state\n )\n }\n } else {\n if (str) str += this.options.newline\n str += this.stringifyElement(child, elementsRule, state)\n }\n } else {\n if (elementsRule.minOccurs > 0) {\n throw new XmlSchemaError(\n substitute(xmlSchemaErrorLocale.atLeastElements, {\n property: elementsRule.property,\n expected: elementsRule.minOccurs,\n actual: 0,\n })\n )\n }\n }\n })\n return str\n }\n}\n\nclass StringifyState {\n constructor(\n readonly depth: number = 0,\n readonly xmlns: Uri | null = null,\n readonly indent: string = ''\n ) {}\n\n createChild(xmlns: Uri | null, indent: string): StringifyState {\n return new StringifyState(this.depth + 1, xmlns, this.indent + indent)\n }\n}\n\nexport function stringifyXml<T>(\n object: OptionalDeep<T, ReservedXmlRuleKeys>,\n rules: MappedXmlRules<T>,\n options?: Partial<StringifyOptions>\n): string {\n const writer = new XmlWriter(rules, options)\n return writer.stringify(object)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,eAA+B;AAExC,SAAS,mBAAmB;AAE5B,IAAM,mBAA2D,wBAAQ,UAAU,WAAW;AAEvF,SAAS,kBAAkB,KAA0B;AACxD,mBAAiB,OAAO,KAAK,YAAY,OAAO;AAChD,SAAO;AACX;;;ACTA;AAAA,EAEI;AAAA,EACA;AAAA,EAEA;AAAA,OACG;;;ACCP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIG;AAIA,IAAK,cAAL,kBAAKA,iBAAL;AACH,EAAAA,a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I,IAAK,QAAO,KAAK,QAAQ;AAC7B,mBAAO,KAAK;AAAA,cACRA;AAAA,cACA;AAAA,cACA;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ,OAAO;AACH,cAAI,IAAK,QAAO,KAAK,QAAQ;AAC7B,iBAAO,KAAK,iBAAiB,OAAO,cAAc,KAAK;AAAA,QAC3D;AAAA,MACJ,OAAO;AACH,YAAI,aAAa,YAAY,GAAG;AAC5B,gBAAM,IAAI;AAAA,YACNJ,YAAW,qBAAqB,iBAAiB;AAAA,cAC7C,UAAU,aAAa;AAAA,cACvB,UAAU,aAAa;AAAA,cACvB,QAAQ;AAAA,YACZ,CAAC;AAAA,UACL;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ,CAAC;AACD,WAAO;AAAA,EACX;AACJ;AAEA,IAAM,iBAAN,MAAM,gBAAe;AAAA,EACjB,YACa,QAAgB,GAChB,QAAoB,MACpB,SAAiB,IAC5B;AAHW;AACA;AACA;AAAA,EACV;AAAA,EAEH,YAAY,OAAmB,QAAgC;AAC3D,WAAO,IAAI,gBAAe,KAAK,QAAQ,GAAG,OAAO,KAAK,SAAS,MAAM;AAAA,EACzE;AACJ;AAEO,SAAS,aACZ,QACA,OACA,SACM;AACN,QAAM,SAAS,IAAI,UAAU,OAAO,OAAO;AAC3C,SAAO,OAAO,UAAU,MAAM;AAClC;",
6
6
  "names": ["XmlRuleType", "stringify", "_a", "rules", "_a", "charsStart", "name", "c", "char", "decodeEntities", "last", "substitute", "ErrorOrigin", "_a", "last", "element", "name", "substitute", "decodeEntities", "substitute", "locale", "substitute", "_a", "qName", "elements", "element"]
7
7
  }