/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatRenderOutput, ChatRenderOutput$inboundSchema, } from "./chatrenderoutput.js"; import { DigestRegularOutput, DigestRegularOutput$inboundSchema, } from "./digestregularoutput.js"; import { EmailRenderOutput, EmailRenderOutput$inboundSchema, } from "./emailrenderoutput.js"; import { InAppRenderOutput, InAppRenderOutput$inboundSchema, } from "./inapprenderoutput.js"; import { PreviewErrorDto, PreviewErrorDto$inboundSchema, } from "./previewerrordto.js"; import { PreviewPayloadDto, PreviewPayloadDto$inboundSchema, } from "./previewpayloaddto.js"; import { PushRenderOutput, PushRenderOutput$inboundSchema, } from "./pushrenderoutput.js"; import { SmsRenderOutput, SmsRenderOutput$inboundSchema, } from "./smsrenderoutput.js"; export const GeneratePreviewResponseDtoResult9Type = { Digest: "digest", } as const; export type GeneratePreviewResponseDtoResult9Type = ClosedEnum< typeof GeneratePreviewResponseDtoResult9Type >; export type Nine = { type?: GeneratePreviewResponseDtoResult9Type | undefined; preview?: DigestRegularOutput | undefined; }; export const GeneratePreviewResponseDtoResult8Type = { Delay: "delay", } as const; export type GeneratePreviewResponseDtoResult8Type = ClosedEnum< typeof GeneratePreviewResponseDtoResult8Type >; export type Eight = { type?: GeneratePreviewResponseDtoResult8Type | undefined; preview?: DigestRegularOutput | undefined; }; export const GeneratePreviewResponseDtoResult7Type = { Chat: "chat", } as const; export type GeneratePreviewResponseDtoResult7Type = ClosedEnum< typeof GeneratePreviewResponseDtoResult7Type >; export type Seven = { type?: GeneratePreviewResponseDtoResult7Type | undefined; preview?: ChatRenderOutput | undefined; error?: PreviewErrorDto | undefined; }; export const GeneratePreviewResponseDtoResult6Type = { Push: "push", } as const; export type GeneratePreviewResponseDtoResult6Type = ClosedEnum< typeof GeneratePreviewResponseDtoResult6Type >; export type Six = { type?: GeneratePreviewResponseDtoResult6Type | undefined; preview?: PushRenderOutput | undefined; error?: PreviewErrorDto | undefined; }; export const GeneratePreviewResponseDtoResult5Type = { Sms: "sms", } as const; export type GeneratePreviewResponseDtoResult5Type = ClosedEnum< typeof GeneratePreviewResponseDtoResult5Type >; export type Result5 = { type?: GeneratePreviewResponseDtoResult5Type | undefined; preview?: SmsRenderOutput | undefined; error?: PreviewErrorDto | undefined; }; export const GeneratePreviewResponseDtoResult4Type = { InApp: "in_app", } as const; export type GeneratePreviewResponseDtoResult4Type = ClosedEnum< typeof GeneratePreviewResponseDtoResult4Type >; export type Result4 = { type?: GeneratePreviewResponseDtoResult4Type | undefined; preview?: InAppRenderOutput | undefined; error?: PreviewErrorDto | undefined; }; export const GeneratePreviewResponseDtoResult3Type = { Email: "email", } as const; export type GeneratePreviewResponseDtoResult3Type = ClosedEnum< typeof GeneratePreviewResponseDtoResult3Type >; export type Three = { type?: GeneratePreviewResponseDtoResult3Type | undefined; preview?: EmailRenderOutput | undefined; error?: PreviewErrorDto | undefined; }; export const GeneratePreviewResponseDtoResultType = { Email: "email", } as const; export type GeneratePreviewResponseDtoResultType = ClosedEnum< typeof GeneratePreviewResponseDtoResultType >; export type Result2 = { type?: GeneratePreviewResponseDtoResultType | undefined; preview?: EmailRenderOutput | undefined; error?: PreviewErrorDto | undefined; }; /** * Preview result */ export type GeneratePreviewResponseDtoResult = | { [k: string]: any } | Result2 | Three | Result4 | Result5 | Six | Seven | Eight | Nine; export type GeneratePreviewResponseDto = { /** * Preview payload example */ previewPayloadExample: PreviewPayloadDto; /** * The payload schema that was used to generate the preview payload example */ schema?: { [k: string]: any } | null | undefined; /** * Sample novu-signature header value for HTTP request steps */ novuSignature?: string | undefined; /** * Preview result */ result: | { [k: string]: any } | Result2 | Three | Result4 | Result5 | Six | Seven | Eight | Nine; }; /** @internal */ export const GeneratePreviewResponseDtoResult9Type$inboundSchema: z.ZodNativeEnum = z.nativeEnum( GeneratePreviewResponseDtoResult9Type, ); /** @internal */ export const Nine$inboundSchema: z.ZodType = z .object({ type: GeneratePreviewResponseDtoResult9Type$inboundSchema.optional(), preview: DigestRegularOutput$inboundSchema.optional(), }); export function nineFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Nine$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Nine' from JSON`, ); } /** @internal */ export const GeneratePreviewResponseDtoResult8Type$inboundSchema: z.ZodNativeEnum = z.nativeEnum( GeneratePreviewResponseDtoResult8Type, ); /** @internal */ export const Eight$inboundSchema: z.ZodType = z .object({ type: GeneratePreviewResponseDtoResult8Type$inboundSchema.optional(), preview: DigestRegularOutput$inboundSchema.optional(), }); export function eightFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Eight$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Eight' from JSON`, ); } /** @internal */ export const GeneratePreviewResponseDtoResult7Type$inboundSchema: z.ZodNativeEnum = z.nativeEnum( GeneratePreviewResponseDtoResult7Type, ); /** @internal */ export const Seven$inboundSchema: z.ZodType = z .object({ type: GeneratePreviewResponseDtoResult7Type$inboundSchema.optional(), preview: ChatRenderOutput$inboundSchema.optional(), error: PreviewErrorDto$inboundSchema.optional(), }); export function sevenFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Seven$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Seven' from JSON`, ); } /** @internal */ export const GeneratePreviewResponseDtoResult6Type$inboundSchema: z.ZodNativeEnum = z.nativeEnum( GeneratePreviewResponseDtoResult6Type, ); /** @internal */ export const Six$inboundSchema: z.ZodType = z .object({ type: GeneratePreviewResponseDtoResult6Type$inboundSchema.optional(), preview: PushRenderOutput$inboundSchema.optional(), error: PreviewErrorDto$inboundSchema.optional(), }); export function sixFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Six$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Six' from JSON`, ); } /** @internal */ export const GeneratePreviewResponseDtoResult5Type$inboundSchema: z.ZodNativeEnum = z.nativeEnum( GeneratePreviewResponseDtoResult5Type, ); /** @internal */ export const Result5$inboundSchema: z.ZodType = z.object({ type: GeneratePreviewResponseDtoResult5Type$inboundSchema.optional(), preview: SmsRenderOutput$inboundSchema.optional(), error: PreviewErrorDto$inboundSchema.optional(), }); export function result5FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Result5$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Result5' from JSON`, ); } /** @internal */ export const GeneratePreviewResponseDtoResult4Type$inboundSchema: z.ZodNativeEnum = z.nativeEnum( GeneratePreviewResponseDtoResult4Type, ); /** @internal */ export const Result4$inboundSchema: z.ZodType = z.object({ type: GeneratePreviewResponseDtoResult4Type$inboundSchema.optional(), preview: InAppRenderOutput$inboundSchema.optional(), error: PreviewErrorDto$inboundSchema.optional(), }); export function result4FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Result4$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Result4' from JSON`, ); } /** @internal */ export const GeneratePreviewResponseDtoResult3Type$inboundSchema: z.ZodNativeEnum = z.nativeEnum( GeneratePreviewResponseDtoResult3Type, ); /** @internal */ export const Three$inboundSchema: z.ZodType = z .object({ type: GeneratePreviewResponseDtoResult3Type$inboundSchema.optional(), preview: EmailRenderOutput$inboundSchema.optional(), error: PreviewErrorDto$inboundSchema.optional(), }); export function threeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Three$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Three' from JSON`, ); } /** @internal */ export const GeneratePreviewResponseDtoResultType$inboundSchema: z.ZodNativeEnum = z.nativeEnum( GeneratePreviewResponseDtoResultType, ); /** @internal */ export const Result2$inboundSchema: z.ZodType = z.object({ type: GeneratePreviewResponseDtoResultType$inboundSchema.optional(), preview: EmailRenderOutput$inboundSchema.optional(), error: PreviewErrorDto$inboundSchema.optional(), }); export function result2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Result2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Result2' from JSON`, ); } /** @internal */ export const GeneratePreviewResponseDtoResult$inboundSchema: z.ZodType< GeneratePreviewResponseDtoResult, z.ZodTypeDef, unknown > = z.union([ z.record(z.any()), z.lazy(() => Result2$inboundSchema), z.lazy(() => Three$inboundSchema), z.lazy(() => Result4$inboundSchema), z.lazy(() => Result5$inboundSchema), z.lazy(() => Six$inboundSchema), z.lazy(() => Seven$inboundSchema), z.lazy(() => Eight$inboundSchema), z.lazy(() => Nine$inboundSchema), ]); export function generatePreviewResponseDtoResultFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GeneratePreviewResponseDtoResult$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GeneratePreviewResponseDtoResult' from JSON`, ); } /** @internal */ export const GeneratePreviewResponseDto$inboundSchema: z.ZodType< GeneratePreviewResponseDto, z.ZodTypeDef, unknown > = z.object({ previewPayloadExample: PreviewPayloadDto$inboundSchema, schema: z.nullable(z.record(z.any())).optional(), novuSignature: z.string().optional(), result: z.union([ z.record(z.any()), z.lazy(() => Result2$inboundSchema), z.lazy(() => Three$inboundSchema), z.lazy(() => Result4$inboundSchema), z.lazy(() => Result5$inboundSchema), z.lazy(() => Six$inboundSchema), z.lazy(() => Seven$inboundSchema), z.lazy(() => Eight$inboundSchema), z.lazy(() => Nine$inboundSchema), ]), }); export function generatePreviewResponseDtoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GeneratePreviewResponseDto$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GeneratePreviewResponseDto' from JSON`, ); }