@itwin/presentation-common 5.1.0-dev.5 → 5.1.0-dev.52
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 +84 -1
- package/Ruleset.schema.json +3 -3
- package/lib/cjs/presentation-common/AsyncTasks.js.map +1 -1
- package/lib/cjs/presentation-common/EC.d.ts.map +1 -1
- package/lib/cjs/presentation-common/EC.js +9 -2
- package/lib/cjs/presentation-common/EC.js.map +1 -1
- package/lib/cjs/presentation-common/Error.d.ts +1 -1
- package/lib/cjs/presentation-common/Error.js +1 -1
- package/lib/cjs/presentation-common/Error.js.map +1 -1
- package/lib/cjs/presentation-common/KoqPropertyValueFormatter.d.ts +24 -2
- package/lib/cjs/presentation-common/KoqPropertyValueFormatter.d.ts.map +1 -1
- package/lib/cjs/presentation-common/KoqPropertyValueFormatter.js +97 -104
- package/lib/cjs/presentation-common/KoqPropertyValueFormatter.js.map +1 -1
- package/lib/cjs/presentation-common/PresentationManagerOptions.d.ts +3 -3
- package/lib/cjs/presentation-common/PresentationManagerOptions.js.map +1 -1
- package/lib/cjs/presentation-common/PresentationRpcInterface.d.ts +19 -19
- package/lib/cjs/presentation-common/PresentationRpcInterface.d.ts.map +1 -1
- package/lib/cjs/presentation-common/PresentationRpcInterface.js +17 -17
- package/lib/cjs/presentation-common/PresentationRpcInterface.js.map +1 -1
- package/lib/cjs/presentation-common/RegisteredRuleset.d.ts +1 -1
- package/lib/cjs/presentation-common/RegisteredRuleset.d.ts.map +1 -1
- package/lib/cjs/presentation-common/RegisteredRuleset.js +1 -1
- package/lib/cjs/presentation-common/RegisteredRuleset.js.map +1 -1
- package/lib/cjs/presentation-common/content/Fields.d.ts +14 -14
- package/lib/cjs/presentation-common/content/Fields.js +9 -9
- package/lib/cjs/presentation-common/content/Fields.js.map +1 -1
- package/lib/cjs/presentation-common/content/Item.d.ts +2 -2
- package/lib/cjs/presentation-common/content/Item.d.ts.map +1 -1
- package/lib/cjs/presentation-common/content/Item.js.map +1 -1
- package/lib/cjs/presentation-common/content/Value.d.ts +1 -1
- package/lib/cjs/presentation-common/content/Value.js.map +1 -1
- package/lib/cjs/presentation-common/hierarchy/Node.d.ts +1 -1
- package/lib/cjs/presentation-common/hierarchy/Node.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/GroupingRule.d.ts +2 -2
- package/lib/cjs/presentation-common/rules/customization/GroupingRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/CustomNodeSpecification.d.ts +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/CustomNodeSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/selection/SelectionScope.d.ts +3 -3
- package/lib/cjs/presentation-common/selection/SelectionScope.js.map +1 -1
- package/lib/esm/presentation-common/AsyncTasks.js.map +1 -1
- package/lib/esm/presentation-common/EC.d.ts.map +1 -1
- package/lib/esm/presentation-common/EC.js +9 -2
- package/lib/esm/presentation-common/EC.js.map +1 -1
- package/lib/esm/presentation-common/Error.d.ts +1 -1
- package/lib/esm/presentation-common/Error.js +1 -1
- package/lib/esm/presentation-common/Error.js.map +1 -1
- package/lib/esm/presentation-common/KoqPropertyValueFormatter.d.ts +24 -2
- package/lib/esm/presentation-common/KoqPropertyValueFormatter.d.ts.map +1 -1
- package/lib/esm/presentation-common/KoqPropertyValueFormatter.js +97 -104
- package/lib/esm/presentation-common/KoqPropertyValueFormatter.js.map +1 -1
- package/lib/esm/presentation-common/PresentationManagerOptions.d.ts +3 -3
- package/lib/esm/presentation-common/PresentationManagerOptions.js.map +1 -1
- package/lib/esm/presentation-common/PresentationRpcInterface.d.ts +19 -19
- package/lib/esm/presentation-common/PresentationRpcInterface.d.ts.map +1 -1
- package/lib/esm/presentation-common/PresentationRpcInterface.js +17 -17
- package/lib/esm/presentation-common/PresentationRpcInterface.js.map +1 -1
- package/lib/esm/presentation-common/RegisteredRuleset.d.ts +1 -1
- package/lib/esm/presentation-common/RegisteredRuleset.d.ts.map +1 -1
- package/lib/esm/presentation-common/RegisteredRuleset.js +1 -1
- package/lib/esm/presentation-common/RegisteredRuleset.js.map +1 -1
- package/lib/esm/presentation-common/content/Fields.d.ts +14 -14
- package/lib/esm/presentation-common/content/Fields.js +9 -9
- package/lib/esm/presentation-common/content/Fields.js.map +1 -1
- package/lib/esm/presentation-common/content/Item.d.ts +2 -2
- package/lib/esm/presentation-common/content/Item.d.ts.map +1 -1
- package/lib/esm/presentation-common/content/Item.js.map +1 -1
- package/lib/esm/presentation-common/content/Value.d.ts +1 -1
- package/lib/esm/presentation-common/content/Value.js.map +1 -1
- package/lib/esm/presentation-common/hierarchy/Node.d.ts +1 -1
- package/lib/esm/presentation-common/hierarchy/Node.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/GroupingRule.d.ts +2 -2
- package/lib/esm/presentation-common/rules/customization/GroupingRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/CustomNodeSpecification.d.ts +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/CustomNodeSpecification.js.map +1 -1
- package/lib/esm/presentation-common/selection/SelectionScope.d.ts +3 -3
- package/lib/esm/presentation-common/selection/SelectionScope.js.map +1 -1
- package/package.json +16 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EC.d.ts","sourceRoot":"","sources":["../../../src/presentation-common/EC.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"EC.d.ts","sourceRoot":"","sources":["../../../src/presentation-common/EC.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;;GAGG;AACH,M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GAIG;AACH,MAAM,MAAM,wBAAwB,GAAG,wBAAwB,EAAE,CAAC"}
|
|
@@ -6,16 +6,23 @@
|
|
|
6
6
|
* @module Core
|
|
7
7
|
*/
|
|
8
8
|
import { assert } from "@itwin/core-bentley";
|
|
9
|
+
import { parseFullClassName } from "@itwin/presentation-shared";
|
|
9
10
|
/** @public */
|
|
10
11
|
export var InstanceKey;
|
|
11
12
|
(function (InstanceKey) {
|
|
12
13
|
/** Compare 2 instance keys */
|
|
13
14
|
function compare(lhs, rhs) {
|
|
14
|
-
const
|
|
15
|
+
const lhsClass = parseFullClassName(lhs.className);
|
|
16
|
+
const rhsClass = parseFullClassName(rhs.className);
|
|
17
|
+
const schemaNameCompare = lhsClass.schemaName.toLowerCase().localeCompare(rhsClass.schemaName.toLowerCase());
|
|
18
|
+
if (schemaNameCompare !== 0) {
|
|
19
|
+
return schemaNameCompare;
|
|
20
|
+
}
|
|
21
|
+
const classNameCompare = lhsClass.className.toLowerCase().localeCompare(rhsClass.className.toLowerCase());
|
|
15
22
|
if (classNameCompare !== 0) {
|
|
16
23
|
return classNameCompare;
|
|
17
24
|
}
|
|
18
|
-
return lhs.id.localeCompare(rhs.id);
|
|
25
|
+
return lhs.id.toLowerCase().localeCompare(rhs.id.toLowerCase());
|
|
19
26
|
}
|
|
20
27
|
InstanceKey.compare = compare;
|
|
21
28
|
})(InstanceKey || (InstanceKey = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EC.js","sourceRoot":"","sources":["../../../src/presentation-common/EC.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAc,MAAM,qBAAqB,CAAC;AA2BzD,cAAc;AACd,MAAM,KAAW,WAAW,CAS3B;AATD,WAAiB,WAAW;IAC1B,8BAA8B;IAC9B,SAAgB,OAAO,CAAC,GAAgB,EAAE,GAAgB;QACxD,MAAM,gBAAgB,GAAG,GAAG,CAAC,SAAS,CAAC,aAAa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,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1G,CAAC;IAFe,uBAAM,SAErB,CAAA;IAED,uEAAuE;IACvE,SAAgB,KAAK,CAAC,IAAsB;QAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IAFe,sBAAK,QAEpB,CAAA;AACH,CAAC,EApBgB,gBAAgB,KAAhB,gBAAgB,QAoBhC","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 Core\n */\n\nimport { assert, Id64String } from \"@itwin/core-bentley\";\nimport { FormatProps } from \"@itwin/core-quantity\";\nimport { PartialBy } from \"./Utils.js\";\n\n/**\n * Type of an ECClass ID.\n * @public\n */\nexport type ClassId = Id64String;\n\n/**\n * Type of an ECInstance ID.\n * @public\n */\nexport type InstanceId = Id64String;\n\n/**\n * A key that uniquely identifies an instance in an iModel\n * @public\n */\nexport interface InstanceKey {\n /** Full class name in format `SchemaName:ClassName` */\n className: string;\n /** ECInstance ID */\n id: InstanceId;\n}\n\n/** @public */\nexport namespace InstanceKey {\n /** Compare 2 instance keys */\n export function compare(lhs: InstanceKey, rhs: InstanceKey): number {\n const classNameCompare = lhs.className.localeCompare(rhs.className);\n if (classNameCompare !== 0) {\n return classNameCompare;\n }\n return lhs.id.localeCompare(rhs.id);\n }\n}\n\n/**\n * Information about an ECClass\n * @public\n */\nexport interface ClassInfo {\n /** ECClass ID */\n id: ClassId;\n /** Full class name in format `SchemaName:ClassName` */\n name: string;\n /** ECClass label */\n label: string;\n}\n\n/**\n * A serialized and compressed version of [[ClassInfo]]\n * @public\n */\nexport interface CompressedClassInfoJSON {\n name: string;\n label: string;\n}\n\n/**\n * A single choice in enumeration\n * @public\n */\nexport interface EnumerationChoice {\n /** Label of the choice */\n label: string;\n /** Value of the choice */\n value: string | number;\n}\n\n/**\n * Enumeration information\n * @public\n */\nexport interface EnumerationInfo {\n /** Available enumeration choices */\n choices: EnumerationChoice[];\n /** Is the enumeration strict (values only allowed from `choices` list) */\n isStrict: boolean;\n}\n\n/**\n * Kind of quantity information\n * @public\n */\nexport interface KindOfQuantityInfo {\n /** Full name of KindOfQuantity in format `SchemaName:KindOfQuantityName` */\n name: string;\n /** Label of KindOfQuantity */\n label: string;\n /** Persistence unit full class name in format `SchemaName:UnitName`. */\n persistenceUnit: string;\n /** Active format that was used to format property value. */\n activeFormat?: FormatProps;\n}\n\n/**\n * A data structure for storing navigation property information.\n * @public\n */\nexport interface NavigationPropertyInfo {\n /** Information about ECProperty's relationship class */\n classInfo: ClassInfo;\n /** Is the direction of the relationship forward */\n isForwardRelationship: boolean;\n /** Information about ECProperty's target class */\n targetClassInfo: ClassInfo;\n /** Is ECProperty's target class polymorphic */\n isTargetPolymorphic: boolean;\n}\n\n/**\n * Contains utilities for working with objects of [[NavigationPropertyInfo]] type.\n * @public\n */\nexport namespace NavigationPropertyInfo {\n /** Serialize [[NavigationPropertyInfo]] to compressed JSON */\n export function toCompressedJSON(\n navigationPropertyInfo: NavigationPropertyInfo,\n classesMap: { [id: string]: CompressedClassInfoJSON },\n ): NavigationPropertyInfoJSON<string> {\n const { id: relationshipId, ...relationshipLeftOverInfo } = navigationPropertyInfo.classInfo;\n const { id: targetId, ...targetLeftOverInfo } = navigationPropertyInfo.targetClassInfo;\n classesMap[relationshipId] = relationshipLeftOverInfo;\n classesMap[targetId] = targetLeftOverInfo;\n\n return {\n ...navigationPropertyInfo,\n classInfo: relationshipId,\n targetClassInfo: targetId,\n };\n }\n\n /** Deserialize [[NavigationPropertyInfo]] from compressed JSON */\n export function fromCompressedJSON(\n compressedNavigationPropertyInfoJSON: NavigationPropertyInfoJSON<string>,\n classesMap: { [id: string]: CompressedClassInfoJSON },\n ): NavigationPropertyInfo {\n return {\n ...compressedNavigationPropertyInfoJSON,\n classInfo: { id: compressedNavigationPropertyInfoJSON.classInfo, ...classesMap[compressedNavigationPropertyInfoJSON.classInfo] },\n targetClassInfo: { id: compressedNavigationPropertyInfoJSON.targetClassInfo, ...classesMap[compressedNavigationPropertyInfoJSON.targetClassInfo] },\n };\n }\n}\n\n/**\n * A serialized version of [[NavigationPropertyInfo]]\n * @public\n */\nexport interface NavigationPropertyInfoJSON<TClassInfoJSON = ClassInfo> {\n classInfo: TClassInfoJSON;\n isForwardRelationship: boolean;\n targetClassInfo: TClassInfoJSON;\n isTargetPolymorphic: boolean;\n}\n\n/**\n * A structure that describes an ECProperty\n * @public\n */\nexport interface PropertyInfo {\n /** Information about ECProperty class */\n classInfo: ClassInfo;\n /** Name of the ECProperty */\n name: string;\n /** Type name of the ECProperty */\n type: string;\n /** Enumeration info if the property is enumerable */\n enumerationInfo?: EnumerationInfo;\n /** Kind of quantity information, if any. */\n kindOfQuantity?: KindOfQuantityInfo;\n /** Extended type name of the ECProperty if it has one */\n extendedType?: string;\n /** Navigation property info if the field is navigation type */\n navigationPropertyInfo?: NavigationPropertyInfo;\n /** Constraints for values of ECProperty */\n constraints?: PropertyValueConstraints;\n}\n\n/**\n * Constraints for values of ECProperty\n * @public\n */\nexport type PropertyValueConstraints = StringPropertyValueConstraints | ArrayPropertyValueConstraints | NumericPropertyValueConstraints;\n\n/**\n * Describes constraints for `string` type ECProperty values\n * @public\n */\nexport interface StringPropertyValueConstraints {\n minimumLength?: number;\n maximumLength?: number;\n}\n\n/**\n * Describes constraints for `int` | `double` | `float` type ECProperty values\n * @public\n */\nexport interface NumericPropertyValueConstraints {\n minimumValue?: number;\n maximumValue?: number;\n}\n\n/**\n * Describes constraints for `array` type ECProperty values\n * @public\n */\nexport interface ArrayPropertyValueConstraints {\n minOccurs?: number;\n maxOccurs?: number;\n}\n\n/** @public */\nexport namespace PropertyInfo {\n /** Serialize [[PropertyInfo]] to compressed JSON */\n export function toCompressedJSON(propertyInfo: PropertyInfo, classesMap: { [id: string]: CompressedClassInfoJSON }): PropertyInfoJSON<string> {\n const { navigationPropertyInfo, ...leftOverPropertyInfo } = propertyInfo;\n const { id, ...leftOverInfo } = propertyInfo.classInfo;\n classesMap[id] = leftOverInfo;\n\n return {\n ...leftOverPropertyInfo,\n classInfo: propertyInfo.classInfo.id,\n ...(navigationPropertyInfo ? { navigationPropertyInfo: NavigationPropertyInfo.toCompressedJSON(navigationPropertyInfo, classesMap) } : undefined),\n };\n }\n}\n\n/**\n * A serialized version of [[PropertyInfo]]\n * @public\n */\nexport interface PropertyInfoJSON<TClassInfoJSON = ClassInfo> {\n classInfo: TClassInfoJSON;\n name: string;\n type: string;\n enumerationInfo?: EnumerationInfo;\n kindOfQuantity?: KindOfQuantityInfo;\n navigationPropertyInfo?: NavigationPropertyInfoJSON<TClassInfoJSON>;\n}\n\n/**\n * A structure that describes a related class and the properties of that relationship.\n * @public\n */\nexport interface RelatedClassInfo {\n /** Information about the source ECClass */\n sourceClassInfo: ClassInfo;\n\n /** Information about the target ECClass */\n targetClassInfo: ClassInfo;\n\n /** Is target class handled polymorphically */\n isPolymorphicTargetClass?: boolean;\n\n /** Optionally, IDs of specific target class instances. */\n targetInstanceIds?: Id64String[];\n\n /** Information about the ECRelationship */\n relationshipInfo: ClassInfo;\n\n /** Should relationship be followed in a forward direction to access the related class. */\n isForwardRelationship: boolean;\n\n /** Is relationship handled polymorphically */\n isPolymorphicRelationship?: boolean;\n}\n\n/** @public */\nexport namespace RelatedClassInfo {\n /** Serialize [[RelatedClassInfo]] to compressed JSON */\n export function toCompressedJSON(classInfo: RelatedClassInfo, classesMap: { [id: string]: CompressedClassInfoJSON }): RelatedClassInfoJSON<string> {\n const { id: sourceId, ...sourceLeftOverInfo } = classInfo.sourceClassInfo;\n const { id: targetId, ...targetLeftOverInfo } = classInfo.targetClassInfo;\n const { id: relationshipId, ...relationshipLeftOverInfo } = classInfo.relationshipInfo;\n\n classesMap[sourceId] = sourceLeftOverInfo;\n classesMap[targetId] = targetLeftOverInfo;\n classesMap[relationshipId] = relationshipLeftOverInfo;\n\n return {\n ...classInfo,\n sourceClassInfo: sourceId,\n targetClassInfo: targetId,\n relationshipInfo: relationshipId,\n };\n }\n\n /** Deserialize [[RelatedClassInfo]] from compressed JSON */\n export function fromCompressedJSON(json: RelatedClassInfoJSON<string>, classesMap: { [id: string]: CompressedClassInfoJSON }): RelatedClassInfo {\n assert(classesMap.hasOwnProperty(json.sourceClassInfo));\n assert(classesMap.hasOwnProperty(json.targetClassInfo));\n assert(classesMap.hasOwnProperty(json.relationshipInfo));\n return {\n ...json,\n sourceClassInfo: { id: json.sourceClassInfo, ...classesMap[json.sourceClassInfo] },\n targetClassInfo: { id: json.targetClassInfo, ...classesMap[json.targetClassInfo] },\n relationshipInfo: { id: json.relationshipInfo, ...classesMap[json.relationshipInfo] },\n };\n }\n\n /** Check two [[RelatedClassInfo]] or [[StrippedRelatedClassInfo]] for equality */\n export function equals(lhs: RelatedClassInfo | StrippedRelatedClassInfo, rhs: RelatedClassInfo | StrippedRelatedClassInfo): boolean {\n return (\n lhs.isForwardRelationship === rhs.isForwardRelationship &&\n getClassName(lhs, \"source\") === getClassName(rhs, \"source\") &&\n getClassName(lhs, \"target\") === getClassName(rhs, \"target\") &&\n getClassName(lhs, \"relationship\") === getClassName(rhs, \"relationship\")\n );\n }\n\n function isStripped(info: RelatedClassInfo | StrippedRelatedClassInfo): info is StrippedRelatedClassInfo {\n const maybeStripped = info as StrippedRelatedClassInfo;\n return !!maybeStripped.relationshipName && !!maybeStripped.sourceClassName && !!maybeStripped.targetClassName;\n }\n\n function getClassName(info: RelatedClassInfo | StrippedRelatedClassInfo, whichClass: \"relationship\" | \"source\" | \"target\"): string {\n switch (whichClass) {\n case \"source\":\n return isStripped(info) ? info.sourceClassName : info.sourceClassInfo.name;\n case \"target\":\n return isStripped(info) ? info.targetClassName : info.targetClassInfo.name;\n case \"relationship\":\n return isStripped(info) ? info.relationshipName : info.relationshipInfo.name;\n }\n }\n\n /** Strip given [[RelatedClassInfo]] to [[StrippedRelatedClassInfo]] */\n export function strip(full: RelatedClassInfo): StrippedRelatedClassInfo {\n return {\n sourceClassName: full.sourceClassInfo.name,\n targetClassName: full.targetClassInfo.name,\n relationshipName: full.relationshipInfo.name,\n isForwardRelationship: full.isForwardRelationship,\n };\n }\n}\n\n/**\n * A serialized version of [[RelatedClassInfo]]\n * @public\n */\nexport interface RelatedClassInfoJSON<TClassInfoJSON = ClassInfo> {\n sourceClassInfo: TClassInfoJSON;\n targetClassInfo: TClassInfoJSON;\n isPolymorphicTargetClass?: boolean;\n targetInstanceIds?: Id64String[];\n relationshipInfo: TClassInfoJSON;\n isForwardRelationship: boolean;\n isPolymorphicRelationship?: boolean;\n}\n\n/**\n * A structure that describes a relationship between source and target classes where\n * an actual ECRelationship between them is optional.\n * @public\n */\nexport type RelatedClassInfoWithOptionalRelationship = PartialBy<RelatedClassInfo, \"relationshipInfo\" | \"isForwardRelationship\" | \"isPolymorphicRelationship\">;\n\n/** @public */\nexport type RelatedClassInfoWithOptionalRelationshipJSON<TClassInfoJSON = ClassInfo> = PartialBy<\n RelatedClassInfoJSON<TClassInfoJSON>,\n \"relationshipInfo\" | \"isForwardRelationship\" | \"isPolymorphicRelationship\"\n>;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace RelatedClassInfoWithOptionalRelationship {\n /** Serialize [[RelatedClassInfoWithOptionalRelationship]] to compressed JSON */\n export function toCompressedJSON(\n classInfo: RelatedClassInfoWithOptionalRelationship,\n classesMap: { [id: string]: CompressedClassInfoJSON },\n ): RelatedClassInfoWithOptionalRelationshipJSON<string> {\n const { sourceClassInfo, targetClassInfo, relationshipInfo, ...otherProps } = classInfo;\n const { id: sourceId, ...sourceLeftOverInfo } = sourceClassInfo;\n const { id: targetId, ...targetLeftOverInfo } = targetClassInfo;\n\n classesMap[sourceId] = sourceLeftOverInfo;\n classesMap[targetId] = targetLeftOverInfo;\n\n if (relationshipInfo) {\n const { id: relationshipId, ...relationshipLeftOverInfo } = relationshipInfo;\n classesMap[relationshipId] = relationshipLeftOverInfo;\n }\n\n return {\n ...otherProps,\n sourceClassInfo: sourceId,\n targetClassInfo: targetId,\n ...(relationshipInfo ? { relationshipInfo: relationshipInfo.id } : undefined),\n };\n }\n\n /** Deserialize [[RelatedClassInfoWithOptionalRelationship]] from compressed JSON */\n export function fromCompressedJSON(\n json: RelatedClassInfoWithOptionalRelationshipJSON<string>,\n classesMap: { [id: string]: CompressedClassInfoJSON },\n ): RelatedClassInfoWithOptionalRelationship {\n const { sourceClassInfo, targetClassInfo, relationshipInfo, ...otherProps } = json;\n assert(classesMap.hasOwnProperty(sourceClassInfo));\n assert(classesMap.hasOwnProperty(targetClassInfo));\n if (relationshipInfo) {\n assert(classesMap.hasOwnProperty(relationshipInfo));\n }\n return {\n ...otherProps,\n sourceClassInfo: { id: sourceClassInfo, ...classesMap[sourceClassInfo] },\n targetClassInfo: { id: targetClassInfo, ...classesMap[targetClassInfo] },\n ...(relationshipInfo ? { relationshipInfo: { id: relationshipInfo, ...classesMap[relationshipInfo] } } : undefined),\n };\n }\n}\n\n/**\n * A structure that describes a related class path.\n * @public\n */\nexport type RelationshipPath = RelatedClassInfo[];\n\n/**\n * Serialized [[RelationshipPath]]\n * @public\n */\nexport type RelationshipPathJSON<TClassInfoJSON = ClassInfo> = RelatedClassInfoJSON<TClassInfoJSON>[];\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace RelationshipPath {\n /** Reverse direction of the given [[RelationshipPath]] */\n export function reverse(path: RelationshipPath): RelationshipPath {\n return [...path].reverse().map((step) => ({\n ...step,\n sourceClassInfo: step.targetClassInfo,\n targetClassInfo: step.sourceClassInfo,\n isForwardRelationship: !step.isForwardRelationship,\n }));\n }\n\n /** Check two [[RelationshipPath]] or [[StrippedRelationshipPath]] for equality */\n export function equals(lhs: Array<RelatedClassInfo | StrippedRelatedClassInfo>, rhs: Array<RelatedClassInfo | StrippedRelatedClassInfo>): boolean {\n return lhs.length === rhs.length && lhs.every((lhsPart, i) => RelatedClassInfo.equals(lhsPart, rhs[i]));\n }\n\n /** Strip given [[RelationshipPath]] to [[StrippedRelationshipPath]] */\n export function strip(full: RelationshipPath): StrippedRelationshipPath {\n return full.map(RelatedClassInfo.strip);\n }\n}\n\n/**\n * Data structure that contains a subset of [[RelatedClassInfo]] required to\n * identify the relationship.\n * @public\n */\nexport interface StrippedRelatedClassInfo {\n sourceClassName: string;\n targetClassName: string;\n relationshipName: string;\n isForwardRelationship: boolean;\n}\n\n/**\n * Data structure that contains a subset of [[RelationshipPath]] required to\n * identify the relationship path.\n * @public\n */\nexport type StrippedRelationshipPath = StrippedRelatedClassInfo[];\n"]}
|
|
1
|
+
{"version":3,"file":"EC.js","sourceRoot":"","sources":["../../../src/presentation-common/EC.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAc,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AA0BhE,cAAc;AACd,MAAM,KAAW,WAAW,CAe3B;AAfD,WAAiB,WAAW;IAC1B,8BAA8B;IAC9B,SAAgB,OAAO,CAAC,GAAgB,EAAE,GAAgB;QACxD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACnD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACnD,MAAM,iBAAiB,GAAG,QAAQ,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;QAC7G,IAAI,iBAAiB,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,iBAAiB,CAAC;QAC3B,CAAC;QACD,MAAM,gBAAgB,GAAG,QAAQ,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,QAAQ,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,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1G,CAAC;IAFe,uBAAM,SAErB,CAAA;IAED,uEAAuE;IACvE,SAAgB,KAAK,CAAC,IAAsB;QAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IAFe,sBAAK,QAEpB,CAAA;AACH,CAAC,EApBgB,gBAAgB,KAAhB,gBAAgB,QAoBhC","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 Core\n */\n\nimport { assert, Id64String } from \"@itwin/core-bentley\";\nimport { FormatProps } from \"@itwin/core-quantity\";\nimport { parseFullClassName } from \"@itwin/presentation-shared\";\nimport { PartialBy } from \"./Utils.js\";\n\n/**\n * Type of an ECClass ID.\n * @public\n */\nexport type ClassId = Id64String;\n\n/**\n * Type of an ECInstance ID.\n * @public\n */\nexport type InstanceId = Id64String;\n\n/**\n * A key that uniquely identifies an instance in an iModel\n * @public\n */\nexport interface InstanceKey {\n /** Full class name in format `SchemaName:ClassName` */\n className: string;\n /** ECInstance ID */\n id: InstanceId;\n}\n\n/** @public */\nexport namespace InstanceKey {\n /** Compare 2 instance keys */\n export function compare(lhs: InstanceKey, rhs: InstanceKey): number {\n const lhsClass = parseFullClassName(lhs.className);\n const rhsClass = parseFullClassName(rhs.className);\n const schemaNameCompare = lhsClass.schemaName.toLowerCase().localeCompare(rhsClass.schemaName.toLowerCase());\n if (schemaNameCompare !== 0) {\n return schemaNameCompare;\n }\n const classNameCompare = lhsClass.className.toLowerCase().localeCompare(rhsClass.className.toLowerCase());\n if (classNameCompare !== 0) {\n return classNameCompare;\n }\n return lhs.id.toLowerCase().localeCompare(rhs.id.toLowerCase());\n }\n}\n\n/**\n * Information about an ECClass\n * @public\n */\nexport interface ClassInfo {\n /** ECClass ID */\n id: ClassId;\n /** Full class name in format `SchemaName:ClassName` */\n name: string;\n /** ECClass label */\n label: string;\n}\n\n/**\n * A serialized and compressed version of [[ClassInfo]]\n * @public\n */\nexport interface CompressedClassInfoJSON {\n name: string;\n label: string;\n}\n\n/**\n * A single choice in enumeration\n * @public\n */\nexport interface EnumerationChoice {\n /** Label of the choice */\n label: string;\n /** Value of the choice */\n value: string | number;\n}\n\n/**\n * Enumeration information\n * @public\n */\nexport interface EnumerationInfo {\n /** Available enumeration choices */\n choices: EnumerationChoice[];\n /** Is the enumeration strict (values only allowed from `choices` list) */\n isStrict: boolean;\n}\n\n/**\n * Kind of quantity information\n * @public\n */\nexport interface KindOfQuantityInfo {\n /** Full name of KindOfQuantity in format `SchemaName:KindOfQuantityName` */\n name: string;\n /** Label of KindOfQuantity */\n label: string;\n /** Persistence unit full class name in format `SchemaName:UnitName`. */\n persistenceUnit: string;\n /** Active format that was used to format property value. */\n activeFormat?: FormatProps;\n}\n\n/**\n * A data structure for storing navigation property information.\n * @public\n */\nexport interface NavigationPropertyInfo {\n /** Information about ECProperty's relationship class */\n classInfo: ClassInfo;\n /** Is the direction of the relationship forward */\n isForwardRelationship: boolean;\n /** Information about ECProperty's target class */\n targetClassInfo: ClassInfo;\n /** Is ECProperty's target class polymorphic */\n isTargetPolymorphic: boolean;\n}\n\n/**\n * Contains utilities for working with objects of [[NavigationPropertyInfo]] type.\n * @public\n */\nexport namespace NavigationPropertyInfo {\n /** Serialize [[NavigationPropertyInfo]] to compressed JSON */\n export function toCompressedJSON(\n navigationPropertyInfo: NavigationPropertyInfo,\n classesMap: { [id: string]: CompressedClassInfoJSON },\n ): NavigationPropertyInfoJSON<string> {\n const { id: relationshipId, ...relationshipLeftOverInfo } = navigationPropertyInfo.classInfo;\n const { id: targetId, ...targetLeftOverInfo } = navigationPropertyInfo.targetClassInfo;\n classesMap[relationshipId] = relationshipLeftOverInfo;\n classesMap[targetId] = targetLeftOverInfo;\n\n return {\n ...navigationPropertyInfo,\n classInfo: relationshipId,\n targetClassInfo: targetId,\n };\n }\n\n /** Deserialize [[NavigationPropertyInfo]] from compressed JSON */\n export function fromCompressedJSON(\n compressedNavigationPropertyInfoJSON: NavigationPropertyInfoJSON<string>,\n classesMap: { [id: string]: CompressedClassInfoJSON },\n ): NavigationPropertyInfo {\n return {\n ...compressedNavigationPropertyInfoJSON,\n classInfo: { id: compressedNavigationPropertyInfoJSON.classInfo, ...classesMap[compressedNavigationPropertyInfoJSON.classInfo] },\n targetClassInfo: { id: compressedNavigationPropertyInfoJSON.targetClassInfo, ...classesMap[compressedNavigationPropertyInfoJSON.targetClassInfo] },\n };\n }\n}\n\n/**\n * A serialized version of [[NavigationPropertyInfo]]\n * @public\n */\nexport interface NavigationPropertyInfoJSON<TClassInfoJSON = ClassInfo> {\n classInfo: TClassInfoJSON;\n isForwardRelationship: boolean;\n targetClassInfo: TClassInfoJSON;\n isTargetPolymorphic: boolean;\n}\n\n/**\n * A structure that describes an ECProperty\n * @public\n */\nexport interface PropertyInfo {\n /** Information about ECProperty class */\n classInfo: ClassInfo;\n /** Name of the ECProperty */\n name: string;\n /** Type name of the ECProperty */\n type: string;\n /** Enumeration info if the property is enumerable */\n enumerationInfo?: EnumerationInfo;\n /** Kind of quantity information, if any. */\n kindOfQuantity?: KindOfQuantityInfo;\n /** Extended type name of the ECProperty if it has one */\n extendedType?: string;\n /** Navigation property info if the field is navigation type */\n navigationPropertyInfo?: NavigationPropertyInfo;\n /** Constraints for values of ECProperty */\n constraints?: PropertyValueConstraints;\n}\n\n/**\n * Constraints for values of ECProperty\n * @public\n */\nexport type PropertyValueConstraints = StringPropertyValueConstraints | ArrayPropertyValueConstraints | NumericPropertyValueConstraints;\n\n/**\n * Describes constraints for `string` type ECProperty values\n * @public\n */\nexport interface StringPropertyValueConstraints {\n minimumLength?: number;\n maximumLength?: number;\n}\n\n/**\n * Describes constraints for `int` | `double` | `float` type ECProperty values\n * @public\n */\nexport interface NumericPropertyValueConstraints {\n minimumValue?: number;\n maximumValue?: number;\n}\n\n/**\n * Describes constraints for `array` type ECProperty values\n * @public\n */\nexport interface ArrayPropertyValueConstraints {\n minOccurs?: number;\n maxOccurs?: number;\n}\n\n/** @public */\nexport namespace PropertyInfo {\n /** Serialize [[PropertyInfo]] to compressed JSON */\n export function toCompressedJSON(propertyInfo: PropertyInfo, classesMap: { [id: string]: CompressedClassInfoJSON }): PropertyInfoJSON<string> {\n const { navigationPropertyInfo, ...leftOverPropertyInfo } = propertyInfo;\n const { id, ...leftOverInfo } = propertyInfo.classInfo;\n classesMap[id] = leftOverInfo;\n\n return {\n ...leftOverPropertyInfo,\n classInfo: propertyInfo.classInfo.id,\n ...(navigationPropertyInfo ? { navigationPropertyInfo: NavigationPropertyInfo.toCompressedJSON(navigationPropertyInfo, classesMap) } : undefined),\n };\n }\n}\n\n/**\n * A serialized version of [[PropertyInfo]]\n * @public\n */\nexport interface PropertyInfoJSON<TClassInfoJSON = ClassInfo> {\n classInfo: TClassInfoJSON;\n name: string;\n type: string;\n enumerationInfo?: EnumerationInfo;\n kindOfQuantity?: KindOfQuantityInfo;\n navigationPropertyInfo?: NavigationPropertyInfoJSON<TClassInfoJSON>;\n}\n\n/**\n * A structure that describes a related class and the properties of that relationship.\n * @public\n */\nexport interface RelatedClassInfo {\n /** Information about the source ECClass */\n sourceClassInfo: ClassInfo;\n\n /** Information about the target ECClass */\n targetClassInfo: ClassInfo;\n\n /** Is target class handled polymorphically */\n isPolymorphicTargetClass?: boolean;\n\n /** Optionally, IDs of specific target class instances. */\n targetInstanceIds?: Id64String[];\n\n /** Information about the ECRelationship */\n relationshipInfo: ClassInfo;\n\n /** Should relationship be followed in a forward direction to access the related class. */\n isForwardRelationship: boolean;\n\n /** Is relationship handled polymorphically */\n isPolymorphicRelationship?: boolean;\n}\n\n/** @public */\nexport namespace RelatedClassInfo {\n /** Serialize [[RelatedClassInfo]] to compressed JSON */\n export function toCompressedJSON(classInfo: RelatedClassInfo, classesMap: { [id: string]: CompressedClassInfoJSON }): RelatedClassInfoJSON<string> {\n const { id: sourceId, ...sourceLeftOverInfo } = classInfo.sourceClassInfo;\n const { id: targetId, ...targetLeftOverInfo } = classInfo.targetClassInfo;\n const { id: relationshipId, ...relationshipLeftOverInfo } = classInfo.relationshipInfo;\n\n classesMap[sourceId] = sourceLeftOverInfo;\n classesMap[targetId] = targetLeftOverInfo;\n classesMap[relationshipId] = relationshipLeftOverInfo;\n\n return {\n ...classInfo,\n sourceClassInfo: sourceId,\n targetClassInfo: targetId,\n relationshipInfo: relationshipId,\n };\n }\n\n /** Deserialize [[RelatedClassInfo]] from compressed JSON */\n export function fromCompressedJSON(json: RelatedClassInfoJSON<string>, classesMap: { [id: string]: CompressedClassInfoJSON }): RelatedClassInfo {\n assert(classesMap.hasOwnProperty(json.sourceClassInfo));\n assert(classesMap.hasOwnProperty(json.targetClassInfo));\n assert(classesMap.hasOwnProperty(json.relationshipInfo));\n return {\n ...json,\n sourceClassInfo: { id: json.sourceClassInfo, ...classesMap[json.sourceClassInfo] },\n targetClassInfo: { id: json.targetClassInfo, ...classesMap[json.targetClassInfo] },\n relationshipInfo: { id: json.relationshipInfo, ...classesMap[json.relationshipInfo] },\n };\n }\n\n /** Check two [[RelatedClassInfo]] or [[StrippedRelatedClassInfo]] for equality */\n export function equals(lhs: RelatedClassInfo | StrippedRelatedClassInfo, rhs: RelatedClassInfo | StrippedRelatedClassInfo): boolean {\n return (\n lhs.isForwardRelationship === rhs.isForwardRelationship &&\n getClassName(lhs, \"source\") === getClassName(rhs, \"source\") &&\n getClassName(lhs, \"target\") === getClassName(rhs, \"target\") &&\n getClassName(lhs, \"relationship\") === getClassName(rhs, \"relationship\")\n );\n }\n\n function isStripped(info: RelatedClassInfo | StrippedRelatedClassInfo): info is StrippedRelatedClassInfo {\n const maybeStripped = info as StrippedRelatedClassInfo;\n return !!maybeStripped.relationshipName && !!maybeStripped.sourceClassName && !!maybeStripped.targetClassName;\n }\n\n function getClassName(info: RelatedClassInfo | StrippedRelatedClassInfo, whichClass: \"relationship\" | \"source\" | \"target\"): string {\n switch (whichClass) {\n case \"source\":\n return isStripped(info) ? info.sourceClassName : info.sourceClassInfo.name;\n case \"target\":\n return isStripped(info) ? info.targetClassName : info.targetClassInfo.name;\n case \"relationship\":\n return isStripped(info) ? info.relationshipName : info.relationshipInfo.name;\n }\n }\n\n /** Strip given [[RelatedClassInfo]] to [[StrippedRelatedClassInfo]] */\n export function strip(full: RelatedClassInfo): StrippedRelatedClassInfo {\n return {\n sourceClassName: full.sourceClassInfo.name,\n targetClassName: full.targetClassInfo.name,\n relationshipName: full.relationshipInfo.name,\n isForwardRelationship: full.isForwardRelationship,\n };\n }\n}\n\n/**\n * A serialized version of [[RelatedClassInfo]]\n * @public\n */\nexport interface RelatedClassInfoJSON<TClassInfoJSON = ClassInfo> {\n sourceClassInfo: TClassInfoJSON;\n targetClassInfo: TClassInfoJSON;\n isPolymorphicTargetClass?: boolean;\n targetInstanceIds?: Id64String[];\n relationshipInfo: TClassInfoJSON;\n isForwardRelationship: boolean;\n isPolymorphicRelationship?: boolean;\n}\n\n/**\n * A structure that describes a relationship between source and target classes where\n * an actual ECRelationship between them is optional.\n * @public\n */\nexport type RelatedClassInfoWithOptionalRelationship = PartialBy<RelatedClassInfo, \"relationshipInfo\" | \"isForwardRelationship\" | \"isPolymorphicRelationship\">;\n\n/** @public */\nexport type RelatedClassInfoWithOptionalRelationshipJSON<TClassInfoJSON = ClassInfo> = PartialBy<\n RelatedClassInfoJSON<TClassInfoJSON>,\n \"relationshipInfo\" | \"isForwardRelationship\" | \"isPolymorphicRelationship\"\n>;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace RelatedClassInfoWithOptionalRelationship {\n /** Serialize [[RelatedClassInfoWithOptionalRelationship]] to compressed JSON */\n export function toCompressedJSON(\n classInfo: RelatedClassInfoWithOptionalRelationship,\n classesMap: { [id: string]: CompressedClassInfoJSON },\n ): RelatedClassInfoWithOptionalRelationshipJSON<string> {\n const { sourceClassInfo, targetClassInfo, relationshipInfo, ...otherProps } = classInfo;\n const { id: sourceId, ...sourceLeftOverInfo } = sourceClassInfo;\n const { id: targetId, ...targetLeftOverInfo } = targetClassInfo;\n\n classesMap[sourceId] = sourceLeftOverInfo;\n classesMap[targetId] = targetLeftOverInfo;\n\n if (relationshipInfo) {\n const { id: relationshipId, ...relationshipLeftOverInfo } = relationshipInfo;\n classesMap[relationshipId] = relationshipLeftOverInfo;\n }\n\n return {\n ...otherProps,\n sourceClassInfo: sourceId,\n targetClassInfo: targetId,\n ...(relationshipInfo ? { relationshipInfo: relationshipInfo.id } : undefined),\n };\n }\n\n /** Deserialize [[RelatedClassInfoWithOptionalRelationship]] from compressed JSON */\n export function fromCompressedJSON(\n json: RelatedClassInfoWithOptionalRelationshipJSON<string>,\n classesMap: { [id: string]: CompressedClassInfoJSON },\n ): RelatedClassInfoWithOptionalRelationship {\n const { sourceClassInfo, targetClassInfo, relationshipInfo, ...otherProps } = json;\n assert(classesMap.hasOwnProperty(sourceClassInfo));\n assert(classesMap.hasOwnProperty(targetClassInfo));\n if (relationshipInfo) {\n assert(classesMap.hasOwnProperty(relationshipInfo));\n }\n return {\n ...otherProps,\n sourceClassInfo: { id: sourceClassInfo, ...classesMap[sourceClassInfo] },\n targetClassInfo: { id: targetClassInfo, ...classesMap[targetClassInfo] },\n ...(relationshipInfo ? { relationshipInfo: { id: relationshipInfo, ...classesMap[relationshipInfo] } } : undefined),\n };\n }\n}\n\n/**\n * A structure that describes a related class path.\n * @public\n */\nexport type RelationshipPath = RelatedClassInfo[];\n\n/**\n * Serialized [[RelationshipPath]]\n * @public\n */\nexport type RelationshipPathJSON<TClassInfoJSON = ClassInfo> = RelatedClassInfoJSON<TClassInfoJSON>[];\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace RelationshipPath {\n /** Reverse direction of the given [[RelationshipPath]] */\n export function reverse(path: RelationshipPath): RelationshipPath {\n return [...path].reverse().map((step) => ({\n ...step,\n sourceClassInfo: step.targetClassInfo,\n targetClassInfo: step.sourceClassInfo,\n isForwardRelationship: !step.isForwardRelationship,\n }));\n }\n\n /** Check two [[RelationshipPath]] or [[StrippedRelationshipPath]] for equality */\n export function equals(lhs: Array<RelatedClassInfo | StrippedRelatedClassInfo>, rhs: Array<RelatedClassInfo | StrippedRelatedClassInfo>): boolean {\n return lhs.length === rhs.length && lhs.every((lhsPart, i) => RelatedClassInfo.equals(lhsPart, rhs[i]));\n }\n\n /** Strip given [[RelationshipPath]] to [[StrippedRelationshipPath]] */\n export function strip(full: RelationshipPath): StrippedRelationshipPath {\n return full.map(RelatedClassInfo.strip);\n }\n}\n\n/**\n * Data structure that contains a subset of [[RelatedClassInfo]] required to\n * identify the relationship.\n * @public\n */\nexport interface StrippedRelatedClassInfo {\n sourceClassName: string;\n targetClassName: string;\n relationshipName: string;\n isForwardRelationship: boolean;\n}\n\n/**\n * Data structure that contains a subset of [[RelationshipPath]] required to\n * identify the relationship path.\n * @public\n */\nexport type StrippedRelationshipPath = StrippedRelatedClassInfo[];\n"]}
|
|
@@ -23,7 +23,7 @@ export declare enum PresentationStatus {
|
|
|
23
23
|
* Timeout for the request was reached which prevented it from being fulfilled. Frontend may
|
|
24
24
|
* repeat the request.
|
|
25
25
|
*
|
|
26
|
-
* @deprecated in 5.
|
|
26
|
+
* @deprecated in 5.0 - will not be removed until after 2026-06-13. Presentation RPC now relies on `RpcPendingResponse` to handle timeouts.
|
|
27
27
|
*/
|
|
28
28
|
BackendTimeout = 65543
|
|
29
29
|
}
|
|
@@ -28,7 +28,7 @@ export var PresentationStatus;
|
|
|
28
28
|
* Timeout for the request was reached which prevented it from being fulfilled. Frontend may
|
|
29
29
|
* repeat the request.
|
|
30
30
|
*
|
|
31
|
-
* @deprecated in 5.
|
|
31
|
+
* @deprecated in 5.0 - will not be removed until after 2026-06-13. Presentation RPC now relies on `RpcPendingResponse` to handle timeouts.
|
|
32
32
|
*/
|
|
33
33
|
PresentationStatus[PresentationStatus["BackendTimeout"] = 65543] = "BackendTimeout";
|
|
34
34
|
})(PresentationStatus || (PresentationStatus = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Error.js","sourceRoot":"","sources":["../../../src/presentation-common/Error.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAuB,MAAM,qBAAqB,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAN,IAAY,kBA0BX;AA1BD,WAAY,kBAAkB;IAC5B,sBAAsB;IACtB,iEAAW,CAAA;IAEX,6BAA6B;IAC7B,mEAAY,CAAA;IAEZ,qBAAqB;IACrB,iEAAe,CAAA;IAEf,yCAAyC;IACzC,mFAA0B,CAAA;IAE1B,sCAAsC;IACtC,yFAA6B,CAAA;IAE7B,kCAAkC;IAClC,qFAA2B,CAAA;IAE3B;;;;;OAKG;IACH,mFAA0B,CAAA;AAC5B,CAAC,EA1BW,kBAAkB,KAAlB,kBAAkB,QA0B7B;AAED;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,YAAY;IACjD;;;;;;;OAOG;IACH,YAAmB,WAA+B,EAAE,OAAgB,EAAE,WAAiC;QACrG,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACgB,SAAS;QAC1B,IAAI,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,kBAAkB,IAAI,CAAC,WAAW,GAAG,CAAC;QAChD,CAAC;QACD,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/** @packageDocumentation\n * @module Core\n */\n\nimport { BentleyError, GetMetaDataFunction } from \"@itwin/core-bentley\";\n\n/**\n * Status codes used by Presentation APIs.\n * @public\n */\nexport enum PresentationStatus {\n /** Success result. */\n Success = 0,\n\n /** Request was cancelled. */\n Canceled = 1,\n\n /** Error: Unknown */\n Error = 0x10000,\n\n /** Error: Backend is not initialized. */\n NotInitialized = Error + 1,\n\n /** Error: Result set is too large. */\n ResultSetTooLarge = Error + 2,\n\n /** Error: Argument is invalid. */\n InvalidArgument = Error + 3,\n\n /**\n * Timeout for the request was reached which prevented it from being fulfilled. Frontend may\n * repeat the request.\n *\n * @deprecated in 5.
|
|
1
|
+
{"version":3,"file":"Error.js","sourceRoot":"","sources":["../../../src/presentation-common/Error.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAuB,MAAM,qBAAqB,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAN,IAAY,kBA0BX;AA1BD,WAAY,kBAAkB;IAC5B,sBAAsB;IACtB,iEAAW,CAAA;IAEX,6BAA6B;IAC7B,mEAAY,CAAA;IAEZ,qBAAqB;IACrB,iEAAe,CAAA;IAEf,yCAAyC;IACzC,mFAA0B,CAAA;IAE1B,sCAAsC;IACtC,yFAA6B,CAAA;IAE7B,kCAAkC;IAClC,qFAA2B,CAAA;IAE3B;;;;;OAKG;IACH,mFAA0B,CAAA;AAC5B,CAAC,EA1BW,kBAAkB,KAAlB,kBAAkB,QA0B7B;AAED;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,YAAY;IACjD;;;;;;;OAOG;IACH,YAAmB,WAA+B,EAAE,OAAgB,EAAE,WAAiC;QACrG,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACgB,SAAS;QAC1B,IAAI,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,kBAAkB,IAAI,CAAC,WAAW,GAAG,CAAC;QAChD,CAAC;QACD,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/** @packageDocumentation\n * @module Core\n */\n\nimport { BentleyError, GetMetaDataFunction } from \"@itwin/core-bentley\";\n\n/**\n * Status codes used by Presentation APIs.\n * @public\n */\nexport enum PresentationStatus {\n /** Success result. */\n Success = 0,\n\n /** Request was cancelled. */\n Canceled = 1,\n\n /** Error: Unknown */\n Error = 0x10000,\n\n /** Error: Backend is not initialized. */\n NotInitialized = Error + 1,\n\n /** Error: Result set is too large. */\n ResultSetTooLarge = Error + 2,\n\n /** Error: Argument is invalid. */\n InvalidArgument = Error + 3,\n\n /**\n * Timeout for the request was reached which prevented it from being fulfilled. Frontend may\n * repeat the request.\n *\n * @deprecated in 5.0 - will not be removed until after 2026-06-13. Presentation RPC now relies on `RpcPendingResponse` to handle timeouts.\n */\n BackendTimeout = Error + 7,\n}\n\n/**\n * An error type thrown by Presentation APIs.\n * @public\n */\nexport class PresentationError extends BentleyError {\n /**\n * Creates an instance of Error.\n * @param errorNumber Error code\n * @param message Optional brief description of the error. The `message` property combined with the `name`\n * property is used by the `Error.prototype.toString()` method to create a string representation of the Error.\n * @param log Optional log function which logs the error.\n * @param getMetaData Optional function that returns meta-data related to an error.\n */\n public constructor(errorNumber: PresentationStatus, message?: string, getMetaData?: GetMetaDataFunction) {\n super(errorNumber, message, getMetaData);\n }\n\n /**\n * Returns the name of each error status. The name is used by the `Error.prototype.toString()`\n * method to create a string representation of the error.\n */\n protected override _initName(): string {\n let value = PresentationStatus[this.errorNumber];\n if (!value) {\n value = `Unknown Error (${this.errorNumber})`;\n }\n return value;\n }\n}\n"]}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Core
|
|
3
3
|
*/
|
|
4
|
-
import { FormatProps, FormatterSpec, ParserSpec, UnitSystemKey } from "@itwin/core-quantity";
|
|
4
|
+
import { FormatProps, FormatsProvider, FormatterSpec, ParserSpec, UnitSystemKey } from "@itwin/core-quantity";
|
|
5
5
|
import { SchemaContext } from "@itwin/ecschema-metadata";
|
|
6
6
|
/**
|
|
7
7
|
* A data structure that associates unit systems with property value formatting props. The associations are used for
|
|
8
8
|
* assigning formatting props for specific phenomenon and unit system combinations (see [[FormatsMap]]).
|
|
9
9
|
*
|
|
10
10
|
* @public
|
|
11
|
+
*
|
|
12
|
+
* @deprecated in 5.1. `FormatsMap` and related APIs have been deprecated in favor of [FormatsProvider]($core-quantity).
|
|
11
13
|
*/
|
|
12
14
|
export interface UnitSystemFormat {
|
|
13
15
|
unitSystems: UnitSystemKey[];
|
|
@@ -33,6 +35,8 @@ export interface UnitSystemFormat {
|
|
|
33
35
|
* ```
|
|
34
36
|
*
|
|
35
37
|
* @public
|
|
38
|
+
*
|
|
39
|
+
* @deprecated in 5.1. `FormatsMap` and related APIs have been deprecated in favor of [FormatsProvider]($core-quantity).
|
|
36
40
|
*/
|
|
37
41
|
export interface FormatsMap {
|
|
38
42
|
[phenomenon: string]: UnitSystemFormat | UnitSystemFormat[];
|
|
@@ -47,17 +51,35 @@ export interface FormatOptions {
|
|
|
47
51
|
/** Unit system to use for formatting. */
|
|
48
52
|
unitSystem?: UnitSystemKey;
|
|
49
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Props for creating [[KoqPropertyValueFormatter]].
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
interface KoqPropertyValueFormatterProps {
|
|
59
|
+
/** Schema context to use for locating units, formats, etc. Generally retrieved through the `schemaContext` getter on an iModel. */
|
|
60
|
+
schemaContext: SchemaContext;
|
|
61
|
+
/** Formats provider to use for finding formatting props. Defaults to [SchemaFormatsProvider]($ecschema-metadata) when not supplied. */
|
|
62
|
+
formatsProvider?: FormatsProvider;
|
|
63
|
+
}
|
|
50
64
|
/**
|
|
51
65
|
* An utility for formatting property values based on `KindOfQuantity` and unit system.
|
|
52
66
|
* @public
|
|
53
67
|
*/
|
|
54
68
|
export declare class KoqPropertyValueFormatter {
|
|
69
|
+
#private;
|
|
55
70
|
private _schemaContext;
|
|
56
71
|
private _unitsProvider;
|
|
72
|
+
private _formatsProvider?;
|
|
57
73
|
private _defaultFormats?;
|
|
58
|
-
|
|
74
|
+
/** @deprecated in 5.1. Use the overload that takes a props object. */
|
|
75
|
+
constructor(schemaContext: SchemaContext, defaultFormats?: FormatsMap, formatsProvider?: FormatsProvider);
|
|
76
|
+
constructor(props: KoqPropertyValueFormatterProps);
|
|
77
|
+
/** @internal */
|
|
78
|
+
get defaultFormats(): FormatsMap | undefined;
|
|
79
|
+
set defaultFormats(value: FormatsMap | undefined);
|
|
59
80
|
format(value: number, options: FormatOptions): Promise<string | undefined>;
|
|
60
81
|
getFormatterSpec(options: FormatOptions): Promise<FormatterSpec | undefined>;
|
|
61
82
|
getParserSpec(options: FormatOptions): Promise<ParserSpec | undefined>;
|
|
62
83
|
}
|
|
84
|
+
export {};
|
|
63
85
|
//# sourceMappingURL=KoqPropertyValueFormatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KoqPropertyValueFormatter.d.ts","sourceRoot":"","sources":["../../../src/presentation-common/KoqPropertyValueFormatter.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"KoqPropertyValueFormatter.d.ts","sourceRoot":"","sources":["../../../src/presentation-common/KoqPropertyValueFormatter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAU,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAiB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrI,OAAO,EAAgC,aAAa,EAAyE,MAAM,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@itwin/core-bentley";
|
|
8
9
|
import { Format, FormatterSpec, ParserSpec } from "@itwin/core-quantity";
|
|
9
|
-
import {
|
|
10
|
+
import { InvertedUnit, KindOfQuantity, SchemaContext, SchemaFormatsProvider, SchemaKey, SchemaMatchType, SchemaUnitProvider } from "@itwin/ecschema-metadata";
|
|
10
11
|
/**
|
|
11
12
|
* An utility for formatting property values based on `KindOfQuantity` and unit system.
|
|
12
13
|
* @public
|
|
@@ -14,14 +15,35 @@ import { getFormatProps, InvertedUnit, KindOfQuantity, SchemaKey, SchemaMatchTyp
|
|
|
14
15
|
export class KoqPropertyValueFormatter {
|
|
15
16
|
_schemaContext;
|
|
16
17
|
_unitsProvider;
|
|
18
|
+
_formatsProvider;
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
17
20
|
_defaultFormats;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
22
|
+
constructor(schemaContextOrProps, defaultFormats, formatsProvider) {
|
|
23
|
+
if (schemaContextOrProps instanceof SchemaContext) {
|
|
24
|
+
this._schemaContext = schemaContextOrProps;
|
|
25
|
+
this._formatsProvider = formatsProvider;
|
|
26
|
+
this.defaultFormats = defaultFormats;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
this._schemaContext = schemaContextOrProps.schemaContext;
|
|
30
|
+
this._formatsProvider = schemaContextOrProps.formatsProvider;
|
|
31
|
+
}
|
|
32
|
+
this._unitsProvider = new SchemaUnitProvider(this._schemaContext);
|
|
33
|
+
}
|
|
34
|
+
/* c8 ignore start */
|
|
35
|
+
/** @internal */
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
37
|
+
get defaultFormats() {
|
|
38
|
+
return this._defaultFormats;
|
|
24
39
|
}
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
41
|
+
set defaultFormats(value) {
|
|
42
|
+
this._defaultFormats = value
|
|
43
|
+
? Object.entries(value).reduce((acc, [phenomenon, unitSystemFormats]) => ({ ...acc, [phenomenon.toUpperCase()]: unitSystemFormats }), {})
|
|
44
|
+
: undefined;
|
|
45
|
+
}
|
|
46
|
+
/* c8 ignore end */
|
|
25
47
|
async format(value, options) {
|
|
26
48
|
const formatterSpec = await this.getFormatterSpec(options);
|
|
27
49
|
if (!formatterSpec) {
|
|
@@ -30,7 +52,7 @@ export class KoqPropertyValueFormatter {
|
|
|
30
52
|
return formatterSpec.applyFormatting(value);
|
|
31
53
|
}
|
|
32
54
|
async getFormatterSpec(options) {
|
|
33
|
-
const formattingProps = await getFormattingProps(
|
|
55
|
+
const formattingProps = await this.#getFormattingProps(options);
|
|
34
56
|
if (!formattingProps) {
|
|
35
57
|
return undefined;
|
|
36
58
|
}
|
|
@@ -40,7 +62,7 @@ export class KoqPropertyValueFormatter {
|
|
|
40
62
|
return FormatterSpec.create("", format, this._unitsProvider, persistenceUnit);
|
|
41
63
|
}
|
|
42
64
|
async getParserSpec(options) {
|
|
43
|
-
const formattingProps = await getFormattingProps(
|
|
65
|
+
const formattingProps = await this.#getFormattingProps(options);
|
|
44
66
|
if (!formattingProps) {
|
|
45
67
|
return undefined;
|
|
46
68
|
}
|
|
@@ -49,23 +71,37 @@ export class KoqPropertyValueFormatter {
|
|
|
49
71
|
const format = await Format.createFromJSON("", this._unitsProvider, formatProps);
|
|
50
72
|
return ParserSpec.create(format, this._unitsProvider, persistenceUnit);
|
|
51
73
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
74
|
+
async #getFormattingProps(options) {
|
|
75
|
+
const { koqName } = options;
|
|
76
|
+
const koq = await getKoq(this._schemaContext, koqName);
|
|
77
|
+
if (!koq) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const persistenceUnit = await koq.persistenceUnit;
|
|
81
|
+
assert(!!persistenceUnit);
|
|
82
|
+
// default to metric as it's the persistence unit system
|
|
83
|
+
const unitSystem = options.unitSystem ?? "metric";
|
|
84
|
+
const formatsProvider = this._formatsProvider ?? new SchemaFormatsProvider(this._schemaContext, unitSystem);
|
|
85
|
+
const formatProps = await formatsProvider.getFormat(koqName);
|
|
86
|
+
// `SchemaFormatsProvider` will fall back to default presentation format, but we want to fall back
|
|
87
|
+
// to default formats' map first, and only then to the default presentation format. All of this can
|
|
88
|
+
// be removed with the removal of default formats map.
|
|
89
|
+
if (this._defaultFormats && (!formatProps || (await getUnitSystemKey(this._unitsProvider, formatProps)) !== unitSystem)) {
|
|
90
|
+
const defaultFormatProps = await getFormatPropsFromDefaultFormats({
|
|
91
|
+
schemaContext: this._schemaContext,
|
|
92
|
+
formatsMap: this._defaultFormats,
|
|
93
|
+
unitSystem,
|
|
94
|
+
koqName,
|
|
95
|
+
});
|
|
96
|
+
if (defaultFormatProps) {
|
|
97
|
+
return { formatProps: defaultFormatProps, persistenceUnitName: persistenceUnit.fullName };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (formatProps) {
|
|
101
|
+
return { formatProps, persistenceUnitName: persistenceUnit.fullName };
|
|
102
|
+
}
|
|
66
103
|
return undefined;
|
|
67
104
|
}
|
|
68
|
-
return { formatProps, persistenceUnitName: persistenceUnit.fullName };
|
|
69
105
|
}
|
|
70
106
|
async function getKoq(schemaLocater, fullName) {
|
|
71
107
|
const [schemaName, propKoqName] = fullName.split(":");
|
|
@@ -75,92 +111,49 @@ async function getKoq(schemaLocater, fullName) {
|
|
|
75
111
|
}
|
|
76
112
|
return schema.getItem(propKoqName, KindOfQuantity);
|
|
77
113
|
}
|
|
78
|
-
async function
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return defaultUnitSystemFormat.format;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
114
|
+
async function getUnitSystemKey(unitsProvider, formatProps) {
|
|
115
|
+
const unitName = formatProps.composite?.units[0].name;
|
|
116
|
+
assert(!!unitName);
|
|
117
|
+
const unit = await unitsProvider.findUnitByName(unitName);
|
|
118
|
+
assert(!!unit);
|
|
119
|
+
const [_, unitSystemName] = unit.system.split(/[\.:]/);
|
|
120
|
+
switch (unitSystemName.toUpperCase()) {
|
|
121
|
+
case "METRIC":
|
|
122
|
+
return "metric";
|
|
123
|
+
case "IMPERIAL":
|
|
124
|
+
return "imperial";
|
|
125
|
+
case "USCUSTOM":
|
|
126
|
+
return "usCustomary";
|
|
127
|
+
case "USSURVEY":
|
|
128
|
+
return "usSurvey";
|
|
129
|
+
/* c8 ignore next 2 */
|
|
130
|
+
default:
|
|
131
|
+
return undefined;
|
|
100
132
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
133
|
+
}
|
|
134
|
+
async function getFormatPropsFromDefaultFormats({ schemaContext, formatsMap, unitSystem, koqName, }) {
|
|
135
|
+
const koq = await getKoq(schemaContext, koqName);
|
|
136
|
+
/* c8 ignore next 3 */
|
|
137
|
+
if (!koq) {
|
|
138
|
+
return undefined;
|
|
105
139
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
140
|
+
const persistenceUnit = await koq.persistenceUnit;
|
|
141
|
+
/* c8 ignore next 3 */
|
|
142
|
+
if (!persistenceUnit) {
|
|
143
|
+
return undefined;
|
|
109
144
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (!lazyUnit) {
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
const unit = await lazyUnit;
|
|
123
|
-
const currentUnitSystem = await unit.unitSystem;
|
|
124
|
-
if (currentUnitSystem && matcher(currentUnitSystem)) {
|
|
125
|
-
return format;
|
|
145
|
+
const actualPersistenceUnit = persistenceUnit instanceof InvertedUnit ? /* c8 ignore next */ await persistenceUnit.invertsUnit : persistenceUnit;
|
|
146
|
+
const phenomenon = await actualPersistenceUnit?.phenomenon;
|
|
147
|
+
if (phenomenon && formatsMap[phenomenon.name.toUpperCase()]) {
|
|
148
|
+
const defaultPhenomenonFormats = formatsMap[phenomenon.name.toUpperCase()];
|
|
149
|
+
for (const defaultUnitSystemFormat of Array.isArray(defaultPhenomenonFormats)
|
|
150
|
+
? /* c8 ignore next */ defaultPhenomenonFormats
|
|
151
|
+
: [defaultPhenomenonFormats]) {
|
|
152
|
+
if (defaultUnitSystemFormat.unitSystems.includes(unitSystem)) {
|
|
153
|
+
return defaultUnitSystemFormat.format;
|
|
126
154
|
}
|
|
127
155
|
}
|
|
128
156
|
}
|
|
129
157
|
return undefined;
|
|
130
158
|
}
|
|
131
|
-
function getPersistenceUnitFormatProps(persistenceUnit) {
|
|
132
|
-
// Same as Format "DefaultRealU" in Formats ecschema
|
|
133
|
-
return {
|
|
134
|
-
formatTraits: ["keepSingleZero", "keepDecimalPoint", "showUnitLabel"],
|
|
135
|
-
precision: 6,
|
|
136
|
-
type: "Decimal",
|
|
137
|
-
uomSeparator: " ",
|
|
138
|
-
decimalSeparator: ".",
|
|
139
|
-
composite: {
|
|
140
|
-
units: [
|
|
141
|
-
{
|
|
142
|
-
name: persistenceUnit.fullName,
|
|
143
|
-
label: persistenceUnit.label,
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
},
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
function getUnitSystemGroupMatchers(groupKey) {
|
|
150
|
-
function createMatcher(name) {
|
|
151
|
-
const names = Array.isArray(name) ? name : [name];
|
|
152
|
-
return (unitSystem) => names.some((n) => n === unitSystem.name.toUpperCase());
|
|
153
|
-
}
|
|
154
|
-
switch (groupKey) {
|
|
155
|
-
case "imperial":
|
|
156
|
-
return ["IMPERIAL", "USCUSTOM", "INTERNATIONAL", "FINANCE"].map(createMatcher);
|
|
157
|
-
case "metric":
|
|
158
|
-
return [["SI", "METRIC"], "INTERNATIONAL", "FINANCE"].map(createMatcher);
|
|
159
|
-
case "usCustomary":
|
|
160
|
-
return ["USCUSTOM", "INTERNATIONAL", "FINANCE"].map(createMatcher);
|
|
161
|
-
case "usSurvey":
|
|
162
|
-
return ["USSURVEY", "USCUSTOM", "INTERNATIONAL", "FINANCE"].map(createMatcher);
|
|
163
|
-
}
|
|
164
|
-
return [];
|
|
165
|
-
}
|
|
166
159
|
//# sourceMappingURL=KoqPropertyValueFormatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KoqPropertyValueFormatter.js","sourceRoot":"","sources":["../../../src/presentation-common/KoqPropertyValueFormatter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAe,aAAa,EAAE,UAAU,EAAgC,MAAM,sBAAsB,CAAC;AACpH,OAAO,EACL,cAAc,EACd,YAAY,EACZ,cAAc,EAEd,SAAS,EACT,eAAe,EACf,kBAAkB,GAGnB,MAAM,0BAA0B,CAAC;AAiDlC;;;GAGG;AACH,MAAM,OAAO,yBAAyB;IAK1B;IAJF,cAAc,CAAgB;IAC9B,eAAe,CAAc;IAErC,YACU,cAA6B,EACrC,cAA2B;QADnB,mBAAc,GAAd,cAAc,CAAe;QAGrC,IAAI,CAAC,cAAc,GAAG,IAAI,kBAAkB,CAAC,cAAc,CAAC,CAAC;QAC7D,IAAI,CAAC,eAAe,GAAG,cAAc;YACnC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC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U,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,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 Core\n */\n\nimport { Format, FormatProps, FormatterSpec, ParserSpec, UnitsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\nimport {\n getFormatProps,\n InvertedUnit,\n KindOfQuantity,\n SchemaContext,\n SchemaKey,\n SchemaMatchType,\n SchemaUnitProvider,\n Unit,\n UnitSystem,\n} from \"@itwin/ecschema-metadata\";\n\n/**\n * A data structure that associates unit systems with property value formatting props. The associations are used for\n * assigning formatting props for specific phenomenon and unit system combinations (see [[FormatsMap]]).\n *\n * @public\n */\nexport interface UnitSystemFormat {\n unitSystems: UnitSystemKey[];\n format: FormatProps;\n}\n\n/**\n * A data structure that associates specific phenomenon with one or more formatting props for specific unit system.\n *\n * Example:\n * ```json\n * {\n * length: [{\n * unitSystems: [\"metric\"],\n * format: formatForCentimeters,\n * }, {\n * unitSystems: [\"imperial\", \"usCustomary\"],\n * format: formatForInches,\n * }, {\n * unitSystems: [\"usSurvey\"],\n * format: formatForUsSurveyInches,\n * }]\n * }\n * ```\n *\n * @public\n */\nexport interface FormatsMap {\n [phenomenon: string]: UnitSystemFormat | UnitSystemFormat[];\n}\n\n/**\n * Options for finding a formatter spec to use in [[KoqPropertyValueFormatter]].\n * @public\n */\nexport interface FormatOptions {\n /** Full name of the `KindOfQuantity`, e.g. `SchemaName:KoqName`. */\n koqName: string;\n /** Unit system to use for formatting. */\n unitSystem?: UnitSystemKey;\n}\n\n/**\n * An utility for formatting property values based on `KindOfQuantity` and unit system.\n * @public\n */\nexport class KoqPropertyValueFormatter {\n private _unitsProvider: UnitsProvider;\n private _defaultFormats?: FormatsMap;\n\n constructor(\n private _schemaContext: SchemaContext,\n defaultFormats?: FormatsMap,\n ) {\n this._unitsProvider = new SchemaUnitProvider(_schemaContext);\n this._defaultFormats = defaultFormats\n ? Object.entries(defaultFormats).reduce((acc, [phenomenon, unitSystemFormats]) => ({ ...acc, [phenomenon.toUpperCase()]: unitSystemFormats }), {})\n : /* c8 ignore next */ undefined;\n }\n\n public async format(value: number, options: FormatOptions) {\n const formatterSpec = await this.getFormatterSpec(options);\n if (!formatterSpec) {\n return undefined;\n }\n return formatterSpec.applyFormatting(value);\n }\n\n public async getFormatterSpec(options: FormatOptions) {\n const formattingProps = await getFormattingProps(this._schemaContext, this._defaultFormats, options);\n if (!formattingProps) {\n return undefined;\n }\n const { formatProps, persistenceUnitName } = formattingProps;\n const persistenceUnit = await this._unitsProvider.findUnitByName(persistenceUnitName);\n const format = await Format.createFromJSON(\"\", this._unitsProvider, formatProps);\n return FormatterSpec.create(\"\", format, this._unitsProvider, persistenceUnit);\n }\n\n public async getParserSpec(options: FormatOptions) {\n const formattingProps = await getFormattingProps(this._schemaContext, this._defaultFormats, options);\n if (!formattingProps) {\n return undefined;\n }\n const { formatProps, persistenceUnitName } = formattingProps;\n const persistenceUnit = await this._unitsProvider.findUnitByName(persistenceUnitName);\n const format = await Format.createFromJSON(\"\", this._unitsProvider, formatProps);\n return ParserSpec.create(format, this._unitsProvider, persistenceUnit);\n }\n}\n\ninterface FormattingProps {\n formatProps: FormatProps;\n persistenceUnitName: string;\n}\n\nasync function getFormattingProps(\n schemaLocater: SchemaContext,\n defaultFormats: FormatsMap | undefined,\n options: FormatOptions,\n): Promise<FormattingProps | undefined> {\n const { koqName, unitSystem } = options;\n\n const koq = await getKoq(schemaLocater, koqName);\n if (!koq) {\n return undefined;\n }\n\n const persistenceUnit = await koq.persistenceUnit;\n /* c8 ignore next 3 */\n if (!persistenceUnit) {\n return undefined;\n }\n\n const formatProps = await getKoqFormatProps(koq, persistenceUnit, defaultFormats, unitSystem);\n if (!formatProps) {\n return undefined;\n }\n\n return { formatProps, persistenceUnitName: persistenceUnit.fullName };\n}\n\nasync function getKoq(schemaLocater: SchemaContext, fullName: string) {\n const [schemaName, propKoqName] = fullName.split(\":\");\n const schema = await schemaLocater.getSchema(new SchemaKey(schemaName), SchemaMatchType.Latest);\n if (!schema) {\n return undefined;\n }\n return schema.getItem(propKoqName, KindOfQuantity);\n}\n\nasync function getKoqFormatProps(\n koq: KindOfQuantity,\n persistenceUnit: Unit | InvertedUnit,\n defaultFormats: FormatsMap | undefined,\n unitSystem?: UnitSystemKey,\n) {\n const unitSystemMatchers = getUnitSystemGroupMatchers(unitSystem);\n // use one of KOQ presentation format that matches requested unit system\n const presentationFormat = await getKoqPresentationFormat(koq, unitSystemMatchers);\n if (presentationFormat) {\n return getFormatProps(presentationFormat);\n }\n\n // use one of the formats in default formats map if there is one for matching phenomena and requested unit\n // system combination\n if (defaultFormats && unitSystem) {\n const actualPersistenceUnit = persistenceUnit instanceof InvertedUnit ? /* c8 ignore next */ await persistenceUnit.invertsUnit : persistenceUnit;\n const phenomenon = await actualPersistenceUnit?.phenomenon;\n if (phenomenon && defaultFormats[phenomenon.name.toUpperCase()]) {\n const defaultPhenomenonFormats = defaultFormats[phenomenon.name.toUpperCase()];\n for (const defaultUnitSystemFormat of Array.isArray(defaultPhenomenonFormats)\n ? /* c8 ignore next */ defaultPhenomenonFormats\n : [defaultPhenomenonFormats]) {\n if (defaultUnitSystemFormat.unitSystems.includes(unitSystem)) {\n return defaultUnitSystemFormat.format;\n }\n }\n }\n }\n\n // use persistence unit format if it matches requested unit system and matching presentation format was not found\n const persistenceUnitSystem = await persistenceUnit.unitSystem;\n if (persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {\n return getPersistenceUnitFormatProps(persistenceUnit);\n }\n\n // use default presentation format if persistence unit does not match requested unit system\n if (koq.defaultPresentationFormat) {\n return getFormatProps(await koq.defaultPresentationFormat);\n }\n\n return undefined;\n}\n\nasync function getKoqPresentationFormat(koq: KindOfQuantity, unitSystemMatchers: Array<(unitSystem: UnitSystem) => boolean>) {\n const presentationFormats = koq.presentationFormats;\n for (const matcher of unitSystemMatchers) {\n for (const lazyFormat of presentationFormats) {\n const format = await lazyFormat;\n const lazyUnit = format.units && format.units[0][0];\n /* c8 ignore next 3 */\n if (!lazyUnit) {\n continue;\n }\n const unit = await lazyUnit;\n const currentUnitSystem = await unit.unitSystem;\n if (currentUnitSystem && matcher(currentUnitSystem)) {\n return format;\n }\n }\n }\n return undefined;\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 uomSeparator: \" \",\n decimalSeparator: \".\",\n composite: {\n units: [\n {\n name: persistenceUnit.fullName,\n label: persistenceUnit.label,\n },\n ],\n },\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"]}
|
|
1
|
+
{"version":3,"file":"KoqPropertyValueFormatter.js","sourceRoot":"","sources":["../../../src/presentation-common/KoqPropertyValueFormatter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;A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,CAAC,MAAM,CAAC;YACxC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,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 Core\n */\n\nimport { assert } from \"@itwin/core-bentley\";\nimport { Format, FormatProps, FormatsProvider, FormatterSpec, ParserSpec, UnitsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\nimport { InvertedUnit, KindOfQuantity, SchemaContext, SchemaFormatsProvider, SchemaKey, SchemaMatchType, SchemaUnitProvider } from \"@itwin/ecschema-metadata\";\n\n/**\n * A data structure that associates unit systems with property value formatting props. The associations are used for\n * assigning formatting props for specific phenomenon and unit system combinations (see [[FormatsMap]]).\n *\n * @public\n *\n * @deprecated in 5.1. `FormatsMap` and related APIs have been deprecated in favor of [FormatsProvider]($core-quantity).\n */\nexport interface UnitSystemFormat {\n unitSystems: UnitSystemKey[];\n format: FormatProps;\n}\n\n/**\n * A data structure that associates specific phenomenon with one or more formatting props for specific unit system.\n *\n * Example:\n * ```json\n * {\n * length: [{\n * unitSystems: [\"metric\"],\n * format: formatForCentimeters,\n * }, {\n * unitSystems: [\"imperial\", \"usCustomary\"],\n * format: formatForInches,\n * }, {\n * unitSystems: [\"usSurvey\"],\n * format: formatForUsSurveyInches,\n * }]\n * }\n * ```\n *\n * @public\n *\n * @deprecated in 5.1. `FormatsMap` and related APIs have been deprecated in favor of [FormatsProvider]($core-quantity).\n */\nexport interface FormatsMap {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n [phenomenon: string]: UnitSystemFormat | UnitSystemFormat[];\n}\n\n/**\n * Options for finding a formatter spec to use in [[KoqPropertyValueFormatter]].\n * @public\n */\nexport interface FormatOptions {\n /** Full name of the `KindOfQuantity`, e.g. `SchemaName:KoqName`. */\n koqName: string;\n /** Unit system to use for formatting. */\n unitSystem?: UnitSystemKey;\n}\n\n/**\n * Props for creating [[KoqPropertyValueFormatter]].\n * @public\n */\ninterface KoqPropertyValueFormatterProps {\n /** Schema context to use for locating units, formats, etc. Generally retrieved through the `schemaContext` getter on an iModel. */\n schemaContext: SchemaContext;\n /** Formats provider to use for finding formatting props. Defaults to [SchemaFormatsProvider]($ecschema-metadata) when not supplied. */\n formatsProvider?: FormatsProvider;\n}\n\n/**\n * An utility for formatting property values based on `KindOfQuantity` and unit system.\n * @public\n */\nexport class KoqPropertyValueFormatter {\n private _schemaContext: SchemaContext;\n private _unitsProvider: UnitsProvider;\n private _formatsProvider?: FormatsProvider;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private _defaultFormats?: FormatsMap;\n\n /** @deprecated in 5.1. Use the overload that takes a props object. */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n constructor(schemaContext: SchemaContext, defaultFormats?: FormatsMap, formatsProvider?: FormatsProvider);\n constructor(props: KoqPropertyValueFormatterProps);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n constructor(schemaContextOrProps: SchemaContext | KoqPropertyValueFormatterProps, defaultFormats?: FormatsMap, formatsProvider?: FormatsProvider) {\n if (schemaContextOrProps instanceof SchemaContext) {\n this._schemaContext = schemaContextOrProps;\n this._formatsProvider = formatsProvider;\n this.defaultFormats = defaultFormats;\n } else {\n this._schemaContext = schemaContextOrProps.schemaContext;\n this._formatsProvider = schemaContextOrProps.formatsProvider;\n }\n this._unitsProvider = new SchemaUnitProvider(this._schemaContext);\n }\n\n /* c8 ignore start */\n /** @internal */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public get defaultFormats(): FormatsMap | undefined {\n return this._defaultFormats;\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public set defaultFormats(value: FormatsMap | undefined) {\n this._defaultFormats = value\n ? Object.entries(value).reduce((acc, [phenomenon, unitSystemFormats]) => ({ ...acc, [phenomenon.toUpperCase()]: unitSystemFormats }), {})\n : undefined;\n }\n /* c8 ignore end */\n\n public async format(value: number, options: FormatOptions) {\n const formatterSpec = await this.getFormatterSpec(options);\n if (!formatterSpec) {\n return undefined;\n }\n return formatterSpec.applyFormatting(value);\n }\n\n public async getFormatterSpec(options: FormatOptions) {\n const formattingProps = await this.#getFormattingProps(options);\n if (!formattingProps) {\n return undefined;\n }\n const { formatProps, persistenceUnitName } = formattingProps;\n const persistenceUnit = await this._unitsProvider.findUnitByName(persistenceUnitName);\n const format = await Format.createFromJSON(\"\", this._unitsProvider, formatProps);\n return FormatterSpec.create(\"\", format, this._unitsProvider, persistenceUnit);\n }\n\n public async getParserSpec(options: FormatOptions) {\n const formattingProps = await this.#getFormattingProps(options);\n if (!formattingProps) {\n return undefined;\n }\n const { formatProps, persistenceUnitName } = formattingProps;\n const persistenceUnit = await this._unitsProvider.findUnitByName(persistenceUnitName);\n const format = await Format.createFromJSON(\"\", this._unitsProvider, formatProps);\n return ParserSpec.create(format, this._unitsProvider, persistenceUnit);\n }\n\n async #getFormattingProps(options: FormatOptions): Promise<FormattingProps | undefined> {\n const { koqName } = options;\n const koq = await getKoq(this._schemaContext, koqName);\n if (!koq) {\n return undefined;\n }\n const persistenceUnit = await koq.persistenceUnit;\n assert(!!persistenceUnit);\n\n // default to metric as it's the persistence unit system\n const unitSystem = options.unitSystem ?? \"metric\";\n\n const formatsProvider = this._formatsProvider ?? new SchemaFormatsProvider(this._schemaContext, unitSystem);\n const formatProps = await formatsProvider.getFormat(koqName);\n\n // `SchemaFormatsProvider` will fall back to default presentation format, but we want to fall back\n // to default formats' map first, and only then to the default presentation format. All of this can\n // be removed with the removal of default formats map.\n if (this._defaultFormats && (!formatProps || (await getUnitSystemKey(this._unitsProvider, formatProps)) !== unitSystem)) {\n const defaultFormatProps = await getFormatPropsFromDefaultFormats({\n schemaContext: this._schemaContext,\n formatsMap: this._defaultFormats,\n unitSystem,\n koqName,\n });\n if (defaultFormatProps) {\n return { formatProps: defaultFormatProps, persistenceUnitName: persistenceUnit.fullName };\n }\n }\n\n if (formatProps) {\n return { formatProps, persistenceUnitName: persistenceUnit.fullName };\n }\n\n return undefined;\n }\n}\n\ninterface FormattingProps {\n formatProps: FormatProps;\n persistenceUnitName: string;\n}\n\nasync function getKoq(schemaLocater: SchemaContext, fullName: string) {\n const [schemaName, propKoqName] = fullName.split(\":\");\n const schema = await schemaLocater.getSchema(new SchemaKey(schemaName), SchemaMatchType.Latest);\n if (!schema) {\n return undefined;\n }\n return schema.getItem(propKoqName, KindOfQuantity);\n}\n\nasync function getUnitSystemKey(unitsProvider: UnitsProvider, formatProps: FormatProps): Promise<UnitSystemKey | undefined> {\n const unitName = formatProps.composite?.units[0].name;\n assert(!!unitName);\n const unit = await unitsProvider.findUnitByName(unitName);\n assert(!!unit);\n const [_, unitSystemName] = unit.system.split(/[\\.:]/);\n switch (unitSystemName.toUpperCase()) {\n case \"METRIC\":\n return \"metric\";\n case \"IMPERIAL\":\n return \"imperial\";\n case \"USCUSTOM\":\n return \"usCustomary\";\n case \"USSURVEY\":\n return \"usSurvey\";\n /* c8 ignore next 2 */\n default:\n return undefined;\n }\n}\n\nasync function getFormatPropsFromDefaultFormats({\n schemaContext,\n formatsMap,\n unitSystem,\n koqName,\n}: {\n schemaContext: SchemaContext;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n formatsMap: FormatsMap;\n unitSystem: UnitSystemKey;\n koqName: string;\n}): Promise<FormatProps | undefined> {\n const koq = await getKoq(schemaContext, koqName);\n /* c8 ignore next 3 */\n if (!koq) {\n return undefined;\n }\n\n const persistenceUnit = await koq.persistenceUnit;\n /* c8 ignore next 3 */\n if (!persistenceUnit) {\n return undefined;\n }\n const actualPersistenceUnit = persistenceUnit instanceof InvertedUnit ? /* c8 ignore next */ await persistenceUnit.invertsUnit : persistenceUnit;\n const phenomenon = await actualPersistenceUnit?.phenomenon;\n if (phenomenon && formatsMap[phenomenon.name.toUpperCase()]) {\n const defaultPhenomenonFormats = formatsMap[phenomenon.name.toUpperCase()];\n for (const defaultUnitSystemFormat of Array.isArray(defaultPhenomenonFormats)\n ? /* c8 ignore next */ defaultPhenomenonFormats\n : [defaultPhenomenonFormats]) {\n if (defaultUnitSystemFormat.unitSystems.includes(unitSystem)) {\n return defaultUnitSystemFormat.format;\n }\n }\n }\n return undefined;\n}\n"]}
|