@webitel/chat-web-sdk 0.0.0 → 0.0.1

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,7 +1,6 @@
1
- import * as _webitel_api_services_gen_models from '@webitel/api-services/gen/models';
2
- import { WebitelImApiGatewayV1HistoryMessage, WebitelImApiGatewayV1Thread, MessageHistorySearchThreadMessagesHistoryWebitelImApiGatewayV1MessageHistoryParams, WebitelImApiGatewayV1SearchMessageHistoryResponse, ThreadManagementSearchParams, ContactsSearchParams, WebitelImApiGatewayV1Contact } from '@webitel/api-services/gen/models';
3
- export { WebitelImApiGatewayV1Contact as ContactModel, WebitelImApiGatewayV1HistoryMessage as MessageModel, WebitelImApiGatewayV1Thread as ThreadModel } from '@webitel/api-services/gen/models';
4
1
  import { AxiosInstance } from 'axios';
2
+ import { WebitelImApiGatewayV1HistoryMessage, WebitelImApiGatewayV1SearchMessageHistoryResponse, WebitelImApiGatewayV1Thread, MessageHistorySearchThreadMessagesHistoryWebitelImApiGatewayV1MessageHistoryParams, WebitelImApiGatewayV1SearchThreadResponse, ThreadManagementSearchParams, WebitelImApiGatewayV1ContactList, WebitelImApiGatewayV1Contact, ContactsSearchParams } from '@webitel/api-services/gen/models';
3
+ export { WebitelImApiGatewayV1Contact as ContactModel, ContactsSearchParams as ContactSearchParams, MessageHistorySearchThreadMessagesHistoryWebitelImApiGatewayV1MessageHistoryParams as MessageHistorySearchParams, WebitelImApiGatewayV1HistoryMessage as MessageModel, WebitelImApiGatewayV1Thread as ThreadModel, ThreadManagementSearchParams as ThreadSearchParams } from '@webitel/api-services/gen/models';
5
4
 
6
5
  type ServiceConfigInputSchema = {
7
6
  baseUrl: string;
@@ -27,63 +26,45 @@ declare class SocketConfig implements SocketConfigInputSchema {
27
26
  }
28
27
  declare function createSocketConfig(rawSocketConfig: SocketConfigInputSchema): SocketConfig;
29
28
 
29
+ interface ServiceConfigurable {
30
+ get serviceConfig(): ServiceConfig;
31
+ }
32
+
30
33
  interface IMessage extends WebitelImApiGatewayV1HistoryMessage {
31
34
  markRead: () => Promise<void>;
32
35
  }
33
-
34
36
  /**
35
37
  * API response with `messages` replaced by instantiated SDK `Message` classes.
36
38
  */
37
- type ThreadMessageHistoryResult = Omit<WebitelImApiGatewayV1SearchMessageHistoryResponse, 'messages'> & {
39
+ type MessageHistorySearchResult = Omit<WebitelImApiGatewayV1SearchMessageHistoryResponse, 'messages'> & {
38
40
  messages: IMessage[];
39
41
  };
40
- interface IThread extends WebitelImApiGatewayV1Thread {
41
- fetchMessageHistory: (config: ServiceConfig, params?: MessageHistorySearchThreadMessagesHistoryWebitelImApiGatewayV1MessageHistoryParams) => Promise<ThreadMessageHistoryResult>;
42
- }
43
42
 
44
- declare function useThreadsService(config: ServiceConfig): {
45
- fetchThreads: (params?: ThreadManagementSearchParams) => Promise<{
46
- threads: {
47
- id?: string;
48
- fetchMessageHistory(config: ServiceConfig, params?: _webitel_api_services_gen_models.MessageHistorySearchThreadMessagesHistoryWebitelImApiGatewayV1MessageHistoryParams): Promise<{
49
- messages: {
50
- markRead(): Promise<void>;
51
- }[];
52
- from?: _webitel_api_services_gen_models.WebitelImApiGatewayV1MessageParticipant[];
53
- next?: boolean;
54
- nextCursor?: _webitel_api_services_gen_models.WebitelImApiGatewayV1HistoryMessageCursor;
55
- paging?: _webitel_api_services_gen_models.WebitelImApiGatewayV1Paging;
56
- }>;
57
- }[];
58
- next?: boolean;
59
- }>;
43
+ interface IThread extends WebitelImApiGatewayV1Thread, ServiceConfigurable {
44
+ id: string;
45
+ fetchMessageHistory: (params?: MessageHistorySearchThreadMessagesHistoryWebitelImApiGatewayV1MessageHistoryParams) => Promise<MessageHistorySearchResult>;
46
+ }
47
+ type ThreadSearchResult = Omit<WebitelImApiGatewayV1SearchThreadResponse, 'threads'> & {
48
+ threads: IThread[];
60
49
  };
61
50
 
62
- declare function useContactsService(config: ServiceConfig): {
63
- fetchContacts: (params?: ContactsSearchParams) => Promise<{
64
- items: {
65
- sendMessage(): Promise<void>;
66
- }[];
67
- next?: boolean;
68
- page?: number;
69
- size?: number;
70
- }>;
51
+ declare function useThreadsService(config: ServiceConfig): {
52
+ fetchThreads: (params?: ThreadManagementSearchParams) => Promise<ThreadSearchResult>;
71
53
  };
72
54
 
73
- interface IContact extends WebitelImApiGatewayV1Contact {
55
+ interface IContact extends WebitelImApiGatewayV1Contact, ServiceConfigurable {
74
56
  sendMessage: () => {};
75
57
  }
58
+ type ContactSearchResult = Omit<WebitelImApiGatewayV1ContactList, 'items'> & {
59
+ items: IContact[];
60
+ };
61
+
62
+ declare function useContactsService(config: ServiceConfig): {
63
+ fetchContacts: (params?: ContactsSearchParams) => Promise<ContactSearchResult>;
64
+ };
76
65
 
77
66
  declare function useMessagesService(config: ServiceConfig): {
78
- fetchMessageHistory: (threadId: string, params?: MessageHistorySearchThreadMessagesHistoryWebitelImApiGatewayV1MessageHistoryParams) => Promise<{
79
- messages: {
80
- markRead(): Promise<void>;
81
- }[];
82
- from?: _webitel_api_services_gen_models.WebitelImApiGatewayV1MessageParticipant[];
83
- next?: boolean;
84
- nextCursor?: _webitel_api_services_gen_models.WebitelImApiGatewayV1HistoryMessageCursor;
85
- paging?: _webitel_api_services_gen_models.WebitelImApiGatewayV1Paging;
86
- }>;
67
+ fetchMessageHistory: (threadId: string, params?: MessageHistorySearchThreadMessagesHistoryWebitelImApiGatewayV1MessageHistoryParams) => Promise<MessageHistorySearchResult>;
87
68
  };
88
69
 
89
70
  /**
@@ -128,4 +109,4 @@ declare class ChatsSocketClient implements IChatsSocketClient {
128
109
  }
129
110
  declare function createChatsSocketClient(config: SocketConfig): ChatsSocketClient;
130
111
 
131
- export { ChatsSocketMessage, type IContact, type IMessage, type IThread, ServiceConfig, type ServiceConfigInputSchema, SocketConfig, type SocketConfigInputSchema, type ThreadMessageHistoryResult, createChatsSocketClient, createServiceConfig, createSocketConfig, useContactsService, useMessagesService, useThreadsService };
112
+ export { ChatsSocketMessage, type ContactSearchResult, type IContact, type IMessage, type IThread, type MessageHistorySearchResult, ServiceConfig, type ServiceConfigInputSchema, SocketConfig, type SocketConfigInputSchema, type ThreadSearchResult, createChatsSocketClient, createServiceConfig, createSocketConfig, useContactsService, useMessagesService, useThreadsService };