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>

589 lines (524 loc) 16.8 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 UpdateResourceOwnership = { Owned: "owned", Linked: "linked", Sandbox: "sandbox", } as const; export type UpdateResourceOwnership = ClosedEnum< typeof UpdateResourceOwnership >; export const UpdateResourceStatus = { Ready: "ready", Pending: "pending", Onboarding: "onboarding", Suspended: "suspended", Resumed: "resumed", Uninstalled: "uninstalled", Error: "error", } as const; export type UpdateResourceStatus = ClosedEnum<typeof UpdateResourceStatus>; export const UpdateResourceType = { Prepayment: "prepayment", Subscription: "subscription", } as const; export type UpdateResourceType = ClosedEnum<typeof UpdateResourceType>; export type UpdateResourceDetails = { label: string; value?: string | undefined; }; export type UpdateResourceHighlightedDetails = { label: string; value?: string | undefined; }; export type UpdateResourceBillingPlan = { id: string; type: UpdateResourceType; name: string; description?: string | undefined; paymentMethodRequired?: boolean | undefined; cost?: string | undefined; details?: Array<UpdateResourceDetails> | undefined; highlightedDetails?: Array<UpdateResourceHighlightedDetails> | undefined; effectiveDate?: string | undefined; additionalProperties?: { [k: string]: any } | undefined; }; export const NotificationLevel = { Info: "info", Warn: "warn", Error: "error", } as const; export type NotificationLevel = ClosedEnum<typeof NotificationLevel>; export type UpdateResourceNotification1 = { level: NotificationLevel; title: string; message?: string | undefined; href?: string | undefined; }; export type UpdateResourceNotification = UpdateResourceNotification1 | string; /** * A map of environments to override values for the secret, used for setting different values across deployments in production, preview, and development environments. Note: the same value will be used for all deployments in the given environment. */ export type UpdateResourceSecretsMarketplaceEnvironmentOverrides = { /** * Value used for development environment. */ development?: string | undefined; /** * Value used for preview environment. */ preview?: string | undefined; /** * Value used for production environment. */ production?: string | undefined; }; export type SecretsSecrets = { name: string; value: string; prefix?: string | undefined; /** * A map of environments to override values for the secret, used for setting different values across deployments in production, preview, and development environments. Note: the same value will be used for all deployments in the given environment. */ environmentOverrides?: | UpdateResourceSecretsMarketplaceEnvironmentOverrides | undefined; }; export type Secrets2 = { secrets: Array<SecretsSecrets>; /** * If true, will only overwrite the provided secrets instead of replacing all secrets. */ partial?: boolean | undefined; }; /** * A map of environments to override values for the secret, used for setting different values across deployments in production, preview, and development environments. Note: the same value will be used for all deployments in the given environment. */ export type SecretsEnvironmentOverrides = { /** * Value used for development environment. */ development?: string | undefined; /** * Value used for preview environment. */ preview?: string | undefined; /** * Value used for production environment. */ production?: string | undefined; }; export type Secrets1 = { name: string; value: string; prefix?: string | undefined; /** * A map of environments to override values for the secret, used for setting different values across deployments in production, preview, and development environments. Note: the same value will be used for all deployments in the given environment. */ environmentOverrides?: SecretsEnvironmentOverrides | undefined; }; export type UpdateResourceSecrets = Secrets2 | Array<Secrets1>; export type UpdateResourceRequestBody = { ownership?: UpdateResourceOwnership | undefined; name?: string | undefined; status?: UpdateResourceStatus | undefined; metadata?: { [k: string]: any } | undefined; billingPlan?: UpdateResourceBillingPlan | undefined; notification?: UpdateResourceNotification1 | string | undefined; extras?: { [k: string]: any } | undefined; secrets?: Secrets2 | Array<Secrets1> | undefined; }; export type UpdateResourceRequest = { integrationConfigurationId: string; resourceId: string; requestBody?: UpdateResourceRequestBody | undefined; }; export type UpdateResourceResponseBody = { name: string; }; /** @internal */ export const UpdateResourceOwnership$outboundSchema: z.ZodNativeEnum< typeof UpdateResourceOwnership > = z.nativeEnum(UpdateResourceOwnership); /** @internal */ export const UpdateResourceStatus$outboundSchema: z.ZodNativeEnum< typeof UpdateResourceStatus > = z.nativeEnum(UpdateResourceStatus); /** @internal */ export const UpdateResourceType$outboundSchema: z.ZodNativeEnum< typeof UpdateResourceType > = z.nativeEnum(UpdateResourceType); /** @internal */ export type UpdateResourceDetails$Outbound = { label: string; value?: string | undefined; }; /** @internal */ export const UpdateResourceDetails$outboundSchema: z.ZodType< UpdateResourceDetails$Outbound, z.ZodTypeDef, UpdateResourceDetails > = z.object({ label: z.string(), value: z.string().optional(), }); export function updateResourceDetailsToJSON( updateResourceDetails: UpdateResourceDetails, ): string { return JSON.stringify( UpdateResourceDetails$outboundSchema.parse(updateResourceDetails), ); } /** @internal */ export type UpdateResourceHighlightedDetails$Outbound = { label: string; value?: string | undefined; }; /** @internal */ export const UpdateResourceHighlightedDetails$outboundSchema: z.ZodType< UpdateResourceHighlightedDetails$Outbound, z.ZodTypeDef, UpdateResourceHighlightedDetails > = z.object({ label: z.string(), value: z.string().optional(), }); export function updateResourceHighlightedDetailsToJSON( updateResourceHighlightedDetails: UpdateResourceHighlightedDetails, ): string { return JSON.stringify( UpdateResourceHighlightedDetails$outboundSchema.parse( updateResourceHighlightedDetails, ), ); } /** @internal */ export type UpdateResourceBillingPlan$Outbound = { id: string; type: string; name: string; description?: string | undefined; paymentMethodRequired?: boolean | undefined; cost?: string | undefined; details?: Array<UpdateResourceDetails$Outbound> | undefined; highlightedDetails?: | Array<UpdateResourceHighlightedDetails$Outbound> | undefined; effectiveDate?: string | undefined; [additionalProperties: string]: unknown; }; /** @internal */ export const UpdateResourceBillingPlan$outboundSchema: z.ZodType< UpdateResourceBillingPlan$Outbound, z.ZodTypeDef, UpdateResourceBillingPlan > = z.object({ id: z.string(), type: UpdateResourceType$outboundSchema, name: z.string(), description: z.string().optional(), paymentMethodRequired: z.boolean().optional(), cost: z.string().optional(), details: z.array(z.lazy(() => UpdateResourceDetails$outboundSchema)) .optional(), highlightedDetails: z.array( z.lazy(() => UpdateResourceHighlightedDetails$outboundSchema), ).optional(), effectiveDate: z.string().optional(), additionalProperties: z.record(z.any()).optional(), }).transform((v) => { return { ...v.additionalProperties, ...remap$(v, { additionalProperties: null, }), }; }); export function updateResourceBillingPlanToJSON( updateResourceBillingPlan: UpdateResourceBillingPlan, ): string { return JSON.stringify( UpdateResourceBillingPlan$outboundSchema.parse(updateResourceBillingPlan), ); } /** @internal */ export const NotificationLevel$outboundSchema: z.ZodNativeEnum< typeof NotificationLevel > = z.nativeEnum(NotificationLevel); /** @internal */ export type UpdateResourceNotification1$Outbound = { level: string; title: string; message?: string | undefined; href?: string | undefined; }; /** @internal */ export const UpdateResourceNotification1$outboundSchema: z.ZodType< UpdateResourceNotification1$Outbound, z.ZodTypeDef, UpdateResourceNotification1 > = z.object({ level: NotificationLevel$outboundSchema, title: z.string(), message: z.string().optional(), href: z.string().optional(), }); export function updateResourceNotification1ToJSON( updateResourceNotification1: UpdateResourceNotification1, ): string { return JSON.stringify( UpdateResourceNotification1$outboundSchema.parse( updateResourceNotification1, ), ); } /** @internal */ export type UpdateResourceNotification$Outbound = | UpdateResourceNotification1$Outbound | string; /** @internal */ export const UpdateResourceNotification$outboundSchema: z.ZodType< UpdateResourceNotification$Outbound, z.ZodTypeDef, UpdateResourceNotification > = smartUnion([ z.lazy(() => UpdateResourceNotification1$outboundSchema), z.string(), ]); export function updateResourceNotificationToJSON( updateResourceNotification: UpdateResourceNotification, ): string { return JSON.stringify( UpdateResourceNotification$outboundSchema.parse(updateResourceNotification), ); } /** @internal */ export type UpdateResourceSecretsMarketplaceEnvironmentOverrides$Outbound = { development?: string | undefined; preview?: string | undefined; production?: string | undefined; }; /** @internal */ export const UpdateResourceSecretsMarketplaceEnvironmentOverrides$outboundSchema: z.ZodType< UpdateResourceSecretsMarketplaceEnvironmentOverrides$Outbound, z.ZodTypeDef, UpdateResourceSecretsMarketplaceEnvironmentOverrides > = z.object({ development: z.string().optional(), preview: z.string().optional(), production: z.string().optional(), }); export function updateResourceSecretsMarketplaceEnvironmentOverridesToJSON( updateResourceSecretsMarketplaceEnvironmentOverrides: UpdateResourceSecretsMarketplaceEnvironmentOverrides, ): string { return JSON.stringify( UpdateResourceSecretsMarketplaceEnvironmentOverrides$outboundSchema.parse( updateResourceSecretsMarketplaceEnvironmentOverrides, ), ); } /** @internal */ export type SecretsSecrets$Outbound = { name: string; value: string; prefix?: string | undefined; environmentOverrides?: | UpdateResourceSecretsMarketplaceEnvironmentOverrides$Outbound | undefined; }; /** @internal */ export const SecretsSecrets$outboundSchema: z.ZodType< SecretsSecrets$Outbound, z.ZodTypeDef, SecretsSecrets > = z.object({ name: z.string(), value: z.string(), prefix: z.string().optional(), environmentOverrides: z.lazy(() => UpdateResourceSecretsMarketplaceEnvironmentOverrides$outboundSchema ).optional(), }); export function secretsSecretsToJSON(secretsSecrets: SecretsSecrets): string { return JSON.stringify(SecretsSecrets$outboundSchema.parse(secretsSecrets)); } /** @internal */ export type Secrets2$Outbound = { secrets: Array<SecretsSecrets$Outbound>; partial?: boolean | undefined; }; /** @internal */ export const Secrets2$outboundSchema: z.ZodType< Secrets2$Outbound, z.ZodTypeDef, Secrets2 > = z.object({ secrets: z.array(z.lazy(() => SecretsSecrets$outboundSchema)), partial: z.boolean().optional(), }); export function secrets2ToJSON(secrets2: Secrets2): string { return JSON.stringify(Secrets2$outboundSchema.parse(secrets2)); } /** @internal */ export type SecretsEnvironmentOverrides$Outbound = { development?: string | undefined; preview?: string | undefined; production?: string | undefined; }; /** @internal */ export const SecretsEnvironmentOverrides$outboundSchema: z.ZodType< SecretsEnvironmentOverrides$Outbound, z.ZodTypeDef, SecretsEnvironmentOverrides > = z.object({ development: z.string().optional(), preview: z.string().optional(), production: z.string().optional(), }); export function secretsEnvironmentOverridesToJSON( secretsEnvironmentOverrides: SecretsEnvironmentOverrides, ): string { return JSON.stringify( SecretsEnvironmentOverrides$outboundSchema.parse( secretsEnvironmentOverrides, ), ); } /** @internal */ export type Secrets1$Outbound = { name: string; value: string; prefix?: string | undefined; environmentOverrides?: SecretsEnvironmentOverrides$Outbound | undefined; }; /** @internal */ export const Secrets1$outboundSchema: z.ZodType< Secrets1$Outbound, z.ZodTypeDef, Secrets1 > = z.object({ name: z.string(), value: z.string(), prefix: z.string().optional(), environmentOverrides: z.lazy(() => SecretsEnvironmentOverrides$outboundSchema) .optional(), }); export function secrets1ToJSON(secrets1: Secrets1): string { return JSON.stringify(Secrets1$outboundSchema.parse(secrets1)); } /** @internal */ export type UpdateResourceSecrets$Outbound = | Secrets2$Outbound | Array<Secrets1$Outbound>; /** @internal */ export const UpdateResourceSecrets$outboundSchema: z.ZodType< UpdateResourceSecrets$Outbound, z.ZodTypeDef, UpdateResourceSecrets > = smartUnion([ z.lazy(() => Secrets2$outboundSchema), z.array(z.lazy(() => Secrets1$outboundSchema)), ]); export function updateResourceSecretsToJSON( updateResourceSecrets: UpdateResourceSecrets, ): string { return JSON.stringify( UpdateResourceSecrets$outboundSchema.parse(updateResourceSecrets), ); } /** @internal */ export type UpdateResourceRequestBody$Outbound = { ownership?: string | undefined; name?: string | undefined; status?: string | undefined; metadata?: { [k: string]: any } | undefined; billingPlan?: UpdateResourceBillingPlan$Outbound | undefined; notification?: UpdateResourceNotification1$Outbound | string | undefined; extras?: { [k: string]: any } | undefined; secrets?: Secrets2$Outbound | Array<Secrets1$Outbound> | undefined; }; /** @internal */ export const UpdateResourceRequestBody$outboundSchema: z.ZodType< UpdateResourceRequestBody$Outbound, z.ZodTypeDef, UpdateResourceRequestBody > = z.object({ ownership: UpdateResourceOwnership$outboundSchema.optional(), name: z.string().optional(), status: UpdateResourceStatus$outboundSchema.optional(), metadata: z.record(z.any()).optional(), billingPlan: z.lazy(() => UpdateResourceBillingPlan$outboundSchema) .optional(), notification: smartUnion([ z.lazy(() => UpdateResourceNotification1$outboundSchema), z.string(), ]).optional(), extras: z.record(z.any()).optional(), secrets: smartUnion([ z.lazy(() => Secrets2$outboundSchema), z.array(z.lazy(() => Secrets1$outboundSchema)), ]).optional(), }); export function updateResourceRequestBodyToJSON( updateResourceRequestBody: UpdateResourceRequestBody, ): string { return JSON.stringify( UpdateResourceRequestBody$outboundSchema.parse(updateResourceRequestBody), ); } /** @internal */ export type UpdateResourceRequest$Outbound = { integrationConfigurationId: string; resourceId: string; RequestBody?: UpdateResourceRequestBody$Outbound | undefined; }; /** @internal */ export const UpdateResourceRequest$outboundSchema: z.ZodType< UpdateResourceRequest$Outbound, z.ZodTypeDef, UpdateResourceRequest > = z.object({ integrationConfigurationId: z.string(), resourceId: z.string(), requestBody: z.lazy(() => UpdateResourceRequestBody$outboundSchema) .optional(), }).transform((v) => { return remap$(v, { requestBody: "RequestBody", }); }); export function updateResourceRequestToJSON( updateResourceRequest: UpdateResourceRequest, ): string { return JSON.stringify( UpdateResourceRequest$outboundSchema.parse(updateResourceRequest), ); } /** @internal */ export const UpdateResourceResponseBody$inboundSchema: z.ZodType< UpdateResourceResponseBody, z.ZodTypeDef, unknown > = z.object({ name: types.string(), }); export function updateResourceResponseBodyFromJSON( jsonString: string, ): SafeParseResult<UpdateResourceResponseBody, SDKValidationError> { return safeParse( jsonString, (x) => UpdateResourceResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdateResourceResponseBody' from JSON`, ); }