/* * 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 { lazySchema as lazySchema$, safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Mode of the webhook support. */ export const Mode = { Native: "native", Virtual: "virtual", None: "none", } as const; /** * Mode of the webhook support. */ export type Mode = OpenEnum; /** * Received events are scoped to connection or across integration. */ export const SubscriptionLevel = { Connection: "connection", Integration: "integration", } as const; /** * Received events are scoped to connection or across integration. */ export type SubscriptionLevel = OpenEnum; /** * How the subscription is managed in the downstream. */ export const ManagedVia = { Manual: "manual", Api: "api", } as const; /** * How the subscription is managed in the downstream. */ export type ManagedVia = OpenEnum; /** * Where the vendor stores the webhook target URL. `app` means one URL per vendor developer app, which customers on Apideck's own credentials cannot configure. `tenant` means each customer's vendor account holds its own URL. */ export const TargetURLScope = { App: "app", Tenant: "tenant", } as const; /** * Where the vendor stores the webhook target URL. `app` means one URL per vendor developer app, which customers on Apideck's own credentials cannot configure. `tenant` means each customer's vendor account holds its own URL. */ export type TargetURLScope = OpenEnum; /** * The window unit for the rate. */ export const Unit = { Second: "second", Minute: "minute", Hour: "hour", Day: "day", } as const; /** * The window unit for the rate. */ export type Unit = OpenEnum; /** * The rate at which requests for resources will be made to downstream. */ export type RequestRate = { /** * The number of requests per window unit. */ rate: number; /** * Size of request window. */ size: number; /** * The window unit for the rate. */ unit: Unit; }; export type WebhookSupportResources = { events?: Array | undefined; }; /** * Virtual webhook config for the connector. */ export type VirtualWebhooks = { /** * The rate at which requests for resources will be made to downstream. */ requestRate: RequestRate; /** * The resources that will be requested from downstream. */ resources?: { [k: string]: WebhookSupportResources } | undefined; }; /** * How webhooks are supported for the connector. Sometimes the connector natively supports webhooks, other times Apideck virtualizes them based on polling. */ export type WebhookSupport = { /** * Mode of the webhook support. */ mode?: Mode | undefined; /** * Received events are scoped to connection or across integration. */ subscriptionLevel?: SubscriptionLevel | undefined; /** * How the subscription is managed in the downstream. */ managedVia?: ManagedVia | undefined; /** * Service IDs of connectors that receive events from this connector's webhook URL when the URL's own connector has no callable connection for the event. Connectors listed here must use the same webhook event mapping. */ sharedWith?: Array | undefined; /** * Where the vendor stores the webhook target URL. `app` means one URL per vendor developer app, which customers on Apideck's own credentials cannot configure. `tenant` means each customer's vendor account holds its own URL. */ targetUrlScope?: TargetURLScope | undefined; /** * Whether Unify accepts webhook URLs scoped to a vendor developer app for this connector, rather than to one Apideck application. Events delivered to such a URL reach every connection that the vendor app authorized. */ vendorAppUrl?: boolean | undefined; /** * Virtual webhook config for the connector. */ virtualWebhooks?: VirtualWebhooks | undefined; }; /** @internal */ export const Mode$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(Mode)); /** @internal */ export const SubscriptionLevel$inboundSchema: z.ZodType< SubscriptionLevel, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(SubscriptionLevel) ); /** @internal */ export const ManagedVia$inboundSchema: z.ZodType< ManagedVia, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(ManagedVia)); /** @internal */ export const TargetURLScope$inboundSchema: z.ZodType< TargetURLScope, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(TargetURLScope)); /** @internal */ export const Unit$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(Unit)); /** @internal */ export const RequestRate$inboundSchema: z.ZodType< RequestRate, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ rate: types.number(), size: types.number(), unit: Unit$inboundSchema, }) ); export function requestRateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RequestRate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RequestRate' from JSON`, ); } /** @internal */ export const WebhookSupportResources$inboundSchema: z.ZodType< WebhookSupportResources, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ events: types.optional(z.array(types.string())), }) ); export function webhookSupportResourcesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookSupportResources$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookSupportResources' from JSON`, ); } /** @internal */ export const VirtualWebhooks$inboundSchema: z.ZodType< VirtualWebhooks, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ request_rate: z.lazy(() => RequestRate$inboundSchema), resources: types.optional( z.record(z.lazy(() => WebhookSupportResources$inboundSchema)), ), }).transform((v) => { return remap$(v, { "request_rate": "requestRate", }); }) ); export function virtualWebhooksFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => VirtualWebhooks$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'VirtualWebhooks' from JSON`, ); } /** @internal */ export const WebhookSupport$inboundSchema: z.ZodType< WebhookSupport, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ mode: types.optional(Mode$inboundSchema), subscription_level: types.optional(SubscriptionLevel$inboundSchema), managed_via: types.optional(ManagedVia$inboundSchema), shared_with: types.optional(z.array(types.string())), target_url_scope: types.optional(TargetURLScope$inboundSchema), vendor_app_url: types.optional(types.boolean()), virtual_webhooks: types.optional( z.lazy(() => VirtualWebhooks$inboundSchema), ), }).transform((v) => { return remap$(v, { "subscription_level": "subscriptionLevel", "managed_via": "managedVia", "shared_with": "sharedWith", "target_url_scope": "targetUrlScope", "vendor_app_url": "vendorAppUrl", "virtual_webhooks": "virtualWebhooks", }); }) ); export function webhookSupportFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookSupport$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookSupport' from JSON`, ); }