/* * 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 { collectExtraKeys as collectExtraKeys$, 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"; import { AuthType, AuthType$inboundSchema } from "./authtype.js"; import { ConnectionHealth, ConnectionHealth$inboundSchema, } from "./connectionhealth.js"; import { ConnectionState, ConnectionState$inboundSchema, } from "./connectionstate.js"; /** * Attach your own consumer specific metadata */ export type Metadata = { /** * Normalized identifier of the authorized organization, copied from the connector-specific setting (e.g. Xero tenant_id, QuickBooks realm_id, NetSuite account_id). */ companyId?: string | undefined; additionalProperties?: { [k: string]: any } | undefined; }; export type ConsumerConnection = { id?: string | undefined; name?: string | undefined; icon?: string | undefined; logo?: string | undefined; website?: string | undefined; tagLine?: string | undefined; serviceId?: string | undefined; unifiedApi?: string | undefined; consumerId?: string | undefined; /** * Type of authorization used by the connector */ authType?: AuthType | undefined; enabled?: boolean | undefined; /** * Connection settings. Values will persist to `form_fields` with corresponding id */ settings?: { [k: string]: any } | null | undefined; /** * Attach your own consumer specific metadata */ metadata?: Metadata | null | undefined; createdAt?: string | undefined; updatedAt?: string | null | undefined; /** * [Connection state flow](#section/Connection-state) */ state?: ConnectionState | undefined; /** * The operational health status of the connection */ health?: ConnectionHealth | undefined; /** * ISO 8601 timestamp indicating when credentials will be cleared if token refresh continues to fail. Only present when connection health is pending_refresh and a retention window is active. */ credentialsExpireAt?: string | null | undefined; /** * ISO 8601 timestamp of the most recent token refresh failure. Only present when connection has experienced refresh failures. */ lastRefreshFailedAt?: string | null | undefined; }; /** @internal */ export const Metadata$inboundSchema: z.ZodType< Metadata, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => collectExtraKeys$( z.object({ company_id: types.optional(types.string()), }).catchall(z.any()), "additionalProperties", true, ).transform((v) => { return remap$(v, { "company_id": "companyId", }); }) ); export function metadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Metadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Metadata' from JSON`, ); } /** @internal */ export const ConsumerConnection$inboundSchema: z.ZodType< ConsumerConnection, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), name: types.optional(types.string()), icon: types.optional(types.string()), logo: types.optional(types.string()), website: types.optional(types.string()), tag_line: types.optional(types.string()), service_id: types.optional(types.string()), unified_api: types.optional(types.string()), consumer_id: types.optional(types.string()), auth_type: types.optional(AuthType$inboundSchema), enabled: types.optional(types.boolean()), settings: z.nullable(z.record(z.any())).optional(), metadata: z.nullable(z.lazy(() => Metadata$inboundSchema)).optional(), created_at: types.optional(types.string()), updated_at: z.nullable(types.string()).optional(), state: types.optional(ConnectionState$inboundSchema), health: types.optional(ConnectionHealth$inboundSchema), credentials_expire_at: z.nullable(types.string()).optional(), last_refresh_failed_at: z.nullable(types.string()).optional(), }).transform((v) => { return remap$(v, { "tag_line": "tagLine", "service_id": "serviceId", "unified_api": "unifiedApi", "consumer_id": "consumerId", "auth_type": "authType", "created_at": "createdAt", "updated_at": "updatedAt", "credentials_expire_at": "credentialsExpireAt", "last_refresh_failed_at": "lastRefreshFailedAt", }); }) ); export function consumerConnectionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ConsumerConnection$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ConsumerConnection' from JSON`, ); }