/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { CustomMappings, CustomMappings$inboundSchema, CustomMappings$Outbound, CustomMappings$outboundSchema, } from "./custommappings.js"; export type Collection = { /** * A unique identifier for an object. */ id: string; /** * The collections's parent ID */ parentId?: string | null | undefined; /** * The collections's type */ type?: string | null | undefined; /** * Name of the collection */ name?: string | null | undefined; /** * Description of the collection */ description?: string | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: CustomMappings | null | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; /** * The date and time when the object was created. */ createdAt?: Date | null | undefined; }; /** @internal */ export const Collection$inboundSchema: z.ZodType< Collection, z.ZodTypeDef, unknown > = z.object({ id: z.string(), parent_id: z.nullable(z.string()).optional(), type: z.nullable(z.string()).optional(), name: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), custom_mappings: z.nullable(CustomMappings$inboundSchema).optional(), updated_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), created_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "parent_id": "parentId", "custom_mappings": "customMappings", "updated_at": "updatedAt", "created_at": "createdAt", }); }); /** @internal */ export type Collection$Outbound = { id: string; parent_id?: string | null | undefined; type?: string | null | undefined; name?: string | null | undefined; description?: string | null | undefined; custom_mappings?: CustomMappings$Outbound | null | undefined; updated_at?: string | null | undefined; created_at?: string | null | undefined; }; /** @internal */ export const Collection$outboundSchema: z.ZodType< Collection$Outbound, z.ZodTypeDef, Collection > = z.object({ id: z.string(), parentId: z.nullable(z.string()).optional(), type: z.nullable(z.string()).optional(), name: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), customMappings: z.nullable(CustomMappings$outboundSchema).optional(), updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), createdAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), }).transform((v) => { return remap$(v, { parentId: "parent_id", customMappings: "custom_mappings", updatedAt: "updated_at", createdAt: "created_at", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Collection$ { /** @deprecated use `Collection$inboundSchema` instead. */ export const inboundSchema = Collection$inboundSchema; /** @deprecated use `Collection$outboundSchema` instead. */ export const outboundSchema = Collection$outboundSchema; /** @deprecated use `Collection$Outbound` instead. */ export type Outbound = Collection$Outbound; } export function collectionToJSON(collection: Collection): string { return JSON.stringify(Collection$outboundSchema.parse(collection)); } export function collectionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Collection$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Collection' from JSON`, ); }