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>

674 lines (627 loc) 20.3 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 { SDKValidationError } from "./sdkvalidationerror.js"; /** * Filter by rolling release state */ export const GetRollingReleaseQueryParamState = { Active: "ACTIVE", Complete: "COMPLETE", Aborted: "ABORTED", } as const; /** * Filter by rolling release state */ export type GetRollingReleaseQueryParamState = ClosedEnum< typeof GetRollingReleaseQueryParamState >; export type GetRollingReleaseRequest = { /** * Project ID or project name (URL-encoded) */ idOrName: string; /** * Filter by rolling release state */ state?: GetRollingReleaseQueryParamState | 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; }; /** * The current state of the rolling release */ export const GetRollingReleaseState = { Aborted: "ABORTED", Active: "ACTIVE", Complete: "COMPLETE", } as const; /** * The current state of the rolling release */ export type GetRollingReleaseState = ClosedEnum<typeof GetRollingReleaseState>; /** * When set to `PAUSED`, the rollout is frozen at the current percentage until continued. */ export const Substate = { Paused: "PAUSED", } as const; /** * When set to `PAUSED`, the rollout is frozen at the current percentage until continued. */ export type Substate = ClosedEnum<typeof Substate>; /** * The state of the deployment depending on the process of deploying, or if it is ready or in an error state */ export const GetRollingReleaseReadyState = { Blocked: "BLOCKED", Building: "BUILDING", Canceled: "CANCELED", Error: "ERROR", Initializing: "INITIALIZING", Queued: "QUEUED", Ready: "READY", } as const; /** * The state of the deployment depending on the process of deploying, or if it is ready or in an error state */ export type GetRollingReleaseReadyState = ClosedEnum< typeof GetRollingReleaseReadyState >; /** * If defined, either `staging` if a staging alias in the format `<project>.<team>.now.sh` was assigned upon creation, or `production` if the aliases from `alias` were assigned. `null` value indicates the "preview" deployment. */ export const GetRollingReleaseTarget = { Production: "production", Staging: "staging", } as const; /** * If defined, either `staging` if a staging alias in the format `<project>.<team>.now.sh` was assigned upon creation, or `production` if the aliases from `alias` were assigned. `null` value indicates the "preview" deployment. */ export type GetRollingReleaseTarget = ClosedEnum< typeof GetRollingReleaseTarget >; /** * Where was the deployment created from. Best-effort guess for metrics only — not authoritative; do not gate behavior on it. */ export const GetRollingReleaseSource = { ApiTriggerGitDeploy: "api-trigger-git-deploy", Cli: "cli", CloneRepo: "clone/repo", Drop: "drop", Git: "git", GitDeployHook: "git-deploy-hook", Import: "import", ImportRepo: "import/repo", Redeploy: "redeploy", V0Web: "v0-web", } as const; /** * Where was the deployment created from. Best-effort guess for metrics only — not authoritative; do not gate behavior on it. */ export type GetRollingReleaseSource = ClosedEnum< typeof GetRollingReleaseSource >; /** * The current deployment receiving production traffic */ export type CurrentDeployment = { /** * The name of the project associated with the deployment at the time that the deployment was created */ name: string; /** * A number containing the date when the deployment was created in milliseconds */ createdAt: number; /** * The state of the deployment depending on the process of deploying, or if it is ready or in an error state */ readyState: GetRollingReleaseReadyState; /** * A string holding the unique ID of the deployment */ id: string; /** * If defined, either `staging` if a staging alias in the format `<project>.<team>.now.sh` was assigned upon creation, or `production` if the aliases from `alias` were assigned. `null` value indicates the "preview" deployment. */ target?: GetRollingReleaseTarget | null | undefined; readyStateAt?: number | undefined; /** * Where was the deployment created from. Best-effort guess for metrics only — not authoritative; do not gate behavior on it. */ source?: GetRollingReleaseSource | undefined; /** * A string with the unique URL of the deployment */ url: string; }; /** * The state of the deployment depending on the process of deploying, or if it is ready or in an error state */ export const GetRollingReleaseRollingReleaseReadyState = { Blocked: "BLOCKED", Building: "BUILDING", Canceled: "CANCELED", Error: "ERROR", Initializing: "INITIALIZING", Queued: "QUEUED", Ready: "READY", } as const; /** * The state of the deployment depending on the process of deploying, or if it is ready or in an error state */ export type GetRollingReleaseRollingReleaseReadyState = ClosedEnum< typeof GetRollingReleaseRollingReleaseReadyState >; /** * If defined, either `staging` if a staging alias in the format `<project>.<team>.now.sh` was assigned upon creation, or `production` if the aliases from `alias` were assigned. `null` value indicates the "preview" deployment. */ export const GetRollingReleaseRollingReleaseTarget = { Production: "production", Staging: "staging", } as const; /** * If defined, either `staging` if a staging alias in the format `<project>.<team>.now.sh` was assigned upon creation, or `production` if the aliases from `alias` were assigned. `null` value indicates the "preview" deployment. */ export type GetRollingReleaseRollingReleaseTarget = ClosedEnum< typeof GetRollingReleaseRollingReleaseTarget >; /** * Where was the deployment created from. Best-effort guess for metrics only — not authoritative; do not gate behavior on it. */ export const GetRollingReleaseRollingReleaseSource = { ApiTriggerGitDeploy: "api-trigger-git-deploy", Cli: "cli", CloneRepo: "clone/repo", Drop: "drop", Git: "git", GitDeployHook: "git-deploy-hook", Import: "import", ImportRepo: "import/repo", Redeploy: "redeploy", V0Web: "v0-web", } as const; /** * Where was the deployment created from. Best-effort guess for metrics only — not authoritative; do not gate behavior on it. */ export type GetRollingReleaseRollingReleaseSource = ClosedEnum< typeof GetRollingReleaseRollingReleaseSource >; /** * The canary deployment being rolled out */ export type CanaryDeployment = { /** * The name of the project associated with the deployment at the time that the deployment was created */ name: string; /** * A number containing the date when the deployment was created in milliseconds */ createdAt: number; /** * The state of the deployment depending on the process of deploying, or if it is ready or in an error state */ readyState: GetRollingReleaseRollingReleaseReadyState; /** * A string holding the unique ID of the deployment */ id: string; /** * If defined, either `staging` if a staging alias in the format `<project>.<team>.now.sh` was assigned upon creation, or `production` if the aliases from `alias` were assigned. `null` value indicates the "preview" deployment. */ target?: GetRollingReleaseRollingReleaseTarget | null | undefined; readyStateAt?: number | undefined; /** * Where was the deployment created from. Best-effort guess for metrics only — not authoritative; do not gate behavior on it. */ source?: GetRollingReleaseRollingReleaseSource | undefined; /** * A string with the unique URL of the deployment */ url: string; }; /** * The advancement type of the rolling release */ export const AdvancementType = { Automatic: "automatic", ManualApproval: "manual-approval", } as const; /** * The advancement type of the rolling release */ export type AdvancementType = ClosedEnum<typeof AdvancementType>; /** * All stages configured for this rolling release */ export type GetRollingReleaseStages = { /** * The zero-based index of the stage */ index: number; /** * Whether or not this stage is the final stage (targetPercentage === 100) */ isFinalStage: boolean; /** * The percentage of traffic to serve to the canary deployment (0-100) */ targetPercentage: number; /** * Whether or not this stage requires manual approval to proceed */ requireApproval: boolean; /** * Duration in seconds for automatic advancement, null for manual stages or the final stage */ duration: number | null; /** * Whether to linearly shift traffic over the duration of this stage */ linearShift?: boolean | undefined; }; /** * The currently active stage, null if the rollout is aborted */ export type ActiveStage = { /** * The zero-based index of the stage */ index: number; /** * Whether or not this stage is the final stage (targetPercentage === 100) */ isFinalStage: boolean; /** * The percentage of traffic to serve to the canary deployment (0-100) */ targetPercentage: number; /** * Whether or not this stage requires manual approval to proceed */ requireApproval: boolean; /** * Duration in seconds for automatic advancement, null for manual stages or the final stage */ duration: number | null; /** * Whether to linearly shift traffic over the duration of this stage */ linearShift?: boolean | undefined; }; /** * The next stage to be activated, null if not in ACTIVE state */ export type NextStage = { /** * The zero-based index of the stage */ index: number; /** * Whether or not this stage is the final stage (targetPercentage === 100) */ isFinalStage: boolean; /** * The percentage of traffic to serve to the canary deployment (0-100) */ targetPercentage: number; /** * Whether or not this stage requires manual approval to proceed */ requireApproval: boolean; /** * Duration in seconds for automatic advancement, null for manual stages or the final stage */ duration: number | null; /** * Whether to linearly shift traffic over the duration of this stage */ linearShift?: boolean | undefined; }; /** * Rolling release information including configuration and document details, or null if no rolling release exists */ export type GetRollingReleaseRollingRelease = { /** * The current state of the rolling release */ state: GetRollingReleaseState; /** * When set to `PAUSED`, the rollout is frozen at the current percentage until continued. */ substate: Substate | null; /** * The current deployment receiving production traffic */ currentDeployment: CurrentDeployment | null; /** * The canary deployment being rolled out */ canaryDeployment: CanaryDeployment | null; /** * The ID of a deployment queued for the next rolling release */ queuedDeploymentId: string | null; /** * The advancement type of the rolling release */ advancementType: AdvancementType; /** * All stages configured for this rolling release */ stages: Array<GetRollingReleaseStages>; /** * The currently active stage, null if the rollout is aborted */ activeStage: ActiveStage | null; /** * The next stage to be activated, null if not in ACTIVE state */ nextStage: NextStage | null; /** * Unix timestamp in milliseconds when the rolling release started */ startedAt: number; /** * Unix timestamp in milliseconds when the rolling release was last updated */ updatedAt: number; /** * When set (for example while {@link substate} is `PAUSED`), the canary traffic percentage persisted on the rollout document — use for dashboard display when linear shift is active. */ currentCanaryPercentage?: number | undefined; }; /** * The response format for rolling release endpoints that return rolling release information */ export type GetRollingReleaseResponseBody = { /** * Rolling release information including configuration and document details, or null if no rolling release exists */ rollingRelease: GetRollingReleaseRollingRelease | null; }; /** @internal */ export const GetRollingReleaseQueryParamState$outboundSchema: z.ZodNativeEnum< typeof GetRollingReleaseQueryParamState > = z.nativeEnum(GetRollingReleaseQueryParamState); /** @internal */ export type GetRollingReleaseRequest$Outbound = { idOrName: string; state?: string | undefined; teamId?: string | undefined; slug?: string | undefined; }; /** @internal */ export const GetRollingReleaseRequest$outboundSchema: z.ZodType< GetRollingReleaseRequest$Outbound, z.ZodTypeDef, GetRollingReleaseRequest > = z.object({ idOrName: z.string(), state: GetRollingReleaseQueryParamState$outboundSchema.optional(), teamId: z.string().optional(), slug: z.string().optional(), }); export function getRollingReleaseRequestToJSON( getRollingReleaseRequest: GetRollingReleaseRequest, ): string { return JSON.stringify( GetRollingReleaseRequest$outboundSchema.parse(getRollingReleaseRequest), ); } /** @internal */ export const GetRollingReleaseState$inboundSchema: z.ZodNativeEnum< typeof GetRollingReleaseState > = z.nativeEnum(GetRollingReleaseState); /** @internal */ export const Substate$inboundSchema: z.ZodNativeEnum<typeof Substate> = z .nativeEnum(Substate); /** @internal */ export const GetRollingReleaseReadyState$inboundSchema: z.ZodNativeEnum< typeof GetRollingReleaseReadyState > = z.nativeEnum(GetRollingReleaseReadyState); /** @internal */ export const GetRollingReleaseTarget$inboundSchema: z.ZodNativeEnum< typeof GetRollingReleaseTarget > = z.nativeEnum(GetRollingReleaseTarget); /** @internal */ export const GetRollingReleaseSource$inboundSchema: z.ZodNativeEnum< typeof GetRollingReleaseSource > = z.nativeEnum(GetRollingReleaseSource); /** @internal */ export const CurrentDeployment$inboundSchema: z.ZodType< CurrentDeployment, z.ZodTypeDef, unknown > = z.object({ name: types.string(), createdAt: types.number(), readyState: GetRollingReleaseReadyState$inboundSchema, id: types.string(), target: z.nullable(GetRollingReleaseTarget$inboundSchema).optional(), readyStateAt: types.optional(types.number()), source: types.optional(GetRollingReleaseSource$inboundSchema), url: types.string(), }); export function currentDeploymentFromJSON( jsonString: string, ): SafeParseResult<CurrentDeployment, SDKValidationError> { return safeParse( jsonString, (x) => CurrentDeployment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CurrentDeployment' from JSON`, ); } /** @internal */ export const GetRollingReleaseRollingReleaseReadyState$inboundSchema: z.ZodNativeEnum<typeof GetRollingReleaseRollingReleaseReadyState> = z .nativeEnum(GetRollingReleaseRollingReleaseReadyState); /** @internal */ export const GetRollingReleaseRollingReleaseTarget$inboundSchema: z.ZodNativeEnum<typeof GetRollingReleaseRollingReleaseTarget> = z.nativeEnum( GetRollingReleaseRollingReleaseTarget, ); /** @internal */ export const GetRollingReleaseRollingReleaseSource$inboundSchema: z.ZodNativeEnum<typeof GetRollingReleaseRollingReleaseSource> = z.nativeEnum( GetRollingReleaseRollingReleaseSource, ); /** @internal */ export const CanaryDeployment$inboundSchema: z.ZodType< CanaryDeployment, z.ZodTypeDef, unknown > = z.object({ name: types.string(), createdAt: types.number(), readyState: GetRollingReleaseRollingReleaseReadyState$inboundSchema, id: types.string(), target: z.nullable(GetRollingReleaseRollingReleaseTarget$inboundSchema) .optional(), readyStateAt: types.optional(types.number()), source: types.optional(GetRollingReleaseRollingReleaseSource$inboundSchema), url: types.string(), }); export function canaryDeploymentFromJSON( jsonString: string, ): SafeParseResult<CanaryDeployment, SDKValidationError> { return safeParse( jsonString, (x) => CanaryDeployment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CanaryDeployment' from JSON`, ); } /** @internal */ export const AdvancementType$inboundSchema: z.ZodNativeEnum< typeof AdvancementType > = z.nativeEnum(AdvancementType); /** @internal */ export const GetRollingReleaseStages$inboundSchema: z.ZodType< GetRollingReleaseStages, z.ZodTypeDef, unknown > = z.object({ index: types.number(), isFinalStage: types.boolean(), targetPercentage: types.number(), requireApproval: types.boolean(), duration: types.nullable(types.number()), linearShift: types.optional(types.boolean()), }); export function getRollingReleaseStagesFromJSON( jsonString: string, ): SafeParseResult<GetRollingReleaseStages, SDKValidationError> { return safeParse( jsonString, (x) => GetRollingReleaseStages$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetRollingReleaseStages' from JSON`, ); } /** @internal */ export const ActiveStage$inboundSchema: z.ZodType< ActiveStage, z.ZodTypeDef, unknown > = z.object({ index: types.number(), isFinalStage: types.boolean(), targetPercentage: types.number(), requireApproval: types.boolean(), duration: types.nullable(types.number()), linearShift: types.optional(types.boolean()), }); export function activeStageFromJSON( jsonString: string, ): SafeParseResult<ActiveStage, SDKValidationError> { return safeParse( jsonString, (x) => ActiveStage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ActiveStage' from JSON`, ); } /** @internal */ export const NextStage$inboundSchema: z.ZodType< NextStage, z.ZodTypeDef, unknown > = z.object({ index: types.number(), isFinalStage: types.boolean(), targetPercentage: types.number(), requireApproval: types.boolean(), duration: types.nullable(types.number()), linearShift: types.optional(types.boolean()), }); export function nextStageFromJSON( jsonString: string, ): SafeParseResult<NextStage, SDKValidationError> { return safeParse( jsonString, (x) => NextStage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'NextStage' from JSON`, ); } /** @internal */ export const GetRollingReleaseRollingRelease$inboundSchema: z.ZodType< GetRollingReleaseRollingRelease, z.ZodTypeDef, unknown > = z.object({ state: GetRollingReleaseState$inboundSchema, substate: types.nullable(Substate$inboundSchema), currentDeployment: types.nullable( z.lazy(() => CurrentDeployment$inboundSchema), ), canaryDeployment: types.nullable( z.lazy(() => CanaryDeployment$inboundSchema), ), queuedDeploymentId: types.nullable(types.string()), advancementType: AdvancementType$inboundSchema, stages: z.array(z.lazy(() => GetRollingReleaseStages$inboundSchema)), activeStage: types.nullable(z.lazy(() => ActiveStage$inboundSchema)), nextStage: types.nullable(z.lazy(() => NextStage$inboundSchema)), startedAt: types.number(), updatedAt: types.number(), currentCanaryPercentage: types.optional(types.number()), }); export function getRollingReleaseRollingReleaseFromJSON( jsonString: string, ): SafeParseResult<GetRollingReleaseRollingRelease, SDKValidationError> { return safeParse( jsonString, (x) => GetRollingReleaseRollingRelease$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetRollingReleaseRollingRelease' from JSON`, ); } /** @internal */ export const GetRollingReleaseResponseBody$inboundSchema: z.ZodType< GetRollingReleaseResponseBody, z.ZodTypeDef, unknown > = z.object({ rollingRelease: types.nullable( z.lazy(() => GetRollingReleaseRollingRelease$inboundSchema), ), }); export function getRollingReleaseResponseBodyFromJSON( jsonString: string, ): SafeParseResult<GetRollingReleaseResponseBody, SDKValidationError> { return safeParse( jsonString, (x) => GetRollingReleaseResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetRollingReleaseResponseBody' from JSON`, ); }