@itwin/presentation-backend 3.1.0-dev.37 → 3.1.0-dev.40
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/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +4 -3
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.js +5 -5
- package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
- package/package.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationRpcImpl.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAU,UAAU,EAAE,WAAW,EAAU,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACL,kCAAkC,EAAgB,oCAAoC,EAAE,wBAAwB,EAAE,+BAA+B,EACjJ,uBAAuB,EAAE,cAAc,EAA4C,6BAA6B,EAAE,8BAA8B,EAC7H,qBAAqB,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,+CAA+C,EAC7I,sCAAsC,EAAE,0BAA0B,EAAe,QAAQ,EAAU,UAAU,EAAmB,mBAAmB,EAC7I,QAAQ,EAAyC,mBAAmB,EAAE,KAAK,EAAE,aAAa,EAChG,wBAAwB,EAAE,uBAAuB,EAChC,cAAc,EAAE,+BAA+B,EAAE,wCAAwC,EAC3G,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAK5D,gBAAgB;AAChB,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,gBAAgB;A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,cAAc,EAAE,cAAc,EAAE,KAAK,CAAC,wBAAwB,CAAC,GAAG,uBAAuB,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAK5I,oBAAoB,CAAC,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,wCAAwC,GAAG,uBAAuB,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAM7J,sBAAsB,CAAC,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,+BAA+B,GAAG,uBAAuB,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAc7J,sBAAsB,CAAC,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,oCAAoC,GAAG,uBAAuB,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,CAAC;IA2BlK,yBAAyB,CAAC,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,6BAA6B,GAAG,uBAAuB,CAAC,mBAAmB,CAAC;IAO7I,+BAA+B,CAAC,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,8BAA8B,GAAG,uBAAuB,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAanK,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,+BAA+B,GAAG,uBAAuB,CAAC,cAAc,EAAE,CAAC;IAMrI,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,+BAA+B,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,uBAAuB,CAAC,UAAU,CAAC;CAMxL"}
|
|
@@ -41,8 +41,9 @@ class PresentationRpcImpl extends presentation_common_1.PresentationRpcInterface
|
|
|
41
41
|
unusedValueLifetime: this._requestTimeout + 10 * 1000,
|
|
42
42
|
// attempt to clean up every second
|
|
43
43
|
cleanupInterval: 1000,
|
|
44
|
-
cleanupHandler: (id) => {
|
|
45
|
-
|
|
44
|
+
cleanupHandler: (id, _, reason) => {
|
|
45
|
+
if (reason !== "request")
|
|
46
|
+
core_bentley_1.Logger.logTrace(BackendLoggerCategory_1.PresentationBackendLoggerCategory.Rpc, `Cleaning up request without frontend retrieving it: ${id}.`);
|
|
46
47
|
},
|
|
47
48
|
});
|
|
48
49
|
}
|
|
@@ -84,7 +85,7 @@ class PresentationRpcImpl extends presentation_common_1.PresentationRpcInterface
|
|
|
84
85
|
return imodel;
|
|
85
86
|
}
|
|
86
87
|
async makeRequest(token, requestId, requestOptions, request) {
|
|
87
|
-
const requestKey = JSON.stringify(requestOptions);
|
|
88
|
+
const requestKey = JSON.stringify({ iModelKey: token.key, requestId, requestOptions });
|
|
88
89
|
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.PresentationBackendLoggerCategory.Rpc, `Received '${requestId}' request. Params: ${requestKey}`);
|
|
89
90
|
let resultPromise = this._pendingRequests.getValue(requestKey);
|
|
90
91
|
if (resultPromise) {
|
|
@@ -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;;;;;;;;;;;GAWG;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,EA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B,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 * Consumers should not use this class. Instead, they should register\r\n * [PresentationRpcInterface]($presentation-common):\r\n * ``` ts\r\n * [[include:Backend.Initialization.RpcInterface]]\r\n * ```\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) => {\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(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,oEAQoC;AACpC,mEAA4E;AAC5E,iDAA8C;AAE9C,yDAAsD;AAItD,gBAAgB;AACH,QAAA,qBAAqB,GAAG,IAAI,CAAC;AAC1C,gBAAgB;AACH,QAAA,0BAA0B,GAAG,KAAK,CAAC;AAEhD;;;;;;;;;;;GAWG;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,EAAE,IAAI,CAAC,eAAe,GAAG,EAAE,GAAG,IAAI;YAErD,mCAAmC;YACnC,eAAe,EAAE,IAAI;YAErB,cAAc,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE;gBAChC,IAAI,MAAM,KAAK,SAAS;oBACtB,qBAAM,CAAC,QAAQ,CAAC,yDAAiC,CAAC,GAAG,EAAE,uDAAuD,EAAE,GAAG,CAAC,CAAC;YACzH,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;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;YACxG,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACtF,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAxUD,kDAwUC;AAED,MAAM,oBAAoB,GAAG,CAAiC,cAAwB,EAAE,WAAW,GAAG,6BAAqB,EAAsC,EAAE;;IACjK,MAAM,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 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 * Consumers should not use this class. Instead, they should register\r\n * [PresentationRpcInterface]($presentation-common):\r\n * ``` ts\r\n * [[include:Backend.Initialization.RpcInterface]]\r\n * ```\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"]}
|
|
@@ -8,7 +8,7 @@ import { IDisposable } from "@itwin/core-bentley";
|
|
|
8
8
|
*/
|
|
9
9
|
export interface TemporaryStorageProps<T> {
|
|
10
10
|
/** A method that's called for every value before it's removed from storage */
|
|
11
|
-
cleanupHandler?: (id: string, value: T) => void;
|
|
11
|
+
cleanupHandler?: (id: string, value: T, reason: "timeout" | "dispose" | "request") => void;
|
|
12
12
|
onDisposedSingle?: (id: string) => void;
|
|
13
13
|
onDisposedAll?: () => void;
|
|
14
14
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemporaryStorage.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/TemporaryStorage.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAG1D;;;GAGG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,8EAA8E;IAC9E,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"TemporaryStorage.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/TemporaryStorage.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAG1D;;;GAGG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,8EAA8E;IAC9E,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;IAE3F,gBAAgB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAE3B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;;;;OAQG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;;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,CAAC,CAAC;IAErE;;OAEG;gBACS,KAAK,EAAE,iCAAiC,CAAC,CAAC,CAAC;IAKvD;;;;;OAKG;IACa,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC;CASxC"}
|
|
@@ -43,7 +43,7 @@ class TemporaryStorage {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
for (const id of valuesToDispose)
|
|
46
|
-
this.deleteExistingEntry(id);
|
|
46
|
+
this.deleteExistingEntry(id, true);
|
|
47
47
|
};
|
|
48
48
|
this.props = props;
|
|
49
49
|
this._values = new Map();
|
|
@@ -59,15 +59,15 @@ class TemporaryStorage {
|
|
|
59
59
|
clearInterval(this._timer);
|
|
60
60
|
if (this.props.cleanupHandler) {
|
|
61
61
|
this._values.forEach((v, id) => {
|
|
62
|
-
this.props.cleanupHandler(id, v.value);
|
|
62
|
+
this.props.cleanupHandler(id, v.value, "dispose");
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
this._values.clear();
|
|
66
66
|
this.props.onDisposedAll && this.props.onDisposedAll();
|
|
67
67
|
}
|
|
68
|
-
deleteExistingEntry(id) {
|
|
68
|
+
deleteExistingEntry(id, isTimeout) {
|
|
69
69
|
(0, core_bentley_1.assert)(this._values.has(id));
|
|
70
|
-
this.props.cleanupHandler && this.props.cleanupHandler(id, this._values.get(id).value);
|
|
70
|
+
this.props.cleanupHandler && this.props.cleanupHandler(id, this._values.get(id).value, isTimeout ? "timeout" : "request");
|
|
71
71
|
this._values.delete(id);
|
|
72
72
|
this.props.onDisposedSingle && this.props.onDisposedSingle(id);
|
|
73
73
|
}
|
|
@@ -103,7 +103,7 @@ class TemporaryStorage {
|
|
|
103
103
|
deleteValue(id) {
|
|
104
104
|
// istanbul ignore else
|
|
105
105
|
if (this._values.has(id))
|
|
106
|
-
this.deleteExistingEntry(id);
|
|
106
|
+
this.deleteExistingEntry(id, false);
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
109
|
* Get all values currently in this storage.
|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,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO,MAAM,CAAC;IAChB,CAAC;CAEF;AApHD,4CAoHC;AAWD;;;;;GAKG;AACH,MAAa,4BAAgC,SAAQ,gBAAmB;IAItE;;OAEG;IACH,YAAY,KAA2C;QACrD,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;;;;OAKG;IACa,QAAQ,CAAC,EAAU;QACjC,MAAM,aAAa,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,aAAa;YACf,OAAO,aAAa,CAAC;QAEvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA3BD,oEA2BC","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 { assert, IDisposable } from \"@itwin/core-bentley\";\r\nimport { PresentationError, PresentationStatus } from \"@itwin/presentation-common\";\r\n\r\n/**\r\n * Configuration properties for [[TemporaryStorage]].\r\n * @internal\r\n */\r\nexport interface TemporaryStorageProps<T> {\r\n /** A method that's called for every value before it's removed from storage */\r\n cleanupHandler?: (id: string, value: T) => void;\r\n\r\n onDisposedSingle?: (id: string) => void;\r\n onDisposedAll?: () => void;\r\n\r\n /**\r\n * An interval at which the storage attempts to clean up its values.\r\n * When `0` or `undefined` is specified, values are not cleaned up\r\n * automatically and cleanup has to be initiated manually by calling\r\n * [[TemporaryStorage.disposeOutdatedValues]].\r\n */\r\n cleanupInterval?: number;\r\n\r\n /**\r\n * Shortest period of time which the value should be kept in storage\r\n * unused before it's cleaned up.\r\n *\r\n * `undefined` means the values may be kept unused in the storage indefinitely.\r\n * `0` means the values are removed from the storage on every cleanup (either manual\r\n * call to [[TemporaryStorage.disposeOutdatedValues]] or scheduled (controlled\r\n * by [[cleanupInterval]])).\r\n */\r\n unusedValueLifetime?: number;\r\n\r\n /**\r\n * The maximum period of time which the value should be kept in storage\r\n * before it's cleaned up. The time is measured from the moment the value is added\r\n * to the storage.\r\n *\r\n * `undefined` means the values may be kept indefinitely. `0` means they're removed\r\n * up on every cleanup (either manual call to [[TemporaryStorage.disposeOutdatedValues]]\r\n * or scheduled (controlled by [[cleanupInterval]])).\r\n */\r\n maxValueLifetime?: number;\r\n}\r\n\r\n/** Value with know last used time */\r\ninterface TemporaryValue<T> {\r\n created: Date;\r\n lastUsed: Date;\r\n value: T;\r\n}\r\n\r\n/**\r\n * Storage for values that get removed from it after being unused (not-requested\r\n * for a specified amount of time).\r\n *\r\n * @internal\r\n */\r\nexport class TemporaryStorage<T> implements IDisposable {\r\n\r\n private _timer?: NodeJS.Timer;\r\n protected _values: Map<string, TemporaryValue<T>>;\r\n public readonly props: TemporaryStorageProps<T>;\r\n\r\n /**\r\n * Constructor. Creates the storage using supplied params.\r\n */\r\n constructor(props: TemporaryStorageProps<T>) {\r\n this.props = props;\r\n this._values = new Map<string, TemporaryValue<T>>();\r\n if (this.props.cleanupInterval)\r\n this._timer = setInterval(this.disposeOutdatedValues, this.props.cleanupInterval);\r\n }\r\n\r\n /**\r\n * Destructor. Must be called to clean up the stored values\r\n * and other resources\r\n */\r\n public dispose() {\r\n if (this._timer)\r\n clearInterval(this._timer);\r\n\r\n if (this.props.cleanupHandler) {\r\n this._values.forEach((v, id) => {\r\n this.props.cleanupHandler!(id, v.value);\r\n });\r\n }\r\n this._values.clear();\r\n this.props.onDisposedAll && this.props.onDisposedAll();\r\n }\r\n\r\n /**\r\n * Cleans up values that are currently outdated (based\r\n * on their max and unused value lifetimes specified through [[Props]]).\r\n */\r\n public disposeOutdatedValues = () => {\r\n const now = (new Date()).getTime();\r\n const valuesToDispose: string[] = [];\r\n for (const [key, entry] of this._values.entries()) {\r\n if (this.props.maxValueLifetime !== undefined) {\r\n if (this.props.maxValueLifetime === 0 || (now - entry.created.getTime()) > this.props.maxValueLifetime) {\r\n valuesToDispose.push(key);\r\n continue;\r\n }\r\n }\r\n if (this.props.unusedValueLifetime !== undefined) {\r\n if (this.props.unusedValueLifetime === 0 || (now - entry.lastUsed.getTime()) > this.props.unusedValueLifetime) {\r\n valuesToDispose.push(key);\r\n continue;\r\n }\r\n }\r\n }\r\n for (const id of valuesToDispose)\r\n this.deleteExistingEntry(id);\r\n };\r\n\r\n private deleteExistingEntry(id: string) {\r\n assert(this._values.has(id));\r\n this.props.cleanupHandler && this.props.cleanupHandler(id, this._values.get(id)!.value);\r\n this._values.delete(id);\r\n this.props.onDisposedSingle && this.props.onDisposedSingle(id);\r\n }\r\n\r\n /**\r\n * Get a value from the storage.\r\n *\r\n * **Note:** requesting a value with this method updates it's last used time.\r\n */\r\n public getValue(id: string): T | undefined {\r\n if (this._values.has(id)) {\r\n const v = this._values.get(id)!;\r\n v.lastUsed = new Date();\r\n return v.value;\r\n }\r\n return undefined;\r\n }\r\n\r\n public notifyValueUsed(id: string) {\r\n const entry = this._values.get(id);\r\n // istanbul ignore else\r\n if (entry)\r\n entry.lastUsed = new Date();\r\n }\r\n\r\n /**\r\n * Adds a value into the storage.\r\n * @throws An error when trying to add a value with ID that's already stored in the storage.\r\n */\r\n public addValue(id: string, value: T) {\r\n if (this._values.has(id))\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `A value with given ID \"${id}\" already exists in this storage.`);\r\n this._values.set(id, { value, created: new Date(), lastUsed: new Date() });\r\n }\r\n\r\n /** Deletes a value with given id. */\r\n public deleteValue(id: string) {\r\n // istanbul ignore else\r\n if (this._values.has(id))\r\n this.deleteExistingEntry(id);\r\n }\r\n\r\n /**\r\n * Get all values currently in this storage.\r\n *\r\n * **Note:** requesting values with this method **doesn't**\r\n * update their last used times.\r\n */\r\n public get values(): T[] {\r\n const values = new Array<T>();\r\n for (const v of this._values.values())\r\n values.push(v.value);\r\n return values;\r\n }\r\n\r\n}\r\n\r\n/**\r\n * Configuration properties for [[FactoryBasedTemporaryStorage]].\r\n * @internal\r\n */\r\nexport interface FactoryBasedTemporaryStorageProps<T> extends TemporaryStorageProps<T> {\r\n /** A factory method that creates a stored value given it's identifier */\r\n factory: (id: string, onValueUsed: () => void) => T;\r\n}\r\n\r\n/**\r\n * Storage for values that get removed from it after being unused (not-requested\r\n * for a specified amount of time).\r\n *\r\n * @internal\r\n */\r\nexport class FactoryBasedTemporaryStorage<T> extends TemporaryStorage<T> {\r\n\r\n public override readonly props: FactoryBasedTemporaryStorageProps<T>;\r\n\r\n /**\r\n * Constructor. Creates the storage using supplied params.\r\n */\r\n constructor(props: FactoryBasedTemporaryStorageProps<T>) {\r\n super(props);\r\n this.props = props;\r\n }\r\n\r\n /**\r\n * Get a value from the storage. If the value with the specified id\r\n * doesn't exist, it gets created.\r\n *\r\n * **Note:** requesting a value with this method updates it's last used time.\r\n */\r\n public override getValue(id: string): T {\r\n const existingValue = super.getValue(id);\r\n if (existingValue)\r\n return existingValue;\r\n\r\n const value = this.props.factory(id, () => this.notifyValueUsed(id));\r\n this.addValue(id, value);\r\n return value;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"TemporaryStorage.js","sourceRoot":"","sources":["../../../src/presentation-backend/TemporaryStorage.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA0D;AAC1D,oEAAmF;AAmDnF;;;;;GAKG;AACH,MAAa,gBAAgB;IAM3B;;OAEG;IACH,YAAY,KAA+B;QAwB3C;;;WAGG;QACI,0BAAqB,GAAG,GAAG,EAAE;YAClC,MAAM,GAAG,GAAG,CAAC,IAAI,IAA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KAAK,CAAC;IACrB,CAAC;IAED;;;;;OAKG;IACa,QAAQ,CAAC,EAAU;QACjC,MAAM,aAAa,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,aAAa;YACf,OAAO,aAAa,CAAC;QAEvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA3BD,oEA2BC","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 { assert, IDisposable } from \"@itwin/core-bentley\";\r\nimport { PresentationError, PresentationStatus } from \"@itwin/presentation-common\";\r\n\r\n/**\r\n * Configuration properties for [[TemporaryStorage]].\r\n * @internal\r\n */\r\nexport interface TemporaryStorageProps<T> {\r\n /** A method that's called for every value before it's removed from storage */\r\n cleanupHandler?: (id: string, value: T, reason: \"timeout\" | \"dispose\" | \"request\") => void;\r\n\r\n onDisposedSingle?: (id: string) => void;\r\n onDisposedAll?: () => void;\r\n\r\n /**\r\n * An interval at which the storage attempts to clean up its values.\r\n * When `0` or `undefined` is specified, values are not cleaned up\r\n * automatically and cleanup has to be initiated manually by calling\r\n * [[TemporaryStorage.disposeOutdatedValues]].\r\n */\r\n cleanupInterval?: number;\r\n\r\n /**\r\n * Shortest period of time which the value should be kept in storage\r\n * unused before it's cleaned up.\r\n *\r\n * `undefined` means the values may be kept unused in the storage indefinitely.\r\n * `0` means the values are removed from the storage on every cleanup (either manual\r\n * call to [[TemporaryStorage.disposeOutdatedValues]] or scheduled (controlled\r\n * by [[cleanupInterval]])).\r\n */\r\n unusedValueLifetime?: number;\r\n\r\n /**\r\n * The maximum period of time which the value should be kept in storage\r\n * before it's cleaned up. The time is measured from the moment the value is added\r\n * to the storage.\r\n *\r\n * `undefined` means the values may be kept indefinitely. `0` means they're removed\r\n * up on every cleanup (either manual call to [[TemporaryStorage.disposeOutdatedValues]]\r\n * or scheduled (controlled by [[cleanupInterval]])).\r\n */\r\n maxValueLifetime?: number;\r\n}\r\n\r\n/** Value with know last used time */\r\ninterface TemporaryValue<T> {\r\n created: Date;\r\n lastUsed: Date;\r\n value: T;\r\n}\r\n\r\n/**\r\n * Storage for values that get removed from it after being unused (not-requested\r\n * for a specified amount of time).\r\n *\r\n * @internal\r\n */\r\nexport class TemporaryStorage<T> implements IDisposable {\r\n\r\n private _timer?: NodeJS.Timer;\r\n protected _values: Map<string, TemporaryValue<T>>;\r\n public readonly props: TemporaryStorageProps<T>;\r\n\r\n /**\r\n * Constructor. Creates the storage using supplied params.\r\n */\r\n constructor(props: TemporaryStorageProps<T>) {\r\n this.props = props;\r\n this._values = new Map<string, TemporaryValue<T>>();\r\n if (this.props.cleanupInterval)\r\n this._timer = setInterval(this.disposeOutdatedValues, this.props.cleanupInterval);\r\n }\r\n\r\n /**\r\n * Destructor. Must be called to clean up the stored values\r\n * and other resources\r\n */\r\n public dispose() {\r\n if (this._timer)\r\n clearInterval(this._timer);\r\n\r\n if (this.props.cleanupHandler) {\r\n this._values.forEach((v, id) => {\r\n this.props.cleanupHandler!(id, v.value, \"dispose\");\r\n });\r\n }\r\n this._values.clear();\r\n this.props.onDisposedAll && this.props.onDisposedAll();\r\n }\r\n\r\n /**\r\n * Cleans up values that are currently outdated (based\r\n * on their max and unused value lifetimes specified through [[Props]]).\r\n */\r\n public disposeOutdatedValues = () => {\r\n const now = (new Date()).getTime();\r\n const valuesToDispose: string[] = [];\r\n for (const [key, entry] of this._values.entries()) {\r\n if (this.props.maxValueLifetime !== undefined) {\r\n if (this.props.maxValueLifetime === 0 || (now - entry.created.getTime()) > this.props.maxValueLifetime) {\r\n valuesToDispose.push(key);\r\n continue;\r\n }\r\n }\r\n if (this.props.unusedValueLifetime !== undefined) {\r\n if (this.props.unusedValueLifetime === 0 || (now - entry.lastUsed.getTime()) > this.props.unusedValueLifetime) {\r\n valuesToDispose.push(key);\r\n continue;\r\n }\r\n }\r\n }\r\n for (const id of valuesToDispose)\r\n this.deleteExistingEntry(id, true);\r\n };\r\n\r\n private deleteExistingEntry(id: string, isTimeout: boolean) {\r\n assert(this._values.has(id));\r\n this.props.cleanupHandler && this.props.cleanupHandler(id, this._values.get(id)!.value, isTimeout ? \"timeout\" : \"request\");\r\n this._values.delete(id);\r\n this.props.onDisposedSingle && this.props.onDisposedSingle(id);\r\n }\r\n\r\n /**\r\n * Get a value from the storage.\r\n *\r\n * **Note:** requesting a value with this method updates it's last used time.\r\n */\r\n public getValue(id: string): T | undefined {\r\n if (this._values.has(id)) {\r\n const v = this._values.get(id)!;\r\n v.lastUsed = new Date();\r\n return v.value;\r\n }\r\n return undefined;\r\n }\r\n\r\n public notifyValueUsed(id: string) {\r\n const entry = this._values.get(id);\r\n // istanbul ignore else\r\n if (entry)\r\n entry.lastUsed = new Date();\r\n }\r\n\r\n /**\r\n * Adds a value into the storage.\r\n * @throws An error when trying to add a value with ID that's already stored in the storage.\r\n */\r\n public addValue(id: string, value: T) {\r\n if (this._values.has(id))\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `A value with given ID \"${id}\" already exists in this storage.`);\r\n this._values.set(id, { value, created: new Date(), lastUsed: new Date() });\r\n }\r\n\r\n /** Deletes a value with given id. */\r\n public deleteValue(id: string) {\r\n // istanbul ignore else\r\n if (this._values.has(id))\r\n this.deleteExistingEntry(id, false);\r\n }\r\n\r\n /**\r\n * Get all values currently in this storage.\r\n *\r\n * **Note:** requesting values with this method **doesn't**\r\n * update their last used times.\r\n */\r\n public get values(): T[] {\r\n const values = new Array<T>();\r\n for (const v of this._values.values())\r\n values.push(v.value);\r\n return values;\r\n }\r\n\r\n}\r\n\r\n/**\r\n * Configuration properties for [[FactoryBasedTemporaryStorage]].\r\n * @internal\r\n */\r\nexport interface FactoryBasedTemporaryStorageProps<T> extends TemporaryStorageProps<T> {\r\n /** A factory method that creates a stored value given it's identifier */\r\n factory: (id: string, onValueUsed: () => void) => T;\r\n}\r\n\r\n/**\r\n * Storage for values that get removed from it after being unused (not-requested\r\n * for a specified amount of time).\r\n *\r\n * @internal\r\n */\r\nexport class FactoryBasedTemporaryStorage<T> extends TemporaryStorage<T> {\r\n\r\n public override readonly props: FactoryBasedTemporaryStorageProps<T>;\r\n\r\n /**\r\n * Constructor. Creates the storage using supplied params.\r\n */\r\n constructor(props: FactoryBasedTemporaryStorageProps<T>) {\r\n super(props);\r\n this.props = props;\r\n }\r\n\r\n /**\r\n * Get a value from the storage. If the value with the specified id\r\n * doesn't exist, it gets created.\r\n *\r\n * **Note:** requesting a value with this method updates it's last used time.\r\n */\r\n public override getValue(id: string): T {\r\n const existingValue = super.getValue(id);\r\n if (existingValue)\r\n return existingValue;\r\n\r\n const value = this.props.factory(id, () => this.notifyValueUsed(id));\r\n this.addValue(id, value);\r\n return value;\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-backend",
|
|
3
|
-
"version": "3.1.0-dev.
|
|
3
|
+
"version": "3.1.0-dev.40",
|
|
4
4
|
"description": "Backend of iTwin.js Presentation library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,20 +22,20 @@
|
|
|
22
22
|
"main": "lib/cjs/presentation-backend.js",
|
|
23
23
|
"typings": "lib/cjs/presentation-backend",
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@itwin/core-backend": "^3.1.0-dev.
|
|
26
|
-
"@itwin/core-bentley": "^3.1.0-dev.
|
|
27
|
-
"@itwin/core-common": "^3.1.0-dev.
|
|
28
|
-
"@itwin/core-quantity": "^3.1.0-dev.
|
|
29
|
-
"@itwin/presentation-common": "^3.1.0-dev.
|
|
25
|
+
"@itwin/core-backend": "^3.1.0-dev.40",
|
|
26
|
+
"@itwin/core-bentley": "^3.1.0-dev.40",
|
|
27
|
+
"@itwin/core-common": "^3.1.0-dev.40",
|
|
28
|
+
"@itwin/core-quantity": "^3.1.0-dev.40",
|
|
29
|
+
"@itwin/presentation-common": "^3.1.0-dev.40"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@itwin/build-tools": "3.1.0-dev.
|
|
33
|
-
"@itwin/core-backend": "3.1.0-dev.
|
|
34
|
-
"@itwin/core-bentley": "3.1.0-dev.
|
|
35
|
-
"@itwin/core-common": "3.1.0-dev.
|
|
36
|
-
"@itwin/core-quantity": "3.1.0-dev.
|
|
37
|
-
"@itwin/eslint-plugin": "3.1.0-dev.
|
|
38
|
-
"@itwin/presentation-common": "3.1.0-dev.
|
|
32
|
+
"@itwin/build-tools": "3.1.0-dev.40",
|
|
33
|
+
"@itwin/core-backend": "3.1.0-dev.40",
|
|
34
|
+
"@itwin/core-bentley": "3.1.0-dev.40",
|
|
35
|
+
"@itwin/core-common": "3.1.0-dev.40",
|
|
36
|
+
"@itwin/core-quantity": "3.1.0-dev.40",
|
|
37
|
+
"@itwin/eslint-plugin": "3.1.0-dev.40",
|
|
38
|
+
"@itwin/presentation-common": "3.1.0-dev.40",
|
|
39
39
|
"@types/chai": "^4.1.4",
|
|
40
40
|
"@types/chai-as-promised": "^7",
|
|
41
41
|
"@types/chai-jest-snapshot": "^1.3.0",
|