import type { Category, CategoryRef, CultureRef, ExtendedStory, Newsroom, NewsroomContactRef, Pagination, Query, SortOrder, Story, StoryRef } from '../../types'; import { Campaign } from '../../types'; /** * Uploadcare image JSON string. */ type UploadedImage = string; type Iso8601DateTime = string; /** * Raw HTML string. */ type Html = string; /** * String-serialized JSON object. */ type Json = string; /** * String containing Prezly Content Format JSON structure. */ type PrezlyContentFormat = string; interface BaseWarning { text: string; scope: string; field: string; value: unknown; } interface ChangingNewsroomUnsafeOperationWarning extends BaseWarning { scope: 'room_id'; field: 'room_id'; value: Newsroom['id']; } interface DestinationNewsroomMissingCategoriesWarning extends BaseWarning { scope: 'room_id'; field: 'categories'; value: CategoryRef[]; } interface DestinationNewsroomMissingCulturesWarning extends BaseWarning { scope: 'room_id'; field: 'cultures'; value: CultureRef[]; } interface StoryTranslationsWillMoveWarning extends BaseWarning { scope: 'room_id'; field: 'translations'; value: CultureRef[]; } interface StoryEmbeddedContactsWillBeRemovedWarning extends BaseWarning { scope: 'room_id'; field: 'room_contacts'; value: NewsroomContactRef[]; } export type ChangeNewsroomWarning = ChangingNewsroomUnsafeOperationWarning | DestinationNewsroomMissingCategoriesWarning | DestinationNewsroomMissingCulturesWarning | StoryEmbeddedContactsWillBeRemovedWarning | StoryTranslationsWillMoveWarning; export interface IncludeOptions { include?: Include[]; } export interface ListOptions { search?: string; limit?: number; offset?: number; sortOrder?: SortOrder | string; include?: Include[]; formats?: Story.FormatVersion[]; } export interface SearchOptions extends ListOptions { query?: Query; scope?: Query; } export interface ListResponse { stories: S[]; pagination: Pagination; sort: string; } interface GenericCreateRequest { /** * Set a custom slug for a Story. * * - If there is another story with exactly the same slug value, the Create request will throw [HTTP 409 Conflict]. * * - Conflicts can be force-resolved by passing `?force` GET parameter. * This will update other conflicting stories slugs to something else (i.e. adding random suffix). */ custom_slug?: Story['custom_slug']; newsroom?: Newsroom['id'] | Newsroom['uuid']; published_at?: Iso8601DateTime; visibility?: Story.Visibility; culture?: CultureRef['code']; preview_image?: UploadedImage | null; social_image?: UploadedImage | null; social_text?: string; categories?: Category['id'][]; tags?: string[]; is_shared_to_prpro?: boolean; } interface GenericUpdateRequest { /** * Set a custom slug for a Story. * Updating it to `null` will revert back to automatically generated slugs. * * - If there is another story with exactly the same slug value, the Update request will throw [HTTP 409 Conflict]. * * - Conflicts can be force-resolved by passing `?force` GET parameter. * This will update other conflicting stories slugs to something else (i.e. adding random suffix). */ custom_slug?: Story['custom_slug']; published_at?: Iso8601DateTime; visibility?: Story.Visibility; culture?: CultureRef['code']; preview_image?: UploadedImage | null; social_image?: UploadedImage | null; social_text?: string; categories?: Category['id'][]; tags?: string[]; is_shared_to_prpro?: boolean; seo_settings?: { meta_title?: string | null; meta_description?: string | null; canonical_url?: string | null; }; } export interface HtmlStoryCreateRequest extends GenericCreateRequest { /** * If format version is omitted, license default editor version will be implied. */ format_version?: Story.FormatVersion.HTML; header_image?: UploadedImage | null; title?: string; subtitle?: string; intro?: Html; content?: Html; attached_attachments_content?: Json; attached_bookmarks_content?: Json; attached_contacts_content?: Json; attached_gallery_content?: Json; attached_videos_content?: Json; } export interface SlateV3StoryCreateRequest extends GenericCreateRequest { format_version?: Story.FormatVersion.SLATEJS_V3; header_image?: UploadedImage | null; title?: string; subtitle?: string; /** * Intro field is not supported for Prezly Content Format stories. */ intro?: never; content?: PrezlyContentFormat; } export interface SlateV4StoryCreateRequest extends GenericCreateRequest { format_version?: Story.FormatVersion.SLATEJS_V4; header_image?: never; title?: never; subtitle?: never; /** * Intro field is not supported for Prezly Content Format stories. */ intro?: never; content?: PrezlyContentFormat; } export interface SlateV5StoryCreateRequest extends Omit { format_version?: Story.FormatVersion.SLATEJS_V5 | Story.FormatVersion.SLATEJS_V6; } export interface HtmlStoryUpdateRequest extends GenericUpdateRequest { format_version?: Story.FormatVersion.HTML; header_image?: UploadedImage | null; title?: string; subtitle?: string; intro?: Html; content?: Html; attached_attachments_content?: Json; attached_bookmarks_content?: Json; attached_contacts_content?: Json; attached_gallery_content?: Json; attached_videos_content?: Json; } export interface SlateV3StoryUpdateRequest extends GenericUpdateRequest { format_version?: Story.FormatVersion.SLATEJS_V3; header_image?: UploadedImage | null; title?: string; subtitle?: string; /** * Intro field is not supported for Prezly Content Format stories. */ intro?: never; content?: PrezlyContentFormat; autosaved_content?: PrezlyContentFormat; content_version?: number; } export interface SlateV4StoryUpdateRequest extends GenericUpdateRequest { format_version?: Story.FormatVersion.SLATEJS_V4; header_image?: never; title?: never; subtitle?: never; /** * Intro field is not supported for Prezly Content Format stories. */ intro?: never; content?: PrezlyContentFormat; autosaved_content?: PrezlyContentFormat; content_version?: number; } export interface SlateV5StoryUpdateRequest extends Omit { format_version?: Story.FormatVersion.SLATEJS_V5 | Story.FormatVersion.SLATEJS_V6; } export interface PreviewResponse { content: { 'text/html': Html; 'text/plain': string; }; } export interface PreviewOptions { alignment?: Alignment; appearance?: Appearance; headerFooter?: HeaderFooter; } export declare const Alignment: typeof Campaign.StoryAlignment; export type Alignment = Campaign.StoryAlignment; export declare const Appearance: typeof Campaign.StoryAppearance; export type Appearance = Campaign.StoryAppearance; export declare const HeaderFooter: typeof Campaign.StoryHeaderFooter; export type HeaderFooter = Campaign.StoryHeaderFooter; export type CreateRequest = HtmlStoryCreateRequest | SlateV3StoryCreateRequest | SlateV4StoryCreateRequest | SlateV5StoryCreateRequest; export type UpdateRequest = HtmlStoryUpdateRequest | SlateV3StoryUpdateRequest | SlateV4StoryUpdateRequest | SlateV5StoryUpdateRequest; export interface AutosaveRequest { autosaved_content: PrezlyContentFormat; content_version?: number; } export interface RevertRequest { content_version?: number; } export interface PublishRequest { published_at?: Iso8601DateTime; visibility?: Story.Visibility.PUBLIC | Story.Visibility.PRIVATE | Story.Visibility.CONFIDENTIAL; } export interface UnpublishRequest { visibility?: Story.Visibility.PUBLIC | Story.Visibility.PRIVATE | Story.Visibility.CONFIDENTIAL; } export interface ScheduleRequest { publish_at: Iso8601DateTime; visibility?: Story.Visibility.PUBLIC | Story.Visibility.EMBARGO; } export type UnscheduleRequest = UnpublishRequest; export interface TranslateRequest { culture?: CultureRef['code']; auto?: boolean; newsroom?: Newsroom['uuid'] | Newsroom['id']; } export interface MoveRequest { newsroom: Newsroom['uuid'] | Newsroom['id']; } export interface LinkTranslationRequest { story: Story['uuid'] | Story['id']; } export interface BulkLinkTranslationsRequest { stories: Array; } export interface ChangeNewsroomSuccessResponse { status: 'success'; story: T; } export interface ChangeNewsroomUnsafeResponse { status: 'error'; code: 'unsafe'; message: string; warnings: ChangeNewsroomWarning[]; } declare const EXTENDED_STORY_INCLUDED_EXTRA_FIELDS_SHAPE: { thumbnail_image: true; header_image: true; preview_image: true; social_image: true; social_text: true; tag_names: true; content: true; attached_gallery_content: true; referenced_entities: true; }; declare const ALL_EXTRA_FIELDS_SHAPE: { thumbnail_image: true; header_image: true; preview_image: true; social_image: true; social_text: true; tag_names: true; content: true; autosaved_content: true; content_version: true; last_modifying_user: true; attached_gallery_content: true; attached_videos_content: true; attached_bookmarks_content: true; attached_attachments_content: true; attached_contacts_content: true; referenced_entities: true; 'campaigns.count': true; 'pitches.count': true; 'coverage.count': true; cross_site_translations: true; }; export declare const ALL_EXTRA_FIELDS: (keyof typeof ALL_EXTRA_FIELDS_SHAPE)[]; export declare const EXTENDED_STORY_INCLUDED_EXTRA_FIELDS: (keyof typeof EXTENDED_STORY_INCLUDED_EXTRA_FIELDS_SHAPE)[]; /** * A story reference resolved through the embeddable scope, for a story referenced by a Story * Embed block. Adds the preview link, which the plain reference payload omits but a * "view this story" affordance needs when the story has no public URL yet. */ export type EmbedReference = StoryRef & { links: StoryRef['links'] & { newsroom_preview: string | null; }; }; /** Supported reporting windows for story analytics, in days. */ export type AnalyticsPeriod = '7d' | '30d' | '90d'; export interface AnalyticsOptions { /** Reporting window. Defaults to `30d`. */ period?: AnalyticsPeriod; } /** Aggregated Plausible web analytics for a story's public page. */ export interface StoryAnalytics { story_id: number; story_uuid: string; /** `true` when the metrics below come from live Plausible data. */ tracked: boolean; /** The newsroom has an active tracked Plausible site and Plausible is enabled. */ tracking_enabled: boolean; /** The story has a public page that Plausible can attribute traffic to. */ is_publicly_accessible: boolean; /** Public page path the metrics were filtered by (`null` when not tracked). */ page: string | null; period: { /** Inclusive start date, `YYYY-MM-DD`. */ from: string; /** Inclusive end date, `YYYY-MM-DD`. */ to: string; days: number; /** Reporting timezone: Plausible site when tracked, newsroom otherwise. */ timezone: string; }; totals: StoryAnalyticsTotals; series: (StoryAnalyticsTotals & { date: string; })[]; } export interface StoryAnalyticsTotals { visitors: number; visits: number; pageviews: number; /** Percentage, 0–100. */ bounce_rate: number; /** Seconds. */ visit_duration: number; } /** * What an HTML import reports about the content it could not carry over, or did something with — * `image.upload_failed`, `contact.linked`, `extraction.review_recommended`, `url.already_imported`, … */ export interface ImportDiagnostic { level: 'info' | 'warning' | 'error'; code: string; message: string; count?: number; } /** Where a story imported from a URL came from, and how it was picked out of the page. Beta. */ export interface ImportSource { url: string; final_url: string; canonical: string | null; slug: string | null; extractor: 'llm' | 'readability'; model: string | null; published_at: Iso8601DateTime | null; language: string | null; lead_image: string | null; } interface GenericImportFromHtmlRequest { title?: string; subtitle?: string; newsroom?: Newsroom['id'] | Newsroom['uuid']; custom_slug?: Story['custom_slug']; culture?: CultureRef['code']; visibility?: Story.Visibility; published_at?: Iso8601DateTime; } export interface HtmlImportRequest extends GenericImportFromHtmlRequest { html: string; nodes?: Record[]; /** Send either `html` or `url`, not both. */ url?: never; on_duplicate?: never; } /** * Import the story published at `url` (beta). The same URL cannot be imported into the same * newsroom twice: `on_duplicate: 'refuse'` (the default) answers HTTP 409 `url.already_imported`; * `'update'` updates that story instead, and needs `newsroom`. */ export interface UrlImportRequest extends GenericImportFromHtmlRequest { url: string; on_duplicate?: 'refuse' | 'update'; /** Send either `html` or `url`, not both; `nodes` only go with `html`. */ html?: never; nodes?: never; } export type ImportFromHtmlRequest = HtmlImportRequest | UrlImportRequest; export interface ImportFromHtmlResponse { story: S; diagnostics: ImportDiagnostic[]; /** Only when importing from a `url`. */ source?: ImportSource; } /** A saved translation candidate. Similarities are not calibrated probabilities. */ export interface TranslationSuggestion { story: { id: number; uuid: string; title: string; thumbnail_url?: string; status?: Story['lifecycle_status']; scheduled_at?: string | null; culture_code: string; newsroom_id: number; publication_status: Story['lifecycle_status']; visibility: Story['visibility']; published_at: string | null; }; similarity: { title: number; body: number; }; publication_date_distance_days: number | null; } export {};