modification.ts•1.82 kB
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
export type Modification = {
date?: Date | undefined;
};
/** @internal */
export const Modification$inboundSchema: z.ZodType<
Modification,
z.ZodTypeDef,
unknown
> = z.object({
date: z.string().datetime({ offset: true }).transform(v => new Date(v))
.optional(),
});
/** @internal */
export type Modification$Outbound = {
date?: string | undefined;
};
/** @internal */
export const Modification$outboundSchema: z.ZodType<
Modification$Outbound,
z.ZodTypeDef,
Modification
> = z.object({
date: z.date().transform(v => v.toISOString()).optional(),
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace Modification$ {
/** @deprecated use `Modification$inboundSchema` instead. */
export const inboundSchema = Modification$inboundSchema;
/** @deprecated use `Modification$outboundSchema` instead. */
export const outboundSchema = Modification$outboundSchema;
/** @deprecated use `Modification$Outbound` instead. */
export type Outbound = Modification$Outbound;
}
export function modificationToJSON(modification: Modification): string {
return JSON.stringify(Modification$outboundSchema.parse(modification));
}
export function modificationFromJSON(
jsonString: string,
): SafeParseResult<Modification, SDKValidationError> {
return safeParse(
jsonString,
(x) => Modification$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Modification' from JSON`,
);
}