@itwin/ecschema-metadata 5.0.0-dev.8 → 5.0.0-dev.83
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 +46 -1
- package/lib/cjs/Constants.js +20 -20
- package/lib/cjs/Constants.js.map +1 -1
- package/lib/cjs/Context.d.ts +60 -20
- package/lib/cjs/Context.d.ts.map +1 -1
- package/lib/cjs/Context.js +43 -19
- package/lib/cjs/Context.js.map +1 -1
- package/lib/cjs/DelayedPromise.js +6 -4
- package/lib/cjs/DelayedPromise.js.map +1 -1
- package/lib/cjs/Deserialization/AbstractParser.js +1 -0
- package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
- package/lib/cjs/Deserialization/Helper.d.ts +3 -3
- package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
- package/lib/cjs/Deserialization/Helper.js +8 -0
- package/lib/cjs/Deserialization/Helper.js.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.js +3 -0
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.d.ts +3 -0
- package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js +11 -1
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/ECName.js +1 -0
- package/lib/cjs/ECName.js.map +1 -1
- package/lib/cjs/ECObjects.d.ts +21 -1
- package/lib/cjs/ECObjects.d.ts.map +1 -1
- package/lib/cjs/ECObjects.js +34 -2
- package/lib/cjs/ECObjects.js.map +1 -1
- package/lib/cjs/Exception.js +1 -0
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Interfaces.d.ts +10 -3
- package/lib/cjs/Interfaces.d.ts.map +1 -1
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/cjs/Metadata/Class.d.ts +53 -5
- package/lib/cjs/Metadata/Class.d.ts.map +1 -1
- package/lib/cjs/Metadata/Class.js +118 -19
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Constant.d.ts +14 -1
- package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
- package/lib/cjs/Metadata/Constant.js +27 -2
- package/lib/cjs/Metadata/Constant.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts +16 -4
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.js +22 -4
- package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.d.ts +18 -6
- package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js +29 -9
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/Enumeration.d.ts +14 -1
- package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/cjs/Metadata/Enumeration.js +22 -1
- package/lib/cjs/Metadata/Enumeration.js.map +1 -1
- package/lib/cjs/Metadata/Format.d.ts +41 -1
- package/lib/cjs/Metadata/Format.d.ts.map +1 -1
- package/lib/cjs/Metadata/Format.js +68 -3
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.d.ts +8 -3
- package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.js +17 -6
- package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.d.ts +14 -3
- package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js +43 -18
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Mixin.d.ts +15 -1
- package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
- package/lib/cjs/Metadata/Mixin.js +23 -2
- package/lib/cjs/Metadata/Mixin.js.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.js +9 -0
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.d.ts +14 -1
- package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.js +22 -1
- package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
- package/lib/cjs/Metadata/Property.d.ts +1 -1
- package/lib/cjs/Metadata/Property.d.ts.map +1 -1
- package/lib/cjs/Metadata/Property.js +83 -28
- package/lib/cjs/Metadata/Property.js.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.d.ts +14 -1
- package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.js +21 -1
- package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.d.ts +15 -2
- package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.js +47 -10
- package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
- package/lib/cjs/Metadata/Schema.d.ts +116 -11
- package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
- package/lib/cjs/Metadata/Schema.js +135 -33
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.d.ts +11 -2
- package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.js +10 -0
- package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
- package/lib/cjs/Metadata/Unit.d.ts +8 -1
- package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
- package/lib/cjs/Metadata/Unit.js +21 -3
- package/lib/cjs/Metadata/Unit.js.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.d.ts +14 -3
- package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.js +21 -3
- package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
- package/lib/cjs/SchemaJsonLocater.d.ts +3 -3
- package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaJsonLocater.js +3 -3
- package/lib/cjs/SchemaJsonLocater.js.map +1 -1
- package/lib/cjs/SchemaKey.d.ts +7 -1
- package/lib/cjs/SchemaKey.d.ts.map +1 -1
- package/lib/cjs/SchemaKey.js +13 -3
- package/lib/cjs/SchemaKey.js.map +1 -1
- package/lib/cjs/SchemaLoader.d.ts +2 -2
- package/lib/cjs/SchemaLoader.d.ts.map +1 -1
- package/lib/cjs/SchemaLoader.js +1 -0
- package/lib/cjs/SchemaLoader.js.map +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.js +1 -0
- package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/cjs/UnitConversion/Graph.js +69 -65
- package/lib/cjs/UnitConversion/Graph.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.d.ts +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.d.ts.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.js +9 -7
- package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.js +2 -0
- package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.d.ts +2 -0
- package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.js +11 -1
- package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js +6 -3
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js +4 -0
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/utils/SchemaGraph.js +2 -3
- package/lib/cjs/utils/SchemaGraph.js.map +1 -1
- package/lib/esm/Constants.js +20 -20
- package/lib/esm/Constants.js.map +1 -1
- package/lib/esm/Context.d.ts +60 -20
- package/lib/esm/Context.d.ts.map +1 -1
- package/lib/esm/Context.js +41 -17
- package/lib/esm/Context.js.map +1 -1
- package/lib/esm/DelayedPromise.js +6 -4
- package/lib/esm/DelayedPromise.js.map +1 -1
- package/lib/esm/Deserialization/AbstractParser.js +1 -0
- package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
- package/lib/esm/Deserialization/Helper.d.ts +3 -3
- package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
- package/lib/esm/Deserialization/Helper.js +8 -0
- package/lib/esm/Deserialization/Helper.js.map +1 -1
- package/lib/esm/Deserialization/JsonParser.js +3 -0
- package/lib/esm/Deserialization/JsonParser.js.map +1 -1
- package/lib/esm/Deserialization/JsonProps.d.ts +3 -0
- package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/esm/Deserialization/JsonProps.js.map +1 -1
- package/lib/esm/Deserialization/XmlParser.js +11 -1
- package/lib/esm/Deserialization/XmlParser.js.map +1 -1
- package/lib/esm/ECName.js +1 -0
- package/lib/esm/ECName.js.map +1 -1
- package/lib/esm/ECObjects.d.ts +21 -1
- package/lib/esm/ECObjects.d.ts.map +1 -1
- package/lib/esm/ECObjects.js +32 -1
- package/lib/esm/ECObjects.js.map +1 -1
- package/lib/esm/Exception.js +1 -0
- package/lib/esm/Exception.js.map +1 -1
- package/lib/esm/Interfaces.d.ts +10 -3
- package/lib/esm/Interfaces.d.ts.map +1 -1
- package/lib/esm/Interfaces.js.map +1 -1
- package/lib/esm/Metadata/Class.d.ts +53 -5
- package/lib/esm/Metadata/Class.d.ts.map +1 -1
- package/lib/esm/Metadata/Class.js +119 -20
- package/lib/esm/Metadata/Class.js.map +1 -1
- package/lib/esm/Metadata/Constant.d.ts +14 -1
- package/lib/esm/Metadata/Constant.d.ts.map +1 -1
- package/lib/esm/Metadata/Constant.js +27 -2
- package/lib/esm/Metadata/Constant.js.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.d.ts +16 -4
- package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.js +22 -4
- package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/esm/Metadata/EntityClass.d.ts +18 -6
- package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/esm/Metadata/EntityClass.js +29 -9
- package/lib/esm/Metadata/EntityClass.js.map +1 -1
- package/lib/esm/Metadata/Enumeration.d.ts +14 -1
- package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/esm/Metadata/Enumeration.js +22 -1
- package/lib/esm/Metadata/Enumeration.js.map +1 -1
- package/lib/esm/Metadata/Format.d.ts +41 -1
- package/lib/esm/Metadata/Format.d.ts.map +1 -1
- package/lib/esm/Metadata/Format.js +68 -3
- package/lib/esm/Metadata/Format.js.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.d.ts +8 -3
- package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.js +17 -6
- package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.d.ts +14 -3
- package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.js +43 -18
- package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/esm/Metadata/Mixin.d.ts +15 -1
- package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
- package/lib/esm/Metadata/Mixin.js +24 -3
- package/lib/esm/Metadata/Mixin.js.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.js +9 -0
- package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
- package/lib/esm/Metadata/Phenomenon.d.ts +14 -1
- package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/esm/Metadata/Phenomenon.js +22 -1
- package/lib/esm/Metadata/Phenomenon.js.map +1 -1
- package/lib/esm/Metadata/Property.d.ts +1 -1
- package/lib/esm/Metadata/Property.d.ts.map +1 -1
- package/lib/esm/Metadata/Property.js +84 -29
- package/lib/esm/Metadata/Property.js.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.d.ts +14 -1
- package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.js +21 -1
- package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.d.ts +15 -2
- package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.js +48 -11
- package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
- package/lib/esm/Metadata/Schema.d.ts +116 -11
- package/lib/esm/Metadata/Schema.d.ts.map +1 -1
- package/lib/esm/Metadata/Schema.js +135 -33
- package/lib/esm/Metadata/Schema.js.map +1 -1
- package/lib/esm/Metadata/SchemaItem.d.ts +11 -2
- package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/esm/Metadata/SchemaItem.js +11 -1
- package/lib/esm/Metadata/SchemaItem.js.map +1 -1
- package/lib/esm/Metadata/Unit.d.ts +8 -1
- package/lib/esm/Metadata/Unit.d.ts.map +1 -1
- package/lib/esm/Metadata/Unit.js +21 -3
- package/lib/esm/Metadata/Unit.js.map +1 -1
- package/lib/esm/Metadata/UnitSystem.d.ts +14 -3
- package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/esm/Metadata/UnitSystem.js +21 -3
- package/lib/esm/Metadata/UnitSystem.js.map +1 -1
- package/lib/esm/SchemaJsonLocater.d.ts +3 -3
- package/lib/esm/SchemaJsonLocater.d.ts.map +1 -1
- package/lib/esm/SchemaJsonLocater.js +3 -3
- package/lib/esm/SchemaJsonLocater.js.map +1 -1
- package/lib/esm/SchemaKey.d.ts +7 -1
- package/lib/esm/SchemaKey.d.ts.map +1 -1
- package/lib/esm/SchemaKey.js +13 -3
- package/lib/esm/SchemaKey.js.map +1 -1
- package/lib/esm/SchemaLoader.d.ts +2 -2
- package/lib/esm/SchemaLoader.d.ts.map +1 -1
- package/lib/esm/SchemaLoader.js +1 -0
- package/lib/esm/SchemaLoader.js.map +1 -1
- package/lib/esm/SchemaPartVisitorDelegate.js +1 -0
- package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/esm/UnitConversion/Graph.js +69 -65
- package/lib/esm/UnitConversion/Graph.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConversion.d.ts +1 -1
- package/lib/esm/UnitConversion/UnitConversion.d.ts.map +1 -1
- package/lib/esm/UnitConversion/UnitConversion.js +9 -7
- package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConverter.js +2 -0
- package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/esm/UnitConversion/UnitTree.d.ts +2 -0
- package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -1
- package/lib/esm/UnitConversion/UnitTree.js +11 -1
- package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.js +6 -3
- package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/esm/Validation/SchemaWalker.d.ts +1 -1
- package/lib/esm/Validation/SchemaWalker.d.ts.map +1 -1
- package/lib/esm/Validation/SchemaWalker.js +4 -0
- package/lib/esm/Validation/SchemaWalker.js.map +1 -1
- package/lib/esm/utils/SchemaGraph.js +2 -3
- package/lib/esm/utils/SchemaGraph.js.map +1 -1
- package/package.json +14 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constant.js","sourceRoot":"","sources":["../../../src/Metadata/Constant.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAA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;IACO,aAAa,CAAC,UAAgC;QACtD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;OAEG;IACO,aAAa,CAAC,UAAkB;QACxC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;OAEG;IACO,YAAY,CAAC,SAAiB;QACtC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,WAAmB;QAC1C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;CACF;AACD;;;GAGG;AACH,MAAM,OAAgB,eAAgB,SAAQ,QAAQ;CAMrD","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { ConstantProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { LazyLoadedPhenomenon } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { Phenomenon } from \"./Phenomenon\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Constant is a specific type of Unit that represents a number.\n * @beta\n */\nexport class Constant extends SchemaItem {\n public override readonly schemaItemType!: SchemaItemType.Constant;\n protected _phenomenon?: LazyLoadedPhenomenon;\n protected _definition: string;\n protected _numerator?: number;\n protected _denominator?: number;\n\n constructor(schema: Schema, name: string) {\n super(schema, name);\n this.schemaItemType = SchemaItemType.Constant;\n this._definition = \"\";\n }\n\n public get phenomenon(): LazyLoadedPhenomenon | undefined { return this._phenomenon; }\n public get definition(): string { return this._definition; }\n public get numerator(): number { return this._numerator ?? 1.0; }\n public get denominator(): number { return this._denominator ?? 1.0; }\n public get hasNumerator(): boolean { return (this._numerator !== undefined); }\n public get hasDenominator(): boolean { return (this._denominator !== undefined); }\n\n /**\n * Save this Constants properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): ConstantProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (this.phenomenon !== undefined)\n schemaJson.phenomenon = this.phenomenon.fullName;\n schemaJson.definition = this.definition;\n if (this.hasNumerator)\n schemaJson.numerator = this.numerator;\n if (this.hasDenominator)\n schemaJson.denominator = this.denominator;\n return schemaJson as ConstantProps;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n itemElement.setAttribute(\"definition\", this.definition);\n if (this.hasNumerator)\n itemElement.setAttribute(\"numerator\", this.numerator.toString());\n if (this.hasDenominator)\n itemElement.setAttribute(\"denominator\", this.denominator.toString());\n\n const phenomenon = await this.phenomenon;\n if (undefined !== phenomenon) {\n const phenomenonName = XmlSerializationUtils.createXmlTypedName(this.schema, phenomenon.schema, phenomenon.name);\n itemElement.setAttribute(\"phenomenon\", phenomenonName);\n }\n\n return itemElement;\n }\n\n public override fromJSONSync(constantProps: ConstantProps) {\n super.fromJSONSync(constantProps);\n\n const schemaItemKey = this.schema.getSchemaItemKey(constantProps.phenomenon);\n if (!schemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);\n this._phenomenon = new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(schemaItemKey,\n async () => {\n const phenom = await this.schema.lookupItem<Phenomenon>(schemaItemKey);\n if (undefined === phenom)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);\n return phenom;\n });\n\n if (this._definition !== \"\" && constantProps.definition.toLowerCase() !== this._definition.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${this.name} has an invalid 'definition' attribute.`);\n else if (this._definition === \"\")\n this._definition = constantProps.definition;\n\n if (undefined !== constantProps.numerator) {\n if (constantProps.numerator !== this._numerator)\n this._numerator = constantProps.numerator;\n }\n\n if (undefined !== constantProps.denominator) {\n if (constantProps.denominator !== this._denominator)\n this._denominator = constantProps.denominator;\n }\n }\n\n public override async fromJSON(constantProps: ConstantProps) {\n this.fromJSONSync(constantProps);\n }\n\n /**\n * @alpha Used in schema editing.\n * @param phenomenon A LazyLoadedPhenomenon.\n */\n protected setPhenomenon(phenomenon: LazyLoadedPhenomenon) {\n this._phenomenon = phenomenon;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setDefinition(definition: string) {\n this._definition = definition;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setNumerator(numerator: number) {\n this._numerator = numerator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setDenominator(denominator: number) {\n this._denominator = denominator;\n }\n}\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableConstant extends Constant {\n public abstract override setPhenomenon(phenomenon: LazyLoadedPhenomenon): void;\n public abstract override setDefinition(definition: string): void;\n public abstract override setNumerator(numerator: number): void;\n public abstract override setDenominator(denominator: number): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Constant.js","sourceRoot":"","sources":["../../../src/Metadata/Constant.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,E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AAC;IAED;;;OAGG;IACO,aAAa,CAAC,UAAgC;QACtD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;OAEG;IACO,aAAa,CAAC,UAAkB;QACxC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;OAEG;IACO,YAAY,CAAC,SAAiB;QACtC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,WAAmB;QAC1C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,IAAiB;QACxC,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,QAAQ;YACzD,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,gBAAgB,CAAC,IAAiB;QAC9C,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACxB,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,qBAAqB,EAAE,aAAa,cAAc,CAAC,QAAQ,cAAc,CAAC,CAAC;IACxH,CAAC;CACF;AACD;;;GAGG;AACH,MAAM,OAAgB,eAAgB,SAAQ,QAAQ;CAMrD","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { ConstantProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { LazyLoadedPhenomenon } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { Phenomenon } from \"./Phenomenon\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Constant is a specific type of Unit that represents a number.\n * @beta\n */\nexport class Constant extends SchemaItem {\n public override readonly schemaItemType = Constant.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.Constant; }\n protected _phenomenon?: LazyLoadedPhenomenon;\n protected _definition: string;\n protected _numerator?: number;\n protected _denominator?: number;\n\n constructor(schema: Schema, name: string) {\n super(schema, name);\n this._definition = \"\";\n }\n\n public get phenomenon(): LazyLoadedPhenomenon | undefined { return this._phenomenon; }\n public get definition(): string { return this._definition; }\n public get numerator(): number { return this._numerator ?? 1.0; }\n public get denominator(): number { return this._denominator ?? 1.0; }\n public get hasNumerator(): boolean { return (this._numerator !== undefined); }\n public get hasDenominator(): boolean { return (this._denominator !== undefined); }\n\n /**\n * Save this Constants properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): ConstantProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (this.phenomenon !== undefined)\n schemaJson.phenomenon = this.phenomenon.fullName;\n schemaJson.definition = this.definition;\n if (this.hasNumerator)\n schemaJson.numerator = this.numerator;\n if (this.hasDenominator)\n schemaJson.denominator = this.denominator;\n return schemaJson as ConstantProps;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n itemElement.setAttribute(\"definition\", this.definition);\n if (this.hasNumerator)\n itemElement.setAttribute(\"numerator\", this.numerator.toString());\n if (this.hasDenominator)\n itemElement.setAttribute(\"denominator\", this.denominator.toString());\n\n const phenomenon = await this.phenomenon;\n if (undefined !== phenomenon) {\n const phenomenonName = XmlSerializationUtils.createXmlTypedName(this.schema, phenomenon.schema, phenomenon.name);\n itemElement.setAttribute(\"phenomenon\", phenomenonName);\n }\n\n return itemElement;\n }\n\n public override fromJSONSync(constantProps: ConstantProps) {\n super.fromJSONSync(constantProps);\n\n const schemaItemKey = this.schema.getSchemaItemKey(constantProps.phenomenon);\n if (!schemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);\n this._phenomenon = new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(schemaItemKey,\n async () => {\n const phenom = await this.schema.lookupItem(schemaItemKey, Phenomenon);\n if (undefined === phenom)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);\n return phenom;\n });\n\n if (this._definition !== \"\" && constantProps.definition.toLowerCase() !== this._definition.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${this.name} has an invalid 'definition' attribute.`);\n else if (this._definition === \"\")\n this._definition = constantProps.definition;\n\n if (undefined !== constantProps.numerator) {\n if (constantProps.numerator !== this._numerator)\n this._numerator = constantProps.numerator;\n }\n\n if (undefined !== constantProps.denominator) {\n if (constantProps.denominator !== this._denominator)\n this._denominator = constantProps.denominator;\n }\n }\n\n public override async fromJSON(constantProps: ConstantProps) {\n this.fromJSONSync(constantProps);\n }\n\n /**\n * @alpha Used in schema editing.\n * @param phenomenon A LazyLoadedPhenomenon.\n */\n protected setPhenomenon(phenomenon: LazyLoadedPhenomenon) {\n this._phenomenon = phenomenon;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setDefinition(definition: string) {\n this._definition = definition;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setNumerator(numerator: number) {\n this._numerator = numerator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setDenominator(denominator: number) {\n this._denominator = denominator;\n }\n\n /**\n * Type guard to check if the SchemaItem is of type Constant.\n * @param item The SchemaItem to check.\n * @returns True if the item is a Constant, false otherwise.\n */\n public static isConstant(item?: SchemaItem): item is Constant {\n if (item && item.schemaItemType === SchemaItemType.Constant)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type Constant.\n * @param item The SchemaItem to check.\n * @returns The item cast to Constant if it is a Constant, undefined otherwise.\n */\n public static assertIsConstant(item?: SchemaItem): asserts item is Constant {\n if (!this.isConstant(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Constant}' (Constant)`);\n }\n}\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableConstant extends Constant {\n public abstract override setPhenomenon(phenomenon: LazyLoadedPhenomenon): void;\n public abstract override setDefinition(definition: string): void;\n public abstract override setNumerator(numerator: number): void;\n public abstract override setDenominator(denominator: number): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
* @module Metadata
|
|
3
3
|
*/
|
|
4
4
|
import { CustomAttributeClassProps } from "../Deserialization/JsonProps";
|
|
5
|
-
import { CustomAttributeContainerType,
|
|
5
|
+
import { CustomAttributeContainerType, SchemaItemType } from "../ECObjects";
|
|
6
6
|
import { ECClass } from "./Class";
|
|
7
|
-
import {
|
|
7
|
+
import { SchemaItem } from "./SchemaItem";
|
|
8
8
|
/**
|
|
9
9
|
* A Typescript class representation of an ECCustomAttributeClass.
|
|
10
10
|
* @beta
|
|
11
11
|
*/
|
|
12
12
|
export declare class CustomAttributeClass extends ECClass {
|
|
13
|
-
readonly schemaItemType: SchemaItemType
|
|
13
|
+
readonly schemaItemType: SchemaItemType;
|
|
14
|
+
static get schemaItemType(): SchemaItemType;
|
|
14
15
|
protected _appliesTo?: CustomAttributeContainerType;
|
|
15
16
|
/**
|
|
16
17
|
* @deprecated in 4.8 use [[appliesTo]]
|
|
17
18
|
* */
|
|
18
19
|
get containerType(): CustomAttributeContainerType;
|
|
19
20
|
get appliesTo(): CustomAttributeContainerType;
|
|
20
|
-
constructor(schema: Schema, name: string, modifier?: ECClassModifier);
|
|
21
21
|
/**
|
|
22
22
|
* Save this CustomAttributeClasses properties to an object for serializing to JSON.
|
|
23
23
|
* @param standalone Serialization includes only this object (as opposed to the full schema).
|
|
@@ -32,6 +32,18 @@ export declare class CustomAttributeClass extends ECClass {
|
|
|
32
32
|
* @alpha Used in schema editing.
|
|
33
33
|
*/
|
|
34
34
|
protected setAppliesTo(containerType: CustomAttributeContainerType): void;
|
|
35
|
+
/**
|
|
36
|
+
* Type guard to check if the SchemaItem is of type CustomAttributeClass.
|
|
37
|
+
* @param item The SchemaItem to check.
|
|
38
|
+
* @returns True if the item is a CustomAttributeClass, false otherwise.
|
|
39
|
+
*/
|
|
40
|
+
static isCustomAttributeClass(item?: SchemaItem): item is CustomAttributeClass;
|
|
41
|
+
/**
|
|
42
|
+
* Type assertion to check if the SchemaItem is of type CustomAttributeClass.
|
|
43
|
+
* @param item The SchemaItem to check.
|
|
44
|
+
* @returns The item cast to CustomAttributeClass if it is a CustomAttributeClass, undefined otherwise.
|
|
45
|
+
*/
|
|
46
|
+
static assertIsCustomAttributeClass(item?: SchemaItem): asserts item is CustomAttributeClass;
|
|
35
47
|
}
|
|
36
48
|
/**
|
|
37
49
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAttributeClass.d.ts","sourceRoot":"","sources":["../../../src/Metadata/CustomAttributeClass.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EACkB,4BAA4B,
|
|
1
|
+
{"version":3,"file":"CustomAttributeClass.d.ts","sourceRoot":"","sources":["../../../src/Metadata/CustomAttributeClass.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EACkB,4BAA4B,EAAqC,cAAc,EACvG,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,OAAO;IAC/C,SAAyB,cAAc,iBAAuC;IAC9E,WAA2B,cAAc,mBAAkD;IAC3F,SAAS,CAAC,UAAU,CAAC,EAAE,4BAA4B,CAAC;IAEpD;;SAEK;IACL,IAAW,aAAa,IAAI,4BAA4B,CAEvD;IAED,IAAW,SAAS,IAAI,4BAA4B,CAInD;IAED;;;;OAIG;IACa,MAAM,CAAC,UAAU,GAAE,OAAe,EAAE,oBAAoB,GAAE,OAAe,GAAG,yBAAyB;IAMrH,gBAAgB;IACM,KAAK,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAMlD,YAAY,CAAC,oBAAoB,EAAE,yBAAyB;IAQtD,QAAQ,CAAC,oBAAoB,EAAE,yBAAyB;IAI9E;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,aAAa,EAAE,4BAA4B;IAIlE;;;;OAIG;WACW,sBAAsB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,IAAI,oBAAoB;IAOrF;;;;OAIG;WACW,4BAA4B,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,oBAAoB;CAIpG;AACD;;;GAGG;AACH,8BAAsB,cAAe,SAAQ,oBAAoB;aACtC,YAAY,CAAC,aAAa,EAAE,4BAA4B,GAAG,IAAI;aAC/D,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
|
|
@@ -13,6 +13,9 @@ import { ECClass } from "./Class";
|
|
|
13
13
|
* @beta
|
|
14
14
|
*/
|
|
15
15
|
export class CustomAttributeClass extends ECClass {
|
|
16
|
+
schemaItemType = CustomAttributeClass.schemaItemType;
|
|
17
|
+
static get schemaItemType() { return SchemaItemType.CustomAttributeClass; }
|
|
18
|
+
_appliesTo;
|
|
16
19
|
/**
|
|
17
20
|
* @deprecated in 4.8 use [[appliesTo]]
|
|
18
21
|
* */
|
|
@@ -24,10 +27,6 @@ export class CustomAttributeClass extends ECClass {
|
|
|
24
27
|
throw new ECObjectsError(ECObjectsStatus.InvalidContainerType, `The CustomAttributeClass ${this.name} does not have a CustomAttributeContainerType.`);
|
|
25
28
|
return this._appliesTo;
|
|
26
29
|
}
|
|
27
|
-
constructor(schema, name, modifier) {
|
|
28
|
-
super(schema, name, modifier);
|
|
29
|
-
this.schemaItemType = SchemaItemType.CustomAttributeClass;
|
|
30
|
-
}
|
|
31
30
|
/**
|
|
32
31
|
* Save this CustomAttributeClasses properties to an object for serializing to JSON.
|
|
33
32
|
* @param standalone Serialization includes only this object (as opposed to the full schema).
|
|
@@ -60,6 +59,25 @@ export class CustomAttributeClass extends ECClass {
|
|
|
60
59
|
setAppliesTo(containerType) {
|
|
61
60
|
this._appliesTo = containerType;
|
|
62
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Type guard to check if the SchemaItem is of type CustomAttributeClass.
|
|
64
|
+
* @param item The SchemaItem to check.
|
|
65
|
+
* @returns True if the item is a CustomAttributeClass, false otherwise.
|
|
66
|
+
*/
|
|
67
|
+
static isCustomAttributeClass(item) {
|
|
68
|
+
if (item && item.schemaItemType === SchemaItemType.CustomAttributeClass)
|
|
69
|
+
return true;
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Type assertion to check if the SchemaItem is of type CustomAttributeClass.
|
|
74
|
+
* @param item The SchemaItem to check.
|
|
75
|
+
* @returns The item cast to CustomAttributeClass if it is a CustomAttributeClass, undefined otherwise.
|
|
76
|
+
*/
|
|
77
|
+
static assertIsCustomAttributeClass(item) {
|
|
78
|
+
if (!this.isCustomAttributeClass(item))
|
|
79
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.CustomAttributeClass}' (CustomAttributeClass)`);
|
|
80
|
+
}
|
|
63
81
|
}
|
|
64
82
|
/**
|
|
65
83
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAttributeClass.js","sourceRoot":"","sources":["../../../src/Metadata/CustomAttributeClass.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EACL,qBAAqB,
|
|
1
|
+
{"version":3,"file":"CustomAttributeClass.js","sourceRoot":"","sources":["../../../src/Metadata/CustomAttributeClass.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EACL,qBAAqB,EAAgC,iCAAiC,EAAE,cAAc,GACvG,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,OAAO;IACtB,cAAc,GAAG,oBAAoB,CAAC,cAAc,CAAC;IACvE,MAAM,KAAc,cAAc,KAAK,OAAO,cAAc,CAAC,oBAAoB,CAAC,CAAC,CAAC;IACjF,UAAU,CAAgC;IAEpD;;SAEK;IACL,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAW,SAAS;QAClB,IAAI,SAAS,KAAK,IAAI,CAAC,UAAU;YAC/B,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,oBAAoB,EAAE,4BAA4B,IAAI,CAAC,IAAI,gDAAgD,CAAC,CAAC;QACxJ,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACa,MAAM,CAAC,aAAsB,KAAK,EAAE,uBAAgC,KAAK;QACvF,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,oBAAoB,CAAQ,CAAC;QACzE,UAAU,CAAC,SAAS,GAAG,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7D,OAAO,UAAuC,CAA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AAe,SAAQ,oBAAoB;CAGhE","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { CustomAttributeClassProps } from \"../Deserialization/JsonProps\";\nimport {\n containerTypeToString, CustomAttributeContainerType, parseCustomAttributeContainerType, SchemaItemType,\n} from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { ECClass } from \"./Class\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Typescript class representation of an ECCustomAttributeClass.\n * @beta\n */\nexport class CustomAttributeClass extends ECClass {\n public override readonly schemaItemType = CustomAttributeClass.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.CustomAttributeClass; }\n protected _appliesTo?: CustomAttributeContainerType;\n\n /**\n * @deprecated in 4.8 use [[appliesTo]]\n * */\n public get containerType(): CustomAttributeContainerType {\n return this.appliesTo;\n }\n\n public get appliesTo(): CustomAttributeContainerType {\n if (undefined === this._appliesTo)\n throw new ECObjectsError(ECObjectsStatus.InvalidContainerType, `The CustomAttributeClass ${this.name} does not have a CustomAttributeContainerType.`);\n return this._appliesTo;\n }\n\n /**\n * Save this CustomAttributeClasses properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): CustomAttributeClassProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.appliesTo = containerTypeToString(this.appliesTo);\n return schemaJson as CustomAttributeClassProps;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n itemElement.setAttribute(\"appliesTo\", containerTypeToString(this.appliesTo));\n return itemElement;\n }\n\n public override fromJSONSync(customAttributeProps: CustomAttributeClassProps) {\n super.fromJSONSync(customAttributeProps);\n const appliesTo = parseCustomAttributeContainerType(customAttributeProps.appliesTo);\n if (undefined === appliesTo)\n throw new ECObjectsError(ECObjectsStatus.InvalidContainerType, `${appliesTo} is not a valid CustomAttributeContainerType.`);\n this._appliesTo = appliesTo;\n }\n\n public override async fromJSON(customAttributeProps: CustomAttributeClassProps) {\n this.fromJSONSync(customAttributeProps);\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setAppliesTo(containerType: CustomAttributeContainerType) {\n this._appliesTo = containerType;\n }\n\n /**\n * Type guard to check if the SchemaItem is of type CustomAttributeClass.\n * @param item The SchemaItem to check.\n * @returns True if the item is a CustomAttributeClass, false otherwise.\n */\n public static isCustomAttributeClass(item?: SchemaItem): item is CustomAttributeClass {\n if (item && item.schemaItemType === SchemaItemType.CustomAttributeClass)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type CustomAttributeClass.\n * @param item The SchemaItem to check.\n * @returns The item cast to CustomAttributeClass if it is a CustomAttributeClass, undefined otherwise.\n */\n public static assertIsCustomAttributeClass(item?: SchemaItem): asserts item is CustomAttributeClass {\n if (!this.isCustomAttributeClass(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.CustomAttributeClass}' (CustomAttributeClass)`);\n }\n}\n/**\n * @internal\n * An abstract class used for Schema editing.\n */\nexport abstract class MutableCAClass extends CustomAttributeClass {\n public abstract override setAppliesTo(containerType: CustomAttributeContainerType): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
* @module Metadata
|
|
3
3
|
*/
|
|
4
4
|
import { EntityClassProps } from "../Deserialization/JsonProps";
|
|
5
|
-
import {
|
|
6
|
-
import { LazyLoadedMixin } from "../Interfaces";
|
|
5
|
+
import { SchemaItemType, StrengthDirection } from "../ECObjects";
|
|
6
|
+
import { HasMixins, LazyLoadedMixin } from "../Interfaces";
|
|
7
7
|
import { ECClass } from "./Class";
|
|
8
8
|
import { Mixin } from "./Mixin";
|
|
9
9
|
import { AnyProperty, NavigationProperty, Property } from "./Property";
|
|
10
10
|
import { RelationshipClass } from "./RelationshipClass";
|
|
11
|
-
import {
|
|
11
|
+
import { SchemaItem } from "./SchemaItem";
|
|
12
12
|
/**
|
|
13
13
|
* A Typescript class representation of an ECEntityClass.
|
|
14
14
|
* @beta
|
|
15
15
|
*/
|
|
16
|
-
export declare class EntityClass extends ECClass {
|
|
17
|
-
readonly schemaItemType: SchemaItemType
|
|
16
|
+
export declare class EntityClass extends ECClass implements HasMixins {
|
|
17
|
+
readonly schemaItemType: SchemaItemType;
|
|
18
|
+
static get schemaItemType(): SchemaItemType;
|
|
18
19
|
protected _mixins?: LazyLoadedMixin[];
|
|
19
|
-
constructor(schema: Schema, name: string, modifier?: ECClassModifier);
|
|
20
20
|
get mixins(): LazyLoadedMixin[];
|
|
21
21
|
getMixinsSync(): Iterable<Mixin>;
|
|
22
22
|
/**
|
|
@@ -60,6 +60,18 @@ export declare class EntityClass extends ECClass {
|
|
|
60
60
|
toXml(schemaXml: Document): Promise<Element>;
|
|
61
61
|
fromJSON(entityClassProps: EntityClassProps): Promise<void>;
|
|
62
62
|
fromJSONSync(entityClassProps: EntityClassProps): void;
|
|
63
|
+
/**
|
|
64
|
+
* Type guard to check if the SchemaItem is of type EntityClass.
|
|
65
|
+
* @param item The SchemaItem to check.
|
|
66
|
+
* @returns True if the item is an EntityClass, false otherwise.
|
|
67
|
+
*/
|
|
68
|
+
static isEntityClass(item?: SchemaItem): item is EntityClass;
|
|
69
|
+
/**
|
|
70
|
+
* Type assertion to check if the SchemaItem is of type EntityClass.
|
|
71
|
+
* @param item The SchemaItem to check.
|
|
72
|
+
* @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.
|
|
73
|
+
*/
|
|
74
|
+
static assertIsEntityClass(item?: SchemaItem): asserts item is EntityClass;
|
|
63
75
|
}
|
|
64
76
|
/**
|
|
65
77
|
* Hackish approach that works like a "friend class" so we can access protected members without making them public.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityClass.d.ts","sourceRoot":"","sources":["../../../src/Metadata/EntityClass.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,
|
|
1
|
+
{"version":3,"file":"EntityClass.d.ts","sourceRoot":"","sources":["../../../src/Metadata/EntityClass.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,EAA0B,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEzF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,qBAAa,WAAY,SAAQ,OAAQ,YAAW,SAAS;IAC3D,SAAyB,cAAc,iBAA8B;IACrE,WAA2B,cAAc,mBAAyC;IAClF,SAAS,CAAC,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAEtC,IAAW,MAAM,IAAI,eAAe,EAAE,CAIrC;IAEO,aAAa,IAAI,QAAQ,CAAC,KAAK,CAAC;IAYxC;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK;IAQ/B;;;OAGG;IACmB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAc1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KAAK,GAAG,GAAG;aAC3B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;aACpJ,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,kBAAkB;aAC/I,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE;AAED,gBAAgB;AAChB,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAsB3L;AAED,gBAAgB;AAChB,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,kBAAkB,CAsBhL"}
|
|
@@ -10,16 +10,17 @@ import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils"
|
|
|
10
10
|
import { parseStrengthDirection, SchemaItemType } from "../ECObjects";
|
|
11
11
|
import { ECObjectsError, ECObjectsStatus } from "../Exception";
|
|
12
12
|
import { ECClass } from "./Class";
|
|
13
|
+
import { Mixin } from "./Mixin";
|
|
13
14
|
import { NavigationProperty } from "./Property";
|
|
15
|
+
import { RelationshipClass } from "./RelationshipClass";
|
|
14
16
|
/**
|
|
15
17
|
* A Typescript class representation of an ECEntityClass.
|
|
16
18
|
* @beta
|
|
17
19
|
*/
|
|
18
20
|
export class EntityClass extends ECClass {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
21
|
+
schemaItemType = EntityClass.schemaItemType;
|
|
22
|
+
static get schemaItemType() { return SchemaItemType.EntityClass; }
|
|
23
|
+
_mixins;
|
|
23
24
|
get mixins() {
|
|
24
25
|
if (!this._mixins)
|
|
25
26
|
return [];
|
|
@@ -29,7 +30,7 @@ export class EntityClass extends ECClass {
|
|
|
29
30
|
if (!this._mixins)
|
|
30
31
|
return function* () { }(); // empty iterable
|
|
31
32
|
for (const mixin of this._mixins) {
|
|
32
|
-
const mObj = this.schema.lookupItemSync(mixin);
|
|
33
|
+
const mObj = this.schema.lookupItemSync(mixin, Mixin);
|
|
33
34
|
if (mObj) {
|
|
34
35
|
yield mObj;
|
|
35
36
|
}
|
|
@@ -73,7 +74,7 @@ export class EntityClass extends ECClass {
|
|
|
73
74
|
}
|
|
74
75
|
for (const mixin of this._mixins) {
|
|
75
76
|
const mObj = this.schema.lookupItemSync(mixin);
|
|
76
|
-
if (mObj) {
|
|
77
|
+
if (mObj && ECClass.isECClass(mObj)) {
|
|
77
78
|
const result = mObj.getPropertySync(name, true);
|
|
78
79
|
if (result) {
|
|
79
80
|
return result;
|
|
@@ -164,7 +165,7 @@ export class EntityClass extends ECClass {
|
|
|
164
165
|
if (!mixinSchemaItemKey)
|
|
165
166
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin ("${name}") that cannot be found.`);
|
|
166
167
|
this._mixins.push(new DelayedPromiseWithProps(mixinSchemaItemKey, async () => {
|
|
167
|
-
const mixin = await this.schema.lookupItem(mixinSchemaItemKey);
|
|
168
|
+
const mixin = await this.schema.lookupItem(mixinSchemaItemKey, Mixin);
|
|
168
169
|
if (undefined === mixin)
|
|
169
170
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin ("${name}") that cannot be found.`);
|
|
170
171
|
return mixin;
|
|
@@ -172,6 +173,25 @@ export class EntityClass extends ECClass {
|
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Type guard to check if the SchemaItem is of type EntityClass.
|
|
178
|
+
* @param item The SchemaItem to check.
|
|
179
|
+
* @returns True if the item is an EntityClass, false otherwise.
|
|
180
|
+
*/
|
|
181
|
+
static isEntityClass(item) {
|
|
182
|
+
if (item && item.schemaItemType === SchemaItemType.EntityClass)
|
|
183
|
+
return true;
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Type assertion to check if the SchemaItem is of type EntityClass.
|
|
188
|
+
* @param item The SchemaItem to check.
|
|
189
|
+
* @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.
|
|
190
|
+
*/
|
|
191
|
+
static assertIsEntityClass(item) {
|
|
192
|
+
if (!this.isEntityClass(item))
|
|
193
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.EntityClass}' (EntityClass)`);
|
|
194
|
+
}
|
|
175
195
|
}
|
|
176
196
|
/**
|
|
177
197
|
* Hackish approach that works like a "friend class" so we can access protected members without making them public.
|
|
@@ -185,7 +205,7 @@ export async function createNavigationProperty(ecClass, name, relationship, dire
|
|
|
185
205
|
throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);
|
|
186
206
|
let resolvedRelationship;
|
|
187
207
|
if (typeof (relationship) === "string") {
|
|
188
|
-
resolvedRelationship = await ecClass.schema.lookupItem(relationship);
|
|
208
|
+
resolvedRelationship = await ecClass.schema.lookupItem(relationship, RelationshipClass);
|
|
189
209
|
}
|
|
190
210
|
else
|
|
191
211
|
resolvedRelationship = relationship;
|
|
@@ -206,7 +226,7 @@ export function createNavigationPropertySync(ecClass, name, relationship, direct
|
|
|
206
226
|
throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);
|
|
207
227
|
let resolvedRelationship;
|
|
208
228
|
if (typeof (relationship) === "string") {
|
|
209
|
-
resolvedRelationship = ecClass.schema.lookupItemSync(relationship);
|
|
229
|
+
resolvedRelationship = ecClass.schema.lookupItemSync(relationship, RelationshipClass);
|
|
210
230
|
}
|
|
211
231
|
else
|
|
212
232
|
resolvedRelationship = relationship;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityClass.js","sourceRoot":"","sources":["../../../src/Metadata/EntityClass.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAmB,sBAAsB,EAAE,cAAc,EAAqB,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAe,kBAAkB,EAAY,MAAM,YAAY,CAAC;AAIvE;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,OAAO;IAItC,YAAY,MAAc,EAAE,IAAY,EAAE,QAA0B;QAClE,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC9B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC,WAAW,CAAC;IACnD,CAAC;IAED,IAAW,MAAM;QACf,IAAI,CAAC,IAAI,CAAC,OAAO;YACf,OAAO,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEM,CAAC,aAAa;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO;YACf,OAAO,QAAQ,CAAC,MAAuB,CAAC,EAAE,CAAC,CAAC,iBAAiB;QAE/D,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAQ,KAAK,CAAC,CAAC;YACtD,IAAI,IA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C,CAAC;QACxJ,SAAS,GAAG,YAAY,CAAC;IAC3B,CAAC;IAED,MAAM,gBAAgB,GAAG,IAAI,uBAAuB,CAAC,oBAAoB,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,oBAAoB,CAAC,CAAC;IACjH,OAAO,IAAI,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { EntityClassProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { ECClassModifier, parseStrengthDirection, SchemaItemType, StrengthDirection } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { LazyLoadedMixin } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { ECClass } from \"./Class\";\nimport { Mixin } from \"./Mixin\";\nimport { AnyProperty, NavigationProperty, Property } from \"./Property\";\nimport { RelationshipClass } from \"./RelationshipClass\";\nimport { Schema } from \"./Schema\";\n\n/**\n * A Typescript class representation of an ECEntityClass.\n * @beta\n */\nexport class EntityClass extends ECClass {\n public override readonly schemaItemType!: SchemaItemType.EntityClass;\n protected _mixins?: LazyLoadedMixin[];\n\n constructor(schema: Schema, name: string, modifier?: ECClassModifier) {\n super(schema, name, modifier);\n this.schemaItemType = SchemaItemType.EntityClass;\n }\n\n public get mixins(): LazyLoadedMixin[] {\n if (!this._mixins)\n return [];\n return this._mixins;\n }\n\n public *getMixinsSync(): Iterable<Mixin> {\n if (!this._mixins)\n return function* (): Iterable<Mixin> { }(); // empty iterable\n\n for (const mixin of this._mixins) {\n const mObj = this.schema.lookupItemSync<Mixin>(mixin);\n if (mObj) {\n yield mObj;\n }\n }\n }\n\n /**\n *\n * @param mixin\n */\n protected addMixin(mixin: Mixin) {\n if (!this._mixins)\n this._mixins = [];\n\n this._mixins.push(new DelayedPromiseWithProps(mixin.key, async () => mixin));\n return;\n }\n\n /**\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\n * @param name The name of the property to find.\n */\n public override async getInheritedProperty(name: string): Promise<AnyProperty | undefined> {\n let inheritedProperty = await super.getInheritedProperty(name);\n\n if (!inheritedProperty && this._mixins) {\n const mixinProps = await Promise.all(this._mixins.map(async (mixin) => (await mixin).getProperty(name)));\n mixinProps.some((prop) => {\n inheritedProperty = prop as AnyProperty;\n return inheritedProperty !== undefined;\n });\n }\n\n return inheritedProperty as AnyProperty | undefined;\n }\n\n /**\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\n * @param name The name of the property to find.\n */\n public override getInheritedPropertySync(name: string): Property | undefined {\n const inheritedProperty = super.getInheritedPropertySync(name);\n if (inheritedProperty)\n return inheritedProperty;\n\n if (!this._mixins) {\n return undefined;\n }\n\n for (const mixin of this._mixins) {\n const mObj = this.schema.lookupItemSync<ECClass>(mixin);\n if (mObj) {\n const result = mObj.getPropertySync(name, true);\n if (result) {\n return result;\n }\n }\n }\n\n return undefined;\n }\n\n protected override async buildPropertyCache(result: Property[], existingValues?: Map<string, number>, resetBaseCaches: boolean = false): Promise<void> {\n if (!existingValues) {\n existingValues = new Map<string, number>();\n }\n\n if (this.baseClass) {\n ECClass.mergeProperties(result, existingValues, await (await this.baseClass).getProperties(resetBaseCaches), false);\n }\n\n for (const mixin of this.mixins) {\n ECClass.mergeProperties(result, existingValues, await (await mixin).getProperties(resetBaseCaches), false);\n }\n\n if (!this.properties)\n return;\n\n ECClass.mergeProperties(result, existingValues, [...this.properties], true);\n }\n\n protected override buildPropertyCacheSync(result: Property[], existingValues?: Map<string, number>, resetBaseCaches: boolean = false): void {\n if (!existingValues) {\n existingValues = new Map<string, number>();\n }\n\n const baseClass = this.getBaseClassSync();\n if (baseClass) {\n ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(resetBaseCaches), false);\n }\n\n for (const mixin of this.getMixinsSync()) {\n ECClass.mergeProperties(result, existingValues, mixin.getPropertiesSync(resetBaseCaches), false);\n }\n\n if (!this.properties)\n return;\n\n ECClass.mergeProperties(result, existingValues, [...this.properties], true);\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n */\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n */\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\n }\n\n /**\n * Save this EntityClass' properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): EntityClassProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (this.mixins.length > 0)\n schemaJson.mixins = this.mixins.map((mixin) => mixin.fullName);\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n for (const mixin of this.getMixinsSync()) {\n const mixinElement = schemaXml.createElement(\"BaseClass\");\n const mixinName = XmlSerializationUtils.createXmlTypedName(this.schema, mixin.schema, mixin.name);\n mixinElement.textContent = mixinName;\n itemElement.appendChild(mixinElement);\n }\n return itemElement;\n }\n\n public override async fromJSON(entityClassProps: EntityClassProps) {\n this.fromJSONSync(entityClassProps);\n }\n\n public override fromJSONSync(entityClassProps: EntityClassProps) {\n super.fromJSONSync(entityClassProps);\n\n if (undefined !== entityClassProps.mixins) {\n if (!this._mixins)\n this._mixins = [];\n for (const name of entityClassProps.mixins) {\n const mixinSchemaItemKey = this.schema.getSchemaItemKey(name);\n if (!mixinSchemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\n this._mixins.push(new DelayedPromiseWithProps<SchemaItemKey, Mixin>(mixinSchemaItemKey,\n async () => {\n const mixin = await this.schema.lookupItem<Mixin>(mixinSchemaItemKey);\n if (undefined === mixin)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\n return mixin;\n }));\n }\n }\n }\n}\n\n/**\n * Hackish approach that works like a \"friend class\" so we can access protected members without making them public.\n * @internal\n */\nexport abstract class MutableEntityClass extends EntityClass {\n public abstract override addMixin(mixin: Mixin): any;\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n\n/** @internal */\nexport async function createNavigationProperty(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n if (await ecClass.getProperty(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\n\n let resolvedRelationship: RelationshipClass | undefined;\n if (typeof (relationship) === \"string\") {\n resolvedRelationship = await ecClass.schema.lookupItem<RelationshipClass>(relationship);\n } else\n resolvedRelationship = relationship;\n\n if (!resolvedRelationship)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\n\n if (typeof (direction) === \"string\") {\n const tmpDirection = parseStrengthDirection(direction);\n if (undefined === tmpDirection)\n throw new ECObjectsError(ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\n direction = tmpDirection;\n }\n\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\n}\n\n/** @internal */\nexport function createNavigationPropertySync(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n if (ecClass.getPropertySync(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\n\n let resolvedRelationship: RelationshipClass | undefined;\n if (typeof (relationship) === \"string\") {\n resolvedRelationship = ecClass.schema.lookupItemSync<RelationshipClass>(relationship);\n } else\n resolvedRelationship = relationship;\n\n if (!resolvedRelationship)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\n\n if (typeof (direction) === \"string\") {\n const tmpDirection = parseStrengthDirection(direction);\n if (undefined === tmpDirection)\n throw new ECObjectsError(ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\n direction = tmpDirection;\n }\n\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"EntityClass.js","sourceRoot":"","sources":["../../../src/Metadata/EntityClass.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAqB,MAAM,cAAc,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,e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AM,IAAI,cAAc,CAAC,eAAe,CAAC,wBAAwB,EAAE,mCAAmC,SAAS,qCAAqC,CAAC,CAAC;QACxJ,SAAS,GAAG,YAAY,CAAC;IAC3B,CAAC;IAED,MAAM,gBAAgB,GAAG,IAAI,uBAAuB,CAAC,oBAAoB,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,oBAAoB,CAAC,CAAC;IACjH,OAAO,IAAI,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { EntityClassProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { parseStrengthDirection, SchemaItemType, StrengthDirection } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { HasMixins, LazyLoadedMixin } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { ECClass } from \"./Class\";\nimport { Mixin } from \"./Mixin\";\nimport { AnyProperty, NavigationProperty, Property } from \"./Property\";\nimport { RelationshipClass } from \"./RelationshipClass\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Typescript class representation of an ECEntityClass.\n * @beta\n */\nexport class EntityClass extends ECClass implements HasMixins {\n public override readonly schemaItemType = EntityClass.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.EntityClass; }\n protected _mixins?: LazyLoadedMixin[];\n\n public get mixins(): LazyLoadedMixin[] {\n if (!this._mixins)\n return [];\n return this._mixins;\n }\n\n public *getMixinsSync(): Iterable<Mixin> {\n if (!this._mixins)\n return function* (): Iterable<Mixin> { }(); // empty iterable\n\n for (const mixin of this._mixins) {\n const mObj = this.schema.lookupItemSync(mixin, Mixin);\n if (mObj) {\n yield mObj;\n }\n }\n }\n\n /**\n *\n * @param mixin\n */\n protected addMixin(mixin: Mixin) {\n if (!this._mixins)\n this._mixins = [];\n\n this._mixins.push(new DelayedPromiseWithProps(mixin.key, async () => mixin));\n return;\n }\n\n /**\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\n * @param name The name of the property to find.\n */\n public override async getInheritedProperty(name: string): Promise<AnyProperty | undefined> {\n let inheritedProperty = await super.getInheritedProperty(name);\n\n if (!inheritedProperty && this._mixins) {\n const mixinProps = await Promise.all(this._mixins.map(async (mixin) => (await mixin).getProperty(name)));\n mixinProps.some((prop) => {\n inheritedProperty = prop as AnyProperty;\n return inheritedProperty !== undefined;\n });\n }\n\n return inheritedProperty as AnyProperty | undefined;\n }\n\n /**\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\n * @param name The name of the property to find.\n */\n public override getInheritedPropertySync(name: string): Property | undefined {\n const inheritedProperty = super.getInheritedPropertySync(name);\n if (inheritedProperty)\n return inheritedProperty;\n\n if (!this._mixins) {\n return undefined;\n }\n\n for (const mixin of this._mixins) {\n const mObj = this.schema.lookupItemSync(mixin);\n if (mObj && ECClass.isECClass(mObj)) {\n const result = mObj.getPropertySync(name, true);\n if (result) {\n return result;\n }\n }\n }\n\n return undefined;\n }\n\n protected override async buildPropertyCache(result: Property[], existingValues?: Map<string, number>, resetBaseCaches: boolean = false): Promise<void> {\n if (!existingValues) {\n existingValues = new Map<string, number>();\n }\n\n if (this.baseClass) {\n ECClass.mergeProperties(result, existingValues, await (await this.baseClass).getProperties(resetBaseCaches), false);\n }\n\n for (const mixin of this.mixins) {\n ECClass.mergeProperties(result, existingValues, await (await mixin).getProperties(resetBaseCaches), false);\n }\n\n if (!this.properties)\n return;\n\n ECClass.mergeProperties(result, existingValues, [...this.properties], true);\n }\n\n protected override buildPropertyCacheSync(result: Property[], existingValues?: Map<string, number>, resetBaseCaches: boolean = false): void {\n if (!existingValues) {\n existingValues = new Map<string, number>();\n }\n\n const baseClass = this.getBaseClassSync();\n if (baseClass) {\n ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(resetBaseCaches), false);\n }\n\n for (const mixin of this.getMixinsSync()) {\n ECClass.mergeProperties(result, existingValues, mixin.getPropertiesSync(resetBaseCaches), false);\n }\n\n if (!this.properties)\n return;\n\n ECClass.mergeProperties(result, existingValues, [...this.properties], true);\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n */\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n */\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\n }\n\n /**\n * Save this EntityClass' properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): EntityClassProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (this.mixins.length > 0)\n schemaJson.mixins = this.mixins.map((mixin) => mixin.fullName);\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n for (const mixin of this.getMixinsSync()) {\n const mixinElement = schemaXml.createElement(\"BaseClass\");\n const mixinName = XmlSerializationUtils.createXmlTypedName(this.schema, mixin.schema, mixin.name);\n mixinElement.textContent = mixinName;\n itemElement.appendChild(mixinElement);\n }\n return itemElement;\n }\n\n public override async fromJSON(entityClassProps: EntityClassProps) {\n this.fromJSONSync(entityClassProps);\n }\n\n public override fromJSONSync(entityClassProps: EntityClassProps) {\n super.fromJSONSync(entityClassProps);\n\n if (undefined !== entityClassProps.mixins) {\n if (!this._mixins)\n this._mixins = [];\n for (const name of entityClassProps.mixins) {\n const mixinSchemaItemKey = this.schema.getSchemaItemKey(name);\n if (!mixinSchemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\n this._mixins.push(new DelayedPromiseWithProps<SchemaItemKey, Mixin>(mixinSchemaItemKey,\n async () => {\n const mixin = await this.schema.lookupItem(mixinSchemaItemKey, Mixin);\n if (undefined === mixin)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\n return mixin;\n }));\n }\n }\n }\n\n /**\n * Type guard to check if the SchemaItem is of type EntityClass.\n * @param item The SchemaItem to check.\n * @returns True if the item is an EntityClass, false otherwise.\n */\n public static isEntityClass(item?: SchemaItem): item is EntityClass {\n if (item && item.schemaItemType === SchemaItemType.EntityClass)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type EntityClass.\n * @param item The SchemaItem to check.\n * @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.\n */\n public static assertIsEntityClass(item?: SchemaItem): asserts item is EntityClass {\n if(!this.isEntityClass(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.EntityClass}' (EntityClass)`);\n }\n}\n\n/**\n * Hackish approach that works like a \"friend class\" so we can access protected members without making them public.\n * @internal\n */\nexport abstract class MutableEntityClass extends EntityClass {\n public abstract override addMixin(mixin: Mixin): any;\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n\n/** @internal */\nexport async function createNavigationProperty(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n if (await ecClass.getProperty(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\n\n let resolvedRelationship: RelationshipClass | undefined;\n if (typeof (relationship) === \"string\") {\n resolvedRelationship = await ecClass.schema.lookupItem(relationship, RelationshipClass);\n } else\n resolvedRelationship = relationship;\n\n if (!resolvedRelationship)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\n\n if (typeof (direction) === \"string\") {\n const tmpDirection = parseStrengthDirection(direction);\n if (undefined === tmpDirection)\n throw new ECObjectsError(ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\n direction = tmpDirection;\n }\n\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\n}\n\n/** @internal */\nexport function createNavigationPropertySync(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n if (ecClass.getPropertySync(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\n\n let resolvedRelationship: RelationshipClass | undefined;\n if (typeof (relationship) === \"string\") {\n resolvedRelationship = ecClass.schema.lookupItemSync(relationship, RelationshipClass);\n } else\n resolvedRelationship = relationship;\n\n if (!resolvedRelationship)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\n\n if (typeof (direction) === \"string\") {\n const tmpDirection = parseStrengthDirection(direction);\n if (undefined === tmpDirection)\n throw new ECObjectsError(ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\n direction = tmpDirection;\n }\n\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\n}\n"]}
|
|
@@ -19,7 +19,8 @@ export type AnyEnumerator = Enumerator<string | number>;
|
|
|
19
19
|
* @beta
|
|
20
20
|
*/
|
|
21
21
|
export declare class Enumeration extends SchemaItem {
|
|
22
|
-
readonly schemaItemType: SchemaItemType
|
|
22
|
+
readonly schemaItemType: SchemaItemType;
|
|
23
|
+
static get schemaItemType(): SchemaItemType;
|
|
23
24
|
protected _type?: PrimitiveType.Integer | PrimitiveType.String;
|
|
24
25
|
protected _isStrict: boolean;
|
|
25
26
|
protected _enumerators: AnyEnumerator[];
|
|
@@ -75,6 +76,18 @@ export declare class Enumeration extends SchemaItem {
|
|
|
75
76
|
* @alpha Used in schema editing.
|
|
76
77
|
*/
|
|
77
78
|
protected setIsStrict(isStrict: boolean): void;
|
|
79
|
+
/**
|
|
80
|
+
* Type guard to check if the SchemaItem is of type Enumeration.
|
|
81
|
+
* @param item The SchemaItem to check.
|
|
82
|
+
* @returns True if the item is an Enumeration, false otherwise.
|
|
83
|
+
*/
|
|
84
|
+
static isEnumeration(item?: SchemaItem): item is Enumeration;
|
|
85
|
+
/**
|
|
86
|
+
* Type assertion to check if the SchemaItem is of type Enumeration.
|
|
87
|
+
* @param item The SchemaItem to check.
|
|
88
|
+
* @returns The item cast to Enumeration if it is an Enumeration, undefined otherwise.
|
|
89
|
+
*/
|
|
90
|
+
static assertIsEnumeration(item?: SchemaItem): asserts item is Enumeration;
|
|
78
91
|
}
|
|
79
92
|
/** @internal
|
|
80
93
|
* An abstract class used for schema editing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Enumeration.d.ts","sourceRoot":"","sources":["../../../src/Metadata/Enumeration.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAmB,MAAM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AAY,CAAC,gBAAgB,EAAE,gBAAgB;IA6BzC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB;IAIjE;;OAEG;IACH,SAAS,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO;IAIvC;;;;OAIG;WACW,aAAa,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,IAAI,WAAW;IAInE;;;;OAIG;WACW,mBAAmB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,WAAW;CAIlF;AAED;;GAEG;AACH,8BAAsB,kBAAmB,SAAQ,WAAW;aACjC,aAAa,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI;aAC9C,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;aACpC,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
|
|
@@ -15,12 +15,16 @@ import { SchemaItem } from "./SchemaItem";
|
|
|
15
15
|
* @beta
|
|
16
16
|
*/
|
|
17
17
|
export class Enumeration extends SchemaItem {
|
|
18
|
+
schemaItemType = Enumeration.schemaItemType;
|
|
19
|
+
static get schemaItemType() { return SchemaItemType.Enumeration; }
|
|
20
|
+
_type;
|
|
21
|
+
_isStrict;
|
|
22
|
+
_enumerators;
|
|
18
23
|
get enumerators() { return this._enumerators; }
|
|
19
24
|
get type() { return this._type; }
|
|
20
25
|
get isStrict() { return this._isStrict; }
|
|
21
26
|
constructor(schema, name, primitiveType) {
|
|
22
27
|
super(schema, name);
|
|
23
|
-
this.schemaItemType = SchemaItemType.Enumeration;
|
|
24
28
|
this._type = primitiveType;
|
|
25
29
|
this._isStrict = true;
|
|
26
30
|
this._enumerators = [];
|
|
@@ -153,6 +157,23 @@ export class Enumeration extends SchemaItem {
|
|
|
153
157
|
setIsStrict(isStrict) {
|
|
154
158
|
this._isStrict = isStrict;
|
|
155
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Type guard to check if the SchemaItem is of type Enumeration.
|
|
162
|
+
* @param item The SchemaItem to check.
|
|
163
|
+
* @returns True if the item is an Enumeration, false otherwise.
|
|
164
|
+
*/
|
|
165
|
+
static isEnumeration(item) {
|
|
166
|
+
return item?.schemaItemType === SchemaItemType.Enumeration;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Type assertion to check if the SchemaItem is of type Enumeration.
|
|
170
|
+
* @param item The SchemaItem to check.
|
|
171
|
+
* @returns The item cast to Enumeration if it is an Enumeration, undefined otherwise.
|
|
172
|
+
*/
|
|
173
|
+
static assertIsEnumeration(item) {
|
|
174
|
+
if (!this.isEnumeration(item))
|
|
175
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Enumeration}' (Enumeration)`);
|
|
176
|
+
}
|
|
156
177
|
}
|
|
157
178
|
/** @internal
|
|
158
179
|
* An abstract class used for schema editing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Enumeration.js","sourceRoot":"","sources":["../../../src/Metadata/Enumeration.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAiB,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAa1C;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,UAAU;IAMzC,IAAW,WAAW,KAAK,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IACtD,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACxC,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhD,YAAY,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,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;YAC/D,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;gBACnD,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,aAAa,EAAE,mBAAmB,IAAI,CAAC,IAAI,0CAA0C,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;QACjN,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC,QAAQ,CAAC;QAE3C,IAAI,SAAS,KAAK,gBAAgB,CAAC,WAAW,EAAE,CAAC;YAC/C,gBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,UAA2B,EAAE,EAAE;gBACnE,4JAA4J;gBAC5J,0FAA0F;gBAC1F,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;YACzH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAEe,KAAK,CAAC,QAAQ,CAAC,gBAAkC;QAC/D,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACO,WAAW,CAAC,QAAiB;QACrC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;CAEF;AAED;;GAEG;AACH,MAAM,OAAgB,kBAAmB,SAAQ,WAAW;CAI3D","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { ECSpecVersion, SchemaReadHelper } from \"../Deserialization/Helper\";\nimport { EnumerationProps, EnumeratorProps } from \"../Deserialization/JsonProps\";\nimport { PrimitiveType, primitiveTypeToString, SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { ECName } from \"../ECName\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/** @beta */\nexport interface Enumerator<T> {\n readonly name: string;\n readonly value: T;\n readonly label?: string;\n readonly description?: string;\n}\n\n/** @beta */\nexport type AnyEnumerator = Enumerator<string | number>;\n\n/**\n * A Typescript class representation of an ECEnumeration.\n * @beta\n */\nexport class Enumeration extends SchemaItem {\n public override readonly schemaItemType!: SchemaItemType.Enumeration;\n protected _type?: PrimitiveType.Integer | PrimitiveType.String;\n protected _isStrict: boolean;\n protected _enumerators: AnyEnumerator[];\n\n public get enumerators() { return this._enumerators; }\n public get type() { return this._type; }\n public get isStrict() { return this._isStrict; }\n\n constructor(schema: Schema, name: string, primitiveType?: PrimitiveType.Integer | PrimitiveType.String) {\n super(schema, name);\n this.schemaItemType = SchemaItemType.Enumeration;\n this._type = primitiveType;\n this._isStrict = true;\n this._enumerators = [];\n }\n\n public get isInt(): boolean { return this._type === PrimitiveType.Integer; }\n public get isString(): boolean { return this._type === PrimitiveType.String; }\n\n /**\n * Gets an enumerator that matches the name provided.\n * @param name The ECName of the Enumerator to find.\n */\n public getEnumeratorByName(name: string): AnyEnumerator | undefined {\n return this.enumerators.find((item) => item.name.toLowerCase() === name.toLowerCase());\n }\n\n /**\n * Gets an enumerator that matches the value provided.\n * @param value The value of the Enumerator to find.\n */\n public getEnumerator(value: string): Enumerator<string> | undefined;\n public getEnumerator(value: number): Enumerator<number> | undefined;\n public getEnumerator(value: string | number): AnyEnumerator | undefined {\n return this.enumerators.find((item) => item.value === value);\n }\n\n /**\n * Checks whether there already exists an enumerator with this name or this value\n * @param name The name of the enumerator we are trying to create\n * @param value The value of the enumerator we are trying to create\n * @internal\n */\n private findDuplicateEnumerators(name: string, value: string | number) {\n this._enumerators.forEach((element: AnyEnumerator) => { // Name and value must be unique within the ECEnumerations\n if (element.name.toLowerCase() === name.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Enumeration ${this.name} has a duplicate Enumerator with name '${name}'.`);\n if (element.value === value)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Enumeration ${this.name} has a duplicate Enumerator with value '${value}'.`);\n });\n }\n\n /**\n * Creates an Enumerator with the provided name and value as well as optional parameters label and description\n * @param name The name of the enumerator\n * @param value The value of the enumerator. The type of this value is dependent on the backing type of the this Enumeration.\n * @param label A localized display label that is used instead of the name in a GUI.\n * @param description A localized description for the enumerator.\n * @return AnyEnumerator object\n */\n public createEnumerator(name: string, value: string | number, label?: string, description?: string): AnyEnumerator {\n if (this.isInt && typeof (value) === \"string\") // throws if backing type is int and value is string\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Enumeration ${this.name} has a backing type 'integer' and an enumerator with value of type 'string'.`);\n if (!this.isInt && typeof (value) === \"number\") // also throws if backing type is string and value is number\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Enumeration ${this.name} has a backing type 'string' and an enumerator with value of type 'integer'.`);\n this.findDuplicateEnumerators(name, value); // check for duplicates; throw if there are any\n if (!ECName.validate(name))\n throw new ECObjectsError(ECObjectsStatus.InvalidECName, `The Enumeration ${this.name} has an enumerator with an invalid 'name' attribute. ${name} is not a valid ECName.`);\n return { name, value, label, description };\n }\n\n /**\n * Adds enumerator to list of enumerators on this Enumeration\n * @param enumerator The enumerator to add\n */\n protected addEnumerator(enumerator: AnyEnumerator) {\n this.enumerators.push(enumerator);\n }\n\n /**\n * Save this Enumeration's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): EnumerationProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.type = (this.isInt) ? \"int\" : \"string\";\n schemaJson.isStrict = this.isStrict;\n schemaJson.enumerators = this._enumerators.map(({ name, label, value, description }) => {\n const enumJson: any = { name, value };\n if (undefined !== label)\n enumJson.label = label;\n if (undefined !== description)\n enumJson.description = description;\n return enumJson;\n });\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n if (undefined !== this.type)\n itemElement.setAttribute(\"backingTypeName\", primitiveTypeToString(this.type));\n itemElement.setAttribute(\"isStrict\", String(this.isStrict));\n\n for (const enumerator of this.enumerators) {\n const enumElement = schemaXml.createElement(\"ECEnumerator\");\n enumElement.setAttribute(\"name\", enumerator.name);\n const enumValue = typeof enumerator.value === \"string\" ? enumerator.value : enumerator.value.toString();\n enumElement.setAttribute(\"value\", enumValue);\n if (undefined !== enumerator.label)\n enumElement.setAttribute(\"displayLabel\", enumerator.label);\n if (undefined !== enumerator.description)\n enumElement.setAttribute(\"description\", enumerator.description);\n itemElement.appendChild(enumElement);\n }\n\n return itemElement;\n }\n\n public override fromJSONSync(enumerationProps: EnumerationProps) {\n super.fromJSONSync(enumerationProps);\n if (undefined === this._type) {\n if (/int/i.test(enumerationProps.type)) {\n this._type = PrimitiveType.Integer;\n } else if (/string/i.test(enumerationProps.type)) {\n this._type = PrimitiveType.String;\n } else {\n if (SchemaReadHelper.isECSpecVersionNewer({readVersion: enumerationProps.originalECSpecMajorVersion, writeVersion: enumerationProps.originalECSpecMinorVersion} as ECSpecVersion))\n this._type = PrimitiveType.String;\n else\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Enumeration ${this.name} has an invalid 'type' attribute. It should be either \"int\" or \"string\".`);\n }\n } else {\n const primitiveTypePattern = (this.isInt) ? /int/i : /string/i;\n if (!primitiveTypePattern.test(enumerationProps.type))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Enumeration ${this.name} has an incompatible type. It must be \"${(this.isInt) ? \"int\" : \"string\"}\", not \"${(this.isInt) ? \"string\" : \"int\"}\".`);\n }\n this._isStrict = enumerationProps.isStrict;\n\n if (undefined !== enumerationProps.enumerators) {\n enumerationProps.enumerators.forEach((enumerator: EnumeratorProps) => {\n // Creates a new enumerator (with the specified name, value, label and description- label and description are optional) and adds to the list of enumerators.\n // Throws ECObjectsError if there are duplicate names or values present in the enumeration\n this.addEnumerator(this.createEnumerator(enumerator.name, enumerator.value, enumerator.label, enumerator.description));\n });\n }\n }\n\n public override async fromJSON(enumerationProps: EnumerationProps) {\n this.fromJSONSync(enumerationProps);\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setIsStrict(isStrict: boolean) {\n this._isStrict = isStrict;\n }\n\n}\n\n/** @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableEnumeration extends Enumeration {\n public abstract override addEnumerator(enumerator: AnyEnumerator): void;\n public abstract override setIsStrict(isStrict: boolean): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Enumeration.js","sourceRoot":"","sources":["../../../src/Metadata/Enumeration.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAiB,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAa1C;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,UAAU;IAChB,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC;IAC9D,MAAM,KAAc,cAAc,KAAK,OAAO,cAAc,CAAC,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S,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,aAAa,CAAC,IAAiB;QAC3C,OAAO,IAAI,EAAE,cAAc,KAAK,cAAc,CAAC,WAAW,CAAC;IAC7D,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,mBAAmB,CAAC,IAAiB;QACjD,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;YAC3B,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,qBAAqB,EAAE,aAAa,cAAc,CAAC,WAAW,iBAAiB,CAAC,CAAC;IAC9H,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAgB,kBAAmB,SAAQ,WAAW;CAI3D","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { ECSpecVersion, SchemaReadHelper } from \"../Deserialization/Helper\";\nimport { EnumerationProps, EnumeratorProps } from \"../Deserialization/JsonProps\";\nimport { PrimitiveType, primitiveTypeToString, SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { ECName } from \"../ECName\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/** @beta */\nexport interface Enumerator<T> {\n readonly name: string;\n readonly value: T;\n readonly label?: string;\n readonly description?: string;\n}\n\n/** @beta */\nexport type AnyEnumerator = Enumerator<string | number>;\n\n/**\n * A Typescript class representation of an ECEnumeration.\n * @beta\n */\nexport class Enumeration extends SchemaItem {\n public override readonly schemaItemType = Enumeration.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.Enumeration; }\n protected _type?: PrimitiveType.Integer | PrimitiveType.String;\n protected _isStrict: boolean;\n protected _enumerators: AnyEnumerator[];\n\n public get enumerators() { return this._enumerators; }\n public get type() { return this._type; }\n public get isStrict() { return this._isStrict; }\n\n constructor(schema: Schema, name: string, primitiveType?: PrimitiveType.Integer | PrimitiveType.String) {\n super(schema, name);\n this._type = primitiveType;\n this._isStrict = true;\n this._enumerators = [];\n }\n\n public get isInt(): boolean { return this._type === PrimitiveType.Integer; }\n public get isString(): boolean { return this._type === PrimitiveType.String; }\n\n /**\n * Gets an enumerator that matches the name provided.\n * @param name The ECName of the Enumerator to find.\n */\n public getEnumeratorByName(name: string): AnyEnumerator | undefined {\n return this.enumerators.find((item) => item.name.toLowerCase() === name.toLowerCase());\n }\n\n /**\n * Gets an enumerator that matches the value provided.\n * @param value The value of the Enumerator to find.\n */\n public getEnumerator(value: string): Enumerator<string> | undefined;\n public getEnumerator(value: number): Enumerator<number> | undefined;\n public getEnumerator(value: string | number): AnyEnumerator | undefined {\n return this.enumerators.find((item) => item.value === value);\n }\n\n /**\n * Checks whether there already exists an enumerator with this name or this value\n * @param name The name of the enumerator we are trying to create\n * @param value The value of the enumerator we are trying to create\n * @internal\n */\n private findDuplicateEnumerators(name: string, value: string | number) {\n this._enumerators.forEach((element: AnyEnumerator) => { // Name and value must be unique within the ECEnumerations\n if (element.name.toLowerCase() === name.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Enumeration ${this.name} has a duplicate Enumerator with name '${name}'.`);\n if (element.value === value)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Enumeration ${this.name} has a duplicate Enumerator with value '${value}'.`);\n });\n }\n\n /**\n * Creates an Enumerator with the provided name and value as well as optional parameters label and description\n * @param name The name of the enumerator\n * @param value The value of the enumerator. The type of this value is dependent on the backing type of the this Enumeration.\n * @param label A localized display label that is used instead of the name in a GUI.\n * @param description A localized description for the enumerator.\n * @return AnyEnumerator object\n */\n public createEnumerator(name: string, value: string | number, label?: string, description?: string): AnyEnumerator {\n if (this.isInt && typeof (value) === \"string\") // throws if backing type is int and value is string\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Enumeration ${this.name} has a backing type 'integer' and an enumerator with value of type 'string'.`);\n if (!this.isInt && typeof (value) === \"number\") // also throws if backing type is string and value is number\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Enumeration ${this.name} has a backing type 'string' and an enumerator with value of type 'integer'.`);\n this.findDuplicateEnumerators(name, value); // check for duplicates; throw if there are any\n if (!ECName.validate(name))\n throw new ECObjectsError(ECObjectsStatus.InvalidECName, `The Enumeration ${this.name} has an enumerator with an invalid 'name' attribute. ${name} is not a valid ECName.`);\n return { name, value, label, description };\n }\n\n /**\n * Adds enumerator to list of enumerators on this Enumeration\n * @param enumerator The enumerator to add\n */\n protected addEnumerator(enumerator: AnyEnumerator) {\n this.enumerators.push(enumerator);\n }\n\n /**\n * Save this Enumeration's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): EnumerationProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.type = (this.isInt) ? \"int\" : \"string\";\n schemaJson.isStrict = this.isStrict;\n schemaJson.enumerators = this._enumerators.map(({ name, label, value, description }) => {\n const enumJson: any = { name, value };\n if (undefined !== label)\n enumJson.label = label;\n if (undefined !== description)\n enumJson.description = description;\n return enumJson;\n });\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n if (undefined !== this.type)\n itemElement.setAttribute(\"backingTypeName\", primitiveTypeToString(this.type));\n itemElement.setAttribute(\"isStrict\", String(this.isStrict));\n\n for (const enumerator of this.enumerators) {\n const enumElement = schemaXml.createElement(\"ECEnumerator\");\n enumElement.setAttribute(\"name\", enumerator.name);\n const enumValue = typeof enumerator.value === \"string\" ? enumerator.value : enumerator.value.toString();\n enumElement.setAttribute(\"value\", enumValue);\n if (undefined !== enumerator.label)\n enumElement.setAttribute(\"displayLabel\", enumerator.label);\n if (undefined !== enumerator.description)\n enumElement.setAttribute(\"description\", enumerator.description);\n itemElement.appendChild(enumElement);\n }\n\n return itemElement;\n }\n\n public override fromJSONSync(enumerationProps: EnumerationProps) {\n super.fromJSONSync(enumerationProps);\n if (undefined === this._type) {\n if (/int/i.test(enumerationProps.type)) {\n this._type = PrimitiveType.Integer;\n } else if (/string/i.test(enumerationProps.type)) {\n this._type = PrimitiveType.String;\n } else {\n if (SchemaReadHelper.isECSpecVersionNewer({readVersion: enumerationProps.originalECSpecMajorVersion, writeVersion: enumerationProps.originalECSpecMinorVersion} as ECSpecVersion))\n this._type = PrimitiveType.String;\n else\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Enumeration ${this.name} has an invalid 'type' attribute. It should be either \"int\" or \"string\".`);\n }\n } else {\n const primitiveTypePattern = (this.isInt) ? /int/i : /string/i;\n if (!primitiveTypePattern.test(enumerationProps.type))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Enumeration ${this.name} has an incompatible type. It must be \"${(this.isInt) ? \"int\" : \"string\"}\", not \"${(this.isInt) ? \"string\" : \"int\"}\".`);\n }\n this._isStrict = enumerationProps.isStrict;\n\n if (undefined !== enumerationProps.enumerators) {\n enumerationProps.enumerators.forEach((enumerator: EnumeratorProps) => {\n // Creates a new enumerator (with the specified name, value, label and description- label and description are optional) and adds to the list of enumerators.\n // Throws ECObjectsError if there are duplicate names or values present in the enumeration\n this.addEnumerator(this.createEnumerator(enumerator.name, enumerator.value, enumerator.label, enumerator.description));\n });\n }\n }\n\n public override async fromJSON(enumerationProps: EnumerationProps) {\n this.fromJSONSync(enumerationProps);\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setIsStrict(isStrict: boolean) {\n this._isStrict = isStrict;\n }\n\n /**\n * Type guard to check if the SchemaItem is of type Enumeration.\n * @param item The SchemaItem to check.\n * @returns True if the item is an Enumeration, false otherwise.\n */\n public static isEnumeration(item?: SchemaItem): item is Enumeration {\n return item?.schemaItemType === SchemaItemType.Enumeration;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type Enumeration.\n * @param item The SchemaItem to check.\n * @returns The item cast to Enumeration if it is an Enumeration, undefined otherwise.\n */\n public static assertIsEnumeration(item?: SchemaItem): asserts item is Enumeration {\n if (!this.isEnumeration(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Enumeration}' (Enumeration)`);\n }\n}\n\n/** @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableEnumeration extends Enumeration {\n public abstract override addEnumerator(enumerator: AnyEnumerator): void;\n public abstract override setIsStrict(isStrict: boolean): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|