export type RequestAnalytics = {source?: ('ICONIK_AUTOMATION' | 'ICONIK_UI_PUBLISH' | 'ICONIK_UI_SCHEDULED_PUBLISH' | 'ICONIK_UI_SAVE_DRAFT' | 'ICONIK_API_PUBLISH' | 'ICONIK_API_SCHEDULED_PUBLISH' | 'ICONIK_API_SAVE_DRAFT') | undefined}; export type CreatePublicationTemplate = {apply?: (boolean | {[key: string]: boolean}) | undefined, data?: {[key: string]: unknown} | undefined, id: string}; export type CreatePublicationJobThumbnailKeyframe = {asset_id: string, keyframe_id: string, type: 'KEYFRAME'}; export type VideoSource = {file_id?: string | undefined, mode?: 'as-is' | undefined}; export type CreatePublicationJobSchema = {allow_transfer?: boolean | undefined, asset_id: string, metadata_overrides?: Record | undefined, publish_at_time?: (string | null) | undefined, request_analytics?: (RequestAnalytics | null) | undefined, save_clip_as_draft?: boolean | undefined, storage_id?: (string | null) | undefined, template?: CreatePublicationTemplate | undefined, thumbnail?: CreatePublicationJobThumbnailKeyframe | undefined, title?: string | undefined, video_source?: (VideoSource | null) | undefined}; export type CreateApiV1PublicationsJobsArgs = {'App-ID': string, 'Auth-Token': string, body: CreatePublicationJobSchema}; export type CreateApiV1PublicationsJobsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * ⚠️ Beta: Schedules publishing for an asset to a list of destinations based on template_id * * POST /v1/publications/jobs/ */ export const createApiV1PublicationsJobs = async (args: CreateApiV1PublicationsJobsArgs, options: CreateApiV1PublicationsJobsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['App-ID'] != null) headers.set("App-ID", String(args['App-ID'])) if (args['Auth-Token'] != null) headers.set("Auth-Token", String(args['Auth-Token'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/publications/jobs/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };