/* * 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 { RFCDate } from "../../types/rfcdate.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The lifecycle status of the batch request itself. Terminal values are `completed` (processing finished — inspect `results` and `exclusions` for per-company outcomes) and `failed` (request failed; can be retried). This is distinct from the per-company `status` returned inside `results[]` and `exclusions[]`. */ export const PayrollDigestResultsStatus = { Pending: "pending", Processing: "processing", Completed: "completed", Failed: "failed", } as const; /** * The lifecycle status of the batch request itself. Terminal values are `completed` (processing finished — inspect `results` and `exclusions` for per-company outcomes) and `failed` (request failed; can be retried). This is distinct from the per-company `status` returned inside `results[]` and `exclusions[]`. */ export type PayrollDigestResultsStatus = ClosedEnum< typeof PayrollDigestResultsStatus >; /** * The type of entity this result represents. */ export const PayrollDigestResultsEntityType = { Company: "company", } as const; /** * The type of entity this result represents. */ export type PayrollDigestResultsEntityType = ClosedEnum< typeof PayrollDigestResultsEntityType >; /** * The status of this company's digest computation. */ export const PayrollDigestResultsResultsStatus = { Success: "success", PartialSuccess: "partial_success", Failed: "failed", } as const; /** * The status of this company's digest computation. */ export type PayrollDigestResultsResultsStatus = ClosedEnum< typeof PayrollDigestResultsResultsStatus >; export type Blockers = { /** * A machine-readable blocker key (e.g. `missing_bank_account`). */ type?: string | undefined; /** * Human-readable description of the blocker. */ description?: string | undefined; }; export type PayrollDigestResultsPayPeriod = { /** * First day of the pay period. */ startDate?: RFCDate | null | undefined; /** * Last day of the pay period. */ endDate?: RFCDate | null | undefined; /** * The date employees get paid. */ checkDate?: RFCDate | null | undefined; /** * The deadline to run payroll for this pay period. */ runPayrollBy?: RFCDate | null | undefined; }; export type PaySchedule = { /** * UUID of the pay schedule. */ uuid?: string | undefined; /** * Human-friendly pay frequency (e.g. "Every other week"). */ frequency?: string | undefined; /** * Custom name for the pay schedule, when set. */ customName?: string | null | undefined; }; /** * Pay totals. `null` when the payroll has not been calculated, or when the calculation is stale (the partner edited hours/earnings after the last calculation). */ export type PayrollDigestResultsTotals = { /** * Total amount debited from the company bank account (string-formatted decimal). */ totalDebitAmount?: string | undefined; /** * Total net pay across all employees on this payroll (string-formatted decimal). */ netPay?: string | undefined; /** * Total employer cost including taxes and benefits (string-formatted decimal). */ totalEmployerCost?: string | undefined; }; export type Payrolls = { /** * UUID of the payroll. `null` for upcoming pay periods that have not been started yet (the `payrolls` API has not yet created a payroll record). Once a payroll is created, subsequent digest requests will include the real `payroll_uuid`. */ payrollUuid?: string | null | undefined; /** * The type of payroll (e.g. `regular`, `new_hire`, `termination`, `transition`, `bonus`, `correction`). */ payrollType?: string | undefined; /** * Partner-facing display title for this payroll (e.g. "Run biweekly payroll"). */ displayTitle?: string | undefined; /** * Whether the company has auto-payroll enabled for this pay schedule. */ autoPayroll?: boolean | undefined; /** * The lifecycle status of the payroll (e.g. `ready_to_start`, `in_progress`, `submitted`, `completed`, `failed`). */ status?: string | undefined; payPeriod?: PayrollDigestResultsPayPeriod | undefined; paySchedule?: PaySchedule | null | undefined; /** * Pay totals. `null` when the payroll has not been calculated, or when the calculation is stale (the partner edited hours/earnings after the last calculation). */ totals?: PayrollDigestResultsTotals | null | undefined; }; export type PayrollDigestResultsResults = { /** * The index of this company in the original POST batch array. */ idx?: number | undefined; /** * The type of entity this result represents. */ entityType?: PayrollDigestResultsEntityType | undefined; /** * The UUID of the company. */ uuid?: string | undefined; /** * The legal/display name of the company. */ name?: string | undefined; /** * The status of this company's digest computation. */ status?: PayrollDigestResultsResultsStatus | undefined; /** * Reasons the company cannot currently run payroll. Applies to every payroll in this company's `payrolls` array — blockers are evaluated at the company level, not per payroll. Empty when there are no blockers. */ blockers?: Array | undefined; /** * Payrolls for this company within the digest date window (7 days past, 30–60 days future). May be empty. */ payrolls?: Array | undefined; }; /** * The type of entity this exclusion represents. */ export const PayrollDigestResultsExclusionsEntityType = { Company: "company", } as const; /** * The type of entity this exclusion represents. */ export type PayrollDigestResultsExclusionsEntityType = ClosedEnum< typeof PayrollDigestResultsExclusionsEntityType >; /** * The status of this company's digest computation. */ export const PayrollDigestResultsExclusionsStatus = { Failed: "failed", } as const; /** * The status of this company's digest computation. */ export type PayrollDigestResultsExclusionsStatus = ClosedEnum< typeof PayrollDigestResultsExclusionsStatus >; /** * Machine-readable category for why the company was excluded. */ export const PayrollDigestResultsCategory = { NotFound: "not_found", CompanyInactive: "company_inactive", Duplicate: "duplicate", InternalError: "internal_error", } as const; /** * Machine-readable category for why the company was excluded. */ export type PayrollDigestResultsCategory = ClosedEnum< typeof PayrollDigestResultsCategory >; export type PayrollDigestResultsExclusions = { /** * The index of this company in the original POST batch array. */ idx?: number | undefined; /** * The type of entity this exclusion represents. */ entityType?: PayrollDigestResultsExclusionsEntityType | undefined; /** * The UUID of the excluded company. */ uuid?: string | undefined; /** * The status of this company's digest computation. */ status?: PayrollDigestResultsExclusionsStatus | undefined; /** * Machine-readable category for why the company was excluded. */ category?: PayrollDigestResultsCategory | undefined; /** * Human-readable explanation for the exclusion. */ message?: string | undefined; }; /** * A payroll digest batch with processing results. */ export type PayrollDigestResults = { /** * The unique identifier of the payroll digest batch. */ uuid: string; /** * The idempotency key provided when creating the batch. */ idempotencyKey: string; /** * The lifecycle status of the batch request itself. Terminal values are `completed` (processing finished — inspect `results` and `exclusions` for per-company outcomes) and `failed` (request failed; can be retried). This is distinct from the per-company `status` returned inside `results[]` and `exclusions[]`. */ status: PayrollDigestResultsStatus; /** * The timestamp when the batch was submitted. */ submittedAt: Date; /** * The timestamp when the batch processing completed. */ completedAt?: Date | null | undefined; /** * The number of companies submitted in the batch. */ submittedItems?: number | null | undefined; /** * The number of companies successfully processed. Only present once the batch reaches a terminal status. */ processedItems?: number | undefined; /** * The number of companies excluded from processing. Only present once the batch reaches a terminal status. */ excludedItems?: number | undefined; /** * Per-company results. Only present once the batch reaches a terminal status. Includes successfully processed companies (with their `payrolls` array, which may be empty when the company has no payrolls in the date window). */ results?: Array | undefined; /** * Companies that could not be processed. Only present once the batch reaches a terminal status. Every UUID submitted in the POST batch appears in exactly one of `results` or `exclusions`. */ exclusions?: Array | undefined; }; /** @internal */ export const PayrollDigestResultsStatus$inboundSchema: z.ZodNativeEnum< typeof PayrollDigestResultsStatus > = z.nativeEnum(PayrollDigestResultsStatus); /** @internal */ export const PayrollDigestResultsEntityType$inboundSchema: z.ZodNativeEnum< typeof PayrollDigestResultsEntityType > = z.nativeEnum(PayrollDigestResultsEntityType); /** @internal */ export const PayrollDigestResultsResultsStatus$inboundSchema: z.ZodNativeEnum< typeof PayrollDigestResultsResultsStatus > = z.nativeEnum(PayrollDigestResultsResultsStatus); /** @internal */ export const Blockers$inboundSchema: z.ZodType< Blockers, z.ZodTypeDef, unknown > = z.object({ type: z.string().optional(), description: z.string().optional(), }); export function blockersFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Blockers$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Blockers' from JSON`, ); } /** @internal */ export const PayrollDigestResultsPayPeriod$inboundSchema: z.ZodType< PayrollDigestResultsPayPeriod, z.ZodTypeDef, unknown > = z.object({ start_date: z.nullable(z.string().transform(v => new RFCDate(v))).optional(), end_date: z.nullable(z.string().transform(v => new RFCDate(v))).optional(), check_date: z.nullable(z.string().transform(v => new RFCDate(v))).optional(), run_payroll_by: z.nullable(z.string().transform(v => new RFCDate(v))) .optional(), }).transform((v) => { return remap$(v, { "start_date": "startDate", "end_date": "endDate", "check_date": "checkDate", "run_payroll_by": "runPayrollBy", }); }); export function payrollDigestResultsPayPeriodFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PayrollDigestResultsPayPeriod$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PayrollDigestResultsPayPeriod' from JSON`, ); } /** @internal */ export const PaySchedule$inboundSchema: z.ZodType< PaySchedule, z.ZodTypeDef, unknown > = z.object({ uuid: z.string().optional(), frequency: z.string().optional(), custom_name: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "custom_name": "customName", }); }); export function payScheduleFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PaySchedule$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PaySchedule' from JSON`, ); } /** @internal */ export const PayrollDigestResultsTotals$inboundSchema: z.ZodType< PayrollDigestResultsTotals, z.ZodTypeDef, unknown > = z.object({ total_debit_amount: z.string().optional(), net_pay: z.string().optional(), total_employer_cost: z.string().optional(), }).transform((v) => { return remap$(v, { "total_debit_amount": "totalDebitAmount", "net_pay": "netPay", "total_employer_cost": "totalEmployerCost", }); }); export function payrollDigestResultsTotalsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PayrollDigestResultsTotals$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PayrollDigestResultsTotals' from JSON`, ); } /** @internal */ export const Payrolls$inboundSchema: z.ZodType< Payrolls, z.ZodTypeDef, unknown > = z.object({ payroll_uuid: z.nullable(z.string()).optional(), payroll_type: z.string().optional(), display_title: z.string().optional(), auto_payroll: z.boolean().optional(), status: z.string().optional(), pay_period: z.lazy(() => PayrollDigestResultsPayPeriod$inboundSchema) .optional(), pay_schedule: z.nullable(z.lazy(() => PaySchedule$inboundSchema)).optional(), totals: z.nullable(z.lazy(() => PayrollDigestResultsTotals$inboundSchema)) .optional(), }).transform((v) => { return remap$(v, { "payroll_uuid": "payrollUuid", "payroll_type": "payrollType", "display_title": "displayTitle", "auto_payroll": "autoPayroll", "pay_period": "payPeriod", "pay_schedule": "paySchedule", }); }); export function payrollsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Payrolls$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Payrolls' from JSON`, ); } /** @internal */ export const PayrollDigestResultsResults$inboundSchema: z.ZodType< PayrollDigestResultsResults, z.ZodTypeDef, unknown > = z.object({ idx: z.number().int().optional(), entity_type: PayrollDigestResultsEntityType$inboundSchema.optional(), uuid: z.string().optional(), name: z.string().optional(), status: PayrollDigestResultsResultsStatus$inboundSchema.optional(), blockers: z.array(z.lazy(() => Blockers$inboundSchema)).optional(), payrolls: z.array(z.lazy(() => Payrolls$inboundSchema)).optional(), }).transform((v) => { return remap$(v, { "entity_type": "entityType", }); }); export function payrollDigestResultsResultsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PayrollDigestResultsResults$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PayrollDigestResultsResults' from JSON`, ); } /** @internal */ export const PayrollDigestResultsExclusionsEntityType$inboundSchema: z.ZodNativeEnum = z .nativeEnum(PayrollDigestResultsExclusionsEntityType); /** @internal */ export const PayrollDigestResultsExclusionsStatus$inboundSchema: z.ZodNativeEnum = z.nativeEnum( PayrollDigestResultsExclusionsStatus, ); /** @internal */ export const PayrollDigestResultsCategory$inboundSchema: z.ZodNativeEnum< typeof PayrollDigestResultsCategory > = z.nativeEnum(PayrollDigestResultsCategory); /** @internal */ export const PayrollDigestResultsExclusions$inboundSchema: z.ZodType< PayrollDigestResultsExclusions, z.ZodTypeDef, unknown > = z.object({ idx: z.number().int().optional(), entity_type: PayrollDigestResultsExclusionsEntityType$inboundSchema .optional(), uuid: z.string().optional(), status: PayrollDigestResultsExclusionsStatus$inboundSchema.optional(), category: PayrollDigestResultsCategory$inboundSchema.optional(), message: z.string().optional(), }).transform((v) => { return remap$(v, { "entity_type": "entityType", }); }); export function payrollDigestResultsExclusionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PayrollDigestResultsExclusions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PayrollDigestResultsExclusions' from JSON`, ); } /** @internal */ export const PayrollDigestResults$inboundSchema: z.ZodType< PayrollDigestResults, z.ZodTypeDef, unknown > = z.object({ uuid: z.string(), idempotency_key: z.string(), status: PayrollDigestResultsStatus$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)), ).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(() => PayrollDigestResultsResults$inboundSchema)) .optional(), exclusions: z.array( z.lazy(() => PayrollDigestResultsExclusions$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 payrollDigestResultsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PayrollDigestResults$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PayrollDigestResults' from JSON`, ); }