/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Unify event source */ export const EventSource = { Native: "native", Virtual: "virtual", } as const; /** * Unify event source */ export type EventSource = ClosedEnum; /** * Unify event that is supported on the connector. Events are delivered via Webhooks. */ export type ConnectorEvent = { /** * Unify event type */ eventType?: string | undefined; /** * Unify event source */ eventSource?: EventSource | undefined; /** * Downstream event type */ downstreamEventType?: string | undefined; resources?: Array | undefined; /** * Unify entity type */ entityType?: string | undefined; }; /** @internal */ export const EventSource$inboundSchema: z.ZodNativeEnum = z .nativeEnum(EventSource); /** @internal */ export const EventSource$outboundSchema: z.ZodNativeEnum = EventSource$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace EventSource$ { /** @deprecated use `EventSource$inboundSchema` instead. */ export const inboundSchema = EventSource$inboundSchema; /** @deprecated use `EventSource$outboundSchema` instead. */ export const outboundSchema = EventSource$outboundSchema; } /** @internal */ export const ConnectorEvent$inboundSchema: z.ZodType< ConnectorEvent, z.ZodTypeDef, unknown > = z.object({ event_type: z.string().optional(), event_source: EventSource$inboundSchema.optional(), downstream_event_type: z.string().optional(), resources: z.array(z.string()).optional(), entity_type: z.string().optional(), }).transform((v) => { return remap$(v, { "event_type": "eventType", "event_source": "eventSource", "downstream_event_type": "downstreamEventType", "entity_type": "entityType", }); }); /** @internal */ export type ConnectorEvent$Outbound = { event_type?: string | undefined; event_source?: string | undefined; downstream_event_type?: string | undefined; resources?: Array | undefined; entity_type?: string | undefined; }; /** @internal */ export const ConnectorEvent$outboundSchema: z.ZodType< ConnectorEvent$Outbound, z.ZodTypeDef, ConnectorEvent > = z.object({ eventType: z.string().optional(), eventSource: EventSource$outboundSchema.optional(), downstreamEventType: z.string().optional(), resources: z.array(z.string()).optional(), entityType: z.string().optional(), }).transform((v) => { return remap$(v, { eventType: "event_type", eventSource: "event_source", downstreamEventType: "downstream_event_type", entityType: "entity_type", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ConnectorEvent$ { /** @deprecated use `ConnectorEvent$inboundSchema` instead. */ export const inboundSchema = ConnectorEvent$inboundSchema; /** @deprecated use `ConnectorEvent$outboundSchema` instead. */ export const outboundSchema = ConnectorEvent$outboundSchema; /** @deprecated use `ConnectorEvent$Outbound` instead. */ export type Outbound = ConnectorEvent$Outbound; } export function connectorEventToJSON(connectorEvent: ConnectorEvent): string { return JSON.stringify(ConnectorEvent$outboundSchema.parse(connectorEvent)); } export function connectorEventFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ConnectorEvent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ConnectorEvent' from JSON`, ); }