/* * 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 { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ConnectedRepository, ConnectedRepository$inboundSchema, ConnectedRepository$Outbound, ConnectedRepository$outboundSchema, } from "./connectedrepository.js"; export type Connection = { githubLogin: string; githubUserId: number; scopes: string; syncedAt: Date; repositories: Array; }; /** @internal */ export const Connection$inboundSchema: z.ZodType< Connection, z.ZodTypeDef, unknown > = z.object({ github_login: z.string(), github_user_id: z.number().int(), scopes: z.string(), synced_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), repositories: z.array(ConnectedRepository$inboundSchema), }).transform((v) => { return remap$(v, { "github_login": "githubLogin", "github_user_id": "githubUserId", "synced_at": "syncedAt", }); }); /** @internal */ export type Connection$Outbound = { github_login: string; github_user_id: number; scopes: string; synced_at: string; repositories: Array; }; /** @internal */ export const Connection$outboundSchema: z.ZodType< Connection$Outbound, z.ZodTypeDef, Connection > = z.object({ githubLogin: z.string(), githubUserId: z.number().int(), scopes: z.string(), syncedAt: z.date().transform(v => v.toISOString()), repositories: z.array(ConnectedRepository$outboundSchema), }).transform((v) => { return remap$(v, { githubLogin: "github_login", githubUserId: "github_user_id", syncedAt: "synced_at", }); }); export function connectionToJSON(connection: Connection): string { return JSON.stringify(Connection$outboundSchema.parse(connection)); } export function connectionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Connection$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Connection' from JSON`, ); }