@itwin/core-backend 4.9.0 → 4.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # Change Log - @itwin/core-backend
2
2
 
3
- This log was last generated on Mon, 23 Sep 2024 13:44:01 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 02 Oct 2024 15:14:43 GMT and should not be manually modified.
4
+
5
+ ## 4.9.2
6
+ Wed, 02 Oct 2024 15:14:43 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 4.9.1
11
+ Wed, 25 Sep 2024 20:10:58 GMT
12
+
13
+ ### Updates
14
+
15
+ - Removed added tests for boolean exps in select statement
4
16
 
5
17
  ## 4.9.0
6
18
  Mon, 23 Sep 2024 13:44:01 GMT
@@ -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;AAC7C,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;IACj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,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"],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G,CAAC,CAAC;IACvD,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,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,2BAAY,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;KACzF,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 { 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.9.0",
3
+ "version": "4.9.2",
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.9.0",
29
- "@itwin/core-common": "^4.9.0",
30
- "@itwin/core-geometry": "^4.9.0",
28
+ "@itwin/core-bentley": "^4.9.2",
29
+ "@itwin/core-common": "^4.9.2",
30
+ "@itwin/core-geometry": "^4.9.2",
31
31
  "@opentelemetry/api": "^1.0.4"
32
32
  },
33
33
  "peerDependenciesMeta": {
@@ -69,16 +69,16 @@
69
69
  "ts-node": "^10.8.2",
70
70
  "typescript": "~5.3.3",
71
71
  "webpack": "^5.76.0",
72
- "@itwin/core-geometry": "4.9.0",
73
- "@itwin/build-tools": "4.9.0",
74
- "@itwin/core-bentley": "4.9.0",
75
- "@itwin/core-common": "4.9.0",
76
- "@itwin/ecsql-common": "4.9.0",
77
- "@itwin/core-webpack-tools": "4.9.0",
78
- "internal-tools": "3.0.0-dev.69"
72
+ "@itwin/core-bentley": "4.9.2",
73
+ "@itwin/core-common": "4.9.2",
74
+ "internal-tools": "3.0.0-dev.69",
75
+ "@itwin/build-tools": "4.9.2",
76
+ "@itwin/core-geometry": "4.9.2",
77
+ "@itwin/core-webpack-tools": "4.9.2",
78
+ "@itwin/ecsql-common": "4.9.2"
79
79
  },
80
80
  "dependencies": {
81
- "@bentley/imodeljs-native": "4.9.28",
81
+ "@bentley/imodeljs-native": "4.9.29",
82
82
  "@itwin/cloud-agnostic-core": "^2.2.4",
83
83
  "@itwin/object-storage-azure": "^2.2.5",
84
84
  "@itwin/object-storage-core": "^2.2.5",
@@ -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.9.0"
95
+ "@itwin/core-telemetry": "4.9.2"
96
96
  },
97
97
  "nyc": {
98
98
  "extends": "./node_modules/@itwin/build-tools/.nycrc"