@itwin/core-backend 3.5.0-dev.7 → 3.6.0-dev.1
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 +92 -1
- package/lib/cjs/BriefcaseManager.d.ts +7 -2
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +11 -3
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +2 -0
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.d.ts +8 -0
- package/lib/cjs/ClassRegistry.d.ts.map +1 -1
- package/lib/cjs/ClassRegistry.js +47 -13
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +1 -0
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +1 -0
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.d.ts +3 -1
- package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
- package/lib/cjs/ConcurrentQuery.js +6 -0
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.d.ts +3 -14
- package/lib/cjs/CustomViewState3dCreator.d.ts.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js +11 -43
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +9 -9
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +12 -12
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/Element.d.ts +23 -30
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +42 -46
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +24 -4
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +35 -2
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/Entity.d.ts +31 -1
- package/lib/cjs/Entity.d.ts.map +1 -1
- package/lib/cjs/Entity.js +52 -0
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/EntityReferences.d.ts +50 -0
- package/lib/cjs/EntityReferences.d.ts.map +1 -0
- package/lib/cjs/EntityReferences.js +96 -0
- package/lib/cjs/EntityReferences.js.map +1 -0
- package/lib/cjs/ExternalSource.d.ts +3 -1
- package/lib/cjs/ExternalSource.d.ts.map +1 -1
- package/lib/cjs/ExternalSource.js +6 -0
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
- package/lib/cjs/GeoCoordConfig.js +10 -7
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/HubMock.d.ts +1 -0
- package/lib/cjs/HubMock.d.ts.map +1 -1
- package/lib/cjs/HubMock.js +34 -2
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelCloneContext.d.ts +5 -82
- package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelCloneContext.js +7 -142
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +21 -2
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +64 -14
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.d.ts +90 -0
- package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -0
- package/lib/cjs/IModelElementCloneContext.js +160 -0
- package/lib/cjs/IModelElementCloneContext.js.map +1 -0
- package/lib/cjs/IModelHost.d.ts +9 -0
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +9 -2
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IpcHost.d.ts +6 -0
- package/lib/cjs/IpcHost.d.ts.map +1 -1
- package/lib/cjs/IpcHost.js +47 -3
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/Model.d.ts +8 -2
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +15 -1
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeHost.d.ts.map +1 -1
- package/lib/cjs/NativeHost.js +10 -15
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.d.ts +4 -4
- package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
- package/lib/cjs/PromiseMemoizer.js +44 -44
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +18 -2
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +30 -1
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.d.ts +0 -23
- package/lib/cjs/RpcBackend.d.ts.map +1 -1
- package/lib/cjs/RpcBackend.js +13 -108
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SqliteStatement.d.ts +81 -4
- package/lib/cjs/SqliteStatement.d.ts.map +1 -1
- package/lib/cjs/SqliteStatement.js +163 -25
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +14 -10
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +31 -20
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.js +2 -2
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/core-backend.d.ts +4 -2
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +4 -2
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/rpc/multipart.d.ts +12 -0
- package/lib/cjs/rpc/multipart.d.ts.map +1 -0
- package/lib/cjs/rpc/multipart.js +71 -0
- package/lib/cjs/rpc/multipart.js.map +1 -0
- package/lib/cjs/rpc/tracing.d.ts +29 -0
- package/lib/cjs/rpc/tracing.d.ts.map +1 -0
- package/lib/cjs/rpc/tracing.js +74 -0
- package/lib/cjs/rpc/tracing.js.map +1 -0
- package/lib/cjs/rpc/web/logging.d.ts +10 -0
- package/lib/cjs/rpc/web/logging.d.ts.map +1 -0
- package/lib/cjs/rpc/web/logging.js +43 -0
- package/lib/cjs/rpc/web/logging.js.map +1 -0
- package/lib/cjs/rpc/web/request.d.ts +7 -0
- package/lib/cjs/rpc/web/request.d.ts.map +1 -0
- package/lib/cjs/rpc/web/request.js +74 -0
- package/lib/cjs/rpc/web/request.js.map +1 -0
- package/lib/cjs/rpc/web/response.d.ts +7 -0
- package/lib/cjs/rpc/web/response.d.ts.map +1 -0
- package/lib/cjs/rpc/web/response.js +106 -0
- package/lib/cjs/rpc/web/response.js.map +1 -0
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +4 -2
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +80 -51
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +13 -15
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Workspace.d.ts +1 -1
- package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
- package/lib/cjs/workspace/Workspace.js +2 -2
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/package.json +14 -14
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module RpcInterface
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.initializeTracing = exports.RpcTrace = void 0;
|
|
11
|
+
// cspell:ignore calltrace
|
|
12
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
13
|
+
const core_common_1 = require("@itwin/core-common");
|
|
14
|
+
const async_hooks_1 = require("async_hooks");
|
|
15
|
+
const BackendLoggerCategory_1 = require("../BackendLoggerCategory");
|
|
16
|
+
const IModelHost_1 = require("../IModelHost");
|
|
17
|
+
/**
|
|
18
|
+
* Utility for tracing Rpc activity processing. When multiple Rpc requests are being processed asynchronously, this
|
|
19
|
+
* class can be used to correlate the current calltrace with the originating RpcActivity. This is used for automatic appending
|
|
20
|
+
* of RpcActivity to log messages emitted during Rpc processing. It may also be used to retrieve the user accessToken
|
|
21
|
+
* from the RpcActivity.
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
class RpcTrace {
|
|
25
|
+
/** Get the [RpcActivity]($common) for the currently executing async, or `undefined` if there is no
|
|
26
|
+
* RpcActivity in the current call stack.
|
|
27
|
+
* */
|
|
28
|
+
static get currentActivity() {
|
|
29
|
+
return RpcTrace._storage.getStore();
|
|
30
|
+
}
|
|
31
|
+
/** Get the [RpcActivity]($common) for the currently executing async. Asserts that the RpcActivity
|
|
32
|
+
* exists in the current call stack.
|
|
33
|
+
* */
|
|
34
|
+
static get expectCurrentActivity() {
|
|
35
|
+
(0, core_bentley_1.assert)(undefined !== RpcTrace.currentActivity);
|
|
36
|
+
return RpcTrace.currentActivity;
|
|
37
|
+
}
|
|
38
|
+
/** Start the processing of an RpcActivity. */
|
|
39
|
+
static async run(activity, fn) {
|
|
40
|
+
return RpcTrace._storage.run(activity, fn);
|
|
41
|
+
}
|
|
42
|
+
/** Start the processing of an RpcActivity inside an OpenTelemetry span */
|
|
43
|
+
static async runWithSpan(activity, fn) {
|
|
44
|
+
var _a;
|
|
45
|
+
return core_bentley_1.Tracing.withSpan((_a = activity.rpcMethod) !== null && _a !== void 0 ? _a : "unknown RPC method", async () => RpcTrace.run(activity, fn), {
|
|
46
|
+
attributes: { ...core_common_1.RpcInvocation.sanitizeForLog(activity) },
|
|
47
|
+
kind: core_bentley_1.SpanKind.SERVER,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.RpcTrace = RpcTrace;
|
|
52
|
+
RpcTrace._storage = new async_hooks_1.AsyncLocalStorage();
|
|
53
|
+
/** @internal */
|
|
54
|
+
function initializeTracing(enableOpenTelemetry = false) {
|
|
55
|
+
core_common_1.RpcInvocation.runActivity = RpcTrace.run; // redirect the invocation processing to the tracer
|
|
56
|
+
if (enableOpenTelemetry) {
|
|
57
|
+
try {
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
59
|
+
const api = require("@opentelemetry/api");
|
|
60
|
+
const tracer = api.trace.getTracer("@itwin/core-backend", IModelHost_1.IModelHost.backendVersion);
|
|
61
|
+
core_bentley_1.Tracing.enableOpenTelemetry(tracer, api);
|
|
62
|
+
core_common_1.RpcInvocation.runActivity = RpcTrace.runWithSpan; // wrap invocation in an OpenTelemetry span in addition to RpcTrace
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
66
|
+
core_bentley_1.Logger.logError(BackendLoggerCategory_1.BackendLoggerCategory.IModelHost, "Failed to initialize OpenTelemetry");
|
|
67
|
+
core_bentley_1.Logger.logException(BackendLoggerCategory_1.BackendLoggerCategory.IModelHost, e);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// set up static logger metadata to include current RpcActivity information for logs during rpc processing
|
|
71
|
+
core_bentley_1.Logger.staticMetaData.set("rpc", () => core_common_1.RpcInvocation.sanitizeForLog(RpcTrace.currentActivity));
|
|
72
|
+
}
|
|
73
|
+
exports.initializeTracing = initializeTracing;
|
|
74
|
+
//# sourceMappingURL=tracing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../../src/rpc/tracing.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0BAA0B;AAE1B,sDAAwE;AACxE,oDAAgE;AAChE,6CAAgD;AAChD,oEAAiE;AACjE,8CAA2C;AAE3C;;;;;;GAMG;AACH,MAAa,QAAQ;IAGnB;;SAEK;IACE,MAAM,KAAK,eAAe;QAC/B,OAAO,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAA6B,CAAC;IACjE,CAAC;IAED;;SAEK;IACE,MAAM,KAAK,qBAAqB;QACrC,IAAA,qBAAM,EAAC,SAAS,KAAK,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC/C,OAAO,QAAQ,CAAC,eAAe,CAAC;IAClC,CAAC;IAED,8CAA8C;IACvC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAI,QAAqB,EAAE,EAAoB;QACpE,OAAO,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,0EAA0E;IACnE,MAAM,CAAC,KAAK,CAAC,WAAW,CAAI,QAAqB,EAAE,EAAoB;;QAC5E,OAAO,sBAAO,CAAC,QAAQ,CAAC,MAAA,QAAQ,CAAC,SAAS,mCAAI,oBAAoB,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE;YAC1G,UAAU,EAAE,EAAE,GAAG,2BAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;YACzD,IAAI,EAAE,uBAAQ,CAAC,MAAM;SACtB,CAAC,CAAC;IACL,CAAC;;AA7BH,4BA8BC;AA7BgB,iBAAQ,GAAG,IAAI,+BAAiB,EAAE,CAAC;AA+BpD,gBAAgB;AAChB,SAAgB,iBAAiB,CAAC,sBAA+B,KAAK;IACpE,2BAAa,CAAC,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,mDAAmD;IAE7F,IAAI,mBAAmB,EAAE;QACvB,IAAI;YACF,8DAA8D;YAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;YAC1C,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,qBAAqB,EAAE,uBAAU,CAAC,cAAc,CAAC,CAAC;YACrF,sBAAO,CAAC,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YACzC,2BAAa,CAAC,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC,mEAAmE;SACtH;QAAC,OAAO,CAAC,EAAE;YACV,gEAAgE;YAChE,qBAAM,CAAC,QAAQ,CAAC,6CAAqB,CAAC,UAAU,EAAE,oCAAoC,CAAC,CAAC;YACxF,qBAAM,CAAC,YAAY,CAAC,6CAAqB,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;SAC1D;KACF;IAED,0GAA0G;IAC1G,qBAAM,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,2BAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;AACjG,CAAC;AAnBD,8CAmBC","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 RpcInterface\r\n */\r\n\r\n// cspell:ignore calltrace\r\n\r\nimport { assert, Logger, SpanKind, Tracing } from \"@itwin/core-bentley\";\r\nimport { RpcActivity, RpcInvocation } from \"@itwin/core-common\";\r\nimport { AsyncLocalStorage } from \"async_hooks\";\r\nimport { BackendLoggerCategory } from \"../BackendLoggerCategory\";\r\nimport { IModelHost } from \"../IModelHost\";\r\n\r\n/**\r\n * Utility for tracing Rpc activity processing. When multiple Rpc requests are being processed asynchronously, this\r\n * class can be used to correlate the current calltrace with the originating RpcActivity. This is used for automatic appending\r\n * of RpcActivity to log messages emitted during Rpc processing. It may also be used to retrieve the user accessToken\r\n * from the RpcActivity.\r\n * @public\r\n */\r\nexport class RpcTrace {\r\n private static _storage = new AsyncLocalStorage();\r\n\r\n /** Get the [RpcActivity]($common) for the currently executing async, or `undefined` if there is no\r\n * RpcActivity in the current call stack.\r\n * */\r\n public static get currentActivity(): RpcActivity | undefined {\r\n return RpcTrace._storage.getStore() as RpcActivity | undefined;\r\n }\r\n\r\n /** Get the [RpcActivity]($common) for the currently executing async. Asserts that the RpcActivity\r\n * exists in the current call stack.\r\n * */\r\n public static get expectCurrentActivity(): RpcActivity {\r\n assert(undefined !== RpcTrace.currentActivity);\r\n return RpcTrace.currentActivity;\r\n }\r\n\r\n /** Start the processing of an RpcActivity. */\r\n public static async run<T>(activity: RpcActivity, fn: () => Promise<T>): Promise<T> {\r\n return RpcTrace._storage.run(activity, fn);\r\n }\r\n\r\n /** Start the processing of an RpcActivity inside an OpenTelemetry span */\r\n public static async runWithSpan<T>(activity: RpcActivity, fn: () => Promise<T>): Promise<T> {\r\n return Tracing.withSpan(activity.rpcMethod ?? \"unknown RPC method\", async () => RpcTrace.run(activity, fn), {\r\n attributes: { ...RpcInvocation.sanitizeForLog(activity) },\r\n kind: SpanKind.SERVER,\r\n });\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function initializeTracing(enableOpenTelemetry: boolean = false) {\r\n RpcInvocation.runActivity = RpcTrace.run; // redirect the invocation processing to the tracer\r\n\r\n if (enableOpenTelemetry) {\r\n try {\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n const api = require(\"@opentelemetry/api\");\r\n const tracer = api.trace.getTracer(\"@itwin/core-backend\", IModelHost.backendVersion);\r\n Tracing.enableOpenTelemetry(tracer, api);\r\n RpcInvocation.runActivity = RpcTrace.runWithSpan; // wrap invocation in an OpenTelemetry span in addition to RpcTrace\r\n } catch (e) {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n Logger.logError(BackendLoggerCategory.IModelHost, \"Failed to initialize OpenTelemetry\");\r\n Logger.logException(BackendLoggerCategory.IModelHost, e);\r\n }\r\n }\r\n\r\n // set up static logger metadata to include current RpcActivity information for logs during rpc processing\r\n Logger.staticMetaData.set(\"rpc\", () => RpcInvocation.sanitizeForLog(RpcTrace.currentActivity));\r\n}\r\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module RpcInterface
|
|
3
|
+
*/
|
|
4
|
+
import { RpcInvocation, RpcProtocolEvent, WebAppRpcLogging } from "@itwin/core-common";
|
|
5
|
+
export declare class WebAppRpcLoggingBackend extends WebAppRpcLogging {
|
|
6
|
+
protected logProtocolEvent(event: RpcProtocolEvent, object: RpcInvocation): Promise<void>;
|
|
7
|
+
protected getHostname(): string;
|
|
8
|
+
private logErrorBackend;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=logging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/logging.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAwB,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG7G,qBAAa,uBAAwB,SAAQ,gBAAgB;cAClC,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;cAQrF,WAAW,IAAI,MAAM;YAI1B,eAAe;CAiB9B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module RpcInterface
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.WebAppRpcLoggingBackend = void 0;
|
|
11
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
+
const core_common_1 = require("@itwin/core-common");
|
|
13
|
+
const os = require("os");
|
|
14
|
+
class WebAppRpcLoggingBackend extends core_common_1.WebAppRpcLogging {
|
|
15
|
+
async logProtocolEvent(event, object) {
|
|
16
|
+
switch (event) {
|
|
17
|
+
case core_common_1.RpcProtocolEvent.RequestReceived: return this.logRequest(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, "RpcInterface.backend.request", object.request);
|
|
18
|
+
case core_common_1.RpcProtocolEvent.BackendErrorOccurred: return this.logErrorBackend("RpcInterface.backend.error", object);
|
|
19
|
+
case core_common_1.RpcProtocolEvent.BackendResponseCreated: return this.logResponse(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, "RpcInterface.backend.response", object.request, object.status, object.elapsed);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
getHostname() {
|
|
23
|
+
return os.hostname();
|
|
24
|
+
}
|
|
25
|
+
async logErrorBackend(message, invocation) {
|
|
26
|
+
const operationDescriptor = this.buildOperationDescriptor(invocation.operation);
|
|
27
|
+
const pathIds = this.findPathIds(invocation.request.path);
|
|
28
|
+
const result = await invocation.result;
|
|
29
|
+
const errorMessage = result.message ? result.message : result.objects; // Can be an error or an RpcSerializedValue
|
|
30
|
+
core_bentley_1.Logger.logInfo(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, `${message}.${operationDescriptor}`, () => ({
|
|
31
|
+
method: invocation.request.method,
|
|
32
|
+
path: invocation.request.path,
|
|
33
|
+
status: invocation.status,
|
|
34
|
+
errorMessage,
|
|
35
|
+
// Alert! The following properties are required by Bentley DevOps standards. Do not change their names!
|
|
36
|
+
ActivityId: invocation.request.id,
|
|
37
|
+
MachineName: this.getHostname(),
|
|
38
|
+
...pathIds,
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.WebAppRpcLoggingBackend = WebAppRpcLoggingBackend;
|
|
43
|
+
//# sourceMappingURL=logging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../../../../src/rpc/web/logging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,oDAA6G;AAC7G,yBAAyB;AAEzB,MAAa,uBAAwB,SAAQ,8BAAgB;IACxC,KAAK,CAAC,gBAAgB,CAAC,KAAuB,EAAE,MAAqB;QACtF,QAAQ,KAAK,EAAE;YACb,KAAK,8BAAgB,CAAC,eAAe,CAAC,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,8BAA8B,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YACxJ,KAAK,8BAAgB,CAAC,oBAAoB,CAAC,CAAC,OAAO,IAAI,CAAC,eAAe,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;YAC9G,KAAK,8BAAgB,CAAC,sBAAsB,CAAC,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,+BAA+B,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;SACjM;IACH,CAAC;IAEkB,WAAW;QAC5B,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,eAAe,CAAC,OAAe,EAAE,UAAyB;QACtE,MAAM,mBAAmB,GAAG,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAChF,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC;QACvC,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,2CAA2C;QAElH,qBAAM,CAAC,OAAO,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,GAAG,OAAO,IAAI,mBAAmB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACnG,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,MAAM;YACjC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,IAAI;YAC7B,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,YAAY;YACZ,uGAAuG;YACvG,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE;YACjC,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;YAC/B,GAAG,OAAO;SACX,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AA9BD,0DA8BC","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 RpcInterface\r\n */\r\n\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory, RpcInvocation, RpcProtocolEvent, WebAppRpcLogging } from \"@itwin/core-common\";\r\nimport * as os from \"os\";\r\n\r\nexport class WebAppRpcLoggingBackend extends WebAppRpcLogging {\r\n protected override async logProtocolEvent(event: RpcProtocolEvent, object: RpcInvocation): Promise<void> {\r\n switch (event) {\r\n case RpcProtocolEvent.RequestReceived: return this.logRequest(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.request\", object.request);\r\n case RpcProtocolEvent.BackendErrorOccurred: return this.logErrorBackend(\"RpcInterface.backend.error\", object);\r\n case RpcProtocolEvent.BackendResponseCreated: return this.logResponse(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.response\", object.request, object.status, object.elapsed);\r\n }\r\n }\r\n\r\n protected override getHostname(): string {\r\n return os.hostname();\r\n }\r\n\r\n private async logErrorBackend(message: string, invocation: RpcInvocation): Promise<void> {\r\n const operationDescriptor = this.buildOperationDescriptor(invocation.operation);\r\n const pathIds = this.findPathIds(invocation.request.path);\r\n const result = await invocation.result;\r\n const errorMessage = result.message ? result.message : result.objects; // Can be an error or an RpcSerializedValue\r\n\r\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceBackend, `${message}.${operationDescriptor}`, () => ({\r\n method: invocation.request.method,\r\n path: invocation.request.path,\r\n status: invocation.status,\r\n errorMessage,\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: invocation.request.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module RpcInterface
|
|
3
|
+
*/
|
|
4
|
+
import { HttpServerRequest, SerializedRpcRequest, WebAppRpcProtocol } from "@itwin/core-common";
|
|
5
|
+
/** @internal */
|
|
6
|
+
export declare function parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest>;
|
|
7
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/request.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAEL,iBAAiB,EASjB,oBAAoB,EAEpB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAgC5B,gBAAgB;AAChB,wBAAsB,YAAY,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAoCrH"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module RpcInterface
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.parseRequest = void 0;
|
|
11
|
+
const core_common_1 = require("@itwin/core-common");
|
|
12
|
+
function parseHeaders(protocol, req) {
|
|
13
|
+
var _a;
|
|
14
|
+
const headerNames = protocol.serializedClientRequestContextHeaderNames;
|
|
15
|
+
const parsedHeaders = {
|
|
16
|
+
id: req.header(headerNames.id) || "",
|
|
17
|
+
applicationId: req.header(headerNames.applicationId) || "",
|
|
18
|
+
applicationVersion: req.header(headerNames.applicationVersion) || "",
|
|
19
|
+
sessionId: req.header(headerNames.sessionId) || "",
|
|
20
|
+
authorization: (_a = (headerNames.authorization ? req.header(headerNames.authorization) : "")) !== null && _a !== void 0 ? _a : "",
|
|
21
|
+
};
|
|
22
|
+
return parsedHeaders;
|
|
23
|
+
}
|
|
24
|
+
function parseFromPath(operation) {
|
|
25
|
+
const decoded = operation.encodedRequest ? Buffer.from(operation.encodedRequest, "base64").toString("binary") : "";
|
|
26
|
+
return core_common_1.RpcSerializedValue.create(decoded);
|
|
27
|
+
}
|
|
28
|
+
async function parseFromBody(req) {
|
|
29
|
+
const contentType = core_common_1.WebAppRpcProtocol.computeContentType(req.header(core_common_1.WEB_RPC_CONSTANTS.CONTENT));
|
|
30
|
+
if (contentType === core_common_1.RpcContentType.Binary) {
|
|
31
|
+
const objects = JSON.stringify([core_common_1.MarshalingBinaryMarker.createDefault()]);
|
|
32
|
+
const data = [req.body];
|
|
33
|
+
return core_common_1.RpcSerializedValue.create(objects, data);
|
|
34
|
+
}
|
|
35
|
+
else if (contentType === core_common_1.RpcContentType.Multipart) {
|
|
36
|
+
return core_common_1.RpcMultipart.parseRequest(req);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return core_common_1.RpcSerializedValue.create(req.body);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** @internal */
|
|
43
|
+
async function parseRequest(protocol, req) {
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
45
|
+
const operation = protocol.getOperationFromPath(req.url);
|
|
46
|
+
const parsedHeaders = parseHeaders(protocol, req);
|
|
47
|
+
const request = {
|
|
48
|
+
...parsedHeaders,
|
|
49
|
+
operation: {
|
|
50
|
+
interfaceDefinition: operation.interfaceDefinition,
|
|
51
|
+
operationName: operation.operationName,
|
|
52
|
+
interfaceVersion: operation.interfaceVersion,
|
|
53
|
+
},
|
|
54
|
+
method: req.method,
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
56
|
+
path: req.url,
|
|
57
|
+
parameters: operation.encodedRequest ? parseFromPath(operation) : await parseFromBody(req),
|
|
58
|
+
caching: operation.encodedRequest ? core_common_1.RpcResponseCacheControl.Immutable : core_common_1.RpcResponseCacheControl.None,
|
|
59
|
+
};
|
|
60
|
+
request.ip = req.ip;
|
|
61
|
+
request.protocolVersion = 0;
|
|
62
|
+
if (protocol.protocolVersionHeaderName) {
|
|
63
|
+
const version = req.header(protocol.protocolVersionHeaderName);
|
|
64
|
+
if (version) {
|
|
65
|
+
request.protocolVersion = parseInt(version, 10);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!request.id) {
|
|
69
|
+
throw new core_common_1.IModelError(core_common_1.BentleyStatus.ERROR, `Invalid request: Missing required activity ID.`);
|
|
70
|
+
}
|
|
71
|
+
return request;
|
|
72
|
+
}
|
|
73
|
+
exports.parseRequest = parseRequest;
|
|
74
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/rpc/web/request.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAc4B;AAE5B,SAAS,YAAY,CAAC,QAA2B,EAAE,GAAsB;;IACvE,MAAM,WAAW,GAA0B,QAAQ,CAAC,yCAAyC,CAAC;IAC9F,MAAM,aAAa,GAA0B;QAC3C,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE;QACpC,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,EAAE;QAC1D,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,EAAE;QACpE,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE;QAClD,aAAa,EAAE,MAAA,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,mCAAI,EAAE;KAC9F,CAAC;IACF,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAS,aAAa,CAAC,SAAiC;IACtD,MAAM,OAAO,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACnH,OAAO,gCAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,GAAsB;IACjD,MAAM,WAAW,GAAG,+BAAiB,CAAC,kBA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AC,qCAAuB,CAAC,SAAS,CAAC,CAAC,CAAC,qCAAuB,CAAC,IAAI;KACrG,CAAC;IAEF,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC;IAEpB,OAAO,CAAC,eAAe,GAAG,CAAC,CAAC;IAE5B,IAAI,QAAQ,CAAC,yBAAyB,EAAE;QACtC,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC;QAC/D,IAAI,OAAO,EAAE;YACX,OAAO,CAAC,eAAe,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;SACjD;KACF;IAED,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE;QACf,MAAM,IAAI,yBAAW,CAAC,2BAAa,CAAC,KAAK,EAAE,gDAAgD,CAAC,CAAC;KAC9F;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AApCD,oCAoCC","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 RpcInterface\r\n */\r\n\r\nimport {\r\n BentleyStatus,\r\n HttpServerRequest,\r\n IModelError,\r\n MarshalingBinaryMarker,\r\n RpcContentType,\r\n RpcMultipart,\r\n RpcResponseCacheControl,\r\n RpcSerializedValue,\r\n SerializedRpcActivity,\r\n SerializedRpcOperation,\r\n SerializedRpcRequest,\r\n WEB_RPC_CONSTANTS,\r\n WebAppRpcProtocol,\r\n} from \"@itwin/core-common\";\r\n\r\nfunction parseHeaders(protocol: WebAppRpcProtocol, req: HttpServerRequest): SerializedRpcActivity {\r\n const headerNames: SerializedRpcActivity = protocol.serializedClientRequestContextHeaderNames;\r\n const parsedHeaders: SerializedRpcActivity = {\r\n id: req.header(headerNames.id) || \"\",\r\n applicationId: req.header(headerNames.applicationId) || \"\",\r\n applicationVersion: req.header(headerNames.applicationVersion) || \"\",\r\n sessionId: req.header(headerNames.sessionId) || \"\",\r\n authorization: (headerNames.authorization ? req.header(headerNames.authorization) : \"\") ?? \"\",\r\n };\r\n return parsedHeaders;\r\n}\r\n\r\nfunction parseFromPath(operation: SerializedRpcOperation): RpcSerializedValue {\r\n const decoded = operation.encodedRequest ? Buffer.from(operation.encodedRequest, \"base64\").toString(\"binary\") : \"\";\r\n return RpcSerializedValue.create(decoded);\r\n}\r\n\r\nasync function parseFromBody(req: HttpServerRequest): Promise<RpcSerializedValue> {\r\n const contentType = WebAppRpcProtocol.computeContentType(req.header(WEB_RPC_CONSTANTS.CONTENT));\r\n if (contentType === RpcContentType.Binary) {\r\n const objects = JSON.stringify([MarshalingBinaryMarker.createDefault()]);\r\n const data = [req.body as Buffer];\r\n return RpcSerializedValue.create(objects, data);\r\n } else if (contentType === RpcContentType.Multipart) {\r\n return RpcMultipart.parseRequest(req);\r\n } else {\r\n return RpcSerializedValue.create(req.body as string);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport async function parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest> {\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n const operation = protocol.getOperationFromPath(req.url!);\r\n\r\n const parsedHeaders = parseHeaders(protocol, req);\r\n\r\n const request: SerializedRpcRequest = {\r\n ...parsedHeaders,\r\n operation: {\r\n interfaceDefinition: operation.interfaceDefinition,\r\n operationName: operation.operationName,\r\n interfaceVersion: operation.interfaceVersion,\r\n },\r\n method: req.method,\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n path: req.url!,\r\n parameters: operation.encodedRequest ? parseFromPath(operation) : await parseFromBody(req),\r\n caching: operation.encodedRequest ? RpcResponseCacheControl.Immutable : RpcResponseCacheControl.None,\r\n };\r\n\r\n request.ip = req.ip;\r\n\r\n request.protocolVersion = 0;\r\n\r\n if (protocol.protocolVersionHeaderName) {\r\n const version = req.header(protocol.protocolVersionHeaderName);\r\n if (version) {\r\n request.protocolVersion = parseInt(version, 10);\r\n }\r\n }\r\n\r\n if (!request.id) {\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid request: Missing required activity ID.`);\r\n }\r\n\r\n return request;\r\n}\r\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module RpcInterface
|
|
3
|
+
*/
|
|
4
|
+
import { HttpServerRequest, HttpServerResponse, RpcRequestFulfillment, SerializedRpcRequest, WebAppRpcProtocol } from "@itwin/core-common";
|
|
5
|
+
/** @internal */
|
|
6
|
+
export declare function sendResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, req: HttpServerRequest, res: HttpServerResponse): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/response.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAKlB,qBAAqB,EAGrB,oBAAoB,EAEpB,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AA2D5B,gBAAgB;AAChB,wBAAsB,YAAY,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,qBAAqB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,EAAE,kBAAkB,iBAqCjL"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module RpcInterface
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.sendResponse = void 0;
|
|
11
|
+
const core_common_1 = require("@itwin/core-common");
|
|
12
|
+
function configureResponse(protocol, request, fulfillment, res) {
|
|
13
|
+
const success = protocol.getStatus(fulfillment.status) === core_common_1.RpcRequestStatus.Resolved;
|
|
14
|
+
// TODO: Use stale-while-revalidate in cache headers. This needs to be tested, and does not currently have support in the router/caching-service.
|
|
15
|
+
// This will allow browsers to use stale cached responses while also revalidating with the router, allowing us to start up a backend if necessary.
|
|
16
|
+
// RPC Caching Service uses the s-maxage header to determine the TTL for the redis cache.
|
|
17
|
+
const oneHourInSeconds = 3600;
|
|
18
|
+
if (success && request.caching === core_common_1.RpcResponseCacheControl.Immutable) {
|
|
19
|
+
// If response size is > 50 MB, do not cache it.
|
|
20
|
+
if (fulfillment.result.objects.length > (50 * 10 ** 7)) {
|
|
21
|
+
res.set("Cache-Control", "no-store");
|
|
22
|
+
}
|
|
23
|
+
else if (request.operation.operationName === "generateTileContent") {
|
|
24
|
+
res.set("Cache-Control", "no-store");
|
|
25
|
+
}
|
|
26
|
+
else if (request.operation.operationName === "getConnectionProps") {
|
|
27
|
+
// GetConnectionprops can't be cached on the browser longer than the lifespan of the backend. The lifespan of backend may shrink too. Keep it at 1 second to be safe.
|
|
28
|
+
res.set("Cache-Control", `s-maxage=${oneHourInSeconds * 24}, max-age=1, immutable`);
|
|
29
|
+
}
|
|
30
|
+
else if (request.operation.operationName === "getTileCacheContainerUrl") {
|
|
31
|
+
// getTileCacheContainerUrl returns a SAS with an expiry of 23:59:59. We can't exceed that time when setting the max-age.
|
|
32
|
+
res.set("Cache-Control", `s-maxage=${oneHourInSeconds * 23}, max-age=${oneHourInSeconds * 23}, immutable`);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
res.set("Cache-Control", `s-maxage=${oneHourInSeconds * 24}, max-age=${oneHourInSeconds * 48}, immutable`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (fulfillment.retry) {
|
|
39
|
+
res.set("Retry-After", fulfillment.retry);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function configureText(fulfillment, res) {
|
|
43
|
+
res.set(core_common_1.WEB_RPC_CONSTANTS.CONTENT, core_common_1.WEB_RPC_CONSTANTS.TEXT);
|
|
44
|
+
return (fulfillment.status === 204) ? "" : fulfillment.result.objects;
|
|
45
|
+
}
|
|
46
|
+
function configureBinary(fulfillment, res) {
|
|
47
|
+
res.set(core_common_1.WEB_RPC_CONSTANTS.CONTENT, core_common_1.WEB_RPC_CONSTANTS.BINARY);
|
|
48
|
+
const data = fulfillment.result.data[0];
|
|
49
|
+
return Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
50
|
+
}
|
|
51
|
+
function configureMultipart(fulfillment, res) {
|
|
52
|
+
const response = core_common_1.RpcMultipart.createStream(fulfillment.result);
|
|
53
|
+
const headers = response.getHeaders();
|
|
54
|
+
for (const header in headers) {
|
|
55
|
+
if (headers.hasOwnProperty(header)) {
|
|
56
|
+
res.set(header, headers[header]);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return response;
|
|
60
|
+
}
|
|
61
|
+
function configureStream(fulfillment) {
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
63
|
+
return fulfillment.result.stream;
|
|
64
|
+
}
|
|
65
|
+
/** @internal */
|
|
66
|
+
async function sendResponse(protocol, request, fulfillment, req, res) {
|
|
67
|
+
var _a;
|
|
68
|
+
const versionHeader = protocol.protocolVersionHeaderName;
|
|
69
|
+
if (versionHeader && core_common_1.RpcProtocol.protocolVersion) {
|
|
70
|
+
res.set(versionHeader, core_common_1.RpcProtocol.protocolVersion.toString());
|
|
71
|
+
}
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
73
|
+
const { Readable, Stream } = await Promise.resolve().then(() => require(/* webpackIgnore: true */ "stream"));
|
|
74
|
+
const { createGzip } = await Promise.resolve().then(() => require(/* webpackIgnore: true */ "zlib"));
|
|
75
|
+
const transportType = core_common_1.WebAppRpcRequest.computeTransportType(fulfillment.result, fulfillment.rawResult);
|
|
76
|
+
let responseBody;
|
|
77
|
+
if (transportType === core_common_1.RpcContentType.Binary) {
|
|
78
|
+
responseBody = configureBinary(fulfillment, res);
|
|
79
|
+
}
|
|
80
|
+
else if (transportType === core_common_1.RpcContentType.Multipart) {
|
|
81
|
+
responseBody = configureMultipart(fulfillment, res);
|
|
82
|
+
}
|
|
83
|
+
else if (transportType === core_common_1.RpcContentType.Stream) {
|
|
84
|
+
responseBody = configureStream(fulfillment);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
responseBody = configureText(fulfillment, res);
|
|
88
|
+
}
|
|
89
|
+
configureResponse(protocol, request, fulfillment, res);
|
|
90
|
+
res.status(fulfillment.status);
|
|
91
|
+
if (fulfillment.allowCompression && ((_a = req.header("Accept-Encoding")) === null || _a === void 0 ? void 0 : _a.includes("gzip"))) {
|
|
92
|
+
res.set("Content-Encoding", "gzip");
|
|
93
|
+
const readableResponseBody = (responseBody instanceof Stream) ? responseBody : Readable.from(responseBody);
|
|
94
|
+
responseBody = readableResponseBody.pipe(createGzip());
|
|
95
|
+
}
|
|
96
|
+
// This check should in theory look for instances of Readable, but that would break backend implementation at
|
|
97
|
+
// core/backend/src/RpcBackend.ts
|
|
98
|
+
if (responseBody instanceof Stream) {
|
|
99
|
+
responseBody.pipe(res);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
res.send(responseBody);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.sendResponse = sendResponse;
|
|
106
|
+
//# sourceMappingURL=response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/rpc/web/response.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAc4B;AAE5B,SAAS,iBAAiB,CAAC,QAA2B,EAAE,OA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C,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;QACpC,MAAM,oBAAoB,GAAG,CAAC,YAAY,YAAY,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3G,YAAY,GAAG,oBAAoB,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;KACxD;IAED,6GAA6G;IAC7G,iCAAiC;IACjC,IAAI,YAAY,YAAY,MAAM,EAAE;QAClC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACxB;SAAM;QACL,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;KACxB;AACH,CAAC;AArCD,oCAqCC","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 RpcInterface\r\n */\r\n\r\nimport {\r\n HttpServerRequest,\r\n HttpServerResponse,\r\n ReadableFormData,\r\n RpcContentType,\r\n RpcMultipart,\r\n RpcProtocol,\r\n RpcRequestFulfillment,\r\n RpcRequestStatus,\r\n RpcResponseCacheControl,\r\n SerializedRpcRequest,\r\n WEB_RPC_CONSTANTS,\r\n WebAppRpcProtocol,\r\n WebAppRpcRequest,\r\n} from \"@itwin/core-common\";\r\n\r\nfunction configureResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse) {\r\n const success = protocol.getStatus(fulfillment.status) === RpcRequestStatus.Resolved;\r\n // TODO: Use stale-while-revalidate in cache headers. This needs to be tested, and does not currently have support in the router/caching-service.\r\n // This will allow browsers to use stale cached responses while also revalidating with the router, allowing us to start up a backend if necessary.\r\n\r\n // RPC Caching Service uses the s-maxage header to determine the TTL for the redis cache.\r\n const oneHourInSeconds = 3600;\r\n if (success && request.caching === RpcResponseCacheControl.Immutable) {\r\n // If response size is > 50 MB, do not cache it.\r\n if (fulfillment.result.objects.length > (50 * 10 ** 7)) {\r\n res.set(\"Cache-Control\", \"no-store\");\r\n } else if (request.operation.operationName === \"generateTileContent\") {\r\n res.set(\"Cache-Control\", \"no-store\");\r\n } else if (request.operation.operationName === \"getConnectionProps\") {\r\n // GetConnectionprops can't be cached on the browser longer than the lifespan of the backend. The lifespan of backend may shrink too. Keep it at 1 second to be safe.\r\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 24}, max-age=1, immutable`);\r\n } else if (request.operation.operationName === \"getTileCacheContainerUrl\") {\r\n // getTileCacheContainerUrl returns a SAS with an expiry of 23:59:59. We can't exceed that time when setting the max-age.\r\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 23}, max-age=${oneHourInSeconds * 23}, immutable`);\r\n } else {\r\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 24}, max-age=${oneHourInSeconds * 48}, immutable`);\r\n }\r\n }\r\n\r\n if (fulfillment.retry) {\r\n res.set(\"Retry-After\", fulfillment.retry);\r\n }\r\n}\r\n\r\nfunction configureText(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): string {\r\n res.set(WEB_RPC_CONSTANTS.CONTENT, WEB_RPC_CONSTANTS.TEXT);\r\n return (fulfillment.status === 204) ? \"\" : fulfillment.result.objects;\r\n}\r\n\r\nfunction configureBinary(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): Buffer {\r\n res.set(WEB_RPC_CONSTANTS.CONTENT, WEB_RPC_CONSTANTS.BINARY);\r\n const data = fulfillment.result.data[0];\r\n return Buffer.isBuffer(data) ? data : Buffer.from(data);\r\n}\r\n\r\nfunction configureMultipart(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): ReadableFormData {\r\n const response = RpcMultipart.createStream(fulfillment.result);\r\n const headers = response.getHeaders();\r\n for (const header in headers) {\r\n if (headers.hasOwnProperty(header)) {\r\n res.set(header, headers[header]);\r\n }\r\n }\r\n\r\n return response;\r\n}\r\n\r\nfunction configureStream(fulfillment: RpcRequestFulfillment) {\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n return fulfillment.result.stream!;\r\n}\r\n\r\n/** @internal */\r\nexport async function sendResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, req: HttpServerRequest, res: HttpServerResponse) {\r\n const versionHeader = protocol.protocolVersionHeaderName;\r\n if (versionHeader && RpcProtocol.protocolVersion) {\r\n res.set(versionHeader, RpcProtocol.protocolVersion.toString());\r\n }\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n const { Readable, Stream } = await import(/* webpackIgnore: true */ \"stream\");\r\n const { createGzip } = await import(/* webpackIgnore: true */ \"zlib\");\r\n\r\n const transportType = WebAppRpcRequest.computeTransportType(fulfillment.result, fulfillment.rawResult);\r\n let responseBody;\r\n if (transportType === RpcContentType.Binary) {\r\n responseBody = configureBinary(fulfillment, res);\r\n } else if (transportType === RpcContentType.Multipart) {\r\n responseBody = configureMultipart(fulfillment, res);\r\n } else if (transportType === RpcContentType.Stream) {\r\n responseBody = configureStream(fulfillment);\r\n } else {\r\n responseBody = configureText(fulfillment, res);\r\n }\r\n\r\n configureResponse(protocol, request, fulfillment, res);\r\n res.status(fulfillment.status);\r\n\r\n if (fulfillment.allowCompression && req.header(\"Accept-Encoding\")?.includes(\"gzip\")) {\r\n res.set(\"Content-Encoding\", \"gzip\");\r\n const readableResponseBody = (responseBody instanceof Stream) ? responseBody : Readable.from(responseBody);\r\n responseBody = readableResponseBody.pipe(createGzip());\r\n }\r\n\r\n // This check should in theory look for instances of Readable, but that would break backend implementation at\r\n // core/backend/src/RpcBackend.ts\r\n if (responseBody instanceof Stream) {\r\n responseBody.pipe(res);\r\n } else {\r\n res.send(responseBody);\r\n }\r\n}\r\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module RpcInterface
|
|
3
3
|
*/
|
|
4
4
|
import { CompressedId64Set, GuidString, Id64String } from "@itwin/core-bentley";
|
|
5
|
-
import { CodeProps, CustomViewState3dCreatorOptions, CustomViewState3dProps, DbBlobRequest, DbBlobResponse, DbQueryRequest, DbQueryResponse, ElementLoadOptions, ElementProps, EntityQueryParams, FontMapProps, GeoCoordinatesRequestProps, GeoCoordinatesResponseProps, GeometryContainmentRequestProps, GeometryContainmentResponseProps, GeometrySummaryRequestProps, HydrateViewStateRequestProps, HydrateViewStateResponseProps, IModelConnectionProps, IModelCoordinatesRequestProps, IModelCoordinatesResponseProps, IModelReadRpcInterface, IModelRpcOpenProps, IModelRpcProps, MassPropertiesPerCandidateRequestProps, MassPropertiesPerCandidateResponseProps, MassPropertiesRequestProps, MassPropertiesResponseProps, ModelProps, RpcInterface, SnapRequestProps, SnapResponseProps, SubCategoryResultRow, TextureData, TextureLoadProps, ViewStateLoadProps, ViewStateProps } from "@itwin/core-common";
|
|
5
|
+
import { CodeProps, CustomViewState3dCreatorOptions, CustomViewState3dProps, DbBlobRequest, DbBlobResponse, DbQueryRequest, DbQueryResponse, ElementLoadOptions, ElementMeshRequestProps, ElementProps, EntityQueryParams, FontMapProps, GeoCoordinatesRequestProps, GeoCoordinatesResponseProps, GeometryContainmentRequestProps, GeometryContainmentResponseProps, GeometrySummaryRequestProps, HydrateViewStateRequestProps, HydrateViewStateResponseProps, IModelConnectionProps, IModelCoordinatesRequestProps, IModelCoordinatesResponseProps, IModelReadRpcInterface, IModelRpcOpenProps, IModelRpcProps, MassPropertiesPerCandidateRequestProps, MassPropertiesPerCandidateResponseProps, MassPropertiesRequestProps, MassPropertiesResponseProps, ModelExtentsProps, ModelProps, RpcInterface, SnapRequestProps, SnapResponseProps, SubCategoryResultRow, TextureData, TextureLoadProps, ViewStateLoadProps, ViewStateProps } from "@itwin/core-common";
|
|
6
6
|
import { Range3dProps } from "@itwin/core-geometry";
|
|
7
7
|
/** The backend implementation of IModelReadRpcInterface.
|
|
8
8
|
* @internal
|
|
@@ -15,7 +15,8 @@ export declare class IModelReadRpcImpl extends RpcInterface implements IModelRea
|
|
|
15
15
|
querySubCategories(tokenProps: IModelRpcProps, compressedCategoryIds: CompressedId64Set): Promise<SubCategoryResultRow[]>;
|
|
16
16
|
queryRows(tokenProps: IModelRpcProps, request: DbQueryRequest): Promise<DbQueryResponse>;
|
|
17
17
|
queryBlob(tokenProps: IModelRpcProps, request: DbBlobRequest): Promise<DbBlobResponse>;
|
|
18
|
-
queryModelRanges(tokenProps: IModelRpcProps,
|
|
18
|
+
queryModelRanges(tokenProps: IModelRpcProps, modelIds: Id64String[]): Promise<Range3dProps[]>;
|
|
19
|
+
queryModelExtents(tokenProps: IModelRpcProps, modelIds: Id64String[]): Promise<ModelExtentsProps[]>;
|
|
19
20
|
getModelProps(tokenProps: IModelRpcProps, modelIdsList: Id64String[]): Promise<ModelProps[]>;
|
|
20
21
|
queryModelProps(tokenProps: IModelRpcProps, params: EntityQueryParams): Promise<ModelProps[]>;
|
|
21
22
|
getElementProps(tokenProps: IModelRpcProps, elementIdsList: Id64String[]): Promise<ElementProps[]>;
|
|
@@ -42,5 +43,6 @@ export declare class IModelReadRpcImpl extends RpcInterface implements IModelRea
|
|
|
42
43
|
getIModelCoordinatesFromGeoCoordinates(tokenProps: IModelRpcProps, props: IModelCoordinatesRequestProps): Promise<IModelCoordinatesResponseProps>;
|
|
43
44
|
getGeoCoordinatesFromIModelCoordinates(tokenProps: IModelRpcProps, props: GeoCoordinatesRequestProps): Promise<GeoCoordinatesResponseProps>;
|
|
44
45
|
queryTextureData(tokenProps: IModelRpcProps, textureLoadProps: TextureLoadProps): Promise<TextureData | undefined>;
|
|
46
|
+
generateElementMeshes(iModelToken: IModelRpcProps, props: ElementMeshRequestProps): Promise<Uint8Array>;
|
|
45
47
|
}
|
|
46
48
|
//# sourceMappingURL=IModelReadRpcImpl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelReadRpcImpl.d.ts","sourceRoot":"","sources":["../../../src/rpc-impl/IModelReadRpcImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"IModelReadRpcImpl.d.ts","sourceRoot":"","sources":["../../../src/rpc-impl/IModelReadRpcImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAC2C,iBAAiB,EAAE,UAAU,EAAQ,UAAU,EAChG,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACC,SAAS,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,kBAAkB,EAC5J,uBAAuB,EAAE,YAAY,EAAkB,iBAAiB,EAAE,YAAY,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,+BAA+B,EAChL,gCAAgC,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,6BAA6B,EAC1H,qBAAqB,EAAE,6BAA6B,EAAE,8BAA8B,EAAe,sBAAsB,EAAE,kBAAkB,EAC7I,cAAc,EAAE,sCAAsC,EAAE,uCAAuC,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,iBAAiB,EAC3K,UAAU,EAAkB,YAAY,EAAkC,gBAAgB,EAAE,iBAAiB,EAAE,oBAAoB,EAAY,WAAW,EAAE,gBAAgB,EAC5K,kBAAkB,EAAE,cAAc,EACnC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAmEpD;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,YAAa,YAAW,sBAAsB;WAErE,QAAQ;IAET,kBAAkB,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIlF,wBAAwB,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAK/H,gBAAgB,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,4BAA4B,GAAG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