@itwin/core-common 4.7.0-dev.4 → 4.7.0-dev.5

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 CHANGED
@@ -1,6 +1,18 @@
1
1
  # Change Log - @itwin/core-common
2
2
 
3
- This log was last generated on Tue, 16 Apr 2024 14:47:36 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 15 May 2024 21:32:22 GMT and should not be manually modified.
4
+
5
+ ## 4.6.0
6
+ Mon, 13 May 2024 20:32:51 GMT
7
+
8
+ ### Updates
9
+
10
+ - Added an optional property called accessString to the QueryPropertyMetaData interface.
11
+ - Added note to `GenericInstanceFilterRuleOperator` that `like` operator should be handled as a contains operator.
12
+ - Add class Id to EntityMetadata.
13
+ - Remove unused TextAnnotation.origin.
14
+ - Add TextAnnotation APIs.
15
+ - Promote QPoint2dBufferBuilderOptions and QPoint3dBufferBuilderOptions from beta to public
4
16
 
5
17
  ## 4.5.2
6
18
  Tue, 16 Apr 2024 14:46:21 GMT
@@ -208,7 +208,7 @@ class RpcInvocation {
208
208
  status: this.protocol.getCode(this.status),
209
209
  id: this.request.id,
210
210
  interfaceName: (typeof (this.operation) === "undefined") ? "" : this.operation.interfaceDefinition.interfaceName,
211
- allowCompression: this.operation?.policy.allowResponseCompression || false,
211
+ allowCompression: this.operation ? this.operation.policy.allowResponseCompression : true,
212
212
  };
213
213
  this.transformResponseStatus(fulfillment, rawResult);
214
214
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"RpcInvocation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcInvocation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,sDAA8J;AAC9J,qEAAkE;AAElE,mDAAgD;AAChD,qDAAkD;AAElD,yDAAsD;AACtD,iDAAoE;AACpE,6CAA0F;AAC1F,mDAAoE;AACpE,iDAA8C;AAC9C,+CAA+H;AAC/H,+CAAgE;AAqChE;;GAEG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CAAC;YACnC,OAAO;QACT,CAAC;QAED,IAAI,aAA+D,CAAC;QACpE,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,aAAa,GAAG,SAAS,CAAC;QAC5B,CAAC;aAAM,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAC1B,aAAa,GAAG,UAAU,CAAC;QAC7B,CAAC;aAAM,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAC3B,aAAa,GAAG,WAAW,CAAC;QAC9B,CAAC;QAED,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC;YACjD,MAAM,MAAM,GAAqB,EAAE,oBAAoB,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;YAC9F,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACpD,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC,eAAe;YACjD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC;QACjC,CAAC;QAED,IAAI,SAAS,YAAY,KAAK,EAAE,CAAC;YAC/B,WAAW,CAAC,MAAM,GAAG,6BAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;QAC1D,CAAC;IACH,CAAC;;AA7QH,sCA8QC;;AA7Qe,yBAAW,GAAmB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,AAAhD,CAAiD","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 { AccessToken, BentleyError, BentleyStatus, GuidString, IModelStatus, Logger, RpcInterfaceStatus, StatusCategory, Tracing } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { SessionProps } from \"../../SessionProps\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus } from \"./RpcConstants\";\r\nimport { RpcControlChannel, RpcNotFoundResponse, RpcPendingResponse } from \"./RpcControl\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcManagedStatus, RpcProtocol, RpcProtocolVersion, RpcRequestFulfillment, SerializedRpcRequest } from \"./RpcProtocol\";\r\nimport { CURRENT_INVOCATION, RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** The properties of an RpcActivity.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface RpcActivity extends SessionProps {\r\n /** Used for logging to correlate an Rpc activity between frontend and backend */\r\n readonly activityId: GuidString;\r\n\r\n /** access token for authorization */\r\n readonly accessToken: AccessToken;\r\n\r\n /** the name of the current rpc method */\r\n readonly rpcMethod?: string;\r\n\r\n readonly user?: string;\r\n}\r\n\r\n/** Serialized format for sending the request across the RPC layer\r\n * @public\r\n */\r\nexport interface SerializedRpcActivity {\r\n id: string;\r\n applicationId: string;\r\n applicationVersion: string;\r\n sessionId: string;\r\n authorization: string;\r\n user?: string;\r\n csrfToken?: { headerName: string, headerValue: string };\r\n}\r\n\r\n/** @internal */\r\nexport type RpcActivityRun = (activity: RpcActivity, fn: () => Promise<any>) => Promise<any>;\r\n\r\n/** An RPC operation invocation in response to a request.\r\n * @internal\r\n */\r\nexport class RpcInvocation {\r\n public static runActivity: RpcActivityRun = async (_activity, fn) => fn();\r\n private _threw: boolean = false;\r\n private _pending: boolean = false;\r\n private _notFound: boolean = false;\r\n private _noContent: boolean = false;\r\n private _timeIn: number = 0;\r\n private _timeOut: number = 0;\r\n\r\n /** The protocol for this invocation. */\r\n public readonly protocol: RpcProtocol;\r\n\r\n /** The received request. */\r\n public readonly request: SerializedRpcRequest;\r\n\r\n /** The operation of the request. */\r\n public readonly operation: RpcOperation = undefined as any;\r\n\r\n /** The implementation response. */\r\n public readonly result: Promise<any>;\r\n\r\n /** The fulfillment for this request. */\r\n public readonly fulfillment: Promise<RpcRequestFulfillment>;\r\n\r\n /** The status for this request. */\r\n public get status(): RpcRequestStatus {\r\n return this._threw ? RpcRequestStatus.Rejected :\r\n this._pending ? RpcRequestStatus.Pending :\r\n this._notFound ? RpcRequestStatus.NotFound :\r\n this._noContent ? RpcRequestStatus.NoContent :\r\n RpcRequestStatus.Resolved;\r\n }\r\n\r\n /** The elapsed time for this invocation. */\r\n public get elapsed(): number {\r\n return this._timeOut - this._timeIn;\r\n }\r\n\r\n /**\r\n * The invocation for the current RPC operation.\r\n * @note The return value of this function is only reliable in an RPC impl class member function where program control was received from the RpcInvocation constructor function.\r\n */\r\n public static current(rpcImpl: RpcInterface): RpcInvocation {\r\n return (rpcImpl as any)[CURRENT_INVOCATION];\r\n }\r\n\r\n /** Constructs an invocation. */\r\n public constructor(protocol: RpcProtocol, request: SerializedRpcRequest) {\r\n this._timeIn = new Date().getTime();\r\n this.protocol = protocol;\r\n this.request = request;\r\n\r\n try {\r\n try {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n\r\n const backend = this.operation.interfaceVersion;\r\n const frontend = this.request.operation.interfaceVersion;\r\n if (!RpcInterface.isVersionCompatible(backend, frontend)) {\r\n throw new IModelError(RpcInterfaceStatus.IncompatibleVersion, `Backend version ${backend} does not match frontend version ${frontend} for RPC interface ${this.operation.operationName}.`);\r\n }\r\n } catch (error) {\r\n if (this.handleUnknownOperation(error)) {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n\r\n this.result = this.resolve();\r\n } catch (error) {\r\n this.result = this.reject(error);\r\n }\r\n\r\n this.fulfillment = this.result.then(async (value) => this._threw ? this.fulfillRejected(value) : this.fulfillResolved(value), async (reason) => this.fulfillRejected(reason));\r\n }\r\n\r\n private handleUnknownOperation(error: any): boolean {\r\n RpcControlChannel.ensureInitialized();\r\n return this.protocol.configuration.controlChannel.handleUnknownOperation(this, error);\r\n }\r\n\r\n public static sanitizeForLog(activity?: RpcActivity) {\r\n /* eslint-disable @typescript-eslint/naming-convention */\r\n return activity ? {\r\n ActivityId: activity.activityId, SessionId: activity.sessionId, ApplicationId: activity.applicationId, ApplicationVersion: activity.applicationVersion, rpcMethod: activity.rpcMethod,\r\n } : undefined;\r\n /* eslint-enable @typescript-eslint/naming-convention */\r\n }\r\n\r\n private async resolve(): Promise<any> {\r\n const request = this.request;\r\n const activity: RpcActivity = {\r\n activityId: request.id,\r\n applicationId: request.applicationId,\r\n applicationVersion: request.applicationVersion,\r\n sessionId: request.sessionId,\r\n user: request.user,\r\n accessToken: request.authorization,\r\n rpcMethod: request.operation.operationName,\r\n };\r\n\r\n try {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.RequestReceived, this);\r\n\r\n const parameters = request.parametersOverride || RpcMarshaling.deserialize(this.protocol, request.parameters);\r\n this.applyPolicies(parameters);\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition);\r\n (impl as any)[CURRENT_INVOCATION] = this;\r\n const op = this.lookupOperationFunction(impl);\r\n\r\n return await RpcInvocation.runActivity(activity, async () => op.call(impl, ...parameters)\r\n .catch(async (error) => {\r\n // this catch block is intentionally placed inside `runActivity` to attach the right logging metadata and use the correct openTelemetry span.\r\n if (!(error instanceof RpcPendingResponse)) {\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, \"Error in RPC operation\", { error: BentleyError.getErrorProps(error) });\r\n Tracing.recordException(error);\r\n }\r\n throw error;\r\n }));\r\n } catch (error: unknown) {\r\n return this.reject(error);\r\n }\r\n }\r\n\r\n private applyPolicies(parameters: any) {\r\n if (!parameters || !Array.isArray(parameters))\r\n return;\r\n\r\n for (let i = 0; i !== parameters.length; ++i) {\r\n const parameter = parameters[i];\r\n const isToken = typeof (parameter) === \"object\" && parameter !== null && parameter.hasOwnProperty(\"iModelId\") && parameter.hasOwnProperty(\"iTwinId\");\r\n if (isToken && this.protocol.checkToken && !this.operation.policy.allowTokenMismatch) {\r\n const inflated = this.protocol.inflateToken(parameter, this.request);\r\n parameters[i] = inflated;\r\n\r\n if (!RpcInvocation.compareTokens(parameter, inflated)) {\r\n if (RpcConfiguration.throwOnTokenMismatch) {\r\n throw new IModelError(BentleyStatus.ERROR, \"IModelRpcProps mismatch detected for this request.\");\r\n } else {\r\n Logger.logWarning(CommonLoggerCategory.RpcInterfaceBackend, \"IModelRpcProps mismatch detected for this request.\");\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static compareTokens(a: IModelRpcProps, b: IModelRpcProps): boolean {\r\n return a.key === b.key &&\r\n a.iTwinId === b.iTwinId &&\r\n a.iModelId === b.iModelId &&\r\n (undefined === a.changeset || (a.changeset.id === b.changeset?.id));\r\n }\r\n\r\n private async reject(error: any): Promise<any> {\r\n this._threw = true;\r\n return error;\r\n }\r\n\r\n private async fulfillResolved(value: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendResponseCreated, this);\r\n const result = RpcMarshaling.serialize(this.protocol, value);\r\n return this.fulfill(result, value);\r\n }\r\n\r\n private async fulfillRejected(reason: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n if (!RpcConfiguration.developmentMode)\r\n reason.stack = undefined;\r\n\r\n const result = RpcMarshaling.serialize(this.protocol, reason);\r\n\r\n if (reason instanceof RpcPendingResponse) {\r\n this._pending = true;\r\n this._threw = false;\r\n result.objects = reason.message;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedPending, this);\r\n } else if (this.supportsNoContent() && reason?.errorNumber === IModelStatus.NoContent) {\r\n this._noContent = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNoContent, this);\r\n } else if (reason instanceof RpcNotFoundResponse) {\r\n this._notFound = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNotFound, this);\r\n } else {\r\n this._threw = true;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendErrorOccurred, this);\r\n }\r\n\r\n return this.fulfill(result, reason);\r\n }\r\n\r\n private supportsNoContent() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedNoContent && this.request.protocolVersion >= RpcProtocolVersion.IntroducedNoContent;\r\n }\r\n\r\n private supportsStatusCategory() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n if (!this.protocol.supportsStatusCategory) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.request.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;\r\n }\r\n\r\n private fulfill(result: RpcSerializedValue, rawResult: any): RpcRequestFulfillment {\r\n const fulfillment: RpcRequestFulfillment = {\r\n result,\r\n rawResult,\r\n status: this.protocol.getCode(this.status),\r\n id: this.request.id,\r\n interfaceName: (typeof (this.operation) === \"undefined\") ? \"\" : this.operation.interfaceDefinition.interfaceName,\r\n allowCompression: this.operation?.policy.allowResponseCompression || false,\r\n };\r\n\r\n this.transformResponseStatus(fulfillment, rawResult);\r\n\r\n try {\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition) as any;\r\n if (impl[CURRENT_INVOCATION] === this) {\r\n impl[CURRENT_INVOCATION] = undefined;\r\n }\r\n } catch (_err) { }\r\n\r\n return fulfillment;\r\n }\r\n\r\n private lookupOperationFunction(implementation: RpcInterface): (...args: any[]) => Promise<any> {\r\n const func = (implementation as any)[this.operation.operationName];\r\n if (!func || typeof (func) !== \"function\")\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface class \"${implementation.constructor.name}\" does not implement operation \"${this.operation.operationName}\".`);\r\n\r\n return func;\r\n }\r\n\r\n private transformResponseStatus(fulfillment: RpcRequestFulfillment, rawResult: any) {\r\n if (!this.supportsStatusCategory()) {\r\n return;\r\n }\r\n\r\n let managedStatus: \"notFound\" | \"pending\" | \"noContent\" | undefined;\r\n if (this._pending) {\r\n managedStatus = \"pending\";\r\n } else if (this._notFound) {\r\n managedStatus = \"notFound\";\r\n } else if (this._noContent) {\r\n managedStatus = \"noContent\";\r\n }\r\n\r\n if (managedStatus) {\r\n const responseValue = fulfillment.result.objects;\r\n const status: RpcManagedStatus = { iTwinRpcCoreResponse: true, managedStatus, responseValue };\r\n fulfillment.result.objects = JSON.stringify(status);\r\n status.responseValue = rawResult; // for ipc case\r\n fulfillment.rawResult = status;\r\n }\r\n\r\n if (rawResult instanceof Error) {\r\n fulfillment.status = StatusCategory.for(rawResult).code;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcInvocation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcInvocation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,sDAA8J;AAC9J,qEAAkE;AAElE,mDAAgD;AAChD,qDAAkD;AAElD,yDAAsD;AACtD,iDAAoE;AACpE,6CAA0F;AAC1F,mDAAoE;AACpE,iDAA8C;AAC9C,+CAA+H;AAC/H,+CAAgE;AAqChE;;GAEG;AACH,MAAa,aAAa;IAwBxB,mCAAmC;IACnC,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,+BAAgB,CAAC,QAAQ,CAAC,CAAC;YAC9C,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,+BAAgB,CAAC,OAAO,CAAC,CAAC;gBACxC,IAA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,CAAC;YAC1B,aAAa,GAAG,UAAU,CAAC;QAC7B,CAAC;aAAM,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAC3B,aAAa,GAAG,WAAW,CAAC;QAC9B,CAAC;QAED,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC;YACjD,MAAM,MAAM,GAAqB,EAAE,oBAAoB,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;YAC9F,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACpD,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC,eAAe;YACjD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC;QACjC,CAAC;QAED,IAAI,SAAS,YAAY,KAAK,EAAE,CAAC;YAC/B,WAAW,CAAC,MAAM,GAAG,6BAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;QAC1D,CAAC;IACH,CAAC;;AA7QH,sCA8QC;;AA7Qe,yBAAW,GAAmB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,AAAhD,CAAiD","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 { AccessToken, BentleyError, BentleyStatus, GuidString, IModelStatus, Logger, RpcInterfaceStatus, StatusCategory, Tracing } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { SessionProps } from \"../../SessionProps\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus } from \"./RpcConstants\";\r\nimport { RpcControlChannel, RpcNotFoundResponse, RpcPendingResponse } from \"./RpcControl\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcManagedStatus, RpcProtocol, RpcProtocolVersion, RpcRequestFulfillment, SerializedRpcRequest } from \"./RpcProtocol\";\r\nimport { CURRENT_INVOCATION, RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** The properties of an RpcActivity.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface RpcActivity extends SessionProps {\r\n /** Used for logging to correlate an Rpc activity between frontend and backend */\r\n readonly activityId: GuidString;\r\n\r\n /** access token for authorization */\r\n readonly accessToken: AccessToken;\r\n\r\n /** the name of the current rpc method */\r\n readonly rpcMethod?: string;\r\n\r\n readonly user?: string;\r\n}\r\n\r\n/** Serialized format for sending the request across the RPC layer\r\n * @public\r\n */\r\nexport interface SerializedRpcActivity {\r\n id: string;\r\n applicationId: string;\r\n applicationVersion: string;\r\n sessionId: string;\r\n authorization: string;\r\n user?: string;\r\n csrfToken?: { headerName: string, headerValue: string };\r\n}\r\n\r\n/** @internal */\r\nexport type RpcActivityRun = (activity: RpcActivity, fn: () => Promise<any>) => Promise<any>;\r\n\r\n/** An RPC operation invocation in response to a request.\r\n * @internal\r\n */\r\nexport class RpcInvocation {\r\n public static runActivity: RpcActivityRun = async (_activity, fn) => fn();\r\n private _threw: boolean = false;\r\n private _pending: boolean = false;\r\n private _notFound: boolean = false;\r\n private _noContent: boolean = false;\r\n private _timeIn: number = 0;\r\n private _timeOut: number = 0;\r\n\r\n /** The protocol for this invocation. */\r\n public readonly protocol: RpcProtocol;\r\n\r\n /** The received request. */\r\n public readonly request: SerializedRpcRequest;\r\n\r\n /** The operation of the request. */\r\n public readonly operation: RpcOperation = undefined as any;\r\n\r\n /** The implementation response. */\r\n public readonly result: Promise<any>;\r\n\r\n /** The fulfillment for this request. */\r\n public readonly fulfillment: Promise<RpcRequestFulfillment>;\r\n\r\n /** The status for this request. */\r\n public get status(): RpcRequestStatus {\r\n return this._threw ? RpcRequestStatus.Rejected :\r\n this._pending ? RpcRequestStatus.Pending :\r\n this._notFound ? RpcRequestStatus.NotFound :\r\n this._noContent ? RpcRequestStatus.NoContent :\r\n RpcRequestStatus.Resolved;\r\n }\r\n\r\n /** The elapsed time for this invocation. */\r\n public get elapsed(): number {\r\n return this._timeOut - this._timeIn;\r\n }\r\n\r\n /**\r\n * The invocation for the current RPC operation.\r\n * @note The return value of this function is only reliable in an RPC impl class member function where program control was received from the RpcInvocation constructor function.\r\n */\r\n public static current(rpcImpl: RpcInterface): RpcInvocation {\r\n return (rpcImpl as any)[CURRENT_INVOCATION];\r\n }\r\n\r\n /** Constructs an invocation. */\r\n public constructor(protocol: RpcProtocol, request: SerializedRpcRequest) {\r\n this._timeIn = new Date().getTime();\r\n this.protocol = protocol;\r\n this.request = request;\r\n\r\n try {\r\n try {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n\r\n const backend = this.operation.interfaceVersion;\r\n const frontend = this.request.operation.interfaceVersion;\r\n if (!RpcInterface.isVersionCompatible(backend, frontend)) {\r\n throw new IModelError(RpcInterfaceStatus.IncompatibleVersion, `Backend version ${backend} does not match frontend version ${frontend} for RPC interface ${this.operation.operationName}.`);\r\n }\r\n } catch (error) {\r\n if (this.handleUnknownOperation(error)) {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n\r\n this.result = this.resolve();\r\n } catch (error) {\r\n this.result = this.reject(error);\r\n }\r\n\r\n this.fulfillment = this.result.then(async (value) => this._threw ? this.fulfillRejected(value) : this.fulfillResolved(value), async (reason) => this.fulfillRejected(reason));\r\n }\r\n\r\n private handleUnknownOperation(error: any): boolean {\r\n RpcControlChannel.ensureInitialized();\r\n return this.protocol.configuration.controlChannel.handleUnknownOperation(this, error);\r\n }\r\n\r\n public static sanitizeForLog(activity?: RpcActivity) {\r\n /* eslint-disable @typescript-eslint/naming-convention */\r\n return activity ? {\r\n ActivityId: activity.activityId, SessionId: activity.sessionId, ApplicationId: activity.applicationId, ApplicationVersion: activity.applicationVersion, rpcMethod: activity.rpcMethod,\r\n } : undefined;\r\n /* eslint-enable @typescript-eslint/naming-convention */\r\n }\r\n\r\n private async resolve(): Promise<any> {\r\n const request = this.request;\r\n const activity: RpcActivity = {\r\n activityId: request.id,\r\n applicationId: request.applicationId,\r\n applicationVersion: request.applicationVersion,\r\n sessionId: request.sessionId,\r\n user: request.user,\r\n accessToken: request.authorization,\r\n rpcMethod: request.operation.operationName,\r\n };\r\n\r\n try {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.RequestReceived, this);\r\n\r\n const parameters = request.parametersOverride || RpcMarshaling.deserialize(this.protocol, request.parameters);\r\n this.applyPolicies(parameters);\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition);\r\n (impl as any)[CURRENT_INVOCATION] = this;\r\n const op = this.lookupOperationFunction(impl);\r\n\r\n return await RpcInvocation.runActivity(activity, async () => op.call(impl, ...parameters)\r\n .catch(async (error) => {\r\n // this catch block is intentionally placed inside `runActivity` to attach the right logging metadata and use the correct openTelemetry span.\r\n if (!(error instanceof RpcPendingResponse)) {\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, \"Error in RPC operation\", { error: BentleyError.getErrorProps(error) });\r\n Tracing.recordException(error);\r\n }\r\n throw error;\r\n }));\r\n } catch (error: unknown) {\r\n return this.reject(error);\r\n }\r\n }\r\n\r\n private applyPolicies(parameters: any) {\r\n if (!parameters || !Array.isArray(parameters))\r\n return;\r\n\r\n for (let i = 0; i !== parameters.length; ++i) {\r\n const parameter = parameters[i];\r\n const isToken = typeof (parameter) === \"object\" && parameter !== null && parameter.hasOwnProperty(\"iModelId\") && parameter.hasOwnProperty(\"iTwinId\");\r\n if (isToken && this.protocol.checkToken && !this.operation.policy.allowTokenMismatch) {\r\n const inflated = this.protocol.inflateToken(parameter, this.request);\r\n parameters[i] = inflated;\r\n\r\n if (!RpcInvocation.compareTokens(parameter, inflated)) {\r\n if (RpcConfiguration.throwOnTokenMismatch) {\r\n throw new IModelError(BentleyStatus.ERROR, \"IModelRpcProps mismatch detected for this request.\");\r\n } else {\r\n Logger.logWarning(CommonLoggerCategory.RpcInterfaceBackend, \"IModelRpcProps mismatch detected for this request.\");\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static compareTokens(a: IModelRpcProps, b: IModelRpcProps): boolean {\r\n return a.key === b.key &&\r\n a.iTwinId === b.iTwinId &&\r\n a.iModelId === b.iModelId &&\r\n (undefined === a.changeset || (a.changeset.id === b.changeset?.id));\r\n }\r\n\r\n private async reject(error: any): Promise<any> {\r\n this._threw = true;\r\n return error;\r\n }\r\n\r\n private async fulfillResolved(value: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendResponseCreated, this);\r\n const result = RpcMarshaling.serialize(this.protocol, value);\r\n return this.fulfill(result, value);\r\n }\r\n\r\n private async fulfillRejected(reason: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n if (!RpcConfiguration.developmentMode)\r\n reason.stack = undefined;\r\n\r\n const result = RpcMarshaling.serialize(this.protocol, reason);\r\n\r\n if (reason instanceof RpcPendingResponse) {\r\n this._pending = true;\r\n this._threw = false;\r\n result.objects = reason.message;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedPending, this);\r\n } else if (this.supportsNoContent() && reason?.errorNumber === IModelStatus.NoContent) {\r\n this._noContent = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNoContent, this);\r\n } else if (reason instanceof RpcNotFoundResponse) {\r\n this._notFound = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNotFound, this);\r\n } else {\r\n this._threw = true;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendErrorOccurred, this);\r\n }\r\n\r\n return this.fulfill(result, reason);\r\n }\r\n\r\n private supportsNoContent() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedNoContent && this.request.protocolVersion >= RpcProtocolVersion.IntroducedNoContent;\r\n }\r\n\r\n private supportsStatusCategory() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n if (!this.protocol.supportsStatusCategory) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.request.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;\r\n }\r\n\r\n private fulfill(result: RpcSerializedValue, rawResult: any): RpcRequestFulfillment {\r\n const fulfillment: RpcRequestFulfillment = {\r\n result,\r\n rawResult,\r\n status: this.protocol.getCode(this.status),\r\n id: this.request.id,\r\n interfaceName: (typeof (this.operation) === \"undefined\") ? \"\" : this.operation.interfaceDefinition.interfaceName,\r\n allowCompression: this.operation ? this.operation.policy.allowResponseCompression : true,\r\n };\r\n\r\n this.transformResponseStatus(fulfillment, rawResult);\r\n\r\n try {\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition) as any;\r\n if (impl[CURRENT_INVOCATION] === this) {\r\n impl[CURRENT_INVOCATION] = undefined;\r\n }\r\n } catch (_err) { }\r\n\r\n return fulfillment;\r\n }\r\n\r\n private lookupOperationFunction(implementation: RpcInterface): (...args: any[]) => Promise<any> {\r\n const func = (implementation as any)[this.operation.operationName];\r\n if (!func || typeof (func) !== \"function\")\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface class \"${implementation.constructor.name}\" does not implement operation \"${this.operation.operationName}\".`);\r\n\r\n return func;\r\n }\r\n\r\n private transformResponseStatus(fulfillment: RpcRequestFulfillment, rawResult: any) {\r\n if (!this.supportsStatusCategory()) {\r\n return;\r\n }\r\n\r\n let managedStatus: \"notFound\" | \"pending\" | \"noContent\" | undefined;\r\n if (this._pending) {\r\n managedStatus = \"pending\";\r\n } else if (this._notFound) {\r\n managedStatus = \"notFound\";\r\n } else if (this._noContent) {\r\n managedStatus = \"noContent\";\r\n }\r\n\r\n if (managedStatus) {\r\n const responseValue = fulfillment.result.objects;\r\n const status: RpcManagedStatus = { iTwinRpcCoreResponse: true, managedStatus, responseValue };\r\n fulfillment.result.objects = JSON.stringify(status);\r\n status.responseValue = rawResult; // for ipc case\r\n fulfillment.rawResult = status;\r\n }\r\n\r\n if (rawResult instanceof Error) {\r\n fulfillment.status = StatusCategory.for(rawResult).code;\r\n }\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcMarshaling.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcMarshaling.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAY5C,gBAAgB;AAChB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,IAAI,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,gBAAgB;AAChB,yBAAiB,sBAAsB,CAAC;IACtC,SAAgB,aAAa,IAAI,sBAAsB,CAEtD;CACF;AAED,gBAAgB;AAChB,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,gBAAgB;AAChB,yBAAiB,kBA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AE,WAAW,GAAG,SAAS,EAAE,KAAK,EAAE,GAAG,GAAG,kBAAkB;IAe1F,4BAA4B;WACd,WAAW,CAAC,QAAQ,EAAE,WAAW,GAAG,SAAS,EAAE,KAAK,EAAE,kBAAkB,GAAG,GAAG;CAoB7F"}
@@ -38,9 +38,8 @@ class RpcMarshaling {
38
38
  /** Serializes a value. */
39
39
  static serialize(protocol, value) {
40
40
  const serialized = RpcSerializedValue.create();
41
- if (typeof (value) === "undefined") {
41
+ if (value === undefined)
42
42
  return serialized;
43
- }
44
43
  marshalingTarget = serialized;
45
44
  chunkThreshold = protocol ? protocol.transferChunkThreshold : 0;
46
45
  serialized.objects = JSON.stringify(value, (_key, _value) => WireFormat.marshal(_key, _value));
@@ -1 +1 @@
1
- {"version":3,"file":"RpcMarshaling.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcMarshaling.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,mDAA+D;AAI/D,0BAA0B;AAC1B,4CAA4C;AAE5C,SAAS,QAAQ,CAAC,GAAQ;IACxB,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,UAAU,IAAI,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC9I,CAAC;AAED,IAAI,gBAAoC,CAAC;AACzC,IAAI,cAAc,GAAG,CAAC,CAAC;AAUvB,gBAAgB;AAChB,IAAiB,sBAAsB,CAItC;AAJD,WAAiB,sBAAsB;IACrC,SAAgB,aAAa;QAC3B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAC3D,CAAC;IAFe,oCAAa,gBAE5B,CAAA;AACH,CAAC,EAJgB,sBAAsB,sCAAtB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CAAC,CAAC;YACtD,KAAK,CAAC,OAAO,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACtF,KAAK,CAAC,IAAI,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;YACzF,KAAK,CAAC,OAAO,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;YAC/F,KAAK,CAAC,KAAK,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;YAC3F,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","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, IModelError } from \"../../IModelError\";\r\nimport { BackendReadable } from \"../../BackendTypes\";\r\nimport { RpcProtocol } from \"./RpcProtocol\";\r\n\r\n// cspell:ignore unmarshal\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nfunction isBuffer(val: any): boolean {\r\n return val && typeof (val.constructor) !== \"undefined\" && typeof (val.constructor.isBuffer) === \"function\" && val.constructor.isBuffer(val);\r\n}\r\n\r\nlet marshalingTarget: RpcSerializedValue;\r\nlet chunkThreshold = 0;\r\n\r\n/** @internal */\r\nexport interface MarshalingBinaryMarker {\r\n isBinary: true;\r\n index: number;\r\n size: number;\r\n chunks: number;\r\n}\r\n\r\n/** @internal */\r\nexport namespace MarshalingBinaryMarker {\r\n export function createDefault(): MarshalingBinaryMarker {\r\n return { isBinary: true, index: 0, size: -1, chunks: 1 };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface RpcSerializedValue {\r\n objects: string;\r\n data: Uint8Array[];\r\n chunks?: number;\r\n stream?: BackendReadable;\r\n}\r\n\r\n/** @internal */\r\nexport namespace RpcSerializedValue {\r\n export function create(objects = \"\", data: Uint8Array[] = []): RpcSerializedValue {\r\n return { objects, data };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class RpcMarshaling {\r\n private constructor() { }\r\n\r\n /** Serializes a value. */\r\n public static serialize(protocol: RpcProtocol | undefined, value: any): RpcSerializedValue {\r\n const serialized = RpcSerializedValue.create();\r\n\r\n if (typeof (value) === \"undefined\") {\r\n return serialized;\r\n }\r\n\r\n marshalingTarget = serialized;\r\n chunkThreshold = protocol ? protocol.transferChunkThreshold : 0;\r\n serialized.objects = JSON.stringify(value, (_key, _value) => WireFormat.marshal(_key, _value));\r\n marshalingTarget = undefined as any;\r\n chunkThreshold = 0;\r\n\r\n return serialized;\r\n }\r\n\r\n /** Deserializes a value. */\r\n public static deserialize(protocol: RpcProtocol | undefined, value: RpcSerializedValue): any {\r\n if (value.objects === \"\") {\r\n return undefined;\r\n }\r\n\r\n marshalingTarget = value;\r\n chunkThreshold = protocol ? protocol.transferChunkThreshold : 0;\r\n let result;\r\n try {\r\n result = JSON.parse(value.objects, (_key, _value) => WireFormat.unmarshal(_key, _value));\r\n } catch (error) {\r\n if (error instanceof SyntaxError)\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid JSON: \"${value.objects}\"`);\r\n throw error;\r\n }\r\n marshalingTarget = undefined as any;\r\n chunkThreshold = 0;\r\n\r\n return result;\r\n }\r\n}\r\n\r\nclass WireFormat {\r\n /** JSON.stringify replacer callback. */\r\n public static marshal(this: any, _key: string, value: any) {\r\n const asBinary = WireFormat.marshalBinary(value);\r\n if (asBinary) {\r\n return asBinary;\r\n }\r\n\r\n const asError = WireFormat.marshalError(value);\r\n if (asError) {\r\n return asError;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /** JSON.parse reviver callback. */\r\n public static unmarshal(_key: string, value: any) {\r\n if (typeof (value) === \"object\" && value !== null && value.hasOwnProperty(\"isBinary\") && value.isBinary) {\r\n return WireFormat.unmarshalBinary(value);\r\n }\r\n\r\n return value;\r\n }\r\n\r\n private static marshalBinary(value: any): any {\r\n if (value instanceof Uint8Array || isBuffer(value)) {\r\n const marker: MarshalingBinaryMarker = { isBinary: true, index: -1, size: value.byteLength, chunks: 1 };\r\n\r\n if (chunkThreshold && value.byteLength > chunkThreshold) {\r\n marker.index = marshalingTarget.data.length;\r\n marker.chunks = 0;\r\n\r\n let cursor = value.byteOffset;\r\n const end = cursor + value.byteLength;\r\n let chunk = chunkThreshold;\r\n\r\n for (; ;) {\r\n if (cursor >= end) {\r\n break;\r\n }\r\n\r\n marshalingTarget.data.push(new Uint8Array(value.buffer, cursor, chunk));\r\n ++marker.chunks;\r\n cursor += chunk;\r\n\r\n const consumed = cursor - value.byteOffset;\r\n const remaining = value.byteLength - consumed;\r\n chunk = Math.min(chunkThreshold, remaining);\r\n }\r\n } else {\r\n marker.index = marshalingTarget.data.push(value) - 1;\r\n }\r\n\r\n return marker;\r\n } else {\r\n return undefined;\r\n }\r\n }\r\n\r\n private static unmarshalBinary(value: MarshalingBinaryMarker): any {\r\n if (value.index >= marshalingTarget.data.length) {\r\n throw new IModelError(BentleyStatus.ERROR, `Cannot unmarshal missing binary value.`);\r\n }\r\n\r\n if (value.chunks === 0) {\r\n return new Uint8Array();\r\n } else if (value.chunks === 1) {\r\n return new Uint8Array(marshalingTarget.data[value.index]);\r\n } else {\r\n const buffer = new ArrayBuffer(value.size);\r\n const view = new Uint8Array(buffer);\r\n\r\n let cursor = 0;\r\n for (let c = 0; c !== value.chunks; ++c) {\r\n const chunk = marshalingTarget.data[value.index + c];\r\n view.set(chunk, cursor);\r\n cursor += chunk.byteLength;\r\n }\r\n\r\n return view;\r\n }\r\n }\r\n\r\n private static marshalError(value: any) {\r\n if (value instanceof Error) {\r\n const props = Object.getOwnPropertyDescriptors(value);\r\n props.isError = { configurable: true, enumerable: true, writable: true, value: true };\r\n props.name = { configurable: true, enumerable: true, writable: true, value: value.name };\r\n props.message = { configurable: true, enumerable: true, writable: true, value: value.message };\r\n props.stack = { configurable: true, enumerable: true, writable: true, value: value.stack };\r\n return Object.create(Object.prototype, props);\r\n }\r\n\r\n return undefined;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcMarshaling.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcMarshaling.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,mDAA+D;AAI/D,0BAA0B;AAC1B,4CAA4C;AAE5C,SAAS,QAAQ,CAAC,GAAQ;IACxB,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,UAAU,IAAI,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC9I,CAAC;AAED,IAAI,gBAAoC,CAAC;AACzC,IAAI,cAAc,GAAG,CAAC,CAAC;AAUvB,gBAAgB;AAChB,IAAiB,sBAAsB,CAItC;AAJD,WAAiB,sBAAsB;IACrC,SAAgB,aAAa;QAC3B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAC3D,CAAC;IAFe,oCAAa,gBAE5B,CAAA;AACH,CAAC,EAJgB,sBAAsB,sCAAtB,sBAAsB,QAIt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AY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACtF,KAAK,CAAC,IAAI,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;YACzF,KAAK,CAAC,OAAO,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;YAC/F,KAAK,CAAC,KAAK,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;YAC3F,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","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, IModelError } from \"../../IModelError\";\r\nimport { BackendReadable } from \"../../BackendTypes\";\r\nimport { RpcProtocol } from \"./RpcProtocol\";\r\n\r\n// cspell:ignore unmarshal\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nfunction isBuffer(val: any): boolean {\r\n return val && typeof (val.constructor) !== \"undefined\" && typeof (val.constructor.isBuffer) === \"function\" && val.constructor.isBuffer(val);\r\n}\r\n\r\nlet marshalingTarget: RpcSerializedValue;\r\nlet chunkThreshold = 0;\r\n\r\n/** @internal */\r\nexport interface MarshalingBinaryMarker {\r\n isBinary: true;\r\n index: number;\r\n size: number;\r\n chunks: number;\r\n}\r\n\r\n/** @internal */\r\nexport namespace MarshalingBinaryMarker {\r\n export function createDefault(): MarshalingBinaryMarker {\r\n return { isBinary: true, index: 0, size: -1, chunks: 1 };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface RpcSerializedValue {\r\n objects: string;\r\n data: Uint8Array[];\r\n chunks?: number;\r\n stream?: BackendReadable;\r\n}\r\n\r\n/** @internal */\r\nexport namespace RpcSerializedValue {\r\n export function create(objects = \"\", data: Uint8Array[] = []): RpcSerializedValue {\r\n return { objects, data };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class RpcMarshaling {\r\n private constructor() { }\r\n\r\n /** Serializes a value. */\r\n public static serialize(protocol: RpcProtocol | undefined, value: any): RpcSerializedValue {\r\n const serialized = RpcSerializedValue.create();\r\n\r\n if (value === undefined)\r\n return serialized;\r\n\r\n marshalingTarget = serialized;\r\n chunkThreshold = protocol ? protocol.transferChunkThreshold : 0;\r\n serialized.objects = JSON.stringify(value, (_key, _value) => WireFormat.marshal(_key, _value));\r\n marshalingTarget = undefined as any;\r\n chunkThreshold = 0;\r\n\r\n return serialized;\r\n }\r\n\r\n /** Deserializes a value. */\r\n public static deserialize(protocol: RpcProtocol | undefined, value: RpcSerializedValue): any {\r\n if (value.objects === \"\") {\r\n return undefined;\r\n }\r\n\r\n marshalingTarget = value;\r\n chunkThreshold = protocol ? protocol.transferChunkThreshold : 0;\r\n let result;\r\n try {\r\n result = JSON.parse(value.objects, (_key, _value) => WireFormat.unmarshal(_key, _value));\r\n } catch (error) {\r\n if (error instanceof SyntaxError)\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid JSON: \"${value.objects}\"`);\r\n throw error;\r\n }\r\n marshalingTarget = undefined as any;\r\n chunkThreshold = 0;\r\n\r\n return result;\r\n }\r\n}\r\n\r\nclass WireFormat {\r\n /** JSON.stringify replacer callback. */\r\n public static marshal(this: any, _key: string, value: any) {\r\n const asBinary = WireFormat.marshalBinary(value);\r\n if (asBinary) {\r\n return asBinary;\r\n }\r\n\r\n const asError = WireFormat.marshalError(value);\r\n if (asError) {\r\n return asError;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /** JSON.parse reviver callback. */\r\n public static unmarshal(_key: string, value: any) {\r\n if (typeof (value) === \"object\" && value !== null && value.hasOwnProperty(\"isBinary\") && value.isBinary) {\r\n return WireFormat.unmarshalBinary(value);\r\n }\r\n\r\n return value;\r\n }\r\n\r\n private static marshalBinary(value: Uint8Array): MarshalingBinaryMarker | undefined {\r\n if (value instanceof Uint8Array || isBuffer(value)) {\r\n const marker: MarshalingBinaryMarker = { isBinary: true, index: -1, size: value.byteLength, chunks: 1 };\r\n\r\n if (chunkThreshold && value.byteLength > chunkThreshold) {\r\n marker.index = marshalingTarget.data.length;\r\n marker.chunks = 0;\r\n\r\n let cursor = value.byteOffset;\r\n const end = cursor + value.byteLength;\r\n let chunk = chunkThreshold;\r\n\r\n for (; ;) {\r\n if (cursor >= end) {\r\n break;\r\n }\r\n\r\n marshalingTarget.data.push(new Uint8Array(value.buffer, cursor, chunk));\r\n ++marker.chunks;\r\n cursor += chunk;\r\n\r\n const consumed = cursor - value.byteOffset;\r\n const remaining = value.byteLength - consumed;\r\n chunk = Math.min(chunkThreshold, remaining);\r\n }\r\n } else {\r\n marker.index = marshalingTarget.data.push(value) - 1;\r\n }\r\n\r\n return marker;\r\n } else {\r\n return undefined;\r\n }\r\n }\r\n\r\n private static unmarshalBinary(value: MarshalingBinaryMarker): Uint8Array {\r\n if (value.index >= marshalingTarget.data.length) {\r\n throw new IModelError(BentleyStatus.ERROR, `Cannot unmarshal missing binary value.`);\r\n }\r\n\r\n if (value.chunks === 0) {\r\n return new Uint8Array();\r\n } else if (value.chunks === 1) {\r\n return new Uint8Array(marshalingTarget.data[value.index]);\r\n } else {\r\n const buffer = new ArrayBuffer(value.size);\r\n const view = new Uint8Array(buffer);\r\n\r\n let cursor = 0;\r\n for (let c = 0; c !== value.chunks; ++c) {\r\n const chunk = marshalingTarget.data[value.index + c];\r\n view.set(chunk, cursor);\r\n cursor += chunk.byteLength;\r\n }\r\n\r\n return view;\r\n }\r\n }\r\n\r\n private static marshalError(value: unknown) {\r\n if (value instanceof Error) {\r\n const props = Object.getOwnPropertyDescriptors(value);\r\n props.isError = { configurable: true, enumerable: true, writable: true, value: true };\r\n props.name = { configurable: true, enumerable: true, writable: true, value: value.name };\r\n props.message = { configurable: true, enumerable: true, writable: true, value: value.message };\r\n props.stack = { configurable: true, enumerable: true, writable: true, value: value.stack };\r\n return Object.create(Object.prototype, props);\r\n }\r\n\r\n return undefined;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcOperation.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcOperation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EACL,oBAAoB,EAAE,wCAAwC,EAAE,yBAAyB,EAAE,4BAA4B,EACxH,MAAM,cAAc,CAAC;AAItB;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,4DAA4D;IACrD,KAAK,EAAE,yBAAyB,CAAkD;IAEzF,oEAAoE;IAC7D,aAAa,EAAE,wCAAwC,CAAkE;IAEhI,qEAAqE;IAC9D,eAAe,EAAE,oBAAoB,CAAqB;IAEjE,oEAAoE;IAC7D,YAAY,EAAE,oBAAoB,CAAqB;IAE9D;;;OAGG;IACI,oBAAoB,EAAE,4BAA4B,CAA8C;IAEvG,6DAA6D;IACtD,eAAe,EAAE,OAAO,CAAS;IAExC,yHAAyH;IAClH,kBAAkB,EAAE,OAAO,CAAS;IAE3C,+FAA+F;IACxF,wBAAwB,EAAE,OAAO,CAAS;CAClD;AAED;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gB,IAAI,MAAM,CAAsD;IAE3F,qCAAqC;IAC9B,MAAM,EAAE,kBAAkB,CAAC;IAElC,gBAAgB;gBACG,UAAU,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB;IAMpG,gBAAgB;WACF,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;CAO/D;AAED,gBAAgB;AAChB,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElE,gBAAgB;AAChB,yBAAiB,YAAY,CAAC;IAW5B,sEAAsE;IACtE,SAAgB,SAAS,CAAC,MAAM,EAAE,kBAAkB,GAAG,uBAAuB,oDACpB,MAAM,cAAc,kBAAkB,UAG/F;IAED,8FAA8F;IAC9F,SAAgB,oBAAoB,CAAC,OAAO,GAAE,uBAA2D,oDAC/C,MAAM,cAAc,kBAAkB,UAK/F;IAED,mHAAmH;IACnH,SAAgB,eAAe,CAAC,OAAO,EAAE,yBAAyB,oDACR,MAAM,cAAc,kBAAkB,UAK/F;IAED,sFAAsF;IACtF,SAAgB,gBAAgB,CAAC,MAAM,EAAE,kBAAkB,GAAG,uBAAuB,2EAIpF;CACF"}
@@ -36,7 +36,7 @@ class RpcOperationPolicy {
36
36
  /** Whether the IModelRpcProps in the operation parameter list is allowed to differ from the token in the request URL. */
37
37
  this.allowTokenMismatch = false;
38
38
  /** Whether to compress the operation response with one of the client's supported encodings. */
39
- this.allowResponseCompression = false;
39
+ this.allowResponseCompression = true;
40
40
  }
41
41
  }
42
42
  exports.RpcOperationPolicy = RpcOperationPolicy;
@@ -1 +1 @@
1
- {"version":3,"file":"RpcOperation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcOperation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AAEpD,mDAAgD;AAEhD,iDAAyD;AACzD,+CAA+D;AAK/D,4CAA4C;AAE5C;;GAEG;AACH,MAAa,kBAA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,CAAC;IACJ,CAAC;IANe,4BAAe,kBAM9B,CAAA;IAED,sFAAsF;IACtF,SAAgB,gBAAgB,CAAC,MAAoD;QACnF,OAAO,CAAyB,UAAqC,EAAE,EAAE;YACtE,UAAkB,CAAC,oBAAM,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QACvD,CAAC,CAAC;IACJ,CAAC;IAJe,6BAAgB,mBAI/B,CAAA;AACH,CAAC,EA1CgB,YAAY,4BAAZ,YAAY,QA0C5B","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 { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface, RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { OPERATION, POLICY, RpcRegistry } from \"./RpcRegistry\";\r\nimport {\r\n RpcRequestCallback_T, RpcRequestInitialRetryIntervalSupplier_T, RpcRequestTokenSupplier_T, RpcResponseCachingCallback_T,\r\n} from \"./RpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** The policy for an RPC operation.\r\n * @internal\r\n */\r\nexport class RpcOperationPolicy {\r\n /** Supplies the IModelRpcProps for an operation request. */\r\n public token: RpcRequestTokenSupplier_T = (request) => request.findTokenPropsParameter();\r\n\r\n /** Supplies the initial retry interval for an operation request. */\r\n public retryInterval: RpcRequestInitialRetryIntervalSupplier_T = (configuration) => configuration.pendingOperationRetryInterval;\r\n\r\n /** Called before every operation request on the frontend is sent. */\r\n public requestCallback: RpcRequestCallback_T = (_request) => { };\r\n\r\n /** Called after every operation request on the frontend is sent. */\r\n public sentCallback: RpcRequestCallback_T = (_request) => { };\r\n\r\n /**\r\n * Determines if caching is permitted for an operation response.\r\n * @note Not all RPC protocols support caching.\r\n */\r\n public allowResponseCaching: RpcResponseCachingCallback_T = (_request) => RpcResponseCacheControl.None;\r\n\r\n /** Forces RpcConfiguration.strictMode for this operation. */\r\n public forceStrictMode: boolean = false;\r\n\r\n /** Whether the IModelRpcProps in the operation parameter list is allowed to differ from the token in the request URL. */\r\n public allowTokenMismatch: boolean = false;\r\n\r\n /** Whether to compress the operation response with one of the client's supported encodings. */\r\n public allowResponseCompression: boolean = false;\r\n}\r\n\r\n/** An RPC operation descriptor.\r\n * @internal\r\n */\r\nexport class RpcOperation {\r\n /** A fallback token to use for RPC requests that do not semantically depend on an iModel. */\r\n public static fallbackToken: IModelRpcProps | undefined = undefined;\r\n\r\n /** Looks up an RPC operation by name. */\r\n public static lookup(target: string | RpcInterfaceDefinition, operationName: string): RpcOperation {\r\n const definition = typeof (target) === \"string\" ? RpcRegistry.instance.lookupInterfaceDefinition(target) : target;\r\n const propertyName: string | symbol = RpcOperation.computeOperationName(operationName);\r\n\r\n const proto = (definition.prototype as any);\r\n if (!proto.hasOwnProperty(propertyName))\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface class \"${definition.interfaceName}\" does not does not declare operation \"${operationName}\"`);\r\n\r\n return proto[propertyName][OPERATION];\r\n }\r\n\r\n /** Iterates the operations of an RPC interface definition. */\r\n public static forEach(definition: RpcInterfaceDefinition, callback: (operation: RpcOperation) => void): void {\r\n Object.getOwnPropertyNames(definition.prototype).forEach((operationName) => {\r\n if (operationName === \"constructor\" || operationName === \"configurationSupplier\")\r\n return;\r\n\r\n const propertyName = RpcOperation.computeOperationName(operationName);\r\n callback((definition.prototype as any)[propertyName][OPERATION]);\r\n });\r\n }\r\n\r\n /** The RPC interface definition for this operation. */\r\n public readonly interfaceDefinition: RpcInterfaceDefinition;\r\n\r\n /** The name of this operation. */\r\n public readonly operationName: string;\r\n\r\n /** The version of this operation. */\r\n public get interfaceVersion(): string { return this.interfaceDefinition.interfaceVersion; }\r\n\r\n /** The policy for this operation. */\r\n public policy: RpcOperationPolicy;\r\n\r\n /** @internal */\r\n public constructor(definition: RpcInterfaceDefinition, operation: string, policy: RpcOperationPolicy) {\r\n this.interfaceDefinition = definition;\r\n this.operationName = operation;\r\n this.policy = policy;\r\n }\r\n\r\n /** @internal */\r\n public static computeOperationName(identifier: string): string {\r\n const c = identifier.indexOf(\":\");\r\n if (c === -1)\r\n return identifier;\r\n\r\n return identifier.substring(0, c + 1);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport type RpcOperationPolicyProps = Partial<RpcOperationPolicy>;\r\n\r\n/** @internal */\r\nexport namespace RpcOperation { // eslint-disable-line no-redeclare\r\n function obtainInstance(obj: RpcOperationPolicy | RpcOperationPolicyProps) {\r\n if (obj instanceof RpcOperationPolicy) {\r\n return obj;\r\n } else {\r\n const instance = new RpcOperationPolicy();\r\n Object.assign(instance, obj);\r\n return instance;\r\n }\r\n }\r\n\r\n /** Decorator for setting the policy for an RPC operation function. */\r\n export function setPolicy(policy: RpcOperationPolicy | RpcOperationPolicyProps) {\r\n return <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => {\r\n descriptor.value[OPERATION] = new RpcOperation(target.constructor as any, propertyKey, obtainInstance(policy));\r\n };\r\n }\r\n\r\n /** Convenience decorator for setting an RPC operation policy that allows response caching. */\r\n export function allowResponseCaching(control: RpcResponseCacheControl = RpcResponseCacheControl.Immutable) {\r\n return <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => {\r\n descriptor.value[OPERATION] = new RpcOperation(target.constructor as any, propertyKey, new class extends RpcOperationPolicy {\r\n public override allowResponseCaching = () => control;\r\n }());\r\n };\r\n }\r\n\r\n /** Convenience decorator for setting an RPC operation policy that supplies the IModelRpcProps for an operation. */\r\n export function setRoutingProps(handler: RpcRequestTokenSupplier_T) {\r\n return <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => {\r\n descriptor.value[OPERATION] = new RpcOperation(target.constructor as any, propertyKey, new class extends RpcOperationPolicy {\r\n public override token = handler;\r\n }());\r\n };\r\n }\r\n\r\n /** Decorator for setting the default policy for an RPC interface definition class. */\r\n export function setDefaultPolicy(policy: RpcOperationPolicy | RpcOperationPolicyProps) {\r\n return <T extends RpcInterface>(definition: RpcInterfaceDefinition<T>) => {\r\n (definition as any)[POLICY] = obtainInstance(policy);\r\n };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcOperation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcOperation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AAEpD,mDAAgD;AAEhD,iDAAyD;AACzD,+CAA+D;AAK/D,4CAA4C;AAE5C;;GAEG;AACH,MAAa,kBAAkB;IAA/B;QACE,4DAA4D;QACrD,UAAK,GAA8B,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,uBAAuB,EAAE,CAAC;QAEzF,oEAAoE;QAC7D,kBAAa,GAA6C,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,CAAC,6BAA6B,CAAC;QAEhI,qEAAqE;QAC9D,oBAAe,GAAyB,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,CAAC;QAEjE,oEAAoE;QAC7D,iBAAY,GAAyB,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,CAAC;QAE9D;;;WAGG;QACI,yBAAoB,GAAiC,CAAC,QAAQ,EAAE,EAAE,CAAC,sCAAuB,CAAC,IAAI,CAAC;QAEvG,6DAA6D;QACtD,oBAAe,GAAY,KAAK,CAAC;QAExC,yHAAyH;QAClH,uBAAkB,GAAY,KAAK,CAAC;QAE3C,+FAA+F;QACxF,6BAAwB,GAAY,IAAI,CAAC;IAClD,CAAC;CAAA;AA3BD,gDA2BC;AAED;;GAEG;AACH,MAAa,YAAY;IAIvB,yCAAyC;IAClC,MAAM,CAAC,MAAM,CAAC,MAAu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AW,EAAE,IAAI,KAAM,SAAQ,kBAAkB;gBAAhC;;oBACzE,yBAAoB,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC;gBACvD,CAAC;aAAA,EAAE,CAAC,CAAC;QACP,CAAC,CAAC;IACJ,CAAC;IANe,iCAAoB,uBAMnC,CAAA;IAED,mHAAmH;IACnH,SAAgB,eAAe,CAAC,OAAkC;QAChE,OAAO,CAAyB,MAAS,EAAE,WAAmB,EAAE,UAA8B,EAAE,EAAE;YAChG,UAAU,CAAC,KAAK,CAAC,uBAAS,CAAC,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,WAAkB,EAAE,WAAW,EAAE,IAAI,KAAM,SAAQ,kBAAkB;gBAAhC;;oBACzE,UAAK,GAAG,OAAO,CAAC;gBAClC,CAAC;aAAA,EAAE,CAAC,CAAC;QACP,CAAC,CAAC;IACJ,CAAC;IANe,4BAAe,kBAM9B,CAAA;IAED,sFAAsF;IACtF,SAAgB,gBAAgB,CAAC,MAAoD;QACnF,OAAO,CAAyB,UAAqC,EAAE,EAAE;YACtE,UAAkB,CAAC,oBAAM,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QACvD,CAAC,CAAC;IACJ,CAAC;IAJe,6BAAgB,mBAI/B,CAAA;AACH,CAAC,EA1CgB,YAAY,4BAAZ,YAAY,QA0C5B","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 { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface, RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { OPERATION, POLICY, RpcRegistry } from \"./RpcRegistry\";\r\nimport {\r\n RpcRequestCallback_T, RpcRequestInitialRetryIntervalSupplier_T, RpcRequestTokenSupplier_T, RpcResponseCachingCallback_T,\r\n} from \"./RpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** The policy for an RPC operation.\r\n * @internal\r\n */\r\nexport class RpcOperationPolicy {\r\n /** Supplies the IModelRpcProps for an operation request. */\r\n public token: RpcRequestTokenSupplier_T = (request) => request.findTokenPropsParameter();\r\n\r\n /** Supplies the initial retry interval for an operation request. */\r\n public retryInterval: RpcRequestInitialRetryIntervalSupplier_T = (configuration) => configuration.pendingOperationRetryInterval;\r\n\r\n /** Called before every operation request on the frontend is sent. */\r\n public requestCallback: RpcRequestCallback_T = (_request) => { };\r\n\r\n /** Called after every operation request on the frontend is sent. */\r\n public sentCallback: RpcRequestCallback_T = (_request) => { };\r\n\r\n /**\r\n * Determines if caching is permitted for an operation response.\r\n * @note Not all RPC protocols support caching.\r\n */\r\n public allowResponseCaching: RpcResponseCachingCallback_T = (_request) => RpcResponseCacheControl.None;\r\n\r\n /** Forces RpcConfiguration.strictMode for this operation. */\r\n public forceStrictMode: boolean = false;\r\n\r\n /** Whether the IModelRpcProps in the operation parameter list is allowed to differ from the token in the request URL. */\r\n public allowTokenMismatch: boolean = false;\r\n\r\n /** Whether to compress the operation response with one of the client's supported encodings. */\r\n public allowResponseCompression: boolean = true;\r\n}\r\n\r\n/** An RPC operation descriptor.\r\n * @internal\r\n */\r\nexport class RpcOperation {\r\n /** A fallback token to use for RPC requests that do not semantically depend on an iModel. */\r\n public static fallbackToken: IModelRpcProps | undefined = undefined;\r\n\r\n /** Looks up an RPC operation by name. */\r\n public static lookup(target: string | RpcInterfaceDefinition, operationName: string): RpcOperation {\r\n const definition = typeof (target) === \"string\" ? RpcRegistry.instance.lookupInterfaceDefinition(target) : target;\r\n const propertyName: string | symbol = RpcOperation.computeOperationName(operationName);\r\n\r\n const proto = (definition.prototype as any);\r\n if (!proto.hasOwnProperty(propertyName))\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface class \"${definition.interfaceName}\" does not does not declare operation \"${operationName}\"`);\r\n\r\n return proto[propertyName][OPERATION];\r\n }\r\n\r\n /** Iterates the operations of an RPC interface definition. */\r\n public static forEach(definition: RpcInterfaceDefinition, callback: (operation: RpcOperation) => void): void {\r\n Object.getOwnPropertyNames(definition.prototype).forEach((operationName) => {\r\n if (operationName === \"constructor\" || operationName === \"configurationSupplier\")\r\n return;\r\n\r\n const propertyName = RpcOperation.computeOperationName(operationName);\r\n callback((definition.prototype as any)[propertyName][OPERATION]);\r\n });\r\n }\r\n\r\n /** The RPC interface definition for this operation. */\r\n public readonly interfaceDefinition: RpcInterfaceDefinition;\r\n\r\n /** The name of this operation. */\r\n public readonly operationName: string;\r\n\r\n /** The version of this operation. */\r\n public get interfaceVersion(): string { return this.interfaceDefinition.interfaceVersion; }\r\n\r\n /** The policy for this operation. */\r\n public policy: RpcOperationPolicy;\r\n\r\n /** @internal */\r\n public constructor(definition: RpcInterfaceDefinition, operation: string, policy: RpcOperationPolicy) {\r\n this.interfaceDefinition = definition;\r\n this.operationName = operation;\r\n this.policy = policy;\r\n }\r\n\r\n /** @internal */\r\n public static computeOperationName(identifier: string): string {\r\n const c = identifier.indexOf(\":\");\r\n if (c === -1)\r\n return identifier;\r\n\r\n return identifier.substring(0, c + 1);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport type RpcOperationPolicyProps = Partial<RpcOperationPolicy>;\r\n\r\n/** @internal */\r\nexport namespace RpcOperation { // eslint-disable-line no-redeclare\r\n function obtainInstance(obj: RpcOperationPolicy | RpcOperationPolicyProps) {\r\n if (obj instanceof RpcOperationPolicy) {\r\n return obj;\r\n } else {\r\n const instance = new RpcOperationPolicy();\r\n Object.assign(instance, obj);\r\n return instance;\r\n }\r\n }\r\n\r\n /** Decorator for setting the policy for an RPC operation function. */\r\n export function setPolicy(policy: RpcOperationPolicy | RpcOperationPolicyProps) {\r\n return <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => {\r\n descriptor.value[OPERATION] = new RpcOperation(target.constructor as any, propertyKey, obtainInstance(policy));\r\n };\r\n }\r\n\r\n /** Convenience decorator for setting an RPC operation policy that allows response caching. */\r\n export function allowResponseCaching(control: RpcResponseCacheControl = RpcResponseCacheControl.Immutable) {\r\n return <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => {\r\n descriptor.value[OPERATION] = new RpcOperation(target.constructor as any, propertyKey, new class extends RpcOperationPolicy {\r\n public override allowResponseCaching = () => control;\r\n }());\r\n };\r\n }\r\n\r\n /** Convenience decorator for setting an RPC operation policy that supplies the IModelRpcProps for an operation. */\r\n export function setRoutingProps(handler: RpcRequestTokenSupplier_T) {\r\n return <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => {\r\n descriptor.value[OPERATION] = new RpcOperation(target.constructor as any, propertyKey, new class extends RpcOperationPolicy {\r\n public override token = handler;\r\n }());\r\n };\r\n }\r\n\r\n /** Decorator for setting the default policy for an RPC interface definition class. */\r\n export function setDefaultPolicy(policy: RpcOperationPolicy | RpcOperationPolicyProps) {\r\n return <T extends RpcInterface>(definition: RpcInterfaceDefinition<T>) => {\r\n (definition as any)[POLICY] = obtainInstance(policy);\r\n };\r\n }\r\n}\r\n"]}
@@ -48,7 +48,7 @@ export interface RpcRequestFulfillment {
48
48
  /** A protocol-specific status code value for the request. */
49
49
  status: number;
50
50
  retry?: string;
51
- /** Whether to compress the result with one of the client's supported encodings. */
51
+ /** Whether to compress the result with one of the client's supported encodings. Defaults to true. */
52
52
  allowCompression?: boolean;
53
53
  }
54
54
  /** @internal */
@@ -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,MA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B;YACxE,yCAAyC;YACzC,EAAE,EAAE,EAAE;YAEN,6CAA6C;YAC7C,aAAa,EAAE,EAAE;YAEjB,sCAAsC;YACtC,kBAAkB,EAAE,EAAE;YAEtB,yCAAyC;YACzC,SAAS,EAAE,EAAE;YAEb,4CAA4C;YAC5C,aAAa,EAAE,EAAE;SAClB,CAAC;QAEF,oFAAoF;QAC7E,2BAAsB,GAAW,CAAC,CAAC;QAE1C,kEAAkE;QAC3D,oBAAe,GAAY,KAAK,CAAC;QAExC,0EAA0E;QACnE,eAAU,GAAY,KAAK,CAAC;QAEnC,gEAAgE;QACzD,2BAAsB,GAAY,KAAK,CAAC;QAkD7C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACzF,CAAC;IAED,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;;AAjHhG,kCAkHC;AAjHC,+DAA+D;AACxC,kBAAM,GAAqC,IAAI,sBAAO,EAAE,AAAlD,CAAmD;AAEhF,oFAAoF;AAC7D,2BAAe,GAAW,kBAAkB,CAAC,wBAAwB,AAAtD,CAAuD","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 { RpcNotFoundResponse } from \"./RpcControl\";\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/* eslint-disable deprecation/deprecation */\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 parametersOverride?: any[];\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 = 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\" | \"noContent\";\r\n responseValue: string | { message: string } | RpcNotFoundResponse;\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: 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,sDAA8C;AAG9C,yDAAsD;AACtD,iDAA6F;AAE7F,mDAAuE;AACvE,mDAAoE;AAwDpE,gBAAgB;AAChB,IAAiB,qBAAqB,CAYrC;AAZD,WAAiB,qBAAqB;IAC7B,KAAK,UAAU,eAAe,CAAC,OAA6B,EAAE,KAAU;QAC7E,MAAM,MAAM,GAAG,6BAAa,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAEzD,OAAO;YACL,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC,mBAAmB;YACpD,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,MAAM;YACN,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE,+BAAgB,CAAC,QAAQ;SAClC,CAAC;IACJ,CAAC;IAVqB,qCAAe,kBAUpC,CAAA;AACH,CAAC,EAZgB,qBAAqB,qCAArB,qBAAqB,QAYrC;AAOD;;GAEG;AAC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AAU,CAAC;IAElG,gBAAgB;IACT,mBAAmB,CAAC,WAAmC,EAAE,KAAmB,IAAU,CAAC;;AAjHhG,kCAkHC;AAjHC,+DAA+D;AACxC,kBAAM,GAAqC,IAAI,sBAAO,EAAE,AAAlD,CAAmD;AAEhF,oFAAoF;AAC7D,2BAAe,GAAW,kBAAkB,CAAC,wBAAwB,AAAtD,CAAuD","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 { RpcNotFoundResponse } from \"./RpcControl\";\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/* eslint-disable deprecation/deprecation */\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 parametersOverride?: any[];\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. Defaults to true. */\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 = 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\" | \"noContent\";\r\n responseValue: string | { message: string } | RpcNotFoundResponse;\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: 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"]}
@@ -205,7 +205,7 @@ export class RpcInvocation {
205
205
  status: this.protocol.getCode(this.status),
206
206
  id: this.request.id,
207
207
  interfaceName: (typeof (this.operation) === "undefined") ? "" : this.operation.interfaceDefinition.interfaceName,
208
- allowCompression: this.operation?.policy.allowResponseCompression || false,
208
+ allowCompression: this.operation ? this.operation.policy.allowResponseCompression : true,
209
209
  };
210
210
  this.transformResponseStatus(f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AW,CAAC,MAAM,CAAC,OAAO,CAAC;YACjD,MAAM,MAAM,GAAqB,EAAE,oBAAoB,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;YAC9F,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACpD,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC,eAAe;YACjD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC;QACjC,CAAC;QAED,IAAI,SAAS,YAAY,KAAK,EAAE,CAAC;YAC/B,WAAW,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;QAC1D,CAAC;IACH,CAAC;;;AA5Qa,yBAAW,GAAmB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,AAAhD,CAAiD","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 { AccessToken, BentleyError, BentleyStatus, GuidString, IModelStatus, Logger, RpcInterfaceStatus, StatusCategory, Tracing } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { SessionProps } from \"../../SessionProps\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus } from \"./RpcConstants\";\r\nimport { RpcControlChannel, RpcNotFoundResponse, RpcPendingResponse } from \"./RpcControl\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcManagedStatus, RpcProtocol, RpcProtocolVersion, RpcRequestFulfillment, SerializedRpcRequest } from \"./RpcProtocol\";\r\nimport { CURRENT_INVOCATION, RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** The properties of an RpcActivity.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface RpcActivity extends SessionProps {\r\n /** Used for logging to correlate an Rpc activity between frontend and backend */\r\n readonly activityId: GuidString;\r\n\r\n /** access token for authorization */\r\n readonly accessToken: AccessToken;\r\n\r\n /** the name of the current rpc method */\r\n readonly rpcMethod?: string;\r\n\r\n readonly user?: string;\r\n}\r\n\r\n/** Serialized format for sending the request across the RPC layer\r\n * @public\r\n */\r\nexport interface SerializedRpcActivity {\r\n id: string;\r\n applicationId: string;\r\n applicationVersion: string;\r\n sessionId: string;\r\n authorization: string;\r\n user?: string;\r\n csrfToken?: { headerName: string, headerValue: string };\r\n}\r\n\r\n/** @internal */\r\nexport type RpcActivityRun = (activity: RpcActivity, fn: () => Promise<any>) => Promise<any>;\r\n\r\n/** An RPC operation invocation in response to a request.\r\n * @internal\r\n */\r\nexport class RpcInvocation {\r\n public static runActivity: RpcActivityRun = async (_activity, fn) => fn();\r\n private _threw: boolean = false;\r\n private _pending: boolean = false;\r\n private _notFound: boolean = false;\r\n private _noContent: boolean = false;\r\n private _timeIn: number = 0;\r\n private _timeOut: number = 0;\r\n\r\n /** The protocol for this invocation. */\r\n public readonly protocol: RpcProtocol;\r\n\r\n /** The received request. */\r\n public readonly request: SerializedRpcRequest;\r\n\r\n /** The operation of the request. */\r\n public readonly operation: RpcOperation = undefined as any;\r\n\r\n /** The implementation response. */\r\n public readonly result: Promise<any>;\r\n\r\n /** The fulfillment for this request. */\r\n public readonly fulfillment: Promise<RpcRequestFulfillment>;\r\n\r\n /** The status for this request. */\r\n public get status(): RpcRequestStatus {\r\n return this._threw ? RpcRequestStatus.Rejected :\r\n this._pending ? RpcRequestStatus.Pending :\r\n this._notFound ? RpcRequestStatus.NotFound :\r\n this._noContent ? RpcRequestStatus.NoContent :\r\n RpcRequestStatus.Resolved;\r\n }\r\n\r\n /** The elapsed time for this invocation. */\r\n public get elapsed(): number {\r\n return this._timeOut - this._timeIn;\r\n }\r\n\r\n /**\r\n * The invocation for the current RPC operation.\r\n * @note The return value of this function is only reliable in an RPC impl class member function where program control was received from the RpcInvocation constructor function.\r\n */\r\n public static current(rpcImpl: RpcInterface): RpcInvocation {\r\n return (rpcImpl as any)[CURRENT_INVOCATION];\r\n }\r\n\r\n /** Constructs an invocation. */\r\n public constructor(protocol: RpcProtocol, request: SerializedRpcRequest) {\r\n this._timeIn = new Date().getTime();\r\n this.protocol = protocol;\r\n this.request = request;\r\n\r\n try {\r\n try {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n\r\n const backend = this.operation.interfaceVersion;\r\n const frontend = this.request.operation.interfaceVersion;\r\n if (!RpcInterface.isVersionCompatible(backend, frontend)) {\r\n throw new IModelError(RpcInterfaceStatus.IncompatibleVersion, `Backend version ${backend} does not match frontend version ${frontend} for RPC interface ${this.operation.operationName}.`);\r\n }\r\n } catch (error) {\r\n if (this.handleUnknownOperation(error)) {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n\r\n this.result = this.resolve();\r\n } catch (error) {\r\n this.result = this.reject(error);\r\n }\r\n\r\n this.fulfillment = this.result.then(async (value) => this._threw ? this.fulfillRejected(value) : this.fulfillResolved(value), async (reason) => this.fulfillRejected(reason));\r\n }\r\n\r\n private handleUnknownOperation(error: any): boolean {\r\n RpcControlChannel.ensureInitialized();\r\n return this.protocol.configuration.controlChannel.handleUnknownOperation(this, error);\r\n }\r\n\r\n public static sanitizeForLog(activity?: RpcActivity) {\r\n /* eslint-disable @typescript-eslint/naming-convention */\r\n return activity ? {\r\n ActivityId: activity.activityId, SessionId: activity.sessionId, ApplicationId: activity.applicationId, ApplicationVersion: activity.applicationVersion, rpcMethod: activity.rpcMethod,\r\n } : undefined;\r\n /* eslint-enable @typescript-eslint/naming-convention */\r\n }\r\n\r\n private async resolve(): Promise<any> {\r\n const request = this.request;\r\n const activity: RpcActivity = {\r\n activityId: request.id,\r\n applicationId: request.applicationId,\r\n applicationVersion: request.applicationVersion,\r\n sessionId: request.sessionId,\r\n user: request.user,\r\n accessToken: request.authorization,\r\n rpcMethod: request.operation.operationName,\r\n };\r\n\r\n try {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.RequestReceived, this);\r\n\r\n const parameters = request.parametersOverride || RpcMarshaling.deserialize(this.protocol, request.parameters);\r\n this.applyPolicies(parameters);\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition);\r\n (impl as any)[CURRENT_INVOCATION] = this;\r\n const op = this.lookupOperationFunction(impl);\r\n\r\n return await RpcInvocation.runActivity(activity, async () => op.call(impl, ...parameters)\r\n .catch(async (error) => {\r\n // this catch block is intentionally placed inside `runActivity` to attach the right logging metadata and use the correct openTelemetry span.\r\n if (!(error instanceof RpcPendingResponse)) {\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, \"Error in RPC operation\", { error: BentleyError.getErrorProps(error) });\r\n Tracing.recordException(error);\r\n }\r\n throw error;\r\n }));\r\n } catch (error: unknown) {\r\n return this.reject(error);\r\n }\r\n }\r\n\r\n private applyPolicies(parameters: any) {\r\n if (!parameters || !Array.isArray(parameters))\r\n return;\r\n\r\n for (let i = 0; i !== parameters.length; ++i) {\r\n const parameter = parameters[i];\r\n const isToken = typeof (parameter) === \"object\" && parameter !== null && parameter.hasOwnProperty(\"iModelId\") && parameter.hasOwnProperty(\"iTwinId\");\r\n if (isToken && this.protocol.checkToken && !this.operation.policy.allowTokenMismatch) {\r\n const inflated = this.protocol.inflateToken(parameter, this.request);\r\n parameters[i] = inflated;\r\n\r\n if (!RpcInvocation.compareTokens(parameter, inflated)) {\r\n if (RpcConfiguration.throwOnTokenMismatch) {\r\n throw new IModelError(BentleyStatus.ERROR, \"IModelRpcProps mismatch detected for this request.\");\r\n } else {\r\n Logger.logWarning(CommonLoggerCategory.RpcInterfaceBackend, \"IModelRpcProps mismatch detected for this request.\");\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static compareTokens(a: IModelRpcProps, b: IModelRpcProps): boolean {\r\n return a.key === b.key &&\r\n a.iTwinId === b.iTwinId &&\r\n a.iModelId === b.iModelId &&\r\n (undefined === a.changeset || (a.changeset.id === b.changeset?.id));\r\n }\r\n\r\n private async reject(error: any): Promise<any> {\r\n this._threw = true;\r\n return error;\r\n }\r\n\r\n private async fulfillResolved(value: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendResponseCreated, this);\r\n const result = RpcMarshaling.serialize(this.protocol, value);\r\n return this.fulfill(result, value);\r\n }\r\n\r\n private async fulfillRejected(reason: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n if (!RpcConfiguration.developmentMode)\r\n reason.stack = undefined;\r\n\r\n const result = RpcMarshaling.serialize(this.protocol, reason);\r\n\r\n if (reason instanceof RpcPendingResponse) {\r\n this._pending = true;\r\n this._threw = false;\r\n result.objects = reason.message;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedPending, this);\r\n } else if (this.supportsNoContent() && reason?.errorNumber === IModelStatus.NoContent) {\r\n this._noContent = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNoContent, this);\r\n } else if (reason instanceof RpcNotFoundResponse) {\r\n this._notFound = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNotFound, this);\r\n } else {\r\n this._threw = true;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendErrorOccurred, this);\r\n }\r\n\r\n return this.fulfill(result, reason);\r\n }\r\n\r\n private supportsNoContent() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedNoContent && this.request.protocolVersion >= RpcProtocolVersion.IntroducedNoContent;\r\n }\r\n\r\n private supportsStatusCategory() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n if (!this.protocol.supportsStatusCategory) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.request.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;\r\n }\r\n\r\n private fulfill(result: RpcSerializedValue, rawResult: any): RpcRequestFulfillment {\r\n const fulfillment: RpcRequestFulfillment = {\r\n result,\r\n rawResult,\r\n status: this.protocol.getCode(this.status),\r\n id: this.request.id,\r\n interfaceName: (typeof (this.operation) === \"undefined\") ? \"\" : this.operation.interfaceDefinition.interfaceName,\r\n allowCompression: this.operation?.policy.allowResponseCompression || false,\r\n };\r\n\r\n this.transformResponseStatus(fulfillment, rawResult);\r\n\r\n try {\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition) as any;\r\n if (impl[CURRENT_INVOCATION] === this) {\r\n impl[CURRENT_INVOCATION] = undefined;\r\n }\r\n } catch (_err) { }\r\n\r\n return fulfillment;\r\n }\r\n\r\n private lookupOperationFunction(implementation: RpcInterface): (...args: any[]) => Promise<any> {\r\n const func = (implementation as any)[this.operation.operationName];\r\n if (!func || typeof (func) !== \"function\")\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface class \"${implementation.constructor.name}\" does not implement operation \"${this.operation.operationName}\".`);\r\n\r\n return func;\r\n }\r\n\r\n private transformResponseStatus(fulfillment: RpcRequestFulfillment, rawResult: any) {\r\n if (!this.supportsStatusCategory()) {\r\n return;\r\n }\r\n\r\n let managedStatus: \"notFound\" | \"pending\" | \"noContent\" | undefined;\r\n if (this._pending) {\r\n managedStatus = \"pending\";\r\n } else if (this._notFound) {\r\n managedStatus = \"notFound\";\r\n } else if (this._noContent) {\r\n managedStatus = \"noContent\";\r\n }\r\n\r\n if (managedStatus) {\r\n const responseValue = fulfillment.result.objects;\r\n const status: RpcManagedStatus = { iTwinRpcCoreResponse: true, managedStatus, responseValue };\r\n fulfillment.result.objects = JSON.stringify(status);\r\n status.responseValue = rawResult; // for ipc case\r\n fulfillment.rawResult = status;\r\n }\r\n\r\n if (rawResult instanceof Error) {\r\n fulfillment.status = StatusCategory.for(rawResult).code;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcInvocation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcInvocation.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;;AAEH,OAAO,EAAe,YAAY,EAAE,aAAa,EAAc,YAAY,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9J,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAsB,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAoB,WAAW,EAAE,kBAAkB,EAA+C,MAAM,eAAe,CAAC;AAC/H,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAqChE;;GAEG;AACH,MAAM,OAAO,aAAa;IAwBxB,mCAAmC;IACnC,IAAW,MAAM;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AED,IAAI,aAA+D,CAAC;QACpE,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,aAAa,GAAG,SAAS,CAAC;QAC5B,CAAC;aAAM,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAC1B,aAAa,GAAG,UAAU,CAAC;QAC7B,CAAC;aAAM,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAC3B,aAAa,GAAG,WAAW,CAAC;QAC9B,CAAC;QAED,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC;YACjD,MAAM,MAAM,GAAqB,EAAE,oBAAoB,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;YAC9F,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACpD,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC,eAAe;YACjD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC;QACjC,CAAC;QAED,IAAI,SAAS,YAAY,KAAK,EAAE,CAAC;YAC/B,WAAW,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;QAC1D,CAAC;IACH,CAAC;;;AA5Qa,yBAAW,GAAmB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,AAAhD,CAAiD","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 { AccessToken, BentleyError, BentleyStatus, GuidString, IModelStatus, Logger, RpcInterfaceStatus, StatusCategory, Tracing } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { SessionProps } from \"../../SessionProps\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus } from \"./RpcConstants\";\r\nimport { RpcControlChannel, RpcNotFoundResponse, RpcPendingResponse } from \"./RpcControl\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcManagedStatus, RpcProtocol, RpcProtocolVersion, RpcRequestFulfillment, SerializedRpcRequest } from \"./RpcProtocol\";\r\nimport { CURRENT_INVOCATION, RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** The properties of an RpcActivity.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface RpcActivity extends SessionProps {\r\n /** Used for logging to correlate an Rpc activity between frontend and backend */\r\n readonly activityId: GuidString;\r\n\r\n /** access token for authorization */\r\n readonly accessToken: AccessToken;\r\n\r\n /** the name of the current rpc method */\r\n readonly rpcMethod?: string;\r\n\r\n readonly user?: string;\r\n}\r\n\r\n/** Serialized format for sending the request across the RPC layer\r\n * @public\r\n */\r\nexport interface SerializedRpcActivity {\r\n id: string;\r\n applicationId: string;\r\n applicationVersion: string;\r\n sessionId: string;\r\n authorization: string;\r\n user?: string;\r\n csrfToken?: { headerName: string, headerValue: string };\r\n}\r\n\r\n/** @internal */\r\nexport type RpcActivityRun = (activity: RpcActivity, fn: () => Promise<any>) => Promise<any>;\r\n\r\n/** An RPC operation invocation in response to a request.\r\n * @internal\r\n */\r\nexport class RpcInvocation {\r\n public static runActivity: RpcActivityRun = async (_activity, fn) => fn();\r\n private _threw: boolean = false;\r\n private _pending: boolean = false;\r\n private _notFound: boolean = false;\r\n private _noContent: boolean = false;\r\n private _timeIn: number = 0;\r\n private _timeOut: number = 0;\r\n\r\n /** The protocol for this invocation. */\r\n public readonly protocol: RpcProtocol;\r\n\r\n /** The received request. */\r\n public readonly request: SerializedRpcRequest;\r\n\r\n /** The operation of the request. */\r\n public readonly operation: RpcOperation = undefined as any;\r\n\r\n /** The implementation response. */\r\n public readonly result: Promise<any>;\r\n\r\n /** The fulfillment for this request. */\r\n public readonly fulfillment: Promise<RpcRequestFulfillment>;\r\n\r\n /** The status for this request. */\r\n public get status(): RpcRequestStatus {\r\n return this._threw ? RpcRequestStatus.Rejected :\r\n this._pending ? RpcRequestStatus.Pending :\r\n this._notFound ? RpcRequestStatus.NotFound :\r\n this._noContent ? RpcRequestStatus.NoContent :\r\n RpcRequestStatus.Resolved;\r\n }\r\n\r\n /** The elapsed time for this invocation. */\r\n public get elapsed(): number {\r\n return this._timeOut - this._timeIn;\r\n }\r\n\r\n /**\r\n * The invocation for the current RPC operation.\r\n * @note The return value of this function is only reliable in an RPC impl class member function where program control was received from the RpcInvocation constructor function.\r\n */\r\n public static current(rpcImpl: RpcInterface): RpcInvocation {\r\n return (rpcImpl as any)[CURRENT_INVOCATION];\r\n }\r\n\r\n /** Constructs an invocation. */\r\n public constructor(protocol: RpcProtocol, request: SerializedRpcRequest) {\r\n this._timeIn = new Date().getTime();\r\n this.protocol = protocol;\r\n this.request = request;\r\n\r\n try {\r\n try {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n\r\n const backend = this.operation.interfaceVersion;\r\n const frontend = this.request.operation.interfaceVersion;\r\n if (!RpcInterface.isVersionCompatible(backend, frontend)) {\r\n throw new IModelError(RpcInterfaceStatus.IncompatibleVersion, `Backend version ${backend} does not match frontend version ${frontend} for RPC interface ${this.operation.operationName}.`);\r\n }\r\n } catch (error) {\r\n if (this.handleUnknownOperation(error)) {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n\r\n this.result = this.resolve();\r\n } catch (error) {\r\n this.result = this.reject(error);\r\n }\r\n\r\n this.fulfillment = this.result.then(async (value) => this._threw ? this.fulfillRejected(value) : this.fulfillResolved(value), async (reason) => this.fulfillRejected(reason));\r\n }\r\n\r\n private handleUnknownOperation(error: any): boolean {\r\n RpcControlChannel.ensureInitialized();\r\n return this.protocol.configuration.controlChannel.handleUnknownOperation(this, error);\r\n }\r\n\r\n public static sanitizeForLog(activity?: RpcActivity) {\r\n /* eslint-disable @typescript-eslint/naming-convention */\r\n return activity ? {\r\n ActivityId: activity.activityId, SessionId: activity.sessionId, ApplicationId: activity.applicationId, ApplicationVersion: activity.applicationVersion, rpcMethod: activity.rpcMethod,\r\n } : undefined;\r\n /* eslint-enable @typescript-eslint/naming-convention */\r\n }\r\n\r\n private async resolve(): Promise<any> {\r\n const request = this.request;\r\n const activity: RpcActivity = {\r\n activityId: request.id,\r\n applicationId: request.applicationId,\r\n applicationVersion: request.applicationVersion,\r\n sessionId: request.sessionId,\r\n user: request.user,\r\n accessToken: request.authorization,\r\n rpcMethod: request.operation.operationName,\r\n };\r\n\r\n try {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.RequestReceived, this);\r\n\r\n const parameters = request.parametersOverride || RpcMarshaling.deserialize(this.protocol, request.parameters);\r\n this.applyPolicies(parameters);\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition);\r\n (impl as any)[CURRENT_INVOCATION] = this;\r\n const op = this.lookupOperationFunction(impl);\r\n\r\n return await RpcInvocation.runActivity(activity, async () => op.call(impl, ...parameters)\r\n .catch(async (error) => {\r\n // this catch block is intentionally placed inside `runActivity` to attach the right logging metadata and use the correct openTelemetry span.\r\n if (!(error instanceof RpcPendingResponse)) {\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, \"Error in RPC operation\", { error: BentleyError.getErrorProps(error) });\r\n Tracing.recordException(error);\r\n }\r\n throw error;\r\n }));\r\n } catch (error: unknown) {\r\n return this.reject(error);\r\n }\r\n }\r\n\r\n private applyPolicies(parameters: any) {\r\n if (!parameters || !Array.isArray(parameters))\r\n return;\r\n\r\n for (let i = 0; i !== parameters.length; ++i) {\r\n const parameter = parameters[i];\r\n const isToken = typeof (parameter) === \"object\" && parameter !== null && parameter.hasOwnProperty(\"iModelId\") && parameter.hasOwnProperty(\"iTwinId\");\r\n if (isToken && this.protocol.checkToken && !this.operation.policy.allowTokenMismatch) {\r\n const inflated = this.protocol.inflateToken(parameter, this.request);\r\n parameters[i] = inflated;\r\n\r\n if (!RpcInvocation.compareTokens(parameter, inflated)) {\r\n if (RpcConfiguration.throwOnTokenMismatch) {\r\n throw new IModelError(BentleyStatus.ERROR, \"IModelRpcProps mismatch detected for this request.\");\r\n } else {\r\n Logger.logWarning(CommonLoggerCategory.RpcInterfaceBackend, \"IModelRpcProps mismatch detected for this request.\");\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static compareTokens(a: IModelRpcProps, b: IModelRpcProps): boolean {\r\n return a.key === b.key &&\r\n a.iTwinId === b.iTwinId &&\r\n a.iModelId === b.iModelId &&\r\n (undefined === a.changeset || (a.changeset.id === b.changeset?.id));\r\n }\r\n\r\n private async reject(error: any): Promise<any> {\r\n this._threw = true;\r\n return error;\r\n }\r\n\r\n private async fulfillResolved(value: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendResponseCreated, this);\r\n const result = RpcMarshaling.serialize(this.protocol, value);\r\n return this.fulfill(result, value);\r\n }\r\n\r\n private async fulfillRejected(reason: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n if (!RpcConfiguration.developmentMode)\r\n reason.stack = undefined;\r\n\r\n const result = RpcMarshaling.serialize(this.protocol, reason);\r\n\r\n if (reason instanceof RpcPendingResponse) {\r\n this._pending = true;\r\n this._threw = false;\r\n result.objects = reason.message;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedPending, this);\r\n } else if (this.supportsNoContent() && reason?.errorNumber === IModelStatus.NoContent) {\r\n this._noContent = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNoContent, this);\r\n } else if (reason instanceof RpcNotFoundResponse) {\r\n this._notFound = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNotFound, this);\r\n } else {\r\n this._threw = true;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendErrorOccurred, this);\r\n }\r\n\r\n return this.fulfill(result, reason);\r\n }\r\n\r\n private supportsNoContent() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedNoContent && this.request.protocolVersion >= RpcProtocolVersion.IntroducedNoContent;\r\n }\r\n\r\n private supportsStatusCategory() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n if (!this.protocol.supportsStatusCategory) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.request.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;\r\n }\r\n\r\n private fulfill(result: RpcSerializedValue, rawResult: any): RpcRequestFulfillment {\r\n const fulfillment: RpcRequestFulfillment = {\r\n result,\r\n rawResult,\r\n status: this.protocol.getCode(this.status),\r\n id: this.request.id,\r\n interfaceName: (typeof (this.operation) === \"undefined\") ? \"\" : this.operation.interfaceDefinition.interfaceName,\r\n allowCompression: this.operation ? this.operation.policy.allowResponseCompression : true,\r\n };\r\n\r\n this.transformResponseStatus(fulfillment, rawResult);\r\n\r\n try {\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition) as any;\r\n if (impl[CURRENT_INVOCATION] === this) {\r\n impl[CURRENT_INVOCATION] = undefined;\r\n }\r\n } catch (_err) { }\r\n\r\n return fulfillment;\r\n }\r\n\r\n private lookupOperationFunction(implementation: RpcInterface): (...args: any[]) => Promise<any> {\r\n const func = (implementation as any)[this.operation.operationName];\r\n if (!func || typeof (func) !== \"function\")\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface class \"${implementation.constructor.name}\" does not implement operation \"${this.operation.operationName}\".`);\r\n\r\n return func;\r\n }\r\n\r\n private transformResponseStatus(fulfillment: RpcRequestFulfillment, rawResult: any) {\r\n if (!this.supportsStatusCategory()) {\r\n return;\r\n }\r\n\r\n let managedStatus: \"notFound\" | \"pending\" | \"noContent\" | undefined;\r\n if (this._pending) {\r\n managedStatus = \"pending\";\r\n } else if (this._notFound) {\r\n managedStatus = \"notFound\";\r\n } else if (this._noContent) {\r\n managedStatus = \"noContent\";\r\n }\r\n\r\n if (managedStatus) {\r\n const responseValue = fulfillment.result.objects;\r\n const status: RpcManagedStatus = { iTwinRpcCoreResponse: true, managedStatus, responseValue };\r\n fulfillment.result.objects = JSON.stringify(status);\r\n status.responseValue = rawResult; // for ipc case\r\n fulfillment.rawResult = status;\r\n }\r\n\r\n if (rawResult instanceof Error) {\r\n fulfillment.status = StatusCategory.for(rawResult).code;\r\n }\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcMarshaling.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcMarshaling.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAY5C,gBAAgB;AAChB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,IAAI,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,gBAAgB;AAChB,yBAAiB,sBAAsB,CAAC;IACtC,SAAgB,aAAa,IAAI,sBAAsB,CAEtD;CACF;AAED,gBAAgB;AAChB,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,U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E,UAAU,EAAO,GAAG,kBAAkB,CAEhF;CACF;AAED,gBAAgB;AAChB,qBAAa,aAAa;IACxB,OAAO;IAEP,0BAA0B;WACZ,SAAS,CAAC,QAAQ,EAAE,WAAW,GAAG,SAAS,EAAE,KAAK,EAAE,GAAG,GAAG,kBAAkB;IAe1F,4BAA4B;WACd,WAAW,CAAC,QAAQ,EAAE,WAAW,GAAG,SAAS,EAAE,KAAK,EAAE,kBAAkB,GAAG,GAAG;CAoB7F"}
@@ -35,9 +35,8 @@ export class RpcMarshaling {
35
35
  /** Serializes a value. */
36
36
  static serialize(protocol, value) {
37
37
  const serialized = RpcSerializedValue.create();
38
- if (typeof (value) === "undefined") {
38
+ if (value === undefined)
39
39
  return serialized;
40
- }
41
40
  marshalingTarget = serialized;
42
41
  chunkThreshold = protocol ? protocol.transferChunkThreshold : 0;
43
42
  serialized.objects = JSON.stringify(value, (_key, _value) => WireFormat.marshal(_key, _value));
@@ -1 +1 @@
1
- {"version":3,"file":"RpcMarshaling.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcMarshaling.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAI/D,0BAA0B;AAC1B,4CAA4C;AAE5C,SAAS,QAAQ,CAAC,GAAQ;IACxB,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,UAAU,IAAI,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC9I,CAAC;AAED,IAAI,gBAAoC,CAAC;AACzC,IAAI,cAAc,GAAG,CAAC,CAAC;AAUvB,gBAAgB;AAChB,MAAM,KAAW,sBAAsB,CAItC;AAJD,WAAiB,sBAAsB;IACrC,SAAgB,aAAa;QAC3B,OAAO,EAAE,QAAQ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AI,CAAC;QACd,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,KAAU;QACpC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,MAAM,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;YACtD,KAAK,CAAC,OAAO,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACtF,KAAK,CAAC,IAAI,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;YACzF,KAAK,CAAC,OAAO,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;YAC/F,KAAK,CAAC,KAAK,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;YAC3F,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","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, IModelError } from \"../../IModelError\";\r\nimport { BackendReadable } from \"../../BackendTypes\";\r\nimport { RpcProtocol } from \"./RpcProtocol\";\r\n\r\n// cspell:ignore unmarshal\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nfunction isBuffer(val: any): boolean {\r\n return val && typeof (val.constructor) !== \"undefined\" && typeof (val.constructor.isBuffer) === \"function\" && val.constructor.isBuffer(val);\r\n}\r\n\r\nlet marshalingTarget: RpcSerializedValue;\r\nlet chunkThreshold = 0;\r\n\r\n/** @internal */\r\nexport interface MarshalingBinaryMarker {\r\n isBinary: true;\r\n index: number;\r\n size: number;\r\n chunks: number;\r\n}\r\n\r\n/** @internal */\r\nexport namespace MarshalingBinaryMarker {\r\n export function createDefault(): MarshalingBinaryMarker {\r\n return { isBinary: true, index: 0, size: -1, chunks: 1 };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface RpcSerializedValue {\r\n objects: string;\r\n data: Uint8Array[];\r\n chunks?: number;\r\n stream?: BackendReadable;\r\n}\r\n\r\n/** @internal */\r\nexport namespace RpcSerializedValue {\r\n export function create(objects = \"\", data: Uint8Array[] = []): RpcSerializedValue {\r\n return { objects, data };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class RpcMarshaling {\r\n private constructor() { }\r\n\r\n /** Serializes a value. */\r\n public static serialize(protocol: RpcProtocol | undefined, value: any): RpcSerializedValue {\r\n const serialized = RpcSerializedValue.create();\r\n\r\n if (typeof (value) === \"undefined\") {\r\n return serialized;\r\n }\r\n\r\n marshalingTarget = serialized;\r\n chunkThreshold = protocol ? protocol.transferChunkThreshold : 0;\r\n serialized.objects = JSON.stringify(value, (_key, _value) => WireFormat.marshal(_key, _value));\r\n marshalingTarget = undefined as any;\r\n chunkThreshold = 0;\r\n\r\n return serialized;\r\n }\r\n\r\n /** Deserializes a value. */\r\n public static deserialize(protocol: RpcProtocol | undefined, value: RpcSerializedValue): any {\r\n if (value.objects === \"\") {\r\n return undefined;\r\n }\r\n\r\n marshalingTarget = value;\r\n chunkThreshold = protocol ? protocol.transferChunkThreshold : 0;\r\n let result;\r\n try {\r\n result = JSON.parse(value.objects, (_key, _value) => WireFormat.unmarshal(_key, _value));\r\n } catch (error) {\r\n if (error instanceof SyntaxError)\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid JSON: \"${value.objects}\"`);\r\n throw error;\r\n }\r\n marshalingTarget = undefined as any;\r\n chunkThreshold = 0;\r\n\r\n return result;\r\n }\r\n}\r\n\r\nclass WireFormat {\r\n /** JSON.stringify replacer callback. */\r\n public static marshal(this: any, _key: string, value: any) {\r\n const asBinary = WireFormat.marshalBinary(value);\r\n if (asBinary) {\r\n return asBinary;\r\n }\r\n\r\n const asError = WireFormat.marshalError(value);\r\n if (asError) {\r\n return asError;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /** JSON.parse reviver callback. */\r\n public static unmarshal(_key: string, value: any) {\r\n if (typeof (value) === \"object\" && value !== null && value.hasOwnProperty(\"isBinary\") && value.isBinary) {\r\n return WireFormat.unmarshalBinary(value);\r\n }\r\n\r\n return value;\r\n }\r\n\r\n private static marshalBinary(value: any): any {\r\n if (value instanceof Uint8Array || isBuffer(value)) {\r\n const marker: MarshalingBinaryMarker = { isBinary: true, index: -1, size: value.byteLength, chunks: 1 };\r\n\r\n if (chunkThreshold && value.byteLength > chunkThreshold) {\r\n marker.index = marshalingTarget.data.length;\r\n marker.chunks = 0;\r\n\r\n let cursor = value.byteOffset;\r\n const end = cursor + value.byteLength;\r\n let chunk = chunkThreshold;\r\n\r\n for (; ;) {\r\n if (cursor >= end) {\r\n break;\r\n }\r\n\r\n marshalingTarget.data.push(new Uint8Array(value.buffer, cursor, chunk));\r\n ++marker.chunks;\r\n cursor += chunk;\r\n\r\n const consumed = cursor - value.byteOffset;\r\n const remaining = value.byteLength - consumed;\r\n chunk = Math.min(chunkThreshold, remaining);\r\n }\r\n } else {\r\n marker.index = marshalingTarget.data.push(value) - 1;\r\n }\r\n\r\n return marker;\r\n } else {\r\n return undefined;\r\n }\r\n }\r\n\r\n private static unmarshalBinary(value: MarshalingBinaryMarker): any {\r\n if (value.index >= marshalingTarget.data.length) {\r\n throw new IModelError(BentleyStatus.ERROR, `Cannot unmarshal missing binary value.`);\r\n }\r\n\r\n if (value.chunks === 0) {\r\n return new Uint8Array();\r\n } else if (value.chunks === 1) {\r\n return new Uint8Array(marshalingTarget.data[value.index]);\r\n } else {\r\n const buffer = new ArrayBuffer(value.size);\r\n const view = new Uint8Array(buffer);\r\n\r\n let cursor = 0;\r\n for (let c = 0; c !== value.chunks; ++c) {\r\n const chunk = marshalingTarget.data[value.index + c];\r\n view.set(chunk, cursor);\r\n cursor += chunk.byteLength;\r\n }\r\n\r\n return view;\r\n }\r\n }\r\n\r\n private static marshalError(value: any) {\r\n if (value instanceof Error) {\r\n const props = Object.getOwnPropertyDescriptors(value);\r\n props.isError = { configurable: true, enumerable: true, writable: true, value: true };\r\n props.name = { configurable: true, enumerable: true, writable: true, value: value.name };\r\n props.message = { configurable: true, enumerable: true, writable: true, value: value.message };\r\n props.stack = { configurable: true, enumerable: true, writable: true, value: value.stack };\r\n return Object.create(Object.prototype, props);\r\n }\r\n\r\n return undefined;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcMarshaling.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcMarshaling.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAI/D,0BAA0B;AAC1B,4CAA4C;AAE5C,SAAS,QAAQ,CAAC,GAAQ;IACxB,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,UAAU,IAAI,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC9I,CAAC;AAED,IAAI,gBAAoC,CAAC;AACzC,IAAI,cAAc,GAAG,CAAC,CAAC;AAUvB,gBAAgB;AAChB,MAAM,KAAW,sBAAsB,CAItC;AAJD,WAAiB,sBAAsB;IACrC,SAAgB,aAAa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d,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,KAAc;QACxC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,MAAM,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;YACtD,KAAK,CAAC,OAAO,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACtF,KAAK,CAAC,IAAI,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;YACzF,KAAK,CAAC,OAAO,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;YAC/F,KAAK,CAAC,KAAK,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;YAC3F,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","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, IModelError } from \"../../IModelError\";\r\nimport { BackendReadable } from \"../../BackendTypes\";\r\nimport { RpcProtocol } from \"./RpcProtocol\";\r\n\r\n// cspell:ignore unmarshal\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nfunction isBuffer(val: any): boolean {\r\n return val && typeof (val.constructor) !== \"undefined\" && typeof (val.constructor.isBuffer) === \"function\" && val.constructor.isBuffer(val);\r\n}\r\n\r\nlet marshalingTarget: RpcSerializedValue;\r\nlet chunkThreshold = 0;\r\n\r\n/** @internal */\r\nexport interface MarshalingBinaryMarker {\r\n isBinary: true;\r\n index: number;\r\n size: number;\r\n chunks: number;\r\n}\r\n\r\n/** @internal */\r\nexport namespace MarshalingBinaryMarker {\r\n export function createDefault(): MarshalingBinaryMarker {\r\n return { isBinary: true, index: 0, size: -1, chunks: 1 };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface RpcSerializedValue {\r\n objects: string;\r\n data: Uint8Array[];\r\n chunks?: number;\r\n stream?: BackendReadable;\r\n}\r\n\r\n/** @internal */\r\nexport namespace RpcSerializedValue {\r\n export function create(objects = \"\", data: Uint8Array[] = []): RpcSerializedValue {\r\n return { objects, data };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class RpcMarshaling {\r\n private constructor() { }\r\n\r\n /** Serializes a value. */\r\n public static serialize(protocol: RpcProtocol | undefined, value: any): RpcSerializedValue {\r\n const serialized = RpcSerializedValue.create();\r\n\r\n if (value === undefined)\r\n return serialized;\r\n\r\n marshalingTarget = serialized;\r\n chunkThreshold = protocol ? protocol.transferChunkThreshold : 0;\r\n serialized.objects = JSON.stringify(value, (_key, _value) => WireFormat.marshal(_key, _value));\r\n marshalingTarget = undefined as any;\r\n chunkThreshold = 0;\r\n\r\n return serialized;\r\n }\r\n\r\n /** Deserializes a value. */\r\n public static deserialize(protocol: RpcProtocol | undefined, value: RpcSerializedValue): any {\r\n if (value.objects === \"\") {\r\n return undefined;\r\n }\r\n\r\n marshalingTarget = value;\r\n chunkThreshold = protocol ? protocol.transferChunkThreshold : 0;\r\n let result;\r\n try {\r\n result = JSON.parse(value.objects, (_key, _value) => WireFormat.unmarshal(_key, _value));\r\n } catch (error) {\r\n if (error instanceof SyntaxError)\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid JSON: \"${value.objects}\"`);\r\n throw error;\r\n }\r\n marshalingTarget = undefined as any;\r\n chunkThreshold = 0;\r\n\r\n return result;\r\n }\r\n}\r\n\r\nclass WireFormat {\r\n /** JSON.stringify replacer callback. */\r\n public static marshal(this: any, _key: string, value: any) {\r\n const asBinary = WireFormat.marshalBinary(value);\r\n if (asBinary) {\r\n return asBinary;\r\n }\r\n\r\n const asError = WireFormat.marshalError(value);\r\n if (asError) {\r\n return asError;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /** JSON.parse reviver callback. */\r\n public static unmarshal(_key: string, value: any) {\r\n if (typeof (value) === \"object\" && value !== null && value.hasOwnProperty(\"isBinary\") && value.isBinary) {\r\n return WireFormat.unmarshalBinary(value);\r\n }\r\n\r\n return value;\r\n }\r\n\r\n private static marshalBinary(value: Uint8Array): MarshalingBinaryMarker | undefined {\r\n if (value instanceof Uint8Array || isBuffer(value)) {\r\n const marker: MarshalingBinaryMarker = { isBinary: true, index: -1, size: value.byteLength, chunks: 1 };\r\n\r\n if (chunkThreshold && value.byteLength > chunkThreshold) {\r\n marker.index = marshalingTarget.data.length;\r\n marker.chunks = 0;\r\n\r\n let cursor = value.byteOffset;\r\n const end = cursor + value.byteLength;\r\n let chunk = chunkThreshold;\r\n\r\n for (; ;) {\r\n if (cursor >= end) {\r\n break;\r\n }\r\n\r\n marshalingTarget.data.push(new Uint8Array(value.buffer, cursor, chunk));\r\n ++marker.chunks;\r\n cursor += chunk;\r\n\r\n const consumed = cursor - value.byteOffset;\r\n const remaining = value.byteLength - consumed;\r\n chunk = Math.min(chunkThreshold, remaining);\r\n }\r\n } else {\r\n marker.index = marshalingTarget.data.push(value) - 1;\r\n }\r\n\r\n return marker;\r\n } else {\r\n return undefined;\r\n }\r\n }\r\n\r\n private static unmarshalBinary(value: MarshalingBinaryMarker): Uint8Array {\r\n if (value.index >= marshalingTarget.data.length) {\r\n throw new IModelError(BentleyStatus.ERROR, `Cannot unmarshal missing binary value.`);\r\n }\r\n\r\n if (value.chunks === 0) {\r\n return new Uint8Array();\r\n } else if (value.chunks === 1) {\r\n return new Uint8Array(marshalingTarget.data[value.index]);\r\n } else {\r\n const buffer = new ArrayBuffer(value.size);\r\n const view = new Uint8Array(buffer);\r\n\r\n let cursor = 0;\r\n for (let c = 0; c !== value.chunks; ++c) {\r\n const chunk = marshalingTarget.data[value.index + c];\r\n view.set(chunk, cursor);\r\n cursor += chunk.byteLength;\r\n }\r\n\r\n return view;\r\n }\r\n }\r\n\r\n private static marshalError(value: unknown) {\r\n if (value instanceof Error) {\r\n const props = Object.getOwnPropertyDescriptors(value);\r\n props.isError = { configurable: true, enumerable: true, writable: true, value: true };\r\n props.name = { configurable: true, enumerable: true, writable: true, value: value.name };\r\n props.message = { configurable: true, enumerable: true, writable: true, value: value.message };\r\n props.stack = { configurable: true, enumerable: true, writable: true, value: value.stack };\r\n return Object.create(Object.prototype, props);\r\n }\r\n\r\n return undefined;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcOperation.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcOperation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EACL,oBAAoB,EAAE,wCAAwC,EAAE,yBAAyB,EAAE,4BAA4B,EACxH,MAAM,cAAc,CAAC;AAItB;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,4DAA4D;IACrD,KAAK,EAAE,yBAAyB,CAAkD;IAEzF,oEAAoE;IAC7D,aAAa,EAAE,wCAAwC,CAAkE;IAEhI,qEAAqE;IAC9D,eAAe,EAAE,oBAAoB,CAAqB;IAEjE,oEAAoE;IAC7D,YAAY,EAAE,oBAAoB,CAA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,QAAQ,EAAE,CAAC,SAAS,EAAE,YAAY,KAAK,IAAI,GAAG,IAAI;IAU5G,uDAAuD;IACvD,SAAgB,mBAAmB,EAAE,sBAAsB,CAAC;IAE5D,kCAAkC;IAClC,SAAgB,aAAa,EAAE,MAAM,CAAC;IAEtC,qCAAqC;IACrC,IAAW,gBAAgB,IAAI,MAAM,CAAsD;IAE3F,qCAAqC;IAC9B,MAAM,EAAE,kBAAkB,CAAC;IAElC,gBAAgB;gBACG,UAAU,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB;IAMpG,gBAAgB;WACF,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;CAO/D;AAED,gBAAgB;AAChB,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElE,gBAAgB;AAChB,yBAAiB,YAAY,CAAC;IAW5B,sEAAsE;IACtE,SAAgB,SAAS,CAAC,MAAM,EAAE,kBAAkB,GAAG,uBAAuB,oDACpB,MAAM,cAAc,kBAAkB,UAG/F;IAED,8FAA8F;IAC9F,SAAgB,oBAAoB,CAAC,OAAO,GAAE,uBAA2D,oDAC/C,MAAM,cAAc,kBAAkB,UAK/F;IAED,mHAAmH;IACnH,SAAgB,eAAe,CAAC,OAAO,EAAE,yBAAyB,oDACR,MAAM,cAAc,kBAAkB,UAK/F;IAED,sFAAsF;IACtF,SAAgB,gBAAgB,CAAC,MAAM,EAAE,kBAAkB,GAAG,uBAAuB,2EAIpF;CACF"}
@@ -33,7 +33,7 @@ export class RpcOperationPolicy {
33
33
  /** Whether the IModelRpcProps in the operation parameter list is allowed to differ from the token in the request URL. */
34
34
  this.allowTokenMismatch = false;
35
35
  /** Whether to compress the operation response with one of the client's supported encodings. */
36
- this.allowResponseCompression = false;
36
+ this.allowResponseCompression = true;
37
37
  }
38
38
  }
39
39
  /** An RPC operation descriptor.
@@ -1 +1 @@
1
- {"version":3,"file":"RpcOperation.js","source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A;IAED,mHAAmH;IACnH,SAAgB,eAAe,CAAC,OAAkC;QAChE,OAAO,CAAyB,MAAS,EAAE,WAAmB,EAAE,UAA8B,EAAE,EAAE;YAChG,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,WAAkB,EAAE,WAAW,EAAE,IAAI,KAAM,SAAQ,kBAAkB;gBAAhC;;oBACzE,UAAK,GAAG,OAAO,CAAC;gBAClC,CAAC;aAAA,EAAE,CAAC,CAAC;QACP,CAAC,CAAC;IACJ,CAAC;IANe,4BAAe,kBAM9B,CAAA;IAED,sFAAsF;IACtF,SAAgB,gBAAgB,CAAC,MAAoD;QACnF,OAAO,CAAyB,UAAqC,EAAE,EAAE;YACtE,UAAkB,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QACvD,CAAC,CAAC;IACJ,CAAC;IAJe,6BAAgB,mBAI/B,CAAA;AACH,CAAC,EA1CgB,YAAY,KAAZ,YAAY,QA0C5B","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 { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface, RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { OPERATION, POLICY, RpcRegistry } from \"./RpcRegistry\";\r\nimport {\r\n RpcRequestCallback_T, RpcRequestInitialRetryIntervalSupplier_T, RpcRequestTokenSupplier_T, RpcResponseCachingCallback_T,\r\n} from \"./RpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** The policy for an RPC operation.\r\n * @internal\r\n */\r\nexport class RpcOperationPolicy {\r\n /** Supplies the IModelRpcProps for an operation request. */\r\n public token: RpcRequestTokenSupplier_T = (request) => request.findTokenPropsParameter();\r\n\r\n /** Supplies the initial retry interval for an operation request. */\r\n public retryInterval: RpcRequestInitialRetryIntervalSupplier_T = (configuration) => configuration.pendingOperationRetryInterval;\r\n\r\n /** Called before every operation request on the frontend is sent. */\r\n public requestCallback: RpcRequestCallback_T = (_request) => { };\r\n\r\n /** Called after every operation request on the frontend is sent. */\r\n public sentCallback: RpcRequestCallback_T = (_request) => { };\r\n\r\n /**\r\n * Determines if caching is permitted for an operation response.\r\n * @note Not all RPC protocols support caching.\r\n */\r\n public allowResponseCaching: RpcResponseCachingCallback_T = (_request) => RpcResponseCacheControl.None;\r\n\r\n /** Forces RpcConfiguration.strictMode for this operation. */\r\n public forceStrictMode: boolean = false;\r\n\r\n /** Whether the IModelRpcProps in the operation parameter list is allowed to differ from the token in the request URL. */\r\n public allowTokenMismatch: boolean = false;\r\n\r\n /** Whether to compress the operation response with one of the client's supported encodings. */\r\n public allowResponseCompression: boolean = false;\r\n}\r\n\r\n/** An RPC operation descriptor.\r\n * @internal\r\n */\r\nexport class RpcOperation {\r\n /** A fallback token to use for RPC requests that do not semantically depend on an iModel. */\r\n public static fallbackToken: IModelRpcProps | undefined = undefined;\r\n\r\n /** Looks up an RPC operation by name. */\r\n public static lookup(target: string | RpcInterfaceDefinition, operationName: string): RpcOperation {\r\n const definition = typeof (target) === \"string\" ? RpcRegistry.instance.lookupInterfaceDefinition(target) : target;\r\n const propertyName: string | symbol = RpcOperation.computeOperationName(operationName);\r\n\r\n const proto = (definition.prototype as any);\r\n if (!proto.hasOwnProperty(propertyName))\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface class \"${definition.interfaceName}\" does not does not declare operation \"${operationName}\"`);\r\n\r\n return proto[propertyName][OPERATION];\r\n }\r\n\r\n /** Iterates the operations of an RPC interface definition. */\r\n public static forEach(definition: RpcInterfaceDefinition, callback: (operation: RpcOperation) => void): void {\r\n Object.getOwnPropertyNames(definition.prototype).forEach((operationName) => {\r\n if (operationName === \"constructor\" || operationName === \"configurationSupplier\")\r\n return;\r\n\r\n const propertyName = RpcOperation.computeOperationName(operationName);\r\n callback((definition.prototype as any)[propertyName][OPERATION]);\r\n });\r\n }\r\n\r\n /** The RPC interface definition for this operation. */\r\n public readonly interfaceDefinition: RpcInterfaceDefinition;\r\n\r\n /** The name of this operation. */\r\n public readonly operationName: string;\r\n\r\n /** The version of this operation. */\r\n public get interfaceVersion(): string { return this.interfaceDefinition.interfaceVersion; }\r\n\r\n /** The policy for this operation. */\r\n public policy: RpcOperationPolicy;\r\n\r\n /** @internal */\r\n public constructor(definition: RpcInterfaceDefinition, operation: string, policy: RpcOperationPolicy) {\r\n this.interfaceDefinition = definition;\r\n this.operationName = operation;\r\n this.policy = policy;\r\n }\r\n\r\n /** @internal */\r\n public static computeOperationName(identifier: string): string {\r\n const c = identifier.indexOf(\":\");\r\n if (c === -1)\r\n return identifier;\r\n\r\n return identifier.substring(0, c + 1);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport type RpcOperationPolicyProps = Partial<RpcOperationPolicy>;\r\n\r\n/** @internal */\r\nexport namespace RpcOperation { // eslint-disable-line no-redeclare\r\n function obtainInstance(obj: RpcOperationPolicy | RpcOperationPolicyProps) {\r\n if (obj instanceof RpcOperationPolicy) {\r\n return obj;\r\n } else {\r\n const instance = new RpcOperationPolicy();\r\n Object.assign(instance, obj);\r\n return instance;\r\n }\r\n }\r\n\r\n /** Decorator for setting the policy for an RPC operation function. */\r\n export function setPolicy(policy: RpcOperationPolicy | RpcOperationPolicyProps) {\r\n return <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => {\r\n descriptor.value[OPERATION] = new RpcOperation(target.constructor as any, propertyKey, obtainInstance(policy));\r\n };\r\n }\r\n\r\n /** Convenience decorator for setting an RPC operation policy that allows response caching. */\r\n export function allowResponseCaching(control: RpcResponseCacheControl = RpcResponseCacheControl.Immutable) {\r\n return <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => {\r\n descriptor.value[OPERATION] = new RpcOperation(target.constructor as any, propertyKey, new class extends RpcOperationPolicy {\r\n public override allowResponseCaching = () => control;\r\n }());\r\n };\r\n }\r\n\r\n /** Convenience decorator for setting an RPC operation policy that supplies the IModelRpcProps for an operation. */\r\n export function setRoutingProps(handler: RpcRequestTokenSupplier_T) {\r\n return <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => {\r\n descriptor.value[OPERATION] = new RpcOperation(target.constructor as any, propertyKey, new class extends RpcOperationPolicy {\r\n public override token = handler;\r\n }());\r\n };\r\n }\r\n\r\n /** Decorator for setting the default policy for an RPC interface definition class. */\r\n export function setDefaultPolicy(policy: RpcOperationPolicy | RpcOperationPolicyProps) {\r\n return <T extends RpcInterface>(definition: RpcInterfaceDefinition<T>) => {\r\n (definition as any)[POLICY] = obtainInstance(policy);\r\n };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcOperation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcOperation.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK/D,4CAA4C;AAE5C;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAA/B;QACE,4DAA4D;QACrD,UAAK,GAA8B,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,uBAAuB,EAAE,CAAC;QAEzF,oEAAoE;QAC7D,kBAAa,GAA6C,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,CAAC,6BAA6B,CAAC;QAEhI,qE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,mBAI/B,CAAA;AACH,CAAC,EA1CgB,YAAY,KAAZ,YAAY,QA0C5B","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 { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface, RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { OPERATION, POLICY, RpcRegistry } from \"./RpcRegistry\";\r\nimport {\r\n RpcRequestCallback_T, RpcRequestInitialRetryIntervalSupplier_T, RpcRequestTokenSupplier_T, RpcResponseCachingCallback_T,\r\n} from \"./RpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** The policy for an RPC operation.\r\n * @internal\r\n */\r\nexport class RpcOperationPolicy {\r\n /** Supplies the IModelRpcProps for an operation request. */\r\n public token: RpcRequestTokenSupplier_T = (request) => request.findTokenPropsParameter();\r\n\r\n /** Supplies the initial retry interval for an operation request. */\r\n public retryInterval: RpcRequestInitialRetryIntervalSupplier_T = (configuration) => configuration.pendingOperationRetryInterval;\r\n\r\n /** Called before every operation request on the frontend is sent. */\r\n public requestCallback: RpcRequestCallback_T = (_request) => { };\r\n\r\n /** Called after every operation request on the frontend is sent. */\r\n public sentCallback: RpcRequestCallback_T = (_request) => { };\r\n\r\n /**\r\n * Determines if caching is permitted for an operation response.\r\n * @note Not all RPC protocols support caching.\r\n */\r\n public allowResponseCaching: RpcResponseCachingCallback_T = (_request) => RpcResponseCacheControl.None;\r\n\r\n /** Forces RpcConfiguration.strictMode for this operation. */\r\n public forceStrictMode: boolean = false;\r\n\r\n /** Whether the IModelRpcProps in the operation parameter list is allowed to differ from the token in the request URL. */\r\n public allowTokenMismatch: boolean = false;\r\n\r\n /** Whether to compress the operation response with one of the client's supported encodings. */\r\n public allowResponseCompression: boolean = true;\r\n}\r\n\r\n/** An RPC operation descriptor.\r\n * @internal\r\n */\r\nexport class RpcOperation {\r\n /** A fallback token to use for RPC requests that do not semantically depend on an iModel. */\r\n public static fallbackToken: IModelRpcProps | undefined = undefined;\r\n\r\n /** Looks up an RPC operation by name. */\r\n public static lookup(target: string | RpcInterfaceDefinition, operationName: string): RpcOperation {\r\n const definition = typeof (target) === \"string\" ? RpcRegistry.instance.lookupInterfaceDefinition(target) : target;\r\n const propertyName: string | symbol = RpcOperation.computeOperationName(operationName);\r\n\r\n const proto = (definition.prototype as any);\r\n if (!proto.hasOwnProperty(propertyName))\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface class \"${definition.interfaceName}\" does not does not declare operation \"${operationName}\"`);\r\n\r\n return proto[propertyName][OPERATION];\r\n }\r\n\r\n /** Iterates the operations of an RPC interface definition. */\r\n public static forEach(definition: RpcInterfaceDefinition, callback: (operation: RpcOperation) => void): void {\r\n Object.getOwnPropertyNames(definition.prototype).forEach((operationName) => {\r\n if (operationName === \"constructor\" || operationName === \"configurationSupplier\")\r\n return;\r\n\r\n const propertyName = RpcOperation.computeOperationName(operationName);\r\n callback((definition.prototype as any)[propertyName][OPERATION]);\r\n });\r\n }\r\n\r\n /** The RPC interface definition for this operation. */\r\n public readonly interfaceDefinition: RpcInterfaceDefinition;\r\n\r\n /** The name of this operation. */\r\n public readonly operationName: string;\r\n\r\n /** The version of this operation. */\r\n public get interfaceVersion(): string { return this.interfaceDefinition.interfaceVersion; }\r\n\r\n /** The policy for this operation. */\r\n public policy: RpcOperationPolicy;\r\n\r\n /** @internal */\r\n public constructor(definition: RpcInterfaceDefinition, operation: string, policy: RpcOperationPolicy) {\r\n this.interfaceDefinition = definition;\r\n this.operationName = operation;\r\n this.policy = policy;\r\n }\r\n\r\n /** @internal */\r\n public static computeOperationName(identifier: string): string {\r\n const c = identifier.indexOf(\":\");\r\n if (c === -1)\r\n return identifier;\r\n\r\n return identifier.substring(0, c + 1);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport type RpcOperationPolicyProps = Partial<RpcOperationPolicy>;\r\n\r\n/** @internal */\r\nexport namespace RpcOperation { // eslint-disable-line no-redeclare\r\n function obtainInstance(obj: RpcOperationPolicy | RpcOperationPolicyProps) {\r\n if (obj instanceof RpcOperationPolicy) {\r\n return obj;\r\n } else {\r\n const instance = new RpcOperationPolicy();\r\n Object.assign(instance, obj);\r\n return instance;\r\n }\r\n }\r\n\r\n /** Decorator for setting the policy for an RPC operation function. */\r\n export function setPolicy(policy: RpcOperationPolicy | RpcOperationPolicyProps) {\r\n return <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => {\r\n descriptor.value[OPERATION] = new RpcOperation(target.constructor as any, propertyKey, obtainInstance(policy));\r\n };\r\n }\r\n\r\n /** Convenience decorator for setting an RPC operation policy that allows response caching. */\r\n export function allowResponseCaching(control: RpcResponseCacheControl = RpcResponseCacheControl.Immutable) {\r\n return <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => {\r\n descriptor.value[OPERATION] = new RpcOperation(target.constructor as any, propertyKey, new class extends RpcOperationPolicy {\r\n public override allowResponseCaching = () => control;\r\n }());\r\n };\r\n }\r\n\r\n /** Convenience decorator for setting an RPC operation policy that supplies the IModelRpcProps for an operation. */\r\n export function setRoutingProps(handler: RpcRequestTokenSupplier_T) {\r\n return <T extends RpcInterface>(target: T, propertyKey: string, descriptor: PropertyDescriptor) => {\r\n descriptor.value[OPERATION] = new RpcOperation(target.constructor as any, propertyKey, new class extends RpcOperationPolicy {\r\n public override token = handler;\r\n }());\r\n };\r\n }\r\n\r\n /** Decorator for setting the default policy for an RPC interface definition class. */\r\n export function setDefaultPolicy(policy: RpcOperationPolicy | RpcOperationPolicyProps) {\r\n return <T extends RpcInterface>(definition: RpcInterfaceDefinition<T>) => {\r\n (definition as any)[POLICY] = obtainInstance(policy);\r\n };\r\n }\r\n}\r\n"]}
@@ -48,7 +48,7 @@ export interface RpcRequestFulfillment {
48
48
  /** A protocol-specific status code value for the request. */
49
49
  status: number;
50
50
  retry?: string;
51
- /** Whether to compress the result with one of the client's supported encodings. */
51
+ /** Whether to compress the result with one of the client's supported encodings. Defaults to true. */
52
52
  allowCompression?: boolean;
53
53
  }
54
54
  /** @internal */
@@ -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,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,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;AAI1C;;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,EAA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AAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACzF,CAAC;IAED,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,AAAlD,CAAmD;AAEhF,oFAAoF;AAC7D,2BAAe,GAAW,kBAAkB,CAAC,wBAAwB,AAAtD,CAAuD","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 { RpcNotFoundResponse } from \"./RpcControl\";\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/* eslint-disable deprecation/deprecation */\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 parametersOverride?: any[];\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 = 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\" | \"noContent\";\r\n responseValue: string | { message: string } | RpcNotFoundResponse;\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: 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":"Rp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,CAAC;QAQzE,kDAAkD;QAClC,mBAAc,GAAyB,aAAa,CAAC;QAE9D,8CAAyC,GAA0B;YACxE,yCAAyC;YACzC,EAAE,EAAE,EAAE;YAEN,6CAA6C;YAC7C,aAAa,EAAE,EAAE;YAEjB,sCAAsC;YACtC,kBAAkB,EAAE,EAAE;YAEtB,yCAAyC;YACzC,SAAS,EAAE,EAAE;YAEb,4CAA4C;YAC5C,aAAa,EAAE,EAAE;SAClB,CAAC;QAEF,oFAAoF;QAC7E,2BAAsB,GAAW,CAAC,CAAC;QAE1C,kEAAkE;QAC3D,oBAAe,GAAY,KAAK,CAAC;QAExC,0EAA0E;QACnE,eAAU,GAAY,KAAK,CAAC;QAEnC,gEAAgE;QACzD,2BAAsB,GAAY,KAAK,CAAC;QAkD7C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACzF,CAAC;IAED,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,AAAlD,CAAmD;AAEhF,oFAAoF;AAC7D,2BAAe,GAAW,kBAAkB,CAAC,wBAAwB,AAAtD,CAAuD","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 { RpcNotFoundResponse } from \"./RpcControl\";\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/* eslint-disable deprecation/deprecation */\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 parametersOverride?: any[];\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. Defaults to true. */\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 = 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\" | \"noContent\";\r\n responseValue: string | { message: string } | RpcNotFoundResponse;\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: 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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-common",
3
- "version": "4.7.0-dev.4",
3
+ "version": "4.7.0-dev.5",
4
4
  "description": "iTwin.js components common to frontend and backend",
5
5
  "main": "lib/cjs/core-common.js",
6
6
  "module": "lib/esm/core-common.js",
@@ -27,8 +27,8 @@
27
27
  "js-base64": "^3.6.1"
28
28
  },
29
29
  "peerDependencies": {
30
- "@itwin/core-bentley": "^4.7.0-dev.4",
31
- "@itwin/core-geometry": "^4.7.0-dev.4"
30
+ "@itwin/core-bentley": "^4.7.0-dev.5",
31
+ "@itwin/core-geometry": "^4.7.0-dev.5"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@itwin/eslint-plugin": "^4.0.2",
@@ -43,9 +43,9 @@
43
43
  "nyc": "^15.1.0",
44
44
  "rimraf": "^3.0.2",
45
45
  "typescript": "~5.3.3",
46
- "@itwin/build-tools": "4.7.0-dev.4",
47
- "@itwin/core-bentley": "4.7.0-dev.4",
48
- "@itwin/core-geometry": "4.7.0-dev.4"
46
+ "@itwin/core-geometry": "4.7.0-dev.5",
47
+ "@itwin/build-tools": "4.7.0-dev.5",
48
+ "@itwin/core-bentley": "4.7.0-dev.5"
49
49
  },
50
50
  "nyc": {
51
51
  "extends": "./node_modules/@itwin/build-tools/.nycrc",