@itwin/ecschema-metadata 5.6.0-dev.7 → 5.6.0
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/CHANGELOG.md +21 -1
- package/lib/cjs/Deserialization/JsonParser.d.ts.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.js +12 -0
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js +12 -0
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/Formatting/SchemaFormatsProvider.js +1 -1
- package/lib/cjs/Formatting/SchemaFormatsProvider.js.map +1 -1
- package/lib/cjs/Metadata/Class.d.ts +14 -0
- package/lib/cjs/Metadata/Class.d.ts.map +1 -1
- package/lib/cjs/Metadata/Class.js +48 -3
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Format.d.ts +3 -0
- package/lib/cjs/Metadata/Format.d.ts.map +1 -1
- package/lib/cjs/Metadata/Format.js +100 -26
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.d.ts +3 -0
- package/lib/cjs/Metadata/OverrideFormat.d.ts.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.js +4 -1
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/esm/Deserialization/JsonParser.d.ts.map +1 -1
- package/lib/esm/Deserialization/JsonParser.js +12 -0
- package/lib/esm/Deserialization/JsonParser.js.map +1 -1
- package/lib/esm/Deserialization/XmlParser.d.ts.map +1 -1
- package/lib/esm/Deserialization/XmlParser.js +12 -0
- package/lib/esm/Deserialization/XmlParser.js.map +1 -1
- package/lib/esm/Formatting/SchemaFormatsProvider.js +1 -1
- package/lib/esm/Formatting/SchemaFormatsProvider.js.map +1 -1
- package/lib/esm/Metadata/Class.d.ts +14 -0
- package/lib/esm/Metadata/Class.d.ts.map +1 -1
- package/lib/esm/Metadata/Class.js +49 -4
- package/lib/esm/Metadata/Class.js.map +1 -1
- package/lib/esm/Metadata/Format.d.ts +3 -0
- package/lib/esm/Metadata/Format.d.ts.map +1 -1
- package/lib/esm/Metadata/Format.js +100 -26
- package/lib/esm/Metadata/Format.js.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.d.ts +3 -0
- package/lib/esm/Metadata/OverrideFormat.d.ts.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.js +4 -1
- package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
- package/package.json +11 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XmlParser.js","sourceRoot":"","sources":["../../../src/Deserialization/XmlParser.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA6C;AAC7C,4CAAsI;AACtI,4CAA6D;AAI7D,yDAAsD;AAEtD,sCAAmC;AACnC,qDAAmE;AAOnE,qCAA2D;AAE3D,MAAM,wBAAwB,GAAG,CAAC,mBAAmB,EAAE,oBAAoB,CAAC,CAAC;AAC7E,MAAM,SAAS,GAAG,oDAAoD,CAAC;AAKvE,gBAAgB;AAChB,MAAa,SAAU,SAAQ,+BAAuB;IAC5C,UAAU,CAAW;IACrB,WAAW,CAAU;IACrB,qBAAqB,CAAsB;IAC3C,YAAY,CAAS;IACrB,cAAc,CAAU;IACxB,aAAa,CAAU;IACvB,oBAAoB,CAAU;IAC9B,YAAY,CAAiC;IAC7C,eAAe,CAAU;IAEjC,YAAY,SAA6B;QACvC,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,MAAM,UAAU,GAAG,SAAS,CAAC,eAAe,CAAC;QAE7C,MAAM,UAAU,GAAG,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACzD,IAAI,UAAU;YACZ,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAEhC,IAAI,CAAC,YAAY,GAAG,EAAE,C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uB,GAAG,gBAAgB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAClE,IAAI,qBAAqB,GAAW,EAAE,CAAC;YACvC,qBAAqB,GAAG,IAAI,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9E,IAAI,uBAAuB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,uBAAuB,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;oBACxD,IAAI,uBAAuB,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC;wBACzC,SAAS;oBACX,MAAM,gBAAgB,GAAG,uBAAuB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;oBACjE,MAAM,cAAc,GAAG,IAAI,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC;oBACxG,MAAM,WAAW,GAAG,uBAAuB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;oBACvE,qBAAqB,IAAI,IAAI,cAAc,GAAG,WAAW,GAAG,CAAC;gBAC/D,CAAC;YACH,CAAC;YAED,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAClC,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAxuCD,8BAwuCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { parsePrimitiveType, PrimitiveType, primitiveTypeToString, StrengthDirection, strengthDirectionToString } from \"../ECObjects\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\r\nimport { ECClass, StructClass } from \"../Metadata/Class\";\r\nimport { CustomAttribute } from \"../Metadata/CustomAttribute\";\r\nimport { CustomAttributeClass } from \"../Metadata/CustomAttributeClass\";\r\nimport { Enumeration } from \"../Metadata/Enumeration\";\r\nimport { PrimitiveProperty, Property, StructArrayProperty } from \"../Metadata/Property\";\r\nimport { ECName } from \"../ECName\";\r\nimport { AbstractParser, CAProviderTuple } from \"./AbstractParser\";\r\nimport {\r\n ClassProps, ConstantProps, CustomAttributeClassProps, EntityClassProps, EnumerationProps, EnumeratorProps, InvertedUnitProps,\r\n KindOfQuantityProps, MixinProps, NavigationPropertyProps, PhenomenonProps, PrimitiveArrayPropertyProps, PrimitiveOrEnumPropertyBaseProps,\r\n PrimitivePropertyProps, PropertyCategoryProps, PropertyProps, RelationshipClassProps, RelationshipConstraintProps, SchemaItemFormatProps, SchemaItemProps,\r\n SchemaItemUnitProps, SchemaProps, SchemaReferenceProps, StructArrayPropertyProps, StructClassProps, StructPropertyProps, UnitSystemProps,\r\n} from \"./JsonProps\";\r\nimport { ECSpecVersion, SchemaReadHelper } from \"./Helper\";\r\n\r\nconst NON_ITEM_SCHEMA_ELEMENTS = [\"ECSchemaReference\", \"ECCustomAttributes\"];\r\nconst ECXML_URI = \"http://www\\\\.bentley\\\\.com/schemas/Bentley\\\\.ECXML\";\r\n\r\ntype PrimitiveArray = PrimitiveValue[];\r\ntype PrimitiveValue = string | number | boolean | Date;\r\n\r\n/** @internal */\r\nexport class XmlParser extends AbstractParser<Element> {\r\n private _rawSchema: Document;\r\n private _schemaName?: string;\r\n private _schemaReferenceNames: Map<string, string>;\r\n private _schemaAlias: string;\r\n private _schemaVersion?: string;\r\n private _xmlNamespace?: string;\r\n private _currentItemFullName?: string;\r\n private _schemaItems: Map<string, [string, Element]>;\r\n private _mapIsPopulated: boolean;\r\n\r\n constructor(rawSchema: Readonly<Document>) {\r\n super();\r\n\r\n this._rawSchema = rawSchema;\r\n const schemaInfo = rawSchema.documentElement;\r\n\r\n const schemaName = schemaInfo.getAttribute(\"schemaName\");\r\n if (schemaName)\r\n this._schemaName = schemaName;\r\n\r\n this._schemaAlias = \"\";\r\n const schemaAlias = schemaInfo.getAttribute(\"alias\");\r\n if (schemaAlias)\r\n this._schemaAlias = schemaAlias;\r\n\r\n this._schemaReferenceNames = new Map<string, string>();\r\n\r\n const schemaVersion = schemaInfo.getAttribute(\"version\");\r\n if (schemaVersion)\r\n this._schemaVersion = schemaVersion;\r\n\r\n const xmlNamespace = schemaInfo.getAttribute(\"xmlns\");\r\n if (xmlNamespace) {\r\n this._xmlNamespace = xmlNamespace;\r\n this._ecSpecVersion = XmlParser.parseXmlNamespace(this._xmlNamespace);\r\n }\r\n\r\n this._schemaItems = new Map<string, [string, Element]>();\r\n this._mapIsPopulated = false;\r\n }\r\n\r\n public get getECSpecVersion(): ECSpecVersion | undefined { return this._ecSpecVersion; }\r\n\r\n public parseSchema(): SchemaProps {\r\n const schemaMetadata = this._rawSchema.documentElement;\r\n if (\"ECSchema\" !== schemaMetadata.nodeName)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, \"An ECSchema is missing the required metadata.\");\r\n\r\n const schemaDefDuplicates = this.getElementChildrenByTagName(schemaMetadata, \"ECSchema\");\r\n if (schemaDefDuplicates.length > 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, \"An ECSchema has more than one ECSchema definition. Only one is allowed.\");\r\n\r\n if (this._schemaName === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `An ECSchema is missing a required 'schemaName' attribute`);\r\n\r\n if (this._schemaVersion === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ECSchema ${this._schemaName} is missing a required 'version' attribute`);\r\n\r\n if (this._xmlNamespace === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ECSchema ${this._schemaName} is missing a required 'xmlns' attribute`);\r\n\r\n if (this._ecSpecVersion === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ECSchema ${this._schemaName} has an invalid 'xmlns' attribute`);\r\n\r\n const alias = this.getRequiredAttribute(schemaMetadata, \"alias\",\r\n `The ECSchema ${this._schemaName} is missing a required 'alias' attribute`);\r\n const description = this.getOptionalAttribute(schemaMetadata, \"description\");\r\n const displayLabel = this.getOptionalAttribute(schemaMetadata, \"displayLabel\");\r\n\r\n const schemaProps = {\r\n name: this._schemaName,\r\n $schema: this._xmlNamespace,\r\n version: this._schemaVersion,\r\n alias,\r\n label: displayLabel,\r\n description,\r\n ecSpecMajorVersion: this._ecSpecVersion.readVersion,\r\n ecSpecMinorVersion: this._ecSpecVersion.writeVersion,\r\n };\r\n\r\n return schemaProps;\r\n }\r\n\r\n public *getReferences(): Iterable<SchemaReferenceProps> {\r\n const schemaReferences = this.getElementChildrenByTagName(this._rawSchema.documentElement, \"ECSchemaReference\");\r\n for (const ref of schemaReferences) {\r\n yield this.getSchemaReference(ref);\r\n }\r\n }\r\n\r\n public *getItems(): Iterable<[string, string, Element]> {\r\n if (!this._mapIsPopulated) {\r\n const schemaItems = this.getSchemaChildren();\r\n for (const item of schemaItems) {\r\n let rawItemType = item.nodeName;\r\n if (NON_ITEM_SCHEMA_ELEMENTS.includes(rawItemType))\r\n continue;\r\n\r\n // Differentiate a Mixin from an EntityClass\r\n const customAttributesResult = this.getElementChildrenByTagName(item, \"ECCustomAttributes\");\r\n if (customAttributesResult.length > 0) {\r\n const customAttributes = customAttributesResult[0];\r\n const isMixinResult = this.getElementChildrenByTagName(customAttributes, \"IsMixin\");\r\n if (isMixinResult.length > 0)\r\n rawItemType = \"Mixin\";\r\n }\r\n\r\n const itemType = this.getSchemaItemType(rawItemType);\r\n if (itemType === undefined) {\r\n if (SchemaReadHelper.isECSpecVersionNewer(this._ecSpecVersion))\r\n continue;\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `A SchemaItem in ${this._schemaName} has an invalid type. '${rawItemType}' is not a valid SchemaItem type.`);\r\n }\r\n\r\n const itemName = this.getRequiredAttribute(item, \"typeName\", `A SchemaItem in ${this._schemaName} is missing the required 'typeName' attribute.`);\r\n\r\n if (!ECName.validate(itemName))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECName, `A SchemaItem in ${this._schemaName} has an invalid 'typeName' attribute. '${itemName}' is not a valid ECName.`);\r\n\r\n this._currentItemFullName = `${this._schemaName}.${itemName}`;\r\n this._schemaItems.set(itemName, [itemType, item]);\r\n yield [itemName, itemType, item];\r\n }\r\n this._mapIsPopulated = true;\r\n } else {\r\n for (const [itemName, [itemType, item]] of this._schemaItems) {\r\n this._currentItemFullName = `${this._schemaName}.${itemName}`;\r\n yield [itemName, itemType, item];\r\n }\r\n }\r\n }\r\n\r\n public findItem(itemName: string): [string, string, Element] | undefined {\r\n if (!this._mapIsPopulated) {\r\n for (const item of this.getItems()) {\r\n if (item[0] === itemName) {\r\n this._currentItemFullName = `${this._schemaName}.${itemName}`;\r\n return item;\r\n }\r\n }\r\n } else {\r\n const values = this._schemaItems.get(itemName);\r\n if (undefined !== values) {\r\n const [itemType, item] = values;\r\n this._currentItemFullName = `${this._schemaName}.${itemName}`;\r\n return [itemName, itemType, item];\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n public parseEntityClass(xmlElement: Element): EntityClassProps {\r\n const classProps = this.getClassProps(xmlElement);\r\n const baseClasses = this.getElementChildrenByTagName(xmlElement, \"BaseClass\");\r\n let mixinElements: Element[];\r\n const mixins = new Array<string>();\r\n\r\n // if it has just one BaseClass we assume it is a 'true' base class not a mixin\r\n if (baseClasses.length > 1) {\r\n mixinElements = baseClasses.slice(1);\r\n for (const mixin of mixinElements) {\r\n if (mixin.textContent) {\r\n const typeName = this.getQualifiedTypeName(mixin.textContent);\r\n mixins.push(typeName);\r\n }\r\n }\r\n }\r\n\r\n const entityClassProps = {\r\n ...classProps,\r\n mixins,\r\n };\r\n\r\n return entityClassProps;\r\n }\r\n\r\n public parseMixin(xmlElement: Element): MixinProps {\r\n const classProps = this.getClassProps(xmlElement);\r\n\r\n const baseClasses = this.getElementChildrenByTagName(xmlElement, \"BaseClass\");\r\n\r\n // Mixins can only have one base class\r\n if (baseClasses.length > 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Mixin ${this._currentItemFullName} has more than one base class which is not allowed.`);\r\n\r\n const customAttributesResult = this.getElementChildrenByTagName(xmlElement, \"ECCustomAttributes\");\r\n\r\n if (customAttributesResult.length < 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Mixin ${this._currentItemFullName} is missing the required 'IsMixin' tag.`);\r\n\r\n const customAttributes = customAttributesResult[0];\r\n const isMixinResult = this.getElementChildrenByTagName(customAttributes, \"IsMixin\");\r\n if (isMixinResult.length < 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Mixin ${this._currentItemFullName} is missing the required 'IsMixin' tag.`);\r\n\r\n const mixinAttributes = isMixinResult[0];\r\n const appliesToResult = this.getElementChildrenByTagName(mixinAttributes, \"AppliesToEntityClass\");\r\n\r\n if (appliesToResult.length < 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Mixin ${this._currentItemFullName} is missing the required 'AppliesToEntityClass' tag.`);\r\n\r\n const appliesToElement = appliesToResult[0];\r\n let appliesTo = appliesToElement.textContent;\r\n if (appliesTo === null || appliesTo.length === 0)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Mixin ${this._currentItemFullName} is missing the required 'AppliesToEntityClass' tag.`);\r\n\r\n appliesTo = this.getQualifiedTypeName(appliesTo);\r\n\r\n const mixinProps = {\r\n ...classProps,\r\n appliesTo,\r\n };\r\n\r\n return mixinProps;\r\n }\r\n\r\n public parseStructClass(xmlElement: Element): StructClassProps {\r\n return this.getClassProps(xmlElement);\r\n }\r\n\r\n public parseCustomAttributeClass(xmlElement: Element): CustomAttributeClassProps {\r\n const classProps = this.getClassProps(xmlElement);\r\n const appliesTo = this.getRequiredAttribute(xmlElement, \"appliesTo\",\r\n `The CustomAttributeClass ${this._currentItemFullName} is missing the required 'appliesTo' attribute.`);\r\n\r\n const customAttributeClassProps = {\r\n ...classProps,\r\n appliesTo,\r\n };\r\n\r\n return customAttributeClassProps;\r\n }\r\n\r\n public parseRelationshipClass(xmlElement: Element): RelationshipClassProps {\r\n const classProps = this.getClassProps(xmlElement);\r\n const strength = this.getRequiredAttribute(xmlElement, \"strength\",\r\n `The RelationshipClass ${this._currentItemFullName} is missing the required 'strength' attribute.`);\r\n let strengthDirection = this.getOptionalAttribute(xmlElement, \"strengthDirection\");\r\n if (!strengthDirection)\r\n strengthDirection = strengthDirectionToString(StrengthDirection.Forward);\r\n\r\n const sourceResult = this.getElementChildrenByTagName(xmlElement, \"Source\");\r\n if (sourceResult.length !== 1) {\r\n if (sourceResult.length === 0)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The RelationshipClass ${this._currentItemFullName} is missing the required Source constraint tag.`);\r\n else\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The RelationshipClass ${this._currentItemFullName} has more than one Source constraint tag. Only one is allowed.`);\r\n }\r\n const source = this.getRelationshipConstraintProps(sourceResult[0], true);\r\n\r\n const targetResult = this.getElementChildrenByTagName(xmlElement, \"Target\");\r\n if (targetResult.length !== 1) {\r\n if (targetResult.length === 0)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The RelationshipClass ${this._currentItemFullName} is missing the required Target constraint tag.`);\r\n else\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The RelationshipClass ${this._currentItemFullName} has more than one Target constraint tag. Only one is allowed.`);\r\n }\r\n const target = this.getRelationshipConstraintProps(targetResult[0], false);\r\n\r\n return {\r\n ...classProps,\r\n strength,\r\n strengthDirection,\r\n source,\r\n target,\r\n };\r\n }\r\n\r\n public parseEnumeration(xmlElement: Element): EnumerationProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n const enumType = this.getRequiredAttribute(xmlElement, \"backingTypeName\",\r\n `The Enumeration ${this._currentItemFullName} is missing the required 'backingTypeName' attribute.`);\r\n\r\n // TODO: This shouldn't be verified here. It's for the deserialize method to handle. The only reason it's currently done here so that the xml\r\n // value can be put in the correct type, number or string.\r\n let tempBackingType: PrimitiveType;\r\n if (/int/i.test(enumType)) {\r\n tempBackingType = PrimitiveType.Integer;\r\n } else if (/string/i.test(enumType)) {\r\n tempBackingType = PrimitiveType.String;\r\n } else {\r\n if (SchemaReadHelper.isECSpecVersionNewer(this._ecSpecVersion))\r\n tempBackingType = PrimitiveType.String;\r\n else\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'backingTypeName' attribute. It should be either \"int\" or \"string\".`);\r\n }\r\n\r\n let isStrictString: string | undefined = this.getOptionalAttribute(xmlElement, \"isStrict\");\r\n if (isStrictString === undefined)\r\n isStrictString = \"true\";\r\n\r\n const isStrict = this.parseBoolean(isStrictString,\r\n `The Enumeration ${this._currentItemFullName} has an invalid 'isStrict' attribute. It should either be \"true\" or \"false\".`);\r\n\r\n const enumeratorElements = this.getElementChildrenByTagName(xmlElement, \"ECEnumerator\");\r\n const enumerators = new Array<EnumeratorProps>();\r\n\r\n for (const element of enumeratorElements) {\r\n const name = this.getRequiredAttribute(element, \"name\",\r\n `The Enumeration ${this._currentItemFullName} has an enumerator that is missing the required attribute 'name'.`);\r\n\r\n const valueString = this.getRequiredAttribute(element, \"value\",\r\n `The Enumeration ${this._currentItemFullName} has an enumerator that is missing the required attribute 'value'.`);\r\n let value: string | number = valueString;\r\n\r\n if (PrimitiveType.Integer === tempBackingType) {\r\n const numericValue = parseInt(valueString, 10);\r\n if (isNaN(numericValue))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Enumeration ${this._currentItemFullName} of type \"int\" has an enumerator with a non-integer value.`);\r\n value = numericValue;\r\n }\r\n\r\n const label = this.getOptionalAttribute(element, \"displayLabel\");\r\n const description = this.getOptionalAttribute(element, \"description\");\r\n\r\n enumerators.push({\r\n name,\r\n value,\r\n label,\r\n description,\r\n });\r\n }\r\n\r\n return {\r\n ...itemProps,\r\n type: enumType,\r\n isStrict,\r\n enumerators,\r\n originalECSpecMajorVersion: this._ecSpecVersion?.readVersion,\r\n originalECSpecMinorVersion: this._ecSpecVersion?.writeVersion,\r\n };\r\n }\r\n\r\n public parseKindOfQuantity(xmlElement: Element): KindOfQuantityProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n const relativeErrorString = this.getRequiredAttribute(xmlElement, \"relativeError\",\r\n `The KindOfQuantity ${this._currentItemFullName} is missing the required 'relativeError' attribute.`);\r\n const relativeError = parseFloat(relativeErrorString);\r\n if (isNaN(relativeError))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The KindOfQuantity ${this._currentItemFullName} has an invalid 'relativeError' attribute. It should be a numeric value.`);\r\n\r\n const presentationUnitsString = this.getOptionalAttribute(xmlElement, \"presentationUnits\");\r\n let presentationUnits: string[] | undefined;\r\n if (presentationUnitsString)\r\n presentationUnits = this.getQualifiedPresentationUnits(presentationUnitsString.split(\";\"));\r\n\r\n let persistenceUnit = this.getRequiredAttribute(xmlElement, \"persistenceUnit\",\r\n `The KindOfQuantity ${this._currentItemFullName} is missing the required 'persistenceUnit' attribute.`);\r\n persistenceUnit = this.getQualifiedTypeName(persistenceUnit);\r\n\r\n return {\r\n ...itemProps,\r\n relativeError,\r\n presentationUnits,\r\n persistenceUnit,\r\n };\r\n }\r\n\r\n public parsePropertyCategory(xmlElement: Element): PropertyCategoryProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n const priorityString = this.getRequiredAttribute(xmlElement, \"priority\",\r\n `The PropertyCategory ${this._currentItemFullName} is missing the required 'priority' attribute.`);\r\n const priority = parseInt(priorityString, 10);\r\n if (isNaN(priority))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The PropertyCategory ${this._currentItemFullName} has an invalid 'priority' attribute. It should be a numeric value.`);\r\n\r\n return {\r\n ...itemProps,\r\n priority,\r\n };\r\n }\r\n\r\n public parseUnit(xmlElement: Element): SchemaItemUnitProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n let phenomenon = this.getRequiredAttribute(xmlElement, \"phenomenon\",\r\n `The Unit ${this._currentItemFullName} is missing the required 'phenomenon' attribute.`);\r\n let unitSystem = this.getRequiredAttribute(xmlElement, \"unitSystem\",\r\n `The Unit ${this._currentItemFullName} is missing the required 'unitSystem' attribute.`);\r\n const definition = this.getRequiredAttribute(xmlElement, \"definition\",\r\n `The Unit ${this._currentItemFullName} is missing the required 'definition' attribute.`);\r\n const numerator = this.getOptionalFloatAttribute(xmlElement, \"numerator\",\r\n `The Unit ${this._currentItemFullName} has an invalid 'numerator' attribute. It should be a numeric value.`);\r\n const denominator = this.getOptionalFloatAttribute(xmlElement, \"denominator\",\r\n `The Unit ${this._currentItemFullName} has an invalid 'denominator' attribute. It should be a numeric value.`);\r\n const offset = this.getOptionalFloatAttribute(xmlElement, \"offset\",\r\n `The Unit ${this._currentItemFullName} has an invalid 'offset' attribute. It should be a numeric value.`);\r\n\r\n phenomenon = this.getQualifiedTypeName(phenomenon);\r\n unitSystem = this.getQualifiedTypeName(unitSystem);\r\n\r\n return {\r\n ...itemProps,\r\n phenomenon,\r\n unitSystem,\r\n definition,\r\n numerator,\r\n denominator,\r\n offset,\r\n };\r\n }\r\n\r\n public parseInvertedUnit(xmlElement: Element): InvertedUnitProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n let invertsUnit = this.getRequiredAttribute(xmlElement, \"invertsUnit\",\r\n `The InvertedUnit ${this._currentItemFullName} is missing the required 'invertsUnit' attribute.`);\r\n let unitSystem = this.getRequiredAttribute(xmlElement, \"unitSystem\",\r\n `The InvertedUnit ${this._currentItemFullName} is missing the required 'unitSystem' attribute.`);\r\n\r\n invertsUnit = this.getQualifiedTypeName(invertsUnit);\r\n unitSystem = this.getQualifiedTypeName(unitSystem);\r\n\r\n return {\r\n ...itemProps,\r\n invertsUnit,\r\n unitSystem,\r\n };\r\n }\r\n\r\n public parseConstant(xmlElement: Element): ConstantProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n let phenomenon = this.getRequiredAttribute(xmlElement, \"phenomenon\",\r\n `The Constant ${this._currentItemFullName} is missing the required 'phenomenon' attribute.`);\r\n const definition = this.getRequiredAttribute(xmlElement, \"definition\",\r\n `The Constant ${this._currentItemFullName} is missing the required 'definition' attribute.`);\r\n const numerator = this.getOptionalFloatAttribute(xmlElement, \"numerator\",\r\n `The Constant ${this._currentItemFullName} has an invalid 'numerator' attribute. It should be a numeric value.`);\r\n const denominator = this.getOptionalFloatAttribute(xmlElement, \"denominator\",\r\n `The Constant ${this._currentItemFullName} has an invalid 'denominator' attribute. It should be a numeric value.`);\r\n\r\n phenomenon = this.getQualifiedTypeName(phenomenon);\r\n\r\n return {\r\n ...itemProps,\r\n phenomenon,\r\n definition,\r\n numerator,\r\n denominator,\r\n };\r\n }\r\n\r\n public parsePhenomenon(xmlElement: Element): PhenomenonProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n const definition = this.getRequiredAttribute(xmlElement, \"definition\",\r\n `The Phenomenon ${this._currentItemFullName} is missing the required 'definition' attribute.`);\r\n\r\n return {\r\n ...itemProps,\r\n definition,\r\n };\r\n }\r\n\r\n public parseFormat(xmlElement: Element): SchemaItemFormatProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n const formatType = this.getRequiredAttribute(xmlElement, \"type\",\r\n `The Format ${this._currentItemFullName} is missing the required 'type' attribute.`);\r\n const precision = this.getOptionalIntAttribute(xmlElement, \"precision\",\r\n `The Format ${this._currentItemFullName} has an invalid 'precision' attribute. It should be a numeric value.`);\r\n const roundFactor = this.getOptionalFloatAttribute(xmlElement, \"roundFactor\",\r\n `The Format ${this._currentItemFullName} has an invalid 'roundFactor' attribute. It should be a numeric value.`);\r\n const minWidth = this.getOptionalIntAttribute(xmlElement, \"minWidth\",\r\n `The Format ${this._currentItemFullName} has an invalid 'minWidth' attribute. It should be a numeric value.`);\r\n const showSignOption = this.getOptionalAttribute(xmlElement, \"showSignOption\");\r\n\r\n const formatTraitsString = this.getRequiredAttribute(xmlElement, \"formatTraits\",\r\n `The Format ${this._currentItemFullName} is missing the required 'formatTraits' attribute.`);\r\n const formatTraits = formatTraitsString.split(\"|\");\r\n\r\n const decimalSeparator = this.getOptionalAttribute(xmlElement, \"decimalSeparator\");\r\n const thousandSeparator = this.getOptionalAttribute(xmlElement, \"thousandSeparator\");\r\n const uomSeparator = this.getOptionalAttribute(xmlElement, \"uomSeparator\");\r\n const scientificType = this.getOptionalAttribute(xmlElement, \"scientificType\");\r\n\r\n const stationOffsetSize = this.getOptionalIntAttribute(xmlElement, \"stationOffsetSize\",\r\n `The Format ${this._currentItemFullName} has an invalid 'stationOffsetSize' attribute. It should be a numeric value.`);\r\n\r\n const stationSeparator = this.getOptionalAttribute(xmlElement, \"stationSeparator\");\r\n\r\n let composite: object | undefined;\r\n const compositeResult = this.getElementChildrenByTagName(xmlElement, \"Composite\");\r\n if (compositeResult.length > 0) {\r\n const compositeElement = compositeResult[0];\r\n\r\n const spacer = this.getOptionalAttribute(compositeElement, \"spacer\");\r\n\r\n const includeZeroString = this.getOptionalAttribute(compositeElement, \"includeZero\");\r\n let includeZero: boolean | undefined;\r\n if (includeZeroString) {\r\n includeZero = this.parseBoolean(includeZeroString,\r\n `The Format ${this._currentItemFullName} has a Composite with an invalid 'includeZero' attribute. It should be either \"true\" or \"false\".`);\r\n }\r\n\r\n const units = new Array<{ name: string, label?: string }>();\r\n const unitsResult = this.getElementChildrenByTagName(compositeElement, \"Unit\");\r\n if (unitsResult.length < 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Format ${this._currentItemFullName} has an invalid 'Composite' element. It should have 1-4 Unit elements.`);\r\n\r\n for (const unit of unitsResult) {\r\n let name = unit.textContent;\r\n if (null === name || 0 === name.length)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Format ${this._currentItemFullName} has a Composite with an invalid Unit. One of the Units is missing the required 'name' attribute.`);\r\n\r\n const label = this.getOptionalAttribute(unit, \"label\");\r\n name = this.getQualifiedTypeName(name);\r\n units.push({ name, label });\r\n }\r\n\r\n composite = {\r\n spacer,\r\n includeZero,\r\n units,\r\n };\r\n }\r\n\r\n return {\r\n ...itemProps,\r\n type: formatType,\r\n precision,\r\n roundFactor,\r\n minWidth,\r\n showSignOption,\r\n formatTraits,\r\n decimalSeparator,\r\n thousandSeparator,\r\n uomSeparator,\r\n scientificType,\r\n stationOffsetSize,\r\n stationSeparator,\r\n composite,\r\n } as SchemaItemFormatProps;\r\n }\r\n\r\n public parseUnitSystem(xmlElement: Element): UnitSystemProps {\r\n return this.getClassProps(xmlElement);\r\n }\r\n\r\n public *getProperties(xmlElement: Element, itemName: string): Iterable<[string, string, Element]> {\r\n const propertyTagRegex = /EC((Struct(Array)?)|Array|Navigation)?Property/;\r\n const children = this.getElementChildrenByTagName(xmlElement, propertyTagRegex);\r\n\r\n for (const child of children) {\r\n const childType = child.nodeName;\r\n const propertyName = this.getRequiredAttribute(child, \"propertyName\",\r\n `An ECProperty in ${itemName} is missing the required 'propertyName' attribute.`);\r\n\r\n const propertyType = this.getPropertyType(childType);\r\n // This may not be needed, just a failsafe if the regex is faulty\r\n if (propertyType === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ECProperty ${itemName}.${propertyName} has an invalid type. ${childType} is not a valid ECProperty type.`);\r\n\r\n yield [propertyName, propertyType, child];\r\n }\r\n }\r\n\r\n public parsePrimitiveProperty(xmlElement: Element): PrimitivePropertyProps {\r\n const typeName = this.getPropertyTypeName(xmlElement);\r\n const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement, typeName);\r\n const primitivePropertyProps = { ...propertyProps, typeName };\r\n return primitivePropertyProps;\r\n }\r\n\r\n public parseStructProperty(xmlElement: Element): StructPropertyProps {\r\n const propertyProps = this.getPropertyProps(xmlElement);\r\n const typeName = this.getPropertyTypeName(xmlElement);\r\n const structPropertyProps = { ...propertyProps, typeName };\r\n return structPropertyProps;\r\n }\r\n\r\n public parsePrimitiveArrayProperty(xmlElement: Element): PrimitiveArrayPropertyProps {\r\n const typeName = this.getPropertyTypeName(xmlElement);\r\n const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement, typeName);\r\n const minAndMaxOccurs = this.getPropertyMinAndMaxOccurs(xmlElement);\r\n\r\n return {\r\n ...propertyProps,\r\n ...minAndMaxOccurs,\r\n typeName,\r\n };\r\n }\r\n\r\n public parseStructArrayProperty(xmlElement: Element): StructArrayPropertyProps {\r\n const propertyProps = this.getPropertyProps(xmlElement);\r\n const typeName = this.getPropertyTypeName(xmlElement);\r\n const minAndMaxOccurs = this.getPropertyMinAndMaxOccurs(xmlElement);\r\n return {\r\n ...propertyProps,\r\n ...minAndMaxOccurs,\r\n typeName,\r\n };\r\n }\r\n\r\n public parseNavigationProperty(xmlElement: Element): NavigationPropertyProps {\r\n const propName = this.getPropertyName(xmlElement);\r\n const propertyProps = this.getPropertyProps(xmlElement);\r\n let relationshipName = this.getRequiredAttribute(xmlElement, \"relationshipName\",\r\n `The ECNavigationProperty ${this._currentItemFullName}.${propName} is missing the required 'relationshipName' property.`);\r\n const direction = this.getRequiredAttribute(xmlElement, \"direction\",\r\n `The ECNavigationProperty ${this._currentItemFullName}.${propName} is missing the required 'direction' property.`);\r\n\r\n relationshipName = this.getQualifiedTypeName(relationshipName);\r\n\r\n return {\r\n ...propertyProps,\r\n relationshipName,\r\n direction,\r\n };\r\n }\r\n\r\n public getSchemaCustomAttributeProviders(): Iterable<CAProviderTuple> {\r\n return this.getCustomAttributeProviders(this._rawSchema.documentElement, \"Schema\", this._schemaName);\r\n }\r\n\r\n public getClassCustomAttributeProviders(xmlElement: Element): Iterable<CAProviderTuple> {\r\n return this.getCustomAttributeProviders(xmlElement, \"ECClass\", this._currentItemFullName);\r\n }\r\n\r\n public getPropertyCustomAttributeProviders(xmlElement: Element): Iterable<CAProviderTuple> {\r\n const propName = this.getPropertyName(xmlElement);\r\n return this.getCustomAttributeProviders(xmlElement, \"ECProperty\", `${this._currentItemFullName}.${propName}`);\r\n }\r\n\r\n public getRelationshipConstraintCustomAttributeProviders(xmlElement: Element): [Iterable<CAProviderTuple> /* source */, Iterable<CAProviderTuple> /* target */] {\r\n const sourceResult = this.getElementChildrenByTagName(xmlElement, \"Source\");\r\n if (sourceResult.length < 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The RelationshipClass ${this._currentItemFullName} is missing the required Source constraint tag.`);\r\n const sourceElement = sourceResult[0];\r\n const sourceCustomAttributes = this.getCustomAttributeProviders(sourceElement, \"Source Constraint of\", this._currentItemFullName);\r\n\r\n const targetResult = this.getElementChildrenByTagName(xmlElement, \"Target\");\r\n if (targetResult.length < 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The RelationshipClass ${this._currentItemFullName} is missing the required Target constraint tag.`);\r\n const targetElement = targetResult[0];\r\n const targetCustomAttributes = this.getCustomAttributeProviders(targetElement, \"Source Constraint of\", this._currentItemFullName);\r\n\r\n return [sourceCustomAttributes, targetCustomAttributes];\r\n }\r\n\r\n private getElementChildren(xmlElement: Element): Element[] {\r\n // NodeListOf<T> does not define [Symbol.iterator]\r\n const children = Array.from(xmlElement.childNodes).filter((child) => {\r\n // (node.nodeType === 1) implies instanceof Element\r\n // https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/children#Polyfill\r\n return child.nodeType === 1;\r\n });\r\n return children as Element[];\r\n }\r\n\r\n private getElementChildrenByTagName(xmlElement: Element, tagName: string | RegExp): Element[] {\r\n const children = this.getElementChildren(xmlElement);\r\n if (\"*\" === tagName)\r\n return children;\r\n\r\n let result: Element[];\r\n if (typeof tagName === \"string\") {\r\n result = children.filter((child) => {\r\n return tagName.toLowerCase() === child.nodeName.toLowerCase();\r\n });\r\n } else {\r\n result = children.filter((child) => {\r\n return tagName.test(child.nodeName);\r\n });\r\n }\r\n\r\n return result;\r\n }\r\n\r\n private getOptionalAttribute(xmlElement: Element, attributeName: string): string | undefined {\r\n if (!xmlElement.hasAttribute(attributeName))\r\n return undefined;\r\n const result = xmlElement.getAttribute(attributeName);\r\n\r\n // The typings for the return value of getAttribute do not match that of xmldom\r\n // xmldom returns an empty string instead of null\r\n // However Typescript will still treat result as a union type without this check\r\n // Hence this is needed for tsc to compile\r\n if (result === null)\r\n return undefined;\r\n return result;\r\n }\r\n\r\n private getOptionalFloatAttribute(xmlElement: Element, attributeName: string, parseErrorMsg: string): number | undefined {\r\n const resultString = this.getOptionalAttribute(xmlElement, attributeName);\r\n let result: number | undefined;\r\n if (resultString) {\r\n result = parseFloat(resultString);\r\n if (isNaN(result))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, parseErrorMsg);\r\n }\r\n return result;\r\n }\r\n\r\n private getOptionalIntAttribute(xmlElement: Element, attributeName: string, parseErrorMsg: string): number | undefined {\r\n const resultString = this.getOptionalAttribute(xmlElement, attributeName);\r\n let result: number | undefined;\r\n if (resultString) {\r\n result = parseInt(resultString, 10);\r\n if (isNaN(result))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, parseErrorMsg);\r\n }\r\n return result;\r\n }\r\n\r\n private parseBoolean(text: string, parseErrorMsg: string): boolean {\r\n const textString = text.toLowerCase();\r\n if (\"true\" === textString)\r\n return true;\r\n else if (\"false\" === textString)\r\n return false;\r\n else\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, parseErrorMsg);\r\n }\r\n\r\n private getRequiredAttribute(xmlElement: Element, attributeName: string, errorMsg: string): string {\r\n if (!xmlElement.hasAttribute(attributeName))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, errorMsg);\r\n const result = xmlElement.getAttribute(attributeName);\r\n if (result === null)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, errorMsg);\r\n return result;\r\n }\r\n\r\n private getSchemaReference(xmlElement: Element): SchemaReferenceProps {\r\n const alias = this.getRequiredAttribute(xmlElement, \"alias\",\r\n `The schema ${this._schemaName} has an invalid ECSchemaReference attribute. One of the references is missing the required 'alias' attribute.`);\r\n const name = this.getRequiredAttribute(xmlElement, \"name\",\r\n `The schema ${this._schemaName} has an invalid ECSchemaReference attribute. One of the references is missing the required 'name' attribute.`);\r\n const version = this.getRequiredAttribute(xmlElement, \"version\",\r\n `The schema ${this._schemaName} has an invalid ECSchemaReference attribute. One of the references is missing the required 'version' attribute.`);\r\n\r\n if (!this._schemaReferenceNames.has(alias.toLowerCase()))\r\n this._schemaReferenceNames.set(alias.toLowerCase(), name);\r\n\r\n return {\r\n name,\r\n version,\r\n };\r\n }\r\n\r\n private getSchemaItemType(rawType: string): string | undefined {\r\n switch (rawType.toLowerCase()) {\r\n case \"ecentityclass\": return \"EntityClass\";\r\n case \"mixin\": return \"Mixin\";\r\n case \"ecstructclass\": return \"StructClass\";\r\n case \"eccustomattributeclass\": return \"CustomAttributeClass\";\r\n case \"ecrelationshipclass\": return \"RelationshipClass\";\r\n case \"ecenumeration\": return \"Enumeration\";\r\n case \"kindofquantity\": return \"KindOfQuantity\";\r\n case \"propertycategory\": return \"PropertyCategory\";\r\n case \"unit\": return \"Unit\";\r\n case \"invertedunit\": return \"InvertedUnit\";\r\n case \"constant\": return \"Constant\";\r\n case \"phenomenon\": return \"Phenomenon\";\r\n case \"unitsystem\": return \"UnitSystem\";\r\n case \"format\": return \"Format\";\r\n }\r\n return undefined;\r\n }\r\n\r\n private getSchemaChildren(): Element[] {\r\n const schemaMetadata = this._rawSchema.documentElement;\r\n return this.getElementChildren(schemaMetadata);\r\n }\r\n\r\n private getSchemaItemProps(xmlElement: Element): SchemaItemProps {\r\n const displayLabel = this.getOptionalAttribute(xmlElement, \"displayLabel\");\r\n const description = this.getOptionalAttribute(xmlElement, \"description\");\r\n\r\n return {\r\n description,\r\n label: displayLabel,\r\n };\r\n }\r\n\r\n private getClassProps(xmlElement: Element): ClassProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n const modifier = this.getOptionalAttribute(xmlElement, \"modifier\");\r\n\r\n let baseClass: string | null | undefined = null;\r\n const baseClasses = this.getElementChildrenByTagName(xmlElement, \"BaseClass\");\r\n if (baseClasses.length > 0) {\r\n // We are assuming here that the first BaseClass is the 'real' one - the rest are mixins\r\n // This is not a finalized approach as this could lead to unsupported schemas\r\n baseClass = baseClasses[0].textContent;\r\n }\r\n\r\n baseClass = baseClass ? this.getQualifiedTypeName(baseClass) : undefined;\r\n\r\n return {\r\n ...itemProps,\r\n modifier,\r\n baseClass,\r\n originalECSpecMajorVersion: this._ecSpecVersion?.readVersion,\r\n originalECSpecMinorVersion: this._ecSpecVersion?.writeVersion,\r\n };\r\n }\r\n\r\n private getRelationshipConstraintProps(xmlElement: Element, isSource: boolean): RelationshipConstraintProps {\r\n const constraintName = `${(isSource) ? \"Source\" : \"Target\"} Constraint of ${this._currentItemFullName}`;\r\n\r\n const multiplicity = this.getRequiredAttribute(xmlElement, \"multiplicity\",\r\n `The ${constraintName} is missing the required 'multiplicity' attribute.`);\r\n const roleLabel = this.getRequiredAttribute(xmlElement, \"roleLabel\",\r\n `The ${constraintName} is missing the required 'roleLabel' attribute.`);\r\n\r\n const polymorphicString = this.getRequiredAttribute(xmlElement, \"polymorphic\",\r\n `The ${constraintName} is missing the required 'polymorphic' attribute.`);\r\n const polymorphic = this.parseBoolean(polymorphicString,\r\n `The ${constraintName} has an invalid 'polymorphic' attribute. It should either be \"true\" or \"false\".`);\r\n\r\n let abstractConstraint = this.getOptionalAttribute(xmlElement, \"abstractConstraint\");\r\n if (undefined !== abstractConstraint)\r\n abstractConstraint = this.getQualifiedTypeName(abstractConstraint);\r\n\r\n const constraintClasses = new Array<string>();\r\n const constraintClassesResult = this.getElementChildrenByTagName(xmlElement, \"Class\");\r\n if (constraintClassesResult.length < 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ${constraintName} is missing the required Class tags.`);\r\n\r\n for (const constraintClass of constraintClassesResult) {\r\n let constraintClassId = constraintClass.getAttribute(\"class\");\r\n if (null === constraintClassId || 0 === constraintClassId.length)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ${constraintName} has a Class that is missing the required 'class' attribute.`);\r\n\r\n constraintClassId = this.getQualifiedTypeName(constraintClassId);\r\n constraintClasses.push(constraintClassId);\r\n }\r\n\r\n return {\r\n multiplicity,\r\n roleLabel,\r\n polymorphic,\r\n abstractConstraint,\r\n constraintClasses,\r\n };\r\n }\r\n\r\n private getPropertyType(propType: string): string | undefined {\r\n switch (propType) {\r\n case \"ECNavigationProperty\": return \"navigationproperty\";\r\n case \"ECStructProperty\": return \"structproperty\";\r\n case \"ECArrayProperty\": return \"primitivearrayproperty\";\r\n case \"ECStructArrayProperty\": return \"structarrayproperty\";\r\n case \"ECProperty\": return \"primitiveproperty\";\r\n default: return undefined;\r\n }\r\n }\r\n\r\n private getPropertyName(xmlElement: Element): string {\r\n return this.getRequiredAttribute(xmlElement, \"propertyName\",\r\n `An ECProperty in ${this._currentItemFullName} is missing the required 'propertyName' attribute.`);\r\n }\r\n\r\n private getPropertyProps(xmlElement: Element): PropertyProps {\r\n const propName = this.getPropertyName(xmlElement);\r\n\r\n const propType = this.getPropertyType(xmlElement.nodeName);\r\n if (propType === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid type. ${propType} is not a valid ECProperty type.`);\r\n\r\n const label = this.getOptionalAttribute(xmlElement, \"displayLabel\");\r\n const description = this.getOptionalAttribute(xmlElement, \"description\");\r\n\r\n const readOnlyString = this.getOptionalAttribute(xmlElement, \"readOnly\");\r\n let isReadOnly: boolean | undefined;\r\n if (readOnlyString) {\r\n isReadOnly = this.parseBoolean(readOnlyString,\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'readOnly' attribute. It should be either \"true\" or \"false\".`);\r\n }\r\n\r\n let category = this.getOptionalAttribute(xmlElement, \"category\");\r\n\r\n const priority = this.getOptionalIntAttribute(xmlElement, \"priority\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'priority' attribute. It should be a numeric value.`);\r\n\r\n const inheritedString = this.getOptionalAttribute(xmlElement, \"inherited\");\r\n let inherited: boolean | undefined;\r\n if (inheritedString) {\r\n inherited = this.parseBoolean(inheritedString,\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'inherited' attribute. It should be either \"true\" or \"false\".`);\r\n }\r\n\r\n let kindOfQuantity = this.getOptionalAttribute(xmlElement, \"kindOfQuantity\");\r\n\r\n if (kindOfQuantity)\r\n kindOfQuantity = this.getQualifiedTypeName(kindOfQuantity);\r\n if (category)\r\n category = this.getQualifiedTypeName(category);\r\n\r\n return {\r\n name: propName,\r\n type: propType,\r\n description,\r\n label,\r\n isReadOnly,\r\n category,\r\n priority,\r\n inherited,\r\n kindOfQuantity,\r\n };\r\n }\r\n\r\n private getPropertyTypeName(xmlElement: Element): string {\r\n const propName = this.getPropertyName(xmlElement);\r\n const rawTypeName = this.getRequiredAttribute(xmlElement, \"typeName\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} is missing the required 'typeName' attribute.`);\r\n\r\n // If not a primitive type, we must prepend the schema name.\r\n const primitiveType = parsePrimitiveType(rawTypeName);\r\n if (primitiveType)\r\n return rawTypeName;\r\n\r\n return this.getQualifiedTypeName(rawTypeName);\r\n }\r\n\r\n private getPrimitiveOrEnumPropertyBaseProps(xmlElement: Element, typeName: string): PrimitiveOrEnumPropertyBaseProps {\r\n const primitiveType = parsePrimitiveType(typeName);\r\n const propertyProps = this.getPropertyProps(xmlElement);\r\n const propName = propertyProps.name;\r\n const extendedTypeName = this.getOptionalAttribute(xmlElement, \"extendedTypeName\");\r\n const minLength = this.getOptionalIntAttribute(xmlElement, \"minimumLength\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumLength' attribute. It should be a numeric value.`);\r\n const maxLength = this.getOptionalIntAttribute(xmlElement, \"maximumLength\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumLength' attribute. It should be a numeric value.`);\r\n\r\n let minValue: number | undefined;\r\n let maxValue: number | undefined;\r\n if (primitiveType === PrimitiveType.Double || primitiveType === PrimitiveType.Long) {\r\n minValue = this.getOptionalFloatAttribute(xmlElement, \"minimumValue\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumValue' attribute. It should be a numeric value.`);\r\n maxValue = this.getOptionalFloatAttribute(xmlElement, \"maximumValue\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumValue' attribute. It should be a numeric value.`);\r\n } else {\r\n minValue = this.getOptionalIntAttribute(xmlElement, \"minimumValue\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumValue' attribute. It should be a numeric value.`);\r\n maxValue = this.getOptionalIntAttribute(xmlElement, \"maximumValue\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumValue' attribute. It should be a numeric value.`);\r\n }\r\n\r\n return {\r\n ...propertyProps,\r\n extendedTypeName,\r\n minLength,\r\n maxLength,\r\n minValue,\r\n maxValue,\r\n };\r\n }\r\n\r\n private getPropertyMinAndMaxOccurs(xmlElement: Element): { minOccurs: number | undefined, maxOccurs: number | undefined } {\r\n const propName = this.getPropertyName(xmlElement);\r\n const minOccurs = this.getOptionalIntAttribute(xmlElement, \"minOccurs\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minOccurs' attribute. It should be a numeric value.`);\r\n\r\n const maxOccursStr = this.getOptionalAttribute(xmlElement, \"maxOccurs\");\r\n let maxOccurs: number | undefined;\r\n if (\"unbounded\" === maxOccursStr)\r\n maxOccurs = 2147483647; // TODO: This should be using the INT32_MAX variable.\r\n else if (undefined !== maxOccursStr) {\r\n maxOccurs = parseInt(maxOccursStr, 10);\r\n if (isNaN(maxOccurs))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maxOccurs' attribute. It should be a numeric value.`);\r\n }\r\n\r\n return { minOccurs, maxOccurs };\r\n }\r\n\r\n private *getCustomAttributeProviders(xmlElement: Element, type: string, _name?: string): Iterable<CAProviderTuple> {\r\n const customAttributesResult = this.getElementChildrenByTagName(xmlElement, \"ECCustomAttributes\");\r\n if (customAttributesResult.length < 1)\r\n return;\r\n\r\n const attributes = this.getElementChildren(customAttributesResult[0]);\r\n for (const attribute of attributes) {\r\n if (\"ECClass\" === type && \"IsMixin\" === attribute.tagName)\r\n continue;\r\n\r\n yield this.getCustomAttributeProvider(attribute);\r\n }\r\n }\r\n\r\n private getCustomAttributeProvider(xmlCustomAttribute: Element): CAProviderTuple {\r\n assert(this._ecSpecVersion !== undefined);\r\n\r\n let ns = xmlCustomAttribute.getAttribute(\"xmlns\");\r\n if (!ns) {\r\n assert(this._schemaName !== undefined);\r\n assert(this._schemaVersion !== undefined);\r\n ns = `${this._schemaName}.${this._schemaVersion}`;\r\n }\r\n\r\n if (null === ns || !this.isSchemaFullNameValidForVersion(ns, this._ecSpecVersion))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Custom attribute namespaces must contain a valid 3.2 full schema name in the form <schemaName>.RR.ww.mm.`);\r\n\r\n const schemaNameParts = ns.split(\".\");\r\n const className = `${schemaNameParts[0]}.${xmlCustomAttribute.tagName}`;\r\n const properties = this.getElementChildren(xmlCustomAttribute);\r\n\r\n const provider = (caClass: CustomAttributeClass) => {\r\n return this.addCAPropertyValues(caClass, properties);\r\n };\r\n\r\n return [className, provider];\r\n }\r\n\r\n private addCAPropertyValues(caClass: CustomAttributeClass, propertyElements: Element[]): CustomAttribute {\r\n const instance = { className: caClass.fullName } as CustomAttribute;\r\n for (const propertyElement of propertyElements) {\r\n const value = this.readPropertyValue(propertyElement, caClass);\r\n if (value !== undefined)\r\n instance[propertyElement.tagName] = value;\r\n }\r\n\r\n return instance;\r\n }\r\n\r\n private readPropertyValue(propElement: Element, parentClass: ECClass): any {\r\n const propertyClass = parentClass.getPropertySync(propElement.tagName);\r\n if (!propertyClass)\r\n return;\r\n\r\n if (propertyClass.isArray())\r\n return this.readArrayPropertyValue(propElement, propertyClass);\r\n\r\n let enumeration: Enumeration | undefined;\r\n if (propertyClass.isPrimitive()) {\r\n if (propertyClass.isEnumeration() && propertyClass.enumeration) {\r\n enumeration = propertyClass.schema.lookupItemSync(propertyClass.enumeration.fullName, Enumeration);\r\n if (!enumeration)\r\n throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `The Enumeration class '${propertyClass.enumeration.fullName}' could not be found.`);\r\n }\r\n const primitiveType = enumeration && enumeration.type ? enumeration.type : (propertyClass).primitiveType;\r\n return this.readPrimitivePropertyValue(propElement, primitiveType);\r\n }\r\n\r\n if (propertyClass.isStruct())\r\n return this.readStructPropertyValue(propElement, propertyClass.structClass);\r\n\r\n return undefined;\r\n }\r\n\r\n private readArrayPropertyValue(propElement: Element, propertyClass: Property): PrimitiveArray | undefined {\r\n if (propertyClass.isPrimitive())\r\n return this.readPrimitiveArrayValues(propElement, (propertyClass as PrimitiveProperty).primitiveType);\r\n\r\n if (propertyClass.isStruct())\r\n return this.readStructArrayValues(propElement, propertyClass as StructArrayProperty);\r\n\r\n return undefined;\r\n }\r\n\r\n private readPrimitiveArrayValues(propElement: Element, primitiveType: PrimitiveType): PrimitiveArray {\r\n const typeName = primitiveTypeToString(primitiveType);\r\n const children = this.getElementChildrenByTagName(propElement, typeName);\r\n const values: PrimitiveArray = [];\r\n for (const child of children) {\r\n const value = this.readPrimitivePropertyValue(child, primitiveType);\r\n values.push(value);\r\n }\r\n\r\n return values;\r\n }\r\n\r\n private readStructArrayValues(propElement: Element, propertyClass: StructArrayProperty): any {\r\n const children = this.getElementChildren(propElement);\r\n const values: any = [];\r\n for (const child of children) {\r\n const value = this.readStructPropertyValue(child, propertyClass.structClass);\r\n values.push(value);\r\n }\r\n\r\n return values;\r\n }\r\n\r\n private readStructPropertyValue(propElement: Element, structClass: StructClass): any {\r\n const structObj: any = {};\r\n const children = this.getElementChildren(propElement);\r\n for (const child of children) {\r\n const value = this.readPropertyValue(child, structClass);\r\n if (value !== undefined)\r\n structObj[child.tagName] = value;\r\n }\r\n return structObj;\r\n }\r\n\r\n private readPrimitivePropertyValue(propElement: Element, primitiveType: PrimitiveType): PrimitiveValue {\r\n if (undefined === propElement.textContent || null === propElement.textContent)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Primitive property '${propElement.tagName}' has an invalid property value.`);\r\n\r\n if (propElement.textContent === \"\" && primitiveType !== PrimitiveType.String)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Primitive property '${propElement.tagName}' has an invalid property value.`);\r\n\r\n // TODO: Mapping all primitive types to string, number and boolean\r\n // for now. Need to review with IModelJs.\r\n switch (primitiveType) {\r\n case PrimitiveType.String:\r\n case PrimitiveType.Binary: /** TODO - Currently treated as strings */\r\n case PrimitiveType.IGeometry: /** TODO - Currently treated as strings */\r\n return propElement.textContent;\r\n case PrimitiveType.DateTime:\r\n return this.getDatePropertyValue(propElement.textContent, propElement.tagName);\r\n case PrimitiveType.Point2d:\r\n return this.getPoint2DPropertyValue(propElement.textContent, propElement.tagName);\r\n case PrimitiveType.Point3d:\r\n return this.getPoint3DPropertyValue(propElement.textContent, propElement.tagName);\r\n case PrimitiveType.Boolean:\r\n return this.getBooleanPropertyValue(propElement.textContent, propElement.tagName);\r\n case PrimitiveType.Integer:\r\n case PrimitiveType.Long:\r\n return this.getIntegerPropertyValue(propElement.textContent, propElement.tagName);\r\n case PrimitiveType.Double:\r\n return this.getDoublePropertyValue(propElement.textContent, propElement.tagName);\r\n default:\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Primitive property '${propElement.tagName}' has an invalid primitive type.`);\r\n }\r\n }\r\n\r\n private getBooleanPropertyValue(propValue: string, propName: string): boolean {\r\n if (propValue.toLowerCase() === \"true\" ||\r\n Number.parseInt(propValue, 10) > 0) {\r\n return true;\r\n } else if (propValue.toLowerCase() === \"false\" ||\r\n Number.parseInt(propValue, 10) === 0) {\r\n return false;\r\n }\r\n\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. An boolean value was expected.`);\r\n }\r\n\r\n private getIntegerPropertyValue(propValue: string, propName: string): number {\r\n const result = Number.parseFloat(propValue);\r\n if (isNaN(result) || result % 1 !== 0)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. An integer value was expected.`);\r\n\r\n return result;\r\n }\r\n\r\n private getDatePropertyValue(propValue: string, propName: string): Date {\r\n const result = Number.parseInt(propValue, 10);\r\n if (isNaN(result))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. A date in milliseconds was expected.`);\r\n\r\n return new Date(result);\r\n }\r\n\r\n private getDoublePropertyValue(propValue: string, propName: string): number {\r\n const result = Number.parseFloat(propValue);\r\n if (isNaN(result))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. A double value was expected.`);\r\n\r\n return result;\r\n }\r\n\r\n private getPoint2DPropertyValue(propValue: string, propName: string): any {\r\n const result = propValue.split(\",\");\r\n if (result.length !== 2) {\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. A Point 2D value was expected.`);\r\n }\r\n\r\n const x = Number.parseFloat(result[0]);\r\n const y = Number.parseFloat(result[1]);\r\n\r\n if (isNaN(x) || isNaN(y))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. A Point 2D value was expected.`);\r\n\r\n return { x, y };\r\n }\r\n\r\n private getPoint3DPropertyValue(propValue: string, propName: string): any {\r\n const result = propValue.split(\",\");\r\n if (result.length !== 3) {\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. A Point 3D value was expected.`);\r\n }\r\n\r\n const x = Number.parseFloat(result[0]);\r\n const y = Number.parseFloat(result[1]);\r\n const z = Number.parseFloat(result[2]);\r\n\r\n if (isNaN(x) || isNaN(y) || isNaN(z))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. A Point 3D value was expected.`);\r\n\r\n return { x, y, z };\r\n }\r\n\r\n private isSchemaFullNameValidForVersion(schemaFullName: string, ecSpecVersion: ECSpecVersion) {\r\n const schemaNameParts = schemaFullName.split(\".\");\r\n\r\n if ((ecSpecVersion.readVersion >= 3 && ecSpecVersion.writeVersion >= 2) || ecSpecVersion.readVersion > 3) {\r\n if (schemaNameParts.length < 4)\r\n return false;\r\n } else {\r\n if (schemaNameParts.length < 3)\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n public static parseXmlNamespace(xmlNamespace: string): ECSpecVersion | undefined {\r\n const regEx = new RegExp(`^${ECXML_URI}\\\\.([0-9]+)\\\\.([0-9]+)$`);\r\n const match = xmlNamespace.match(regEx);\r\n if (!match)\r\n return;\r\n\r\n const readVersion = parseInt(match[1], 10);\r\n const writeVersion = parseInt(match[2], 10);\r\n return { readVersion, writeVersion };\r\n }\r\n\r\n private getQualifiedTypeName(rawTypeName: string): string {\r\n const nameParts = rawTypeName.split(\":\");\r\n if (nameParts.length !== 2)\r\n return `${this._schemaName}.${rawTypeName}`;\r\n\r\n if (nameParts[0].toLowerCase() === this._schemaAlias.toLowerCase())\r\n return `${this._schemaName}.${nameParts[1]}`;\r\n if (this._schemaReferenceNames.has(nameParts[0].toLowerCase()))\r\n return `${this._schemaReferenceNames.get(nameParts[0].toLowerCase())}.${nameParts[1]}`;\r\n\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `No valid schema found for alias ${nameParts[0]}`);\r\n }\r\n\r\n /** The rest of the API uses the full name format of `{SchemaName}.{SchemaItemName}`,\r\n * meaning all of the references in the format string need to be changed.\r\n */\r\n private getQualifiedPresentationUnits(presentationUnits: string[]): string[] {\r\n const res: string[] = [];\r\n for (const presentationUnit of presentationUnits) {\r\n // we split the presentation unit by square parantheses [ ], f:DefaultReal(6)[u:FT|feet] will be splitted into f:DefaultReal(6) and u:FT|feet\r\n // we format the first one and the next one will be put into [ ] again\r\n const presentationUnitFormats = presentationUnit.split(/[\\[\\]]/g);\r\n let qualifiedPresentation: string = \"\";\r\n qualifiedPresentation = this.getQualifiedTypeName(presentationUnitFormats[0]);\r\n if (presentationUnitFormats.length > 1) {\r\n for (let i = 1; i < presentationUnitFormats.length; ++i) {\r\n if (presentationUnitFormats[i].length === 0)\r\n continue;\r\n const verticalSlashIdx = presentationUnitFormats[i].indexOf(\"|\");\r\n const overrideFormat = this.getQualifiedTypeName(presentationUnitFormats[i].slice(0, verticalSlashIdx));\r\n const formatLabel = presentationUnitFormats[i].slice(verticalSlashIdx);\r\n qualifiedPresentation += `[${overrideFormat}${formatLabel}]`;\r\n }\r\n }\r\n\r\n res.push(qualifiedPresentation);\r\n }\r\n\r\n return res;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"XmlParser.js","sourceRoot":"","sources":["../../../src/Deserialization/XmlParser.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA6C;AAC7C,4CAAsI;AACtI,4CAA6D;AAI7D,yDAAsD;AAEtD,sCAAmC;AACnC,qDAAmE;AAOnE,qCAA2D;AAE3D,MAAM,wBAAwB,GAAG,CAAC,mBAAmB,EAAE,oBAAoB,CAAC,CAAC;AAC7E,MAAM,SAAS,GAAG,oDAAoD,CAAC;AAKvE,gBAAgB;AAChB,MAAa,SAAU,SAAQ,+BAAuB;IAC5C,UAAU,CAAW;IACrB,WAAW,CAA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I,qBAAqB,GAAW,EAAE,CAAC;YACvC,qBAAqB,GAAG,IAAI,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9E,IAAI,uBAAuB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,uBAAuB,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;oBACxD,IAAI,uBAAuB,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC;wBACzC,SAAS;oBACX,MAAM,gBAAgB,GAAG,uBAAuB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;oBACjE,MAAM,cAAc,GAAG,IAAI,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC;oBACxG,MAAM,WAAW,GAAG,uBAAuB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;oBACvE,qBAAqB,IAAI,IAAI,cAAc,GAAG,WAAW,GAAG,CAAC;gBAC/D,CAAC;YACH,CAAC;YAED,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAClC,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AArvCD,8BAqvCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { parsePrimitiveType, PrimitiveType, primitiveTypeToString, StrengthDirection, strengthDirectionToString } from \"../ECObjects\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\r\nimport { ECClass, StructClass } from \"../Metadata/Class\";\r\nimport { CustomAttribute } from \"../Metadata/CustomAttribute\";\r\nimport { CustomAttributeClass } from \"../Metadata/CustomAttributeClass\";\r\nimport { Enumeration } from \"../Metadata/Enumeration\";\r\nimport { PrimitiveProperty, Property, StructArrayProperty } from \"../Metadata/Property\";\r\nimport { ECName } from \"../ECName\";\r\nimport { AbstractParser, CAProviderTuple } from \"./AbstractParser\";\r\nimport {\r\n ClassProps, ConstantProps, CustomAttributeClassProps, EntityClassProps, EnumerationProps, EnumeratorProps, InvertedUnitProps,\r\n KindOfQuantityProps, MixinProps, NavigationPropertyProps, PhenomenonProps, PrimitiveArrayPropertyProps, PrimitiveOrEnumPropertyBaseProps,\r\n PrimitivePropertyProps, PropertyCategoryProps, PropertyProps, RelationshipClassProps, RelationshipConstraintProps, SchemaItemFormatProps, SchemaItemProps,\r\n SchemaItemUnitProps, SchemaProps, SchemaReferenceProps, StructArrayPropertyProps, StructClassProps, StructPropertyProps, UnitSystemProps,\r\n} from \"./JsonProps\";\r\nimport { ECSpecVersion, SchemaReadHelper } from \"./Helper\";\r\n\r\nconst NON_ITEM_SCHEMA_ELEMENTS = [\"ECSchemaReference\", \"ECCustomAttributes\"];\r\nconst ECXML_URI = \"http://www\\\\.bentley\\\\.com/schemas/Bentley\\\\.ECXML\";\r\n\r\ntype PrimitiveArray = PrimitiveValue[];\r\ntype PrimitiveValue = string | number | boolean | Date;\r\n\r\n/** @internal */\r\nexport class XmlParser extends AbstractParser<Element> {\r\n private _rawSchema: Document;\r\n private _schemaName?: string;\r\n private _schemaReferenceNames: Map<string, string>;\r\n private _schemaAlias: string;\r\n private _schemaVersion?: string;\r\n private _xmlNamespace?: string;\r\n private _currentItemFullName?: string;\r\n private _schemaItems: Map<string, [string, Element]>;\r\n private _mapIsPopulated: boolean;\r\n\r\n constructor(rawSchema: Readonly<Document>) {\r\n super();\r\n\r\n this._rawSchema = rawSchema;\r\n const schemaInfo = rawSchema.documentElement;\r\n\r\n const schemaName = schemaInfo.getAttribute(\"schemaName\");\r\n if (schemaName)\r\n this._schemaName = schemaName;\r\n\r\n this._schemaAlias = \"\";\r\n const schemaAlias = schemaInfo.getAttribute(\"alias\");\r\n if (schemaAlias)\r\n this._schemaAlias = schemaAlias;\r\n\r\n this._schemaReferenceNames = new Map<string, string>();\r\n\r\n const schemaVersion = schemaInfo.getAttribute(\"version\");\r\n if (schemaVersion)\r\n this._schemaVersion = schemaVersion;\r\n\r\n const xmlNamespace = schemaInfo.getAttribute(\"xmlns\");\r\n if (xmlNamespace) {\r\n this._xmlNamespace = xmlNamespace;\r\n this._ecSpecVersion = XmlParser.parseXmlNamespace(this._xmlNamespace);\r\n }\r\n\r\n this._schemaItems = new Map<string, [string, Element]>();\r\n this._mapIsPopulated = false;\r\n }\r\n\r\n public get getECSpecVersion(): ECSpecVersion | undefined { return this._ecSpecVersion; }\r\n\r\n public parseSchema(): SchemaProps {\r\n const schemaMetadata = this._rawSchema.documentElement;\r\n if (\"ECSchema\" !== schemaMetadata.nodeName)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, \"An ECSchema is missing the required metadata.\");\r\n\r\n const schemaDefDuplicates = this.getElementChildrenByTagName(schemaMetadata, \"ECSchema\");\r\n if (schemaDefDuplicates.length > 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, \"An ECSchema has more than one ECSchema definition. Only one is allowed.\");\r\n\r\n if (this._schemaName === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `An ECSchema is missing a required 'schemaName' attribute`);\r\n\r\n if (this._schemaVersion === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ECSchema ${this._schemaName} is missing a required 'version' attribute`);\r\n\r\n if (this._xmlNamespace === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ECSchema ${this._schemaName} is missing a required 'xmlns' attribute`);\r\n\r\n if (this._ecSpecVersion === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ECSchema ${this._schemaName} has an invalid 'xmlns' attribute`);\r\n\r\n const alias = this.getRequiredAttribute(schemaMetadata, \"alias\",\r\n `The ECSchema ${this._schemaName} is missing a required 'alias' attribute`);\r\n const description = this.getOptionalAttribute(schemaMetadata, \"description\");\r\n const displayLabel = this.getOptionalAttribute(schemaMetadata, \"displayLabel\");\r\n\r\n const schemaProps = {\r\n name: this._schemaName,\r\n $schema: this._xmlNamespace,\r\n version: this._schemaVersion,\r\n alias,\r\n label: displayLabel,\r\n description,\r\n ecSpecMajorVersion: this._ecSpecVersion.readVersion,\r\n ecSpecMinorVersion: this._ecSpecVersion.writeVersion,\r\n };\r\n\r\n return schemaProps;\r\n }\r\n\r\n public *getReferences(): Iterable<SchemaReferenceProps> {\r\n const schemaReferences = this.getElementChildrenByTagName(this._rawSchema.documentElement, \"ECSchemaReference\");\r\n for (const ref of schemaReferences) {\r\n yield this.getSchemaReference(ref);\r\n }\r\n }\r\n\r\n public *getItems(): Iterable<[string, string, Element]> {\r\n if (!this._mapIsPopulated) {\r\n const schemaItems = this.getSchemaChildren();\r\n for (const item of schemaItems) {\r\n let rawItemType = item.nodeName;\r\n if (NON_ITEM_SCHEMA_ELEMENTS.includes(rawItemType))\r\n continue;\r\n\r\n // Differentiate a Mixin from an EntityClass\r\n const customAttributesResult = this.getElementChildrenByTagName(item, \"ECCustomAttributes\");\r\n if (customAttributesResult.length > 0) {\r\n const customAttributes = customAttributesResult[0];\r\n const isMixinResult = this.getElementChildrenByTagName(customAttributes, \"IsMixin\");\r\n if (isMixinResult.length > 0)\r\n rawItemType = \"Mixin\";\r\n }\r\n\r\n const itemType = this.getSchemaItemType(rawItemType);\r\n if (itemType === undefined) {\r\n if (SchemaReadHelper.isECSpecVersionNewer(this._ecSpecVersion))\r\n continue;\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `A SchemaItem in ${this._schemaName} has an invalid type. '${rawItemType}' is not a valid SchemaItem type.`);\r\n }\r\n\r\n const itemName = this.getRequiredAttribute(item, \"typeName\", `A SchemaItem in ${this._schemaName} is missing the required 'typeName' attribute.`);\r\n\r\n if (!ECName.validate(itemName))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECName, `A SchemaItem in ${this._schemaName} has an invalid 'typeName' attribute. '${itemName}' is not a valid ECName.`);\r\n\r\n this._currentItemFullName = `${this._schemaName}.${itemName}`;\r\n this._schemaItems.set(itemName, [itemType, item]);\r\n yield [itemName, itemType, item];\r\n }\r\n this._mapIsPopulated = true;\r\n } else {\r\n for (const [itemName, [itemType, item]] of this._schemaItems) {\r\n this._currentItemFullName = `${this._schemaName}.${itemName}`;\r\n yield [itemName, itemType, item];\r\n }\r\n }\r\n }\r\n\r\n public findItem(itemName: string): [string, string, Element] | undefined {\r\n if (!this._mapIsPopulated) {\r\n for (const item of this.getItems()) {\r\n if (item[0] === itemName) {\r\n this._currentItemFullName = `${this._schemaName}.${itemName}`;\r\n return item;\r\n }\r\n }\r\n } else {\r\n const values = this._schemaItems.get(itemName);\r\n if (undefined !== values) {\r\n const [itemType, item] = values;\r\n this._currentItemFullName = `${this._schemaName}.${itemName}`;\r\n return [itemName, itemType, item];\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n public parseEntityClass(xmlElement: Element): EntityClassProps {\r\n const classProps = this.getClassProps(xmlElement);\r\n const baseClasses = this.getElementChildrenByTagName(xmlElement, \"BaseClass\");\r\n let mixinElements: Element[];\r\n const mixins = new Array<string>();\r\n\r\n // if it has just one BaseClass we assume it is a 'true' base class not a mixin\r\n if (baseClasses.length > 1) {\r\n mixinElements = baseClasses.slice(1);\r\n for (const mixin of mixinElements) {\r\n if (mixin.textContent) {\r\n const typeName = this.getQualifiedTypeName(mixin.textContent);\r\n mixins.push(typeName);\r\n }\r\n }\r\n }\r\n\r\n const entityClassProps = {\r\n ...classProps,\r\n mixins,\r\n };\r\n\r\n return entityClassProps;\r\n }\r\n\r\n public parseMixin(xmlElement: Element): MixinProps {\r\n const classProps = this.getClassProps(xmlElement);\r\n\r\n const baseClasses = this.getElementChildrenByTagName(xmlElement, \"BaseClass\");\r\n\r\n // Mixins can only have one base class\r\n if (baseClasses.length > 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Mixin ${this._currentItemFullName} has more than one base class which is not allowed.`);\r\n\r\n const customAttributesResult = this.getElementChildrenByTagName(xmlElement, \"ECCustomAttributes\");\r\n\r\n if (customAttributesResult.length < 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Mixin ${this._currentItemFullName} is missing the required 'IsMixin' tag.`);\r\n\r\n const customAttributes = customAttributesResult[0];\r\n const isMixinResult = this.getElementChildrenByTagName(customAttributes, \"IsMixin\");\r\n if (isMixinResult.length < 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Mixin ${this._currentItemFullName} is missing the required 'IsMixin' tag.`);\r\n\r\n const mixinAttributes = isMixinResult[0];\r\n const appliesToResult = this.getElementChildrenByTagName(mixinAttributes, \"AppliesToEntityClass\");\r\n\r\n if (appliesToResult.length < 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Mixin ${this._currentItemFullName} is missing the required 'AppliesToEntityClass' tag.`);\r\n\r\n const appliesToElement = appliesToResult[0];\r\n let appliesTo = appliesToElement.textContent;\r\n if (appliesTo === null || appliesTo.length === 0)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Mixin ${this._currentItemFullName} is missing the required 'AppliesToEntityClass' tag.`);\r\n\r\n appliesTo = this.getQualifiedTypeName(appliesTo);\r\n\r\n const mixinProps = {\r\n ...classProps,\r\n appliesTo,\r\n };\r\n\r\n return mixinProps;\r\n }\r\n\r\n public parseStructClass(xmlElement: Element): StructClassProps {\r\n return this.getClassProps(xmlElement);\r\n }\r\n\r\n public parseCustomAttributeClass(xmlElement: Element): CustomAttributeClassProps {\r\n const classProps = this.getClassProps(xmlElement);\r\n const appliesTo = this.getRequiredAttribute(xmlElement, \"appliesTo\",\r\n `The CustomAttributeClass ${this._currentItemFullName} is missing the required 'appliesTo' attribute.`);\r\n\r\n const customAttributeClassProps = {\r\n ...classProps,\r\n appliesTo,\r\n };\r\n\r\n return customAttributeClassProps;\r\n }\r\n\r\n public parseRelationshipClass(xmlElement: Element): RelationshipClassProps {\r\n const classProps = this.getClassProps(xmlElement);\r\n const strength = this.getRequiredAttribute(xmlElement, \"strength\",\r\n `The RelationshipClass ${this._currentItemFullName} is missing the required 'strength' attribute.`);\r\n let strengthDirection = this.getOptionalAttribute(xmlElement, \"strengthDirection\");\r\n if (!strengthDirection)\r\n strengthDirection = strengthDirectionToString(StrengthDirection.Forward);\r\n\r\n const sourceResult = this.getElementChildrenByTagName(xmlElement, \"Source\");\r\n if (sourceResult.length !== 1) {\r\n if (sourceResult.length === 0)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The RelationshipClass ${this._currentItemFullName} is missing the required Source constraint tag.`);\r\n else\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The RelationshipClass ${this._currentItemFullName} has more than one Source constraint tag. Only one is allowed.`);\r\n }\r\n const source = this.getRelationshipConstraintProps(sourceResult[0], true);\r\n\r\n const targetResult = this.getElementChildrenByTagName(xmlElement, \"Target\");\r\n if (targetResult.length !== 1) {\r\n if (targetResult.length === 0)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The RelationshipClass ${this._currentItemFullName} is missing the required Target constraint tag.`);\r\n else\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The RelationshipClass ${this._currentItemFullName} has more than one Target constraint tag. Only one is allowed.`);\r\n }\r\n const target = this.getRelationshipConstraintProps(targetResult[0], false);\r\n\r\n return {\r\n ...classProps,\r\n strength,\r\n strengthDirection,\r\n source,\r\n target,\r\n };\r\n }\r\n\r\n public parseEnumeration(xmlElement: Element): EnumerationProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n const enumType = this.getRequiredAttribute(xmlElement, \"backingTypeName\",\r\n `The Enumeration ${this._currentItemFullName} is missing the required 'backingTypeName' attribute.`);\r\n\r\n // TODO: This shouldn't be verified here. It's for the deserialize method to handle. The only reason it's currently done here so that the xml\r\n // value can be put in the correct type, number or string.\r\n let tempBackingType: PrimitiveType;\r\n if (/int/i.test(enumType)) {\r\n tempBackingType = PrimitiveType.Integer;\r\n } else if (/string/i.test(enumType)) {\r\n tempBackingType = PrimitiveType.String;\r\n } else {\r\n if (SchemaReadHelper.isECSpecVersionNewer(this._ecSpecVersion))\r\n tempBackingType = PrimitiveType.String;\r\n else\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'backingTypeName' attribute. It should be either \"int\" or \"string\".`);\r\n }\r\n\r\n let isStrictString: string | undefined = this.getOptionalAttribute(xmlElement, \"isStrict\");\r\n if (isStrictString === undefined)\r\n isStrictString = \"true\";\r\n\r\n const isStrict = this.parseBoolean(isStrictString,\r\n `The Enumeration ${this._currentItemFullName} has an invalid 'isStrict' attribute. It should either be \"true\" or \"false\".`);\r\n\r\n const enumeratorElements = this.getElementChildrenByTagName(xmlElement, \"ECEnumerator\");\r\n const enumerators = new Array<EnumeratorProps>();\r\n\r\n for (const element of enumeratorElements) {\r\n const name = this.getRequiredAttribute(element, \"name\",\r\n `The Enumeration ${this._currentItemFullName} has an enumerator that is missing the required attribute 'name'.`);\r\n\r\n const valueString = this.getRequiredAttribute(element, \"value\",\r\n `The Enumeration ${this._currentItemFullName} has an enumerator that is missing the required attribute 'value'.`);\r\n let value: string | number = valueString;\r\n\r\n if (PrimitiveType.Integer === tempBackingType) {\r\n const numericValue = parseInt(valueString, 10);\r\n if (isNaN(numericValue))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Enumeration ${this._currentItemFullName} of type \"int\" has an enumerator with a non-integer value.`);\r\n value = numericValue;\r\n }\r\n\r\n const label = this.getOptionalAttribute(element, \"displayLabel\");\r\n const description = this.getOptionalAttribute(element, \"description\");\r\n\r\n enumerators.push({\r\n name,\r\n value,\r\n label,\r\n description,\r\n });\r\n }\r\n\r\n return {\r\n ...itemProps,\r\n type: enumType,\r\n isStrict,\r\n enumerators,\r\n originalECSpecMajorVersion: this._ecSpecVersion?.readVersion,\r\n originalECSpecMinorVersion: this._ecSpecVersion?.writeVersion,\r\n };\r\n }\r\n\r\n public parseKindOfQuantity(xmlElement: Element): KindOfQuantityProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n const relativeErrorString = this.getRequiredAttribute(xmlElement, \"relativeError\",\r\n `The KindOfQuantity ${this._currentItemFullName} is missing the required 'relativeError' attribute.`);\r\n const relativeError = parseFloat(relativeErrorString);\r\n if (isNaN(relativeError))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The KindOfQuantity ${this._currentItemFullName} has an invalid 'relativeError' attribute. It should be a numeric value.`);\r\n\r\n const presentationUnitsString = this.getOptionalAttribute(xmlElement, \"presentationUnits\");\r\n let presentationUnits: string[] | undefined;\r\n if (presentationUnitsString)\r\n presentationUnits = this.getQualifiedPresentationUnits(presentationUnitsString.split(\";\"));\r\n\r\n let persistenceUnit = this.getRequiredAttribute(xmlElement, \"persistenceUnit\",\r\n `The KindOfQuantity ${this._currentItemFullName} is missing the required 'persistenceUnit' attribute.`);\r\n persistenceUnit = this.getQualifiedTypeName(persistenceUnit);\r\n\r\n return {\r\n ...itemProps,\r\n relativeError,\r\n presentationUnits,\r\n persistenceUnit,\r\n };\r\n }\r\n\r\n public parsePropertyCategory(xmlElement: Element): PropertyCategoryProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n const priorityString = this.getRequiredAttribute(xmlElement, \"priority\",\r\n `The PropertyCategory ${this._currentItemFullName} is missing the required 'priority' attribute.`);\r\n const priority = parseInt(priorityString, 10);\r\n if (isNaN(priority))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The PropertyCategory ${this._currentItemFullName} has an invalid 'priority' attribute. It should be a numeric value.`);\r\n\r\n return {\r\n ...itemProps,\r\n priority,\r\n };\r\n }\r\n\r\n public parseUnit(xmlElement: Element): SchemaItemUnitProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n let phenomenon = this.getRequiredAttribute(xmlElement, \"phenomenon\",\r\n `The Unit ${this._currentItemFullName} is missing the required 'phenomenon' attribute.`);\r\n let unitSystem = this.getRequiredAttribute(xmlElement, \"unitSystem\",\r\n `The Unit ${this._currentItemFullName} is missing the required 'unitSystem' attribute.`);\r\n const definition = this.getRequiredAttribute(xmlElement, \"definition\",\r\n `The Unit ${this._currentItemFullName} is missing the required 'definition' attribute.`);\r\n const numerator = this.getOptionalFloatAttribute(xmlElement, \"numerator\",\r\n `The Unit ${this._currentItemFullName} has an invalid 'numerator' attribute. It should be a numeric value.`);\r\n const denominator = this.getOptionalFloatAttribute(xmlElement, \"denominator\",\r\n `The Unit ${this._currentItemFullName} has an invalid 'denominator' attribute. It should be a numeric value.`);\r\n const offset = this.getOptionalFloatAttribute(xmlElement, \"offset\",\r\n `The Unit ${this._currentItemFullName} has an invalid 'offset' attribute. It should be a numeric value.`);\r\n\r\n phenomenon = this.getQualifiedTypeName(phenomenon);\r\n unitSystem = this.getQualifiedTypeName(unitSystem);\r\n\r\n return {\r\n ...itemProps,\r\n phenomenon,\r\n unitSystem,\r\n definition,\r\n numerator,\r\n denominator,\r\n offset,\r\n };\r\n }\r\n\r\n public parseInvertedUnit(xmlElement: Element): InvertedUnitProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n let invertsUnit = this.getRequiredAttribute(xmlElement, \"invertsUnit\",\r\n `The InvertedUnit ${this._currentItemFullName} is missing the required 'invertsUnit' attribute.`);\r\n let unitSystem = this.getRequiredAttribute(xmlElement, \"unitSystem\",\r\n `The InvertedUnit ${this._currentItemFullName} is missing the required 'unitSystem' attribute.`);\r\n\r\n invertsUnit = this.getQualifiedTypeName(invertsUnit);\r\n unitSystem = this.getQualifiedTypeName(unitSystem);\r\n\r\n return {\r\n ...itemProps,\r\n invertsUnit,\r\n unitSystem,\r\n };\r\n }\r\n\r\n public parseConstant(xmlElement: Element): ConstantProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n let phenomenon = this.getRequiredAttribute(xmlElement, \"phenomenon\",\r\n `The Constant ${this._currentItemFullName} is missing the required 'phenomenon' attribute.`);\r\n const definition = this.getRequiredAttribute(xmlElement, \"definition\",\r\n `The Constant ${this._currentItemFullName} is missing the required 'definition' attribute.`);\r\n const numerator = this.getOptionalFloatAttribute(xmlElement, \"numerator\",\r\n `The Constant ${this._currentItemFullName} has an invalid 'numerator' attribute. It should be a numeric value.`);\r\n const denominator = this.getOptionalFloatAttribute(xmlElement, \"denominator\",\r\n `The Constant ${this._currentItemFullName} has an invalid 'denominator' attribute. It should be a numeric value.`);\r\n\r\n phenomenon = this.getQualifiedTypeName(phenomenon);\r\n\r\n return {\r\n ...itemProps,\r\n phenomenon,\r\n definition,\r\n numerator,\r\n denominator,\r\n };\r\n }\r\n\r\n public parsePhenomenon(xmlElement: Element): PhenomenonProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n const definition = this.getRequiredAttribute(xmlElement, \"definition\",\r\n `The Phenomenon ${this._currentItemFullName} is missing the required 'definition' attribute.`);\r\n\r\n return {\r\n ...itemProps,\r\n definition,\r\n };\r\n }\r\n\r\n public parseFormat(xmlElement: Element): SchemaItemFormatProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n\r\n const formatType = this.getRequiredAttribute(xmlElement, \"type\",\r\n `The Format ${this._currentItemFullName} is missing the required 'type' attribute.`);\r\n const precision = this.getOptionalIntAttribute(xmlElement, \"precision\",\r\n `The Format ${this._currentItemFullName} has an invalid 'precision' attribute. It should be a numeric value.`);\r\n const roundFactor = this.getOptionalFloatAttribute(xmlElement, \"roundFactor\",\r\n `The Format ${this._currentItemFullName} has an invalid 'roundFactor' attribute. It should be a numeric value.`);\r\n const minWidth = this.getOptionalIntAttribute(xmlElement, \"minWidth\",\r\n `The Format ${this._currentItemFullName} has an invalid 'minWidth' attribute. It should be a numeric value.`);\r\n const showSignOption = this.getOptionalAttribute(xmlElement, \"showSignOption\");\r\n\r\n const formatTraitsString = this.getRequiredAttribute(xmlElement, \"formatTraits\",\r\n `The Format ${this._currentItemFullName} is missing the required 'formatTraits' attribute.`);\r\n const formatTraits = formatTraitsString.split(\"|\");\r\n\r\n const decimalSeparator = this.getOptionalAttribute(xmlElement, \"decimalSeparator\");\r\n const thousandSeparator = this.getOptionalAttribute(xmlElement, \"thousandSeparator\");\r\n const uomSeparator = this.getOptionalAttribute(xmlElement, \"uomSeparator\");\r\n const scientificType = this.getOptionalAttribute(xmlElement, \"scientificType\");\r\n const ratioType = this.getOptionalAttribute(xmlElement, \"ratioType\");\r\n const ratioSeparator = this.getOptionalAttribute(xmlElement, \"ratioSeparator\");\r\n const ratioFormatType = this.getOptionalAttribute(xmlElement, \"ratioFormatType\");\r\n\r\n // Validate EC version if ratio properties exist - they require EC version 3.3+\r\n if (ratioType !== undefined || ratioSeparator !== undefined || ratioFormatType !== undefined) {\r\n if (this._ecSpecVersion === undefined || this._ecSpecVersion.readVersion < 3 || (this._ecSpecVersion.readVersion === 3 && this._ecSpecVersion.writeVersion < 3)) {\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Format ${this._currentItemFullName} has ratio properties that require EC version 3.3 or newer.`);\r\n }\r\n }\r\n\r\n const stationOffsetSize = this.getOptionalIntAttribute(xmlElement, \"stationOffsetSize\",\r\n `The Format ${this._currentItemFullName} has an invalid 'stationOffsetSize' attribute. It should be a numeric value.`);\r\n\r\n const stationSeparator = this.getOptionalAttribute(xmlElement, \"stationSeparator\");\r\n\r\n let composite: object | undefined;\r\n const compositeResult = this.getElementChildrenByTagName(xmlElement, \"Composite\");\r\n if (compositeResult.length > 0) {\r\n const compositeElement = compositeResult[0];\r\n\r\n const spacer = this.getOptionalAttribute(compositeElement, \"spacer\");\r\n\r\n const includeZeroString = this.getOptionalAttribute(compositeElement, \"includeZero\");\r\n let includeZero: boolean | undefined;\r\n if (includeZeroString) {\r\n includeZero = this.parseBoolean(includeZeroString,\r\n `The Format ${this._currentItemFullName} has a Composite with an invalid 'includeZero' attribute. It should be either \"true\" or \"false\".`);\r\n }\r\n\r\n const units = new Array<{ name: string, label?: string }>();\r\n const unitsResult = this.getElementChildrenByTagName(compositeElement, \"Unit\");\r\n if (unitsResult.length < 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Format ${this._currentItemFullName} has an invalid 'Composite' element. It should have 1-4 Unit elements.`);\r\n\r\n for (const unit of unitsResult) {\r\n let name = unit.textContent;\r\n if (null === name || 0 === name.length)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The Format ${this._currentItemFullName} has a Composite with an invalid Unit. One of the Units is missing the required 'name' attribute.`);\r\n\r\n const label = this.getOptionalAttribute(unit, \"label\");\r\n name = this.getQualifiedTypeName(name);\r\n units.push({ name, label });\r\n }\r\n\r\n composite = {\r\n spacer,\r\n includeZero,\r\n units,\r\n };\r\n }\r\n\r\n return {\r\n ...itemProps,\r\n type: formatType,\r\n precision,\r\n roundFactor,\r\n minWidth,\r\n showSignOption,\r\n formatTraits,\r\n decimalSeparator,\r\n thousandSeparator,\r\n uomSeparator,\r\n scientificType,\r\n ratioType,\r\n ratioSeparator,\r\n ratioFormatType,\r\n stationOffsetSize,\r\n stationSeparator,\r\n composite,\r\n } as SchemaItemFormatProps;\r\n }\r\n\r\n public parseUnitSystem(xmlElement: Element): UnitSystemProps {\r\n return this.getClassProps(xmlElement);\r\n }\r\n\r\n public *getProperties(xmlElement: Element, itemName: string): Iterable<[string, string, Element]> {\r\n const propertyTagRegex = /EC((Struct(Array)?)|Array|Navigation)?Property/;\r\n const children = this.getElementChildrenByTagName(xmlElement, propertyTagRegex);\r\n\r\n for (const child of children) {\r\n const childType = child.nodeName;\r\n const propertyName = this.getRequiredAttribute(child, \"propertyName\",\r\n `An ECProperty in ${itemName} is missing the required 'propertyName' attribute.`);\r\n\r\n const propertyType = this.getPropertyType(childType);\r\n // This may not be needed, just a failsafe if the regex is faulty\r\n if (propertyType === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ECProperty ${itemName}.${propertyName} has an invalid type. ${childType} is not a valid ECProperty type.`);\r\n\r\n yield [propertyName, propertyType, child];\r\n }\r\n }\r\n\r\n public parsePrimitiveProperty(xmlElement: Element): PrimitivePropertyProps {\r\n const typeName = this.getPropertyTypeName(xmlElement);\r\n const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement, typeName);\r\n const primitivePropertyProps = { ...propertyProps, typeName };\r\n return primitivePropertyProps;\r\n }\r\n\r\n public parseStructProperty(xmlElement: Element): StructPropertyProps {\r\n const propertyProps = this.getPropertyProps(xmlElement);\r\n const typeName = this.getPropertyTypeName(xmlElement);\r\n const structPropertyProps = { ...propertyProps, typeName };\r\n return structPropertyProps;\r\n }\r\n\r\n public parsePrimitiveArrayProperty(xmlElement: Element): PrimitiveArrayPropertyProps {\r\n const typeName = this.getPropertyTypeName(xmlElement);\r\n const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement, typeName);\r\n const minAndMaxOccurs = this.getPropertyMinAndMaxOccurs(xmlElement);\r\n\r\n return {\r\n ...propertyProps,\r\n ...minAndMaxOccurs,\r\n typeName,\r\n };\r\n }\r\n\r\n public parseStructArrayProperty(xmlElement: Element): StructArrayPropertyProps {\r\n const propertyProps = this.getPropertyProps(xmlElement);\r\n const typeName = this.getPropertyTypeName(xmlElement);\r\n const minAndMaxOccurs = this.getPropertyMinAndMaxOccurs(xmlElement);\r\n return {\r\n ...propertyProps,\r\n ...minAndMaxOccurs,\r\n typeName,\r\n };\r\n }\r\n\r\n public parseNavigationProperty(xmlElement: Element): NavigationPropertyProps {\r\n const propName = this.getPropertyName(xmlElement);\r\n const propertyProps = this.getPropertyProps(xmlElement);\r\n let relationshipName = this.getRequiredAttribute(xmlElement, \"relationshipName\",\r\n `The ECNavigationProperty ${this._currentItemFullName}.${propName} is missing the required 'relationshipName' property.`);\r\n const direction = this.getRequiredAttribute(xmlElement, \"direction\",\r\n `The ECNavigationProperty ${this._currentItemFullName}.${propName} is missing the required 'direction' property.`);\r\n\r\n relationshipName = this.getQualifiedTypeName(relationshipName);\r\n\r\n return {\r\n ...propertyProps,\r\n relationshipName,\r\n direction,\r\n };\r\n }\r\n\r\n public getSchemaCustomAttributeProviders(): Iterable<CAProviderTuple> {\r\n return this.getCustomAttributeProviders(this._rawSchema.documentElement, \"Schema\", this._schemaName);\r\n }\r\n\r\n public getClassCustomAttributeProviders(xmlElement: Element): Iterable<CAProviderTuple> {\r\n return this.getCustomAttributeProviders(xmlElement, \"ECClass\", this._currentItemFullName);\r\n }\r\n\r\n public getPropertyCustomAttributeProviders(xmlElement: Element): Iterable<CAProviderTuple> {\r\n const propName = this.getPropertyName(xmlElement);\r\n return this.getCustomAttributeProviders(xmlElement, \"ECProperty\", `${this._currentItemFullName}.${propName}`);\r\n }\r\n\r\n public getRelationshipConstraintCustomAttributeProviders(xmlElement: Element): [Iterable<CAProviderTuple> /* source */, Iterable<CAProviderTuple> /* target */] {\r\n const sourceResult = this.getElementChildrenByTagName(xmlElement, \"Source\");\r\n if (sourceResult.length < 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The RelationshipClass ${this._currentItemFullName} is missing the required Source constraint tag.`);\r\n const sourceElement = sourceResult[0];\r\n const sourceCustomAttributes = this.getCustomAttributeProviders(sourceElement, \"Source Constraint of\", this._currentItemFullName);\r\n\r\n const targetResult = this.getElementChildrenByTagName(xmlElement, \"Target\");\r\n if (targetResult.length < 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The RelationshipClass ${this._currentItemFullName} is missing the required Target constraint tag.`);\r\n const targetElement = targetResult[0];\r\n const targetCustomAttributes = this.getCustomAttributeProviders(targetElement, \"Source Constraint of\", this._currentItemFullName);\r\n\r\n return [sourceCustomAttributes, targetCustomAttributes];\r\n }\r\n\r\n private getElementChildren(xmlElement: Element): Element[] {\r\n // NodeListOf<T> does not define [Symbol.iterator]\r\n const children = Array.from(xmlElement.childNodes).filter((child) => {\r\n // (node.nodeType === 1) implies instanceof Element\r\n // https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/children#Polyfill\r\n return child.nodeType === 1;\r\n });\r\n return children as Element[];\r\n }\r\n\r\n private getElementChildrenByTagName(xmlElement: Element, tagName: string | RegExp): Element[] {\r\n const children = this.getElementChildren(xmlElement);\r\n if (\"*\" === tagName)\r\n return children;\r\n\r\n let result: Element[];\r\n if (typeof tagName === \"string\") {\r\n result = children.filter((child) => {\r\n return tagName.toLowerCase() === child.nodeName.toLowerCase();\r\n });\r\n } else {\r\n result = children.filter((child) => {\r\n return tagName.test(child.nodeName);\r\n });\r\n }\r\n\r\n return result;\r\n }\r\n\r\n private getOptionalAttribute(xmlElement: Element, attributeName: string): string | undefined {\r\n if (!xmlElement.hasAttribute(attributeName))\r\n return undefined;\r\n const result = xmlElement.getAttribute(attributeName);\r\n\r\n // The typings for the return value of getAttribute do not match that of xmldom\r\n // xmldom returns an empty string instead of null\r\n // However Typescript will still treat result as a union type without this check\r\n // Hence this is needed for tsc to compile\r\n if (result === null)\r\n return undefined;\r\n return result;\r\n }\r\n\r\n private getOptionalFloatAttribute(xmlElement: Element, attributeName: string, parseErrorMsg: string): number | undefined {\r\n const resultString = this.getOptionalAttribute(xmlElement, attributeName);\r\n let result: number | undefined;\r\n if (resultString) {\r\n result = parseFloat(resultString);\r\n if (isNaN(result))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, parseErrorMsg);\r\n }\r\n return result;\r\n }\r\n\r\n private getOptionalIntAttribute(xmlElement: Element, attributeName: string, parseErrorMsg: string): number | undefined {\r\n const resultString = this.getOptionalAttribute(xmlElement, attributeName);\r\n let result: number | undefined;\r\n if (resultString) {\r\n result = parseInt(resultString, 10);\r\n if (isNaN(result))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, parseErrorMsg);\r\n }\r\n return result;\r\n }\r\n\r\n private parseBoolean(text: string, parseErrorMsg: string): boolean {\r\n const textString = text.toLowerCase();\r\n if (\"true\" === textString)\r\n return true;\r\n else if (\"false\" === textString)\r\n return false;\r\n else\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, parseErrorMsg);\r\n }\r\n\r\n private getRequiredAttribute(xmlElement: Element, attributeName: string, errorMsg: string): string {\r\n if (!xmlElement.hasAttribute(attributeName))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, errorMsg);\r\n const result = xmlElement.getAttribute(attributeName);\r\n if (result === null)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, errorMsg);\r\n return result;\r\n }\r\n\r\n private getSchemaReference(xmlElement: Element): SchemaReferenceProps {\r\n const alias = this.getRequiredAttribute(xmlElement, \"alias\",\r\n `The schema ${this._schemaName} has an invalid ECSchemaReference attribute. One of the references is missing the required 'alias' attribute.`);\r\n const name = this.getRequiredAttribute(xmlElement, \"name\",\r\n `The schema ${this._schemaName} has an invalid ECSchemaReference attribute. One of the references is missing the required 'name' attribute.`);\r\n const version = this.getRequiredAttribute(xmlElement, \"version\",\r\n `The schema ${this._schemaName} has an invalid ECSchemaReference attribute. One of the references is missing the required 'version' attribute.`);\r\n\r\n if (!this._schemaReferenceNames.has(alias.toLowerCase()))\r\n this._schemaReferenceNames.set(alias.toLowerCase(), name);\r\n\r\n return {\r\n name,\r\n version,\r\n };\r\n }\r\n\r\n private getSchemaItemType(rawType: string): string | undefined {\r\n switch (rawType.toLowerCase()) {\r\n case \"ecentityclass\": return \"EntityClass\";\r\n case \"mixin\": return \"Mixin\";\r\n case \"ecstructclass\": return \"StructClass\";\r\n case \"eccustomattributeclass\": return \"CustomAttributeClass\";\r\n case \"ecrelationshipclass\": return \"RelationshipClass\";\r\n case \"ecenumeration\": return \"Enumeration\";\r\n case \"kindofquantity\": return \"KindOfQuantity\";\r\n case \"propertycategory\": return \"PropertyCategory\";\r\n case \"unit\": return \"Unit\";\r\n case \"invertedunit\": return \"InvertedUnit\";\r\n case \"constant\": return \"Constant\";\r\n case \"phenomenon\": return \"Phenomenon\";\r\n case \"unitsystem\": return \"UnitSystem\";\r\n case \"format\": return \"Format\";\r\n }\r\n return undefined;\r\n }\r\n\r\n private getSchemaChildren(): Element[] {\r\n const schemaMetadata = this._rawSchema.documentElement;\r\n return this.getElementChildren(schemaMetadata);\r\n }\r\n\r\n private getSchemaItemProps(xmlElement: Element): SchemaItemProps {\r\n const displayLabel = this.getOptionalAttribute(xmlElement, \"displayLabel\");\r\n const description = this.getOptionalAttribute(xmlElement, \"description\");\r\n\r\n return {\r\n description,\r\n label: displayLabel,\r\n };\r\n }\r\n\r\n private getClassProps(xmlElement: Element): ClassProps {\r\n const itemProps = this.getSchemaItemProps(xmlElement);\r\n const modifier = this.getOptionalAttribute(xmlElement, \"modifier\");\r\n\r\n let baseClass: string | null | undefined = null;\r\n const baseClasses = this.getElementChildrenByTagName(xmlElement, \"BaseClass\");\r\n if (baseClasses.length > 0) {\r\n // We are assuming here that the first BaseClass is the 'real' one - the rest are mixins\r\n // This is not a finalized approach as this could lead to unsupported schemas\r\n baseClass = baseClasses[0].textContent;\r\n }\r\n\r\n baseClass = baseClass ? this.getQualifiedTypeName(baseClass) : undefined;\r\n\r\n return {\r\n ...itemProps,\r\n modifier,\r\n baseClass,\r\n originalECSpecMajorVersion: this._ecSpecVersion?.readVersion,\r\n originalECSpecMinorVersion: this._ecSpecVersion?.writeVersion,\r\n };\r\n }\r\n\r\n private getRelationshipConstraintProps(xmlElement: Element, isSource: boolean): RelationshipConstraintProps {\r\n const constraintName = `${(isSource) ? \"Source\" : \"Target\"} Constraint of ${this._currentItemFullName}`;\r\n\r\n const multiplicity = this.getRequiredAttribute(xmlElement, \"multiplicity\",\r\n `The ${constraintName} is missing the required 'multiplicity' attribute.`);\r\n const roleLabel = this.getRequiredAttribute(xmlElement, \"roleLabel\",\r\n `The ${constraintName} is missing the required 'roleLabel' attribute.`);\r\n\r\n const polymorphicString = this.getRequiredAttribute(xmlElement, \"polymorphic\",\r\n `The ${constraintName} is missing the required 'polymorphic' attribute.`);\r\n const polymorphic = this.parseBoolean(polymorphicString,\r\n `The ${constraintName} has an invalid 'polymorphic' attribute. It should either be \"true\" or \"false\".`);\r\n\r\n let abstractConstraint = this.getOptionalAttribute(xmlElement, \"abstractConstraint\");\r\n if (undefined !== abstractConstraint)\r\n abstractConstraint = this.getQualifiedTypeName(abstractConstraint);\r\n\r\n const constraintClasses = new Array<string>();\r\n const constraintClassesResult = this.getElementChildrenByTagName(xmlElement, \"Class\");\r\n if (constraintClassesResult.length < 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ${constraintName} is missing the required Class tags.`);\r\n\r\n for (const constraintClass of constraintClassesResult) {\r\n let constraintClassId = constraintClass.getAttribute(\"class\");\r\n if (null === constraintClassId || 0 === constraintClassId.length)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ${constraintName} has a Class that is missing the required 'class' attribute.`);\r\n\r\n constraintClassId = this.getQualifiedTypeName(constraintClassId);\r\n constraintClasses.push(constraintClassId);\r\n }\r\n\r\n return {\r\n multiplicity,\r\n roleLabel,\r\n polymorphic,\r\n abstractConstraint,\r\n constraintClasses,\r\n };\r\n }\r\n\r\n private getPropertyType(propType: string): string | undefined {\r\n switch (propType) {\r\n case \"ECNavigationProperty\": return \"navigationproperty\";\r\n case \"ECStructProperty\": return \"structproperty\";\r\n case \"ECArrayProperty\": return \"primitivearrayproperty\";\r\n case \"ECStructArrayProperty\": return \"structarrayproperty\";\r\n case \"ECProperty\": return \"primitiveproperty\";\r\n default: return undefined;\r\n }\r\n }\r\n\r\n private getPropertyName(xmlElement: Element): string {\r\n return this.getRequiredAttribute(xmlElement, \"propertyName\",\r\n `An ECProperty in ${this._currentItemFullName} is missing the required 'propertyName' attribute.`);\r\n }\r\n\r\n private getPropertyProps(xmlElement: Element): PropertyProps {\r\n const propName = this.getPropertyName(xmlElement);\r\n\r\n const propType = this.getPropertyType(xmlElement.nodeName);\r\n if (propType === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid type. ${propType} is not a valid ECProperty type.`);\r\n\r\n const label = this.getOptionalAttribute(xmlElement, \"displayLabel\");\r\n const description = this.getOptionalAttribute(xmlElement, \"description\");\r\n\r\n const readOnlyString = this.getOptionalAttribute(xmlElement, \"readOnly\");\r\n let isReadOnly: boolean | undefined;\r\n if (readOnlyString) {\r\n isReadOnly = this.parseBoolean(readOnlyString,\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'readOnly' attribute. It should be either \"true\" or \"false\".`);\r\n }\r\n\r\n let category = this.getOptionalAttribute(xmlElement, \"category\");\r\n\r\n const priority = this.getOptionalIntAttribute(xmlElement, \"priority\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'priority' attribute. It should be a numeric value.`);\r\n\r\n const inheritedString = this.getOptionalAttribute(xmlElement, \"inherited\");\r\n let inherited: boolean | undefined;\r\n if (inheritedString) {\r\n inherited = this.parseBoolean(inheritedString,\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'inherited' attribute. It should be either \"true\" or \"false\".`);\r\n }\r\n\r\n let kindOfQuantity = this.getOptionalAttribute(xmlElement, \"kindOfQuantity\");\r\n\r\n if (kindOfQuantity)\r\n kindOfQuantity = this.getQualifiedTypeName(kindOfQuantity);\r\n if (category)\r\n category = this.getQualifiedTypeName(category);\r\n\r\n return {\r\n name: propName,\r\n type: propType,\r\n description,\r\n label,\r\n isReadOnly,\r\n category,\r\n priority,\r\n inherited,\r\n kindOfQuantity,\r\n };\r\n }\r\n\r\n private getPropertyTypeName(xmlElement: Element): string {\r\n const propName = this.getPropertyName(xmlElement);\r\n const rawTypeName = this.getRequiredAttribute(xmlElement, \"typeName\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} is missing the required 'typeName' attribute.`);\r\n\r\n // If not a primitive type, we must prepend the schema name.\r\n const primitiveType = parsePrimitiveType(rawTypeName);\r\n if (primitiveType)\r\n return rawTypeName;\r\n\r\n return this.getQualifiedTypeName(rawTypeName);\r\n }\r\n\r\n private getPrimitiveOrEnumPropertyBaseProps(xmlElement: Element, typeName: string): PrimitiveOrEnumPropertyBaseProps {\r\n const primitiveType = parsePrimitiveType(typeName);\r\n const propertyProps = this.getPropertyProps(xmlElement);\r\n const propName = propertyProps.name;\r\n const extendedTypeName = this.getOptionalAttribute(xmlElement, \"extendedTypeName\");\r\n const minLength = this.getOptionalIntAttribute(xmlElement, \"minimumLength\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumLength' attribute. It should be a numeric value.`);\r\n const maxLength = this.getOptionalIntAttribute(xmlElement, \"maximumLength\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumLength' attribute. It should be a numeric value.`);\r\n\r\n let minValue: number | undefined;\r\n let maxValue: number | undefined;\r\n if (primitiveType === PrimitiveType.Double || primitiveType === PrimitiveType.Long) {\r\n minValue = this.getOptionalFloatAttribute(xmlElement, \"minimumValue\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumValue' attribute. It should be a numeric value.`);\r\n maxValue = this.getOptionalFloatAttribute(xmlElement, \"maximumValue\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumValue' attribute. It should be a numeric value.`);\r\n } else {\r\n minValue = this.getOptionalIntAttribute(xmlElement, \"minimumValue\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumValue' attribute. It should be a numeric value.`);\r\n maxValue = this.getOptionalIntAttribute(xmlElement, \"maximumValue\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumValue' attribute. It should be a numeric value.`);\r\n }\r\n\r\n return {\r\n ...propertyProps,\r\n extendedTypeName,\r\n minLength,\r\n maxLength,\r\n minValue,\r\n maxValue,\r\n };\r\n }\r\n\r\n private getPropertyMinAndMaxOccurs(xmlElement: Element): { minOccurs: number | undefined, maxOccurs: number | undefined } {\r\n const propName = this.getPropertyName(xmlElement);\r\n const minOccurs = this.getOptionalIntAttribute(xmlElement, \"minOccurs\",\r\n `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minOccurs' attribute. It should be a numeric value.`);\r\n\r\n const maxOccursStr = this.getOptionalAttribute(xmlElement, \"maxOccurs\");\r\n let maxOccurs: number | undefined;\r\n if (\"unbounded\" === maxOccursStr)\r\n maxOccurs = 2147483647; // TODO: This should be using the INT32_MAX variable.\r\n else if (undefined !== maxOccursStr) {\r\n maxOccurs = parseInt(maxOccursStr, 10);\r\n if (isNaN(maxOccurs))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maxOccurs' attribute. It should be a numeric value.`);\r\n }\r\n\r\n return { minOccurs, maxOccurs };\r\n }\r\n\r\n private *getCustomAttributeProviders(xmlElement: Element, type: string, _name?: string): Iterable<CAProviderTuple> {\r\n const customAttributesResult = this.getElementChildrenByTagName(xmlElement, \"ECCustomAttributes\");\r\n if (customAttributesResult.length < 1)\r\n return;\r\n\r\n const attributes = this.getElementChildren(customAttributesResult[0]);\r\n for (const attribute of attributes) {\r\n if (\"ECClass\" === type && \"IsMixin\" === attribute.tagName)\r\n continue;\r\n\r\n yield this.getCustomAttributeProvider(attribute);\r\n }\r\n }\r\n\r\n private getCustomAttributeProvider(xmlCustomAttribute: Element): CAProviderTuple {\r\n assert(this._ecSpecVersion !== undefined);\r\n\r\n let ns = xmlCustomAttribute.getAttribute(\"xmlns\");\r\n if (!ns) {\r\n assert(this._schemaName !== undefined);\r\n assert(this._schemaVersion !== undefined);\r\n ns = `${this._schemaName}.${this._schemaVersion}`;\r\n }\r\n\r\n if (null === ns || !this.isSchemaFullNameValidForVersion(ns, this._ecSpecVersion))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Custom attribute namespaces must contain a valid 3.2 full schema name in the form <schemaName>.RR.ww.mm.`);\r\n\r\n const schemaNameParts = ns.split(\".\");\r\n const className = `${schemaNameParts[0]}.${xmlCustomAttribute.tagName}`;\r\n const properties = this.getElementChildren(xmlCustomAttribute);\r\n\r\n const provider = (caClass: CustomAttributeClass) => {\r\n return this.addCAPropertyValues(caClass, properties);\r\n };\r\n\r\n return [className, provider];\r\n }\r\n\r\n private addCAPropertyValues(caClass: CustomAttributeClass, propertyElements: Element[]): CustomAttribute {\r\n const instance = { className: caClass.fullName } as CustomAttribute;\r\n for (const propertyElement of propertyElements) {\r\n const value = this.readPropertyValue(propertyElement, caClass);\r\n if (value !== undefined)\r\n instance[propertyElement.tagName] = value;\r\n }\r\n\r\n return instance;\r\n }\r\n\r\n private readPropertyValue(propElement: Element, parentClass: ECClass): any {\r\n const propertyClass = parentClass.getPropertySync(propElement.tagName);\r\n if (!propertyClass)\r\n return;\r\n\r\n if (propertyClass.isArray())\r\n return this.readArrayPropertyValue(propElement, propertyClass);\r\n\r\n let enumeration: Enumeration | undefined;\r\n if (propertyClass.isPrimitive()) {\r\n if (propertyClass.isEnumeration() && propertyClass.enumeration) {\r\n enumeration = propertyClass.schema.lookupItemSync(propertyClass.enumeration.fullName, Enumeration);\r\n if (!enumeration)\r\n throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `The Enumeration class '${propertyClass.enumeration.fullName}' could not be found.`);\r\n }\r\n const primitiveType = enumeration && enumeration.type ? enumeration.type : (propertyClass).primitiveType;\r\n return this.readPrimitivePropertyValue(propElement, primitiveType);\r\n }\r\n\r\n if (propertyClass.isStruct())\r\n return this.readStructPropertyValue(propElement, propertyClass.structClass);\r\n\r\n return undefined;\r\n }\r\n\r\n private readArrayPropertyValue(propElement: Element, propertyClass: Property): PrimitiveArray | undefined {\r\n if (propertyClass.isPrimitive())\r\n return this.readPrimitiveArrayValues(propElement, (propertyClass as PrimitiveProperty).primitiveType);\r\n\r\n if (propertyClass.isStruct())\r\n return this.readStructArrayValues(propElement, propertyClass as StructArrayProperty);\r\n\r\n return undefined;\r\n }\r\n\r\n private readPrimitiveArrayValues(propElement: Element, primitiveType: PrimitiveType): PrimitiveArray {\r\n const typeName = primitiveTypeToString(primitiveType);\r\n const children = this.getElementChildrenByTagName(propElement, typeName);\r\n const values: PrimitiveArray = [];\r\n for (const child of children) {\r\n const value = this.readPrimitivePropertyValue(child, primitiveType);\r\n values.push(value);\r\n }\r\n\r\n return values;\r\n }\r\n\r\n private readStructArrayValues(propElement: Element, propertyClass: StructArrayProperty): any {\r\n const children = this.getElementChildren(propElement);\r\n const values: any = [];\r\n for (const child of children) {\r\n const value = this.readStructPropertyValue(child, propertyClass.structClass);\r\n values.push(value);\r\n }\r\n\r\n return values;\r\n }\r\n\r\n private readStructPropertyValue(propElement: Element, structClass: StructClass): any {\r\n const structObj: any = {};\r\n const children = this.getElementChildren(propElement);\r\n for (const child of children) {\r\n const value = this.readPropertyValue(child, structClass);\r\n if (value !== undefined)\r\n structObj[child.tagName] = value;\r\n }\r\n return structObj;\r\n }\r\n\r\n private readPrimitivePropertyValue(propElement: Element, primitiveType: PrimitiveType): PrimitiveValue {\r\n if (undefined === propElement.textContent || null === propElement.textContent)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Primitive property '${propElement.tagName}' has an invalid property value.`);\r\n\r\n if (propElement.textContent === \"\" && primitiveType !== PrimitiveType.String)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Primitive property '${propElement.tagName}' has an invalid property value.`);\r\n\r\n // TODO: Mapping all primitive types to string, number and boolean\r\n // for now. Need to review with IModelJs.\r\n switch (primitiveType) {\r\n case PrimitiveType.String:\r\n case PrimitiveType.Binary: /** TODO - Currently treated as strings */\r\n case PrimitiveType.IGeometry: /** TODO - Currently treated as strings */\r\n return propElement.textContent;\r\n case PrimitiveType.DateTime:\r\n return this.getDatePropertyValue(propElement.textContent, propElement.tagName);\r\n case PrimitiveType.Point2d:\r\n return this.getPoint2DPropertyValue(propElement.textContent, propElement.tagName);\r\n case PrimitiveType.Point3d:\r\n return this.getPoint3DPropertyValue(propElement.textContent, propElement.tagName);\r\n case PrimitiveType.Boolean:\r\n return this.getBooleanPropertyValue(propElement.textContent, propElement.tagName);\r\n case PrimitiveType.Integer:\r\n case PrimitiveType.Long:\r\n return this.getIntegerPropertyValue(propElement.textContent, propElement.tagName);\r\n case PrimitiveType.Double:\r\n return this.getDoublePropertyValue(propElement.textContent, propElement.tagName);\r\n default:\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Primitive property '${propElement.tagName}' has an invalid primitive type.`);\r\n }\r\n }\r\n\r\n private getBooleanPropertyValue(propValue: string, propName: string): boolean {\r\n if (propValue.toLowerCase() === \"true\" ||\r\n Number.parseInt(propValue, 10) > 0) {\r\n return true;\r\n } else if (propValue.toLowerCase() === \"false\" ||\r\n Number.parseInt(propValue, 10) === 0) {\r\n return false;\r\n }\r\n\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. An boolean value was expected.`);\r\n }\r\n\r\n private getIntegerPropertyValue(propValue: string, propName: string): number {\r\n const result = Number.parseFloat(propValue);\r\n if (isNaN(result) || result % 1 !== 0)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. An integer value was expected.`);\r\n\r\n return result;\r\n }\r\n\r\n private getDatePropertyValue(propValue: string, propName: string): Date {\r\n const result = Number.parseInt(propValue, 10);\r\n if (isNaN(result))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. A date in milliseconds was expected.`);\r\n\r\n return new Date(result);\r\n }\r\n\r\n private getDoublePropertyValue(propValue: string, propName: string): number {\r\n const result = Number.parseFloat(propValue);\r\n if (isNaN(result))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. A double value was expected.`);\r\n\r\n return result;\r\n }\r\n\r\n private getPoint2DPropertyValue(propValue: string, propName: string): any {\r\n const result = propValue.split(\",\");\r\n if (result.length !== 2) {\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. A Point 2D value was expected.`);\r\n }\r\n\r\n const x = Number.parseFloat(result[0]);\r\n const y = Number.parseFloat(result[1]);\r\n\r\n if (isNaN(x) || isNaN(y))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. A Point 2D value was expected.`);\r\n\r\n return { x, y };\r\n }\r\n\r\n private getPoint3DPropertyValue(propValue: string, propName: string): any {\r\n const result = propValue.split(\",\");\r\n if (result.length !== 3) {\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. A Point 3D value was expected.`);\r\n }\r\n\r\n const x = Number.parseFloat(result[0]);\r\n const y = Number.parseFloat(result[1]);\r\n const z = Number.parseFloat(result[2]);\r\n\r\n if (isNaN(x) || isNaN(y) || isNaN(z))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Property '${propName}' has an invalid property value. A Point 3D value was expected.`);\r\n\r\n return { x, y, z };\r\n }\r\n\r\n private isSchemaFullNameValidForVersion(schemaFullName: string, ecSpecVersion: ECSpecVersion) {\r\n const schemaNameParts = schemaFullName.split(\".\");\r\n\r\n if ((ecSpecVersion.readVersion >= 3 && ecSpecVersion.writeVersion >= 2) || ecSpecVersion.readVersion > 3) {\r\n if (schemaNameParts.length < 4)\r\n return false;\r\n } else {\r\n if (schemaNameParts.length < 3)\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n public static parseXmlNamespace(xmlNamespace: string): ECSpecVersion | undefined {\r\n const regEx = new RegExp(`^${ECXML_URI}\\\\.([0-9]+)\\\\.([0-9]+)$`);\r\n const match = xmlNamespace.match(regEx);\r\n if (!match)\r\n return;\r\n\r\n const readVersion = parseInt(match[1], 10);\r\n const writeVersion = parseInt(match[2], 10);\r\n return { readVersion, writeVersion };\r\n }\r\n\r\n private getQualifiedTypeName(rawTypeName: string): string {\r\n const nameParts = rawTypeName.split(\":\");\r\n if (nameParts.length !== 2)\r\n return `${this._schemaName}.${rawTypeName}`;\r\n\r\n if (nameParts[0].toLowerCase() === this._schemaAlias.toLowerCase())\r\n return `${this._schemaName}.${nameParts[1]}`;\r\n if (this._schemaReferenceNames.has(nameParts[0].toLowerCase()))\r\n return `${this._schemaReferenceNames.get(nameParts[0].toLowerCase())}.${nameParts[1]}`;\r\n\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `No valid schema found for alias ${nameParts[0]}`);\r\n }\r\n\r\n /** The rest of the API uses the full name format of `{SchemaName}.{SchemaItemName}`,\r\n * meaning all of the references in the format string need to be changed.\r\n */\r\n private getQualifiedPresentationUnits(presentationUnits: string[]): string[] {\r\n const res: string[] = [];\r\n for (const presentationUnit of presentationUnits) {\r\n // we split the presentation unit by square parantheses [ ], f:DefaultReal(6)[u:FT|feet] will be splitted into f:DefaultReal(6) and u:FT|feet\r\n // we format the first one and the next one will be put into [ ] again\r\n const presentationUnitFormats = presentationUnit.split(/[\\[\\]]/g);\r\n let qualifiedPresentation: string = \"\";\r\n qualifiedPresentation = this.getQualifiedTypeName(presentationUnitFormats[0]);\r\n if (presentationUnitFormats.length > 1) {\r\n for (let i = 1; i < presentationUnitFormats.length; ++i) {\r\n if (presentationUnitFormats[i].length === 0)\r\n continue;\r\n const verticalSlashIdx = presentationUnitFormats[i].indexOf(\"|\");\r\n const overrideFormat = this.getQualifiedTypeName(presentationUnitFormats[i].slice(0, verticalSlashIdx));\r\n const formatLabel = presentationUnitFormats[i].slice(verticalSlashIdx);\r\n qualifiedPresentation += `[${overrideFormat}${formatLabel}]`;\r\n }\r\n }\r\n\r\n res.push(qualifiedPresentation);\r\n }\r\n\r\n return res;\r\n }\r\n}\r\n"]}
|
|
@@ -100,7 +100,7 @@ class SchemaFormatsProvider {
|
|
|
100
100
|
// If no matching presentation format was found, use persistence unit format if it matches unit system.
|
|
101
101
|
const persistenceUnit = await kindOfQuantity.persistenceUnit;
|
|
102
102
|
const persistenceUnitSystem = await persistenceUnit?.unitSystem;
|
|
103
|
-
if (persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {
|
|
103
|
+
if (persistenceUnit && persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {
|
|
104
104
|
this._formatsRetrieved.add(itemKey.fullName);
|
|
105
105
|
const props = getPersistenceUnitFormatProps(persistenceUnit);
|
|
106
106
|
return this.convertToFormatDefinition(props, kindOfQuantity);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaFormatsProvider.js","sourceRoot":"","sources":["../../../src/Formatting/SchemaFormatsProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wCAA2D;AAC3D,4CAAwD;AACxD,uDAAoD;AACpD,+CAA4C;AAE5C,sDAAsD;AACtD,+DAA4D;AAC5D,+DAA4D;AAM5D,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAC/C;;;GAGG;AACH,MAAa,qBAAqB;IACxB,QAAQ,CAAgB;IACxB,WAAW,CAAgB;IAC3B,iBAAiB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAC5C,gBAAgB,GAAG,IAAI,sBAAO,EAAsC,CAAC;IAC5E;;;;;;OAMG;IACH,YAAY,gBAAgC,EAAE,UAAyB;QACrE,IAAI,gBAAgB,YAAY,uBAAa,EAAE,CAAC;YAC9C,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAa,EAAE,CAAC;YACpC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;QAC7C,C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C,GAAG,CAAC,aAAa,CAAC,CAAC;QAC3E,KAAK,aAAa;YAChB,OAAO,CAAC,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACrE,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,6BAA6B,CAAC,eAAoC;IACzE,oDAAoD;IACpD,OAAO;QACL,YAAY,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC;QACrE,SAAS,EAAE,CAAC;QACZ,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,eAAe,CAAC,QAAQ;oBAC9B,KAAK,EAAE,eAAe,CAAC,KAAK;iBAC7B;aACF;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { ISchemaLocater, SchemaContext } from \"../Context\";\r\nimport { SchemaItemKey, SchemaKey } from \"../SchemaKey\";\r\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\r\nimport { Format } from \"../Metadata/Format\";\r\nimport { SchemaItemFormatProps } from \"../Deserialization/JsonProps\";\r\nimport { BeEvent, Logger } from \"@itwin/core-bentley\";\r\nimport { KindOfQuantity } from \"../Metadata/KindOfQuantity\";\r\nimport { getFormatProps } from \"../Metadata/OverrideFormat\";\r\nimport { FormatDefinition, FormatProps, FormatsChangedArgs, FormatsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { Unit } from \"../Metadata/Unit\";\r\nimport { InvertedUnit } from \"../Metadata/InvertedUnit\";\r\nimport { Schema } from \"../Metadata/Schema\";\r\nimport { UnitSystem } from \"../Metadata/UnitSystem\";\r\nconst loggerCategory = \"SchemaFormatsProvider\";\r\n/**\r\n * Provides default formats and kind of quantities from a given SchemaContext or SchemaLocater.\r\n * @beta\r\n */\r\nexport class SchemaFormatsProvider implements FormatsProvider {\r\n private _context: SchemaContext;\r\n private _unitSystem: UnitSystemKey;\r\n private _formatsRetrieved: Set<string> = new Set();\r\n public onFormatsChanged = new BeEvent<(args: FormatsChangedArgs) => void>();\r\n /**\r\n *\r\n * @param contextOrLocater The SchemaContext or a different ISchemaLocater implementation used to retrieve the schema. The SchemaContext\r\n * class implements the ISchemaLocater interface. If the provided locater is not a SchemaContext instance a new SchemaContext will be\r\n * created and the locater will be added.\r\n * @param unitSystem Used to lookup a default format through a schema specific algorithm, when the format retrieved is associated with a KindOfQuantity.\r\n */\r\n constructor(contextOrLocater: ISchemaLocater, unitSystem: UnitSystemKey) {\r\n if (contextOrLocater instanceof SchemaContext) {\r\n this._context = contextOrLocater;\r\n } else {\r\n this._context = new SchemaContext();\r\n this._context.addLocater(contextOrLocater);\r\n }\r\n this._unitSystem = unitSystem;\r\n }\r\n\r\n public get context() { return this._context; }\r\n public get unitSystem() { return this._unitSystem; }\r\n\r\n public set unitSystem(unitSystem: UnitSystemKey) {\r\n this._unitSystem = unitSystem;\r\n this.clear();\r\n }\r\n\r\n private clear(): void {\r\n const formatsChanged = Array.from(this._formatsRetrieved);\r\n this._formatsRetrieved.clear();\r\n this.onFormatsChanged.raiseEvent({ formatsChanged });\r\n }\r\n\r\n /** When using a presentation unit from a KindOfQuantity, the label and description should come from the KindOfQuantity */\r\n private convertToFormatDefinition(format: SchemaItemFormatProps, kindOfQuantity: KindOfQuantity): FormatDefinition {\r\n // Destructure all properties except 'rest'\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n const { name, label, description, $schema, schema, schemaVersion, schemaItemType,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n customAttributes, originalECSpecMajorVersion, originalECSpecMinorVersion, ...rest } = format;\r\n\r\n return {\r\n ...rest,\r\n name: kindOfQuantity.fullName,\r\n label: kindOfQuantity.label ?? format.label,\r\n description: kindOfQuantity.description ?? format.description,\r\n }\r\n }\r\n\r\n private async getKindOfQuantityFormatFromSchema(itemKey: SchemaItemKey): Promise<FormatDefinition | undefined> {\r\n let kindOfQuantity: KindOfQuantity | undefined;\r\n try {\r\n kindOfQuantity = await this._context.getSchemaItem(itemKey, KindOfQuantity);\r\n } catch {\r\n Logger.logError(loggerCategory, `Failed to find KindOfQuantity ${itemKey.fullName}`);\r\n return undefined;\r\n }\r\n\r\n if (!kindOfQuantity) {\r\n return undefined;\r\n }\r\n\r\n // Find the first presentation format that matches the provided unit system.\r\n const unitSystemMatchers = getUnitSystemGroupMatchers(this._unitSystem);\r\n const presentationFormats = kindOfQuantity.presentationFormats;\r\n for (const matcher of unitSystemMatchers) {\r\n for (const lazyFormat of presentationFormats) {\r\n const format = await lazyFormat;\r\n const unit = await (format.units && format.units[0][0]);\r\n if (!unit) {\r\n continue;\r\n }\r\n const currentUnitSystem = await unit.unitSystem;\r\n if (currentUnitSystem && matcher(currentUnitSystem)) {\r\n this._formatsRetrieved.add(itemKey.fullName);\r\n const props = getFormatProps(format);\r\n return this.convertToFormatDefinition(props, kindOfQuantity);\r\n }\r\n }\r\n }\r\n\r\n // If no matching presentation format was found, use persistence unit format if it matches unit system.\r\n const persistenceUnit = await kindOfQuantity.persistenceUnit;\r\n const persistenceUnitSystem = await persistenceUnit?.unitSystem;\r\n if (persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {\r\n this._formatsRetrieved.add(itemKey.fullName);\r\n const props = getPersistenceUnitFormatProps(persistenceUnit!);\r\n return this.convertToFormatDefinition(props, kindOfQuantity);\r\n }\r\n\r\n const defaultFormat = kindOfQuantity.defaultPresentationFormat;\r\n if (!defaultFormat) {\r\n return undefined;\r\n }\r\n this._formatsRetrieved.add(itemKey.fullName);\r\n const defaultProps = getFormatProps(await defaultFormat);\r\n return this.convertToFormatDefinition(defaultProps, kindOfQuantity);\r\n }\r\n\r\n\r\n /**\r\n * Retrieves a Format from a SchemaContext. If the format is part of a KindOfQuantity, the first presentation format in the KindOfQuantity that matches the current unit system will be retrieved.\r\n * If no presentation format matches the current unit system, the persistence unit format will be retrieved if it matches the current unit system.\r\n * Else, the default presentation format will be retrieved.\r\n * @param name The full name of the Format or KindOfQuantity.\r\n * @returns\r\n */\r\n public async getFormat(name: string): Promise<FormatDefinition | undefined> {\r\n const [schemaName, schemaItemName] = SchemaItem.parseFullName(name);\r\n const schemaKey = new SchemaKey(schemaName);\r\n let schema: Schema | undefined;\r\n try {\r\n schema = await this._context.getSchema(schemaKey);\r\n } catch {\r\n Logger.logError(loggerCategory, `Failed to find schema ${schemaName}`);\r\n return undefined;\r\n }\r\n if (!schema) {\r\n return undefined;\r\n }\r\n const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);\r\n\r\n if (schema.name === \"Formats\") {\r\n let format: Format | undefined;\r\n try {\r\n format = await this._context.getSchemaItem(itemKey, Format);\r\n } catch {\r\n Logger.logError(loggerCategory, `Failed to find Format ${itemKey.fullName}`);\r\n return undefined;\r\n }\r\n if (!format) {\r\n return undefined;\r\n }\r\n return format.toJSON(true);\r\n }\r\n return this.getKindOfQuantityFormatFromSchema(itemKey);\r\n }\r\n}\r\n\r\nfunction getUnitSystemGroupMatchers(groupKey?: UnitSystemKey) {\r\n function createMatcher(name: string | string[]) {\r\n const names = Array.isArray(name) ? name : [name];\r\n return (unitSystem: UnitSystem) => names.some((n) => n === unitSystem.name.toUpperCase());\r\n }\r\n switch (groupKey) {\r\n case \"imperial\":\r\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n case \"metric\":\r\n return [[\"SI\", \"METRIC\"], \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n case \"usCustomary\":\r\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n case \"usSurvey\":\r\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n }\r\n return [];\r\n}\r\n\r\nfunction getPersistenceUnitFormatProps(persistenceUnit: Unit | InvertedUnit): FormatProps {\r\n // Same as Format \"DefaultRealU\" in Formats ecschema\r\n return {\r\n formatTraits: [\"keepSingleZero\", \"keepDecimalPoint\", \"showUnitLabel\"],\r\n precision: 6,\r\n type: \"Decimal\",\r\n composite: {\r\n units: [\r\n {\r\n name: persistenceUnit.fullName,\r\n label: persistenceUnit.label,\r\n },\r\n ],\r\n },\r\n };\r\n}"]}
|
|
1
|
+
{"version":3,"file":"SchemaFormatsProvider.js","sourceRoot":"","sources":["../../../src/Formatting/SchemaFormatsProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wCAA2D;AAC3D,4CAAwD;AACxD,uDAAoD;AACpD,+CAA4C;AAE5C,sDAAsD;AACtD,+DAA4D;AAC5D,+DAA4D;AAM5D,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAC/C;;;GAGG;AACH,MAAa,qBAAqB;IACxB,QAAQ,CAAgB;IACxB,WAAW,CAAgB;IAC3B,iBAAiB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAC5C,gBAAgB,GAAG,IAAI,sBAAO,EAAsC,CAAC;IAC5E;;;;;;OAMG;IACH,YAAY,gBAAgC,EAAE,UAAyB;QACrE,IAAI,gBAAgB,YAAY,uBAAa,EAAE,CAAC;YAC9C,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAa,EAAE,CAAC;YACpC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;QAC7C,C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,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC3E,KAAK,aAAa;YAChB,OAAO,CAAC,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACrE,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,6BAA6B,CAAC,eAAoC;IACzE,oDAAoD;IACpD,OAAO;QACL,YAAY,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC;QACrE,SAAS,EAAE,CAAC;QACZ,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,eAAe,CAAC,QAAQ;oBAC9B,KAAK,EAAE,eAAe,CAAC,KAAK;iBAC7B;aACF;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { ISchemaLocater, SchemaContext } from \"../Context\";\r\nimport { SchemaItemKey, SchemaKey } from \"../SchemaKey\";\r\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\r\nimport { Format } from \"../Metadata/Format\";\r\nimport { SchemaItemFormatProps } from \"../Deserialization/JsonProps\";\r\nimport { BeEvent, Logger } from \"@itwin/core-bentley\";\r\nimport { KindOfQuantity } from \"../Metadata/KindOfQuantity\";\r\nimport { getFormatProps } from \"../Metadata/OverrideFormat\";\r\nimport { FormatDefinition, FormatProps, FormatsChangedArgs, FormatsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { Unit } from \"../Metadata/Unit\";\r\nimport { InvertedUnit } from \"../Metadata/InvertedUnit\";\r\nimport { Schema } from \"../Metadata/Schema\";\r\nimport { UnitSystem } from \"../Metadata/UnitSystem\";\r\nconst loggerCategory = \"SchemaFormatsProvider\";\r\n/**\r\n * Provides default formats and kind of quantities from a given SchemaContext or SchemaLocater.\r\n * @beta\r\n */\r\nexport class SchemaFormatsProvider implements FormatsProvider {\r\n private _context: SchemaContext;\r\n private _unitSystem: UnitSystemKey;\r\n private _formatsRetrieved: Set<string> = new Set();\r\n public onFormatsChanged = new BeEvent<(args: FormatsChangedArgs) => void>();\r\n /**\r\n *\r\n * @param contextOrLocater The SchemaContext or a different ISchemaLocater implementation used to retrieve the schema. The SchemaContext\r\n * class implements the ISchemaLocater interface. If the provided locater is not a SchemaContext instance a new SchemaContext will be\r\n * created and the locater will be added.\r\n * @param unitSystem Used to lookup a default format through a schema specific algorithm, when the format retrieved is associated with a KindOfQuantity.\r\n */\r\n constructor(contextOrLocater: ISchemaLocater, unitSystem: UnitSystemKey) {\r\n if (contextOrLocater instanceof SchemaContext) {\r\n this._context = contextOrLocater;\r\n } else {\r\n this._context = new SchemaContext();\r\n this._context.addLocater(contextOrLocater);\r\n }\r\n this._unitSystem = unitSystem;\r\n }\r\n\r\n public get context() { return this._context; }\r\n public get unitSystem() { return this._unitSystem; }\r\n\r\n public set unitSystem(unitSystem: UnitSystemKey) {\r\n this._unitSystem = unitSystem;\r\n this.clear();\r\n }\r\n\r\n private clear(): void {\r\n const formatsChanged = Array.from(this._formatsRetrieved);\r\n this._formatsRetrieved.clear();\r\n this.onFormatsChanged.raiseEvent({ formatsChanged });\r\n }\r\n\r\n /** When using a presentation unit from a KindOfQuantity, the label and description should come from the KindOfQuantity */\r\n private convertToFormatDefinition(format: SchemaItemFormatProps, kindOfQuantity: KindOfQuantity): FormatDefinition {\r\n // Destructure all properties except 'rest'\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n const { name, label, description, $schema, schema, schemaVersion, schemaItemType,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n customAttributes, originalECSpecMajorVersion, originalECSpecMinorVersion, ...rest } = format;\r\n\r\n return {\r\n ...rest,\r\n name: kindOfQuantity.fullName,\r\n label: kindOfQuantity.label ?? format.label,\r\n description: kindOfQuantity.description ?? format.description,\r\n }\r\n }\r\n\r\n private async getKindOfQuantityFormatFromSchema(itemKey: SchemaItemKey): Promise<FormatDefinition | undefined> {\r\n let kindOfQuantity: KindOfQuantity | undefined;\r\n try {\r\n kindOfQuantity = await this._context.getSchemaItem(itemKey, KindOfQuantity);\r\n } catch {\r\n Logger.logError(loggerCategory, `Failed to find KindOfQuantity ${itemKey.fullName}`);\r\n return undefined;\r\n }\r\n\r\n if (!kindOfQuantity) {\r\n return undefined;\r\n }\r\n\r\n // Find the first presentation format that matches the provided unit system.\r\n const unitSystemMatchers = getUnitSystemGroupMatchers(this._unitSystem);\r\n const presentationFormats = kindOfQuantity.presentationFormats;\r\n for (const matcher of unitSystemMatchers) {\r\n for (const lazyFormat of presentationFormats) {\r\n const format = await lazyFormat;\r\n const unit = await (format.units && format.units[0][0]);\r\n if (!unit) {\r\n continue;\r\n }\r\n const currentUnitSystem = await unit.unitSystem;\r\n if (currentUnitSystem && matcher(currentUnitSystem)) {\r\n this._formatsRetrieved.add(itemKey.fullName);\r\n const props = getFormatProps(format);\r\n return this.convertToFormatDefinition(props, kindOfQuantity);\r\n }\r\n }\r\n }\r\n\r\n // If no matching presentation format was found, use persistence unit format if it matches unit system.\r\n const persistenceUnit = await kindOfQuantity.persistenceUnit;\r\n const persistenceUnitSystem = await persistenceUnit?.unitSystem;\r\n if (persistenceUnit && persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {\r\n this._formatsRetrieved.add(itemKey.fullName);\r\n const props = getPersistenceUnitFormatProps(persistenceUnit);\r\n return this.convertToFormatDefinition(props, kindOfQuantity);\r\n }\r\n\r\n const defaultFormat = kindOfQuantity.defaultPresentationFormat;\r\n if (!defaultFormat) {\r\n return undefined;\r\n }\r\n this._formatsRetrieved.add(itemKey.fullName);\r\n const defaultProps = getFormatProps(await defaultFormat);\r\n return this.convertToFormatDefinition(defaultProps, kindOfQuantity);\r\n }\r\n\r\n\r\n /**\r\n * Retrieves a Format from a SchemaContext. If the format is part of a KindOfQuantity, the first presentation format in the KindOfQuantity that matches the current unit system will be retrieved.\r\n * If no presentation format matches the current unit system, the persistence unit format will be retrieved if it matches the current unit system.\r\n * Else, the default presentation format will be retrieved.\r\n * @param name The full name of the Format or KindOfQuantity.\r\n * @returns\r\n */\r\n public async getFormat(name: string): Promise<FormatDefinition | undefined> {\r\n const [schemaName, schemaItemName] = SchemaItem.parseFullName(name);\r\n const schemaKey = new SchemaKey(schemaName);\r\n let schema: Schema | undefined;\r\n try {\r\n schema = await this._context.getSchema(schemaKey);\r\n } catch {\r\n Logger.logError(loggerCategory, `Failed to find schema ${schemaName}`);\r\n return undefined;\r\n }\r\n if (!schema) {\r\n return undefined;\r\n }\r\n const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);\r\n\r\n if (schema.name === \"Formats\") {\r\n let format: Format | undefined;\r\n try {\r\n format = await this._context.getSchemaItem(itemKey, Format);\r\n } catch {\r\n Logger.logError(loggerCategory, `Failed to find Format ${itemKey.fullName}`);\r\n return undefined;\r\n }\r\n if (!format) {\r\n return undefined;\r\n }\r\n return format.toJSON(true);\r\n }\r\n return this.getKindOfQuantityFormatFromSchema(itemKey);\r\n }\r\n}\r\n\r\nfunction getUnitSystemGroupMatchers(groupKey?: UnitSystemKey) {\r\n function createMatcher(name: string | string[]) {\r\n const names = Array.isArray(name) ? name : [name];\r\n return (unitSystem: UnitSystem) => names.some((n) => n === unitSystem.name.toUpperCase());\r\n }\r\n switch (groupKey) {\r\n case \"imperial\":\r\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n case \"metric\":\r\n return [[\"SI\", \"METRIC\"], \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n case \"usCustomary\":\r\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n case \"usSurvey\":\r\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n }\r\n return [];\r\n}\r\n\r\nfunction getPersistenceUnitFormatProps(persistenceUnit: Unit | InvertedUnit): FormatProps {\r\n // Same as Format \"DefaultRealU\" in Formats ecschema\r\n return {\r\n formatTraits: [\"keepSingleZero\", \"keepDecimalPoint\", \"showUnitLabel\"],\r\n precision: 6,\r\n type: \"Decimal\",\r\n composite: {\r\n units: [\r\n {\r\n name: persistenceUnit.fullName,\r\n label: persistenceUnit.label,\r\n },\r\n ],\r\n },\r\n };\r\n}"]}
|
|
@@ -212,7 +212,21 @@ export declare abstract class ECClass extends SchemaItem implements CustomAttrib
|
|
|
212
212
|
* This is essentially a depth-first traversal through the inheritance tree.
|
|
213
213
|
*/
|
|
214
214
|
getAllBaseClasses(): AsyncIterable<ECClass>;
|
|
215
|
+
/**
|
|
216
|
+
* gets a class from this schema or its references recursively using the item key
|
|
217
|
+
* @param itemKey
|
|
218
|
+
* @returns ECClass if it could be found, undefined otherwise
|
|
219
|
+
* @internal
|
|
220
|
+
*/
|
|
221
|
+
private getClassFromReferencesRecursively;
|
|
215
222
|
getAllBaseClassesSync(): Iterable<AnyClass>;
|
|
223
|
+
/**
|
|
224
|
+
* gets a class from this schema or its references recursively using the item key synchronously
|
|
225
|
+
* @param itemKey
|
|
226
|
+
* @returns ECClass if it could be found, undefined otherwise
|
|
227
|
+
* @internal
|
|
228
|
+
*/
|
|
229
|
+
private getClassFromReferencesRecursivelySync;
|
|
216
230
|
/**
|
|
217
231
|
*
|
|
218
232
|
* @param cache
|