/* * 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 { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Filter attempts by event ID(s). Use bracket notation for multiple values (e.g., `event_id[0]=e1&event_id[1]=e2`). */ export type ListTenantDestinationAttemptsEventId = string | Array; /** * Filter attempts by status. */ export const ListTenantDestinationAttemptsStatus = { Success: "success", Failed: "failed", } as const; /** * Filter attempts by status. */ export type ListTenantDestinationAttemptsStatus = ClosedEnum< typeof ListTenantDestinationAttemptsStatus >; /** * Filter attempts by event topic(s). Use bracket notation for multiple values (e.g., `topic[0]=user.created&topic[1]=user.updated`). */ export type ListTenantDestinationAttemptsTopic = string | Array; /** * Fields to include in the response. Use bracket notation for multiple values (e.g., `include[0]=event&include[1]=response_data`). * * @remarks * - `event`: Include event summary (id, topic, time, eligible_for_retry, metadata) * - `event.data`: Include full event with payload data * - `response_data`: Include response body and headers * - `destination`: Include the full destination object */ export type ListTenantDestinationAttemptsInclude = string | Array; /** * Field to sort by. */ export const ListTenantDestinationAttemptsOrderBy = { Time: "time", } as const; /** * Field to sort by. */ export type ListTenantDestinationAttemptsOrderBy = ClosedEnum< typeof ListTenantDestinationAttemptsOrderBy >; /** * Sort direction. */ export const ListTenantDestinationAttemptsDir = { Asc: "asc", Desc: "desc", } as const; /** * Sort direction. */ export type ListTenantDestinationAttemptsDir = ClosedEnum< typeof ListTenantDestinationAttemptsDir >; export type ListTenantDestinationAttemptsRequest = { /** * The ID of the tenant. Required when using AdminApiKey authentication. */ tenantId: string; /** * The ID of the destination. */ destinationId: string; /** * Filter attempts by event ID(s). Use bracket notation for multiple values (e.g., `event_id[0]=e1&event_id[1]=e2`). */ eventId?: string | Array | undefined; /** * Filter attempts by status. */ status?: ListTenantDestinationAttemptsStatus | undefined; /** * Filter attempts by event topic(s). Use bracket notation for multiple values (e.g., `topic[0]=user.created&topic[1]=user.updated`). */ topic?: string | Array | undefined; /** * Filter attempts by event time >= value (RFC3339 or YYYY-MM-DD format). */ timeGte?: Date | undefined; /** * Filter attempts by event time <= value (RFC3339 or YYYY-MM-DD format). */ timeLte?: Date | undefined; /** * Filter attempts by event time > value (RFC3339 or YYYY-MM-DD format). */ timeGt?: Date | undefined; /** * Filter attempts by event time < value (RFC3339 or YYYY-MM-DD format). */ timeLt?: Date | undefined; /** * Number of items per page (default 100, max 1000). */ limit?: number | undefined; /** * Cursor for next page of results. */ next?: string | undefined; /** * Cursor for previous page of results. */ prev?: string | undefined; /** * Fields to include in the response. Use bracket notation for multiple values (e.g., `include[0]=event&include[1]=response_data`). * * @remarks * - `event`: Include event summary (id, topic, time, eligible_for_retry, metadata) * - `event.data`: Include full event with payload data * - `response_data`: Include response body and headers * - `destination`: Include the full destination object */ include?: string | Array | undefined; /** * Field to sort by. */ orderBy?: ListTenantDestinationAttemptsOrderBy | undefined; /** * Sort direction. */ dir?: ListTenantDestinationAttemptsDir | undefined; }; export type ListTenantDestinationAttemptsResponse = { result: components.AttemptPaginatedResult; }; /** @internal */ export const ListTenantDestinationAttemptsEventId$inboundSchema: z.ZodType< ListTenantDestinationAttemptsEventId, z.ZodTypeDef, unknown > = z.union([z.string(), z.array(z.string())]); /** @internal */ export type ListTenantDestinationAttemptsEventId$Outbound = | string | Array; /** @internal */ export const ListTenantDestinationAttemptsEventId$outboundSchema: z.ZodType< ListTenantDestinationAttemptsEventId$Outbound, z.ZodTypeDef, ListTenantDestinationAttemptsEventId > = z.union([z.string(), z.array(z.string())]); export function listTenantDestinationAttemptsEventIdToJSON( listTenantDestinationAttemptsEventId: ListTenantDestinationAttemptsEventId, ): string { return JSON.stringify( ListTenantDestinationAttemptsEventId$outboundSchema.parse( listTenantDestinationAttemptsEventId, ), ); } export function listTenantDestinationAttemptsEventIdFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListTenantDestinationAttemptsEventId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListTenantDestinationAttemptsEventId' from JSON`, ); } /** @internal */ export const ListTenantDestinationAttemptsStatus$inboundSchema: z.ZodNativeEnum< typeof ListTenantDestinationAttemptsStatus > = z.nativeEnum(ListTenantDestinationAttemptsStatus); /** @internal */ export const ListTenantDestinationAttemptsStatus$outboundSchema: z.ZodNativeEnum = ListTenantDestinationAttemptsStatus$inboundSchema; /** @internal */ export const ListTenantDestinationAttemptsTopic$inboundSchema: z.ZodType< ListTenantDestinationAttemptsTopic, z.ZodTypeDef, unknown > = z.union([z.string(), z.array(z.string())]); /** @internal */ export type ListTenantDestinationAttemptsTopic$Outbound = | string | Array; /** @internal */ export const ListTenantDestinationAttemptsTopic$outboundSchema: z.ZodType< ListTenantDestinationAttemptsTopic$Outbound, z.ZodTypeDef, ListTenantDestinationAttemptsTopic > = z.union([z.string(), z.array(z.string())]); export function listTenantDestinationAttemptsTopicToJSON( listTenantDestinationAttemptsTopic: ListTenantDestinationAttemptsTopic, ): string { return JSON.stringify( ListTenantDestinationAttemptsTopic$outboundSchema.parse( listTenantDestinationAttemptsTopic, ), ); } export function listTenantDestinationAttemptsTopicFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListTenantDestinationAttemptsTopic$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListTenantDestinationAttemptsTopic' from JSON`, ); } /** @internal */ export const ListTenantDestinationAttemptsInclude$inboundSchema: z.ZodType< ListTenantDestinationAttemptsInclude, z.ZodTypeDef, unknown > = z.union([z.string(), z.array(z.string())]); /** @internal */ export type ListTenantDestinationAttemptsInclude$Outbound = | string | Array; /** @internal */ export const ListTenantDestinationAttemptsInclude$outboundSchema: z.ZodType< ListTenantDestinationAttemptsInclude$Outbound, z.ZodTypeDef, ListTenantDestinationAttemptsInclude > = z.union([z.string(), z.array(z.string())]); export function listTenantDestinationAttemptsIncludeToJSON( listTenantDestinationAttemptsInclude: ListTenantDestinationAttemptsInclude, ): string { return JSON.stringify( ListTenantDestinationAttemptsInclude$outboundSchema.parse( listTenantDestinationAttemptsInclude, ), ); } export function listTenantDestinationAttemptsIncludeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListTenantDestinationAttemptsInclude$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListTenantDestinationAttemptsInclude' from JSON`, ); } /** @internal */ export const ListTenantDestinationAttemptsOrderBy$inboundSchema: z.ZodNativeEnum = z.nativeEnum( ListTenantDestinationAttemptsOrderBy, ); /** @internal */ export const ListTenantDestinationAttemptsOrderBy$outboundSchema: z.ZodNativeEnum = ListTenantDestinationAttemptsOrderBy$inboundSchema; /** @internal */ export const ListTenantDestinationAttemptsDir$inboundSchema: z.ZodNativeEnum< typeof ListTenantDestinationAttemptsDir > = z.nativeEnum(ListTenantDestinationAttemptsDir); /** @internal */ export const ListTenantDestinationAttemptsDir$outboundSchema: z.ZodNativeEnum< typeof ListTenantDestinationAttemptsDir > = ListTenantDestinationAttemptsDir$inboundSchema; /** @internal */ export const ListTenantDestinationAttemptsRequest$inboundSchema: z.ZodType< ListTenantDestinationAttemptsRequest, z.ZodTypeDef, unknown > = z.object({ tenant_id: z.string(), destination_id: z.string(), event_id: z.union([z.string(), z.array(z.string())]).optional(), status: ListTenantDestinationAttemptsStatus$inboundSchema.optional(), topic: z.union([z.string(), z.array(z.string())]).optional(), "time[gte]": z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), "time[lte]": z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), "time[gt]": z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), "time[lt]": z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), limit: z.number().int().default(100), next: z.string().optional(), prev: z.string().optional(), include: z.union([z.string(), z.array(z.string())]).optional(), order_by: ListTenantDestinationAttemptsOrderBy$inboundSchema.default("time"), dir: ListTenantDestinationAttemptsDir$inboundSchema.default("desc"), }).transform((v) => { return remap$(v, { "tenant_id": "tenantId", "destination_id": "destinationId", "event_id": "eventId", "time[gte]": "timeGte", "time[lte]": "timeLte", "time[gt]": "timeGt", "time[lt]": "timeLt", "order_by": "orderBy", }); }); /** @internal */ export type ListTenantDestinationAttemptsRequest$Outbound = { tenant_id: string; destination_id: string; event_id?: string | Array | undefined; status?: string | undefined; topic?: string | Array | undefined; "time[gte]"?: string | undefined; "time[lte]"?: string | undefined; "time[gt]"?: string | undefined; "time[lt]"?: string | undefined; limit: number; next?: string | undefined; prev?: string | undefined; include?: string | Array | undefined; order_by: string; dir: string; }; /** @internal */ export const ListTenantDestinationAttemptsRequest$outboundSchema: z.ZodType< ListTenantDestinationAttemptsRequest$Outbound, z.ZodTypeDef, ListTenantDestinationAttemptsRequest > = z.object({ tenantId: z.string(), destinationId: z.string(), eventId: z.union([z.string(), z.array(z.string())]).optional(), status: ListTenantDestinationAttemptsStatus$outboundSchema.optional(), topic: z.union([z.string(), z.array(z.string())]).optional(), timeGte: z.date().transform(v => v.toISOString()).optional(), timeLte: z.date().transform(v => v.toISOString()).optional(), timeGt: z.date().transform(v => v.toISOString()).optional(), timeLt: z.date().transform(v => v.toISOString()).optional(), limit: z.number().int().default(100), next: z.string().optional(), prev: z.string().optional(), include: z.union([z.string(), z.array(z.string())]).optional(), orderBy: ListTenantDestinationAttemptsOrderBy$outboundSchema.default("time"), dir: ListTenantDestinationAttemptsDir$outboundSchema.default("desc"), }).transform((v) => { return remap$(v, { tenantId: "tenant_id", destinationId: "destination_id", eventId: "event_id", timeGte: "time[gte]", timeLte: "time[lte]", timeGt: "time[gt]", timeLt: "time[lt]", orderBy: "order_by", }); }); export function listTenantDestinationAttemptsRequestToJSON( listTenantDestinationAttemptsRequest: ListTenantDestinationAttemptsRequest, ): string { return JSON.stringify( ListTenantDestinationAttemptsRequest$outboundSchema.parse( listTenantDestinationAttemptsRequest, ), ); } export function listTenantDestinationAttemptsRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListTenantDestinationAttemptsRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListTenantDestinationAttemptsRequest' from JSON`, ); } /** @internal */ export const ListTenantDestinationAttemptsResponse$inboundSchema: z.ZodType< ListTenantDestinationAttemptsResponse, z.ZodTypeDef, unknown > = z.object({ Result: components.AttemptPaginatedResult$inboundSchema, }).transform((v) => { return remap$(v, { "Result": "result", }); }); /** @internal */ export type ListTenantDestinationAttemptsResponse$Outbound = { Result: components.AttemptPaginatedResult$Outbound; }; /** @internal */ export const ListTenantDestinationAttemptsResponse$outboundSchema: z.ZodType< ListTenantDestinationAttemptsResponse$Outbound, z.ZodTypeDef, ListTenantDestinationAttemptsResponse > = z.object({ result: components.AttemptPaginatedResult$outboundSchema, }).transform((v) => { return remap$(v, { result: "Result", }); }); export function listTenantDestinationAttemptsResponseToJSON( listTenantDestinationAttemptsResponse: ListTenantDestinationAttemptsResponse, ): string { return JSON.stringify( ListTenantDestinationAttemptsResponse$outboundSchema.parse( listTenantDestinationAttemptsResponse, ), ); } export function listTenantDestinationAttemptsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListTenantDestinationAttemptsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListTenantDestinationAttemptsResponse' from JSON`, ); }