@itwin/ecschema-metadata 5.5.0-dev.2 → 5.5.0-dev.5
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 +6 -1
- package/lib/cjs/Constants.js.map +1 -1
- package/lib/cjs/DelayedPromise.js.map +1 -1
- package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
- package/lib/cjs/Deserialization/Helper.js.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
- package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/cjs/ECName.js.map +1 -1
- package/lib/cjs/ECObjects.js.map +1 -1
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Formatting/FormatSetFormatsProvider.js.map +1 -1
- package/lib/cjs/Formatting/SchemaFormatsProvider.js.map +1 -1
- package/lib/cjs/IncrementalLoading/ClassParsers.js.map +1 -1
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
- package/lib/cjs/IncrementalLoading/FullSchemaQueries.js +466 -466
- package/lib/cjs/IncrementalLoading/FullSchemaQueries.js.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaItemQueries.js +235 -235
- package/lib/cjs/IncrementalLoading/SchemaItemQueries.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaParser.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaStubQueries.js +309 -309
- package/lib/cjs/IncrementalLoading/SchemaStubQueries.js.map +1 -1
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Constant.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/Enumeration.js.map +1 -1
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Mixin.js.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
- package/lib/cjs/Metadata/Property.js.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
- package/lib/cjs/PropertyTypes.js.map +1 -1
- package/lib/cjs/SchemaJsonLocater.js.map +1 -1
- package/lib/cjs/SchemaKey.js.map +1 -1
- package/lib/cjs/SchemaLoader.js.map +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/cjs/UnitConversion/Graph.js.map +1 -1
- package/lib/cjs/UnitConversion/Parser.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-metadata.js.map +1 -1
- package/lib/cjs/utils/SchemaGraph.js.map +1 -1
- package/lib/cjs/utils/SchemaLoadingController.js.map +1 -1
- package/lib/esm/Constants.js.map +1 -1
- package/lib/esm/DelayedPromise.js.map +1 -1
- package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
- package/lib/esm/Deserialization/Helper.js.map +1 -1
- package/lib/esm/Deserialization/JsonParser.js.map +1 -1
- package/lib/esm/Deserialization/JsonProps.js.map +1 -1
- package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/esm/Deserialization/XmlParser.js.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/esm/ECName.js.map +1 -1
- package/lib/esm/ECObjects.js.map +1 -1
- package/lib/esm/Exception.js.map +1 -1
- package/lib/esm/Formatting/FormatSetFormatsProvider.js.map +1 -1
- package/lib/esm/Formatting/SchemaFormatsProvider.js.map +1 -1
- package/lib/esm/IncrementalLoading/ClassParsers.js.map +1 -1
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
- package/lib/esm/IncrementalLoading/FullSchemaQueries.js +466 -466
- package/lib/esm/IncrementalLoading/FullSchemaQueries.js.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaItemParsers.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaItemQueries.js +235 -235
- package/lib/esm/IncrementalLoading/SchemaItemQueries.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaParser.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaStubQueries.js +309 -309
- package/lib/esm/IncrementalLoading/SchemaStubQueries.js.map +1 -1
- package/lib/esm/Interfaces.js.map +1 -1
- package/lib/esm/Metadata/Class.js.map +1 -1
- package/lib/esm/Metadata/Constant.js.map +1 -1
- package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/esm/Metadata/EntityClass.js.map +1 -1
- package/lib/esm/Metadata/Enumeration.js.map +1 -1
- package/lib/esm/Metadata/Format.js.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/esm/Metadata/Mixin.js.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
- package/lib/esm/Metadata/Phenomenon.js.map +1 -1
- package/lib/esm/Metadata/Property.js.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
- package/lib/esm/Metadata/Schema.js.map +1 -1
- package/lib/esm/Metadata/SchemaItem.js.map +1 -1
- package/lib/esm/Metadata/UnitSystem.js.map +1 -1
- package/lib/esm/PropertyTypes.js.map +1 -1
- package/lib/esm/SchemaJsonLocater.js.map +1 -1
- package/lib/esm/SchemaKey.js.map +1 -1
- package/lib/esm/SchemaLoader.js.map +1 -1
- package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/esm/UnitConversion/Graph.js.map +1 -1
- package/lib/esm/UnitConversion/Parser.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/esm/Validation/SchemaWalker.js.map +1 -1
- package/lib/esm/ecschema-metadata.js.map +1 -1
- package/lib/esm/utils/SchemaGraph.js.map +1 -1
- package/lib/esm/utils/SchemaLoadingController.js.map +1 -1
- package/package.json +6 -6
package/lib/esm/ECObjects.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECObjects.js","sourceRoot":"","sources":["../../src/ECObjects.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,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AChD,KAAK,KAAK,cAAc,CAAC,WAAW;QACpC,KAAK,KAAK,cAAc,CAAC,KAAK;QAC9B,KAAK,KAAK,cAAc,CAAC,WAAW;QACpC,KAAK,KAAK,cAAc,CAAC,oBAAoB;QAC7C,KAAK,KAAK,cAAc,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,SAAS,KAAK,sBAAsB,CAAC,UAAU,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,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 { ECStringConstants } from \"./Constants\";\nimport { ECSchemaError, ECSchemaStatus } from \"./Exception\";\n\nexport { PropertyType } from \"./PropertyTypes\";\n\n// NEEDSWORK: This shim is currently required to use async iterators. See https://github.com/Microsoft/TypeScript/issues/14151\nif (!(Symbol as any).asyncIterator) {\n (Symbol as any).asyncIterator = Symbol.for(\"Symbol.asyncIterator\");\n}\n\n/**\n * Identifies a class as abstract or sealed\n *\n * @public @preview\n */\nexport enum ECClassModifier {\n /* normal, instantiable class, can be subclassed */\n None,\n /* abstract class, cannot be instantiated, can be subclassed */\n Abstract,\n /* sealed class, instantiable class, cannot be subclassed */\n Sealed,\n}\n\n/**\n * An enumeration that has all the schema item type names as values\n *\n * @enum {string}\n * @public @preview\n */\nexport enum SchemaItemType {\n EntityClass = \"EntityClass\",\n Mixin = \"Mixin\",\n StructClass = \"StructClass\",\n CustomAttributeClass = \"CustomAttributeClass\",\n RelationshipClass = \"RelationshipClass\",\n Enumeration = \"Enumeration\",\n KindOfQuantity = \"KindOfQuantity\",\n PropertyCategory = \"PropertyCategory\",\n Unit = \"Unit\",\n InvertedUnit = \"InvertedUnit\",\n Constant = \"Constant\",\n Phenomenon = \"Phenomenon\",\n UnitSystem = \"UnitSystem\",\n Format = \"Format\",\n}\n\n/**\n * Additional Schema Item Types which define classes of item types\n * @public @preview\n */\nexport enum AbstractSchemaItemType {\n /* Item is EntityClass, Mixin, StructClass, CustomAttributeClass, or RelationshipClass */\n Class = \"Class\",\n /* Any item type including the Class types */\n SchemaItem = \"SchemaItem\",\n}\n\n/**\n * Defines types of items that may be provided to identify supported items\n * @public @preview\n */\nexport type SupportedSchemaItemType = SchemaItemType | AbstractSchemaItemType;\n\n/**\n * Primitive data types for ECProperties.\n * @public @preview\n */\nexport enum PrimitiveType {\n Uninitialized = 0x00,\n Binary = 0x101,\n Boolean = 0x201,\n DateTime = 0x301,\n Double = 0x401,\n Integer = 0x501,\n Long = 0x601,\n Point2d = 0x701,\n Point3d = 0x801,\n String = 0x901,\n IGeometry = 0xa01,\n}\n\n/**\n * Defines the valid CustomAttribute container types.\n * @public @preview\n */\nexport enum CustomAttributeContainerType {\n Schema = 0x0001 << 0,\n EntityClass = 0x0001 << 1,\n CustomAttributeClass = 0x0001 << 2,\n StructClass = 0x0001 << 3,\n RelationshipClass = 0x0001 << 4,\n AnyClass = EntityClass | CustomAttributeClass | StructClass | RelationshipClass,\n PrimitiveProperty = 0x0001 << 5,\n StructProperty = 0x0001 << 6,\n PrimitiveArrayProperty = 0x0001 << 7,\n StructArrayProperty = 0x0001 << 8,\n NavigationProperty = 0x0001 << 9,\n AnyProperty = PrimitiveProperty | StructProperty | PrimitiveArrayProperty | StructArrayProperty | NavigationProperty,\n SourceRelationshipConstraint = 0x0001 << 10,\n TargetRelationshipConstraint = 0x0001 << 11,\n AnyRelationshipConstraint = SourceRelationshipConstraint | TargetRelationshipConstraint,\n Any = Schema | AnyClass | AnyProperty | AnyRelationshipConstraint,\n}\n\n/**\n * Defines what sort of match should be used when locating a schema.\n * @public @preview\n */\nexport enum SchemaMatchType {\n /*\n * Find exact VersionRead, VersionWrite, VersionMinor match as well as Data. NOTE data is not yet matched\n * @deprecated in 4.10 - will not be removed until after 2026-06-13. Use Exact instead.\n */\n Identical,\n /* Find exact VersionRead, VersionWrite, VersionMinor match. */\n Exact,\n /* Find latest version with matching VersionRead and VersionWrite */\n LatestWriteCompatible,\n /* Find latest version. */\n Latest,\n /* Find latest version with matching VersionRead */\n LatestReadCompatible,\n}\n\n/**\n * Identifer for an ECRelationshipConstraint. Used to determine the side of the relationship the constraint is representing.\n * @public @preview\n */\nexport enum RelationshipEnd {\n Source = 0,\n Target = 1,\n}\n\n/**\n * Defines the how the lifetime of the source and target are related.\n *\n * @public @preview */\nexport enum StrengthType {\n Referencing,\n Holding,\n Embedding,\n}\n\n/**\n * Defines the which side of the relationship is the starting point of the relationship. This impacts how relationship strength is applied.\n *\n * @public @preview */\nexport enum StrengthDirection {\n /** The source is the starting point of the relationship. */\n Forward = 1,\n /** The target is the starting point of the relationship. */\n Backward = 2,\n}\n\n// Helper methods for going to/from string for the above Enumerations.\n\n/**\n * Parses the provided string into an ECClassModifier if the string is a valid modifier.\n * @param modifier The modifier string to parse.\n * @beta\n */\nexport function parseClassModifier(modifier: string): ECClassModifier | undefined {\n const lowerModifier = modifier.toLowerCase();\n switch (lowerModifier) {\n case \"abstract\": return ECClassModifier.Abstract;\n case \"none\": return ECClassModifier.None;\n case \"sealed\": return ECClassModifier.Sealed;\n }\n return undefined;\n}\n\n/**\n * @return A string representing the provided ECClassModifier. If the modifier is not valid, an empty string is returned.\n * @beta\n */\nexport function classModifierToString(modifier: ECClassModifier): string {\n switch (modifier) {\n case ECClassModifier.Abstract: return \"Abstract\";\n case ECClassModifier.None: return \"None\";\n case ECClassModifier.Sealed: return \"Sealed\";\n default:\n throw new ECSchemaError(ECSchemaStatus.InvalidModifier, \"An invalid ECClassModifier has been provided.\");\n }\n}\n\n/**\n * Tries to parse the given string as one of the 8 schema item types.\n * @param type The schema item type string to parse.\n * @returns A valid SchemaItemType if successfully parsed. Otherwise, undefined if the provided string is not a valid SchemaItemType.\n * @beta\n */\nexport function parseSchemaItemType(type: string): SchemaItemType | undefined {\n switch (type.toLowerCase()) {\n case \"entityclass\": return SchemaItemType.EntityClass;\n case \"mixin\": return SchemaItemType.Mixin;\n case \"structclass\": return SchemaItemType.StructClass;\n case \"customattributeclass\": return SchemaItemType.CustomAttributeClass;\n case \"relationshipclass\": return SchemaItemType.RelationshipClass;\n case \"enumeration\": return SchemaItemType.Enumeration;\n case \"kindofquantity\": return SchemaItemType.KindOfQuantity;\n case \"propertycategory\": return SchemaItemType.PropertyCategory;\n case \"unit\": return SchemaItemType.Unit;\n case \"invertedunit\": return SchemaItemType.InvertedUnit;\n case \"constant\": return SchemaItemType.Constant;\n case \"phenomenon\": return SchemaItemType.Phenomenon;\n case \"unitsystem\": return SchemaItemType.UnitSystem;\n case \"format\": return SchemaItemType.Format;\n }\n return undefined;\n}\n\n/**\n * Converts a valid SchemaItemType to a display string.\n * @param value The SchemaItemType to stringify.\n * @return A string representing the provided SchemaItemType. If the type is not valid, an empty string is returned.\n * @beta\n * @deprecated in 4.6.0 - will not be removed until after 2026-06-13. SchemaItemType is a string enum so just use it directly\n */\nexport function schemaItemTypeToString(value: SchemaItemType): string {\n return value; // TODO: Remove\n}\n\n/** @internal */\nexport function schemaItemTypeToXmlString(value: SchemaItemType): string {\n switch (value) {\n case SchemaItemType.EntityClass: return \"ECEntityClass\";\n case SchemaItemType.Mixin: return \"ECEntityClass\";\n case SchemaItemType.StructClass: return \"ECStructClass\";\n case SchemaItemType.CustomAttributeClass: return \"ECCustomAttributeClass\";\n case SchemaItemType.RelationshipClass: return \"ECRelationshipClass\";\n case SchemaItemType.Enumeration: return \"ECEnumeration\";\n case SchemaItemType.KindOfQuantity: return \"KindOfQuantity\";\n case SchemaItemType.PropertyCategory: return \"PropertyCategory\";\n case SchemaItemType.Unit: return \"Unit\";\n case SchemaItemType.InvertedUnit: return \"InvertedUnit\";\n case SchemaItemType.Constant: return \"Constant\";\n case SchemaItemType.Phenomenon: return \"Phenomenon\";\n case SchemaItemType.UnitSystem: return \"UnitSystem\";\n case SchemaItemType.Format: return \"Format\";\n default:\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, \"An invalid SchemaItemType has been provided.\");\n }\n}\n\n/**\n * Tries to parse the given string as one of the 10 primitive types.\n * @param type The primitive type string to parse.\n * @returns A valid PrimitiveType if successfully parsed, or undefined if the provided string is not a valid PrimitiveType.\n * @beta\n */\nexport function parsePrimitiveType(type: string): PrimitiveType | undefined {\n switch (type.toLowerCase()) {\n case \"binary\": return PrimitiveType.Binary;\n case \"boolean\": case \"bool\": return PrimitiveType.Boolean;\n case \"datetime\": return PrimitiveType.DateTime;\n case \"double\": return PrimitiveType.Double;\n case \"int\": return PrimitiveType.Integer;\n case \"long\": return PrimitiveType.Long;\n case \"point2d\": return PrimitiveType.Point2d;\n case \"point3d\": return PrimitiveType.Point3d;\n case \"string\": return PrimitiveType.String;\n case \"bentley.geometry.common.igeometry\": return PrimitiveType.IGeometry;\n }\n\n return undefined;\n}\n\n/** @beta */\nexport function primitiveTypeToString(type: PrimitiveType): string {\n switch (type) {\n case PrimitiveType.Binary: return \"binary\";\n case PrimitiveType.Boolean: return \"boolean\";\n case PrimitiveType.DateTime: return \"dateTime\";\n case PrimitiveType.Double: return \"double\";\n case PrimitiveType.Integer: return \"int\";\n case PrimitiveType.IGeometry: return \"Bentley.Geometry.Common.IGeometry\";\n case PrimitiveType.Long: return \"long\";\n case PrimitiveType.Point2d: return \"point2d\";\n case PrimitiveType.Point3d: return \"point3d\";\n case PrimitiveType.String: return \"string\";\n default:\n throw new ECSchemaError(ECSchemaStatus.InvalidPrimitiveType, \"An invalid PrimitiveType has been provided.\");\n }\n}\n\n/**\n * Parses the given string into the appropriate CustomAttributeContainerType if the string is valid.\n * @param type The container type string to parse.\n * @beta\n */\nexport function parseCustomAttributeContainerType(type: string): CustomAttributeContainerType | undefined {\n const typeTokens = type.split(/[|,;]+/);\n\n let containerType = 0;\n\n typeTokens.forEach((typeToken) => {\n typeToken = typeToken.trim();\n if (typeToken.length === 0) return;\n\n typeToken = typeToken.toLowerCase();\n switch (typeToken) {\n case \"schema\":\n containerType = containerType | CustomAttributeContainerType.Schema;\n break;\n case \"entityclass\":\n containerType = containerType | CustomAttributeContainerType.EntityClass;\n break;\n case \"customattributeclass\":\n containerType = containerType | CustomAttributeContainerType.CustomAttributeClass;\n break;\n case \"structclass\":\n containerType = containerType | CustomAttributeContainerType.StructClass;\n break;\n case \"relationshipclass\":\n containerType = containerType | CustomAttributeContainerType.RelationshipClass;\n break;\n case \"anyclass\":\n containerType = containerType | CustomAttributeContainerType.AnyClass;\n break;\n case \"primitiveproperty\":\n containerType = containerType | CustomAttributeContainerType.PrimitiveProperty;\n break;\n case \"structproperty\":\n containerType = containerType | CustomAttributeContainerType.StructProperty;\n break;\n case \"arrayproperty\":\n containerType = containerType | CustomAttributeContainerType.PrimitiveArrayProperty;\n break;\n case \"structarrayproperty\":\n containerType = containerType | CustomAttributeContainerType.StructArrayProperty;\n break;\n case \"navigationproperty\":\n containerType = containerType | CustomAttributeContainerType.NavigationProperty;\n break;\n case \"anyproperty\":\n containerType = containerType | CustomAttributeContainerType.AnyProperty;\n break;\n case \"sourcerelationshipconstraint\":\n containerType = containerType | CustomAttributeContainerType.SourceRelationshipConstraint;\n break;\n case \"targetrelationshipconstraint\":\n containerType = containerType | CustomAttributeContainerType.TargetRelationshipConstraint;\n break;\n case \"anyrelationshipconstraint\":\n containerType = containerType | CustomAttributeContainerType.AnyRelationshipConstraint;\n break;\n case \"any\":\n containerType = containerType | CustomAttributeContainerType.Any;\n break;\n default:\n throw new ECSchemaError(ECSchemaStatus.InvalidContainerType, `${typeToken} is not a valid CustomAttributeContainerType value.`);\n }\n });\n\n return containerType as CustomAttributeContainerType;\n}\n\n/**\n * Creates a string representing a valid CustomAttributeContainerType.\n * @param value The CustomAttributeContainerType to stringify.\n * @return A string representing the provided CustomAttributeContainerType. If the type is not valid, an empty string is returned.\n * @beta\n */\nexport function containerTypeToString(type: CustomAttributeContainerType): string {\n const testContainerTypeValue = (compareType: CustomAttributeContainerType, otherType: CustomAttributeContainerType) => {\n return compareType === (compareType & otherType);\n };\n\n if (testContainerTypeValue(CustomAttributeContainerType.Any, type))\n return ECStringConstants.CONTAINERTYPE_ANY;\n\n let containerType = \"\";\n const setOrAppend = (val: string) => {\n if (containerType.length === 0) containerType = val;\n else containerType = `${containerType}, ${val}`;\n };\n\n if (testContainerTypeValue(CustomAttributeContainerType.Schema, type))\n setOrAppend(\"Schema\");\n\n if (testContainerTypeValue(CustomAttributeContainerType.AnyClass, type))\n setOrAppend(\"AnyClass\");\n else {\n if (testContainerTypeValue(CustomAttributeContainerType.EntityClass, type))\n setOrAppend(ECStringConstants.CONTAINERTYPE_ENTITYCLASS);\n if (testContainerTypeValue(CustomAttributeContainerType.CustomAttributeClass, type))\n setOrAppend(ECStringConstants.CONTAINERTYPE_CUSTOMATTRIBUTECLASS);\n if (testContainerTypeValue(CustomAttributeContainerType.StructClass, type))\n setOrAppend(ECStringConstants.CONTAINERTYPE_STRUCTCLASS);\n if (testContainerTypeValue(CustomAttributeContainerType.RelationshipClass, type))\n setOrAppend(ECStringConstants.CONTAINERTYPE_RELATIONSHIPCLASS);\n }\n\n if (testContainerTypeValue(CustomAttributeContainerType.AnyProperty, type))\n setOrAppend(ECStringConstants.CONTAINERTYPE_ANYPROPERTY);\n else {\n if (testContainerTypeValue(CustomAttributeContainerType.PrimitiveProperty, type))\n setOrAppend(ECStringConstants.CONTAINERTYPE_PRIMITIVEPROPERTY);\n if (testContainerTypeValue(CustomAttributeContainerType.StructProperty, type))\n setOrAppend(ECStringConstants.CONTAINERTYPE_STRUCTPROPERTY);\n if (testContainerTypeValue(CustomAttributeContainerType.PrimitiveArrayProperty, type))\n setOrAppend(ECStringConstants.CONTAINERTYPE_PRIMITIVEARRAYPROPERTY);\n if (testContainerTypeValue(CustomAttributeContainerType.StructArrayProperty, type))\n setOrAppend(ECStringConstants.CONTAINERTYPE_STRUCTARRAYPROPERTY);\n if (testContainerTypeValue(CustomAttributeContainerType.NavigationProperty, type))\n setOrAppend(ECStringConstants.CONTAINERTYPE_NAVIGATIONPROPERTY);\n }\n\n if (testContainerTypeValue(CustomAttributeContainerType.AnyRelationshipConstraint, type))\n setOrAppend(ECStringConstants.CONTAINERTYPE_ANYRELATIONSHIPCONSTRAINT);\n else {\n if (testContainerTypeValue(CustomAttributeContainerType.SourceRelationshipConstraint, type))\n setOrAppend(ECStringConstants.CONTAINERTYPE_SOURCERELATIONSHIPCONSTRAINT);\n if (testContainerTypeValue(CustomAttributeContainerType.TargetRelationshipConstraint, type))\n setOrAppend(ECStringConstants.CONTAINERTYPE_TARGETRELATIONSHIPCONSTRAINT);\n }\n\n return containerType;\n}\n\n/** @beta */\nexport function parseRelationshipEnd(end: string): RelationshipEnd | undefined {\n switch (end.toLowerCase()) {\n case \"source\": return RelationshipEnd.Source;\n case \"target\": return RelationshipEnd.Target;\n }\n return undefined;\n}\n\n/** @beta */\nexport function relationshipEndToString(end: RelationshipEnd): string {\n switch (end) {\n case RelationshipEnd.Source: return ECStringConstants.RELATIONSHIP_END_SOURCE;\n case RelationshipEnd.Target: return ECStringConstants.RELATIONSHIP_END_TARGET;\n default:\n throw new ECSchemaError(ECSchemaStatus.InvalidRelationshipEnd, `An invalid RelationshipEnd has been provided.`);\n }\n}\n\n/**\n * Takes a string representing a StrengthType, will parse it and return the corresponding StrengthType.\n * @throws ECSchemaStatus.InvalidStrength if the provided string that is not valid\n * @param strength\n * @beta\n */\nexport function parseStrength(strength: string): StrengthType | undefined {\n switch (strength.toLowerCase()) {\n case \"referencing\": return StrengthType.Referencing;\n case \"holding\": return StrengthType.Holding;\n case \"embedding\": return StrengthType.Embedding;\n }\n return undefined;\n}\n\n/** @beta */\nexport function strengthToString(strength: StrengthType): string {\n switch (strength) {\n case StrengthType.Embedding: return \"Embedding\";\n case StrengthType.Holding: return \"Holding\";\n case StrengthType.Referencing: return \"Referencing\";\n default:\n throw new ECSchemaError(ECSchemaStatus.InvalidStrength, `An invalid Strength has been provided.`);\n }\n}\n\n/** @beta */\nexport function parseStrengthDirection(direction: string): StrengthDirection | undefined {\n switch (direction.toLowerCase()) {\n case \"forward\": return StrengthDirection.Forward;\n case \"backward\": return StrengthDirection.Backward;\n }\n return undefined;\n}\n\n/** @beta */\nexport function strengthDirectionToString(direction: StrengthDirection): string {\n switch (direction) {\n case StrengthDirection.Forward: return \"Forward\";\n case StrengthDirection.Backward: return \"Backward\";\n default:\n throw new ECSchemaError(ECSchemaStatus.InvalidStrengthDirection, `An invalid StrengthDirection has been provided.`);\n }\n}\n\n/** Compares a SchemaItemType against supported type.\n * @beta\n */\nexport function isSupportedSchemaItemType(value: SchemaItemType, supported: SupportedSchemaItemType): boolean {\n if (value === supported) return true;\n\n if (supported === AbstractSchemaItemType.Class && (\n value === SchemaItemType.EntityClass ||\n value === SchemaItemType.Mixin ||\n value === SchemaItemType.StructClass ||\n value === SchemaItemType.CustomAttributeClass ||\n value === SchemaItemType.RelationshipClass)) {\n return true;\n }\n\n if (supported === AbstractSchemaItemType.SchemaItem) {\n return true;\n }\n\n return false;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ECObjects.js","sourceRoot":"","sources":["../../src/ECObjects.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,+HAA+H;AAC/H,IAAI,CAAE,MAAc,CAAC,aAAa,EAAE,CAAC;IAClC,MAAc,CAAC,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;AACrE,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,mDAAmD;IACnD,qDAAI,CAAA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AAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { ECStringConstants } from \"./Constants\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"./Exception\";\r\n\r\nexport { PropertyType } from \"./PropertyTypes\";\r\n\r\n// NEEDSWORK: This shim is currently required to use async iterators. See https://github.com/Microsoft/TypeScript/issues/14151\r\nif (!(Symbol as any).asyncIterator) {\r\n (Symbol as any).asyncIterator = Symbol.for(\"Symbol.asyncIterator\");\r\n}\r\n\r\n/**\r\n * Identifies a class as abstract or sealed\r\n *\r\n * @public @preview\r\n */\r\nexport enum ECClassModifier {\r\n /* normal, instantiable class, can be subclassed */\r\n None,\r\n /* abstract class, cannot be instantiated, can be subclassed */\r\n Abstract,\r\n /* sealed class, instantiable class, cannot be subclassed */\r\n Sealed,\r\n}\r\n\r\n/**\r\n * An enumeration that has all the schema item type names as values\r\n *\r\n * @enum {string}\r\n * @public @preview\r\n */\r\nexport enum SchemaItemType {\r\n EntityClass = \"EntityClass\",\r\n Mixin = \"Mixin\",\r\n StructClass = \"StructClass\",\r\n CustomAttributeClass = \"CustomAttributeClass\",\r\n RelationshipClass = \"RelationshipClass\",\r\n Enumeration = \"Enumeration\",\r\n KindOfQuantity = \"KindOfQuantity\",\r\n PropertyCategory = \"PropertyCategory\",\r\n Unit = \"Unit\",\r\n InvertedUnit = \"InvertedUnit\",\r\n Constant = \"Constant\",\r\n Phenomenon = \"Phenomenon\",\r\n UnitSystem = \"UnitSystem\",\r\n Format = \"Format\",\r\n}\r\n\r\n/**\r\n * Additional Schema Item Types which define classes of item types\r\n * @public @preview\r\n */\r\nexport enum AbstractSchemaItemType {\r\n /* Item is EntityClass, Mixin, StructClass, CustomAttributeClass, or RelationshipClass */\r\n Class = \"Class\",\r\n /* Any item type including the Class types */\r\n SchemaItem = \"SchemaItem\",\r\n}\r\n\r\n/**\r\n * Defines types of items that may be provided to identify supported items\r\n * @public @preview\r\n */\r\nexport type SupportedSchemaItemType = SchemaItemType | AbstractSchemaItemType;\r\n\r\n/**\r\n * Primitive data types for ECProperties.\r\n * @public @preview\r\n */\r\nexport enum PrimitiveType {\r\n Uninitialized = 0x00,\r\n Binary = 0x101,\r\n Boolean = 0x201,\r\n DateTime = 0x301,\r\n Double = 0x401,\r\n Integer = 0x501,\r\n Long = 0x601,\r\n Point2d = 0x701,\r\n Point3d = 0x801,\r\n String = 0x901,\r\n IGeometry = 0xa01,\r\n}\r\n\r\n/**\r\n * Defines the valid CustomAttribute container types.\r\n * @public @preview\r\n */\r\nexport enum CustomAttributeContainerType {\r\n Schema = 0x0001 << 0,\r\n EntityClass = 0x0001 << 1,\r\n CustomAttributeClass = 0x0001 << 2,\r\n StructClass = 0x0001 << 3,\r\n RelationshipClass = 0x0001 << 4,\r\n AnyClass = EntityClass | CustomAttributeClass | StructClass | RelationshipClass,\r\n PrimitiveProperty = 0x0001 << 5,\r\n StructProperty = 0x0001 << 6,\r\n PrimitiveArrayProperty = 0x0001 << 7,\r\n StructArrayProperty = 0x0001 << 8,\r\n NavigationProperty = 0x0001 << 9,\r\n AnyProperty = PrimitiveProperty | StructProperty | PrimitiveArrayProperty | StructArrayProperty | NavigationProperty,\r\n SourceRelationshipConstraint = 0x0001 << 10,\r\n TargetRelationshipConstraint = 0x0001 << 11,\r\n AnyRelationshipConstraint = SourceRelationshipConstraint | TargetRelationshipConstraint,\r\n Any = Schema | AnyClass | AnyProperty | AnyRelationshipConstraint,\r\n}\r\n\r\n/**\r\n * Defines what sort of match should be used when locating a schema.\r\n * @public @preview\r\n */\r\nexport enum SchemaMatchType {\r\n /*\r\n * Find exact VersionRead, VersionWrite, VersionMinor match as well as Data. NOTE data is not yet matched\r\n * @deprecated in 4.10 - will not be removed until after 2026-06-13. Use Exact instead.\r\n */\r\n Identical,\r\n /* Find exact VersionRead, VersionWrite, VersionMinor match. */\r\n Exact,\r\n /* Find latest version with matching VersionRead and VersionWrite */\r\n LatestWriteCompatible,\r\n /* Find latest version. */\r\n Latest,\r\n /* Find latest version with matching VersionRead */\r\n LatestReadCompatible,\r\n}\r\n\r\n/**\r\n * Identifer for an ECRelationshipConstraint. Used to determine the side of the relationship the constraint is representing.\r\n * @public @preview\r\n */\r\nexport enum RelationshipEnd {\r\n Source = 0,\r\n Target = 1,\r\n}\r\n\r\n/**\r\n * Defines the how the lifetime of the source and target are related.\r\n *\r\n * @public @preview */\r\nexport enum StrengthType {\r\n Referencing,\r\n Holding,\r\n Embedding,\r\n}\r\n\r\n/**\r\n * Defines the which side of the relationship is the starting point of the relationship. This impacts how relationship strength is applied.\r\n *\r\n * @public @preview */\r\nexport enum StrengthDirection {\r\n /** The source is the starting point of the relationship. */\r\n Forward = 1,\r\n /** The target is the starting point of the relationship. */\r\n Backward = 2,\r\n}\r\n\r\n// Helper methods for going to/from string for the above Enumerations.\r\n\r\n/**\r\n * Parses the provided string into an ECClassModifier if the string is a valid modifier.\r\n * @param modifier The modifier string to parse.\r\n * @beta\r\n */\r\nexport function parseClassModifier(modifier: string): ECClassModifier | undefined {\r\n const lowerModifier = modifier.toLowerCase();\r\n switch (lowerModifier) {\r\n case \"abstract\": return ECClassModifier.Abstract;\r\n case \"none\": return ECClassModifier.None;\r\n case \"sealed\": return ECClassModifier.Sealed;\r\n }\r\n return undefined;\r\n}\r\n\r\n/**\r\n * @return A string representing the provided ECClassModifier. If the modifier is not valid, an empty string is returned.\r\n * @beta\r\n */\r\nexport function classModifierToString(modifier: ECClassModifier): string {\r\n switch (modifier) {\r\n case ECClassModifier.Abstract: return \"Abstract\";\r\n case ECClassModifier.None: return \"None\";\r\n case ECClassModifier.Sealed: return \"Sealed\";\r\n default:\r\n throw new ECSchemaError(ECSchemaStatus.InvalidModifier, \"An invalid ECClassModifier has been provided.\");\r\n }\r\n}\r\n\r\n/**\r\n * Tries to parse the given string as one of the 8 schema item types.\r\n * @param type The schema item type string to parse.\r\n * @returns A valid SchemaItemType if successfully parsed. Otherwise, undefined if the provided string is not a valid SchemaItemType.\r\n * @beta\r\n */\r\nexport function parseSchemaItemType(type: string): SchemaItemType | undefined {\r\n switch (type.toLowerCase()) {\r\n case \"entityclass\": return SchemaItemType.EntityClass;\r\n case \"mixin\": return SchemaItemType.Mixin;\r\n case \"structclass\": return SchemaItemType.StructClass;\r\n case \"customattributeclass\": return SchemaItemType.CustomAttributeClass;\r\n case \"relationshipclass\": return SchemaItemType.RelationshipClass;\r\n case \"enumeration\": return SchemaItemType.Enumeration;\r\n case \"kindofquantity\": return SchemaItemType.KindOfQuantity;\r\n case \"propertycategory\": return SchemaItemType.PropertyCategory;\r\n case \"unit\": return SchemaItemType.Unit;\r\n case \"invertedunit\": return SchemaItemType.InvertedUnit;\r\n case \"constant\": return SchemaItemType.Constant;\r\n case \"phenomenon\": return SchemaItemType.Phenomenon;\r\n case \"unitsystem\": return SchemaItemType.UnitSystem;\r\n case \"format\": return SchemaItemType.Format;\r\n }\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Converts a valid SchemaItemType to a display string.\r\n * @param value The SchemaItemType to stringify.\r\n * @return A string representing the provided SchemaItemType. If the type is not valid, an empty string is returned.\r\n * @beta\r\n * @deprecated in 4.6.0 - will not be removed until after 2026-06-13. SchemaItemType is a string enum so just use it directly\r\n */\r\nexport function schemaItemTypeToString(value: SchemaItemType): string {\r\n return value; // TODO: Remove\r\n}\r\n\r\n/** @internal */\r\nexport function schemaItemTypeToXmlString(value: SchemaItemType): string {\r\n switch (value) {\r\n case SchemaItemType.EntityClass: return \"ECEntityClass\";\r\n case SchemaItemType.Mixin: return \"ECEntityClass\";\r\n case SchemaItemType.StructClass: return \"ECStructClass\";\r\n case SchemaItemType.CustomAttributeClass: return \"ECCustomAttributeClass\";\r\n case SchemaItemType.RelationshipClass: return \"ECRelationshipClass\";\r\n case SchemaItemType.Enumeration: return \"ECEnumeration\";\r\n case SchemaItemType.KindOfQuantity: return \"KindOfQuantity\";\r\n case SchemaItemType.PropertyCategory: return \"PropertyCategory\";\r\n case SchemaItemType.Unit: return \"Unit\";\r\n case SchemaItemType.InvertedUnit: return \"InvertedUnit\";\r\n case SchemaItemType.Constant: return \"Constant\";\r\n case SchemaItemType.Phenomenon: return \"Phenomenon\";\r\n case SchemaItemType.UnitSystem: return \"UnitSystem\";\r\n case SchemaItemType.Format: return \"Format\";\r\n default:\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, \"An invalid SchemaItemType has been provided.\");\r\n }\r\n}\r\n\r\n/**\r\n * Tries to parse the given string as one of the 10 primitive types.\r\n * @param type The primitive type string to parse.\r\n * @returns A valid PrimitiveType if successfully parsed, or undefined if the provided string is not a valid PrimitiveType.\r\n * @beta\r\n */\r\nexport function parsePrimitiveType(type: string): PrimitiveType | undefined {\r\n switch (type.toLowerCase()) {\r\n case \"binary\": return PrimitiveType.Binary;\r\n case \"boolean\": case \"bool\": return PrimitiveType.Boolean;\r\n case \"datetime\": return PrimitiveType.DateTime;\r\n case \"double\": return PrimitiveType.Double;\r\n case \"int\": return PrimitiveType.Integer;\r\n case \"long\": return PrimitiveType.Long;\r\n case \"point2d\": return PrimitiveType.Point2d;\r\n case \"point3d\": return PrimitiveType.Point3d;\r\n case \"string\": return PrimitiveType.String;\r\n case \"bentley.geometry.common.igeometry\": return PrimitiveType.IGeometry;\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\n/** @beta */\r\nexport function primitiveTypeToString(type: PrimitiveType): string {\r\n switch (type) {\r\n case PrimitiveType.Binary: return \"binary\";\r\n case PrimitiveType.Boolean: return \"boolean\";\r\n case PrimitiveType.DateTime: return \"dateTime\";\r\n case PrimitiveType.Double: return \"double\";\r\n case PrimitiveType.Integer: return \"int\";\r\n case PrimitiveType.IGeometry: return \"Bentley.Geometry.Common.IGeometry\";\r\n case PrimitiveType.Long: return \"long\";\r\n case PrimitiveType.Point2d: return \"point2d\";\r\n case PrimitiveType.Point3d: return \"point3d\";\r\n case PrimitiveType.String: return \"string\";\r\n default:\r\n throw new ECSchemaError(ECSchemaStatus.InvalidPrimitiveType, \"An invalid PrimitiveType has been provided.\");\r\n }\r\n}\r\n\r\n/**\r\n * Parses the given string into the appropriate CustomAttributeContainerType if the string is valid.\r\n * @param type The container type string to parse.\r\n * @beta\r\n */\r\nexport function parseCustomAttributeContainerType(type: string): CustomAttributeContainerType | undefined {\r\n const typeTokens = type.split(/[|,;]+/);\r\n\r\n let containerType = 0;\r\n\r\n typeTokens.forEach((typeToken) => {\r\n typeToken = typeToken.trim();\r\n if (typeToken.length === 0) return;\r\n\r\n typeToken = typeToken.toLowerCase();\r\n switch (typeToken) {\r\n case \"schema\":\r\n containerType = containerType | CustomAttributeContainerType.Schema;\r\n break;\r\n case \"entityclass\":\r\n containerType = containerType | CustomAttributeContainerType.EntityClass;\r\n break;\r\n case \"customattributeclass\":\r\n containerType = containerType | CustomAttributeContainerType.CustomAttributeClass;\r\n break;\r\n case \"structclass\":\r\n containerType = containerType | CustomAttributeContainerType.StructClass;\r\n break;\r\n case \"relationshipclass\":\r\n containerType = containerType | CustomAttributeContainerType.RelationshipClass;\r\n break;\r\n case \"anyclass\":\r\n containerType = containerType | CustomAttributeContainerType.AnyClass;\r\n break;\r\n case \"primitiveproperty\":\r\n containerType = containerType | CustomAttributeContainerType.PrimitiveProperty;\r\n break;\r\n case \"structproperty\":\r\n containerType = containerType | CustomAttributeContainerType.StructProperty;\r\n break;\r\n case \"arrayproperty\":\r\n containerType = containerType | CustomAttributeContainerType.PrimitiveArrayProperty;\r\n break;\r\n case \"structarrayproperty\":\r\n containerType = containerType | CustomAttributeContainerType.StructArrayProperty;\r\n break;\r\n case \"navigationproperty\":\r\n containerType = containerType | CustomAttributeContainerType.NavigationProperty;\r\n break;\r\n case \"anyproperty\":\r\n containerType = containerType | CustomAttributeContainerType.AnyProperty;\r\n break;\r\n case \"sourcerelationshipconstraint\":\r\n containerType = containerType | CustomAttributeContainerType.SourceRelationshipConstraint;\r\n break;\r\n case \"targetrelationshipconstraint\":\r\n containerType = containerType | CustomAttributeContainerType.TargetRelationshipConstraint;\r\n break;\r\n case \"anyrelationshipconstraint\":\r\n containerType = containerType | CustomAttributeContainerType.AnyRelationshipConstraint;\r\n break;\r\n case \"any\":\r\n containerType = containerType | CustomAttributeContainerType.Any;\r\n break;\r\n default:\r\n throw new ECSchemaError(ECSchemaStatus.InvalidContainerType, `${typeToken} is not a valid CustomAttributeContainerType value.`);\r\n }\r\n });\r\n\r\n return containerType as CustomAttributeContainerType;\r\n}\r\n\r\n/**\r\n * Creates a string representing a valid CustomAttributeContainerType.\r\n * @param value The CustomAttributeContainerType to stringify.\r\n * @return A string representing the provided CustomAttributeContainerType. If the type is not valid, an empty string is returned.\r\n * @beta\r\n */\r\nexport function containerTypeToString(type: CustomAttributeContainerType): string {\r\n const testContainerTypeValue = (compareType: CustomAttributeContainerType, otherType: CustomAttributeContainerType) => {\r\n return compareType === (compareType & otherType);\r\n };\r\n\r\n if (testContainerTypeValue(CustomAttributeContainerType.Any, type))\r\n return ECStringConstants.CONTAINERTYPE_ANY;\r\n\r\n let containerType = \"\";\r\n const setOrAppend = (val: string) => {\r\n if (containerType.length === 0) containerType = val;\r\n else containerType = `${containerType}, ${val}`;\r\n };\r\n\r\n if (testContainerTypeValue(CustomAttributeContainerType.Schema, type))\r\n setOrAppend(\"Schema\");\r\n\r\n if (testContainerTypeValue(CustomAttributeContainerType.AnyClass, type))\r\n setOrAppend(\"AnyClass\");\r\n else {\r\n if (testContainerTypeValue(CustomAttributeContainerType.EntityClass, type))\r\n setOrAppend(ECStringConstants.CONTAINERTYPE_ENTITYCLASS);\r\n if (testContainerTypeValue(CustomAttributeContainerType.CustomAttributeClass, type))\r\n setOrAppend(ECStringConstants.CONTAINERTYPE_CUSTOMATTRIBUTECLASS);\r\n if (testContainerTypeValue(CustomAttributeContainerType.StructClass, type))\r\n setOrAppend(ECStringConstants.CONTAINERTYPE_STRUCTCLASS);\r\n if (testContainerTypeValue(CustomAttributeContainerType.RelationshipClass, type))\r\n setOrAppend(ECStringConstants.CONTAINERTYPE_RELATIONSHIPCLASS);\r\n }\r\n\r\n if (testContainerTypeValue(CustomAttributeContainerType.AnyProperty, type))\r\n setOrAppend(ECStringConstants.CONTAINERTYPE_ANYPROPERTY);\r\n else {\r\n if (testContainerTypeValue(CustomAttributeContainerType.PrimitiveProperty, type))\r\n setOrAppend(ECStringConstants.CONTAINERTYPE_PRIMITIVEPROPERTY);\r\n if (testContainerTypeValue(CustomAttributeContainerType.StructProperty, type))\r\n setOrAppend(ECStringConstants.CONTAINERTYPE_STRUCTPROPERTY);\r\n if (testContainerTypeValue(CustomAttributeContainerType.PrimitiveArrayProperty, type))\r\n setOrAppend(ECStringConstants.CONTAINERTYPE_PRIMITIVEARRAYPROPERTY);\r\n if (testContainerTypeValue(CustomAttributeContainerType.StructArrayProperty, type))\r\n setOrAppend(ECStringConstants.CONTAINERTYPE_STRUCTARRAYPROPERTY);\r\n if (testContainerTypeValue(CustomAttributeContainerType.NavigationProperty, type))\r\n setOrAppend(ECStringConstants.CONTAINERTYPE_NAVIGATIONPROPERTY);\r\n }\r\n\r\n if (testContainerTypeValue(CustomAttributeContainerType.AnyRelationshipConstraint, type))\r\n setOrAppend(ECStringConstants.CONTAINERTYPE_ANYRELATIONSHIPCONSTRAINT);\r\n else {\r\n if (testContainerTypeValue(CustomAttributeContainerType.SourceRelationshipConstraint, type))\r\n setOrAppend(ECStringConstants.CONTAINERTYPE_SOURCERELATIONSHIPCONSTRAINT);\r\n if (testContainerTypeValue(CustomAttributeContainerType.TargetRelationshipConstraint, type))\r\n setOrAppend(ECStringConstants.CONTAINERTYPE_TARGETRELATIONSHIPCONSTRAINT);\r\n }\r\n\r\n return containerType;\r\n}\r\n\r\n/** @beta */\r\nexport function parseRelationshipEnd(end: string): RelationshipEnd | undefined {\r\n switch (end.toLowerCase()) {\r\n case \"source\": return RelationshipEnd.Source;\r\n case \"target\": return RelationshipEnd.Target;\r\n }\r\n return undefined;\r\n}\r\n\r\n/** @beta */\r\nexport function relationshipEndToString(end: RelationshipEnd): string {\r\n switch (end) {\r\n case RelationshipEnd.Source: return ECStringConstants.RELATIONSHIP_END_SOURCE;\r\n case RelationshipEnd.Target: return ECStringConstants.RELATIONSHIP_END_TARGET;\r\n default:\r\n throw new ECSchemaError(ECSchemaStatus.InvalidRelationshipEnd, `An invalid RelationshipEnd has been provided.`);\r\n }\r\n}\r\n\r\n/**\r\n * Takes a string representing a StrengthType, will parse it and return the corresponding StrengthType.\r\n * @throws ECSchemaStatus.InvalidStrength if the provided string that is not valid\r\n * @param strength\r\n * @beta\r\n */\r\nexport function parseStrength(strength: string): StrengthType | undefined {\r\n switch (strength.toLowerCase()) {\r\n case \"referencing\": return StrengthType.Referencing;\r\n case \"holding\": return StrengthType.Holding;\r\n case \"embedding\": return StrengthType.Embedding;\r\n }\r\n return undefined;\r\n}\r\n\r\n/** @beta */\r\nexport function strengthToString(strength: StrengthType): string {\r\n switch (strength) {\r\n case StrengthType.Embedding: return \"Embedding\";\r\n case StrengthType.Holding: return \"Holding\";\r\n case StrengthType.Referencing: return \"Referencing\";\r\n default:\r\n throw new ECSchemaError(ECSchemaStatus.InvalidStrength, `An invalid Strength has been provided.`);\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function parseStrengthDirection(direction: string): StrengthDirection | undefined {\r\n switch (direction.toLowerCase()) {\r\n case \"forward\": return StrengthDirection.Forward;\r\n case \"backward\": return StrengthDirection.Backward;\r\n }\r\n return undefined;\r\n}\r\n\r\n/** @beta */\r\nexport function strengthDirectionToString(direction: StrengthDirection): string {\r\n switch (direction) {\r\n case StrengthDirection.Forward: return \"Forward\";\r\n case StrengthDirection.Backward: return \"Backward\";\r\n default:\r\n throw new ECSchemaError(ECSchemaStatus.InvalidStrengthDirection, `An invalid StrengthDirection has been provided.`);\r\n }\r\n}\r\n\r\n/** Compares a SchemaItemType against supported type.\r\n * @beta\r\n */\r\nexport function isSupportedSchemaItemType(value: SchemaItemType, supported: SupportedSchemaItemType): boolean {\r\n if (value === supported) return true;\r\n\r\n if (supported === AbstractSchemaItemType.Class && (\r\n value === SchemaItemType.EntityClass ||\r\n value === SchemaItemType.Mixin ||\r\n value === SchemaItemType.StructClass ||\r\n value === SchemaItemType.CustomAttributeClass ||\r\n value === SchemaItemType.RelationshipClass)) {\r\n return true;\r\n }\r\n\r\n if (supported === AbstractSchemaItemType.SchemaItem) {\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n"]}
|
package/lib/esm/Exception.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Exception.js","sourceRoot":"","sources":["../../src/Exception.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,uBAAuB;AACvB,MAAM,CAAN,IAAY,cAgCX;AAhCD,WAAY,cAAc;IACxB,qFAA4B,CAAA;IAC5B,yDAAW,CAAA;IACX,yEAAuC,CAAA;IACvC,iFAA2C,CAAA;IAC3C,6EAAyC,CAAA;IACzC,6EAAyC,CAAA;IACzC,uFAA8C,CAAA;IAC9C,yEAAuC,CAAA;IACvC,yEAAuC,CAAA;IACvC,+EAA0C,CAAA;IAC1C,+EAA0C,CAAA;IAC1C,6EAA0C,CAAA;IAC1C,qFAA8C,CAAA;IAC9C,uFAA+C,CAAA;IAC/C,yFAAgD,CAAA;IAChD,6EAA0C,CAAA;IAC1C,+FAAmD,CAAA;IACnD,2FAAiD,CAAA;IACjD,qEAAsC,CAAA;IACtC,+EAA2C,CAAA;IAC3C,uFAA+C,CAAA;IAC/C,+EAA2C,CAAA;IAC3C,qFAA8C,CAAA;IAC9C,yEAAwC,CAAA;IACxC,2FAAiD,CAAA;IACjD,6FAAkD,CAAA;IAClD,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AAC;YAClH;gBACE,0BAA0B;gBAC1B,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAEO,cAAc,CAAC,CAAS;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;CACF","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 { BentleyError } from \"@itwin/core-bentley\";\n\n/** @public @preview */\nexport enum ECSchemaStatus {\n ECSCHEMA_ERROR_BASE = 0x88EC,\n Success = 0,\n DuplicateItem = ECSCHEMA_ERROR_BASE + 1,\n DuplicateProperty = ECSCHEMA_ERROR_BASE + 2,\n DuplicateSchema = ECSCHEMA_ERROR_BASE + 3,\n ImmutableSchema = ECSCHEMA_ERROR_BASE + 4,\n InvalidContainerType = ECSCHEMA_ERROR_BASE + 5,\n InvalidECJson = ECSCHEMA_ERROR_BASE + 6,\n InvalidECName = ECSCHEMA_ERROR_BASE + 7,\n InvalidECVersion = ECSCHEMA_ERROR_BASE + 8,\n InvalidEnumValue = ECSCHEMA_ERROR_BASE + 9,\n InvalidModifier = ECSCHEMA_ERROR_BASE + 10,\n InvalidMultiplicity = ECSCHEMA_ERROR_BASE + 11,\n InvalidPrimitiveType = ECSCHEMA_ERROR_BASE + 12,\n InvalidSchemaItemType = ECSCHEMA_ERROR_BASE + 13,\n InvalidStrength = ECSCHEMA_ERROR_BASE + 14,\n InvalidStrengthDirection = ECSCHEMA_ERROR_BASE + 15,\n InvalidRelationshipEnd = ECSCHEMA_ERROR_BASE + 16,\n InvalidType = ECSCHEMA_ERROR_BASE + 17,\n MissingSchemaUrl = ECSCHEMA_ERROR_BASE + 18,\n UnableToLocateSchema = ECSCHEMA_ERROR_BASE + 19,\n InvalidSchemaXML = ECSCHEMA_ERROR_BASE + 20,\n InvalidSchemaString = ECSCHEMA_ERROR_BASE + 21,\n ClassNotFound = ECSCHEMA_ERROR_BASE + 22,\n SchemaContextUndefined = ECSCHEMA_ERROR_BASE + 23,\n DifferentSchemaContexts = ECSCHEMA_ERROR_BASE + 24,\n InvalidSchemaComparisonArgument = ECSCHEMA_ERROR_BASE + 25,\n InvalidSchemaAlias = ECSCHEMA_ERROR_BASE + 26,\n InvalidSchemaKey = ECSCHEMA_ERROR_BASE + 27,\n UnableToLoadSchema = ECSCHEMA_ERROR_BASE + 28,\n NewerECSpecVersion = ECSCHEMA_ERROR_BASE + 29,\n}\n\n/** @internal */\nexport class ECSchemaError extends BentleyError {\n public constructor(public override readonly errorNumber: number, message?: string) {\n super(errorNumber, message);\n }\n\n public toDebugString(): string {\n switch (this.errorNumber) {\n case ECSchemaStatus.DuplicateItem: return this._appendMessage(\"ECSchemaStatus.DuplicateItem\");\n case ECSchemaStatus.DuplicateProperty: return this._appendMessage(\"ECSchemaStatus.DuplicateProperty\");\n case ECSchemaStatus.DuplicateSchema: return this._appendMessage(\"ECSchemaStatus.DuplicateSchema\");\n case ECSchemaStatus.ImmutableSchema: return this._appendMessage(\"ECSchemaStatus.ImmutableSchema\");\n case ECSchemaStatus.InvalidContainerType: return this._appendMessage(\"ECSchemaStatus.InvalidContainerType\");\n case ECSchemaStatus.InvalidECJson: return this._appendMessage(\"ECSchemaStatus.InvalidECJson\");\n case ECSchemaStatus.InvalidECName: return this._appendMessage(\"ECSchemaStatus.InvalidECName\");\n case ECSchemaStatus.InvalidECVersion: return this._appendMessage(\"ECSchemaStatus.InvalidECVersion\");\n case ECSchemaStatus.InvalidEnumValue: return this._appendMessage(\"ECSchemaStatus.InvalidEnumValue\");\n case ECSchemaStatus.InvalidModifier: return this._appendMessage(\"ECSchemaStatus.InvalidModifier\");\n case ECSchemaStatus.InvalidMultiplicity: return this._appendMessage(\"ECSchemaStatus.InvalidMultiplicity\");\n case ECSchemaStatus.InvalidPrimitiveType: return this._appendMessage(\"ECSchemaStatus.InvalidPrimitiveType\");\n case ECSchemaStatus.InvalidSchemaItemType: return this._appendMessage(\"ECSchemaStatus.InvalidSchemaItemType\");\n case ECSchemaStatus.InvalidStrength: return this._appendMessage(\"ECSchemaStatus.InvalidStrength\");\n case ECSchemaStatus.InvalidStrengthDirection: return this._appendMessage(\"ECSchemaStatus.InvalidStrengthDirection\");\n case ECSchemaStatus.InvalidRelationshipEnd: return this._appendMessage(\"ECSchemaStatus.InvalidRelationshipEnd\");\n case ECSchemaStatus.InvalidType: return this._appendMessage(\"ECSchemaStatus.InvalidType\");\n case ECSchemaStatus.MissingSchemaUrl: return this._appendMessage(\"ECSchemaStatus.MissingSchemaUrl\");\n case ECSchemaStatus.UnableToLocateSchema: return this._appendMessage(\"ECSchemaStatus.UnableToLocateSchema\");\n case ECSchemaStatus.ClassNotFound: return this._appendMessage(\"ECSchemaStatus.ClassNotFound\");\n case ECSchemaStatus.SchemaContextUndefined: return this._appendMessage(\"ECSchemaStatus.SchemaContextUndefined\");\n case ECSchemaStatus.DifferentSchemaContexts: return this._appendMessage(\"ECSchemaStatus.DifferentSchemaContexts\");\n default:\n /* istanbul ignore next */\n return this._appendMessage(`Error ${this.errorNumber.toString()}`);\n }\n }\n\n private _appendMessage(e: string): string {\n return this.message ? `${e}: ${this.message}` : e;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Exception.js","sourceRoot":"","sources":["../../src/Exception.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,uBAAuB;AACvB,MAAM,CAAN,IAAY,cAgCX;AAhCD,WAAY,cAAc;IACxB,qFAA4B,CAAA;IAC5B,yDAAW,CAAA;IACX,yEAAu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,CAAC,4BAA4B,CAAC,CAAC;YAC1F,KAAK,cAAc,CAAC,gBAAgB,CAAC,CAAC,OAAO,IAAI,CAAC,cAAc,CAAC,iCAAiC,CAAC,CAAC;YACpG,KAAK,cAAc,CAAC,oBAAoB,CAAC,CAAC,OAAO,IAAI,CAAC,cAAc,CAAC,qCAAqC,CAAC,CAAC;YAC5G,KAAK,cAAc,CAAC,aAAa,CAAC,CAAC,OAAO,IAAI,CAAC,cAAc,CAAC,8BAA8B,CAAC,CAAC;YAC9F,KAAK,cAAc,CAAC,sBAAsB,CAAC,CAAC,OAAO,IAAI,CAAC,cAAc,CAAC,uCAAuC,CAAC,CAAC;YAChH,KAAK,cAAc,CAAC,uBAAuB,CAAC,CAAC,OAAO,IAAI,CAAC,cAAc,CAAC,wCAAwC,CAAC,CAAC;YAClH;gBACE,0BAA0B;gBAC1B,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAEO,cAAc,CAAC,CAAS;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;CACF","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 { BentleyError } from \"@itwin/core-bentley\";\r\n\r\n/** @public @preview */\r\nexport enum ECSchemaStatus {\r\n ECSCHEMA_ERROR_BASE = 0x88EC,\r\n Success = 0,\r\n DuplicateItem = ECSCHEMA_ERROR_BASE + 1,\r\n DuplicateProperty = ECSCHEMA_ERROR_BASE + 2,\r\n DuplicateSchema = ECSCHEMA_ERROR_BASE + 3,\r\n ImmutableSchema = ECSCHEMA_ERROR_BASE + 4,\r\n InvalidContainerType = ECSCHEMA_ERROR_BASE + 5,\r\n InvalidECJson = ECSCHEMA_ERROR_BASE + 6,\r\n InvalidECName = ECSCHEMA_ERROR_BASE + 7,\r\n InvalidECVersion = ECSCHEMA_ERROR_BASE + 8,\r\n InvalidEnumValue = ECSCHEMA_ERROR_BASE + 9,\r\n InvalidModifier = ECSCHEMA_ERROR_BASE + 10,\r\n InvalidMultiplicity = ECSCHEMA_ERROR_BASE + 11,\r\n InvalidPrimitiveType = ECSCHEMA_ERROR_BASE + 12,\r\n InvalidSchemaItemType = ECSCHEMA_ERROR_BASE + 13,\r\n InvalidStrength = ECSCHEMA_ERROR_BASE + 14,\r\n InvalidStrengthDirection = ECSCHEMA_ERROR_BASE + 15,\r\n InvalidRelationshipEnd = ECSCHEMA_ERROR_BASE + 16,\r\n InvalidType = ECSCHEMA_ERROR_BASE + 17,\r\n MissingSchemaUrl = ECSCHEMA_ERROR_BASE + 18,\r\n UnableToLocateSchema = ECSCHEMA_ERROR_BASE + 19,\r\n InvalidSchemaXML = ECSCHEMA_ERROR_BASE + 20,\r\n InvalidSchemaString = ECSCHEMA_ERROR_BASE + 21,\r\n ClassNotFound = ECSCHEMA_ERROR_BASE + 22,\r\n SchemaContextUndefined = ECSCHEMA_ERROR_BASE + 23,\r\n DifferentSchemaContexts = ECSCHEMA_ERROR_BASE + 24,\r\n InvalidSchemaComparisonArgument = ECSCHEMA_ERROR_BASE + 25,\r\n InvalidSchemaAlias = ECSCHEMA_ERROR_BASE + 26,\r\n InvalidSchemaKey = ECSCHEMA_ERROR_BASE + 27,\r\n UnableToLoadSchema = ECSCHEMA_ERROR_BASE + 28,\r\n NewerECSpecVersion = ECSCHEMA_ERROR_BASE + 29,\r\n}\r\n\r\n/** @internal */\r\nexport class ECSchemaError extends BentleyError {\r\n public constructor(public override readonly errorNumber: number, message?: string) {\r\n super(errorNumber, message);\r\n }\r\n\r\n public toDebugString(): string {\r\n switch (this.errorNumber) {\r\n case ECSchemaStatus.DuplicateItem: return this._appendMessage(\"ECSchemaStatus.DuplicateItem\");\r\n case ECSchemaStatus.DuplicateProperty: return this._appendMessage(\"ECSchemaStatus.DuplicateProperty\");\r\n case ECSchemaStatus.DuplicateSchema: return this._appendMessage(\"ECSchemaStatus.DuplicateSchema\");\r\n case ECSchemaStatus.ImmutableSchema: return this._appendMessage(\"ECSchemaStatus.ImmutableSchema\");\r\n case ECSchemaStatus.InvalidContainerType: return this._appendMessage(\"ECSchemaStatus.InvalidContainerType\");\r\n case ECSchemaStatus.InvalidECJson: return this._appendMessage(\"ECSchemaStatus.InvalidECJson\");\r\n case ECSchemaStatus.InvalidECName: return this._appendMessage(\"ECSchemaStatus.InvalidECName\");\r\n case ECSchemaStatus.InvalidECVersion: return this._appendMessage(\"ECSchemaStatus.InvalidECVersion\");\r\n case ECSchemaStatus.InvalidEnumValue: return this._appendMessage(\"ECSchemaStatus.InvalidEnumValue\");\r\n case ECSchemaStatus.InvalidModifier: return this._appendMessage(\"ECSchemaStatus.InvalidModifier\");\r\n case ECSchemaStatus.InvalidMultiplicity: return this._appendMessage(\"ECSchemaStatus.InvalidMultiplicity\");\r\n case ECSchemaStatus.InvalidPrimitiveType: return this._appendMessage(\"ECSchemaStatus.InvalidPrimitiveType\");\r\n case ECSchemaStatus.InvalidSchemaItemType: return this._appendMessage(\"ECSchemaStatus.InvalidSchemaItemType\");\r\n case ECSchemaStatus.InvalidStrength: return this._appendMessage(\"ECSchemaStatus.InvalidStrength\");\r\n case ECSchemaStatus.InvalidStrengthDirection: return this._appendMessage(\"ECSchemaStatus.InvalidStrengthDirection\");\r\n case ECSchemaStatus.InvalidRelationshipEnd: return this._appendMessage(\"ECSchemaStatus.InvalidRelationshipEnd\");\r\n case ECSchemaStatus.InvalidType: return this._appendMessage(\"ECSchemaStatus.InvalidType\");\r\n case ECSchemaStatus.MissingSchemaUrl: return this._appendMessage(\"ECSchemaStatus.MissingSchemaUrl\");\r\n case ECSchemaStatus.UnableToLocateSchema: return this._appendMessage(\"ECSchemaStatus.UnableToLocateSchema\");\r\n case ECSchemaStatus.ClassNotFound: return this._appendMessage(\"ECSchemaStatus.ClassNotFound\");\r\n case ECSchemaStatus.SchemaContextUndefined: return this._appendMessage(\"ECSchemaStatus.SchemaContextUndefined\");\r\n case ECSchemaStatus.DifferentSchemaContexts: return this._appendMessage(\"ECSchemaStatus.DifferentSchemaContexts\");\r\n default:\r\n /* istanbul ignore next */\r\n return this._appendMessage(`Error ${this.errorNumber.toString()}`);\r\n }\r\n }\r\n\r\n private _appendMessage(e: string): string {\r\n return this.message ? `${e}: ${this.message}` : e;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatSetFormatsProvider.js","sourceRoot":"","sources":["../../../src/Formatting/FormatSetFormatsProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,OAAO,wBAAwB;IAC5B,gBAAgB,GAAgD,IAAI,OAAO,EAAsC,CAAC;IAEjH,UAAU,CAAY;IACtB,iBAAiB,CAAmB;IACpC,WAAW,CAAsB,CAAC,iDAAiD;IAE3F,YAAmB,KAAiE;QAClF,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,gBAAgB,CAAC;QAChD,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;QAE7C,wCAAwC;QACxC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACrE,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC/B,IAAI,CAAC,WAAW,CA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CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAE9B,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC;IAED;;;;OAIG;IACK,2BAA2B,CAAC,MAAc;QAChD,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAU,CAAC;QAE7C,sDAAsD;QACtD,KAAK,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC;YACjE,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;gBACzB,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBACnC,sDAAsD;gBACtD,MAAM,kBAAkB,GAAG,IAAI,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC;gBACxE,KAAK,MAAM,WAAW,IAAI,kBAAkB,EAAE,CAAC;oBAC7C,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;gBACtC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,kBAAkB,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { BeEvent } from \"@itwin/core-bentley\";\nimport { FormatDefinition, FormatsChangedArgs, FormatsProvider, MutableFormatsProvider } from \"@itwin/core-quantity\";\nimport { FormatSet } from \"../Deserialization/JsonProps\";\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\n\n/**\n * A mutable format provider that manages format definitions within a format set.\n * When formats are added or removed, the underlying format set is automatically updated.\n * @beta\n */\nexport class FormatSetFormatsProvider implements MutableFormatsProvider {\n public onFormatsChanged: BeEvent<(args: FormatsChangedArgs) => void> = new BeEvent<(args: FormatsChangedArgs) => void>();\n\n private _formatSet: FormatSet;\n private _fallbackProvider?: FormatsProvider;\n private _references: Map<string, string>; // Maps format name to the reference it points to\n\n public constructor(props: {formatSet: FormatSet, fallbackProvider?: FormatsProvider}) {\n this._formatSet = props.formatSet;\n this._fallbackProvider = props.fallbackProvider;\n this._references = new Map<string, string>();\n\n // Build up the map of string references\n for (const [name, format] of Object.entries(this._formatSet.formats)) {\n if (typeof format === \"string\") {\n this._references.set(name, format);\n }\n }\n }\n\n /**\n * Adds or updates the format definition returned for a kind of quantity. Takes either a format definition or a kind of quantity full name that will be used to lookup the format that will be used.\n * @param name A kind of quantity full name used as a key to lookup this format\n * @param format The format definition or the name of a kind of quantity\n */\n public async addFormat(name: string, format: FormatDefinition | string): Promise<void> {\n this._formatSet.formats[name] = format;\n\n // Update the references map\n if (typeof format === \"string\") {\n this._references.set(name, format);\n } else {\n this._references.delete(name);\n }\n\n // Collect all formats that reference this format (directly or indirectly)\n const affectedFormats = this.getFormatsReferencingTarget(name);\n affectedFormats.add(name); // Include the format itself\n\n this.onFormatsChanged.raiseEvent({ formatsChanged: Array.from(affectedFormats) });\n }\n\n /**\n * Clears the fallback provider, if one is set.\n */\n public clearFallbackProvider(): void {\n this._fallbackProvider = undefined;\n }\n\n /**\n * Retrieves a format definition by its name from the format set. If not found, it checks the fallback provider to find the format, else returns undefined.\n * If the format is a string reference to another format, it resolves the reference and returns the FormatDefinition.\n */\n public async getFormat(input: string): Promise<FormatDefinition | undefined> {\n // Normalizes any schemaItem names coming from node addon 'schemaName:schemaItemName' -> 'schemaName.schemaItemName'\n const [schemaName, itemName] = SchemaItem.parseFullName(input);\n\n const name = (schemaName === \"\") ? itemName : `${schemaName}.${itemName}`;\n const format = this._formatSet.formats[name];\n\n if (format !== undefined) {\n // If format is a string reference, resolve it\n if (typeof format === \"string\") {\n return this.resolveReference(format);\n }\n return format;\n }\n\n if (this._fallbackProvider) return this._fallbackProvider.getFormat(name);\n return undefined;\n }\n\n /**\n * Resolves a string reference to its FormatDefinition, following chains of references.\n * @param reference The string reference to resolve\n * @param visited Set of visited references to detect circular references\n */\n private async resolveReference(reference: string, visited: Set<string> = new Set()): Promise<FormatDefinition | undefined> {\n // Prevent infinite loops from circular references\n if (visited.has(reference)) {\n return undefined;\n }\n visited.add(reference);\n\n const format = this._formatSet.formats[reference];\n\n if (format === undefined) {\n if (this._fallbackProvider) {\n return this._fallbackProvider.getFormat(reference);\n }\n return undefined;\n }\n\n // If we found another string reference, resolve it recursively\n if (typeof format === \"string\") {\n return this.resolveReference(format, visited);\n }\n\n return format;\n }\n\n /**\n * Removes a format definition or string reference from the format set.\n * @param name The name of the format to remove\n */\n public async removeFormat(name: string): Promise<void> {\n // Collect all formats that reference this format (directly or indirectly)\n const affectedFormats = this.getFormatsReferencingTarget(name);\n affectedFormats.add(name); // Include the format itself\n\n delete this._formatSet.formats[name];\n this._references.delete(name);\n\n this.onFormatsChanged.raiseEvent({ formatsChanged: Array.from(affectedFormats) });\n }\n\n /**\n * Gets all format names that reference the target format (directly or indirectly).\n * @param target The format name to find references to\n * @returns Set of format names that reference the target\n */\n private getFormatsReferencingTarget(target: string): Set<string> {\n const referencingFormats = new Set<string>();\n\n // Find all formats that directly reference the target\n for (const [formatName, reference] of this._references.entries()) {\n if (reference === target) {\n referencingFormats.add(formatName);\n // Recursively find formats that reference this format\n const indirectReferences = this.getFormatsReferencingTarget(formatName);\n for (const indirectRef of indirectReferences) {\n referencingFormats.add(indirectRef);\n }\n }\n }\n\n return referencingFormats;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FormatSetFormatsProvider.js","sourceRoot":"","sources":["../../../src/Formatting/FormatSetFormatsProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,OAAO,wBAAwB;IAC5B,gBAAgB,GAAgD,IAAI,OAAO,EAAsC,CAAC;IAEjH,UAAU,CAAY;IACtB,iBAAiB,CAAmB;IACpC,WAAW,CAAsB,CAAC,iDAAi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\"@itwin/core-bentley\";\r\nimport { FormatDefinition, FormatsChangedArgs, FormatsProvider, MutableFormatsProvider } from \"@itwin/core-quantity\";\r\nimport { FormatSet } from \"../Deserialization/JsonProps\";\r\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\r\n\r\n/**\r\n * A mutable format provider that manages format definitions within a format set.\r\n * When formats are added or removed, the underlying format set is automatically updated.\r\n * @beta\r\n */\r\nexport class FormatSetFormatsProvider implements MutableFormatsProvider {\r\n public onFormatsChanged: BeEvent<(args: FormatsChangedArgs) => void> = new BeEvent<(args: FormatsChangedArgs) => void>();\r\n\r\n private _formatSet: FormatSet;\r\n private _fallbackProvider?: FormatsProvider;\r\n private _references: Map<string, string>; // Maps format name to the reference it points to\r\n\r\n public constructor(props: {formatSet: FormatSet, fallbackProvider?: FormatsProvider}) {\r\n this._formatSet = props.formatSet;\r\n this._fallbackProvider = props.fallbackProvider;\r\n this._references = new Map<string, string>();\r\n\r\n // Build up the map of string references\r\n for (const [name, format] of Object.entries(this._formatSet.formats)) {\r\n if (typeof format === \"string\") {\r\n this._references.set(name, format);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Adds or updates the format definition returned for a kind of quantity. Takes either a format definition or a kind of quantity full name that will be used to lookup the format that will be used.\r\n * @param name A kind of quantity full name used as a key to lookup this format\r\n * @param format The format definition or the name of a kind of quantity\r\n */\r\n public async addFormat(name: string, format: FormatDefinition | string): Promise<void> {\r\n this._formatSet.formats[name] = format;\r\n\r\n // Update the references map\r\n if (typeof format === \"string\") {\r\n this._references.set(name, format);\r\n } else {\r\n this._references.delete(name);\r\n }\r\n\r\n // Collect all formats that reference this format (directly or indirectly)\r\n const affectedFormats = this.getFormatsReferencingTarget(name);\r\n affectedFormats.add(name); // Include the format itself\r\n\r\n this.onFormatsChanged.raiseEvent({ formatsChanged: Array.from(affectedFormats) });\r\n }\r\n\r\n /**\r\n * Clears the fallback provider, if one is set.\r\n */\r\n public clearFallbackProvider(): void {\r\n this._fallbackProvider = undefined;\r\n }\r\n\r\n /**\r\n * Retrieves a format definition by its name from the format set. If not found, it checks the fallback provider to find the format, else returns undefined.\r\n * If the format is a string reference to another format, it resolves the reference and returns the FormatDefinition.\r\n */\r\n public async getFormat(input: string): Promise<FormatDefinition | undefined> {\r\n // Normalizes any schemaItem names coming from node addon 'schemaName:schemaItemName' -> 'schemaName.schemaItemName'\r\n const [schemaName, itemName] = SchemaItem.parseFullName(input);\r\n\r\n const name = (schemaName === \"\") ? itemName : `${schemaName}.${itemName}`;\r\n const format = this._formatSet.formats[name];\r\n\r\n if (format !== undefined) {\r\n // If format is a string reference, resolve it\r\n if (typeof format === \"string\") {\r\n return this.resolveReference(format);\r\n }\r\n return format;\r\n }\r\n\r\n if (this._fallbackProvider) return this._fallbackProvider.getFormat(name);\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Resolves a string reference to its FormatDefinition, following chains of references.\r\n * @param reference The string reference to resolve\r\n * @param visited Set of visited references to detect circular references\r\n */\r\n private async resolveReference(reference: string, visited: Set<string> = new Set()): Promise<FormatDefinition | undefined> {\r\n // Prevent infinite loops from circular references\r\n if (visited.has(reference)) {\r\n return undefined;\r\n }\r\n visited.add(reference);\r\n\r\n const format = this._formatSet.formats[reference];\r\n\r\n if (format === undefined) {\r\n if (this._fallbackProvider) {\r\n return this._fallbackProvider.getFormat(reference);\r\n }\r\n return undefined;\r\n }\r\n\r\n // If we found another string reference, resolve it recursively\r\n if (typeof format === \"string\") {\r\n return this.resolveReference(format, visited);\r\n }\r\n\r\n return format;\r\n }\r\n\r\n /**\r\n * Removes a format definition or string reference from the format set.\r\n * @param name The name of the format to remove\r\n */\r\n public async removeFormat(name: string): Promise<void> {\r\n // Collect all formats that reference this format (directly or indirectly)\r\n const affectedFormats = this.getFormatsReferencingTarget(name);\r\n affectedFormats.add(name); // Include the format itself\r\n\r\n delete this._formatSet.formats[name];\r\n this._references.delete(name);\r\n\r\n this.onFormatsChanged.raiseEvent({ formatsChanged: Array.from(affectedFormats) });\r\n }\r\n\r\n /**\r\n * Gets all format names that reference the target format (directly or indirectly).\r\n * @param target The format name to find references to\r\n * @returns Set of format names that reference the target\r\n */\r\n private getFormatsReferencingTarget(target: string): Set<string> {\r\n const referencingFormats = new Set<string>();\r\n\r\n // Find all formats that directly reference the target\r\n for (const [formatName, reference] of this._references.entries()) {\r\n if (reference === target) {\r\n referencingFormats.add(formatName);\r\n // Recursively find formats that reference this format\r\n const indirectReferences = this.getFormatsReferencingTarget(formatName);\r\n for (const indirectRef of indirectReferences) {\r\n referencingFormats.add(indirectRef);\r\n }\r\n }\r\n }\r\n\r\n return referencingFormats;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaFormatsProvider.js","sourceRoot":"","sources":["../../../src/Formatting/SchemaFormatsProvider.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAkB,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAM5D,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAC/C;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACxB,QAAQ,CAAgB;IACxB,WAAW,CAAgB;IAC3B,iBAAiB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAC5C,gBAAgB,GAAG,IAAI,OAAO,EAAsC,CAAC;IAC5E;;;;;;OAMG;IACH,YAAY,gBAAgC,EAAE,UAAyB;QACrE,IAAI,gBAAgB,YAAY,aAAa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AAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACjF,KAAK,QAAQ;YACX,OAAO,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC3E,KAAK,aAAa;YAChB,OAAO,CAAC,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACrE,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,6BAA6B,CAAC,eAAoC;IACzE,oDAAoD;IACpD,OAAO;QACL,YAAY,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC;QACrE,SAAS,EAAE,CAAC;QACZ,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,eAAe,CAAC,QAAQ;oBAC9B,KAAK,EAAE,eAAe,CAAC,KAAK;iBAC7B;aACF;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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 { ISchemaLocater, SchemaContext } from \"../Context\";\nimport { SchemaItemKey, SchemaKey } from \"../SchemaKey\";\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\nimport { Format } from \"../Metadata/Format\";\nimport { SchemaItemFormatProps } from \"../Deserialization/JsonProps\";\nimport { BeEvent, Logger } from \"@itwin/core-bentley\";\nimport { KindOfQuantity } from \"../Metadata/KindOfQuantity\";\nimport { getFormatProps } from \"../Metadata/OverrideFormat\";\nimport { FormatDefinition, FormatProps, FormatsChangedArgs, FormatsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\nimport { Unit } from \"../Metadata/Unit\";\nimport { InvertedUnit } from \"../Metadata/InvertedUnit\";\nimport { Schema } from \"../Metadata/Schema\";\nimport { UnitSystem } from \"../Metadata/UnitSystem\";\nconst loggerCategory = \"SchemaFormatsProvider\";\n/**\n * Provides default formats and kind of quantities from a given SchemaContext or SchemaLocater.\n * @beta\n */\nexport class SchemaFormatsProvider implements FormatsProvider {\n private _context: SchemaContext;\n private _unitSystem: UnitSystemKey;\n private _formatsRetrieved: Set<string> = new Set();\n public onFormatsChanged = new BeEvent<(args: FormatsChangedArgs) => void>();\n /**\n *\n * @param contextOrLocater The SchemaContext or a different ISchemaLocater implementation used to retrieve the schema. The SchemaContext\n * class implements the ISchemaLocater interface. If the provided locater is not a SchemaContext instance a new SchemaContext will be\n * created and the locater will be added.\n * @param unitSystem Used to lookup a default format through a schema specific algorithm, when the format retrieved is associated with a KindOfQuantity.\n */\n constructor(contextOrLocater: ISchemaLocater, unitSystem: UnitSystemKey) {\n if (contextOrLocater instanceof SchemaContext) {\n this._context = contextOrLocater;\n } else {\n this._context = new SchemaContext();\n this._context.addLocater(contextOrLocater);\n }\n this._unitSystem = unitSystem;\n }\n\n public get context() { return this._context; }\n public get unitSystem() { return this._unitSystem; }\n\n public set unitSystem(unitSystem: UnitSystemKey) {\n this._unitSystem = unitSystem;\n this.clear();\n }\n\n private clear(): void {\n const formatsChanged = Array.from(this._formatsRetrieved);\n this._formatsRetrieved.clear();\n this.onFormatsChanged.raiseEvent({ formatsChanged });\n }\n\n /** When using a presentation unit from a KindOfQuantity, the label and description should come from the KindOfQuantity */\n private convertToFormatDefinition(format: SchemaItemFormatProps, kindOfQuantity: KindOfQuantity): FormatDefinition {\n // Destructure all properties except 'rest'\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { name, label, description, $schema, schema, schemaVersion, schemaItemType,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n customAttributes, originalECSpecMajorVersion, originalECSpecMinorVersion, ...rest } = format;\n\n return {\n ...rest,\n name: kindOfQuantity.fullName,\n label: kindOfQuantity.label ?? format.label,\n description: kindOfQuantity.description ?? format.description,\n }\n }\n\n private async getKindOfQuantityFormatFromSchema(itemKey: SchemaItemKey): Promise<FormatDefinition | undefined> {\n let kindOfQuantity: KindOfQuantity | undefined;\n try {\n kindOfQuantity = await this._context.getSchemaItem(itemKey, KindOfQuantity);\n } catch {\n Logger.logError(loggerCategory, `Failed to find KindOfQuantity ${itemKey.fullName}`);\n return undefined;\n }\n\n if (!kindOfQuantity) {\n return undefined;\n }\n\n // Find the first presentation format that matches the provided unit system.\n const unitSystemMatchers = getUnitSystemGroupMatchers(this._unitSystem);\n const presentationFormats = kindOfQuantity.presentationFormats;\n for (const matcher of unitSystemMatchers) {\n for (const lazyFormat of presentationFormats) {\n const format = await lazyFormat;\n const unit = await (format.units && format.units[0][0]);\n if (!unit) {\n continue;\n }\n const currentUnitSystem = await unit.unitSystem;\n if (currentUnitSystem && matcher(currentUnitSystem)) {\n this._formatsRetrieved.add(itemKey.fullName);\n const props = getFormatProps(format);\n return this.convertToFormatDefinition(props, kindOfQuantity);\n }\n }\n }\n\n // If no matching presentation format was found, use persistence unit format if it matches unit system.\n const persistenceUnit = await kindOfQuantity.persistenceUnit;\n const persistenceUnitSystem = await persistenceUnit?.unitSystem;\n if (persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {\n this._formatsRetrieved.add(itemKey.fullName);\n const props = getPersistenceUnitFormatProps(persistenceUnit!);\n return this.convertToFormatDefinition(props, kindOfQuantity);\n }\n\n const defaultFormat = kindOfQuantity.defaultPresentationFormat;\n if (!defaultFormat) {\n return undefined;\n }\n this._formatsRetrieved.add(itemKey.fullName);\n const defaultProps = getFormatProps(await defaultFormat);\n return this.convertToFormatDefinition(defaultProps, kindOfQuantity);\n }\n\n\n /**\n * Retrieves a Format from a SchemaContext. If the format is part of a KindOfQuantity, the first presentation format in the KindOfQuantity that matches the current unit system will be retrieved.\n * If no presentation format matches the current unit system, the persistence unit format will be retrieved if it matches the current unit system.\n * Else, the default presentation format will be retrieved.\n * @param name The full name of the Format or KindOfQuantity.\n * @returns\n */\n public async getFormat(name: string): Promise<FormatDefinition | undefined> {\n const [schemaName, schemaItemName] = SchemaItem.parseFullName(name);\n const schemaKey = new SchemaKey(schemaName);\n let schema: Schema | undefined;\n try {\n schema = await this._context.getSchema(schemaKey);\n } catch {\n Logger.logError(loggerCategory, `Failed to find schema ${schemaName}`);\n return undefined;\n }\n if (!schema) {\n return undefined;\n }\n const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);\n\n if (schema.name === \"Formats\") {\n let format: Format | undefined;\n try {\n format = await this._context.getSchemaItem(itemKey, Format);\n } catch {\n Logger.logError(loggerCategory, `Failed to find Format ${itemKey.fullName}`);\n return undefined;\n }\n if (!format) {\n return undefined;\n }\n return format.toJSON(true);\n }\n return this.getKindOfQuantityFormatFromSchema(itemKey);\n }\n}\n\nfunction getUnitSystemGroupMatchers(groupKey?: UnitSystemKey) {\n function createMatcher(name: string | string[]) {\n const names = Array.isArray(name) ? name : [name];\n return (unitSystem: UnitSystem) => names.some((n) => n === unitSystem.name.toUpperCase());\n }\n switch (groupKey) {\n case \"imperial\":\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n case \"metric\":\n return [[\"SI\", \"METRIC\"], \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n case \"usCustomary\":\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n case \"usSurvey\":\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n }\n return [];\n}\n\nfunction getPersistenceUnitFormatProps(persistenceUnit: Unit | InvertedUnit): FormatProps {\n // Same as Format \"DefaultRealU\" in Formats ecschema\n return {\n formatTraits: [\"keepSingleZero\", \"keepDecimalPoint\", \"showUnitLabel\"],\n precision: 6,\n type: \"Decimal\",\n composite: {\n units: [\n {\n name: persistenceUnit.fullName,\n label: persistenceUnit.label,\n },\n ],\n },\n };\n}"]}
|
|
1
|
+
{"version":3,"file":"SchemaFormatsProvider.js","sourceRoot":"","sources":["../../../src/Formatting/SchemaFormatsProvider.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAkB,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAM5D,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAC/C;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACxB,QAAQ,CAAgB;IACxB,WAAW,CAAgB;IAC3B,iBAAiB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAC5C,gBAAgB,GAAG,IAAI,OAAO,EAAsC,CAAC;IAC5E;;;;;;OAMG;IACH,YAAY,gBAAgC,EAAE,UAAyB;QACrE,IAAI,gBAAgB,YAAY,aAAa,EAAE,CAAC;YAC9C,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;YACpC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,UAAU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AAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACrE,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,6BAA6B,CAAC,eAAoC;IACzE,oDAAoD;IACpD,OAAO;QACL,YAAY,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC;QACrE,SAAS,EAAE,CAAC;QACZ,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,eAAe,CAAC,QAAQ;oBAC9B,KAAK,EAAE,eAAe,CAAC,KAAK;iBAC7B;aACF;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { ISchemaLocater, SchemaContext } from \"../Context\";\r\nimport { SchemaItemKey, SchemaKey } from \"../SchemaKey\";\r\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\r\nimport { Format } from \"../Metadata/Format\";\r\nimport { SchemaItemFormatProps } from \"../Deserialization/JsonProps\";\r\nimport { BeEvent, Logger } from \"@itwin/core-bentley\";\r\nimport { KindOfQuantity } from \"../Metadata/KindOfQuantity\";\r\nimport { getFormatProps } from \"../Metadata/OverrideFormat\";\r\nimport { FormatDefinition, FormatProps, FormatsChangedArgs, FormatsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { Unit } from \"../Metadata/Unit\";\r\nimport { InvertedUnit } from \"../Metadata/InvertedUnit\";\r\nimport { Schema } from \"../Metadata/Schema\";\r\nimport { UnitSystem } from \"../Metadata/UnitSystem\";\r\nconst loggerCategory = \"SchemaFormatsProvider\";\r\n/**\r\n * Provides default formats and kind of quantities from a given SchemaContext or SchemaLocater.\r\n * @beta\r\n */\r\nexport class SchemaFormatsProvider implements FormatsProvider {\r\n private _context: SchemaContext;\r\n private _unitSystem: UnitSystemKey;\r\n private _formatsRetrieved: Set<string> = new Set();\r\n public onFormatsChanged = new BeEvent<(args: FormatsChangedArgs) => void>();\r\n /**\r\n *\r\n * @param contextOrLocater The SchemaContext or a different ISchemaLocater implementation used to retrieve the schema. The SchemaContext\r\n * class implements the ISchemaLocater interface. If the provided locater is not a SchemaContext instance a new SchemaContext will be\r\n * created and the locater will be added.\r\n * @param unitSystem Used to lookup a default format through a schema specific algorithm, when the format retrieved is associated with a KindOfQuantity.\r\n */\r\n constructor(contextOrLocater: ISchemaLocater, unitSystem: UnitSystemKey) {\r\n if (contextOrLocater instanceof SchemaContext) {\r\n this._context = contextOrLocater;\r\n } else {\r\n this._context = new SchemaContext();\r\n this._context.addLocater(contextOrLocater);\r\n }\r\n this._unitSystem = unitSystem;\r\n }\r\n\r\n public get context() { return this._context; }\r\n public get unitSystem() { return this._unitSystem; }\r\n\r\n public set unitSystem(unitSystem: UnitSystemKey) {\r\n this._unitSystem = unitSystem;\r\n this.clear();\r\n }\r\n\r\n private clear(): void {\r\n const formatsChanged = Array.from(this._formatsRetrieved);\r\n this._formatsRetrieved.clear();\r\n this.onFormatsChanged.raiseEvent({ formatsChanged });\r\n }\r\n\r\n /** When using a presentation unit from a KindOfQuantity, the label and description should come from the KindOfQuantity */\r\n private convertToFormatDefinition(format: SchemaItemFormatProps, kindOfQuantity: KindOfQuantity): FormatDefinition {\r\n // Destructure all properties except 'rest'\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n const { name, label, description, $schema, schema, schemaVersion, schemaItemType,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n customAttributes, originalECSpecMajorVersion, originalECSpecMinorVersion, ...rest } = format;\r\n\r\n return {\r\n ...rest,\r\n name: kindOfQuantity.fullName,\r\n label: kindOfQuantity.label ?? format.label,\r\n description: kindOfQuantity.description ?? format.description,\r\n }\r\n }\r\n\r\n private async getKindOfQuantityFormatFromSchema(itemKey: SchemaItemKey): Promise<FormatDefinition | undefined> {\r\n let kindOfQuantity: KindOfQuantity | undefined;\r\n try {\r\n kindOfQuantity = await this._context.getSchemaItem(itemKey, KindOfQuantity);\r\n } catch {\r\n Logger.logError(loggerCategory, `Failed to find KindOfQuantity ${itemKey.fullName}`);\r\n return undefined;\r\n }\r\n\r\n if (!kindOfQuantity) {\r\n return undefined;\r\n }\r\n\r\n // Find the first presentation format that matches the provided unit system.\r\n const unitSystemMatchers = getUnitSystemGroupMatchers(this._unitSystem);\r\n const presentationFormats = kindOfQuantity.presentationFormats;\r\n for (const matcher of unitSystemMatchers) {\r\n for (const lazyFormat of presentationFormats) {\r\n const format = await lazyFormat;\r\n const unit = await (format.units && format.units[0][0]);\r\n if (!unit) {\r\n continue;\r\n }\r\n const currentUnitSystem = await unit.unitSystem;\r\n if (currentUnitSystem && matcher(currentUnitSystem)) {\r\n this._formatsRetrieved.add(itemKey.fullName);\r\n const props = getFormatProps(format);\r\n return this.convertToFormatDefinition(props, kindOfQuantity);\r\n }\r\n }\r\n }\r\n\r\n // If no matching presentation format was found, use persistence unit format if it matches unit system.\r\n const persistenceUnit = await kindOfQuantity.persistenceUnit;\r\n const persistenceUnitSystem = await persistenceUnit?.unitSystem;\r\n if (persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {\r\n this._formatsRetrieved.add(itemKey.fullName);\r\n const props = getPersistenceUnitFormatProps(persistenceUnit!);\r\n return this.convertToFormatDefinition(props, kindOfQuantity);\r\n }\r\n\r\n const defaultFormat = kindOfQuantity.defaultPresentationFormat;\r\n if (!defaultFormat) {\r\n return undefined;\r\n }\r\n this._formatsRetrieved.add(itemKey.fullName);\r\n const defaultProps = getFormatProps(await defaultFormat);\r\n return this.convertToFormatDefinition(defaultProps, kindOfQuantity);\r\n }\r\n\r\n\r\n /**\r\n * Retrieves a Format from a SchemaContext. If the format is part of a KindOfQuantity, the first presentation format in the KindOfQuantity that matches the current unit system will be retrieved.\r\n * If no presentation format matches the current unit system, the persistence unit format will be retrieved if it matches the current unit system.\r\n * Else, the default presentation format will be retrieved.\r\n * @param name The full name of the Format or KindOfQuantity.\r\n * @returns\r\n */\r\n public async getFormat(name: string): Promise<FormatDefinition | undefined> {\r\n const [schemaName, schemaItemName] = SchemaItem.parseFullName(name);\r\n const schemaKey = new SchemaKey(schemaName);\r\n let schema: Schema | undefined;\r\n try {\r\n schema = await this._context.getSchema(schemaKey);\r\n } catch {\r\n Logger.logError(loggerCategory, `Failed to find schema ${schemaName}`);\r\n return undefined;\r\n }\r\n if (!schema) {\r\n return undefined;\r\n }\r\n const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);\r\n\r\n if (schema.name === \"Formats\") {\r\n let format: Format | undefined;\r\n try {\r\n format = await this._context.getSchemaItem(itemKey, Format);\r\n } catch {\r\n Logger.logError(loggerCategory, `Failed to find Format ${itemKey.fullName}`);\r\n return undefined;\r\n }\r\n if (!format) {\r\n return undefined;\r\n }\r\n return format.toJSON(true);\r\n }\r\n return this.getKindOfQuantityFormatFromSchema(itemKey);\r\n }\r\n}\r\n\r\nfunction getUnitSystemGroupMatchers(groupKey?: UnitSystemKey) {\r\n function createMatcher(name: string | string[]) {\r\n const names = Array.isArray(name) ? name : [name];\r\n return (unitSystem: UnitSystem) => names.some((n) => n === unitSystem.name.toUpperCase());\r\n }\r\n switch (groupKey) {\r\n case \"imperial\":\r\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n case \"metric\":\r\n return [[\"SI\", \"METRIC\"], \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n case \"usCustomary\":\r\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n case \"usSurvey\":\r\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n }\r\n return [];\r\n}\r\n\r\nfunction getPersistenceUnitFormatProps(persistenceUnit: Unit | InvertedUnit): FormatProps {\r\n // Same as Format \"DefaultRealU\" in Formats ecschema\r\n return {\r\n formatTraits: [\"keepSingleZero\", \"keepDecimalPoint\", \"showUnitLabel\"],\r\n precision: 6,\r\n type: \"Decimal\",\r\n composite: {\r\n units: [\r\n {\r\n name: persistenceUnit.fullName,\r\n label: persistenceUnit.label,\r\n },\r\n ],\r\n },\r\n };\r\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassParsers.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/ClassParsers.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAUtD;;;;;GAKG;AACH,MAAM,OAAO,WAAY,SAAQ,gBAAgB;IAC/C;;;;OAIG;IACa,KAAK,CAAC,KAAK,CAAC,IAAgB;QAC1C,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAAsB,CAAC;QAC3D,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;YACrB,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;gBAC/B,OAAO,KAAK,CAAC,UAAU,CAAC;;gBAExB,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,eAAe,CAAC,aAAiC;QACvD,KAAK,MAAM,KAAK,IAAI,aAAuC,EAAE,CAAC;YAC5D,KAAK,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AA2B,CAAC;QAChE,MAAM,MAAM,GAAG,KAAK,CAAC,MAA4C,CAAC;QAClE,MAAM,MAAM,GAAG,KAAK,CAAC,MAA4C,CAAC;QAElE,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,GAAG,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACnJ,IAAI,CAAC,MAAM,CAAC,gBAAgB;gBAC1B,OAAO,MAAM,CAAC,gBAAgB,CAAC;QACnC,CAAC;QAED,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,GAAG,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACnJ,IAAI,CAAC,MAAM,CAAC,gBAAgB;gBAC1B,OAAO,MAAM,CAAC,gBAAgB,CAAC;QACnC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF","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\nimport { AnyPropertyProps, ClassProps, CustomAttributeClassProps, MixinProps, RelationshipClassProps, RelationshipConstraintProps } from \"../Deserialization/JsonProps\";\nimport { containerTypeToString, CustomAttributeContainerType } from \"../ECObjects\";\nimport { SchemaItemParser } from \"./SchemaItemParsers\";\nimport { parseCustomAttribute } from \"./SchemaParser\";\n\ntype MutablePropertyProps = {\n -readonly [K in keyof AnyPropertyProps]: AnyPropertyProps[K]\n};\n\ntype MutableClassProps = {\n -readonly [K in keyof ClassProps]: ClassProps[K]\n};\n\n/**\n * Parses ClassProps JSON returned from an ECSql query and returns the correct ClassProps JSON.\n * This is necessary as a small amount information (ie. CustomAttribute data) returned from the\n * iModelDb is in a different format than is required for a ClassProps JSON object.\n * @internal\n */\nexport class ClassParser extends SchemaItemParser {\n /**\n * Parses the given ClassProps JSON returned from an ECSql query.\n * @param data The ClassProps JSON as returned from an iModelDb.\n * @returns The corrected ClassProps Json.\n */\n public override async parse(data: ClassProps): Promise<ClassProps> {\n const props = await super.parse(data) as MutableClassProps;\n if (props.properties) {\n if (props.properties.length === 0)\n delete props.properties;\n else\n this.parseProperties(props.properties);\n }\n\n return props;\n }\n\n private parseProperties(propertyProps: AnyPropertyProps[]) {\n for (const props of propertyProps as MutablePropertyProps[]) {\n props.customAttributes = props.customAttributes && props.customAttributes.length > 0 ? props.customAttributes.map((attr: any) => { return parseCustomAttribute(attr); }) : undefined;\n if (!props.customAttributes)\n delete props.customAttributes;\n }\n }\n}\n\ntype MutableMixinProps = {\n -readonly [K in keyof MixinProps]: MixinProps[K]\n};\n\n/**\n * Parses the given MixinProps JSON returned from an ECSql query.\n * @param data The MixinProps JSON as returned from an iModelDb.\n * @returns The corrected MixinProps Json.\n * @internal\n */\nexport class MixinParser extends ClassParser {\n /**\n * Parses the given MixinProps JSON returned from an ECSql query.\n * @param data The MixinProps JSON as returned from an iModelDb.\n * @returns The corrected MixinProps Json.\n */\n public override async parse(data: MixinProps): Promise<MixinProps> {\n const props = await super.parse(data) as MutableMixinProps;\n if (!props.customAttributes)\n delete props.customAttributes;\n\n return props;\n }\n}\n\ntype MutableCustomAttributeClassProps = {\n -readonly [K in keyof CustomAttributeClassProps]: CustomAttributeClassProps[K]\n};\n\n/**\n * Parses the given CustomAttributeClassProps JSON returned from an ECSql query.\n * @param data The CustomAttributeClassProps JSON as returned from an iModelDb.\n * @returns The corrected CustomAttributeClassProps Json.\n * @internal\n */\nexport class CustomAttributeClassParser extends ClassParser {\n /**\n * Parses the given CustomAttributeClassProps JSON returned from an ECSql query.\n * @param data The CustomAttributeClassProps JSON as returned from an iModelDb.\n * @returns The corrected CustomAttributeClassProps Json.\n */\n public override async parse(data: CustomAttributeClassProps): Promise<CustomAttributeClassProps> {\n const props = await super.parse(data) as MutableCustomAttributeClassProps;\n props.appliesTo = props.appliesTo ? containerTypeToString(props.appliesTo as any as number) : CustomAttributeContainerType[CustomAttributeContainerType.Any];\n return props;\n }\n}\n\ntype MutableRelationshipConstraintProps = {\n -readonly [K in keyof RelationshipConstraintProps]: RelationshipConstraintProps[K]\n};\n\n/**\n * Parses the given RelationshipClassProps JSON returned from an ECSql query.\n * @param data The RelationshipClassProps JSON as returned from an iModelDb.\n * @returns The corrected RelationshipClassProps Json.\n * @internal\n */\nexport class RelationshipClassParser extends ClassParser {\n /**\n * Parses the given RelationshipClassProps JSON returned from an ECSql query.\n * @param data The RelationshipClassProps JSON as returned from an iModelDb.\n * @returns The corrected RelationshipClassProps Json.\n */\n public override async parse(data: RelationshipClassProps): Promise<RelationshipClassProps> {\n const props = await super.parse(data) as RelationshipClassProps;\n const source = props.source as MutableRelationshipConstraintProps;\n const target = props.target as MutableRelationshipConstraintProps;\n\n if (source) {\n source.customAttributes = source.customAttributes ? source.customAttributes.map((attr: any) => { return parseCustomAttribute(attr); }) : undefined;\n if (!source.customAttributes)\n delete source.customAttributes;\n }\n\n if (target) {\n target.customAttributes = target.customAttributes ? target.customAttributes.map((attr: any) => { return parseCustomAttribute(attr); }) : undefined;\n if (!target.customAttributes)\n delete target.customAttributes;\n }\n\n return props;\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"ClassParsers.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/ClassParsers.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,q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AI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACnJ,IAAI,CAAC,MAAM,CAAC,gBAAgB;gBAC1B,OAAO,MAAM,CAAC,gBAAgB,CAAC;QACnC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n\r\nimport { AnyPropertyProps, ClassProps, CustomAttributeClassProps, MixinProps, RelationshipClassProps, RelationshipConstraintProps } from \"../Deserialization/JsonProps\";\r\nimport { containerTypeToString, CustomAttributeContainerType } from \"../ECObjects\";\r\nimport { SchemaItemParser } from \"./SchemaItemParsers\";\r\nimport { parseCustomAttribute } from \"./SchemaParser\";\r\n\r\ntype MutablePropertyProps = {\r\n -readonly [K in keyof AnyPropertyProps]: AnyPropertyProps[K]\r\n};\r\n\r\ntype MutableClassProps = {\r\n -readonly [K in keyof ClassProps]: ClassProps[K]\r\n};\r\n\r\n/**\r\n * Parses ClassProps JSON returned from an ECSql query and returns the correct ClassProps JSON.\r\n * This is necessary as a small amount information (ie. CustomAttribute data) returned from the\r\n * iModelDb is in a different format than is required for a ClassProps JSON object.\r\n * @internal\r\n */\r\nexport class ClassParser extends SchemaItemParser {\r\n /**\r\n * Parses the given ClassProps JSON returned from an ECSql query.\r\n * @param data The ClassProps JSON as returned from an iModelDb.\r\n * @returns The corrected ClassProps Json.\r\n */\r\n public override async parse(data: ClassProps): Promise<ClassProps> {\r\n const props = await super.parse(data) as MutableClassProps;\r\n if (props.properties) {\r\n if (props.properties.length === 0)\r\n delete props.properties;\r\n else\r\n this.parseProperties(props.properties);\r\n }\r\n\r\n return props;\r\n }\r\n\r\n private parseProperties(propertyProps: AnyPropertyProps[]) {\r\n for (const props of propertyProps as MutablePropertyProps[]) {\r\n props.customAttributes = props.customAttributes && props.customAttributes.length > 0 ? props.customAttributes.map((attr: any) => { return parseCustomAttribute(attr); }) : undefined;\r\n if (!props.customAttributes)\r\n delete props.customAttributes;\r\n }\r\n }\r\n}\r\n\r\ntype MutableMixinProps = {\r\n -readonly [K in keyof MixinProps]: MixinProps[K]\r\n};\r\n\r\n/**\r\n * Parses the given MixinProps JSON returned from an ECSql query.\r\n * @param data The MixinProps JSON as returned from an iModelDb.\r\n * @returns The corrected MixinProps Json.\r\n * @internal\r\n */\r\nexport class MixinParser extends ClassParser {\r\n /**\r\n * Parses the given MixinProps JSON returned from an ECSql query.\r\n * @param data The MixinProps JSON as returned from an iModelDb.\r\n * @returns The corrected MixinProps Json.\r\n */\r\n public override async parse(data: MixinProps): Promise<MixinProps> {\r\n const props = await super.parse(data) as MutableMixinProps;\r\n if (!props.customAttributes)\r\n delete props.customAttributes;\r\n\r\n return props;\r\n }\r\n}\r\n\r\ntype MutableCustomAttributeClassProps = {\r\n -readonly [K in keyof CustomAttributeClassProps]: CustomAttributeClassProps[K]\r\n};\r\n\r\n/**\r\n * Parses the given CustomAttributeClassProps JSON returned from an ECSql query.\r\n * @param data The CustomAttributeClassProps JSON as returned from an iModelDb.\r\n * @returns The corrected CustomAttributeClassProps Json.\r\n * @internal\r\n */\r\nexport class CustomAttributeClassParser extends ClassParser {\r\n /**\r\n * Parses the given CustomAttributeClassProps JSON returned from an ECSql query.\r\n * @param data The CustomAttributeClassProps JSON as returned from an iModelDb.\r\n * @returns The corrected CustomAttributeClassProps Json.\r\n */\r\n public override async parse(data: CustomAttributeClassProps): Promise<CustomAttributeClassProps> {\r\n const props = await super.parse(data) as MutableCustomAttributeClassProps;\r\n props.appliesTo = props.appliesTo ? containerTypeToString(props.appliesTo as any as number) : CustomAttributeContainerType[CustomAttributeContainerType.Any];\r\n return props;\r\n }\r\n}\r\n\r\ntype MutableRelationshipConstraintProps = {\r\n -readonly [K in keyof RelationshipConstraintProps]: RelationshipConstraintProps[K]\r\n};\r\n\r\n/**\r\n * Parses the given RelationshipClassProps JSON returned from an ECSql query.\r\n * @param data The RelationshipClassProps JSON as returned from an iModelDb.\r\n * @returns The corrected RelationshipClassProps Json.\r\n * @internal\r\n */\r\nexport class RelationshipClassParser extends ClassParser {\r\n /**\r\n * Parses the given RelationshipClassProps JSON returned from an ECSql query.\r\n * @param data The RelationshipClassProps JSON as returned from an iModelDb.\r\n * @returns The corrected RelationshipClassProps Json.\r\n */\r\n public override async parse(data: RelationshipClassProps): Promise<RelationshipClassProps> {\r\n const props = await super.parse(data) as RelationshipClassProps;\r\n const source = props.source as MutableRelationshipConstraintProps;\r\n const target = props.target as MutableRelationshipConstraintProps;\r\n\r\n if (source) {\r\n source.customAttributes = source.customAttributes ? source.customAttributes.map((attr: any) => { return parseCustomAttribute(attr); }) : undefined;\r\n if (!source.customAttributes)\r\n delete source.customAttributes;\r\n }\r\n\r\n if (target) {\r\n target.customAttributes = target.customAttributes ? target.customAttributes.map((attr: any) => { return parseCustomAttribute(attr); }) : undefined;\r\n if (!target.customAttributes)\r\n delete target.customAttributes;\r\n }\r\n\r\n return props;\r\n }\r\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSqlSchemaLocater.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/ECSqlSchemaLocater.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAK7C,OAAO,EAAkB,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAwB,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MA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AK,CAAC,EAAE,GAAG,OAAO,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC1E,CAAC,CAAC,SAAS;SACd,CAAC,CAAC;QAEH,MAAM,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAE5C,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YAC5C,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YACvF,MAAM,eAAe,CAAC,QAAQ,CAAC,MAAM,EAAE;gBACrC,GAAG,SAAS;gBACZ,IAAI,EAAE,SAAS,CAAC,IAAI;gBACpB,cAAc,EAAE,SAAS,CAAC,cAAc;aACzC,CAAC,CAAC;YACH,MAAM,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;AACH,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 *--------------------------------------------------------------------------------------------*/\nimport { Logger } from \"@itwin/core-bentley\";\nimport { SchemaContext } from \"../Context\";\nimport { ConstantProps, CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps, MixinProps,\n PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, SchemaItemFormatProps, SchemaItemProps, SchemaItemUnitProps, SchemaProps,\n StructClassProps, UnitSystemProps } from \"../Deserialization/JsonProps\";\nimport { SchemaItemType, SchemaMatchType } from \"../ECObjects\";\nimport { SchemaInfo, WithSchemaKey } from \"../Interfaces\";\nimport { SchemaKey } from \"../SchemaKey\";\nimport { FullSchemaQueries } from \"./FullSchemaQueries\";\nimport { IncrementalSchemaLocater, SchemaLocaterOptions } from \"./IncrementalSchemaLocater\";\nimport { SchemaItemQueries } from \"./SchemaItemQueries\";\nimport { SchemaParser } from \"./SchemaParser\";\nimport { ecsqlQueries } from \"./SchemaStubQueries\";\n\ninterface SchemaItemInfo {\n readonly name: string;\n readonly schemaItemType: SchemaItemType;\n}\n\ninterface SchemaInfoRow {\n readonly name: string;\n readonly version: string;\n readonly alias: string;\n readonly label: string;\n readonly description: string; \n readonly references: string;\n}\n\ninterface SchemaStubRow {\n readonly item: string;\n}\n\ninterface BaseClassStubRow {\n readonly schema: string;\n readonly name: string;\n readonly schemaItemType: string;\n readonly modifier: number;\n}\n\ninterface SchemaItemStubRow {\n readonly name: string;\n readonly schemaItemType: string;\n readonly modifier?: number;\n readonly baseClasses?: Array<BaseClassStubRow>;\n readonly mixins?: Array<{\n readonly schema: string,\n readonly name: string;\n readonly schemaItemType: string;\n readonly modifier: number;\n readonly baseClasses?: Array<BaseClassStubRow>\n }>;\n}\n\ninterface SchemaRow {\n schema: string\n}\n\ninterface SchemaItemRow {\n item: string | SchemaItemProps;\n}\n\ntype AddSchemaItemHandler = <T extends SchemaItemInfo>(schemaName: string, itemStub: T) => Promise<void>;\n\ntype MutableSchemaProps = {\n -readonly [K in keyof SchemaProps]: SchemaProps[K];\n};\n\ninterface QueryParameters {\n [parameterName: string]: string | number;\n}\n\nconst LOGGER_CATEGORY = \"IncrementalSchemaLoading.Performance\";\n\n/**\n * Query options used by the ECSqlSchemaLocater.\n * @internal\n */\nexport interface ECSqlQueryOptions {\n parameters?: QueryParameters;\n limit?: number;\n}\n\n/**\n * Defines the [[ECSqlSchemaLocater]] options which determine how each\n * schema is to be loaded. All options are optional.\n * @internal\n */\nexport interface ECSqlSchemaLocaterOptions extends SchemaLocaterOptions {\n /** Query for Schemas using multiple queries. Defaults to false. */\n readonly useMultipleQueries?: boolean;\n}\n\n/**\n * An abstract [[IncrementalSchemaLocater]] implementation for loading\n * EC [Schema] instances from an iModelDb using ECSql queries.\n * @internal\n */\nexport abstract class ECSqlSchemaLocater extends IncrementalSchemaLocater {\n /**\n * Gets the [[ECSqlSchemaLocaterOptions]] used by this locater.\n */\n protected override get options(): ECSqlSchemaLocaterOptions {\n return super.options as ECSqlSchemaLocaterOptions;\n }\n\n /**\n * Initializes a new ECSqlSchemaLocater instance.\n * @param options The options used by this Schema locater.\n */\n constructor(options?: ECSqlSchemaLocaterOptions) {\n super(options);\n }\n\n /**\n * Executes the given ECSql query and returns the resulting rows.\n * @param query The ECSql query to execute.\n * @param options Optional arguments to control the query result.\n * @returns A promise that resolves to the resulting rows.\n */\n protected abstract executeQuery<TRow>(query: string, options?: ECSqlQueryOptions): Promise<ReadonlyArray<TRow>>;\n\n /**\n * Gets the [[SchemaProps]] for the given schema key.\n * @param schemaKey The schema key of the schema to be resolved.\n */\n protected abstract getSchemaProps(schemaKey: SchemaKey): Promise<SchemaProps | undefined>\n\n /**\n * Gets the [[SchemaProps]] for the given schema key. This is the full schema json with all elements that are defined\n * in the schema. The schema locater calls this after the stub has been loaded to fully load the schema in the background.\n * @param schemaKey The [[SchemaKey]] of the schema to be resolved.\n * @param context The [[SchemaContext]] to use for resolving references.\n * @internal\n */\n protected async getSchemaJson(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\n // If the meta schema is an earlier version than 4.0.3, we can't use the ECSql query interface to get the schema\n // information required to load the schema entirely. In this case, we fallback to use the ECSchema RPC interface\n // to fetch the whole schema json.\n if (!await this.supportPartialSchemaLoading(context))\n return this.getSchemaProps(schemaKey);\n\n const queryStart = Date.now();\n const schemaProps = this.options.useMultipleQueries\n ? await this.getFullSchemaMultipleQueries(schemaKey, context)\n : await this.getFullSchema(schemaKey, context);\n\n const queryDuration = Date.now() - queryStart;\n Logger.logTrace(LOGGER_CATEGORY, `Recieved SchemaProps for ${schemaKey.name} in ${queryDuration}ms`, {\n schemaName: schemaKey.name,\n queryMode: this.options.useMultipleQueries ? \"parallel\" : \"single\",\n duration: queryDuration,\n });\n\n return schemaProps;\n };\n\n /**\n * Gets the [[SchemaProps]] without schemaItems for the given schema name.\n * @param schemaName The name of the Schema.\n * @param context The [[SchemaContext]] to use for resolving references.\n * @returns\n * @internal\n */\n private async getSchemaNoItems(schemaName: string, context: SchemaContext): Promise<SchemaProps | undefined> {\n const schemaRows = await this.executeQuery<SchemaRow>(FullSchemaQueries.schemaNoItemsQuery, { parameters: { schemaName } });\n const schemaRow = schemaRows[0];\n if (schemaRow === undefined)\n return undefined;\n\n const schema = JSON.parse(schemaRow.schema) as SchemaProps;\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\n return SchemaParser.parse(schema, schemaInfos);\n }\n\n /**\n * Checks if the [[SchemaContext]] has the right Meta Schema version to support the incremental schema loading.\n * @param context The schema context to lookup the meta schema.\n * @returns true if the context has a supported meta schema version, false otherwise.\n */\n protected async supportPartialSchemaLoading(context: SchemaContext): Promise<boolean> {\n const metaSchemaKey = new SchemaKey(\"ECDbMeta\", 4, 0, 3);\n const metaSchemaInfo = await context.getSchemaInfo(metaSchemaKey, SchemaMatchType.LatestWriteCompatible);\n return metaSchemaInfo !== undefined;\n };\n\n /**\n * Gets all the Schema's Entity classes as [[EntityClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The [[SchemaContext]] to which the schema belongs.\n * @returns A promise that resolves to a EntityClassProps array. Maybe empty of no entities are found.\n * @internal\n */\n protected async getEntities(schema: string, context: SchemaContext, queryOverride?: string): Promise<EntityClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.entityQuery;\n return this.querySchemaItem<EntityClassProps>(context, schema, query, \"EntityClass\");\n }\n\n /**\n * Gets all the Schema's Mixin classes as [[MixinProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a MixinProps array. Maybe empty of no entities are found.\n * @internal\n */\n protected async getMixins(schema: string, context: SchemaContext, queryOverride?: string): Promise<MixinProps[]> {\n const query = queryOverride ?? FullSchemaQueries.mixinQuery;\n return this.querySchemaItem<MixinProps>(context, schema, query, \"Mixin\");\n }\n\n /**\n * Gets all the Schema's Relationship classes as [[RelationshipClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a RelationshipClassProps array. Maybe empty if no items are found.\n * @internal\n */\n protected async getRelationships(schema: string, context: SchemaContext, queryOverride?: string): Promise<RelationshipClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.relationshipClassQuery;\n return this.querySchemaItem<RelationshipClassProps>(context, schema, query, \"RelationshipClass\");\n }\n\n /**\n * Gets all the Schema's CustomAttributeClass items as [[CustomAttributeClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a CustomAttributeClassProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getCustomAttributeClasses(schema: string, context: SchemaContext, queryOverride?: string): Promise<CustomAttributeClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.customAttributeQuery;\n return this.querySchemaItem<CustomAttributeClassProps>(context, schema, query, \"CustomAttributeClass\");\n }\n\n\n /**\n * Gets all the Schema's StructClass items as [[StructClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a StructClassProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getStructs(schema: string, context: SchemaContext, queryOverride?: string): Promise<StructClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.structQuery;\n return this.querySchemaItem<StructClassProps>(context, schema, query, \"StructClass\");\n }\n\n /**\n * Gets all the Schema's KindOfQuantity items as [[KindOfQuantityProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a KindOfQuantityProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getKindOfQuantities(schema: string, context: SchemaContext): Promise<KindOfQuantityProps[]> {\n return this.querySchemaItem<KindOfQuantityProps>(context, schema, SchemaItemQueries.kindOfQuantity(true), \"KindOfQuantity\");\n }\n\n /**\n * Gets all the Schema's PropertyCategory items as [[PropertyCategoryProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a PropertyCategoryProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getPropertyCategories(schema: string, context: SchemaContext): Promise<PropertyCategoryProps[]> {\n return this.querySchemaItem<PropertyCategoryProps>(context, schema, SchemaItemQueries.propertyCategory(true), \"PropertyCategory\");\n }\n\n /**\n * Gets all the Schema's Enumeration items as [[EnumerationProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a EnumerationProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getEnumerations(schema: string, context: SchemaContext): Promise<EnumerationProps[]> {\n return this.querySchemaItem<EnumerationProps>(context, schema, SchemaItemQueries.enumeration(true), \"Enumeration\");\n }\n\n /**\n * Gets all the Schema's Unit items as [[SchemaItemUnitProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a SchemaItemUnitProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getUnits(schema: string, context: SchemaContext): Promise<SchemaItemUnitProps[]> {\n return this.querySchemaItem<SchemaItemUnitProps>(context, schema, SchemaItemQueries.unit(true), \"Unit\");\n }\n\n /**\n * Gets all the Schema's InvertedUnit items as [[InvertedUnitProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a InvertedUnitProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getInvertedUnits(schema: string, context: SchemaContext): Promise<InvertedUnitProps[]> {\n return this.querySchemaItem<InvertedUnitProps>(context, schema, SchemaItemQueries.invertedUnit(true), \"InvertedUnit\");\n }\n\n /**\n * Gets all the Schema's Constant items as [[ConstantProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a ConstantProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getConstants(schema: string, context: SchemaContext): Promise<ConstantProps[]> {\n return this.querySchemaItem<ConstantProps>(context, schema, SchemaItemQueries.constant(true), \"Constant\");\n }\n\n /**\n * Gets all the Schema's UnitSystem items as [[UnitSystemProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a UnitSystemProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getUnitSystems(schema: string, context: SchemaContext): Promise<UnitSystemProps[]> {\n return this.querySchemaItem<UnitSystemProps>(context, schema, SchemaItemQueries.unitSystem(true), \"UnitSystem\");\n }\n\n /**\n * Gets all the Schema's Phenomenon items as [[PhenomenonProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a PhenomenonProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getPhenomenon(schema: string, context: SchemaContext): Promise<PhenomenonProps[]> {\n return this.querySchemaItem<PhenomenonProps>(context, schema, SchemaItemQueries.phenomenon(true), \"Phenomenon\");\n }\n\n /**\n * Gets all the Schema's Format items as [[SchemaItemFormatProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a SchemaItemFormatProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getFormats(schema: string, context: SchemaContext): Promise<SchemaItemFormatProps[]> {\n return this.querySchemaItem<SchemaItemFormatProps>(context, schema, SchemaItemQueries.format(true), \"Format\");\n }\n\n /**\n * Gets [[SchemaInfo]] objects for all schemas including their direct schema references.\n * @internal\n */\n protected async loadSchemaInfos(): Promise<ReadonlyArray<SchemaInfo>> {\n const schemaRows = await this.executeQuery<SchemaInfoRow>(ecsqlQueries.schemaInfoQuery);\n return schemaRows.map((schemaRow) => (\n {\n alias: schemaRow.alias,\n description: schemaRow.description,\n label: schemaRow.label,\n schemaKey: SchemaKey.parseString(`${schemaRow.name}.${schemaRow.version}`),\n references: Array.from(JSON.parse(schemaRow.references), parseSchemaReference),\n }\n ));\n }\n\n /**\n * Gets the [[SchemaProps]] to create the basic schema skeleton. Depending on which options are set, the schema items or class hierarchy\n * can be included in the initial fetch.\n * @param schemaKey The [[SchemaKey]] of the schema to be resolved.\n * @returns A promise that resolves to the schema partials, which is an array of [[SchemaProps]].\n * @internal\n */\n protected async getSchemaPartials(schemaKey: SchemaKey, context: SchemaContext): Promise<ReadonlyArray<SchemaProps> | undefined> {\n const queryStart = Date.now();\n const itemRows = await this.executeQuery<SchemaStubRow>(ecsqlQueries.schemaStubQuery, {\n parameters: { schemaName: schemaKey.name }\n });\n\n const queryDuration = Date.now() - queryStart;\n Logger.logTrace(LOGGER_CATEGORY, `Recieved PartialSchema for ${schemaKey.name} in ${queryDuration}ms`, {\n schemaName: schemaKey.name,\n itemCount: itemRows.length,\n duration: queryDuration,\n });\n\n if (itemRows.length === 0)\n return undefined;\n\n const schemaPartials: Array<SchemaProps> = [];\n const addSchema = async (key: SchemaKey) => {\n const stub = await this.createSchemaProps(key, context);\n schemaPartials.push(stub);\n\n if (stub.references) {\n for (const referenceProps of stub.references) {\n if (!schemaPartials.some((schema) => schema.name === referenceProps.name)) {\n await addSchema(SchemaKey.parseString(`${referenceProps.name}.${referenceProps.version}`));\n }\n }\n }\n\n return stub;\n };\n\n const addItems = async (schemaName: string, itemInfo: SchemaItemInfo) => {\n let schemaStub = schemaPartials.find((schema) => schema.name === schemaName);\n if (!schemaStub) {\n schemaStub = await addSchema(SchemaKey.parseString(`${schemaName}.0.0.0`));\n }\n\n let items = schemaStub.items;\n if (!items) {\n Object.assign(schemaStub, items = { items: {} });\n }\n\n const existingItem = items[itemInfo.name] || {};\n Object.assign(items, { [itemInfo.name]: Object.assign(existingItem, itemInfo) });\n };\n\n const reviver = (_key: string, value: any) => {\n return value === null ? undefined : value;\n };\n\n await addSchema(schemaKey);\n\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\n const stubItems = itemRows.map((itemRow) => {\n return JSON.parse(itemRow.item, reviver) as SchemaItemStubRow;\n });\n await parseSchemaItemStubs(schemaKey.name, stubItems, addItems, schemaInfos);\n\n return schemaPartials;\n }\n\n private async querySchemaItem<TRow extends SchemaItemProps>(context: SchemaContext, schemaName: string, query: string, schemaType: string): Promise<Array<TRow>> {\n const start = Date.now();\n const itemRows = await this.executeQuery<SchemaItemRow>(query, { parameters: { schemaName } });\n\n const queryDuration = Date.now() - start;\n Logger.logTrace(LOGGER_CATEGORY, `Recieved rows of ${schemaType} items for ${schemaName} in ${queryDuration}ms`, {\n schemaName,\n itemCount: itemRows.length,\n itemType: schemaType,\n duration: queryDuration,\n });\n\n if (itemRows.length === 0)\n return [];\n\n const items = itemRows.map((itemRow: SchemaItemRow) => {\n return \"string\" === typeof itemRow.item ? JSON.parse(itemRow.item) : itemRow.item;\n });\n\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\n return await SchemaParser.parseSchemaItems(items, schemaName, schemaInfos) as Array<TRow> ?? []\n }\n\n private async getFullSchema(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\n const schemaRows = await this.executeQuery<SchemaRow>(FullSchemaQueries.schemaQuery, { parameters: { schemaName: schemaKey.name } });\n const schemaRow = schemaRows[0];\n if (schemaRow === undefined)\n return undefined;\n\n // Map SchemaItemRow array, [{item: SchemaItemProps}], to array of SchemaItemProps.\n const schema = JSON.parse(schemaRow.schema) as SchemaProps;\n if (schema.items) {\n (schema as any).items = (schema.items as any).map((itemRow: SchemaItemRow) => { return itemRow.item; });\n }\n\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\n return SchemaParser.parse(schema, schemaInfos);\n }\n\n private async getFullSchemaMultipleQueries(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\n const schema = await this.getSchemaNoItems(schemaKey.name, context) as MutableSchemaProps;\n if (!schema)\n return undefined;\n\n const items = schema.items || (schema.items = {});\n await Promise.all([\n this.getEntities(schemaKey.name, context),\n this.getMixins(schemaKey.name, context),\n this.getStructs(schemaKey.name, context),\n this.getRelationships(schemaKey.name, context),\n this.getCustomAttributeClasses(schemaKey.name, context),\n this.getKindOfQuantities(schemaKey.name, context),\n this.getPropertyCategories(schemaKey.name, context),\n this.getEnumerations(schemaKey.name, context),\n this.getUnits(schemaKey.name, context),\n this.getInvertedUnits(schemaKey.name, context),\n this.getUnitSystems(schemaKey.name, context),\n this.getConstants(schemaKey.name, context),\n this.getPhenomenon(schemaKey.name, context),\n this.getFormats(schemaKey.name, context)\n ]).then((itemResults) => {\n const flatItemList = itemResults.reduce((acc, result) => acc.concat(result));\n flatItemList.forEach((schemaItem) => {\n if(!schemaItem.name) {\n // This should never be happen, as we query the schema items by name from the database, but since the SchemaProps\n // have name optional, we need the check here to make the compiler happy.\n throw new Error(`SchemaItem with no name encountered in schema ${schemaKey.name}`);\n }\n items[schemaItem.name] = schemaItem;\n });\n });\n\n return schema;\n }\n}\n\nfunction parseSchemaReference(referenceName: string): WithSchemaKey {\n return { schemaKey: SchemaKey.parseString(referenceName) };\n}\n\nasync function parseSchemaItemStubs(schemaName: string, itemRows: Array<SchemaItemStubRow>, addItemsHandler: AddSchemaItemHandler, schemaInfos: Iterable<SchemaInfo>) {\n if (!itemRows || itemRows.length === 0) {\n return;\n }\n\n const parseBaseClasses = async (baseClasses: Array<BaseClassStubRow> | undefined) => {\n if (!baseClasses || baseClasses.length < 2)\n return;\n\n for (let index = baseClasses.length - 1; index >= 0;) {\n const currentItem = baseClasses[index--];\n const baseClassItem = baseClasses[index];\n const baseClassName = baseClassItem ? `${baseClassItem.schema}.${baseClassItem.name}` : undefined;\n\n const schemaItem = await SchemaParser.parseItem(currentItem, currentItem.schema, schemaInfos);\n await addItemsHandler(currentItem.schema, {\n ...schemaItem,\n name: schemaItem.name,\n schemaItemType: schemaItem.schemaItemType,\n baseClass: baseClassName,\n });\n }\n };\n\n for (const itemRow of itemRows) {\n const schemaItem = await SchemaParser.parseItem(itemRow, schemaName, schemaInfos);\n await addItemsHandler(schemaName, {\n ...schemaItem,\n name: schemaItem.name,\n schemaItemType: schemaItem.schemaItemType,\n mixins: itemRow.mixins\n ? itemRow.mixins.map(mixin => { return `${mixin.schema}.${mixin.name}`; })\n : undefined,\n });\n\n await parseBaseClasses(itemRow.baseClasses);\n\n for (const mixinRow of itemRow.mixins || []) {\n const mixinItem = await SchemaParser.parseItem(mixinRow, mixinRow.schema, schemaInfos);\n await addItemsHandler(mixinRow.schema, {\n ...mixinItem,\n name: mixinItem.name,\n schemaItemType: mixinItem.schemaItemType,\n });\n await parseBaseClasses(mixinRow.baseClasses);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ECSqlSchemaLocater.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/ECSqlSchemaLocater.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAK7C,OAAO,EAAkB,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAwB,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA2DnD,MAAM,eAAe,GAAG,sCAAsC,CAAC;AAqB/D;;;;GAIG;AACH,MAAM,OAAgB,kBAAmB,SAAQ,wBAAwB;IACvE;;OAEG;IACH,IAAuB,OAAO;QAC5B,OAAO,KAAK,CAAC,OAAoC,CAAC;IACpD,CAAC;IAED;;;OAGG;IACH,YAAY,OAAmC;QAC7C,KAAK,CAAC,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AAM,IAAI,EAAE,EAAE,CAAC;YAC5C,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YACvF,MAAM,eAAe,CAAC,QAAQ,CAAC,MAAM,EAAE;gBACrC,GAAG,SAAS;gBACZ,IAAI,EAAE,SAAS,CAAC,IAAI;gBACpB,cAAc,EAAE,SAAS,CAAC,cAAc;aACzC,CAAC,CAAC;YACH,MAAM,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { SchemaContext } from \"../Context\";\r\nimport { ConstantProps, CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps, MixinProps,\r\n PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, SchemaItemFormatProps, SchemaItemProps, SchemaItemUnitProps, SchemaProps,\r\n StructClassProps, UnitSystemProps } from \"../Deserialization/JsonProps\";\r\nimport { SchemaItemType, SchemaMatchType } from \"../ECObjects\";\r\nimport { SchemaInfo, WithSchemaKey } from \"../Interfaces\";\r\nimport { SchemaKey } from \"../SchemaKey\";\r\nimport { FullSchemaQueries } from \"./FullSchemaQueries\";\r\nimport { IncrementalSchemaLocater, SchemaLocaterOptions } from \"./IncrementalSchemaLocater\";\r\nimport { SchemaItemQueries } from \"./SchemaItemQueries\";\r\nimport { SchemaParser } from \"./SchemaParser\";\r\nimport { ecsqlQueries } from \"./SchemaStubQueries\";\r\n\r\ninterface SchemaItemInfo {\r\n readonly name: string;\r\n readonly schemaItemType: SchemaItemType;\r\n}\r\n\r\ninterface SchemaInfoRow {\r\n readonly name: string;\r\n readonly version: string;\r\n readonly alias: string;\r\n readonly label: string;\r\n readonly description: string; \r\n readonly references: string;\r\n}\r\n\r\ninterface SchemaStubRow {\r\n readonly item: string;\r\n}\r\n\r\ninterface BaseClassStubRow {\r\n readonly schema: string;\r\n readonly name: string;\r\n readonly schemaItemType: string;\r\n readonly modifier: number;\r\n}\r\n\r\ninterface SchemaItemStubRow {\r\n readonly name: string;\r\n readonly schemaItemType: string;\r\n readonly modifier?: number;\r\n readonly baseClasses?: Array<BaseClassStubRow>;\r\n readonly mixins?: Array<{\r\n readonly schema: string,\r\n readonly name: string;\r\n readonly schemaItemType: string;\r\n readonly modifier: number;\r\n readonly baseClasses?: Array<BaseClassStubRow>\r\n }>;\r\n}\r\n\r\ninterface SchemaRow {\r\n schema: string\r\n}\r\n\r\ninterface SchemaItemRow {\r\n item: string | SchemaItemProps;\r\n}\r\n\r\ntype AddSchemaItemHandler = <T extends SchemaItemInfo>(schemaName: string, itemStub: T) => Promise<void>;\r\n\r\ntype MutableSchemaProps = {\r\n -readonly [K in keyof SchemaProps]: SchemaProps[K];\r\n};\r\n\r\ninterface QueryParameters {\r\n [parameterName: string]: string | number;\r\n}\r\n\r\nconst LOGGER_CATEGORY = \"IncrementalSchemaLoading.Performance\";\r\n\r\n/**\r\n * Query options used by the ECSqlSchemaLocater.\r\n * @internal\r\n */\r\nexport interface ECSqlQueryOptions {\r\n parameters?: QueryParameters;\r\n limit?: number;\r\n}\r\n\r\n/**\r\n * Defines the [[ECSqlSchemaLocater]] options which determine how each\r\n * schema is to be loaded. All options are optional.\r\n * @internal\r\n */\r\nexport interface ECSqlSchemaLocaterOptions extends SchemaLocaterOptions {\r\n /** Query for Schemas using multiple queries. Defaults to false. */\r\n readonly useMultipleQueries?: boolean;\r\n}\r\n\r\n/**\r\n * An abstract [[IncrementalSchemaLocater]] implementation for loading\r\n * EC [Schema] instances from an iModelDb using ECSql queries.\r\n * @internal\r\n */\r\nexport abstract class ECSqlSchemaLocater extends IncrementalSchemaLocater {\r\n /**\r\n * Gets the [[ECSqlSchemaLocaterOptions]] used by this locater.\r\n */\r\n protected override get options(): ECSqlSchemaLocaterOptions {\r\n return super.options as ECSqlSchemaLocaterOptions;\r\n }\r\n\r\n /**\r\n * Initializes a new ECSqlSchemaLocater instance.\r\n * @param options The options used by this Schema locater.\r\n */\r\n constructor(options?: ECSqlSchemaLocaterOptions) {\r\n super(options);\r\n }\r\n\r\n /**\r\n * Executes the given ECSql query and returns the resulting rows.\r\n * @param query The ECSql query to execute.\r\n * @param options Optional arguments to control the query result.\r\n * @returns A promise that resolves to the resulting rows.\r\n */\r\n protected abstract executeQuery<TRow>(query: string, options?: ECSqlQueryOptions): Promise<ReadonlyArray<TRow>>;\r\n\r\n /**\r\n * Gets the [[SchemaProps]] for the given schema key.\r\n * @param schemaKey The schema key of the schema to be resolved.\r\n */\r\n protected abstract getSchemaProps(schemaKey: SchemaKey): Promise<SchemaProps | undefined>\r\n\r\n /**\r\n * Gets the [[SchemaProps]] for the given schema key. This is the full schema json with all elements that are defined\r\n * in the schema. The schema locater calls this after the stub has been loaded to fully load the schema in the background.\r\n * @param schemaKey The [[SchemaKey]] of the schema to be resolved.\r\n * @param context The [[SchemaContext]] to use for resolving references.\r\n * @internal\r\n */\r\n protected async getSchemaJson(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\r\n // If the meta schema is an earlier version than 4.0.3, we can't use the ECSql query interface to get the schema\r\n // information required to load the schema entirely. In this case, we fallback to use the ECSchema RPC interface\r\n // to fetch the whole schema json.\r\n if (!await this.supportPartialSchemaLoading(context))\r\n return this.getSchemaProps(schemaKey);\r\n\r\n const queryStart = Date.now();\r\n const schemaProps = this.options.useMultipleQueries\r\n ? await this.getFullSchemaMultipleQueries(schemaKey, context)\r\n : await this.getFullSchema(schemaKey, context);\r\n\r\n const queryDuration = Date.now() - queryStart;\r\n Logger.logTrace(LOGGER_CATEGORY, `Recieved SchemaProps for ${schemaKey.name} in ${queryDuration}ms`, {\r\n schemaName: schemaKey.name,\r\n queryMode: this.options.useMultipleQueries ? \"parallel\" : \"single\",\r\n duration: queryDuration,\r\n });\r\n\r\n return schemaProps;\r\n };\r\n\r\n /**\r\n * Gets the [[SchemaProps]] without schemaItems for the given schema name.\r\n * @param schemaName The name of the Schema.\r\n * @param context The [[SchemaContext]] to use for resolving references.\r\n * @returns\r\n * @internal\r\n */\r\n private async getSchemaNoItems(schemaName: string, context: SchemaContext): Promise<SchemaProps | undefined> {\r\n const schemaRows = await this.executeQuery<SchemaRow>(FullSchemaQueries.schemaNoItemsQuery, { parameters: { schemaName } });\r\n const schemaRow = schemaRows[0];\r\n if (schemaRow === undefined)\r\n return undefined;\r\n\r\n const schema = JSON.parse(schemaRow.schema) as SchemaProps;\r\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\r\n return SchemaParser.parse(schema, schemaInfos);\r\n }\r\n\r\n /**\r\n * Checks if the [[SchemaContext]] has the right Meta Schema version to support the incremental schema loading.\r\n * @param context The schema context to lookup the meta schema.\r\n * @returns true if the context has a supported meta schema version, false otherwise.\r\n */\r\n protected async supportPartialSchemaLoading(context: SchemaContext): Promise<boolean> {\r\n const metaSchemaKey = new SchemaKey(\"ECDbMeta\", 4, 0, 3);\r\n const metaSchemaInfo = await context.getSchemaInfo(metaSchemaKey, SchemaMatchType.LatestWriteCompatible);\r\n return metaSchemaInfo !== undefined;\r\n };\r\n\r\n /**\r\n * Gets all the Schema's Entity classes as [[EntityClassProps]] JSON objects.\r\n * @param schemaName The name of the Schema.\r\n * @param context The [[SchemaContext]] to which the schema belongs.\r\n * @returns A promise that resolves to a EntityClassProps array. Maybe empty of no entities are found.\r\n * @internal\r\n */\r\n protected async getEntities(schema: string, context: SchemaContext, queryOverride?: string): Promise<EntityClassProps[]> {\r\n const query = queryOverride ?? FullSchemaQueries.entityQuery;\r\n return this.querySchemaItem<EntityClassProps>(context, schema, query, \"EntityClass\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's Mixin classes as [[MixinProps]] JSON objects.\r\n * @param schemaName The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a MixinProps array. Maybe empty of no entities are found.\r\n * @internal\r\n */\r\n protected async getMixins(schema: string, context: SchemaContext, queryOverride?: string): Promise<MixinProps[]> {\r\n const query = queryOverride ?? FullSchemaQueries.mixinQuery;\r\n return this.querySchemaItem<MixinProps>(context, schema, query, \"Mixin\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's Relationship classes as [[RelationshipClassProps]] JSON objects.\r\n * @param schemaName The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a RelationshipClassProps array. Maybe empty if no items are found.\r\n * @internal\r\n */\r\n protected async getRelationships(schema: string, context: SchemaContext, queryOverride?: string): Promise<RelationshipClassProps[]> {\r\n const query = queryOverride ?? FullSchemaQueries.relationshipClassQuery;\r\n return this.querySchemaItem<RelationshipClassProps>(context, schema, query, \"RelationshipClass\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's CustomAttributeClass items as [[CustomAttributeClassProps]] JSON objects.\r\n * @param schemaName The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a CustomAttributeClassProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getCustomAttributeClasses(schema: string, context: SchemaContext, queryOverride?: string): Promise<CustomAttributeClassProps[]> {\r\n const query = queryOverride ?? FullSchemaQueries.customAttributeQuery;\r\n return this.querySchemaItem<CustomAttributeClassProps>(context, schema, query, \"CustomAttributeClass\");\r\n }\r\n\r\n\r\n /**\r\n * Gets all the Schema's StructClass items as [[StructClassProps]] JSON objects.\r\n * @param schemaName The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a StructClassProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getStructs(schema: string, context: SchemaContext, queryOverride?: string): Promise<StructClassProps[]> {\r\n const query = queryOverride ?? FullSchemaQueries.structQuery;\r\n return this.querySchemaItem<StructClassProps>(context, schema, query, \"StructClass\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's KindOfQuantity items as [[KindOfQuantityProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a KindOfQuantityProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getKindOfQuantities(schema: string, context: SchemaContext): Promise<KindOfQuantityProps[]> {\r\n return this.querySchemaItem<KindOfQuantityProps>(context, schema, SchemaItemQueries.kindOfQuantity(true), \"KindOfQuantity\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's PropertyCategory items as [[PropertyCategoryProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a PropertyCategoryProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getPropertyCategories(schema: string, context: SchemaContext): Promise<PropertyCategoryProps[]> {\r\n return this.querySchemaItem<PropertyCategoryProps>(context, schema, SchemaItemQueries.propertyCategory(true), \"PropertyCategory\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's Enumeration items as [[EnumerationProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a EnumerationProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getEnumerations(schema: string, context: SchemaContext): Promise<EnumerationProps[]> {\r\n return this.querySchemaItem<EnumerationProps>(context, schema, SchemaItemQueries.enumeration(true), \"Enumeration\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's Unit items as [[SchemaItemUnitProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a SchemaItemUnitProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getUnits(schema: string, context: SchemaContext): Promise<SchemaItemUnitProps[]> {\r\n return this.querySchemaItem<SchemaItemUnitProps>(context, schema, SchemaItemQueries.unit(true), \"Unit\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's InvertedUnit items as [[InvertedUnitProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a InvertedUnitProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getInvertedUnits(schema: string, context: SchemaContext): Promise<InvertedUnitProps[]> {\r\n return this.querySchemaItem<InvertedUnitProps>(context, schema, SchemaItemQueries.invertedUnit(true), \"InvertedUnit\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's Constant items as [[ConstantProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a ConstantProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getConstants(schema: string, context: SchemaContext): Promise<ConstantProps[]> {\r\n return this.querySchemaItem<ConstantProps>(context, schema, SchemaItemQueries.constant(true), \"Constant\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's UnitSystem items as [[UnitSystemProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a UnitSystemProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getUnitSystems(schema: string, context: SchemaContext): Promise<UnitSystemProps[]> {\r\n return this.querySchemaItem<UnitSystemProps>(context, schema, SchemaItemQueries.unitSystem(true), \"UnitSystem\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's Phenomenon items as [[PhenomenonProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a PhenomenonProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getPhenomenon(schema: string, context: SchemaContext): Promise<PhenomenonProps[]> {\r\n return this.querySchemaItem<PhenomenonProps>(context, schema, SchemaItemQueries.phenomenon(true), \"Phenomenon\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's Format items as [[SchemaItemFormatProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a SchemaItemFormatProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getFormats(schema: string, context: SchemaContext): Promise<SchemaItemFormatProps[]> {\r\n return this.querySchemaItem<SchemaItemFormatProps>(context, schema, SchemaItemQueries.format(true), \"Format\");\r\n }\r\n\r\n /**\r\n * Gets [[SchemaInfo]] objects for all schemas including their direct schema references.\r\n * @internal\r\n */\r\n protected async loadSchemaInfos(): Promise<ReadonlyArray<SchemaInfo>> {\r\n const schemaRows = await this.executeQuery<SchemaInfoRow>(ecsqlQueries.schemaInfoQuery);\r\n return schemaRows.map((schemaRow) => (\r\n {\r\n alias: schemaRow.alias,\r\n description: schemaRow.description,\r\n label: schemaRow.label,\r\n schemaKey: SchemaKey.parseString(`${schemaRow.name}.${schemaRow.version}`),\r\n references: Array.from(JSON.parse(schemaRow.references), parseSchemaReference),\r\n }\r\n ));\r\n }\r\n\r\n /**\r\n * Gets the [[SchemaProps]] to create the basic schema skeleton. Depending on which options are set, the schema items or class hierarchy\r\n * can be included in the initial fetch.\r\n * @param schemaKey The [[SchemaKey]] of the schema to be resolved.\r\n * @returns A promise that resolves to the schema partials, which is an array of [[SchemaProps]].\r\n * @internal\r\n */\r\n protected async getSchemaPartials(schemaKey: SchemaKey, context: SchemaContext): Promise<ReadonlyArray<SchemaProps> | undefined> {\r\n const queryStart = Date.now();\r\n const itemRows = await this.executeQuery<SchemaStubRow>(ecsqlQueries.schemaStubQuery, {\r\n parameters: { schemaName: schemaKey.name }\r\n });\r\n\r\n const queryDuration = Date.now() - queryStart;\r\n Logger.logTrace(LOGGER_CATEGORY, `Recieved PartialSchema for ${schemaKey.name} in ${queryDuration}ms`, {\r\n schemaName: schemaKey.name,\r\n itemCount: itemRows.length,\r\n duration: queryDuration,\r\n });\r\n\r\n if (itemRows.length === 0)\r\n return undefined;\r\n\r\n const schemaPartials: Array<SchemaProps> = [];\r\n const addSchema = async (key: SchemaKey) => {\r\n const stub = await this.createSchemaProps(key, context);\r\n schemaPartials.push(stub);\r\n\r\n if (stub.references) {\r\n for (const referenceProps of stub.references) {\r\n if (!schemaPartials.some((schema) => schema.name === referenceProps.name)) {\r\n await addSchema(SchemaKey.parseString(`${referenceProps.name}.${referenceProps.version}`));\r\n }\r\n }\r\n }\r\n\r\n return stub;\r\n };\r\n\r\n const addItems = async (schemaName: string, itemInfo: SchemaItemInfo) => {\r\n let schemaStub = schemaPartials.find((schema) => schema.name === schemaName);\r\n if (!schemaStub) {\r\n schemaStub = await addSchema(SchemaKey.parseString(`${schemaName}.0.0.0`));\r\n }\r\n\r\n let items = schemaStub.items;\r\n if (!items) {\r\n Object.assign(schemaStub, items = { items: {} });\r\n }\r\n\r\n const existingItem = items[itemInfo.name] || {};\r\n Object.assign(items, { [itemInfo.name]: Object.assign(existingItem, itemInfo) });\r\n };\r\n\r\n const reviver = (_key: string, value: any) => {\r\n return value === null ? undefined : value;\r\n };\r\n\r\n await addSchema(schemaKey);\r\n\r\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\r\n const stubItems = itemRows.map((itemRow) => {\r\n return JSON.parse(itemRow.item, reviver) as SchemaItemStubRow;\r\n });\r\n await parseSchemaItemStubs(schemaKey.name, stubItems, addItems, schemaInfos);\r\n\r\n return schemaPartials;\r\n }\r\n\r\n private async querySchemaItem<TRow extends SchemaItemProps>(context: SchemaContext, schemaName: string, query: string, schemaType: string): Promise<Array<TRow>> {\r\n const start = Date.now();\r\n const itemRows = await this.executeQuery<SchemaItemRow>(query, { parameters: { schemaName } });\r\n\r\n const queryDuration = Date.now() - start;\r\n Logger.logTrace(LOGGER_CATEGORY, `Recieved rows of ${schemaType} items for ${schemaName} in ${queryDuration}ms`, {\r\n schemaName,\r\n itemCount: itemRows.length,\r\n itemType: schemaType,\r\n duration: queryDuration,\r\n });\r\n\r\n if (itemRows.length === 0)\r\n return [];\r\n\r\n const items = itemRows.map((itemRow: SchemaItemRow) => {\r\n return \"string\" === typeof itemRow.item ? JSON.parse(itemRow.item) : itemRow.item;\r\n });\r\n\r\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\r\n return await SchemaParser.parseSchemaItems(items, schemaName, schemaInfos) as Array<TRow> ?? []\r\n }\r\n\r\n private async getFullSchema(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\r\n const schemaRows = await this.executeQuery<SchemaRow>(FullSchemaQueries.schemaQuery, { parameters: { schemaName: schemaKey.name } });\r\n const schemaRow = schemaRows[0];\r\n if (schemaRow === undefined)\r\n return undefined;\r\n\r\n // Map SchemaItemRow array, [{item: SchemaItemProps}], to array of SchemaItemProps.\r\n const schema = JSON.parse(schemaRow.schema) as SchemaProps;\r\n if (schema.items) {\r\n (schema as any).items = (schema.items as any).map((itemRow: SchemaItemRow) => { return itemRow.item; });\r\n }\r\n\r\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\r\n return SchemaParser.parse(schema, schemaInfos);\r\n }\r\n\r\n private async getFullSchemaMultipleQueries(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\r\n const schema = await this.getSchemaNoItems(schemaKey.name, context) as MutableSchemaProps;\r\n if (!schema)\r\n return undefined;\r\n\r\n const items = schema.items || (schema.items = {});\r\n await Promise.all([\r\n this.getEntities(schemaKey.name, context),\r\n this.getMixins(schemaKey.name, context),\r\n this.getStructs(schemaKey.name, context),\r\n this.getRelationships(schemaKey.name, context),\r\n this.getCustomAttributeClasses(schemaKey.name, context),\r\n this.getKindOfQuantities(schemaKey.name, context),\r\n this.getPropertyCategories(schemaKey.name, context),\r\n this.getEnumerations(schemaKey.name, context),\r\n this.getUnits(schemaKey.name, context),\r\n this.getInvertedUnits(schemaKey.name, context),\r\n this.getUnitSystems(schemaKey.name, context),\r\n this.getConstants(schemaKey.name, context),\r\n this.getPhenomenon(schemaKey.name, context),\r\n this.getFormats(schemaKey.name, context)\r\n ]).then((itemResults) => {\r\n const flatItemList = itemResults.reduce((acc, result) => acc.concat(result));\r\n flatItemList.forEach((schemaItem) => {\r\n if(!schemaItem.name) {\r\n // This should never be happen, as we query the schema items by name from the database, but since the SchemaProps\r\n // have name optional, we need the check here to make the compiler happy.\r\n throw new Error(`SchemaItem with no name encountered in schema ${schemaKey.name}`);\r\n }\r\n items[schemaItem.name] = schemaItem;\r\n });\r\n });\r\n\r\n return schema;\r\n }\r\n}\r\n\r\nfunction parseSchemaReference(referenceName: string): WithSchemaKey {\r\n return { schemaKey: SchemaKey.parseString(referenceName) };\r\n}\r\n\r\nasync function parseSchemaItemStubs(schemaName: string, itemRows: Array<SchemaItemStubRow>, addItemsHandler: AddSchemaItemHandler, schemaInfos: Iterable<SchemaInfo>) {\r\n if (!itemRows || itemRows.length === 0) {\r\n return;\r\n }\r\n\r\n const parseBaseClasses = async (baseClasses: Array<BaseClassStubRow> | undefined) => {\r\n if (!baseClasses || baseClasses.length < 2)\r\n return;\r\n\r\n for (let index = baseClasses.length - 1; index >= 0;) {\r\n const currentItem = baseClasses[index--];\r\n const baseClassItem = baseClasses[index];\r\n const baseClassName = baseClassItem ? `${baseClassItem.schema}.${baseClassItem.name}` : undefined;\r\n\r\n const schemaItem = await SchemaParser.parseItem(currentItem, currentItem.schema, schemaInfos);\r\n await addItemsHandler(currentItem.schema, {\r\n ...schemaItem,\r\n name: schemaItem.name,\r\n schemaItemType: schemaItem.schemaItemType,\r\n baseClass: baseClassName,\r\n });\r\n }\r\n };\r\n\r\n for (const itemRow of itemRows) {\r\n const schemaItem = await SchemaParser.parseItem(itemRow, schemaName, schemaInfos);\r\n await addItemsHandler(schemaName, {\r\n ...schemaItem,\r\n name: schemaItem.name,\r\n schemaItemType: schemaItem.schemaItemType,\r\n mixins: itemRow.mixins\r\n ? itemRow.mixins.map(mixin => { return `${mixin.schema}.${mixin.name}`; })\r\n : undefined,\r\n });\r\n\r\n await parseBaseClasses(itemRow.baseClasses);\r\n\r\n for (const mixinRow of itemRow.mixins || []) {\r\n const mixinItem = await SchemaParser.parseItem(mixinRow, mixinRow.schema, schemaInfos);\r\n await addItemsHandler(mixinRow.schema, {\r\n ...mixinItem,\r\n name: mixinItem.name,\r\n schemaItemType: mixinItem.schemaItemType,\r\n });\r\n await parseBaseClasses(mixinRow.baseClasses);\r\n }\r\n }\r\n}\r\n"]}
|