UNPKG

@vercel/sdk

Version:

<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>

112 lines (99 loc) 2.95 kB
/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../lib/schemas.js"; import { ClosedEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import * as types from "../types/primitives.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; export const Type = { Deny: "deny", Rewrite: "rewrite", } as const; export type Type = ClosedEnum<typeof Type>; export type Match = { model?: string | undefined; }; export type Action = { rewriteModel?: string | undefined; reason?: string | undefined; }; /** * Public response shape for AI Gateway routing rules. Used so OpenAPI generation can avoid ElectroDB's recursive EntityItem types. */ export type AiGatewayRule = { ownerId: string; ruleId: string; type: Type; match?: Match | undefined; action?: Action | undefined; enabled: boolean; deleted?: boolean | undefined; description?: string | undefined; createdBy?: string | undefined; updatedBy?: string | undefined; createdAt: number; updatedAt: number; }; /** @internal */ export const Type$inboundSchema: z.ZodNativeEnum<typeof Type> = z.nativeEnum( Type, ); /** @internal */ export const Match$inboundSchema: z.ZodType<Match, z.ZodTypeDef, unknown> = z .object({ model: types.optional(types.string()), }); export function matchFromJSON( jsonString: string, ): SafeParseResult<Match, SDKValidationError> { return safeParse( jsonString, (x) => Match$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Match' from JSON`, ); } /** @internal */ export const Action$inboundSchema: z.ZodType<Action, z.ZodTypeDef, unknown> = z .object({ rewriteModel: types.optional(types.string()), reason: types.optional(types.string()), }); export function actionFromJSON( jsonString: string, ): SafeParseResult<Action, SDKValidationError> { return safeParse( jsonString, (x) => Action$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Action' from JSON`, ); } /** @internal */ export const AiGatewayRule$inboundSchema: z.ZodType< AiGatewayRule, z.ZodTypeDef, unknown > = z.object({ ownerId: types.string(), ruleId: types.string(), type: Type$inboundSchema, match: types.optional(z.lazy(() => Match$inboundSchema)), action: types.optional(z.lazy(() => Action$inboundSchema)), enabled: types.boolean(), deleted: types.optional(types.boolean()), description: types.optional(types.string()), createdBy: types.optional(types.string()), updatedBy: types.optional(types.string()), createdAt: types.number(), updatedAt: types.number(), }); export function aiGatewayRuleFromJSON( jsonString: string, ): SafeParseResult<AiGatewayRule, SDKValidationError> { return safeParse( jsonString, (x) => AiGatewayRule$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AiGatewayRule' from JSON`, ); }