import type { StoryState } from '../core/types/story'; export type IdentifierValidation = { ok: boolean; errors: string[]; }; /** * Namespace for identifiers Mango generates itself, before an author has said * where the story will actually live. * * These are real HTTP(S) URIs so that a draft export is structurally valid * IIIF rather than a document nothing can read. They are deliberately *not* a * substitute for a publisher's own identifiers: they sit in a domain the * publisher does not control, so `validatePublicationIdentifiers` rejects them * for anything heading to publication. The `/stories/draft/` segment is what * makes that check possible, so it is load-bearing — a generated id must stay * recognisable as generated. * * A URN was the obvious alternative and was tried first. It is honest about * being unresolvable, but it makes every draft fail IIIF's requirement that an * AnnotationPage and an Annotation carry an HTTP(S) id, which in turn made the * whole draft profile unvalidatable. `localhost` was rejected for the opposite * reason: it passes a syntax check while pointing at whatever happens to be * running on the reader's machine — `validatePublicIdentifier` already refuses * it for author-supplied ids for exactly that reason. */ export declare const MANGO_DRAFT_ID_BASE = "https://mangoviewer.dev/stories/draft/"; /** * Last-resort id for a story that reached serialisation without one. Stable * rather than freshly generated: serialisation has to be deterministic, or * every export of the same story would differ and round-trip comparisons * would be meaningless. Stories created through the builder are given their * own generated id up front, so this is a safety net, not the normal path. */ export declare const MANGO_DRAFT_FALLBACK_ID = "https://mangoviewer.dev/stories/draft/untitled"; /** * Identifiers written before drafts carried an HTTP(S) id. Dropped on load * rather than preserved, so the story picks up a generated one and its next * export is valid IIIF instead of inheriting a URN that never was. */ export declare const LEGACY_DRAFT_ID_PREFIX = "urn:mango:draft:"; export declare const isLegacyDraftId: (value: string | undefined | null) => boolean; /** True for an id Mango generated, as opposed to one an author chose. */ export declare const isGeneratedDraftId: (value: string | undefined | null) => boolean; /** A fresh draft identifier for a story that has just been created. */ export declare const createDraftStoryId: () => string; export declare const validatePublicIdentifier: (value: string, label?: string) => string[]; export declare const deriveChapterAnnotationBase: (story: StoryState) => string | undefined; export declare const buildChapterAnnotationId: (story: StoryState, chapterId: string) => string; export type PublicationValidationOptions = { requirePublishableId?: boolean; }; export declare const validatePublicationIdentifiers: (story: StoryState, options?: PublicationValidationOptions) => IdentifierValidation;