@itwin/presentation-common 5.4.0-dev.6 → 5.4.0-dev.7
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 +13 -1
- package/lib/assets/locales/en/Presentation.json +19 -19
- package/lib/cjs/presentation-common/AsyncTasks.js.map +1 -1
- package/lib/cjs/presentation-common/CommonLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-common/Diagnostics.js.map +1 -1
- package/lib/cjs/presentation-common/EC.js.map +1 -1
- package/lib/cjs/presentation-common/ElementProperties.js.map +1 -1
- package/lib/cjs/presentation-common/Error.js.map +1 -1
- package/lib/cjs/presentation-common/InstanceFilterDefinition.js.map +1 -1
- package/lib/cjs/presentation-common/KeySet.js.map +1 -1
- package/lib/cjs/presentation-common/KoqPropertyValueFormatter.js.map +1 -1
- package/lib/cjs/presentation-common/LabelDefinition.js.map +1 -1
- package/lib/cjs/presentation-common/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-common/PresentationIpcInterface.js.map +1 -1
- package/lib/cjs/presentation-common/PresentationManagerOptions.js.map +1 -1
- package/lib/cjs/presentation-common/PresentationRpcInterface.js.map +1 -1
- package/lib/cjs/presentation-common/RegisteredRuleset.js.map +1 -1
- package/lib/cjs/presentation-common/RpcRequestsHandler.js.map +1 -1
- package/lib/cjs/presentation-common/RulesetVariables.js.map +1 -1
- package/lib/cjs/presentation-common/RulesetsFactory.js.map +1 -1
- package/lib/cjs/presentation-common/Update.js.map +1 -1
- package/lib/cjs/presentation-common/Utils.js.map +1 -1
- package/lib/cjs/presentation-common/content/Category.js.map +1 -1
- package/lib/cjs/presentation-common/content/Content.js.map +1 -1
- package/lib/cjs/presentation-common/content/ContentTraverser.js.map +1 -1
- package/lib/cjs/presentation-common/content/Descriptor.js.map +1 -1
- package/lib/cjs/presentation-common/content/DisplayTypes.js.map +1 -1
- package/lib/cjs/presentation-common/content/Editor.js.map +1 -1
- package/lib/cjs/presentation-common/content/Fields.js.map +1 -1
- package/lib/cjs/presentation-common/content/Item.js.map +1 -1
- package/lib/cjs/presentation-common/content/Property.js.map +1 -1
- package/lib/cjs/presentation-common/content/PropertyValueFormatter.js.map +1 -1
- package/lib/cjs/presentation-common/content/Renderer.js.map +1 -1
- package/lib/cjs/presentation-common/content/TypeDescription.js.map +1 -1
- package/lib/cjs/presentation-common/content/Value.js.map +1 -1
- package/lib/cjs/presentation-common/hierarchy/HierarchyLevel.js.map +1 -1
- package/lib/cjs/presentation-common/hierarchy/Key.js.map +1 -1
- package/lib/cjs/presentation-common/hierarchy/Node.js.map +1 -1
- package/lib/cjs/presentation-common/hierarchy/NodePathElement.js.map +1 -1
- package/lib/cjs/presentation-common/rules/ClassSpecifications.js.map +1 -1
- package/lib/cjs/presentation-common/rules/RelatedInstanceSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/RelationshipDirection.js.map +1 -1
- package/lib/cjs/presentation-common/rules/RelationshipPathSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/Rule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/Ruleset.js.map +1 -1
- package/lib/cjs/presentation-common/rules/SchemasSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/Variables.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/ContentInstancesOfSpecificClassesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/ContentRelatedInstancesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/ContentRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/ContentSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/DefaultPropertyCategoryOverride.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/PropertySpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/SelectedNodeInstancesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/CalculatedPropertiesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/ContentModifier.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/CustomRendererSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/PropertyCategorySpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/PropertyEditorsSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/RelatedPropertiesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/CustomizationRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/ExtendedDataRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/GroupingRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/InstanceLabelOverride.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/SortingRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/CustomNodeSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/NavigationRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/NodeArtifactsRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/RootNodeRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/SubCondition.js.map +1 -1
- package/lib/cjs/presentation-common/selection/SelectionScope.js.map +1 -1
- package/lib/cjs/presentation-common-internal.js.map +1 -1
- package/lib/cjs/presentation-common.js.map +1 -1
- package/lib/esm/presentation-common/AsyncTasks.js.map +1 -1
- package/lib/esm/presentation-common/CommonLoggerCategory.js.map +1 -1
- package/lib/esm/presentation-common/Diagnostics.js.map +1 -1
- package/lib/esm/presentation-common/EC.js.map +1 -1
- package/lib/esm/presentation-common/ElementProperties.js.map +1 -1
- package/lib/esm/presentation-common/Error.js.map +1 -1
- package/lib/esm/presentation-common/InstanceFilterDefinition.js.map +1 -1
- package/lib/esm/presentation-common/KeySet.js.map +1 -1
- package/lib/esm/presentation-common/KoqPropertyValueFormatter.js.map +1 -1
- package/lib/esm/presentation-common/LabelDefinition.js.map +1 -1
- package/lib/esm/presentation-common/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-common/PresentationIpcInterface.js.map +1 -1
- package/lib/esm/presentation-common/PresentationManagerOptions.js.map +1 -1
- package/lib/esm/presentation-common/PresentationRpcInterface.js.map +1 -1
- package/lib/esm/presentation-common/RegisteredRuleset.js.map +1 -1
- package/lib/esm/presentation-common/RpcRequestsHandler.js.map +1 -1
- package/lib/esm/presentation-common/RulesetVariables.js.map +1 -1
- package/lib/esm/presentation-common/RulesetsFactory.js.map +1 -1
- package/lib/esm/presentation-common/Update.js.map +1 -1
- package/lib/esm/presentation-common/Utils.js.map +1 -1
- package/lib/esm/presentation-common/content/Category.js.map +1 -1
- package/lib/esm/presentation-common/content/Content.js.map +1 -1
- package/lib/esm/presentation-common/content/ContentTraverser.js.map +1 -1
- package/lib/esm/presentation-common/content/Descriptor.js.map +1 -1
- package/lib/esm/presentation-common/content/DisplayTypes.js.map +1 -1
- package/lib/esm/presentation-common/content/Editor.js.map +1 -1
- package/lib/esm/presentation-common/content/Fields.js.map +1 -1
- package/lib/esm/presentation-common/content/Item.js.map +1 -1
- package/lib/esm/presentation-common/content/Property.js.map +1 -1
- package/lib/esm/presentation-common/content/PropertyValueFormatter.js.map +1 -1
- package/lib/esm/presentation-common/content/Renderer.js.map +1 -1
- package/lib/esm/presentation-common/content/TypeDescription.js.map +1 -1
- package/lib/esm/presentation-common/content/Value.js.map +1 -1
- package/lib/esm/presentation-common/hierarchy/HierarchyLevel.js.map +1 -1
- package/lib/esm/presentation-common/hierarchy/Key.js.map +1 -1
- package/lib/esm/presentation-common/hierarchy/Node.js.map +1 -1
- package/lib/esm/presentation-common/hierarchy/NodePathElement.js.map +1 -1
- package/lib/esm/presentation-common/rules/ClassSpecifications.js.map +1 -1
- package/lib/esm/presentation-common/rules/RelatedInstanceSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/RelationshipDirection.js.map +1 -1
- package/lib/esm/presentation-common/rules/RelationshipPathSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/Rule.js.map +1 -1
- package/lib/esm/presentation-common/rules/Ruleset.js.map +1 -1
- package/lib/esm/presentation-common/rules/SchemasSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/Variables.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/ContentInstancesOfSpecificClassesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/ContentRelatedInstancesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/ContentRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/ContentSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/DefaultPropertyCategoryOverride.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/PropertySpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/SelectedNodeInstancesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/CalculatedPropertiesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/ContentModifier.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/CustomRendererSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/PropertyCategorySpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/PropertyEditorsSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/RelatedPropertiesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/CustomizationRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/ExtendedDataRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/GroupingRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/InstanceLabelOverride.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/SortingRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/ChildNodeRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/ChildNodeSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/CustomNodeSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/NavigationRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/NodeArtifactsRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/RootNodeRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/SubCondition.js.map +1 -1
- package/lib/esm/presentation-common/selection/SelectionScope.js.map +1 -1
- package/lib/esm/presentation-common-internal.js.map +1 -1
- package/lib/esm/presentation-common.js.map +1 -1
- package/lib/public/locales/en/Presentation.json +19 -19
- package/package.json +11 -11
|
@@ -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;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,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EAAE,CAAC,CAAC;YACxC,GAAG,IAAI;YACP,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,qBAAqB,EAAE,CAAC,IAAI,CAAC,qBAAqB;SACnD,CAAC,CAAC,CAAC;IACN,CAAC;IAPe,wBAAO,UAOtB,CAAA;IAED,kFAAkF;IAClF,SAAgB,MAAM,CAAC,GAAuD,EAAE,GAAuD;QACrI,OAAO,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,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":["/*---------------------------------------------------------------------------------------------\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 Core\r\n */\r\n\r\nimport { assert, Id64String } from \"@itwin/core-bentley\";\r\nimport { FormatProps } from \"@itwin/core-quantity\";\r\nimport { parseFullClassName } from \"@itwin/presentation-shared\";\r\nimport { PartialBy } from \"./Utils.js\";\r\n\r\n/**\r\n * Type of an ECClass ID.\r\n * @public\r\n */\r\nexport type ClassId = Id64String;\r\n\r\n/**\r\n * Type of an ECInstance ID.\r\n * @public\r\n */\r\nexport type InstanceId = Id64String;\r\n\r\n/**\r\n * A key that uniquely identifies an instance in an iModel\r\n * @public\r\n */\r\nexport interface InstanceKey {\r\n /** Full class name in format `SchemaName:ClassName` */\r\n className: string;\r\n /** ECInstance ID */\r\n id: InstanceId;\r\n}\r\n\r\n/** @public */\r\nexport namespace InstanceKey {\r\n /** Compare 2 instance keys */\r\n export function compare(lhs: InstanceKey, rhs: InstanceKey): number {\r\n const lhsClass = parseFullClassName(lhs.className);\r\n const rhsClass = parseFullClassName(rhs.className);\r\n const schemaNameCompare = lhsClass.schemaName.toLowerCase().localeCompare(rhsClass.schemaName.toLowerCase());\r\n if (schemaNameCompare !== 0) {\r\n return schemaNameCompare;\r\n }\r\n const classNameCompare = lhsClass.className.toLowerCase().localeCompare(rhsClass.className.toLowerCase());\r\n if (classNameCompare !== 0) {\r\n return classNameCompare;\r\n }\r\n return lhs.id.toLowerCase().localeCompare(rhs.id.toLowerCase());\r\n }\r\n}\r\n\r\n/**\r\n * Information about an ECClass\r\n * @public\r\n */\r\nexport interface ClassInfo {\r\n /** ECClass ID */\r\n id: ClassId;\r\n /** Full class name in format `SchemaName:ClassName` */\r\n name: string;\r\n /** ECClass label */\r\n label: string;\r\n}\r\n\r\n/**\r\n * A serialized and compressed version of [[ClassInfo]]\r\n * @public\r\n */\r\nexport interface CompressedClassInfoJSON {\r\n name: string;\r\n label: string;\r\n}\r\n\r\n/**\r\n * A single choice in enumeration\r\n * @public\r\n */\r\nexport interface EnumerationChoice {\r\n /** Label of the choice */\r\n label: string;\r\n /** Value of the choice */\r\n value: string | number;\r\n}\r\n\r\n/**\r\n * Enumeration information\r\n * @public\r\n */\r\nexport interface EnumerationInfo {\r\n /** Available enumeration choices */\r\n choices: EnumerationChoice[];\r\n /** Is the enumeration strict (values only allowed from `choices` list) */\r\n isStrict: boolean;\r\n}\r\n\r\n/**\r\n * Kind of quantity information\r\n * @public\r\n */\r\nexport interface KindOfQuantityInfo {\r\n /** Full name of KindOfQuantity in format `SchemaName:KindOfQuantityName` */\r\n name: string;\r\n /** Label of KindOfQuantity */\r\n label: string;\r\n /** Persistence unit full class name in format `SchemaName:UnitName`. */\r\n persistenceUnit: string;\r\n /** Active format that was used to format property value. */\r\n activeFormat?: FormatProps;\r\n}\r\n\r\n/**\r\n * A data structure for storing navigation property information.\r\n * @public\r\n */\r\nexport interface NavigationPropertyInfo {\r\n /** Information about ECProperty's relationship class */\r\n classInfo: ClassInfo;\r\n /** Is the direction of the relationship forward */\r\n isForwardRelationship: boolean;\r\n /** Information about ECProperty's target class */\r\n targetClassInfo: ClassInfo;\r\n /** Is ECProperty's target class polymorphic */\r\n isTargetPolymorphic: boolean;\r\n}\r\n\r\n/**\r\n * Contains utilities for working with objects of [[NavigationPropertyInfo]] type.\r\n * @public\r\n */\r\nexport namespace NavigationPropertyInfo {\r\n /** Serialize [[NavigationPropertyInfo]] to compressed JSON */\r\n export function toCompressedJSON(\r\n navigationPropertyInfo: NavigationPropertyInfo,\r\n classesMap: { [id: string]: CompressedClassInfoJSON },\r\n ): NavigationPropertyInfoJSON<string> {\r\n const { id: relationshipId, ...relationshipLeftOverInfo } = navigationPropertyInfo.classInfo;\r\n const { id: targetId, ...targetLeftOverInfo } = navigationPropertyInfo.targetClassInfo;\r\n classesMap[relationshipId] = relationshipLeftOverInfo;\r\n classesMap[targetId] = targetLeftOverInfo;\r\n\r\n return {\r\n ...navigationPropertyInfo,\r\n classInfo: relationshipId,\r\n targetClassInfo: targetId,\r\n };\r\n }\r\n\r\n /** Deserialize [[NavigationPropertyInfo]] from compressed JSON */\r\n export function fromCompressedJSON(\r\n compressedNavigationPropertyInfoJSON: NavigationPropertyInfoJSON<string>,\r\n classesMap: { [id: string]: CompressedClassInfoJSON },\r\n ): NavigationPropertyInfo {\r\n return {\r\n ...compressedNavigationPropertyInfoJSON,\r\n classInfo: { id: compressedNavigationPropertyInfoJSON.classInfo, ...classesMap[compressedNavigationPropertyInfoJSON.classInfo] },\r\n targetClassInfo: { id: compressedNavigationPropertyInfoJSON.targetClassInfo, ...classesMap[compressedNavigationPropertyInfoJSON.targetClassInfo] },\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * A serialized version of [[NavigationPropertyInfo]]\r\n * @public\r\n */\r\nexport interface NavigationPropertyInfoJSON<TClassInfoJSON = ClassInfo> {\r\n classInfo: TClassInfoJSON;\r\n isForwardRelationship: boolean;\r\n targetClassInfo: TClassInfoJSON;\r\n isTargetPolymorphic: boolean;\r\n}\r\n\r\n/**\r\n * A structure that describes an ECProperty\r\n * @public\r\n */\r\nexport interface PropertyInfo {\r\n /** Information about ECProperty class */\r\n classInfo: ClassInfo;\r\n /** Name of the ECProperty */\r\n name: string;\r\n /** Type name of the ECProperty */\r\n type: string;\r\n /** Enumeration info if the property is enumerable */\r\n enumerationInfo?: EnumerationInfo;\r\n /** Kind of quantity information, if any. */\r\n kindOfQuantity?: KindOfQuantityInfo;\r\n /** Extended type name of the ECProperty if it has one */\r\n extendedType?: string;\r\n /** Navigation property info if the field is navigation type */\r\n navigationPropertyInfo?: NavigationPropertyInfo;\r\n /** Constraints for values of ECProperty */\r\n constraints?: PropertyValueConstraints;\r\n}\r\n\r\n/**\r\n * Constraints for values of ECProperty\r\n * @public\r\n */\r\nexport type PropertyValueConstraints = StringPropertyValueConstraints | ArrayPropertyValueConstraints | NumericPropertyValueConstraints;\r\n\r\n/**\r\n * Describes constraints for `string` type ECProperty values\r\n * @public\r\n */\r\nexport interface StringPropertyValueConstraints {\r\n minimumLength?: number;\r\n maximumLength?: number;\r\n}\r\n\r\n/**\r\n * Describes constraints for `int` | `double` | `float` type ECProperty values\r\n * @public\r\n */\r\nexport interface NumericPropertyValueConstraints {\r\n minimumValue?: number;\r\n maximumValue?: number;\r\n}\r\n\r\n/**\r\n * Describes constraints for `array` type ECProperty values\r\n * @public\r\n */\r\nexport interface ArrayPropertyValueConstraints {\r\n minOccurs?: number;\r\n maxOccurs?: number;\r\n}\r\n\r\n/** @public */\r\nexport namespace PropertyInfo {\r\n /** Serialize [[PropertyInfo]] to compressed JSON */\r\n export function toCompressedJSON(propertyInfo: PropertyInfo, classesMap: { [id: string]: CompressedClassInfoJSON }): PropertyInfoJSON<string> {\r\n const { navigationPropertyInfo, ...leftOverPropertyInfo } = propertyInfo;\r\n const { id, ...leftOverInfo } = propertyInfo.classInfo;\r\n classesMap[id] = leftOverInfo;\r\n\r\n return {\r\n ...leftOverPropertyInfo,\r\n classInfo: propertyInfo.classInfo.id,\r\n ...(navigationPropertyInfo ? { navigationPropertyInfo: NavigationPropertyInfo.toCompressedJSON(navigationPropertyInfo, classesMap) } : undefined),\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * A serialized version of [[PropertyInfo]]\r\n * @public\r\n */\r\nexport interface PropertyInfoJSON<TClassInfoJSON = ClassInfo> {\r\n classInfo: TClassInfoJSON;\r\n name: string;\r\n type: string;\r\n enumerationInfo?: EnumerationInfo;\r\n kindOfQuantity?: KindOfQuantityInfo;\r\n navigationPropertyInfo?: NavigationPropertyInfoJSON<TClassInfoJSON>;\r\n}\r\n\r\n/**\r\n * A structure that describes a related class and the properties of that relationship.\r\n * @public\r\n */\r\nexport interface RelatedClassInfo {\r\n /** Information about the source ECClass */\r\n sourceClassInfo: ClassInfo;\r\n\r\n /** Information about the target ECClass */\r\n targetClassInfo: ClassInfo;\r\n\r\n /** Is target class handled polymorphically */\r\n isPolymorphicTargetClass?: boolean;\r\n\r\n /** Optionally, IDs of specific target class instances. */\r\n targetInstanceIds?: Id64String[];\r\n\r\n /** Information about the ECRelationship */\r\n relationshipInfo: ClassInfo;\r\n\r\n /** Should relationship be followed in a forward direction to access the related class. */\r\n isForwardRelationship: boolean;\r\n\r\n /** Is relationship handled polymorphically */\r\n isPolymorphicRelationship?: boolean;\r\n}\r\n\r\n/** @public */\r\nexport namespace RelatedClassInfo {\r\n /** Serialize [[RelatedClassInfo]] to compressed JSON */\r\n export function toCompressedJSON(classInfo: RelatedClassInfo, classesMap: { [id: string]: CompressedClassInfoJSON }): RelatedClassInfoJSON<string> {\r\n const { id: sourceId, ...sourceLeftOverInfo } = classInfo.sourceClassInfo;\r\n const { id: targetId, ...targetLeftOverInfo } = classInfo.targetClassInfo;\r\n const { id: relationshipId, ...relationshipLeftOverInfo } = classInfo.relationshipInfo;\r\n\r\n classesMap[sourceId] = sourceLeftOverInfo;\r\n classesMap[targetId] = targetLeftOverInfo;\r\n classesMap[relationshipId] = relationshipLeftOverInfo;\r\n\r\n return {\r\n ...classInfo,\r\n sourceClassInfo: sourceId,\r\n targetClassInfo: targetId,\r\n relationshipInfo: relationshipId,\r\n };\r\n }\r\n\r\n /** Deserialize [[RelatedClassInfo]] from compressed JSON */\r\n export function fromCompressedJSON(json: RelatedClassInfoJSON<string>, classesMap: { [id: string]: CompressedClassInfoJSON }): RelatedClassInfo {\r\n assert(classesMap.hasOwnProperty(json.sourceClassInfo));\r\n assert(classesMap.hasOwnProperty(json.targetClassInfo));\r\n assert(classesMap.hasOwnProperty(json.relationshipInfo));\r\n return {\r\n ...json,\r\n sourceClassInfo: { id: json.sourceClassInfo, ...classesMap[json.sourceClassInfo] },\r\n targetClassInfo: { id: json.targetClassInfo, ...classesMap[json.targetClassInfo] },\r\n relationshipInfo: { id: json.relationshipInfo, ...classesMap[json.relationshipInfo] },\r\n };\r\n }\r\n\r\n /** Check two [[RelatedClassInfo]] or [[StrippedRelatedClassInfo]] for equality */\r\n export function equals(lhs: RelatedClassInfo | StrippedRelatedClassInfo, rhs: RelatedClassInfo | StrippedRelatedClassInfo): boolean {\r\n return (\r\n lhs.isForwardRelationship === rhs.isForwardRelationship &&\r\n getClassName(lhs, \"source\") === getClassName(rhs, \"source\") &&\r\n getClassName(lhs, \"target\") === getClassName(rhs, \"target\") &&\r\n getClassName(lhs, \"relationship\") === getClassName(rhs, \"relationship\")\r\n );\r\n }\r\n\r\n function isStripped(info: RelatedClassInfo | StrippedRelatedClassInfo): info is StrippedRelatedClassInfo {\r\n const maybeStripped = info as StrippedRelatedClassInfo;\r\n return !!maybeStripped.relationshipName && !!maybeStripped.sourceClassName && !!maybeStripped.targetClassName;\r\n }\r\n\r\n function getClassName(info: RelatedClassInfo | StrippedRelatedClassInfo, whichClass: \"relationship\" | \"source\" | \"target\"): string {\r\n switch (whichClass) {\r\n case \"source\":\r\n return isStripped(info) ? info.sourceClassName : info.sourceClassInfo.name;\r\n case \"target\":\r\n return isStripped(info) ? info.targetClassName : info.targetClassInfo.name;\r\n case \"relationship\":\r\n return isStripped(info) ? info.relationshipName : info.relationshipInfo.name;\r\n }\r\n }\r\n\r\n /** Strip given [[RelatedClassInfo]] to [[StrippedRelatedClassInfo]] */\r\n export function strip(full: RelatedClassInfo): StrippedRelatedClassInfo {\r\n return {\r\n sourceClassName: full.sourceClassInfo.name,\r\n targetClassName: full.targetClassInfo.name,\r\n relationshipName: full.relationshipInfo.name,\r\n isForwardRelationship: full.isForwardRelationship,\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * A serialized version of [[RelatedClassInfo]]\r\n * @public\r\n */\r\nexport interface RelatedClassInfoJSON<TClassInfoJSON = ClassInfo> {\r\n sourceClassInfo: TClassInfoJSON;\r\n targetClassInfo: TClassInfoJSON;\r\n isPolymorphicTargetClass?: boolean;\r\n targetInstanceIds?: Id64String[];\r\n relationshipInfo: TClassInfoJSON;\r\n isForwardRelationship: boolean;\r\n isPolymorphicRelationship?: boolean;\r\n}\r\n\r\n/**\r\n * A structure that describes a relationship between source and target classes where\r\n * an actual ECRelationship between them is optional.\r\n * @public\r\n */\r\nexport type RelatedClassInfoWithOptionalRelationship = PartialBy<RelatedClassInfo, \"relationshipInfo\" | \"isForwardRelationship\" | \"isPolymorphicRelationship\">;\r\n\r\n/** @public */\r\nexport type RelatedClassInfoWithOptionalRelationshipJSON<TClassInfoJSON = ClassInfo> = PartialBy<\r\n RelatedClassInfoJSON<TClassInfoJSON>,\r\n \"relationshipInfo\" | \"isForwardRelationship\" | \"isPolymorphicRelationship\"\r\n>;\r\n\r\n/** @public */\r\n// eslint-disable-next-line @typescript-eslint/no-redeclare\r\nexport namespace RelatedClassInfoWithOptionalRelationship {\r\n /** Serialize [[RelatedClassInfoWithOptionalRelationship]] to compressed JSON */\r\n export function toCompressedJSON(\r\n classInfo: RelatedClassInfoWithOptionalRelationship,\r\n classesMap: { [id: string]: CompressedClassInfoJSON },\r\n ): RelatedClassInfoWithOptionalRelationshipJSON<string> {\r\n const { sourceClassInfo, targetClassInfo, relationshipInfo, ...otherProps } = classInfo;\r\n const { id: sourceId, ...sourceLeftOverInfo } = sourceClassInfo;\r\n const { id: targetId, ...targetLeftOverInfo } = targetClassInfo;\r\n\r\n classesMap[sourceId] = sourceLeftOverInfo;\r\n classesMap[targetId] = targetLeftOverInfo;\r\n\r\n if (relationshipInfo) {\r\n const { id: relationshipId, ...relationshipLeftOverInfo } = relationshipInfo;\r\n classesMap[relationshipId] = relationshipLeftOverInfo;\r\n }\r\n\r\n return {\r\n ...otherProps,\r\n sourceClassInfo: sourceId,\r\n targetClassInfo: targetId,\r\n ...(relationshipInfo ? { relationshipInfo: relationshipInfo.id } : undefined),\r\n };\r\n }\r\n\r\n /** Deserialize [[RelatedClassInfoWithOptionalRelationship]] from compressed JSON */\r\n export function fromCompressedJSON(\r\n json: RelatedClassInfoWithOptionalRelationshipJSON<string>,\r\n classesMap: { [id: string]: CompressedClassInfoJSON },\r\n ): RelatedClassInfoWithOptionalRelationship {\r\n const { sourceClassInfo, targetClassInfo, relationshipInfo, ...otherProps } = json;\r\n assert(classesMap.hasOwnProperty(sourceClassInfo));\r\n assert(classesMap.hasOwnProperty(targetClassInfo));\r\n if (relationshipInfo) {\r\n assert(classesMap.hasOwnProperty(relationshipInfo));\r\n }\r\n return {\r\n ...otherProps,\r\n sourceClassInfo: { id: sourceClassInfo, ...classesMap[sourceClassInfo] },\r\n targetClassInfo: { id: targetClassInfo, ...classesMap[targetClassInfo] },\r\n ...(relationshipInfo ? { relationshipInfo: { id: relationshipInfo, ...classesMap[relationshipInfo] } } : undefined),\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * A structure that describes a related class path.\r\n * @public\r\n */\r\nexport type RelationshipPath = RelatedClassInfo[];\r\n\r\n/**\r\n * Serialized [[RelationshipPath]]\r\n * @public\r\n */\r\nexport type RelationshipPathJSON<TClassInfoJSON = ClassInfo> = RelatedClassInfoJSON<TClassInfoJSON>[];\r\n\r\n/** @public */\r\n// eslint-disable-next-line @typescript-eslint/no-redeclare\r\nexport namespace RelationshipPath {\r\n /** Reverse direction of the given [[RelationshipPath]] */\r\n export function reverse(path: RelationshipPath): RelationshipPath {\r\n return [...path].reverse().map((step) => ({\r\n ...step,\r\n sourceClassInfo: step.targetClassInfo,\r\n targetClassInfo: step.sourceClassInfo,\r\n isForwardRelationship: !step.isForwardRelationship,\r\n }));\r\n }\r\n\r\n /** Check two [[RelationshipPath]] or [[StrippedRelationshipPath]] for equality */\r\n export function equals(lhs: Array<RelatedClassInfo | StrippedRelatedClassInfo>, rhs: Array<RelatedClassInfo | StrippedRelatedClassInfo>): boolean {\r\n return lhs.length === rhs.length && lhs.every((lhsPart, i) => RelatedClassInfo.equals(lhsPart, rhs[i]));\r\n }\r\n\r\n /** Strip given [[RelationshipPath]] to [[StrippedRelationshipPath]] */\r\n export function strip(full: RelationshipPath): StrippedRelationshipPath {\r\n return full.map(RelatedClassInfo.strip);\r\n }\r\n}\r\n\r\n/**\r\n * Data structure that contains a subset of [[RelatedClassInfo]] required to\r\n * identify the relationship.\r\n * @public\r\n */\r\nexport interface StrippedRelatedClassInfo {\r\n sourceClassName: string;\r\n targetClassName: string;\r\n relationshipName: string;\r\n isForwardRelationship: boolean;\r\n}\r\n\r\n/**\r\n * Data structure that contains a subset of [[RelationshipPath]] required to\r\n * identify the relationship path.\r\n * @public\r\n */\r\nexport type StrippedRelationshipPath = StrippedRelatedClassInfo[];\r\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,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;AACd,2DAA2D;AAC3D,MAAM,KAAW,gBAAgB,CAoBhC;AApBD,WAAiB,gBAAgB;IAC/B,0DAA0D;IAC1D,SAAgB,OAAO,CAAC,IAAsB;QAC5C,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACxC,GAAG,IAAI;YACP,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,qBAAqB,EAAE,CAAC,IAAI,CAAC,qBAAqB;SACnD,CAAC,CAAC,CAAC;IACN,CAAC;IAPe,wBAAO,UAOtB,CAAA;IAED,kFAAkF;IAClF,SAAgB,MAAM,CAAC,GAAuD,EAAE,GAAuD;QACrI,OAAO,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementProperties.js","sourceRoot":"","sources":["../../../src/presentation-common/ElementProperties.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAWL,mBAAmB,GACpB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AA8HnE,gBAAgB;AAChB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,UAAsB,EAAE,IAAU,EAAqB,EAAE;IAC9F,MAAM,OAAO,GAAG,IAAI,wBAAwB,EAAE,CAAC;IAC/C,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC,CAAC;AAOF,MAAM,yBAAyB;IAInB;IACA;IAJF,cAAc,GAA+C,EAAE,CAAC;IAChE,sBAAsB,GAAoD,EAAE,CAAC;IACrF,YACU,KAAW,EACX,eAAkD;QADlD,UAAK,GAAL,KAAK,CAAM;QACX,oBAAe,GAAf,eAAe,CAAmC;IACzD,CAAC;IAEG,MAAM,CAAC,KAAa,EAAE,IAA2B;QACtD,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACpC,CAAC;IAEM,MAAM;QACX,wCAAwC;QACxC,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;YACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAC;YAC3D,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpB,CAAC;QAED,IAAI,CAAC,eAAe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C,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC;IACd,CAAC;IACM,YAAY;QACjB,IAAI,CAAC,eAAe,CAAC,GAAG,EAAG,CAAC,MAAM,EAAE,CAAC;IACvC,CAAC;IAEM,UAAU,CAAC,KAAsB;QACtC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IACM,WAAW;QAChB,IAAI,CAAC,eAAe,CAAC,GAAG,EAAG,CAAC,MAAM,EAAE,CAAC;IACvC,CAAC;IAEM,kBAAkB,CAAC,KAA8B;QACtD,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE;YACpD,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,EAAE;SACV,CAAC,CAAC;IACL,CAAC;IACM,qBAAqB,CAAC,KAAiC;QAC5D,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE;YAC9C,IAAI,EAAE,WAAW;YACjB,gEAAgE;YAChE,KAAK,EAAE,KAAK,CAAC,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC5C,CAAC,CAAC;IACL,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 RPC\r\n */\r\n\r\nimport { assert, Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { CategoryDescription } from \"./content/Category.js\";\r\nimport {\r\n IContentVisitor,\r\n ProcessFieldHierarchiesProps,\r\n ProcessMergedValueProps,\r\n ProcessPrimitiveValueProps,\r\n StartArrayProps,\r\n StartCategoryProps,\r\n StartContentProps,\r\n StartFieldProps,\r\n StartItemProps,\r\n StartStructProps,\r\n traverseContentItem,\r\n} from \"./content/ContentTraverser.js\";\r\nimport { Descriptor } from \"./content/Descriptor.js\";\r\nimport { Item } from \"./content/Item.js\";\r\nimport { PropertyValueFormat } from \"./content/TypeDescription.js\";\r\n\r\n/**\r\n * Data structure for storing element properties information in a simplified format.\r\n * @see [[Content]] for a format that stores all available element property data.\r\n * @public\r\n */\r\nexport interface ElementProperties {\r\n /** Label of element's ECClass. */\r\n class: string;\r\n /** Element's ID. */\r\n id: Id64String;\r\n /** Element's label. */\r\n label: string;\r\n /** Container of property values */\r\n items: { [label: string]: ElementPropertiesItem };\r\n}\r\n\r\n/**\r\n * Base type for all [[ElementPropertiesItem]] types.\r\n * @public\r\n */\r\nexport interface ElementPropertiesItemBase {\r\n /** Type of the properties item. */\r\n type: \"category\" | ElementPropertiesPropertyValueType;\r\n}\r\n\r\n/**\r\n * Definition for a category. A category can nest other property items, including categories.\r\n * @public\r\n */\r\nexport interface ElementPropertiesCategoryItem extends ElementPropertiesItemBase {\r\n /** Type of the properties item. */\r\n type: \"category\";\r\n /** Container of property values */\r\n items: { [label: string]: ElementPropertiesItem };\r\n}\r\n\r\n/**\r\n * Base type for all [[ElementPropertiesPropertyItem]] types.\r\n * @public\r\n */\r\nexport interface ElementPropertiesPropertyItemBase extends ElementPropertiesItemBase {\r\n /** Type of the properties item. */\r\n type: ElementPropertiesPropertyValueType;\r\n}\r\n\r\n/**\r\n * Definition for a primitive property value.\r\n * @public\r\n */\r\nexport interface ElementPropertiesPrimitivePropertyItem extends ElementPropertiesPropertyItemBase {\r\n /** Type of the properties item. */\r\n type: \"primitive\";\r\n /** Display value of the property. */\r\n value: string;\r\n}\r\n\r\n/**\r\n * Base type for all [[ElementPropertiesArrayPropertyItem]] types.\r\n * @public\r\n */\r\nexport interface ElementPropertiesArrayPropertyItemBase extends ElementPropertiesPropertyItemBase {\r\n /** Type of the properties item. */\r\n type: \"array\";\r\n /** Type of values contained in this array. */\r\n valueType: \"primitive\" | \"struct\";\r\n}\r\n\r\n/**\r\n * Definition for a primitives' array property value.\r\n * @public\r\n */\r\nexport interface ElementPropertiesPrimitiveArrayPropertyItem extends ElementPropertiesArrayPropertyItemBase {\r\n /** Type of values contained in this array. */\r\n valueType: \"primitive\";\r\n /** Array of display values. */\r\n values: string[];\r\n}\r\n\r\n/**\r\n * Definition for a structs' array property value.\r\n * @public\r\n */\r\nexport interface ElementPropertiesStructArrayPropertyItem extends ElementPropertiesArrayPropertyItemBase {\r\n /** Type of values contained in this array. */\r\n valueType: \"struct\";\r\n /** Array of structs. */\r\n values: Array<{ [memberLabel: string]: ElementPropertiesPropertyItem }>;\r\n}\r\n\r\n/**\r\n * Definition for an array property value.\r\n * @public\r\n */\r\nexport type ElementPropertiesArrayPropertyItem = ElementPropertiesPrimitiveArrayPropertyItem | ElementPropertiesStructArrayPropertyItem;\r\n\r\n/**\r\n * Definition for an struct property value.\r\n * @public\r\n */\r\nexport interface ElementPropertiesStructPropertyItem extends ElementPropertiesPropertyItemBase {\r\n /** Type of the properties item. */\r\n type: \"struct\";\r\n /** Container of struct members. */\r\n members: { [memberLabel: string]: ElementPropertiesPropertyItem };\r\n}\r\n\r\n/**\r\n * Available element property types.\r\n * @public\r\n */\r\nexport type ElementPropertiesPropertyValueType = \"primitive\" | \"array\" | \"struct\";\r\n\r\n/**\r\n * Definition of a property value.\r\n * @public\r\n */\r\nexport type ElementPropertiesPropertyItem = ElementPropertiesPrimitivePropertyItem | ElementPropertiesArrayPropertyItem | ElementPropertiesStructPropertyItem;\r\n\r\n/**\r\n * Definition of a property item, including a property category.\r\n * @public\r\n */\r\nexport type ElementPropertiesItem = ElementPropertiesCategoryItem | ElementPropertiesPropertyItem;\r\n\r\n/** @internal */\r\nexport const buildElementProperties = (descriptor: Descriptor, item: Item): ElementProperties => {\r\n const builder = new ElementPropertiesBuilder();\r\n traverseContentItem(builder, descriptor, item);\r\n return builder.items[0];\r\n};\r\n\r\ninterface IPropertiesAppender {\r\n append(label: string, item: ElementPropertiesItem): void;\r\n finish(): void;\r\n}\r\n\r\nclass ElementPropertiesAppender implements IPropertiesAppender {\r\n private _propertyItems: { [label: string]: ElementPropertiesItem } = {};\r\n private _categoryItemAppenders: { [categoryName: string]: IPropertiesAppender } = {};\r\n constructor(\r\n private _item: Item,\r\n private _onItemFinished: (item: ElementProperties) => void,\r\n ) {}\r\n\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n this._propertyItems[label] = item;\r\n }\r\n\r\n public finish(): void {\r\n // eslint-disable-next-line guard-for-in\r\n for (const categoryName in this._categoryItemAppenders) {\r\n const appender = this._categoryItemAppenders[categoryName];\r\n appender.finish();\r\n }\r\n\r\n this._onItemFinished({\r\n class: this._item.classInfo?.label ?? \"\",\r\n id: this._item.primaryKeys[0]?.id ?? Id64.invalid,\r\n label: this._item.label.displayValue,\r\n items: this._propertyItems,\r\n });\r\n }\r\n\r\n public getCategoryAppender(parentAppender: IPropertiesAppender, category: CategoryDescription): IPropertiesAppender {\r\n let appender = this._categoryItemAppenders[category.name];\r\n if (!appender) {\r\n appender = new CategoryItemAppender(parentAppender, category);\r\n this._categoryItemAppenders[category.name] = appender;\r\n }\r\n return appender;\r\n }\r\n}\r\n\r\nclass CategoryItemAppender implements IPropertiesAppender {\r\n private _items: { [label: string]: ElementPropertiesItem } = {};\r\n constructor(\r\n private _parentAppender: IPropertiesAppender,\r\n private _category: CategoryDescription,\r\n ) {}\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n this._items[label] = item;\r\n }\r\n public finish(): void {\r\n if (Object.keys(this._items).length === 0) {\r\n return;\r\n }\r\n\r\n this._parentAppender.append(this._category.label, {\r\n type: \"category\",\r\n items: this._items,\r\n });\r\n }\r\n}\r\n\r\nclass ArrayItemAppender implements IPropertiesAppender {\r\n private _items: ElementPropertiesPropertyItem[] = [];\r\n constructor(\r\n private _parentAppender: IPropertiesAppender,\r\n private _props: StartArrayProps,\r\n ) {}\r\n public append(_label: string, item: ElementPropertiesItem): void {\r\n assert(item.type !== \"category\");\r\n this._items.push(item);\r\n }\r\n public finish(): void {\r\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Array);\r\n if (this._props.valueType.memberType.valueFormat === PropertyValueFormat.Primitive) {\r\n this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());\r\n } else {\r\n this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());\r\n }\r\n }\r\n private createPrimitivesArray(): ElementPropertiesPrimitiveArrayPropertyItem {\r\n return {\r\n type: \"array\",\r\n valueType: \"primitive\",\r\n values: this._items.map((item) => {\r\n assert(item.type === \"primitive\");\r\n return item.value;\r\n }),\r\n };\r\n }\r\n private createStructsArray(): ElementPropertiesStructArrayPropertyItem {\r\n return {\r\n type: \"array\",\r\n valueType: \"struct\",\r\n values: this._items.map((item) => {\r\n assert(item.type === \"struct\");\r\n return item.members;\r\n }),\r\n };\r\n }\r\n}\r\n\r\nclass StructItemAppender implements IPropertiesAppender {\r\n private _members: { [label: string]: ElementPropertiesPropertyItem } = {};\r\n constructor(\r\n private _parentAppender: IPropertiesAppender,\r\n private _props: StartStructProps,\r\n ) {}\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n assert(item.type !== \"category\");\r\n this._members[label] = item;\r\n }\r\n public finish(): void {\r\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Struct);\r\n this._parentAppender.append(this._props.hierarchy.field.label, {\r\n type: \"struct\",\r\n members: this._members,\r\n });\r\n }\r\n}\r\n\r\nclass ElementPropertiesBuilder implements IContentVisitor {\r\n private _appendersStack: IPropertiesAppender[] = [];\r\n private _items: ElementProperties[] = [];\r\n private _elementPropertiesAppender: ElementPropertiesAppender | undefined;\r\n\r\n public get items(): ElementProperties[] {\r\n return this._items;\r\n }\r\n\r\n private get _currentAppender(): IPropertiesAppender {\r\n const appender = this._appendersStack[this._appendersStack.length - 1];\r\n assert(appender !== undefined);\r\n return appender;\r\n }\r\n\r\n public startContent(_props: StartContentProps): boolean {\r\n return true;\r\n }\r\n public finishContent(): void {}\r\n\r\n public processFieldHierarchies(_props: ProcessFieldHierarchiesProps): void {}\r\n\r\n public startItem(props: StartItemProps): boolean {\r\n this._elementPropertiesAppender = new ElementPropertiesAppender(props.item, (item) => this._items.push(item));\r\n this._appendersStack.push(this._elementPropertiesAppender);\r\n return true;\r\n }\r\n public finishItem(): void {\r\n this._appendersStack.pop();\r\n assert(this._elementPropertiesAppender !== undefined);\r\n this._elementPropertiesAppender.finish();\r\n this._elementPropertiesAppender = undefined;\r\n }\r\n\r\n public startCategory(props: StartCategoryProps): boolean {\r\n assert(this._elementPropertiesAppender !== undefined);\r\n this._appendersStack.push(this._elementPropertiesAppender.getCategoryAppender(this._currentAppender, props.category));\r\n return true;\r\n }\r\n public finishCategory(): void {\r\n this._appendersStack.pop();\r\n }\r\n\r\n public startField(_props: StartFieldProps): boolean {\r\n return true;\r\n }\r\n public finishField(): void {}\r\n\r\n public startStruct(props: StartStructProps): boolean {\r\n this._appendersStack.push(new StructItemAppender(this._currentAppender, props));\r\n return true;\r\n }\r\n public finishStruct(): void {\r\n this._appendersStack.pop()!.finish();\r\n }\r\n\r\n public startArray(props: StartArrayProps): boolean {\r\n this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));\r\n return true;\r\n }\r\n public finishArray(): void {\r\n this._appendersStack.pop()!.finish();\r\n }\r\n\r\n public processMergedValue(props: ProcessMergedValueProps): void {\r\n this._currentAppender.append(props.mergedField.label, {\r\n type: \"primitive\",\r\n value: \"\",\r\n });\r\n }\r\n public processPrimitiveValue(props: ProcessPrimitiveValueProps): void {\r\n this._currentAppender.append(props.field.label, {\r\n type: \"primitive\",\r\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\r\n value: props.displayValue?.toString() ?? \"\",\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ElementProperties.js","sourceRoot":"","sources":["../../../src/presentation-common/ElementProperties.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C,KAAsB;QACtC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IACM,WAAW;QAChB,IAAI,CAAC,eAAe,CAAC,GAAG,EAAG,CAAC,MAAM,EAAE,CAAC;IACvC,CAAC;IAEM,kBAAkB,CAAC,KAA8B;QACtD,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE;YACpD,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,EAAE;SACV,CAAC,CAAC;IACL,CAAC;IACM,qBAAqB,CAAC,KAAiC;QAC5D,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE;YAC9C,IAAI,EAAE,WAAW;YACjB,gEAAgE;YAChE,KAAK,EAAE,KAAK,CAAC,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC5C,CAAC,CAAC;IACL,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 RPC\n */\n\nimport { assert, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { CategoryDescription } from \"./content/Category.js\";\nimport {\n IContentVisitor,\n ProcessFieldHierarchiesProps,\n ProcessMergedValueProps,\n ProcessPrimitiveValueProps,\n StartArrayProps,\n StartCategoryProps,\n StartContentProps,\n StartFieldProps,\n StartItemProps,\n StartStructProps,\n traverseContentItem,\n} from \"./content/ContentTraverser.js\";\nimport { Descriptor } from \"./content/Descriptor.js\";\nimport { Item } from \"./content/Item.js\";\nimport { PropertyValueFormat } from \"./content/TypeDescription.js\";\n\n/**\n * Data structure for storing element properties information in a simplified format.\n * @see [[Content]] for a format that stores all available element property data.\n * @public\n */\nexport interface ElementProperties {\n /** Label of element's ECClass. */\n class: string;\n /** Element's ID. */\n id: Id64String;\n /** Element's label. */\n label: string;\n /** Container of property values */\n items: { [label: string]: ElementPropertiesItem };\n}\n\n/**\n * Base type for all [[ElementPropertiesItem]] types.\n * @public\n */\nexport interface ElementPropertiesItemBase {\n /** Type of the properties item. */\n type: \"category\" | ElementPropertiesPropertyValueType;\n}\n\n/**\n * Definition for a category. A category can nest other property items, including categories.\n * @public\n */\nexport interface ElementPropertiesCategoryItem extends ElementPropertiesItemBase {\n /** Type of the properties item. */\n type: \"category\";\n /** Container of property values */\n items: { [label: string]: ElementPropertiesItem };\n}\n\n/**\n * Base type for all [[ElementPropertiesPropertyItem]] types.\n * @public\n */\nexport interface ElementPropertiesPropertyItemBase extends ElementPropertiesItemBase {\n /** Type of the properties item. */\n type: ElementPropertiesPropertyValueType;\n}\n\n/**\n * Definition for a primitive property value.\n * @public\n */\nexport interface ElementPropertiesPrimitivePropertyItem extends ElementPropertiesPropertyItemBase {\n /** Type of the properties item. */\n type: \"primitive\";\n /** Display value of the property. */\n value: string;\n}\n\n/**\n * Base type for all [[ElementPropertiesArrayPropertyItem]] types.\n * @public\n */\nexport interface ElementPropertiesArrayPropertyItemBase extends ElementPropertiesPropertyItemBase {\n /** Type of the properties item. */\n type: \"array\";\n /** Type of values contained in this array. */\n valueType: \"primitive\" | \"struct\";\n}\n\n/**\n * Definition for a primitives' array property value.\n * @public\n */\nexport interface ElementPropertiesPrimitiveArrayPropertyItem extends ElementPropertiesArrayPropertyItemBase {\n /** Type of values contained in this array. */\n valueType: \"primitive\";\n /** Array of display values. */\n values: string[];\n}\n\n/**\n * Definition for a structs' array property value.\n * @public\n */\nexport interface ElementPropertiesStructArrayPropertyItem extends ElementPropertiesArrayPropertyItemBase {\n /** Type of values contained in this array. */\n valueType: \"struct\";\n /** Array of structs. */\n values: Array<{ [memberLabel: string]: ElementPropertiesPropertyItem }>;\n}\n\n/**\n * Definition for an array property value.\n * @public\n */\nexport type ElementPropertiesArrayPropertyItem = ElementPropertiesPrimitiveArrayPropertyItem | ElementPropertiesStructArrayPropertyItem;\n\n/**\n * Definition for an struct property value.\n * @public\n */\nexport interface ElementPropertiesStructPropertyItem extends ElementPropertiesPropertyItemBase {\n /** Type of the properties item. */\n type: \"struct\";\n /** Container of struct members. */\n members: { [memberLabel: string]: ElementPropertiesPropertyItem };\n}\n\n/**\n * Available element property types.\n * @public\n */\nexport type ElementPropertiesPropertyValueType = \"primitive\" | \"array\" | \"struct\";\n\n/**\n * Definition of a property value.\n * @public\n */\nexport type ElementPropertiesPropertyItem = ElementPropertiesPrimitivePropertyItem | ElementPropertiesArrayPropertyItem | ElementPropertiesStructPropertyItem;\n\n/**\n * Definition of a property item, including a property category.\n * @public\n */\nexport type ElementPropertiesItem = ElementPropertiesCategoryItem | ElementPropertiesPropertyItem;\n\n/** @internal */\nexport const buildElementProperties = (descriptor: Descriptor, item: Item): ElementProperties => {\n const builder = new ElementPropertiesBuilder();\n traverseContentItem(builder, descriptor, item);\n return builder.items[0];\n};\n\ninterface IPropertiesAppender {\n append(label: string, item: ElementPropertiesItem): void;\n finish(): void;\n}\n\nclass ElementPropertiesAppender implements IPropertiesAppender {\n private _propertyItems: { [label: string]: ElementPropertiesItem } = {};\n private _categoryItemAppenders: { [categoryName: string]: IPropertiesAppender } = {};\n constructor(\n private _item: Item,\n private _onItemFinished: (item: ElementProperties) => void,\n ) {}\n\n public append(label: string, item: ElementPropertiesItem): void {\n this._propertyItems[label] = item;\n }\n\n public finish(): void {\n // eslint-disable-next-line guard-for-in\n for (const categoryName in this._categoryItemAppenders) {\n const appender = this._categoryItemAppenders[categoryName];\n appender.finish();\n }\n\n this._onItemFinished({\n class: this._item.classInfo?.label ?? \"\",\n id: this._item.primaryKeys[0]?.id ?? Id64.invalid,\n label: this._item.label.displayValue,\n items: this._propertyItems,\n });\n }\n\n public getCategoryAppender(parentAppender: IPropertiesAppender, category: CategoryDescription): IPropertiesAppender {\n let appender = this._categoryItemAppenders[category.name];\n if (!appender) {\n appender = new CategoryItemAppender(parentAppender, category);\n this._categoryItemAppenders[category.name] = appender;\n }\n return appender;\n }\n}\n\nclass CategoryItemAppender implements IPropertiesAppender {\n private _items: { [label: string]: ElementPropertiesItem } = {};\n constructor(\n private _parentAppender: IPropertiesAppender,\n private _category: CategoryDescription,\n ) {}\n public append(label: string, item: ElementPropertiesItem): void {\n this._items[label] = item;\n }\n public finish(): void {\n if (Object.keys(this._items).length === 0) {\n return;\n }\n\n this._parentAppender.append(this._category.label, {\n type: \"category\",\n items: this._items,\n });\n }\n}\n\nclass ArrayItemAppender implements IPropertiesAppender {\n private _items: ElementPropertiesPropertyItem[] = [];\n constructor(\n private _parentAppender: IPropertiesAppender,\n private _props: StartArrayProps,\n ) {}\n public append(_label: string, item: ElementPropertiesItem): void {\n assert(item.type !== \"category\");\n this._items.push(item);\n }\n public finish(): void {\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Array);\n if (this._props.valueType.memberType.valueFormat === PropertyValueFormat.Primitive) {\n this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());\n } else {\n this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());\n }\n }\n private createPrimitivesArray(): ElementPropertiesPrimitiveArrayPropertyItem {\n return {\n type: \"array\",\n valueType: \"primitive\",\n values: this._items.map((item) => {\n assert(item.type === \"primitive\");\n return item.value;\n }),\n };\n }\n private createStructsArray(): ElementPropertiesStructArrayPropertyItem {\n return {\n type: \"array\",\n valueType: \"struct\",\n values: this._items.map((item) => {\n assert(item.type === \"struct\");\n return item.members;\n }),\n };\n }\n}\n\nclass StructItemAppender implements IPropertiesAppender {\n private _members: { [label: string]: ElementPropertiesPropertyItem } = {};\n constructor(\n private _parentAppender: IPropertiesAppender,\n private _props: StartStructProps,\n ) {}\n public append(label: string, item: ElementPropertiesItem): void {\n assert(item.type !== \"category\");\n this._members[label] = item;\n }\n public finish(): void {\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Struct);\n this._parentAppender.append(this._props.hierarchy.field.label, {\n type: \"struct\",\n members: this._members,\n });\n }\n}\n\nclass ElementPropertiesBuilder implements IContentVisitor {\n private _appendersStack: IPropertiesAppender[] = [];\n private _items: ElementProperties[] = [];\n private _elementPropertiesAppender: ElementPropertiesAppender | undefined;\n\n public get items(): ElementProperties[] {\n return this._items;\n }\n\n private get _currentAppender(): IPropertiesAppender {\n const appender = this._appendersStack[this._appendersStack.length - 1];\n assert(appender !== undefined);\n return appender;\n }\n\n public startContent(_props: StartContentProps): boolean {\n return true;\n }\n public finishContent(): void {}\n\n public processFieldHierarchies(_props: ProcessFieldHierarchiesProps): void {}\n\n public startItem(props: StartItemProps): boolean {\n this._elementPropertiesAppender = new ElementPropertiesAppender(props.item, (item) => this._items.push(item));\n this._appendersStack.push(this._elementPropertiesAppender);\n return true;\n }\n public finishItem(): void {\n this._appendersStack.pop();\n assert(this._elementPropertiesAppender !== undefined);\n this._elementPropertiesAppender.finish();\n this._elementPropertiesAppender = undefined;\n }\n\n public startCategory(props: StartCategoryProps): boolean {\n assert(this._elementPropertiesAppender !== undefined);\n this._appendersStack.push(this._elementPropertiesAppender.getCategoryAppender(this._currentAppender, props.category));\n return true;\n }\n public finishCategory(): void {\n this._appendersStack.pop();\n }\n\n public startField(_props: StartFieldProps): boolean {\n return true;\n }\n public finishField(): void {}\n\n public startStruct(props: StartStructProps): boolean {\n this._appendersStack.push(new StructItemAppender(this._currentAppender, props));\n return true;\n }\n public finishStruct(): void {\n this._appendersStack.pop()!.finish();\n }\n\n public startArray(props: StartArrayProps): boolean {\n this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));\n return true;\n }\n public finishArray(): void {\n this._appendersStack.pop()!.finish();\n }\n\n public processMergedValue(props: ProcessMergedValueProps): void {\n this._currentAppender.append(props.mergedField.label, {\n type: \"primitive\",\n value: \"\",\n });\n }\n public processPrimitiveValue(props: ProcessPrimitiveValueProps): void {\n this._currentAppender.append(props.field.label, {\n type: \"primitive\",\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n value: props.displayValue?.toString() ?? \"\",\n });\n }\n}\n"]}
|
|
@@ -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":["/*---------------------------------------------------------------------------------------------\
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstanceFilterDefinition.js","sourceRoot":"","sources":["../../../src/presentation-common/InstanceFilterDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"InstanceFilterDefinition.js","sourceRoot":"","sources":["../../../src/presentation-common/InstanceFilterDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG","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 { StrippedRelationshipPath } from \"./EC.js\";\n\n/**\n * Definition of an instance filter that can be used to filter content or hierarchy levels.\n *\n * Example:\n *\n * ```json\n * {\n * selectClassName: \"MySchema:MyClass\",\n * expression: \"this.MyProperty = 1 AND other.OtherProperty = 2\",\n * relatedInstances: [{\n * pathFromSelectToPropertyClass: [{\n * sourceClassName: \"MySchema:MyClass\",\n * relationshipName: \"MySchema:RelationshipFromMyToOtherClass\",\n * isForwardRelationship: true,\n * targetClassName: \"MySchema:OtherClass\",\n * }],\n * alias: \"other\",\n * }],\n * }\n * ```\n *\n * @public\n */\nexport interface InstanceFilterDefinition {\n /**\n * Select class filter used to select only instances of specific class.\n * The [[relatedInstances]] attribute, when used, should specify paths from this class.\n * Also, the [[expression]] attribute's `this` symbol points to instances of this class.\n *\n * The format is full class name: `SchemaName:ClassName`.\n */\n selectClassName: string;\n\n /**\n * Specifies relationship paths pointing to related instances used in the [[expression]] attribute.\n *\n * Sometimes there's a need to filter on a related instance property. In that case, the relationship\n * needs to be named by specifying the path and alias for the target (or the relationship). Then, the\n * related instance's symbol context can be accessed through the root symbol named as specified in the\n * [[alias]] (or [[relationshipAlias]]) attribute.\n */\n relatedInstances?: InstanceFilterRelatedInstanceDefinition[];\n\n /**\n * [ECExpression]($docs/presentation/advanced/ECExpressions.md) for filtering the select instances.\n */\n expression: string;\n}\n\n/**\n * Related instance definition for accessing properties of a related instance in [[InstanceFilterDefinition.expression]].\n * @public\n */\nexport type InstanceFilterRelatedInstanceDefinition = InstanceFilterRelatedInstancePath &\n (InstanceFilterRelatedInstanceTargetAlias | InstanceFilterRelatedInstanceRelationshipAlias);\n\n/**\n * Partial definition of common attributes for [[InstanceFilterRelatedInstanceDefinition]].\n * @public\n */\nexport interface InstanceFilterRelatedInstancePath {\n /**\n * A relationship path from select class (either specified through [[InstanceFilterDefinition.selectClassName]] or taken from context)\n * to the target related instance containing the properties used in [[InstanceFilterDefinition.expression]].\n */\n pathFromSelectToPropertyClass: StrippedRelationshipPath;\n /**\n * An optional flag indicating that the target instance must exist. Setting this allows to filter out all\n * select instances that don't have a related instance by following the [[pathFromSelectToPropertyClass]] path.\n */\n isRequired?: boolean;\n}\n\n/**\n * Partial definition of [[InstanceFilterRelatedInstanceDefinition]] for the case when referencing the target class.\n * @public\n */\nexport interface InstanceFilterRelatedInstanceTargetAlias {\n /**\n * An alias for the target class in the [[InstanceFilterRelatedInstancePath.pathFromSelectToPropertyClass]] path. This alias can be used to\n * access related instance symbols context in the [[InstanceFilterDefinition.expression]].\n */\n alias: string;\n}\n\n/**\n * Partial definition of [[InstanceFilterRelatedInstanceDefinition]] for the case when referencing the relationship class.\n * @public\n */\nexport interface InstanceFilterRelatedInstanceRelationshipAlias {\n /**\n * An alias for the relationship in the last step of the [[InstanceFilterRelatedInstancePath.pathFromSelectToPropertyClass]] path. This alias can be\n * used to access the relationship instance symbols context in the [[InstanceFilterDefinition.expression]].\n */\n relationshipAlias: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeySet.js","sourceRoot":"","sources":["../../../src/presentation-common/KeySet.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAc,IAAI,EAAc,MAAM,qBAAqB,CAAC;AAYpG,cAAc;AACd,2DAA2D;AAC3D,MAAM,KAAW,GAAG,CAsBnB;AAtBD,WAAiB,GAAG;IAClB;;;;;OAKG;IACH,4DAA4D;IAC5D,SAAgB,SAAS,CAAC,GAAQ;QAChC,4DAA4D;QAC5D,OAAO,CAAC,CAAE,GAAe,CAAC,IAAI,CAAC;IACjC,CAAC;IAHe,aAAS,YAGxB,CAAA;IAED,oDAAoD;IACpD,SAAgB,aAAa,CAAC,GAAQ;QACpC,OAAO,CAAC,CAAE,GAAmB,CAAC,SAAS,IAAI,CAAC,CAAE,GAAmB,CAAC,EAAE,CAAC;IACvE,CAAC;IAFe,iBAAa,gBAE5B,CAAA;IAED,oDAAoD;IACpD,SAAgB,aAAa,CAAC,GAAQ;QACp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AI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO;YACL,YAAY;YACZ,QAAQ;SACT,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAgB;QACrC,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QAC5B,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,SAAS,kBAAkB,CAAC,SAAiB;IAC3C,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,IAAI,GAAG,CAAQ,GAAe,EAAE,EAA4B,EAAE,EAAE;IACpE,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,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 Core\r\n */\r\n\r\nimport { assert, CompressedId64Set, Guid, GuidString, Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { EntityProps } from \"@itwin/core-common\";\r\nimport { InstanceId, InstanceKey } from \"./EC.js\";\r\nimport { NodeKey } from \"./hierarchy/Key.js\";\r\n\r\n/**\r\n * A single key that identifies something in an iTwin.js application\r\n * @public\r\n */\r\n// eslint-disable-next-line @typescript-eslint/no-deprecated\r\nexport type Key = Readonly<NodeKey> | Readonly<InstanceKey> | Readonly<EntityProps>;\r\n\r\n/** @public */\r\n// eslint-disable-next-line @typescript-eslint/no-redeclare\r\nexport namespace Key {\r\n /**\r\n * Check if the supplied key is a `NodeKey`\r\n *\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n export function isNodeKey(key: Key): key is Extract<Key, Readonly<NodeKey>> {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return !!(key as NodeKey).type;\r\n }\r\n\r\n /** Check if the supplied key is an `InstanceKey` */\r\n export function isInstanceKey(key: Key): key is Extract<Key, Readonly<InstanceKey>> {\r\n return !!(key as InstanceKey).className && !!(key as InstanceKey).id;\r\n }\r\n\r\n /** Check if the supplied key is an `EntityProps` */\r\n export function isEntityProps(key: Key): key is Extract<Key, Readonly<EntityProps>> {\r\n return !!(key as EntityProps).classFullName && !!(key as EntityProps).id;\r\n }\r\n}\r\n\r\n/**\r\n * A type for multiple keys that identify something in iModel.js application\r\n * @public\r\n */\r\nexport type Keys = ReadonlyArray<Key> | Readonly<KeySet>;\r\n\r\n/**\r\n * A data structure of serialized [[KeySet]]\r\n * @public\r\n */\r\nexport interface KeySetJSON {\r\n /** JSON representation of a list of instance keys */\r\n instanceKeys: Array<[string, string]>;\r\n /**\r\n * An array of serialized node keys\r\n *\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n nodeKeys: NodeKey[];\r\n}\r\n\r\n/**\r\n * A class that holds multiple [[Key]] objects. It's basically\r\n * used as a container that holds multiple keys of different types.\r\n *\r\n * @public\r\n */\r\nexport class KeySet {\r\n // note: all keys are stored as strings because we need ability to find them by value\r\n private _instanceKeys: Map<string, Set<string>>; // lower case class name => instance ids\r\n private _lowerCaseMap: Map<string, string>; // lower case class name => most recent class name\r\n private _nodeKeys: Set<string>;\r\n private _guid!: GuidString;\r\n\r\n /**\r\n * Creates an instance of KeySet.\r\n * @param source Optional source to initialize from.\r\n */\r\n constructor(source?: Keys) {\r\n this._instanceKeys = new Map();\r\n this._lowerCaseMap = new Map();\r\n this._nodeKeys = new Set();\r\n this.recalculateGuid();\r\n if (source) {\r\n this.add(source);\r\n }\r\n }\r\n\r\n private recalculateGuid() {\r\n // empty keyset should have empty guid, otherwise use a random guid value\r\n this._guid = this.isEmpty ? Guid.empty : Guid.createValue();\r\n }\r\n\r\n /**\r\n * Get a GUID that identifies changes in this keyset. The value\r\n * does not uniquely identify contents of the keyset, but it can be\r\n * used to check whether keyset has changed.\r\n */\r\n public get guid(): GuidString {\r\n return this._guid;\r\n }\r\n\r\n /**\r\n * Get a map of instance keys stored in this KeySet\r\n *\r\n * **Warning**: getting instance keys might be expensive for\r\n * large KeySets.\r\n */\r\n public get instanceKeys(): Map<string, Set<InstanceId>> {\r\n const map = new Map<string, Set<InstanceId>>();\r\n for (const entry of this._instanceKeys) {\r\n map.set(this._lowerCaseMap.get(entry[\"0\"])!, new Set([...entry[\"1\"]].map((key: string) => Id64.fromJSON(key))));\r\n }\r\n return map;\r\n }\r\n\r\n /**\r\n * Get instance keys count\r\n */\r\n public get instanceKeysCount(): number {\r\n let count = 0;\r\n this._instanceKeys.forEach((set: Set<string>) => (count += set.size));\r\n return count;\r\n }\r\n\r\n /**\r\n * Get a set of node keys stored in this KeySet\r\n *\r\n * **Warning**: getting node keys might be expensive for large KeySets.\r\n *\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n public get nodeKeys() {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const set = new Set<NodeKey>();\r\n for (const serialized of this._nodeKeys) {\r\n set.add(JSON.parse(serialized));\r\n }\r\n return set;\r\n }\r\n\r\n /**\r\n * Get node keys count\r\n *\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n public get nodeKeysCount(): number {\r\n return this._nodeKeys.size;\r\n }\r\n\r\n private isKeySet(set: Keys | Key): set is Readonly<KeySet> {\r\n return !!(set as KeySet)._nodeKeys && !!(set as KeySet)._instanceKeys;\r\n }\r\n\r\n private isKeysArray(keys: Keys | Key): keys is ReadonlyArray<Key> {\r\n return Array.isArray(keys);\r\n }\r\n\r\n /**\r\n * Clear this KeySet.\r\n * @returns itself\r\n */\r\n public clear(): KeySet {\r\n if (this.isEmpty) {\r\n return this;\r\n }\r\n\r\n this._instanceKeys = new Map();\r\n this._lowerCaseMap = new Map();\r\n this._nodeKeys = new Set();\r\n this.recalculateGuid();\r\n return this;\r\n }\r\n\r\n private addKeySet(keyset: Readonly<KeySet>, pred?: (key: Key) => boolean): void {\r\n for (const key of (keyset as any)._nodeKeys) {\r\n if (!pred || pred(JSON.parse(key))) {\r\n this._nodeKeys.add(key);\r\n }\r\n }\r\n for (const entry of (keyset as any)._instanceKeys) {\r\n let set = this._instanceKeys.get(entry[\"0\"]);\r\n const className = (keyset as KeySet)._lowerCaseMap.get(entry[\"0\"])!;\r\n if (!set) {\r\n set = new Set();\r\n this._instanceKeys.set(entry[\"0\"], set);\r\n this._lowerCaseMap.set(entry[\"0\"], className);\r\n }\r\n entry[\"1\"].forEach((id: Id64String) => {\r\n if (!pred || pred({ className, id })) {\r\n set.add(id);\r\n }\r\n });\r\n }\r\n }\r\n\r\n private addKeySetJSON(keyset: Readonly<KeySetJSON>): void {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n for (const key of keyset.nodeKeys) {\r\n this._nodeKeys.add(JSON.stringify(key));\r\n }\r\n for (const entry of keyset.instanceKeys) {\r\n const normalizedClassName = normalizeClassName(entry[\"0\"]);\r\n const lcClassName = normalizedClassName.toLowerCase();\r\n const idsJson: string | Id64String[] = entry[\"1\"];\r\n const ids: Set<Id64String> =\r\n typeof idsJson === \"string\" ? (idsJson === Id64.invalid ? new Set([Id64.invalid]) : CompressedId64Set.decompressSet(idsJson)) : new Set(idsJson);\r\n this._instanceKeys.set(lcClassName, ids);\r\n this._lowerCaseMap.set(lcClassName, normalizedClassName);\r\n }\r\n }\r\n\r\n /**\r\n * Add a key or keys to this KeySet.\r\n * @param value A key or keys to add.\r\n * @param pred An optional predicate function that indicates whether a key should be added\r\n * @returns itself\r\n */\r\n public add(value: Keys | Key, pred?: (key: Key) => boolean): KeySet {\r\n const sizeBefore = this.size;\r\n if (this.isKeySet(value)) {\r\n this.addKeySet(value, pred);\r\n } else if (this.isKeysArray(value)) {\r\n value.forEach((key) => this.add(key, pred));\r\n } else if (!pred || pred(value)) {\r\n if (Key.isEntityProps(value)) {\r\n this.add({ className: value.classFullName, id: Id64.fromJSON(value.id) } as InstanceKey);\r\n } else if (Key.isInstanceKey(value)) {\r\n const normalizedClassName = normalizeClassName(value.className);\r\n const lcClassName = normalizedClassName.toLowerCase();\r\n if (!this._instanceKeys.has(lcClassName)) {\r\n this._instanceKeys.set(lcClassName, new Set());\r\n }\r\n this._lowerCaseMap.set(lcClassName, normalizedClassName);\r\n this._instanceKeys.get(lcClassName)!.add(value.id);\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n } else if (Key.isNodeKey(value)) {\r\n this._nodeKeys.add(JSON.stringify(value));\r\n }\r\n }\r\n if (this.size !== sizeBefore) {\r\n this.recalculateGuid();\r\n }\r\n return this;\r\n }\r\n\r\n private deleteKeySet(keyset: Readonly<KeySet>): void {\r\n for (const key of (keyset as any)._nodeKeys) {\r\n this._nodeKeys.delete(key);\r\n }\r\n for (const entry of (keyset as any)._instanceKeys) {\r\n const set = this._instanceKeys.get(entry[\"0\"]);\r\n if (set) {\r\n entry[\"1\"].forEach((key: string) => {\r\n set.delete(key);\r\n });\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Deletes a key or keys from this KeySet.\r\n * @param value A key or keys to delete.\r\n * @returns itself\r\n */\r\n public delete(value: Keys | Key): KeySet {\r\n const sizeBefore = this.size;\r\n if (this.isKeySet(value)) {\r\n this.deleteKeySet(value);\r\n } else if (this.isKeysArray(value)) {\r\n for (const key of value) {\r\n this.delete(key);\r\n }\r\n } else if (Key.isEntityProps(value)) {\r\n this.delete({ className: value.classFullName, id: value.id! } as InstanceKey);\r\n } else if (Key.isInstanceKey(value)) {\r\n const normalizedClassName = normalizeClassName(value.className);\r\n const set = this._instanceKeys.get(normalizedClassName.toLowerCase());\r\n if (set) {\r\n set.delete(value.id);\r\n }\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n } else if (Key.isNodeKey(value)) {\r\n this._nodeKeys.delete(JSON.stringify(value));\r\n }\r\n if (this.size !== sizeBefore) {\r\n this.recalculateGuid();\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Check if this KeySet contains the specified key.\r\n * @param value The key to check.\r\n */\r\n public has(value: Key): boolean {\r\n if (Key.isEntityProps(value)) {\r\n return this.has({ className: value.classFullName, id: value.id! } as InstanceKey);\r\n }\r\n if (Key.isInstanceKey(value)) {\r\n const normalizedClassName = normalizeClassName(value.className);\r\n const set = this._instanceKeys.get(normalizedClassName.toLowerCase());\r\n return !!(set && set.has(value.id));\r\n }\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n assert(Key.isNodeKey(value));\r\n return this._nodeKeys.has(JSON.stringify(value));\r\n }\r\n\r\n private hasKeySet(readonlyKeys: Readonly<KeySet>, checkType: \"all\" | \"any\"): boolean {\r\n // note: cast-away read-onlyness to access private members...\r\n const keys = readonlyKeys as KeySet;\r\n\r\n if (checkType === \"all\") {\r\n if (this._nodeKeys.size < keys._nodeKeys.size || this._instanceKeys.size < keys._instanceKeys.size) {\r\n return false;\r\n }\r\n if ([...keys._nodeKeys].some((key) => !this._nodeKeys.has(key))) {\r\n return false;\r\n }\r\n for (const otherEntry of keys._instanceKeys) {\r\n const thisEntryKeys = this._instanceKeys.get(otherEntry[\"0\"]);\r\n if (!thisEntryKeys || thisEntryKeys.size < otherEntry[\"1\"].size) {\r\n return false;\r\n }\r\n if ([...otherEntry[\"1\"]].some((key) => !thisEntryKeys.has(key))) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n // \"any\" check type\r\n if ([...keys._nodeKeys].some((key) => this._nodeKeys.has(key))) {\r\n return true;\r\n }\r\n for (const otherEntry of keys._instanceKeys) {\r\n const thisEntryKeys = this._instanceKeys.get(otherEntry[\"0\"]);\r\n if (thisEntryKeys && [...otherEntry[\"1\"]].some((key) => thisEntryKeys.has(key))) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n private hasKeysArray(keys: ReadonlyArray<Key>, checkType: \"all\" | \"any\"): boolean {\r\n if (checkType === \"all\") {\r\n if (this.size < keys.length) {\r\n return false;\r\n }\r\n for (const key of keys) {\r\n if (!this.has(key)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n // \"any\" check type\r\n for (const key of keys) {\r\n if (this.has(key)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Check if this KeySet contains all the specified keys.\r\n * @param keys The keys to check.\r\n */\r\n public hasAll(keys: Keys): boolean {\r\n if (this.isKeySet(keys)) {\r\n return this.hasKeySet(keys, \"all\");\r\n }\r\n assert(this.isKeysArray(keys));\r\n return this.hasKeysArray(keys, \"all\");\r\n }\r\n\r\n /**\r\n * Check if this KeySet contains any of the specified keys.\r\n * @param keys The keys to check.\r\n */\r\n public hasAny(keys: Keys): boolean {\r\n if (this.isKeySet(keys)) {\r\n return this.hasKeySet(keys, \"any\");\r\n }\r\n assert(this.isKeysArray(keys));\r\n return this.hasKeysArray(keys, \"any\");\r\n }\r\n\r\n /**\r\n * Get the number of keys stored in this KeySet.\r\n */\r\n public get size(): number {\r\n const nodeKeysCount = this._nodeKeys.size;\r\n let instanceIdsCount = 0;\r\n for (const set of this._instanceKeys.values()) {\r\n instanceIdsCount += set.size;\r\n }\r\n return nodeKeysCount + instanceIdsCount;\r\n }\r\n\r\n /**\r\n * Is this KeySet currently empty.\r\n */\r\n public get isEmpty(): boolean {\r\n return 0 === this.size;\r\n }\r\n\r\n /** Iterate over all keys in this keyset. */\r\n public some(callback: (key: Key) => boolean) {\r\n for (const entry of this._instanceKeys) {\r\n const className = this._lowerCaseMap.get(entry[\"0\"].toLowerCase())!;\r\n if (some(entry[1], (id: Id64String) => callback({ className, id }))) {\r\n return true;\r\n }\r\n }\r\n return some(this._nodeKeys, (serializedKey: string) => callback(JSON.parse(serializedKey)));\r\n }\r\n\r\n /** Iterate over all keys in this keyset. */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public forEach(callback: (key: InstanceKey | NodeKey, index: number) => void) {\r\n let index = 0;\r\n this._instanceKeys.forEach((ids: Set<Id64String>, className: string) => {\r\n const recentClassName = this._lowerCaseMap.get(className.toLowerCase())!;\r\n ids.forEach((id: Id64String) => callback({ className: recentClassName, id }, index++));\r\n });\r\n this._nodeKeys.forEach((serializedKey: string) => {\r\n callback(JSON.parse(serializedKey), index++);\r\n });\r\n }\r\n\r\n /** Iterate over all keys in this keyset in batches */\r\n public forEachBatch(batchSize: number, callback: (batch: KeySet, index: number) => void) {\r\n const size = this.size;\r\n const count = Math.ceil(size / batchSize);\r\n if (1 === count) {\r\n callback(this, 0);\r\n return;\r\n }\r\n let batch = new KeySet();\r\n let batchIndex = 0;\r\n let currBatchSize = 0;\r\n this.forEach((key, index) => {\r\n batch.add(key);\r\n ++currBatchSize;\r\n if (currBatchSize === batchSize || index === size - 1) {\r\n callback(batch, batchIndex++);\r\n batch = new KeySet();\r\n currBatchSize = 0;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Serializes this KeySet to JSON\r\n * @public\r\n */\r\n public toJSON(): KeySetJSON {\r\n const instanceKeys: [string, string][] = [];\r\n for (const entry of this._instanceKeys.entries()) {\r\n if (entry[\"1\"].size > 0) {\r\n const className = this._lowerCaseMap.get(entry[\"0\"].toLowerCase());\r\n const compressedIds = CompressedId64Set.sortAndCompress(entry[\"1\"]);\r\n instanceKeys.push([className!, compressedIds.length > 0 ? compressedIds : Id64.invalid]);\r\n }\r\n }\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const nodeKeys: NodeKey[] = [];\r\n for (const serializedKey of this._nodeKeys.values()) {\r\n nodeKeys.push(JSON.parse(serializedKey));\r\n }\r\n return {\r\n instanceKeys,\r\n nodeKeys,\r\n };\r\n }\r\n\r\n /**\r\n * Creates a KeySet from JSON\r\n * @public\r\n */\r\n public static fromJSON(json: KeySetJSON): KeySet {\r\n const keyset = new KeySet();\r\n keyset.addKeySetJSON(json);\r\n return keyset;\r\n }\r\n}\r\n\r\nfunction normalizeClassName(className: string) {\r\n return className.replace(\".\", \":\");\r\n}\r\n\r\nconst some = <TItem>(set: Set<TItem>, cb: (item: TItem) => boolean) => {\r\n for (const item of set) {\r\n if (cb(item)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"KeySet.js","sourceRoot":"","sources":["../../../src/presentation-common/KeySet.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAc,IAAI,EAAc,MAAM,qBAAqB,CAAC;AAYpG,cAAc;AACd,2DAA2D;AAC3D,MAAM,KAAW,GAAG,CAsBnB;AAtBD,WAAiB,GAAG;IAClB;;;;;OAKG;IACH,4DAA4D;IAC5D,SAAgB,SAAS,CAAC,GAAQ;QAChC,4DAA4D;QAC5D,OAAO,CAAC,CAAE,GAAe,CAAC,IAAI,CAAC;IACjC,CAAC;IAHe,aAAS,YAGxB,CAAA;IAED,oDAAoD;IACpD,SAAgB,aAAa,CAAC,GAAQ;QACpC,OAAO,CAAC,CAAE,GAAmB,CAAC,SAAS,IAA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Ac,EAAE,CAAC;QAC/B,KAAK,MAAM,aAAa,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;YACpD,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO;YACL,YAAY;YACZ,QAAQ;SACT,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAgB;QACrC,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QAC5B,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,SAAS,kBAAkB,CAAC,SAAiB;IAC3C,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,IAAI,GAAG,CAAQ,GAAe,EAAE,EAA4B,EAAE,EAAE;IACpE,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,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, CompressedId64Set, Guid, GuidString, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { EntityProps } from \"@itwin/core-common\";\nimport { InstanceId, InstanceKey } from \"./EC.js\";\nimport { NodeKey } from \"./hierarchy/Key.js\";\n\n/**\n * A single key that identifies something in an iTwin.js application\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport type Key = Readonly<NodeKey> | Readonly<InstanceKey> | Readonly<EntityProps>;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Key {\n /**\n * Check if the supplied key is a `NodeKey`\n *\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\n * package for creating hierarchies.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n export function isNodeKey(key: Key): key is Extract<Key, Readonly<NodeKey>> {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return !!(key as NodeKey).type;\n }\n\n /** Check if the supplied key is an `InstanceKey` */\n export function isInstanceKey(key: Key): key is Extract<Key, Readonly<InstanceKey>> {\n return !!(key as InstanceKey).className && !!(key as InstanceKey).id;\n }\n\n /** Check if the supplied key is an `EntityProps` */\n export function isEntityProps(key: Key): key is Extract<Key, Readonly<EntityProps>> {\n return !!(key as EntityProps).classFullName && !!(key as EntityProps).id;\n }\n}\n\n/**\n * A type for multiple keys that identify something in iModel.js application\n * @public\n */\nexport type Keys = ReadonlyArray<Key> | Readonly<KeySet>;\n\n/**\n * A data structure of serialized [[KeySet]]\n * @public\n */\nexport interface KeySetJSON {\n /** JSON representation of a list of instance keys */\n instanceKeys: Array<[string, string]>;\n /**\n * An array of serialized node keys\n *\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\n * package for creating hierarchies.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n nodeKeys: NodeKey[];\n}\n\n/**\n * A class that holds multiple [[Key]] objects. It's basically\n * used as a container that holds multiple keys of different types.\n *\n * @public\n */\nexport class KeySet {\n // note: all keys are stored as strings because we need ability to find them by value\n private _instanceKeys: Map<string, Set<string>>; // lower case class name => instance ids\n private _lowerCaseMap: Map<string, string>; // lower case class name => most recent class name\n private _nodeKeys: Set<string>;\n private _guid!: GuidString;\n\n /**\n * Creates an instance of KeySet.\n * @param source Optional source to initialize from.\n */\n constructor(source?: Keys) {\n this._instanceKeys = new Map();\n this._lowerCaseMap = new Map();\n this._nodeKeys = new Set();\n this.recalculateGuid();\n if (source) {\n this.add(source);\n }\n }\n\n private recalculateGuid() {\n // empty keyset should have empty guid, otherwise use a random guid value\n this._guid = this.isEmpty ? Guid.empty : Guid.createValue();\n }\n\n /**\n * Get a GUID that identifies changes in this keyset. The value\n * does not uniquely identify contents of the keyset, but it can be\n * used to check whether keyset has changed.\n */\n public get guid(): GuidString {\n return this._guid;\n }\n\n /**\n * Get a map of instance keys stored in this KeySet\n *\n * **Warning**: getting instance keys might be expensive for\n * large KeySets.\n */\n public get instanceKeys(): Map<string, Set<InstanceId>> {\n const map = new Map<string, Set<InstanceId>>();\n for (const entry of this._instanceKeys) {\n map.set(this._lowerCaseMap.get(entry[\"0\"])!, new Set([...entry[\"1\"]].map((key: string) => Id64.fromJSON(key))));\n }\n return map;\n }\n\n /**\n * Get instance keys count\n */\n public get instanceKeysCount(): number {\n let count = 0;\n this._instanceKeys.forEach((set: Set<string>) => (count += set.size));\n return count;\n }\n\n /**\n * Get a set of node keys stored in this KeySet\n *\n * **Warning**: getting node keys might be expensive for large KeySets.\n *\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\n * package for creating hierarchies.\n */\n public get nodeKeys() {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const set = new Set<NodeKey>();\n for (const serialized of this._nodeKeys) {\n set.add(JSON.parse(serialized));\n }\n return set;\n }\n\n /**\n * Get node keys count\n *\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\n * package for creating hierarchies.\n */\n public get nodeKeysCount(): number {\n return this._nodeKeys.size;\n }\n\n private isKeySet(set: Keys | Key): set is Readonly<KeySet> {\n return !!(set as KeySet)._nodeKeys && !!(set as KeySet)._instanceKeys;\n }\n\n private isKeysArray(keys: Keys | Key): keys is ReadonlyArray<Key> {\n return Array.isArray(keys);\n }\n\n /**\n * Clear this KeySet.\n * @returns itself\n */\n public clear(): KeySet {\n if (this.isEmpty) {\n return this;\n }\n\n this._instanceKeys = new Map();\n this._lowerCaseMap = new Map();\n this._nodeKeys = new Set();\n this.recalculateGuid();\n return this;\n }\n\n private addKeySet(keyset: Readonly<KeySet>, pred?: (key: Key) => boolean): void {\n for (const key of (keyset as any)._nodeKeys) {\n if (!pred || pred(JSON.parse(key))) {\n this._nodeKeys.add(key);\n }\n }\n for (const entry of (keyset as any)._instanceKeys) {\n let set = this._instanceKeys.get(entry[\"0\"]);\n const className = (keyset as KeySet)._lowerCaseMap.get(entry[\"0\"])!;\n if (!set) {\n set = new Set();\n this._instanceKeys.set(entry[\"0\"], set);\n this._lowerCaseMap.set(entry[\"0\"], className);\n }\n entry[\"1\"].forEach((id: Id64String) => {\n if (!pred || pred({ className, id })) {\n set.add(id);\n }\n });\n }\n }\n\n private addKeySetJSON(keyset: Readonly<KeySetJSON>): void {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n for (const key of keyset.nodeKeys) {\n this._nodeKeys.add(JSON.stringify(key));\n }\n for (const entry of keyset.instanceKeys) {\n const normalizedClassName = normalizeClassName(entry[\"0\"]);\n const lcClassName = normalizedClassName.toLowerCase();\n const idsJson: string | Id64String[] = entry[\"1\"];\n const ids: Set<Id64String> =\n typeof idsJson === \"string\" ? (idsJson === Id64.invalid ? new Set([Id64.invalid]) : CompressedId64Set.decompressSet(idsJson)) : new Set(idsJson);\n this._instanceKeys.set(lcClassName, ids);\n this._lowerCaseMap.set(lcClassName, normalizedClassName);\n }\n }\n\n /**\n * Add a key or keys to this KeySet.\n * @param value A key or keys to add.\n * @param pred An optional predicate function that indicates whether a key should be added\n * @returns itself\n */\n public add(value: Keys | Key, pred?: (key: Key) => boolean): KeySet {\n const sizeBefore = this.size;\n if (this.isKeySet(value)) {\n this.addKeySet(value, pred);\n } else if (this.isKeysArray(value)) {\n value.forEach((key) => this.add(key, pred));\n } else if (!pred || pred(value)) {\n if (Key.isEntityProps(value)) {\n this.add({ className: value.classFullName, id: Id64.fromJSON(value.id) } as InstanceKey);\n } else if (Key.isInstanceKey(value)) {\n const normalizedClassName = normalizeClassName(value.className);\n const lcClassName = normalizedClassName.toLowerCase();\n if (!this._instanceKeys.has(lcClassName)) {\n this._instanceKeys.set(lcClassName, new Set());\n }\n this._lowerCaseMap.set(lcClassName, normalizedClassName);\n this._instanceKeys.get(lcClassName)!.add(value.id);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n } else if (Key.isNodeKey(value)) {\n this._nodeKeys.add(JSON.stringify(value));\n }\n }\n if (this.size !== sizeBefore) {\n this.recalculateGuid();\n }\n return this;\n }\n\n private deleteKeySet(keyset: Readonly<KeySet>): void {\n for (const key of (keyset as any)._nodeKeys) {\n this._nodeKeys.delete(key);\n }\n for (const entry of (keyset as any)._instanceKeys) {\n const set = this._instanceKeys.get(entry[\"0\"]);\n if (set) {\n entry[\"1\"].forEach((key: string) => {\n set.delete(key);\n });\n }\n }\n }\n\n /**\n * Deletes a key or keys from this KeySet.\n * @param value A key or keys to delete.\n * @returns itself\n */\n public delete(value: Keys | Key): KeySet {\n const sizeBefore = this.size;\n if (this.isKeySet(value)) {\n this.deleteKeySet(value);\n } else if (this.isKeysArray(value)) {\n for (const key of value) {\n this.delete(key);\n }\n } else if (Key.isEntityProps(value)) {\n this.delete({ className: value.classFullName, id: value.id! } as InstanceKey);\n } else if (Key.isInstanceKey(value)) {\n const normalizedClassName = normalizeClassName(value.className);\n const set = this._instanceKeys.get(normalizedClassName.toLowerCase());\n if (set) {\n set.delete(value.id);\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n } else if (Key.isNodeKey(value)) {\n this._nodeKeys.delete(JSON.stringify(value));\n }\n if (this.size !== sizeBefore) {\n this.recalculateGuid();\n }\n return this;\n }\n\n /**\n * Check if this KeySet contains the specified key.\n * @param value The key to check.\n */\n public has(value: Key): boolean {\n if (Key.isEntityProps(value)) {\n return this.has({ className: value.classFullName, id: value.id! } as InstanceKey);\n }\n if (Key.isInstanceKey(value)) {\n const normalizedClassName = normalizeClassName(value.className);\n const set = this._instanceKeys.get(normalizedClassName.toLowerCase());\n return !!(set && set.has(value.id));\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n assert(Key.isNodeKey(value));\n return this._nodeKeys.has(JSON.stringify(value));\n }\n\n private hasKeySet(readonlyKeys: Readonly<KeySet>, checkType: \"all\" | \"any\"): boolean {\n // note: cast-away read-onlyness to access private members...\n const keys = readonlyKeys as KeySet;\n\n if (checkType === \"all\") {\n if (this._nodeKeys.size < keys._nodeKeys.size || this._instanceKeys.size < keys._instanceKeys.size) {\n return false;\n }\n if ([...keys._nodeKeys].some((key) => !this._nodeKeys.has(key))) {\n return false;\n }\n for (const otherEntry of keys._instanceKeys) {\n const thisEntryKeys = this._instanceKeys.get(otherEntry[\"0\"]);\n if (!thisEntryKeys || thisEntryKeys.size < otherEntry[\"1\"].size) {\n return false;\n }\n if ([...otherEntry[\"1\"]].some((key) => !thisEntryKeys.has(key))) {\n return false;\n }\n }\n return true;\n }\n\n // \"any\" check type\n if ([...keys._nodeKeys].some((key) => this._nodeKeys.has(key))) {\n return true;\n }\n for (const otherEntry of keys._instanceKeys) {\n const thisEntryKeys = this._instanceKeys.get(otherEntry[\"0\"]);\n if (thisEntryKeys && [...otherEntry[\"1\"]].some((key) => thisEntryKeys.has(key))) {\n return true;\n }\n }\n return false;\n }\n\n private hasKeysArray(keys: ReadonlyArray<Key>, checkType: \"all\" | \"any\"): boolean {\n if (checkType === \"all\") {\n if (this.size < keys.length) {\n return false;\n }\n for (const key of keys) {\n if (!this.has(key)) {\n return false;\n }\n }\n return true;\n }\n\n // \"any\" check type\n for (const key of keys) {\n if (this.has(key)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Check if this KeySet contains all the specified keys.\n * @param keys The keys to check.\n */\n public hasAll(keys: Keys): boolean {\n if (this.isKeySet(keys)) {\n return this.hasKeySet(keys, \"all\");\n }\n assert(this.isKeysArray(keys));\n return this.hasKeysArray(keys, \"all\");\n }\n\n /**\n * Check if this KeySet contains any of the specified keys.\n * @param keys The keys to check.\n */\n public hasAny(keys: Keys): boolean {\n if (this.isKeySet(keys)) {\n return this.hasKeySet(keys, \"any\");\n }\n assert(this.isKeysArray(keys));\n return this.hasKeysArray(keys, \"any\");\n }\n\n /**\n * Get the number of keys stored in this KeySet.\n */\n public get size(): number {\n const nodeKeysCount = this._nodeKeys.size;\n let instanceIdsCount = 0;\n for (const set of this._instanceKeys.values()) {\n instanceIdsCount += set.size;\n }\n return nodeKeysCount + instanceIdsCount;\n }\n\n /**\n * Is this KeySet currently empty.\n */\n public get isEmpty(): boolean {\n return 0 === this.size;\n }\n\n /** Iterate over all keys in this keyset. */\n public some(callback: (key: Key) => boolean) {\n for (const entry of this._instanceKeys) {\n const className = this._lowerCaseMap.get(entry[\"0\"].toLowerCase())!;\n if (some(entry[1], (id: Id64String) => callback({ className, id }))) {\n return true;\n }\n }\n return some(this._nodeKeys, (serializedKey: string) => callback(JSON.parse(serializedKey)));\n }\n\n /** Iterate over all keys in this keyset. */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public forEach(callback: (key: InstanceKey | NodeKey, index: number) => void) {\n let index = 0;\n this._instanceKeys.forEach((ids: Set<Id64String>, className: string) => {\n const recentClassName = this._lowerCaseMap.get(className.toLowerCase())!;\n ids.forEach((id: Id64String) => callback({ className: recentClassName, id }, index++));\n });\n this._nodeKeys.forEach((serializedKey: string) => {\n callback(JSON.parse(serializedKey), index++);\n });\n }\n\n /** Iterate over all keys in this keyset in batches */\n public forEachBatch(batchSize: number, callback: (batch: KeySet, index: number) => void) {\n const size = this.size;\n const count = Math.ceil(size / batchSize);\n if (1 === count) {\n callback(this, 0);\n return;\n }\n let batch = new KeySet();\n let batchIndex = 0;\n let currBatchSize = 0;\n this.forEach((key, index) => {\n batch.add(key);\n ++currBatchSize;\n if (currBatchSize === batchSize || index === size - 1) {\n callback(batch, batchIndex++);\n batch = new KeySet();\n currBatchSize = 0;\n }\n });\n }\n\n /**\n * Serializes this KeySet to JSON\n * @public\n */\n public toJSON(): KeySetJSON {\n const instanceKeys: [string, string][] = [];\n for (const entry of this._instanceKeys.entries()) {\n if (entry[\"1\"].size > 0) {\n const className = this._lowerCaseMap.get(entry[\"0\"].toLowerCase());\n const compressedIds = CompressedId64Set.sortAndCompress(entry[\"1\"]);\n instanceKeys.push([className!, compressedIds.length > 0 ? compressedIds : Id64.invalid]);\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const nodeKeys: NodeKey[] = [];\n for (const serializedKey of this._nodeKeys.values()) {\n nodeKeys.push(JSON.parse(serializedKey));\n }\n return {\n instanceKeys,\n nodeKeys,\n };\n }\n\n /**\n * Creates a KeySet from JSON\n * @public\n */\n public static fromJSON(json: KeySetJSON): KeySet {\n const keyset = new KeySet();\n keyset.addKeySetJSON(json);\n return keyset;\n }\n}\n\nfunction normalizeClassName(className: string) {\n return className.replace(\".\", \":\");\n}\n\nconst some = <TItem>(set: Set<TItem>, cb: (item: TItem) => boolean) => {\n for (const item of set) {\n if (cb(item)) {\n return true;\n }\n }\n return false;\n};\n"]}
|
|
@@ -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,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAgC,aAAa,EAAE,UAAU,EAAgC,MAAM,sBAAsB,CAAC;AACrI,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,qBAAqB,EAAE,SAAS,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;A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B;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED,KAAK,UAAU,gCAAgC,CAAC,EAC9C,aAAa,EACb,UAAU,EACV,UAAU,EACV,OAAO,GAOR;IACC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACjD,sBAAsB;IACtB,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,GAAG,CAAC,eAAe,CAAC;IAClD,sBAAsB;IACtB,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,qBAAqB,GAAG,eAAe,YAAY,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,MAAM,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC;IACjJ,MAAM,UAAU,GAAG,MAAM,qBAAqB,EAAE,UAAU,CAAC;IAC3D,IAAI,UAAU,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;QAC5D,MAAM,wBAAwB,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QAC3E,KAAK,MAAM,uBAAuB,IAAI,KAAK,CAAC,OAAO,CAAC,wBAAwB,CAAC;YAC3E,CAAC,CAAC,oBAAoB,CAAC,wBAAwB;YAC/C,CAAC,CAAC,CAAC,wBAAwB,CAAC,EAAE,CAAC;YAC/B,IAAI,uBAAuB,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC7D,OAAO,uBAAuB,CAAC,MAAM,CAAC;YACxC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,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 Core\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Format, FormatProps, FormatsProvider, FormatterSpec, ParserSpec, UnitsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { InvertedUnit, KindOfQuantity, SchemaContext, SchemaFormatsProvider, SchemaKey, SchemaMatchType, SchemaUnitProvider } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * A data structure that associates unit systems with property value formatting props. The associations are used for\r\n * assigning formatting props for specific phenomenon and unit system combinations (see [[FormatsMap]]).\r\n *\r\n * @public\r\n *\r\n * @deprecated in 5.1 - will not be removed until after 2026-08-08. `FormatsMap` and related APIs have been deprecated in favor of [FormatsProvider]($core-quantity).\r\n */\r\nexport interface UnitSystemFormat {\r\n unitSystems: UnitSystemKey[];\r\n format: FormatProps;\r\n}\r\n\r\n/**\r\n * A data structure that associates specific phenomenon with one or more formatting props for specific unit system.\r\n *\r\n * Example:\r\n * ```json\r\n * {\r\n * length: [{\r\n * unitSystems: [\"metric\"],\r\n * format: formatForCentimeters,\r\n * }, {\r\n * unitSystems: [\"imperial\", \"usCustomary\"],\r\n * format: formatForInches,\r\n * }, {\r\n * unitSystems: [\"usSurvey\"],\r\n * format: formatForUsSurveyInches,\r\n * }]\r\n * }\r\n * ```\r\n *\r\n * @public\r\n *\r\n * @deprecated in 5.1 - will not be removed until after 2026-08-08. `FormatsMap` and related APIs have been deprecated in favor of [FormatsProvider]($core-quantity).\r\n */\r\nexport interface FormatsMap {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n [phenomenon: string]: UnitSystemFormat | UnitSystemFormat[];\r\n}\r\n\r\n/**\r\n * Options for finding a formatter spec to use in [[KoqPropertyValueFormatter]].\r\n * @public\r\n */\r\nexport interface FormatOptions {\r\n /** Full name of the `KindOfQuantity`, e.g. `SchemaName:KoqName`. */\r\n koqName: string;\r\n /** Unit system to use for formatting. */\r\n unitSystem?: UnitSystemKey;\r\n /** Optional overrides for the format used to parse or format values. */\r\n formatOverride?: Partial<Omit<FormatProps, \"type\">>;\r\n}\r\n\r\n/**\r\n * Props for creating [[KoqPropertyValueFormatter]].\r\n * @public\r\n */\r\ninterface KoqPropertyValueFormatterProps {\r\n /** Schema context to use for locating units, formats, etc. Generally retrieved through the `schemaContext` getter on an iModel. */\r\n schemaContext: SchemaContext;\r\n /** Formats provider to use for finding formatting props. Defaults to [SchemaFormatsProvider]($ecschema-metadata) when not supplied. */\r\n formatsProvider?: FormatsProvider;\r\n}\r\n\r\n/**\r\n * An utility for formatting property values based on `KindOfQuantity` and unit system.\r\n * @public\r\n */\r\nexport class KoqPropertyValueFormatter {\r\n private _schemaContext: SchemaContext;\r\n private _unitsProvider: UnitsProvider;\r\n private _formatsProvider?: FormatsProvider;\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n private _defaultFormats?: FormatsMap;\r\n\r\n /** @deprecated in 5.1 - will not be removed until after 2026-08-08. Use the overload that takes a props object. */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n constructor(schemaContext: SchemaContext, defaultFormats?: FormatsMap, formatsProvider?: FormatsProvider);\r\n constructor(props: KoqPropertyValueFormatterProps);\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n constructor(schemaContextOrProps: SchemaContext | KoqPropertyValueFormatterProps, defaultFormats?: FormatsMap, formatsProvider?: FormatsProvider) {\r\n if (schemaContextOrProps instanceof SchemaContext) {\r\n this._schemaContext = schemaContextOrProps;\r\n this._formatsProvider = formatsProvider;\r\n this.defaultFormats = defaultFormats;\r\n } else {\r\n this._schemaContext = schemaContextOrProps.schemaContext;\r\n this._formatsProvider = schemaContextOrProps.formatsProvider;\r\n }\r\n this._unitsProvider = new SchemaUnitProvider(this._schemaContext);\r\n }\r\n\r\n /* c8 ignore start */\r\n /** @internal */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public get defaultFormats(): FormatsMap | undefined {\r\n return this._defaultFormats;\r\n }\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public set defaultFormats(value: FormatsMap | undefined) {\r\n this._defaultFormats = value\r\n ? Object.entries(value).reduce((acc, [phenomenon, unitSystemFormats]) => ({ ...acc, [phenomenon.toUpperCase()]: unitSystemFormats }), {})\r\n : undefined;\r\n }\r\n /* c8 ignore end */\r\n\r\n public async format(value: number, options: FormatOptions) {\r\n const formatterSpec = await this.getFormatterSpec(options);\r\n if (!formatterSpec) {\r\n return undefined;\r\n }\r\n return formatterSpec.applyFormatting(value);\r\n }\r\n\r\n public async getFormatterSpec(options: FormatOptions) {\r\n const formattingProps = await this.#getFormattingProps(options);\r\n if (!formattingProps) {\r\n return undefined;\r\n }\r\n const { formatProps, persistenceUnitName } = formattingProps;\r\n const persistenceUnit = await this._unitsProvider.findUnitByName(persistenceUnitName);\r\n const format = await Format.createFromJSON(\"\", this._unitsProvider, { ...formatProps, ...options.formatOverride });\r\n return FormatterSpec.create(\"\", format, this._unitsProvider, persistenceUnit);\r\n }\r\n\r\n public async getParserSpec(options: FormatOptions) {\r\n const formattingProps = await this.#getFormattingProps(options);\r\n if (!formattingProps) {\r\n return undefined;\r\n }\r\n const { formatProps, persistenceUnitName } = formattingProps;\r\n const persistenceUnit = await this._unitsProvider.findUnitByName(persistenceUnitName);\r\n const format = await Format.createFromJSON(\"\", this._unitsProvider, { ...formatProps, ...options.formatOverride });\r\n return ParserSpec.create(format, this._unitsProvider, persistenceUnit);\r\n }\r\n\r\n async #getFormattingProps(options: FormatOptions): Promise<FormattingProps | undefined> {\r\n const { koqName } = options;\r\n const koq = await getKoq(this._schemaContext, koqName);\r\n if (!koq) {\r\n return undefined;\r\n }\r\n const persistenceUnit = await koq.persistenceUnit;\r\n assert(!!persistenceUnit);\r\n\r\n // default to metric as it's the persistence unit system\r\n const unitSystem = options.unitSystem ?? \"metric\";\r\n\r\n const formatsProvider = this._formatsProvider ?? new SchemaFormatsProvider(this._schemaContext, unitSystem);\r\n const formatProps = await formatsProvider.getFormat(koqName);\r\n\r\n // `SchemaFormatsProvider` will fall back to default presentation format, but we want to fall back\r\n // to default formats' map first, and only then to the default presentation format. All of this can\r\n // be removed with the removal of default formats map.\r\n if (this._defaultFormats && (!formatProps || (await getUnitSystemKey(this._unitsProvider, formatProps)) !== unitSystem)) {\r\n const defaultFormatProps = await getFormatPropsFromDefaultFormats({\r\n schemaContext: this._schemaContext,\r\n formatsMap: this._defaultFormats,\r\n unitSystem,\r\n koqName,\r\n });\r\n if (defaultFormatProps) {\r\n return { formatProps: defaultFormatProps, persistenceUnitName: persistenceUnit.fullName };\r\n }\r\n }\r\n\r\n if (formatProps) {\r\n return { formatProps, persistenceUnitName: persistenceUnit.fullName };\r\n }\r\n\r\n return undefined;\r\n }\r\n}\r\n\r\ninterface FormattingProps {\r\n formatProps: FormatProps;\r\n persistenceUnitName: string;\r\n}\r\n\r\nasync function getKoq(schemaLocater: SchemaContext, fullName: string) {\r\n const [schemaName, propKoqName] = fullName.split(\":\");\r\n const schema = await schemaLocater.getSchema(new SchemaKey(schemaName), SchemaMatchType.Latest);\r\n if (!schema) {\r\n return undefined;\r\n }\r\n return schema.getItem(propKoqName, KindOfQuantity);\r\n}\r\n\r\nasync function getUnitSystemKey(unitsProvider: UnitsProvider, formatProps: FormatProps): Promise<UnitSystemKey | undefined> {\r\n const unitName = formatProps.composite?.units[0].name;\r\n assert(!!unitName);\r\n const unit = await unitsProvider.findUnitByName(unitName);\r\n assert(!!unit);\r\n const [_, unitSystemName] = unit.system.split(/[\\.:]/);\r\n switch (unitSystemName.toUpperCase()) {\r\n case \"METRIC\":\r\n return \"metric\";\r\n case \"IMPERIAL\":\r\n return \"imperial\";\r\n case \"USCUSTOM\":\r\n return \"usCustomary\";\r\n case \"USSURVEY\":\r\n return \"usSurvey\";\r\n /* c8 ignore next 2 */\r\n default:\r\n return undefined;\r\n }\r\n}\r\n\r\nasync function getFormatPropsFromDefaultFormats({\r\n schemaContext,\r\n formatsMap,\r\n unitSystem,\r\n koqName,\r\n}: {\r\n schemaContext: SchemaContext;\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n formatsMap: FormatsMap;\r\n unitSystem: UnitSystemKey;\r\n koqName: string;\r\n}): Promise<FormatProps | undefined> {\r\n const koq = await getKoq(schemaContext, koqName);\r\n /* c8 ignore next 3 */\r\n if (!koq) {\r\n return undefined;\r\n }\r\n\r\n const persistenceUnit = await koq.persistenceUnit;\r\n /* c8 ignore next 3 */\r\n if (!persistenceUnit) {\r\n return undefined;\r\n }\r\n const actualPersistenceUnit = persistenceUnit instanceof InvertedUnit ? /* c8 ignore next */ await persistenceUnit.invertsUnit : persistenceUnit;\r\n const phenomenon = await actualPersistenceUnit?.phenomenon;\r\n if (phenomenon && formatsMap[phenomenon.name.toUpperCase()]) {\r\n const defaultPhenomenonFormats = formatsMap[phenomenon.name.toUpperCase()];\r\n for (const defaultUnitSystemFormat of Array.isArray(defaultPhenomenonFormats)\r\n ? /* c8 ignore next */ defaultPhenomenonFormats\r\n : [defaultPhenomenonFormats]) {\r\n if (defaultUnitSystemFormat.unitSystems.includes(unitSystem)) {\r\n return defaultUnitSystemFormat.format;\r\n }\r\n }\r\n }\r\n return undefined;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"KoqPropertyValueFormatter.js","sourceRoot":"","sources":["../../../src/presentation-common/KoqPropertyValueFormatter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAgC,aAAa,EAAE,UAAU,EAAgC,MAAM,sBAAsB,CAAC;AACrI,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,qBAAqB,EAAE,SAAS,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAmE9J;;;GAGG;AACH,MAAM,OAAO,yBAAyB;I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CAAC;AAED,KAAK,UAAU,gCAAgC,CAAC,EAC9C,aAAa,EACb,UAAU,EACV,UAAU,EACV,OAAO,GAOR;IACC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACjD,sBAAsB;IACtB,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,GAAG,CAAC,eAAe,CAAC;IAClD,sBAAsB;IACtB,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,qBAAqB,GAAG,eAAe,YAAY,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,MAAM,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC;IACjJ,MAAM,UAAU,GAAG,MAAM,qBAAqB,EAAE,UAAU,CAAC;IAC3D,IAAI,UAAU,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;QAC5D,MAAM,wBAAwB,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QAC3E,KAAK,MAAM,uBAAuB,IAAI,KAAK,CAAC,OAAO,CAAC,wBAAwB,CAAC;YAC3E,CAAC,CAAC,oBAAoB,CAAC,wBAAwB;YAC/C,CAAC,CAAC,CAAC,wBAAwB,CAAC,EAAE,CAAC;YAC/B,IAAI,uBAAuB,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC7D,OAAO,uBAAuB,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 - will not be removed until after 2026-08-08. `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 - will not be removed until after 2026-08-08. `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 /** Optional overrides for the format used to parse or format values. */\n formatOverride?: Partial<Omit<FormatProps, \"type\">>;\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 - will not be removed until after 2026-08-08. 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, ...options.formatOverride });\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, ...options.formatOverride });\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LabelDefinition.js","sourceRoot":"","sources":["../../../src/presentation-common/LabelDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AA8BH,gBAAgB;AAChB,MAAM,CAAC,MAAM,mCAAmC,GAAG,WAAW,CAAC;AAE/D,cAAc;AACd,MAAM,KAAW,eAAe,CAoB/B;AApBD,WAAiB,eAAe;IAC9B;;;OAGG;IACH,SAAgB,qBAAqB,CAAC,GAAoB;QACxD,OAAO,GAAG,CAAC,QAAQ,KAAK,mCAAmC,CAAC;IAC9D,CAAC;IAFe,qCAAqB,wBAEpC,CAAA;IAED;;;OAGG;IACH,SAAgB,eAAe,CAAC,KAAa;QAC3C,OAAO;YACL,YAAY,EAAE,KAAK;YACnB,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,QAAQ;SACnB,CAAC;IACJ,CAAC;IANe,+BAAe,kBAM9B,CAAA;AACH,CAAC,EApBgB,eAAe,KAAf,eAAe,QAoB/B","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"LabelDefinition.js","sourceRoot":"","sources":["../../../src/presentation-common/LabelDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AA8BH,gBAAgB;AAChB,MAAM,CAAC,MAAM,mCAAmC,GAAG,WAAW,CAAC;AAE/D,cAAc;AACd,MAAM,KAAW,eAAe,CAoB/B;AApBD,WAAiB,eAAe;IAC9B;;;OAGG;IACH,SAAgB,qBAAqB,CAAC,GAAoB;QACxD,OAAO,GAAG,CAAC,QAAQ,KAAK,mCAAmC,CAAC;IAC9D,CAAC;IAFe,qCAAqB,wBAEpC,CAAA;IAED;;;OAGG;IACH,SAAgB,eAAe,CAAC,KAAa;QAC3C,OAAO;YACL,YAAY,EAAE,KAAK;YACnB,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,QAAQ;SACnB,CAAC;IACJ,CAAC;IANe,+BAAe,kBAM9B,CAAA;AACH,CAAC,EApBgB,eAAe,KAAf,eAAe,QAoB/B","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 Hierarchies\n */\n\n/**\n * Data structure that describes raw composite label value.\n * @public\n */\nexport interface LabelCompositeValue {\n separator: string;\n values: LabelDefinition[];\n}\n\n/**\n * Type definition of label raw value.\n * @public\n */\nexport type LabelRawValue = string | number | boolean | LabelCompositeValue;\n\n/**\n * Data structure that describes label definition.\n * @public\n */\nexport interface LabelDefinition {\n /** Display value of label */\n displayValue: string;\n /** Raw value of label */\n rawValue: LabelRawValue;\n /** Type name of raw value */\n typeName: string;\n}\n\n/** @internal */\nexport const COMPOSITE_LABEL_DEFINITION_TYPENAME = \"composite\";\n\n/** @public */\nexport namespace LabelDefinition {\n /**\n * Checks if provided [[LabelDefinition]] has raw value of type [[LabelCompositeValue]].\n * @public\n */\n export function isCompositeDefinition(def: LabelDefinition): def is LabelDefinition & { rawValue: LabelCompositeValue } {\n return def.typeName === COMPOSITE_LABEL_DEFINITION_TYPENAME;\n }\n\n /**\n * Creates [[LabelDefinition]] from string value.\n * @public\n */\n export function fromLabelString(label: string): LabelDefinition {\n return {\n displayValue: label,\n rawValue: label,\n typeName: \"string\",\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalizationHelper.js","sourceRoot":"","sources":["../../../src/presentation-common/LocalizationHelper.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO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,CAAC,oBAAoB,EAAE,EAAE,CAAC;YACxC,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC;QACvF,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,8CAA8C;IACtC,+BAA+B,CAAC,QAA6B;QACnE,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACzD,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACrE,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,wBAAwB,CAAC,KAAmB;QAClD,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE,CAAC;YACjC,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5G,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 Core\r\n */\r\n\r\nimport { CategoryDescription } from \"./content/Category.js\";\r\nimport { Content } from \"./content/Content.js\";\r\nimport { Descriptor } from \"./content/Descriptor.js\";\r\nimport { Field } from \"./content/Fields.js\";\r\nimport { Item } from \"./content/Item.js\";\r\nimport { DisplayValue, DisplayValueGroup, Value } from \"./content/Value.js\";\r\nimport { ElementProperties } from \"./ElementProperties.js\";\r\nimport { Node } from \"./hierarchy/Node.js\";\r\nimport { NodePathElement } from \"./hierarchy/NodePathElement.js\";\r\nimport { COMPOSITE_LABEL_DEFINITION_TYPENAME, LabelCompositeValue, LabelDefinition } from \"./LabelDefinition.js\";\r\n\r\nconst KEY_PATTERN = /@[\\w\\d\\-_]+:[\\w\\d\\-\\._]+?@/g;\r\n\r\ninterface LocalizationHelperProps {\r\n getLocalizedString: (key: string) => string;\r\n}\r\n\r\n/** @internal */\r\nexport class LocalizationHelper {\r\n private _getLocalizedString: (key: string) => string;\r\n\r\n constructor(props: LocalizationHelperProps) {\r\n this._getLocalizedString = props.getLocalizedString;\r\n }\r\n\r\n public getLocalizedString(text: string) {\r\n return text.replace(KEY_PATTERN, (key) => this._getLocalizedString(key.replace(/^@|@$/g, \"\")));\r\n }\r\n\r\n /* eslint-disable @typescript-eslint/no-deprecated */\r\n public getLocalizedNodes(nodes: Node[]): Node[] {\r\n return nodes.map((n) => this.getLocalizedNode(n));\r\n }\r\n\r\n public getLocalizedNode(node: Node): Node {\r\n return {\r\n ...node,\r\n label: this.getLocalizedLabelDefinition(node.label),\r\n ...(node.description ? { description: this.getLocalizedString(node.description) } : undefined),\r\n };\r\n }\r\n\r\n public getLocalizedNodePathElement(npe: NodePathElement): NodePathElement {\r\n return {\r\n ...npe,\r\n node: this.getLocalizedNode(npe.node),\r\n children: npe.children.map((c) => this.getLocalizedNodePathElement(c)),\r\n };\r\n }\r\n /* eslint-enable @typescript-eslint/no-deprecated */\r\n\r\n public getLocalizedDisplayValueGroup(group: DisplayValueGroup): DisplayValueGroup {\r\n return {\r\n ...group,\r\n displayValue: this.getLocalizedDisplayValue(group.displayValue),\r\n };\r\n }\r\n\r\n public getLocalizedLabelDefinition(labelDefinition: LabelDefinition): LabelDefinition {\r\n const getLocalizedComposite = (compositeValue: LabelCompositeValue) => ({\r\n ...compositeValue,\r\n values: compositeValue.values.map((value) => this.getLocalizedLabelDefinition(value)),\r\n });\r\n\r\n if (labelDefinition.typeName === COMPOSITE_LABEL_DEFINITION_TYPENAME) {\r\n return {\r\n ...labelDefinition,\r\n rawValue: getLocalizedComposite(labelDefinition.rawValue as LabelCompositeValue),\r\n };\r\n }\r\n if (labelDefinition.typeName === \"string\") {\r\n return {\r\n ...labelDefinition,\r\n rawValue: this.getLocalizedString(labelDefinition.rawValue as string),\r\n displayValue: this.getLocalizedString(labelDefinition.displayValue),\r\n };\r\n }\r\n return labelDefinition;\r\n }\r\n\r\n public getLocalizedLabelDefinitions(labelDefinitions: LabelDefinition[]) {\r\n return labelDefinitions.map((labelDefinition) => this.getLocalizedLabelDefinition(labelDefinition));\r\n }\r\n\r\n public getLocalizedContentDescriptor(descriptor: Descriptor) {\r\n const clone = new Descriptor(descriptor);\r\n clone.fields.forEach((field) => this.getLocalizedContentField(field));\r\n clone.categories.forEach((category) => this.getLocalizedCategoryDescription(category));\r\n return clone;\r\n }\r\n\r\n public getLocalizedContentItems(items: Item[]): Item[] {\r\n return items.map((item) => this.getLocalizedContentItem(item));\r\n }\r\n\r\n public getLocalizedContent(content: Content): Content {\r\n return new Content(this.getLocalizedContentDescriptor(content.descriptor), this.getLocalizedContentItems(content.contentSet));\r\n }\r\n\r\n public getLocalizedElementProperties(elem: ElementProperties): ElementProperties {\r\n return {\r\n ...elem,\r\n label: this.getLocalizedString(elem.label),\r\n };\r\n }\r\n\r\n // warning: this function mutates the item\r\n private getLocalizedContentItem(item: Item): Item {\r\n item.label = this.getLocalizedLabelDefinition(item.label);\r\n item.values = Object.entries(item.values).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {});\r\n item.displayValues = Object.entries(item.displayValues).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {});\r\n return item;\r\n }\r\n\r\n private getLocalizedRawValue(value: Value): Value {\r\n if (typeof value === \"string\") {\r\n return this.getLocalizedString(value);\r\n }\r\n if (Value.isNavigationValue(value)) {\r\n return {\r\n ...value,\r\n label: this.getLocalizedLabelDefinition(value.label),\r\n };\r\n }\r\n if (Value.isNestedContent(value)) {\r\n return value.map((item) => ({\r\n ...item,\r\n values: Object.entries(item.values).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {}),\r\n displayValues: Object.entries(item.displayValues).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {}),\r\n }));\r\n }\r\n if (Value.isArray(value)) {\r\n return value.map((v) => this.getLocalizedRawValue(v));\r\n }\r\n if (Value.isMap(value)) {\r\n return Object.entries(value).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {});\r\n }\r\n return value;\r\n }\r\n\r\n // warning: this function mutates the field\r\n private getLocalizedContentField<TField extends Field>(field: TField) {\r\n field.label = this.getLocalizedString(field.label);\r\n if (field.isPropertiesField()) {\r\n if (field.isStructPropertiesField()) {\r\n field.memberFields = field.memberFields.map((m) => this.getLocalizedContentField(m));\r\n } else if (field.isArrayPropertiesField()) {\r\n field.itemsField = this.getLocalizedContentField(field.itemsField);\r\n }\r\n } else if (field.isNestedContentField()) {\r\n field.nestedFields = field.nestedFields.map((m) => this.getLocalizedContentField(m));\r\n }\r\n return field;\r\n }\r\n\r\n // warning: this function mutates the category\r\n private getLocalizedCategoryDescription(category: CategoryDescription) {\r\n category.label = this.getLocalizedString(category.label);\r\n category.description = this.getLocalizedString(category.description);\r\n return category;\r\n }\r\n\r\n private getLocalizedDisplayValue(value: DisplayValue): DisplayValue {\r\n if (typeof value === \"undefined\") {\r\n return undefined;\r\n }\r\n if (typeof value === \"string\") {\r\n return this.getLocalizedString(value);\r\n }\r\n if (DisplayValue.isArray(value)) {\r\n return value.map((v) => this.getLocalizedDisplayValue(v));\r\n }\r\n return Object.entries(value).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {});\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"LocalizationHelper.js","sourceRoot":"","sources":["../../../src/presentation-common/LocalizationHelper.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAI5E,OAAO,EAAE,mCAAmC,EAAwC,MAAM,sBAAsB,CAAC;AAEjH,MAAM,WAAW,GAAG,6BAA6B,CAAC;AAMlD,gBAAgB;AAChB,MAAM,OAAO,kBAAkB;IACrB,mBAAmB,CAA0B;IAErD,YAAY,KAA8B;QACxC,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC,kBAAkB,CAAC;IACtD,CAAC;IAEM,kBAAkB,CAAC,IAAY;QACpC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACjG,CAAC;IAED,qDAAqD;IAC9C,iBAAiB,CAAC,KAAa;QACpC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;IAEM,gBAAgB,CAAC,IAAU;QAChC,O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AC;YAChC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5G,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 { CategoryDescription } from \"./content/Category.js\";\nimport { Content } from \"./content/Content.js\";\nimport { Descriptor } from \"./content/Descriptor.js\";\nimport { Field } from \"./content/Fields.js\";\nimport { Item } from \"./content/Item.js\";\nimport { DisplayValue, DisplayValueGroup, Value } from \"./content/Value.js\";\nimport { ElementProperties } from \"./ElementProperties.js\";\nimport { Node } from \"./hierarchy/Node.js\";\nimport { NodePathElement } from \"./hierarchy/NodePathElement.js\";\nimport { COMPOSITE_LABEL_DEFINITION_TYPENAME, LabelCompositeValue, LabelDefinition } from \"./LabelDefinition.js\";\n\nconst KEY_PATTERN = /@[\\w\\d\\-_]+:[\\w\\d\\-\\._]+?@/g;\n\ninterface LocalizationHelperProps {\n getLocalizedString: (key: string) => string;\n}\n\n/** @internal */\nexport class LocalizationHelper {\n private _getLocalizedString: (key: string) => string;\n\n constructor(props: LocalizationHelperProps) {\n this._getLocalizedString = props.getLocalizedString;\n }\n\n public getLocalizedString(text: string) {\n return text.replace(KEY_PATTERN, (key) => this._getLocalizedString(key.replace(/^@|@$/g, \"\")));\n }\n\n /* eslint-disable @typescript-eslint/no-deprecated */\n public getLocalizedNodes(nodes: Node[]): Node[] {\n return nodes.map((n) => this.getLocalizedNode(n));\n }\n\n public getLocalizedNode(node: Node): Node {\n return {\n ...node,\n label: this.getLocalizedLabelDefinition(node.label),\n ...(node.description ? { description: this.getLocalizedString(node.description) } : undefined),\n };\n }\n\n public getLocalizedNodePathElement(npe: NodePathElement): NodePathElement {\n return {\n ...npe,\n node: this.getLocalizedNode(npe.node),\n children: npe.children.map((c) => this.getLocalizedNodePathElement(c)),\n };\n }\n /* eslint-enable @typescript-eslint/no-deprecated */\n\n public getLocalizedDisplayValueGroup(group: DisplayValueGroup): DisplayValueGroup {\n return {\n ...group,\n displayValue: this.getLocalizedDisplayValue(group.displayValue),\n };\n }\n\n public getLocalizedLabelDefinition(labelDefinition: LabelDefinition): LabelDefinition {\n const getLocalizedComposite = (compositeValue: LabelCompositeValue) => ({\n ...compositeValue,\n values: compositeValue.values.map((value) => this.getLocalizedLabelDefinition(value)),\n });\n\n if (labelDefinition.typeName === COMPOSITE_LABEL_DEFINITION_TYPENAME) {\n return {\n ...labelDefinition,\n rawValue: getLocalizedComposite(labelDefinition.rawValue as LabelCompositeValue),\n };\n }\n if (labelDefinition.typeName === \"string\") {\n return {\n ...labelDefinition,\n rawValue: this.getLocalizedString(labelDefinition.rawValue as string),\n displayValue: this.getLocalizedString(labelDefinition.displayValue),\n };\n }\n return labelDefinition;\n }\n\n public getLocalizedLabelDefinitions(labelDefinitions: LabelDefinition[]) {\n return labelDefinitions.map((labelDefinition) => this.getLocalizedLabelDefinition(labelDefinition));\n }\n\n public getLocalizedContentDescriptor(descriptor: Descriptor) {\n const clone = new Descriptor(descriptor);\n clone.fields.forEach((field) => this.getLocalizedContentField(field));\n clone.categories.forEach((category) => this.getLocalizedCategoryDescription(category));\n return clone;\n }\n\n public getLocalizedContentItems(items: Item[]): Item[] {\n return items.map((item) => this.getLocalizedContentItem(item));\n }\n\n public getLocalizedContent(content: Content): Content {\n return new Content(this.getLocalizedContentDescriptor(content.descriptor), this.getLocalizedContentItems(content.contentSet));\n }\n\n public getLocalizedElementProperties(elem: ElementProperties): ElementProperties {\n return {\n ...elem,\n label: this.getLocalizedString(elem.label),\n };\n }\n\n // warning: this function mutates the item\n private getLocalizedContentItem(item: Item): Item {\n item.label = this.getLocalizedLabelDefinition(item.label);\n item.values = Object.entries(item.values).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {});\n item.displayValues = Object.entries(item.displayValues).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {});\n return item;\n }\n\n private getLocalizedRawValue(value: Value): Value {\n if (typeof value === \"string\") {\n return this.getLocalizedString(value);\n }\n if (Value.isNavigationValue(value)) {\n return {\n ...value,\n label: this.getLocalizedLabelDefinition(value.label),\n };\n }\n if (Value.isNestedContent(value)) {\n return value.map((item) => ({\n ...item,\n values: Object.entries(item.values).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {}),\n displayValues: Object.entries(item.displayValues).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {}),\n }));\n }\n if (Value.isArray(value)) {\n return value.map((v) => this.getLocalizedRawValue(v));\n }\n if (Value.isMap(value)) {\n return Object.entries(value).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {});\n }\n return value;\n }\n\n // warning: this function mutates the field\n private getLocalizedContentField<TField extends Field>(field: TField) {\n field.label = this.getLocalizedString(field.label);\n if (field.isPropertiesField()) {\n if (field.isStructPropertiesField()) {\n field.memberFields = field.memberFields.map((m) => this.getLocalizedContentField(m));\n } else if (field.isArrayPropertiesField()) {\n field.itemsField = this.getLocalizedContentField(field.itemsField);\n }\n } else if (field.isNestedContentField()) {\n field.nestedFields = field.nestedFields.map((m) => this.getLocalizedContentField(m));\n }\n return field;\n }\n\n // warning: this function mutates the category\n private getLocalizedCategoryDescription(category: CategoryDescription) {\n category.label = this.getLocalizedString(category.label);\n category.description = this.getLocalizedString(category.description);\n return category;\n }\n\n private getLocalizedDisplayValue(value: DisplayValue): DisplayValue {\n if (typeof value === \"undefined\") {\n return undefined;\n }\n if (typeof value === \"string\") {\n return this.getLocalizedString(value);\n }\n if (DisplayValue.isArray(value)) {\n return value.map((v) => this.getLocalizedDisplayValue(v));\n }\n return Object.entries(value).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {});\n }\n}\n"]}
|