@itwin/presentation-common
Version:
Common pieces for iModel.js presentation packages
297 lines • 10.3 kB
TypeScript
/** @packageDocumentation
* @module Core
*/
import { Id64String } from "@itwin/core-bentley";
import { FormatProps } from "@itwin/core-quantity";
import { PartialBy } from "./Utils.js";
/**
* Type of an ECClass ID.
* @public
*/
export type ClassId = Id64String;
/**
* Type of an ECInstance ID.
* @public
*/
export type InstanceId = Id64String;
/**
* A key that uniquely identifies an instance in an iModel
* @public
*/
export interface InstanceKey {
/** Full class name in format `SchemaName:ClassName` */
className: string;
/** ECInstance ID */
id: InstanceId;
}
/** @public */
export declare namespace InstanceKey {
/** Compare 2 instance keys */
function compare(lhs: InstanceKey, rhs: InstanceKey): number;
}
/**
* Information about an ECClass
* @public
*/
export interface ClassInfo {
/** ECClass ID */
id: ClassId;
/** Full class name in format `SchemaName:ClassName` */
name: string;
/** ECClass label */
label: string;
}
/**
* A serialized and compressed version of [[ClassInfo]]
* @public
*/
export interface CompressedClassInfoJSON {
name: string;
label: string;
}
/**
* A single choice in enumeration
* @public
*/
export interface EnumerationChoice {
/** Label of the choice */
label: string;
/** Value of the choice */
value: string | number;
}
/**
* Enumeration information
* @public
*/
export interface EnumerationInfo {
/** Available enumeration choices */
choices: EnumerationChoice[];
/** Is the enumeration strict (values only allowed from `choices` list) */
isStrict: boolean;
}
/**
* Kind of quantity information
* @public
*/
export interface KindOfQuantityInfo {
/** Full name of KindOfQuantity in format `SchemaName:KindOfQuantityName` */
name: string;
/** Label of KindOfQuantity */
label: string;
/** Persistence unit full class name in format `SchemaName:UnitName`. */
persistenceUnit: string;
/** Active format that was used to format property value. */
activeFormat?: FormatProps;
}
/**
* A data structure for storing navigation property information.
* @public
*/
export interface NavigationPropertyInfo {
/** Information about ECProperty's relationship class */
classInfo: ClassInfo;
/** Is the direction of the relationship forward */
isForwardRelationship: boolean;
/** Information about ECProperty's target class */
targetClassInfo: ClassInfo;
/** Is ECProperty's target class polymorphic */
isTargetPolymorphic: boolean;
}
/**
* Contains utilities for working with objects of [[NavigationPropertyInfo]] type.
* @public
*/
export declare namespace NavigationPropertyInfo {
/** Serialize [[NavigationPropertyInfo]] to compressed JSON */
function toCompressedJSON(navigationPropertyInfo: NavigationPropertyInfo, classesMap: {
[id: string]: CompressedClassInfoJSON;
}): NavigationPropertyInfoJSON<string>;
/** Deserialize [[NavigationPropertyInfo]] from compressed JSON */
function fromCompressedJSON(compressedNavigationPropertyInfoJSON: NavigationPropertyInfoJSON<string>, classesMap: {
[id: string]: CompressedClassInfoJSON;
}): NavigationPropertyInfo;
}
/**
* A serialized version of [[NavigationPropertyInfo]]
* @public
*/
export interface NavigationPropertyInfoJSON<TClassInfoJSON = ClassInfo> {
classInfo: TClassInfoJSON;
isForwardRelationship: boolean;
targetClassInfo: TClassInfoJSON;
isTargetPolymorphic: boolean;
}
/**
* A structure that describes an ECProperty
* @public
*/
export interface PropertyInfo {
/** Information about ECProperty class */
classInfo: ClassInfo;
/** Name of the ECProperty */
name: string;
/** Type name of the ECProperty */
type: string;
/** Enumeration info if the property is enumerable */
enumerationInfo?: EnumerationInfo;
/** Kind of quantity information, if any. */
kindOfQuantity?: KindOfQuantityInfo;
/** Extended type name of the ECProperty if it has one */
extendedType?: string;
/** Navigation property info if the field is navigation type */
navigationPropertyInfo?: NavigationPropertyInfo;
/** Constraints for values of ECProperty */
constraints?: PropertyValueConstraints;
}
/**
* Constraints for values of ECProperty
* @public
*/
export type PropertyValueConstraints = StringPropertyValueConstraints | ArrayPropertyValueConstraints | NumericPropertyValueConstraints;
/**
* Describes constraints for `string` type ECProperty values
* @public
*/
export interface StringPropertyValueConstraints {
minimumLength?: number;
maximumLength?: number;
}
/**
* Describes constraints for `int` | `double` | `float` type ECProperty values
* @public
*/
export interface NumericPropertyValueConstraints {
minimumValue?: number;
maximumValue?: number;
}
/**
* Describes constraints for `array` type ECProperty values
* @public
*/
export interface ArrayPropertyValueConstraints {
minOccurs?: number;
maxOccurs?: number;
}
/** @public */
export declare namespace PropertyInfo {
/** Serialize [[PropertyInfo]] to compressed JSON */
function toCompressedJSON(propertyInfo: PropertyInfo, classesMap: {
[id: string]: CompressedClassInfoJSON;
}): PropertyInfoJSON<string>;
}
/**
* A serialized version of [[PropertyInfo]]
* @public
*/
export interface PropertyInfoJSON<TClassInfoJSON = ClassInfo> {
classInfo: TClassInfoJSON;
name: string;
type: string;
enumerationInfo?: EnumerationInfo;
kindOfQuantity?: KindOfQuantityInfo;
navigationPropertyInfo?: NavigationPropertyInfoJSON<TClassInfoJSON>;
}
/**
* A structure that describes a related class and the properties of that relationship.
* @public
*/
export interface RelatedClassInfo {
/** Information about the source ECClass */
sourceClassInfo: ClassInfo;
/** Information about the target ECClass */
targetClassInfo: ClassInfo;
/** Is target class handled polymorphically */
isPolymorphicTargetClass?: boolean;
/** Optionally, IDs of specific target class instances. */
targetInstanceIds?: Id64String[];
/** Information about the ECRelationship */
relationshipInfo: ClassInfo;
/** Should relationship be followed in a forward direction to access the related class. */
isForwardRelationship: boolean;
/** Is relationship handled polymorphically */
isPolymorphicRelationship?: boolean;
}
/** @public */
export declare namespace RelatedClassInfo {
/** Serialize [[RelatedClassInfo]] to compressed JSON */
function toCompressedJSON(classInfo: RelatedClassInfo, classesMap: {
[id: string]: CompressedClassInfoJSON;
}): RelatedClassInfoJSON<string>;
/** Deserialize [[RelatedClassInfo]] from compressed JSON */
function fromCompressedJSON(json: RelatedClassInfoJSON<string>, classesMap: {
[id: string]: CompressedClassInfoJSON;
}): RelatedClassInfo;
/** Check two [[RelatedClassInfo]] or [[StrippedRelatedClassInfo]] for equality */
function equals(lhs: RelatedClassInfo | StrippedRelatedClassInfo, rhs: RelatedClassInfo | StrippedRelatedClassInfo): boolean;
/** Strip given [[RelatedClassInfo]] to [[StrippedRelatedClassInfo]] */
function strip(full: RelatedClassInfo): StrippedRelatedClassInfo;
}
/**
* A serialized version of [[RelatedClassInfo]]
* @public
*/
export interface RelatedClassInfoJSON<TClassInfoJSON = ClassInfo> {
sourceClassInfo: TClassInfoJSON;
targetClassInfo: TClassInfoJSON;
isPolymorphicTargetClass?: boolean;
targetInstanceIds?: Id64String[];
relationshipInfo: TClassInfoJSON;
isForwardRelationship: boolean;
isPolymorphicRelationship?: boolean;
}
/**
* A structure that describes a relationship between source and target classes where
* an actual ECRelationship between them is optional.
* @public
*/
export type RelatedClassInfoWithOptionalRelationship = PartialBy<RelatedClassInfo, "relationshipInfo" | "isForwardRelationship" | "isPolymorphicRelationship">;
/** @public */
export type RelatedClassInfoWithOptionalRelationshipJSON<TClassInfoJSON = ClassInfo> = PartialBy<RelatedClassInfoJSON<TClassInfoJSON>, "relationshipInfo" | "isForwardRelationship" | "isPolymorphicRelationship">;
/** @public */
export declare namespace RelatedClassInfoWithOptionalRelationship {
/** Serialize [[RelatedClassInfoWithOptionalRelationship]] to compressed JSON */
function toCompressedJSON(classInfo: RelatedClassInfoWithOptionalRelationship, classesMap: {
[id: string]: CompressedClassInfoJSON;
}): RelatedClassInfoWithOptionalRelationshipJSON<string>;
/** Deserialize [[RelatedClassInfoWithOptionalRelationship]] from compressed JSON */
function fromCompressedJSON(json: RelatedClassInfoWithOptionalRelationshipJSON<string>, classesMap: {
[id: string]: CompressedClassInfoJSON;
}): RelatedClassInfoWithOptionalRelationship;
}
/**
* A structure that describes a related class path.
* @public
*/
export type RelationshipPath = RelatedClassInfo[];
/**
* Serialized [[RelationshipPath]]
* @public
*/
export type RelationshipPathJSON<TClassInfoJSON = ClassInfo> = RelatedClassInfoJSON<TClassInfoJSON>[];
/** @public */
export declare namespace RelationshipPath {
/** Reverse direction of the given [[RelationshipPath]] */
function reverse(path: RelationshipPath): RelationshipPath;
/** Check two [[RelationshipPath]] or [[StrippedRelationshipPath]] for equality */
function equals(lhs: Array<RelatedClassInfo | StrippedRelatedClassInfo>, rhs: Array<RelatedClassInfo | StrippedRelatedClassInfo>): boolean;
/** Strip given [[RelationshipPath]] to [[StrippedRelationshipPath]] */
function strip(full: RelationshipPath): StrippedRelationshipPath;
}
/**
* Data structure that contains a subset of [[RelatedClassInfo]] required to
* identify the relationship.
* @public
*/
export interface StrippedRelatedClassInfo {
sourceClassName: string;
targetClassName: string;
relationshipName: string;
isForwardRelationship: boolean;
}
/**
* Data structure that contains a subset of [[RelationshipPath]] required to
* identify the relationship path.
* @public
*/
export type StrippedRelationshipPath = StrippedRelatedClassInfo[];
//# sourceMappingURL=EC.d.ts.map