/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 67a47f034b53 */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type AuthToken = { accessToken: string; datasource: string; scope?: string | undefined; tokenType?: string | undefined; /** * Used by Google to indicate the index of the logged in user. Useful for generating hyperlinks that support multilogin. */ authUser?: string | undefined; /** * Unix timestamp when this token expires (in seconds since epoch UTC). */ expiration?: number | undefined; }; /** @internal */ export const AuthToken$inboundSchema: z.ZodType< AuthToken, z.ZodTypeDef, unknown > = z.object({ accessToken: z.string(), datasource: z.string(), scope: z.string().optional(), tokenType: z.string().optional(), authUser: z.string().optional(), expiration: z.number().int().optional(), }); /** @internal */ export type AuthToken$Outbound = { accessToken: string; datasource: string; scope?: string | undefined; tokenType?: string | undefined; authUser?: string | undefined; expiration?: number | undefined; }; /** @internal */ export const AuthToken$outboundSchema: z.ZodType< AuthToken$Outbound, z.ZodTypeDef, AuthToken > = z.object({ accessToken: z.string(), datasource: z.string(), scope: z.string().optional(), tokenType: z.string().optional(), authUser: z.string().optional(), expiration: z.number().int().optional(), }); export function authTokenToJSON(authToken: AuthToken): string { return JSON.stringify(AuthToken$outboundSchema.parse(authToken)); } export function authTokenFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AuthToken$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AuthToken' from JSON`, ); }