/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../lib/primitives.js"; import { safeParse } from "../lib/schemas.js"; import { blobLikeSchema } from "../types/blobs.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; export type Image = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; export type CannyEdgeDetectionRequestBody = { /** * The image to be processed with canny edge detection */ image: Image | Blob; /** * Scalar minimum threshold for edge detection. Equivalent to `threshold2` in OpenCV. */ maxVal?: number | undefined; /** * Scalar maximum threshold for edge detection. Equivalent to `threshold1` in OpenCV. */ minVal?: number | undefined; }; export type CannyEdgeDetectionRequest = { /** * The account in which the model is */ accountId: string; /** * The ID of the model, e.g. stable-diffusion-xl-1024-v1-0 */ modelId: string; requestBody: CannyEdgeDetectionRequestBody; }; export type CannyEdgeDetectionResponse = | ReadableStream | ReadableStream; /** @internal */ export const Image$inboundSchema: z.ZodType = z .object({ fileName: z.string(), content: z.union([ z.instanceof(ReadableStream), z.instanceof(Blob), z.instanceof(ArrayBuffer), z.instanceof(Uint8Array), ]), }); /** @internal */ export type Image$Outbound = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; /** @internal */ export const Image$outboundSchema: z.ZodType< Image$Outbound, z.ZodTypeDef, Image > = z.object({ fileName: z.string(), content: z.union([ z.instanceof(ReadableStream), z.instanceof(Blob), z.instanceof(ArrayBuffer), z.instanceof(Uint8Array), ]), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Image$ { /** @deprecated use `Image$inboundSchema` instead. */ export const inboundSchema = Image$inboundSchema; /** @deprecated use `Image$outboundSchema` instead. */ export const outboundSchema = Image$outboundSchema; /** @deprecated use `Image$Outbound` instead. */ export type Outbound = Image$Outbound; } export function imageToJSON(image: Image): string { return JSON.stringify(Image$outboundSchema.parse(image)); } export function imageFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Image$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Image' from JSON`, ); } /** @internal */ export const CannyEdgeDetectionRequestBody$inboundSchema: z.ZodType< CannyEdgeDetectionRequestBody, z.ZodTypeDef, unknown > = z.object({ image: z.lazy(() => Image$inboundSchema), max_val: z.number().default(100), min_val: z.number().default(100), }).transform((v) => { return remap$(v, { "max_val": "maxVal", "min_val": "minVal", }); }); /** @internal */ export type CannyEdgeDetectionRequestBody$Outbound = { image: Image$Outbound | Blob; max_val: number; min_val: number; }; /** @internal */ export const CannyEdgeDetectionRequestBody$outboundSchema: z.ZodType< CannyEdgeDetectionRequestBody$Outbound, z.ZodTypeDef, CannyEdgeDetectionRequestBody > = z.object({ image: z.lazy(() => Image$outboundSchema).or(blobLikeSchema), maxVal: z.number().default(100), minVal: z.number().default(100), }).transform((v) => { return remap$(v, { maxVal: "max_val", minVal: "min_val", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CannyEdgeDetectionRequestBody$ { /** @deprecated use `CannyEdgeDetectionRequestBody$inboundSchema` instead. */ export const inboundSchema = CannyEdgeDetectionRequestBody$inboundSchema; /** @deprecated use `CannyEdgeDetectionRequestBody$outboundSchema` instead. */ export const outboundSchema = CannyEdgeDetectionRequestBody$outboundSchema; /** @deprecated use `CannyEdgeDetectionRequestBody$Outbound` instead. */ export type Outbound = CannyEdgeDetectionRequestBody$Outbound; } export function cannyEdgeDetectionRequestBodyToJSON( cannyEdgeDetectionRequestBody: CannyEdgeDetectionRequestBody, ): string { return JSON.stringify( CannyEdgeDetectionRequestBody$outboundSchema.parse( cannyEdgeDetectionRequestBody, ), ); } export function cannyEdgeDetectionRequestBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CannyEdgeDetectionRequestBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CannyEdgeDetectionRequestBody' from JSON`, ); } /** @internal */ export const CannyEdgeDetectionRequest$inboundSchema: z.ZodType< CannyEdgeDetectionRequest, z.ZodTypeDef, unknown > = z.object({ accountId: z.string(), modelId: z.string(), RequestBody: z.lazy(() => CannyEdgeDetectionRequestBody$inboundSchema), }).transform((v) => { return remap$(v, { "RequestBody": "requestBody", }); }); /** @internal */ export type CannyEdgeDetectionRequest$Outbound = { accountId: string; modelId: string; RequestBody: CannyEdgeDetectionRequestBody$Outbound; }; /** @internal */ export const CannyEdgeDetectionRequest$outboundSchema: z.ZodType< CannyEdgeDetectionRequest$Outbound, z.ZodTypeDef, CannyEdgeDetectionRequest > = z.object({ accountId: z.string(), modelId: z.string(), requestBody: z.lazy(() => CannyEdgeDetectionRequestBody$outboundSchema), }).transform((v) => { return remap$(v, { requestBody: "RequestBody", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CannyEdgeDetectionRequest$ { /** @deprecated use `CannyEdgeDetectionRequest$inboundSchema` instead. */ export const inboundSchema = CannyEdgeDetectionRequest$inboundSchema; /** @deprecated use `CannyEdgeDetectionRequest$outboundSchema` instead. */ export const outboundSchema = CannyEdgeDetectionRequest$outboundSchema; /** @deprecated use `CannyEdgeDetectionRequest$Outbound` instead. */ export type Outbound = CannyEdgeDetectionRequest$Outbound; } export function cannyEdgeDetectionRequestToJSON( cannyEdgeDetectionRequest: CannyEdgeDetectionRequest, ): string { return JSON.stringify( CannyEdgeDetectionRequest$outboundSchema.parse(cannyEdgeDetectionRequest), ); } export function cannyEdgeDetectionRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CannyEdgeDetectionRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CannyEdgeDetectionRequest' from JSON`, ); } /** @internal */ export const CannyEdgeDetectionResponse$inboundSchema: z.ZodType< CannyEdgeDetectionResponse, z.ZodTypeDef, unknown > = z.union([ z.instanceof(ReadableStream), z.instanceof(ReadableStream), ]); /** @internal */ export type CannyEdgeDetectionResponse$Outbound = | ReadableStream | ReadableStream; /** @internal */ export const CannyEdgeDetectionResponse$outboundSchema: z.ZodType< CannyEdgeDetectionResponse$Outbound, z.ZodTypeDef, CannyEdgeDetectionResponse > = z.union([ z.instanceof(ReadableStream), z.instanceof(ReadableStream), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CannyEdgeDetectionResponse$ { /** @deprecated use `CannyEdgeDetectionResponse$inboundSchema` instead. */ export const inboundSchema = CannyEdgeDetectionResponse$inboundSchema; /** @deprecated use `CannyEdgeDetectionResponse$outboundSchema` instead. */ export const outboundSchema = CannyEdgeDetectionResponse$outboundSchema; /** @deprecated use `CannyEdgeDetectionResponse$Outbound` instead. */ export type Outbound = CannyEdgeDetectionResponse$Outbound; } export function cannyEdgeDetectionResponseToJSON( cannyEdgeDetectionResponse: CannyEdgeDetectionResponse, ): string { return JSON.stringify( CannyEdgeDetectionResponse$outboundSchema.parse(cannyEdgeDetectionResponse), ); } export function cannyEdgeDetectionResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CannyEdgeDetectionResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CannyEdgeDetectionResponse' from JSON`, ); }