import { Database } from "bun:sqlite";
import { LEGACY_PROJECT_CANVAS_TABLE, PROJECT_STORE_TABLES } from "./store-adoption.js";
import type { JsonObject, Workspace } from "../types/workspace.js";
export { PROJECTS_HOME_ENV } from "../lib/project-store-paths.js";
export declare const PROJECT_STORE_SCHEMA_VERSION: 3;
export declare const PROJECT_STORE_OWNER_META_KEY: "owner_project_id";
export declare const LEGACY_PROJECT_CANVAS_EXPORT_SCHEMA: "hasna.projects_legacy_canvas_export.v1";
export { PROJECT_STORE_TABLES };
export type ProjectStoreTable = (typeof PROJECT_STORE_TABLES)[number];
export type ProjectStoreProject = Pick<Workspace, "id" | "name" | "slug" | "status" | "kind" | "primary_path">;
export interface ProjectStorePaths extends JsonObject {
    project_id: string;
    home_dir: string;
    project_dir: string;
    db_path: string;
    assets_dir: string;
}
export interface LegacyProjectCanvasNode extends JsonObject {
    id: string;
    type?: string;
    position: {
        x: number;
        y: number;
    };
    data: JsonObject;
    width?: number;
    height?: number;
}
export interface LegacyProjectCanvasEdge extends JsonObject {
    id: string;
    source: string;
    target: string;
    sourceHandle?: string;
    targetHandle?: string;
    label?: string;
    type?: string;
    data?: JsonObject;
}
export interface LegacyProjectCanvasMigrationRecord extends JsonObject {
    id: string;
    source_ref: string;
    slug: string;
    name: string;
    description: string | null;
    status: string;
    layout_engine: string;
    viewport: JsonObject;
    nodes: LegacyProjectCanvasNode[];
    edges: LegacyProjectCanvasEdge[];
    data: JsonObject;
    metadata: JsonObject;
    created_at: string;
    updated_at: string;
}
export interface LegacyProjectCanvasStorage extends JsonObject {
    state: "absent" | "present";
    read_only: true;
    table: typeof LEGACY_PROJECT_CANVAS_TABLE;
    table_exists: boolean;
    record_count: number;
    db_path: string;
    files_path: string;
    files_path_exists: boolean;
    export_schema: typeof LEGACY_PROJECT_CANVAS_EXPORT_SCHEMA;
}
export interface LegacyProjectCanvasMigrationSource extends JsonObject {
    schema: typeof LEGACY_PROJECT_CANVAS_EXPORT_SCHEMA;
    project_id: string;
    read_only: true;
    source: LegacyProjectCanvasStorage;
    canvases: LegacyProjectCanvasMigrationRecord[];
}
export interface ProjectDataModel extends JsonObject {
    id: string;
    slug: string;
    name: string;
    description: string | null;
    schema: JsonObject;
    ui_schema: JsonObject;
    render_spec: JsonObject | null;
    metadata: JsonObject;
    created_at: string;
    updated_at: string;
}
export interface CreateProjectDataModelInput {
    name: string;
    slug?: string;
    description?: string;
    schema?: JsonObject;
    ui_schema?: JsonObject;
    render_spec?: JsonObject;
    metadata?: JsonObject;
}
export interface ProjectDataRecord extends JsonObject {
    id: string;
    model_id: string;
    key: string;
    title: string | null;
    data: JsonObject;
    render_spec: JsonObject | null;
    metadata: JsonObject;
    created_at: string;
    updated_at: string;
}
export interface CreateProjectDataRecordInput {
    model_id: string;
    key?: string;
    title?: string;
    data?: JsonObject;
    render_spec?: JsonObject;
    metadata?: JsonObject;
}
export interface ProjectDataRecordDeleteTarget {
    id: string;
    model_id: string;
}
export interface ProjectDataModelDeleteTarget {
    id: string;
    slug: string;
}
export interface DeleteProjectDataExactInput {
    record_targets: readonly ProjectDataRecordDeleteTarget[];
    expected_record_count: number;
    model_targets: readonly ProjectDataModelDeleteTarget[];
    expected_model_count: number;
}
export interface ProjectDataExactDeleteResult extends JsonObject {
    deleted_record_ids: string[];
    deleted_record_count: number;
    deleted_model_ids: string[];
    deleted_model_count: number;
}
export interface ProjectLoopLink extends JsonObject {
    id: string;
    loop_id: string;
    loop_name: string | null;
    role: string;
    metadata: JsonObject;
    created_at: string;
    updated_at: string;
}
export interface LinkProjectLoopInput {
    loop_id: string;
    loop_name?: string;
    role?: string;
    metadata?: JsonObject;
}
export interface ProjectLoopRunSummary extends JsonObject {
    id: string;
    scheduled_for: string;
    attempt: number;
    status: string;
    started_at?: string;
    finished_at?: string;
    exit_code?: number;
    duration_ms?: number;
    error?: string;
}
export interface ProjectLoopSummary extends JsonObject {
    link: ProjectLoopLink;
    status: "linked" | "missing" | "unavailable";
    loop: JsonObject | null;
    runs: ProjectLoopRunSummary[];
    error?: string;
}
export interface ProjectStoreSummary extends JsonObject {
    project_id: string;
    paths: ProjectStorePaths;
    exists: boolean;
    schema_version: number | null;
    counts: {
        data_models: number;
        data_records: number;
        loop_links: number;
    };
    legacy_canvas_storage: LegacyProjectCanvasStorage;
    loops?: ProjectLoopSummary[];
}
export interface LoopsClientLike {
    get(idOrName: string): unknown | Promise<unknown>;
    runs(loopId?: string): unknown[];
    close?(): void;
}
export declare function getProjectsHome(): string;
export declare function getProjectStorePaths(project: string | Pick<Workspace, "id">): ProjectStorePaths;
export declare function ensureProjectStoreDirs(project: string | Pick<Workspace, "id">): ProjectStorePaths;
export declare function runProjectStoreMigrations(db: Database): void;
export declare function inspectProjectStoreOwner(project: string | Pick<Workspace, "id">): string | null;
export declare function getProjectDatabase(project: string | Pick<Workspace, "id">): Database;
export declare function ensureProjectStore(project: string | Pick<Workspace, "id">): ProjectStoreSummary;
export declare function createProjectDataModel(project: string | Pick<Workspace, "id">, input: CreateProjectDataModelInput, db?: Database): ProjectDataModel;
export declare function listProjectDataModels(project: string | Pick<Workspace, "id">, db?: Database): ProjectDataModel[];
export declare function getProjectDataModel(project: string | Pick<Workspace, "id">, idOrSlug: string, db?: Database): ProjectDataModel | null;
export declare function createProjectDataRecord(project: string | Pick<Workspace, "id">, input: CreateProjectDataRecordInput, db?: Database): ProjectDataRecord;
export declare function listProjectDataRecords(project: string | Pick<Workspace, "id">, modelId: string, db?: Database): ProjectDataRecord[];
export declare function getProjectDataRecord(project: string | Pick<Workspace, "id">, modelId: string, keyOrId: string, db?: Database): ProjectDataRecord | null;
export declare function deleteProjectDataExact(project: string | Pick<Workspace, "id">, db: Database, input: DeleteProjectDataExactInput): ProjectDataExactDeleteResult;
export declare function linkProjectLoop(project: string | Pick<Workspace, "id">, input: LinkProjectLoopInput, db?: Database): ProjectLoopLink;
export declare function getProjectLoopLink(project: string | Pick<Workspace, "id">, loopId: string, db?: Database): ProjectLoopLink | null;
export declare function listProjectLoopLinks(project: string | Pick<Workspace, "id">, db?: Database): ProjectLoopLink[];
export declare function listProjectLoopSummaries(project: string | Pick<Workspace, "id">, options?: {
    db?: Database;
    loopsClient?: LoopsClientLike;
    includeRuns?: boolean;
    runLimit?: number;
}): Promise<ProjectLoopSummary[]>;
export declare function inspectProjectStore(project: string | Pick<Workspace, "id">, options?: {
    db?: Database;
}): ProjectStoreSummary;
/**
 * Inspect an already-present app store without running migrations or binding
 * ownership. This is the producer for dry-run planning: reading a preview must
 * never initialize or upgrade the file it is describing.
 */
export declare function inspectProjectStoreReadOnly(project: string | Pick<Workspace, "id">): ProjectStoreSummary;
/**
 * Inventory the retired Projects-owned canvas store without creating, updating,
 * or deleting it. Existing rows and files remain in place until a separately
 * approved Canvases migration consumes the read-only source.
 */
export declare function inspectLegacyProjectCanvasStorage(project: string | Pick<Workspace, "id">, db?: Database): LegacyProjectCanvasStorage;
/**
 * Read the complete legacy canvas payload for a future migration adapter.
 * This compatibility seam is deliberately read-only and performs no schema
 * migration, writes, remote calls, or Canvases product behavior.
 */
export declare function readLegacyProjectCanvasMigrationSource(project: string | Pick<Workspace, "id">): LegacyProjectCanvasMigrationSource;
export declare function inspectProjectStoreWithLoops(project: string | Pick<Workspace, "id">, options?: {
    db?: Database;
    loopsClient?: LoopsClientLike;
    includeRuns?: boolean;
}): Promise<ProjectStoreSummary>;
//# sourceMappingURL=project-store.d.ts.map