/* * 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 { HookdeckCredentials, HookdeckCredentials$inboundSchema, HookdeckCredentials$Outbound, HookdeckCredentials$outboundSchema, } from "./hookdeckcredentials.js"; import { Topics, Topics$inboundSchema, Topics$Outbound, Topics$outboundSchema, } from "./topics.js"; export type DestinationCreateHookdeck = { /** * Optional user-provided ID. A UUID will be generated if empty. */ id?: string | undefined; /** * Type of the destination. Must be 'hookdeck'. */ type: "hookdeck"; /** * "*" 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?: any | undefined; credentials: HookdeckCredentials; /** * 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 DestinationCreateHookdeck$inboundSchema: z.ZodType< DestinationCreateHookdeck, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), type: z.literal("hookdeck"), topics: Topics$inboundSchema, filter: z.nullable(z.record(z.any())).optional(), config: z.any().optional(), credentials: HookdeckCredentials$inboundSchema, 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 DestinationCreateHookdeck$Outbound = { id?: string | undefined; type: "hookdeck"; topics: Topics$Outbound; filter?: { [k: string]: any } | null | undefined; config?: any | undefined; credentials: HookdeckCredentials$Outbound; delivery_metadata?: { [k: string]: string } | null | undefined; metadata?: { [k: string]: string } | null | undefined; }; /** @internal */ export const DestinationCreateHookdeck$outboundSchema: z.ZodType< DestinationCreateHookdeck$Outbound, z.ZodTypeDef, DestinationCreateHookdeck > = z.object({ id: z.string().optional(), type: z.literal("hookdeck"), topics: Topics$outboundSchema, filter: z.nullable(z.record(z.any())).optional(), config: z.any().optional(), credentials: HookdeckCredentials$outboundSchema, 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 destinationCreateHookdeckToJSON( destinationCreateHookdeck: DestinationCreateHookdeck, ): string { return JSON.stringify( DestinationCreateHookdeck$outboundSchema.parse(destinationCreateHookdeck), ); } export function destinationCreateHookdeckFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DestinationCreateHookdeck$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DestinationCreateHookdeck' from JSON`, ); }