@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>
703 lines (646 loc) • 20 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";
/**
* Get only aliases of the given domain name
*/
export type Domain = Array<string> | string;
export type ListAliasesRequest = {
/**
* Get only aliases of the given domain name
*/
domain?: Array<string> | string | undefined;
/**
* Get only aliases created after the provided timestamp
*/
from?: number | undefined;
/**
* Maximum number of aliases to list from a request
*/
limit?: number | undefined;
/**
* Filter aliases from the given `projectId`
*/
projectId?: string | undefined;
/**
* Get aliases created after this JavaScript timestamp
*/
since?: number | undefined;
/**
* Get aliases created before this JavaScript timestamp
*/
until?: number | undefined;
/**
* Get aliases that would be rolled back for the given deployment
*/
rollbackDeploymentId?: 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;
};
/**
* Information of the user who created the alias
*/
export type ListAliasesCreator = {
/**
* ID of the user who created the alias
*/
uid: string;
/**
* Email of the user who created the alias
*/
email: string;
/**
* Username of the user who created the alias
*/
username: string;
};
/**
* A map with the deployment ID, URL and metadata
*/
export type ListAliasesDeployment = {
/**
* The deployment unique identifier
*/
id: string;
/**
* The deployment unique URL
*/
url: string;
/**
* The deployment metadata
*/
meta?: string | undefined;
};
/**
* The protection bypass for the alias
*/
export type ListAliasesProtectionBypass4 = {
createdAt: number;
lastUpdatedAt: number;
lastUpdatedBy: string;
scope: "email_invite";
};
/**
* The protection bypass for the alias
*/
export type ListAliasesProtectionBypass3 = {
createdAt: number;
createdBy: string;
scope: "alias-protection-override";
};
export const ListAliasesProtectionBypassAccess = {
Granted: "granted",
Requested: "requested",
} as const;
export type ListAliasesProtectionBypassAccess = ClosedEnum<
typeof ListAliasesProtectionBypassAccess
>;
/**
* The protection bypass for the alias
*/
export type ListAliasesProtectionBypass2 = {
createdAt: number;
lastUpdatedAt: number;
lastUpdatedBy: string;
access: ListAliasesProtectionBypassAccess;
scope: "user";
};
/**
* The protection bypass for the alias
*/
export type ListAliasesProtectionBypass1 = {
createdAt: number;
createdBy: string;
scope: "shareable-link";
expires?: number | undefined;
};
export type ListAliasesProtectionBypass =
| ListAliasesProtectionBypass1
| ListAliasesProtectionBypass2
| ListAliasesProtectionBypass3
| ListAliasesProtectionBypass4;
export type ListAliasesDefaultApp = {
projectId: string;
};
/**
* A list of the deployment routing information for each project.
*/
export type ListAliasesApplications3 = {
/**
* This is the deployment for the same commit, it could be a cancelled deployment. The proxy will fallback to the branchDeploymentId and then the fallbackDeploymentId.
*/
deploymentId?: string | undefined;
/**
* This is the latest non-cancelled deployment of the branch alias at the time the commit alias was created. It is possible there is no deployment for the branch, or this was set before the deployment was canceled, in which case this will point to a cancelled deployment, in either case the proxy will fallback to the fallbackDeploymentId.
*/
branchDeploymentId?: string | undefined;
/**
* This is the deployment of the fallback host at the time the commit alias was created. It is possible for this to be a deleted deployment, in which case the proxy will show that the deployment is deleted. It will not use the fallbackHost, as a future deployment on the fallback host could be invalid for this deployment, and it could lead to confusion / incorrect behavior for the commit alias.
*/
fallbackDeploymentId?: string | undefined;
/**
* Temporary for backwards compatibility. Can remove when metadata change is released
*/
fallbackHost?: string | undefined;
branchAlias?: string | undefined;
/**
* The project ID of the microfrontends application.
*/
projectId: string;
};
/**
* A list of the deployment routing information for each project.
*/
export type ListAliasesApplications2 = {
/**
* This is always set. For branch aliases, it's used as the fallback if there is no deployment for the branch.
*/
fallbackHost: string;
/**
* Could point to a branch without a deployment if the project was never deployed. The proxy will fallback to the fallbackHost if there is no deployment.
*/
branchAlias: string;
/**
* The project ID of the microfrontends application.
*/
projectId: string;
};
/**
* A list of the deployment routing information for each project.
*/
export type ListAliasesApplications1 = {
/**
* This is always set. In production it is used as a pointer to each apps production deployment. For pre-production, it's used as the fallback if there is no deployment for the branch.
*/
fallbackHost: string;
/**
* The project ID of the microfrontends application.
*/
projectId: string;
};
export type ListAliasesApplications =
| Array<ListAliasesApplications1>
| Array<ListAliasesApplications2>
| Array<ListAliasesApplications3>;
/**
* The microfrontends for the alias including the routing configuration
*/
export type ListAliasesMicrofrontends = {
defaultApp: ListAliasesDefaultApp;
applications:
| Array<ListAliasesApplications1>
| Array<ListAliasesApplications2>
| Array<ListAliasesApplications3>;
};
export type ListAliasesAliases = {
/**
* The alias name, it could be a `.vercel.app` subdomain or a custom domain
*/
alias: string;
/**
* The date when the alias was created
*/
created: Date;
/**
* The date when the alias was created in milliseconds since the UNIX epoch
*/
createdAt?: number | undefined;
/**
* Information of the user who created the alias
*/
creator?: ListAliasesCreator | undefined;
/**
* The date when the alias was deleted in milliseconds since the UNIX epoch
*/
deletedAt?: number | null | undefined;
/**
* A map with the deployment ID, URL and metadata
*/
deployment?: ListAliasesDeployment | undefined;
/**
* The deployment ID
*/
deploymentId: string | null;
/**
* The unique identifier of the project
*/
projectId: string | null;
/**
* Target destination domain for redirect when the alias is a redirect
*/
redirect?: string | null | undefined;
/**
* Status code to be used on redirect
*/
redirectStatusCode?: number | null | undefined;
/**
* The unique identifier of the alias
*/
uid: string;
/**
* The date when the alias was updated in milliseconds since the UNIX epoch
*/
updatedAt?: number | undefined;
/**
* The protection bypass for the alias
*/
protectionBypass?: {
[k: string]:
| ListAliasesProtectionBypass1
| ListAliasesProtectionBypass2
| ListAliasesProtectionBypass3
| ListAliasesProtectionBypass4;
} | undefined;
/**
* The microfrontends for the alias including the routing configuration
*/
microfrontends?: ListAliasesMicrofrontends | undefined;
};
/**
* The paginated list of aliases
*/
export type ListAliasesResponseBody = {
aliases: Array<ListAliasesAliases>;
/**
* 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;
};
/** @internal */
export type Domain$Outbound = Array<string> | string;
/** @internal */
export const Domain$outboundSchema: z.ZodType<
Domain$Outbound,
z.ZodTypeDef,
Domain
> = smartUnion([z.array(z.string()), z.string()]);
export function domainToJSON(domain: Domain): string {
return JSON.stringify(Domain$outboundSchema.parse(domain));
}
/** @internal */
export type ListAliasesRequest$Outbound = {
domain?: Array<string> | string | undefined;
from?: number | undefined;
limit?: number | undefined;
projectId?: string | undefined;
since?: number | undefined;
until?: number | undefined;
rollbackDeploymentId?: string | undefined;
teamId?: string | undefined;
slug?: string | undefined;
};
/** @internal */
export const ListAliasesRequest$outboundSchema: z.ZodType<
ListAliasesRequest$Outbound,
z.ZodTypeDef,
ListAliasesRequest
> = z.object({
domain: smartUnion([z.array(z.string()), z.string()]).optional(),
from: z.number().optional(),
limit: z.number().optional(),
projectId: z.string().optional(),
since: z.number().optional(),
until: z.number().optional(),
rollbackDeploymentId: z.string().optional(),
teamId: z.string().optional(),
slug: z.string().optional(),
});
export function listAliasesRequestToJSON(
listAliasesRequest: ListAliasesRequest,
): string {
return JSON.stringify(
ListAliasesRequest$outboundSchema.parse(listAliasesRequest),
);
}
/** @internal */
export const ListAliasesCreator$inboundSchema: z.ZodType<
ListAliasesCreator,
z.ZodTypeDef,
unknown
> = z.object({
uid: types.string(),
email: types.string(),
username: types.string(),
});
export function listAliasesCreatorFromJSON(
jsonString: string,
): SafeParseResult<ListAliasesCreator, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesCreator$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesCreator' from JSON`,
);
}
/** @internal */
export const ListAliasesDeployment$inboundSchema: z.ZodType<
ListAliasesDeployment,
z.ZodTypeDef,
unknown
> = z.object({
id: types.string(),
url: types.string(),
meta: types.optional(types.string()),
});
export function listAliasesDeploymentFromJSON(
jsonString: string,
): SafeParseResult<ListAliasesDeployment, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesDeployment$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesDeployment' from JSON`,
);
}
/** @internal */
export const ListAliasesProtectionBypass4$inboundSchema: z.ZodType<
ListAliasesProtectionBypass4,
z.ZodTypeDef,
unknown
> = z.object({
createdAt: types.number(),
lastUpdatedAt: types.number(),
lastUpdatedBy: types.string(),
scope: types.literal("email_invite"),
});
export function listAliasesProtectionBypass4FromJSON(
jsonString: string,
): SafeParseResult<ListAliasesProtectionBypass4, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesProtectionBypass4$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesProtectionBypass4' from JSON`,
);
}
/** @internal */
export const ListAliasesProtectionBypass3$inboundSchema: z.ZodType<
ListAliasesProtectionBypass3,
z.ZodTypeDef,
unknown
> = z.object({
createdAt: types.number(),
createdBy: types.string(),
scope: types.literal("alias-protection-override"),
});
export function listAliasesProtectionBypass3FromJSON(
jsonString: string,
): SafeParseResult<ListAliasesProtectionBypass3, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesProtectionBypass3$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesProtectionBypass3' from JSON`,
);
}
/** @internal */
export const ListAliasesProtectionBypassAccess$inboundSchema: z.ZodNativeEnum<
typeof ListAliasesProtectionBypassAccess
> = z.nativeEnum(ListAliasesProtectionBypassAccess);
/** @internal */
export const ListAliasesProtectionBypass2$inboundSchema: z.ZodType<
ListAliasesProtectionBypass2,
z.ZodTypeDef,
unknown
> = z.object({
createdAt: types.number(),
lastUpdatedAt: types.number(),
lastUpdatedBy: types.string(),
access: ListAliasesProtectionBypassAccess$inboundSchema,
scope: types.literal("user"),
});
export function listAliasesProtectionBypass2FromJSON(
jsonString: string,
): SafeParseResult<ListAliasesProtectionBypass2, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesProtectionBypass2$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesProtectionBypass2' from JSON`,
);
}
/** @internal */
export const ListAliasesProtectionBypass1$inboundSchema: z.ZodType<
ListAliasesProtectionBypass1,
z.ZodTypeDef,
unknown
> = z.object({
createdAt: types.number(),
createdBy: types.string(),
scope: types.literal("shareable-link"),
expires: types.optional(types.number()),
});
export function listAliasesProtectionBypass1FromJSON(
jsonString: string,
): SafeParseResult<ListAliasesProtectionBypass1, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesProtectionBypass1$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesProtectionBypass1' from JSON`,
);
}
/** @internal */
export const ListAliasesProtectionBypass$inboundSchema: z.ZodType<
ListAliasesProtectionBypass,
z.ZodTypeDef,
unknown
> = z.union([
z.lazy(() => ListAliasesProtectionBypass1$inboundSchema),
z.lazy(() => ListAliasesProtectionBypass2$inboundSchema),
z.lazy(() => ListAliasesProtectionBypass3$inboundSchema),
z.lazy(() => ListAliasesProtectionBypass4$inboundSchema),
]);
export function listAliasesProtectionBypassFromJSON(
jsonString: string,
): SafeParseResult<ListAliasesProtectionBypass, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesProtectionBypass$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesProtectionBypass' from JSON`,
);
}
/** @internal */
export const ListAliasesDefaultApp$inboundSchema: z.ZodType<
ListAliasesDefaultApp,
z.ZodTypeDef,
unknown
> = z.object({
projectId: types.string(),
});
export function listAliasesDefaultAppFromJSON(
jsonString: string,
): SafeParseResult<ListAliasesDefaultApp, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesDefaultApp$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesDefaultApp' from JSON`,
);
}
/** @internal */
export const ListAliasesApplications3$inboundSchema: z.ZodType<
ListAliasesApplications3,
z.ZodTypeDef,
unknown
> = z.object({
deploymentId: types.optional(types.string()),
branchDeploymentId: types.optional(types.string()),
fallbackDeploymentId: types.optional(types.string()),
fallbackHost: types.optional(types.string()),
branchAlias: types.optional(types.string()),
projectId: types.string(),
});
export function listAliasesApplications3FromJSON(
jsonString: string,
): SafeParseResult<ListAliasesApplications3, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesApplications3$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesApplications3' from JSON`,
);
}
/** @internal */
export const ListAliasesApplications2$inboundSchema: z.ZodType<
ListAliasesApplications2,
z.ZodTypeDef,
unknown
> = z.object({
fallbackHost: types.string(),
branchAlias: types.string(),
projectId: types.string(),
});
export function listAliasesApplications2FromJSON(
jsonString: string,
): SafeParseResult<ListAliasesApplications2, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesApplications2$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesApplications2' from JSON`,
);
}
/** @internal */
export const ListAliasesApplications1$inboundSchema: z.ZodType<
ListAliasesApplications1,
z.ZodTypeDef,
unknown
> = z.object({
fallbackHost: types.string(),
projectId: types.string(),
});
export function listAliasesApplications1FromJSON(
jsonString: string,
): SafeParseResult<ListAliasesApplications1, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesApplications1$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesApplications1' from JSON`,
);
}
/** @internal */
export const ListAliasesApplications$inboundSchema: z.ZodType<
ListAliasesApplications,
z.ZodTypeDef,
unknown
> = smartUnion([
z.array(z.lazy(() => ListAliasesApplications1$inboundSchema)),
z.array(z.lazy(() => ListAliasesApplications2$inboundSchema)),
z.array(z.lazy(() => ListAliasesApplications3$inboundSchema)),
]);
export function listAliasesApplicationsFromJSON(
jsonString: string,
): SafeParseResult<ListAliasesApplications, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesApplications$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesApplications' from JSON`,
);
}
/** @internal */
export const ListAliasesMicrofrontends$inboundSchema: z.ZodType<
ListAliasesMicrofrontends,
z.ZodTypeDef,
unknown
> = z.object({
defaultApp: z.lazy(() => ListAliasesDefaultApp$inboundSchema),
applications: smartUnion([
z.array(z.lazy(() => ListAliasesApplications1$inboundSchema)),
z.array(z.lazy(() => ListAliasesApplications2$inboundSchema)),
z.array(z.lazy(() => ListAliasesApplications3$inboundSchema)),
]),
});
export function listAliasesMicrofrontendsFromJSON(
jsonString: string,
): SafeParseResult<ListAliasesMicrofrontends, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesMicrofrontends$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesMicrofrontends' from JSON`,
);
}
/** @internal */
export const ListAliasesAliases$inboundSchema: z.ZodType<
ListAliasesAliases,
z.ZodTypeDef,
unknown
> = z.object({
alias: types.string(),
created: types.date(),
createdAt: types.optional(types.number()),
creator: types.optional(z.lazy(() => ListAliasesCreator$inboundSchema)),
deletedAt: z.nullable(types.number()).optional(),
deployment: types.optional(z.lazy(() => ListAliasesDeployment$inboundSchema)),
deploymentId: types.nullable(types.string()),
projectId: types.nullable(types.string()),
redirect: z.nullable(types.string()).optional(),
redirectStatusCode: z.nullable(types.number()).optional(),
uid: types.string(),
updatedAt: types.optional(types.number()),
protectionBypass: types.optional(
z.record(z.union([
z.lazy(() => ListAliasesProtectionBypass1$inboundSchema),
z.lazy(() =>
ListAliasesProtectionBypass2$inboundSchema
),
z.lazy(() => ListAliasesProtectionBypass3$inboundSchema),
z.lazy(() => ListAliasesProtectionBypass4$inboundSchema),
])),
),
microfrontends: types.optional(
z.lazy(() => ListAliasesMicrofrontends$inboundSchema),
),
});
export function listAliasesAliasesFromJSON(
jsonString: string,
): SafeParseResult<ListAliasesAliases, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesAliases$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesAliases' from JSON`,
);
}
/** @internal */
export const ListAliasesResponseBody$inboundSchema: z.ZodType<
ListAliasesResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
aliases: z.array(z.lazy(() => ListAliasesAliases$inboundSchema)),
pagination: Pagination$inboundSchema,
});
export function listAliasesResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<ListAliasesResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAliasesResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAliasesResponseBody' from JSON`,
);
}