/* * 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$ } from "../../lib/schemas.js"; export type Credentials = { /** * The refresh token can be used to obtain a new access token. */ refreshToken?: string | null | undefined; /** * Access token */ accessToken?: string | undefined; /** * The datetime at which the token was issued. If omitted the token will be queued for refresh. */ issuedAt?: Date | null | undefined; /** * The number of seconds until the token expires. If omitted the token will be queued for refresh. */ expiresIn?: number | null | undefined; }; export type ConnectionImportData = { credentials?: Credentials | 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?: { [k: string]: any } | null | undefined; }; /** @internal */ export type Credentials$Outbound = { refresh_token?: string | null | undefined; access_token?: string | undefined; issued_at?: string | null | undefined; expires_in?: number | null | undefined; }; /** @internal */ export const Credentials$outboundSchema: z.ZodType< Credentials$Outbound, z.ZodTypeDef, Credentials > = /* @__PURE__ */ lazySchema$(() => z.object({ refreshToken: z.nullable(z.string()).optional(), accessToken: z.string().optional(), issuedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), expiresIn: z.nullable(z.number().int()).optional(), }).transform((v) => { return remap$(v, { refreshToken: "refresh_token", accessToken: "access_token", issuedAt: "issued_at", expiresIn: "expires_in", }); }) ); export function credentialsToJSON(credentials: Credentials): string { return JSON.stringify(Credentials$outboundSchema.parse(credentials)); } /** @internal */ export type ConnectionImportData$Outbound = { credentials?: Credentials$Outbound | undefined; settings?: { [k: string]: any } | null | undefined; metadata?: { [k: string]: any } | null | undefined; }; /** @internal */ export const ConnectionImportData$outboundSchema: z.ZodType< ConnectionImportData$Outbound, z.ZodTypeDef, ConnectionImportData > = /* @__PURE__ */ lazySchema$(() => z.object({ credentials: z.lazy(() => Credentials$outboundSchema).optional(), settings: z.nullable(z.record(z.any())).optional(), metadata: z.nullable(z.record(z.any())).optional(), }) ); export function connectionImportDataToJSON( connectionImportData: ConnectionImportData, ): string { return JSON.stringify( ConnectionImportData$outboundSchema.parse(connectionImportData), ); }