/* * 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"; /** * If `cursor[enabled]` is set to 1, the first result set will be fetched with cursor pagination enabled. This * * @remarks * values is ignored if `cursor[before]` or `cursor[after]` are set. */ export const GetMediasEnabled = { Zero: 0, One: 1, } as const; /** * If `cursor[enabled]` is set to 1, the first result set will be fetched with cursor pagination enabled. This * * @remarks * values is ignored if `cursor[before]` or `cursor[after]` are set. */ export type GetMediasEnabled = ClosedEnum; /** * If `cursor[enabled]` is set to 1 than cursor pagination is enabled and the * * @remarks * first set of records are fetched up to the `per_page`. Cursor * pagination will also be turned on if `cursor[before]` or `cursor[after]` * are set. Records returned will have a `cursor` property set which can be used to fetch more records in the same `sort_by` ordering. * The cursor value of the last record can be used to fetch records after the current result set and * the cursor of the first record can be used to fetch records before the result set. * * NOTE: a cursor value is only valid if the `sort_by` value hasn't changed from the * last fetch. For example, you cannot fetch using `sort_by` id and than pass that * cursor value to a `sort_by` name. */ export type GetMediasCursor = { /** * If `cursor[enabled]` is set to 1, the first result set will be fetched with cursor pagination enabled. This * * @remarks * values is ignored if `cursor[before]` or `cursor[after]` are set. */ enabled?: GetMediasEnabled | undefined; /** * If `cursor[before]` is set than cursor pagination is enabled and all records * * @remarks * before the cursor up to the `per_page` are returned. This feature is useful for * fetching "new records", for example, in a "pull to refersh" feature when showing records in a descending * order. */ before?: string | undefined; /** * If `cursor[after]` is set than cursor pagination is enabled and all records * * @remarks * after the cursor up to the `per_page` are returned. */ after?: string | undefined; }; /** * Ordering. When using cursor pagination (see cursor param), * * @remarks * only `id` and `created` are supported. All other sort_by options (`name`, `updated`, `position`) * require offset pagination. */ export const GetMediasSortBy = { Name: "name", Created: "created", Updated: "updated", Position: "position", } as const; /** * Ordering. When using cursor pagination (see cursor param), * * @remarks * only `id` and `created` are supported. All other sort_by options (`name`, `updated`, `position`) * require offset pagination. */ export type GetMediasSortBy = ClosedEnum; /** * Ordering Sort Direction (0 = desc, 1 = asc; default is 1) */ export const GetMediasSortDirection = { Zero: 0, One: 1, } as const; /** * Ordering Sort Direction (0 = desc, 1 = asc; default is 1) */ export type GetMediasSortDirection = ClosedEnum; /** * A string specifying which type of media you would like to get. */ export const QueryParamType = { Video: "Video", Audio: "Audio", Image: "Image", PdfDocument: "PdfDocument", MicrosoftOfficeDocument: "MicrosoftOfficeDocument", Swf: "Swf", UnknownType: "UnknownType", } as const; /** * A string specifying which type of media you would like to get. */ export type QueryParamType = ClosedEnum; export type GetMediasRequest = { /** * The page number to retrieve. This cannot be combined with `cursor`, * * @remarks * pagination. */ page?: number | undefined; /** * The number of medias per page. Use this for both offset pagination and cursor pagination. */ perPage?: number | undefined; /** * If `cursor[enabled]` is set to 1 than cursor pagination is enabled and the * * @remarks * first set of records are fetched up to the `per_page`. Cursor * pagination will also be turned on if `cursor[before]` or `cursor[after]` * are set. Records returned will have a `cursor` property set which can be used to fetch more records in the same `sort_by` ordering. * The cursor value of the last record can be used to fetch records after the current result set and * the cursor of the first record can be used to fetch records before the result set. * * NOTE: a cursor value is only valid if the `sort_by` value hasn't changed from the * last fetch. For example, you cannot fetch using `sort_by` id and than pass that * cursor value to a `sort_by` name. */ cursor?: GetMediasCursor | undefined; /** * Ordering. When using cursor pagination (see cursor param), * * @remarks * only `id` and `created` are supported. All other sort_by options (`name`, `updated`, `position`) * require offset pagination. */ sortBy?: GetMediasSortBy | undefined; /** * Ordering Sort Direction (0 = desc, 1 = asc; default is 1) */ sortDirection?: GetMediasSortDirection | undefined; /** * A hashed ID specifying the folder from which you would like to get results. */ folderId?: string | undefined; /** * Find a media or medias whose name exactly matches this parameter. */ name?: string | undefined; /** * Format for media descriptions */ descriptionFormat?: "markdown" | undefined; /** * A string specifying which type of media you would like to get. */ type?: QueryParamType | undefined; /** * Find all of the medias by these hashed_ids. */ hashedIds?: Array | undefined; /** * Find all of the medias that match all of these tag names. */ tags?: Array | undefined; /** * Filter by archived status. True will return only archived medias, while false will return only active medias. */ archived?: boolean | undefined; }; /** * A string representing what type of media this is. */ export const GetMediasTypeResponse = { 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 GetMediasTypeResponse = 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 GetMediasStatus = { 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 GetMediasStatus = ClosedEnum; export type GetMediasThumbnail = { url?: string | undefined; width?: number | undefined; height?: number | undefined; }; export type GetMediasFolder = { /** * A unique numeric identifier for the folder within the system. */ id?: number | undefined; /** * The folder’s display name. */ name?: string | undefined; /** * A private hashed id, uniquely identifying the folder within the system. */ hashedId?: string | undefined; }; export type GetMediasAsset = { /** * A direct-access URL to the content of the asset. */ url?: string | undefined; /** * The width of this specific asset, if applicable. */ width?: number | null | undefined; /** * The height of this specific asset, if applicable. */ height?: number | null | undefined; /** * The size of the asset file that’s referenced by url, measured in bytes. */ fileSize?: number | null | undefined; /** * The asset’s content type. */ contentType?: string | null | undefined; /** * The internal type of the asset, describing how the asset should be used. Values can include OriginalFile, FlashVideoFile, MdFlashVideoFile, HdFlashVideoFile, Mp4VideoFile, MdMp4VideoFile, HdMp4VideoFile, IPhoneVideoFile, StillImageFile, SwfFile, Mp3AudioFile, and LargeImageFile. * * @remarks */ type?: string | undefined; }; /** * A subfolder within a folder that contains media. */ export type GetMediasSubfolder = { /** * 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; }; export type GetMediasTag = { /** * The display name of the tag. */ name?: string | undefined; }; /** * 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 GetMediasResponse = { /** * 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?: GetMediasTypeResponse | 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?: GetMediasStatus | 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?: GetMediasThumbnail | undefined; folder: GetMediasFolder | null; /** * An array of the assets available for this media. */ assets?: Array | undefined; /** * The subfolder (media group) in which the media appears. Null if the media is not in a subfolder. */ subfolder?: GetMediasSubfolder | undefined; /** * Tags associated with this media. */ tags?: Array | 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; }; /** @internal */ export const GetMediasEnabled$outboundSchema: z.ZodNativeEnum< typeof GetMediasEnabled > = z.nativeEnum(GetMediasEnabled); /** @internal */ export type GetMediasCursor$Outbound = { enabled?: number | undefined; before?: string | undefined; after?: string | undefined; }; /** @internal */ export const GetMediasCursor$outboundSchema: z.ZodType< GetMediasCursor$Outbound, z.ZodTypeDef, GetMediasCursor > = z.object({ enabled: GetMediasEnabled$outboundSchema.optional(), before: z.string().optional(), after: z.string().optional(), }); export function getMediasCursorToJSON( getMediasCursor: GetMediasCursor, ): string { return JSON.stringify(GetMediasCursor$outboundSchema.parse(getMediasCursor)); } /** @internal */ export const GetMediasSortBy$outboundSchema: z.ZodNativeEnum< typeof GetMediasSortBy > = z.nativeEnum(GetMediasSortBy); /** @internal */ export const GetMediasSortDirection$outboundSchema: z.ZodNativeEnum< typeof GetMediasSortDirection > = z.nativeEnum(GetMediasSortDirection); /** @internal */ export const QueryParamType$outboundSchema: z.ZodNativeEnum< typeof QueryParamType > = z.nativeEnum(QueryParamType); /** @internal */ export type GetMediasRequest$Outbound = { page?: number | undefined; per_page?: number | undefined; cursor?: GetMediasCursor$Outbound | undefined; sort_by?: string | undefined; sort_direction?: number | undefined; folder_id?: string | undefined; name?: string | undefined; description_format?: "markdown" | undefined; type?: string | undefined; "hashed_ids[]"?: Array | undefined; "tags[]"?: Array | undefined; archived?: boolean | undefined; }; /** @internal */ export const GetMediasRequest$outboundSchema: z.ZodType< GetMediasRequest$Outbound, z.ZodTypeDef, GetMediasRequest > = z.object({ page: z.number().int().optional(), perPage: z.number().int().optional(), cursor: z.lazy(() => GetMediasCursor$outboundSchema).optional(), sortBy: GetMediasSortBy$outboundSchema.optional(), sortDirection: GetMediasSortDirection$outboundSchema.optional(), folderId: z.string().optional(), name: z.string().optional(), descriptionFormat: z.literal("markdown").optional(), type: QueryParamType$outboundSchema.optional(), hashedIds: z.array(z.string()).optional(), tags: z.array(z.string()).optional(), archived: z.boolean().optional(), }).transform((v) => { return remap$(v, { perPage: "per_page", sortBy: "sort_by", sortDirection: "sort_direction", folderId: "folder_id", descriptionFormat: "description_format", hashedIds: "hashed_ids[]", tags: "tags[]", }); }); export function getMediasRequestToJSON( getMediasRequest: GetMediasRequest, ): string { return JSON.stringify( GetMediasRequest$outboundSchema.parse(getMediasRequest), ); } /** @internal */ export const GetMediasTypeResponse$inboundSchema: z.ZodNativeEnum< typeof GetMediasTypeResponse > = z.nativeEnum(GetMediasTypeResponse); /** @internal */ export const GetMediasStatus$inboundSchema: z.ZodNativeEnum< typeof GetMediasStatus > = z.nativeEnum(GetMediasStatus); /** @internal */ export const GetMediasThumbnail$inboundSchema: z.ZodType< GetMediasThumbnail, z.ZodTypeDef, unknown > = z.object({ url: z.string().optional(), width: z.number().int().optional(), height: z.number().int().optional(), }); export function getMediasThumbnailFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetMediasThumbnail$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetMediasThumbnail' from JSON`, ); } /** @internal */ export const GetMediasFolder$inboundSchema: z.ZodType< GetMediasFolder, z.ZodTypeDef, unknown > = z.object({ id: z.number().int().optional(), name: z.string().optional(), hashedId: z.string().optional(), }); export function getMediasFolderFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetMediasFolder$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetMediasFolder' from JSON`, ); } /** @internal */ export const GetMediasAsset$inboundSchema: z.ZodType< GetMediasAsset, z.ZodTypeDef, unknown > = z.object({ url: z.string().optional(), width: z.nullable(z.number().int()).optional(), height: z.nullable(z.number().int()).optional(), file_size: z.nullable(z.number().int()).optional(), content_type: z.nullable(z.string()).optional(), type: z.string().optional(), }).transform((v) => { return remap$(v, { "file_size": "fileSize", "content_type": "contentType", }); }); export function getMediasAssetFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetMediasAsset$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetMediasAsset' from JSON`, ); } /** @internal */ export const GetMediasSubfolder$inboundSchema: z.ZodType< GetMediasSubfolder, 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 getMediasSubfolderFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetMediasSubfolder$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetMediasSubfolder' from JSON`, ); } /** @internal */ export const GetMediasTag$inboundSchema: z.ZodType< GetMediasTag, z.ZodTypeDef, unknown > = z.object({ name: z.string().optional(), }); export function getMediasTagFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetMediasTag$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetMediasTag' from JSON`, ); } /** @internal */ export const GetMediasResponse$inboundSchema: z.ZodType< GetMediasResponse, z.ZodTypeDef, unknown > = z.object({ id: z.number().int().optional(), name: z.string().optional(), type: GetMediasTypeResponse$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: GetMediasStatus$inboundSchema.optional(), section: z.nullable(z.string()).optional(), thumbnail: z.lazy(() => GetMediasThumbnail$inboundSchema).optional(), folder: z.nullable(z.lazy(() => GetMediasFolder$inboundSchema)), assets: z.array(z.lazy(() => GetMediasAsset$inboundSchema)).optional(), subfolder: z.lazy(() => GetMediasSubfolder$inboundSchema).optional(), tags: z.array(z.lazy(() => GetMediasTag$inboundSchema)).optional(), cursor: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "hashed_id": "hashedId", }); }); export function getMediasResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetMediasResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetMediasResponse' from JSON`, ); }