UNPKG

@itwin/core-frontend

Version:
95 lines 4.84 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module IModelConnection */ Object.defineProperty(exports, "__esModule", { value: true }); exports.CatalogConnection = void 0; const core_common_1 = require("@itwin/core-common"); const BriefcaseConnection_1 = require("./BriefcaseConnection"); const core_bentley_1 = require("@itwin/core-bentley"); const NativeApp_1 = require("./NativeApp"); /** @beta */ var CatalogConnection; (function (CatalogConnection) { /** Create a new [BlobContainer]($backend) to hold versions of a [CatalogIModel]($common). * @returns The properties of the newly created container. * @note creating new containers requires "admin" authorization. */ async function createNewContainer(args) { return NativeApp_1.NativeApp.catalogIpc.createNewContainer(args); } CatalogConnection.createNewContainer = createNewContainer; /** Acquire the write lock for a CatalogIModel container. Only one person may obtain the write lock at a time. * @note this requires "write" authorization to the container */ async function acquireWriteLock(args) { return NativeApp_1.NativeApp.catalogIpc.acquireWriteLock(args); } CatalogConnection.acquireWriteLock = acquireWriteLock; /** Release the write lock on a CatalogIModel container. This uploads all changes made while the lock is held, so they become visible to other users. */ async function releaseWriteLock(args) { return NativeApp_1.NativeApp.catalogIpc.releaseWriteLock(args); } CatalogConnection.releaseWriteLock = releaseWriteLock; /** * Create a new version of a CatalogIModel 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 [[openEditable]] to modify the new version with new content. * @note the write lock must be held for this operation to succeed * @see [[acquireWriteLock]] */ async function createNewVersion(args) { return NativeApp_1.NativeApp.catalogIpc.createNewVersion(args); } CatalogConnection.createNewVersion = createNewVersion; /** Open a CatalogIModel for read access. * @returns the [[CatalogConnection]] to access the contents of the Catalog. * @note CatalogConnection extends BriefcaseConnection. When finished reading, call `close` on the connection. */ async function openReadonly(args) { const openResponse = await NativeApp_1.NativeApp.catalogIpc.openReadonly(args); const connection = new CatalogConnectionImpl(openResponse, core_bentley_1.OpenMode.Readonly); BriefcaseConnection_1.BriefcaseConnection.onOpen.raiseEvent(connection); return connection; } CatalogConnection.openReadonly = openReadonly; /** Open a CatalogIModel for write access. * @note Once a version of a CatalogIModel 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 */ async function openEditable(args) { const openResponse = await NativeApp_1.NativeApp.catalogIpc.openEditable(args); const connection = new EditableCatalogConnectionImpl(openResponse, core_bentley_1.OpenMode.ReadWrite); BriefcaseConnection_1.BriefcaseConnection.onOpen.raiseEvent(connection); return connection; } CatalogConnection.openEditable = openEditable; })(CatalogConnection || (exports.CatalogConnection = CatalogConnection = {})); class CatalogConnectionImpl extends BriefcaseConnection_1.BriefcaseConnection { constructor(props, openMode) { super(props, openMode); } requireTimeline() { throw new core_common_1.IModelError(core_bentley_1.IModelStatus.WrongIModel, "Catalogs have no timeline"); } /** Get the manifest and version information for an open CatalogConnection. */ async getCatalogInfo() { return NativeApp_1.NativeApp.catalogIpc.getInfo(this.key); } isEditable() { return false; } } class EditableCatalogConnectionImpl extends CatalogConnectionImpl { /** Update the contents of the manifest in a CatalogIModel that is open with [[openEditable]]. */ async updateManifest(manifest) { return NativeApp_1.NativeApp.catalogIpc.updateCatalogManifest(this.key, manifest); } isEditable() { return true; } } //# sourceMappingURL=CatalogConnection.js.map