import axios, { AxiosInstance, AxiosResponse } from 'axios'; import { GlobalCredentialsHandler } from './credentials-handler'; import type { BotDetail, Me, OAuth, ProviderAccountEntry } from './interfaces'; interface IntegrationResponse { detail: string; provider_account: { id: string; bot_id: string; provider: string; name: string; username: string; phone_number: string | null; credentials: string | null; credentials_json: any; netlify_url: string; is_playground: boolean; is_whatsapp_cloud: boolean; created_by_id: string; chat_count: number; is_active: boolean; is_test: boolean; imp_id: string; is_preview: boolean; }; netlify_url: string | null; } interface BotonicAPIServiceConfig { projectRoot?: string; /** Monorepo/workspace root. When set, global credentials are stored at workspaceRoot/.botonic/env-credentials.json (source of truth). */ workspaceRoot?: string; environmentVariables?: Record; targetEnvironment?: string; } export declare class BotonicAPIService { clientId: string; baseUrl: string; loginUrl: string; private botsRegistryHandler; globalCredentialsHandler: InstanceType; oauth?: OAuth; private _tokenExpiresAt?; me?: Me; /** Cached from credentials for display when me is not loaded yet. */ loggedUserName?: string; loggedEnvironmentUrl?: string; bot: BotDetail | null; headers: { [key: string]: any; set(headerName?: string, value?: axios.AxiosHeaderValue, rewrite?: boolean | (string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean))): /*elided*/ any; set(headers?: axios.RawAxiosHeaders | /*elided*/ any | string, rewrite?: boolean): /*elided*/ any; get(headerName: string, parser: RegExp): RegExpExecArray | null; get(headerName: string, matcher?: true | ((this: /*elided*/ any, value: axios.AxiosHeaderValue, header: string) => any)): axios.AxiosHeaderValue; has(header: string, matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): boolean; delete(header: string | string[], matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): boolean; clear(matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): boolean; normalize(format: boolean): /*elided*/ any; concat(...targets: Array): /*elided*/ any; toJSON(asStrings?: boolean): axios.RawAxiosHeaders; setContentType(value: axios.AxiosHeaderValue, rewrite?: boolean | (string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean))): /*elided*/ any; getContentType(parser?: RegExp): RegExpExecArray | null; getContentType(matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): axios.AxiosHeaderValue; hasContentType(matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): boolean; setContentLength(value: axios.AxiosHeaderValue, rewrite?: boolean | (string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean))): /*elided*/ any; getContentLength(parser?: RegExp): RegExpExecArray | null; getContentLength(matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): axios.AxiosHeaderValue; hasContentLength(matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): boolean; setAccept(value: axios.AxiosHeaderValue, rewrite?: boolean | (string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean))): /*elided*/ any; getAccept(parser?: RegExp): RegExpExecArray | null; getAccept(matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): axios.AxiosHeaderValue; hasAccept(matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): boolean; setUserAgent(value: axios.AxiosHeaderValue, rewrite?: boolean | (string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean))): /*elided*/ any; getUserAgent(parser?: RegExp): RegExpExecArray | null; getUserAgent(matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): axios.AxiosHeaderValue; hasUserAgent(matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): boolean; setContentEncoding(value: axios.AxiosHeaderValue, rewrite?: boolean | (string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean))): /*elided*/ any; getContentEncoding(parser?: RegExp): RegExpExecArray | null; getContentEncoding(matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): axios.AxiosHeaderValue; hasContentEncoding(matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): boolean; setAuthorization(value: axios.AxiosHeaderValue, rewrite?: boolean | (string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean))): /*elided*/ any; getAuthorization(parser?: RegExp): RegExpExecArray | null; getAuthorization(matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): axios.AxiosHeaderValue; hasAuthorization(matcher?: string | RegExp | ((this: /*elided*/ any, value: string, name: string) => boolean)): boolean; getSetCookie(): string[]; [Symbol.iterator](): IterableIterator<[string, axios.AxiosHeaderValue]>; }; apiClient: AxiosInstance; projectRoot?: string; targetEnvironment?: string; constructor(config?: BotonicAPIServiceConfig); saveAllCredentials(): void; botInfo(): BotDetail; getOauth(): OAuth; isAuthenticated(): boolean; ensureAuthenticated(): Promise; setCurrentBot(bot: BotDetail | null): void; selectBot(bot: BotDetail): Promise; private loadGlobalCredentials; /** * Returns store as env -> credentials. Migrates old single-credential format to { local: creds }. */ private normalizeCredentialsStore; private loadBotFromRegistry; private saveToBotsRegistry; saveProviders(providers: ProviderAccountEntry[]): void; fetchProviders(botId: string): Promise; saveBotEntry(bot: BotDetail): void; private setHeaders; private saveGlobalCredentials; private refreshToken; login(email: string, password: string): Promise; logout(): Promise; /** * Ensures me is loaded (for display). Call before showing "Working as ...". */ ensureMeLoaded(): Promise; /** * Display name for the logged-in user (for "Working as X in environment ..."). */ getDisplayName(): string; createWebchatIntegration(botId: string, integrationName: string): Promise>; signup(email: string, password: string, orgName: string, campaign: any): Promise; createBot(botName: string, isTest?: boolean): Promise; getBots(): Promise; deleteBot(botId: string): Promise; getProviders(botId?: string): Promise; deployBot(bundlePath: string, botConfigJson: any): Promise; deployStatus(deployId: string): Promise; build({ projectRoot, projectName, }: { projectRoot: string; projectName: string; }): Promise; private prepareLambda; private apiPost; private apiGet; private apiDelete; private apiPut; registerDevSessionWhatsapp(botId: string, chatProviderId: string, devSessionUrl: string, lambdaFunctionName: string, botConfig?: object): Promise; registerDevSessionWebchat(botId: string, chatProviderId: string, devSessionUrl: string, lambdaFunctionName: string, botConfig?: object): Promise; unregisterDevSessionWhatsapp(botId: string, chatProviderId: string): Promise; unregisterDevSessionWebchat(botId: string, chatProviderId: string): Promise; refreshTokenIfNeeded(): Promise; private getMe; private validateToken; private isTokenExpired; private getHeaders; } export {};