/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const ResourceType = { Media: "media", Folder: "folder", Subfolder: "subfolder", Channel: "channel", ChannelEpisode: "channel_episode", Webinar: "webinar", } as const; export type ResourceType = ClosedEnum; export type GetSearchRequest = { /** * The search query string */ q: string; /** * Filter results by one or more tag names. When multiple tags are provided, results matching any of the specified tags are returned (OR logic). */ tags?: Array | undefined; /** * Filter results by one or more resource types. */ resourceType?: Array | undefined; /** * Filter results created on or after this datetime. Must be a valid ISO8601 timestamp in UTC (ending with 'Z'). */ createdAfter?: Date | undefined; /** * Filter results created on or before this datetime. Must be a valid ISO8601 timestamp in UTC (ending with 'Z'). */ createdBefore?: Date | undefined; }; /** * A string representing what type of media this is. */ export const FolderType = { Video: "Video", Audio: "Audio", Image: "Image", PdfDocument: "PdfDocument", MicrosoftOfficeDocument: "MicrosoftOfficeDocument", Swf: "Swf", UnknownType: "UnknownType", } as const; /** * A string representing what type of media this is. */ export type FolderType = ClosedEnum; /** * Post upload processing status. - `queued`: the file is waiting in the queue to be processed. - `processing`: the file is actively being processed. - `ready`: the file has been fully processed and is ready for embedding and viewing. - `failed`: the file was unable to be processed (usually a format or size error). * * @remarks */ export const FolderStatus = { Queued: "queued", Processing: "processing", Ready: "ready", Failed: "failed", } as const; /** * Post upload processing status. - `queued`: the file is waiting in the queue to be processed. - `processing`: the file is actively being processed. - `ready`: the file has been fully processed and is ready for embedding and viewing. - `failed`: the file was unable to be processed (usually a format or size error). * * @remarks */ export type FolderStatus = ClosedEnum; export type FolderThumbnail = { url?: string | undefined; width?: number | undefined; height?: number | undefined; }; /** * A link to where you can fetch the medias for this folder. */ export type GetSearchMedias = { /** * A unique numeric identifier for the media within the system. */ id?: number | undefined; /** * The display name of the media. */ name?: string | undefined; /** * A string representing what type of media this is. */ type?: FolderType | undefined; /** * Whether or not the media is archived, either true or false. */ archived?: boolean | undefined; /** * The date when the media was originally uploaded. */ created?: Date | undefined; /** * The date when the media was last changed. */ updated?: Date | undefined; /** * Specifies the length (in seconds) for audio and video files. Specifies number of pages in the document. Omitted for other types of media. */ duration?: number | null | undefined; /** * DEPRECATED: If you want to programmatically embed videos, follow the construct an embed code guide. * * @remarks * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ embedCode?: string | undefined; /** * A unique alphanumeric identifier for this media. */ hashedId?: string | undefined; /** * A description for the media which usually appears near the top of the sidebar on the media's page. */ description?: string | undefined; /** * A floating point value between 0 and 1 that indicates the progress of the processing for this file. */ progress?: number | undefined; /** * Post upload processing status. - `queued`: the file is waiting in the queue to be processed. - `processing`: the file is actively being processed. - `ready`: the file has been fully processed and is ready for embedding and viewing. - `failed`: the file was unable to be processed (usually a format or size error). * * @remarks */ status?: FolderStatus | undefined; /** * The title of the section in which the media appears. This attribute is omitted if the media is not in a section (default). */ section?: string | null | undefined; thumbnail?: FolderThumbnail | undefined; }; /** * A folder (previously called a project) is a container in which to organize media into. It can be * * @remarks * used to set permissions that apply to all the media in the folder as well as * organizing media into subfolders (previously called media groups). */ export type GetSearchFolder = { /** * A unique numeric identifier for the folder within the system. */ id: number; /** * The folder’s display name. */ name: string; /** * The folder’s description. */ description?: string | null | undefined; /** * The number of different medias that have been uploaded to the folder. */ mediaCount: number; /** * A link to where you can fetch the medias for this folder. */ medias: GetSearchMedias; /** * The date that the folder was originally created. */ created: Date; /** * The date that the folder was last updated. */ updated: Date; /** * A private hashed id, uniquely identifying the folder within the system. */ hashedId: string; /** * A boolean indicating whether the folder is available for public (anonymous) viewing. */ public: boolean; /** * If the folder is public, this field contains a string representing the ID used for referencing the folder in public URLs. */ publicId: string | null; anonymousCanUpload?: boolean | undefined; anonymousCanDownload?: boolean | undefined; /** * A cursor for stable pagination based on current `sort_by` order. You can pass this to `cursor[before]` or `cursor[after]` as a parameter to fetch the records before or after this record in the same sort order. This is only populated if records were fetched with `cursor[enabled]`, or `cursor[before]` or `cursor[after]`. */ cursor?: string | null | undefined; }; /** * A subfolder within a folder that contains media. */ export type GetSearchSubfolder = { /** * A unique alphanumeric identifier for this subfolder. */ hashedId: string; /** * The display name of the subfolder. */ name?: string | null | undefined; /** * A description for the subfolder. */ description?: string | null | undefined; /** * The position of this subfolder within its folder, used for ordering. */ position: number | null; /** * The date when the subfolder was created. */ created: Date | null; /** * The date when the subfolder was last modified. */ updated: Date | null; /** * A cursor for stable pagination based on current `sort_by` order. You can pass this to `cursor[before]` or `cursor[after]` as a parameter to fetch the records before or after this record in the same sort order. This is only populated if records were fetched with `cursor[enabled]`, or `cursor[before]` or `cursor[after]`. */ cursor?: string | null | undefined; }; /** * A string representing what type of media this is. */ export const GetSearchMediaType = { Video: "Video", Audio: "Audio", Image: "Image", PdfDocument: "PdfDocument", MicrosoftOfficeDocument: "MicrosoftOfficeDocument", Swf: "Swf", UnknownType: "UnknownType", } as const; /** * A string representing what type of media this is. */ export type GetSearchMediaType = ClosedEnum; /** * Post upload processing status. - `queued`: the file is waiting in the queue to be processed. - `processing`: the file is actively being processed. - `ready`: the file has been fully processed and is ready for embedding and viewing. - `failed`: the file was unable to be processed (usually a format or size error). * * @remarks */ export const GetSearchMediaStatus = { Queued: "queued", Processing: "processing", Ready: "ready", Failed: "failed", } as const; /** * Post upload processing status. - `queued`: the file is waiting in the queue to be processed. - `processing`: the file is actively being processed. - `ready`: the file has been fully processed and is ready for embedding and viewing. - `failed`: the file was unable to be processed (usually a format or size error). * * @remarks */ export type GetSearchMediaStatus = ClosedEnum; export type GetSearchMediaThumbnail = { url?: string | undefined; width?: number | undefined; height?: number | undefined; }; export type TranscriptMatch = { /** * The matched transcript text with context */ text: string; /** * Start time of the match in seconds */ startTimeSeconds: number; /** * Human-readable start time (e.g., "0:03" or "1:23:45") */ startTimeFormatted: string; /** * Thumbnail URL at the match timestamp */ thumbnailUrl: string | null; }; /** * A media generally represents a video or an audio which can be embedded into your website. * * @remarks * * CDN-backed medias are accessible using this url structure: https://fast.wistia.com/embed/medias/{hashed_id}.m3u8. * For more information, see https://docs.wistia.com/docs/asset-urls#getting-hls-assets. */ export type GetSearchMedia = { /** * A unique numeric identifier for the media within the system. */ id?: number | undefined; /** * The display name of the media. */ name?: string | undefined; /** * A string representing what type of media this is. */ type?: GetSearchMediaType | undefined; /** * Whether or not the media is archived, either true or false. */ archived?: boolean | undefined; /** * The date when the media was originally uploaded. */ created?: Date | undefined; /** * The date when the media was last changed. */ updated?: Date | undefined; /** * Specifies the length (in seconds) for audio and video files. Specifies number of pages in the document. Omitted for other types of media. */ duration?: number | null | undefined; /** * DEPRECATED: If you want to programmatically embed videos, follow the construct an embed code guide. * * @remarks * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ embedCode?: string | undefined; /** * A unique alphanumeric identifier for this media. */ hashedId?: string | undefined; /** * A description for the media which usually appears near the top of the sidebar on the media's page. */ description?: string | undefined; /** * A floating point value between 0 and 1 that indicates the progress of the processing for this file. */ progress?: number | undefined; /** * Post upload processing status. - `queued`: the file is waiting in the queue to be processed. - `processing`: the file is actively being processed. - `ready`: the file has been fully processed and is ready for embedding and viewing. - `failed`: the file was unable to be processed (usually a format or size error). * * @remarks */ status?: GetSearchMediaStatus | undefined; /** * The title of the section in which the media appears. This attribute is omitted if the media is not in a section (default). */ section?: string | null | undefined; thumbnail?: GetSearchMediaThumbnail | undefined; /** * The hashed ID of the folder this media belongs to */ folderHashedId: string | null; /** * Array of transcript matches with timestamps */ transcriptMatches: Array; }; export type Channel = { /** * A unique numeric identifier for the channel within the system. */ id: number; /** * A unique alphanumeric identifier for this channel. */ hashedId: string; /** * The display name for the channel. */ name: string; /** * The channel's description. */ description: string; /** * The number of medias in the channel. */ mediaCount: number; /** * The date when the channel was originally created. */ created: Date; /** * The date when the channel was last updated. */ updated: Date; }; export type ChannelEpisode = { /** * A unique numeric identifier for the channel episode within the system. */ id: number; /** * A unique alphanumeric identifier for this channel episode. */ hashedId: string; /** * The title of the channel episode. */ title?: string | null | undefined; /** * The episode notes for the channel episode. */ description: string; /** * The description of the channel episode. */ summary: string; /** * The hashed ID of the channel this episode belongs to. */ channelHashedId: string | null; /** * The hashed ID of the media associated with this channel episode. */ mediaHashedId: string | null; /** * Whether the channel episode is published. */ published: boolean; /** * The date when the channel episode was originally created. */ created: Date; /** * The date when the channel episode was last updated. */ updated: Date; /** * The scheduled publish date (only present if scheduled). */ publishAt?: Date | null | undefined; }; /** * A webinar is an event which allows you to stream a video * * @remarks * to multiple participants. See our [Webinars Guide](https://support.wistia.com/en/articles/8288501-getting-started-with-webinars) * for more info. */ export type GetSearchWebinar = { /** * The hashed ID of the webinar */ id: string; /** * The title of the webinar */ title: string; /** * The description of the webinar */ description?: string | null | undefined; /** * The scheduled start time in W3C format with timezone */ scheduledFor?: Date | null | undefined; /** * Duration of the webinar in minutes */ eventDuration?: number | null | undefined; /** * Current lifecycle status of the event */ lifecycleStatus: string; /** * Registration status of the event */ registrationStatus: string; /** * When the event was created (UTC) */ createdAt: Date; /** * When the event was last updated (UTC) */ updatedAt: Date; /** * Link for the audience to join the event */ audienceLink: string; /** * Link for the host to manage the event */ hostLink: string; /** * Link for panelists to join the event */ panelistLink: string; }; export type GetSearchData = { folders: Array; subfolders: Array; medias: Array; channels: Array; channelEpisodes: Array; webinars: Array; }; /** * Search results */ export type GetSearchResponse = { data: GetSearchData; }; /** @internal */ export const ResourceType$outboundSchema: z.ZodNativeEnum = z.nativeEnum(ResourceType); /** @internal */ export type GetSearchRequest$Outbound = { q: string; "tags[]"?: Array | undefined; "resource_type[]"?: Array | undefined; created_after?: string | undefined; created_before?: string | undefined; }; /** @internal */ export const GetSearchRequest$outboundSchema: z.ZodType< GetSearchRequest$Outbound, z.ZodTypeDef, GetSearchRequest > = z.object({ q: z.string(), tags: z.array(z.string()).optional(), resourceType: z.array(ResourceType$outboundSchema).optional(), createdAfter: z.date().transform(v => v.toISOString()).optional(), createdBefore: z.date().transform(v => v.toISOString()).optional(), }).transform((v) => { return remap$(v, { tags: "tags[]", resourceType: "resource_type[]", createdAfter: "created_after", createdBefore: "created_before", }); }); export function getSearchRequestToJSON( getSearchRequest: GetSearchRequest, ): string { return JSON.stringify( GetSearchRequest$outboundSchema.parse(getSearchRequest), ); } /** @internal */ export const FolderType$inboundSchema: z.ZodNativeEnum = z .nativeEnum(FolderType); /** @internal */ export const FolderStatus$inboundSchema: z.ZodNativeEnum = z.nativeEnum(FolderStatus); /** @internal */ export const FolderThumbnail$inboundSchema: z.ZodType< FolderThumbnail, z.ZodTypeDef, unknown > = z.object({ url: z.string().optional(), width: z.number().int().optional(), height: z.number().int().optional(), }); export function folderThumbnailFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FolderThumbnail$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FolderThumbnail' from JSON`, ); } /** @internal */ export const GetSearchMedias$inboundSchema: z.ZodType< GetSearchMedias, z.ZodTypeDef, unknown > = z.object({ id: z.number().int().optional(), name: z.string().optional(), type: FolderType$inboundSchema.optional(), archived: z.boolean().optional(), created: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), updated: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), duration: z.nullable(z.number()).optional(), embedCode: z.string().optional(), hashed_id: z.string().optional(), description: z.string().optional(), progress: z.number().optional(), status: FolderStatus$inboundSchema.optional(), section: z.nullable(z.string()).optional(), thumbnail: z.lazy(() => FolderThumbnail$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "hashed_id": "hashedId", }); }); export function getSearchMediasFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetSearchMedias$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetSearchMedias' from JSON`, ); } /** @internal */ export const GetSearchFolder$inboundSchema: z.ZodType< GetSearchFolder, z.ZodTypeDef, unknown > = z.object({ id: z.number().int(), name: z.string(), description: z.nullable(z.string()).optional(), media_count: z.number().int(), medias: z.lazy(() => GetSearchMedias$inboundSchema), created: z.string().datetime({ offset: true }).transform(v => new Date(v)), updated: z.string().datetime({ offset: true }).transform(v => new Date(v)), hashed_id: z.string(), public: z.boolean(), public_id: z.nullable(z.string()), anonymous_can_upload: z.boolean().optional(), anonymous_can_download: z.boolean().optional(), cursor: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "media_count": "mediaCount", "hashed_id": "hashedId", "public_id": "publicId", "anonymous_can_upload": "anonymousCanUpload", "anonymous_can_download": "anonymousCanDownload", }); }); export function getSearchFolderFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetSearchFolder$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetSearchFolder' from JSON`, ); } /** @internal */ export const GetSearchSubfolder$inboundSchema: z.ZodType< GetSearchSubfolder, z.ZodTypeDef, unknown > = z.object({ hashed_id: z.string(), name: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), position: z.nullable(z.number().int()), created: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), updated: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), cursor: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "hashed_id": "hashedId", }); }); export function getSearchSubfolderFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetSearchSubfolder$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetSearchSubfolder' from JSON`, ); } /** @internal */ export const GetSearchMediaType$inboundSchema: z.ZodNativeEnum< typeof GetSearchMediaType > = z.nativeEnum(GetSearchMediaType); /** @internal */ export const GetSearchMediaStatus$inboundSchema: z.ZodNativeEnum< typeof GetSearchMediaStatus > = z.nativeEnum(GetSearchMediaStatus); /** @internal */ export const GetSearchMediaThumbnail$inboundSchema: z.ZodType< GetSearchMediaThumbnail, z.ZodTypeDef, unknown > = z.object({ url: z.string().optional(), width: z.number().int().optional(), height: z.number().int().optional(), }); export function getSearchMediaThumbnailFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetSearchMediaThumbnail$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetSearchMediaThumbnail' from JSON`, ); } /** @internal */ export const TranscriptMatch$inboundSchema: z.ZodType< TranscriptMatch, z.ZodTypeDef, unknown > = z.object({ text: z.string(), start_time_seconds: z.number(), start_time_formatted: z.string(), thumbnail_url: z.nullable(z.string()), }).transform((v) => { return remap$(v, { "start_time_seconds": "startTimeSeconds", "start_time_formatted": "startTimeFormatted", "thumbnail_url": "thumbnailUrl", }); }); export function transcriptMatchFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TranscriptMatch$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TranscriptMatch' from JSON`, ); } /** @internal */ export const GetSearchMedia$inboundSchema: z.ZodType< GetSearchMedia, z.ZodTypeDef, unknown > = z.object({ id: z.number().int().optional(), name: z.string().optional(), type: GetSearchMediaType$inboundSchema.optional(), archived: z.boolean().optional(), created: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), updated: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), duration: z.nullable(z.number()).optional(), embedCode: z.string().optional(), hashed_id: z.string().optional(), description: z.string().optional(), progress: z.number().optional(), status: GetSearchMediaStatus$inboundSchema.optional(), section: z.nullable(z.string()).optional(), thumbnail: z.lazy(() => GetSearchMediaThumbnail$inboundSchema).optional(), folder_hashed_id: z.nullable(z.string()), transcript_matches: z.array(z.lazy(() => TranscriptMatch$inboundSchema)), }).transform((v) => { return remap$(v, { "hashed_id": "hashedId", "folder_hashed_id": "folderHashedId", "transcript_matches": "transcriptMatches", }); }); export function getSearchMediaFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetSearchMedia$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetSearchMedia' from JSON`, ); } /** @internal */ export const Channel$inboundSchema: z.ZodType = z.object({ id: z.number().int(), hashed_id: z.string(), name: z.string(), description: z.string(), media_count: z.number().int(), created: z.string().datetime({ offset: true }).transform(v => new Date(v)), updated: z.string().datetime({ offset: true }).transform(v => new Date(v)), }).transform((v) => { return remap$(v, { "hashed_id": "hashedId", "media_count": "mediaCount", }); }); export function channelFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Channel$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Channel' from JSON`, ); } /** @internal */ export const ChannelEpisode$inboundSchema: z.ZodType< ChannelEpisode, z.ZodTypeDef, unknown > = z.object({ id: z.number().int(), hashed_id: z.string(), title: z.nullable(z.string()).optional(), description: z.string(), summary: z.string(), channel_hashed_id: z.nullable(z.string()), media_hashed_id: z.nullable(z.string()), published: z.boolean(), created: z.string().datetime({ offset: true }).transform(v => new Date(v)), updated: z.string().datetime({ offset: true }).transform(v => new Date(v)), publish_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "hashed_id": "hashedId", "channel_hashed_id": "channelHashedId", "media_hashed_id": "mediaHashedId", "publish_at": "publishAt", }); }); export function channelEpisodeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ChannelEpisode$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChannelEpisode' from JSON`, ); } /** @internal */ export const GetSearchWebinar$inboundSchema: z.ZodType< GetSearchWebinar, z.ZodTypeDef, unknown > = z.object({ id: z.string(), title: z.string(), description: z.nullable(z.string()).optional(), scheduled_for: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), event_duration: z.nullable(z.number().int()).optional(), lifecycle_status: z.string(), registration_status: z.string(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), audience_link: z.string(), host_link: z.string(), panelist_link: z.string(), }).transform((v) => { return remap$(v, { "scheduled_for": "scheduledFor", "event_duration": "eventDuration", "lifecycle_status": "lifecycleStatus", "registration_status": "registrationStatus", "created_at": "createdAt", "updated_at": "updatedAt", "audience_link": "audienceLink", "host_link": "hostLink", "panelist_link": "panelistLink", }); }); export function getSearchWebinarFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetSearchWebinar$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetSearchWebinar' from JSON`, ); } /** @internal */ export const GetSearchData$inboundSchema: z.ZodType< GetSearchData, z.ZodTypeDef, unknown > = z.object({ folders: z.array(z.lazy(() => GetSearchFolder$inboundSchema)), subfolders: z.array(z.lazy(() => GetSearchSubfolder$inboundSchema)), medias: z.array(z.lazy(() => GetSearchMedia$inboundSchema)), channels: z.array(z.lazy(() => Channel$inboundSchema)), channel_episodes: z.array(z.lazy(() => ChannelEpisode$inboundSchema)), webinars: z.array(z.lazy(() => GetSearchWebinar$inboundSchema)), }).transform((v) => { return remap$(v, { "channel_episodes": "channelEpisodes", }); }); export function getSearchDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetSearchData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetSearchData' from JSON`, ); } /** @internal */ export const GetSearchResponse$inboundSchema: z.ZodType< GetSearchResponse, z.ZodTypeDef, unknown > = z.object({ data: z.lazy(() => GetSearchData$inboundSchema), }); export function getSearchResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetSearchResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetSearchResponse' from JSON`, ); }