/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AuthType, AuthType$inboundSchema, AuthType$outboundSchema, } from "./authtype.js"; import { ConnectionState, ConnectionState$inboundSchema, ConnectionState$outboundSchema, } from "./connectionstate.js"; /** * Connection settings. Values will persist to `form_fields` with corresponding id */ export type Settings = {}; 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?: Settings | null | undefined; /** * Attach your own consumer specific metadata */ metadata?: { [k: string]: any } | null | undefined; createdAt?: string | undefined; updatedAt?: string | null | undefined; /** * [Connection state flow](#section/Connection-state) */ state?: ConnectionState | undefined; }; /** @internal */ export const Settings$inboundSchema: z.ZodType< Settings, z.ZodTypeDef, unknown > = z.object({}); /** @internal */ export type Settings$Outbound = {}; /** @internal */ export const Settings$outboundSchema: z.ZodType< Settings$Outbound, z.ZodTypeDef, Settings > = z.object({}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Settings$ { /** @deprecated use `Settings$inboundSchema` instead. */ export const inboundSchema = Settings$inboundSchema; /** @deprecated use `Settings$outboundSchema` instead. */ export const outboundSchema = Settings$outboundSchema; /** @deprecated use `Settings$Outbound` instead. */ export type Outbound = Settings$Outbound; } export function settingsToJSON(settings: Settings): string { return JSON.stringify(Settings$outboundSchema.parse(settings)); } export function settingsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Settings$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Settings' from JSON`, ); } /** @internal */ export const ConsumerConnection$inboundSchema: z.ZodType< ConsumerConnection, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), name: z.string().optional(), icon: z.string().optional(), logo: z.string().optional(), website: z.string().optional(), tag_line: z.string().optional(), service_id: z.string().optional(), unified_api: z.string().optional(), consumer_id: z.string().optional(), auth_type: AuthType$inboundSchema.optional(), enabled: z.boolean().optional(), settings: z.nullable(z.lazy(() => Settings$inboundSchema)).optional(), metadata: z.nullable(z.record(z.any())).optional(), created_at: z.string().optional(), updated_at: z.nullable(z.string()).optional(), state: ConnectionState$inboundSchema.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", }); }); /** @internal */ export type ConsumerConnection$Outbound = { id?: string | undefined; name?: string | undefined; icon?: string | undefined; logo?: string | undefined; website?: string | undefined; tag_line?: string | undefined; service_id?: string | undefined; unified_api?: string | undefined; consumer_id?: string | undefined; auth_type?: string | undefined; enabled?: boolean | undefined; settings?: Settings$Outbound | null | undefined; metadata?: { [k: string]: any } | null | undefined; created_at?: string | undefined; updated_at?: string | null | undefined; state?: string | undefined; }; /** @internal */ export const ConsumerConnection$outboundSchema: z.ZodType< ConsumerConnection$Outbound, z.ZodTypeDef, ConsumerConnection > = z.object({ id: z.string().optional(), name: z.string().optional(), icon: z.string().optional(), logo: z.string().optional(), website: z.string().optional(), tagLine: z.string().optional(), serviceId: z.string().optional(), unifiedApi: z.string().optional(), consumerId: z.string().optional(), authType: AuthType$outboundSchema.optional(), enabled: z.boolean().optional(), settings: z.nullable(z.lazy(() => Settings$outboundSchema)).optional(), metadata: z.nullable(z.record(z.any())).optional(), createdAt: z.string().optional(), updatedAt: z.nullable(z.string()).optional(), state: ConnectionState$outboundSchema.optional(), }).transform((v) => { return remap$(v, { tagLine: "tag_line", serviceId: "service_id", unifiedApi: "unified_api", consumerId: "consumer_id", authType: "auth_type", createdAt: "created_at", updatedAt: "updated_at", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ConsumerConnection$ { /** @deprecated use `ConsumerConnection$inboundSchema` instead. */ export const inboundSchema = ConsumerConnection$inboundSchema; /** @deprecated use `ConsumerConnection$outboundSchema` instead. */ export const outboundSchema = ConsumerConnection$outboundSchema; /** @deprecated use `ConsumerConnection$Outbound` instead. */ export type Outbound = ConsumerConnection$Outbound; } export function consumerConnectionToJSON( consumerConnection: ConsumerConnection, ): string { return JSON.stringify( ConsumerConnection$outboundSchema.parse(consumerConnection), ); } export function consumerConnectionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ConsumerConnection$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ConsumerConnection' from JSON`, ); }