@itwin/ecschema-metadata 3.6.0-dev.51 → 3.6.0-dev.53
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/lib/cjs/Constants.d.ts +23 -23
- package/lib/cjs/Constants.js +33 -33
- package/lib/cjs/Constants.js.map +1 -1
- package/lib/cjs/Context.d.ts +139 -139
- package/lib/cjs/Context.js +204 -204
- package/lib/cjs/DelayedPromise.d.ts +88 -88
- package/lib/cjs/DelayedPromise.js +91 -91
- package/lib/cjs/DelayedPromise.js.map +1 -1
- package/lib/cjs/Deserialization/AbstractParser.d.ts +45 -45
- package/lib/cjs/Deserialization/AbstractParser.js +11 -11
- package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
- package/lib/cjs/Deserialization/Helper.d.ts +251 -251
- package/lib/cjs/Deserialization/Helper.js +843 -843
- package/lib/cjs/Deserialization/Helper.js.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.d.ts +165 -165
- package/lib/cjs/Deserialization/JsonParser.js +680 -680
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.d.ts +282 -282
- package/lib/cjs/Deserialization/JsonProps.js +9 -9
- package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
- package/lib/cjs/Deserialization/SchemaGraphUtil.d.ts +34 -34
- package/lib/cjs/Deserialization/SchemaGraphUtil.js +77 -77
- package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.d.ts +85 -85
- package/lib/cjs/Deserialization/XmlParser.js +973 -973
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +54 -54
- package/lib/cjs/Deserialization/XmlSerializationUtils.js +174 -174
- package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/cjs/ECName.d.ts +30 -30
- package/lib/cjs/ECName.js +85 -85
- package/lib/cjs/ECName.js.map +1 -1
- package/lib/cjs/ECObjects.d.ts +162 -162
- package/lib/cjs/ECObjects.js +453 -453
- package/lib/cjs/ECObjects.js.map +1 -1
- package/lib/cjs/Exception.d.ts +43 -43
- package/lib/cjs/Exception.js +86 -86
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Interfaces.d.ts +66 -66
- package/lib/cjs/Interfaces.js +9 -9
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/cjs/Metadata/Class.d.ts +243 -243
- package/lib/cjs/Metadata/Class.js +558 -558
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Constant.d.ts +64 -64
- package/lib/cjs/Metadata/Constant.js +123 -123
- package/lib/cjs/Metadata/Constant.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.d.ts +23 -23
- package/lib/cjs/Metadata/CustomAttribute.js +27 -27
- package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts +39 -39
- package/lib/cjs/Metadata/CustomAttributeClass.js +68 -68
- package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.d.ts +77 -77
- package/lib/cjs/Metadata/EntityClass.js +230 -230
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/Enumeration.d.ts +86 -86
- package/lib/cjs/Metadata/Enumeration.js +159 -159
- package/lib/cjs/Metadata/Enumeration.js.map +1 -1
- package/lib/cjs/Metadata/Format.d.ts +98 -98
- package/lib/cjs/Metadata/Format.js +242 -242
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.d.ts +49 -49
- package/lib/cjs/Metadata/InvertedUnit.js +97 -97
- package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.d.ts +65 -65
- package/lib/cjs/Metadata/KindOfQuantity.js +225 -225
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Mixin.d.ts +54 -54
- package/lib/cjs/Metadata/Mixin.js +113 -113
- package/lib/cjs/Metadata/Mixin.js.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.d.ts +55 -55
- package/lib/cjs/Metadata/OverrideFormat.js +88 -88
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.d.ts +33 -33
- package/lib/cjs/Metadata/Phenomenon.js +59 -59
- package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
- package/lib/cjs/Metadata/Property.d.ts +197 -197
- package/lib/cjs/Metadata/Property.js +491 -491
- package/lib/cjs/Metadata/Property.js.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.d.ts +39 -39
- package/lib/cjs/Metadata/PropertyCategory.js +61 -61
- package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.d.ts +152 -152
- package/lib/cjs/Metadata/RelationshipClass.js +349 -349
- package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
- package/lib/cjs/Metadata/Schema.d.ts +291 -291
- package/lib/cjs/Metadata/Schema.js +520 -520
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.d.ts +61 -61
- package/lib/cjs/Metadata/SchemaItem.js +136 -136
- package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
- package/lib/cjs/Metadata/Unit.d.ts +76 -76
- package/lib/cjs/Metadata/Unit.js +162 -162
- package/lib/cjs/Metadata/UnitSystem.d.ts +20 -20
- package/lib/cjs/Metadata/UnitSystem.js +29 -29
- package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
- package/lib/cjs/PropertyTypes.d.ts +49 -49
- package/lib/cjs/PropertyTypes.js +91 -91
- package/lib/cjs/PropertyTypes.js.map +1 -1
- package/lib/cjs/SchemaJsonLocater.d.ts +34 -34
- package/lib/cjs/SchemaJsonLocater.js +42 -42
- package/lib/cjs/SchemaJsonLocater.js.map +1 -1
- package/lib/cjs/SchemaKey.d.ts +110 -110
- package/lib/cjs/SchemaKey.js +219 -219
- package/lib/cjs/SchemaKey.js.map +1 -1
- package/lib/cjs/SchemaLoader.d.ts +23 -23
- package/lib/cjs/SchemaLoader.js +47 -47
- package/lib/cjs/SchemaLoader.js.map +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.d.ts +274 -274
- package/lib/cjs/SchemaPartVisitorDelegate.js +212 -212
- package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/cjs/UnitConversion/Graph.d.ts +34 -34
- package/lib/cjs/UnitConversion/Graph.js +83 -83
- package/lib/cjs/UnitConversion/Graph.js.map +1 -1
- package/lib/cjs/UnitConversion/Parser.d.ts +8 -8
- package/lib/cjs/UnitConversion/Parser.js +42 -42
- package/lib/cjs/UnitConversion/Parser.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.d.ts +45 -45
- package/lib/cjs/UnitConversion/UnitConversion.js +77 -77
- package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.d.ts +39 -39
- package/lib/cjs/UnitConversion/UnitConverter.js +116 -116
- package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.d.ts +43 -43
- package/lib/cjs/UnitConversion/UnitTree.js +169 -169
- package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts +77 -77
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js +236 -236
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts +23 -23
- package/lib/cjs/Validation/SchemaWalker.js +53 -53
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-metadata.d.ts +51 -51
- package/lib/cjs/ecschema-metadata.js +96 -96
- package/lib/cjs/ecschema-metadata.js.map +1 -1
- package/lib/cjs/utils/SchemaGraph.d.ts +25 -25
- package/lib/cjs/utils/SchemaGraph.js +65 -65
- package/lib/cjs/utils/SchemaGraph.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaItem.js","sourceRoot":"","sources":["../../../src/Metadata/SchemaItem.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,4CAAiG;AACjG,4CAA+D;AAC/D,4CAAwD;AAGxD,MAAM,YAAY,GAAG,uDAAuD,CAAC;AAE7E;;;GAGG;AACH,MAAsB,UAAU;IAO9B,YAAY,MAAc,EAAE,IAAY;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,yBAAa,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3C,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACxG,IAAW,GAAG,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,IAAW,KAAK,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C,IAAW,WAAW,KAAK,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEtD,wLAAwL;IACxL;;;;OAIG;IACI,MAAM,CAAC,aAAsB,KAAK,EAAE,uBAAgC,KAAK;QAC9E,MAAM,QAAQ,GAA6B,EAAE,CAAC;QAC9C,IAAI,UAAU,EAAE;YACd,QAAQ,CAAC,OAAO,GAAG,YAA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CAAC;QAExC,OAAO,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS;eACtF,UAAU,CAAC,cAAc,KAAK,SAAS,CAAC;IACtD,CAAC;IAED;;;OAGG;IACO,eAAe,CAAC,YAAoB;QAC5C,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACO,cAAc,CAAC,WAAmB;QAC1C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;CACF;AAjJD,gCAiJC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { SchemaItemProps } from \"../Deserialization/JsonProps\";\r\nimport { SchemaItemType, schemaItemTypeToString, schemaItemTypeToXmlString } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { ECVersion, SchemaItemKey } from \"../SchemaKey\";\r\nimport { Schema } from \"./Schema\";\r\n\r\nconst SCHEMAURL3_2 = \"https://dev.bentley.com/json_schemas/ec/32/schemaitem\";\r\n\r\n/**\r\n * An abstract class that supplies all of the common parts of a SchemaItem.\r\n * @beta\r\n */\r\nexport abstract class SchemaItem {\r\n public readonly schemaItemType!: SchemaItemType; // allow the derived classes to define their own schemaItemType\r\n public readonly schema: Schema;\r\n protected _key: SchemaItemKey;\r\n protected _description?: string;\r\n protected _label?: string;\r\n\r\n constructor(schema: Schema, name: string) {\r\n this._key = new SchemaItemKey(name, schema.schemaKey);\r\n this.schema = schema;\r\n }\r\n\r\n public get name() { return this.key.name; }\r\n public get fullName() { return this.key.schemaKey ? `${this.key.schemaName}.${this.name}` : this.name; }\r\n public get key() { return this._key; }\r\n public get label() { return this._label; }\r\n public get description() { return this._description; }\r\n\r\n // Proposal: Create protected setter methods for description and label? For UnitSystems as an example, where using createFromProps isn't that necessary and can just use basic create().\r\n /**\r\n * Save this SchemaItem's properties to an object for serializing to JSON.\r\n * @param standalone Serialization includes only this object (as opposed to the full schema).\r\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\r\n */\r\n public toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false) {\r\n const itemJson: { [value: string]: any } = {};\r\n if (standalone) {\r\n itemJson.$schema = SCHEMAURL3_2; // $schema is required\r\n itemJson.schema = this.schema.name;\r\n itemJson.name = this.name; // name is required\r\n if (includeSchemaVersion) // check flag to see if we should output version\r\n itemJson.schemaVersion = this.key.schemaKey.version.toString();\r\n }\r\n itemJson.schemaItemType = schemaItemTypeToString(this.schemaItemType);\r\n if (undefined !== this.label)\r\n itemJson.label = this.label;\r\n if (undefined !== this.description)\r\n itemJson.description = this.description;\r\n\r\n return itemJson as SchemaItemProps;\r\n }\r\n\r\n /** @internal */\r\n public async toXml(schemaXml: Document): Promise<Element> {\r\n const itemType = schemaItemTypeToXmlString(this.schemaItemType);\r\n const itemElement = schemaXml.createElement(itemType);\r\n itemElement.setAttribute(\"typeName\", this.name);\r\n if (undefined !== this.label)\r\n itemElement.setAttribute(\"displayLabel\", this.label);\r\n if (undefined !== this.description)\r\n itemElement.setAttribute(\"description\", this.description);\r\n\r\n // When all schema items support custom attributes they should be added here rather than in ECClass\r\n\r\n return itemElement;\r\n }\r\n\r\n public fromJSONSync(schemaItemProps: SchemaItemProps) {\r\n if (undefined !== schemaItemProps.label)\r\n this._label = schemaItemProps.label;\r\n\r\n this._description = schemaItemProps.description;\r\n\r\n if (undefined !== schemaItemProps.schema) {\r\n if (schemaItemProps.schema.toLowerCase() !== this.schema.name.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema name, ${schemaItemProps.schema}, than the current Schema of this SchemaItem, ${this.schema.fullName}.`);\r\n }\r\n\r\n if (undefined !== schemaItemProps.schemaVersion) {\r\n if (this.key.schemaKey.version.compare(ECVersion.fromString(schemaItemProps.schemaVersion)))\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema version, ${schemaItemProps.schemaVersion}, than the current Schema version of this SchemaItem, ${this.key.schemaKey.version}.`);\r\n }\r\n }\r\n\r\n public async fromJSON(schemaItemProps: SchemaItemProps) {\r\n if (undefined !== schemaItemProps.label)\r\n this._label = schemaItemProps.label;\r\n\r\n this._description = schemaItemProps.description;\r\n\r\n if (undefined !== schemaItemProps.schema) {\r\n if (schemaItemProps.schema.toLowerCase() !== this.schema.name.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem ${this.fullName}' with a different schema name, ${schemaItemProps.schema}, than the current Schema of this SchemaItem, ${this.schema.fullName}`);\r\n }\r\n\r\n if (undefined !== schemaItemProps.schemaVersion) {\r\n if (this.key.schemaKey.version.compare(ECVersion.fromString(schemaItemProps.schemaVersion)))\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema version, ${schemaItemProps.schemaVersion}, than the current Schema version of this SchemaItem, ${this.key.schemaKey.version}.`);\r\n }\r\n }\r\n\r\n /**\r\n * Parses the given full name, {schemaName}.{schemaItemName} or {schemaName}:{schemaItemName}, into two separate strings.\r\n * @note The schema name can be a schema alias.\r\n * @param fullName The full name to be parsed.\r\n * @returns A tuple of the parsed Schema name and Schema Item name. If the full name does not contain a '.' or ':', the second string in the tuple will returned the exact string pass in.\r\n */\r\n public static parseFullName(fullName: string): [string, string] {\r\n const matches = /^([a-zA-Z_]+[a-zA-Z0-9_]*(\\.\\d+\\.\\d+\\.\\d+)?)[.:]([a-zA-Z_]+[a-zA-Z0-9_]*)$/.exec(fullName);\r\n\r\n // The first match will be the full string match, the second three will be the three groups\r\n if (matches === null || matches.length !== 4)\r\n return [\"\", fullName];\r\n\r\n return [matches[1], matches[3]];\r\n }\r\n\r\n /**\r\n * Indicates if the two SchemaItem objects are equal by comparing their respective [[key]] properties.\r\n * @param thisSchemaItem The first SchemaItem.\r\n * @param thatSchemaItemOrKey The second SchemaItem or SchemaItemKey.\r\n */\r\n public static equalByKey(thisSchemaItem: SchemaItem, thatSchemaItemOrKey?: SchemaItem | SchemaItemKey): boolean {\r\n if (!thatSchemaItemOrKey)\r\n return true;\r\n\r\n const key = SchemaItem.isSchemaItem(thatSchemaItemOrKey) ? thatSchemaItemOrKey.key : thatSchemaItemOrKey;\r\n return thisSchemaItem.key.matches(key);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static isSchemaItem(object: any): object is SchemaItem {\r\n const schemaItem = object as SchemaItem;\r\n\r\n return schemaItem !== undefined && schemaItem.key !== undefined && schemaItem.schema !== undefined\r\n && schemaItem.schemaItemType !== undefined;\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected setDisplayLabel(displayLabel: string) {\r\n this._label = displayLabel;\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected setDescription(description: string) {\r\n this._description = description;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaItem.js","sourceRoot":"","sources":["../../../src/Metadata/SchemaItem.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,4CAAiG;AACjG,4CAA+D;AAC/D,4CAAwD;AAGxD,MAAM,YAAY,GAAG,uDAAuD,CAAC;AAE7E;;;GAGG;AACH,MAAsB,UAAU;IAO9B,YAAY,MAAc,EAAE,IAAY;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,yBAAa,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC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AC3F,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAC1C,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QAExB,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,cAA0B,EAAE,mBAAgD;QACnG,IAAI,CAAC,mBAAmB;YACtB,OAAO,IAAI,CAAC;QAEd,MAAM,GAAG,GAAG,UAAU,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,mBAAmB,CAAC;QACzG,OAAO,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAED;;MAEE;IACK,MAAM,CAAC,YAAY,CAAC,MAAW;QACpC,MAAM,UAAU,GAAG,MAAoB,CAAC;QAExC,OAAO,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS;eACtF,UAAU,CAAC,cAAc,KAAK,SAAS,CAAC;IACtD,CAAC;IAED;;;OAGG;IACO,eAAe,CAAC,YAAoB;QAC5C,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACO,cAAc,CAAC,WAAmB;QAC1C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;CACF;AAjJD,gCAiJC","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 { SchemaItemProps } from \"../Deserialization/JsonProps\";\nimport { SchemaItemType, schemaItemTypeToString, schemaItemTypeToXmlString } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { ECVersion, SchemaItemKey } from \"../SchemaKey\";\nimport { Schema } from \"./Schema\";\n\nconst SCHEMAURL3_2 = \"https://dev.bentley.com/json_schemas/ec/32/schemaitem\";\n\n/**\n * An abstract class that supplies all of the common parts of a SchemaItem.\n * @beta\n */\nexport abstract class SchemaItem {\n public readonly schemaItemType!: SchemaItemType; // allow the derived classes to define their own schemaItemType\n public readonly schema: Schema;\n protected _key: SchemaItemKey;\n protected _description?: string;\n protected _label?: string;\n\n constructor(schema: Schema, name: string) {\n this._key = new SchemaItemKey(name, schema.schemaKey);\n this.schema = schema;\n }\n\n public get name() { return this.key.name; }\n public get fullName() { return this.key.schemaKey ? `${this.key.schemaName}.${this.name}` : this.name; }\n public get key() { return this._key; }\n public get label() { return this._label; }\n public get description() { return this._description; }\n\n // Proposal: Create protected setter methods for description and label? For UnitSystems as an example, where using createFromProps isn't that necessary and can just use basic create().\n /**\n * Save this SchemaItem'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 toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false) {\n const itemJson: { [value: string]: any } = {};\n if (standalone) {\n itemJson.$schema = SCHEMAURL3_2; // $schema is required\n itemJson.schema = this.schema.name;\n itemJson.name = this.name; // name is required\n if (includeSchemaVersion) // check flag to see if we should output version\n itemJson.schemaVersion = this.key.schemaKey.version.toString();\n }\n itemJson.schemaItemType = schemaItemTypeToString(this.schemaItemType);\n if (undefined !== this.label)\n itemJson.label = this.label;\n if (undefined !== this.description)\n itemJson.description = this.description;\n\n return itemJson as SchemaItemProps;\n }\n\n /** @internal */\n public async toXml(schemaXml: Document): Promise<Element> {\n const itemType = schemaItemTypeToXmlString(this.schemaItemType);\n const itemElement = schemaXml.createElement(itemType);\n itemElement.setAttribute(\"typeName\", this.name);\n if (undefined !== this.label)\n itemElement.setAttribute(\"displayLabel\", this.label);\n if (undefined !== this.description)\n itemElement.setAttribute(\"description\", this.description);\n\n // When all schema items support custom attributes they should be added here rather than in ECClass\n\n return itemElement;\n }\n\n public fromJSONSync(schemaItemProps: SchemaItemProps) {\n if (undefined !== schemaItemProps.label)\n this._label = schemaItemProps.label;\n\n this._description = schemaItemProps.description;\n\n if (undefined !== schemaItemProps.schema) {\n if (schemaItemProps.schema.toLowerCase() !== this.schema.name.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema name, ${schemaItemProps.schema}, than the current Schema of this SchemaItem, ${this.schema.fullName}.`);\n }\n\n if (undefined !== schemaItemProps.schemaVersion) {\n if (this.key.schemaKey.version.compare(ECVersion.fromString(schemaItemProps.schemaVersion)))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema version, ${schemaItemProps.schemaVersion}, than the current Schema version of this SchemaItem, ${this.key.schemaKey.version}.`);\n }\n }\n\n public async fromJSON(schemaItemProps: SchemaItemProps) {\n if (undefined !== schemaItemProps.label)\n this._label = schemaItemProps.label;\n\n this._description = schemaItemProps.description;\n\n if (undefined !== schemaItemProps.schema) {\n if (schemaItemProps.schema.toLowerCase() !== this.schema.name.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem ${this.fullName}' with a different schema name, ${schemaItemProps.schema}, than the current Schema of this SchemaItem, ${this.schema.fullName}`);\n }\n\n if (undefined !== schemaItemProps.schemaVersion) {\n if (this.key.schemaKey.version.compare(ECVersion.fromString(schemaItemProps.schemaVersion)))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema version, ${schemaItemProps.schemaVersion}, than the current Schema version of this SchemaItem, ${this.key.schemaKey.version}.`);\n }\n }\n\n /**\n * Parses the given full name, {schemaName}.{schemaItemName} or {schemaName}:{schemaItemName}, into two separate strings.\n * @note The schema name can be a schema alias.\n * @param fullName The full name to be parsed.\n * @returns A tuple of the parsed Schema name and Schema Item name. If the full name does not contain a '.' or ':', the second string in the tuple will returned the exact string pass in.\n */\n public static parseFullName(fullName: string): [string, string] {\n const matches = /^([a-zA-Z_]+[a-zA-Z0-9_]*(\\.\\d+\\.\\d+\\.\\d+)?)[.:]([a-zA-Z_]+[a-zA-Z0-9_]*)$/.exec(fullName);\n\n // The first match will be the full string match, the second three will be the three groups\n if (matches === null || matches.length !== 4)\n return [\"\", fullName];\n\n return [matches[1], matches[3]];\n }\n\n /**\n * Indicates if the two SchemaItem objects are equal by comparing their respective [[key]] properties.\n * @param thisSchemaItem The first SchemaItem.\n * @param thatSchemaItemOrKey The second SchemaItem or SchemaItemKey.\n */\n public static equalByKey(thisSchemaItem: SchemaItem, thatSchemaItemOrKey?: SchemaItem | SchemaItemKey): boolean {\n if (!thatSchemaItemOrKey)\n return true;\n\n const key = SchemaItem.isSchemaItem(thatSchemaItemOrKey) ? thatSchemaItemOrKey.key : thatSchemaItemOrKey;\n return thisSchemaItem.key.matches(key);\n }\n\n /**\n * @internal\n */\n public static isSchemaItem(object: any): object is SchemaItem {\n const schemaItem = object as SchemaItem;\n\n return schemaItem !== undefined && schemaItem.key !== undefined && schemaItem.schema !== undefined\n && schemaItem.schemaItemType !== undefined;\n }\n\n /**\n * @alpha\n * Used for schema editing.\n */\n protected setDisplayLabel(displayLabel: string) {\n this._label = displayLabel;\n }\n\n /**\n * @alpha\n * Used for schema editing.\n */\n protected setDescription(description: string) {\n this._description = description;\n }\n}\n"]}
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Metadata
|
|
3
|
-
*/
|
|
4
|
-
import { UnitProps } from "../Deserialization/JsonProps";
|
|
5
|
-
import { SchemaItemType } from "../ECObjects";
|
|
6
|
-
import { LazyLoadedPhenomenon, LazyLoadedUnitSystem } from "../Interfaces";
|
|
7
|
-
import { Schema } from "./Schema";
|
|
8
|
-
import { SchemaItem } from "./SchemaItem";
|
|
9
|
-
/**
|
|
10
|
-
* An abstract class that adds the ability to define Units and everything that goes with them, within an ECSchema as a
|
|
11
|
-
* first-class concept is to allow the iModel to not be dependent on any hard-coded Units
|
|
12
|
-
* @beta
|
|
13
|
-
*/
|
|
14
|
-
export declare class Unit extends SchemaItem {
|
|
15
|
-
readonly schemaItemType: SchemaItemType.Unit;
|
|
16
|
-
protected _phenomenon?: LazyLoadedPhenomenon;
|
|
17
|
-
protected _unitSystem?: LazyLoadedUnitSystem;
|
|
18
|
-
protected _definition: string;
|
|
19
|
-
protected _numerator?: number;
|
|
20
|
-
protected _denominator?: number;
|
|
21
|
-
protected _offset?: number;
|
|
22
|
-
constructor(schema: Schema, name: string);
|
|
23
|
-
get phenomenon(): LazyLoadedPhenomenon | undefined;
|
|
24
|
-
get unitSystem(): LazyLoadedUnitSystem | undefined;
|
|
25
|
-
get definition(): string;
|
|
26
|
-
get numerator(): number;
|
|
27
|
-
get offset(): number;
|
|
28
|
-
get denominator(): number;
|
|
29
|
-
get hasNumerator(): boolean;
|
|
30
|
-
get hasOffset(): boolean;
|
|
31
|
-
get hasDenominator(): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Returns true if a conversion can be calculated between the input units
|
|
34
|
-
* @alpha
|
|
35
|
-
*/
|
|
36
|
-
static areCompatible(unitA: Unit, unitB: Unit): Promise<boolean>;
|
|
37
|
-
/**
|
|
38
|
-
* @alpha
|
|
39
|
-
*/
|
|
40
|
-
static isUnit(object: any): object is Unit;
|
|
41
|
-
/**
|
|
42
|
-
* Save this Unit's properties to an object for serializing to JSON.
|
|
43
|
-
* @param standalone Serialization includes only this object (as opposed to the full schema).
|
|
44
|
-
* @param includeSchemaVersion Include the Schema's version information in the serialized object.
|
|
45
|
-
*/
|
|
46
|
-
toJSON(standalone?: boolean, includeSchemaVersion?: boolean): UnitProps;
|
|
47
|
-
/** @internal */
|
|
48
|
-
toXml(schemaXml: Document): Promise<Element>;
|
|
49
|
-
fromJSONSync(unitProps: UnitProps): void;
|
|
50
|
-
fromJSON(unitProps: UnitProps): Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* @alpha
|
|
53
|
-
* Used for schema editing.
|
|
54
|
-
*/
|
|
55
|
-
protected setPhenomenon(phenomenon: LazyLoadedPhenomenon): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* @alpha
|
|
58
|
-
* Used for schema editing.
|
|
59
|
-
*/
|
|
60
|
-
protected setUnitSystem(unitSystem: LazyLoadedUnitSystem): Promise<void>;
|
|
61
|
-
/**
|
|
62
|
-
* @alpha
|
|
63
|
-
* Used for schema editing.
|
|
64
|
-
*/
|
|
65
|
-
protected setDefinition(definition: string): Promise<void>;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* @internal
|
|
69
|
-
* An abstract class used for schema editing.
|
|
70
|
-
*/
|
|
71
|
-
export declare abstract class MutableUnit extends Unit {
|
|
72
|
-
abstract setPhenomenon(phenomenon: LazyLoadedPhenomenon): Promise<void>;
|
|
73
|
-
abstract setUnitSystem(unitSystem: LazyLoadedUnitSystem): Promise<void>;
|
|
74
|
-
abstract setDefinition(definition: string): Promise<void>;
|
|
75
|
-
abstract setDisplayLabel(displayLabel: string): void;
|
|
76
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Metadata
|
|
3
|
+
*/
|
|
4
|
+
import { UnitProps } from "../Deserialization/JsonProps";
|
|
5
|
+
import { SchemaItemType } from "../ECObjects";
|
|
6
|
+
import { LazyLoadedPhenomenon, LazyLoadedUnitSystem } from "../Interfaces";
|
|
7
|
+
import { Schema } from "./Schema";
|
|
8
|
+
import { SchemaItem } from "./SchemaItem";
|
|
9
|
+
/**
|
|
10
|
+
* An abstract class that adds the ability to define Units and everything that goes with them, within an ECSchema as a
|
|
11
|
+
* first-class concept is to allow the iModel to not be dependent on any hard-coded Units
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
export declare class Unit extends SchemaItem {
|
|
15
|
+
readonly schemaItemType: SchemaItemType.Unit;
|
|
16
|
+
protected _phenomenon?: LazyLoadedPhenomenon;
|
|
17
|
+
protected _unitSystem?: LazyLoadedUnitSystem;
|
|
18
|
+
protected _definition: string;
|
|
19
|
+
protected _numerator?: number;
|
|
20
|
+
protected _denominator?: number;
|
|
21
|
+
protected _offset?: number;
|
|
22
|
+
constructor(schema: Schema, name: string);
|
|
23
|
+
get phenomenon(): LazyLoadedPhenomenon | undefined;
|
|
24
|
+
get unitSystem(): LazyLoadedUnitSystem | undefined;
|
|
25
|
+
get definition(): string;
|
|
26
|
+
get numerator(): number;
|
|
27
|
+
get offset(): number;
|
|
28
|
+
get denominator(): number;
|
|
29
|
+
get hasNumerator(): boolean;
|
|
30
|
+
get hasOffset(): boolean;
|
|
31
|
+
get hasDenominator(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Returns true if a conversion can be calculated between the input units
|
|
34
|
+
* @alpha
|
|
35
|
+
*/
|
|
36
|
+
static areCompatible(unitA: Unit, unitB: Unit): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* @alpha
|
|
39
|
+
*/
|
|
40
|
+
static isUnit(object: any): object is Unit;
|
|
41
|
+
/**
|
|
42
|
+
* Save this Unit's properties to an object for serializing to JSON.
|
|
43
|
+
* @param standalone Serialization includes only this object (as opposed to the full schema).
|
|
44
|
+
* @param includeSchemaVersion Include the Schema's version information in the serialized object.
|
|
45
|
+
*/
|
|
46
|
+
toJSON(standalone?: boolean, includeSchemaVersion?: boolean): UnitProps;
|
|
47
|
+
/** @internal */
|
|
48
|
+
toXml(schemaXml: Document): Promise<Element>;
|
|
49
|
+
fromJSONSync(unitProps: UnitProps): void;
|
|
50
|
+
fromJSON(unitProps: UnitProps): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* @alpha
|
|
53
|
+
* Used for schema editing.
|
|
54
|
+
*/
|
|
55
|
+
protected setPhenomenon(phenomenon: LazyLoadedPhenomenon): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* @alpha
|
|
58
|
+
* Used for schema editing.
|
|
59
|
+
*/
|
|
60
|
+
protected setUnitSystem(unitSystem: LazyLoadedUnitSystem): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* @alpha
|
|
63
|
+
* Used for schema editing.
|
|
64
|
+
*/
|
|
65
|
+
protected setDefinition(definition: string): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
* An abstract class used for schema editing.
|
|
70
|
+
*/
|
|
71
|
+
export declare abstract class MutableUnit extends Unit {
|
|
72
|
+
abstract setPhenomenon(phenomenon: LazyLoadedPhenomenon): Promise<void>;
|
|
73
|
+
abstract setUnitSystem(unitSystem: LazyLoadedUnitSystem): Promise<void>;
|
|
74
|
+
abstract setDefinition(definition: string): Promise<void>;
|
|
75
|
+
abstract setDisplayLabel(displayLabel: string): void;
|
|
76
|
+
}
|
|
77
77
|
//# sourceMappingURL=Unit.d.ts.map
|
package/lib/cjs/Metadata/Unit.js
CHANGED
|
@@ -1,163 +1,163 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module Metadata
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.MutableUnit = exports.Unit = void 0;
|
|
11
|
-
const DelayedPromise_1 = require("../DelayedPromise");
|
|
12
|
-
const XmlSerializationUtils_1 = require("../Deserialization/XmlSerializationUtils");
|
|
13
|
-
const ECObjects_1 = require("../ECObjects");
|
|
14
|
-
const Exception_1 = require("../Exception");
|
|
15
|
-
const SchemaItem_1 = require("./SchemaItem");
|
|
16
|
-
/**
|
|
17
|
-
* An abstract class that adds the ability to define Units and everything that goes with them, within an ECSchema as a
|
|
18
|
-
* first-class concept is to allow the iModel to not be dependent on any hard-coded Units
|
|
19
|
-
* @beta
|
|
20
|
-
*/
|
|
21
|
-
class Unit extends SchemaItem_1.SchemaItem {
|
|
22
|
-
constructor(schema, name) {
|
|
23
|
-
super(schema, name);
|
|
24
|
-
this.schemaItemType = ECObjects_1.SchemaItemType.Unit;
|
|
25
|
-
this._definition = "";
|
|
26
|
-
}
|
|
27
|
-
get phenomenon() { return this._phenomenon; }
|
|
28
|
-
get unitSystem() { return this._unitSystem; }
|
|
29
|
-
get definition() { return this._definition; }
|
|
30
|
-
get numerator() { var _a; return (_a = this._numerator) !== null && _a !== void 0 ? _a : 1.0; }
|
|
31
|
-
get offset() { var _a; return (_a = this._offset) !== null && _a !== void 0 ? _a : 0.0; }
|
|
32
|
-
get denominator() { var _a; return (_a = this._denominator) !== null && _a !== void 0 ? _a : 1.0; }
|
|
33
|
-
get hasNumerator() { return (this._numerator !== undefined); }
|
|
34
|
-
get hasOffset() { return (this._offset !== undefined); }
|
|
35
|
-
get hasDenominator() { return (this._denominator !== undefined); }
|
|
36
|
-
/**
|
|
37
|
-
* Returns true if a conversion can be calculated between the input units
|
|
38
|
-
* @alpha
|
|
39
|
-
*/
|
|
40
|
-
static async areCompatible(unitA, unitB) {
|
|
41
|
-
const unitAPhenomenon = await unitA.phenomenon;
|
|
42
|
-
const unitBPhenomenon = await unitB.phenomenon;
|
|
43
|
-
if (!unitAPhenomenon || !unitBPhenomenon || !unitAPhenomenon.key.matches(unitBPhenomenon.key))
|
|
44
|
-
return false;
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* @alpha
|
|
49
|
-
*/
|
|
50
|
-
static isUnit(object) {
|
|
51
|
-
return SchemaItem_1.SchemaItem.isSchemaItem(object) && object.schemaItemType === ECObjects_1.SchemaItemType.Unit;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Save this Unit's properties to an object for serializing to JSON.
|
|
55
|
-
* @param standalone Serialization includes only this object (as opposed to the full schema).
|
|
56
|
-
* @param includeSchemaVersion Include the Schema's version information in the serialized object.
|
|
57
|
-
*/
|
|
58
|
-
toJSON(standalone = false, includeSchemaVersion = false) {
|
|
59
|
-
const schemaJson = super.toJSON(standalone, includeSchemaVersion);
|
|
60
|
-
schemaJson.phenomenon = this.phenomenon.fullName;
|
|
61
|
-
schemaJson.unitSystem = this.unitSystem.fullName;
|
|
62
|
-
schemaJson.definition = this.definition;
|
|
63
|
-
if (this.hasNumerator)
|
|
64
|
-
schemaJson.numerator = this.numerator;
|
|
65
|
-
if (this.hasDenominator)
|
|
66
|
-
schemaJson.denominator = this.denominator;
|
|
67
|
-
if (this.hasOffset)
|
|
68
|
-
schemaJson.offset = this.offset;
|
|
69
|
-
return schemaJson;
|
|
70
|
-
}
|
|
71
|
-
/** @internal */
|
|
72
|
-
async toXml(schemaXml) {
|
|
73
|
-
const itemElement = await super.toXml(schemaXml);
|
|
74
|
-
const phenomenon = await this.phenomenon;
|
|
75
|
-
if (undefined !== phenomenon) {
|
|
76
|
-
const phenomenonName = XmlSerializationUtils_1.XmlSerializationUtils.createXmlTypedName(this.schema, phenomenon.schema, phenomenon.name);
|
|
77
|
-
itemElement.setAttribute("phenomenon", phenomenonName);
|
|
78
|
-
}
|
|
79
|
-
const unitSystem = await this.unitSystem;
|
|
80
|
-
if (undefined !== unitSystem) {
|
|
81
|
-
const unitSystemName = XmlSerializationUtils_1.XmlSerializationUtils.createXmlTypedName(this.schema, unitSystem.schema, unitSystem.name);
|
|
82
|
-
itemElement.setAttribute("unitSystem", unitSystemName);
|
|
83
|
-
}
|
|
84
|
-
itemElement.setAttribute("definition", this.definition);
|
|
85
|
-
if (this.hasNumerator)
|
|
86
|
-
itemElement.setAttribute("numerator", this.numerator.toString());
|
|
87
|
-
if (this.hasDenominator)
|
|
88
|
-
itemElement.setAttribute("denominator", this.denominator.toString());
|
|
89
|
-
if (this.hasOffset)
|
|
90
|
-
itemElement.setAttribute("offset", this.offset.toString());
|
|
91
|
-
return itemElement;
|
|
92
|
-
}
|
|
93
|
-
fromJSONSync(unitProps) {
|
|
94
|
-
super.fromJSONSync(unitProps);
|
|
95
|
-
const phenomenonSchemaItemKey = this.schema.getSchemaItemKey(unitProps.phenomenon);
|
|
96
|
-
if (!phenomenonSchemaItemKey)
|
|
97
|
-
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);
|
|
98
|
-
this._phenomenon = new DelayedPromise_1.DelayedPromiseWithProps(phenomenonSchemaItemKey, async () => {
|
|
99
|
-
const phenom = await this.schema.lookupItem(phenomenonSchemaItemKey);
|
|
100
|
-
if (undefined === phenom)
|
|
101
|
-
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);
|
|
102
|
-
return phenom;
|
|
103
|
-
});
|
|
104
|
-
const unitSystemSchemaItemKey = this.schema.getSchemaItemKey(unitProps.unitSystem);
|
|
105
|
-
if (!unitSystemSchemaItemKey)
|
|
106
|
-
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);
|
|
107
|
-
this._unitSystem = new DelayedPromise_1.DelayedPromiseWithProps(unitSystemSchemaItemKey, async () => {
|
|
108
|
-
const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey);
|
|
109
|
-
if (undefined === unitSystem)
|
|
110
|
-
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);
|
|
111
|
-
return unitSystem;
|
|
112
|
-
});
|
|
113
|
-
if (this._definition !== "" && unitProps.definition.toLowerCase() !== this._definition.toLowerCase())
|
|
114
|
-
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this.name} has an invalid 'definition' attribute.`);
|
|
115
|
-
else if (this._definition === "")
|
|
116
|
-
this._definition = unitProps.definition;
|
|
117
|
-
if (undefined !== unitProps.numerator) {
|
|
118
|
-
if (unitProps.numerator !== this._numerator)
|
|
119
|
-
this._numerator = unitProps.numerator;
|
|
120
|
-
}
|
|
121
|
-
if (undefined !== unitProps.denominator) {
|
|
122
|
-
if (unitProps.denominator !== this._denominator)
|
|
123
|
-
this._denominator = unitProps.denominator;
|
|
124
|
-
}
|
|
125
|
-
if (undefined !== unitProps.offset) {
|
|
126
|
-
if (unitProps.offset !== this._offset)
|
|
127
|
-
this._offset = unitProps.offset;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
async fromJSON(unitProps) {
|
|
131
|
-
this.fromJSONSync(unitProps);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* @alpha
|
|
135
|
-
* Used for schema editing.
|
|
136
|
-
*/
|
|
137
|
-
async setPhenomenon(phenomenon) {
|
|
138
|
-
this._phenomenon = phenomenon;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* @alpha
|
|
142
|
-
* Used for schema editing.
|
|
143
|
-
*/
|
|
144
|
-
async setUnitSystem(unitSystem) {
|
|
145
|
-
this._unitSystem = unitSystem;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* @alpha
|
|
149
|
-
* Used for schema editing.
|
|
150
|
-
*/
|
|
151
|
-
async setDefinition(definition) {
|
|
152
|
-
this._definition = definition;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
exports.Unit = Unit;
|
|
156
|
-
/**
|
|
157
|
-
* @internal
|
|
158
|
-
* An abstract class used for schema editing.
|
|
159
|
-
*/
|
|
160
|
-
class MutableUnit extends Unit {
|
|
161
|
-
}
|
|
162
|
-
exports.MutableUnit = MutableUnit;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Metadata
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.MutableUnit = exports.Unit = void 0;
|
|
11
|
+
const DelayedPromise_1 = require("../DelayedPromise");
|
|
12
|
+
const XmlSerializationUtils_1 = require("../Deserialization/XmlSerializationUtils");
|
|
13
|
+
const ECObjects_1 = require("../ECObjects");
|
|
14
|
+
const Exception_1 = require("../Exception");
|
|
15
|
+
const SchemaItem_1 = require("./SchemaItem");
|
|
16
|
+
/**
|
|
17
|
+
* An abstract class that adds the ability to define Units and everything that goes with them, within an ECSchema as a
|
|
18
|
+
* first-class concept is to allow the iModel to not be dependent on any hard-coded Units
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
class Unit extends SchemaItem_1.SchemaItem {
|
|
22
|
+
constructor(schema, name) {
|
|
23
|
+
super(schema, name);
|
|
24
|
+
this.schemaItemType = ECObjects_1.SchemaItemType.Unit;
|
|
25
|
+
this._definition = "";
|
|
26
|
+
}
|
|
27
|
+
get phenomenon() { return this._phenomenon; }
|
|
28
|
+
get unitSystem() { return this._unitSystem; }
|
|
29
|
+
get definition() { return this._definition; }
|
|
30
|
+
get numerator() { var _a; return (_a = this._numerator) !== null && _a !== void 0 ? _a : 1.0; }
|
|
31
|
+
get offset() { var _a; return (_a = this._offset) !== null && _a !== void 0 ? _a : 0.0; }
|
|
32
|
+
get denominator() { var _a; return (_a = this._denominator) !== null && _a !== void 0 ? _a : 1.0; }
|
|
33
|
+
get hasNumerator() { return (this._numerator !== undefined); }
|
|
34
|
+
get hasOffset() { return (this._offset !== undefined); }
|
|
35
|
+
get hasDenominator() { return (this._denominator !== undefined); }
|
|
36
|
+
/**
|
|
37
|
+
* Returns true if a conversion can be calculated between the input units
|
|
38
|
+
* @alpha
|
|
39
|
+
*/
|
|
40
|
+
static async areCompatible(unitA, unitB) {
|
|
41
|
+
const unitAPhenomenon = await unitA.phenomenon;
|
|
42
|
+
const unitBPhenomenon = await unitB.phenomenon;
|
|
43
|
+
if (!unitAPhenomenon || !unitBPhenomenon || !unitAPhenomenon.key.matches(unitBPhenomenon.key))
|
|
44
|
+
return false;
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @alpha
|
|
49
|
+
*/
|
|
50
|
+
static isUnit(object) {
|
|
51
|
+
return SchemaItem_1.SchemaItem.isSchemaItem(object) && object.schemaItemType === ECObjects_1.SchemaItemType.Unit;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Save this Unit's properties to an object for serializing to JSON.
|
|
55
|
+
* @param standalone Serialization includes only this object (as opposed to the full schema).
|
|
56
|
+
* @param includeSchemaVersion Include the Schema's version information in the serialized object.
|
|
57
|
+
*/
|
|
58
|
+
toJSON(standalone = false, includeSchemaVersion = false) {
|
|
59
|
+
const schemaJson = super.toJSON(standalone, includeSchemaVersion);
|
|
60
|
+
schemaJson.phenomenon = this.phenomenon.fullName;
|
|
61
|
+
schemaJson.unitSystem = this.unitSystem.fullName;
|
|
62
|
+
schemaJson.definition = this.definition;
|
|
63
|
+
if (this.hasNumerator)
|
|
64
|
+
schemaJson.numerator = this.numerator;
|
|
65
|
+
if (this.hasDenominator)
|
|
66
|
+
schemaJson.denominator = this.denominator;
|
|
67
|
+
if (this.hasOffset)
|
|
68
|
+
schemaJson.offset = this.offset;
|
|
69
|
+
return schemaJson;
|
|
70
|
+
}
|
|
71
|
+
/** @internal */
|
|
72
|
+
async toXml(schemaXml) {
|
|
73
|
+
const itemElement = await super.toXml(schemaXml);
|
|
74
|
+
const phenomenon = await this.phenomenon;
|
|
75
|
+
if (undefined !== phenomenon) {
|
|
76
|
+
const phenomenonName = XmlSerializationUtils_1.XmlSerializationUtils.createXmlTypedName(this.schema, phenomenon.schema, phenomenon.name);
|
|
77
|
+
itemElement.setAttribute("phenomenon", phenomenonName);
|
|
78
|
+
}
|
|
79
|
+
const unitSystem = await this.unitSystem;
|
|
80
|
+
if (undefined !== unitSystem) {
|
|
81
|
+
const unitSystemName = XmlSerializationUtils_1.XmlSerializationUtils.createXmlTypedName(this.schema, unitSystem.schema, unitSystem.name);
|
|
82
|
+
itemElement.setAttribute("unitSystem", unitSystemName);
|
|
83
|
+
}
|
|
84
|
+
itemElement.setAttribute("definition", this.definition);
|
|
85
|
+
if (this.hasNumerator)
|
|
86
|
+
itemElement.setAttribute("numerator", this.numerator.toString());
|
|
87
|
+
if (this.hasDenominator)
|
|
88
|
+
itemElement.setAttribute("denominator", this.denominator.toString());
|
|
89
|
+
if (this.hasOffset)
|
|
90
|
+
itemElement.setAttribute("offset", this.offset.toString());
|
|
91
|
+
return itemElement;
|
|
92
|
+
}
|
|
93
|
+
fromJSONSync(unitProps) {
|
|
94
|
+
super.fromJSONSync(unitProps);
|
|
95
|
+
const phenomenonSchemaItemKey = this.schema.getSchemaItemKey(unitProps.phenomenon);
|
|
96
|
+
if (!phenomenonSchemaItemKey)
|
|
97
|
+
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);
|
|
98
|
+
this._phenomenon = new DelayedPromise_1.DelayedPromiseWithProps(phenomenonSchemaItemKey, async () => {
|
|
99
|
+
const phenom = await this.schema.lookupItem(phenomenonSchemaItemKey);
|
|
100
|
+
if (undefined === phenom)
|
|
101
|
+
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);
|
|
102
|
+
return phenom;
|
|
103
|
+
});
|
|
104
|
+
const unitSystemSchemaItemKey = this.schema.getSchemaItemKey(unitProps.unitSystem);
|
|
105
|
+
if (!unitSystemSchemaItemKey)
|
|
106
|
+
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);
|
|
107
|
+
this._unitSystem = new DelayedPromise_1.DelayedPromiseWithProps(unitSystemSchemaItemKey, async () => {
|
|
108
|
+
const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey);
|
|
109
|
+
if (undefined === unitSystem)
|
|
110
|
+
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);
|
|
111
|
+
return unitSystem;
|
|
112
|
+
});
|
|
113
|
+
if (this._definition !== "" && unitProps.definition.toLowerCase() !== this._definition.toLowerCase())
|
|
114
|
+
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this.name} has an invalid 'definition' attribute.`);
|
|
115
|
+
else if (this._definition === "")
|
|
116
|
+
this._definition = unitProps.definition;
|
|
117
|
+
if (undefined !== unitProps.numerator) {
|
|
118
|
+
if (unitProps.numerator !== this._numerator)
|
|
119
|
+
this._numerator = unitProps.numerator;
|
|
120
|
+
}
|
|
121
|
+
if (undefined !== unitProps.denominator) {
|
|
122
|
+
if (unitProps.denominator !== this._denominator)
|
|
123
|
+
this._denominator = unitProps.denominator;
|
|
124
|
+
}
|
|
125
|
+
if (undefined !== unitProps.offset) {
|
|
126
|
+
if (unitProps.offset !== this._offset)
|
|
127
|
+
this._offset = unitProps.offset;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async fromJSON(unitProps) {
|
|
131
|
+
this.fromJSONSync(unitProps);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* @alpha
|
|
135
|
+
* Used for schema editing.
|
|
136
|
+
*/
|
|
137
|
+
async setPhenomenon(phenomenon) {
|
|
138
|
+
this._phenomenon = phenomenon;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* @alpha
|
|
142
|
+
* Used for schema editing.
|
|
143
|
+
*/
|
|
144
|
+
async setUnitSystem(unitSystem) {
|
|
145
|
+
this._unitSystem = unitSystem;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* @alpha
|
|
149
|
+
* Used for schema editing.
|
|
150
|
+
*/
|
|
151
|
+
async setDefinition(definition) {
|
|
152
|
+
this._definition = definition;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.Unit = Unit;
|
|
156
|
+
/**
|
|
157
|
+
* @internal
|
|
158
|
+
* An abstract class used for schema editing.
|
|
159
|
+
*/
|
|
160
|
+
class MutableUnit extends Unit {
|
|
161
|
+
}
|
|
162
|
+
exports.MutableUnit = MutableUnit;
|
|
163
163
|
//# sourceMappingURL=Unit.js.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Metadata
|
|
3
|
-
*/
|
|
4
|
-
import { SchemaItemType } from "../ECObjects";
|
|
5
|
-
import { Schema } from "./Schema";
|
|
6
|
-
import { SchemaItem } from "./SchemaItem";
|
|
7
|
-
/**
|
|
8
|
-
* @beta
|
|
9
|
-
*/
|
|
10
|
-
export declare class UnitSystem extends SchemaItem {
|
|
11
|
-
readonly schemaItemType: SchemaItemType.UnitSystem;
|
|
12
|
-
constructor(schema: Schema, name: string);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* @internal
|
|
16
|
-
* Used for schema editing.
|
|
17
|
-
*/
|
|
18
|
-
export declare abstract class MutableUnitSystem extends UnitSystem {
|
|
19
|
-
abstract setDisplayLabel(displayLabel: string): void;
|
|
20
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Metadata
|
|
3
|
+
*/
|
|
4
|
+
import { SchemaItemType } from "../ECObjects";
|
|
5
|
+
import { Schema } from "./Schema";
|
|
6
|
+
import { SchemaItem } from "./SchemaItem";
|
|
7
|
+
/**
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
10
|
+
export declare class UnitSystem extends SchemaItem {
|
|
11
|
+
readonly schemaItemType: SchemaItemType.UnitSystem;
|
|
12
|
+
constructor(schema: Schema, name: string);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
* Used for schema editing.
|
|
17
|
+
*/
|
|
18
|
+
export declare abstract class MutableUnitSystem extends UnitSystem {
|
|
19
|
+
abstract setDisplayLabel(displayLabel: string): void;
|
|
20
|
+
}
|
|
21
21
|
//# sourceMappingURL=UnitSystem.d.ts.map
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module Metadata
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.MutableUnitSystem = exports.UnitSystem = void 0;
|
|
11
|
-
const ECObjects_1 = require("../ECObjects");
|
|
12
|
-
const SchemaItem_1 = require("./SchemaItem");
|
|
13
|
-
/**
|
|
14
|
-
* @beta
|
|
15
|
-
*/
|
|
16
|
-
class UnitSystem extends SchemaItem_1.SchemaItem {
|
|
17
|
-
constructor(schema, name) {
|
|
18
|
-
super(schema, name);
|
|
19
|
-
this.schemaItemType = ECObjects_1.SchemaItemType.UnitSystem;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.UnitSystem = UnitSystem;
|
|
23
|
-
/**
|
|
24
|
-
* @internal
|
|
25
|
-
* Used for schema editing.
|
|
26
|
-
*/
|
|
27
|
-
class MutableUnitSystem extends UnitSystem {
|
|
28
|
-
}
|
|
29
|
-
exports.MutableUnitSystem = MutableUnitSystem;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Metadata
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.MutableUnitSystem = exports.UnitSystem = void 0;
|
|
11
|
+
const ECObjects_1 = require("../ECObjects");
|
|
12
|
+
const SchemaItem_1 = require("./SchemaItem");
|
|
13
|
+
/**
|
|
14
|
+
* @beta
|
|
15
|
+
*/
|
|
16
|
+
class UnitSystem extends SchemaItem_1.SchemaItem {
|
|
17
|
+
constructor(schema, name) {
|
|
18
|
+
super(schema, name);
|
|
19
|
+
this.schemaItemType = ECObjects_1.SchemaItemType.UnitSystem;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.UnitSystem = UnitSystem;
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
* Used for schema editing.
|
|
26
|
+
*/
|
|
27
|
+
class MutableUnitSystem extends UnitSystem {
|
|
28
|
+
}
|
|
29
|
+
exports.MutableUnitSystem = MutableUnitSystem;
|
|
30
30
|
//# sourceMappingURL=UnitSystem.js.map
|