/* * 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"; /** * The connector's overall batch capability: `none` when no resource supports a batch write, otherwise the mode most of its resources use. This is a summary — read `resources` for the answer that applies to the resource you are calling, because a connector can be `native` for one resource and `loop` for another. */ export const BatchSupportMode = { None: "none", Native: "native", Loop: "loop", } as const; /** * The connector's overall batch capability: `none` when no resource supports a batch write, otherwise the mode most of its resources use. This is a summary — read `resources` for the answer that applies to the resource you are calling, because a connector can be `native` for one resource and `loop` for another. */ export type BatchSupportMode = OpenEnum; /** * `none` means this resource refuses batch writes. `native` satisfies a batch in a single downstream call against the provider's own batch endpoint, so the request counts as one request against your plan. `loop` satisfies it as a bounded sequential fan-out, one downstream call per item — so a request of N records takes roughly N times as long and counts as N requests. */ export const BatchSupportResourcesMode = { None: "none", Native: "native", Loop: "loop", } as const; /** * `none` means this resource refuses batch writes. `native` satisfies a batch in a single downstream call against the provider's own batch endpoint, so the request counts as one request against your plan. `loop` satisfies it as a bounded sequential fan-out, one downstream call per item — so a request of N records takes roughly N times as long and counts as N requests. */ export type BatchSupportResourcesMode = OpenEnum< typeof BatchSupportResourcesMode >; export type Resources = { /** * `none` means this resource refuses batch writes. `native` satisfies a batch in a single downstream call against the provider's own batch endpoint, so the request counts as one request against your plan. `loop` satisfies it as a bounded sequential fan-out, one downstream call per item — so a request of N records takes roughly N times as long and counts as N requests. */ mode: BatchSupportResourcesMode; /** * The maximum number of items this resource accepts in one request. A request carrying more is rejected before any record is written. Resources on the same connector can differ: a resource that writes records one at a time is usually capped lower than one that writes them in a single call. Absent when the connector has not declared one, in which case the platform default applies. */ maxItems?: number | undefined; }; /** * How this connector satisfies a batch write, per resource. Read this before calling a batch endpoint: support, execution mode and the per-request limit all vary by resource on the same connector, and the mode determines both latency and how many requests the call counts against your plan. */ export type BatchSupport = { /** * The connector's overall batch capability: `none` when no resource supports a batch write, otherwise the mode most of its resources use. This is a summary — read `resources` for the answer that applies to the resource you are calling, because a connector can be `native` for one resource and `loop` for another. */ mode: BatchSupportMode; /** * Batch support for each resource that has a batch endpoint, keyed by the batch resource name (for example `invoices-batch`). A resource absent from this map, or reporting `none`, will refuse a batch request with a 501. */ resources?: { [k: string]: Resources } | undefined; }; /** @internal */ export const BatchSupportMode$inboundSchema: z.ZodType< BatchSupportMode, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(BatchSupportMode) ); /** @internal */ export const BatchSupportResourcesMode$inboundSchema: z.ZodType< BatchSupportResourcesMode, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(BatchSupportResourcesMode) ); /** @internal */ export const Resources$inboundSchema: z.ZodType< Resources, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ mode: BatchSupportResourcesMode$inboundSchema, max_items: types.optional(types.number()), }).transform((v) => { return remap$(v, { "max_items": "maxItems", }); }) ); export function resourcesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Resources$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Resources' from JSON`, ); } /** @internal */ export const BatchSupport$inboundSchema: z.ZodType< BatchSupport, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ mode: BatchSupportMode$inboundSchema, resources: types.optional(z.record(z.lazy(() => Resources$inboundSchema))), }) ); export function batchSupportFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BatchSupport$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchSupport' from JSON`, ); }