@livechat/customer-sdk 3.1.4 → 3.1.5

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 +1 -1
  2. package/dist/customer-sdk.cjs.js +4 -4
  3. package/dist/customer-sdk.cjs.native.js +4 -4
  4. package/dist/customer-sdk.esm.js +3 -3
  5. package/dist/customer-sdk.js +170 -279
  6. package/dist/customer-sdk.min.js +1 -1
  7. package/package.json +3 -2
  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,374 @@
1
+ import { Any, Object } from 'ts-toolbelt';
2
+ import * as eventTypes from '../constants/eventTypes';
3
+ import * as userTypes from '../constants/userTypes';
4
+ import * as serverEntities from './serverEntities';
5
+ export type GreetingSubtype = 'greeting' | 'announcement';
6
+ export type Greeting = {
7
+ id: number;
8
+ addon: string | null;
9
+ uniqueId: string;
10
+ displayedFirstTime: boolean;
11
+ accepted: boolean;
12
+ subtype: GreetingSubtype;
13
+ event: GreetingEvent;
14
+ agent: {
15
+ id: string;
16
+ name: string;
17
+ avatar: string;
18
+ jobTitle: string;
19
+ isBot: boolean;
20
+ };
21
+ };
22
+ export type Access = {
23
+ groupIds?: number[];
24
+ };
25
+ export type EventsSeenUpToMap = {
26
+ [userId: string]: string | null;
27
+ };
28
+ export type Properties = {
29
+ [namespace: string]: {
30
+ [key: string]: string | number;
31
+ };
32
+ };
33
+ export type CustomerSessionFields = Record<string, string>;
34
+ export type Thread = {
35
+ id: string;
36
+ chatId: string;
37
+ active: boolean;
38
+ access: Access;
39
+ createdAt: string;
40
+ userIds: string[];
41
+ events: Event[];
42
+ properties: Properties;
43
+ previousThreadId: string | null;
44
+ nextThreadId: string | null;
45
+ queue: {
46
+ position: number;
47
+ waitTime: number;
48
+ queuedAt: string;
49
+ } | null;
50
+ };
51
+ export type ChatSummary = {
52
+ id: string;
53
+ active: boolean;
54
+ access: Access;
55
+ properties: Properties;
56
+ users: ChatUser[];
57
+ lastThreadId: string | null;
58
+ lastThreadCreatedAt: string | null;
59
+ eventsSeenUpToMap: EventsSeenUpToMap;
60
+ lastEventsPerType?: {
61
+ [Type in Event['type']]?: Extract<Event, {
62
+ type: Type;
63
+ }>;
64
+ };
65
+ lastEvent?: Event;
66
+ };
67
+ export type Chat = {
68
+ id: string;
69
+ access?: Access;
70
+ users: ChatUser[];
71
+ properties: Properties;
72
+ thread: Thread | null;
73
+ eventsSeenUpToMap: EventsSeenUpToMap;
74
+ };
75
+ export type IncomingChat = Chat & {
76
+ thread: Thread;
77
+ };
78
+ export type Agent = {
79
+ type: typeof userTypes.AGENT;
80
+ id: string;
81
+ name: string;
82
+ avatar: string;
83
+ jobTitle: string;
84
+ };
85
+ export type CustomerCommonProps = {
86
+ type: typeof userTypes.CUSTOMER;
87
+ id: string;
88
+ name?: string;
89
+ email?: string;
90
+ avatar?: string;
91
+ sessionFields: CustomerSessionFields;
92
+ };
93
+ export type CustomerOptionalProps = {
94
+ name?: string;
95
+ email?: string;
96
+ avatar?: string;
97
+ sessionFields?: CustomerSessionFields;
98
+ };
99
+ type ChatUserProps = {
100
+ present: boolean;
101
+ };
102
+ export type Customer = Any.Compute<CustomerCommonProps & {
103
+ statistics: {
104
+ chatsCount: number;
105
+ threadsCount: number;
106
+ visitsCount: number;
107
+ pageViewsCount: number;
108
+ greetingsShownCount: number;
109
+ greetingsAcceptedCount: number;
110
+ };
111
+ }>;
112
+ export type User = Agent | Customer;
113
+ export type ChatAgent = Any.Compute<Agent & ChatUserProps>;
114
+ export type ChatCustomer = Any.Compute<CustomerCommonProps & ChatUserProps>;
115
+ export type ChatUser = ChatAgent | ChatCustomer;
116
+ export type PredictedAgent = {
117
+ agent: Any.Compute<Pick<Agent, 'avatar' | 'id' | 'name' | 'jobTitle' | 'type'> & {
118
+ isBot: boolean;
119
+ }>;
120
+ queue: boolean;
121
+ };
122
+ export type CustomerUpdate = Any.Compute<Partial<Pick<Customer, 'avatar' | 'email' | 'name' | 'sessionFields'>>>;
123
+ export type FormType = serverEntities.FormType;
124
+ type FormFieldOption = {
125
+ id: string;
126
+ label: string;
127
+ checked: boolean;
128
+ };
129
+ type HeaderField = {
130
+ type: 'header';
131
+ id: string;
132
+ label: string;
133
+ };
134
+ type NameField = {
135
+ type: 'name';
136
+ id: string;
137
+ label: string;
138
+ required: boolean;
139
+ };
140
+ type EmailField = {
141
+ type: 'email';
142
+ id: string;
143
+ label: string;
144
+ required: boolean;
145
+ };
146
+ type QuestionField = {
147
+ type: 'question';
148
+ id: string;
149
+ label: string;
150
+ required: boolean;
151
+ };
152
+ type TextareaField = {
153
+ type: 'textarea';
154
+ id: string;
155
+ label: string;
156
+ required: boolean;
157
+ };
158
+ type RadioField = {
159
+ type: 'radio';
160
+ id: string;
161
+ label: string;
162
+ options: FormFieldOption[];
163
+ required: boolean;
164
+ };
165
+ type SelectField = {
166
+ type: 'select';
167
+ id: string;
168
+ label: string;
169
+ options: FormFieldOption[];
170
+ required: boolean;
171
+ };
172
+ type CheckboxField = {
173
+ type: 'checkbox';
174
+ id: string;
175
+ label: string;
176
+ options: FormFieldOption[];
177
+ required: boolean;
178
+ };
179
+ type CheckboxForEmailField = {
180
+ type: 'checkbox_for_email';
181
+ id: string;
182
+ label: string;
183
+ required: boolean;
184
+ checked: boolean;
185
+ };
186
+ type GroupChooserField = {
187
+ type: 'group_chooser';
188
+ id: string;
189
+ label: string;
190
+ options: Array<{
191
+ id: string;
192
+ label: string;
193
+ groupId: number;
194
+ }>;
195
+ required: boolean;
196
+ };
197
+ type RatingField = {
198
+ type: 'rating';
199
+ id: string;
200
+ label: string;
201
+ commentLabel: string;
202
+ required: boolean;
203
+ };
204
+ type SubjectField = {
205
+ type: 'subject';
206
+ id: string;
207
+ label: string;
208
+ required: boolean;
209
+ };
210
+ export type FormField = HeaderField | NameField | EmailField | QuestionField | TextareaField | RadioField | SelectField | CheckboxField | CheckboxForEmailField | GroupChooserField | RatingField | SubjectField;
211
+ type CreateFilledField<Field extends FormField, Answer> = Any.Compute<Pick<Field, 'type' | 'id' | 'label'> & Answer>;
212
+ type FilledGroupChooserField = CreateFilledField<GroupChooserField, {
213
+ answer?: {
214
+ id: string;
215
+ groupId: number;
216
+ label: string;
217
+ };
218
+ }>;
219
+ export type FilledFormField = Exclude<serverEntities.FilledFormField, {
220
+ type: 'group_chooser';
221
+ }> | FilledGroupChooserField;
222
+ type RichMessageButtonBase = {
223
+ postbackId: string;
224
+ text: string;
225
+ userIds: string[];
226
+ role: serverEntities.RichMessageButtonRole;
227
+ };
228
+ type RichMessageButtonWithoutValue = Any.Compute<RichMessageButtonBase & {
229
+ type?: void;
230
+ }>;
231
+ type RichMessageMessageButton = Any.Compute<RichMessageButtonBase & {
232
+ type: 'message';
233
+ value: string;
234
+ }>;
235
+ type RichMessageUrlButton = Any.Compute<RichMessageButtonBase & {
236
+ type: 'url';
237
+ value: string;
238
+ target?: 'current' | 'new';
239
+ }>;
240
+ type RichMessagePhoneButton = Any.Compute<RichMessageButtonBase & {
241
+ type: 'phone';
242
+ value: string;
243
+ }>;
244
+ type RichMessageCancelButton = Any.Compute<RichMessageButtonBase & {
245
+ type: 'cancel';
246
+ }>;
247
+ type RichMessageWebviewButton = Any.Compute<RichMessageButtonBase & {
248
+ type: 'webview';
249
+ value: string;
250
+ webviewHeight?: 'full' | 'tall' | 'compact';
251
+ }>;
252
+ export type RichMessageButton = RichMessageButtonWithoutValue | RichMessageMessageButton | RichMessageUrlButton | RichMessagePhoneButton | RichMessageCancelButton | RichMessageWebviewButton;
253
+ export type RichMessageElement = {
254
+ title?: string;
255
+ subtitle?: string;
256
+ image?: {
257
+ url: string;
258
+ name?: string;
259
+ alternativeText?: string;
260
+ content_type?: string;
261
+ size?: number;
262
+ width?: number;
263
+ height?: number;
264
+ };
265
+ buttons?: RichMessageButton[];
266
+ };
267
+ export type AvailabilityStatus = 'online' | 'offline';
268
+ type RichMessageTemplate = 'cards' | 'quick_replies' | 'sticker';
269
+ type Thumbnail = {
270
+ url: string;
271
+ height: number;
272
+ width: number;
273
+ };
274
+ type ServerGeneratedEventBase = {
275
+ id: string;
276
+ authorId: string;
277
+ createdAt: string;
278
+ };
279
+ type ClientGeneratedEventBase = {
280
+ threadId: string;
281
+ };
282
+ type EventBase = {
283
+ customId?: string;
284
+ properties: Properties;
285
+ };
286
+ export type NonSpecificEventBase = ServerGeneratedEventBase & ClientGeneratedEventBase & EventBase;
287
+ type FileSpecificProps = {
288
+ type: typeof eventTypes.FILE;
289
+ contentType: string;
290
+ url: string;
291
+ name: string;
292
+ };
293
+ type ImageSpecificProps = {
294
+ width: number;
295
+ height: number;
296
+ thumbnails: {
297
+ high: Thumbnail;
298
+ default: Thumbnail;
299
+ };
300
+ alternativeText?: string;
301
+ };
302
+ type NonImageSpecificProps = {
303
+ width?: undefined;
304
+ height?: undefined;
305
+ };
306
+ type FormSpecificProps = {
307
+ type: typeof eventTypes.FORM;
308
+ formId: string;
309
+ fields: FormField[];
310
+ };
311
+ type FilledFormSpecificProps = {
312
+ type: typeof eventTypes.FILLED_FORM;
313
+ formId: string;
314
+ fields: FilledFormField[];
315
+ };
316
+ type CustomEventSpecificProps = {
317
+ type: typeof eventTypes.CUSTOM;
318
+ content?: any;
319
+ };
320
+ type MessageSpecificProps = {
321
+ type: typeof eventTypes.MESSAGE;
322
+ text: string;
323
+ postback?: {
324
+ id: string;
325
+ threadId: string;
326
+ eventId: string;
327
+ type: string;
328
+ value: string;
329
+ };
330
+ };
331
+ type RichMessageSpecificProps = {
332
+ type: typeof eventTypes.RICH_MESSAGE;
333
+ template: RichMessageTemplate;
334
+ elements: RichMessageElement[];
335
+ };
336
+ type SystemMessageSpecificProps = {
337
+ type: typeof eventTypes.SYSTEM_MESSAGE;
338
+ text: string;
339
+ systemMessageType: string;
340
+ textVars?: Record<string, string>;
341
+ };
342
+ type RequestBodyFile = Any.Compute<EventBase & {
343
+ type: typeof eventTypes.FILE;
344
+ url: string;
345
+ alternativeText: string;
346
+ }>;
347
+ type RequestBodyFilledForm = Any.Compute<EventBase & FilledFormSpecificProps>;
348
+ type RequestBodyMessage = Any.Compute<EventBase & MessageSpecificProps>;
349
+ type RequestBodySystemMessage = Any.Compute<EventBase & SystemMessageSpecificProps & {
350
+ recipients?: 'all' | 'agents';
351
+ }>;
352
+ type RequestBodyCustomEvent = Any.Compute<EventBase & CustomEventSpecificProps>;
353
+ export type RequestBodyEvent = RequestBodyFile | RequestBodyFilledForm | RequestBodyMessage | RequestBodySystemMessage | RequestBodyCustomEvent;
354
+ export type ImageFile = Any.Compute<NonSpecificEventBase & FileSpecificProps & ImageSpecificProps>;
355
+ export type NonImageFile = Any.Compute<NonSpecificEventBase & FileSpecificProps & NonImageSpecificProps>;
356
+ export type File = ImageFile | NonImageFile;
357
+ export type Form = Any.Compute<NonSpecificEventBase & FormSpecificProps>;
358
+ export type FilledForm = Any.Compute<NonSpecificEventBase & FilledFormSpecificProps>;
359
+ export type CustomEvent = Any.Compute<NonSpecificEventBase & CustomEventSpecificProps>;
360
+ export type Message = Any.Compute<NonSpecificEventBase & MessageSpecificProps>;
361
+ export type RichMessage = Any.Compute<NonSpecificEventBase & RichMessageSpecificProps>;
362
+ export type SystemMessage = Any.Compute<NonSpecificEventBase & SystemMessageSpecificProps>;
363
+ export type GreetingEvent = Object.Update<Message | RichMessage, 'threadId', null>;
364
+ export type Event = File | Form | FilledForm | Message | RichMessage | SystemMessage | CustomEvent;
365
+ export type UrlInfo = {
366
+ url: string;
367
+ title?: string;
368
+ description?: string;
369
+ imageUrl?: string;
370
+ imageWidth?: number;
371
+ imageHeight?: number;
372
+ };
373
+ export {};
374
+ //# sourceMappingURL=clientEntities.d.ts.map