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>

345 lines (312 loc) 9.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 { smartUnion } from "../types/smartUnion.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; export type GetIntegrationResourceRequest = { /** * The ID of the integration configuration (installation) the resource belongs to */ integrationConfigurationId: string; /** * The ID provided by the 3rd party provider for the given resource */ resourceId: string; }; /** * The current status of the resource */ export const GetIntegrationResourceStatus = { Error: "error", Onboarding: "onboarding", Pending: "pending", Ready: "ready", Resumed: "resumed", Suspended: "suspended", Uninstalled: "uninstalled", } as const; /** * The current status of the resource */ export type GetIntegrationResourceStatus = ClosedEnum< typeof GetIntegrationResourceStatus >; export type Experimentation = { edgeConfigId?: string | undefined; globalConfigId?: string | undefined; }; export const GetIntegrationResourceTarget = { Development: "development", Preview: "preview", Production: "production", } as const; export type GetIntegrationResourceTarget = ClosedEnum< typeof GetIntegrationResourceTarget >; export type AppUrls = { url: string; target: GetIntegrationResourceTarget; }; export type Authentication = { appUrls?: Array<AppUrls> | undefined; }; /** * Any settings provided for the resource to support its product's protocols */ export type ProtocolSettings = { experimentation?: Experimentation | undefined; authentication?: Authentication | undefined; }; export const GetIntegrationResourceLevel = { Error: "error", Info: "info", Warn: "warn", } as const; export type GetIntegrationResourceLevel = ClosedEnum< typeof GetIntegrationResourceLevel >; /** * The notification, if set, displayed to the user when viewing the resource in Vercel */ export type GetIntegrationResourceNotification = { title: string; level: GetIntegrationResourceLevel; message?: string | undefined; href?: string | undefined; }; export type GetIntegrationResourceMetadata = | string | number | Array<string> | Array<number> | boolean; export type GetIntegrationResourceResponseBody = { /** * The ID provided by the 3rd party provider for the given resource */ id: string; /** * The ID assigned by Vercel for the given resource */ internalId: string; /** * The name of the resource as it is recorded in Vercel */ name: string; /** * The current status of the resource */ status?: GetIntegrationResourceStatus | undefined; /** * The ID of the product the resource is derived from */ productId: string; /** * Any settings provided for the resource to support its product's protocols */ protocolSettings?: ProtocolSettings | undefined; /** * The notification, if set, displayed to the user when viewing the resource in Vercel */ notification?: GetIntegrationResourceNotification | undefined; /** * The ID of the billing plan the resource is subscribed to, if applicable */ billingPlanId?: string | undefined; /** * The configured metadata for the resource as defined by its product's Metadata Schema */ metadata?: { [k: string]: string | number | Array<string> | Array<number> | boolean; } | undefined; }; /** @internal */ export type GetIntegrationResourceRequest$Outbound = { integrationConfigurationId: string; resourceId: string; }; /** @internal */ export const GetIntegrationResourceRequest$outboundSchema: z.ZodType< GetIntegrationResourceRequest$Outbound, z.ZodTypeDef, GetIntegrationResourceRequest > = z.object({ integrationConfigurationId: z.string(), resourceId: z.string(), }); export function getIntegrationResourceRequestToJSON( getIntegrationResourceRequest: GetIntegrationResourceRequest, ): string { return JSON.stringify( GetIntegrationResourceRequest$outboundSchema.parse( getIntegrationResourceRequest, ), ); } /** @internal */ export const GetIntegrationResourceStatus$inboundSchema: z.ZodNativeEnum< typeof GetIntegrationResourceStatus > = z.nativeEnum(GetIntegrationResourceStatus); /** @internal */ export const Experimentation$inboundSchema: z.ZodType< Experimentation, z.ZodTypeDef, unknown > = z.object({ edgeConfigId: types.optional(types.string()), globalConfigId: types.optional(types.string()), }); export function experimentationFromJSON( jsonString: string, ): SafeParseResult<Experimentation, SDKValidationError> { return safeParse( jsonString, (x) => Experimentation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Experimentation' from JSON`, ); } /** @internal */ export const GetIntegrationResourceTarget$inboundSchema: z.ZodNativeEnum< typeof GetIntegrationResourceTarget > = z.nativeEnum(GetIntegrationResourceTarget); /** @internal */ export const AppUrls$inboundSchema: z.ZodType<AppUrls, z.ZodTypeDef, unknown> = z.object({ url: types.string(), target: GetIntegrationResourceTarget$inboundSchema, }); export function appUrlsFromJSON( jsonString: string, ): SafeParseResult<AppUrls, SDKValidationError> { return safeParse( jsonString, (x) => AppUrls$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AppUrls' from JSON`, ); } /** @internal */ export const Authentication$inboundSchema: z.ZodType< Authentication, z.ZodTypeDef, unknown > = z.object({ appUrls: types.optional(z.array(z.lazy(() => AppUrls$inboundSchema))), }); export function authenticationFromJSON( jsonString: string, ): SafeParseResult<Authentication, SDKValidationError> { return safeParse( jsonString, (x) => Authentication$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Authentication' from JSON`, ); } /** @internal */ export const ProtocolSettings$inboundSchema: z.ZodType< ProtocolSettings, z.ZodTypeDef, unknown > = z.object({ experimentation: types.optional(z.lazy(() => Experimentation$inboundSchema)), authentication: types.optional(z.lazy(() => Authentication$inboundSchema)), }); export function protocolSettingsFromJSON( jsonString: string, ): SafeParseResult<ProtocolSettings, SDKValidationError> { return safeParse( jsonString, (x) => ProtocolSettings$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ProtocolSettings' from JSON`, ); } /** @internal */ export const GetIntegrationResourceLevel$inboundSchema: z.ZodNativeEnum< typeof GetIntegrationResourceLevel > = z.nativeEnum(GetIntegrationResourceLevel); /** @internal */ export const GetIntegrationResourceNotification$inboundSchema: z.ZodType< GetIntegrationResourceNotification, z.ZodTypeDef, unknown > = z.object({ title: types.string(), level: GetIntegrationResourceLevel$inboundSchema, message: types.optional(types.string()), href: types.optional(types.string()), }); export function getIntegrationResourceNotificationFromJSON( jsonString: string, ): SafeParseResult<GetIntegrationResourceNotification, SDKValidationError> { return safeParse( jsonString, (x) => GetIntegrationResourceNotification$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetIntegrationResourceNotification' from JSON`, ); } /** @internal */ export const GetIntegrationResourceMetadata$inboundSchema: z.ZodType< GetIntegrationResourceMetadata, z.ZodTypeDef, unknown > = smartUnion([ types.string(), types.number(), z.array(types.string()), z.array(types.number()), types.boolean(), ]); export function getIntegrationResourceMetadataFromJSON( jsonString: string, ): SafeParseResult<GetIntegrationResourceMetadata, SDKValidationError> { return safeParse( jsonString, (x) => GetIntegrationResourceMetadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetIntegrationResourceMetadata' from JSON`, ); } /** @internal */ export const GetIntegrationResourceResponseBody$inboundSchema: z.ZodType< GetIntegrationResourceResponseBody, z.ZodTypeDef, unknown > = z.object({ id: types.string(), internalId: types.string(), name: types.string(), status: types.optional(GetIntegrationResourceStatus$inboundSchema), productId: types.string(), protocolSettings: types.optional( z.lazy(() => ProtocolSettings$inboundSchema), ), notification: types.optional( z.lazy(() => GetIntegrationResourceNotification$inboundSchema), ), billingPlanId: types.optional(types.string()), metadata: types.optional( z.record( smartUnion([ types.string(), types.number(), z.array(types.string()), z.array(types.number()), types.boolean(), ]), ), ), }); export function getIntegrationResourceResponseBodyFromJSON( jsonString: string, ): SafeParseResult<GetIntegrationResourceResponseBody, SDKValidationError> { return safeParse( jsonString, (x) => GetIntegrationResourceResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetIntegrationResourceResponseBody' from JSON`, ); }