UNPKG

@vercel/sdk

Version:

<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>

195 lines (175 loc) 5.4 kB
/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../lib/schemas.js"; import { ClosedEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import * as types from "../types/primitives.js"; import { smartUnion } from "../types/smartUnion.js"; import { NamedSandbox, NamedSandbox$inboundSchema } from "./namedsandbox.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * Field to sort by. */ export const QueryParamSortBy = { CreatedAt: "createdAt", Name: "name", StatusUpdatedAt: "statusUpdatedAt", CurrentSnapshotId: "currentSnapshotId", } as const; /** * Field to sort by. */ export type QueryParamSortBy = ClosedEnum<typeof QueryParamSortBy>; /** * Sort direction. Defaults to desc. */ export const QueryParamSortOrder = { Asc: "asc", Desc: "desc", } as const; /** * Sort direction. Defaults to desc. */ export type QueryParamSortOrder = ClosedEnum<typeof QueryParamSortOrder>; /** * Filter sandboxes by tag. Format: \"key:value\". Only one tag filter is supported at a time. */ export type QueryParamTags = string | Array<string>; export type ListSandboxesRequest = { /** * The unique identifier or name of the project to list named sandboxes for. */ project?: string | undefined; /** * Maximum number of named sandboxes to return in the response. Used for pagination. */ limit?: number | undefined; /** * Field to sort by. */ sortBy?: QueryParamSortBy | undefined; /** * Filter named sandboxes whose name starts with this prefix. Only valid when sortBy=name. */ namePrefix?: string | undefined; /** * Opaque pagination cursor from a previous response. */ cursor?: string | undefined; /** * Sort direction. Defaults to desc. */ sortOrder?: QueryParamSortOrder | undefined; /** * Filter sandboxes by tag. Format: \"key:value\". Only one tag filter is supported at a time. */ tags?: string | Array<string> | undefined; /** * The Team identifier to perform the request on behalf of. */ teamId?: string | undefined; /** * The Team slug to perform the request on behalf of. */ slug?: string | undefined; }; export type ListSandboxesPagination = { count: number; next: string | null; }; export type ListSandboxesResponseBody = { sandboxes: Array<NamedSandbox>; pagination: ListSandboxesPagination; }; /** @internal */ export const QueryParamSortBy$outboundSchema: z.ZodNativeEnum< typeof QueryParamSortBy > = z.nativeEnum(QueryParamSortBy); /** @internal */ export const QueryParamSortOrder$outboundSchema: z.ZodNativeEnum< typeof QueryParamSortOrder > = z.nativeEnum(QueryParamSortOrder); /** @internal */ export type QueryParamTags$Outbound = string | Array<string>; /** @internal */ export const QueryParamTags$outboundSchema: z.ZodType< QueryParamTags$Outbound, z.ZodTypeDef, QueryParamTags > = smartUnion([z.string(), z.array(z.string())]); export function queryParamTagsToJSON(queryParamTags: QueryParamTags): string { return JSON.stringify(QueryParamTags$outboundSchema.parse(queryParamTags)); } /** @internal */ export type ListSandboxesRequest$Outbound = { project?: string | undefined; limit: number; sortBy: string; namePrefix?: string | undefined; cursor?: string | undefined; sortOrder: string; tags?: string | Array<string> | undefined; teamId?: string | undefined; slug?: string | undefined; }; /** @internal */ export const ListSandboxesRequest$outboundSchema: z.ZodType< ListSandboxesRequest$Outbound, z.ZodTypeDef, ListSandboxesRequest > = z.object({ project: z.string().optional(), limit: z.number().default(20), sortBy: QueryParamSortBy$outboundSchema.default("createdAt"), namePrefix: z.string().optional(), cursor: z.string().optional(), sortOrder: QueryParamSortOrder$outboundSchema.default("desc"), tags: smartUnion([z.string(), z.array(z.string())]).optional(), teamId: z.string().optional(), slug: z.string().optional(), }); export function listSandboxesRequestToJSON( listSandboxesRequest: ListSandboxesRequest, ): string { return JSON.stringify( ListSandboxesRequest$outboundSchema.parse(listSandboxesRequest), ); } /** @internal */ export const ListSandboxesPagination$inboundSchema: z.ZodType< ListSandboxesPagination, z.ZodTypeDef, unknown > = z.object({ count: types.number(), next: types.nullable(types.string()), }); export function listSandboxesPaginationFromJSON( jsonString: string, ): SafeParseResult<ListSandboxesPagination, SDKValidationError> { return safeParse( jsonString, (x) => ListSandboxesPagination$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListSandboxesPagination' from JSON`, ); } /** @internal */ export const ListSandboxesResponseBody$inboundSchema: z.ZodType< ListSandboxesResponseBody, z.ZodTypeDef, unknown > = z.object({ sandboxes: z.array(NamedSandbox$inboundSchema), pagination: z.lazy(() => ListSandboxesPagination$inboundSchema), }); export function listSandboxesResponseBodyFromJSON( jsonString: string, ): SafeParseResult<ListSandboxesResponseBody, SDKValidationError> { return safeParse( jsonString, (x) => ListSandboxesResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListSandboxesResponseBody' from JSON`, ); }