@itwin/presentation-hierarchies 2.0.0-alpha.15 → 2.0.0-alpha.16
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 +47 -0
- package/README.md +6 -17
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts +2 -33
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts +20 -2
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +27 -21
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/LimitingECSqlQueryExecutor.js +6 -2
- package/lib/cjs/hierarchies/imodel/LimitingECSqlQueryExecutor.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts +4 -3
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js +11 -6
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/Utils.d.ts +1 -0
- package/lib/cjs/hierarchies/imodel/Utils.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/Utils.js +2 -0
- package/lib/cjs/hierarchies/imodel/Utils.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/DetermineChildren.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/Grouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideNodesInHierarchy.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ReleaseMainThread.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies.d.ts +0 -2
- package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies.js +1 -4
- package/lib/cjs/presentation-hierarchies.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts +2 -33
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts +20 -2
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +27 -21
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/imodel/LimitingECSqlQueryExecutor.js +6 -2
- package/lib/esm/hierarchies/imodel/LimitingECSqlQueryExecutor.js.map +1 -1
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts +4 -3
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js +11 -6
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
- package/lib/esm/hierarchies/imodel/Utils.d.ts +1 -0
- package/lib/esm/hierarchies/imodel/Utils.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/Utils.js +1 -0
- package/lib/esm/hierarchies/imodel/Utils.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/DetermineChildren.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/Grouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideNodesInHierarchy.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/ReleaseMainThread.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies.d.ts +0 -2
- package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies.js +0 -1
- package/lib/esm/presentation-hierarchies.js.map +1 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.16
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#1350](https://github.com/iTwin/presentation/pull/1350): **Breaking:** `createInstanceKeysFilteredQuery` now correctly appends `IdSet` bindings in both positional and named binding formats, using the `IdSet` virtual table instead of `InVirtualSet`.
|
|
8
|
+
|
|
9
|
+
Consumers that provide their own `LimitingECSqlQueryExecutor` or `imodelAccess` may now receive named bindings (`Record<string, ECSqlBinding>`) through the public `createQueryReader` path.
|
|
10
|
+
|
|
11
|
+
To migrate, update custom query reader / executor implementations to handle both positional bindings (`ECSqlBinding[]`) and named bindings (`Record<string, ECSqlBinding>`), or use the default implementation provided by the `@itwin/presentation-core-interop` package, `createECSqlQueryExecutor` function.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies:
|
|
16
|
+
- @itwin/presentation-shared@2.0.0-alpha.11
|
|
17
|
+
|
|
3
18
|
## 2.0.0-alpha.15
|
|
4
19
|
|
|
5
20
|
### Major Changes
|
|
@@ -595,6 +610,38 @@
|
|
|
595
610
|
- Updated dependencies:
|
|
596
611
|
- @itwin/presentation-shared@2.0.0-alpha.0
|
|
597
612
|
|
|
613
|
+
## 1.7.16
|
|
614
|
+
|
|
615
|
+
### Patch Changes
|
|
616
|
+
|
|
617
|
+
- [#1390](https://github.com/iTwin/presentation/pull/1390): Update `@itwin/core-*` dependencies to `^5.10.0`.
|
|
618
|
+
- Updated dependencies:
|
|
619
|
+
- @itwin/presentation-shared@1.2.16
|
|
620
|
+
|
|
621
|
+
## 1.7.15
|
|
622
|
+
|
|
623
|
+
### Patch Changes
|
|
624
|
+
|
|
625
|
+
- [#1358](https://github.com/iTwin/presentation/pull/1358): Bump dependencies.
|
|
626
|
+
- Updated dependencies:
|
|
627
|
+
- @itwin/presentation-shared@1.2.14
|
|
628
|
+
|
|
629
|
+
## 1.7.14
|
|
630
|
+
|
|
631
|
+
### Patch Changes
|
|
632
|
+
|
|
633
|
+
- [#1338](https://github.com/iTwin/presentation/pull/1338): Bump iTwin.js core dependencies to `^5.9.1`.
|
|
634
|
+
- Updated dependencies:
|
|
635
|
+
- @itwin/presentation-shared@1.2.13
|
|
636
|
+
|
|
637
|
+
## 1.7.13
|
|
638
|
+
|
|
639
|
+
### Patch Changes
|
|
640
|
+
|
|
641
|
+
- [#1313](https://github.com/iTwin/presentation/pull/1313): Bump dependencies.
|
|
642
|
+
- Updated dependencies:
|
|
643
|
+
- @itwin/presentation-shared@1.2.12
|
|
644
|
+
|
|
598
645
|
## 1.7.12
|
|
599
646
|
|
|
600
647
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -109,21 +109,16 @@ function createProvider(imodelAccess: Props<typeof createIModelHierarchyProvider
|
|
|
109
109
|
classHierarchyInspector: imodelAccess,
|
|
110
110
|
hierarchy: {
|
|
111
111
|
// For root nodes, select all BisCore.GeometricModel3d instances
|
|
112
|
-
rootNodes: async ({
|
|
112
|
+
rootNodes: async ({ createSelectClause }) => [
|
|
113
113
|
{
|
|
114
114
|
fullClassName: "BisCore.GeometricModel3d",
|
|
115
115
|
query: {
|
|
116
116
|
ecsql: `
|
|
117
117
|
SELECT
|
|
118
|
-
${await
|
|
118
|
+
${await createSelectClause({
|
|
119
119
|
ecClassId: { selector: "this.ECClassId" },
|
|
120
120
|
ecInstanceId: { selector: "this.ECInstanceId" },
|
|
121
|
-
nodeLabel: {
|
|
122
|
-
selector: await instanceLabelSelectClauseFactory.createSelectClause({
|
|
123
|
-
classAlias: "this",
|
|
124
|
-
className: "BisCore.GeometricModel3d",
|
|
125
|
-
}),
|
|
126
|
-
},
|
|
121
|
+
nodeLabel: { of: { classAlias: "this", className: "BisCore.GeometricModel3d" } },
|
|
127
122
|
})}
|
|
128
123
|
FROM BisCore.GeometricModel3d this
|
|
129
124
|
`,
|
|
@@ -136,23 +131,17 @@ function createProvider(imodelAccess: Props<typeof createIModelHierarchyProvider
|
|
|
136
131
|
parentInstancesNodePredicate: "BisCore.Model",
|
|
137
132
|
definitions: async ({
|
|
138
133
|
parentNodeInstanceIds,
|
|
139
|
-
|
|
140
|
-
nodeSelectClauseFactory,
|
|
134
|
+
createSelectClause,
|
|
141
135
|
}: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> => [
|
|
142
136
|
{
|
|
143
137
|
fullClassName: "BisCore.Element",
|
|
144
138
|
query: {
|
|
145
139
|
ecsql: `
|
|
146
140
|
SELECT
|
|
147
|
-
${await
|
|
141
|
+
${await createSelectClause({
|
|
148
142
|
ecClassId: { selector: "this.ECClassId" },
|
|
149
143
|
ecInstanceId: { selector: "this.ECInstanceId" },
|
|
150
|
-
nodeLabel: {
|
|
151
|
-
selector: await instanceLabelSelectClauseFactory.createSelectClause({
|
|
152
|
-
classAlias: "this",
|
|
153
|
-
className: "BisCore.Element",
|
|
154
|
-
}),
|
|
155
|
-
},
|
|
144
|
+
nodeLabel: { of: { classAlias: "this", className: "BisCore.Element" } },
|
|
156
145
|
grouping: { byClass: true },
|
|
157
146
|
})}
|
|
158
147
|
FROM BisCore.Element this
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GenericInstanceFilter } from "@itwin/core-common";
|
|
2
|
-
import type { EC, ECClassHierarchyInspector, ECSchemaProvider, ECSqlQueryDef
|
|
2
|
+
import type { EC, ECClassHierarchyInspector, ECSchemaProvider, ECSqlQueryDef } from "@itwin/presentation-shared";
|
|
3
3
|
import type { NonGroupingHierarchyNode, ParentHierarchyNode } from "../HierarchyNode.js";
|
|
4
4
|
import type { ProcessedGenericHierarchyNode, ProcessedHierarchyNode, ProcessedInstanceHierarchyNode, SourceGenericHierarchyNode, SourceInstanceHierarchyNode } from "./IModelHierarchyNode.js";
|
|
5
5
|
import type { LimitingECSqlQueryExecutor } from "./LimitingECSqlQueryExecutor.js";
|
|
@@ -95,7 +95,7 @@ export type HierarchyDefinitionParentNode = Omit<NonGroupingHierarchyNode, "chil
|
|
|
95
95
|
* Props for `HierarchyDefinition.defineHierarchyLevel`.
|
|
96
96
|
* @public
|
|
97
97
|
*/
|
|
98
|
-
export interface DefineHierarchyLevelProps {
|
|
98
|
+
export interface DefineHierarchyLevelProps extends Pick<NodesQueryClauseFactory, "createSelectClause" | "createFilterClauses"> {
|
|
99
99
|
/** The iModel for which the hierarchy definition is being requested for. */
|
|
100
100
|
imodelAccess: LimitingECSqlQueryExecutor & ECSchemaProvider & ECClassHierarchyInspector & {
|
|
101
101
|
imodelKey: string;
|
|
@@ -104,37 +104,6 @@ export interface DefineHierarchyLevelProps {
|
|
|
104
104
|
parentNode: HierarchyDefinitionParentNode | undefined;
|
|
105
105
|
/** Optional hierarchy level filter. */
|
|
106
106
|
instanceFilter?: GenericInstanceFilter;
|
|
107
|
-
/**
|
|
108
|
-
* A factory for creating ECSQL select clauses for instance labels. Created using
|
|
109
|
-
* `createIModelInstanceLabelSelectClauseFactory` from `@itwin/presentation-shared` and scoped
|
|
110
|
-
* to the iModel identified by `imodelAccess`.
|
|
111
|
-
*
|
|
112
|
-
* Example:
|
|
113
|
-
* ```ts
|
|
114
|
-
* const labelClause = await instanceLabelSelectClauseFactory.createSelectClause({ classAlias: "this", className: "SomeSchema.SomeClass" });
|
|
115
|
-
* ```
|
|
116
|
-
*
|
|
117
|
-
* Using this factory is optional — consumers may create their own `IInstanceLabelSelectClauseFactory`
|
|
118
|
-
* and use it instead, or just define instance label select clauses manually without a factory.
|
|
119
|
-
*/
|
|
120
|
-
instanceLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;
|
|
121
|
-
/**
|
|
122
|
-
* A factory for creating ECSQL select clauses for hierarchy nodes. Created using
|
|
123
|
-
* `createNodesQueryClauseFactory` and scoped to the iModel identified by `imodelAccess`.
|
|
124
|
-
*
|
|
125
|
-
* Example:
|
|
126
|
-
* ```ts
|
|
127
|
-
* const selectClause = await nodeSelectClauseFactory.createSelectClause({
|
|
128
|
-
* ecClassId: { selector: "this.ECClassId" },
|
|
129
|
-
* ecInstanceId: { selector: "this.ECInstanceId" },
|
|
130
|
-
* nodeLabel: { selector: "this.UserLabel" },
|
|
131
|
-
* });
|
|
132
|
-
* ```
|
|
133
|
-
*
|
|
134
|
-
* While using this factory is optional, and consumers may create their own `NodesQueryClauseFactory`,
|
|
135
|
-
* it's strongly recommended to use it to ensure the select clause format is consistent with the parser.
|
|
136
|
-
*/
|
|
137
|
-
nodeSelectClauseFactory: NodesQueryClauseFactory;
|
|
138
107
|
}
|
|
139
108
|
/**
|
|
140
109
|
* An interface for a factory that knows how define a hierarchy based on a given parent node.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"IModelHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,EAAE,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACjH,OAAO,KAAK,EAAE,wBAAwB,EAAE,m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ceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;
|
|
1
|
+
{"version":3,"file":"IModelHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA+ChG,cAAc;AACd,2DAA2D;AAC3D,IAAiB,wBAAwB,CAOxC;AAPD,WAAiB,wBAAwB;IACvC,SAAgB,aAAa,CAAC,GAA6B;QACzD,OAAO,CAAC,CAAE,GAAsC,CAAC,IAAI,CAAC;IACxD,CAAC;IAFe,sCAAa,gBAE5B,CAAA;IACD,SAAgB,oBAAoB,CAAC,GAA6B;QAChE,OAAO,CAAC,CAAE,GAAoC,CAAC,KAAK,CAAC;IACvD,CAAC;IAFe,6CAAoB,uBAEnC,CAAA;AACH,CAAC,EAPgB,wBAAwB,wCAAxB,wBAAwB,QAOxC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport type { GenericInstanceFilter } from \"@itwin/core-common\";\nimport type { EC, ECClassHierarchyInspector, ECSchemaProvider, ECSqlQueryDef } from \"@itwin/presentation-shared\";\nimport type { NonGroupingHierarchyNode, ParentHierarchyNode } from \"../HierarchyNode.js\";\nimport type {\n ProcessedGenericHierarchyNode,\n ProcessedHierarchyNode,\n ProcessedInstanceHierarchyNode,\n SourceGenericHierarchyNode,\n SourceInstanceHierarchyNode,\n} from \"./IModelHierarchyNode.js\";\nimport type { LimitingECSqlQueryExecutor } from \"./LimitingECSqlQueryExecutor.js\";\nimport type { NodesQueryClauseFactory } from \"./NodeSelectQueryFactory.js\";\n\n/**\n * A nodes definition that returns a single generic node.\n * @public\n */\nexport interface GenericHierarchyNodeDefinition {\n /** The node to be created in the hierarchy level */\n node: SourceGenericHierarchyNode;\n}\n\n/**\n * A nodes definition that returns an ECSQL query for selecting nodes from an iModel.\n * @public\n */\nexport interface InstanceNodesQueryDefinition {\n /**\n * Full name of the class whose instances are going to be returned. It's okay if the attribute\n * points to a base class of multiple different classes of instances returned by the query, however\n * the more specific this class is, the more efficient hierarchy building process is.\n */\n fullClassName: EC.FullClassName;\n /**\n * An ECSQL query that selects nodes from an iModel. `SELECT` clause of the query is expected\n * to be built using `NodeSelectQueryFactory.createSelectClause`.\n */\n query: ECSqlQueryDef;\n}\n\n/**\n * A definition of nodes included in a hierarchy level.\n * @public\n */\nexport type HierarchyNodesDefinition = GenericHierarchyNodeDefinition | InstanceNodesQueryDefinition;\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNodesDefinition {\n export function isGenericNode(def: HierarchyNodesDefinition): def is GenericHierarchyNodeDefinition {\n return !!(def as GenericHierarchyNodeDefinition).node;\n }\n export function isInstanceNodesQuery(def: HierarchyNodesDefinition): def is InstanceNodesQueryDefinition {\n return !!(def as InstanceNodesQueryDefinition).query;\n }\n}\n\n/**\n * A definition of a hierarchy level, which may consist of multiple node definitions.\n * @public\n */\nexport type HierarchyLevelDefinition = HierarchyNodesDefinition[];\n\n/**\n * A type for a function that parses a `SourceInstanceHierarchyNode` from provided ECSQL `row` object.\n * @public\n */\nexport type NodeParser = (props: {\n /** The ECSQL row object to parse. Keys & value types depend on the executed query. */\n row: { [columnName: string]: any };\n\n /** The parent node whose child node is being parsed. */\n parentNode?: HierarchyDefinitionParentNode;\n\n /** The key of iModel which is used to run the query. */\n imodelKey: string;\n}) => SourceInstanceHierarchyNode | Promise<SourceInstanceHierarchyNode>;\n\n/**\n * A type for a function that pre-processes given node. Unless the function decides not to make any modifications,\n * it should return a new - modified - node, rather than modifying the given one. Returning `undefined` omits the node\n * from the hierarchy.\n *\n * @public\n */\nexport type NodePreProcessor = <TNode extends ProcessedGenericHierarchyNode | ProcessedInstanceHierarchyNode>(props: {\n /** Node to be pre-processed. */\n node: TNode;\n\n /** The parent node whose child node is being pre-processed. */\n parentNode?: ParentHierarchyNode;\n}) => Promise<TNode | undefined>;\n\n/**\n * A type for a function that post-processes given node. Unless the function decides not to make any modifications,\n * it should return a new - modified - node, rather than modifying the given one.\n *\n * @public\n */\nexport type NodePostProcessor = (props: {\n /** Node to be post-processed. */\n node: ProcessedHierarchyNode;\n\n /** The parent node whose child node is being post-processed. */\n parentNode?: ParentHierarchyNode;\n}) => Promise<ProcessedHierarchyNode>;\n\n/**\n * A type of node that can be passed to `HierarchyDefinition.defineHierarchyLevel`. This basically means\n * a `HierarchyNode` that:\n * - knows nothing about its children,\n * - is either an instances node (key is of `InstancesNodeKey` type) or a generic node (key is of `GenericNodeKey` type).\n * @public\n */\nexport type HierarchyDefinitionParentNode = Omit<NonGroupingHierarchyNode, \"children\">;\n\n/**\n * Props for `HierarchyDefinition.defineHierarchyLevel`.\n * @public\n */\nexport interface DefineHierarchyLevelProps extends Pick<\n NodesQueryClauseFactory,\n \"createSelectClause\" | \"createFilterClauses\"\n> {\n /** The iModel for which the hierarchy definition is being requested for. */\n imodelAccess: LimitingECSqlQueryExecutor & ECSchemaProvider & ECClassHierarchyInspector & { imodelKey: string };\n\n /** Parent node to get children for. Pass `undefined` to get root nodes. */\n parentNode: HierarchyDefinitionParentNode | undefined;\n\n /** Optional hierarchy level filter. */\n instanceFilter?: GenericInstanceFilter;\n}\n\n/**\n * An interface for a factory that knows how define a hierarchy based on a given parent node.\n * @public\n */\nexport interface HierarchyDefinition {\n /**\n * An optional function for parsing ECInstance node from ECSQL row.\n *\n * Should be used in situations when the `HierarchyDefinition` implementation\n * introduces additional ECSQL columns into the select clause and wants to assign additional\n * data to the nodes it produces.\n *\n * Defaults to a function that parses all `HierarchyNode` attributes from a query, whose SELECT\n * clause is created using `NodeSelectQueryFactory.createSelectClause`.\n */\n parseNode?: NodeParser;\n\n /**\n * An optional function for pre-processing nodes.\n *\n * Pre-processing happens immediately after the nodes are loaded based on `HierarchyLevelDefinition`\n * returned by this `HierarchyDefinition` and before their processing (hiding, grouping, sorting, etc.) starts.\n * The step allows assigning nodes additional data or excluding them from the hierarchy based on some attributes.\n */\n preProcessNode?: NodePreProcessor;\n\n /**\n * An optional function for post-processing nodes.\n *\n * Post-processing happens after the loaded nodes go through all the merging, hiding and grouping\n * steps, but before sorting them. This step allows `HierarchyDefinition` implementations to assign additional data\n * to nodes after they're processed. This is especially true for grouping nodes as they're only created during\n * processing.\n */\n postProcessNode?: NodePostProcessor;\n\n /** A function to create a hierarchy level definition for given parent node. */\n defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../internal/DisposePolyfill.js";
|
|
2
2
|
import { HierarchySearchTree } from "../HierarchySearch.js";
|
|
3
|
-
import type { ECClassHierarchyInspector, ECSchemaProvider, Event, IPrimitiveValueFormatter } from "@itwin/presentation-shared";
|
|
3
|
+
import type { ECClassHierarchyInspector, ECSchemaProvider, Event, IInstanceLabelSelectClauseFactory, IPrimitiveValueFormatter } from "@itwin/presentation-shared";
|
|
4
4
|
import type { HierarchyProvider } from "../HierarchyProvider.js";
|
|
5
5
|
import type { HierarchyDefinition } from "./IModelHierarchyDefinition.js";
|
|
6
6
|
import type { LimitingECSqlQueryExecutor } from "./LimitingECSqlQueryExecutor.js";
|
|
@@ -72,6 +72,15 @@ interface IModelHierarchyProviderProps {
|
|
|
72
72
|
/** A list of search trees that define paths from root to search target nodes. */
|
|
73
73
|
paths: HierarchySearchTree[];
|
|
74
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* A factory for creating ECSQL select clauses for instance labels. The clause is injected into
|
|
77
|
+
* hierarchy node queries to select labels for instance-based nodes.
|
|
78
|
+
*
|
|
79
|
+
* Defaults to the result of `createIModelInstanceLabelSelectClauseFactory` called with the provided `imodelAccess`.
|
|
80
|
+
*
|
|
81
|
+
* @see `IInstanceLabelSelectClauseFactory`
|
|
82
|
+
*/
|
|
83
|
+
instanceLabelSelectClauseFactory?: IInstanceLabelSelectClauseFactory;
|
|
75
84
|
}
|
|
76
85
|
/**
|
|
77
86
|
* Creates an instance of `HierarchyProvider` that creates a hierarchy based on given the iModel and
|
|
@@ -84,7 +93,7 @@ export declare function createIModelHierarchyProvider(props: IModelHierarchyProv
|
|
|
84
93
|
* Props for `createMergedIModelHierarchyProvider`.
|
|
85
94
|
* @alpha
|
|
86
95
|
*/
|
|
87
|
-
interface MergedIModelHierarchyProviderProps extends Omit<IModelHierarchyProviderProps, "imodelAccess" | "imodelChanged"> {
|
|
96
|
+
interface MergedIModelHierarchyProviderProps extends Omit<IModelHierarchyProviderProps, "imodelAccess" | "imodelChanged" | "instanceLabelSelectClauseFactory"> {
|
|
88
97
|
/**
|
|
89
98
|
* A list of iModels to create merged hierarchy for.
|
|
90
99
|
*
|
|
@@ -105,6 +114,15 @@ interface MergedIModelHierarchyProviderProps extends Omit<IModelHierarchyProvide
|
|
|
105
114
|
* subscribes to the event to know that it needs to reload the data, and unsubscribes on disposal.
|
|
106
115
|
*/
|
|
107
116
|
imodelChanged?: Event<() => void>;
|
|
117
|
+
/**
|
|
118
|
+
* A factory for creating ECSQL select clauses for instance labels. The clause is injected into
|
|
119
|
+
* hierarchy node queries to select labels for instance-based nodes.
|
|
120
|
+
*
|
|
121
|
+
* Defaults to the result of `createIModelInstanceLabelSelectClauseFactory` called with the provided `imodelAccess`.
|
|
122
|
+
*
|
|
123
|
+
* @see `IInstanceLabelSelectClauseFactory`
|
|
124
|
+
*/
|
|
125
|
+
instanceLabelSelectClauseFactory?: IInstanceLabelSelectClauseFactory;
|
|
108
126
|
}>;
|
|
109
127
|
}
|
|
110
128
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelHierarchyProvider.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyProvider.ts"],"names":[],"mappings":"AAKA,OAAO,gCAAgC,CAAC;AAkCxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"IModelHierarchyProvider.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyProvider.ts"],"names":[],"mappings":"AAKA,OAAO,gCAAgC,CAAC;AAkCxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AA6B5D,OAAO,KAAK,EAEV,yBAAyB,EACzB,gBAAgB,EAEhB,KAAK,EAEL,iCAAiC,EACjC,wBAAwB,EACzB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EAA0B,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEzF,OAAO,KAAK,EAGV,mBAAmB,EAEpB,MAAM,gCAAgC,CAAC;AAOxC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAUlF;;;GAGG;AACH,UAAU,uCAAuC;IAC/C;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED,cAAc;AACd,KAAK,YAAY,GAAG,gBAAgB,GAAG,0BAA0B,GAAG,yBAAyB,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtH;;;GAGG;AACH,UAAU,4BAA4B;IACpC;;;;;;OAMG;IACH,YAAY,EAAE,YAAY,CAAC;IAE3B;;;OAGG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;IAElC;;;OAGG;IACH,mBAAmB,EAAE,mBAAmB,CAAC;IAEzC,qGAAqG;IACrG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,sEAAsE;IACtE,gBAAgB,CAAC,EAAE,OAAO,CAAC,uCAAuC,CAAC,CAAC;IAEpE;;;;OAIG;IACH,SAAS,CAAC,EAAE,wBAAwB,CAAC;IAErC;;;;;OAKG;IACH,MAAM,CAAC,EAAE;QACP,iFAAiF;QACjF,KAAK,EAAE,mBAAmB,EAAE,CAAC;KAC9B,CAAC;IAEF;;;;;;;OAOG;IACH,gCAAgC,CAAC,EAAE,iCAAiC,CAAC;CACtE;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,4BAA4B,GAAG,iBAAiB,GAAG,UAAU,CAMjH;AAED;;;GAGG;AACH,UAAU,kCAAmC,SAAQ,IAAI,CACvD,4BAA4B,EAC5B,cAAc,GAAG,eAAe,GAAG,kCAAkC,CACtE;IACC;;;;;OAKG;IACH,OAAO,EAAE,KAAK,CAAC;QACb;;;;;;WAMG;QACH,YAAY,EAAE,YAAY,CAAC;QAE3B;;;WAGG;QACH,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;QAElC;;;;;;;WAOG;QACH,gCAAgC,CAAC,EAAE,iCAAiC,CAAC;KACtE,CAAC,CAAC;CACJ;AAED;;;;;;;GAOG;AACH,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,kCAAkC,GACxC,iBAAiB,GAAG,UAAU,CAEhC"}
|
|
@@ -32,6 +32,7 @@ const HideIfNoChildren_js_1 = require("./operators/HideIfNoChildren.js");
|
|
|
32
32
|
const HideNodesInHierarchy_js_1 = require("./operators/HideNodesInHierarchy.js");
|
|
33
33
|
const SearchHierarchyDefinition_js_1 = require("./SearchHierarchyDefinition.js");
|
|
34
34
|
const TreeNodesReader_js_1 = require("./TreeNodesReader.js");
|
|
35
|
+
const Utils_js_1 = require("./Utils.js");
|
|
35
36
|
const LOGGING_NAMESPACE = `${Common_js_1.LOGGING_NAMESPACE}.IModelHierarchyProvider`;
|
|
36
37
|
const LOGGING_NAMESPACE_INTERNAL = `${Common_js_1.LOGGING_NAMESPACE_INTERNAL}.IModelHierarchyProvider`;
|
|
37
38
|
const LOGGING_NAMESPACE_PERFORMANCE = `${Common_js_1.LOGGING_NAMESPACE_PERFORMANCE}.IModelHierarchyProvider`;
|
|
@@ -44,8 +45,11 @@ const DEFAULT_QUERY_CACHE_SIZE = 1;
|
|
|
44
45
|
* @public
|
|
45
46
|
*/
|
|
46
47
|
function createIModelHierarchyProvider(props) {
|
|
47
|
-
const { imodelAccess, imodelChanged, ...restProps } = props;
|
|
48
|
-
return createMergedIModelHierarchyProvider({
|
|
48
|
+
const { imodelAccess, imodelChanged, instanceLabelSelectClauseFactory, ...restProps } = props;
|
|
49
|
+
return createMergedIModelHierarchyProvider({
|
|
50
|
+
...restProps,
|
|
51
|
+
imodels: [{ imodelAccess, imodelChanged, instanceLabelSelectClauseFactory }],
|
|
52
|
+
});
|
|
49
53
|
}
|
|
50
54
|
/**
|
|
51
55
|
* Creates an instance of `HierarchyProvider` that creates a hierarchy based on multiple version of **the same** iModel
|
|
@@ -80,10 +84,12 @@ class IModelHierarchyProviderImpl {
|
|
|
80
84
|
this.#componentId = core_bentley_1.Guid.createValue();
|
|
81
85
|
this.#componentName = "IModelHierarchyProviderImpl";
|
|
82
86
|
this.#sourceName = props.sourceName ?? `${this.#componentName}:${this.#componentId}`;
|
|
83
|
-
this._imodels = props.imodels.map(({ imodelAccess, imodelChanged }) => {
|
|
84
|
-
|
|
87
|
+
this._imodels = props.imodels.map(({ imodelAccess, imodelChanged, instanceLabelSelectClauseFactory }) => {
|
|
88
|
+
if (!instanceLabelSelectClauseFactory) {
|
|
89
|
+
instanceLabelSelectClauseFactory = (0, presentation_shared_1.createIModelInstanceLabelSelectClauseFactory)({ imodelAccess });
|
|
90
|
+
}
|
|
85
91
|
const nodeSelectClauseFactory = (0, NodeSelectQueryFactory_js_1.createNodesQueryClauseFactory)({ imodelAccess, instanceLabelSelectClauseFactory });
|
|
86
|
-
return { imodelAccess, imodelChanged,
|
|
92
|
+
return { imodelAccess, imodelChanged, nodeSelectClauseFactory };
|
|
87
93
|
});
|
|
88
94
|
this._hierarchyChanged = new core_bentley_1.BeEvent();
|
|
89
95
|
this._activeHierarchyDefinition = this._sourceHierarchyDefinition = (0, RxjsHierarchyDefinition_js_1.getRxjsHierarchyDefinition)(props.hierarchyDefinition);
|
|
@@ -180,7 +186,7 @@ class IModelHierarchyProviderImpl {
|
|
|
180
186
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
181
187
|
message: () => `[${requestContext.requestId}] Requesting hierarchy level definitions for ${(0, Common_js_1.createNodeIdentifierForLogging)(props.parentNode)}`,
|
|
182
188
|
});
|
|
183
|
-
return (0, rxjs_1.from)(this._imodels).pipe((0, rxjs_1.mergeMap)(({ imodelAccess,
|
|
189
|
+
return (0, rxjs_1.from)(this._imodels).pipe((0, rxjs_1.mergeMap)(({ imodelAccess, nodeSelectClauseFactory }, imodelAccessIndex) => {
|
|
184
190
|
let parentNode = props.parentNode;
|
|
185
191
|
if (parentNode &&
|
|
186
192
|
HierarchyNode_js_1.HierarchyNode.isGeneric(parentNode) &&
|
|
@@ -204,10 +210,12 @@ class IModelHierarchyProviderImpl {
|
|
|
204
210
|
return this._activeHierarchyDefinition
|
|
205
211
|
.defineHierarchyLevel({
|
|
206
212
|
...defineHierarchyLevelProps,
|
|
213
|
+
createSelectClause: async (selectClauseProps) => nodeSelectClauseFactory.createSelectClause(selectClauseProps),
|
|
214
|
+
/* v8 ignore start */
|
|
215
|
+
createFilterClauses: async (filterClausesProps) => nodeSelectClauseFactory.createFilterClauses(filterClausesProps),
|
|
216
|
+
/* v8 ignore stop */
|
|
207
217
|
parentNode,
|
|
208
218
|
imodelAccess,
|
|
209
|
-
instanceLabelSelectClauseFactory,
|
|
210
|
-
nodeSelectClauseFactory,
|
|
211
219
|
})
|
|
212
220
|
.pipe((0, rxjs_1.mergeAll)(), (0, rxjs_1.map)(
|
|
213
221
|
/* Using `as` to work around TS not understanding that `{ x: A, y: B | C }` is the same as `{ x: A } & ({ y: B } | { y: C })` */
|
|
@@ -529,34 +537,32 @@ function createInstanceKeysFilteredQuery(query, targetInstanceKeys) {
|
|
|
529
537
|
if (!targetInstanceKeys || !targetInstanceKeys.length) {
|
|
530
538
|
return query;
|
|
531
539
|
}
|
|
532
|
-
|
|
533
|
-
// TODO: MISSING_COVERAGE
|
|
534
|
-
/* v8 ignore else -- @preserve */
|
|
535
|
-
if (targetInstanceKeys.length < MAX_ALLOWED_BINDINGS) {
|
|
540
|
+
if (Array.isArray(query.bindings)) {
|
|
536
541
|
return {
|
|
537
542
|
...query,
|
|
538
543
|
ecsql: `
|
|
539
544
|
SELECT *
|
|
540
545
|
FROM (${query.ecsql}) q
|
|
541
|
-
|
|
546
|
+
JOIN IdSet(?) targetInstanceKeys ON targetInstanceKeys.id = q.ECInstanceId
|
|
547
|
+
ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES
|
|
542
548
|
`,
|
|
543
|
-
bindings: [
|
|
544
|
-
...(query.bindings ?? []),
|
|
545
|
-
...targetInstanceKeys.map((k) => ({ type: "id", value: k.id })),
|
|
546
|
-
],
|
|
549
|
+
bindings: [...query.bindings, { type: "idset", value: targetInstanceKeys.map((k) => k.id) }],
|
|
547
550
|
};
|
|
548
551
|
}
|
|
549
|
-
|
|
552
|
+
const ecsqlVarTargetInstanceKeys = `${Utils_js_1.ECSQL_PREFIX}targetInstanceKeys`;
|
|
550
553
|
return {
|
|
551
554
|
...query,
|
|
552
555
|
ecsql: `
|
|
553
556
|
SELECT *
|
|
554
557
|
FROM (${query.ecsql}) q
|
|
555
|
-
|
|
558
|
+
JOIN IdSet(:${ecsqlVarTargetInstanceKeys}) targetInstanceKeys ON targetInstanceKeys.id = q.ECInstanceId
|
|
559
|
+
ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES
|
|
556
560
|
`,
|
|
557
|
-
bindings:
|
|
561
|
+
bindings: {
|
|
562
|
+
...query.bindings,
|
|
563
|
+
[ecsqlVarTargetInstanceKeys]: { type: "idset", value: targetInstanceKeys.map((k) => k.id) },
|
|
564
|
+
},
|
|
558
565
|
};
|
|
559
|
-
/* v8 ignore stop */
|
|
560
566
|
}
|
|
561
567
|
// TODO: MISSING_COVERAGE
|
|
562
568
|
/* v8 ignore start */
|