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>

357 lines (312 loc) 9.99 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 { SDKValidationError } from "./sdkvalidationerror.js"; export type NamespaceId = string | number; export const SearchRepoQueryParamProvider = { Github: "github", GithubLimited: "github-limited", GithubCustomHost: "github-custom-host", Gitlab: "gitlab", Bitbucket: "bitbucket", } as const; export type SearchRepoQueryParamProvider = ClosedEnum< typeof SearchRepoQueryParamProvider >; export type SearchRepoRequest = { query?: string | undefined; namespaceId?: string | number | null | undefined; provider?: SearchRepoQueryParamProvider | undefined; installationId?: string | undefined; /** * The custom Git host if using a custom Git provider, like GitHub Enterprise Server */ host?: 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 const SearchRepoResponseBodyProvider = { Bitbucket: "bitbucket", Github: "github", GithubCustomHost: "github-custom-host", GithubLimited: "github-limited", Gitlab: "gitlab", Vercel: "vercel", } as const; export type SearchRepoResponseBodyProvider = ClosedEnum< typeof SearchRepoResponseBodyProvider >; export type ResponseBodyNamespaceId = string | number; export type GitAccount = { provider: SearchRepoResponseBodyProvider; namespaceId: string | number | null; }; export type ResponseBodyId = string | number; export const SearchRepoResponseBodyIntegrationsProvider = { Bitbucket: "bitbucket", Github: "github", GithubCustomHost: "github-custom-host", GithubLimited: "github-limited", Gitlab: "gitlab", Vercel: "vercel", } as const; export type SearchRepoResponseBodyIntegrationsProvider = ClosedEnum< typeof SearchRepoResponseBodyIntegrationsProvider >; export type SearchRepoResponseBodyId = string | number; export type ResponseBodyOwner = { id: string | number; name: string; }; export const ResponseBodyOwnerType = { Team: "team", User: "user", } as const; export type ResponseBodyOwnerType = ClosedEnum<typeof ResponseBodyOwnerType>; export type Repos = { id: string | number; provider: SearchRepoResponseBodyIntegrationsProvider; url: string; name: string; slug: string; namespace: string; owner: ResponseBodyOwner; ownerType: ResponseBodyOwnerType; private: boolean; defaultBranch: string; updatedAt: number; }; export type SearchRepoResponseBody2 = { gitAccount: GitAccount; repos: Array<Repos>; }; export type SearchRepoResponseBody1 = {}; export type SearchRepoResponseBody = | SearchRepoResponseBody2 | SearchRepoResponseBody1; /** @internal */ export type NamespaceId$Outbound = string | number; /** @internal */ export const NamespaceId$outboundSchema: z.ZodType< NamespaceId$Outbound, z.ZodTypeDef, NamespaceId > = smartUnion([z.string(), z.number()]); export function namespaceIdToJSON(namespaceId: NamespaceId): string { return JSON.stringify(NamespaceId$outboundSchema.parse(namespaceId)); } /** @internal */ export const SearchRepoQueryParamProvider$outboundSchema: z.ZodNativeEnum< typeof SearchRepoQueryParamProvider > = z.nativeEnum(SearchRepoQueryParamProvider); /** @internal */ export type SearchRepoRequest$Outbound = { query?: string | undefined; namespaceId?: string | number | null | undefined; provider?: string | undefined; installationId?: string | undefined; host?: string | undefined; teamId?: string | undefined; slug?: string | undefined; }; /** @internal */ export const SearchRepoRequest$outboundSchema: z.ZodType< SearchRepoRequest$Outbound, z.ZodTypeDef, SearchRepoRequest > = z.object({ query: z.string().optional(), namespaceId: z.nullable(smartUnion([z.string(), z.number()])).optional(), provider: SearchRepoQueryParamProvider$outboundSchema.optional(), installationId: z.string().optional(), host: z.string().optional(), teamId: z.string().optional(), slug: z.string().optional(), }); export function searchRepoRequestToJSON( searchRepoRequest: SearchRepoRequest, ): string { return JSON.stringify( SearchRepoRequest$outboundSchema.parse(searchRepoRequest), ); } /** @internal */ export const SearchRepoResponseBodyProvider$inboundSchema: z.ZodNativeEnum< typeof SearchRepoResponseBodyProvider > = z.nativeEnum(SearchRepoResponseBodyProvider); /** @internal */ export const ResponseBodyNamespaceId$inboundSchema: z.ZodType< ResponseBodyNamespaceId, z.ZodTypeDef, unknown > = smartUnion([types.string(), types.number()]); export function responseBodyNamespaceIdFromJSON( jsonString: string, ): SafeParseResult<ResponseBodyNamespaceId, SDKValidationError> { return safeParse( jsonString, (x) => ResponseBodyNamespaceId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResponseBodyNamespaceId' from JSON`, ); } /** @internal */ export const GitAccount$inboundSchema: z.ZodType< GitAccount, z.ZodTypeDef, unknown > = z.object({ provider: SearchRepoResponseBodyProvider$inboundSchema, namespaceId: types.nullable(smartUnion([types.string(), types.number()])), }); export function gitAccountFromJSON( jsonString: string, ): SafeParseResult<GitAccount, SDKValidationError> { return safeParse( jsonString, (x) => GitAccount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GitAccount' from JSON`, ); } /** @internal */ export const ResponseBodyId$inboundSchema: z.ZodType< ResponseBodyId, z.ZodTypeDef, unknown > = smartUnion([types.string(), types.number()]); export function responseBodyIdFromJSON( jsonString: string, ): SafeParseResult<ResponseBodyId, SDKValidationError> { return safeParse( jsonString, (x) => ResponseBodyId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResponseBodyId' from JSON`, ); } /** @internal */ export const SearchRepoResponseBodyIntegrationsProvider$inboundSchema: z.ZodNativeEnum<typeof SearchRepoResponseBodyIntegrationsProvider> = z .nativeEnum(SearchRepoResponseBodyIntegrationsProvider); /** @internal */ export const SearchRepoResponseBodyId$inboundSchema: z.ZodType< SearchRepoResponseBodyId, z.ZodTypeDef, unknown > = smartUnion([types.string(), types.number()]); export function searchRepoResponseBodyIdFromJSON( jsonString: string, ): SafeParseResult<SearchRepoResponseBodyId, SDKValidationError> { return safeParse( jsonString, (x) => SearchRepoResponseBodyId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SearchRepoResponseBodyId' from JSON`, ); } /** @internal */ export const ResponseBodyOwner$inboundSchema: z.ZodType< ResponseBodyOwner, z.ZodTypeDef, unknown > = z.object({ id: smartUnion([types.string(), types.number()]), name: types.string(), }); export function responseBodyOwnerFromJSON( jsonString: string, ): SafeParseResult<ResponseBodyOwner, SDKValidationError> { return safeParse( jsonString, (x) => ResponseBodyOwner$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResponseBodyOwner' from JSON`, ); } /** @internal */ export const ResponseBodyOwnerType$inboundSchema: z.ZodNativeEnum< typeof ResponseBodyOwnerType > = z.nativeEnum(ResponseBodyOwnerType); /** @internal */ export const Repos$inboundSchema: z.ZodType<Repos, z.ZodTypeDef, unknown> = z .object({ id: smartUnion([types.string(), types.number()]), provider: SearchRepoResponseBodyIntegrationsProvider$inboundSchema, url: types.string(), name: types.string(), slug: types.string(), namespace: types.string(), owner: z.lazy(() => ResponseBodyOwner$inboundSchema), ownerType: ResponseBodyOwnerType$inboundSchema, private: types.boolean(), defaultBranch: types.string(), updatedAt: types.number(), }); export function reposFromJSON( jsonString: string, ): SafeParseResult<Repos, SDKValidationError> { return safeParse( jsonString, (x) => Repos$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Repos' from JSON`, ); } /** @internal */ export const SearchRepoResponseBody2$inboundSchema: z.ZodType< SearchRepoResponseBody2, z.ZodTypeDef, unknown > = z.object({ gitAccount: z.lazy(() => GitAccount$inboundSchema), repos: z.array(z.lazy(() => Repos$inboundSchema)), }); export function searchRepoResponseBody2FromJSON( jsonString: string, ): SafeParseResult<SearchRepoResponseBody2, SDKValidationError> { return safeParse( jsonString, (x) => SearchRepoResponseBody2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SearchRepoResponseBody2' from JSON`, ); } /** @internal */ export const SearchRepoResponseBody1$inboundSchema: z.ZodType< SearchRepoResponseBody1, z.ZodTypeDef, unknown > = z.object({}); export function searchRepoResponseBody1FromJSON( jsonString: string, ): SafeParseResult<SearchRepoResponseBody1, SDKValidationError> { return safeParse( jsonString, (x) => SearchRepoResponseBody1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SearchRepoResponseBody1' from JSON`, ); } /** @internal */ export const SearchRepoResponseBody$inboundSchema: z.ZodType< SearchRepoResponseBody, z.ZodTypeDef, unknown > = smartUnion([ z.lazy(() => SearchRepoResponseBody2$inboundSchema), z.lazy(() => SearchRepoResponseBody1$inboundSchema), ]); export function searchRepoResponseBodyFromJSON( jsonString: string, ): SafeParseResult<SearchRepoResponseBody, SDKValidationError> { return safeParse( jsonString, (x) => SearchRepoResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SearchRepoResponseBody' from JSON`, ); }