@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>
565 lines (496 loc) • 15.7 kB
text/typescript
/*
* 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",
CursorOrigin: "cursor-origin",
} 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 SearchRepoResponseBodyIntegrationsProvider = {
Bitbucket: "bitbucket",
CursorOrigin: "cursor-origin",
Github: "github",
GithubCustomHost: "github-custom-host",
GithubLimited: "github-limited",
Gitlab: "gitlab",
Vercel: "vercel",
} as const;
export type SearchRepoResponseBodyIntegrationsProvider = ClosedEnum<
typeof SearchRepoResponseBodyIntegrationsProvider
>;
export type ResponseBodyNamespaceId = string | number;
export type ResponseBodyGitAccount = {
provider: SearchRepoResponseBodyIntegrationsProvider;
namespaceId: string | number | null;
};
export type ResponseBodyId = string | number;
export const SearchRepoResponseBodyIntegrationsResponseProvider = {
Bitbucket: "bitbucket",
CursorOrigin: "cursor-origin",
Github: "github",
GithubCustomHost: "github-custom-host",
GithubLimited: "github-limited",
Gitlab: "gitlab",
Vercel: "vercel",
} as const;
export type SearchRepoResponseBodyIntegrationsResponseProvider = ClosedEnum<
typeof SearchRepoResponseBodyIntegrationsResponseProvider
>;
export type SearchRepoResponseBodyId = string | number;
export type SearchRepoResponseBodyOwner = {
id: string | number;
name: string;
};
export const SearchRepoResponseBodyOwnerType = {
Team: "team",
User: "user",
} as const;
export type SearchRepoResponseBodyOwnerType = ClosedEnum<
typeof SearchRepoResponseBodyOwnerType
>;
export type ResponseBodyRepos = {
id: string | number;
provider: SearchRepoResponseBodyIntegrationsResponseProvider;
url: string;
name: string;
slug: string;
namespace: string;
owner: SearchRepoResponseBodyOwner;
ownerType: SearchRepoResponseBodyOwnerType;
private: boolean;
defaultBranch: string;
updatedAt: number;
};
export type ResponseBody4 = {
gitAccount: ResponseBodyGitAccount;
repos: Array<ResponseBodyRepos>;
};
export type GitAccount = {
provider: string;
namespaceId: string | null;
};
export const SearchRepoResponseBodyProvider = {
CursorOrigin: "cursor-origin",
} as const;
export type SearchRepoResponseBodyProvider = ClosedEnum<
typeof SearchRepoResponseBodyProvider
>;
export const ResponseBodyOwnerType = {
Team: "team",
User: "user",
} as const;
export type ResponseBodyOwnerType = ClosedEnum<typeof ResponseBodyOwnerType>;
export type ResponseBodyOwner = {
id: string;
name: string;
};
export type Repos = {
id: string;
provider: SearchRepoResponseBodyProvider;
url: string;
name: string;
slug: string;
namespace: string;
ownerType: ResponseBodyOwnerType;
owner: ResponseBodyOwner;
private: boolean;
defaultBranch: string;
updatedAt: number;
};
export type SearchRepoResponseBody3 = {
gitAccount: GitAccount;
repos: Array<Repos>;
};
export const ResponseBodyCode = {
InstallationNotFound: "installation_not_found",
} as const;
export type ResponseBodyCode = ClosedEnum<typeof ResponseBodyCode>;
export type SearchRepoResponseBodyError = {
code: ResponseBodyCode;
message: string;
};
export type SearchRepoResponseBody2 = {
error: SearchRepoResponseBodyError;
};
export type SearchRepoResponseBody1 = {};
export type SearchRepoResponseBody =
| SearchRepoResponseBody3
| ResponseBody4
| 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 SearchRepoResponseBodyIntegrationsProvider$inboundSchema:
z.ZodNativeEnum<typeof SearchRepoResponseBodyIntegrationsProvider> = z
.nativeEnum(SearchRepoResponseBodyIntegrationsProvider);
/** @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 ResponseBodyGitAccount$inboundSchema: z.ZodType<
ResponseBodyGitAccount,
z.ZodTypeDef,
unknown
> = z.object({
provider: SearchRepoResponseBodyIntegrationsProvider$inboundSchema,
namespaceId: types.nullable(smartUnion([types.string(), types.number()])),
});
export function responseBodyGitAccountFromJSON(
jsonString: string,
): SafeParseResult<ResponseBodyGitAccount, SDKValidationError> {
return safeParse(
jsonString,
(x) => ResponseBodyGitAccount$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ResponseBodyGitAccount' 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 SearchRepoResponseBodyIntegrationsResponseProvider$inboundSchema:
z.ZodNativeEnum<typeof SearchRepoResponseBodyIntegrationsResponseProvider> = z
.nativeEnum(SearchRepoResponseBodyIntegrationsResponseProvider);
/** @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 SearchRepoResponseBodyOwner$inboundSchema: z.ZodType<
SearchRepoResponseBodyOwner,
z.ZodTypeDef,
unknown
> = z.object({
id: smartUnion([types.string(), types.number()]),
name: types.string(),
});
export function searchRepoResponseBodyOwnerFromJSON(
jsonString: string,
): SafeParseResult<SearchRepoResponseBodyOwner, SDKValidationError> {
return safeParse(
jsonString,
(x) => SearchRepoResponseBodyOwner$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'SearchRepoResponseBodyOwner' from JSON`,
);
}
/** @internal */
export const SearchRepoResponseBodyOwnerType$inboundSchema: z.ZodNativeEnum<
typeof SearchRepoResponseBodyOwnerType
> = z.nativeEnum(SearchRepoResponseBodyOwnerType);
/** @internal */
export const ResponseBodyRepos$inboundSchema: z.ZodType<
ResponseBodyRepos,
z.ZodTypeDef,
unknown
> = z.object({
id: smartUnion([types.string(), types.number()]),
provider: SearchRepoResponseBodyIntegrationsResponseProvider$inboundSchema,
url: types.string(),
name: types.string(),
slug: types.string(),
namespace: types.string(),
owner: z.lazy(() => SearchRepoResponseBodyOwner$inboundSchema),
ownerType: SearchRepoResponseBodyOwnerType$inboundSchema,
private: types.boolean(),
defaultBranch: types.string(),
updatedAt: types.number(),
});
export function responseBodyReposFromJSON(
jsonString: string,
): SafeParseResult<ResponseBodyRepos, SDKValidationError> {
return safeParse(
jsonString,
(x) => ResponseBodyRepos$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ResponseBodyRepos' from JSON`,
);
}
/** @internal */
export const ResponseBody4$inboundSchema: z.ZodType<
ResponseBody4,
z.ZodTypeDef,
unknown
> = z.object({
gitAccount: z.lazy(() => ResponseBodyGitAccount$inboundSchema),
repos: z.array(z.lazy(() => ResponseBodyRepos$inboundSchema)),
});
export function responseBody4FromJSON(
jsonString: string,
): SafeParseResult<ResponseBody4, SDKValidationError> {
return safeParse(
jsonString,
(x) => ResponseBody4$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ResponseBody4' from JSON`,
);
}
/** @internal */
export const GitAccount$inboundSchema: z.ZodType<
GitAccount,
z.ZodTypeDef,
unknown
> = z.object({
provider: types.string(),
namespaceId: types.nullable(types.string()),
});
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 SearchRepoResponseBodyProvider$inboundSchema: z.ZodNativeEnum<
typeof SearchRepoResponseBodyProvider
> = z.nativeEnum(SearchRepoResponseBodyProvider);
/** @internal */
export const ResponseBodyOwnerType$inboundSchema: z.ZodNativeEnum<
typeof ResponseBodyOwnerType
> = z.nativeEnum(ResponseBodyOwnerType);
/** @internal */
export const ResponseBodyOwner$inboundSchema: z.ZodType<
ResponseBodyOwner,
z.ZodTypeDef,
unknown
> = z.object({
id: types.string(),
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 Repos$inboundSchema: z.ZodType<Repos, z.ZodTypeDef, unknown> = z
.object({
id: types.string(),
provider: SearchRepoResponseBodyProvider$inboundSchema,
url: types.string(),
name: types.string(),
slug: types.string(),
namespace: types.string(),
ownerType: ResponseBodyOwnerType$inboundSchema,
owner: z.lazy(() => ResponseBodyOwner$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 SearchRepoResponseBody3$inboundSchema: z.ZodType<
SearchRepoResponseBody3,
z.ZodTypeDef,
unknown
> = z.object({
gitAccount: z.lazy(() => GitAccount$inboundSchema),
repos: z.array(z.lazy(() => Repos$inboundSchema)),
});
export function searchRepoResponseBody3FromJSON(
jsonString: string,
): SafeParseResult<SearchRepoResponseBody3, SDKValidationError> {
return safeParse(
jsonString,
(x) => SearchRepoResponseBody3$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'SearchRepoResponseBody3' from JSON`,
);
}
/** @internal */
export const ResponseBodyCode$inboundSchema: z.ZodNativeEnum<
typeof ResponseBodyCode
> = z.nativeEnum(ResponseBodyCode);
/** @internal */
export const SearchRepoResponseBodyError$inboundSchema: z.ZodType<
SearchRepoResponseBodyError,
z.ZodTypeDef,
unknown
> = z.object({
code: ResponseBodyCode$inboundSchema,
message: types.string(),
});
export function searchRepoResponseBodyErrorFromJSON(
jsonString: string,
): SafeParseResult<SearchRepoResponseBodyError, SDKValidationError> {
return safeParse(
jsonString,
(x) => SearchRepoResponseBodyError$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'SearchRepoResponseBodyError' from JSON`,
);
}
/** @internal */
export const SearchRepoResponseBody2$inboundSchema: z.ZodType<
SearchRepoResponseBody2,
z.ZodTypeDef,
unknown
> = z.object({
error: z.lazy(() => SearchRepoResponseBodyError$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(() => SearchRepoResponseBody3$inboundSchema),
z.lazy(() => ResponseBody4$inboundSchema),
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`,
);
}