@itwin/presentation-hierarchies 2.0.0-alpha.7 → 2.0.0-alpha.8
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 +40 -0
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts +12 -3
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +32 -4
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js +1 -1
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts +1 -3
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js +60 -64
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts +4 -6
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js +6 -5
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js +6 -5
- package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js +4 -3
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js +21 -16
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts +7 -3
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js +2 -2
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -1
- package/lib/cjs/presentation-hierarchies.d.ts +1 -1
- package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts +12 -3
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +32 -4
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js +2 -2
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts +1 -3
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js +60 -64
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts +4 -6
- package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js +3 -3
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js +7 -6
- package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js +5 -4
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js +22 -17
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts +7 -3
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js +2 -2
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -1
- package/lib/esm/presentation-hierarchies.d.ts +1 -1
- package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies.js.map +1 -1
- package/package.json +8 -8
|
@@ -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;I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,CAAC,CAAC;IACnE,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,IAAI,UAAU,GAAG,IAAI,WAAW,yBAAyB,IAAI;aAC1D,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,IAAA,wCAAkB,EAAC,QAAQ,CAAC,CAAC;aACnD,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,IAAI,UAAU,MAAM,SAAS,GAAG,CAAC;aACpE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QACjB,MAAM,YAAY,GAAG,iCAAiC,CACpD,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,EACxC,WAAW,CACZ,CAAC;QACF,IAAI,YAAY,CAAC,UAAU,EAAE,CAAC;YAC5B,UAAU,GAAG,IAAI,UAAU,OAAO,YAAY,CAAC,UAAU,GAAG,CAAC;QAC/D,CAAC;QACD,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;IAED,OAAO,GAAG,CAAC;AACb,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;\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;\n }): Promise<{ from: string; where: string; joins: string }> {\n const { contentClass, filter } = props;\n const { from, joins, where } = filter\n ? await createInstanceFilterClauses({ imodelAccess: this._imodelAccess, contentClass, filter })\n : {\n from: contentClass.fullName,\n joins: [],\n where: [],\n };\n\n const fromClass = await getClass(this._imodelAccess, from);\n const hiddenClasses = await getHiddenClassesTree(fromClass);\n const hiddenClassesWhereClause = createWhereClauseForHiddenClasses(hiddenClasses, contentClass.alias);\n hiddenClassesWhereClause.hideClause && where.push(hiddenClassesWhereClause.hideClause);\n assert(!hiddenClassesWhereClause.showClause, \"`showClause` is expected to always be empty here\");\n\n return {\n from,\n joins: joins.join(\"\\n\"),\n where: where.join(\" AND \"),\n };\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 */\nasync function createInstanceFilterClauses(props: {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector;\n contentClass: { fullName: string; alias: string };\n filter: GenericInstanceFilter;\n}): Promise<{ from: string; where: string[]; joins: string[] }> {\n const { imodelAccess, contentClass, filter } = props;\n\n const from = await specializeContentClass({\n classHierarchyInspector: 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: imodelAccess,\n path: assignRelationshipPathAliases(rel.path, i, contentClass.alias, rel.alias),\n }),\n ),\n );\n\n const where = new Array<string>();\n if (filter.filteredClassNames && filter.filteredClassNames.length > 0) {\n where.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(imodelAccess, aliasClassName) : undefined;\n },\n filter.rules,\n );\n if (propertiesFilter) {\n where.push(propertiesFilter);\n }\n\n return { from, joins, where };\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\ninterface HiddenClassNode {\n fullName: string;\n state: \"hide\" | \"show\";\n children: HiddenClassNode[];\n}\n\nasync function getHiddenClassesTree(selectClass: EC.Class, selectClassAttribute: \"show\" | \"hide\" = \"show\"): Promise<HiddenClassNode[]> {\n const derivedClasses = await getDirectDerivedClasses(selectClass);\n\n const derivedClassSchemas = derivedClasses.reduce(\n (acc, ecClass) => {\n if (!acc.set.has(ecClass.schema.name)) {\n acc.schemas.push(ecClass.schema);\n acc.set.add(ecClass.schema.name);\n }\n return acc;\n },\n { set: new Set<string>(), schemas: new Array<EC.Schema>() },\n ).schemas;\n const hiddenSchemas = new Map<string, \"hide\" | \"show\" | undefined>();\n await Promise.all(\n derivedClassSchemas.map(async (ecSchema) => {\n hiddenSchemas.set(ecSchema.name, await getHiddenSchemaAttribute(ecSchema));\n }),\n );\n\n const tree = (\n await Promise.all(\n derivedClasses.map(async (ecClass): Promise<HiddenClassNode[]> => {\n const hiddenClassAttr = await getHiddenClassAttribute(ecClass);\n const attr = hiddenClassAttr ?? hiddenSchemas.get(ecClass.schema.name);\n if (!attr || attr === selectClassAttribute) {\n return getHiddenClassesTree(ecClass, selectClassAttribute);\n }\n return [\n {\n fullName: ecClass.fullName,\n state: attr,\n children: await getHiddenClassesTree(ecClass, attr),\n },\n ];\n }),\n )\n ).flat();\n return tree;\n}\n\nasync function getDirectDerivedClasses(ecClass: EC.Class): Promise<EC.Class[]> {\n const allDerived = await ecClass.getDerivedClasses();\n return (await Promise.all(allDerived.map(async (c) => ({ derived: c, base: await c.baseClass }))))\n .filter(({ base }) => base?.fullName === ecClass.fullName)\n .map(({ derived }) => derived);\n}\n\nasync function getHiddenClassAttribute(ecClass: EC.Class): Promise<\"hide\" | \"show\" | undefined> {\n const customAttributes = await ecClass.getCustomAttributes();\n const hiddenClassAttribute = customAttributes.get(\"CoreCustomAttributes.HiddenClass\");\n return hiddenClassAttribute ? (hiddenClassAttribute.Show ? \"show\" : \"hide\") : undefined;\n}\n\nasync function getHiddenSchemaAttribute(ecSchema: EC.Schema): Promise<\"hide\" | \"show\" | undefined> {\n const customAttributes = await ecSchema.getCustomAttributes();\n const hiddenSchemaAttribute = customAttributes.get(\"CoreCustomAttributes.HiddenSchema\");\n return hiddenSchemaAttribute ? (hiddenSchemaAttribute.ShowClasses ? \"show\" : \"hide\") : undefined;\n}\n\nfunction createWhereClauseForHiddenClasses(hiddenClasses: HiddenClassNode[], selectAlias: string): { showClause?: string; hideClause?: string } {\n const res: { showClause?: string; hideClause?: string } = {};\n\n const show = hiddenClasses.filter(({ state }) => state === \"show\");\n if (show.length > 0) {\n let showClause = `[${selectAlias}].[ECClassId] IS (${show\n .map(({ fullName }) => parseFullClassName(fullName))\n .map(({ schemaName, className }) => `[${schemaName}].[${className}]`)\n .join(\", \")})`;\n const childClauses = createWhereClauseForHiddenClasses(\n show.flatMap(({ children }) => children),\n selectAlias,\n );\n if (childClauses.hideClause) {\n showClause = `(${showClause} AND ${childClauses.hideClause})`;\n }\n res.showClause = showClause;\n }\n\n const hide = hiddenClasses.filter(({ state }) => state === \"hide\");\n if (hide.length > 0) {\n let hideClause = `[${selectAlias}].[ECClassId] IS NOT (${hide\n .map(({ fullName }) => parseFullClassName(fullName))\n .map(({ schemaName, className }) => `[${schemaName}].[${className}]`)\n .join(\", \")})`;\n const childClauses = createWhereClauseForHiddenClasses(\n hide.flatMap(({ children }) => children),\n selectAlias,\n );\n if (childClauses.showClause) {\n hideClause = `(${hideClause} OR ${childClauses.showClause})`;\n }\n res.hideClause = hideClause;\n }\n\n return res;\n}\n"]}
|
|
1
|
+
{"version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,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,EACxC,WAAW,CACZ,CAAC;QACF,IAAI,YAAY,CAAC,UAAU,EAAE,CAAC;YAC5B,UAAU,GAAG,IAAI,UAAU,QAAQ,YAAY,CAAC,UAAU,GAAG,CAAC;QAChE,CAAC;QACD,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;IAED,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC;IACnE,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,IAAI,UAAU,GAAG,IAAI,WAAW,yBAAyB,IAAI;aAC1D,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,IAAA,wCAAkB,EAAC,QAAQ,CAAC,CAAC;aACnD,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,IAAI,UAAU,MAAM,SAAS,GAAG,CAAC;aACpE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QACjB,MAAM,YAAY,GAAG,iCAAiC,CACpD,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,EACxC,WAAW,CACZ,CAAC;QACF,IAAI,YAAY,CAAC,UAAU,EAAE,CAAC;YAC5B,UAAU,GAAG,IAAI,UAAU,OAAO,YAAY,CAAC,UAAU,GAAG,CAAC;QAC/D,CAAC;QACD,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;IAED,OAAO,GAAG,CAAC;AACb,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 compareFullClassNames,\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;\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;\n }): Promise<{ from: string; where: string; joins: string }> {\n const { contentClass, filter } = props;\n const { from, joins, where } = filter\n ? await createInstanceFilterClauses({ imodelAccess: this._imodelAccess, contentClass, filter })\n : {\n from: contentClass.fullName,\n joins: [],\n where: [],\n };\n\n const fromClass = await getClass(this._imodelAccess, from);\n const hiddenClasses = await getHiddenClassesTree(fromClass);\n const hiddenClassesWhereClause = createWhereClauseForHiddenClasses(hiddenClasses, contentClass.alias);\n hiddenClassesWhereClause.hideClause && where.push(hiddenClassesWhereClause.hideClause);\n assert(!hiddenClassesWhereClause.showClause, \"`showClause` is expected to always be empty here\");\n\n return {\n from,\n joins: joins.join(\"\\n\"),\n where: where.join(\" AND \"),\n };\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 */\nasync function createInstanceFilterClauses(props: {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector;\n contentClass: { fullName: string; alias: string };\n filter: GenericInstanceFilter;\n}): Promise<{ from: string; where: string[]; joins: string[] }> {\n const { imodelAccess, contentClass, filter } = props;\n\n const from = await specializeContentClass({\n classHierarchyInspector: 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: imodelAccess,\n path: assignRelationshipPathAliases(rel.path, i, contentClass.alias, rel.alias),\n }),\n ),\n );\n\n const where = new Array<string>();\n if (filter.filteredClassNames && filter.filteredClassNames.length > 0) {\n where.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(imodelAccess, aliasClassName) : undefined;\n },\n filter.rules,\n );\n if (propertiesFilter) {\n where.push(propertiesFilter);\n }\n\n return { from, joins, where };\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\ninterface HiddenClassNode {\n fullName: string;\n state: \"hide\" | \"show\";\n children: HiddenClassNode[];\n}\n\nasync function getHiddenClassesTree(selectClass: EC.Class, selectClassAttribute: \"show\" | \"hide\" = \"show\"): Promise<HiddenClassNode[]> {\n const derivedClasses = await getDirectDerivedClasses(selectClass);\n\n const derivedClassSchemas = derivedClasses.reduce(\n (acc, ecClass) => {\n if (!acc.set.has(ecClass.schema.name)) {\n acc.schemas.push(ecClass.schema);\n acc.set.add(ecClass.schema.name);\n }\n return acc;\n },\n { set: new Set<string>(), schemas: new Array<EC.Schema>() },\n ).schemas;\n const hiddenSchemas = new Map<string, \"hide\" | \"show\" | undefined>();\n await Promise.all(\n derivedClassSchemas.map(async (ecSchema) => {\n hiddenSchemas.set(ecSchema.name, await getHiddenSchemaAttribute(ecSchema));\n }),\n );\n\n const tree = (\n await Promise.all(\n derivedClasses.map(async (ecClass): Promise<HiddenClassNode[]> => {\n const hiddenClassAttr = await getHiddenClassAttribute(ecClass);\n const attr = hiddenClassAttr ?? hiddenSchemas.get(ecClass.schema.name);\n if (!attr || attr === selectClassAttribute) {\n return getHiddenClassesTree(ecClass, selectClassAttribute);\n }\n return [\n {\n fullName: ecClass.fullName,\n state: attr,\n children: await getHiddenClassesTree(ecClass, attr),\n },\n ];\n }),\n )\n ).flat();\n return tree;\n}\n\nasync function getDirectDerivedClasses(ecClass: EC.Class): Promise<EC.Class[]> {\n const allDerived = await ecClass.getDerivedClasses();\n return (await Promise.all(allDerived.map(async (c) => ({ derived: c, base: await c.baseClass }))))\n .filter(({ base }) => base && compareFullClassNames(base.fullName, ecClass.fullName) === 0)\n .map(({ derived }) => derived);\n}\n\nasync function getHiddenClassAttribute(ecClass: EC.Class): Promise<\"hide\" | \"show\" | undefined> {\n const customAttributes = await ecClass.getCustomAttributes();\n const hiddenClassAttribute = customAttributes.get(\"CoreCustomAttributes.HiddenClass\");\n return hiddenClassAttribute ? (hiddenClassAttribute.Show ? \"show\" : \"hide\") : undefined;\n}\n\nasync function getHiddenSchemaAttribute(ecSchema: EC.Schema): Promise<\"hide\" | \"show\" | undefined> {\n const customAttributes = await ecSchema.getCustomAttributes();\n const hiddenSchemaAttribute = customAttributes.get(\"CoreCustomAttributes.HiddenSchema\");\n return hiddenSchemaAttribute ? (hiddenSchemaAttribute.ShowClasses ? \"show\" : \"hide\") : undefined;\n}\n\nfunction createWhereClauseForHiddenClasses(hiddenClasses: HiddenClassNode[], selectAlias: string): { showClause?: string; hideClause?: string } {\n const res: { showClause?: string; hideClause?: string } = {};\n\n const show = hiddenClasses.filter(({ state }) => state === \"show\");\n if (show.length > 0) {\n let showClause = `[${selectAlias}].[ECClassId] IS (${show\n .map(({ fullName }) => parseFullClassName(fullName))\n .map(({ schemaName, className }) => `[${schemaName}].[${className}]`)\n .join(\", \")})`;\n const childClauses = createWhereClauseForHiddenClasses(\n show.flatMap(({ children }) => children),\n selectAlias,\n );\n if (childClauses.hideClause) {\n showClause = `(${showClause} AND ${childClauses.hideClause})`;\n }\n res.showClause = showClause;\n }\n\n const hide = hiddenClasses.filter(({ state }) => state === \"hide\");\n if (hide.length > 0) {\n let hideClause = `[${selectAlias}].[ECClassId] IS NOT (${hide\n .map(({ fullName }) => parseFullClassName(fullName))\n .map(({ schemaName, className }) => `[${schemaName}].[${className}]`)\n .join(\", \")})`;\n const childClauses = createWhereClauseForHiddenClasses(\n hide.flatMap(({ children }) => children),\n selectAlias,\n );\n if (childClauses.showClause) {\n hideClause = `(${hideClause} OR ${childClauses.showClause})`;\n }\n res.hideClause = hideClause;\n }\n\n return res;\n}\n"]}
|
|
@@ -4,9 +4,7 @@ import { HierarchySearchPath } from "../HierarchySearch.js";
|
|
|
4
4
|
import { DefineHierarchyLevelProps, HierarchyLevelDefinition, InstanceNodesQueryDefinition } from "../imodel/IModelHierarchyDefinition.js";
|
|
5
5
|
import { RxjsHierarchyDefinition, RxjsNodeParser, RxjsNodePostProcessor, RxjsNodePreProcessor } from "../internal/RxjsHierarchyDefinition.js";
|
|
6
6
|
interface SearchHierarchyDefinitionProps {
|
|
7
|
-
imodelAccess: ECClassHierarchyInspector
|
|
8
|
-
imodelKey: string;
|
|
9
|
-
};
|
|
7
|
+
imodelAccess: ECClassHierarchyInspector;
|
|
10
8
|
source: RxjsHierarchyDefinition;
|
|
11
9
|
sourceName: string;
|
|
12
10
|
targetPaths: HierarchySearchPath[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/SearchHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAiF,UAAU,EAAqB,MAAM,MAAM,CAAC;AAEpI,OAAO,
|
|
1
|
+
{"version":3,"file":"SearchHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/SearchHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAiF,UAAU,EAAqB,MAAM,MA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}
|
|
@@ -8,6 +8,7 @@ exports.ECSQL_COLUMN_NAME_SearchClassName = exports.ECSQL_COLUMN_NAME_SearchECIn
|
|
|
8
8
|
exports.applyECInstanceIdsSearch = applyECInstanceIdsSearch;
|
|
9
9
|
exports.applyECInstanceIdsSelector = applyECInstanceIdsSelector;
|
|
10
10
|
const rxjs_1 = require("rxjs");
|
|
11
|
+
const presentation_shared_1 = require("@itwin/presentation-shared");
|
|
11
12
|
const HierarchyNodeIdentifier_js_1 = require("../HierarchyNodeIdentifier.js");
|
|
12
13
|
const HierarchyNodeKey_js_1 = require("../HierarchyNodeKey.js");
|
|
13
14
|
const HierarchySearch_js_1 = require("../HierarchySearch.js");
|
|
@@ -32,73 +33,68 @@ class SearchHierarchyDefinition {
|
|
|
32
33
|
this._nodesParser = props.nodesParser ?? this._source.parseNode ?? ((row) => (0, rxjs_1.of)((0, TreeNodesReader_js_1.defaultNodesParser)(row)));
|
|
33
34
|
}
|
|
34
35
|
get preProcessNode() {
|
|
35
|
-
return (node) => {
|
|
36
|
-
|
|
37
|
-
if
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}));
|
|
43
|
-
};
|
|
36
|
+
return (node) => (this._source.preProcessNode ? this._source.preProcessNode(node) : (0, rxjs_1.of)(node)).pipe((0, rxjs_1.filter)((processedNode) => {
|
|
37
|
+
if (processedNode.processingParams?.hideInHierarchy && processedNode.search?.isSearchTarget && !processedNode.search.hasSearchTargetAncestor) {
|
|
38
|
+
// we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another search target
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}));
|
|
44
43
|
}
|
|
45
44
|
get postProcessNode() {
|
|
46
|
-
return (node) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}));
|
|
67
|
-
};
|
|
45
|
+
return (node) => (this._source.postProcessNode ? this._source.postProcessNode(node) : (0, rxjs_1.of)(node)).pipe((0, rxjs_1.map)((processedNode) => {
|
|
46
|
+
const parentKeysWithoutGroupingNodesLength = processedNode.parentKeys.filter((key) => !HierarchyNodeKey_js_1.HierarchyNodeKey.isGrouping(key)).length;
|
|
47
|
+
const parentKeysLength = processedNode.parentKeys.length;
|
|
48
|
+
const shouldAutoExpand = IModelHierarchyNode_js_1.ProcessedHierarchyNode.isGroupingNode(processedNode)
|
|
49
|
+
? shouldAutoExpandGroupingNodeBasedOnNestedChildren({
|
|
50
|
+
directOrIndirectChildren: processedNode.children,
|
|
51
|
+
parentKeysWithoutGroupingNodesLength,
|
|
52
|
+
parentKeysLength,
|
|
53
|
+
})
|
|
54
|
+
: (processedNode.search?.isSearchTarget && !!processedNode.search.searchTargetOptions?.autoExpand) ||
|
|
55
|
+
processedNode.search?.childrenTargetPaths?.some((path) => (0, HierarchySearch_js_1.shouldAutoExpandBasedOnReveal)({
|
|
56
|
+
reveal: HierarchySearch_js_1.HierarchySearchPath.normalize(path).options?.reveal,
|
|
57
|
+
nodePositionInPath: parentKeysWithoutGroupingNodesLength,
|
|
58
|
+
nodePositionInHierarchy: parentKeysLength,
|
|
59
|
+
}));
|
|
60
|
+
if (shouldAutoExpand) {
|
|
61
|
+
Object.assign(processedNode, { autoExpand: true });
|
|
62
|
+
}
|
|
63
|
+
return processedNode;
|
|
64
|
+
}));
|
|
68
65
|
}
|
|
69
66
|
get parseNode() {
|
|
70
|
-
return (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
if (!HierarchyNodeIdentifier_js_1.HierarchyNodeIdentifier.isInstanceNodeIdentifier(identifier)) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
if (identifier.imodelKey && identifier.imodelKey !== this._imodelAccess.imodelKey) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
if (identifier.className === rowInstanceKey.className) {
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
return (0, rxjs_1.firstValueFrom)((0, rxjs_1.merge)((0, Common_js_1.fromPossiblyPromise)(this._imodelAccess.classDerivesFrom(identifier.className, rowInstanceKey.className)), (0, Common_js_1.fromPossiblyPromise)(this._imodelAccess.classDerivesFrom(rowInstanceKey.className, identifier.className))).pipe((0, rxjs_1.filter)((classDerives) => classDerives), (0, rxjs_1.defaultIfEmpty)(false), (0, rxjs_1.take)(1)));
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
return (0, Common_js_1.fromPossiblyPromise)(nodeSearchPropPossiblyPromise).pipe((0, rxjs_1.map)((nodeExtraProps) => {
|
|
95
|
-
if (nodeExtraProps?.search) {
|
|
96
|
-
parsedNode.search = nodeExtraProps.search;
|
|
67
|
+
return (props) => this._nodesParser(props).pipe((0, rxjs_1.mergeMap)((parsedNode) => {
|
|
68
|
+
const { row, parentNode, imodelKey } = props;
|
|
69
|
+
if (!row[exports.ECSQL_COLUMN_NAME_SearchECInstanceId] || !row[exports.ECSQL_COLUMN_NAME_SearchClassName]) {
|
|
70
|
+
return (0, rxjs_1.of)(parsedNode);
|
|
71
|
+
}
|
|
72
|
+
const rowInstanceKey = { className: row[exports.ECSQL_COLUMN_NAME_SearchClassName], id: row[exports.ECSQL_COLUMN_NAME_SearchECInstanceId] };
|
|
73
|
+
const searchHelper = (0, HierarchySearch_js_1.createHierarchySearchHelper)(this._targetPaths, parentNode);
|
|
74
|
+
const nodeSearchPropPossiblyPromise = searchHelper.createChildNodeProps({
|
|
75
|
+
asyncPathMatcher: (identifier) => {
|
|
76
|
+
if (identifier.id !== rowInstanceKey.id) {
|
|
77
|
+
return false;
|
|
97
78
|
}
|
|
98
|
-
|
|
99
|
-
|
|
79
|
+
if (!HierarchyNodeIdentifier_js_1.HierarchyNodeIdentifier.isInstanceNodeIdentifier(identifier)) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
if (identifier.imodelKey && identifier.imodelKey !== imodelKey) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
if ((0, presentation_shared_1.compareFullClassNames)(identifier.className, rowInstanceKey.className) === 0) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
return (0, rxjs_1.firstValueFrom)((0, rxjs_1.merge)((0, Common_js_1.fromPossiblyPromise)(this._imodelAccess.classDerivesFrom(identifier.className, rowInstanceKey.className)), (0, Common_js_1.fromPossiblyPromise)(this._imodelAccess.classDerivesFrom(rowInstanceKey.className, identifier.className))).pipe((0, rxjs_1.filter)((classDerives) => classDerives), (0, rxjs_1.defaultIfEmpty)(false), (0, rxjs_1.take)(1)));
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
return (0, Common_js_1.fromPossiblyPromise)(nodeSearchPropPossiblyPromise).pipe((0, rxjs_1.map)((nodeExtraProps) => {
|
|
92
|
+
if (nodeExtraProps?.search) {
|
|
93
|
+
parsedNode.search = nodeExtraProps.search;
|
|
94
|
+
}
|
|
95
|
+
return parsedNode;
|
|
100
96
|
}));
|
|
101
|
-
};
|
|
97
|
+
}));
|
|
102
98
|
}
|
|
103
99
|
defineHierarchyLevel(props) {
|
|
104
100
|
const sourceDefinitions = this._source.defineHierarchyLevel(props);
|
|
@@ -142,7 +138,7 @@ class SearchHierarchyDefinition {
|
|
|
142
138
|
// are actually the same instance, so we only need to keep one of them, or otherwise the query will
|
|
143
139
|
// duplicate it
|
|
144
140
|
for (const entry of entries) {
|
|
145
|
-
if (entry.className
|
|
141
|
+
if ((0, presentation_shared_1.compareFullClassNames)(entry.className, x.className) === 0 ||
|
|
146
142
|
(await imodelAccess.classDerivesFrom(entry.className, x.className)) ||
|
|
147
143
|
(await imodelAccess.classDerivesFrom(x.className, entry.className))) {
|
|
148
144
|
return undefined;
|
|
@@ -155,10 +151,10 @@ class SearchHierarchyDefinition {
|
|
|
155
151
|
if (!HierarchyNodeIdentifier_js_1.HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {
|
|
156
152
|
continue;
|
|
157
153
|
}
|
|
158
|
-
if (id.imodelKey && id.imodelKey !==
|
|
154
|
+
if (id.imodelKey && id.imodelKey !== props.imodelKey) {
|
|
159
155
|
continue;
|
|
160
156
|
}
|
|
161
|
-
if (id.className
|
|
157
|
+
if ((0, presentation_shared_1.compareFullClassNames)(id.className, definition.fullClassName) !== 0 &&
|
|
162
158
|
!(await Promise.all([
|
|
163
159
|
imodelAccess.classDerivesFrom(id.className, definition.fullClassName),
|
|
164
160
|
imodelAccess.classDerivesFrom(definition.fullClassName, id.className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/SearchHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAsQhG,4DAgCC;AAGD,gEAcC;AArTD,+BAAoI;AAGpI,8EAAwE;AACxE,gEAA6E;AAC7E,8DAAwH;AACxH,yFAMgD;AAChD,6EAA0I;AAC1I,mFAAkF;AAClF,qEAAkE;AAClE,qDAA4D;AAC5D,qEAA+D;AAW/D,gBAAgB;AAChB,MAAa,yBAAyB;IAC5B,aAAa,CAAoD;IACjE,OAAO,CAA0B;IACjC,YAAY,CAAwB;IACpC,YAAY,CAAiB;IACrC,WAAW,CAAS;IAEpB,YAAmB,KAAqC;QACtD,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC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,KAAK,CAAC,MAAM,CAAC,cAAc;YAC3B,IAAA,kDAA6B,EAAC;gBAC5B,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM;gBAChD,uBAAuB,EAAE,gBAAgB;gBACzC,0IAA0I;gBAC1I,kBAAkB,EAAE,oCAAoC,GAAG,CAAC;aAC7D,CAAC,EACF,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;YACtC,oBAAoB;YACpB,SAAS;QACX,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;YACpD,IACE,MAAM,IAAI,IAAI;gBACd,IAAA,kDAA6B,EAAC;oBAC5B,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM;oBAC5B,uBAAuB,EAAE,gBAAgB;oBACzC,0IAA0I;oBAC1I,kBAAkB,EAAE,oCAAoC,GAAG,CAAC;iBAC7D,CAAC,EACF,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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 { defaultIfEmpty, defer, filter, firstValueFrom, map, merge, mergeAll, mergeMap, Observable, of, take, toArray } from \"rxjs\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport { HierarchyNodeIdentifier } from \"../HierarchyNodeIdentifier.js\";\nimport { HierarchyNodeKey, IModelInstanceKey } from \"../HierarchyNodeKey.js\";\nimport { createHierarchySearchHelper, HierarchySearchPath, shouldAutoExpandBasedOnReveal } from \"../HierarchySearch.js\";\nimport {\n DefineHierarchyLevelProps,\n GenericHierarchyNodeDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n} from \"../imodel/IModelHierarchyDefinition.js\";\nimport { ProcessedGroupingHierarchyNode, ProcessedHierarchyNode, ProcessedInstanceHierarchyNode } from \"../imodel/IModelHierarchyNode.js\";\nimport { NodeSelectClauseColumnNames } from \"../imodel/NodeSelectQueryFactory.js\";\nimport { defaultNodesParser } from \"../imodel/TreeNodesReader.js\";\nimport { fromPossiblyPromise } from \"../internal/Common.js\";\nimport { partition } from \"../internal/operators/Partition.js\";\nimport { RxjsHierarchyDefinition, RxjsNodeParser, RxjsNodePostProcessor, RxjsNodePreProcessor } from \"../internal/RxjsHierarchyDefinition.js\";\n\ninterface SearchHierarchyDefinitionProps {\n imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n source: RxjsHierarchyDefinition;\n sourceName: string;\n targetPaths: HierarchySearchPath[];\n nodesParser?: RxjsNodeParser;\n}\n\n/** @internal */\nexport class SearchHierarchyDefinition implements RxjsHierarchyDefinition {\n private _imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n private _source: RxjsHierarchyDefinition;\n private _targetPaths: HierarchySearchPath[];\n private _nodesParser: RxjsNodeParser;\n #sourceName: string;\n\n public constructor(props: SearchHierarchyDefinitionProps) {\n this._imodelAccess = props.imodelAccess;\n this._source = props.source;\n this.#sourceName = props.sourceName;\n this._targetPaths = props.targetPaths;\n this._nodesParser = props.nodesParser ?? this._source.parseNode ?? ((row) => of(defaultNodesParser(row)));\n }\n\n public get preProcessNode(): RxjsNodePreProcessor {\n return (node) => {\n return (this._source.preProcessNode ? this._source.preProcessNode(node) : of(node)).pipe(\n filter((processedNode) => {\n if (processedNode.processingParams?.hideInHierarchy && processedNode.search?.isSearchTarget && !processedNode.search.hasSearchTargetAncestor) {\n // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another search target\n return false;\n }\n return true;\n }),\n );\n };\n }\n\n public get postProcessNode(): RxjsNodePostProcessor {\n return (node) => {\n return (this._source.postProcessNode ? this._source.postProcessNode(node) : of(node)).pipe(\n map((processedNode) => {\n const parentKeysWithoutGroupingNodesLength = processedNode.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;\n const parentKeysLength = processedNode.parentKeys.length;\n const shouldAutoExpand = ProcessedHierarchyNode.isGroupingNode(processedNode)\n ? shouldAutoExpandGroupingNodeBasedOnNestedChildren({\n directOrIndirectChildren: processedNode.children,\n parentKeysWithoutGroupingNodesLength,\n parentKeysLength,\n })\n : (processedNode.search?.isSearchTarget && !!processedNode.search.searchTargetOptions?.autoExpand) ||\n processedNode.search?.childrenTargetPaths?.some((path) =>\n shouldAutoExpandBasedOnReveal({\n reveal: HierarchySearchPath.normalize(path).options?.reveal,\n nodePositionInPath: parentKeysWithoutGroupingNodesLength,\n nodePositionInHierarchy: parentKeysLength,\n }),\n );\n if (shouldAutoExpand) {\n Object.assign(processedNode, { autoExpand: true });\n }\n\n return processedNode;\n }),\n );\n };\n }\n\n public get parseNode(): RxjsNodeParser {\n return (row, parentNode) => {\n return this._nodesParser(row).pipe(\n mergeMap((parsedNode) => {\n if (!row[ECSQL_COLUMN_NAME_SearchECInstanceId] || !row[ECSQL_COLUMN_NAME_SearchClassName]) {\n return of(parsedNode);\n }\n const rowInstanceKey = { className: row[ECSQL_COLUMN_NAME_SearchClassName], id: row[ECSQL_COLUMN_NAME_SearchECInstanceId] };\n const searchHelper = createHierarchySearchHelper(this._targetPaths, parentNode);\n const nodeSearchPropPossiblyPromise = searchHelper.createChildNodeProps({\n asyncPathMatcher: (identifier): boolean | Promise<boolean> => {\n if (identifier.id !== rowInstanceKey.id) {\n return false;\n }\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(identifier)) {\n return false;\n }\n if (identifier.imodelKey && identifier.imodelKey !== this._imodelAccess.imodelKey) {\n return false;\n }\n if (identifier.className === rowInstanceKey.className) {\n return true;\n }\n return firstValueFrom(\n merge(\n fromPossiblyPromise(this._imodelAccess.classDerivesFrom(identifier.className, rowInstanceKey.className)),\n fromPossiblyPromise(this._imodelAccess.classDerivesFrom(rowInstanceKey.className, identifier.className)),\n ).pipe(\n filter((classDerives) => classDerives),\n defaultIfEmpty(false),\n take(1),\n ),\n );\n },\n });\n return fromPossiblyPromise(nodeSearchPropPossiblyPromise).pipe(\n map((nodeExtraProps) => {\n if (nodeExtraProps?.search) {\n parsedNode.search = nodeExtraProps.search;\n }\n return parsedNode;\n }),\n );\n }),\n );\n };\n }\n\n public defineHierarchyLevel(props: DefineHierarchyLevelProps): Observable<HierarchyLevelDefinition> {\n const sourceDefinitions = this._source.defineHierarchyLevel(props);\n\n const searchHelper = createHierarchySearchHelper(this._targetPaths, props.parentNode);\n const childNodeSearchIdentifiers = searchHelper.getChildNodeSearchIdentifiers();\n if (!childNodeSearchIdentifiers) {\n return sourceDefinitions;\n }\n\n const [genericNodeDefinitions, instanceNodeDefinitions] = partition(sourceDefinitions.pipe(mergeAll()), HierarchyNodesDefinition.isGenericNode);\n return merge(\n genericNodeDefinitions.pipe(\n map((definition) => {\n if (\n searchHelper.hasSearchTargetAncestor ||\n childNodeSearchIdentifiers.some(\n (identifier) =>\n HierarchyNodeIdentifier.isGenericNodeIdentifier(identifier) &&\n (!identifier.source || identifier.source === this.#sourceName) &&\n identifier.id === definition.node.key,\n )\n ) {\n return {\n ...definition,\n node: {\n ...definition.node,\n ...searchHelper.createChildNodeProps({ pathMatcher: ({ id }) => id === definition.node.key }),\n },\n };\n }\n return undefined;\n }),\n filter((def): def is GenericHierarchyNodeDefinition => !!def),\n ),\n\n instanceNodeDefinitions.pipe(\n mergeMap((definition) => {\n if (searchHelper.hasSearchTargetAncestor) {\n // if we have a search target ancestor, we don't need to search the definitions - we use all of them\n return of(applyECInstanceIdsSelector(definition));\n }\n return defer(async () => {\n const imodelAccess = this._imodelAccess;\n const matches = new Map<Id64String, IModelInstanceKey[]>();\n async function getEntries(x: IModelInstanceKey) {\n let entries = matches.get(x.id);\n if (!entries) {\n entries = [];\n matches.set(x.id, entries);\n }\n // make sure that we don't have path identifiers that only differ by class name, where\n // class names are in the same class hierarchy, e.g.:\n // [{ className: \"bis.Element\", id: \"0x1\" }, { className: \"bis.Subject\", id: \"0x1\" }]\n // are actually the same instance, so we only need to keep one of them, or otherwise the query will\n // duplicate it\n for (const entry of entries) {\n if (\n entry.className === x.className ||\n (await imodelAccess.classDerivesFrom(entry.className, x.className)) ||\n (await imodelAccess.classDerivesFrom(x.className, entry.className))\n ) {\n return undefined;\n }\n }\n return entries;\n }\n for (const id of childNodeSearchIdentifiers) {\n // take only identifiers that match the definition by type, source and class\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {\n continue;\n }\n if (id.imodelKey && id.imodelKey !== imodelAccess.imodelKey) {\n continue;\n }\n if (\n id.className !== definition.fullClassName &&\n !(await Promise.all([\n imodelAccess.classDerivesFrom(id.className, definition.fullClassName),\n imodelAccess.classDerivesFrom(definition.fullClassName, id.className),\n ]).then(([isDerivedFrom, isDerivedTo]) => isDerivedFrom || isDerivedTo))\n ) {\n continue;\n }\n const entriesTargetForPathIdentifier = await getEntries(id);\n if (entriesTargetForPathIdentifier) {\n entriesTargetForPathIdentifier.push(id);\n }\n }\n return Array.from(matches.values()).flat();\n }).pipe(\n // only take definitions that have matching path identifiers\n filter((pathIdentifiers) => pathIdentifiers.length > 0),\n\n // for each definition that we're going to use, apply query-level search\n map((pathIdentifiers) => applyECInstanceIdsSearch(definition, pathIdentifiers)),\n );\n }),\n ),\n ).pipe(toArray());\n }\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_SearchECInstanceId = \"SearchECInstanceId\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_SearchClassName = \"SearchClassName\";\n\nfunction getClassECInstanceIds(targetInstanceKeys: InstanceKey[]) {\n const classNameECInstanceIds = new Map<string, Id64String[]>();\n for (const key of targetInstanceKeys) {\n const entry = classNameECInstanceIds.get(key.className);\n if (entry === undefined) {\n classNameECInstanceIds.set(key.className, [key.id]);\n continue;\n }\n entry.push(key.id);\n }\n return classNameECInstanceIds;\n}\n\n/** @internal */\nexport function applyECInstanceIdsSearch(def: InstanceNodesQueryDefinition, targetInstanceKeys: InstanceKey[]): InstanceNodesQueryDefinition {\n const instanceIdsByClass = getClassECInstanceIds(targetInstanceKeys);\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n `SearchInfo(ECInstanceId, SearchClassName) AS (\n ${Array.from(instanceIdsByClass)\n .map(\n ([className, ecInstanceIds]) => `\n SELECT ECInstanceId, '${className}' AS SearchClassName\n FROM ${className}\n WHERE ECInstanceId IN (${ecInstanceIds.join(\", \")})\n `,\n )\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n IdToHex([f].[ECInstanceId]) AS [${ECSQL_COLUMN_NAME_SearchECInstanceId}],\n [f].[SearchClassName] AS [${ECSQL_COLUMN_NAME_SearchClassName}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n JOIN SearchInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n\n/** @internal */\nexport function applyECInstanceIdsSelector(def: InstanceNodesQueryDefinition): InstanceNodesQueryDefinition {\n return {\n ...def,\n query: {\n ...def.query,\n ecsql: `\n SELECT\n [q].*,\n IdToHex([q].[ECInstanceId]) AS [${ECSQL_COLUMN_NAME_SearchECInstanceId}],\n [q].[${NodeSelectClauseColumnNames.FullClassName}] AS [${ECSQL_COLUMN_NAME_SearchClassName}]\n FROM (${def.query.ecsql}) [q]\n `,\n },\n };\n}\n\nfunction shouldAutoExpandGroupingNodeBasedOnNestedChildren({\n directOrIndirectChildren,\n parentKeysLength,\n parentKeysWithoutGroupingNodesLength,\n}: {\n directOrIndirectChildren: Array<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode>;\n parentKeysLength: number;\n parentKeysWithoutGroupingNodesLength: number;\n}) {\n for (const child of directOrIndirectChildren) {\n if (ProcessedHierarchyNode.isGroupingNode(child)) {\n // Need to check if the same grouping node needs to be expanded, but check the indirect children instead\n if (\n shouldAutoExpandGroupingNodeBasedOnNestedChildren({ directOrIndirectChildren: child.children, parentKeysLength, parentKeysWithoutGroupingNodesLength })\n ) {\n return true;\n }\n continue;\n }\n\n /* c8 ignore next 3 */\n if (!child.search) {\n continue;\n }\n\n if (\n child.search.isSearchTarget &&\n shouldAutoExpandBasedOnReveal({\n reveal: child.search.searchTargetOptions?.reveal,\n nodePositionInHierarchy: parentKeysLength,\n // Grouping node is not in search path, but we can assume that it is at the position of 1 less than `parentKeysWithoutGroupingNodesLength`\n nodePositionInPath: parentKeysWithoutGroupingNodesLength - 1,\n })\n ) {\n return true;\n }\n\n if (!child.search.childrenTargetPaths) {\n /* c8 ignore next */\n continue;\n }\n\n for (const path of child.search.childrenTargetPaths) {\n if (\n \"path\" in path &&\n shouldAutoExpandBasedOnReveal({\n reveal: path.options?.reveal,\n nodePositionInHierarchy: parentKeysLength,\n // Grouping node is not in search path, but we can assume that it is at the position of 1 less than `parentKeysWithoutGroupingNodesLength`\n nodePositionInPath: parentKeysWithoutGroupingNodesLength - 1,\n })\n ) {\n return true;\n }\n }\n }\n return false;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SearchHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/SearchHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAoQhG,4DAgCC;AAGD,gEAcC;AAnTD,+BAAoI;AAEpI,oEAA2G;AAC3G,8EAAwE;AACxE,gEAA6E;AAC7E,8DAAwH;AACxH,yFAMgD;AAChD,6EAA0I;AAC1I,mFAAkF;AAClF,qEAAkE;AAClE,qDAA4D;AAC5D,qEAA+D;AAW/D,gBAAgB;AAChB,MAAa,yBAAyB;IAC5B,aAAa,CAA4B;IACzC,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AC,KAAK,CAAC,EAAE,CAAC;YACjD,wGAAwG;YACxG,IACE,iDAAiD,CAAC,EAAE,wBAAwB,EAAE,KAAK,CAAC,QAAQ,EAAE,gBAAgB,EAAE,oCAAoC,EAAE,CAAC,EACvJ,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;YACD,SAAS;QACX,CAAC;QAED,sBAAsB;QACtB,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAClB,SAAS;QACX,CAAC;QAED,IACE,KAAK,CAAC,MAAM,CAAC,cAAc;YAC3B,IAAA,kDAA6B,EAAC;gBAC5B,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM;gBAChD,uBAAuB,EAAE,gBAAgB;gBACzC,0IAA0I;gBAC1I,kBAAkB,EAAE,oCAAoC,GAAG,CAAC;aAC7D,CAAC,EACF,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;YACtC,oBAAoB;YACpB,SAAS;QACX,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;YACpD,IACE,MAAM,IAAI,IAAI;gBACd,IAAA,kDAA6B,EAAC;oBAC5B,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM;oBAC5B,uBAAuB,EAAE,gBAAgB;oBACzC,0IAA0I;oBAC1I,kBAAkB,EAAE,oCAAoC,GAAG,CAAC;iBAC7D,CAAC,EACF,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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 { defaultIfEmpty, defer, filter, firstValueFrom, map, merge, mergeAll, mergeMap, Observable, of, take, toArray } from \"rxjs\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { compareFullClassNames, ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport { HierarchyNodeIdentifier } from \"../HierarchyNodeIdentifier.js\";\nimport { HierarchyNodeKey, IModelInstanceKey } from \"../HierarchyNodeKey.js\";\nimport { createHierarchySearchHelper, HierarchySearchPath, shouldAutoExpandBasedOnReveal } from \"../HierarchySearch.js\";\nimport {\n DefineHierarchyLevelProps,\n GenericHierarchyNodeDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n} from \"../imodel/IModelHierarchyDefinition.js\";\nimport { ProcessedGroupingHierarchyNode, ProcessedHierarchyNode, ProcessedInstanceHierarchyNode } from \"../imodel/IModelHierarchyNode.js\";\nimport { NodeSelectClauseColumnNames } from \"../imodel/NodeSelectQueryFactory.js\";\nimport { defaultNodesParser } from \"../imodel/TreeNodesReader.js\";\nimport { fromPossiblyPromise } from \"../internal/Common.js\";\nimport { partition } from \"../internal/operators/Partition.js\";\nimport { RxjsHierarchyDefinition, RxjsNodeParser, RxjsNodePostProcessor, RxjsNodePreProcessor } from \"../internal/RxjsHierarchyDefinition.js\";\n\ninterface SearchHierarchyDefinitionProps {\n imodelAccess: ECClassHierarchyInspector;\n source: RxjsHierarchyDefinition;\n sourceName: string;\n targetPaths: HierarchySearchPath[];\n nodesParser?: RxjsNodeParser;\n}\n\n/** @internal */\nexport class SearchHierarchyDefinition implements RxjsHierarchyDefinition {\n private _imodelAccess: ECClassHierarchyInspector;\n private _source: RxjsHierarchyDefinition;\n private _targetPaths: HierarchySearchPath[];\n private _nodesParser: RxjsNodeParser;\n #sourceName: string;\n\n public constructor(props: SearchHierarchyDefinitionProps) {\n this._imodelAccess = props.imodelAccess;\n this._source = props.source;\n this.#sourceName = props.sourceName;\n this._targetPaths = props.targetPaths;\n this._nodesParser = props.nodesParser ?? this._source.parseNode ?? ((row) => of(defaultNodesParser(row)));\n }\n\n public get preProcessNode(): RxjsNodePreProcessor {\n return (node) =>\n (this._source.preProcessNode ? this._source.preProcessNode(node) : of(node)).pipe(\n filter((processedNode) => {\n if (processedNode.processingParams?.hideInHierarchy && processedNode.search?.isSearchTarget && !processedNode.search.hasSearchTargetAncestor) {\n // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another search target\n return false;\n }\n return true;\n }),\n );\n }\n\n public get postProcessNode(): RxjsNodePostProcessor {\n return (node) =>\n (this._source.postProcessNode ? this._source.postProcessNode(node) : of(node)).pipe(\n map((processedNode) => {\n const parentKeysWithoutGroupingNodesLength = processedNode.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;\n const parentKeysLength = processedNode.parentKeys.length;\n const shouldAutoExpand = ProcessedHierarchyNode.isGroupingNode(processedNode)\n ? shouldAutoExpandGroupingNodeBasedOnNestedChildren({\n directOrIndirectChildren: processedNode.children,\n parentKeysWithoutGroupingNodesLength,\n parentKeysLength,\n })\n : (processedNode.search?.isSearchTarget && !!processedNode.search.searchTargetOptions?.autoExpand) ||\n processedNode.search?.childrenTargetPaths?.some((path) =>\n shouldAutoExpandBasedOnReveal({\n reveal: HierarchySearchPath.normalize(path).options?.reveal,\n nodePositionInPath: parentKeysWithoutGroupingNodesLength,\n nodePositionInHierarchy: parentKeysLength,\n }),\n );\n if (shouldAutoExpand) {\n Object.assign(processedNode, { autoExpand: true });\n }\n\n return processedNode;\n }),\n );\n }\n\n public get parseNode(): RxjsNodeParser {\n return (props) =>\n this._nodesParser(props).pipe(\n mergeMap((parsedNode) => {\n const { row, parentNode, imodelKey } = props;\n if (!row[ECSQL_COLUMN_NAME_SearchECInstanceId] || !row[ECSQL_COLUMN_NAME_SearchClassName]) {\n return of(parsedNode);\n }\n const rowInstanceKey = { className: row[ECSQL_COLUMN_NAME_SearchClassName], id: row[ECSQL_COLUMN_NAME_SearchECInstanceId] };\n const searchHelper = createHierarchySearchHelper(this._targetPaths, parentNode);\n const nodeSearchPropPossiblyPromise = searchHelper.createChildNodeProps({\n asyncPathMatcher: (identifier): boolean | Promise<boolean> => {\n if (identifier.id !== rowInstanceKey.id) {\n return false;\n }\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(identifier)) {\n return false;\n }\n if (identifier.imodelKey && identifier.imodelKey !== imodelKey) {\n return false;\n }\n if (compareFullClassNames(identifier.className, rowInstanceKey.className) === 0) {\n return true;\n }\n return firstValueFrom(\n merge(\n fromPossiblyPromise(this._imodelAccess.classDerivesFrom(identifier.className, rowInstanceKey.className)),\n fromPossiblyPromise(this._imodelAccess.classDerivesFrom(rowInstanceKey.className, identifier.className)),\n ).pipe(\n filter((classDerives) => classDerives),\n defaultIfEmpty(false),\n take(1),\n ),\n );\n },\n });\n return fromPossiblyPromise(nodeSearchPropPossiblyPromise).pipe(\n map((nodeExtraProps) => {\n if (nodeExtraProps?.search) {\n parsedNode.search = nodeExtraProps.search;\n }\n return parsedNode;\n }),\n );\n }),\n );\n }\n\n public defineHierarchyLevel(props: DefineHierarchyLevelProps): Observable<HierarchyLevelDefinition> {\n const sourceDefinitions = this._source.defineHierarchyLevel(props);\n\n const searchHelper = createHierarchySearchHelper(this._targetPaths, props.parentNode);\n const childNodeSearchIdentifiers = searchHelper.getChildNodeSearchIdentifiers();\n if (!childNodeSearchIdentifiers) {\n return sourceDefinitions;\n }\n\n const [genericNodeDefinitions, instanceNodeDefinitions] = partition(sourceDefinitions.pipe(mergeAll()), HierarchyNodesDefinition.isGenericNode);\n return merge(\n genericNodeDefinitions.pipe(\n map((definition) => {\n if (\n searchHelper.hasSearchTargetAncestor ||\n childNodeSearchIdentifiers.some(\n (identifier) =>\n HierarchyNodeIdentifier.isGenericNodeIdentifier(identifier) &&\n (!identifier.source || identifier.source === this.#sourceName) &&\n identifier.id === definition.node.key,\n )\n ) {\n return {\n ...definition,\n node: {\n ...definition.node,\n ...searchHelper.createChildNodeProps({ pathMatcher: ({ id }) => id === definition.node.key }),\n },\n };\n }\n return undefined;\n }),\n filter((def): def is GenericHierarchyNodeDefinition => !!def),\n ),\n\n instanceNodeDefinitions.pipe(\n mergeMap((definition) => {\n if (searchHelper.hasSearchTargetAncestor) {\n // if we have a search target ancestor, we don't need to search the definitions - we use all of them\n return of(applyECInstanceIdsSelector(definition));\n }\n return defer(async () => {\n const imodelAccess = this._imodelAccess;\n const matches = new Map<Id64String, IModelInstanceKey[]>();\n async function getEntries(x: IModelInstanceKey) {\n let entries = matches.get(x.id);\n if (!entries) {\n entries = [];\n matches.set(x.id, entries);\n }\n // make sure that we don't have path identifiers that only differ by class name, where\n // class names are in the same class hierarchy, e.g.:\n // [{ className: \"bis.Element\", id: \"0x1\" }, { className: \"bis.Subject\", id: \"0x1\" }]\n // are actually the same instance, so we only need to keep one of them, or otherwise the query will\n // duplicate it\n for (const entry of entries) {\n if (\n compareFullClassNames(entry.className, x.className) === 0 ||\n (await imodelAccess.classDerivesFrom(entry.className, x.className)) ||\n (await imodelAccess.classDerivesFrom(x.className, entry.className))\n ) {\n return undefined;\n }\n }\n return entries;\n }\n for (const id of childNodeSearchIdentifiers) {\n // take only identifiers that match the definition by type, source and class\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {\n continue;\n }\n if (id.imodelKey && id.imodelKey !== props.imodelKey) {\n continue;\n }\n if (\n compareFullClassNames(id.className, definition.fullClassName) !== 0 &&\n !(await Promise.all([\n imodelAccess.classDerivesFrom(id.className, definition.fullClassName),\n imodelAccess.classDerivesFrom(definition.fullClassName, id.className),\n ]).then(([isDerivedFrom, isDerivedTo]) => isDerivedFrom || isDerivedTo))\n ) {\n continue;\n }\n const entriesTargetForPathIdentifier = await getEntries(id);\n if (entriesTargetForPathIdentifier) {\n entriesTargetForPathIdentifier.push(id);\n }\n }\n return Array.from(matches.values()).flat();\n }).pipe(\n // only take definitions that have matching path identifiers\n filter((pathIdentifiers) => pathIdentifiers.length > 0),\n\n // for each definition that we're going to use, apply query-level search\n map((pathIdentifiers) => applyECInstanceIdsSearch(definition, pathIdentifiers)),\n );\n }),\n ),\n ).pipe(toArray());\n }\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_SearchECInstanceId = \"SearchECInstanceId\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_SearchClassName = \"SearchClassName\";\n\nfunction getClassECInstanceIds(targetInstanceKeys: InstanceKey[]) {\n const classNameECInstanceIds = new Map<string, Id64String[]>();\n for (const key of targetInstanceKeys) {\n const entry = classNameECInstanceIds.get(key.className);\n if (entry === undefined) {\n classNameECInstanceIds.set(key.className, [key.id]);\n continue;\n }\n entry.push(key.id);\n }\n return classNameECInstanceIds;\n}\n\n/** @internal */\nexport function applyECInstanceIdsSearch(def: InstanceNodesQueryDefinition, targetInstanceKeys: InstanceKey[]): InstanceNodesQueryDefinition {\n const instanceIdsByClass = getClassECInstanceIds(targetInstanceKeys);\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n `SearchInfo(ECInstanceId, SearchClassName) AS (\n ${Array.from(instanceIdsByClass)\n .map(\n ([className, ecInstanceIds]) => `\n SELECT ECInstanceId, '${className}' AS SearchClassName\n FROM ${className}\n WHERE ECInstanceId IN (${ecInstanceIds.join(\", \")})\n `,\n )\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n IdToHex([f].[ECInstanceId]) AS [${ECSQL_COLUMN_NAME_SearchECInstanceId}],\n [f].[SearchClassName] AS [${ECSQL_COLUMN_NAME_SearchClassName}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n JOIN SearchInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n\n/** @internal */\nexport function applyECInstanceIdsSelector(def: InstanceNodesQueryDefinition): InstanceNodesQueryDefinition {\n return {\n ...def,\n query: {\n ...def.query,\n ecsql: `\n SELECT\n [q].*,\n IdToHex([q].[ECInstanceId]) AS [${ECSQL_COLUMN_NAME_SearchECInstanceId}],\n [q].[${NodeSelectClauseColumnNames.FullClassName}] AS [${ECSQL_COLUMN_NAME_SearchClassName}]\n FROM (${def.query.ecsql}) [q]\n `,\n },\n };\n}\n\nfunction shouldAutoExpandGroupingNodeBasedOnNestedChildren({\n directOrIndirectChildren,\n parentKeysLength,\n parentKeysWithoutGroupingNodesLength,\n}: {\n directOrIndirectChildren: Array<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode>;\n parentKeysLength: number;\n parentKeysWithoutGroupingNodesLength: number;\n}) {\n for (const child of directOrIndirectChildren) {\n if (ProcessedHierarchyNode.isGroupingNode(child)) {\n // Need to check if the same grouping node needs to be expanded, but check the indirect children instead\n if (\n shouldAutoExpandGroupingNodeBasedOnNestedChildren({ directOrIndirectChildren: child.children, parentKeysLength, parentKeysWithoutGroupingNodesLength })\n ) {\n return true;\n }\n continue;\n }\n\n /* c8 ignore next 3 */\n if (!child.search) {\n continue;\n }\n\n if (\n child.search.isSearchTarget &&\n shouldAutoExpandBasedOnReveal({\n reveal: child.search.searchTargetOptions?.reveal,\n nodePositionInHierarchy: parentKeysLength,\n // Grouping node is not in search path, but we can assume that it is at the position of 1 less than `parentKeysWithoutGroupingNodesLength`\n nodePositionInPath: parentKeysWithoutGroupingNodesLength - 1,\n })\n ) {\n return true;\n }\n\n if (!child.search.childrenTargetPaths) {\n /* c8 ignore next */\n continue;\n }\n\n for (const path of child.search.childrenTargetPaths) {\n if (\n \"path\" in path &&\n shouldAutoExpandBasedOnReveal({\n reveal: path.options?.reveal,\n nodePositionInHierarchy: parentKeysLength,\n // Grouping node is not in search path, but we can assume that it is at the position of 1 less than `parentKeysWithoutGroupingNodesLength`\n nodePositionInPath: parentKeysWithoutGroupingNodesLength - 1,\n })\n ) {\n return true;\n }\n }\n }\n return false;\n}\n"]}
|