/* * 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"; /** * Represents a JSON Web Token for access to the system; See: https://datatracker.ietf.org/doc/html/rfc6749#section-5.1 */ export type Token = { /** * The access token issued by the authorization server */ accessToken?: string | undefined; /** * The lifetime in seconds of the access token */ expiresIn?: number | undefined; /** * The token type for this access token */ tokenType?: string | undefined; }; /** @internal */ export const Token$inboundSchema: z.ZodType = z .object({ access_token: z.string().optional(), expires_in: z.number().int().optional(), token_type: z.string().optional(), }).transform((v) => { return remap$(v, { "access_token": "accessToken", "expires_in": "expiresIn", "token_type": "tokenType", }); }); /** @internal */ export type Token$Outbound = { access_token?: string | undefined; expires_in?: number | undefined; token_type?: string | undefined; }; /** @internal */ export const Token$outboundSchema: z.ZodType< Token$Outbound, z.ZodTypeDef, Token > = z.object({ accessToken: z.string().optional(), expiresIn: z.number().int().optional(), tokenType: z.string().optional(), }).transform((v) => { return remap$(v, { accessToken: "access_token", expiresIn: "expires_in", tokenType: "token_type", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Token$ { /** @deprecated use `Token$inboundSchema` instead. */ export const inboundSchema = Token$inboundSchema; /** @deprecated use `Token$outboundSchema` instead. */ export const outboundSchema = Token$outboundSchema; /** @deprecated use `Token$Outbound` instead. */ export type Outbound = Token$Outbound; } export function tokenToJSON(token: Token): string { return JSON.stringify(Token$outboundSchema.parse(token)); } export function tokenFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Token$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Token' from JSON`, ); }