import { FetchRepositoryBase } from "../../../shared/index.js"; import type { ParamsSchema as ListParams } from "../../../tools/content/entries/List.js"; import type { ArchiveResponse, BulkEntriesResponse, EntryDetailResponse, EntryResponse, ListEntryResponse, PublishedEntryResponse } from "./EntriesTypes.js"; type BulkArchiveToolRequest = { spaceId: number; entries: string[]; }; type TranslationFieldValue = { field_id: number; type: string; value: unknown; id?: number | null; multi?: boolean; name?: string; parent_id?: number | null; }; type ArchiveToolRequest = { spaceId: number; workflowId: number; }; type DeleteToolRequest = { spaceId: number; entryId: number; }; type CreateToolRequest = { spaceId: number; type_uid?: string; content_type_id?: number; name?: string; slug?: string; fields?: Record; field_values?: unknown[]; locale?: string; [key: string]: unknown; }; type UpdateToolRequest = { spaceId: number; entryId: number; [key: string]: unknown; }; type UpdateEntryToolRequest = Record; type ListToolRequest = Omit; export type ListToolRequestQuery = Omit; /** * Repository for managing Content API entries * * Handles CRUD operations and bulk actions for content entries within spaces. * Entries are content instances of a specific content type (e.g., blog posts, products). */ export declare class EntriesRepository extends FetchRepositoryBase { /** * Bulk deletes multiple entries by UUID * * Permanently deletes multiple entries in a single operation. * This operation is irreversible. * * Important notes: * - Entries must be archived before deletion * - Uses entry UUIDs (not IDs) for identification * - Target locale is optional; omit to operate on all locales * * @param spaceId - The ID of the space containing the entries * @param entries - Array of entry UUIDs to delete * @param locale - Target locale (e.g. 'es', 'en'). If omitted, operates on all locales. * @returns Promise resolving when bulk deletion completes * @throws Error if entries are published, not found, API request fails, or authentication is invalid */ bulkDeleteEntries(spaceId: BulkArchiveToolRequest["spaceId"], entries: BulkArchiveToolRequest["entries"], locale?: string): Promise; /** * Performs bulk actions on multiple entries * * Executes a single action (archive, restore, delete, publish, unpublish) on multiple entries. * More efficient than individual operations for large batches. * * Supported actions: * - 'archive': Archives entries (step before delete for published entries) * - 'restore': Restores archived entries back to draft * - 'delete': Permanently deletes entries (must be archived first) * - 'publish': Publishes entries to live site * - 'unpublish': Removes entries from live site * * Important notes: * - Archive is required before deleting published entries * - Restore is the inverse of archive (only works on archived entries) * - Returns success/failure status for each entry * * @param spaceId - The ID of the space containing the entries * @param entries - Array of entry UUIDs to process * @param bulk_action - Action to perform ('archive', 'restore', 'delete', 'publish', 'unpublish') * @param target_locale - Target locale. If omitted, the API operates on all locales. * @returns Promise resolving to operation results with per-entry status * @throws Error if action fails, entries not found, API request fails, or authentication is invalid */ bulkActionEntry(spaceId: BulkArchiveToolRequest["spaceId"], entries: BulkArchiveToolRequest["entries"], bulk_action: "archive" | "restore" | "delete" | "publish" | "unpublish", target_locale?: string): Promise; /** * Archives an entry workflow * * Archives the workflow associated with an entry. This is required before * deleting published entries. * * Workflow for deleting published entries: * 1. Unpublish entry (via bulkActionEntry with 'unpublish') * 2. Archive workflow (this method) * 3. Delete entry (via bulkActionEntry with 'delete' or deleteEntry) * * @param spaceId - The ID of the space containing the entry * @param workflowId - The ID of the workflow to archive * @returns Promise resolving to archive confirmation * @throws Error if workflow not found, already archived, API request fails, or authentication is invalid */ archiveEntry(spaceId: ArchiveToolRequest["spaceId"], workflowId: ArchiveToolRequest["workflowId"]): Promise; /** * Creates a new content entry * * Creates a new entry instance of a specific content type within a space. * Entry is created as a draft and must be published separately. * * Important notes: * - Entry structure must match content type field definitions * - All required fields from content type must be provided * - Entry created in the space's default locale when target_locale is omitted * - Use content type slug or UUID for type_uid * * @param spaceId - The ID of the space to create entry in * @param entry - Entry creation data * @param entry.type_uid - Content type slug or UUID * @param entry.fields - Entry field values matching content type schema * @param targetLocale - Target locale (omit for space default locale) * @returns Promise resolving to created entry data with UUID and workflow info * @throws Error if validation fails, type not found, API request fails, or authentication is invalid */ createEntry(spaceId: CreateToolRequest["spaceId"], entry: Omit, targetLocale?: string): Promise; /** * Permanently deletes a single entry * * Important restrictions: * - Entry must be archived before deletion * - Deletion is permanent and cannot be undone * - Use bulkDeleteEntries for deleting multiple entries * * @param spaceId - The ID of the space containing the entry * @param entryId - The ID of the entry to delete * @returns Promise resolving when deletion completes * @throws Error if entry is published, not found, API request fails, or authentication is invalid */ deleteEntry(spaceId: DeleteToolRequest["spaceId"], entryId: DeleteToolRequest["entryId"]): Promise; /** * Retrieves a single entry by ID * * Returns complete entry data including all field values, workflow status, * and metadata. * * @param spaceId - The ID of the space containing the entry * @param entryId - The numeric ID of the entry to retrieve * @returns Promise resolving to entry data with all fields and metadata * @throws Error if entry not found, API request fails, or authentication is invalid */ getEntry(spaceId: number, entryId: number, targetLocale?: string): Promise; /** * Fetches a PUBLISHED entry from the Content API (public endpoint) * * The Content API returns complete entry data including field_values, * unlike the Admin API which may return empty field_values. * * Important: This only works for PUBLISHED entries. * * @param spaceUid - The UID (not ID) of the space * @param typeUid - The UID (not ID) of the content type * @param entryUuid - The UUID (not ID) of the entry * @returns Promise resolving to complete entry data with all field values * @throws Error if entry is not published or not found */ getPublishedEntry(spaceUid: string, typeUid: string, entryUuid: string): Promise; /** * Gets a published entry's numeric ID by looking it up via the Admin API's * UID-based endpoint, which can return published-only entries. * * Uses the same path as getPublishedEntry but extracts the numeric ID * from the response (Admin API variant returns id field). * * @param spaceUid - The UID of the space * @param typeUid - The UID of the content type * @param entryUuid - The UUID of the entry * @returns The numeric entry ID, or undefined if not found or no id in response */ getPublishedEntryId(spaceUid: string, typeUid: string, entryUuid: string): Promise; /** * Searches for a published entry by slug using the public Content API. * * The Admin API list endpoint does not return published-only entries * (entries without a pending draft version). The Content API at * /api/content always returns published entries and supports meta.slug filter. * * @param spaceUid - The UID (not ID) of the space * @param typeUid - The UID (not ID) of the content type * @param slug - The slug to search for * @returns The entry's UUID if found, undefined otherwise */ findPublishedEntryUuidBySlug(spaceUid: string, typeUid: string, slug: string): Promise; /** * Retrieves a paginated list of entries for a space * * Supports filtering, sorting, and pagination for efficient data retrieval. * * @param spaceId - The ID of the space to list entries from * @param queryParams - Optional query parameters * @param queryParams.type - Filter by content type slug or UUID * @param queryParams.category - Filter by category slug * @param targetLocale - Filter by locale (omit to return all locales) * @param queryParams.query - Search query string * @param queryParams.page - Page number for pagination (default: 1) * @param queryParams.per_page - Items per page (default: 15) * @param queryParams.sort_by - Field to sort by * @param queryParams.order - Sort order ('asc' or 'desc') * @returns Promise resolving to paginated list of entries with metadata * @throws Error if API request fails or authentication is invalid */ getEntries(spaceId: ListToolRequest["spaceId"], queryParams?: ListToolRequestQuery, targetLocale?: string): Promise; /** * Updates an existing entry * * Partial updates supported - only include fields to change. * Updated entry remains in current workflow state (draft/published). * * Important notes: * - Only mutable fields can be updated * - System fields (id, uuid, created_at) are read-only * - Updating published entry creates a new draft version * * @param spaceId - The ID of the space containing the entry * @param entryId - The ID of the entry to update * @param entry - Entry update data (partial) * @param entry.fields - Field values to update * @param entry.category - Updated category slug * @param entry.tags - Updated tags array * @returns Promise resolving to updated entry data * @throws Error if validation fails, entry not found, API request fails, or authentication is invalid */ updateEntry(spaceId: UpdateToolRequest["spaceId"], entryId: UpdateToolRequest["entryId"], entry: UpdateEntryToolRequest, targetLocale?: string): Promise; /** * Publishes a single entry to the live site * * Makes the entry content visible on the public API. * Entry ID may change after publishing - use UUID for stable references. * * Important notes: * - Entry must have all required fields filled * - Entry ID may change after publishing * - UUID remains stable across publish cycles * * @param spaceId - The ID of the space containing the entry * @param entryId - The ID of the entry to publish * @param options - Optional publish options * @param options.publish_at - ISO date string for scheduled publish (empty for immediate) * @param options.unpublish_at - ISO date string for scheduled unpublish * @param options.force_publish - Force publish even if validation warnings exist * @returns Promise resolving to published entry data * @throws Error if entry not found, validation fails, API request fails, or authentication is invalid */ publishEntry(spaceId: number, entryId: number, options?: { publish_at?: string; unpublish_at?: string; force_publish?: boolean; }): Promise; /** * Unpublishes a single entry from the live site * * Removes the entry from the public API while keeping it in draft state. * * Important notes: * - Entry must be currently published * - Entry will return to draft state * * @param spaceId - The ID of the space containing the entry * @param entryId - The ID of the entry to unpublish * @returns Promise resolving to unpublished entry data * @throws Error if entry not found, not published, API request fails, or authentication is invalid */ unpublishEntry(spaceId: number, entryId: number, options?: { unpublish_at?: string; }): Promise; /** * Creates a copy/clone of an existing entry * * Duplicates an entry with all its field values in the same space. * The new entry is created as a draft with a new UUID and ID. * * Important notes: * - The new entry is created as a draft * - All field values are copied from the source entry * - A new UUID is generated for the cloned entry * - The slug will be auto-generated (usually source-slug-copy or similar) * * @param spaceId - The ID of the space containing the entry * @param entryId - The ID of the entry to copy * @param uuid - The UUID of the entry to copy * @returns Promise resolving to the newly created entry data * @throws Error if entry not found, API request fails, or authentication is invalid */ copyEntry(spaceId: number, entryId: number, uuid: string): Promise; /** * Creates a translation of an existing entry in a target locale. * * Uses the same entries endpoint with `status: "translate"` to signal * the API that this is a translation, not a new entry. * * @param spaceId - The ID of the space * @param params - Translation parameters * @returns Promise resolving to created translation entry */ createTranslation(spaceId: number, params: { uuid: string; content_type_id: number; name: string; slug: string; target_locale: string; field_values: TranslationFieldValue[]; category_id?: number | null | undefined; excerpt?: string | null | undefined; }): Promise; /** * Fetches all entries from all pages in parallel * * First gets page 1 to determine total count, then fetches remaining pages * concurrently using Promise.all for maximum throughput. * * @param spaceId - The ID of the space to fetch entries from * @param options - Optional filters * @param options.type_id - Filter by content type ID * @returns Promise resolving to array of all entries across all pages */ getAllEntries(spaceId: number, options?: { type_id?: number; target_locale?: string; query?: string; }): Promise; } export {}; //# sourceMappingURL=EntriesRepository.d.ts.map