@itwin/core-backend 4.10.0-dev.10 → 4.10.0-dev.11

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.
@@ -94,7 +94,7 @@ export declare namespace BlobContainer {
94
94
  */
95
95
  type RequestAccessLevel = "write" | "read" | "admin" | "writeIfPossible";
96
96
  /** Information required to request an access token for a container. */
97
- interface RequestTokenProps extends AccessContainerProps {
97
+ interface RequestTokenProps extends Omit<AccessContainerProps, "baseUri"> {
98
98
  /** the level of access requested. If not specified, defaults to `"writeIfPossible"`. */
99
99
  accessLevel?: RequestAccessLevel;
100
100
  /** the number of seconds before the token should expire.
@@ -1 +1 @@
1
- {"version":3,"file":"BlobContainerService.d.ts","sourceRoot":"","sources":["../../src/BlobContainerService.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;GAGG;AACH,yBAAiB,aAAa,CAAC;IAE7B,+FAA+F;IACxF,IAAI,OAAO,EAAE,aAAa,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAE/D,8CAA8C;IAC9C,KAAY,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IAE1C,mDAAmD;IACnD,KAAY,WAAW,GAAG,MAAM,CAAC;IAEjC,4FAA4F;IAC5F,KAAY,SAAS,GAAG,WAAW,CAAC;IAEpC,+EAA+E;IAC/E,KAAY,cAAc,GAAG,WAAW,CAAC;IAEzC;;;;;;;;OAQG;IACH,UAAiB,KAAK;QACpB,8CAA8C;QAC9C,OAAO,EAAE,UAAU,CAAC;QACpB,6GAA6G;QAC7G,QAAQ,CAAC,EAAE,UAAU,CAAC;QACtB,iEAAiE;QACjE,SAAS,CAAC,EAAE,UAAU,CAAC;KACxB;IAED;;;;;;OAMG;IACH,UAAiB,QAAQ;QACvB,y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,WAAW,CAAC,EAAE,kBAAkB,CAAC;QACjC;;WAEG;QACH,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B;IAED,sDAAsD;IACtD,UAAiB,uBAAuB;QACtC,qCAAqC;QACrC,KAAK,EAAE,KAAK,CAAC;QACb,iDAAiD;QACjD,QAAQ,EAAE,QAAQ,CAAC;QACnB,4GAA4G;QAC5G,SAAS,EAAE,SAAS,CAAC;QACrB;;;WAGG;QACH,WAAW,CAAC,EAAE,WAAW,CAAC;KAC3B;IAED,6DAA6D;IAC7D,UAAiB,gBAAgB;QAC/B,wGAAwG;QACxG,MAAM,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;QAEvE;;;WAGG;QACH,MAAM,CAAC,SAAS,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAEvD,sCAAsC;QACtC,UAAU,CAAC,SAAS,EAAE,oBAAoB,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAE5D,yCAAyC;QACzC,aAAa,CAAC,SAAS,EAAE,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAElE,mDAAmD;QACnD,UAAU,CAAC,SAAS,EAAE,oBAAoB,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAEpF,qEAAqE;QACrE,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;KAC7D;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"BlobContainerService.js","sourceRoot":"","sources":["../../src/BlobContainerService.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAOH;;;GAGG;AACH,IAAiB,aAAa,CAmJ7B;AAnJD,WAAiB,aAAa;AAmJ9B,CAAC,EAnJgB,aAAa,6BAAb,aAAa,QAmJ7B","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 BlobContainers\r\n */\r\n\r\n// spell:ignore datacenter\r\n\r\nimport { AccessToken, GuidString, Id64String } from \"@itwin/core-bentley\";\r\nimport { SettingsContainer } from \"./workspace/Settings\";\r\n\r\n/**\r\n * Types and functions for creating, deleting and authorizing access to cloud-based blob containers for an iTwin.\r\n * @beta\r\n */\r\nexport namespace BlobContainer {\r\n\r\n /** Object that implements the methods to create, delete, and request access to a container. */\r\n export let service: BlobContainer.ContainerService | undefined;\r\n\r\n /** name of cloud provider for a container. */\r\n export type Provider = \"azure\" | \"google\";\r\n\r\n /** the name of the container within its `Scope` */\r\n export type ContainerId = string;\r\n\r\n /** token that authenticates a user. This token is required to obtain a `ContainerToken`. */\r\n export type UserToken = AccessToken;\r\n\r\n /** token that authenticates access to a container for either read or write. */\r\n export type ContainerToken = AccessToken;\r\n\r\n /**\r\n * The scope for a container. This determines:\r\n * - the \"owner\" organization, including the contract that governs its legal and commercial terms and obligations\r\n * - the administrators who may configure RBAC permissions\r\n * - the datacenter for the container. Every container resides in a datacenter as determined by the iTwinId. This\r\n * determines the region for data residency requirements.\r\n * - the lifecycle constraints for the container. No container can outlive its iTwin or its iModel (if defined). That is,\r\n * when the iTwin/iModel is deleted (either explicitly or due to contract expiration), the container is also deleted.\r\n */\r\n export interface Scope {\r\n /** iTwinId of the owner of this container. */\r\n iTwinId: Id64String;\r\n /** optionally, an iModelId within the iTwin. If present, container is deleted when the iModel is deleted. */\r\n iModelId?: Id64String;\r\n /** the user GUID an individual, if this container is private. */\r\n ownerGuid?: GuidString;\r\n }\r\n\r\n /**\r\n * Metadata about the use of a container so that:\r\n * - administrators can understand why a container exists for assigning RBAC permissions appropriately\r\n * - usage reports can aggregate types of containers\r\n * - applications can identify their containers\r\n * - applications can store properties about their containers\r\n */\r\n export interface Metadata {\r\n /** The machine-readable string that describes what the container is being used for (e.g. \"workspace\"). Always lowercase and singular. */\r\n containerType: string;\r\n /** Human-readable name for the container. This will be displayed in the administrator RBAC panel, and on usage reports. Not required to be unique.*/\r\n label: string;\r\n /** Optional human-readable explanation of the information held in the container. This will be displayed in the administrator RBAC panel, and on usage reports. */\r\n description?: string;\r\n /** optional properties for the container */\r\n json?: SettingsContainer;\r\n }\r\n\r\n /** Properties returned by `Service.requestToken` */\r\n export interface TokenProps {\r\n /**\r\n * expiring token that provides the requested access to the container. Should be used in all subsequent requests for blobs within the container,\r\n * and must be refreshed before it expires\r\n */\r\n token: ContainerToken;\r\n /** scope of the container. */\r\n scope: Scope;\r\n /** name of the blob storage provider. */\r\n provider: Provider;\r\n /** Time at which the token will expire. The token should be refreshed (that is, a new token should be requested) before this time. */\r\n expiration: Date;\r\n /** Metadata of the container. */\r\n metadata: Metadata;\r\n /** Base URI of container */\r\n baseUri: string;\r\n }\r\n\r\n /** The URI and Id of the container. */\r\n export interface UriAndId {\r\n baseUri: string;\r\n containerId: ContainerId;\r\n }\r\n\r\n /** Information required to access an existing container. */\r\n export interface AccessContainerProps extends UriAndId {\r\n userToken: UserToken;\r\n }\r\n\r\n /** Information about a newly created container. */\r\n export interface CreatedContainerProps extends UriAndId {\r\n /** name of the blob storage provider. */\r\n provider: Provider;\r\n }\r\n\r\n /**\r\n * Access level to request for token.\r\n * - `\"write\"`: request a writeable AccessToken.\r\n * - `\"read\"`: request a read-only AccessToken.\r\n * - `\"admin\"`: request a admin AccessToken.\r\n * - `\"writeIfPossible\"`: first request a writeable AccessToken. If the user is not authorized for write, request a read-only AccessToken.\r\n * If the user is not authorized for the level requested, an exception is thrown.\r\n */\r\n export type RequestAccessLevel = \"write\" | \"read\" | \"admin\" | \"writeIfPossible\";\r\n\r\n /** Information required to request an access token for a container. */\r\n export interface RequestTokenProps extends AccessContainerProps {\r\n /** the level of access requested. If not specified, defaults to `\"writeIfPossible\"`. */\r\n accessLevel?: RequestAccessLevel;\r\n /** the number of seconds before the token should expire.\r\n * @note A maximum duration is determined by the service. If no value is supplied, or the value is larger than the maximum, the maximum duration is used.\r\n */\r\n durationSeconds?: number;\r\n }\r\n\r\n /** Information required to create a new container. */\r\n export interface CreateNewContainerProps {\r\n /** the scope of the new container */\r\n scope: Scope;\r\n /** metadata to be stored on the new container */\r\n metadata: Metadata;\r\n /** The user's access token. The user must be authorized with \"create container\" RBAC role for the iTwin. */\r\n userToken: UserToken;\r\n /**\r\n * the id for the container. Useful for tests.\r\n * @internal\r\n */\r\n containerId?: ContainerId;\r\n }\r\n\r\n /** Methods to create, delete, and access blob containers. */\r\n export interface ContainerService {\r\n /** Create a new blob container. Throws on failure (e.g. access denied or container already exists.) */\r\n create(props: CreateNewContainerProps): Promise<CreatedContainerProps>;\r\n\r\n /**\r\n * Delete an existing blob container.\r\n * @note This method requires that the user be authorized with \"delete container\" RBAC role for the iTwin.\r\n */\r\n delete(container: AccessContainerProps): Promise<void>;\r\n\r\n /** query the Scope for a container */\r\n queryScope(container: AccessContainerProps): Promise<Scope>;\r\n\r\n /** query the Metadata for a container */\r\n queryMetadata(container: AccessContainerProps): Promise<Metadata>;\r\n\r\n /** update the json properties of this container */\r\n updateJson(container: AccessContainerProps, json: SettingsContainer): Promise<void>;\r\n\r\n /** Request a `ContainerToken` for a container. Throws on failure. */\r\n requestToken(props: RequestTokenProps): Promise<TokenProps>;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"BlobContainerService.js","sourceRoot":"","sources":["../../src/BlobContainerService.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAOH;;;GAGG;AACH,IAAiB,aAAa,CAmJ7B;AAnJD,WAAiB,aAAa;AAmJ9B,CAAC,EAnJgB,aAAa,6BAAb,aAAa,QAmJ7B","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 BlobContainers\r\n */\r\n\r\n// spell:ignore datacenter\r\n\r\nimport { AccessToken, GuidString, Id64String } from \"@itwin/core-bentley\";\r\nimport { SettingsContainer } from \"./workspace/Settings\";\r\n\r\n/**\r\n * Types and functions for creating, deleting and authorizing access to cloud-based blob containers for an iTwin.\r\n * @beta\r\n */\r\nexport namespace BlobContainer {\r\n\r\n /** Object that implements the methods to create, delete, and request access to a container. */\r\n export let service: BlobContainer.ContainerService | undefined;\r\n\r\n /** name of cloud provider for a container. */\r\n export type Provider = \"azure\" | \"google\";\r\n\r\n /** the name of the container within its `Scope` */\r\n export type ContainerId = string;\r\n\r\n /** token that authenticates a user. This token is required to obtain a `ContainerToken`. */\r\n export type UserToken = AccessToken;\r\n\r\n /** token that authenticates access to a container for either read or write. */\r\n export type ContainerToken = AccessToken;\r\n\r\n /**\r\n * The scope for a container. This determines:\r\n * - the \"owner\" organization, including the contract that governs its legal and commercial terms and obligations\r\n * - the administrators who may configure RBAC permissions\r\n * - the datacenter for the container. Every container resides in a datacenter as determined by the iTwinId. This\r\n * determines the region for data residency requirements.\r\n * - the lifecycle constraints for the container. No container can outlive its iTwin or its iModel (if defined). That is,\r\n * when the iTwin/iModel is deleted (either explicitly or due to contract expiration), the container is also deleted.\r\n */\r\n export interface Scope {\r\n /** iTwinId of the owner of this container. */\r\n iTwinId: Id64String;\r\n /** optionally, an iModelId within the iTwin. If present, container is deleted when the iModel is deleted. */\r\n iModelId?: Id64String;\r\n /** the user GUID an individual, if this container is private. */\r\n ownerGuid?: GuidString;\r\n }\r\n\r\n /**\r\n * Metadata about the use of a container so that:\r\n * - administrators can understand why a container exists for assigning RBAC permissions appropriately\r\n * - usage reports can aggregate types of containers\r\n * - applications can identify their containers\r\n * - applications can store properties about their containers\r\n */\r\n export interface Metadata {\r\n /** The machine-readable string that describes what the container is being used for (e.g. \"workspace\"). Always lowercase and singular. */\r\n containerType: string;\r\n /** Human-readable name for the container. This will be displayed in the administrator RBAC panel, and on usage reports. Not required to be unique.*/\r\n label: string;\r\n /** Optional human-readable explanation of the information held in the container. This will be displayed in the administrator RBAC panel, and on usage reports. */\r\n description?: string;\r\n /** optional properties for the container */\r\n json?: SettingsContainer;\r\n }\r\n\r\n /** Properties returned by `Service.requestToken` */\r\n export interface TokenProps {\r\n /**\r\n * expiring token that provides the requested access to the container. Should be used in all subsequent requests for blobs within the container,\r\n * and must be refreshed before it expires\r\n */\r\n token: ContainerToken;\r\n /** scope of the container. */\r\n scope: Scope;\r\n /** name of the blob storage provider. */\r\n provider: Provider;\r\n /** Time at which the token will expire. The token should be refreshed (that is, a new token should be requested) before this time. */\r\n expiration: Date;\r\n /** Metadata of the container. */\r\n metadata: Metadata;\r\n /** Base URI of container */\r\n baseUri: string;\r\n }\r\n\r\n /** The URI and Id of the container. */\r\n export interface UriAndId {\r\n baseUri: string;\r\n containerId: ContainerId;\r\n }\r\n\r\n /** Information required to access an existing container. */\r\n export interface AccessContainerProps extends UriAndId {\r\n userToken: UserToken;\r\n }\r\n\r\n /** Information about a newly created container. */\r\n export interface CreatedContainerProps extends UriAndId {\r\n /** name of the blob storage provider. */\r\n provider: Provider;\r\n }\r\n\r\n /**\r\n * Access level to request for token.\r\n * - `\"write\"`: request a writeable AccessToken.\r\n * - `\"read\"`: request a read-only AccessToken.\r\n * - `\"admin\"`: request a admin AccessToken.\r\n * - `\"writeIfPossible\"`: first request a writeable AccessToken. If the user is not authorized for write, request a read-only AccessToken.\r\n * If the user is not authorized for the level requested, an exception is thrown.\r\n */\r\n export type RequestAccessLevel = \"write\" | \"read\" | \"admin\" | \"writeIfPossible\";\r\n\r\n /** Information required to request an access token for a container. */\r\n export interface RequestTokenProps extends Omit<AccessContainerProps,\"baseUri\"> {\r\n /** the level of access requested. If not specified, defaults to `\"writeIfPossible\"`. */\r\n accessLevel?: RequestAccessLevel;\r\n /** the number of seconds before the token should expire.\r\n * @note A maximum duration is determined by the service. If no value is supplied, or the value is larger than the maximum, the maximum duration is used.\r\n */\r\n durationSeconds?: number;\r\n }\r\n\r\n /** Information required to create a new container. */\r\n export interface CreateNewContainerProps {\r\n /** the scope of the new container */\r\n scope: Scope;\r\n /** metadata to be stored on the new container */\r\n metadata: Metadata;\r\n /** The user's access token. The user must be authorized with \"create container\" RBAC role for the iTwin. */\r\n userToken: UserToken;\r\n /**\r\n * the id for the container. Useful for tests.\r\n * @internal\r\n */\r\n containerId?: ContainerId;\r\n }\r\n\r\n /** Methods to create, delete, and access blob containers. */\r\n export interface ContainerService {\r\n /** Create a new blob container. Throws on failure (e.g. access denied or container already exists.) */\r\n create(props: CreateNewContainerProps): Promise<CreatedContainerProps>;\r\n\r\n /**\r\n * Delete an existing blob container.\r\n * @note This method requires that the user be authorized with \"delete container\" RBAC role for the iTwin.\r\n */\r\n delete(container: AccessContainerProps): Promise<void>;\r\n\r\n /** query the Scope for a container */\r\n queryScope(container: AccessContainerProps): Promise<Scope>;\r\n\r\n /** query the Metadata for a container */\r\n queryMetadata(container: AccessContainerProps): Promise<Metadata>;\r\n\r\n /** update the json properties of this container */\r\n updateJson(container: AccessContainerProps, json: SettingsContainer): Promise<void>;\r\n\r\n /** Request a `ContainerToken` for a container. Throws on failure. */\r\n requestToken(props: RequestTokenProps): Promise<TokenProps>;\r\n }\r\n}\r\n"]}
@@ -130,7 +130,7 @@ function logResponse(request, statusCode, resultObj) {
130
130
  path: request.path,
131
131
  operation: request.operation,
132
132
  statusCode,
133
- errorObj: resultObj instanceof Error ? resultObj : undefined,
133
+ errorObj: resultObj instanceof Error ? core_bentley_1.BentleyError.getErrorProps(resultObj) : undefined,
134
134
  };
135
135
  if (statusCode < 400)
136
136
  core_bentley_1.Logger.logInfo(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, "RPC over HTTP success response", metadata);
@@ -1 +1 @@
1
- {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/rpc/web/response.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;A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CAAC,CAAC;IAE/B,IAAI,WAAW,CAAC,gBAAgB;QAC9B,YAAY,GAAG,MAAM,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;IAEjE,6GAA6G;IAC7G,iCAAiC;IACjC,IAAI,YAAY,YAAY,oBAAM,EAAE,CAAC;QACnC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACzB,CAAC;AACH,CAAC;AAjCD,oCAiCC;AAED,SAAS,WAAW,CAAC,OAA6B,EAAE,UAAkB,EAAE,SAAkB;IACxF,MAAM,QAAQ,GAAG;QACf,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,2DAA2D;QACnF,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,UAAU;QACV,QAAQ,EAAE,SAAS,YAAY,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;KAC7D,CAAC;IAEF,IAAI,UAAU,GAAG,GAAG;QAClB,qBAAM,CAAC,OAAO,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,gCAAgC,EAAE,QAAQ,CAAC,CAAC;;QAErG,qBAAM,CAAC,QAAQ,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,gCAAgC,EAAE,QAAQ,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n CommonLoggerCategory,\r\n HttpServerRequest,\r\n HttpServerResponse,\r\n ReadableFormData,\r\n RpcContentType,\r\n RpcMultipart,\r\n RpcProtocol,\r\n RpcRequestFulfillment,\r\n RpcRequestStatus,\r\n RpcResponseCacheControl,\r\n SerializedRpcRequest,\r\n WEB_RPC_CONSTANTS,\r\n WebAppRpcProtocol,\r\n WebAppRpcRequest,\r\n} from \"@itwin/core-common\";\r\n\r\nimport { Readable, Stream } from \"node:stream\";\r\nimport { promisify } from \"node:util\";\r\nimport { brotliCompress, BrotliOptions, createBrotliCompress, createGzip, gzip, constants as zlibConstants } from \"node:zlib\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nfunction configureResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse) {\r\n const success = protocol.getStatus(fulfillment.status) === RpcRequestStatus.Resolved;\r\n // TODO: Use stale-while-revalidate in cache headers. This needs to be tested, and does not currently have support in the router/caching-service.\r\n // This will allow browsers to use stale cached responses while also revalidating with the router, allowing us to start up a backend if necessary.\r\n\r\n // RPC Caching Service uses the s-maxage header to determine the TTL for the redis cache.\r\n const oneHourInSeconds = 3600;\r\n if (success && request.caching === RpcResponseCacheControl.Immutable) {\r\n // If response size is > 50 MB, do not cache it.\r\n if (fulfillment.result.objects.length > (50 * 10 ** 7)) {\r\n res.set(\"Cache-Control\", \"no-store\");\r\n } else if (request.operation.operationName === \"generateTileContent\") {\r\n res.set(\"Cache-Control\", \"no-store\");\r\n } else if (request.operation.operationName === \"getConnectionProps\") {\r\n // GetConnectionprops can't be cached on the browser longer than the lifespan of the backend. The lifespan of backend may shrink too. Keep it at 1 second to be safe.\r\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 24}, max-age=1, immutable`);\r\n } else if (request.operation.operationName === \"getTileCacheContainerUrl\") {\r\n // getTileCacheContainerUrl returns a SAS with an expiry of 23:59:59. We can't exceed that time when setting the max-age.\r\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 23}, max-age=${oneHourInSeconds * 23}, immutable`);\r\n } else {\r\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 24}, max-age=${oneHourInSeconds * 48}, immutable`);\r\n }\r\n }\r\n\r\n if (fulfillment.retry) {\r\n res.set(\"Retry-After\", fulfillment.retry);\r\n }\r\n}\r\n\r\nfunction configureText(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): string {\r\n res.set(WEB_RPC_CONSTANTS.CONTENT, WEB_RPC_CONSTANTS.TEXT);\r\n return (fulfillment.status === 204) ? \"\" : fulfillment.result.objects;\r\n}\r\n\r\nfunction configureBinary(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): Buffer {\r\n res.set(WEB_RPC_CONSTANTS.CONTENT, WEB_RPC_CONSTANTS.BINARY);\r\n const data = fulfillment.result.data[0];\r\n return Buffer.isBuffer(data) ? data : Buffer.from(data);\r\n}\r\n\r\nfunction configureMultipart(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): ReadableFormData {\r\n const response = RpcMultipart.createStream(fulfillment.result);\r\n const headers = response.getHeaders();\r\n for (const header in headers) {\r\n if (headers.hasOwnProperty(header)) {\r\n res.set(header, headers[header]);\r\n }\r\n }\r\n\r\n return response;\r\n}\r\n\r\nfunction configureStream(fulfillment: RpcRequestFulfillment) {\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n return fulfillment.result.stream!;\r\n}\r\n\r\nasync function configureEncoding(req: HttpServerRequest, res: HttpServerResponse, responseBody: string | Buffer | Readable): Promise<string | Buffer | Readable> {\r\n const acceptedEncodings = req.header(\"Accept-Encoding\")?.split(\",\").map((value) => value.trim());\r\n if (!acceptedEncodings)\r\n return responseBody;\r\n\r\n const encoding = acceptedEncodings.includes(\"br\") ? \"br\" : acceptedEncodings.includes(\"gzip\") ? \"gzip\" : undefined;\r\n if (!encoding)\r\n return responseBody;\r\n\r\n res.set(\"Content-Encoding\", encoding);\r\n\r\n const brotliOptions: BrotliOptions = {\r\n params: {\r\n // Experimentation revealed that the default compression quality significantly increases the compression time for larger texts.\r\n // Reducing the quality improves speed substantially without a significant loss in the compression ratio.\r\n [zlibConstants.BROTLI_PARAM_QUALITY]: 3,\r\n },\r\n };\r\n\r\n if (responseBody instanceof Stream) {\r\n const compressStream = encoding === \"br\" ? createBrotliCompress(brotliOptions) : createGzip();\r\n return responseBody.pipe(compressStream);\r\n }\r\n\r\n return encoding === \"br\" ? promisify(brotliCompress)(responseBody, brotliOptions) : promisify(gzip)(responseBody);\r\n}\r\n\r\n/** @internal */\r\nexport async function sendResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, req: HttpServerRequest, res: HttpServerResponse) {\r\n logResponse(request, fulfillment.status, fulfillment.rawResult);\r\n\r\n const versionHeader = protocol.protocolVersionHeaderName;\r\n if (versionHeader && RpcProtocol.protocolVersion) {\r\n res.set(versionHeader, RpcProtocol.protocolVersion.toString());\r\n }\r\n\r\n const transportType = WebAppRpcRequest.computeTransportType(fulfillment.result, fulfillment.rawResult);\r\n let responseBody;\r\n if (transportType === RpcContentType.Binary) {\r\n responseBody = configureBinary(fulfillment, res);\r\n } else if (transportType === RpcContentType.Multipart) {\r\n responseBody = configureMultipart(fulfillment, res);\r\n } else if (transportType === RpcContentType.Stream) {\r\n responseBody = configureStream(fulfillment);\r\n } else {\r\n responseBody = configureText(fulfillment, res);\r\n }\r\n\r\n configureResponse(protocol, request, fulfillment, res);\r\n res.status(fulfillment.status);\r\n\r\n if (fulfillment.allowCompression)\r\n responseBody = await configureEncoding(req, res, responseBody);\r\n\r\n // This check should in theory look for instances of Readable, but that would break backend implementation at\r\n // core/backend/src/RpcBackend.ts\r\n if (responseBody instanceof Stream) {\r\n responseBody.pipe(res);\r\n } else {\r\n res.send(responseBody);\r\n }\r\n}\r\n\r\nfunction logResponse(request: SerializedRpcRequest, statusCode: number, resultObj: unknown) {\r\n const metadata = {\r\n ActivityId: request.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n method: request.method,\r\n path: request.path,\r\n operation: request.operation,\r\n statusCode,\r\n errorObj: resultObj instanceof Error ? resultObj : undefined,\r\n };\r\n\r\n if (statusCode < 400)\r\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceBackend, \"RPC over HTTP success response\", metadata);\r\n else\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, \"RPC over HTTP failure response\", metadata);\r\n}\r\n"]}
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/rpc/web/response.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2D;AAC3D,oDAe4B;AAE5B,6CAA+C;AAC/C,yCAAsC;AACtC,yCAA8H;AAE9H,4CAA4C;AAE5C,SAAS,iBAAiB,CAAC,QAA2B,EAAE,OAA6B,EAAE,WAAkC,EAAE,GAAuB;IAChJ,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,8BAAgB,CAAC,QAAQ,CAAC;IACrF,iJAAiJ;IACjJ,kJAAkJ;IAElJ,yFAAyF;IACzF,MAAM,gBAAgB,GAAG,IAAI,CAAC;IAC9B,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,KAAK,qCAAuB,CAAC,SAAS,EAAE,CAAC;QACrE,gDAAgD;QAChD,IAAI,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;YACvD,GAAG,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;QACvC,CAAC;aAAM,IAAI,OAAO,CAAC,SAAS,CAAC,aAAa,KAAK,qBAAqB,EAAE,CAAC;YACrE,GAAG,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;QACvC,CAAC;aAAM,IAAI,OAAO,CAAC,SAAS,CAAC,aAAa,KAAK,oBAAoB,EAAE,CAAC;YACpE,qKAAqK;YACrK,GAAG,CAAC,GAAG,CAAC,eAAe,EAA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CAAC,kCAAoB,CAAC,mBAAmB,EAAE,gCAAgC,EAAE,QAAQ,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyError, Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n CommonLoggerCategory,\r\n HttpServerRequest,\r\n HttpServerResponse,\r\n ReadableFormData,\r\n RpcContentType,\r\n RpcMultipart,\r\n RpcProtocol,\r\n RpcRequestFulfillment,\r\n RpcRequestStatus,\r\n RpcResponseCacheControl,\r\n SerializedRpcRequest,\r\n WEB_RPC_CONSTANTS,\r\n WebAppRpcProtocol,\r\n WebAppRpcRequest,\r\n} from \"@itwin/core-common\";\r\n\r\nimport { Readable, Stream } from \"node:stream\";\r\nimport { promisify } from \"node:util\";\r\nimport { brotliCompress, BrotliOptions, createBrotliCompress, createGzip, gzip, constants as zlibConstants } from \"node:zlib\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nfunction configureResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse) {\r\n const success = protocol.getStatus(fulfillment.status) === RpcRequestStatus.Resolved;\r\n // TODO: Use stale-while-revalidate in cache headers. This needs to be tested, and does not currently have support in the router/caching-service.\r\n // This will allow browsers to use stale cached responses while also revalidating with the router, allowing us to start up a backend if necessary.\r\n\r\n // RPC Caching Service uses the s-maxage header to determine the TTL for the redis cache.\r\n const oneHourInSeconds = 3600;\r\n if (success && request.caching === RpcResponseCacheControl.Immutable) {\r\n // If response size is > 50 MB, do not cache it.\r\n if (fulfillment.result.objects.length > (50 * 10 ** 7)) {\r\n res.set(\"Cache-Control\", \"no-store\");\r\n } else if (request.operation.operationName === \"generateTileContent\") {\r\n res.set(\"Cache-Control\", \"no-store\");\r\n } else if (request.operation.operationName === \"getConnectionProps\") {\r\n // GetConnectionprops can't be cached on the browser longer than the lifespan of the backend. The lifespan of backend may shrink too. Keep it at 1 second to be safe.\r\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 24}, max-age=1, immutable`);\r\n } else if (request.operation.operationName === \"getTileCacheContainerUrl\") {\r\n // getTileCacheContainerUrl returns a SAS with an expiry of 23:59:59. We can't exceed that time when setting the max-age.\r\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 23}, max-age=${oneHourInSeconds * 23}, immutable`);\r\n } else {\r\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 24}, max-age=${oneHourInSeconds * 48}, immutable`);\r\n }\r\n }\r\n\r\n if (fulfillment.retry) {\r\n res.set(\"Retry-After\", fulfillment.retry);\r\n }\r\n}\r\n\r\nfunction configureText(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): string {\r\n res.set(WEB_RPC_CONSTANTS.CONTENT, WEB_RPC_CONSTANTS.TEXT);\r\n return (fulfillment.status === 204) ? \"\" : fulfillment.result.objects;\r\n}\r\n\r\nfunction configureBinary(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): Buffer {\r\n res.set(WEB_RPC_CONSTANTS.CONTENT, WEB_RPC_CONSTANTS.BINARY);\r\n const data = fulfillment.result.data[0];\r\n return Buffer.isBuffer(data) ? data : Buffer.from(data);\r\n}\r\n\r\nfunction configureMultipart(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): ReadableFormData {\r\n const response = RpcMultipart.createStream(fulfillment.result);\r\n const headers = response.getHeaders();\r\n for (const header in headers) {\r\n if (headers.hasOwnProperty(header)) {\r\n res.set(header, headers[header]);\r\n }\r\n }\r\n\r\n return response;\r\n}\r\n\r\nfunction configureStream(fulfillment: RpcRequestFulfillment) {\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n return fulfillment.result.stream!;\r\n}\r\n\r\nasync function configureEncoding(req: HttpServerRequest, res: HttpServerResponse, responseBody: string | Buffer | Readable): Promise<string | Buffer | Readable> {\r\n const acceptedEncodings = req.header(\"Accept-Encoding\")?.split(\",\").map((value) => value.trim());\r\n if (!acceptedEncodings)\r\n return responseBody;\r\n\r\n const encoding = acceptedEncodings.includes(\"br\") ? \"br\" : acceptedEncodings.includes(\"gzip\") ? \"gzip\" : undefined;\r\n if (!encoding)\r\n return responseBody;\r\n\r\n res.set(\"Content-Encoding\", encoding);\r\n\r\n const brotliOptions: BrotliOptions = {\r\n params: {\r\n // Experimentation revealed that the default compression quality significantly increases the compression time for larger texts.\r\n // Reducing the quality improves speed substantially without a significant loss in the compression ratio.\r\n [zlibConstants.BROTLI_PARAM_QUALITY]: 3,\r\n },\r\n };\r\n\r\n if (responseBody instanceof Stream) {\r\n const compressStream = encoding === \"br\" ? createBrotliCompress(brotliOptions) : createGzip();\r\n return responseBody.pipe(compressStream);\r\n }\r\n\r\n return encoding === \"br\" ? promisify(brotliCompress)(responseBody, brotliOptions) : promisify(gzip)(responseBody);\r\n}\r\n\r\n/** @internal */\r\nexport async function sendResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, req: HttpServerRequest, res: HttpServerResponse) {\r\n logResponse(request, fulfillment.status, fulfillment.rawResult);\r\n\r\n const versionHeader = protocol.protocolVersionHeaderName;\r\n if (versionHeader && RpcProtocol.protocolVersion) {\r\n res.set(versionHeader, RpcProtocol.protocolVersion.toString());\r\n }\r\n\r\n const transportType = WebAppRpcRequest.computeTransportType(fulfillment.result, fulfillment.rawResult);\r\n let responseBody;\r\n if (transportType === RpcContentType.Binary) {\r\n responseBody = configureBinary(fulfillment, res);\r\n } else if (transportType === RpcContentType.Multipart) {\r\n responseBody = configureMultipart(fulfillment, res);\r\n } else if (transportType === RpcContentType.Stream) {\r\n responseBody = configureStream(fulfillment);\r\n } else {\r\n responseBody = configureText(fulfillment, res);\r\n }\r\n\r\n configureResponse(protocol, request, fulfillment, res);\r\n res.status(fulfillment.status);\r\n\r\n if (fulfillment.allowCompression)\r\n responseBody = await configureEncoding(req, res, responseBody);\r\n\r\n // This check should in theory look for instances of Readable, but that would break backend implementation at\r\n // core/backend/src/RpcBackend.ts\r\n if (responseBody instanceof Stream) {\r\n responseBody.pipe(res);\r\n } else {\r\n res.send(responseBody);\r\n }\r\n}\r\n\r\nfunction logResponse(request: SerializedRpcRequest, statusCode: number, resultObj: unknown) {\r\n const metadata = {\r\n ActivityId: request.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n method: request.method,\r\n path: request.path,\r\n operation: request.operation,\r\n statusCode,\r\n errorObj: resultObj instanceof Error ? BentleyError.getErrorProps(resultObj) : undefined,\r\n };\r\n\r\n if (statusCode < 400)\r\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceBackend, \"RPC over HTTP success response\", metadata);\r\n else\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, \"RPC over HTTP failure response\", metadata);\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-backend",
3
- "version": "4.10.0-dev.10",
3
+ "version": "4.10.0-dev.11",
4
4
  "description": "iTwin.js backend components",
5
5
  "main": "lib/cjs/core-backend.js",
6
6
  "typings": "lib/cjs/core-backend",
@@ -25,9 +25,9 @@
25
25
  "url": "http://www.bentley.com"
26
26
  },
27
27
  "peerDependencies": {
28
- "@itwin/core-bentley": "^4.10.0-dev.10",
29
- "@itwin/core-common": "^4.10.0-dev.10",
30
- "@itwin/core-geometry": "^4.10.0-dev.10",
28
+ "@itwin/core-bentley": "^4.10.0-dev.11",
29
+ "@itwin/core-common": "^4.10.0-dev.11",
30
+ "@itwin/core-geometry": "^4.10.0-dev.11",
31
31
  "@opentelemetry/api": "^1.0.4"
32
32
  },
33
33
  "peerDependenciesMeta": {
@@ -69,13 +69,13 @@
69
69
  "ts-node": "^10.8.2",
70
70
  "typescript": "~5.3.3",
71
71
  "webpack": "^5.76.0",
72
- "@itwin/core-bentley": "4.10.0-dev.10",
73
- "@itwin/build-tools": "4.10.0-dev.10",
74
- "@itwin/core-common": "4.10.0-dev.10",
75
- "@itwin/core-geometry": "4.10.0-dev.10",
76
- "@itwin/core-webpack-tools": "4.10.0-dev.10",
77
- "@itwin/ecsql-common": "4.10.0-dev.10",
78
- "internal-tools": "3.0.0-dev.69"
72
+ "@itwin/build-tools": "4.10.0-dev.11",
73
+ "@itwin/core-common": "4.10.0-dev.11",
74
+ "@itwin/core-geometry": "4.10.0-dev.11",
75
+ "@itwin/core-bentley": "4.10.0-dev.11",
76
+ "internal-tools": "3.0.0-dev.69",
77
+ "@itwin/core-webpack-tools": "4.10.0-dev.11",
78
+ "@itwin/ecsql-common": "4.10.0-dev.11"
79
79
  },
80
80
  "dependencies": {
81
81
  "@bentley/imodeljs-native": "4.10.6",
@@ -92,7 +92,7 @@
92
92
  "semver": "^7.5.2",
93
93
  "touch": "^3.1.0",
94
94
  "ws": "^7.5.10",
95
- "@itwin/core-telemetry": "4.10.0-dev.10"
95
+ "@itwin/core-telemetry": "4.10.0-dev.11"
96
96
  },
97
97
  "nyc": {
98
98
  "extends": "./node_modules/@itwin/build-tools/.nycrc"