/* * 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 GetFoldersEnabled = { 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 GetFoldersEnabled = 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 GetFoldersCursor = { /** * 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?: GetFoldersEnabled | 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`, `updated` and `created` are supported. All other sort_by options * require offset pagination. */ export const GetFoldersSortBy = { Name: "name", Created: "created", Updated: "updated", MediaCount: "mediaCount", Id: "id", } as const; /** * Ordering. When using cursor pagination (see cursor param), * * @remarks * only `id`, `updated` and `created` are supported. All other sort_by options * require offset pagination. */ export type GetFoldersSortBy = ClosedEnum; /** * Ordering Sort Direction (0 = desc, 1 = asc; default is 1) */ export const GetFoldersSortDirection = { Zero: 0, One: 1, } as const; /** * Ordering Sort Direction (0 = desc, 1 = asc; default is 1) */ export type GetFoldersSortDirection = ClosedEnum< typeof GetFoldersSortDirection >; export type GetFoldersRequest = { /** * 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?: GetFoldersCursor | undefined; /** * Ordering. When using cursor pagination (see cursor param), * * @remarks * only `id`, `updated` and `created` are supported. All other sort_by options * require offset pagination. */ sortBy?: GetFoldersSortBy | undefined; /** * Ordering Sort Direction (0 = desc, 1 = asc; default is 1) */ sortDirection?: GetFoldersSortDirection | undefined; /** * A collection of hashed ids belonging to folders to fetch */ hashedIds?: Array | undefined; }; /** * A string representing what type of media this is. */ export const GetFoldersType = { 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 GetFoldersType = 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 GetFoldersStatus = { 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 GetFoldersStatus = ClosedEnum; export type GetFoldersThumbnail = { url?: string | undefined; width?: number | undefined; height?: number | undefined; }; /** * A link to where you can fetch the medias for this folder. */ export type GetFoldersMedias = { /** * 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?: GetFoldersType | 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?: GetFoldersStatus | 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?: GetFoldersThumbnail | 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 GetFoldersResponse = { /** * 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: GetFoldersMedias; /** * 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; }; /** @internal */ export const GetFoldersEnabled$outboundSchema: z.ZodNativeEnum< typeof GetFoldersEnabled > = z.nativeEnum(GetFoldersEnabled); /** @internal */ export type GetFoldersCursor$Outbound = { enabled?: number | undefined; before?: string | undefined; after?: string | undefined; }; /** @internal */ export const GetFoldersCursor$outboundSchema: z.ZodType< GetFoldersCursor$Outbound, z.ZodTypeDef, GetFoldersCursor > = z.object({ enabled: GetFoldersEnabled$outboundSchema.optional(), before: z.string().optional(), after: z.string().optional(), }); export function getFoldersCursorToJSON( getFoldersCursor: GetFoldersCursor, ): string { return JSON.stringify( GetFoldersCursor$outboundSchema.parse(getFoldersCursor), ); } /** @internal */ export const GetFoldersSortBy$outboundSchema: z.ZodNativeEnum< typeof GetFoldersSortBy > = z.nativeEnum(GetFoldersSortBy); /** @internal */ export const GetFoldersSortDirection$outboundSchema: z.ZodNativeEnum< typeof GetFoldersSortDirection > = z.nativeEnum(GetFoldersSortDirection); /** @internal */ export type GetFoldersRequest$Outbound = { page?: number | undefined; per_page?: number | undefined; cursor?: GetFoldersCursor$Outbound | undefined; sort_by?: string | undefined; sort_direction?: number | undefined; "hashed_ids[]"?: Array | undefined; }; /** @internal */ export const GetFoldersRequest$outboundSchema: z.ZodType< GetFoldersRequest$Outbound, z.ZodTypeDef, GetFoldersRequest > = z.object({ page: z.number().int().optional(), perPage: z.number().int().optional(), cursor: z.lazy(() => GetFoldersCursor$outboundSchema).optional(), sortBy: GetFoldersSortBy$outboundSchema.optional(), sortDirection: GetFoldersSortDirection$outboundSchema.optional(), hashedIds: z.array(z.string()).optional(), }).transform((v) => { return remap$(v, { perPage: "per_page", sortBy: "sort_by", sortDirection: "sort_direction", hashedIds: "hashed_ids[]", }); }); export function getFoldersRequestToJSON( getFoldersRequest: GetFoldersRequest, ): string { return JSON.stringify( GetFoldersRequest$outboundSchema.parse(getFoldersRequest), ); } /** @internal */ export const GetFoldersType$inboundSchema: z.ZodNativeEnum< typeof GetFoldersType > = z.nativeEnum(GetFoldersType); /** @internal */ export const GetFoldersStatus$inboundSchema: z.ZodNativeEnum< typeof GetFoldersStatus > = z.nativeEnum(GetFoldersStatus); /** @internal */ export const GetFoldersThumbnail$inboundSchema: z.ZodType< GetFoldersThumbnail, z.ZodTypeDef, unknown > = z.object({ url: z.string().optional(), width: z.number().int().optional(), height: z.number().int().optional(), }); export function getFoldersThumbnailFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetFoldersThumbnail$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetFoldersThumbnail' from JSON`, ); } /** @internal */ export const GetFoldersMedias$inboundSchema: z.ZodType< GetFoldersMedias, z.ZodTypeDef, unknown > = z.object({ id: z.number().int().optional(), name: z.string().optional(), type: GetFoldersType$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: GetFoldersStatus$inboundSchema.optional(), section: z.nullable(z.string()).optional(), thumbnail: z.lazy(() => GetFoldersThumbnail$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "hashed_id": "hashedId", }); }); export function getFoldersMediasFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetFoldersMedias$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetFoldersMedias' from JSON`, ); } /** @internal */ export const GetFoldersResponse$inboundSchema: z.ZodType< GetFoldersResponse, 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(() => GetFoldersMedias$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 getFoldersResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetFoldersResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetFoldersResponse' from JSON`, ); }