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