/* * 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"; import { ApiStatus, ApiStatus$inboundSchema } from "./apistatus.js"; import { ResourceStatus, ResourceStatus$inboundSchema, } from "./resourcestatus.js"; /** * Indicates whether the API is a Unified API. If unified_api is false, the API is a Platform API. */ export const ApiType = { Platform: "platform", Unified: "unified", } as const; /** * Indicates whether the API is a Unified API. If unified_api is false, the API is a Platform API. */ export type ApiType = OpenEnum; export type ApiResources = { /** * ID of the resource, typically a lowercased version of its name. */ id?: string | undefined; /** * Name of the resource (plural) */ name?: string | undefined; /** * Status of the resource. Resources with status live or beta are callable. */ status?: ResourceStatus | undefined; /** * Exclude from mapping coverage */ excludedFromCoverage?: boolean | undefined; }; export type Api = { /** * ID of the API. */ id?: string | undefined; /** * Indicates whether the API is a Unified API. If unified_api is false, the API is a Platform API. */ type?: ApiType | undefined; /** * Name of the API. */ name?: string | undefined; /** * Description of the API. */ description?: string | null | undefined; /** * Status of the API. APIs with status live or beta are callable. */ status?: ApiStatus | undefined; /** * Link to the latest OpenAPI specification of the API. */ specUrl?: string | undefined; /** * Link to the API reference of the API. */ apiReferenceUrl?: string | undefined; /** * ID of the Postman collection of the API. */ postmanCollectionId?: string | null | undefined; /** * List of categories the API belongs to. */ categories?: Array | undefined; /** * List of resources supported in this API. */ resources?: Array | undefined; /** * List of event types this API supports. */ events?: Array | undefined; }; /** @internal */ export const ApiType$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(ApiType)); /** @internal */ export const ApiResources$inboundSchema: z.ZodType< ApiResources, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), name: types.optional(types.string()), status: types.optional(ResourceStatus$inboundSchema), excluded_from_coverage: types.optional(types.boolean()), }).transform((v) => { return remap$(v, { "excluded_from_coverage": "excludedFromCoverage", }); }) ); export function apiResourcesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ApiResources$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ApiResources' from JSON`, ); } /** @internal */ export const Api$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), type: types.optional(ApiType$inboundSchema), name: types.optional(types.string()), description: z.nullable(types.string()).optional(), status: types.optional(ApiStatus$inboundSchema), spec_url: types.optional(types.string()), api_reference_url: types.optional(types.string()), postman_collection_id: z.nullable(types.string()).optional(), categories: types.optional(z.array(types.string())), resources: types.optional( z.array(z.lazy(() => ApiResources$inboundSchema)), ), events: types.optional(z.array(types.string())), }).transform((v) => { return remap$(v, { "spec_url": "specUrl", "api_reference_url": "apiReferenceUrl", "postman_collection_id": "postmanCollectionId", }); }) ); export function apiFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Api$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Api' from JSON`, ); }