/* * 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"; export type PublishRequest = { /** * Optional. A unique identifier for the event. If not provided, a UUID will be generated. */ id?: string | undefined; /** * The ID of the tenant to publish for. */ tenantId?: string | undefined; /** * Optional. Route event to a specific destination. */ destinationId?: string | undefined; /** * Topic name for the event. Required if Outpost has been configured with topics. */ topic?: string | undefined; /** * Should event delivery be retried on failure. */ eligibleForRetry?: boolean | undefined; /** * Optional. Custom timestamp for the event. If not provided, defaults to the current time. */ time?: Date | undefined; /** * Any key-value string pairs for metadata. */ metadata?: { [k: string]: string } | undefined; /** * Any JSON payload for the event data. */ data: { [k: string]: any }; }; /** @internal */ export const PublishRequest$inboundSchema: z.ZodType< PublishRequest, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), tenant_id: z.string().optional(), destination_id: z.string().optional(), topic: z.string().optional(), eligible_for_retry: z.boolean().optional(), time: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), metadata: z.record(z.string()).optional(), data: z.record(z.any()), }).transform((v) => { return remap$(v, { "tenant_id": "tenantId", "destination_id": "destinationId", "eligible_for_retry": "eligibleForRetry", }); }); /** @internal */ export type PublishRequest$Outbound = { id?: string | undefined; tenant_id?: string | undefined; destination_id?: string | undefined; topic?: string | undefined; eligible_for_retry?: boolean | undefined; time?: string | undefined; metadata?: { [k: string]: string } | undefined; data: { [k: string]: any }; }; /** @internal */ export const PublishRequest$outboundSchema: z.ZodType< PublishRequest$Outbound, z.ZodTypeDef, PublishRequest > = z.object({ id: z.string().optional(), tenantId: z.string().optional(), destinationId: z.string().optional(), topic: z.string().optional(), eligibleForRetry: z.boolean().optional(), time: z.date().transform(v => v.toISOString()).optional(), metadata: z.record(z.string()).optional(), data: z.record(z.any()), }).transform((v) => { return remap$(v, { tenantId: "tenant_id", destinationId: "destination_id", eligibleForRetry: "eligible_for_retry", }); }); export function publishRequestToJSON(publishRequest: PublishRequest): string { return JSON.stringify(PublishRequest$outboundSchema.parse(publishRequest)); } export function publishRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PublishRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PublishRequest' from JSON`, ); }