/* * 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 { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of token used. */ export const GetTokenDetailsType = { Permanent: "permanent", Expiring: "expiring", Oauth: "oauth", } as const; /** * The type of token used. */ export type GetTokenDetailsType = ClosedEnum; export type Application = { /** * The name of the application. */ name: string; /** * The scopes of the application. These may be different than the token scope. */ scopes: Array; }; /** * The token used to make the API request. This is primarily for debugging * * @remarks * purposes. Sensitive data such as the token value is excluded. */ export type GetTokenDetailsResponse = { /** * The type of token used. */ type: GetTokenDetailsType; /** * The application used by the token. Will be null if the token isn't an oauth token. */ application: Application | null; /** * The scopes of the token. */ scopes: Array; /** * The name of the token. This only applies to permanent tokens. */ name: string | null; /** * When the token expires. A null token means it never expires. */ expiresAt?: string | null | undefined; }; /** @internal */ export const GetTokenDetailsType$inboundSchema: z.ZodNativeEnum< typeof GetTokenDetailsType > = z.nativeEnum(GetTokenDetailsType); /** @internal */ export const Application$inboundSchema: z.ZodType< Application, z.ZodTypeDef, unknown > = z.object({ name: z.string(), scopes: z.array(z.string()), }); export function applicationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Application$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Application' from JSON`, ); } /** @internal */ export const GetTokenDetailsResponse$inboundSchema: z.ZodType< GetTokenDetailsResponse, z.ZodTypeDef, unknown > = z.object({ type: GetTokenDetailsType$inboundSchema, application: z.nullable(z.lazy(() => Application$inboundSchema)), scopes: z.array(z.string()), name: z.nullable(z.string()), expires_at: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "expires_at": "expiresAt", }); }); export function getTokenDetailsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetTokenDetailsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetTokenDetailsResponse' from JSON`, ); }