@itwin/presentation-backend 3.3.0-dev.3 → 3.3.0-dev.32
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 +21 -1
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +19 -16
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +7 -7
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +2 -2
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +29 -8
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +5 -7
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js +60 -87
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/Utils.d.ts +13 -2
- package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/Utils.js +2 -2
- package/lib/cjs/presentation-backend/Utils.js.map +1 -1
- package/package.json +14 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationRpcImpl.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+C;AAC/C,sDAA8E;AAE9E,oEAQoC;AACpC,mEAA4E;AAC5E,iDAA8C;AAE9C,yDAAsD;AAItD,gBAAgB;AACH,QAAA,qBAAqB,GAAG,IAAI,CAAC;AAC1C,gBAAgB;AACH,QAAA,0BAA0B,GAAG,KAAK,CAAC;AAEhD;;;;;GAKG;AACH,MAAa,mBAAoB,SAAQ,8CAAw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,EAAE,EAAE,CAAC;IAC1F,OAAO,cAAsD,CAAC;AAChE,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,IAAwB,EAAE,WAAmB,EAAE,EAAE;IACzE,MAAM,aAAa,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,CAAC,CAAC;IAChC,OAAO,CAAC,aAAa,KAAK,CAAC,IAAI,aAAa,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC;AAC5F,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,IAA6B,EAAuB,EAAE;IAC7E,IAAI,CAAC,IAAI;QACP,OAAO,SAAS,CAAC;IACnB,OAAO,6BAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RPC\r\n */\r\n\r\nimport { IModelDb } from \"@itwin/core-backend\";\r\nimport { assert, Id64String, IDisposable, Logger } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"@itwin/core-common\";\r\nimport {\r\n ContentDescriptorRpcRequestOptions, ContentFlags, ContentInstanceKeysRpcRequestOptions, ContentRpcRequestOptions, ContentSourcesRpcRequestOptions,\r\n ContentSourcesRpcResult, DescriptorJSON, DiagnosticsOptions, DiagnosticsScopeLogs, DisplayLabelRpcRequestOptions, DisplayLabelsRpcRequestOptions,\r\n DisplayValueGroup, DisplayValueGroupJSON, DistinctValuesRpcRequestOptions, ElementProperties, FilterByInstancePathsHierarchyRpcRequestOptions,\r\n FilterByTextHierarchyRpcRequestOptions, HierarchyRpcRequestOptions, InstanceKey, ItemJSON, KeySet, KeySetJSON, LabelDefinition, LabelDefinitionJSON,\r\n Node, NodeJSON, NodeKey, NodeKeyJSON, NodePathElement, NodePathElementJSON, Paged, PagedResponse, PageOptions, PresentationError,\r\n PresentationRpcInterface, PresentationRpcResponse, PresentationRpcResponseData, PresentationStatus, Ruleset, RulesetVariable, RulesetVariableJSON,\r\n SelectClassInfo, SelectionScope, SelectionScopeRpcRequestOptions, SingleElementPropertiesRpcRequestOptions,\r\n} from \"@itwin/presentation-common\";\r\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { Presentation } from \"./Presentation\";\r\nimport { PresentationManager } from \"./PresentationManager\";\r\nimport { TemporaryStorage } from \"./TemporaryStorage\";\r\n\r\ntype ContentGetter<TResult = any, TOptions = any> = (requestOptions: TOptions) => TResult;\r\n\r\n/** @internal */\r\nexport const MAX_ALLOWED_PAGE_SIZE = 1000;\r\n/** @internal */\r\nexport const MAX_ALLOWED_KEYS_PAGE_SIZE = 10000;\r\n\r\n/**\r\n * The backend implementation of PresentationRpcInterface. All it's basically\r\n * responsible for is forwarding calls to [[Presentation.manager]].\r\n *\r\n * @internal\r\n */\r\nexport class PresentationRpcImpl extends PresentationRpcInterface implements IDisposable {\r\n\r\n private _requestTimeout: number;\r\n private _pendingRequests: TemporaryStorage<PresentationRpcResponse<any>>;\r\n\r\n public constructor(props?: { requestTimeout: number }) {\r\n super();\r\n this._requestTimeout = props?.requestTimeout ?? 90 * 1000;\r\n this._pendingRequests = new TemporaryStorage({\r\n // remove the pending request after request timeout + 10 seconds - this gives\r\n // frontend 10 seconds to re-send the request until it's removed from requests' cache\r\n unusedValueLifetime: this._requestTimeout + 10 * 1000,\r\n\r\n // attempt to clean up every second\r\n cleanupInterval: 1000,\r\n\r\n cleanupHandler: (id, _, reason) => {\r\n if (reason !== \"request\")\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Cleaning up request without frontend retrieving it: ${id}.`);\r\n },\r\n });\r\n }\r\n\r\n public dispose() {\r\n this._pendingRequests.dispose();\r\n }\r\n\r\n public get requestTimeout() { return this._requestTimeout; }\r\n\r\n /** Returns an ok response with result inside */\r\n private successResponse<TResult>(result: TResult, diagnostics?: DiagnosticsScopeLogs[]) {\r\n return {\r\n statusCode: PresentationStatus.Success,\r\n result,\r\n diagnostics,\r\n };\r\n }\r\n\r\n /** Returns a bad request response with empty result and an error code */\r\n private errorResponse(errorCode: PresentationStatus, errorMessage?: string, diagnostics?: DiagnosticsScopeLogs[]) {\r\n return {\r\n statusCode: errorCode,\r\n result: undefined,\r\n errorMessage,\r\n diagnostics,\r\n };\r\n }\r\n\r\n /**\r\n * Get the [[PresentationManager]] used by this RPC impl.\r\n */\r\n public getManager(clientId?: string): PresentationManager {\r\n return Presentation.getManager(clientId);\r\n }\r\n\r\n private getIModel(token: IModelRpcProps): IModelDb {\r\n let imodel: IModelDb;\r\n try {\r\n imodel = IModelDb.findByKey(token.key);\r\n } catch {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, \"IModelRpcProps doesn't point to a valid iModel\");\r\n }\r\n return imodel;\r\n }\r\n\r\n private async makeRequest<TRpcOptions extends { rulesetOrId?: Ruleset | string, clientId?: string, diagnostics?: DiagnosticsOptions, rulesetVariables?: RulesetVariableJSON[] }, TResult>(token: IModelRpcProps, requestId: string, requestOptions: TRpcOptions, request: ContentGetter<Promise<TResult>>): PresentationRpcResponse<TResult> {\r\n const requestKey = JSON.stringify({ iModelKey: token.key, requestId, requestOptions });\r\n\r\n Logger.logInfo(PresentationBackendLoggerCategory.Rpc, `Received '${requestId}' request. Params: ${requestKey}`);\r\n\r\n let resultPromise = this._pendingRequests.getValue(requestKey);\r\n if (resultPromise) {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request already pending`);\r\n } else {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request not found, creating a new one`);\r\n let imodel: IModelDb;\r\n try {\r\n imodel = this.getIModel(token);\r\n } catch (e) {\r\n assert(e instanceof Error);\r\n return this.errorResponse(PresentationStatus.InvalidArgument, e.message);\r\n }\r\n\r\n const { clientId: _, diagnostics: diagnosticsOptions, rulesetVariables, ...options } = requestOptions;\r\n const managerRequestOptions: any = {\r\n ...options,\r\n imodel,\r\n };\r\n\r\n // set up ruleset variables\r\n if (rulesetVariables)\r\n managerRequestOptions.rulesetVariables = rulesetVariables.map(RulesetVariable.fromJSON);\r\n\r\n // set up diagnostics listener\r\n let diagnosticLogs: DiagnosticsScopeLogs[] | undefined;\r\n if (diagnosticsOptions) {\r\n managerRequestOptions.diagnostics = {\r\n ...diagnosticsOptions,\r\n handler: (logs: DiagnosticsScopeLogs[]) => {\r\n if (!diagnosticLogs)\r\n diagnosticLogs = [];\r\n diagnosticLogs.push(...logs);\r\n },\r\n };\r\n }\r\n\r\n // initiate request\r\n resultPromise = request(managerRequestOptions)\r\n .then((result) => this.successResponse(result, diagnosticLogs))\r\n .catch((e: PresentationError) => this.errorResponse(e.errorNumber, e.message, diagnosticLogs));\r\n\r\n // store the request promise\r\n this._pendingRequests.addValue(requestKey, resultPromise);\r\n }\r\n\r\n if (this._requestTimeout === 0) {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout not configured, returning promise without a timeout.`);\r\n resultPromise.finally(() => {\r\n this._pendingRequests.deleteValue(requestKey);\r\n });\r\n return resultPromise;\r\n }\r\n\r\n let timeout: NodeJS.Timeout;\r\n const timeoutPromise = new Promise<any>((_resolve, reject) => {\r\n timeout = setTimeout(() => {\r\n reject(\"Timed out\");\r\n }, this._requestTimeout);\r\n });\r\n\r\n /* eslint-disable @typescript-eslint/indent */\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Returning a promise with a timeout of ${this._requestTimeout}.`);\r\n return Promise\r\n .race([resultPromise, timeoutPromise])\r\n .catch<PresentationRpcResponseData>(() => {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout, returning \"BackendTimeout\" status.`);\r\n return this.errorResponse(PresentationStatus.BackendTimeout);\r\n })\r\n .then((response: PresentationRpcResponseData<any>) => {\r\n if (response.statusCode !== PresentationStatus.BackendTimeout) {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request completed, returning result.`);\r\n this._pendingRequests.deleteValue(requestKey);\r\n }\r\n clearTimeout(timeout);\r\n return response;\r\n });\r\n /* eslint-enable @typescript-eslint/indent */\r\n }\r\n\r\n public override async getNodesCount(token: IModelRpcProps, requestOptions: HierarchyRpcRequestOptions): PresentationRpcResponse<number> {\r\n return this.makeRequest(token, \"getNodesCount\", requestOptions, async (options) => {\r\n options = {\r\n ...options,\r\n parentKey: nodeKeyFromJson(options.parentKey),\r\n };\r\n return this.getManager(requestOptions.clientId).getNodesCount(options);\r\n });\r\n }\r\n\r\n public override async getPagedNodes(token: IModelRpcProps, requestOptions: Paged<HierarchyRpcRequestOptions>): PresentationRpcResponse<PagedResponse<NodeJSON>> {\r\n return this.makeRequest(token, \"getPagedNodes\", requestOptions, async (options) => {\r\n options = enforceValidPageSize({\r\n ...options,\r\n parentKey: nodeKeyFromJson(options.parentKey),\r\n });\r\n const [nodes, count] = await Promise.all([\r\n this.getManager(requestOptions.clientId).getNodes(options),\r\n this.getManager(requestOptions.clientId).getNodesCount(options),\r\n ]);\r\n return { total: count, items: nodes.map(Node.toJSON) };\r\n });\r\n }\r\n\r\n public override async getNodePaths(token: IModelRpcProps, requestOptions: FilterByInstancePathsHierarchyRpcRequestOptions): PresentationRpcResponse<NodePathElementJSON[]> {\r\n return this.makeRequest(token, \"getNodePaths\", requestOptions, async (options) => {\r\n const result = await this.getManager(requestOptions.clientId).getNodePaths(options);\r\n return result.map(NodePathElement.toJSON);\r\n });\r\n }\r\n\r\n public override async getFilteredNodePaths(token: IModelRpcProps, requestOptions: FilterByTextHierarchyRpcRequestOptions): PresentationRpcResponse<NodePathElementJSON[]> {\r\n return this.makeRequest(token, \"getFilteredNodePaths\", requestOptions, async (options) => {\r\n const result = await this.getManager(requestOptions.clientId).getFilteredNodePaths(options);\r\n return result.map(NodePathElement.toJSON);\r\n });\r\n }\r\n\r\n public override async getContentSources(token: IModelRpcProps, requestOptions: ContentSourcesRpcRequestOptions): PresentationRpcResponse<ContentSourcesRpcResult> {\r\n return this.makeRequest(token, \"getContentSources\", requestOptions, async (options) => {\r\n const result = await this.getManager(requestOptions.clientId).getContentSources(options);\r\n const classesMap = {};\r\n const selectClasses = result.map((sci) => SelectClassInfo.toCompressedJSON(sci, classesMap));\r\n return { sources: selectClasses, classesMap };\r\n });\r\n }\r\n\r\n public override async getContentDescriptor(token: IModelRpcProps, requestOptions: ContentDescriptorRpcRequestOptions): PresentationRpcResponse<DescriptorJSON | undefined> {\r\n return this.makeRequest(token, \"getContentDescriptor\", requestOptions, async (options) => {\r\n options = {\r\n ...options,\r\n keys: KeySet.fromJSON(options.keys),\r\n };\r\n const descriptor = await this.getManager(requestOptions.clientId).getContentDescriptor(options);\r\n if (descriptor)\r\n return descriptor.toJSON();\r\n return undefined;\r\n });\r\n }\r\n\r\n public override async getContentSetSize(token: IModelRpcProps, requestOptions: ContentRpcRequestOptions): PresentationRpcResponse<number> {\r\n return this.makeRequest(token, \"getContentSetSize\", requestOptions, async (options) => {\r\n options = {\r\n ...options,\r\n keys: KeySet.fromJSON(options.keys),\r\n };\r\n return this.getManager(requestOptions.clientId).getContentSetSize(options);\r\n });\r\n }\r\n\r\n public override async getPagedContent(token: IModelRpcProps, requestOptions: Paged<ContentRpcRequestOptions>): PresentationRpcResponse<{ descriptor: DescriptorJSON, contentSet: PagedResponse<ItemJSON> } | undefined> {\r\n return this.makeRequest(token, \"getPagedContent\", requestOptions, async (options) => {\r\n options = enforceValidPageSize({\r\n ...options,\r\n keys: KeySet.fromJSON(options.keys),\r\n });\r\n\r\n const [size, content] = await Promise.all([\r\n this.getManager(requestOptions.clientId).getContentSetSize(options),\r\n this.getManager(requestOptions.clientId).getContent(options),\r\n ]);\r\n\r\n if (!content)\r\n return undefined;\r\n\r\n return {\r\n descriptor: content.descriptor.toJSON(),\r\n contentSet: {\r\n total: size,\r\n items: content.contentSet.map((i) => i.toJSON()),\r\n },\r\n };\r\n });\r\n }\r\n\r\n public override async getPagedContentSet(token: IModelRpcProps, requestOptions: Paged<ContentRpcRequestOptions>): PresentationRpcResponse<PagedResponse<ItemJSON>> {\r\n const content = await this.getPagedContent(token, requestOptions);\r\n return this.successResponse(content.result ? content.result.contentSet : { total: 0, items: [] });\r\n }\r\n\r\n public override async getElementProperties(token: IModelRpcProps, requestOptions: SingleElementPropertiesRpcRequestOptions): PresentationRpcResponse<ElementProperties | undefined> {\r\n return this.makeRequest(token, \"getElementProperties\", { ...requestOptions }, async (options) => {\r\n return this.getManager(requestOptions.clientId).getElementProperties(options);\r\n });\r\n }\r\n\r\n public override async getPagedDistinctValues(token: IModelRpcProps, requestOptions: DistinctValuesRpcRequestOptions): PresentationRpcResponse<PagedResponse<DisplayValueGroupJSON>> {\r\n return this.makeRequest(token, \"getPagedDistinctValues\", requestOptions, async (options) => {\r\n options = enforceValidPageSize({\r\n ...options,\r\n keys: KeySet.fromJSON(options.keys),\r\n });\r\n const response = await this.getManager(requestOptions.clientId).getPagedDistinctValues(options);\r\n return {\r\n ...response,\r\n items: response.items.map(DisplayValueGroup.toJSON),\r\n };\r\n });\r\n }\r\n\r\n public override async getContentInstanceKeys(token: IModelRpcProps, requestOptions: ContentInstanceKeysRpcRequestOptions): PresentationRpcResponse<{ total: number, items: KeySetJSON }> {\r\n return this.makeRequest(token, \"getContentInstanceKeys\", requestOptions, async (options) => {\r\n const { displayType, ...optionsNoDisplayType } = options;\r\n options = enforceValidPageSize({\r\n ...optionsNoDisplayType,\r\n keys: KeySet.fromJSON(optionsNoDisplayType.keys),\r\n descriptor: {\r\n displayType,\r\n contentFlags: ContentFlags.KeysOnly,\r\n },\r\n }, MAX_ALLOWED_KEYS_PAGE_SIZE);\r\n\r\n const [size, content] = await Promise.all([\r\n this.getManager(requestOptions.clientId).getContentSetSize(options),\r\n this.getManager(requestOptions.clientId).getContent(options),\r\n ]);\r\n\r\n if (size === 0 || !content)\r\n return { total: 0, items: new KeySet().toJSON() };\r\n\r\n return {\r\n total: size,\r\n items: content.contentSet.reduce((keys, item) => keys.add(item.primaryKeys), new KeySet()).toJSON(),\r\n };\r\n });\r\n }\r\n\r\n public override async getDisplayLabelDefinition(token: IModelRpcProps, requestOptions: DisplayLabelRpcRequestOptions): PresentationRpcResponse<LabelDefinitionJSON> {\r\n return this.makeRequest(token, \"getDisplayLabelDefinition\", requestOptions, async (options) => {\r\n const label = await this.getManager(requestOptions.clientId).getDisplayLabelDefinition(options);\r\n return LabelDefinition.toJSON(label);\r\n });\r\n }\r\n\r\n public override async getPagedDisplayLabelDefinitions(token: IModelRpcProps, requestOptions: DisplayLabelsRpcRequestOptions): PresentationRpcResponse<PagedResponse<LabelDefinitionJSON>> {\r\n const pageOpts = enforceValidPageSize({ paging: { start: 0, size: requestOptions.keys.length } });\r\n if (pageOpts.paging.size < requestOptions.keys.length)\r\n requestOptions.keys.splice(pageOpts.paging.size);\r\n return this.makeRequest(token, \"getPagedDisplayLabelDefinitions\", requestOptions, async (options) => {\r\n const labels = await this.getManager(requestOptions.clientId).getDisplayLabelDefinitions({ ...options, keys: options.keys.map(InstanceKey.fromJSON) });\r\n return {\r\n total: options.keys.length,\r\n items: labels.map(LabelDefinition.toJSON),\r\n };\r\n });\r\n }\r\n\r\n public override async getSelectionScopes(token: IModelRpcProps, requestOptions: SelectionScopeRpcRequestOptions): PresentationRpcResponse<SelectionScope[]> {\r\n return this.makeRequest(token, \"getSelectionScopes\", requestOptions, async (options) =>\r\n this.getManager(requestOptions.clientId).getSelectionScopes(options),\r\n );\r\n }\r\n\r\n public override async computeSelection(token: IModelRpcProps, requestOptions: SelectionScopeRpcRequestOptions, ids: Id64String[], scopeId: string): PresentationRpcResponse<KeySetJSON> {\r\n return this.makeRequest(token, \"computeSelection\", { ...requestOptions, ids, scopeId }, async (options) => {\r\n const keys = await this.getManager(requestOptions.clientId).computeSelection(options);\r\n return keys.toJSON();\r\n });\r\n }\r\n}\r\n\r\nconst enforceValidPageSize = <TOptions extends Paged<object>>(requestOptions: TOptions, maxPageSize = MAX_ALLOWED_PAGE_SIZE): TOptions & { paging: PageOptions } => {\r\n const validPageSize = getValidPageSize(requestOptions.paging?.size, maxPageSize);\r\n if (!requestOptions.paging || requestOptions.paging.size !== validPageSize)\r\n return { ...requestOptions, paging: { ...requestOptions.paging, size: validPageSize } };\r\n return requestOptions as (TOptions & { paging: PageOptions });\r\n};\r\n\r\nconst getValidPageSize = (size: number | undefined, maxPageSize: number) => {\r\n const requestedSize = size ?? 0;\r\n return (requestedSize === 0 || requestedSize > maxPageSize) ? maxPageSize : requestedSize;\r\n};\r\n\r\nconst nodeKeyFromJson = (json: NodeKeyJSON | undefined): NodeKey | undefined => {\r\n if (!json)\r\n return undefined;\r\n return NodeKey.fromJSON(json);\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"PresentationRpcImpl.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+C;AAC/C,sDAA8E;AAE9E,oEASoC;AACpC,mEAA4E;AAC5E,iDAA8C;AAE9C,yDAAsD;AAEtD,8DAA8D;AAC9D,MAAM,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAAC;AAIpE,gBAAgB;AACH,QAAA,qBAAqB,GAAG,IAAI,CAAC;AAC1C,gBAAgB;AACH,QAAA,0BAA0B,GAAG,KAAK,CAAC;AAEhD;;;;;GAKG;AACH,MAAa,mBAAoB,SAAQ,8CAAwB;IAK/D,YAAmB,KAAkC;;QACnD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,eAAe,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,mCAAI,EAAE,GAAG,IAAI,CAAC;QAC1D,IAAI,CAAC,gBAAgB,GAAG,IAAI,mCAAgB,CAAC;YAC3C,6EAA6E;YAC7E,qFAAqF;YACrF,mBAAmB,EAA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AM,aAAa,GAAG,gBAAgB,CAAC,MAAA,cAAc,CAAC,MAAM,0CAAE,IAAI,EAAE,WAAW,CAAC,CAAC;IACjF,IAAI,CAAC,cAAc,CAAC,MAAM,IAAI,cAAc,CAAC,MAAM,CAAC,IAAI,KAAK,aAAa;QACxE,OAAO,EAAE,GAAG,cAAc,EAAE,MAAM,EAAE,EAAE,GAAG,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,CAAC;IAC1F,OAAO,cAAsD,CAAC;AAChE,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,IAAwB,EAAE,WAAmB,EAAE,EAAE;IACzE,MAAM,aAAa,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,CAAC,CAAC;IAChC,OAAO,CAAC,aAAa,KAAK,CAAC,IAAI,aAAa,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC;AAC5F,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,IAA6B,EAAuB,EAAE;IAC7E,IAAI,CAAC,IAAI;QACP,OAAO,SAAS,CAAC;IACnB,OAAO,6BAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RPC\r\n */\r\n\r\nimport { IModelDb } from \"@itwin/core-backend\";\r\nimport { assert, Id64String, IDisposable, Logger } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"@itwin/core-common\";\r\nimport {\r\n ClientDiagnostics, ComputeSelectionRpcRequestOptions, ContentDescriptorRpcRequestOptions, ContentFlags, ContentInstanceKeysRpcRequestOptions,\r\n ContentRpcRequestOptions, ContentSourcesRpcRequestOptions, ContentSourcesRpcResult, DescriptorJSON, Diagnostics, DisplayLabelRpcRequestOptions,\r\n DisplayLabelsRpcRequestOptions, DisplayValueGroup, DisplayValueGroupJSON, DistinctValuesRpcRequestOptions, ElementProperties,\r\n FilterByInstancePathsHierarchyRpcRequestOptions, FilterByTextHierarchyRpcRequestOptions, HierarchyRpcRequestOptions, InstanceKey,\r\n isComputeSelectionRequestOptions, ItemJSON, KeySet, KeySetJSON, LabelDefinition, LabelDefinitionJSON, Node, NodeJSON, NodeKey, NodeKeyJSON,\r\n NodePathElement, NodePathElementJSON, Paged, PagedResponse, PageOptions, PresentationError, PresentationRpcInterface, PresentationRpcResponse,\r\n PresentationRpcResponseData, PresentationStatus, RpcDiagnosticsOptions, Ruleset, RulesetVariable, RulesetVariableJSON, SelectClassInfo,\r\n SelectionScope, SelectionScopeRpcRequestOptions, SingleElementPropertiesRpcRequestOptions,\r\n} from \"@itwin/presentation-common\";\r\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { Presentation } from \"./Presentation\";\r\nimport { PresentationManager } from \"./PresentationManager\";\r\nimport { TemporaryStorage } from \"./TemporaryStorage\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-var-requires\r\nconst packageJsonVersion = require(\"../../../package.json\").version;\r\n\r\ntype ContentGetter<TResult = any, TOptions = any> = (requestOptions: TOptions) => TResult;\r\n\r\n/** @internal */\r\nexport const MAX_ALLOWED_PAGE_SIZE = 1000;\r\n/** @internal */\r\nexport const MAX_ALLOWED_KEYS_PAGE_SIZE = 10000;\r\n\r\n/**\r\n * The backend implementation of PresentationRpcInterface. All it's basically\r\n * responsible for is forwarding calls to [[Presentation.manager]].\r\n *\r\n * @internal\r\n */\r\nexport class PresentationRpcImpl extends PresentationRpcInterface implements IDisposable {\r\n\r\n private _requestTimeout: number;\r\n private _pendingRequests: TemporaryStorage<PresentationRpcResponse<any>>;\r\n\r\n public constructor(props?: { requestTimeout: number }) {\r\n super();\r\n this._requestTimeout = props?.requestTimeout ?? 90 * 1000;\r\n this._pendingRequests = new TemporaryStorage({\r\n // remove the pending request after request timeout + 10 seconds - this gives\r\n // frontend 10 seconds to re-send the request until it's removed from requests' cache\r\n unusedValueLifetime: this._requestTimeout + 10 * 1000,\r\n\r\n // attempt to clean up every second\r\n cleanupInterval: 1000,\r\n\r\n cleanupHandler: (id, _, reason) => {\r\n if (reason !== \"request\")\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Cleaning up request without frontend retrieving it: ${id}.`);\r\n },\r\n });\r\n }\r\n\r\n public dispose() {\r\n this._pendingRequests.dispose();\r\n }\r\n\r\n public get requestTimeout() { return this._requestTimeout; }\r\n\r\n /** Returns an ok response with result inside */\r\n private successResponse<TResult>(result: TResult, diagnostics?: ClientDiagnostics) {\r\n return {\r\n statusCode: PresentationStatus.Success,\r\n result,\r\n diagnostics,\r\n };\r\n }\r\n\r\n /** Returns a bad request response with empty result and an error code */\r\n private errorResponse(errorCode: PresentationStatus, errorMessage?: string, diagnostics?: ClientDiagnostics) {\r\n return {\r\n statusCode: errorCode,\r\n result: undefined,\r\n errorMessage,\r\n diagnostics,\r\n };\r\n }\r\n\r\n /**\r\n * Get the [[PresentationManager]] used by this RPC impl.\r\n */\r\n public getManager(clientId?: string): PresentationManager {\r\n return Presentation.getManager(clientId);\r\n }\r\n\r\n private getIModel(token: IModelRpcProps): IModelDb {\r\n let imodel: IModelDb;\r\n try {\r\n imodel = IModelDb.findByKey(token.key);\r\n } catch {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, \"IModelRpcProps doesn't point to a valid iModel\");\r\n }\r\n return imodel;\r\n }\r\n\r\n private async makeRequest<TRpcOptions extends { rulesetOrId?: Ruleset | string, clientId?: string, diagnostics?: RpcDiagnosticsOptions, rulesetVariables?: RulesetVariableJSON[] }, TResult>(token: IModelRpcProps, requestId: string, requestOptions: TRpcOptions, request: ContentGetter<Promise<TResult>>): PresentationRpcResponse<TResult> {\r\n const requestKey = JSON.stringify({ iModelKey: token.key, requestId, requestOptions });\r\n\r\n Logger.logInfo(PresentationBackendLoggerCategory.Rpc, `Received '${requestId}' request. Params: ${requestKey}`);\r\n\r\n let resultPromise = this._pendingRequests.getValue(requestKey);\r\n if (resultPromise) {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request already pending`);\r\n } else {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request not found, creating a new one`);\r\n let imodel: IModelDb;\r\n try {\r\n imodel = this.getIModel(token);\r\n } catch (e) {\r\n assert(e instanceof Error);\r\n return this.errorResponse(PresentationStatus.InvalidArgument, e.message);\r\n }\r\n\r\n const { clientId: _, diagnostics: diagnosticsOptions, rulesetVariables, ...options } = requestOptions;\r\n const managerRequestOptions: any = {\r\n ...options,\r\n imodel,\r\n };\r\n\r\n // set up ruleset variables\r\n if (rulesetVariables)\r\n managerRequestOptions.rulesetVariables = rulesetVariables.map(RulesetVariable.fromJSON);\r\n\r\n // set up diagnostics listener\r\n let diagnostics: ClientDiagnostics | undefined;\r\n const getDiagnostics = (): ClientDiagnostics => {\r\n if (!diagnostics)\r\n diagnostics = {};\r\n return diagnostics;\r\n };\r\n if (diagnosticsOptions) {\r\n if (diagnosticsOptions.backendVersion) {\r\n getDiagnostics().backendVersion = packageJsonVersion;\r\n }\r\n managerRequestOptions.diagnostics = {\r\n ...diagnosticsOptions,\r\n handler: (d: Diagnostics) => {\r\n if (d.logs) {\r\n const target = getDiagnostics();\r\n if (target.logs)\r\n target.logs.push(...d.logs);\r\n else\r\n target.logs = [...d.logs];\r\n }\r\n },\r\n };\r\n }\r\n\r\n // initiate request\r\n resultPromise = request(managerRequestOptions)\r\n .then((result) => this.successResponse(result, diagnostics))\r\n .catch((e: PresentationError) => this.errorResponse(e.errorNumber, e.message, diagnostics));\r\n\r\n // store the request promise\r\n this._pendingRequests.addValue(requestKey, resultPromise);\r\n }\r\n\r\n if (this._requestTimeout === 0) {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout not configured, returning promise without a timeout.`);\r\n resultPromise.finally(() => {\r\n this._pendingRequests.deleteValue(requestKey);\r\n });\r\n return resultPromise;\r\n }\r\n\r\n let timeout: NodeJS.Timeout;\r\n const timeoutPromise = new Promise<any>((_resolve, reject) => {\r\n timeout = setTimeout(() => {\r\n reject(\"Timed out\");\r\n }, this._requestTimeout);\r\n });\r\n\r\n /* eslint-disable @typescript-eslint/indent */\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Returning a promise with a timeout of ${this._requestTimeout}.`);\r\n return Promise\r\n .race([resultPromise, timeoutPromise])\r\n .catch<PresentationRpcResponseData>(() => {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout, returning \"BackendTimeout\" status.`);\r\n return this.errorResponse(PresentationStatus.BackendTimeout);\r\n })\r\n .then((response: PresentationRpcResponseData<any>) => {\r\n if (response.statusCode !== PresentationStatus.BackendTimeout) {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request completed, returning result.`);\r\n this._pendingRequests.deleteValue(requestKey);\r\n }\r\n clearTimeout(timeout);\r\n return response;\r\n });\r\n /* eslint-enable @typescript-eslint/indent */\r\n }\r\n\r\n public override async getNodesCount(token: IModelRpcProps, requestOptions: HierarchyRpcRequestOptions): PresentationRpcResponse<number> {\r\n return this.makeRequest(token, \"getNodesCount\", requestOptions, async (options) => {\r\n options = {\r\n ...options,\r\n parentKey: nodeKeyFromJson(options.parentKey),\r\n };\r\n return this.getManager(requestOptions.clientId).getNodesCount(options);\r\n });\r\n }\r\n\r\n public override async getPagedNodes(token: IModelRpcProps, requestOptions: Paged<HierarchyRpcRequestOptions>): PresentationRpcResponse<PagedResponse<NodeJSON>> {\r\n return this.makeRequest(token, \"getPagedNodes\", requestOptions, async (options) => {\r\n options = enforceValidPageSize({\r\n ...options,\r\n parentKey: nodeKeyFromJson(options.parentKey),\r\n });\r\n const [nodes, count] = await Promise.all([\r\n this.getManager(requestOptions.clientId).getNodes(options),\r\n this.getManager(requestOptions.clientId).getNodesCount(options),\r\n ]);\r\n return { total: count, items: nodes.map(Node.toJSON) };\r\n });\r\n }\r\n\r\n public override async getNodePaths(token: IModelRpcProps, requestOptions: FilterByInstancePathsHierarchyRpcRequestOptions): PresentationRpcResponse<NodePathElementJSON[]> {\r\n return this.makeRequest(token, \"getNodePaths\", requestOptions, async (options) => {\r\n const result = await this.getManager(requestOptions.clientId).getNodePaths(options);\r\n return result.map(NodePathElement.toJSON);\r\n });\r\n }\r\n\r\n public override async getFilteredNodePaths(token: IModelRpcProps, requestOptions: FilterByTextHierarchyRpcRequestOptions): PresentationRpcResponse<NodePathElementJSON[]> {\r\n return this.makeRequest(token, \"getFilteredNodePaths\", requestOptions, async (options) => {\r\n const result = await this.getManager(requestOptions.clientId).getFilteredNodePaths(options);\r\n return result.map(NodePathElement.toJSON);\r\n });\r\n }\r\n\r\n public override async getContentSources(token: IModelRpcProps, requestOptions: ContentSourcesRpcRequestOptions): PresentationRpcResponse<ContentSourcesRpcResult> {\r\n return this.makeRequest(token, \"getContentSources\", requestOptions, async (options) => {\r\n const result = await this.getManager(requestOptions.clientId).getContentSources(options);\r\n const classesMap = {};\r\n const selectClasses = result.map((sci) => SelectClassInfo.toCompressedJSON(sci, classesMap));\r\n return { sources: selectClasses, classesMap };\r\n });\r\n }\r\n\r\n public override async getContentDescriptor(token: IModelRpcProps, requestOptions: ContentDescriptorRpcRequestOptions): PresentationRpcResponse<DescriptorJSON | undefined> {\r\n return this.makeRequest(token, \"getContentDescriptor\", requestOptions, async (options) => {\r\n options = {\r\n ...options,\r\n keys: KeySet.fromJSON(options.keys),\r\n };\r\n const descriptor = await this.getManager(requestOptions.clientId).getContentDescriptor(options);\r\n if (descriptor)\r\n return descriptor.toJSON();\r\n return undefined;\r\n });\r\n }\r\n\r\n public override async getContentSetSize(token: IModelRpcProps, requestOptions: ContentRpcRequestOptions): PresentationRpcResponse<number> {\r\n return this.makeRequest(token, \"getContentSetSize\", requestOptions, async (options) => {\r\n options = {\r\n ...options,\r\n keys: KeySet.fromJSON(options.keys),\r\n };\r\n return this.getManager(requestOptions.clientId).getContentSetSize(options);\r\n });\r\n }\r\n\r\n public override async getPagedContent(token: IModelRpcProps, requestOptions: Paged<ContentRpcRequestOptions>): PresentationRpcResponse<{ descriptor: DescriptorJSON, contentSet: PagedResponse<ItemJSON> } | undefined> {\r\n return this.makeRequest(token, \"getPagedContent\", requestOptions, async (options) => {\r\n options = enforceValidPageSize({\r\n ...options,\r\n keys: KeySet.fromJSON(options.keys),\r\n });\r\n\r\n const [size, content] = await Promise.all([\r\n this.getManager(requestOptions.clientId).getContentSetSize(options),\r\n this.getManager(requestOptions.clientId).getContent(options),\r\n ]);\r\n\r\n if (!content)\r\n return undefined;\r\n\r\n return {\r\n descriptor: content.descriptor.toJSON(),\r\n contentSet: {\r\n total: size,\r\n items: content.contentSet.map((i) => i.toJSON()),\r\n },\r\n };\r\n });\r\n }\r\n\r\n public override async getPagedContentSet(token: IModelRpcProps, requestOptions: Paged<ContentRpcRequestOptions>): PresentationRpcResponse<PagedResponse<ItemJSON>> {\r\n const content = await this.getPagedContent(token, requestOptions);\r\n return this.successResponse(content.result ? content.result.contentSet : { total: 0, items: [] });\r\n }\r\n\r\n public override async getElementProperties(token: IModelRpcProps, requestOptions: SingleElementPropertiesRpcRequestOptions): PresentationRpcResponse<ElementProperties | undefined> {\r\n return this.makeRequest(token, \"getElementProperties\", { ...requestOptions }, async (options) => {\r\n return this.getManager(requestOptions.clientId).getElementProperties(options);\r\n });\r\n }\r\n\r\n public override async getPagedDistinctValues(token: IModelRpcProps, requestOptions: DistinctValuesRpcRequestOptions): PresentationRpcResponse<PagedResponse<DisplayValueGroupJSON>> {\r\n return this.makeRequest(token, \"getPagedDistinctValues\", requestOptions, async (options) => {\r\n options = enforceValidPageSize({\r\n ...options,\r\n keys: KeySet.fromJSON(options.keys),\r\n });\r\n const response = await this.getManager(requestOptions.clientId).getPagedDistinctValues(options);\r\n return {\r\n ...response,\r\n items: response.items.map(DisplayValueGroup.toJSON),\r\n };\r\n });\r\n }\r\n\r\n public override async getContentInstanceKeys(token: IModelRpcProps, requestOptions: ContentInstanceKeysRpcRequestOptions): PresentationRpcResponse<{ total: number, items: KeySetJSON }> {\r\n return this.makeRequest(token, \"getContentInstanceKeys\", requestOptions, async (options) => {\r\n const { displayType, ...optionsNoDisplayType } = options;\r\n options = enforceValidPageSize({\r\n ...optionsNoDisplayType,\r\n keys: KeySet.fromJSON(optionsNoDisplayType.keys),\r\n descriptor: {\r\n displayType,\r\n contentFlags: ContentFlags.KeysOnly,\r\n },\r\n }, MAX_ALLOWED_KEYS_PAGE_SIZE);\r\n\r\n const [size, content] = await Promise.all([\r\n this.getManager(requestOptions.clientId).getContentSetSize(options),\r\n this.getManager(requestOptions.clientId).getContent(options),\r\n ]);\r\n\r\n if (size === 0 || !content)\r\n return { total: 0, items: new KeySet().toJSON() };\r\n\r\n return {\r\n total: size,\r\n items: content.contentSet.reduce((keys, item) => keys.add(item.primaryKeys), new KeySet()).toJSON(),\r\n };\r\n });\r\n }\r\n\r\n public override async getDisplayLabelDefinition(token: IModelRpcProps, requestOptions: DisplayLabelRpcRequestOptions): PresentationRpcResponse<LabelDefinitionJSON> {\r\n return this.makeRequest(token, \"getDisplayLabelDefinition\", requestOptions, async (options) => {\r\n const label = await this.getManager(requestOptions.clientId).getDisplayLabelDefinition(options);\r\n return LabelDefinition.toJSON(label);\r\n });\r\n }\r\n\r\n public override async getPagedDisplayLabelDefinitions(token: IModelRpcProps, requestOptions: DisplayLabelsRpcRequestOptions): PresentationRpcResponse<PagedResponse<LabelDefinitionJSON>> {\r\n const pageOpts = enforceValidPageSize({ paging: { start: 0, size: requestOptions.keys.length } });\r\n if (pageOpts.paging.size < requestOptions.keys.length)\r\n requestOptions.keys.splice(pageOpts.paging.size);\r\n return this.makeRequest(token, \"getPagedDisplayLabelDefinitions\", requestOptions, async (options) => {\r\n const labels = await this.getManager(requestOptions.clientId).getDisplayLabelDefinitions({ ...options, keys: options.keys.map(InstanceKey.fromJSON) });\r\n return {\r\n total: options.keys.length,\r\n items: labels.map(LabelDefinition.toJSON),\r\n };\r\n });\r\n }\r\n\r\n public override async getSelectionScopes(token: IModelRpcProps, requestOptions: SelectionScopeRpcRequestOptions): PresentationRpcResponse<SelectionScope[]> {\r\n return this.makeRequest(token, \"getSelectionScopes\", requestOptions, async (options) =>\r\n this.getManager(requestOptions.clientId).getSelectionScopes(options),\r\n );\r\n }\r\n\r\n public override async computeSelection(token: IModelRpcProps, requestOptions: ComputeSelectionRpcRequestOptions | SelectionScopeRpcRequestOptions, ids?: Id64String[], scopeId?: string): PresentationRpcResponse<KeySetJSON> {\r\n return this.makeRequest(token, \"computeSelection\", requestOptions, async (options) => {\r\n if (!isComputeSelectionRequestOptions(options)) {\r\n options = {\r\n ...options,\r\n elementIds: ids!,\r\n scope: { id: scopeId! },\r\n };\r\n }\r\n const keys = await this.getManager(requestOptions.clientId).computeSelection(options);\r\n return keys.toJSON();\r\n });\r\n }\r\n}\r\n\r\nconst enforceValidPageSize = <TOptions extends Paged<object>>(requestOptions: TOptions, maxPageSize = MAX_ALLOWED_PAGE_SIZE): TOptions & { paging: PageOptions } => {\r\n const validPageSize = getValidPageSize(requestOptions.paging?.size, maxPageSize);\r\n if (!requestOptions.paging || requestOptions.paging.size !== validPageSize)\r\n return { ...requestOptions, paging: { ...requestOptions.paging, size: validPageSize } };\r\n return requestOptions as (TOptions & { paging: PageOptions });\r\n};\r\n\r\nconst getValidPageSize = (size: number | undefined, maxPageSize: number) => {\r\n const requestedSize = size ?? 0;\r\n return (requestedSize === 0 || requestedSize > maxPageSize) ? maxPageSize : requestedSize;\r\n};\r\n\r\nconst nodeKeyFromJson = (json: NodeKeyJSON | undefined): NodeKey | undefined => {\r\n if (!json)\r\n return undefined;\r\n return NodeKey.fromJSON(json);\r\n};\r\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Core
|
|
3
3
|
*/
|
|
4
|
-
import { Id64String } from "@itwin/core-bentley";
|
|
5
4
|
import { IModelDb } from "@itwin/core-backend";
|
|
6
|
-
import {
|
|
5
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
6
|
+
import { ComputeSelectionRequestOptions, KeySet, SelectionScope, SelectionScopeRequestOptions } from "@itwin/presentation-common";
|
|
7
7
|
/**
|
|
8
8
|
* Contains helper methods for computing selection scopes. Will get removed
|
|
9
9
|
* once rules-driven scopes are implemented.
|
|
@@ -13,12 +13,8 @@ import { KeySet, SelectionScope, SelectionScopeRequestOptions } from "@itwin/pre
|
|
|
13
13
|
export declare class SelectionScopesHelper {
|
|
14
14
|
private constructor();
|
|
15
15
|
static getSelectionScopes(): SelectionScope[];
|
|
16
|
+
private static getElementKey;
|
|
16
17
|
private static computeElementSelection;
|
|
17
|
-
private static getParentInstanceKey;
|
|
18
|
-
private static getAssemblyKey;
|
|
19
|
-
private static computeAssemblySelection;
|
|
20
|
-
private static getTopAssemblyKey;
|
|
21
|
-
private static computeTopAssemblySelection;
|
|
22
18
|
private static computeCategorySelection;
|
|
23
19
|
private static computeModelSelection;
|
|
24
20
|
private static getRelatedFunctionalElementKey;
|
|
@@ -34,5 +30,7 @@ export declare class SelectionScopesHelper {
|
|
|
34
30
|
* @param scopeId ID of selection scope to use for computing selection
|
|
35
31
|
*/
|
|
36
32
|
static computeSelection(requestOptions: SelectionScopeRequestOptions<IModelDb>, ids: Id64String[], scopeId: string): Promise<KeySet>;
|
|
33
|
+
/** @alpha */
|
|
34
|
+
static computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb>): Promise<KeySet>;
|
|
37
35
|
}
|
|
38
36
|
//# sourceMappingURL=SelectionScopesHelper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionScopesHelper.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/SelectionScopesHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"SelectionScopesHelper.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/SelectionScopesHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAwC,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAkB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EACL,8BAA8B,EAA6E,MAAM,EAC7F,cAAc,EAAE,4BAA4B,EACjE,MAAM,4BAA4B,CAAC;AAGpC;;;;;GAKG;AACH,qBAAa,qBAAqB;IAGhC,OAAO;WAEO,kBAAkB,IAAI,cAAc,EAAE;IAgBpD,OAAO,CAAC,MAAM,CAAC,aAAa;IAW5B,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAStC,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAavC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAWpC,OAAO,CAAC,MAAM,CAAC,8BAA8B;IAuB7C,OAAO,CAAC,MAAM,CAAC,oCAAoC;IAWnD,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAgBtC,OAAO,CAAC,MAAM,CAAC,iCAAiC;IAwBhD,OAAO,CAAC,MAAM,CAAC,kCAAkC;IAyBjD,OAAO,CAAC,MAAM,CAAC,qCAAqC;IAyBpD;;;;;OAKG;WACiB,gBAAgB,CAAC,cAAc,EAAE,4BAA4B,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACjJ,aAAa;WACO,gBAAgB,CAAC,cAAc,EAAE,8BAA8B,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CAyBhH"}
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.SelectionScopesHelper = void 0;
|
|
11
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
11
|
const core_backend_1 = require("@itwin/core-backend");
|
|
12
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
13
13
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
14
14
|
const Utils_1 = require("./Utils");
|
|
15
15
|
/**
|
|
@@ -36,71 +36,42 @@ class SelectionScopesHelper {
|
|
|
36
36
|
// createSelectionScope("model", "Model", "Select all elements in the picked element's model"),
|
|
37
37
|
];
|
|
38
38
|
}
|
|
39
|
-
static
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
static getParentInstanceKey(imodel, id) {
|
|
49
|
-
const elementProps = imodel.elements.tryGetElementProps(id);
|
|
50
|
-
if (!(elementProps === null || elementProps === void 0 ? void 0 : elementProps.parent))
|
|
51
|
-
return undefined;
|
|
52
|
-
return (0, Utils_1.getElementKey)(imodel, elementProps.parent.id);
|
|
53
|
-
}
|
|
54
|
-
static getAssemblyKey(imodel, id) {
|
|
55
|
-
const parentKey = this.getParentInstanceKey(imodel, id);
|
|
56
|
-
if (parentKey)
|
|
57
|
-
return parentKey;
|
|
58
|
-
return (0, Utils_1.getElementKey)(imodel, id);
|
|
59
|
-
}
|
|
60
|
-
static computeAssemblySelection(requestOptions, ids) {
|
|
61
|
-
const parentKeys = new presentation_common_1.KeySet();
|
|
62
|
-
ids.forEach(skipTransients((id) => {
|
|
63
|
-
const key = this.getAssemblyKey(requestOptions.imodel, id);
|
|
64
|
-
if (key)
|
|
65
|
-
parentKeys.add(key);
|
|
66
|
-
}));
|
|
67
|
-
return parentKeys;
|
|
68
|
-
}
|
|
69
|
-
static getTopAssemblyKey(imodel, id) {
|
|
70
|
-
let currKey;
|
|
71
|
-
let parentKey = this.getParentInstanceKey(imodel, id);
|
|
72
|
-
while (parentKey) {
|
|
73
|
-
currKey = parentKey;
|
|
74
|
-
parentKey = this.getParentInstanceKey(imodel, currKey.id);
|
|
39
|
+
static getElementKey(iModel, elementId, ancestorLevel) {
|
|
40
|
+
var _a, _b, _c, _d;
|
|
41
|
+
let currId = elementId;
|
|
42
|
+
let parentId = (_b = (_a = iModel.elements.tryGetElementProps(currId)) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id;
|
|
43
|
+
while (parentId && ancestorLevel !== 0) {
|
|
44
|
+
currId = parentId;
|
|
45
|
+
parentId = (_d = (_c = iModel.elements.tryGetElementProps(currId)) === null || _c === void 0 ? void 0 : _c.parent) === null || _d === void 0 ? void 0 : _d.id;
|
|
46
|
+
--ancestorLevel;
|
|
75
47
|
}
|
|
76
|
-
return
|
|
48
|
+
return (0, Utils_1.getElementKey)(iModel, currId);
|
|
77
49
|
}
|
|
78
|
-
static
|
|
50
|
+
static computeElementSelection(iModel, elementIds, ancestorLevel) {
|
|
79
51
|
const parentKeys = new presentation_common_1.KeySet();
|
|
80
|
-
|
|
81
|
-
const key = this.
|
|
82
|
-
|
|
83
|
-
parentKeys.add(key);
|
|
52
|
+
elementIds.forEach(skipTransients((id) => {
|
|
53
|
+
const key = this.getElementKey(iModel, id, ancestorLevel);
|
|
54
|
+
key && parentKeys.add(key);
|
|
84
55
|
}));
|
|
85
56
|
return parentKeys;
|
|
86
57
|
}
|
|
87
|
-
static computeCategorySelection(
|
|
58
|
+
static computeCategorySelection(iModel, ids) {
|
|
88
59
|
const categoryKeys = new presentation_common_1.KeySet();
|
|
89
60
|
ids.forEach(skipTransients((id) => {
|
|
90
|
-
const el =
|
|
61
|
+
const el = iModel.elements.tryGetElement(id);
|
|
91
62
|
if (el instanceof core_backend_1.GeometricElement) {
|
|
92
|
-
const category =
|
|
63
|
+
const category = iModel.elements.tryGetElementProps(el.category);
|
|
93
64
|
if (category)
|
|
94
65
|
categoryKeys.add({ className: category.classFullName, id: category.id });
|
|
95
66
|
}
|
|
96
67
|
}));
|
|
97
68
|
return categoryKeys;
|
|
98
69
|
}
|
|
99
|
-
static computeModelSelection(
|
|
70
|
+
static computeModelSelection(iModel, ids) {
|
|
100
71
|
const modelKeys = new presentation_common_1.KeySet();
|
|
101
72
|
ids.forEach(skipTransients((id) => {
|
|
102
|
-
const el =
|
|
103
|
-
const model = el ?
|
|
73
|
+
const el = iModel.elements.tryGetElementProps(id);
|
|
74
|
+
const model = el ? iModel.models.tryGetModelProps(el.model) : undefined;
|
|
104
75
|
if (model)
|
|
105
76
|
modelKeys.add({ className: model.classFullName, id: model.id });
|
|
106
77
|
}));
|
|
@@ -129,24 +100,24 @@ class SelectionScopesHelper {
|
|
|
129
100
|
});
|
|
130
101
|
}
|
|
131
102
|
static findFirstRelatedFunctionalElementKey(imodel, graphicalElementId) {
|
|
132
|
-
var _a;
|
|
103
|
+
var _a, _b;
|
|
133
104
|
let currId = graphicalElementId;
|
|
134
105
|
while (currId) {
|
|
135
106
|
const relatedFunctionalKey = this.getRelatedFunctionalElementKey(imodel, currId);
|
|
136
107
|
if (relatedFunctionalKey)
|
|
137
108
|
return relatedFunctionalKey;
|
|
138
|
-
currId = (_a =
|
|
109
|
+
currId = (_b = (_a = imodel.elements.tryGetElementProps(currId)) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id;
|
|
139
110
|
}
|
|
140
111
|
return undefined;
|
|
141
112
|
}
|
|
142
113
|
static elementClassDerivesFrom(imodel, elementId, baseClassFullName) {
|
|
143
114
|
const query = `
|
|
144
115
|
SELECT 1
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
116
|
+
FROM bis.Element e
|
|
117
|
+
INNER JOIN meta.ClassHasAllBaseClasses baseClassRels ON baseClassRels.SourceECInstanceId = e.ECClassId
|
|
118
|
+
INNER JOIN meta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId
|
|
119
|
+
INNER JOIN meta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id
|
|
120
|
+
WHERE e.ECInstanceId = ? AND (baseSchema.Name || ':' || baseClass.Name) = ?
|
|
150
121
|
`;
|
|
151
122
|
return imodel.withPreparedStatement(query, (stmt) => {
|
|
152
123
|
stmt.bindId(1, elementId);
|
|
@@ -154,13 +125,13 @@ class SelectionScopesHelper {
|
|
|
154
125
|
return (core_bentley_1.DbResult.BE_SQLITE_ROW === stmt.step());
|
|
155
126
|
});
|
|
156
127
|
}
|
|
157
|
-
static computeFunctionalElementSelection(
|
|
128
|
+
static computeFunctionalElementSelection(iModel, ids) {
|
|
158
129
|
const keys = new presentation_common_1.KeySet();
|
|
159
130
|
ids.forEach(skipTransients((id) => {
|
|
160
|
-
const is3d = this.elementClassDerivesFrom(
|
|
131
|
+
const is3d = this.elementClassDerivesFrom(iModel, id, core_backend_1.GeometricElement3d.classFullName);
|
|
161
132
|
if (!is3d) {
|
|
162
133
|
// if the input is not a 3d element, we try to find the first related functional element
|
|
163
|
-
const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(
|
|
134
|
+
const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);
|
|
164
135
|
if (firstFunctionalKey) {
|
|
165
136
|
keys.add(firstFunctionalKey);
|
|
166
137
|
return;
|
|
@@ -169,31 +140,31 @@ class SelectionScopesHelper {
|
|
|
169
140
|
let keyToAdd;
|
|
170
141
|
if (is3d) {
|
|
171
142
|
// if we're computing scope for a 3d element, try to switch to its related functional element
|
|
172
|
-
keyToAdd = this.getRelatedFunctionalElementKey(
|
|
143
|
+
keyToAdd = this.getRelatedFunctionalElementKey(iModel, id);
|
|
173
144
|
}
|
|
174
145
|
if (!keyToAdd)
|
|
175
|
-
keyToAdd = (0, Utils_1.getElementKey)(
|
|
146
|
+
keyToAdd = (0, Utils_1.getElementKey)(iModel, id);
|
|
176
147
|
keyToAdd && keys.add(keyToAdd);
|
|
177
148
|
}));
|
|
178
149
|
return keys;
|
|
179
150
|
}
|
|
180
|
-
static computeFunctionalAssemblySelection(
|
|
151
|
+
static computeFunctionalAssemblySelection(iModel, ids) {
|
|
181
152
|
const keys = new presentation_common_1.KeySet();
|
|
182
153
|
ids.forEach(skipTransients((id) => {
|
|
183
154
|
let idToGetAssemblyFor = id;
|
|
184
|
-
const is3d = this.elementClassDerivesFrom(
|
|
155
|
+
const is3d = this.elementClassDerivesFrom(iModel, id, core_backend_1.GeometricElement3d.classFullName);
|
|
185
156
|
if (!is3d) {
|
|
186
157
|
// if the input is not a 3d element, we try to find the first related functional element
|
|
187
|
-
const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(
|
|
158
|
+
const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);
|
|
188
159
|
if (firstFunctionalKey)
|
|
189
160
|
idToGetAssemblyFor = firstFunctionalKey.id;
|
|
190
161
|
}
|
|
191
162
|
// find the assembly of either the given element or the functional element
|
|
192
|
-
const assemblyKey = this.
|
|
163
|
+
const assemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, 1);
|
|
193
164
|
let keyToAdd = assemblyKey;
|
|
194
165
|
if (is3d && keyToAdd) {
|
|
195
166
|
// if we're computing scope for a 3d element, try to switch to its related functional element
|
|
196
|
-
const relatedFunctionalKey = this.getRelatedFunctionalElementKey(
|
|
167
|
+
const relatedFunctionalKey = this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);
|
|
197
168
|
if (relatedFunctionalKey)
|
|
198
169
|
keyToAdd = relatedFunctionalKey;
|
|
199
170
|
}
|
|
@@ -201,23 +172,23 @@ class SelectionScopesHelper {
|
|
|
201
172
|
}));
|
|
202
173
|
return keys;
|
|
203
174
|
}
|
|
204
|
-
static computeFunctionalTopAssemblySelection(
|
|
175
|
+
static computeFunctionalTopAssemblySelection(iModel, ids) {
|
|
205
176
|
const keys = new presentation_common_1.KeySet();
|
|
206
177
|
ids.forEach(skipTransients((id) => {
|
|
207
178
|
let idToGetAssemblyFor = id;
|
|
208
|
-
const is3d = this.elementClassDerivesFrom(
|
|
179
|
+
const is3d = this.elementClassDerivesFrom(iModel, id, core_backend_1.GeometricElement3d.classFullName);
|
|
209
180
|
if (!is3d) {
|
|
210
181
|
// if the input is not a 3d element, we try to find the first related functional element
|
|
211
|
-
const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(
|
|
182
|
+
const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);
|
|
212
183
|
if (firstFunctionalKey)
|
|
213
184
|
idToGetAssemblyFor = firstFunctionalKey.id;
|
|
214
185
|
}
|
|
215
186
|
// find the top assembly of either the given element or the functional element
|
|
216
|
-
const topAssemblyKey = this.
|
|
187
|
+
const topAssemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, Number.MAX_SAFE_INTEGER);
|
|
217
188
|
let keyToAdd = topAssemblyKey;
|
|
218
189
|
if (is3d && keyToAdd) {
|
|
219
190
|
// if we're computing scope for a 3d element, try to switch to its related functional element
|
|
220
|
-
const relatedFunctionalKey = this.getRelatedFunctionalElementKey(
|
|
191
|
+
const relatedFunctionalKey = this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);
|
|
221
192
|
if (relatedFunctionalKey)
|
|
222
193
|
keyToAdd = relatedFunctionalKey;
|
|
223
194
|
}
|
|
@@ -225,24 +196,26 @@ class SelectionScopesHelper {
|
|
|
225
196
|
}));
|
|
226
197
|
return keys;
|
|
227
198
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
case "
|
|
239
|
-
case "
|
|
240
|
-
case "
|
|
199
|
+
static async computeSelection(requestOptions, elementIds, scopeId) {
|
|
200
|
+
var _a;
|
|
201
|
+
if (!(0, presentation_common_1.isComputeSelectionRequestOptions)(requestOptions)) {
|
|
202
|
+
return this.computeSelection({
|
|
203
|
+
...requestOptions,
|
|
204
|
+
elementIds: elementIds,
|
|
205
|
+
scope: { id: scopeId },
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
switch (requestOptions.scope.id) {
|
|
209
|
+
case "element": return this.computeElementSelection(requestOptions.imodel, requestOptions.elementIds, (_a = requestOptions.scope.ancestorLevel) !== null && _a !== void 0 ? _a : 0);
|
|
210
|
+
case "assembly": return this.computeElementSelection(requestOptions.imodel, requestOptions.elementIds, 1);
|
|
211
|
+
case "top-assembly": return this.computeElementSelection(requestOptions.imodel, requestOptions.elementIds, Number.MAX_SAFE_INTEGER);
|
|
212
|
+
case "category": return this.computeCategorySelection(requestOptions.imodel, requestOptions.elementIds);
|
|
213
|
+
case "model": return this.computeModelSelection(requestOptions.imodel, requestOptions.elementIds);
|
|
241
214
|
case "functional":
|
|
242
215
|
case "functional-element":
|
|
243
|
-
return this.computeFunctionalElementSelection(requestOptions,
|
|
244
|
-
case "functional-assembly": return this.computeFunctionalAssemblySelection(requestOptions,
|
|
245
|
-
case "functional-top-assembly": return this.computeFunctionalTopAssemblySelection(requestOptions,
|
|
216
|
+
return this.computeFunctionalElementSelection(requestOptions.imodel, requestOptions.elementIds);
|
|
217
|
+
case "functional-assembly": return this.computeFunctionalAssemblySelection(requestOptions.imodel, requestOptions.elementIds);
|
|
218
|
+
case "functional-top-assembly": return this.computeFunctionalTopAssemblySelection(requestOptions.imodel, requestOptions.elementIds);
|
|
246
219
|
}
|
|
247
220
|
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "scopeId");
|
|
248
221
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionScopesHelper.js","sourceRoot":"","sources":["../../../src/presentation-backend/SelectionScopesHelper.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAiE;AACjE,sDAAqF;AACrF,oEAEoC;AACpC,mCAAwC;AAExC;;;;;GAKG;AACH,MAAa,qBAAqB;IAEhC,uBAAuB;IACvB,gBAAwB,CAAC;IAElB,MAAM,CAAC,kBAAkB;QAC9B,MAAM,oBAAoB,GAAG,CAAC,OAAe,EAA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Ac,EAAE,GAAG,CAAC,CAAC;YAClF,KAAK,UAAU,CAAC,CAAC,OAAO,IAAI,CAAC,wBAAwB,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;YAC3E,KAAK,OAAO,CAAC,CAAC,OAAO,IAAI,CAAC,qBAAqB,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;YACrE,KAAK,YAAY,CAAC;YAClB,KAAK,oBAAoB;gBACvB,OAAO,IAAI,CAAC,iCAAiC,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;YACrE,KAAK,qBAAqB,CAAC,CAAC,OAAO,IAAI,CAAC,kCAAkC,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;YAChG,KAAK,yBAAyB,CAAC,CAAC,OAAO,IAAI,CAAC,qCAAqC,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;SACxG;QACD,MAAM,IAAI,uCAAiB,CAAC,wCAAkB,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAC7E,CAAC;CAEF;AArPD,sDAqPC;AAED,MAAM,cAAc,GAAG,CAAC,QAAkC,EAAE,EAAE;IAC5D,OAAO,CAAC,EAAc,EAAE,EAAE;QACxB,IAAI,CAAC,mBAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YACvB,QAAQ,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { GeometricElement, GeometricElement3d, IModelDb } from \"@itwin/core-backend\";\r\nimport {\r\n InstanceKey, KeySet, PresentationError, PresentationStatus, SelectionScope, SelectionScopeRequestOptions,\r\n} from \"@itwin/presentation-common\";\r\nimport { getElementKey } from \"./Utils\";\r\n\r\n/**\r\n * Contains helper methods for computing selection scopes. Will get removed\r\n * once rules-driven scopes are implemented.\r\n *\r\n * @internal\r\n */\r\nexport class SelectionScopesHelper {\r\n\r\n // istanbul ignore next\r\n private constructor() { }\r\n\r\n public static getSelectionScopes(): SelectionScope[] {\r\n const createSelectionScope = (scopeId: string, label: string, description: string): SelectionScope => ({\r\n id: scopeId,\r\n label,\r\n description,\r\n });\r\n return [\r\n createSelectionScope(\"element\", \"Element\", \"Select the picked element\"),\r\n createSelectionScope(\"assembly\", \"Assembly\", \"Select parent of the picked element\"),\r\n createSelectionScope(\"top-assembly\", \"Top Assembly\", \"Select the topmost parent of the picked element\"),\r\n // WIP: temporarily comment-out \"category\" and \"model\" scopes since we can't hilite contents of them fast enough\r\n // createSelectionScope(\"category\", \"Category\", \"Select all elements in the picked element's category\"),\r\n // createSelectionScope(\"model\", \"Model\", \"Select all elements in the picked element's model\"),\r\n ];\r\n }\r\n\r\n private static computeElementSelection(requestOptions: SelectionScopeRequestOptions<IModelDb>, ids: Id64String[]) {\r\n const keys = new KeySet();\r\n ids.forEach(skipTransients((id) => {\r\n const key = getElementKey(requestOptions.imodel, id);\r\n if (key)\r\n keys.add(key);\r\n }));\r\n return keys;\r\n }\r\n\r\n private static getParentInstanceKey(imodel: IModelDb, id: Id64String): InstanceKey | undefined {\r\n const elementProps = imodel.elements.tryGetElementProps(id);\r\n if (!elementProps?.parent)\r\n return undefined;\r\n return getElementKey(imodel, elementProps.parent.id);\r\n }\r\n\r\n private static getAssemblyKey(imodel: IModelDb, id: Id64String) {\r\n const parentKey = this.getParentInstanceKey(imodel, id);\r\n if (parentKey)\r\n return parentKey;\r\n return getElementKey(imodel, id);\r\n }\r\n\r\n private static computeAssemblySelection(requestOptions: SelectionScopeRequestOptions<IModelDb>, ids: Id64String[]) {\r\n const parentKeys = new KeySet();\r\n ids.forEach(skipTransients((id) => {\r\n const key = this.getAssemblyKey(requestOptions.imodel, id);\r\n if (key)\r\n parentKeys.add(key);\r\n }));\r\n return parentKeys;\r\n }\r\n\r\n private static getTopAssemblyKey(imodel: IModelDb, id: Id64String) {\r\n let currKey: InstanceKey | undefined;\r\n let parentKey = this.getParentInstanceKey(imodel, id);\r\n while (parentKey) {\r\n currKey = parentKey;\r\n parentKey = this.getParentInstanceKey(imodel, currKey.id);\r\n }\r\n return currKey ?? getElementKey(imodel, id);\r\n }\r\n\r\n private static computeTopAssemblySelection(requestOptions: SelectionScopeRequestOptions<IModelDb>, ids: Id64String[]) {\r\n const parentKeys = new KeySet();\r\n ids.forEach(skipTransients((id) => {\r\n const key = this.getTopAssemblyKey(requestOptions.imodel, id);\r\n if (key)\r\n parentKeys.add(key);\r\n }));\r\n return parentKeys;\r\n }\r\n\r\n private static computeCategorySelection(requestOptions: SelectionScopeRequestOptions<IModelDb>, ids: Id64String[]) {\r\n const categoryKeys = new KeySet();\r\n ids.forEach(skipTransients((id) => {\r\n const el = requestOptions.imodel.elements.tryGetElement(id);\r\n if (el instanceof GeometricElement) {\r\n const category = requestOptions.imodel.elements.tryGetElementProps(el.category);\r\n if (category)\r\n categoryKeys.add({ className: category.classFullName, id: category.id! });\r\n }\r\n }));\r\n return categoryKeys;\r\n }\r\n\r\n private static computeModelSelection(requestOptions: SelectionScopeRequestOptions<IModelDb>, ids: Id64String[]) {\r\n const modelKeys = new KeySet();\r\n ids.forEach(skipTransients((id) => {\r\n const el = requestOptions.imodel.elements.tryGetElementProps(id);\r\n const model = el ? requestOptions.imodel.models.tryGetModelProps(el.model) : undefined;\r\n if (model)\r\n modelKeys.add({ className: model.classFullName, id: model.id! });\r\n }));\r\n return modelKeys;\r\n }\r\n\r\n private static getRelatedFunctionalElementKey(imodel: IModelDb, graphicalElementId: Id64String): InstanceKey | undefined {\r\n const query = `\r\n SELECT funcSchemaDef.Name || '.' || funcClassDef.Name funcElClassName, fe.ECInstanceId funcElId\r\n FROM bis.Element e\r\n LEFT JOIN func.PhysicalElementFulfillsFunction rel1 ON rel1.SourceECInstanceId = e.ECInstanceId\r\n LEFT JOIN func.DrawingGraphicRepresentsFunctionalElement rel2 ON rel2.SourceECInstanceId = e.ECInstanceId\r\n LEFT JOIN func.FunctionalElement fe ON fe.ECInstanceId IN (rel1.TargetECInstanceId, rel2.TargetECInstanceId)\r\n INNER JOIN meta.ECClassDef funcClassDef ON funcClassDef.ECInstanceId = fe.ECClassId\r\n INNER JOIN meta.ECSchemaDef funcSchemaDef ON funcSchemaDef.ECInstanceId = funcClassDef.Schema.Id\r\n WHERE e.ECInstanceId = ?\r\n `;\r\n return imodel.withPreparedStatement(query, (stmt): InstanceKey | undefined => {\r\n stmt.bindId(1, graphicalElementId);\r\n // istanbul ignore else\r\n if (DbResult.BE_SQLITE_ROW === stmt.step()) {\r\n const row = stmt.getRow();\r\n if (row.funcElClassName && row.funcElId)\r\n return { className: row.funcElClassName.replace(\".\", \":\"), id: row.funcElId };\r\n }\r\n return undefined;\r\n });\r\n }\r\n\r\n private static findFirstRelatedFunctionalElementKey(imodel: IModelDb, graphicalElementId: Id64String): InstanceKey | undefined {\r\n let currId: Id64String | undefined = graphicalElementId;\r\n while (currId) {\r\n const relatedFunctionalKey = this.getRelatedFunctionalElementKey(imodel, currId);\r\n if (relatedFunctionalKey)\r\n return relatedFunctionalKey;\r\n currId = this.getParentInstanceKey(imodel, currId)?.id;\r\n }\r\n return undefined;\r\n }\r\n\r\n private static elementClassDerivesFrom(imodel: IModelDb, elementId: Id64String, baseClassFullName: string): boolean {\r\n const query = `\r\n SELECT 1\r\n FROM bis.Element e\r\n INNER JOIN meta.ClassHasAllBaseClasses baseClassRels ON baseClassRels.SourceECInstanceId = e.ECClassId\r\n INNER JOIN meta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId\r\n INNER JOIN meta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id\r\n WHERE e.ECInstanceId = ? AND (baseSchema.Name || ':' || baseClass.Name) = ?\r\n `;\r\n return imodel.withPreparedStatement(query, (stmt): boolean => {\r\n stmt.bindId(1, elementId);\r\n stmt.bindString(2, baseClassFullName);\r\n return (DbResult.BE_SQLITE_ROW === stmt.step());\r\n });\r\n }\r\n\r\n private static computeFunctionalElementSelection(requestOptions: SelectionScopeRequestOptions<IModelDb>, ids: Id64String[]) {\r\n const keys = new KeySet();\r\n ids.forEach(skipTransients((id): void => {\r\n const is3d = this.elementClassDerivesFrom(requestOptions.imodel, id, GeometricElement3d.classFullName);\r\n if (!is3d) {\r\n // if the input is not a 3d element, we try to find the first related functional element\r\n const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(requestOptions.imodel, id);\r\n if (firstFunctionalKey) {\r\n keys.add(firstFunctionalKey);\r\n return;\r\n }\r\n }\r\n let keyToAdd: InstanceKey | undefined;\r\n if (is3d) {\r\n // if we're computing scope for a 3d element, try to switch to its related functional element\r\n keyToAdd = this.getRelatedFunctionalElementKey(requestOptions.imodel, id);\r\n }\r\n if (!keyToAdd)\r\n keyToAdd = getElementKey(requestOptions.imodel, id);\r\n keyToAdd && keys.add(keyToAdd);\r\n }));\r\n return keys;\r\n }\r\n\r\n private static computeFunctionalAssemblySelection(requestOptions: SelectionScopeRequestOptions<IModelDb>, ids: Id64String[]) {\r\n const keys = new KeySet();\r\n ids.forEach(skipTransients((id): void => {\r\n let idToGetAssemblyFor = id;\r\n const is3d = this.elementClassDerivesFrom(requestOptions.imodel, id, GeometricElement3d.classFullName);\r\n if (!is3d) {\r\n // if the input is not a 3d element, we try to find the first related functional element\r\n const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(requestOptions.imodel, id);\r\n if (firstFunctionalKey)\r\n idToGetAssemblyFor = firstFunctionalKey.id;\r\n }\r\n // find the assembly of either the given element or the functional element\r\n const assemblyKey = this.getAssemblyKey(requestOptions.imodel, idToGetAssemblyFor);\r\n let keyToAdd = assemblyKey;\r\n if (is3d && keyToAdd) {\r\n // if we're computing scope for a 3d element, try to switch to its related functional element\r\n const relatedFunctionalKey = this.getRelatedFunctionalElementKey(requestOptions.imodel, keyToAdd.id);\r\n if (relatedFunctionalKey)\r\n keyToAdd = relatedFunctionalKey;\r\n }\r\n keyToAdd && keys.add(keyToAdd);\r\n }));\r\n return keys;\r\n }\r\n\r\n private static computeFunctionalTopAssemblySelection(requestOptions: SelectionScopeRequestOptions<IModelDb>, ids: Id64String[]) {\r\n const keys = new KeySet();\r\n ids.forEach(skipTransients((id): void => {\r\n let idToGetAssemblyFor = id;\r\n const is3d = this.elementClassDerivesFrom(requestOptions.imodel, id, GeometricElement3d.classFullName);\r\n if (!is3d) {\r\n // if the input is not a 3d element, we try to find the first related functional element\r\n const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(requestOptions.imodel, id);\r\n if (firstFunctionalKey)\r\n idToGetAssemblyFor = firstFunctionalKey.id;\r\n }\r\n // find the top assembly of either the given element or the functional element\r\n const topAssemblyKey = this.getTopAssemblyKey(requestOptions.imodel, idToGetAssemblyFor);\r\n let keyToAdd = topAssemblyKey;\r\n if (is3d && keyToAdd) {\r\n // if we're computing scope for a 3d element, try to switch to its related functional element\r\n const relatedFunctionalKey = this.getRelatedFunctionalElementKey(requestOptions.imodel, keyToAdd.id);\r\n if (relatedFunctionalKey)\r\n keyToAdd = relatedFunctionalKey;\r\n }\r\n keyToAdd && keys.add(keyToAdd);\r\n }));\r\n return keys;\r\n }\r\n\r\n /**\r\n * Computes selection set based on provided selection scope.\r\n * @param requestOptions Options for the request\r\n * @param keys Keys of elements to get the content for.\r\n * @param scopeId ID of selection scope to use for computing selection\r\n */\r\n public static async computeSelection(requestOptions: SelectionScopeRequestOptions<IModelDb>, ids: Id64String[], scopeId: string): Promise<KeySet> {\r\n switch (scopeId) {\r\n case \"element\": return this.computeElementSelection(requestOptions, ids);\r\n case \"assembly\": return this.computeAssemblySelection(requestOptions, ids);\r\n case \"top-assembly\": return this.computeTopAssemblySelection(requestOptions, ids);\r\n case \"category\": return this.computeCategorySelection(requestOptions, ids);\r\n case \"model\": return this.computeModelSelection(requestOptions, ids);\r\n case \"functional\":\r\n case \"functional-element\":\r\n return this.computeFunctionalElementSelection(requestOptions, ids);\r\n case \"functional-assembly\": return this.computeFunctionalAssemblySelection(requestOptions, ids);\r\n case \"functional-top-assembly\": return this.computeFunctionalTopAssemblySelection(requestOptions, ids);\r\n }\r\n throw new PresentationError(PresentationStatus.InvalidArgument, \"scopeId\");\r\n }\r\n\r\n}\r\n\r\nconst skipTransients = (callback: (id: Id64String) => void) => {\r\n return (id: Id64String) => {\r\n if (!Id64.isTransient(id))\r\n callback(id);\r\n };\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"SelectionScopesHelper.js","sourceRoot":"","sources":["../../../src/presentation-backend/SelectionScopesHelper.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAqF;AACrF,sDAAiE;AACjE,oEAGoC;AACpC,mCAAwC;AAExC;;;;;GAKG;AACH,MAAa,qBAAqB;IAEhC,uBAAuB;IACvB,gBAAwB,CAAC;IAElB,MAAM,CAAC,kBAAkB;QAC9B,MAAM,oBAAoB,GAAG,CAAC,OAAe,EAAE,KAAa,EAAE,WAAmB,EAAkB,EAAE,CAAC,CAAC;YACrG,EAAE,EAAE,OAAO;YACX,KAAK;YACL,WAAW;SACZ,CAAC,CAAC;QACH,OAAO;YACL,oBAAoB,CAAC,SAAS,EAAE,SAAS,EAAE,2BAA2B,CAAC;YACvE,oBAAoB,CAAC,UAAU,EAAE,UAAU,EAAE,qCAAqC,CAAC;YACnF,oBAAoB,CAAC,cAAc,EAAE,cAAc,EAAE,iDAAiD,CAAC;YACvG,gHAAgH;YAChH,wGAAwG;YACxG,+FAA+F;SAChG,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,aAAa,CAAC,MAAgB,EAAE,SAAqB,EAAE,aAAqB;;QACzF,IAAI,MAAM,GAAG,SAAS,CAAC;QACvB,IAAI,QAAQ,GAAG,MAAA,MAAA,MAAM,CAAC,QAAQ,CAAC,kBAAkB,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K,oBAAoB;gBACvB,OAAO,IAAI,CAAC,iCAAiC,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;YAClG,KAAK,qBAAqB,CAAC,CAAC,OAAO,IAAI,CAAC,kCAAkC,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;YAC7H,KAAK,yBAAyB,CAAC,CAAC,OAAO,IAAI,CAAC,qCAAqC,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;SACrI;QACD,MAAM,IAAI,uCAAiB,CAAC,wCAAkB,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAC7E,CAAC;CAEF;AA9ND,sDA8NC;AAED,MAAM,cAAc,GAAG,CAAC,QAAkC,EAAE,EAAE;IAC5D,OAAO,CAAC,EAAc,EAAE,EAAE;QACxB,IAAI,CAAC,mBAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YACvB,QAAQ,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { GeometricElement, GeometricElement3d, IModelDb } from \"@itwin/core-backend\";\r\nimport { DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n ComputeSelectionRequestOptions, ElementSelectionScopeProps, InstanceKey, isComputeSelectionRequestOptions, KeySet, PresentationError,\r\n PresentationStatus, SelectionScope, SelectionScopeRequestOptions,\r\n} from \"@itwin/presentation-common\";\r\nimport { getElementKey } from \"./Utils\";\r\n\r\n/**\r\n * Contains helper methods for computing selection scopes. Will get removed\r\n * once rules-driven scopes are implemented.\r\n *\r\n * @internal\r\n */\r\nexport class SelectionScopesHelper {\r\n\r\n // istanbul ignore next\r\n private constructor() { }\r\n\r\n public static getSelectionScopes(): SelectionScope[] {\r\n const createSelectionScope = (scopeId: string, label: string, description: string): SelectionScope => ({\r\n id: scopeId,\r\n label,\r\n description,\r\n });\r\n return [\r\n createSelectionScope(\"element\", \"Element\", \"Select the picked element\"),\r\n createSelectionScope(\"assembly\", \"Assembly\", \"Select parent of the picked element\"),\r\n createSelectionScope(\"top-assembly\", \"Top Assembly\", \"Select the topmost parent of the picked element\"),\r\n // WIP: temporarily comment-out \"category\" and \"model\" scopes since we can't hilite contents of them fast enough\r\n // createSelectionScope(\"category\", \"Category\", \"Select all elements in the picked element's category\"),\r\n // createSelectionScope(\"model\", \"Model\", \"Select all elements in the picked element's model\"),\r\n ];\r\n }\r\n\r\n private static getElementKey(iModel: IModelDb, elementId: Id64String, ancestorLevel: number) {\r\n let currId = elementId;\r\n let parentId = iModel.elements.tryGetElementProps(currId)?.parent?.id;\r\n while (parentId && ancestorLevel !== 0) {\r\n currId = parentId;\r\n parentId = iModel.elements.tryGetElementProps(currId)?.parent?.id;\r\n --ancestorLevel;\r\n }\r\n return getElementKey(iModel, currId);\r\n }\r\n\r\n private static computeElementSelection(iModel: IModelDb, elementIds: Id64String[], ancestorLevel: number) {\r\n const parentKeys = new KeySet();\r\n elementIds.forEach(skipTransients((id) => {\r\n const key = this.getElementKey(iModel, id, ancestorLevel);\r\n key && parentKeys.add(key);\r\n }));\r\n return parentKeys;\r\n }\r\n\r\n private static computeCategorySelection(iModel: IModelDb, ids: Id64String[]) {\r\n const categoryKeys = new KeySet();\r\n ids.forEach(skipTransients((id) => {\r\n const el = iModel.elements.tryGetElement(id);\r\n if (el instanceof GeometricElement) {\r\n const category = iModel.elements.tryGetElementProps(el.category);\r\n if (category)\r\n categoryKeys.add({ className: category.classFullName, id: category.id! });\r\n }\r\n }));\r\n return categoryKeys;\r\n }\r\n\r\n private static computeModelSelection(iModel: IModelDb, ids: Id64String[]) {\r\n const modelKeys = new KeySet();\r\n ids.forEach(skipTransients((id) => {\r\n const el = iModel.elements.tryGetElementProps(id);\r\n const model = el ? iModel.models.tryGetModelProps(el.model) : undefined;\r\n if (model)\r\n modelKeys.add({ className: model.classFullName, id: model.id! });\r\n }));\r\n return modelKeys;\r\n }\r\n\r\n private static getRelatedFunctionalElementKey(imodel: IModelDb, graphicalElementId: Id64String): InstanceKey | undefined {\r\n const query = `\r\n SELECT funcSchemaDef.Name || '.' || funcClassDef.Name funcElClassName, fe.ECInstanceId funcElId\r\n FROM bis.Element e\r\n LEFT JOIN func.PhysicalElementFulfillsFunction rel1 ON rel1.SourceECInstanceId = e.ECInstanceId\r\n LEFT JOIN func.DrawingGraphicRepresentsFunctionalElement rel2 ON rel2.SourceECInstanceId = e.ECInstanceId\r\n LEFT JOIN func.FunctionalElement fe ON fe.ECInstanceId IN (rel1.TargetECInstanceId, rel2.TargetECInstanceId)\r\n INNER JOIN meta.ECClassDef funcClassDef ON funcClassDef.ECInstanceId = fe.ECClassId\r\n INNER JOIN meta.ECSchemaDef funcSchemaDef ON funcSchemaDef.ECInstanceId = funcClassDef.Schema.Id\r\n WHERE e.ECInstanceId = ?\r\n `;\r\n return imodel.withPreparedStatement(query, (stmt): InstanceKey | undefined => {\r\n stmt.bindId(1, graphicalElementId);\r\n // istanbul ignore else\r\n if (DbResult.BE_SQLITE_ROW === stmt.step()) {\r\n const row = stmt.getRow();\r\n if (row.funcElClassName && row.funcElId)\r\n return { className: row.funcElClassName.replace(\".\", \":\"), id: row.funcElId };\r\n }\r\n return undefined;\r\n });\r\n }\r\n\r\n private static findFirstRelatedFunctionalElementKey(imodel: IModelDb, graphicalElementId: Id64String): InstanceKey | undefined {\r\n let currId: Id64String | undefined = graphicalElementId;\r\n while (currId) {\r\n const relatedFunctionalKey = this.getRelatedFunctionalElementKey(imodel, currId);\r\n if (relatedFunctionalKey)\r\n return relatedFunctionalKey;\r\n currId = imodel.elements.tryGetElementProps(currId)?.parent?.id;\r\n }\r\n return undefined;\r\n }\r\n\r\n private static elementClassDerivesFrom(imodel: IModelDb, elementId: Id64String, baseClassFullName: string): boolean {\r\n const query = `\r\n SELECT 1\r\n FROM bis.Element e\r\n INNER JOIN meta.ClassHasAllBaseClasses baseClassRels ON baseClassRels.SourceECInstanceId = e.ECClassId\r\n INNER JOIN meta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId\r\n INNER JOIN meta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id\r\n WHERE e.ECInstanceId = ? AND (baseSchema.Name || ':' || baseClass.Name) = ?\r\n `;\r\n return imodel.withPreparedStatement(query, (stmt): boolean => {\r\n stmt.bindId(1, elementId);\r\n stmt.bindString(2, baseClassFullName);\r\n return (DbResult.BE_SQLITE_ROW === stmt.step());\r\n });\r\n }\r\n\r\n private static computeFunctionalElementSelection(iModel: IModelDb, ids: Id64String[]) {\r\n const keys = new KeySet();\r\n ids.forEach(skipTransients((id): void => {\r\n const is3d = this.elementClassDerivesFrom(iModel, id, GeometricElement3d.classFullName);\r\n if (!is3d) {\r\n // if the input is not a 3d element, we try to find the first related functional element\r\n const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);\r\n if (firstFunctionalKey) {\r\n keys.add(firstFunctionalKey);\r\n return;\r\n }\r\n }\r\n let keyToAdd: InstanceKey | undefined;\r\n if (is3d) {\r\n // if we're computing scope for a 3d element, try to switch to its related functional element\r\n keyToAdd = this.getRelatedFunctionalElementKey(iModel, id);\r\n }\r\n if (!keyToAdd)\r\n keyToAdd = getElementKey(iModel, id);\r\n keyToAdd && keys.add(keyToAdd);\r\n }));\r\n return keys;\r\n }\r\n\r\n private static computeFunctionalAssemblySelection(iModel: IModelDb, ids: Id64String[]) {\r\n const keys = new KeySet();\r\n ids.forEach(skipTransients((id): void => {\r\n let idToGetAssemblyFor = id;\r\n const is3d = this.elementClassDerivesFrom(iModel, id, GeometricElement3d.classFullName);\r\n if (!is3d) {\r\n // if the input is not a 3d element, we try to find the first related functional element\r\n const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);\r\n if (firstFunctionalKey)\r\n idToGetAssemblyFor = firstFunctionalKey.id;\r\n }\r\n // find the assembly of either the given element or the functional element\r\n const assemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, 1);\r\n let keyToAdd = assemblyKey;\r\n if (is3d && keyToAdd) {\r\n // if we're computing scope for a 3d element, try to switch to its related functional element\r\n const relatedFunctionalKey = this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);\r\n if (relatedFunctionalKey)\r\n keyToAdd = relatedFunctionalKey;\r\n }\r\n keyToAdd && keys.add(keyToAdd);\r\n }));\r\n return keys;\r\n }\r\n\r\n private static computeFunctionalTopAssemblySelection(iModel: IModelDb, ids: Id64String[]) {\r\n const keys = new KeySet();\r\n ids.forEach(skipTransients((id): void => {\r\n let idToGetAssemblyFor = id;\r\n const is3d = this.elementClassDerivesFrom(iModel, id, GeometricElement3d.classFullName);\r\n if (!is3d) {\r\n // if the input is not a 3d element, we try to find the first related functional element\r\n const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);\r\n if (firstFunctionalKey)\r\n idToGetAssemblyFor = firstFunctionalKey.id;\r\n }\r\n // find the top assembly of either the given element or the functional element\r\n const topAssemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, Number.MAX_SAFE_INTEGER);\r\n let keyToAdd = topAssemblyKey;\r\n if (is3d && keyToAdd) {\r\n // if we're computing scope for a 3d element, try to switch to its related functional element\r\n const relatedFunctionalKey = this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);\r\n if (relatedFunctionalKey)\r\n keyToAdd = relatedFunctionalKey;\r\n }\r\n keyToAdd && keys.add(keyToAdd);\r\n }));\r\n return keys;\r\n }\r\n\r\n /**\r\n * Computes selection set based on provided selection scope.\r\n * @param requestOptions Options for the request\r\n * @param keys Keys of elements to get the content for.\r\n * @param scopeId ID of selection scope to use for computing selection\r\n */\r\n public static async computeSelection(requestOptions: SelectionScopeRequestOptions<IModelDb>, ids: Id64String[], scopeId: string): Promise<KeySet>;\r\n /** @alpha */\r\n public static async computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb>): Promise<KeySet>;\r\n public static async computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb> | SelectionScopeRequestOptions<IModelDb>, elementIds?: Id64String[], scopeId?: string): Promise<KeySet> {\r\n if (!isComputeSelectionRequestOptions(requestOptions)) {\r\n return this.computeSelection({\r\n ...requestOptions,\r\n elementIds: elementIds!,\r\n scope: { id: scopeId! },\r\n });\r\n }\r\n\r\n switch (requestOptions.scope.id) {\r\n case \"element\": return this.computeElementSelection(requestOptions.imodel, requestOptions.elementIds, (requestOptions.scope as ElementSelectionScopeProps).ancestorLevel ?? 0);\r\n case \"assembly\": return this.computeElementSelection(requestOptions.imodel, requestOptions.elementIds, 1);\r\n case \"top-assembly\": return this.computeElementSelection(requestOptions.imodel, requestOptions.elementIds, Number.MAX_SAFE_INTEGER);\r\n case \"category\": return this.computeCategorySelection(requestOptions.imodel, requestOptions.elementIds);\r\n case \"model\": return this.computeModelSelection(requestOptions.imodel, requestOptions.elementIds);\r\n case \"functional\":\r\n case \"functional-element\":\r\n return this.computeFunctionalElementSelection(requestOptions.imodel, requestOptions.elementIds);\r\n case \"functional-assembly\": return this.computeFunctionalAssemblySelection(requestOptions.imodel, requestOptions.elementIds);\r\n case \"functional-top-assembly\": return this.computeFunctionalTopAssemblySelection(requestOptions.imodel, requestOptions.elementIds);\r\n }\r\n throw new PresentationError(PresentationStatus.InvalidArgument, \"scopeId\");\r\n }\r\n\r\n}\r\n\r\nconst skipTransients = (callback: (id: Id64String) => void) => {\r\n return (id: Id64String) => {\r\n if (!Id64.isTransient(id))\r\n callback(id);\r\n };\r\n};\r\n"]}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Core
|
|
3
3
|
*/
|
|
4
|
-
import { Id64String } from "@itwin/core-bentley";
|
|
5
4
|
import { IModelDb } from "@itwin/core-backend";
|
|
6
|
-
import {
|
|
5
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
6
|
+
import { Diagnostics, DiagnosticsOptions, InstanceKey } from "@itwin/presentation-common";
|
|
7
7
|
/** @internal */
|
|
8
8
|
export declare function getElementKey(imodel: IModelDb, id: Id64String): InstanceKey | undefined;
|
|
9
9
|
/** @internal */
|
|
10
10
|
export declare function normalizeVersion(version?: string): string;
|
|
11
11
|
/** @internal */
|
|
12
12
|
export declare const getLocalesDirectory: (assetsDirectory: string) => string;
|
|
13
|
+
/** @alpha */
|
|
14
|
+
export declare type BackendDiagnosticsHandler = (logs: Diagnostics) => void;
|
|
15
|
+
/** @alpha */
|
|
16
|
+
export interface BackendDiagnosticsOptions extends DiagnosticsOptions {
|
|
17
|
+
handler: BackendDiagnosticsHandler;
|
|
18
|
+
}
|
|
19
|
+
/** @public */
|
|
20
|
+
export interface BackendDiagnosticsAttribute {
|
|
21
|
+
/** @alpha */
|
|
22
|
+
diagnostics?: BackendDiagnosticsOptions;
|
|
23
|
+
}
|
|
13
24
|
//# sourceMappingURL=Utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/Utils.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/Utils.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAW,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAY,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE1F,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,GAAG,WAAW,GAAG,SAAS,CAWvF;AAED,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,UAOhD;AAED,gBAAgB;AAEhB,eAAO,MAAM,mBAAmB,oBAAqB,MAAM,WAA0C,CAAC;AAEtG,aAAa;AACb,oBAAY,yBAAyB,GAAG,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;AAEpE,aAAa;AACb,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE,OAAO,EAAE,yBAAyB,CAAC;CACpC;AAED,cAAc;AACd,MAAM,WAAW,2BAA2B;IAC1C,aAAa;IACb,WAAW,CAAC,EAAE,yBAAyB,CAAC;CACzC"}
|
|
@@ -11,10 +11,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.getLocalesDirectory = exports.normalizeVersion = exports.getElementKey = void 0;
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
14
15
|
const semver_1 = require("semver");
|
|
15
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
16
16
|
const core_backend_1 = require("@itwin/core-backend");
|
|
17
|
-
const
|
|
17
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
18
18
|
/** @internal */
|
|
19
19
|
function getElementKey(imodel, id) {
|
|
20
20
|
let key;
|