@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
|
@@ -72,9 +72,10 @@ const LOGGING_NAMESPACE = `${Common_js_1.LOGGING_NAMESPACE}.Queries`;
|
|
|
72
72
|
const LOGGING_NAMESPACE_PERFORMANCE = `${Common_js_1.LOGGING_NAMESPACE_PERFORMANCE}.Queries`;
|
|
73
73
|
function createQueryLogger(query, firstStepWarningThreshold = 3000, allRowsWarningThreshold = 5000) {
|
|
74
74
|
const queryId = core_bentley_1.Guid.createValue();
|
|
75
|
+
/* v8 ignore next -- @preserve */
|
|
75
76
|
(0, LoggingUtils_js_1.doLog)({
|
|
76
77
|
category: LOGGING_NAMESPACE,
|
|
77
|
-
message:
|
|
78
|
+
message: () => `Executing query [${queryId}]: ${createQueryLogMessage(query)}`,
|
|
78
79
|
});
|
|
79
80
|
let firstStep = true;
|
|
80
81
|
let rowsCount = 0;
|
|
@@ -82,29 +83,29 @@ function createQueryLogger(query, firstStepWarningThreshold = 3000, allRowsWarni
|
|
|
82
83
|
return {
|
|
83
84
|
onStep() {
|
|
84
85
|
if (firstStep) {
|
|
85
|
-
/*
|
|
86
|
+
/* v8 ignore start */
|
|
86
87
|
(0, LoggingUtils_js_1.doLog)({
|
|
87
88
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
88
89
|
severity: timer.current.milliseconds >= firstStepWarningThreshold ? "warning" : "trace",
|
|
89
90
|
message: () => `[${queryId}] First step took ${timer.currentSeconds} s.`,
|
|
90
91
|
});
|
|
91
|
-
/*
|
|
92
|
+
/* v8 ignore stop */
|
|
92
93
|
firstStep = false;
|
|
93
94
|
}
|
|
94
95
|
++rowsCount;
|
|
95
96
|
},
|
|
96
97
|
onComplete() {
|
|
97
|
-
/*
|
|
98
|
+
/* v8 ignore start */
|
|
98
99
|
(0, LoggingUtils_js_1.doLog)({
|
|
99
100
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
100
101
|
severity: timer.current.milliseconds >= allRowsWarningThreshold ? "warning" : "trace",
|
|
101
102
|
message: () => `[${queryId}] Query took ${timer.currentSeconds} s. for ${rowsCount} rows.`,
|
|
102
103
|
});
|
|
103
|
-
/*
|
|
104
|
+
/* v8 ignore stop */
|
|
104
105
|
},
|
|
105
106
|
};
|
|
106
107
|
}
|
|
107
|
-
/*
|
|
108
|
+
/* v8 ignore start */
|
|
108
109
|
function createQueryLogMessage(query) {
|
|
109
110
|
const ctes = query.ctes?.map((cte) => ` ${(0, presentation_shared_1.trimWhitespace)(cte)}`).join(", \n");
|
|
110
111
|
const bindings = query.bindings?.map((b) => JSON.stringify(b.value)).join(", ");
|
|
@@ -119,5 +120,5 @@ function createQueryLogMessage(query) {
|
|
|
119
120
|
output += "}";
|
|
120
121
|
return output;
|
|
121
122
|
}
|
|
122
|
-
/*
|
|
123
|
+
/* v8 ignore stop */
|
|
123
124
|
//# sourceMappingURL=LimitingECSqlQueryExecutor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LimitingECSqlQueryExecutor.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/LimitingECSqlQueryExecutor.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAmChG,4EA4CC;AA7ED,sDAAsD;AACtD,oEAOoC;AACpC,8DAA+D;AAC/D,qDAAyJ;AACzJ,iEAAoD;AAkBpD;;;GAGG;AACH,SAAgB,gCAAgC,CAAC,YAAgC,EAAE,YAAkC;IACnH,OAAO;QACL,KAAK,CAAC,CAAC,iBAAiB,CAAC,KAAoB,EAAE,MAAmE;YAChH,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;YAC3D,MAAM,KAAK,GAAG,WAAW,IAAI,YAAY,CAAC;YAC1C,MAAM,WAAW,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC7C,MAAM,iBAAiB,GAAG,IAAA,gEAA0C,GAAE,CAAC;YAEvE,2CAA2C;YAC3C,MAAM,MAAM,GAAG,YAAY,CAAC,iBAAiB,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;YAC7G,IAAI,KAAK,KAAK,WAAW,EAAE,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M,CAAC,CAAC;IACjF,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChF,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,IAAI,eAAe,IAAI,UAAU,CAAC;IAC1C,CAAC;IACD,MAAM,IAAI,YAAY,IAAA,oCAAc,EAAC,KAAK,CAAC,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"]}
|
|
@@ -186,6 +186,8 @@ async function createGroupingSelector(grouping, imodelAccess, instanceLabelSelec
|
|
|
186
186
|
...createBaseGroupingParamSelectors(grouping.byBaseClasses),
|
|
187
187
|
]),
|
|
188
188
|
});
|
|
189
|
+
// TODO: MISSING_COVERAGE
|
|
190
|
+
/* v8 ignore else -- @preserve */
|
|
189
191
|
if (grouping.byProperties) {
|
|
190
192
|
const propertyClass = await (0, presentation_shared_1.getClass)(imodelAccess, grouping.byProperties.propertiesClassName);
|
|
191
193
|
groupingSelectors.push({
|
|
@@ -253,6 +255,8 @@ async function createPropertyGroupSelectors(propertyGroup, propertyClass, instan
|
|
|
253
255
|
if (property.isNavigation()) {
|
|
254
256
|
const relationshipClass = await property.relationshipClass;
|
|
255
257
|
const abstractConstraint = property.direction === "Forward" ? await relationshipClass.target.abstractConstraint : await relationshipClass.source.abstractConstraint;
|
|
258
|
+
// TODO: MISSING_COVERAGE
|
|
259
|
+
/* v8 ignore else -- @preserve */
|
|
256
260
|
if (!abstractConstraint) {
|
|
257
261
|
throw new Error(`Could not determine class name for navigation property with direction "${property.direction}".`);
|
|
258
262
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeSelectQueryFactory.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/NodeSelectQueryFactory.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAiQhG,sEAKC;AApQD,sDAAyD;AACzD,oDAQ4B;AAC5B,oEAUoC;AAGpC;;;;;GAKG;AACH,IAAY,2BA0BX;AA1BD,WAAY,2BAA2B;IACrC,kHAAkH;IAClH,8DAA+B,CAAA;IAC/B,6EAA6E;IAC7E,4DAA6B,CAAA;IAC7B,qCAAqC;IACrC,4DAA6B,CAAA;IAC7B;;;;;OAKG;IACH,0DAA2B,CAAA;IAC3B,6FAA6F;IAC7F,oEAAqC,CAAA;IACrC,oHAAoH;IACpH,0EAA2C,CAAA;IAC3C,mEAAmE;IACnE,oDAAqB,CAAA;IACrB,4EAA4E;IAC5E,4DAA6B,CAAA;IAC7B,2EAA2E;IAC3E,wDAAyB,CAAA;IACzB,2EAA2E;IAC3E,sEAAuC,CAAA;AACzC,CAAC,EA1BW,2BAA2B,2CAA3B,2BAA2B,QA0BtC;AAoMD;;;GAGG;AACH,SAAgB,6BAA6B,CAAC,KAG7C;IACC,OAAO,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,0DAA0D;AAC1D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B,CAAC;AAC3B,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 { assert, Id64String } from \"@itwin/core-bentley\";\nimport {\n GenericInstanceFilter,\n GenericInstanceFilterRelationshipStep,\n GenericInstanceFilterRule,\n GenericInstanceFilterRuleGroup,\n GenericInstanceFilterRuleGroupOperator,\n GenericInstanceFilterRuleOperator,\n GenericInstanceFilterRuleValue,\n} from \"@itwin/core-common\";\nimport {\n EC,\n ECClassHierarchyInspector,\n ECSchemaProvider,\n ECSql,\n getClass,\n IInstanceLabelSelectClauseFactory,\n parseFullClassName,\n PrimitiveValue,\n Props,\n} from \"@itwin/presentation-shared\";\nimport { HierarchyNodeAutoExpandProp } from \"./IModelHierarchyNode.js\";\n\n/**\n * Column names of the SELECT clause created by `NodeSelectClauseFactory`. Order of the names matches the order of columns\n * created by the factory.\n *\n * @public\n */\nexport enum NodeSelectClauseColumnNames {\n /** Full class name of the instance the node represents. Type: `string` in format `{schema name}:{class name}`. */\n FullClassName = \"FullClassName\",\n /** ECInstance ID of the instance the node represents. Type: `Id64String`. */\n ECInstanceId = \"ECInstanceId\",\n /** Display label. Type: `string`. */\n DisplayLabel = \"DisplayLabel\",\n /**\n * A flag indicating if the node has children. Type: `boolean`. Values:\n * - `false` - node never has children.\n * - `true` - node always has children.\n * - NULL - unknown, needs to be determined by requesting children for the node.\n */\n HasChildren = \"HasChildren\",\n /** A flag indicating that a node should be hidden if it has no children. Type: `boolean`. */\n HideIfNoChildren = \"HideIfNoChildren\",\n /** A flag indicating that a node should be hidden and its children should be displayed instead. Type: `boolean`. */\n HideNodeInHierarchy = \"HideNodeInHierarchy\",\n /** A serialized JSON object for providing grouping information. */\n Grouping = \"Grouping\",\n /** A serialized JSON object for associating a node with additional data. */\n ExtendedData = \"ExtendedData\",\n /** A flag indicating the node should be auto-expanded when it's loaded. */\n AutoExpand = \"AutoExpand\",\n /** A flag indicating the node supports child hierarchy level filtering. */\n SupportsFiltering = \"SupportsFiltering\",\n}\n\n/**\n * A data structure for defining an ECSQL value selector.\n * @public\n */\ninterface ECSqlValueSelector {\n selector: string;\n}\n\n/**\n * Props for `NodeSelectClauseFactory.createSelectClause`.\n * @public\n */\ninterface NodeSelectClauseProps {\n ecClassId: ECSqlValueSelector;\n ecInstanceId: ECSqlValueSelector;\n nodeLabel: string | ECSqlValueSelector;\n extendedData?: {\n [key: string]: Id64String | string | number | boolean | ECSqlValueSelector;\n };\n autoExpand?: boolean | ECSqlValueSelector;\n supportsFiltering?: boolean | ECSqlValueSelector;\n hasChildren?: boolean | ECSqlValueSelector;\n hideNodeInHierarchy?: boolean | ECSqlValueSelector;\n hideIfNoChildren?: boolean | ECSqlValueSelector;\n grouping?: ECSqlSelectClauseGroupingParams;\n}\n\n/**\n * A data structure for defining nodes' grouping requirements.\n * @public\n */\ninterface ECSqlSelectClauseGroupingParams {\n byLabel?: ECSqlSelectClauseLabelGroupingParams;\n byClass?: boolean | ECSqlSelectClauseGroupingParamsBase | ECSqlValueSelector;\n byBaseClasses?: ECSqlSelectClauseBaseClassGroupingParams;\n byProperties?: ECSqlSelectClausePropertiesGroupingParams;\n}\n\n/**\n * A data structure for defining label grouping params.\n * @public\n */\ninterface ECSqlSelectClauseLabelGroupingBaseParams {\n /** Label grouping option that determines whether to group nodes or to merge them. Defaults to \"group\".*/\n action?: \"group\" | \"merge\";\n /** Id that needs to match for nodes to be grouped or merged.*/\n groupId?: string | ECSqlValueSelector;\n}\n\n/**\n * A data structure for defining label merging.\n * @public\n */\ninterface ECSqlSelectClauseLabelGroupingMergeParams extends ECSqlSelectClauseLabelGroupingBaseParams {\n action: \"merge\";\n}\n\n/**\n * A data structure for defining label grouping.\n * @public\n */\ninterface ECSqlSelectClauseLabelGroupingGroupParams extends ECSqlSelectClauseLabelGroupingBaseParams, ECSqlSelectClauseGroupingParamsBase {\n action?: \"group\";\n}\n\n/**\n * A data structure for defining possible label grouping types.\n * @public\n */\ntype ECSqlSelectClauseLabelGroupingParams =\n | boolean\n | ECSqlValueSelector\n | ECSqlSelectClauseLabelGroupingMergeParams\n | ECSqlSelectClauseLabelGroupingGroupParams;\n\n/**\n * A data structure for defining base grouping parameters shared across all types of grouping.\n * @public\n */\ninterface ECSqlSelectClauseGroupingParamsBase {\n hideIfNoSiblings?: boolean | ECSqlValueSelector;\n hideIfOneGroupedNode?: boolean | ECSqlValueSelector;\n autoExpand?: HierarchyNodeAutoExpandProp | ECSqlValueSelector;\n}\n\n/**\n * A data structure for defining properties grouping.\n * @public\n */\ninterface ECSqlSelectClausePropertiesGroupingParams extends ECSqlSelectClauseGroupingParamsBase {\n /**\n * Full name of a class whose properties are used to group the node. Only has effect if the node\n * represents an instance of that class.\n *\n * Full class name format: `SchemaName.ClassName`.\n */\n propertiesClassName: string;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value is not set or is set to an empty string.\n *\n * Label of the created grouping node will be `Not Specified`.\n */\n createGroupForUnspecifiedValues?: boolean | ECSqlValueSelector;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value doesn't fit within any of the provided\n * ranges, or is not a numeric value.\n *\n * Label of the created grouping node will be `Other`.\n */\n createGroupForOutOfRangeValues?: boolean | ECSqlValueSelector;\n /**\n * Properties of the specified class, by which the nodes should be grouped.\n *\n * Example usage:\n * ```ts\n * propertyGroups: [\n * {\n * propertyName: \"type\",\n * propertyClassAlias: \"this\"\n * },\n * {\n * propertyName: \"length\",\n * propertyClassAlias: \"x\",\n * ranges: [\n * { fromValue: 1, toValue: 10, rangeLabel: \"Small\" },\n * { fromValue: 11, toValue: 20, rangeLabel: \"Medium\" }\n * ]\n * },\n * ]\n * ```\n */\n propertyGroups: ECSqlSelectClausePropertyGroup[];\n}\n\n/**\n * A data structure for defining specific properties' grouping params.\n * @public\n */\ninterface ECSqlSelectClausePropertyGroup {\n /** A string indicating the name of the property to group by. */\n propertyName: string;\n /** Alias to of the class containing the property. Used to select the property value. */\n propertyClassAlias: string;\n /** Ranges are used to group nodes by numeric properties which are within specified bounds. */\n ranges?: ECSqlSelectClausePropertyValueRange[];\n}\n\n/**\n * A data structure for defining boundaries for a value.\n * @public\n */\ninterface ECSqlSelectClausePropertyValueRange {\n /** Defines the lower bound of the range. */\n fromValue: number | ECSqlValueSelector;\n /** Defines the upper bound of the range. */\n toValue: number | ECSqlValueSelector;\n /** Defines the range label. Will be used as grouping node's display label. */\n rangeLabel?: string | ECSqlValueSelector;\n}\n\n/**\n * A data structure for defining base class grouping.\n * @public\n */\ninterface ECSqlSelectClauseBaseClassGroupingParams extends ECSqlSelectClauseGroupingParamsBase {\n fullClassNames: string[] | ECSqlValueSelector[];\n}\n\n/**\n * An interface of a factory that knows how to create nodes' select ECSQL query.\n * @public\n */\nexport interface NodesQueryClauseFactory {\n /** Create a SELECT clause in a format understood by nodes query parser used by `HierarchyProvider`. */\n createSelectClause(props: NodeSelectClauseProps): Promise<string>;\n\n /**\n * Creates the necessary ECSQL snippets to create an instance filter described by the given `GenericInstanceFilter` argument.\n * - `from` is set to either the `contentClass.fullName` or one of `filter.propertyClassNames`, depending on which is more specific.\n * - `joins` is set to a number of `JOIN` clauses required to join all relationships described by `filter.relatedInstances`.\n * - `where` is set to a `WHERE` clause (without the `WHERE` keyword) that filters instances by classes on\n * `filter.filterClassNames` and by properties as described by `filter.rules`.\n *\n * Special cases:\n * - If `filter` is `undefined`, `joins` and `where` are set to empty strings and `from` is set to `contentClass.fullName`.\n * - If the provided content class doesn't intersect with the property class in provided filter, a special result\n * is returned to make sure the resulting query is valid and doesn't return anything.\n */\n createFilterClauses(props: {\n contentClass: { fullName: string; alias: string };\n filter: GenericInstanceFilter | undefined;\n }): Promise<{ from: string; where: string; joins: string }>;\n}\n\n/**\n * Creates an instance of `NodeSelectQueryFactory`.\n * @public\n */\nexport function createNodesQueryClauseFactory(props: {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector;\n instanceLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n}): NodesQueryClauseFactory {\n return new NodeSelectQueryFactory(props);\n}\n\n/** A factory for creating a nodes' select ECSQL query. */\nclass NodeSelectQueryFactory {\n private _imodelAccess: ECSchemaProvider & ECClassHierarchyInspector;\n private _instanceLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n\n public constructor(props: {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector;\n instanceLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n }) {\n this._imodelAccess = props.imodelAccess;\n this._instanceLabelSelectClauseFactory = props.instanceLabelSelectClauseFactory;\n }\n\n /** Create a SELECT clause in a format understood by results reader of the library. */\n public async createSelectClause(props: NodeSelectClauseProps) {\n // note: the columns order must match the order in `NodeSelectClauseColumnNames`\n return `\n ec_ClassName(${props.ecClassId.selector}) AS ${NodeSelectClauseColumnNames.FullClassName},\n ${props.ecInstanceId.selector} AS ${NodeSelectClauseColumnNames.ECInstanceId},\n ${createECSqlValueSelector(props.nodeLabel)} AS ${NodeSelectClauseColumnNames.DisplayLabel},\n CAST(${createECSqlValueSelector(props.hasChildren)} AS BOOLEAN) AS ${NodeSelectClauseColumnNames.HasChildren},\n CAST(${createECSqlValueSelector(props.hideIfNoChildren)} AS BOOLEAN) AS ${NodeSelectClauseColumnNames.HideIfNoChildren},\n CAST(${createECSqlValueSelector(props.hideNodeInHierarchy)} AS BOOLEAN) AS ${NodeSelectClauseColumnNames.HideNodeInHierarchy},\n ${props.grouping ? await createGroupingSelector(props.grouping, this._imodelAccess, this._instanceLabelSelectClauseFactory) : \"CAST(NULL AS TEXT)\"} AS ${NodeSelectClauseColumnNames.Grouping},\n ${\n props.extendedData\n ? `json_object(${Object.entries(props.extendedData)\n .map(([key, value]) => `'${key}', ${createECSqlValueSelector(value)}`)\n .join(\", \")})`\n : \"CAST(NULL AS TEXT)\"\n } AS ${NodeSelectClauseColumnNames.ExtendedData},\n CAST(${createECSqlValueSelector(props.autoExpand)} AS BOOLEAN) AS ${NodeSelectClauseColumnNames.AutoExpand},\n CAST(${createECSqlValueSelector(props.supportsFiltering)} AS BOOLEAN) AS ${NodeSelectClauseColumnNames.SupportsFiltering}\n `;\n }\n\n /**\n * Creates the necessary ECSQL snippets to create an instance filter described by the `filter` argument.\n * - `from` is set to either the `contentClass.fullName` or one of `filter.propertyClassNames`, depending on which is more specific.\n * - `joins` is set to a number of `JOIN` clauses required to join all relationships described by `filter.relatedInstances`.\n * - `where` is set to a `WHERE` clause (without the `WHERE` keyword) that filters instances by classes on\n * `filter.filterClassNames` and by properties as described by `filter.rules`.\n *\n * Special cases:\n * - If `filter` is `undefined`, `joins` and `where` are set to empty strings and `from` is set to `contentClass.fullName`.\n * - If the provided content class doesn't intersect with the property class in provided filter, a special result\n * is returned to make sure the resulting query is valid and doesn't return anything.\n */\n public async createFilterClauses(props: {\n contentClass: { fullName: string; alias: string };\n filter: GenericInstanceFilter | undefined;\n }): Promise<{ from: string; where: string; joins: string }> {\n const { contentClass, filter } = props;\n if (!filter) {\n // undefined filter means we don't want any filtering to be applied\n return { from: contentClass.fullName, joins: \"\", where: \"\" };\n }\n\n const from = await specializeContentClass({\n classHierarchyInspector: this._imodelAccess,\n contentClassName: contentClass.fullName,\n filterClassNames: filter.propertyClassNames,\n });\n if (!from) {\n // filter class doesn't intersect with content class - make sure the query returns nothing by returning a `FALSE` WHERE clause\n return { from: contentClass.fullName, joins: \"\", where: \"FALSE\" };\n }\n\n /**\n * TODO:\n * There may be similar related instance paths, e.g.:\n * - A -> B -> C,\n * - A -> B -> D.\n * At this moment we're handling each path individually which means A and B would get joined twice. We could look into\n * creating a join tree first, e.g.\n * C\n * /\n * A -> B\n * \\\n * D\n */\n const joins = await Promise.all(\n filter.relatedInstances.map(async (rel, i) =>\n ECSql.createRelationshipPathJoinClause({\n schemaProvider: this._imodelAccess,\n path: assignRelationshipPathAliases(rel.path, i, contentClass.alias, rel.alias),\n }),\n ),\n );\n\n const whereConditions = new Array<string>();\n if (filter.filteredClassNames && filter.filteredClassNames.length > 0) {\n whereConditions.push(\n `${ECSql.createRawPropertyValueSelector(contentClass.alias, \"ECClassId\")} IS (\n ${filter.filteredClassNames\n .map(parseFullClassName)\n .map(({ schemaName, className }) => `[${schemaName}].[${className}]`)\n .join(\", \")}\n )`,\n );\n }\n const classAliasMap = new Map<string, string>([[contentClass.alias, from]]);\n filter.relatedInstances.forEach(({ path, alias }) => path.length > 0 && classAliasMap.set(alias, path[path.length - 1].targetClassName));\n const propertiesFilter = await createWhereClause(\n contentClass.alias,\n async (alias) => {\n const aliasClassName = classAliasMap.get(alias);\n return aliasClassName ? getClass(this._imodelAccess, aliasClassName) : undefined;\n },\n filter.rules,\n );\n if (propertiesFilter) {\n whereConditions.push(propertiesFilter);\n }\n\n return {\n from,\n joins: joins.join(\"\\n\"),\n where: whereConditions.join(\" AND \"),\n };\n }\n}\n\nfunction createECSqlValueSelector(input: undefined | PrimitiveValue | ECSqlValueSelector) {\n if (input === undefined) {\n return \"NULL\";\n }\n if (isSelector(input)) {\n return input.selector;\n }\n return ECSql.createRawPrimitiveValueSelector(input);\n}\n\nfunction isSelector(x: any): x is ECSqlValueSelector {\n return !!x.selector;\n}\n\nasync function createGroupingSelector(\n grouping: ECSqlSelectClauseGroupingParams,\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector,\n instanceLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory,\n): Promise<string> {\n const groupingSelectors = new Array<{ key: string; selector: string }>();\n\n grouping.byLabel &&\n groupingSelectors.push({\n key: \"byLabel\",\n selector:\n typeof grouping.byLabel === \"boolean\" || isSelector(grouping.byLabel)\n ? createECSqlValueSelector(grouping.byLabel)\n : serializeJsonObject(createLabelGroupingBaseParamsSelectors(grouping.byLabel)),\n });\n\n grouping.byClass &&\n groupingSelectors.push({\n key: \"byClass\",\n selector:\n typeof grouping.byClass === \"boolean\" || isSelector(grouping.byClass)\n ? createECSqlValueSelector(grouping.byClass)\n : serializeJsonObject(createBaseGroupingParamSelectors(grouping.byClass)),\n });\n\n grouping.byBaseClasses &&\n groupingSelectors.push({\n key: \"byBaseClasses\",\n selector: serializeJsonObject([\n {\n key: \"fullClassNames\",\n selector: `json_array(${grouping.byBaseClasses.fullClassNames.map((className) => createECSqlValueSelector(className)).join(\", \")})`,\n },\n ...createBaseGroupingParamSelectors(grouping.byBaseClasses),\n ]),\n });\n\n if (grouping.byProperties) {\n const propertyClass = await getClass(imodelAccess, grouping.byProperties.propertiesClassName);\n groupingSelectors.push({\n key: \"byProperties\",\n selector: serializeJsonObject([\n {\n key: \"propertiesClassName\",\n selector: `${createECSqlValueSelector(grouping.byProperties.propertiesClassName)}`,\n },\n {\n key: \"propertyGroups\",\n selector: `json_array(${(\n await Promise.all(\n grouping.byProperties.propertyGroups.map(async (propertyGroup) =>\n serializeJsonObject(await createPropertyGroupSelectors(propertyGroup, propertyClass, instanceLabelSelectClauseFactory)),\n ),\n )\n ).join(\", \")})`,\n },\n ...(grouping.byProperties.createGroupForOutOfRangeValues !== undefined\n ? [\n {\n key: \"createGroupForOutOfRangeValues\",\n selector: `CAST(${createECSqlValueSelector(grouping.byProperties.createGroupForOutOfRangeValues)} AS BOOLEAN)`,\n },\n ]\n : []),\n ...(grouping.byProperties.createGroupForUnspecifiedValues !== undefined\n ? [\n {\n key: \"createGroupForUnspecifiedValues\",\n selector: `CAST(${createECSqlValueSelector(grouping.byProperties.createGroupForUnspecifiedValues)} AS BOOLEAN)`,\n },\n ]\n : []),\n ...createBaseGroupingParamSelectors(grouping.byProperties),\n ]),\n });\n }\n\n return serializeJsonObject(groupingSelectors);\n}\n\nfunction createLabelGroupingBaseParamsSelectors(byLabel: ECSqlSelectClauseLabelGroupingMergeParams | ECSqlSelectClauseLabelGroupingGroupParams) {\n const selectors = new Array<{ key: string; selector: string }>();\n if (byLabel.action !== undefined) {\n selectors.push({\n key: \"action\",\n selector: `${createECSqlValueSelector(byLabel.action)}`,\n });\n }\n if (byLabel.groupId !== undefined) {\n selectors.push({\n key: \"groupId\",\n selector: createECSqlValueSelector(byLabel.groupId),\n });\n }\n if (byLabel.action !== \"merge\") {\n selectors.push(...createBaseGroupingParamSelectors(byLabel));\n }\n\n return selectors;\n}\n\nasync function createPropertyGroupSelectors(\n propertyGroup: ECSqlSelectClausePropertyGroup,\n propertyClass: EC.Class,\n instanceLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory,\n) {\n const selectors = new Array<{ key: string; selector: string }>();\n selectors.push({\n key: \"propertyName\",\n selector: `${createECSqlValueSelector(propertyGroup.propertyName)}`,\n });\n\n const property = await propertyClass.getProperty(propertyGroup.propertyName);\n if (!property) {\n throw new Error(`Property \"${propertyGroup.propertyName}\" not found in ECClass \"${propertyClass.fullName}\".`);\n }\n\n if (property.isNavigation()) {\n const relationshipClass = await property.relationshipClass;\n const abstractConstraint =\n property.direction === \"Forward\" ? await relationshipClass.target.abstractConstraint : await relationshipClass.source.abstractConstraint;\n if (!abstractConstraint) {\n throw new Error(`Could not determine class name for navigation property with direction \"${property.direction}\".`);\n }\n\n const fullName = abstractConstraint.fullName;\n const targetAlias = \"target\";\n selectors.push({\n key: \"propertyValue\",\n selector: `(\n SELECT ${await instanceLabelSelectClauseFactory.createSelectClause({ className: fullName, classAlias: targetAlias })}\n FROM ${fullName} AS ${targetAlias}\n WHERE [${targetAlias}].[ECInstanceId] = [${propertyGroup.propertyClassAlias}].[${propertyGroup.propertyName}].[Id]\n )`,\n });\n } else {\n selectors.push({\n key: \"propertyValue\",\n selector: `[${propertyGroup.propertyClassAlias}].[${propertyGroup.propertyName}]`,\n });\n }\n\n if (propertyGroup.ranges) {\n selectors.push(createRangeParamSelectors(propertyGroup.ranges));\n }\n\n return selectors;\n}\n\nfunction createRangeParamSelectors(ranges: ECSqlSelectClausePropertyValueRange[]) {\n return {\n key: \"ranges\",\n selector: `json_array(${ranges\n .map((range) =>\n serializeJsonObject([\n {\n key: \"fromValue\",\n selector: createECSqlValueSelector(range.fromValue),\n },\n {\n key: \"toValue\",\n selector: createECSqlValueSelector(range.toValue),\n },\n ...(range.rangeLabel\n ? [\n {\n key: \"rangeLabel\",\n selector: `${createECSqlValueSelector(range.rangeLabel)}`,\n },\n ]\n : []),\n ]),\n )\n .join(\", \")})`,\n };\n}\n\nfunction createBaseGroupingParamSelectors(params: ECSqlSelectClauseGroupingParamsBase) {\n const selectors = new Array<{ key: string; selector: string }>();\n if (params.hideIfNoSiblings !== undefined) {\n selectors.push({\n key: \"hideIfNoSiblings\",\n selector: createECSqlValueSelector(params.hideIfNoSiblings),\n });\n }\n if (params.hideIfOneGroupedNode !== undefined) {\n selectors.push({\n key: \"hideIfOneGroupedNode\",\n selector: createECSqlValueSelector(params.hideIfOneGroupedNode),\n });\n }\n if (params.autoExpand !== undefined) {\n selectors.push({\n key: \"autoExpand\",\n selector: createECSqlValueSelector(params.autoExpand),\n });\n }\n return selectors;\n}\n\nfunction serializeJsonObject(selectors: Array<{ key: string; selector: string }>): string {\n return `json_object(${selectors.map(({ key, selector }) => `'${key}', ${selector}`).join(\", \")})`;\n}\n\nasync function createWhereClause(\n contentClassAlias: string,\n classLoader: (alias: string) => Promise<EC.Class | undefined>,\n rule: GenericInstanceFilterRule | GenericInstanceFilterRuleGroup,\n): Promise<string | undefined> {\n if (GenericInstanceFilter.isFilterRuleGroup(rule)) {\n const clause = (await Promise.all(rule.rules.map(async (r) => createWhereClause(contentClassAlias, classLoader, r))))\n .filter((c) => !!c)\n .join(` ${getECSqlLogicalOperator(rule.operator)} `);\n return clause ? (rule.operator === \"or\" ? `(${clause})` : clause) : undefined;\n }\n const sourceAlias = rule.sourceAlias ? rule.sourceAlias : contentClassAlias;\n const propertyValueSelector = ECSql.createRawPropertyValueSelector(sourceAlias, rule.propertyName);\n if (isUnaryRuleOperator(rule.operator)) {\n switch (rule.operator) {\n case \"is-true\":\n return propertyValueSelector;\n case \"is-false\":\n return `NOT ${propertyValueSelector}`;\n case \"is-null\":\n return `${propertyValueSelector} IS NULL`;\n case \"is-not-null\":\n return `${propertyValueSelector} IS NOT NULL`;\n }\n }\n const ecsqlOperator = getECSqlComparisonOperator(rule.operator);\n if (rule.value === undefined) {\n throw new Error(`Rule \"${rule.propertyName}\" ${ecsqlOperator} is missing value.`);\n }\n\n const value = rule.value.rawValue;\n\n if (rule.operator === \"like\" && typeof value === \"string\") {\n const escapedValue = value.replace(/[%_\\\\]/g, \"\\\\$&\");\n return `${propertyValueSelector} ${ecsqlOperator} '%${escapedValue}%' ESCAPE '\\\\'`;\n }\n const propertyClass = await classLoader(sourceAlias);\n if (!propertyClass) {\n throw new Error(`Class with alias \"${sourceAlias}\" not found.`);\n }\n const property = await propertyClass.getProperty(rule.propertyName);\n if (!property) {\n throw new Error(`Property \"${rule.propertyName}\" not found in ECClass \"${propertyClass.fullName}\".`);\n }\n if (property.isNavigation()) {\n assert(rule.value !== undefined && GenericInstanceFilterRuleValue.isInstanceKey(value));\n return `${propertyValueSelector}.[Id] ${ecsqlOperator} ${ECSql.createRawPrimitiveValueSelector(value.id)}`;\n }\n if (property.isEnumeration()) {\n assert(rule.value !== undefined && !GenericInstanceFilterRuleValue.isInstanceKey(value));\n return `${propertyValueSelector} ${ecsqlOperator} ${ECSql.createRawPrimitiveValueSelector(value)}`;\n }\n if (property.isPrimitive()) {\n assert(rule.value !== undefined && !GenericInstanceFilterRuleValue.isInstanceKey(value));\n switch (property.primitiveType) {\n case \"Point2d\": {\n assert(rule.operator === \"is-equal\" || rule.operator === \"is-not-equal\");\n assert(PrimitiveValue.isPoint2d(value));\n const condition = `\n ${createFloatingPointEqualityClause(`${propertyValueSelector}.[x]`, \"is-equal\", value.x)}\n AND ${createFloatingPointEqualityClause(`${propertyValueSelector}.[y]`, \"is-equal\", value.y)}\n `;\n return rule.operator === \"is-equal\" ? condition : `NOT (${condition})`;\n }\n case \"Point3d\": {\n assert(rule.operator === \"is-equal\" || rule.operator === \"is-not-equal\");\n assert(PrimitiveValue.isPoint3d(value));\n const condition = `\n ${createFloatingPointEqualityClause(`${propertyValueSelector}.[x]`, \"is-equal\", value.x)}\n AND ${createFloatingPointEqualityClause(`${propertyValueSelector}.[y]`, \"is-equal\", value.y)}\n AND ${createFloatingPointEqualityClause(`${propertyValueSelector}.[z]`, \"is-equal\", value.z)}\n `;\n return rule.operator === \"is-equal\" ? condition : `NOT (${condition})`;\n }\n case \"Double\": {\n assert(typeof value === \"number\");\n if (rule.operator === \"is-equal\" || rule.operator === \"is-not-equal\") {\n return `${createFloatingPointEqualityClause(propertyValueSelector, rule.operator, value)}`;\n }\n return `${propertyValueSelector} ${ecsqlOperator} ${ECSql.createRawPrimitiveValueSelector(value)}`;\n }\n default: {\n return `${propertyValueSelector} ${ecsqlOperator} ${ECSql.createRawPrimitiveValueSelector(value)}`;\n }\n }\n }\n throw new Error(\"Struct and array properties are not supported for filtering\");\n}\n\nfunction createFloatingPointEqualityClause(valueSelector: string, operator: \"is-equal\" | \"is-not-equal\", value: number) {\n const [from, to] = getFloatingPointValueRange(value);\n return `${valueSelector} ${operator === \"is-not-equal\" ? \"NOT \" : \"\"} BETWEEN ${from} AND ${to}`;\n}\n\nfunction getFloatingPointValueRange(value: number): [number, number] {\n return [value - Number.EPSILON, value + Number.EPSILON];\n}\n\nfunction getECSqlLogicalOperator(op: GenericInstanceFilterRuleGroupOperator) {\n switch (op) {\n case \"and\":\n return \"AND\";\n case \"or\":\n return \"OR\";\n }\n}\n\nfunction isUnaryRuleOperator(\n op: GenericInstanceFilterRuleOperator,\n): op is Extract<GenericInstanceFilterRuleOperator, \"is-true\" | \"is-false\" | \"is-null\" | \"is-not-null\"> {\n return op === \"is-true\" || op === \"is-false\" || op === \"is-null\" || op === \"is-not-null\";\n}\n\nfunction getECSqlComparisonOperator(op: Exclude<GenericInstanceFilterRuleOperator, \"is-true\" | \"is-false\" | \"is-null\" | \"is-not-null\">) {\n switch (op) {\n case \"is-equal\":\n return `=`;\n case \"is-not-equal\":\n return `<>`;\n case \"greater\":\n return `>`;\n case \"greater-or-equal\":\n return `>=`;\n case \"less\":\n return `<`;\n case \"less-or-equal\":\n return `<=`;\n case \"like\":\n return `LIKE`;\n }\n}\n\ntype JoinRelationshipPath = Props<typeof ECSql.createRelationshipPathJoinClause>[\"path\"];\nfunction assignRelationshipPathAliases(\n path: GenericInstanceFilterRelationshipStep[],\n pathIndex: number,\n sourceAlias: string,\n targetAlias: string,\n): JoinRelationshipPath {\n function createAlias(fullClassName: string, index: number) {\n return `rel_${pathIndex}_${fullClassName.replaceAll(/[\\.:]/g, \"_\")}_${index}`;\n }\n const result: JoinRelationshipPath = [];\n path.forEach((step, i) => {\n result.push({\n targetClassName: step.targetClassName,\n relationshipName: step.relationshipClassName,\n sourceClassName: step.sourceClassName,\n relationshipReverse: !step.isForwardRelationship,\n sourceAlias: i === 0 ? sourceAlias : result[i - 1].targetAlias,\n relationshipAlias: createAlias(step.relationshipClassName, i),\n targetAlias: i === path.length - 1 ? targetAlias : createAlias(step.targetClassName, i),\n joinType: \"inner\",\n });\n });\n return result;\n}\n\ninterface SpecializeContentClassProps {\n classHierarchyInspector: ECClassHierarchyInspector;\n contentClassName: string;\n filterClassNames: string[];\n}\nasync function specializeContentClass(props: SpecializeContentClassProps): Promise<string | undefined> {\n const filterClass = await getSpecializedPropertyClass(props.classHierarchyInspector, props.filterClassNames);\n if (!filterClass) {\n return props.contentClassName;\n }\n if (await props.classHierarchyInspector.classDerivesFrom(filterClass, props.contentClassName)) {\n return filterClass;\n }\n if (await props.classHierarchyInspector.classDerivesFrom(props.contentClassName, filterClass)) {\n return props.contentClassName;\n }\n return undefined;\n}\n\nasync function getSpecializedPropertyClass(classHierarchyInspector: ECClassHierarchyInspector, classes: string[]): Promise<string | undefined> {\n if (classes.length === 0) {\n return undefined;\n }\n const [currClassName, ...restClasses] = classes;\n let resolvedClassName = currClassName;\n for (const propClassName of restClasses) {\n if (await classHierarchyInspector.classDerivesFrom(propClassName, resolvedClassName)) {\n resolvedClassName = propClassName;\n }\n }\n return resolvedClassName;\n}\n"]}
|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AE,CAAC;QACjB,OAAO,KAAK,CAAC,gBAAgB,CAAC;IAChC,CAAC;IACD,IAAI,MAAM,KAAK,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,WAAW,EAAE,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC9F,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,IAAI,MAAM,KAAK,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,KAAK,CAAC,gBAAgB,EAAE,WAAW,CAAC,EAAE,CAAC;QAC9F,OAAO,KAAK,CAAC,gBAAgB,CAAC;IAChC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,KAAK,UAAU,2BAA2B,CAAC,uBAAkD,EAAE,OAAiB;IAC9G,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,CAAC,aAAa,EAAE,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC;IAChD,IAAI,iBAAiB,GAAG,aAAa,CAAC;IACtC,KAAK,MAAM,aAAa,IAAI,WAAW,EAAE,CAAC;QACxC,IAAI,MAAM,uBAAuB,CAAC,gBAAgB,CAAC,aAAa,EAAE,iBAAiB,CAAC,EAAE,CAAC;YACrF,iBAAiB,GAAG,aAAa,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,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 { assert, Id64String } from \"@itwin/core-bentley\";\nimport {\n GenericInstanceFilter,\n GenericInstanceFilterRelationshipStep,\n GenericInstanceFilterRule,\n GenericInstanceFilterRuleGroup,\n GenericInstanceFilterRuleGroupOperator,\n GenericInstanceFilterRuleOperator,\n GenericInstanceFilterRuleValue,\n} from \"@itwin/core-common\";\nimport {\n EC,\n ECClassHierarchyInspector,\n ECSchemaProvider,\n ECSql,\n getClass,\n IInstanceLabelSelectClauseFactory,\n parseFullClassName,\n PrimitiveValue,\n Props,\n} from \"@itwin/presentation-shared\";\nimport { HierarchyNodeAutoExpandProp } from \"./IModelHierarchyNode.js\";\n\n/**\n * Column names of the SELECT clause created by `NodeSelectClauseFactory`. Order of the names matches the order of columns\n * created by the factory.\n *\n * @public\n */\nexport enum NodeSelectClauseColumnNames {\n /** Full class name of the instance the node represents. Type: `string` in format `{schema name}:{class name}`. */\n FullClassName = \"FullClassName\",\n /** ECInstance ID of the instance the node represents. Type: `Id64String`. */\n ECInstanceId = \"ECInstanceId\",\n /** Display label. Type: `string`. */\n DisplayLabel = \"DisplayLabel\",\n /**\n * A flag indicating if the node has children. Type: `boolean`. Values:\n * - `false` - node never has children.\n * - `true` - node always has children.\n * - NULL - unknown, needs to be determined by requesting children for the node.\n */\n HasChildren = \"HasChildren\",\n /** A flag indicating that a node should be hidden if it has no children. Type: `boolean`. */\n HideIfNoChildren = \"HideIfNoChildren\",\n /** A flag indicating that a node should be hidden and its children should be displayed instead. Type: `boolean`. */\n HideNodeInHierarchy = \"HideNodeInHierarchy\",\n /** A serialized JSON object for providing grouping information. */\n Grouping = \"Grouping\",\n /** A serialized JSON object for associating a node with additional data. */\n ExtendedData = \"ExtendedData\",\n /** A flag indicating the node should be auto-expanded when it's loaded. */\n AutoExpand = \"AutoExpand\",\n /** A flag indicating the node supports child hierarchy level filtering. */\n SupportsFiltering = \"SupportsFiltering\",\n}\n\n/**\n * A data structure for defining an ECSQL value selector.\n * @public\n */\ninterface ECSqlValueSelector {\n selector: string;\n}\n\n/**\n * Props for `NodeSelectClauseFactory.createSelectClause`.\n * @public\n */\ninterface NodeSelectClauseProps {\n ecClassId: ECSqlValueSelector;\n ecInstanceId: ECSqlValueSelector;\n nodeLabel: string | ECSqlValueSelector;\n extendedData?: {\n [key: string]: Id64String | string | number | boolean | ECSqlValueSelector;\n };\n autoExpand?: boolean | ECSqlValueSelector;\n supportsFiltering?: boolean | ECSqlValueSelector;\n hasChildren?: boolean | ECSqlValueSelector;\n hideNodeInHierarchy?: boolean | ECSqlValueSelector;\n hideIfNoChildren?: boolean | ECSqlValueSelector;\n grouping?: ECSqlSelectClauseGroupingParams;\n}\n\n/**\n * A data structure for defining nodes' grouping requirements.\n * @public\n */\ninterface ECSqlSelectClauseGroupingParams {\n byLabel?: ECSqlSelectClauseLabelGroupingParams;\n byClass?: boolean | ECSqlSelectClauseGroupingParamsBase | ECSqlValueSelector;\n byBaseClasses?: ECSqlSelectClauseBaseClassGroupingParams;\n byProperties?: ECSqlSelectClausePropertiesGroupingParams;\n}\n\n/**\n * A data structure for defining label grouping params.\n * @public\n */\ninterface ECSqlSelectClauseLabelGroupingBaseParams {\n /** Label grouping option that determines whether to group nodes or to merge them. Defaults to \"group\".*/\n action?: \"group\" | \"merge\";\n /** Id that needs to match for nodes to be grouped or merged.*/\n groupId?: string | ECSqlValueSelector;\n}\n\n/**\n * A data structure for defining label merging.\n * @public\n */\ninterface ECSqlSelectClauseLabelGroupingMergeParams extends ECSqlSelectClauseLabelGroupingBaseParams {\n action: \"merge\";\n}\n\n/**\n * A data structure for defining label grouping.\n * @public\n */\ninterface ECSqlSelectClauseLabelGroupingGroupParams extends ECSqlSelectClauseLabelGroupingBaseParams, ECSqlSelectClauseGroupingParamsBase {\n action?: \"group\";\n}\n\n/**\n * A data structure for defining possible label grouping types.\n * @public\n */\ntype ECSqlSelectClauseLabelGroupingParams =\n | boolean\n | ECSqlValueSelector\n | ECSqlSelectClauseLabelGroupingMergeParams\n | ECSqlSelectClauseLabelGroupingGroupParams;\n\n/**\n * A data structure for defining base grouping parameters shared across all types of grouping.\n * @public\n */\ninterface ECSqlSelectClauseGroupingParamsBase {\n hideIfNoSiblings?: boolean | ECSqlValueSelector;\n hideIfOneGroupedNode?: boolean | ECSqlValueSelector;\n autoExpand?: HierarchyNodeAutoExpandProp | ECSqlValueSelector;\n}\n\n/**\n * A data structure for defining properties grouping.\n * @public\n */\ninterface ECSqlSelectClausePropertiesGroupingParams extends ECSqlSelectClauseGroupingParamsBase {\n /**\n * Full name of a class whose properties are used to group the node. Only has effect if the node\n * represents an instance of that class.\n *\n * Full class name format: `SchemaName.ClassName`.\n */\n propertiesClassName: string;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value is not set or is set to an empty string.\n *\n * Label of the created grouping node will be `Not Specified`.\n */\n createGroupForUnspecifiedValues?: boolean | ECSqlValueSelector;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value doesn't fit within any of the provided\n * ranges, or is not a numeric value.\n *\n * Label of the created grouping node will be `Other`.\n */\n createGroupForOutOfRangeValues?: boolean | ECSqlValueSelector;\n /**\n * Properties of the specified class, by which the nodes should be grouped.\n *\n * Example usage:\n * ```ts\n * propertyGroups: [\n * {\n * propertyName: \"type\",\n * propertyClassAlias: \"this\"\n * },\n * {\n * propertyName: \"length\",\n * propertyClassAlias: \"x\",\n * ranges: [\n * { fromValue: 1, toValue: 10, rangeLabel: \"Small\" },\n * { fromValue: 11, toValue: 20, rangeLabel: \"Medium\" }\n * ]\n * },\n * ]\n * ```\n */\n propertyGroups: ECSqlSelectClausePropertyGroup[];\n}\n\n/**\n * A data structure for defining specific properties' grouping params.\n * @public\n */\ninterface ECSqlSelectClausePropertyGroup {\n /** A string indicating the name of the property to group by. */\n propertyName: string;\n /** Alias to of the class containing the property. Used to select the property value. */\n propertyClassAlias: string;\n /** Ranges are used to group nodes by numeric properties which are within specified bounds. */\n ranges?: ECSqlSelectClausePropertyValueRange[];\n}\n\n/**\n * A data structure for defining boundaries for a value.\n * @public\n */\ninterface ECSqlSelectClausePropertyValueRange {\n /** Defines the lower bound of the range. */\n fromValue: number | ECSqlValueSelector;\n /** Defines the upper bound of the range. */\n toValue: number | ECSqlValueSelector;\n /** Defines the range label. Will be used as grouping node's display label. */\n rangeLabel?: string | ECSqlValueSelector;\n}\n\n/**\n * A data structure for defining base class grouping.\n * @public\n */\ninterface ECSqlSelectClauseBaseClassGroupingParams extends ECSqlSelectClauseGroupingParamsBase {\n fullClassNames: string[] | ECSqlValueSelector[];\n}\n\n/**\n * An interface of a factory that knows how to create nodes' select ECSQL query.\n * @public\n */\nexport interface NodesQueryClauseFactory {\n /** Create a SELECT clause in a format understood by nodes query parser used by `HierarchyProvider`. */\n createSelectClause(props: NodeSelectClauseProps): Promise<string>;\n\n /**\n * Creates the necessary ECSQL snippets to create an instance filter described by the given `GenericInstanceFilter` argument.\n * - `from` is set to either the `contentClass.fullName` or one of `filter.propertyClassNames`, depending on which is more specific.\n * - `joins` is set to a number of `JOIN` clauses required to join all relationships described by `filter.relatedInstances`.\n * - `where` is set to a `WHERE` clause (without the `WHERE` keyword) that filters instances by classes on\n * `filter.filterClassNames` and by properties as described by `filter.rules`.\n *\n * Special cases:\n * - If `filter` is `undefined`, `joins` and `where` are set to empty strings and `from` is set to `contentClass.fullName`.\n * - If the provided content class doesn't intersect with the property class in provided filter, a special result\n * is returned to make sure the resulting query is valid and doesn't return anything.\n */\n createFilterClauses(props: {\n contentClass: { fullName: string; alias: string };\n filter: GenericInstanceFilter | undefined;\n }): Promise<{ from: string; where: string; joins: string }>;\n}\n\n/**\n * Creates an instance of `NodeSelectQueryFactory`.\n * @public\n */\nexport function createNodesQueryClauseFactory(props: {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector;\n instanceLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n}): NodesQueryClauseFactory {\n return new NodeSelectQueryFactory(props);\n}\n\n/** A factory for creating a nodes' select ECSQL query. */\nclass NodeSelectQueryFactory {\n private _imodelAccess: ECSchemaProvider & ECClassHierarchyInspector;\n private _instanceLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n\n public constructor(props: {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector;\n instanceLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n }) {\n this._imodelAccess = props.imodelAccess;\n this._instanceLabelSelectClauseFactory = props.instanceLabelSelectClauseFactory;\n }\n\n /** Create a SELECT clause in a format understood by results reader of the library. */\n public async createSelectClause(props: NodeSelectClauseProps) {\n // note: the columns order must match the order in `NodeSelectClauseColumnNames`\n return `\n ec_ClassName(${props.ecClassId.selector}) AS ${NodeSelectClauseColumnNames.FullClassName},\n ${props.ecInstanceId.selector} AS ${NodeSelectClauseColumnNames.ECInstanceId},\n ${createECSqlValueSelector(props.nodeLabel)} AS ${NodeSelectClauseColumnNames.DisplayLabel},\n CAST(${createECSqlValueSelector(props.hasChildren)} AS BOOLEAN) AS ${NodeSelectClauseColumnNames.HasChildren},\n CAST(${createECSqlValueSelector(props.hideIfNoChildren)} AS BOOLEAN) AS ${NodeSelectClauseColumnNames.HideIfNoChildren},\n CAST(${createECSqlValueSelector(props.hideNodeInHierarchy)} AS BOOLEAN) AS ${NodeSelectClauseColumnNames.HideNodeInHierarchy},\n ${props.grouping ? await createGroupingSelector(props.grouping, this._imodelAccess, this._instanceLabelSelectClauseFactory) : \"CAST(NULL AS TEXT)\"} AS ${NodeSelectClauseColumnNames.Grouping},\n ${\n props.extendedData\n ? `json_object(${Object.entries(props.extendedData)\n .map(([key, value]) => `'${key}', ${createECSqlValueSelector(value)}`)\n .join(\", \")})`\n : \"CAST(NULL AS TEXT)\"\n } AS ${NodeSelectClauseColumnNames.ExtendedData},\n CAST(${createECSqlValueSelector(props.autoExpand)} AS BOOLEAN) AS ${NodeSelectClauseColumnNames.AutoExpand},\n CAST(${createECSqlValueSelector(props.supportsFiltering)} AS BOOLEAN) AS ${NodeSelectClauseColumnNames.SupportsFiltering}\n `;\n }\n\n /**\n * Creates the necessary ECSQL snippets to create an instance filter described by the `filter` argument.\n * - `from` is set to either the `contentClass.fullName` or one of `filter.propertyClassNames`, depending on which is more specific.\n * - `joins` is set to a number of `JOIN` clauses required to join all relationships described by `filter.relatedInstances`.\n * - `where` is set to a `WHERE` clause (without the `WHERE` keyword) that filters instances by classes on\n * `filter.filterClassNames` and by properties as described by `filter.rules`.\n *\n * Special cases:\n * - If `filter` is `undefined`, `joins` and `where` are set to empty strings and `from` is set to `contentClass.fullName`.\n * - If the provided content class doesn't intersect with the property class in provided filter, a special result\n * is returned to make sure the resulting query is valid and doesn't return anything.\n */\n public async createFilterClauses(props: {\n contentClass: { fullName: string; alias: string };\n filter: GenericInstanceFilter | undefined;\n }): Promise<{ from: string; where: string; joins: string }> {\n const { contentClass, filter } = props;\n if (!filter) {\n // undefined filter means we don't want any filtering to be applied\n return { from: contentClass.fullName, joins: \"\", where: \"\" };\n }\n\n const from = await specializeContentClass({\n classHierarchyInspector: this._imodelAccess,\n contentClassName: contentClass.fullName,\n filterClassNames: filter.propertyClassNames,\n });\n if (!from) {\n // filter class doesn't intersect with content class - make sure the query returns nothing by returning a `FALSE` WHERE clause\n return { from: contentClass.fullName, joins: \"\", where: \"FALSE\" };\n }\n\n /**\n * TODO:\n * There may be similar related instance paths, e.g.:\n * - A -> B -> C,\n * - A -> B -> D.\n * At this moment we're handling each path individually which means A and B would get joined twice. We could look into\n * creating a join tree first, e.g.\n * C\n * /\n * A -> B\n * \\\n * D\n */\n const joins = await Promise.all(\n filter.relatedInstances.map(async (rel, i) =>\n ECSql.createRelationshipPathJoinClause({\n schemaProvider: this._imodelAccess,\n path: assignRelationshipPathAliases(rel.path, i, contentClass.alias, rel.alias),\n }),\n ),\n );\n\n const whereConditions = new Array<string>();\n if (filter.filteredClassNames && filter.filteredClassNames.length > 0) {\n whereConditions.push(\n `${ECSql.createRawPropertyValueSelector(contentClass.alias, \"ECClassId\")} IS (\n ${filter.filteredClassNames\n .map(parseFullClassName)\n .map(({ schemaName, className }) => `[${schemaName}].[${className}]`)\n .join(\", \")}\n )`,\n );\n }\n const classAliasMap = new Map<string, string>([[contentClass.alias, from]]);\n filter.relatedInstances.forEach(({ path, alias }) => path.length > 0 && classAliasMap.set(alias, path[path.length - 1].targetClassName));\n const propertiesFilter = await createWhereClause(\n contentClass.alias,\n async (alias) => {\n const aliasClassName = classAliasMap.get(alias);\n return aliasClassName ? getClass(this._imodelAccess, aliasClassName) : undefined;\n },\n filter.rules,\n );\n if (propertiesFilter) {\n whereConditions.push(propertiesFilter);\n }\n\n return {\n from,\n joins: joins.join(\"\\n\"),\n where: whereConditions.join(\" AND \"),\n };\n }\n}\n\nfunction createECSqlValueSelector(input: undefined | PrimitiveValue | ECSqlValueSelector) {\n if (input === undefined) {\n return \"NULL\";\n }\n if (isSelector(input)) {\n return input.selector;\n }\n return ECSql.createRawPrimitiveValueSelector(input);\n}\n\nfunction isSelector(x: any): x is ECSqlValueSelector {\n return !!x.selector;\n}\n\nasync function createGroupingSelector(\n grouping: ECSqlSelectClauseGroupingParams,\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector,\n instanceLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory,\n): Promise<string> {\n const groupingSelectors = new Array<{ key: string; selector: string }>();\n\n grouping.byLabel &&\n groupingSelectors.push({\n key: \"byLabel\",\n selector:\n typeof grouping.byLabel === \"boolean\" || isSelector(grouping.byLabel)\n ? createECSqlValueSelector(grouping.byLabel)\n : serializeJsonObject(createLabelGroupingBaseParamsSelectors(grouping.byLabel)),\n });\n\n grouping.byClass &&\n groupingSelectors.push({\n key: \"byClass\",\n selector:\n typeof grouping.byClass === \"boolean\" || isSelector(grouping.byClass)\n ? createECSqlValueSelector(grouping.byClass)\n : serializeJsonObject(createBaseGroupingParamSelectors(grouping.byClass)),\n });\n\n grouping.byBaseClasses &&\n groupingSelectors.push({\n key: \"byBaseClasses\",\n selector: serializeJsonObject([\n {\n key: \"fullClassNames\",\n selector: `json_array(${grouping.byBaseClasses.fullClassNames.map((className) => createECSqlValueSelector(className)).join(\", \")})`,\n },\n ...createBaseGroupingParamSelectors(grouping.byBaseClasses),\n ]),\n });\n\n // TODO: MISSING_COVERAGE\n /* v8 ignore else -- @preserve */\n if (grouping.byProperties) {\n const propertyClass = await getClass(imodelAccess, grouping.byProperties.propertiesClassName);\n groupingSelectors.push({\n key: \"byProperties\",\n selector: serializeJsonObject([\n {\n key: \"propertiesClassName\",\n selector: `${createECSqlValueSelector(grouping.byProperties.propertiesClassName)}`,\n },\n {\n key: \"propertyGroups\",\n selector: `json_array(${(\n await Promise.all(\n grouping.byProperties.propertyGroups.map(async (propertyGroup) =>\n serializeJsonObject(await createPropertyGroupSelectors(propertyGroup, propertyClass, instanceLabelSelectClauseFactory)),\n ),\n )\n ).join(\", \")})`,\n },\n ...(grouping.byProperties.createGroupForOutOfRangeValues !== undefined\n ? [\n {\n key: \"createGroupForOutOfRangeValues\",\n selector: `CAST(${createECSqlValueSelector(grouping.byProperties.createGroupForOutOfRangeValues)} AS BOOLEAN)`,\n },\n ]\n : []),\n ...(grouping.byProperties.createGroupForUnspecifiedValues !== undefined\n ? [\n {\n key: \"createGroupForUnspecifiedValues\",\n selector: `CAST(${createECSqlValueSelector(grouping.byProperties.createGroupForUnspecifiedValues)} AS BOOLEAN)`,\n },\n ]\n : []),\n ...createBaseGroupingParamSelectors(grouping.byProperties),\n ]),\n });\n }\n\n return serializeJsonObject(groupingSelectors);\n}\n\nfunction createLabelGroupingBaseParamsSelectors(byLabel: ECSqlSelectClauseLabelGroupingMergeParams | ECSqlSelectClauseLabelGroupingGroupParams) {\n const selectors = new Array<{ key: string; selector: string }>();\n if (byLabel.action !== undefined) {\n selectors.push({\n key: \"action\",\n selector: `${createECSqlValueSelector(byLabel.action)}`,\n });\n }\n if (byLabel.groupId !== undefined) {\n selectors.push({\n key: \"groupId\",\n selector: createECSqlValueSelector(byLabel.groupId),\n });\n }\n if (byLabel.action !== \"merge\") {\n selectors.push(...createBaseGroupingParamSelectors(byLabel));\n }\n\n return selectors;\n}\n\nasync function createPropertyGroupSelectors(\n propertyGroup: ECSqlSelectClausePropertyGroup,\n propertyClass: EC.Class,\n instanceLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory,\n) {\n const selectors = new Array<{ key: string; selector: string }>();\n selectors.push({\n key: \"propertyName\",\n selector: `${createECSqlValueSelector(propertyGroup.propertyName)}`,\n });\n\n const property = await propertyClass.getProperty(propertyGroup.propertyName);\n if (!property) {\n throw new Error(`Property \"${propertyGroup.propertyName}\" not found in ECClass \"${propertyClass.fullName}\".`);\n }\n\n if (property.isNavigation()) {\n const relationshipClass = await property.relationshipClass;\n const abstractConstraint =\n property.direction === \"Forward\" ? await relationshipClass.target.abstractConstraint : await relationshipClass.source.abstractConstraint;\n // TODO: MISSING_COVERAGE\n /* v8 ignore else -- @preserve */\n if (!abstractConstraint) {\n throw new Error(`Could not determine class name for navigation property with direction \"${property.direction}\".`);\n }\n\n const fullName = abstractConstraint.fullName;\n const targetAlias = \"target\";\n selectors.push({\n key: \"propertyValue\",\n selector: `(\n SELECT ${await instanceLabelSelectClauseFactory.createSelectClause({ className: fullName, classAlias: targetAlias })}\n FROM ${fullName} AS ${targetAlias}\n WHERE [${targetAlias}].[ECInstanceId] = [${propertyGroup.propertyClassAlias}].[${propertyGroup.propertyName}].[Id]\n )`,\n });\n } else {\n selectors.push({\n key: \"propertyValue\",\n selector: `[${propertyGroup.propertyClassAlias}].[${propertyGroup.propertyName}]`,\n });\n }\n\n if (propertyGroup.ranges) {\n selectors.push(createRangeParamSelectors(propertyGroup.ranges));\n }\n\n return selectors;\n}\n\nfunction createRangeParamSelectors(ranges: ECSqlSelectClausePropertyValueRange[]) {\n return {\n key: \"ranges\",\n selector: `json_array(${ranges\n .map((range) =>\n serializeJsonObject([\n {\n key: \"fromValue\",\n selector: createECSqlValueSelector(range.fromValue),\n },\n {\n key: \"toValue\",\n selector: createECSqlValueSelector(range.toValue),\n },\n ...(range.rangeLabel\n ? [\n {\n key: \"rangeLabel\",\n selector: `${createECSqlValueSelector(range.rangeLabel)}`,\n },\n ]\n : []),\n ]),\n )\n .join(\", \")})`,\n };\n}\n\nfunction createBaseGroupingParamSelectors(params: ECSqlSelectClauseGroupingParamsBase) {\n const selectors = new Array<{ key: string; selector: string }>();\n if (params.hideIfNoSiblings !== undefined) {\n selectors.push({\n key: \"hideIfNoSiblings\",\n selector: createECSqlValueSelector(params.hideIfNoSiblings),\n });\n }\n if (params.hideIfOneGroupedNode !== undefined) {\n selectors.push({\n key: \"hideIfOneGroupedNode\",\n selector: createECSqlValueSelector(params.hideIfOneGroupedNode),\n });\n }\n if (params.autoExpand !== undefined) {\n selectors.push({\n key: \"autoExpand\",\n selector: createECSqlValueSelector(params.autoExpand),\n });\n }\n return selectors;\n}\n\nfunction serializeJsonObject(selectors: Array<{ key: string; selector: string }>): string {\n return `json_object(${selectors.map(({ key, selector }) => `'${key}', ${selector}`).join(\", \")})`;\n}\n\nasync function createWhereClause(\n contentClassAlias: string,\n classLoader: (alias: string) => Promise<EC.Class | undefined>,\n rule: GenericInstanceFilterRule | GenericInstanceFilterRuleGroup,\n): Promise<string | undefined> {\n if (GenericInstanceFilter.isFilterRuleGroup(rule)) {\n const clause = (await Promise.all(rule.rules.map(async (r) => createWhereClause(contentClassAlias, classLoader, r))))\n .filter((c) => !!c)\n .join(` ${getECSqlLogicalOperator(rule.operator)} `);\n return clause ? (rule.operator === \"or\" ? `(${clause})` : clause) : undefined;\n }\n const sourceAlias = rule.sourceAlias ? rule.sourceAlias : contentClassAlias;\n const propertyValueSelector = ECSql.createRawPropertyValueSelector(sourceAlias, rule.propertyName);\n if (isUnaryRuleOperator(rule.operator)) {\n switch (rule.operator) {\n case \"is-true\":\n return propertyValueSelector;\n case \"is-false\":\n return `NOT ${propertyValueSelector}`;\n case \"is-null\":\n return `${propertyValueSelector} IS NULL`;\n case \"is-not-null\":\n return `${propertyValueSelector} IS NOT NULL`;\n }\n }\n const ecsqlOperator = getECSqlComparisonOperator(rule.operator);\n if (rule.value === undefined) {\n throw new Error(`Rule \"${rule.propertyName}\" ${ecsqlOperator} is missing value.`);\n }\n\n const value = rule.value.rawValue;\n\n if (rule.operator === \"like\" && typeof value === \"string\") {\n const escapedValue = value.replace(/[%_\\\\]/g, \"\\\\$&\");\n return `${propertyValueSelector} ${ecsqlOperator} '%${escapedValue}%' ESCAPE '\\\\'`;\n }\n const propertyClass = await classLoader(sourceAlias);\n if (!propertyClass) {\n throw new Error(`Class with alias \"${sourceAlias}\" not found.`);\n }\n const property = await propertyClass.getProperty(rule.propertyName);\n if (!property) {\n throw new Error(`Property \"${rule.propertyName}\" not found in ECClass \"${propertyClass.fullName}\".`);\n }\n if (property.isNavigation()) {\n assert(rule.value !== undefined && GenericInstanceFilterRuleValue.isInstanceKey(value));\n return `${propertyValueSelector}.[Id] ${ecsqlOperator} ${ECSql.createRawPrimitiveValueSelector(value.id)}`;\n }\n if (property.isEnumeration()) {\n assert(rule.value !== undefined && !GenericInstanceFilterRuleValue.isInstanceKey(value));\n return `${propertyValueSelector} ${ecsqlOperator} ${ECSql.createRawPrimitiveValueSelector(value)}`;\n }\n if (property.isPrimitive()) {\n assert(rule.value !== undefined && !GenericInstanceFilterRuleValue.isInstanceKey(value));\n switch (property.primitiveType) {\n case \"Point2d\": {\n assert(rule.operator === \"is-equal\" || rule.operator === \"is-not-equal\");\n assert(PrimitiveValue.isPoint2d(value));\n const condition = `\n ${createFloatingPointEqualityClause(`${propertyValueSelector}.[x]`, \"is-equal\", value.x)}\n AND ${createFloatingPointEqualityClause(`${propertyValueSelector}.[y]`, \"is-equal\", value.y)}\n `;\n return rule.operator === \"is-equal\" ? condition : `NOT (${condition})`;\n }\n case \"Point3d\": {\n assert(rule.operator === \"is-equal\" || rule.operator === \"is-not-equal\");\n assert(PrimitiveValue.isPoint3d(value));\n const condition = `\n ${createFloatingPointEqualityClause(`${propertyValueSelector}.[x]`, \"is-equal\", value.x)}\n AND ${createFloatingPointEqualityClause(`${propertyValueSelector}.[y]`, \"is-equal\", value.y)}\n AND ${createFloatingPointEqualityClause(`${propertyValueSelector}.[z]`, \"is-equal\", value.z)}\n `;\n return rule.operator === \"is-equal\" ? condition : `NOT (${condition})`;\n }\n case \"Double\": {\n assert(typeof value === \"number\");\n if (rule.operator === \"is-equal\" || rule.operator === \"is-not-equal\") {\n return `${createFloatingPointEqualityClause(propertyValueSelector, rule.operator, value)}`;\n }\n return `${propertyValueSelector} ${ecsqlOperator} ${ECSql.createRawPrimitiveValueSelector(value)}`;\n }\n default: {\n return `${propertyValueSelector} ${ecsqlOperator} ${ECSql.createRawPrimitiveValueSelector(value)}`;\n }\n }\n }\n throw new Error(\"Struct and array properties are not supported for filtering\");\n}\n\nfunction createFloatingPointEqualityClause(valueSelector: string, operator: \"is-equal\" | \"is-not-equal\", value: number) {\n const [from, to] = getFloatingPointValueRange(value);\n return `${valueSelector} ${operator === \"is-not-equal\" ? \"NOT \" : \"\"} BETWEEN ${from} AND ${to}`;\n}\n\nfunction getFloatingPointValueRange(value: number): [number, number] {\n return [value - Number.EPSILON, value + Number.EPSILON];\n}\n\nfunction getECSqlLogicalOperator(op: GenericInstanceFilterRuleGroupOperator) {\n switch (op) {\n case \"and\":\n return \"AND\";\n case \"or\":\n return \"OR\";\n }\n}\n\nfunction isUnaryRuleOperator(\n op: GenericInstanceFilterRuleOperator,\n): op is Extract<GenericInstanceFilterRuleOperator, \"is-true\" | \"is-false\" | \"is-null\" | \"is-not-null\"> {\n return op === \"is-true\" || op === \"is-false\" || op === \"is-null\" || op === \"is-not-null\";\n}\n\nfunction getECSqlComparisonOperator(op: Exclude<GenericInstanceFilterRuleOperator, \"is-true\" | \"is-false\" | \"is-null\" | \"is-not-null\">) {\n switch (op) {\n case \"is-equal\":\n return `=`;\n case \"is-not-equal\":\n return `<>`;\n case \"greater\":\n return `>`;\n case \"greater-or-equal\":\n return `>=`;\n case \"less\":\n return `<`;\n case \"less-or-equal\":\n return `<=`;\n case \"like\":\n return `LIKE`;\n }\n}\n\ntype JoinRelationshipPath = Props<typeof ECSql.createRelationshipPathJoinClause>[\"path\"];\nfunction assignRelationshipPathAliases(\n path: GenericInstanceFilterRelationshipStep[],\n pathIndex: number,\n sourceAlias: string,\n targetAlias: string,\n): JoinRelationshipPath {\n function createAlias(fullClassName: string, index: number) {\n return `rel_${pathIndex}_${fullClassName.replaceAll(/[\\.:]/g, \"_\")}_${index}`;\n }\n const result: JoinRelationshipPath = [];\n path.forEach((step, i) => {\n result.push({\n targetClassName: step.targetClassName,\n relationshipName: step.relationshipClassName,\n sourceClassName: step.sourceClassName,\n relationshipReverse: !step.isForwardRelationship,\n sourceAlias: i === 0 ? sourceAlias : result[i - 1].targetAlias,\n relationshipAlias: createAlias(step.relationshipClassName, i),\n targetAlias: i === path.length - 1 ? targetAlias : createAlias(step.targetClassName, i),\n joinType: \"inner\",\n });\n });\n return result;\n}\n\ninterface SpecializeContentClassProps {\n classHierarchyInspector: ECClassHierarchyInspector;\n contentClassName: string;\n filterClassNames: string[];\n}\nasync function specializeContentClass(props: SpecializeContentClassProps): Promise<string | undefined> {\n const filterClass = await getSpecializedPropertyClass(props.classHierarchyInspector, props.filterClassNames);\n if (!filterClass) {\n return props.contentClassName;\n }\n if (await props.classHierarchyInspector.classDerivesFrom(filterClass, props.contentClassName)) {\n return filterClass;\n }\n if (await props.classHierarchyInspector.classDerivesFrom(props.contentClassName, filterClass)) {\n return props.contentClassName;\n }\n return undefined;\n}\n\nasync function getSpecializedPropertyClass(classHierarchyInspector: ECClassHierarchyInspector, classes: string[]): Promise<string | undefined> {\n if (classes.length === 0) {\n return undefined;\n }\n const [currClassName, ...restClasses] = classes;\n let resolvedClassName = currClassName;\n for (const propClassName of restClasses) {\n if (await classHierarchyInspector.classDerivesFrom(propClassName, resolvedClassName)) {\n resolvedClassName = propClassName;\n }\n }\n return resolvedClassName;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetermineChildren.d.ts","sourceRoot":"","sources":["../../../../../src/hierarchies/imodel/operators/DetermineChildren.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,UAAU,EAAM,MAAM,MAAM,CAAC;AAItD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAGnE,gBAAgB;AAChB,eAAO,MAAM,iBAAiB,QAA4E,CAAC;AAE3G;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,UAAU,CAAC,OAAO,CAAC,WACrF,UAAU,CAAC,sBAAsB,CAAC,KAAG,UAAU,CAAC,sBAAsB,CAAC,
|
|
1
|
+
{"version":3,"file":"DetermineChildren.d.ts","sourceRoot":"","sources":["../../../../../src/hierarchies/imodel/operators/DetermineChildren.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,UAAU,EAAM,MAAM,MAAM,CAAC;AAItD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAGnE,gBAAgB;AAChB,eAAO,MAAM,iBAAiB,QAA4E,CAAC;AAE3G;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,UAAU,CAAC,OAAO,CAAC,WACrF,UAAU,CAAC,sBAAsB,CAAC,KAAG,UAAU,CAAC,sBAAsB,CAAC,CAsBhG"}
|
|
@@ -20,15 +20,21 @@ exports.LOGGING_NAMESPACE = (0, Common_js_1.createOperatorLoggingNamespace)(OPER
|
|
|
20
20
|
*/
|
|
21
21
|
function createDetermineChildrenOperator(hasNodes) {
|
|
22
22
|
return function (nodes) {
|
|
23
|
-
return nodes.pipe(
|
|
23
|
+
return nodes.pipe(
|
|
24
|
+
/* v8 ignore next -- @preserve */
|
|
25
|
+
(0, LoggingUtils_js_1.log)({ category: exports.LOGGING_NAMESPACE, message: (n) => `in: ${(0, Common_js_1.createNodeIdentifierForLogging)(n)}` }), (0, ReleaseMainThread_js_1.releaseMainThreadOnItemsCount)(200), (0, rxjs_1.concatMap)((n) => {
|
|
24
26
|
if (n.children !== undefined) {
|
|
25
27
|
return (0, rxjs_1.of)(n);
|
|
26
28
|
}
|
|
27
|
-
return hasNodes(n).pipe(
|
|
29
|
+
return hasNodes(n).pipe(
|
|
30
|
+
/* v8 ignore next -- @preserve */
|
|
31
|
+
(0, LoggingUtils_js_1.log)({
|
|
28
32
|
category: exports.LOGGING_NAMESPACE,
|
|
29
|
-
message:
|
|
33
|
+
message: (hasChildrenFlag) => `${(0, Common_js_1.createNodeIdentifierForLogging)(n)}: determined children: ${hasChildrenFlag}`,
|
|
30
34
|
}), (0, rxjs_1.map)((hasChildrenFlag) => Object.assign(n, { children: hasChildrenFlag })));
|
|
31
|
-
}),
|
|
35
|
+
}),
|
|
36
|
+
/* v8 ignore next -- @preserve */
|
|
37
|
+
(0, LoggingUtils_js_1.log)({ category: exports.LOGGING_NAMESPACE, message: (n) => `out: ${(0, Common_js_1.createNodeIdentifierForLogging)(n)}` }));
|
|
32
38
|
};
|
|
33
39
|
}
|
|
34
40
|
//# sourceMappingURL=DetermineChildren.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetermineChildren.js","sourceRoot":"","sources":["../../../../../src/hierarchies/imodel/operators/DetermineChildren.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAiBhG,
|
|
1
|
+
{"version":3,"file":"DetermineChildren.js","sourceRoot":"","sources":["../../../../../src/hierarchies/imodel/operators/DetermineChildren.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAiBhG,0EAuBC;AAtCD,+BAAsD;AACtD,wDAAsI;AACtI,oEAAqD;AACrD,wFAA8F;AAG9F,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAC1C,gBAAgB;AACH,QAAA,iBAAiB,GAAG,IAAA,0CAA8B,EAAC,aAAa,EAAE,sCAA0B,CAAC,CAAC;AAE3G;;;;GAIG;AACH,SAAgB,+BAA+B,CAAC,QAA+D;IAC7G,OAAO,UAAU,KAAyC;QACxD,OAAO,KAAK,CAAC,IAAI;QACf,iCAAiC;QACjC,IAAA,qBAAG,EAAC,EAAE,QAAQ,EAAE,yBAAiB,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,IAAA,0CAA8B,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAChG,IAAA,oDAA6B,EAAC,GAAG,CAAC,EAClC,IAAA,gBAAS,EAAC,CAAC,CAAyB,EAAsC,EAAE;YAC1E,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC7B,OAAO,IAAA,SAAE,EAAC,CAAC,CAAC,CAAC;YACf,CAAC;YACD,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI;YACrB,iCAAiC;YACjC,IAAA,qBAAG,EAAC;gBACF,QAAQ,EAAE,yBAAiB;gBAC3B,OAAO,EAAE,CAAC,eAAe,EAAE,EAAE,CAAC,GAAG,IAAA,0CAA8B,EAAC,CAAC,CAAC,0BAA0B,eAAe,EAAE;aAC9G,CAAC,EACF,IAAA,UAAG,EAAC,CAAC,eAAe,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAAC,CAC1E,CAAC;QACJ,CAAC,CAAC;QACF,iCAAiC;QACjC,IAAA,qBAAG,EAAC,EAAE,QAAQ,EAAE,yBAAiB,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,IAAA,0CAA8B,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAClG,CAAC;IACJ,CAAC,CAAC;AACJ,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 { concatMap, map, Observable, of } from \"rxjs\";\nimport { createNodeIdentifierForLogging, createOperatorLoggingNamespace, LOGGING_NAMESPACE_INTERNAL } from \"../../internal/Common.js\";\nimport { log } from \"../../internal/LoggingUtils.js\";\nimport { releaseMainThreadOnItemsCount } from \"../../internal/operators/ReleaseMainThread.js\";\nimport { ProcessedHierarchyNode } from \"../IModelHierarchyNode.js\";\n\nconst OPERATOR_NAME = \"DetermineChildren\";\n/** @internal */\nexport const LOGGING_NAMESPACE = createOperatorLoggingNamespace(OPERATOR_NAME, LOGGING_NAMESPACE_INTERNAL);\n\n/**\n * Ensures all input nodes have their children determined.\n *\n * @internal\n */\nexport function createDetermineChildrenOperator(hasNodes: (node: ProcessedHierarchyNode) => Observable<boolean>) {\n return function (nodes: Observable<ProcessedHierarchyNode>): Observable<ProcessedHierarchyNode> {\n return nodes.pipe(\n /* v8 ignore next -- @preserve */\n log({ category: LOGGING_NAMESPACE, message: (n) => `in: ${createNodeIdentifierForLogging(n)}` }),\n releaseMainThreadOnItemsCount(200),\n concatMap((n: ProcessedHierarchyNode): Observable<ProcessedHierarchyNode> => {\n if (n.children !== undefined) {\n return of(n);\n }\n return hasNodes(n).pipe(\n /* v8 ignore next -- @preserve */\n log({\n category: LOGGING_NAMESPACE,\n message: (hasChildrenFlag) => `${createNodeIdentifierForLogging(n)}: determined children: ${hasChildrenFlag}`,\n }),\n map((hasChildrenFlag) => Object.assign(n, { children: hasChildrenFlag })),\n );\n }),\n /* v8 ignore next -- @preserve */\n log({ category: LOGGING_NAMESPACE, message: (n) => `out: ${createNodeIdentifierForLogging(n)}` }),\n );\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grouping.d.ts","sourceRoot":"","sources":["../../../../../src/hierarchies/imodel/operators/Grouping.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuF,UAAU,EAA4B,MAAM,MAAM,CAAC;AAEjJ,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACnH,OAAO,EAAiB,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAW5E,OAAO,EAAE,8BAA8B,EAAE,sBAAsB,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAMnI,OAAO,EAAoC,kCAAkC,EAAE,MAAM,kCAAkC,CAAC;AAGxH,gBAAgB;AAChB,eAAO,MAAM,iBAAiB,QAA4E,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AE,CAAC,YAAY,EAAE,8BAA8B,KAAK,IAAI,EAC9E,gBAAgB,CAAC,EAAE,eAAe,EAAE,WAEZ,UAAU,CAAC,sBAAsB,CAAC,KAAG,UAAU,CAAC,sBAAsB,CAAC,CA8DhG;AAED,gBAAgB;AAChB,MAAM,MAAM,uCAAuC,GAAG,IAAI,CAAC,8BAA8B,EAAE,UAAU,CAAC,GAAG;IAAE,QAAQ,EAAE,8BAA8B,EAAE,CAAA;CAAE,CAAC;AAExJ,gBAAgB;AAChB,MAAM,WAAW,qBAAqB;IACpC,sCAAsC;IACtC,OAAO,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;IACxD,sCAAsC;IACtC,SAAS,EAAE,8BAA8B,EAAE,CAAC;IAC5C,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,gBAAgB;AAChB,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,YAAY,GAAG,UAAU,CAAC;AAEzE,gBAAgB;AAChB,MAAM,MAAM,eAAe,GAAG,CAC5B,YAAY,EAAE,8BAA8B,EAAE,EAC9C,mBAAmB,EAAE,uCAAuC,EAAE,KAC3D,OAAO,CAAC,qBAAqB,CAAC,CAAC"}
|
|
@@ -27,10 +27,13 @@ const LOGGING_NAMESPACE_PERFORMANCE_INTERNAL = (0, Common_js_1.createOperatorLog
|
|
|
27
27
|
/** @internal */
|
|
28
28
|
function createGroupingOperator(imodelAccess, parentNode, valueFormatter, localizedStrings, onNodesGrouped, onGroupingNodeCreated, groupingHandlers) {
|
|
29
29
|
return function (nodes) {
|
|
30
|
-
return nodes.pipe(
|
|
30
|
+
return nodes.pipe(
|
|
31
|
+
/* v8 ignore next -- @preserve */
|
|
32
|
+
(0, LoggingUtils_js_1.log)({ category: exports.LOGGING_NAMESPACE, message: (n) => `in: ${(0, Common_js_1.createNodeIdentifierForLogging)(n)}` }), (0, TapOnce_js_1.tapOnce)(() => {
|
|
33
|
+
/* v8 ignore next -- @preserve */
|
|
31
34
|
(0, LoggingUtils_js_1.doLog)({
|
|
32
35
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
33
|
-
message:
|
|
36
|
+
message: () => `Starting grouping (parent: ${(0, Common_js_1.createNodeIdentifierForLogging)(parentNode)})`,
|
|
34
37
|
});
|
|
35
38
|
}), (0, rxjs_1.reduce)((resolvedNodes, node) => {
|
|
36
39
|
if (HierarchyNode_js_1.HierarchyNode.isInstancesNode(node)) {
|
|
@@ -41,27 +44,30 @@ function createGroupingOperator(imodelAccess, parentNode, valueFormatter, locali
|
|
|
41
44
|
}
|
|
42
45
|
return resolvedNodes;
|
|
43
46
|
}, { instanceNodes: [], restNodes: [] }), (0, rxjs_1.tap)(({ instanceNodes, restNodes }) => {
|
|
47
|
+
/* v8 ignore next -- @preserve */
|
|
44
48
|
(0, LoggingUtils_js_1.doLog)({
|
|
45
49
|
category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,
|
|
46
|
-
message:
|
|
50
|
+
message: () => `Nodes partitioned. Got ${instanceNodes.length} instance nodes and ${restNodes.length} rest nodes.`,
|
|
47
51
|
});
|
|
48
52
|
}), (0, rxjs_1.mergeMap)((res) => {
|
|
49
53
|
const out = (0, rxjs_1.of)(res);
|
|
50
54
|
const totalNodes = res.instanceNodes.length + res.restNodes.length;
|
|
51
|
-
/*
|
|
52
|
-
return totalNodes <= 1000 ? out : out.pipe((0, rxjs_1.delay)(0));
|
|
55
|
+
return totalNodes <= 1000 ? out : /* v8 ignore next */ out.pipe((0, rxjs_1.delay)(0));
|
|
53
56
|
}), (0, rxjs_1.mergeMap)(({ instanceNodes, restNodes }) => {
|
|
54
57
|
const timer = new core_bentley_1.StopWatch(undefined, true);
|
|
55
58
|
const groupingHandlersObs = groupingHandlers
|
|
56
59
|
? (0, rxjs_1.from)(groupingHandlers)
|
|
57
60
|
: createGroupingHandlers(imodelAccess, parentNode, instanceNodes, valueFormatter, localizedStrings);
|
|
58
61
|
return (0, rxjs_1.merge)(groupingHandlersObs.pipe((0, rxjs_1.toArray)(), (0, rxjs_1.mergeMap)((createdGroupingHandlers) => groupInstanceNodes(instanceNodes, restNodes.length, createdGroupingHandlers, parentNode, onNodesGrouped, onGroupingNodeCreated)), (0, rxjs_1.finalize)(() => {
|
|
62
|
+
/* v8 ignore next -- @preserve */
|
|
59
63
|
(0, LoggingUtils_js_1.doLog)({
|
|
60
64
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
61
|
-
message:
|
|
65
|
+
message: () => `Grouping ${instanceNodes.length} nodes took ${timer.elapsedSeconds.toFixed(3)} s`,
|
|
62
66
|
});
|
|
63
67
|
})), (0, rxjs_1.from)(restNodes));
|
|
64
|
-
}), (0, ReleaseMainThread_js_1.releaseMainThreadOnItemsCount)(500),
|
|
68
|
+
}), (0, ReleaseMainThread_js_1.releaseMainThreadOnItemsCount)(500),
|
|
69
|
+
/* v8 ignore next -- @preserve */
|
|
70
|
+
(0, LoggingUtils_js_1.log)({ category: exports.LOGGING_NAMESPACE, message: (n) => `out: ${(0, Common_js_1.createNodeIdentifierForLogging)(n)}` }));
|
|
65
71
|
};
|
|
66
72
|
}
|
|
67
73
|
function groupInstanceNodes(nodes, extraSiblings, groupingHandlers, parentNode, onNodesGrouped, onGroupingNodeCreated) {
|
|
@@ -74,9 +80,11 @@ function groupInstanceNodes(nodes, extraSiblings, groupingHandlers, parentNode,
|
|
|
74
80
|
}
|
|
75
81
|
const timer = new core_bentley_1.StopWatch(undefined, true);
|
|
76
82
|
const currentHandler = groupingHandlers[handlerIndex];
|
|
77
|
-
return (0, rxjs_1.from)(currentHandler(curr?.ungrouped ?? nodes, curr?.grouped ?? [])).pipe(
|
|
83
|
+
return (0, rxjs_1.from)(currentHandler(curr?.ungrouped ?? nodes, curr?.grouped ?? [])).pipe(
|
|
84
|
+
/* v8 ignore next -- @preserve */
|
|
85
|
+
(0, LoggingUtils_js_1.log)({
|
|
78
86
|
category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,
|
|
79
|
-
message:
|
|
87
|
+
message: () => `Grouping handler ${handlerIndex} exclusively took ${timer.elapsedSeconds.toFixed(3)} s.`,
|
|
80
88
|
}), (0, rxjs_1.tap)((result) => {
|
|
81
89
|
onNodesGrouped?.(result, currentHandler);
|
|
82
90
|
}), (0, rxjs_1.mergeMap)((result) => {
|
|
@@ -84,13 +92,17 @@ function groupInstanceNodes(nodes, extraSiblings, groupingHandlers, parentNode,
|
|
|
84
92
|
return (0, rxjs_1.of)({ handlerIndex: handlerIndex + 1, result: { ...result, grouped: curr?.grouped ?? [] } });
|
|
85
93
|
}
|
|
86
94
|
const groupingPostProcessingTimer = new core_bentley_1.StopWatch(undefined, true);
|
|
87
|
-
return (0, rxjs_1.of)(result).pipe((0, rxjs_1.map)((r) => (0, GroupHiding_js_1.applyGroupHidingParams)(r, extraSiblings)), (0, rxjs_1.map)((r) => (0, AutoExpand_js_1.assignAutoExpand)(r)), (0, rxjs_1.map)((r) => ({ handlerIndex: handlerIndex + 1, result: { ...r, grouped: mergeInPlace(curr?.grouped, r.grouped) } })),
|
|
95
|
+
return (0, rxjs_1.of)(result).pipe((0, rxjs_1.map)((r) => (0, GroupHiding_js_1.applyGroupHidingParams)(r, extraSiblings)), (0, rxjs_1.map)((r) => (0, AutoExpand_js_1.assignAutoExpand)(r)), (0, rxjs_1.map)((r) => ({ handlerIndex: handlerIndex + 1, result: { ...r, grouped: mergeInPlace(curr?.grouped, r.grouped) } })),
|
|
96
|
+
/* v8 ignore next -- @preserve */
|
|
97
|
+
(0, LoggingUtils_js_1.log)({
|
|
88
98
|
category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,
|
|
89
|
-
message:
|
|
99
|
+
message: () => `Post-processing grouping handler ${handlerIndex} exclusively took ${groupingPostProcessingTimer.elapsedSeconds.toFixed(3)} s.`,
|
|
90
100
|
}), (0, rxjs_1.delay)(0));
|
|
91
|
-
}),
|
|
101
|
+
}),
|
|
102
|
+
/* v8 ignore next -- @preserve */
|
|
103
|
+
(0, LoggingUtils_js_1.log)({
|
|
92
104
|
category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,
|
|
93
|
-
message:
|
|
105
|
+
message: () => `Total time for grouping handler ${handlerIndex}: ${timer.elapsedSeconds.toFixed(3)} s.`,
|
|
94
106
|
}));
|
|
95
107
|
}), (0, rxjs_1.last)(), (0, rxjs_1.mergeMap)(({ result }) => {
|
|
96
108
|
result.grouped.forEach((groupingNode) => {
|
|
@@ -127,16 +139,18 @@ function createGroupingHandlers(imodelAccess, parentNode, processedInstanceNodes
|
|
|
127
139
|
? (0, rxjs_1.from)((0, PropertiesGrouping_js_1.createPropertiesGroupingHandlers)(imodelAccess, parentNode, processedInstanceNodes, valueFormatter, localizedStrings)).pipe((0, rxjs_1.concatAll)())
|
|
128
140
|
: rxjs_1.EMPTY, groupingLevel < GroupingLevel.Label ? (0, rxjs_1.of)(async (allNodes) => (0, LabelGrouping_js_1.createLabelGroups)(allNodes)) : rxjs_1.EMPTY).pipe((0, rxjs_1.tap)({
|
|
129
141
|
subscribe: () => {
|
|
142
|
+
/* v8 ignore next -- @preserve */
|
|
130
143
|
(0, LoggingUtils_js_1.doLog)({
|
|
131
144
|
category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,
|
|
132
|
-
message:
|
|
145
|
+
message: () => `Start creating grouping handlers`,
|
|
133
146
|
});
|
|
134
147
|
timer.start();
|
|
135
148
|
},
|
|
136
149
|
}), (0, rxjs_1.finalize)(() => {
|
|
150
|
+
/* v8 ignore next -- @preserve */
|
|
137
151
|
(0, LoggingUtils_js_1.doLog)({
|
|
138
152
|
category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,
|
|
139
|
-
message:
|
|
153
|
+
message: () => `Creating grouping handlers took ${timer.elapsedSeconds.toFixed(3)} s`,
|
|
140
154
|
});
|
|
141
155
|
}));
|
|
142
156
|
}
|