import {z} from 'zod' export type OverlayAnimationCurve = 'linear' | 'smooth' | 'natural' | 'slow_down' | 'accelerate' | 'elastic' | 'bounce' | 'overshoot' | 'impulse' | 'swing' | 'custom' | 'spring'; export type OverlayAnimationSpring = {damping: number, mass: number, stiffness: number}; export type OverlayAnimationEasingInput = {bezier?: (Array) | undefined, curve: OverlayAnimationCurve, intensity?: number | undefined, spring?: OverlayAnimationSpring | undefined}; export type OverlayAnimationPreset = 'fade' | 'slide_up' | 'slide_down' | 'slide_left' | 'slide_right' | 'mask_up' | 'mask_down' | 'grow' | 'shrink' | 'blur' | 'blur_slide_up'; export type OverlayAnimationTextInput = {delayMs?: number | undefined, order?: ('forward' | 'backward' | 'center' | 'edges' | 'random') | undefined, smoothing?: ('linear' | 'smooth' | 'natural' | 'slow_down' | 'accelerate' | 'elastic' | 'overshoot' | 'impulse' | 'swing') | undefined, unit: 'letters' | 'words' | 'lines'}; export type OverlayAnimationSideInput = {blur?: number | undefined, clip?: boolean | undefined, durationMs?: number | undefined, easing?: OverlayAnimationEasingInput | undefined, moveX?: number | undefined, moveY?: number | undefined, opacity?: number | undefined, preset?: OverlayAnimationPreset | undefined, rotate?: number | undefined, scale?: number | undefined, text?: OverlayAnimationTextInput | undefined}; export type OverlayAnimationInput = {intro?: (OverlayAnimationSideInput | null) | undefined, motionBlur?: boolean | undefined, outro?: (OverlayAnimationSideInput | null) | undefined, textIntro?: (OverlayAnimationSideInput | null) | undefined, textOutro?: (OverlayAnimationSideInput | null) | undefined}; export type ShapeBorder = {color: string, width: number} | null; export type TextOverlayBackgroundShape = 'none' | 'regular' | 'squircle'; export type OverlayDepth = 'front' | 'behind_presenter'; export type OverlayDepthChanges = Array<{atMs: number, depth: OverlayDepth}>; export type OverlayDimensions = {height: number, width: number}; export type ClipBackground = {color?: (string | null) | undefined, gradientAngle?: (number | null) | undefined, gradientColor1?: (string | null) | undefined, gradientColor2?: (string | null) | undefined, imageUrl?: (string | null) | undefined, shaderGradientPreset?: (string | null) | undefined, sourceId?: (string | null) | undefined, type: 'solid' | 'gradient' | 'image' | 'video' | 'shaderGradient' | 'ambient', videoDurationSeconds?: (number | null) | undefined, videoUrl?: (string | null) | undefined}; export type OverlayPoint = {xPct: number, yPct: number}; export type TextOverlayShadow = 'none' | 'subtle' | 'deep'; export type ShapeType = 'square' | 'circle' | 'triangle' | 'diamond' | 'star' | 'hexagon' | 'arrow' | 'path'; export type TransitionStyle = 'smooth' | 'hard_cut'; export type UpdateClipShapeOverlayRequest = {animation?: (OverlayAnimationInput | null) | undefined, border?: ShapeBorder | undefined, corners?: TextOverlayBackgroundShape | undefined, depth?: OverlayDepth | undefined, depthChanges?: OverlayDepthChanges | undefined, dimensions?: OverlayDimensions | undefined, durationMs?: number | undefined, fill?: ClipBackground | undefined, path?: string | undefined, point?: OverlayPoint | undefined, shadow?: TextOverlayShadow | undefined, shapeType?: ShapeType | undefined, startTimeMs?: number | undefined, transition?: TransitionStyle | undefined, zIndex?: number | undefined}; export type PatchApiV1VideosIdClipsClipIdShapeOverlaysShapeOverlayIdArgs = {id: string, clipId: string, shapeOverlayId: string, body: UpdateClipShapeOverlayRequest}; export type PatchApiV1VideosIdClipsClipIdShapeOverlaysShapeOverlayIdOptions = {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 clipShapeOverlayResponse = z.object({shapeOverlay: 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 }; /** * Update a shape overlay * * PATCH /v1/videos/{id}/clips/{clipId}/shape-overlays/{shapeOverlayId} */ export const patchApiV1VideosIdClipsClipIdShapeOverlaysShapeOverlayId = async (args: PatchApiV1VideosIdClipsClipIdShapeOverlaysShapeOverlayIdArgs, options?: PatchApiV1VideosIdClipsClipIdShapeOverlaysShapeOverlayIdOptions) => { const {baseUrl = "https://api.tella.com", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") 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/${encodeURIComponent(String(args.shapeOverlayId))}${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(clipShapeOverlayResponse, await res.json()) };