import {z} from 'zod' export type ExportLocationSchema = {description?: string | undefined, export_metadata?: boolean | undefined, export_original?: boolean | undefined, export_posters?: boolean | undefined, export_proxy?: boolean | undefined, export_to_asset_folder?: boolean | undefined, export_transcriptions?: boolean | undefined, id?: string | undefined, include_original_extension?: boolean | undefined, metadata_format?: ('CSV' | 'JSON' | 'XML') | undefined, metadata_view?: string | undefined, name: string, path: string, storage_id: string, system_domain_id?: string | undefined, transcode_profile_ids?: Array | undefined, transcription_format?: ('WEBVTT' | 'SRT') | undefined}; export type PatchApiV1ExportLocationsExportLocationIdArgs = {'App-ID': string, 'Auth-Token': string, export_location_id: string, body: ExportLocationSchema}; export type PatchApiV1ExportLocationsExportLocationIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const exportLocationSchema = z.object({description: z.string().optional(), export_metadata: z.boolean().optional(), export_original: z.boolean().optional(), export_posters: z.boolean().optional(), export_proxy: z.boolean().optional(), export_to_asset_folder: z.boolean().optional(), export_transcriptions: z.boolean().optional(), id: z.string().optional(), include_original_extension: z.boolean().optional(), metadata_format: z.enum(["CSV", "JSON", "XML"]).optional(), metadata_view: z.string().optional(), name: z.string(), path: z.string(), storage_id: z.string(), system_domain_id: z.string().optional(), transcode_profile_ids: z.array(z.string()).optional(), transcription_format: z.enum(["WEBVTT", "SRT"]).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Update export_location * * PATCH /v1/export_locations/{export_location_id}/ */ export const patchApiV1ExportLocationsExportLocationId = async (args: PatchApiV1ExportLocationsExportLocationIdArgs, options: PatchApiV1ExportLocationsExportLocationIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "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/export_locations/${encodeURIComponent(String(args.export_location_id))}/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 validateResponse(exportLocationSchema, await res.json()) };