/// import { AxiosRequestConfig } from 'axios'; import { AxiosResponse } from 'axios'; import { EventEmitter } from 'events'; import { FetchInfiniteQueryOptions } from 'react-query/core'; import { MutationKey as MutationKey_2 } from 'react-query/core'; import { MutationOptions } from 'react-query/core'; import { QueryClient } from 'react-query/core'; import { QueryKey as QueryKey_2 } from 'react-query/core'; /** @beta */ export declare type ActivityPage = { activity: unknown[]; cursor?: string; }; /** @beta */ export declare type App = { [key: string]: unknown; }; /** @beta */ export declare type AppsPage = { apps: App[]; cursor?: string; }; /** @beta */ export declare type AskResponse = { actions?: string[]; suggestions?: string[]; prompt?: PromptResponse; text: string; }; /** @beta */ declare class Client { readonly queryClient: QueryClient; readonly httpClient: HttpClient; readonly wsClient: WsClient; constructor(options: ClientOptions); /** * Invoke a query * * @param queryKey - The query key (must be pre-defined) * @param options - Any additional query options * @returns The query result * * @beta */ /** * Invoke a query * * @param queryKey - The query key (must be pre-defined) * @param options - Any additional query options * @returns The query result * * @beta */ query(queryKey: QueryKey, options?: FetchInfiniteQueryOptions): Promise; /** * Invoke a custom query (should be used sparingly and never in production) * * @param queryKey - A unique cache key * @param options - Any additional query options * @returns The query result * * @beta */ /** * Invoke a custom query (should be used sparingly and never in production) * * @param queryKey - A unique cache key * @param options - Any additional query options * @returns The query result * * @beta */ customQuery(queryKey: QueryKey_2, options?: FetchInfiniteQueryOptions): Promise; /** * Invoke a mutation * * @param mutationKey - The mutation key (must be pre-defined) * @param variables - The appropriate variables * @param options - Any additional mutation options * @returns The mutation result * * @beta */ /** * Invoke a mutation * * @param mutationKey - The mutation key (must be pre-defined) * @param variables - The appropriate variables * @param options - Any additional mutation options * @returns The mutation result * * @beta */ mutate(mutationKey: MutationKey, variables?: M['TVariables'], options?: MutationOptions): Promise; /** * Invoke a custom mutation (should be used sparingly and never in production) * * @param mutationKey - A unique cache key * @param variables - The appropriate variables * @param options - Any additional mutation options * @returns The mutation result * * @beta */ /** * Invoke a custom mutation (should be used sparingly and never in production) * * @param mutationKey - A unique cache key * @param variables - The appropriate variables * @param options - Any additional mutation options * @returns The mutation result * * @beta */ customMutate(mutationKey: MutationKey_2, variables?: TVariables, options?: MutationOptions): Promise; } export default Client; /** @beta */ export declare type ClientOptions = { context: PartialContext | (() => Promise); queryClient?: QueryClient; httpClient?: HttpClient; wsClient?: WsClient; }; /** @beta */ export declare type Context = { token: string; apiHost: string; wssHost: string; userAgent: string; clientAgent: string; }; /** * Attach a default select callback to normalize data * (We always use infinite query and the flatten the page data) * * @param options - The query defaults options * @returns The query defaults options (with default select) * * @internal */ export declare function _defaultSelect(options: O): { select(data: Q['TQueryData']): unknown; } & O; /** @beta */ export declare type DiscoverPage = { items: Record[]; }; /** @beta */ export declare type Flags = { [key: string]: boolean | string | number | null; }; /** * @beta */ export declare class HttpClient { private context; private instance; constructor({ context }: { context: () => Promise; }); /** * Create a new instance of axios with request and response interceptors. * Populate the baseURL and headers from the context, directly return the response data. */ private createInstance; /** * Make an http get request * * @param url - The request url * @param config - Additional request config * @returns The response data * * @beta */ get(url: string, config?: AxiosRequestConfig): Promise>; /** * Make an http post request * * @param url - The request url * @param data - The request payload * @param config - Additional request config * @returns The response data * * @beta */ post(url: string, data?: unknown, config?: AxiosRequestConfig): Promise>; /** * Make an http put request * * @param url - The request url * @param data - The request payload * @param config - Additional request config * @returns The response data * * @beta */ put(url: string, data?: unknown, config?: AxiosRequestConfig): Promise>; /** * Make an http delete request * * @param url - The request url * @param config - Additional request config * @returns The response data * * @beta */ delete(url: string, config?: AxiosRequestConfig): Promise>; } /** @beta */ declare type Location_2 = 'toknow' | 'todo'; export { Location_2 as Location } /** @beta */ export declare type Me = { id: string; displayName: string; }; /** @beta */ export declare type Mutation = { TMutationKey: TMutationKey; TVariables: TVariables; TContext: TContext; TError: TError; TData: TData; }; /** @beta */ export declare type MutationKey = Q['TMutationKey'] extends string | [string] ? K | [K] : Q['TMutationKey'] extends [string, ...infer R] ? [K, ...R] : never; /** This interface is populated inline as mutation defaults are applied * * @beta */ export declare interface Mutations { } /** @beta */ export declare interface Mutations { actionNotification: Mutation<['actionNotification'], { spaceId: string; id: string; data?: unknown; }, Notification_2>; } /** @beta */ export declare interface Mutations { deleteNotification: Mutation<['deleteNotification'], { spaceId: string; id: string; }, Notification_2>; } /** @beta */ export declare interface Mutations { graphql: Mutation<['graphql'], { query: string; variables: unknown; }, unknown>; } /** @beta */ export declare interface Mutations { notificationViewed: Mutation<['notificationViewed'], { spaceId: string; id: string; }, Notification_2>; } /** @beta */ export declare interface Mutations { notificationDetailViewed: Mutation<['notificationDetailViewed'], { spaceId: string; id: string; }, Notification_2>; } /** @beta */ declare type Notification_2 = { [key: string]: unknown; }; export { Notification_2 as Notification } /** @beta */ export declare type NotificationsPage = { notifications: Notification_2[]; cursor?: string; }; /** @beta */ export declare type PartialContext = (Pick & { clientAgent?: string; } & { apiHost: string; wssHost?: string; }) | (Pick & { clientAgent?: string; } & { companyCode: string; }); /** @beta */ export declare type PromptResponse = { botId: string; botAliasId: string; appId?: string; type: string; }; /** This interface is populated inline as query defaults are applied * * @beta */ export declare interface Queries { } /** @beta */ export declare interface Queries { getSpaces: Query<['getSpaces'], Spaces>; } /** @beta */ export declare interface Queries { me: Query<['me'], Me>; } /** @beta */ export declare interface Queries { discover: Query<['discover', { spaceId: string; }], DiscoverPage, unknown, DiscoverPage['items']>; } /** @beta */ export declare interface Queries { getFlags: Query<['getFlags', { spaceId: string; }], Flags>; } /** @beta */ export declare interface Queries { getNotifications: Query<[ 'getNotifications', { spaceId: string; location: Location_2; limit?: number; } ], NotificationsPage, unknown, NotificationsPage['notifications']>; } /** @beta */ export declare interface Queries { getNotification: Query<['getNotification', { spaceId: string; id: string; }], Notification_2>; } /** @beta */ export declare interface Queries { getNotificationDetail: Query<['getNotificationDetail', { spaceId: string; id: string; }], Notification_2>; } /** @beta */ export declare interface Queries { getActivity: Query<[ 'getActivity', { spaceId: string; limit?: number; } ], ActivityPage, unknown, ActivityPage['activity']>; } /** @beta */ export declare interface Queries { getApps: Query<['getApps', { spaceId: string; limit?: number; }], AppsPage, unknown, AppsPage['apps']>; } /** @beta */ export declare interface Queries { ask: Query<[ 'ask', { spaceId: string; utterance: string; channel: string; locale: string; appId?: string; botId?: string; botAliasId?: string; } ], AskResponse>; } /** * Support a string, or an array with one item, if given a string or single item array (otherwise return K) * TODO: Can we determine if everything after the first value is optional, and accept a single string then? * * @beta */ /** @beta */ export declare type Query = { TQueryKey: TQueryKey; TQueryFnData: TQueryFnData; TQueryData: TQueryData; TError: TError; TData: TData; }; /** @beta */ export declare type QueryKey = Q['TQueryKey'] extends string | [string] ? K | [K] : Q['TQueryKey'] extends [string, ...infer R] ? [K, ...R] : never; /** @beta */ export declare type Spaces = { id: string; name: string; default: boolean; }[]; /** * @beta */ export declare class WsClient { private context; private emitter; private connection?; private pingInterval; constructor({ context, pingInterval }: { context: () => Promise; pingInterval?: number; }); /** * Create a new websocket connection (singleton) * * @param options - The connect options */ private connect; /** * Listen to events for the given trigger * * @param connect - The connect options * @param trigger - The event name * @param callback - The event listener * @returns An unsubscribe method * * @beta */ subscribe(connect: { spaceId: string; }, trigger: string, callback: (...args: unknown[]) => void): () => EventEmitter; /** * Publish an event * * @param connect - The connect options * @param type - The event type * @param data - The event payload * * @beta */ publish(connect: { spaceId: string; }, type: string, data?: unknown): void; } export { }