/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { smartUnion } from "../../types/smartUnion.js"; import { EventNamesSortProperty, EventNamesSortProperty$outboundSchema, } from "../components/eventnamessortproperty.js"; import { EventSource, EventSource$outboundSchema, } from "../components/eventsource.js"; import { ListResourceEventName, ListResourceEventName$inboundSchema, } from "../components/listresourceeventname.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Filter by organization ID. */ export type EventsListNamesQueryParamOrganizationIDFilter = | string | Array; /** * Filter by customer ID. */ export type EventsListNamesQueryParamCustomerIDFilter = string | Array; /** * Filter by external customer ID. */ export type EventsListNamesQueryParamExternalCustomerIDFilter = | string | Array; /** * Filter by event source. */ export type QueryParamSourceFilter = EventSource | Array; export type EventsListNamesRequest = { /** * Filter by organization ID. */ organizationId?: string | Array | null | undefined; /** * Filter by customer ID. */ customerId?: string | Array | null | undefined; /** * Filter by external customer ID. */ externalCustomerId?: string | Array | null | undefined; /** * Filter by event source. */ source?: EventSource | Array | null | undefined; /** * Query to filter event names. */ query?: string | null | undefined; /** * Page number, defaults to 1. */ page?: number | undefined; /** * Size of a page, defaults to 10. Maximum is 100. */ limit?: number | undefined; /** * Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign `-` before the criteria name to sort by descending order. */ sorting?: Array | null | undefined; }; export type EventsListNamesResponse = { result: ListResourceEventName; }; /** @internal */ export type EventsListNamesQueryParamOrganizationIDFilter$Outbound = | string | Array; /** @internal */ export const EventsListNamesQueryParamOrganizationIDFilter$outboundSchema: z.ZodMiniType< EventsListNamesQueryParamOrganizationIDFilter$Outbound, EventsListNamesQueryParamOrganizationIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function eventsListNamesQueryParamOrganizationIDFilterToJSON( eventsListNamesQueryParamOrganizationIDFilter: EventsListNamesQueryParamOrganizationIDFilter, ): string { return JSON.stringify( EventsListNamesQueryParamOrganizationIDFilter$outboundSchema.parse( eventsListNamesQueryParamOrganizationIDFilter, ), ); } /** @internal */ export type EventsListNamesQueryParamCustomerIDFilter$Outbound = | string | Array; /** @internal */ export const EventsListNamesQueryParamCustomerIDFilter$outboundSchema: z.ZodMiniType< EventsListNamesQueryParamCustomerIDFilter$Outbound, EventsListNamesQueryParamCustomerIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function eventsListNamesQueryParamCustomerIDFilterToJSON( eventsListNamesQueryParamCustomerIDFilter: EventsListNamesQueryParamCustomerIDFilter, ): string { return JSON.stringify( EventsListNamesQueryParamCustomerIDFilter$outboundSchema.parse( eventsListNamesQueryParamCustomerIDFilter, ), ); } /** @internal */ export type EventsListNamesQueryParamExternalCustomerIDFilter$Outbound = | string | Array; /** @internal */ export const EventsListNamesQueryParamExternalCustomerIDFilter$outboundSchema: z.ZodMiniType< EventsListNamesQueryParamExternalCustomerIDFilter$Outbound, EventsListNamesQueryParamExternalCustomerIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function eventsListNamesQueryParamExternalCustomerIDFilterToJSON( eventsListNamesQueryParamExternalCustomerIDFilter: EventsListNamesQueryParamExternalCustomerIDFilter, ): string { return JSON.stringify( EventsListNamesQueryParamExternalCustomerIDFilter$outboundSchema.parse( eventsListNamesQueryParamExternalCustomerIDFilter, ), ); } /** @internal */ export type QueryParamSourceFilter$Outbound = string | Array; /** @internal */ export const QueryParamSourceFilter$outboundSchema: z.ZodMiniType< QueryParamSourceFilter$Outbound, QueryParamSourceFilter > = smartUnion([ EventSource$outboundSchema, z.array(EventSource$outboundSchema), ]); export function queryParamSourceFilterToJSON( queryParamSourceFilter: QueryParamSourceFilter, ): string { return JSON.stringify( QueryParamSourceFilter$outboundSchema.parse(queryParamSourceFilter), ); } /** @internal */ export type EventsListNamesRequest$Outbound = { organization_id?: string | Array | null | undefined; customer_id?: string | Array | null | undefined; external_customer_id?: string | Array | null | undefined; source?: string | Array | null | undefined; query?: string | null | undefined; page: number; limit: number; sorting?: Array | null | undefined; }; /** @internal */ export const EventsListNamesRequest$outboundSchema: z.ZodMiniType< EventsListNamesRequest$Outbound, EventsListNamesRequest > = z.pipe( z.object({ organizationId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), customerId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), externalCustomerId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), source: z.optional( z.nullable( smartUnion([ EventSource$outboundSchema, z.array(EventSource$outboundSchema), ]), ), ), query: z.optional(z.nullable(z.string())), page: z._default(z.int(), 1), limit: z._default(z.int(), 10), sorting: z.optional( z.nullable(z.array(EventNamesSortProperty$outboundSchema)), ), }), z.transform((v) => { return remap$(v, { organizationId: "organization_id", customerId: "customer_id", externalCustomerId: "external_customer_id", }); }), ); export function eventsListNamesRequestToJSON( eventsListNamesRequest: EventsListNamesRequest, ): string { return JSON.stringify( EventsListNamesRequest$outboundSchema.parse(eventsListNamesRequest), ); } /** @internal */ export const EventsListNamesResponse$inboundSchema: z.ZodMiniType< EventsListNamesResponse, unknown > = z.pipe( z.object({ Result: ListResourceEventName$inboundSchema, }), z.transform((v) => { return remap$(v, { "Result": "result", }); }), ); export function eventsListNamesResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EventsListNamesResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EventsListNamesResponse' from JSON`, ); }