import type { RelayFileClient } from "@relayfile/sdk"; export interface OpReceipt { opId: string; status: string; providerResult?: Record; lastError?: string | null; attemptCount?: number; } export interface CreateResult { /** The non-canonical draft filename we wrote to. */ draftPath: string; receipt: OpReceipt; /** Provider's returned id (e.g. Linear UUID). */ externalId?: string; /** Path under the same root where the canonical record will materialise. */ canonicalPath?: string; /** Provider-side URL, if returned. */ url?: string; } export interface WritebackApi { /** * Create a provider record by writing a schema-validated draft. * Polls the resulting op to `succeeded`, returns `providerResult.externalId` * and the conventional canonical path `{root}/{externalId}.json`. * * @param root e.g. `/linear/labels` * @param payload must validate against `{root}/.schema.json` */ create>(root: string, payload: T, opts?: { intervalMs?: number; timeoutMs?: number; }): Promise; /** * Read a canonical record, polling until it materialises in the Relayfile * mirror tree. After `create()` succeeds against the provider, the canonical * file at `/{provider}/{resource}/.json` arrives asynchronously * via inbound webhook sync — usually fast but variable. This wraps that * polling so `update`/`delete` paths don't need to babysit it. */ readCanonical(canonicalPath: string, opts?: { intervalMs?: number; timeoutMs?: number; }): Promise<{ revision: string; record: Record; }>; /** PATCH an existing canonical record. Polls the resulting op. */ update>(canonicalPath: string, baseRevision: string, patch: T, opts?: { intervalMs?: number; timeoutMs?: number; }): Promise<{ targetRevision: string; receipt: OpReceipt; }>; /** Delete a canonical record. Polls the resulting op. */ delete(canonicalPath: string, baseRevision: string, opts?: { intervalMs?: number; timeoutMs?: number; }): Promise<{ receipt: OpReceipt; }>; /** Delete an orphan draft receipt (local-only Relayfile cleanup, no provider effect). */ deleteDraft(draftPath: string): Promise<{ deleted: boolean; reason?: string; }>; } export declare function createWriteback(client: RelayFileClient, workspaceId: string): WritebackApi;