/** * @fileoverview Version history type definitions for @writenex/astro * * This file contains all TypeScript type definitions related to version history, * including version entries, manifests, and operation results. * * @module @writenex/astro/types/version */ /** * Version entry metadata stored in manifest * * Represents a single version snapshot of a content item. */ interface VersionEntry { /** Unique version ID (ISO timestamp with hyphens instead of colons) */ id: string; /** When this version was created (ISO string for JSON serialization) */ timestamp: string; /** First 100 characters of content for preview */ preview: string; /** File size in bytes */ size: number; /** Optional label for manual snapshots */ label?: string; } /** * Version manifest for a content item * * Tracks all versions for a specific content item in a JSON file. */ interface VersionManifest { /** Content item identifier (slug) */ contentId: string; /** Collection name */ collection: string; /** List of version entries */ versions: VersionEntry[]; /** When manifest was last updated (ISO string for JSON serialization) */ updatedAt: string; } /** * Full version data including content * * Extends VersionEntry with the actual content of the version. */ interface Version extends VersionEntry { /** Full markdown content */ content: string; /** Parsed frontmatter */ frontmatter: Record; /** Markdown body */ body: string; } /** * Version history configuration * * Controls how version history behaves for the project. * All fields are optional - defaults are applied via applyConfigDefaults(). */ interface VersionHistoryConfig { /** Enable/disable version history (default: true) */ enabled?: boolean; /** Maximum versions to keep per content item, unlabeled only (default: 20) */ maxVersions?: number; /** Storage path relative to project root (default: ".writenex/versions") */ storagePath?: string; } /** * Result of version operations * * Returned by version CRUD operations to indicate success/failure. */ interface VersionResult { /** Whether the operation succeeded */ success: boolean; /** Version entry if operation created/retrieved one */ version?: VersionEntry; /** Error message if operation failed */ error?: string; } /** * Options for saving a version */ interface SaveVersionOptions { /** Optional label for the version */ label?: string; /** Skip if content is identical to last version */ skipIfIdentical?: boolean; } /** * Options for restoring a version */ interface RestoreVersionOptions { /** Label for the safety snapshot created before restore */ safetySnapshotLabel?: string; /** Skip creating safety snapshot (not recommended) */ skipSafetySnapshot?: boolean; } /** * Result of a restore operation * * Extends VersionResult with additional restore-specific fields. */ interface RestoreResult extends VersionResult { /** The restored content */ content?: string; /** The safety snapshot version entry (if created) */ safetySnapshot?: VersionEntry; } /** * @fileoverview Configuration-related type definitions for @writenex/astro * * This file contains all TypeScript type definitions related to configuration, * including collection config, image config, editor config, and discovery config. * * @module @writenex/astro/types/config */ type FieldKind = "text" | "slug" | "url" | "number" | "integer" | "select" | "multiselect" | "checkbox" | "date" | "datetime" | "image" | "file" | "object" | "array" | "blocks" | "relationship" | "path-reference" | "markdoc" | "mdx" | "conditional" | "child" | "cloud-image" | "empty" | "empty-content" | "empty-document" | "ignored"; type FieldType = "string" | "number" | "boolean" | "date" | "array" | "image" | "object" | "file" | "blocks" | "relationship" | "markdoc" | "mdx" | "child" | "slug" | "url" | "integer" | "select" | "multiselect" | "datetime" | "cloud-image" | "path-reference" | "conditional" | "empty" | "empty-content" | "empty-document" | "ignored" | "checkbox"; interface ValidationOptions { isRequired?: boolean; min?: number; max?: number; minLength?: number; maxLength?: number; pattern?: string; patternDescription?: string; } interface SchemaField { type: FieldType; required?: boolean; default?: unknown; items?: string; description?: string; label?: string; options?: string[]; directory?: string; publicPath?: string; validation?: ValidationOptions; fields?: Record; itemField?: SchemaField; blockTypes?: Record; collection?: string; multiline?: boolean; format?: string; itemLabel?: string; matchField?: string; matchValue?: unknown; showField?: SchemaField; accept?: string; allowExternal?: boolean; inline?: boolean; } type CollectionSchema = Record; type ImageStrategy = "colocated" | "public" | "custom"; interface ImageConfig { strategy: ImageStrategy; publicPath?: string; storagePath?: string; } interface CollectionConfig { name: string; path: string; filePattern?: string; previewUrl?: string; schema?: CollectionSchema; images?: ImageConfig; } interface SingletonConfig { name: string; path: string; previewUrl?: string; schema?: CollectionSchema; images?: ImageConfig; } interface DiscoveryConfig { enabled: boolean; ignore?: string[]; } interface EditorConfig { autosave?: boolean; autosaveInterval?: number; } interface WritenexConfig { collections?: CollectionConfig[]; singletons?: SingletonConfig[]; images?: ImageConfig; editor?: EditorConfig; discovery?: DiscoveryConfig; versionHistory?: VersionHistoryConfig; } interface WritenexOptions { allowProduction?: boolean; } export type { CollectionConfig as C, DiscoveryConfig as D, EditorConfig as E, FieldKind as F, ImageConfig as I, RestoreResult as R, SaveVersionOptions as S, ValidationOptions as V, WritenexConfig as W, CollectionSchema as a, FieldType as b, ImageStrategy as c, RestoreVersionOptions as d, SchemaField as e, SingletonConfig as f, Version as g, VersionEntry as h, VersionHistoryConfig as i, VersionManifest as j, VersionResult as k, WritenexOptions as l };