/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Topics, Topics$inboundSchema, Topics$Outbound, Topics$outboundSchema, } from "./topics.js"; import { WebhookConfig, WebhookConfig$inboundSchema, WebhookConfig$Outbound, WebhookConfig$outboundSchema, } from "./webhookconfig.js"; import { WebhookCredentials, WebhookCredentials$inboundSchema, WebhookCredentials$Outbound, WebhookCredentials$outboundSchema, } from "./webhookcredentials.js"; export type DestinationCreateWebhook = { /** * Optional user-provided ID. A UUID will be generated if empty. */ id?: string | undefined; /** * Type of the destination. Must be 'webhook'. */ type: "webhook"; /** * "*" or an array of enabled topics. */ topics: Topics; /** * Optional JSON schema filter for event matching. Events must match this filter to be delivered to this destination. * * @remarks * Supports operators: $eq, $neq, $gt, $gte, $lt, $lte, $in, $nin, $startsWith, $endsWith, $exist, $or, $and, $not. * If null or empty, all events matching the topic filter will be delivered. * To remove an existing filter when updating a destination, set filter to an empty object `{}`. */ filter?: { [k: string]: any } | null | undefined; config: WebhookConfig; credentials?: WebhookCredentials | undefined; /** * Static key-value pairs merged into event metadata on every attempt. */ deliveryMetadata?: { [k: string]: string } | null | undefined; /** * Arbitrary contextual information stored with the destination. */ metadata?: { [k: string]: string } | null | undefined; }; /** @internal */ export const DestinationCreateWebhook$inboundSchema: z.ZodType< DestinationCreateWebhook, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), type: z.literal("webhook"), topics: Topics$inboundSchema, filter: z.nullable(z.record(z.any())).optional(), config: WebhookConfig$inboundSchema, credentials: WebhookCredentials$inboundSchema.optional(), delivery_metadata: z.nullable(z.record(z.string())).optional(), metadata: z.nullable(z.record(z.string())).optional(), }).transform((v) => { return remap$(v, { "delivery_metadata": "deliveryMetadata", }); }); /** @internal */ export type DestinationCreateWebhook$Outbound = { id?: string | undefined; type: "webhook"; topics: Topics$Outbound; filter?: { [k: string]: any } | null | undefined; config: WebhookConfig$Outbound; credentials?: WebhookCredentials$Outbound | undefined; delivery_metadata?: { [k: string]: string } | null | undefined; metadata?: { [k: string]: string } | null | undefined; }; /** @internal */ export const DestinationCreateWebhook$outboundSchema: z.ZodType< DestinationCreateWebhook$Outbound, z.ZodTypeDef, DestinationCreateWebhook > = z.object({ id: z.string().optional(), type: z.literal("webhook"), topics: Topics$outboundSchema, filter: z.nullable(z.record(z.any())).optional(), config: WebhookConfig$outboundSchema, credentials: WebhookCredentials$outboundSchema.optional(), deliveryMetadata: z.nullable(z.record(z.string())).optional(), metadata: z.nullable(z.record(z.string())).optional(), }).transform((v) => { return remap$(v, { deliveryMetadata: "delivery_metadata", }); }); export function destinationCreateWebhookToJSON( destinationCreateWebhook: DestinationCreateWebhook, ): string { return JSON.stringify( DestinationCreateWebhook$outboundSchema.parse(destinationCreateWebhook), ); } export function destinationCreateWebhookFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DestinationCreateWebhook$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DestinationCreateWebhook' from JSON`, ); }