@itwin/core-backend 5.0.0-dev.106 → 5.0.0-dev.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/lib/cjs/CatalogDb.d.ts +103 -0
  2. package/lib/cjs/CatalogDb.d.ts.map +1 -0
  3. package/lib/cjs/CatalogDb.js +271 -0
  4. package/lib/cjs/CatalogDb.js.map +1 -0
  5. package/lib/cjs/CloudSqlite.d.ts +104 -20
  6. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  7. package/lib/cjs/CloudSqlite.js +157 -46
  8. package/lib/cjs/CloudSqlite.js.map +1 -1
  9. package/lib/cjs/ECSchemaXmlContext.d.ts +1 -1
  10. package/lib/cjs/ECSchemaXmlContext.js +1 -1
  11. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  12. package/lib/cjs/Entity.d.ts +8 -4
  13. package/lib/cjs/Entity.d.ts.map +1 -1
  14. package/lib/cjs/Entity.js +3 -3
  15. package/lib/cjs/Entity.js.map +1 -1
  16. package/lib/cjs/IModelDb.d.ts +6 -1
  17. package/lib/cjs/IModelDb.d.ts.map +1 -1
  18. package/lib/cjs/IModelDb.js +14 -7
  19. package/lib/cjs/IModelDb.js.map +1 -1
  20. package/lib/cjs/IModelHost.d.ts +1 -1
  21. package/lib/cjs/IModelHost.js +1 -1
  22. package/lib/cjs/IModelHost.js.map +1 -1
  23. package/lib/cjs/NativeHost.d.ts.map +1 -1
  24. package/lib/cjs/NativeHost.js +4 -1
  25. package/lib/cjs/NativeHost.js.map +1 -1
  26. package/lib/cjs/SQLiteDb.d.ts.map +1 -1
  27. package/lib/cjs/SQLiteDb.js +5 -4
  28. package/lib/cjs/SQLiteDb.js.map +1 -1
  29. package/lib/cjs/ViewStore.d.ts.map +1 -1
  30. package/lib/cjs/ViewStore.js +27 -27
  31. package/lib/cjs/ViewStore.js.map +1 -1
  32. package/lib/cjs/core-backend.d.ts +1 -0
  33. package/lib/cjs/core-backend.d.ts.map +1 -1
  34. package/lib/cjs/core-backend.js +1 -0
  35. package/lib/cjs/core-backend.js.map +1 -1
  36. package/lib/cjs/internal/ChannelAdmin.js +4 -4
  37. package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
  38. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts +2 -16
  39. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  40. package/lib/cjs/internal/workspace/WorkspaceImpl.js +35 -104
  41. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
  42. package/lib/cjs/workspace/Workspace.d.ts +6 -13
  43. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  44. package/lib/cjs/workspace/Workspace.js.map +1 -1
  45. package/lib/cjs/workspace/WorkspaceEditor.d.ts +2 -7
  46. package/lib/cjs/workspace/WorkspaceEditor.d.ts.map +1 -1
  47. package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
  48. package/lib/esm/CatalogDb.d.ts +103 -0
  49. package/lib/esm/CatalogDb.d.ts.map +1 -0
  50. package/lib/esm/CatalogDb.js +267 -0
  51. package/lib/esm/CatalogDb.js.map +1 -0
  52. package/lib/esm/CloudSqlite.d.ts +104 -20
  53. package/lib/esm/CloudSqlite.d.ts.map +1 -1
  54. package/lib/esm/CloudSqlite.js +157 -46
  55. package/lib/esm/CloudSqlite.js.map +1 -1
  56. package/lib/esm/ECSchemaXmlContext.d.ts +1 -1
  57. package/lib/esm/ECSchemaXmlContext.js +1 -1
  58. package/lib/esm/ECSchemaXmlContext.js.map +1 -1
  59. package/lib/esm/Entity.d.ts +8 -4
  60. package/lib/esm/Entity.d.ts.map +1 -1
  61. package/lib/esm/Entity.js +3 -3
  62. package/lib/esm/Entity.js.map +1 -1
  63. package/lib/esm/IModelDb.d.ts +6 -1
  64. package/lib/esm/IModelDb.d.ts.map +1 -1
  65. package/lib/esm/IModelDb.js +14 -7
  66. package/lib/esm/IModelDb.js.map +1 -1
  67. package/lib/esm/IModelHost.d.ts +1 -1
  68. package/lib/esm/IModelHost.js +1 -1
  69. package/lib/esm/IModelHost.js.map +1 -1
  70. package/lib/esm/NativeHost.d.ts.map +1 -1
  71. package/lib/esm/NativeHost.js +4 -1
  72. package/lib/esm/NativeHost.js.map +1 -1
  73. package/lib/esm/SQLiteDb.d.ts.map +1 -1
  74. package/lib/esm/SQLiteDb.js +5 -4
  75. package/lib/esm/SQLiteDb.js.map +1 -1
  76. package/lib/esm/ViewStore.d.ts.map +1 -1
  77. package/lib/esm/ViewStore.js +28 -28
  78. package/lib/esm/ViewStore.js.map +1 -1
  79. package/lib/esm/core-backend.d.ts +1 -0
  80. package/lib/esm/core-backend.d.ts.map +1 -1
  81. package/lib/esm/core-backend.js +1 -0
  82. package/lib/esm/core-backend.js.map +1 -1
  83. package/lib/esm/internal/ChannelAdmin.js +5 -5
  84. package/lib/esm/internal/ChannelAdmin.js.map +1 -1
  85. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts +2 -16
  86. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  87. package/lib/esm/internal/workspace/WorkspaceImpl.js +36 -100
  88. package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
  89. package/lib/esm/test/standalone/SnapshotDb.test.js +2 -2
  90. package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
  91. package/lib/esm/test/standalone/Workspace.test.js +4 -3
  92. package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
  93. package/lib/esm/workspace/Workspace.d.ts +6 -13
  94. package/lib/esm/workspace/Workspace.d.ts.map +1 -1
  95. package/lib/esm/workspace/Workspace.js.map +1 -1
  96. package/lib/esm/workspace/WorkspaceEditor.d.ts +2 -7
  97. package/lib/esm/workspace/WorkspaceEditor.d.ts.map +1 -1
  98. package/lib/esm/workspace/WorkspaceEditor.js.map +1 -1
  99. package/package.json +13 -13
@@ -1 +1 @@
1
- {"version":3,"file":"WorkspaceImpl.js","sourceRoot":"","sources":["../../../../src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IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IACxF,IAAI,CAAC,UAAU;QACb,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,OAAO,GAAG,UAAU,CAAC;IACrB,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,UAA+B;IACtE,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACjD,CAAC;AAED,kHAAkH;AAClH,SAAgB,uBAAuB,CAAC,MAAuB,EAAE,OAA4B;IAC3F,OAAO,GAAG,MAAM,IAAI,0BAA0B,CAAC,OAAO,CAAC,EAAE,CAAC;AAC5D,CAAC;AAEY,QAAA,yBAAyB,GAAsB,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAEzG,SAAS,yBAAyB,CAAC,GAAW,EAAE,SAAmD,EAAE,EAAgB;IACnH,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAyB,CAAC;IACrD,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;IAChB,MAAM,KAAK,CAAC;AACd,CAAC;AAED,SAAgB,0BAA0B,CAAC,GAAW,EAAE,MAA8B;IACpF,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAA0B,CAAC;IACtD,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC;IAC5B,MAAM,KAAK,CAAC;AACd,CAAC","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 Workspace\n */\n\nimport { createHash } from \"crypto\";\nimport * as fs from \"fs-extra\";\nimport { dirname, extname, join } from \"path\";\nimport * as semver from \"semver\";\nimport { AccessToken, assert, BeEvent, DbResult, Mutable, OpenMode } from \"@itwin/core-bentley\";\nimport { FilePropertyProps, IModelError, LocalDirName, LocalFileName } from \"@itwin/core-common\";\nimport { CloudSqlite } from \"../../CloudSqlite\";\nimport { IModelHost, KnownLocations } from \"../../IModelHost\";\nimport { IModelJsFs } from \"../../IModelJsFs\";\nimport { SQLiteDb } from \"../../SQLiteDb\";\nimport { SqliteStatement } from \"../../SqliteStatement\";\nimport { SettingName, Settings, SettingsContainer, SettingsDictionaryProps, SettingsPriority } from \"../../workspace/Settings\";\nimport type { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport {\n GetWorkspaceContainerArgs, Workspace, WorkspaceContainer, WorkspaceContainerId, WorkspaceContainerProps, WorkspaceDb, WorkspaceDbCloudProps,\n WorkspaceDbFullName, WorkspaceDbLoadError, WorkspaceDbLoadErrors, WorkspaceDbManifest, WorkspaceDbName, WorkspaceDbNameAndVersion, WorkspaceDbProps,\n WorkspaceDbQueryResourcesArgs, WorkspaceDbSettingsProps, WorkspaceDbVersion, WorkspaceOpts, WorkspaceResourceName, WorkspaceSettingNames,\n} from \"../../workspace/Workspace\";\nimport { CreateNewWorkspaceContainerArgs, CreateNewWorkspaceDbVersionArgs, EditableWorkspaceContainer, EditableWorkspaceDb, WorkspaceEditor } from \"../../workspace/WorkspaceEditor\";\nimport { WorkspaceSqliteDb } from \"./WorkspaceSqliteDb\";\nimport { SettingsImpl } from \"./SettingsImpl\";\nimport { _implementationProhibited, _nativeDb } from \"../Symbols\";\n\nfunction workspaceDbNameWithDefault(dbName?: WorkspaceDbName): WorkspaceDbName {\n return dbName ?? \"workspace-db\";\n}\n\n/** file extension for local WorkspaceDbs */\nexport const workspaceDbFileExt = \"itwin-workspace\";\n\ninterface WorkspaceCloudContainer extends CloudSqlite.CloudContainer {\n connectCount: number;\n sharedConnect(): boolean;\n sharedDisconnect(): void;\n}\n\ninterface WorkspaceCloudCache extends CloudSqlite.CloudCache {\n workspaceContainers: Map<string, WorkspaceCloudContainer>;\n}\n\nfunction makeWorkspaceCloudCache(arg: CloudSqlite.CreateCloudCacheArg): WorkspaceCloudCache {\n const cache = CloudSqlite.CloudCaches.getCache(arg) as WorkspaceCloudCache;\n if (undefined === cache.workspaceContainers) // if we just created this container, add the map.\n cache.workspaceContainers = new Map<string, WorkspaceCloudContainer>();\n return cache;\n}\n\nfunction getContainerFullId(props: WorkspaceContainerProps) {\n return `${props.baseUri}/${props.containerId}`;\n}\n\nfunction getWorkspaceCloudContainer(props: CloudSqlite.ContainerAccessProps, cache: WorkspaceCloudCache) {\n const id = getContainerFullId(props);\n let cloudContainer = cache.workspaceContainers.get(id);\n if (undefined !== cloudContainer)\n return cloudContainer;\n\n cloudContainer = CloudSqlite.createCloudContainer(props) as WorkspaceCloudContainer;\n cache.workspaceContainers.set(id, cloudContainer);\n cloudContainer.connectCount = 0;\n cloudContainer.sharedConnect = function (this: WorkspaceCloudContainer) {\n if (this.connectCount++ === 0) {\n this.connect(cache);\n return true;\n }\n\n return false;\n };\n\n cloudContainer.sharedDisconnect = function (this: WorkspaceCloudContainer) {\n if (--this.connectCount <= 0) {\n this.disconnect();\n cache.workspaceContainers.delete(id);\n this.connectCount = 0;\n }\n };\n\n return cloudContainer;\n}\n\nclass WorkspaceContainerImpl implements WorkspaceContainer {\n public readonly [_implementationProhibited] = undefined;\n public readonly workspace: WorkspaceImpl;\n public readonly filesDir: LocalDirName;\n public readonly id: WorkspaceContainerId;\n public readonly fromProps: WorkspaceContainerProps;\n private readonly _cloudContainer?: WorkspaceCloudContainer | undefined;\n\n public get cloudContainer(): WorkspaceCloudContainer | undefined {\n return this._cloudContainer;\n }\n\n protected _wsDbs = new Map<WorkspaceDbName, WorkspaceDb>();\n public get dirName() { return join(this.workspace.containerDir, this.id); }\n\n public constructor(workspace: WorkspaceImpl, props: WorkspaceContainerProps & { accessToken: AccessToken }) {\n validateWorkspaceContainerId(props.containerId);\n this.workspace = workspace;\n this.id = props.containerId;\n this.fromProps = props;\n\n if (props.baseUri !== \"\")\n this._cloudContainer = getWorkspaceCloudContainer(props, this.workspace.getCloudCache());\n\n workspace.addContainer(this);\n this.filesDir = join(this.dirName, \"Files\");\n\n const cloudContainer = this.cloudContainer;\n if (undefined === cloudContainer)\n return;\n\n // sharedConnect returns true if we just connected (if the container is shared, it may have already been connected)\n if (cloudContainer.sharedConnect() && false !== props.syncOnConnect) {\n try {\n cloudContainer.checkForChanges();\n } catch {\n // must be offline\n }\n }\n }\n\n public resolveDbFileName(props: WorkspaceDbProps): WorkspaceDbFullName {\n const cloudContainer = this.cloudContainer;\n if (undefined === cloudContainer)\n return join(this.dirName, `${props.dbName}.${workspaceDbFileExt}`); // local file, versions not allowed\n\n const dbName = workspaceDbNameWithDefault(props.dbName);\n const dbs = cloudContainer.queryDatabases(`${dbName}*`); // get all databases that start with dbName\n\n const versions = [];\n for (const db of dbs) {\n const thisDb = parseWorkspaceDbFileName(db);\n if (thisDb.dbName === dbName && \"string\" === typeof thisDb.version && thisDb.version.length > 0)\n versions.push(thisDb.version);\n }\n\n if (versions.length === 0)\n versions[0] = \"0.0.0\";\n\n const range = props.version ?? \"*\";\n try {\n const version = semver.maxSatisfying(versions, range, { loose: true, includePrerelease: props.includePrerelease });\n if (version)\n return `${dbName}:${version}`;\n } catch { }\n throwWorkspaceDbLoadError(`No version of '${dbName}' available for \"${range}\"`, props);\n }\n\n public addWorkspaceDb(toAdd: WorkspaceDb) {\n if (undefined !== this._wsDbs.get(toAdd.dbName))\n throw new Error(`workspaceDb '${toAdd.dbName}' already exists in workspace`);\n this._wsDbs.set(toAdd.dbName, toAdd);\n }\n\n public getWorkspaceDb(props?: WorkspaceDbProps): WorkspaceDb {\n return this._wsDbs.get(workspaceDbNameWithDefault(props?.dbName)) ?? new WorkspaceDbImpl(props ?? {}, this);\n }\n\n public closeWorkspaceDb(toDrop: WorkspaceDb) {\n const name = toDrop.dbName;\n const wsDb = this._wsDbs.get(name);\n if (wsDb === toDrop) {\n this._wsDbs.delete(name);\n wsDb.close();\n }\n }\n\n public close() {\n for (const [_name, db] of this._wsDbs)\n db.close();\n this._wsDbs.clear();\n this.cloudContainer?.sharedDisconnect();\n }\n}\n\n/** Implementation of WorkspaceDb */\nclass WorkspaceDbImpl implements WorkspaceDb {\n public readonly [_implementationProhibited] = undefined;\n public readonly sqliteDb = new WorkspaceSqliteDb();\n public readonly dbName: WorkspaceDbName;\n protected readonly _container: WorkspaceContainer;\n public readonly onClose = new BeEvent<() => void>();\n public readonly dbFileName: string;\n protected _manifest?: WorkspaceDbManifest;\n\n /** true if this WorkspaceDb is currently open */\n public get isOpen() { return this.sqliteDb.isOpen; }\n public get container(): WorkspaceContainer { return this._container; }\n public queryFileResource(rscName: WorkspaceResourceName): { localFileName: LocalFileName, info: IModelJsNative.EmbedFileQuery } | undefined {\n const info = this.sqliteDb[_nativeDb].queryEmbeddedFile(rscName);\n if (undefined === info)\n return undefined;\n\n // since resource names can contain illegal characters, path separators, etc., we make the local file name from its hash, in hex.\n let localFileName = join(this._container.filesDir, createHash(\"sha1\").update(this.dbFileName).update(rscName).digest(\"hex\"));\n if (info.fileExt !== \"\") // since some applications may expect to see the extension, append it here if it was supplied.\n localFileName = `${localFileName}.${info.fileExt}`;\n return { localFileName, info };\n }\n\n public constructor(props: WorkspaceDbProps, container: WorkspaceContainer) {\n this.dbName = workspaceDbNameWithDefault(props.dbName);\n validateWorkspaceDbName(this.dbName);\n this._container = container;\n this.dbFileName = container.resolveDbFileName(props);\n container.addWorkspaceDb(this);\n if (true === props.prefetch)\n this.prefetch();\n }\n\n public open() {\n this.sqliteDb.openDb(this.dbFileName, OpenMode.Readonly, this._container.cloudContainer);\n }\n\n public close() {\n if (this.isOpen) {\n this.onClose.raiseEvent();\n this.sqliteDb.closeDb();\n this._container.closeWorkspaceDb(this);\n }\n }\n public get version() {\n const cloudContainer = this.container.cloudContainer;\n if (undefined === cloudContainer)\n return \"1.0.0\"; // local file, no versioning. return default\n return parseWorkspaceDbFileName(this.dbFileName).version;\n }\n\n public get manifest(): WorkspaceDbManifest {\n return this._manifest ??= this.withOpenDb((db) => {\n const manifestJson = db[_nativeDb].queryFileProperty(workspaceManifestProperty, true) as string | undefined;\n return manifestJson ? JSON.parse(manifestJson) : { workspaceName: this.dbName };\n });\n }\n\n private withOpenDb<T>(operation: (db: WorkspaceSqliteDb) => T): T {\n const done = this.isOpen ? () => { } : (this.open(), () => this.close());\n try {\n return operation(this.sqliteDb);\n } finally {\n done();\n }\n }\n\n public getString(rscName: WorkspaceResourceName): string | undefined {\n return this.withOpenDb((db) => {\n return db.withSqliteStatement(\"SELECT value from strings WHERE id=?\", (stmt) => {\n stmt.bindString(1, rscName);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValueString(0) : undefined;\n });\n });\n }\n\n public getBlobReader(rscName: WorkspaceResourceName): SQLiteDb.BlobIO {\n return this.sqliteDb.withSqliteStatement(\"SELECT rowid from blobs WHERE id=?\", (stmt) => {\n stmt.bindString(1, rscName);\n const blobReader = SQLiteDb.createBlobIO();\n blobReader.open(this.sqliteDb[_nativeDb], { tableName: \"blobs\", columnName: \"value\", row: stmt.getValueInteger(0) });\n return blobReader;\n });\n }\n\n public getBlob(rscName: WorkspaceResourceName): Uint8Array | undefined {\n return this.withOpenDb((db) => {\n return db.withSqliteStatement(\"SELECT value from blobs WHERE id=?\", (stmt) => {\n stmt.bindString(1, rscName);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValueBlob(0) : undefined;\n });\n });\n }\n\n public getFile(rscName: WorkspaceResourceName, targetFileName?: LocalFileName): LocalFileName | undefined {\n return this.withOpenDb((db) => {\n const file = this.queryFileResource(rscName);\n if (!file)\n return undefined;\n\n const info = file.info;\n const localFileName = targetFileName ?? file.localFileName;\n\n // check whether the file is already up to date.\n const stat = fs.existsSync(localFileName) && fs.statSync(localFileName);\n if (stat && Math.round(stat.mtimeMs) === info.date && stat.size === info.size)\n return localFileName; // yes, we're done\n\n // extractEmbeddedFile fails if the file exists or if the directory does not exist\n if (stat)\n fs.removeSync(localFileName);\n else\n IModelJsFs.recursiveMkDirSync(dirname(localFileName));\n\n db[_nativeDb].extractEmbeddedFile({ name: rscName, localFileName });\n const date = new Date(info.date);\n fs.utimesSync(localFileName, date, date); // set the last-modified date of the file to match date in container\n fs.chmodSync(localFileName, \"0444\"); // set file readonly\n return localFileName;\n });\n }\n\n public prefetch(opts?: CloudSqlite.PrefetchProps): CloudSqlite.CloudPrefetch {\n const cloudContainer = this._container.cloudContainer;\n if (cloudContainer === undefined)\n throw new Error(\"no cloud container to prefetch\");\n return CloudSqlite.startCloudPrefetch(cloudContainer, this.dbFileName, opts);\n }\n\n public queryResources(args: WorkspaceDbQueryResourcesArgs): void {\n const table = \"blob\" !== args.type ? \"strings\" : \"blobs\";\n this.withOpenDb((db) => {\n const where = undefined !== args.namePattern ? ` WHERE id ${args.nameCompare ?? \"=\"} ?` : \"\";\n db.withSqliteStatement(`SELECT id from ${table}${where}`, (stmt) => {\n function* makeIterable() {\n while (DbResult.BE_SQLITE_ROW === stmt.step()) {\n yield stmt.getValueString(0);\n }\n }\n\n if (undefined !== args.namePattern) {\n stmt.bindString(1, args.namePattern);\n }\n\n args.callback(makeIterable());\n });\n });\n }\n}\n\n/** Implementation of Workspace */\nclass WorkspaceImpl implements Workspace {\n public readonly [_implementationProhibited] = undefined;\n private _containers = new Map<WorkspaceContainerId, WorkspaceContainerImpl>();\n public readonly containerDir: LocalDirName;\n public readonly settings: Settings;\n protected _cloudCache?: WorkspaceCloudCache;\n public getCloudCache(): WorkspaceCloudCache {\n return this._cloudCache ??= makeWorkspaceCloudCache({ cacheName: \"Workspace\", cacheSize: \"20G\" });\n }\n\n public constructor(settings: Settings, opts?: WorkspaceOpts) {\n this.settings = settings;\n this.containerDir = opts?.containerDir ?? join(IModelHost.cacheDir, \"Workspace\");\n let settingsFiles = opts?.settingsFiles;\n if (settingsFiles) {\n if (typeof settingsFiles === \"string\")\n settingsFiles = [settingsFiles];\n settingsFiles.forEach((file) => settings.addFile(file, SettingsPriority.application));\n }\n }\n\n public addContainer(toAdd: WorkspaceContainerImpl) {\n if (undefined !== this._containers.get(toAdd.id))\n throw new Error(\"container already exists in workspace\");\n this._containers.set(toAdd.id, toAdd);\n }\n\n public findContainer(containerId: WorkspaceContainerId) {\n return this._containers.get(containerId);\n }\n\n public getContainer(props: GetWorkspaceContainerArgs): WorkspaceContainer {\n return this.findContainer(props.containerId) ?? new WorkspaceContainerImpl(this, props);\n }\n\n public async getContainerAsync(props: WorkspaceContainerProps): Promise<WorkspaceContainer> {\n const accessToken = props.accessToken ?? ((props.baseUri === \"\") || props.isPublic) ? \"\" : await CloudSqlite.requestToken({ ...props, accessLevel: \"read\" });\n return this.getContainer({ ...props, accessToken });\n }\n\n public async getWorkspaceDb(props: WorkspaceDbCloudProps): Promise<WorkspaceDb> {\n let container: WorkspaceContainer | undefined = this.findContainer(props.containerId);\n if (undefined === container) {\n const accessToken = props.isPublic ? \"\" : await CloudSqlite.requestToken({ accessLevel: \"read\", ...props });\n container = new WorkspaceContainerImpl(this, { ...props, accessToken });\n }\n return container.getWorkspaceDb(props);\n }\n\n public async loadSettingsDictionary(props: WorkspaceDbSettingsProps | WorkspaceDbSettingsProps[], problems?: WorkspaceDbLoadError[]) {\n if (!Array.isArray(props))\n props = [props];\n\n for (const prop of props) {\n const db = await this.getWorkspaceDb(prop);\n db.open();\n try {\n const manifest = db.manifest;\n const dictProps: SettingsDictionaryProps = { name: prop.resourceName, workspaceDb: db, priority: prop.priority };\n // don't load if we already have this dictionary. Happens if the same WorkspaceDb is in more than one list\n if (undefined === this.settings.getDictionary(dictProps)) {\n const settingsJson = db.getString(prop.resourceName);\n if (undefined === settingsJson)\n throwWorkspaceDbLoadError(`could not load setting dictionary resource '${prop.resourceName}' from: '${manifest.workspaceName}'`, prop, db);\n\n db.close(); // don't leave this db open in case we're going to find another dictionary in it recursively.\n\n this.settings.addJson(dictProps, settingsJson);\n const dict = this.settings.getDictionary(dictProps);\n if (dict) {\n Workspace.onSettingsDictionaryLoadedFn({ dict, from: db });\n // if the dictionary we just loaded has a \"settingsWorkspaces\" entry, load them too, recursively\n const nested = dict.getSetting<WorkspaceDbSettingsProps[]>(WorkspaceSettingNames.settingsWorkspaces);\n if (nested !== undefined) {\n IModelHost.settingsSchemas.validateSetting<WorkspaceDbSettingsProps[]>(nested, WorkspaceSettingNames.settingsWorkspaces);\n await this.loadSettingsDictionary(nested, problems);\n }\n }\n }\n } catch (e) {\n db.close();\n problems?.push(e as WorkspaceDbLoadError);\n }\n }\n }\n\n public close() {\n this.settings.close();\n for (const [_id, container] of this._containers)\n container.close();\n this._containers.clear();\n }\n\n public resolveWorkspaceDbSetting(settingName: SettingName, filter?: Workspace.DbListFilter): WorkspaceDbCloudProps[] {\n const settingDef = IModelHost.settingsSchemas.settingDefs.get(settingName);\n const combine = settingDef?.combineArray === true;\n filter = filter ?? (() => true);\n const result: WorkspaceDbCloudProps[] = [];\n for (const entry of this.settings.getSettingEntries<WorkspaceDbCloudProps[]>(settingName)) {\n for (const dbProp of entry.value) {\n if (filter(dbProp, entry.dictionary)) {\n result.push(dbProp);\n }\n }\n\n if (!combine) {\n break;\n }\n }\n\n return result;\n }\n\n public async getWorkspaceDbs(args: Workspace.DbListOrSettingName & { filter?: Workspace.DbListFilter, problems?: WorkspaceDbLoadError[] }): Promise<WorkspaceDb[]> {\n const dbList = (args.settingName !== undefined) ? this.resolveWorkspaceDbSetting(args.settingName, args.filter) : args.dbs;\n const result: WorkspaceDb[] = [];\n const pushUnique = (wsDb: WorkspaceDb) => {\n for (const db of result) {\n // if we already have this db, skip it. The test below also has to consider that we create a separate WorkspaceDb object for the same\n // database from more than one Workspace (though then they must use a \"shared\" CloudContainer).\n if (db === wsDb || ((db.container.cloudContainer === wsDb.container.cloudContainer) && (db.dbFileName === wsDb.dbFileName)))\n return; // this db is redundant\n }\n result.push(wsDb);\n };\n\n for (const dbProps of dbList) {\n try {\n pushUnique(await this.getWorkspaceDb(dbProps));\n } catch (e) {\n const loadErr = e as WorkspaceDbLoadError;\n loadErr.wsDbProps = dbProps;\n args.problems?.push(loadErr);\n }\n }\n return result;\n }\n}\n\nconst workspaceEditorName = \"WorkspaceEditor\"; // name of the cache for the editor workspace\nclass EditorWorkspaceImpl extends WorkspaceImpl {\n public override getCloudCache(): WorkspaceCloudCache {\n return this._cloudCache ??= makeWorkspaceCloudCache({ cacheName: workspaceEditorName, cacheSize: \"20G\" });\n }\n}\n\nclass EditorImpl implements WorkspaceEditor {\n public readonly [_implementationProhibited] = undefined;\n public workspace = new EditorWorkspaceImpl(new SettingsImpl(), { containerDir: join(IModelHost.cacheDir, workspaceEditorName) });\n\n public async initializeContainer(args: CreateNewWorkspaceContainerArgs) {\n class CloudAccess extends CloudSqlite.DbAccess<WorkspaceSqliteDb> {\n protected static override _cacheName = workspaceEditorName;\n public static async initializeWorkspace(args: CreateNewWorkspaceContainerArgs) {\n const props = await this.createBlobContainer({ scope: args.scope, metadata: { ...args.metadata, containerType: \"workspace\" } });\n const dbFullName = makeWorkspaceDbFileName(workspaceDbNameWithDefault(args.dbName), \"0.0.0\");\n await super._initializeDb({ ...args, props, dbName: dbFullName, dbType: WorkspaceSqliteDb, blockSize: \"4M\" });\n return props;\n }\n }\n return CloudAccess.initializeWorkspace(args);\n }\n\n public async createNewCloudContainer(args: CreateNewWorkspaceContainerArgs): Promise<EditableWorkspaceContainer> {\n const cloudContainer = await this.initializeContainer(args);\n const userToken = await IModelHost.authorizationClient?.getAccessToken();\n const accessToken = await CloudSqlite.requestToken({ ...cloudContainer, accessLevel: \"write\", userToken });\n return this.getContainer({ accessToken, ...cloudContainer, writeable: true, description: args.metadata.description });\n }\n\n public getContainer(props: GetWorkspaceContainerArgs): EditableWorkspaceContainer {\n return this.workspace.findContainer(props.containerId) as EditableWorkspaceContainer | undefined ?? new EditorContainerImpl(this.workspace, props);\n }\n public async getContainerAsync(props: WorkspaceContainerProps): Promise<EditableWorkspaceContainer> {\n const accessToken = props.accessToken ?? (props.baseUri === \"\") ? \"\" : await CloudSqlite.requestToken({ ...props, accessLevel: \"write\" });\n return this.getContainer({ ...props, accessToken });\n }\n\n public close() {\n this.workspace.close();\n }\n}\n\ninterface EditCloudContainer extends WorkspaceCloudContainer {\n writeLockHeldBy?: string; // added by acquireWriteLock\n}\n\nclass EditorContainerImpl extends WorkspaceContainerImpl implements EditableWorkspaceContainer {\n public override get cloudContainer(): EditCloudContainer | undefined {\n return super.cloudContainer as EditCloudContainer | undefined;\n }\n\n public get cloudProps(): WorkspaceContainerProps | undefined {\n const cloudContainer = this.cloudContainer;\n if (undefined === cloudContainer)\n return undefined;\n return {\n baseUri: cloudContainer.baseUri,\n containerId: cloudContainer.containerId,\n storageType: cloudContainer.storageType as \"azure\" | \"google\",\n isPublic: cloudContainer.isPublic,\n };\n }\n\n public async createNewWorkspaceDbVersion(args: CreateNewWorkspaceDbVersionArgs): Promise<{ oldDb: WorkspaceDbNameAndVersion, newDb: WorkspaceDbNameAndVersion }> {\n const cloudContainer = this.cloudContainer;\n if (undefined === cloudContainer)\n throw new Error(\"versions require cloud containers\");\n\n const oldName = this.resolveDbFileName(args.fromProps ?? {});\n const oldDb = parseWorkspaceDbFileName(oldName);\n const newVersion = semver.inc(oldDb.version, args.versionType, args.identifier);\n if (!newVersion)\n throwWorkspaceDbLoadError(\"invalid version\", args.fromProps ?? {});\n\n const newName = makeWorkspaceDbFileName(oldDb.dbName, newVersion);\n await cloudContainer.copyDatabase(oldName, newName);\n // return the old and new db names and versions\n return { oldDb, newDb: { dbName: oldDb.dbName, version: newVersion } };\n }\n\n public override getWorkspaceDb(props: WorkspaceDbProps): EditableWorkspaceDb {\n return this.getEditableDb(props);\n }\n\n public getEditableDb(props: WorkspaceDbProps): EditableWorkspaceDb {\n const db = this._wsDbs.get(workspaceDbNameWithDefault(props.dbName)) as EditableDbImpl | undefined ?? new EditableDbImpl(props, this);\n const isPrerelease = semver.major(db.version) === 0 || semver.prerelease(db.version);\n\n if (!isPrerelease && this.cloudContainer && this.cloudContainer.queryDatabase(db.dbFileName)?.state !== \"copied\") {\n this._wsDbs.delete(workspaceDbNameWithDefault(props.dbName));\n throw new Error(`${db.dbFileName} has been published and is not editable. Make a new version first.`);\n }\n\n return db;\n }\n\n public acquireWriteLock(user: string): void {\n if (this.cloudContainer) {\n this.cloudContainer.acquireWriteLock(user);\n this.cloudContainer.writeLockHeldBy = user;\n }\n }\n public releaseWriteLock() {\n if (this.cloudContainer) {\n this.cloudContainer.releaseWriteLock();\n this.cloudContainer.writeLockHeldBy = undefined;\n }\n }\n\n public abandonChanges() {\n if (this.cloudContainer) {\n this.cloudContainer.abandonChanges();\n this.cloudContainer.writeLockHeldBy = undefined;\n }\n }\n\n public async createDb(args: { dbName?: string, manifest: WorkspaceDbManifest }): Promise<EditableWorkspaceDb> {\n if (!this.cloudContainer) {\n WorkspaceEditor.createEmptyDb({ localFileName: this.resolveDbFileName(args), manifest: args.manifest });\n } else {\n // currently the only way to create a workspaceDb in a cloud container is to create a temporary workspaceDb and upload it.\n const tempDbFile = join(KnownLocations.tmpdir, `empty.${workspaceDbFileExt}`);\n if (fs.existsSync(tempDbFile))\n IModelJsFs.removeSync(tempDbFile);\n\n WorkspaceEditor.createEmptyDb({ localFileName: tempDbFile, manifest: args.manifest });\n await CloudSqlite.uploadDb(this.cloudContainer, { localFileName: tempDbFile, dbName: makeWorkspaceDbFileName(workspaceDbNameWithDefault(args.dbName)) });\n IModelJsFs.removeSync(tempDbFile);\n }\n\n return this.getWorkspaceDb(args);\n }\n}\n\nclass EditableDbImpl extends WorkspaceDbImpl implements EditableWorkspaceDb {\n public override get container(): EditableWorkspaceContainer {\n assert(this._container instanceof EditorContainerImpl);\n return this._container;\n }\n\n private static validateResourceName(name: WorkspaceResourceName) {\n if (name.trim() !== name) {\n throw new Error(\"resource name may not have leading or trailing spaces\");\n }\n\n if (name.length > 1024) {\n throw new Error(\"resource name too long\");\n }\n }\n\n private validateResourceSize(val: Uint8Array | string) {\n const len = typeof val === \"string\" ? val.length : val.byteLength;\n if (len > (1024 * 1024 * 1024)) // one gigabyte\n throw new Error(\"value is too large\");\n }\n public get cloudProps(): WorkspaceDbCloudProps | undefined {\n const props = (this._container as EditorContainerImpl).cloudProps as Mutable<WorkspaceDbCloudProps>;\n if (props === undefined)\n return undefined;\n\n const parsed = parseWorkspaceDbFileName(this.dbFileName);\n return { ...props, dbName: parsed.dbName, version: parsed.version };\n }\n\n public override open() {\n this.sqliteDb.openDb(this.dbFileName, OpenMode.ReadWrite, this._container.cloudContainer);\n }\n\n public override close() {\n if (this.isOpen) {\n // whenever we close an EditableDb, update the name of the last editor in the manifest\n const lastEditedBy = (this._container.cloudContainer as any)?.writeLockHeldBy;\n if (lastEditedBy !== undefined)\n this.updateManifest({ ...this.manifest, lastEditedBy });\n\n // make sure all changes were saved before we close\n this.sqliteDb.saveChanges();\n }\n super.close();\n }\n\n private getFileModifiedTime(localFileName: LocalFileName): number {\n return Math.round(fs.statSync(localFileName).mtimeMs);\n }\n\n private performWriteSql(rscName: WorkspaceResourceName, sql: string, bind?: (stmt: SqliteStatement) => void) {\n this.sqliteDb.withSqliteStatement(sql, (stmt) => {\n stmt.bindString(1, rscName);\n bind?.(stmt);\n const rc = stmt.step();\n if (DbResult.BE_SQLITE_DONE !== rc) {\n if (DbResult.BE_SQLITE_CONSTRAINT_PRIMARYKEY === rc)\n throw new IModelError(rc, `resource \"${rscName}\" already exists`);\n\n throw new IModelError(rc, `workspace [${sql}]`);\n }\n });\n this.sqliteDb.saveChanges();\n }\n\n public updateManifest(manifest: WorkspaceDbManifest) {\n this.sqliteDb[_nativeDb].saveFileProperty(workspaceManifestProperty, JSON.stringify(manifest));\n this._manifest = undefined;\n }\n public updateSettingsResource(settings: SettingsContainer, rscName?: string) {\n this.updateString(rscName ?? \"settingsDictionary\", JSON.stringify(settings));\n }\n public addString(rscName: WorkspaceResourceName, val: string): void {\n EditableDbImpl.validateResourceName(rscName);\n this.validateResourceSize(val);\n this.performWriteSql(rscName, \"INSERT INTO strings(id,value) VALUES(?,?)\", (stmt) => stmt.bindString(2, val));\n }\n public updateString(rscName: WorkspaceResourceName, val: string): void {\n this.validateResourceSize(val);\n this.performWriteSql(rscName, \"INSERT INTO strings(id,value) VALUES(?,?) ON CONFLICT(id) DO UPDATE SET value=excluded.value WHERE value!=excluded.value\", (stmt) => stmt.bindString(2, val));\n }\n public removeString(rscName: WorkspaceResourceName): void {\n this.performWriteSql(rscName, \"DELETE FROM strings WHERE id=?\");\n }\n public addBlob(rscName: WorkspaceResourceName, val: Uint8Array): void {\n EditableDbImpl.validateResourceName(rscName);\n this.validateResourceSize(val);\n this.performWriteSql(rscName, \"INSERT INTO blobs(id,value) VALUES(?,?)\", (stmt) => stmt.bindBlob(2, val));\n }\n public updateBlob(rscName: WorkspaceResourceName, val: Uint8Array): void {\n this.validateResourceSize(val);\n this.performWriteSql(rscName, \"INSERT INTO blobs(id,value) VALUES(?,?) ON CONFLICT(id) DO UPDATE SET value=excluded.value WHERE value!=excluded.value\", (stmt) => stmt.bindBlob(2, val));\n }\n public getBlobWriter(rscName: WorkspaceResourceName): SQLiteDb.BlobIO {\n return this.sqliteDb.withSqliteStatement(\"SELECT rowid from blobs WHERE id=?\", (stmt) => {\n stmt.bindString(1, rscName);\n const blobWriter = SQLiteDb.createBlobIO();\n blobWriter.open(this.sqliteDb[_nativeDb], { tableName: \"blobs\", columnName: \"value\", row: stmt.getValueInteger(0), writeable: true });\n return blobWriter;\n });\n }\n public removeBlob(rscName: WorkspaceResourceName): void {\n this.performWriteSql(rscName, \"DELETE FROM blobs WHERE id=?\");\n }\n public addFile(rscName: WorkspaceResourceName, localFileName: LocalFileName, fileExt?: string): void {\n EditableDbImpl.validateResourceName(rscName);\n fileExt = fileExt ?? extname(localFileName);\n if (fileExt?.[0] === \".\")\n fileExt = fileExt.slice(1);\n this.sqliteDb[_nativeDb].embedFile({ name: rscName, localFileName, date: this.getFileModifiedTime(localFileName), fileExt });\n }\n public updateFile(rscName: WorkspaceResourceName, localFileName: LocalFileName): void {\n this.queryFileResource(rscName); // throws if not present\n this.sqliteDb[_nativeDb].replaceEmbeddedFile({ name: rscName, localFileName, date: this.getFileModifiedTime(localFileName) });\n }\n public removeFile(rscName: WorkspaceResourceName): void {\n const file = this.queryFileResource(rscName);\n if (undefined === file)\n throw new Error(`file resource \"${rscName}\" does not exist`);\n if (file && fs.existsSync(file.localFileName))\n fs.unlinkSync(file.localFileName);\n this.sqliteDb[_nativeDb].removeEmbeddedFile(rscName);\n }\n}\n\nexport function constructWorkspaceDb(props: WorkspaceDbProps, container: WorkspaceContainer): WorkspaceDb {\n return new WorkspaceDbImpl(props, container);\n}\n\nexport function constructWorkspace(settings: Settings, opts?: WorkspaceOpts): OwnedWorkspace {\n return new WorkspaceImpl(settings, opts);\n}\n\nexport function constructWorkspaceEditor(): WorkspaceEditor {\n return new EditorImpl();\n}\n\nexport function noLeadingOrTrailingSpaces(name: string, msg: string) {\n if (name.trim() !== name)\n throw new Error(`${msg} [${name}] may not have leading or trailing spaces`);\n}\n\nexport function validateWorkspaceDbName(dbName: WorkspaceDbName) {\n if (dbName === \"\" || dbName.length > 255 || /[#\\.<>:\"/\\\\\"`'|?*\\u0000-\\u001F]/g.test(dbName) || /^(con|prn|aux|nul|com\\d|lpt\\d)$/i.test(dbName))\n throw new Error(`invalid dbName: [${dbName}]`);\n\n noLeadingOrTrailingSpaces(dbName, \"dbName\");\n}\n\n/**\n * Validate that a WorkspaceContainer.Id is valid.\n * The rules for ContainerIds (from Azure, see https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata):\n * - may only contain lower case letters, numbers or dashes\n * - may not start or end with with a dash nor have more than one dash in a row\n * - may not be shorter than 3 or longer than 63 characters\n */\nexport function validateWorkspaceContainerId(id: WorkspaceContainerId) {\n if (!/^(?=.{3,63}$)[a-z0-9]+(-[a-z0-9]+)*$/g.test(id))\n throw new Error(`invalid containerId: [${id}]`);\n}\n\nexport function validateWorkspaceDbVersion(version?: WorkspaceDbVersion) {\n version = version ?? \"0.0.0\";\n const opts = { loose: true, includePrerelease: true };\n // clean allows prerelease, so try it first. If that fails attempt to coerce it (coerce strips prerelease even if you say not to.)\n const semVersion = semver.clean(version, opts) ?? semver.coerce(version, opts)?.version;\n if (!semVersion)\n throw new Error(\"invalid version specification\");\n version = semVersion;\n return version;\n}\n\n/**\n * Parse the name stored in a WorkspaceContainer into the dbName and version number. A single WorkspaceContainer may hold\n * many versions of the same WorkspaceDb. The name of the Db in the WorkspaceContainer is in the format \"name:version\". This\n * function splits them into separate strings.\n */\nexport function parseWorkspaceDbFileName(dbFileName: WorkspaceDbFullName): { dbName: WorkspaceDbName, version: WorkspaceDbVersion } {\n const parts = dbFileName.split(\":\");\n return { dbName: parts[0], version: parts[1] };\n}\n\n/** Create a dbName for a WorkspaceDb from its base name and version. This will be in the format \"name:version\" */\nexport function makeWorkspaceDbFileName(dbName: WorkspaceDbName, version?: WorkspaceDbVersion): WorkspaceDbName {\n return `${dbName}:${validateWorkspaceDbVersion(version)}`;\n}\n\nexport const workspaceManifestProperty: FilePropertyProps = { namespace: \"workspace\", name: \"manifest\" };\n\nfunction throwWorkspaceDbLoadError(msg: string, wsDbProps: WorkspaceDbProps | WorkspaceDbCloudProps, db?: WorkspaceDb): never {\n const error = new Error(msg) as WorkspaceDbLoadError;\n error.wsDbProps = wsDbProps;\n error.wsDb = db;\n throw error;\n}\n\nexport function throwWorkspaceDbLoadErrors(msg: string, errors: WorkspaceDbLoadError[]): never {\n const error = new Error(msg) as WorkspaceDbLoadErrors;\n error.wsLoadErrors = errors;\n throw error;\n}\n\nexport interface OwnedWorkspace extends Workspace {\n /** Only the owner of a Workspace may close it. */\n close(): void;\n}\n"]}
1
+ {"version":3,"file":"Work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---------------------------------------------------------------------------------------------\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 Workspace\n */\n\nimport { createHash } from \"crypto\";\nimport * as fs from \"fs-extra\";\nimport { dirname, extname, join } from \"path\";\nimport { AccessToken, assert, BeEvent, DbResult, Mutable, OpenMode } from \"@itwin/core-bentley\";\nimport { CloudSqliteError, FilePropertyProps, LocalDirName, LocalFileName, WorkspaceError } from \"@itwin/core-common\";\nimport { CloudSqlite } from \"../../CloudSqlite\";\nimport { IModelHost, KnownLocations } from \"../../IModelHost\";\nimport { IModelJsFs } from \"../../IModelJsFs\";\nimport { SQLiteDb } from \"../../SQLiteDb\";\nimport { SqliteStatement } from \"../../SqliteStatement\";\nimport { SettingName, Settings, SettingsContainer, SettingsDictionaryProps, SettingsPriority } from \"../../workspace/Settings\";\nimport type { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport {\n GetWorkspaceContainerArgs, Workspace, WorkspaceContainer, WorkspaceContainerId, WorkspaceContainerProps, WorkspaceDb, WorkspaceDbCloudProps,\n WorkspaceDbFullName, WorkspaceDbLoadError, WorkspaceDbLoadErrors, WorkspaceDbManifest, WorkspaceDbName, WorkspaceDbNameAndVersion, WorkspaceDbProps,\n WorkspaceDbQueryResourcesArgs, WorkspaceDbSettingsProps, WorkspaceOpts, WorkspaceResourceName, WorkspaceSettingNames,\n} from \"../../workspace/Workspace\";\nimport { CreateNewWorkspaceContainerArgs, CreateNewWorkspaceDbVersionArgs, EditableWorkspaceContainer, EditableWorkspaceDb, WorkspaceEditor } from \"../../workspace/WorkspaceEditor\";\nimport { WorkspaceSqliteDb } from \"./WorkspaceSqliteDb\";\nimport { SettingsImpl } from \"./SettingsImpl\";\nimport { _implementationProhibited, _nativeDb } from \"../Symbols\";\n\nfunction workspaceDbNameWithDefault(dbName?: WorkspaceDbName): WorkspaceDbName {\n return dbName ?? \"workspace-db\";\n}\n\n/** file extension for local WorkspaceDbs */\nexport const workspaceDbFileExt = \"itwin-workspace\";\n\ninterface WorkspaceCloudContainer extends CloudSqlite.CloudContainer {\n connectCount: number;\n sharedConnect(): boolean;\n sharedDisconnect(): void;\n}\n\ninterface WorkspaceCloudCache extends CloudSqlite.CloudCache {\n workspaceContainers: Map<string, WorkspaceCloudContainer>;\n}\n\nfunction makeWorkspaceCloudCache(arg: CloudSqlite.CreateCloudCacheArg): WorkspaceCloudCache {\n const cache = CloudSqlite.CloudCaches.getCache(arg) as WorkspaceCloudCache;\n if (undefined === cache.workspaceContainers) // if we just created this container, add the map.\n CloudSqlite.addHiddenProperty(cache, \"workspaceContainers\", new Map<string, WorkspaceCloudContainer>());\n return cache;\n}\n\nfunction getContainerFullId(props: WorkspaceContainerProps) {\n return `${props.baseUri}/${props.containerId}`;\n}\n\nfunction getWorkspaceCloudContainer(props: CloudSqlite.ContainerAccessProps, cache: WorkspaceCloudCache) {\n const id = getContainerFullId(props);\n let cloudContainer = cache.workspaceContainers.get(id);\n if (undefined !== cloudContainer)\n return cloudContainer;\n\n cloudContainer = CloudSqlite.createCloudContainer(props) as WorkspaceCloudContainer;\n cache.workspaceContainers.set(id, cloudContainer);\n cloudContainer.connectCount = 0;\n CloudSqlite.addHiddenProperty(cloudContainer, \"sharedConnect\", function (this: WorkspaceCloudContainer) {\n if (this.connectCount++ === 0) {\n this.connect(cache);\n return true;\n }\n\n return false;\n });\n\n CloudSqlite.addHiddenProperty(cloudContainer, \"sharedDisconnect\", function (this: WorkspaceCloudContainer) {\n if (--this.connectCount <= 0) {\n this.disconnect();\n cache.workspaceContainers.delete(id);\n this.connectCount = 0;\n }\n });\n\n return cloudContainer;\n}\n\nclass WorkspaceContainerImpl implements WorkspaceContainer {\n public readonly [_implementationProhibited] = undefined;\n public readonly workspace: WorkspaceImpl;\n public readonly filesDir: LocalDirName;\n public readonly id: WorkspaceContainerId;\n public readonly fromProps: WorkspaceContainerProps;\n private readonly _cloudContainer?: WorkspaceCloudContainer | undefined;\n\n public get cloudContainer(): WorkspaceCloudContainer | undefined {\n return this._cloudContainer;\n }\n\n protected _wsDbs = new Map<WorkspaceDbName, WorkspaceDb>();\n public get dirName() { return join(this.workspace.containerDir, this.id); }\n\n public constructor(workspace: WorkspaceImpl, props: WorkspaceContainerProps & { accessToken: AccessToken }) {\n validateWorkspaceContainerId(props.containerId);\n this.workspace = workspace;\n this.id = props.containerId;\n this.fromProps = props;\n\n if (props.baseUri !== \"\")\n this._cloudContainer = getWorkspaceCloudContainer(props, this.workspace.getCloudCache());\n\n workspace.addContainer(this);\n this.filesDir = join(this.dirName, \"Files\");\n\n const cloudContainer = this.cloudContainer;\n if (undefined === cloudContainer)\n return;\n\n // sharedConnect returns true if we just connected (if the container is shared, it may have already been connected)\n if (cloudContainer.sharedConnect() && false !== props.syncOnConnect) {\n try {\n cloudContainer.checkForChanges();\n } catch {\n // must be offline\n }\n }\n }\n\n public resolveDbFileName(props: WorkspaceDbProps): WorkspaceDbFullName {\n const container = this.cloudContainer;\n if (undefined === container)\n return join(this.dirName, `${props.dbName}.${workspaceDbFileExt}`); // local file, versions not allowed\n\n return CloudSqlite.querySemverMatch({ ...props, container, dbName: workspaceDbNameWithDefault(props.dbName) });\n }\n\n public addWorkspaceDb(toAdd: WorkspaceDb) {\n if (undefined !== this._wsDbs.get(toAdd.dbName))\n WorkspaceError.throwError(\"already-exists\", { message: `workspaceDb '${toAdd.dbName}' already exists in workspace` });\n this._wsDbs.set(toAdd.dbName, toAdd);\n }\n\n public getWorkspaceDb(props?: WorkspaceDbProps): WorkspaceDb {\n return this._wsDbs.get(workspaceDbNameWithDefault(props?.dbName)) ?? new WorkspaceDbImpl(props ?? {}, this);\n }\n\n public closeWorkspaceDb(toDrop: WorkspaceDb) {\n const name = toDrop.dbName;\n const wsDb = this._wsDbs.get(name);\n if (wsDb === toDrop) {\n this._wsDbs.delete(name);\n wsDb.close();\n }\n }\n\n public close() {\n for (const [_name, db] of this._wsDbs)\n db.close();\n this._wsDbs.clear();\n this.cloudContainer?.sharedDisconnect();\n }\n}\n\n/** Implementation of WorkspaceDb */\nclass WorkspaceDbImpl implements WorkspaceDb {\n public readonly [_implementationProhibited] = undefined;\n public readonly sqliteDb = new WorkspaceSqliteDb();\n public readonly dbName: WorkspaceDbName;\n protected readonly _container: WorkspaceContainer;\n public readonly onClose = new BeEvent<() => void>();\n public readonly dbFileName: string;\n protected _manifest?: WorkspaceDbManifest;\n\n /** true if this WorkspaceDb is currently open */\n public get isOpen() { return this.sqliteDb.isOpen; }\n public get container(): WorkspaceContainer { return this._container; }\n public queryFileResource(rscName: WorkspaceResourceName): { localFileName: LocalFileName, info: IModelJsNative.EmbedFileQuery } | undefined {\n const info = this.sqliteDb[_nativeDb].queryEmbeddedFile(rscName);\n if (undefined === info)\n return undefined;\n\n // since resource names can contain illegal characters, path separators, etc., we make the local file name from its hash, in hex.\n let localFileName = join(this._container.filesDir, createHash(\"sha1\").update(this.dbFileName).update(rscName).digest(\"hex\"));\n if (info.fileExt !== \"\") // since some applications may expect to see the extension, append it here if it was supplied.\n localFileName = `${localFileName}.${info.fileExt}`;\n return { localFileName, info };\n }\n\n public constructor(props: WorkspaceDbProps, container: WorkspaceContainer) {\n this.dbName = workspaceDbNameWithDefault(props.dbName);\n CloudSqlite.validateDbName(this.dbName);\n this._container = container;\n this.dbFileName = container.resolveDbFileName(props);\n container.addWorkspaceDb(this);\n if (true === props.prefetch)\n this.prefetch();\n }\n\n public open() {\n this.sqliteDb.openDb(this.dbFileName, OpenMode.Readonly, this._container.cloudContainer);\n }\n\n public close() {\n if (this.isOpen) {\n this.onClose.raiseEvent();\n this.sqliteDb.closeDb();\n this._container.closeWorkspaceDb(this);\n }\n }\n public get version() {\n const cloudContainer = this.container.cloudContainer;\n if (undefined === cloudContainer)\n return \"1.0.0\"; // local file, no versioning. return default\n return CloudSqlite.parseDbFileName(this.dbFileName).version;\n }\n\n public get manifest(): WorkspaceDbManifest {\n return this._manifest ??= this.withOpenDb((db) => {\n const manifestJson = db[_nativeDb].queryFileProperty(workspaceManifestProperty, true) as string | undefined;\n return manifestJson ? JSON.parse(manifestJson) : { workspaceName: this.dbName };\n });\n }\n\n private withOpenDb<T>(operation: (db: WorkspaceSqliteDb) => T): T {\n const done = this.isOpen ? () => { } : (this.open(), () => this.close());\n try {\n return operation(this.sqliteDb);\n } finally {\n done();\n }\n }\n\n public getString(rscName: WorkspaceResourceName): string | undefined {\n return this.withOpenDb((db) => {\n return db.withSqliteStatement(\"SELECT value from strings WHERE id=?\", (stmt) => {\n stmt.bindString(1, rscName);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValueString(0) : undefined;\n });\n });\n }\n\n public getBlobReader(rscName: WorkspaceResourceName): SQLiteDb.BlobIO {\n return this.sqliteDb.withSqliteStatement(\"SELECT rowid from blobs WHERE id=?\", (stmt) => {\n stmt.bindString(1, rscName);\n const blobReader = SQLiteDb.createBlobIO();\n blobReader.open(this.sqliteDb[_nativeDb], { tableName: \"blobs\", columnName: \"value\", row: stmt.getValueInteger(0) });\n return blobReader;\n });\n }\n\n public getBlob(rscName: WorkspaceResourceName): Uint8Array | undefined {\n return this.withOpenDb((db) => {\n return db.withSqliteStatement(\"SELECT value from blobs WHERE id=?\", (stmt) => {\n stmt.bindString(1, rscName);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValueBlob(0) : undefined;\n });\n });\n }\n\n public getFile(rscName: WorkspaceResourceName, targetFileName?: LocalFileName): LocalFileName | undefined {\n return this.withOpenDb((db) => {\n const file = this.queryFileResource(rscName);\n if (!file)\n return undefined;\n\n const info = file.info;\n const localFileName = targetFileName ?? file.localFileName;\n\n // check whether the file is already up to date.\n const stat = fs.existsSync(localFileName) && fs.statSync(localFileName);\n if (stat && Math.round(stat.mtimeMs) === info.date && stat.size === info.size)\n return localFileName; // yes, we're done\n\n // extractEmbeddedFile fails if the file exists or if the directory does not exist\n if (stat)\n fs.removeSync(localFileName);\n else\n IModelJsFs.recursiveMkDirSync(dirname(localFileName));\n\n db[_nativeDb].extractEmbeddedFile({ name: rscName, localFileName });\n const date = new Date(info.date);\n fs.utimesSync(localFileName, date, date); // set the last-modified date of the file to match date in container\n fs.chmodSync(localFileName, \"0444\"); // set file readonly\n return localFileName;\n });\n }\n\n public prefetch(opts?: CloudSqlite.PrefetchProps): CloudSqlite.CloudPrefetch {\n const cloudContainer = this._container.cloudContainer;\n if (cloudContainer === undefined)\n WorkspaceError.throwError(\"no-cloud-container\", { message: \"no cloud container to prefetch\" });\n return CloudSqlite.startCloudPrefetch(cloudContainer, this.dbFileName, opts);\n }\n\n public queryResources(args: WorkspaceDbQueryResourcesArgs): void {\n const table = \"blob\" !== args.type ? \"strings\" : \"blobs\";\n this.withOpenDb((db) => {\n const where = undefined !== args.namePattern ? ` WHERE id ${args.nameCompare ?? \"=\"} ?` : \"\";\n db.withSqliteStatement(`SELECT id from ${table}${where}`, (stmt) => {\n function* makeIterable() {\n while (DbResult.BE_SQLITE_ROW === stmt.step()) {\n yield stmt.getValueString(0);\n }\n }\n\n if (undefined !== args.namePattern) {\n stmt.bindString(1, args.namePattern);\n }\n\n args.callback(makeIterable());\n });\n });\n }\n}\n\n/** Implementation of Workspace */\nclass WorkspaceImpl implements Workspace {\n public readonly [_implementationProhibited] = undefined;\n private _containers = new Map<WorkspaceContainerId, WorkspaceContainerImpl>();\n public readonly containerDir: LocalDirName;\n public readonly settings: Settings;\n protected _cloudCache?: WorkspaceCloudCache;\n public getCloudCache(): WorkspaceCloudCache {\n return this._cloudCache ??= makeWorkspaceCloudCache({ cacheName: \"Workspace\", cacheSize: \"20G\" });\n }\n\n public constructor(settings: Settings, opts?: WorkspaceOpts) {\n this.settings = settings;\n this.containerDir = opts?.containerDir ?? join(IModelHost.cacheDir, \"Workspace\");\n let settingsFiles = opts?.settingsFiles;\n if (settingsFiles) {\n if (typeof settingsFiles === \"string\")\n settingsFiles = [settingsFiles];\n settingsFiles.forEach((file) => settings.addFile(file, SettingsPriority.application));\n }\n }\n\n public addContainer(toAdd: WorkspaceContainerImpl) {\n if (undefined !== this._containers.get(toAdd.id))\n WorkspaceError.throwError(\"container-exists\", { message: `container ${toAdd.id} already exists in workspace` });\n this._containers.set(toAdd.id, toAdd);\n }\n\n public findContainer(containerId: WorkspaceContainerId) {\n return this._containers.get(containerId);\n }\n\n public getContainer(props: GetWorkspaceContainerArgs): WorkspaceContainer {\n return this.findContainer(props.containerId) ?? new WorkspaceContainerImpl(this, props);\n }\n\n public async getContainerAsync(props: WorkspaceContainerProps): Promise<WorkspaceContainer> {\n const accessToken = props.accessToken ?? ((props.baseUri === \"\") || props.isPublic) ? \"\" : await CloudSqlite.requestToken({ ...props, accessLevel: \"read\" });\n return this.getContainer({ ...props, accessToken });\n }\n\n public async getWorkspaceDb(props: WorkspaceDbCloudProps): Promise<WorkspaceDb> {\n let container: WorkspaceContainer | undefined = this.findContainer(props.containerId);\n if (undefined === container) {\n const accessToken = props.isPublic ? \"\" : await CloudSqlite.requestToken({ accessLevel: \"read\", ...props });\n container = new WorkspaceContainerImpl(this, { ...props, accessToken });\n }\n return container.getWorkspaceDb(props);\n }\n\n public async loadSettingsDictionary(props: WorkspaceDbSettingsProps | WorkspaceDbSettingsProps[], problems?: WorkspaceDbLoadError[]) {\n if (!Array.isArray(props))\n props = [props];\n\n for (const prop of props) {\n const db = await this.getWorkspaceDb(prop);\n db.open();\n try {\n const manifest = db.manifest;\n const dictProps: SettingsDictionaryProps = { name: prop.resourceName, workspaceDb: db, priority: prop.priority };\n // don't load if we already have this dictionary. Happens if the same WorkspaceDb is in more than one list\n if (undefined === this.settings.getDictionary(dictProps)) {\n const settingsJson = db.getString(prop.resourceName);\n if (undefined === settingsJson)\n throwWorkspaceDbLoadError(`could not load setting dictionary resource '${prop.resourceName}' from: '${manifest.workspaceName}'`, prop, db);\n\n db.close(); // don't leave this db open in case we're going to find another dictionary in it recursively.\n\n this.settings.addJson(dictProps, settingsJson);\n const dict = this.settings.getDictionary(dictProps);\n if (dict) {\n Workspace.onSettingsDictionaryLoadedFn({ dict, from: db });\n // if the dictionary we just loaded has a \"settingsWorkspaces\" entry, load them too, recursively\n const nested = dict.getSetting<WorkspaceDbSettingsProps[]>(WorkspaceSettingNames.settingsWorkspaces);\n if (nested !== undefined) {\n IModelHost.settingsSchemas.validateSetting<WorkspaceDbSettingsProps[]>(nested, WorkspaceSettingNames.settingsWorkspaces);\n await this.loadSettingsDictionary(nested, problems);\n }\n }\n }\n } catch (e) {\n db.close();\n problems?.push(e as WorkspaceDbLoadError);\n }\n }\n }\n\n public close() {\n this.settings.close();\n for (const [_id, container] of this._containers)\n container.close();\n this._containers.clear();\n }\n\n public resolveWorkspaceDbSetting(settingName: SettingName, filter?: Workspace.DbListFilter): WorkspaceDbCloudProps[] {\n const settingDef = IModelHost.settingsSchemas.settingDefs.get(settingName);\n const combine = settingDef?.combineArray === true;\n filter = filter ?? (() => true);\n const result: WorkspaceDbCloudProps[] = [];\n for (const entry of this.settings.getSettingEntries<WorkspaceDbCloudProps[]>(settingName)) {\n for (const dbProp of entry.value) {\n if (filter(dbProp, entry.dictionary)) {\n result.push(dbProp);\n }\n }\n\n if (!combine) {\n break;\n }\n }\n\n return result;\n }\n\n public async getWorkspaceDbs(args: Workspace.DbListOrSettingName & { filter?: Workspace.DbListFilter, problems?: WorkspaceDbLoadError[] }): Promise<WorkspaceDb[]> {\n const dbList = (args.settingName !== undefined) ? this.resolveWorkspaceDbSetting(args.settingName, args.filter) : args.dbs;\n const result: WorkspaceDb[] = [];\n const pushUnique = (wsDb: WorkspaceDb) => {\n for (const db of result) {\n // if we already have this db, skip it. The test below also has to consider that we create a separate WorkspaceDb object for the same\n // database from more than one Workspace (though then they must use a \"shared\" CloudContainer).\n if (db === wsDb || ((db.container.cloudContainer === wsDb.container.cloudContainer) && (db.dbFileName === wsDb.dbFileName)))\n return; // this db is redundant\n }\n result.push(wsDb);\n };\n\n for (const dbProps of dbList) {\n try {\n pushUnique(await this.getWorkspaceDb(dbProps));\n } catch (e) {\n const loadErr = e as WorkspaceDbLoadError;\n loadErr.wsDbProps = dbProps;\n args.problems?.push(loadErr);\n }\n }\n return result;\n }\n}\n\nconst workspaceEditorName = \"WorkspaceEditor\"; // name of the cache for the editor workspace\nclass EditorWorkspaceImpl extends WorkspaceImpl {\n public override getCloudCache(): WorkspaceCloudCache {\n return this._cloudCache ??= makeWorkspaceCloudCache({ cacheName: workspaceEditorName, cacheSize: \"20G\" });\n }\n}\n\nclass EditorImpl implements WorkspaceEditor {\n public readonly [_implementationProhibited] = undefined;\n public workspace = new EditorWorkspaceImpl(new SettingsImpl(), { containerDir: join(IModelHost.cacheDir, workspaceEditorName) });\n\n public async initializeContainer(args: CreateNewWorkspaceContainerArgs) {\n class CloudAccess extends CloudSqlite.DbAccess<WorkspaceSqliteDb> {\n protected static override _cacheName = workspaceEditorName;\n public static async initializeWorkspace(args: CreateNewWorkspaceContainerArgs) {\n const props = await this.createBlobContainer({ scope: args.scope, metadata: { ...args.metadata, containerType: \"workspace\" } });\n const dbFullName = CloudSqlite.makeSemverName(workspaceDbNameWithDefault(args.dbName), \"0.0.0\");\n await super._initializeDb({ ...args, props, dbName: dbFullName, dbType: WorkspaceSqliteDb, blockSize: \"4M\" });\n return props;\n }\n }\n return CloudAccess.initializeWorkspace(args);\n }\n\n public async createNewCloudContainer(args: CreateNewWorkspaceContainerArgs): Promise<EditableWorkspaceContainer> {\n const cloudContainer = await this.initializeContainer(args);\n const userToken = await IModelHost.authorizationClient?.getAccessToken();\n const accessToken = await CloudSqlite.requestToken({ ...cloudContainer, accessLevel: \"write\", userToken });\n return this.getContainer({ accessToken, ...cloudContainer, writeable: true, description: args.metadata.description });\n }\n\n public getContainer(props: GetWorkspaceContainerArgs): EditableWorkspaceContainer {\n return this.workspace.findContainer(props.containerId) as EditableWorkspaceContainer | undefined ?? new EditorContainerImpl(this.workspace, props);\n }\n public async getContainerAsync(props: WorkspaceContainerProps): Promise<EditableWorkspaceContainer> {\n const accessToken = props.accessToken ?? (props.baseUri === \"\") ? \"\" : await CloudSqlite.requestToken({ ...props, accessLevel: \"write\" });\n return this.getContainer({ ...props, accessToken });\n }\n\n public close() {\n this.workspace.close();\n }\n}\n\ninterface EditCloudContainer extends WorkspaceCloudContainer {\n writeLockHeldBy?: string; // added by acquireWriteLock\n}\n\nclass EditorContainerImpl extends WorkspaceContainerImpl implements EditableWorkspaceContainer {\n public override get cloudContainer(): EditCloudContainer | undefined {\n return super.cloudContainer as EditCloudContainer | undefined;\n }\n\n public get cloudProps(): WorkspaceContainerProps | undefined {\n const cloudContainer = this.cloudContainer;\n if (undefined === cloudContainer)\n return undefined;\n return {\n baseUri: cloudContainer.baseUri,\n containerId: cloudContainer.containerId,\n storageType: cloudContainer.storageType as \"azure\" | \"google\",\n isPublic: cloudContainer.isPublic,\n };\n }\n\n public async createNewWorkspaceDbVersion(args: CreateNewWorkspaceDbVersionArgs): Promise<{ oldDb: WorkspaceDbNameAndVersion, newDb: WorkspaceDbNameAndVersion }> {\n const container = this.cloudContainer;\n if (undefined === container)\n WorkspaceError.throwError(\"no-cloud-container\", { message: \"versions require cloud containers\" });\n\n const fromDb = { ...args.fromProps, dbName: workspaceDbNameWithDefault(args.fromProps?.dbName) };\n return CloudSqlite.createNewDbVersion(container, { ...args, fromDb });\n }\n\n public override getWorkspaceDb(props: WorkspaceDbProps): EditableWorkspaceDb {\n return this.getEditableDb(props);\n }\n\n public getEditableDb(props: WorkspaceDbProps): EditableWorkspaceDb {\n const db = this._wsDbs.get(workspaceDbNameWithDefault(props.dbName)) as EditableDbImpl | undefined ?? new EditableDbImpl(props, this);\n\n if (this.cloudContainer && !CloudSqlite.isSemverEditable(db.dbFileName, this.cloudContainer)) {\n this._wsDbs.delete(workspaceDbNameWithDefault(props.dbName));\n CloudSqliteError.throwError(\"already-published\", { message: `${db.dbFileName} has been published and is not editable. Make a new version first.` });\n }\n\n return db;\n }\n\n public acquireWriteLock(user: string): void {\n if (this.cloudContainer) {\n this.cloudContainer.acquireWriteLock(user);\n this.cloudContainer.writeLockHeldBy = user;\n }\n }\n public releaseWriteLock() {\n if (this.cloudContainer) {\n this.cloudContainer.releaseWriteLock();\n this.cloudContainer.writeLockHeldBy = undefined;\n }\n }\n\n public abandonChanges() {\n if (this.cloudContainer) {\n this.cloudContainer.abandonChanges();\n this.cloudContainer.writeLockHeldBy = undefined;\n }\n }\n\n public async createDb(args: { dbName?: string, manifest: WorkspaceDbManifest }): Promise<EditableWorkspaceDb> {\n if (!this.cloudContainer) {\n WorkspaceEditor.createEmptyDb({ localFileName: this.resolveDbFileName(args), manifest: args.manifest });\n } else {\n // currently the only way to create a workspaceDb in a cloud container is to create a temporary workspaceDb and upload it.\n const tempDbFile = join(KnownLocations.tmpdir, `empty.${workspaceDbFileExt}`);\n if (fs.existsSync(tempDbFile))\n IModelJsFs.removeSync(tempDbFile);\n\n WorkspaceEditor.createEmptyDb({ localFileName: tempDbFile, manifest: args.manifest });\n await CloudSqlite.uploadDb(this.cloudContainer, { localFileName: tempDbFile, dbName: CloudSqlite.makeSemverName(workspaceDbNameWithDefault(args.dbName)) });\n IModelJsFs.removeSync(tempDbFile);\n }\n\n return this.getWorkspaceDb(args);\n }\n}\n\nclass EditableDbImpl extends WorkspaceDbImpl implements EditableWorkspaceDb {\n public override get container(): EditableWorkspaceContainer {\n assert(this._container instanceof EditorContainerImpl);\n return this._container;\n }\n\n private static validateResourceName(name: WorkspaceResourceName) {\n if (name.trim() !== name)\n WorkspaceError.throwError(\"invalid-name\", { message: \"resource name may not have leading or trailing spaces\" });\n\n if (name.length > 1024) {\n WorkspaceError.throwError(\"invalid-name\", { message: \"resource name too long\" });\n }\n }\n\n private validateResourceSize(val: Uint8Array | string) {\n const len = typeof val === \"string\" ? val.length : val.byteLength;\n if (len > (1024 * 1024 * 1024)) // one gigabyte\n WorkspaceError.throwError(\"too-large\", { message: \"value is too large\" });\n }\n public get cloudProps(): WorkspaceDbCloudProps | undefined {\n const props = (this._container as EditorContainerImpl).cloudProps as Mutable<WorkspaceDbCloudProps>;\n if (props === undefined)\n return undefined;\n\n const parsed = CloudSqlite.parseDbFileName(this.dbFileName);\n return { ...props, dbName: parsed.dbName, version: parsed.version };\n }\n\n public override open() {\n this.sqliteDb.openDb(this.dbFileName, OpenMode.ReadWrite, this._container.cloudContainer);\n }\n\n public override close() {\n if (this.isOpen) {\n // whenever we close an EditableDb, update the name of the last editor in the manifest\n const lastEditedBy = (this._container.cloudContainer as any)?.writeLockHeldBy;\n if (lastEditedBy !== undefined)\n this.updateManifest({ ...this.manifest, lastEditedBy });\n\n // make sure all changes were saved before we close\n this.sqliteDb.saveChanges();\n }\n super.close();\n }\n\n private getFileModifiedTime(localFileName: LocalFileName): number {\n return Math.round(fs.statSync(localFileName).mtimeMs);\n }\n\n private performWriteSql(rscName: WorkspaceResourceName, sql: string, bind?: (stmt: SqliteStatement) => void) {\n this.sqliteDb.withSqliteStatement(sql, (stmt) => {\n stmt.bindString(1, rscName);\n bind?.(stmt);\n const rc = stmt.step();\n if (DbResult.BE_SQLITE_DONE !== rc) {\n if (DbResult.BE_SQLITE_CONSTRAINT_PRIMARYKEY === rc)\n WorkspaceError.throwError(\"resource-exists\", { message: `resource \"${rscName}\" already exists` });\n\n WorkspaceError.throwError(\"write-error\", { message: `workspace [${sql}], rc=${rc}` });\n }\n });\n this.sqliteDb.saveChanges();\n }\n\n public updateManifest(manifest: WorkspaceDbManifest) {\n this.sqliteDb[_nativeDb].saveFileProperty(workspaceManifestProperty, JSON.stringify(manifest));\n this._manifest = undefined;\n }\n public updateSettingsResource(settings: SettingsContainer, rscName?: string) {\n this.updateString(rscName ?? \"settingsDictionary\", JSON.stringify(settings));\n }\n public addString(rscName: WorkspaceResourceName, val: string): void {\n EditableDbImpl.validateResourceName(rscName);\n this.validateResourceSize(val);\n this.performWriteSql(rscName, \"INSERT INTO strings(id,value) VALUES(?,?)\", (stmt) => stmt.bindString(2, val));\n }\n public updateString(rscName: WorkspaceResourceName, val: string): void {\n this.validateResourceSize(val);\n this.performWriteSql(rscName, \"INSERT INTO strings(id,value) VALUES(?,?) ON CONFLICT(id) DO UPDATE SET value=excluded.value WHERE value!=excluded.value\", (stmt) => stmt.bindString(2, val));\n }\n public removeString(rscName: WorkspaceResourceName): void {\n this.performWriteSql(rscName, \"DELETE FROM strings WHERE id=?\");\n }\n public addBlob(rscName: WorkspaceResourceName, val: Uint8Array): void {\n EditableDbImpl.validateResourceName(rscName);\n this.validateResourceSize(val);\n this.performWriteSql(rscName, \"INSERT INTO blobs(id,value) VALUES(?,?)\", (stmt) => stmt.bindBlob(2, val));\n }\n public updateBlob(rscName: WorkspaceResourceName, val: Uint8Array): void {\n this.validateResourceSize(val);\n this.performWriteSql(rscName, \"INSERT INTO blobs(id,value) VALUES(?,?) ON CONFLICT(id) DO UPDATE SET value=excluded.value WHERE value!=excluded.value\", (stmt) => stmt.bindBlob(2, val));\n }\n public getBlobWriter(rscName: WorkspaceResourceName): SQLiteDb.BlobIO {\n return this.sqliteDb.withSqliteStatement(\"SELECT rowid from blobs WHERE id=?\", (stmt) => {\n stmt.bindString(1, rscName);\n const blobWriter = SQLiteDb.createBlobIO();\n blobWriter.open(this.sqliteDb[_nativeDb], { tableName: \"blobs\", columnName: \"value\", row: stmt.getValueInteger(0), writeable: true });\n return blobWriter;\n });\n }\n public removeBlob(rscName: WorkspaceResourceName): void {\n this.performWriteSql(rscName, \"DELETE FROM blobs WHERE id=?\");\n }\n public addFile(rscName: WorkspaceResourceName, localFileName: LocalFileName, fileExt?: string): void {\n EditableDbImpl.validateResourceName(rscName);\n fileExt = fileExt ?? extname(localFileName);\n if (fileExt?.[0] === \".\")\n fileExt = fileExt.slice(1);\n this.sqliteDb[_nativeDb].embedFile({ name: rscName, localFileName, date: this.getFileModifiedTime(localFileName), fileExt });\n }\n public updateFile(rscName: WorkspaceResourceName, localFileName: LocalFileName): void {\n this.queryFileResource(rscName); // throws if not present\n this.sqliteDb[_nativeDb].replaceEmbeddedFile({ name: rscName, localFileName, date: this.getFileModifiedTime(localFileName) });\n }\n public removeFile(rscName: WorkspaceResourceName): void {\n const file = this.queryFileResource(rscName);\n if (undefined === file)\n WorkspaceError.throwError(\"does-not-exist\", { message: `file resource \"${rscName}\" does not exist` });\n if (file && fs.existsSync(file.localFileName))\n fs.unlinkSync(file.localFileName);\n this.sqliteDb[_nativeDb].removeEmbeddedFile(rscName);\n }\n}\n\nexport function constructWorkspaceDb(props: WorkspaceDbProps, container: WorkspaceContainer): WorkspaceDb {\n return new WorkspaceDbImpl(props, container);\n}\n\nexport function constructWorkspace(settings: Settings, opts?: WorkspaceOpts): OwnedWorkspace {\n return new WorkspaceImpl(settings, opts);\n}\n\nexport function constructWorkspaceEditor(): WorkspaceEditor {\n return new EditorImpl();\n}\n\n/**\n * Validate that a WorkspaceContainer.Id is valid.\n * The rules for ContainerIds (from Azure, see https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata):\n * - may only contain lower case letters, numbers or dashes\n * - may not start or end with with a dash nor have more than one dash in a row\n * - may not be shorter than 3 or longer than 63 characters\n */\nexport function validateWorkspaceContainerId(id: WorkspaceContainerId) {\n if (!/^(?=.{3,63}$)[a-z0-9]+(-[a-z0-9]+)*$/g.test(id))\n WorkspaceError.throwError(\"invalid-name\", { message: `invalid containerId: [${id}]` });\n}\n\nexport const workspaceManifestProperty: FilePropertyProps = { namespace: \"workspace\", name: \"manifest\" };\n\n\nfunction throwWorkspaceDbLoadError(message: string, wsDbProps: WorkspaceDbProps | WorkspaceDbCloudProps, wsDb?: WorkspaceDb): never {\n WorkspaceError.throwError<WorkspaceDbLoadError>(\"load-error\", { message, wsDb, wsDbProps });\n}\n\nexport function throwWorkspaceDbLoadErrors(message: string, wsLoadErrors: WorkspaceDbLoadError[]): never {\n WorkspaceError.throwError<WorkspaceDbLoadErrors>(\"load-errors\", { message, wsLoadErrors });\n}\n\nexport interface OwnedWorkspace extends Workspace {\n /** Only the owner of a Workspace may close it. */\n close(): void;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /** @packageDocumentation
2
2
  * @module Workspace
3
3
  */
4
- import { AccessToken, BeEvent, Optional } from "@itwin/core-bentley";
4
+ import { AccessToken, BeEvent, ITwinError, Optional } from "@itwin/core-bentley";
5
5
  import { LocalDirName, LocalFileName } from "@itwin/core-common";
6
6
  import { CloudSqlite } from "../CloudSqlite";
7
7
  import { SQLiteDb } from "../SQLiteDb";
@@ -47,23 +47,16 @@ export type WorkspaceDbFullName = string;
47
47
  /** A [semver](https://github.com/npm/node-semver) string describing the version of a [[WorkspaceDb]], e.g., "4.2.11".
48
48
  * @beta
49
49
  */
50
- export type WorkspaceDbVersion = string;
50
+ export type WorkspaceDbVersion = CloudSqlite.DbVersion;
51
51
  /** A [semver string](https://github.com/npm/node-semver?tab=readme-ov-file#ranges) describing a range of acceptable [[WorkspaceDbVersion]]s,
52
52
  * e.g., ">=1.2.7 <1.3.0".
53
53
  * @beta
54
54
  */
55
- export type WorkspaceDbVersionRange = string;
55
+ export type WorkspaceDbVersionRange = CloudSqlite.DbVersionRange;
56
56
  /** Specifies the name and version of a [[WorkspaceDb]].
57
57
  * @beta
58
58
  */
59
- export interface WorkspaceDbNameAndVersion {
60
- /** The name of the [[WorkspaceDb]]. If omitted, it defaults to "workspace-db". */
61
- readonly dbName?: WorkspaceDbName;
62
- /** The range of acceptable versions of the [[WorkspaceDb]] of the specified [[dbName]].
63
- * If omitted, it defaults to the newest available version.
64
- */
65
- readonly version?: WorkspaceDbVersionRange;
66
- }
59
+ export type WorkspaceDbNameAndVersion = Optional<CloudSqlite.DbNameAndVersion, "dbName">;
67
60
  /** Properties that specify how to load a [[WorkspaceDb]] within a [[WorkspaceContainer]].
68
61
  * @beta
69
62
  */
@@ -126,7 +119,7 @@ export interface WorkspaceDbManifest {
126
119
  * is not authorized to access its [[WorkspaceContainer]].
127
120
  * @beta
128
121
  */
129
- export interface WorkspaceDbLoadError extends Error {
122
+ export interface WorkspaceDbLoadError extends ITwinError {
130
123
  /** The properties of the [[WorkspaceDb]] that was attempted to load, including the identity of its [[WorkspaceContainer]]. */
131
124
  wsDbProps?: WorkspaceDbProps & Partial<WorkspaceDbCloudProps>;
132
125
  /** The [[WorkspaceDb]] in which the error occurred, if available. */
@@ -137,7 +130,7 @@ export interface WorkspaceDbLoadError extends Error {
137
130
  * so that the user can be notified of the problems.
138
131
  * @beta
139
132
  */
140
- export interface WorkspaceDbLoadErrors extends Error {
133
+ export interface WorkspaceDbLoadErrors extends ITwinError {
141
134
  /** An array of problems that were encountered attempting to load [[WorkspaceDb]]s for an [[IModelDb]]. The most common problem
142
135
  * is that the user doesn't have read access to one or more [[WorkspaceContainer]]s used by the iModel's [[Workspace]]..
143
136
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Workspace.d.ts","sourceRoot":"","sources":["../../../src/workspace/Workspace.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAU,QAAQ,EAAoB,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,QAAQ,CAAC,WAAW,CAAC,oBAAoB,EAAE,aAAa,CAAC;IACxG;;OAEG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,+D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AAA;IAED;;;OAGG;IACH,SAAgB,cAAc,CAAC,IAAiC;QAC9D,MAAM,SAAS,GAA6C,EAAE,CAAC;QAC/D,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YAC1B,EAAE,CAAC,cAAc,CAAC;gBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;oBAClB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;wBACzB,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC/B,CAAC;gBACH,CAAC;aACF,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAhBe,wBAAc,iBAgB7B,CAAA;AACH,CAAC,EAtFgB,SAAS,yBAAT,SAAS,QAsFzB","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 Workspace\n */\n\nimport { AccessToken, BeEvent, Logger, Optional, UnexpectedErrors } from \"@itwin/core-bentley\";\nimport { LocalDirName, LocalFileName } from \"@itwin/core-common\";\nimport { CloudSqlite } from \"../CloudSqlite\";\nimport { SQLiteDb } from \"../SQLiteDb\";\nimport { SettingName, Settings, SettingsDictionary, SettingsPriority } from \"./Settings\";\nimport type { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { BackendLoggerCategory } from \"../BackendLoggerCategory\";\nimport { _implementationProhibited } from \"../internal/Symbols\";\n\n/** The unique identifier of a [[WorkspaceContainer]]. This becomes the base name for a local file directory holding the container's [[WorkspaceDb]]s.\n * A valid `WorkspaceContainerId` must conform to the following constraints:\n * - Consist solely of a combination of lower case letters, numbers, and dashes.\n * - May not start or end with a dash.\n * - Must be at least 3 characters long and no longer than 63 characters.\n * @beta\n */\nexport type WorkspaceContainerId = string;\n\n/** Properties describing a [[WorkspaceContainer]] for methods like [[Workspace.getContainerAsync]].\n * @beta\n */\nexport interface WorkspaceContainerProps extends Optional<CloudSqlite.ContainerAccessProps, \"accessToken\"> {\n /** Whether to synchronize the container via [[CloudSqlite.CloudContainer.checkForChanges]] whenever it is connected to a [[CloudSqlite.CloudCache]].\n * @note This property defaults to `true`.\n */\n readonly syncOnConnect?: boolean;\n /** A user-friendly description of the container's contents. */\n readonly description?: string;\n /** A message to display to the user if problems occur while loading the container. */\n readonly loadingHelp?: string;\n}\n\n/** The base name of a [[WorkspaceDb]], without any version information.\n * The name must conform to the following constraints:\n * - Case-insensitively unique among all [[WorkspaceDb]]s in the same [[WorkspaceContainer]].\n * - Between 1 and 255 characters in length.\n * - A legal filename on both [Windows](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions) and UNIX.\n * - Contain none of the following characters: forward or backward slash, period, single or double quote, backtick, and \"#\".\n * - Begin or end with a whitespace character.\n * @see [[WorkspaceDbFullName]] for the fully-specified name, including version information.\n * @beta\n */\nexport type WorkspaceDbName = string;\n\n/** The fully-specified name of a [[WorkspaceDb]], combining its [[WorkspaceDbName]] and [[WorkspaceDbVersion]] in the format \"name:version\".\n * @beta\n */\nexport type WorkspaceDbFullName = string;\n\n/** A [semver](https://github.com/npm/node-semver) string describing the version of a [[WorkspaceDb]], e.g., \"4.2.11\".\n * @beta\n */\nexport type WorkspaceDbVersion = string;\n\n/** A [semver string](https://github.com/npm/node-semver?tab=readme-ov-file#ranges) describing a range of acceptable [[WorkspaceDbVersion]]s,\n * e.g., \">=1.2.7 <1.3.0\".\n * @beta\n */\nexport type WorkspaceDbVersionRange = string;\n\n/** Specifies the name and version of a [[WorkspaceDb]].\n * @beta\n */\nexport interface WorkspaceDbNameAndVersion {\n /** The name of the [[WorkspaceDb]]. If omitted, it defaults to \"workspace-db\". */\n readonly dbName?: WorkspaceDbName;\n /** The range of acceptable versions of the [[WorkspaceDb]] of the specified [[dbName]].\n * If omitted, it defaults to the newest available version.\n */\n readonly version?: WorkspaceDbVersionRange;\n}\n\n/** Properties that specify how to load a [[WorkspaceDb]] within a [[WorkspaceContainer]].\n * @beta\n */\nexport interface WorkspaceDbProps extends WorkspaceDbNameAndVersion {\n /** If true, allow semver [prerelease versions](https://github.com/npm/node-semver?tab=readme-ov-file#prerelease-tags), e.g., \"1.4.2-beta.0\".\n * By default, only released version are allowed.\n */\n readonly includePrerelease?: boolean;\n /** If true, start a prefetch operation whenever this [[WorkspaceDb]] is opened, to begin downloading pages of the database before they are needed. */\n readonly prefetch?: boolean;\n}\n\n/** Properties describing a [[WorkspaceDb]] and the [[WorkspaceContainer]] containing it.\n * @beta\n */\nexport type WorkspaceDbCloudProps = WorkspaceDbProps & WorkspaceContainerProps;\n\n/** A function supplied as [[WorkspaceDbQueryResourcesArgs.callback]] to be invoked to process the requested resources.\n * @beta\n */\nexport type WorkspaceDbQueryResourcesCallback = (resourceNames: Iterable<string>) => void;\n\n/** Arguments supplied to [[WorkspaceDb.queryResources]].\n * @beta\n */\nexport interface WorkspaceDbQueryResourcesArgs {\n /** The type of resource to query. */\n type?: \"string\" | \"blob\";\n /** A pattern against which to compare the name of each resource, using [[nameCompare]] as the comparison operator.\n * Only resources whose names match the pattern will be included in the query results.\n */\n namePattern?: string;\n /** The comparison operator by which to compare the name of each resource to [[namePattern]].\n * Only resources whose names match the pattern will be included in the query results.\n * Ignored if [[namePattern]] is undefined.\n */\n nameCompare?: \"GLOB\" | \"LIKE\" | \"NOT GLOB\" | \"NOT LIKE\" | \"=\" | \"<\" | \">\";\n /** A function invoked to process the resources that match the query criterion. */\n callback: WorkspaceDbQueryResourcesCallback;\n}\n\n/** Metadata stored inside a [[WorkspaceDb]] describing the database's contents, to help users understand the purpose of the [[WorkspaceDb]], who to\n * contact with questions about it, and so on.\n * @note Only the [[workspaceName]] field is required, and users may add additional fields for their own purposes.\n * @note Since the information is stored inside of the [[WorkspaceDb]], it is versioned along with the rest of the contents.\n * @beta\n */\nexport interface WorkspaceDbManifest {\n /** The name of the [[WorkspaceDb]] to be shown in user interfaces. Organizations should attempt to make this name informative enough\n * so that uses may refer to this name in conversations. It should also be unique enough that there's no confusion when it appears in\n * lists of WorkspaceDbs.\n * @note it is possible and valid to change the workspaceName between new version of a WorkspaceDb (e.g. incorporating a date).\n */\n readonly workspaceName: string;\n /** A description of the contents of this [[WorkspaceDb]] to help users understand its purpose and appropriate usage. */\n readonly description?: string;\n /** The name of the person to contact with questions about this [[WorkspaceDb]]. */\n readonly contactName?: string;\n /** The name of the person who last modified this [[WorkspaceDb]]. */\n readonly lastEditedBy?: string;\n}\n\n/**\n * An exception thrown when attempting to load a [[WorkspaceDb]] or some of its data; for example, if the [[WorkspaceDb]] could not be found or the user\n * is not authorized to access its [[WorkspaceContainer]].\n * @beta\n */\nexport interface WorkspaceDbLoadError extends Error {\n /** The properties of the [[WorkspaceDb]] that was attempted to load, including the identity of its [[WorkspaceContainer]]. */\n wsDbProps?: WorkspaceDbProps & Partial<WorkspaceDbCloudProps>;\n /** The [[WorkspaceDb]] in which the error occurred, if available. */\n wsDb?: WorkspaceDb;\n}\n\n/** An exception that may occur while opening an [[IModelDb]] if any problems are detected while loading its [[IModelDb.workspace]].\n * This exception is never actually thrown; instead, after the iModel is opened, the exception is forwarded to [[Workspace.exceptionDiagnosticFn]]\n * so that the user can be notified of the problems.\n * @beta\n */\nexport interface WorkspaceDbLoadErrors extends Error {\n /** An array of problems that were encountered attempting to load [[WorkspaceDb]]s for an [[IModelDb]]. The most common problem\n * is that the user doesn't have read access to one or more [[WorkspaceContainer]]s used by the iModel's [[Workspace]]..\n */\n wsLoadErrors?: WorkspaceDbLoadError[];\n}\n\n/** Specifies a resource inside a [[WorkspaceDb]] that holds a [[SettingsDictionary]] to load into [[Workspace.settings]].\n * Settings of this type named [[WorkspaceSettingNames.settingsWorkspaces]] are automatically loaded by [[Workspace.loadSettingsDictionary]].\n * @beta\n */\nexport interface WorkspaceDbSettingsProps extends WorkspaceDbCloudProps {\n /** The name of the resource holding the stringified JSON of the [[SettingsDictionary]]. */\n resourceName: string;\n /** The priority to assign to the [[SettingsDictionary]]. */\n priority: SettingsPriority;\n}\n\n/** The name of a blob, string, or file resource stored in a [[WorkspaceDb]].\n * Resource names must conform to the following constraints:\n * - At least 1 character and no more than 1024 characters in length.\n * - No leading or trailing whitespace characters.\n * Each resource of a given type must has a unique name within the [[WorkspaceDb]]. It is technically possible, but discouraged, to define\n * resources with the same name but different types.\n * @beta\n */\nexport type WorkspaceResourceName = string;\n\n/** A SQLite database in a [[Workspace]] containing named resources that the application is configured to use.\n * Resources are referred to by their [[WorkspaceResourceName]]s and can represent any number of things, including:\n * - Fonts and [TextStyle]($common)s used when placing [TextAnnotation]($common)s.\n * - [GeographicCRS]($common)es used to define the coordinate reference system of an iTwin.\n * - [[SettingsDictionary]]'s that contribute to the [[Workspace.settings]].\n * - Files that can be extracted temporarily to the local file system to be accessed by programs directly from disk.\n *\n * Ultimately, each resource is stored in one of the following formats:\n * - A `string`, which is often a stringified `JSON` representation of the resource;\n * - A binary `blob`; or\n * - An embedded file.\n *\n * Strings and blobs can be accessed directly using [[getString]] and [[getBlob]]. Files must first be copied to the local file system using [[getFile]], and should be avoided unless the software\n * that uses them is written to access them from disk.\n *\n * A `WorkspaceDb` resides in a [[WorkspaceContainer]] that can be published to the cloud. Once published, the `WorkspaceDb` becomes immutable.\n * However, multiple versions of a single `WorkspaceDb` can be created, allowing the [[Workspace]] contents to evolve over time.\n * `WorkspaceDb`s use [semantic versioning](https://github.com/npm/node-semver).\n *\n * The set of available `WorkspaceDb`s available for use for specific purposes are defined in the [[Workspace]]'s [[Settings]]. You can obtain\n * a single `WorkspaceDb` using [[WorkspaceContainer.getWorkspaceDb]], but more commonly you will use [[Workspace.getWorkspaceDbs]] to obtain\n * a list of all of the `WorkspaceDb`s, sorted by priority, that correspond to a given [[SettingName]].\n *\n * You can create new `WorkspaceDb`s (or new versions of existing `WorkspaceDb`s) using [[WorkspaceEditor]].\n * @beta\n */\nexport interface WorkspaceDb {\n /** @internal */\n [_implementationProhibited]: unknown;\n /** The [[WorkspaceContainer]] in which this db resides. */\n readonly container: WorkspaceContainer;\n /** The base name of this WorkspaceDb, without version */\n readonly dbName: WorkspaceDbName;\n /** An event raised before this WorkspaceDb is [[close]]d. */\n readonly onClose: BeEvent<() => void>;\n /** The name by which the WorkspaceDb can be opened. This will be either a local file name or the name of a database in a [[CloudSqlite.CloudContainer]]. */\n readonly dbFileName: string;\n /** The underlying SQLite database that stores this WorkspaceDb's resources. */\n readonly sqliteDb: SQLiteDb;\n /** Whether the underlying [[sqliteDb]] is currently [[open]]ed. */\n readonly isOpen: boolean;\n /** The manifest that describes the contents and context of this WorkspaceDb. */\n readonly manifest: WorkspaceDbManifest;\n /** The version of this WorkspaceDb */\n readonly version: WorkspaceDbVersion;\n\n /** Open the underlying [[sqliteDb]] to perform a query. Generally WorkspaceDbs are left closed and opened/closed as they're used. However,\n * when there will be significant activity against a WorkspaceDb, it may be useful to open it before the operations and close it afterwards.\n * Methods like [[queryResources]] open the SQLite database automatically and [[close]] it before they return.\n */\n open(): void;\n\n /** Close the underlying [[sqliteDb]]. You should call this after [[open]]ing the database and completing your query. */\n close(): void;\n\n /** Look up a string resource by name, if one exists. */\n getString(rscName: WorkspaceResourceName): string | undefined;\n\n /** Look up a binary resource by name, if one exists. */\n getBlob(rscName: WorkspaceResourceName): Uint8Array | undefined;\n\n /** Get a BlobIO reader for a blob WorkspaceResource.\n * @note when finished, caller *must* call `close` on the BlobIO.\n * @internal\n */\n getBlobReader(rscName: WorkspaceResourceName): SQLiteDb.BlobIO;\n\n /**\n * Extract a local copy of a file resource from this WorkspaceDb, if present.\n * @param rscName The name of the file resource in the WorkspaceDb\n * @param targetFileName optional name for extracted file. Some applications require files in specific locations or filenames. If\n * you know the full path to use for the extracted file, you can supply it. Generally, it is best to *not* supply the filename and\n * keep the extracted files in the directory specified by [[WorkspaceContainer.filesDir]].\n * @returns the full path to a file on the local file system, or undefined if the no file named `rscName` exists.\n * @note The file is copied from the file into the local file system so it may be accessed directly. This happens only\n * as necessary, if the local file doesn't exist, or if it is out-of-date because it was updated in the file.\n * For this reason, you should not save the local file name, and instead call this method every time you access it, so its\n * content is always holds the correct version.\n * @note The filename will be a hash value, not the resource name.\n * @note Workspace resource files are set as read-only as they are copied from the file.\n * To edit them, you must first copy them to another location.\n */\n getFile(rscName: WorkspaceResourceName, targetFileName?: LocalFileName): LocalFileName | undefined;\n\n /**\n * Ensure that the contents of this `WorkspaceDb` are downloaded into the local cache so that it may be accessed offline.\n * Until the promise resolves, the `WorkspaceDb` is not fully downloaded, but it *may* be safely accessed during the download.\n * To determine the progress of the download, use the `localBlocks` and `totalBlocks` values returned by `CloudContainer.queryDatabase`.\n * @returns a [[CloudSqlite.CloudPrefetch]] object that can be used to await and/or cancel the prefetch.\n * @throws if this WorkspaceDb is not from a [[CloudSqlite.CloudContainer]].\n */\n prefetch(opts?: CloudSqlite.PrefetchProps): CloudSqlite.CloudPrefetch;\n\n /** Find resources of a particular type with names matching a specified pattern.\n * The matching resources will be supplied to [[WorkspaceDbQueryResourcesArgs.callbackk]].\n * @see [[Workspace.queryResources]] to query resources within multiple `WorkspaceDb`s.\n */\n queryResources(args: WorkspaceDbQueryResourcesArgs): void;\n\n /** @internal */\n queryFileResource(rscName: WorkspaceResourceName): { localFileName: LocalFileName, info: IModelJsNative.EmbedFileQuery } | undefined;\n}\n\n/** Options supplied to [[IModelHost.startup]] via [[IModelHostOptions.workspace]] to customize the initialization of [[IModelHost.appWorkspace]].\n * @beta\n */\nexport interface WorkspaceOpts {\n /** The local directory for non-cloud-based [[WorkspaceDb]] files. The [[Workspace]] API will look in this directory\n * for files named `${containerId}/${dbId}.itwin-workspace`.\n * @note if not supplied, defaults to \"iTwin/Workspace\" in the user-local folder.\n */\n containerDir?: LocalDirName;\n\n /** The name(s) of one or more local JSON files containing [[SettingsDictionary]]s to load when initializing the [[Workspace]]. */\n settingsFiles?: LocalFileName | LocalFileName[];\n}\n\n/** Arguments supplied to [[Workspace.getContainer]] and [[WorkspaceEditor.getContainer]].\n * @beta\n */\nexport interface GetWorkspaceContainerArgs extends WorkspaceContainerProps {\n /** Token required to access the container. */\n accessToken: AccessToken;\n}\n\n/**\n * Settings and resources that customize an application for the current session.\n * See the [learning article]($docs/learning/backend/Workspace) for a detailed overiew and examples.\n * @beta\n */\nexport interface Workspace {\n /** @internal */\n [_implementationProhibited]: unknown;\n\n /** The directory for local WorkspaceDb files with the name `${containerId}/${dbId}.itwin-workspace`.\n * @internal\n */\n readonly containerDir: LocalDirName;\n\n /** The current [[Settings]] for this Workspace */\n readonly settings: Settings;\n\n /** Get the cloud cache for cloud-based [[WorkspaceContainer]]s. */\n getCloudCache(): CloudSqlite.CloudCache;\n\n /** Search for a container previously opened by [[getContainer]] or [[getContainerAsync]].\n * @param containerId The id of the container\n * @returns the [[WorkspaceContainer]] for `containerId`, or `undefined` if no such container has been opened.\n * @internal\n */\n findContainer(containerId: WorkspaceContainerId): WorkspaceContainer | undefined;\n\n /** Obtain the [[WorkspaceContainer]] specified by `props`.\n * @param props The properties of the `WorkspaceContainer`, opening it if it is not already opened.\n * Otherwise it is created.\n * @note This function allows a `WorkspaceContainer.Props` without its [AccessToken]($bentley). It will attempt to obtain one from the [[BlobContainer]] service,\n * hence this function is async.\n * @see [[getContainer]] to obtain a container synchronously.\n */\n getContainerAsync(props: WorkspaceContainerProps): Promise<WorkspaceContainer>;\n\n /** Get a WorkspaceContainer with a supplied access token. This function is synchronous and may be used if:\n * - a valid [AccessToken]($bentley) is already available;\n * - the container has already been previously prefetched in another session (this is useful for offline usage); or\n * - the container is public and doesn't require an [AccessToken]($bentley).\n * @see [[getContainerAsync]] to obtain a container asynchronously if the above conditions do not apply.\n */\n getContainer(props: GetWorkspaceContainerArgs): WorkspaceContainer;\n\n /** Load a [[SettingsDictionary]] from the specified [[WorkspaceDb]] and add it to this workspace's current [[Settings]].\n * @note this function will load the dictionaries from the supplied list, and it will also call itself recursively for any entries in\n * the loaded Settings with the name [[WorkspaceSettingNames.settingsWorkspaces]]. In this manner, WorkspaceSettings may be \"chained\" together so that loading one\n * causes its \"dependent\" WorkspaceSettings to be loaded. Its `Promise` is resolved after all have been loaded (or failed to load).\n */\n loadSettingsDictionary(\n /** The properties of the [[WorkspaceDb]], plus the resourceName and [[SettingsPriority]]. May be either a single value or an array of them */\n props: WorkspaceDbSettingsProps | WorkspaceDbSettingsProps[],\n /** If present, an array that is populated with a list of problems while attempting to load the [[SettingsDictionary]](s). */\n problems?: WorkspaceDbLoadError[]\n ): Promise<void>;\n\n /** Get a single [[WorkspaceDb]]. */\n getWorkspaceDb(props: WorkspaceDbCloudProps): Promise<WorkspaceDb>;\n\n /**\n * Resolve the value of all [[Setting]]s from this workspace with the supplied `settingName` into an array of [[WorkspaceDbCloudProps]]\n * that can be used to query or load workspace resources. The settings must each be an array of type [[WorkspaceDbSettingsProps]].\n * The returned array will be sorted according to their [[SettingsPriority]], with the first entry being the highest priority [[WorkspaceDb]].\n * @note The list is built by combining, in order, all of the settings with the supplied [[SettingName]]. It may therefore include the\n * properties of same WorkspaceDb multiple times. This list is automatically de-duped by [[getWorkspaceDb]].\n * @note This function is rarely used directly. Usually it is called by [[getWorkspaceDbs]]. However, this function is synchronous and may sometimes\n * be useful for editors, tests, or diagnostics.\n */\n resolveWorkspaceDbSetting(\n /** the name of the setting. */\n settingName: SettingName,\n /** optional filter to choose specific WorkspaceDbs from the settings values. If present, only those WorkspaceDbs for which the filter returns `true` will be included. */\n filter?: Workspace.DbListFilter): WorkspaceDbCloudProps[];\n\n /**\n * Get a sorted array of [[WorkspaceDb]]s that can be used to query or load resources. If the arguments supply a `settingName`, this function will\n * use [[resolveWorkspaceDbSetting]] to get get the array of [[WorkspaceDbCloudProps]].\n * @returns A `Promise` resolving to an array of [[WorkspaceDb]]s sorted by [[SettingsPriority]] so that resources found in WorkspaceDbs earlier in the list take precedence\n * over ones with the same name in later WorkspaceDbs. No WorkspaceDb will appear more than once in the list.\n * @note this function may request an [AccessToken]($bentley) for each WorkspaceDb if necessary, and hence is asynchronous.\n */\n getWorkspaceDbs(\n args: Workspace.DbListOrSettingName & {\n /** if supplied, this array is populated with a list of problems (e.g. no read permission) attempting to load WorkspacesDbs. */\n problems?: WorkspaceDbLoadError[];\n /** only valid when called with a settingName, if so passed as `filter` argument to [[resolveWorkspaceDbSetting]] */\n filter?: Workspace.DbListFilter;\n }): Promise<WorkspaceDb[]>;\n}\n\n/**\n * A WorkspaceContainer is a type of [[CloudSqlite.CloudContainer]] that holds one or more [[WorkspaceDb]]s. Normally a WorkspaceContainer will hold (many versions of) a single WorkspaceDb.\n * Each version of a WorkspaceDb is treated as immutable after it is created and is stored in the WorkspaceContainer indefinitely. That means that\n * older versions of the WorkspaceDb may continue to be used, for example by archived projects. For programmers familiar with [NPM](https://www.npmjs.com/), this is conceptually\n * similar and versioning follows the same rules as NPM using [Semantic Versioning](https://semver.org/).\n * @note It is possible to store more than one WorkspaceDb in the same WorkspaceContainer, but access rights are administered per WorkspaceContainer.\n * That is, if a user has rights to access a WorkspaceContainer, that right applies to all WorkspaceDbs in the WorkspaceContainer.\n * @note Not every WorkspaceContainer is associated with a [[CloudSqlite.CloudContainer]] - WorkspaceContainers may also be loaded from the local file system.\n * In this case, [[cloudContainer]] will be `undefined`.\n * @see [[Workspace.getContainer]] and [[Workspace.getContainerAsync]] to load a container.\n * @beta\n */\nexport interface WorkspaceContainer {\n /** @internal */\n [_implementationProhibited]: unknown;\n /** the local directory where this WorkspaceContainer will store temporary files extracted for file-resources.\n * @internal\n */\n readonly filesDir: LocalDirName;\n /** The workspace into which this container was loaded. */\n readonly workspace: Workspace;\n /** Cloud container for this WorkspaceContainer, or `undefined` if this is a local WorkspaceContainer. */\n readonly cloudContainer?: CloudSqlite.CloudContainer;\n /** Properties supplied when this container was loaded */\n readonly fromProps: WorkspaceContainerProps;\n\n /** @internal */\n addWorkspaceDb(toAdd: WorkspaceDb): void;\n\n /**\n * Find the fully-qualified name of a [[WorkspaceDb]] satisfying the name and version criteria specified by `props`.\n * @throws Error if no version satisfying the criteria exists.\n */\n resolveDbFileName(props: WorkspaceDbProps): WorkspaceDbFullName;\n\n /** Obtain a [[WorkspaceDb]] satisfying the name and version criteria specified by `props`. */\n getWorkspaceDb(props?: WorkspaceDbProps): WorkspaceDb;\n\n /** Close and remove a currently opened [[WorkspaceDb]] from this Workspace.\n * @internal\n */\n closeWorkspaceDb(container: WorkspaceDb): void;\n}\n\nfunction makeSettingName(name: string) {\n return `${\"itwin/core/workspace\"}/${name}`;\n}\n\n/** The names of various [[Setting]]s with special meaning to the [[Workspace]] system.\n * @beta\n */\nexport namespace WorkspaceSettingNames {\n /** The name of a setting that, when present in a [[WorkspaceDb]] loaded by [[Workspace.loadSettingsDictionary]], will automatically\n * be used to find and load additional [[SettingsDictionary]]'s in other [[WorkspaceDb]]s. This permits you to chain the settings inside on [[WorkspaceDb]]\n * to others upon which they depend.\n * This setting's value is an array of [[WorkspaceDbSettingsProps]]s.\n */\n export const settingsWorkspaces = makeSettingName(\"settingsWorkspaces\");\n}\n\n/** A function supplied as part of a [[QueryWorkspaceResourcesArgs]] to iterate the resources retrieved by [[Workspace.queryResources]].\n * The `resources` object should only be used inside the function - it is an error to attempt to iterate it after the function returns.\n * @beta\n */\nexport type QueryWorkspaceResourcesCallback = (resources: Iterable<{ name: string, db: WorkspaceDb }>) => void;\n\n/** Arguments supplied to [[Workspace.queryResources]] defining the query criteria and the list of [[WorkspaceDb]]s to query.\n * @beta\n */\nexport interface QueryWorkspaceResourcesArgs {\n /** The list of `WorkspaceDb`s to query, in the order in which they are to be queried.\n * @see [[Workspace.resolveWorkspaceDbSetting]] or [[Workspace.getWorkspaceDbs]] to obtain an appropriate list of `WorkspaceDb`s.\n */\n dbs: WorkspaceDb[];\n /** The type of resource to query. */\n type?: \"string\" | \"blob\";\n /** A pattern against which to compare the name of each resource, using [[nameCompare]] as the comparison operator.\n * Only resources whose names match the pattern will be included in the query results.\n */\n namePattern?: string;\n /** The comparison operator by which to compare the name of each resource to [[namePattern]].\n * Only resources whose names match the pattern will be included in the query results.\n * Ignored i [[namePattern]] is undefined.\n */\n nameCompare?: \"GLOB\" | \"LIKE\" | \"NOT GLOB\" | \"NOT LIKE\" | \"=\" | \"<\" | \">\";\n /** A function invoked to process the resources that match the query criteria. */\n callback: QueryWorkspaceResourcesCallback;\n}\n\nfunction getWorkspaceResource(dbs: WorkspaceDb[], name: string, type: \"string\" | \"blob\"): string | Uint8Array | undefined {\n for (const db of dbs) {\n const val = type === \"blob\" ? db.getBlob(name) : db.getString(name);\n if (undefined !== val) {\n return val;\n }\n }\n\n return undefined;\n}\n\n/** Arguments supplied to [[Workspace.getStringResource]] and [[WOrkspace.getBlobResource]].\n * @beta\n */\nexport interface GetWorkspaceResourceArgs {\n /** The list of `WorkspaceDb`s to search, in the order in which they are to be searched.\n * @see [[Workspace.resolveWorkspaceDbSetting]] or [[Workspace.getWorkspaceDbs]] to obtain an appropriate list of `WorkspaceDb`s.\n */\n dbs: WorkspaceDb[];\n /** The name of the resource to find. */\n name: WorkspaceResourceName;\n}\n\n/** @beta */\nexport namespace Workspace {\n /** A function invoked to handle exceptions produced while loading workspace data.\n * Applications can override this function to notify the user and/or attempt to diagnose the problem.\n * The default implementation simply logs each exception.\n */\n export let exceptionDiagnosticFn = (e: WorkspaceDbLoadErrors) => { // eslint-disable-line prefer-const\n if (e instanceof Error)\n Logger.logException(BackendLoggerCategory.Workspace, e);\n else\n UnexpectedErrors.handle(e);\n };\n\n /** Arguments supplied to [[Workspace.onSettingsDictionaryLoadedFn]] for every [[SettingsDictionary]] that is loaded from a [[WorkspaceDb]]. */\n export interface SettingsDictionaryLoaded {\n /** The dictionary that was loaded */\n dict: SettingsDictionary;\n /** The WorkspaceDb from which the dictionary was loaded. */\n from: WorkspaceDb;\n }\n\n /** A function invoked each time any [[SettingsDictionary]] is loaded from a [[WorkspaceDb]].\n * Applications can override this function to notify the user and/or record diagnostics.\n * The default implementation simply records an information message in the [Logger]($bentley).\n */\n export let onSettingsDictionaryLoadedFn = (loaded: SettingsDictionaryLoaded) => { // eslint-disable-line prefer-const\n Logger.logInfo(BackendLoggerCategory.Workspace, `loaded setting dictionary ${loaded.dict.props.name} from ${loaded.from.dbFileName}`);\n };\n\n /** Either an array of [[WorkspaceDbCloudProps]] or the name of a [[Setting]] that resolves to an array of [[WorkspaceDbCloudProps]].\n * Used by [[Workspace.getWorkspaceDbs]].\n */\n export type DbListOrSettingName = { readonly dbs: WorkspaceDbCloudProps[], readonly settingName?: never } | { readonly settingName: SettingName, readonly dbs?: never };\n\n /** In arguments supplied to [[Workspace.getWorkspaceDbs]] and [[Workspace.resolveWorkspaceDbSetting]], an optional function used to exclude some\n * [[WorkspaceDb]]s. Only those [[WorkspaceDb]]s for which the function returns `true` will be included.\n */\n export type DbListFilter = (\n /** The properties of the WorkspaceDb to be returned */\n dbProp: WorkspaceDbCloudProps,\n /** The SettingsDictionary holding the [[WorkspaceSettingNames.settingsWorkspace]] setting. May be used, for example, to determine the\n * [[SettingsPriority]] of the dictionary.\n */\n dict: SettingsDictionary\n ) => boolean;\n\n /** Searches a list of [[WorkspaceDb]]s for a string resource of a given name.\n * The list is searched in order, and the first resource with the request name is returned.\n * If no such resource exists, the function returns `undefined`.\n * @see [[WorkspaceDb.getString]] if you only need to search a single `WorkspaceDb`.\n * @beta\n */\n export function getStringResource(args: GetWorkspaceResourceArgs): string | undefined {\n return getWorkspaceResource(args.dbs, args.name, \"string\") as string | undefined;\n }\n\n /** Searches a list of [[WorkspaceDb]]s for a blob resource of a given name.\n * The list is searched in order, and the first resource with the request name is returned.\n * If no such resource exists, the function returns `undefined`.\n * @see [[WorkspaceDb.getblob]] if you only need to search a single `WorkspaceDb`.\n * @beta\n */\n export function getBlobResource(args: GetWorkspaceResourceArgs): Uint8Array | undefined {\n return getWorkspaceResource(args.dbs, args.name, \"blob\") as Uint8Array | undefined;\n }\n\n /** Query a list of [[WorkspaceDb]]s to find resources of a particular type with names matching a specified pattern.\n * @see [[WorkspaceDb.queryResources]] if you only need to query a single `WorkspaceDb`.\n * @beta\n */\n export function queryResources(args: QueryWorkspaceResourcesArgs): void {\n const resources: Array<{ name: string, db: WorkspaceDb }> = [];\n for (const db of args.dbs) {\n db.queryResources({\n type: args.type,\n namePattern: args.namePattern,\n nameCompare: args.nameCompare,\n callback: (names) => {\n for (const name of names) {\n resources.push({ db, name });\n }\n },\n });\n }\n\n args.callback(resources);\n }\n}\n"]}
1
+ {"version":3,"file":"Workspace.js","sourceRoot":"","sources":["../../../src/workspace/Workspace.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2G;AAM3G,oEAAiE;AACjE,iDAAgE;AAwahE,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,GAAG,sBAAsB,IAAI,IAAI,EAAE,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,IAAiB,qBAAqB,CAOrC;AAPD,WAAiB,qBAAqB;IACpC;;;;OAIG;IACU,wCAAkB,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;AAC1E,CAAC,EAPgB,qBAAqB,qCAArB,qBAAqB,QAOrC;AA+BD,SAAS,oBAAoB,CAAC,GAAkB,EAAE,IAAY,EAAE,IAAuB;IACrF,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,GAAG,GAAG,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpE,IAAI,SAAS,KAAK,GAAG,EAAE,CAAC;YACtB,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IAED,OAAO,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AAQ,EAAE,CAAC,KAAK,EAAE,EAAE;oBAClB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;wBACzB,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC/B,CAAC;gBACH,CAAC;aACF,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAhBe,wBAAc,iBAgB7B,CAAA;AACH,CAAC,EAtFgB,SAAS,yBAAT,SAAS,QAsFzB","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 Workspace\n */\n\nimport { AccessToken, BeEvent, ITwinError, Logger, Optional, UnexpectedErrors } from \"@itwin/core-bentley\";\nimport { LocalDirName, LocalFileName } from \"@itwin/core-common\";\nimport { CloudSqlite } from \"../CloudSqlite\";\nimport { SQLiteDb } from \"../SQLiteDb\";\nimport { SettingName, Settings, SettingsDictionary, SettingsPriority } from \"./Settings\";\nimport type { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { BackendLoggerCategory } from \"../BackendLoggerCategory\";\nimport { _implementationProhibited } from \"../internal/Symbols\";\n\n/** The unique identifier of a [[WorkspaceContainer]]. This becomes the base name for a local file directory holding the container's [[WorkspaceDb]]s.\n * A valid `WorkspaceContainerId` must conform to the following constraints:\n * - Consist solely of a combination of lower case letters, numbers, and dashes.\n * - May not start or end with a dash.\n * - Must be at least 3 characters long and no longer than 63 characters.\n * @beta\n */\nexport type WorkspaceContainerId = string;\n\n/** Properties describing a [[WorkspaceContainer]] for methods like [[Workspace.getContainerAsync]].\n * @beta\n */\nexport interface WorkspaceContainerProps extends Optional<CloudSqlite.ContainerAccessProps, \"accessToken\"> {\n /** Whether to synchronize the container via [[CloudSqlite.CloudContainer.checkForChanges]] whenever it is connected to a [[CloudSqlite.CloudCache]].\n * @note This property defaults to `true`.\n */\n readonly syncOnConnect?: boolean;\n /** A user-friendly description of the container's contents. */\n readonly description?: string;\n /** A message to display to the user if problems occur while loading the container. */\n readonly loadingHelp?: string;\n}\n\n/** The base name of a [[WorkspaceDb]], without any version information.\n * The name must conform to the following constraints:\n * - Case-insensitively unique among all [[WorkspaceDb]]s in the same [[WorkspaceContainer]].\n * - Between 1 and 255 characters in length.\n * - A legal filename on both [Windows](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions) and UNIX.\n * - Contain none of the following characters: forward or backward slash, period, single or double quote, backtick, and \"#\".\n * - Begin or end with a whitespace character.\n * @see [[WorkspaceDbFullName]] for the fully-specified name, including version information.\n * @beta\n */\nexport type WorkspaceDbName = string;\n\n/** The fully-specified name of a [[WorkspaceDb]], combining its [[WorkspaceDbName]] and [[WorkspaceDbVersion]] in the format \"name:version\".\n * @beta\n */\nexport type WorkspaceDbFullName = string;\n\n/** A [semver](https://github.com/npm/node-semver) string describing the version of a [[WorkspaceDb]], e.g., \"4.2.11\".\n * @beta\n */\nexport type WorkspaceDbVersion = CloudSqlite.DbVersion;\n\n/** A [semver string](https://github.com/npm/node-semver?tab=readme-ov-file#ranges) describing a range of acceptable [[WorkspaceDbVersion]]s,\n * e.g., \">=1.2.7 <1.3.0\".\n * @beta\n */\nexport type WorkspaceDbVersionRange = CloudSqlite.DbVersionRange;\n\n/** Specifies the name and version of a [[WorkspaceDb]].\n * @beta\n */\nexport type WorkspaceDbNameAndVersion = Optional<CloudSqlite.DbNameAndVersion, \"dbName\">;\n\n/** Properties that specify how to load a [[WorkspaceDb]] within a [[WorkspaceContainer]].\n * @beta\n */\nexport interface WorkspaceDbProps extends WorkspaceDbNameAndVersion {\n /** If true, allow semver [prerelease versions](https://github.com/npm/node-semver?tab=readme-ov-file#prerelease-tags), e.g., \"1.4.2-beta.0\".\n * By default, only released version are allowed.\n */\n readonly includePrerelease?: boolean;\n /** If true, start a prefetch operation whenever this [[WorkspaceDb]] is opened, to begin downloading pages of the database before they are needed. */\n readonly prefetch?: boolean;\n}\n\n/** Properties describing a [[WorkspaceDb]] and the [[WorkspaceContainer]] containing it.\n * @beta\n */\nexport type WorkspaceDbCloudProps = WorkspaceDbProps & WorkspaceContainerProps;\n\n/** A function supplied as [[WorkspaceDbQueryResourcesArgs.callback]] to be invoked to process the requested resources.\n * @beta\n */\nexport type WorkspaceDbQueryResourcesCallback = (resourceNames: Iterable<string>) => void;\n\n/** Arguments supplied to [[WorkspaceDb.queryResources]].\n * @beta\n */\nexport interface WorkspaceDbQueryResourcesArgs {\n /** The type of resource to query. */\n type?: \"string\" | \"blob\";\n /** A pattern against which to compare the name of each resource, using [[nameCompare]] as the comparison operator.\n * Only resources whose names match the pattern will be included in the query results.\n */\n namePattern?: string;\n /** The comparison operator by which to compare the name of each resource to [[namePattern]].\n * Only resources whose names match the pattern will be included in the query results.\n * Ignored if [[namePattern]] is undefined.\n */\n nameCompare?: \"GLOB\" | \"LIKE\" | \"NOT GLOB\" | \"NOT LIKE\" | \"=\" | \"<\" | \">\";\n /** A function invoked to process the resources that match the query criterion. */\n callback: WorkspaceDbQueryResourcesCallback;\n}\n\n/** Metadata stored inside a [[WorkspaceDb]] describing the database's contents, to help users understand the purpose of the [[WorkspaceDb]], who to\n * contact with questions about it, and so on.\n * @note Only the [[workspaceName]] field is required, and users may add additional fields for their own purposes.\n * @note Since the information is stored inside of the [[WorkspaceDb]], it is versioned along with the rest of the contents.\n * @beta\n */\nexport interface WorkspaceDbManifest {\n /** The name of the [[WorkspaceDb]] to be shown in user interfaces. Organizations should attempt to make this name informative enough\n * so that uses may refer to this name in conversations. It should also be unique enough that there's no confusion when it appears in\n * lists of WorkspaceDbs.\n * @note it is possible and valid to change the workspaceName between new version of a WorkspaceDb (e.g. incorporating a date).\n */\n readonly workspaceName: string;\n /** A description of the contents of this [[WorkspaceDb]] to help users understand its purpose and appropriate usage. */\n readonly description?: string;\n /** The name of the person to contact with questions about this [[WorkspaceDb]]. */\n readonly contactName?: string;\n /** The name of the person who last modified this [[WorkspaceDb]]. */\n readonly lastEditedBy?: string;\n}\n\n/**\n * An exception thrown when attempting to load a [[WorkspaceDb]] or some of its data; for example, if the [[WorkspaceDb]] could not be found or the user\n * is not authorized to access its [[WorkspaceContainer]].\n * @beta\n */\nexport interface WorkspaceDbLoadError extends ITwinError {\n /** The properties of the [[WorkspaceDb]] that was attempted to load, including the identity of its [[WorkspaceContainer]]. */\n wsDbProps?: WorkspaceDbProps & Partial<WorkspaceDbCloudProps>;\n /** The [[WorkspaceDb]] in which the error occurred, if available. */\n wsDb?: WorkspaceDb;\n}\n\n/** An exception that may occur while opening an [[IModelDb]] if any problems are detected while loading its [[IModelDb.workspace]].\n * This exception is never actually thrown; instead, after the iModel is opened, the exception is forwarded to [[Workspace.exceptionDiagnosticFn]]\n * so that the user can be notified of the problems.\n * @beta\n */\nexport interface WorkspaceDbLoadErrors extends ITwinError {\n /** An array of problems that were encountered attempting to load [[WorkspaceDb]]s for an [[IModelDb]]. The most common problem\n * is that the user doesn't have read access to one or more [[WorkspaceContainer]]s used by the iModel's [[Workspace]]..\n */\n wsLoadErrors?: WorkspaceDbLoadError[];\n}\n\n/** Specifies a resource inside a [[WorkspaceDb]] that holds a [[SettingsDictionary]] to load into [[Workspace.settings]].\n * Settings of this type named [[WorkspaceSettingNames.settingsWorkspaces]] are automatically loaded by [[Workspace.loadSettingsDictionary]].\n * @beta\n */\nexport interface WorkspaceDbSettingsProps extends WorkspaceDbCloudProps {\n /** The name of the resource holding the stringified JSON of the [[SettingsDictionary]]. */\n resourceName: string;\n /** The priority to assign to the [[SettingsDictionary]]. */\n priority: SettingsPriority;\n}\n\n/** The name of a blob, string, or file resource stored in a [[WorkspaceDb]].\n * Resource names must conform to the following constraints:\n * - At least 1 character and no more than 1024 characters in length.\n * - No leading or trailing whitespace characters.\n * Each resource of a given type must has a unique name within the [[WorkspaceDb]]. It is technically possible, but discouraged, to define\n * resources with the same name but different types.\n * @beta\n */\nexport type WorkspaceResourceName = string;\n\n/** A SQLite database in a [[Workspace]] containing named resources that the application is configured to use.\n * Resources are referred to by their [[WorkspaceResourceName]]s and can represent any number of things, including:\n * - Fonts and [TextStyle]($common)s used when placing [TextAnnotation]($common)s.\n * - [GeographicCRS]($common)es used to define the coordinate reference system of an iTwin.\n * - [[SettingsDictionary]]'s that contribute to the [[Workspace.settings]].\n * - Files that can be extracted temporarily to the local file system to be accessed by programs directly from disk.\n *\n * Ultimately, each resource is stored in one of the following formats:\n * - A `string`, which is often a stringified `JSON` representation of the resource;\n * - A binary `blob`; or\n * - An embedded file.\n *\n * Strings and blobs can be accessed directly using [[getString]] and [[getBlob]]. Files must first be copied to the local file system using [[getFile]], and should be avoided unless the software\n * that uses them is written to access them from disk.\n *\n * A `WorkspaceDb` resides in a [[WorkspaceContainer]] that can be published to the cloud. Once published, the `WorkspaceDb` becomes immutable.\n * However, multiple versions of a single `WorkspaceDb` can be created, allowing the [[Workspace]] contents to evolve over time.\n * `WorkspaceDb`s use [semantic versioning](https://github.com/npm/node-semver).\n *\n * The set of available `WorkspaceDb`s available for use for specific purposes are defined in the [[Workspace]]'s [[Settings]]. You can obtain\n * a single `WorkspaceDb` using [[WorkspaceContainer.getWorkspaceDb]], but more commonly you will use [[Workspace.getWorkspaceDbs]] to obtain\n * a list of all of the `WorkspaceDb`s, sorted by priority, that correspond to a given [[SettingName]].\n *\n * You can create new `WorkspaceDb`s (or new versions of existing `WorkspaceDb`s) using [[WorkspaceEditor]].\n * @beta\n */\nexport interface WorkspaceDb {\n /** @internal */\n [_implementationProhibited]: unknown;\n /** The [[WorkspaceContainer]] in which this db resides. */\n readonly container: WorkspaceContainer;\n /** The base name of this WorkspaceDb, without version */\n readonly dbName: WorkspaceDbName;\n /** An event raised before this WorkspaceDb is [[close]]d. */\n readonly onClose: BeEvent<() => void>;\n /** The name by which the WorkspaceDb can be opened. This will be either a local file name or the name of a database in a [[CloudSqlite.CloudContainer]]. */\n readonly dbFileName: string;\n /** The underlying SQLite database that stores this WorkspaceDb's resources. */\n readonly sqliteDb: SQLiteDb;\n /** Whether the underlying [[sqliteDb]] is currently [[open]]ed. */\n readonly isOpen: boolean;\n /** The manifest that describes the contents and context of this WorkspaceDb. */\n readonly manifest: WorkspaceDbManifest;\n /** The version of this WorkspaceDb */\n readonly version: WorkspaceDbVersion;\n\n /** Open the underlying [[sqliteDb]] to perform a query. Generally WorkspaceDbs are left closed and opened/closed as they're used. However,\n * when there will be significant activity against a WorkspaceDb, it may be useful to open it before the operations and close it afterwards.\n * Methods like [[queryResources]] open the SQLite database automatically and [[close]] it before they return.\n */\n open(): void;\n\n /** Close the underlying [[sqliteDb]]. You should call this after [[open]]ing the database and completing your query. */\n close(): void;\n\n /** Look up a string resource by name, if one exists. */\n getString(rscName: WorkspaceResourceName): string | undefined;\n\n /** Look up a binary resource by name, if one exists. */\n getBlob(rscName: WorkspaceResourceName): Uint8Array | undefined;\n\n /** Get a BlobIO reader for a blob WorkspaceResource.\n * @note when finished, caller *must* call `close` on the BlobIO.\n * @internal\n */\n getBlobReader(rscName: WorkspaceResourceName): SQLiteDb.BlobIO;\n\n /**\n * Extract a local copy of a file resource from this WorkspaceDb, if present.\n * @param rscName The name of the file resource in the WorkspaceDb\n * @param targetFileName optional name for extracted file. Some applications require files in specific locations or filenames. If\n * you know the full path to use for the extracted file, you can supply it. Generally, it is best to *not* supply the filename and\n * keep the extracted files in the directory specified by [[WorkspaceContainer.filesDir]].\n * @returns the full path to a file on the local file system, or undefined if the no file named `rscName` exists.\n * @note The file is copied from the file into the local file system so it may be accessed directly. This happens only\n * as necessary, if the local file doesn't exist, or if it is out-of-date because it was updated in the file.\n * For this reason, you should not save the local file name, and instead call this method every time you access it, so its\n * content is always holds the correct version.\n * @note The filename will be a hash value, not the resource name.\n * @note Workspace resource files are set as read-only as they are copied from the file.\n * To edit them, you must first copy them to another location.\n */\n getFile(rscName: WorkspaceResourceName, targetFileName?: LocalFileName): LocalFileName | undefined;\n\n /**\n * Ensure that the contents of this `WorkspaceDb` are downloaded into the local cache so that it may be accessed offline.\n * Until the promise resolves, the `WorkspaceDb` is not fully downloaded, but it *may* be safely accessed during the download.\n * To determine the progress of the download, use the `localBlocks` and `totalBlocks` values returned by `CloudContainer.queryDatabase`.\n * @returns a [[CloudSqlite.CloudPrefetch]] object that can be used to await and/or cancel the prefetch.\n * @throws if this WorkspaceDb is not from a [[CloudSqlite.CloudContainer]].\n */\n prefetch(opts?: CloudSqlite.PrefetchProps): CloudSqlite.CloudPrefetch;\n\n /** Find resources of a particular type with names matching a specified pattern.\n * The matching resources will be supplied to [[WorkspaceDbQueryResourcesArgs.callbackk]].\n * @see [[Workspace.queryResources]] to query resources within multiple `WorkspaceDb`s.\n */\n queryResources(args: WorkspaceDbQueryResourcesArgs): void;\n\n /** @internal */\n queryFileResource(rscName: WorkspaceResourceName): { localFileName: LocalFileName, info: IModelJsNative.EmbedFileQuery } | undefined;\n}\n\n/** Options supplied to [[IModelHost.startup]] via [[IModelHostOptions.workspace]] to customize the initialization of [[IModelHost.appWorkspace]].\n * @beta\n */\nexport interface WorkspaceOpts {\n /** The local directory for non-cloud-based [[WorkspaceDb]] files. The [[Workspace]] API will look in this directory\n * for files named `${containerId}/${dbId}.itwin-workspace`.\n * @note if not supplied, defaults to \"iTwin/Workspace\" in the user-local folder.\n */\n containerDir?: LocalDirName;\n\n /** The name(s) of one or more local JSON files containing [[SettingsDictionary]]s to load when initializing the [[Workspace]]. */\n settingsFiles?: LocalFileName | LocalFileName[];\n}\n\n/** Arguments supplied to [[Workspace.getContainer]] and [[WorkspaceEditor.getContainer]].\n * @beta\n */\nexport interface GetWorkspaceContainerArgs extends WorkspaceContainerProps {\n /** Token required to access the container. */\n accessToken: AccessToken;\n}\n\n/**\n * Settings and resources that customize an application for the current session.\n * See the [learning article]($docs/learning/backend/Workspace) for a detailed overiew and examples.\n * @beta\n */\nexport interface Workspace {\n /** @internal */\n [_implementationProhibited]: unknown;\n\n /** The directory for local WorkspaceDb files with the name `${containerId}/${dbId}.itwin-workspace`.\n * @internal\n */\n readonly containerDir: LocalDirName;\n\n /** The current [[Settings]] for this Workspace */\n readonly settings: Settings;\n\n /** Get the cloud cache for cloud-based [[WorkspaceContainer]]s. */\n getCloudCache(): CloudSqlite.CloudCache;\n\n /** Search for a container previously opened by [[getContainer]] or [[getContainerAsync]].\n * @param containerId The id of the container\n * @returns the [[WorkspaceContainer]] for `containerId`, or `undefined` if no such container has been opened.\n * @internal\n */\n findContainer(containerId: WorkspaceContainerId): WorkspaceContainer | undefined;\n\n /** Obtain the [[WorkspaceContainer]] specified by `props`.\n * @param props The properties of the `WorkspaceContainer`, opening it if it is not already opened.\n * Otherwise it is created.\n * @note This function allows a `WorkspaceContainer.Props` without its [AccessToken]($bentley). It will attempt to obtain one from the [[BlobContainer]] service,\n * hence this function is async.\n * @see [[getContainer]] to obtain a container synchronously.\n */\n getContainerAsync(props: WorkspaceContainerProps): Promise<WorkspaceContainer>;\n\n /** Get a WorkspaceContainer with a supplied access token. This function is synchronous and may be used if:\n * - a valid [AccessToken]($bentley) is already available;\n * - the container has already been previously prefetched in another session (this is useful for offline usage); or\n * - the container is public and doesn't require an [AccessToken]($bentley).\n * @see [[getContainerAsync]] to obtain a container asynchronously if the above conditions do not apply.\n */\n getContainer(props: GetWorkspaceContainerArgs): WorkspaceContainer;\n\n /** Load a [[SettingsDictionary]] from the specified [[WorkspaceDb]] and add it to this workspace's current [[Settings]].\n * @note this function will load the dictionaries from the supplied list, and it will also call itself recursively for any entries in\n * the loaded Settings with the name [[WorkspaceSettingNames.settingsWorkspaces]]. In this manner, WorkspaceSettings may be \"chained\" together so that loading one\n * causes its \"dependent\" WorkspaceSettings to be loaded. Its `Promise` is resolved after all have been loaded (or failed to load).\n */\n loadSettingsDictionary(\n /** The properties of the [[WorkspaceDb]], plus the resourceName and [[SettingsPriority]]. May be either a single value or an array of them */\n props: WorkspaceDbSettingsProps | WorkspaceDbSettingsProps[],\n /** If present, an array that is populated with a list of problems while attempting to load the [[SettingsDictionary]](s). */\n problems?: WorkspaceDbLoadError[]\n ): Promise<void>;\n\n /** Get a single [[WorkspaceDb]]. */\n getWorkspaceDb(props: WorkspaceDbCloudProps): Promise<WorkspaceDb>;\n\n /**\n * Resolve the value of all [[Setting]]s from this workspace with the supplied `settingName` into an array of [[WorkspaceDbCloudProps]]\n * that can be used to query or load workspace resources. The settings must each be an array of type [[WorkspaceDbSettingsProps]].\n * The returned array will be sorted according to their [[SettingsPriority]], with the first entry being the highest priority [[WorkspaceDb]].\n * @note The list is built by combining, in order, all of the settings with the supplied [[SettingName]]. It may therefore include the\n * properties of same WorkspaceDb multiple times. This list is automatically de-duped by [[getWorkspaceDb]].\n * @note This function is rarely used directly. Usually it is called by [[getWorkspaceDbs]]. However, this function is synchronous and may sometimes\n * be useful for editors, tests, or diagnostics.\n */\n resolveWorkspaceDbSetting(\n /** the name of the setting. */\n settingName: SettingName,\n /** optional filter to choose specific WorkspaceDbs from the settings values. If present, only those WorkspaceDbs for which the filter returns `true` will be included. */\n filter?: Workspace.DbListFilter): WorkspaceDbCloudProps[];\n\n /**\n * Get a sorted array of [[WorkspaceDb]]s that can be used to query or load resources. If the arguments supply a `settingName`, this function will\n * use [[resolveWorkspaceDbSetting]] to get get the array of [[WorkspaceDbCloudProps]].\n * @returns A `Promise` resolving to an array of [[WorkspaceDb]]s sorted by [[SettingsPriority]] so that resources found in WorkspaceDbs earlier in the list take precedence\n * over ones with the same name in later WorkspaceDbs. No WorkspaceDb will appear more than once in the list.\n * @note this function may request an [AccessToken]($bentley) for each WorkspaceDb if necessary, and hence is asynchronous.\n */\n getWorkspaceDbs(\n args: Workspace.DbListOrSettingName & {\n /** if supplied, this array is populated with a list of problems (e.g. no read permission) attempting to load WorkspacesDbs. */\n problems?: WorkspaceDbLoadError[];\n /** only valid when called with a settingName, if so passed as `filter` argument to [[resolveWorkspaceDbSetting]] */\n filter?: Workspace.DbListFilter;\n }): Promise<WorkspaceDb[]>;\n}\n\n/**\n * A WorkspaceContainer is a type of [[CloudSqlite.CloudContainer]] that holds one or more [[WorkspaceDb]]s. Normally a WorkspaceContainer will hold (many versions of) a single WorkspaceDb.\n * Each version of a WorkspaceDb is treated as immutable after it is created and is stored in the WorkspaceContainer indefinitely. That means that\n * older versions of the WorkspaceDb may continue to be used, for example by archived projects. For programmers familiar with [NPM](https://www.npmjs.com/), this is conceptually\n * similar and versioning follows the same rules as NPM using [Semantic Versioning](https://semver.org/).\n * @note It is possible to store more than one WorkspaceDb in the same WorkspaceContainer, but access rights are administered per WorkspaceContainer.\n * That is, if a user has rights to access a WorkspaceContainer, that right applies to all WorkspaceDbs in the WorkspaceContainer.\n * @note Not every WorkspaceContainer is associated with a [[CloudSqlite.CloudContainer]] - WorkspaceContainers may also be loaded from the local file system.\n * In this case, [[cloudContainer]] will be `undefined`.\n * @see [[Workspace.getContainer]] and [[Workspace.getContainerAsync]] to load a container.\n * @beta\n */\nexport interface WorkspaceContainer {\n /** @internal */\n [_implementationProhibited]: unknown;\n /** the local directory where this WorkspaceContainer will store temporary files extracted for file-resources.\n * @internal\n */\n readonly filesDir: LocalDirName;\n /** The workspace into which this container was loaded. */\n readonly workspace: Workspace;\n /** Cloud container for this WorkspaceContainer, or `undefined` if this is a local WorkspaceContainer. */\n readonly cloudContainer?: CloudSqlite.CloudContainer;\n /** Properties supplied when this container was loaded */\n readonly fromProps: WorkspaceContainerProps;\n\n /** @internal */\n addWorkspaceDb(toAdd: WorkspaceDb): void;\n\n /**\n * Find the fully-qualified name of a [[WorkspaceDb]] satisfying the name and version criteria specified by `props`.\n * @throws Error if no version satisfying the criteria exists.\n */\n resolveDbFileName(props: WorkspaceDbProps): WorkspaceDbFullName;\n\n /** Obtain a [[WorkspaceDb]] satisfying the name and version criteria specified by `props`. */\n getWorkspaceDb(props?: WorkspaceDbProps): WorkspaceDb;\n\n /** Close and remove a currently opened [[WorkspaceDb]] from this Workspace.\n * @internal\n */\n closeWorkspaceDb(container: WorkspaceDb): void;\n}\n\nfunction makeSettingName(name: string) {\n return `${\"itwin/core/workspace\"}/${name}`;\n}\n\n/** The names of various [[Setting]]s with special meaning to the [[Workspace]] system.\n * @beta\n */\nexport namespace WorkspaceSettingNames {\n /** The name of a setting that, when present in a [[WorkspaceDb]] loaded by [[Workspace.loadSettingsDictionary]], will automatically\n * be used to find and load additional [[SettingsDictionary]]'s in other [[WorkspaceDb]]s. This permits you to chain the settings inside on [[WorkspaceDb]]\n * to others upon which they depend.\n * This setting's value is an array of [[WorkspaceDbSettingsProps]]s.\n */\n export const settingsWorkspaces = makeSettingName(\"settingsWorkspaces\");\n}\n\n/** A function supplied as part of a [[QueryWorkspaceResourcesArgs]] to iterate the resources retrieved by [[Workspace.queryResources]].\n * The `resources` object should only be used inside the function - it is an error to attempt to iterate it after the function returns.\n * @beta\n */\nexport type QueryWorkspaceResourcesCallback = (resources: Iterable<{ name: string, db: WorkspaceDb }>) => void;\n\n/** Arguments supplied to [[Workspace.queryResources]] defining the query criteria and the list of [[WorkspaceDb]]s to query.\n * @beta\n */\nexport interface QueryWorkspaceResourcesArgs {\n /** The list of `WorkspaceDb`s to query, in the order in which they are to be queried.\n * @see [[Workspace.resolveWorkspaceDbSetting]] or [[Workspace.getWorkspaceDbs]] to obtain an appropriate list of `WorkspaceDb`s.\n */\n dbs: WorkspaceDb[];\n /** The type of resource to query. */\n type?: \"string\" | \"blob\";\n /** A pattern against which to compare the name of each resource, using [[nameCompare]] as the comparison operator.\n * Only resources whose names match the pattern will be included in the query results.\n */\n namePattern?: string;\n /** The comparison operator by which to compare the name of each resource to [[namePattern]].\n * Only resources whose names match the pattern will be included in the query results.\n * Ignored i [[namePattern]] is undefined.\n */\n nameCompare?: \"GLOB\" | \"LIKE\" | \"NOT GLOB\" | \"NOT LIKE\" | \"=\" | \"<\" | \">\";\n /** A function invoked to process the resources that match the query criteria. */\n callback: QueryWorkspaceResourcesCallback;\n}\n\nfunction getWorkspaceResource(dbs: WorkspaceDb[], name: string, type: \"string\" | \"blob\"): string | Uint8Array | undefined {\n for (const db of dbs) {\n const val = type === \"blob\" ? db.getBlob(name) : db.getString(name);\n if (undefined !== val) {\n return val;\n }\n }\n\n return undefined;\n}\n\n/** Arguments supplied to [[Workspace.getStringResource]] and [[WOrkspace.getBlobResource]].\n * @beta\n */\nexport interface GetWorkspaceResourceArgs {\n /** The list of `WorkspaceDb`s to search, in the order in which they are to be searched.\n * @see [[Workspace.resolveWorkspaceDbSetting]] or [[Workspace.getWorkspaceDbs]] to obtain an appropriate list of `WorkspaceDb`s.\n */\n dbs: WorkspaceDb[];\n /** The name of the resource to find. */\n name: WorkspaceResourceName;\n}\n\n/** @beta */\nexport namespace Workspace {\n /** A function invoked to handle exceptions produced while loading workspace data.\n * Applications can override this function to notify the user and/or attempt to diagnose the problem.\n * The default implementation simply logs each exception.\n */\n export let exceptionDiagnosticFn = (e: WorkspaceDbLoadErrors) => { // eslint-disable-line prefer-const\n if (e instanceof Error)\n Logger.logException(BackendLoggerCategory.Workspace, e);\n else\n UnexpectedErrors.handle(e);\n };\n\n /** Arguments supplied to [[Workspace.onSettingsDictionaryLoadedFn]] for every [[SettingsDictionary]] that is loaded from a [[WorkspaceDb]]. */\n export interface SettingsDictionaryLoaded {\n /** The dictionary that was loaded */\n dict: SettingsDictionary;\n /** The WorkspaceDb from which the dictionary was loaded. */\n from: WorkspaceDb;\n }\n\n /** A function invoked each time any [[SettingsDictionary]] is loaded from a [[WorkspaceDb]].\n * Applications can override this function to notify the user and/or record diagnostics.\n * The default implementation simply records an information message in the [Logger]($bentley).\n */\n export let onSettingsDictionaryLoadedFn = (loaded: SettingsDictionaryLoaded) => { // eslint-disable-line prefer-const\n Logger.logInfo(BackendLoggerCategory.Workspace, `loaded setting dictionary ${loaded.dict.props.name} from ${loaded.from.dbFileName}`);\n };\n\n /** Either an array of [[WorkspaceDbCloudProps]] or the name of a [[Setting]] that resolves to an array of [[WorkspaceDbCloudProps]].\n * Used by [[Workspace.getWorkspaceDbs]].\n */\n export type DbListOrSettingName = { readonly dbs: WorkspaceDbCloudProps[], readonly settingName?: never } | { readonly settingName: SettingName, readonly dbs?: never };\n\n /** In arguments supplied to [[Workspace.getWorkspaceDbs]] and [[Workspace.resolveWorkspaceDbSetting]], an optional function used to exclude some\n * [[WorkspaceDb]]s. Only those [[WorkspaceDb]]s for which the function returns `true` will be included.\n */\n export type DbListFilter = (\n /** The properties of the WorkspaceDb to be returned */\n dbProp: WorkspaceDbCloudProps,\n /** The SettingsDictionary holding the [[WorkspaceSettingNames.settingsWorkspace]] setting. May be used, for example, to determine the\n * [[SettingsPriority]] of the dictionary.\n */\n dict: SettingsDictionary\n ) => boolean;\n\n /** Searches a list of [[WorkspaceDb]]s for a string resource of a given name.\n * The list is searched in order, and the first resource with the request name is returned.\n * If no such resource exists, the function returns `undefined`.\n * @see [[WorkspaceDb.getString]] if you only need to search a single `WorkspaceDb`.\n * @beta\n */\n export function getStringResource(args: GetWorkspaceResourceArgs): string | undefined {\n return getWorkspaceResource(args.dbs, args.name, \"string\") as string | undefined;\n }\n\n /** Searches a list of [[WorkspaceDb]]s for a blob resource of a given name.\n * The list is searched in order, and the first resource with the request name is returned.\n * If no such resource exists, the function returns `undefined`.\n * @see [[WorkspaceDb.getblob]] if you only need to search a single `WorkspaceDb`.\n * @beta\n */\n export function getBlobResource(args: GetWorkspaceResourceArgs): Uint8Array | undefined {\n return getWorkspaceResource(args.dbs, args.name, \"blob\") as Uint8Array | undefined;\n }\n\n /** Query a list of [[WorkspaceDb]]s to find resources of a particular type with names matching a specified pattern.\n * @see [[WorkspaceDb.queryResources]] if you only need to query a single `WorkspaceDb`.\n * @beta\n */\n export function queryResources(args: QueryWorkspaceResourcesArgs): void {\n const resources: Array<{ name: string, db: WorkspaceDb }> = [];\n for (const db of args.dbs) {\n db.queryResources({\n type: args.type,\n namePattern: args.namePattern,\n nameCompare: args.nameCompare,\n callback: (names) => {\n for (const name of names) {\n resources.push({ db, name });\n }\n },\n });\n }\n\n args.callback(resources);\n }\n}\n"]}
@@ -7,6 +7,7 @@ import { SettingsContainer } from "./Settings";
7
7
  import { BlobContainer } from "../BlobContainerService";
8
8
  import { GetWorkspaceContainerArgs, Workspace, WorkspaceContainer, WorkspaceContainerProps, WorkspaceDb, WorkspaceDbCloudProps, WorkspaceDbManifest, WorkspaceDbName, WorkspaceDbNameAndVersion, WorkspaceDbProps, WorkspaceDbVersion, WorkspaceResourceName } from "./Workspace";
9
9
  import { _implementationProhibited } from "../internal/Symbols";
10
+ import { CloudSqlite } from "../CloudSqlite";
10
11
  /** @beta */
11
12
  export declare namespace WorkspaceEditor {
12
13
  /**
@@ -99,12 +100,6 @@ export interface EditableWorkspaceContainer extends WorkspaceContainer {
99
100
  */
100
101
  abandonChanges(): void;
101
102
  }
102
- /**
103
- * The release increment for a version number, used as part of [[CreateNewWorkspaceDbVersionArgs]] to specify the kind of version to create.
104
- * @see [semver.ReleaseType](https://www.npmjs.com/package/semver)
105
- * @beta
106
- */
107
- export type WorkspaceDbVersionIncrement = "major" | "minor" | "patch" | "premajor" | "preminor" | "prepatch" | "prerelease";
108
103
  /**
109
104
  * Arguments supplied to [[Workspace.createNewWorkspaceDbVersion]].
110
105
  * @beta
@@ -116,7 +111,7 @@ export interface CreateNewWorkspaceDbVersionArgs {
116
111
  */
117
112
  fromProps?: WorkspaceDbProps;
118
113
  /** The type of version increment to apply to the source version. */
119
- versionType: WorkspaceDbVersionIncrement;
114
+ versionType: CloudSqlite.SemverIncrement;
120
115
  /** For prerelease versions, a string that becomes part of the version name. */
121
116
  identifier?: string;
122
117
  }