@itwin/core-backend
Version:
iTwin.js backend components
103 lines • 4.94 kB
TypeScript
/** @packageDocumentation
* @module iModels
*/
import { type CatalogIModel, IModelConnectionProps } from "@itwin/core-common";
import { IpcHandler } from "./IpcHost";
import { StandaloneDb } from "./IModelDb";
/** A [[StandaloneDb]] that provides read-only access to the contents of a [CatalogIModel]($common).
* @see [[CatalogDb.openReadonly]] to instantiate this type.
* @beta
*/
export interface CatalogDb extends StandaloneDb {
/** Get the catalog's manifest. */
getManifest(): CatalogIModel.Manifest | undefined;
/** Get the catalog's version information. */
getVersion(): string;
/** Get the catalog's manifest and version. */
getInfo(): {
manifest?: CatalogIModel.Manifest;
version: string;
};
/** Returns true if the catalog was opened in read-write mode. */
isEditable(): this is EditableCatalogDb;
}
/** A writable [[CatalogDb]].
* @see [[CatalogDb.openEditable]] to instantiate this type.
* @beta
*/
export interface EditableCatalogDb extends CatalogDb {
/** Update the contents of the catalog manifest. */
updateCatalogManifest(manifest: CatalogIModel.Manifest): void;
}
/** @beta */
export declare namespace CatalogDb {
/** Create a new [[BlobContainer]] to hold versions of a [[CatalogDb]].
* @returns The properties of the newly created container.
* @note creating new containers requires "admin" authorization.
*/
function createNewContainer(args: CatalogIModel.CreateNewContainerArgs): Promise<CatalogIModel.NewContainerProps>;
/** Acquire the write lock for a [CatalogIModel]($common) container. Only one person may obtain the write lock at a time.
* You must obtain the lock before attempting to write to the container via functions like [[CatalogDb.openEditable]] and [[CatalogDb.createNewVersion]].
* @note This requires "write" authorization to the container
*/
function acquireWriteLock(args: {
/** The id of the container */
containerId: string;
/**
* The name of the individual acquiring the lock. This will be shown to others who attempt to acquire the lock while it is held.
* It is also stored in the "lastEditedBy" field of the manifest of any new version edited while the lock is held.
*/
username: string;
}): Promise<void>;
/** 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. */
function releaseWriteLock(args: {
/** The id of the container */
containerId: string;
/** If true, abandon all local changes before releasing the lock */
abandon?: true;
}): Promise<void>;
/** Open an [[EditableCatalogDb]] for write access.
* @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.
* @note The write lock must be held for this operation to succeed
*/
function openEditable(args: CatalogIModel.OpenArgs): Promise<EditableCatalogDb>;
/** Open a [[CatalogDb]] for read-only access. */
function openReadonly(args: CatalogIModel.OpenArgs): Promise<CatalogDb>;
/**
* 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
* of the source CatalogIModel. Then, use [[CatalogDb.openEditable]] to modify the new version with new content.
* @note The write lock must be held for this operation to succeed
*/
function createNewVersion(args: CatalogIModel.CreateNewVersionArgs): Promise<{
oldDb: CatalogIModel.NameAndVersion;
newDb: CatalogIModel.NameAndVersion;
}>;
}
/**
* Handler for Ipc access to CatalogIModels. Registered by NativeHost.
* @internal
*/
export declare class CatalogIModelHandler extends IpcHandler implements CatalogIModel.IpcMethods {
get channelName(): CatalogIModel.IpcChannel;
createNewContainer(args: CatalogIModel.CreateNewContainerArgs): Promise<CatalogIModel.NewContainerProps>;
acquireWriteLock(args: {
containerId: string;
username: string;
}): Promise<void>;
releaseWriteLock(args: {
containerId: string;
abandon?: true;
}): Promise<void>;
openReadonly(args: CatalogIModel.OpenArgs): Promise<IModelConnectionProps>;
openEditable(args: CatalogIModel.OpenArgs): Promise<IModelConnectionProps>;
createNewVersion(args: CatalogIModel.CreateNewVersionArgs): Promise<{
oldDb: CatalogIModel.NameAndVersion;
newDb: CatalogIModel.NameAndVersion;
}>;
getInfo(key: string): Promise<{
manifest?: CatalogIModel.Manifest;
version: string;
}>;
updateCatalogManifest(key: string, manifest: CatalogIModel.Manifest): Promise<void>;
}
//# sourceMappingURL=CatalogDb.d.ts.map