message.ts•1.66 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 Message = {
content: string;
role: string;
};
/** @internal */
export const Message$inboundSchema: z.ZodType<Message, z.ZodTypeDef, unknown> =
z.object({
content: z.string(),
role: z.string(),
});
/** @internal */
export type Message$Outbound = {
content: string;
role: string;
};
/** @internal */
export const Message$outboundSchema: z.ZodType<
Message$Outbound,
z.ZodTypeDef,
Message
> = z.object({
content: z.string(),
role: z.string(),
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace Message$ {
/** @deprecated use `Message$inboundSchema` instead. */
export const inboundSchema = Message$inboundSchema;
/** @deprecated use `Message$outboundSchema` instead. */
export const outboundSchema = Message$outboundSchema;
/** @deprecated use `Message$Outbound` instead. */
export type Outbound = Message$Outbound;
}
export function messageToJSON(message: Message): string {
return JSON.stringify(Message$outboundSchema.parse(message));
}
export function messageFromJSON(
jsonString: string,
): SafeParseResult<Message, SDKValidationError> {
return safeParse(
jsonString,
(x) => Message$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Message' from JSON`,
);
}