@greatapps/greatchat-ui 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { ClassValue } from 'clsx';
2
+ import * as _tanstack_react_query from '@tanstack/react-query';
3
+ import * as _tanstack_query_core from '@tanstack/query-core';
2
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
5
 
4
6
  interface ApiResponse<T> {
@@ -147,6 +149,244 @@ declare function groupMessagesByDate(messages: InboxMessage[]): {
147
149
  declare function formatDateGroup(dateStr: string): string;
148
150
  declare function formatMessageTime(dateStr: string): string;
149
151
 
152
+ interface GchatHookConfig {
153
+ accountId: number;
154
+ token: string;
155
+ baseUrl: string;
156
+ language?: string;
157
+ idWl?: number;
158
+ }
159
+ declare const DEFAULT_INBOX_POLLING = 5000;
160
+ declare const DEFAULT_MESSAGES_POLLING = 3000;
161
+ declare const DEFAULT_CHANNEL_STATUS_POLLING = 5000;
162
+ declare const DEFAULT_QR_POLLING = 2000;
163
+
164
+ declare function useInboxes(config: GchatHookConfig, statusFilter?: string, pollingInterval?: number): _tanstack_react_query.UseQueryResult<Inbox[], Error>;
165
+ declare function useInbox(config: GchatHookConfig, id: number | null): _tanstack_react_query.UseQueryResult<Inbox, Error>;
166
+ declare function useInboxStats(config: GchatHookConfig, pollingInterval?: number): _tanstack_react_query.UseQueryResult<InboxStats, Error>;
167
+ declare function useCreateInbox(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<Inbox>, Error, {
168
+ id_channel: number;
169
+ id_contact: number;
170
+ }, unknown>;
171
+ declare function useUpdateInbox(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<Inbox>, Error, {
172
+ id: number;
173
+ body: Partial<Pick<Inbox, "status" | "id_agent">>;
174
+ }, unknown>;
175
+ declare function useDeleteInbox(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<void>, Error, number, unknown>;
176
+
177
+ declare function useInboxMessages(config: GchatHookConfig, idInbox: number | null, pollingInterval?: number): {
178
+ data: InboxMessage[];
179
+ error: Error;
180
+ isError: true;
181
+ isPending: false;
182
+ isLoading: false;
183
+ isLoadingError: false;
184
+ isRefetchError: true;
185
+ isSuccess: false;
186
+ isPlaceholderData: false;
187
+ status: "error";
188
+ dataUpdatedAt: number;
189
+ errorUpdatedAt: number;
190
+ failureCount: number;
191
+ failureReason: Error | null;
192
+ errorUpdateCount: number;
193
+ isFetched: boolean;
194
+ isFetchedAfterMount: boolean;
195
+ isFetching: boolean;
196
+ isInitialLoading: boolean;
197
+ isPaused: boolean;
198
+ isRefetching: boolean;
199
+ isStale: boolean;
200
+ isEnabled: boolean;
201
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<InboxMessage[], Error>>;
202
+ fetchStatus: _tanstack_query_core.FetchStatus;
203
+ promise: Promise<InboxMessage[]>;
204
+ } | {
205
+ data: InboxMessage[];
206
+ error: null;
207
+ isError: false;
208
+ isPending: false;
209
+ isLoading: false;
210
+ isLoadingError: false;
211
+ isRefetchError: false;
212
+ isSuccess: true;
213
+ isPlaceholderData: false;
214
+ status: "success";
215
+ dataUpdatedAt: number;
216
+ errorUpdatedAt: number;
217
+ failureCount: number;
218
+ failureReason: Error | null;
219
+ errorUpdateCount: number;
220
+ isFetched: boolean;
221
+ isFetchedAfterMount: boolean;
222
+ isFetching: boolean;
223
+ isInitialLoading: boolean;
224
+ isPaused: boolean;
225
+ isRefetching: boolean;
226
+ isStale: boolean;
227
+ isEnabled: boolean;
228
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<InboxMessage[], Error>>;
229
+ fetchStatus: _tanstack_query_core.FetchStatus;
230
+ promise: Promise<InboxMessage[]>;
231
+ } | {
232
+ data: InboxMessage[];
233
+ error: Error;
234
+ isError: true;
235
+ isPending: false;
236
+ isLoading: false;
237
+ isLoadingError: true;
238
+ isRefetchError: false;
239
+ isSuccess: false;
240
+ isPlaceholderData: false;
241
+ status: "error";
242
+ dataUpdatedAt: number;
243
+ errorUpdatedAt: number;
244
+ failureCount: number;
245
+ failureReason: Error | null;
246
+ errorUpdateCount: number;
247
+ isFetched: boolean;
248
+ isFetchedAfterMount: boolean;
249
+ isFetching: boolean;
250
+ isInitialLoading: boolean;
251
+ isPaused: boolean;
252
+ isRefetching: boolean;
253
+ isStale: boolean;
254
+ isEnabled: boolean;
255
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<InboxMessage[], Error>>;
256
+ fetchStatus: _tanstack_query_core.FetchStatus;
257
+ promise: Promise<InboxMessage[]>;
258
+ } | {
259
+ data: InboxMessage[];
260
+ error: null;
261
+ isError: false;
262
+ isPending: true;
263
+ isLoading: true;
264
+ isLoadingError: false;
265
+ isRefetchError: false;
266
+ isSuccess: false;
267
+ isPlaceholderData: false;
268
+ status: "pending";
269
+ dataUpdatedAt: number;
270
+ errorUpdatedAt: number;
271
+ failureCount: number;
272
+ failureReason: Error | null;
273
+ errorUpdateCount: number;
274
+ isFetched: boolean;
275
+ isFetchedAfterMount: boolean;
276
+ isFetching: boolean;
277
+ isInitialLoading: boolean;
278
+ isPaused: boolean;
279
+ isRefetching: boolean;
280
+ isStale: boolean;
281
+ isEnabled: boolean;
282
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<InboxMessage[], Error>>;
283
+ fetchStatus: _tanstack_query_core.FetchStatus;
284
+ promise: Promise<InboxMessage[]>;
285
+ } | {
286
+ data: InboxMessage[];
287
+ error: null;
288
+ isError: false;
289
+ isPending: true;
290
+ isLoadingError: false;
291
+ isRefetchError: false;
292
+ isSuccess: false;
293
+ isPlaceholderData: false;
294
+ status: "pending";
295
+ dataUpdatedAt: number;
296
+ errorUpdatedAt: number;
297
+ failureCount: number;
298
+ failureReason: Error | null;
299
+ errorUpdateCount: number;
300
+ isFetched: boolean;
301
+ isFetchedAfterMount: boolean;
302
+ isFetching: boolean;
303
+ isLoading: boolean;
304
+ isInitialLoading: boolean;
305
+ isPaused: boolean;
306
+ isRefetching: boolean;
307
+ isStale: boolean;
308
+ isEnabled: boolean;
309
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<InboxMessage[], Error>>;
310
+ fetchStatus: _tanstack_query_core.FetchStatus;
311
+ promise: Promise<InboxMessage[]>;
312
+ } | {
313
+ data: InboxMessage[];
314
+ isError: false;
315
+ error: null;
316
+ isPending: false;
317
+ isLoading: false;
318
+ isLoadingError: false;
319
+ isRefetchError: false;
320
+ isSuccess: true;
321
+ isPlaceholderData: true;
322
+ status: "success";
323
+ dataUpdatedAt: number;
324
+ errorUpdatedAt: number;
325
+ failureCount: number;
326
+ failureReason: Error | null;
327
+ errorUpdateCount: number;
328
+ isFetched: boolean;
329
+ isFetchedAfterMount: boolean;
330
+ isFetching: boolean;
331
+ isInitialLoading: boolean;
332
+ isPaused: boolean;
333
+ isRefetching: boolean;
334
+ isStale: boolean;
335
+ isEnabled: boolean;
336
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<InboxMessage[], Error>>;
337
+ fetchStatus: _tanstack_query_core.FetchStatus;
338
+ promise: Promise<InboxMessage[]>;
339
+ };
340
+ declare function useSendMessage(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<InboxMessage>, Error, {
341
+ idInbox: number;
342
+ content: string;
343
+ }, {
344
+ optimisticMsg: InboxMessage;
345
+ }>;
346
+ declare function useRetryMessage(config: GchatHookConfig): (message: InboxMessage) => Promise<void>;
347
+ declare function useRevokeMessage(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<void>, Error, {
348
+ id: number;
349
+ idInbox: number;
350
+ }, unknown>;
351
+ declare function useEditMessage(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<void>, Error, {
352
+ id: number;
353
+ idInbox: number;
354
+ content: string;
355
+ }, unknown>;
356
+
357
+ declare function useContacts(config: GchatHookConfig, params?: Record<string, string>): _tanstack_react_query.UseQueryResult<{
358
+ data: Contact[];
359
+ total: number;
360
+ }, Error>;
361
+ declare function useGetContact(config: GchatHookConfig, contactId: number | null): _tanstack_react_query.UseQueryResult<Contact, Error>;
362
+ declare function useCreateContact(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<Contact>, Error, {
363
+ name: string;
364
+ phone_number?: string;
365
+ identifier?: string;
366
+ }, unknown>;
367
+ declare function useUpdateContact(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<Contact>, Error, {
368
+ id: number;
369
+ body: {
370
+ name?: string;
371
+ phone_number?: string;
372
+ identifier?: string;
373
+ };
374
+ }, unknown>;
375
+ declare function useDeleteContact(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<void>, Error, number, unknown>;
376
+
377
+ declare function useChannels(config: GchatHookConfig): _tanstack_react_query.UseQueryResult<Channel[], Error>;
378
+ declare function useChannelWhatsappStatus(config: GchatHookConfig, channelId: number | null, enabled?: boolean, pollingInterval?: number): _tanstack_react_query.UseQueryResult<WhatsappStatus, Error>;
379
+ declare function useChannelQR(config: GchatHookConfig, channelId: number | null, enabled?: boolean, pollingInterval?: number): _tanstack_react_query.UseQueryResult<string | null, Error>;
380
+ declare function useCreateChannel(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<Channel>, Error, Pick<Channel, "name" | "type" | "provider"> & Partial<Pick<Channel, "id_agent" | "identifier">>, unknown>;
381
+ declare function useUpdateChannel(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<Channel>, Error, {
382
+ id: number;
383
+ body: Partial<Pick<Channel, "name" | "identifier" | "status" | "id_agent">>;
384
+ }, unknown>;
385
+ declare function useDeleteChannel(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<void>, Error, number, unknown>;
386
+ declare function useConnectChannel(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<unknown>, Error, number, unknown>;
387
+ declare function useDisconnectChannel(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<unknown>, Error, number, unknown>;
388
+ declare function useLogoutChannel(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<unknown>, Error, number, unknown>;
389
+
150
390
  interface ChatViewProps {
151
391
  messages: InboxMessage[];
152
392
  isLoading: boolean;
@@ -177,4 +417,4 @@ interface MessageBubbleProps {
177
417
  }
178
418
  declare function MessageBubble({ message, onRetry, onRevoke, onEdit, renderActions, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
179
419
 
180
- export { type ApiResponse, type Channel, ChatInput, type ChatInputProps, ChatView, type ChatViewProps, type Contact, type GchatClientConfig, type Inbox, type InboxMessage, type InboxStats, MessageBubble, type MessageBubbleProps, type MessageContentType, type WhatsappStatus, cn, createGchatClient, formatDateGroup, formatMessageTime, groupMessagesByDate };
420
+ export { type ApiResponse, type Channel, ChatInput, type ChatInputProps, ChatView, type ChatViewProps, type Contact, DEFAULT_CHANNEL_STATUS_POLLING, DEFAULT_INBOX_POLLING, DEFAULT_MESSAGES_POLLING, DEFAULT_QR_POLLING, type GchatClientConfig, type GchatHookConfig, type Inbox, type InboxMessage, type InboxStats, MessageBubble, type MessageBubbleProps, type MessageContentType, type WhatsappStatus, cn, createGchatClient, formatDateGroup, formatMessageTime, groupMessagesByDate, useChannelQR, useChannelWhatsappStatus, useChannels, useConnectChannel, useContacts, useCreateChannel, useCreateContact, useCreateInbox, useDeleteChannel, useDeleteContact, useDeleteInbox, useDisconnectChannel, useEditMessage, useGetContact, useInbox, useInboxMessages, useInboxStats, useInboxes, useLogoutChannel, useRetryMessage, useRevokeMessage, useSendMessage, useUpdateChannel, useUpdateContact, useUpdateInbox };