/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 6c0610cd28ac
 */

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import {
  OAuth2Token,
  OAuth2Token$Outbound,
  OAuth2Token$outboundSchema,
} from "./oauth2token.js";

export type ConnectionCredentials = {
  oauth?: OAuth2Token | null | undefined;
  headers?: { [k: string]: string } | null | undefined;
  bearerToken?: string | null | undefined;
  githubInstallationId?: string | null | undefined;
};

/** @internal */
export type ConnectionCredentials$Outbound = {
  oauth?: OAuth2Token$Outbound | null | undefined;
  headers?: { [k: string]: string } | null | undefined;
  bearer_token?: string | null | undefined;
  github_installation_id?: string | null | undefined;
};

/** @internal */
export const ConnectionCredentials$outboundSchema: z.ZodType<
  ConnectionCredentials$Outbound,
  ConnectionCredentials
> = z.object({
  oauth: z.nullable(OAuth2Token$outboundSchema).optional(),
  headers: z.nullable(z.record(z.string(), z.string())).optional(),
  bearerToken: z.nullable(z.string()).optional(),
  githubInstallationId: z.nullable(z.string()).optional(),
}).transform((v) => {
  return remap$(v, {
    bearerToken: "bearer_token",
    githubInstallationId: "github_installation_id",
  });
});

export function connectionCredentialsToJSON(
  connectionCredentials: ConnectionCredentials,
): string {
  return JSON.stringify(
    ConnectionCredentials$outboundSchema.parse(connectionCredentials),
  );
}
