import { z } from 'zod'; /** * Import/export conversion job types shared between api and web (ADR 0009, * issue #62). A conversion runs asynchronously against the pandoc sidecar; * the client enqueues it and polls `GET /jobs/:id` for this view. */ export type ConversionJobStatus = 'pending' | 'running' | 'succeeded' | 'failed'; export interface ConversionJobView { id: string; status: ConversionJobStatus; kind: string; sourceFormat: string; targetFormat: string; /** Set only when `status` is `failed` — a code from the errors namespace * (`converter_unavailable` | `converter_timeout` | `conversion_failed` | * `quota_exceeded`). */ errorCode: string | null; /** Set once an import job (#63) succeeds: the id of the page it created, so * the client can navigate to it. `null` for a pending/failed import and for * plain byte→byte conversions (export). */ resultPageId: string | null; /** For a data-export job (#68), when its download link stops working — the * result is purged after this. `null` for every other job kind, which never * expires. */ expiresAt: string | null; createdAt: string; updatedAt: string; } /** Extensions the import endpoint accepts (ADR 0009, issues #63/#64). `.docx` * and `.odt` convert via the sidecar (a job to poll); `.md`/`.markdown` import * in-process and come back already `succeeded`. */ export const IMPORT_EXTENSIONS = ['docx', 'odt', 'md', 'markdown'] as const; export type ImportExtension = (typeof IMPORT_EXTENSIONS)[number]; /** Formats a single page exports to via a conversion job whose result is * downloaded from `GET /jobs/:id/result` (issues #65/#67). `docx`/`odt` run * `markdown → pandoc`; `pdf` renders HTML through Gotenberg. Markdown export is * a separate direct download (#30). */ export const EXPORT_FORMATS = ['docx', 'odt', 'pdf'] as const; export type ExportFormat = (typeof EXPORT_FORMATS)[number]; export const pageExportInputSchema = z.object({ format: z.enum(EXPORT_FORMATS), }); export type PageExportInput = z.infer;