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