/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; 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 { SortDirection, SortDirection$inboundSchema, SortDirection$outboundSchema, } from "./sortdirection.js"; /** * The field on which to sort the Purchase Orders */ export const PurchaseOrdersSortBy = { UpdatedAt: "updated_at", CreatedAt: "created_at", } as const; /** * The field on which to sort the Purchase Orders */ export type PurchaseOrdersSortBy = ClosedEnum; export type PurchaseOrdersSort = { /** * The field on which to sort the Purchase Orders */ by?: PurchaseOrdersSortBy | undefined; /** * The direction in which to sort the results */ direction?: SortDirection | undefined; }; /** @internal */ export const PurchaseOrdersSortBy$inboundSchema: z.ZodNativeEnum< typeof PurchaseOrdersSortBy > = z.nativeEnum(PurchaseOrdersSortBy); /** @internal */ export const PurchaseOrdersSortBy$outboundSchema: z.ZodNativeEnum< typeof PurchaseOrdersSortBy > = PurchaseOrdersSortBy$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace PurchaseOrdersSortBy$ { /** @deprecated use `PurchaseOrdersSortBy$inboundSchema` instead. */ export const inboundSchema = PurchaseOrdersSortBy$inboundSchema; /** @deprecated use `PurchaseOrdersSortBy$outboundSchema` instead. */ export const outboundSchema = PurchaseOrdersSortBy$outboundSchema; } /** @internal */ export const PurchaseOrdersSort$inboundSchema: z.ZodType< PurchaseOrdersSort, z.ZodTypeDef, unknown > = z.object({ by: PurchaseOrdersSortBy$inboundSchema.optional(), direction: SortDirection$inboundSchema.default("asc"), }); /** @internal */ export type PurchaseOrdersSort$Outbound = { by?: string | undefined; direction: string; }; /** @internal */ export const PurchaseOrdersSort$outboundSchema: z.ZodType< PurchaseOrdersSort$Outbound, z.ZodTypeDef, PurchaseOrdersSort > = z.object({ by: PurchaseOrdersSortBy$outboundSchema.optional(), direction: SortDirection$outboundSchema.default("asc"), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace PurchaseOrdersSort$ { /** @deprecated use `PurchaseOrdersSort$inboundSchema` instead. */ export const inboundSchema = PurchaseOrdersSort$inboundSchema; /** @deprecated use `PurchaseOrdersSort$outboundSchema` instead. */ export const outboundSchema = PurchaseOrdersSort$outboundSchema; /** @deprecated use `PurchaseOrdersSort$Outbound` instead. */ export type Outbound = PurchaseOrdersSort$Outbound; } export function purchaseOrdersSortToJSON( purchaseOrdersSort: PurchaseOrdersSort, ): string { return JSON.stringify( PurchaseOrdersSort$outboundSchema.parse(purchaseOrdersSort), ); } export function purchaseOrdersSortFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PurchaseOrdersSort$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PurchaseOrdersSort' from JSON`, ); }