/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { safeParse } from "../lib/schemas.js"; import * as openEnums from "../types/enums.js"; import { OpenEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import * as types from "../types/primitives.js"; import { ChannelName, ChannelName$inboundSchema } from "./channel-name.js"; import { ChannelScope, ChannelScope$inboundSchema } from "./channel-scope.js"; import { SDKValidationError } from "./errors/sdk-validation-error.js"; export const ChannelLinkResponseMode = { User: "user", Guild: "guild", } as const; export type ChannelLinkResponseMode = OpenEnum; export const ChannelLinkResponsePrivacy = { Public: "public", Private: "private", } as const; export type ChannelLinkResponsePrivacy = OpenEnum< typeof ChannelLinkResponsePrivacy >; export const Type = { Redirect: "redirect", Websocket: "websocket", Oauth: "oauth", } as const; export type Type = OpenEnum; export type Action = { type?: Type | undefined; label?: string | undefined; url?: string | null | undefined; socket?: string | undefined; command?: string | undefined; }; export type ChannelLinkResponse = { /** * Short-lived linking code (10 min TTL) */ code: string; channel: ChannelName; userAddress: string; agentWallet: string; /** * Channel route scope. Local scope requires haiId. */ scope: ChannelScope; haiId?: string | undefined; agentName?: string | undefined; mode?: ChannelLinkResponseMode | undefined; privacy?: ChannelLinkResponsePrivacy | undefined; /** * Unix timestamp (ms) */ createdAt: number; /** * Unix timestamp (ms) */ expiresAt: number; /** * URL the user should visit to complete linking */ url?: string | null | undefined; action?: Action | undefined; }; /** @internal */ export const ChannelLinkResponseMode$inboundSchema: z.ZodMiniType< ChannelLinkResponseMode, unknown > = openEnums.inboundSchema(ChannelLinkResponseMode); /** @internal */ export const ChannelLinkResponsePrivacy$inboundSchema: z.ZodMiniType< ChannelLinkResponsePrivacy, unknown > = openEnums.inboundSchema(ChannelLinkResponsePrivacy); /** @internal */ export const Type$inboundSchema: z.ZodMiniType = openEnums .inboundSchema(Type); /** @internal */ export const Action$inboundSchema: z.ZodMiniType = z.object({ type: types.optional(Type$inboundSchema), label: types.optional(types.string()), url: z.optional(z.nullable(types.string())), socket: types.optional(types.string()), command: types.optional(types.string()), }); export function actionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Action$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Action' from JSON`, ); } /** @internal */ export const ChannelLinkResponse$inboundSchema: z.ZodMiniType< ChannelLinkResponse, unknown > = z.object({ code: types.string(), channel: ChannelName$inboundSchema, userAddress: types.string(), agentWallet: types.string(), scope: ChannelScope$inboundSchema, haiId: types.optional(types.string()), agentName: types.optional(types.string()), mode: types.optional(ChannelLinkResponseMode$inboundSchema), privacy: types.optional(ChannelLinkResponsePrivacy$inboundSchema), createdAt: types.number(), expiresAt: types.number(), url: z.optional(z.nullable(types.string())), action: types.optional(z.lazy(() => Action$inboundSchema)), }); export function channelLinkResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ChannelLinkResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChannelLinkResponse' from JSON`, ); }