/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { BulkReportCompany, BulkReportCompany$inboundSchema, } from "./bulkreportcompany.js"; /** * Overall batch status. `pending`/`processing` while in progress; once finished, `success` (all reports succeeded), `partial_success` (some succeeded, some failed), or `failed` (none succeeded). */ export const BulkReportStatus = { Pending: "pending", Processing: "processing", Success: "success", PartialSuccess: "partial_success", Failed: "failed", } as const; /** * Overall batch status. `pending`/`processing` while in progress; once finished, `success` (all reports succeeded), `partial_success` (some succeeded, some failed), or `failed` (none succeeded). */ export type BulkReportStatus = ClosedEnum; export type BulkReport = { /** * Unique identifier of the bulk report batch. */ uuid: string; /** * Overall batch status. `pending`/`processing` while in progress; once finished, `success` (all reports succeeded), `partial_success` (some succeeded, some failed), or `failed` (none succeeded). */ status: BulkReportStatus; /** * When the batch was accepted. */ submittedAt: Date; /** * When the batch reached a terminal state. Null while non-terminal. */ completedAt: Date | null; /** * How many reports the partner asked for in this batch. */ submittedItems: number; /** * UUID of the partner that owns this batch. Returned only once the batch has finished; omitted while in progress. */ partnerUuid?: string | undefined; /** * How many reports succeeded. Returned only once the batch has finished; omitted while in progress. */ processedItems?: number | undefined; /** * Signed S3 URL to a zip containing every successfully-generated report, valid for 10 minutes. Returned only once the batch has finished; omitted while in progress. */ reportUrl?: string | null | undefined; /** * Per-company breakdown. Returned only once the batch has finished; omitted while in progress. */ companies?: Array | undefined; }; /** @internal */ export const BulkReportStatus$inboundSchema: z.ZodNativeEnum< typeof BulkReportStatus > = z.nativeEnum(BulkReportStatus); /** @internal */ export const BulkReport$inboundSchema: z.ZodType< BulkReport, z.ZodTypeDef, unknown > = z.object({ uuid: z.string(), status: BulkReportStatus$inboundSchema, submitted_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ), completed_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), submitted_items: z.number().int(), partner_uuid: z.string().optional(), processed_items: z.number().int().optional(), report_url: z.nullable(z.string()).optional(), companies: z.array(BulkReportCompany$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "submitted_at": "submittedAt", "completed_at": "completedAt", "submitted_items": "submittedItems", "partner_uuid": "partnerUuid", "processed_items": "processedItems", "report_url": "reportUrl", }); }); export function bulkReportFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BulkReport$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BulkReport' from JSON`, ); }