import { r as ContentFieldFilters } from "../content-list-query-BhejKVqb.mjs"; import { a as tokenInterceptor, i as devBypassInterceptor, n as createTransport, r as csrfInterceptor, t as Interceptor } from "../transport-DDEHAmW4.mjs"; //#region src/client/portable-text.d.ts /** * Portable Text <-> Markdown conversion layer. * * Three tiers of block handling: * Tier 1: Standard PT blocks <-> standard Markdown (headings, paragraphs, lists, etc.) * Tier 2: EmDash custom blocks <-> Markdown directives (future) * Tier 3: Unknown blocks <-> opaque HTML comment fences (preserved, not editable) */ /** Minimal Portable Text block shape */ interface PortableTextBlock { _type: string; _key?: string; style?: string; level?: number; listItem?: string; markDefs?: MarkDef[]; children?: PortableTextSpan[]; [key: string]: unknown; } interface PortableTextSpan { _type: string; _key?: string; text?: string; marks?: string[]; [key: string]: unknown; } interface MarkDef { _key: string; _type: string; href?: string; [key: string]: unknown; } /** * Convert Portable Text blocks to Markdown. * Unknown block types are serialized as opaque fences. */ declare function portableTextToMarkdown(blocks: PortableTextBlock[]): string; /** * Convert Markdown to Portable Text blocks. * Opaque fences () are deserialized and spliced back in. */ declare function markdownToPortableText(markdown: string): PortableTextBlock[]; //#endregion //#region src/client/index.d.ts interface EmDashClientOptions { /** Base URL of the EmDash instance */ baseUrl: string; /** API token (ec_pat_...) or OAuth token (ec_oat_...) */ token?: string; /** OAuth refresh token for auto-refresh on 401 */ refreshToken?: string; /** Called when a token is refreshed (for persisting new access token) */ onTokenRefresh?: (accessToken: string, expiresIn: number) => void; /** Use dev-bypass authentication (localhost only) */ devBypass?: boolean; /** Additional request interceptors */ interceptors?: Interceptor[]; } /** Standard API error shape */ interface ApiError { code: string; message: string; details?: Record; } /** Standard API response wrapper */ interface ClientResponse { success: true; data: T; } /** Paginated list response */ interface ListResult { items: T[]; nextCursor?: string; } /** Content item as returned by the API */ interface ContentItem { id: string; type: string; slug: string | null; status: string; data: Record; authorId: string | null; createdAt: string; updatedAt: string; publishedAt: string | null; scheduledAt: string | null; liveRevisionId: string | null; draftRevisionId: string | null; locale: string | null; translationGroup: string | null; _rev?: string; } /** Collection metadata */ interface Collection { slug: string; label: string; labelSingular: string; description?: string; icon?: string; supports: string[]; } /** Collection with fields */ interface CollectionWithFields extends Collection { fields: Field[]; } /** Field metadata */ interface Field { slug: string; label: string; type: string; required: boolean; unique: boolean; defaultValue?: unknown; validation?: unknown; widget?: string; options?: unknown; sortOrder?: number; } /** Aggregate trust state for media usage reads */ type MediaUsageCoverageStatus = "complete" | "never" | "running" | "partial" | "failed" | "stale" | "unknown"; /** Aggregate media usage coverage across all content collections */ interface MediaUsageCoverage { scope: "all_content_collections"; status: MediaUsageCoverageStatus; } /** Coverage-aware usage count for a media item */ interface MediaUsageSummary { count: number | null; coverage: MediaUsageCoverage; } /** One indexed media reference within a content source */ interface MediaUsageOccurrenceDetail { fieldSlug: string; fieldPath: string; occurrenceIndex: number; referenceType: "image_field" | "file_field" | "portable_text_image" | "unknown"; } /** Indexed references from one visible content source */ interface MediaUsageSourceDetail { variant: "columns" | "draft_overlay"; occurrences: MediaUsageOccurrenceDetail[]; } /** One content entry that references a media item */ interface MediaUsageEntryDetail { collection: string; contentId: string; title: string | null; slug: string | null; locale: string | null; status: string | null; scheduledAt: string | null; deletedAt: string | null; sources: MediaUsageSourceDetail[]; } /** Entry-grouped media usage details */ interface MediaUsageDetailsResponse { items: MediaUsageEntryDetail[]; nextCursor?: string; coverage: MediaUsageCoverage; } /** Media item */ interface MediaItem { id: string; filename: string; key: string; mimeType: string; size: number; width?: number; height?: number; alt?: string; caption?: string; createdAt: string; updatedAt: string; usage?: MediaUsageSummary; } /** Media usage repair request */ type MediaUsageRepairInput = { scope: "collection"; collection: string; } | { scope: "all"; }; /** Media usage repair status */ type MediaUsageRepairStatus = "complete" | "partial" | "failed" | "stale"; /** Per-collection media usage repair summary */ interface MediaUsageRepairCollectionSummary { collection: string; status: MediaUsageRepairStatus; indexedSourceCount: number; failedSourceCount: number; skippedSourceCount: number; deletedSourceCount: number; lastErrorCode: string | null; startedAt: string; completedAt: string | null; } /** Media usage repair response */ interface MediaUsageRepairResponse { status: MediaUsageRepairStatus; indexedSourceCount: number; failedSourceCount: number; skippedSourceCount: number; deletedSourceCount: number; collections: MediaUsageRepairCollectionSummary[]; } /** Durable media usage entry-work state */ type MediaUsageWorkState = "pending" | "retry" | "leased" | "failed"; /** Redacted operator view of one durable media usage job */ interface MediaUsageWorkItem { collectionId: string; collectionSlug: string; contentId: string; state: MediaUsageWorkState; attemptCount: number; nextAttemptAt: string; leaseExpiresAt: string | null; lastAttemptedAt: string | null; lastErrorCode: string | null; updatedAt: string; } /** Filters and pagination for durable media usage work */ interface MediaUsageWorkListOptions { collection: string; state?: MediaUsageWorkState; limit?: number; cursor?: string; } /** One bounded page of durable media usage work */ interface MediaUsageWorkListResponse { items: MediaUsageWorkItem[]; nextCursor?: string; } /** Identity for explicitly retrying one durable media usage job */ interface MediaUsageWorkRetryInput { collectionId: string; contentId: string; } /** Result of explicitly retrying one durable media usage job */ interface MediaUsageWorkRetryResponse { changed: boolean; item: MediaUsageWorkItem; } type MediaUsageCollectionDeletionState = "pending" | "retry" | "leased" | "failed"; type MediaUsageCollectionDeletionPhase = "fence" | "registry" | "table" | "work" | "sources" | "status" | "finalize"; interface MediaUsageCollectionDeletionItem { collectionId: string; collectionSlug: string; state: MediaUsageCollectionDeletionState; phase: MediaUsageCollectionDeletionPhase; attemptCount: number; nextAttemptAt: string; leaseExpiresAt: string | null; lastErrorCode: string | null; updatedAt: string; } interface MediaUsageCollectionDeletionListResponse { items: MediaUsageCollectionDeletionItem[]; nextCursor?: string; } /** Search result */ interface SearchResult { id: string; collection: string; title: string; excerpt?: string; score: number; } /** Taxonomy */ interface Taxonomy { name: string; label: string; hierarchical: boolean; } /** Taxonomy term */ interface Term { id: string; slug: string; label: string; parentId?: string | null; description?: string; count?: number; } /** Menu */ interface Menu { name: string; label: string; } /** Menu with items */ interface MenuWithItems extends Menu { items: MenuItem[]; } /** Menu item */ interface MenuItem { id: string; type: string; label: string; customUrl?: string; referenceCollection?: string; referenceId?: string; target?: string; parentId?: string | null; sortOrder: number; } /** Full schema export (returned by /api/schema) */ interface SchemaExport { collections: Array<{ slug: string; label: string; labelSingular: string; description?: string; icon?: string; supports: string[]; fields: Array<{ slug: string; label: string; type: string; required: boolean; unique: boolean; defaultValue?: unknown; validation?: unknown; widget?: string; options?: unknown; }>; }>; version: string; } /** Manifest — full schema + field descriptors */ interface Manifest { version: string; hash: string; collections: Record; }>; } declare class EmDashApiError extends Error { readonly status: number; readonly code: string; readonly details?: Record | undefined; constructor(status: number, code: string, message: string, details?: Record | undefined); } declare class EmDashClientError extends Error { constructor(message: string); } declare class EmDashClient { private readonly baseUrl; private readonly transport; /** Cached field schemas per collection for PT conversion */ private fieldSchemaCache; constructor(options: EmDashClientOptions); /** List all collections */ collections(): Promise; /** Get a single collection with its fields */ collection(slug: string): Promise; /** Create a collection */ createCollection(input: { slug: string; label: string; labelSingular?: string; description?: string; icon?: string; supports?: string[]; }): Promise; /** Delete a collection */ deleteCollection(slug: string): Promise; /** Create a field on a collection */ createField(collection: string, input: { slug: string; type: string; label: string; required?: boolean; unique?: boolean; defaultValue?: unknown; validation?: unknown; widget?: string; options?: unknown; sortOrder?: number; }): Promise; /** Delete a field from a collection */ deleteField(collection: string, fieldSlug: string): Promise; /** Get full manifest (schema + field descriptors + features) */ manifest(): Promise; /** Export full schema as JSON (used by `emdash types`) */ schemaExport(): Promise; /** Export schema as TypeScript type definitions (used by `emdash types`) */ schemaTypes(): Promise; /** List content in a collection */ list(collection: string, options?: { status?: string; limit?: number; cursor?: string; orderBy?: string; order?: "asc" | "desc"; locale?: string; /** AND-combined filters over custom fields explicitly marked as indexed. */ fieldFilters?: ContentFieldFilters; }): Promise>; /** Async iterator that auto-follows cursors */ listAll(collection: string, options?: { status?: string; limit?: number; orderBy?: string; order?: "asc" | "desc"; locale?: string; /** AND-combined filters over custom fields explicitly marked as indexed. */ fieldFilters?: ContentFieldFilters; }): AsyncGenerator; /** * Get a single content item. Returns the item with a `_rev` token * that can be passed to update() for optimistic concurrency. */ get(collection: string, id: string, options?: { raw?: boolean; locale?: string; }): Promise; /** Create a new content item */ create(collection: string, input: { data: Record; slug?: string; status?: string; locale?: string; translationOf?: string; }): Promise; /** * Update a content item. Pass `_rev` from a prior get() for optimistic * concurrency — the server returns 409 if the item has changed. * Omit `_rev` for a blind write (no conflict detection). */ update(collection: string, id: string, input: { data?: Record; slug?: string; status?: string; _rev?: string; locale?: string; }): Promise; /** Delete (soft) a content item */ delete(collection: string, id: string): Promise; /** Publish a content item */ publish(collection: string, id: string): Promise; /** Unpublish a content item */ unpublish(collection: string, id: string): Promise; /** Schedule publishing */ schedule(collection: string, id: string, options: { at: string; }): Promise; /** Restore a trashed content item */ restore(collection: string, id: string): Promise; /** Compare live and draft revisions */ compare(collection: string, id: string): Promise<{ hasChanges: boolean; live: Record | null; draft: Record | null; }>; /** Discard draft revision, reverting to the published version */ discardDraft(collection: string, id: string): Promise; /** * Get all translations of a content item. * Returns the translation group ID and a summary of each locale version. */ translations(collection: string, id: string): Promise<{ translationGroup: string; translations: Array<{ id: string; locale: string | null; slug: string | null; status: string; updatedAt: string; }>; }>; /** List media items */ mediaList(options?: { mimeType?: string; limit?: number; cursor?: string; includeUsage?: boolean; }): Promise>; /** Get a single media item */ mediaGet(id: string, options?: { includeUsage?: boolean; }): Promise; /** Get entry-grouped usage details for a media item */ mediaGetUsage(id: string, options?: { limit?: number; cursor?: string; }): Promise; /** Upload a media file */ mediaUpload(file: Uint8Array | Blob, filename: string, options?: { alt?: string; caption?: string; contentType?: string; }): Promise; /** Delete a media item */ mediaDelete(id: string): Promise; /** Repair content media usage indexes for one collection or all collections */ mediaRepairUsage(input: MediaUsageRepairInput): Promise; /** List a bounded page of durable media usage entry work */ mediaListUsageWork(options: MediaUsageWorkListOptions): Promise; /** Explicitly retry one durable media usage entry job */ mediaRetryUsageWork(input: MediaUsageWorkRetryInput): Promise; mediaListCollectionDeletions(options?: { state?: MediaUsageCollectionDeletionState; limit?: number; cursor?: string; }): Promise; mediaRetryCollectionDeletion(collectionId: string): Promise<{ changed: boolean; item: MediaUsageCollectionDeletionItem; }>; /** Full-text search */ search(query: string, options?: { collection?: string; locale?: string; limit?: number; }): Promise; /** List taxonomies */ taxonomies(): Promise; /** List terms in a taxonomy */ terms(taxonomy: string, options?: { limit?: number; cursor?: string; }): Promise>; /** Create a taxonomy term */ createTerm(taxonomy: string, input: { slug: string; label: string; parentId?: string; description?: string; }): Promise; /** List menus */ menus(): Promise; /** Get a menu with its items */ menu(name: string): Promise; /** Make a typed JSON request to the API */ private request; /** Make a raw request — caller handles response */ private requestRaw; /** Assert a response is OK, throw typed error if not */ private assertOk; /** Get cached field schemas for a collection, fetching if needed */ private getFieldSchemas; } //#endregion export { ApiError, ClientResponse, Collection, CollectionWithFields, ContentItem, EmDashApiError, EmDashClient, EmDashClientError, EmDashClientOptions, Field, type Interceptor, ListResult, Manifest, MediaItem, MediaUsageCollectionDeletionItem, MediaUsageCollectionDeletionListResponse, MediaUsageCollectionDeletionPhase, MediaUsageCollectionDeletionState, MediaUsageCoverage, MediaUsageCoverageStatus, MediaUsageDetailsResponse, MediaUsageEntryDetail, MediaUsageOccurrenceDetail, MediaUsageRepairCollectionSummary, MediaUsageRepairInput, MediaUsageRepairResponse, MediaUsageRepairStatus, MediaUsageSourceDetail, MediaUsageSummary, MediaUsageWorkItem, MediaUsageWorkListOptions, MediaUsageWorkListResponse, MediaUsageWorkRetryInput, MediaUsageWorkRetryResponse, MediaUsageWorkState, Menu, MenuItem, MenuWithItems, type PortableTextBlock, SchemaExport, SearchResult, Taxonomy, Term, createTransport, csrfInterceptor, devBypassInterceptor, markdownToPortableText, portableTextToMarkdown, tokenInterceptor }; //# sourceMappingURL=index.d.mts.map