/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Cursors to navigate to previous or next pages through the API */ export type Cursors = { /** * Cursor to navigate to the previous page of results through the API */ previous?: string | null | undefined; /** * Cursor to navigate to the current page of results through the API */ current?: string | null | undefined; /** * Cursor to navigate to the next page of results through the API */ next?: string | null | undefined; }; /** * Advisory warning emitted when an optional workflow step fails non-fatally. The overall request still succeeds (HTTP 200); inspect this to detect partial or degraded data. */ export type Warnings = { /** * Discriminator for the warning kind. */ type?: string | undefined; /** * HTTP status code returned by the failed downstream request, when available. */ statusCode?: number | null | undefined; /** * Short error description from the downstream provider, when available. */ error?: string | null | undefined; /** * Identifier of the workflow step that failed. */ operation?: string | null | undefined; /** * Detailed message from the downstream provider, when available. */ message?: string | null | undefined; }; /** * Response metadata */ export type Meta = { /** * Number of items returned in the data property of the response */ itemsOnPage?: number | undefined; /** * Cursors to navigate to previous or next pages through the API */ cursors?: Cursors | undefined; /** * Number of records available in total for this resource */ totalCount?: number | undefined; /** * Non-fatal warnings emitted when optional workflow steps failed. Present only when at least one step degraded; the response status remains 200. */ warnings?: Array | null | undefined; }; /** @internal */ export const Cursors$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ previous: z.nullable(types.string()).optional(), current: z.nullable(types.string()).optional(), next: z.nullable(types.string()).optional(), }) ); export function cursorsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Cursors$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Cursors' from JSON`, ); } /** @internal */ export const Warnings$inboundSchema: z.ZodType< Warnings, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ type: types.optional(types.string()), status_code: z.nullable(types.number()).optional(), error: z.nullable(types.string()).optional(), operation: z.nullable(types.string()).optional(), message: z.nullable(types.string()).optional(), }).transform((v) => { return remap$(v, { "status_code": "statusCode", }); }) ); export function warningsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Warnings$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Warnings' from JSON`, ); } /** @internal */ export const Meta$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ items_on_page: types.optional(types.number()), cursors: types.optional(z.lazy(() => Cursors$inboundSchema)), total_count: types.optional(types.number()), warnings: z.nullable(z.array(z.lazy(() => Warnings$inboundSchema))) .optional(), }).transform((v) => { return remap$(v, { "items_on_page": "itemsOnPage", "total_count": "totalCount", }); }) ); export function metaFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Meta$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Meta' from JSON`, ); }