@itwin/core-common 4.5.0-dev.3 → 4.5.0-dev.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -1
- package/LICENSE.md +1 -1
- package/lib/cjs/BriefcaseTypes.d.ts +12 -1
- package/lib/cjs/BriefcaseTypes.d.ts.map +1 -1
- package/lib/cjs/BriefcaseTypes.js.map +1 -1
- package/lib/cjs/ECSqlReader.d.ts.map +1 -1
- package/lib/cjs/ECSqlReader.js +10 -1
- package/lib/cjs/ECSqlReader.js.map +1 -1
- package/lib/cjs/GenericInstanceFilter.d.ts +151 -0
- package/lib/cjs/GenericInstanceFilter.d.ts.map +1 -0
- package/lib/cjs/GenericInstanceFilter.js +42 -0
- package/lib/cjs/GenericInstanceFilter.js.map +1 -0
- package/lib/cjs/IModel.d.ts +12 -0
- package/lib/cjs/IModel.d.ts.map +1 -1
- package/lib/cjs/IModel.js.map +1 -1
- package/lib/cjs/IpcAppProps.d.ts +5 -3
- package/lib/cjs/IpcAppProps.d.ts.map +1 -1
- package/lib/cjs/IpcAppProps.js.map +1 -1
- package/lib/cjs/MaterialProps.d.ts +9 -5
- package/lib/cjs/MaterialProps.d.ts.map +1 -1
- package/lib/cjs/MaterialProps.js.map +1 -1
- package/lib/cjs/TerrainSettings.d.ts +31 -0
- package/lib/cjs/TerrainSettings.d.ts.map +1 -1
- package/lib/cjs/TerrainSettings.js +47 -14
- package/lib/cjs/TerrainSettings.js.map +1 -1
- package/lib/cjs/ViewFlags.d.ts +1 -1
- package/lib/cjs/ViewFlags.d.ts.map +1 -1
- package/lib/cjs/ViewFlags.js +1 -1
- package/lib/cjs/ViewFlags.js.map +1 -1
- package/lib/cjs/core-common.d.ts +1 -0
- package/lib/cjs/core-common.d.ts.map +1 -1
- package/lib/cjs/core-common.js +1 -0
- package/lib/cjs/core-common.js.map +1 -1
- package/lib/cjs/rpc/core/RpcConstants.d.ts +6 -6
- package/lib/cjs/rpc/core/RpcConstants.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcConstants.js +6 -6
- package/lib/cjs/rpc/core/RpcConstants.js.map +1 -1
- package/lib/cjs/rpc/core/RpcInvocation.js +1 -1
- package/lib/cjs/rpc/core/RpcInvocation.js.map +1 -1
- package/lib/cjs/rpc/web/OpenAPI.d.ts +1 -1
- package/lib/cjs/rpc/web/OpenAPI.js.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcProtocol.d.ts +2 -2
- package/lib/cjs/rpc/web/WebAppRpcProtocol.js.map +1 -1
- package/lib/esm/BriefcaseTypes.d.ts +12 -1
- package/lib/esm/BriefcaseTypes.d.ts.map +1 -1
- package/lib/esm/BriefcaseTypes.js.map +1 -1
- package/lib/esm/ECSqlReader.d.ts.map +1 -1
- package/lib/esm/ECSqlReader.js +10 -1
- package/lib/esm/ECSqlReader.js.map +1 -1
- package/lib/esm/GenericInstanceFilter.d.ts +151 -0
- package/lib/esm/GenericInstanceFilter.d.ts.map +1 -0
- package/lib/esm/GenericInstanceFilter.js +39 -0
- package/lib/esm/GenericInstanceFilter.js.map +1 -0
- package/lib/esm/IModel.d.ts +12 -0
- package/lib/esm/IModel.d.ts.map +1 -1
- package/lib/esm/IModel.js.map +1 -1
- package/lib/esm/IpcAppProps.d.ts +5 -3
- package/lib/esm/IpcAppProps.d.ts.map +1 -1
- package/lib/esm/IpcAppProps.js.map +1 -1
- package/lib/esm/MaterialProps.d.ts +9 -5
- package/lib/esm/MaterialProps.d.ts.map +1 -1
- package/lib/esm/MaterialProps.js.map +1 -1
- package/lib/esm/TerrainSettings.d.ts +31 -0
- package/lib/esm/TerrainSettings.d.ts.map +1 -1
- package/lib/esm/TerrainSettings.js +46 -13
- package/lib/esm/TerrainSettings.js.map +1 -1
- package/lib/esm/ViewFlags.d.ts +1 -1
- package/lib/esm/ViewFlags.d.ts.map +1 -1
- package/lib/esm/ViewFlags.js +1 -1
- package/lib/esm/ViewFlags.js.map +1 -1
- package/lib/esm/core-common.d.ts +1 -0
- package/lib/esm/core-common.d.ts.map +1 -1
- package/lib/esm/core-common.js +1 -0
- package/lib/esm/core-common.js.map +1 -1
- package/lib/esm/rpc/core/RpcConstants.d.ts +6 -6
- package/lib/esm/rpc/core/RpcConstants.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcConstants.js +6 -6
- package/lib/esm/rpc/core/RpcConstants.js.map +1 -1
- package/lib/esm/rpc/core/RpcInvocation.js +1 -1
- package/lib/esm/rpc/core/RpcInvocation.js.map +1 -1
- package/lib/esm/rpc/web/OpenAPI.d.ts +1 -1
- package/lib/esm/rpc/web/OpenAPI.js.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcProtocol.d.ts +2 -2
- package/lib/esm/rpc/web/WebAppRpcProtocol.js.map +1 -1
- package/package.json +7 -6
|
@@ -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;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,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,+BAAgB,CAAC,QAAQ,CAAC,CAAC;oBAC1C,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,+BAAgB,CAAC,SAAS,CAAC,CAAC;wBAC5C,+BAAgB,CAAC,QAAQ,CAAC;IACpC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AAC,SAAS,CAAC,CAAC,IAAI,CAAC;SACzD;IACH,CAAC;;;AA5Qa,yBAAW,GAAmB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,AAAhD,CAAiD;AAD/D,sCAAa","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 BentleyError) {\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/Rp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AAQ,EAAE;YACjB,aAAa,GAAG,SAAS,CAAC;SAC3B;aAAM,IAAI,IAAI,CAAC,SAAS,EAAE;YACzB,aAAa,GAAG,UAAU,CAAC;SAC5B;aAAM,IAAI,IAAI,CAAC,UAAU,EAAE;YAC1B,aAAa,GAAG,WAAW,CAAC;SAC7B;QAED,IAAI,aAAa,EAAE;YACjB,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;SAChC;QAED,IAAI,SAAS,YAAY,KAAK,EAAE;YAC9B,WAAW,CAAC,MAAM,GAAG,6BAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;SACzD;IACH,CAAC;;;AA5Qa,yBAAW,GAAmB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,AAAhD,CAAiD;AAD/D,sCAAa","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"]}
|
|
@@ -12,7 +12,7 @@ export interface OpenAPIDocument {
|
|
|
12
12
|
}
|
|
13
13
|
/** An OpenAPI 3.0 info object.
|
|
14
14
|
* @public
|
|
15
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in
|
|
15
|
+
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in the future.
|
|
16
16
|
*/
|
|
17
17
|
export interface OpenAPIInfo {
|
|
18
18
|
title: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAPI.js","sourceRoot":"","sources":["../../../../src/rpc/web/OpenAPI.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uDAAoD;AAwIpD;;GAEG;AACH,MAAa,qBAAqB;IAIhC,iDAAiD;IACjD,IAAW,KAAK;QACd,MAAM,KAAK,GAAiB,EAAE,CAAC;QAE/B,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YAC9D,2BAAY,CAAC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,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC;QAC7E,IAAI,UAAU,CAAC,MAAM;YACnB,WAAW,CAAC,UAAU,GAAG,UAAU,CAAC;QAEtC,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AAzDD,sDAyDC","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 { RpcOperation } from \"../core/RpcOperation\";\r\nimport { WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** An OpenAPI 3.0 root document object.\r\n * @internal\r\n */\r\nexport interface OpenAPIDocument {\r\n openapi: \"3.0.0\";\r\n info: OpenAPIInfo;\r\n paths: OpenAPIPaths;\r\n}\r\n\r\n/** An OpenAPI 3.0 info object.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in
|
|
1
|
+
{"version":3,"file":"OpenAPI.js","sourceRoot":"","sources":["../../../../src/rpc/web/OpenAPI.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uDAAoD;AAwIpD;;GAEG;AACH,MAAa,qBAAqB;IAIhC,iDAAiD;IACjD,IAAW,KAAK;QACd,MAAM,KAAK,GAAiB,EAAE,CAAC;QAE/B,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YAC9D,2BAAY,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,EAAE;gBAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBACxE,KAAK,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AAO,WAAW,CAAC;IACrB,CAAC;CACF;AAzDD,sDAyDC","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 { RpcOperation } from \"../core/RpcOperation\";\r\nimport { WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** An OpenAPI 3.0 root document object.\r\n * @internal\r\n */\r\nexport interface OpenAPIDocument {\r\n openapi: \"3.0.0\";\r\n info: OpenAPIInfo;\r\n paths: OpenAPIPaths;\r\n}\r\n\r\n/** An OpenAPI 3.0 info object.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in the future.\r\n */\r\nexport interface OpenAPIInfo {\r\n title: string;\r\n version: string;\r\n}\r\n\r\n/** An OpenAPI 3.0 paths object.\r\n * @internal\r\n */\r\nexport interface OpenAPIPaths {\r\n [index: string]: OpenAPIPathItem;\r\n}\r\n\r\n/** An OpenAPI 3.0 path item object.\r\n * @internal\r\n */\r\nexport interface OpenAPIPathItem {\r\n summary?: string;\r\n get?: OpenAPIOperation;\r\n put?: OpenAPIOperation;\r\n post?: OpenAPIOperation;\r\n delete?: OpenAPIOperation;\r\n options?: OpenAPIOperation;\r\n head?: OpenAPIOperation;\r\n patch?: OpenAPIOperation;\r\n trace?: OpenAPIOperation;\r\n parameters?: OpenAPIParameter[];\r\n}\r\n\r\n/** An OpenAPI 3.0 operation object.\r\n * @internal\r\n */\r\nexport interface OpenAPIOperation {\r\n summary?: string;\r\n operationId?: string;\r\n parameters?: OpenAPIParameter[];\r\n requestBody?: OpenAPIRequestBody;\r\n responses: OpenAPIResponses;\r\n}\r\n\r\n/** An OpenAPI 3.0 content map.\r\n * @internal\r\n */\r\nexport interface OpenAPIContentMap {\r\n [index: string]: OpenAPIMediaType;\r\n}\r\n\r\n/** An OpenAPI 3.0 parameter object.\r\n * @internal\r\n */\r\nexport interface OpenAPIParameter {\r\n name: string;\r\n in: \"query\" | \"header\" | \"path\" | \"cookie\";\r\n description?: string;\r\n required?: boolean;\r\n allowEmptyValue?: boolean;\r\n style?: \"matrix\" | \"label\" | \"form\" | \"simple\" | \"spaceDelimited\" | \"pipeDelimited\" | \"deepObject\";\r\n explode?: boolean;\r\n allowReserved?: boolean;\r\n schema?: OpenAPISchema;\r\n content?: OpenAPIContentMap;\r\n}\r\n\r\n/** An OpenAPI 3.0 media type object.\r\n * @internal\r\n */\r\nexport interface OpenAPIMediaType {\r\n schema?: OpenAPISchema;\r\n}\r\n\r\n/** An OpenAPI 3.0 schema object.\r\n * @internal\r\n */\r\nexport interface OpenAPISchema {\r\n type?: \"boolean\" | \"object\" | \"array\" | \"number\" | \"string\";\r\n nullable?: boolean;\r\n description?: string;\r\n}\r\n\r\n/** An OpenAPI 3.0 encoding object.\r\n * @internal\r\n */\r\nexport interface OpenAPIEncoding {\r\n contentType?: string;\r\n style?: string;\r\n explode?: boolean;\r\n allowReserved?: boolean;\r\n}\r\n\r\n/** An OpenAPI 3.0 parameter object.\r\n * @internal\r\n */\r\nexport interface OpenAPIRequestBody {\r\n description?: string;\r\n content: OpenAPIContentMap;\r\n required?: boolean;\r\n}\r\n\r\n/** An OpenAPI 3.0 responses object.\r\n * @internal\r\n */\r\nexport interface OpenAPIResponses {\r\n default?: OpenAPIResponse;\r\n \"200\"?: OpenAPIResponse;\r\n \"301\"?: OpenAPIResponse;\r\n \"302\"?: OpenAPIResponse;\r\n \"400\"?: OpenAPIResponse;\r\n \"404\"?: OpenAPIResponse;\r\n \"500\"?: OpenAPIResponse;\r\n}\r\n\r\n/** An OpenAPI 3.0 response object.\r\n * @internal\r\n */\r\nexport interface OpenAPIResponse {\r\n description: string;\r\n content?: { [index: string]: OpenAPIMediaType };\r\n}\r\n\r\n/** An OpenAPI-compatible description of an RPC protocol.\r\n * @internal\r\n */\r\nexport class RpcOpenAPIDescription {\r\n /** The protocol for this description. */\r\n public readonly protocol: WebAppRpcProtocol;\r\n\r\n /** The OpenAPI paths object for the protocol. */\r\n public get paths(): OpenAPIPaths {\r\n const paths: OpenAPIPaths = {};\r\n\r\n this.protocol.configuration.interfaces().forEach((definition) => {\r\n RpcOperation.forEach(definition, (operation) => {\r\n const path = this.protocol.supplyPathForOperation(operation, undefined);\r\n paths[path] = this.generateDescription(operation);\r\n });\r\n });\r\n\r\n return paths;\r\n }\r\n\r\n /** An OpenAPI 3.0 (Swagger) description of the RESTful API that is exposed through the protocol. */\r\n public get document(): OpenAPIDocument {\r\n return {\r\n openapi: \"3.0.0\",\r\n info: this.protocol.info,\r\n paths: this.paths,\r\n };\r\n }\r\n\r\n /** Creates an OpenAPI description of an RPC protocol. */\r\n public constructor(protocol: WebAppRpcProtocol) {\r\n this.protocol = protocol;\r\n }\r\n\r\n /** Converts to JSON. */\r\n public toJSON() {\r\n return this.document;\r\n }\r\n\r\n private generateDescription(operation: RpcOperation): OpenAPIPathItem {\r\n const requestContent: OpenAPIContentMap = { \"application/json\": { schema: { type: \"array\" } } };\r\n const responseContent: OpenAPIContentMap = { \"application/json\": { schema: { type: \"object\" } } };\r\n\r\n const description: OpenAPIPathItem = {};\r\n\r\n description.head = {\r\n requestBody: { content: requestContent, required: true },\r\n responses: {\r\n 200: { description: \"Success\", content: responseContent },\r\n default: { description: \"Error\", content: responseContent },\r\n },\r\n };\r\n\r\n const parameters = this.protocol.supplyPathParametersForOperation(operation);\r\n if (parameters.length)\r\n description.parameters = parameters;\r\n\r\n return description;\r\n }\r\n}\r\n"]}
|
|
@@ -12,7 +12,7 @@ import { OpenAPIInfo, OpenAPIParameter, RpcOpenAPIDescription } from "./OpenAPI"
|
|
|
12
12
|
import { WebAppRpcRequest } from "./WebAppRpcRequest";
|
|
13
13
|
/** An HTTP server request object.
|
|
14
14
|
* @public
|
|
15
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in
|
|
15
|
+
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in the future.
|
|
16
16
|
*/
|
|
17
17
|
export interface HttpServerRequest extends BackendReadable {
|
|
18
18
|
aborted: boolean;
|
|
@@ -46,7 +46,7 @@ export interface HttpServerRequest extends BackendReadable {
|
|
|
46
46
|
}
|
|
47
47
|
/** An HTTP server response object.
|
|
48
48
|
* @public
|
|
49
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in
|
|
49
|
+
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in the future.
|
|
50
50
|
*/
|
|
51
51
|
export interface HttpServerResponse extends BackendWritable {
|
|
52
52
|
send(body?: any): HttpServerResponse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebAppRpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2D;AAC3D,qEAAkE;AAGlE,uDAA2F;AAE3F,qDAAwE;AACxE,uCAAiF;AACjF,yDAAsD;AACtD,yDAAsD;AA6CtD;;GAEG;AACH,MAAsB,iBAAkB,SAAQ,yBAAW;IAGzD,+EAA+E;IACxE,KAAK,CAAC,yBAAyB,CAAC,GAAsB,EAAE,GAAuB;QACpF,OAAO,IAAI,CAAC,0BAA0B,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACnD,CAAC;IAED,gFAAgF;IACzE,KAAK,CAAC,0BAA0B,CAAC,GAAsB,EAAE,GAAuB;QACrF,IAAI,OAA6B,CAAC;QAClC,IAAI;YACF,OAAO,GAAG,MAAM,mCAAgB,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;SAC1D;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,OAAO,GAAG,2BAAY,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YACpD,qBAAM,CAAC,QAAQ,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YAC7C,KAAK,+BAAgB,CAAC,kBAAkB,CAAC,CAAC,OAAO,GAAG,CAAC;YACrD,KAAK,+BAAgB,CAAC,cAAc,CAAC,CAAC,OAAO,GAAG,CAAC;YACjD,KAAK,+BAAgB,CAAC,cAAc,CAAC,CAAC,OAAO,GAAG,CAAC;YACjD,KAAK,+BAAgB,CAAC,eAAe,CAAC,CAAC,OAAO,GAAG,CAAC;YAClD,OAAO,CAAC,CAAC,OAAO,GAAG,CAAC;SACrB;IACH,CAAC;IAID,+DAA+D;IACxD,SAAS,CAAC,IAAY;QAC3B,OAAO,IAAI,KAAK,GAAG,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAW,kBAAkB,KAAK,OAAO,IAAI,+BAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAO3E,mCAAmC;IACnC,YAAmB,aAA+B;QAChD,KAAK,CAAC,aAAa,CAAC,CAAC;QA3GP,oBAAe,GAAG,IAAI,CAAC;QAgDvC,sDAAsD;QAC/C,eAAU,GAAW,EAAE,CAAC;QAE/B,+CAA+C;QAC/B,gBAAW,GAAG,mCAAgB,CAAC;QAoC/B,2BAAsB,GAAG,IAAI,CAAC;QAoB5C,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,mCAAgB,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IACrG,CAAC;CACF;AA/GD,8CA+GC","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 { BentleyError, Logger } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { BackendReadable, BackendWritable } from \"../../BackendTypes\";\r\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\r\nimport { RpcContentType, RpcRequestStatus, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\r\nimport { RpcOperation } from \"../core/RpcOperation\";\r\nimport { RpcProtocol, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { OpenAPIInfo, OpenAPIParameter, RpcOpenAPIDescription } from \"./OpenAPI\";\r\nimport { WebAppRpcLogging } from \"./WebAppRpcLogging\";\r\nimport { WebAppRpcRequest } from \"./WebAppRpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** An HTTP server request object.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.\r\n */\r\nexport interface HttpServerRequest extends BackendReadable {\r\n aborted: boolean;\r\n httpVersion: string;\r\n httpVersionMajor: number;\r\n httpVersionMinor: number;\r\n complete: boolean;\r\n connection: any;\r\n headers: { [header: string]: string | string[] | undefined };\r\n rawHeaders: string[];\r\n trailers: { [key: string]: string | undefined };\r\n trailersDistinct: NodeJS.Dict<string[]>;\r\n rawTrailers: string[];\r\n setTimeout(msecs: number, callback: () => void): void;\r\n setTimeout(msecs: number, callback: () => void): this;\r\n url?: string;\r\n statusCode?: number;\r\n statusMessage?: string;\r\n socket: any;\r\n destroy(error?: Error): this;\r\n body: string | Buffer;\r\n path: string;\r\n method: string;\r\n ip?: string;\r\n header: (field: string) => string | undefined;\r\n headersDistinct: NodeJS.Dict<string[]>;\r\n}\r\n\r\n/** An HTTP server response object.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.\r\n */\r\nexport interface HttpServerResponse extends BackendWritable {\r\n send(body?: any): HttpServerResponse;\r\n status(code: number): HttpServerResponse;\r\n set(field: string, value: string): void;\r\n}\r\n\r\n/** The HTTP application protocol.\r\n * @internal\r\n */\r\nexport abstract class WebAppRpcProtocol extends RpcProtocol {\r\n public override preserveStreams = true;\r\n\r\n /** Convenience handler for an RPC operation get request for an HTTP server. */\r\n public async handleOperationGetRequest(req: HttpServerRequest, res: HttpServerResponse) {\r\n return this.handleOperationPostRequest(req, res);\r\n }\r\n\r\n /** Convenience handler for an RPC operation post request for an HTTP server. */\r\n public async handleOperationPostRequest(req: HttpServerRequest, res: HttpServerResponse) {\r\n let request: SerializedRpcRequest;\r\n try {\r\n request = await WebAppRpcRequest.parseRequest(this, req);\r\n } catch (error) {\r\n const message = BentleyError.getErrorMessage(error);\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, `Failed to parse request: ${message}`, BentleyError.getErrorMetadata(error));\r\n res.status(400);\r\n res.send(JSON.stringify({ message, isError: true }));\r\n return;\r\n }\r\n const fulfillment = await this.fulfill(request);\r\n await WebAppRpcRequest.sendResponse(this, request, fulfillment, req, res);\r\n }\r\n\r\n /** Convenience handler for an OpenAPI description request for an HTTP server. */\r\n public handleOpenApiDescriptionRequest(_req: HttpServerRequest, res: HttpServerResponse) {\r\n const description = JSON.stringify(this.openAPIDescription);\r\n res.send(description);\r\n }\r\n\r\n /** Converts an HTTP content type value to an RPC content type value. */\r\n public static computeContentType(httpType: string | null | undefined): RpcContentType {\r\n if (!httpType)\r\n return RpcContentType.Unknown;\r\n\r\n if (httpType.indexOf(WEB_RPC_CONSTANTS.ANY_TEXT) === 0) {\r\n return RpcContentType.Text;\r\n } else if (httpType.indexOf(WEB_RPC_CONSTANTS.BINARY) === 0) {\r\n return RpcContentType.Binary;\r\n } else if (httpType.indexOf(WEB_RPC_CONSTANTS.MULTIPART) === 0) {\r\n return RpcContentType.Multipart;\r\n } else {\r\n return RpcContentType.Unknown;\r\n }\r\n }\r\n\r\n /** The OpenAPI-compatible info object for this protocol. */\r\n public abstract info: OpenAPIInfo;\r\n\r\n /** An optional prefix for RPC operation URI paths. */\r\n public pathPrefix: string = \"\";\r\n\r\n /** The RPC request class for this protocol. */\r\n public readonly requestType = WebAppRpcRequest;\r\n\r\n /** Supplies the status corresponding to a protocol-specific code value. */\r\n public override getStatus(code: number): RpcRequestStatus {\r\n switch (code) {\r\n case 404: return RpcRequestStatus.NotFound;\r\n case 202: return RpcRequestStatus.Pending;\r\n case 200: return RpcRequestStatus.Resolved;\r\n case 500: return RpcRequestStatus.Rejected;\r\n case 204: return RpcRequestStatus.NoContent;\r\n case 502: return RpcRequestStatus.BadGateway;\r\n case 503: return RpcRequestStatus.ServiceUnavailable;\r\n case 504: return RpcRequestStatus.GatewayTimeout;\r\n case 408: return RpcRequestStatus.RequestTimeout;\r\n case 429: return RpcRequestStatus.TooManyRequests;\r\n default: return RpcRequestStatus.Unknown;\r\n }\r\n }\r\n\r\n /** Supplies the protocol-specific code corresponding to a status value. */\r\n public override getCode(status: RpcRequestStatus): number {\r\n switch (status) {\r\n case RpcRequestStatus.NotFound: return 404;\r\n case RpcRequestStatus.Pending: return 202;\r\n case RpcRequestStatus.Resolved: return 200;\r\n case RpcRequestStatus.Rejected: return 500;\r\n case RpcRequestStatus.NoContent: return 204;\r\n case RpcRequestStatus.BadGateway: return 502;\r\n case RpcRequestStatus.ServiceUnavailable: return 503;\r\n case RpcRequestStatus.GatewayTimeout: return 504;\r\n case RpcRequestStatus.RequestTimeout: return 408;\r\n case RpcRequestStatus.TooManyRequests: return 429;\r\n default: return 501;\r\n }\r\n }\r\n\r\n public override supportsStatusCategory = true;\r\n\r\n /** Whether an HTTP status code indicates a request timeout. */\r\n public isTimeout(code: number): boolean {\r\n return code === 504;\r\n }\r\n\r\n /** An OpenAPI-compatible description of this protocol.\r\n * @internal\r\n */\r\n public get openAPIDescription() { return new RpcOpenAPIDescription(this); }\r\n\r\n /** Returns the OpenAPI-compatible URI path parameters for an RPC operation.\r\n * @internal\r\n */\r\n public abstract supplyPathParametersForOperation(_operation: RpcOperation): OpenAPIParameter[];\r\n\r\n /** Constructs an HTTP protocol. */\r\n public constructor(configuration: RpcConfiguration) {\r\n super(configuration);\r\n this.events.addListener(async (event, object) => WebAppRpcLogging.logProtocolEvent(event, object));\r\n }\r\n}\r\n"]}
|
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,CAAC;IAO3E,mCAAmC;IACnC,YAAmB,aAA+B;QAChD,KAAK,CAAC,aAAa,CAAC,CAAC;QA3GP,oBAAe,GAAG,IAAI,CAAC;QAgDvC,sDAAsD;QAC/C,eAAU,GAAW,EAAE,CAAC;QAE/B,+CAA+C;QAC/B,gBAAW,GAAG,mCAAgB,CAAC;QAoC/B,2BAAsB,GAAG,IAAI,CAAC;QAoB5C,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,mCAAgB,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IACrG,CAAC;CACF;AA/GD,8CA+GC","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 { BentleyError, Logger } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { BackendReadable, BackendWritable } from \"../../BackendTypes\";\r\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\r\nimport { RpcContentType, RpcRequestStatus, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\r\nimport { RpcOperation } from \"../core/RpcOperation\";\r\nimport { RpcProtocol, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { OpenAPIInfo, OpenAPIParameter, RpcOpenAPIDescription } from \"./OpenAPI\";\r\nimport { WebAppRpcLogging } from \"./WebAppRpcLogging\";\r\nimport { WebAppRpcRequest } from \"./WebAppRpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** An HTTP server request object.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in the future.\r\n */\r\nexport interface HttpServerRequest extends BackendReadable {\r\n aborted: boolean;\r\n httpVersion: string;\r\n httpVersionMajor: number;\r\n httpVersionMinor: number;\r\n complete: boolean;\r\n connection: any;\r\n headers: { [header: string]: string | string[] | undefined };\r\n rawHeaders: string[];\r\n trailers: { [key: string]: string | undefined };\r\n trailersDistinct: NodeJS.Dict<string[]>;\r\n rawTrailers: string[];\r\n setTimeout(msecs: number, callback: () => void): void;\r\n setTimeout(msecs: number, callback: () => void): this;\r\n url?: string;\r\n statusCode?: number;\r\n statusMessage?: string;\r\n socket: any;\r\n destroy(error?: Error): this;\r\n body: string | Buffer;\r\n path: string;\r\n method: string;\r\n ip?: string;\r\n header: (field: string) => string | undefined;\r\n headersDistinct: NodeJS.Dict<string[]>;\r\n}\r\n\r\n/** An HTTP server response object.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in the future.\r\n */\r\nexport interface HttpServerResponse extends BackendWritable {\r\n send(body?: any): HttpServerResponse;\r\n status(code: number): HttpServerResponse;\r\n set(field: string, value: string): void;\r\n}\r\n\r\n/** The HTTP application protocol.\r\n * @internal\r\n */\r\nexport abstract class WebAppRpcProtocol extends RpcProtocol {\r\n public override preserveStreams = true;\r\n\r\n /** Convenience handler for an RPC operation get request for an HTTP server. */\r\n public async handleOperationGetRequest(req: HttpServerRequest, res: HttpServerResponse) {\r\n return this.handleOperationPostRequest(req, res);\r\n }\r\n\r\n /** Convenience handler for an RPC operation post request for an HTTP server. */\r\n public async handleOperationPostRequest(req: HttpServerRequest, res: HttpServerResponse) {\r\n let request: SerializedRpcRequest;\r\n try {\r\n request = await WebAppRpcRequest.parseRequest(this, req);\r\n } catch (error) {\r\n const message = BentleyError.getErrorMessage(error);\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, `Failed to parse request: ${message}`, BentleyError.getErrorMetadata(error));\r\n res.status(400);\r\n res.send(JSON.stringify({ message, isError: true }));\r\n return;\r\n }\r\n const fulfillment = await this.fulfill(request);\r\n await WebAppRpcRequest.sendResponse(this, request, fulfillment, req, res);\r\n }\r\n\r\n /** Convenience handler for an OpenAPI description request for an HTTP server. */\r\n public handleOpenApiDescriptionRequest(_req: HttpServerRequest, res: HttpServerResponse) {\r\n const description = JSON.stringify(this.openAPIDescription);\r\n res.send(description);\r\n }\r\n\r\n /** Converts an HTTP content type value to an RPC content type value. */\r\n public static computeContentType(httpType: string | null | undefined): RpcContentType {\r\n if (!httpType)\r\n return RpcContentType.Unknown;\r\n\r\n if (httpType.indexOf(WEB_RPC_CONSTANTS.ANY_TEXT) === 0) {\r\n return RpcContentType.Text;\r\n } else if (httpType.indexOf(WEB_RPC_CONSTANTS.BINARY) === 0) {\r\n return RpcContentType.Binary;\r\n } else if (httpType.indexOf(WEB_RPC_CONSTANTS.MULTIPART) === 0) {\r\n return RpcContentType.Multipart;\r\n } else {\r\n return RpcContentType.Unknown;\r\n }\r\n }\r\n\r\n /** The OpenAPI-compatible info object for this protocol. */\r\n public abstract info: OpenAPIInfo;\r\n\r\n /** An optional prefix for RPC operation URI paths. */\r\n public pathPrefix: string = \"\";\r\n\r\n /** The RPC request class for this protocol. */\r\n public readonly requestType = WebAppRpcRequest;\r\n\r\n /** Supplies the status corresponding to a protocol-specific code value. */\r\n public override getStatus(code: number): RpcRequestStatus {\r\n switch (code) {\r\n case 404: return RpcRequestStatus.NotFound;\r\n case 202: return RpcRequestStatus.Pending;\r\n case 200: return RpcRequestStatus.Resolved;\r\n case 500: return RpcRequestStatus.Rejected;\r\n case 204: return RpcRequestStatus.NoContent;\r\n case 502: return RpcRequestStatus.BadGateway;\r\n case 503: return RpcRequestStatus.ServiceUnavailable;\r\n case 504: return RpcRequestStatus.GatewayTimeout;\r\n case 408: return RpcRequestStatus.RequestTimeout;\r\n case 429: return RpcRequestStatus.TooManyRequests;\r\n default: return RpcRequestStatus.Unknown;\r\n }\r\n }\r\n\r\n /** Supplies the protocol-specific code corresponding to a status value. */\r\n public override getCode(status: RpcRequestStatus): number {\r\n switch (status) {\r\n case RpcRequestStatus.NotFound: return 404;\r\n case RpcRequestStatus.Pending: return 202;\r\n case RpcRequestStatus.Resolved: return 200;\r\n case RpcRequestStatus.Rejected: return 500;\r\n case RpcRequestStatus.NoContent: return 204;\r\n case RpcRequestStatus.BadGateway: return 502;\r\n case RpcRequestStatus.ServiceUnavailable: return 503;\r\n case RpcRequestStatus.GatewayTimeout: return 504;\r\n case RpcRequestStatus.RequestTimeout: return 408;\r\n case RpcRequestStatus.TooManyRequests: return 429;\r\n default: return 501;\r\n }\r\n }\r\n\r\n public override supportsStatusCategory = true;\r\n\r\n /** Whether an HTTP status code indicates a request timeout. */\r\n public isTimeout(code: number): boolean {\r\n return code === 504;\r\n }\r\n\r\n /** An OpenAPI-compatible description of this protocol.\r\n * @internal\r\n */\r\n public get openAPIDescription() { return new RpcOpenAPIDescription(this); }\r\n\r\n /** Returns the OpenAPI-compatible URI path parameters for an RPC operation.\r\n * @internal\r\n */\r\n public abstract supplyPathParametersForOperation(_operation: RpcOperation): OpenAPIParameter[];\r\n\r\n /** Constructs an HTTP protocol. */\r\n public constructor(configuration: RpcConfiguration) {\r\n super(configuration);\r\n this.events.addListener(async (event, object) => WebAppRpcLogging.logProtocolEvent(event, object));\r\n }\r\n}\r\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module iModels
|
|
3
3
|
*/
|
|
4
4
|
import { GuidString } from "@itwin/core-bentley";
|
|
5
|
-
import { ChangesetIdWithIndex, LocalFileName } from "./ChangesetProps";
|
|
5
|
+
import { ChangesetIdWithIndex, ChangesetIndexOrId, LocalFileName } from "./ChangesetProps";
|
|
6
6
|
import { IModelEncryptionProps, OpenDbKey } from "./IModel";
|
|
7
7
|
import { IModelVersionProps } from "./IModelVersion";
|
|
8
8
|
/** The Id assigned to a briefcase by iModelHub, or [[BriefcaseIdValue.Unassigned]] .
|
|
@@ -135,6 +135,17 @@ export interface RequestNewBriefcaseProps {
|
|
|
135
135
|
/** Id of the change set of the new briefcase. If undefined, use latest. */
|
|
136
136
|
asOf?: IModelVersionProps;
|
|
137
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Arguments to open a Checkpoint directly from its cloud container
|
|
140
|
+
* @beta
|
|
141
|
+
*/
|
|
142
|
+
export interface OpenCheckpointArgs {
|
|
143
|
+
readonly iTwinId: GuidString;
|
|
144
|
+
/** Id of the iModel */
|
|
145
|
+
readonly iModelId: GuidString;
|
|
146
|
+
/** changeset for the checkpoint. If undefined, attempt to open the checkpoint for the latest changeset. */
|
|
147
|
+
readonly changeset?: ChangesetIndexOrId;
|
|
148
|
+
}
|
|
138
149
|
/**
|
|
139
150
|
* Manages the download of a briefcase
|
|
140
151
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BriefcaseTypes.d.ts","sourceRoot":"","sources":["../../src/BriefcaseTypes.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"BriefcaseTypes.d.ts","sourceRoot":"","sources":["../../src/BriefcaseTypes.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC;;;GAGG;AACH,oBAAY,gBAAgB;IAC1B,+CAA+C;IAC/C,OAAO,aAAa;IAEpB,gDAAgD;IAChD,GAAG,WAAU;IAEb,gFAAgF;IAChF,UAAU,IAAI;IAEd,+EAA+E;IAC/E,SAAS,WAA4B;IAErC;;;;;;;;;;OA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IAER,qDAAqD;IACrD,yDAAW,CAAA;AACb,CAAC,EANW,cAAc,KAAd,cAAc,QAMzB;AAgBD;;;;GAIG;AACH,MAAM,CAAN,IAAY,WAkBX;AAlBD,WAAY,WAAW;IACrB,sIAAsI;IACtI,qDAAQ,CAAA;IAER;;;OAGG;IACH,mEAAe,CAAA;IAEf,4IAA4I;IAC5I,yEAAkB,CAAA;IAElB,oIAAoI;IACpI,iDAAM,CAAA;IAEN,4FAA4F;IAC5F,iDAAM,CAAA;AACR,CAAC,EAlBW,WAAW,KAAX,WAAW,QAkBtB","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 iModels\r\n */\r\n\r\nimport { GuidString } from \"@itwin/core-bentley\";\r\nimport { ChangesetIdWithIndex, LocalFileName } from \"./ChangesetProps\";\r\nimport { IModelEncryptionProps, OpenDbKey } from \"./IModel\";\r\nimport { IModelVersionProps } from \"./IModelVersion\";\r\n\r\n/** The Id assigned to a briefcase by iModelHub, or [[BriefcaseIdValue.Unassigned]] .\r\n * @public\r\n * @extensions\r\n */\r\nexport type BriefcaseId = number;\r\n\r\n/** Values of [[BriefcaseId]] that have special meaning.\r\n * @public\r\n * @extensions\r\n */\r\nexport enum BriefcaseIdValue {\r\n /** Indicates an invalid/illegal BriefcaseId */\r\n Illegal = 0xffffffff,\r\n\r\n /** BriefcaseIds must be less than this value */\r\n Max = 1 << 24,\r\n\r\n /** All valid iModelHub issued BriefcaseIds will be equal or higher than this */\r\n FirstValid = 2,\r\n\r\n /** All valid iModelHub issued BriefcaseIds will be equal or lower than this */\r\n LastValid = BriefcaseIdValue.Max - 11,\r\n\r\n /**\r\n * The briefcase has not been assigned a unique Id by iModelHub. Only briefcases that have been assigned a unique BriefcaseId may create changesets,\r\n * because BriefcaseId is used to create unique ElementIds for new elements.\r\n *\r\n * The `Unassigned` briefcaseId is used for several purposes:\r\n * - **Snapshots**. Snapshot files are immutable copies of an iModel for archival or data exchange purposes. They can neither generate nor accept new changesets.\r\n * - **Checkpoints**. Checkpoints are Snapshots that represent a specific version on an iModel's timeline.\r\n * - **PullOnly**. A local briefcase file that may be used to \"slide\" along a timeline by applying incoming changesets.\r\n * They are always opened readonly except to apply changesets.\r\n * - **Standalone**. Standalone iModels are local files that are not connected to iModelHub, and therefore cannot accept or create changesets.\r\n */\r\n Unassigned = 0,\r\n}\r\n\r\n/** Whether a briefcase is editable or may only accept incoming changesets from iModelHub\r\n * @public\r\n * @extensions\r\n */\r\nexport enum SyncMode {\r\n /** Use a fixed version (i.e. a checkpoint). See [CheckpointManager]($backend) for preferred approach to using checkpoint files. */\r\n FixedVersion = 1,\r\n /** A briefcase that can be edited. A unique briefcaseId must be assigned by iModelHub. */\r\n PullAndPush = 2,\r\n /** use [BriefcaseIdValue.Unassigned](%backend). This makes a briefcase that can accept changesets from iModelHub but can never create changesets. */\r\n PullOnly = 3,\r\n}\r\n\r\n/**\r\n * Options to open a previously downloaded briefcase\r\n * @public\r\n */\r\nexport interface OpenBriefcaseOptions {\r\n /** open briefcase Readonly */\r\n readonly openAsReadOnly?: boolean;\r\n}\r\n\r\n/**\r\n * Properties that specify a briefcase within the local briefcase cache.\r\n * @see BriefcaseManager.getFileName\r\n * @public\r\n */\r\nexport interface BriefcaseProps {\r\n /** Id of the iModel */\r\n readonly iModelId: GuidString;\r\n\r\n /** BriefcaseId of the briefcase */\r\n readonly briefcaseId: BriefcaseId;\r\n}\r\n\r\n/** Properties for opening a local briefcase file via [BriefcaseDb.open]($backend)\r\n * @public\r\n */\r\nexport interface OpenBriefcaseProps extends IModelEncryptionProps, OpenDbKey { // eslint-disable-line deprecation/deprecation\r\n /** the full path to the briefcase file */\r\n readonly fileName: LocalFileName;\r\n /**\r\n * If true, open the briefcase readonly.\r\n * @note Readonly connections always hold a read transaction against the briefcase. That can cause the WAL file size to grow\r\n * unbounded if changes happen while they're open (see [Checkpoint starvation](https://www.sqlite.org/wal.html#avoiding_excessively_large_wal_files))\r\n * It is a good idea to close the readonly connection *before* closing the writeable connection so the WAL file will be deleted.\r\n */\r\n readonly readonly?: boolean;\r\n /** If true, open the briefcase readonly and monitor it for changes originating from another connection.\r\n * When such changes are detected, the default txn will be restarted.\r\n * The restart occurs only after the next iteration of the backend event loop, and will generate events that reflect the changes from the other connection.\r\n * This can be useful in contexts where the read-only connection is displaying a view of the contents of the briefcase while another, non-interactive program\r\n * is adding txns to the briefcase. It may not be reliable if the writable connection is undoing or redoing txns.\r\n * @note This cannot be used with cloud-based briefcases.\r\n */\r\n readonly watchForChanges?: boolean;\r\n}\r\n\r\n/** Properties of a local briefcase file, returned by [BriefcaseManager.getCachedBriefcases]($backend) and [BriefcaseManager.downloadBriefcase]($backend)\r\n * @public\r\n * @extensions\r\n */\r\nexport interface LocalBriefcaseProps {\r\n /** Full path of local file. */\r\n readonly fileName: LocalFileName;\r\n\r\n /** The iTwin containing the iModel. */\r\n readonly iTwinId: GuidString;\r\n\r\n /** The iModelId. */\r\n readonly iModelId: GuidString;\r\n\r\n /** The briefcaseId. */\r\n readonly briefcaseId: BriefcaseId;\r\n\r\n /** The current changesetId.\r\n * @note ChangeSet Ids are string hash values based on the ChangeSet's content and parent.\r\n */\r\n readonly changeset: ChangesetIdWithIndex;\r\n\r\n /** Size of the briefcase file in bytes */\r\n readonly fileSize: number;\r\n}\r\n\r\n/** Properties for downloading a briefcase to a local file, from iModelHub.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface RequestNewBriefcaseProps {\r\n /** iTwin that the iModel belongs to. */\r\n readonly iTwinId: GuidString;\r\n\r\n /** The iModelId for the new briefcase. */\r\n readonly iModelId: GuidString;\r\n\r\n /** Full path of local file to store the briefcase. If undefined, a file will be created in the briefcase cache, and this member will be filled with the full path to the file.\r\n * Callers can use this to open the briefcase after the download completes.\r\n * @note this member is both an input and an output.\r\n */\r\n readonly fileName?: LocalFileName;\r\n\r\n /**\r\n * The BriefcaseId for the new briefcase. If undefined, a new BriefcaseId will be acquired from iModelHub before the download, and is returned in this member.\r\n * @note To download a briefcase that can accept but not create new changesets (sometimes referred to as \"pull only\" briefcases), set this value to [[BriefcaseIdValue.Unassigned]].\r\n * After downloading, you can merely delete unassigned briefcase files when they are no longer needed. Assigned BriefcaseIds should be released (via [BriefcaseManager.releaseBriefcase]($backend) )\r\n * when you are done with them.\r\n * @note this member is both an input and an output.\r\n *\r\n */\r\n briefcaseId?: BriefcaseId;\r\n\r\n /** Id of the change set of the new briefcase. If undefined, use latest. */\r\n asOf?: IModelVersionProps;\r\n}\r\n\r\n/**\r\n * Manages the download of a briefcase\r\n * @public\r\n */\r\nexport interface BriefcaseDownloader {\r\n /** Id of the briefcase being downloaded */\r\n readonly briefcaseId: BriefcaseId;\r\n\r\n /** the name of the local file for the briefcase */\r\n readonly fileName: LocalFileName;\r\n\r\n /** Promise that resolves when the download completes. await this to complete the download */\r\n readonly downloadPromise: Promise<void>;\r\n\r\n /** Request cancellation of the download */\r\n readonly requestCancel: () => Promise<boolean>;\r\n}\r\n\r\n/** Option to control the validation and upgrade of domain schemas in the Db\r\n * @beta\r\n */\r\nexport enum DomainOptions {\r\n /** Domain schemas will be validated for any required upgrades. Any errors will be reported back, and cause the application to fail opening the Db */\r\n CheckRequiredUpgrades = 0,\r\n\r\n /** Domain schemas will be validated for any required or optional upgrades. Any errors will be reported back, and cause the application to fail opening the Db */\r\n CheckRecommendedUpgrades = 1,\r\n\r\n /** Domain schemas will be upgraded if necessary. However, only compatible schema upgrades will be allowed - these are typically additions of classes, properties, and changes to custom attributes */\r\n Upgrade = 2,\r\n\r\n /** Domain schemas will neither be validated nor be upgraded. Used only internally */\r\n SkipCheck = 3,\r\n}\r\n\r\n/** Options that control whether a profile upgrade should be performed when opening a Db\r\n * @beta\r\n */\r\nexport enum ProfileOptions {\r\n /** No profile upgrade will be performed. If a profile upgrade was required, opening the file will fail */\r\n None = 0,\r\n\r\n /** Profile upgrade will be performed if necessary */\r\n Upgrade = 1,\r\n}\r\n\r\n/** Arguments to validate and update the profile and domain schemas when opening a Db\r\n * @beta\r\n */\r\nexport interface UpgradeOptions {\r\n /** Option to control the validation and upgrade of domain schemas in the Db */\r\n readonly domain?: DomainOptions;\r\n\r\n /** Options that control whether a profile upgrade should be performed when opening a file */\r\n readonly profile?: ProfileOptions;\r\n\r\n /** Options that will allow data transform during Profile/Domain schema upgrade */\r\n readonly schemaLockHeld?: boolean;\r\n}\r\n\r\n/**\r\n * The state of the schemas in the Db compared with what the current version of the software expects\r\n * Note: The state may vary depending on whether the Db is to be opened ReadOnly or ReadWrite.\r\n * @beta\r\n */\r\nexport enum SchemaState {\r\n /** The schemas in the Db are up-to-date, and do not need to be upgraded before opening it with the current version of the software */\r\n UpToDate,\r\n\r\n /** It's required that the schemas in the Db be upgraded before it can be opened with the current version of the software.\r\n * This may happen in read-write scenarios where the application requires a newer version of the schemas to be in place before\r\n * it can write data based on that new schema.\r\n */\r\n UpgradeRequired,\r\n\r\n /** It's recommended, but not necessary that the schemas in the Db be upgraded before opening it with the current version of the software */\r\n UpgradeRecommended,\r\n\r\n /** The schemas in the Db are too old to be opened by the current version of the software. Upgrade using the API is not possible. */\r\n TooOld,\r\n\r\n /** The schemas in the Db are too new to be opened by the current version of the software */\r\n TooNew,\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"BriefcaseTypes.js","sourceRoot":"","sources":["../../src/BriefcaseTypes.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAaH;;;GAGG;AACH,MAAM,CAAN,IAAY,gBAyBX;AAzBD,WAAY,gBAAgB;IAC1B,+CAA+C;IAC/C,sEAAoB,CAAA;IAEpB,gDAAgD;IAChD,4DAAa,CAAA;IAEb,gFAAgF;IAChF,mEAAc,CAAA;IAEd,+EAA+E;IAC/E,wEAAqC,CAAA;IAErC;;;;;;;;;;OAUG;IACH,mEAAc,CAAA;AAChB,CAAC,EAzBW,gBAAgB,KAAhB,gBAAgB,QAyB3B;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,QAOX;AAPD,WAAY,QAAQ;IAClB,mIAAmI;IACnI,uDAAgB,CAAA;IAChB,0FAA0F;IAC1F,qDAAe,CAAA;IACf,qJAAqJ;IACrJ,+CAAY,CAAA;AACd,CAAC,EAPW,QAAQ,KAAR,QAAQ,QAOnB;AAwID;;GAEG;AACH,MAAM,CAAN,IAAY,aAYX;AAZD,WAAY,aAAa;IACvB,qJAAqJ;IACrJ,mFAAyB,CAAA;IAEzB,iKAAiK;IACjK,yFAA4B,CAAA;IAE5B,sMAAsM;IACtM,uDAAW,CAAA;IAEX,qFAAqF;IACrF,2DAAa,CAAA;AACf,CAAC,EAZW,aAAa,KAAb,aAAa,QAYxB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,0GAA0G;IAC1G,mDAAQ,CAAA;IAER,qDAAqD;IACrD,yDAAW,CAAA;AACb,CAAC,EANW,cAAc,KAAd,cAAc,QAMzB;AAgBD;;;;GAIG;AACH,MAAM,CAAN,IAAY,WAkBX;AAlBD,WAAY,WAAW;IACrB,sIAAsI;IACtI,qDAAQ,CAAA;IAER;;;OAGG;IACH,mEAAe,CAAA;IAEf,4IAA4I;IAC5I,yEAAkB,CAAA;IAElB,oIAAoI;IACpI,iDAAM,CAAA;IAEN,4FAA4F;IAC5F,iDAAM,CAAA;AACR,CAAC,EAlBW,WAAW,KAAX,WAAW,QAkBtB","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 iModels\r\n */\r\n\r\nimport { GuidString } from \"@itwin/core-bentley\";\r\nimport { ChangesetIdWithIndex, ChangesetIndexOrId, LocalFileName } from \"./ChangesetProps\";\r\nimport { IModelEncryptionProps, OpenDbKey } from \"./IModel\";\r\nimport { IModelVersionProps } from \"./IModelVersion\";\r\n\r\n/** The Id assigned to a briefcase by iModelHub, or [[BriefcaseIdValue.Unassigned]] .\r\n * @public\r\n * @extensions\r\n */\r\nexport type BriefcaseId = number;\r\n\r\n/** Values of [[BriefcaseId]] that have special meaning.\r\n * @public\r\n * @extensions\r\n */\r\nexport enum BriefcaseIdValue {\r\n /** Indicates an invalid/illegal BriefcaseId */\r\n Illegal = 0xffffffff,\r\n\r\n /** BriefcaseIds must be less than this value */\r\n Max = 1 << 24,\r\n\r\n /** All valid iModelHub issued BriefcaseIds will be equal or higher than this */\r\n FirstValid = 2,\r\n\r\n /** All valid iModelHub issued BriefcaseIds will be equal or lower than this */\r\n LastValid = BriefcaseIdValue.Max - 11,\r\n\r\n /**\r\n * The briefcase has not been assigned a unique Id by iModelHub. Only briefcases that have been assigned a unique BriefcaseId may create changesets,\r\n * because BriefcaseId is used to create unique ElementIds for new elements.\r\n *\r\n * The `Unassigned` briefcaseId is used for several purposes:\r\n * - **Snapshots**. Snapshot files are immutable copies of an iModel for archival or data exchange purposes. They can neither generate nor accept new changesets.\r\n * - **Checkpoints**. Checkpoints are Snapshots that represent a specific version on an iModel's timeline.\r\n * - **PullOnly**. A local briefcase file that may be used to \"slide\" along a timeline by applying incoming changesets.\r\n * They are always opened readonly except to apply changesets.\r\n * - **Standalone**. Standalone iModels are local files that are not connected to iModelHub, and therefore cannot accept or create changesets.\r\n */\r\n Unassigned = 0,\r\n}\r\n\r\n/** Whether a briefcase is editable or may only accept incoming changesets from iModelHub\r\n * @public\r\n * @extensions\r\n */\r\nexport enum SyncMode {\r\n /** Use a fixed version (i.e. a checkpoint). See [CheckpointManager]($backend) for preferred approach to using checkpoint files. */\r\n FixedVersion = 1,\r\n /** A briefcase that can be edited. A unique briefcaseId must be assigned by iModelHub. */\r\n PullAndPush = 2,\r\n /** use [BriefcaseIdValue.Unassigned](%backend). This makes a briefcase that can accept changesets from iModelHub but can never create changesets. */\r\n PullOnly = 3,\r\n}\r\n\r\n/**\r\n * Options to open a previously downloaded briefcase\r\n * @public\r\n */\r\nexport interface OpenBriefcaseOptions {\r\n /** open briefcase Readonly */\r\n readonly openAsReadOnly?: boolean;\r\n}\r\n\r\n/**\r\n * Properties that specify a briefcase within the local briefcase cache.\r\n * @see BriefcaseManager.getFileName\r\n * @public\r\n */\r\nexport interface BriefcaseProps {\r\n /** Id of the iModel */\r\n readonly iModelId: GuidString;\r\n\r\n /** BriefcaseId of the briefcase */\r\n readonly briefcaseId: BriefcaseId;\r\n}\r\n\r\n/** Properties for opening a local briefcase file via [BriefcaseDb.open]($backend)\r\n * @public\r\n */\r\nexport interface OpenBriefcaseProps extends IModelEncryptionProps, OpenDbKey { // eslint-disable-line deprecation/deprecation\r\n /** the full path to the briefcase file */\r\n readonly fileName: LocalFileName;\r\n /**\r\n * If true, open the briefcase readonly.\r\n * @note Readonly connections always hold a read transaction against the briefcase. That can cause the WAL file size to grow\r\n * unbounded if changes happen while they're open (see [Checkpoint starvation](https://www.sqlite.org/wal.html#avoiding_excessively_large_wal_files))\r\n * It is a good idea to close the readonly connection *before* closing the writeable connection so the WAL file will be deleted.\r\n */\r\n readonly readonly?: boolean;\r\n /** If true, open the briefcase readonly and monitor it for changes originating from another connection.\r\n * When such changes are detected, the default txn will be restarted.\r\n * The restart occurs only after the next iteration of the backend event loop, and will generate events that reflect the changes from the other connection.\r\n * This can be useful in contexts where the read-only connection is displaying a view of the contents of the briefcase while another, non-interactive program\r\n * is adding txns to the briefcase. It may not be reliable if the writable connection is undoing or redoing txns.\r\n * @note This cannot be used with cloud-based briefcases.\r\n */\r\n readonly watchForChanges?: boolean;\r\n}\r\n\r\n/** Properties of a local briefcase file, returned by [BriefcaseManager.getCachedBriefcases]($backend) and [BriefcaseManager.downloadBriefcase]($backend)\r\n * @public\r\n * @extensions\r\n */\r\nexport interface LocalBriefcaseProps {\r\n /** Full path of local file. */\r\n readonly fileName: LocalFileName;\r\n\r\n /** The iTwin containing the iModel. */\r\n readonly iTwinId: GuidString;\r\n\r\n /** The iModelId. */\r\n readonly iModelId: GuidString;\r\n\r\n /** The briefcaseId. */\r\n readonly briefcaseId: BriefcaseId;\r\n\r\n /** The current changesetId.\r\n * @note ChangeSet Ids are string hash values based on the ChangeSet's content and parent.\r\n */\r\n readonly changeset: ChangesetIdWithIndex;\r\n\r\n /** Size of the briefcase file in bytes */\r\n readonly fileSize: number;\r\n}\r\n\r\n/** Properties for downloading a briefcase to a local file, from iModelHub.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface RequestNewBriefcaseProps {\r\n /** iTwin that the iModel belongs to. */\r\n readonly iTwinId: GuidString;\r\n\r\n /** The iModelId for the new briefcase. */\r\n readonly iModelId: GuidString;\r\n\r\n /** Full path of local file to store the briefcase. If undefined, a file will be created in the briefcase cache, and this member will be filled with the full path to the file.\r\n * Callers can use this to open the briefcase after the download completes.\r\n * @note this member is both an input and an output.\r\n */\r\n readonly fileName?: LocalFileName;\r\n\r\n /**\r\n * The BriefcaseId for the new briefcase. If undefined, a new BriefcaseId will be acquired from iModelHub before the download, and is returned in this member.\r\n * @note To download a briefcase that can accept but not create new changesets (sometimes referred to as \"pull only\" briefcases), set this value to [[BriefcaseIdValue.Unassigned]].\r\n * After downloading, you can merely delete unassigned briefcase files when they are no longer needed. Assigned BriefcaseIds should be released (via [BriefcaseManager.releaseBriefcase]($backend) )\r\n * when you are done with them.\r\n * @note this member is both an input and an output.\r\n *\r\n */\r\n briefcaseId?: BriefcaseId;\r\n\r\n /** Id of the change set of the new briefcase. If undefined, use latest. */\r\n asOf?: IModelVersionProps;\r\n}\r\n\r\n/**\r\n * Arguments to open a Checkpoint directly from its cloud container\r\n * @beta\r\n */\r\nexport interface OpenCheckpointArgs {\r\n readonly iTwinId: GuidString;\r\n\r\n /** Id of the iModel */\r\n readonly iModelId: GuidString;\r\n\r\n /** changeset for the checkpoint. If undefined, attempt to open the checkpoint for the latest changeset. */\r\n readonly changeset?: ChangesetIndexOrId;\r\n}\r\n\r\n/**\r\n * Manages the download of a briefcase\r\n * @public\r\n */\r\nexport interface BriefcaseDownloader {\r\n /** Id of the briefcase being downloaded */\r\n readonly briefcaseId: BriefcaseId;\r\n\r\n /** the name of the local file for the briefcase */\r\n readonly fileName: LocalFileName;\r\n\r\n /** Promise that resolves when the download completes. await this to complete the download */\r\n readonly downloadPromise: Promise<void>;\r\n\r\n /** Request cancellation of the download */\r\n readonly requestCancel: () => Promise<boolean>;\r\n}\r\n\r\n/** Option to control the validation and upgrade of domain schemas in the Db\r\n * @beta\r\n */\r\nexport enum DomainOptions {\r\n /** Domain schemas will be validated for any required upgrades. Any errors will be reported back, and cause the application to fail opening the Db */\r\n CheckRequiredUpgrades = 0,\r\n\r\n /** Domain schemas will be validated for any required or optional upgrades. Any errors will be reported back, and cause the application to fail opening the Db */\r\n CheckRecommendedUpgrades = 1,\r\n\r\n /** Domain schemas will be upgraded if necessary. However, only compatible schema upgrades will be allowed - these are typically additions of classes, properties, and changes to custom attributes */\r\n Upgrade = 2,\r\n\r\n /** Domain schemas will neither be validated nor be upgraded. Used only internally */\r\n SkipCheck = 3,\r\n}\r\n\r\n/** Options that control whether a profile upgrade should be performed when opening a Db\r\n * @beta\r\n */\r\nexport enum ProfileOptions {\r\n /** No profile upgrade will be performed. If a profile upgrade was required, opening the file will fail */\r\n None = 0,\r\n\r\n /** Profile upgrade will be performed if necessary */\r\n Upgrade = 1,\r\n}\r\n\r\n/** Arguments to validate and update the profile and domain schemas when opening a Db\r\n * @beta\r\n */\r\nexport interface UpgradeOptions {\r\n /** Option to control the validation and upgrade of domain schemas in the Db */\r\n readonly domain?: DomainOptions;\r\n\r\n /** Options that control whether a profile upgrade should be performed when opening a file */\r\n readonly profile?: ProfileOptions;\r\n\r\n /** Options that will allow data transform during Profile/Domain schema upgrade */\r\n readonly schemaLockHeld?: boolean;\r\n}\r\n\r\n/**\r\n * The state of the schemas in the Db compared with what the current version of the software expects\r\n * Note: The state may vary depending on whether the Db is to be opened ReadOnly or ReadWrite.\r\n * @beta\r\n */\r\nexport enum SchemaState {\r\n /** The schemas in the Db are up-to-date, and do not need to be upgraded before opening it with the current version of the software */\r\n UpToDate,\r\n\r\n /** It's required that the schemas in the Db be upgraded before it can be opened with the current version of the software.\r\n * This may happen in read-write scenarios where the application requires a newer version of the schemas to be in place before\r\n * it can write data based on that new schema.\r\n */\r\n UpgradeRequired,\r\n\r\n /** It's recommended, but not necessary that the schemas in the Db be upgraded before opening it with the current version of the software */\r\n UpgradeRecommended,\r\n\r\n /** The schemas in the Db are too old to be opened by the current version of the software. Upgrade using the API is not possible. */\r\n TooOld,\r\n\r\n /** The schemas in the Db are too new to be opened by the current version of the software */\r\n TooNew,\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSqlReader.d.ts","sourceRoot":"","sources":["../../src/ECSqlReader.ts"],"names":[],"mappings":"AAQA,OAAO,EACS,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAkD,WAAW,EAAE,YAAY,EAC3I,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAE3B,cAAc;AACd,qBAAa,mBAAoB,YAAW,QAAQ,CAAC,qBAAqB,CAAC;aAKtC,UAAU,EAAE,qBAAqB,EAAE;IAJtE,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,SAAS,CAA6B;gBAEX,UAAU,EAAE,qBAAqB,EAAE;IAStE,IAAW,MAAM,IAAI,MAAM,CAE1B;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE,SAAS,CAAC;IAIpE,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS;IAQ3D,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS;IAQ/D,YAAY,CAAC,IAAI,EAAE,MAAM,GA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AAC,GAAG,EAAE,CAAC;IAQtC;;;;OAIG;IACI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,aAAa,CAAC;IAIrE;;;;;;OAMG;IACU,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;CAajE"}
|
package/lib/esm/ECSqlReader.js
CHANGED
|
@@ -304,11 +304,20 @@ class ECSqlReader {
|
|
|
304
304
|
return this.getRowInternal();
|
|
305
305
|
}
|
|
306
306
|
const formattedRow = {};
|
|
307
|
+
const uniqueNames = new Map();
|
|
307
308
|
for (const prop of this._props) {
|
|
308
309
|
const propName = this._options.rowFormat === QueryRowFormat.UseJsPropertyNames ? prop.jsonName : prop.name;
|
|
309
310
|
const val = this.getRowInternal()[prop.index];
|
|
310
311
|
if (typeof val !== "undefined" && val !== null) {
|
|
311
|
-
|
|
312
|
+
let uniquePropName = propName;
|
|
313
|
+
if (uniqueNames.has(propName)) {
|
|
314
|
+
uniqueNames.set(propName, uniqueNames.get(propName) + 1);
|
|
315
|
+
uniquePropName = `${propName}_${uniqueNames.get(propName)}`;
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
uniqueNames.set(propName, 0);
|
|
319
|
+
}
|
|
320
|
+
Object.defineProperty(formattedRow, uniquePropName, {
|
|
312
321
|
value: val,
|
|
313
322
|
enumerable: true,
|
|
314
323
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSqlReader.js","sourceRoot":"","sources":["../../src/ECSqlReader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACL,YAAY,EAAsD,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAgB,mBAAmB,EACzI,cAAc,GACtC,MAAM,mBAAmB,CAAC;AAE3B,cAAc;AACd,MAAM,OAAO,mBAAmB;IAK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UAAU,CAAC,MAAM,CAAC;QAC1C,IAAI,IAAI,CAAC,YAAY,GAAG,UAAU,GAAG,CAAC,EAAE;YACtC,EAAE,IAAI,CAAC,YAAY,CAAC;SACrB;aAAM;YACL,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;YACvB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;YACtB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;SACpB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,OAAO;QAClB,MAAM,IAAI,GAAG,EAAE,CAAC;QAChB,OAAO,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE;YACxB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;SACpC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACI,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,IAAI;QACf,IAAI,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE;YACrB,OAAO;gBACL,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,IAAI,CAAC,OAAO;aACpB,CAAC;SACH;aAAM;YACL,OAAO;gBACL,IAAI,EAAE,IAAI;gBACV,KAAK,EAAE,IAAI,CAAC,OAAO;aACpB,CAAC;SACH;IACH,CAAC;;AAtVuB,0BAAc,GAAG,EAAE,AAAL,CAAM;SADjC,WAAW","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 iModels\r\n */\r\nimport { Base64EncodedString } from \"./Base64EncodedString\";\r\nimport {\r\n DbQueryError, DbQueryRequest, DbQueryResponse, DbRequestExecutor, DbRequestKind, DbResponseStatus, DbValueFormat, QueryBinder, QueryOptions, QueryOptionsBuilder,\r\n QueryPropertyMetaData, QueryRowFormat,\r\n} from \"./ConcurrentQuery\";\r\n\r\n/** @public */\r\nexport class PropertyMetaDataMap implements Iterable<QueryPropertyMetaData> {\r\n private _byPropName = new Map<string, number>();\r\n private _byJsonName = new Map<string, number>();\r\n private _byNoCase = new Map<string, number>();\r\n\r\n public constructor(public readonly properties: QueryPropertyMetaData[]) {\r\n for (const property of this.properties) {\r\n this._byPropName.set(property.name, property.index);\r\n this._byJsonName.set(property.jsonName, property.index);\r\n this._byNoCase.set(property.name.toLowerCase(), property.index);\r\n this._byNoCase.set(property.jsonName.toLowerCase(), property.index);\r\n }\r\n }\r\n\r\n public get length(): number {\r\n return this.properties.length;\r\n }\r\n\r\n public [Symbol.iterator](): Iterator<QueryPropertyMetaData, any, undefined> {\r\n return this.properties[Symbol.iterator]();\r\n }\r\n\r\n public findByName(name: string): QueryPropertyMetaData | undefined {\r\n const index = this._byPropName.get(name);\r\n if (typeof index === \"number\") {\r\n return this.properties[index];\r\n }\r\n return undefined;\r\n }\r\n\r\n public findByJsonName(name: string): QueryPropertyMetaData | undefined {\r\n const index = this._byJsonName.get(name);\r\n if (typeof index === \"number\") {\r\n return this.properties[index];\r\n }\r\n return undefined;\r\n }\r\n\r\n public findByNoCase(name: string): QueryPropertyMetaData | undefined {\r\n const index = this._byNoCase.get(name.toLowerCase());\r\n if (typeof index === \"number\") {\r\n return this.properties[index];\r\n }\r\n return undefined;\r\n }\r\n}\r\n\r\n/**\r\n * The format for rows returned by [[ECSqlReader]].\r\n * @public\r\n */\r\nexport type QueryValueType = any;\r\n\r\n/**\r\n * Methods and ways of accessing values from rows returned by [[ECSqlReader]].\r\n * @public\r\n */\r\nexport interface QueryRowProxy {\r\n /**\r\n * Get the current row as a JavaScript `object`.\r\n *\r\n * @returns The current row as a JavaScript `object`.\r\n */\r\n toRow(): any;\r\n\r\n /**\r\n * Get all remaining rows from the query result.\r\n * If called on the current row ([[ECSqlReader.current]]), only that row is returned.\r\n *\r\n * @returns All remaining rows from the query result.\r\n */\r\n toArray(): QueryValueType[];\r\n\r\n /**\r\n * Get the metadata for each column in the query result.\r\n *\r\n * @returns The metadata for each column in the query result.\r\n */\r\n getMetaData(): QueryPropertyMetaData[];\r\n\r\n /**\r\n * Access a property using its name.\r\n *\r\n * @returns The value from the row whose key (ECSQL column name) is `propertyName`.\r\n *\r\n * @example\r\n * The following lines will all return the same result:\r\n * ```ts\r\n * reader.current.ECInstanceId;\r\n * reader.current.ecinstanceid;\r\n * reader.current.[\"ECInstanceId\"];\r\n * ```\r\n */\r\n [propertyName: string]: QueryValueType;\r\n\r\n /**\r\n * Access a property using its index.\r\n * The index is relative to the order of the columns returned by the query that produced the row.\r\n *\r\n * @returns The value from the column at `propertyIndex`.\r\n *\r\n * @example reader.current[0]\r\n */\r\n [propertyIndex: number]: QueryValueType;\r\n}\r\n\r\n/**\r\n * Performance-related statistics for [[ECSqlReader]].\r\n * @public\r\n */\r\nexport interface QueryStats {\r\n /** Time spent running the query; not including time spent queued. Time is in microseconds */\r\n backendCpuTime: number;\r\n /** Total time it took the backend to run the query. Time is in milliseconds. */\r\n backendTotalTime: number;\r\n /** Estimated memory used for the query. */\r\n backendMemUsed: number;\r\n /** Total number of rows returned by the backend. */\r\n backendRowsReturned: number;\r\n /** The total round trip time from the client's perspective. Time is in milliseconds. */\r\n totalTime: number;\r\n /** The number of retries attempted to execute the query. */\r\n retryCount: number;\r\n}\r\n\r\n/**\r\n * Execute ECSQL statements and read the results.\r\n *\r\n * The query results are returned one row at a time. The format of the row is dictated by the\r\n * [[QueryOptions.rowFormat]] specified in the `options` parameter of the constructed ECSqlReader object. Defaults to\r\n * [[QueryRowFormat.UseECSqlPropertyIndexes]] when no `rowFormat` is defined.\r\n *\r\n * There are three primary ways to interact with and read the results:\r\n * - Stream them using ECSqlReader as an asynchronous iterator.\r\n * - Iterator over them manually using [[ECSqlReader.step]].\r\n * - Capture all of the results at once in an array using [[QueryRowProxy.toArray]].\r\n *\r\n * @see\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [ECSQL Row Formats]($docs/learning/ECSQLRowFormat) for more details on how rows are formatted.\r\n * - [ECSQL Code Examples]($docs/learning/ECSQLCodeExamples#iterating-over-query-results) for examples of each\r\n * of the above ways of interacting with ECSqlReader.\r\n *\r\n * @note When iterating over the results, the current row will be a [[QueryRowProxy]] object. To get the row as a basic\r\n * JavaScript object, call [[QueryRowProxy.toRow]] on it.\r\n * @public\r\n */\r\nexport class ECSqlReader implements AsyncIterableIterator<QueryRowProxy> {\r\n private static readonly _maxRetryCount = 10;\r\n\r\n private _localRows: any[] = [];\r\n private _localOffset: number = 0;\r\n private _globalOffset: number = -1;\r\n private _globalCount: number = -1;\r\n private _done: boolean = false;\r\n private _globalDone: boolean = false;\r\n private _props = new PropertyMetaDataMap([]);\r\n private _param = new QueryBinder().serialize();\r\n private _lockArgs: boolean = false;\r\n private _stats = { backendCpuTime: 0, backendTotalTime: 0, backendMemUsed: 0, backendRowsReturned: 0, totalTime: 0, retryCount: 0 };\r\n private _options: QueryOptions = new QueryOptionsBuilder().getOptions();\r\n\r\n private _rowProxy = new Proxy<ECSqlReader>(this, {\r\n get: (target: ECSqlReader, key: string | Symbol) => {\r\n if (typeof key === \"string\") {\r\n const idx = Number.parseInt(key, 10);\r\n if (!Number.isNaN(idx)) {\r\n return target.getRowInternal()[idx];\r\n }\r\n const prop = target._props.findByNoCase(key);\r\n if (prop) {\r\n return target.getRowInternal()[prop.index];\r\n }\r\n if (key === \"getMetaData\") {\r\n return () => target._props.properties;\r\n }\r\n if (key === \"toRow\") {\r\n return () => target.formatCurrentRow(true);\r\n }\r\n if (key === \"toArray\") {\r\n return () => this.getRowInternal();\r\n }\r\n }\r\n return undefined;\r\n },\r\n has: (target: ECSqlReader, p: string | symbol) => {\r\n return !target._props.findByNoCase(p as string);\r\n },\r\n ownKeys: (target: ECSqlReader) => {\r\n const keys = [];\r\n for (const prop of target._props) {\r\n keys.push(prop.name);\r\n }\r\n return keys;\r\n },\r\n });\r\n\r\n /**\r\n * @internal\r\n */\r\n public constructor(private _executor: DbRequestExecutor<DbQueryRequest, DbQueryResponse>, public readonly query: string, param?: QueryBinder, options?: QueryOptions) {\r\n if (query.trim().length === 0) {\r\n throw new Error(\"expecting non-empty ecsql statement\");\r\n }\r\n if (param) {\r\n this._param = param.serialize();\r\n }\r\n this.reset(options);\r\n }\r\n\r\n private static replaceBase64WithUint8Array(row: any) {\r\n for (const key of Object.keys(row)) {\r\n const val = row[key];\r\n if (typeof val === \"string\") {\r\n if (Base64EncodedString.hasPrefix(val)) {\r\n row[key] = Base64EncodedString.toUint8Array(val);\r\n }\r\n } else if (typeof val === \"object\" && val !== null) {\r\n this.replaceBase64WithUint8Array(val);\r\n }\r\n }\r\n }\r\n\r\n public setParams(param: QueryBinder) {\r\n if (this._lockArgs) {\r\n throw new Error(\"call resetBindings() before setting or changing parameters\");\r\n }\r\n this._param = param.serialize();\r\n }\r\n\r\n public reset(options?: QueryOptions) {\r\n if (options) {\r\n this._options = options;\r\n }\r\n this._props = new PropertyMetaDataMap([]);\r\n this._localRows = [];\r\n this._globalDone = false;\r\n this._globalOffset = 0;\r\n this._globalCount = -1;\r\n if (typeof this._options.rowFormat === \"undefined\")\r\n this._options.rowFormat = QueryRowFormat.UseECSqlPropertyIndexes;\r\n if (this._options.limit) {\r\n if (typeof this._options.limit.offset === \"number\" && this._options.limit.offset > 0)\r\n this._globalOffset = this._options.limit.offset;\r\n if (typeof this._options.limit.count === \"number\" && this._options.limit.count > 0)\r\n this._globalCount = this._options.limit.count;\r\n }\r\n this._done = false;\r\n }\r\n\r\n /**\r\n * Get the current row from the query result. The current row is the one most recently stepped-to\r\n * (by step() or during iteration).\r\n *\r\n * Each value from the row can be accessed by index or by name.\r\n *\r\n * The format of the row is dictated by the [[QueryOptions.rowFormat]] specified in the `options` parameter of the\r\n * constructed ECSqlReader object.\r\n *\r\n * @see\r\n * - [[QueryRowFormat]]\r\n * - [ECSQL Row Formats]($docs/learning/ECSQLRowFormat)\r\n *\r\n * @note The current row is be a [[QueryRowProxy]] object. To get the row as a basic JavaScript object, call\r\n * [[QueryRowProxy.toRow]] on it.\r\n *\r\n * @example\r\n * ```ts\r\n * const reader = iModel.createQueryReader(\"SELECT ECInstanceId FROM bis.Element\");\r\n * while (await reader.step()) {\r\n * // Both lines below print the same value\r\n * console.log(reader.current[0]);\r\n * console.log(reader.current.ecinstanceid);\r\n * }\r\n * ```\r\n *\r\n * @return The current row as a [[QueryRowProxy]].\r\n */\r\n public get current(): QueryRowProxy {\r\n return this._rowProxy as any;\r\n }\r\n\r\n /**\r\n * Clear all bindings.\r\n */\r\n public resetBindings() {\r\n this._param = new QueryBinder().serialize();\r\n this._lockArgs = false;\r\n }\r\n\r\n /**\r\n * Returns if there are more rows available.\r\n *\r\n * @returns `true` if all rows have been stepped through already.<br/>\r\n * `false` if there are any yet unaccessed rows.\r\n */\r\n public get done(): boolean {\r\n return this._done;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public getRowInternal(): any[] {\r\n if (this._localRows.length <= this._localOffset)\r\n throw new Error(\"no current row\");\r\n return this._localRows[this._localOffset] as any[];\r\n }\r\n\r\n /**\r\n * Get performance-related statistics for the current query.\r\n */\r\n public get stats(): QueryStats {\r\n return this._stats;\r\n }\r\n\r\n /**\r\n *\r\n */\r\n private async readRows(): Promise<any[]> {\r\n if (this._globalDone) {\r\n return [];\r\n }\r\n this._lockArgs = true;\r\n this._globalOffset += this._localRows.length;\r\n this._globalCount -= this._localRows.length;\r\n if (this._globalCount === 0) {\r\n return [];\r\n }\r\n const valueFormat = this._options.rowFormat === QueryRowFormat.UseJsPropertyNames ? DbValueFormat.JsNames : DbValueFormat.ECSqlNames;\r\n const request: DbQueryRequest = {\r\n ... this._options,\r\n kind: DbRequestKind.ECSql,\r\n valueFormat,\r\n query: this.query,\r\n args: this._param,\r\n };\r\n request.includeMetaData = this._props.length > 0 ? false : true;\r\n request.limit = { offset: this._globalOffset, count: this._globalCount < 1 ? -1 : this._globalCount };\r\n const resp = await this.runWithRetry(request);\r\n this._globalDone = resp.status === DbResponseStatus.Done;\r\n if (this._props.length === 0 && resp.meta.length > 0) {\r\n this._props = new PropertyMetaDataMap(resp.meta);\r\n }\r\n for (const row of resp.data) {\r\n ECSqlReader.replaceBase64WithUint8Array(row);\r\n }\r\n return resp.data;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected async runWithRetry(request: DbQueryRequest) {\r\n const needRetry = (rs: DbQueryResponse) => (rs.status === DbResponseStatus.Partial || rs.status === DbResponseStatus.QueueFull || rs.status === DbResponseStatus.Timeout) && (rs.data === undefined || rs.data.length === 0);\r\n const updateStats = (rs: DbQueryResponse) => {\r\n this._stats.backendCpuTime += rs.stats.cpuTime;\r\n this._stats.backendTotalTime += rs.stats.totalTime;\r\n this._stats.backendMemUsed += rs.stats.memUsed;\r\n this._stats.backendRowsReturned += (rs.data === undefined) ? 0 : rs.data.length;\r\n };\r\n const execQuery = async (req: DbQueryRequest) => {\r\n const startTime = Date.now();\r\n const rs = await this._executor.execute(req);\r\n this.stats.totalTime += (Date.now() - startTime);\r\n return rs;\r\n };\r\n let retry = ECSqlReader._maxRetryCount;\r\n let resp = await execQuery(request);\r\n DbQueryError.throwIfError(resp, request);\r\n while (--retry > 0 && needRetry(resp)) {\r\n resp = await execQuery(request);\r\n this._stats.retryCount += 1;\r\n if (needRetry(resp)) {\r\n updateStats(resp);\r\n }\r\n }\r\n if (retry === 0 && needRetry(resp)) {\r\n throw new Error(\"query too long to execute or server is too busy\");\r\n }\r\n updateStats(resp);\r\n return resp;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public formatCurrentRow(onlyReturnObject: boolean = false): any[] | object {\r\n if (!onlyReturnObject && this._options.rowFormat === QueryRowFormat.UseECSqlPropertyIndexes) {\r\n return this.getRowInternal();\r\n }\r\n const formattedRow = {};\r\n for (const prop of this._props) {\r\n const propName = this._options.rowFormat === QueryRowFormat.UseJsPropertyNames ? prop.jsonName : prop.name;\r\n const val = this.getRowInternal()[prop.index];\r\n if (typeof val !== \"undefined\" && val !== null) {\r\n Object.defineProperty(formattedRow, propName, {\r\n value: val,\r\n enumerable: true,\r\n });\r\n }\r\n }\r\n return formattedRow;\r\n }\r\n\r\n /**\r\n * Get the metadata for each column in the query result.\r\n *\r\n * @returns An array of [[QueryPropertyMetaData]].\r\n */\r\n public async getMetaData(): Promise<QueryPropertyMetaData[]> {\r\n if (this._props.length === 0) {\r\n await this.fetchRows();\r\n }\r\n return this._props.properties;\r\n }\r\n\r\n /**\r\n *\r\n */\r\n private async fetchRows() {\r\n this._localOffset = -1;\r\n this._localRows = await this.readRows();\r\n if (this._localRows.length === 0) {\r\n this._done = true;\r\n }\r\n }\r\n\r\n /**\r\n * Step to the next row of the query result.\r\n *\r\n * @returns `true` if a row can be read from `current`.<br/>\r\n * `false` if there are no more rows; i.e., all rows have been stepped through already.\r\n */\r\n public async step(): Promise<boolean> {\r\n if (this._done) {\r\n return false;\r\n }\r\n const cachedRows = this._localRows.length;\r\n if (this._localOffset < cachedRows - 1) {\r\n ++this._localOffset;\r\n } else {\r\n await this.fetchRows();\r\n this._localOffset = 0;\r\n return !this._done;\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Get all remaining rows from the query result.\r\n *\r\n * @returns An array of all remaining rows from the query result.\r\n */\r\n public async toArray(): Promise<any[]> {\r\n const rows = [];\r\n while (await this.step()) {\r\n rows.push(this.formatCurrentRow());\r\n }\r\n return rows;\r\n }\r\n\r\n /**\r\n * Accessor for using ECSqlReader as an asynchronous iterator.\r\n *\r\n * @returns An asynchronous iterator over the rows returned by the executed ECSQL query.\r\n */\r\n public [Symbol.asyncIterator](): AsyncIterableIterator<QueryRowProxy> {\r\n return this;\r\n }\r\n\r\n /**\r\n * Calls step when called as an iterator.\r\n *\r\n * Returns the row alongside a `done` boolean to indicate if there are any more rows for an iterator to step to.\r\n *\r\n * @returns An object with the keys: `value` which contains the row and `done` which contains a boolean.\r\n */\r\n public async next(): Promise<IteratorResult<QueryRowProxy, any>> {\r\n if (await this.step()) {\r\n return {\r\n done: false,\r\n value: this.current,\r\n };\r\n } else {\r\n return {\r\n done: true,\r\n value: this.current,\r\n };\r\n }\r\n }\r\n}\r\n\r\n"]}
|
|
1
|
+
{"version":3,"file":"ECSqlReader.js","sourceRoot":"","sources":["../../src/ECSqlReader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACL,YAAY,EAAsD,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAgB,mBAAmB,EACzI,cAAc,GACtC,MAAM,mBAAmB,CAAC;AAE3B,cAAc;AACd,MAAM,OAAO,mBAAmB;IAK9B,YAAmC,UAAmC;QAAnC,eAAU,GAAV,UAAU,CAAyB;QAJ9D,gBAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;QACxC,gBAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;QACxC,cAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;QAG5C,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE;YACtC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;YACpD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;YACxD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;YAChE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;SACrE;I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;SACpB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,OAAO;QAClB,MAAM,IAAI,GAAG,EAAE,CAAC;QAChB,OAAO,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE;YACxB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;SACpC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACI,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,IAAI;QACf,IAAI,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE;YACrB,OAAO;gBACL,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,IAAI,CAAC,OAAO;aACpB,CAAC;SACH;aAAM;YACL,OAAO;gBACL,IAAI,EAAE,IAAI;gBACV,KAAK,EAAE,IAAI,CAAC,OAAO;aACpB,CAAC;SACH;IACH,CAAC;;AA/VuB,0BAAc,GAAG,EAAE,AAAL,CAAM;SADjC,WAAW","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 iModels\r\n */\r\nimport { Base64EncodedString } from \"./Base64EncodedString\";\r\nimport {\r\n DbQueryError, DbQueryRequest, DbQueryResponse, DbRequestExecutor, DbRequestKind, DbResponseStatus, DbValueFormat, QueryBinder, QueryOptions, QueryOptionsBuilder,\r\n QueryPropertyMetaData, QueryRowFormat,\r\n} from \"./ConcurrentQuery\";\r\n\r\n/** @public */\r\nexport class PropertyMetaDataMap implements Iterable<QueryPropertyMetaData> {\r\n private _byPropName = new Map<string, number>();\r\n private _byJsonName = new Map<string, number>();\r\n private _byNoCase = new Map<string, number>();\r\n\r\n public constructor(public readonly properties: QueryPropertyMetaData[]) {\r\n for (const property of this.properties) {\r\n this._byPropName.set(property.name, property.index);\r\n this._byJsonName.set(property.jsonName, property.index);\r\n this._byNoCase.set(property.name.toLowerCase(), property.index);\r\n this._byNoCase.set(property.jsonName.toLowerCase(), property.index);\r\n }\r\n }\r\n\r\n public get length(): number {\r\n return this.properties.length;\r\n }\r\n\r\n public [Symbol.iterator](): Iterator<QueryPropertyMetaData, any, undefined> {\r\n return this.properties[Symbol.iterator]();\r\n }\r\n\r\n public findByName(name: string): QueryPropertyMetaData | undefined {\r\n const index = this._byPropName.get(name);\r\n if (typeof index === \"number\") {\r\n return this.properties[index];\r\n }\r\n return undefined;\r\n }\r\n\r\n public findByJsonName(name: string): QueryPropertyMetaData | undefined {\r\n const index = this._byJsonName.get(name);\r\n if (typeof index === \"number\") {\r\n return this.properties[index];\r\n }\r\n return undefined;\r\n }\r\n\r\n public findByNoCase(name: string): QueryPropertyMetaData | undefined {\r\n const index = this._byNoCase.get(name.toLowerCase());\r\n if (typeof index === \"number\") {\r\n return this.properties[index];\r\n }\r\n return undefined;\r\n }\r\n}\r\n\r\n/**\r\n * The format for rows returned by [[ECSqlReader]].\r\n * @public\r\n */\r\nexport type QueryValueType = any;\r\n\r\n/**\r\n * Methods and ways of accessing values from rows returned by [[ECSqlReader]].\r\n * @public\r\n */\r\nexport interface QueryRowProxy {\r\n /**\r\n * Get the current row as a JavaScript `object`.\r\n *\r\n * @returns The current row as a JavaScript `object`.\r\n */\r\n toRow(): any;\r\n\r\n /**\r\n * Get all remaining rows from the query result.\r\n * If called on the current row ([[ECSqlReader.current]]), only that row is returned.\r\n *\r\n * @returns All remaining rows from the query result.\r\n */\r\n toArray(): QueryValueType[];\r\n\r\n /**\r\n * Get the metadata for each column in the query result.\r\n *\r\n * @returns The metadata for each column in the query result.\r\n */\r\n getMetaData(): QueryPropertyMetaData[];\r\n\r\n /**\r\n * Access a property using its name.\r\n *\r\n * @returns The value from the row whose key (ECSQL column name) is `propertyName`.\r\n *\r\n * @example\r\n * The following lines will all return the same result:\r\n * ```ts\r\n * reader.current.ECInstanceId;\r\n * reader.current.ecinstanceid;\r\n * reader.current.[\"ECInstanceId\"];\r\n * ```\r\n */\r\n [propertyName: string]: QueryValueType;\r\n\r\n /**\r\n * Access a property using its index.\r\n * The index is relative to the order of the columns returned by the query that produced the row.\r\n *\r\n * @returns The value from the column at `propertyIndex`.\r\n *\r\n * @example reader.current[0]\r\n */\r\n [propertyIndex: number]: QueryValueType;\r\n}\r\n\r\n/**\r\n * Performance-related statistics for [[ECSqlReader]].\r\n * @public\r\n */\r\nexport interface QueryStats {\r\n /** Time spent running the query; not including time spent queued. Time is in microseconds */\r\n backendCpuTime: number;\r\n /** Total time it took the backend to run the query. Time is in milliseconds. */\r\n backendTotalTime: number;\r\n /** Estimated memory used for the query. */\r\n backendMemUsed: number;\r\n /** Total number of rows returned by the backend. */\r\n backendRowsReturned: number;\r\n /** The total round trip time from the client's perspective. Time is in milliseconds. */\r\n totalTime: number;\r\n /** The number of retries attempted to execute the query. */\r\n retryCount: number;\r\n}\r\n\r\n/**\r\n * Execute ECSQL statements and read the results.\r\n *\r\n * The query results are returned one row at a time. The format of the row is dictated by the\r\n * [[QueryOptions.rowFormat]] specified in the `options` parameter of the constructed ECSqlReader object. Defaults to\r\n * [[QueryRowFormat.UseECSqlPropertyIndexes]] when no `rowFormat` is defined.\r\n *\r\n * There are three primary ways to interact with and read the results:\r\n * - Stream them using ECSqlReader as an asynchronous iterator.\r\n * - Iterator over them manually using [[ECSqlReader.step]].\r\n * - Capture all of the results at once in an array using [[QueryRowProxy.toArray]].\r\n *\r\n * @see\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [ECSQL Row Formats]($docs/learning/ECSQLRowFormat) for more details on how rows are formatted.\r\n * - [ECSQL Code Examples]($docs/learning/ECSQLCodeExamples#iterating-over-query-results) for examples of each\r\n * of the above ways of interacting with ECSqlReader.\r\n *\r\n * @note When iterating over the results, the current row will be a [[QueryRowProxy]] object. To get the row as a basic\r\n * JavaScript object, call [[QueryRowProxy.toRow]] on it.\r\n * @public\r\n */\r\nexport class ECSqlReader implements AsyncIterableIterator<QueryRowProxy> {\r\n private static readonly _maxRetryCount = 10;\r\n\r\n private _localRows: any[] = [];\r\n private _localOffset: number = 0;\r\n private _globalOffset: number = -1;\r\n private _globalCount: number = -1;\r\n private _done: boolean = false;\r\n private _globalDone: boolean = false;\r\n private _props = new PropertyMetaDataMap([]);\r\n private _param = new QueryBinder().serialize();\r\n private _lockArgs: boolean = false;\r\n private _stats = { backendCpuTime: 0, backendTotalTime: 0, backendMemUsed: 0, backendRowsReturned: 0, totalTime: 0, retryCount: 0 };\r\n private _options: QueryOptions = new QueryOptionsBuilder().getOptions();\r\n\r\n private _rowProxy = new Proxy<ECSqlReader>(this, {\r\n get: (target: ECSqlReader, key: string | Symbol) => {\r\n if (typeof key === \"string\") {\r\n const idx = Number.parseInt(key, 10);\r\n if (!Number.isNaN(idx)) {\r\n return target.getRowInternal()[idx];\r\n }\r\n const prop = target._props.findByNoCase(key);\r\n if (prop) {\r\n return target.getRowInternal()[prop.index];\r\n }\r\n if (key === \"getMetaData\") {\r\n return () => target._props.properties;\r\n }\r\n if (key === \"toRow\") {\r\n return () => target.formatCurrentRow(true);\r\n }\r\n if (key === \"toArray\") {\r\n return () => this.getRowInternal();\r\n }\r\n }\r\n return undefined;\r\n },\r\n has: (target: ECSqlReader, p: string | symbol) => {\r\n return !target._props.findByNoCase(p as string);\r\n },\r\n ownKeys: (target: ECSqlReader) => {\r\n const keys = [];\r\n for (const prop of target._props) {\r\n keys.push(prop.name);\r\n }\r\n return keys;\r\n },\r\n });\r\n\r\n /**\r\n * @internal\r\n */\r\n public constructor(private _executor: DbRequestExecutor<DbQueryRequest, DbQueryResponse>, public readonly query: string, param?: QueryBinder, options?: QueryOptions) {\r\n if (query.trim().length === 0) {\r\n throw new Error(\"expecting non-empty ecsql statement\");\r\n }\r\n if (param) {\r\n this._param = param.serialize();\r\n }\r\n this.reset(options);\r\n }\r\n\r\n private static replaceBase64WithUint8Array(row: any) {\r\n for (const key of Object.keys(row)) {\r\n const val = row[key];\r\n if (typeof val === \"string\") {\r\n if (Base64EncodedString.hasPrefix(val)) {\r\n row[key] = Base64EncodedString.toUint8Array(val);\r\n }\r\n } else if (typeof val === \"object\" && val !== null) {\r\n this.replaceBase64WithUint8Array(val);\r\n }\r\n }\r\n }\r\n\r\n public setParams(param: QueryBinder) {\r\n if (this._lockArgs) {\r\n throw new Error(\"call resetBindings() before setting or changing parameters\");\r\n }\r\n this._param = param.serialize();\r\n }\r\n\r\n public reset(options?: QueryOptions) {\r\n if (options) {\r\n this._options = options;\r\n }\r\n this._props = new PropertyMetaDataMap([]);\r\n this._localRows = [];\r\n this._globalDone = false;\r\n this._globalOffset = 0;\r\n this._globalCount = -1;\r\n if (typeof this._options.rowFormat === \"undefined\")\r\n this._options.rowFormat = QueryRowFormat.UseECSqlPropertyIndexes;\r\n if (this._options.limit) {\r\n if (typeof this._options.limit.offset === \"number\" && this._options.limit.offset > 0)\r\n this._globalOffset = this._options.limit.offset;\r\n if (typeof this._options.limit.count === \"number\" && this._options.limit.count > 0)\r\n this._globalCount = this._options.limit.count;\r\n }\r\n this._done = false;\r\n }\r\n\r\n /**\r\n * Get the current row from the query result. The current row is the one most recently stepped-to\r\n * (by step() or during iteration).\r\n *\r\n * Each value from the row can be accessed by index or by name.\r\n *\r\n * The format of the row is dictated by the [[QueryOptions.rowFormat]] specified in the `options` parameter of the\r\n * constructed ECSqlReader object.\r\n *\r\n * @see\r\n * - [[QueryRowFormat]]\r\n * - [ECSQL Row Formats]($docs/learning/ECSQLRowFormat)\r\n *\r\n * @note The current row is be a [[QueryRowProxy]] object. To get the row as a basic JavaScript object, call\r\n * [[QueryRowProxy.toRow]] on it.\r\n *\r\n * @example\r\n * ```ts\r\n * const reader = iModel.createQueryReader(\"SELECT ECInstanceId FROM bis.Element\");\r\n * while (await reader.step()) {\r\n * // Both lines below print the same value\r\n * console.log(reader.current[0]);\r\n * console.log(reader.current.ecinstanceid);\r\n * }\r\n * ```\r\n *\r\n * @return The current row as a [[QueryRowProxy]].\r\n */\r\n public get current(): QueryRowProxy {\r\n return this._rowProxy as any;\r\n }\r\n\r\n /**\r\n * Clear all bindings.\r\n */\r\n public resetBindings() {\r\n this._param = new QueryBinder().serialize();\r\n this._lockArgs = false;\r\n }\r\n\r\n /**\r\n * Returns if there are more rows available.\r\n *\r\n * @returns `true` if all rows have been stepped through already.<br/>\r\n * `false` if there are any yet unaccessed rows.\r\n */\r\n public get done(): boolean {\r\n return this._done;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public getRowInternal(): any[] {\r\n if (this._localRows.length <= this._localOffset)\r\n throw new Error(\"no current row\");\r\n return this._localRows[this._localOffset] as any[];\r\n }\r\n\r\n /**\r\n * Get performance-related statistics for the current query.\r\n */\r\n public get stats(): QueryStats {\r\n return this._stats;\r\n }\r\n\r\n /**\r\n *\r\n */\r\n private async readRows(): Promise<any[]> {\r\n if (this._globalDone) {\r\n return [];\r\n }\r\n this._lockArgs = true;\r\n this._globalOffset += this._localRows.length;\r\n this._globalCount -= this._localRows.length;\r\n if (this._globalCount === 0) {\r\n return [];\r\n }\r\n const valueFormat = this._options.rowFormat === QueryRowFormat.UseJsPropertyNames ? DbValueFormat.JsNames : DbValueFormat.ECSqlNames;\r\n const request: DbQueryRequest = {\r\n ... this._options,\r\n kind: DbRequestKind.ECSql,\r\n valueFormat,\r\n query: this.query,\r\n args: this._param,\r\n };\r\n request.includeMetaData = this._props.length > 0 ? false : true;\r\n request.limit = { offset: this._globalOffset, count: this._globalCount < 1 ? -1 : this._globalCount };\r\n const resp = await this.runWithRetry(request);\r\n this._globalDone = resp.status === DbResponseStatus.Done;\r\n if (this._props.length === 0 && resp.meta.length > 0) {\r\n this._props = new PropertyMetaDataMap(resp.meta);\r\n }\r\n for (const row of resp.data) {\r\n ECSqlReader.replaceBase64WithUint8Array(row);\r\n }\r\n return resp.data;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected async runWithRetry(request: DbQueryRequest) {\r\n const needRetry = (rs: DbQueryResponse) => (rs.status === DbResponseStatus.Partial || rs.status === DbResponseStatus.QueueFull || rs.status === DbResponseStatus.Timeout) && (rs.data === undefined || rs.data.length === 0);\r\n const updateStats = (rs: DbQueryResponse) => {\r\n this._stats.backendCpuTime += rs.stats.cpuTime;\r\n this._stats.backendTotalTime += rs.stats.totalTime;\r\n this._stats.backendMemUsed += rs.stats.memUsed;\r\n this._stats.backendRowsReturned += (rs.data === undefined) ? 0 : rs.data.length;\r\n };\r\n const execQuery = async (req: DbQueryRequest) => {\r\n const startTime = Date.now();\r\n const rs = await this._executor.execute(req);\r\n this.stats.totalTime += (Date.now() - startTime);\r\n return rs;\r\n };\r\n let retry = ECSqlReader._maxRetryCount;\r\n let resp = await execQuery(request);\r\n DbQueryError.throwIfError(resp, request);\r\n while (--retry > 0 && needRetry(resp)) {\r\n resp = await execQuery(request);\r\n this._stats.retryCount += 1;\r\n if (needRetry(resp)) {\r\n updateStats(resp);\r\n }\r\n }\r\n if (retry === 0 && needRetry(resp)) {\r\n throw new Error(\"query too long to execute or server is too busy\");\r\n }\r\n updateStats(resp);\r\n return resp;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public formatCurrentRow(onlyReturnObject: boolean = false): any[] | object {\r\n if (!onlyReturnObject && this._options.rowFormat === QueryRowFormat.UseECSqlPropertyIndexes) {\r\n return this.getRowInternal();\r\n }\r\n const formattedRow = {};\r\n const uniqueNames = new Map<string, number>();\r\n for (const prop of this._props) {\r\n const propName = this._options.rowFormat === QueryRowFormat.UseJsPropertyNames ? prop.jsonName : prop.name;\r\n const val = this.getRowInternal()[prop.index];\r\n if (typeof val !== \"undefined\" && val !== null) {\r\n let uniquePropName = propName;\r\n if (uniqueNames.has(propName)) {\r\n uniqueNames.set(propName, uniqueNames.get(propName)! + 1);\r\n uniquePropName = `${propName}_${uniqueNames.get(propName)!}`;\r\n } else {\r\n uniqueNames.set(propName,0);\r\n }\r\n\r\n Object.defineProperty(formattedRow, uniquePropName, {\r\n value: val,\r\n enumerable: true,\r\n });\r\n }\r\n }\r\n return formattedRow;\r\n }\r\n\r\n /**\r\n * Get the metadata for each column in the query result.\r\n *\r\n * @returns An array of [[QueryPropertyMetaData]].\r\n */\r\n public async getMetaData(): Promise<QueryPropertyMetaData[]> {\r\n if (this._props.length === 0) {\r\n await this.fetchRows();\r\n }\r\n return this._props.properties;\r\n }\r\n\r\n /**\r\n *\r\n */\r\n private async fetchRows() {\r\n this._localOffset = -1;\r\n this._localRows = await this.readRows();\r\n if (this._localRows.length === 0) {\r\n this._done = true;\r\n }\r\n }\r\n\r\n /**\r\n * Step to the next row of the query result.\r\n *\r\n * @returns `true` if a row can be read from `current`.<br/>\r\n * `false` if there are no more rows; i.e., all rows have been stepped through already.\r\n */\r\n public async step(): Promise<boolean> {\r\n if (this._done) {\r\n return false;\r\n }\r\n const cachedRows = this._localRows.length;\r\n if (this._localOffset < cachedRows - 1) {\r\n ++this._localOffset;\r\n } else {\r\n await this.fetchRows();\r\n this._localOffset = 0;\r\n return !this._done;\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Get all remaining rows from the query result.\r\n *\r\n * @returns An array of all remaining rows from the query result.\r\n */\r\n public async toArray(): Promise<any[]> {\r\n const rows = [];\r\n while (await this.step()) {\r\n rows.push(this.formatCurrentRow());\r\n }\r\n return rows;\r\n }\r\n\r\n /**\r\n * Accessor for using ECSqlReader as an asynchronous iterator.\r\n *\r\n * @returns An asynchronous iterator over the rows returned by the executed ECSQL query.\r\n */\r\n public [Symbol.asyncIterator](): AsyncIterableIterator<QueryRowProxy> {\r\n return this;\r\n }\r\n\r\n /**\r\n * Calls step when called as an iterator.\r\n *\r\n * Returns the row alongside a `done` boolean to indicate if there are any more rows for an iterator to step to.\r\n *\r\n * @returns An object with the keys: `value` which contains the row and `done` which contains a boolean.\r\n */\r\n public async next(): Promise<IteratorResult<QueryRowProxy, any>> {\r\n if (await this.step()) {\r\n return {\r\n done: false,\r\n value: this.current,\r\n };\r\n } else {\r\n return {\r\n done: true,\r\n value: this.current,\r\n };\r\n }\r\n }\r\n}\r\n\r\n"]}
|