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

import * as z from "zod/v4";
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 {
  AuthenticationConfiguration,
  AuthenticationConfiguration$inboundSchema,
} from "./authenticationconfiguration.js";
import {
  OutboundAuthenticationType,
  OutboundAuthenticationType$inboundSchema,
} from "./outboundauthenticationtype.js";

export type CredentialsResponse = {
  credentials: Array<AuthenticationConfiguration>;
  connectorPresetCredentialsForAuth?:
    | Array<OutboundAuthenticationType>
    | undefined;
};

/** @internal */
export const CredentialsResponse$inboundSchema: z.ZodType<
  CredentialsResponse,
  unknown
> = z.object({
  credentials: z.array(AuthenticationConfiguration$inboundSchema),
  connector_preset_credentials_for_auth: z.array(
    OutboundAuthenticationType$inboundSchema,
  ).optional(),
}).transform((v) => {
  return remap$(v, {
    "connector_preset_credentials_for_auth":
      "connectorPresetCredentialsForAuth",
  });
});

export function credentialsResponseFromJSON(
  jsonString: string,
): SafeParseResult<CredentialsResponse, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CredentialsResponse$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CredentialsResponse' from JSON`,
  );
}
