import {z} from 'zod' export type GetApiV1VideosIdClipsClipIdShapeOverlaysArgs = {id: string, clipId: string}; export type GetApiV1VideosIdClipsClipIdShapeOverlaysOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const shapeBorderOutput = z.object({color: z.string(), width: z.number().gt(0)}).nullable(); export const textOverlayBackgroundShape = z.enum(["none", "regular", "squircle"]); export const overlayDepth = z.enum(["front", "behind_presenter"]); export const overlayDepthChanges = z.array(z.object({atMs: z.number().gte(0), depth: overlayDepth})); export const overlayDimensionsOutput = z.object({height: z.number().gt(0), width: z.number().gt(0)}); export const clipBackgroundOutput = z.object({color: z.string().nullable().optional(), gradientAngle: z.number().int().gte(-9007199254740991).lte(9007199254740991).nullable().optional(), gradientColor1: z.string().nullable().optional(), gradientColor2: z.string().nullable().optional(), imageUrl: z.string().nullable().optional(), shaderGradientPreset: z.string().nullable().optional(), sourceId: z.string().nullable().optional(), type: z.enum(["solid", "gradient", "image", "video", "shaderGradient", "ambient"]), videoDurationSeconds: z.number().gte(0).nullable().optional(), videoUrl: z.string().nullable().optional()}); export const overlayPointOutput = z.object({xPct: z.number(), yPct: z.number()}); export const textOverlayShadow = z.enum(["none", "subtle", "deep"]); export const shapeType = z.enum(["square", "circle", "triangle", "diamond", "star", "hexagon", "arrow", "path"]); export const transitionStyle = z.enum(["smooth", "hard_cut"]); export const overlayZIndex = z.number().int().gte(0).lte(9007199254740991); export const clipShapeOverlay = z.object({border: shapeBorderOutput, corners: textOverlayBackgroundShape, depth: overlayDepth, depthChanges: overlayDepthChanges.optional(), dimensions: overlayDimensionsOutput, durationMs: z.number().gte(0), fill: clipBackgroundOutput, id: z.string(), name: z.string().nullable(), path: z.string().nullable(), point: overlayPointOutput, shadow: textOverlayShadow, shapeType: shapeType, startTimeMs: z.number().gte(0), transition: transitionStyle, zIndex: overlayZIndex}); export const listClipShapeOverlaysResponse = z.object({shapeOverlays: z.array(clipShapeOverlay)}); 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 shape overlays on a clip * * GET /v1/videos/{id}/clips/{clipId}/shape-overlays */ export const getApiV1VideosIdClipsClipIdShapeOverlays = async (args: GetApiV1VideosIdClipsClipIdShapeOverlaysArgs, options?: GetApiV1VideosIdClipsClipIdShapeOverlaysOptions) => { const {baseUrl = "https://api.tella.com", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/videos/${encodeURIComponent(String(args.id))}/clips/${encodeURIComponent(String(args.clipId))}/shape-overlays${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(listClipShapeOverlaysResponse, await res.json()) };