/**
 * Sanity Canvas adapter — domain types.
 *
 * Narrows core's literal-free `DocSourceConfig` + ref interfaces to the
 * Canvas-specific shapes. Lives in the adapter directory so adding/removing
 * Canvas is a single-directory operation (mirrors the Drive adapter).
 */
import type { DocSourceConfig } from "../../../_vendor/ailf-core/index.d.ts";
/**
 * Which Canvas deployment the docs live in. The environment decides both
 * hosts — the Canvas CRUD API gateway and the dashboard — and the bearer
 * token must be issued for the same environment. Tokens are opaque, so a
 * mismatch only surfaces as the API's 401; the fetcher's auth error names
 * the environment and token env var to make that diagnosable.
 *
 * Deployment status: the Canvas CRUD API is currently served on **staging
 * only** (it ships behind an experimental feature flag that is off in
 * production). The `"production"` arm is wired so configs are ready the day
 * it ships — a production source today fails at first fetch with a 404 from
 * `api.sanity.io`. This is why `environment` is required rather than
 * defaulted: authors must state where their docs are.
 */
export type CanvasEnvironment = "production" | "staging";
/**
 * A Sanity Canvas doc source. Validated eagerly by `defineCanvasSource`.
 *
 * Canvas documents are unstructured markdown-first documents served by the
 * Canvas CRUD REST API (`GET …/documents/{id}?format=markdown` returns clean
 * markdown), so the fetcher needs no conversion step.
 *
 * `documentIds` is the whole-source corpus: the documents a ref-less task
 * receives as its context (the Canvas analogue of Drive's whole-folder
 * mode). Canvas has no folder hierarchy to enumerate, so the corpus is
 * declared explicitly.
 */
export interface CanvasSource extends DocSourceConfig {
    kind: "sanity-canvas";
    name: string;
    /** Canvas deployment the docs live in — required; see {@link CanvasEnvironment}. */
    environment: CanvasEnvironment;
    /** Organization id (`oXXXXXXXX`) — anchors dashboard links and URL validation. */
    organizationId: string;
    /** Canvas resource id — the `{resourceId}` segment of the CRUD API path. */
    resourceId: string;
    /** The doc corpus: Canvas document ids (whole-source context for ref-less tasks). */
    documentIds: string[];
    /**
     * Env var the bearer token is read from (default `AILF_CANVAS_TOKEN`).
     * Per-source so production and staging sources can coexist in one config.
     */
    tokenEnvVar?: string;
}
/**
 * A single Canvas document reference. `documentId` is the canvas document's
 * `_id` — the same value the dashboard doc URL ends in.
 */
export interface CanvasDocRef {
    kind: "canvas-doc";
    documentId: string;
    reason?: string;
}
