/* * 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"; /** * The current status of the batch processing. */ export const PeopleBatchResultsStatus = { Pending: "pending", Processing: "processing", Completed: "completed", Failed: "failed", PartialSuccess: "partial_success", } as const; /** * The current status of the batch processing. */ export type PeopleBatchResultsStatus = ClosedEnum< typeof PeopleBatchResultsStatus >; /** * The type of person created. */ export const Role = { Employee: "employee", } as const; /** * The type of person created. */ export type Role = ClosedEnum; /** * The status of this batch item. */ export const PeopleBatchResultsResultsStatus = { Success: "success", PartialSuccess: "partial_success", Failed: "failed", } as const; /** * The status of this batch item. */ export type PeopleBatchResultsResultsStatus = ClosedEnum< typeof PeopleBatchResultsResultsStatus >; export type PeopleBatchResultsResultsErrors = {}; export type PeopleBatchResultsErrors = { /** * The key identifying the error source. */ errorKey?: string | undefined; /** * The error category. */ category?: string | undefined; /** * Human-readable error message. */ message?: string | null | undefined; /** * Nested errors for sub-operations. */ errors?: Array | null | undefined; }; export type Results = { /** * The external ID provided in the batch request. */ externalId?: string | undefined; /** * The type of person created. */ role?: Role | undefined; /** * The status of this batch item. */ status?: PeopleBatchResultsResultsStatus | undefined; /** * The index of this item in the original batch request. */ idx?: number | undefined; /** * The UUID of the created person. */ uuid?: string | undefined; /** * The UUID of the created employee (if role is employee). */ employeeUuid?: string | undefined; /** * Errors encountered while processing this batch item. */ errors?: Array | null | undefined; }; export type Exclusions = { /** * The external ID of the excluded item(s). */ externalId?: string | undefined; /** * The exclusion category. */ category?: string | undefined; /** * Human-readable explanation for exclusion. */ message?: string | undefined; /** * Number of items affected by this exclusion. */ itemCount?: number | undefined; }; /** * A people batch with processing results. */ export type PeopleBatchResults = { /** * The unique identifier of the people batch. */ uuid: string; /** * The idempotency key provided when creating the batch. */ idempotencyKey: string; /** * The current status of the batch processing. */ status: PeopleBatchResultsStatus; /** * The timestamp when the batch was submitted. */ submittedAt?: Date | undefined; /** * The timestamp when the batch processing completed. */ completedAt?: Date | null | undefined; /** * The number of items submitted in the batch. */ submittedItems?: number | null | undefined; /** * The number of items successfully processed. */ processedItems?: number | undefined; /** * The number of items excluded from processing. */ excludedItems?: number | undefined; /** * The results for each batch item. */ results?: Array | undefined; /** * Items excluded from processing due to validation errors. */ exclusions?: Array | null | undefined; }; /** @internal */ export const PeopleBatchResultsStatus$inboundSchema: z.ZodNativeEnum< typeof PeopleBatchResultsStatus > = z.nativeEnum(PeopleBatchResultsStatus); /** @internal */ export const Role$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Role, ); /** @internal */ export const PeopleBatchResultsResultsStatus$inboundSchema: z.ZodNativeEnum< typeof PeopleBatchResultsResultsStatus > = z.nativeEnum(PeopleBatchResultsResultsStatus); /** @internal */ export const PeopleBatchResultsResultsErrors$inboundSchema: z.ZodType< PeopleBatchResultsResultsErrors, z.ZodTypeDef, unknown > = z.object({}); export function peopleBatchResultsResultsErrorsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PeopleBatchResultsResultsErrors$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PeopleBatchResultsResultsErrors' from JSON`, ); } /** @internal */ export const PeopleBatchResultsErrors$inboundSchema: z.ZodType< PeopleBatchResultsErrors, z.ZodTypeDef, unknown > = z.object({ error_key: z.string().optional(), category: z.string().optional(), message: z.nullable(z.string()).optional(), errors: z.nullable( z.array(z.lazy(() => PeopleBatchResultsResultsErrors$inboundSchema)), ).optional(), }).transform((v) => { return remap$(v, { "error_key": "errorKey", }); }); export function peopleBatchResultsErrorsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PeopleBatchResultsErrors$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PeopleBatchResultsErrors' from JSON`, ); } /** @internal */ export const Results$inboundSchema: z.ZodType = z.object({ external_id: z.string().optional(), role: Role$inboundSchema.optional(), status: PeopleBatchResultsResultsStatus$inboundSchema.optional(), idx: z.number().int().optional(), uuid: z.string().optional(), employee_uuid: z.string().optional(), errors: z.nullable( z.array(z.lazy(() => PeopleBatchResultsErrors$inboundSchema)), ).optional(), }).transform((v) => { return remap$(v, { "external_id": "externalId", "employee_uuid": "employeeUuid", }); }); export function resultsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Results$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Results' from JSON`, ); } /** @internal */ export const Exclusions$inboundSchema: z.ZodType< Exclusions, z.ZodTypeDef, unknown > = z.object({ external_id: z.string().optional(), category: z.string().optional(), message: z.string().optional(), item_count: z.number().int().optional(), }).transform((v) => { return remap$(v, { "external_id": "externalId", "item_count": "itemCount", }); }); export function exclusionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Exclusions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Exclusions' from JSON`, ); } /** @internal */ export const PeopleBatchResults$inboundSchema: z.ZodType< PeopleBatchResults, z.ZodTypeDef, unknown > = z.object({ uuid: z.string(), idempotency_key: z.string(), status: PeopleBatchResultsStatus$inboundSchema, submitted_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ).optional(), completed_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), submitted_items: z.nullable(z.number().int()).optional(), processed_items: z.number().int().optional(), excluded_items: z.number().int().optional(), results: z.array(z.lazy(() => Results$inboundSchema)).optional(), exclusions: z.nullable(z.array(z.lazy(() => Exclusions$inboundSchema))) .optional(), }).transform((v) => { return remap$(v, { "idempotency_key": "idempotencyKey", "submitted_at": "submittedAt", "completed_at": "completedAt", "submitted_items": "submittedItems", "processed_items": "processedItems", "excluded_items": "excludedItems", }); }); export function peopleBatchResultsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PeopleBatchResults$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PeopleBatchResults' from JSON`, ); }