/* * 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"; export type Credentials = { /** * Telegram bot token issued by BotFather. It is encrypted at rest and is never returned by the API. */ botToken: string; }; export const CreateTelegramAgentConnectorRequestMode = { Allowlist: "allowlist", } as const; export type CreateTelegramAgentConnectorRequestMode = ClosedEnum< typeof CreateTelegramAgentConnectorRequestMode >; /** * The explicit Telegram chat allowlist permitted to invoke the agent. */ export type CreateTelegramAgentConnectorRequestAccess = { mode: CreateTelegramAgentConnectorRequestMode; chatIds: Array; }; export type CreateTelegramAgentConnectorRequest = { /** * Telegram Bot API connector. Supports text, photos up to the Bot API's 20 MiB download limit, gateway-supported documents, and response feedback through native thumbs reactions. */ provider: "telegram"; name?: string | undefined; credentials: Credentials; /** * The explicit Telegram chat allowlist permitted to invoke the agent. */ access: CreateTelegramAgentConnectorRequestAccess; /** * Always true: Telegram discards updates queued before this tenancy's webhook is registered. */ dropPendingUpdates?: true | undefined; }; /** @internal */ export const Credentials$inboundSchema: z.ZodType< Credentials, z.ZodTypeDef, unknown > = z.object({ bot_token: z.string(), }).transform((v) => { return remap$(v, { "bot_token": "botToken", }); }); /** @internal */ export type Credentials$Outbound = { bot_token: string; }; /** @internal */ export const Credentials$outboundSchema: z.ZodType< Credentials$Outbound, z.ZodTypeDef, Credentials > = z.object({ botToken: z.string(), }).transform((v) => { return remap$(v, { botToken: "bot_token", }); }); export function credentialsToJSON(credentials: Credentials): string { return JSON.stringify(Credentials$outboundSchema.parse(credentials)); } export function credentialsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Credentials$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Credentials' from JSON`, ); } /** @internal */ export const CreateTelegramAgentConnectorRequestMode$inboundSchema: z.ZodNativeEnum = z .nativeEnum(CreateTelegramAgentConnectorRequestMode); /** @internal */ export const CreateTelegramAgentConnectorRequestMode$outboundSchema: z.ZodNativeEnum = CreateTelegramAgentConnectorRequestMode$inboundSchema; /** @internal */ export const CreateTelegramAgentConnectorRequestAccess$inboundSchema: z.ZodType< CreateTelegramAgentConnectorRequestAccess, z.ZodTypeDef, unknown > = z.object({ mode: CreateTelegramAgentConnectorRequestMode$inboundSchema, chat_ids: z.array(z.number().int()), }).transform((v) => { return remap$(v, { "chat_ids": "chatIds", }); }); /** @internal */ export type CreateTelegramAgentConnectorRequestAccess$Outbound = { mode: string; chat_ids: Array; }; /** @internal */ export const CreateTelegramAgentConnectorRequestAccess$outboundSchema: z.ZodType< CreateTelegramAgentConnectorRequestAccess$Outbound, z.ZodTypeDef, CreateTelegramAgentConnectorRequestAccess > = z.object({ mode: CreateTelegramAgentConnectorRequestMode$outboundSchema, chatIds: z.array(z.number().int()), }).transform((v) => { return remap$(v, { chatIds: "chat_ids", }); }); export function createTelegramAgentConnectorRequestAccessToJSON( createTelegramAgentConnectorRequestAccess: CreateTelegramAgentConnectorRequestAccess, ): string { return JSON.stringify( CreateTelegramAgentConnectorRequestAccess$outboundSchema.parse( createTelegramAgentConnectorRequestAccess, ), ); } export function createTelegramAgentConnectorRequestAccessFromJSON( jsonString: string, ): SafeParseResult< CreateTelegramAgentConnectorRequestAccess, SDKValidationError > { return safeParse( jsonString, (x) => CreateTelegramAgentConnectorRequestAccess$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CreateTelegramAgentConnectorRequestAccess' from JSON`, ); } /** @internal */ export const CreateTelegramAgentConnectorRequest$inboundSchema: z.ZodType< CreateTelegramAgentConnectorRequest, z.ZodTypeDef, unknown > = z.object({ provider: z.literal("telegram"), name: z.string().optional(), credentials: z.lazy(() => Credentials$inboundSchema), access: z.lazy(() => CreateTelegramAgentConnectorRequestAccess$inboundSchema), drop_pending_updates: z.literal(true).default(true), }).transform((v) => { return remap$(v, { "drop_pending_updates": "dropPendingUpdates", }); }); /** @internal */ export type CreateTelegramAgentConnectorRequest$Outbound = { provider: "telegram"; name?: string | undefined; credentials: Credentials$Outbound; access: CreateTelegramAgentConnectorRequestAccess$Outbound; drop_pending_updates: true; }; /** @internal */ export const CreateTelegramAgentConnectorRequest$outboundSchema: z.ZodType< CreateTelegramAgentConnectorRequest$Outbound, z.ZodTypeDef, CreateTelegramAgentConnectorRequest > = z.object({ provider: z.literal("telegram"), name: z.string().optional(), credentials: z.lazy(() => Credentials$outboundSchema), access: z.lazy(() => CreateTelegramAgentConnectorRequestAccess$outboundSchema ), dropPendingUpdates: z.literal(true).default(true as const), }).transform((v) => { return remap$(v, { dropPendingUpdates: "drop_pending_updates", }); }); export function createTelegramAgentConnectorRequestToJSON( createTelegramAgentConnectorRequest: CreateTelegramAgentConnectorRequest, ): string { return JSON.stringify( CreateTelegramAgentConnectorRequest$outboundSchema.parse( createTelegramAgentConnectorRequest, ), ); } export function createTelegramAgentConnectorRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateTelegramAgentConnectorRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateTelegramAgentConnectorRequest' from JSON`, ); }