@itwin/core-common 3.2.6 → 3.2.9
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 +16 -1
- package/lib/cjs/rpc/core/RpcProtocol.d.ts +0 -2
- package/lib/cjs/rpc/core/RpcProtocol.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcProtocol.js +0 -2
- package/lib/cjs/rpc/core/RpcProtocol.js.map +1 -1
- package/lib/cjs/rpc/core/RpcRequest.d.ts +2 -4
- package/lib/cjs/rpc/core/RpcRequest.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcRequest.js +2 -8
- package/lib/cjs/rpc/core/RpcRequest.js.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcProtocol.d.ts +0 -6
- package/lib/cjs/rpc/web/WebAppRpcProtocol.d.ts.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcProtocol.js +0 -47
- package/lib/cjs/rpc/web/WebAppRpcProtocol.js.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcRequest.d.ts +0 -3
- package/lib/cjs/rpc/web/WebAppRpcRequest.d.ts.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcRequest.js +0 -15
- package/lib/cjs/rpc/web/WebAppRpcRequest.js.map +1 -1
- package/lib/esm/rpc/core/RpcProtocol.d.ts +0 -2
- package/lib/esm/rpc/core/RpcProtocol.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcProtocol.js +0 -2
- package/lib/esm/rpc/core/RpcProtocol.js.map +1 -1
- package/lib/esm/rpc/core/RpcRequest.d.ts +2 -4
- package/lib/esm/rpc/core/RpcRequest.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcRequest.js +2 -8
- package/lib/esm/rpc/core/RpcRequest.js.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcProtocol.d.ts +0 -6
- package/lib/esm/rpc/web/WebAppRpcProtocol.d.ts.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcProtocol.js +0 -47
- package/lib/esm/rpc/web/WebAppRpcProtocol.js.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcRequest.d.ts +0 -3
- package/lib/esm/rpc/web/WebAppRpcRequest.d.ts.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcRequest.js +0 -15
- package/lib/esm/rpc/web/WebAppRpcRequest.js.map +1 -1
- package/package.json +9 -9
|
@@ -134,18 +134,6 @@ class WebAppRpcRequest extends RpcRequest_1.RpcRequest {
|
|
|
134
134
|
return RpcConstants_1.RpcContentType.Text;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
/** @internal */
|
|
138
|
-
async preflight() {
|
|
139
|
-
this.method = "options";
|
|
140
|
-
this._request.method = "options";
|
|
141
|
-
await this.setHeaders();
|
|
142
|
-
await this.send();
|
|
143
|
-
return this._response;
|
|
144
|
-
}
|
|
145
|
-
isHeaderAvailable(name) {
|
|
146
|
-
const allowed = this.protocol.allowedHeaders;
|
|
147
|
-
return allowed.has("*") || allowed.has(name);
|
|
148
|
-
}
|
|
149
137
|
/** Sets request header values. */
|
|
150
138
|
setHeader(name, value) {
|
|
151
139
|
this._headers[name] = value;
|
|
@@ -316,9 +304,6 @@ class WebAppRpcRequest extends RpcRequest_1.RpcRequest {
|
|
|
316
304
|
return value;
|
|
317
305
|
}
|
|
318
306
|
async setupTransport() {
|
|
319
|
-
if (this.method === "options") {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
307
|
const parameters = (await this.protocol.serialize(this)).parameters;
|
|
323
308
|
const transportType = WebAppRpcRequest.computeTransportType(parameters, this.parameters);
|
|
324
309
|
if (transportType === RpcConstants_1.RpcContentType.Binary) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebAppRpcRequest.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcRequest.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AACpD,mCAAgC;AAChC,mDAA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Q,CAAC,gCAAiB,CAAC,OAAO,CAAC,CAAC;gBAChD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;gBAC/B,OAAO;aACR;SACF;QAED,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,QAAQ,CAAC,gCAAiB,CAAC,OAAO,CAAC,GAAG,gCAAiB,CAAC,IAAI,CAAC;QAClE,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC;IAC1C,CAAC;;AAvYH,4CAwYC;AAlYC;;GAEG;AACW,oCAAmB,GAAG,IAAI,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { Buffer } from \"buffer\";\r\nimport { IModelError, ServerError, ServerTimeoutError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcContentType, RpcProtocolEvent, RpcRequestStatus, RpcResponseCacheControl, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\r\nimport { SerializedRpcActivity } from \"../core/RpcInvocation\";\r\nimport { MarshalingBinaryMarker, RpcSerializedValue } from \"../core/RpcMarshaling\";\r\nimport { RpcProtocol, RpcRequestFulfillment, SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { RpcRequest } from \"../core/RpcRequest\";\r\nimport { RpcMultipartParser } from \"./multipart/RpcMultipartParser\";\r\nimport { ReadableFormData, RpcMultipart } from \"./RpcMultipart\";\r\nimport { HttpServerRequest, HttpServerResponse, WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\r\n\r\n/** @internal */\r\nexport type HttpMethod_T = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\"; // eslint-disable-line @typescript-eslint/naming-convention\r\n\r\n/** A web application RPC request.\r\n * @internal\r\n */\r\nexport class WebAppRpcRequest extends RpcRequest {\r\n private _loading: boolean = false;\r\n private _request: RequestInit = {};\r\n private _pathSuffix: string = \"\";\r\n private get _headers() { return this._request.headers as { [key: string]: string }; }\r\n\r\n /** The maximum size permitted for an encoded component in a URL.\r\n * @note This is used for features like encoding the payload of a cacheable request in the URL.\r\n */\r\n public static maxUrlComponentSize = 4096;\r\n\r\n /** The HTTP method for this request. */\r\n public override method: HttpMethod_T;\r\n\r\n /** Convenience access to the protocol of this request. */\r\n public override readonly protocol: WebAppRpcProtocol = this.client.configuration.protocol as any;\r\n\r\n /** Standardized access to metadata about the request (useful for purposes such as logging). */\r\n public metadata = { status: 0, message: \"\" };\r\n\r\n /** Parse headers */\r\n private static 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\n /** Parses a request. */\r\n public static async parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest> {\r\n const operation = protocol.getOperationFromPath(req.url!);\r\n\r\n const parsedHeaders = this.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 path: req.url!,\r\n parameters: operation.encodedRequest ? WebAppRpcRequest.parseFromPath(operation) : await WebAppRpcRequest.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.`);\r\n }\r\n\r\n return request;\r\n }\r\n\r\n /** Sends the response for a web request. */\r\n public static async sendResponse(\r\n protocol: WebAppRpcProtocol,\r\n request: SerializedRpcRequest,\r\n fulfillment: RpcRequestFulfillment,\r\n req: HttpServerRequest,\r\n res: HttpServerResponse,\r\n ): Promise<void> {\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 = WebAppRpcRequest.configureBinary(fulfillment, res);\r\n } else if (transportType === RpcContentType.Multipart) {\r\n responseBody = WebAppRpcRequest.configureMultipart(fulfillment, res);\r\n } else if (transportType === RpcContentType.Stream) {\r\n responseBody = WebAppRpcRequest.configureStream(fulfillment);\r\n } else {\r\n responseBody = WebAppRpcRequest.configureText(fulfillment, res);\r\n }\r\n\r\n WebAppRpcRequest.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\r\n /** Determines the most efficient transport type for an RPC value. */\r\n protected static computeTransportType(value: RpcSerializedValue, source: any): RpcContentType {\r\n if (source instanceof Uint8Array || (Array.isArray(source) && source[0] instanceof Uint8Array)) {\r\n return RpcContentType.Binary;\r\n } else if (value.data.length > 0) {\r\n return RpcContentType.Multipart;\r\n } else if (value.stream) {\r\n return RpcContentType.Stream;\r\n } else {\r\n return RpcContentType.Text;\r\n }\r\n }\r\n\r\n /** Constructs a web application request. */\r\n public constructor(client: RpcInterface, operation: string, parameters: any[]) {\r\n super(client, operation, parameters);\r\n this.path = this.protocol.supplyPathForOperation(this.operation, this);\r\n this.method = \"head\";\r\n this._request.headers = {};\r\n }\r\n\r\n /** @internal */\r\n public async preflight(): Promise<Response | undefined> {\r\n this.method = \"options\";\r\n this._request.method = \"options\";\r\n await this.setHeaders();\r\n await this.send();\r\n return this._response;\r\n }\r\n\r\n protected override isHeaderAvailable(name: string): boolean {\r\n const allowed = this.protocol.allowedHeaders;\r\n return allowed.has(\"*\") || allowed.has(name);\r\n }\r\n\r\n /** Sets request header values. */\r\n protected setHeader(name: string, value: string): void {\r\n this._headers[name] = value;\r\n }\r\n\r\n /** Sends the request. */\r\n protected async send(): Promise<number> {\r\n this._loading = true;\r\n await this.setupTransport();\r\n\r\n return new Promise<number>(async (resolve, reject) => {\r\n try {\r\n resolve(await this.performFetch());\r\n } catch (reason) {\r\n reject(new ServerError(-1, typeof (reason) === \"string\" ? reason : \"Server connection error.\"));\r\n }\r\n });\r\n }\r\n\r\n protected override computeRetryAfter(attempts: number): number {\r\n const retryAfter = this._response && this._response.headers.get(\"Retry-After\");\r\n if (retryAfter) {\r\n this.resetTransientFaultCount();\r\n\r\n const r = Number(retryAfter);\r\n if (Number.isFinite(r)) {\r\n return r * 1000;\r\n }\r\n\r\n const d = Date.parse(retryAfter);\r\n if (!Number.isNaN(d)) {\r\n return d - Date.now();\r\n }\r\n } else {\r\n this.recordTransientFault();\r\n }\r\n\r\n return super.computeRetryAfter(attempts);\r\n }\r\n\r\n protected override handleUnknownResponse(code: number) {\r\n if (this.protocol.isTimeout(code)) {\r\n this.reject(new ServerTimeoutError(\"Request timeout.\"));\r\n } else {\r\n this.reject(new ServerError(code, \"Unknown server response code.\"));\r\n }\r\n }\r\n\r\n protected async load(): Promise<RpcSerializedValue> {\r\n return new Promise<RpcSerializedValue>(async (resolve, reject) => {\r\n try {\r\n if (!this._loading)\r\n return;\r\n\r\n const response = this._response;\r\n if (!response) {\r\n reject(new IModelError(BentleyStatus.ERROR, \"Invalid state.\"));\r\n return;\r\n }\r\n\r\n if (this.protocol.protocolVersionHeaderName) {\r\n const version = response.headers.get(this.protocol.protocolVersionHeaderName);\r\n if (version) {\r\n this.responseProtocolVersion = parseInt(version, 10);\r\n }\r\n }\r\n\r\n const contentType = response.headers.get(WEB_RPC_CONSTANTS.CONTENT);\r\n const responseType = WebAppRpcProtocol.computeContentType(contentType);\r\n\r\n if (responseType === RpcContentType.Binary) {\r\n resolve(await this.loadBinary(response));\r\n } else if (responseType === RpcContentType.Multipart) {\r\n resolve(await this.loadMultipart(response, contentType!));\r\n } else {\r\n resolve(await this.loadText(response));\r\n }\r\n\r\n this._loading = false;\r\n this.setLastUpdatedTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoaded, this);\r\n } catch (reason) {\r\n if (!this._loading)\r\n return;\r\n\r\n this._loading = false;\r\n reject(new ServerError(this.metadata.status, typeof (reason) === \"string\" ? reason : \"Unknown server response error.\"));\r\n }\r\n });\r\n }\r\n\r\n /** Override to supply an alternate fetch function. */\r\n protected supplyFetch(): typeof fetch {\r\n return fetch;\r\n }\r\n\r\n /** Override to supply an alternate Request function. */\r\n protected supplyRequest(): typeof Request {\r\n return Request;\r\n }\r\n\r\n private static configureResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse) {\r\n const success = protocol.getStatus(fulfillment.status) === RpcRequestStatus.Resolved;\r\n\r\n if (success && request.caching === RpcResponseCacheControl.Immutable) {\r\n res.set(\"Cache-Control\", \"private, max-age=31536000, immutable\");\r\n }\r\n\r\n if (fulfillment.retry) {\r\n res.set(\"Retry-After\", fulfillment.retry);\r\n }\r\n }\r\n\r\n private static 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\n private static 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\n private static 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\n private static configureStream(fulfillment: RpcRequestFulfillment) {\r\n return fulfillment.result.stream!;\r\n }\r\n\r\n private static 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\n private static async 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 private async performFetch(): Promise<number> {\r\n const requestClass = this.supplyRequest();\r\n const fetchFunction = this.supplyFetch();\r\n\r\n const path = new URL(this.path, typeof (location) !== \"undefined\" ? location.origin : undefined);\r\n if (this._pathSuffix) {\r\n const params = new URLSearchParams();\r\n params.set(\"parameters\", this._pathSuffix);\r\n path.search = `?${params.toString()}`;\r\n }\r\n\r\n const request = new requestClass(path.toString(), this._request);\r\n const response = await fetchFunction(request);\r\n this._response = response;\r\n this.metadata.status = response.status;\r\n return response.status;\r\n }\r\n\r\n private async loadText(response: Response) {\r\n const value = await response.text();\r\n this.metadata.message = value;\r\n return RpcSerializedValue.create(value);\r\n }\r\n\r\n private async loadBinary(response: Response) {\r\n const value = new Uint8Array(await response.arrayBuffer());\r\n const objects = JSON.stringify(MarshalingBinaryMarker.createDefault());\r\n return RpcSerializedValue.create(objects, [value]);\r\n }\r\n\r\n private async loadMultipart(response: Response, contentType: string) {\r\n const data = await response.arrayBuffer();\r\n const value = new RpcMultipartParser(contentType, Buffer.from(data)).parse();\r\n return value;\r\n }\r\n\r\n private async setupTransport(): Promise<void> {\r\n if (this.method === \"options\") {\r\n return;\r\n }\r\n\r\n const parameters = (await this.protocol.serialize(this)).parameters;\r\n const transportType = WebAppRpcRequest.computeTransportType(parameters, this.parameters);\r\n\r\n if (transportType === RpcContentType.Binary) {\r\n this.setupBinaryTransport(parameters);\r\n } else if (transportType === RpcContentType.Multipart) {\r\n this.setupMultipartTransport(parameters);\r\n } else {\r\n this.setupTextTransport(parameters);\r\n }\r\n }\r\n\r\n private setupBinaryTransport(parameters: RpcSerializedValue) {\r\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.BINARY;\r\n this._request.method = \"post\";\r\n this._request.body = parameters.data[0];\r\n }\r\n\r\n private setupMultipartTransport(parameters: RpcSerializedValue) {\r\n // IMPORTANT: do not set a multipart Content-Type header value. The browser does this automatically!\r\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\r\n this._request.method = \"post\";\r\n this._request.body = RpcMultipart.createForm(parameters);\r\n }\r\n\r\n private setupTextTransport(parameters: RpcSerializedValue) {\r\n if (this.operation.policy.allowResponseCaching(this)) {\r\n const encodedBody = btoa(parameters.objects); // eslint-disable-line deprecation/deprecation\r\n if (encodedBody.length <= WebAppRpcRequest.maxUrlComponentSize) {\r\n this._request.method = \"get\";\r\n this._request.body = undefined;\r\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\r\n this._pathSuffix = encodedBody;\r\n return;\r\n }\r\n }\r\n\r\n this._pathSuffix = \"\";\r\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.TEXT;\r\n this._request.method = \"post\";\r\n this._request.body = parameters.objects;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"WebAppRpcRequest.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcRequest.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AACpD,mCAAgC;AAChC,mDAAiF;AAEjF,uDAAsI;AAEtI,yDAAmF;AACnF,qDAAuH;AACvH,mDAAgD;AAChD,uEAAoE;AACpE,iDAAgE;AAChE,2DAA+F;AAK/F;;GAEG;AACH,MAAa,gBAAiB,SAAQ,uBAAU;IAiI9C,4CAA4C;IAC5C,YAAmB,MAAoB,EAAE,SAAiB,EAAE,UAAiB;QAC3E,KAAK,CAAC,MAAM,EAAE,S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AC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC3D,CAAC;IAEO,kBAAkB,CAAC,UAA8B;QACvD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE;YACpD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,8CAA8C;YAC5F,IAAI,WAAW,CAAC,MAAM,IAAI,gBAAgB,CAAC,mBAAmB,EAAE;gBAC9D,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC;gBAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,SAAS,CAAC;gBAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,gCAAiB,CAAC,OAAO,CAAC,CAAC;gBAChD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;gBAC/B,OAAO;aACR;SACF;QAED,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,QAAQ,CAAC,gCAAiB,CAAC,OAAO,CAAC,GAAG,gCAAiB,CAAC,IAAI,CAAC;QAClE,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC;IAC1C,CAAC;;AArXH,4CAsXC;AAhXC;;GAEG;AACW,oCAAmB,GAAG,IAAI,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { Buffer } from \"buffer\";\r\nimport { IModelError, ServerError, ServerTimeoutError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcContentType, RpcProtocolEvent, RpcRequestStatus, RpcResponseCacheControl, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\r\nimport { SerializedRpcActivity } from \"../core/RpcInvocation\";\r\nimport { MarshalingBinaryMarker, RpcSerializedValue } from \"../core/RpcMarshaling\";\r\nimport { RpcProtocol, RpcRequestFulfillment, SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { RpcRequest } from \"../core/RpcRequest\";\r\nimport { RpcMultipartParser } from \"./multipart/RpcMultipartParser\";\r\nimport { ReadableFormData, RpcMultipart } from \"./RpcMultipart\";\r\nimport { HttpServerRequest, HttpServerResponse, WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\r\n\r\n/** @internal */\r\nexport type HttpMethod_T = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\"; // eslint-disable-line @typescript-eslint/naming-convention\r\n\r\n/** A web application RPC request.\r\n * @internal\r\n */\r\nexport class WebAppRpcRequest extends RpcRequest {\r\n private _loading: boolean = false;\r\n private _request: RequestInit = {};\r\n private _pathSuffix: string = \"\";\r\n private get _headers() { return this._request.headers as { [key: string]: string }; }\r\n\r\n /** The maximum size permitted for an encoded component in a URL.\r\n * @note This is used for features like encoding the payload of a cacheable request in the URL.\r\n */\r\n public static maxUrlComponentSize = 4096;\r\n\r\n /** The HTTP method for this request. */\r\n public override method: HttpMethod_T;\r\n\r\n /** Convenience access to the protocol of this request. */\r\n public override readonly protocol: WebAppRpcProtocol = this.client.configuration.protocol as any;\r\n\r\n /** Standardized access to metadata about the request (useful for purposes such as logging). */\r\n public metadata = { status: 0, message: \"\" };\r\n\r\n /** Parse headers */\r\n private static 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\n /** Parses a request. */\r\n public static async parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest> {\r\n const operation = protocol.getOperationFromPath(req.url!);\r\n\r\n const parsedHeaders = this.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 path: req.url!,\r\n parameters: operation.encodedRequest ? WebAppRpcRequest.parseFromPath(operation) : await WebAppRpcRequest.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.`);\r\n }\r\n\r\n return request;\r\n }\r\n\r\n /** Sends the response for a web request. */\r\n public static async sendResponse(\r\n protocol: WebAppRpcProtocol,\r\n request: SerializedRpcRequest,\r\n fulfillment: RpcRequestFulfillment,\r\n req: HttpServerRequest,\r\n res: HttpServerResponse,\r\n ): Promise<void> {\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 = WebAppRpcRequest.configureBinary(fulfillment, res);\r\n } else if (transportType === RpcContentType.Multipart) {\r\n responseBody = WebAppRpcRequest.configureMultipart(fulfillment, res);\r\n } else if (transportType === RpcContentType.Stream) {\r\n responseBody = WebAppRpcRequest.configureStream(fulfillment);\r\n } else {\r\n responseBody = WebAppRpcRequest.configureText(fulfillment, res);\r\n }\r\n\r\n WebAppRpcRequest.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\r\n /** Determines the most efficient transport type for an RPC value. */\r\n protected static computeTransportType(value: RpcSerializedValue, source: any): RpcContentType {\r\n if (source instanceof Uint8Array || (Array.isArray(source) && source[0] instanceof Uint8Array)) {\r\n return RpcContentType.Binary;\r\n } else if (value.data.length > 0) {\r\n return RpcContentType.Multipart;\r\n } else if (value.stream) {\r\n return RpcContentType.Stream;\r\n } else {\r\n return RpcContentType.Text;\r\n }\r\n }\r\n\r\n /** Constructs a web application request. */\r\n public constructor(client: RpcInterface, operation: string, parameters: any[]) {\r\n super(client, operation, parameters);\r\n this.path = this.protocol.supplyPathForOperation(this.operation, this);\r\n this.method = \"head\";\r\n this._request.headers = {};\r\n }\r\n\r\n /** Sets request header values. */\r\n protected setHeader(name: string, value: string): void {\r\n this._headers[name] = value;\r\n }\r\n\r\n /** Sends the request. */\r\n protected async send(): Promise<number> {\r\n this._loading = true;\r\n await this.setupTransport();\r\n\r\n return new Promise<number>(async (resolve, reject) => {\r\n try {\r\n resolve(await this.performFetch());\r\n } catch (reason) {\r\n reject(new ServerError(-1, typeof (reason) === \"string\" ? reason : \"Server connection error.\"));\r\n }\r\n });\r\n }\r\n\r\n protected override computeRetryAfter(attempts: number): number {\r\n const retryAfter = this._response && this._response.headers.get(\"Retry-After\");\r\n if (retryAfter) {\r\n this.resetTransientFaultCount();\r\n\r\n const r = Number(retryAfter);\r\n if (Number.isFinite(r)) {\r\n return r * 1000;\r\n }\r\n\r\n const d = Date.parse(retryAfter);\r\n if (!Number.isNaN(d)) {\r\n return d - Date.now();\r\n }\r\n } else {\r\n this.recordTransientFault();\r\n }\r\n\r\n return super.computeRetryAfter(attempts);\r\n }\r\n\r\n protected override handleUnknownResponse(code: number) {\r\n if (this.protocol.isTimeout(code)) {\r\n this.reject(new ServerTimeoutError(\"Request timeout.\"));\r\n } else {\r\n this.reject(new ServerError(code, \"Unknown server response code.\"));\r\n }\r\n }\r\n\r\n protected async load(): Promise<RpcSerializedValue> {\r\n return new Promise<RpcSerializedValue>(async (resolve, reject) => {\r\n try {\r\n if (!this._loading)\r\n return;\r\n\r\n const response = this._response;\r\n if (!response) {\r\n reject(new IModelError(BentleyStatus.ERROR, \"Invalid state.\"));\r\n return;\r\n }\r\n\r\n if (this.protocol.protocolVersionHeaderName) {\r\n const version = response.headers.get(this.protocol.protocolVersionHeaderName);\r\n if (version) {\r\n this.responseProtocolVersion = parseInt(version, 10);\r\n }\r\n }\r\n\r\n const contentType = response.headers.get(WEB_RPC_CONSTANTS.CONTENT);\r\n const responseType = WebAppRpcProtocol.computeContentType(contentType);\r\n\r\n if (responseType === RpcContentType.Binary) {\r\n resolve(await this.loadBinary(response));\r\n } else if (responseType === RpcContentType.Multipart) {\r\n resolve(await this.loadMultipart(response, contentType!));\r\n } else {\r\n resolve(await this.loadText(response));\r\n }\r\n\r\n this._loading = false;\r\n this.setLastUpdatedTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoaded, this);\r\n } catch (reason) {\r\n if (!this._loading)\r\n return;\r\n\r\n this._loading = false;\r\n reject(new ServerError(this.metadata.status, typeof (reason) === \"string\" ? reason : \"Unknown server response error.\"));\r\n }\r\n });\r\n }\r\n\r\n /** Override to supply an alternate fetch function. */\r\n protected supplyFetch(): typeof fetch {\r\n return fetch;\r\n }\r\n\r\n /** Override to supply an alternate Request function. */\r\n protected supplyRequest(): typeof Request {\r\n return Request;\r\n }\r\n\r\n private static configureResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse) {\r\n const success = protocol.getStatus(fulfillment.status) === RpcRequestStatus.Resolved;\r\n\r\n if (success && request.caching === RpcResponseCacheControl.Immutable) {\r\n res.set(\"Cache-Control\", \"private, max-age=31536000, immutable\");\r\n }\r\n\r\n if (fulfillment.retry) {\r\n res.set(\"Retry-After\", fulfillment.retry);\r\n }\r\n }\r\n\r\n private static 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\n private static 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\n private static 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\n private static configureStream(fulfillment: RpcRequestFulfillment) {\r\n return fulfillment.result.stream!;\r\n }\r\n\r\n private static 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\n private static async 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 private async performFetch(): Promise<number> {\r\n const requestClass = this.supplyRequest();\r\n const fetchFunction = this.supplyFetch();\r\n\r\n const path = new URL(this.path, typeof (location) !== \"undefined\" ? location.origin : undefined);\r\n if (this._pathSuffix) {\r\n const params = new URLSearchParams();\r\n params.set(\"parameters\", this._pathSuffix);\r\n path.search = `?${params.toString()}`;\r\n }\r\n\r\n const request = new requestClass(path.toString(), this._request);\r\n const response = await fetchFunction(request);\r\n this._response = response;\r\n this.metadata.status = response.status;\r\n return response.status;\r\n }\r\n\r\n private async loadText(response: Response) {\r\n const value = await response.text();\r\n this.metadata.message = value;\r\n return RpcSerializedValue.create(value);\r\n }\r\n\r\n private async loadBinary(response: Response) {\r\n const value = new Uint8Array(await response.arrayBuffer());\r\n const objects = JSON.stringify(MarshalingBinaryMarker.createDefault());\r\n return RpcSerializedValue.create(objects, [value]);\r\n }\r\n\r\n private async loadMultipart(response: Response, contentType: string) {\r\n const data = await response.arrayBuffer();\r\n const value = new RpcMultipartParser(contentType, Buffer.from(data)).parse();\r\n return value;\r\n }\r\n\r\n private async setupTransport(): Promise<void> {\r\n const parameters = (await this.protocol.serialize(this)).parameters;\r\n const transportType = WebAppRpcRequest.computeTransportType(parameters, this.parameters);\r\n\r\n if (transportType === RpcContentType.Binary) {\r\n this.setupBinaryTransport(parameters);\r\n } else if (transportType === RpcContentType.Multipart) {\r\n this.setupMultipartTransport(parameters);\r\n } else {\r\n this.setupTextTransport(parameters);\r\n }\r\n }\r\n\r\n private setupBinaryTransport(parameters: RpcSerializedValue) {\r\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.BINARY;\r\n this._request.method = \"post\";\r\n this._request.body = parameters.data[0];\r\n }\r\n\r\n private setupMultipartTransport(parameters: RpcSerializedValue) {\r\n // IMPORTANT: do not set a multipart Content-Type header value. The browser does this automatically!\r\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\r\n this._request.method = \"post\";\r\n this._request.body = RpcMultipart.createForm(parameters);\r\n }\r\n\r\n private setupTextTransport(parameters: RpcSerializedValue) {\r\n if (this.operation.policy.allowResponseCaching(this)) {\r\n const encodedBody = btoa(parameters.objects); // eslint-disable-line deprecation/deprecation\r\n if (encodedBody.length <= WebAppRpcRequest.maxUrlComponentSize) {\r\n this._request.method = \"get\";\r\n this._request.body = undefined;\r\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\r\n this._pathSuffix = encodedBody;\r\n return;\r\n }\r\n }\r\n\r\n this._pathSuffix = \"\";\r\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.TEXT;\r\n this._request.method = \"post\";\r\n this._request.body = parameters.objects;\r\n }\r\n}\r\n"]}
|
|
@@ -113,8 +113,6 @@ export declare abstract class RpcProtocol {
|
|
|
113
113
|
getOperationFromPath(path: string): SerializedRpcOperation;
|
|
114
114
|
/** Obtains the implementation result on the backend for an RPC operation request. */
|
|
115
115
|
fulfill(request: SerializedRpcRequest): Promise<RpcRequestFulfillment>;
|
|
116
|
-
/** @internal */
|
|
117
|
-
initialize(_token?: IModelRpcProps): Promise<void>;
|
|
118
116
|
/** Serializes a request. */
|
|
119
117
|
serialize(request: RpcRequest): Promise<SerializedRpcRequest>;
|
|
120
118
|
/** Constructs a protocol. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcProtocol.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcProtocol.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAiB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IACjE,SAAS,EAAE,sBAAsB,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,kBAAkB,CAAC;IAC/B,OAAO,EAAE,uBAAuB,CAAC;IACjC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B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AAM,GAAG,gBAAgB;IAIhD,qFAAqF;IAC9E,OAAO,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM;IAIhD,gFAAgF;IACzE,sBAAsB,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM;IAIhG,2EAA2E;IACpE,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB;IAIjE,qFAAqF;IACxE,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAInF,4BAA4B;IACf,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAiB1E,6BAA6B;gBACV,aAAa,EAAE,gBAAgB;IAKlD,gBAAgB;IACT,sBAAsB,CAAC,WAAW,EAAE,sBAAsB,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI;IAE/F,gBAAgB;IACT,oBAAoB,CAAC,WAAW,EAAE,sBAAsB,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI;IAE3F,gBAAgB;IACT,qBAAqB,CAAC,WAAW,EAAE,sBAAsB,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI;IAE9F,gBAAgB;IACT,mBAAmB,CAAC,WAAW,EAAE,sBAAsB,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI;CAC3F"}
|
|
@@ -91,8 +91,6 @@ export class RpcProtocol {
|
|
|
91
91
|
async fulfill(request) {
|
|
92
92
|
return new (this.invocationType)(this, request).fulfillment;
|
|
93
93
|
}
|
|
94
|
-
/** @internal */
|
|
95
|
-
async initialize(_token) { }
|
|
96
94
|
/** Serializes a request. */
|
|
97
95
|
async serialize(request) {
|
|
98
96
|
const serializedContext = await RpcConfiguration.requestContext.serialize(request);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcProtocol.ts"],"names":[],"mappings":"AAAA;;;+FAG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AgB;IACT,KAAK,CAAC,UAAU,CAAC,MAAuB,IAAmB,CAAC;IAEnE,4BAA4B;IACrB,KAAK,CAAC,SAAS,CAAC,OAAmB;QACxC,MAAM,iBAAiB,GAAG,MAAM,gBAAgB,CAAC,cAAc,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACnF,OAAO;YACL,GAAG,iBAAiB;YACpB,SAAS,EAAE;gBACT,mBAAmB,EAAE,OAAO,CAAC,SAAS,CAAC,mBAAmB,CAAC,aAAa;gBACxE,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC,aAAa;gBAC9C,gBAAgB,EAAE,OAAO,CAAC,SAAS,CAAC,gBAAgB;aACrD;YACD,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,UAAU,EAAE,MAAM,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC;YAC/E,OAAO,EAAE,uBAAuB,CAAC,IAAI;YACrC,eAAe,EAAE,WAAW,CAAC,eAAe;SAC7C,CAAC;IACJ,CAAC;IAQD,gBAAgB;IACT,sBAAsB,CAAC,WAAmC,EAAE,OAAqB,IAAU,CAAC;IAEnG,gBAAgB;IACT,oBAAoB,CAAC,WAAmC,EAAE,KAAmB,IAAU,CAAC;IAE/F,gBAAgB;IACT,qBAAqB,CAAC,WAAmC,EAAE,OAAqB,IAAU,CAAC;IAElG,gBAAgB;IACT,mBAAmB,CAAC,WAAmC,EAAE,KAAmB,IAAU,CAAC;;AAnH9F,+DAA+D;AACxC,kBAAM,GAAqC,IAAI,OAAO,EAAE,CAAC;AAEhF,oFAAoF;AAC7D,2BAAe,GAAW,kBAAkB,CAAC,wBAAwB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { RpcInterface, RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { RpcInvocation, SerializedRpcActivity } from \"./RpcInvocation\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/** A serialized RPC operation descriptor.\r\n * @internal\r\n */\r\nexport interface SerializedRpcOperation {\r\n interfaceDefinition: string;\r\n operationName: string;\r\n interfaceVersion: string;\r\n encodedRequest?: string;\r\n}\r\n\r\n/** A serialized RPC operation request.\r\n * @internal\r\n */\r\nexport interface SerializedRpcRequest extends SerializedRpcActivity {\r\n operation: SerializedRpcOperation;\r\n method: string;\r\n path: string;\r\n parameters: RpcSerializedValue;\r\n caching: RpcResponseCacheControl;\r\n ip?: string;\r\n protocolVersion?: number;\r\n}\r\n\r\n/** An RPC operation request fulfillment.\r\n * @internal\r\n */\r\nexport interface RpcRequestFulfillment {\r\n /** The RPC interface for the request. */\r\n interfaceName: string;\r\n\r\n /** The id for the request. */\r\n id: string;\r\n\r\n /** The result for the request. */\r\n result: RpcSerializedValue;\r\n\r\n /** The un-serialized result for the request. */\r\n rawResult: any;\r\n\r\n /** A protocol-specific status code value for the request. */\r\n status: number;\r\n\r\n /* A protocol-specific value for retrying this request. */\r\n retry?: string;\r\n\r\n /** Whether to compress the result with one of the client's supported encodings. */\r\n allowCompression?: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport namespace RpcRequestFulfillment {\r\n export async function forUnknownError(request: SerializedRpcRequest, error: any): Promise<RpcRequestFulfillment> {\r\n const result = await RpcMarshaling.serialize(undefined, error);\r\n\r\n return {\r\n interfaceName: request.operation.interfaceDefinition,\r\n id: request.id,\r\n result,\r\n rawResult: error,\r\n status: RpcRequestStatus.Rejected,\r\n };\r\n }\r\n}\r\n\r\n/** Handles RPC protocol events.\r\n * @internal\r\n */\r\nexport type RpcProtocolEventHandler = (type: RpcProtocolEvent, object: RpcRequest | RpcInvocation, err?: any) => void;\r\n\r\n/** Documents changes to the RPC protocol version.\r\n * @internal\r\n */\r\nexport enum RpcProtocolVersion {\r\n None = 0,\r\n IntroducedNoContent = 1,\r\n IntroducedStatusCategory = 2\r\n}\r\n\r\n/**\r\n * A backend response that is handled internally by the RPC system.\r\n * @internal\r\n */\r\nexport interface RpcManagedStatus {\r\n iTwinRpcCoreResponse: true;\r\n managedStatus: \"pending\" | \"notFound\";\r\n responseValue: string;\r\n}\r\n\r\n/** An application protocol for an RPC interface.\r\n * @internal\r\n */\r\nexport abstract class RpcProtocol {\r\n /** Events raised by all protocols. See [[RpcProtocolEvent]] */\r\n public static readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\r\n\r\n /** A version code that identifies the RPC protocol capabilties of this endpoint. */\r\n public static readonly protocolVersion: number = RpcProtocolVersion.IntroducedStatusCategory;\r\n\r\n /** The name of the RPC protocol version header. */\r\n public protocolVersionHeaderName = \"\";\r\n\r\n /** Events raised by the protocol. See [[RpcProtocolEvent]] */\r\n public readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\r\n\r\n /** The configuration for the protocol. */\r\n public readonly configuration: RpcConfiguration;\r\n\r\n /** The RPC request class for this protocol. */\r\n public abstract readonly requestType: typeof RpcRequest;\r\n\r\n /** The RPC invocation class for this protocol. */\r\n public readonly invocationType: typeof RpcInvocation = RpcInvocation;\r\n\r\n public serializedClientRequestContextHeaderNames: SerializedRpcActivity = {\r\n /** The name of the request id header. */\r\n id: \"\",\r\n\r\n /** The name of the application id header */\r\n applicationId: \"\",\r\n\r\n /** The name of the version header. */\r\n applicationVersion: \"\",\r\n\r\n /** The name of the session id header */\r\n sessionId: \"\",\r\n\r\n /** The name of the authorization header. */\r\n authorization: \"\",\r\n };\r\n\r\n /** If greater than zero, specifies where to break large binary request payloads. */\r\n public transferChunkThreshold: number = 0;\r\n\r\n /** Used by protocols that can transmit stream values natively. */\r\n public preserveStreams: boolean = false;\r\n\r\n /** Used by protocols that can transmit IModelRpcProps values natively. */\r\n public checkToken: boolean = false;\r\n\r\n /** Used by protocols that support user-defined status codes. */\r\n public supportsStatusCategory: boolean = false;\r\n\r\n /** If checkToken is true, will be called on the backend to inflate the IModelRpcProps for each request. */\r\n public inflateToken(tokenFromBody: IModelRpcProps, _request: SerializedRpcRequest): IModelRpcProps { return tokenFromBody; }\r\n\r\n /** Override to supply the status corresponding to a protocol-specific code value. */\r\n public getStatus(code: number): RpcRequestStatus {\r\n return code;\r\n }\r\n\r\n /** Override to supply the protocol-specific code corresponding to a status value. */\r\n public getCode(status: RpcRequestStatus): number {\r\n return status;\r\n }\r\n\r\n /** Override to supply the protocol-specific path value for an RPC operation. */\r\n public supplyPathForOperation(operation: RpcOperation, _request: RpcRequest | undefined): string {\r\n return JSON.stringify(operation);\r\n }\r\n\r\n /** Override to supply the operation for a protocol-specific path value. */\r\n public getOperationFromPath(path: string): SerializedRpcOperation {\r\n return JSON.parse(path);\r\n }\r\n\r\n /** Obtains the implementation result on the backend for an RPC operation request. */\r\n public async fulfill(request: SerializedRpcRequest): Promise<RpcRequestFulfillment> {\r\n return new (this.invocationType)(this, request).fulfillment;\r\n }\r\n\r\n /** @internal */\r\n public async initialize(_token?: IModelRpcProps): Promise<void> { }\r\n\r\n /** Serializes a request. */\r\n public async serialize(request: RpcRequest): Promise<SerializedRpcRequest> {\r\n const serializedContext = await RpcConfiguration.requestContext.serialize(request);\r\n return {\r\n ...serializedContext,\r\n operation: {\r\n interfaceDefinition: request.operation.interfaceDefinition.interfaceName,\r\n operationName: request.operation.operationName,\r\n interfaceVersion: request.operation.interfaceVersion,\r\n },\r\n method: request.method,\r\n path: request.path,\r\n parameters: await RpcMarshaling.serialize(request.protocol, request.parameters),\r\n caching: RpcResponseCacheControl.None,\r\n protocolVersion: RpcProtocol.protocolVersion,\r\n };\r\n }\r\n\r\n /** Constructs a protocol. */\r\n public constructor(configuration: RpcConfiguration) {\r\n this.configuration = configuration;\r\n this.events.addListener((type, object) => RpcProtocol.events.raiseEvent(type, object));\r\n }\r\n\r\n /** @internal */\r\n public onRpcClientInitialized(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcImplInitialized(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcClientTerminated(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcImplTerminated(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcProtocol.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAoB,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAyB,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAsB,MAAM,iBAAiB,CAAC;AAqDpE,gBAAgB;AAChB,MAAM,KAAW,qBAAqB,CAYrC;AAZD,WAAiB,qBAAqB;IAC7B,KAAK,UAAU,eAAe,CAAC,OAA6B,EAAE,KAAU;QAC7E,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAE/D,OAAO;YACL,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC,mBAAmB;YACpD,EAAE,EAAE,OAAO,CAA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,eAAe;SAC7C,CAAC;IACJ,CAAC;IAQD,gBAAgB;IACT,sBAAsB,CAAC,WAAmC,EAAE,OAAqB,IAAU,CAAC;IAEnG,gBAAgB;IACT,oBAAoB,CAAC,WAAmC,EAAE,KAAmB,IAAU,CAAC;IAE/F,gBAAgB;IACT,qBAAqB,CAAC,WAAmC,EAAE,OAAqB,IAAU,CAAC;IAElG,gBAAgB;IACT,mBAAmB,CAAC,WAAmC,EAAE,KAAmB,IAAU,CAAC;;AAhH9F,+DAA+D;AACxC,kBAAM,GAAqC,IAAI,OAAO,EAAE,CAAC;AAEhF,oFAAoF;AAC7D,2BAAe,GAAW,kBAAkB,CAAC,wBAAwB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { RpcInterface, RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { RpcInvocation, SerializedRpcActivity } from \"./RpcInvocation\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/** A serialized RPC operation descriptor.\r\n * @internal\r\n */\r\nexport interface SerializedRpcOperation {\r\n interfaceDefinition: string;\r\n operationName: string;\r\n interfaceVersion: string;\r\n encodedRequest?: string;\r\n}\r\n\r\n/** A serialized RPC operation request.\r\n * @internal\r\n */\r\nexport interface SerializedRpcRequest extends SerializedRpcActivity {\r\n operation: SerializedRpcOperation;\r\n method: string;\r\n path: string;\r\n parameters: RpcSerializedValue;\r\n caching: RpcResponseCacheControl;\r\n ip?: string;\r\n protocolVersion?: number;\r\n}\r\n\r\n/** An RPC operation request fulfillment.\r\n * @internal\r\n */\r\nexport interface RpcRequestFulfillment {\r\n /** The RPC interface for the request. */\r\n interfaceName: string;\r\n\r\n /** The id for the request. */\r\n id: string;\r\n\r\n /** The result for the request. */\r\n result: RpcSerializedValue;\r\n\r\n /** The un-serialized result for the request. */\r\n rawResult: any;\r\n\r\n /** A protocol-specific status code value for the request. */\r\n status: number;\r\n\r\n /* A protocol-specific value for retrying this request. */\r\n retry?: string;\r\n\r\n /** Whether to compress the result with one of the client's supported encodings. */\r\n allowCompression?: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport namespace RpcRequestFulfillment {\r\n export async function forUnknownError(request: SerializedRpcRequest, error: any): Promise<RpcRequestFulfillment> {\r\n const result = await RpcMarshaling.serialize(undefined, error);\r\n\r\n return {\r\n interfaceName: request.operation.interfaceDefinition,\r\n id: request.id,\r\n result,\r\n rawResult: error,\r\n status: RpcRequestStatus.Rejected,\r\n };\r\n }\r\n}\r\n\r\n/** Handles RPC protocol events.\r\n * @internal\r\n */\r\nexport type RpcProtocolEventHandler = (type: RpcProtocolEvent, object: RpcRequest | RpcInvocation, err?: any) => void;\r\n\r\n/** Documents changes to the RPC protocol version.\r\n * @internal\r\n */\r\nexport enum RpcProtocolVersion {\r\n None = 0,\r\n IntroducedNoContent = 1,\r\n IntroducedStatusCategory = 2\r\n}\r\n\r\n/**\r\n * A backend response that is handled internally by the RPC system.\r\n * @internal\r\n */\r\nexport interface RpcManagedStatus {\r\n iTwinRpcCoreResponse: true;\r\n managedStatus: \"pending\" | \"notFound\";\r\n responseValue: string;\r\n}\r\n\r\n/** An application protocol for an RPC interface.\r\n * @internal\r\n */\r\nexport abstract class RpcProtocol {\r\n /** Events raised by all protocols. See [[RpcProtocolEvent]] */\r\n public static readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\r\n\r\n /** A version code that identifies the RPC protocol capabilties of this endpoint. */\r\n public static readonly protocolVersion: number = RpcProtocolVersion.IntroducedStatusCategory;\r\n\r\n /** The name of the RPC protocol version header. */\r\n public protocolVersionHeaderName = \"\";\r\n\r\n /** Events raised by the protocol. See [[RpcProtocolEvent]] */\r\n public readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\r\n\r\n /** The configuration for the protocol. */\r\n public readonly configuration: RpcConfiguration;\r\n\r\n /** The RPC request class for this protocol. */\r\n public abstract readonly requestType: typeof RpcRequest;\r\n\r\n /** The RPC invocation class for this protocol. */\r\n public readonly invocationType: typeof RpcInvocation = RpcInvocation;\r\n\r\n public serializedClientRequestContextHeaderNames: SerializedRpcActivity = {\r\n /** The name of the request id header. */\r\n id: \"\",\r\n\r\n /** The name of the application id header */\r\n applicationId: \"\",\r\n\r\n /** The name of the version header. */\r\n applicationVersion: \"\",\r\n\r\n /** The name of the session id header */\r\n sessionId: \"\",\r\n\r\n /** The name of the authorization header. */\r\n authorization: \"\",\r\n };\r\n\r\n /** If greater than zero, specifies where to break large binary request payloads. */\r\n public transferChunkThreshold: number = 0;\r\n\r\n /** Used by protocols that can transmit stream values natively. */\r\n public preserveStreams: boolean = false;\r\n\r\n /** Used by protocols that can transmit IModelRpcProps values natively. */\r\n public checkToken: boolean = false;\r\n\r\n /** Used by protocols that support user-defined status codes. */\r\n public supportsStatusCategory: boolean = false;\r\n\r\n /** If checkToken is true, will be called on the backend to inflate the IModelRpcProps for each request. */\r\n public inflateToken(tokenFromBody: IModelRpcProps, _request: SerializedRpcRequest): IModelRpcProps { return tokenFromBody; }\r\n\r\n /** Override to supply the status corresponding to a protocol-specific code value. */\r\n public getStatus(code: number): RpcRequestStatus {\r\n return code;\r\n }\r\n\r\n /** Override to supply the protocol-specific code corresponding to a status value. */\r\n public getCode(status: RpcRequestStatus): number {\r\n return status;\r\n }\r\n\r\n /** Override to supply the protocol-specific path value for an RPC operation. */\r\n public supplyPathForOperation(operation: RpcOperation, _request: RpcRequest | undefined): string {\r\n return JSON.stringify(operation);\r\n }\r\n\r\n /** Override to supply the operation for a protocol-specific path value. */\r\n public getOperationFromPath(path: string): SerializedRpcOperation {\r\n return JSON.parse(path);\r\n }\r\n\r\n /** Obtains the implementation result on the backend for an RPC operation request. */\r\n public async fulfill(request: SerializedRpcRequest): Promise<RpcRequestFulfillment> {\r\n return new (this.invocationType)(this, request).fulfillment;\r\n }\r\n\r\n /** Serializes a request. */\r\n public async serialize(request: RpcRequest): Promise<SerializedRpcRequest> {\r\n const serializedContext = await RpcConfiguration.requestContext.serialize(request);\r\n return {\r\n ...serializedContext,\r\n operation: {\r\n interfaceDefinition: request.operation.interfaceDefinition.interfaceName,\r\n operationName: request.operation.operationName,\r\n interfaceVersion: request.operation.interfaceVersion,\r\n },\r\n method: request.method,\r\n path: request.path,\r\n parameters: await RpcMarshaling.serialize(request.protocol, request.parameters),\r\n caching: RpcResponseCacheControl.None,\r\n protocolVersion: RpcProtocol.protocolVersion,\r\n };\r\n }\r\n\r\n /** Constructs a protocol. */\r\n public constructor(configuration: RpcConfiguration) {\r\n this.configuration = configuration;\r\n this.events.addListener((type, object) => RpcProtocol.events.raiseEvent(type, object));\r\n }\r\n\r\n /** @internal */\r\n public onRpcClientInitialized(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcImplInitialized(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcClientTerminated(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcImplTerminated(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\r\n}\r\n"]}
|
|
@@ -9,7 +9,7 @@ import { RpcRequestEvent, RpcRequestStatus, RpcResponseCacheControl } from "./Rp
|
|
|
9
9
|
import { RpcNotFoundResponse } from "./RpcControl";
|
|
10
10
|
import { RpcSerializedValue } from "./RpcMarshaling";
|
|
11
11
|
import { RpcOperation } from "./RpcOperation";
|
|
12
|
-
import { RpcProtocol } from "./RpcProtocol";
|
|
12
|
+
import { RpcProtocol, RpcProtocolVersion } from "./RpcProtocol";
|
|
13
13
|
/** @internal */
|
|
14
14
|
export declare class ResponseLike implements Response {
|
|
15
15
|
private _data;
|
|
@@ -86,7 +86,7 @@ export declare abstract class RpcRequest<TResponse = any> {
|
|
|
86
86
|
private _transientFaults;
|
|
87
87
|
protected _response: Response | undefined;
|
|
88
88
|
protected _rawPromise: Promise<Response | undefined>;
|
|
89
|
-
|
|
89
|
+
responseProtocolVersion: RpcProtocolVersion;
|
|
90
90
|
/** All RPC requests that are currently in flight. */
|
|
91
91
|
static get activeRequests(): ReadonlyMap<string, RpcRequest>;
|
|
92
92
|
/** Events raised by RpcRequest. See [[RpcRequestEvent]] */
|
|
@@ -152,8 +152,6 @@ export declare abstract class RpcRequest<TResponse = any> {
|
|
|
152
152
|
protected abstract setHeader(name: string, value: string): void;
|
|
153
153
|
/** Sets the last updated time for the request. */
|
|
154
154
|
protected setLastUpdatedTime(): void;
|
|
155
|
-
/** Override to describe available headers based on a protocol-specific criteria (such as a CORS whitelist). */
|
|
156
|
-
protected isHeaderAvailable(_name: string): boolean;
|
|
157
155
|
protected computeRetryAfter(attempts: number): number;
|
|
158
156
|
protected recordTransientFault(): void;
|
|
159
157
|
protected resetTransientFaultCount(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcRequest.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRequest.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAuB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAoB,eAAe,EAAE,gBAAgB,EAAE,uBAAuB,E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C,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAE/D,kDAAkD;IAClD,SAAS,CAAC,kBAAkB;IAI5B,SAAS,CAAC,iBAAiB,CAAC,QAAQ,EAAE,MAAM;IAI5C,SAAS,CAAC,oBAAoB;IAI9B,SAAS,CAAC,wBAAwB;IAIlC,SAAS,CAAC,sBAAsB;IASzB,MAAM;IAcA,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAwDpC,SAAS,CAAC,qBAAqB,CAAC,IAAI,EAAE,MAAM;IAI5C,OAAO,CAAC,cAAc;IA+BtB,OAAO,CAAC,uBAAuB;IA6B/B,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,OAAO;IAoBf,OAAO,CAAC,UAAU;IAYlB,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI;IAgBnC,gBAAgB;IACT,OAAO,IAAI,IAAI;IAWtB,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,oBAAoB;cAeZ,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA2B3C,OAAO,CAAC,SAAS;CAOlB;AAED,gBAAgB;AAChB,eAAO,MAAM,oBAAoB,YA+C7B,CAAC"}
|
|
@@ -71,7 +71,7 @@ export class RpcRequest {
|
|
|
71
71
|
this._retryAfter = null;
|
|
72
72
|
this._transientFaults = 0;
|
|
73
73
|
this._response = undefined;
|
|
74
|
-
this.responseProtocolVersion =
|
|
74
|
+
this.responseProtocolVersion = RpcProtocolVersion.None;
|
|
75
75
|
this._created = new Date().getTime();
|
|
76
76
|
this.path = "";
|
|
77
77
|
this.method = "";
|
|
@@ -151,10 +151,6 @@ export class RpcRequest {
|
|
|
151
151
|
setLastUpdatedTime() {
|
|
152
152
|
this._lastUpdated = new Date().getTime();
|
|
153
153
|
}
|
|
154
|
-
/** Override to describe available headers based on a protocol-specific criteria (such as a CORS whitelist). */
|
|
155
|
-
isHeaderAvailable(_name) {
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
154
|
computeRetryAfter(attempts) {
|
|
159
155
|
return (((Math.pow(2, attempts) - 1) / 2) * 500) + 500;
|
|
160
156
|
}
|
|
@@ -195,7 +191,6 @@ export class RpcRequest {
|
|
|
195
191
|
this._connecting = true;
|
|
196
192
|
RpcRequest._activeRequests.set(this.id, this);
|
|
197
193
|
this.protocol.events.raiseEvent(RpcProtocolEvent.RequestCreated, this);
|
|
198
|
-
await this.protocol.initialize(this.operation.policy.token(this));
|
|
199
194
|
this._sending = new Cancellable(this.setHeaders().then(async () => this.send()));
|
|
200
195
|
this.operation.policy.sentCallback(this);
|
|
201
196
|
const response = await this._sending.promise;
|
|
@@ -396,9 +391,8 @@ export class RpcRequest {
|
|
|
396
391
|
}
|
|
397
392
|
async setHeaders() {
|
|
398
393
|
const versionHeader = this.protocol.protocolVersionHeaderName;
|
|
399
|
-
if (versionHeader && RpcProtocol.protocolVersion
|
|
394
|
+
if (versionHeader && RpcProtocol.protocolVersion)
|
|
400
395
|
this.setHeader(versionHeader, RpcProtocol.protocolVersion.toString());
|
|
401
|
-
}
|
|
402
396
|
const headerNames = this.protocol.serializedClientRequestContextHeaderNames;
|
|
403
397
|
const headerValues = await RpcConfiguration.requestContext.serialize(this);
|
|
404
398
|
if (headerNames.id)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcRequest.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRequest.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAA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AAa;gBACxC,OAAO;YAET,QAAQ,OAAO,CAAC,MAAM,EAAE;gBACtB,KAAK,gBAAgB,CAAC,SAAS,CAAC,CAAC;oBAC/B,aAAa,CAAC,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;oBAClD,MAAM;iBACP;gBAED,KAAK,gBAAgB,CAAC,OAAO,CAAC;gBAC9B,KAAK,gBAAgB,CAAC,QAAQ,CAAC;gBAC/B,KAAK,gBAAgB,CAAC,QAAQ,CAAC,CAAC;oBAC9B,aAAa,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;oBACjD,MAAM;iBACP;aACF;QACH,CAAC,CAAC,CAAC;QAEH,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;YACtC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;YAEjC,QAAQ,IAAI,EAAE;gBACZ,KAAK,gBAAgB,CAAC,eAAe,CAAC,CAAC;oBACrC,aAAa,CAAC,WAAW,GAAG,GAAG,CAAC;oBAChC,MAAM;iBACP;gBAED,KAAK,gBAAgB,CAAC,sBAAsB,CAAC;gBAC7C,KAAK,gBAAgB,CAAC,oBAAoB,CAAC;gBAC3C,KAAK,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;oBAC5C,aAAa,CAAC,YAAY,GAAG,GAAG,CAAC;oBACjC,MAAM;iBACP;aACF;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC,EAAE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BeEvent, BentleyStatus, Guid } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { BackendError, IModelError, NoContentError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestEvent, RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { RpcNotFoundResponse } from \"./RpcControl\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcManagedStatus, RpcProtocol, RpcProtocolVersion } from \"./RpcProtocol\";\r\nimport { CURRENT_REQUEST } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\n// cspell:ignore csrf\r\n\r\nconst aggregateLoad = { lastRequest: 0, lastResponse: 0 };\r\n\r\n/** @internal */\r\nexport class ResponseLike implements Response {\r\n private _data: Promise<any>;\r\n public get body() { return null; }\r\n public async arrayBuffer(): Promise<ArrayBuffer> { return this._data; }\r\n public async blob(): Promise<Blob> { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\r\n public async formData(): Promise<FormData> { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\r\n public async json(): Promise<any> { return this._data; }\r\n public async text(): Promise<string> { return this._data; }\r\n public get bodyUsed() { return false; }\r\n public get headers(): Headers { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\r\n public get ok(): boolean { return this.status >= 200 && this.status <= 299; }\r\n public get redirected() { return false; }\r\n public get status() { return 200; }\r\n public get statusText() { return \"\"; }\r\n public get trailer(): Promise<Headers> { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\r\n public get type(): ResponseType { return \"basic\"; }\r\n public get url() { return \"\"; }\r\n public clone() { return { ...this }; }\r\n\r\n public constructor(data: any) {\r\n this._data = Promise.resolve(data);\r\n }\r\n}\r\n\r\n/** Supplies an IModelRpcProps for an RPC request.\r\n * @internal\r\n */\r\nexport type RpcRequestTokenSupplier_T = (request: RpcRequest) => IModelRpcProps | undefined;\r\n\r\n/** Supplies the initial retry interval for an RPC request.\r\n * @internal\r\n */\r\nexport type RpcRequestInitialRetryIntervalSupplier_T = (configuration: RpcConfiguration) => number;\r\n\r\n/** Notification callback for an RPC request.\r\n * @internal\r\n */\r\nexport type RpcRequestCallback_T = (request: RpcRequest) => void;\r\n\r\n/** Determines if caching is permitted for a RPC response.\r\n * @internal\r\n */\r\nexport type RpcResponseCachingCallback_T = (request: RpcRequest) => RpcResponseCacheControl;\r\n\r\n/** Runtime information related to the operation load of one or more RPC interfaces.\r\n * @internal\r\n */\r\nexport interface RpcOperationsProfile {\r\n readonly lastRequest: number;\r\n readonly lastResponse: number;\r\n}\r\n\r\n/** Handles RPC request events.\r\n * @internal\r\n */\r\nexport type RpcRequestEventHandler = (type: RpcRequestEvent, request: RpcRequest) => void;\r\n\r\n/** Resolves \"not found\" responses for RPC requests.\r\n * @internal\r\n */\r\nexport type RpcRequestNotFoundHandler = (request: RpcRequest, response: RpcNotFoundResponse, resubmit: () => void, reject: (reason: any) => void) => void;\r\n\r\nclass Cancellable<T> {\r\n public promise: Promise<T | undefined>;\r\n public cancel() { }\r\n\r\n public constructor(task: Promise<T>) {\r\n this.promise = new Promise((resolve, reject) => {\r\n // eslint-disable-next-line @typescript-eslint/unbound-method\r\n this.cancel = () => resolve(undefined);\r\n task.then(resolve, reject);\r\n });\r\n }\r\n}\r\n\r\n/** A RPC operation request.\r\n * @internal\r\n */\r\nexport abstract class RpcRequest<TResponse = any> {\r\n private static _activeRequests: Map<string, RpcRequest> = new Map();\r\n private _resolve: (value?: TResponse | PromiseLike<TResponse> | undefined) => void = () => undefined;\r\n protected _resolveRaw: (value?: Response | PromiseLike<Response> | undefined) => void = () => undefined;\r\n private _reject: (reason?: any) => void = () => undefined;\r\n private _rejectRaw: (reason?: any) => void = () => undefined;\r\n private _created: number = 0;\r\n private _lastSubmitted: number = 0;\r\n private _lastUpdated: number = 0;\r\n private _status: RpcRequestStatus = RpcRequestStatus.Unknown;\r\n private _extendedStatus: string = \"\";\r\n private _connecting: boolean = false;\r\n private _active: boolean = true;\r\n private _hasRawListener = false;\r\n private _raw: ArrayBuffer | string | undefined = undefined;\r\n private _sending?: Cancellable<number>;\r\n private _attempts = 0;\r\n private _retryAfter: number | null = null;\r\n private _transientFaults = 0;\r\n protected _response: Response | undefined = undefined;\r\n protected _rawPromise: Promise<Response | undefined>;\r\n protected responseProtocolVersion = 0;\r\n\r\n /** All RPC requests that are currently in flight. */\r\n public static get activeRequests(): ReadonlyMap<string, RpcRequest> { return this._activeRequests; }\r\n\r\n /** Events raised by RpcRequest. See [[RpcRequestEvent]] */\r\n public static readonly events: BeEvent<RpcRequestEventHandler> = new BeEvent();\r\n\r\n /** Resolvers for \"not found\" requests. See [[RpcRequestNotFoundHandler]] */\r\n public static readonly notFoundHandlers: BeEvent<RpcRequestNotFoundHandler> = new BeEvent();\r\n\r\n /** The aggregate operations profile of all active RPC interfaces. */\r\n public static get aggregateLoad(): RpcOperationsProfile { return aggregateLoad; }\r\n\r\n /**\r\n * The request for the current RPC operation.\r\n * @note The return value of this function is only reliable if program control was received from a RPC interface class member function that directly returns the result of calling RpcInterface.forward.\r\n */\r\n public static current(context: RpcInterface): RpcRequest {\r\n return (context as any)[CURRENT_REQUEST];\r\n }\r\n\r\n /** The unique identifier of this request. */\r\n public readonly id: string;\r\n\r\n /** The operation for this request. */\r\n public readonly operation: RpcOperation;\r\n\r\n /** The parameters for this request. */\r\n public parameters: any[];\r\n\r\n /** The RPC client instance for this request. */\r\n public readonly client: RpcInterface;\r\n\r\n /** Convenience access to the protocol of this request. */\r\n public readonly protocol: RpcProtocol;\r\n\r\n /** The implementation response for this request. */\r\n public readonly response: Promise<TResponse | undefined>;\r\n\r\n /** The status of this request. */\r\n public get status() { return this._status; }\r\n\r\n /** Extended status information for this request (if available). */\r\n public get extendedStatus() { return this._extendedStatus; }\r\n\r\n /** The last submission for this request. */\r\n public get lastSubmitted() { return this._lastSubmitted; }\r\n\r\n /** The last status update received for this request. */\r\n public get lastUpdated() { return this._lastUpdated; }\r\n\r\n /** The target interval (in milliseconds) between submission attempts for this request. */\r\n public retryInterval: number;\r\n\r\n /** Whether a connection is active for this request. */\r\n public get connecting() { return this._connecting; }\r\n\r\n /** Whether this request is pending. */\r\n public get pending(): boolean {\r\n switch (this.status) {\r\n case RpcRequestStatus.Submitted:\r\n case RpcRequestStatus.Pending: {\r\n return true;\r\n }\r\n\r\n default: {\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n /** The elapsed time for this request. */\r\n public get elapsed(): number {\r\n return this._lastUpdated - this._created;\r\n }\r\n\r\n /** A protocol-specific path identifier for this request. */\r\n public path: string;\r\n\r\n /** A protocol-specific method identifier for this request. */\r\n public method: string;\r\n\r\n /** An attempt-specific value for when to next retry this request. */\r\n public get retryAfter() { return this._retryAfter; }\r\n\r\n /** Finds the first parameter of a given structural type if present. */\r\n public findParameterOfType<T>(requiredProperties: { [index: string]: string }): T | undefined {\r\n for (const param of this.parameters) {\r\n if (typeof (param) === \"object\" && param !== null) {\r\n for (const prop of Object.getOwnPropertyNames(requiredProperties)) {\r\n if (param.hasOwnProperty(prop) && typeof (param[prop]) === requiredProperties[prop]) {\r\n return param;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Finds the first IModelRpcProps parameter if present. */\r\n public findTokenPropsParameter(): IModelRpcProps | undefined {\r\n return this.findParameterOfType({ iModelId: \"string\" });\r\n\r\n }\r\n\r\n /** The raw implementation response for this request. */\r\n public get rawResponse(): Promise<Response | undefined> {\r\n this._hasRawListener = true;\r\n return this._rawPromise;\r\n }\r\n\r\n /** Constructs an RPC request. */\r\n public constructor(client: RpcInterface, operation: string, parameters: any[]) {\r\n this._created = new Date().getTime();\r\n this.path = \"\";\r\n this.method = \"\";\r\n this.client = client;\r\n this.protocol = client.configuration.protocol;\r\n this.operation = RpcOperation.lookup(client.constructor as any, operation);\r\n this.parameters = parameters;\r\n this.retryInterval = this.operation.policy.retryInterval(client.configuration);\r\n this.response = new Promise((resolve, reject) => { this._resolve = resolve; this._reject = reject; });\r\n this._rawPromise = new Promise((resolve, reject) => { this._resolveRaw = resolve; this._rejectRaw = reject; });\r\n this.id = RpcConfiguration.requestContext.getId(this) || Guid.createValue();\r\n this.setStatus(RpcRequestStatus.Created);\r\n this.operation.policy.requestCallback(this);\r\n }\r\n\r\n /** Override to send the request. */\r\n protected abstract send(): Promise<number>;\r\n\r\n /** Override to load response value. */\r\n protected abstract load(): Promise<RpcSerializedValue>;\r\n\r\n /** Override to set request header values. */\r\n protected abstract setHeader(name: string, value: string): void;\r\n\r\n /** Sets the last updated time for the request. */\r\n protected setLastUpdatedTime() {\r\n this._lastUpdated = new Date().getTime();\r\n }\r\n\r\n /** Override to describe available headers based on a protocol-specific criteria (such as a CORS whitelist). */\r\n protected isHeaderAvailable(_name: string): boolean {\r\n return true;\r\n }\r\n\r\n protected computeRetryAfter(attempts: number) {\r\n return (((Math.pow(2, attempts) - 1) / 2) * 500) + 500;\r\n }\r\n\r\n protected recordTransientFault() {\r\n ++this._transientFaults;\r\n }\r\n\r\n protected resetTransientFaultCount() {\r\n this._transientFaults = 0;\r\n }\r\n\r\n protected supportsStatusCategory() {\r\n if (!this.protocol.supportsStatusCategory) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.responseProtocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;\r\n }\r\n\r\n /* @internal */\r\n public cancel() {\r\n if (typeof (this._sending) === \"undefined\") {\r\n return;\r\n }\r\n\r\n this._sending.cancel();\r\n this._sending = undefined;\r\n\r\n this._connecting = false;\r\n RpcRequest._activeRequests.delete(this.id);\r\n this.setStatus(RpcRequestStatus.Cancelled);\r\n }\r\n\r\n /* @internal */\r\n public async submit(): Promise<void> {\r\n if (!this._active)\r\n return;\r\n\r\n this._lastSubmitted = new Date().getTime();\r\n this._retryAfter = null;\r\n ++this._attempts;\r\n\r\n if (this.status === RpcRequestStatus.Created || this.status === RpcRequestStatus.NotFound || this.status === RpcRequestStatus.Cancelled) {\r\n this.setStatus(RpcRequestStatus.Submitted);\r\n }\r\n\r\n try {\r\n this._connecting = true;\r\n RpcRequest._activeRequests.set(this.id, this);\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.RequestCreated, this);\r\n await this.protocol.initialize(this.operation.policy.token(this));\r\n this._sending = new Cancellable(this.setHeaders().then(async () => this.send()));\r\n this.operation.policy.sentCallback(this);\r\n\r\n const response = await this._sending.promise;\r\n if (typeof (response) === \"undefined\") {\r\n return;\r\n }\r\n\r\n this._sending = undefined;\r\n\r\n const status = this.protocol.getStatus(response);\r\n\r\n if (this._hasRawListener && status === RpcRequestStatus.Resolved && typeof (this._response) !== \"undefined\") {\r\n this._connecting = false;\r\n RpcRequest._activeRequests.delete(this.id);\r\n this.resolveRaw();\r\n } else {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoading, this);\r\n\r\n if (status === RpcRequestStatus.Unknown) {\r\n this._connecting = false;\r\n RpcRequest._activeRequests.delete(this.id);\r\n this.handleUnknownResponse(response);\r\n return;\r\n }\r\n\r\n const value = await this.load();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoaded, this);\r\n RpcRequest._activeRequests.delete(this.id);\r\n this._connecting = false;\r\n this.handleResponse(response, value);\r\n }\r\n } catch (err) {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ConnectionErrorReceived, this, err);\r\n RpcRequest._activeRequests.delete(this.id);\r\n this._connecting = false;\r\n this.reject(err);\r\n }\r\n }\r\n\r\n protected handleUnknownResponse(code: number) {\r\n this.reject(new IModelError(BentleyStatus.ERROR, `Unknown response ${code}.`));\r\n }\r\n\r\n private handleResponse(code: number, value: RpcSerializedValue) {\r\n const protocolStatus = this.protocol.getStatus(code);\r\n const status = this.transformResponseStatus(protocolStatus, value);\r\n\r\n if (RpcRequestStatus.isTransientError(status)) {\r\n return this.handleTransientError(status);\r\n }\r\n\r\n switch (status) {\r\n case RpcRequestStatus.Resolved: {\r\n return this.handleResolved(value);\r\n }\r\n\r\n case RpcRequestStatus.Rejected: {\r\n return this.handleRejected(value);\r\n }\r\n\r\n case RpcRequestStatus.Pending: {\r\n return this.setPending(status, value.objects);\r\n }\r\n\r\n case RpcRequestStatus.NotFound: {\r\n return this.handleNotFound(status, value);\r\n }\r\n\r\n case RpcRequestStatus.NoContent: {\r\n return this.handleNoContent();\r\n }\r\n }\r\n }\r\n\r\n private transformResponseStatus(protocolStatus: RpcRequestStatus, value: RpcSerializedValue): RpcRequestStatus {\r\n if (!this.supportsStatusCategory()) {\r\n return protocolStatus;\r\n }\r\n\r\n let status = protocolStatus;\r\n\r\n if (protocolStatus === RpcRequestStatus.Pending) {\r\n status = RpcRequestStatus.Rejected;\r\n } else if (protocolStatus === RpcRequestStatus.NotFound) {\r\n status = RpcRequestStatus.Rejected;\r\n } else if (protocolStatus === RpcRequestStatus.Unknown) {\r\n status = RpcRequestStatus.Rejected;\r\n }\r\n\r\n if (value.objects.indexOf(\"iTwinRpcCoreResponse\") !== -1 && value.objects.indexOf(\"managedStatus\") !== -1) {\r\n const managedStatus: RpcManagedStatus = JSON.parse(value.objects);\r\n value.objects = managedStatus.responseValue;\r\n\r\n if (managedStatus.managedStatus === \"pending\") {\r\n status = RpcRequestStatus.Pending;\r\n } else if (managedStatus.managedStatus === \"notFound\") {\r\n status = RpcRequestStatus.NotFound;\r\n }\r\n }\r\n\r\n return status;\r\n }\r\n\r\n private handleResolved(value: RpcSerializedValue) {\r\n try {\r\n this._raw = value.objects;\r\n const result: TResponse = RpcMarshaling.deserialize(this.protocol, value);\r\n\r\n if (ArrayBuffer.isView(result)) {\r\n this._raw = result.buffer;\r\n }\r\n\r\n return this.resolve(result);\r\n } catch (err) {\r\n return this.reject(err);\r\n }\r\n }\r\n\r\n private handleRejected(value: RpcSerializedValue) {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendErrorReceived, this);\r\n\r\n try {\r\n const error = RpcMarshaling.deserialize(this.protocol, value);\r\n const hasInfo = error && typeof (error) === \"object\" && error.hasOwnProperty(\"name\") && error.hasOwnProperty(\"message\");\r\n const name = hasInfo ? error.name : \"\";\r\n const message = hasInfo ? error.message : \"\";\r\n const errorNumber = (hasInfo && error.hasOwnProperty(\"errorNumber\")) ? error.errorNumber : BentleyStatus.ERROR;\r\n return this.reject(new BackendError(errorNumber, name, message, () => error));\r\n } catch (err) {\r\n return this.reject(err);\r\n }\r\n }\r\n\r\n private handleNoContent() {\r\n return this.reject(new NoContentError());\r\n }\r\n\r\n private handleNotFound(status: RpcRequestStatus, value: RpcSerializedValue) {\r\n const response = RpcMarshaling.deserialize(this.protocol, value);\r\n this.setStatus(status);\r\n\r\n let resubmitted = false;\r\n RpcRequest.notFoundHandlers.raiseEvent(this, response, () => {\r\n if (resubmitted)\r\n throw new IModelError(BentleyStatus.ERROR, `Already resubmitted using this handler.`);\r\n\r\n resubmitted = true;\r\n this.submit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }, (reason: any) => this.reject(reason));\r\n return;\r\n }\r\n\r\n private resolve(result: TResponse): void {\r\n if (!this._active)\r\n return;\r\n\r\n this._active = false;\r\n this.setLastUpdatedTime();\r\n this._resolve(result);\r\n\r\n if (this._hasRawListener) {\r\n if (typeof (this._raw) === \"undefined\") {\r\n throw new IModelError(BentleyStatus.ERROR, \"Cannot access raw response.\");\r\n }\r\n\r\n this._resolveRaw(new ResponseLike(this._raw));\r\n }\r\n\r\n this.setStatus(RpcRequestStatus.Resolved);\r\n this.dispose();\r\n }\r\n\r\n private resolveRaw() {\r\n if (typeof (this._response) === \"undefined\") {\r\n throw new IModelError(BentleyStatus.ERROR, \"Cannot access raw response.\");\r\n }\r\n\r\n this._active = false;\r\n this.setLastUpdatedTime();\r\n this._resolveRaw(this._response);\r\n this.setStatus(RpcRequestStatus.Resolved);\r\n this.dispose();\r\n }\r\n\r\n protected reject(reason: any): void {\r\n if (!this._active)\r\n return;\r\n\r\n this._active = false;\r\n this.setLastUpdatedTime();\r\n this._reject(reason);\r\n\r\n if (this._hasRawListener) {\r\n this._rejectRaw(reason);\r\n }\r\n\r\n this.setStatus(RpcRequestStatus.Rejected);\r\n this.dispose();\r\n }\r\n\r\n /** @internal */\r\n public dispose(): void {\r\n this.setStatus(RpcRequestStatus.Disposed);\r\n this._raw = undefined;\r\n this._response = undefined;\r\n\r\n const client = this.client as any;\r\n if (client[CURRENT_REQUEST] === this) {\r\n client[CURRENT_REQUEST] = undefined;\r\n }\r\n }\r\n\r\n private setPending(status: RpcRequestStatus.Pending, extendedStatus: string): void {\r\n if (!this._active)\r\n return;\r\n\r\n this.setLastUpdatedTime();\r\n this._extendedStatus = extendedStatus;\r\n this.setStatus(status);\r\n RpcRequest.events.raiseEvent(RpcRequestEvent.PendingUpdateReceived, this);\r\n }\r\n\r\n private handleTransientError(status: RpcRequestStatus) {\r\n if (!this._active)\r\n return;\r\n\r\n this.setLastUpdatedTime();\r\n this._retryAfter = this.computeRetryAfter(this._attempts - 1);\r\n\r\n if (this._transientFaults > this.protocol.configuration.transientFaultLimit) {\r\n this.reject(new IModelError(BentleyStatus.ERROR, `Exceeded transient fault limit.`));\r\n } else {\r\n this.setStatus(status);\r\n RpcRequest.events.raiseEvent(RpcRequestEvent.TransientErrorReceived, this);\r\n }\r\n }\r\n\r\n protected async setHeaders(): Promise<void> {\r\n const versionHeader = this.protocol.protocolVersionHeaderName;\r\n if (versionHeader && RpcProtocol.protocolVersion && this.isHeaderAvailable(versionHeader)) {\r\n this.setHeader(versionHeader, RpcProtocol.protocolVersion.toString());\r\n }\r\n\r\n const headerNames = this.protocol.serializedClientRequestContextHeaderNames;\r\n const headerValues = await RpcConfiguration.requestContext.serialize(this);\r\n\r\n if (headerNames.id)\r\n this.setHeader(headerNames.id, headerValues.id || this.id); // Cannot be empty\r\n\r\n if (headerNames.applicationVersion)\r\n this.setHeader(headerNames.applicationVersion, headerValues.applicationVersion);\r\n\r\n if (headerNames.applicationId)\r\n this.setHeader(headerNames.applicationId, headerValues.applicationId);\r\n\r\n if (headerNames.sessionId)\r\n this.setHeader(headerNames.sessionId, headerValues.sessionId);\r\n\r\n if (headerNames.authorization && headerValues.authorization)\r\n this.setHeader(headerNames.authorization, headerValues.authorization);\r\n\r\n if (headerValues.csrfToken)\r\n this.setHeader(headerValues.csrfToken.headerName, headerValues.csrfToken.headerValue);\r\n }\r\n\r\n private setStatus(status: RpcRequestStatus): void {\r\n if (this._status === status)\r\n return;\r\n\r\n this._status = status;\r\n RpcRequest.events.raiseEvent(RpcRequestEvent.StatusChanged, this);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport const initializeRpcRequest = (() => {\r\n let initialized = false;\r\n\r\n return () => {\r\n if (initialized) {\r\n return;\r\n }\r\n\r\n initialized = true;\r\n\r\n RpcRequest.events.addListener((type, request) => {\r\n if (type !== RpcRequestEvent.StatusChanged)\r\n return;\r\n\r\n switch (request.status) {\r\n case RpcRequestStatus.Submitted: {\r\n aggregateLoad.lastRequest = request.lastSubmitted;\r\n break;\r\n }\r\n\r\n case RpcRequestStatus.Pending:\r\n case RpcRequestStatus.Resolved:\r\n case RpcRequestStatus.Rejected: {\r\n aggregateLoad.lastResponse = request.lastUpdated;\r\n break;\r\n }\r\n }\r\n });\r\n\r\n RpcProtocol.events.addListener((type) => {\r\n const now = new Date().getTime();\r\n\r\n switch (type) {\r\n case RpcProtocolEvent.RequestReceived: {\r\n aggregateLoad.lastRequest = now;\r\n break;\r\n }\r\n\r\n case RpcProtocolEvent.BackendReportedPending:\r\n case RpcProtocolEvent.BackendErrorOccurred:\r\n case RpcProtocolEvent.BackendResponseCreated: {\r\n aggregateLoad.lastResponse = now;\r\n break;\r\n }\r\n }\r\n });\r\n };\r\n})();\r\n"]}
|
|
1
|
+
{"version":3,"file":"RpcRequest.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRequest.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAA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E;gBACtB,KAAK,gBAAgB,CAAC,SAAS,CAAC,CAAC;oBAC/B,aAAa,CAAC,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;oBAClD,MAAM;iBACP;gBAED,KAAK,gBAAgB,CAAC,OAAO,CAAC;gBAC9B,KAAK,gBAAgB,CAAC,QAAQ,CAAC;gBAC/B,KAAK,gBAAgB,CAAC,QAAQ,CAAC,CAAC;oBAC9B,aAAa,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;oBACjD,MAAM;iBACP;aACF;QACH,CAAC,CAAC,CAAC;QAEH,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;YACtC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;YAEjC,QAAQ,IAAI,EAAE;gBACZ,KAAK,gBAAgB,CAAC,eAAe,CAAC,CAAC;oBACrC,aAAa,CAAC,WAAW,GAAG,GAAG,CAAC;oBAChC,MAAM;iBACP;gBAED,KAAK,gBAAgB,CAAC,sBAAsB,CAAC;gBAC7C,KAAK,gBAAgB,CAAC,oBAAoB,CAAC;gBAC3C,KAAK,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;oBAC5C,aAAa,CAAC,YAAY,GAAG,GAAG,CAAC;oBACjC,MAAM;iBACP;aACF;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC,EAAE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BeEvent, BentleyStatus, Guid } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { BackendError, IModelError, NoContentError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestEvent, RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { RpcNotFoundResponse } from \"./RpcControl\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcManagedStatus, RpcProtocol, RpcProtocolVersion } from \"./RpcProtocol\";\r\nimport { CURRENT_REQUEST } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\n// cspell:ignore csrf\r\n\r\nconst aggregateLoad = { lastRequest: 0, lastResponse: 0 };\r\n\r\n/** @internal */\r\nexport class ResponseLike implements Response {\r\n private _data: Promise<any>;\r\n public get body() { return null; }\r\n public async arrayBuffer(): Promise<ArrayBuffer> { return this._data; }\r\n public async blob(): Promise<Blob> { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\r\n public async formData(): Promise<FormData> { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\r\n public async json(): Promise<any> { return this._data; }\r\n public async text(): Promise<string> { return this._data; }\r\n public get bodyUsed() { return false; }\r\n public get headers(): Headers { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\r\n public get ok(): boolean { return this.status >= 200 && this.status <= 299; }\r\n public get redirected() { return false; }\r\n public get status() { return 200; }\r\n public get statusText() { return \"\"; }\r\n public get trailer(): Promise<Headers> { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\r\n public get type(): ResponseType { return \"basic\"; }\r\n public get url() { return \"\"; }\r\n public clone() { return { ...this }; }\r\n\r\n public constructor(data: any) {\r\n this._data = Promise.resolve(data);\r\n }\r\n}\r\n\r\n/** Supplies an IModelRpcProps for an RPC request.\r\n * @internal\r\n */\r\nexport type RpcRequestTokenSupplier_T = (request: RpcRequest) => IModelRpcProps | undefined;\r\n\r\n/** Supplies the initial retry interval for an RPC request.\r\n * @internal\r\n */\r\nexport type RpcRequestInitialRetryIntervalSupplier_T = (configuration: RpcConfiguration) => number;\r\n\r\n/** Notification callback for an RPC request.\r\n * @internal\r\n */\r\nexport type RpcRequestCallback_T = (request: RpcRequest) => void;\r\n\r\n/** Determines if caching is permitted for a RPC response.\r\n * @internal\r\n */\r\nexport type RpcResponseCachingCallback_T = (request: RpcRequest) => RpcResponseCacheControl;\r\n\r\n/** Runtime information related to the operation load of one or more RPC interfaces.\r\n * @internal\r\n */\r\nexport interface RpcOperationsProfile {\r\n readonly lastRequest: number;\r\n readonly lastResponse: number;\r\n}\r\n\r\n/** Handles RPC request events.\r\n * @internal\r\n */\r\nexport type RpcRequestEventHandler = (type: RpcRequestEvent, request: RpcRequest) => void;\r\n\r\n/** Resolves \"not found\" responses for RPC requests.\r\n * @internal\r\n */\r\nexport type RpcRequestNotFoundHandler = (request: RpcRequest, response: RpcNotFoundResponse, resubmit: () => void, reject: (reason: any) => void) => void;\r\n\r\nclass Cancellable<T> {\r\n public promise: Promise<T | undefined>;\r\n public cancel() { }\r\n\r\n public constructor(task: Promise<T>) {\r\n this.promise = new Promise((resolve, reject) => {\r\n // eslint-disable-next-line @typescript-eslint/unbound-method\r\n this.cancel = () => resolve(undefined);\r\n task.then(resolve, reject);\r\n });\r\n }\r\n}\r\n\r\n/** A RPC operation request.\r\n * @internal\r\n */\r\nexport abstract class RpcRequest<TResponse = any> {\r\n private static _activeRequests: Map<string, RpcRequest> = new Map();\r\n private _resolve: (value?: TResponse | PromiseLike<TResponse> | undefined) => void = () => undefined;\r\n protected _resolveRaw: (value?: Response | PromiseLike<Response> | undefined) => void = () => undefined;\r\n private _reject: (reason?: any) => void = () => undefined;\r\n private _rejectRaw: (reason?: any) => void = () => undefined;\r\n private _created: number = 0;\r\n private _lastSubmitted: number = 0;\r\n private _lastUpdated: number = 0;\r\n private _status: RpcRequestStatus = RpcRequestStatus.Unknown;\r\n private _extendedStatus: string = \"\";\r\n private _connecting: boolean = false;\r\n private _active: boolean = true;\r\n private _hasRawListener = false;\r\n private _raw: ArrayBuffer | string | undefined = undefined;\r\n private _sending?: Cancellable<number>;\r\n private _attempts = 0;\r\n private _retryAfter: number | null = null;\r\n private _transientFaults = 0;\r\n protected _response: Response | undefined = undefined;\r\n protected _rawPromise: Promise<Response | undefined>;\r\n public responseProtocolVersion = RpcProtocolVersion.None;\r\n\r\n /** All RPC requests that are currently in flight. */\r\n public static get activeRequests(): ReadonlyMap<string, RpcRequest> { return this._activeRequests; }\r\n\r\n /** Events raised by RpcRequest. See [[RpcRequestEvent]] */\r\n public static readonly events: BeEvent<RpcRequestEventHandler> = new BeEvent();\r\n\r\n /** Resolvers for \"not found\" requests. See [[RpcRequestNotFoundHandler]] */\r\n public static readonly notFoundHandlers: BeEvent<RpcRequestNotFoundHandler> = new BeEvent();\r\n\r\n /** The aggregate operations profile of all active RPC interfaces. */\r\n public static get aggregateLoad(): RpcOperationsProfile { return aggregateLoad; }\r\n\r\n /**\r\n * The request for the current RPC operation.\r\n * @note The return value of this function is only reliable if program control was received from a RPC interface class member function that directly returns the result of calling RpcInterface.forward.\r\n */\r\n public static current(context: RpcInterface): RpcRequest {\r\n return (context as any)[CURRENT_REQUEST];\r\n }\r\n\r\n /** The unique identifier of this request. */\r\n public readonly id: string;\r\n\r\n /** The operation for this request. */\r\n public readonly operation: RpcOperation;\r\n\r\n /** The parameters for this request. */\r\n public parameters: any[];\r\n\r\n /** The RPC client instance for this request. */\r\n public readonly client: RpcInterface;\r\n\r\n /** Convenience access to the protocol of this request. */\r\n public readonly protocol: RpcProtocol;\r\n\r\n /** The implementation response for this request. */\r\n public readonly response: Promise<TResponse | undefined>;\r\n\r\n /** The status of this request. */\r\n public get status() { return this._status; }\r\n\r\n /** Extended status information for this request (if available). */\r\n public get extendedStatus() { return this._extendedStatus; }\r\n\r\n /** The last submission for this request. */\r\n public get lastSubmitted() { return this._lastSubmitted; }\r\n\r\n /** The last status update received for this request. */\r\n public get lastUpdated() { return this._lastUpdated; }\r\n\r\n /** The target interval (in milliseconds) between submission attempts for this request. */\r\n public retryInterval: number;\r\n\r\n /** Whether a connection is active for this request. */\r\n public get connecting() { return this._connecting; }\r\n\r\n /** Whether this request is pending. */\r\n public get pending(): boolean {\r\n switch (this.status) {\r\n case RpcRequestStatus.Submitted:\r\n case RpcRequestStatus.Pending: {\r\n return true;\r\n }\r\n\r\n default: {\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n /** The elapsed time for this request. */\r\n public get elapsed(): number {\r\n return this._lastUpdated - this._created;\r\n }\r\n\r\n /** A protocol-specific path identifier for this request. */\r\n public path: string;\r\n\r\n /** A protocol-specific method identifier for this request. */\r\n public method: string;\r\n\r\n /** An attempt-specific value for when to next retry this request. */\r\n public get retryAfter() { return this._retryAfter; }\r\n\r\n /** Finds the first parameter of a given structural type if present. */\r\n public findParameterOfType<T>(requiredProperties: { [index: string]: string }): T | undefined {\r\n for (const param of this.parameters) {\r\n if (typeof (param) === \"object\" && param !== null) {\r\n for (const prop of Object.getOwnPropertyNames(requiredProperties)) {\r\n if (param.hasOwnProperty(prop) && typeof (param[prop]) === requiredProperties[prop]) {\r\n return param;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Finds the first IModelRpcProps parameter if present. */\r\n public findTokenPropsParameter(): IModelRpcProps | undefined {\r\n return this.findParameterOfType({ iModelId: \"string\" });\r\n\r\n }\r\n\r\n /** The raw implementation response for this request. */\r\n public get rawResponse(): Promise<Response | undefined> {\r\n this._hasRawListener = true;\r\n return this._rawPromise;\r\n }\r\n\r\n /** Constructs an RPC request. */\r\n public constructor(client: RpcInterface, operation: string, parameters: any[]) {\r\n this._created = new Date().getTime();\r\n this.path = \"\";\r\n this.method = \"\";\r\n this.client = client;\r\n this.protocol = client.configuration.protocol;\r\n this.operation = RpcOperation.lookup(client.constructor as any, operation);\r\n this.parameters = parameters;\r\n this.retryInterval = this.operation.policy.retryInterval(client.configuration);\r\n this.response = new Promise((resolve, reject) => { this._resolve = resolve; this._reject = reject; });\r\n this._rawPromise = new Promise((resolve, reject) => { this._resolveRaw = resolve; this._rejectRaw = reject; });\r\n this.id = RpcConfiguration.requestContext.getId(this) || Guid.createValue();\r\n this.setStatus(RpcRequestStatus.Created);\r\n this.operation.policy.requestCallback(this);\r\n }\r\n\r\n /** Override to send the request. */\r\n protected abstract send(): Promise<number>;\r\n\r\n /** Override to load response value. */\r\n protected abstract load(): Promise<RpcSerializedValue>;\r\n\r\n /** Override to set request header values. */\r\n protected abstract setHeader(name: string, value: string): void;\r\n\r\n /** Sets the last updated time for the request. */\r\n protected setLastUpdatedTime() {\r\n this._lastUpdated = new Date().getTime();\r\n }\r\n\r\n protected computeRetryAfter(attempts: number) {\r\n return (((Math.pow(2, attempts) - 1) / 2) * 500) + 500;\r\n }\r\n\r\n protected recordTransientFault() {\r\n ++this._transientFaults;\r\n }\r\n\r\n protected resetTransientFaultCount() {\r\n this._transientFaults = 0;\r\n }\r\n\r\n protected supportsStatusCategory() {\r\n if (!this.protocol.supportsStatusCategory) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.responseProtocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;\r\n }\r\n\r\n /* @internal */\r\n public cancel() {\r\n if (typeof (this._sending) === \"undefined\") {\r\n return;\r\n }\r\n\r\n this._sending.cancel();\r\n this._sending = undefined;\r\n\r\n this._connecting = false;\r\n RpcRequest._activeRequests.delete(this.id);\r\n this.setStatus(RpcRequestStatus.Cancelled);\r\n }\r\n\r\n /* @internal */\r\n public async submit(): Promise<void> {\r\n if (!this._active)\r\n return;\r\n\r\n this._lastSubmitted = new Date().getTime();\r\n this._retryAfter = null;\r\n ++this._attempts;\r\n\r\n if (this.status === RpcRequestStatus.Created || this.status === RpcRequestStatus.NotFound || this.status === RpcRequestStatus.Cancelled) {\r\n this.setStatus(RpcRequestStatus.Submitted);\r\n }\r\n\r\n try {\r\n this._connecting = true;\r\n RpcRequest._activeRequests.set(this.id, this);\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.RequestCreated, this);\r\n this._sending = new Cancellable(this.setHeaders().then(async () => this.send()));\r\n this.operation.policy.sentCallback(this);\r\n\r\n const response = await this._sending.promise;\r\n if (typeof (response) === \"undefined\") {\r\n return;\r\n }\r\n\r\n this._sending = undefined;\r\n\r\n const status = this.protocol.getStatus(response);\r\n\r\n if (this._hasRawListener && status === RpcRequestStatus.Resolved && typeof (this._response) !== \"undefined\") {\r\n this._connecting = false;\r\n RpcRequest._activeRequests.delete(this.id);\r\n this.resolveRaw();\r\n } else {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoading, this);\r\n\r\n if (status === RpcRequestStatus.Unknown) {\r\n this._connecting = false;\r\n RpcRequest._activeRequests.delete(this.id);\r\n this.handleUnknownResponse(response);\r\n return;\r\n }\r\n\r\n const value = await this.load();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoaded, this);\r\n RpcRequest._activeRequests.delete(this.id);\r\n this._connecting = false;\r\n this.handleResponse(response, value);\r\n }\r\n } catch (err) {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ConnectionErrorReceived, this, err);\r\n RpcRequest._activeRequests.delete(this.id);\r\n this._connecting = false;\r\n this.reject(err);\r\n }\r\n }\r\n\r\n protected handleUnknownResponse(code: number) {\r\n this.reject(new IModelError(BentleyStatus.ERROR, `Unknown response ${code}.`));\r\n }\r\n\r\n private handleResponse(code: number, value: RpcSerializedValue) {\r\n const protocolStatus = this.protocol.getStatus(code);\r\n const status = this.transformResponseStatus(protocolStatus, value);\r\n\r\n if (RpcRequestStatus.isTransientError(status)) {\r\n return this.handleTransientError(status);\r\n }\r\n\r\n switch (status) {\r\n case RpcRequestStatus.Resolved: {\r\n return this.handleResolved(value);\r\n }\r\n\r\n case RpcRequestStatus.Rejected: {\r\n return this.handleRejected(value);\r\n }\r\n\r\n case RpcRequestStatus.Pending: {\r\n return this.setPending(status, value.objects);\r\n }\r\n\r\n case RpcRequestStatus.NotFound: {\r\n return this.handleNotFound(status, value);\r\n }\r\n\r\n case RpcRequestStatus.NoContent: {\r\n return this.handleNoContent();\r\n }\r\n }\r\n }\r\n\r\n private transformResponseStatus(protocolStatus: RpcRequestStatus, value: RpcSerializedValue): RpcRequestStatus {\r\n if (!this.supportsStatusCategory()) {\r\n return protocolStatus;\r\n }\r\n\r\n let status = protocolStatus;\r\n\r\n if (protocolStatus === RpcRequestStatus.Pending) {\r\n status = RpcRequestStatus.Rejected;\r\n } else if (protocolStatus === RpcRequestStatus.NotFound) {\r\n status = RpcRequestStatus.Rejected;\r\n } else if (protocolStatus === RpcRequestStatus.Unknown) {\r\n status = RpcRequestStatus.Rejected;\r\n }\r\n\r\n if (value.objects.indexOf(\"iTwinRpcCoreResponse\") !== -1 && value.objects.indexOf(\"managedStatus\") !== -1) {\r\n const managedStatus: RpcManagedStatus = JSON.parse(value.objects);\r\n value.objects = managedStatus.responseValue;\r\n\r\n if (managedStatus.managedStatus === \"pending\") {\r\n status = RpcRequestStatus.Pending;\r\n } else if (managedStatus.managedStatus === \"notFound\") {\r\n status = RpcRequestStatus.NotFound;\r\n }\r\n }\r\n\r\n return status;\r\n }\r\n\r\n private handleResolved(value: RpcSerializedValue) {\r\n try {\r\n this._raw = value.objects;\r\n const result: TResponse = RpcMarshaling.deserialize(this.protocol, value);\r\n\r\n if (ArrayBuffer.isView(result)) {\r\n this._raw = result.buffer;\r\n }\r\n\r\n return this.resolve(result);\r\n } catch (err) {\r\n return this.reject(err);\r\n }\r\n }\r\n\r\n private handleRejected(value: RpcSerializedValue) {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendErrorReceived, this);\r\n\r\n try {\r\n const error = RpcMarshaling.deserialize(this.protocol, value);\r\n const hasInfo = error && typeof (error) === \"object\" && error.hasOwnProperty(\"name\") && error.hasOwnProperty(\"message\");\r\n const name = hasInfo ? error.name : \"\";\r\n const message = hasInfo ? error.message : \"\";\r\n const errorNumber = (hasInfo && error.hasOwnProperty(\"errorNumber\")) ? error.errorNumber : BentleyStatus.ERROR;\r\n return this.reject(new BackendError(errorNumber, name, message, () => error));\r\n } catch (err) {\r\n return this.reject(err);\r\n }\r\n }\r\n\r\n private handleNoContent() {\r\n return this.reject(new NoContentError());\r\n }\r\n\r\n private handleNotFound(status: RpcRequestStatus, value: RpcSerializedValue) {\r\n const response = RpcMarshaling.deserialize(this.protocol, value);\r\n this.setStatus(status);\r\n\r\n let resubmitted = false;\r\n RpcRequest.notFoundHandlers.raiseEvent(this, response, () => {\r\n if (resubmitted)\r\n throw new IModelError(BentleyStatus.ERROR, `Already resubmitted using this handler.`);\r\n\r\n resubmitted = true;\r\n this.submit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }, (reason: any) => this.reject(reason));\r\n return;\r\n }\r\n\r\n private resolve(result: TResponse): void {\r\n if (!this._active)\r\n return;\r\n\r\n this._active = false;\r\n this.setLastUpdatedTime();\r\n this._resolve(result);\r\n\r\n if (this._hasRawListener) {\r\n if (typeof (this._raw) === \"undefined\") {\r\n throw new IModelError(BentleyStatus.ERROR, \"Cannot access raw response.\");\r\n }\r\n\r\n this._resolveRaw(new ResponseLike(this._raw));\r\n }\r\n\r\n this.setStatus(RpcRequestStatus.Resolved);\r\n this.dispose();\r\n }\r\n\r\n private resolveRaw() {\r\n if (typeof (this._response) === \"undefined\") {\r\n throw new IModelError(BentleyStatus.ERROR, \"Cannot access raw response.\");\r\n }\r\n\r\n this._active = false;\r\n this.setLastUpdatedTime();\r\n this._resolveRaw(this._response);\r\n this.setStatus(RpcRequestStatus.Resolved);\r\n this.dispose();\r\n }\r\n\r\n protected reject(reason: any): void {\r\n if (!this._active)\r\n return;\r\n\r\n this._active = false;\r\n this.setLastUpdatedTime();\r\n this._reject(reason);\r\n\r\n if (this._hasRawListener) {\r\n this._rejectRaw(reason);\r\n }\r\n\r\n this.setStatus(RpcRequestStatus.Rejected);\r\n this.dispose();\r\n }\r\n\r\n /** @internal */\r\n public dispose(): void {\r\n this.setStatus(RpcRequestStatus.Disposed);\r\n this._raw = undefined;\r\n this._response = undefined;\r\n\r\n const client = this.client as any;\r\n if (client[CURRENT_REQUEST] === this) {\r\n client[CURRENT_REQUEST] = undefined;\r\n }\r\n }\r\n\r\n private setPending(status: RpcRequestStatus.Pending, extendedStatus: string): void {\r\n if (!this._active)\r\n return;\r\n\r\n this.setLastUpdatedTime();\r\n this._extendedStatus = extendedStatus;\r\n this.setStatus(status);\r\n RpcRequest.events.raiseEvent(RpcRequestEvent.PendingUpdateReceived, this);\r\n }\r\n\r\n private handleTransientError(status: RpcRequestStatus) {\r\n if (!this._active)\r\n return;\r\n\r\n this.setLastUpdatedTime();\r\n this._retryAfter = this.computeRetryAfter(this._attempts - 1);\r\n\r\n if (this._transientFaults > this.protocol.configuration.transientFaultLimit) {\r\n this.reject(new IModelError(BentleyStatus.ERROR, `Exceeded transient fault limit.`));\r\n } else {\r\n this.setStatus(status);\r\n RpcRequest.events.raiseEvent(RpcRequestEvent.TransientErrorReceived, this);\r\n }\r\n }\r\n\r\n protected async setHeaders(): Promise<void> {\r\n const versionHeader = this.protocol.protocolVersionHeaderName;\r\n if (versionHeader && RpcProtocol.protocolVersion)\r\n this.setHeader(versionHeader, RpcProtocol.protocolVersion.toString());\r\n\r\n const headerNames = this.protocol.serializedClientRequestContextHeaderNames;\r\n const headerValues = await RpcConfiguration.requestContext.serialize(this);\r\n\r\n if (headerNames.id)\r\n this.setHeader(headerNames.id, headerValues.id || this.id); // Cannot be empty\r\n\r\n if (headerNames.applicationVersion)\r\n this.setHeader(headerNames.applicationVersion, headerValues.applicationVersion);\r\n\r\n if (headerNames.applicationId)\r\n this.setHeader(headerNames.applicationId, headerValues.applicationId);\r\n\r\n if (headerNames.sessionId)\r\n this.setHeader(headerNames.sessionId, headerValues.sessionId);\r\n\r\n if (headerNames.authorization && headerValues.authorization)\r\n this.setHeader(headerNames.authorization, headerValues.authorization);\r\n\r\n if (headerValues.csrfToken)\r\n this.setHeader(headerValues.csrfToken.headerName, headerValues.csrfToken.headerValue);\r\n }\r\n\r\n private setStatus(status: RpcRequestStatus): void {\r\n if (this._status === status)\r\n return;\r\n\r\n this._status = status;\r\n RpcRequest.events.raiseEvent(RpcRequestEvent.StatusChanged, this);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport const initializeRpcRequest = (() => {\r\n let initialized = false;\r\n\r\n return () => {\r\n if (initialized) {\r\n return;\r\n }\r\n\r\n initialized = true;\r\n\r\n RpcRequest.events.addListener((type, request) => {\r\n if (type !== RpcRequestEvent.StatusChanged)\r\n return;\r\n\r\n switch (request.status) {\r\n case RpcRequestStatus.Submitted: {\r\n aggregateLoad.lastRequest = request.lastSubmitted;\r\n break;\r\n }\r\n\r\n case RpcRequestStatus.Pending:\r\n case RpcRequestStatus.Resolved:\r\n case RpcRequestStatus.Rejected: {\r\n aggregateLoad.lastResponse = request.lastUpdated;\r\n break;\r\n }\r\n }\r\n });\r\n\r\n RpcProtocol.events.addListener((type) => {\r\n const now = new Date().getTime();\r\n\r\n switch (type) {\r\n case RpcProtocolEvent.RequestReceived: {\r\n aggregateLoad.lastRequest = now;\r\n break;\r\n }\r\n\r\n case RpcProtocolEvent.BackendReportedPending:\r\n case RpcProtocolEvent.BackendErrorOccurred:\r\n case RpcProtocolEvent.BackendResponseCreated: {\r\n aggregateLoad.lastResponse = now;\r\n break;\r\n }\r\n }\r\n });\r\n };\r\n})();\r\n"]}
|
|
@@ -9,7 +9,6 @@ import { RpcOperation } from "../core/RpcOperation";
|
|
|
9
9
|
import { RpcProtocol } from "../core/RpcProtocol";
|
|
10
10
|
import { OpenAPIInfo, OpenAPIParameter, RpcOpenAPIDescription } from "./OpenAPI";
|
|
11
11
|
import { WebAppRpcRequest } from "./WebAppRpcRequest";
|
|
12
|
-
import { IModelRpcProps } from "../../IModel";
|
|
13
12
|
/** An HTTP server request object.
|
|
14
13
|
* @public
|
|
15
14
|
*/
|
|
@@ -53,11 +52,6 @@ export interface HttpServerResponse extends Writable {
|
|
|
53
52
|
*/
|
|
54
53
|
export declare abstract class WebAppRpcProtocol extends RpcProtocol {
|
|
55
54
|
preserveStreams: boolean;
|
|
56
|
-
private _initialized;
|
|
57
|
-
/** @internal */
|
|
58
|
-
allowedHeaders: Set<string>;
|
|
59
|
-
/** @internal */
|
|
60
|
-
initialize(token?: IModelRpcProps): Promise<void>;
|
|
61
55
|
/** Convenience handler for an RPC operation get request for an HTTP server. */
|
|
62
56
|
handleOperationGetRequest(req: HttpServerRequest, res: HttpServerResponse): Promise<void>;
|
|
63
57
|
/** Convenience handler for an RPC operation post request for an HTTP server. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebAppRpcProtocol.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcProtocol.ts"],"names":[],"mappings":"AAIA;;GAEG;;
|
|
1
|
+
{"version":3,"file":"WebAppRpcProtocol.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcProtocol.ts"],"names":[],"mappings":"AAIA;;GAEG;;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAqB,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAA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