/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Workspace
 */
import { BlobContainer } from "../BlobContainerService";
import { WorkspaceSqliteDb } from "../internal/workspace/WorkspaceSqliteDb";
import { constructWorkspaceEditor } from "../internal/workspace/WorkspaceImpl";
import { _implementationProhibited } from "../internal/Symbols";
import { IModelHost } from "../IModelHost";
/** @beta */
export var WorkspaceEditor;
(function (WorkspaceEditor) {
    /**
     * Create a new [[WorkspaceEditor]] for creating new versions of [[WorkspaceDb]]s.
     * @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.
     * @note It is illegal to have more than one Workspace.Editor active in a single session.
     */
    function construct() {
        return constructWorkspaceEditor();
    }
    WorkspaceEditor.construct = construct;
    /**
     * Create a new, empty, [[EditableWorkspaceDb]] file on the local filesystem for importing [[Workspace]] resources.
     * @note Do not pass an untrusted or unintended path in `localFileName`.
     * This helper creates or overwrites the file at that location; callers that need fail-if-exists behavior should check first.
     */
    function createEmptyDb(args) {
        WorkspaceSqliteDb.createNewDb(args.localFileName, args);
    }
    WorkspaceEditor.createEmptyDb = createEmptyDb;
    /**
     * Query the [[BlobContainer]] service for all workspace containers associated with a given iTwin.
     * This is a convenience wrapper around `BlobContainer.service.queryContainersMetadata` that
     * automatically filters by `containerType: "workspace"`.
     * @param args - The query arguments including the iTwinId.
     * @returns A promise that resolves to the matching container metadata entries.
     * @note Requires [[IModelHost.authorizationClient]] to be configured.
     */
    async function queryContainers(args) {
        if (undefined === BlobContainer.service)
            throw new Error("BlobContainer.service is not available. Ensure IModelHost is initialized with a valid configuration.");
        const userToken = await IModelHost.getAccessToken();
        return BlobContainer.service.queryContainersMetadata(userToken, { ...args, containerType: args.containerType ?? "workspace" });
    }
    WorkspaceEditor.queryContainers = queryContainers;
})(WorkspaceEditor || (WorkspaceEditor = {}));
//# sourceMappingURL=WorkspaceEditor.js.map