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>

153 lines (132 loc) 3.77 kB
/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../lib/primitives.js"; import { safeParse } from "../lib/schemas.js"; import { Result as SafeParseResult } from "../types/fp.js"; import * as types from "../types/primitives.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * The claims to include in the token. */ export type SignKmsTokenClaims = {}; /** * Additional headers to include in the token. */ export type Headers = {}; export type SignKmsTokenRequestBody = { /** * The claims to include in the token. */ claims?: SignKmsTokenClaims | undefined; /** * Additional headers to include in the token. */ headers?: Headers | undefined; /** * The time-to-live for the token, in seconds. */ ttl?: number | null | undefined; }; export type SignKmsTokenRequest = { /** * The ID of the issuer. */ issuerId: string; requestBody?: SignKmsTokenRequestBody | undefined; }; export type SignKmsTokenResponseBody = { token: string; }; /** @internal */ export type SignKmsTokenClaims$Outbound = {}; /** @internal */ export const SignKmsTokenClaims$outboundSchema: z.ZodType< SignKmsTokenClaims$Outbound, z.ZodTypeDef, SignKmsTokenClaims > = z.object({}); export function signKmsTokenClaimsToJSON( signKmsTokenClaims: SignKmsTokenClaims, ): string { return JSON.stringify( SignKmsTokenClaims$outboundSchema.parse(signKmsTokenClaims), ); } /** @internal */ export type Headers$Outbound = {}; /** @internal */ export const Headers$outboundSchema: z.ZodType< Headers$Outbound, z.ZodTypeDef, Headers > = z.object({}); export function headersToJSON(headers: Headers): string { return JSON.stringify(Headers$outboundSchema.parse(headers)); } /** @internal */ export type SignKmsTokenRequestBody$Outbound = { claims?: SignKmsTokenClaims$Outbound | undefined; headers?: Headers$Outbound | undefined; ttl: number | null; }; /** @internal */ export const SignKmsTokenRequestBody$outboundSchema: z.ZodType< SignKmsTokenRequestBody$Outbound, z.ZodTypeDef, SignKmsTokenRequestBody > = z.object({ claims: z.lazy(() => SignKmsTokenClaims$outboundSchema).optional(), headers: z.lazy(() => Headers$outboundSchema).optional(), ttl: z.nullable(z.number().default(300)), }); export function signKmsTokenRequestBodyToJSON( signKmsTokenRequestBody: SignKmsTokenRequestBody, ): string { return JSON.stringify( SignKmsTokenRequestBody$outboundSchema.parse(signKmsTokenRequestBody), ); } /** @internal */ export type SignKmsTokenRequest$Outbound = { issuerId: string; RequestBody?: SignKmsTokenRequestBody$Outbound | undefined; }; /** @internal */ export const SignKmsTokenRequest$outboundSchema: z.ZodType< SignKmsTokenRequest$Outbound, z.ZodTypeDef, SignKmsTokenRequest > = z.object({ issuerId: z.string(), requestBody: z.lazy(() => SignKmsTokenRequestBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { requestBody: "RequestBody", }); }); export function signKmsTokenRequestToJSON( signKmsTokenRequest: SignKmsTokenRequest, ): string { return JSON.stringify( SignKmsTokenRequest$outboundSchema.parse(signKmsTokenRequest), ); } /** @internal */ export const SignKmsTokenResponseBody$inboundSchema: z.ZodType< SignKmsTokenResponseBody, z.ZodTypeDef, unknown > = z.object({ token: types.string(), }); export function signKmsTokenResponseBodyFromJSON( jsonString: string, ): SafeParseResult<SignKmsTokenResponseBody, SDKValidationError> { return safeParse( jsonString, (x) => SignKmsTokenResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SignKmsTokenResponseBody' from JSON`, ); }