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>

154 lines (132 loc) 3.52 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"; export type Event2 = { type: "resource.updated"; /** * Partner-provided product slug or id */ productId?: string | undefined; /** * Partner provided resource ID */ resourceId: string; }; export type Event1 = { type: "installation.updated"; /** * The installation-level billing plan ID */ billingPlanId?: string | undefined; }; export type CreateEventEvent = Event1 | Event2; export type CreateEventRequestBody = { event: Event1 | Event2; }; export type CreateEventRequest = { integrationConfigurationId: string; requestBody: CreateEventRequestBody; }; /** @internal */ export type Event2$Outbound = { type: "resource.updated"; productId?: string | undefined; resourceId: string; }; /** @internal */ export const Event2$outboundSchema: z.ZodType< Event2$Outbound, z.ZodTypeDef, Event2 > = z.object({ type: z.literal("resource.updated"), productId: z.string().optional(), resourceId: z.string(), }); export function event2ToJSON(event2: Event2): string { return JSON.stringify(Event2$outboundSchema.parse(event2)); } /** @internal */ export type Event1$Outbound = { type: "installation.updated"; billingPlanId?: string | undefined; }; /** @internal */ export const Event1$outboundSchema: z.ZodType< Event1$Outbound, z.ZodTypeDef, Event1 > = z.object({ type: z.literal("installation.updated"), billingPlanId: z.string().optional(), }); export function event1ToJSON(event1: Event1): string { return JSON.stringify(Event1$outboundSchema.parse(event1)); } /** @internal */ export type CreateEventEvent$Outbound = Event1$Outbound | Event2$Outbound; /** @internal */ export const CreateEventEvent$outboundSchema: z.ZodType< CreateEventEvent$Outbound, z.ZodTypeDef, CreateEventEvent > = z.union([ z.lazy(() => Event1$outboundSchema), z.lazy(() => Event2$outboundSchema), ]); export function createEventEventToJSON( createEventEvent: CreateEventEvent, ): string { return JSON.stringify( CreateEventEvent$outboundSchema.parse(createEventEvent), ); } /** @internal */ export type CreateEventRequestBody$Outbound = { event: Event1$Outbound | Event2$Outbound; }; /** @internal */ export const CreateEventRequestBody$outboundSchema: z.ZodType< CreateEventRequestBody$Outbound, z.ZodTypeDef, CreateEventRequestBody > = z.object({ event: z.union([ z.lazy(() => Event1$outboundSchema), z.lazy(() => Event2$outboundSchema), ]), }); export function createEventRequestBodyToJSON( createEventRequestBody: CreateEventRequestBody, ): string { return JSON.stringify( CreateEventRequestBody$outboundSchema.parse(createEventRequestBody), ); } /** @internal */ export type CreateEventRequest$Outbound = { integrationConfigurationId: string; RequestBody: CreateEventRequestBody$Outbound; }; /** @internal */ export const CreateEventRequest$outboundSchema: z.ZodType< CreateEventRequest$Outbound, z.ZodTypeDef, CreateEventRequest > = z.object({ integrationConfigurationId: z.string(), requestBody: z.lazy(() => CreateEventRequestBody$outboundSchema), }).transform((v) => { return remap$(v, { requestBody: "RequestBody", }); }); export function createEventRequestToJSON( createEventRequest: CreateEventRequest, ): string { return JSON.stringify( CreateEventRequest$outboundSchema.parse(createEventRequest), ); }