/* * 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"; import { AuthorizationCodeRequest, AuthorizationCodeRequest$inboundSchema, AuthorizationCodeRequest$Outbound, AuthorizationCodeRequest$outboundSchema, } from "./authorizationcoderequest.js"; import { RefreshTokenRequest, RefreshTokenRequest$inboundSchema, RefreshTokenRequest$Outbound, RefreshTokenRequest$outboundSchema, } from "./refreshtokenrequest.js"; export type TokenRequest = AuthorizationCodeRequest | RefreshTokenRequest; /** @internal */ export const TokenRequest$inboundSchema: z.ZodType< TokenRequest, z.ZodTypeDef, unknown > = z.union([ AuthorizationCodeRequest$inboundSchema, RefreshTokenRequest$inboundSchema, ]); /** @internal */ export type TokenRequest$Outbound = | AuthorizationCodeRequest$Outbound | RefreshTokenRequest$Outbound; /** @internal */ export const TokenRequest$outboundSchema: z.ZodType< TokenRequest$Outbound, z.ZodTypeDef, TokenRequest > = z.union([ AuthorizationCodeRequest$outboundSchema, RefreshTokenRequest$outboundSchema, ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TokenRequest$ { /** @deprecated use `TokenRequest$inboundSchema` instead. */ export const inboundSchema = TokenRequest$inboundSchema; /** @deprecated use `TokenRequest$outboundSchema` instead. */ export const outboundSchema = TokenRequest$outboundSchema; /** @deprecated use `TokenRequest$Outbound` instead. */ export type Outbound = TokenRequest$Outbound; } export function tokenRequestToJSON(tokenRequest: TokenRequest): string { return JSON.stringify(TokenRequest$outboundSchema.parse(tokenRequest)); } export function tokenRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TokenRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TokenRequest' from JSON`, ); }