/* * 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 Orders */ export const OrdersSortBy = { CreatedAt: "created_at", UpdatedAt: "updated_at", Name: "name", } as const; /** * The field on which to sort the Orders */ export type OrdersSortBy = ClosedEnum; export type OrdersSort = { /** * The field on which to sort the Orders */ by?: OrdersSortBy | undefined; /** * The direction in which to sort the results */ direction?: SortDirection | undefined; }; /** @internal */ export const OrdersSortBy$inboundSchema: z.ZodNativeEnum = z.nativeEnum(OrdersSortBy); /** @internal */ export const OrdersSortBy$outboundSchema: z.ZodNativeEnum = OrdersSortBy$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OrdersSortBy$ { /** @deprecated use `OrdersSortBy$inboundSchema` instead. */ export const inboundSchema = OrdersSortBy$inboundSchema; /** @deprecated use `OrdersSortBy$outboundSchema` instead. */ export const outboundSchema = OrdersSortBy$outboundSchema; } /** @internal */ export const OrdersSort$inboundSchema: z.ZodType< OrdersSort, z.ZodTypeDef, unknown > = z.object({ by: OrdersSortBy$inboundSchema.optional(), direction: SortDirection$inboundSchema.default("asc"), }); /** @internal */ export type OrdersSort$Outbound = { by?: string | undefined; direction: string; }; /** @internal */ export const OrdersSort$outboundSchema: z.ZodType< OrdersSort$Outbound, z.ZodTypeDef, OrdersSort > = z.object({ by: OrdersSortBy$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 OrdersSort$ { /** @deprecated use `OrdersSort$inboundSchema` instead. */ export const inboundSchema = OrdersSort$inboundSchema; /** @deprecated use `OrdersSort$outboundSchema` instead. */ export const outboundSchema = OrdersSort$outboundSchema; /** @deprecated use `OrdersSort$Outbound` instead. */ export type Outbound = OrdersSort$Outbound; } export function ordersSortToJSON(ordersSort: OrdersSort): string { return JSON.stringify(OrdersSort$outboundSchema.parse(ordersSort)); } export function ordersSortFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OrdersSort$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OrdersSort' from JSON`, ); }