@livechat/customer-sdk 3.1.0 → 3.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.
Files changed (47) hide show
  1. package/README.md +32 -4
  2. package/dist/customer-sdk.cjs.js +187 -640
  3. package/dist/customer-sdk.cjs.native.js +187 -639
  4. package/dist/customer-sdk.esm.js +188 -641
  5. package/dist/customer-sdk.js +265 -867
  6. package/dist/customer-sdk.min.js +1 -1
  7. package/package.json +10 -9
  8. package/types/actions.d.ts +331 -0
  9. package/types/chatHistory.d.ts +19 -0
  10. package/types/clientDataParsers.d.ts +55 -0
  11. package/types/completionValues.d.ts +4 -0
  12. package/types/constants/clientErrorCodes.d.ts +11 -0
  13. package/types/constants/connectionStatuses.d.ts +6 -0
  14. package/types/constants/eventTypes.d.ts +8 -0
  15. package/types/constants/reduxActions.d.ts +23 -0
  16. package/types/constants/serverDisconnectionReasons.d.ts +15 -0
  17. package/types/constants/serverErrorCodes.d.ts +23 -0
  18. package/types/constants/serverPushActions.d.ts +26 -0
  19. package/types/constants/serverRequestActions.d.ts +30 -0
  20. package/types/constants/sortOrders.d.ts +3 -0
  21. package/types/constants/userTypes.d.ts +3 -0
  22. package/types/createError.d.ts +9 -0
  23. package/types/createStore.d.ts +12 -0
  24. package/types/debug.d.ts +3 -0
  25. package/types/graylog/index.d.ts +14 -0
  26. package/types/graylog/makeGrayLogRequest.d.ts +2 -0
  27. package/types/graylog/makeGrayLogRequest.native.d.ts +6 -0
  28. package/types/index.d.ts +239 -0
  29. package/types/reducer.d.ts +546 -0
  30. package/types/sendRequestAction.d.ts +4 -0
  31. package/types/sendTicketForm.d.ts +14 -0
  32. package/types/serverDataParser.d.ts +34 -0
  33. package/types/serverEventParser.d.ts +12 -0
  34. package/types/serverFrameParser.d.ts +385 -0
  35. package/types/sideEffects/checkGoals.d.ts +5 -0
  36. package/types/sideEffects/index.d.ts +12 -0
  37. package/types/sideStorage.d.ts +5 -0
  38. package/types/socketClient.d.ts +11 -0
  39. package/types/socketListener.d.ts +9 -0
  40. package/types/thunks.d.ts +4 -0
  41. package/types/types/actions.d.ts +157 -0
  42. package/types/types/clientEntities.d.ts +374 -0
  43. package/types/types/frames.d.ts +635 -0
  44. package/types/types/serverEntities.d.ts +408 -0
  45. package/types/types/state.d.ts +56 -0
  46. package/types/uploadFile.d.ts +19 -0
  47. package/types/validateFile/index.d.ts +3 -0
@@ -0,0 +1,239 @@
1
+ import sendTicketForm from './sendTicketForm';
2
+ import { UploadFileOptions } from './uploadFile';
3
+ import * as actions from './actions';
4
+ import { RequestBodyResumeChatData, RequestBodyStartChatData } from './clientDataParsers';
5
+ import { Config, Env, Page, SortOrder } from './types';
6
+ import * as clientEntities from './types/clientEntities';
7
+ export { default as debug } from './debug';
8
+ export * from './serverEventParser';
9
+ export { parseForm } from './serverFrameParser';
10
+ export declare const init: (config: Config, env?: Env) => Readonly<{
11
+ acceptGreeting({ greetingId, uniqueId }: {
12
+ greetingId: number;
13
+ uniqueId: string;
14
+ }): Promise<Readonly<{
15
+ readonly success: true;
16
+ }>>;
17
+ auth: import("@livechat/customer-auth/src/types").CustomerAuth;
18
+ cancelGreeting({ uniqueId }: {
19
+ uniqueId: string;
20
+ }): Promise<Readonly<{
21
+ readonly success: true;
22
+ }>>;
23
+ cancelRate(params: {
24
+ chatId: string;
25
+ properties: Array<'score' | 'comment'>;
26
+ }): Promise<Readonly<{
27
+ readonly success: true;
28
+ }>>;
29
+ connect: () => void;
30
+ deactivateChat({ id }: {
31
+ id: string;
32
+ }): Promise<Readonly<{
33
+ readonly success: true;
34
+ }>>;
35
+ deleteChatProperties({ id, properties }: {
36
+ id: string;
37
+ properties: Record<string, string[]>;
38
+ }): Promise<Readonly<{
39
+ readonly success: true;
40
+ }>>;
41
+ deleteEventProperties({ chatId, threadId, eventId, properties, }: {
42
+ chatId: string;
43
+ threadId: string;
44
+ eventId: string;
45
+ properties: Record<string, string[]>;
46
+ }): Promise<Readonly<{
47
+ readonly success: true;
48
+ }>>;
49
+ deleteThreadProperties({ chatId, threadId, properties, }: {
50
+ chatId: string;
51
+ threadId: string;
52
+ properties: Record<string, string[]>;
53
+ }): Promise<Readonly<{
54
+ readonly success: true;
55
+ }>>;
56
+ destroy(): void;
57
+ disconnect(): void;
58
+ getChat({ chatId, threadId }: {
59
+ chatId: string;
60
+ threadId?: string | undefined;
61
+ }): Promise<{
62
+ thread: clientEntities.Thread | null;
63
+ id: string;
64
+ access: clientEntities.Access;
65
+ users: clientEntities.ChatUser[];
66
+ properties: import("./types/serverEntities").Properties;
67
+ eventsSeenUpToMap: clientEntities.EventsSeenUpToMap;
68
+ }>;
69
+ getChatHistory({ chatId }: {
70
+ chatId: string;
71
+ }): import("./chatHistory").HistoryIterator;
72
+ getCustomer(): Promise<{
73
+ type: "customer";
74
+ id: string;
75
+ name?: string | undefined;
76
+ email?: string | undefined;
77
+ avatar?: string | undefined;
78
+ sessionFields: clientEntities.CustomerSessionFields;
79
+ statistics: {
80
+ chatsCount: number;
81
+ threadsCount: number;
82
+ visitsCount: number;
83
+ pageViewsCount: number;
84
+ greetingsShownCount: number;
85
+ greetingsAcceptedCount: number;
86
+ };
87
+ }>;
88
+ getForm({ groupId, type }: {
89
+ groupId: number;
90
+ type: clientEntities.FormType;
91
+ }): Promise<{
92
+ enabled: false;
93
+ } | {
94
+ form: {
95
+ id: string;
96
+ fields: clientEntities.FormField[];
97
+ };
98
+ enabled: true;
99
+ }>;
100
+ getPredictedAgent(params?: {
101
+ groupId?: number;
102
+ }): Promise<clientEntities.PredictedAgent>;
103
+ getUrlInfo({ url }: {
104
+ url: string;
105
+ }): Promise<clientEntities.UrlInfo>;
106
+ listChats(params?: {
107
+ pageId: string;
108
+ } | {
109
+ pageId?: undefined;
110
+ limit?: number;
111
+ }): Promise<{
112
+ chatsSummary: any;
113
+ totalChats: number;
114
+ users: clientEntities.ChatUser[];
115
+ previousPageId: string | null;
116
+ nextPageId: string | null;
117
+ }>;
118
+ listGroupStatuses({ groupIds }?: {
119
+ groupIds?: number[] | undefined;
120
+ }): Promise<Record<number, import("./types/serverEntities").GroupStatus>>;
121
+ listThreads(params: {
122
+ chatId: string;
123
+ sortOrder?: SortOrder;
124
+ limit?: number;
125
+ pageId?: undefined;
126
+ minEventsCount?: number;
127
+ } | {
128
+ chatId: string;
129
+ pageId: string;
130
+ }): Promise<{
131
+ threads: clientEntities.Thread[];
132
+ previousPageId: string | null;
133
+ nextPageId: string | null;
134
+ }>;
135
+ markEventsAsSeen({ chatId, seenUpTo }: {
136
+ chatId: string;
137
+ seenUpTo: string;
138
+ }): Promise<Readonly<{
139
+ readonly success: true;
140
+ }>>;
141
+ on: {
142
+ <Key extends import("mitt").EventType>(type: Key, handler: import("mitt").Handler<{
143
+ [x: string]: unknown;
144
+ [x: symbol]: unknown;
145
+ }[Key]>): void;
146
+ (type: "*", handler: import("mitt").WildcardHandler<{
147
+ [x: string]: unknown;
148
+ [x: symbol]: unknown;
149
+ }>): void;
150
+ };
151
+ once: {
152
+ <Key extends import("mitt").EventType>(type: Key, handler: import("mitt").Handler<{
153
+ [x: string]: unknown;
154
+ [x: symbol]: unknown;
155
+ }[Key]>): void;
156
+ (type: "*", handler: import("mitt").WildcardHandler<{
157
+ [x: string]: unknown;
158
+ [x: symbol]: unknown;
159
+ }>): void;
160
+ };
161
+ off: {
162
+ <Key_1 extends import("mitt").EventType>(type: Key_1, handler?: import("mitt").Handler<{
163
+ [x: string]: unknown;
164
+ [x: symbol]: unknown;
165
+ }[Key_1]> | undefined): void;
166
+ (type: "*", handler: import("mitt").WildcardHandler<{
167
+ [x: string]: unknown;
168
+ [x: symbol]: unknown;
169
+ }>): void;
170
+ } & (() => void);
171
+ rateChat(params: {
172
+ chatId: string;
173
+ rating: {
174
+ comment?: string;
175
+ score?: 0 | 1;
176
+ };
177
+ }): Promise<Readonly<{
178
+ readonly success: true;
179
+ }>>;
180
+ resumeChat(data: RequestBodyResumeChatData): Promise<clientEntities.IncomingChat>;
181
+ sendEvent(params: Parameters<typeof actions.sendEvent>[0]): Promise<clientEntities.Event>;
182
+ sendTicketForm(options: Parameters<typeof sendTicketForm>['2']): Promise<{
183
+ id: string;
184
+ }>;
185
+ sendRichMessagePostback({ chatId, threadId, eventId, postback, }: {
186
+ chatId: string;
187
+ threadId: string;
188
+ eventId: string;
189
+ postback: {
190
+ id: string;
191
+ toggled: boolean;
192
+ };
193
+ }): Promise<Readonly<{
194
+ readonly success: true;
195
+ }>>;
196
+ setCustomerSessionFields({ sessionFields }: {
197
+ sessionFields: clientEntities.CustomerSessionFields;
198
+ }): Promise<Readonly<{
199
+ readonly success: true;
200
+ }>>;
201
+ setSneakPeek: ({ chatId, sneakPeekText }: {
202
+ chatId: string;
203
+ sneakPeekText: string;
204
+ }) => void;
205
+ startChat(data?: RequestBodyStartChatData): Promise<clientEntities.IncomingChat>;
206
+ updateChatProperties({ id, properties }: {
207
+ id: string;
208
+ properties: clientEntities.Properties;
209
+ }): Promise<Readonly<{
210
+ readonly success: true;
211
+ }>>;
212
+ updateCustomer(update: clientEntities.CustomerUpdate): Promise<Readonly<{
213
+ readonly success: true;
214
+ }>>;
215
+ updateCustomerPage(page: Page): void;
216
+ updateEventProperties({ chatId, threadId, eventId, properties, }: {
217
+ chatId: string;
218
+ threadId: string;
219
+ eventId: string;
220
+ properties: clientEntities.Properties;
221
+ }): Promise<Readonly<{
222
+ readonly success: true;
223
+ }>>;
224
+ updateThreadProperties({ chatId, threadId, properties, }: {
225
+ chatId: string;
226
+ threadId: string;
227
+ properties: clientEntities.Properties;
228
+ }): Promise<Readonly<{
229
+ readonly success: true;
230
+ }>>;
231
+ uploadFile(options: UploadFileOptions): {
232
+ promise: Promise<{
233
+ url: string;
234
+ }>;
235
+ cancel(): void;
236
+ };
237
+ }>;
238
+ export type CustomerSDK = ReturnType<typeof init>;
239
+ //# sourceMappingURL=index.d.ts.map