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>

892 lines (805 loc) 23.7 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 { 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 const EditProjectEnvTarget = { Production: "production", Preview: "preview", Development: "development", } as const; export type EditProjectEnvTarget = ClosedEnum<typeof EditProjectEnvTarget>; /** * The type of environment variable */ export const EditProjectEnvType = { System: "system", Encrypted: "encrypted", Plain: "plain", Sensitive: "sensitive", } as const; /** * The type of environment variable */ export type EditProjectEnvType = ClosedEnum<typeof EditProjectEnvType>; export type EditProjectEnvRequestBody = { /** * The name of the environment variable */ key?: string | undefined; /** * The target environment of the environment variable */ target?: Array<EditProjectEnvTarget> | undefined; /** * If defined, the git branch of the environment variable (must have target=preview) */ gitBranch?: string | null | undefined; /** * The type of environment variable */ type?: EditProjectEnvType | undefined; /** * The value of the environment variable */ value?: string | undefined; /** * The custom environments that the environment variable should be synced to */ customEnvironmentIds?: Array<string> | undefined; /** * A comment to add context on what this env var is for */ comment?: string | undefined; }; export type EditProjectEnvRequest = { /** * The unique project identifier or the project name */ idOrName: string; /** * The unique environment variable identifier */ id: 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: EditProjectEnvRequestBody; }; export const EditProjectEnvProjectsType = { Encrypted: "encrypted", Plain: "plain", Secret: "secret", Sensitive: "sensitive", System: "system", } as const; export type EditProjectEnvProjectsType = ClosedEnum< typeof EditProjectEnvProjectsType >; export const EditProjectEnvTarget2 = { Development: "development", Preview: "preview", Production: "production", } as const; export type EditProjectEnvTarget2 = ClosedEnum<typeof EditProjectEnvTarget2>; export const EditProjectEnvTarget1 = { Development: "development", Preview: "preview", Production: "production", } as const; export type EditProjectEnvTarget1 = ClosedEnum<typeof EditProjectEnvTarget1>; export type EditProjectEnvProjectsTarget = | Array<EditProjectEnvTarget1> | EditProjectEnvTarget2; /** * User-facing config/secret model. When set, authoritative for new code paths when the env-var-config-secret-ui flag is enabled. Legacy rows omit this field; legacy rows omit it and callers fall back to existing `type` behavior. */ export const Visibility = { Config: "config", Secret: "secret", } as const; /** * User-facing config/secret model. When set, authoritative for new code paths when the env-var-config-secret-ui flag is enabled. Legacy rows omit this field; legacy rows omit it and callers fall back to existing `type` behavior. */ export type Visibility = ClosedEnum<typeof Visibility>; export type ContentHint17 = { type: "flags-connection-string"; projectId: string; }; export type ContentHint16 = { type: "integration-store-secret"; storeId: string; integrationId: string; integrationProductId: string; integrationConfigurationId: string; }; export type ContentHint15 = { type: "postgres-url-no-ssl"; storeId: string; }; export type ContentHint14 = { type: "postgres-database"; storeId: string; }; export type ContentHint13 = { type: "postgres-password"; storeId: string; }; export type ContentHint12 = { type: "postgres-host"; storeId: string; }; export type ContentHint11 = { type: "postgres-user"; storeId: string; }; export type ContentHint10 = { type: "postgres-prisma-url"; storeId: string; }; export type ContentHint9 = { type: "postgres-url-non-pooling"; storeId: string; }; export type ContentHint8 = { type: "postgres-url"; storeId: string; }; export type ContentHint7 = { type: "blob-webhook-public-key"; storeId: string; }; export type ContentHint6 = { type: "blob-store-id"; storeId: string; }; export type ContentHint5 = { type: "blob-read-write-token"; storeId: string; }; export type ContentHint4 = { type: "redis-rest-api-read-only-token"; storeId: string; }; export type ContentHint3 = { type: "redis-rest-api-token"; storeId: string; }; export type ContentHint2 = { type: "redis-rest-api-url"; storeId: string; }; export type ContentHint1 = { type: "redis-url"; storeId: string; }; export type ContentHint = | ContentHint1 | ContentHint2 | ContentHint3 | ContentHint4 | ContentHint5 | ContentHint6 | ContentHint7 | ContentHint8 | ContentHint9 | ContentHint10 | ContentHint11 | ContentHint12 | ContentHint13 | ContentHint14 | ContentHint15 | ContentHint16 | ContentHint17; export const EditProjectEnvProjectsResponseType = { FlagsSecret: "flags-secret", } as const; export type EditProjectEnvProjectsResponseType = ClosedEnum< typeof EditProjectEnvProjectsResponseType >; /** * Similar to `contentHints`, but should not be exposed to the user. */ export type InternalContentHint = { type: EditProjectEnvProjectsResponseType; /** * Contains the `value` of the env variable, encrypted with a special key to make decryption possible in the subscriber Lambda. */ encryptedValue: string; }; export type EditProjectEnvResponseBody = { type: EditProjectEnvProjectsType; value: string; edgeConfigId?: string | null | undefined; edgeConfigTokenId?: string | null | undefined; createdAt?: number | undefined; updatedAt?: number | undefined; id?: string | undefined; key: string; target?: Array<EditProjectEnvTarget1> | EditProjectEnvTarget2 | undefined; gitBranch?: string | undefined; createdBy?: string | null | undefined; updatedBy?: string | null | undefined; /** * This is used to identify variables that have been migrated from type secret to sensitive. */ sunsetSecretId?: string | undefined; /** * Legacy now-encryption ciphertext, present after migration swaps value/vsmValue */ legacyValue?: string | undefined; decrypted?: boolean | undefined; configurationId?: string | null | undefined; /** * User-facing config/secret model. When set, authoritative for new code paths when the env-var-config-secret-ui flag is enabled. Legacy rows omit this field; legacy rows omit it and callers fall back to existing `type` behavior. */ visibility?: Visibility | undefined; contentHint?: | ContentHint1 | ContentHint2 | ContentHint3 | ContentHint4 | ContentHint5 | ContentHint6 | ContentHint7 | ContentHint8 | ContentHint9 | ContentHint10 | ContentHint11 | ContentHint12 | ContentHint13 | ContentHint14 | ContentHint15 | ContentHint16 | ContentHint17 | null | undefined; /** * Similar to `contentHints`, but should not be exposed to the user. */ internalContentHint?: InternalContentHint | null | undefined; comment?: string | undefined; customEnvironmentIds?: Array<string> | undefined; }; /** @internal */ export const EditProjectEnvTarget$outboundSchema: z.ZodNativeEnum< typeof EditProjectEnvTarget > = z.nativeEnum(EditProjectEnvTarget); /** @internal */ export const EditProjectEnvType$outboundSchema: z.ZodNativeEnum< typeof EditProjectEnvType > = z.nativeEnum(EditProjectEnvType); /** @internal */ export type EditProjectEnvRequestBody$Outbound = { key?: string | undefined; target?: Array<string> | undefined; gitBranch?: string | null | undefined; type?: string | undefined; value?: string | undefined; customEnvironmentIds?: Array<string> | undefined; comment?: string | undefined; }; /** @internal */ export const EditProjectEnvRequestBody$outboundSchema: z.ZodType< EditProjectEnvRequestBody$Outbound, z.ZodTypeDef, EditProjectEnvRequestBody > = z.object({ key: z.string().optional(), target: z.array(EditProjectEnvTarget$outboundSchema).optional(), gitBranch: z.nullable(z.string()).optional(), type: EditProjectEnvType$outboundSchema.optional(), value: z.string().optional(), customEnvironmentIds: z.array(z.string()).optional(), comment: z.string().optional(), }); export function editProjectEnvRequestBodyToJSON( editProjectEnvRequestBody: EditProjectEnvRequestBody, ): string { return JSON.stringify( EditProjectEnvRequestBody$outboundSchema.parse(editProjectEnvRequestBody), ); } /** @internal */ export type EditProjectEnvRequest$Outbound = { idOrName: string; id: string; teamId?: string | undefined; slug?: string | undefined; RequestBody: EditProjectEnvRequestBody$Outbound; }; /** @internal */ export const EditProjectEnvRequest$outboundSchema: z.ZodType< EditProjectEnvRequest$Outbound, z.ZodTypeDef, EditProjectEnvRequest > = z.object({ idOrName: z.string(), id: z.string(), teamId: z.string().optional(), slug: z.string().optional(), requestBody: z.lazy(() => EditProjectEnvRequestBody$outboundSchema), }).transform((v) => { return remap$(v, { requestBody: "RequestBody", }); }); export function editProjectEnvRequestToJSON( editProjectEnvRequest: EditProjectEnvRequest, ): string { return JSON.stringify( EditProjectEnvRequest$outboundSchema.parse(editProjectEnvRequest), ); } /** @internal */ export const EditProjectEnvProjectsType$inboundSchema: z.ZodNativeEnum< typeof EditProjectEnvProjectsType > = z.nativeEnum(EditProjectEnvProjectsType); /** @internal */ export const EditProjectEnvTarget2$inboundSchema: z.ZodNativeEnum< typeof EditProjectEnvTarget2 > = z.nativeEnum(EditProjectEnvTarget2); /** @internal */ export const EditProjectEnvTarget1$inboundSchema: z.ZodNativeEnum< typeof EditProjectEnvTarget1 > = z.nativeEnum(EditProjectEnvTarget1); /** @internal */ export const EditProjectEnvProjectsTarget$inboundSchema: z.ZodType< EditProjectEnvProjectsTarget, z.ZodTypeDef, unknown > = smartUnion([ z.array(EditProjectEnvTarget1$inboundSchema), EditProjectEnvTarget2$inboundSchema, ]); export function editProjectEnvProjectsTargetFromJSON( jsonString: string, ): SafeParseResult<EditProjectEnvProjectsTarget, SDKValidationError> { return safeParse( jsonString, (x) => EditProjectEnvProjectsTarget$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EditProjectEnvProjectsTarget' from JSON`, ); } /** @internal */ export const Visibility$inboundSchema: z.ZodNativeEnum<typeof Visibility> = z .nativeEnum(Visibility); /** @internal */ export const ContentHint17$inboundSchema: z.ZodType< ContentHint17, z.ZodTypeDef, unknown > = z.object({ type: types.literal("flags-connection-string"), projectId: types.string(), }); export function contentHint17FromJSON( jsonString: string, ): SafeParseResult<ContentHint17, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint17$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint17' from JSON`, ); } /** @internal */ export const ContentHint16$inboundSchema: z.ZodType< ContentHint16, z.ZodTypeDef, unknown > = z.object({ type: types.literal("integration-store-secret"), storeId: types.string(), integrationId: types.string(), integrationProductId: types.string(), integrationConfigurationId: types.string(), }); export function contentHint16FromJSON( jsonString: string, ): SafeParseResult<ContentHint16, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint16$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint16' from JSON`, ); } /** @internal */ export const ContentHint15$inboundSchema: z.ZodType< ContentHint15, z.ZodTypeDef, unknown > = z.object({ type: types.literal("postgres-url-no-ssl"), storeId: types.string(), }); export function contentHint15FromJSON( jsonString: string, ): SafeParseResult<ContentHint15, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint15$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint15' from JSON`, ); } /** @internal */ export const ContentHint14$inboundSchema: z.ZodType< ContentHint14, z.ZodTypeDef, unknown > = z.object({ type: types.literal("postgres-database"), storeId: types.string(), }); export function contentHint14FromJSON( jsonString: string, ): SafeParseResult<ContentHint14, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint14$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint14' from JSON`, ); } /** @internal */ export const ContentHint13$inboundSchema: z.ZodType< ContentHint13, z.ZodTypeDef, unknown > = z.object({ type: types.literal("postgres-password"), storeId: types.string(), }); export function contentHint13FromJSON( jsonString: string, ): SafeParseResult<ContentHint13, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint13$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint13' from JSON`, ); } /** @internal */ export const ContentHint12$inboundSchema: z.ZodType< ContentHint12, z.ZodTypeDef, unknown > = z.object({ type: types.literal("postgres-host"), storeId: types.string(), }); export function contentHint12FromJSON( jsonString: string, ): SafeParseResult<ContentHint12, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint12$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint12' from JSON`, ); } /** @internal */ export const ContentHint11$inboundSchema: z.ZodType< ContentHint11, z.ZodTypeDef, unknown > = z.object({ type: types.literal("postgres-user"), storeId: types.string(), }); export function contentHint11FromJSON( jsonString: string, ): SafeParseResult<ContentHint11, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint11$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint11' from JSON`, ); } /** @internal */ export const ContentHint10$inboundSchema: z.ZodType< ContentHint10, z.ZodTypeDef, unknown > = z.object({ type: types.literal("postgres-prisma-url"), storeId: types.string(), }); export function contentHint10FromJSON( jsonString: string, ): SafeParseResult<ContentHint10, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint10$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint10' from JSON`, ); } /** @internal */ export const ContentHint9$inboundSchema: z.ZodType< ContentHint9, z.ZodTypeDef, unknown > = z.object({ type: types.literal("postgres-url-non-pooling"), storeId: types.string(), }); export function contentHint9FromJSON( jsonString: string, ): SafeParseResult<ContentHint9, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint9$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint9' from JSON`, ); } /** @internal */ export const ContentHint8$inboundSchema: z.ZodType< ContentHint8, z.ZodTypeDef, unknown > = z.object({ type: types.literal("postgres-url"), storeId: types.string(), }); export function contentHint8FromJSON( jsonString: string, ): SafeParseResult<ContentHint8, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint8$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint8' from JSON`, ); } /** @internal */ export const ContentHint7$inboundSchema: z.ZodType< ContentHint7, z.ZodTypeDef, unknown > = z.object({ type: types.literal("blob-webhook-public-key"), storeId: types.string(), }); export function contentHint7FromJSON( jsonString: string, ): SafeParseResult<ContentHint7, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint7$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint7' from JSON`, ); } /** @internal */ export const ContentHint6$inboundSchema: z.ZodType< ContentHint6, z.ZodTypeDef, unknown > = z.object({ type: types.literal("blob-store-id"), storeId: types.string(), }); export function contentHint6FromJSON( jsonString: string, ): SafeParseResult<ContentHint6, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint6$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint6' from JSON`, ); } /** @internal */ export const ContentHint5$inboundSchema: z.ZodType< ContentHint5, z.ZodTypeDef, unknown > = z.object({ type: types.literal("blob-read-write-token"), storeId: types.string(), }); export function contentHint5FromJSON( jsonString: string, ): SafeParseResult<ContentHint5, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint5$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint5' from JSON`, ); } /** @internal */ export const ContentHint4$inboundSchema: z.ZodType< ContentHint4, z.ZodTypeDef, unknown > = z.object({ type: types.literal("redis-rest-api-read-only-token"), storeId: types.string(), }); export function contentHint4FromJSON( jsonString: string, ): SafeParseResult<ContentHint4, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint4$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint4' from JSON`, ); } /** @internal */ export const ContentHint3$inboundSchema: z.ZodType< ContentHint3, z.ZodTypeDef, unknown > = z.object({ type: types.literal("redis-rest-api-token"), storeId: types.string(), }); export function contentHint3FromJSON( jsonString: string, ): SafeParseResult<ContentHint3, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint3$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint3' from JSON`, ); } /** @internal */ export const ContentHint2$inboundSchema: z.ZodType< ContentHint2, z.ZodTypeDef, unknown > = z.object({ type: types.literal("redis-rest-api-url"), storeId: types.string(), }); export function contentHint2FromJSON( jsonString: string, ): SafeParseResult<ContentHint2, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint2' from JSON`, ); } /** @internal */ export const ContentHint1$inboundSchema: z.ZodType< ContentHint1, z.ZodTypeDef, unknown > = z.object({ type: types.literal("redis-url"), storeId: types.string(), }); export function contentHint1FromJSON( jsonString: string, ): SafeParseResult<ContentHint1, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint1' from JSON`, ); } /** @internal */ export const ContentHint$inboundSchema: z.ZodType< ContentHint, z.ZodTypeDef, unknown > = z.union([ z.lazy(() => ContentHint1$inboundSchema), z.lazy(() => ContentHint2$inboundSchema), z.lazy(() => ContentHint3$inboundSchema), z.lazy(() => ContentHint4$inboundSchema), z.lazy(() => ContentHint5$inboundSchema), z.lazy(() => ContentHint6$inboundSchema), z.lazy(() => ContentHint7$inboundSchema), z.lazy(() => ContentHint8$inboundSchema), z.lazy(() => ContentHint9$inboundSchema), z.lazy(() => ContentHint10$inboundSchema), z.lazy(() => ContentHint11$inboundSchema), z.lazy(() => ContentHint12$inboundSchema), z.lazy(() => ContentHint13$inboundSchema), z.lazy(() => ContentHint14$inboundSchema), z.lazy(() => ContentHint15$inboundSchema), z.lazy(() => ContentHint16$inboundSchema), z.lazy(() => ContentHint17$inboundSchema), ]); export function contentHintFromJSON( jsonString: string, ): SafeParseResult<ContentHint, SDKValidationError> { return safeParse( jsonString, (x) => ContentHint$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentHint' from JSON`, ); } /** @internal */ export const EditProjectEnvProjectsResponseType$inboundSchema: z.ZodNativeEnum< typeof EditProjectEnvProjectsResponseType > = z.nativeEnum(EditProjectEnvProjectsResponseType); /** @internal */ export const InternalContentHint$inboundSchema: z.ZodType< InternalContentHint, z.ZodTypeDef, unknown > = z.object({ type: EditProjectEnvProjectsResponseType$inboundSchema, encryptedValue: types.string(), }); export function internalContentHintFromJSON( jsonString: string, ): SafeParseResult<InternalContentHint, SDKValidationError> { return safeParse( jsonString, (x) => InternalContentHint$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InternalContentHint' from JSON`, ); } /** @internal */ export const EditProjectEnvResponseBody$inboundSchema: z.ZodType< EditProjectEnvResponseBody, z.ZodTypeDef, unknown > = z.object({ type: EditProjectEnvProjectsType$inboundSchema, value: types.string(), edgeConfigId: z.nullable(types.string()).optional(), edgeConfigTokenId: z.nullable(types.string()).optional(), createdAt: types.optional(types.number()), updatedAt: types.optional(types.number()), id: types.optional(types.string()), key: types.string(), target: types.optional( smartUnion([ z.array(EditProjectEnvTarget1$inboundSchema), EditProjectEnvTarget2$inboundSchema, ]), ), gitBranch: types.optional(types.string()), createdBy: z.nullable(types.string()).optional(), updatedBy: z.nullable(types.string()).optional(), sunsetSecretId: types.optional(types.string()), legacyValue: types.optional(types.string()), decrypted: types.optional(types.boolean()), configurationId: z.nullable(types.string()).optional(), visibility: types.optional(Visibility$inboundSchema), contentHint: z.nullable( z.union([ z.lazy(() => ContentHint1$inboundSchema), z.lazy(() => ContentHint2$inboundSchema), z.lazy(() => ContentHint3$inboundSchema), z.lazy(() => ContentHint4$inboundSchema), z.lazy(() => ContentHint5$inboundSchema), z.lazy(() => ContentHint6$inboundSchema), z.lazy(() => ContentHint7$inboundSchema), z.lazy(() => ContentHint8$inboundSchema), z.lazy(() => ContentHint9$inboundSchema), z.lazy(() => ContentHint10$inboundSchema), z.lazy(() => ContentHint11$inboundSchema), z.lazy(() => ContentHint12$inboundSchema), z.lazy(() => ContentHint13$inboundSchema), z.lazy(() => ContentHint14$inboundSchema), z.lazy(() => ContentHint15$inboundSchema), z.lazy(() => ContentHint16$inboundSchema), z.lazy(() => ContentHint17$inboundSchema), ]), ).optional(), internalContentHint: z.nullable( z.lazy(() => InternalContentHint$inboundSchema), ).optional(), comment: types.optional(types.string()), customEnvironmentIds: types.optional(z.array(types.string())), }); export function editProjectEnvResponseBodyFromJSON( jsonString: string, ): SafeParseResult<EditProjectEnvResponseBody, SDKValidationError> { return safeParse( jsonString, (x) => EditProjectEnvResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EditProjectEnvResponseBody' from JSON`, ); }