patchwithcomment.ts•2.21 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";
import {
PatchOperation,
PatchOperation$inboundSchema,
PatchOperation$Outbound,
PatchOperation$outboundSchema,
} from "./patchoperation.js";
export type PatchWithComment = {
patch: Array<PatchOperation>;
/**
* Optional comment
*/
comment?: string | undefined;
};
/** @internal */
export const PatchWithComment$inboundSchema: z.ZodType<
PatchWithComment,
z.ZodTypeDef,
unknown
> = z.object({
patch: z.array(PatchOperation$inboundSchema),
comment: z.string().optional(),
});
/** @internal */
export type PatchWithComment$Outbound = {
patch: Array<PatchOperation$Outbound>;
comment?: string | undefined;
};
/** @internal */
export const PatchWithComment$outboundSchema: z.ZodType<
PatchWithComment$Outbound,
z.ZodTypeDef,
PatchWithComment
> = z.object({
patch: z.array(PatchOperation$outboundSchema),
comment: z.string().optional(),
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace PatchWithComment$ {
/** @deprecated use `PatchWithComment$inboundSchema` instead. */
export const inboundSchema = PatchWithComment$inboundSchema;
/** @deprecated use `PatchWithComment$outboundSchema` instead. */
export const outboundSchema = PatchWithComment$outboundSchema;
/** @deprecated use `PatchWithComment$Outbound` instead. */
export type Outbound = PatchWithComment$Outbound;
}
export function patchWithCommentToJSON(
patchWithComment: PatchWithComment,
): string {
return JSON.stringify(
PatchWithComment$outboundSchema.parse(patchWithComment),
);
}
export function patchWithCommentFromJSON(
jsonString: string,
): SafeParseResult<PatchWithComment, SDKValidationError> {
return safeParse(
jsonString,
(x) => PatchWithComment$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'PatchWithComment' from JSON`,
);
}