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

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";

export type Connector = {
  id: string;
  name: string;
  description: string;
  createdAt: Date;
  modifiedAt: Date;
  server?: string | null | undefined;
  authType?: string | null | undefined;
};

/** @internal */
export const Connector$inboundSchema: z.ZodType<Connector, unknown> = z.object({
  id: z.string(),
  name: z.string(),
  description: z.string(),
  created_at: z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  modified_at: z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  server: z.nullable(z.string()).optional(),
  auth_type: z.nullable(z.string()).optional(),
}).transform((v) => {
  return remap$(v, {
    "created_at": "createdAt",
    "modified_at": "modifiedAt",
    "auth_type": "authType",
  });
});

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