/* * 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 tenant ID(s). Use bracket notation for multiple values (e.g., `tenant_id[0]=t1&tenant_id[1]=t2`). * * @remarks * When authenticated with a Tenant JWT, this parameter is ignored and the JWT's tenant is used. * If not provided with API key auth, returns attempts from all tenants. */ export type ListAttemptsTenantId = string | Array; /** * Filter attempts by event ID(s). Use bracket notation for multiple values (e.g., `event_id[0]=e1&event_id[1]=e2`). */ export type ListAttemptsEventId = string | Array; /** * Filter attempts by destination ID(s). Use bracket notation for multiple values (e.g., `destination_id[0]=d1&destination_id[1]=d2`). */ export type ListAttemptsDestinationId = string | Array; /** * Filter attempts by status. */ export const ListAttemptsStatus = { Success: "success", Failed: "failed", } as const; /** * Filter attempts by status. */ export type ListAttemptsStatus = ClosedEnum; /** * Filter attempts by event topic(s). Use bracket notation for multiple values (e.g., `topic[0]=user.created&topic[1]=user.updated`). */ export type ListAttemptsTopic = 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 ListAttemptsInclude = string | Array; /** * Field to sort by. */ export const ListAttemptsOrderBy = { Time: "time", } as const; /** * Field to sort by. */ export type ListAttemptsOrderBy = ClosedEnum; /** * Sort direction. */ export const ListAttemptsDir = { Asc: "asc", Desc: "desc", } as const; /** * Sort direction. */ export type ListAttemptsDir = ClosedEnum; export type ListAttemptsRequest = { /** * Filter attempts by tenant ID(s). Use bracket notation for multiple values (e.g., `tenant_id[0]=t1&tenant_id[1]=t2`). * * @remarks * When authenticated with a Tenant JWT, this parameter is ignored and the JWT's tenant is used. * If not provided with API key auth, returns attempts from all tenants. */ tenantId?: string | Array | undefined; /** * 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 destination ID(s). Use bracket notation for multiple values (e.g., `destination_id[0]=d1&destination_id[1]=d2`). */ destinationId?: string | Array | undefined; /** * Filter attempts by status. */ status?: ListAttemptsStatus | 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?: ListAttemptsOrderBy | undefined; /** * Sort direction. */ dir?: ListAttemptsDir | undefined; }; export type ListAttemptsResponse = { result: components.AttemptPaginatedResult; }; /** @internal */ export const ListAttemptsTenantId$inboundSchema: z.ZodType< ListAttemptsTenantId, z.ZodTypeDef, unknown > = z.union([z.string(), z.array(z.string())]); /** @internal */ export type ListAttemptsTenantId$Outbound = string | Array; /** @internal */ export const ListAttemptsTenantId$outboundSchema: z.ZodType< ListAttemptsTenantId$Outbound, z.ZodTypeDef, ListAttemptsTenantId > = z.union([z.string(), z.array(z.string())]); export function listAttemptsTenantIdToJSON( listAttemptsTenantId: ListAttemptsTenantId, ): string { return JSON.stringify( ListAttemptsTenantId$outboundSchema.parse(listAttemptsTenantId), ); } export function listAttemptsTenantIdFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListAttemptsTenantId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListAttemptsTenantId' from JSON`, ); } /** @internal */ export const ListAttemptsEventId$inboundSchema: z.ZodType< ListAttemptsEventId, z.ZodTypeDef, unknown > = z.union([z.string(), z.array(z.string())]); /** @internal */ export type ListAttemptsEventId$Outbound = string | Array; /** @internal */ export const ListAttemptsEventId$outboundSchema: z.ZodType< ListAttemptsEventId$Outbound, z.ZodTypeDef, ListAttemptsEventId > = z.union([z.string(), z.array(z.string())]); export function listAttemptsEventIdToJSON( listAttemptsEventId: ListAttemptsEventId, ): string { return JSON.stringify( ListAttemptsEventId$outboundSchema.parse(listAttemptsEventId), ); } export function listAttemptsEventIdFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListAttemptsEventId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListAttemptsEventId' from JSON`, ); } /** @internal */ export const ListAttemptsDestinationId$inboundSchema: z.ZodType< ListAttemptsDestinationId, z.ZodTypeDef, unknown > = z.union([z.string(), z.array(z.string())]); /** @internal */ export type ListAttemptsDestinationId$Outbound = string | Array; /** @internal */ export const ListAttemptsDestinationId$outboundSchema: z.ZodType< ListAttemptsDestinationId$Outbound, z.ZodTypeDef, ListAttemptsDestinationId > = z.union([z.string(), z.array(z.string())]); export function listAttemptsDestinationIdToJSON( listAttemptsDestinationId: ListAttemptsDestinationId, ): string { return JSON.stringify( ListAttemptsDestinationId$outboundSchema.parse(listAttemptsDestinationId), ); } export function listAttemptsDestinationIdFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListAttemptsDestinationId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListAttemptsDestinationId' from JSON`, ); } /** @internal */ export const ListAttemptsStatus$inboundSchema: z.ZodNativeEnum< typeof ListAttemptsStatus > = z.nativeEnum(ListAttemptsStatus); /** @internal */ export const ListAttemptsStatus$outboundSchema: z.ZodNativeEnum< typeof ListAttemptsStatus > = ListAttemptsStatus$inboundSchema; /** @internal */ export const ListAttemptsTopic$inboundSchema: z.ZodType< ListAttemptsTopic, z.ZodTypeDef, unknown > = z.union([z.string(), z.array(z.string())]); /** @internal */ export type ListAttemptsTopic$Outbound = string | Array; /** @internal */ export const ListAttemptsTopic$outboundSchema: z.ZodType< ListAttemptsTopic$Outbound, z.ZodTypeDef, ListAttemptsTopic > = z.union([z.string(), z.array(z.string())]); export function listAttemptsTopicToJSON( listAttemptsTopic: ListAttemptsTopic, ): string { return JSON.stringify( ListAttemptsTopic$outboundSchema.parse(listAttemptsTopic), ); } export function listAttemptsTopicFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListAttemptsTopic$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListAttemptsTopic' from JSON`, ); } /** @internal */ export const ListAttemptsInclude$inboundSchema: z.ZodType< ListAttemptsInclude, z.ZodTypeDef, unknown > = z.union([z.string(), z.array(z.string())]); /** @internal */ export type ListAttemptsInclude$Outbound = string | Array; /** @internal */ export const ListAttemptsInclude$outboundSchema: z.ZodType< ListAttemptsInclude$Outbound, z.ZodTypeDef, ListAttemptsInclude > = z.union([z.string(), z.array(z.string())]); export function listAttemptsIncludeToJSON( listAttemptsInclude: ListAttemptsInclude, ): string { return JSON.stringify( ListAttemptsInclude$outboundSchema.parse(listAttemptsInclude), ); } export function listAttemptsIncludeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListAttemptsInclude$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListAttemptsInclude' from JSON`, ); } /** @internal */ export const ListAttemptsOrderBy$inboundSchema: z.ZodNativeEnum< typeof ListAttemptsOrderBy > = z.nativeEnum(ListAttemptsOrderBy); /** @internal */ export const ListAttemptsOrderBy$outboundSchema: z.ZodNativeEnum< typeof ListAttemptsOrderBy > = ListAttemptsOrderBy$inboundSchema; /** @internal */ export const ListAttemptsDir$inboundSchema: z.ZodNativeEnum< typeof ListAttemptsDir > = z.nativeEnum(ListAttemptsDir); /** @internal */ export const ListAttemptsDir$outboundSchema: z.ZodNativeEnum< typeof ListAttemptsDir > = ListAttemptsDir$inboundSchema; /** @internal */ export const ListAttemptsRequest$inboundSchema: z.ZodType< ListAttemptsRequest, z.ZodTypeDef, unknown > = z.object({ tenant_id: z.union([z.string(), z.array(z.string())]).optional(), event_id: z.union([z.string(), z.array(z.string())]).optional(), destination_id: z.union([z.string(), z.array(z.string())]).optional(), status: ListAttemptsStatus$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: ListAttemptsOrderBy$inboundSchema.default("time"), dir: ListAttemptsDir$inboundSchema.default("desc"), }).transform((v) => { return remap$(v, { "tenant_id": "tenantId", "event_id": "eventId", "destination_id": "destinationId", "time[gte]": "timeGte", "time[lte]": "timeLte", "time[gt]": "timeGt", "time[lt]": "timeLt", "order_by": "orderBy", }); }); /** @internal */ export type ListAttemptsRequest$Outbound = { tenant_id?: string | Array | undefined; event_id?: string | Array | undefined; destination_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 ListAttemptsRequest$outboundSchema: z.ZodType< ListAttemptsRequest$Outbound, z.ZodTypeDef, ListAttemptsRequest > = z.object({ tenantId: z.union([z.string(), z.array(z.string())]).optional(), eventId: z.union([z.string(), z.array(z.string())]).optional(), destinationId: z.union([z.string(), z.array(z.string())]).optional(), status: ListAttemptsStatus$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: ListAttemptsOrderBy$outboundSchema.default("time"), dir: ListAttemptsDir$outboundSchema.default("desc"), }).transform((v) => { return remap$(v, { tenantId: "tenant_id", eventId: "event_id", destinationId: "destination_id", timeGte: "time[gte]", timeLte: "time[lte]", timeGt: "time[gt]", timeLt: "time[lt]", orderBy: "order_by", }); }); export function listAttemptsRequestToJSON( listAttemptsRequest: ListAttemptsRequest, ): string { return JSON.stringify( ListAttemptsRequest$outboundSchema.parse(listAttemptsRequest), ); } export function listAttemptsRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListAttemptsRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListAttemptsRequest' from JSON`, ); } /** @internal */ export const ListAttemptsResponse$inboundSchema: z.ZodType< ListAttemptsResponse, z.ZodTypeDef, unknown > = z.object({ Result: components.AttemptPaginatedResult$inboundSchema, }).transform((v) => { return remap$(v, { "Result": "result", }); }); /** @internal */ export type ListAttemptsResponse$Outbound = { Result: components.AttemptPaginatedResult$Outbound; }; /** @internal */ export const ListAttemptsResponse$outboundSchema: z.ZodType< ListAttemptsResponse$Outbound, z.ZodTypeDef, ListAttemptsResponse > = z.object({ result: components.AttemptPaginatedResult$outboundSchema, }).transform((v) => { return remap$(v, { result: "Result", }); }); export function listAttemptsResponseToJSON( listAttemptsResponse: ListAttemptsResponse, ): string { return JSON.stringify( ListAttemptsResponse$outboundSchema.parse(listAttemptsResponse), ); } export function listAttemptsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListAttemptsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListAttemptsResponse' from JSON`, ); }