/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; 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"; export type Six = { type: "number"; }; export type Five = { type: "label_set"; labels: Array; caseSensitive?: boolean | undefined; }; export type EvalOutputExtractionGroup = number | string; export type EvalOutputExtraction4 = { type: "regex_last"; pattern: string; group?: number | string | undefined; flags?: string | undefined; }; export type Group = number | string; export type EvalOutputExtraction3 = { type: "regex"; pattern: string; group?: number | string | undefined; flags?: string | undefined; }; export type EvalOutputExtraction2 = { type: "take_first"; lines?: number | undefined; }; export type EvalOutputExtraction1 = { type: "none"; }; export type EvalOutputExtraction = | EvalOutputExtraction1 | EvalOutputExtraction2 | EvalOutputExtraction3 | EvalOutputExtraction4 | Five | Six; /** @internal */ export const Six$inboundSchema: z.ZodType = z .object({ type: z.literal("number"), }); /** @internal */ export type Six$Outbound = { type: "number"; }; /** @internal */ export const Six$outboundSchema: z.ZodType = z .object({ type: z.literal("number"), }); export function sixToJSON(six: Six): string { return JSON.stringify(Six$outboundSchema.parse(six)); } export function sixFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Six$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Six' from JSON`, ); } /** @internal */ export const Five$inboundSchema: z.ZodType = z .object({ type: z.literal("label_set"), labels: z.array(z.string()), case_sensitive: z.boolean().default(false), }).transform((v) => { return remap$(v, { "case_sensitive": "caseSensitive", }); }); /** @internal */ export type Five$Outbound = { type: "label_set"; labels: Array; case_sensitive: boolean; }; /** @internal */ export const Five$outboundSchema: z.ZodType = z.object({ type: z.literal("label_set"), labels: z.array(z.string()), caseSensitive: z.boolean().default(false), }).transform((v) => { return remap$(v, { caseSensitive: "case_sensitive", }); }); export function fiveToJSON(five: Five): string { return JSON.stringify(Five$outboundSchema.parse(five)); } export function fiveFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Five$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Five' from JSON`, ); } /** @internal */ export const EvalOutputExtractionGroup$inboundSchema: z.ZodType< EvalOutputExtractionGroup, z.ZodTypeDef, unknown > = z.union([z.number().int(), z.string()]); /** @internal */ export type EvalOutputExtractionGroup$Outbound = number | string; /** @internal */ export const EvalOutputExtractionGroup$outboundSchema: z.ZodType< EvalOutputExtractionGroup$Outbound, z.ZodTypeDef, EvalOutputExtractionGroup > = z.union([z.number().int(), z.string()]); export function evalOutputExtractionGroupToJSON( evalOutputExtractionGroup: EvalOutputExtractionGroup, ): string { return JSON.stringify( EvalOutputExtractionGroup$outboundSchema.parse(evalOutputExtractionGroup), ); } export function evalOutputExtractionGroupFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EvalOutputExtractionGroup$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EvalOutputExtractionGroup' from JSON`, ); } /** @internal */ export const EvalOutputExtraction4$inboundSchema: z.ZodType< EvalOutputExtraction4, z.ZodTypeDef, unknown > = z.object({ type: z.literal("regex_last"), pattern: z.string(), group: z.union([z.number().int(), z.string()]).optional(), flags: z.string().optional(), }); /** @internal */ export type EvalOutputExtraction4$Outbound = { type: "regex_last"; pattern: string; group?: number | string | undefined; flags?: string | undefined; }; /** @internal */ export const EvalOutputExtraction4$outboundSchema: z.ZodType< EvalOutputExtraction4$Outbound, z.ZodTypeDef, EvalOutputExtraction4 > = z.object({ type: z.literal("regex_last"), pattern: z.string(), group: z.union([z.number().int(), z.string()]).optional(), flags: z.string().optional(), }); export function evalOutputExtraction4ToJSON( evalOutputExtraction4: EvalOutputExtraction4, ): string { return JSON.stringify( EvalOutputExtraction4$outboundSchema.parse(evalOutputExtraction4), ); } export function evalOutputExtraction4FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EvalOutputExtraction4$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EvalOutputExtraction4' from JSON`, ); } /** @internal */ export const Group$inboundSchema: z.ZodType = z .union([z.number().int(), z.string()]); /** @internal */ export type Group$Outbound = number | string; /** @internal */ export const Group$outboundSchema: z.ZodType< Group$Outbound, z.ZodTypeDef, Group > = z.union([z.number().int(), z.string()]); export function groupToJSON(group: Group): string { return JSON.stringify(Group$outboundSchema.parse(group)); } export function groupFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Group$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Group' from JSON`, ); } /** @internal */ export const EvalOutputExtraction3$inboundSchema: z.ZodType< EvalOutputExtraction3, z.ZodTypeDef, unknown > = z.object({ type: z.literal("regex"), pattern: z.string(), group: z.union([z.number().int(), z.string()]).optional(), flags: z.string().optional(), }); /** @internal */ export type EvalOutputExtraction3$Outbound = { type: "regex"; pattern: string; group?: number | string | undefined; flags?: string | undefined; }; /** @internal */ export const EvalOutputExtraction3$outboundSchema: z.ZodType< EvalOutputExtraction3$Outbound, z.ZodTypeDef, EvalOutputExtraction3 > = z.object({ type: z.literal("regex"), pattern: z.string(), group: z.union([z.number().int(), z.string()]).optional(), flags: z.string().optional(), }); export function evalOutputExtraction3ToJSON( evalOutputExtraction3: EvalOutputExtraction3, ): string { return JSON.stringify( EvalOutputExtraction3$outboundSchema.parse(evalOutputExtraction3), ); } export function evalOutputExtraction3FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EvalOutputExtraction3$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EvalOutputExtraction3' from JSON`, ); } /** @internal */ export const EvalOutputExtraction2$inboundSchema: z.ZodType< EvalOutputExtraction2, z.ZodTypeDef, unknown > = z.object({ type: z.literal("take_first"), lines: z.number().int().default(1), }); /** @internal */ export type EvalOutputExtraction2$Outbound = { type: "take_first"; lines: number; }; /** @internal */ export const EvalOutputExtraction2$outboundSchema: z.ZodType< EvalOutputExtraction2$Outbound, z.ZodTypeDef, EvalOutputExtraction2 > = z.object({ type: z.literal("take_first"), lines: z.number().int().default(1), }); export function evalOutputExtraction2ToJSON( evalOutputExtraction2: EvalOutputExtraction2, ): string { return JSON.stringify( EvalOutputExtraction2$outboundSchema.parse(evalOutputExtraction2), ); } export function evalOutputExtraction2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EvalOutputExtraction2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EvalOutputExtraction2' from JSON`, ); } /** @internal */ export const EvalOutputExtraction1$inboundSchema: z.ZodType< EvalOutputExtraction1, z.ZodTypeDef, unknown > = z.object({ type: z.literal("none"), }); /** @internal */ export type EvalOutputExtraction1$Outbound = { type: "none"; }; /** @internal */ export const EvalOutputExtraction1$outboundSchema: z.ZodType< EvalOutputExtraction1$Outbound, z.ZodTypeDef, EvalOutputExtraction1 > = z.object({ type: z.literal("none"), }); export function evalOutputExtraction1ToJSON( evalOutputExtraction1: EvalOutputExtraction1, ): string { return JSON.stringify( EvalOutputExtraction1$outboundSchema.parse(evalOutputExtraction1), ); } export function evalOutputExtraction1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EvalOutputExtraction1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EvalOutputExtraction1' from JSON`, ); } /** @internal */ export const EvalOutputExtraction$inboundSchema: z.ZodType< EvalOutputExtraction, z.ZodTypeDef, unknown > = z.union([ z.lazy(() => EvalOutputExtraction1$inboundSchema), z.lazy(() => EvalOutputExtraction2$inboundSchema), z.lazy(() => EvalOutputExtraction3$inboundSchema), z.lazy(() => EvalOutputExtraction4$inboundSchema), z.lazy(() => Five$inboundSchema), z.lazy(() => Six$inboundSchema), ]); /** @internal */ export type EvalOutputExtraction$Outbound = | EvalOutputExtraction1$Outbound | EvalOutputExtraction2$Outbound | EvalOutputExtraction3$Outbound | EvalOutputExtraction4$Outbound | Five$Outbound | Six$Outbound; /** @internal */ export const EvalOutputExtraction$outboundSchema: z.ZodType< EvalOutputExtraction$Outbound, z.ZodTypeDef, EvalOutputExtraction > = z.union([ z.lazy(() => EvalOutputExtraction1$outboundSchema), z.lazy(() => EvalOutputExtraction2$outboundSchema), z.lazy(() => EvalOutputExtraction3$outboundSchema), z.lazy(() => EvalOutputExtraction4$outboundSchema), z.lazy(() => Five$outboundSchema), z.lazy(() => Six$outboundSchema), ]); export function evalOutputExtractionToJSON( evalOutputExtraction: EvalOutputExtraction, ): string { return JSON.stringify( EvalOutputExtraction$outboundSchema.parse(evalOutputExtraction), ); } export function evalOutputExtractionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EvalOutputExtraction$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EvalOutputExtraction' from JSON`, ); }