@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":"WorkspaceEditor.d.ts","sourceRoot":"","sources":["../../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AE1E;;OAEG;IACH,iBAAiB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAEvF;;;OAGG;IACH,uBAAuB,CAAC,IAAI,EAAE,+BAA+B,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAEpG;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;CACf"}
@@ -1 +1 @@
1
- {"version":3,"file":"WorkspaceEditor.js","sourceRoot":"","sources":["../../../src/workspace/WorkspaceEditor.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAUH,+EAA4E;AAC5E,uEAA+E;AAC/E,iDAAgE;AAEhE,YAAY;AACZ,IAAiB,eAAe,CAgB/B;AAhBD,WAAiB,eAAe;IAC9B;;;;OAIG;IACH,SAAgB,SAAS;QACvB,OAAO,IAAA,wCAAwB,GAAE,CAAC;IACpC,CAAC;IAFe,yBAAS,YAExB,CAAA;IAED;;OAEG;IACH,SAAgB,aAAa,CAAC,IAAqE;QACjG,qCAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;IAFe,6BAAa,gBAE5B,CAAA;AACH,CAAC,EAhBgB,eAAe,+BAAf,eAAe,QAgB/B","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 { LocalFileName } from \"@itwin/core-common\";\nimport { SQLiteDb } from \"../SQLiteDb\";\nimport { SettingsContainer } from \"./Settings\";\nimport { BlobContainer } from \"../BlobContainerService\";\nimport {\n GetWorkspaceContainerArgs, Workspace, WorkspaceContainer, WorkspaceContainerProps, WorkspaceDb, WorkspaceDbCloudProps, WorkspaceDbManifest, WorkspaceDbName, WorkspaceDbNameAndVersion,\n WorkspaceDbProps, WorkspaceDbVersion, WorkspaceResourceName,\n} from \"./Workspace\";\nimport { WorkspaceSqliteDb } from \"../internal/workspace/WorkspaceSqliteDb\";\nimport { constructWorkspaceEditor } from \"../internal/workspace/WorkspaceImpl\";\nimport { _implementationProhibited } from \"../internal/Symbols\";\n\n/** @beta */\nexport namespace WorkspaceEditor {\n /**\n * Create a new [[WorkspaceEditor]] for creating new versions of [[WorkspaceDb]]s.\n * @note the caller becomes the owner of the Workspace.Editor and is responsible for calling [[WorkspaceEditor.close]] on it when they are finished using it.\n * @note It is illegal to have more than one Workspace.Editor active in a single session.\n */\n export function construct(): WorkspaceEditor {\n return constructWorkspaceEditor();\n }\n\n /**\n * Create a new, empty, [[EditableWorkspaceDb]] file on the local filesystem for importing [[Workspace]] resources.\n */\n export function createEmptyDb(args: { localFileName: LocalFileName, manifest: WorkspaceDbManifest }): void {\n WorkspaceSqliteDb.createNewDb(args.localFileName, args);\n }\n}\n\n/** Arguments supplied to [[WorkspaceEditor.createNewCloudContainer]] to create a new [[EditableWorkspaceContainer]].\n * @beta\n */\nexport interface CreateNewWorkspaceContainerArgs {\n /**\n * The scope of the container. This determines the ownership of the container, how RBAC rights are assigned,\n * and the location of the datacenter\n */\n scope: BlobContainer.Scope;\n /** The manifest to be stored in the default WorkspaceDb in the new container. */\n manifest: WorkspaceDbManifest;\n /** Metadata stored by the BlobContainer service */\n metadata: Omit<BlobContainer.Metadata, \"containerType\">;\n /** The name of the default [[WorkspaceDb]] created inside the new container.\n * Default: \"workspace-db\";\n */\n dbName?: WorkspaceDbName;\n}\n\n/**\n * A [[WorkspaceContainer]] opened for editing by a [[WorkspaceEditor]].\n * You can create new [[WorkspaceDb]]s or new versions of existing [[WorkspaceDb]]s inside it.\n * Before actually making any changes to the container's contents, you must first obtain an exclusive write lock on it via\n * [[acquireWriteLock]]. Only one user can hold the write lock at any given time. When you have finished making changes,\n * you can use [[releaseWriteLock]] to publish your changes, or [[abandonChanges]] to discard them.\n * @beta\n */\nexport interface EditableWorkspaceContainer extends WorkspaceContainer {\n /**\n * Create a copy of an existing [[WorkspaceDb]] in this container with a new [[WorkspaceDbVersion]].\n * The copy should be modified with new content before the write lock is released,\n * and thereafter may never be modified again.\n * @note The copy actually shares all of the data with the original, but with copy-on-write if/when data in the new WorkspaceDb is modified.\n * @param props - The properties that determine the source WorkspaceDb to serve as the basis for the new version.\n * @returns A promise that resolves to an object containing the old and new WorkspaceDb names and versions.\n */\n createNewWorkspaceDbVersion(props: CreateNewWorkspaceDbVersionArgs): Promise<{ oldDb: WorkspaceDbNameAndVersion, newDb: WorkspaceDbNameAndVersion }>;\n\n /**\n * Create a new, empty [[WorkspaceDb]].\n * @param args - The arguments for creating the new WorkspaceDb.\n * @returns A promise that resolves to an EditableWorkspaceDb.\n */\n createDb(args: { dbName?: WorkspaceDbName, version?: WorkspaceDbVersion, manifest: WorkspaceDbManifest }): Promise<EditableWorkspaceDb>;\n\n /**\n * Get the cloud properties of this container.\n */\n readonly cloudProps: WorkspaceContainerProps | undefined;\n\n /**\n * Get an editable [[WorkspaceDb]] to add, delete, or update resources *within a newly created version* of a WorkspaceDb.\n * @param props - The properties of the WorkspaceDb.\n */\n getEditableDb(props: WorkspaceDbProps): EditableWorkspaceDb;\n\n /**\n * Acquire the write lock on the container. Use [[releaseWriteLock]] to release the lock after publishing your changes, or\n * [[abandonChanges]] to release the lock and discard your changes.\n * Only one use can hold the write lock at any given time. However, readers can continue to read the published contents of the container while\n * a writer holds the write lock. Readers will only see the writer's changes after they are published by [[releaseWriteLock]].\n * @param user - The name of the user acquiring the write lock.\n */\n acquireWriteLock(user: string): void;\n\n /**\n * Release the write lock on the container. This should be called after all changes to the container's contents are complete. It\n * publishes and uploads the changes made to any [[WorkspaceDb]]s while the lock was held, after which those dbs become immutable.\n */\n releaseWriteLock(): void;\n\n /**\n * Abandon any changes made to the container and release the write lock. Any newly created versions of WorkspaceDbs are discarded.\n */\n abandonChanges(): void;\n}\n\n/**\n * The release increment for a version number, used as part of [[CreateNewWorkspaceDbVersionArgs]] to specify the kind of version to create.\n * @see [semver.ReleaseType](https://www.npmjs.com/package/semver)\n * @beta\n */\nexport type WorkspaceDbVersionIncrement = \"major\" | \"minor\" | \"patch\" | \"premajor\" | \"preminor\" | \"prepatch\" | \"prerelease\";\n\n/**\n * Arguments supplied to [[Workspace.createNewWorkspaceDbVersion]].\n * @beta\n */\nexport interface CreateNewWorkspaceDbVersionArgs {\n /**\n * The properties that determine the source [[WorkspaceDb]] to serve as the basis for the new version.\n * This is usually the latest version, but it is possible to create patches to older versions.\n */\n fromProps?: WorkspaceDbProps;\n /** The type of version increment to apply to the source version. */\n versionType: WorkspaceDbVersionIncrement;\n /** For prerelease versions, a string that becomes part of the version name. */\n identifier?: string;\n}\n\n/**\n * An editable [[WorkspaceDb]]. This is used only by tools to allow administrators to create and modify WorkspaceDbs.\n * For cloud-based WorkspaceDbs, the container's write token must be obtained via [[EditableWorkspaceContainer.acquireWriteLock]] before the methods in this interface may be used.\n * Normally, only admins will have write access to a [[Workspace]].\n * Only one admin at a time may be editing a Workspace.\n * @beta\n */\nexport interface EditableWorkspaceDb extends WorkspaceDb {\n readonly container: EditableWorkspaceContainer;\n /**\n * The cloud properties of the [[WorkspaceDb]], if this is a cloud-based WorkspaceDb.\n */\n get cloudProps(): WorkspaceDbCloudProps | undefined;\n\n /**\n * Update the contents of the manifest in this WorkspaceDb.\n * @param manifest - The updated manifest.\n */\n updateManifest(manifest: WorkspaceDbManifest): void;\n\n /**\n * Add or update a resource in this WorkspaceDb that can be loaded as a [[SettingsDictionary]].\n * The `settings` will be stored as stringified JSON.\n * @param settings - The settings object to add or update.\n * @param rscName - The name of the settings resource. Defaults to \"settingsDictionary\" if undefined.\n */\n updateSettingsResource(settings: SettingsContainer, rscName?: string): void;\n\n /**\n * Add a new string resource to this WorkspaceDb.\n * @param rscName - The name of the string resource.\n * @param val - The string to save.\n * @throws if a string resource named `rscName` already exists.\n */\n addString(rscName: WorkspaceResourceName, val: string): void;\n\n /**\n * Update an existing string resource with a new value, or add it if it does not exist.\n * @param rscName - The name of the string resource.\n * @param val - The new value.\n */\n updateString(rscName: WorkspaceResourceName, val: string): void;\n\n /**\n * Remove a string resource.\n * @param rscName - The name of the string resource to remove.\n */\n removeString(rscName: WorkspaceResourceName): void;\n\n /**\n * Add a new binary resource to this WorkspaceDb.\n * @param rscName - The name of the blob resource.\n * @param val - The blob to save.\n * @throws if a blob resource named `rscName` already exists.\n */\n addBlob(rscName: WorkspaceResourceName, val: Uint8Array): void;\n\n /**\n * Update an existing blob resource with a new value, or add it if it does not exist.\n * @param rscName - The name of the blob resource.\n * @param val - The new value.\n */\n updateBlob(rscName: WorkspaceResourceName, val: Uint8Array): void;\n\n /**\n * Get a BlobIO writer for a previously-added blob WorkspaceResource.\n * @param rscName - The name of the blob resource.\n * @returns A BlobIO writer.\n * @note After writing is complete, the caller must call `close` on the BlobIO and must call `saveChanges` on the `db`.\n * @internal\n */\n getBlobWriter(rscName: WorkspaceResourceName): SQLiteDb.BlobIO;\n\n /**\n * Remove a binary resource.\n * @param rscName - The name of the blob resource to remove.\n */\n removeBlob(rscName: WorkspaceResourceName): void;\n\n /**\n * Copy the contents of an existing local file into this WorkspaceDb as a file resource.\n * @param rscName - The name of the file resource.\n * @param localFileName - The name of a local file to be read.\n * @param fileExt - The extension to be appended to the generated fileName when this WorkspaceDb is extracted from the WorkspaceDb.\n * By default, the characters after the last \".\" in `localFileName` are used. Pass this argument to override that.\n */\n addFile(rscName: WorkspaceResourceName, localFileName: LocalFileName, fileExt?: string): void;\n\n /**\n * Replace an existing file resource with the contents of another local file.\n * @param rscName - The name of the file resource.\n * @param localFileName - The name of a local file to be read.\n * @throws If the file resource does not exist.\n */\n updateFile(rscName: WorkspaceResourceName, localFileName: LocalFileName): void;\n\n /**\n * Remove a file resource.\n * @param rscName - The name of the file resource to remove.\n */\n removeFile(rscName: WorkspaceResourceName): void;\n}\n\n/** An object that permits administrators to modify the contents of a [[Workspace]].\n * Use [[WorkspaceEditor.construct]] to obtain a WorkspaceEditor, and [[close]] when finished using it.\n * Only one WorkspaceEditor may be in use at any given time.\n * Use [[getContainer]] to edit an existing [[WorkspaceContainer]], or [[createNewCloudContainer]] to create a new [[WorkspaceContainer]].\n * @beta\n */\nexport interface WorkspaceEditor {\n /** @internal */\n [_implementationProhibited]: unknown;\n\n /**\n * The workspace dedicated to this editor.\n * @note This workspace is independent from [[IModelHost.appWorkspace]] and all [[IModelDb.workspace]]s. It has its own [[Settings]] and [[WorkspaceDb]]s.\n */\n readonly workspace: Workspace;\n\n /**\n * Retrieves a container for the editor with the specified properties and access token.\n */\n getContainer(args: GetWorkspaceContainerArgs): EditableWorkspaceContainer;\n\n /**\n * Asynchronously retrieves a container for the editor with the specified properties.\n */\n getContainerAsync(props: WorkspaceContainerProps): Promise<EditableWorkspaceContainer>;\n\n /**\n * Creates a new cloud container for holding WorkspaceDbs, from the [[BlobContainer]] service.\n * @note The current user must have administrator rights for the iTwin for the container.\n */\n createNewCloudContainer(args: CreateNewWorkspaceContainerArgs): Promise<EditableWorkspaceContainer>;\n\n /**\n * Closes this editor. All [[workspace]] containers are dropped.\n */\n close(): void;\n}\n"]}
1
+ {"version":3,"file":"WorkspaceEditor.js","sourceRoot":"","sources":["../../../src/workspace/WorkspaceEditor.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAUH,+EAA4E;AAC5E,uEAA+E;AAC/E,iDAAgE;AAGhE,YAAY;AACZ,IAAiB,eAAe,CAgB/B;AAhBD,WAAiB,eAAe;IAC9B;;;;OAIG;IACH,SAAgB,SAAS;QACvB,OAAO,IAAA,wCAAwB,GAAE,CAAC;IACpC,CAAC;IAFe,yBAAS,YAExB,CAAA;IAED;;OAEG;IACH,SAAgB,aAAa,CAAC,IAAqE;QACjG,qCAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;IAFe,6BAAa,gBAE5B,CAAA;AACH,CAAC,EAhBgB,eAAe,+BAAf,eAAe,QAgB/B","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 { LocalFileName } from \"@itwin/core-common\";\nimport { SQLiteDb } from \"../SQLiteDb\";\nimport { SettingsContainer } from \"./Settings\";\nimport { BlobContainer } from \"../BlobContainerService\";\nimport {\n GetWorkspaceContainerArgs, Workspace, WorkspaceContainer, WorkspaceContainerProps, WorkspaceDb, WorkspaceDbCloudProps, WorkspaceDbManifest, WorkspaceDbName, WorkspaceDbNameAndVersion,\n WorkspaceDbProps, WorkspaceDbVersion, WorkspaceResourceName,\n} from \"./Workspace\";\nimport { WorkspaceSqliteDb } from \"../internal/workspace/WorkspaceSqliteDb\";\nimport { constructWorkspaceEditor } from \"../internal/workspace/WorkspaceImpl\";\nimport { _implementationProhibited } from \"../internal/Symbols\";\nimport { CloudSqlite } from \"../CloudSqlite\";\n\n/** @beta */\nexport namespace WorkspaceEditor {\n /**\n * Create a new [[WorkspaceEditor]] for creating new versions of [[WorkspaceDb]]s.\n * @note the caller becomes the owner of the Workspace.Editor and is responsible for calling [[WorkspaceEditor.close]] on it when they are finished using it.\n * @note It is illegal to have more than one Workspace.Editor active in a single session.\n */\n export function construct(): WorkspaceEditor {\n return constructWorkspaceEditor();\n }\n\n /**\n * Create a new, empty, [[EditableWorkspaceDb]] file on the local filesystem for importing [[Workspace]] resources.\n */\n export function createEmptyDb(args: { localFileName: LocalFileName, manifest: WorkspaceDbManifest }): void {\n WorkspaceSqliteDb.createNewDb(args.localFileName, args);\n }\n}\n\n/** Arguments supplied to [[WorkspaceEditor.createNewCloudContainer]] to create a new [[EditableWorkspaceContainer]].\n * @beta\n */\nexport interface CreateNewWorkspaceContainerArgs {\n /**\n * The scope of the container. This determines the ownership of the container, how RBAC rights are assigned,\n * and the location of the datacenter\n */\n scope: BlobContainer.Scope;\n /** The manifest to be stored in the default WorkspaceDb in the new container. */\n manifest: WorkspaceDbManifest;\n /** Metadata stored by the BlobContainer service */\n metadata: Omit<BlobContainer.Metadata, \"containerType\">;\n /** The name of the default [[WorkspaceDb]] created inside the new container.\n * Default: \"workspace-db\";\n */\n dbName?: WorkspaceDbName;\n}\n\n/**\n * A [[WorkspaceContainer]] opened for editing by a [[WorkspaceEditor]].\n * You can create new [[WorkspaceDb]]s or new versions of existing [[WorkspaceDb]]s inside it.\n * Before actually making any changes to the container's contents, you must first obtain an exclusive write lock on it via\n * [[acquireWriteLock]]. Only one user can hold the write lock at any given time. When you have finished making changes,\n * you can use [[releaseWriteLock]] to publish your changes, or [[abandonChanges]] to discard them.\n * @beta\n */\nexport interface EditableWorkspaceContainer extends WorkspaceContainer {\n /**\n * Create a copy of an existing [[WorkspaceDb]] in this container with a new [[WorkspaceDbVersion]].\n * The copy should be modified with new content before the write lock is released,\n * and thereafter may never be modified again.\n * @note The copy actually shares all of the data with the original, but with copy-on-write if/when data in the new WorkspaceDb is modified.\n * @param props - The properties that determine the source WorkspaceDb to serve as the basis for the new version.\n * @returns A promise that resolves to an object containing the old and new WorkspaceDb names and versions.\n */\n createNewWorkspaceDbVersion(props: CreateNewWorkspaceDbVersionArgs): Promise<{ oldDb: WorkspaceDbNameAndVersion, newDb: WorkspaceDbNameAndVersion }>;\n\n /**\n * Create a new, empty [[WorkspaceDb]].\n * @param args - The arguments for creating the new WorkspaceDb.\n * @returns A promise that resolves to an EditableWorkspaceDb.\n */\n createDb(args: { dbName?: WorkspaceDbName, version?: WorkspaceDbVersion, manifest: WorkspaceDbManifest }): Promise<EditableWorkspaceDb>;\n\n /**\n * Get the cloud properties of this container.\n */\n readonly cloudProps: WorkspaceContainerProps | undefined;\n\n /**\n * Get an editable [[WorkspaceDb]] to add, delete, or update resources *within a newly created version* of a WorkspaceDb.\n * @param props - The properties of the WorkspaceDb.\n */\n getEditableDb(props: WorkspaceDbProps): EditableWorkspaceDb;\n\n /**\n * Acquire the write lock on the container. Use [[releaseWriteLock]] to release the lock after publishing your changes, or\n * [[abandonChanges]] to release the lock and discard your changes.\n * Only one use can hold the write lock at any given time. However, readers can continue to read the published contents of the container while\n * a writer holds the write lock. Readers will only see the writer's changes after they are published by [[releaseWriteLock]].\n * @param user - The name of the user acquiring the write lock.\n */\n acquireWriteLock(user: string): void;\n\n /**\n * Release the write lock on the container. This should be called after all changes to the container's contents are complete. It\n * publishes and uploads the changes made to any [[WorkspaceDb]]s while the lock was held, after which those dbs become immutable.\n */\n releaseWriteLock(): void;\n\n /**\n * Abandon any changes made to the container and release the write lock. Any newly created versions of WorkspaceDbs are discarded.\n */\n abandonChanges(): void;\n}\n\n/**\n * Arguments supplied to [[Workspace.createNewWorkspaceDbVersion]].\n * @beta\n */\nexport interface CreateNewWorkspaceDbVersionArgs {\n /**\n * The properties that determine the source [[WorkspaceDb]] to serve as the basis for the new version.\n * This is usually the latest version, but it is possible to create patches to older versions.\n */\n fromProps?: WorkspaceDbProps;\n /** The type of version increment to apply to the source version. */\n versionType: CloudSqlite.SemverIncrement;\n /** For prerelease versions, a string that becomes part of the version name. */\n identifier?: string;\n}\n\n/**\n * An editable [[WorkspaceDb]]. This is used only by tools to allow administrators to create and modify WorkspaceDbs.\n * For cloud-based WorkspaceDbs, the container's write token must be obtained via [[EditableWorkspaceContainer.acquireWriteLock]] before the methods in this interface may be used.\n * Normally, only admins will have write access to a [[Workspace]].\n * Only one admin at a time may be editing a Workspace.\n * @beta\n */\nexport interface EditableWorkspaceDb extends WorkspaceDb {\n readonly container: EditableWorkspaceContainer;\n /**\n * The cloud properties of the [[WorkspaceDb]], if this is a cloud-based WorkspaceDb.\n */\n get cloudProps(): WorkspaceDbCloudProps | undefined;\n\n /**\n * Update the contents of the manifest in this WorkspaceDb.\n * @param manifest - The updated manifest.\n */\n updateManifest(manifest: WorkspaceDbManifest): void;\n\n /**\n * Add or update a resource in this WorkspaceDb that can be loaded as a [[SettingsDictionary]].\n * The `settings` will be stored as stringified JSON.\n * @param settings - The settings object to add or update.\n * @param rscName - The name of the settings resource. Defaults to \"settingsDictionary\" if undefined.\n */\n updateSettingsResource(settings: SettingsContainer, rscName?: string): void;\n\n /**\n * Add a new string resource to this WorkspaceDb.\n * @param rscName - The name of the string resource.\n * @param val - The string to save.\n * @throws if a string resource named `rscName` already exists.\n */\n addString(rscName: WorkspaceResourceName, val: string): void;\n\n /**\n * Update an existing string resource with a new value, or add it if it does not exist.\n * @param rscName - The name of the string resource.\n * @param val - The new value.\n */\n updateString(rscName: WorkspaceResourceName, val: string): void;\n\n /**\n * Remove a string resource.\n * @param rscName - The name of the string resource to remove.\n */\n removeString(rscName: WorkspaceResourceName): void;\n\n /**\n * Add a new binary resource to this WorkspaceDb.\n * @param rscName - The name of the blob resource.\n * @param val - The blob to save.\n * @throws if a blob resource named `rscName` already exists.\n */\n addBlob(rscName: WorkspaceResourceName, val: Uint8Array): void;\n\n /**\n * Update an existing blob resource with a new value, or add it if it does not exist.\n * @param rscName - The name of the blob resource.\n * @param val - The new value.\n */\n updateBlob(rscName: WorkspaceResourceName, val: Uint8Array): void;\n\n /**\n * Get a BlobIO writer for a previously-added blob WorkspaceResource.\n * @param rscName - The name of the blob resource.\n * @returns A BlobIO writer.\n * @note After writing is complete, the caller must call `close` on the BlobIO and must call `saveChanges` on the `db`.\n * @internal\n */\n getBlobWriter(rscName: WorkspaceResourceName): SQLiteDb.BlobIO;\n\n /**\n * Remove a binary resource.\n * @param rscName - The name of the blob resource to remove.\n */\n removeBlob(rscName: WorkspaceResourceName): void;\n\n /**\n * Copy the contents of an existing local file into this WorkspaceDb as a file resource.\n * @param rscName - The name of the file resource.\n * @param localFileName - The name of a local file to be read.\n * @param fileExt - The extension to be appended to the generated fileName when this WorkspaceDb is extracted from the WorkspaceDb.\n * By default, the characters after the last \".\" in `localFileName` are used. Pass this argument to override that.\n */\n addFile(rscName: WorkspaceResourceName, localFileName: LocalFileName, fileExt?: string): void;\n\n /**\n * Replace an existing file resource with the contents of another local file.\n * @param rscName - The name of the file resource.\n * @param localFileName - The name of a local file to be read.\n * @throws If the file resource does not exist.\n */\n updateFile(rscName: WorkspaceResourceName, localFileName: LocalFileName): void;\n\n /**\n * Remove a file resource.\n * @param rscName - The name of the file resource to remove.\n */\n removeFile(rscName: WorkspaceResourceName): void;\n}\n\n/** An object that permits administrators to modify the contents of a [[Workspace]].\n * Use [[WorkspaceEditor.construct]] to obtain a WorkspaceEditor, and [[close]] when finished using it.\n * Only one WorkspaceEditor may be in use at any given time.\n * Use [[getContainer]] to edit an existing [[WorkspaceContainer]], or [[createNewCloudContainer]] to create a new [[WorkspaceContainer]].\n * @beta\n */\nexport interface WorkspaceEditor {\n /** @internal */\n [_implementationProhibited]: unknown;\n\n /**\n * The workspace dedicated to this editor.\n * @note This workspace is independent from [[IModelHost.appWorkspace]] and all [[IModelDb.workspace]]s. It has its own [[Settings]] and [[WorkspaceDb]]s.\n */\n readonly workspace: Workspace;\n\n /**\n * Retrieves a container for the editor with the specified properties and access token.\n */\n getContainer(args: GetWorkspaceContainerArgs): EditableWorkspaceContainer;\n\n /**\n * Asynchronously retrieves a container for the editor with the specified properties.\n */\n getContainerAsync(props: WorkspaceContainerProps): Promise<EditableWorkspaceContainer>;\n\n /**\n * Creates a new cloud container for holding WorkspaceDbs, from the [[BlobContainer]] service.\n * @note The current user must have administrator rights for the iTwin for the container.\n */\n createNewCloudContainer(args: CreateNewWorkspaceContainerArgs): Promise<EditableWorkspaceContainer>;\n\n /**\n * Closes this editor. All [[workspace]] containers are dropped.\n */\n close(): void;\n}\n"]}
@@ -0,0 +1,103 @@
1
+ /** @packageDocumentation
2
+ * @module iModels
3
+ */
4
+ import { type CatalogIModel, IModelConnectionProps } from "@itwin/core-common";
5
+ import { IpcHandler } from "./IpcHost";
6
+ import { StandaloneDb } from "./IModelDb";
7
+ /** A [[StandaloneDb]] that provides read-only access to the contents of a [CatalogIModel]($common).
8
+ * @see [[CatalogDb.openReadonly]] to instantiate this type.
9
+ * @beta
10
+ */
11
+ export interface CatalogDb extends StandaloneDb {
12
+ /** Get the catalog's manifest. */
13
+ getManifest(): CatalogIModel.Manifest | undefined;
14
+ /** Get the catalog's version information. */
15
+ getVersion(): string;
16
+ /** Get the catalog's manifest and version. */
17
+ getInfo(): {
18
+ manifest?: CatalogIModel.Manifest;
19
+ version: string;
20
+ };
21
+ /** Returns true if the catalog was opened in read-write mode. */
22
+ isEditable(): this is EditableCatalogDb;
23
+ }
24
+ /** A writable [[CatalogDb]].
25
+ * @see [[CatalogDb.openEditable]] to instantiate this type.
26
+ * @beta
27
+ */
28
+ export interface EditableCatalogDb extends CatalogDb {
29
+ /** Update the contents of the catalog manifest. */
30
+ updateCatalogManifest(manifest: CatalogIModel.Manifest): void;
31
+ }
32
+ /** @beta */
33
+ export declare namespace CatalogDb {
34
+ /** Create a new [[BlobContainer]] to hold versions of a [[CatalogDb]].
35
+ * @returns The properties of the newly created container.
36
+ * @note creating new containers requires "admin" authorization.
37
+ */
38
+ function createNewContainer(args: CatalogIModel.CreateNewContainerArgs): Promise<CatalogIModel.NewContainerProps>;
39
+ /** Acquire the write lock for a [CatalogIModel]($common) container. Only one person may obtain the write lock at a time.
40
+ * You must obtain the lock before attempting to write to the container via functions like [[CatalogDb.openEditable]] and [[CatalogDb.createNewVersion]].
41
+ * @note This requires "write" authorization to the container
42
+ */
43
+ function acquireWriteLock(args: {
44
+ /** The id of the container */
45
+ containerId: string;
46
+ /**
47
+ * The name of the individual acquiring the lock. This will be shown to others who attempt to acquire the lock while it is held.
48
+ * It is also stored in the "lastEditedBy" field of the manifest of any new version edited while the lock is held.
49
+ */
50
+ username: string;
51
+ }): Promise<void>;
52
+ /** Release the write lock on a [CatalogIModel]($common) container. This uploads all changes made while the lock is held, so they become visible to other users. */
53
+ function releaseWriteLock(args: {
54
+ /** The id of the container */
55
+ containerId: string;
56
+ /** If true, abandon all local changes before releasing the lock */
57
+ abandon?: true;
58
+ }): Promise<void>;
59
+ /** Open an [[EditableCatalogDb]] for write access.
60
+ * @note Once a version of a catalog iModel has been published (i.e. the write lock has been released), it is no longer editable, *unless* it is a prerelease version.
61
+ * @note The write lock must be held for this operation to succeed
62
+ */
63
+ function openEditable(args: CatalogIModel.OpenArgs): Promise<EditableCatalogDb>;
64
+ /** Open a [[CatalogDb]] for read-only access. */
65
+ function openReadonly(args: CatalogIModel.OpenArgs): Promise<CatalogDb>;
66
+ /**
67
+ * Create a new version of a [CatalogIModel]($common) as a copy of an existing version. Immediately after this operation, the new version will be an exact copy
68
+ * of the source CatalogIModel. Then, use [[CatalogDb.openEditable]] to modify the new version with new content.
69
+ * @note The write lock must be held for this operation to succeed
70
+ */
71
+ function createNewVersion(args: CatalogIModel.CreateNewVersionArgs): Promise<{
72
+ oldDb: CatalogIModel.NameAndVersion;
73
+ newDb: CatalogIModel.NameAndVersion;
74
+ }>;
75
+ }
76
+ /**
77
+ * Handler for Ipc access to CatalogIModels. Registered by NativeHost.
78
+ * @internal
79
+ */
80
+ export declare class CatalogIModelHandler extends IpcHandler implements CatalogIModel.IpcMethods {
81
+ get channelName(): CatalogIModel.IpcChannel;
82
+ createNewContainer(args: CatalogIModel.CreateNewContainerArgs): Promise<CatalogIModel.NewContainerProps>;
83
+ acquireWriteLock(args: {
84
+ containerId: string;
85
+ username: string;
86
+ }): Promise<void>;
87
+ releaseWriteLock(args: {
88
+ containerId: string;
89
+ abandon?: true;
90
+ }): Promise<void>;
91
+ openReadonly(args: CatalogIModel.OpenArgs): Promise<IModelConnectionProps>;
92
+ openEditable(args: CatalogIModel.OpenArgs): Promise<IModelConnectionProps>;
93
+ createNewVersion(args: CatalogIModel.CreateNewVersionArgs): Promise<{
94
+ oldDb: CatalogIModel.NameAndVersion;
95
+ newDb: CatalogIModel.NameAndVersion;
96
+ }>;
97
+ getInfo(key: string): Promise<{
98
+ manifest?: CatalogIModel.Manifest;
99
+ version: string;
100
+ }>;
101
+ updateCatalogManifest(key: string, manifest: CatalogIModel.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AgB,CAAC,IAAI,EAAE,aAAa,CAAC,oBAAoB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC;QAAC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC;KAAE,CAAC;IAGlJ,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAGrF,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAGjG"}
@@ -0,0 +1,267 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module iModels
7
+ */
8
+ import * as fs from "fs";
9
+ import { join } from "path";
10
+ import { CloudSqlite } from "./CloudSqlite";
11
+ import { IModelHost, KnownLocations } from "./IModelHost";
12
+ import { BriefcaseIdValue, CatalogError, CloudSqliteError } from "@itwin/core-common";
13
+ import { IpcHandler } from "./IpcHost";
14
+ import { StandaloneDb } from "./IModelDb";
15
+ import { Guid, OpenMode } from "@itwin/core-bentley";
16
+ import { _nativeDb } from "./internal/Symbols";
17
+ import { IModelNative } from "./internal/NativePlatform";
18
+ let readonlyCloudCache;
19
+ let writeableCloudCache;
20
+ const catalogManifestName = "CatalogManifest";
21
+ // we make a readonly CloudCache and a writeable CloudCache. That way the access token authorizations are distinct.
22
+ function makeCloudCache(arg, writeable) {
23
+ const cache = CloudSqlite.CloudCaches.getCache(arg);
24
+ // if the cache was just created, add the "catalog" members as hidden
25
+ if (undefined === cache.catalogContainers) {
26
+ CloudSqlite.addHiddenProperty(cache, "catalogContainers", new Map());
27
+ CloudSqlite.addHiddenProperty(cache, "writeable", writeable);
28
+ }
29
+ return cache;
30
+ }
31
+ // find an existing CloudContainer for accessing a CatalogIModel, or make a new one and connect it
32
+ async function getCatalogContainerObj(cache, containerId) {
33
+ const cloudContainer = cache.catalogContainers.get(containerId);
34
+ if (undefined !== cloudContainer)
35
+ return cloudContainer;
36
+ const accessLevel = cache.writeable ? "write" : "read";
37
+ const tokenProps = await CloudSqlite.getBlobService().requestToken({ containerId, accessLevel, userToken: await IModelHost.getAccessToken() });
38
+ const container = CloudSqlite.createCloudContainer({
39
+ accessLevel,
40
+ baseUri: tokenProps.baseUri,
41
+ containerId,
42
+ storageType: tokenProps.provider,
43
+ writeable: cache.writeable,
44
+ accessToken: tokenProps.token
45
+ });
46
+ cache.catalogContainers.set(containerId, container); // save the container in the map of ContainerIds so we can reuse them
47
+ container.connect(cache);
48
+ return container;
49
+ }
50
+ function getReadonlyCloudCache() { return readonlyCloudCache ??= makeCloudCache({ cacheName: "catalogs", cacheSize: "10G" }, false); }
51
+ ;
52
+ function getWritableCloudCache() { return writeableCloudCache ??= makeCloudCache({ cacheName: "writeableCatalogs", cacheSize: "10G" }, true); }
53
+ ;
54
+ async function getReadonlyContainer(containerId) { return getCatalogContainerObj(getReadonlyCloudCache(), containerId); }
55
+ ;
56
+ async function getWriteableContainer(containerId) { return getCatalogContainerObj(getWritableCloudCache(), containerId); }
57
+ ;
58
+ /** Throw an error if the write lock is not held for the supplied container */
59
+ function ensureLocked(container, reason) {
60
+ if (!container.hasWriteLock)
61
+ CloudSqliteError.throwError("write-lock-not-held", { message: `Write lock must be held to ${reason}` });
62
+ }
63
+ /** update the manifest in a CatalogIModel (calls `saveChanges`) */
64
+ function updateManifest(nativeDb, manifest) {
65
+ nativeDb.saveLocalValue(catalogManifestName, JSON.stringify(manifest));
66
+ nativeDb.saveChanges("update manifest");
67
+ }
68
+ function catalogDbNameWithDefault(dbName) {
69
+ return dbName ?? "catalog-db";
70
+ }
71
+ /** A StandaloneDb that holds a CatalogIModel */
72
+ class CatalogDbImpl extends StandaloneDb {
73
+ isEditable() {
74
+ return false;
75
+ }
76
+ getManifest() {
77
+ const manifestString = this[_nativeDb].queryLocalValue(catalogManifestName);
78
+ if (undefined === manifestString)
79
+ return undefined;
80
+ return JSON.parse(manifestString);
81
+ }
82
+ getVersion() {
83
+ return CloudSqlite.parseDbFileName(this[_nativeDb].getFilePath()).version;
84
+ }
85
+ getInfo() {
86
+ return { manifest: this.getManifest(), version: this.getVersion() };
87
+ }
88
+ }
89
+ /**
90
+ * A CatalogDb that permits editing.
91
+ * This class ensures that CatalogIModels never have a Txn table when they are published.
92
+ * It also automatically updates the `lastEditedBy` field in the CatalogManifest.
93
+ */
94
+ class EditableCatalogDbImpl extends CatalogDbImpl {
95
+ isEditable() {
96
+ return true;
97
+ }
98
+ updateCatalogManifest(manifest) {
99
+ updateManifest(this[_nativeDb], manifest);
100
+ }
101
+ // Make sure the txn table is deleted and update the manifest every time we close.
102
+ beforeClose() {
103
+ try {
104
+ const manifest = this.getManifest();
105
+ const container = this.cloudContainer;
106
+ if (container && manifest) {
107
+ manifest.lastEditedBy = CloudSqlite.getWriteLockHeldBy(container);
108
+ this.updateCatalogManifest(manifest);
109
+ }
110
+ // when saved, CatalogIModels should never have any Txns. If we wanted to create a changeset, we'd have to do it here.
111
+ this[_nativeDb].deleteAllTxns();
112
+ }
113
+ catch { } // ignore errors attempting to update
114
+ // might also want to vacuum here?
115
+ super.beforeClose();
116
+ }
117
+ }
118
+ function findCatalogByKey(key) {
119
+ return CatalogDbImpl.findByKey(key);
120
+ }
121
+ /** @beta */
122
+ export var CatalogDb;
123
+ (function (CatalogDb) {
124
+ /** Create a new [[BlobContainer]] to hold versions of a [[CatalogDb]].
125
+ * @returns The properties of the newly created container.
126
+ * @note creating new containers requires "admin" authorization.
127
+ */
128
+ async function createNewContainer(args) {
129
+ const dbName = catalogDbNameWithDefault(args.dbName);
130
+ CloudSqlite.validateDbName(dbName);
131
+ CloudSqlite.validateDbVersion(args.version);
132
+ const tmpName = join(KnownLocations.tmpdir, `temp-${dbName}`);
133
+ try {
134
+ // make a copy of the file they supplied so we can modify its contents safely
135
+ fs.copyFileSync(args.localCatalogFile, tmpName);
136
+ const nativeDb = new IModelNative.platform.DgnDb();
137
+ nativeDb.openIModel(tmpName, OpenMode.ReadWrite);
138
+ nativeDb.setITwinId(Guid.empty); // catalogs must be a StandaloneDb
139
+ nativeDb.setIModelId(Guid.createValue()); // make sure its iModelId is unique
140
+ updateManifest(nativeDb, args.manifest); // store the manifest inside the Catalog
141
+ nativeDb.deleteAllTxns(); // Catalogs should never have Txns (and, this must be empty before resetting BriefcaseId)
142
+ nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned); // catalogs should always be unassigned
143
+ nativeDb.saveChanges(); // save change to briefcaseId
144
+ nativeDb.vacuum();
145
+ nativeDb.closeFile();
146
+ }
147
+ catch (e) {
148
+ CatalogError.throwError("invalid-seed-catalog", { message: "Illegal seed catalog", ...args, cause: e });
149
+ }
150
+ const userToken = await IModelHost.getAccessToken();
151
+ // create tne new container from the blob service, requires "admin" authorization
152
+ const cloudContainerProps = await CloudSqlite.getBlobService().create({ scope: { iTwinId: args.iTwinId }, metadata: { ...args.metadata, containerType: "CatalogIModel" }, userToken });
153
+ // now create a CloudSqlite container object to access it
154
+ const container = CloudSqlite.createCloudContainer({
155
+ accessToken: await CloudSqlite.requestToken(cloudContainerProps),
156
+ accessLevel: "admin",
157
+ writeable: true,
158
+ baseUri: cloudContainerProps.baseUri,
159
+ containerId: cloudContainerProps.containerId,
160
+ storageType: cloudContainerProps.provider,
161
+ });
162
+ // initialize the container for use by CloudSqlite
163
+ container.initializeContainer({ blockSize: 4 * 1024 * 1024 });
164
+ container.connect(getWritableCloudCache());
165
+ // upload the initial version of the Catalog
166
+ await CloudSqlite.withWriteLock({ user: "initialize", container }, async () => {
167
+ await CloudSqlite.uploadDb(container, { dbName: CloudSqlite.makeSemverName(dbName, args.version), localFileName: tmpName });
168
+ fs.unlinkSync(tmpName); // delete temporary copy of catalog
169
+ });
170
+ container.disconnect();
171
+ return cloudContainerProps;
172
+ }
173
+ CatalogDb.createNewContainer = createNewContainer;
174
+ /** Acquire the write lock for a [CatalogIModel]($common) container. Only one person may obtain the write lock at a time.
175
+ * You must obtain the lock before attempting to write to the container via functions like [[CatalogDb.openEditable]] and [[CatalogDb.createNewVersion]].
176
+ * @note This requires "write" authorization to the container
177
+ */
178
+ async function acquireWriteLock(args) {
179
+ const container = await getWriteableContainer(args.containerId);
180
+ return CloudSqlite.acquireWriteLock({ container, user: args.username });
181
+ }
182
+ CatalogDb.acquireWriteLock = acquireWriteLock;
183
+ /** Release the write lock on a [CatalogIModel]($common) container. This uploads all changes made while the lock is held, so they become visible to other users. */
184
+ async function releaseWriteLock(args) {
185
+ const container = await getWriteableContainer(args.containerId);
186
+ if (args.abandon)
187
+ container.abandonChanges();
188
+ CloudSqlite.releaseWriteLock(container);
189
+ }
190
+ CatalogDb.releaseWriteLock = releaseWriteLock;
191
+ /** Open an [[EditableCatalogDb]] for write access.
192
+ * @note Once a version of a catalog iModel has been published (i.e. the write lock has been released), it is no longer editable, *unless* it is a prerelease version.
193
+ * @note The write lock must be held for this operation to succeed
194
+ */
195
+ async function openEditable(args) {
196
+ const dbName = catalogDbNameWithDefault(args.dbName);
197
+ if (undefined === args.containerId) // local file?
198
+ return EditableCatalogDbImpl.openFile(dbName, OpenMode.ReadWrite, args);
199
+ const container = await getWriteableContainer(args.containerId);
200
+ ensureLocked(container, "open a Catalog for editing"); // editing Catalogs requires the write lock
201
+ // look up the full name with version
202
+ const dbFullName = CloudSqlite.querySemverMatch({ container, dbName, version: args.version ?? "*" });
203
+ if (!CloudSqlite.isSemverEditable(dbFullName, container))
204
+ CloudSqliteError.throwError("already-published", { message: "Catalog has already been published and is not editable. Make a new version first.", ...args });
205
+ if (args.prefetch)
206
+ CloudSqlite.startCloudPrefetch(container, dbFullName);
207
+ return EditableCatalogDbImpl.openFile(dbFullName, OpenMode.ReadWrite, { container, ...args });
208
+ }
209
+ CatalogDb.openEditable = openEditable;
210
+ /** Open a [[CatalogDb]] for read-only access. */
211
+ async function openReadonly(args) {
212
+ const dbName = catalogDbNameWithDefault(args.dbName);
213
+ if (undefined === args.containerId) // local file?
214
+ return CatalogDbImpl.openFile(dbName, OpenMode.Readonly, args);
215
+ const container = await getReadonlyContainer(args.containerId);
216
+ if (args.syncWithCloud)
217
+ container.checkForChanges();
218
+ const dbFullName = CloudSqlite.querySemverMatch({ container, ...args, dbName });
219
+ if (args.prefetch)
220
+ CloudSqlite.startCloudPrefetch(container, dbFullName);
221
+ return CatalogDbImpl.openFile(dbFullName, OpenMode.Readonly, { container, ...args });
222
+ }
223
+ CatalogDb.openReadonly = openReadonly;
224
+ /**
225
+ * Create a new version of a [CatalogIModel]($common) as a copy of an existing version. Immediately after this operation, the new version will be an exact copy
226
+ * of the source CatalogIModel. Then, use [[CatalogDb.openEditable]] to modify the new version with new content.
227
+ * @note The write lock must be held for this operation to succeed
228
+ */
229
+ async function createNewVersion(args) {
230
+ const container = await getWriteableContainer(args.containerId);
231
+ ensureLocked(container, "create a new version");
232
+ return CloudSqlite.createNewDbVersion(container, { ...args, fromDb: { ...args.fromDb, dbName: catalogDbNameWithDefault(args.fromDb.dbName) } });
233
+ }
234
+ CatalogDb.createNewVersion = createNewVersion;
235
+ })(CatalogDb || (CatalogDb = {}));
236
+ /**
237
+ * Handler for Ipc access to CatalogIModels. Registered by NativeHost.
238
+ * @internal
239
+ */
240
+ export class CatalogIModelHandler extends IpcHandler {
241
+ get channelName() { return "catalogIModel/ipc"; }
242
+ async createNewContainer(args) {
243
+ return CatalogDb.createNewContainer(args);
244
+ }
245
+ async acquireWriteLock(args) {
246
+ return CatalogDb.acquireWriteLock(args);
247
+ }
248
+ async releaseWriteLock(args) {
249
+ return CatalogDb.releaseWriteLock(args);
250
+ }
251
+ async openReadonly(args) {
252
+ return ((await CatalogDb.openReadonly(args)).getConnectionProps());
253
+ }
254
+ async openEditable(args) {
255
+ return (await CatalogDb.openEditable(args)).getConnectionProps();
256
+ }
257
+ async createNewVersion(args) {
258
+ return CatalogDb.createNewVersion(args);
259
+ }
260
+ async getInfo(key) {
261
+ return findCatalogByKey(key).getInfo();
262
+ }
263
+ async updateCatalogManifest(key, manifest) {
264
+ findCatalogByKey(key).updateCatalogManifest(manifest);
265
+ }
266
+ }
267
+ //# sourceMappingURL=CatalogDb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CatalogDb.js","sourceRoot":"","sources":["../../src/CatalogDb.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAsB,gBAAgB,EAAyB,MAAM,oBAAoB,CAAC;AACjI,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAQzD,IAAI,kBAAiD,CAAC;AACtD,IAAI,mBAAkD,CAAC;AACvD,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAE9C,mHAAmH;AACnH,SAAS,cAAc,CAAC,GAAoC,EAAE,SAAkB;IAC9E,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAsB,CAAC;IACzE,qEAAqE;IACrE,IAAI,SAAS,KAAK,KAAK,CAAC,iBAAiB,EAAE,CAAC;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CAAC;IAC1C,CAAC;IACM,KAAK,CAAC,OAAO,CAAC,GAAW;QAC9B,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC;IACM,KAAK,CAAC,qBAAqB,CAAC,GAAW,EAAE,QAAgC;QAC9E,gBAAgB,CAAC,GAAG,CAAC,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module iModels\n */\n\nimport * as fs from \"fs\";\nimport { join } from \"path\";\nimport { CloudSqlite } from \"./CloudSqlite\";\nimport { IModelHost, KnownLocations } from \"./IModelHost\";\nimport { BriefcaseIdValue, CatalogError, type CatalogIModel, CloudSqliteError, IModelConnectionProps } from \"@itwin/core-common\";\nimport { IpcHandler } from \"./IpcHost\";\nimport { StandaloneDb } from \"./IModelDb\";\nimport { Guid, OpenMode } from \"@itwin/core-bentley\";\nimport { _nativeDb } from \"./internal/Symbols\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\n\ninterface CatalogCloudCache extends CloudSqlite.CloudCache {\n writeable: boolean;\n catalogContainers: Map<string, CloudSqlite.CloudContainer>;\n}\n\nlet readonlyCloudCache: CatalogCloudCache | undefined;\nlet writeableCloudCache: CatalogCloudCache | undefined;\nconst catalogManifestName = \"CatalogManifest\";\n\n// we make a readonly CloudCache and a writeable CloudCache. That way the access token authorizations are distinct.\nfunction makeCloudCache(arg: CloudSqlite.CreateCloudCacheArg, writeable: boolean) {\n const cache = CloudSqlite.CloudCaches.getCache(arg) as CatalogCloudCache;\n // if the cache was just created, add the \"catalog\" members as hidden\n if (undefined === cache.catalogContainers) {\n CloudSqlite.addHiddenProperty(cache, \"catalogContainers\", new Map<string, CloudSqlite.CloudContainer>());\n CloudSqlite.addHiddenProperty(cache, \"writeable\", writeable);\n }\n return cache;\n}\n\n// find an existing CloudContainer for accessing a CatalogIModel, or make a new one and connect it\nasync function getCatalogContainerObj(cache: CatalogCloudCache, containerId: string): Promise<CloudSqlite.CloudContainer> {\n const cloudContainer = cache.catalogContainers.get(containerId);\n if (undefined !== cloudContainer)\n return cloudContainer;\n\n const accessLevel = cache.writeable ? \"write\" : \"read\";\n const tokenProps = await CloudSqlite.getBlobService().requestToken({ containerId, accessLevel, userToken: await IModelHost.getAccessToken() });\n const container = CloudSqlite.createCloudContainer({\n accessLevel,\n baseUri: tokenProps.baseUri,\n containerId,\n storageType: tokenProps.provider,\n writeable: cache.writeable,\n accessToken: tokenProps.token\n });\n cache.catalogContainers.set(containerId, container); // save the container in the map of ContainerIds so we can reuse them\n container.connect(cache);\n return container;\n}\n\nfunction getReadonlyCloudCache() { return readonlyCloudCache ??= makeCloudCache({ cacheName: \"catalogs\", cacheSize: \"10G\" }, false) };\nfunction getWritableCloudCache() { return writeableCloudCache ??= makeCloudCache({ cacheName: \"writeableCatalogs\", cacheSize: \"10G\" }, true) };\nasync function getReadonlyContainer(containerId: string) { return getCatalogContainerObj(getReadonlyCloudCache(), containerId) };\nasync function getWriteableContainer(containerId: string) { return getCatalogContainerObj(getWritableCloudCache(), containerId) };\n\n/** Throw an error if the write lock is not held for the supplied container */\nfunction ensureLocked(container: CloudSqlite.CloudContainer, reason: string) {\n if (!container.hasWriteLock)\n CloudSqliteError.throwError(\"write-lock-not-held\", { message: `Write lock must be held to ${reason}` });\n}\n/** update the manifest in a CatalogIModel (calls `saveChanges`) */\nfunction updateManifest(nativeDb: IModelJsNative.DgnDb, manifest: CatalogIModel.Manifest) {\n nativeDb.saveLocalValue(catalogManifestName, JSON.stringify(manifest));\n nativeDb.saveChanges(\"update manifest\");\n}\nfunction catalogDbNameWithDefault(dbName?: string): string {\n return dbName ?? \"catalog-db\";\n}\n\n/** A [[StandaloneDb]] that provides read-only access to the contents of a [CatalogIModel]($common).\n * @see [[CatalogDb.openReadonly]] to instantiate this type.\n * @beta\n */\nexport interface CatalogDb extends StandaloneDb {\n /** Get the catalog's manifest. */\n getManifest(): CatalogIModel.Manifest | undefined;\n /** Get the catalog's version information. */\n getVersion(): string;\n /** Get the catalog's manifest and version. */\n getInfo(): { manifest?: CatalogIModel.Manifest, version: string };\n /** Returns true if the catalog was opened in read-write mode. */\n isEditable(): this is EditableCatalogDb;\n}\n\n/** A writable [[CatalogDb]].\n * @see [[CatalogDb.openEditable]] to instantiate this type.\n * @beta\n */\nexport interface EditableCatalogDb extends CatalogDb {\n /** Update the contents of the catalog manifest. */\n updateCatalogManifest(manifest: CatalogIModel.Manifest): void;\n}\n\n/** A StandaloneDb that holds a CatalogIModel */\nclass CatalogDbImpl extends StandaloneDb implements CatalogDb {\n public isEditable(): this is EditableCatalogDb {\n return false;\n }\n\n public getManifest(): CatalogIModel.Manifest | undefined {\n const manifestString = this[_nativeDb].queryLocalValue(catalogManifestName);\n if (undefined === manifestString)\n return undefined;\n return JSON.parse(manifestString) as CatalogIModel.Manifest;\n }\n\n public getVersion(): string {\n return CloudSqlite.parseDbFileName(this[_nativeDb].getFilePath()).version;\n }\n\n public getInfo() {\n return { manifest: this.getManifest(), version: this.getVersion() };\n }\n}\n\n/**\n * A CatalogDb that permits editing.\n * This class ensures that CatalogIModels never have a Txn table when they are published.\n * It also automatically updates the `lastEditedBy` field in the CatalogManifest.\n */\nclass EditableCatalogDbImpl extends CatalogDbImpl implements EditableCatalogDb {\n public override isEditable(): this is EditableCatalogDb {\n return true;\n }\n\n public updateCatalogManifest(manifest: CatalogIModel.Manifest): void {\n updateManifest(this[_nativeDb], manifest);\n }\n\n // Make sure the txn table is deleted and update the manifest every time we close.\n public override beforeClose(): void {\n try {\n const manifest = this.getManifest();\n const container = this.cloudContainer;\n if (container && manifest) {\n manifest.lastEditedBy = CloudSqlite.getWriteLockHeldBy(container);\n this.updateCatalogManifest(manifest);\n }\n\n // when saved, CatalogIModels should never have any Txns. If we wanted to create a changeset, we'd have to do it here.\n this[_nativeDb].deleteAllTxns();\n } catch { } // ignore errors attempting to update\n\n // might also want to vacuum here?\n super.beforeClose();\n }\n}\n\nfunction findCatalogByKey(key: string): CatalogDbImpl & EditableCatalogDb {\n return CatalogDbImpl.findByKey(key) as CatalogDbImpl & EditableCatalogDb;\n}\n\n/** @beta */\nexport namespace CatalogDb {\n /** Create a new [[BlobContainer]] to hold versions of a [[CatalogDb]].\n * @returns The properties of the newly created container.\n * @note creating new containers requires \"admin\" authorization.\n */\n export async function createNewContainer(args: CatalogIModel.CreateNewContainerArgs): Promise<CatalogIModel.NewContainerProps> {\n const dbName = catalogDbNameWithDefault(args.dbName);\n CloudSqlite.validateDbName(dbName);\n CloudSqlite.validateDbVersion(args.version);\n\n const tmpName = join(KnownLocations.tmpdir, `temp-${dbName}`);\n try {\n // make a copy of the file they supplied so we can modify its contents safely\n fs.copyFileSync(args.localCatalogFile, tmpName);\n const nativeDb = new IModelNative.platform.DgnDb();\n nativeDb.openIModel(tmpName, OpenMode.ReadWrite);\n nativeDb.setITwinId(Guid.empty); // catalogs must be a StandaloneDb\n nativeDb.setIModelId(Guid.createValue()); // make sure its iModelId is unique\n updateManifest(nativeDb, args.manifest); // store the manifest inside the Catalog\n nativeDb.deleteAllTxns(); // Catalogs should never have Txns (and, this must be empty before resetting BriefcaseId)\n nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned); // catalogs should always be unassigned\n nativeDb.saveChanges(); // save change to briefcaseId\n nativeDb.vacuum();\n nativeDb.closeFile();\n } catch (e: unknown) {\n CatalogError.throwError(\"invalid-seed-catalog\", { message: \"Illegal seed catalog\", ...args, cause: e });\n }\n\n const userToken = await IModelHost.getAccessToken();\n // create tne new container from the blob service, requires \"admin\" authorization\n const cloudContainerProps = await CloudSqlite.getBlobService().create({ scope: { iTwinId: args.iTwinId }, metadata: { ...args.metadata, containerType: \"CatalogIModel\" }, userToken });\n\n // now create a CloudSqlite container object to access it\n const container = CloudSqlite.createCloudContainer({\n accessToken: await CloudSqlite.requestToken(cloudContainerProps),\n accessLevel: \"admin\",\n writeable: true,\n baseUri: cloudContainerProps.baseUri,\n containerId: cloudContainerProps.containerId,\n storageType: cloudContainerProps.provider,\n });\n\n // initialize the container for use by CloudSqlite\n container.initializeContainer({ blockSize: 4 * 1024 * 1024 });\n container.connect(getWritableCloudCache());\n\n // upload the initial version of the Catalog\n await CloudSqlite.withWriteLock({ user: \"initialize\", container }, async () => {\n await CloudSqlite.uploadDb(container, { dbName: CloudSqlite.makeSemverName(dbName, args.version), localFileName: tmpName });\n fs.unlinkSync(tmpName); // delete temporary copy of catalog\n });\n container.disconnect();\n return cloudContainerProps;\n }\n\n /** Acquire the write lock for a [CatalogIModel]($common) container. Only one person may obtain the write lock at a time.\n * You must obtain the lock before attempting to write to the container via functions like [[CatalogDb.openEditable]] and [[CatalogDb.createNewVersion]].\n * @note This requires \"write\" authorization to the container\n */\n export async function acquireWriteLock(args: {\n /** The id of the container */\n containerId: string,\n /**\n * The name of the individual acquiring the lock. This will be shown to others who attempt to acquire the lock while it is held.\n * It is also stored in the \"lastEditedBy\" field of the manifest of any new version edited while the lock is held.\n */\n username: string;\n }): Promise<void> {\n const container = await getWriteableContainer(args.containerId);\n return CloudSqlite.acquireWriteLock({ container, user: args.username });\n }\n\n /** Release the write lock on a [CatalogIModel]($common) container. This uploads all changes made while the lock is held, so they become visible to other users. */\n export async function releaseWriteLock(args: {\n /** The id of the container */\n containerId: string,\n /** If true, abandon all local changes before releasing the lock */\n abandon?: true\n }): Promise<void> {\n const container = await getWriteableContainer(args.containerId);\n if (args.abandon)\n container.abandonChanges();\n CloudSqlite.releaseWriteLock(container);\n }\n\n /** Open an [[EditableCatalogDb]] for write access.\n * @note Once a version of a catalog iModel has been published (i.e. the write lock has been released), it is no longer editable, *unless* it is a prerelease version.\n * @note The write lock must be held for this operation to succeed\n */\n export async function openEditable(args: CatalogIModel.OpenArgs): Promise<EditableCatalogDb> {\n const dbName = catalogDbNameWithDefault(args.dbName);\n if (undefined === args.containerId) // local file?\n return EditableCatalogDbImpl.openFile(dbName, OpenMode.ReadWrite, args) as EditableCatalogDbImpl;\n\n const container = await getWriteableContainer(args.containerId);\n ensureLocked(container, \"open a Catalog for editing\"); // editing Catalogs requires the write lock\n\n // look up the full name with version\n const dbFullName = CloudSqlite.querySemverMatch({ container, dbName, version: args.version ?? \"*\" });\n if (!CloudSqlite.isSemverEditable(dbFullName, container))\n CloudSqliteError.throwError(\"already-published\", { message: \"Catalog has already been published and is not editable. Make a new version first.\", ...args })\n\n if (args.prefetch)\n CloudSqlite.startCloudPrefetch(container, dbFullName);\n\n return EditableCatalogDbImpl.openFile(dbFullName, OpenMode.ReadWrite, { container, ...args }) as EditableCatalogDbImpl;\n }\n\n /** Open a [[CatalogDb]] for read-only access. */\n export async function openReadonly(args: CatalogIModel.OpenArgs): Promise<CatalogDb> {\n const dbName = catalogDbNameWithDefault(args.dbName);\n if (undefined === args.containerId) // local file?\n return CatalogDbImpl.openFile(dbName, OpenMode.Readonly, args) as CatalogDbImpl;\n\n const container = await getReadonlyContainer(args.containerId);\n if (args.syncWithCloud)\n container.checkForChanges();\n\n const dbFullName = CloudSqlite.querySemverMatch({ container, ...args, dbName });\n if (args.prefetch)\n CloudSqlite.startCloudPrefetch(container, dbFullName);\n\n return CatalogDbImpl.openFile(dbFullName, OpenMode.Readonly, { container, ...args }) as CatalogDbImpl;\n }\n\n /**\n * Create a new version of a [CatalogIModel]($common) as a copy of an existing version. Immediately after this operation, the new version will be an exact copy\n * of the source CatalogIModel. Then, use [[CatalogDb.openEditable]] to modify the new version with new content.\n * @note The write lock must be held for this operation to succeed\n */\n export async function createNewVersion(args: CatalogIModel.CreateNewVersionArgs): Promise<{ oldDb: CatalogIModel.NameAndVersion; newDb: CatalogIModel.NameAndVersion; }> {\n const container = await getWriteableContainer(args.containerId);\n ensureLocked(container, \"create a new version\");\n return CloudSqlite.createNewDbVersion(container, { ...args, fromDb: { ...args.fromDb, dbName: catalogDbNameWithDefault(args.fromDb.dbName) } });\n }\n}\n\n/**\n * Handler for Ipc access to CatalogIModels. Registered by NativeHost.\n * @internal\n */\nexport class CatalogIModelHandler extends IpcHandler implements CatalogIModel.IpcMethods {\n public get channelName(): CatalogIModel.IpcChannel { return \"catalogIModel/ipc\"; }\n\n public async createNewContainer(args: CatalogIModel.CreateNewContainerArgs): Promise<CatalogIModel.NewContainerProps> {\n return CatalogDb.createNewContainer(args);\n }\n public async acquireWriteLock(args: { containerId: string, username: string; }): Promise<void> {\n return CatalogDb.acquireWriteLock(args);\n }\n public async releaseWriteLock(args: { containerId: string, abandon?: true; }): Promise<void> {\n return CatalogDb.releaseWriteLock(args);\n }\n public async openReadonly(args: CatalogIModel.OpenArgs): Promise<IModelConnectionProps> {\n return ((await CatalogDb.openReadonly(args)).getConnectionProps());\n }\n public async openEditable(args: CatalogIModel.OpenArgs): Promise<IModelConnectionProps> {\n return (await CatalogDb.openEditable(args)).getConnectionProps();\n }\n public async createNewVersion(args: CatalogIModel.CreateNewVersionArgs): Promise<{ oldDb: CatalogIModel.NameAndVersion; newDb: CatalogIModel.NameAndVersion; }> {\n return CatalogDb.createNewVersion(args);\n }\n public async getInfo(key: string): Promise<{ manifest?: CatalogIModel.Manifest, version: string }> {\n return findCatalogByKey(key).getInfo();\n }\n public async updateCatalogManifest(key: string, manifest: CatalogIModel.Manifest): Promise<void> {\n findCatalogByKey(key).updateCatalogManifest(manifest);\n }\n}\n"]}