/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; 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 { CustomFieldDateProperties, CustomFieldDateProperties$inboundSchema, CustomFieldDateProperties$Outbound, CustomFieldDateProperties$outboundSchema, } from "./customfielddateproperties.js"; import { MetadataOutputType, MetadataOutputType$inboundSchema, MetadataOutputType$Outbound, MetadataOutputType$outboundSchema, } from "./metadataoutputtype.js"; /** * Schema for a custom field of type date. */ export type CustomFieldDate = { /** * Creation timestamp of the object. */ createdAt: Date; /** * Last modification timestamp of the object. */ modifiedAt: Date | null; /** * The ID of the object. */ id: string; metadata: { [k: string]: MetadataOutputType }; type: "date"; /** * Identifier of the custom field. It'll be used as key when storing the value. */ slug: string; /** * Name of the custom field. */ name: string; /** * The ID of the organization owning the custom field. */ organizationId: string; properties: CustomFieldDateProperties; }; /** @internal */ export const CustomFieldDate$inboundSchema: z.ZodMiniType< CustomFieldDate, unknown > = z.pipe( z.object({ created_at: z.pipe( z.iso.datetime({ offset: true }), z.transform(v => new Date(v)), ), modified_at: z.nullable( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), id: z.string(), metadata: z.record(z.string(), MetadataOutputType$inboundSchema), type: z.literal("date"), slug: z.string(), name: z.string(), organization_id: z.string(), properties: CustomFieldDateProperties$inboundSchema, }), z.transform((v) => { return remap$(v, { "created_at": "createdAt", "modified_at": "modifiedAt", "organization_id": "organizationId", }); }), ); /** @internal */ export type CustomFieldDate$Outbound = { created_at: string; modified_at: string | null; id: string; metadata: { [k: string]: MetadataOutputType$Outbound }; type: "date"; slug: string; name: string; organization_id: string; properties: CustomFieldDateProperties$Outbound; }; /** @internal */ export const CustomFieldDate$outboundSchema: z.ZodMiniType< CustomFieldDate$Outbound, CustomFieldDate > = z.pipe( z.object({ createdAt: z.pipe(z.date(), z.transform(v => v.toISOString())), modifiedAt: z.nullable(z.pipe(z.date(), z.transform(v => v.toISOString()))), id: z.string(), metadata: z.record(z.string(), MetadataOutputType$outboundSchema), type: z.literal("date"), slug: z.string(), name: z.string(), organizationId: z.string(), properties: CustomFieldDateProperties$outboundSchema, }), z.transform((v) => { return remap$(v, { createdAt: "created_at", modifiedAt: "modified_at", organizationId: "organization_id", }); }), ); export function customFieldDateToJSON( customFieldDate: CustomFieldDate, ): string { return JSON.stringify(CustomFieldDate$outboundSchema.parse(customFieldDate)); } export function customFieldDateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomFieldDate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomFieldDate' from JSON`, ); }