/**
 * WorkspaceService — Shared versioned JSON document store with CAS
 *
 * Provides read/write/update operations on Workspaces using optimistic
 * locking (Compare-And-Swap). Each write must provide the expectedVersion
 * matching the current version; mismatches result in a conflict error.
 *
 * Storage: JSON files + atomic write (reuses atomicWriteJson from file-io.utils).
 *
 * Usage discipline (CEO requirement):
 * - Owner-only writes by default, configurable via allowedWriters
 * - Access mode controls overwrite vs append vs structured
 * - All writes are audited (lastWrittenBy, updatedAt)
 *
 * @module services/workspace/workspace.service
 */
import type { Workspace, CreateWorkspaceInput, WriteWorkspaceInput, StructuredWriteInput } from '../../types/v2/index.js';
/**
 * Abstraction over file I/O for workspace persistence.
 */
export interface WorkspaceStorage {
    /** Read a workspace from disk. Returns null if not found. */
    read(workspaceId: string): Promise<Workspace | null>;
    /** Write a workspace to disk (atomic). */
    write(workspace: Workspace): Promise<void>;
    /** Delete a workspace from disk. */
    delete(workspaceId: string): Promise<boolean>;
    /** List all workspace IDs. */
    listIds(): Promise<string[]>;
}
/**
 * File-based WorkspaceStorage using JSON files + atomic write.
 */
export declare class FileWorkspaceStorage implements WorkspaceStorage {
    private baseDir;
    constructor(baseDir: string);
    private filePath;
    read(workspaceId: string): Promise<Workspace | null>;
    write(workspace: Workspace): Promise<void>;
    delete(workspaceId: string): Promise<boolean>;
    listIds(): Promise<string[]>;
}
export declare class WorkspaceService {
    private storage;
    /**
     * Creates a new WorkspaceService.
     *
     * @param storage - Storage backend (FileWorkspaceStorage or mock for tests)
     */
    constructor(storage: WorkspaceStorage);
    /**
     * Creates a new workspace.
     *
     * @param input - Workspace creation parameters
     * @returns The created Workspace at version 1
     */
    create(input: CreateWorkspaceInput): Promise<Workspace>;
    /**
     * Reads a workspace by ID.
     *
     * @param workspaceId - The workspace ID
     * @returns The workspace, or null if not found
     */
    read(workspaceId: string): Promise<Workspace | null>;
    /**
     * Writes data to a workspace with CAS validation.
     *
     * The write semantics depend on the workspace's accessMode:
     * - overwrite: data replaces the entire workspace data
     * - append: data is shallow-merged with existing data
     * - structured: use writeStructured() instead
     *
     * @param workspaceId - The workspace to write to
     * @param input - Write input with expectedVersion and data
     * @returns The updated Workspace
     * @throws WorkspaceConflictError if version mismatch
     * @throws WorkspaceAccessError if writer not authorized
     * @throws Error if workspace not found
     */
    write(workspaceId: string, input: WriteWorkspaceInput): Promise<Workspace>;
    /**
     * Writes to a specific path within a structured workspace.
     *
     * @param workspaceId - The workspace to write to
     * @param input - Structured write input with path and value
     * @returns The updated Workspace
     * @throws WorkspaceConflictError if version mismatch
     * @throws WorkspaceAccessError if writer not authorized
     * @throws Error if workspace not found or not in structured mode
     */
    writeStructured(workspaceId: string, input: StructuredWriteInput): Promise<Workspace>;
    /**
     * Deletes a workspace.
     *
     * @param workspaceId - The workspace to delete
     * @returns True if deleted, false if not found
     */
    delete(workspaceId: string): Promise<boolean>;
    /**
     * Lists all workspaces (IDs only, for discovery).
     *
     * @returns Array of workspace IDs
     */
    listIds(): Promise<string[]>;
    /**
     * Lists all workspaces with full data.
     *
     * @returns Array of all Workspace objects
     */
    listAll(): Promise<Workspace[]>;
    /**
     * Checks whether a writer is authorized to write to a workspace.
     *
     * @param workspace - The workspace to check
     * @param writerId - The writer's identifier
     * @throws WorkspaceAccessError if not authorized
     */
    private checkWriteAccess;
}
//# sourceMappingURL=workspace.service.d.ts.map