@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>
639 lines (589 loc) • 17.6 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 GetAliasRequest = {
/**
* Get the alias only if it was created after the provided timestamp
*/
from?: number | undefined;
/**
* The alias or alias ID to be retrieved
*/
idOrAlias: string;
/**
* Get the alias only if it is assigned to the provided project ID
*/
projectId?: string | undefined;
/**
* Get the alias only if it was created after this JavaScript timestamp
*/
since?: number | undefined;
/**
* Get the alias only if it was created before this JavaScript timestamp
*/
until?: number | 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 GetAliasCreator = {
/**
* ID of the user who created the alias
*/
uid: string;
/**
* Email of the user who created the alias
*/
email?: string | undefined;
/**
* Username of the user who created the alias
*/
username?: string | undefined;
};
/**
* A map with the deployment ID, URL and metadata
*/
export type GetAliasDeployment = {
/**
* The deployment unique identifier
*/
id: string;
/**
* The deployment unique URL
*/
url?: string | undefined;
/**
* The deployment metadata
*/
meta?: string | undefined;
};
/**
* The protection bypass for the alias
*/
export type ProtectionBypass4 = {
createdAt: number;
lastUpdatedAt: number;
lastUpdatedBy: string;
scope: "email_invite";
};
/**
* The protection bypass for the alias
*/
export type ProtectionBypass3 = {
createdAt: number;
createdBy: string;
scope: "alias-protection-override";
};
export const ProtectionBypassAccess = {
Granted: "granted",
Requested: "requested",
} as const;
export type ProtectionBypassAccess = ClosedEnum<typeof ProtectionBypassAccess>;
/**
* The protection bypass for the alias
*/
export type GetAliasProtectionBypass2 = {
createdAt: number;
lastUpdatedAt: number;
lastUpdatedBy: string;
access: ProtectionBypassAccess;
scope: "user";
};
/**
* The protection bypass for the alias
*/
export type GetAliasProtectionBypass1 = {
createdAt: number;
createdBy: string;
scope: "shareable-link";
expires?: number | undefined;
};
export type GetAliasProtectionBypass =
| GetAliasProtectionBypass1
| GetAliasProtectionBypass2
| ProtectionBypass3
| ProtectionBypass4;
export type GetAliasDefaultApp = {
projectId: string;
};
/**
* A list of the deployment routing information for each project.
*/
export type Applications3 = {
/**
* 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 GetAliasApplications2 = {
/**
* 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 GetAliasApplications1 = {
/**
* 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 GetAliasApplications =
| Array<GetAliasApplications1>
| Array<GetAliasApplications2>
| Array<Applications3>;
/**
* The microfrontends for the alias including the routing configuration
*/
export type GetAliasMicrofrontends = {
defaultApp: GetAliasDefaultApp;
applications:
| Array<GetAliasApplications1>
| Array<GetAliasApplications2>
| Array<Applications3>;
};
/**
* The alias information
*/
export type GetAliasResponseBody = {
/**
* 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 | null | undefined;
/**
* Information of the user who created the alias
*/
creator?: GetAliasCreator | 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?: GetAliasDeployment | 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 | null | undefined;
/**
* The protection bypass for the alias
*/
protectionBypass?: {
[k: string]:
| GetAliasProtectionBypass1
| GetAliasProtectionBypass2
| ProtectionBypass3
| ProtectionBypass4;
} | undefined;
/**
* The microfrontends for the alias including the routing configuration
*/
microfrontends?: GetAliasMicrofrontends | undefined;
};
/** @internal */
export type GetAliasRequest$Outbound = {
from?: number | undefined;
idOrAlias: string;
projectId?: string | undefined;
since?: number | undefined;
until?: number | undefined;
teamId?: string | undefined;
slug?: string | undefined;
};
/** @internal */
export const GetAliasRequest$outboundSchema: z.ZodType<
GetAliasRequest$Outbound,
z.ZodTypeDef,
GetAliasRequest
> = z.object({
from: z.number().optional(),
idOrAlias: z.string(),
projectId: z.string().optional(),
since: z.number().optional(),
until: z.number().optional(),
teamId: z.string().optional(),
slug: z.string().optional(),
});
export function getAliasRequestToJSON(
getAliasRequest: GetAliasRequest,
): string {
return JSON.stringify(GetAliasRequest$outboundSchema.parse(getAliasRequest));
}
/** @internal */
export const GetAliasCreator$inboundSchema: z.ZodType<
GetAliasCreator,
z.ZodTypeDef,
unknown
> = z.object({
uid: types.string(),
email: types.optional(types.string()),
username: types.optional(types.string()),
});
export function getAliasCreatorFromJSON(
jsonString: string,
): SafeParseResult<GetAliasCreator, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetAliasCreator$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetAliasCreator' from JSON`,
);
}
/** @internal */
export const GetAliasDeployment$inboundSchema: z.ZodType<
GetAliasDeployment,
z.ZodTypeDef,
unknown
> = z.object({
id: types.string(),
url: types.optional(types.string()),
meta: types.optional(types.string()),
});
export function getAliasDeploymentFromJSON(
jsonString: string,
): SafeParseResult<GetAliasDeployment, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetAliasDeployment$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetAliasDeployment' from JSON`,
);
}
/** @internal */
export const ProtectionBypass4$inboundSchema: z.ZodType<
ProtectionBypass4,
z.ZodTypeDef,
unknown
> = z.object({
createdAt: types.number(),
lastUpdatedAt: types.number(),
lastUpdatedBy: types.string(),
scope: types.literal("email_invite"),
});
export function protectionBypass4FromJSON(
jsonString: string,
): SafeParseResult<ProtectionBypass4, SDKValidationError> {
return safeParse(
jsonString,
(x) => ProtectionBypass4$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ProtectionBypass4' from JSON`,
);
}
/** @internal */
export const ProtectionBypass3$inboundSchema: z.ZodType<
ProtectionBypass3,
z.ZodTypeDef,
unknown
> = z.object({
createdAt: types.number(),
createdBy: types.string(),
scope: types.literal("alias-protection-override"),
});
export function protectionBypass3FromJSON(
jsonString: string,
): SafeParseResult<ProtectionBypass3, SDKValidationError> {
return safeParse(
jsonString,
(x) => ProtectionBypass3$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ProtectionBypass3' from JSON`,
);
}
/** @internal */
export const ProtectionBypassAccess$inboundSchema: z.ZodNativeEnum<
typeof ProtectionBypassAccess
> = z.nativeEnum(ProtectionBypassAccess);
/** @internal */
export const GetAliasProtectionBypass2$inboundSchema: z.ZodType<
GetAliasProtectionBypass2,
z.ZodTypeDef,
unknown
> = z.object({
createdAt: types.number(),
lastUpdatedAt: types.number(),
lastUpdatedBy: types.string(),
access: ProtectionBypassAccess$inboundSchema,
scope: types.literal("user"),
});
export function getAliasProtectionBypass2FromJSON(
jsonString: string,
): SafeParseResult<GetAliasProtectionBypass2, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetAliasProtectionBypass2$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetAliasProtectionBypass2' from JSON`,
);
}
/** @internal */
export const GetAliasProtectionBypass1$inboundSchema: z.ZodType<
GetAliasProtectionBypass1,
z.ZodTypeDef,
unknown
> = z.object({
createdAt: types.number(),
createdBy: types.string(),
scope: types.literal("shareable-link"),
expires: types.optional(types.number()),
});
export function getAliasProtectionBypass1FromJSON(
jsonString: string,
): SafeParseResult<GetAliasProtectionBypass1, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetAliasProtectionBypass1$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetAliasProtectionBypass1' from JSON`,
);
}
/** @internal */
export const GetAliasProtectionBypass$inboundSchema: z.ZodType<
GetAliasProtectionBypass,
z.ZodTypeDef,
unknown
> = z.union([
z.lazy(() => GetAliasProtectionBypass1$inboundSchema),
z.lazy(() => GetAliasProtectionBypass2$inboundSchema),
z.lazy(() => ProtectionBypass3$inboundSchema),
z.lazy(() => ProtectionBypass4$inboundSchema),
]);
export function getAliasProtectionBypassFromJSON(
jsonString: string,
): SafeParseResult<GetAliasProtectionBypass, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetAliasProtectionBypass$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetAliasProtectionBypass' from JSON`,
);
}
/** @internal */
export const GetAliasDefaultApp$inboundSchema: z.ZodType<
GetAliasDefaultApp,
z.ZodTypeDef,
unknown
> = z.object({
projectId: types.string(),
});
export function getAliasDefaultAppFromJSON(
jsonString: string,
): SafeParseResult<GetAliasDefaultApp, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetAliasDefaultApp$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetAliasDefaultApp' from JSON`,
);
}
/** @internal */
export const Applications3$inboundSchema: z.ZodType<
Applications3,
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 applications3FromJSON(
jsonString: string,
): SafeParseResult<Applications3, SDKValidationError> {
return safeParse(
jsonString,
(x) => Applications3$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Applications3' from JSON`,
);
}
/** @internal */
export const GetAliasApplications2$inboundSchema: z.ZodType<
GetAliasApplications2,
z.ZodTypeDef,
unknown
> = z.object({
fallbackHost: types.string(),
branchAlias: types.string(),
projectId: types.string(),
});
export function getAliasApplications2FromJSON(
jsonString: string,
): SafeParseResult<GetAliasApplications2, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetAliasApplications2$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetAliasApplications2' from JSON`,
);
}
/** @internal */
export const GetAliasApplications1$inboundSchema: z.ZodType<
GetAliasApplications1,
z.ZodTypeDef,
unknown
> = z.object({
fallbackHost: types.string(),
projectId: types.string(),
});
export function getAliasApplications1FromJSON(
jsonString: string,
): SafeParseResult<GetAliasApplications1, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetAliasApplications1$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetAliasApplications1' from JSON`,
);
}
/** @internal */
export const GetAliasApplications$inboundSchema: z.ZodType<
GetAliasApplications,
z.ZodTypeDef,
unknown
> = smartUnion([
z.array(z.lazy(() => GetAliasApplications1$inboundSchema)),
z.array(z.lazy(() => GetAliasApplications2$inboundSchema)),
z.array(z.lazy(() => Applications3$inboundSchema)),
]);
export function getAliasApplicationsFromJSON(
jsonString: string,
): SafeParseResult<GetAliasApplications, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetAliasApplications$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetAliasApplications' from JSON`,
);
}
/** @internal */
export const GetAliasMicrofrontends$inboundSchema: z.ZodType<
GetAliasMicrofrontends,
z.ZodTypeDef,
unknown
> = z.object({
defaultApp: z.lazy(() => GetAliasDefaultApp$inboundSchema),
applications: smartUnion([
z.array(z.lazy(() => GetAliasApplications1$inboundSchema)),
z.array(z.lazy(() => GetAliasApplications2$inboundSchema)),
z.array(z.lazy(() => Applications3$inboundSchema)),
]),
});
export function getAliasMicrofrontendsFromJSON(
jsonString: string,
): SafeParseResult<GetAliasMicrofrontends, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetAliasMicrofrontends$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetAliasMicrofrontends' from JSON`,
);
}
/** @internal */
export const GetAliasResponseBody$inboundSchema: z.ZodType<
GetAliasResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
alias: types.string(),
created: types.date(),
createdAt: z.nullable(types.number()).optional(),
creator: types.optional(z.lazy(() => GetAliasCreator$inboundSchema)),
deletedAt: z.nullable(types.number()).optional(),
deployment: types.optional(z.lazy(() => GetAliasDeployment$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: z.nullable(types.number()).optional(),
protectionBypass: types.optional(
z.record(z.union([
z.lazy(() => GetAliasProtectionBypass1$inboundSchema),
z.lazy(() =>
GetAliasProtectionBypass2$inboundSchema
),
z.lazy(() => ProtectionBypass3$inboundSchema),
z.lazy(() => ProtectionBypass4$inboundSchema),
])),
),
microfrontends: types.optional(
z.lazy(() => GetAliasMicrofrontends$inboundSchema),
),
});
export function getAliasResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<GetAliasResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetAliasResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetAliasResponseBody' from JSON`,
);
}