/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: cd59afe310c0 */ 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 SessionInfo = { /** * A unique token for this session. A new session (and token) is created when the user issues a request from a new tab or when our server hasn't seen activity for more than 10 minutes from a tab. */ sessionTrackingToken?: string | undefined; /** * A unique id for all requests a user makes from a given tab, no matter how far apart. A new tab id is only generated when a user issues a request from a new tab. */ tabId?: string | undefined; /** * The last time the server saw this token. */ lastSeen?: Date | undefined; /** * The last query seen by the server. */ lastQuery?: string | undefined; }; /** @internal */ export const SessionInfo$inboundSchema: z.ZodType< SessionInfo, z.ZodTypeDef, unknown > = z.object({ sessionTrackingToken: z.string().optional(), tabId: z.string().optional(), lastSeen: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), lastQuery: z.string().optional(), }); /** @internal */ export type SessionInfo$Outbound = { sessionTrackingToken?: string | undefined; tabId?: string | undefined; lastSeen?: string | undefined; lastQuery?: string | undefined; }; /** @internal */ export const SessionInfo$outboundSchema: z.ZodType< SessionInfo$Outbound, z.ZodTypeDef, SessionInfo > = z.object({ sessionTrackingToken: z.string().optional(), tabId: z.string().optional(), lastSeen: z.date().transform(v => v.toISOString()).optional(), lastQuery: z.string().optional(), }); export function sessionInfoToJSON(sessionInfo: SessionInfo): string { return JSON.stringify(SessionInfo$outboundSchema.parse(sessionInfo)); } export function sessionInfoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SessionInfo$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SessionInfo' from JSON`, ); }