/* * 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 resource associated with this access token. Null when * * @remarks * the token has no associated resource. */ export type Resource = { /** * The type of resource associated with the access token, e.g. `Company` for a company-level token or `Oauth::Application` for a system-level token. * * @remarks */ type?: string | undefined; /** * The UUID of the associated resource */ uuid?: string | undefined; }; /** * The type of resource owner: * * @remarks * - `CompanyAdmin`: A company administrator * - `Employee`: An employee * - `Contractor`: A contractor */ export const TokenInfoType = { CompanyAdmin: "CompanyAdmin", Employee: "Employee", Contractor: "Contractor", } as const; /** * The type of resource owner: * * @remarks * - `CompanyAdmin`: A company administrator * - `Employee`: An employee * - `Contractor`: A contractor */ export type TokenInfoType = ClosedEnum; /** * The resource owner (user) who authorized this access token. Null for * * @remarks * system-level tokens or when the owner cannot be determined. */ export type ResourceOwner = { /** * The type of resource owner: * * @remarks * - `CompanyAdmin`: A company administrator * - `Employee`: An employee * - `Contractor`: A contractor */ type?: TokenInfoType | undefined; /** * The UUID of the resource owner */ uuid?: string | undefined; }; export type TokenInfo = { /** * Space-separated list of OAuth scopes granted to this access token. * * @remarks */ scope?: string | undefined; /** * The resource associated with this access token. Null when * * @remarks * the token has no associated resource. */ resource?: Resource | null | undefined; /** * The resource owner (user) who authorized this access token. Null for * * @remarks * system-level tokens or when the owner cannot be determined. */ resourceOwner?: ResourceOwner | null | undefined; }; /** @internal */ export const Resource$inboundSchema: z.ZodType< Resource, z.ZodTypeDef, unknown > = z.object({ type: z.string().optional(), uuid: z.string().optional(), }); export function resourceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Resource$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Resource' from JSON`, ); } /** @internal */ export const TokenInfoType$inboundSchema: z.ZodNativeEnum< typeof TokenInfoType > = z.nativeEnum(TokenInfoType); /** @internal */ export const ResourceOwner$inboundSchema: z.ZodType< ResourceOwner, z.ZodTypeDef, unknown > = z.object({ type: TokenInfoType$inboundSchema.optional(), uuid: z.string().optional(), }); export function resourceOwnerFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResourceOwner$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResourceOwner' from JSON`, ); } /** @internal */ export const TokenInfo$inboundSchema: z.ZodType< TokenInfo, z.ZodTypeDef, unknown > = z.object({ scope: z.string().optional(), resource: z.nullable(z.lazy(() => Resource$inboundSchema)).optional(), resource_owner: z.nullable(z.lazy(() => ResourceOwner$inboundSchema)) .optional(), }).transform((v) => { return remap$(v, { "resource_owner": "resourceOwner", }); }); export function tokenInfoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TokenInfo$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TokenInfo' from JSON`, ); }