@itwin/tree-widget-react 3.0.0-dev.4 → 3.0.0-dev.5
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/README.md +27 -0
- package/lib/cjs/components/SelectableTree.js +1 -2
- package/lib/cjs/components/SelectableTree.js.map +1 -1
- package/lib/cjs/components/SelectableTree.scss +5 -0
- package/lib/cjs/components/tree-header/TreeHeader.d.ts +3 -2
- package/lib/cjs/components/tree-header/TreeHeader.js +1 -1
- package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js +2 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -2
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.js +5 -4
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js +2 -1
- package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContext.d.ts +1 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContext.js.map +1 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js +4 -4
- package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
- package/lib/cjs/components/trees/common/TreeErrors.d.ts +9 -0
- package/lib/cjs/components/trees/common/TreeErrors.js +19 -0
- package/lib/cjs/components/trees/common/TreeErrors.js.map +1 -0
- package/lib/cjs/components/trees/common/UseActiveViewport.d.ts +7 -0
- package/lib/cjs/components/trees/common/UseActiveViewport.js +25 -0
- package/lib/cjs/components/trees/common/UseActiveViewport.js.map +1 -0
- package/lib/cjs/components/trees/index.d.ts +1 -0
- package/lib/cjs/components/trees/index.js +3 -1
- package/lib/cjs/components/trees/index.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +6 -11
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +2 -2
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +3 -2
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.d.ts +10 -6
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js +63 -43
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/UseModelsTree.d.ts +11 -2
- package/lib/cjs/components/trees/models-tree/UseModelsTree.js +51 -31
- package/lib/cjs/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +4 -3
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/components/SelectableTree.js +2 -3
- package/lib/esm/components/SelectableTree.js.map +1 -1
- package/lib/esm/components/SelectableTree.scss +5 -0
- package/lib/esm/components/tree-header/TreeHeader.d.ts +3 -2
- package/lib/esm/components/tree-header/TreeHeader.js +1 -1
- package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js +2 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -2
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.js +5 -4
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js +2 -1
- package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/esm/components/trees/common/FocusedInstancesContext.d.ts +1 -1
- package/lib/esm/components/trees/common/FocusedInstancesContext.js.map +1 -1
- package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js +4 -4
- package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
- package/lib/esm/components/trees/common/TreeErrors.d.ts +9 -0
- package/lib/esm/components/trees/common/TreeErrors.js +15 -0
- package/lib/esm/components/trees/common/TreeErrors.js.map +1 -0
- package/lib/esm/components/trees/common/UseActiveViewport.d.ts +7 -0
- package/lib/esm/components/trees/common/UseActiveViewport.js +21 -0
- package/lib/esm/components/trees/common/UseActiveViewport.js.map +1 -0
- package/lib/esm/components/trees/index.d.ts +1 -0
- package/lib/esm/components/trees/index.js +1 -0
- package/lib/esm/components/trees/index.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +6 -11
- package/lib/esm/components/trees/models-tree/ModelsTree.js +2 -2
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +3 -2
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.d.ts +10 -6
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js +63 -43
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/components/trees/models-tree/UseModelsTree.d.ts +11 -2
- package/lib/esm/components/trees/models-tree/UseModelsTree.js +51 -31
- package/lib/esm/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +4 -3
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/package.json +28 -28
|
@@ -6,6 +6,7 @@ import { defer, EMPTY, from, map, merge, mergeAll, mergeMap } from "rxjs";
|
|
|
6
6
|
import { createClassBasedHierarchyDefinition, createNodesQueryClauseFactory, HierarchyNode, NodeSelectClauseColumnNames, } from "@itwin/presentation-hierarchies";
|
|
7
7
|
import { createBisInstanceLabelSelectClauseFactory, ECSql } from "@itwin/presentation-shared";
|
|
8
8
|
import { collect } from "../common/Rxjs";
|
|
9
|
+
import { FilterLimitExceededError } from "../common/TreeErrors";
|
|
9
10
|
import { createIdsSelector, parseIdsSelectorResult } from "../common/Utils";
|
|
10
11
|
const MAX_FILTERING_INSTANCE_KEY_COUNT = 100;
|
|
11
12
|
export const defaultHierarchyConfiguration = {
|
|
@@ -426,7 +427,7 @@ export class ModelsTreeDefinition {
|
|
|
426
427
|
const labelsFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });
|
|
427
428
|
return createInstanceKeyPathsFromInstanceLabel({ ...props, labelsFactory });
|
|
428
429
|
}
|
|
429
|
-
return
|
|
430
|
+
return createInstanceKeyPathsFromTargetItems(props);
|
|
430
431
|
}
|
|
431
432
|
async isSupported() {
|
|
432
433
|
const [schemaName, className] = this._hierarchyConfig.elementClassSpecification.split(/[\.:]/);
|
|
@@ -460,30 +461,47 @@ function createModelInstanceKeyPaths(modelId, idsCache) {
|
|
|
460
461
|
function createCategoryInstanceKeyPaths(categoryId, idsCache) {
|
|
461
462
|
return from(idsCache.getCategoryModels(categoryId)).pipe(mergeAll(), mergeMap((categoryModelId) => createModelInstanceKeyPaths(categoryModelId, idsCache).pipe(map((modelPath) => [...modelPath, { className: "BisCore.SpatialCategory", id: categoryId }]))));
|
|
462
463
|
}
|
|
463
|
-
function createGeometricElementInstanceKeyPaths(imodelAccess, idsCache, hierarchyConfig,
|
|
464
|
+
function createGeometricElementInstanceKeyPaths(imodelAccess, idsCache, hierarchyConfig, targetItems) {
|
|
465
|
+
const elementIds = targetItems.filter((info) => typeof info === "string");
|
|
466
|
+
const groupInfos = targetItems.filter((info) => typeof info !== "string");
|
|
464
467
|
return defer(() => {
|
|
465
|
-
const
|
|
466
|
-
const
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
const
|
|
471
|
-
|
|
468
|
+
const bindings = new Array();
|
|
469
|
+
const bind = (selector, idSet) => {
|
|
470
|
+
bindings.push(...idSet.map((id) => ({ type: "id", value: id })));
|
|
471
|
+
return `${selector} IN (${idSet.map(() => "?").join(",")})`;
|
|
472
|
+
};
|
|
473
|
+
const targetElementsInfoQuery = elementIds.length > 0
|
|
474
|
+
? `
|
|
475
|
+
SELECT e.ECInstanceId, e.ECClassId, e.Parent.Id, e.Model.Id, e.Category.Id, -1
|
|
476
|
+
FROM ${hierarchyConfig.elementClassSpecification} e
|
|
477
|
+
WHERE ${bind("e.ECInstanceId", elementIds)}
|
|
478
|
+
`
|
|
479
|
+
: undefined;
|
|
480
|
+
const targetGroupingNodesElementInfoQueries = groupInfos.map(({ parent, groupingNode }, index) => `
|
|
481
|
+
SELECT e.ECInstanceId, e.ECClassId, e.Parent.Id, e.Model.Id, e.Category.Id, ${index}
|
|
482
|
+
FROM ${hierarchyConfig.elementClassSpecification} e
|
|
483
|
+
WHERE
|
|
484
|
+
e.ECClassId IS (${groupingNode.key.className})
|
|
485
|
+
AND ${parent.type === "element" ? bind("e.Parent.Id", parent.ids) : `e.Parent IS NULL AND ${bind("e.Category.Id", parent.ids)} AND ${bind("e.Model.Id", parent.modelIds)}`}
|
|
486
|
+
`);
|
|
472
487
|
const ctes = [
|
|
473
|
-
`
|
|
488
|
+
`InstanceElementsWithClassGroupingNodes(ECInstanceId, ECClassId, ParentId, ModelId, CategoryId, GroupingNodeIndex) AS (
|
|
489
|
+
${[...(targetElementsInfoQuery ? [targetElementsInfoQuery] : []), ...targetGroupingNodesElementInfoQueries].join(" UNION ALL ")}
|
|
490
|
+
)`,
|
|
491
|
+
`ModelsCategoriesElementsHierarchy(ECInstanceId, ParentId, ModelId, GroupingNodeIndex, Path) AS (
|
|
474
492
|
SELECT
|
|
475
493
|
e.ECInstanceId,
|
|
476
|
-
e.
|
|
477
|
-
e.
|
|
494
|
+
e.ParentId,
|
|
495
|
+
e.ModelId,
|
|
496
|
+
e.GroupingNodeIndex,
|
|
478
497
|
json_array(
|
|
479
498
|
${createECInstanceKeySelectClause({ alias: "e" })},
|
|
480
|
-
IIF(e.
|
|
481
|
-
IIF(e.
|
|
499
|
+
IIF(e.ParentId IS NULL, ${createECInstanceKeySelectClause({ alias: "c" })}, NULL),
|
|
500
|
+
IIF(e.ParentId IS NULL, ${createECInstanceKeySelectClause({ alias: "m" })}, NULL)
|
|
482
501
|
)
|
|
483
|
-
FROM
|
|
484
|
-
JOIN bis.GeometricModel3d m ON m.ECInstanceId = e.
|
|
485
|
-
JOIN bis.SpatialCategory c ON c.ECInstanceId = e.
|
|
486
|
-
WHERE ${whereClause}
|
|
502
|
+
FROM InstanceElementsWithClassGroupingNodes e
|
|
503
|
+
JOIN bis.GeometricModel3d m ON m.ECInstanceId = e.ModelId
|
|
504
|
+
JOIN bis.SpatialCategory c ON c.ECInstanceId = e.CategoryId
|
|
487
505
|
|
|
488
506
|
UNION ALL
|
|
489
507
|
|
|
@@ -491,6 +509,7 @@ function createGeometricElementInstanceKeyPaths(imodelAccess, idsCache, hierarch
|
|
|
491
509
|
pe.ECInstanceId,
|
|
492
510
|
pe.Parent.Id,
|
|
493
511
|
pe.Model.Id,
|
|
512
|
+
ce.GroupingNodeIndex,
|
|
494
513
|
json_insert(
|
|
495
514
|
ce.Path,
|
|
496
515
|
'$[#]', ${createECInstanceKeySelectClause({ alias: "pe" })},
|
|
@@ -504,34 +523,35 @@ function createGeometricElementInstanceKeyPaths(imodelAccess, idsCache, hierarch
|
|
|
504
523
|
)`,
|
|
505
524
|
];
|
|
506
525
|
const ecsql = `
|
|
507
|
-
SELECT mce.ModelId, mce.Path
|
|
526
|
+
SELECT mce.ModelId, mce.Path, mce.GroupingNodeIndex
|
|
508
527
|
FROM ModelsCategoriesElementsHierarchy mce
|
|
509
528
|
WHERE mce.ParentId IS NULL
|
|
510
529
|
`;
|
|
511
|
-
|
|
512
|
-
const createCategoryElementsBindings = ({ ids, modelIds }) => [
|
|
513
|
-
...ids.map(createIdBinding),
|
|
514
|
-
...modelIds.map(createIdBinding),
|
|
515
|
-
];
|
|
516
|
-
return imodelAccess.createQueryReader({
|
|
517
|
-
ctes,
|
|
518
|
-
ecsql,
|
|
519
|
-
bindings: [
|
|
520
|
-
...elementIds.map(createIdBinding),
|
|
521
|
-
...groupInfos.flatMap((info) => info.parent.type === "element" ? info.parent.ids.map(createIdBinding) : createCategoryElementsBindings(info.parent)),
|
|
522
|
-
],
|
|
523
|
-
}, { rowFormat: "Indexes" });
|
|
530
|
+
return imodelAccess.createQueryReader({ ctes, ecsql, bindings }, { rowFormat: "Indexes" });
|
|
524
531
|
}).pipe(map((row) => ({
|
|
525
532
|
modelId: row[0],
|
|
526
533
|
elementHierarchyPath: flatten(JSON.parse(row[1])).reverse(),
|
|
527
|
-
|
|
534
|
+
groupingNode: row[2] === -1 ? undefined : groupInfos[row[2]].groupingNode,
|
|
535
|
+
})), mergeMap(({ modelId, elementHierarchyPath, groupingNode }) => createModelInstanceKeyPaths(modelId, idsCache).pipe(map((modelPath) => {
|
|
528
536
|
modelPath.pop(); // model is already included in the element hierarchy path
|
|
529
|
-
|
|
537
|
+
const path = [...modelPath, ...elementHierarchyPath.filter((x) => !!x)];
|
|
538
|
+
if (!groupingNode) {
|
|
539
|
+
return path;
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
542
|
+
path,
|
|
543
|
+
options: {
|
|
544
|
+
autoExpand: {
|
|
545
|
+
key: groupingNode.key,
|
|
546
|
+
depth: groupingNode.parentKeys.length,
|
|
547
|
+
},
|
|
548
|
+
},
|
|
549
|
+
};
|
|
530
550
|
}))));
|
|
531
551
|
}
|
|
532
|
-
async function
|
|
533
|
-
if (
|
|
534
|
-
throw new
|
|
552
|
+
async function createInstanceKeyPathsFromTargetItems({ targetItems, imodelAccess, hierarchyConfig, idsCache, }) {
|
|
553
|
+
if (targetItems.length > MAX_FILTERING_INSTANCE_KEY_COUNT) {
|
|
554
|
+
throw new FilterLimitExceededError(MAX_FILTERING_INSTANCE_KEY_COUNT);
|
|
535
555
|
}
|
|
536
556
|
const ids = {
|
|
537
557
|
models: new Array(),
|
|
@@ -539,24 +559,24 @@ async function createInstanceKeyPathsFromInstanceKeys(props) {
|
|
|
539
559
|
subjects: new Array(),
|
|
540
560
|
elements: new Array(),
|
|
541
561
|
};
|
|
542
|
-
await Promise.all(
|
|
562
|
+
await Promise.all(targetItems.map(async (key) => {
|
|
543
563
|
if ("parent" in key) {
|
|
544
564
|
ids.elements.push(key);
|
|
545
565
|
}
|
|
546
|
-
else if (await
|
|
566
|
+
else if (await imodelAccess.classDerivesFrom(key.className, "BisCore.Subject")) {
|
|
547
567
|
ids.subjects.push(key.id);
|
|
548
568
|
}
|
|
549
|
-
else if (await
|
|
569
|
+
else if (await imodelAccess.classDerivesFrom(key.className, "BisCore.Model")) {
|
|
550
570
|
ids.models.push(key.id);
|
|
551
571
|
}
|
|
552
|
-
else if (await
|
|
572
|
+
else if (await imodelAccess.classDerivesFrom(key.className, "BisCore.SpatialCategory")) {
|
|
553
573
|
ids.categories.push(key.id);
|
|
554
574
|
}
|
|
555
575
|
else {
|
|
556
576
|
ids.elements.push(key.id);
|
|
557
577
|
}
|
|
558
578
|
}));
|
|
559
|
-
return collect(merge(from(ids.subjects).pipe(mergeMap((id) => createSubjectInstanceKeysPath(id,
|
|
579
|
+
return collect(merge(from(ids.subjects).pipe(mergeMap((id) => createSubjectInstanceKeysPath(id, idsCache))), from(ids.models).pipe(mergeMap((id) => createModelInstanceKeyPaths(id, idsCache))), from(ids.categories).pipe(mergeMap((id) => createCategoryInstanceKeyPaths(id, idsCache))), ids.elements.length ? createGeometricElementInstanceKeyPaths(imodelAccess, idsCache, hierarchyConfig, ids.elements) : EMPTY));
|
|
560
580
|
}
|
|
561
581
|
async function createInstanceKeyPathsFromInstanceLabel(props) {
|
|
562
582
|
const elementLabelSelectClause = await props.labelsFactory.createSelectClause({
|
|
@@ -598,7 +618,7 @@ async function createInstanceKeyPathsFromInstanceLabel(props) {
|
|
|
598
618
|
for await (const row of targetsReader) {
|
|
599
619
|
targetKeys.push({ className: row[0], id: row[1] });
|
|
600
620
|
}
|
|
601
|
-
return
|
|
621
|
+
return createInstanceKeyPathsFromTargetItems({ ...props, targetItems: targetKeys });
|
|
602
622
|
}
|
|
603
623
|
function createECInstanceKeySelectClause(props) {
|
|
604
624
|
const classIdSelector = `[${props.alias}].[ECClassId]`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeDefinition.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC1E,OAAO,EACL,mCAAmC,EAAE,6BAA6B,EAAE,aAAa,EAAE,2BAA2B,GAC/G,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,yCAAyC,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AA0B5E,MAAM,gCAAgC,GAAG,GAAG,CAAC;AAe7C,MAAM,CAAC,MAAM,6BAA6B,GAAqC;IAC7E,oBAAoB,EAAE,QAAQ;IAC9B,yBAAyB,EAAE,4BAA4B;IACvD,eAAe,EAAE,KAAK;CACvB,CAAC;AAsCF,2DAA2D;AAC3D,MAAM,KAAW,+BAA+B,CAI/C;AAJD,WAAiB,+BAA+B;IAC9C,SAAgB,YAAY,CAAC,KAAsC;QACjE,OAAO,CAAC,CAAE,KAA0D,CAAC,KAAK,CAAC;IAC7E,CAAC;IAFe,4CAAY,eAE3B,C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EF,MAAM,UAAU,GAAG,IAAI,KAAK,EAAe,CAAC;IAC5C,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,aAAa,EAAE;QACrC,UAAU,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KACpD;IAED,OAAO,sCAAsC,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,+BAA+B,CAAC,KAAwB;IAC/D,MAAM,eAAe,GAAG,IAAI,KAAK,CAAC,KAAK,eAAe,CAAC;IACvD,MAAM,qBAAqB,GAAG,YAAY,KAAK,CAAC,KAAK,mBAAmB,CAAC;IACzE,OAAO,yCAAyC,eAAe,mBAAmB,qBAAqB,GAAG,CAAC;AAC7G,CAAC;AAGD,SAAS,OAAO,CAAI,MAA8B;IAChD,OAAO,MAAM,CAAC,MAAM,CAAM,CAAC,IAAI,EAAE,IAAI,EAAO,EAAE;QAC5C,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC,EAAE,IAAI,KAAK,EAAK,CAAC,CAAC;AACrB,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\nimport { defer, EMPTY, from, map, merge, mergeAll, mergeMap } from \"rxjs\";\nimport {\n createClassBasedHierarchyDefinition, createNodesQueryClauseFactory, HierarchyNode, NodeSelectClauseColumnNames,\n} from \"@itwin/presentation-hierarchies\";\nimport { createBisInstanceLabelSelectClauseFactory, ECSql } from \"@itwin/presentation-shared\";\nimport { collect } from \"../common/Rxjs\";\nimport { createIdsSelector, parseIdsSelectorResult } from \"../common/Utils\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { Observable } from \"rxjs\";\nimport type {\n DefineHierarchyLevelProps,\n DefineInstanceNodeChildHierarchyLevelProps,\n DefineRootHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n HierarchyNodeIdentifiersPath,\n HierarchyNodesDefinition,\n LimitingECSqlQueryExecutor,\n NodesQueryClauseFactory,\n ProcessedHierarchyNode,\n} from \"@itwin/presentation-hierarchies\";\nimport type {\n ECClassHierarchyInspector,\n ECSchemaProvider,\n ECSqlBinding,\n ECSqlQueryDef,\n IInstanceLabelSelectClauseFactory,\n InstanceKey,\n} from \"@itwin/presentation-shared\";\nimport type { ModelsTreeIdsCache } from \"./internal/ModelsTreeIdsCache\";\n\nconst MAX_FILTERING_INSTANCE_KEY_COUNT = 100;\n\n/**\n * Defines hierarchy configuration supported by `ModelsTree`.\n * @beta\n */\nexport interface ModelsTreeHierarchyConfiguration {\n /** Should element nodes be grouped by class. Defaults to `enable`. */\n elementClassGrouping: \"enable\" | \"enableWithCounts\" | \"disable\";\n /** Full class name of a `GeometricElement3d` sub-class that should be used to load element nodes. Defaults to `BisCore.GeometricElement3d` */\n elementClassSpecification: string;\n /** Should models without elements be shown. Defaults to `false` */\n showEmptyModels: boolean;\n}\n\nexport const defaultHierarchyConfiguration: ModelsTreeHierarchyConfiguration = {\n elementClassGrouping: \"enable\",\n elementClassSpecification: \"BisCore.GeometricElement3d\",\n showEmptyModels: false,\n};\n\ninterface ModelsTreeDefinitionProps {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n idsCache: ModelsTreeIdsCache;\n hierarchyConfig: ModelsTreeHierarchyConfiguration;\n}\n\nexport interface ElementsGroupInfo {\n parent:\n | {\n ids: Id64String[];\n type: \"element\";\n }\n | {\n ids: Id64String[];\n modelIds: Id64String[];\n type: \"category\";\n };\n classes: string[];\n}\n\ninterface ModelsTreeInstanceKeyPathsFromInstanceKeysProps {\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n idsCache: ModelsTreeIdsCache;\n keys: Array<InstanceKey | ElementsGroupInfo>;\n hierarchyConfig: ModelsTreeHierarchyConfiguration;\n}\n\ninterface ModelsTreeInstanceKeyPathsFromInstanceLabelProps {\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n idsCache: ModelsTreeIdsCache;\n label: string;\n hierarchyConfig: ModelsTreeHierarchyConfiguration;\n}\n\nexport type ModelsTreeInstanceKeyPathsProps = ModelsTreeInstanceKeyPathsFromInstanceKeysProps | ModelsTreeInstanceKeyPathsFromInstanceLabelProps;\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace ModelsTreeInstanceKeyPathsProps {\n export function isLabelProps(props: ModelsTreeInstanceKeyPathsProps): props is ModelsTreeInstanceKeyPathsFromInstanceLabelProps {\n return !!(props as ModelsTreeInstanceKeyPathsFromInstanceLabelProps).label;\n }\n}\n\nexport class ModelsTreeDefinition implements HierarchyDefinition {\n private _impl: HierarchyDefinition;\n private _idsCache: ModelsTreeIdsCache;\n private _hierarchyConfig: ModelsTreeHierarchyConfiguration;\n private _selectQueryFactory: NodesQueryClauseFactory;\n private _nodeLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n private _queryExecutor: LimitingECSqlQueryExecutor;\n private _isSupported?: Promise<boolean>;\n\n public constructor(props: ModelsTreeDefinitionProps) {\n this._impl = createClassBasedHierarchyDefinition({\n classHierarchyInspector: props.imodelAccess,\n hierarchy: {\n rootNodes: async (requestProps) => this.createRootHierarchyLevelDefinition(requestProps),\n childNodes: [\n {\n parentNodeClassName: \"BisCore.Subject\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createSubjectChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.ISubModeledElement\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createISubModeledElementChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.GeometricModel3d\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createGeometricModel3dChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.SpatialCategory\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createSpatialCategoryChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.GeometricElement3d\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createGeometricElement3dChildrenQuery(requestProps),\n },\n ],\n },\n });\n this._idsCache = props.idsCache;\n this._queryExecutor = props.imodelAccess;\n this._hierarchyConfig = props.hierarchyConfig;\n this._selectQueryFactory = createNodesQueryClauseFactory({ imodelAccess: props.imodelAccess });\n this._nodeLabelSelectClauseFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n }\n\n public async postProcessNode(node: ProcessedHierarchyNode): Promise<ProcessedHierarchyNode> {\n if (HierarchyNode.isClassGroupingNode(node)) {\n return {\n ...node,\n label: this._hierarchyConfig.elementClassGrouping === \"enableWithCounts\" ? `${node.label} (${node.children.length})` : node.label,\n extendedData: {\n ...node.extendedData,\n // add `modelId` and `categoryId` from the first grouped element\n ...node.children[0].extendedData,\n // `imageId` is assigned to instance nodes at query time, but grouping ones need to\n // be handled during post-processing\n imageId: \"icon-ec-class\",\n },\n };\n }\n return node;\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps) {\n if (this._isSupported === undefined) {\n this._isSupported = this.isSupported();\n }\n\n if ((await this._isSupported) === false) {\n return [];\n }\n\n return this._impl.defineHierarchyLevel(props);\n }\n\n private async createRootHierarchyLevelDefinition(props: DefineRootHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: props.instanceFilter,\n contentClass: { fullName: \"BisCore.Subject\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.Subject\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: ECSql.createRawPropertyValueSelector(\"this\", \"ECClassId\") },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.Subject\",\n }),\n },\n extendedData: {\n imageId: \"icon-imodel-hollow-2\",\n isSubject: true,\n },\n autoExpand: true,\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.Parent IS NULL\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n },\n ];\n }\n\n private async createSubjectChildrenQuery({\n parentNodeInstanceIds: subjectIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const [subjectFilterClauses, modelFilterClauses] = await Promise.all([\n this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.Subject\", alias: \"this\" },\n }),\n this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.GeometricModel3d\", alias: \"this\" },\n }),\n ]);\n const [childSubjectIds, childModelIds] = await Promise.all([\n this._idsCache.getChildSubjectIds(subjectIds),\n this._idsCache.getChildSubjectModelIds(subjectIds),\n ]);\n const defs = new Array<HierarchyNodesDefinition>();\n childSubjectIds.length &&\n defs.push({\n fullClassName: \"BisCore.Subject\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.Subject\",\n }),\n },\n hideIfNoChildren: true,\n hasChildren: { selector: `InVirtualSet(?, this.ECInstanceId)` },\n grouping: { byLabel: { action: \"merge\", groupId: \"subject\" } },\n extendedData: {\n imageId: \"icon-folder\",\n isSubject: true,\n },\n supportsFiltering: true,\n })}\n FROM ${subjectFilterClauses.from} this\n ${subjectFilterClauses.joins}\n WHERE\n this.ECInstanceId IN (${childSubjectIds.map(() => \"?\").join(\",\")})\n ${subjectFilterClauses.where ? `AND ${subjectFilterClauses.where}` : \"\"}\n `,\n bindings: [\n { type: \"idset\", value: await this._idsCache.getParentSubjectIds() },\n ...childSubjectIds.map((id): ECSqlBinding => ({ type: \"id\", value: id })),\n ],\n },\n });\n childModelIds.length &&\n defs.push({\n fullClassName: \"BisCore.GeometricModel3d\",\n query: {\n ecsql: `\n SELECT model.ECInstanceId AS ECInstanceId, model.*\n FROM (\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"m.ECClassId\" },\n ecInstanceId: { selector: \"m.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"partition\",\n className: \"BisCore.InformationPartitionElement\",\n }),\n },\n hideNodeInHierarchy: {\n selector: `\n CASE\n WHEN (\n json_extract([partition].JsonProperties, '$.PhysicalPartition.Model.Content') IS NOT NULL\n OR json_extract([partition].JsonProperties, '$.GraphicalPartition3d.Model.Content') IS NOT NULL\n ) THEN 1\n ELSE 0\n END\n `,\n },\n hasChildren: this._hierarchyConfig.showEmptyModels\n ? {\n selector: `\n IFNULL((\n SELECT 1\n FROM ${this._hierarchyConfig.elementClassSpecification} e\n WHERE e.Model.Id = m.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n }\n : true,\n extendedData: {\n imageId: \"icon-model\",\n isModel: true,\n },\n supportsFiltering: true,\n })}\n FROM Bis.GeometricModel3d m\n JOIN bis.InformationPartitionElement [partition] ON [partition].ECInstanceId = m.ModeledElement.Id\n WHERE\n m.ECInstanceId IN (${childModelIds.map(() => \"?\").join(\",\")})\n ) model\n JOIN ${modelFilterClauses.from} this ON this.ECInstanceId = model.ECInstanceId\n ${modelFilterClauses.joins}\n ${modelFilterClauses.where ? `AND (model.${NodeSelectClauseColumnNames.HideNodeInHierarchy} OR ${modelFilterClauses.where})` : \"\"}\n `,\n bindings: childModelIds.map((id): ECSqlBinding => ({ type: \"id\", value: id })),\n },\n });\n return defs;\n }\n\n private async createISubModeledElementChildrenQuery({\n parentNodeInstanceIds: elementIds,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n // note: we do not apply hierarchy level filtering on this hierarchy level, because it's always\n // hidden - the filter will get applied on the child hierarchy levels\n return [\n {\n fullClassName: \"BisCore.GeometricModel3d\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: \"\", // doesn't matter - the node is always hidden\n hideNodeInHierarchy: true,\n })}\n FROM BisCore.GeometricModel3d this\n WHERE\n this.ModeledElement.Id IN (${elementIds.map(() => \"?\").join(\",\")})\n AND NOT this.IsPrivate\n AND this.ECInstanceId IN (SELECT Model.Id FROM ${this._hierarchyConfig.elementClassSpecification})\n `,\n bindings: [...elementIds.map((id): ECSqlBinding => ({ type: \"id\", value: id }))],\n },\n },\n ];\n }\n\n private async createGeometricModel3dChildrenQuery({\n parentNodeInstanceIds: modelIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.SpatialCategory\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.SpatialCategory\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.SpatialCategory\",\n }),\n },\n grouping: { byLabel: { action: \"merge\", groupId: \"category\" } },\n hasChildren: true,\n extendedData: {\n imageId: \"icon-layers\",\n isCategory: true,\n modelIds: { selector: createIdsSelector(modelIds) },\n },\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n EXISTS (\n SELECT 1\n FROM ${this._hierarchyConfig.elementClassSpecification} element\n WHERE\n element.Model.Id IN (${modelIds.map(() => \"?\").join(\",\")})\n AND element.Category.Id = +this.ECInstanceId\n AND element.Parent IS NULL\n )\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: modelIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n private async createSpatialCategoryChildrenQuery({\n parentNodeInstanceIds: categoryIds,\n parentNode,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const modelIds = parseIdsSelectorResult(parentNode.extendedData?.modelIds);\n if (modelIds.length === 0) {\n throw new Error(`Invalid category node \"${parentNode.label}\" - missing model information.`);\n }\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: this._hierarchyConfig.elementClassSpecification, alias: \"this\" },\n });\n return [\n {\n fullClassName: this._hierarchyConfig.elementClassSpecification,\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: this._hierarchyConfig.elementClassSpecification,\n }),\n },\n grouping: {\n byClass: this._hierarchyConfig.elementClassGrouping !== \"disable\",\n },\n hasChildren: {\n selector: `\n IFNULL((\n SELECT 1\n FROM (\n SELECT Parent.Id ParentId FROM ${this._hierarchyConfig.elementClassSpecification}\n UNION ALL\n SELECT ModeledElement.Id ParentId FROM bis.GeometricModel3d\n )\n WHERE ParentId = this.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n },\n extendedData: {\n modelId: { selector: \"IdToHex(this.Model.Id)\" },\n categoryId: { selector: \"IdToHex(this.Category.Id)\" },\n imageId: \"icon-item\",\n },\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.Category.Id IN (${categoryIds.map(() => \"?\").join(\",\")})\n AND this.Model.Id IN (${modelIds.map(() => \"?\").join(\",\")})\n AND this.Parent IS NULL\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: [...categoryIds.map((id) => ({ type: \"id\", value: id })), ...modelIds.map((id) => ({ type: \"id\", value: id }))] as ECSqlBinding[],\n },\n },\n ];\n }\n\n private async createGeometricElement3dChildrenQuery({\n parentNodeInstanceIds: elementIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: this._hierarchyConfig.elementClassSpecification, alias: \"this\" },\n });\n return [\n {\n fullClassName: this._hierarchyConfig.elementClassSpecification,\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: this._hierarchyConfig.elementClassSpecification,\n }),\n },\n grouping: {\n byClass: this._hierarchyConfig.elementClassGrouping !== \"disable\",\n },\n hasChildren: {\n selector: `\n IFNULL((\n SELECT 1\n FROM (\n SELECT Parent.Id ParentId FROM ${this._hierarchyConfig.elementClassSpecification}\n UNION ALL\n SELECT ModeledElement.Id ParentId FROM bis.GeometricModel3d\n )\n WHERE ParentId = this.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n },\n extendedData: {\n modelId: { selector: \"IdToHex(this.Model.Id)\" },\n categoryId: { selector: \"IdToHex(this.Category.Id)\" },\n imageId: \"icon-item\",\n },\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.Parent.Id IN (${elementIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: elementIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n public static async createInstanceKeyPaths(props: ModelsTreeInstanceKeyPathsProps) {\n if (ModelsTreeInstanceKeyPathsProps.isLabelProps(props)) {\n const labelsFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n return createInstanceKeyPathsFromInstanceLabel({ ...props, labelsFactory });\n }\n return createInstanceKeyPathsFromInstanceKeys(props);\n }\n\n private async isSupported() {\n const [schemaName, className] = this._hierarchyConfig.elementClassSpecification.split(/[\\.:]/);\n if (!schemaName || !className) {\n throw new Error(\n `Provided class specification ${this._hierarchyConfig.elementClassSpecification} should be in format {SchemaName}:{ClassName} or {SchemaName}.{ClassName}`,\n );\n }\n\n const query: ECSqlQueryDef = {\n ecsql: `\n SELECT 1\n FROM ECDbMeta.ECSchemaDef s\n JOIN ECDbMeta.ECClassDef c ON c.Schema.Id = s.ECInstanceId\n WHERE s.Name = ? AND c.Name = ? AND c.ECInstanceId IS (BisCore.GeometricElement3d)\n `,\n bindings: [\n { type: \"string\", value: schemaName },\n { type: \"string\", value: className },\n ],\n };\n\n for await (const _row of this._queryExecutor.createQueryReader(query)) {\n return true;\n }\n return false;\n }\n}\n\nfunction createSubjectInstanceKeysPath(subjectId: Id64String, idsCache: ModelsTreeIdsCache): Observable<HierarchyNodeIdentifiersPath> {\n return from(idsCache.getSubjectAncestorsPath(subjectId)).pipe(map((idsPath) => idsPath.map((id) => ({ className: \"BisCore.Subject\", id }))));\n}\n\nfunction createModelInstanceKeyPaths(modelId: Id64String, idsCache: ModelsTreeIdsCache): Observable<HierarchyNodeIdentifiersPath> {\n return from(idsCache.getModelSubjects(modelId)).pipe(\n mergeAll(),\n mergeMap((modelSubjectId) =>\n createSubjectInstanceKeysPath(modelSubjectId, idsCache).pipe(\n map((subjectPath) => [...subjectPath, { className: \"BisCore.GeometricModel3d\", id: modelId }]),\n ),\n ),\n );\n}\n\nfunction createCategoryInstanceKeyPaths(categoryId: Id64String, idsCache: ModelsTreeIdsCache): Observable<HierarchyNodeIdentifiersPath> {\n return from(idsCache.getCategoryModels(categoryId)).pipe(\n mergeAll(),\n mergeMap((categoryModelId) =>\n createModelInstanceKeyPaths(categoryModelId, idsCache).pipe(map((modelPath) => [...modelPath, { className: \"BisCore.SpatialCategory\", id: categoryId }])),\n ),\n );\n}\n\nfunction createGeometricElementInstanceKeyPaths(\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor,\n idsCache: ModelsTreeIdsCache,\n hierarchyConfig: ModelsTreeHierarchyConfiguration,\n elementInfos: Array<Id64String | ElementsGroupInfo>,\n): Observable<HierarchyNodeIdentifiersPath> {\n return defer(() => {\n const elementIds = elementInfos.filter((info): info is Id64String => typeof info === \"string\");\n const groupInfos = elementInfos.filter((info): info is ElementsGroupInfo => typeof info !== \"string\");\n\n const elementsClause = elementIds.length > 0 ? `e.ECInstanceId IN (${elementIds.map(() => \"?\").join(\",\")})` : undefined;\n\n const createParentElementClause = (parent: { ids: Id64String[] }) => `e.Parent.Id IN (${parent.ids.map(() => \"?\").join(\",\")})`;\n const createParentCategoryClause = ({ ids, modelIds }: { ids: Id64String[]; modelIds: Id64String[] }) =>\n `e.Category.Id IN (${ids.map(() => \"?\").join(\",\")}) AND e.Model.Id IN (${modelIds.map(() => \"?\").join(\",\")})`;\n\n const classClause = groupInfos.map(\n ({ parent, classes }) =>\n `(${parent.type === \"element\" ? createParentElementClause(parent) : createParentCategoryClause(parent)} AND e.ECClassId IS (${classes.join(\",\")}))`,\n );\n\n const whereClause = [...(elementsClause ? [elementsClause] : []), ...(classClause ?? [])].join(\" OR \");\n\n const ctes = [\n `ModelsCategoriesElementsHierarchy(ECInstanceId, ParentId, ModelId, Path) AS (\n SELECT\n e.ECInstanceId,\n e.Parent.Id,\n e.Model.Id,\n json_array(\n ${createECInstanceKeySelectClause({ alias: \"e\" })},\n IIF(e.Parent.Id IS NULL, ${createECInstanceKeySelectClause({ alias: \"c\" })}, NULL),\n IIF(e.Parent.Id IS NULL, ${createECInstanceKeySelectClause({ alias: \"m\" })}, NULL)\n )\n FROM ${hierarchyConfig.elementClassSpecification} e\n JOIN bis.GeometricModel3d m ON m.ECInstanceId = e.Model.Id\n JOIN bis.SpatialCategory c ON c.ECInstanceId = e.Category.Id\n WHERE ${whereClause}\n\n UNION ALL\n\n SELECT\n pe.ECInstanceId,\n pe.Parent.Id,\n pe.Model.Id,\n json_insert(\n ce.Path,\n '$[#]', ${createECInstanceKeySelectClause({ alias: \"pe\" })},\n '$[#]', IIF(pe.Parent.Id IS NULL, ${createECInstanceKeySelectClause({ alias: \"c\" })}, NULL),\n '$[#]', IIF(pe.Parent.Id IS NULL, ${createECInstanceKeySelectClause({ alias: \"m\" })}, NULL)\n )\n FROM ModelsCategoriesElementsHierarchy ce\n JOIN ${hierarchyConfig.elementClassSpecification} pe ON (pe.ECInstanceId = ce.ParentId OR pe.ECInstanceId = ce.ModelId AND ce.ParentId IS NULL)\n JOIN bis.GeometricModel3d m ON m.ECInstanceId = pe.Model.Id\n JOIN bis.SpatialCategory c ON c.ECInstanceId = pe.Category.Id\n )`,\n ];\n const ecsql = `\n SELECT mce.ModelId, mce.Path\n FROM ModelsCategoriesElementsHierarchy mce\n WHERE mce.ParentId IS NULL\n `;\n const createIdBinding = (id: Id64String) => ({ type: \"id\" as const, value: id });\n const createCategoryElementsBindings = ({ ids, modelIds }: { ids: Id64String[]; modelIds: Id64String[] }) => [\n ...ids.map(createIdBinding),\n ...modelIds.map(createIdBinding),\n ];\n return imodelAccess.createQueryReader(\n {\n ctes,\n ecsql,\n bindings: [\n ...elementIds.map(createIdBinding),\n ...groupInfos.flatMap((info) =>\n info.parent.type === \"element\" ? info.parent.ids.map(createIdBinding) : createCategoryElementsBindings(info.parent),\n ),\n ],\n },\n { rowFormat: \"Indexes\" },\n );\n }).pipe(\n map((row) => ({\n modelId: row[0],\n elementHierarchyPath: flatten<InstanceKey | undefined>(JSON.parse(row[1])).reverse(),\n })),\n mergeMap(({ modelId, elementHierarchyPath }) =>\n createModelInstanceKeyPaths(modelId, idsCache).pipe(\n map((modelPath) => {\n modelPath.pop(); // model is already included in the element hierarchy path\n return [...modelPath, ...elementHierarchyPath.filter((x): x is InstanceKey => !!x)];\n }),\n ),\n ),\n );\n}\n\nasync function createInstanceKeyPathsFromInstanceKeys(props: ModelsTreeInstanceKeyPathsFromInstanceKeysProps): Promise<HierarchyNodeIdentifiersPath[]> {\n if (props.keys.length > MAX_FILTERING_INSTANCE_KEY_COUNT) {\n throw new Error(`Filter matches more than ${MAX_FILTERING_INSTANCE_KEY_COUNT} items`);\n }\n const ids = {\n models: new Array<Id64String>(),\n categories: new Array<Id64String>(),\n subjects: new Array<Id64String>(),\n elements: new Array<Id64String | ElementsGroupInfo>(),\n };\n await Promise.all(\n props.keys.map(async (key) => {\n if (\"parent\" in key) {\n ids.elements.push(key);\n } else if (await props.imodelAccess.classDerivesFrom(key.className, \"BisCore.Subject\")) {\n ids.subjects.push(key.id);\n } else if (await props.imodelAccess.classDerivesFrom(key.className, \"BisCore.Model\")) {\n ids.models.push(key.id);\n } else if (await props.imodelAccess.classDerivesFrom(key.className, \"BisCore.SpatialCategory\")) {\n ids.categories.push(key.id);\n } else {\n ids.elements.push(key.id);\n }\n }),\n );\n return collect(\n merge(\n from(ids.subjects).pipe(mergeMap((id) => createSubjectInstanceKeysPath(id, props.idsCache))),\n from(ids.models).pipe(mergeMap((id) => createModelInstanceKeyPaths(id, props.idsCache))),\n from(ids.categories).pipe(mergeMap((id) => createCategoryInstanceKeyPaths(id, props.idsCache))),\n ids.elements.length ? createGeometricElementInstanceKeyPaths(props.imodelAccess, props.idsCache, props.hierarchyConfig, ids.elements) : EMPTY,\n ),\n );\n}\n\nasync function createInstanceKeyPathsFromInstanceLabel(\n props: ModelsTreeInstanceKeyPathsFromInstanceLabelProps & { labelsFactory: IInstanceLabelSelectClauseFactory },\n) {\n const elementLabelSelectClause = await props.labelsFactory.createSelectClause({\n classAlias: \"e\",\n className: \"BisCore.Element\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n selectorsConcatenator: ECSql.createConcatenatedValueStringSelector,\n });\n const targetsReader = props.imodelAccess.createQueryReader(\n {\n ecsql: `\n SELECT *\n FROM (\n SELECT\n ec_classname(e.ECClassId, 's.c'),\n e.ECInstanceId,\n ${elementLabelSelectClause} Label\n FROM BisCore.Element e\n WHERE e.ECClassId IS (BisCore.Subject, BisCore.SpatialCategory, ${props.hierarchyConfig.elementClassSpecification})\n\n UNION ALL\n\n SELECT\n ec_classname(m.ECClassId, 's.c'),\n m.ECInstanceId,\n ${elementLabelSelectClause} Label\n FROM BisCore.GeometricModel3d m\n JOIN BisCore.Element e ON e.ECInstanceId = m.ModeledElement.Id\n WHERE NOT m.IsPrivate\n ${props.hierarchyConfig.showEmptyModels ? \"\" : `AND EXISTS (SELECT 1 FROM ${props.hierarchyConfig.elementClassSpecification} WHERE Model.Id = m.ECInstanceId)`}\n AND json_extract(e.JsonProperties, '$.PhysicalPartition.Model.Content') IS NULL\n AND json_extract(e.JsonProperties, '$.GraphicalPartition3d.Model.Content') IS NULL\n )\n WHERE Label LIKE '%' || ? || '%' ESCAPE '\\\\'\n LIMIT ${MAX_FILTERING_INSTANCE_KEY_COUNT + 1}\n `,\n bindings: [{ type: \"string\", value: props.label.replace(/[%_\\\\]/g, \"\\\\$&\") }],\n },\n { rowFormat: \"Indexes\", restartToken: \"tree-widget/models-tree/filter-by-label-query\" },\n );\n\n const targetKeys = new Array<InstanceKey>();\n for await (const row of targetsReader) {\n targetKeys.push({ className: row[0], id: row[1] });\n }\n\n return createInstanceKeyPathsFromInstanceKeys({ ...props, keys: targetKeys });\n}\n\nfunction createECInstanceKeySelectClause(props: { alias: string }) {\n const classIdSelector = `[${props.alias}].[ECClassId]`;\n const instanceHexIdSelector = `IdToHex([${props.alias}].[ECInstanceId])`;\n return `json_object('className', ec_classname(${classIdSelector}, 's.c'), 'id', ${instanceHexIdSelector})`;\n}\n\ntype ArrayOrValue<T> = T | Array<ArrayOrValue<T>>;\nfunction flatten<T>(source: Array<ArrayOrValue<T>>): T[] {\n return source.reduce<T[]>((flat, item): T[] => {\n return [...flat, ...(Array.isArray(item) ? flatten(item) : [item])];\n }, new Array<T>());\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ModelsTreeDefinition.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC1E,OAAO,EACL,mCAAmC,EAAE,6BAA6B,EAAE,aAAa,EAAE,2BAA2B,GAC/G,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,yCAAyC,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AA+B5E,MAAM,gCAAgC,GAAG,GAAG,CAAC;AAe7C,MAAM,CAAC,MAAM,6BAA6B,GAAqC;IAC7E,oBAAoB,EAAE,QAAQ;IAC9B,yBAAyB,EAAE,4B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IAAI,KAAK,EAAe,CAAC;IAC5C,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,aAAa,EAAE;QACrC,UAAU,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KACpD;IAED,OAAO,qCAAqC,CAAC,EAAE,GAAG,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC;AACtF,CAAC;AAED,SAAS,+BAA+B,CAAC,KAAwB;IAC/D,MAAM,eAAe,GAAG,IAAI,KAAK,CAAC,KAAK,eAAe,CAAC;IACvD,MAAM,qBAAqB,GAAG,YAAY,KAAK,CAAC,KAAK,mBAAmB,CAAC;IACzE,OAAO,yCAAyC,eAAe,mBAAmB,qBAAqB,GAAG,CAAC;AAC7G,CAAC;AAGD,SAAS,OAAO,CAAI,MAA8B;IAChD,OAAO,MAAM,CAAC,MAAM,CAAM,CAAC,IAAI,EAAE,IAAI,EAAO,EAAE;QAC5C,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC,EAAE,IAAI,KAAK,EAAK,CAAC,CAAC;AACrB,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\nimport { defer, EMPTY, from, map, merge, mergeAll, mergeMap } from \"rxjs\";\nimport {\n createClassBasedHierarchyDefinition, createNodesQueryClauseFactory, HierarchyNode, NodeSelectClauseColumnNames,\n} from \"@itwin/presentation-hierarchies\";\nimport { createBisInstanceLabelSelectClauseFactory, ECSql } from \"@itwin/presentation-shared\";\nimport { collect } from \"../common/Rxjs\";\nimport { FilterLimitExceededError } from \"../common/TreeErrors\";\nimport { createIdsSelector, parseIdsSelectorResult } from \"../common/Utils\";\n\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { Observable } from \"rxjs\";\nimport type {\n ClassGroupingNodeKey,\n createHierarchyProvider,\n DefineHierarchyLevelProps,\n DefineInstanceNodeChildHierarchyLevelProps,\n DefineRootHierarchyLevelProps,\n GroupingHierarchyNode,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n HierarchyNodeIdentifiersPath,\n HierarchyNodesDefinition,\n LimitingECSqlQueryExecutor,\n NodesQueryClauseFactory,\n ProcessedHierarchyNode,\n} from \"@itwin/presentation-hierarchies\";\nimport type {\n ECClassHierarchyInspector,\n ECSchemaProvider,\n ECSqlBinding,\n ECSqlQueryDef,\n IInstanceLabelSelectClauseFactory,\n InstanceKey,\n} from \"@itwin/presentation-shared\";\nimport type { ModelsTreeIdsCache } from \"./internal/ModelsTreeIdsCache\";\n\nexport type ClassGroupingHierarchyNode = GroupingHierarchyNode & { key: ClassGroupingNodeKey };\n\nconst MAX_FILTERING_INSTANCE_KEY_COUNT = 100;\n\n/**\n * Defines hierarchy configuration supported by `ModelsTree`.\n * @beta\n */\nexport interface ModelsTreeHierarchyConfiguration {\n /** Should element nodes be grouped by class. Defaults to `enable`. */\n elementClassGrouping: \"enable\" | \"enableWithCounts\" | \"disable\";\n /** Full class name of a `GeometricElement3d` sub-class that should be used to load element nodes. Defaults to `BisCore.GeometricElement3d` */\n elementClassSpecification: string;\n /** Should models without elements be shown. Defaults to `false` */\n showEmptyModels: boolean;\n}\n\nexport const defaultHierarchyConfiguration: ModelsTreeHierarchyConfiguration = {\n elementClassGrouping: \"enable\",\n elementClassSpecification: \"BisCore.GeometricElement3d\",\n showEmptyModels: false,\n};\n\ninterface ModelsTreeDefinitionProps {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n idsCache: ModelsTreeIdsCache;\n hierarchyConfig: ModelsTreeHierarchyConfiguration;\n}\n\n/** @beta */\nexport interface ElementsGroupInfo {\n parent:\n | {\n ids: Id64String[];\n type: \"element\";\n }\n | {\n ids: Id64String[];\n modelIds: Id64String[];\n type: \"category\";\n };\n groupingNode: ClassGroupingHierarchyNode;\n}\n\ninterface ModelsTreeInstanceKeyPathsFromTargetItemsProps {\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n idsCache: ModelsTreeIdsCache;\n targetItems: Array<InstanceKey | ElementsGroupInfo>;\n hierarchyConfig: ModelsTreeHierarchyConfiguration;\n}\n\ninterface ModelsTreeInstanceKeyPathsFromInstanceLabelProps {\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n idsCache: ModelsTreeIdsCache;\n label: string;\n hierarchyConfig: ModelsTreeHierarchyConfiguration;\n}\n\nexport type ModelsTreeInstanceKeyPathsProps = ModelsTreeInstanceKeyPathsFromTargetItemsProps | ModelsTreeInstanceKeyPathsFromInstanceLabelProps;\ntype HierarchyProviderProps = Parameters<typeof createHierarchyProvider>[0];\ntype HierarchyFilteringPaths = NonNullable<NonNullable<HierarchyProviderProps[\"filtering\"]>[\"paths\"]>;\ntype HierarchyFilteringPath = HierarchyFilteringPaths[number];\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace ModelsTreeInstanceKeyPathsProps {\n export function isLabelProps(props: ModelsTreeInstanceKeyPathsProps): props is ModelsTreeInstanceKeyPathsFromInstanceLabelProps {\n return !!(props as ModelsTreeInstanceKeyPathsFromInstanceLabelProps).label;\n }\n}\n\nexport class ModelsTreeDefinition implements HierarchyDefinition {\n private _impl: HierarchyDefinition;\n private _idsCache: ModelsTreeIdsCache;\n private _hierarchyConfig: ModelsTreeHierarchyConfiguration;\n private _selectQueryFactory: NodesQueryClauseFactory;\n private _nodeLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n private _queryExecutor: LimitingECSqlQueryExecutor;\n private _isSupported?: Promise<boolean>;\n\n public constructor(props: ModelsTreeDefinitionProps) {\n this._impl = createClassBasedHierarchyDefinition({\n classHierarchyInspector: props.imodelAccess,\n hierarchy: {\n rootNodes: async (requestProps) => this.createRootHierarchyLevelDefinition(requestProps),\n childNodes: [\n {\n parentNodeClassName: \"BisCore.Subject\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createSubjectChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.ISubModeledElement\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createISubModeledElementChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.GeometricModel3d\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createGeometricModel3dChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.SpatialCategory\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createSpatialCategoryChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.GeometricElement3d\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createGeometricElement3dChildrenQuery(requestProps),\n },\n ],\n },\n });\n this._idsCache = props.idsCache;\n this._queryExecutor = props.imodelAccess;\n this._hierarchyConfig = props.hierarchyConfig;\n this._selectQueryFactory = createNodesQueryClauseFactory({ imodelAccess: props.imodelAccess });\n this._nodeLabelSelectClauseFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n }\n\n public async postProcessNode(node: ProcessedHierarchyNode): Promise<ProcessedHierarchyNode> {\n if (HierarchyNode.isClassGroupingNode(node)) {\n return {\n ...node,\n label: this._hierarchyConfig.elementClassGrouping === \"enableWithCounts\" ? `${node.label} (${node.children.length})` : node.label,\n extendedData: {\n ...node.extendedData,\n // add `modelId` and `categoryId` from the first grouped element\n ...node.children[0].extendedData,\n // `imageId` is assigned to instance nodes at query time, but grouping ones need to\n // be handled during post-processing\n imageId: \"icon-ec-class\",\n },\n };\n }\n return node;\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps) {\n if (this._isSupported === undefined) {\n this._isSupported = this.isSupported();\n }\n\n if ((await this._isSupported) === false) {\n return [];\n }\n\n return this._impl.defineHierarchyLevel(props);\n }\n\n private async createRootHierarchyLevelDefinition(props: DefineRootHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: props.instanceFilter,\n contentClass: { fullName: \"BisCore.Subject\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.Subject\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: ECSql.createRawPropertyValueSelector(\"this\", \"ECClassId\") },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.Subject\",\n }),\n },\n extendedData: {\n imageId: \"icon-imodel-hollow-2\",\n isSubject: true,\n },\n autoExpand: true,\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.Parent IS NULL\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n },\n ];\n }\n\n private async createSubjectChildrenQuery({\n parentNodeInstanceIds: subjectIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const [subjectFilterClauses, modelFilterClauses] = await Promise.all([\n this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.Subject\", alias: \"this\" },\n }),\n this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.GeometricModel3d\", alias: \"this\" },\n }),\n ]);\n const [childSubjectIds, childModelIds] = await Promise.all([\n this._idsCache.getChildSubjectIds(subjectIds),\n this._idsCache.getChildSubjectModelIds(subjectIds),\n ]);\n const defs = new Array<HierarchyNodesDefinition>();\n childSubjectIds.length &&\n defs.push({\n fullClassName: \"BisCore.Subject\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.Subject\",\n }),\n },\n hideIfNoChildren: true,\n hasChildren: { selector: `InVirtualSet(?, this.ECInstanceId)` },\n grouping: { byLabel: { action: \"merge\", groupId: \"subject\" } },\n extendedData: {\n imageId: \"icon-folder\",\n isSubject: true,\n },\n supportsFiltering: true,\n })}\n FROM ${subjectFilterClauses.from} this\n ${subjectFilterClauses.joins}\n WHERE\n this.ECInstanceId IN (${childSubjectIds.map(() => \"?\").join(\",\")})\n ${subjectFilterClauses.where ? `AND ${subjectFilterClauses.where}` : \"\"}\n `,\n bindings: [\n { type: \"idset\", value: await this._idsCache.getParentSubjectIds() },\n ...childSubjectIds.map((id): ECSqlBinding => ({ type: \"id\", value: id })),\n ],\n },\n });\n childModelIds.length &&\n defs.push({\n fullClassName: \"BisCore.GeometricModel3d\",\n query: {\n ecsql: `\n SELECT model.ECInstanceId AS ECInstanceId, model.*\n FROM (\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"m.ECClassId\" },\n ecInstanceId: { selector: \"m.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"partition\",\n className: \"BisCore.InformationPartitionElement\",\n }),\n },\n hideNodeInHierarchy: {\n selector: `\n CASE\n WHEN (\n json_extract([partition].JsonProperties, '$.PhysicalPartition.Model.Content') IS NOT NULL\n OR json_extract([partition].JsonProperties, '$.GraphicalPartition3d.Model.Content') IS NOT NULL\n ) THEN 1\n ELSE 0\n END\n `,\n },\n hasChildren: this._hierarchyConfig.showEmptyModels\n ? {\n selector: `\n IFNULL((\n SELECT 1\n FROM ${this._hierarchyConfig.elementClassSpecification} e\n WHERE e.Model.Id = m.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n }\n : true,\n extendedData: {\n imageId: \"icon-model\",\n isModel: true,\n },\n supportsFiltering: true,\n })}\n FROM Bis.GeometricModel3d m\n JOIN bis.InformationPartitionElement [partition] ON [partition].ECInstanceId = m.ModeledElement.Id\n WHERE\n m.ECInstanceId IN (${childModelIds.map(() => \"?\").join(\",\")})\n ) model\n JOIN ${modelFilterClauses.from} this ON this.ECInstanceId = model.ECInstanceId\n ${modelFilterClauses.joins}\n ${modelFilterClauses.where ? `AND (model.${NodeSelectClauseColumnNames.HideNodeInHierarchy} OR ${modelFilterClauses.where})` : \"\"}\n `,\n bindings: childModelIds.map((id): ECSqlBinding => ({ type: \"id\", value: id })),\n },\n });\n return defs;\n }\n\n private async createISubModeledElementChildrenQuery({\n parentNodeInstanceIds: elementIds,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n // note: we do not apply hierarchy level filtering on this hierarchy level, because it's always\n // hidden - the filter will get applied on the child hierarchy levels\n return [\n {\n fullClassName: \"BisCore.GeometricModel3d\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: \"\", // doesn't matter - the node is always hidden\n hideNodeInHierarchy: true,\n })}\n FROM BisCore.GeometricModel3d this\n WHERE\n this.ModeledElement.Id IN (${elementIds.map(() => \"?\").join(\",\")})\n AND NOT this.IsPrivate\n AND this.ECInstanceId IN (SELECT Model.Id FROM ${this._hierarchyConfig.elementClassSpecification})\n `,\n bindings: [...elementIds.map((id): ECSqlBinding => ({ type: \"id\", value: id }))],\n },\n },\n ];\n }\n\n private async createGeometricModel3dChildrenQuery({\n parentNodeInstanceIds: modelIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.SpatialCategory\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.SpatialCategory\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.SpatialCategory\",\n }),\n },\n grouping: { byLabel: { action: \"merge\", groupId: \"category\" } },\n hasChildren: true,\n extendedData: {\n imageId: \"icon-layers\",\n isCategory: true,\n modelIds: { selector: createIdsSelector(modelIds) },\n },\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n EXISTS (\n SELECT 1\n FROM ${this._hierarchyConfig.elementClassSpecification} element\n WHERE\n element.Model.Id IN (${modelIds.map(() => \"?\").join(\",\")})\n AND element.Category.Id = +this.ECInstanceId\n AND element.Parent IS NULL\n )\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: modelIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n private async createSpatialCategoryChildrenQuery({\n parentNodeInstanceIds: categoryIds,\n parentNode,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const modelIds = parseIdsSelectorResult(parentNode.extendedData?.modelIds);\n if (modelIds.length === 0) {\n throw new Error(`Invalid category node \"${parentNode.label}\" - missing model information.`);\n }\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: this._hierarchyConfig.elementClassSpecification, alias: \"this\" },\n });\n return [\n {\n fullClassName: this._hierarchyConfig.elementClassSpecification,\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: this._hierarchyConfig.elementClassSpecification,\n }),\n },\n grouping: {\n byClass: this._hierarchyConfig.elementClassGrouping !== \"disable\",\n },\n hasChildren: {\n selector: `\n IFNULL((\n SELECT 1\n FROM (\n SELECT Parent.Id ParentId FROM ${this._hierarchyConfig.elementClassSpecification}\n UNION ALL\n SELECT ModeledElement.Id ParentId FROM bis.GeometricModel3d\n )\n WHERE ParentId = this.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n },\n extendedData: {\n modelId: { selector: \"IdToHex(this.Model.Id)\" },\n categoryId: { selector: \"IdToHex(this.Category.Id)\" },\n imageId: \"icon-item\",\n },\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.Category.Id IN (${categoryIds.map(() => \"?\").join(\",\")})\n AND this.Model.Id IN (${modelIds.map(() => \"?\").join(\",\")})\n AND this.Parent IS NULL\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: [...categoryIds.map((id) => ({ type: \"id\", value: id })), ...modelIds.map((id) => ({ type: \"id\", value: id }))] as ECSqlBinding[],\n },\n },\n ];\n }\n\n private async createGeometricElement3dChildrenQuery({\n parentNodeInstanceIds: elementIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: this._hierarchyConfig.elementClassSpecification, alias: \"this\" },\n });\n return [\n {\n fullClassName: this._hierarchyConfig.elementClassSpecification,\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: this._hierarchyConfig.elementClassSpecification,\n }),\n },\n grouping: {\n byClass: this._hierarchyConfig.elementClassGrouping !== \"disable\",\n },\n hasChildren: {\n selector: `\n IFNULL((\n SELECT 1\n FROM (\n SELECT Parent.Id ParentId FROM ${this._hierarchyConfig.elementClassSpecification}\n UNION ALL\n SELECT ModeledElement.Id ParentId FROM bis.GeometricModel3d\n )\n WHERE ParentId = this.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n },\n extendedData: {\n modelId: { selector: \"IdToHex(this.Model.Id)\" },\n categoryId: { selector: \"IdToHex(this.Category.Id)\" },\n imageId: \"icon-item\",\n },\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.Parent.Id IN (${elementIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: elementIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n public static async createInstanceKeyPaths(props: ModelsTreeInstanceKeyPathsProps) {\n if (ModelsTreeInstanceKeyPathsProps.isLabelProps(props)) {\n const labelsFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n return createInstanceKeyPathsFromInstanceLabel({ ...props, labelsFactory });\n }\n return createInstanceKeyPathsFromTargetItems(props);\n }\n\n private async isSupported() {\n const [schemaName, className] = this._hierarchyConfig.elementClassSpecification.split(/[\\.:]/);\n if (!schemaName || !className) {\n throw new Error(\n `Provided class specification ${this._hierarchyConfig.elementClassSpecification} should be in format {SchemaName}:{ClassName} or {SchemaName}.{ClassName}`,\n );\n }\n\n const query: ECSqlQueryDef = {\n ecsql: `\n SELECT 1\n FROM ECDbMeta.ECSchemaDef s\n JOIN ECDbMeta.ECClassDef c ON c.Schema.Id = s.ECInstanceId\n WHERE s.Name = ? AND c.Name = ? AND c.ECInstanceId IS (BisCore.GeometricElement3d)\n `,\n bindings: [\n { type: \"string\", value: schemaName },\n { type: \"string\", value: className },\n ],\n };\n\n for await (const _row of this._queryExecutor.createQueryReader(query)) {\n return true;\n }\n return false;\n }\n}\n\nfunction createSubjectInstanceKeysPath(subjectId: Id64String, idsCache: ModelsTreeIdsCache): Observable<HierarchyNodeIdentifiersPath> {\n return from(idsCache.getSubjectAncestorsPath(subjectId)).pipe(map((idsPath) => idsPath.map((id) => ({ className: \"BisCore.Subject\", id }))));\n}\n\nfunction createModelInstanceKeyPaths(modelId: Id64String, idsCache: ModelsTreeIdsCache): Observable<HierarchyNodeIdentifiersPath> {\n return from(idsCache.getModelSubjects(modelId)).pipe(\n mergeAll(),\n mergeMap((modelSubjectId) =>\n createSubjectInstanceKeysPath(modelSubjectId, idsCache).pipe(\n map((subjectPath) => [...subjectPath, { className: \"BisCore.GeometricModel3d\", id: modelId }]),\n ),\n ),\n );\n}\n\nfunction createCategoryInstanceKeyPaths(categoryId: Id64String, idsCache: ModelsTreeIdsCache): Observable<HierarchyNodeIdentifiersPath> {\n return from(idsCache.getCategoryModels(categoryId)).pipe(\n mergeAll(),\n mergeMap((categoryModelId) =>\n createModelInstanceKeyPaths(categoryModelId, idsCache).pipe(map((modelPath) => [...modelPath, { className: \"BisCore.SpatialCategory\", id: categoryId }])),\n ),\n );\n}\n\nfunction createGeometricElementInstanceKeyPaths(\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor,\n idsCache: ModelsTreeIdsCache,\n hierarchyConfig: ModelsTreeHierarchyConfiguration,\n targetItems: Array<Id64String | ElementsGroupInfo>,\n): Observable<HierarchyFilteringPath> {\n const elementIds = targetItems.filter((info): info is Id64String => typeof info === \"string\");\n const groupInfos = targetItems.filter((info): info is ElementsGroupInfo => typeof info !== \"string\");\n\n return defer(() => {\n const bindings = new Array<ECSqlBinding>();\n const bind = (selector: string, idSet: Id64Array) => {\n bindings.push(...idSet.map((id) => ({ type: \"id\" as const, value: id })));\n return `${selector} IN (${idSet.map(() => \"?\").join(\",\")})`;\n };\n\n const targetElementsInfoQuery =\n elementIds.length > 0\n ? `\n SELECT e.ECInstanceId, e.ECClassId, e.Parent.Id, e.Model.Id, e.Category.Id, -1\n FROM ${hierarchyConfig.elementClassSpecification} e\n WHERE ${bind(\"e.ECInstanceId\", elementIds)}\n `\n : undefined;\n\n const targetGroupingNodesElementInfoQueries = groupInfos.map(\n ({ parent, groupingNode }, index) => `\n SELECT e.ECInstanceId, e.ECClassId, e.Parent.Id, e.Model.Id, e.Category.Id, ${index}\n FROM ${hierarchyConfig.elementClassSpecification} e\n WHERE\n e.ECClassId IS (${groupingNode.key.className})\n AND ${parent.type === \"element\" ? bind(\"e.Parent.Id\", parent.ids) : `e.Parent IS NULL AND ${bind(\"e.Category.Id\", parent.ids)} AND ${bind(\"e.Model.Id\", parent.modelIds)}`}\n `,\n );\n\n const ctes = [\n `InstanceElementsWithClassGroupingNodes(ECInstanceId, ECClassId, ParentId, ModelId, CategoryId, GroupingNodeIndex) AS (\n ${[...(targetElementsInfoQuery ? [targetElementsInfoQuery] : []), ...targetGroupingNodesElementInfoQueries].join(\" UNION ALL \")}\n )`,\n `ModelsCategoriesElementsHierarchy(ECInstanceId, ParentId, ModelId, GroupingNodeIndex, Path) AS (\n SELECT\n e.ECInstanceId,\n e.ParentId,\n e.ModelId,\n e.GroupingNodeIndex,\n json_array(\n ${createECInstanceKeySelectClause({ alias: \"e\" })},\n IIF(e.ParentId IS NULL, ${createECInstanceKeySelectClause({ alias: \"c\" })}, NULL),\n IIF(e.ParentId IS NULL, ${createECInstanceKeySelectClause({ alias: \"m\" })}, NULL)\n )\n FROM InstanceElementsWithClassGroupingNodes e\n JOIN bis.GeometricModel3d m ON m.ECInstanceId = e.ModelId\n JOIN bis.SpatialCategory c ON c.ECInstanceId = e.CategoryId\n\n UNION ALL\n\n SELECT\n pe.ECInstanceId,\n pe.Parent.Id,\n pe.Model.Id,\n ce.GroupingNodeIndex,\n json_insert(\n ce.Path,\n '$[#]', ${createECInstanceKeySelectClause({ alias: \"pe\" })},\n '$[#]', IIF(pe.Parent.Id IS NULL, ${createECInstanceKeySelectClause({ alias: \"c\" })}, NULL),\n '$[#]', IIF(pe.Parent.Id IS NULL, ${createECInstanceKeySelectClause({ alias: \"m\" })}, NULL)\n )\n FROM ModelsCategoriesElementsHierarchy ce\n JOIN ${hierarchyConfig.elementClassSpecification} pe ON (pe.ECInstanceId = ce.ParentId OR pe.ECInstanceId = ce.ModelId AND ce.ParentId IS NULL)\n JOIN bis.GeometricModel3d m ON m.ECInstanceId = pe.Model.Id\n JOIN bis.SpatialCategory c ON c.ECInstanceId = pe.Category.Id\n )`,\n ];\n const ecsql = `\n SELECT mce.ModelId, mce.Path, mce.GroupingNodeIndex\n FROM ModelsCategoriesElementsHierarchy mce\n WHERE mce.ParentId IS NULL\n `;\n\n return imodelAccess.createQueryReader({ ctes, ecsql, bindings }, { rowFormat: \"Indexes\" });\n }).pipe(\n map((row) => ({\n modelId: row[0],\n elementHierarchyPath: flatten<InstanceKey | undefined>(JSON.parse(row[1])).reverse(),\n groupingNode: row[2] === -1 ? undefined : groupInfos[row[2]].groupingNode,\n })),\n mergeMap(({ modelId, elementHierarchyPath, groupingNode }) =>\n createModelInstanceKeyPaths(modelId, idsCache).pipe(\n map((modelPath) => {\n modelPath.pop(); // model is already included in the element hierarchy path\n const path = [...modelPath, ...elementHierarchyPath.filter((x): x is InstanceKey => !!x)];\n if (!groupingNode) {\n return path;\n }\n return {\n path,\n options: {\n autoExpand: {\n key: groupingNode.key,\n depth: groupingNode.parentKeys.length,\n },\n },\n };\n }),\n ),\n ),\n );\n}\n\nasync function createInstanceKeyPathsFromTargetItems({\n targetItems,\n imodelAccess,\n hierarchyConfig,\n idsCache,\n}: ModelsTreeInstanceKeyPathsFromTargetItemsProps): Promise<HierarchyFilteringPath[]> {\n if (targetItems.length > MAX_FILTERING_INSTANCE_KEY_COUNT) {\n throw new FilterLimitExceededError(MAX_FILTERING_INSTANCE_KEY_COUNT);\n }\n const ids = {\n models: new Array<Id64String>(),\n categories: new Array<Id64String>(),\n subjects: new Array<Id64String>(),\n elements: new Array<Id64String | ElementsGroupInfo>(),\n };\n await Promise.all(\n targetItems.map(async (key) => {\n if (\"parent\" in key) {\n ids.elements.push(key);\n } else if (await imodelAccess.classDerivesFrom(key.className, \"BisCore.Subject\")) {\n ids.subjects.push(key.id);\n } else if (await imodelAccess.classDerivesFrom(key.className, \"BisCore.Model\")) {\n ids.models.push(key.id);\n } else if (await imodelAccess.classDerivesFrom(key.className, \"BisCore.SpatialCategory\")) {\n ids.categories.push(key.id);\n } else {\n ids.elements.push(key.id);\n }\n }),\n );\n return collect(\n merge(\n from(ids.subjects).pipe(mergeMap((id) => createSubjectInstanceKeysPath(id, idsCache))),\n from(ids.models).pipe(mergeMap((id) => createModelInstanceKeyPaths(id, idsCache))),\n from(ids.categories).pipe(mergeMap((id) => createCategoryInstanceKeyPaths(id, idsCache))),\n ids.elements.length ? createGeometricElementInstanceKeyPaths(imodelAccess, idsCache, hierarchyConfig, ids.elements) : EMPTY,\n ),\n );\n}\n\nasync function createInstanceKeyPathsFromInstanceLabel(\n props: ModelsTreeInstanceKeyPathsFromInstanceLabelProps & { labelsFactory: IInstanceLabelSelectClauseFactory },\n) {\n const elementLabelSelectClause = await props.labelsFactory.createSelectClause({\n classAlias: \"e\",\n className: \"BisCore.Element\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n selectorsConcatenator: ECSql.createConcatenatedValueStringSelector,\n });\n const targetsReader = props.imodelAccess.createQueryReader(\n {\n ecsql: `\n SELECT *\n FROM (\n SELECT\n ec_classname(e.ECClassId, 's.c'),\n e.ECInstanceId,\n ${elementLabelSelectClause} Label\n FROM BisCore.Element e\n WHERE e.ECClassId IS (BisCore.Subject, BisCore.SpatialCategory, ${props.hierarchyConfig.elementClassSpecification})\n\n UNION ALL\n\n SELECT\n ec_classname(m.ECClassId, 's.c'),\n m.ECInstanceId,\n ${elementLabelSelectClause} Label\n FROM BisCore.GeometricModel3d m\n JOIN BisCore.Element e ON e.ECInstanceId = m.ModeledElement.Id\n WHERE NOT m.IsPrivate\n ${props.hierarchyConfig.showEmptyModels ? \"\" : `AND EXISTS (SELECT 1 FROM ${props.hierarchyConfig.elementClassSpecification} WHERE Model.Id = m.ECInstanceId)`}\n AND json_extract(e.JsonProperties, '$.PhysicalPartition.Model.Content') IS NULL\n AND json_extract(e.JsonProperties, '$.GraphicalPartition3d.Model.Content') IS NULL\n )\n WHERE Label LIKE '%' || ? || '%' ESCAPE '\\\\'\n LIMIT ${MAX_FILTERING_INSTANCE_KEY_COUNT + 1}\n `,\n bindings: [{ type: \"string\", value: props.label.replace(/[%_\\\\]/g, \"\\\\$&\") }],\n },\n { rowFormat: \"Indexes\", restartToken: \"tree-widget/models-tree/filter-by-label-query\" },\n );\n\n const targetKeys = new Array<InstanceKey>();\n for await (const row of targetsReader) {\n targetKeys.push({ className: row[0], id: row[1] });\n }\n\n return createInstanceKeyPathsFromTargetItems({ ...props, targetItems: targetKeys });\n}\n\nfunction createECInstanceKeySelectClause(props: { alias: string }) {\n const classIdSelector = `[${props.alias}].[ECClassId]`;\n const instanceHexIdSelector = `IdToHex([${props.alias}].[ECInstanceId])`;\n return `json_object('className', ec_classname(${classIdSelector}, 's.c'), 'id', ${instanceHexIdSelector})`;\n}\n\ntype ArrayOrValue<T> = T | Array<ArrayOrValue<T>>;\nfunction flatten<T>(source: Array<ArrayOrValue<T>>): T[] {\n return source.reduce<T[]>((flat, item): T[] => {\n return [...flat, ...(Array.isArray(item) ? flatten(item) : [item])];\n }, new Array<T>());\n}\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { InstanceKey } from "@itwin/presentation-shared";
|
|
1
2
|
import type { ComponentPropsWithoutRef } from "react";
|
|
2
3
|
import type { Viewport } from "@itwin/core-frontend";
|
|
3
|
-
import type { ModelsTreeHierarchyConfiguration } from "./ModelsTreeDefinition";
|
|
4
|
+
import type { ElementsGroupInfo, ModelsTreeHierarchyConfiguration } from "./ModelsTreeDefinition";
|
|
4
5
|
import type { ModelsTreeVisibilityHandlerOverrides } from "./internal/ModelsTreeVisibilityHandler";
|
|
5
6
|
import type { VisibilityTree } from "../common/components/VisibilityTree";
|
|
6
7
|
import type { VisibilityTreeRenderer } from "../common/components/VisibilityTreeRenderer";
|
|
8
|
+
type HierarchyFilteringPaths = Awaited<ReturnType<Required<VisibilityTreeProps>["getFilteredPaths"]>>;
|
|
7
9
|
/** @beta */
|
|
8
10
|
type VisibilityTreeRendererProps = ComponentPropsWithoutRef<typeof VisibilityTreeRenderer>;
|
|
9
11
|
/** @beta */
|
|
@@ -14,6 +16,13 @@ interface UseModelsTreeProps {
|
|
|
14
16
|
activeView: Viewport;
|
|
15
17
|
hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;
|
|
16
18
|
visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides;
|
|
19
|
+
getFilteredPaths?: (props: {
|
|
20
|
+
createInstanceKeyPaths: (props: {
|
|
21
|
+
targetItems: Array<InstanceKey | ElementsGroupInfo>;
|
|
22
|
+
} | {
|
|
23
|
+
label: string;
|
|
24
|
+
}) => Promise<HierarchyFilteringPaths>;
|
|
25
|
+
}) => Promise<HierarchyFilteringPaths>;
|
|
17
26
|
}
|
|
18
27
|
/** @beta */
|
|
19
28
|
interface UseModelsTreeResult {
|
|
@@ -24,6 +33,6 @@ interface UseModelsTreeResult {
|
|
|
24
33
|
* Custom hook to create and manage state for the models tree.
|
|
25
34
|
* @beta
|
|
26
35
|
*/
|
|
27
|
-
export declare function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides }: UseModelsTreeProps): UseModelsTreeResult;
|
|
36
|
+
export declare function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides, getFilteredPaths }: UseModelsTreeProps): UseModelsTreeResult;
|
|
28
37
|
export {};
|
|
29
38
|
//# sourceMappingURL=UseModelsTree.d.ts.map
|