/* * 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 GetFoldersFolderIdSubfoldersEnabled = { 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 GetFoldersFolderIdSubfoldersEnabled = ClosedEnum< typeof GetFoldersFolderIdSubfoldersEnabled >; /** * 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 GetFoldersFolderIdSubfoldersCursor = { /** * 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?: GetFoldersFolderIdSubfoldersEnabled | 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; }; /** * Field to sort by. When using cursor pagination (see cursor param), * * @remarks * only `id` is supported. */ export const GetFoldersFolderIdSubfoldersSortBy = { Name: "name", Created: "created", Updated: "updated", Position: "position", Id: "id", } as const; /** * Field to sort by. When using cursor pagination (see cursor param), * * @remarks * only `id` is supported. */ export type GetFoldersFolderIdSubfoldersSortBy = ClosedEnum< typeof GetFoldersFolderIdSubfoldersSortBy >; /** * Sort direction (0 = desc, 1 = asc; default is 1) */ export const GetFoldersFolderIdSubfoldersSortDirection = { Zero: 0, One: 1, } as const; /** * Sort direction (0 = desc, 1 = asc; default is 1) */ export type GetFoldersFolderIdSubfoldersSortDirection = ClosedEnum< typeof GetFoldersFolderIdSubfoldersSortDirection >; export type GetFoldersFolderIdSubfoldersRequest = { /** * The hashed ID of the folder */ folderId: string; /** * 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?: GetFoldersFolderIdSubfoldersCursor | undefined; /** * Field to sort by. When using cursor pagination (see cursor param), * * @remarks * only `id` is supported. */ sortBy?: GetFoldersFolderIdSubfoldersSortBy | undefined; /** * Sort direction (0 = desc, 1 = asc; default is 1) */ sortDirection?: GetFoldersFolderIdSubfoldersSortDirection | undefined; /** * Filter subfolders by their hashed IDs */ hashedIds?: Array | undefined; }; /** * A subfolder within a folder that contains media. */ export type GetFoldersFolderIdSubfoldersResponse = { /** * 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; }; /** @internal */ export const GetFoldersFolderIdSubfoldersEnabled$outboundSchema: z.ZodNativeEnum = z.nativeEnum( GetFoldersFolderIdSubfoldersEnabled, ); /** @internal */ export type GetFoldersFolderIdSubfoldersCursor$Outbound = { enabled?: number | undefined; before?: string | undefined; after?: string | undefined; }; /** @internal */ export const GetFoldersFolderIdSubfoldersCursor$outboundSchema: z.ZodType< GetFoldersFolderIdSubfoldersCursor$Outbound, z.ZodTypeDef, GetFoldersFolderIdSubfoldersCursor > = z.object({ enabled: GetFoldersFolderIdSubfoldersEnabled$outboundSchema.optional(), before: z.string().optional(), after: z.string().optional(), }); export function getFoldersFolderIdSubfoldersCursorToJSON( getFoldersFolderIdSubfoldersCursor: GetFoldersFolderIdSubfoldersCursor, ): string { return JSON.stringify( GetFoldersFolderIdSubfoldersCursor$outboundSchema.parse( getFoldersFolderIdSubfoldersCursor, ), ); } /** @internal */ export const GetFoldersFolderIdSubfoldersSortBy$outboundSchema: z.ZodNativeEnum< typeof GetFoldersFolderIdSubfoldersSortBy > = z.nativeEnum(GetFoldersFolderIdSubfoldersSortBy); /** @internal */ export const GetFoldersFolderIdSubfoldersSortDirection$outboundSchema: z.ZodNativeEnum = z .nativeEnum(GetFoldersFolderIdSubfoldersSortDirection); /** @internal */ export type GetFoldersFolderIdSubfoldersRequest$Outbound = { folderId: string; page?: number | undefined; per_page?: number | undefined; cursor?: GetFoldersFolderIdSubfoldersCursor$Outbound | undefined; sort_by: string; sort_direction: number; "hashed_ids[]"?: Array | undefined; }; /** @internal */ export const GetFoldersFolderIdSubfoldersRequest$outboundSchema: z.ZodType< GetFoldersFolderIdSubfoldersRequest$Outbound, z.ZodTypeDef, GetFoldersFolderIdSubfoldersRequest > = z.object({ folderId: z.string(), page: z.number().int().optional(), perPage: z.number().int().optional(), cursor: z.lazy(() => GetFoldersFolderIdSubfoldersCursor$outboundSchema) .optional(), sortBy: GetFoldersFolderIdSubfoldersSortBy$outboundSchema.default("position"), sortDirection: GetFoldersFolderIdSubfoldersSortDirection$outboundSchema .default(1), 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 getFoldersFolderIdSubfoldersRequestToJSON( getFoldersFolderIdSubfoldersRequest: GetFoldersFolderIdSubfoldersRequest, ): string { return JSON.stringify( GetFoldersFolderIdSubfoldersRequest$outboundSchema.parse( getFoldersFolderIdSubfoldersRequest, ), ); } /** @internal */ export const GetFoldersFolderIdSubfoldersResponse$inboundSchema: z.ZodType< GetFoldersFolderIdSubfoldersResponse, 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 getFoldersFolderIdSubfoldersResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetFoldersFolderIdSubfoldersResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetFoldersFolderIdSubfoldersResponse' from JSON`, ); }