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]; /** What happens to a note's YAML frontmatter on vault import (issue #117): * dropped, or preserved as a yaml code block at the top of the page. */ export const VAULT_FRONTMATTER_MODES = ['strip', 'preserve'] as const; export type VaultFrontmatterMode = (typeof VAULT_FRONTMATTER_MODES)[number]; /** * Options of an Obsidian vault import (issue #117), sent as a JSON string in * the multipart `options` field and stored on the job row. `parentPageId` * mounts the vault under an existing page (null/absent = the pond root); * `labelIds` are assigned to every imported page on top of the tag labels. */ export const importVaultOptionsSchema = z.object({ parentPageId: z.string().min(1).nullish(), labelIds: z.array(z.string().min(1)).max(20).default([]), frontmatterMode: z.enum(VAULT_FRONTMATTER_MODES).default('strip'), }); export type ImportVaultOptions = z.infer; /** 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;