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

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 IngestionPipelineConfiguration = {
  id: string;
  authorId: string;
  name: string;
  createdAt: Date;
  modifiedAt: Date;
  lastRunTime: Date | null;
  lastRunChunksCount: number;
  totalChunksCount: number;
  pipelineComposition: { [k: string]: string } | null;
};

/** @internal */
export const IngestionPipelineConfiguration$inboundSchema: z.ZodType<
  IngestionPipelineConfiguration,
  unknown
> = z.object({
  id: z.string(),
  author_id: z.string(),
  name: 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)),
  last_run_time: z.nullable(
    z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  ),
  last_run_chunks_count: z.int(),
  total_chunks_count: z.int(),
  pipeline_composition: z.nullable(z.record(z.string(), z.string())),
}).transform((v) => {
  return remap$(v, {
    "author_id": "authorId",
    "created_at": "createdAt",
    "modified_at": "modifiedAt",
    "last_run_time": "lastRunTime",
    "last_run_chunks_count": "lastRunChunksCount",
    "total_chunks_count": "totalChunksCount",
    "pipeline_composition": "pipelineComposition",
  });
});

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