|
| 1 | +/* |
| 2 | + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. |
| 3 | + */ |
| 4 | + |
| 5 | +import * as z from "zod"; |
| 6 | +import { safeParse } from "../../lib/schemas.js"; |
| 7 | +import { Result as SafeParseResult } from "../../types/fp.js"; |
| 8 | +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; |
| 9 | + |
| 10 | +export type Four = {}; |
| 11 | + |
| 12 | +/** |
| 13 | + * Value that failed validation |
| 14 | + */ |
| 15 | +export type Value = |
| 16 | + | Four |
| 17 | + | string |
| 18 | + | number |
| 19 | + | boolean |
| 20 | + | Array<{ [k: string]: any }>; |
| 21 | + |
| 22 | +export type ConstraintValidation = { |
| 23 | + /** |
| 24 | + * List of validation error messages |
| 25 | + */ |
| 26 | + messages: Array<string>; |
| 27 | + /** |
| 28 | + * Value that failed validation |
| 29 | + */ |
| 30 | + value?: |
| 31 | + | Four |
| 32 | + | string |
| 33 | + | number |
| 34 | + | boolean |
| 35 | + | Array<{ [k: string]: any }> |
| 36 | + | null |
| 37 | + | undefined; |
| 38 | +}; |
| 39 | + |
| 40 | +/** @internal */ |
| 41 | +export const Four$inboundSchema: z.ZodType<Four, z.ZodTypeDef, unknown> = z |
| 42 | + .object({}); |
| 43 | + |
| 44 | +/** @internal */ |
| 45 | +export type Four$Outbound = {}; |
| 46 | + |
| 47 | +/** @internal */ |
| 48 | +export const Four$outboundSchema: z.ZodType<Four$Outbound, z.ZodTypeDef, Four> = |
| 49 | + z.object({}); |
| 50 | + |
| 51 | +/** |
| 52 | + * @internal |
| 53 | + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. |
| 54 | + */ |
| 55 | +export namespace Four$ { |
| 56 | + /** @deprecated use `Four$inboundSchema` instead. */ |
| 57 | + export const inboundSchema = Four$inboundSchema; |
| 58 | + /** @deprecated use `Four$outboundSchema` instead. */ |
| 59 | + export const outboundSchema = Four$outboundSchema; |
| 60 | + /** @deprecated use `Four$Outbound` instead. */ |
| 61 | + export type Outbound = Four$Outbound; |
| 62 | +} |
| 63 | + |
| 64 | +export function fourToJSON(four: Four): string { |
| 65 | + return JSON.stringify(Four$outboundSchema.parse(four)); |
| 66 | +} |
| 67 | + |
| 68 | +export function fourFromJSON( |
| 69 | + jsonString: string, |
| 70 | +): SafeParseResult<Four, SDKValidationError> { |
| 71 | + return safeParse( |
| 72 | + jsonString, |
| 73 | + (x) => Four$inboundSchema.parse(JSON.parse(x)), |
| 74 | + `Failed to parse 'Four' from JSON`, |
| 75 | + ); |
| 76 | +} |
| 77 | + |
| 78 | +/** @internal */ |
| 79 | +export const Value$inboundSchema: z.ZodType<Value, z.ZodTypeDef, unknown> = z |
| 80 | + .union([ |
| 81 | + z.lazy(() => Four$inboundSchema), |
| 82 | + z.string(), |
| 83 | + z.number(), |
| 84 | + z.boolean(), |
| 85 | + z.array(z.record(z.any())), |
| 86 | + ]); |
| 87 | + |
| 88 | +/** @internal */ |
| 89 | +export type Value$Outbound = |
| 90 | + | Four$Outbound |
| 91 | + | string |
| 92 | + | number |
| 93 | + | boolean |
| 94 | + | Array<{ [k: string]: any }>; |
| 95 | + |
| 96 | +/** @internal */ |
| 97 | +export const Value$outboundSchema: z.ZodType< |
| 98 | + Value$Outbound, |
| 99 | + z.ZodTypeDef, |
| 100 | + Value |
| 101 | +> = z.union([ |
| 102 | + z.lazy(() => Four$outboundSchema), |
| 103 | + z.string(), |
| 104 | + z.number(), |
| 105 | + z.boolean(), |
| 106 | + z.array(z.record(z.any())), |
| 107 | +]); |
| 108 | + |
| 109 | +/** |
| 110 | + * @internal |
| 111 | + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. |
| 112 | + */ |
| 113 | +export namespace Value$ { |
| 114 | + /** @deprecated use `Value$inboundSchema` instead. */ |
| 115 | + export const inboundSchema = Value$inboundSchema; |
| 116 | + /** @deprecated use `Value$outboundSchema` instead. */ |
| 117 | + export const outboundSchema = Value$outboundSchema; |
| 118 | + /** @deprecated use `Value$Outbound` instead. */ |
| 119 | + export type Outbound = Value$Outbound; |
| 120 | +} |
| 121 | + |
| 122 | +export function valueToJSON(value: Value): string { |
| 123 | + return JSON.stringify(Value$outboundSchema.parse(value)); |
| 124 | +} |
| 125 | + |
| 126 | +export function valueFromJSON( |
| 127 | + jsonString: string, |
| 128 | +): SafeParseResult<Value, SDKValidationError> { |
| 129 | + return safeParse( |
| 130 | + jsonString, |
| 131 | + (x) => Value$inboundSchema.parse(JSON.parse(x)), |
| 132 | + `Failed to parse 'Value' from JSON`, |
| 133 | + ); |
| 134 | +} |
| 135 | + |
| 136 | +/** @internal */ |
| 137 | +export const ConstraintValidation$inboundSchema: z.ZodType< |
| 138 | + ConstraintValidation, |
| 139 | + z.ZodTypeDef, |
| 140 | + unknown |
| 141 | +> = z.object({ |
| 142 | + messages: z.array(z.string()), |
| 143 | + value: z.nullable( |
| 144 | + z.union([ |
| 145 | + z.lazy(() => Four$inboundSchema), |
| 146 | + z.string(), |
| 147 | + z.number(), |
| 148 | + z.boolean(), |
| 149 | + z.array(z.record(z.any())), |
| 150 | + ]), |
| 151 | + ).optional(), |
| 152 | +}); |
| 153 | + |
| 154 | +/** @internal */ |
| 155 | +export type ConstraintValidation$Outbound = { |
| 156 | + messages: Array<string>; |
| 157 | + value?: |
| 158 | + | Four$Outbound |
| 159 | + | string |
| 160 | + | number |
| 161 | + | boolean |
| 162 | + | Array<{ [k: string]: any }> |
| 163 | + | null |
| 164 | + | undefined; |
| 165 | +}; |
| 166 | + |
| 167 | +/** @internal */ |
| 168 | +export const ConstraintValidation$outboundSchema: z.ZodType< |
| 169 | + ConstraintValidation$Outbound, |
| 170 | + z.ZodTypeDef, |
| 171 | + ConstraintValidation |
| 172 | +> = z.object({ |
| 173 | + messages: z.array(z.string()), |
| 174 | + value: z.nullable( |
| 175 | + z.union([ |
| 176 | + z.lazy(() => Four$outboundSchema), |
| 177 | + z.string(), |
| 178 | + z.number(), |
| 179 | + z.boolean(), |
| 180 | + z.array(z.record(z.any())), |
| 181 | + ]), |
| 182 | + ).optional(), |
| 183 | +}); |
| 184 | + |
| 185 | +/** |
| 186 | + * @internal |
| 187 | + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. |
| 188 | + */ |
| 189 | +export namespace ConstraintValidation$ { |
| 190 | + /** @deprecated use `ConstraintValidation$inboundSchema` instead. */ |
| 191 | + export const inboundSchema = ConstraintValidation$inboundSchema; |
| 192 | + /** @deprecated use `ConstraintValidation$outboundSchema` instead. */ |
| 193 | + export const outboundSchema = ConstraintValidation$outboundSchema; |
| 194 | + /** @deprecated use `ConstraintValidation$Outbound` instead. */ |
| 195 | + export type Outbound = ConstraintValidation$Outbound; |
| 196 | +} |
| 197 | + |
| 198 | +export function constraintValidationToJSON( |
| 199 | + constraintValidation: ConstraintValidation, |
| 200 | +): string { |
| 201 | + return JSON.stringify( |
| 202 | + ConstraintValidation$outboundSchema.parse(constraintValidation), |
| 203 | + ); |
| 204 | +} |
| 205 | + |
| 206 | +export function constraintValidationFromJSON( |
| 207 | + jsonString: string, |
| 208 | +): SafeParseResult<ConstraintValidation, SDKValidationError> { |
| 209 | + return safeParse( |
| 210 | + jsonString, |
| 211 | + (x) => ConstraintValidation$inboundSchema.parse(JSON.parse(x)), |
| 212 | + `Failed to parse 'ConstraintValidation' from JSON`, |
| 213 | + ); |
| 214 | +} |
0 commit comments