import { ChatMessage } from './types/messages.js'; import { CoachListFilters } from './types/gateway.js'; import { ReactNativeFile } from 'apollo-upload-client'; import { Subscription } from 'zen-observable-ts'; import * as _apollo_client_core from '@apollo/client/core'; import { FetchPolicy, OperationVariables, QueryOptions, ApolloQueryResult, MutationOptions, FetchResult, SubscriptionOptions, WatchQueryOptions, ObservableQuery } from '@apollo/client/core'; import { Observable } from '@apollo/client/utilities'; import { NewMessageSubscription } from './generated/graphql.js'; interface NaluriChatLoginOptions { authorizationCode: string; } interface TokenPayload { accessToken: string; expiresIn: number; idToken: string; refreshToken: string; tokenType: 'Bearer'; } interface AccountUser { id: string; referenceId: string; tenantId: string; name: string; country: string; claims: Record; email: string; codeId: string; couponId: string; subscriptionId: string; preferredLanguage: string; deletedAt: Date | null; insertedAt: Date; updatedAt: Date; chatUserId?: string; } interface NaluriChatLoginResponse extends TokenPayload { user: AccountUser; } interface NaluriChatRefreshTokenOptions { refreshToken: string; } type NaluriChatRefreshTokenResponse = TokenPayload; interface NaluriChatLogoutOptions { refreshToken: string; } interface CoachProfile { id: string; userId: string; name?: string; photo?: string; coachRole?: string; bio?: string; country?: string; experience?: string; education?: string; roomId?: string; isMainCoach?: boolean; isLeadCoach?: boolean; status: string; [key: string]: any; } interface UserProfile { id: string; reference: string; userId: string; channels?: string[]; metadata?: MetadataInput[] | undefined; } interface AccountOptions { apiKey: string; apiUrl: string; timeoutMs?: number; onRefreshTokenError?: () => void | Promise; } declare class AccountApi { private userId; private userReference; private apiKey; private apiUrl; constructor(opts: AccountOptions); login(authorizationCode: string): Promise; refresh(refreshToken: string): Promise; logout(refreshToken: string): Promise; getUserId(): string; getUserReference(): string; getApiUrl(): string; getApiKey(): string; protected getHeaders(): { "x-api-key": string; Accept: string; 'Content-Type': string; 'User-Agent': string; 'x-nl-sdk-version': string; }; } interface AuthTokens { accessToken: string; refreshToken: string; } interface ChatApiOptions { accountApi: AccountApi; onRefreshTokenError?: () => Promise; refreshTokens?: () => Promise; requestPolicy?: FetchPolicy; subscriptionListener?: () => void; } declare class ChatApi { private readonly accountApi; private client; private onRefreshTokenError?; constructor(opts: ChatApiOptions); query>(options: QueryOptions): Promise>; mutate>(options: MutationOptions): Promise>; subscribe>(options: SubscriptionOptions): Observable>; refetch>(options: WatchQueryOptions): ObservableQuery; unSubscribeAll(): void; } declare const chatCache: _apollo_client_core.InMemoryCache; declare class EventsApi { private readonly queue; private readonly FLUSH_INTERVAL; private flushed; private intervalId; private userId; private apiUrl; init(userId: any, apiUrl: any): void; isReady(): boolean; identify(traits?: Record): void; track(event: EVENTS, properties?: Record): void; private flush; private getDefaultHeaders; cleanup(): void; } declare const EVENTS: { readonly LOGIN: "login"; readonly REFRESH: "refresh"; readonly LOGOUT: "logout"; readonly SEND_TEXT_MESSAGE: "send_text_message"; readonly SEND_IMAGE_MESSAGE: "send_image_message"; readonly SEND_FILE_MESSAGE: "send_file_message"; readonly GET_CHANNEL_MESSAGES: "get_channel_messages"; readonly GET_CHANNELS: "get_channels"; readonly GET_CHANNEL: "get_channel"; readonly GET_MESSAGE: "get_message"; readonly GET_COACH_PROFILE: "get_coach_profile"; readonly GET_COACHES: "get_coaches"; readonly MARK_MESSAGE_AS_READ: "mark_message_as_read"; readonly LOGIN_ERROR: "login_error"; readonly LOGOUT_ERROR: "logout_error"; readonly REFRESH_ERROR: "refresh_error"; readonly SEND_TEXT_MESSAGE_ERROR: "send_text_message_error"; readonly SEND_IMAGE_MESSAGE_ERROR: "send_image_message_error"; readonly SEND_FILE_MESSAGE_ERROR: "send_file_message_error"; readonly GET_CHANNEL_MESSAGES_ERROR: "get_channel_messages_error"; readonly GET_CHANNELS_ERROR: "get_channels_error"; readonly GET_CHANNEL_ERROR: "get_channel_error"; readonly GET_MESSAGE_ERROR: "get_message_error"; readonly GET_COACH_PROFILE_ERROR: "get_coach_profile_error"; readonly GET_COACHES_ERROR: "get_coaches_error"; readonly CHANNEL_SUBSCRIPTION_ERROR: "channel_subscription_error"; readonly CHANNEL_LISTING_SUBSCRIPTION_ERROR: "channel_listing_subscription_error"; readonly CHANNEL_ACTING_COACH_INJECTION_ERROR: "channel_acting_coach_injection_error"; }; type EVENTS = (typeof EVENTS)[keyof typeof EVENTS]; interface GatewayApiOptions { apiUrl: string; apiKey: string; accountApi: AccountApi; timeoutMs?: number; onRefreshTokenError?: () => void | Promise; } declare class GatewayApi { private readonly apiUrl; private readonly apiKey; private readonly accountApi; private onRefreshTokenError?; constructor(opts: GatewayApiOptions); getCoachList(filters?: CoachListFilters): Promise; protected getHeaders(): { "x-api-key": string; Accept: string; 'Content-Type': string; 'User-Agent': string; 'x-nl-sdk-version': string; }; } declare const ChannelType: { readonly CHANNEL: "channel"; readonly NOTES: "notes"; readonly SLEEP: "sleep"; readonly FOOD: "food"; readonly THOUGHT: "thought"; readonly LESSON: "lesson"; readonly GROUP: "group"; }; type ChannelType = (typeof ChannelType)[keyof typeof ChannelType]; interface ChannelUser { id: string; reference: string; userId: string; metadata?: MetadataInput[]; } interface Channel { id: string; name: string; type: ChannelType; lastMessageId?: string; status?: string; createdAt: Date; updatedAt: Date; unreadCount: number; chat?: Partial; users: ChannelUser[]; metadata?: MetadataInput[]; } interface ChatChannelOptions { chatClient: ChatApi; gatewayClient: GatewayApi; accountClient: AccountApi; eventsClient?: EventsApi; roomId?: string; senderId?: string; lastKey?: string; lastKeys: Map; } interface GetMessagesParams { limit?: number; after?: string; } interface GetMessagesResponse { roomId: string; count: number; lastKey?: string; chats: ChatMessage[] | []; } interface SendTextMessageParams { message: string; replyTo?: string; } interface SubscriptionObserver { start?: (subscription: Subscription) => void; next: (value: T) => void; error?: (error: any) => void; complete?: () => void; } interface NewMessageData { data: NewMessageSubscription; } type SubscriptionCallback = ({ data, error, connected, }: { data?: TData; error?: Error; connected?: boolean; }) => void; interface SendMediaMessageParams { file: ReactNativeFile | any; replyTo?: string; } type MetadataInput = { key: string; value: string; }; type GetIndividualMessageParam = { id: string; roomId?: string; }; type NaluriLogout = { success: boolean; }; export { AccountApi as A, type ChatChannelOptions as C, type GetMessagesParams as G, type MetadataInput as M, type NaluriChatLoginOptions as N, type SendTextMessageParams as S, type TokenPayload as T, type UserProfile as U, type Channel as a, type GetMessagesResponse as b, type GetIndividualMessageParam as c, type SendMediaMessageParams as d, type SubscriptionCallback as e, type AccountUser as f, type NaluriLogout as g, type CoachProfile as h, type NaluriChatLoginResponse as i, type NaluriChatRefreshTokenOptions as j, type NaluriChatRefreshTokenResponse as k, type NaluriChatLogoutOptions as l, ChannelType as m, type ChannelUser as n, type SubscriptionObserver as o, type NewMessageData as p, type AccountOptions as q, type AuthTokens as r, type ChatApiOptions as s, ChatApi as t, chatCache as u, type GatewayApiOptions as v, GatewayApi as w };