UNPKG

@unkey/api

Version:

Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@unkey/api* API.

100 lines (91 loc) 2.79 kB
/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type V2RatelimitLimitRequestBody = { /** * The namespace name for the rate limit. */ namespace: string; /** * The cost of the request. Defaults to 1 if not provided. */ cost?: number | undefined; /** * The duration in milliseconds for the rate limit window. */ duration: number; /** * The identifier for the rate limit. */ identifier: string; /** * The maximum number of requests allowed. */ limit: number; }; /** @internal */ export const V2RatelimitLimitRequestBody$inboundSchema: z.ZodType< V2RatelimitLimitRequestBody, z.ZodTypeDef, unknown > = z.object({ namespace: z.string(), cost: z.number().int().default(1), duration: z.number().int(), identifier: z.string(), limit: z.number().int(), }); /** @internal */ export type V2RatelimitLimitRequestBody$Outbound = { namespace: string; cost: number; duration: number; identifier: string; limit: number; }; /** @internal */ export const V2RatelimitLimitRequestBody$outboundSchema: z.ZodType< V2RatelimitLimitRequestBody$Outbound, z.ZodTypeDef, V2RatelimitLimitRequestBody > = z.object({ namespace: z.string(), cost: z.number().int().default(1), duration: z.number().int(), identifier: z.string(), limit: z.number().int(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace V2RatelimitLimitRequestBody$ { /** @deprecated use `V2RatelimitLimitRequestBody$inboundSchema` instead. */ export const inboundSchema = V2RatelimitLimitRequestBody$inboundSchema; /** @deprecated use `V2RatelimitLimitRequestBody$outboundSchema` instead. */ export const outboundSchema = V2RatelimitLimitRequestBody$outboundSchema; /** @deprecated use `V2RatelimitLimitRequestBody$Outbound` instead. */ export type Outbound = V2RatelimitLimitRequestBody$Outbound; } export function v2RatelimitLimitRequestBodyToJSON( v2RatelimitLimitRequestBody: V2RatelimitLimitRequestBody, ): string { return JSON.stringify( V2RatelimitLimitRequestBody$outboundSchema.parse( v2RatelimitLimitRequestBody, ), ); } export function v2RatelimitLimitRequestBodyFromJSON( jsonString: string, ): SafeParseResult<V2RatelimitLimitRequestBody, SDKValidationError> { return safeParse( jsonString, (x) => V2RatelimitLimitRequestBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'V2RatelimitLimitRequestBody' from JSON`, ); }