import {z} from 'zod' export type GetApiApiV1VideoLibraryItemsArgs = {status?: (string | null) | undefined, source?: (string | null) | undefined, video_type?: (string | null) | undefined, tag?: (string | null) | undefined, tags?: (string | null) | undefined, meta_status?: (string | null) | undefined, search?: (string | null) | undefined, page?: number | undefined, page_size?: number | undefined}; export type GetApiApiV1VideoLibraryItemsOptions = {baseUrl: string, JWTBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiApiV1VideoLibraryItemsResponse = z.unknown(); 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 }; /** * List Items * * GET /api/v1/video-library/items */ export const getApiApiV1VideoLibraryItems = async (args: GetApiApiV1VideoLibraryItemsArgs, options: GetApiApiV1VideoLibraryItemsOptions) => { const {baseUrl, fetch: fetchFn = fetch, JWTBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.status != null) query.append("status", String(args.status)) if (args.source != null) query.append("source", String(args.source)) if (args.video_type != null) query.append("video_type", String(args.video_type)) if (args.tag != null) query.append("tag", String(args.tag)) if (args.tags != null) query.append("tags", String(args.tags)) if (args.meta_status != null) query.append("meta_status", String(args.meta_status)) if (args.search != null) query.append("search", String(args.search)) if (args.page != null) query.append("page", String(args.page)) if (args.page_size != null) query.append("page_size", String(args.page_size)) if (JWTBearer !== undefined) headers.set('authorization', `Bearer ${JWTBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/video-library/items${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getApiApiV1VideoLibraryItemsResponse, await res.json()) };