aiconfigs.ts•2.46 kB
/*
* 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 { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
AIConfig,
AIConfig$inboundSchema,
AIConfig$Outbound,
AIConfig$outboundSchema,
} from "./aiconfig.js";
import {
PaginatedLinks,
PaginatedLinks$inboundSchema,
PaginatedLinks$Outbound,
PaginatedLinks$outboundSchema,
} from "./paginatedlinks.js";
export type AIConfigs = {
links?: PaginatedLinks | undefined;
items: Array<AIConfig>;
totalCount: number;
};
/** @internal */
export const AIConfigs$inboundSchema: z.ZodType<
AIConfigs,
z.ZodTypeDef,
unknown
> = z.object({
_links: PaginatedLinks$inboundSchema.optional(),
items: z.array(AIConfig$inboundSchema),
totalCount: z.number().int(),
}).transform((v) => {
return remap$(v, {
"_links": "links",
});
});
/** @internal */
export type AIConfigs$Outbound = {
_links?: PaginatedLinks$Outbound | undefined;
items: Array<AIConfig$Outbound>;
totalCount: number;
};
/** @internal */
export const AIConfigs$outboundSchema: z.ZodType<
AIConfigs$Outbound,
z.ZodTypeDef,
AIConfigs
> = z.object({
links: PaginatedLinks$outboundSchema.optional(),
items: z.array(AIConfig$outboundSchema),
totalCount: z.number().int(),
}).transform((v) => {
return remap$(v, {
links: "_links",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace AIConfigs$ {
/** @deprecated use `AIConfigs$inboundSchema` instead. */
export const inboundSchema = AIConfigs$inboundSchema;
/** @deprecated use `AIConfigs$outboundSchema` instead. */
export const outboundSchema = AIConfigs$outboundSchema;
/** @deprecated use `AIConfigs$Outbound` instead. */
export type Outbound = AIConfigs$Outbound;
}
export function aiConfigsToJSON(aiConfigs: AIConfigs): string {
return JSON.stringify(AIConfigs$outboundSchema.parse(aiConfigs));
}
export function aiConfigsFromJSON(
jsonString: string,
): SafeParseResult<AIConfigs, SDKValidationError> {
return safeParse(
jsonString,
(x) => AIConfigs$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'AIConfigs' from JSON`,
);
}