@itwin/presentation-hierarchies 2.0.0-alpha.0 → 2.0.0-alpha.10
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 +306 -7
- package/README.md +4 -22
- package/lib/cjs/hierarchies/HierarchyMerge.d.ts +19 -0
- package/lib/cjs/hierarchies/HierarchyMerge.d.ts.map +1 -0
- package/lib/cjs/hierarchies/HierarchyMerge.js +43 -0
- package/lib/cjs/hierarchies/HierarchyMerge.js.map +1 -0
- package/lib/cjs/hierarchies/HierarchyNode.d.ts +14 -24
- package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.js +1 -21
- package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.js +8 -8
- package/lib/cjs/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts +11 -29
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.js +0 -37
- package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchySearch.d.ts +167 -0
- package/lib/cjs/hierarchies/HierarchySearch.d.ts.map +1 -0
- package/lib/cjs/hierarchies/HierarchySearch.js +259 -0
- package/lib/cjs/hierarchies/HierarchySearch.js.map +1 -0
- package/lib/cjs/hierarchies/imodel/HierarchyCache.js +3 -3
- package/lib/cjs/hierarchies/imodel/HierarchyCache.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts +15 -4
- 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 +46 -11
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +192 -72
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts +2 -2
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js +99 -40
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts +35 -0
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -0
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js +285 -0
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -0
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts +5 -7
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js +15 -8
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.js +1 -0
- package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js +6 -5
- package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js +4 -3
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js +21 -16
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/Common.d.ts +3 -0
- package/lib/cjs/hierarchies/internal/Common.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/Common.js +12 -1
- package/lib/cjs/hierarchies/internal/Common.js.map +1 -1
- package/lib/cjs/hierarchies/internal/EachValueFrom.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/EachValueFrom.js +1 -0
- package/lib/cjs/hierarchies/internal/EachValueFrom.js.map +1 -1
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts +68 -0
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js +26 -0
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -0
- package/lib/cjs/presentation-hierarchies.d.ts +5 -4
- package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies.js +7 -7
- package/lib/cjs/presentation-hierarchies.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyMerge.d.ts +19 -0
- package/lib/esm/hierarchies/HierarchyMerge.d.ts.map +1 -0
- package/lib/esm/hierarchies/HierarchyMerge.js +40 -0
- package/lib/esm/hierarchies/HierarchyMerge.js.map +1 -0
- package/lib/esm/hierarchies/HierarchyNode.d.ts +14 -24
- package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.js +0 -20
- package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.js +9 -9
- package/lib/esm/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.d.ts +11 -29
- package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.js +1 -36
- package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/HierarchySearch.d.ts +167 -0
- package/lib/esm/hierarchies/HierarchySearch.d.ts.map +1 -0
- package/lib/esm/hierarchies/HierarchySearch.js +254 -0
- package/lib/esm/hierarchies/HierarchySearch.js.map +1 -0
- package/lib/esm/hierarchies/imodel/HierarchyCache.js +3 -3
- package/lib/esm/hierarchies/imodel/HierarchyCache.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts +15 -4
- 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 +46 -11
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +194 -75
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts +2 -2
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js +100 -41
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts +35 -0
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -0
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js +279 -0
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -0
- package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts +5 -7
- package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js +13 -7
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.js +1 -0
- package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js +7 -6
- package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js +5 -4
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js +22 -17
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
- package/lib/esm/hierarchies/internal/Common.d.ts +3 -0
- package/lib/esm/hierarchies/internal/Common.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/Common.js +11 -1
- package/lib/esm/hierarchies/internal/Common.js.map +1 -1
- package/lib/esm/hierarchies/internal/EachValueFrom.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/EachValueFrom.js +1 -0
- package/lib/esm/hierarchies/internal/EachValueFrom.js.map +1 -1
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts +68 -0
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js +23 -0
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -0
- package/lib/esm/presentation-hierarchies.d.ts +5 -4
- package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies.js +3 -3
- package/lib/esm/presentation-hierarchies.js.map +1 -1
- package/package.json +19 -19
- package/lib/cjs/hierarchies/HierarchyFiltering.d.ts +0 -110
- package/lib/cjs/hierarchies/HierarchyFiltering.d.ts.map +0 -1
- package/lib/cjs/hierarchies/HierarchyFiltering.js +0 -210
- package/lib/cjs/hierarchies/HierarchyFiltering.js.map +0 -1
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +0 -34
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +0 -1
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js +0 -270
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js.map +0 -1
- package/lib/esm/hierarchies/HierarchyFiltering.d.ts +0 -110
- package/lib/esm/hierarchies/HierarchyFiltering.d.ts.map +0 -1
- package/lib/esm/hierarchies/HierarchyFiltering.js +0 -205
- package/lib/esm/hierarchies/HierarchyFiltering.js.map +0 -1
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +0 -34
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +0 -1
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js +0 -264
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js.map +0 -1
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.createIModelHierarchyProvider = createIModelHierarchyProvider;
|
|
8
|
+
exports.createMergedIModelHierarchyProvider = createMergedIModelHierarchyProvider;
|
|
8
9
|
require("../internal/DisposePolyfill.js");
|
|
9
10
|
const rxjs_1 = require("rxjs");
|
|
10
11
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
@@ -12,6 +13,7 @@ const presentation_shared_1 = require("@itwin/presentation-shared");
|
|
|
12
13
|
const HierarchyErrors_js_1 = require("../HierarchyErrors.js");
|
|
13
14
|
const HierarchyNode_js_1 = require("../HierarchyNode.js");
|
|
14
15
|
const HierarchyNodeKey_js_1 = require("../HierarchyNodeKey.js");
|
|
16
|
+
const HierarchySearch_js_1 = require("../HierarchySearch.js");
|
|
15
17
|
const Common_js_1 = require("../internal/Common.js");
|
|
16
18
|
const EachValueFrom_js_1 = require("../internal/EachValueFrom.js");
|
|
17
19
|
const LoggingUtils_js_1 = require("../internal/LoggingUtils.js");
|
|
@@ -19,8 +21,8 @@ const Partition_js_1 = require("../internal/operators/Partition.js");
|
|
|
19
21
|
const ReduceToMergeMap_js_1 = require("../internal/operators/ReduceToMergeMap.js");
|
|
20
22
|
const ShareReplayWithErrors_js_1 = require("../internal/operators/ShareReplayWithErrors.js");
|
|
21
23
|
const Sorting_js_1 = require("../internal/operators/Sorting.js");
|
|
24
|
+
const RxjsHierarchyDefinition_js_1 = require("../internal/RxjsHierarchyDefinition.js");
|
|
22
25
|
const SubscriptionScheduler_js_1 = require("../internal/SubscriptionScheduler.js");
|
|
23
|
-
const FilteringHierarchyDefinition_js_1 = require("./FilteringHierarchyDefinition.js");
|
|
24
26
|
const HierarchyCache_js_1 = require("./HierarchyCache.js");
|
|
25
27
|
const IModelHierarchyDefinition_js_1 = require("./IModelHierarchyDefinition.js");
|
|
26
28
|
const NodeSelectQueryFactory_js_1 = require("./NodeSelectQueryFactory.js");
|
|
@@ -28,6 +30,7 @@ const DetermineChildren_js_1 = require("./operators/DetermineChildren.js");
|
|
|
28
30
|
const Grouping_js_1 = require("./operators/Grouping.js");
|
|
29
31
|
const HideIfNoChildren_js_1 = require("./operators/HideIfNoChildren.js");
|
|
30
32
|
const HideNodesInHierarchy_js_1 = require("./operators/HideNodesInHierarchy.js");
|
|
33
|
+
const SearchHierarchyDefinition_js_1 = require("./SearchHierarchyDefinition.js");
|
|
31
34
|
const TreeNodesReader_js_1 = require("./TreeNodesReader.js");
|
|
32
35
|
const LOGGING_NAMESPACE = `${Common_js_1.LOGGING_NAMESPACE}.IModelHierarchyProvider`;
|
|
33
36
|
const LOGGING_NAMESPACE_INTERNAL = `${Common_js_1.LOGGING_NAMESPACE_INTERNAL}.IModelHierarchyProvider`;
|
|
@@ -35,33 +38,57 @@ const LOGGING_NAMESPACE_PERFORMANCE = `${Common_js_1.LOGGING_NAMESPACE_PERFORMAN
|
|
|
35
38
|
const DEFAULT_QUERY_CONCURRENCY = 10;
|
|
36
39
|
const DEFAULT_QUERY_CACHE_SIZE = 1;
|
|
37
40
|
/**
|
|
38
|
-
* Creates an instance of `HierarchyProvider` that creates a hierarchy based on given iModel and
|
|
41
|
+
* Creates an instance of `HierarchyProvider` that creates a hierarchy based on given the iModel and
|
|
39
42
|
* a hierarchy definition, which defines each hierarchy level through ECSQL queries.
|
|
40
43
|
*
|
|
41
44
|
* @public
|
|
42
45
|
*/
|
|
43
46
|
function createIModelHierarchyProvider(props) {
|
|
47
|
+
const { imodelAccess, imodelChanged, ...restProps } = props;
|
|
48
|
+
return createMergedIModelHierarchyProvider({ ...restProps, imodels: [{ imodelAccess, imodelChanged }] });
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Creates an instance of `HierarchyProvider` that creates a hierarchy based on multiple version of **the same** iModel
|
|
52
|
+
* and a hierarchy definition, which defines each hierarchy level through ECSQL queries.
|
|
53
|
+
*
|
|
54
|
+
* **Warning:** This is an experimental API that **should not be used in production**.
|
|
55
|
+
*
|
|
56
|
+
* @alpha
|
|
57
|
+
*/
|
|
58
|
+
function createMergedIModelHierarchyProvider(props) {
|
|
44
59
|
return new IModelHierarchyProviderImpl(props);
|
|
45
60
|
}
|
|
46
61
|
class IModelHierarchyProviderImpl {
|
|
47
|
-
|
|
62
|
+
_imodels;
|
|
48
63
|
_hierarchyChanged;
|
|
49
64
|
_valuesFormatter;
|
|
50
65
|
_sourceHierarchyDefinition;
|
|
51
66
|
_activeHierarchyDefinition;
|
|
52
67
|
_localizedStrings;
|
|
53
|
-
|
|
68
|
+
_queryConcurrency;
|
|
69
|
+
_querySchedulers;
|
|
54
70
|
_nodesCache;
|
|
55
71
|
_unsubscribe;
|
|
56
72
|
_dispose = new rxjs_1.Subject();
|
|
73
|
+
#componentId;
|
|
74
|
+
#componentName;
|
|
75
|
+
#sourceName;
|
|
57
76
|
constructor(props) {
|
|
58
|
-
|
|
77
|
+
if (props.imodels.length === 0) {
|
|
78
|
+
throw new Error(`Creating an iModel hierarchy provider requires at least one iModel.`);
|
|
79
|
+
}
|
|
80
|
+
this.#componentId = core_bentley_1.Guid.createValue();
|
|
81
|
+
this.#componentName = "IModelHierarchyProviderImpl";
|
|
82
|
+
/* c8 ignore next */
|
|
83
|
+
this.#sourceName = props.sourceName ?? `${this.#componentName}:${this.#componentId}`;
|
|
84
|
+
this._imodels = props.imodels;
|
|
59
85
|
this._hierarchyChanged = new core_bentley_1.BeEvent();
|
|
60
|
-
this._activeHierarchyDefinition = this._sourceHierarchyDefinition = props.hierarchyDefinition;
|
|
86
|
+
this._activeHierarchyDefinition = this._sourceHierarchyDefinition = (0, RxjsHierarchyDefinition_js_1.getRxjsHierarchyDefinition)(props.hierarchyDefinition);
|
|
61
87
|
this._valuesFormatter = props?.formatter ?? (0, presentation_shared_1.createDefaultValueFormatter)();
|
|
62
88
|
this._localizedStrings = { other: "Other", unspecified: "Not specified", ...props?.localizedStrings };
|
|
63
|
-
this.
|
|
64
|
-
this.
|
|
89
|
+
this._queryConcurrency = props.queryConcurrency ?? DEFAULT_QUERY_CONCURRENCY;
|
|
90
|
+
this._querySchedulers = new Map();
|
|
91
|
+
this.setHierarchySearch(props.search);
|
|
65
92
|
const queryCacheSize = props.queryCacheSize ?? DEFAULT_QUERY_CACHE_SIZE;
|
|
66
93
|
if (queryCacheSize !== 0) {
|
|
67
94
|
this._nodesCache = new HierarchyCache_js_1.HierarchyCache({
|
|
@@ -70,11 +97,18 @@ class IModelHierarchyProviderImpl {
|
|
|
70
97
|
variationsCount: 1,
|
|
71
98
|
});
|
|
72
99
|
}
|
|
73
|
-
|
|
74
|
-
|
|
100
|
+
const imodelChangeSubscription = (0, rxjs_1.from)(this._imodels)
|
|
101
|
+
.pipe((0, rxjs_1.mergeMap)(({ imodelAccess, imodelChanged }) => imodelChanged
|
|
102
|
+
? (0, rxjs_1.fromEventPattern)((handler) => imodelChanged.addListener(handler), (handler) => imodelChanged.removeListener(handler), () => imodelAccess)
|
|
103
|
+
: rxjs_1.EMPTY))
|
|
104
|
+
.subscribe(({ imodelKey }) => {
|
|
105
|
+
this.invalidateHierarchyCache(`Data source changed: "${imodelKey}"`);
|
|
75
106
|
this._dispose.next();
|
|
76
107
|
this._hierarchyChanged.raiseEvent();
|
|
77
108
|
});
|
|
109
|
+
this._unsubscribe = () => {
|
|
110
|
+
imodelChangeSubscription.unsubscribe();
|
|
111
|
+
};
|
|
78
112
|
}
|
|
79
113
|
[Symbol.dispose]() {
|
|
80
114
|
this._dispose.next();
|
|
@@ -87,6 +121,17 @@ class IModelHierarchyProviderImpl {
|
|
|
87
121
|
get hierarchyChanged() {
|
|
88
122
|
return this._hierarchyChanged;
|
|
89
123
|
}
|
|
124
|
+
getQueryScheduler(imodelKey) {
|
|
125
|
+
let scheduler = this._querySchedulers.get(imodelKey);
|
|
126
|
+
if (!scheduler) {
|
|
127
|
+
scheduler = new SubscriptionScheduler_js_1.SubscriptionScheduler(this._queryConcurrency);
|
|
128
|
+
this._querySchedulers.set(imodelKey, scheduler);
|
|
129
|
+
}
|
|
130
|
+
return scheduler;
|
|
131
|
+
}
|
|
132
|
+
getPrimaryIModelAccess() {
|
|
133
|
+
return this._imodels[this._imodels.length - 1].imodelAccess;
|
|
134
|
+
}
|
|
90
135
|
invalidateHierarchyCache(reason) {
|
|
91
136
|
(0, LoggingUtils_js_1.doLog)({
|
|
92
137
|
category: `${LOGGING_NAMESPACE}.Events`,
|
|
@@ -102,23 +147,24 @@ class IModelHierarchyProviderImpl {
|
|
|
102
147
|
this._valuesFormatter = formatter ?? (0, presentation_shared_1.createDefaultValueFormatter)();
|
|
103
148
|
this._hierarchyChanged.raiseEvent({ formatterChange: { newFormatter: this._valuesFormatter } });
|
|
104
149
|
}
|
|
105
|
-
|
|
150
|
+
setHierarchySearch(props) {
|
|
106
151
|
if (!props) {
|
|
107
152
|
if (this._sourceHierarchyDefinition !== this._activeHierarchyDefinition) {
|
|
108
153
|
this._activeHierarchyDefinition = this._sourceHierarchyDefinition;
|
|
109
|
-
this.invalidateHierarchyCache("Hierarchy
|
|
154
|
+
this.invalidateHierarchyCache("Hierarchy search reset");
|
|
110
155
|
}
|
|
111
|
-
this._hierarchyChanged.raiseEvent({
|
|
156
|
+
this._hierarchyChanged.raiseEvent({ searchChange: { newSearch: undefined } });
|
|
112
157
|
return;
|
|
113
158
|
}
|
|
114
|
-
this._activeHierarchyDefinition = new
|
|
115
|
-
imodelAccess: this.
|
|
159
|
+
this._activeHierarchyDefinition = new SearchHierarchyDefinition_js_1.SearchHierarchyDefinition({
|
|
160
|
+
imodelAccess: this.getPrimaryIModelAccess(),
|
|
116
161
|
source: this._sourceHierarchyDefinition,
|
|
117
|
-
|
|
162
|
+
sourceName: this.#sourceName,
|
|
163
|
+
targetPaths: props.paths,
|
|
118
164
|
});
|
|
119
|
-
this.invalidateHierarchyCache("Hierarchy
|
|
165
|
+
this.invalidateHierarchyCache("Hierarchy search set");
|
|
120
166
|
this._dispose.next();
|
|
121
|
-
this._hierarchyChanged.raiseEvent({
|
|
167
|
+
this._hierarchyChanged.raiseEvent({ searchChange: { newSearch: props } });
|
|
122
168
|
}
|
|
123
169
|
onGroupingNodeCreated(groupingNode, props) {
|
|
124
170
|
this._nodesCache?.set({ ...props, parentNode: groupingNode }, { observable: (0, rxjs_1.from)(groupingNode.children), processingStatus: "pre-processed" });
|
|
@@ -129,48 +175,53 @@ class IModelHierarchyProviderImpl {
|
|
|
129
175
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
130
176
|
message: /* c8 ignore next */ () => `[${requestContext.requestId}] Requesting hierarchy level definitions for ${(0, Common_js_1.createNodeIdentifierForLogging)(props.parentNode)}`,
|
|
131
177
|
});
|
|
132
|
-
return (0, rxjs_1.from)((0, rxjs_1.
|
|
178
|
+
return (0, rxjs_1.from)(this._imodels).pipe((0, rxjs_1.mergeMap)(({ imodelAccess }, imodelAccessIndex) => {
|
|
133
179
|
let parentNode = props.parentNode;
|
|
134
|
-
if (parentNode && HierarchyNode_js_1.HierarchyNode.isGeneric(parentNode) && parentNode.key.source && parentNode.key.source !== this
|
|
135
|
-
return
|
|
180
|
+
if (parentNode && HierarchyNode_js_1.HierarchyNode.isGeneric(parentNode) && parentNode.key.source && parentNode.key.source !== this.#sourceName) {
|
|
181
|
+
return rxjs_1.EMPTY;
|
|
136
182
|
}
|
|
137
183
|
if (parentNode && HierarchyNode_js_1.HierarchyNode.isInstancesNode(parentNode)) {
|
|
138
184
|
parentNode = {
|
|
139
185
|
...parentNode,
|
|
140
186
|
key: {
|
|
141
187
|
...parentNode.key,
|
|
142
|
-
instanceKeys: parentNode.key.instanceKeys.filter((ik) => !ik.imodelKey || ik.imodelKey ===
|
|
188
|
+
instanceKeys: parentNode.key.instanceKeys.filter((ik) => !ik.imodelKey || ik.imodelKey === imodelAccess.imodelKey),
|
|
143
189
|
},
|
|
144
190
|
};
|
|
145
191
|
(0, core_bentley_1.assert)(HierarchyNodeKey_js_1.HierarchyNodeKey.isInstances(parentNode.key));
|
|
146
192
|
if (parentNode.key.instanceKeys.length === 0) {
|
|
147
|
-
return
|
|
193
|
+
return rxjs_1.EMPTY;
|
|
148
194
|
}
|
|
149
195
|
}
|
|
150
|
-
return this._activeHierarchyDefinition.defineHierarchyLevel({ ...defineHierarchyLevelProps, parentNode })
|
|
151
|
-
|
|
196
|
+
return this._activeHierarchyDefinition.defineHierarchyLevel({ ...defineHierarchyLevelProps, parentNode, imodelAccess }).pipe((0, rxjs_1.mergeAll)(), (0, rxjs_1.map)(
|
|
197
|
+
/* Using `as` to work around TS not understanding that `{ x: A, y: B | C }` is the same as `{ x: A } & ({ y: B } | { y: C })` */
|
|
198
|
+
(hierarchyNodesDefinition) => ({ imodelAccess, imodelAccessIndex, hierarchyNodesDefinition })));
|
|
199
|
+
}), (0, rxjs_1.finalize)(() => (0, LoggingUtils_js_1.doLog)({
|
|
152
200
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
153
201
|
message: /* c8 ignore next */ () => `[${requestContext.requestId}] Received all hierarchy level definitions for ${(0, Common_js_1.createNodeIdentifierForLogging)(props.parentNode)}`,
|
|
154
202
|
})));
|
|
155
203
|
}
|
|
156
204
|
createSourceNodesObservable(props) {
|
|
157
205
|
// pipe definitions to nodes and put "share replay" on it
|
|
158
|
-
return this.createHierarchyLevelDefinitionsObservable(props).pipe((0, rxjs_1.mergeMap)((def) => {
|
|
206
|
+
return this.createHierarchyLevelDefinitionsObservable(props).pipe((0, rxjs_1.mergeMap)(({ imodelAccess, imodelAccessIndex, hierarchyNodesDefinition: def }) => (0, rxjs_1.defer)(() => {
|
|
159
207
|
if (IModelHierarchyDefinition_js_1.HierarchyNodesDefinition.isGenericNode(def)) {
|
|
160
|
-
return (0, rxjs_1.of)({
|
|
208
|
+
return (0, rxjs_1.of)({
|
|
209
|
+
...def.node,
|
|
210
|
+
key: { type: "generic", id: def.node.key, source: this.#sourceName },
|
|
211
|
+
});
|
|
161
212
|
}
|
|
162
|
-
return this.
|
|
163
|
-
queryExecutor:
|
|
213
|
+
return this.getQueryScheduler(imodelAccess.imodelKey).scheduleSubscription((0, rxjs_1.of)(def.query).pipe((0, rxjs_1.map)((query) => createInstanceKeysFilteredQuery(query, props.targetInstanceKeys)), (0, rxjs_1.mergeMap)((query) => (0, TreeNodesReader_js_1.readNodes)({
|
|
214
|
+
queryExecutor: imodelAccess,
|
|
164
215
|
query,
|
|
165
216
|
limit: props.hierarchyLevelSizeLimit,
|
|
166
217
|
parser: this._activeHierarchyDefinition.parseNode
|
|
167
|
-
?
|
|
218
|
+
? ({ row }) => this._activeHierarchyDefinition.parseNode({ row, parentNode: props.parentNode, imodelKey: imodelAccess.imodelKey })
|
|
168
219
|
: undefined,
|
|
169
220
|
})), (0, rxjs_1.map)((node) => ({
|
|
170
221
|
...node,
|
|
171
|
-
key: { ...node.key, instanceKeys: node.key.instanceKeys.map((key) => ({ ...key, imodelKey:
|
|
222
|
+
key: { ...node.key, instanceKeys: node.key.instanceKeys.map((key) => ({ ...key, imodelKey: imodelAccess.imodelKey })) },
|
|
172
223
|
}))));
|
|
173
|
-
}), (0, rxjs_1.finalize)(() => (0, LoggingUtils_js_1.doLog)({
|
|
224
|
+
}).pipe((0, rxjs_1.map)((node) => ({ imodelAccess, imodelAccessIndex, node })))), mergeNodes, (0, rxjs_1.map)(({ node }) => node), (0, rxjs_1.finalize)(() => (0, LoggingUtils_js_1.doLog)({
|
|
174
225
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
175
226
|
message: /* c8 ignore next */ () => `[${props.requestContext.requestId}] Read all child nodes ${(0, Common_js_1.createNodeIdentifierForLogging)(props.parentNode)}`,
|
|
176
227
|
})), (0, ShareReplayWithErrors_js_1.shareReplayWithErrors)());
|
|
@@ -182,8 +233,9 @@ class IModelHierarchyProviderImpl {
|
|
|
182
233
|
// set parent node keys on the source node
|
|
183
234
|
(0, rxjs_1.map)((node) => Object.assign(node, { parentKeys: createParentNodeKeysList(props.parentNode) })),
|
|
184
235
|
// format `ConcatenatedValue` labels into string labels
|
|
185
|
-
(0, rxjs_1.mergeMap)(
|
|
236
|
+
(0, rxjs_1.mergeMap)((node) => applyLabelsFormatting(node, this._valuesFormatter)),
|
|
186
237
|
// we have `ProcessedHierarchyNode` from here
|
|
238
|
+
// let consumers step-in
|
|
187
239
|
preProcessNodes(this._activeHierarchyDefinition),
|
|
188
240
|
// process hiding
|
|
189
241
|
(0, HideIfNoChildren_js_1.createHideIfNoChildrenOperator)((n) => this.getChildNodesObservables({ parentNode: n, requestContext: props.requestContext }).hasNodes), (0, HideNodesInHierarchy_js_1.createHideNodesInHierarchyOperator)(
|
|
@@ -194,7 +246,7 @@ class IModelHierarchyProviderImpl {
|
|
|
194
246
|
})));
|
|
195
247
|
}
|
|
196
248
|
createProcessedNodesObservable(preprocessedNodesObservable, props) {
|
|
197
|
-
return preprocessedNodesObservable.pipe((0, Grouping_js_1.createGroupingOperator)(this.
|
|
249
|
+
return preprocessedNodesObservable.pipe((0, Grouping_js_1.createGroupingOperator)(this.getPrimaryIModelAccess(), props.parentNode, this._valuesFormatter, this._localizedStrings, undefined, (gn) => this.onGroupingNodeCreated(gn, props)), (0, rxjs_1.finalize)(() => (0, LoggingUtils_js_1.doLog)({
|
|
198
250
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
199
251
|
message: /* c8 ignore next */ () => `[${props.requestContext.requestId}] Finished grouping child nodes for ${(0, Common_js_1.createNodeIdentifierForLogging)(props.parentNode)}`,
|
|
200
252
|
})));
|
|
@@ -204,9 +256,7 @@ class IModelHierarchyProviderImpl {
|
|
|
204
256
|
if ("processingParams" in n) {
|
|
205
257
|
delete n.processingParams;
|
|
206
258
|
}
|
|
207
|
-
return
|
|
208
|
-
children: (0, Common_js_1.hasChildren)(n),
|
|
209
|
-
});
|
|
259
|
+
return { ...n, children: (0, Common_js_1.hasChildren)(n) };
|
|
210
260
|
}), (0, rxjs_1.takeUntil)(this._dispose), (0, rxjs_1.finalize)(() => (0, LoggingUtils_js_1.doLog)({
|
|
211
261
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
212
262
|
message: /* c8 ignore next */ () => `[${props.requestContext.requestId}] Finished finalizing child nodes for ${(0, Common_js_1.createNodeIdentifierForLogging)(props.parentNode)}`,
|
|
@@ -240,13 +290,13 @@ class IModelHierarchyProviderImpl {
|
|
|
240
290
|
return cached;
|
|
241
291
|
}
|
|
242
292
|
// if we don't find an entry for a grouping node, we load its instances by getting a query and applying
|
|
243
|
-
// a
|
|
244
|
-
let
|
|
293
|
+
// a search based on grouped instance keys
|
|
294
|
+
let targetInstanceKeys;
|
|
245
295
|
let parentNonGroupingNode;
|
|
246
296
|
if (parentNode) {
|
|
247
297
|
if (HierarchyNode_js_1.HierarchyNode.isGroupingNode(parentNode)) {
|
|
248
298
|
parentNonGroupingNode = parentNode.nonGroupingAncestor;
|
|
249
|
-
|
|
299
|
+
targetInstanceKeys = parentNode.groupedInstanceKeys;
|
|
250
300
|
}
|
|
251
301
|
else {
|
|
252
302
|
// not sure why type checker doesn't pick this up
|
|
@@ -257,7 +307,7 @@ class IModelHierarchyProviderImpl {
|
|
|
257
307
|
const nonGroupingNodeChildrenRequestProps = {
|
|
258
308
|
...restProps,
|
|
259
309
|
parentNode: parentNonGroupingNode,
|
|
260
|
-
...(
|
|
310
|
+
...(targetInstanceKeys ? { targetInstanceKeys } : undefined),
|
|
261
311
|
};
|
|
262
312
|
const value = { observable: this.createSourceNodesObservable(nonGroupingNodeChildrenRequestProps), processingStatus: "none" };
|
|
263
313
|
this._nodesCache?.set(nonGroupingNodeChildrenRequestProps, value);
|
|
@@ -321,11 +371,11 @@ class IModelHierarchyProviderImpl {
|
|
|
321
371
|
return (0, rxjs_1.from)(parentNode.groupedInstanceKeys);
|
|
322
372
|
}
|
|
323
373
|
(0, core_bentley_1.assert)(!parentNode || HierarchyNode_js_1.HierarchyNode.isGeneric(parentNode) || HierarchyNode_js_1.HierarchyNode.isInstancesNode(parentNode));
|
|
324
|
-
const hierarchyLevelDefinitions = this.createHierarchyLevelDefinitionsObservable({ parentNode, instanceFilter, requestContext });
|
|
325
374
|
// split the definitions based on whether they're for generic nodes or for instance nodes
|
|
326
|
-
const
|
|
375
|
+
const hierarchyLevelDefinitions = this.createHierarchyLevelDefinitionsObservable({ parentNode, instanceFilter, requestContext });
|
|
376
|
+
const [instanceDefs, genericDefs] = (0, Partition_js_1.partition)(hierarchyLevelDefinitions, (x) => IModelHierarchyDefinition_js_1.HierarchyNodesDefinition.isInstanceNodesQuery(x.hierarchyNodesDefinition));
|
|
327
377
|
// query instance keys and a flag whether they should be hidden
|
|
328
|
-
const instanceKeys = instanceDefs.pipe((0, rxjs_1.mergeMap)((def) => this.
|
|
378
|
+
const instanceKeys = instanceDefs.pipe((0, rxjs_1.mergeMap)(({ imodelAccess, hierarchyNodesDefinition: def }) => this.getQueryScheduler(imodelAccess.imodelKey).scheduleSubscription((0, rxjs_1.of)(def.query).pipe((0, rxjs_1.mergeMap)(async (query) => {
|
|
329
379
|
const ecsql = `
|
|
330
380
|
SELECT
|
|
331
381
|
${NodeSelectQueryFactory_js_1.NodeSelectClauseColumnNames.FullClassName},
|
|
@@ -335,12 +385,16 @@ class IModelHierarchyProviderImpl {
|
|
|
335
385
|
${query.ecsql}
|
|
336
386
|
)
|
|
337
387
|
`;
|
|
338
|
-
const reader =
|
|
388
|
+
const reader = imodelAccess.createQueryReader({ ...query, ecsql }, {
|
|
389
|
+
rowFormat: "Indexes",
|
|
390
|
+
limit: hierarchyLevelSizeLimit,
|
|
391
|
+
restartToken: `${this.#componentName}/${this.#componentId}/node-instance-keys/${core_bentley_1.Guid.createValue()}`,
|
|
392
|
+
});
|
|
339
393
|
return (0, rxjs_1.from)(reader).pipe((0, rxjs_1.map)((row) => ({
|
|
340
394
|
key: {
|
|
341
395
|
className: (0, presentation_shared_1.normalizeFullClassName)(row[0]),
|
|
342
396
|
id: row[1],
|
|
343
|
-
imodelKey:
|
|
397
|
+
imodelKey: imodelAccess.imodelKey,
|
|
344
398
|
},
|
|
345
399
|
hide: !!row[2],
|
|
346
400
|
})));
|
|
@@ -350,17 +404,17 @@ class IModelHierarchyProviderImpl {
|
|
|
350
404
|
// hidden items' handling:
|
|
351
405
|
// - if a generic node is hidden, we'll want to retrieve instance keys of its children, otherwise we don't care about it,
|
|
352
406
|
// - if an instance key is hidden, we want to create a merged node similar to what we do in `createHideNodesInHierarchyOperator`
|
|
353
|
-
const hiddenParentNodes = (0, rxjs_1.merge)(genericDefs.pipe((0, rxjs_1.filter)((
|
|
407
|
+
const hiddenParentNodes = (0, rxjs_1.merge)(genericDefs.pipe((0, rxjs_1.filter)(({ hierarchyNodesDefinition }) => !!hierarchyNodesDefinition.node.processingParams?.hideInHierarchy), (0, rxjs_1.map)(({ hierarchyNodesDefinition }) => ({
|
|
354
408
|
type: "generic",
|
|
355
|
-
id:
|
|
356
|
-
source: this
|
|
409
|
+
id: hierarchyNodesDefinition.node.key,
|
|
410
|
+
source: this.#sourceName,
|
|
357
411
|
}))), hiddenNodeInstanceKeys.pipe(
|
|
358
412
|
// first merge all keys by class
|
|
359
|
-
(0, ReduceToMergeMap_js_1.reduceToMergeMapList)(({ key }) => key.className, ({ key }) => key
|
|
413
|
+
(0, ReduceToMergeMap_js_1.reduceToMergeMapList)(({ key }) => key.className, ({ key }) => key),
|
|
360
414
|
// then, for each class, create an instance key
|
|
361
|
-
(0, rxjs_1.mergeMap)((mergedMap) => [...mergedMap.entries()].map(([className,
|
|
415
|
+
(0, rxjs_1.mergeMap)((mergedMap) => [...mergedMap.entries()].map(([className, keys]) => ({
|
|
362
416
|
type: "instances",
|
|
363
|
-
instanceKeys:
|
|
417
|
+
instanceKeys: keys.map(({ id, imodelKey }) => ({ className, id, imodelKey })),
|
|
364
418
|
}))))).pipe((0, rxjs_1.map)((key) => ({
|
|
365
419
|
key,
|
|
366
420
|
parentKeys: [],
|
|
@@ -398,26 +452,22 @@ class IModelHierarchyProviderImpl {
|
|
|
398
452
|
}
|
|
399
453
|
}
|
|
400
454
|
function preProcessNodes(hierarchyFactory) {
|
|
401
|
-
return hierarchyFactory.preProcessNode
|
|
402
|
-
? processNodes(hierarchyFactory.preProcessNode.bind(hierarchyFactory))
|
|
403
|
-
: (o) => o;
|
|
455
|
+
return hierarchyFactory.preProcessNode ? processNodes(hierarchyFactory.preProcessNode) : rxjs_1.identity;
|
|
404
456
|
}
|
|
405
457
|
function postProcessNodes(hierarchyFactory) {
|
|
406
|
-
return hierarchyFactory.postProcessNode
|
|
407
|
-
? processNodes(hierarchyFactory.postProcessNode.bind(hierarchyFactory))
|
|
408
|
-
: (o) => o;
|
|
458
|
+
return hierarchyFactory.postProcessNode ? processNodes(hierarchyFactory.postProcessNode) : rxjs_1.identity;
|
|
409
459
|
}
|
|
410
460
|
function processNodes(processor) {
|
|
411
|
-
return (nodes) => nodes.pipe((0, rxjs_1.mergeMap)(processor)
|
|
461
|
+
return (nodes) => nodes.pipe((0, rxjs_1.mergeMap)(processor));
|
|
412
462
|
}
|
|
413
|
-
|
|
414
|
-
return {
|
|
463
|
+
function applyLabelsFormatting(node, valueFormatter) {
|
|
464
|
+
return (0, rxjs_1.from)((0, presentation_shared_1.formatConcatenatedValue)({
|
|
465
|
+
value: node.label,
|
|
466
|
+
valueFormatter,
|
|
467
|
+
})).pipe((0, rxjs_1.map)((label) => ({
|
|
415
468
|
...node,
|
|
416
|
-
label
|
|
417
|
-
|
|
418
|
-
valueFormatter,
|
|
419
|
-
}),
|
|
420
|
-
};
|
|
469
|
+
label,
|
|
470
|
+
})));
|
|
421
471
|
}
|
|
422
472
|
function createParentNodeKeysList(parentNode) {
|
|
423
473
|
if (!parentNode) {
|
|
@@ -425,20 +475,20 @@ function createParentNodeKeysList(parentNode) {
|
|
|
425
475
|
}
|
|
426
476
|
return [...parentNode.parentKeys, parentNode.key];
|
|
427
477
|
}
|
|
428
|
-
function
|
|
429
|
-
if (!
|
|
478
|
+
function createInstanceKeysFilteredQuery(query, targetInstanceKeys) {
|
|
479
|
+
if (!targetInstanceKeys || !targetInstanceKeys.length) {
|
|
430
480
|
return query;
|
|
431
481
|
}
|
|
432
482
|
const MAX_ALLOWED_BINDINGS = 1000;
|
|
433
|
-
if (
|
|
483
|
+
if (targetInstanceKeys.length < MAX_ALLOWED_BINDINGS) {
|
|
434
484
|
return {
|
|
435
485
|
...query,
|
|
436
486
|
ecsql: `
|
|
437
487
|
SELECT *
|
|
438
488
|
FROM (${query.ecsql}) q
|
|
439
|
-
WHERE q.ECInstanceId IN (${
|
|
489
|
+
WHERE q.ECInstanceId IN (${targetInstanceKeys.map(() => "?").join(",")})
|
|
440
490
|
`,
|
|
441
|
-
bindings: [...(query.bindings ?? []), ...
|
|
491
|
+
bindings: [...(query.bindings ?? []), ...targetInstanceKeys.map((k) => ({ type: "id", value: k.id }))],
|
|
442
492
|
};
|
|
443
493
|
}
|
|
444
494
|
/* c8 ignore start */
|
|
@@ -449,8 +499,78 @@ function filterQueryByInstanceKeys(query, filteredInstanceKeys) {
|
|
|
449
499
|
FROM (${query.ecsql}) q
|
|
450
500
|
WHERE InVirtualSet(?, q.ECInstanceId)
|
|
451
501
|
`,
|
|
452
|
-
bindings: [...(query.bindings ?? []), { type: "idset", value:
|
|
502
|
+
bindings: [...(query.bindings ?? []), { type: "idset", value: targetInstanceKeys.map((k) => k.id) }],
|
|
453
503
|
};
|
|
454
504
|
/* c8 ignore end */
|
|
455
505
|
}
|
|
506
|
+
function mergeNodes(source) {
|
|
507
|
+
return (0, rxjs_1.from)(source).pipe((0, rxjs_1.reduce)((acc, input) => {
|
|
508
|
+
for (let i = 0; i < acc.length; ++i) {
|
|
509
|
+
if (input.imodelAccess === acc[i].imodelAccess) {
|
|
510
|
+
// don't attempt to merge nodes if they come from the same provider
|
|
511
|
+
continue;
|
|
512
|
+
}
|
|
513
|
+
// the first argument for `tryMergeNodes` acts as the primary data source, so we have to make sure we pass
|
|
514
|
+
// the node with higher `imodelAccessIndex` first
|
|
515
|
+
const candidates = input.imodelAccessIndex > acc[i].imodelAccessIndex
|
|
516
|
+
? { imodelAccess: input.imodelAccess, imodelAccessIndex: input.imodelAccessIndex, primary: input.node, secondary: acc[i].node }
|
|
517
|
+
: { imodelAccess: acc[i].imodelAccess, imodelAccessIndex: acc[i].imodelAccessIndex, primary: acc[i].node, secondary: input.node };
|
|
518
|
+
const merged = tryMergeNodes(candidates.primary, candidates.secondary);
|
|
519
|
+
if (merged) {
|
|
520
|
+
acc[i] = { node: merged, imodelAccess: candidates.imodelAccess, imodelAccessIndex: candidates.imodelAccessIndex };
|
|
521
|
+
return acc;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
acc.push(input);
|
|
525
|
+
return acc;
|
|
526
|
+
}, new Array()), (0, rxjs_1.mergeAll)());
|
|
527
|
+
}
|
|
528
|
+
function mergeSearchProps(primary, secondary) {
|
|
529
|
+
if (!primary || !secondary) {
|
|
530
|
+
return primary ?? secondary;
|
|
531
|
+
}
|
|
532
|
+
const hasSearchTargetAncestor = primary.hasSearchTargetAncestor || secondary.hasSearchTargetAncestor;
|
|
533
|
+
const childrenTargetPaths = [...(primary.childrenTargetPaths ?? []), ...(secondary.childrenTargetPaths ?? [])];
|
|
534
|
+
return {
|
|
535
|
+
...(hasSearchTargetAncestor ? { hasSearchTargetAncestor } : undefined),
|
|
536
|
+
...(childrenTargetPaths.length ? { childrenTargetPaths } : undefined),
|
|
537
|
+
...(primary.isSearchTarget || secondary.isSearchTarget
|
|
538
|
+
? {
|
|
539
|
+
isSearchTarget: true,
|
|
540
|
+
searchTargetOptions: HierarchySearch_js_1.HierarchySearchPath.mergeOptions(primary.isSearchTarget ? primary.searchTargetOptions : undefined, secondary.isSearchTarget ? secondary.searchTargetOptions : undefined),
|
|
541
|
+
}
|
|
542
|
+
: {
|
|
543
|
+
isSearchTarget: false,
|
|
544
|
+
}),
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
function tryMergeInstanceNodes(primary, secondary) {
|
|
548
|
+
if (HierarchyNode_js_1.HierarchyNode.isInstancesNode(primary) &&
|
|
549
|
+
HierarchyNode_js_1.HierarchyNode.isInstancesNode(secondary) &&
|
|
550
|
+
primary.key.instanceKeys.some((lhsKey) => secondary.key.instanceKeys.some((rhsKey) => presentation_shared_1.InstanceKey.equals(lhsKey, rhsKey)))) {
|
|
551
|
+
const searchProps = mergeSearchProps(primary.search, secondary.search);
|
|
552
|
+
return {
|
|
553
|
+
...primary,
|
|
554
|
+
key: {
|
|
555
|
+
type: "instances",
|
|
556
|
+
instanceKeys: primary.key.instanceKeys.concat(secondary.key.instanceKeys),
|
|
557
|
+
},
|
|
558
|
+
...(searchProps ? { search: searchProps } : undefined),
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
return undefined;
|
|
562
|
+
}
|
|
563
|
+
function tryMergeGenericNodes(primary, secondary) {
|
|
564
|
+
if (HierarchyNode_js_1.HierarchyNode.isGeneric(primary) && HierarchyNode_js_1.HierarchyNode.isGeneric(secondary) && primary.key.type === secondary.key.type) {
|
|
565
|
+
const searchProps = mergeSearchProps(primary.search, secondary.search);
|
|
566
|
+
return {
|
|
567
|
+
...primary,
|
|
568
|
+
...(searchProps ? { search: searchProps } : undefined),
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
return undefined;
|
|
572
|
+
}
|
|
573
|
+
function tryMergeNodes(primary, secondary) {
|
|
574
|
+
return tryMergeInstanceNodes(primary, secondary) ?? tryMergeGenericNodes(primary, secondary) ?? undefined;
|
|
575
|
+
}
|
|
456
576
|
//# sourceMappingURL=IModelHierarchyProvider.js.map
|