@itwin/presentation-backend 5.0.0-dev.8 → 5.0.0-dev.82
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 +46 -1
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +31 -4
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +161 -57
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.d.ts +2 -2
- package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.js +3 -1
- package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.js +19 -15
- package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js +1 -4
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +4 -68
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +56 -103
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +3 -3
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js +20 -20
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +9 -9
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +74 -84
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetEmbedder.js +5 -3
- package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetManager.js +2 -1
- package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js +2 -0
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +2 -4
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js +17 -26
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +2 -3
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.js +30 -26
- package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
- package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/Utils.js +1 -2
- package/lib/cjs/presentation-backend/Utils.js.map +1 -1
- package/package.json +23 -22
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module RPC
|
|
3
3
|
*/
|
|
4
|
-
import { Id64String, IDisposable } from "@itwin/core-bentley";
|
|
5
4
|
import { IModelRpcProps } from "@itwin/core-common";
|
|
6
|
-
import { ComputeSelectionRpcRequestOptions, ContentDescriptorRpcRequestOptions, ContentInstanceKeysRpcRequestOptions, ContentRpcRequestOptions, ContentSourcesRpcRequestOptions, ContentSourcesRpcResult, DescriptorJSON, DisplayLabelRpcRequestOptions, DisplayLabelsRpcRequestOptions,
|
|
5
|
+
import { ComputeSelectionRpcRequestOptions, ContentDescriptorRpcRequestOptions, ContentInstanceKeysRpcRequestOptions, ContentRpcRequestOptions, ContentSourcesRpcRequestOptions, ContentSourcesRpcResult, DescriptorJSON, DisplayLabelRpcRequestOptions, DisplayLabelsRpcRequestOptions, DisplayValueGroup, DistinctValuesRpcRequestOptions, ElementProperties, FilterByInstancePathsHierarchyRpcRequestOptions, FilterByTextHierarchyRpcRequestOptions, HierarchyLevelDescriptorRpcRequestOptions, HierarchyRpcRequestOptions, ItemJSON, KeySetJSON, LabelDefinition, Node, NodePathElement, Paged, PagedResponse, PresentationRpcInterface, PresentationRpcResponse, SelectionScope, SelectionScopeRpcRequestOptions, SingleElementPropertiesRpcRequestOptions } from "@itwin/presentation-common";
|
|
7
6
|
import { PresentationManager } from "./PresentationManager";
|
|
8
7
|
import { TemporaryStorage } from "./TemporaryStorage";
|
|
9
8
|
/** @internal */
|
|
@@ -16,14 +15,15 @@ export declare const MAX_ALLOWED_KEYS_PAGE_SIZE = 10000;
|
|
|
16
15
|
*
|
|
17
16
|
* @internal
|
|
18
17
|
*/
|
|
19
|
-
export declare class PresentationRpcImpl extends PresentationRpcInterface implements
|
|
18
|
+
export declare class PresentationRpcImpl extends PresentationRpcInterface implements Disposable {
|
|
20
19
|
private _requestTimeout;
|
|
21
20
|
private _pendingRequests;
|
|
22
21
|
private _cancelEvents;
|
|
22
|
+
private _statusHandler;
|
|
23
23
|
constructor(props?: {
|
|
24
24
|
requestTimeout?: number;
|
|
25
25
|
});
|
|
26
|
-
dispose(): void;
|
|
26
|
+
[Symbol.dispose](): void;
|
|
27
27
|
get requestTimeout(): number;
|
|
28
28
|
get pendingRequests(): TemporaryStorage<PresentationRpcResponse<any>>;
|
|
29
29
|
/** Returns an ok response with result inside */
|
|
@@ -37,10 +37,10 @@ export declare class PresentationRpcImpl extends PresentationRpcInterface implem
|
|
|
37
37
|
private getIModel;
|
|
38
38
|
private makeRequest;
|
|
39
39
|
getNodesCount(token: IModelRpcProps, requestOptions: HierarchyRpcRequestOptions): PresentationRpcResponse<number>;
|
|
40
|
-
getPagedNodes(token: IModelRpcProps, requestOptions: Paged<HierarchyRpcRequestOptions>): PresentationRpcResponse<PagedResponse<
|
|
40
|
+
getPagedNodes(token: IModelRpcProps, requestOptions: Paged<HierarchyRpcRequestOptions>): PresentationRpcResponse<PagedResponse<Node>>;
|
|
41
41
|
getNodesDescriptor(token: IModelRpcProps, requestOptions: HierarchyLevelDescriptorRpcRequestOptions): PresentationRpcResponse<string | DescriptorJSON | undefined>;
|
|
42
|
-
getNodePaths(token: IModelRpcProps, requestOptions: FilterByInstancePathsHierarchyRpcRequestOptions): PresentationRpcResponse<
|
|
43
|
-
getFilteredNodePaths(token: IModelRpcProps, requestOptions: FilterByTextHierarchyRpcRequestOptions): PresentationRpcResponse<
|
|
42
|
+
getNodePaths(token: IModelRpcProps, requestOptions: FilterByInstancePathsHierarchyRpcRequestOptions): PresentationRpcResponse<NodePathElement[]>;
|
|
43
|
+
getFilteredNodePaths(token: IModelRpcProps, requestOptions: FilterByTextHierarchyRpcRequestOptions): PresentationRpcResponse<NodePathElement[]>;
|
|
44
44
|
getContentSources(token: IModelRpcProps, requestOptions: ContentSourcesRpcRequestOptions): PresentationRpcResponse<ContentSourcesRpcResult>;
|
|
45
45
|
getContentDescriptor(token: IModelRpcProps, requestOptions: ContentDescriptorRpcRequestOptions): PresentationRpcResponse<DescriptorJSON | undefined>;
|
|
46
46
|
getContentSetSize(token: IModelRpcProps, requestOptions: ContentRpcRequestOptions): PresentationRpcResponse<number>;
|
|
@@ -50,7 +50,7 @@ export declare class PresentationRpcImpl extends PresentationRpcInterface implem
|
|
|
50
50
|
} | undefined>;
|
|
51
51
|
getPagedContentSet(token: IModelRpcProps, requestOptions: Paged<ContentRpcRequestOptions>): PresentationRpcResponse<PagedResponse<ItemJSON>>;
|
|
52
52
|
getElementProperties(token: IModelRpcProps, requestOptions: SingleElementPropertiesRpcRequestOptions): PresentationRpcResponse<ElementProperties | undefined>;
|
|
53
|
-
getPagedDistinctValues(token: IModelRpcProps, requestOptions: DistinctValuesRpcRequestOptions): PresentationRpcResponse<PagedResponse<
|
|
53
|
+
getPagedDistinctValues(token: IModelRpcProps, requestOptions: DistinctValuesRpcRequestOptions): PresentationRpcResponse<PagedResponse<DisplayValueGroup>>;
|
|
54
54
|
getContentInstanceKeys(token: IModelRpcProps, requestOptions: ContentInstanceKeysRpcRequestOptions): PresentationRpcResponse<{
|
|
55
55
|
total: number;
|
|
56
56
|
items: KeySetJSON;
|
|
@@ -58,6 +58,6 @@ export declare class PresentationRpcImpl extends PresentationRpcInterface implem
|
|
|
58
58
|
getDisplayLabelDefinition(token: IModelRpcProps, requestOptions: DisplayLabelRpcRequestOptions): PresentationRpcResponse<LabelDefinition>;
|
|
59
59
|
getPagedDisplayLabelDefinitions(token: IModelRpcProps, requestOptions: DisplayLabelsRpcRequestOptions): PresentationRpcResponse<PagedResponse<LabelDefinition>>;
|
|
60
60
|
getSelectionScopes(token: IModelRpcProps, requestOptions: SelectionScopeRpcRequestOptions): PresentationRpcResponse<SelectionScope[]>;
|
|
61
|
-
computeSelection(token: IModelRpcProps, requestOptions: ComputeSelectionRpcRequestOptions
|
|
61
|
+
computeSelection(token: IModelRpcProps, requestOptions: ComputeSelectionRpcRequestOptions): PresentationRpcResponse<KeySetJSON>;
|
|
62
62
|
}
|
|
63
63
|
//# sourceMappingURL=PresentationRpcImpl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationRpcImpl.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"PresentationRpcImpl.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,cAAc,EAAsB,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAGL,iCAAiC,EACjC,kCAAkC,EAElC,oCAAoC,EACpC,wBAAwB,EACxB,+BAA+B,EAC/B,uBAAuB,EAIvB,cAAc,EAEd,6BAA6B,EAC7B,8BAA8B,EAC9B,iBAAiB,EACjB,+BAA+B,EAC/B,iBAAiB,EACjB,+CAA+C,EAC/C,sCAAsC,EAEt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ACnD,uBAAuB,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,CAAC;IA+B1C,yBAAyB,CAC7C,KAAK,EAAE,cAAc,EACrB,cAAc,EAAE,6BAA6B,GAC5C,uBAAuB,CAAC,eAAe,CAAC;IAOrB,+BAA+B,CACnD,KAAK,EAAE,cAAc,EACrB,cAAc,EAAE,8BAA8B,GAC7C,uBAAuB,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;IAiBpC,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,iCAAiC,GAAG,uBAAuB,CAAC,UAAU,CAAC;CAOtJ"}
|
|
@@ -10,10 +10,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.PresentationRpcImpl = exports.MAX_ALLOWED_KEYS_PAGE_SIZE = exports.MAX_ALLOWED_PAGE_SIZE = void 0;
|
|
11
11
|
const core_backend_1 = require("@itwin/core-backend");
|
|
12
12
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
13
|
+
const core_common_1 = require("@itwin/core-common");
|
|
13
14
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
14
15
|
const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
|
|
15
16
|
const Presentation_1 = require("./Presentation");
|
|
16
17
|
const TemporaryStorage_1 = require("./TemporaryStorage");
|
|
18
|
+
const PresentationManagerDetail_1 = require("./PresentationManagerDetail");
|
|
17
19
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
18
20
|
const packageJsonVersion = require("../../../package.json").version;
|
|
19
21
|
/** @internal */
|
|
@@ -28,6 +30,10 @@ const DEFAULT_REQUEST_TIMEOUT = 5000;
|
|
|
28
30
|
* @internal
|
|
29
31
|
*/
|
|
30
32
|
class PresentationRpcImpl extends presentation_common_1.PresentationRpcInterface {
|
|
33
|
+
_requestTimeout;
|
|
34
|
+
_pendingRequests;
|
|
35
|
+
_cancelEvents;
|
|
36
|
+
_statusHandler;
|
|
31
37
|
constructor(props) {
|
|
32
38
|
super();
|
|
33
39
|
this._requestTimeout = props?.requestTimeout ?? DEFAULT_REQUEST_TIMEOUT;
|
|
@@ -47,9 +53,12 @@ class PresentationRpcImpl extends presentation_common_1.PresentationRpcInterface
|
|
|
47
53
|
},
|
|
48
54
|
});
|
|
49
55
|
this._cancelEvents = new Map();
|
|
56
|
+
this._statusHandler = createStatusCategoryHandler();
|
|
57
|
+
core_bentley_1.StatusCategory.handlers.add(this._statusHandler);
|
|
50
58
|
}
|
|
51
|
-
dispose() {
|
|
52
|
-
this._pendingRequests.dispose();
|
|
59
|
+
[Symbol.dispose]() {
|
|
60
|
+
this._pendingRequests[Symbol.dispose]();
|
|
61
|
+
core_bentley_1.StatusCategory.handlers.delete(this._statusHandler);
|
|
53
62
|
}
|
|
54
63
|
get requestTimeout() {
|
|
55
64
|
return this._requestTimeout;
|
|
@@ -81,28 +90,19 @@ class PresentationRpcImpl extends presentation_common_1.PresentationRpcInterface
|
|
|
81
90
|
return Presentation_1.Presentation.getManager(clientId);
|
|
82
91
|
}
|
|
83
92
|
async getIModel(token) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// call refreshContainer, just in case this is a V2 checkpoint whose sasToken is about to expire, or its default transaction is about to be restarted.
|
|
88
|
-
await imodel.refreshContainerForRpc(core_backend_1.RpcTrace.expectCurrentActivity.accessToken);
|
|
89
|
-
}
|
|
90
|
-
catch {
|
|
91
|
-
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "IModelRpcProps doesn't point to a valid iModel");
|
|
92
|
-
}
|
|
93
|
+
const imodel = core_backend_1.IModelDb.findByKey(token.key);
|
|
94
|
+
// call refreshContainer, just in case this is a V2 checkpoint whose sasToken is about to expire, or its default transaction is about to be restarted.
|
|
95
|
+
await imodel.refreshContainerForRpc(core_backend_1.RpcTrace.expectCurrentActivity.accessToken);
|
|
93
96
|
return imodel;
|
|
94
97
|
}
|
|
95
98
|
async makeRequest(token, requestId, requestOptions, request) {
|
|
99
|
+
const serializedRequestOptionsForLogging = JSON.stringify({
|
|
100
|
+
...(0, core_bentley_1.omit)(requestOptions, ["rulesetOrId"]),
|
|
101
|
+
...(requestOptions.rulesetOrId ? { rulesetId: (0, PresentationManagerDetail_1.getRulesetIdObject)(requestOptions.rulesetOrId).uniqueId } : undefined),
|
|
102
|
+
});
|
|
103
|
+
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.PresentationBackendLoggerCategory.Rpc, `Received '${requestId}' request. Params: ${serializedRequestOptionsForLogging}`);
|
|
104
|
+
const imodel = await this.getIModel(token);
|
|
96
105
|
const requestKey = JSON.stringify({ iModelKey: token.key, requestId, requestOptions });
|
|
97
|
-
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.PresentationBackendLoggerCategory.Rpc, `Received '${requestId}' request. Params: ${requestKey}`);
|
|
98
|
-
let imodel;
|
|
99
|
-
try {
|
|
100
|
-
imodel = await this.getIModel(token);
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
(0, core_bentley_1.assert)(e instanceof Error);
|
|
104
|
-
return this.errorResponse(presentation_common_1.PresentationStatus.InvalidArgument, e.message);
|
|
105
|
-
}
|
|
106
106
|
let resultPromise = this._pendingRequests.getValue(requestKey);
|
|
107
107
|
if (resultPromise) {
|
|
108
108
|
core_bentley_1.Logger.logTrace(BackendLoggerCategory_1.PresentationBackendLoggerCategory.Rpc, `Request already pending`);
|
|
@@ -147,9 +147,7 @@ class PresentationRpcImpl extends presentation_common_1.PresentationRpcInterface
|
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
149
|
// initiate request
|
|
150
|
-
resultPromise = request(managerRequestOptions)
|
|
151
|
-
.then((result) => this.successResponse(result, diagnostics))
|
|
152
|
-
.catch((e) => this.errorResponse(e.errorNumber, e.message, diagnostics));
|
|
150
|
+
resultPromise = request(managerRequestOptions).then((result) => this.successResponse(result, diagnostics));
|
|
153
151
|
// store the request promise
|
|
154
152
|
this._pendingRequests.addValue(requestKey, resultPromise);
|
|
155
153
|
this._cancelEvents.set(requestKey, managerRequestOptions.cancelEvent);
|
|
@@ -161,77 +159,56 @@ class PresentationRpcImpl extends presentation_common_1.PresentationRpcInterface
|
|
|
161
159
|
});
|
|
162
160
|
return resultPromise;
|
|
163
161
|
}
|
|
164
|
-
let timeout;
|
|
165
|
-
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
166
|
-
timeout = setTimeout(() => {
|
|
167
|
-
reject(new Error());
|
|
168
|
-
}, this._requestTimeout);
|
|
169
|
-
});
|
|
170
162
|
core_bentley_1.Logger.logTrace(BackendLoggerCategory_1.PresentationBackendLoggerCategory.Rpc, `Returning a promise with a timeout of ${this._requestTimeout}.`);
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
163
|
+
const timeout = (0, presentation_common_1.createCancellableTimeoutPromise)(this._requestTimeout);
|
|
164
|
+
return Promise.race([
|
|
165
|
+
resultPromise,
|
|
166
|
+
timeout.promise.then(() => {
|
|
167
|
+
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
168
|
+
throw new core_common_1.RpcPendingResponse("Timeout");
|
|
169
|
+
}),
|
|
170
|
+
])
|
|
178
171
|
.then((response) => {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
this._pendingRequests.deleteValue(requestKey);
|
|
182
|
-
}
|
|
183
|
-
clearTimeout(timeout);
|
|
172
|
+
core_bentley_1.Logger.logTrace(BackendLoggerCategory_1.PresentationBackendLoggerCategory.Rpc, `Request completed, returning result.`);
|
|
173
|
+
this._pendingRequests.deleteValue(requestKey);
|
|
184
174
|
return response;
|
|
175
|
+
})
|
|
176
|
+
.finally(() => {
|
|
177
|
+
timeout.cancel();
|
|
185
178
|
});
|
|
186
179
|
}
|
|
187
180
|
async getNodesCount(token, requestOptions) {
|
|
188
181
|
return this.makeRequest(token, "getNodesCount", requestOptions, async (options) => {
|
|
189
|
-
options = {
|
|
190
|
-
...options,
|
|
191
|
-
parentKey: nodeKeyFromJson(options.parentKey),
|
|
192
|
-
};
|
|
193
182
|
return this.getManager(requestOptions.clientId).getNodesCount(options);
|
|
194
183
|
});
|
|
195
184
|
}
|
|
196
185
|
async getPagedNodes(token, requestOptions) {
|
|
197
186
|
return this.makeRequest(token, "getPagedNodes", requestOptions, async (options) => {
|
|
198
|
-
options = enforceValidPageSize(
|
|
199
|
-
|
|
200
|
-
parentKey: nodeKeyFromJson(options.parentKey),
|
|
201
|
-
});
|
|
202
|
-
const [serializedNodesJson, count] = await Promise.all([
|
|
187
|
+
options = enforceValidPageSize(options);
|
|
188
|
+
const [serializedHierarchyLevel, count] = await Promise.all([
|
|
203
189
|
this.getManager(requestOptions.clientId).getDetail().getNodes(options),
|
|
204
190
|
this.getManager(requestOptions.clientId).getNodesCount(options),
|
|
205
191
|
]);
|
|
206
|
-
|
|
207
|
-
const nodesJson = JSON.parse(serializedNodesJson);
|
|
192
|
+
const hierarchyLevel = (0, presentation_common_1.deepReplaceNullsToUndefined)(JSON.parse(serializedHierarchyLevel));
|
|
208
193
|
return {
|
|
209
194
|
total: count,
|
|
210
|
-
items:
|
|
195
|
+
items: hierarchyLevel.nodes,
|
|
211
196
|
};
|
|
212
197
|
});
|
|
213
198
|
}
|
|
214
199
|
async getNodesDescriptor(token, requestOptions) {
|
|
215
200
|
return this.makeRequest(token, "getNodesDescriptor", requestOptions, async (options) => {
|
|
216
|
-
options = {
|
|
217
|
-
...options,
|
|
218
|
-
parentKey: nodeKeyFromJson(options.parentKey),
|
|
219
|
-
};
|
|
220
201
|
return this.getManager(requestOptions.clientId).getDetail().getNodesDescriptor(options);
|
|
221
202
|
});
|
|
222
203
|
}
|
|
223
204
|
async getNodePaths(token, requestOptions) {
|
|
224
205
|
return this.makeRequest(token, "getNodePaths", requestOptions, async (options) => {
|
|
225
|
-
|
|
226
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
227
|
-
return result.map(presentation_common_1.NodePathElement.toJSON);
|
|
206
|
+
return this.getManager(requestOptions.clientId).getDetail().getNodePaths(options);
|
|
228
207
|
});
|
|
229
208
|
}
|
|
230
209
|
async getFilteredNodePaths(token, requestOptions) {
|
|
231
210
|
return this.makeRequest(token, "getFilteredNodePaths", requestOptions, async (options) => {
|
|
232
|
-
|
|
233
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
234
|
-
return result.map(presentation_common_1.NodePathElement.toJSON);
|
|
211
|
+
return this.getManager(requestOptions.clientId).getDetail().getFilteredNodePaths(options);
|
|
235
212
|
});
|
|
236
213
|
}
|
|
237
214
|
async getContentSources(token, requestOptions) {
|
|
@@ -331,12 +308,7 @@ class PresentationRpcImpl extends presentation_common_1.PresentationRpcInterface
|
|
|
331
308
|
...options,
|
|
332
309
|
keys: presentation_common_1.KeySet.fromJSON(options.keys),
|
|
333
310
|
});
|
|
334
|
-
|
|
335
|
-
return {
|
|
336
|
-
...response,
|
|
337
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
338
|
-
items: response.items.map(presentation_common_1.DisplayValueGroup.toJSON),
|
|
339
|
-
};
|
|
311
|
+
return this.getManager(requestOptions.clientId).getDetail().getPagedDistinctValues(options);
|
|
340
312
|
});
|
|
341
313
|
}
|
|
342
314
|
async getContentInstanceKeys(token, requestOptions) {
|
|
@@ -384,18 +356,12 @@ class PresentationRpcImpl extends presentation_common_1.PresentationRpcInterface
|
|
|
384
356
|
};
|
|
385
357
|
});
|
|
386
358
|
}
|
|
359
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
387
360
|
async getSelectionScopes(token, requestOptions) {
|
|
388
361
|
return this.makeRequest(token, "getSelectionScopes", requestOptions, async (options) => this.getManager(requestOptions.clientId).getSelectionScopes(options));
|
|
389
362
|
}
|
|
390
|
-
async computeSelection(token, requestOptions
|
|
363
|
+
async computeSelection(token, requestOptions) {
|
|
391
364
|
return this.makeRequest(token, "computeSelection", requestOptions, async (options) => {
|
|
392
|
-
if (!(0, presentation_common_1.isComputeSelectionRequestOptions)(options)) {
|
|
393
|
-
options = {
|
|
394
|
-
...options,
|
|
395
|
-
elementIds: ids,
|
|
396
|
-
scope: { id: scopeId },
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
365
|
const keys = await this.getManager(requestOptions.clientId).computeSelection(options);
|
|
400
366
|
return keys.toJSON();
|
|
401
367
|
});
|
|
@@ -413,12 +379,36 @@ const getValidPageSize = (size, maxPageSize) => {
|
|
|
413
379
|
const requestedSize = size ?? 0;
|
|
414
380
|
return requestedSize === 0 || requestedSize > maxPageSize ? maxPageSize : requestedSize;
|
|
415
381
|
};
|
|
416
|
-
//
|
|
417
|
-
|
|
418
|
-
|
|
382
|
+
// not testing temporary solution
|
|
383
|
+
// istanbul ignore next
|
|
384
|
+
function createStatusCategoryHandler() {
|
|
385
|
+
return (e) => {
|
|
386
|
+
if (e instanceof presentation_common_1.PresentationError) {
|
|
387
|
+
switch (e.errorNumber) {
|
|
388
|
+
case presentation_common_1.PresentationStatus.NotInitialized:
|
|
389
|
+
return new (class extends core_bentley_1.ErrorCategory {
|
|
390
|
+
name = "Internal server error";
|
|
391
|
+
code = 500;
|
|
392
|
+
})();
|
|
393
|
+
case presentation_common_1.PresentationStatus.Canceled:
|
|
394
|
+
return new (class extends core_bentley_1.SuccessCategory {
|
|
395
|
+
name = "Cancelled";
|
|
396
|
+
code = 204;
|
|
397
|
+
})();
|
|
398
|
+
case presentation_common_1.PresentationStatus.ResultSetTooLarge:
|
|
399
|
+
return new (class extends core_bentley_1.ErrorCategory {
|
|
400
|
+
name = "Result set is too large";
|
|
401
|
+
code = 413;
|
|
402
|
+
})();
|
|
403
|
+
case presentation_common_1.PresentationStatus.Error:
|
|
404
|
+
case presentation_common_1.PresentationStatus.InvalidArgument:
|
|
405
|
+
return new (class extends core_bentley_1.ErrorCategory {
|
|
406
|
+
name = "Invalid request props";
|
|
407
|
+
code = 422;
|
|
408
|
+
})();
|
|
409
|
+
}
|
|
410
|
+
}
|
|
419
411
|
return undefined;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
return presentation_common_1.NodeKey.fromJSON(json);
|
|
423
|
-
};
|
|
412
|
+
};
|
|
413
|
+
}
|
|
424
414
|
//# sourceMappingURL=PresentationRpcImpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationRpcImpl.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAyD;AACzD,sDAAuF;AAEvF,oEAmDoC;AACpC,mEAA4E;AAC5E,iDAA8C;AAE9C,yDAAsD;AAEtD,iEAAiE;AACjE,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,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC;;;;;GAKG;AACH,MAAa,mBAAoB,SAAQ,8CAAwB;IAK/D,YAAmB,KAAmC;QACpD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,eAAe,GAAG,KAAK,EAAE,cAAc,IAAI,uBAAuB,CAAC;QACxE,IAAI,CAAC,gBAAgB,GAAG,IAAI,mCAAgB,CAAC;YAC3C,6EAA6E;YAC7E,qFAAqF;YACrF,mBAAmB,EAAE,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS;YAE5F,mCAAmC;YACnC,eAAe,EAAE,IAAI;YAErB,cAAc,EAA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CACF;AAvdD,kDAudC;AAED,MAAM,oBAAoB,GAAG,CAC3B,cAAwB,EACxB,WAAW,GAAG,6BAAqB,EACC,EAAE;IACtC,MAAM,aAAa,GAAG,gBAAgB,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;IACjF,IAAI,CAAC,cAAc,CAAC,MAAM,IAAI,cAAc,CAAC,MAAM,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QAC3E,OAAO,EAAE,GAAG,cAAc,EAAE,MAAM,EAAE,EAAE,GAAG,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,CAAC;IAC1F,CAAC;IACD,OAAO,cAAoD,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,IAAwB,EAAE,WAAmB,EAAE,EAAE;IACzE,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,CAAC;IAChC,OAAO,aAAa,KAAK,CAAC,IAAI,aAAa,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC;AAC1F,CAAC,CAAC;AAEF,4DAA4D;AAC5D,MAAM,eAAe,GAAG,CAAC,IAA6B,EAAuB,EAAE;IAC7E,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,4DAA4D;IAC5D,OAAO,6BAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RPC\n */\n\nimport { IModelDb, RpcTrace } from \"@itwin/core-backend\";\nimport { assert, BeEvent, Id64String, IDisposable, Logger } from \"@itwin/core-bentley\";\nimport { IModelRpcProps } from \"@itwin/core-common\";\nimport {\n buildElementProperties,\n ClientDiagnostics,\n ComputeSelectionRequestOptions,\n ComputeSelectionRpcRequestOptions,\n ContentDescriptorRpcRequestOptions,\n ContentFlags,\n ContentInstanceKeysRpcRequestOptions,\n ContentRpcRequestOptions,\n ContentSourcesRpcRequestOptions,\n ContentSourcesRpcResult,\n DefaultContentDisplayTypes,\n DescriptorJSON,\n Diagnostics,\n DisplayLabelRpcRequestOptions,\n DisplayLabelsRpcRequestOptions,\n DisplayValueGroup,\n DisplayValueGroupJSON,\n DistinctValuesRpcRequestOptions,\n ElementProperties,\n FilterByInstancePathsHierarchyRpcRequestOptions,\n FilterByTextHierarchyRpcRequestOptions,\n HierarchyLevelDescriptorRpcRequestOptions,\n HierarchyLevelJSON,\n HierarchyRpcRequestOptions,\n isComputeSelectionRequestOptions,\n ItemJSON,\n KeySet,\n KeySetJSON,\n LabelDefinition,\n NodeJSON,\n NodeKey,\n NodeKeyJSON,\n NodePathElement,\n NodePathElementJSON,\n Paged,\n PagedResponse,\n PageOptions,\n PresentationError,\n PresentationRpcInterface,\n PresentationRpcResponse,\n PresentationRpcResponseData,\n PresentationStatus,\n RpcDiagnosticsOptions,\n Ruleset,\n RulesetVariable,\n RulesetVariableJSON,\n SelectClassInfo,\n SelectionScope,\n SelectionScopeRpcRequestOptions,\n SingleElementPropertiesRpcRequestOptions,\n} from \"@itwin/presentation-common\";\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { Presentation } from \"./Presentation\";\nimport { PresentationManager } from \"./PresentationManager\";\nimport { TemporaryStorage } from \"./TemporaryStorage\";\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst packageJsonVersion = require(\"../../../package.json\").version;\n\ntype ContentGetter<TResult = any, TOptions = any> = (requestOptions: TOptions) => TResult;\n\n/** @internal */\nexport const MAX_ALLOWED_PAGE_SIZE = 1000;\n/** @internal */\nexport const MAX_ALLOWED_KEYS_PAGE_SIZE = 10000;\n\nconst DEFAULT_REQUEST_TIMEOUT = 5000;\n\n/**\n * The backend implementation of PresentationRpcInterface. All it's basically\n * responsible for is forwarding calls to [[Presentation.manager]].\n *\n * @internal\n */\nexport class PresentationRpcImpl extends PresentationRpcInterface implements IDisposable {\n private _requestTimeout: number;\n private _pendingRequests: TemporaryStorage<PresentationRpcResponse<any>>;\n private _cancelEvents: Map<string, BeEvent<() => void>>;\n\n public constructor(props?: { requestTimeout?: number }) {\n super();\n this._requestTimeout = props?.requestTimeout ?? DEFAULT_REQUEST_TIMEOUT;\n this._pendingRequests = new TemporaryStorage({\n // remove the pending request after request timeout + 10 seconds - this gives\n // frontend 10 seconds to re-send the request until it's removed from requests' cache\n unusedValueLifetime: this._requestTimeout > 0 ? this._requestTimeout + 10 * 1000 : undefined,\n\n // attempt to clean up every second\n cleanupInterval: 1000,\n\n cleanupHandler: (id, _, reason) => {\n if (reason !== \"request\") {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Cleaning up request without frontend retrieving it: ${id}.`);\n // istanbul ignore next\n this._cancelEvents.get(id)?.raiseEvent();\n }\n this._cancelEvents.delete(id);\n },\n });\n this._cancelEvents = new Map<string, BeEvent<() => void>>();\n }\n\n public dispose() {\n this._pendingRequests.dispose();\n }\n\n public get requestTimeout() {\n return this._requestTimeout;\n }\n\n public get pendingRequests() {\n return this._pendingRequests;\n }\n\n /** Returns an ok response with result inside */\n private successResponse<TResult>(result: TResult, diagnostics?: ClientDiagnostics) {\n return {\n statusCode: PresentationStatus.Success,\n result,\n diagnostics,\n };\n }\n\n /** Returns a bad request response with empty result and an error code */\n private errorResponse(errorCode: PresentationStatus, errorMessage?: string, diagnostics?: ClientDiagnostics) {\n return {\n statusCode: errorCode,\n result: undefined,\n errorMessage,\n diagnostics,\n };\n }\n\n /**\n * Get the [[PresentationManager]] used by this RPC impl.\n */\n public getManager(clientId?: string): PresentationManager {\n return Presentation.getManager(clientId);\n }\n\n private async getIModel(token: IModelRpcProps): Promise<IModelDb> {\n let imodel: IModelDb;\n try {\n imodel = IModelDb.findByKey(token.key);\n // call refreshContainer, just in case this is a V2 checkpoint whose sasToken is about to expire, or its default transaction is about to be restarted.\n await imodel.refreshContainerForRpc(RpcTrace.expectCurrentActivity.accessToken);\n } catch {\n throw new PresentationError(PresentationStatus.InvalidArgument, \"IModelRpcProps doesn't point to a valid iModel\");\n }\n return imodel;\n }\n\n private async makeRequest<\n TRpcOptions extends { rulesetOrId?: Ruleset | string; clientId?: string; diagnostics?: RpcDiagnosticsOptions; rulesetVariables?: RulesetVariableJSON[] },\n TResult,\n >(token: IModelRpcProps, requestId: string, requestOptions: TRpcOptions, request: ContentGetter<Promise<TResult>>): PresentationRpcResponse<TResult> {\n const requestKey = JSON.stringify({ iModelKey: token.key, requestId, requestOptions });\n\n Logger.logInfo(PresentationBackendLoggerCategory.Rpc, `Received '${requestId}' request. Params: ${requestKey}`);\n\n let imodel: IModelDb;\n try {\n imodel = await this.getIModel(token);\n } catch (e) {\n assert(e instanceof Error);\n return this.errorResponse(PresentationStatus.InvalidArgument, e.message);\n }\n\n let resultPromise = this._pendingRequests.getValue(requestKey);\n if (resultPromise) {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request already pending`);\n } else {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request not found, creating a new one`);\n const { clientId: _, diagnostics: diagnosticsOptions, rulesetVariables, ...options } = requestOptions;\n const managerRequestOptions: any = {\n ...options,\n imodel,\n cancelEvent: new BeEvent<() => void>(),\n };\n\n // set up ruleset variables\n if (rulesetVariables) {\n managerRequestOptions.rulesetVariables = rulesetVariables.map(RulesetVariable.fromJSON);\n }\n\n // set up diagnostics listener\n let diagnostics: ClientDiagnostics | undefined;\n const getDiagnostics = (): ClientDiagnostics => {\n if (!diagnostics) {\n diagnostics = {};\n }\n return diagnostics;\n };\n if (diagnosticsOptions) {\n if (diagnosticsOptions.backendVersion) {\n getDiagnostics().backendVersion = packageJsonVersion;\n }\n managerRequestOptions.diagnostics = {\n ...diagnosticsOptions,\n handler: (d: Diagnostics) => {\n if (d.logs) {\n const target = getDiagnostics();\n if (target.logs) {\n target.logs.push(...d.logs);\n } else {\n target.logs = [...d.logs];\n }\n }\n },\n };\n }\n\n // initiate request\n resultPromise = request(managerRequestOptions)\n .then((result) => this.successResponse(result, diagnostics))\n .catch((e: PresentationError) => this.errorResponse(e.errorNumber, e.message, diagnostics));\n\n // store the request promise\n this._pendingRequests.addValue(requestKey, resultPromise);\n this._cancelEvents.set(requestKey, managerRequestOptions.cancelEvent);\n }\n\n if (this._requestTimeout === 0) {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout not configured, returning promise without a timeout.`);\n void resultPromise.finally(() => {\n this._pendingRequests.deleteValue(requestKey);\n });\n return resultPromise;\n }\n\n let timeout: NodeJS.Timeout;\n const timeoutPromise = new Promise<any>((_resolve, reject) => {\n timeout = setTimeout(() => {\n reject(new Error());\n }, this._requestTimeout);\n });\n\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Returning a promise with a timeout of ${this._requestTimeout}.`);\n return Promise.race([resultPromise, timeoutPromise])\n .catch<PresentationRpcResponseData>(() => {\n // note: error responses from the manager get handled when creating `resultPromise`, so we can only get here due\n // to a timeout exception\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout, returning \"BackendTimeout\" status.`);\n return this.errorResponse(PresentationStatus.BackendTimeout);\n })\n .then((response: PresentationRpcResponseData<TResult>) => {\n if (response.statusCode !== PresentationStatus.BackendTimeout) {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request completed, returning result.`);\n this._pendingRequests.deleteValue(requestKey);\n }\n clearTimeout(timeout);\n return response;\n });\n }\n\n public override async getNodesCount(token: IModelRpcProps, requestOptions: HierarchyRpcRequestOptions): PresentationRpcResponse<number> {\n return this.makeRequest(token, \"getNodesCount\", requestOptions, async (options) => {\n options = {\n ...options,\n parentKey: nodeKeyFromJson(options.parentKey),\n };\n return this.getManager(requestOptions.clientId).getNodesCount(options);\n });\n }\n\n public override async getPagedNodes(\n token: IModelRpcProps,\n requestOptions: Paged<HierarchyRpcRequestOptions>,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ): PresentationRpcResponse<PagedResponse<NodeJSON>> {\n return this.makeRequest(token, \"getPagedNodes\", requestOptions, async (options) => {\n options = enforceValidPageSize({\n ...options,\n parentKey: nodeKeyFromJson(options.parentKey),\n });\n const [serializedNodesJson, count] = await Promise.all([\n this.getManager(requestOptions.clientId).getDetail().getNodes(options),\n this.getManager(requestOptions.clientId).getNodesCount(options),\n ]);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const nodesJson = JSON.parse(serializedNodesJson) as HierarchyLevelJSON;\n return {\n total: count,\n items: nodesJson.nodes,\n };\n });\n }\n\n public override async getNodesDescriptor(\n token: IModelRpcProps,\n requestOptions: HierarchyLevelDescriptorRpcRequestOptions,\n ): PresentationRpcResponse<string | DescriptorJSON | undefined> {\n return this.makeRequest(token, \"getNodesDescriptor\", requestOptions, async (options) => {\n options = {\n ...options,\n parentKey: nodeKeyFromJson(options.parentKey),\n };\n return this.getManager(requestOptions.clientId).getDetail().getNodesDescriptor(options);\n });\n }\n\n public override async getNodePaths(\n token: IModelRpcProps,\n requestOptions: FilterByInstancePathsHierarchyRpcRequestOptions,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ): PresentationRpcResponse<NodePathElementJSON[]> {\n return this.makeRequest(token, \"getNodePaths\", requestOptions, async (options) => {\n const result = await this.getManager(requestOptions.clientId).getDetail().getNodePaths(options);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return result.map(NodePathElement.toJSON);\n });\n }\n\n public override async getFilteredNodePaths(\n token: IModelRpcProps,\n requestOptions: FilterByTextHierarchyRpcRequestOptions,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ): PresentationRpcResponse<NodePathElementJSON[]> {\n return this.makeRequest(token, \"getFilteredNodePaths\", requestOptions, async (options) => {\n const result = await this.getManager(requestOptions.clientId).getDetail().getFilteredNodePaths(options);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return result.map(NodePathElement.toJSON);\n });\n }\n\n public override async getContentSources(\n token: IModelRpcProps,\n requestOptions: ContentSourcesRpcRequestOptions,\n ): PresentationRpcResponse<ContentSourcesRpcResult> {\n return this.makeRequest(token, \"getContentSources\", requestOptions, async (options) => {\n const result = await this.getManager(requestOptions.clientId).getContentSources(options);\n const classesMap = {};\n const selectClasses = result.map((sci) => SelectClassInfo.toCompressedJSON(sci, classesMap));\n return { sources: selectClasses, classesMap };\n });\n }\n\n public override async getContentDescriptor(\n token: IModelRpcProps,\n requestOptions: ContentDescriptorRpcRequestOptions,\n ): PresentationRpcResponse<DescriptorJSON | undefined> {\n return this.makeRequest(token, \"getContentDescriptor\", requestOptions, async (options) => {\n options = {\n ...options,\n contentFlags: (options.contentFlags ?? 0) | ContentFlags.DescriptorOnly, // always append the \"descriptor only\" flag when handling request from the frontend\n keys: KeySet.fromJSON(options.keys),\n };\n if (options.transport === \"unparsed-json\") {\n // Here we send a plain JSON string but we will parse it to DescriptorJSON on the frontend. This way we are\n // bypassing unnecessary deserialization and serialization.\n return Presentation.getManager(requestOptions.clientId).getDetail().getContentDescriptor(options) as unknown as DescriptorJSON | undefined;\n } else {\n // Support for older frontends that still expect a parsed descriptor\n const descriptor = await Presentation.getManager(requestOptions.clientId).getContentDescriptor(options);\n return descriptor?.toJSON();\n }\n });\n }\n\n public override async getContentSetSize(token: IModelRpcProps, requestOptions: ContentRpcRequestOptions): PresentationRpcResponse<number> {\n return this.makeRequest(token, \"getContentSetSize\", requestOptions, async (options) => {\n options = {\n ...options,\n keys: KeySet.fromJSON(options.keys),\n };\n return this.getManager(requestOptions.clientId).getContentSetSize(options);\n });\n }\n\n public override async getPagedContent(\n token: IModelRpcProps,\n requestOptions: Paged<ContentRpcRequestOptions>,\n ): PresentationRpcResponse<{ descriptor: DescriptorJSON; contentSet: PagedResponse<ItemJSON> } | undefined> {\n return this.makeRequest(token, \"getPagedContent\", requestOptions, async (options) => {\n options = enforceValidPageSize({\n ...options,\n keys: KeySet.fromJSON(options.keys),\n });\n\n const [size, content] = await Promise.all([\n this.getManager(requestOptions.clientId).getContentSetSize(options),\n this.getManager(requestOptions.clientId).getDetail().getContent(options),\n ]);\n\n if (!content) {\n return undefined;\n }\n\n return {\n descriptor: content.descriptor.toJSON(),\n contentSet: {\n total: size,\n items: content.contentSet.map((i) => i.toJSON()),\n },\n };\n });\n }\n\n public override async getPagedContentSet(\n token: IModelRpcProps,\n requestOptions: Paged<ContentRpcRequestOptions>,\n ): PresentationRpcResponse<PagedResponse<ItemJSON>> {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const response = await this.getPagedContent(token, requestOptions);\n if (response.statusCode !== PresentationStatus.Success) {\n return this.errorResponse(response.statusCode, response.errorMessage, response.diagnostics);\n }\n if (!response.result) {\n return this.errorResponse(PresentationStatus.Error, `Failed to get content set (received a success response with empty result)`, response.diagnostics);\n }\n return {\n ...response,\n result: response.result.contentSet,\n };\n }\n\n public override async getElementProperties(\n token: IModelRpcProps,\n requestOptions: SingleElementPropertiesRpcRequestOptions,\n ): PresentationRpcResponse<ElementProperties | undefined> {\n return this.makeRequest(token, \"getElementProperties\", { ...requestOptions }, async (options) => {\n const manager = this.getManager(requestOptions.clientId);\n const { elementId, ...optionsNoElementId } = options;\n const content = await manager.getDetail().getContent({\n ...optionsNoElementId,\n descriptor: {\n displayType: DefaultContentDisplayTypes.PropertyPane,\n contentFlags: ContentFlags.ShowLabels,\n },\n rulesetOrId: \"ElementProperties\",\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\n });\n if (!content || content.contentSet.length === 0) {\n return undefined;\n }\n return buildElementProperties(content.descriptor, content.contentSet[0]);\n });\n }\n\n public override async getPagedDistinctValues(\n token: IModelRpcProps,\n requestOptions: DistinctValuesRpcRequestOptions,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ): PresentationRpcResponse<PagedResponse<DisplayValueGroupJSON>> {\n return this.makeRequest(token, \"getPagedDistinctValues\", requestOptions, async (options) => {\n options = enforceValidPageSize({\n ...options,\n keys: KeySet.fromJSON(options.keys),\n });\n const response = await this.getManager(requestOptions.clientId).getDetail().getPagedDistinctValues(options);\n return {\n ...response,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n items: response.items.map(DisplayValueGroup.toJSON),\n };\n });\n }\n\n public override async getContentInstanceKeys(\n token: IModelRpcProps,\n requestOptions: ContentInstanceKeysRpcRequestOptions,\n ): PresentationRpcResponse<{ total: number; items: KeySetJSON }> {\n return this.makeRequest(token, \"getContentInstanceKeys\", requestOptions, async (options) => {\n const { displayType, ...optionsNoDisplayType } = options;\n options = enforceValidPageSize(\n {\n ...optionsNoDisplayType,\n keys: KeySet.fromJSON(optionsNoDisplayType.keys),\n descriptor: {\n displayType,\n contentFlags: ContentFlags.KeysOnly,\n },\n },\n MAX_ALLOWED_KEYS_PAGE_SIZE,\n );\n\n const [size, content] = await Promise.all([\n this.getManager(requestOptions.clientId).getContentSetSize(options),\n this.getManager(requestOptions.clientId).getDetail().getContent(options),\n ]);\n\n if (size === 0 || !content) {\n return { total: 0, items: new KeySet().toJSON() };\n }\n\n return {\n total: size,\n items: content.contentSet.reduce((keys, item) => keys.add(item.primaryKeys), new KeySet()).toJSON(),\n };\n });\n }\n\n public override async getDisplayLabelDefinition(\n token: IModelRpcProps,\n requestOptions: DisplayLabelRpcRequestOptions,\n ): PresentationRpcResponse<LabelDefinition> {\n return this.makeRequest(token, \"getDisplayLabelDefinition\", requestOptions, async (options) => {\n const label = await this.getManager(requestOptions.clientId).getDetail().getDisplayLabelDefinition(options);\n return label;\n });\n }\n\n public override async getPagedDisplayLabelDefinitions(\n token: IModelRpcProps,\n requestOptions: DisplayLabelsRpcRequestOptions,\n ): PresentationRpcResponse<PagedResponse<LabelDefinition>> {\n const pageOpts = enforceValidPageSize({ paging: { start: 0, size: requestOptions.keys.length } });\n if (pageOpts.paging.size < requestOptions.keys.length) {\n requestOptions.keys.splice(pageOpts.paging.size);\n }\n return this.makeRequest(token, \"getPagedDisplayLabelDefinitions\", requestOptions, async (options) => {\n const labels = await this.getManager(requestOptions.clientId)\n .getDetail()\n .getDisplayLabelDefinitions({ ...options, keys: options.keys });\n return {\n total: options.keys.length,\n items: labels,\n };\n });\n }\n\n public override async getSelectionScopes(token: IModelRpcProps, requestOptions: SelectionScopeRpcRequestOptions): PresentationRpcResponse<SelectionScope[]> {\n return this.makeRequest(token, \"getSelectionScopes\", requestOptions, async (options) =>\n this.getManager(requestOptions.clientId).getSelectionScopes(options),\n );\n }\n\n public override async computeSelection(\n token: IModelRpcProps,\n requestOptions: ComputeSelectionRpcRequestOptions | SelectionScopeRpcRequestOptions,\n ids?: Id64String[],\n scopeId?: string,\n ): PresentationRpcResponse<KeySetJSON> {\n return this.makeRequest(token, \"computeSelection\", requestOptions, async (options) => {\n if (!isComputeSelectionRequestOptions(options)) {\n options = {\n ...options,\n elementIds: ids!,\n scope: { id: scopeId! },\n };\n }\n const keys = await this.getManager(requestOptions.clientId).computeSelection(options as ComputeSelectionRequestOptions<IModelDb>);\n return keys.toJSON();\n });\n }\n}\n\nconst enforceValidPageSize = <TOptions extends Paged<object>>(\n requestOptions: TOptions,\n maxPageSize = MAX_ALLOWED_PAGE_SIZE,\n): TOptions & { paging: PageOptions } => {\n const validPageSize = getValidPageSize(requestOptions.paging?.size, maxPageSize);\n if (!requestOptions.paging || requestOptions.paging.size !== validPageSize) {\n return { ...requestOptions, paging: { ...requestOptions.paging, size: validPageSize } };\n }\n return requestOptions as TOptions & { paging: PageOptions };\n};\n\nconst getValidPageSize = (size: number | undefined, maxPageSize: number) => {\n const requestedSize = size ?? 0;\n return requestedSize === 0 || requestedSize > maxPageSize ? maxPageSize : requestedSize;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nconst nodeKeyFromJson = (json: NodeKeyJSON | undefined): NodeKey | undefined => {\n if (!json) {\n return undefined;\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return NodeKey.fromJSON(json);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"PresentationRpcImpl.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAyD;AACzD,sDAA4G;AAC5G,oDAAwE;AACxE,oEA+CoC;AACpC,mEAA4E;AAC5E,iDAA8C;AAE9C,yDAAsD;AACtD,2EAAiE;AAEjE,iEAAiE;AACjE,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,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC;;;;;GAKG;AACH,MAAa,mBAAoB,SAAQ,8CAAwB;IACvD,eAAe,CAAS;IACxB,gBAAgB,CAAiD;IACjE,aAAa,CAAmC;IAChD,cAAc,CAA2C;IAEjE,YAAmB,KAAmC;QACpD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,eAAe,GAAG,KAAK,EAAE,cAAc,IAAI,uBAAuB,CAAC;QACxE,IAAI,CAAC,gBAAgB,GAAG,IAAI,mCAAgB,CAAC;YAC3C,6EAA6E;YAC7E,qFAAqF;YACrF,mBAAmB,EAAE,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS;YAE5F,mCAAmC;YACnC,eAAe,EAAE,IAAI;YAErB,cAAc,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE;gBAChC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;oBACzB,qBAAM,CAAC,QAAQ,CAAC,yDAAiC,CAAC,GAAG,EAAE,uDAAuD,EAAE,GAAG,CAAC,CAAC;oBACrH,uBAAuB;oBACvB,IAAI,CAAC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gBACP,KAAK,wCAAkB,CAAC,KAAK,CAAC;gBAC9B,KAAK,wCAAkB,CAAC,eAAe;oBACrC,OAAO,IAAI,CAAC,KAAM,SAAQ,4BAAa;wBAC9B,IAAI,GAAG,uBAAuB,CAAC;wBAC/B,IAAI,GAAG,GAAG,CAAC;qBACnB,CAAC,EAAE,CAAC;YACT,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RPC\n */\n\nimport { IModelDb, RpcTrace } from \"@itwin/core-backend\";\nimport { BeEvent, ErrorCategory, Logger, omit, StatusCategory, SuccessCategory } from \"@itwin/core-bentley\";\nimport { IModelRpcProps, RpcPendingResponse } from \"@itwin/core-common\";\nimport {\n buildElementProperties,\n ClientDiagnostics,\n ComputeSelectionRpcRequestOptions,\n ContentDescriptorRpcRequestOptions,\n ContentFlags,\n ContentInstanceKeysRpcRequestOptions,\n ContentRpcRequestOptions,\n ContentSourcesRpcRequestOptions,\n ContentSourcesRpcResult,\n createCancellableTimeoutPromise,\n deepReplaceNullsToUndefined,\n DefaultContentDisplayTypes,\n DescriptorJSON,\n Diagnostics,\n DisplayLabelRpcRequestOptions,\n DisplayLabelsRpcRequestOptions,\n DisplayValueGroup,\n DistinctValuesRpcRequestOptions,\n ElementProperties,\n FilterByInstancePathsHierarchyRpcRequestOptions,\n FilterByTextHierarchyRpcRequestOptions,\n HierarchyLevel,\n HierarchyLevelDescriptorRpcRequestOptions,\n HierarchyRpcRequestOptions,\n ItemJSON,\n KeySet,\n KeySetJSON,\n LabelDefinition,\n Node,\n NodePathElement,\n Paged,\n PagedResponse,\n PageOptions,\n PresentationError,\n PresentationRpcInterface,\n PresentationRpcResponse,\n PresentationRpcResponseData,\n PresentationStatus,\n RpcDiagnosticsOptions,\n Ruleset,\n RulesetVariable,\n RulesetVariableJSON,\n SelectClassInfo,\n SelectionScope,\n SelectionScopeRpcRequestOptions,\n SingleElementPropertiesRpcRequestOptions,\n} from \"@itwin/presentation-common\";\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { Presentation } from \"./Presentation\";\nimport { PresentationManager } from \"./PresentationManager\";\nimport { TemporaryStorage } from \"./TemporaryStorage\";\nimport { getRulesetIdObject } from \"./PresentationManagerDetail\";\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst packageJsonVersion = require(\"../../../package.json\").version;\n\ntype ContentGetter<TResult = any, TOptions = any> = (requestOptions: TOptions) => TResult;\n\n/** @internal */\nexport const MAX_ALLOWED_PAGE_SIZE = 1000;\n/** @internal */\nexport const MAX_ALLOWED_KEYS_PAGE_SIZE = 10000;\n\nconst DEFAULT_REQUEST_TIMEOUT = 5000;\n\n/**\n * The backend implementation of PresentationRpcInterface. All it's basically\n * responsible for is forwarding calls to [[Presentation.manager]].\n *\n * @internal\n */\nexport class PresentationRpcImpl extends PresentationRpcInterface implements Disposable {\n private _requestTimeout: number;\n private _pendingRequests: TemporaryStorage<PresentationRpcResponse<any>>;\n private _cancelEvents: Map<string, BeEvent<() => void>>;\n private _statusHandler: (e: Error) => StatusCategory | undefined;\n\n public constructor(props?: { requestTimeout?: number }) {\n super();\n this._requestTimeout = props?.requestTimeout ?? DEFAULT_REQUEST_TIMEOUT;\n this._pendingRequests = new TemporaryStorage({\n // remove the pending request after request timeout + 10 seconds - this gives\n // frontend 10 seconds to re-send the request until it's removed from requests' cache\n unusedValueLifetime: this._requestTimeout > 0 ? this._requestTimeout + 10 * 1000 : undefined,\n\n // attempt to clean up every second\n cleanupInterval: 1000,\n\n cleanupHandler: (id, _, reason) => {\n if (reason !== \"request\") {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Cleaning up request without frontend retrieving it: ${id}.`);\n // istanbul ignore next\n this._cancelEvents.get(id)?.raiseEvent();\n }\n this._cancelEvents.delete(id);\n },\n });\n this._cancelEvents = new Map<string, BeEvent<() => void>>();\n\n this._statusHandler = createStatusCategoryHandler();\n StatusCategory.handlers.add(this._statusHandler);\n }\n\n public [Symbol.dispose]() {\n this._pendingRequests[Symbol.dispose]();\n StatusCategory.handlers.delete(this._statusHandler);\n }\n\n public get requestTimeout() {\n return this._requestTimeout;\n }\n\n public get pendingRequests() {\n return this._pendingRequests;\n }\n\n /** Returns an ok response with result inside */\n private successResponse<TResult>(result: TResult, diagnostics?: ClientDiagnostics) {\n return {\n statusCode: PresentationStatus.Success,\n result,\n diagnostics,\n };\n }\n\n /** Returns a bad request response with empty result and an error code */\n private errorResponse(errorCode: PresentationStatus, errorMessage?: string, diagnostics?: ClientDiagnostics) {\n return {\n statusCode: errorCode,\n result: undefined,\n errorMessage,\n diagnostics,\n };\n }\n\n /**\n * Get the [[PresentationManager]] used by this RPC impl.\n */\n public getManager(clientId?: string): PresentationManager {\n return Presentation.getManager(clientId);\n }\n\n private async getIModel(token: IModelRpcProps): Promise<IModelDb> {\n const imodel = IModelDb.findByKey(token.key);\n // call refreshContainer, just in case this is a V2 checkpoint whose sasToken is about to expire, or its default transaction is about to be restarted.\n await imodel.refreshContainerForRpc(RpcTrace.expectCurrentActivity.accessToken);\n return imodel;\n }\n\n private async makeRequest<\n TRpcOptions extends { rulesetOrId?: Ruleset | string; clientId?: string; diagnostics?: RpcDiagnosticsOptions; rulesetVariables?: RulesetVariableJSON[] },\n TResult,\n >(token: IModelRpcProps, requestId: string, requestOptions: TRpcOptions, request: ContentGetter<Promise<TResult>>): PresentationRpcResponse<TResult> {\n const serializedRequestOptionsForLogging = JSON.stringify({\n ...omit(requestOptions, [\"rulesetOrId\"]),\n ...(requestOptions.rulesetOrId ? { rulesetId: getRulesetIdObject(requestOptions.rulesetOrId).uniqueId } : undefined),\n });\n Logger.logInfo(PresentationBackendLoggerCategory.Rpc, `Received '${requestId}' request. Params: ${serializedRequestOptionsForLogging}`);\n\n const imodel = await this.getIModel(token);\n const requestKey = JSON.stringify({ iModelKey: token.key, requestId, requestOptions });\n let resultPromise = this._pendingRequests.getValue(requestKey);\n if (resultPromise) {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request already pending`);\n } else {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request not found, creating a new one`);\n const { clientId: _, diagnostics: diagnosticsOptions, rulesetVariables, ...options } = requestOptions;\n const managerRequestOptions: any = {\n ...options,\n imodel,\n cancelEvent: new BeEvent<() => void>(),\n };\n\n // set up ruleset variables\n if (rulesetVariables) {\n managerRequestOptions.rulesetVariables = rulesetVariables.map(RulesetVariable.fromJSON);\n }\n\n // set up diagnostics listener\n let diagnostics: ClientDiagnostics | undefined;\n const getDiagnostics = (): ClientDiagnostics => {\n if (!diagnostics) {\n diagnostics = {};\n }\n return diagnostics;\n };\n if (diagnosticsOptions) {\n if (diagnosticsOptions.backendVersion) {\n getDiagnostics().backendVersion = packageJsonVersion;\n }\n managerRequestOptions.diagnostics = {\n ...diagnosticsOptions,\n handler: (d: Diagnostics) => {\n if (d.logs) {\n const target = getDiagnostics();\n if (target.logs) {\n target.logs.push(...d.logs);\n } else {\n target.logs = [...d.logs];\n }\n }\n },\n };\n }\n\n // initiate request\n resultPromise = request(managerRequestOptions).then((result) => this.successResponse(result, diagnostics));\n\n // store the request promise\n this._pendingRequests.addValue(requestKey, resultPromise);\n this._cancelEvents.set(requestKey, managerRequestOptions.cancelEvent);\n }\n\n if (this._requestTimeout === 0) {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout not configured, returning promise without a timeout.`);\n void resultPromise.finally(() => {\n this._pendingRequests.deleteValue(requestKey);\n });\n return resultPromise;\n }\n\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Returning a promise with a timeout of ${this._requestTimeout}.`);\n const timeout = createCancellableTimeoutPromise(this._requestTimeout);\n return Promise.race([\n resultPromise,\n timeout.promise.then(() => {\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n throw new RpcPendingResponse(\"Timeout\");\n }),\n ])\n .then((response: PresentationRpcResponseData<TResult>) => {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request completed, returning result.`);\n this._pendingRequests.deleteValue(requestKey);\n return response;\n })\n .finally(() => {\n timeout.cancel();\n });\n }\n\n public override async getNodesCount(token: IModelRpcProps, requestOptions: HierarchyRpcRequestOptions): PresentationRpcResponse<number> {\n return this.makeRequest(token, \"getNodesCount\", requestOptions, async (options) => {\n return this.getManager(requestOptions.clientId).getNodesCount(options);\n });\n }\n\n public override async getPagedNodes(token: IModelRpcProps, requestOptions: Paged<HierarchyRpcRequestOptions>): PresentationRpcResponse<PagedResponse<Node>> {\n return this.makeRequest(token, \"getPagedNodes\", requestOptions, async (options) => {\n options = enforceValidPageSize(options);\n const [serializedHierarchyLevel, count] = await Promise.all([\n this.getManager(requestOptions.clientId).getDetail().getNodes(options),\n this.getManager(requestOptions.clientId).getNodesCount(options),\n ]);\n const hierarchyLevel: HierarchyLevel = deepReplaceNullsToUndefined(JSON.parse(serializedHierarchyLevel));\n return {\n total: count,\n items: hierarchyLevel.nodes,\n };\n });\n }\n\n public override async getNodesDescriptor(\n token: IModelRpcProps,\n requestOptions: HierarchyLevelDescriptorRpcRequestOptions,\n ): PresentationRpcResponse<string | DescriptorJSON | undefined> {\n return this.makeRequest(token, \"getNodesDescriptor\", requestOptions, async (options) => {\n return this.getManager(requestOptions.clientId).getDetail().getNodesDescriptor(options);\n });\n }\n\n public override async getNodePaths(\n token: IModelRpcProps,\n requestOptions: FilterByInstancePathsHierarchyRpcRequestOptions,\n ): PresentationRpcResponse<NodePathElement[]> {\n return this.makeRequest(token, \"getNodePaths\", requestOptions, async (options) => {\n return this.getManager(requestOptions.clientId).getDetail().getNodePaths(options);\n });\n }\n\n public override async getFilteredNodePaths(\n token: IModelRpcProps,\n requestOptions: FilterByTextHierarchyRpcRequestOptions,\n ): PresentationRpcResponse<NodePathElement[]> {\n return this.makeRequest(token, \"getFilteredNodePaths\", requestOptions, async (options) => {\n return this.getManager(requestOptions.clientId).getDetail().getFilteredNodePaths(options);\n });\n }\n\n public override async getContentSources(\n token: IModelRpcProps,\n requestOptions: ContentSourcesRpcRequestOptions,\n ): PresentationRpcResponse<ContentSourcesRpcResult> {\n return this.makeRequest(token, \"getContentSources\", requestOptions, async (options) => {\n const result = await this.getManager(requestOptions.clientId).getContentSources(options);\n const classesMap = {};\n const selectClasses = result.map((sci) => SelectClassInfo.toCompressedJSON(sci, classesMap));\n return { sources: selectClasses, classesMap };\n });\n }\n\n public override async getContentDescriptor(\n token: IModelRpcProps,\n requestOptions: ContentDescriptorRpcRequestOptions,\n ): PresentationRpcResponse<DescriptorJSON | undefined> {\n return this.makeRequest(token, \"getContentDescriptor\", requestOptions, async (options) => {\n options = {\n ...options,\n contentFlags: (options.contentFlags ?? 0) | ContentFlags.DescriptorOnly, // always append the \"descriptor only\" flag when handling request from the frontend\n keys: KeySet.fromJSON(options.keys),\n };\n if (options.transport === \"unparsed-json\") {\n // Here we send a plain JSON string but we will parse it to DescriptorJSON on the frontend. This way we are\n // bypassing unnecessary deserialization and serialization.\n return Presentation.getManager(requestOptions.clientId).getDetail().getContentDescriptor(options) as unknown as DescriptorJSON | undefined;\n } else {\n // Support for older frontends that still expect a parsed descriptor\n const descriptor = await Presentation.getManager(requestOptions.clientId).getContentDescriptor(options);\n return descriptor?.toJSON();\n }\n });\n }\n\n public override async getContentSetSize(token: IModelRpcProps, requestOptions: ContentRpcRequestOptions): PresentationRpcResponse<number> {\n return this.makeRequest(token, \"getContentSetSize\", requestOptions, async (options) => {\n options = {\n ...options,\n keys: KeySet.fromJSON(options.keys),\n };\n return this.getManager(requestOptions.clientId).getContentSetSize(options);\n });\n }\n\n public override async getPagedContent(\n token: IModelRpcProps,\n requestOptions: Paged<ContentRpcRequestOptions>,\n ): PresentationRpcResponse<{ descriptor: DescriptorJSON; contentSet: PagedResponse<ItemJSON> } | undefined> {\n return this.makeRequest(token, \"getPagedContent\", requestOptions, async (options) => {\n options = enforceValidPageSize({\n ...options,\n keys: KeySet.fromJSON(options.keys),\n });\n\n const [size, content] = await Promise.all([\n this.getManager(requestOptions.clientId).getContentSetSize(options),\n this.getManager(requestOptions.clientId).getDetail().getContent(options),\n ]);\n\n if (!content) {\n return undefined;\n }\n\n return {\n descriptor: content.descriptor.toJSON(),\n contentSet: {\n total: size,\n items: content.contentSet.map((i) => i.toJSON()),\n },\n };\n });\n }\n\n public override async getPagedContentSet(\n token: IModelRpcProps,\n requestOptions: Paged<ContentRpcRequestOptions>,\n ): PresentationRpcResponse<PagedResponse<ItemJSON>> {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const response = await this.getPagedContent(token, requestOptions);\n if (response.statusCode !== PresentationStatus.Success) {\n return this.errorResponse(response.statusCode, response.errorMessage, response.diagnostics);\n }\n if (!response.result) {\n return this.errorResponse(PresentationStatus.Error, `Failed to get content set (received a success response with empty result)`, response.diagnostics);\n }\n return {\n ...response,\n result: response.result.contentSet,\n };\n }\n\n public override async getElementProperties(\n token: IModelRpcProps,\n requestOptions: SingleElementPropertiesRpcRequestOptions,\n ): PresentationRpcResponse<ElementProperties | undefined> {\n return this.makeRequest(token, \"getElementProperties\", { ...requestOptions }, async (options) => {\n const manager = this.getManager(requestOptions.clientId);\n const { elementId, ...optionsNoElementId } = options;\n const content = await manager.getDetail().getContent({\n ...optionsNoElementId,\n descriptor: {\n displayType: DefaultContentDisplayTypes.PropertyPane,\n contentFlags: ContentFlags.ShowLabels,\n },\n rulesetOrId: \"ElementProperties\",\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\n });\n if (!content || content.contentSet.length === 0) {\n return undefined;\n }\n return buildElementProperties(content.descriptor, content.contentSet[0]);\n });\n }\n\n public override async getPagedDistinctValues(\n token: IModelRpcProps,\n requestOptions: DistinctValuesRpcRequestOptions,\n ): PresentationRpcResponse<PagedResponse<DisplayValueGroup>> {\n return this.makeRequest(token, \"getPagedDistinctValues\", requestOptions, async (options) => {\n options = enforceValidPageSize({\n ...options,\n keys: KeySet.fromJSON(options.keys),\n });\n return this.getManager(requestOptions.clientId).getDetail().getPagedDistinctValues(options);\n });\n }\n\n public override async getContentInstanceKeys(\n token: IModelRpcProps,\n requestOptions: ContentInstanceKeysRpcRequestOptions,\n ): PresentationRpcResponse<{ total: number; items: KeySetJSON }> {\n return this.makeRequest(token, \"getContentInstanceKeys\", requestOptions, async (options) => {\n const { displayType, ...optionsNoDisplayType } = options;\n options = enforceValidPageSize(\n {\n ...optionsNoDisplayType,\n keys: KeySet.fromJSON(optionsNoDisplayType.keys),\n descriptor: {\n displayType,\n contentFlags: ContentFlags.KeysOnly,\n },\n },\n MAX_ALLOWED_KEYS_PAGE_SIZE,\n );\n\n const [size, content] = await Promise.all([\n this.getManager(requestOptions.clientId).getContentSetSize(options),\n this.getManager(requestOptions.clientId).getDetail().getContent(options),\n ]);\n\n if (size === 0 || !content) {\n return { total: 0, items: new KeySet().toJSON() };\n }\n\n return {\n total: size,\n items: content.contentSet.reduce((keys, item) => keys.add(item.primaryKeys), new KeySet()).toJSON(),\n };\n });\n }\n\n public override async getDisplayLabelDefinition(\n token: IModelRpcProps,\n requestOptions: DisplayLabelRpcRequestOptions,\n ): PresentationRpcResponse<LabelDefinition> {\n return this.makeRequest(token, \"getDisplayLabelDefinition\", requestOptions, async (options) => {\n const label = await this.getManager(requestOptions.clientId).getDetail().getDisplayLabelDefinition(options);\n return label;\n });\n }\n\n public override async getPagedDisplayLabelDefinitions(\n token: IModelRpcProps,\n requestOptions: DisplayLabelsRpcRequestOptions,\n ): PresentationRpcResponse<PagedResponse<LabelDefinition>> {\n const pageOpts = enforceValidPageSize({ paging: { start: 0, size: requestOptions.keys.length } });\n if (pageOpts.paging.size < requestOptions.keys.length) {\n requestOptions.keys.splice(pageOpts.paging.size);\n }\n return this.makeRequest(token, \"getPagedDisplayLabelDefinitions\", requestOptions, async (options) => {\n const labels = await this.getManager(requestOptions.clientId)\n .getDetail()\n .getDisplayLabelDefinitions({ ...options, keys: options.keys });\n return {\n total: options.keys.length,\n items: labels,\n };\n });\n }\n\n /* eslint-disable @typescript-eslint/no-deprecated */\n public override async getSelectionScopes(token: IModelRpcProps, requestOptions: SelectionScopeRpcRequestOptions): PresentationRpcResponse<SelectionScope[]> {\n return this.makeRequest(token, \"getSelectionScopes\", requestOptions, async (options) =>\n this.getManager(requestOptions.clientId).getSelectionScopes(options),\n );\n }\n\n public override async computeSelection(token: IModelRpcProps, requestOptions: ComputeSelectionRpcRequestOptions): PresentationRpcResponse<KeySetJSON> {\n return this.makeRequest(token, \"computeSelection\", requestOptions, async (options) => {\n const keys = await this.getManager(requestOptions.clientId).computeSelection(options);\n return keys.toJSON();\n });\n }\n /* eslint-enable @typescript-eslint/no-deprecated */\n}\n\nconst enforceValidPageSize = <TOptions extends Paged<object>>(\n requestOptions: TOptions,\n maxPageSize = MAX_ALLOWED_PAGE_SIZE,\n): TOptions & { paging: PageOptions } => {\n const validPageSize = getValidPageSize(requestOptions.paging?.size, maxPageSize);\n if (!requestOptions.paging || requestOptions.paging.size !== validPageSize) {\n return { ...requestOptions, paging: { ...requestOptions.paging, size: validPageSize } };\n }\n return requestOptions as TOptions & { paging: PageOptions };\n};\n\nconst getValidPageSize = (size: number | undefined, maxPageSize: number) => {\n const requestedSize = size ?? 0;\n return requestedSize === 0 || requestedSize > maxPageSize ? maxPageSize : requestedSize;\n};\n\n// not testing temporary solution\n// istanbul ignore next\nfunction createStatusCategoryHandler() {\n return (e: Error) => {\n if (e instanceof PresentationError) {\n switch (e.errorNumber) {\n case PresentationStatus.NotInitialized:\n return new (class extends ErrorCategory {\n public name = \"Internal server error\";\n public code = 500;\n })();\n case PresentationStatus.Canceled:\n return new (class extends SuccessCategory {\n public name = \"Cancelled\";\n public code = 204;\n })();\n case PresentationStatus.ResultSetTooLarge:\n return new (class extends ErrorCategory {\n public name = \"Result set is too large\";\n public code = 413;\n })();\n case PresentationStatus.Error:\n case PresentationStatus.InvalidArgument:\n return new (class extends ErrorCategory {\n public name = \"Invalid request props\";\n public code = 422;\n })();\n }\n }\n return undefined;\n };\n}\n"]}
|
|
@@ -44,13 +44,15 @@ const Utils_1 = require("./Utils");
|
|
|
44
44
|
* @public
|
|
45
45
|
*/
|
|
46
46
|
class RulesetEmbedder {
|
|
47
|
+
_imodel;
|
|
48
|
+
_parentSubjectId;
|
|
49
|
+
_schemaPath = path.join(core_backend_1.KnownLocations.nativeAssetsDir, "ECSchemas/Domain/PresentationRules.ecschema.xml");
|
|
50
|
+
_rulesetModelName = "PresentationRules";
|
|
51
|
+
_rulesetSubjectName = "PresentationRules";
|
|
47
52
|
/**
|
|
48
53
|
* Constructs RulesetEmbedder
|
|
49
54
|
*/
|
|
50
55
|
constructor(props) {
|
|
51
|
-
this._schemaPath = path.join(core_backend_1.KnownLocations.nativeAssetsDir, "ECSchemas/Domain/PresentationRules.ecschema.xml");
|
|
52
|
-
this._rulesetModelName = "PresentationRules";
|
|
53
|
-
this._rulesetSubjectName = "PresentationRules";
|
|
54
56
|
PresentationRulesDomain_1.PresentationRules.registerSchema();
|
|
55
57
|
this._imodel = props.imodel;
|
|
56
58
|
this._parentSubjectId = props.parentSubjectId ?? core_common_1.IModel.rootSubjectId;
|