@itwin/core-backend 4.0.0-dev.2 → 4.0.0-dev.22

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,23 @@
1
1
  # Change Log - @itwin/core-backend
2
2
 
3
- This log was last generated on Thu, 26 Jan 2023 22:53:27 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 08 Feb 2023 14:58:39 GMT and should not be manually modified.
4
+
5
+ ## 3.6.0
6
+ Wed, 08 Feb 2023 14:58:39 GMT
7
+
8
+ ### Updates
9
+
10
+ - add CodeSpecs.updateProperties
11
+ - add flag schemaLockHeld
12
+ - Added getOriginPropertyName() method to column info.
13
+ - add allowPreceding as an optional boolean to CheckpointProps interface
14
+ - Log a warning when we fail to download a v2 checkpoint, but download a v1 checkpoint successfully.
15
+ - Promote IModelHost.authorizationClient to public.
16
+ - Add support for material elements with normal maps
17
+ - React to RPC deprecations.
18
+ - Fix documentation of ExternalSourceAspectProps.jsonProperties. It must be a string.
19
+ - Element.toJSON should not include undefined values for userLabel or federationGuid
20
+ - allow passing a custom schema read context to IModelDb.importSchemas
4
21
 
5
22
  ## 3.5.5
6
23
  Thu, 26 Jan 2023 22:53:27 GMT
@@ -2,7 +2,7 @@ import { CloudStorageContainerDescriptor, CloudStorageContainerUrl, CloudStorage
2
2
  import { CloudStorageService, CloudStorageUploadOptions } from "./CloudStorageBackend";
3
3
  /**
4
4
  * @beta
5
- * @deprecated in 3.x.
5
+ * @deprecated in 3.x. Use `@itwin/object-storage-oss` instead, see https://github.com/iTwin/object-storage for more details.
6
6
  */
7
7
  export interface AliCloudStorageServiceCredentials {
8
8
  region: string;
@@ -1 +1 @@
1
- {"version":3,"file":"AliCloudStorageService.js","sourceRoot":"","sources":["../../src/AliCloudStorageService.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,mCAA+C;AAC/C,6BAA6B;AAC7B,sDAAoD;AACpD,oDAAkI;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,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACtC;aAAM;YACL,MAAM,GAAG,UAAU,CAAC;SACrB;QACD,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QACvD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AApED,wDAoEC","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\nimport { PassThrough, Readable } from \"stream\";\r\nimport * as zlib from \"zlib\";\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { CloudStorageContainerDescriptor, CloudStorageContainerUrl, CloudStorageProvider, IModelError } from \"@itwin/core-common\";\r\nimport { CloudStorageService, CloudStorageUploadOptions } from \"./CloudStorageBackend\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x.\r\n */\r\nexport interface AliCloudStorageServiceCredentials {\r\n region: string;\r\n accessKeyId: string;\r\n accessKeySecret: string;\r\n}\r\n\r\ndeclare class OSS {\r\n constructor(params: AliCloudStorageServiceCredentials)\r\n public useBucket(name: string): void;\r\n public signatureUrl(name: string, policy: OSS.SignatureUrlOptions): string;\r\n public list(params: { marker: string, \"max-keys\": number }, arg2: {}): Promise<{ objects?: Array<{ name: string }> }>;\r\n public putBucket(name: string): Promise<void>;\r\n public putBucketCORS(name: string, params: Array<{ allowedOrigin: string, allowedMethod: string[], allowedHeader: string }>): Promise<void>;\r\n public putStream(name: string, source: Readable, options: OSS.PutStreamOptions): Promise<void>;\r\n}\r\n\r\ndeclare namespace OSS { // eslint-disable-line no-redeclare\r\n interface SignatureUrlOptions {\r\n expires: number;\r\n }\r\n\r\n interface PutStreamOptions {\r\n mime: string;\r\n headers: { [index: string]: string };\r\n }\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x. Use `@itwin/object-storage-oss` instead, see https://github.com/iTwin/object-storage for more details.\r\n */\r\nexport class AliCloudStorageService extends CloudStorageService {\r\n private _client: OSS;\r\n\r\n public id = CloudStorageProvider.AliCloud;\r\n\r\n public constructor(credentials: AliCloudStorageServiceCredentials) {\r\n super();\r\n\r\n this._client = new OSS(credentials);\r\n }\r\n\r\n public obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, _clientIp?: string): CloudStorageContainerUrl {\r\n const now = new Date().getTime();\r\n\r\n const policy: OSS.SignatureUrlOptions = {\r\n expires: expiry.getTime() - now,\r\n };\r\n\r\n this._client.useBucket(id.name);\r\n\r\n if (undefined === id.resource)\r\n throw new IModelError(BentleyStatus.ERROR, \"Attribute 'resource' on CloudStorageContainerDescriptor object is undefined.\");\r\n\r\n const url: CloudStorageContainerUrl = {\r\n descriptor: this.makeDescriptor(id),\r\n valid: 0,\r\n expires: expiry.getTime(),\r\n url: this._client.signatureUrl(id.resource, policy),\r\n bound: true,\r\n };\r\n\r\n return url;\r\n }\r\n\r\n public async listContainer(name: string, marker: string, count: number): Promise<string[]> {\r\n this._client.useBucket(name);\r\n const query = await this._client.list({ marker, \"max-keys\": count }, {});\r\n return query.objects ? query.objects.map((o) => o.name) : [];\r\n }\r\n\r\n public async upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions): Promise<string> {\r\n await this._client.putBucket(container);\r\n await this._client.putBucketCORS(container, [{ allowedOrigin: \"*\", allowedMethod: [\"GET\", \"POST\", \"PUT\", \"DELETE\", \"HEAD\"], allowedHeader: \"*\" }]);\r\n this._client.useBucket(container);\r\n\r\n const dataStream = new PassThrough();\r\n dataStream.end(data);\r\n\r\n let source: Readable;\r\n\r\n const putOptions = {\r\n mime: (options && options.type) ? options.type : \"application/octet-stream\",\r\n headers: {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"Cache-Control\": (options && options.cacheControl) ? options.cacheControl : \"private, max-age=31536000, immutable\",\r\n },\r\n } as OSS.PutStreamOptions;\r\n\r\n if (options && options.contentEncoding === \"gzip\") {\r\n (putOptions.headers as any)[\"Content-Encoding\"] = options.contentEncoding;\r\n const compressor = zlib.createGzip();\r\n source = dataStream.pipe(compressor);\r\n } else {\r\n source = dataStream;\r\n }\r\n await this._client.putStream(name, source, putOptions);\r\n return \"\";\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"AliCloudStorageService.js","sourceRoot":"","sources":["../../src/AliCloudStorageService.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,mCAA+C;AAC/C,6BAA6B;AAC7B,sDAAoD;AACpD,oDAAkI;AAClI,+DAAuF;AAmCvF;;;GAGG;AACH,MAAa,sBAAuB,SAAQ,yCAAmB;IAK7D,YAAmB,WAA8C;QAC/D,KAAK,EAAE,CAAC;QAHH,OAAE,GAAG,kCAAoB,CAAC,QAAQ,CAAC;QAKxC,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IAEM,kBAAkB,CAAC,EAAmC,EAAE,MAAY,EAAE,SAAkB;QAC7F,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAEjC,MAAM,MAAM,GAA4B;YACtC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,GAAG,GAAG;SAChC,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QAEhC,IAAI,SAAS,KAAK,EAAE,CAAC,QAAQ;YAC3B,MAAM,IAAI,yBAAW,CAAC,4BAAa,CAAC,KAAK,EAAE,8EAA8E,CAAC,CAAC;QAE7H,MAAM,GAAG,GAA6B;YACpC,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;YACnC,KAAK,EAAE,CAAC;YACR,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE;YACzB,GAAG,EAAE,IAA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O,CAAC,IAAI,CAAC,CAAC,CAAC,0BAA0B;YAC3E,OAAO,EAAE;gBACP,gEAAgE;gBAChE,eAAe,EAAE,CAAC,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,sCAAsC;aACnH;SACsB,CAAC;QAE1B,IAAI,OAAO,IAAI,OAAO,CAAC,eAAe,KAAK,MAAM,EAAE;YAChD,UAAU,CAAC,OAAe,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;YAC1E,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YACrC,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACtC;aAAM;YACL,MAAM,GAAG,UAAU,CAAC;SACrB;QACD,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QACvD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AApED,wDAoEC","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\nimport { PassThrough, Readable } from \"stream\";\r\nimport * as zlib from \"zlib\";\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { CloudStorageContainerDescriptor, CloudStorageContainerUrl, CloudStorageProvider, IModelError } from \"@itwin/core-common\";\r\nimport { CloudStorageService, CloudStorageUploadOptions } from \"./CloudStorageBackend\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x. Use `@itwin/object-storage-oss` instead, see https://github.com/iTwin/object-storage for more details.\r\n */\r\nexport interface AliCloudStorageServiceCredentials {\r\n region: string;\r\n accessKeyId: string;\r\n accessKeySecret: string;\r\n}\r\n\r\ndeclare class OSS {\r\n constructor(params: AliCloudStorageServiceCredentials)\r\n public useBucket(name: string): void;\r\n public signatureUrl(name: string, policy: OSS.SignatureUrlOptions): string;\r\n public list(params: { marker: string, \"max-keys\": number }, arg2: {}): Promise<{ objects?: Array<{ name: string }> }>;\r\n public putBucket(name: string): Promise<void>;\r\n public putBucketCORS(name: string, params: Array<{ allowedOrigin: string, allowedMethod: string[], allowedHeader: string }>): Promise<void>;\r\n public putStream(name: string, source: Readable, options: OSS.PutStreamOptions): Promise<void>;\r\n}\r\n\r\ndeclare namespace OSS { // eslint-disable-line no-redeclare\r\n interface SignatureUrlOptions {\r\n expires: number;\r\n }\r\n\r\n interface PutStreamOptions {\r\n mime: string;\r\n headers: { [index: string]: string };\r\n }\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x. Use `@itwin/object-storage-oss` instead, see https://github.com/iTwin/object-storage for more details.\r\n */\r\nexport class AliCloudStorageService extends CloudStorageService {\r\n private _client: OSS;\r\n\r\n public id = CloudStorageProvider.AliCloud;\r\n\r\n public constructor(credentials: AliCloudStorageServiceCredentials) {\r\n super();\r\n\r\n this._client = new OSS(credentials);\r\n }\r\n\r\n public obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, _clientIp?: string): CloudStorageContainerUrl {\r\n const now = new Date().getTime();\r\n\r\n const policy: OSS.SignatureUrlOptions = {\r\n expires: expiry.getTime() - now,\r\n };\r\n\r\n this._client.useBucket(id.name);\r\n\r\n if (undefined === id.resource)\r\n throw new IModelError(BentleyStatus.ERROR, \"Attribute 'resource' on CloudStorageContainerDescriptor object is undefined.\");\r\n\r\n const url: CloudStorageContainerUrl = {\r\n descriptor: this.makeDescriptor(id),\r\n valid: 0,\r\n expires: expiry.getTime(),\r\n url: this._client.signatureUrl(id.resource, policy),\r\n bound: true,\r\n };\r\n\r\n return url;\r\n }\r\n\r\n public async listContainer(name: string, marker: string, count: number): Promise<string[]> {\r\n this._client.useBucket(name);\r\n const query = await this._client.list({ marker, \"max-keys\": count }, {});\r\n return query.objects ? query.objects.map((o) => o.name) : [];\r\n }\r\n\r\n public async upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions): Promise<string> {\r\n await this._client.putBucket(container);\r\n await this._client.putBucketCORS(container, [{ allowedOrigin: \"*\", allowedMethod: [\"GET\", \"POST\", \"PUT\", \"DELETE\", \"HEAD\"], allowedHeader: \"*\" }]);\r\n this._client.useBucket(container);\r\n\r\n const dataStream = new PassThrough();\r\n dataStream.end(data);\r\n\r\n let source: Readable;\r\n\r\n const putOptions = {\r\n mime: (options && options.type) ? options.type : \"application/octet-stream\",\r\n headers: {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"Cache-Control\": (options && options.cacheControl) ? options.cacheControl : \"private, max-age=31536000, immutable\",\r\n },\r\n } as OSS.PutStreamOptions;\r\n\r\n if (options && options.contentEncoding === \"gzip\") {\r\n (putOptions.headers as any)[\"Content-Encoding\"] = options.contentEncoding;\r\n const compressor = zlib.createGzip();\r\n source = dataStream.pipe(compressor);\r\n } else {\r\n source = dataStream;\r\n }\r\n await this._client.putStream(name, source, putOptions);\r\n return \"\";\r\n }\r\n}\r\n"]}
@@ -140,7 +140,7 @@ export interface DownloadChangesetRangeArg extends ChangesetRangeArg, DownloadPr
140
140
  targetDir: LocalDirName;
141
141
  }
142
142
  /**
143
- * @deprecated in 3.x.
143
+ * @deprecated in 3.x. Use [[DownloadRequest]].
144
144
  * @internal
145
145
  */
146
146
  export declare type CheckpointArg = DownloadRequest;
@@ -190,8 +190,8 @@ export interface BackendHubAccess {
190
190
  /** get an array of the briefcases assigned to a user. */
191
191
  getMyBriefcaseIds: (arg: IModelIdArg) => Promise<BriefcaseId[]>;
192
192
  /**
193
- * download a v1 checkpoint
194
- * @deprecated in 3.x.
193
+ * Download a v1 checkpoint
194
+ * @deprecated in 3.x. V1 checkpoints are deprecated. Download V2 checkpoint using [[V2CheckpointManager.downloadCheckpoint]].
195
195
  * @internal
196
196
  */
197
197
  downloadV1Checkpoint: (arg: CheckpointArg) => Promise<ChangesetIndexAndId>;
@@ -1 +1 @@
1
- {"version":3,"file":"BackendHubAccess.js","sourceRoot":"","sources":["../../src/BackendHubAccess.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2F;AAC3F,oDAG4B;AAI5B;;GAEG;AACH,IAAY,SASX;AATD,WAAY,SAAS;IACnB,gCAAgC;IAChC,yCAAQ,CAAA;IACR,mJAAmJ;IACnJ,6CAAU,CAAA;IACV;;OAEG;IACH,mDAAa,CAAA;AACf,CAAC,EATW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QASpB;AAED;;EAEE;AACF,MAAa,YAAa,SAAQ,yBAAW;IAC3C;IACE,mCAAmC;IACnB,WAAwB;IACxC,sCAAsC;IACtB,cAAsB,EACtC,GAA6D;QAE7D,KAAK,CAAC,8BAAe,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;QALxC,gBAAW,GAAX,WAAW,CAAa;QAExB,mBAAc,GAAd,cAAc,CAAQ;IAIxC,CAAC;CACF;AAVD,oCAUC","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 HubAccess\r\n */\r\n\r\nimport { AccessToken, GuidString, Id64String, IModelHubStatus } from \"@itwin/core-bentley\";\r\nimport {\r\n BriefcaseId, ChangesetFileProps, ChangesetIdWithIndex, ChangesetIndex, ChangesetIndexAndId, ChangesetIndexOrId, ChangesetProps, ChangesetRange,\r\n IModelError, IModelVersion, LocalDirName, LocalFileName,\r\n} from \"@itwin/core-common\";\r\nimport { CheckpointProps, DownloadRequest, ProgressFunction } from \"./CheckpointManager\";\r\nimport { TokenArg } from \"./IModelDb\";\r\n\r\n/** The state of a lock.\r\n * @public\r\n */\r\nexport enum LockState {\r\n /** The element is not locked */\r\n None = 0,\r\n /** Holding a shared lock on an element blocks other users from acquiring the Exclusive lock it. More than one user may acquire the shared lock. */\r\n Shared = 1,\r\n /** A Lock that permits modifications to an element and blocks other users from making modifications to it.\r\n * Holding an exclusive lock on an \"owner\" (a model or a parent element), implicitly exclusively locks all its members.\r\n */\r\n Exclusive = 2,\r\n}\r\n\r\n/** Exception thrown if lock cannot be acquired.\r\n * @beta\r\n*/\r\nexport class LockConflict extends IModelError {\r\n public constructor(\r\n /** Id of Briefcase holding lock */\r\n public readonly briefcaseId: BriefcaseId,\r\n /** Alias of Briefcase holding lock */\r\n public readonly briefcaseAlias: string,\r\n msg: \"shared lock is held\" | \"exclusive lock is already held\"\r\n ) {\r\n super(IModelHubStatus.LockOwnedByAnotherBriefcase, msg);\r\n }\r\n}\r\n\r\n/**\r\n * The properties to access a V2 checkpoint through a daemon.\r\n * @internal\r\n */\r\nexport interface V2CheckpointAccessProps {\r\n /** blob store account name. */\r\n readonly accountName: string;\r\n /** AccessToken that grants access to the container. */\r\n readonly sasToken: AccessToken;\r\n /** The name of the iModel's blob store container holding all checkpoints. */\r\n readonly containerId: string;\r\n /** The name of the virtual file within the container, used for the checkpoint */\r\n readonly dbName: string;\r\n /** blob storage module: e.g. \"azure\", \"google\", \"aws\". May also include URI style parameters. */\r\n readonly storageType: string;\r\n}\r\n\r\n/** @internal */\r\nexport type LockMap = Map<Id64String, LockState>;\r\n\r\n/**\r\n * The properties of a lock that may be obtained from a lock server.\r\n * @beta\r\n */\r\nexport interface LockProps {\r\n /** The elementId for the lock */\r\n readonly id: Id64String;\r\n /** the lock state */\r\n readonly state: LockState;\r\n}\r\n\r\n/**\r\n * Argument for cancelling and tracking download progress.\r\n * @beta\r\n */\r\nexport interface DownloadProgressArg {\r\n /** Called to show progress during a download. If this function returns non-zero, the download is aborted. */\r\n progressCallback?: ProgressFunction;\r\n}\r\n\r\n/**\r\n * Argument for methods that must supply an iTwinId\r\n * @public\r\n */\r\nexport interface ITwinIdArg {\r\n readonly iTwinId: GuidString;\r\n}\r\n\r\n/**\r\n * Argument for methods that must supply an IModelId\r\n * @public\r\n */\r\nexport interface IModelIdArg extends TokenArg {\r\n readonly iModelId: GuidString;\r\n}\r\n\r\n/**\r\n * Argument for acquiring a new BriefcaseId\r\n * @public\r\n */\r\nexport interface AcquireNewBriefcaseIdArg extends IModelIdArg {\r\n /** A string to be reported to other users to identify this briefcase, for example in the case of conflicts or lock collisions. */\r\n readonly briefcaseAlias?: string;\r\n}\r\n\r\n/** Argument for methods that must supply an IModel name and iTwinId\r\n * @public\r\n */\r\nexport interface IModelNameArg extends TokenArg, ITwinIdArg {\r\n readonly iModelName: string;\r\n}\r\n\r\n/** Argument for methods that must supply an IModelId and a BriefcaseId\r\n * @public\r\n */\r\nexport interface BriefcaseIdArg extends IModelIdArg {\r\n readonly briefcaseId: BriefcaseId;\r\n}\r\n\r\n/** Argument for methods that must supply a briefcaseId and a changeset\r\n * @public\r\n */\r\nexport interface BriefcaseDbArg extends BriefcaseIdArg {\r\n readonly changeset: ChangesetIdWithIndex;\r\n}\r\n\r\n/** Argument for methods that must supply an IModelId and a changeset\r\n * @public\r\n */\r\nexport interface ChangesetArg extends IModelIdArg {\r\n readonly changeset: ChangesetIndexOrId;\r\n}\r\n\r\n/** Argument for downloading a changeset.\r\n * @beta\r\n */\r\nexport interface DownloadChangesetArg extends ChangesetArg, DownloadProgressArg {\r\n /** Directory where the changeset should be downloaded. */\r\n targetDir: LocalDirName;\r\n}\r\n\r\n/** @internal */\r\nexport interface ChangesetIndexArg extends IModelIdArg {\r\n readonly changeset: ChangesetIdWithIndex;\r\n}\r\n\r\n/** Argument for methods that must supply an IModelId and a range of Changesets.\r\n * @public\r\n */\r\nexport interface ChangesetRangeArg extends IModelIdArg {\r\n /** the range of changesets desired. If is undefined, *all* changesets are returned. */\r\n readonly range?: ChangesetRange;\r\n}\r\n\r\n/** Argument for downloading a changeset range.\r\n * @beta\r\n */\r\nexport interface DownloadChangesetRangeArg extends ChangesetRangeArg, DownloadProgressArg {\r\n /** Directory where the changesets should be downloaded. */\r\n targetDir: LocalDirName;\r\n}\r\n\r\n/**\r\n * @deprecated in 3.x.\r\n * @internal\r\n */\r\nexport type CheckpointArg = DownloadRequest;\r\n\r\n/**\r\n * Arguments to create a new iModel in iModelHub\r\n * @public\r\n */\r\nexport interface CreateNewIModelProps extends IModelNameArg {\r\n readonly description?: string;\r\n readonly version0?: LocalFileName;\r\n readonly noLocks?: true;\r\n}\r\n\r\n/**\r\n * Methods for accessing services of IModelHub from an iTwin.js backend.\r\n * Generally direct access to these methods should not be required, since higher-level apis are provided.\r\n * @beta\r\n */\r\nexport interface BackendHubAccess {\r\n /** Download all the changesets in the specified range. */\r\n downloadChangesets: (arg: DownloadChangesetRangeArg) => Promise<ChangesetFileProps[]>;\r\n /** Download a single changeset. */\r\n downloadChangeset: (arg: DownloadChangesetArg) => Promise<ChangesetFileProps>;\r\n /** Query the changeset properties given a ChangesetIndex */\r\n queryChangeset: (arg: ChangesetArg) => Promise<ChangesetProps>;\r\n /** Query an array of changeset properties given a range of ChangesetIndexes */\r\n queryChangesets: (arg: ChangesetRangeArg) => Promise<ChangesetProps[]>;\r\n /** Push a changeset to iModelHub. Returns the newly pushed changeset's index */\r\n pushChangeset: (arg: IModelIdArg & { changesetProps: ChangesetFileProps }) => Promise<ChangesetIndex>;\r\n /** Get the ChangesetProps of the most recent changeset */\r\n getLatestChangeset: (arg: IModelIdArg) => Promise<ChangesetProps>;\r\n /** Get the ChangesetProps for an IModelVersion */\r\n getChangesetFromVersion: (arg: IModelIdArg & { version: IModelVersion }) => Promise<ChangesetProps>;\r\n /** Get the ChangesetProps for a named version */\r\n getChangesetFromNamedVersion: (arg: IModelIdArg & { versionName: string }) => Promise<ChangesetProps>;\r\n\r\n /** Acquire a new briefcaseId for the supplied iModelId\r\n * @note usually there should only be one briefcase per iModel per user.\r\n */\r\n acquireNewBriefcaseId: (arg: AcquireNewBriefcaseIdArg) => Promise<BriefcaseId>;\r\n /** Release a briefcaseId. After this call it is illegal to generate changesets for the released briefcaseId. */\r\n releaseBriefcase: (arg: BriefcaseIdArg) => Promise<void>;\r\n\r\n /** get an array of the briefcases assigned to a user. */\r\n getMyBriefcaseIds: (arg: IModelIdArg) => Promise<BriefcaseId[]>;\r\n\r\n /**\r\n * download a v1 checkpoint\r\n * @deprecated in 3.x.\r\n * @internal\r\n */\r\n downloadV1Checkpoint: (arg: CheckpointArg) => Promise<ChangesetIndexAndId>; // eslint-disable-line deprecation/deprecation\r\n\r\n /**\r\n * Get the access props for a V2 checkpoint. Returns undefined if no V2 checkpoint exists.\r\n * @internal\r\n */\r\n queryV2Checkpoint: (arg: CheckpointProps) => Promise<V2CheckpointAccessProps | undefined>;\r\n\r\n /**\r\n * acquire one or more locks. Throws if unsuccessful. If *any* lock cannot be obtained, no locks are acquired\r\n * @internal\r\n */\r\n acquireLocks: (arg: BriefcaseDbArg, locks: LockMap) => Promise<void>;\r\n\r\n /**\r\n * Get the list of all held locks for a briefcase. This can be very expensive and is currently used only for tests.\r\n * @internal\r\n */\r\n queryAllLocks: (arg: BriefcaseDbArg) => Promise<LockProps[]>;\r\n\r\n /**\r\n * Release all currently held locks\r\n * @internal\r\n */\r\n releaseAllLocks: (arg: BriefcaseDbArg) => Promise<void>;\r\n\r\n /** Get the iModelId of an iModel by name. Undefined if no iModel with that name exists. */\r\n queryIModelByName: (arg: IModelNameArg) => Promise<GuidString | undefined>;\r\n\r\n /** create a new iModel. Returns the Guid of the newly created iModel */\r\n createNewIModel: (arg: CreateNewIModelProps) => Promise<GuidString>;\r\n\r\n /** delete an iModel */\r\n deleteIModel: (arg: IModelIdArg & ITwinIdArg) => Promise<void>;\r\n}\r\n"]}
1
+ {"version":3,"file":"BackendHubAccess.js","sourceRoot":"","sources":["../../src/BackendHubAccess.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2F;AAC3F,oDAG4B;AAI5B;;GAEG;AACH,IAAY,SASX;AATD,WAAY,SAAS;IACnB,gCAAgC;IAChC,yCAAQ,CAAA;IACR,mJAAmJ;IACnJ,6CAAU,CAAA;IACV;;OAEG;IACH,mDAAa,CAAA;AACf,CAAC,EATW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QASpB;AAED;;EAEE;AACF,MAAa,YAAa,SAAQ,yBAAW;IAC3C;IACE,mCAAmC;IACnB,WAAwB;IACxC,sCAAsC;IACtB,cAAsB,EACtC,GAA6D;QAE7D,KAAK,CAAC,8BAAe,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;QALxC,gBAAW,GAAX,WAAW,CAAa;QAExB,mBAAc,GAAd,cAAc,CAAQ;IAIxC,CAAC;CACF;AAVD,oCAUC","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 HubAccess\r\n */\r\n\r\nimport { AccessToken, GuidString, Id64String, IModelHubStatus } from \"@itwin/core-bentley\";\r\nimport {\r\n BriefcaseId, ChangesetFileProps, ChangesetIdWithIndex, ChangesetIndex, ChangesetIndexAndId, ChangesetIndexOrId, ChangesetProps, ChangesetRange,\r\n IModelError, IModelVersion, LocalDirName, LocalFileName,\r\n} from \"@itwin/core-common\";\r\nimport { CheckpointProps, DownloadRequest, ProgressFunction } from \"./CheckpointManager\";\r\nimport { TokenArg } from \"./IModelDb\";\r\n\r\n/** The state of a lock.\r\n * @public\r\n */\r\nexport enum LockState {\r\n /** The element is not locked */\r\n None = 0,\r\n /** Holding a shared lock on an element blocks other users from acquiring the Exclusive lock it. More than one user may acquire the shared lock. */\r\n Shared = 1,\r\n /** A Lock that permits modifications to an element and blocks other users from making modifications to it.\r\n * Holding an exclusive lock on an \"owner\" (a model or a parent element), implicitly exclusively locks all its members.\r\n */\r\n Exclusive = 2,\r\n}\r\n\r\n/** Exception thrown if lock cannot be acquired.\r\n * @beta\r\n*/\r\nexport class LockConflict extends IModelError {\r\n public constructor(\r\n /** Id of Briefcase holding lock */\r\n public readonly briefcaseId: BriefcaseId,\r\n /** Alias of Briefcase holding lock */\r\n public readonly briefcaseAlias: string,\r\n msg: \"shared lock is held\" | \"exclusive lock is already held\"\r\n ) {\r\n super(IModelHubStatus.LockOwnedByAnotherBriefcase, msg);\r\n }\r\n}\r\n\r\n/**\r\n * The properties to access a V2 checkpoint through a daemon.\r\n * @internal\r\n */\r\nexport interface V2CheckpointAccessProps {\r\n /** blob store account name. */\r\n readonly accountName: string;\r\n /** AccessToken that grants access to the container. */\r\n readonly sasToken: AccessToken;\r\n /** The name of the iModel's blob store container holding all checkpoints. */\r\n readonly containerId: string;\r\n /** The name of the virtual file within the container, used for the checkpoint */\r\n readonly dbName: string;\r\n /** blob storage module: e.g. \"azure\", \"google\", \"aws\". May also include URI style parameters. */\r\n readonly storageType: string;\r\n}\r\n\r\n/** @internal */\r\nexport type LockMap = Map<Id64String, LockState>;\r\n\r\n/**\r\n * The properties of a lock that may be obtained from a lock server.\r\n * @beta\r\n */\r\nexport interface LockProps {\r\n /** The elementId for the lock */\r\n readonly id: Id64String;\r\n /** the lock state */\r\n readonly state: LockState;\r\n}\r\n\r\n/**\r\n * Argument for cancelling and tracking download progress.\r\n * @beta\r\n */\r\nexport interface DownloadProgressArg {\r\n /** Called to show progress during a download. If this function returns non-zero, the download is aborted. */\r\n progressCallback?: ProgressFunction;\r\n}\r\n\r\n/**\r\n * Argument for methods that must supply an iTwinId\r\n * @public\r\n */\r\nexport interface ITwinIdArg {\r\n readonly iTwinId: GuidString;\r\n}\r\n\r\n/**\r\n * Argument for methods that must supply an IModelId\r\n * @public\r\n */\r\nexport interface IModelIdArg extends TokenArg {\r\n readonly iModelId: GuidString;\r\n}\r\n\r\n/**\r\n * Argument for acquiring a new BriefcaseId\r\n * @public\r\n */\r\nexport interface AcquireNewBriefcaseIdArg extends IModelIdArg {\r\n /** A string to be reported to other users to identify this briefcase, for example in the case of conflicts or lock collisions. */\r\n readonly briefcaseAlias?: string;\r\n}\r\n\r\n/** Argument for methods that must supply an IModel name and iTwinId\r\n * @public\r\n */\r\nexport interface IModelNameArg extends TokenArg, ITwinIdArg {\r\n readonly iModelName: string;\r\n}\r\n\r\n/** Argument for methods that must supply an IModelId and a BriefcaseId\r\n * @public\r\n */\r\nexport interface BriefcaseIdArg extends IModelIdArg {\r\n readonly briefcaseId: BriefcaseId;\r\n}\r\n\r\n/** Argument for methods that must supply a briefcaseId and a changeset\r\n * @public\r\n */\r\nexport interface BriefcaseDbArg extends BriefcaseIdArg {\r\n readonly changeset: ChangesetIdWithIndex;\r\n}\r\n\r\n/** Argument for methods that must supply an IModelId and a changeset\r\n * @public\r\n */\r\nexport interface ChangesetArg extends IModelIdArg {\r\n readonly changeset: ChangesetIndexOrId;\r\n}\r\n\r\n/** Argument for downloading a changeset.\r\n * @beta\r\n */\r\nexport interface DownloadChangesetArg extends ChangesetArg, DownloadProgressArg {\r\n /** Directory where the changeset should be downloaded. */\r\n targetDir: LocalDirName;\r\n}\r\n\r\n/** @internal */\r\nexport interface ChangesetIndexArg extends IModelIdArg {\r\n readonly changeset: ChangesetIdWithIndex;\r\n}\r\n\r\n/** Argument for methods that must supply an IModelId and a range of Changesets.\r\n * @public\r\n */\r\nexport interface ChangesetRangeArg extends IModelIdArg {\r\n /** the range of changesets desired. If is undefined, *all* changesets are returned. */\r\n readonly range?: ChangesetRange;\r\n}\r\n\r\n/** Argument for downloading a changeset range.\r\n * @beta\r\n */\r\nexport interface DownloadChangesetRangeArg extends ChangesetRangeArg, DownloadProgressArg {\r\n /** Directory where the changesets should be downloaded. */\r\n targetDir: LocalDirName;\r\n}\r\n\r\n/**\r\n * @deprecated in 3.x. Use [[DownloadRequest]].\r\n * @internal\r\n */\r\nexport type CheckpointArg = DownloadRequest;\r\n\r\n/**\r\n * Arguments to create a new iModel in iModelHub\r\n * @public\r\n */\r\nexport interface CreateNewIModelProps extends IModelNameArg {\r\n readonly description?: string;\r\n readonly version0?: LocalFileName;\r\n readonly noLocks?: true;\r\n}\r\n\r\n/**\r\n * Methods for accessing services of IModelHub from an iTwin.js backend.\r\n * Generally direct access to these methods should not be required, since higher-level apis are provided.\r\n * @beta\r\n */\r\nexport interface BackendHubAccess {\r\n /** Download all the changesets in the specified range. */\r\n downloadChangesets: (arg: DownloadChangesetRangeArg) => Promise<ChangesetFileProps[]>;\r\n /** Download a single changeset. */\r\n downloadChangeset: (arg: DownloadChangesetArg) => Promise<ChangesetFileProps>;\r\n /** Query the changeset properties given a ChangesetIndex */\r\n queryChangeset: (arg: ChangesetArg) => Promise<ChangesetProps>;\r\n /** Query an array of changeset properties given a range of ChangesetIndexes */\r\n queryChangesets: (arg: ChangesetRangeArg) => Promise<ChangesetProps[]>;\r\n /** Push a changeset to iModelHub. Returns the newly pushed changeset's index */\r\n pushChangeset: (arg: IModelIdArg & { changesetProps: ChangesetFileProps }) => Promise<ChangesetIndex>;\r\n /** Get the ChangesetProps of the most recent changeset */\r\n getLatestChangeset: (arg: IModelIdArg) => Promise<ChangesetProps>;\r\n /** Get the ChangesetProps for an IModelVersion */\r\n getChangesetFromVersion: (arg: IModelIdArg & { version: IModelVersion }) => Promise<ChangesetProps>;\r\n /** Get the ChangesetProps for a named version */\r\n getChangesetFromNamedVersion: (arg: IModelIdArg & { versionName: string }) => Promise<ChangesetProps>;\r\n\r\n /** Acquire a new briefcaseId for the supplied iModelId\r\n * @note usually there should only be one briefcase per iModel per user.\r\n */\r\n acquireNewBriefcaseId: (arg: AcquireNewBriefcaseIdArg) => Promise<BriefcaseId>;\r\n /** Release a briefcaseId. After this call it is illegal to generate changesets for the released briefcaseId. */\r\n releaseBriefcase: (arg: BriefcaseIdArg) => Promise<void>;\r\n\r\n /** get an array of the briefcases assigned to a user. */\r\n getMyBriefcaseIds: (arg: IModelIdArg) => Promise<BriefcaseId[]>;\r\n\r\n /**\r\n * Download a v1 checkpoint\r\n * @deprecated in 3.x. V1 checkpoints are deprecated. Download V2 checkpoint using [[V2CheckpointManager.downloadCheckpoint]].\r\n * @internal\r\n */\r\n downloadV1Checkpoint: (arg: CheckpointArg) => Promise<ChangesetIndexAndId>; // eslint-disable-line deprecation/deprecation\r\n\r\n /**\r\n * Get the access props for a V2 checkpoint. Returns undefined if no V2 checkpoint exists.\r\n * @internal\r\n */\r\n queryV2Checkpoint: (arg: CheckpointProps) => Promise<V2CheckpointAccessProps | undefined>;\r\n\r\n /**\r\n * acquire one or more locks. Throws if unsuccessful. If *any* lock cannot be obtained, no locks are acquired\r\n * @internal\r\n */\r\n acquireLocks: (arg: BriefcaseDbArg, locks: LockMap) => Promise<void>;\r\n\r\n /**\r\n * Get the list of all held locks for a briefcase. This can be very expensive and is currently used only for tests.\r\n * @internal\r\n */\r\n queryAllLocks: (arg: BriefcaseDbArg) => Promise<LockProps[]>;\r\n\r\n /**\r\n * Release all currently held locks\r\n * @internal\r\n */\r\n releaseAllLocks: (arg: BriefcaseDbArg) => Promise<void>;\r\n\r\n /** Get the iModelId of an iModel by name. Undefined if no iModel with that name exists. */\r\n queryIModelByName: (arg: IModelNameArg) => Promise<GuidString | undefined>;\r\n\r\n /** create a new iModel. Returns the Guid of the newly created iModel */\r\n createNewIModel: (arg: CreateNewIModelProps) => Promise<GuidString>;\r\n\r\n /** delete an iModel */\r\n deleteIModel: (arg: IModelIdArg & ITwinIdArg) => Promise<void>;\r\n}\r\n"]}
@@ -9,7 +9,7 @@ export interface AzureBlobStorageCredentials {
9
9
  }
10
10
  /**
11
11
  * @beta
12
- * @deprecated in 3.x.
12
+ * @deprecated in 3.x. Use [[TileStorage]] instead.
13
13
  */
14
14
  export interface CloudStorageUploadOptions {
15
15
  type?: string;
@@ -18,7 +18,7 @@ export interface CloudStorageUploadOptions {
18
18
  }
19
19
  /**
20
20
  * @beta
21
- * @deprecated in 3.x.
21
+ * @deprecated in 3.x. Use [[TileStorage]] instead.
22
22
  */
23
23
  export declare abstract class CloudStorageService {
24
24
  initialize(): void;
@@ -34,7 +34,7 @@ export declare abstract class CloudStorageService {
34
34
  }
35
35
  /**
36
36
  * @beta
37
- * @deprecated in 3.x.
37
+ * @deprecated in 3.x. Use `@itwin/object-storage-oss` instead, see https://github.com/iTwin/object-storage for more details.
38
38
  */
39
39
  export declare class AzureBlobStorage extends CloudStorageService {
40
40
  private _service;
@@ -48,7 +48,7 @@ export declare class AzureBlobStorage extends CloudStorageService {
48
48
  }
49
49
  /**
50
50
  * @beta
51
- * @deprecated in 3.x.
51
+ * @deprecated in 3.x. Use [[TileStorage]] instead.
52
52
  */
53
53
  export declare class CloudStorageTileUploader {
54
54
  private _activeUploads;
@@ -14,7 +14,7 @@ const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
14
14
  const IModelHost_1 = require("./IModelHost");
15
15
  /**
16
16
  * @beta
17
- * @deprecated in 3.x.
17
+ * @deprecated in 3.x. Use [[TileStorage]] instead.
18
18
  */
19
19
  class CloudStorageService {
20
20
  initialize() { }
@@ -27,7 +27,7 @@ class CloudStorageService {
27
27
  exports.CloudStorageService = CloudStorageService;
28
28
  /**
29
29
  * @beta
30
- * @deprecated in 3.x.
30
+ * @deprecated in 3.x. Use `@itwin/object-storage-oss` instead, see https://github.com/iTwin/object-storage for more details.
31
31
  */
32
32
  class AzureBlobStorage extends CloudStorageService {
33
33
  constructor(credentials) {
@@ -130,7 +130,7 @@ class AzureBlobStorage extends CloudStorageService {
130
130
  exports.AzureBlobStorage = AzureBlobStorage;
131
131
  /**
132
132
  * @beta
133
- * @deprecated in 3.x.
133
+ * @deprecated in 3.x. Use [[TileStorage]] instead.
134
134
  */
135
135
  class CloudStorageTileUploader {
136
136
  constructor() {
@@ -1 +1 @@
1
- {"version":3,"file":"CloudStorageBackend.js","sourceRoot":"","sources":["../../src/CloudStorageBackend.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,mCAA+C;AAC/C,6BAA6B;AAC7B,6CAA6C;AAC7C,sDAAyD;AACzD,oDAG4B;A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,GAAG,GAAG,YAAY,GAAG,WAAW,CAAC;QAEvC,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;YAC9B,OAAO;QAET,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;QACrF,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACtC,MAAM,OAAO,CAAC;IAChB,CAAC;CACF;AA1CD,4DA0CC","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\nimport { PassThrough, Readable } from \"stream\";\r\nimport * as zlib from \"zlib\";\r\nimport * as Azure from \"@azure/storage-blob\";\r\nimport { Logger, PerfLogger } from \"@itwin/core-bentley\";\r\nimport {\r\n BentleyStatus, CloudStorageContainerDescriptor, CloudStorageContainerUrl, CloudStorageProvider, CloudStorageTileCache, IModelError, IModelRpcProps,\r\n TileContentIdentifier,\r\n} from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** @beta */\r\nexport interface AzureBlobStorageCredentials {\r\n account: string;\r\n accessKey: string;\r\n baseUrl?: string;\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x.\r\n */\r\nexport interface CloudStorageUploadOptions {\r\n type?: string;\r\n cacheControl?: string;\r\n contentEncoding?: \"gzip\";\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x.\r\n */\r\nexport abstract class CloudStorageService {\r\n public initialize(): void { }\r\n public terminate(): void { }\r\n public abstract id: CloudStorageProvider;\r\n public abstract obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl;\r\n public abstract upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string>;\r\n public async download(_name: string): Promise<Readable | undefined> { return undefined; }\r\n\r\n protected makeDescriptor(id: CloudStorageContainerDescriptor) {\r\n return { name: id.name, provider: this.id };\r\n }\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x.\r\n */\r\nexport class AzureBlobStorage extends CloudStorageService {\r\n private _service: Azure.BlobServiceClient;\r\n private _credential: Azure.StorageSharedKeyCredential;\r\n private _baseUrl: string;\r\n\r\n public constructor(credentials: AzureBlobStorageCredentials) {\r\n super();\r\n\r\n if (!credentials.account || !credentials.accessKey) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid credentials for Azure blob storage.\");\r\n }\r\n\r\n this._baseUrl = credentials.baseUrl ?? `https://${credentials.account}.blob.core.windows.net`;\r\n\r\n this._credential = new Azure.StorageSharedKeyCredential(credentials.account, credentials.accessKey);\r\n const options: Azure.StoragePipelineOptions = {};\r\n const pipeline = Azure.newPipeline(this._credential, options);\r\n this._service = new Azure.BlobServiceClient(this._baseUrl, pipeline);\r\n }\r\n\r\n public readonly id = CloudStorageProvider.Azure;\r\n\r\n public obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl {\r\n const policy: Azure.BlobSASSignatureValues = {\r\n containerName: id.name,\r\n permissions: Azure.ContainerSASPermissions.parse(\"rl\"),\r\n expiresOn: expiry,\r\n };\r\n\r\n if (clientIp && clientIp !== \"localhost\" && clientIp !== \"127.0.0.1\" && clientIp !== \"::1\") {\r\n policy.ipRange = { start: clientIp };\r\n }\r\n\r\n const token = Azure.generateBlobSASQueryParameters(policy, this._credential);\r\n const url = new URL(this._baseUrl);\r\n url.pathname = `${url.pathname.replace(/\\/*$/, \"\")}/${id.name}`;\r\n url.search = token.toString();\r\n\r\n const urlObject: CloudStorageContainerUrl = {\r\n descriptor: this.makeDescriptor(id),\r\n valid: 0,\r\n expires: expiry.getTime(),\r\n url: url.toString(),\r\n };\r\n\r\n return urlObject;\r\n }\r\n\r\n public async ensureContainer(name: string): Promise<void> {\r\n try {\r\n const container = this._service.getContainerClient(name);\r\n await container.create();\r\n return;\r\n } catch (maybeErr) {\r\n try {\r\n const err = maybeErr as Azure.RestError;\r\n if (err.statusCode === 409 && err.code === \"ContainerAlreadyExists\") {\r\n return;\r\n }\r\n } catch { }\r\n\r\n if (typeof (maybeErr) !== \"undefined\" && maybeErr) {\r\n throw maybeErr;\r\n }\r\n\r\n throw new IModelError(BentleyStatus.ERROR, `Unable to create container \"${name}\".`);\r\n }\r\n }\r\n\r\n public async upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string> {\r\n try {\r\n await this.ensureContainer(container);\r\n\r\n const containerClient = this._service.getContainerClient(container);\r\n const blocks = containerClient.getBlockBlobClient(name);\r\n const blobHTTPHeaders = {\r\n blobContentType: options?.type ?? \"application/octet-stream\",\r\n blobCacheControl: options?.cacheControl ?? \"private, max-age=31536000, immutable\",\r\n };\r\n\r\n const blobOptions: Azure.BlockBlobUploadStreamOptions = metadata ?\r\n {\r\n blobHTTPHeaders,\r\n metadata: { ...metadata },\r\n } : {\r\n blobHTTPHeaders,\r\n };\r\n\r\n const dataStream = new PassThrough();\r\n dataStream.end(data);\r\n\r\n let source: Readable;\r\n\r\n if (options && options.contentEncoding === \"gzip\") {\r\n if (undefined === blobOptions.blobHTTPHeaders)\r\n throw new IModelError(BentleyStatus.ERROR, \"Blob HTTP headers object is undefined.\");\r\n\r\n blobOptions.blobHTTPHeaders.blobContentEncoding = options.contentEncoding;\r\n const compressor = zlib.createGzip();\r\n source = dataStream.pipe(compressor);\r\n } else {\r\n source = dataStream;\r\n }\r\n\r\n const blockSize = 100 * 1024 * 1024;\r\n const concurrency = 1;\r\n const result = await blocks.uploadStream(source, blockSize, concurrency, blobOptions);\r\n return result.etag ?? \"\";\r\n } catch (maybeErr) {\r\n if (typeof (maybeErr) !== \"undefined\" && maybeErr) {\r\n throw maybeErr;\r\n }\r\n\r\n throw new IModelError(BentleyStatus.ERROR, `Unable to upload \"${name}\".`);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x.\r\n */\r\nexport class CloudStorageTileUploader {\r\n private _activeUploads: Map<string, Promise<void>> = new Map();\r\n\r\n public get activeUploads(): Iterable<Promise<void>> {\r\n return this._activeUploads.values();\r\n }\r\n\r\n private async uploadToCache(id: TileContentIdentifier, content: Uint8Array, containerKey: string, resourceKey: string, metadata?: object,) {\r\n await new Promise((resolve) => setTimeout(resolve));\r\n\r\n try {\r\n const options: CloudStorageUploadOptions = {};\r\n if (IModelHost.compressCachedTiles) {\r\n options.contentEncoding = \"gzip\";\r\n }\r\n\r\n const perfInfo = { ...id.tokenProps, treeId: id.treeId, contentId: id.contentId, size: content.byteLength, compress: IModelHost.compressCachedTiles };\r\n const perfLogger = new PerfLogger(\"Uploading tile to external tile cache\", () => perfInfo);\r\n await IModelHost.tileCacheService?.upload(containerKey, resourceKey, content, options, metadata);\r\n perfLogger.dispose();\r\n } catch (err) {\r\n Logger.logError(BackendLoggerCategory.IModelTileUpload, (err instanceof Error) ? err.toString() : JSON.stringify(err));\r\n }\r\n\r\n this._activeUploads.delete(containerKey + resourceKey);\r\n }\r\n\r\n public async cacheTile(tokenProps: IModelRpcProps, treeId: string, contentId: string, content: Uint8Array, guid: string | undefined, metadata?: object): Promise<void> {\r\n const id: TileContentIdentifier = { tokenProps, treeId, contentId, guid };\r\n\r\n const cache = CloudStorageTileCache.getCache();\r\n const containerKey = cache.formContainerName(id);\r\n const resourceKey = cache.formResourceName(id);\r\n const key = containerKey + resourceKey;\r\n\r\n if (this._activeUploads.has(key))\r\n return;\r\n\r\n const promise = this.uploadToCache(id, content, containerKey, resourceKey, metadata);\r\n this._activeUploads.set(key, promise);\r\n await promise;\r\n }\r\n}\r\n"]}
1
+ {"version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,QAAQ,EAAE,CAAC;QAC/C,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,WAAW,GAAG,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAC/C,MAAM,GAAG,GAAG,YAAY,GAAG,WAAW,CAAC;QAEvC,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;YAC9B,OAAO;QAET,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;QACrF,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACtC,MAAM,OAAO,CAAC;IAChB,CAAC;CACF;AA1CD,4DA0CC","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\nimport { PassThrough, Readable } from \"stream\";\r\nimport * as zlib from \"zlib\";\r\nimport * as Azure from \"@azure/storage-blob\";\r\nimport { Logger, PerfLogger } from \"@itwin/core-bentley\";\r\nimport {\r\n BentleyStatus, CloudStorageContainerDescriptor, CloudStorageContainerUrl, CloudStorageProvider, CloudStorageTileCache, IModelError, IModelRpcProps,\r\n TileContentIdentifier,\r\n} from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** @beta */\r\nexport interface AzureBlobStorageCredentials {\r\n account: string;\r\n accessKey: string;\r\n baseUrl?: string;\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x. Use [[TileStorage]] instead.\r\n */\r\nexport interface CloudStorageUploadOptions {\r\n type?: string;\r\n cacheControl?: string;\r\n contentEncoding?: \"gzip\";\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x. Use [[TileStorage]] instead.\r\n */\r\nexport abstract class CloudStorageService {\r\n public initialize(): void { }\r\n public terminate(): void { }\r\n public abstract id: CloudStorageProvider;\r\n public abstract obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl;\r\n public abstract upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string>;\r\n public async download(_name: string): Promise<Readable | undefined> { return undefined; }\r\n\r\n protected makeDescriptor(id: CloudStorageContainerDescriptor) {\r\n return { name: id.name, provider: this.id };\r\n }\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x. Use `@itwin/object-storage-oss` instead, see https://github.com/iTwin/object-storage for more details.\r\n */\r\nexport class AzureBlobStorage extends CloudStorageService {\r\n private _service: Azure.BlobServiceClient;\r\n private _credential: Azure.StorageSharedKeyCredential;\r\n private _baseUrl: string;\r\n\r\n public constructor(credentials: AzureBlobStorageCredentials) {\r\n super();\r\n\r\n if (!credentials.account || !credentials.accessKey) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid credentials for Azure blob storage.\");\r\n }\r\n\r\n this._baseUrl = credentials.baseUrl ?? `https://${credentials.account}.blob.core.windows.net`;\r\n\r\n this._credential = new Azure.StorageSharedKeyCredential(credentials.account, credentials.accessKey);\r\n const options: Azure.StoragePipelineOptions = {};\r\n const pipeline = Azure.newPipeline(this._credential, options);\r\n this._service = new Azure.BlobServiceClient(this._baseUrl, pipeline);\r\n }\r\n\r\n public readonly id = CloudStorageProvider.Azure;\r\n\r\n public obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl {\r\n const policy: Azure.BlobSASSignatureValues = {\r\n containerName: id.name,\r\n permissions: Azure.ContainerSASPermissions.parse(\"rl\"),\r\n expiresOn: expiry,\r\n };\r\n\r\n if (clientIp && clientIp !== \"localhost\" && clientIp !== \"127.0.0.1\" && clientIp !== \"::1\") {\r\n policy.ipRange = { start: clientIp };\r\n }\r\n\r\n const token = Azure.generateBlobSASQueryParameters(policy, this._credential);\r\n const url = new URL(this._baseUrl);\r\n url.pathname = `${url.pathname.replace(/\\/*$/, \"\")}/${id.name}`;\r\n url.search = token.toString();\r\n\r\n const urlObject: CloudStorageContainerUrl = {\r\n descriptor: this.makeDescriptor(id),\r\n valid: 0,\r\n expires: expiry.getTime(),\r\n url: url.toString(),\r\n };\r\n\r\n return urlObject;\r\n }\r\n\r\n public async ensureContainer(name: string): Promise<void> {\r\n try {\r\n const container = this._service.getContainerClient(name);\r\n await container.create();\r\n return;\r\n } catch (maybeErr) {\r\n try {\r\n const err = maybeErr as Azure.RestError;\r\n if (err.statusCode === 409 && err.code === \"ContainerAlreadyExists\") {\r\n return;\r\n }\r\n } catch { }\r\n\r\n if (typeof (maybeErr) !== \"undefined\" && maybeErr) {\r\n throw maybeErr;\r\n }\r\n\r\n throw new IModelError(BentleyStatus.ERROR, `Unable to create container \"${name}\".`);\r\n }\r\n }\r\n\r\n public async upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string> {\r\n try {\r\n await this.ensureContainer(container);\r\n\r\n const containerClient = this._service.getContainerClient(container);\r\n const blocks = containerClient.getBlockBlobClient(name);\r\n const blobHTTPHeaders = {\r\n blobContentType: options?.type ?? \"application/octet-stream\",\r\n blobCacheControl: options?.cacheControl ?? \"private, max-age=31536000, immutable\",\r\n };\r\n\r\n const blobOptions: Azure.BlockBlobUploadStreamOptions = metadata ?\r\n {\r\n blobHTTPHeaders,\r\n metadata: { ...metadata },\r\n } : {\r\n blobHTTPHeaders,\r\n };\r\n\r\n const dataStream = new PassThrough();\r\n dataStream.end(data);\r\n\r\n let source: Readable;\r\n\r\n if (options && options.contentEncoding === \"gzip\") {\r\n if (undefined === blobOptions.blobHTTPHeaders)\r\n throw new IModelError(BentleyStatus.ERROR, \"Blob HTTP headers object is undefined.\");\r\n\r\n blobOptions.blobHTTPHeaders.blobContentEncoding = options.contentEncoding;\r\n const compressor = zlib.createGzip();\r\n source = dataStream.pipe(compressor);\r\n } else {\r\n source = dataStream;\r\n }\r\n\r\n const blockSize = 100 * 1024 * 1024;\r\n const concurrency = 1;\r\n const result = await blocks.uploadStream(source, blockSize, concurrency, blobOptions);\r\n return result.etag ?? \"\";\r\n } catch (maybeErr) {\r\n if (typeof (maybeErr) !== \"undefined\" && maybeErr) {\r\n throw maybeErr;\r\n }\r\n\r\n throw new IModelError(BentleyStatus.ERROR, `Unable to upload \"${name}\".`);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x. Use [[TileStorage]] instead.\r\n */\r\nexport class CloudStorageTileUploader {\r\n private _activeUploads: Map<string, Promise<void>> = new Map();\r\n\r\n public get activeUploads(): Iterable<Promise<void>> {\r\n return this._activeUploads.values();\r\n }\r\n\r\n private async uploadToCache(id: TileContentIdentifier, content: Uint8Array, containerKey: string, resourceKey: string, metadata?: object,) {\r\n await new Promise((resolve) => setTimeout(resolve));\r\n\r\n try {\r\n const options: CloudStorageUploadOptions = {};\r\n if (IModelHost.compressCachedTiles) {\r\n options.contentEncoding = \"gzip\";\r\n }\r\n\r\n const perfInfo = { ...id.tokenProps, treeId: id.treeId, contentId: id.contentId, size: content.byteLength, compress: IModelHost.compressCachedTiles };\r\n const perfLogger = new PerfLogger(\"Uploading tile to external tile cache\", () => perfInfo);\r\n await IModelHost.tileCacheService?.upload(containerKey, resourceKey, content, options, metadata);\r\n perfLogger.dispose();\r\n } catch (err) {\r\n Logger.logError(BackendLoggerCategory.IModelTileUpload, (err instanceof Error) ? err.toString() : JSON.stringify(err));\r\n }\r\n\r\n this._activeUploads.delete(containerKey + resourceKey);\r\n }\r\n\r\n public async cacheTile(tokenProps: IModelRpcProps, treeId: string, contentId: string, content: Uint8Array, guid: string | undefined, metadata?: object): Promise<void> {\r\n const id: TileContentIdentifier = { tokenProps, treeId, contentId, guid };\r\n\r\n const cache = CloudStorageTileCache.getCache();\r\n const containerKey = cache.formContainerName(id);\r\n const resourceKey = cache.formResourceName(id);\r\n const key = containerKey + resourceKey;\r\n\r\n if (this._activeUploads.has(key))\r\n return;\r\n\r\n const promise = this.uploadToCache(id, content, containerKey, resourceKey, metadata);\r\n this._activeUploads.set(key, promise);\r\n await promise;\r\n }\r\n}\r\n"]}
@@ -256,8 +256,8 @@ export declare namespace CodeService {
256
256
  }
257
257
  /** A code Scope guid, and code spec name. */
258
258
  interface ScopeAndSpec {
259
- readonly spec: CodeSpecName;
260
- readonly scope: ScopeGuid;
259
+ readonly specName: CodeSpecName;
260
+ readonly scopeGuid: ScopeGuid;
261
261
  }
262
262
  /** A code Scope guid, code spec, and code value. */
263
263
  interface ScopeSpecAndValue extends ScopeAndSpec {
@@ -266,9 +266,9 @@ export declare namespace CodeService {
266
266
  /** The data held in a code index for a single code. */
267
267
  interface CodeEntry {
268
268
  /** The name of the code spec for this code. */
269
- readonly spec: CodeSpecName;
269
+ readonly specName: CodeSpecName;
270
270
  /** The guid of the entity that provides the scope for this code. */
271
- readonly scope: ScopeGuid;
271
+ readonly scopeGuid: ScopeGuid;
272
272
  /** The value of this code. */
273
273
  readonly value: CodeValue;
274
274
  /** The guid of the entity this code identifies. */
@@ -296,9 +296,9 @@ export declare namespace CodeService {
296
296
  /** A filter to limit and/or sort the values for the [[CodeIndex.forAllCodes]] iteration. */
297
297
  interface CodeFilter extends ValueFilter {
298
298
  /** If supplied, limit results to only those with this spec */
299
- readonly spec?: CodeSpecName;
299
+ readonly specName?: CodeSpecName;
300
300
  /** If supplied, limit results to only those with this scope Guid */
301
- readonly scope?: ScopeGuid;
301
+ readonly scopeGuid?: ScopeGuid;
302
302
  /** If supplied, limit results to only those with this origin */
303
303
  readonly origin?: CodeOriginName;
304
304
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CodeService.d.ts","sourceRoot":"","sources":["../../src/CodeService.ts"],"names":[],"m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c,EAAE,GAAG,aAAa,EAAE,CAAC;QAE9D,gBAAgB;oBACJ,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,EAAE,GAAG,aAAa,EAAE;KAK7G;IAED;;OAEG;IACH,KAAY,OAAO,GACjB,eAAe,GACf,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,aAAa,GACb,cAAc,GACd,cAAc,GACd,eAAe,GACf,kBAAkB,GAClB,aAAa,GACb,iBAAiB,GACjB,aAAa,GACb,aAAa,GACb,cAAc,GACd,aAAa,GACb,aAAa,GACb,cAAc,GACd,eAAe,GACf,kBAAkB,GAClB,eAAe,GACf,cAAc,GACd,cAAc,GACd,cAAc,CAAC;CAElB"}
@@ -33,10 +33,10 @@ var CodeService;
33
33
  * converts the spec Id to the spec name and looks up the `FederationGuid` of the scope element.
34
34
  */
35
35
  function makeScopeAndSpec(iModel, code) {
36
- const scope = iModel.elements.getElementProps({ id: code.scope, onlyBaseProperties: true }).federationGuid;
37
- if (undefined === scope)
36
+ const scopeGuid = iModel.elements.getElementProps({ id: code.scope, onlyBaseProperties: true }).federationGuid;
37
+ if (undefined === scopeGuid)
38
38
  throw new CodeService.Error("MissingGuid", core_bentley_1.IModelStatus.InvalidCode, "code scope element has no federationGuid");
39
- return { scope, spec: iModel.codeSpecs.getById(code.spec).name };
39
+ return { scopeGuid, specName: iModel.codeSpecs.getById(code.spec).name };
40
40
  }
41
41
  CodeService.makeScopeAndSpec = makeScopeAndSpec;
42
42
  /** Turn a `CodeProps` and `ProposedCodeProps` into a `ProposedCode` for use with a CodeService.
@@ -1 +1 @@
1
- {"version":3,"file":"CodeService.js","sourceRoot":"","sources":["../../src/CodeService.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAiH;AA+KjH,aAAa;AACb,IAAiB,WAAW,CA6U3B;AA7UD,WAAiB,WAAW;IAC1B,gBAAgB;IAChB,MAA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J,CAAC;IANe,4BAAgB,mBAM/B,CAAA;IAqPD,uDAAuD;IACvD,MAAa,KAAM,SAAQ,2BAAY;QAMrC,gBAAgB;QAChB,YAAY,OAAgB,EAAE,MAAc,EAAE,OAAe,EAAE,QAA6C;YAC1G,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC3B,CAAC;KACF;IAZY,iBAAK,QAYjB,CAAA;AA8BH,CAAC,EA7UgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA6U3B","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\r\nimport { AccessToken, BentleyError, GuidString, IModelStatus, MarkRequired, Mutable } from \"@itwin/core-bentley\";\r\nimport { CodeProps } from \"@itwin/core-common\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { SettingObject } from \"./workspace/Settings\";\r\n\r\n/**\r\n * A readonly index of all known Codes for an iTwin. The CodeIndex may be slightly out-of-date\r\n * with the master copy in the cloud, but it should be periodically synchronized. Whenever codes are reserved/updated/deleted\r\n * locally, this copy is always up-to-date as of those changes.\r\n * @alpha\r\n */\r\nexport interface CodeIndex {\r\n /**\r\n * Find the next available value for the supplied `SequenceScope`.\r\n * If the sequence is full (there are no available values), this will throw an exception with `errorId=\"SequenceFull\"`\r\n * @param from the sequence and scope to search\r\n * @returns the next available CodeValue in the sequence.\r\n */\r\n findNextAvailable(from: CodeService.SequenceScope): CodeService.CodeValue;\r\n\r\n /**\r\n * Find the highest currently used value for the supplied `SequenceScope`\r\n * @param from the sequence and scope to search\r\n * @returns the highest used value, or undefined if no values have been used.\r\n */\r\n findHighestUsed(from: CodeService.SequenceScope): CodeService.CodeValue | undefined;\r\n\r\n /** Determine whether a code is present in this CodeIndex by its Guid. */\r\n isCodePresent(guid: CodeService.CodeGuid): boolean;\r\n\r\n /** Get the data for a code in this CodeIndex by its Guid.\r\n * @returns the data for the code or undefined if no code is present for the supplied Guid.\r\n */\r\n getCode(guid: CodeService.CodeGuid): CodeService.CodeEntry | undefined;\r\n\r\n /** Look up a code by its Scope, Spec, and Value.\r\n * @returns the Guid of the code, or undefined if not present.\r\n */\r\n findCode(code: CodeService.ScopeSpecAndValue): CodeService.CodeGuid | undefined;\r\n\r\n /** Look up a code spec by its name\r\n * @throws if the spec is not present.\r\n */\r\n getCodeSpec(props: CodeService.CodeSpecName): CodeService.NameAndJson;\r\n\r\n /** Call a `CodeIteration` function for all codes in this index, optionally filtered by a `CodeFilter ` */\r\n forAllCodes(iter: CodeService.CodeIteration, filter?: CodeService.CodeFilter): void;\r\n\r\n /** Call an iteration function for all code specs in this index, optionally filtered by a `ValueFilter ` */\r\n forAllCodeSpecs(iter: CodeService.NameAndJsonIteration, filter?: CodeService.ValueFilter): void;\r\n}\r\n\r\n/**\r\n * The services for querying, reserving, updating, and deleting codes for a BriefcaseDb (available via `BriefcaseDb.codeService`) whenever it is opened for write access.\r\n * @alpha\r\n */\r\nexport interface CodeService {\r\n /** @internal */\r\n close: () => void;\r\n\r\n /** @internal */\r\n addAllCodeSpecs(iModel: IModelDb): Promise<void>;\r\n\r\n /** the code index for this CodeService */\r\n readonly codeIndex: CodeIndex;\r\n\r\n /**\r\n * Application-supplied parameters for obtaining the write lock on the container.\r\n * Applications should set these parameters by adding a listener for `BriefcaseDb.onCodeServiceCreated`\r\n * that is called every time a BriefcaseDb that uses code services is opened for write access.\r\n */\r\n readonly lockParams: CloudSqlite.ObtainLockParams;\r\n\r\n /**\r\n * Application-supplied parameters for reserving new codes.\r\n * @see lockParams\r\n */\r\n readonly appParams: CodeService.AuthorAndOrigin;\r\n\r\n /**\r\n * The token that grants access to the cloud container for this CodeService.\r\n * It should be established in a listener for `BriefcaseDb.onCodeServiceCreated`, and should be refreshed (via a\r\n * timer) before it expires.\r\n */\r\n sasToken: AccessToken;\r\n\r\n /**\r\n * Synchronize the local index with any changes by made by others.\r\n * @note This is called automatically whenever any write operation is performed on the code index. It is only necessary to\r\n * call this directly if you have not changed the code index recently, but wish to perform a readonly operation and want to\r\n * ensure it is up-to-date as of now.\r\n * @note There is no guarantee that a readonly index is up-to-date even immediately after calling this method, since others\r\n * may be modifying it at any time.\r\n */\r\n synchronizeWithCloud(): void;\r\n\r\n /**\r\n * Verify that the Code of a to-be-inserted or to-be-updated Element:\r\n * 1. has already been reserved,\r\n * 2. if the element has a `federationGuid`, it must match the reserved value. If the federationGuid is undefined,\r\n * the value from the code index is returned.\r\n *\r\n * If not, throw an exception. Elements with no CodeValue are ignored.\r\n * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.\r\n */\r\n verifyCode(props: CodeService.ElementCodeProps): void;\r\n\r\n /** Add a new code spec to this code service.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n addCodeSpec(val: CodeService.NameAndJson): Promise<void>;\r\n\r\n /**\r\n * Add all of the codes and code specs from this CodeService's BriefcaseDb into the code index.\r\n * @returns the number of codes actually added.\r\n * @note It is not necessary to call this method unless the BriefcaseDb somehow becomes out of sync with its CodeService,\r\n * for example when migrating iModels to a new code service. It is safe (but relatively expensive) to call this method multiple times, since\r\n * any codes or code specs that are already in the index are ignored.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n addAllCodes(iModel: IModelDb): Promise<number>;\r\n\r\n /**\r\n * Attempt to reserve a single proposed code.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n * @throws `CodeService.Error` if the proposed code cannot be reserved.\r\n */\r\n reserveCode(code: CodeService.ProposedCode): Promise<void>;\r\n\r\n /**\r\n * Attempt to reserve an array of proposed codes.\r\n * @returns number of codes actually reserved.\r\n * @see the `problems` member of the `CodeService.Error` exception\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n * @note If you have a set of codes to reserve, it is considerably more efficient to do them as an array rather than one at a time.\r\n * @throws `CodeService.Error` if any of the proposed code cannot be reserved. The details for each failed code are in the `problems` member.\r\n */\r\n reserveCodes(arg: CodeService.ReserveCodesArgs): Promise<number>;\r\n\r\n /**\r\n * Attempt to reserve the next available code for a code sequence and scope.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n reserveNextAvailableCode(arg: CodeService.ReserveNextArgs): Promise<void>;\r\n\r\n /**\r\n * Attempt to reserve an array of the next available codes for a code sequence and scope.\r\n * The length of the array determines the number of codes requested. The values for the new codes are returned\r\n * in the array, so they can be associated with the supplied GUIDs.\r\n * @returns number of codes actually reserved.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n reserveNextAvailableCodes(arg: CodeService.ReserveNextArrayArgs): Promise<number>;\r\n\r\n /**\r\n * Update the properties of a single code.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n updateCode(props: CodeService.UpdatedCode): Promise<void>;\r\n\r\n /**\r\n * Update the properties of an array codes.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n * @note If you have a set of codes to update, it is considerably more efficient to do them as an array rather than one at a time.\r\n * @returns number of codes actually updated.\r\n */\r\n updateCodes(arg: CodeService.UpdateCodesArgs): Promise<number>;\r\n\r\n /** Delete an array of codes by their guids.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n deleteCodes(guid: CodeService.CodeGuid[]): Promise<void>;\r\n}\r\n\r\n/** @alpha */\r\nexport namespace CodeService {\r\n /** @internal */\r\n const codeSequences = new Map<string, CodeSequence>();\r\n\r\n /** @internal */\r\n export let createForIModel: ((db: IModelDb) => CodeService) | undefined;\r\n\r\n /** Register an instance of a`CodeSequence` so it can be looked up by name. */\r\n export function registerSequence(seq: CodeSequence) {\r\n codeSequences.set(seq.sequenceName, seq);\r\n }\r\n\r\n /** Get a previously registered `CodeSequence` by its name.\r\n * @throws if no sequence by that name was registered.\r\n */\r\n export function getSequence(name: string): CodeSequence {\r\n const seq = codeSequences.get(name);\r\n if (!seq)\r\n throw new Error(\"SequenceNotFound\", -1, `code sequence ${name} not found`);\r\n return seq;\r\n }\r\n\r\n /**\r\n * Turn a `CodePops` for the briefcase of this CodeService into a `ScopeAndSpec` object for use with a CodeService.\r\n * This is necessary because the `spec` member of `CodeProps` refers to the id of a code spec in the iModel, and\r\n * the `scope` member refers to the element Id of the scope element in the iModel. This helper function\r\n * converts the spec Id to the spec name and looks up the `FederationGuid` of the scope element.\r\n */\r\n export function makeScopeAndSpec(iModel: IModelDb, code: CodeProps): CodeService.ScopeAndSpec {\r\n const scope = iModel.elements.getElementProps({ id: code.scope, onlyBaseProperties: true }).federationGuid;\r\n if (undefined === scope)\r\n throw new CodeService.Error(\"MissingGuid\", IModelStatus.InvalidCode, \"code scope element has no federationGuid\");\r\n\r\n return { scope, spec: iModel.codeSpecs.getById(code.spec).name };\r\n }\r\n\r\n /** Turn a `CodeProps` and `ProposedCodeProps` into a `ProposedCode` for use with a CodeService.\r\n * @see [[makeScopeAndSpec]] for explanation of why this is necessary.\r\n */\r\n export function makeProposedCode(arg: CodeService.MakeProposedCodeArgs): CodeService.ProposedCode {\r\n return {\r\n ...arg.props,\r\n value: arg.code.value,\r\n ...makeScopeAndSpec(arg.iModel, arg.code),\r\n };\r\n }\r\n\r\n /** The name of a code spec */\r\n export type CodeSpecName = string;\r\n\r\n /** The name that identifies the \"originator\" of a code. Usually this is the Guid of the iModel from which a code was added,\r\n * but can also be used to identify a system or type from an external code service. */\r\n export type CodeOriginName = string;\r\n\r\n /** The name that identifies the \"author\" of a code. Generally, this is intended to be the name of a person or group that helps identify the purpose of the code. */\r\n export type AuthorName = string;\r\n\r\n /** The value for a code. */\r\n export type CodeValue = string;\r\n\r\n /** The guid for a code. This identifies the real-world entity associated with the code. */\r\n export type CodeGuid = GuidString;\r\n\r\n /** The guid of the scope for a code. This identifies the real-world entity that provides the uniqueness scope for code values. */\r\n export type ScopeGuid = GuidString;\r\n\r\n /** An optional number associated with a code that may be used for \"status\" information. Values must be defined by applications. */\r\n export type CodeState = number;\r\n\r\n /** The return status of an iteration function. The value \"stop\" causes the iteration to terminate. */\r\n export type IterationReturn = void | \"stop\";\r\n\r\n /** An iteration function over codes in a code index. It is called with the Guid of a each code. */\r\n export type CodeIteration = (guid: GuidString) => IterationReturn;\r\n\r\n /** An iteration function over code specs in a code index. It is called with the name and json of a each code spec. */\r\n export type NameAndJsonIteration = (nameAndJson: NameAndJson) => IterationReturn;\r\n\r\n /** Argument for reserving an array of new codes. */\r\n export interface ReserveCodesArgs {\r\n /** an array of proposed codes to reserve.\r\n * @note the guid of each proposed code must be supplied by the caller.\r\n */\r\n readonly codes: CodeService.ProposedCode[];\r\n /** If true, unless all codes are available, don't reserve any codes. Otherwise reserve all available codes. */\r\n readonly allOrNothing?: true;\r\n }\r\n\r\n /** Argument for reserving a code from a code sequence. */\r\n export interface ReserveNextArgs {\r\n /** the properties of the new code */\r\n readonly code: CodeService.ProposedCodeProps;\r\n /** The code sequence and scope for the new code. */\r\n readonly from: SequenceScope;\r\n }\r\n\r\n /** Argument for reserving an array of codes from a code sequence. */\r\n export interface ReserveNextArrayArgs {\r\n /** an array of proposed codes to reserve. */\r\n readonly codes: CodeService.ProposedCodeProps[];\r\n /** The code sequence and scope for the new codes. */\r\n readonly from: CodeService.SequenceScope;\r\n /** If true, and in the event that the code sequence does not have enough available codes to fulfill all the entries in `codes`,\r\n * return as many as possible. Otherwise no codes are reserved. The `problems` member of the exception can be used to determine how many codes were available.\r\n * @note if `asManyAsPossible` is true, no error is thrown if the sequence becomes full. You must check the return value to see how many\r\n * were actually available. The `value` member will be undefined for any proposed codes that were not reserved.\r\n */\r\n readonly asManyAsPossible?: true;\r\n }\r\n\r\n /** Argument for updating an array of codes. */\r\n export interface UpdateCodesArgs {\r\n /** Properties of the codes to update */\r\n readonly props: CodeService.UpdatedCode[];\r\n /** If true, unless all codes are updated, don't update any codes. Otherwise update all possible codes. */\r\n readonly allOrNothing?: true;\r\n }\r\n\r\n /** Arguments for CodeService.makeProposedCode */\r\n export interface MakeProposedCodeArgs {\r\n readonly iModel: IModelDb;\r\n readonly code: Required<CodeProps>;\r\n readonly props: CodeService.CodeGuidStateJson;\r\n }\r\n\r\n /** The properties of an Element to be checked against the code index.\r\n * @see CodeService.verifyCode\r\n */\r\n export interface ElementCodeProps {\r\n /** iModel from which the code is being inserted/updated. */\r\n readonly iModel: IModelDb;\r\n /** Properties of the code */\r\n readonly props: {\r\n /** The imodel-specific code properties. */\r\n readonly code: CodeProps;\r\n /**\r\n * The federationGuid of the element being inserted or updated.\r\n * If federationGuid is defined, it is must match the value in the code index or an error is thrown.\r\n * If it is undefined, the value from the code index is returned here.\r\n */\r\n federationGuid?: GuidString;\r\n };\r\n }\r\n\r\n /** a name and a json object. Used for code specs, authors and origins. */\r\n export interface NameAndJson {\r\n readonly name: string;\r\n readonly json?: SettingObject;\r\n }\r\n\r\n /** A code Scope guid, and code spec name. */\r\n export interface ScopeAndSpec {\r\n readonly spec: CodeSpecName;\r\n readonly scope: ScopeGuid;\r\n }\r\n\r\n /** A code Scope guid, code spec, and code value. */\r\n export interface ScopeSpecAndValue extends ScopeAndSpec {\r\n readonly value: CodeValue;\r\n }\r\n\r\n /** The data held in a code index for a single code. */\r\n export interface CodeEntry {\r\n /** The name of the code spec for this code. */\r\n readonly spec: CodeSpecName;\r\n /** The guid of the entity that provides the scope for this code. */\r\n readonly scope: ScopeGuid;\r\n /** The value of this code. */\r\n readonly value: CodeValue;\r\n /** The guid of the entity this code identifies. */\r\n readonly guid: CodeGuid;\r\n /** the state of the code. May be undefined. */\r\n readonly state?: CodeState;\r\n /** The name of the originating source of this code (usually an iModel Guid). May be undefined. */\r\n readonly origin: CodeOriginName;\r\n /** The name of the author of this code. May be undefined. */\r\n readonly author?: AuthorName;\r\n /** Option json properties associated with this code. May be undefined. */\r\n readonly json?: SettingObject;\r\n }\r\n\r\n /** A filter used to limit and/or sort the values returned by an iteration. */\r\n export interface ValueFilter {\r\n /** A value filter. May include wild cards when used with `GLOB` or `LIKE` */\r\n readonly value?: string;\r\n /** The comparison operator for `value`. Default is `=` */\r\n readonly valueCompare?: \"GLOB\" | \"LIKE\" | \"NOT GLOB\" | \"NOT LIKE\" | \"=\" | \"<\" | \">\";\r\n /** Order results ascending or descending. If not supplied, the results are unordered (random). */\r\n readonly orderBy?: \"ASC\" | \"DESC\";\r\n /** An SQL expression to further filter results. This string is appended to the `WHERE` clause with an `AND` (that should not be part of the sqlExpression) */\r\n readonly sqlExpression?: string;\r\n }\r\n\r\n /** A filter to limit and/or sort the values for the [[CodeIndex.forAllCodes]] iteration. */\r\n export interface CodeFilter extends ValueFilter {\r\n /** If supplied, limit results to only those with this spec */\r\n readonly spec?: CodeSpecName;\r\n /** If supplied, limit results to only those with this scope Guid */\r\n readonly scope?: ScopeGuid;\r\n /** If supplied, limit results to only those with this origin */\r\n readonly origin?: CodeOriginName;\r\n }\r\n\r\n /** Author and origin information supplied when codes are reserved. */\r\n export interface AuthorAndOrigin {\r\n /** The name of the individual or group for whom the code was reserved. */\r\n readonly author: Mutable<NameAndJson>;\r\n /** The identity of the \"originator\" of the code. This is usually a guid of an iModel, but can be any unique string. */\r\n readonly origin: Mutable<NameAndJson>;\r\n }\r\n\r\n /** The Guid, state, and json properties of a code. */\r\n export interface CodeGuidStateJson {\r\n /** The Guid of the new code. This must be always be supplied by the application. */\r\n readonly guid: CodeGuid;\r\n /** An optional value for the state of the code. */\r\n readonly state?: CodeState;\r\n /** An optional json object to be stored with the code. */\r\n readonly json?: SettingObject;\r\n }\r\n\r\n /** Properties of a \"proposed\" new code to be reserved.\r\n * @note the Guid of the entity identified by this code *must* be supplied, but `value` is optional, since\r\n * this may be used to reserve codes from a sequence where the value is generated.\r\n */\r\n export interface ProposedCodeProps extends CodeGuidStateJson {\r\n /** The value for the proposed code.\r\n * @note For code sequence operations, this value is ignored on input and is set with a new value from the sequence on successful return.\r\n */\r\n value?: CodeValue;\r\n }\r\n\r\n /** Properties of a proposed new code that is not from a code sequence (its `value` is required). */\r\n export type ProposedCode = ProposedCodeProps & ScopeSpecAndValue;\r\n\r\n /** Properties that describe a code sequence and a scope and spec for a proposed code or array of codes from a sequence. */\r\n export interface SequenceScope extends ScopeAndSpec {\r\n /** The code sequence. */\r\n readonly seq: CodeSequence;\r\n /** A valid current value. If supplied, the returned value will always be later in the sequence than this. */\r\n readonly start?: CodeValue;\r\n }\r\n\r\n /** Properties of a code to be updated.\r\n * @note The `guid` member identifies the code to be updated and is required.\r\n * All other properties are optional - if `undefined`, its value is not changed.\r\n */\r\n export type UpdatedCode = MarkRequired<Partial<ProposedCode>, \"guid\">;\r\n\r\n /** A proposed code that could not be reserved due to some error. */\r\n export interface ReserveProblem {\r\n /** the proposed code that failed. */\r\n readonly code: ProposedCode;\r\n /** the reason for the failure */\r\n readonly errorId: ErrorId;\r\n /** the error message from the exception for this proposed code. */\r\n readonly message: string;\r\n }\r\n\r\n /** A update to a code that failed for some error. */\r\n export interface UpdateProblem {\r\n /** The properties of the code that was to be updated */\r\n readonly prop: UpdatedCode;\r\n /** the reason for the failure */\r\n readonly errorId: ErrorId;\r\n /** the error message from the exception for the update request. */\r\n readonly message: string;\r\n }\r\n\r\n /**\r\n * A sequence of code values following a increasing pattern. Valid code sequences must have a first value, a last value, and\r\n * a way to get the next valid value from an existing valid value.\r\n * Code sequences have a `sequenceName` so they can be registered using `CodeService.registerSequence`.\r\n */\r\n export interface CodeSequence {\r\n /** the name of this CodeSequence. */\r\n get sequenceName(): string;\r\n /** Get the first valid value for this CodeSequence */\r\n getFirstValue(): CodeValue;\r\n /** Get the last valid value for this CodeSequence */\r\n getLastValue(): CodeValue;\r\n /** Get the next valid value for this CodeSequence from the supplied value.\r\n * If the sequence is full (that is, the next value is greater than the last value, this method should throw with errorId=\"SequenceFull\".\r\n * @return the next valid value according to the rules of this CodeSequence.\r\n */\r\n getNextValue(code: CodeValue): CodeValue;\r\n /** Determine whether this supplied value is valid for this sequence. */\r\n isValidCode(code: CodeValue): boolean;\r\n }\r\n\r\n /** Exception class thrown by `CodeService` methods. */\r\n export class Error extends BentleyError {\r\n /** A string that indicates the type of problem that caused the exception. */\r\n public readonly errorId: ErrorId;\r\n /** For [[CodeService.reserveCodes]] and [[CodeService.updateCodes]], a list of the problem details. */\r\n public readonly problems?: ReserveProblem[] | UpdateProblem[];\r\n\r\n /** @internal */\r\n constructor(errorId: ErrorId, errNum: number, message: string, problems?: ReserveProblem[] | UpdateProblem[]) {\r\n super(errNum, message);\r\n this.errorId = errorId;\r\n this.problems = problems;\r\n }\r\n }\r\n\r\n /** Identifiers for exceptions thrown by `CodeService` methods.\r\n * @see [[CodeService.Error.errorId]]\r\n */\r\n export type ErrorId =\r\n \"BadIndexProps\" |\r\n \"CorruptIModel\" |\r\n \"CorruptIndex\" |\r\n \"DuplicateValue\" |\r\n \"GuidIsInUse\" |\r\n \"GuidMismatch\" |\r\n \"IllegalValue\" |\r\n \"IndexReadonly\" |\r\n \"InvalidCodeScope\" |\r\n \"InvalidGuid\" |\r\n \"InvalidSequence\" |\r\n \"MissingCode\" |\r\n \"MissingGuid\" |\r\n \"MissingInput\" |\r\n \"MissingSpec\" |\r\n \"NoCodeIndex\" |\r\n \"SequenceFull\" |\r\n \"ReserveErrors\" |\r\n \"SequenceNotFound\" |\r\n \"SqlLogicError\" |\r\n \"UpdateErrors\" |\r\n \"ValueIsInUse\" |\r\n \"WrongVersion\";\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"CodeService.js","sourceRoot":"","sources":["../../src/CodeService.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAiH;AA+KjH,aAAa;AACb,IAAiB,WAAW,CA6U3B;AA7UD,WAAiB,WAAW;IAC1B,gBAAgB;IAChB,MAAM,aAAa,GAAG,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e,4BAAgB,mBAM/B,CAAA;IAqPD,uDAAuD;IACvD,MAAa,KAAM,SAAQ,2BAAY;QAMrC,gBAAgB;QAChB,YAAY,OAAgB,EAAE,MAAc,EAAE,OAAe,EAAE,QAA6C;YAC1G,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC3B,CAAC;KACF;IAZY,iBAAK,QAYjB,CAAA;AA8BH,CAAC,EA7UgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA6U3B","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\r\nimport { AccessToken, BentleyError, GuidString, IModelStatus, MarkRequired, Mutable } from \"@itwin/core-bentley\";\r\nimport { CodeProps } from \"@itwin/core-common\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { SettingObject } from \"./workspace/Settings\";\r\n\r\n/**\r\n * A readonly index of all known Codes for an iTwin. The CodeIndex may be slightly out-of-date\r\n * with the master copy in the cloud, but it should be periodically synchronized. Whenever codes are reserved/updated/deleted\r\n * locally, this copy is always up-to-date as of those changes.\r\n * @alpha\r\n */\r\nexport interface CodeIndex {\r\n /**\r\n * Find the next available value for the supplied `SequenceScope`.\r\n * If the sequence is full (there are no available values), this will throw an exception with `errorId=\"SequenceFull\"`\r\n * @param from the sequence and scope to search\r\n * @returns the next available CodeValue in the sequence.\r\n */\r\n findNextAvailable(from: CodeService.SequenceScope): CodeService.CodeValue;\r\n\r\n /**\r\n * Find the highest currently used value for the supplied `SequenceScope`\r\n * @param from the sequence and scope to search\r\n * @returns the highest used value, or undefined if no values have been used.\r\n */\r\n findHighestUsed(from: CodeService.SequenceScope): CodeService.CodeValue | undefined;\r\n\r\n /** Determine whether a code is present in this CodeIndex by its Guid. */\r\n isCodePresent(guid: CodeService.CodeGuid): boolean;\r\n\r\n /** Get the data for a code in this CodeIndex by its Guid.\r\n * @returns the data for the code or undefined if no code is present for the supplied Guid.\r\n */\r\n getCode(guid: CodeService.CodeGuid): CodeService.CodeEntry | undefined;\r\n\r\n /** Look up a code by its Scope, Spec, and Value.\r\n * @returns the Guid of the code, or undefined if not present.\r\n */\r\n findCode(code: CodeService.ScopeSpecAndValue): CodeService.CodeGuid | undefined;\r\n\r\n /** Look up a code spec by its name\r\n * @throws if the spec is not present.\r\n */\r\n getCodeSpec(props: CodeService.CodeSpecName): CodeService.NameAndJson;\r\n\r\n /** Call a `CodeIteration` function for all codes in this index, optionally filtered by a `CodeFilter ` */\r\n forAllCodes(iter: CodeService.CodeIteration, filter?: CodeService.CodeFilter): void;\r\n\r\n /** Call an iteration function for all code specs in this index, optionally filtered by a `ValueFilter ` */\r\n forAllCodeSpecs(iter: CodeService.NameAndJsonIteration, filter?: CodeService.ValueFilter): void;\r\n}\r\n\r\n/**\r\n * The services for querying, reserving, updating, and deleting codes for a BriefcaseDb (available via `BriefcaseDb.codeService`) whenever it is opened for write access.\r\n * @alpha\r\n */\r\nexport interface CodeService {\r\n /** @internal */\r\n close: () => void;\r\n\r\n /** @internal */\r\n addAllCodeSpecs(iModel: IModelDb): Promise<void>;\r\n\r\n /** the code index for this CodeService */\r\n readonly codeIndex: CodeIndex;\r\n\r\n /**\r\n * Application-supplied parameters for obtaining the write lock on the container.\r\n * Applications should set these parameters by adding a listener for `BriefcaseDb.onCodeServiceCreated`\r\n * that is called every time a BriefcaseDb that uses code services is opened for write access.\r\n */\r\n readonly lockParams: CloudSqlite.ObtainLockParams;\r\n\r\n /**\r\n * Application-supplied parameters for reserving new codes.\r\n * @see lockParams\r\n */\r\n readonly appParams: CodeService.AuthorAndOrigin;\r\n\r\n /**\r\n * The token that grants access to the cloud container for this CodeService.\r\n * It should be established in a listener for `BriefcaseDb.onCodeServiceCreated`, and should be refreshed (via a\r\n * timer) before it expires.\r\n */\r\n sasToken: AccessToken;\r\n\r\n /**\r\n * Synchronize the local index with any changes by made by others.\r\n * @note This is called automatically whenever any write operation is performed on the code index. It is only necessary to\r\n * call this directly if you have not changed the code index recently, but wish to perform a readonly operation and want to\r\n * ensure it is up-to-date as of now.\r\n * @note There is no guarantee that a readonly index is up-to-date even immediately after calling this method, since others\r\n * may be modifying it at any time.\r\n */\r\n synchronizeWithCloud(): void;\r\n\r\n /**\r\n * Verify that the Code of a to-be-inserted or to-be-updated Element:\r\n * 1. has already been reserved,\r\n * 2. if the element has a `federationGuid`, it must match the reserved value. If the federationGuid is undefined,\r\n * the value from the code index is returned.\r\n *\r\n * If not, throw an exception. Elements with no CodeValue are ignored.\r\n * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.\r\n */\r\n verifyCode(props: CodeService.ElementCodeProps): void;\r\n\r\n /** Add a new code spec to this code service.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n addCodeSpec(val: CodeService.NameAndJson): Promise<void>;\r\n\r\n /**\r\n * Add all of the codes and code specs from this CodeService's BriefcaseDb into the code index.\r\n * @returns the number of codes actually added.\r\n * @note It is not necessary to call this method unless the BriefcaseDb somehow becomes out of sync with its CodeService,\r\n * for example when migrating iModels to a new code service. It is safe (but relatively expensive) to call this method multiple times, since\r\n * any codes or code specs that are already in the index are ignored.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n addAllCodes(iModel: IModelDb): Promise<number>;\r\n\r\n /**\r\n * Attempt to reserve a single proposed code.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n * @throws `CodeService.Error` if the proposed code cannot be reserved.\r\n */\r\n reserveCode(code: CodeService.ProposedCode): Promise<void>;\r\n\r\n /**\r\n * Attempt to reserve an array of proposed codes.\r\n * @returns number of codes actually reserved.\r\n * @see the `problems` member of the `CodeService.Error` exception\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n * @note If you have a set of codes to reserve, it is considerably more efficient to do them as an array rather than one at a time.\r\n * @throws `CodeService.Error` if any of the proposed code cannot be reserved. The details for each failed code are in the `problems` member.\r\n */\r\n reserveCodes(arg: CodeService.ReserveCodesArgs): Promise<number>;\r\n\r\n /**\r\n * Attempt to reserve the next available code for a code sequence and scope.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n reserveNextAvailableCode(arg: CodeService.ReserveNextArgs): Promise<void>;\r\n\r\n /**\r\n * Attempt to reserve an array of the next available codes for a code sequence and scope.\r\n * The length of the array determines the number of codes requested. The values for the new codes are returned\r\n * in the array, so they can be associated with the supplied GUIDs.\r\n * @returns number of codes actually reserved.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n reserveNextAvailableCodes(arg: CodeService.ReserveNextArrayArgs): Promise<number>;\r\n\r\n /**\r\n * Update the properties of a single code.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n updateCode(props: CodeService.UpdatedCode): Promise<void>;\r\n\r\n /**\r\n * Update the properties of an array codes.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n * @note If you have a set of codes to update, it is considerably more efficient to do them as an array rather than one at a time.\r\n * @returns number of codes actually updated.\r\n */\r\n updateCodes(arg: CodeService.UpdateCodesArgs): Promise<number>;\r\n\r\n /** Delete an array of codes by their guids.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n deleteCodes(guid: CodeService.CodeGuid[]): Promise<void>;\r\n}\r\n\r\n/** @alpha */\r\nexport namespace CodeService {\r\n /** @internal */\r\n const codeSequences = new Map<string, CodeSequence>();\r\n\r\n /** @internal */\r\n export let createForIModel: ((db: IModelDb) => CodeService) | undefined;\r\n\r\n /** Register an instance of a`CodeSequence` so it can be looked up by name. */\r\n export function registerSequence(seq: CodeSequence) {\r\n codeSequences.set(seq.sequenceName, seq);\r\n }\r\n\r\n /** Get a previously registered `CodeSequence` by its name.\r\n * @throws if no sequence by that name was registered.\r\n */\r\n export function getSequence(name: string): CodeSequence {\r\n const seq = codeSequences.get(name);\r\n if (!seq)\r\n throw new Error(\"SequenceNotFound\", -1, `code sequence ${name} not found`);\r\n return seq;\r\n }\r\n\r\n /**\r\n * Turn a `CodePops` for the briefcase of this CodeService into a `ScopeAndSpec` object for use with a CodeService.\r\n * This is necessary because the `spec` member of `CodeProps` refers to the id of a code spec in the iModel, and\r\n * the `scope` member refers to the element Id of the scope element in the iModel. This helper function\r\n * converts the spec Id to the spec name and looks up the `FederationGuid` of the scope element.\r\n */\r\n export function makeScopeAndSpec(iModel: IModelDb, code: CodeProps): CodeService.ScopeAndSpec {\r\n const scopeGuid = iModel.elements.getElementProps({ id: code.scope, onlyBaseProperties: true }).federationGuid;\r\n if (undefined === scopeGuid)\r\n throw new CodeService.Error(\"MissingGuid\", IModelStatus.InvalidCode, \"code scope element has no federationGuid\");\r\n\r\n return { scopeGuid, specName: iModel.codeSpecs.getById(code.spec).name };\r\n }\r\n\r\n /** Turn a `CodeProps` and `ProposedCodeProps` into a `ProposedCode` for use with a CodeService.\r\n * @see [[makeScopeAndSpec]] for explanation of why this is necessary.\r\n */\r\n export function makeProposedCode(arg: CodeService.MakeProposedCodeArgs): CodeService.ProposedCode {\r\n return {\r\n ...arg.props,\r\n value: arg.code.value,\r\n ...makeScopeAndSpec(arg.iModel, arg.code),\r\n };\r\n }\r\n\r\n /** The name of a code spec */\r\n export type CodeSpecName = string;\r\n\r\n /** The name that identifies the \"originator\" of a code. Usually this is the Guid of the iModel from which a code was added,\r\n * but can also be used to identify a system or type from an external code service. */\r\n export type CodeOriginName = string;\r\n\r\n /** The name that identifies the \"author\" of a code. Generally, this is intended to be the name of a person or group that helps identify the purpose of the code. */\r\n export type AuthorName = string;\r\n\r\n /** The value for a code. */\r\n export type CodeValue = string;\r\n\r\n /** The guid for a code. This identifies the real-world entity associated with the code. */\r\n export type CodeGuid = GuidString;\r\n\r\n /** The guid of the scope for a code. This identifies the real-world entity that provides the uniqueness scope for code values. */\r\n export type ScopeGuid = GuidString;\r\n\r\n /** An optional number associated with a code that may be used for \"status\" information. Values must be defined by applications. */\r\n export type CodeState = number;\r\n\r\n /** The return status of an iteration function. The value \"stop\" causes the iteration to terminate. */\r\n export type IterationReturn = void | \"stop\";\r\n\r\n /** An iteration function over codes in a code index. It is called with the Guid of a each code. */\r\n export type CodeIteration = (guid: GuidString) => IterationReturn;\r\n\r\n /** An iteration function over code specs in a code index. It is called with the name and json of a each code spec. */\r\n export type NameAndJsonIteration = (nameAndJson: NameAndJson) => IterationReturn;\r\n\r\n /** Argument for reserving an array of new codes. */\r\n export interface ReserveCodesArgs {\r\n /** an array of proposed codes to reserve.\r\n * @note the guid of each proposed code must be supplied by the caller.\r\n */\r\n readonly codes: CodeService.ProposedCode[];\r\n /** If true, unless all codes are available, don't reserve any codes. Otherwise reserve all available codes. */\r\n readonly allOrNothing?: true;\r\n }\r\n\r\n /** Argument for reserving a code from a code sequence. */\r\n export interface ReserveNextArgs {\r\n /** the properties of the new code */\r\n readonly code: CodeService.ProposedCodeProps;\r\n /** The code sequence and scope for the new code. */\r\n readonly from: SequenceScope;\r\n }\r\n\r\n /** Argument for reserving an array of codes from a code sequence. */\r\n export interface ReserveNextArrayArgs {\r\n /** an array of proposed codes to reserve. */\r\n readonly codes: CodeService.ProposedCodeProps[];\r\n /** The code sequence and scope for the new codes. */\r\n readonly from: CodeService.SequenceScope;\r\n /** If true, and in the event that the code sequence does not have enough available codes to fulfill all the entries in `codes`,\r\n * return as many as possible. Otherwise no codes are reserved. The `problems` member of the exception can be used to determine how many codes were available.\r\n * @note if `asManyAsPossible` is true, no error is thrown if the sequence becomes full. You must check the return value to see how many\r\n * were actually available. The `value` member will be undefined for any proposed codes that were not reserved.\r\n */\r\n readonly asManyAsPossible?: true;\r\n }\r\n\r\n /** Argument for updating an array of codes. */\r\n export interface UpdateCodesArgs {\r\n /** Properties of the codes to update */\r\n readonly props: CodeService.UpdatedCode[];\r\n /** If true, unless all codes are updated, don't update any codes. Otherwise update all possible codes. */\r\n readonly allOrNothing?: true;\r\n }\r\n\r\n /** Arguments for CodeService.makeProposedCode */\r\n export interface MakeProposedCodeArgs {\r\n readonly iModel: IModelDb;\r\n readonly code: Required<CodeProps>;\r\n readonly props: CodeService.CodeGuidStateJson;\r\n }\r\n\r\n /** The properties of an Element to be checked against the code index.\r\n * @see CodeService.verifyCode\r\n */\r\n export interface ElementCodeProps {\r\n /** iModel from which the code is being inserted/updated. */\r\n readonly iModel: IModelDb;\r\n /** Properties of the code */\r\n readonly props: {\r\n /** The imodel-specific code properties. */\r\n readonly code: CodeProps;\r\n /**\r\n * The federationGuid of the element being inserted or updated.\r\n * If federationGuid is defined, it is must match the value in the code index or an error is thrown.\r\n * If it is undefined, the value from the code index is returned here.\r\n */\r\n federationGuid?: GuidString;\r\n };\r\n }\r\n\r\n /** a name and a json object. Used for code specs, authors and origins. */\r\n export interface NameAndJson {\r\n readonly name: string;\r\n readonly json?: SettingObject;\r\n }\r\n\r\n /** A code Scope guid, and code spec name. */\r\n export interface ScopeAndSpec {\r\n readonly specName: CodeSpecName;\r\n readonly scopeGuid: ScopeGuid;\r\n }\r\n\r\n /** A code Scope guid, code spec, and code value. */\r\n export interface ScopeSpecAndValue extends ScopeAndSpec {\r\n readonly value: CodeValue;\r\n }\r\n\r\n /** The data held in a code index for a single code. */\r\n export interface CodeEntry {\r\n /** The name of the code spec for this code. */\r\n readonly specName: CodeSpecName;\r\n /** The guid of the entity that provides the scope for this code. */\r\n readonly scopeGuid: ScopeGuid;\r\n /** The value of this code. */\r\n readonly value: CodeValue;\r\n /** The guid of the entity this code identifies. */\r\n readonly guid: CodeGuid;\r\n /** the state of the code. May be undefined. */\r\n readonly state?: CodeState;\r\n /** The name of the originating source of this code (usually an iModel Guid). May be undefined. */\r\n readonly origin: CodeOriginName;\r\n /** The name of the author of this code. May be undefined. */\r\n readonly author?: AuthorName;\r\n /** Option json properties associated with this code. May be undefined. */\r\n readonly json?: SettingObject;\r\n }\r\n\r\n /** A filter used to limit and/or sort the values returned by an iteration. */\r\n export interface ValueFilter {\r\n /** A value filter. May include wild cards when used with `GLOB` or `LIKE` */\r\n readonly value?: string;\r\n /** The comparison operator for `value`. Default is `=` */\r\n readonly valueCompare?: \"GLOB\" | \"LIKE\" | \"NOT GLOB\" | \"NOT LIKE\" | \"=\" | \"<\" | \">\";\r\n /** Order results ascending or descending. If not supplied, the results are unordered (random). */\r\n readonly orderBy?: \"ASC\" | \"DESC\";\r\n /** An SQL expression to further filter results. This string is appended to the `WHERE` clause with an `AND` (that should not be part of the sqlExpression) */\r\n readonly sqlExpression?: string;\r\n }\r\n\r\n /** A filter to limit and/or sort the values for the [[CodeIndex.forAllCodes]] iteration. */\r\n export interface CodeFilter extends ValueFilter {\r\n /** If supplied, limit results to only those with this spec */\r\n readonly specName?: CodeSpecName;\r\n /** If supplied, limit results to only those with this scope Guid */\r\n readonly scopeGuid?: ScopeGuid;\r\n /** If supplied, limit results to only those with this origin */\r\n readonly origin?: CodeOriginName;\r\n }\r\n\r\n /** Author and origin information supplied when codes are reserved. */\r\n export interface AuthorAndOrigin {\r\n /** The name of the individual or group for whom the code was reserved. */\r\n readonly author: Mutable<NameAndJson>;\r\n /** The identity of the \"originator\" of the code. This is usually a guid of an iModel, but can be any unique string. */\r\n readonly origin: Mutable<NameAndJson>;\r\n }\r\n\r\n /** The Guid, state, and json properties of a code. */\r\n export interface CodeGuidStateJson {\r\n /** The Guid of the new code. This must be always be supplied by the application. */\r\n readonly guid: CodeGuid;\r\n /** An optional value for the state of the code. */\r\n readonly state?: CodeState;\r\n /** An optional json object to be stored with the code. */\r\n readonly json?: SettingObject;\r\n }\r\n\r\n /** Properties of a \"proposed\" new code to be reserved.\r\n * @note the Guid of the entity identified by this code *must* be supplied, but `value` is optional, since\r\n * this may be used to reserve codes from a sequence where the value is generated.\r\n */\r\n export interface ProposedCodeProps extends CodeGuidStateJson {\r\n /** The value for the proposed code.\r\n * @note For code sequence operations, this value is ignored on input and is set with a new value from the sequence on successful return.\r\n */\r\n value?: CodeValue;\r\n }\r\n\r\n /** Properties of a proposed new code that is not from a code sequence (its `value` is required). */\r\n export type ProposedCode = ProposedCodeProps & ScopeSpecAndValue;\r\n\r\n /** Properties that describe a code sequence and a scope and spec for a proposed code or array of codes from a sequence. */\r\n export interface SequenceScope extends ScopeAndSpec {\r\n /** The code sequence. */\r\n readonly seq: CodeSequence;\r\n /** A valid current value. If supplied, the returned value will always be later in the sequence than this. */\r\n readonly start?: CodeValue;\r\n }\r\n\r\n /** Properties of a code to be updated.\r\n * @note The `guid` member identifies the code to be updated and is required.\r\n * All other properties are optional - if `undefined`, its value is not changed.\r\n */\r\n export type UpdatedCode = MarkRequired<Partial<ProposedCode>, \"guid\">;\r\n\r\n /** A proposed code that could not be reserved due to some error. */\r\n export interface ReserveProblem {\r\n /** the proposed code that failed. */\r\n readonly code: ProposedCode;\r\n /** the reason for the failure */\r\n readonly errorId: ErrorId;\r\n /** the error message from the exception for this proposed code. */\r\n readonly message: string;\r\n }\r\n\r\n /** A update to a code that failed for some error. */\r\n export interface UpdateProblem {\r\n /** The properties of the code that was to be updated */\r\n readonly prop: UpdatedCode;\r\n /** the reason for the failure */\r\n readonly errorId: ErrorId;\r\n /** the error message from the exception for the update request. */\r\n readonly message: string;\r\n }\r\n\r\n /**\r\n * A sequence of code values following a increasing pattern. Valid code sequences must have a first value, a last value, and\r\n * a way to get the next valid value from an existing valid value.\r\n * Code sequences have a `sequenceName` so they can be registered using `CodeService.registerSequence`.\r\n */\r\n export interface CodeSequence {\r\n /** the name of this CodeSequence. */\r\n get sequenceName(): string;\r\n /** Get the first valid value for this CodeSequence */\r\n getFirstValue(): CodeValue;\r\n /** Get the last valid value for this CodeSequence */\r\n getLastValue(): CodeValue;\r\n /** Get the next valid value for this CodeSequence from the supplied value.\r\n * If the sequence is full (that is, the next value is greater than the last value, this method should throw with errorId=\"SequenceFull\".\r\n * @return the next valid value according to the rules of this CodeSequence.\r\n */\r\n getNextValue(code: CodeValue): CodeValue;\r\n /** Determine whether this supplied value is valid for this sequence. */\r\n isValidCode(code: CodeValue): boolean;\r\n }\r\n\r\n /** Exception class thrown by `CodeService` methods. */\r\n export class Error extends BentleyError {\r\n /** A string that indicates the type of problem that caused the exception. */\r\n public readonly errorId: ErrorId;\r\n /** For [[CodeService.reserveCodes]] and [[CodeService.updateCodes]], a list of the problem details. */\r\n public readonly problems?: ReserveProblem[] | UpdateProblem[];\r\n\r\n /** @internal */\r\n constructor(errorId: ErrorId, errNum: number, message: string, problems?: ReserveProblem[] | UpdateProblem[]) {\r\n super(errNum, message);\r\n this.errorId = errorId;\r\n this.problems = problems;\r\n }\r\n }\r\n\r\n /** Identifiers for exceptions thrown by `CodeService` methods.\r\n * @see [[CodeService.Error.errorId]]\r\n */\r\n export type ErrorId =\r\n \"BadIndexProps\" |\r\n \"CorruptIModel\" |\r\n \"CorruptIndex\" |\r\n \"DuplicateValue\" |\r\n \"GuidIsInUse\" |\r\n \"GuidMismatch\" |\r\n \"IllegalValue\" |\r\n \"IndexReadonly\" |\r\n \"InvalidCodeScope\" |\r\n \"InvalidGuid\" |\r\n \"InvalidSequence\" |\r\n \"MissingCode\" |\r\n \"MissingGuid\" |\r\n \"MissingInput\" |\r\n \"MissingSpec\" |\r\n \"NoCodeIndex\" |\r\n \"SequenceFull\" |\r\n \"ReserveErrors\" |\r\n \"SequenceNotFound\" |\r\n \"SqlLogicError\" |\r\n \"UpdateErrors\" |\r\n \"ValueIsInUse\" |\r\n \"WrongVersion\";\r\n\r\n}\r\n"]}
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import * as os from "os";
3
3
  import { LogLevel } from "@itwin/core-bentley";
4
+ import { RpcInterfaceEndpoints } from "@itwin/core-common";
4
5
  /**
5
6
  * Performance and Memory statistics of backend
6
7
  * @internal
@@ -64,9 +65,10 @@ export declare class DevTools {
64
65
  /** Sets up a log level at the backend and returns the old log level */
65
66
  static setLogLevel(inLoggerCategory: string, newLevel: LogLevel): LogLevel | undefined;
66
67
  /** Obtains the backend application and iTwin.js Core versions */
67
- static versions(): {
68
+ static versions(): Promise<{
68
69
  application: string;
69
70
  iTwinJs: any;
70
- };
71
+ availableRpcs: RpcInterfaceEndpoints[];
72
+ }>;
71
73
  }
72
74
  //# sourceMappingURL=DevTools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DevTools.d.ts","sourceRoot":"","sources":["../../src/DevTools.ts"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,EAAU,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAYvD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,eAAe,CAAC;IACpB,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;CACjC;AAED;;GAEG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAuE;IAC7G,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAsD;IAC3F,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC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oldLevel;
145
145
  }
146
146
  /** Obtains the backend application and iTwin.js Core versions */
147
- static versions() {
147
+ static async versions() {
148
+ const availableRpcs = [];
148
149
  return {
149
150
  application: IModelHost_1.IModelHost.applicationVersion,
150
- iTwinJs: require("../../package.json").version, // eslint-disable-line @typescript-eslint/no-var-requires
151
+ iTwinJs: require("../../package.json").version,
152
+ availableRpcs, // filled in on the frontend
151
153
  };
152
154
  }
153
155
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DevTools.js","sourceRoot":"","sources":["../../src/DevTools.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,yBAAyB;AACzB,mCAAmC;AACnC,sDAAuD;AACvD,mEAAgE;AAChE,6CAA0C;AAE1C,0BAA0B;AAE1B,MAAM,cAAc,GAAW,6CAAqB,CAAC,QAAQ,CAAC;AAwC9D;;GAEG;AACH,MAAa,sBAAsB;IAmBjC,0GAA0G;IACnG,MAAM,CAAC,eAAe,CAAC,KAAU;QACtC,8FAA8F;QAC9F,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;QAEzE,2BAA2B;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;;AA1BH,wDA2BC;AA1ByB,qCAAc,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AACrF,oCAAa,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;AACnE,gCAAS,GAAG,CAAC,OAAO,CAAC,CAAC;AACtB,oCAAa,GAAG,CAAC,QAAQ,CAAC,CAAC;AAEnD,wEAAwE;AACzD,gCAAS,GAAG,CAAC,GAAW,EAAE,KAAU,EAAE,EAAE;IACrD,IAAI,sBAAsB,CAAC,cAAc,CAAC,QAAQ,CAAC,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E;YACnB,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE;YACzB,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE;SACf,CAAC;IACvB,CAAC;IAED,kDAAkD;IAC3C,MAAM,CAAC,KAAK;QACjB,IAAI;YACF,MAAM,KAAK,GAAG;gBACZ,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE;gBAC1B,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE;aACpB,CAAC;YACnB,OAAO,KAAK,CAAC;SACd;QAAC,OAAO,KAAK,EAAE;YACd,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,kCAAkC,CAAC,CAAC;YACpE,MAAM,KAAK,CAAC;SACb;IACH,CAAC;IAED,uEAAuE;IAChE,MAAM,CAAC,WAAW,CAAC,gBAAwB,EAAE,QAAkB;QACpE,MAAM,QAAQ,GAAG,qBAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACnD,qBAAM,CAAC,OAAO,CAAC,cAAc,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,cAAc,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QACtH,qBAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QAC5C,uBAAU,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;QACzC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,iEAAiE;IAC1D,MAAM,CAAC,QAAQ;QACpB,OAAO;YACL,WAAW,EAAE,uBAAU,CAAC,kBAAkB;YAC1C,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,EAAE,yDAAyD;SAC1G,CAAC;IACJ,CAAC;CACF;AAzHD,4BAyHC","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\r\nimport * as os from \"os\";\r\nimport * as process from \"process\";\r\nimport { Logger, LogLevel } from \"@itwin/core-bentley\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n// cspell:ignore ppid elap\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.DevTools;\r\n\r\ninterface StringIndexedObject<T> {\r\n [index: string]: T;\r\n}\r\n\r\n/**\r\n * Performance and Memory statistics of backend\r\n * @internal\r\n */\r\nexport interface DevToolsStats {\r\n os: DevToolsOsStats;\r\n process: DevToolsProcessStats;\r\n}\r\n\r\n/**\r\n * OS stats of backend\r\n * @internal\r\n */\r\nexport interface DevToolsOsStats {\r\n platform: NodeJS.Platform;\r\n hostname: string;\r\n totalmem: number;\r\n freemem: number;\r\n uptime: number;\r\n cpus: os.CpuInfo[];\r\n cpuUsage: number;\r\n}\r\n\r\n/**\r\n * Process stats of backend\r\n * @internal\r\n */\r\nexport interface DevToolsProcessStats {\r\n uptime: number;\r\n pid: number;\r\n ppid: number;\r\n memoryUsage: NodeJS.MemoryUsage;\r\n}\r\n\r\n/** Utility to format the JSON created by DevTools.stats() to include the appropriate units\r\n * @internal\r\n */\r\nexport class DevToolsStatsFormatter {\r\n private static readonly _megaByteProps = [\"totalmem\", \"freemem\", \"rss\", \"heapTotal\", \"heapUsed\", \"external\"];\r\n private static readonly _percentProps = [\"user\", \"nice\", \"sys\", \"idle\", \"irq\", \"cpuUsage\"];\r\n private static readonly _mHzProps = [\"speed\"];\r\n private static readonly _secondsProps = [\"uptime\"];\r\n\r\n /** Replacer that includes units - can be used with JSON.stringify() */\r\n private static _replacer = (key: string, value: any) => {\r\n if (DevToolsStatsFormatter._megaByteProps.includes(key))\r\n return `${value.toFixed()} MB`;\r\n if (DevToolsStatsFormatter._percentProps.includes(key))\r\n return `${value.toFixed()}%`;\r\n if (DevToolsStatsFormatter._mHzProps.includes(key))\r\n return `${value.toString()} MHz`;\r\n if (DevToolsStatsFormatter._secondsProps.includes(key))\r\n return `${value.toFixed()} secs`;\r\n return value;\r\n };\r\n\r\n /** Converts the input stats to another JSON object with the appropriate units setup for various fields */\r\n public static toFormattedJson(stats: any) {\r\n // Serialize the stats to a string with a replacer that sets up units during the serialization\r\n const statsStr = JSON.stringify(stats, DevToolsStatsFormatter._replacer);\r\n\r\n // Deserialize back to JSON\r\n return JSON.parse(statsStr);\r\n }\r\n}\r\n\r\n/**\r\n * Internal diagnostic utility\r\n * @internal\r\n */\r\nexport class DevTools {\r\n\r\n /** Receives a ping and returns true */\r\n public static ping(): boolean {\r\n Logger.logInfo(loggerCategory, \"Received ping at backend\");\r\n return true;\r\n }\r\n\r\n private static hrtimeToMS(hrtime: any) {\r\n return hrtime[0] * 1000 + hrtime[1] / 1000000;\r\n }\r\n\r\n private static bytesToMegaBytes(bytes: number): number {\r\n const megaBytes = bytes / Math.pow(1024, 2);\r\n return Math.round(megaBytes * 100) / 100;\r\n }\r\n\r\n private static evaluateCpuUsage(): number {\r\n const NUMBER_OF_CPUS = os.cpus().length;\r\n const startTime = process.hrtime();\r\n const startUsage = process.cpuUsage();\r\n\r\n // spin the CPU for 500 milliseconds\r\n const now = Date.now();\r\n while (Date.now() - now < 500)\r\n ;\r\n\r\n const elapTime = process.hrtime(startTime);\r\n const elapUsage = process.cpuUsage(startUsage);\r\n\r\n const elapTimeMS = this.hrtimeToMS(elapTime);\r\n\r\n const elapUserMS = elapUsage.user / 1000; // microseconds to milliseconds\r\n const elapSystMS = elapUsage.system / 1000;\r\n const cpuPercent = Math.round((100 * (elapUserMS + elapSystMS) / elapTimeMS / NUMBER_OF_CPUS));\r\n\r\n return cpuPercent;\r\n }\r\n\r\n private static evaluateCpus(): os.CpuInfo[] {\r\n // Create a clone\r\n const srcCpus = os.cpus();\r\n const cpus = new Array<os.CpuInfo>(srcCpus.length);\r\n let ii = 0;\r\n for (const srcCpu of srcCpus)\r\n cpus[ii++] = { ...srcCpu };\r\n\r\n // Evaluate cpu usage as percentages\r\n for (const cpu of Object.values(cpus)) {\r\n const total = Object.values(cpu.times).reduce((_total: number, currValue) => _total += currValue, 0);\r\n const cpuTimes = cpu.times as StringIndexedObject<number>;\r\n for (const type of Object.keys(cpuTimes)) {\r\n const cpuPercent = Math.round(100 * cpuTimes[type] / total);\r\n cpuTimes[type] = cpuPercent;\r\n }\r\n }\r\n return cpus;\r\n }\r\n\r\n private static evaluateMemoryUsage() {\r\n // Create a clone\r\n const memUsage = { ...process.memoryUsage() } as NodeJS.MemoryUsage;\r\n const memUsageObj = (memUsage as any) as StringIndexedObject<number>;\r\n // Evaluate memory usage as mega bytes\r\n for (const type of Object.keys(memUsageObj)) {\r\n memUsageObj[type] = this.bytesToMegaBytes(memUsageObj[type]);\r\n }\r\n return memUsage;\r\n }\r\n\r\n private static evaluateProcessStats(): DevToolsProcessStats {\r\n return {\r\n uptime: process.uptime(),\r\n pid: process.pid,\r\n ppid: process.ppid,\r\n memoryUsage: this.evaluateMemoryUsage(),\r\n } as DevToolsProcessStats;\r\n }\r\n\r\n private static evaluateOsStats(): DevToolsOsStats {\r\n return {\r\n platform: os.platform(),\r\n hostname: os.hostname(),\r\n totalmem: this.bytesToMegaBytes(os.totalmem()),\r\n freemem: this.bytesToMegaBytes(os.freemem()),\r\n uptime: os.uptime(),\r\n cpus: this.evaluateCpus(),\r\n cpuUsage: this.evaluateCpuUsage(),\r\n } as DevToolsOsStats;\r\n }\r\n\r\n /** Returns JSON object with backend statistics */\r\n public static stats(): DevToolsStats {\r\n try {\r\n const stats = {\r\n os: this.evaluateOsStats(),\r\n process: this.evaluateProcessStats(),\r\n } as DevToolsStats;\r\n return stats;\r\n } catch (error) {\r\n Logger.logError(loggerCategory, \"Could not fetch stats at backend\");\r\n throw error;\r\n }\r\n }\r\n\r\n /** Sets up a log level at the backend and returns the old log level */\r\n public static setLogLevel(inLoggerCategory: string, newLevel: LogLevel): LogLevel | undefined {\r\n const oldLevel = Logger.getLevel(inLoggerCategory);\r\n Logger.logInfo(loggerCategory, `Setting log level`, () => ({ loggerCategory: inLoggerCategory, oldLevel, newLevel }));\r\n Logger.setLevel(inLoggerCategory, newLevel);\r\n IModelHost.platform.clearLogLevelCache();\r\n return oldLevel;\r\n }\r\n\r\n /** Obtains the backend application and iTwin.js Core versions */\r\n public static versions() {\r\n return {\r\n application: IModelHost.applicationVersion,\r\n iTwinJs: require(\"../../package.json\").version, // eslint-disable-line @typescript-eslint/no-var-requires\r\n };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"DevTools.js","sourceRoot":"","sources":["../../src/DevTools.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,yBAAyB;AACzB,mCAAmC;AACnC,sDAAuD;AACvD,mEAAgE;AAChE,6CAA0C;AAG1C,0BAA0B;AAE1B,MAAM,cAAc,GAAW,6CAAqB,CAAC,QAAQ,CAAC;AAwC9D;;GAEG;AACH,MAAa,sBAAsB;IAmBjC,0GAA0G;IACnG,MAAM,CAAC,eAAe,CAAC,KAAU;QACtC,8FAA8F;QAC9F,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;QAEzE,2BAA2B;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;;AA1BH,wDA2BC;AA1ByB,qCAAc,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AACrF,oCAAa,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;AACnE,gCAAS,GAAG,CAAC,OAAO,CAAC,CAAC;AACtB,oCAAa,GAAG,CAAC,QAAQ,CAAC,CAAC;AAEnD,wEAAwE;AACzD,gCAAS,GAAG,CAAC,GAAW,EAAE,KAAU,EAAE,EAAE;IACrD,IAAI,sBAAsB,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------\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\r\nimport * as os from \"os\";\r\nimport * as process from \"process\";\r\nimport { Logger, LogLevel } from \"@itwin/core-bentley\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { RpcInterfaceEndpoints } from \"@itwin/core-common\";\r\n\r\n// cspell:ignore ppid elap\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.DevTools;\r\n\r\ninterface StringIndexedObject<T> {\r\n [index: string]: T;\r\n}\r\n\r\n/**\r\n * Performance and Memory statistics of backend\r\n * @internal\r\n */\r\nexport interface DevToolsStats {\r\n os: DevToolsOsStats;\r\n process: DevToolsProcessStats;\r\n}\r\n\r\n/**\r\n * OS stats of backend\r\n * @internal\r\n */\r\nexport interface DevToolsOsStats {\r\n platform: NodeJS.Platform;\r\n hostname: string;\r\n totalmem: number;\r\n freemem: number;\r\n uptime: number;\r\n cpus: os.CpuInfo[];\r\n cpuUsage: number;\r\n}\r\n\r\n/**\r\n * Process stats of backend\r\n * @internal\r\n */\r\nexport interface DevToolsProcessStats {\r\n uptime: number;\r\n pid: number;\r\n ppid: number;\r\n memoryUsage: NodeJS.MemoryUsage;\r\n}\r\n\r\n/** Utility to format the JSON created by DevTools.stats() to include the appropriate units\r\n * @internal\r\n */\r\nexport class DevToolsStatsFormatter {\r\n private static readonly _megaByteProps = [\"totalmem\", \"freemem\", \"rss\", \"heapTotal\", \"heapUsed\", \"external\"];\r\n private static readonly _percentProps = [\"user\", \"nice\", \"sys\", \"idle\", \"irq\", \"cpuUsage\"];\r\n private static readonly _mHzProps = [\"speed\"];\r\n private static readonly _secondsProps = [\"uptime\"];\r\n\r\n /** Replacer that includes units - can be used with JSON.stringify() */\r\n private static _replacer = (key: string, value: any) => {\r\n if (DevToolsStatsFormatter._megaByteProps.includes(key))\r\n return `${value.toFixed()} MB`;\r\n if (DevToolsStatsFormatter._percentProps.includes(key))\r\n return `${value.toFixed()}%`;\r\n if (DevToolsStatsFormatter._mHzProps.includes(key))\r\n return `${value.toString()} MHz`;\r\n if (DevToolsStatsFormatter._secondsProps.includes(key))\r\n return `${value.toFixed()} secs`;\r\n return value;\r\n };\r\n\r\n /** Converts the input stats to another JSON object with the appropriate units setup for various fields */\r\n public static toFormattedJson(stats: any) {\r\n // Serialize the stats to a string with a replacer that sets up units during the serialization\r\n const statsStr = JSON.stringify(stats, DevToolsStatsFormatter._replacer);\r\n\r\n // Deserialize back to JSON\r\n return JSON.parse(statsStr);\r\n }\r\n}\r\n\r\n/**\r\n * Internal diagnostic utility\r\n * @internal\r\n */\r\nexport class DevTools {\r\n\r\n /** Receives a ping and returns true */\r\n public static ping(): boolean {\r\n Logger.logInfo(loggerCategory, \"Received ping at backend\");\r\n return true;\r\n }\r\n\r\n private static hrtimeToMS(hrtime: any) {\r\n return hrtime[0] * 1000 + hrtime[1] / 1000000;\r\n }\r\n\r\n private static bytesToMegaBytes(bytes: number): number {\r\n const megaBytes = bytes / Math.pow(1024, 2);\r\n return Math.round(megaBytes * 100) / 100;\r\n }\r\n\r\n private static evaluateCpuUsage(): number {\r\n const NUMBER_OF_CPUS = os.cpus().length;\r\n const startTime = process.hrtime();\r\n const startUsage = process.cpuUsage();\r\n\r\n // spin the CPU for 500 milliseconds\r\n const now = Date.now();\r\n while (Date.now() - now < 500)\r\n ;\r\n\r\n const elapTime = process.hrtime(startTime);\r\n const elapUsage = process.cpuUsage(startUsage);\r\n\r\n const elapTimeMS = this.hrtimeToMS(elapTime);\r\n\r\n const elapUserMS = elapUsage.user / 1000; // microseconds to milliseconds\r\n const elapSystMS = elapUsage.system / 1000;\r\n const cpuPercent = Math.round((100 * (elapUserMS + elapSystMS) / elapTimeMS / NUMBER_OF_CPUS));\r\n\r\n return cpuPercent;\r\n }\r\n\r\n private static evaluateCpus(): os.CpuInfo[] {\r\n // Create a clone\r\n const srcCpus = os.cpus();\r\n const cpus = new Array<os.CpuInfo>(srcCpus.length);\r\n let ii = 0;\r\n for (const srcCpu of srcCpus)\r\n cpus[ii++] = { ...srcCpu };\r\n\r\n // Evaluate cpu usage as percentages\r\n for (const cpu of Object.values(cpus)) {\r\n const total = Object.values(cpu.times).reduce((_total: number, currValue) => _total += currValue, 0);\r\n const cpuTimes = cpu.times as StringIndexedObject<number>;\r\n for (const type of Object.keys(cpuTimes)) {\r\n const cpuPercent = Math.round(100 * cpuTimes[type] / total);\r\n cpuTimes[type] = cpuPercent;\r\n }\r\n }\r\n return cpus;\r\n }\r\n\r\n private static evaluateMemoryUsage() {\r\n // Create a clone\r\n const memUsage = { ...process.memoryUsage() } as NodeJS.MemoryUsage;\r\n const memUsageObj = (memUsage as any) as StringIndexedObject<number>;\r\n // Evaluate memory usage as mega bytes\r\n for (const type of Object.keys(memUsageObj)) {\r\n memUsageObj[type] = this.bytesToMegaBytes(memUsageObj[type]);\r\n }\r\n return memUsage;\r\n }\r\n\r\n private static evaluateProcessStats(): DevToolsProcessStats {\r\n return {\r\n uptime: process.uptime(),\r\n pid: process.pid,\r\n ppid: process.ppid,\r\n memoryUsage: this.evaluateMemoryUsage(),\r\n } as DevToolsProcessStats;\r\n }\r\n\r\n private static evaluateOsStats(): DevToolsOsStats {\r\n return {\r\n platform: os.platform(),\r\n hostname: os.hostname(),\r\n totalmem: this.bytesToMegaBytes(os.totalmem()),\r\n freemem: this.bytesToMegaBytes(os.freemem()),\r\n uptime: os.uptime(),\r\n cpus: this.evaluateCpus(),\r\n cpuUsage: this.evaluateCpuUsage(),\r\n } as DevToolsOsStats;\r\n }\r\n\r\n /** Returns JSON object with backend statistics */\r\n public static stats(): DevToolsStats {\r\n try {\r\n const stats = {\r\n os: this.evaluateOsStats(),\r\n process: this.evaluateProcessStats(),\r\n } as DevToolsStats;\r\n return stats;\r\n } catch (error) {\r\n Logger.logError(loggerCategory, \"Could not fetch stats at backend\");\r\n throw error;\r\n }\r\n }\r\n\r\n /** Sets up a log level at the backend and returns the old log level */\r\n public static setLogLevel(inLoggerCategory: string, newLevel: LogLevel): LogLevel | undefined {\r\n const oldLevel = Logger.getLevel(inLoggerCategory);\r\n Logger.logInfo(loggerCategory, `Setting log level`, () => ({ loggerCategory: inLoggerCategory, oldLevel, newLevel }));\r\n Logger.setLevel(inLoggerCategory, newLevel);\r\n IModelHost.platform.clearLogLevelCache();\r\n return oldLevel;\r\n }\r\n\r\n /** Obtains the backend application and iTwin.js Core versions */\r\n public static async versions() {\r\n const availableRpcs: RpcInterfaceEndpoints[] = [];\r\n return {\r\n application: IModelHost.applicationVersion,\r\n iTwinJs: require(\"../../package.json\").version, // eslint-disable-line @typescript-eslint/no-var-requires\r\n availableRpcs, // filled in on the frontend\r\n };\r\n }\r\n}\r\n"]}
@@ -79,7 +79,7 @@ export interface IModelHostOptions {
79
79
  tileCacheAzureCredentials?: AzureBlobStorageCredentials;
80
80
  /**
81
81
  * @beta
82
- * @deprecated in 3.x. use tileCacheStorage
82
+ * @deprecated in 3.x. Use [[tileCacheStorage]] instead.
83
83
  */
84
84
  tileCacheService?: CloudStorageService;
85
85
  /**
@@ -147,7 +147,7 @@ export declare class IModelHostConfiguration implements IModelHostOptions {
147
147
  hubAccess?: BackendHubAccess;
148
148
  /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */
149
149
  authorizationClient?: AuthorizationClient;
150
- /** @beta @deprecated in 3.x. */
150
+ /** @beta @deprecated in 3.x. Use [[tileCacheStorage]] instead. */
151
151
  tileCacheService?: CloudStorageService;
152
152
  /** @beta */
153
153
  restrictTileUrlsByClientIp?: boolean;
@@ -226,7 +226,7 @@ export declare class IModelHost {
226
226
  private static registerPlatform;
227
227
  /**
228
228
  * @internal
229
- * @deprecated in 3.x.
229
+ * @deprecated in 3.x. Use [[IModelHost.tileStorage]] instead.
230
230
  * @note Use [[IModelHostOptions.tileCacheService]] to set the service provider.
231
231
  */
232
232
  static tileCacheService?: CloudStorageService;
@@ -234,7 +234,7 @@ export declare class IModelHost {
234
234
  static tileStorage?: TileStorage;
235
235
  /**
236
236
  * @internal
237
- * @deprecated in 3.x.
237
+ * @deprecated in 3.x. Use [[IModelHost.tileStorage]] instead.
238
238
  */
239
239
  static tileUploader?: CloudStorageTileUploader;
240
240
  private static _hubAccess?;
@@ -1 +1 @@
1
- {"version":3,"file":"IModelHost.d.ts","sourceRoot":"","sources":["../../src/IModelHost.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAGzE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAU,OAAO,EAAQ,UAAU,EAAkC,OAAO,EAAmB,MAAM,qBAAqB,CAAC;AAC/I,OAAO,EAAE,mBAAmB,EAA8B,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAAoB,2BAA2B,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAWrI,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAkB,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAMjF,aAAa;AACb,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,8JAA8J;IAC9J,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wOAAwO;IACxO,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,sFAAsF;IACtF,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9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AClC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,GAAG,OAAO,eAAe,CAAC,CAAC;SACzE;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD;;;OAGG;IACI,kBAAkB,CAAC,UAAkB,IAAwB,OAAO,UAAU,CAAC,CAAC,CAAC;IACxF;;;;OAIG;IACI,eAAe,CAAC,UAAkB;QACvC,MAAM,gBAAgB,GAAuB,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACjF,IAAI,SAAS,KAAK,gBAAgB,EAAE;YAClC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,GAAG,UAAU,eAAe,CAAC,CAAC;SAC5E;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AAnCD,4CAmCC","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 IModelHost\r\n */\r\n\r\nimport { IModelJsNative, NativeLibrary } from \"@bentley/imodeljs-native\";\r\nimport { AzureServerStorageBindings } from \"@itwin/object-storage-azure\";\r\nimport { DependenciesConfig, Types as ExtensionTypes } from \"@itwin/cloud-agnostic-core\";\r\nimport { ServerStorage } from \"@itwin/object-storage-core\";\r\nimport { AccessToken, assert, BeEvent, Guid, GuidString, IModelStatus, Logger, LogLevel, Mutable, ProcessDetector } from \"@itwin/core-bentley\";\r\nimport { AuthorizationClient, BentleyStatus, IModelError, LocalDirName, SessionProps } from \"@itwin/core-common\";\r\nimport { TelemetryManager } from \"@itwin/core-telemetry\";\r\nimport { Container } from \"inversify\";\r\nimport * as os from \"os\";\r\nimport * as path from \"path\";\r\nimport { BackendHubAccess } from \"./BackendHubAccess\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { BisCoreSchema } from \"./BisCoreSchema\";\r\nimport { BriefcaseManager } from \"./BriefcaseManager\";\r\nimport { AzureBlobStorage, AzureBlobStorageCredentials, CloudStorageService, CloudStorageTileUploader } from \"./CloudStorageBackend\";\r\nimport { FunctionalSchema } from \"./domains/FunctionalSchema\";\r\nimport { GenericSchema } from \"./domains/GenericSchema\";\r\nimport { GeoCoordConfig } from \"./GeoCoordConfig\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\nimport { DevToolsRpcImpl } from \"./rpc-impl/DevToolsRpcImpl\";\r\nimport { IModelReadRpcImpl } from \"./rpc-impl/IModelReadRpcImpl\";\r\nimport { IModelTileRpcImpl } from \"./rpc-impl/IModelTileRpcImpl\";\r\nimport { SnapshotIModelRpcImpl } from \"./rpc-impl/SnapshotIModelRpcImpl\";\r\nimport { WipRpcImpl } from \"./rpc-impl/WipRpcImpl\";\r\nimport { initializeRpcBackend } from \"./RpcBackend\";\r\nimport { TileStorage } from \"./TileStorage\";\r\nimport { BaseSettings, SettingDictionary, SettingsPriority } from \"./workspace/Settings\";\r\nimport { SettingsSchemas } from \"./workspace/SettingsSchemas\";\r\nimport { ITwinWorkspace, Workspace, WorkspaceOpts } from \"./workspace/Workspace\";\r\n\r\nconst loggerCategory = BackendLoggerCategory.IModelHost;\r\n\r\n// cspell:ignore nodereport fatalerror apicall alicloud rpcs\r\n\r\n/** @alpha */\r\nexport interface CrashReportingConfigNameValuePair {\r\n name: string;\r\n value: string;\r\n}\r\n\r\n/** Configuration of the crash-reporting system.\r\n * @alpha\r\n */\r\nexport interface CrashReportingConfig {\r\n /** The directory to which *.dmp and/or iModelJsNativeCrash*.properties.txt files are written. This directory will be created if it does not already exist. */\r\n crashDir: string;\r\n /** max # .dmp files that may exist in crashDir. The default is 50. */\r\n maxDumpsInDir?: number;\r\n /** Enable crash-dumps? If so, .dmp and .properties.txt files will be generated and written to crashDir in the event of an unhandled native-code exception. If not, only .properties.txt files will be written. The default is false. */\r\n enableCrashDumps?: boolean;\r\n /** If enableCrashDumps is true, do you want a full-memory dump? Defaults to false. */\r\n wantFullMemoryDumps?: boolean;\r\n /** Enable Node.js crash reporting? If so, report files will be generated in the event of an unhandled exception or fatal error and written to crashDir. The default is false. */\r\n enableNodeReport?: boolean;\r\n /** Additional name, value pairs to write to iModelJsNativeCrash*.properties.txt file in the event of a crash. */\r\n params?: CrashReportingConfigNameValuePair[];\r\n /** Run this .js file to process .dmp and Node.js crash reporting .json files in the event of a crash.\r\n * This script will be executed with a single command-line parameter: the name of the dump or Node.js report file.\r\n * In the case of a dump file, there will be a second file with the same basename and the extension \".properties.txt\".\r\n * Since it runs in a separate process, this script will have no access to the Javascript\r\n * context of the exiting backend. No default.\r\n */\r\n dumpProcessorScriptFileName?: string;\r\n /** Upload crash dump and node-reports to Bentley's crash-reporting service? Defaults to false */\r\n uploadToBentley?: boolean;\r\n}\r\n\r\n/**\r\n * Options for [[IModelHost.startup]]\r\n * @public\r\n */\r\nexport interface IModelHostOptions {\r\n /**\r\n * Root of the directory holding all the files that iTwin.js caches\r\n * - If not specified at startup a platform specific default is used -\r\n * - Windows: $(HOMEDIR)/AppData/Local/iModelJs/\r\n * - Mac/iOS: $(HOMEDIR)/Library/Caches/iModelJs/\r\n * - Linux: $(HOMEDIR)/.cache/iModelJs/\r\n * where $(HOMEDIR) is documented [here](https://nodejs.org/api/os.html#os_os_homedir)\r\n * - if specified, ensure it is set to a folder with read/write access.\r\n * - Sub-folders within this folder organize various caches -\r\n * - bc/ -> Briefcases\r\n * - appSettings/ -> Offline application settings (only relevant in native applications)\r\n * - etc.\r\n * @see [[IModelHost.cacheDir]] for the value it's set to after startup\r\n */\r\n cacheDir?: LocalDirName;\r\n\r\n /** The directory where application assets are found. */\r\n appAssetsDir?: LocalDirName;\r\n\r\n /**\r\n * Options for creating the [[Workspace]]\r\n * @beta\r\n */\r\n workspace?: WorkspaceOpts;\r\n\r\n /**\r\n * The kind of iModel hub server to use.\r\n * @beta\r\n */\r\n hubAccess?: BackendHubAccess;\r\n\r\n /** The Azure blob storage credentials to use for the tile cache service. If omitted and no external service implementation is provided, a local cache will be used.\r\n * @beta\r\n */\r\n tileCacheAzureCredentials?: AzureBlobStorageCredentials;\r\n\r\n /**\r\n * @beta\r\n * @deprecated in 3.x. use tileCacheStorage\r\n */\r\n tileCacheService?: CloudStorageService; // eslint-disable-line deprecation/deprecation\r\n\r\n /**\r\n * @beta\r\n * @note A reference implementation is set for AzureServerStorage from @itwin/object-storage-azure if [[tileCacheAzureCredentials]] property is set. To supply a different implementation for any service provider (such as AWS),\r\n * set this property with a custom ServerStorage.\r\n */\r\n tileCacheStorage?: ServerStorage;\r\n\r\n /** The maximum size in bytes to which a local sqlite database used for caching tiles can grow before it is purged of least-recently-used tiles.\r\n * The local cache is used only if an external cache has not been configured via [[tileCacheService]], [[tileCacheStorage]], and [[tileCacheAzureCredentials]].\r\n * Defaults to 1 GB. Must be an unsigned integer. A value of zero disables the local cache entirely.\r\n * @beta\r\n */\r\n maxTileCacheDbSize?: number;\r\n\r\n /** Whether to restrict tile cache URLs by client IP address (if available).\r\n * @beta\r\n */\r\n restrictTileUrlsByClientIp?: boolean;\r\n\r\n /**\r\n * Whether to enable OpenTelemetry tracing\r\n * @beta\r\n */\r\n enableOpenTelemetry?: boolean;\r\n\r\n /** Whether to compress cached tiles.\r\n * Defaults to `true`.\r\n */\r\n compressCachedTiles?: boolean;\r\n\r\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileTreeProps]($common) should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n tileTreeRequestTimeout?: number;\r\n\r\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileContent]($common) should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n tileContentRequestTimeout?: number;\r\n\r\n /** The backend will log when a tile took longer to load than this threshold in seconds.\r\n * @internal\r\n */\r\n logTileLoadTimeThreshold?: number;\r\n\r\n /** The backend will log when a tile is loaded with a size in bytes above this threshold.\r\n * @internal\r\n */\r\n logTileSizeThreshold?: number;\r\n\r\n /** Crash-reporting configuration\r\n * @alpha\r\n */\r\n crashReportingConfig?: CrashReportingConfig;\r\n\r\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\r\n authorizationClient?: AuthorizationClient;\r\n}\r\n\r\n/** Configuration of core-backend.\r\n * @public\r\n */\r\nexport class IModelHostConfiguration implements IModelHostOptions {\r\n public static defaultTileRequestTimeout = 20 * 1000;\r\n public static defaultLogTileLoadTimeThreshold = 40;\r\n public static defaultLogTileSizeThreshold = 20 * 1000000;\r\n /** @internal */\r\n public static defaultMaxTileCacheDbSize = 1024 * 1024 * 1024;\r\n\r\n public appAssetsDir?: LocalDirName;\r\n public cacheDir?: LocalDirName;\r\n\r\n /** @beta */\r\n public workspace?: WorkspaceOpts;\r\n /** @beta */\r\n public hubAccess?: BackendHubAccess;\r\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\r\n public authorizationClient?: AuthorizationClient;\r\n /** @beta @deprecated in 3.x. */\r\n public tileCacheService?: CloudStorageService; // eslint-disable-line deprecation/deprecation\r\n /** @beta */\r\n public restrictTileUrlsByClientIp?: boolean;\r\n public compressCachedTiles?: boolean;\r\n /** @beta */\r\n public tileCacheAzureCredentials?: AzureBlobStorageCredentials;\r\n /** @internal */\r\n public tileTreeRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\r\n /** @internal */\r\n public tileContentRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\r\n /** @internal */\r\n public logTileLoadTimeThreshold = IModelHostConfiguration.defaultLogTileLoadTimeThreshold;\r\n /** @internal */\r\n public logTileSizeThreshold = IModelHostConfiguration.defaultLogTileSizeThreshold;\r\n /** @alpha */\r\n public crashReportingConfig?: CrashReportingConfig;\r\n}\r\n\r\n/**\r\n * Settings for `IModelHost.appWorkspace`.\r\n * @note this includes the default dictionary from the SettingsSpecRegistry\r\n */\r\nclass ApplicationSettings extends BaseSettings {\r\n private _remove?: VoidFunction;\r\n protected override verifyPriority(priority: SettingsPriority) {\r\n if (priority >= SettingsPriority.iModel) // iModel settings may not appear in ApplicationSettings\r\n throw new Error(\"Use IModelSettings\");\r\n }\r\n private updateDefaults() {\r\n const defaults: SettingDictionary = {};\r\n for (const [schemaName, val] of SettingsSchemas.allSchemas) {\r\n if (val.default)\r\n defaults[schemaName] = val.default;\r\n }\r\n this.addDictionary(\"_default_\", 0, defaults);\r\n }\r\n\r\n public constructor() {\r\n super();\r\n this._remove = SettingsSchemas.onSchemaChanged.addListener(() => this.updateDefaults());\r\n this.updateDefaults();\r\n }\r\n\r\n public override close() {\r\n if (this._remove) {\r\n this._remove();\r\n this._remove = undefined;\r\n }\r\n }\r\n}\r\n\r\n/** IModelHost initializes ($backend) and captures its configuration. A backend must call [[IModelHost.startup]] before using any backend classes.\r\n * See [the learning article]($docs/learning/backend/IModelHost.md)\r\n * @public\r\n */\r\nexport class IModelHost {\r\n private constructor() { }\r\n\r\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\r\n public static authorizationClient?: AuthorizationClient;\r\n\r\n /** @alpha */\r\n public static readonly telemetry = new TelemetryManager();\r\n\r\n public static backendVersion = \"\";\r\n private static _cacheDir = \"\";\r\n private static _appWorkspace?: Workspace;\r\n\r\n private static _platform?: typeof IModelJsNative;\r\n /** @internal */\r\n public static get platform(): typeof IModelJsNative {\r\n if (this._platform === undefined)\r\n throw new Error(\"IModelHost.startup must be called first\");\r\n return this._platform;\r\n }\r\n\r\n public static configuration?: IModelHostOptions;\r\n\r\n /** Event raised during startup to allow loading settings data */\r\n public static readonly onWorkspaceStartup = new BeEvent<() => void>();\r\n\r\n /** Event raised just after the backend IModelHost was started */\r\n public static readonly onAfterStartup = new BeEvent<() => void>();\r\n\r\n /** Event raised just before the backend IModelHost is to be shut down */\r\n public static readonly onBeforeShutdown = new BeEvent<() => void>();\r\n\r\n /** @internal */\r\n public static readonly session: Mutable<SessionProps> = { applicationId: \"2686\", applicationVersion: \"1.0.0\", sessionId: \"\" };\r\n\r\n /** A uniqueId for this session */\r\n public static get sessionId() { return this.session.sessionId; }\r\n public static set sessionId(id: GuidString) { this.session.sessionId = id; }\r\n\r\n /** The Id of this application - needs to be set only if it is an agent application. The applicationId will otherwise originate at the frontend. */\r\n public static get applicationId() { return this.session.applicationId; }\r\n public static set applicationId(id: string) { this.session.applicationId = id; }\r\n\r\n /** The version of this application - needs to be set if is an agent application. The applicationVersion will otherwise originate at the frontend. */\r\n public static get applicationVersion() { return this.session.applicationVersion; }\r\n public static set applicationVersion(version: string) { this.session.applicationVersion = version; }\r\n\r\n /** Root directory holding files that iTwin.js caches */\r\n public static get cacheDir(): LocalDirName { return this._cacheDir; }\r\n\r\n /** The application [[Workspace]] for this `IModelHost`\r\n * @note this `Workspace` only holds [[WorkspaceContainer]]s and [[Settings]] scoped to the currently loaded application(s).\r\n * All organization, iTwin, and iModel based containers or settings must be accessed through [[IModelDb.workspace]] and\r\n * attempting to add them to this Workspace will fail.\r\n * @beta\r\n */\r\n public static get appWorkspace(): Workspace { return this._appWorkspace!; } // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n\r\n /** The optional [[FileNameResolver]] that resolves keys and partial file names for snapshot iModels. */\r\n public static snapshotFileNameResolver?: FileNameResolver;\r\n\r\n /** Get the current access token for this IModelHost, or a blank string if none is available.\r\n * @note for web backends, this will *always* return a blank string because the backend itself has no token (but never needs one either.)\r\n * For all IpcHosts, where this backend is servicing a single frontend, this will be the user's token. For ElectronHost, the backend\r\n * obtains the token and forwards it to the frontend.\r\n * @note accessTokens expire periodically and are automatically refreshed, if possible. Therefore tokens should not be saved, and the value\r\n * returned by this method may change over time throughout the course of a session.\r\n */\r\n public static async getAccessToken(): Promise<AccessToken> {\r\n try {\r\n return (await this.authorizationClient?.getAccessToken()) ?? \"\";\r\n } catch (e) {\r\n return \"\";\r\n }\r\n }\r\n\r\n /** @internal */\r\n public static flushLog() {\r\n return this.platform.flushLog();\r\n }\r\n /** @internal */\r\n public static loadNative(): void {\r\n const platform = Platform.load();\r\n this.registerPlatform(platform);\r\n }\r\n private static syncNativeLogLevels() {\r\n this.platform.clearLogLevelCache();\r\n }\r\n\r\n private static registerPlatform(platform: typeof IModelJsNative): void {\r\n this._platform = platform;\r\n if (undefined === platform)\r\n return;\r\n\r\n platform.logger = Logger;\r\n Logger.logLevelChangedFn = () => IModelHost.syncNativeLogLevels();\r\n }\r\n\r\n /**\r\n * @internal\r\n * @deprecated in 3.x.\r\n * @note Use [[IModelHostOptions.tileCacheService]] to set the service provider.\r\n */\r\n public static tileCacheService?: CloudStorageService; // eslint-disable-line deprecation/deprecation\r\n\r\n /** @internal */\r\n public static tileStorage?: TileStorage;\r\n\r\n /**\r\n * @internal\r\n * @deprecated in 3.x.\r\n */\r\n public static tileUploader?: CloudStorageTileUploader; // eslint-disable-line deprecation/deprecation\r\n\r\n private static _hubAccess?: BackendHubAccess;\r\n /** @internal */\r\n public static setHubAccess(hubAccess: BackendHubAccess | undefined) { this._hubAccess = hubAccess; }\r\n\r\n /** get the current hubAccess, if present.\r\n * @beta\r\n */\r\n public static getHubAccess(): BackendHubAccess | undefined { return this._hubAccess; }\r\n\r\n /** Provides access to the IModelHub for this IModelHost\r\n * @beta\r\n * @note If [[IModelHostOptions.hubAccess]] was undefined when initializing this class, accessing this property will throw an error.\r\n * To determine whether one is present, use [[getHubAccess]].\r\n */\r\n public static get hubAccess(): BackendHubAccess {\r\n if (this._hubAccess === undefined)\r\n throw new IModelError(IModelStatus.BadRequest, \"No BackendHubAccess supplied in IModelHostOptions\");\r\n return this._hubAccess;\r\n }\r\n\r\n private static initializeWorkspace(configuration: IModelHostOptions) {\r\n const settingAssets = path.join(KnownLocations.packageAssetsDir, \"Settings\");\r\n SettingsSchemas.addDirectory(path.join(settingAssets, \"Schemas\"));\r\n this._appWorkspace = new ITwinWorkspace(new ApplicationSettings(), configuration.workspace);\r\n this.appWorkspace.settings.addDirectory(settingAssets, SettingsPriority.defaults);\r\n\r\n GeoCoordConfig.onStartup();\r\n // allow applications to load their default settings\r\n this.onWorkspaceStartup.raiseEvent();\r\n }\r\n\r\n private static _isValid = false;\r\n /** Returns true if IModelHost is started. */\r\n public static get isValid() { return this._isValid; }\r\n /** This method must be called before any iTwin.js services are used.\r\n * @param options Host configuration data.\r\n * Raises [[onAfterStartup]].\r\n * @see [[shutdown]].\r\n */\r\n public static async startup(options?: IModelHostOptions): Promise<void> {\r\n if (this._isValid)\r\n return; // we're already initialized\r\n this._isValid = true;\r\n\r\n options = options ?? {};\r\n if (IModelHost.sessionId === \"\")\r\n IModelHost.sessionId = Guid.createValue();\r\n\r\n this.authorizationClient = options.authorizationClient;\r\n\r\n this.logStartup();\r\n\r\n this.backendVersion = require(\"../../package.json\").version; // eslint-disable-line @typescript-eslint/no-var-requires\r\n initializeRpcBackend(options.enableOpenTelemetry);\r\n\r\n if (this._platform === undefined) {\r\n try {\r\n this.loadNative();\r\n } catch (error) {\r\n Logger.logError(loggerCategory, \"Error registering/loading the native platform API\", () => (options));\r\n throw error;\r\n }\r\n }\r\n\r\n if (options.crashReportingConfig && options.crashReportingConfig.crashDir && !ProcessDetector.isElectronAppBackend && !ProcessDetector.isMobileAppBackend) {\r\n this.platform.setCrashReporting(options.crashReportingConfig);\r\n\r\n Logger.logTrace(loggerCategory, \"Configured crash reporting\", {\r\n enableCrashDumps: options.crashReportingConfig?.enableCrashDumps,\r\n wantFullMemoryDumps: options.crashReportingConfig?.wantFullMemoryDumps,\r\n enableNodeReport: options.crashReportingConfig?.enableNodeReport,\r\n uploadToBentley: options.crashReportingConfig?.uploadToBentley,\r\n });\r\n\r\n if (options.crashReportingConfig.enableNodeReport) {\r\n if (process.report !== undefined) {\r\n process.report.reportOnFatalError = true;\r\n process.report.reportOnUncaughtException = true;\r\n process.report.directory = options.crashReportingConfig.crashDir;\r\n Logger.logTrace(loggerCategory, \"Configured Node.js crash reporting\");\r\n } else {\r\n Logger.logWarning(loggerCategory, \"Unable to configure Node.js crash reporting\");\r\n }\r\n }\r\n }\r\n\r\n this.setupHostDirs(options);\r\n this.initializeWorkspace(options);\r\n\r\n BriefcaseManager.initialize(this._briefcaseCacheDir);\r\n\r\n [\r\n IModelReadRpcImpl,\r\n IModelTileRpcImpl,\r\n SnapshotIModelRpcImpl,\r\n WipRpcImpl,\r\n DevToolsRpcImpl,\r\n ].forEach((rpc) => rpc.register()); // register all of the RPC implementations\r\n\r\n [\r\n BisCoreSchema,\r\n GenericSchema,\r\n FunctionalSchema,\r\n ].forEach((schema) => schema.registerSchema()); // register all of the schemas\r\n\r\n if (undefined !== options.hubAccess)\r\n this._hubAccess = options.hubAccess;\r\n\r\n this.configuration = options;\r\n this.setupTileCache();\r\n\r\n process.once(\"beforeExit\", IModelHost.shutdown);\r\n this.onAfterStartup.raiseEvent();\r\n }\r\n\r\n private static _briefcaseCacheDir: LocalDirName;\r\n\r\n private static logStartup() {\r\n if (!Logger.isEnabled(loggerCategory, LogLevel.Trace))\r\n return;\r\n\r\n // Extract the iModel details from environment - note this is very specific to Bentley hosted backends, but is quite useful for tracing\r\n let startupInfo: any = {};\r\n const serviceName = process.env.FABRIC_SERVICE_NAME;\r\n if (serviceName) {\r\n // e.g., fabric:/iModelWebViewer3.0/iModelJSGuest/1/08daaeb3-b56f-480b-9051-7efc834d18ae/512d971d-b641-4735-bb1c-c07ab3e44ce7/c1315fcce125ca40b2d405bb7809214daf8b4c85\r\n const serviceNameComponents = serviceName.split(\"/\");\r\n if (serviceNameComponents.length === 7) {\r\n startupInfo = {\r\n ...startupInfo,\r\n iTwinId: serviceNameComponents[4],\r\n iModelId: serviceNameComponents[5],\r\n changesetId: serviceNameComponents[6],\r\n };\r\n }\r\n }\r\n\r\n Logger.logTrace(loggerCategory, \"IModelHost.startup\", () => startupInfo);\r\n }\r\n\r\n private static setupHostDirs(configuration: IModelHostOptions) {\r\n const setupDir = (dir: LocalDirName) => {\r\n dir = path.normalize(dir);\r\n IModelJsFs.recursiveMkDirSync(dir);\r\n return dir;\r\n };\r\n this._cacheDir = setupDir(configuration.cacheDir ?? NativeLibrary.defaultCacheDir);\r\n this._briefcaseCacheDir = path.join(this._cacheDir, \"imodels\");\r\n }\r\n\r\n /** This method must be called when an iTwin.js host is shut down. Raises [[onBeforeShutdown]] */\r\n public static async shutdown(): Promise<void> {\r\n // NB: This method is set as a node listener where `this` is unbound\r\n if (!IModelHost._isValid)\r\n return;\r\n\r\n IModelHost._isValid = false;\r\n IModelHost.onBeforeShutdown.raiseEvent();\r\n IModelHost.configuration = undefined;\r\n // eslint-disable-next-line deprecation/deprecation\r\n IModelHost.tileCacheService = undefined;\r\n // eslint-disable-next-line deprecation/deprecation\r\n IModelHost.tileUploader = undefined;\r\n IModelHost.tileStorage = undefined;\r\n IModelHost._appWorkspace?.close();\r\n IModelHost._appWorkspace = undefined;\r\n ITwinWorkspace.finalize();\r\n process.removeListener(\"beforeExit\", IModelHost.shutdown);\r\n }\r\n\r\n /**\r\n * Add or update a property that should be included in a crash report.\r\n * @param name The name of the property\r\n * @param value The value of the property\r\n * @alpha\r\n */\r\n public static setCrashReportProperty(name: string, value: string): void {\r\n assert(undefined !== this._platform);\r\n this._platform.setCrashReportProperty(name, value);\r\n }\r\n\r\n /**\r\n * Remove a previously defined property so that will not be included in a crash report.\r\n * @param name The name of the property\r\n * @alpha\r\n */\r\n public static removeCrashReportProperty(name: string): void {\r\n assert(undefined !== this._platform);\r\n this._platform.setCrashReportProperty(name, undefined);\r\n }\r\n\r\n /**\r\n * Get all properties that will be included in a crash report.\r\n * @alpha\r\n */\r\n public static getCrashReportProperties(): CrashReportingConfigNameValuePair[] {\r\n assert(undefined !== this._platform);\r\n return this._platform.getCrashReportProperties();\r\n }\r\n\r\n /** The directory where application assets may be found */\r\n public static get appAssetsDir(): string | undefined { return undefined !== IModelHost.configuration ? IModelHost.configuration.appAssetsDir : undefined; }\r\n\r\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileTreeProps should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n public static get tileTreeRequestTimeout(): number {\r\n return IModelHost.configuration?.tileTreeRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\r\n }\r\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileContent should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n public static get tileContentRequestTimeout(): number {\r\n return IModelHost.configuration?.tileContentRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\r\n }\r\n\r\n /** The backend will log when a tile took longer to load than this threshold in seconds. */\r\n public static get logTileLoadTimeThreshold(): number { return IModelHost.configuration?.logTileLoadTimeThreshold ?? IModelHostConfiguration.defaultLogTileLoadTimeThreshold; }\r\n /** The backend will log when a tile is loaded with a size in bytes above this threshold. */\r\n public static get logTileSizeThreshold(): number { return IModelHost.configuration?.logTileSizeThreshold ?? IModelHostConfiguration.defaultLogTileSizeThreshold; }\r\n\r\n /** Whether external tile caching is active.\r\n * @internal\r\n */\r\n public static get usingExternalTileCache(): boolean {\r\n return undefined !== IModelHost.tileStorage;\r\n }\r\n\r\n /** Whether to restrict tile cache URLs by client IP address.\r\n * @internal\r\n */\r\n public static get restrictTileUrlsByClientIp(): boolean { return undefined !== IModelHost.configuration && (IModelHost.configuration.restrictTileUrlsByClientIp ? true : false); }\r\n\r\n /** Whether to compress cached tiles.\r\n * @internal\r\n */\r\n public static get compressCachedTiles(): boolean { return false !== IModelHost.configuration?.compressCachedTiles; }\r\n\r\n private static setupTileCache() {\r\n assert(undefined !== IModelHost.configuration);\r\n const config = IModelHost.configuration;\r\n // eslint-disable-next-line deprecation/deprecation\r\n const service = config.tileCacheService;\r\n const storage = config.tileCacheStorage;\r\n const credentials = config.tileCacheAzureCredentials;\r\n\r\n if (!service && !storage && !credentials) {\r\n this.platform.setMaxTileCacheSize(config.maxTileCacheDbSize ?? IModelHostConfiguration.defaultMaxTileCacheDbSize);\r\n return;\r\n }\r\n\r\n this.platform.setMaxTileCacheSize(0);\r\n // eslint-disable-next-line deprecation/deprecation\r\n IModelHost.tileUploader = new CloudStorageTileUploader();\r\n if (credentials) {\r\n if (storage || service)\r\n throw new IModelError(BentleyStatus.ERROR, \"Cannot use both Azure and custom cloud storage providers for tile cache.\");\r\n this.setupAzureTileCache(credentials);\r\n }\r\n if (service) {\r\n if (!storage)\r\n Logger.logWarning(loggerCategory, \"Using tileCacheService without tileCacheStorage is unsupported\");\r\n IModelHost.tileCacheService = service; // eslint-disable-line deprecation/deprecation\r\n }\r\n if (storage)\r\n IModelHost.tileStorage = new TileStorage(storage);\r\n }\r\n\r\n private static setupAzureTileCache(credentials: AzureBlobStorageCredentials) {\r\n const config = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n ServerSideStorage: {\r\n dependencyName: \"azure\",\r\n accountName: credentials.account,\r\n accountKey: credentials.accessKey,\r\n baseUrl: credentials.baseUrl ?? `https://${credentials.account}.blob.core.windows.net`,\r\n },\r\n };\r\n const ioc: Container = new Container();\r\n ioc.bind<DependenciesConfig>(ExtensionTypes.dependenciesConfig).toConstantValue(config);\r\n new AzureServerStorageBindings().register(ioc, config.ServerSideStorage);\r\n IModelHost.tileStorage = new TileStorage(ioc.get(ServerStorage));\r\n // eslint-disable-next-line deprecation/deprecation\r\n IModelHost.tileCacheService = new AzureBlobStorage(credentials); // needed for backwards compatibility with old frontends\r\n }\r\n\r\n /** @internal */\r\n public static computeSchemaChecksum(arg: { schemaXmlPath: string, referencePaths: string[], exactMatch?: boolean }): string {\r\n return this.platform.computeSchemaChecksum(arg);\r\n }\r\n}\r\n\r\n/** Information about the platform on which the app is running. Also see [[KnownLocations]] and [[IModelJsFs]].\r\n * @public\r\n */\r\nexport class Platform {\r\n /** Get the name of the platform. */\r\n public static get platformName(): \"win32\" | \"linux\" | \"darwin\" | \"ios\" | \"android\" | \"uwp\" {\r\n return process.platform as any;\r\n }\r\n\r\n /** @internal */\r\n public static load(): typeof IModelJsNative {\r\n return ProcessDetector.isMobileAppBackend ? (process as any)._linkedBinding(\"iModelJsNative\") : NativeLibrary.load();\r\n }\r\n}\r\n\r\n/** Well known directories that may be used by the application. Also see [[Platform]]\r\n * @public\r\n */\r\nexport class KnownLocations {\r\n\r\n /** The directory where the imodeljs-native assets are stored. */\r\n public static get nativeAssetsDir(): string { return IModelHost.platform.DgnDb.getAssetsDir(); }\r\n\r\n /** The directory where the core-backend assets are stored. */\r\n public static get packageAssetsDir(): string {\r\n return path.join(__dirname, \"assets\");\r\n }\r\n\r\n /** The temporary directory. */\r\n public static get tmpdir(): string {\r\n return os.tmpdir();\r\n }\r\n}\r\n\r\n/** Extend this class to provide custom file name resolution behavior.\r\n * @note Only `tryResolveKey` and/or `tryResolveFileName` need to be overridden as the implementations of `resolveKey` and `resolveFileName` work for most purposes.\r\n * @see [[IModelHost.snapshotFileNameResolver]]\r\n * @public\r\n */\r\nexport abstract class FileNameResolver {\r\n /** Resolve a file name from the specified key.\r\n * @param _fileKey The key that identifies the file name in a `Map` or other similar data structure.\r\n * @returns The resolved file name or `undefined` if not found.\r\n */\r\n public tryResolveKey(_fileKey: string): string | undefined { return undefined; }\r\n /** Resolve a file name from the specified key.\r\n * @param fileKey The key that identifies the file name in a `Map` or other similar data structure.\r\n * @returns The resolved file name.\r\n * @throws [[IModelError]] if not found.\r\n */\r\n public resolveKey(fileKey: string): string {\r\n const resolvedFileName: string | undefined = this.tryResolveKey(fileKey);\r\n if (undefined === resolvedFileName) {\r\n throw new IModelError(IModelStatus.NotFound, `${fileKey} not resolved`);\r\n }\r\n return resolvedFileName;\r\n }\r\n /** Resolve the input file name, which may be a partial name, into a full path file name.\r\n * @param inFileName The partial file name.\r\n * @returns The resolved full path file name or `undefined` if not found.\r\n */\r\n public tryResolveFileName(inFileName: string): string | undefined { return inFileName; }\r\n /** Resolve the input file name, which may be a partial name, into a full path file name.\r\n * @param inFileName The partial file name.\r\n * @returns The resolved full path file name.\r\n * @throws [[IModelError]] if not found.\r\n */\r\n public resolveFileName(inFileName: string): string {\r\n const resolvedFileName: string | undefined = this.tryResolveFileName(inFileName);\r\n if (undefined === resolvedFileName) {\r\n throw new IModelError(IModelStatus.NotFound, `${inFileName} not resolved`);\r\n }\r\n return resolvedFileName;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"IModelHost.js","sourceRoot":"","sources":["../../src/IModelHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,8DAAyE;AACzE,sEAAyE;AACzE,oEAAyF;AACzF,oEAA2D;AAC3D,sDAA+I;AAC/I,oDAAiH;AACjH,0DAAyD;AACzD,yCAAsC;AACtC,yBAAyB;AACzB,6BAA6B;AAE7B,mEAAgE;AAChE,mDAAgD;AAChD,yDAAsD;AACtD,+DAAqI;AACrI,iEAA8D;AAC9D,2DAAwD;AACxD,qDAAkD;AAClD,6CAA0C;AAC1C,gEAA6D;AAC7D,oEAAiE;AACjE,oEAAiE;AACjE,4EAAyE;AACzE,sDAAmD;AACnD,6CAAoD;AACpD,+CAA4C;AAC5C,mDAAyF;AACzF,iEAA8D;AAC9D,qDAAiF;AAEjF,MAAM,cAAc,GAAG,6CAAqB,CAAC,UAAU,CAAC;AA+IxD;;GAEG;AACH,MAAa,uBAAuB;IAApC;QAuBE,gBAAgB;QACT,2BAAsB,GAAG,uBAAuB,CAAC,yBAAyB,CAAC;QAClF,gBAAgB;QACT,8BAAyB,GAAG,uBAAuB,CAAC,yBAAyB,CAAC;QACrF,gBAAgB;QACT,6BAAwB,GAAG,uBAAuB,CAAC,+BAA+B,CAAC;QAC1F,gBAAgB;QACT,yBAAoB,GAAG,uBAAuB,CAAC,2BAA2B,CAAC;IAGpF,CAAC;;AAjCD,0DAiCC;AAhCe,iDAAyB,GAAG,EAAE,GAAG,IAAI,CAAC;AACtC,uDAA+B,GAAG,EAAE,CAAC;AACrC,mDAA2B,GAAG,EAAE,GAAG,OAAO,CAAC;AACzD,gBAAgB;AACF,iDAAyB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AA8B/D;;;GAGG;AACH,MAAM,mBAAoB,SAAQ,uBAAY;IAe5C;QACE,KAAK,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;OAGG;IACI,kBAAkB,CAAC,UAAkB,IAAwB,OAAO,UAAU,CAAC,CAAC,CAAC;IACxF;;;;OAIG;IACI,eAAe,CAAC,UAAkB;QACvC,MAAM,gBAAgB,GAAuB,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACjF,IAAI,SAAS,KAAK,gBAAgB,EAAE;YAClC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,GAAG,UAAU,eAAe,CAAC,CAAC;SAC5E;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AAnCD,4CAmCC","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 IModelHost\r\n */\r\n\r\nimport { IModelJsNative, NativeLibrary } from \"@bentley/imodeljs-native\";\r\nimport { AzureServerStorageBindings } from \"@itwin/object-storage-azure\";\r\nimport { DependenciesConfig, Types as ExtensionTypes } from \"@itwin/cloud-agnostic-core\";\r\nimport { ServerStorage } from \"@itwin/object-storage-core\";\r\nimport { AccessToken, assert, BeEvent, Guid, GuidString, IModelStatus, Logger, LogLevel, Mutable, ProcessDetector } from \"@itwin/core-bentley\";\r\nimport { AuthorizationClient, BentleyStatus, IModelError, LocalDirName, SessionProps } from \"@itwin/core-common\";\r\nimport { TelemetryManager } from \"@itwin/core-telemetry\";\r\nimport { Container } from \"inversify\";\r\nimport * as os from \"os\";\r\nimport * as path from \"path\";\r\nimport { BackendHubAccess } from \"./BackendHubAccess\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { BisCoreSchema } from \"./BisCoreSchema\";\r\nimport { BriefcaseManager } from \"./BriefcaseManager\";\r\nimport { AzureBlobStorage, AzureBlobStorageCredentials, CloudStorageService, CloudStorageTileUploader } from \"./CloudStorageBackend\";\r\nimport { FunctionalSchema } from \"./domains/FunctionalSchema\";\r\nimport { GenericSchema } from \"./domains/GenericSchema\";\r\nimport { GeoCoordConfig } from \"./GeoCoordConfig\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\nimport { DevToolsRpcImpl } from \"./rpc-impl/DevToolsRpcImpl\";\r\nimport { IModelReadRpcImpl } from \"./rpc-impl/IModelReadRpcImpl\";\r\nimport { IModelTileRpcImpl } from \"./rpc-impl/IModelTileRpcImpl\";\r\nimport { SnapshotIModelRpcImpl } from \"./rpc-impl/SnapshotIModelRpcImpl\";\r\nimport { WipRpcImpl } from \"./rpc-impl/WipRpcImpl\";\r\nimport { initializeRpcBackend } from \"./RpcBackend\";\r\nimport { TileStorage } from \"./TileStorage\";\r\nimport { BaseSettings, SettingDictionary, SettingsPriority } from \"./workspace/Settings\";\r\nimport { SettingsSchemas } from \"./workspace/SettingsSchemas\";\r\nimport { ITwinWorkspace, Workspace, WorkspaceOpts } from \"./workspace/Workspace\";\r\n\r\nconst loggerCategory = BackendLoggerCategory.IModelHost;\r\n\r\n// cspell:ignore nodereport fatalerror apicall alicloud rpcs\r\n\r\n/** @alpha */\r\nexport interface CrashReportingConfigNameValuePair {\r\n name: string;\r\n value: string;\r\n}\r\n\r\n/** Configuration of the crash-reporting system.\r\n * @alpha\r\n */\r\nexport interface CrashReportingConfig {\r\n /** The directory to which *.dmp and/or iModelJsNativeCrash*.properties.txt files are written. This directory will be created if it does not already exist. */\r\n crashDir: string;\r\n /** max # .dmp files that may exist in crashDir. The default is 50. */\r\n maxDumpsInDir?: number;\r\n /** Enable crash-dumps? If so, .dmp and .properties.txt files will be generated and written to crashDir in the event of an unhandled native-code exception. If not, only .properties.txt files will be written. The default is false. */\r\n enableCrashDumps?: boolean;\r\n /** If enableCrashDumps is true, do you want a full-memory dump? Defaults to false. */\r\n wantFullMemoryDumps?: boolean;\r\n /** Enable Node.js crash reporting? If so, report files will be generated in the event of an unhandled exception or fatal error and written to crashDir. The default is false. */\r\n enableNodeReport?: boolean;\r\n /** Additional name, value pairs to write to iModelJsNativeCrash*.properties.txt file in the event of a crash. */\r\n params?: CrashReportingConfigNameValuePair[];\r\n /** Run this .js file to process .dmp and Node.js crash reporting .json files in the event of a crash.\r\n * This script will be executed with a single command-line parameter: the name of the dump or Node.js report file.\r\n * In the case of a dump file, there will be a second file with the same basename and the extension \".properties.txt\".\r\n * Since it runs in a separate process, this script will have no access to the Javascript\r\n * context of the exiting backend. No default.\r\n */\r\n dumpProcessorScriptFileName?: string;\r\n /** Upload crash dump and node-reports to Bentley's crash-reporting service? Defaults to false */\r\n uploadToBentley?: boolean;\r\n}\r\n\r\n/**\r\n * Options for [[IModelHost.startup]]\r\n * @public\r\n */\r\nexport interface IModelHostOptions {\r\n /**\r\n * Root of the directory holding all the files that iTwin.js caches\r\n * - If not specified at startup a platform specific default is used -\r\n * - Windows: $(HOMEDIR)/AppData/Local/iModelJs/\r\n * - Mac/iOS: $(HOMEDIR)/Library/Caches/iModelJs/\r\n * - Linux: $(HOMEDIR)/.cache/iModelJs/\r\n * where $(HOMEDIR) is documented [here](https://nodejs.org/api/os.html#os_os_homedir)\r\n * - if specified, ensure it is set to a folder with read/write access.\r\n * - Sub-folders within this folder organize various caches -\r\n * - bc/ -> Briefcases\r\n * - appSettings/ -> Offline application settings (only relevant in native applications)\r\n * - etc.\r\n * @see [[IModelHost.cacheDir]] for the value it's set to after startup\r\n */\r\n cacheDir?: LocalDirName;\r\n\r\n /** The directory where application assets are found. */\r\n appAssetsDir?: LocalDirName;\r\n\r\n /**\r\n * Options for creating the [[Workspace]]\r\n * @beta\r\n */\r\n workspace?: WorkspaceOpts;\r\n\r\n /**\r\n * The kind of iModel hub server to use.\r\n * @beta\r\n */\r\n hubAccess?: BackendHubAccess;\r\n\r\n /** The Azure blob storage credentials to use for the tile cache service. If omitted and no external service implementation is provided, a local cache will be used.\r\n * @beta\r\n */\r\n tileCacheAzureCredentials?: AzureBlobStorageCredentials;\r\n\r\n /**\r\n * @beta\r\n * @deprecated in 3.x. Use [[tileCacheStorage]] instead.\r\n */\r\n tileCacheService?: CloudStorageService; // eslint-disable-line deprecation/deprecation\r\n\r\n /**\r\n * @beta\r\n * @note A reference implementation is set for AzureServerStorage from @itwin/object-storage-azure if [[tileCacheAzureCredentials]] property is set. To supply a different implementation for any service provider (such as AWS),\r\n * set this property with a custom ServerStorage.\r\n */\r\n tileCacheStorage?: ServerStorage;\r\n\r\n /** The maximum size in bytes to which a local sqlite database used for caching tiles can grow before it is purged of least-recently-used tiles.\r\n * The local cache is used only if an external cache has not been configured via [[tileCacheService]], [[tileCacheStorage]], and [[tileCacheAzureCredentials]].\r\n * Defaults to 1 GB. Must be an unsigned integer. A value of zero disables the local cache entirely.\r\n * @beta\r\n */\r\n maxTileCacheDbSize?: number;\r\n\r\n /** Whether to restrict tile cache URLs by client IP address (if available).\r\n * @beta\r\n */\r\n restrictTileUrlsByClientIp?: boolean;\r\n\r\n /**\r\n * Whether to enable OpenTelemetry tracing\r\n * @beta\r\n */\r\n enableOpenTelemetry?: boolean;\r\n\r\n /** Whether to compress cached tiles.\r\n * Defaults to `true`.\r\n */\r\n compressCachedTiles?: boolean;\r\n\r\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileTreeProps]($common) should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n tileTreeRequestTimeout?: number;\r\n\r\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileContent]($common) should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n tileContentRequestTimeout?: number;\r\n\r\n /** The backend will log when a tile took longer to load than this threshold in seconds.\r\n * @internal\r\n */\r\n logTileLoadTimeThreshold?: number;\r\n\r\n /** The backend will log when a tile is loaded with a size in bytes above this threshold.\r\n * @internal\r\n */\r\n logTileSizeThreshold?: number;\r\n\r\n /** Crash-reporting configuration\r\n * @alpha\r\n */\r\n crashReportingConfig?: CrashReportingConfig;\r\n\r\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\r\n authorizationClient?: AuthorizationClient;\r\n}\r\n\r\n/** Configuration of core-backend.\r\n * @public\r\n */\r\nexport class IModelHostConfiguration implements IModelHostOptions {\r\n public static defaultTileRequestTimeout = 20 * 1000;\r\n public static defaultLogTileLoadTimeThreshold = 40;\r\n public static defaultLogTileSizeThreshold = 20 * 1000000;\r\n /** @internal */\r\n public static defaultMaxTileCacheDbSize = 1024 * 1024 * 1024;\r\n\r\n public appAssetsDir?: LocalDirName;\r\n public cacheDir?: LocalDirName;\r\n\r\n /** @beta */\r\n public workspace?: WorkspaceOpts;\r\n /** @beta */\r\n public hubAccess?: BackendHubAccess;\r\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\r\n public authorizationClient?: AuthorizationClient;\r\n /** @beta @deprecated in 3.x. Use [[tileCacheStorage]] instead. */\r\n public tileCacheService?: CloudStorageService; // eslint-disable-line deprecation/deprecation\r\n /** @beta */\r\n public restrictTileUrlsByClientIp?: boolean;\r\n public compressCachedTiles?: boolean;\r\n /** @beta */\r\n public tileCacheAzureCredentials?: AzureBlobStorageCredentials;\r\n /** @internal */\r\n public tileTreeRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\r\n /** @internal */\r\n public tileContentRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\r\n /** @internal */\r\n public logTileLoadTimeThreshold = IModelHostConfiguration.defaultLogTileLoadTimeThreshold;\r\n /** @internal */\r\n public logTileSizeThreshold = IModelHostConfiguration.defaultLogTileSizeThreshold;\r\n /** @alpha */\r\n public crashReportingConfig?: CrashReportingConfig;\r\n}\r\n\r\n/**\r\n * Settings for `IModelHost.appWorkspace`.\r\n * @note this includes the default dictionary from the SettingsSpecRegistry\r\n */\r\nclass ApplicationSettings extends BaseSettings {\r\n private _remove?: VoidFunction;\r\n protected override verifyPriority(priority: SettingsPriority) {\r\n if (priority >= SettingsPriority.iModel) // iModel settings may not appear in ApplicationSettings\r\n throw new Error(\"Use IModelSettings\");\r\n }\r\n private updateDefaults() {\r\n const defaults: SettingDictionary = {};\r\n for (const [schemaName, val] of SettingsSchemas.allSchemas) {\r\n if (val.default)\r\n defaults[schemaName] = val.default;\r\n }\r\n this.addDictionary(\"_default_\", 0, defaults);\r\n }\r\n\r\n public constructor() {\r\n super();\r\n this._remove = SettingsSchemas.onSchemaChanged.addListener(() => this.updateDefaults());\r\n this.updateDefaults();\r\n }\r\n\r\n public override close() {\r\n if (this._remove) {\r\n this._remove();\r\n this._remove = undefined;\r\n }\r\n }\r\n}\r\n\r\n/** IModelHost initializes ($backend) and captures its configuration. A backend must call [[IModelHost.startup]] before using any backend classes.\r\n * See [the learning article]($docs/learning/backend/IModelHost.md)\r\n * @public\r\n */\r\nexport class IModelHost {\r\n private constructor() { }\r\n\r\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\r\n public static authorizationClient?: AuthorizationClient;\r\n\r\n /** @alpha */\r\n public static readonly telemetry = new TelemetryManager();\r\n\r\n public static backendVersion = \"\";\r\n private static _cacheDir = \"\";\r\n private static _appWorkspace?: Workspace;\r\n\r\n private static _platform?: typeof IModelJsNative;\r\n /** @internal */\r\n public static get platform(): typeof IModelJsNative {\r\n if (this._platform === undefined)\r\n throw new Error(\"IModelHost.startup must be called first\");\r\n return this._platform;\r\n }\r\n\r\n public static configuration?: IModelHostOptions;\r\n\r\n /** Event raised during startup to allow loading settings data */\r\n public static readonly onWorkspaceStartup = new BeEvent<() => void>();\r\n\r\n /** Event raised just after the backend IModelHost was started */\r\n public static readonly onAfterStartup = new BeEvent<() => void>();\r\n\r\n /** Event raised just before the backend IModelHost is to be shut down */\r\n public static readonly onBeforeShutdown = new BeEvent<() => void>();\r\n\r\n /** @internal */\r\n public static readonly session: Mutable<SessionProps> = { applicationId: \"2686\", applicationVersion: \"1.0.0\", sessionId: \"\" };\r\n\r\n /** A uniqueId for this session */\r\n public static get sessionId() { return this.session.sessionId; }\r\n public static set sessionId(id: GuidString) { this.session.sessionId = id; }\r\n\r\n /** The Id of this application - needs to be set only if it is an agent application. The applicationId will otherwise originate at the frontend. */\r\n public static get applicationId() { return this.session.applicationId; }\r\n public static set applicationId(id: string) { this.session.applicationId = id; }\r\n\r\n /** The version of this application - needs to be set if is an agent application. The applicationVersion will otherwise originate at the frontend. */\r\n public static get applicationVersion() { return this.session.applicationVersion; }\r\n public static set applicationVersion(version: string) { this.session.applicationVersion = version; }\r\n\r\n /** Root directory holding files that iTwin.js caches */\r\n public static get cacheDir(): LocalDirName { return this._cacheDir; }\r\n\r\n /** The application [[Workspace]] for this `IModelHost`\r\n * @note this `Workspace` only holds [[WorkspaceContainer]]s and [[Settings]] scoped to the currently loaded application(s).\r\n * All organization, iTwin, and iModel based containers or settings must be accessed through [[IModelDb.workspace]] and\r\n * attempting to add them to this Workspace will fail.\r\n * @beta\r\n */\r\n public static get appWorkspace(): Workspace { return this._appWorkspace!; } // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n\r\n /** The optional [[FileNameResolver]] that resolves keys and partial file names for snapshot iModels. */\r\n public static snapshotFileNameResolver?: FileNameResolver;\r\n\r\n /** Get the current access token for this IModelHost, or a blank string if none is available.\r\n * @note for web backends, this will *always* return a blank string because the backend itself has no token (but never needs one either.)\r\n * For all IpcHosts, where this backend is servicing a single frontend, this will be the user's token. For ElectronHost, the backend\r\n * obtains the token and forwards it to the frontend.\r\n * @note accessTokens expire periodically and are automatically refreshed, if possible. Therefore tokens should not be saved, and the value\r\n * returned by this method may change over time throughout the course of a session.\r\n */\r\n public static async getAccessToken(): Promise<AccessToken> {\r\n try {\r\n return (await this.authorizationClient?.getAccessToken()) ?? \"\";\r\n } catch (e) {\r\n return \"\";\r\n }\r\n }\r\n\r\n /** @internal */\r\n public static flushLog() {\r\n return this.platform.flushLog();\r\n }\r\n /** @internal */\r\n public static loadNative(): void {\r\n const platform = Platform.load();\r\n this.registerPlatform(platform);\r\n }\r\n private static syncNativeLogLevels() {\r\n this.platform.clearLogLevelCache();\r\n }\r\n\r\n private static registerPlatform(platform: typeof IModelJsNative): void {\r\n this._platform = platform;\r\n if (undefined === platform)\r\n return;\r\n\r\n platform.logger = Logger;\r\n Logger.logLevelChangedFn = () => IModelHost.syncNativeLogLevels();\r\n }\r\n\r\n /**\r\n * @internal\r\n * @deprecated in 3.x. Use [[IModelHost.tileStorage]] instead.\r\n * @note Use [[IModelHostOptions.tileCacheService]] to set the service provider.\r\n */\r\n public static tileCacheService?: CloudStorageService; // eslint-disable-line deprecation/deprecation\r\n\r\n /** @internal */\r\n public static tileStorage?: TileStorage;\r\n\r\n /**\r\n * @internal\r\n * @deprecated in 3.x. Use [[IModelHost.tileStorage]] instead.\r\n */\r\n public static tileUploader?: CloudStorageTileUploader; // eslint-disable-line deprecation/deprecation\r\n\r\n private static _hubAccess?: BackendHubAccess;\r\n /** @internal */\r\n public static setHubAccess(hubAccess: BackendHubAccess | undefined) { this._hubAccess = hubAccess; }\r\n\r\n /** get the current hubAccess, if present.\r\n * @beta\r\n */\r\n public static getHubAccess(): BackendHubAccess | undefined { return this._hubAccess; }\r\n\r\n /** Provides access to the IModelHub for this IModelHost\r\n * @beta\r\n * @note If [[IModelHostOptions.hubAccess]] was undefined when initializing this class, accessing this property will throw an error.\r\n * To determine whether one is present, use [[getHubAccess]].\r\n */\r\n public static get hubAccess(): BackendHubAccess {\r\n if (this._hubAccess === undefined)\r\n throw new IModelError(IModelStatus.BadRequest, \"No BackendHubAccess supplied in IModelHostOptions\");\r\n return this._hubAccess;\r\n }\r\n\r\n private static initializeWorkspace(configuration: IModelHostOptions) {\r\n const settingAssets = path.join(KnownLocations.packageAssetsDir, \"Settings\");\r\n SettingsSchemas.addDirectory(path.join(settingAssets, \"Schemas\"));\r\n this._appWorkspace = new ITwinWorkspace(new ApplicationSettings(), configuration.workspace);\r\n this.appWorkspace.settings.addDirectory(settingAssets, SettingsPriority.defaults);\r\n\r\n GeoCoordConfig.onStartup();\r\n // allow applications to load their default settings\r\n this.onWorkspaceStartup.raiseEvent();\r\n }\r\n\r\n private static _isValid = false;\r\n /** Returns true if IModelHost is started. */\r\n public static get isValid() { return this._isValid; }\r\n /** This method must be called before any iTwin.js services are used.\r\n * @param options Host configuration data.\r\n * Raises [[onAfterStartup]].\r\n * @see [[shutdown]].\r\n */\r\n public static async startup(options?: IModelHostOptions): Promise<void> {\r\n if (this._isValid)\r\n return; // we're already initialized\r\n this._isValid = true;\r\n\r\n options = options ?? {};\r\n if (IModelHost.sessionId === \"\")\r\n IModelHost.sessionId = Guid.createValue();\r\n\r\n this.authorizationClient = options.authorizationClient;\r\n\r\n this.logStartup();\r\n\r\n this.backendVersion = require(\"../../package.json\").version; // eslint-disable-line @typescript-eslint/no-var-requires\r\n initializeRpcBackend(options.enableOpenTelemetry);\r\n\r\n if (this._platform === undefined) {\r\n try {\r\n this.loadNative();\r\n } catch (error) {\r\n Logger.logError(loggerCategory, \"Error registering/loading the native platform API\", () => (options));\r\n throw error;\r\n }\r\n }\r\n\r\n if (options.crashReportingConfig && options.crashReportingConfig.crashDir && !ProcessDetector.isElectronAppBackend && !ProcessDetector.isMobileAppBackend) {\r\n this.platform.setCrashReporting(options.crashReportingConfig);\r\n\r\n Logger.logTrace(loggerCategory, \"Configured crash reporting\", {\r\n enableCrashDumps: options.crashReportingConfig?.enableCrashDumps,\r\n wantFullMemoryDumps: options.crashReportingConfig?.wantFullMemoryDumps,\r\n enableNodeReport: options.crashReportingConfig?.enableNodeReport,\r\n uploadToBentley: options.crashReportingConfig?.uploadToBentley,\r\n });\r\n\r\n if (options.crashReportingConfig.enableNodeReport) {\r\n if (process.report !== undefined) {\r\n process.report.reportOnFatalError = true;\r\n process.report.reportOnUncaughtException = true;\r\n process.report.directory = options.crashReportingConfig.crashDir;\r\n Logger.logTrace(loggerCategory, \"Configured Node.js crash reporting\");\r\n } else {\r\n Logger.logWarning(loggerCategory, \"Unable to configure Node.js crash reporting\");\r\n }\r\n }\r\n }\r\n\r\n this.setupHostDirs(options);\r\n this.initializeWorkspace(options);\r\n\r\n BriefcaseManager.initialize(this._briefcaseCacheDir);\r\n\r\n [\r\n IModelReadRpcImpl,\r\n IModelTileRpcImpl,\r\n SnapshotIModelRpcImpl,\r\n WipRpcImpl,\r\n DevToolsRpcImpl,\r\n ].forEach((rpc) => rpc.register()); // register all of the RPC implementations\r\n\r\n [\r\n BisCoreSchema,\r\n GenericSchema,\r\n FunctionalSchema,\r\n ].forEach((schema) => schema.registerSchema()); // register all of the schemas\r\n\r\n if (undefined !== options.hubAccess)\r\n this._hubAccess = options.hubAccess;\r\n\r\n this.configuration = options;\r\n this.setupTileCache();\r\n\r\n process.once(\"beforeExit\", IModelHost.shutdown);\r\n this.onAfterStartup.raiseEvent();\r\n }\r\n\r\n private static _briefcaseCacheDir: LocalDirName;\r\n\r\n private static logStartup() {\r\n if (!Logger.isEnabled(loggerCategory, LogLevel.Trace))\r\n return;\r\n\r\n // Extract the iModel details from environment - note this is very specific to Bentley hosted backends, but is quite useful for tracing\r\n let startupInfo: any = {};\r\n const serviceName = process.env.FABRIC_SERVICE_NAME;\r\n if (serviceName) {\r\n // e.g., fabric:/iModelWebViewer3.0/iModelJSGuest/1/08daaeb3-b56f-480b-9051-7efc834d18ae/512d971d-b641-4735-bb1c-c07ab3e44ce7/c1315fcce125ca40b2d405bb7809214daf8b4c85\r\n const serviceNameComponents = serviceName.split(\"/\");\r\n if (serviceNameComponents.length === 7) {\r\n startupInfo = {\r\n ...startupInfo,\r\n iTwinId: serviceNameComponents[4],\r\n iModelId: serviceNameComponents[5],\r\n changesetId: serviceNameComponents[6],\r\n };\r\n }\r\n }\r\n\r\n Logger.logTrace(loggerCategory, \"IModelHost.startup\", () => startupInfo);\r\n }\r\n\r\n private static setupHostDirs(configuration: IModelHostOptions) {\r\n const setupDir = (dir: LocalDirName) => {\r\n dir = path.normalize(dir);\r\n IModelJsFs.recursiveMkDirSync(dir);\r\n return dir;\r\n };\r\n this._cacheDir = setupDir(configuration.cacheDir ?? NativeLibrary.defaultCacheDir);\r\n this._briefcaseCacheDir = path.join(this._cacheDir, \"imodels\");\r\n }\r\n\r\n /** This method must be called when an iTwin.js host is shut down. Raises [[onBeforeShutdown]] */\r\n public static async shutdown(): Promise<void> {\r\n // NB: This method is set as a node listener where `this` is unbound\r\n if (!IModelHost._isValid)\r\n return;\r\n\r\n IModelHost._isValid = false;\r\n IModelHost.onBeforeShutdown.raiseEvent();\r\n IModelHost.configuration = undefined;\r\n // eslint-disable-next-line deprecation/deprecation\r\n IModelHost.tileCacheService = undefined;\r\n // eslint-disable-next-line deprecation/deprecation\r\n IModelHost.tileUploader = undefined;\r\n IModelHost.tileStorage = undefined;\r\n IModelHost._appWorkspace?.close();\r\n IModelHost._appWorkspace = undefined;\r\n ITwinWorkspace.finalize();\r\n process.removeListener(\"beforeExit\", IModelHost.shutdown);\r\n }\r\n\r\n /**\r\n * Add or update a property that should be included in a crash report.\r\n * @param name The name of the property\r\n * @param value The value of the property\r\n * @alpha\r\n */\r\n public static setCrashReportProperty(name: string, value: string): void {\r\n assert(undefined !== this._platform);\r\n this._platform.setCrashReportProperty(name, value);\r\n }\r\n\r\n /**\r\n * Remove a previously defined property so that will not be included in a crash report.\r\n * @param name The name of the property\r\n * @alpha\r\n */\r\n public static removeCrashReportProperty(name: string): void {\r\n assert(undefined !== this._platform);\r\n this._platform.setCrashReportProperty(name, undefined);\r\n }\r\n\r\n /**\r\n * Get all properties that will be included in a crash report.\r\n * @alpha\r\n */\r\n public static getCrashReportProperties(): CrashReportingConfigNameValuePair[] {\r\n assert(undefined !== this._platform);\r\n return this._platform.getCrashReportProperties();\r\n }\r\n\r\n /** The directory where application assets may be found */\r\n public static get appAssetsDir(): string | undefined { return undefined !== IModelHost.configuration ? IModelHost.configuration.appAssetsDir : undefined; }\r\n\r\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileTreeProps should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n public static get tileTreeRequestTimeout(): number {\r\n return IModelHost.configuration?.tileTreeRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\r\n }\r\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileContent should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n public static get tileContentRequestTimeout(): number {\r\n return IModelHost.configuration?.tileContentRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\r\n }\r\n\r\n /** The backend will log when a tile took longer to load than this threshold in seconds. */\r\n public static get logTileLoadTimeThreshold(): number { return IModelHost.configuration?.logTileLoadTimeThreshold ?? IModelHostConfiguration.defaultLogTileLoadTimeThreshold; }\r\n /** The backend will log when a tile is loaded with a size in bytes above this threshold. */\r\n public static get logTileSizeThreshold(): number { return IModelHost.configuration?.logTileSizeThreshold ?? IModelHostConfiguration.defaultLogTileSizeThreshold; }\r\n\r\n /** Whether external tile caching is active.\r\n * @internal\r\n */\r\n public static get usingExternalTileCache(): boolean {\r\n return undefined !== IModelHost.tileStorage;\r\n }\r\n\r\n /** Whether to restrict tile cache URLs by client IP address.\r\n * @internal\r\n */\r\n public static get restrictTileUrlsByClientIp(): boolean { return undefined !== IModelHost.configuration && (IModelHost.configuration.restrictTileUrlsByClientIp ? true : false); }\r\n\r\n /** Whether to compress cached tiles.\r\n * @internal\r\n */\r\n public static get compressCachedTiles(): boolean { return false !== IModelHost.configuration?.compressCachedTiles; }\r\n\r\n private static setupTileCache() {\r\n assert(undefined !== IModelHost.configuration);\r\n const config = IModelHost.configuration;\r\n // eslint-disable-next-line deprecation/deprecation\r\n const service = config.tileCacheService;\r\n const storage = config.tileCacheStorage;\r\n const credentials = config.tileCacheAzureCredentials;\r\n\r\n if (!service && !storage && !credentials) {\r\n this.platform.setMaxTileCacheSize(config.maxTileCacheDbSize ?? IModelHostConfiguration.defaultMaxTileCacheDbSize);\r\n return;\r\n }\r\n\r\n this.platform.setMaxTileCacheSize(0);\r\n // eslint-disable-next-line deprecation/deprecation\r\n IModelHost.tileUploader = new CloudStorageTileUploader();\r\n if (credentials) {\r\n if (storage || service)\r\n throw new IModelError(BentleyStatus.ERROR, \"Cannot use both Azure and custom cloud storage providers for tile cache.\");\r\n this.setupAzureTileCache(credentials);\r\n }\r\n if (service) {\r\n if (!storage)\r\n Logger.logWarning(loggerCategory, \"Using tileCacheService without tileCacheStorage is unsupported\");\r\n IModelHost.tileCacheService = service; // eslint-disable-line deprecation/deprecation\r\n }\r\n if (storage)\r\n IModelHost.tileStorage = new TileStorage(storage);\r\n }\r\n\r\n private static setupAzureTileCache(credentials: AzureBlobStorageCredentials) {\r\n const config = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n ServerSideStorage: {\r\n dependencyName: \"azure\",\r\n accountName: credentials.account,\r\n accountKey: credentials.accessKey,\r\n baseUrl: credentials.baseUrl ?? `https://${credentials.account}.blob.core.windows.net`,\r\n },\r\n };\r\n const ioc: Container = new Container();\r\n ioc.bind<DependenciesConfig>(ExtensionTypes.dependenciesConfig).toConstantValue(config);\r\n new AzureServerStorageBindings().register(ioc, config.ServerSideStorage);\r\n IModelHost.tileStorage = new TileStorage(ioc.get(ServerStorage));\r\n // eslint-disable-next-line deprecation/deprecation\r\n IModelHost.tileCacheService = new AzureBlobStorage(credentials); // needed for backwards compatibility with old frontends\r\n }\r\n\r\n /** @internal */\r\n public static computeSchemaChecksum(arg: { schemaXmlPath: string, referencePaths: string[], exactMatch?: boolean }): string {\r\n return this.platform.computeSchemaChecksum(arg);\r\n }\r\n}\r\n\r\n/** Information about the platform on which the app is running. Also see [[KnownLocations]] and [[IModelJsFs]].\r\n * @public\r\n */\r\nexport class Platform {\r\n /** Get the name of the platform. */\r\n public static get platformName(): \"win32\" | \"linux\" | \"darwin\" | \"ios\" | \"android\" | \"uwp\" {\r\n return process.platform as any;\r\n }\r\n\r\n /** @internal */\r\n public static load(): typeof IModelJsNative {\r\n return ProcessDetector.isMobileAppBackend ? (process as any)._linkedBinding(\"iModelJsNative\") : NativeLibrary.load();\r\n }\r\n}\r\n\r\n/** Well known directories that may be used by the application. Also see [[Platform]]\r\n * @public\r\n */\r\nexport class KnownLocations {\r\n\r\n /** The directory where the imodeljs-native assets are stored. */\r\n public static get nativeAssetsDir(): string { return IModelHost.platform.DgnDb.getAssetsDir(); }\r\n\r\n /** The directory where the core-backend assets are stored. */\r\n public static get packageAssetsDir(): string {\r\n return path.join(__dirname, \"assets\");\r\n }\r\n\r\n /** The temporary directory. */\r\n public static get tmpdir(): string {\r\n return os.tmpdir();\r\n }\r\n}\r\n\r\n/** Extend this class to provide custom file name resolution behavior.\r\n * @note Only `tryResolveKey` and/or `tryResolveFileName` need to be overridden as the implementations of `resolveKey` and `resolveFileName` work for most purposes.\r\n * @see [[IModelHost.snapshotFileNameResolver]]\r\n * @public\r\n */\r\nexport abstract class FileNameResolver {\r\n /** Resolve a file name from the specified key.\r\n * @param _fileKey The key that identifies the file name in a `Map` or other similar data structure.\r\n * @returns The resolved file name or `undefined` if not found.\r\n */\r\n public tryResolveKey(_fileKey: string): string | undefined { return undefined; }\r\n /** Resolve a file name from the specified key.\r\n * @param fileKey The key that identifies the file name in a `Map` or other similar data structure.\r\n * @returns The resolved file name.\r\n * @throws [[IModelError]] if not found.\r\n */\r\n public resolveKey(fileKey: string): string {\r\n const resolvedFileName: string | undefined = this.tryResolveKey(fileKey);\r\n if (undefined === resolvedFileName) {\r\n throw new IModelError(IModelStatus.NotFound, `${fileKey} not resolved`);\r\n }\r\n return resolvedFileName;\r\n }\r\n /** Resolve the input file name, which may be a partial name, into a full path file name.\r\n * @param inFileName The partial file name.\r\n * @returns The resolved full path file name or `undefined` if not found.\r\n */\r\n public tryResolveFileName(inFileName: string): string | undefined { return inFileName; }\r\n /** Resolve the input file name, which may be a partial name, into a full path file name.\r\n * @param inFileName The partial file name.\r\n * @returns The resolved full path file name.\r\n * @throws [[IModelError]] if not found.\r\n */\r\n public resolveFileName(inFileName: string): string {\r\n const resolvedFileName: string | undefined = this.tryResolveFileName(inFileName);\r\n if (undefined === resolvedFileName) {\r\n throw new IModelError(IModelStatus.NotFound, `${inFileName} not resolved`);\r\n }\r\n return resolvedFileName;\r\n }\r\n}\r\n"]}
@@ -35,7 +35,7 @@ export declare class IModelReadRpcImpl extends RpcInterface implements IModelRea
35
35
  getMassPropertiesPerCandidate(tokenProps: IModelRpcProps, props: MassPropertiesPerCandidateRequestProps): Promise<MassPropertiesPerCandidateResponseProps[]>;
36
36
  getToolTipMessage(tokenProps: IModelRpcProps, id: string): Promise<string[]>;
37
37
  /** Send a view thumbnail to the frontend. This is a binary transfer with the metadata in a 16-byte prefix header.
38
- * @deprecated in 3.x.
38
+ * @deprecated in 3.x with no replacement; thumbnails are rarely added to the iModel.
39
39
  */
40
40
  getViewThumbnail(_tokenProps: IModelRpcProps, _viewId: string): Promise<Uint8Array>;
41
41
  getDefaultViewId(tokenProps: IModelRpcProps): Promise<Id64String>;
@@ -248,7 +248,7 @@ class IModelReadRpcImpl extends core_common_1.RpcInterface {
248
248
  return (el === undefined) ? [] : el.getToolTipMessage();
249
249
  }
250
250
  /** Send a view thumbnail to the frontend. This is a binary transfer with the metadata in a 16-byte prefix header.
251
- * @deprecated in 3.x.
251
+ * @deprecated in 3.x with no replacement; thumbnails are rarely added to the iModel.
252
252
  */
253
253
  async getViewThumbnail(_tokenProps, _viewId) {
254
254
  const iModelDb = await RpcBriefcaseUtility_1.RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, _tokenProps);
@@ -1 +1 @@
1
- {"version":3,"file":"IModelReadRpcImpl.js","sourceRoot":"","sources":["../../../src/rpc-impl/IModelReadRpcImpl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAE6B;AAC7B,oDAQ4B;AAE5B,0CAA8C;AAC9C,wDAAqD;AACrD,wDAA+D;AAE/D,+DAA4D;AAC5D,4CAA0C;AAC1C,oEAAiE;AACjE,0EAAuE;AACvE,4DAAyD;AACzD,wDAAqD;AAQrD,MAAM,wBAAyB,SAAQ,iCAAuC;IAW5E;QACE,MAAM,OAAO,GAAG,KAAK,EAAE,KAA4B,EAAE,EAAE;YACrD,MAAM,E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H,MAAM,QAAQ,GAAG,MAAM,yCAAmB,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACrG,OAAO,QAAQ,CAAC,sCAAsC,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;IAEM,KAAK,CAAC,sCAAsC,CAAC,UAA0B,EAAE,KAAiC;QAC/G,MAAM,QAAQ,GAAG,MAAM,yCAAmB,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACrG,OAAO,QAAQ,CAAC,sCAAsC,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,UAA0B,EAAE,gBAAkC;QAC1F,MAAM,EAAE,GAAG,MAAM,yCAAmB,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAC/F,OAAO,EAAE,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAC/C,CAAC;IAEM,KAAK,CAAC,qBAAqB,CAAC,WAA2B,EAAE,KAA8B;QAC5F,MAAM,EAAE,GAAG,MAAM,yCAAmB,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAChG,OAAO,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;CACF;AA9QD,8CA8QC","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 {\r\n AccessToken, assert, BeDuration, BentleyStatus, CompressedId64Set, GuidString, Id64, Id64String, IModelStatus, Logger,\r\n} from \"@itwin/core-bentley\";\r\nimport {\r\n Code, CodeProps, CustomViewState3dCreatorOptions, CustomViewState3dProps, DbBlobRequest, DbBlobResponse, DbQueryRequest, DbQueryResponse, ElementLoadOptions, ElementLoadProps,\r\n ElementMeshRequestProps, ElementProps, EntityMetaData, EntityQueryParams, FontMapProps, GeoCoordinatesRequestProps, GeoCoordinatesResponseProps, GeometryContainmentRequestProps,\r\n GeometryContainmentResponseProps, GeometrySummaryRequestProps, HydrateViewStateRequestProps, HydrateViewStateResponseProps, ImageSourceFormat, IModel,\r\n IModelConnectionProps, IModelCoordinatesRequestProps, IModelCoordinatesResponseProps, IModelError, IModelReadRpcInterface, IModelRpcOpenProps,\r\n IModelRpcProps, MassPropertiesPerCandidateRequestProps, MassPropertiesPerCandidateResponseProps, MassPropertiesRequestProps, MassPropertiesResponseProps, ModelExtentsProps,\r\n ModelProps, NoContentError, RpcInterface, RpcManager, RpcPendingResponse, SnapRequestProps, SnapResponseProps, SubCategoryResultRow, SyncMode, TextureData, TextureLoadProps,\r\n ViewStateLoadProps, ViewStateProps,\r\n} from \"@itwin/core-common\";\r\nimport { Range3dProps } from \"@itwin/core-geometry\";\r\nimport { SpatialCategory } from \"../Category\";\r\nimport { ConcurrentQuery } from \"../ConcurrentQuery\";\r\nimport { generateGeometrySummaries } from \"../GeometrySummary\";\r\nimport { DictionaryModel } from \"../Model\";\r\nimport { RpcBriefcaseUtility } from \"./RpcBriefcaseUtility\";\r\nimport { RpcTrace } from \"../rpc/tracing\";\r\nimport { BackendLoggerCategory } from \"../BackendLoggerCategory\";\r\nimport { CustomViewState3dCreator } from \"../CustomViewState3dCreator\";\r\nimport { ViewStateHydrator } from \"../ViewStateHydrator\";\r\nimport { PromiseMemoizer } from \"../PromiseMemoizer\";\r\n\r\ninterface ViewStateRequestProps {\r\n accessToken: AccessToken;\r\n tokenProps: IModelRpcProps;\r\n options: CustomViewState3dCreatorOptions;\r\n}\r\n\r\nclass ViewStateRequestMemoizer extends PromiseMemoizer<CustomViewState3dProps> {\r\n private readonly _timeoutMs: number;\r\n private static _instance?: ViewStateRequestMemoizer;\r\n\r\n public static async perform(props: ViewStateRequestProps): Promise<CustomViewState3dProps> {\r\n if (!this._instance)\r\n this._instance = new ViewStateRequestMemoizer();\r\n\r\n return this._instance.perform(props);\r\n }\r\n\r\n private constructor() {\r\n const memoize = async (props: ViewStateRequestProps) => {\r\n const db = await RpcBriefcaseUtility.findOpenIModel(props.accessToken, props.tokenProps);\r\n const viewCreator = new CustomViewState3dCreator(db);\r\n return viewCreator.getCustomViewState3dData(props.options);\r\n };\r\n\r\n const stringify = (props: ViewStateRequestProps) => {\r\n const token = props.tokenProps;\r\n const modelIds = props.options.modelIds;\r\n return `${token.key}-${token.iTwinId}-${token.iModelId}-${token.changeset?.id}:${modelIds}`;\r\n };\r\n\r\n super(memoize, stringify);\r\n this._timeoutMs = 20 * 1000;\r\n }\r\n\r\n private async perform(props: ViewStateRequestProps): Promise<CustomViewState3dProps> {\r\n const memo = this.memoize(props);\r\n\r\n // Rejections must be caught so that the memoization entry is deleted.\r\n await BeDuration.race(this._timeoutMs, memo.promise).catch(() => undefined);\r\n\r\n if (memo.isPending)\r\n throw new RpcPendingResponse(); // eslint-disable-line deprecation/deprecation\r\n\r\n this.deleteMemoized(props);\r\n\r\n if (memo.isFulfilled) {\r\n assert(undefined !== memo.result);\r\n return memo.result;\r\n }\r\n\r\n assert(memo.isRejected);\r\n throw memo.error; // eslint-disable-line no-throw-literal\r\n }\r\n}\r\n\r\nfunction currentActivity() {\r\n return RpcTrace.expectCurrentActivity; // eslint-disable-line deprecation/deprecation\r\n}\r\n\r\n/** The backend implementation of IModelReadRpcInterface.\r\n * @internal\r\n */\r\nexport class IModelReadRpcImpl extends RpcInterface implements IModelReadRpcInterface { // eslint-disable-line deprecation/deprecation\r\n\r\n public static register() { RpcManager.registerImpl(IModelReadRpcInterface, IModelReadRpcImpl); }\r\n\r\n public async getConnectionProps(tokenProps: IModelRpcOpenProps): Promise<IModelConnectionProps> {\r\n return RpcBriefcaseUtility.openWithTimeout(currentActivity(), tokenProps, SyncMode.FixedVersion);\r\n }\r\n\r\n public async getCustomViewState3dData(tokenProps: IModelRpcProps, options: CustomViewState3dCreatorOptions): Promise<CustomViewState3dProps> {\r\n const accessToken = currentActivity().accessToken;\r\n return ViewStateRequestMemoizer.perform({ accessToken, tokenProps, options });\r\n }\r\n\r\n public async hydrateViewState(tokenProps: IModelRpcProps, options: HydrateViewStateRequestProps): Promise<HydrateViewStateResponseProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const viewHydrater = new ViewStateHydrator(iModelDb);\r\n return viewHydrater.getHydrateResponseProps(options);\r\n }\r\n\r\n public async querySubCategories(tokenProps: IModelRpcProps, compressedCategoryIds: CompressedId64Set): Promise<SubCategoryResultRow[]> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const decompressedIds = CompressedId64Set.decompressArray(compressedCategoryIds);\r\n return iModelDb.querySubCategories(decompressedIds);\r\n }\r\n\r\n public async queryRows(tokenProps: IModelRpcProps, request: DbQueryRequest): Promise<DbQueryResponse> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n if (iModelDb.isReadonly && request.usePrimaryConn === true) {\r\n Logger.logWarning(BackendLoggerCategory.IModelDb, \"usePrimaryConn is only supported on imodel that is opened in read/write mode. The option will be ignored.\", request);\r\n request.usePrimaryConn = false;\r\n }\r\n return ConcurrentQuery.executeQueryRequest(iModelDb.nativeDb, request);\r\n }\r\n\r\n public async queryBlob(tokenProps: IModelRpcProps, request: DbBlobRequest): Promise<DbBlobResponse> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n if (iModelDb.isReadonly && request.usePrimaryConn === true) {\r\n Logger.logWarning(BackendLoggerCategory.IModelDb, \"usePrimaryConn is only supported on imodel that is opened in read/write mode. The option will be ignored.\", request);\r\n request.usePrimaryConn = false;\r\n }\r\n return ConcurrentQuery.executeBlobRequest(iModelDb.nativeDb, request);\r\n }\r\n\r\n public async queryModelRanges(tokenProps: IModelRpcProps, modelIds: Id64String[]): Promise<Range3dProps[]> {\r\n const results = await this.queryModelExtents(tokenProps, modelIds);\r\n if (results.length === 1 && results[0].status !== IModelStatus.Success)\r\n throw new IModelError(results[0].status, \"error querying model range\");\r\n\r\n return results.filter((x) => x.status === IModelStatus.Success).map((x) => x.extents);\r\n }\r\n\r\n public async queryModelExtents(tokenProps: IModelRpcProps, modelIds: Id64String[]): Promise<ModelExtentsProps[]> {\r\n const iModel = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModel.models.queryExtents(modelIds);\r\n }\r\n\r\n public async getModelProps(tokenProps: IModelRpcProps, modelIdsList: Id64String[]): Promise<ModelProps[]> {\r\n const modelIds = new Set(modelIdsList);\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const modelJsonArray: ModelProps[] = [];\r\n for (const id of modelIds) {\r\n try {\r\n const modelProps = iModelDb.models.getModelJson({ id });\r\n modelJsonArray.push(modelProps);\r\n } catch (error) {\r\n if (modelIds.size === 1)\r\n throw error; // if they're asking for more than one model, don't throw on error.\r\n }\r\n }\r\n return modelJsonArray;\r\n }\r\n\r\n public async queryModelProps(tokenProps: IModelRpcProps, params: EntityQueryParams): Promise<ModelProps[]> {\r\n const ids = await this.queryEntityIds(tokenProps, params);\r\n return this.getModelProps(tokenProps, [...ids]);\r\n }\r\n\r\n public async getElementProps(tokenProps: IModelRpcProps, elementIdsList: Id64String[]): Promise<ElementProps[]> {\r\n const elementIds = new Set(elementIdsList);\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const elementProps: ElementProps[] = [];\r\n for (const id of elementIds) {\r\n try {\r\n elementProps.push(iModelDb.elements.getElementJson({ id }));\r\n } catch (error) {\r\n if (elementIds.size === 1)\r\n throw error; // if they're asking for more than one element, don't throw on error.\r\n }\r\n }\r\n return elementProps;\r\n }\r\n\r\n public async loadElementProps(tokenProps: IModelRpcProps, identifier: Id64String | GuidString | CodeProps, options?: ElementLoadOptions): Promise<ElementProps | undefined> {\r\n const props: ElementLoadProps = options ? { ...options } : {};\r\n if (typeof identifier === \"string\") {\r\n if (Id64.isId64(identifier))\r\n props.id = identifier;\r\n else\r\n props.federationGuid = identifier;\r\n } else {\r\n props.code = Code.fromJSON(identifier);\r\n }\r\n\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.elements.tryGetElementProps(props);\r\n }\r\n\r\n public async getGeometrySummary(tokenProps: IModelRpcProps, request: GeometrySummaryRequestProps): Promise<string> {\r\n const iModel = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return generateGeometrySummaries(request, iModel);\r\n }\r\n\r\n public async queryElementProps(tokenProps: IModelRpcProps, params: EntityQueryParams): Promise<ElementProps[]> {\r\n const ids = await this.queryEntityIds(tokenProps, params);\r\n const res = this.getElementProps(tokenProps, [...ids]);\r\n return res;\r\n }\r\n\r\n public async queryEntityIds(tokenProps: IModelRpcProps, params: EntityQueryParams): Promise<Id64String[]> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const res = iModelDb.queryEntityIds(params);\r\n return [...res];\r\n }\r\n\r\n public async getClassHierarchy(tokenProps: IModelRpcProps, classFullName: string): Promise<string[]> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const classArray: string[] = [];\r\n while (true) {\r\n const classMetaData: EntityMetaData = iModelDb.getMetaData(classFullName);\r\n classArray.push(classFullName);\r\n if (!classMetaData.baseClasses || classMetaData.baseClasses.length === 0)\r\n break;\r\n\r\n classFullName = classMetaData.baseClasses[0];\r\n }\r\n return classArray;\r\n }\r\n\r\n public async getAllCodeSpecs(tokenProps: IModelRpcProps): Promise<any[]> {\r\n const codeSpecs: any[] = [];\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n iModelDb.withPreparedStatement(\"SELECT ECInstanceId AS id, name, jsonProperties FROM BisCore.CodeSpec\", (statement) => {\r\n for (const row of statement)\r\n codeSpecs.push({ id: row.id, name: row.name, jsonProperties: JSON.parse(row.jsonProperties) });\r\n });\r\n return codeSpecs;\r\n }\r\n\r\n public async getViewStateData(tokenProps: IModelRpcProps, viewDefinitionId: string, options?: ViewStateLoadProps): Promise<ViewStateProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.views.getViewStateProps(viewDefinitionId, options);\r\n }\r\n\r\n public async readFontJson(tokenProps: IModelRpcProps): Promise<FontMapProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.nativeDb.readFontMap();\r\n }\r\n\r\n public async requestSnap(tokenProps: IModelRpcProps, sessionId: string, props: SnapRequestProps): Promise<SnapResponseProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.requestSnap(sessionId, props);\r\n }\r\n\r\n public async cancelSnap(tokenProps: IModelRpcProps, sessionId: string): Promise<void> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.cancelSnap(sessionId);\r\n }\r\n\r\n public async getGeometryContainment(tokenProps: IModelRpcProps, props: GeometryContainmentRequestProps): Promise<GeometryContainmentResponseProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.getGeometryContainment(props);\r\n }\r\n\r\n public async getMassProperties(tokenProps: IModelRpcProps, props: MassPropertiesRequestProps): Promise<MassPropertiesResponseProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.getMassProperties(props);\r\n }\r\n\r\n public async getMassPropertiesPerCandidate(tokenProps: IModelRpcProps, props: MassPropertiesPerCandidateRequestProps): Promise<MassPropertiesPerCandidateResponseProps[]> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n\r\n const getSingleCandidateMassProperties = async (candidate: string) => {\r\n try {\r\n const massPropResults: MassPropertiesResponseProps[] = [];\r\n\r\n for (const op of props.operations) {\r\n const massProperties = await iModelDb.getMassProperties({ operation: op, candidates: [candidate] });\r\n massPropResults.push(massProperties);\r\n }\r\n\r\n let singleCandidateResult: MassPropertiesPerCandidateResponseProps = { status: BentleyStatus.ERROR, candidate };\r\n\r\n if (massPropResults.some((r) => r.status !== BentleyStatus.ERROR)) {\r\n singleCandidateResult.status = BentleyStatus.SUCCESS;\r\n for (const r of massPropResults.filter((mpr) => mpr.status !== BentleyStatus.ERROR)) {\r\n singleCandidateResult = { ...singleCandidateResult, ...r };\r\n }\r\n }\r\n\r\n return singleCandidateResult;\r\n } catch {\r\n return { status: BentleyStatus.ERROR, candidate };\r\n }\r\n };\r\n\r\n const promises: Promise<MassPropertiesPerCandidateResponseProps>[] = [];\r\n\r\n for (const candidate of CompressedId64Set.iterable(props.candidates)) {\r\n promises.push(getSingleCandidateMassProperties(candidate));\r\n }\r\n\r\n return Promise.all(promises);\r\n }\r\n\r\n public async getToolTipMessage(tokenProps: IModelRpcProps, id: string): Promise<string[]> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const el = iModelDb.elements.getElement(id);\r\n return (el === undefined) ? [] : el.getToolTipMessage();\r\n }\r\n\r\n /** Send a view thumbnail to the frontend. This is a binary transfer with the metadata in a 16-byte prefix header.\r\n * @deprecated in 3.x.\r\n */\r\n public async getViewThumbnail(_tokenProps: IModelRpcProps, _viewId: string): Promise<Uint8Array> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, _tokenProps);\r\n const thumbnail = iModelDb.views.getThumbnail(_viewId);\r\n if (undefined === thumbnail || 0 === thumbnail.image.length)\r\n throw new NoContentError();\r\n\r\n const val = new Uint8Array(thumbnail.image.length + 16); // allocate a new buffer 16 bytes larger than the image size\r\n new Uint32Array(val.buffer, 0, 4).set([thumbnail.image.length, thumbnail.format === \"jpeg\" ? ImageSourceFormat.Jpeg : ImageSourceFormat.Png, thumbnail.width, thumbnail.height]); // Put the metadata in the first 16 bytes.\r\n val.set(thumbnail.image, 16); // put the image data at offset 16 after metadata\r\n return val;\r\n }\r\n\r\n public async getDefaultViewId(tokenProps: IModelRpcProps): Promise<Id64String> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const spec = { namespace: \"dgn_View\", name: \"DefaultView\" };\r\n const blob = iModelDb.queryFilePropertyBlob(spec);\r\n if (undefined === blob || 8 !== blob.length)\r\n return Id64.invalid;\r\n\r\n const view = new Uint32Array(blob.buffer);\r\n return Id64.fromUint32Pair(view[0], view[1]);\r\n }\r\n public async getSpatialCategoryId(tokenProps: IModelRpcProps, categoryName: string): Promise<Id64String | undefined> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const dictionary: DictionaryModel = iModelDb.models.getModel<DictionaryModel>(IModel.dictionaryId);\r\n return SpatialCategory.queryCategoryIdByName(iModelDb, dictionary.id, categoryName);\r\n }\r\n\r\n public async getIModelCoordinatesFromGeoCoordinates(tokenProps: IModelRpcProps, props: IModelCoordinatesRequestProps): Promise<IModelCoordinatesResponseProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.getIModelCoordinatesFromGeoCoordinates(props);\r\n }\r\n\r\n public async getGeoCoordinatesFromIModelCoordinates(tokenProps: IModelRpcProps, props: GeoCoordinatesRequestProps): Promise<GeoCoordinatesResponseProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.getGeoCoordinatesFromIModelCoordinates(props);\r\n }\r\n\r\n public async queryTextureData(tokenProps: IModelRpcProps, textureLoadProps: TextureLoadProps): Promise<TextureData | undefined> {\r\n const db = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return db.queryTextureData(textureLoadProps);\r\n }\r\n\r\n public async generateElementMeshes(iModelToken: IModelRpcProps, props: ElementMeshRequestProps): Promise<Uint8Array> {\r\n const db = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, iModelToken);\r\n return db.nativeDb.generateElementMeshes(props);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"IModelReadRpcImpl.js","sourceRoot":"","sources":["../../../src/rpc-impl/IModelReadRpcImpl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAE6B;AAC7B,oDAQ4B;AAE5B,0CAA8C;AAC9C,wDAAqD;AACrD,wDAA+D;AAE/D,+DAA4D;AAC5D,4CAA0C;AAC1C,oEAAiE;AACjE,0EAAuE;AACvE,4DAAyD;AACzD,wDAAqD;AAQrD,MAAM,wBAAyB,SAAQ,iCAAuC;IAW5E;QACE,MAAM,OAAO,GAAG,KAAK,EAAE,KAA4B,EAAE,EAAE;YACrD,MAAM,EAAE,GAAG,MAAM,yCAAmB,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;YACzF,MAAM,WAAW,GAAG,IAAI,mDAAwB,CAAC,EAAE,CAAC,CAAC;YACrD,OAAO,WAAW,CAAC,wBAAwB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7D,CAAC,CAAC;QAEF,MAAM,SAAS,GAAG,CAAC,KAA4B,EAAE,EAAE;;YACjD,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC;YAC/B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAA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,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,UAA0B,EAAE,gBAAkC;QAC1F,MAAM,EAAE,GAAG,MAAM,yCAAmB,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAC/F,OAAO,EAAE,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAC/C,CAAC;IAEM,KAAK,CAAC,qBAAqB,CAAC,WAA2B,EAAE,KAA8B;QAC5F,MAAM,EAAE,GAAG,MAAM,yCAAmB,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAChG,OAAO,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;CACF;AA9QD,8CA8QC","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 {\r\n AccessToken, assert, BeDuration, BentleyStatus, CompressedId64Set, GuidString, Id64, Id64String, IModelStatus, Logger,\r\n} from \"@itwin/core-bentley\";\r\nimport {\r\n Code, CodeProps, CustomViewState3dCreatorOptions, CustomViewState3dProps, DbBlobRequest, DbBlobResponse, DbQueryRequest, DbQueryResponse, ElementLoadOptions, ElementLoadProps,\r\n ElementMeshRequestProps, ElementProps, EntityMetaData, EntityQueryParams, FontMapProps, GeoCoordinatesRequestProps, GeoCoordinatesResponseProps, GeometryContainmentRequestProps,\r\n GeometryContainmentResponseProps, GeometrySummaryRequestProps, HydrateViewStateRequestProps, HydrateViewStateResponseProps, ImageSourceFormat, IModel,\r\n IModelConnectionProps, IModelCoordinatesRequestProps, IModelCoordinatesResponseProps, IModelError, IModelReadRpcInterface, IModelRpcOpenProps,\r\n IModelRpcProps, MassPropertiesPerCandidateRequestProps, MassPropertiesPerCandidateResponseProps, MassPropertiesRequestProps, MassPropertiesResponseProps, ModelExtentsProps,\r\n ModelProps, NoContentError, RpcInterface, RpcManager, RpcPendingResponse, SnapRequestProps, SnapResponseProps, SubCategoryResultRow, SyncMode, TextureData, TextureLoadProps,\r\n ViewStateLoadProps, ViewStateProps,\r\n} from \"@itwin/core-common\";\r\nimport { Range3dProps } from \"@itwin/core-geometry\";\r\nimport { SpatialCategory } from \"../Category\";\r\nimport { ConcurrentQuery } from \"../ConcurrentQuery\";\r\nimport { generateGeometrySummaries } from \"../GeometrySummary\";\r\nimport { DictionaryModel } from \"../Model\";\r\nimport { RpcBriefcaseUtility } from \"./RpcBriefcaseUtility\";\r\nimport { RpcTrace } from \"../rpc/tracing\";\r\nimport { BackendLoggerCategory } from \"../BackendLoggerCategory\";\r\nimport { CustomViewState3dCreator } from \"../CustomViewState3dCreator\";\r\nimport { ViewStateHydrator } from \"../ViewStateHydrator\";\r\nimport { PromiseMemoizer } from \"../PromiseMemoizer\";\r\n\r\ninterface ViewStateRequestProps {\r\n accessToken: AccessToken;\r\n tokenProps: IModelRpcProps;\r\n options: CustomViewState3dCreatorOptions;\r\n}\r\n\r\nclass ViewStateRequestMemoizer extends PromiseMemoizer<CustomViewState3dProps> {\r\n private readonly _timeoutMs: number;\r\n private static _instance?: ViewStateRequestMemoizer;\r\n\r\n public static async perform(props: ViewStateRequestProps): Promise<CustomViewState3dProps> {\r\n if (!this._instance)\r\n this._instance = new ViewStateRequestMemoizer();\r\n\r\n return this._instance.perform(props);\r\n }\r\n\r\n private constructor() {\r\n const memoize = async (props: ViewStateRequestProps) => {\r\n const db = await RpcBriefcaseUtility.findOpenIModel(props.accessToken, props.tokenProps);\r\n const viewCreator = new CustomViewState3dCreator(db);\r\n return viewCreator.getCustomViewState3dData(props.options);\r\n };\r\n\r\n const stringify = (props: ViewStateRequestProps) => {\r\n const token = props.tokenProps;\r\n const modelIds = props.options.modelIds;\r\n return `${token.key}-${token.iTwinId}-${token.iModelId}-${token.changeset?.id}:${modelIds}`;\r\n };\r\n\r\n super(memoize, stringify);\r\n this._timeoutMs = 20 * 1000;\r\n }\r\n\r\n private async perform(props: ViewStateRequestProps): Promise<CustomViewState3dProps> {\r\n const memo = this.memoize(props);\r\n\r\n // Rejections must be caught so that the memoization entry is deleted.\r\n await BeDuration.race(this._timeoutMs, memo.promise).catch(() => undefined);\r\n\r\n if (memo.isPending)\r\n throw new RpcPendingResponse(); // eslint-disable-line deprecation/deprecation\r\n\r\n this.deleteMemoized(props);\r\n\r\n if (memo.isFulfilled) {\r\n assert(undefined !== memo.result);\r\n return memo.result;\r\n }\r\n\r\n assert(memo.isRejected);\r\n throw memo.error; // eslint-disable-line no-throw-literal\r\n }\r\n}\r\n\r\nfunction currentActivity() {\r\n return RpcTrace.expectCurrentActivity; // eslint-disable-line deprecation/deprecation\r\n}\r\n\r\n/** The backend implementation of IModelReadRpcInterface.\r\n * @internal\r\n */\r\nexport class IModelReadRpcImpl extends RpcInterface implements IModelReadRpcInterface { // eslint-disable-line deprecation/deprecation\r\n\r\n public static register() { RpcManager.registerImpl(IModelReadRpcInterface, IModelReadRpcImpl); }\r\n\r\n public async getConnectionProps(tokenProps: IModelRpcOpenProps): Promise<IModelConnectionProps> {\r\n return RpcBriefcaseUtility.openWithTimeout(currentActivity(), tokenProps, SyncMode.FixedVersion);\r\n }\r\n\r\n public async getCustomViewState3dData(tokenProps: IModelRpcProps, options: CustomViewState3dCreatorOptions): Promise<CustomViewState3dProps> {\r\n const accessToken = currentActivity().accessToken;\r\n return ViewStateRequestMemoizer.perform({ accessToken, tokenProps, options });\r\n }\r\n\r\n public async hydrateViewState(tokenProps: IModelRpcProps, options: HydrateViewStateRequestProps): Promise<HydrateViewStateResponseProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const viewHydrater = new ViewStateHydrator(iModelDb);\r\n return viewHydrater.getHydrateResponseProps(options);\r\n }\r\n\r\n public async querySubCategories(tokenProps: IModelRpcProps, compressedCategoryIds: CompressedId64Set): Promise<SubCategoryResultRow[]> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const decompressedIds = CompressedId64Set.decompressArray(compressedCategoryIds);\r\n return iModelDb.querySubCategories(decompressedIds);\r\n }\r\n\r\n public async queryRows(tokenProps: IModelRpcProps, request: DbQueryRequest): Promise<DbQueryResponse> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n if (iModelDb.isReadonly && request.usePrimaryConn === true) {\r\n Logger.logWarning(BackendLoggerCategory.IModelDb, \"usePrimaryConn is only supported on imodel that is opened in read/write mode. The option will be ignored.\", request);\r\n request.usePrimaryConn = false;\r\n }\r\n return ConcurrentQuery.executeQueryRequest(iModelDb.nativeDb, request);\r\n }\r\n\r\n public async queryBlob(tokenProps: IModelRpcProps, request: DbBlobRequest): Promise<DbBlobResponse> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n if (iModelDb.isReadonly && request.usePrimaryConn === true) {\r\n Logger.logWarning(BackendLoggerCategory.IModelDb, \"usePrimaryConn is only supported on imodel that is opened in read/write mode. The option will be ignored.\", request);\r\n request.usePrimaryConn = false;\r\n }\r\n return ConcurrentQuery.executeBlobRequest(iModelDb.nativeDb, request);\r\n }\r\n\r\n public async queryModelRanges(tokenProps: IModelRpcProps, modelIds: Id64String[]): Promise<Range3dProps[]> {\r\n const results = await this.queryModelExtents(tokenProps, modelIds);\r\n if (results.length === 1 && results[0].status !== IModelStatus.Success)\r\n throw new IModelError(results[0].status, \"error querying model range\");\r\n\r\n return results.filter((x) => x.status === IModelStatus.Success).map((x) => x.extents);\r\n }\r\n\r\n public async queryModelExtents(tokenProps: IModelRpcProps, modelIds: Id64String[]): Promise<ModelExtentsProps[]> {\r\n const iModel = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModel.models.queryExtents(modelIds);\r\n }\r\n\r\n public async getModelProps(tokenProps: IModelRpcProps, modelIdsList: Id64String[]): Promise<ModelProps[]> {\r\n const modelIds = new Set(modelIdsList);\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const modelJsonArray: ModelProps[] = [];\r\n for (const id of modelIds) {\r\n try {\r\n const modelProps = iModelDb.models.getModelJson({ id });\r\n modelJsonArray.push(modelProps);\r\n } catch (error) {\r\n if (modelIds.size === 1)\r\n throw error; // if they're asking for more than one model, don't throw on error.\r\n }\r\n }\r\n return modelJsonArray;\r\n }\r\n\r\n public async queryModelProps(tokenProps: IModelRpcProps, params: EntityQueryParams): Promise<ModelProps[]> {\r\n const ids = await this.queryEntityIds(tokenProps, params);\r\n return this.getModelProps(tokenProps, [...ids]);\r\n }\r\n\r\n public async getElementProps(tokenProps: IModelRpcProps, elementIdsList: Id64String[]): Promise<ElementProps[]> {\r\n const elementIds = new Set(elementIdsList);\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const elementProps: ElementProps[] = [];\r\n for (const id of elementIds) {\r\n try {\r\n elementProps.push(iModelDb.elements.getElementJson({ id }));\r\n } catch (error) {\r\n if (elementIds.size === 1)\r\n throw error; // if they're asking for more than one element, don't throw on error.\r\n }\r\n }\r\n return elementProps;\r\n }\r\n\r\n public async loadElementProps(tokenProps: IModelRpcProps, identifier: Id64String | GuidString | CodeProps, options?: ElementLoadOptions): Promise<ElementProps | undefined> {\r\n const props: ElementLoadProps = options ? { ...options } : {};\r\n if (typeof identifier === \"string\") {\r\n if (Id64.isId64(identifier))\r\n props.id = identifier;\r\n else\r\n props.federationGuid = identifier;\r\n } else {\r\n props.code = Code.fromJSON(identifier);\r\n }\r\n\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.elements.tryGetElementProps(props);\r\n }\r\n\r\n public async getGeometrySummary(tokenProps: IModelRpcProps, request: GeometrySummaryRequestProps): Promise<string> {\r\n const iModel = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return generateGeometrySummaries(request, iModel);\r\n }\r\n\r\n public async queryElementProps(tokenProps: IModelRpcProps, params: EntityQueryParams): Promise<ElementProps[]> {\r\n const ids = await this.queryEntityIds(tokenProps, params);\r\n const res = this.getElementProps(tokenProps, [...ids]);\r\n return res;\r\n }\r\n\r\n public async queryEntityIds(tokenProps: IModelRpcProps, params: EntityQueryParams): Promise<Id64String[]> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const res = iModelDb.queryEntityIds(params);\r\n return [...res];\r\n }\r\n\r\n public async getClassHierarchy(tokenProps: IModelRpcProps, classFullName: string): Promise<string[]> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const classArray: string[] = [];\r\n while (true) {\r\n const classMetaData: EntityMetaData = iModelDb.getMetaData(classFullName);\r\n classArray.push(classFullName);\r\n if (!classMetaData.baseClasses || classMetaData.baseClasses.length === 0)\r\n break;\r\n\r\n classFullName = classMetaData.baseClasses[0];\r\n }\r\n return classArray;\r\n }\r\n\r\n public async getAllCodeSpecs(tokenProps: IModelRpcProps): Promise<any[]> {\r\n const codeSpecs: any[] = [];\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n iModelDb.withPreparedStatement(\"SELECT ECInstanceId AS id, name, jsonProperties FROM BisCore.CodeSpec\", (statement) => {\r\n for (const row of statement)\r\n codeSpecs.push({ id: row.id, name: row.name, jsonProperties: JSON.parse(row.jsonProperties) });\r\n });\r\n return codeSpecs;\r\n }\r\n\r\n public async getViewStateData(tokenProps: IModelRpcProps, viewDefinitionId: string, options?: ViewStateLoadProps): Promise<ViewStateProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.views.getViewStateProps(viewDefinitionId, options);\r\n }\r\n\r\n public async readFontJson(tokenProps: IModelRpcProps): Promise<FontMapProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.nativeDb.readFontMap();\r\n }\r\n\r\n public async requestSnap(tokenProps: IModelRpcProps, sessionId: string, props: SnapRequestProps): Promise<SnapResponseProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.requestSnap(sessionId, props);\r\n }\r\n\r\n public async cancelSnap(tokenProps: IModelRpcProps, sessionId: string): Promise<void> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.cancelSnap(sessionId);\r\n }\r\n\r\n public async getGeometryContainment(tokenProps: IModelRpcProps, props: GeometryContainmentRequestProps): Promise<GeometryContainmentResponseProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.getGeometryContainment(props);\r\n }\r\n\r\n public async getMassProperties(tokenProps: IModelRpcProps, props: MassPropertiesRequestProps): Promise<MassPropertiesResponseProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.getMassProperties(props);\r\n }\r\n\r\n public async getMassPropertiesPerCandidate(tokenProps: IModelRpcProps, props: MassPropertiesPerCandidateRequestProps): Promise<MassPropertiesPerCandidateResponseProps[]> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n\r\n const getSingleCandidateMassProperties = async (candidate: string) => {\r\n try {\r\n const massPropResults: MassPropertiesResponseProps[] = [];\r\n\r\n for (const op of props.operations) {\r\n const massProperties = await iModelDb.getMassProperties({ operation: op, candidates: [candidate] });\r\n massPropResults.push(massProperties);\r\n }\r\n\r\n let singleCandidateResult: MassPropertiesPerCandidateResponseProps = { status: BentleyStatus.ERROR, candidate };\r\n\r\n if (massPropResults.some((r) => r.status !== BentleyStatus.ERROR)) {\r\n singleCandidateResult.status = BentleyStatus.SUCCESS;\r\n for (const r of massPropResults.filter((mpr) => mpr.status !== BentleyStatus.ERROR)) {\r\n singleCandidateResult = { ...singleCandidateResult, ...r };\r\n }\r\n }\r\n\r\n return singleCandidateResult;\r\n } catch {\r\n return { status: BentleyStatus.ERROR, candidate };\r\n }\r\n };\r\n\r\n const promises: Promise<MassPropertiesPerCandidateResponseProps>[] = [];\r\n\r\n for (const candidate of CompressedId64Set.iterable(props.candidates)) {\r\n promises.push(getSingleCandidateMassProperties(candidate));\r\n }\r\n\r\n return Promise.all(promises);\r\n }\r\n\r\n public async getToolTipMessage(tokenProps: IModelRpcProps, id: string): Promise<string[]> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const el = iModelDb.elements.getElement(id);\r\n return (el === undefined) ? [] : el.getToolTipMessage();\r\n }\r\n\r\n /** Send a view thumbnail to the frontend. This is a binary transfer with the metadata in a 16-byte prefix header.\r\n * @deprecated in 3.x with no replacement; thumbnails are rarely added to the iModel.\r\n */\r\n public async getViewThumbnail(_tokenProps: IModelRpcProps, _viewId: string): Promise<Uint8Array> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, _tokenProps);\r\n const thumbnail = iModelDb.views.getThumbnail(_viewId);\r\n if (undefined === thumbnail || 0 === thumbnail.image.length)\r\n throw new NoContentError();\r\n\r\n const val = new Uint8Array(thumbnail.image.length + 16); // allocate a new buffer 16 bytes larger than the image size\r\n new Uint32Array(val.buffer, 0, 4).set([thumbnail.image.length, thumbnail.format === \"jpeg\" ? ImageSourceFormat.Jpeg : ImageSourceFormat.Png, thumbnail.width, thumbnail.height]); // Put the metadata in the first 16 bytes.\r\n val.set(thumbnail.image, 16); // put the image data at offset 16 after metadata\r\n return val;\r\n }\r\n\r\n public async getDefaultViewId(tokenProps: IModelRpcProps): Promise<Id64String> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const spec = { namespace: \"dgn_View\", name: \"DefaultView\" };\r\n const blob = iModelDb.queryFilePropertyBlob(spec);\r\n if (undefined === blob || 8 !== blob.length)\r\n return Id64.invalid;\r\n\r\n const view = new Uint32Array(blob.buffer);\r\n return Id64.fromUint32Pair(view[0], view[1]);\r\n }\r\n public async getSpatialCategoryId(tokenProps: IModelRpcProps, categoryName: string): Promise<Id64String | undefined> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n const dictionary: DictionaryModel = iModelDb.models.getModel<DictionaryModel>(IModel.dictionaryId);\r\n return SpatialCategory.queryCategoryIdByName(iModelDb, dictionary.id, categoryName);\r\n }\r\n\r\n public async getIModelCoordinatesFromGeoCoordinates(tokenProps: IModelRpcProps, props: IModelCoordinatesRequestProps): Promise<IModelCoordinatesResponseProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.getIModelCoordinatesFromGeoCoordinates(props);\r\n }\r\n\r\n public async getGeoCoordinatesFromIModelCoordinates(tokenProps: IModelRpcProps, props: GeoCoordinatesRequestProps): Promise<GeoCoordinatesResponseProps> {\r\n const iModelDb = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return iModelDb.getGeoCoordinatesFromIModelCoordinates(props);\r\n }\r\n\r\n public async queryTextureData(tokenProps: IModelRpcProps, textureLoadProps: TextureLoadProps): Promise<TextureData | undefined> {\r\n const db = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, tokenProps);\r\n return db.queryTextureData(textureLoadProps);\r\n }\r\n\r\n public async generateElementMeshes(iModelToken: IModelRpcProps, props: ElementMeshRequestProps): Promise<Uint8Array> {\r\n const db = await RpcBriefcaseUtility.findOpenIModel(currentActivity().accessToken, iModelToken);\r\n return db.nativeDb.generateElementMeshes(props);\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@itwin/core-backend",
3
- "version": "4.0.0-dev.2",
3
+ "version": "4.0.0-dev.22",
4
4
  "description": "iTwin.js backend components",
5
5
  "main": "lib/cjs/core-backend.js",
6
6
  "typings": "lib/cjs/core-backend",
7
7
  "license": "MIT",
8
8
  "engines": {
9
- "node": ">=12.22.0 < 14.0 || >=14.17.0 < 19.0"
9
+ "node": "^18.0.0"
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
@@ -24,9 +24,9 @@
24
24
  "url": "http://www.bentley.com"
25
25
  },
26
26
  "peerDependencies": {
27
- "@itwin/core-bentley": "^4.0.0-dev.2",
28
- "@itwin/core-common": "^4.0.0-dev.2",
29
- "@itwin/core-geometry": "^4.0.0-dev.2",
27
+ "@itwin/core-bentley": "^4.0.0-dev.22",
28
+ "@itwin/core-common": "^4.0.0-dev.22",
29
+ "@itwin/core-geometry": "^4.0.0-dev.22",
30
30
  "@opentelemetry/api": "^1.0.4"
31
31
  },
32
32
  "peerDependenciesMeta": {
@@ -39,19 +39,19 @@
39
39
  "NOTE: All tools used by scripts in this package must be listed as devDependencies"
40
40
  ],
41
41
  "devDependencies": {
42
- "@itwin/build-tools": "4.0.0-dev.2",
43
- "@itwin/core-bentley": "4.0.0-dev.2",
44
- "@itwin/core-common": "4.0.0-dev.2",
45
- "@itwin/core-geometry": "4.0.0-dev.2",
46
- "@itwin/core-webpack-tools": "4.0.0-dev.2",
47
- "@itwin/eslint-plugin": "4.0.0-dev.2",
42
+ "@itwin/build-tools": "4.0.0-dev.22",
43
+ "@itwin/core-bentley": "4.0.0-dev.22",
44
+ "@itwin/core-common": "4.0.0-dev.22",
45
+ "@itwin/core-geometry": "4.0.0-dev.22",
46
+ "@itwin/core-webpack-tools": "4.0.0-dev.22",
47
+ "@itwin/eslint-plugin": "4.0.0-dev.22",
48
48
  "@opentelemetry/api": "1.0.4",
49
49
  "@types/chai": "4.3.1",
50
50
  "@types/chai-as-promised": "^7",
51
51
  "@types/fs-extra": "^4.0.7",
52
52
  "@types/mocha": "^8.2.2",
53
53
  "@types/multiparty": "^0.0.31",
54
- "@types/node": "18.11.5",
54
+ "@types/node": "^18.11.5",
55
55
  "@types/semver": "7.3.10",
56
56
  "@types/sinon": "^9.0.0",
57
57
  "@types/ws": "^7.0.0",
@@ -75,10 +75,10 @@
75
75
  "dependencies": {
76
76
  "@azure/storage-blob": "^12.7.0",
77
77
  "@bentley/imodeljs-native": "3.6.6",
78
- "@itwin/object-storage-azure": "~1.4.0",
79
- "@itwin/cloud-agnostic-core": "~1.4.0",
80
- "@itwin/object-storage-core": "~1.4.0",
81
- "@itwin/core-telemetry": "4.0.0-dev.2",
78
+ "@itwin/object-storage-azure": "^1.5.0",
79
+ "@itwin/cloud-agnostic-core": "^1.5.0",
80
+ "@itwin/object-storage-core": "^1.5.0",
81
+ "@itwin/core-telemetry": "4.0.0-dev.22",
82
82
  "form-data": "^2.3.2",
83
83
  "fs-extra": "^8.1.0",
84
84
  "inversify": "~5.0.1",