@itwin/presentation-common
Version:
Common pieces for iModel.js presentation packages
171 lines • 5.5 kB
TypeScript
/** @packageDocumentation
* @module Hierarchies
*/
import { Id64String } from "@itwin/core-bentley";
import { InstanceKey } from "../EC.js";
/**
* Standard node types
* @public
*/
export declare enum StandardNodeTypes {
ECInstancesNode = "ECInstancesNode",
ECClassGroupingNode = "ECClassGroupingNode",
ECPropertyGroupingNode = "ECPropertyGroupingNode",
DisplayLabelGroupingNode = "DisplayLabelGroupingNode"
}
/**
* One of the node key types
* @public
*/
export type NodeKey = BaseNodeKey | ECInstancesNodeKey | ECClassGroupingNodeKey | ECPropertyGroupingNodeKey | LabelGroupingNodeKey;
/** @public */
export declare namespace NodeKey {
/** Checks if the supplied key is an [[ECInstancesNodeKey]] */
function isInstancesNodeKey(key: NodeKey): key is ECInstancesNodeKey;
/** Checks if the supplied key is an [[ECClassGroupingNodeKey]] */
function isClassGroupingNodeKey(key: NodeKey): key is ECClassGroupingNodeKey;
/** Checks if the supplied key is an [[ECPropertyGroupingNodeKey]] */
function isPropertyGroupingNodeKey(key: NodeKey): key is ECPropertyGroupingNodeKey;
/** Checks if the supplied key is a [[LabelGroupingNodeKey]] */
function isLabelGroupingNodeKey(key: NodeKey): key is LabelGroupingNodeKey;
/** Checks if the supplied key is a grouping node key */
function isGroupingNodeKey(key: NodeKey): key is GroupingNodeKey;
/**
* Checks if two given node keys are equal, taking their versions into account.
*
* When comparing two keys of the same version, the algorithm uses [[NodeKey.pathFromRoot]] array
* which is the most accurate way of checking equality. However, when version are different,
* [[NodeKey.pathFromRoot]] array may contain different strings even though keys represent the same node.
* In that case equality is checked using other key attributes, depending on the type of the node (type,
* label, grouping class, property name, etc.).
*/
function equals(lhs: NodeKey, rhs: NodeKey): boolean;
}
/**
* Node key path. Can be used to define path from one node to another.
* @public
*/
export type NodeKeyPath = NodeKey[];
/**
* Data structure that describes a basic node key
* @public
*/
export interface BaseNodeKey {
/** Node type */
type: string;
/**
* Version of the key. Different versions suggest that node keys were created by two different
* versions of the library. In that case, keys representing the same node may be different.
*/
version: number;
/** Node hash path from root to the node whose key this is */
pathFromRoot: string[];
/** Query that returns all selected instance keys */
instanceKeysSelectQuery?: PresentationQuery;
}
/**
* Data structure that describes a node ECInstance node key
* @public
*/
export interface ECInstancesNodeKey extends BaseNodeKey {
type: StandardNodeTypes.ECInstancesNode;
/** List of [[InstanceKey]] objects of ECInstances represented by the node */
instanceKeys: InstanceKey[];
}
/**
* Data structure that describes a grouping node key
* @public
*/
export interface GroupingNodeKey extends BaseNodeKey {
/**
* Get the number of instances grouped by the node represented
* by this key.
*
* **Note:** this property is just a helper and is not involved
* in identifying a node.
*/
groupedInstancesCount: number;
}
/**
* Data structure that describes an ECClass grouping node key
* @public
*/
export interface ECClassGroupingNodeKey extends GroupingNodeKey {
type: StandardNodeTypes.ECClassGroupingNode;
/** Full name of the grouping ECClass */
className: string;
}
/**
* Data structure that describes an ECProperty grouping node key
* @public
*/
export interface ECPropertyGroupingNodeKey extends GroupingNodeKey {
type: StandardNodeTypes.ECPropertyGroupingNode;
/** Full name of the grouping ECProperty class */
className: string;
/** Name of the ECProperty */
propertyName: string;
/** Raw grouping values */
groupingValues: any[];
}
/**
* Data structure that describes a display label grouping node key
* @public
*/
export interface LabelGroupingNodeKey extends GroupingNodeKey {
type: StandardNodeTypes.DisplayLabelGroupingNode;
/** Grouping display label */
label: string;
}
/**
* Data structure that describes a presentation query
* @public
*/
export interface PresentationQuery {
/** ECSQL query */
query: string;
/** The query bindings */
bindings?: PresentationQueryBinding[];
}
/**
* Defines an [[Id64String]] value binding.
* @public
*/
export interface IdBinding {
type: "Id";
value: Id64String;
}
/**
* Defines an [[IdSet]] value binding for use with `InVirtualSet` ECSQL function.
* @public
*/
export interface IdSetBinding {
type: "IdSet";
value: Id64String[];
}
/**
* Defines an EC value binding.
* @public
*/
export interface ECValueBinding {
type: "ECValue";
valueType: string;
valueTypeExtended?: string;
value: any;
}
/**
* Defines a binding for a list of EC values for use with `InVirtualSet` ECSQL function.
* @public
*/
export interface ECValueSetBinding {
type: "ValueSet";
valueType: string;
valueTypeExtended?: string;
value: any[];
}
/**
* One of the [[PresentationQuery]] binding types.
* @public
*/
export type PresentationQueryBinding = IdBinding | IdSetBinding | ECValueBinding | ECValueSetBinding;
//# sourceMappingURL=Key.d.ts.map