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

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 {
  BaseTaskStatus,
  BaseTaskStatus$inboundSchema,
} from "./basetaskstatus.js";

export type DatasetImportTask = {
  id: string;
  createdAt: Date;
  updatedAt: Date;
  deletedAt: Date | null;
  creatorId: string;
  datasetId: string;
  workspaceId: string;
  status: BaseTaskStatus;
  progress?: number | null | undefined;
  message?: string | null | undefined;
};

/** @internal */
export const DatasetImportTask$inboundSchema: z.ZodType<
  DatasetImportTask,
  unknown
> = z.object({
  id: z.string(),
  created_at: z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  updated_at: z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  deleted_at: z.nullable(
    z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  ),
  creator_id: z.string(),
  dataset_id: z.string(),
  workspace_id: z.string(),
  status: BaseTaskStatus$inboundSchema,
  progress: z.nullable(z.int()).optional(),
  message: z.nullable(z.string()).optional(),
}).transform((v) => {
  return remap$(v, {
    "created_at": "createdAt",
    "updated_at": "updatedAt",
    "deleted_at": "deletedAt",
    "creator_id": "creatorId",
    "dataset_id": "datasetId",
    "workspace_id": "workspaceId",
  });
});

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