@itwin/presentation-hierarchies 1.7.11 → 1.7.12
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 +65 -12
- package/lib/cjs/hierarchies/HierarchyFiltering.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyFiltering.js +21 -6
- package/lib/cjs/hierarchies/HierarchyFiltering.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.js +2 -2
- package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/cjs/hierarchies/Logging.js +1 -1
- package/lib/cjs/hierarchies/Logging.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js +2 -2
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +65 -37
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/LimitingECSqlQueryExecutor.js +8 -7
- package/lib/cjs/hierarchies/imodel/LimitingECSqlQueryExecutor.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js +4 -0
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/DetermineChildren.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/DetermineChildren.js +10 -4
- package/lib/cjs/hierarchies/imodel/operators/DetermineChildren.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/Grouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/Grouping.js +29 -15
- package/lib/cjs/hierarchies/imodel/operators/Grouping.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.js +23 -8
- package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideNodesInHierarchy.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideNodesInHierarchy.js +28 -13
- package/lib/cjs/hierarchies/imodel/operators/HideNodesInHierarchy.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js +1 -2
- package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/Common.js +2 -2
- 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 +0 -2
- package/lib/cjs/hierarchies/internal/EachValueFrom.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Sorting.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Sorting.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyFiltering.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyFiltering.js +21 -6
- package/lib/esm/hierarchies/HierarchyFiltering.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.js +2 -2
- package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/esm/hierarchies/Logging.js +1 -1
- package/lib/esm/hierarchies/Logging.js.map +1 -1
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js +2 -2
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +65 -37
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/imodel/LimitingECSqlQueryExecutor.js +8 -7
- package/lib/esm/hierarchies/imodel/LimitingECSqlQueryExecutor.js.map +1 -1
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js +4 -0
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/DetermineChildren.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/DetermineChildren.js +10 -4
- package/lib/esm/hierarchies/imodel/operators/DetermineChildren.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/Grouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/Grouping.js +29 -15
- package/lib/esm/hierarchies/imodel/operators/Grouping.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.js +23 -8
- package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideNodesInHierarchy.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideNodesInHierarchy.js +28 -13
- package/lib/esm/hierarchies/imodel/operators/HideNodesInHierarchy.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js +1 -2
- package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
- package/lib/esm/hierarchies/internal/Common.js +2 -2
- 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 +0 -2
- package/lib/esm/hierarchies/internal/EachValueFrom.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/Sorting.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/Sorting.js.map +1 -1
- package/package.json +14 -22
|
@@ -82,7 +82,7 @@ class IModelHierarchyProviderImpl {
|
|
|
82
82
|
this._dispose.next();
|
|
83
83
|
this._unsubscribe?.();
|
|
84
84
|
}
|
|
85
|
-
/*
|
|
85
|
+
/* v8 ignore next -- @preserve */
|
|
86
86
|
dispose() {
|
|
87
87
|
this[Symbol.dispose]();
|
|
88
88
|
}
|
|
@@ -90,9 +90,10 @@ class IModelHierarchyProviderImpl {
|
|
|
90
90
|
return this._hierarchyChanged;
|
|
91
91
|
}
|
|
92
92
|
invalidateHierarchyCache(reason) {
|
|
93
|
+
/* v8 ignore next -- @preserve */
|
|
93
94
|
doLog({
|
|
94
95
|
category: `${LOGGING_NAMESPACE}.Events`,
|
|
95
|
-
message:
|
|
96
|
+
message: () => (reason ? `${reason}: clear hierarchy cache` : `Clear hierarchy cache`),
|
|
96
97
|
});
|
|
97
98
|
this._nodesCache?.clear();
|
|
98
99
|
}
|
|
@@ -127,9 +128,10 @@ class IModelHierarchyProviderImpl {
|
|
|
127
128
|
}
|
|
128
129
|
createHierarchyLevelDefinitionsObservable(props) {
|
|
129
130
|
const { requestContext, ...defineHierarchyLevelProps } = props;
|
|
131
|
+
/* v8 ignore next -- @preserve */
|
|
130
132
|
doLog({
|
|
131
133
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
132
|
-
message:
|
|
134
|
+
message: () => `[${requestContext.requestId}] Requesting hierarchy level definitions for ${createNodeIdentifierForLogging(props.parentNode)}`,
|
|
133
135
|
});
|
|
134
136
|
let parentNode = props.parentNode;
|
|
135
137
|
if (parentNode && HierarchyNode.isGeneric(parentNode) && parentNode.key.source && parentNode.key.source !== this._imodelAccess.imodelKey) {
|
|
@@ -148,10 +150,13 @@ class IModelHierarchyProviderImpl {
|
|
|
148
150
|
return EMPTY;
|
|
149
151
|
}
|
|
150
152
|
}
|
|
151
|
-
return this._activeHierarchyDefinition.defineHierarchyLevel({ ...defineHierarchyLevelProps, parentNode }).pipe(mergeAll(), finalize(() =>
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
return this._activeHierarchyDefinition.defineHierarchyLevel({ ...defineHierarchyLevelProps, parentNode }).pipe(mergeAll(), finalize(() => {
|
|
154
|
+
/* v8 ignore next -- @preserve */
|
|
155
|
+
doLog({
|
|
156
|
+
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
157
|
+
message: () => `[${requestContext.requestId}] Received all hierarchy level definitions for ${createNodeIdentifierForLogging(props.parentNode)}`,
|
|
158
|
+
});
|
|
159
|
+
}));
|
|
155
160
|
}
|
|
156
161
|
createSourceNodesObservable(props) {
|
|
157
162
|
// pipe definitions to nodes and put "share replay" on it
|
|
@@ -168,10 +173,13 @@ class IModelHierarchyProviderImpl {
|
|
|
168
173
|
...node,
|
|
169
174
|
key: { ...node.key, instanceKeys: node.key.instanceKeys.map((key) => ({ ...key, imodelKey: this._imodelAccess.imodelKey })) },
|
|
170
175
|
}))));
|
|
171
|
-
}), finalize(() =>
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
}), finalize(() => {
|
|
177
|
+
/* v8 ignore next -- @preserve */
|
|
178
|
+
doLog({
|
|
179
|
+
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
180
|
+
message: () => `[${props.requestContext.requestId}] Read all child nodes ${createNodeIdentifierForLogging(props.parentNode)}`,
|
|
181
|
+
});
|
|
182
|
+
}), shareReplayWithErrors());
|
|
175
183
|
}
|
|
176
184
|
createPreProcessedNodesObservable(queryNodesObservable, props) {
|
|
177
185
|
return queryNodesObservable.pipe(
|
|
@@ -186,16 +194,22 @@ class IModelHierarchyProviderImpl {
|
|
|
186
194
|
// process hiding
|
|
187
195
|
createHideIfNoChildrenOperator((n) => this.getChildNodesObservables({ parentNode: n, requestContext: props.requestContext }).hasNodes), createHideNodesInHierarchyOperator(
|
|
188
196
|
// note: for child nodes created because of hidden parent, we want to use parent's request props (instance filter, limit)
|
|
189
|
-
(n) => this.getChildNodesObservables({ ...props, parentNode: n }).processedNodes, false), finalize(() =>
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
197
|
+
(n) => this.getChildNodesObservables({ ...props, parentNode: n }).processedNodes, false), finalize(() => {
|
|
198
|
+
/* v8 ignore next -- @preserve */
|
|
199
|
+
doLog({
|
|
200
|
+
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
201
|
+
message: () => `[${props.requestContext.requestId}] Finished pre-processing child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,
|
|
202
|
+
});
|
|
203
|
+
}));
|
|
193
204
|
}
|
|
194
205
|
createProcessedNodesObservable(preprocessedNodesObservable, props) {
|
|
195
|
-
return preprocessedNodesObservable.pipe(createGroupingOperator(this._imodelAccess, props.parentNode, this._valuesFormatter, this._localizedStrings, undefined, (gn) => this.onGroupingNodeCreated(gn, props)), finalize(() =>
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
206
|
+
return preprocessedNodesObservable.pipe(createGroupingOperator(this._imodelAccess, props.parentNode, this._valuesFormatter, this._localizedStrings, undefined, (gn) => this.onGroupingNodeCreated(gn, props)), finalize(() => {
|
|
207
|
+
/* v8 ignore next -- @preserve */
|
|
208
|
+
doLog({
|
|
209
|
+
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
210
|
+
message: () => `[${props.requestContext.requestId}] Finished grouping child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,
|
|
211
|
+
});
|
|
212
|
+
}));
|
|
199
213
|
}
|
|
200
214
|
createFinalizedNodesObservable(processedNodesObservable, props) {
|
|
201
215
|
return processedNodesObservable.pipe(createDetermineChildrenOperator((n) => this.getChildNodesObservables({ parentNode: n, requestContext: props.requestContext }).hasNodes), postProcessNodes(this._activeHierarchyDefinition), sortNodesByLabelOperator, map((n) => {
|
|
@@ -205,35 +219,44 @@ class IModelHierarchyProviderImpl {
|
|
|
205
219
|
return Object.assign(n, {
|
|
206
220
|
children: hasChildren(n),
|
|
207
221
|
});
|
|
208
|
-
}), takeUntil(this._dispose), finalize(() =>
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
222
|
+
}), takeUntil(this._dispose), finalize(() => {
|
|
223
|
+
/* v8 ignore next -- @preserve */
|
|
224
|
+
doLog({
|
|
225
|
+
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
226
|
+
message: () => `[${props.requestContext.requestId}] Finished finalizing child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,
|
|
227
|
+
});
|
|
228
|
+
}));
|
|
212
229
|
}
|
|
213
230
|
createHasNodesObservable(preprocessedNodesObservable, possiblyKnownChildrenObservable, props) {
|
|
214
231
|
const loggingCategory = `${LOGGING_NAMESPACE_INTERNAL}.HasNodes`;
|
|
215
|
-
return concat((possiblyKnownChildrenObservable ?? EMPTY).pipe(filter((n) => hasChildren(n))), preprocessedNodesObservable).pipe(
|
|
232
|
+
return concat((possiblyKnownChildrenObservable ?? EMPTY).pipe(filter((n) => hasChildren(n))), preprocessedNodesObservable).pipe(
|
|
233
|
+
/* v8 ignore next -- @preserve */
|
|
234
|
+
log({
|
|
216
235
|
category: loggingCategory,
|
|
217
|
-
message:
|
|
236
|
+
message: (n) => `[${props.requestContext.requestId}] Node before mapping to 'true': ${createNodeIdentifierForLogging(n)}`,
|
|
218
237
|
}), take(1), map(() => true), defaultIfEmpty(false), catchError((e) => {
|
|
238
|
+
/* v8 ignore next -- @preserve */
|
|
219
239
|
doLog({
|
|
220
240
|
category: loggingCategory,
|
|
221
|
-
message:
|
|
241
|
+
message: () => `[${props.requestContext.requestId}] Error while determining children: ${e.message}`,
|
|
222
242
|
});
|
|
223
243
|
if (e instanceof RowsLimitExceededError) {
|
|
224
244
|
return of(true);
|
|
225
245
|
}
|
|
226
246
|
throw e;
|
|
227
|
-
}),
|
|
247
|
+
}),
|
|
248
|
+
/* v8 ignore next -- @preserve */
|
|
249
|
+
log({ category: loggingCategory, message: (r) => `[${props.requestContext.requestId}] Result: ${r}` }));
|
|
228
250
|
}
|
|
229
251
|
getCachedObservableEntry(props) {
|
|
230
252
|
const loggingCategory = `${LOGGING_NAMESPACE}.QueryResultsCache`;
|
|
231
253
|
const { parentNode, ...restProps } = props;
|
|
232
254
|
const cached = props.ignoreCache || !this._nodesCache ? undefined : this._nodesCache.get(props);
|
|
233
255
|
if (cached) {
|
|
256
|
+
/* v8 ignore next -- @preserve */
|
|
234
257
|
doLog({
|
|
235
258
|
category: loggingCategory,
|
|
236
|
-
message:
|
|
259
|
+
message: () => `[${props.requestContext.requestId}] Found query nodes observable for ${createNodeIdentifierForLogging(parentNode)}`,
|
|
237
260
|
});
|
|
238
261
|
return cached;
|
|
239
262
|
}
|
|
@@ -259,9 +282,10 @@ class IModelHierarchyProviderImpl {
|
|
|
259
282
|
};
|
|
260
283
|
const value = { observable: this.createSourceNodesObservable(nonGroupingNodeChildrenRequestProps), processingStatus: "none" };
|
|
261
284
|
this._nodesCache?.set(nonGroupingNodeChildrenRequestProps, value);
|
|
285
|
+
/* v8 ignore next -- @preserve */
|
|
262
286
|
doLog({
|
|
263
287
|
category: loggingCategory,
|
|
264
|
-
message:
|
|
288
|
+
message: () => `[${props.requestContext.requestId}] Saved query nodes observable for ${createNodeIdentifierForLogging(parentNode)}`,
|
|
265
289
|
});
|
|
266
290
|
return value;
|
|
267
291
|
}
|
|
@@ -296,18 +320,19 @@ class IModelHierarchyProviderImpl {
|
|
|
296
320
|
const timer = new StopWatch(undefined, true);
|
|
297
321
|
let error;
|
|
298
322
|
let nodesCount = 0;
|
|
323
|
+
/* v8 ignore next -- @preserve */
|
|
299
324
|
doLog({
|
|
300
325
|
category: loggingCategory,
|
|
301
|
-
message:
|
|
326
|
+
message: () => `[${requestContext.requestId}] Requesting child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,
|
|
302
327
|
});
|
|
303
328
|
return eachValueFrom(this.getChildNodesObservables({ ...props, requestContext }).finalizedNodes.pipe(tap(() => ++nodesCount), catchError((e) => {
|
|
304
329
|
error = e;
|
|
305
330
|
throw e;
|
|
306
331
|
}), finalize(() => {
|
|
332
|
+
/* v8 ignore next -- @preserve */
|
|
307
333
|
doLog({
|
|
308
334
|
category: loggingCategory,
|
|
309
|
-
message:
|
|
310
|
-
/* c8 ignore next 3 */ error
|
|
335
|
+
message: () => error
|
|
311
336
|
? `[${requestContext.requestId}] Error creating child nodes for ${createNodeIdentifierForLogging(props.parentNode)}: ${error instanceof Error ? error.message : error.toString()}`
|
|
312
337
|
: `[${requestContext.requestId}] Returned ${nodesCount} child nodes for ${createNodeIdentifierForLogging(props.parentNode)} in ${timer.currentSeconds.toFixed(2)} s.`,
|
|
313
338
|
});
|
|
@@ -379,9 +404,10 @@ class IModelHierarchyProviderImpl {
|
|
|
379
404
|
const requestContext = { requestId: Guid.createValue() };
|
|
380
405
|
const loggingCategory = `${LOGGING_NAMESPACE}.GetNodeInstanceKeys`;
|
|
381
406
|
const timer = new StopWatch(undefined, true);
|
|
407
|
+
/* v8 ignore next -- @preserve */
|
|
382
408
|
doLog({
|
|
383
409
|
category: loggingCategory,
|
|
384
|
-
message:
|
|
410
|
+
message: () => `[${requestContext.requestId}] Requesting keys for ${createNodeIdentifierForLogging(props.parentNode)}`,
|
|
385
411
|
});
|
|
386
412
|
let error;
|
|
387
413
|
let keysCount = 0;
|
|
@@ -389,10 +415,10 @@ class IModelHierarchyProviderImpl {
|
|
|
389
415
|
error = e;
|
|
390
416
|
throw e;
|
|
391
417
|
}), finalize(() => {
|
|
418
|
+
/* v8 ignore next -- @preserve */
|
|
392
419
|
doLog({
|
|
393
420
|
category: loggingCategory,
|
|
394
|
-
message:
|
|
395
|
-
/* c8 ignore next 3 */ error
|
|
421
|
+
message: () => error
|
|
396
422
|
? `[${requestContext.requestId}] Error creating node instance keys for ${createNodeIdentifierForLogging(props.parentNode)}: ${error instanceof Error ? error.message : error.toString()}`
|
|
397
423
|
: `[${requestContext.requestId}] Returned ${keysCount} instance keys for ${createNodeIdentifierForLogging(props.parentNode)} in ${timer.currentSeconds.toFixed(2)} s.`,
|
|
398
424
|
});
|
|
@@ -428,6 +454,8 @@ function filterQueryByInstanceKeys(query, filteredInstanceKeys) {
|
|
|
428
454
|
return query;
|
|
429
455
|
}
|
|
430
456
|
const MAX_ALLOWED_BINDINGS = 1000;
|
|
457
|
+
// TODO: MISSING_COVERAGE
|
|
458
|
+
/* v8 ignore else -- @preserve */
|
|
431
459
|
if (filteredInstanceKeys.length < MAX_ALLOWED_BINDINGS) {
|
|
432
460
|
return {
|
|
433
461
|
...query,
|
|
@@ -439,7 +467,7 @@ function filterQueryByInstanceKeys(query, filteredInstanceKeys) {
|
|
|
439
467
|
bindings: [...(query.bindings ?? []), ...filteredInstanceKeys.map((k) => ({ type: "id", value: k.id }))],
|
|
440
468
|
};
|
|
441
469
|
}
|
|
442
|
-
/*
|
|
470
|
+
/* v8 ignore start */
|
|
443
471
|
return {
|
|
444
472
|
...query,
|
|
445
473
|
ecsql: `
|
|
@@ -449,6 +477,6 @@ function filterQueryByInstanceKeys(query, filteredInstanceKeys) {
|
|
|
449
477
|
`,
|
|
450
478
|
bindings: [...(query.bindings ?? []), { type: "idset", value: filteredInstanceKeys.map((k) => k.id) }],
|
|
451
479
|
};
|
|
452
|
-
/*
|
|
480
|
+
/* v8 ignore stop */
|
|
453
481
|
}
|
|
454
482
|
//# sourceMappingURL=IModelHierarchyProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelHierarchyProvider.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,gCAAgC,CAAC;AAExC,OAAO,EACL,UAAU,EACV,MAAM,EACN,cAAc,EACd,KAAK,EACL,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,GAAG,EACH,KAAK,EACL,QAAQ,EACR,QAAQ,EAGR,EAAE,EACF,OAAO,EACP,IAAI,EACJ,SAAS,EACT,GAAG,GACJ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAc,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAEL,2BAA2B,EAO3B,uBAAuB,EAGvB,sBAAsB,GACvB,MAAM,4B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,EAAgB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;SACvH,CAAC;IACJ,CAAC;IACD,qBAAqB;IACrB,OAAO;QACL,GAAG,KAAK;QACR,KAAK,EAAE;;cAEG,KAAK,CAAC,KAAK;;KAEpB;QACD,QAAQ,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;KACvG,CAAC;IACF,mBAAmB;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 \"../internal/DisposePolyfill.js\";\n\nimport {\n catchError,\n concat,\n defaultIfEmpty,\n EMPTY,\n filter,\n finalize,\n from,\n identity,\n map,\n merge,\n mergeAll,\n mergeMap,\n Observable,\n ObservableInput,\n of,\n Subject,\n take,\n takeUntil,\n tap,\n} from \"rxjs\";\nimport { assert, BeEvent, Guid, GuidString, StopWatch } from \"@itwin/core-bentley\";\nimport {\n ConcatenatedValue,\n createDefaultValueFormatter,\n ECClassHierarchyInspector,\n ECSchemaProvider,\n ECSqlBinding,\n ECSqlQueryDef,\n Event,\n EventArgs,\n formatConcatenatedValue,\n InstanceKey,\n IPrimitiveValueFormatter,\n normalizeFullClassName,\n} from \"@itwin/presentation-shared\";\nimport { RowsLimitExceededError } from \"../HierarchyErrors.js\";\nimport { HierarchyFilteringPath } from \"../HierarchyFiltering.js\";\nimport { HierarchyNode, NonGroupingHierarchyNode, ParentHierarchyNode } from \"../HierarchyNode.js\";\nimport { GenericNodeKey, HierarchyNodeKey, IModelInstanceKey, InstancesNodeKey } from \"../HierarchyNodeKey.js\";\nimport { GetHierarchyNodesProps, HierarchyProvider } from \"../HierarchyProvider.js\";\nimport {\n LOGGING_NAMESPACE as BASE_LOGGING_NAMESPACE,\n LOGGING_NAMESPACE_INTERNAL as BASE_LOGGING_NAMESPACE_INTERNAL,\n LOGGING_NAMESPACE_PERFORMANCE as BASE_LOGGING_NAMESPACE_PERFORMANCE,\n createNodeIdentifierForLogging,\n hasChildren,\n} from \"../internal/Common.js\";\nimport { eachValueFrom } from \"../internal/EachValueFrom.js\";\nimport { doLog, log } from \"../internal/LoggingUtils.js\";\nimport { partition } from \"../internal/operators/Partition.js\";\nimport { reduceToMergeMapList } from \"../internal/operators/ReduceToMergeMap.js\";\nimport { shareReplayWithErrors } from \"../internal/operators/ShareReplayWithErrors.js\";\nimport { sortNodesByLabelOperator } from \"../internal/operators/Sorting.js\";\nimport { getRxjsHierarchyDefinition, RxjsHierarchyDefinition } from \"../internal/RxjsHierarchyDefinition.js\";\nimport { SubscriptionScheduler } from \"../internal/SubscriptionScheduler.js\";\nimport { FilteringHierarchyDefinition } from \"./FilteringHierarchyDefinition.js\";\nimport { HierarchyCache } from \"./HierarchyCache.js\";\nimport { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyNodesDefinition } from \"./IModelHierarchyDefinition.js\";\nimport { ProcessedGroupingHierarchyNode, ProcessedHierarchyNode, SourceGenericHierarchyNode, SourceInstanceHierarchyNode } from \"./IModelHierarchyNode.js\";\nimport { LimitingECSqlQueryExecutor } from \"./LimitingECSqlQueryExecutor.js\";\nimport { NodeSelectClauseColumnNames } from \"./NodeSelectQueryFactory.js\";\nimport { createDetermineChildrenOperator } from \"./operators/DetermineChildren.js\";\nimport { createGroupingOperator } from \"./operators/Grouping.js\";\nimport { createHideIfNoChildrenOperator } from \"./operators/HideIfNoChildren.js\";\nimport { createHideNodesInHierarchyOperator } from \"./operators/HideNodesInHierarchy.js\";\nimport { readNodes } from \"./TreeNodesReader.js\";\n\nconst LOGGING_NAMESPACE = `${BASE_LOGGING_NAMESPACE}.IModelHierarchyProvider`;\nconst LOGGING_NAMESPACE_INTERNAL = `${BASE_LOGGING_NAMESPACE_INTERNAL}.IModelHierarchyProvider`;\nconst LOGGING_NAMESPACE_PERFORMANCE = `${BASE_LOGGING_NAMESPACE_PERFORMANCE}.IModelHierarchyProvider`;\n\nconst DEFAULT_QUERY_CONCURRENCY = 10;\nconst DEFAULT_QUERY_CACHE_SIZE = 1;\n\n/**\n * Defines the strings used by hierarchy provider.\n * @public\n */\ninterface IModelHierarchyProviderLocalizedStrings {\n /**\n * A string for \"Unspecified\". Used for labels of property grouping nodes\n * that group by an empty value.\n */\n unspecified: string;\n\n /**\n * A string for \"Other\". Used for label of a range property grouping node that\n * groups values which don't fit into any other range.\n */\n other: string;\n}\n\n/** @public */\ntype IModelAccess = ECSchemaProvider & LimitingECSqlQueryExecutor & ECClassHierarchyInspector & { imodelKey: string };\n\n/**\n * Props for `createIModelHierarchyProvider`.\n * @public\n */\ninterface IModelHierarchyProviderProps {\n /**\n * An object that provides access to iModel's data and metadata.\n *\n * @see `ECSchemaProvider`\n * @see `LimitingECSqlQueryExecutor`\n * @see `ECClassHierarchyInspector`\n */\n imodelAccess: IModelAccess;\n\n /** An event that is raised when iModel data, that may affect the hierarchy, changes. */\n imodelChanged?: Event<() => void>;\n\n /**\n * A function that returns a hierarchy definition, describing how the hierarchy that the provider should be create. The\n * function is called once during the provider's construction.\n */\n hierarchyDefinition: HierarchyDefinition;\n\n /** Maximum number of queries that the provider attempts to execute in parallel. Defaults to `10`. */\n queryConcurrency?: number;\n /**\n * The amount of queries whose results are stored in-memory for quick retrieval. Defaults to `1`,\n * which means only results of the last run query are cached.\n */\n queryCacheSize?: number;\n\n /** A set of localized strings to use. Defaults to English strings. */\n localizedStrings?: Partial<IModelHierarchyProviderLocalizedStrings>;\n\n /**\n * A values formatter for formatting node labels. Defaults to the\n * result of `createDefaultValueFormatter` called with default parameters. May be overridden\n * by calling `setFormatter` on the provider instance.\n */\n formatter?: IPrimitiveValueFormatter;\n /** Props for filtering the hierarchy. */\n filtering?: {\n /** A list of node identifiers from root to target node. */\n paths: HierarchyFilteringPath[];\n };\n}\n\n/**\n * Creates an instance of `HierarchyProvider` that creates a hierarchy based on given iModel and\n * a hierarchy definition, which defines each hierarchy level through ECSQL queries.\n *\n * @public\n */\nexport function createIModelHierarchyProvider(props: IModelHierarchyProviderProps): HierarchyProvider & {\n /** @deprecated in 1.4. Use `[Symbol.dispose]` instead. */\n dispose: () => void;\n [Symbol.dispose]: () => void;\n} {\n return new IModelHierarchyProviderImpl(props);\n}\n\ninterface RequestContextProp {\n requestContext: {\n requestId: string;\n };\n}\n\nclass IModelHierarchyProviderImpl implements HierarchyProvider {\n private _imodelAccess: IModelAccess;\n private _hierarchyChanged: BeEvent<(args?: EventArgs<HierarchyProvider[\"hierarchyChanged\"]>) => void>;\n private _valuesFormatter: IPrimitiveValueFormatter;\n private _sourceHierarchyDefinition: RxjsHierarchyDefinition;\n private _activeHierarchyDefinition: RxjsHierarchyDefinition;\n private _localizedStrings: IModelHierarchyProviderLocalizedStrings;\n private _queryScheduler: SubscriptionScheduler;\n private _nodesCache?: HierarchyCache<HierarchyCacheEntry>;\n private _unsubscribe?: () => void;\n private _dispose = new Subject<void>();\n #componentId: GuidString;\n #componentName: string;\n\n public constructor(props: IModelHierarchyProviderProps) {\n this.#componentId = Guid.createValue();\n this.#componentName = \"IModelHierarchyProviderImpl\";\n this._imodelAccess = props.imodelAccess;\n this._hierarchyChanged = new BeEvent();\n this._activeHierarchyDefinition = this._sourceHierarchyDefinition = getRxjsHierarchyDefinition(props.hierarchyDefinition);\n this._valuesFormatter = props?.formatter ?? createDefaultValueFormatter();\n this._localizedStrings = { other: \"Other\", unspecified: \"Not specified\", ...props?.localizedStrings };\n this._queryScheduler = new SubscriptionScheduler(props.queryConcurrency ?? DEFAULT_QUERY_CONCURRENCY);\n this.setHierarchyFilter(props.filtering);\n\n const queryCacheSize = props.queryCacheSize ?? DEFAULT_QUERY_CACHE_SIZE;\n if (queryCacheSize !== 0) {\n this._nodesCache = new HierarchyCache({\n // we divide the size by 2, because each variation also counts as a query that we cache\n size: Math.ceil(queryCacheSize / 2),\n variationsCount: 1,\n });\n }\n\n this._unsubscribe = props.imodelChanged?.addListener(() => {\n this.invalidateHierarchyCache(\"Data source changed\");\n this._dispose.next();\n this._hierarchyChanged.raiseEvent();\n });\n }\n\n public [Symbol.dispose]() {\n this._dispose.next();\n this._unsubscribe?.();\n }\n\n /* c8 ignore next 3 */\n public dispose() {\n this[Symbol.dispose]();\n }\n\n public get hierarchyChanged() {\n return this._hierarchyChanged;\n }\n\n private invalidateHierarchyCache(reason?: string) {\n doLog({\n category: `${LOGGING_NAMESPACE}.Events`,\n message: /* c8 ignore next */ () => (reason ? `${reason}: clear hierarchy cache` : `Clear hierarchy cache`),\n });\n this._nodesCache?.clear();\n }\n\n /**\n * Sets `HierarchyProvider` values formatter that formats nodes' labels. If provided `undefined`, then defaults to the\n * result of `createDefaultValueFormatter` called with default parameters.\n */\n public setFormatter(formatter: IPrimitiveValueFormatter | undefined) {\n this._valuesFormatter = formatter ?? createDefaultValueFormatter();\n this._hierarchyChanged.raiseEvent({ formatterChange: { newFormatter: this._valuesFormatter } });\n }\n\n public setHierarchyFilter(props: IModelHierarchyProviderProps[\"filtering\"]) {\n if (!props) {\n if (this._sourceHierarchyDefinition !== this._activeHierarchyDefinition) {\n this._activeHierarchyDefinition = this._sourceHierarchyDefinition;\n this.invalidateHierarchyCache(\"Hierarchy filter reset\");\n }\n this._hierarchyChanged.raiseEvent({ filterChange: { newFilter: undefined } });\n return;\n }\n this._activeHierarchyDefinition = new FilteringHierarchyDefinition({\n imodelAccess: this._imodelAccess,\n source: this._sourceHierarchyDefinition,\n nodeIdentifierPaths: props.paths,\n });\n this.invalidateHierarchyCache(\"Hierarchy filter set\");\n this._dispose.next();\n this._hierarchyChanged.raiseEvent({ filterChange: { newFilter: props } });\n }\n\n private onGroupingNodeCreated(groupingNode: ProcessedGroupingHierarchyNode, props: GetHierarchyNodesProps) {\n this._nodesCache?.set({ ...props, parentNode: groupingNode }, { observable: from(groupingNode.children), processingStatus: \"pre-processed\" });\n }\n\n private createHierarchyLevelDefinitionsObservable(props: DefineHierarchyLevelProps & RequestContextProp): Observable<HierarchyNodesDefinition> {\n const { requestContext, ...defineHierarchyLevelProps } = props;\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* c8 ignore next */ () =>\n `[${requestContext.requestId}] Requesting hierarchy level definitions for ${createNodeIdentifierForLogging(props.parentNode)}`,\n });\n let parentNode = props.parentNode;\n if (parentNode && HierarchyNode.isGeneric(parentNode) && parentNode.key.source && parentNode.key.source !== this._imodelAccess.imodelKey) {\n return EMPTY;\n }\n if (parentNode && HierarchyNode.isInstancesNode(parentNode)) {\n parentNode = {\n ...parentNode,\n key: {\n ...parentNode.key,\n instanceKeys: parentNode.key.instanceKeys.filter((ik) => !ik.imodelKey || ik.imodelKey === this._imodelAccess.imodelKey),\n },\n };\n assert(HierarchyNodeKey.isInstances(parentNode.key));\n if (parentNode.key.instanceKeys.length === 0) {\n return EMPTY;\n }\n }\n return this._activeHierarchyDefinition.defineHierarchyLevel({ ...defineHierarchyLevelProps, parentNode }).pipe(\n mergeAll(),\n finalize(() =>\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* c8 ignore next */ () =>\n `[${requestContext.requestId}] Received all hierarchy level definitions for ${createNodeIdentifierForLogging(props.parentNode)}`,\n }),\n ),\n );\n }\n\n private createSourceNodesObservable(\n props: DefineHierarchyLevelProps & { hierarchyLevelSizeLimit?: number | \"unbounded\"; filteredInstanceKeys?: InstanceKey[] } & RequestContextProp,\n ): SourceNodesObservable {\n // pipe definitions to nodes and put \"share replay\" on it\n return this.createHierarchyLevelDefinitionsObservable(props).pipe(\n mergeMap((def): ObservableInput<SourceHierarchyNode> => {\n if (HierarchyNodesDefinition.isGenericNode(def)) {\n return of({ ...def.node, key: { type: \"generic\", id: def.node.key, source: this._imodelAccess.imodelKey } });\n }\n return this._queryScheduler.scheduleSubscription(\n of(def.query).pipe(\n map((query) => filterQueryByInstanceKeys(query, props.filteredInstanceKeys)),\n mergeMap((query) =>\n readNodes({\n queryExecutor: this._imodelAccess,\n query,\n limit: props.hierarchyLevelSizeLimit,\n parser: this._activeHierarchyDefinition.parseNode ? (row) => this._activeHierarchyDefinition.parseNode!(row, props.parentNode) : undefined,\n }),\n ),\n map((node) => ({\n ...node,\n key: { ...node.key, instanceKeys: node.key.instanceKeys.map((key) => ({ ...key, imodelKey: this._imodelAccess.imodelKey })) },\n })),\n ),\n );\n }),\n finalize(() =>\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* c8 ignore next */ () => `[${props.requestContext.requestId}] Read all child nodes ${createNodeIdentifierForLogging(props.parentNode)}`,\n }),\n ),\n shareReplayWithErrors(),\n );\n }\n\n private createPreProcessedNodesObservable(\n queryNodesObservable: SourceNodesObservable,\n props: GetHierarchyNodesProps & RequestContextProp,\n ): Observable<ProcessedHierarchyNode> {\n return queryNodesObservable.pipe(\n // we're going to be mutating the nodes, but don't want to mutate the original one, so just clone it here once\n map((node) => ({ ...node })),\n // set parent node keys on the source node\n map((node) => Object.assign(node, { parentKeys: createParentNodeKeysList(props.parentNode) })),\n // format `ConcatenatedValue` labels into string labels\n mergeMap((node) => applyLabelsFormatting(node, this._valuesFormatter)),\n // we have `ProcessedHierarchyNode` from here\n preProcessNodes(this._activeHierarchyDefinition),\n // process hiding\n createHideIfNoChildrenOperator((n) => this.getChildNodesObservables({ parentNode: n, requestContext: props.requestContext }).hasNodes),\n createHideNodesInHierarchyOperator(\n // note: for child nodes created because of hidden parent, we want to use parent's request props (instance filter, limit)\n (n) => this.getChildNodesObservables({ ...props, parentNode: n }).processedNodes,\n false,\n ),\n finalize(() =>\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* c8 ignore next */ () =>\n `[${props.requestContext.requestId}] Finished pre-processing child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,\n }),\n ),\n );\n }\n\n private createProcessedNodesObservable(\n preprocessedNodesObservable: Observable<ProcessedHierarchyNode>,\n props: GetHierarchyNodesProps & RequestContextProp,\n ): Observable<ProcessedHierarchyNode> {\n return preprocessedNodesObservable.pipe(\n createGroupingOperator(this._imodelAccess, props.parentNode, this._valuesFormatter, this._localizedStrings, undefined, (gn) =>\n this.onGroupingNodeCreated(gn, props),\n ),\n finalize(() =>\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* c8 ignore next */ () =>\n `[${props.requestContext.requestId}] Finished grouping child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,\n }),\n ),\n );\n }\n\n private createFinalizedNodesObservable(\n processedNodesObservable: Observable<ProcessedHierarchyNode>,\n props: GetHierarchyNodesProps & RequestContextProp,\n ): Observable<HierarchyNode> {\n return processedNodesObservable.pipe(\n createDetermineChildrenOperator((n) => this.getChildNodesObservables({ parentNode: n, requestContext: props.requestContext }).hasNodes),\n postProcessNodes(this._activeHierarchyDefinition),\n sortNodesByLabelOperator,\n map((n): HierarchyNode => {\n if (\"processingParams\" in n) {\n delete n.processingParams;\n }\n return Object.assign(n, {\n children: hasChildren(n),\n });\n }),\n takeUntil(this._dispose),\n finalize(() =>\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* c8 ignore next */ () =>\n `[${props.requestContext.requestId}] Finished finalizing child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,\n }),\n ),\n );\n }\n\n private createHasNodesObservable(\n preprocessedNodesObservable: Observable<ProcessedHierarchyNode>,\n possiblyKnownChildrenObservable: SourceNodesObservable | undefined,\n props: RequestContextProp,\n ): Observable<boolean> {\n const loggingCategory = `${LOGGING_NAMESPACE_INTERNAL}.HasNodes`;\n return concat((possiblyKnownChildrenObservable ?? EMPTY).pipe(filter((n) => hasChildren(n))), preprocessedNodesObservable).pipe(\n log({\n category: loggingCategory,\n message: /* c8 ignore next */ (n) => `[${props.requestContext.requestId}] Node before mapping to 'true': ${createNodeIdentifierForLogging(n)}`,\n }),\n take(1),\n map(() => true),\n defaultIfEmpty(false),\n catchError((e: Error) => {\n doLog({\n category: loggingCategory,\n message: /* c8 ignore next */ () => `[${props.requestContext.requestId}] Error while determining children: ${e.message}`,\n });\n if (e instanceof RowsLimitExceededError) {\n return of(true);\n }\n throw e;\n }),\n log({ category: loggingCategory, message: /* c8 ignore next */ (r) => `[${props.requestContext.requestId}] Result: ${r}` }),\n );\n }\n\n private getCachedObservableEntry(props: GetHierarchyNodesProps & RequestContextProp): HierarchyCacheEntry {\n const loggingCategory = `${LOGGING_NAMESPACE}.QueryResultsCache`;\n const { parentNode, ...restProps } = props;\n const cached = props.ignoreCache || !this._nodesCache ? undefined : this._nodesCache.get(props);\n if (cached) {\n doLog({\n category: loggingCategory,\n message: /* c8 ignore next */ () =>\n `[${props.requestContext.requestId}] Found query nodes observable for ${createNodeIdentifierForLogging(parentNode)}`,\n });\n return cached;\n }\n\n // if we don't find an entry for a grouping node, we load its instances by getting a query and applying\n // a filter based on grouped instance keys\n let filteredInstanceKeys: InstanceKey[] | undefined;\n let parentNonGroupingNode: ParentHierarchyNode<NonGroupingHierarchyNode> | undefined;\n if (parentNode) {\n if (HierarchyNode.isGroupingNode(parentNode)) {\n parentNonGroupingNode = parentNode.nonGroupingAncestor;\n filteredInstanceKeys = parentNode.groupedInstanceKeys;\n } else {\n // not sure why type checker doesn't pick this up\n assert(HierarchyNode.isGeneric(parentNode) || HierarchyNode.isInstancesNode(parentNode));\n parentNonGroupingNode = parentNode;\n }\n }\n\n const nonGroupingNodeChildrenRequestProps = {\n ...restProps,\n parentNode: parentNonGroupingNode,\n ...(filteredInstanceKeys ? { filteredInstanceKeys } : undefined),\n };\n const value = { observable: this.createSourceNodesObservable(nonGroupingNodeChildrenRequestProps), processingStatus: \"none\" as const };\n this._nodesCache?.set(nonGroupingNodeChildrenRequestProps, value);\n doLog({\n category: loggingCategory,\n message: /* c8 ignore next */ () => `[${props.requestContext.requestId}] Saved query nodes observable for ${createNodeIdentifierForLogging(parentNode)}`,\n });\n return value;\n }\n\n private getChildNodesObservables(props: GetHierarchyNodesProps & { hierarchyLevelSizeLimit?: number | \"unbounded\" } & RequestContextProp) {\n const entry = this.getCachedObservableEntry(props);\n switch (entry.processingStatus) {\n case \"none\": {\n const pre = this.createPreProcessedNodesObservable(entry.observable, props);\n const post = this.createProcessedNodesObservable(pre, props);\n return {\n processedNodes: post,\n hasNodes: this.createHasNodesObservable(pre, entry.observable, props),\n finalizedNodes: this.createFinalizedNodesObservable(post, props),\n };\n }\n case \"pre-processed\": {\n const post = this.createProcessedNodesObservable(entry.observable, props);\n return {\n processedNodes: post,\n hasNodes: this.createHasNodesObservable(entry.observable, undefined, props),\n finalizedNodes: this.createFinalizedNodesObservable(post, props),\n };\n }\n }\n }\n\n /**\n * Creates and runs a query based on provided props, then processes retrieved nodes and returns them.\n */\n public getNodes(props: GetHierarchyNodesProps): AsyncIterableIterator<HierarchyNode> {\n const requestContext = { requestId: Guid.createValue() };\n const loggingCategory = `${LOGGING_NAMESPACE}.GetNodes`;\n const timer = new StopWatch(undefined, true);\n let error: any;\n let nodesCount = 0;\n doLog({\n category: loggingCategory,\n message: /* c8 ignore next */ () => `[${requestContext.requestId}] Requesting child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,\n });\n return eachValueFrom(\n this.getChildNodesObservables({ ...props, requestContext }).finalizedNodes.pipe(\n tap(() => ++nodesCount),\n catchError((e) => {\n error = e;\n throw e;\n }),\n finalize(() => {\n doLog({\n category: loggingCategory,\n message: /* c8 ignore next */ () =>\n /* c8 ignore next 3 */ error\n ? `[${requestContext.requestId}] Error creating child nodes for ${createNodeIdentifierForLogging(props.parentNode)}: ${error instanceof Error ? error.message : error.toString()}`\n : `[${requestContext.requestId}] Returned ${nodesCount} child nodes for ${createNodeIdentifierForLogging(props.parentNode)} in ${timer.currentSeconds.toFixed(2)} s.`,\n });\n }),\n ),\n );\n }\n\n private getNodeInstanceKeysObs(props: Omit<GetHierarchyNodesProps, \"ignoreCache\"> & RequestContextProp): Observable<InstanceKey> {\n const { parentNode, instanceFilter, hierarchyLevelSizeLimit = \"unbounded\", requestContext } = props;\n if (parentNode && HierarchyNode.isGroupingNode(parentNode)) {\n return from(parentNode.groupedInstanceKeys);\n }\n assert(!parentNode || HierarchyNode.isGeneric(parentNode) || HierarchyNode.isInstancesNode(parentNode));\n\n const hierarchyLevelDefinitions = this.createHierarchyLevelDefinitionsObservable({ parentNode, instanceFilter, requestContext });\n\n // split the definitions based on whether they're for generic nodes or for instance nodes\n const [genericDefs, instanceDefs] = partition(hierarchyLevelDefinitions, HierarchyNodesDefinition.isGenericNode);\n\n // query instance keys and a flag whether they should be hidden\n const instanceKeys = instanceDefs.pipe(\n mergeMap((def) =>\n this._queryScheduler.scheduleSubscription(\n of(def.query).pipe(\n mergeMap(async (query) => {\n const ecsql = `\n SELECT\n ${NodeSelectClauseColumnNames.FullClassName},\n ${NodeSelectClauseColumnNames.ECInstanceId},\n ${NodeSelectClauseColumnNames.HideNodeInHierarchy}\n FROM (\n ${query.ecsql}\n )\n `;\n const reader = this._imodelAccess.createQueryReader(\n { ...query, ecsql },\n {\n rowFormat: \"Indexes\",\n limit: hierarchyLevelSizeLimit,\n restartToken: `${this.#componentName}/${this.#componentId}/node-instance-keys/${Guid.createValue()}`,\n },\n );\n return from(reader).pipe(\n map((row) => ({\n key: {\n className: normalizeFullClassName(row[0]),\n id: row[1],\n imodelKey: this._imodelAccess.imodelKey,\n } satisfies IModelInstanceKey,\n hide: !!row[2],\n })),\n );\n }),\n mergeAll(),\n ),\n ),\n ),\n );\n // split the instance keys observable based on whether they should be hidden or not\n const [visibleNodeInstanceKeys, hiddenNodeInstanceKeys] = partition(instanceKeys, ({ hide }) => !hide);\n\n // hidden items' handling:\n // - if a generic node is hidden, we'll want to retrieve instance keys of its children, otherwise we don't care about it,\n // - if an instance key is hidden, we want to create a merged node similar to what we do in `createHideNodesInHierarchyOperator`\n const hiddenParentNodes = merge(\n genericDefs.pipe(\n filter((def) => !!def.node.processingParams?.hideInHierarchy),\n map(\n (def): GenericNodeKey => ({\n type: \"generic\",\n id: def.node.key,\n source: this._imodelAccess.imodelKey,\n }),\n ),\n ),\n hiddenNodeInstanceKeys.pipe(\n // first merge all keys by class\n reduceToMergeMapList(\n ({ key }) => key.className,\n ({ key }) => key.id,\n ),\n // then, for each class, create an instance key\n mergeMap((mergedMap): InstancesNodeKey[] =>\n [...mergedMap.entries()].map(([className, ids]) => ({\n type: \"instances\",\n instanceKeys: ids.map((id) => ({ className, id, imodelKey: this._imodelAccess.imodelKey })),\n })),\n ),\n ),\n ).pipe(\n map((key) => ({\n key,\n parentKeys: [],\n label: \"\",\n })),\n );\n\n // merge visible instance keys from this level & the ones we get recursively requesting from deeper levels\n return merge(\n visibleNodeInstanceKeys.pipe(map(({ key }) => key)),\n hiddenParentNodes.pipe(mergeMap((hiddenNode) => this.getNodeInstanceKeysObs({ parentNode: hiddenNode, requestContext }))),\n ).pipe(takeUntil(this._dispose));\n }\n\n /**\n * Creates an iterator for all child hierarchy level instance keys, taking into account any hidden hierarchy levels\n * that there may be under the given parent node.\n */\n public getNodeInstanceKeys(props: Omit<GetHierarchyNodesProps, \"ignoreCache\">): AsyncIterableIterator<InstanceKey> {\n const requestContext = { requestId: Guid.createValue() };\n const loggingCategory = `${LOGGING_NAMESPACE}.GetNodeInstanceKeys`;\n const timer = new StopWatch(undefined, true);\n doLog({\n category: loggingCategory,\n message: /* c8 ignore next */ () => `[${requestContext.requestId}] Requesting keys for ${createNodeIdentifierForLogging(props.parentNode)}`,\n });\n let error: any;\n let keysCount = 0;\n return eachValueFrom(\n this.getNodeInstanceKeysObs({ ...props, requestContext }).pipe(\n tap(() => ++keysCount),\n catchError((e) => {\n error = e;\n throw e;\n }),\n finalize(() => {\n doLog({\n category: loggingCategory,\n message: /* c8 ignore next */ () =>\n /* c8 ignore next 3 */ error\n ? `[${requestContext.requestId}] Error creating node instance keys for ${createNodeIdentifierForLogging(props.parentNode)}: ${error instanceof Error ? error.message : error.toString()}`\n : `[${requestContext.requestId}] Returned ${keysCount} instance keys for ${createNodeIdentifierForLogging(props.parentNode)} in ${timer.currentSeconds.toFixed(2)} s.`,\n });\n }),\n ),\n );\n }\n}\n\ntype SourceHierarchyNode = SourceInstanceHierarchyNode | (Omit<SourceGenericHierarchyNode, \"key\"> & { key: GenericNodeKey });\ntype SourceNodesObservable = Observable<SourceHierarchyNode>;\ntype ProcessedNodesObservable = Observable<ProcessedHierarchyNode>;\ntype HierarchyCacheEntry =\n | { observable: SourceNodesObservable; processingStatus: \"none\" }\n | { observable: ProcessedNodesObservable; processingStatus: \"pre-processed\" };\n\nfunction preProcessNodes(hierarchyFactory: RxjsHierarchyDefinition) {\n return hierarchyFactory.preProcessNode ? processNodes(hierarchyFactory.preProcessNode) : identity;\n}\n\nfunction postProcessNodes(hierarchyFactory: RxjsHierarchyDefinition) {\n return hierarchyFactory.postProcessNode ? processNodes(hierarchyFactory.postProcessNode) : identity;\n}\n\nfunction processNodes<TNode>(processor: (node: TNode) => Observable<TNode>) {\n return (nodes: Observable<TNode>) => nodes.pipe(mergeMap(processor));\n}\n\nfunction applyLabelsFormatting<TNode extends { label: string | ConcatenatedValue }>(\n node: TNode,\n valueFormatter: IPrimitiveValueFormatter,\n): Observable<TNode & { label: string }> {\n return from(\n formatConcatenatedValue({\n value: node.label,\n valueFormatter,\n }),\n ).pipe(\n map((label) => ({\n ...node,\n label,\n })),\n );\n}\n\nfunction createParentNodeKeysList(parentNode: ParentHierarchyNode | undefined) {\n if (!parentNode) {\n return [];\n }\n return [...parentNode.parentKeys, parentNode.key];\n}\n\nfunction filterQueryByInstanceKeys(query: ECSqlQueryDef, filteredInstanceKeys: InstanceKey[] | undefined): ECSqlQueryDef {\n if (!filteredInstanceKeys || !filteredInstanceKeys.length) {\n return query;\n }\n const MAX_ALLOWED_BINDINGS = 1000;\n if (filteredInstanceKeys.length < MAX_ALLOWED_BINDINGS) {\n return {\n ...query,\n ecsql: `\n SELECT *\n FROM (${query.ecsql}) q\n WHERE q.ECInstanceId IN (${filteredInstanceKeys.map(() => \"?\").join(\",\")})\n `,\n bindings: [...(query.bindings ?? []), ...filteredInstanceKeys.map((k): ECSqlBinding => ({ type: \"id\", value: k.id }))],\n };\n }\n /* c8 ignore start */\n return {\n ...query,\n ecsql: `\n SELECT *\n FROM (${query.ecsql}) q\n WHERE InVirtualSet(?, q.ECInstanceId)\n `,\n bindings: [...(query.bindings ?? []), { type: \"idset\", value: filteredInstanceKeys.map((k) => k.id) }],\n };\n /* c8 ignore end */\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IModelHierarchyProvider.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,gCAAgC,CAAC;AAExC,OAAO,EACL,UAAU,EACV,MAAM,EACN,cAAc,EACd,KAAK,EACL,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,GAAG,EACH,KAAK,EACL,QAAQ,EACR,QAAQ,EAGR,EAAE,EACF,OAAO,EACP,IAAI,EACJ,SAAS,EACT,GAAG,GACJ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAc,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAEL,2BAA2B,EAO3B,uBAAuB,EAGvB,sBAAsB,GACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAiD,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAkB,gBAAgB,EAAuC,MAAM,wBAAwB,CAAC;AAE/G,OAAO,EACL,iBAAiB,IAAI,sBAAsB,EAC3C,0BAA0B,IAAI,+BAA+B,EAC7D,6BAA6B,I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,GAAG,KAAK;QACR,KAAK,EAAE;;cAEG,KAAK,CAAC,KAAK;;KAEpB;QACD,QAAQ,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;KACvG,CAAC;IACF,oBAAoB;AACtB,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 \"../internal/DisposePolyfill.js\";\n\nimport {\n catchError,\n concat,\n defaultIfEmpty,\n EMPTY,\n filter,\n finalize,\n from,\n identity,\n map,\n merge,\n mergeAll,\n mergeMap,\n Observable,\n ObservableInput,\n of,\n Subject,\n take,\n takeUntil,\n tap,\n} from \"rxjs\";\nimport { assert, BeEvent, Guid, GuidString, StopWatch } from \"@itwin/core-bentley\";\nimport {\n ConcatenatedValue,\n createDefaultValueFormatter,\n ECClassHierarchyInspector,\n ECSchemaProvider,\n ECSqlBinding,\n ECSqlQueryDef,\n Event,\n EventArgs,\n formatConcatenatedValue,\n InstanceKey,\n IPrimitiveValueFormatter,\n normalizeFullClassName,\n} from \"@itwin/presentation-shared\";\nimport { RowsLimitExceededError } from \"../HierarchyErrors.js\";\nimport { HierarchyFilteringPath } from \"../HierarchyFiltering.js\";\nimport { HierarchyNode, NonGroupingHierarchyNode, ParentHierarchyNode } from \"../HierarchyNode.js\";\nimport { GenericNodeKey, HierarchyNodeKey, IModelInstanceKey, InstancesNodeKey } from \"../HierarchyNodeKey.js\";\nimport { GetHierarchyNodesProps, HierarchyProvider } from \"../HierarchyProvider.js\";\nimport {\n LOGGING_NAMESPACE as BASE_LOGGING_NAMESPACE,\n LOGGING_NAMESPACE_INTERNAL as BASE_LOGGING_NAMESPACE_INTERNAL,\n LOGGING_NAMESPACE_PERFORMANCE as BASE_LOGGING_NAMESPACE_PERFORMANCE,\n createNodeIdentifierForLogging,\n hasChildren,\n} from \"../internal/Common.js\";\nimport { eachValueFrom } from \"../internal/EachValueFrom.js\";\nimport { doLog, log } from \"../internal/LoggingUtils.js\";\nimport { partition } from \"../internal/operators/Partition.js\";\nimport { reduceToMergeMapList } from \"../internal/operators/ReduceToMergeMap.js\";\nimport { shareReplayWithErrors } from \"../internal/operators/ShareReplayWithErrors.js\";\nimport { sortNodesByLabelOperator } from \"../internal/operators/Sorting.js\";\nimport { getRxjsHierarchyDefinition, RxjsHierarchyDefinition } from \"../internal/RxjsHierarchyDefinition.js\";\nimport { SubscriptionScheduler } from \"../internal/SubscriptionScheduler.js\";\nimport { FilteringHierarchyDefinition } from \"./FilteringHierarchyDefinition.js\";\nimport { HierarchyCache } from \"./HierarchyCache.js\";\nimport { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyNodesDefinition } from \"./IModelHierarchyDefinition.js\";\nimport { ProcessedGroupingHierarchyNode, ProcessedHierarchyNode, SourceGenericHierarchyNode, SourceInstanceHierarchyNode } from \"./IModelHierarchyNode.js\";\nimport { LimitingECSqlQueryExecutor } from \"./LimitingECSqlQueryExecutor.js\";\nimport { NodeSelectClauseColumnNames } from \"./NodeSelectQueryFactory.js\";\nimport { createDetermineChildrenOperator } from \"./operators/DetermineChildren.js\";\nimport { createGroupingOperator } from \"./operators/Grouping.js\";\nimport { createHideIfNoChildrenOperator } from \"./operators/HideIfNoChildren.js\";\nimport { createHideNodesInHierarchyOperator } from \"./operators/HideNodesInHierarchy.js\";\nimport { readNodes } from \"./TreeNodesReader.js\";\n\nconst LOGGING_NAMESPACE = `${BASE_LOGGING_NAMESPACE}.IModelHierarchyProvider`;\nconst LOGGING_NAMESPACE_INTERNAL = `${BASE_LOGGING_NAMESPACE_INTERNAL}.IModelHierarchyProvider`;\nconst LOGGING_NAMESPACE_PERFORMANCE = `${BASE_LOGGING_NAMESPACE_PERFORMANCE}.IModelHierarchyProvider`;\n\nconst DEFAULT_QUERY_CONCURRENCY = 10;\nconst DEFAULT_QUERY_CACHE_SIZE = 1;\n\n/**\n * Defines the strings used by hierarchy provider.\n * @public\n */\ninterface IModelHierarchyProviderLocalizedStrings {\n /**\n * A string for \"Unspecified\". Used for labels of property grouping nodes\n * that group by an empty value.\n */\n unspecified: string;\n\n /**\n * A string for \"Other\". Used for label of a range property grouping node that\n * groups values which don't fit into any other range.\n */\n other: string;\n}\n\n/** @public */\ntype IModelAccess = ECSchemaProvider & LimitingECSqlQueryExecutor & ECClassHierarchyInspector & { imodelKey: string };\n\n/**\n * Props for `createIModelHierarchyProvider`.\n * @public\n */\ninterface IModelHierarchyProviderProps {\n /**\n * An object that provides access to iModel's data and metadata.\n *\n * @see `ECSchemaProvider`\n * @see `LimitingECSqlQueryExecutor`\n * @see `ECClassHierarchyInspector`\n */\n imodelAccess: IModelAccess;\n\n /** An event that is raised when iModel data, that may affect the hierarchy, changes. */\n imodelChanged?: Event<() => void>;\n\n /**\n * A function that returns a hierarchy definition, describing how the hierarchy that the provider should be create. The\n * function is called once during the provider's construction.\n */\n hierarchyDefinition: HierarchyDefinition;\n\n /** Maximum number of queries that the provider attempts to execute in parallel. Defaults to `10`. */\n queryConcurrency?: number;\n /**\n * The amount of queries whose results are stored in-memory for quick retrieval. Defaults to `1`,\n * which means only results of the last run query are cached.\n */\n queryCacheSize?: number;\n\n /** A set of localized strings to use. Defaults to English strings. */\n localizedStrings?: Partial<IModelHierarchyProviderLocalizedStrings>;\n\n /**\n * A values formatter for formatting node labels. Defaults to the\n * result of `createDefaultValueFormatter` called with default parameters. May be overridden\n * by calling `setFormatter` on the provider instance.\n */\n formatter?: IPrimitiveValueFormatter;\n /** Props for filtering the hierarchy. */\n filtering?: {\n /** A list of node identifiers from root to target node. */\n paths: HierarchyFilteringPath[];\n };\n}\n\n/**\n * Creates an instance of `HierarchyProvider` that creates a hierarchy based on given iModel and\n * a hierarchy definition, which defines each hierarchy level through ECSQL queries.\n *\n * @public\n */\nexport function createIModelHierarchyProvider(props: IModelHierarchyProviderProps): HierarchyProvider & {\n /** @deprecated in 1.4. Use `[Symbol.dispose]` instead. */\n dispose: () => void;\n [Symbol.dispose]: () => void;\n} {\n return new IModelHierarchyProviderImpl(props);\n}\n\ninterface RequestContextProp {\n requestContext: {\n requestId: string;\n };\n}\n\nclass IModelHierarchyProviderImpl implements HierarchyProvider {\n private _imodelAccess: IModelAccess;\n private _hierarchyChanged: BeEvent<(args?: EventArgs<HierarchyProvider[\"hierarchyChanged\"]>) => void>;\n private _valuesFormatter: IPrimitiveValueFormatter;\n private _sourceHierarchyDefinition: RxjsHierarchyDefinition;\n private _activeHierarchyDefinition: RxjsHierarchyDefinition;\n private _localizedStrings: IModelHierarchyProviderLocalizedStrings;\n private _queryScheduler: SubscriptionScheduler;\n private _nodesCache?: HierarchyCache<HierarchyCacheEntry>;\n private _unsubscribe?: () => void;\n private _dispose = new Subject<void>();\n #componentId: GuidString;\n #componentName: string;\n\n public constructor(props: IModelHierarchyProviderProps) {\n this.#componentId = Guid.createValue();\n this.#componentName = \"IModelHierarchyProviderImpl\";\n this._imodelAccess = props.imodelAccess;\n this._hierarchyChanged = new BeEvent();\n this._activeHierarchyDefinition = this._sourceHierarchyDefinition = getRxjsHierarchyDefinition(props.hierarchyDefinition);\n this._valuesFormatter = props?.formatter ?? createDefaultValueFormatter();\n this._localizedStrings = { other: \"Other\", unspecified: \"Not specified\", ...props?.localizedStrings };\n this._queryScheduler = new SubscriptionScheduler(props.queryConcurrency ?? DEFAULT_QUERY_CONCURRENCY);\n this.setHierarchyFilter(props.filtering);\n\n const queryCacheSize = props.queryCacheSize ?? DEFAULT_QUERY_CACHE_SIZE;\n if (queryCacheSize !== 0) {\n this._nodesCache = new HierarchyCache({\n // we divide the size by 2, because each variation also counts as a query that we cache\n size: Math.ceil(queryCacheSize / 2),\n variationsCount: 1,\n });\n }\n\n this._unsubscribe = props.imodelChanged?.addListener(() => {\n this.invalidateHierarchyCache(\"Data source changed\");\n this._dispose.next();\n this._hierarchyChanged.raiseEvent();\n });\n }\n\n public [Symbol.dispose]() {\n this._dispose.next();\n this._unsubscribe?.();\n }\n\n /* v8 ignore next -- @preserve */\n public dispose() {\n this[Symbol.dispose]();\n }\n\n public get hierarchyChanged() {\n return this._hierarchyChanged;\n }\n\n private invalidateHierarchyCache(reason?: string) {\n /* v8 ignore next -- @preserve */\n doLog({\n category: `${LOGGING_NAMESPACE}.Events`,\n message: () => (reason ? `${reason}: clear hierarchy cache` : `Clear hierarchy cache`),\n });\n this._nodesCache?.clear();\n }\n\n /**\n * Sets `HierarchyProvider` values formatter that formats nodes' labels. If provided `undefined`, then defaults to the\n * result of `createDefaultValueFormatter` called with default parameters.\n */\n public setFormatter(formatter: IPrimitiveValueFormatter | undefined) {\n this._valuesFormatter = formatter ?? createDefaultValueFormatter();\n this._hierarchyChanged.raiseEvent({ formatterChange: { newFormatter: this._valuesFormatter } });\n }\n\n public setHierarchyFilter(props: IModelHierarchyProviderProps[\"filtering\"]) {\n if (!props) {\n if (this._sourceHierarchyDefinition !== this._activeHierarchyDefinition) {\n this._activeHierarchyDefinition = this._sourceHierarchyDefinition;\n this.invalidateHierarchyCache(\"Hierarchy filter reset\");\n }\n this._hierarchyChanged.raiseEvent({ filterChange: { newFilter: undefined } });\n return;\n }\n this._activeHierarchyDefinition = new FilteringHierarchyDefinition({\n imodelAccess: this._imodelAccess,\n source: this._sourceHierarchyDefinition,\n nodeIdentifierPaths: props.paths,\n });\n this.invalidateHierarchyCache(\"Hierarchy filter set\");\n this._dispose.next();\n this._hierarchyChanged.raiseEvent({ filterChange: { newFilter: props } });\n }\n\n private onGroupingNodeCreated(groupingNode: ProcessedGroupingHierarchyNode, props: GetHierarchyNodesProps) {\n this._nodesCache?.set({ ...props, parentNode: groupingNode }, { observable: from(groupingNode.children), processingStatus: \"pre-processed\" });\n }\n\n private createHierarchyLevelDefinitionsObservable(props: DefineHierarchyLevelProps & RequestContextProp): Observable<HierarchyNodesDefinition> {\n const { requestContext, ...defineHierarchyLevelProps } = props;\n /* v8 ignore next -- @preserve */\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: () => `[${requestContext.requestId}] Requesting hierarchy level definitions for ${createNodeIdentifierForLogging(props.parentNode)}`,\n });\n let parentNode = props.parentNode;\n if (parentNode && HierarchyNode.isGeneric(parentNode) && parentNode.key.source && parentNode.key.source !== this._imodelAccess.imodelKey) {\n return EMPTY;\n }\n if (parentNode && HierarchyNode.isInstancesNode(parentNode)) {\n parentNode = {\n ...parentNode,\n key: {\n ...parentNode.key,\n instanceKeys: parentNode.key.instanceKeys.filter((ik) => !ik.imodelKey || ik.imodelKey === this._imodelAccess.imodelKey),\n },\n };\n assert(HierarchyNodeKey.isInstances(parentNode.key));\n if (parentNode.key.instanceKeys.length === 0) {\n return EMPTY;\n }\n }\n return this._activeHierarchyDefinition.defineHierarchyLevel({ ...defineHierarchyLevelProps, parentNode }).pipe(\n mergeAll(),\n finalize(() => {\n /* v8 ignore next -- @preserve */\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: () => `[${requestContext.requestId}] Received all hierarchy level definitions for ${createNodeIdentifierForLogging(props.parentNode)}`,\n });\n }),\n );\n }\n\n private createSourceNodesObservable(\n props: DefineHierarchyLevelProps & { hierarchyLevelSizeLimit?: number | \"unbounded\"; filteredInstanceKeys?: InstanceKey[] } & RequestContextProp,\n ): SourceNodesObservable {\n // pipe definitions to nodes and put \"share replay\" on it\n return this.createHierarchyLevelDefinitionsObservable(props).pipe(\n mergeMap((def): ObservableInput<SourceHierarchyNode> => {\n if (HierarchyNodesDefinition.isGenericNode(def)) {\n return of({ ...def.node, key: { type: \"generic\", id: def.node.key, source: this._imodelAccess.imodelKey } });\n }\n return this._queryScheduler.scheduleSubscription(\n of(def.query).pipe(\n map((query) => filterQueryByInstanceKeys(query, props.filteredInstanceKeys)),\n mergeMap((query) =>\n readNodes({\n queryExecutor: this._imodelAccess,\n query,\n limit: props.hierarchyLevelSizeLimit,\n parser: this._activeHierarchyDefinition.parseNode ? (row) => this._activeHierarchyDefinition.parseNode!(row, props.parentNode) : undefined,\n }),\n ),\n map((node) => ({\n ...node,\n key: { ...node.key, instanceKeys: node.key.instanceKeys.map((key) => ({ ...key, imodelKey: this._imodelAccess.imodelKey })) },\n })),\n ),\n );\n }),\n finalize(() => {\n /* v8 ignore next -- @preserve */\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: () => `[${props.requestContext.requestId}] Read all child nodes ${createNodeIdentifierForLogging(props.parentNode)}`,\n });\n }),\n shareReplayWithErrors(),\n );\n }\n\n private createPreProcessedNodesObservable(\n queryNodesObservable: SourceNodesObservable,\n props: GetHierarchyNodesProps & RequestContextProp,\n ): Observable<ProcessedHierarchyNode> {\n return queryNodesObservable.pipe(\n // we're going to be mutating the nodes, but don't want to mutate the original one, so just clone it here once\n map((node) => ({ ...node })),\n // set parent node keys on the source node\n map((node) => Object.assign(node, { parentKeys: createParentNodeKeysList(props.parentNode) })),\n // format `ConcatenatedValue` labels into string labels\n mergeMap((node) => applyLabelsFormatting(node, this._valuesFormatter)),\n // we have `ProcessedHierarchyNode` from here\n preProcessNodes(this._activeHierarchyDefinition),\n // process hiding\n createHideIfNoChildrenOperator((n) => this.getChildNodesObservables({ parentNode: n, requestContext: props.requestContext }).hasNodes),\n createHideNodesInHierarchyOperator(\n // note: for child nodes created because of hidden parent, we want to use parent's request props (instance filter, limit)\n (n) => this.getChildNodesObservables({ ...props, parentNode: n }).processedNodes,\n false,\n ),\n finalize(() => {\n /* v8 ignore next -- @preserve */\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: () => `[${props.requestContext.requestId}] Finished pre-processing child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,\n });\n }),\n );\n }\n\n private createProcessedNodesObservable(\n preprocessedNodesObservable: Observable<ProcessedHierarchyNode>,\n props: GetHierarchyNodesProps & RequestContextProp,\n ): Observable<ProcessedHierarchyNode> {\n return preprocessedNodesObservable.pipe(\n createGroupingOperator(this._imodelAccess, props.parentNode, this._valuesFormatter, this._localizedStrings, undefined, (gn) =>\n this.onGroupingNodeCreated(gn, props),\n ),\n finalize(() => {\n /* v8 ignore next -- @preserve */\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: () => `[${props.requestContext.requestId}] Finished grouping child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,\n });\n }),\n );\n }\n\n private createFinalizedNodesObservable(\n processedNodesObservable: Observable<ProcessedHierarchyNode>,\n props: GetHierarchyNodesProps & RequestContextProp,\n ): Observable<HierarchyNode> {\n return processedNodesObservable.pipe(\n createDetermineChildrenOperator((n) => this.getChildNodesObservables({ parentNode: n, requestContext: props.requestContext }).hasNodes),\n postProcessNodes(this._activeHierarchyDefinition),\n sortNodesByLabelOperator,\n map((n): HierarchyNode => {\n if (\"processingParams\" in n) {\n delete n.processingParams;\n }\n return Object.assign(n, {\n children: hasChildren(n),\n });\n }),\n takeUntil(this._dispose),\n finalize(() => {\n /* v8 ignore next -- @preserve */\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: () => `[${props.requestContext.requestId}] Finished finalizing child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,\n });\n }),\n );\n }\n\n private createHasNodesObservable(\n preprocessedNodesObservable: Observable<ProcessedHierarchyNode>,\n possiblyKnownChildrenObservable: SourceNodesObservable | undefined,\n props: RequestContextProp,\n ): Observable<boolean> {\n const loggingCategory = `${LOGGING_NAMESPACE_INTERNAL}.HasNodes`;\n return concat((possiblyKnownChildrenObservable ?? EMPTY).pipe(filter((n) => hasChildren(n))), preprocessedNodesObservable).pipe(\n /* v8 ignore next -- @preserve */\n log({\n category: loggingCategory,\n message: (n) => `[${props.requestContext.requestId}] Node before mapping to 'true': ${createNodeIdentifierForLogging(n)}`,\n }),\n take(1),\n map(() => true),\n defaultIfEmpty(false),\n catchError((e: Error) => {\n /* v8 ignore next -- @preserve */\n doLog({\n category: loggingCategory,\n message: () => `[${props.requestContext.requestId}] Error while determining children: ${e.message}`,\n });\n if (e instanceof RowsLimitExceededError) {\n return of(true);\n }\n throw e;\n }),\n /* v8 ignore next -- @preserve */\n log({ category: loggingCategory, message: (r) => `[${props.requestContext.requestId}] Result: ${r}` }),\n );\n }\n\n private getCachedObservableEntry(props: GetHierarchyNodesProps & RequestContextProp): HierarchyCacheEntry {\n const loggingCategory = `${LOGGING_NAMESPACE}.QueryResultsCache`;\n const { parentNode, ...restProps } = props;\n const cached = props.ignoreCache || !this._nodesCache ? undefined : this._nodesCache.get(props);\n if (cached) {\n /* v8 ignore next -- @preserve */\n doLog({\n category: loggingCategory,\n message: () => `[${props.requestContext.requestId}] Found query nodes observable for ${createNodeIdentifierForLogging(parentNode)}`,\n });\n return cached;\n }\n\n // if we don't find an entry for a grouping node, we load its instances by getting a query and applying\n // a filter based on grouped instance keys\n let filteredInstanceKeys: InstanceKey[] | undefined;\n let parentNonGroupingNode: ParentHierarchyNode<NonGroupingHierarchyNode> | undefined;\n if (parentNode) {\n if (HierarchyNode.isGroupingNode(parentNode)) {\n parentNonGroupingNode = parentNode.nonGroupingAncestor;\n filteredInstanceKeys = parentNode.groupedInstanceKeys;\n } else {\n // not sure why type checker doesn't pick this up\n assert(HierarchyNode.isGeneric(parentNode) || HierarchyNode.isInstancesNode(parentNode));\n parentNonGroupingNode = parentNode;\n }\n }\n\n const nonGroupingNodeChildrenRequestProps = {\n ...restProps,\n parentNode: parentNonGroupingNode,\n ...(filteredInstanceKeys ? { filteredInstanceKeys } : undefined),\n };\n const value = { observable: this.createSourceNodesObservable(nonGroupingNodeChildrenRequestProps), processingStatus: \"none\" as const };\n this._nodesCache?.set(nonGroupingNodeChildrenRequestProps, value);\n /* v8 ignore next -- @preserve */\n doLog({\n category: loggingCategory,\n message: () => `[${props.requestContext.requestId}] Saved query nodes observable for ${createNodeIdentifierForLogging(parentNode)}`,\n });\n return value;\n }\n\n private getChildNodesObservables(props: GetHierarchyNodesProps & { hierarchyLevelSizeLimit?: number | \"unbounded\" } & RequestContextProp) {\n const entry = this.getCachedObservableEntry(props);\n switch (entry.processingStatus) {\n case \"none\": {\n const pre = this.createPreProcessedNodesObservable(entry.observable, props);\n const post = this.createProcessedNodesObservable(pre, props);\n return {\n processedNodes: post,\n hasNodes: this.createHasNodesObservable(pre, entry.observable, props),\n finalizedNodes: this.createFinalizedNodesObservable(post, props),\n };\n }\n case \"pre-processed\": {\n const post = this.createProcessedNodesObservable(entry.observable, props);\n return {\n processedNodes: post,\n hasNodes: this.createHasNodesObservable(entry.observable, undefined, props),\n finalizedNodes: this.createFinalizedNodesObservable(post, props),\n };\n }\n }\n }\n\n /**\n * Creates and runs a query based on provided props, then processes retrieved nodes and returns them.\n */\n public getNodes(props: GetHierarchyNodesProps): AsyncIterableIterator<HierarchyNode> {\n const requestContext = { requestId: Guid.createValue() };\n const loggingCategory = `${LOGGING_NAMESPACE}.GetNodes`;\n const timer = new StopWatch(undefined, true);\n let error: any;\n let nodesCount = 0;\n /* v8 ignore next -- @preserve */\n doLog({\n category: loggingCategory,\n message: () => `[${requestContext.requestId}] Requesting child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,\n });\n return eachValueFrom(\n this.getChildNodesObservables({ ...props, requestContext }).finalizedNodes.pipe(\n tap(() => ++nodesCount),\n catchError((e) => {\n error = e;\n throw e;\n }),\n finalize(() => {\n /* v8 ignore next -- @preserve */\n doLog({\n category: loggingCategory,\n message: () =>\n error\n ? `[${requestContext.requestId}] Error creating child nodes for ${createNodeIdentifierForLogging(props.parentNode)}: ${error instanceof Error ? error.message : error.toString()}`\n : `[${requestContext.requestId}] Returned ${nodesCount} child nodes for ${createNodeIdentifierForLogging(props.parentNode)} in ${timer.currentSeconds.toFixed(2)} s.`,\n });\n }),\n ),\n );\n }\n\n private getNodeInstanceKeysObs(props: Omit<GetHierarchyNodesProps, \"ignoreCache\"> & RequestContextProp): Observable<InstanceKey> {\n const { parentNode, instanceFilter, hierarchyLevelSizeLimit = \"unbounded\", requestContext } = props;\n if (parentNode && HierarchyNode.isGroupingNode(parentNode)) {\n return from(parentNode.groupedInstanceKeys);\n }\n assert(!parentNode || HierarchyNode.isGeneric(parentNode) || HierarchyNode.isInstancesNode(parentNode));\n\n const hierarchyLevelDefinitions = this.createHierarchyLevelDefinitionsObservable({ parentNode, instanceFilter, requestContext });\n\n // split the definitions based on whether they're for generic nodes or for instance nodes\n const [genericDefs, instanceDefs] = partition(hierarchyLevelDefinitions, HierarchyNodesDefinition.isGenericNode);\n\n // query instance keys and a flag whether they should be hidden\n const instanceKeys = instanceDefs.pipe(\n mergeMap((def) =>\n this._queryScheduler.scheduleSubscription(\n of(def.query).pipe(\n mergeMap(async (query) => {\n const ecsql = `\n SELECT\n ${NodeSelectClauseColumnNames.FullClassName},\n ${NodeSelectClauseColumnNames.ECInstanceId},\n ${NodeSelectClauseColumnNames.HideNodeInHierarchy}\n FROM (\n ${query.ecsql}\n )\n `;\n const reader = this._imodelAccess.createQueryReader(\n { ...query, ecsql },\n {\n rowFormat: \"Indexes\",\n limit: hierarchyLevelSizeLimit,\n restartToken: `${this.#componentName}/${this.#componentId}/node-instance-keys/${Guid.createValue()}`,\n },\n );\n return from(reader).pipe(\n map((row) => ({\n key: {\n className: normalizeFullClassName(row[0]),\n id: row[1],\n imodelKey: this._imodelAccess.imodelKey,\n } satisfies IModelInstanceKey,\n hide: !!row[2],\n })),\n );\n }),\n mergeAll(),\n ),\n ),\n ),\n );\n // split the instance keys observable based on whether they should be hidden or not\n const [visibleNodeInstanceKeys, hiddenNodeInstanceKeys] = partition(instanceKeys, ({ hide }) => !hide);\n\n // hidden items' handling:\n // - if a generic node is hidden, we'll want to retrieve instance keys of its children, otherwise we don't care about it,\n // - if an instance key is hidden, we want to create a merged node similar to what we do in `createHideNodesInHierarchyOperator`\n const hiddenParentNodes = merge(\n genericDefs.pipe(\n filter((def) => !!def.node.processingParams?.hideInHierarchy),\n map(\n (def): GenericNodeKey => ({\n type: \"generic\",\n id: def.node.key,\n source: this._imodelAccess.imodelKey,\n }),\n ),\n ),\n hiddenNodeInstanceKeys.pipe(\n // first merge all keys by class\n reduceToMergeMapList(\n ({ key }) => key.className,\n ({ key }) => key.id,\n ),\n // then, for each class, create an instance key\n mergeMap((mergedMap): InstancesNodeKey[] =>\n [...mergedMap.entries()].map(([className, ids]) => ({\n type: \"instances\",\n instanceKeys: ids.map((id) => ({ className, id, imodelKey: this._imodelAccess.imodelKey })),\n })),\n ),\n ),\n ).pipe(\n map((key) => ({\n key,\n parentKeys: [],\n label: \"\",\n })),\n );\n\n // merge visible instance keys from this level & the ones we get recursively requesting from deeper levels\n return merge(\n visibleNodeInstanceKeys.pipe(map(({ key }) => key)),\n hiddenParentNodes.pipe(mergeMap((hiddenNode) => this.getNodeInstanceKeysObs({ parentNode: hiddenNode, requestContext }))),\n ).pipe(takeUntil(this._dispose));\n }\n\n /**\n * Creates an iterator for all child hierarchy level instance keys, taking into account any hidden hierarchy levels\n * that there may be under the given parent node.\n */\n public getNodeInstanceKeys(props: Omit<GetHierarchyNodesProps, \"ignoreCache\">): AsyncIterableIterator<InstanceKey> {\n const requestContext = { requestId: Guid.createValue() };\n const loggingCategory = `${LOGGING_NAMESPACE}.GetNodeInstanceKeys`;\n const timer = new StopWatch(undefined, true);\n /* v8 ignore next -- @preserve */\n doLog({\n category: loggingCategory,\n message: () => `[${requestContext.requestId}] Requesting keys for ${createNodeIdentifierForLogging(props.parentNode)}`,\n });\n let error: any;\n let keysCount = 0;\n return eachValueFrom(\n this.getNodeInstanceKeysObs({ ...props, requestContext }).pipe(\n tap(() => ++keysCount),\n catchError((e) => {\n error = e;\n throw e;\n }),\n finalize(() => {\n /* v8 ignore next -- @preserve */\n doLog({\n category: loggingCategory,\n message: () =>\n error\n ? `[${requestContext.requestId}] Error creating node instance keys for ${createNodeIdentifierForLogging(props.parentNode)}: ${error instanceof Error ? error.message : error.toString()}`\n : `[${requestContext.requestId}] Returned ${keysCount} instance keys for ${createNodeIdentifierForLogging(props.parentNode)} in ${timer.currentSeconds.toFixed(2)} s.`,\n });\n }),\n ),\n );\n }\n}\n\ntype SourceHierarchyNode = SourceInstanceHierarchyNode | (Omit<SourceGenericHierarchyNode, \"key\"> & { key: GenericNodeKey });\ntype SourceNodesObservable = Observable<SourceHierarchyNode>;\ntype ProcessedNodesObservable = Observable<ProcessedHierarchyNode>;\ntype HierarchyCacheEntry =\n | { observable: SourceNodesObservable; processingStatus: \"none\" }\n | { observable: ProcessedNodesObservable; processingStatus: \"pre-processed\" };\n\nfunction preProcessNodes(hierarchyFactory: RxjsHierarchyDefinition) {\n return hierarchyFactory.preProcessNode ? processNodes(hierarchyFactory.preProcessNode) : identity;\n}\n\nfunction postProcessNodes(hierarchyFactory: RxjsHierarchyDefinition) {\n return hierarchyFactory.postProcessNode ? processNodes(hierarchyFactory.postProcessNode) : identity;\n}\n\nfunction processNodes<TNode>(processor: (node: TNode) => Observable<TNode>) {\n return (nodes: Observable<TNode>) => nodes.pipe(mergeMap(processor));\n}\n\nfunction applyLabelsFormatting<TNode extends { label: string | ConcatenatedValue }>(\n node: TNode,\n valueFormatter: IPrimitiveValueFormatter,\n): Observable<TNode & { label: string }> {\n return from(\n formatConcatenatedValue({\n value: node.label,\n valueFormatter,\n }),\n ).pipe(\n map((label) => ({\n ...node,\n label,\n })),\n );\n}\n\nfunction createParentNodeKeysList(parentNode: ParentHierarchyNode | undefined) {\n if (!parentNode) {\n return [];\n }\n return [...parentNode.parentKeys, parentNode.key];\n}\n\nfunction filterQueryByInstanceKeys(query: ECSqlQueryDef, filteredInstanceKeys: InstanceKey[] | undefined): ECSqlQueryDef {\n if (!filteredInstanceKeys || !filteredInstanceKeys.length) {\n return query;\n }\n const MAX_ALLOWED_BINDINGS = 1000;\n // TODO: MISSING_COVERAGE\n /* v8 ignore else -- @preserve */\n if (filteredInstanceKeys.length < MAX_ALLOWED_BINDINGS) {\n return {\n ...query,\n ecsql: `\n SELECT *\n FROM (${query.ecsql}) q\n WHERE q.ECInstanceId IN (${filteredInstanceKeys.map(() => \"?\").join(\",\")})\n `,\n bindings: [...(query.bindings ?? []), ...filteredInstanceKeys.map((k): ECSqlBinding => ({ type: \"id\", value: k.id }))],\n };\n }\n /* v8 ignore start */\n return {\n ...query,\n ecsql: `\n SELECT *\n FROM (${query.ecsql}) q\n WHERE InVirtualSet(?, q.ECInstanceId)\n `,\n bindings: [...(query.bindings ?? []), { type: \"idset\", value: filteredInstanceKeys.map((k) => k.id) }],\n };\n /* v8 ignore stop */\n}\n"]}
|
|
@@ -69,9 +69,10 @@ const LOGGING_NAMESPACE = `${BASE_LOGGING_NAMESPACE}.Queries`;
|
|
|
69
69
|
const LOGGING_NAMESPACE_PERFORMANCE = `${BASE_LOGGING_NAMESPACE_PERFORMANCE}.Queries`;
|
|
70
70
|
function createQueryLogger(query, firstStepWarningThreshold = 3000, allRowsWarningThreshold = 5000) {
|
|
71
71
|
const queryId = Guid.createValue();
|
|
72
|
+
/* v8 ignore next -- @preserve */
|
|
72
73
|
doLog({
|
|
73
74
|
category: LOGGING_NAMESPACE,
|
|
74
|
-
message:
|
|
75
|
+
message: () => `Executing query [${queryId}]: ${createQueryLogMessage(query)}`,
|
|
75
76
|
});
|
|
76
77
|
let firstStep = true;
|
|
77
78
|
let rowsCount = 0;
|
|
@@ -79,29 +80,29 @@ function createQueryLogger(query, firstStepWarningThreshold = 3000, allRowsWarni
|
|
|
79
80
|
return {
|
|
80
81
|
onStep() {
|
|
81
82
|
if (firstStep) {
|
|
82
|
-
/*
|
|
83
|
+
/* v8 ignore start */
|
|
83
84
|
doLog({
|
|
84
85
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
85
86
|
severity: timer.current.milliseconds >= firstStepWarningThreshold ? "warning" : "trace",
|
|
86
87
|
message: () => `[${queryId}] First step took ${timer.currentSeconds} s.`,
|
|
87
88
|
});
|
|
88
|
-
/*
|
|
89
|
+
/* v8 ignore stop */
|
|
89
90
|
firstStep = false;
|
|
90
91
|
}
|
|
91
92
|
++rowsCount;
|
|
92
93
|
},
|
|
93
94
|
onComplete() {
|
|
94
|
-
/*
|
|
95
|
+
/* v8 ignore start */
|
|
95
96
|
doLog({
|
|
96
97
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
97
98
|
severity: timer.current.milliseconds >= allRowsWarningThreshold ? "warning" : "trace",
|
|
98
99
|
message: () => `[${queryId}] Query took ${timer.currentSeconds} s. for ${rowsCount} rows.`,
|
|
99
100
|
});
|
|
100
|
-
/*
|
|
101
|
+
/* v8 ignore stop */
|
|
101
102
|
},
|
|
102
103
|
};
|
|
103
104
|
}
|
|
104
|
-
/*
|
|
105
|
+
/* v8 ignore start */
|
|
105
106
|
function createQueryLogMessage(query) {
|
|
106
107
|
const ctes = query.ctes?.map((cte) => ` ${trimWhitespace(cte)}`).join(", \n");
|
|
107
108
|
const bindings = query.bindings?.map((b) => JSON.stringify(b.value)).join(", ");
|
|
@@ -116,5 +117,5 @@ function createQueryLogMessage(query) {
|
|
|
116
117
|
output += "}";
|
|
117
118
|
return output;
|
|
118
119
|
}
|
|
119
|
-
/*
|
|
120
|
+
/* v8 ignore stop */
|
|
120
121
|
//# sourceMappingURL=LimitingECSqlQueryExecutor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LimitingECSqlQueryExecutor.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/LimitingECSqlQueryExecutor.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EACL,0CAA0C,EAK1C,cAAc,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,IAAI,sBAAsB,EAAE,6BAA6B,IAAI,kCAAkC,EAAE,M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C,KAAK,CAAC,MAAM,CAAC;IACxD,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,IAAI,gBAAgB,QAAQ,OAAO,CAAC;IAC5C,CAAC;IACD,MAAM,IAAI,GAAG,CAAC;IACd,OAAO,MAAM,CAAC;AAChB,CAAC;AACD,oBAAoB","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 { Guid, StopWatch } from \"@itwin/core-bentley\";\nimport {\n createMainThreadReleaseOnTimePassedHandler,\n ECSqlQueryDef,\n ECSqlQueryExecutor,\n ECSqlQueryReaderOptions,\n ECSqlQueryRow,\n trimWhitespace,\n} from \"@itwin/presentation-shared\";\nimport { RowsLimitExceededError } from \"../HierarchyErrors.js\";\nimport { LOGGING_NAMESPACE as BASE_LOGGING_NAMESPACE, LOGGING_NAMESPACE_PERFORMANCE as BASE_LOGGING_NAMESPACE_PERFORMANCE } from \"../internal/Common.js\";\nimport { doLog } from \"../internal/LoggingUtils.js\";\n\n/**\n * An interface for something that knows how to create a limiting ECSQL query reader.\n * @public\n */\nexport interface LimitingECSqlQueryExecutor {\n /**\n * Creates a query reader for given query, but makes sure it doesn't return more than the configured\n * limit of rows.\n * @throws `RowsLimitExceededError` when the query returns more than configured limit of rows.\n */\n createQueryReader(\n query: ECSqlQueryDef,\n config?: ECSqlQueryReaderOptions & { limit?: number | \"unbounded\" },\n ): ReturnType<ECSqlQueryExecutor[\"createQueryReader\"]>;\n}\n\n/**\n * Creates an `LimitingECSqlQueryExecutor` that throws `RowsLimitExceededError` if the query exceeds given amount of rows.\n * @public\n */\nexport function createLimitingECSqlQueryExecutor(baseExecutor: ECSqlQueryExecutor, defaultLimit: number | \"unbounded\"): LimitingECSqlQueryExecutor {\n return {\n async *createQueryReader(query: ECSqlQueryDef, config?: ECSqlQueryReaderOptions & { limit?: number | \"unbounded\" }) {\n const { limit: configLimit, ...restConfig } = config ?? {};\n const limit = configLimit ?? defaultLimit;\n const queryLogger = createQueryLogger(query);\n const releaseMainThread = createMainThreadReleaseOnTimePassedHandler();\n\n // handle \"unbounded\" case without a buffer\n const reader = baseExecutor.createQueryReader({ ...query, ecsql: addLimit(query.ecsql, limit) }, restConfig);\n if (limit === \"unbounded\") {\n try {\n for await (const row of reader) {\n await releaseMainThread();\n queryLogger.onStep();\n yield row;\n }\n } finally {\n queryLogger.onComplete();\n }\n return;\n }\n\n // avoid streaming until we know the number of rows is okay\n const buffer: ECSqlQueryRow[] = [];\n try {\n for await (const row of reader) {\n await releaseMainThread();\n queryLogger.onStep();\n buffer.push(row);\n if (buffer.length > limit) {\n throw new RowsLimitExceededError(limit);\n }\n }\n } finally {\n queryLogger.onComplete();\n }\n\n for (const row of buffer) {\n await releaseMainThread();\n yield row;\n }\n },\n };\n}\n\nfunction addLimit(ecsql: string, limit: number | \"unbounded\") {\n if (limit === \"unbounded\") {\n return ecsql;\n }\n return `\n SELECT *\n FROM (${ecsql})\n LIMIT ${limit + 1}\n `;\n}\n\nconst LOGGING_NAMESPACE = `${BASE_LOGGING_NAMESPACE}.Queries`;\nconst LOGGING_NAMESPACE_PERFORMANCE = `${BASE_LOGGING_NAMESPACE_PERFORMANCE}.Queries`;\nfunction createQueryLogger(query: ECSqlQueryDef, firstStepWarningThreshold = 3000, allRowsWarningThreshold = 5000) {\n const queryId = Guid.createValue();\n /* v8 ignore next -- @preserve */\n doLog({\n category: LOGGING_NAMESPACE,\n message: () => `Executing query [${queryId}]: ${createQueryLogMessage(query)}`,\n });\n\n let firstStep = true;\n let rowsCount = 0;\n const timer = new StopWatch(undefined, true);\n return {\n onStep() {\n if (firstStep) {\n /* v8 ignore start */\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n severity: timer.current.milliseconds >= firstStepWarningThreshold ? \"warning\" : \"trace\",\n message: () => `[${queryId}] First step took ${timer.currentSeconds} s.`,\n });\n /* v8 ignore stop */\n firstStep = false;\n }\n ++rowsCount;\n },\n onComplete() {\n /* v8 ignore start */\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n severity: timer.current.milliseconds >= allRowsWarningThreshold ? \"warning\" : \"trace\",\n message: () => `[${queryId}] Query took ${timer.currentSeconds} s. for ${rowsCount} rows.`,\n });\n /* v8 ignore stop */\n },\n };\n}\n\n/* v8 ignore start */\nfunction createQueryLogMessage(query: ECSqlQueryDef): string {\n const ctes = query.ctes?.map((cte) => ` ${trimWhitespace(cte)}`).join(\", \\n\");\n const bindings = query.bindings?.map((b) => JSON.stringify(b.value)).join(\", \");\n let output = \"{\\n\";\n if (ctes) {\n output += ` ctes: [ \\n${ctes} \\n], \\n`;\n }\n output += ` ecsql: ${trimWhitespace(query.ecsql)}, \\n`;\n if (bindings) {\n output += ` bindings: [${bindings}], \\n`;\n }\n output += \"}\";\n return output;\n}\n/* v8 ignore stop */\n"]}
|
|
@@ -182,6 +182,8 @@ async function createGroupingSelector(grouping, imodelAccess, instanceLabelSelec
|
|
|
182
182
|
...createBaseGroupingParamSelectors(grouping.byBaseClasses),
|
|
183
183
|
]),
|
|
184
184
|
});
|
|
185
|
+
// TODO: MISSING_COVERAGE
|
|
186
|
+
/* v8 ignore else -- @preserve */
|
|
185
187
|
if (grouping.byProperties) {
|
|
186
188
|
const propertyClass = await getClass(imodelAccess, grouping.byProperties.propertiesClassName);
|
|
187
189
|
groupingSelectors.push({
|
|
@@ -249,6 +251,8 @@ async function createPropertyGroupSelectors(propertyGroup, propertyClass, instan
|
|
|
249
251
|
if (property.isNavigation()) {
|
|
250
252
|
const relationshipClass = await property.relationshipClass;
|
|
251
253
|
const abstractConstraint = property.direction === "Forward" ? await relationshipClass.target.abstractConstraint : await relationshipClass.source.abstractConstraint;
|
|
254
|
+
// TODO: MISSING_COVERAGE
|
|
255
|
+
/* v8 ignore else -- @preserve */
|
|
252
256
|
if (!abstractConstraint) {
|
|
253
257
|
throw new Error(`Could not determine class name for navigation property with direction "${property.direction}".`);
|
|
254
258
|
}
|