@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>
495 lines (455 loc) • 15.3 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 { Pagination, Pagination$inboundSchema } from "./pagination.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
/**
* Filters only production domains when set to `true`.
*/
export const Production = {
True: "true",
False: "false",
} as const;
/**
* Filters only production domains when set to `true`.
*/
export type Production = ClosedEnum<typeof Production>;
/**
* Filters on the target of the domain. Can be either "production", "preview"
*/
export const QueryParamTarget = {
Production: "production",
Preview: "preview",
} as const;
/**
* Filters on the target of the domain. Can be either "production", "preview"
*/
export type QueryParamTarget = ClosedEnum<typeof QueryParamTarget>;
/**
* Excludes redirect project domains when "false". Includes redirect project domains when "true" (default).
*/
export const QueryParamRedirects = {
True: "true",
False: "false",
} as const;
/**
* Excludes redirect project domains when "false". Includes redirect project domains when "true" (default).
*/
export type QueryParamRedirects = ClosedEnum<typeof QueryParamRedirects>;
/**
* Filters domains based on their verification status.
*/
export const Verified = {
True: "true",
False: "false",
} as const;
/**
* Filters domains based on their verification status.
*/
export type Verified = ClosedEnum<typeof Verified>;
/**
* Domains sort order by createdAt
*/
export const Order = {
Asc: "ASC",
Desc: "DESC",
} as const;
/**
* Domains sort order by createdAt
*/
export type Order = ClosedEnum<typeof Order>;
export type GetProjectDomainsRequest = {
/**
* The unique project identifier or the project name
*/
idOrName: string;
/**
* Filters only production domains when set to `true`.
*/
production?: Production | undefined;
/**
* Filters on the target of the domain. Can be either "production", "preview"
*/
target?: QueryParamTarget | undefined;
/**
* The unique custom environment identifier within the project
*/
customEnvironmentId?: string | undefined;
/**
* Filters domains based on specific branch.
*/
gitBranch?: string | undefined;
/**
* Excludes redirect project domains when "false". Includes redirect project domains when "true" (default).
*/
redirects?: QueryParamRedirects | undefined;
/**
* Filters domains based on their redirect target.
*/
redirect?: string | undefined;
/**
* Filters domains based on their verification status.
*/
verified?: Verified | undefined;
/**
* Maximum number of domains to list from a request (max 100).
*/
limit?: number | undefined;
/**
* Get domains created after this JavaScript timestamp.
*/
since?: number | undefined;
/**
* Get domains created before this JavaScript timestamp.
*/
until?: number | undefined;
/**
* Domains sort order by createdAt
*/
order?: Order | 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;
};
/**
* A list of verification challenges, one of which must be completed to verify the domain for use on the project. After the challenge is complete `POST /projects/:idOrName/domains/:domain/verify` to verify the domain. Possible challenges: - If `verification.type = TXT` the `verification.domain` will be checked for a TXT record matching `verification.value`.
*/
export type GetProjectDomainsResponseBodyVerification = {
type: string;
domain: string;
value: string;
reason: string;
};
export type GetProjectDomainsResponseBodyDomains = {
name: string;
apexName: string;
projectId: string;
redirect?: string | null | undefined;
redirectStatusCode?: number | null | undefined;
gitBranch?: string | null | undefined;
customEnvironmentId?: string | null | undefined;
updatedAt?: number | undefined;
createdAt?: number | undefined;
/**
* `true` if the domain is verified for use with the project. If `false` it will not be used as an alias on this project until the challenge in `verification` is completed.
*/
verified: boolean;
/**
* A list of verification challenges, one of which must be completed to verify the domain for use on the project. After the challenge is complete `POST /projects/:idOrName/domains/:domain/verify` to verify the domain. Possible challenges: - If `verification.type = TXT` the `verification.domain` will be checked for a TXT record matching `verification.value`.
*/
verification?: Array<GetProjectDomainsResponseBodyVerification> | undefined;
};
export type GetProjectDomainsResponseBody2 = {
domains: Array<GetProjectDomainsResponseBodyDomains>;
/**
* This object contains information related to the pagination of the current request, including the necessary parameters to get the next or previous page of data.
*/
pagination: Pagination;
};
/**
* A list of verification challenges, one of which must be completed to verify the domain for use on the project. After the challenge is complete `POST /projects/:idOrName/domains/:domain/verify` to verify the domain. Possible challenges: - If `verification.type = TXT` the `verification.domain` will be checked for a TXT record matching `verification.value`.
*/
export type ResponseBodyVerification = {
type: string;
domain: string;
value: string;
reason: string;
};
export type ResponseBodyDomains = {
name: string;
apexName: string;
projectId: string;
redirect?: string | null | undefined;
redirectStatusCode?: number | null | undefined;
gitBranch?: string | null | undefined;
customEnvironmentId?: string | null | undefined;
updatedAt?: number | undefined;
createdAt?: number | undefined;
/**
* `true` if the domain is verified for use with the project. If `false` it will not be used as an alias on this project until the challenge in `verification` is completed.
*/
verified: boolean;
/**
* A list of verification challenges, one of which must be completed to verify the domain for use on the project. After the challenge is complete `POST /projects/:idOrName/domains/:domain/verify` to verify the domain. Possible challenges: - If `verification.type = TXT` the `verification.domain` will be checked for a TXT record matching `verification.value`.
*/
verification?: Array<ResponseBodyVerification> | undefined;
};
export type GetProjectDomainsResponseBodyPagination = {
count: number;
next: number | null;
prev: number | null;
};
export type GetProjectDomainsResponseBody1 = {
domains: Array<ResponseBodyDomains>;
pagination: GetProjectDomainsResponseBodyPagination;
};
/**
* Successful response retrieving a list of domains
*/
export type GetProjectDomainsResponseBody =
| GetProjectDomainsResponseBody1
| GetProjectDomainsResponseBody2;
/** @internal */
export const Production$outboundSchema: z.ZodNativeEnum<typeof Production> = z
.nativeEnum(Production);
/** @internal */
export const QueryParamTarget$outboundSchema: z.ZodNativeEnum<
typeof QueryParamTarget
> = z.nativeEnum(QueryParamTarget);
/** @internal */
export const QueryParamRedirects$outboundSchema: z.ZodNativeEnum<
typeof QueryParamRedirects
> = z.nativeEnum(QueryParamRedirects);
/** @internal */
export const Verified$outboundSchema: z.ZodNativeEnum<typeof Verified> = z
.nativeEnum(Verified);
/** @internal */
export const Order$outboundSchema: z.ZodNativeEnum<typeof Order> = z.nativeEnum(
Order,
);
/** @internal */
export type GetProjectDomainsRequest$Outbound = {
idOrName: string;
production: string;
target?: string | undefined;
customEnvironmentId?: string | undefined;
gitBranch?: string | undefined;
redirects: string;
redirect?: string | undefined;
verified?: string | undefined;
limit?: number | undefined;
since?: number | undefined;
until?: number | undefined;
order: string;
teamId?: string | undefined;
slug?: string | undefined;
};
/** @internal */
export const GetProjectDomainsRequest$outboundSchema: z.ZodType<
GetProjectDomainsRequest$Outbound,
z.ZodTypeDef,
GetProjectDomainsRequest
> = z.object({
idOrName: z.string(),
production: Production$outboundSchema.default("false"),
target: QueryParamTarget$outboundSchema.optional(),
customEnvironmentId: z.string().optional(),
gitBranch: z.string().optional(),
redirects: QueryParamRedirects$outboundSchema.default("true"),
redirect: z.string().optional(),
verified: Verified$outboundSchema.optional(),
limit: z.number().optional(),
since: z.number().optional(),
until: z.number().optional(),
order: Order$outboundSchema.default("DESC"),
teamId: z.string().optional(),
slug: z.string().optional(),
});
export function getProjectDomainsRequestToJSON(
getProjectDomainsRequest: GetProjectDomainsRequest,
): string {
return JSON.stringify(
GetProjectDomainsRequest$outboundSchema.parse(getProjectDomainsRequest),
);
}
/** @internal */
export const GetProjectDomainsResponseBodyVerification$inboundSchema: z.ZodType<
GetProjectDomainsResponseBodyVerification,
z.ZodTypeDef,
unknown
> = z.object({
type: types.string(),
domain: types.string(),
value: types.string(),
reason: types.string(),
});
export function getProjectDomainsResponseBodyVerificationFromJSON(
jsonString: string,
): SafeParseResult<
GetProjectDomainsResponseBodyVerification,
SDKValidationError
> {
return safeParse(
jsonString,
(x) =>
GetProjectDomainsResponseBodyVerification$inboundSchema.parse(
JSON.parse(x),
),
`Failed to parse 'GetProjectDomainsResponseBodyVerification' from JSON`,
);
}
/** @internal */
export const GetProjectDomainsResponseBodyDomains$inboundSchema: z.ZodType<
GetProjectDomainsResponseBodyDomains,
z.ZodTypeDef,
unknown
> = z.object({
name: types.string(),
apexName: types.string(),
projectId: types.string(),
redirect: z.nullable(types.string()).optional(),
redirectStatusCode: z.nullable(types.number()).optional(),
gitBranch: z.nullable(types.string()).optional(),
customEnvironmentId: z.nullable(types.string()).optional(),
updatedAt: types.optional(types.number()),
createdAt: types.optional(types.number()),
verified: types.boolean(),
verification: types.optional(
z.array(
z.lazy(() => GetProjectDomainsResponseBodyVerification$inboundSchema),
),
),
});
export function getProjectDomainsResponseBodyDomainsFromJSON(
jsonString: string,
): SafeParseResult<GetProjectDomainsResponseBodyDomains, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
GetProjectDomainsResponseBodyDomains$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetProjectDomainsResponseBodyDomains' from JSON`,
);
}
/** @internal */
export const GetProjectDomainsResponseBody2$inboundSchema: z.ZodType<
GetProjectDomainsResponseBody2,
z.ZodTypeDef,
unknown
> = z.object({
domains: z.array(
z.lazy(() => GetProjectDomainsResponseBodyDomains$inboundSchema),
),
pagination: Pagination$inboundSchema,
});
export function getProjectDomainsResponseBody2FromJSON(
jsonString: string,
): SafeParseResult<GetProjectDomainsResponseBody2, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetProjectDomainsResponseBody2$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetProjectDomainsResponseBody2' from JSON`,
);
}
/** @internal */
export const ResponseBodyVerification$inboundSchema: z.ZodType<
ResponseBodyVerification,
z.ZodTypeDef,
unknown
> = z.object({
type: types.string(),
domain: types.string(),
value: types.string(),
reason: types.string(),
});
export function responseBodyVerificationFromJSON(
jsonString: string,
): SafeParseResult<ResponseBodyVerification, SDKValidationError> {
return safeParse(
jsonString,
(x) => ResponseBodyVerification$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ResponseBodyVerification' from JSON`,
);
}
/** @internal */
export const ResponseBodyDomains$inboundSchema: z.ZodType<
ResponseBodyDomains,
z.ZodTypeDef,
unknown
> = z.object({
name: types.string(),
apexName: types.string(),
projectId: types.string(),
redirect: z.nullable(types.string()).optional(),
redirectStatusCode: z.nullable(types.number()).optional(),
gitBranch: z.nullable(types.string()).optional(),
customEnvironmentId: z.nullable(types.string()).optional(),
updatedAt: types.optional(types.number()),
createdAt: types.optional(types.number()),
verified: types.boolean(),
verification: types.optional(
z.array(z.lazy(() => ResponseBodyVerification$inboundSchema)),
),
});
export function responseBodyDomainsFromJSON(
jsonString: string,
): SafeParseResult<ResponseBodyDomains, SDKValidationError> {
return safeParse(
jsonString,
(x) => ResponseBodyDomains$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ResponseBodyDomains' from JSON`,
);
}
/** @internal */
export const GetProjectDomainsResponseBodyPagination$inboundSchema: z.ZodType<
GetProjectDomainsResponseBodyPagination,
z.ZodTypeDef,
unknown
> = z.object({
count: types.number(),
next: types.nullable(types.number()),
prev: types.nullable(types.number()),
});
export function getProjectDomainsResponseBodyPaginationFromJSON(
jsonString: string,
): SafeParseResult<
GetProjectDomainsResponseBodyPagination,
SDKValidationError
> {
return safeParse(
jsonString,
(x) =>
GetProjectDomainsResponseBodyPagination$inboundSchema.parse(
JSON.parse(x),
),
`Failed to parse 'GetProjectDomainsResponseBodyPagination' from JSON`,
);
}
/** @internal */
export const GetProjectDomainsResponseBody1$inboundSchema: z.ZodType<
GetProjectDomainsResponseBody1,
z.ZodTypeDef,
unknown
> = z.object({
domains: z.array(z.lazy(() => ResponseBodyDomains$inboundSchema)),
pagination: z.lazy(() =>
GetProjectDomainsResponseBodyPagination$inboundSchema
),
});
export function getProjectDomainsResponseBody1FromJSON(
jsonString: string,
): SafeParseResult<GetProjectDomainsResponseBody1, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetProjectDomainsResponseBody1$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetProjectDomainsResponseBody1' from JSON`,
);
}
/** @internal */
export const GetProjectDomainsResponseBody$inboundSchema: z.ZodType<
GetProjectDomainsResponseBody,
z.ZodTypeDef,
unknown
> = smartUnion([
z.lazy(() => GetProjectDomainsResponseBody1$inboundSchema),
z.lazy(() => GetProjectDomainsResponseBody2$inboundSchema),
]);
export function getProjectDomainsResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<GetProjectDomainsResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetProjectDomainsResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetProjectDomainsResponseBody' from JSON`,
);
}