/**
 * HTTP Sync Handlers - Browser sync support via HTTP endpoints
 *
 * Provides framework-agnostic handlers for browser sync operations.
 * These can be integrated with any HTTP framework (Bun.serve, Express, Hono, etc.)
 *
 * Implements the browser sync protocol from api/sync.md:
 * 1. Browser exports local changes
 * 2. HTTP POST to server with JSONL
 * 3. Server merges with its state
 * 4. Server exports current state
 * 5. HTTP response with JSONL
 * 6. Browser imports and merges
 */
import type { StorageBackend } from '@stoneforge/storage';
import type { ImportResult, SyncStatus } from '../sync/types.js';
/**
 * Request body for browser sync pull (export from server)
 */
export interface SyncPullRequest {
    /** Include ephemeral elements in export */
    includeEphemeral?: boolean;
    /** Include dependencies in export */
    includeDependencies?: boolean;
}
/**
 * Response for browser sync pull
 */
export interface SyncPullResponse {
    /** JSONL string of elements */
    elements: string;
    /** JSONL string of dependencies (if requested) */
    dependencies?: string;
    /** Element count */
    elementCount: number;
    /** Dependency count (if included) */
    dependencyCount?: number;
    /** Export timestamp */
    exportedAt: string;
}
/**
 * Request body for browser sync push (import to server)
 */
export interface SyncPushRequest {
    /** JSONL string of elements to import */
    elements: string;
    /** JSONL string of dependencies to import */
    dependencies?: string;
    /** Dry run - validate without applying changes */
    dryRun?: boolean;
    /** Force - remote always wins conflicts */
    force?: boolean;
}
/**
 * Response for browser sync push
 */
export interface SyncPushResponse {
    /** Import result with counts and conflicts */
    result: ImportResult;
    /** Server's current state after merge (for client to sync) */
    serverState?: SyncPullResponse;
}
/**
 * Request/Response for full bidirectional sync
 */
export interface SyncExchangeRequest {
    /** Client's elements to import */
    elements: string;
    /** Client's dependencies to import */
    dependencies?: string;
    /** Force - remote always wins conflicts */
    force?: boolean;
}
export interface SyncExchangeResponse {
    /** Import result from processing client data */
    importResult: ImportResult;
    /** Server's current state (for client to import) */
    serverElements: string;
    /** Server's dependencies (for client to import) */
    serverDependencies: string;
    /** Counts for client reference */
    serverElementCount: number;
    serverDependencyCount: number;
    /** Sync timestamp */
    syncedAt: string;
}
/**
 * HTTP response envelope
 */
export interface HttpResponse<T> {
    success: boolean;
    data?: T;
    error?: {
        code: string;
        message: string;
        details?: Record<string, unknown>;
    };
}
/**
 * HTTP handlers for browser sync operations
 */
export declare class SyncHttpHandlers {
    private backend;
    private syncService;
    constructor(backend: StorageBackend);
    /**
     * Handle GET /api/sync/status
     *
     * Returns current sync status including dirty element count
     */
    getStatus(): HttpResponse<SyncStatus>;
    /**
     * Handle GET /api/sync/pull or POST /api/sync/pull
     *
     * Exports server state as JSONL for client to import
     */
    pull(request?: SyncPullRequest): HttpResponse<SyncPullResponse>;
    /**
     * Handle POST /api/sync/push
     *
     * Imports client JSONL data to server
     */
    push(request: SyncPushRequest): HttpResponse<SyncPushResponse>;
    /**
     * Handle POST /api/sync/exchange
     *
     * Bidirectional sync in a single request:
     * 1. Import client data
     * 2. Export server state
     * 3. Return both results
     */
    exchange(request: SyncExchangeRequest): HttpResponse<SyncExchangeResponse>;
    /**
     * Handle errors and return appropriate HTTP response
     */
    private handleError;
}
/**
 * Create sync HTTP handlers for a storage backend
 */
export declare function createSyncHttpHandlers(backend: StorageBackend): SyncHttpHandlers;
/**
 * Map response to HTTP status code
 */
export declare function getHttpStatus(response: HttpResponse<unknown>): number;
/**
 * Supported content types for sync endpoints
 */
export declare const SYNC_CONTENT_TYPES: {
    readonly JSON: "application/json";
    readonly JSONL: "application/jsonl";
    readonly NDJSON: "application/x-ndjson";
};
/**
 * Parse request body based on content type
 */
export declare function parseRequestBody<T>(body: string, _contentType?: string): T;
/**
 * Serialize response based on accept header
 */
export declare function serializeResponse<T>(response: HttpResponse<T>): string;
//# sourceMappingURL=sync-handlers.d.ts.map