@itwin/core-backend 5.0.0-dev.97 → 5.0.0-dev.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/BackendHubAccess.d.ts +2 -8
- package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +12 -5
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +1 -0
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts +8 -15
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +23 -54
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +37 -1
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +81 -0
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +181 -2
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js +224 -5
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +16 -4
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +40 -2
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +1 -0
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
- package/lib/cjs/ElementTreeWalker.js +4 -0
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/HubMock.d.ts +1 -1
- package/lib/cjs/HubMock.d.ts.map +1 -1
- package/lib/cjs/HubMock.js +13 -2
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +4 -0
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +33 -3
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +2 -0
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/ViewStore.d.ts.map +1 -1
- package/lib/cjs/ViewStore.js +2 -1
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.js +2 -0
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
- package/lib/cjs/internal/Symbols.d.ts +2 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -1
- package/lib/cjs/internal/Symbols.js +3 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +1 -0
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +11 -22
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/esm/BackendHubAccess.d.ts +2 -8
- package/lib/esm/BackendHubAccess.d.ts.map +1 -1
- package/lib/esm/BackendHubAccess.js.map +1 -1
- package/lib/esm/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/esm/ChangeSummaryManager.js +12 -5
- package/lib/esm/ChangeSummaryManager.js.map +1 -1
- package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/esm/ChangesetECAdaptor.js +1 -0
- package/lib/esm/ChangesetECAdaptor.js.map +1 -1
- package/lib/esm/CheckpointManager.d.ts +8 -15
- package/lib/esm/CheckpointManager.d.ts.map +1 -1
- package/lib/esm/CheckpointManager.js +22 -52
- package/lib/esm/CheckpointManager.js.map +1 -1
- package/lib/esm/ECDb.d.ts +37 -1
- package/lib/esm/ECDb.d.ts.map +1 -1
- package/lib/esm/ECDb.js +82 -1
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/ECSqlStatement.d.ts +181 -2
- package/lib/esm/ECSqlStatement.d.ts.map +1 -1
- package/lib/esm/ECSqlStatement.js +222 -4
- package/lib/esm/ECSqlStatement.js.map +1 -1
- package/lib/esm/Element.d.ts +16 -4
- package/lib/esm/Element.d.ts.map +1 -1
- package/lib/esm/Element.js +40 -2
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/ElementAspect.d.ts.map +1 -1
- package/lib/esm/ElementAspect.js +1 -0
- package/lib/esm/ElementAspect.js.map +1 -1
- package/lib/esm/ElementTreeWalker.d.ts.map +1 -1
- package/lib/esm/ElementTreeWalker.js +4 -0
- package/lib/esm/ElementTreeWalker.js.map +1 -1
- package/lib/esm/HubMock.d.ts +1 -1
- package/lib/esm/HubMock.d.ts.map +1 -1
- package/lib/esm/HubMock.js +13 -2
- package/lib/esm/HubMock.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +4 -0
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +33 -3
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/Relationship.d.ts.map +1 -1
- package/lib/esm/Relationship.js +2 -0
- package/lib/esm/Relationship.js.map +1 -1
- package/lib/esm/ViewStore.d.ts.map +1 -1
- package/lib/esm/ViewStore.js +2 -1
- package/lib/esm/ViewStore.js.map +1 -1
- package/lib/esm/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/esm/internal/ChannelAdmin.js +2 -0
- package/lib/esm/internal/ChannelAdmin.js.map +1 -1
- package/lib/esm/internal/Symbols.d.ts +2 -0
- package/lib/esm/internal/Symbols.d.ts.map +1 -1
- package/lib/esm/internal/Symbols.js +2 -0
- package/lib/esm/internal/Symbols.js.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js +1 -0
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.js +13 -24
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/esm/test/CloudSqliteMock.d.ts +37 -0
- package/lib/esm/test/CloudSqliteMock.d.ts.map +1 -0
- package/lib/esm/test/CloudSqliteMock.js +117 -0
- package/lib/esm/test/CloudSqliteMock.js.map +1 -0
- package/lib/esm/test/IModelTestUtils.d.ts +1 -1
- package/lib/esm/test/IModelTestUtils.d.ts.map +1 -1
- package/lib/esm/test/IModelTestUtils.js +16 -4
- package/lib/esm/test/IModelTestUtils.js.map +1 -1
- package/lib/esm/test/PrintElementTree.js +1 -0
- package/lib/esm/test/PrintElementTree.js.map +1 -1
- package/lib/esm/test/SchemaUtils.test.js +2 -0
- package/lib/esm/test/SchemaUtils.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECDb.test.js +12 -1
- package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlAst.test.js +1 -0
- package/lib/esm/test/ecdb/ECSqlAst.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlQuery.test.js +6 -0
- package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlReader.test.js +1 -1
- package/lib/esm/test/ecdb/ECSqlReader.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlStatement.test.js +253 -163
- package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
- package/lib/esm/test/ecdb/SqliteStatement.test.js +2 -0
- package/lib/esm/test/ecdb/SqliteStatement.test.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js +1 -0
- package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js +5 -1
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
- package/lib/esm/test/element/ElementRoundTrip.test.js +10 -0
- package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
- package/lib/esm/test/font/IModelDbFonts.test.js +3 -1
- package/lib/esm/test/font/IModelDbFonts.test.js.map +1 -1
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js +18 -7
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
- package/lib/esm/test/hubaccess/CheckpointManager.test.js +5 -91
- package/lib/esm/test/hubaccess/CheckpointManager.test.js.map +1 -1
- package/lib/esm/test/imodel/ElementTreeWalker.test.js +1 -0
- package/lib/esm/test/imodel/ElementTreeWalker.test.js.map +1 -1
- package/lib/esm/test/imodel/IModel.test.js +14 -0
- package/lib/esm/test/imodel/IModel.test.js.map +1 -1
- package/lib/esm/test/schema/GenericDomain.test.js +1 -0
- package/lib/esm/test/schema/GenericDomain.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangeMerge.test.js +0 -4
- package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +1 -0
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/Drawing.test.d.ts +2 -0
- package/lib/esm/test/standalone/Drawing.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/Drawing.test.js +120 -0
- package/lib/esm/test/standalone/Drawing.test.js.map +1 -0
- package/lib/esm/test/standalone/IModelWrite.test.js +22 -6
- package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
- package/lib/esm/test/standalone/RenderMaterialElement.test.js +1 -0
- package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
- package/lib/esm/test/standalone/SnapshotDb.test.js +4 -3
- package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
- package/package.json +13 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckpointManager.js","sourceRoot":"","sources":["../../src/CheckpointManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,2BAA2B;AAE3B,6BAA6B;AAC7B,8DAAgE;AAChE,sDAA4J;AAC5J,oDAE4B;AAE5B,mEAAgE;AAChE,yDAAsD;AACtD,+CAA4C;AAC5C,6CAA0C;AAC1C,6CAA0C;AAC1C,yCAAkD;AAClD,8DAAyD;AACzD,gDAA2D;AAE3D,MAAM,cAAc,GAAG,6CAAqB,CAAC,QAAQ,CAAC;AAyBtD;;GAEG;AACH,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,yBAAyB;IACzB,2DAAY,CAAA;IACZ,sBAAsB;IACtB,qDAAS,CAAA;AACX,CAAC,EALW,cAAc,8BAAd,cAAc,QAKzB;AAmCD,gBAAgB;AAChB,MAAa,SAAS;IACZ,MAAM,CAAC,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEhD,MAAM,CAAC,KAAK,CAAC,OAAO,CAAI,GAAgB,EAAE,EAAoC;QACpF,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,gDAAgD;QACvF,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC/B,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAEM,MAAM,CAAC,YAAY,CAAC,QAAuB;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAI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M,uBAAU,CAAC,oBAAU,CAAC,CAAC,cAAc,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAU,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE;aAC7I;SACF,CAAC;IACJ,CAAC;;AA3KH,8CA4KC","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 iModels\n */\n\n// cspell:ignore BLOCKCACHE\n\nimport * as path from \"path\";\nimport { NativeLoggerCategory } from \"@bentley/imodeljs-native\";\nimport { AccessToken, BeEvent, ChangeSetStatus, Guid, GuidString, IModelStatus, Logger, LogLevel, Mutable, OpenMode, StopWatch } from \"@itwin/core-bentley\";\nimport {\n BriefcaseIdValue, ChangesetId, ChangesetIdWithIndex, ChangesetIndexAndId, IModelError, IModelVersion, LocalDirName, LocalFileName, OpenCheckpointArgs,\n} from \"@itwin/core-common\";\nimport { V2CheckpointAccessProps } from \"./BackendHubAccess\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { BriefcaseManager } from \"./BriefcaseManager\";\nimport { CloudSqlite } from \"./CloudSqlite\";\nimport { IModelHost } from \"./IModelHost\";\nimport { IModelJsFs } from \"./IModelJsFs\";\nimport { SnapshotDb, TokenArg } from \"./IModelDb\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { _hubAccess, _nativeDb } from \"./internal/Symbols\";\n\nconst loggerCategory = BackendLoggerCategory.IModelDb;\n\n/**\n * Properties of a checkpoint\n * @public\n */\nexport interface CheckpointProps extends TokenArg {\n readonly expectV2?: boolean;\n\n /** iTwin that the iModel belongs to */\n readonly iTwinId: GuidString;\n\n /** Id of the iModel */\n readonly iModelId: GuidString;\n\n /** changeset for the checkpoint */\n readonly changeset: ChangesetIdWithIndex;\n\n /** If true, then the latest successful v2 checkpoint at or before the provided changeset will be returned when calling queryV2Checkpoint. */\n readonly allowPreceding?: boolean;\n\n /** The number of seconds before the current token expires to attempt to reacquire a new token. Default is 1 hour. */\n readonly reattachSafetySeconds?: number;\n}\n\n/** Return value from [[ProgressFunction]].\n * @public\n */\nexport enum ProgressStatus {\n /** Continue download. */\n Continue = 0,\n /** Abort download. */\n Abort = 1,\n}\n\n/** Called to show progress during a download. If this function returns non-zero, the download is aborted.\n * @public\n */\nexport type ProgressFunction = (loaded: number, total: number) => ProgressStatus;\n\n/** The parameters that specify a request to download a checkpoint file from iModelHub.\n * @internal\n */\nexport interface DownloadRequest {\n /** name of local file to hold the downloaded data. */\n localFile: LocalFileName;\n\n /** A list of full fileName paths to test before downloading. If a valid file exists by one of these names,\n * no download is performed and `localFile` is updated to reflect the fact that the file exists with that name.\n * This can be used, for example, to look for checkpoints from previous versions if the naming strategy changes.\n */\n readonly aliasFiles?: ReadonlyArray<string>;\n\n /** Properties of the checkpoint to be downloaded */\n readonly checkpoint: CheckpointProps;\n\n /** If present, this function will be called to indicate progress as the briefcase is downloaded. If this\n * function returns a non-zero value, the download is aborted.\n */\n readonly onProgress?: ProgressFunction;\n}\n\n/** @internal */\nexport interface DownloadJob {\n request: DownloadRequest;\n promise?: Promise<any>;\n}\n\n/** @internal */\nexport class Downloads {\n private static _active = new Map<string, DownloadJob>();\n\n private static async process<T>(job: DownloadJob, fn: (job: DownloadJob) => Promise<T>) {\n const jobName = job.request.localFile; // save this, it can change inside call to `fn`!\n this._active.set(jobName, job);\n try {\n return await fn(job);\n } finally {\n this._active.delete(jobName);\n }\n }\n\n public static isInProgress(pathName: LocalFileName): DownloadJob | undefined {\n return this._active.get(pathName);\n }\n\n public static async download<T>(request: DownloadRequest, downloadFn: (job: DownloadJob) => Promise<T>) {\n const pathName = request.localFile;\n let job = this.isInProgress(pathName);\n if (undefined !== job)\n return job.promise;\n\n IModelJsFs.recursiveMkDirSync(path.dirname(pathName));\n job = { request };\n return job.promise = this.process(job, downloadFn);\n }\n}\n\n/**\n * Utility class for opening V2 checkpoints from cloud containers, and also for downloading them.\n * @internal\n*/\nexport class V2CheckpointManager {\n public static readonly cloudCacheName = \"Checkpoints\";\n private static _cloudCache?: CloudSqlite.CloudCache;\n private static containers = new Map<string, CloudSqlite.CloudContainer>();\n\n public static getFolder(): LocalDirName {\n const cloudCachePath = path.join(BriefcaseManager.cacheDir, V2CheckpointManager.cloudCacheName);\n if (!(IModelJsFs.existsSync(cloudCachePath))) {\n IModelJsFs.recursiveMkDirSync(cloudCachePath);\n }\n return cloudCachePath;\n }\n\n /* only used by tests that reset the state of the v2CheckpointManager. all dbs should be closed before calling this function. */\n public static cleanup(): void {\n for (const [_, value] of this.containers.entries()) {\n if (value.isConnected)\n value.disconnect({ detach: true });\n }\n\n CloudSqlite.CloudCaches.dropCache(this.cloudCacheName)?.destroy();\n this._cloudCache = undefined;\n this.containers.clear();\n }\n\n private static get cloudCache(): CloudSqlite.CloudCache {\n if (!this._cloudCache) {\n let cacheDir: string | undefined = process.env.CHECKPOINT_CACHE_DIR ?? this.getFolder();\n // See if there is a daemon running, otherwise use profile directory for cloudCache\n if (!(IModelJsFs.existsSync(path.join(cacheDir, \"portnumber.bcv\"))))\n cacheDir = undefined; // no daemon running, use profile directory\n\n this._cloudCache = CloudSqlite.CloudCaches.getCache({ cacheName: this.cloudCacheName, cacheDir, cacheSize: \"50G\" });\n }\n return this._cloudCache;\n }\n\n /** Member names differ slightly between the V2Checkpoint api and the CloudSqlite api. Add aliases `accessName` for `accountName` and `accessToken` for `sasToken` */\n private static toCloudContainerProps(from: V2CheckpointAccessProps): CloudSqlite.ContainerAccessProps {\n return { ...from, baseUri: `https://${from.accountName}.blob.core.windows.net`, accessToken: from.sasToken, storageType: \"azure\" };\n }\n\n private static getContainer(v2Props: V2CheckpointAccessProps, checkpoint: CheckpointProps) {\n let container = this.containers.get(v2Props.containerId);\n if (undefined === container) {\n let tokenFn: ((args: CloudSqlite.RequestTokenArgs) => Promise<AccessToken>) | undefined;\n let tokenRefreshSeconds: number | undefined = -1;\n // from Rpc, the accessToken in the checkpoint request is from the current user. It is used to request the sasToken for the container and\n // the sasToken is checked for refresh (before it expires) on every Rpc request using that user's accessToken. For Ipc, the\n // accessToken in the checkpoint request is undefined, and the sasToken is requested by IModelHost.getAccessToken(). It is refreshed on a timer.\n if (undefined === checkpoint.accessToken) {\n tokenFn = async () => (await IModelHost[_hubAccess].queryV2Checkpoint(checkpoint))?.sasToken ?? \"\";\n tokenRefreshSeconds = undefined;\n }\n container = CloudSqlite.createCloudContainer({ ...this.toCloudContainerProps(v2Props), tokenRefreshSeconds, logId: process.env.POD_NAME, tokenFn });\n this.containers.set(v2Props.containerId, container);\n }\n return container;\n }\n\n public static async attach(checkpoint: CheckpointProps): Promise<{ dbName: string, container: CloudSqlite.CloudContainer }> {\n let v2props: V2CheckpointAccessProps | undefined;\n try {\n v2props = await IModelHost[_hubAccess].queryV2Checkpoint(checkpoint);\n if (!v2props)\n throw new Error(\"no checkpoint\");\n } catch (err: any) {\n throw new IModelError(IModelStatus.NotFound, `V2 checkpoint not found: err: ${err.message}`);\n }\n\n try {\n const container = this.getContainer(v2props, checkpoint);\n const dbName = v2props.dbName;\n // Use the new token from the recently queried v2 checkpoint just incase the one we currently have is expired.\n container.accessToken = v2props.sasToken;\n if (!container.isConnected)\n container.connect(this.cloudCache);\n container.checkForChanges();\n const dbStats = container.queryDatabase(dbName);\n if (IModelHost.appWorkspace.settings.getBoolean(\"Checkpoints/prefetch\", false)) {\n const getPrefetchConfig = (name: string, defaultVal: number) => IModelHost.appWorkspace.settings.getNumber(`Checkpoints/prefetch/${name}`, defaultVal);\n const minRequests = getPrefetchConfig(\"minRequests\", 3);\n const maxRequests = getPrefetchConfig(\"maxRequests\", 6);\n const timeout = getPrefetchConfig(\"timeout\", 100);\n const maxBlocks = getPrefetchConfig(\"maxBlocks\", 500); // default size of 2GB. Assumes a checkpoint block size of 4MB.\n if (dbStats?.totalBlocks !== undefined && dbStats.totalBlocks <= maxBlocks && dbStats.nPrefetch === 0) {\n const logPrefetch = async (prefetch: CloudSqlite.CloudPrefetch) => {\n const stopwatch = new StopWatch(`[${container.containerId}/${dbName}]`, true);\n Logger.logInfo(loggerCategory, `Starting prefetch of ${stopwatch.description}`, { minRequests, maxRequests, timeout });\n const done = await prefetch.promise;\n Logger.logInfo(loggerCategory, `Prefetch of ${stopwatch.description} complete=${done} (${stopwatch.elapsedSeconds} seconds)`, { minRequests, maxRequests, timeout });\n };\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n logPrefetch(CloudSqlite.startCloudPrefetch(container, dbName, { minRequests, nRequests: maxRequests, timeout }));\n } else {\n Logger.logInfo(loggerCategory, `Skipping prefetch due to size limits or ongoing prefetch.`, { maxBlocks, numPrefetches: dbStats?.nPrefetch, totalBlocksInDb: dbStats?.totalBlocks, v2props });\n }\n }\n return { dbName, container };\n } catch (e: any) {\n const error = `Cloud cache connect failed: ${e.message}`;\n if (checkpoint.expectV2)\n Logger.logError(loggerCategory, error);\n\n throw new IModelError(e.errorNumber, error);\n }\n }\n\n private static async performDownload(job: DownloadJob): Promise<ChangesetId> {\n const request = job.request;\n const v2props: V2CheckpointAccessProps | undefined = await IModelHost[_hubAccess].queryV2Checkpoint({ ...request.checkpoint, allowPreceding: true });\n if (!v2props)\n throw new IModelError(IModelStatus.NotFound, \"V2 checkpoint not found\");\n\n CheckpointManager.onDownloadV2.raiseEvent(job);\n const container = CloudSqlite.createCloudContainer(this.toCloudContainerProps(v2props));\n await CloudSqlite.transferDb(\"download\", container, { dbName: v2props.dbName, localFileName: request.localFile, onProgress: request.onProgress });\n return request.checkpoint.changeset.id;\n }\n\n /** Fully download a V2 checkpoint to a local file that can be used to create a briefcase or to work offline.\n * @returns a Promise that is resolved when the download completes with the changesetId of the downloaded checkpoint (which will\n * be the same as the requested changesetId or the most recent checkpoint before it.)\n */\n public static async downloadCheckpoint(request: DownloadRequest): Promise<ChangesetId> {\n return Downloads.download(request, async (job: DownloadJob) => this.performDownload(job));\n }\n}\n\n/** Utility class to deal with downloading V1 checkpoints from iModelHub.\n * @internal\n */\nexport class V1CheckpointManager {\n public static getFolder(iModelId: GuidString): LocalDirName {\n return path.join(BriefcaseManager.getIModelPath(iModelId), \"checkpoints\");\n }\n\n public static getFileName(checkpoint: CheckpointProps): LocalFileName {\n const changesetId = checkpoint.changeset.id || \"first\";\n return path.join(this.getFolder(checkpoint.iModelId), `${changesetId}.bim`);\n }\n\n public static async getCheckpointDb(request: DownloadRequest): Promise<SnapshotDb> {\n const db = SnapshotDb.tryFindByKey(CheckpointManager.getKey(request.checkpoint));\n return (undefined !== db) ? db : Downloads.download(request, async (job: DownloadJob) => this.downloadAndOpen(job));\n }\n\n /** Download a V1 checkpoint */\n public static async downloadCheckpoint(request: DownloadRequest): Promise<ChangesetId> {\n return Downloads.download(request, async (job: DownloadJob) => this.performDownload(job));\n }\n\n public static openCheckpointV1(fileName: LocalFileName, checkpoint: CheckpointProps) {\n const snapshot = SnapshotDb.openFile(fileName, { key: CheckpointManager.getKey(checkpoint) });\n (snapshot as any)._iTwinId = checkpoint.iTwinId;\n return snapshot;\n }\n\n private static async downloadAndOpen(job: DownloadJob) {\n const db = CheckpointManager.tryOpenLocalFile(job.request);\n if (db)\n return db;\n await this.performDownload(job);\n await CheckpointManager.updateToRequestedVersion(job.request);\n return this.openCheckpointV1(job.request.localFile, job.request.checkpoint);\n }\n\n private static async performDownload(job: DownloadJob): Promise<ChangesetId> {\n CheckpointManager.onDownloadV1.raiseEvent(job);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return (await IModelHost[_hubAccess].downloadV1Checkpoint(job.request)).id;\n }\n}\n\n/** @internal */\nexport class CheckpointManager {\n public static readonly onDownloadV1 = new BeEvent<(job: DownloadJob) => void>();\n public static readonly onDownloadV2 = new BeEvent<(job: DownloadJob) => void>();\n public static getKey(checkpoint: CheckpointProps) { return `${checkpoint.iModelId}:${checkpoint.changeset.id}`; }\n\n private static async doDownload(request: DownloadRequest): Promise<ChangesetId> {\n try {\n // first see if there's a V2 checkpoint available.\n const stopwatch = new StopWatch(`[${request.checkpoint.changeset.id}]`, true);\n Logger.logInfo(loggerCategory, `Starting download of V2 checkpoint with id ${stopwatch.description}`);\n const changesetId = await V2CheckpointManager.downloadCheckpoint(request);\n Logger.logInfo(loggerCategory, `Downloaded V2 checkpoint with id ${stopwatch.description} (${stopwatch.elapsedSeconds} seconds)`);\n if (changesetId !== request.checkpoint.changeset.id)\n Logger.logInfo(loggerCategory, `Downloaded previous v2 checkpoint because requested checkpoint not found.`, { requestedChangesetId: request.checkpoint.changeset.id, iModelId: request.checkpoint.iModelId, changesetId, iTwinId: request.checkpoint.iTwinId });\n else\n Logger.logInfo(loggerCategory, `Downloaded v2 checkpoint.`, { iModelId: request.checkpoint.iModelId, changesetId: request.checkpoint.changeset.id, iTwinId: request.checkpoint.iTwinId });\n return changesetId;\n } catch (error: any) {\n if (error.errorNumber === IModelStatus.NotFound) { // No V2 checkpoint available, try a v1 checkpoint\n const changeset = await V1CheckpointManager.downloadCheckpoint(request);\n Logger.logWarning(loggerCategory, `Got an error downloading v2 checkpoint, but downloaded v1 checkpoint successfully!`, { error, iModelId: request.checkpoint.iModelId, iTwinId: request.checkpoint.iTwinId, requestedChangesetId: request.checkpoint.changeset.id, changesetId: changeset });\n return changeset;\n }\n throw error; // most likely, was aborted\n }\n }\n\n public static async updateToRequestedVersion(request: DownloadRequest) {\n const checkpoint = request.checkpoint;\n const targetFile = request.localFile;\n const traceInfo = { iTwinId: checkpoint.iTwinId, iModelId: checkpoint.iModelId, changeset: checkpoint.changeset };\n try {\n // Open checkpoint for write\n const prevLogLevel = Logger.getLevel(NativeLoggerCategory.SQLite) ?? LogLevel.Error; // Get log level before we set it to None.\n Logger.setLevel(NativeLoggerCategory.SQLite, LogLevel.None); // Ignores noisy error messages when applying changesets.\n const db = SnapshotDb.openForApplyChangesets(targetFile);\n const nativeDb = db[_nativeDb];\n try {\n\n if (nativeDb.hasPendingTxns()) {\n Logger.logWarning(loggerCategory, \"Checkpoint with Txns found - deleting them\", () => traceInfo);\n nativeDb.deleteAllTxns();\n }\n\n if (nativeDb.getBriefcaseId() !== BriefcaseIdValue.Unassigned)\n nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);\n\n CheckpointManager.validateCheckpointGuids(checkpoint, db);\n // Apply change sets if necessary\n const currentChangeset: Mutable<ChangesetIndexAndId> = nativeDb.getCurrentChangeset();\n if (currentChangeset.id !== checkpoint.changeset.id) {\n const accessToken = checkpoint.accessToken;\n const toIndex = checkpoint.changeset.index ??\n (await IModelHost[_hubAccess].getChangesetFromVersion({ accessToken, iModelId: checkpoint.iModelId, version: IModelVersion.asOfChangeSet(checkpoint.changeset.id) })).index;\n await BriefcaseManager.pullAndApplyChangesets(db, { accessToken, toIndex });\n } else {\n // make sure the parent changeset index is saved in the file - old versions didn't have it.\n currentChangeset.index = checkpoint.changeset.index!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n nativeDb.saveLocalValue(\"parentChangeSet\", JSON.stringify(currentChangeset));\n }\n } finally {\n Logger.setLevel(NativeLoggerCategory.SQLite, prevLogLevel); // Set logging to what it was before we started applying changesets.\n db.saveChanges();\n db.close();\n }\n } catch (error: any) {\n\n Logger.logError(loggerCategory, \"Error downloading checkpoint - deleting it\", () => traceInfo);\n IModelJsFs.removeSync(targetFile);\n\n if (error.errorNumber === ChangeSetStatus.CorruptedChangeStream || error.errorNumber === ChangeSetStatus.InvalidId || error.errorNumber === ChangeSetStatus.InvalidVersion) {\n Logger.logError(loggerCategory, \"Detected potential corruption of change sets. Deleting them to enable retries\", () => traceInfo);\n BriefcaseManager.deleteChangeSetsFromLocalDisk(checkpoint.iModelId);\n }\n throw error;\n }\n }\n\n /** Download a checkpoint file from iModelHub into a local file specified in the request parameters. */\n public static async downloadCheckpoint(request: DownloadRequest): Promise<void> {\n if (this.verifyCheckpoint(request.checkpoint, request.localFile))\n return;\n\n if (request.aliasFiles) {\n for (const alias of request.aliasFiles) {\n if (this.verifyCheckpoint(request.checkpoint, alias)) {\n request.localFile = alias;\n return;\n }\n }\n }\n\n await this.doDownload(request);\n return this.updateToRequestedVersion(request);\n }\n\n /** checks a file's dbGuid & iTwinId for consistency, and updates the dbGuid when possible */\n public static validateCheckpointGuids(checkpoint: CheckpointProps, snapshotDb: SnapshotDb) {\n const traceInfo = { iTwinId: checkpoint.iTwinId, iModelId: checkpoint.iModelId };\n\n const nativeDb = snapshotDb[_nativeDb];\n const dbChangeset = nativeDb.getCurrentChangeset();\n const iModelId = Guid.normalize(nativeDb.getIModelId());\n if (iModelId !== Guid.normalize(checkpoint.iModelId)) {\n if (nativeDb.isReadonly())\n throw new IModelError(IModelStatus.ValidationFailed, \"iModelId is not properly set up in the checkpoint\");\n\n Logger.logWarning(loggerCategory, \"iModelId is not properly set up in the checkpoint. Updated checkpoint to the correct iModelId.\", () => ({ ...traceInfo, dbGuid: iModelId }));\n const iModelIdNormalized = Guid.normalize(checkpoint.iModelId);\n nativeDb.setIModelId(iModelIdNormalized);\n (snapshotDb as any)._iModelId = iModelIdNormalized;\n // Required to reset the ChangeSetId because setDbGuid clears the value.\n nativeDb.saveLocalValue(\"ParentChangeSetId\", dbChangeset.id);\n if (undefined !== dbChangeset.index)\n nativeDb.saveLocalValue(\"parentChangeSet\", JSON.stringify(dbChangeset));\n }\n\n const iTwinId = Guid.normalize(nativeDb.getITwinId());\n if (iTwinId !== Guid.normalize(checkpoint.iTwinId))\n throw new IModelError(IModelStatus.ValidationFailed, \"iTwinId was not properly set up in the checkpoint\");\n }\n\n /** @returns true if the file is the checkpoint requested */\n public static verifyCheckpoint(checkpoint: CheckpointProps, fileName: LocalFileName): boolean {\n if (!IModelJsFs.existsSync(fileName))\n return false;\n\n const nativeDb = new IModelNative.platform.DgnDb();\n try {\n nativeDb.openIModel(fileName, OpenMode.Readonly);\n } catch {\n return false;\n }\n\n const isValid = checkpoint.iModelId === nativeDb.getIModelId() && checkpoint.changeset.id === nativeDb.getCurrentChangeset().id;\n nativeDb.closeFile();\n if (!isValid)\n IModelJsFs.removeSync(fileName);\n\n return isValid;\n }\n\n /** try to open an existing local file to satisfy a download request */\n public static tryOpenLocalFile(request: DownloadRequest): SnapshotDb | undefined {\n const checkpoint = request.checkpoint;\n if (this.verifyCheckpoint(checkpoint, request.localFile))\n return V1CheckpointManager.openCheckpointV1(request.localFile, checkpoint);\n\n // check a list of aliases for finding checkpoints downloaded to non-default locations (e.g. from older versions)\n if (request.aliasFiles) {\n for (const alias of request.aliasFiles) {\n if (this.verifyCheckpoint(checkpoint, alias)) {\n request.localFile = alias;\n return V1CheckpointManager.openCheckpointV1(alias, checkpoint);\n }\n }\n }\n return undefined;\n }\n\n public static async toCheckpointProps(args: OpenCheckpointArgs): Promise<CheckpointProps> {\n const changeset = args.changeset ?? await IModelHost[_hubAccess].getLatestChangeset({ ...args, accessToken: await IModelHost.getAccessToken() });\n\n return {\n iModelId: args.iModelId,\n iTwinId: args.iTwinId,\n changeset: {\n index: changeset.index,\n id: changeset.id ?? (await IModelHost[_hubAccess].queryChangeset({ ...args, changeset, accessToken: await IModelHost.getAccessToken() })).id,\n },\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CheckpointManager.js","sourceRoot":"","sources":["../../src/CheckpointManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,2BAA2B;AAE3B,6BAA6B;AAC7B,8DAAgE;AAChE,sDAA4J;AAC5J,oDAE4B;AAE5B,mEAAgE;AAChE,yDAAsD;AACtD,+CAA4C;AAC5C,6CAA0C;AAC1C,6CAA0C;AAC1C,yCAAkD;AAClD,8DAAyD;AACzD,gDAA8F;AAE9F,MAAM,cAAc,GAAG,6CAAqB,CAAC,QAAQ,CAAC;AAyBtD;;GAEG;AACH,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,yBAAyB;IACzB,2DAAY,CAAA;IACZ,sBAAsB;IACtB,qDAAS,CAAA;AACX,CAA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C,IAAwB;QAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,MAAM,uBAAU,CAAC,oBAAU,CAAC,CAAC,kBAAkB,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,EAAE,MAAM,uBAAU,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QAEjJ,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE;gBACT,KAAK,EAAE,SAAS,CAAC,KAAK;gBACtB,EAAE,EAAE,SAAS,CAAC,EAAE,IAAI,CAAC,MAAM,uBAAU,CAAC,oBAAU,CAAC,CAAC,cAAc,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAU,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE;aAC7I;SACF,CAAC;IACJ,CAAC;;AAxKH,8CAyKC","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 iModels\n */\n\n// cspell:ignore BLOCKCACHE\n\nimport * as path from \"path\";\nimport { NativeLoggerCategory } from \"@bentley/imodeljs-native\";\nimport { AccessToken, BeEvent, ChangeSetStatus, Guid, GuidString, IModelStatus, Logger, LogLevel, Mutable, OpenMode, StopWatch } from \"@itwin/core-bentley\";\nimport {\n BriefcaseIdValue, ChangesetId, ChangesetIdWithIndex, ChangesetIndexAndId, IModelError, IModelVersion, LocalDirName, LocalFileName, OpenCheckpointArgs,\n} from \"@itwin/core-common\";\nimport { V2CheckpointAccessProps } from \"./BackendHubAccess\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { BriefcaseManager } from \"./BriefcaseManager\";\nimport { CloudSqlite } from \"./CloudSqlite\";\nimport { IModelHost } from \"./IModelHost\";\nimport { IModelJsFs } from \"./IModelJsFs\";\nimport { SnapshotDb, TokenArg } from \"./IModelDb\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { _getCheckpointDb, _hubAccess, _nativeDb, _openCheckpoint } from \"./internal/Symbols\";\n\nconst loggerCategory = BackendLoggerCategory.IModelDb;\n\n/**\n * Properties of a checkpoint\n * @public\n */\nexport interface CheckpointProps extends TokenArg {\n readonly expectV2?: boolean;\n\n /** iTwin that the iModel belongs to */\n readonly iTwinId: GuidString;\n\n /** Id of the iModel */\n readonly iModelId: GuidString;\n\n /** changeset for the checkpoint */\n readonly changeset: ChangesetIdWithIndex;\n\n /** If true, then the latest successful v2 checkpoint at or before the provided changeset will be returned when calling queryV2Checkpoint. */\n readonly allowPreceding?: boolean;\n\n /** The number of seconds before the current token expires to attempt to reacquire a new token. Default is 1 hour. */\n readonly reattachSafetySeconds?: number;\n}\n\n/** Return value from [[ProgressFunction]].\n * @public\n */\nexport enum ProgressStatus {\n /** Continue download. */\n Continue = 0,\n /** Abort download. */\n Abort = 1,\n}\n\n/** Called to show progress during a download. If this function returns non-zero, the download is aborted.\n * @public\n */\nexport type ProgressFunction = (loaded: number, total: number) => ProgressStatus;\n\n/** The parameters that specify a request to download a checkpoint file from iModelHub.\n * @internal\n */\nexport interface DownloadRequest {\n /** name of local file to hold the downloaded data. */\n localFile: LocalFileName;\n\n /** A list of full fileName paths to test before downloading. If a valid file exists by one of these names,\n * no download is performed and `localFile` is updated to reflect the fact that the file exists with that name.\n * This can be used, for example, to look for checkpoints from previous versions if the naming strategy changes.\n */\n readonly aliasFiles?: ReadonlyArray<string>;\n\n /** Properties of the checkpoint to be downloaded */\n readonly checkpoint: CheckpointProps;\n\n /** If present, this function will be called to indicate progress as the briefcase is downloaded. If this\n * function returns a non-zero value, the download is aborted.\n */\n readonly onProgress?: ProgressFunction;\n}\n\n/** @internal */\nexport interface DownloadJob {\n request: DownloadRequest;\n promise?: Promise<any>;\n}\n\n/** @internal */\nexport class Downloads {\n private static _active = new Map<string, DownloadJob>();\n\n private static async process<T>(job: DownloadJob, fn: (job: DownloadJob) => Promise<T>) {\n const jobName = job.request.localFile; // save this, it can change inside call to `fn`!\n this._active.set(jobName, job);\n try {\n return await fn(job);\n } finally {\n this._active.delete(jobName);\n }\n }\n\n public static isInProgress(pathName: LocalFileName): DownloadJob | undefined {\n return this._active.get(pathName);\n }\n\n public static async download<T>(request: DownloadRequest, downloadFn: (job: DownloadJob) => Promise<T>) {\n const pathName = request.localFile;\n let job = this.isInProgress(pathName);\n if (undefined !== job)\n return job.promise;\n\n IModelJsFs.recursiveMkDirSync(path.dirname(pathName));\n job = { request };\n return job.promise = this.process(job, downloadFn);\n }\n}\n\n/**\n * Utility class for opening V2 checkpoints from cloud containers, and also for downloading them.\n * @internal\n*/\nexport class V2CheckpointManager {\n public static readonly cloudCacheName = \"Checkpoints\";\n private static _cloudCache?: CloudSqlite.CloudCache;\n private static containers = new Map<string, CloudSqlite.CloudContainer>();\n\n public static getFolder(): LocalDirName {\n const cloudCachePath = path.join(BriefcaseManager.cacheDir, V2CheckpointManager.cloudCacheName);\n if (!(IModelJsFs.existsSync(cloudCachePath))) {\n IModelJsFs.recursiveMkDirSync(cloudCachePath);\n }\n return cloudCachePath;\n }\n\n /* only used by tests that reset the state of the v2CheckpointManager. all dbs should be closed before calling this function. */\n public static cleanup(): void {\n for (const [_, value] of this.containers.entries()) {\n if (value.isConnected)\n value.disconnect({ detach: true });\n }\n\n CloudSqlite.CloudCaches.dropCache(this.cloudCacheName)?.destroy();\n this._cloudCache = undefined;\n this.containers.clear();\n }\n\n private static get cloudCache(): CloudSqlite.CloudCache {\n if (!this._cloudCache) {\n let cacheDir: string | undefined = process.env.CHECKPOINT_CACHE_DIR ?? this.getFolder();\n // See if there is a daemon running, otherwise use profile directory for cloudCache\n if (!(IModelJsFs.existsSync(path.join(cacheDir, \"portnumber.bcv\"))))\n cacheDir = undefined; // no daemon running, use profile directory\n\n this._cloudCache = CloudSqlite.CloudCaches.getCache({ cacheName: this.cloudCacheName, cacheDir, cacheSize: \"50G\" });\n }\n return this._cloudCache;\n }\n\n /** Member names differ slightly between the V2Checkpoint api and the CloudSqlite api. Add aliases `accessName` for `accountName` and `accessToken` for `sasToken` */\n private static toCloudContainerProps(from: V2CheckpointAccessProps): CloudSqlite.ContainerAccessProps {\n return { ...from, baseUri: `https://${from.accountName}.blob.core.windows.net`, accessToken: from.sasToken, storageType: \"azure\" };\n }\n\n public static getContainer(v2Props: V2CheckpointAccessProps, checkpoint: CheckpointProps) {\n let container = this.containers.get(v2Props.containerId);\n if (undefined === container) {\n let tokenFn: ((args: CloudSqlite.RequestTokenArgs) => Promise<AccessToken>) | undefined;\n let tokenRefreshSeconds: number | undefined = -1;\n // from Rpc, the accessToken in the checkpoint request is from the current user. It is used to request the sasToken for the container and\n // the sasToken is checked for refresh (before it expires) on every Rpc request using that user's accessToken. For Ipc, the\n // accessToken in the checkpoint request is undefined, and the sasToken is requested by IModelHost.getAccessToken(). It is refreshed on a timer.\n if (undefined === checkpoint.accessToken) {\n tokenFn = async () => (await IModelHost[_hubAccess].queryV2Checkpoint(checkpoint))?.sasToken ?? \"\";\n tokenRefreshSeconds = undefined;\n }\n container = CloudSqlite.createCloudContainer({ ...this.toCloudContainerProps(v2Props), tokenRefreshSeconds, logId: process.env.POD_NAME, tokenFn });\n this.containers.set(v2Props.containerId, container);\n }\n return container;\n }\n\n public static async attach(checkpoint: CheckpointProps): Promise<{ dbName: string, container: CloudSqlite.CloudContainer | undefined }> {\n let v2props: V2CheckpointAccessProps | undefined;\n try {\n v2props = await IModelHost[_hubAccess].queryV2Checkpoint(checkpoint);\n if (!v2props)\n throw new Error(\"no checkpoint\");\n } catch (err: any) {\n throw new IModelError(IModelStatus.NotFound, `V2 checkpoint not found: err: ${err.message}`);\n }\n\n try {\n const container = this.getContainer(v2props, checkpoint);\n const dbName = v2props.dbName;\n // Use the new token from the recently queried v2 checkpoint just incase the one we currently have is expired.\n container.accessToken = v2props.sasToken;\n if (!container.isConnected)\n container.connect(this.cloudCache);\n container.checkForChanges();\n const dbStats = container.queryDatabase(dbName);\n if (IModelHost.appWorkspace.settings.getBoolean(\"Checkpoints/prefetch\", false)) {\n const getPrefetchConfig = (name: string, defaultVal: number) => IModelHost.appWorkspace.settings.getNumber(`Checkpoints/prefetch/${name}`, defaultVal);\n const minRequests = getPrefetchConfig(\"minRequests\", 3);\n const maxRequests = getPrefetchConfig(\"maxRequests\", 6);\n const timeout = getPrefetchConfig(\"timeout\", 100);\n const maxBlocks = getPrefetchConfig(\"maxBlocks\", 500); // default size of 2GB. Assumes a checkpoint block size of 4MB.\n if (dbStats?.totalBlocks !== undefined && dbStats.totalBlocks <= maxBlocks && dbStats.nPrefetch === 0) {\n const logPrefetch = async (prefetch: CloudSqlite.CloudPrefetch) => {\n const stopwatch = new StopWatch(`[${container.containerId}/${dbName}]`, true);\n Logger.logInfo(loggerCategory, `Starting prefetch of ${stopwatch.description}`, { minRequests, maxRequests, timeout });\n const done = await prefetch.promise;\n Logger.logInfo(loggerCategory, `Prefetch of ${stopwatch.description} complete=${done} (${stopwatch.elapsedSeconds} seconds)`, { minRequests, maxRequests, timeout });\n };\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n logPrefetch(CloudSqlite.startCloudPrefetch(container, dbName, { minRequests, nRequests: maxRequests, timeout }));\n } else {\n Logger.logInfo(loggerCategory, `Skipping prefetch due to size limits or ongoing prefetch.`, { maxBlocks, numPrefetches: dbStats?.nPrefetch, totalBlocksInDb: dbStats?.totalBlocks, v2props });\n }\n }\n return { dbName, container };\n } catch (e: any) {\n const error = `Cloud cache connect failed: ${e.message}`;\n if (checkpoint.expectV2)\n Logger.logError(loggerCategory, error);\n\n throw new IModelError(e.errorNumber, error);\n }\n }\n\n private static async performDownload(job: DownloadJob): Promise<ChangesetId> {\n const request = job.request;\n const v2props: V2CheckpointAccessProps | undefined = await IModelHost[_hubAccess].queryV2Checkpoint({ ...request.checkpoint, allowPreceding: true });\n if (!v2props)\n throw new IModelError(IModelStatus.NotFound, \"V2 checkpoint not found\");\n\n CheckpointManager.onDownloadV2.raiseEvent(job);\n const container = CloudSqlite.createCloudContainer(this.toCloudContainerProps(v2props));\n await CloudSqlite.transferDb(\"download\", container, { dbName: v2props.dbName, localFileName: request.localFile, onProgress: request.onProgress });\n return request.checkpoint.changeset.id;\n }\n\n /** Fully download a V2 checkpoint to a local file that can be used to create a briefcase or to work offline.\n * @returns a Promise that is resolved when the download completes with the changesetId of the downloaded checkpoint (which will\n * be the same as the requested changesetId or the most recent checkpoint before it.)\n */\n public static async downloadCheckpoint(request: DownloadRequest): Promise<ChangesetId> {\n return Downloads.download(request, async (job: DownloadJob) => this.performDownload(job));\n }\n\n /** @internal */\n public static async [_getCheckpointDb](request: DownloadRequest): Promise<SnapshotDb> {\n const db = SnapshotDb.tryFindByKey(CheckpointManager.getKey(request.checkpoint));\n return (undefined !== db) ? db : Downloads.download(request, async (job: DownloadJob) => this.downloadAndOpen(job));\n }\n\n private static async downloadAndOpen(job: DownloadJob) {\n const db = CheckpointManager.tryOpenLocalFile(job.request);\n if (db)\n return db;\n await this.performDownload(job);\n await CheckpointManager.updateToRequestedVersion(job.request);\n return CheckpointManager[_openCheckpoint](job.request.localFile, job.request.checkpoint);\n }\n}\n\n/** @internal */\nexport class CheckpointManager {\n public static readonly onDownloadV2 = new BeEvent<(job: DownloadJob) => void>();\n public static getKey(checkpoint: CheckpointProps) { return `${checkpoint.iModelId}:${checkpoint.changeset.id}`; }\n\n private static async doDownload(request: DownloadRequest): Promise<ChangesetId> {\n // first see if there's a V2 checkpoint available.\n const stopwatch = new StopWatch(`[${request.checkpoint.changeset.id}]`, true);\n Logger.logInfo(loggerCategory, `Starting download of V2 checkpoint with id ${stopwatch.description}`);\n const changesetId = await V2CheckpointManager.downloadCheckpoint(request);\n Logger.logInfo(loggerCategory, `Downloaded V2 checkpoint with id ${stopwatch.description} (${stopwatch.elapsedSeconds} seconds)`);\n if (changesetId !== request.checkpoint.changeset.id)\n Logger.logInfo(loggerCategory, `Downloaded previous v2 checkpoint because requested checkpoint not found.`, { requestedChangesetId: request.checkpoint.changeset.id, iModelId: request.checkpoint.iModelId, changesetId, iTwinId: request.checkpoint.iTwinId });\n else\n Logger.logInfo(loggerCategory, `Downloaded v2 checkpoint.`, { iModelId: request.checkpoint.iModelId, changesetId: request.checkpoint.changeset.id, iTwinId: request.checkpoint.iTwinId });\n return changesetId;\n }\n\n public static async updateToRequestedVersion(request: DownloadRequest) {\n const checkpoint = request.checkpoint;\n const targetFile = request.localFile;\n const traceInfo = { iTwinId: checkpoint.iTwinId, iModelId: checkpoint.iModelId, changeset: checkpoint.changeset };\n try {\n // Open checkpoint for write\n const prevLogLevel = Logger.getLevel(NativeLoggerCategory.SQLite) ?? LogLevel.Error; // Get log level before we set it to None.\n Logger.setLevel(NativeLoggerCategory.SQLite, LogLevel.None); // Ignores noisy error messages when applying changesets.\n const db = SnapshotDb.openForApplyChangesets(targetFile);\n const nativeDb = db[_nativeDb];\n try {\n\n if (nativeDb.hasPendingTxns()) {\n Logger.logWarning(loggerCategory, \"Checkpoint with Txns found - deleting them\", () => traceInfo);\n nativeDb.deleteAllTxns();\n }\n\n if (nativeDb.getBriefcaseId() !== BriefcaseIdValue.Unassigned)\n nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);\n\n CheckpointManager.validateCheckpointGuids(checkpoint, db);\n // Apply change sets if necessary\n const currentChangeset: Mutable<ChangesetIndexAndId> = nativeDb.getCurrentChangeset();\n if (currentChangeset.id !== checkpoint.changeset.id) {\n const accessToken = checkpoint.accessToken;\n const toIndex = checkpoint.changeset.index ??\n (await IModelHost[_hubAccess].getChangesetFromVersion({ accessToken, iModelId: checkpoint.iModelId, version: IModelVersion.asOfChangeSet(checkpoint.changeset.id) })).index;\n await BriefcaseManager.pullAndApplyChangesets(db, { accessToken, toIndex });\n } else {\n // make sure the parent changeset index is saved in the file - old versions didn't have it.\n currentChangeset.index = checkpoint.changeset.index!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n nativeDb.saveLocalValue(\"parentChangeSet\", JSON.stringify(currentChangeset));\n }\n } finally {\n Logger.setLevel(NativeLoggerCategory.SQLite, prevLogLevel); // Set logging to what it was before we started applying changesets.\n db.saveChanges();\n db.close();\n }\n } catch (error: any) {\n\n Logger.logError(loggerCategory, \"Error downloading checkpoint - deleting it\", () => traceInfo);\n IModelJsFs.removeSync(targetFile);\n\n if (error.errorNumber === ChangeSetStatus.CorruptedChangeStream || error.errorNumber === ChangeSetStatus.InvalidId || error.errorNumber === ChangeSetStatus.InvalidVersion) {\n Logger.logError(loggerCategory, \"Detected potential corruption of change sets. Deleting them to enable retries\", () => traceInfo);\n BriefcaseManager.deleteChangeSetsFromLocalDisk(checkpoint.iModelId);\n }\n throw error;\n }\n }\n\n /** Download a checkpoint file from iModelHub into a local file specified in the request parameters. */\n public static async downloadCheckpoint(request: DownloadRequest): Promise<void> {\n if (this.verifyCheckpoint(request.checkpoint, request.localFile))\n return;\n\n if (request.aliasFiles) {\n for (const alias of request.aliasFiles) {\n if (this.verifyCheckpoint(request.checkpoint, alias)) {\n request.localFile = alias;\n return;\n }\n }\n }\n\n await this.doDownload(request);\n return this.updateToRequestedVersion(request);\n }\n\n /** checks a file's dbGuid & iTwinId for consistency, and updates the dbGuid when possible */\n public static validateCheckpointGuids(checkpoint: CheckpointProps, snapshotDb: SnapshotDb) {\n const traceInfo = { iTwinId: checkpoint.iTwinId, iModelId: checkpoint.iModelId };\n\n const nativeDb = snapshotDb[_nativeDb];\n const dbChangeset = nativeDb.getCurrentChangeset();\n const iModelId = Guid.normalize(nativeDb.getIModelId());\n if (iModelId !== Guid.normalize(checkpoint.iModelId)) {\n if (nativeDb.isReadonly())\n throw new IModelError(IModelStatus.ValidationFailed, \"iModelId is not properly set up in the checkpoint\");\n\n Logger.logWarning(loggerCategory, \"iModelId is not properly set up in the checkpoint. Updated checkpoint to the correct iModelId.\", () => ({ ...traceInfo, dbGuid: iModelId }));\n const iModelIdNormalized = Guid.normalize(checkpoint.iModelId);\n nativeDb.setIModelId(iModelIdNormalized);\n (snapshotDb as any)._iModelId = iModelIdNormalized;\n // Required to reset the ChangeSetId because setDbGuid clears the value.\n nativeDb.saveLocalValue(\"ParentChangeSetId\", dbChangeset.id);\n if (undefined !== dbChangeset.index)\n nativeDb.saveLocalValue(\"parentChangeSet\", JSON.stringify(dbChangeset));\n }\n\n const iTwinId = Guid.normalize(nativeDb.getITwinId());\n if (iTwinId !== Guid.normalize(checkpoint.iTwinId))\n throw new IModelError(IModelStatus.ValidationFailed, \"iTwinId was not properly set up in the checkpoint\");\n }\n\n /** @returns true if the file is the checkpoint requested */\n public static verifyCheckpoint(checkpoint: CheckpointProps, fileName: LocalFileName): boolean {\n if (!IModelJsFs.existsSync(fileName))\n return false;\n\n const nativeDb = new IModelNative.platform.DgnDb();\n try {\n nativeDb.openIModel(fileName, OpenMode.Readonly);\n } catch {\n return false;\n }\n\n const isValid = checkpoint.iModelId === nativeDb.getIModelId() && checkpoint.changeset.id === nativeDb.getCurrentChangeset().id;\n nativeDb.closeFile();\n if (!isValid)\n IModelJsFs.removeSync(fileName);\n\n return isValid;\n }\n\n /** @internal */\n public static [_openCheckpoint](fileName: LocalFileName, checkpoint: CheckpointProps) {\n const snapshot = SnapshotDb.openFile(fileName, { key: this.getKey(checkpoint) });\n (snapshot as any)._iTwinId = checkpoint.iTwinId;\n return snapshot;\n }\n\n /** try to open an existing local file to satisfy a download request */\n public static tryOpenLocalFile(request: DownloadRequest): SnapshotDb | undefined {\n const checkpoint = request.checkpoint;\n if (this.verifyCheckpoint(checkpoint, request.localFile))\n return this[_openCheckpoint](request.localFile, checkpoint);\n\n // check a list of aliases for finding checkpoints downloaded to non-default locations (e.g. from older versions)\n if (request.aliasFiles) {\n for (const alias of request.aliasFiles) {\n if (this.verifyCheckpoint(checkpoint, alias)) {\n request.localFile = alias;\n return this[_openCheckpoint](alias, checkpoint);\n }\n }\n }\n return undefined;\n }\n\n public static async toCheckpointProps(args: OpenCheckpointArgs): Promise<CheckpointProps> {\n const changeset = args.changeset ?? await IModelHost[_hubAccess].getLatestChangeset({ ...args, accessToken: await IModelHost.getAccessToken() });\n\n return {\n iModelId: args.iModelId,\n iTwinId: args.iTwinId,\n changeset: {\n index: changeset.index,\n id: changeset.id ?? (await IModelHost[_hubAccess].queryChangeset({ ...args, changeset, accessToken: await IModelHost.getAccessToken() })).id,\n },\n };\n }\n}\n"]}
|
package/lib/cjs/ECDb.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IModelJsNative } from "@bentley/imodeljs-native";
|
|
2
2
|
import { ECSchemaProps, ECSqlReader, QueryBinder, QueryOptions } from "@itwin/core-common";
|
|
3
|
-
import { ECSqlStatement } from "./ECSqlStatement";
|
|
3
|
+
import { ECSqlStatement, ECSqlWriteStatement } from "./ECSqlStatement";
|
|
4
4
|
import { SqliteStatement } from "./SqliteStatement";
|
|
5
5
|
import { _nativeDb } from "./internal/Symbols";
|
|
6
6
|
/** Modes for how to open [ECDb]($backend) files.
|
|
@@ -87,6 +87,39 @@ export declare class ECDb implements Disposable {
|
|
|
87
87
|
* @throws if the schema can not be found or loaded.
|
|
88
88
|
*/
|
|
89
89
|
getSchemaProps(name: string): ECSchemaProps;
|
|
90
|
+
/**
|
|
91
|
+
* Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist
|
|
92
|
+
* in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved
|
|
93
|
+
* in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be
|
|
94
|
+
* reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding
|
|
95
|
+
* the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].
|
|
96
|
+
* @param sql The SQLite SQL statement to execute
|
|
97
|
+
* @param callback the callback to invoke on the prepared statement
|
|
98
|
+
* @param logErrors Determines if error will be logged if statement fail to prepare
|
|
99
|
+
* @returns the value returned by `callback`.
|
|
100
|
+
* @see [[withWriteStatement]]
|
|
101
|
+
* @beta
|
|
102
|
+
*/
|
|
103
|
+
withCachedWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors?: boolean): T;
|
|
104
|
+
/**
|
|
105
|
+
* Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.
|
|
106
|
+
* Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.
|
|
107
|
+
* For statements that will be reused often, instead use [[withPreparedStatement]].
|
|
108
|
+
* @param sql The SQLite SQL statement to execute
|
|
109
|
+
* @param callback the callback to invoke on the prepared statement
|
|
110
|
+
* @param logErrors Determines if error will be logged if statement fail to prepare
|
|
111
|
+
* @returns the value returned by `callback`.
|
|
112
|
+
* @see [[withCachedWriteStatement]]
|
|
113
|
+
* @beta
|
|
114
|
+
*/
|
|
115
|
+
withWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors?: boolean): T;
|
|
116
|
+
/** Prepare an ECSQL statement.
|
|
117
|
+
* @param ecsql The ECSQL statement to prepare
|
|
118
|
+
* @param logErrors Determines if error will be logged if statement fail to prepare
|
|
119
|
+
* @throws [IModelError]($common) if there is a problem preparing the statement.
|
|
120
|
+
* @beta
|
|
121
|
+
*/
|
|
122
|
+
prepareWriteStatement(ecsql: string, logErrors?: boolean): ECSqlWriteStatement;
|
|
90
123
|
/**
|
|
91
124
|
* Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist
|
|
92
125
|
* in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved
|
|
@@ -99,6 +132,7 @@ export declare class ECDb implements Disposable {
|
|
|
99
132
|
* @returns the value returned by `callback`.
|
|
100
133
|
* @see [[withStatement]]
|
|
101
134
|
* @public
|
|
135
|
+
* @deprecated in 4.11. Use [[createQueryReader]] for SELECT statements and [[withCachedWriteStatement]] for INSERT/UPDATE/DELETE instead.
|
|
102
136
|
*/
|
|
103
137
|
withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors?: boolean): T;
|
|
104
138
|
/**
|
|
@@ -111,12 +145,14 @@ export declare class ECDb implements Disposable {
|
|
|
111
145
|
* @returns the value returned by `callback`.
|
|
112
146
|
* @see [[withPreparedStatement]]
|
|
113
147
|
* @public
|
|
148
|
+
* @deprecated in 4.11. Use [[createQueryReader]] for SELECT statements and [[withWriteStatement]] for INSERT/UPDATE/DELETE instead.
|
|
114
149
|
*/
|
|
115
150
|
withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors?: boolean): T;
|
|
116
151
|
/** Prepare an ECSQL statement.
|
|
117
152
|
* @param ecsql The ECSQL statement to prepare
|
|
118
153
|
* @param logErrors Determines if error will be logged if statement fail to prepare
|
|
119
154
|
* @throws [IModelError]($common) if there is a problem preparing the statement.
|
|
155
|
+
* @deprecated in 4.11. Use [[prepareWriteStatement]] when preparing an INSERT/UPDATE/DELETE statement or [[createQueryReader]] to execute a SELECT statement.
|
|
120
156
|
*/
|
|
121
157
|
prepareStatement(ecsql: string, logErrors?: boolean): ECSqlStatement;
|
|
122
158
|
/**
|
package/lib/cjs/ECDb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECDb.d.ts","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAkB,aAAa,EAAE,WAAW,EAAe,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGxH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ECDb.d.ts","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAkB,aAAa,EAAE,WAAW,EAAe,WAAW,EAAE,YAAY,EAAE,MAAM,o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G;IACI,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,eAAe;IAM7E,gBAAgB;IAChB,IAAW,CAAC,SAAS,CAAC,IAAI,cAAc,CAAC,IAAI,CAG5C;IAED;;;;;;;;;;;SAWK;IACE,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW;CAWlG"}
|
package/lib/cjs/ECDb.js
CHANGED
|
@@ -32,6 +32,7 @@ var ECDbOpenMode;
|
|
|
32
32
|
*/
|
|
33
33
|
class ECDb {
|
|
34
34
|
_nativeDb;
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
35
36
|
_statementCache = new SqliteStatement_1.StatementCache();
|
|
36
37
|
_sqliteStatementCache = new SqliteStatement_1.StatementCache();
|
|
37
38
|
/** only for tests
|
|
@@ -160,6 +161,77 @@ class ECDb {
|
|
|
160
161
|
getSchemaProps(name) {
|
|
161
162
|
return this[Symbols_1._nativeDb].getSchemaProps(name);
|
|
162
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist
|
|
166
|
+
* in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved
|
|
167
|
+
* in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be
|
|
168
|
+
* reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding
|
|
169
|
+
* the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].
|
|
170
|
+
* @param sql The SQLite SQL statement to execute
|
|
171
|
+
* @param callback the callback to invoke on the prepared statement
|
|
172
|
+
* @param logErrors Determines if error will be logged if statement fail to prepare
|
|
173
|
+
* @returns the value returned by `callback`.
|
|
174
|
+
* @see [[withWriteStatement]]
|
|
175
|
+
* @beta
|
|
176
|
+
*/
|
|
177
|
+
withCachedWriteStatement(ecsql, callback, logErrors = true) {
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
179
|
+
const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);
|
|
180
|
+
const release = () => this._statementCache.addOrDispose(stmt);
|
|
181
|
+
try {
|
|
182
|
+
const val = callback(new ECSqlStatement_1.ECSqlWriteStatement(stmt));
|
|
183
|
+
if (val instanceof Promise) {
|
|
184
|
+
val.then(release, release);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
release();
|
|
188
|
+
}
|
|
189
|
+
return val;
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
release();
|
|
193
|
+
throw err;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.
|
|
198
|
+
* Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.
|
|
199
|
+
* For statements that will be reused often, instead use [[withPreparedStatement]].
|
|
200
|
+
* @param sql The SQLite SQL statement to execute
|
|
201
|
+
* @param callback the callback to invoke on the prepared statement
|
|
202
|
+
* @param logErrors Determines if error will be logged if statement fail to prepare
|
|
203
|
+
* @returns the value returned by `callback`.
|
|
204
|
+
* @see [[withCachedWriteStatement]]
|
|
205
|
+
* @beta
|
|
206
|
+
*/
|
|
207
|
+
withWriteStatement(ecsql, callback, logErrors = true) {
|
|
208
|
+
const stmt = this.prepareWriteStatement(ecsql, logErrors);
|
|
209
|
+
const release = () => { };
|
|
210
|
+
try {
|
|
211
|
+
const val = callback(stmt);
|
|
212
|
+
if (val instanceof Promise) {
|
|
213
|
+
val.then(release, release);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
release();
|
|
217
|
+
}
|
|
218
|
+
return val;
|
|
219
|
+
}
|
|
220
|
+
catch (err) {
|
|
221
|
+
release();
|
|
222
|
+
throw err;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/** Prepare an ECSQL statement.
|
|
226
|
+
* @param ecsql The ECSQL statement to prepare
|
|
227
|
+
* @param logErrors Determines if error will be logged if statement fail to prepare
|
|
228
|
+
* @throws [IModelError]($common) if there is a problem preparing the statement.
|
|
229
|
+
* @beta
|
|
230
|
+
*/
|
|
231
|
+
prepareWriteStatement(ecsql, logErrors = true) {
|
|
232
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
233
|
+
return new ECSqlStatement_1.ECSqlWriteStatement(this.prepareStatement(ecsql, logErrors));
|
|
234
|
+
}
|
|
163
235
|
/**
|
|
164
236
|
* Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist
|
|
165
237
|
* in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved
|
|
@@ -172,8 +244,11 @@ class ECDb {
|
|
|
172
244
|
* @returns the value returned by `callback`.
|
|
173
245
|
* @see [[withStatement]]
|
|
174
246
|
* @public
|
|
247
|
+
* @deprecated in 4.11. Use [[createQueryReader]] for SELECT statements and [[withCachedWriteStatement]] for INSERT/UPDATE/DELETE instead.
|
|
175
248
|
*/
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
176
250
|
withPreparedStatement(ecsql, callback, logErrors = true) {
|
|
251
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
177
252
|
const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);
|
|
178
253
|
const release = () => this._statementCache.addOrDispose(stmt);
|
|
179
254
|
try {
|
|
@@ -201,8 +276,11 @@ class ECDb {
|
|
|
201
276
|
* @returns the value returned by `callback`.
|
|
202
277
|
* @see [[withPreparedStatement]]
|
|
203
278
|
* @public
|
|
279
|
+
* @deprecated in 4.11. Use [[createQueryReader]] for SELECT statements and [[withWriteStatement]] for INSERT/UPDATE/DELETE instead.
|
|
204
280
|
*/
|
|
281
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
205
282
|
withStatement(ecsql, callback, logErrors = true) {
|
|
283
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
206
284
|
const stmt = this.prepareStatement(ecsql, logErrors);
|
|
207
285
|
const release = () => stmt[Symbol.dispose]();
|
|
208
286
|
try {
|
|
@@ -224,8 +302,11 @@ class ECDb {
|
|
|
224
302
|
* @param ecsql The ECSQL statement to prepare
|
|
225
303
|
* @param logErrors Determines if error will be logged if statement fail to prepare
|
|
226
304
|
* @throws [IModelError]($common) if there is a problem preparing the statement.
|
|
305
|
+
* @deprecated in 4.11. Use [[prepareWriteStatement]] when preparing an INSERT/UPDATE/DELETE statement or [[createQueryReader]] to execute a SELECT statement.
|
|
227
306
|
*/
|
|
307
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
228
308
|
prepareStatement(ecsql, logErrors = true) {
|
|
309
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
229
310
|
const stmt = new ECSqlStatement_1.ECSqlStatement();
|
|
230
311
|
stmt.prepare(this[Symbols_1._nativeDb], ecsql, logErrors);
|
|
231
312
|
return stmt;
|
package/lib/cjs/ECDb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECDb.js","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAyE;AAEzE,oDAAwH;AACxH,mEAAgE;AAChE,uDAAoD;AACpD,qDAAkD;AAClD,8DAAyD;AACzD,uDAAoE;AACpE,gDAA+C;AAE/C,MAAM,cAAc,GAAW,6CAAqB,CAAC,IAAI,CAAC;AAE1D;;GAEG;AACH,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uDAAQ,CAAA;IACR,yDAAS,CAAA;IACT,sGAAsG;IACtG,6DAAW,CAAA;AACb,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAED;;GAEG;AACH,MAAa,IAAI;IACP,SAAS,CAAuB;IACvB,eAAe,GAAG,IAAI,gCAAc,EAAkB,CAAC;IAChE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C;YACvE,CAAC;SACF,CAAC;QACF,OAAO,IAAI,yBAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;CACF;AAxTD,oBAwTC","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 ECDb\n */\nimport { assert, DbResult, Logger, OpenMode } from \"@itwin/core-bentley\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { DbQueryRequest, ECSchemaProps, ECSqlReader, IModelError, QueryBinder, QueryOptions } from \"@itwin/core-common\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\nimport { ECSqlStatement } from \"./ECSqlStatement\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\n\n/** Modes for how to open [ECDb]($backend) files.\n * @public\n */\nexport enum ECDbOpenMode {\n Readonly,\n ReadWrite,\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\n FileUpgrade,\n}\n\n/** An ECDb file\n * @public\n */\nexport class ECDb implements Disposable {\n private _nativeDb?: IModelJsNative.ECDb;\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\n\n /** only for tests\n * @internal\n */\n public resetSqliteCache(size: number) {\n this._sqliteStatementCache.clear();\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\n }\n\n constructor() {\n this._nativeDb = new IModelNative.platform.ECDb();\n }\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\n * ECDb object.\n */\n public [Symbol.dispose](): void {\n if (!this._nativeDb)\n return;\n\n this.closeDb();\n this._nativeDb.dispose();\n this._nativeDb = undefined;\n }\n /**\n * Attach an iModel file to this connection and load and register its schemas.\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\n * @param fileName IModel file name\n * @param alias identifier for the attached file. This identifer is used to access schema from the attached file. e.g. if alias is 'abc' then schema can be accessed using 'abc.MySchema.MyClass'\n */\n public attachDb(fileName: string, alias: string): void {\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\n }\n this[_nativeDb].attachDb(fileName, alias);\n }\n /**\n * Detach the attached file from this connection. The attached file is closed and its schemas are unregistered.\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\n * @param alias identifer that was used in the call to [[attachDb]]\n */\n public detachDb(alias: string): void {\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\n }\n this.clearStatementCache();\n this[_nativeDb].detachDb(alias);\n }\n\n /** @deprecated in 5.0 Use [Symbol.dispose] instead. */\n public dispose(): void {\n this[Symbol.dispose]();\n }\n\n /** Create an ECDb\n * @param pathName The path to the ECDb file to create.\n * @throws [IModelError]($common) if the operation failed.\n */\n public createDb(pathName: string): void {\n const status: DbResult = this[_nativeDb].createDb(pathName);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to created ECDb\");\n }\n\n /** Open the ECDb.\n * @param pathName The path to the ECDb file to open\n * @param openMode Open mode\n * @throws [IModelError]($common) if the operation failed.\n */\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\n const status: DbResult = this[_nativeDb].openDb(pathName, nativeOpenMode, tryUpgrade);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to open ECDb\");\n }\n\n /** Returns true if the ECDb is open */\n public get isOpen(): boolean { return this[_nativeDb].isOpen(); }\n\n /** Close the Db after saving any uncommitted changes.\n * @throws [IModelError]($common) if the database is not open.\n */\n public closeDb(): void {\n this._statementCache.clear();\n this._sqliteStatementCache.clear();\n this[_nativeDb].closeDb();\n }\n\n /** @internal use to test statement caching */\n public clearStatementCache() {\n this._statementCache.clear();\n }\n\n /** @internal use to test statement caching */\n public getCachedStatementCount() {\n return this._statementCache.size;\n }\n\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\n * @param changesetName The name of the operation that generated these changes.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public saveChanges(changesetName?: string): void {\n const status: DbResult = this[_nativeDb].saveChanges(changesetName);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to save changes\");\n }\n\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public abandonChanges(): void {\n const status: DbResult = this[_nativeDb].abandonChanges();\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to abandon changes\");\n }\n\n /** Import a schema.\n *\n * If the import was successful, the database is automatically saved to disk.\n * @param pathName Path to ECSchema XML file to import.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public importSchema(pathName: string): void {\n const status: DbResult = this[_nativeDb].importSchema(pathName);\n if (status !== DbResult.BE_SQLITE_OK) {\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\n }\n }\n\n /**\n * Returns the full schema for the input name.\n * @param name The name of the schema e.g. 'ECDbMeta'\n * @returns The SchemaProps for the requested schema\n * @throws if the schema can not be found or loaded.\n */\n public getSchemaProps(name: string): ECSchemaProps {\n return this[_nativeDb].getSchemaProps(name);\n }\n\n /**\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withStatement]]\n * @public\n */\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\n const release = () => this._statementCache.addOrDispose(stmt);\n try {\n const val = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withPreparedStatement]]\n * @public\n */\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\n const stmt = this.prepareStatement(ecsql, logErrors);\n const release = () => stmt[Symbol.dispose]();\n try {\n const val = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /** Prepare an ECSQL statement.\n * @param ecsql The ECSQL statement to prepare\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @throws [IModelError]($common) if there is a problem preparing the statement.\n */\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\n const stmt = new ECSqlStatement();\n stmt.prepare(this[_nativeDb], ecsql, logErrors);\n return stmt;\n }\n\n /**\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withPreparedStatement]]\n * @public\n */\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\n try {\n const val: T = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @public\n */\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\n const stmt = this.prepareSqliteStatement(sql, logErrors);\n const release = () => stmt[Symbol.dispose]();\n try {\n const val: T = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /** Prepare an SQL statement.\n * @param sql The SQLite SQL statement to prepare\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @throws [IModelError]($common) if there is a problem preparing the statement.\n * @internal\n */\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\n const stmt = new SqliteStatement(sql);\n stmt.prepare(this[_nativeDb], logErrors);\n return stmt;\n }\n\n /** @internal */\n public get [_nativeDb](): IModelJsNative.ECDb {\n assert(undefined !== this._nativeDb);\n return this._nativeDb;\n }\n\n /** Allow to execute query and read results along with meta data. The result are streamed.\n *\n * See also:\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\n *\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * @param config Allow to specify certain flags which control how query is executed.\n * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.\n * @public\n * */\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"db not open\");\n }\n const executor = {\n execute: async (request: DbQueryRequest) => {\n return ConcurrentQuery.executeQueryRequest(this[_nativeDb], request);\n },\n };\n return new ECSqlReader(executor, ecsql, params, config);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ECDb.js","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAyE;AAEzE,oDAAwH;AACxH,mEAAgE;AAChE,uDAAoD;AACpD,qDAAuE;AACvE,8DAAyD;AACzD,uDAAoE;AACpE,gDAA+C;AAE/C,MAAM,cAAc,GAAW,6CAAqB,CAAC,IAAI,CAAC;AAE1D;;GAEG;AACH,IAAY,YAKX;AALD,WAAY,YAAY;IAC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O,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB;IAChB,IAAW,CAAC,mBAAS,CAAC;QACpB,IAAA,qBAAM,EAAC,SAAS,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;;;;;;;;SAWK;IACE,iBAAiB,CAAC,KAAa,EAAE,MAAoB,EAAE,MAAqB;QACjF,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;YAChD,MAAM,IAAI,yBAAW,CAAC,uBAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,QAAQ,GAAG;YACf,OAAO,EAAE,KAAK,EAAE,OAAuB,EAAE,EAAE;gBACzC,OAAO,iCAAe,CAAC,mBAAmB,CAAC,IAAI,CAAC,mBAAS,CAAC,EAAE,OAAO,CAAC,CAAC;YACvE,CAAC;SACF,CAAC;QACF,OAAO,IAAI,yBAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;CACF;AAxYD,oBAwYC","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 ECDb\n */\nimport { assert, DbResult, Logger, OpenMode } from \"@itwin/core-bentley\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { DbQueryRequest, ECSchemaProps, ECSqlReader, IModelError, QueryBinder, QueryOptions } from \"@itwin/core-common\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\nimport { ECSqlStatement, ECSqlWriteStatement } from \"./ECSqlStatement\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\n\n/** Modes for how to open [ECDb]($backend) files.\n * @public\n */\nexport enum ECDbOpenMode {\n Readonly,\n ReadWrite,\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\n FileUpgrade,\n}\n\n/** An ECDb file\n * @public\n */\nexport class ECDb implements Disposable {\n private _nativeDb?: IModelJsNative.ECDb;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\n\n /** only for tests\n * @internal\n */\n public resetSqliteCache(size: number) {\n this._sqliteStatementCache.clear();\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\n }\n\n constructor() {\n this._nativeDb = new IModelNative.platform.ECDb();\n }\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\n * ECDb object.\n */\n public [Symbol.dispose](): void {\n if (!this._nativeDb)\n return;\n\n this.closeDb();\n this._nativeDb.dispose();\n this._nativeDb = undefined;\n }\n /**\n * Attach an iModel file to this connection and load and register its schemas.\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\n * @param fileName IModel file name\n * @param alias identifier for the attached file. This identifer is used to access schema from the attached file. e.g. if alias is 'abc' then schema can be accessed using 'abc.MySchema.MyClass'\n */\n public attachDb(fileName: string, alias: string): void {\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\n }\n this[_nativeDb].attachDb(fileName, alias);\n }\n /**\n * Detach the attached file from this connection. The attached file is closed and its schemas are unregistered.\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\n * @param alias identifer that was used in the call to [[attachDb]]\n */\n public detachDb(alias: string): void {\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\n }\n this.clearStatementCache();\n this[_nativeDb].detachDb(alias);\n }\n\n /** @deprecated in 5.0 Use [Symbol.dispose] instead. */\n public dispose(): void {\n this[Symbol.dispose]();\n }\n\n /** Create an ECDb\n * @param pathName The path to the ECDb file to create.\n * @throws [IModelError]($common) if the operation failed.\n */\n public createDb(pathName: string): void {\n const status: DbResult = this[_nativeDb].createDb(pathName);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to created ECDb\");\n }\n\n /** Open the ECDb.\n * @param pathName The path to the ECDb file to open\n * @param openMode Open mode\n * @throws [IModelError]($common) if the operation failed.\n */\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\n const status: DbResult = this[_nativeDb].openDb(pathName, nativeOpenMode, tryUpgrade);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to open ECDb\");\n }\n\n /** Returns true if the ECDb is open */\n public get isOpen(): boolean { return this[_nativeDb].isOpen(); }\n\n /** Close the Db after saving any uncommitted changes.\n * @throws [IModelError]($common) if the database is not open.\n */\n public closeDb(): void {\n this._statementCache.clear();\n this._sqliteStatementCache.clear();\n this[_nativeDb].closeDb();\n }\n\n /** @internal use to test statement caching */\n public clearStatementCache() {\n this._statementCache.clear();\n }\n\n /** @internal use to test statement caching */\n public getCachedStatementCount() {\n return this._statementCache.size;\n }\n\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\n * @param changesetName The name of the operation that generated these changes.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public saveChanges(changesetName?: string): void {\n const status: DbResult = this[_nativeDb].saveChanges(changesetName);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to save changes\");\n }\n\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public abandonChanges(): void {\n const status: DbResult = this[_nativeDb].abandonChanges();\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to abandon changes\");\n }\n\n /** Import a schema.\n *\n * If the import was successful, the database is automatically saved to disk.\n * @param pathName Path to ECSchema XML file to import.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public importSchema(pathName: string): void {\n const status: DbResult = this[_nativeDb].importSchema(pathName);\n if (status !== DbResult.BE_SQLITE_OK) {\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\n }\n }\n\n /**\n * Returns the full schema for the input name.\n * @param name The name of the schema e.g. 'ECDbMeta'\n * @returns The SchemaProps for the requested schema\n * @throws if the schema can not be found or loaded.\n */\n public getSchemaProps(name: string): ECSchemaProps {\n return this[_nativeDb].getSchemaProps(name);\n }\n\n /**\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withWriteStatement]]\n * @beta\n */\n public withCachedWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors = true): T {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\n const release = () => this._statementCache.addOrDispose(stmt);\n try {\n const val = callback(new ECSqlWriteStatement(stmt));\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withCachedWriteStatement]]\n * @beta\n */\n public withWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors = true): T {\n const stmt = this.prepareWriteStatement(ecsql, logErrors);\n const release = () => { };\n try {\n const val = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /** Prepare an ECSQL statement.\n * @param ecsql The ECSQL statement to prepare\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @throws [IModelError]($common) if there is a problem preparing the statement.\n * @beta\n */\n public prepareWriteStatement(ecsql: string, logErrors = true): ECSqlWriteStatement {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return new ECSqlWriteStatement(this.prepareStatement(ecsql, logErrors));\n }\n\n /**\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withStatement]]\n * @public\n * @deprecated in 4.11. Use [[createQueryReader]] for SELECT statements and [[withCachedWriteStatement]] for INSERT/UPDATE/DELETE instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\n const release = () => this._statementCache.addOrDispose(stmt);\n try {\n const val = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withPreparedStatement]]\n * @public\n * @deprecated in 4.11. Use [[createQueryReader]] for SELECT statements and [[withWriteStatement]] for INSERT/UPDATE/DELETE instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const stmt = this.prepareStatement(ecsql, logErrors);\n const release = () => stmt[Symbol.dispose]();\n try {\n const val = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /** Prepare an ECSQL statement.\n * @param ecsql The ECSQL statement to prepare\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @throws [IModelError]($common) if there is a problem preparing the statement.\n * @deprecated in 4.11. Use [[prepareWriteStatement]] when preparing an INSERT/UPDATE/DELETE statement or [[createQueryReader]] to execute a SELECT statement.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const stmt = new ECSqlStatement();\n stmt.prepare(this[_nativeDb], ecsql, logErrors);\n return stmt;\n }\n\n /**\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withPreparedStatement]]\n * @public\n */\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\n try {\n const val: T = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @public\n */\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\n const stmt = this.prepareSqliteStatement(sql, logErrors);\n const release = () => stmt[Symbol.dispose]();\n try {\n const val: T = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /** Prepare an SQL statement.\n * @param sql The SQLite SQL statement to prepare\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @throws [IModelError]($common) if there is a problem preparing the statement.\n * @internal\n */\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\n const stmt = new SqliteStatement(sql);\n stmt.prepare(this[_nativeDb], logErrors);\n return stmt;\n }\n\n /** @internal */\n public get [_nativeDb](): IModelJsNative.ECDb {\n assert(undefined !== this._nativeDb);\n return this._nativeDb;\n }\n\n /** Allow to execute query and read results along with meta data. The result are streamed.\n *\n * See also:\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\n *\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * @param config Allow to specify certain flags which control how query is executed.\n * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.\n * @public\n * */\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"db not open\");\n }\n const executor = {\n execute: async (request: DbQueryRequest) => {\n return ConcurrentQuery.executeQueryRequest(this[_nativeDb], request);\n },\n };\n return new ECSqlReader(executor, ecsql, params, config);\n }\n}\n"]}
|