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>

370 lines (336 loc) 10.1 kB
/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../lib/primitives.js"; import { safeParse } from "../lib/schemas.js"; import { Result as SafeParseResult } from "../types/fp.js"; import * as types from "../types/primitives.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * Optional instructions for revoking and regenerating a automation bypass */ export type Revoke = { /** * Automation bypass to revoked */ secret: string; /** * Whether or not a new automation bypass should be created after the provided secret is revoked */ regenerate: boolean; }; /** * Generate a new secret. If neither generate or revoke are provided, a new random secret will be generated. */ export type Generate = { /** * Optional value of the secret to generate, don't send it for oauth2 tokens */ secret?: string | undefined; /** * Note to be displayed in the UI for this bypass */ note?: string | undefined; }; /** * Update an existing bypass */ export type Update = { /** * Automation bypass to updated */ secret: string; /** * Whether or not this bypass is set as the VERCEL_AUTOMATION_BYPASS_SECRET environment variable on deployments */ isEnvVar?: boolean | undefined; /** * Note to be displayed in the UI for this bypass */ note?: string | undefined; }; export type UpdateProjectProtectionBypassRequestBody = { /** * Optional instructions for revoking and regenerating a automation bypass */ revoke?: Revoke | undefined; /** * Generate a new secret. If neither generate or revoke are provided, a new random secret will be generated. */ generate?: Generate | undefined; /** * Update an existing bypass */ update?: Update | undefined; }; export type UpdateProjectProtectionBypassRequest = { /** * The unique project identifier or the project name */ idOrName: string; /** * 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; requestBody: UpdateProjectProtectionBypassRequestBody; }; export type UpdateProjectProtectionBypassProtectionBypass2 = { createdAt: number; createdBy: string; scope: "automation-bypass"; /** * When there was only one bypass, it was automatically set as an env var on deployments. With multiple bypasses, there is always one bypass that is selected as the default, and gets set as an env var on deployments. As this is a new field, undefined means that the bypass is the env var. If there are any automation bypasses, exactly one must be the env var. */ isEnvVar?: boolean | undefined; /** * Optional note about the bypass to be displayed in the UI */ note?: string | undefined; }; export type UpdateProjectProtectionBypassProtectionBypass1 = { createdAt: number; createdBy: string; scope: "integration-automation-bypass"; integrationId: string; configurationId: string; }; export type UpdateProjectProtectionBypassProtectionBypass = | UpdateProjectProtectionBypassProtectionBypass1 | UpdateProjectProtectionBypassProtectionBypass2; export type UpdateProjectProtectionBypassResponseBody = { protectionBypass?: { [k: string]: | UpdateProjectProtectionBypassProtectionBypass1 | UpdateProjectProtectionBypassProtectionBypass2; } | undefined; }; /** @internal */ export type Revoke$Outbound = { secret: string; regenerate: boolean; }; /** @internal */ export const Revoke$outboundSchema: z.ZodType< Revoke$Outbound, z.ZodTypeDef, Revoke > = z.object({ secret: z.string(), regenerate: z.boolean(), }); export function revokeToJSON(revoke: Revoke): string { return JSON.stringify(Revoke$outboundSchema.parse(revoke)); } /** @internal */ export type Generate$Outbound = { secret?: string | undefined; note?: string | undefined; }; /** @internal */ export const Generate$outboundSchema: z.ZodType< Generate$Outbound, z.ZodTypeDef, Generate > = z.object({ secret: z.string().optional(), note: z.string().optional(), }); export function generateToJSON(generate: Generate): string { return JSON.stringify(Generate$outboundSchema.parse(generate)); } /** @internal */ export type Update$Outbound = { secret: string; isEnvVar?: boolean | undefined; note?: string | undefined; }; /** @internal */ export const Update$outboundSchema: z.ZodType< Update$Outbound, z.ZodTypeDef, Update > = z.object({ secret: z.string(), isEnvVar: z.boolean().optional(), note: z.string().optional(), }); export function updateToJSON(update: Update): string { return JSON.stringify(Update$outboundSchema.parse(update)); } /** @internal */ export type UpdateProjectProtectionBypassRequestBody$Outbound = { revoke?: Revoke$Outbound | undefined; generate?: Generate$Outbound | undefined; update?: Update$Outbound | undefined; }; /** @internal */ export const UpdateProjectProtectionBypassRequestBody$outboundSchema: z.ZodType< UpdateProjectProtectionBypassRequestBody$Outbound, z.ZodTypeDef, UpdateProjectProtectionBypassRequestBody > = z.object({ revoke: z.lazy(() => Revoke$outboundSchema).optional(), generate: z.lazy(() => Generate$outboundSchema).optional(), update: z.lazy(() => Update$outboundSchema).optional(), }); export function updateProjectProtectionBypassRequestBodyToJSON( updateProjectProtectionBypassRequestBody: UpdateProjectProtectionBypassRequestBody, ): string { return JSON.stringify( UpdateProjectProtectionBypassRequestBody$outboundSchema.parse( updateProjectProtectionBypassRequestBody, ), ); } /** @internal */ export type UpdateProjectProtectionBypassRequest$Outbound = { idOrName: string; teamId?: string | undefined; slug?: string | undefined; RequestBody: UpdateProjectProtectionBypassRequestBody$Outbound; }; /** @internal */ export const UpdateProjectProtectionBypassRequest$outboundSchema: z.ZodType< UpdateProjectProtectionBypassRequest$Outbound, z.ZodTypeDef, UpdateProjectProtectionBypassRequest > = z.object({ idOrName: z.string(), teamId: z.string().optional(), slug: z.string().optional(), requestBody: z.lazy(() => UpdateProjectProtectionBypassRequestBody$outboundSchema ), }).transform((v) => { return remap$(v, { requestBody: "RequestBody", }); }); export function updateProjectProtectionBypassRequestToJSON( updateProjectProtectionBypassRequest: UpdateProjectProtectionBypassRequest, ): string { return JSON.stringify( UpdateProjectProtectionBypassRequest$outboundSchema.parse( updateProjectProtectionBypassRequest, ), ); } /** @internal */ export const UpdateProjectProtectionBypassProtectionBypass2$inboundSchema: z.ZodType< UpdateProjectProtectionBypassProtectionBypass2, z.ZodTypeDef, unknown > = z.object({ createdAt: types.number(), createdBy: types.string(), scope: types.literal("automation-bypass"), isEnvVar: types.optional(types.boolean()), note: types.optional(types.string()), }); export function updateProjectProtectionBypassProtectionBypass2FromJSON( jsonString: string, ): SafeParseResult< UpdateProjectProtectionBypassProtectionBypass2, SDKValidationError > { return safeParse( jsonString, (x) => UpdateProjectProtectionBypassProtectionBypass2$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'UpdateProjectProtectionBypassProtectionBypass2' from JSON`, ); } /** @internal */ export const UpdateProjectProtectionBypassProtectionBypass1$inboundSchema: z.ZodType< UpdateProjectProtectionBypassProtectionBypass1, z.ZodTypeDef, unknown > = z.object({ createdAt: types.number(), createdBy: types.string(), scope: types.literal("integration-automation-bypass"), integrationId: types.string(), configurationId: types.string(), }); export function updateProjectProtectionBypassProtectionBypass1FromJSON( jsonString: string, ): SafeParseResult< UpdateProjectProtectionBypassProtectionBypass1, SDKValidationError > { return safeParse( jsonString, (x) => UpdateProjectProtectionBypassProtectionBypass1$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'UpdateProjectProtectionBypassProtectionBypass1' from JSON`, ); } /** @internal */ export const UpdateProjectProtectionBypassProtectionBypass$inboundSchema: z.ZodType< UpdateProjectProtectionBypassProtectionBypass, z.ZodTypeDef, unknown > = z.union([ z.lazy(() => UpdateProjectProtectionBypassProtectionBypass1$inboundSchema), z.lazy(() => UpdateProjectProtectionBypassProtectionBypass2$inboundSchema), ]); export function updateProjectProtectionBypassProtectionBypassFromJSON( jsonString: string, ): SafeParseResult< UpdateProjectProtectionBypassProtectionBypass, SDKValidationError > { return safeParse( jsonString, (x) => UpdateProjectProtectionBypassProtectionBypass$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'UpdateProjectProtectionBypassProtectionBypass' from JSON`, ); } /** @internal */ export const UpdateProjectProtectionBypassResponseBody$inboundSchema: z.ZodType< UpdateProjectProtectionBypassResponseBody, z.ZodTypeDef, unknown > = z.object({ protectionBypass: types.optional( z.record(z.union([ z.lazy(() => UpdateProjectProtectionBypassProtectionBypass1$inboundSchema ), z.lazy(() => UpdateProjectProtectionBypassProtectionBypass2$inboundSchema ), ])), ), }); export function updateProjectProtectionBypassResponseBodyFromJSON( jsonString: string, ): SafeParseResult< UpdateProjectProtectionBypassResponseBody, SDKValidationError > { return safeParse( jsonString, (x) => UpdateProjectProtectionBypassResponseBody$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'UpdateProjectProtectionBypassResponseBody' from JSON`, ); }