@itwin/core-backend 4.5.0-dev.8 → 4.6.0-dev.0

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +68 -1
  2. package/LICENSE.md +1 -1
  3. package/lib/cjs/BackendHubAccess.d.ts +1 -1
  4. package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
  5. package/lib/cjs/BackendHubAccess.js.map +1 -1
  6. package/lib/cjs/CheckpointManager.d.ts +4 -3
  7. package/lib/cjs/CheckpointManager.d.ts.map +1 -1
  8. package/lib/cjs/CheckpointManager.js +37 -28
  9. package/lib/cjs/CheckpointManager.js.map +1 -1
  10. package/lib/cjs/CloudSqlite.d.ts +3 -1
  11. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  12. package/lib/cjs/CloudSqlite.js +6 -3
  13. package/lib/cjs/CloudSqlite.js.map +1 -1
  14. package/lib/cjs/Element.d.ts +6 -0
  15. package/lib/cjs/Element.d.ts.map +1 -1
  16. package/lib/cjs/Element.js +7 -1
  17. package/lib/cjs/Element.js.map +1 -1
  18. package/lib/cjs/IModelDb.d.ts +32 -27
  19. package/lib/cjs/IModelDb.d.ts.map +1 -1
  20. package/lib/cjs/IModelDb.js +159 -30
  21. package/lib/cjs/IModelDb.js.map +1 -1
  22. package/lib/cjs/IModelHost.d.ts +0 -2
  23. package/lib/cjs/IModelHost.d.ts.map +1 -1
  24. package/lib/cjs/IModelHost.js +1 -5
  25. package/lib/cjs/IModelHost.js.map +1 -1
  26. package/lib/cjs/IpcHost.d.ts.map +1 -1
  27. package/lib/cjs/IpcHost.js +3 -0
  28. package/lib/cjs/IpcHost.js.map +1 -1
  29. package/lib/cjs/TileStorage.d.ts.map +1 -1
  30. package/lib/cjs/TileStorage.js +9 -1
  31. package/lib/cjs/TileStorage.js.map +1 -1
  32. package/lib/cjs/rpc/web/logging.d.ts.map +1 -1
  33. package/lib/cjs/rpc/web/logging.js +0 -2
  34. package/lib/cjs/rpc/web/logging.js.map +1 -1
  35. package/lib/cjs/rpc/web/response.d.ts.map +1 -1
  36. package/lib/cjs/rpc/web/response.js +16 -0
  37. package/lib/cjs/rpc/web/response.js.map +1 -1
  38. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
  39. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +12 -13
  40. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  41. package/lib/cjs/workspace/Workspace.d.ts +107 -123
  42. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  43. package/lib/cjs/workspace/Workspace.js +132 -155
  44. package/lib/cjs/workspace/Workspace.js.map +1 -1
  45. package/package.json +13 -12
@@ -236,8 +236,6 @@ export declare class IModelHost {
236
236
  * returned by this method may change over time throughout the course of a session.
237
237
  */
238
238
  static getAccessToken(): Promise<AccessToken>;
239
- /** @internal */
240
- static flushLog(): void;
241
239
  private static syncNativeLogLevels;
242
240
  private static loadNative;
243
241
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"IModelHost.d.ts","sourceRoot":"","sources":["../../src/IModelHost.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,YAAY,CAAC;AAGpB,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAU,OAAO,EAAkB,UAAU,EAAwB,OAAO,EAAmB,MAAM,qBAAqB,CAAC;AAC/I,OAAO,EAAE,mBAAmB,EAA8B,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEjH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAetD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAkB,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CA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AC/B,WAAkB,MAAM,IAAI,YAAY,CAEvC;CACF;AAED;;;;GAIG;AACH,8BAAsB,gBAAgB;IACpC;;;OAGG;IACI,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAC1D;;;;OAIG;IACI,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAO1C;;;OAGG;IACI,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IACjE;;;;OAIG;IACI,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;CAOnD"}
@@ -155,10 +155,6 @@ class IModelHost {
155
155
  return "";
156
156
  }
157
157
  }
158
- /** @internal */
159
- static flushLog() {
160
- return IModelHost.platform.flushLog();
161
- }
162
158
  static syncNativeLogLevels() {
163
159
  this.platform.clearLogLevelCache();
164
160
  }
@@ -208,7 +204,7 @@ class IModelHost {
208
204
  static initializeWorkspace(configuration) {
209
205
  const settingAssets = (0, path_1.join)(KnownLocations.packageAssetsDir, "Settings");
210
206
  SettingsSchemas_1.SettingsSchemas.addDirectory((0, path_1.join)(settingAssets, "Schemas"));
211
- this._appWorkspace = new Workspace_1.ITwinWorkspace(new ApplicationSettings(), configuration.workspace);
207
+ this._appWorkspace = Workspace_1.Workspace.construct(new ApplicationSettings(), configuration.workspace);
212
208
  // Create the CloudCache for Workspaces. This will fail if another process is already using the same profile.
213
209
  try {
214
210
  this.appWorkspace.getCloudCache();
@@ -1 +1 @@
1
- {"version":3,"file":"IModelHost.js","sourceRoot":"","sources":["../../src/IModelHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yFAAyF;AACzF,sBAAoB,CAAC,mCAAmC;AAExD,yBAAyB;AACzB,4BAA0B,CAAC,yJAAyJ;AACpL,8DAAyE;AACzE,oEAAyF;AACzF,sDAA+I;AAC/I,oDAAiH;AACjH,sEAAyE;AACzE,oEAA2D;AAE3D,mEAAgE;AAChE,mDAAgD;AA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C,QAAQ,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;IAClD,CAAC;IAED,8DAA8D;IACvD,MAAM,KAAK,gBAAgB;QAChC,OAAO,IAAA,WAAI,EAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,+BAA+B;IACxB,MAAM,KAAK,MAAM;QACtB,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;CACF;AAhBD,wCAgBC;AAED;;;;GAIG;AACH,MAAsB,gBAAgB;IACpC;;;OAGG;IACI,aAAa,CAAC,QAAgB,IAAwB,OAAO,SAAS,CAAC,CAAC,CAAC;IAChF;;;;OAIG;IACI,UAAU,CAAC,OAAe;QAC/B,MAAM,gBAAgB,GAAuB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACzE,IAAI,SAAS,KAAK,gBAAgB,EAAE;YAClC,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModelHost\n */\n\n// To avoid circular load errors, the \"Element\" classes must be loaded before IModelHost.\nimport \"./IModelDb\"; // DO NOT REMOVE OR MOVE THIS LINE!\n\nimport * as os from \"os\";\nimport \"reflect-metadata\"; // this has to be before @itwin/object-storage-* and @itwin/cloud-agnostic-core imports because those packages contain decorators that use this polyfill.\nimport { IModelJsNative, NativeLibrary } from \"@bentley/imodeljs-native\";\nimport { DependenciesConfig, Types as ExtensionTypes } from \"@itwin/cloud-agnostic-core\";\nimport { AccessToken, assert, BeEvent, DbResult, Guid, GuidString, IModelStatus, Logger, Mutable, ProcessDetector } from \"@itwin/core-bentley\";\nimport { AuthorizationClient, BentleyStatus, IModelError, LocalDirName, SessionProps } from \"@itwin/core-common\";\nimport { AzureServerStorageBindings } from \"@itwin/object-storage-azure\";\nimport { ServerStorage } from \"@itwin/object-storage-core\";\nimport { BackendHubAccess } from \"./BackendHubAccess\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { BisCoreSchema } from \"./BisCoreSchema\";\nimport { BriefcaseManager } from \"./BriefcaseManager\";\nimport { CloudSqlite } from \"./CloudSqlite\";\nimport { FunctionalSchema } from \"./domains/FunctionalSchema\";\nimport { GenericSchema } from \"./domains/GenericSchema\";\nimport { GeoCoordConfig } from \"./GeoCoordConfig\";\nimport { IModelJsFs } from \"./IModelJsFs\";\nimport { DevToolsRpcImpl } from \"./rpc-impl/DevToolsRpcImpl\";\nimport { IModelReadRpcImpl } from \"./rpc-impl/IModelReadRpcImpl\";\nimport { IModelTileRpcImpl } from \"./rpc-impl/IModelTileRpcImpl\";\nimport { SnapshotIModelRpcImpl } from \"./rpc-impl/SnapshotIModelRpcImpl\";\nimport { WipRpcImpl } from \"./rpc-impl/WipRpcImpl\";\nimport { initializeRpcBackend } from \"./RpcBackend\";\nimport { TileStorage } from \"./TileStorage\";\nimport { BaseSettings, SettingDictionary, SettingsPriority } from \"./workspace/Settings\";\nimport { SettingsSchemas } from \"./workspace/SettingsSchemas\";\nimport { ITwinWorkspace, Workspace, WorkspaceOpts } from \"./workspace/Workspace\";\nimport { Container } from \"inversify\";\nimport { join, normalize as normalizeDir } from \"path\";\n\nconst loggerCategory = BackendLoggerCategory.IModelHost;\n\n// cspell:ignore nodereport fatalerror apicall alicloud rpcs inversify\n\n/** @internal */\nexport interface CrashReportingConfigNameValuePair {\n name: string;\n value: string;\n}\n\n/** Configuration of the crash-reporting system.\n * @internal\n */\nexport interface CrashReportingConfig {\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. */\n crashDir: string;\n /** max # .dmp files that may exist in crashDir. The default is 50. */\n maxDumpsInDir?: number;\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. */\n enableCrashDumps?: boolean;\n /** If enableCrashDumps is true, do you want a full-memory dump? Defaults to false. */\n wantFullMemoryDumps?: boolean;\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. */\n enableNodeReport?: boolean;\n /** Additional name, value pairs to write to iModelJsNativeCrash*.properties.txt file in the event of a crash. */\n params?: CrashReportingConfigNameValuePair[];\n /** Run this .js file to process .dmp and Node.js crash reporting .json files in the event of a crash.\n * This script will be executed with a single command-line parameter: the name of the dump or Node.js report file.\n * In the case of a dump file, there will be a second file with the same basename and the extension \".properties.txt\".\n * Since it runs in a separate process, this script will have no access to the Javascript\n * context of the exiting backend. No default.\n */\n dumpProcessorScriptFileName?: string;\n /** Upload crash dump and node-reports to Bentley's crash-reporting service? Defaults to false */\n uploadToBentley?: boolean;\n}\n\n/** @beta */\nexport interface AzureBlobStorageCredentials {\n account: string;\n accessKey: string;\n baseUrl?: string;\n}\n\n/**\n * Options for [[IModelHost.startup]]\n * @public\n */\nexport interface IModelHostOptions {\n /**\n * The name of the *Profile* subdirectory of [[cacheDir]] for this process. If not present, \"default\" is used.\n * @see [[IModelHost.profileName]]\n * @beta\n */\n profileName?: string;\n\n /**\n * Root of the directory holding all the files that iTwin.js caches\n * - If not specified at startup a platform specific default is used -\n * - Windows: $(HOMEDIR)/AppData/Local/iModelJs/\n * - Mac/iOS: $(HOMEDIR)/Library/Caches/iModelJs/\n * - Linux: $(HOMEDIR)/.cache/iModelJs/\n * where $(HOMEDIR) is documented [here](https://nodejs.org/api/os.html#os_os_homedir)\n * - if specified, ensure it is set to a folder with read/write access.\n * @see [[IModelHost.cacheDir]] for the value it's set to after startup\n */\n cacheDir?: LocalDirName;\n\n /** The directory where application assets are found. */\n appAssetsDir?: LocalDirName;\n\n /**\n * Options for creating the [[Workspace]]\n * @beta\n */\n workspace?: WorkspaceOpts;\n\n /**\n * The kind of iModel hub server to use.\n * @internal\n */\n hubAccess?: BackendHubAccess;\n\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.\n * @beta\n */\n tileCacheAzureCredentials?: AzureBlobStorageCredentials;\n\n /**\n * @beta\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),\n * set this property with a custom ServerStorage.\n */\n tileCacheStorage?: ServerStorage;\n\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.\n * The local cache is used only if an external cache has not been configured via [[tileCacheStorage]], and [[tileCacheAzureCredentials]].\n * Defaults to 1 GB. Must be an unsigned integer. A value of zero disables the local cache entirely.\n * @beta\n */\n maxTileCacheDbSize?: number;\n\n /** Whether to restrict tile cache URLs by client IP address (if available).\n * @beta\n */\n restrictTileUrlsByClientIp?: boolean;\n\n /** Whether to enable OpenTelemetry tracing.\n * Defaults to `false`.\n */\n enableOpenTelemetry?: boolean;\n\n /** Whether to compress cached tiles.\n * Defaults to `true`.\n */\n compressCachedTiles?: boolean;\n\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileTreeProps]($common) should wait before returning a \"pending\" status.\n * @internal\n */\n tileTreeRequestTimeout?: number;\n\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileContent]($common) should wait before returning a \"pending\" status.\n * @internal\n */\n tileContentRequestTimeout?: number;\n\n /** The backend will log when a tile took longer to load than this threshold in seconds.\n * @internal\n */\n logTileLoadTimeThreshold?: number;\n\n /** The backend will log when a tile is loaded with a size in bytes above this threshold.\n * @internal\n */\n logTileSizeThreshold?: number;\n\n /** Crash-reporting configuration\n * @internal\n */\n crashReportingConfig?: CrashReportingConfig;\n\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\n authorizationClient?: AuthorizationClient;\n}\n\n/** Configuration of core-backend.\n * @public\n */\nexport class IModelHostConfiguration implements IModelHostOptions {\n public static defaultTileRequestTimeout = 20 * 1000;\n public static defaultLogTileLoadTimeThreshold = 40;\n public static defaultLogTileSizeThreshold = 20 * 1000000;\n /** @internal */\n public static defaultMaxTileCacheDbSize = 1024 * 1024 * 1024;\n\n public appAssetsDir?: LocalDirName;\n public cacheDir?: LocalDirName;\n\n /** @beta */\n public workspace?: WorkspaceOpts;\n /** @internal */\n public hubAccess?: BackendHubAccess;\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\n public authorizationClient?: AuthorizationClient;\n /** @beta */\n public restrictTileUrlsByClientIp?: boolean;\n public compressCachedTiles?: boolean;\n /** @beta */\n public tileCacheAzureCredentials?: AzureBlobStorageCredentials;\n /** @internal */\n public tileTreeRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\n /** @internal */\n public tileContentRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\n /** @internal */\n public logTileLoadTimeThreshold = IModelHostConfiguration.defaultLogTileLoadTimeThreshold;\n /** @internal */\n public logTileSizeThreshold = IModelHostConfiguration.defaultLogTileSizeThreshold;\n /** @internal */\n public crashReportingConfig?: CrashReportingConfig;\n}\n\n/**\n * Settings for `IModelHost.appWorkspace`.\n * @note this includes the default dictionary from the SettingsSpecRegistry\n */\nclass ApplicationSettings extends BaseSettings {\n private _remove?: VoidFunction;\n protected override verifyPriority(priority: SettingsPriority) {\n if (priority >= SettingsPriority.iModel) // iModel settings may not appear in ApplicationSettings\n throw new Error(\"Use IModelSettings\");\n }\n private updateDefaults() {\n const defaults: SettingDictionary = {};\n for (const [schemaName, val] of SettingsSchemas.allSchemas) {\n if (val.default)\n defaults[schemaName] = val.default;\n }\n this.addDictionary(\"_default_\", 0 as SettingsPriority, defaults);\n }\n\n public constructor() {\n super();\n this._remove = SettingsSchemas.onSchemaChanged.addListener(() => this.updateDefaults());\n this.updateDefaults();\n }\n\n public override close() {\n if (this._remove) {\n this._remove();\n this._remove = undefined;\n }\n }\n}\n\n/** IModelHost initializes ($backend) and captures its configuration. A backend must call [[IModelHost.startup]] before using any backend classes.\n * See [the learning article]($docs/learning/backend/IModelHost.md)\n * @public\n */\nexport class IModelHost {\n private constructor() { }\n\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\n public static authorizationClient?: AuthorizationClient;\n\n public static backendVersion = \"\";\n private static _profileName: string;\n private static _cacheDir = \"\";\n private static _appWorkspace?: Workspace;\n\n private static _platform?: typeof IModelJsNative;\n /** @internal */\n public static get platform(): typeof IModelJsNative {\n if (this._platform === undefined)\n throw new Error(\"IModelHost.startup must be called first\");\n return this._platform;\n }\n\n public static configuration?: IModelHostOptions;\n\n /**\n * The name of the *Profile* directory (a subdirectory of \"[[cacheDir]]/profiles/\") for this process.\n *\n * The *Profile* directory is used to cache data that is specific to a type-of-usage of the iTwin.js library.\n * It is important that information in the profile cache be consistent but isolated across sessions (i.e.\n * data for a profile is maintained between runs, but each profile is completely independent and\n * unaffected by the presence ot use of others.)\n * @note **Only one process at a time may be using a given profile**, and an exception will be thrown by [[startup]]\n * if a second process attempts to use the same profile.\n * @beta\n */\n public static get profileName(): string {\n return this._profileName;\n }\n\n /** The full path of the Profile directory.\n * @see [[profileName]]\n * @beta\n */\n public static get profileDir(): LocalDirName {\n return join(this._cacheDir, \"profiles\", this._profileName);\n }\n\n /** Event raised during startup to allow loading settings data */\n public static readonly onWorkspaceStartup = new BeEvent<() => void>();\n\n /** Event raised just after the backend IModelHost was started */\n public static readonly onAfterStartup = new BeEvent<() => void>();\n\n /** Event raised just before the backend IModelHost is to be shut down */\n public static readonly onBeforeShutdown = new BeEvent<() => void>();\n\n /** @internal */\n public static readonly session: Mutable<SessionProps> = { applicationId: \"2686\", applicationVersion: \"1.0.0\", sessionId: \"\" };\n\n /** A uniqueId for this session */\n public static get sessionId() { return this.session.sessionId; }\n public static set sessionId(id: GuidString) { this.session.sessionId = id; }\n\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. */\n public static get applicationId() { return this.session.applicationId; }\n public static set applicationId(id: string) { this.session.applicationId = id; }\n\n /** The version of this application - needs to be set if is an agent application. The applicationVersion will otherwise originate at the frontend. */\n public static get applicationVersion() { return this.session.applicationVersion; }\n public static set applicationVersion(version: string) { this.session.applicationVersion = version; }\n\n /** A string that can identify the current user to other users when collaborating. */\n public static userMoniker = \"unknown\";\n\n /** Root directory holding files that iTwin.js caches */\n public static get cacheDir(): LocalDirName { return this._cacheDir; }\n\n /** The application [[Workspace]] for this `IModelHost`\n * @note this `Workspace` only holds [[WorkspaceContainer]]s and [[Settings]] scoped to the currently loaded application(s).\n * All organization, iTwin, and iModel based containers or settings must be accessed through [[IModelDb.workspace]] and\n * attempting to add them to this Workspace will fail.\n * @beta\n */\n public static get appWorkspace(): Workspace { return this._appWorkspace!; } // eslint-disable-line @typescript-eslint/no-non-null-assertion\n\n /** The optional [[FileNameResolver]] that resolves keys and partial file names for snapshot iModels. */\n public static snapshotFileNameResolver?: FileNameResolver;\n\n /** Get the current access token for this IModelHost, or a blank string if none is available.\n * @note for web backends, this will *always* return a blank string because the backend itself has no token (but never needs one either.)\n * For all IpcHosts, where this backend is servicing a single frontend, this will be the user's token. For ElectronHost, the backend\n * obtains the token and forwards it to the frontend.\n * @note accessTokens expire periodically and are automatically refreshed, if possible. Therefore tokens should not be saved, and the value\n * returned by this method may change over time throughout the course of a session.\n */\n public static async getAccessToken(): Promise<AccessToken> {\n try {\n return (await IModelHost.authorizationClient?.getAccessToken()) ?? \"\";\n } catch (e) {\n return \"\";\n }\n }\n\n /** @internal */\n public static flushLog() {\n return IModelHost.platform.flushLog();\n }\n\n private static syncNativeLogLevels() {\n this.platform.clearLogLevelCache();\n }\n private static loadNative(options: IModelHostOptions) {\n if (undefined !== this._platform)\n return;\n\n this._platform = ProcessDetector.isMobileAppBackend ? (process as any)._linkedBinding(\"iModelJsNative\") as typeof IModelJsNative : NativeLibrary.load();\n this._platform.logger = Logger;\n Logger.logLevelChangedFn = () => IModelHost.syncNativeLogLevels(); // the arrow function exists only so that it can be spied in tests\n\n if (options.crashReportingConfig && options.crashReportingConfig.crashDir && !ProcessDetector.isElectronAppBackend && !ProcessDetector.isMobileAppBackend) {\n this.platform.setCrashReporting(options.crashReportingConfig);\n\n Logger.logTrace(loggerCategory, \"Configured crash reporting\", {\n enableCrashDumps: options.crashReportingConfig?.enableCrashDumps,\n wantFullMemoryDumps: options.crashReportingConfig?.wantFullMemoryDumps,\n enableNodeReport: options.crashReportingConfig?.enableNodeReport,\n uploadToBentley: options.crashReportingConfig?.uploadToBentley,\n });\n\n if (options.crashReportingConfig.enableNodeReport) {\n if (process.report !== undefined) {\n process.report.reportOnFatalError = true;\n process.report.reportOnUncaughtException = true;\n process.report.directory = options.crashReportingConfig.crashDir;\n Logger.logTrace(loggerCategory, \"Configured Node.js crash reporting\");\n } else {\n Logger.logWarning(loggerCategory, \"Unable to configure Node.js crash reporting\");\n }\n }\n }\n }\n\n /** @internal */\n public static tileStorage?: TileStorage;\n\n private static _hubAccess?: BackendHubAccess;\n /** @internal */\n public static setHubAccess(hubAccess: BackendHubAccess | undefined) { this._hubAccess = hubAccess; }\n\n /** get the current hubAccess, if present.\n * @internal\n */\n public static getHubAccess(): BackendHubAccess | undefined { return this._hubAccess; }\n\n /** Provides access to the IModelHub for this IModelHost\n * @internal\n * @note If [[IModelHostOptions.hubAccess]] was undefined when initializing this class, accessing this property will throw an error.\n * To determine whether one is present, use [[getHubAccess]].\n */\n public static get hubAccess(): BackendHubAccess {\n if (IModelHost._hubAccess === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"No BackendHubAccess supplied in IModelHostOptions\");\n return IModelHost._hubAccess;\n }\n\n private static initializeWorkspace(configuration: IModelHostOptions) {\n const settingAssets = join(KnownLocations.packageAssetsDir, \"Settings\");\n SettingsSchemas.addDirectory(join(settingAssets, \"Schemas\"));\n this._appWorkspace = new ITwinWorkspace(new ApplicationSettings(), configuration.workspace);\n\n // Create the CloudCache for Workspaces. This will fail if another process is already using the same profile.\n try {\n this.appWorkspace.getCloudCache();\n } catch (e: any) {\n throw (e.errorNumber === DbResult.BE_SQLITE_BUSY) ? new IModelError(DbResult.BE_SQLITE_BUSY, `Profile [${this.profileDir}] is already in use by another process`) : e;\n }\n\n this.appWorkspace.settings.addDirectory(settingAssets, SettingsPriority.defaults);\n\n GeoCoordConfig.onStartup();\n // allow applications to load their default settings\n this.onWorkspaceStartup.raiseEvent();\n }\n\n private static _isValid = false;\n\n /** true between a successful call to [[startup]] and before [[shutdown]] */\n public static get isValid() {\n return IModelHost._isValid;\n }\n\n /** This method must be called before any iTwin.js services are used.\n * @param options Host configuration data.\n * Raises [[onAfterStartup]].\n * @see [[shutdown]].\n */\n public static async startup(options?: IModelHostOptions): Promise<void> {\n if (this._isValid)\n return; // we're already initialized\n this._isValid = true;\n\n options = options ?? {};\n if (this.sessionId === \"\")\n this.sessionId = Guid.createValue();\n\n this.authorizationClient = options.authorizationClient;\n\n this.backendVersion = require(\"../../package.json\").version; // eslint-disable-line @typescript-eslint/no-var-requires\n initializeRpcBackend(options.enableOpenTelemetry);\n\n this.loadNative(options);\n this.setupCacheDir(options);\n this.initializeWorkspace(options);\n\n BriefcaseManager.initialize(join(this._cacheDir, \"imodels\"));\n\n [\n IModelReadRpcImpl,\n IModelTileRpcImpl,\n SnapshotIModelRpcImpl,\n WipRpcImpl,\n DevToolsRpcImpl,\n ].forEach((rpc) => rpc.register()); // register all of the RPC implementations\n\n [\n BisCoreSchema,\n GenericSchema,\n FunctionalSchema,\n ].forEach((schema) => schema.registerSchema()); // register all of the schemas\n\n if (undefined !== options.hubAccess)\n this._hubAccess = options.hubAccess;\n\n this.configuration = options;\n this.setupTileCache();\n\n process.once(\"beforeExit\", IModelHost.shutdown);\n this.onAfterStartup.raiseEvent();\n }\n\n private static setupCacheDir(configuration: IModelHostOptions) {\n this._cacheDir = normalizeDir(configuration.cacheDir ?? NativeLibrary.defaultCacheDir);\n IModelJsFs.recursiveMkDirSync(this._cacheDir);\n\n this._profileName = configuration.profileName ?? \"default\";\n Logger.logInfo(loggerCategory, `cacheDir: [${this.cacheDir}], profileDir: [${this.profileDir}]`);\n }\n\n /** This method must be called when an iTwin.js host is shut down. Raises [[onBeforeShutdown]] */\n public static async shutdown(this: void): Promise<void> {\n // Note: This method is set as a node listener where `this` is unbound. Call private method to\n // ensure `this` is correct. Don't combine these methods.\n return IModelHost.doShutdown();\n }\n\n private static async doShutdown() {\n if (!this._isValid)\n return;\n\n this._isValid = false;\n this.onBeforeShutdown.raiseEvent();\n this.configuration = undefined;\n this.tileStorage = undefined;\n this._appWorkspace?.close();\n this._appWorkspace = undefined;\n\n CloudSqlite.CloudCaches.destroy();\n process.removeListener(\"beforeExit\", IModelHost.shutdown);\n }\n\n /**\n * Add or update a property that should be included in a crash report.\n * @internal\n */\n public static setCrashReportProperty(name: string, value: string): void {\n this.platform.setCrashReportProperty(name, value);\n }\n\n /**\n * Remove a previously defined property so that will not be included in a crash report.\n * @internal\n */\n public static removeCrashReportProperty(name: string): void {\n this.platform.setCrashReportProperty(name, undefined);\n }\n\n /**\n * Get all properties that will be included in a crash report.\n * @internal\n */\n public static getCrashReportProperties(): CrashReportingConfigNameValuePair[] {\n return this.platform.getCrashReportProperties();\n }\n\n /** The directory where application assets may be found */\n public static get appAssetsDir(): string | undefined {\n return undefined !== IModelHost.configuration ? IModelHost.configuration.appAssetsDir : undefined;\n }\n\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileTreeProps should wait before returning a \"pending\" status.\n * @internal\n */\n public static get tileTreeRequestTimeout(): number {\n return IModelHost.configuration?.tileTreeRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\n }\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileContent should wait before returning a \"pending\" status.\n * @internal\n */\n public static get tileContentRequestTimeout(): number {\n return IModelHost.configuration?.tileContentRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\n }\n\n /** The backend will log when a tile took longer to load than this threshold in seconds. */\n public static get logTileLoadTimeThreshold(): number {\n return IModelHost.configuration?.logTileLoadTimeThreshold ?? IModelHostConfiguration.defaultLogTileLoadTimeThreshold;\n }\n /** The backend will log when a tile is loaded with a size in bytes above this threshold. */\n public static get logTileSizeThreshold(): number {\n return IModelHost.configuration?.logTileSizeThreshold ?? IModelHostConfiguration.defaultLogTileSizeThreshold;\n }\n\n /** Whether external tile caching is active.\n * @internal\n */\n public static get usingExternalTileCache(): boolean {\n return undefined !== IModelHost.tileStorage;\n }\n\n /** Whether to restrict tile cache URLs by client IP address.\n * @internal\n */\n public static get restrictTileUrlsByClientIp(): boolean {\n return undefined !== IModelHost.configuration && (IModelHost.configuration.restrictTileUrlsByClientIp ? true : false);\n }\n\n /** Whether to compress cached tiles.\n * @internal\n */\n public static get compressCachedTiles(): boolean {\n return false !== IModelHost.configuration?.compressCachedTiles;\n }\n\n private static setupTileCache() {\n assert(undefined !== IModelHost.configuration);\n const config = IModelHost.configuration;\n const storage = config.tileCacheStorage;\n const credentials = config.tileCacheAzureCredentials;\n\n if (!storage && !credentials) {\n this.platform.setMaxTileCacheSize(config.maxTileCacheDbSize ?? IModelHostConfiguration.defaultMaxTileCacheDbSize);\n return;\n }\n\n this.platform.setMaxTileCacheSize(0);\n if (credentials) {\n if (storage)\n throw new IModelError(BentleyStatus.ERROR, \"Cannot use both Azure and custom cloud storage providers for tile cache.\");\n this.setupAzureTileCache(credentials);\n }\n if (storage)\n IModelHost.tileStorage = new TileStorage(storage);\n }\n\n private static setupAzureTileCache(credentials: AzureBlobStorageCredentials) {\n const config = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ServerSideStorage: {\n dependencyName: \"azure\",\n accountName: credentials.account,\n accountKey: credentials.accessKey,\n baseUrl: credentials.baseUrl ?? `https://${credentials.account}.blob.core.windows.net`,\n },\n };\n const ioc: Container = new Container();\n ioc.bind<DependenciesConfig>(ExtensionTypes.dependenciesConfig).toConstantValue(config);\n new AzureServerStorageBindings().register(ioc, config.ServerSideStorage);\n IModelHost.tileStorage = new TileStorage(ioc.get(ServerStorage));\n }\n\n /** @internal */\n public static computeSchemaChecksum(arg: { schemaXmlPath: string, referencePaths: string[], exactMatch?: boolean }): string {\n return this.platform.computeSchemaChecksum(arg);\n }\n}\n\n/** Information about the platform on which the app is running.\n * @public\n */\nexport class Platform {\n /** Get the name of the platform. */\n public static get platformName(): \"win32\" | \"linux\" | \"darwin\" | \"ios\" | \"android\" | \"uwp\" {\n return process.platform as any;\n }\n}\n\n/** Well known directories that may be used by the application.\n * @public\n */\nexport class KnownLocations {\n\n /** The directory where the imodeljs-native assets are stored. */\n public static get nativeAssetsDir(): LocalDirName {\n return IModelHost.platform.DgnDb.getAssetsDir();\n }\n\n /** The directory where the core-backend assets are stored. */\n public static get packageAssetsDir(): LocalDirName {\n return join(__dirname, \"assets\");\n }\n\n /** The temporary directory. */\n public static get tmpdir(): LocalDirName {\n return os.tmpdir();\n }\n}\n\n/** Extend this class to provide custom file name resolution behavior.\n * @note Only `tryResolveKey` and/or `tryResolveFileName` need to be overridden as the implementations of `resolveKey` and `resolveFileName` work for most purposes.\n * @see [[IModelHost.snapshotFileNameResolver]]\n * @public\n */\nexport abstract class FileNameResolver {\n /** Resolve a file name from the specified key.\n * @param _fileKey The key that identifies the file name in a `Map` or other similar data structure.\n * @returns The resolved file name or `undefined` if not found.\n */\n public tryResolveKey(_fileKey: string): string | undefined { return undefined; }\n /** Resolve a file name from the specified key.\n * @param fileKey The key that identifies the file name in a `Map` or other similar data structure.\n * @returns The resolved file name.\n * @throws [[IModelError]] if not found.\n */\n public resolveKey(fileKey: string): string {\n const resolvedFileName: string | undefined = this.tryResolveKey(fileKey);\n if (undefined === resolvedFileName) {\n throw new IModelError(IModelStatus.NotFound, `${fileKey} not resolved`);\n }\n return resolvedFileName;\n }\n /** Resolve the input file name, which may be a partial name, into a full path file name.\n * @param inFileName The partial file name.\n * @returns The resolved full path file name or `undefined` if not found.\n */\n public tryResolveFileName(inFileName: string): string | undefined { return inFileName; }\n /** Resolve the input file name, which may be a partial name, into a full path file name.\n * @param inFileName The partial file name.\n * @returns The resolved full path file name.\n * @throws [[IModelError]] if not found.\n */\n public resolveFileName(inFileName: string): string {\n const resolvedFileName: string | undefined = this.tryResolveFileName(inFileName);\n if (undefined === resolvedFileName) {\n throw new IModelError(IModelStatus.NotFound, `${inFileName} not resolved`);\n }\n return resolvedFileName;\n }\n}\n"]}
1
+ {"version":3,"file":"IModelHost.js","sourceRoot":"","sources":["../../src/IModelHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yFAAyF;AACzF,sBAAoB,CAAC,mCAAmC;AAExD,yBAAyB;AACzB,4BAA0B,CAAC,yJAAyJ;AACpL,8DAAyE;AACzE,oEAAyF;AACzF,sDAA+I;AAC/I,oDAAiH;AACjH,sEAAyE;AACzE,oEAA2D;AAE3D,mEAAgE;AAChE,mDAAgD;AAChD,yDAAsD;AACtD,+CAA4C;AAC5C,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,qDAAiE;AACjE,yCAAsC;AACtC,+BAAuD;AAEv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O,SAAS,CAAC,CAAC,CAAC;IAChF;;;;OAIG;IACI,UAAU,CAAC,OAAe;QAC/B,MAAM,gBAAgB,GAAuB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACzE,IAAI,SAAS,KAAK,gBAAgB,EAAE;YAClC,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModelHost\n */\n\n// To avoid circular load errors, the \"Element\" classes must be loaded before IModelHost.\nimport \"./IModelDb\"; // DO NOT REMOVE OR MOVE THIS LINE!\n\nimport * as os from \"os\";\nimport \"reflect-metadata\"; // this has to be before @itwin/object-storage-* and @itwin/cloud-agnostic-core imports because those packages contain decorators that use this polyfill.\nimport { IModelJsNative, NativeLibrary } from \"@bentley/imodeljs-native\";\nimport { DependenciesConfig, Types as ExtensionTypes } from \"@itwin/cloud-agnostic-core\";\nimport { AccessToken, assert, BeEvent, DbResult, Guid, GuidString, IModelStatus, Logger, Mutable, ProcessDetector } from \"@itwin/core-bentley\";\nimport { AuthorizationClient, BentleyStatus, IModelError, LocalDirName, SessionProps } from \"@itwin/core-common\";\nimport { AzureServerStorageBindings } from \"@itwin/object-storage-azure\";\nimport { ServerStorage } from \"@itwin/object-storage-core\";\nimport { BackendHubAccess } from \"./BackendHubAccess\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { BisCoreSchema } from \"./BisCoreSchema\";\nimport { BriefcaseManager } from \"./BriefcaseManager\";\nimport { CloudSqlite } from \"./CloudSqlite\";\nimport { FunctionalSchema } from \"./domains/FunctionalSchema\";\nimport { GenericSchema } from \"./domains/GenericSchema\";\nimport { GeoCoordConfig } from \"./GeoCoordConfig\";\nimport { IModelJsFs } from \"./IModelJsFs\";\nimport { DevToolsRpcImpl } from \"./rpc-impl/DevToolsRpcImpl\";\nimport { IModelReadRpcImpl } from \"./rpc-impl/IModelReadRpcImpl\";\nimport { IModelTileRpcImpl } from \"./rpc-impl/IModelTileRpcImpl\";\nimport { SnapshotIModelRpcImpl } from \"./rpc-impl/SnapshotIModelRpcImpl\";\nimport { WipRpcImpl } from \"./rpc-impl/WipRpcImpl\";\nimport { initializeRpcBackend } from \"./RpcBackend\";\nimport { TileStorage } from \"./TileStorage\";\nimport { BaseSettings, SettingDictionary, SettingsPriority } from \"./workspace/Settings\";\nimport { SettingsSchemas } from \"./workspace/SettingsSchemas\";\nimport { Workspace, WorkspaceOpts } from \"./workspace/Workspace\";\nimport { Container } from \"inversify\";\nimport { join, normalize as normalizeDir } from \"path\";\n\nconst loggerCategory = BackendLoggerCategory.IModelHost;\n\n// cspell:ignore nodereport fatalerror apicall alicloud rpcs inversify\n\n/** @internal */\nexport interface CrashReportingConfigNameValuePair {\n name: string;\n value: string;\n}\n\n/** Configuration of the crash-reporting system.\n * @internal\n */\nexport interface CrashReportingConfig {\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. */\n crashDir: string;\n /** max # .dmp files that may exist in crashDir. The default is 50. */\n maxDumpsInDir?: number;\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. */\n enableCrashDumps?: boolean;\n /** If enableCrashDumps is true, do you want a full-memory dump? Defaults to false. */\n wantFullMemoryDumps?: boolean;\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. */\n enableNodeReport?: boolean;\n /** Additional name, value pairs to write to iModelJsNativeCrash*.properties.txt file in the event of a crash. */\n params?: CrashReportingConfigNameValuePair[];\n /** Run this .js file to process .dmp and Node.js crash reporting .json files in the event of a crash.\n * This script will be executed with a single command-line parameter: the name of the dump or Node.js report file.\n * In the case of a dump file, there will be a second file with the same basename and the extension \".properties.txt\".\n * Since it runs in a separate process, this script will have no access to the Javascript\n * context of the exiting backend. No default.\n */\n dumpProcessorScriptFileName?: string;\n /** Upload crash dump and node-reports to Bentley's crash-reporting service? Defaults to false */\n uploadToBentley?: boolean;\n}\n\n/** @beta */\nexport interface AzureBlobStorageCredentials {\n account: string;\n accessKey: string;\n baseUrl?: string;\n}\n\n/**\n * Options for [[IModelHost.startup]]\n * @public\n */\nexport interface IModelHostOptions {\n /**\n * The name of the *Profile* subdirectory of [[cacheDir]] for this process. If not present, \"default\" is used.\n * @see [[IModelHost.profileName]]\n * @beta\n */\n profileName?: string;\n\n /**\n * Root of the directory holding all the files that iTwin.js caches\n * - If not specified at startup a platform specific default is used -\n * - Windows: $(HOMEDIR)/AppData/Local/iModelJs/\n * - Mac/iOS: $(HOMEDIR)/Library/Caches/iModelJs/\n * - Linux: $(HOMEDIR)/.cache/iModelJs/\n * where $(HOMEDIR) is documented [here](https://nodejs.org/api/os.html#os_os_homedir)\n * - if specified, ensure it is set to a folder with read/write access.\n * @see [[IModelHost.cacheDir]] for the value it's set to after startup\n */\n cacheDir?: LocalDirName;\n\n /** The directory where application assets are found. */\n appAssetsDir?: LocalDirName;\n\n /**\n * Options for creating the [[Workspace]]\n * @beta\n */\n workspace?: WorkspaceOpts;\n\n /**\n * The kind of iModel hub server to use.\n * @internal\n */\n hubAccess?: BackendHubAccess;\n\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.\n * @beta\n */\n tileCacheAzureCredentials?: AzureBlobStorageCredentials;\n\n /**\n * @beta\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),\n * set this property with a custom ServerStorage.\n */\n tileCacheStorage?: ServerStorage;\n\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.\n * The local cache is used only if an external cache has not been configured via [[tileCacheStorage]], and [[tileCacheAzureCredentials]].\n * Defaults to 1 GB. Must be an unsigned integer. A value of zero disables the local cache entirely.\n * @beta\n */\n maxTileCacheDbSize?: number;\n\n /** Whether to restrict tile cache URLs by client IP address (if available).\n * @beta\n */\n restrictTileUrlsByClientIp?: boolean;\n\n /** Whether to enable OpenTelemetry tracing.\n * Defaults to `false`.\n */\n enableOpenTelemetry?: boolean;\n\n /** Whether to compress cached tiles.\n * Defaults to `true`.\n */\n compressCachedTiles?: boolean;\n\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileTreeProps]($common) should wait before returning a \"pending\" status.\n * @internal\n */\n tileTreeRequestTimeout?: number;\n\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileContent]($common) should wait before returning a \"pending\" status.\n * @internal\n */\n tileContentRequestTimeout?: number;\n\n /** The backend will log when a tile took longer to load than this threshold in seconds.\n * @internal\n */\n logTileLoadTimeThreshold?: number;\n\n /** The backend will log when a tile is loaded with a size in bytes above this threshold.\n * @internal\n */\n logTileSizeThreshold?: number;\n\n /** Crash-reporting configuration\n * @internal\n */\n crashReportingConfig?: CrashReportingConfig;\n\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\n authorizationClient?: AuthorizationClient;\n}\n\n/** Configuration of core-backend.\n * @public\n */\nexport class IModelHostConfiguration implements IModelHostOptions {\n public static defaultTileRequestTimeout = 20 * 1000;\n public static defaultLogTileLoadTimeThreshold = 40;\n public static defaultLogTileSizeThreshold = 20 * 1000000;\n /** @internal */\n public static defaultMaxTileCacheDbSize = 1024 * 1024 * 1024;\n\n public appAssetsDir?: LocalDirName;\n public cacheDir?: LocalDirName;\n\n /** @beta */\n public workspace?: WorkspaceOpts;\n /** @internal */\n public hubAccess?: BackendHubAccess;\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\n public authorizationClient?: AuthorizationClient;\n /** @beta */\n public restrictTileUrlsByClientIp?: boolean;\n public compressCachedTiles?: boolean;\n /** @beta */\n public tileCacheAzureCredentials?: AzureBlobStorageCredentials;\n /** @internal */\n public tileTreeRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\n /** @internal */\n public tileContentRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\n /** @internal */\n public logTileLoadTimeThreshold = IModelHostConfiguration.defaultLogTileLoadTimeThreshold;\n /** @internal */\n public logTileSizeThreshold = IModelHostConfiguration.defaultLogTileSizeThreshold;\n /** @internal */\n public crashReportingConfig?: CrashReportingConfig;\n}\n\n/**\n * Settings for `IModelHost.appWorkspace`.\n * @note this includes the default dictionary from the SettingsSpecRegistry\n */\nclass ApplicationSettings extends BaseSettings {\n private _remove?: VoidFunction;\n protected override verifyPriority(priority: SettingsPriority) {\n if (priority >= SettingsPriority.iModel) // iModel settings may not appear in ApplicationSettings\n throw new Error(\"Use IModelSettings\");\n }\n private updateDefaults() {\n const defaults: SettingDictionary = {};\n for (const [schemaName, val] of SettingsSchemas.allSchemas) {\n if (val.default)\n defaults[schemaName] = val.default;\n }\n this.addDictionary(\"_default_\", 0 as SettingsPriority, defaults);\n }\n\n public constructor() {\n super();\n this._remove = SettingsSchemas.onSchemaChanged.addListener(() => this.updateDefaults());\n this.updateDefaults();\n }\n\n public override close() {\n if (this._remove) {\n this._remove();\n this._remove = undefined;\n }\n }\n}\n\n/** IModelHost initializes ($backend) and captures its configuration. A backend must call [[IModelHost.startup]] before using any backend classes.\n * See [the learning article]($docs/learning/backend/IModelHost.md)\n * @public\n */\nexport class IModelHost {\n private constructor() { }\n\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\n public static authorizationClient?: AuthorizationClient;\n\n public static backendVersion = \"\";\n private static _profileName: string;\n private static _cacheDir = \"\";\n private static _appWorkspace?: Workspace;\n\n private static _platform?: typeof IModelJsNative;\n /** @internal */\n public static get platform(): typeof IModelJsNative {\n if (this._platform === undefined)\n throw new Error(\"IModelHost.startup must be called first\");\n return this._platform;\n }\n\n public static configuration?: IModelHostOptions;\n\n /**\n * The name of the *Profile* directory (a subdirectory of \"[[cacheDir]]/profiles/\") for this process.\n *\n * The *Profile* directory is used to cache data that is specific to a type-of-usage of the iTwin.js library.\n * It is important that information in the profile cache be consistent but isolated across sessions (i.e.\n * data for a profile is maintained between runs, but each profile is completely independent and\n * unaffected by the presence ot use of others.)\n * @note **Only one process at a time may be using a given profile**, and an exception will be thrown by [[startup]]\n * if a second process attempts to use the same profile.\n * @beta\n */\n public static get profileName(): string {\n return this._profileName;\n }\n\n /** The full path of the Profile directory.\n * @see [[profileName]]\n * @beta\n */\n public static get profileDir(): LocalDirName {\n return join(this._cacheDir, \"profiles\", this._profileName);\n }\n\n /** Event raised during startup to allow loading settings data */\n public static readonly onWorkspaceStartup = new BeEvent<() => void>();\n\n /** Event raised just after the backend IModelHost was started */\n public static readonly onAfterStartup = new BeEvent<() => void>();\n\n /** Event raised just before the backend IModelHost is to be shut down */\n public static readonly onBeforeShutdown = new BeEvent<() => void>();\n\n /** @internal */\n public static readonly session: Mutable<SessionProps> = { applicationId: \"2686\", applicationVersion: \"1.0.0\", sessionId: \"\" };\n\n /** A uniqueId for this session */\n public static get sessionId() { return this.session.sessionId; }\n public static set sessionId(id: GuidString) { this.session.sessionId = id; }\n\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. */\n public static get applicationId() { return this.session.applicationId; }\n public static set applicationId(id: string) { this.session.applicationId = id; }\n\n /** The version of this application - needs to be set if is an agent application. The applicationVersion will otherwise originate at the frontend. */\n public static get applicationVersion() { return this.session.applicationVersion; }\n public static set applicationVersion(version: string) { this.session.applicationVersion = version; }\n\n /** A string that can identify the current user to other users when collaborating. */\n public static userMoniker = \"unknown\";\n\n /** Root directory holding files that iTwin.js caches */\n public static get cacheDir(): LocalDirName { return this._cacheDir; }\n\n /** The application [[Workspace]] for this `IModelHost`\n * @note this `Workspace` only holds [[WorkspaceContainer]]s and [[Settings]] scoped to the currently loaded application(s).\n * All organization, iTwin, and iModel based containers or settings must be accessed through [[IModelDb.workspace]] and\n * attempting to add them to this Workspace will fail.\n * @beta\n */\n public static get appWorkspace(): Workspace { return this._appWorkspace!; } // eslint-disable-line @typescript-eslint/no-non-null-assertion\n\n /** The optional [[FileNameResolver]] that resolves keys and partial file names for snapshot iModels. */\n public static snapshotFileNameResolver?: FileNameResolver;\n\n /** Get the current access token for this IModelHost, or a blank string if none is available.\n * @note for web backends, this will *always* return a blank string because the backend itself has no token (but never needs one either.)\n * For all IpcHosts, where this backend is servicing a single frontend, this will be the user's token. For ElectronHost, the backend\n * obtains the token and forwards it to the frontend.\n * @note accessTokens expire periodically and are automatically refreshed, if possible. Therefore tokens should not be saved, and the value\n * returned by this method may change over time throughout the course of a session.\n */\n public static async getAccessToken(): Promise<AccessToken> {\n try {\n return (await IModelHost.authorizationClient?.getAccessToken()) ?? \"\";\n } catch (e) {\n return \"\";\n }\n }\n\n private static syncNativeLogLevels() {\n this.platform.clearLogLevelCache();\n }\n private static loadNative(options: IModelHostOptions) {\n if (undefined !== this._platform)\n return;\n\n this._platform = ProcessDetector.isMobileAppBackend ? (process as any)._linkedBinding(\"iModelJsNative\") as typeof IModelJsNative : NativeLibrary.load();\n this._platform.logger = Logger;\n Logger.logLevelChangedFn = () => IModelHost.syncNativeLogLevels(); // the arrow function exists only so that it can be spied in tests\n\n if (options.crashReportingConfig && options.crashReportingConfig.crashDir && !ProcessDetector.isElectronAppBackend && !ProcessDetector.isMobileAppBackend) {\n this.platform.setCrashReporting(options.crashReportingConfig);\n\n Logger.logTrace(loggerCategory, \"Configured crash reporting\", {\n enableCrashDumps: options.crashReportingConfig?.enableCrashDumps,\n wantFullMemoryDumps: options.crashReportingConfig?.wantFullMemoryDumps,\n enableNodeReport: options.crashReportingConfig?.enableNodeReport,\n uploadToBentley: options.crashReportingConfig?.uploadToBentley,\n });\n\n if (options.crashReportingConfig.enableNodeReport) {\n if (process.report !== undefined) {\n process.report.reportOnFatalError = true;\n process.report.reportOnUncaughtException = true;\n process.report.directory = options.crashReportingConfig.crashDir;\n Logger.logTrace(loggerCategory, \"Configured Node.js crash reporting\");\n } else {\n Logger.logWarning(loggerCategory, \"Unable to configure Node.js crash reporting\");\n }\n }\n }\n }\n\n /** @internal */\n public static tileStorage?: TileStorage;\n\n private static _hubAccess?: BackendHubAccess;\n /** @internal */\n public static setHubAccess(hubAccess: BackendHubAccess | undefined) { this._hubAccess = hubAccess; }\n\n /** get the current hubAccess, if present.\n * @internal\n */\n public static getHubAccess(): BackendHubAccess | undefined { return this._hubAccess; }\n\n /** Provides access to the IModelHub for this IModelHost\n * @internal\n * @note If [[IModelHostOptions.hubAccess]] was undefined when initializing this class, accessing this property will throw an error.\n * To determine whether one is present, use [[getHubAccess]].\n */\n public static get hubAccess(): BackendHubAccess {\n if (IModelHost._hubAccess === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"No BackendHubAccess supplied in IModelHostOptions\");\n return IModelHost._hubAccess;\n }\n\n private static initializeWorkspace(configuration: IModelHostOptions) {\n const settingAssets = join(KnownLocations.packageAssetsDir, \"Settings\");\n SettingsSchemas.addDirectory(join(settingAssets, \"Schemas\"));\n this._appWorkspace = Workspace.construct(new ApplicationSettings(), configuration.workspace);\n\n // Create the CloudCache for Workspaces. This will fail if another process is already using the same profile.\n try {\n this.appWorkspace.getCloudCache();\n } catch (e: any) {\n throw (e.errorNumber === DbResult.BE_SQLITE_BUSY) ? new IModelError(DbResult.BE_SQLITE_BUSY, `Profile [${this.profileDir}] is already in use by another process`) : e;\n }\n\n this.appWorkspace.settings.addDirectory(settingAssets, SettingsPriority.defaults);\n\n GeoCoordConfig.onStartup();\n // allow applications to load their default settings\n this.onWorkspaceStartup.raiseEvent();\n }\n\n private static _isValid = false;\n\n /** true between a successful call to [[startup]] and before [[shutdown]] */\n public static get isValid() {\n return IModelHost._isValid;\n }\n\n /** This method must be called before any iTwin.js services are used.\n * @param options Host configuration data.\n * Raises [[onAfterStartup]].\n * @see [[shutdown]].\n */\n public static async startup(options?: IModelHostOptions): Promise<void> {\n if (this._isValid)\n return; // we're already initialized\n this._isValid = true;\n\n options = options ?? {};\n if (this.sessionId === \"\")\n this.sessionId = Guid.createValue();\n\n this.authorizationClient = options.authorizationClient;\n\n this.backendVersion = require(\"../../package.json\").version; // eslint-disable-line @typescript-eslint/no-var-requires\n initializeRpcBackend(options.enableOpenTelemetry);\n\n this.loadNative(options);\n this.setupCacheDir(options);\n this.initializeWorkspace(options);\n\n BriefcaseManager.initialize(join(this._cacheDir, \"imodels\"));\n\n [\n IModelReadRpcImpl,\n IModelTileRpcImpl,\n SnapshotIModelRpcImpl,\n WipRpcImpl,\n DevToolsRpcImpl,\n ].forEach((rpc) => rpc.register()); // register all of the RPC implementations\n\n [\n BisCoreSchema,\n GenericSchema,\n FunctionalSchema,\n ].forEach((schema) => schema.registerSchema()); // register all of the schemas\n\n if (undefined !== options.hubAccess)\n this._hubAccess = options.hubAccess;\n\n this.configuration = options;\n this.setupTileCache();\n\n process.once(\"beforeExit\", IModelHost.shutdown);\n this.onAfterStartup.raiseEvent();\n }\n\n private static setupCacheDir(configuration: IModelHostOptions) {\n this._cacheDir = normalizeDir(configuration.cacheDir ?? NativeLibrary.defaultCacheDir);\n IModelJsFs.recursiveMkDirSync(this._cacheDir);\n\n this._profileName = configuration.profileName ?? \"default\";\n Logger.logInfo(loggerCategory, `cacheDir: [${this.cacheDir}], profileDir: [${this.profileDir}]`);\n }\n\n /** This method must be called when an iTwin.js host is shut down. Raises [[onBeforeShutdown]] */\n public static async shutdown(this: void): Promise<void> {\n // Note: This method is set as a node listener where `this` is unbound. Call private method to\n // ensure `this` is correct. Don't combine these methods.\n return IModelHost.doShutdown();\n }\n\n private static async doShutdown() {\n if (!this._isValid)\n return;\n\n this._isValid = false;\n this.onBeforeShutdown.raiseEvent();\n this.configuration = undefined;\n this.tileStorage = undefined;\n this._appWorkspace?.close();\n this._appWorkspace = undefined;\n\n CloudSqlite.CloudCaches.destroy();\n process.removeListener(\"beforeExit\", IModelHost.shutdown);\n }\n\n /**\n * Add or update a property that should be included in a crash report.\n * @internal\n */\n public static setCrashReportProperty(name: string, value: string): void {\n this.platform.setCrashReportProperty(name, value);\n }\n\n /**\n * Remove a previously defined property so that will not be included in a crash report.\n * @internal\n */\n public static removeCrashReportProperty(name: string): void {\n this.platform.setCrashReportProperty(name, undefined);\n }\n\n /**\n * Get all properties that will be included in a crash report.\n * @internal\n */\n public static getCrashReportProperties(): CrashReportingConfigNameValuePair[] {\n return this.platform.getCrashReportProperties();\n }\n\n /** The directory where application assets may be found */\n public static get appAssetsDir(): string | undefined {\n return undefined !== IModelHost.configuration ? IModelHost.configuration.appAssetsDir : undefined;\n }\n\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileTreeProps should wait before returning a \"pending\" status.\n * @internal\n */\n public static get tileTreeRequestTimeout(): number {\n return IModelHost.configuration?.tileTreeRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\n }\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileContent should wait before returning a \"pending\" status.\n * @internal\n */\n public static get tileContentRequestTimeout(): number {\n return IModelHost.configuration?.tileContentRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\n }\n\n /** The backend will log when a tile took longer to load than this threshold in seconds. */\n public static get logTileLoadTimeThreshold(): number {\n return IModelHost.configuration?.logTileLoadTimeThreshold ?? IModelHostConfiguration.defaultLogTileLoadTimeThreshold;\n }\n /** The backend will log when a tile is loaded with a size in bytes above this threshold. */\n public static get logTileSizeThreshold(): number {\n return IModelHost.configuration?.logTileSizeThreshold ?? IModelHostConfiguration.defaultLogTileSizeThreshold;\n }\n\n /** Whether external tile caching is active.\n * @internal\n */\n public static get usingExternalTileCache(): boolean {\n return undefined !== IModelHost.tileStorage;\n }\n\n /** Whether to restrict tile cache URLs by client IP address.\n * @internal\n */\n public static get restrictTileUrlsByClientIp(): boolean {\n return undefined !== IModelHost.configuration && (IModelHost.configuration.restrictTileUrlsByClientIp ? true : false);\n }\n\n /** Whether to compress cached tiles.\n * @internal\n */\n public static get compressCachedTiles(): boolean {\n return false !== IModelHost.configuration?.compressCachedTiles;\n }\n\n private static setupTileCache() {\n assert(undefined !== IModelHost.configuration);\n const config = IModelHost.configuration;\n const storage = config.tileCacheStorage;\n const credentials = config.tileCacheAzureCredentials;\n\n if (!storage && !credentials) {\n this.platform.setMaxTileCacheSize(config.maxTileCacheDbSize ?? IModelHostConfiguration.defaultMaxTileCacheDbSize);\n return;\n }\n\n this.platform.setMaxTileCacheSize(0);\n if (credentials) {\n if (storage)\n throw new IModelError(BentleyStatus.ERROR, \"Cannot use both Azure and custom cloud storage providers for tile cache.\");\n this.setupAzureTileCache(credentials);\n }\n if (storage)\n IModelHost.tileStorage = new TileStorage(storage);\n }\n\n private static setupAzureTileCache(credentials: AzureBlobStorageCredentials) {\n const config = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ServerSideStorage: {\n dependencyName: \"azure\",\n accountName: credentials.account,\n accountKey: credentials.accessKey,\n baseUrl: credentials.baseUrl ?? `https://${credentials.account}.blob.core.windows.net`,\n },\n };\n const ioc: Container = new Container();\n ioc.bind<DependenciesConfig>(ExtensionTypes.dependenciesConfig).toConstantValue(config);\n new AzureServerStorageBindings().register(ioc, config.ServerSideStorage);\n IModelHost.tileStorage = new TileStorage(ioc.get(ServerStorage));\n }\n\n /** @internal */\n public static computeSchemaChecksum(arg: { schemaXmlPath: string, referencePaths: string[], exactMatch?: boolean }): string {\n return this.platform.computeSchemaChecksum(arg);\n }\n}\n\n/** Information about the platform on which the app is running.\n * @public\n */\nexport class Platform {\n /** Get the name of the platform. */\n public static get platformName(): \"win32\" | \"linux\" | \"darwin\" | \"ios\" | \"android\" | \"uwp\" {\n return process.platform as any;\n }\n}\n\n/** Well known directories that may be used by the application.\n * @public\n */\nexport class KnownLocations {\n\n /** The directory where the imodeljs-native assets are stored. */\n public static get nativeAssetsDir(): LocalDirName {\n return IModelHost.platform.DgnDb.getAssetsDir();\n }\n\n /** The directory where the core-backend assets are stored. */\n public static get packageAssetsDir(): LocalDirName {\n return join(__dirname, \"assets\");\n }\n\n /** The temporary directory. */\n public static get tmpdir(): LocalDirName {\n return os.tmpdir();\n }\n}\n\n/** Extend this class to provide custom file name resolution behavior.\n * @note Only `tryResolveKey` and/or `tryResolveFileName` need to be overridden as the implementations of `resolveKey` and `resolveFileName` work for most purposes.\n * @see [[IModelHost.snapshotFileNameResolver]]\n * @public\n */\nexport abstract class FileNameResolver {\n /** Resolve a file name from the specified key.\n * @param _fileKey The key that identifies the file name in a `Map` or other similar data structure.\n * @returns The resolved file name or `undefined` if not found.\n */\n public tryResolveKey(_fileKey: string): string | undefined { return undefined; }\n /** Resolve a file name from the specified key.\n * @param fileKey The key that identifies the file name in a `Map` or other similar data structure.\n * @returns The resolved file name.\n * @throws [[IModelError]] if not found.\n */\n public resolveKey(fileKey: string): string {\n const resolvedFileName: string | undefined = this.tryResolveKey(fileKey);\n if (undefined === resolvedFileName) {\n throw new IModelError(IModelStatus.NotFound, `${fileKey} not resolved`);\n }\n return resolvedFileName;\n }\n /** Resolve the input file name, which may be a partial name, into a full path file name.\n * @param inFileName The partial file name.\n * @returns The resolved full path file name or `undefined` if not found.\n */\n public tryResolveFileName(inFileName: string): string | undefined { return inFileName; }\n /** Resolve the input file name, which may be a partial name, into a full path file name.\n * @param inFileName The partial file name.\n * @returns The resolved full path file name.\n * @throws [[IModelError]] if not found.\n */\n public resolveFileName(inFileName: string): string {\n const resolvedFileName: string | undefined = this.tryResolveFileName(inFileName);\n if (undefined === resolvedFileName) {\n throw new IModelError(IModelStatus.NotFound, `${inFileName} not resolved`);\n }\n return resolvedFileName;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IpcHost.d.ts","sourceRoot":"","sources":["../../src/IpcHost.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EACgC,yBAAyB,EAC7B,mBAAmB,EAAmB,WAAW,EAAE,gBAAgB,EAC5D,cAAc,EAA6C,gBAAgB,EACpH,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAY,YAAY,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAc,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAG7D;;;IAGI;AACJ,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,OAAO,CAAC,EAAE;QACR,wGAAwG;QACxG,MAAM,CAAC,EAAE,gBAAgB,CAAC;QAE1B,iDAAiD;QACjD,UAAU,CAAC,EAAE;YACX,OAAO,CAAC,EAAE,OAAO,CAAC;SACnB,CAAC;KACH,CAAC;CACH;AAED;;;;GAIG;AACH,qBAAa,OAAO;IAClB,OAAc,OAAO,UAAS;IAC9B,OAAO,CAAC,MAAM,CAAC,IAAI,CAA+B;IAClD,2EAA2E;IAC3E,OAAO,CAAC,MAAM,KAAK,GAAG,GAA2C;IACjE,gIAAgI;IAChI,WAAkB,OAAO,IAAI,OAAO,CAAoC;IAExE;;;;OAIG;WACW,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAIzD;;;;;OAKG;WACW,MAAM,CAAC,OAAO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Db.open(args);
176
176
  return db.toJSON();
177
177
  }
178
+ async openCheckpoint(checkpoint) {
179
+ return (await IModelDb_1.SnapshotDb.openCheckpoint(checkpoint)).getConnectionProps();
180
+ }
178
181
  async openStandalone(filePath, openMode, opts) {
179
182
  return IModelDb_1.StandaloneDb.openFile(filePath, openMode, opts).getConnectionProps();
180
183
  }
@@ -1 +1 @@
1
- {"version":3,"file":"IpcHost.js","sourceRoot":"","sources":["../../src/IpcHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,sDAAqG;AACrG,oDAI4B;AAC5B,2DAAuE;AACvE,yCAAiE;AACjE,6CAA6D;AAC7D,oEAAyE;AAmBzE;;;;GAIG;AACH,MAAa,OAAO;IAGlB,2EAA2E;IACnE,MAAM,KAAK,GAAG,KAAuB,OAAO,IAAI,CAAC,IAAK,CAAC,CAAC,CAAC,CAAC,+DAA+D;IACjI,gIAAgI;IACzH,MAAM,KAAK,OAAO,KAAc,OAAO,SAAS,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAExE;;;;OAIG;IACI,MAAM,CAAC,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QAChD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAA,0BAAY,EAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,OAAe,EAAE,OAAyC;QAC7E,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAA,0BAAY,EAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;IACD;;;;;OAKG;IACI,MAAM,CAAC,WAAW,CAAC,OAAe,EAAE,QAAqB;QAC9D,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAA,0BAAY,EAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC/D,CAAC;IACD;;;;OAIG;IACI,MA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,QAAQ,CAAC,UAAU,EAAE,CAAC;IACvD,CAAC;IACM,KAAK,CAAC,YAAY,CAAC,GAAW;QACnC,OAAO,mBAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;IACzD,CAAC;IACM,KAAK,CAAC,iBAAiB,CAAC,GAAW;QACxC,OAAO,mBAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;IAC9D,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,IAAkB;QAC9C,OAAO,uBAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;CACF;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,IAAsB,EAAE,UAAgC,EAAE,gBAAyB;IAC1H,MAAM,QAAQ,GAAG,gBAAgB,IAAI,GAAG,CAAC,CAAC,+DAA+D;IACzG,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC;IACrC,MAAM,gBAAgB,GAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAC3D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,IAAI,MAAM,IAAI,KAAK,IAAI,GAAG,IAAI,QAAQ,EAAE;YACtC,QAAQ,GAAG,GAAG,GAAG,QAAQ,CAAC;YAC1B,OAAO,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;SAC5B;QACD,OAAO,UAAU,EAAE,CAAC;IACtB,CAAC,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAbD,4DAaC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module NativeApp\n */\n\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { assert, BentleyError, IModelStatus, Logger, LogLevel, OpenMode } from \"@itwin/core-bentley\";\nimport {\n ChangesetIndex, ChangesetIndexAndId, EditingScopeNotifications, getPullChangesIpcChannel, IModelConnectionProps, IModelError, IModelRpcProps,\n ipcAppChannels, IpcAppFunctions, IpcAppNotifications, IpcInvokeReturn, IpcListener, IpcSocketBackend, iTwinChannel,\n OpenBriefcaseProps, PullChangesOptions, RemoveFunction, StandaloneOpenOptions, TileTreeContentIds, TxnNotifications,\n} from \"@itwin/core-common\";\nimport { ProgressFunction, ProgressStatus } from \"./CheckpointManager\";\nimport { BriefcaseDb, IModelDb, StandaloneDb } from \"./IModelDb\";\nimport { IModelHost, IModelHostOptions } from \"./IModelHost\";\nimport { cancelTileContentRequests } from \"./rpc-impl/IModelTileRpcImpl\";\n\n/**\n * Options for [[IpcHost.startup]]\n * @public\n */\nexport interface IpcHostOpts {\n iModelHost?: IModelHostOptions;\n ipcHost?: {\n /** The Ipc socket to use for communications with frontend. Allows undefined only for headless tests. */\n socket?: IpcSocketBackend;\n\n /** don't send stack information on exceptions */\n exceptions?: {\n noStack?: boolean;\n };\n };\n}\n\n/**\n * Used by applications that have a dedicated backend. IpcHosts may send messages to their corresponding IpcApp.\n * @note if either end terminates, the other must too.\n * @public\n */\nexport class IpcHost {\n public static noStack = false;\n private static _ipc: IpcSocketBackend | undefined;\n /** Get the implementation of the [IpcSocketBackend]($common) interface. */\n private static get ipc(): IpcSocketBackend { return this._ipc!; } // eslint-disable-line @typescript-eslint/no-non-null-assertion\n /** Determine whether Ipc is available for this backend. This will only be true if [[startup]] has been called on this class. */\n public static get isValid(): boolean { return undefined !== this._ipc; }\n\n /**\n * Send a message to the frontend over an Ipc channel.\n * @param channel the name of the channel matching the name registered with [[IpcApp.addListener]].\n * @param data The content of the message.\n */\n public static send(channel: string, ...data: any[]): void {\n this.ipc.send(iTwinChannel(channel), ...data);\n }\n\n /**\n * Establish a handler for an Ipc channel to receive [[Frontend.invoke]] calls\n * @param channel The name of the channel for this handler.\n * @param handler A function that supplies the implementation for `channel`\n * @note returns A function to call to remove the handler.\n */\n public static handle(channel: string, handler: (...args: any[]) => Promise<any>): RemoveFunction {\n return this.ipc.handle(iTwinChannel(channel), handler);\n }\n /**\n * Establish a handler to receive messages sent via [[IpcApp.send]].\n * @param channel The name of the channel for the messages.\n * @param listener A function called when messages are sent over `channel`\n * @note returns A function to call to remove the listener.\n */\n public static addListener(channel: string, listener: IpcListener): RemoveFunction {\n return this.ipc.addListener(iTwinChannel(channel), listener);\n }\n /**\n * Remove a previously registered listener\n * @param channel The name of the channel for the listener previously registered with [[addListener]]\n * @param listener The function passed to [[addListener]]\n */\n public static removeListener(channel: string, listener: IpcListener): void {\n this.ipc.removeListener(iTwinChannel(channel), listener);\n }\n\n private static notify(channel: string, briefcase: BriefcaseDb | StandaloneDb, methodName: string, ...args: any[]) {\n if (this.isValid)\n return this.send(`${channel}/${briefcase.key}`, methodName, ...args);\n }\n\n /** @internal */\n public static notifyIpcFrontend<T extends keyof IpcAppNotifications>(methodName: T, ...args: Parameters<IpcAppNotifications[T]>) {\n return IpcHost.send(ipcAppChannels.appNotify, methodName, ...args);\n }\n\n /** @internal */\n public static notifyTxns<T extends keyof TxnNotifications>(briefcase: BriefcaseDb | StandaloneDb, methodName: T, ...args: Parameters<TxnNotifications[T]>) {\n this.notify(ipcAppChannels.txns, briefcase, methodName, ...args);\n }\n\n /** @internal */\n public static notifyEditingScope<T extends keyof EditingScopeNotifications>(briefcase: BriefcaseDb | StandaloneDb, methodName: T, ...args: Parameters<EditingScopeNotifications[T]>) {\n this.notify(ipcAppChannels.editingScope, briefcase, methodName, ...args);\n }\n\n /**\n * Start the backend of an Ipc app.\n * @param opt\n * @note this method calls [[IModelHost.startup]] internally.\n */\n public static async startup(opt?: IpcHostOpts): Promise<void> {\n this._ipc = opt?.ipcHost?.socket;\n if (opt?.ipcHost?.exceptions?.noStack)\n this.noStack = true;\n\n if (this.isValid) { // for tests, we use IpcHost but don't have a frontend\n IpcAppHandler.register();\n }\n\n await IModelHost.startup(opt?.iModelHost);\n }\n\n /** Shutdown IpcHost backend. Also calls [[IModelHost.shutdown]] */\n public static async shutdown(): Promise<void> {\n this._ipc = undefined;\n await IModelHost.shutdown();\n }\n}\n\n/**\n * Base class for all implementations of an Ipc interface.\n *\n * Create a subclass to implement your Ipc interface. Your class should be declared like this:\n * ```ts\n * class MyHandler extends IpcHandler implements MyInterface\n * ```\n * to ensure all methods and signatures are correct.\n *\n * Then, call `MyClass.register` at startup to connect your class to your channel.\n * @public\n */\nexport abstract class IpcHandler {\n /**\n * All subclasses *must* implement this method to specify their channel name.\n *\n * Channel names are the key that connects Handlers and senders. The channel name of IpcHandlers must exactly match the name used by senders.\n * By convention, channel names should be prefixed by a *namespace* (e.g. `${appName}/`)\n * unique enough to disambiguate them from channels for other apps that may be running in the same processes.\n */\n public abstract get channelName(): string;\n\n /**\n * Register this class as the handler for methods on its channel. This static method creates a new instance\n * that becomes the handler and is `this` when its methods are called.\n * @returns A function that can be called to remove the handler.\n * @note this method should only be called once per channel. If it is called multiple times, subsequent calls replace the previous ones.\n */\n public static register(): RemoveFunction {\n const impl = new (this as any)() as IpcHandler; // create an instance of subclass. \"as any\" is necessary because base class is abstract\n return IpcHost.handle(impl.channelName, async (_evt: Event, funcName: string, ...args: any[]): Promise<IpcInvokeReturn> => {\n try {\n const func = (impl as any)[funcName];\n if (typeof func !== \"function\")\n throw new IModelError(IModelStatus.FunctionNotFound, `Method \"${impl.constructor.name}.${funcName}\" not found on IpcHandler registered for channel: ${impl.channelName}`);\n\n return { result: await func.call(impl, ...args) };\n } catch (err: any) {\n const ret: IpcInvokeReturn = {\n error: {\n name: err.hasOwnProperty(\"name\") ? err.name : err.constructor?.name ?? \"Unknown Error\",\n message: err.message ?? BentleyError.getErrorMessage(err),\n errorNumber: err.errorNumber ?? 0,\n },\n };\n if (!IpcHost.noStack)\n ret.error.stack = BentleyError.getErrorStack(err);\n return ret;\n }\n });\n }\n}\n\n/**\n * Implementation of IpcAppFunctions\n */\nclass IpcAppHandler extends IpcHandler implements IpcAppFunctions {\n public get channelName() { return ipcAppChannels.functions; }\n\n private _iModelKeyToPullStatus = new Map<string, ProgressStatus>();\n\n public async log(_timestamp: number, level: LogLevel, category: string, message: string, metaData?: any): Promise<void> {\n switch (level) {\n case LogLevel.Error:\n Logger.logError(category, message, metaData);\n break;\n case LogLevel.Info:\n Logger.logInfo(category, message, metaData);\n break;\n case LogLevel.Trace:\n Logger.logTrace(category, message, metaData);\n break;\n case LogLevel.Warning:\n Logger.logWarning(category, message, metaData);\n break;\n }\n }\n\n public async cancelTileContentRequests(tokenProps: IModelRpcProps, contentIds: TileTreeContentIds[]): Promise<void> {\n return cancelTileContentRequests(tokenProps, contentIds);\n }\n public async cancelElementGraphicsRequests(key: string, requestIds: string[]): Promise<void> {\n return IModelDb.findByKey(key).nativeDb.cancelElementGraphicsRequests(requestIds);\n }\n public async openBriefcase(args: OpenBriefcaseProps): Promise<IModelConnectionProps> {\n const db = await BriefcaseDb.open(args);\n return db.toJSON();\n }\n public async openStandalone(filePath: string, openMode: OpenMode, opts?: StandaloneOpenOptions): Promise<IModelConnectionProps> {\n return StandaloneDb.openFile(filePath, openMode, opts).getConnectionProps();\n }\n public async closeIModel(key: string): Promise<void> {\n IModelDb.findByKey(key).close();\n }\n public async saveChanges(key: string, description?: string): Promise<void> {\n IModelDb.findByKey(key).saveChanges(description);\n }\n public async hasPendingTxns(key: string): Promise<boolean> {\n return IModelDb.findByKey(key).nativeDb.hasPendingTxns();\n }\n\n public async isUndoPossible(key: string): Promise<boolean> {\n return IModelDb.findByKey(key).nativeDb.isUndoPossible();\n }\n public async isRedoPossible(key: string): Promise<boolean> {\n return IModelDb.findByKey(key).nativeDb.isRedoPossible();\n }\n public async getUndoString(key: string): Promise<string> {\n return IModelDb.findByKey(key).nativeDb.getUndoString();\n }\n public async getRedoString(key: string): Promise<string> {\n return IModelDb.findByKey(key).nativeDb.getUndoString();\n }\n\n public async pullChanges(key: string, toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<ChangesetIndexAndId> {\n const iModelDb = BriefcaseDb.findByKey(key);\n\n this._iModelKeyToPullStatus.set(key, ProgressStatus.Continue);\n const checkAbort = () => this._iModelKeyToPullStatus.get(key) ?? ProgressStatus.Continue;\n\n let onProgress: ProgressFunction | undefined;\n if (options?.reportProgress) {\n const progressCallback: ProgressFunction = (loaded, total) => {\n IpcHost.send(getPullChangesIpcChannel(iModelDb.iModelId), { loaded, total });\n return checkAbort();\n };\n onProgress = throttleProgressCallback(progressCallback, checkAbort, options?.progressInterval);\n } else if (options?.enableCancellation) {\n onProgress = checkAbort;\n }\n\n try {\n await iModelDb.pullChanges({ toIndex, onProgress });\n } finally {\n this._iModelKeyToPullStatus.delete(key);\n }\n\n return iModelDb.changeset as ChangesetIndexAndId;\n }\n public async cancelPullChangesRequest(key: string): Promise<void> {\n this._iModelKeyToPullStatus.set(key, ProgressStatus.Abort);\n }\n\n public async pushChanges(key: string, description: string): Promise<ChangesetIndexAndId> {\n const iModelDb = BriefcaseDb.findByKey(key);\n await iModelDb.pushChanges({ description });\n return iModelDb.changeset as ChangesetIndexAndId;\n }\n\n public async toggleGraphicalEditingScope(key: string, startSession: boolean): Promise<boolean> {\n const val: IModelJsNative.ErrorStatusOrResult<any, boolean> = IModelDb.findByKey(key).nativeDb.setGeometricModelTrackingEnabled(startSession);\n if (val.error)\n throw new IModelError(val.error.status, \"Failed to toggle graphical editing scope\");\n assert(undefined !== val.result);\n return val.result;\n }\n public async isGraphicalEditingSupported(key: string): Promise<boolean> {\n return IModelDb.findByKey(key).nativeDb.isGeometricModelTrackingSupported();\n }\n\n public async reverseTxns(key: string, numOperations: number): Promise<IModelStatus> {\n return IModelDb.findByKey(key).nativeDb.reverseTxns(numOperations);\n }\n public async reverseAllTxn(key: string): Promise<IModelStatus> {\n return IModelDb.findByKey(key).nativeDb.reverseAll();\n }\n public async reinstateTxn(key: string): Promise<IModelStatus> {\n return IModelDb.findByKey(key).nativeDb.reinstateTxn();\n }\n public async restartTxnSession(key: string): Promise<void> {\n return IModelDb.findByKey(key).nativeDb.restartTxnSession();\n }\n\n public async queryConcurrency(pool: \"io\" | \"cpu\"): Promise<number> {\n return IModelHost.platform.queryConcurrency(pool);\n }\n}\n\n/**\n * Prevents progress callback being called more frequently when provided interval.\n * @internal\n */\nexport function throttleProgressCallback(func: ProgressFunction, checkAbort: () => ProgressStatus, progressInterval?: number): ProgressFunction {\n const interval = progressInterval ?? 250; // by default, only send progress events every 250 milliseconds\n let nextTime = Date.now() + interval;\n const progressCallback: ProgressFunction = (loaded, total) => {\n const now = Date.now();\n if (loaded >= total || now >= nextTime) {\n nextTime = now + interval;\n return func(loaded, total);\n }\n return checkAbort();\n };\n\n return progressCallback;\n}\n"]}
1
+ {"version":3,"file":"IpcHost.js","sourceRoot":"","sources":["../../src/IpcHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,sDAAqG;AACrG,oDAI4B;AAC5B,2DAAuE;AACvE,yCAA6E;AAC7E,6CAA6D;AAC7D,oEAAyE;AAmBzE;;;;GAIG;AACH,MAAa,OAAO;IAGlB,2EAA2E;IACnE,MAAM,KAAK,GAAG,KAAuB,OAAO,IAAI,CAAC,IAAK,CAAC,CAAC,CAAC,CAAC,+DAA+D;IACjI,gIAAgI;IACzH,MAAM,KAAK,OAAO,KAAc,OAAO,SAAS,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAExE;;;;OAIG;IACI,MAAM,CAAC,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QAChD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAA,0BAAY,EAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,OAAe,EAAE,OAAyC;QAC7E,OAAO,IAAI,CAAC,GAAG,CAAC,MAA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IAAI,GAAG,IAAI,QAAQ,EAAE;YACtC,QAAQ,GAAG,GAAG,GAAG,QAAQ,CAAC;YAC1B,OAAO,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;SAC5B;QACD,OAAO,UAAU,EAAE,CAAC;IACtB,CAAC,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAbD,4DAaC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module NativeApp\n */\n\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { assert, BentleyError, IModelStatus, Logger, LogLevel, OpenMode } from \"@itwin/core-bentley\";\nimport {\n ChangesetIndex, ChangesetIndexAndId, EditingScopeNotifications, getPullChangesIpcChannel, IModelConnectionProps, IModelError, IModelRpcProps,\n ipcAppChannels, IpcAppFunctions, IpcAppNotifications, IpcInvokeReturn, IpcListener, IpcSocketBackend, iTwinChannel,\n OpenBriefcaseProps, OpenCheckpointArgs, PullChangesOptions, RemoveFunction, StandaloneOpenOptions, TileTreeContentIds, TxnNotifications,\n} from \"@itwin/core-common\";\nimport { ProgressFunction, ProgressStatus } from \"./CheckpointManager\";\nimport { BriefcaseDb, IModelDb, SnapshotDb, StandaloneDb } from \"./IModelDb\";\nimport { IModelHost, IModelHostOptions } from \"./IModelHost\";\nimport { cancelTileContentRequests } from \"./rpc-impl/IModelTileRpcImpl\";\n\n/**\n * Options for [[IpcHost.startup]]\n * @public\n */\nexport interface IpcHostOpts {\n iModelHost?: IModelHostOptions;\n ipcHost?: {\n /** The Ipc socket to use for communications with frontend. Allows undefined only for headless tests. */\n socket?: IpcSocketBackend;\n\n /** don't send stack information on exceptions */\n exceptions?: {\n noStack?: boolean;\n };\n };\n}\n\n/**\n * Used by applications that have a dedicated backend. IpcHosts may send messages to their corresponding IpcApp.\n * @note if either end terminates, the other must too.\n * @public\n */\nexport class IpcHost {\n public static noStack = false;\n private static _ipc: IpcSocketBackend | undefined;\n /** Get the implementation of the [IpcSocketBackend]($common) interface. */\n private static get ipc(): IpcSocketBackend { return this._ipc!; } // eslint-disable-line @typescript-eslint/no-non-null-assertion\n /** Determine whether Ipc is available for this backend. This will only be true if [[startup]] has been called on this class. */\n public static get isValid(): boolean { return undefined !== this._ipc; }\n\n /**\n * Send a message to the frontend over an Ipc channel.\n * @param channel the name of the channel matching the name registered with [[IpcApp.addListener]].\n * @param data The content of the message.\n */\n public static send(channel: string, ...data: any[]): void {\n this.ipc.send(iTwinChannel(channel), ...data);\n }\n\n /**\n * Establish a handler for an Ipc channel to receive [[Frontend.invoke]] calls\n * @param channel The name of the channel for this handler.\n * @param handler A function that supplies the implementation for `channel`\n * @note returns A function to call to remove the handler.\n */\n public static handle(channel: string, handler: (...args: any[]) => Promise<any>): RemoveFunction {\n return this.ipc.handle(iTwinChannel(channel), handler);\n }\n /**\n * Establish a handler to receive messages sent via [[IpcApp.send]].\n * @param channel The name of the channel for the messages.\n * @param listener A function called when messages are sent over `channel`\n * @note returns A function to call to remove the listener.\n */\n public static addListener(channel: string, listener: IpcListener): RemoveFunction {\n return this.ipc.addListener(iTwinChannel(channel), listener);\n }\n /**\n * Remove a previously registered listener\n * @param channel The name of the channel for the listener previously registered with [[addListener]]\n * @param listener The function passed to [[addListener]]\n */\n public static removeListener(channel: string, listener: IpcListener): void {\n this.ipc.removeListener(iTwinChannel(channel), listener);\n }\n\n private static notify(channel: string, briefcase: BriefcaseDb | StandaloneDb, methodName: string, ...args: any[]) {\n if (this.isValid)\n return this.send(`${channel}/${briefcase.key}`, methodName, ...args);\n }\n\n /** @internal */\n public static notifyIpcFrontend<T extends keyof IpcAppNotifications>(methodName: T, ...args: Parameters<IpcAppNotifications[T]>) {\n return IpcHost.send(ipcAppChannels.appNotify, methodName, ...args);\n }\n\n /** @internal */\n public static notifyTxns<T extends keyof TxnNotifications>(briefcase: BriefcaseDb | StandaloneDb, methodName: T, ...args: Parameters<TxnNotifications[T]>) {\n this.notify(ipcAppChannels.txns, briefcase, methodName, ...args);\n }\n\n /** @internal */\n public static notifyEditingScope<T extends keyof EditingScopeNotifications>(briefcase: BriefcaseDb | StandaloneDb, methodName: T, ...args: Parameters<EditingScopeNotifications[T]>) {\n this.notify(ipcAppChannels.editingScope, briefcase, methodName, ...args);\n }\n\n /**\n * Start the backend of an Ipc app.\n * @param opt\n * @note this method calls [[IModelHost.startup]] internally.\n */\n public static async startup(opt?: IpcHostOpts): Promise<void> {\n this._ipc = opt?.ipcHost?.socket;\n if (opt?.ipcHost?.exceptions?.noStack)\n this.noStack = true;\n\n if (this.isValid) { // for tests, we use IpcHost but don't have a frontend\n IpcAppHandler.register();\n }\n\n await IModelHost.startup(opt?.iModelHost);\n }\n\n /** Shutdown IpcHost backend. Also calls [[IModelHost.shutdown]] */\n public static async shutdown(): Promise<void> {\n this._ipc = undefined;\n await IModelHost.shutdown();\n }\n}\n\n/**\n * Base class for all implementations of an Ipc interface.\n *\n * Create a subclass to implement your Ipc interface. Your class should be declared like this:\n * ```ts\n * class MyHandler extends IpcHandler implements MyInterface\n * ```\n * to ensure all methods and signatures are correct.\n *\n * Then, call `MyClass.register` at startup to connect your class to your channel.\n * @public\n */\nexport abstract class IpcHandler {\n /**\n * All subclasses *must* implement this method to specify their channel name.\n *\n * Channel names are the key that connects Handlers and senders. The channel name of IpcHandlers must exactly match the name used by senders.\n * By convention, channel names should be prefixed by a *namespace* (e.g. `${appName}/`)\n * unique enough to disambiguate them from channels for other apps that may be running in the same processes.\n */\n public abstract get channelName(): string;\n\n /**\n * Register this class as the handler for methods on its channel. This static method creates a new instance\n * that becomes the handler and is `this` when its methods are called.\n * @returns A function that can be called to remove the handler.\n * @note this method should only be called once per channel. If it is called multiple times, subsequent calls replace the previous ones.\n */\n public static register(): RemoveFunction {\n const impl = new (this as any)() as IpcHandler; // create an instance of subclass. \"as any\" is necessary because base class is abstract\n return IpcHost.handle(impl.channelName, async (_evt: Event, funcName: string, ...args: any[]): Promise<IpcInvokeReturn> => {\n try {\n const func = (impl as any)[funcName];\n if (typeof func !== \"function\")\n throw new IModelError(IModelStatus.FunctionNotFound, `Method \"${impl.constructor.name}.${funcName}\" not found on IpcHandler registered for channel: ${impl.channelName}`);\n\n return { result: await func.call(impl, ...args) };\n } catch (err: any) {\n const ret: IpcInvokeReturn = {\n error: {\n name: err.hasOwnProperty(\"name\") ? err.name : err.constructor?.name ?? \"Unknown Error\",\n message: err.message ?? BentleyError.getErrorMessage(err),\n errorNumber: err.errorNumber ?? 0,\n },\n };\n if (!IpcHost.noStack)\n ret.error.stack = BentleyError.getErrorStack(err);\n return ret;\n }\n });\n }\n}\n\n/**\n * Implementation of IpcAppFunctions\n */\nclass IpcAppHandler extends IpcHandler implements IpcAppFunctions {\n public get channelName() { return ipcAppChannels.functions; }\n\n private _iModelKeyToPullStatus = new Map<string, ProgressStatus>();\n\n public async log(_timestamp: number, level: LogLevel, category: string, message: string, metaData?: any): Promise<void> {\n switch (level) {\n case LogLevel.Error:\n Logger.logError(category, message, metaData);\n break;\n case LogLevel.Info:\n Logger.logInfo(category, message, metaData);\n break;\n case LogLevel.Trace:\n Logger.logTrace(category, message, metaData);\n break;\n case LogLevel.Warning:\n Logger.logWarning(category, message, metaData);\n break;\n }\n }\n\n public async cancelTileContentRequests(tokenProps: IModelRpcProps, contentIds: TileTreeContentIds[]): Promise<void> {\n return cancelTileContentRequests(tokenProps, contentIds);\n }\n public async cancelElementGraphicsRequests(key: string, requestIds: string[]): Promise<void> {\n return IModelDb.findByKey(key).nativeDb.cancelElementGraphicsRequests(requestIds);\n }\n public async openBriefcase(args: OpenBriefcaseProps): Promise<IModelConnectionProps> {\n const db = await BriefcaseDb.open(args);\n return db.toJSON();\n }\n public async openCheckpoint(checkpoint: OpenCheckpointArgs): Promise<IModelConnectionProps> {\n return (await SnapshotDb.openCheckpoint(checkpoint)).getConnectionProps();\n }\n public async openStandalone(filePath: string, openMode: OpenMode, opts?: StandaloneOpenOptions): Promise<IModelConnectionProps> {\n return StandaloneDb.openFile(filePath, openMode, opts).getConnectionProps();\n }\n public async closeIModel(key: string): Promise<void> {\n IModelDb.findByKey(key).close();\n }\n public async saveChanges(key: string, description?: string): Promise<void> {\n IModelDb.findByKey(key).saveChanges(description);\n }\n public async hasPendingTxns(key: string): Promise<boolean> {\n return IModelDb.findByKey(key).nativeDb.hasPendingTxns();\n }\n\n public async isUndoPossible(key: string): Promise<boolean> {\n return IModelDb.findByKey(key).nativeDb.isUndoPossible();\n }\n public async isRedoPossible(key: string): Promise<boolean> {\n return IModelDb.findByKey(key).nativeDb.isRedoPossible();\n }\n public async getUndoString(key: string): Promise<string> {\n return IModelDb.findByKey(key).nativeDb.getUndoString();\n }\n public async getRedoString(key: string): Promise<string> {\n return IModelDb.findByKey(key).nativeDb.getUndoString();\n }\n\n public async pullChanges(key: string, toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<ChangesetIndexAndId> {\n const iModelDb = BriefcaseDb.findByKey(key);\n\n this._iModelKeyToPullStatus.set(key, ProgressStatus.Continue);\n const checkAbort = () => this._iModelKeyToPullStatus.get(key) ?? ProgressStatus.Continue;\n\n let onProgress: ProgressFunction | undefined;\n if (options?.reportProgress) {\n const progressCallback: ProgressFunction = (loaded, total) => {\n IpcHost.send(getPullChangesIpcChannel(iModelDb.iModelId), { loaded, total });\n return checkAbort();\n };\n onProgress = throttleProgressCallback(progressCallback, checkAbort, options?.progressInterval);\n } else if (options?.enableCancellation) {\n onProgress = checkAbort;\n }\n\n try {\n await iModelDb.pullChanges({ toIndex, onProgress });\n } finally {\n this._iModelKeyToPullStatus.delete(key);\n }\n\n return iModelDb.changeset as ChangesetIndexAndId;\n }\n public async cancelPullChangesRequest(key: string): Promise<void> {\n this._iModelKeyToPullStatus.set(key, ProgressStatus.Abort);\n }\n\n public async pushChanges(key: string, description: string): Promise<ChangesetIndexAndId> {\n const iModelDb = BriefcaseDb.findByKey(key);\n await iModelDb.pushChanges({ description });\n return iModelDb.changeset as ChangesetIndexAndId;\n }\n\n public async toggleGraphicalEditingScope(key: string, startSession: boolean): Promise<boolean> {\n const val: IModelJsNative.ErrorStatusOrResult<any, boolean> = IModelDb.findByKey(key).nativeDb.setGeometricModelTrackingEnabled(startSession);\n if (val.error)\n throw new IModelError(val.error.status, \"Failed to toggle graphical editing scope\");\n assert(undefined !== val.result);\n return val.result;\n }\n public async isGraphicalEditingSupported(key: string): Promise<boolean> {\n return IModelDb.findByKey(key).nativeDb.isGeometricModelTrackingSupported();\n }\n\n public async reverseTxns(key: string, numOperations: number): Promise<IModelStatus> {\n return IModelDb.findByKey(key).nativeDb.reverseTxns(numOperations);\n }\n public async reverseAllTxn(key: string): Promise<IModelStatus> {\n return IModelDb.findByKey(key).nativeDb.reverseAll();\n }\n public async reinstateTxn(key: string): Promise<IModelStatus> {\n return IModelDb.findByKey(key).nativeDb.reinstateTxn();\n }\n public async restartTxnSession(key: string): Promise<void> {\n return IModelDb.findByKey(key).nativeDb.restartTxnSession();\n }\n\n public async queryConcurrency(pool: \"io\" | \"cpu\"): Promise<number> {\n return IModelHost.platform.queryConcurrency(pool);\n }\n}\n\n/**\n * Prevents progress callback being called more frequently when provided interval.\n * @internal\n */\nexport function throttleProgressCallback(func: ProgressFunction, checkAbort: () => ProgressStatus, progressInterval?: number): ProgressFunction {\n const interval = progressInterval ?? 250; // by default, only send progress events every 250 milliseconds\n let nextTime = Date.now() + interval;\n const progressCallback: ProgressFunction = (loaded, total) => {\n const now = Date.now();\n if (loaded >= total || now >= nextTime) {\n nextTime = now + interval;\n return func(loaded, total);\n }\n return checkAbort();\n };\n\n return progressCallback;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TileStorage.d.ts","sourceRoot":"","sources":["../../src/TileStorage.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAmB,aAAa,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAMtG;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cjC,OAAO,CAAC,WAAW;IAyBnB;;OAEG;IACU,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAQhE;;OAEG;IACU,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIpI,OAAO,CAAC,YAAY;CAOrB"}
@@ -27,7 +27,15 @@ class TileStorage {
27
27
  if (this._initializedIModels.has(iModelId))
28
28
  return;
29
29
  if (!(await this.storage.baseDirectoryExists({ baseDirectory: iModelId }))) {
30
- await this.storage.createBaseDirectory({ baseDirectory: iModelId });
30
+ try {
31
+ await this.storage.createBaseDirectory({ baseDirectory: iModelId });
32
+ }
33
+ catch (e) {
34
+ // Ignore 409 errors. This is what Azure blob storage returns when the container already exists.
35
+ // Usually this means multiple backends tried to initialize tile storage at the same time.
36
+ if (e.statusCode !== 409)
37
+ throw e;
38
+ }
31
39
  }
32
40
  this._initializedIModels.add(iModelId);
33
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TileStorage.js","sourceRoot":"","sources":["../../src/TileStorage.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,+BAAoC;AACpC,+BAAiC;AAEjC,oDAA4D;AAC5D,sDAA6C;AAC7C,mEAAgE;AAChE,6CAA0C;AAY1C;;;GAGG;AACH,MAAa,WAAW;IAOtB,YAAmB,OAAsB;QAIjC,wBAAmB,GAAgB,IAAI,GAAG,EAAE,CAAC;QAHnD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAID;;OAEG;IACI,KAAK,CAAC,UAAU,CAAC,QAAgB;QACtC,IAAI,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC;YACxC,OAAO;QACT,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC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,CAAC;QACd,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE;YAC/B,4CAA4C;YAC5C,2BAA2B;YAC3B,OAAO;gBACL,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;gBAChB,SAAS,EAAE,UAAU;gBACrB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;aACf,CAAC;QACJ,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,cAAc,CAAC,QAAgB;QAC1C,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE;YAC1D,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;SACvB;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,YAAY,CAAC,QAAgB,EAAE,WAAmB,EAAE,MAAc,EAAE,SAAiB,EAAE,IAAa;QAC/G,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAA,oCAAsB,EAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAC3G,CAAC;IAEO,YAAY,CAAC,OAAe,EAAE,GAAY;QAChD,qBAAM,CAAC,YAAY,CACjB,6CAAqB,CAAC,iBAAiB,EACvC,GAAG,EACH,CAAC,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,qBAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,OAAO,kBAAkB,EAAE,EAAE,GAAG,aAAa,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CACnI,CAAC;IACJ,CAAC;CACF;AA3JD,kCA2JC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { gunzip, gzip } from \"zlib\";\nimport { promisify } from \"util\";\nimport { Metadata, ObjectReference, ServerStorage, TransferConfig } from \"@itwin/object-storage-core\";\nimport { getTileObjectReference } from \"@itwin/core-common\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { IModelHost } from \"./IModelHost\";\n\n/**\n * Identifies a tile in cloud tile cache.\n * @beta\n */\nexport interface TileId {\n treeId: string;\n contentId: string;\n guid: string;\n}\n\n/**\n * Facilitates interaction with cloud tile cache.\n * @beta\n */\nexport class TileStorage {\n /**\n * Allows using the underlying `ServerStorage` API directly.\n * @see https://github.com/iTwin/object-storage/\n */\n public readonly storage: ServerStorage;\n\n public constructor(storage: ServerStorage) {\n this.storage = storage;\n }\n\n private _initializedIModels: Set<string> = new Set();\n\n /**\n * Ensures any required cloud storage resources for a specific iModel are ready to use.\n */\n public async initialize(iModelId: string): Promise<void> {\n if (this._initializedIModels.has(iModelId))\n return;\n if (!(await this.storage.baseDirectoryExists({ baseDirectory: iModelId }))) {\n await this.storage.createBaseDirectory({ baseDirectory: iModelId });\n }\n this._initializedIModels.add(iModelId);\n }\n\n /**\n * Returns config that can be used by frontends to download tiles\n * @param iModelId Id of the iModel\n * @param expiresInSeconds Optional number of seconds until the download URL expires. Defaults to expiring exactly at midnight of next Sunday to enable persistent client-side caching.\n * It is recommended to set this to a shorter period when using S3-compatible storage - an exact expiry date cannot be ensured due to limitations in their API.\n * @see [TileStorage]($frontend)\n */\n public async getDownloadConfig(iModelId: string, expiresInSeconds?: number): Promise<TransferConfig> {\n try {\n if (expiresInSeconds !== undefined)\n return await this.storage.getDownloadConfig({ baseDirectory: iModelId }, { expiresInSeconds });\n const expiresOn = new Date();\n expiresOn.setDate(expiresOn.getDate() + (7 - expiresOn.getDay())); // next Sunday\n expiresOn.setHours(0, 0, 0, 0); // exactly at midnight\n return await this.storage.getDownloadConfig({ baseDirectory: iModelId }, { expiresOn });\n } catch (err) {\n this.logException(\"Failed to get download config\", err);\n throw err;\n }\n }\n\n /**\n * Uploads a tile to the cloud cache.\n */\n public async uploadTile(iModelId: string, changesetId: string, treeId: string, contentId: string, content: Uint8Array, guid?: string, metadata?: Metadata): Promise<void> {\n try {\n await this.storage.upload(\n getTileObjectReference(iModelId, changesetId, treeId, contentId, guid),\n Buffer.from(IModelHost.compressCachedTiles ? await promisify(gzip)(content.buffer) : content.buffer),\n metadata,\n IModelHost.compressCachedTiles ? { contentEncoding: \"gzip\" } : undefined,\n );\n } catch (err) {\n this.logException(\"Failed to upload tile\", err);\n throw err;\n }\n }\n\n /**\n * Downloads a tile from the cloud cache.\n */\n public async downloadTile(iModelId: string, changesetId: string, treeId: string, contentId: string, guid?: string): Promise<Uint8Array> {\n try {\n const buffer = await this.storage.download(\n getTileObjectReference(iModelId, changesetId, treeId, contentId, guid),\n \"buffer\",\n );\n return IModelHost.compressCachedTiles ? await promisify(gunzip)(buffer) : buffer;\n } catch (err) {\n this.logException(\"Failed to download tile\", err);\n throw err;\n }\n }\n\n /**\n * Returns an async iterator of all tiles that are found in the cloud cache.\n */\n public async *getCachedTilesGenerator(iModelId: string): AsyncGenerator<TileId> {\n const iterator = this.getCachedTilePages(iModelId);\n for await (const page of iterator) {\n for (const tile of page) {\n yield tile;\n }\n }\n }\n\n private async *getCachedTilePages(iModelId: string): AsyncGenerator<TileId[]> {\n const iterator = this.storage.getListObjectsPagedIterator({ baseDirectory: iModelId }, 500);\n let prevPage: IteratorResult<ObjectReference[], any> | undefined;\n do {\n // initiate loading the next page\n const page = iterator.next();\n // process results from the previous page\n if (prevPage)\n yield this.convertPage(prevPage.value);\n // finish loading the next page\n prevPage = await page;\n } while (!prevPage.done);\n }\n\n private convertPage(page: ObjectReference[]): TileId[] {\n return page\n .map((objectReference) => ({\n parts: objectReference.relativeDirectory?.split(\"/\") ?? [\"\"],\n objectName: objectReference.objectName,\n }))\n .filter(({ parts, objectName }) => {\n if (parts[0] !== \"tiles\")\n return false;\n if (parts.length !== 3) {\n Logger.logWarning(BackendLoggerCategory.IModelTileStorage, \"Malformed tile id found in tile cache: {tileId}\", { tileId: [...parts, objectName].join(\"/\") });\n return false;\n }\n return true;\n }).map(({ parts, objectName }) => {\n // relativeDirectory = tiles/<treeId>/<guid>\n // objectName = <contentId>\n return {\n treeId: parts[1],\n contentId: objectName,\n guid: parts[2],\n };\n });\n }\n\n /**\n * Returns a list of all tiles that are found in the cloud cache.\n */\n public async getCachedTiles(iModelId: string): Promise<TileId[]> {\n const results: TileId[] = [];\n for await (const page of this.getCachedTilePages(iModelId)) {\n results.push(...page);\n }\n return results;\n }\n\n /**\n * Returns a boolean indicating whether a tile exists in the cloud cache\n */\n public async isTileCached(iModelId: string, changesetId: string, treeId: string, contentId: string, guid?: string): Promise<boolean> {\n return this.storage.objectExists(getTileObjectReference(iModelId, changesetId, treeId, contentId, guid));\n }\n\n private logException(message: string, err: unknown): void {\n Logger.logException(\n BackendLoggerCategory.IModelTileStorage,\n err,\n (category, msg, errorMetadata) => Logger.logError(category, `${message}: {errorMessage}`, { ...errorMetadata, errorMessage: msg }),\n );\n }\n}\n"]}
1
+ {"version":3,"file":"TileStorage.js","sourceRoot":"","sources":["../../src/TileStorage.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,+BAAoC;AACpC,+BAAiC;AAEjC,oDAA4D;AAC5D,sDAA6C;AAC7C,mEAAgE;AAChE,6CAA0C;AAY1C;;;GAGG;AACH,MAAa,WAAW;IAOtB,YAAmB,OAAsB;QAIjC,wBAAmB,GAAgB,IAAI,GAAG,EAAE,CAAC;QAHnD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAID;;OAEG;IACI,KAAK,CAAC,UAAU,CAAC,QAAgB;QACtC,IAAI,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC;YACxC,OAAO;QACT,IAAI,CAAC,CAAC,MAAM,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EAAE,GAAG,EAAE,CAAC,CACnI,CAAC;IACJ,CAAC;CACF;AAlKD,kCAkKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { gunzip, gzip } from \"zlib\";\nimport { promisify } from \"util\";\nimport { Metadata, ObjectReference, ServerStorage, TransferConfig } from \"@itwin/object-storage-core\";\nimport { getTileObjectReference } from \"@itwin/core-common\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { IModelHost } from \"./IModelHost\";\n\n/**\n * Identifies a tile in cloud tile cache.\n * @beta\n */\nexport interface TileId {\n treeId: string;\n contentId: string;\n guid: string;\n}\n\n/**\n * Facilitates interaction with cloud tile cache.\n * @beta\n */\nexport class TileStorage {\n /**\n * Allows using the underlying `ServerStorage` API directly.\n * @see https://github.com/iTwin/object-storage/\n */\n public readonly storage: ServerStorage;\n\n public constructor(storage: ServerStorage) {\n this.storage = storage;\n }\n\n private _initializedIModels: Set<string> = new Set();\n\n /**\n * Ensures any required cloud storage resources for a specific iModel are ready to use.\n */\n public async initialize(iModelId: string): Promise<void> {\n if (this._initializedIModels.has(iModelId))\n return;\n if (!(await this.storage.baseDirectoryExists({ baseDirectory: iModelId }))) {\n try {\n await this.storage.createBaseDirectory({ baseDirectory: iModelId });\n } catch (e: any) {\n // Ignore 409 errors. This is what Azure blob storage returns when the container already exists.\n // Usually this means multiple backends tried to initialize tile storage at the same time.\n if(e.statusCode !== 409)\n throw e;\n }\n }\n this._initializedIModels.add(iModelId);\n }\n\n /**\n * Returns config that can be used by frontends to download tiles\n * @param iModelId Id of the iModel\n * @param expiresInSeconds Optional number of seconds until the download URL expires. Defaults to expiring exactly at midnight of next Sunday to enable persistent client-side caching.\n * It is recommended to set this to a shorter period when using S3-compatible storage - an exact expiry date cannot be ensured due to limitations in their API.\n * @see [TileStorage]($frontend)\n */\n public async getDownloadConfig(iModelId: string, expiresInSeconds?: number): Promise<TransferConfig> {\n try {\n if (expiresInSeconds !== undefined)\n return await this.storage.getDownloadConfig({ baseDirectory: iModelId }, { expiresInSeconds });\n const expiresOn = new Date();\n expiresOn.setDate(expiresOn.getDate() + (7 - expiresOn.getDay())); // next Sunday\n expiresOn.setHours(0, 0, 0, 0); // exactly at midnight\n return await this.storage.getDownloadConfig({ baseDirectory: iModelId }, { expiresOn });\n } catch (err) {\n this.logException(\"Failed to get download config\", err);\n throw err;\n }\n }\n\n /**\n * Uploads a tile to the cloud cache.\n */\n public async uploadTile(iModelId: string, changesetId: string, treeId: string, contentId: string, content: Uint8Array, guid?: string, metadata?: Metadata): Promise<void> {\n try {\n await this.storage.upload(\n getTileObjectReference(iModelId, changesetId, treeId, contentId, guid),\n Buffer.from(IModelHost.compressCachedTiles ? await promisify(gzip)(content.buffer) : content.buffer),\n metadata,\n IModelHost.compressCachedTiles ? { contentEncoding: \"gzip\" } : undefined,\n );\n } catch (err) {\n this.logException(\"Failed to upload tile\", err);\n throw err;\n }\n }\n\n /**\n * Downloads a tile from the cloud cache.\n */\n public async downloadTile(iModelId: string, changesetId: string, treeId: string, contentId: string, guid?: string): Promise<Uint8Array> {\n try {\n const buffer = await this.storage.download(\n getTileObjectReference(iModelId, changesetId, treeId, contentId, guid),\n \"buffer\",\n );\n return IModelHost.compressCachedTiles ? await promisify(gunzip)(buffer) : buffer;\n } catch (err) {\n this.logException(\"Failed to download tile\", err);\n throw err;\n }\n }\n\n /**\n * Returns an async iterator of all tiles that are found in the cloud cache.\n */\n public async *getCachedTilesGenerator(iModelId: string): AsyncGenerator<TileId> {\n const iterator = this.getCachedTilePages(iModelId);\n for await (const page of iterator) {\n for (const tile of page) {\n yield tile;\n }\n }\n }\n\n private async *getCachedTilePages(iModelId: string): AsyncGenerator<TileId[]> {\n const iterator = this.storage.getListObjectsPagedIterator({ baseDirectory: iModelId }, 500);\n let prevPage: IteratorResult<ObjectReference[], any> | undefined;\n do {\n // initiate loading the next page\n const page = iterator.next();\n // process results from the previous page\n if (prevPage)\n yield this.convertPage(prevPage.value);\n // finish loading the next page\n prevPage = await page;\n } while (!prevPage.done);\n }\n\n private convertPage(page: ObjectReference[]): TileId[] {\n return page\n .map((objectReference) => ({\n parts: objectReference.relativeDirectory?.split(\"/\") ?? [\"\"],\n objectName: objectReference.objectName,\n }))\n .filter(({ parts, objectName }) => {\n if (parts[0] !== \"tiles\")\n return false;\n if (parts.length !== 3) {\n Logger.logWarning(BackendLoggerCategory.IModelTileStorage, \"Malformed tile id found in tile cache: {tileId}\", { tileId: [...parts, objectName].join(\"/\") });\n return false;\n }\n return true;\n }).map(({ parts, objectName }) => {\n // relativeDirectory = tiles/<treeId>/<guid>\n // objectName = <contentId>\n return {\n treeId: parts[1],\n contentId: objectName,\n guid: parts[2],\n };\n });\n }\n\n /**\n * Returns a list of all tiles that are found in the cloud cache.\n */\n public async getCachedTiles(iModelId: string): Promise<TileId[]> {\n const results: TileId[] = [];\n for await (const page of this.getCachedTilePages(iModelId)) {\n results.push(...page);\n }\n return results;\n }\n\n /**\n * Returns a boolean indicating whether a tile exists in the cloud cache\n */\n public async isTileCached(iModelId: string, changesetId: string, treeId: string, contentId: string, guid?: string): Promise<boolean> {\n return this.storage.objectExists(getTileObjectReference(iModelId, changesetId, treeId, contentId, guid));\n }\n\n private logException(message: string, err: unknown): void {\n Logger.logException(\n BackendLoggerCategory.IModelTileStorage,\n err,\n (category, msg, errorMetadata) => Logger.logError(category, `${message}: {errorMessage}`, { ...errorMetadata, errorMessage: msg }),\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/logging.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAwB,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAK7G,qBAAa,uBAAwB,SAAQ,gBAAgB;cAClC,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;cAQrF,WAAW,IAAI,MAAM;YAI1B,eAAe;CAqB9B"}
1
+ {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/logging.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAwB,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAK7G,qBAAa,uBAAwB,SAAQ,gBAAgB;cAClC,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;cAQrF,WAAW,IAAI,MAAM;YAI1B,eAAe;CAmB9B"}
@@ -32,9 +32,7 @@ class WebAppRpcLoggingBackend extends core_common_1.WebAppRpcLogging {
32
32
  method: invocation.request.method,
33
33
  path: invocation.request.path,
34
34
  status: invocation.status,
35
- httpStatus: core_bentley_1.StatusCategory.for(result).code,
36
35
  errorMessage,
37
- error: core_bentley_1.BentleyError.getErrorProps(result),
38
36
  // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!
39
37
  ActivityId: invocation.request.id,
40
38
  MachineName: this.getHostname(),
@@ -1 +1 @@
1
- {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../../../src/rpc/web/logging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2E;AAC3E,oDAA6G;AAC7G,yBAAyB;AAEzB,4CAA4C;AAE5C,MAAa,uBAAwB,SAAQ,8BAAgB;IACxC,KAAK,CAAC,gBAAgB,CAAC,KAAuB,EAAE,MAAqB;QACtF,QAAQ,KAAK,EAAE;YACb,KAAK,8BAAgB,CAAC,eAAe,CAAC,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,8BAA8B,EAAE,MAAM,CAAC,OAAO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G,OAAO;SACX,CAAC;QAEF,qBAAM,CAAC,QAAQ,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,GAAG,OAAO,IAAI,mBAAmB,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC3G,CAAC;CACF;AAlCD,0DAkCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyError, Logger, StatusCategory } from \"@itwin/core-bentley\";\nimport { CommonLoggerCategory, RpcInvocation, RpcProtocolEvent, WebAppRpcLogging } from \"@itwin/core-common\";\nimport * as os from \"os\";\n\n/* eslint-disable deprecation/deprecation */\n\nexport class WebAppRpcLoggingBackend extends WebAppRpcLogging {\n protected override async logProtocolEvent(event: RpcProtocolEvent, object: RpcInvocation): Promise<void> {\n switch (event) {\n case RpcProtocolEvent.RequestReceived: return this.logRequest(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.request\", object.request);\n case RpcProtocolEvent.BackendErrorOccurred: return this.logErrorBackend(\"RpcInterface.backend.error\", object);\n case RpcProtocolEvent.BackendResponseCreated: return this.logResponse(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.response\", object.request, object.status, object.elapsed);\n }\n }\n\n protected override getHostname(): string {\n return os.hostname();\n }\n\n private async logErrorBackend(message: string, invocation: RpcInvocation): Promise<void> {\n const operationDescriptor = this.buildOperationDescriptor(invocation.operation);\n const pathIds = this.findPathIds(invocation.request.path);\n const result = await invocation.result;\n const errorMessage = result.message ? result.message : result.objects; // Can be an error or an RpcSerializedValue\n\n const metadata = {\n method: invocation.request.method,\n path: invocation.request.path,\n status: invocation.status,\n httpStatus: StatusCategory.for(result).code,\n errorMessage,\n error: BentleyError.getErrorProps(result),\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: invocation.request.id, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n };\n\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, `${message}.${operationDescriptor}`, metadata);\n }\n}\n"]}
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../../../src/rpc/web/logging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,oDAA6G;AAC7G,yBAAyB;AAEzB,4CAA4C;AAE5C,MAAa,uBAAwB,SAAQ,8BAAgB;IACxC,KAAK,CAAC,gBAAgB,CAAC,KAAuB,EAAE,MAAqB;QACtF,QAAQ,KAAK,EAAE;YACb,KAAK,8BAAgB,CAAC,eAAe,CAAC,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,8BAA8B,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YACxJ,KAAK,8BAAgB,CAAC,oBAAoB,CAAC,CAAC,OAAO,IAAI,CAAC,eAAe,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;YAC9G,KAAK,8BAAgB,CAAC,sBAAsB,CAAC,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,+BAA+B,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;SACjM;IACH,CAAC;IAEkB,WAAW;QAC5B,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,eAAe,CAAC,OAAe,EAAE,UAAyB;QACtE,MAAM,mBAAmB,GAAG,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAChF,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC;QACvC,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,2CAA2C;QAElH,MAAM,QAAQ,GAAG;YACf,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,MAAM;YACjC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,IAAI;YAC7B,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,YAAY;YACZ,uGAAuG;YACvG,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE;YACjC,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;YAC/B,GAAG,OAAO;SACX,CAAC;QAEF,qBAAM,CAAC,QAAQ,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,GAAG,OAAO,IAAI,mBAAmB,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC3G,CAAC;CACF;AAhCD,0DAgCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport { CommonLoggerCategory, RpcInvocation, RpcProtocolEvent, WebAppRpcLogging } from \"@itwin/core-common\";\nimport * as os from \"os\";\n\n/* eslint-disable deprecation/deprecation */\n\nexport class WebAppRpcLoggingBackend extends WebAppRpcLogging {\n protected override async logProtocolEvent(event: RpcProtocolEvent, object: RpcInvocation): Promise<void> {\n switch (event) {\n case RpcProtocolEvent.RequestReceived: return this.logRequest(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.request\", object.request);\n case RpcProtocolEvent.BackendErrorOccurred: return this.logErrorBackend(\"RpcInterface.backend.error\", object);\n case RpcProtocolEvent.BackendResponseCreated: return this.logResponse(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.response\", object.request, object.status, object.elapsed);\n }\n }\n\n protected override getHostname(): string {\n return os.hostname();\n }\n\n private async logErrorBackend(message: string, invocation: RpcInvocation): Promise<void> {\n const operationDescriptor = this.buildOperationDescriptor(invocation.operation);\n const pathIds = this.findPathIds(invocation.request.path);\n const result = await invocation.result;\n const errorMessage = result.message ? result.message : result.objects; // Can be an error or an RpcSerializedValue\n\n const metadata = {\n method: invocation.request.method,\n path: invocation.request.path,\n status: invocation.status,\n errorMessage,\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: invocation.request.id, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n };\n\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, `${message}.${operationDescriptor}`, metadata);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/response.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAKlB,qBAAqB,EAGrB,oBAAoB,EAEpB,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AA6D5B,gBAAgB;AAChB,wBAAsB,YAAY,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,qBAAqB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,EAAE,kBAAkB,iBAqCjL"}
1
+ {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/response.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAEL,iBAAiB,EACjB,kBAAkB,EAKlB,qBAAqB,EAGrB,oBAAoB,EAEpB,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AA6D5B,gBAAgB;AAChB,wBAAsB,YAAY,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,qBAAqB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,EAAE,kBAAkB,iBAuCjL"}
@@ -8,6 +8,7 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.sendResponse = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
11
12
  const core_common_1 = require("@itwin/core-common");
12
13
  /* eslint-disable deprecation/deprecation */
13
14
  function configureResponse(protocol, request, fulfillment, res) {
@@ -65,6 +66,7 @@ function configureStream(fulfillment) {
65
66
  }
66
67
  /** @internal */
67
68
  async function sendResponse(protocol, request, fulfillment, req, res) {
69
+ logResponse(request, fulfillment.status, fulfillment.rawResult);
68
70
  const versionHeader = protocol.protocolVersionHeaderName;
69
71
  if (versionHeader && core_common_1.RpcProtocol.protocolVersion) {
70
72
  res.set(versionHeader, core_common_1.RpcProtocol.protocolVersion.toString());
@@ -103,4 +105,18 @@ async function sendResponse(protocol, request, fulfillment, req, res) {
103
105
  }
104
106
  }
105
107
  exports.sendResponse = sendResponse;
108
+ function logResponse(request, statusCode, resultObj) {
109
+ const metadata = {
110
+ ActivityId: request.id,
111
+ method: request.method,
112
+ path: request.path,
113
+ operation: request.operation,
114
+ statusCode,
115
+ error: resultObj instanceof Error ? resultObj : undefined,
116
+ };
117
+ if (statusCode < 400)
118
+ core_bentley_1.Logger.logInfo(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, "RPC over HTTP success response", metadata);
119
+ else
120
+ core_bentley_1.Logger.logError(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, "RPC over HTTP failure response", metadata);
121
+ }
106
122
  //# sourceMappingURL=response.js.map