@livechat/customer-sdk 3.1.1 → 3.1.3
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/README.md +24 -10
- package/dist/customer-sdk.cjs.js +243 -673
- package/dist/customer-sdk.cjs.native.js +243 -672
- package/dist/customer-sdk.esm.js +243 -671
- package/dist/customer-sdk.js +589 -1056
- package/dist/customer-sdk.min.js +1 -1
- package/package.json +9 -9
- package/types/actions.d.ts +331 -0
- package/types/chatHistory.d.ts +19 -0
- package/types/clientDataParsers.d.ts +55 -0
- package/types/completionValues.d.ts +4 -0
- package/types/constants/clientErrorCodes.d.ts +11 -0
- package/types/constants/connectionStatuses.d.ts +6 -0
- package/types/constants/eventTypes.d.ts +8 -0
- package/types/constants/organizationIds.d.ts +2 -0
- package/types/constants/reduxActions.d.ts +23 -0
- package/types/constants/serverDisconnectionReasons.d.ts +15 -0
- package/types/constants/serverErrorCodes.d.ts +23 -0
- package/types/constants/serverPushActions.d.ts +26 -0
- package/types/constants/serverRequestActions.d.ts +30 -0
- package/types/constants/sortOrders.d.ts +3 -0
- package/types/constants/userTypes.d.ts +3 -0
- package/types/createError.d.ts +9 -0
- package/types/createStore.d.ts +12 -0
- package/types/debug.d.ts +3 -0
- package/types/graylog/index.d.ts +14 -0
- package/types/graylog/makeGrayLogRequest.d.ts +2 -0
- package/types/graylog/makeGrayLogRequest.native.d.ts +6 -0
- package/types/index.d.ts +245 -0
- package/types/reducer.d.ts +546 -0
- package/types/sendRequestAction.d.ts +4 -0
- package/types/sendTicketForm.d.ts +15 -0
- package/types/serverDataParser.d.ts +34 -0
- package/types/serverEventParser.d.ts +12 -0
- package/types/serverFrameParser.d.ts +385 -0
- package/types/sideEffects/checkGoals.d.ts +5 -0
- package/types/sideEffects/index.d.ts +13 -0
- package/types/sideStorage.d.ts +5 -0
- package/types/socketClient.d.ts +11 -0
- package/types/socketListener.d.ts +12 -0
- package/types/thunks.d.ts +4 -0
- package/types/types/actions.d.ts +157 -0
- package/types/types/clientEntities.d.ts +376 -0
- package/types/types/frames.d.ts +635 -0
- package/types/types/serverEntities.d.ts +409 -0
- package/types/types/state.d.ts +56 -0
- package/types/uploadFile.d.ts +19 -0
- package/types/validateFile/index.d.ts +3 -0
|
@@ -7,8 +7,7 @@ var mitt = require('@livechat/mitt');
|
|
|
7
7
|
var dataUtils = require('@livechat/data-utils');
|
|
8
8
|
var redux = require('redux');
|
|
9
9
|
var createSideEffectsMiddleware = require('@livechat/side-effects-middleware');
|
|
10
|
-
var
|
|
11
|
-
var promiseTry = require('@livechat/promise-try');
|
|
10
|
+
var promiseUtils = require('@livechat/promise-utils');
|
|
12
11
|
var createBackoff = require('@livechat/backoff');
|
|
13
12
|
var storage = require('@livechat/isomorphic-storage');
|
|
14
13
|
var unfetch = require('unfetch');
|
|
@@ -21,8 +20,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
21
20
|
var createAuth__default = /*#__PURE__*/_interopDefaultLegacy(createAuth);
|
|
22
21
|
var mitt__default = /*#__PURE__*/_interopDefaultLegacy(mitt);
|
|
23
22
|
var createSideEffectsMiddleware__default = /*#__PURE__*/_interopDefaultLegacy(createSideEffectsMiddleware);
|
|
24
|
-
var deferred__default = /*#__PURE__*/_interopDefaultLegacy(deferred);
|
|
25
|
-
var promiseTry__default = /*#__PURE__*/_interopDefaultLegacy(promiseTry);
|
|
26
23
|
var createBackoff__default = /*#__PURE__*/_interopDefaultLegacy(createBackoff);
|
|
27
24
|
var storage__default = /*#__PURE__*/_interopDefaultLegacy(storage);
|
|
28
25
|
var unfetch__default = /*#__PURE__*/_interopDefaultLegacy(unfetch);
|
|
@@ -33,50 +30,40 @@ function _extends() {
|
|
|
33
30
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
34
31
|
for (var i = 1; i < arguments.length; i++) {
|
|
35
32
|
var source = arguments[i];
|
|
36
|
-
|
|
37
33
|
for (var key in source) {
|
|
38
34
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
39
35
|
target[key] = source[key];
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
38
|
}
|
|
43
|
-
|
|
44
39
|
return target;
|
|
45
40
|
};
|
|
46
41
|
return _extends.apply(this, arguments);
|
|
47
42
|
}
|
|
48
|
-
|
|
49
43
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
50
44
|
if (source == null) return {};
|
|
51
45
|
var target = {};
|
|
52
46
|
var sourceKeys = Object.keys(source);
|
|
53
47
|
var key, i;
|
|
54
|
-
|
|
55
48
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
56
49
|
key = sourceKeys[i];
|
|
57
50
|
if (excluded.indexOf(key) >= 0) continue;
|
|
58
51
|
target[key] = source[key];
|
|
59
52
|
}
|
|
60
|
-
|
|
61
53
|
return target;
|
|
62
54
|
}
|
|
63
|
-
|
|
64
55
|
function _toPrimitive(input, hint) {
|
|
65
56
|
if (typeof input !== "object" || input === null) return input;
|
|
66
57
|
var prim = input[Symbol.toPrimitive];
|
|
67
|
-
|
|
68
58
|
if (prim !== undefined) {
|
|
69
59
|
var res = prim.call(input, hint || "default");
|
|
70
60
|
if (typeof res !== "object") return res;
|
|
71
61
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
72
62
|
}
|
|
73
|
-
|
|
74
63
|
return (hint === "string" ? String : Number)(input);
|
|
75
64
|
}
|
|
76
|
-
|
|
77
65
|
function _toPropertyKey(arg) {
|
|
78
66
|
var key = _toPrimitive(arg, "string");
|
|
79
|
-
|
|
80
67
|
return typeof key === "symbol" ? key : String(key);
|
|
81
68
|
}
|
|
82
69
|
|
|
@@ -147,19 +134,16 @@ var createReducer = function createReducer(initialState, reducersMap) {
|
|
|
147
134
|
// eslint-disable-next-line no-console
|
|
148
135
|
console.warn(["Reducer contains an 'undefined' action type.", 'Have you misspelled a constant?'].join('\n'));
|
|
149
136
|
}
|
|
150
|
-
|
|
151
137
|
return function reducer(state, action) {
|
|
152
138
|
if (state === void 0) {
|
|
153
139
|
state = initialState;
|
|
154
140
|
}
|
|
155
|
-
|
|
156
141
|
if (dataUtils.hasOwn(action.type, reducersMap)) {
|
|
157
142
|
return reducersMap[action.type](state, action.payload);
|
|
158
143
|
}
|
|
159
|
-
|
|
160
144
|
return state;
|
|
161
145
|
};
|
|
162
|
-
};
|
|
146
|
+
};
|
|
163
147
|
|
|
164
148
|
var CONNECTED = 'connected';
|
|
165
149
|
var DESTROYED = 'destroyed';
|
|
@@ -170,6 +154,8 @@ var RECONNECTING = 'reconnecting';
|
|
|
170
154
|
var AGENT = 'agent';
|
|
171
155
|
var CUSTOMER = 'customer';
|
|
172
156
|
|
|
157
|
+
var LIVECHAT_ORGANIZATION_ID = 'feaf6c0e-9f43-48ff-9ad0-8e24e0350932';
|
|
158
|
+
|
|
173
159
|
var getAllRequests = function getAllRequests(state) {
|
|
174
160
|
return state.requests;
|
|
175
161
|
};
|
|
@@ -192,53 +178,48 @@ var isConnected = function isConnected(state) {
|
|
|
192
178
|
var isDestroyed = function isDestroyed(state) {
|
|
193
179
|
return getConnectionStatus(state) === DESTROYED;
|
|
194
180
|
};
|
|
195
|
-
|
|
196
181
|
var getEnvPart = function getEnvPart(_ref) {
|
|
197
|
-
var
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (licenseId === 1520) {
|
|
182
|
+
var organizationId = _ref.organizationId,
|
|
183
|
+
env = _ref.env;
|
|
184
|
+
if (organizationId === LIVECHAT_ORGANIZATION_ID) {
|
|
201
185
|
return '.staging';
|
|
202
186
|
}
|
|
203
|
-
|
|
204
187
|
if (env === 'production') {
|
|
205
188
|
return '';
|
|
206
189
|
}
|
|
207
|
-
|
|
208
190
|
return "." + env;
|
|
209
191
|
};
|
|
210
|
-
|
|
211
192
|
var getApiOrigin = function getApiOrigin(state) {
|
|
212
193
|
var region = state.region;
|
|
213
194
|
var regionPart = region ? "-" + region : '';
|
|
214
195
|
return "https://api" + regionPart + getEnvPart(state) + ".livechatinc.com";
|
|
215
196
|
};
|
|
216
197
|
var getServerUrl = function getServerUrl(state) {
|
|
217
|
-
return getApiOrigin(state) + "/v3.
|
|
198
|
+
return getApiOrigin(state) + "/v3.4/customer";
|
|
218
199
|
};
|
|
219
200
|
var createInitialState = function createInitialState(initialStateData) {
|
|
220
201
|
var _initialStateData$app = initialStateData.application,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
202
|
+
application = _initialStateData$app === void 0 ? {} : _initialStateData$app,
|
|
203
|
+
organizationId = initialStateData.organizationId,
|
|
204
|
+
_initialStateData$gro = initialStateData.groupId,
|
|
205
|
+
groupId = _initialStateData$gro === void 0 ? null : _initialStateData$gro,
|
|
206
|
+
env = initialStateData.env,
|
|
207
|
+
_initialStateData$pag = initialStateData.page,
|
|
208
|
+
page = _initialStateData$pag === void 0 ? null : _initialStateData$pag,
|
|
209
|
+
_initialStateData$reg = initialStateData.region,
|
|
210
|
+
region = _initialStateData$reg === void 0 ? null : _initialStateData$reg,
|
|
211
|
+
_initialStateData$ref = initialStateData.referrer,
|
|
212
|
+
referrer = _initialStateData$ref === void 0 ? null : _initialStateData$ref,
|
|
213
|
+
_initialStateData$uni = initialStateData.uniqueGroups,
|
|
214
|
+
uniqueGroups = _initialStateData$uni === void 0 ? false : _initialStateData$uni,
|
|
215
|
+
_initialStateData$mob = initialStateData.mobile,
|
|
216
|
+
mobile = _initialStateData$mob === void 0 ? false : _initialStateData$mob;
|
|
236
217
|
return {
|
|
237
218
|
application: _extends({}, application, {
|
|
238
219
|
name: "customer_sdk",
|
|
239
|
-
version: "3.1.
|
|
220
|
+
version: "3.1.3"
|
|
240
221
|
}),
|
|
241
|
-
|
|
222
|
+
organizationId: organizationId,
|
|
242
223
|
env: env,
|
|
243
224
|
groupId: groupId,
|
|
244
225
|
chats: {},
|
|
@@ -260,18 +241,14 @@ var createInitialState = function createInitialState(initialStateData) {
|
|
|
260
241
|
mobile: mobile
|
|
261
242
|
};
|
|
262
243
|
};
|
|
263
|
-
|
|
264
244
|
var removeStoredRequest = function removeStoredRequest(state, _ref2) {
|
|
265
245
|
var id = _ref2.id;
|
|
266
|
-
|
|
267
246
|
var _state$requests = state.requests,
|
|
268
|
-
|
|
269
|
-
|
|
247
|
+
requests = _objectWithoutPropertiesLoose(_state$requests, [id].map(_toPropertyKey));
|
|
270
248
|
return _extends({}, state, {
|
|
271
249
|
requests: requests
|
|
272
250
|
});
|
|
273
251
|
};
|
|
274
|
-
|
|
275
252
|
var setConnectionStatus = function setConnectionStatus(status, state) {
|
|
276
253
|
return _extends({}, state, {
|
|
277
254
|
connection: _extends({}, state.connection, {
|
|
@@ -279,10 +256,8 @@ var setConnectionStatus = function setConnectionStatus(status, state) {
|
|
|
279
256
|
})
|
|
280
257
|
});
|
|
281
258
|
};
|
|
282
|
-
|
|
283
259
|
var createReducer$1 = (function (state) {
|
|
284
260
|
var _createReducer;
|
|
285
|
-
|
|
286
261
|
return createReducer(state, (_createReducer = {}, _createReducer[CHANGE_REGION] = function (state, _ref3) {
|
|
287
262
|
var region = _ref3.region;
|
|
288
263
|
return _extends({}, state, {
|
|
@@ -296,12 +271,11 @@ var createReducer$1 = (function (state) {
|
|
|
296
271
|
return setConnectionStatus(PAUSED, state);
|
|
297
272
|
}, _createReducer[REQUEST_FAILED] = removeStoredRequest, _createReducer[RESPONSE_RECEIVED] = removeStoredRequest, _createReducer[PUSH_RESPONSE_RECEIVED] = removeStoredRequest, _createReducer[SEND_REQUEST] = function (state, _ref4) {
|
|
298
273
|
var _extends2;
|
|
299
|
-
|
|
300
274
|
var promise = _ref4.promise,
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
275
|
+
resolve = _ref4.resolve,
|
|
276
|
+
reject = _ref4.reject,
|
|
277
|
+
id = _ref4.id,
|
|
278
|
+
request = _ref4.request;
|
|
305
279
|
return _extends({}, state, {
|
|
306
280
|
requests: _extends({}, state.requests, (_extends2 = {}, _extends2[id] = {
|
|
307
281
|
id: id,
|
|
@@ -313,9 +287,8 @@ var createReducer$1 = (function (state) {
|
|
|
313
287
|
});
|
|
314
288
|
}, _createReducer[SET_CHAT_ACTIVE] = function (state, _ref5) {
|
|
315
289
|
var _extends3;
|
|
316
|
-
|
|
317
290
|
var id = _ref5.id,
|
|
318
|
-
|
|
291
|
+
active = _ref5.active;
|
|
319
292
|
return _extends({}, state, {
|
|
320
293
|
chats: _extends({}, state.chats, (_extends3 = {}, _extends3[id] = _extends({}, state.chats[id], {
|
|
321
294
|
active: active
|
|
@@ -331,11 +304,9 @@ var createReducer$1 = (function (state) {
|
|
|
331
304
|
});
|
|
332
305
|
}, _createReducer[SOCKET_DISCONNECTED] = function (state) {
|
|
333
306
|
var previousStatus = getConnectionStatus(state);
|
|
334
|
-
|
|
335
307
|
if (process.env.NODE_ENV !== 'production' && (previousStatus === PAUSED || previousStatus === DESTROYED)) {
|
|
336
308
|
throw new Error("Got 'socket_disconnected' action when in " + previousStatus + " state. This should be an impossible state.");
|
|
337
309
|
}
|
|
338
|
-
|
|
339
310
|
var state1 = setConnectionStatus(previousStatus === DISCONNECTED ? DISCONNECTED : RECONNECTING, state);
|
|
340
311
|
return _extends({}, state1, {
|
|
341
312
|
requests: {}
|
|
@@ -359,27 +330,27 @@ function finalCreateStore(initialStateData) {
|
|
|
359
330
|
|
|
360
331
|
function createError(_ref) {
|
|
361
332
|
var message = _ref.message,
|
|
362
|
-
|
|
333
|
+
code = _ref.code;
|
|
363
334
|
var error = new Error(message);
|
|
364
335
|
error.code = code;
|
|
365
336
|
return error;
|
|
366
337
|
}
|
|
367
338
|
|
|
368
339
|
var ACCESS_TOKEN_EXPIRED = 'access_token_expired';
|
|
369
|
-
var CUSTOMER_BANNED = 'customer_banned';
|
|
370
|
-
|
|
340
|
+
var CUSTOMER_BANNED = 'customer_banned';
|
|
341
|
+
// customer tried reconnecting too many times after they received too_many_connections error
|
|
371
342
|
var CUSTOMER_TEMPORARILY_BLOCKED = 'customer_temporarily_blocked';
|
|
372
343
|
var LICENSE_EXPIRED = 'license_expired';
|
|
373
344
|
var LICENSE_NOT_FOUND = 'license_not_found';
|
|
374
345
|
var MISDIRECTED_CONNECTION$1 = 'misdirected_connection';
|
|
375
|
-
var PRODUCT_VERSION_CHANGED = 'product_version_changed';
|
|
346
|
+
var PRODUCT_VERSION_CHANGED = 'product_version_changed';
|
|
347
|
+
// the limit of connections per user host has been exceeded
|
|
376
348
|
// or rate limit for new connections has been hit
|
|
377
349
|
// (in 3.2 only the latter case, the first one is using `too_many_connections` to avoid breaking changes)
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
350
|
+
var SERVICE_TEMPORARILY_UNAVAILABLE$1 = 'service_temporarily_unavailable';
|
|
351
|
+
// the limit of those connections is per user
|
|
352
|
+
var TOO_MANY_CONNECTIONS = 'too_many_connections';
|
|
353
|
+
// the limit of unauthorized connections is per IP
|
|
383
354
|
var TOO_MANY_UNAUTHORIZED_CONNECTIONS = 'too_many_unauthorized_connections';
|
|
384
355
|
var UNSUPPORTED_VERSION = 'unsupported_version';
|
|
385
356
|
|
|
@@ -448,20 +419,17 @@ var CUSTOM = 'custom';
|
|
|
448
419
|
|
|
449
420
|
var createEventBase = function createEventBase(event) {
|
|
450
421
|
var base = {};
|
|
451
|
-
|
|
452
422
|
if (typeof event.customId === 'string') {
|
|
453
423
|
base.custom_id = event.customId;
|
|
454
424
|
}
|
|
455
|
-
|
|
456
425
|
if (dataUtils.isObject(event.properties)) {
|
|
457
426
|
base.properties = event.properties;
|
|
458
427
|
}
|
|
459
|
-
|
|
460
428
|
return base;
|
|
461
|
-
};
|
|
462
|
-
// but should we? maybe only in DEV mode?
|
|
463
|
-
|
|
429
|
+
};
|
|
464
430
|
|
|
431
|
+
// TODO: we could validate and throw here
|
|
432
|
+
// but should we? maybe only in DEV mode?
|
|
465
433
|
var parseEvent = function parseEvent(event) {
|
|
466
434
|
switch (event.type) {
|
|
467
435
|
case MESSAGE:
|
|
@@ -470,7 +438,6 @@ var parseEvent = function parseEvent(event) {
|
|
|
470
438
|
type: event.type,
|
|
471
439
|
text: event.text
|
|
472
440
|
});
|
|
473
|
-
|
|
474
441
|
if (event.postback) {
|
|
475
442
|
message.postback = {
|
|
476
443
|
id: event.postback.id,
|
|
@@ -480,10 +447,8 @@ var parseEvent = function parseEvent(event) {
|
|
|
480
447
|
value: event.postback.value
|
|
481
448
|
};
|
|
482
449
|
}
|
|
483
|
-
|
|
484
450
|
return message;
|
|
485
451
|
}
|
|
486
|
-
|
|
487
452
|
case FILE:
|
|
488
453
|
{
|
|
489
454
|
var file = _extends({}, createEventBase(event), {
|
|
@@ -491,10 +456,8 @@ var parseEvent = function parseEvent(event) {
|
|
|
491
456
|
url: event.url,
|
|
492
457
|
alternative_text: event.alternativeText
|
|
493
458
|
});
|
|
494
|
-
|
|
495
459
|
return file;
|
|
496
460
|
}
|
|
497
|
-
|
|
498
461
|
case FILLED_FORM:
|
|
499
462
|
{
|
|
500
463
|
var filledForm = _extends({}, createEventBase(event), {
|
|
@@ -507,27 +470,22 @@ var parseEvent = function parseEvent(event) {
|
|
|
507
470
|
if (!field.answer) {
|
|
508
471
|
return field;
|
|
509
472
|
}
|
|
510
|
-
|
|
511
473
|
var _field$answer = field.answer,
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
474
|
+
groupId = _field$answer.groupId,
|
|
475
|
+
answer = _objectWithoutPropertiesLoose(_field$answer, ["groupId"]);
|
|
515
476
|
return _extends({}, field, {
|
|
516
477
|
answer: _extends({}, answer, {
|
|
517
478
|
group_id: groupId
|
|
518
479
|
})
|
|
519
480
|
});
|
|
520
481
|
}
|
|
521
|
-
|
|
522
482
|
default:
|
|
523
483
|
return field;
|
|
524
484
|
}
|
|
525
485
|
})
|
|
526
486
|
});
|
|
527
|
-
|
|
528
487
|
return filledForm;
|
|
529
488
|
}
|
|
530
|
-
|
|
531
489
|
case SYSTEM_MESSAGE:
|
|
532
490
|
{
|
|
533
491
|
var systemMessage = _extends({}, createEventBase(event), {
|
|
@@ -535,81 +493,64 @@ var parseEvent = function parseEvent(event) {
|
|
|
535
493
|
text: event.text,
|
|
536
494
|
system_message_type: event.systemMessageType
|
|
537
495
|
});
|
|
538
|
-
|
|
539
496
|
if (event.recipients) {
|
|
540
497
|
systemMessage.recipients = event.recipients;
|
|
541
498
|
}
|
|
542
|
-
|
|
543
499
|
return systemMessage;
|
|
544
500
|
}
|
|
545
|
-
|
|
546
501
|
case CUSTOM:
|
|
547
502
|
{
|
|
548
503
|
var customEvent = _extends({}, createEventBase(event), {
|
|
549
504
|
type: event.type
|
|
550
505
|
});
|
|
551
|
-
|
|
552
506
|
if (event.content) {
|
|
553
507
|
customEvent.content = event.content;
|
|
554
508
|
}
|
|
555
|
-
|
|
556
509
|
return customEvent;
|
|
557
510
|
}
|
|
558
511
|
}
|
|
559
512
|
};
|
|
560
|
-
|
|
561
513
|
var parseThreadData = function parseThreadData(thread) {
|
|
562
514
|
var data = {};
|
|
563
515
|
var events = thread.events,
|
|
564
|
-
|
|
565
|
-
|
|
516
|
+
properties = thread.properties;
|
|
566
517
|
if (events) {
|
|
567
518
|
data.events = events.map(parseEvent);
|
|
568
519
|
}
|
|
569
|
-
|
|
570
520
|
if (properties) {
|
|
571
521
|
data.properties = properties;
|
|
572
522
|
}
|
|
573
|
-
|
|
574
523
|
return data;
|
|
575
524
|
};
|
|
576
|
-
|
|
577
525
|
var parseStartChatData = function parseStartChatData(_ref) {
|
|
578
526
|
var _ref$active = _ref.active,
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
527
|
+
active = _ref$active === void 0 ? true : _ref$active,
|
|
528
|
+
chat = _ref.chat,
|
|
529
|
+
continuous = _ref.continuous;
|
|
582
530
|
var data = {
|
|
583
531
|
active: active,
|
|
584
532
|
chat: {}
|
|
585
533
|
};
|
|
586
|
-
|
|
587
534
|
if (typeof continuous === 'boolean') {
|
|
588
535
|
data.continuous = continuous;
|
|
589
536
|
}
|
|
590
|
-
|
|
591
537
|
if (!chat) {
|
|
592
538
|
return data;
|
|
593
539
|
}
|
|
594
|
-
|
|
595
540
|
var access = chat.access,
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
541
|
+
thread = chat.thread,
|
|
542
|
+
properties = chat.properties;
|
|
599
543
|
if (access && access.groupIds) {
|
|
600
544
|
data.chat.access = {
|
|
601
545
|
group_ids: access.groupIds
|
|
602
546
|
};
|
|
603
547
|
}
|
|
604
|
-
|
|
605
548
|
if (properties) {
|
|
606
549
|
data.chat.properties = properties;
|
|
607
550
|
}
|
|
608
|
-
|
|
609
551
|
if (thread) {
|
|
610
552
|
data.chat.thread = parseThreadData(thread);
|
|
611
553
|
}
|
|
612
|
-
|
|
613
554
|
return data;
|
|
614
555
|
};
|
|
615
556
|
var parseResumeChatData = function parseResumeChatData(requestData) {
|
|
@@ -623,19 +564,16 @@ var parseResumeChatData = function parseResumeChatData(requestData) {
|
|
|
623
564
|
var parseCustomerSessionFields = function parseCustomerSessionFields(sessionFields) {
|
|
624
565
|
return dataUtils.toPairs(sessionFields).map(function (_ref2) {
|
|
625
566
|
var _ref3;
|
|
626
|
-
|
|
627
567
|
var key = _ref2[0],
|
|
628
|
-
|
|
568
|
+
value = _ref2[1];
|
|
629
569
|
return _ref3 = {}, _ref3[key] = value, _ref3;
|
|
630
570
|
});
|
|
631
571
|
};
|
|
632
572
|
var parseCustomerUpdate = function parseCustomerUpdate(update) {
|
|
633
573
|
var result = dataUtils.pickOwn(['avatar', 'name', 'email'], update);
|
|
634
|
-
|
|
635
574
|
if (update.sessionFields) {
|
|
636
575
|
result.session_fields = parseCustomerSessionFields(update.sessionFields);
|
|
637
576
|
}
|
|
638
|
-
|
|
639
577
|
return result;
|
|
640
578
|
};
|
|
641
579
|
|
|
@@ -665,7 +603,6 @@ var prefetchToken = function prefetchToken(fresh) {
|
|
|
665
603
|
if (fresh === void 0) {
|
|
666
604
|
fresh = false;
|
|
667
605
|
}
|
|
668
|
-
|
|
669
606
|
return {
|
|
670
607
|
type: PREFETCH_TOKEN,
|
|
671
608
|
payload: {
|
|
@@ -680,9 +617,10 @@ var reconnect = function reconnect(delay) {
|
|
|
680
617
|
delay: delay
|
|
681
618
|
}
|
|
682
619
|
};
|
|
683
|
-
};
|
|
684
|
-
// we should explore providing stricter types for this in the future
|
|
620
|
+
};
|
|
685
621
|
|
|
622
|
+
// TODO: this one was currently pretty hard to type in full
|
|
623
|
+
// we should explore providing stricter types for this in the future
|
|
686
624
|
var sendRequest = function sendRequest(action, payload, source) {
|
|
687
625
|
return {
|
|
688
626
|
type: SEND_REQUEST,
|
|
@@ -698,17 +636,15 @@ var sendRequest = function sendRequest(action, payload, source) {
|
|
|
698
636
|
};
|
|
699
637
|
var sendEvent = function sendEvent(_ref) {
|
|
700
638
|
var chatId = _ref.chatId,
|
|
701
|
-
|
|
702
|
-
|
|
639
|
+
event = _ref.event,
|
|
640
|
+
attachToLastThread = _ref.attachToLastThread;
|
|
703
641
|
var payload = {
|
|
704
642
|
chat_id: chatId,
|
|
705
643
|
event: parseEvent(event)
|
|
706
644
|
};
|
|
707
|
-
|
|
708
645
|
if (attachToLastThread) {
|
|
709
646
|
payload.attach_to_last_thread = true;
|
|
710
647
|
}
|
|
711
|
-
|
|
712
648
|
return sendRequest(SEND_EVENT, payload);
|
|
713
649
|
};
|
|
714
650
|
var setChatActive = function setChatActive(id, active) {
|
|
@@ -737,12 +673,10 @@ var socketDisconnected = function socketDisconnected() {
|
|
|
737
673
|
// TODO: this thing is not really well typed and should be improved
|
|
738
674
|
var sendRequestAction = function sendRequestAction(store, action) {
|
|
739
675
|
action.payload.id = dataUtils.generateUniqueId(store.getState().requests);
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
promise = _deferred.promise;
|
|
745
|
-
|
|
676
|
+
var _promiseDeferred = promiseUtils.promiseDeferred(),
|
|
677
|
+
resolve = _promiseDeferred.resolve,
|
|
678
|
+
reject = _promiseDeferred.reject,
|
|
679
|
+
promise = _promiseDeferred.promise;
|
|
746
680
|
action.payload.promise = promise;
|
|
747
681
|
action.payload.resolve = resolve;
|
|
748
682
|
action.payload.reject = reject;
|
|
@@ -755,56 +689,64 @@ var CUSTOMER_BANNED$1 = 'CUSTOMER_BANNED';
|
|
|
755
689
|
var USERS_LIMIT_REACHED = 'USERS_LIMIT_REACHED';
|
|
756
690
|
var WRONG_PRODUCT_VERSION = 'WRONG_PRODUCT_VERSION';
|
|
757
691
|
|
|
758
|
-
var
|
|
692
|
+
var getSideStorageKeyByLicense = function getSideStorageKeyByLicense(store, licenseId) {
|
|
759
693
|
var _store$getState = store.getState(),
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
uniqueGroups = _store$getState.uniqueGroups;
|
|
763
|
-
|
|
694
|
+
groupId = _store$getState.groupId,
|
|
695
|
+
uniqueGroups = _store$getState.uniqueGroups;
|
|
764
696
|
return "side_storage_" + licenseId + (uniqueGroups ? ":" + groupId : '');
|
|
765
697
|
};
|
|
766
|
-
|
|
767
|
-
var
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
698
|
+
var getSideStorageKeyByOrganization = function getSideStorageKeyByOrganization(store) {
|
|
699
|
+
var _store$getState2 = store.getState(),
|
|
700
|
+
organizationId = _store$getState2.organizationId,
|
|
701
|
+
groupId = _store$getState2.groupId,
|
|
702
|
+
uniqueGroups = _store$getState2.uniqueGroups;
|
|
703
|
+
return "side_storage_" + organizationId + (uniqueGroups ? ":" + groupId : '');
|
|
704
|
+
};
|
|
705
|
+
var getSideStorage = function getSideStorage(store, licenseId) {
|
|
706
|
+
var sideStorageLicenseKey = getSideStorageKeyByLicense(store, licenseId);
|
|
707
|
+
var sideStorageOrganizationKey = getSideStorageKeyByOrganization(store);
|
|
708
|
+
return storage__default['default'].getItem(sideStorageLicenseKey)["catch"](dataUtils.noop).then(function (sideStorage) {
|
|
709
|
+
if (!sideStorage) {
|
|
710
|
+
return storage__default['default'].getItem(sideStorageOrganizationKey)["catch"](dataUtils.noop).then(function (organizationSideStorage) {
|
|
711
|
+
return JSON.parse(organizationSideStorage || '{}');
|
|
712
|
+
})["catch"](dataUtils.noop);
|
|
713
|
+
}
|
|
714
|
+
return storage__default['default'].setItem(sideStorageOrganizationKey, sideStorage)["catch"](dataUtils.noop).then(function () {
|
|
715
|
+
return storage__default['default'].removeItem(sideStorageLicenseKey)["catch"](dataUtils.noop).then(function () {
|
|
716
|
+
return JSON.parse(sideStorage);
|
|
717
|
+
})["catch"](dataUtils.noop);
|
|
718
|
+
});
|
|
719
|
+
})
|
|
720
|
+
// shouldnt get triggered, just a defensive measure against malformed storage entries
|
|
721
|
+
["catch"](dataUtils.noop);
|
|
774
722
|
};
|
|
775
723
|
var saveSideStorage = function saveSideStorage(store, sideStorage) {
|
|
776
|
-
|
|
724
|
+
storage__default['default'].setItem(getSideStorageKeyByOrganization(store), JSON.stringify(sideStorage))["catch"](dataUtils.noop);
|
|
777
725
|
};
|
|
778
726
|
|
|
779
727
|
var taskChain = function taskChain(_ref, onSuccess, onError) {
|
|
780
728
|
var steps = _ref.slice(0);
|
|
781
|
-
|
|
782
729
|
var cancelled = false;
|
|
783
|
-
|
|
784
730
|
var next = function next(intermediateResult) {
|
|
785
731
|
var step = steps.shift();
|
|
786
|
-
|
|
732
|
+
promiseUtils.promiseTry(function () {
|
|
787
733
|
return step(intermediateResult);
|
|
788
734
|
}).then(function (result) {
|
|
789
735
|
if (cancelled) {
|
|
790
736
|
return;
|
|
791
737
|
}
|
|
792
|
-
|
|
793
738
|
if (steps.length) {
|
|
794
739
|
next(result);
|
|
795
740
|
return;
|
|
796
741
|
}
|
|
797
|
-
|
|
798
742
|
onSuccess(result);
|
|
799
743
|
}, function (error) {
|
|
800
744
|
if (cancelled) {
|
|
801
745
|
return;
|
|
802
746
|
}
|
|
803
|
-
|
|
804
747
|
onError(error);
|
|
805
748
|
});
|
|
806
749
|
};
|
|
807
|
-
|
|
808
750
|
next();
|
|
809
751
|
return {
|
|
810
752
|
cancel: function cancel() {
|
|
@@ -812,18 +754,15 @@ var taskChain = function taskChain(_ref, onSuccess, onError) {
|
|
|
812
754
|
}
|
|
813
755
|
};
|
|
814
756
|
};
|
|
815
|
-
|
|
816
757
|
var sendLoginFlowRequest = function sendLoginFlowRequest(store, type, payload) {
|
|
817
758
|
return sendRequestAction(store, sendRequest(type, payload, 'login'));
|
|
818
759
|
};
|
|
819
|
-
|
|
820
760
|
var delay = function delay(ms) {
|
|
821
761
|
return new Promise(function (resolve) {
|
|
822
762
|
setTimeout(resolve, ms);
|
|
823
763
|
});
|
|
824
764
|
};
|
|
825
|
-
|
|
826
|
-
function createLoginTask(auth, customerDataProvider) {
|
|
765
|
+
function createLoginTask(auth, customerDataProvider, licenseId) {
|
|
827
766
|
var store;
|
|
828
767
|
var sentPage = null;
|
|
829
768
|
var task;
|
|
@@ -837,24 +776,19 @@ function createLoginTask(auth, customerDataProvider) {
|
|
|
837
776
|
min: 1000
|
|
838
777
|
}));
|
|
839
778
|
var currentBackoffStrategy = defaultBackoffStrategy;
|
|
840
|
-
|
|
841
779
|
var destroy$1 = function destroy$1(reason) {
|
|
842
780
|
return store.dispatch(destroy(reason));
|
|
843
781
|
};
|
|
844
|
-
|
|
845
782
|
var reconnect$1 = function reconnect$1() {
|
|
846
783
|
return store.dispatch(reconnect(currentBackoffStrategy.duration()));
|
|
847
784
|
};
|
|
848
|
-
|
|
849
785
|
var getTokenAndSideStorage = function getTokenAndSideStorage() {
|
|
850
|
-
return Promise.all([auth.getToken(), getSideStorage(store)]);
|
|
786
|
+
return Promise.all([auth.getToken(), getSideStorage(store, licenseId)]);
|
|
851
787
|
};
|
|
852
|
-
|
|
853
788
|
var dispatchSelfId = function dispatchSelfId(_ref2) {
|
|
854
789
|
var token = _ref2[0],
|
|
855
|
-
|
|
790
|
+
sideStorage = _ref2[1];
|
|
856
791
|
var selfId = getSelfId(store.getState());
|
|
857
|
-
|
|
858
792
|
if (selfId === null) {
|
|
859
793
|
store.dispatch(setSelfId(token.entityId));
|
|
860
794
|
} else if (selfId !== token.entityId) {
|
|
@@ -862,19 +796,17 @@ function createLoginTask(auth, customerDataProvider) {
|
|
|
862
796
|
err.code = IDENTITY_MISMATCH;
|
|
863
797
|
throw err;
|
|
864
798
|
}
|
|
865
|
-
|
|
866
799
|
return [token, sideStorage];
|
|
867
800
|
};
|
|
868
|
-
|
|
869
801
|
var _sendLogin = function sendLogin(_ref3) {
|
|
870
802
|
var token = _ref3[0],
|
|
871
|
-
|
|
803
|
+
sideStorage = _ref3[1];
|
|
872
804
|
var state = store.getState();
|
|
873
805
|
var application = state.application,
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
806
|
+
groupId = state.groupId,
|
|
807
|
+
page = state.page,
|
|
808
|
+
referrer = state.referrer,
|
|
809
|
+
mobile = state.mobile;
|
|
878
810
|
var payload = {
|
|
879
811
|
token: token.tokenType + " " + token.accessToken,
|
|
880
812
|
customer: typeof customerDataProvider === 'function' ? parseCustomerUpdate(customerDataProvider()) : {},
|
|
@@ -882,24 +814,19 @@ function createLoginTask(auth, customerDataProvider) {
|
|
|
882
814
|
is_mobile: mobile,
|
|
883
815
|
application: dataUtils.pick(['name', 'version'], application)
|
|
884
816
|
};
|
|
885
|
-
|
|
886
817
|
if (typeof groupId === 'number') {
|
|
887
818
|
payload.group_id = groupId;
|
|
888
819
|
}
|
|
889
|
-
|
|
890
820
|
if (application.channelType) {
|
|
891
821
|
payload.application.channel_type = application.channelType;
|
|
892
822
|
}
|
|
893
|
-
|
|
894
823
|
if (page !== null) {
|
|
895
824
|
sentPage = page;
|
|
896
825
|
payload.customer_page = page;
|
|
897
826
|
}
|
|
898
|
-
|
|
899
827
|
if (referrer !== null) {
|
|
900
828
|
payload.referrer = referrer;
|
|
901
829
|
}
|
|
902
|
-
|
|
903
830
|
return Promise.race([sendLoginFlowRequest(store, LOGIN, payload), delay(15 * 1000).then(function () {
|
|
904
831
|
return Promise.reject(createError({
|
|
905
832
|
message: 'Request timed out.',
|
|
@@ -907,22 +834,17 @@ function createLoginTask(auth, customerDataProvider) {
|
|
|
907
834
|
}));
|
|
908
835
|
})]);
|
|
909
836
|
};
|
|
910
|
-
|
|
911
837
|
var updateCustomerPageIfNeeded = function updateCustomerPageIfNeeded() {
|
|
912
838
|
var _store$getState = store.getState(),
|
|
913
|
-
|
|
914
|
-
|
|
839
|
+
page = _store$getState.page;
|
|
915
840
|
if (sentPage !== page) {
|
|
916
841
|
sendLoginFlowRequest(store, UPDATE_CUSTOMER_PAGE$1, page)["catch"](dataUtils.noop);
|
|
917
842
|
}
|
|
918
|
-
|
|
919
843
|
sentPage = null;
|
|
920
844
|
};
|
|
921
|
-
|
|
922
845
|
return {
|
|
923
846
|
sendLogin: function sendLogin(_store) {
|
|
924
847
|
var _task;
|
|
925
|
-
|
|
926
848
|
// after switching to callbags, we should be able to use smth similar to redux-observable
|
|
927
849
|
// and thus just use store given to epic
|
|
928
850
|
store = _store;
|
|
@@ -931,62 +853,52 @@ function createLoginTask(auth, customerDataProvider) {
|
|
|
931
853
|
task = null;
|
|
932
854
|
defaultBackoffStrategy.reset();
|
|
933
855
|
slowerBackoffStrategy.reset();
|
|
934
|
-
currentBackoffStrategy = defaultBackoffStrategy;
|
|
856
|
+
currentBackoffStrategy = defaultBackoffStrategy;
|
|
935
857
|
|
|
858
|
+
// TODO: rethink if this should be handled by SDK consumer
|
|
936
859
|
updateCustomerPageIfNeeded();
|
|
937
860
|
store.dispatch(loginSuccess(loginResponse));
|
|
938
861
|
}, function (error) {
|
|
939
862
|
task = null;
|
|
940
|
-
|
|
941
863
|
if (process.env.NODE_ENV !== 'production') {
|
|
942
864
|
console.error('[Customer SDK] Login flow has thrown code', error.code, 'with', error);
|
|
943
865
|
}
|
|
944
|
-
|
|
945
866
|
switch (error.code) {
|
|
946
867
|
case AUTHENTICATION:
|
|
947
868
|
auth.getFreshToken();
|
|
948
869
|
reconnect$1();
|
|
949
870
|
return;
|
|
950
|
-
|
|
951
871
|
case CONNECTION_LOST:
|
|
952
872
|
// this is connectivity problem, not a server error
|
|
953
873
|
// and is taken care of in socket module
|
|
954
874
|
// as it has its own backoff implementation
|
|
955
875
|
return;
|
|
956
|
-
|
|
957
876
|
case MISDIRECTED_CONNECTION:
|
|
958
877
|
// socket gets reinitialized on this anyway, so just ignore it here
|
|
959
878
|
return;
|
|
960
|
-
|
|
961
879
|
case SDK_DESTROYED:
|
|
962
880
|
return;
|
|
963
881
|
// those are auth errors, we should maybe export those constants from the auth package
|
|
964
|
-
|
|
965
882
|
case 'SSO_IDENTITY_EXCEPTION':
|
|
966
883
|
case 'SSO_OAUTH_EXCEPTION':
|
|
967
884
|
if (error.message === 'server_error' || error.message === 'temporarily_unavailable') {
|
|
968
885
|
reconnect$1();
|
|
969
886
|
return;
|
|
970
887
|
}
|
|
971
|
-
|
|
972
888
|
destroy$1(error.message);
|
|
973
889
|
return;
|
|
974
|
-
|
|
975
890
|
case USERS_LIMIT_REACHED:
|
|
976
891
|
store.dispatch(pauseConnection(error.code.toLowerCase()));
|
|
977
892
|
return;
|
|
978
|
-
|
|
979
893
|
case IDENTITY_MISMATCH:
|
|
980
894
|
case CUSTOMER_BANNED$1:
|
|
981
895
|
case WRONG_PRODUCT_VERSION:
|
|
982
896
|
destroy$1(error.code.toLowerCase());
|
|
983
897
|
return;
|
|
984
|
-
|
|
985
898
|
case SERVICE_TEMPORARILY_UNAVAILABLE:
|
|
986
899
|
currentBackoffStrategy = slowerBackoffStrategy;
|
|
987
900
|
reconnect$1();
|
|
988
901
|
return;
|
|
989
|
-
|
|
990
902
|
default:
|
|
991
903
|
reconnect$1();
|
|
992
904
|
return;
|
|
@@ -995,7 +907,6 @@ function createLoginTask(auth, customerDataProvider) {
|
|
|
995
907
|
},
|
|
996
908
|
cancel: function cancel() {
|
|
997
909
|
var _task2;
|
|
998
|
-
|
|
999
910
|
(_task2 = task) == null ? void 0 : _task2.cancel();
|
|
1000
911
|
}
|
|
1001
912
|
};
|
|
@@ -1004,19 +915,15 @@ function createLoginTask(auth, customerDataProvider) {
|
|
|
1004
915
|
var checkGoals = function checkGoals(store, auth, sessionFields) {
|
|
1005
916
|
return auth.getToken().then(function (token) {
|
|
1006
917
|
var state = store.getState();
|
|
1007
|
-
|
|
1008
918
|
if (getSelfId(state) === null) {
|
|
1009
919
|
store.dispatch(setSelfId(token.entityId));
|
|
1010
920
|
}
|
|
1011
|
-
|
|
1012
921
|
var page = state.page;
|
|
1013
|
-
|
|
1014
922
|
if (!page || !page.url) {
|
|
1015
923
|
return;
|
|
1016
924
|
}
|
|
1017
|
-
|
|
1018
925
|
var query = urlUtils.buildQueryString({
|
|
1019
|
-
|
|
926
|
+
organization_id: state.organizationId
|
|
1020
927
|
});
|
|
1021
928
|
var payload = {
|
|
1022
929
|
session_fields: parseCustomerSessionFields(sessionFields || {}),
|
|
@@ -1039,7 +946,7 @@ var checkGoals = function checkGoals(store, auth, sessionFields) {
|
|
|
1039
946
|
|
|
1040
947
|
var failAllRequests = function failAllRequests(_ref, reason) {
|
|
1041
948
|
var getState = _ref.getState,
|
|
1042
|
-
|
|
949
|
+
dispatch = _ref.dispatch;
|
|
1043
950
|
var state = getState();
|
|
1044
951
|
var requests = getAllRequests(state);
|
|
1045
952
|
dispatch({
|
|
@@ -1054,7 +961,7 @@ var failAllRequests = function failAllRequests(_ref, reason) {
|
|
|
1054
961
|
};
|
|
1055
962
|
var failRequest = function failRequest(_ref2, requestAction, error) {
|
|
1056
963
|
var getState = _ref2.getState,
|
|
1057
|
-
|
|
964
|
+
dispatch = _ref2.dispatch;
|
|
1058
965
|
var requestId = requestAction.payload.id;
|
|
1059
966
|
dispatch({
|
|
1060
967
|
type: REQUEST_FAILED,
|
|
@@ -1078,22 +985,17 @@ var parseCommonEventProps = function parseCommonEventProps(threadId, event) {
|
|
|
1078
985
|
threadId: threadId,
|
|
1079
986
|
properties: event.properties || {}
|
|
1080
987
|
};
|
|
1081
|
-
|
|
1082
988
|
if (event.custom_id !== undefined) {
|
|
1083
989
|
parsed.customId = event.custom_id;
|
|
1084
990
|
}
|
|
1085
|
-
|
|
1086
991
|
return parsed;
|
|
1087
992
|
};
|
|
1088
|
-
|
|
1089
993
|
var downsizeWithRatio = function downsizeWithRatio(max, dimensions) {
|
|
1090
994
|
var _ref;
|
|
1091
|
-
|
|
1092
995
|
var biggerProp;
|
|
1093
996
|
var smallerProp;
|
|
1094
997
|
var bigger;
|
|
1095
998
|
var smaller;
|
|
1096
|
-
|
|
1097
999
|
if (dimensions.height > dimensions.width) {
|
|
1098
1000
|
biggerProp = 'height';
|
|
1099
1001
|
smallerProp = 'width';
|
|
@@ -1105,11 +1007,9 @@ var downsizeWithRatio = function downsizeWithRatio(max, dimensions) {
|
|
|
1105
1007
|
bigger = dimensions.width;
|
|
1106
1008
|
smaller = dimensions.height;
|
|
1107
1009
|
}
|
|
1108
|
-
|
|
1109
1010
|
var ratio = max / bigger;
|
|
1110
1011
|
return _ref = {}, _ref[biggerProp] = Math.ceil(Math.min(bigger, max)), _ref[smallerProp] = Math.ceil(Math.min(ratio * smaller, smaller)), _ref;
|
|
1111
1012
|
};
|
|
1112
|
-
|
|
1113
1013
|
var parseImage = function parseImage(thread, image) {
|
|
1114
1014
|
return _extends({}, parseCommonEventProps(thread, image), {
|
|
1115
1015
|
type: FILE,
|
|
@@ -1130,12 +1030,10 @@ var parseImage = function parseImage(thread, image) {
|
|
|
1130
1030
|
alternativeText: image.alternative_text
|
|
1131
1031
|
});
|
|
1132
1032
|
};
|
|
1133
|
-
|
|
1134
1033
|
var parseFile = function parseFile(thread, file) {
|
|
1135
1034
|
if (file.width !== undefined && file.height !== undefined) {
|
|
1136
1035
|
return parseImage(thread, file);
|
|
1137
1036
|
}
|
|
1138
|
-
|
|
1139
1037
|
return _extends({}, parseCommonEventProps(thread, file), {
|
|
1140
1038
|
type: FILE,
|
|
1141
1039
|
contentType: file.content_type,
|
|
@@ -1162,18 +1060,15 @@ var parseFilledForm = function parseFilledForm(thread, filledForm) {
|
|
|
1162
1060
|
if (!field.answer) {
|
|
1163
1061
|
return field;
|
|
1164
1062
|
}
|
|
1165
|
-
|
|
1166
1063
|
var _field$answer = field.answer,
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1064
|
+
groupId = _field$answer.group_id,
|
|
1065
|
+
answer = _objectWithoutPropertiesLoose(_field$answer, ["group_id"]);
|
|
1170
1066
|
return _extends({}, field, {
|
|
1171
1067
|
answer: _extends({}, answer, {
|
|
1172
1068
|
groupId: groupId
|
|
1173
1069
|
})
|
|
1174
1070
|
});
|
|
1175
1071
|
}
|
|
1176
|
-
|
|
1177
1072
|
default:
|
|
1178
1073
|
return field;
|
|
1179
1074
|
}
|
|
@@ -1193,18 +1088,14 @@ var parseCustomEvent = function parseCustomEvent(thread, event) {
|
|
|
1193
1088
|
content: event.content
|
|
1194
1089
|
});
|
|
1195
1090
|
};
|
|
1196
|
-
|
|
1197
1091
|
var parseRichMessageElement = function parseRichMessageElement(element) {
|
|
1198
1092
|
var parsed = {};
|
|
1199
|
-
|
|
1200
1093
|
if (typeof element.title === 'string') {
|
|
1201
1094
|
parsed.title = element.title;
|
|
1202
1095
|
}
|
|
1203
|
-
|
|
1204
1096
|
if (typeof element.subtitle === 'string') {
|
|
1205
1097
|
parsed.subtitle = element.subtitle;
|
|
1206
1098
|
}
|
|
1207
|
-
|
|
1208
1099
|
if (element.image) {
|
|
1209
1100
|
// TODO: we should reuse parseImage here
|
|
1210
1101
|
var image = element.image;
|
|
@@ -1215,7 +1106,6 @@ var parseRichMessageElement = function parseRichMessageElement(element) {
|
|
|
1215
1106
|
alternativeText: image.alternative_text
|
|
1216
1107
|
});
|
|
1217
1108
|
}
|
|
1218
|
-
|
|
1219
1109
|
if (element.buttons) {
|
|
1220
1110
|
parsed.buttons = element.buttons.map(function (serverButton) {
|
|
1221
1111
|
switch (serverButton.type) {
|
|
@@ -1231,7 +1121,6 @@ var parseRichMessageElement = function parseRichMessageElement(element) {
|
|
|
1231
1121
|
role: serverButton.role || 'default'
|
|
1232
1122
|
};
|
|
1233
1123
|
}
|
|
1234
|
-
|
|
1235
1124
|
case 'cancel':
|
|
1236
1125
|
{
|
|
1237
1126
|
return {
|
|
@@ -1242,7 +1131,6 @@ var parseRichMessageElement = function parseRichMessageElement(element) {
|
|
|
1242
1131
|
role: serverButton.role || 'default'
|
|
1243
1132
|
};
|
|
1244
1133
|
}
|
|
1245
|
-
|
|
1246
1134
|
case 'url':
|
|
1247
1135
|
{
|
|
1248
1136
|
var button = {
|
|
@@ -1253,14 +1141,11 @@ var parseRichMessageElement = function parseRichMessageElement(element) {
|
|
|
1253
1141
|
value: serverButton.value,
|
|
1254
1142
|
role: serverButton.role || 'default'
|
|
1255
1143
|
};
|
|
1256
|
-
|
|
1257
1144
|
if (serverButton.target) {
|
|
1258
1145
|
button.target = serverButton.target;
|
|
1259
1146
|
}
|
|
1260
|
-
|
|
1261
1147
|
return button;
|
|
1262
1148
|
}
|
|
1263
|
-
|
|
1264
1149
|
case 'webview':
|
|
1265
1150
|
{
|
|
1266
1151
|
var _button = {
|
|
@@ -1271,14 +1156,11 @@ var parseRichMessageElement = function parseRichMessageElement(element) {
|
|
|
1271
1156
|
value: serverButton.value,
|
|
1272
1157
|
role: serverButton.role || 'default'
|
|
1273
1158
|
};
|
|
1274
|
-
|
|
1275
1159
|
if (typeof serverButton.webview_height === 'string') {
|
|
1276
1160
|
_button.webviewHeight = serverButton.webview_height;
|
|
1277
1161
|
}
|
|
1278
|
-
|
|
1279
1162
|
return _button;
|
|
1280
1163
|
}
|
|
1281
|
-
|
|
1282
1164
|
default:
|
|
1283
1165
|
{
|
|
1284
1166
|
return {
|
|
@@ -1291,10 +1173,8 @@ var parseRichMessageElement = function parseRichMessageElement(element) {
|
|
|
1291
1173
|
}
|
|
1292
1174
|
});
|
|
1293
1175
|
}
|
|
1294
|
-
|
|
1295
1176
|
return parsed;
|
|
1296
1177
|
};
|
|
1297
|
-
|
|
1298
1178
|
var parseRichMessage = function parseRichMessage(thread, richMessage) {
|
|
1299
1179
|
switch (richMessage.template_id) {
|
|
1300
1180
|
case 'cards':
|
|
@@ -1305,7 +1185,6 @@ var parseRichMessage = function parseRichMessage(thread, richMessage) {
|
|
|
1305
1185
|
template: richMessage.template_id,
|
|
1306
1186
|
elements: richMessage.elements.map(parseRichMessageElement)
|
|
1307
1187
|
});
|
|
1308
|
-
|
|
1309
1188
|
default:
|
|
1310
1189
|
return null;
|
|
1311
1190
|
}
|
|
@@ -1318,36 +1197,27 @@ var parseSystemMessage = function parseSystemMessage(thread, systemMessage) {
|
|
|
1318
1197
|
text: systemMessage.text,
|
|
1319
1198
|
systemMessageType: systemMessage.system_message_type
|
|
1320
1199
|
});
|
|
1321
|
-
|
|
1322
1200
|
if (systemMessage.text_vars) {
|
|
1323
1201
|
parsed.textVars = systemMessage.text_vars;
|
|
1324
1202
|
}
|
|
1325
|
-
|
|
1326
1203
|
return parsed;
|
|
1327
1204
|
};
|
|
1328
1205
|
var parseEvent$1 = function parseEvent(thread, event) {
|
|
1329
1206
|
switch (event.type) {
|
|
1330
1207
|
case FILE:
|
|
1331
1208
|
return parseFile(thread, event);
|
|
1332
|
-
|
|
1333
1209
|
case FORM:
|
|
1334
1210
|
return parseForm(thread, event);
|
|
1335
|
-
|
|
1336
1211
|
case FILLED_FORM:
|
|
1337
1212
|
return parseFilledForm(thread, event);
|
|
1338
|
-
|
|
1339
1213
|
case MESSAGE:
|
|
1340
1214
|
return parseMessage(thread, event);
|
|
1341
|
-
|
|
1342
1215
|
case RICH_MESSAGE:
|
|
1343
1216
|
return parseRichMessage(thread, event);
|
|
1344
|
-
|
|
1345
1217
|
case SYSTEM_MESSAGE:
|
|
1346
1218
|
return parseSystemMessage(thread, event);
|
|
1347
|
-
|
|
1348
1219
|
case CUSTOM:
|
|
1349
1220
|
return parseCustomEvent(thread, event);
|
|
1350
|
-
|
|
1351
1221
|
default:
|
|
1352
1222
|
return null;
|
|
1353
1223
|
}
|
|
@@ -1372,23 +1242,20 @@ var parseGreeting = function parseGreeting(greeting) {
|
|
|
1372
1242
|
};
|
|
1373
1243
|
};
|
|
1374
1244
|
|
|
1245
|
+
// we could use `mergeAll` for this, but we need to preserve insertion order here
|
|
1375
1246
|
// so it's better to rely on a custom implementation
|
|
1376
|
-
|
|
1377
1247
|
var parseCustomerSessionFields$1 = function parseCustomerSessionFields(sessionFields) {
|
|
1378
1248
|
return sessionFields.reduce(function (acc, field) {
|
|
1379
1249
|
var _Object$keys = Object.keys(field),
|
|
1380
|
-
|
|
1381
|
-
|
|
1250
|
+
key = _Object$keys[0];
|
|
1382
1251
|
acc[key] = field[key];
|
|
1383
1252
|
return acc;
|
|
1384
1253
|
}, {});
|
|
1385
1254
|
};
|
|
1386
|
-
|
|
1387
1255
|
var parseAccess = function parseAccess(access) {
|
|
1388
1256
|
if (access === void 0) {
|
|
1389
1257
|
access = {};
|
|
1390
1258
|
}
|
|
1391
|
-
|
|
1392
1259
|
return access.group_ids ? {
|
|
1393
1260
|
groupIds: access.group_ids
|
|
1394
1261
|
} : {};
|
|
@@ -1440,14 +1307,11 @@ var parseChatAgent = function parseChatAgent(agent) {
|
|
|
1440
1307
|
};
|
|
1441
1308
|
var parseCustomerOptionalProps = function parseCustomerOptionalProps(customerProps) {
|
|
1442
1309
|
var optionalProps = dataUtils.pickOwn(['avatar', 'email', 'name'], customerProps);
|
|
1443
|
-
|
|
1444
1310
|
if (customerProps.session_fields) {
|
|
1445
1311
|
optionalProps.sessionFields = parseCustomerSessionFields$1(customerProps.session_fields);
|
|
1446
1312
|
}
|
|
1447
|
-
|
|
1448
1313
|
return optionalProps;
|
|
1449
1314
|
};
|
|
1450
|
-
|
|
1451
1315
|
var parseCustomerCommonProps = function parseCustomerCommonProps(customer) {
|
|
1452
1316
|
var optionalProps = parseCustomerOptionalProps(customer);
|
|
1453
1317
|
return _extends({
|
|
@@ -1457,7 +1321,6 @@ var parseCustomerCommonProps = function parseCustomerCommonProps(customer) {
|
|
|
1457
1321
|
sessionFields: optionalProps.sessionFields || {}
|
|
1458
1322
|
});
|
|
1459
1323
|
};
|
|
1460
|
-
|
|
1461
1324
|
var parseChatCustomer = function parseChatCustomer(customer) {
|
|
1462
1325
|
return _extends({}, parseCustomerCommonProps(customer), {
|
|
1463
1326
|
present: customer.present
|
|
@@ -1478,7 +1341,7 @@ var parseCustomer = function parseCustomer(customer) {
|
|
|
1478
1341
|
};
|
|
1479
1342
|
var parsePredictedAgent = function parsePredictedAgent(payload) {
|
|
1480
1343
|
var agent = payload.agent,
|
|
1481
|
-
|
|
1344
|
+
queue = payload.queue;
|
|
1482
1345
|
return {
|
|
1483
1346
|
agent: {
|
|
1484
1347
|
id: agent.id,
|
|
@@ -1511,12 +1374,11 @@ var parseGroupStatus = function parseGroupStatus(status) {
|
|
|
1511
1374
|
|
|
1512
1375
|
var _FAIL_ALL_REQUESTS_ME;
|
|
1513
1376
|
|
|
1377
|
+
// TODO: rethink how we handle reconnects
|
|
1514
1378
|
var SMALL_RECONNECT_DELAY = 100;
|
|
1515
1379
|
var FAIL_ALL_REQUESTS_MESSAGES = (_FAIL_ALL_REQUESTS_ME = {}, _FAIL_ALL_REQUESTS_ME[CONNECTION_LOST] = 'Connection lost.', _FAIL_ALL_REQUESTS_ME[MISDIRECTED_CONNECTION] = 'Connected to wrong region.', _FAIL_ALL_REQUESTS_ME);
|
|
1516
|
-
|
|
1517
1380
|
var updateStateIfNeeded = function updateStateIfNeeded(store, action) {
|
|
1518
1381
|
var state = store.getState();
|
|
1519
|
-
|
|
1520
1382
|
switch (action.type) {
|
|
1521
1383
|
case PUSH_RESPONSE_RECEIVED:
|
|
1522
1384
|
case PUSH_RECEIVED:
|
|
@@ -1524,56 +1386,49 @@ var updateStateIfNeeded = function updateStateIfNeeded(store, action) {
|
|
|
1524
1386
|
case CHAT_DEACTIVATED:
|
|
1525
1387
|
store.dispatch(setChatActive(action.payload.payload.chatId, false));
|
|
1526
1388
|
return;
|
|
1527
|
-
|
|
1528
1389
|
case INCOMING_CHAT:
|
|
1529
1390
|
store.dispatch(setChatActive(action.payload.payload.chat.id, true));
|
|
1530
1391
|
return;
|
|
1531
|
-
|
|
1532
1392
|
default:
|
|
1533
1393
|
return;
|
|
1534
1394
|
}
|
|
1535
|
-
|
|
1536
1395
|
case RESPONSE_RECEIVED:
|
|
1537
1396
|
switch (action.payload.action) {
|
|
1538
1397
|
case LIST_CHATS:
|
|
1539
1398
|
action.payload.payload.chatsSummary.filter(function (_ref) {
|
|
1540
1399
|
var id = _ref.id,
|
|
1541
|
-
|
|
1400
|
+
active = _ref.active;
|
|
1542
1401
|
return isChatActive(state, id) !== active;
|
|
1543
1402
|
}).forEach(function (_ref2) {
|
|
1544
1403
|
var id = _ref2.id,
|
|
1545
|
-
|
|
1404
|
+
active = _ref2.active;
|
|
1546
1405
|
store.dispatch(setChatActive(id, active));
|
|
1547
1406
|
});
|
|
1548
1407
|
return;
|
|
1549
|
-
|
|
1550
1408
|
default:
|
|
1551
1409
|
return;
|
|
1552
1410
|
}
|
|
1553
|
-
|
|
1554
1411
|
}
|
|
1555
1412
|
};
|
|
1556
|
-
|
|
1557
1413
|
var sendRequest$1 = function sendRequest(socket, _ref3) {
|
|
1558
1414
|
var _ref3$payload = _ref3.payload,
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1415
|
+
id = _ref3$payload.id,
|
|
1416
|
+
request = _ref3$payload.request;
|
|
1562
1417
|
var frame = _extends({
|
|
1563
1418
|
request_id: id
|
|
1564
1419
|
}, request);
|
|
1565
|
-
|
|
1566
1420
|
switch (frame.action) {
|
|
1567
1421
|
case LOGIN:
|
|
1568
1422
|
{
|
|
1569
1423
|
var upgradedPushes = [];
|
|
1570
1424
|
socket.emit(_extends({}, frame, {
|
|
1571
|
-
version: '3.
|
|
1425
|
+
version: '3.4',
|
|
1572
1426
|
payload: _extends({}, frame.payload, {
|
|
1573
1427
|
pushes: {
|
|
1574
|
-
// '3.
|
|
1575
|
-
'3.
|
|
1576
|
-
return (
|
|
1428
|
+
// '3.5': upgradedPushes,
|
|
1429
|
+
'3.4': dataUtils.values(serverPushActions).filter(function (pushAction) {
|
|
1430
|
+
return (
|
|
1431
|
+
// `customer_disconnected` can be sent immediately after opening the connection, before it even received login request
|
|
1577
1432
|
// therefore it's not possible to subscribe for a particular version of this push - the "connection version" is always used
|
|
1578
1433
|
pushAction !== CUSTOMER_DISCONNECTED && !dataUtils.includes(pushAction, upgradedPushes)
|
|
1579
1434
|
);
|
|
@@ -1583,56 +1438,45 @@ var sendRequest$1 = function sendRequest(socket, _ref3) {
|
|
|
1583
1438
|
}));
|
|
1584
1439
|
return;
|
|
1585
1440
|
}
|
|
1586
|
-
|
|
1587
1441
|
default:
|
|
1588
1442
|
socket.emit(frame);
|
|
1589
1443
|
return;
|
|
1590
1444
|
}
|
|
1591
1445
|
};
|
|
1592
|
-
|
|
1593
1446
|
var emitUsers = function emitUsers(emit, users) {
|
|
1594
1447
|
users.forEach(function (user) {
|
|
1595
1448
|
if ('present' in user) {
|
|
1596
1449
|
var rest = _objectWithoutPropertiesLoose(user, ["present"]);
|
|
1597
|
-
|
|
1598
1450
|
emit('user_data', rest);
|
|
1599
1451
|
return;
|
|
1600
1452
|
}
|
|
1601
|
-
|
|
1602
1453
|
if (user.type === CUSTOMER) {
|
|
1603
1454
|
var _rest = _objectWithoutPropertiesLoose(user, ["statistics"]);
|
|
1604
|
-
|
|
1605
1455
|
emit('user_data', _rest);
|
|
1606
1456
|
return;
|
|
1607
1457
|
}
|
|
1608
|
-
|
|
1609
1458
|
emit('user_data', user);
|
|
1610
1459
|
});
|
|
1611
1460
|
};
|
|
1612
|
-
|
|
1613
1461
|
var handleMulticast = function handleMulticast(emit, _ref4) {
|
|
1614
1462
|
var type = _ref4.type,
|
|
1615
|
-
|
|
1616
|
-
|
|
1463
|
+
content = _ref4.content;
|
|
1617
1464
|
if (type !== 'lc2') {
|
|
1618
1465
|
return;
|
|
1619
1466
|
}
|
|
1620
|
-
|
|
1621
1467
|
if (content.name === 'groups_update' && 'groups' in content && !dataUtils.isEmpty(content.groups)) {
|
|
1622
1468
|
var _content$groups = content.groups,
|
|
1623
|
-
|
|
1469
|
+
group = _content$groups[0];
|
|
1624
1470
|
var availability = parseGroupStatus(group.status);
|
|
1625
1471
|
emit('availability_updated', {
|
|
1626
1472
|
availability: availability
|
|
1627
1473
|
});
|
|
1628
1474
|
}
|
|
1629
1475
|
};
|
|
1630
|
-
|
|
1631
1476
|
var handlePush = function handlePush(_ref5, _ref6) {
|
|
1632
1477
|
var emit = _ref5.emit,
|
|
1633
|
-
|
|
1478
|
+
store = _ref5.store;
|
|
1634
1479
|
var payload = _ref6.payload;
|
|
1635
|
-
|
|
1636
1480
|
switch (payload.action) {
|
|
1637
1481
|
case THREAD_PROPERTIES_UPDATED:
|
|
1638
1482
|
if (payload.payload.properties.lc2 && 'queue_pos' in payload.payload.properties.lc2) {
|
|
@@ -1645,14 +1489,11 @@ var handlePush = function handlePush(_ref5, _ref6) {
|
|
|
1645
1489
|
}
|
|
1646
1490
|
});
|
|
1647
1491
|
}
|
|
1648
|
-
|
|
1649
1492
|
emit('thread_properties_updated', payload.payload);
|
|
1650
1493
|
return;
|
|
1651
|
-
|
|
1652
1494
|
case CUSTOMER_SIDE_STORAGE_UPDATED:
|
|
1653
1495
|
saveSideStorage(store, payload.payload.customer_side_storage);
|
|
1654
1496
|
return;
|
|
1655
|
-
|
|
1656
1497
|
case CUSTOMER_DISCONNECTED:
|
|
1657
1498
|
// each of those should currently lead to either reconnect or destroy call
|
|
1658
1499
|
// after receiving this push server closes the connection with us
|
|
@@ -1669,7 +1510,6 @@ var handlePush = function handlePush(_ref5, _ref6) {
|
|
|
1669
1510
|
store.dispatch(reconnect(SMALL_RECONNECT_DELAY));
|
|
1670
1511
|
emit('disconnected', payload.payload);
|
|
1671
1512
|
break;
|
|
1672
|
-
|
|
1673
1513
|
case CUSTOMER_BANNED:
|
|
1674
1514
|
case CUSTOMER_TEMPORARILY_BLOCKED:
|
|
1675
1515
|
case LICENSE_NOT_FOUND:
|
|
@@ -1679,7 +1519,6 @@ var handlePush = function handlePush(_ref5, _ref6) {
|
|
|
1679
1519
|
// this also emits `disconnected` event - but it's handled in response to this action by destroy handler
|
|
1680
1520
|
store.dispatch(destroy(payload.payload.reason));
|
|
1681
1521
|
break;
|
|
1682
|
-
|
|
1683
1522
|
case MISDIRECTED_CONNECTION$1:
|
|
1684
1523
|
failAllRequests(store, MISDIRECTED_CONNECTION);
|
|
1685
1524
|
store.dispatch({
|
|
@@ -1687,119 +1526,99 @@ var handlePush = function handlePush(_ref5, _ref6) {
|
|
|
1687
1526
|
payload: payload.payload.data
|
|
1688
1527
|
});
|
|
1689
1528
|
break;
|
|
1690
|
-
|
|
1691
1529
|
case SERVICE_TEMPORARILY_UNAVAILABLE$1:
|
|
1692
1530
|
case TOO_MANY_UNAUTHORIZED_CONNECTIONS:
|
|
1693
1531
|
// this should only really fail a `login` request - as it's the only one sent before authorization
|
|
1694
1532
|
// and login should reconnect on its own right now
|
|
1695
1533
|
failAllRequests(store, payload.payload.reason.toUpperCase());
|
|
1696
1534
|
break;
|
|
1697
|
-
|
|
1698
1535
|
default:
|
|
1699
1536
|
store.dispatch(reconnect(SMALL_RECONNECT_DELAY));
|
|
1700
1537
|
emit('disconnected', payload.payload);
|
|
1701
1538
|
break;
|
|
1702
1539
|
}
|
|
1703
|
-
|
|
1704
1540
|
return;
|
|
1705
|
-
|
|
1706
1541
|
case INCOMING_CHAT:
|
|
1707
1542
|
emitUsers(emit, payload.payload.chat.users);
|
|
1708
1543
|
emit(payload.action, payload.payload);
|
|
1709
1544
|
return;
|
|
1710
|
-
|
|
1711
1545
|
case INCOMING_EVENT:
|
|
1712
1546
|
if (payload.payload.event === null) {
|
|
1713
1547
|
return;
|
|
1714
1548
|
}
|
|
1715
|
-
|
|
1716
1549
|
emit(payload.action, payload.payload);
|
|
1717
1550
|
return;
|
|
1718
|
-
|
|
1719
1551
|
case INCOMING_TYPING_INDICATOR:
|
|
1720
1552
|
emit(payload.action, payload.payload);
|
|
1721
1553
|
return;
|
|
1722
|
-
|
|
1723
1554
|
case INCOMING_MULTICAST:
|
|
1724
|
-
handleMulticast(emit, payload.payload);
|
|
1725
|
-
|
|
1555
|
+
handleMulticast(emit, payload.payload);
|
|
1556
|
+
// we passthrough this action even if it was already handled above
|
|
1726
1557
|
emit(payload.action, payload.payload);
|
|
1727
1558
|
return;
|
|
1728
|
-
|
|
1729
1559
|
case USER_ADDED_TO_CHAT:
|
|
1730
1560
|
emitUsers(emit, [payload.payload.user]);
|
|
1731
1561
|
emit(payload.action, payload.payload);
|
|
1732
1562
|
return;
|
|
1733
|
-
|
|
1734
1563
|
default:
|
|
1735
1564
|
emit(payload.action, payload.payload);
|
|
1736
1565
|
return;
|
|
1737
1566
|
}
|
|
1738
1567
|
};
|
|
1739
|
-
|
|
1740
1568
|
var handleResponse = function handleResponse(_ref7, _ref8) {
|
|
1741
1569
|
var emit = _ref7.emit;
|
|
1742
1570
|
var payload = _ref8.payload;
|
|
1743
|
-
|
|
1744
1571
|
switch (payload.action) {
|
|
1745
1572
|
case CHAT_DEACTIVATED:
|
|
1746
1573
|
payload.resolve(SUCCESS);
|
|
1747
1574
|
return;
|
|
1748
|
-
|
|
1749
1575
|
case GET_CHAT:
|
|
1750
1576
|
emitUsers(emit, payload.payload.users);
|
|
1751
1577
|
payload.resolve(payload.payload);
|
|
1752
1578
|
return;
|
|
1753
|
-
|
|
1754
1579
|
case INCOMING_CHAT:
|
|
1755
1580
|
emitUsers(emit, payload.payload.chat.users);
|
|
1756
1581
|
payload.resolve(payload.payload);
|
|
1757
1582
|
return;
|
|
1758
|
-
|
|
1759
1583
|
case INCOMING_EVENT:
|
|
1760
1584
|
payload.resolve(payload.payload.event);
|
|
1761
1585
|
return;
|
|
1762
|
-
|
|
1763
1586
|
case LIST_CHATS:
|
|
1764
1587
|
emitUsers(emit, payload.payload.users);
|
|
1765
1588
|
payload.resolve(payload.payload);
|
|
1766
1589
|
return;
|
|
1767
|
-
|
|
1768
1590
|
default:
|
|
1769
1591
|
payload.resolve(payload.payload);
|
|
1770
1592
|
return;
|
|
1771
1593
|
}
|
|
1772
1594
|
};
|
|
1773
|
-
|
|
1774
1595
|
var createSideEffectsHandler = (function (_ref9) {
|
|
1775
1596
|
var auth = _ref9.auth,
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1597
|
+
customerDataProvider = _ref9.customerDataProvider,
|
|
1598
|
+
emitter = _ref9.emitter,
|
|
1599
|
+
socket = _ref9.socket,
|
|
1600
|
+
licenseId = _ref9.licenseId;
|
|
1779
1601
|
var emit = emitter.emit;
|
|
1780
|
-
var loginTask = createLoginTask(auth, customerDataProvider);
|
|
1602
|
+
var loginTask = createLoginTask(auth, customerDataProvider, licenseId);
|
|
1781
1603
|
|
|
1604
|
+
// TODO: using Store type here is a lie, middleware only provides MiddlewareAPI here
|
|
1782
1605
|
return function (action, store) {
|
|
1783
1606
|
switch (action.type) {
|
|
1784
1607
|
case CHANGE_REGION:
|
|
1785
1608
|
socket.reinitialize();
|
|
1786
1609
|
return;
|
|
1787
|
-
|
|
1788
1610
|
case CHECK_GOALS:
|
|
1789
1611
|
checkGoals(store, auth, action.payload.sessionFields)["catch"](dataUtils.noop);
|
|
1790
1612
|
return;
|
|
1791
|
-
|
|
1792
1613
|
case DESTROY:
|
|
1793
1614
|
{
|
|
1794
1615
|
var payload = action.payload;
|
|
1795
1616
|
loginTask.cancel();
|
|
1796
1617
|
socket.destroy();
|
|
1797
|
-
|
|
1798
1618
|
switch (payload.reason) {
|
|
1799
1619
|
case 'manual':
|
|
1800
1620
|
failAllRequests(store, SDK_DESTROYED);
|
|
1801
1621
|
break;
|
|
1802
|
-
|
|
1803
1622
|
case CUSTOMER_BANNED:
|
|
1804
1623
|
case LICENSE_EXPIRED:
|
|
1805
1624
|
case PRODUCT_VERSION_CHANGED:
|
|
@@ -1807,7 +1626,6 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
1807
1626
|
failAllRequests(store, CONNECTION_LOST);
|
|
1808
1627
|
emit('disconnected', payload);
|
|
1809
1628
|
break;
|
|
1810
|
-
|
|
1811
1629
|
default:
|
|
1812
1630
|
// in general those deestroys should only come either from login errors
|
|
1813
1631
|
// or from customer_disconnected pushes that are sent immediately after connection
|
|
@@ -1816,16 +1634,14 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
1816
1634
|
emit('disconnected', payload);
|
|
1817
1635
|
break;
|
|
1818
1636
|
}
|
|
1819
|
-
|
|
1820
1637
|
emitter.off();
|
|
1821
1638
|
return;
|
|
1822
1639
|
}
|
|
1823
|
-
|
|
1824
1640
|
case FAIL_ALL_REQUESTS:
|
|
1825
1641
|
{
|
|
1826
1642
|
var _action$payload = action.payload,
|
|
1827
|
-
|
|
1828
|
-
|
|
1643
|
+
reason = _action$payload.reason,
|
|
1644
|
+
rejects = _action$payload.rejects;
|
|
1829
1645
|
var error = {
|
|
1830
1646
|
message: FAIL_ALL_REQUESTS_MESSAGES[reason],
|
|
1831
1647
|
code: reason
|
|
@@ -1835,23 +1651,20 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
1835
1651
|
});
|
|
1836
1652
|
return;
|
|
1837
1653
|
}
|
|
1838
|
-
|
|
1839
1654
|
case LOGIN_SUCCESS:
|
|
1840
1655
|
{
|
|
1841
1656
|
var _action$payload2 = action.payload,
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1657
|
+
dynamicConfig = _action$payload2.dynamicConfig,
|
|
1658
|
+
customer = _action$payload2.customer,
|
|
1659
|
+
chats = _action$payload2.chats,
|
|
1660
|
+
greeting = _action$payload2.greeting,
|
|
1661
|
+
availability = _action$payload2.availability;
|
|
1848
1662
|
var eventData = _extends({
|
|
1849
1663
|
customer: customer,
|
|
1850
1664
|
availability: availability
|
|
1851
1665
|
}, greeting && {
|
|
1852
1666
|
greeting: greeting
|
|
1853
1667
|
});
|
|
1854
|
-
|
|
1855
1668
|
Object.defineProperty(eventData, '__unsafeDynamicConfig', {
|
|
1856
1669
|
value: dynamicConfig
|
|
1857
1670
|
});
|
|
@@ -1861,45 +1674,37 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
1861
1674
|
emit('connected', eventData);
|
|
1862
1675
|
return;
|
|
1863
1676
|
}
|
|
1864
|
-
|
|
1865
1677
|
case PAUSE_CONNECTION:
|
|
1866
1678
|
{
|
|
1867
1679
|
var _payload = action.payload;
|
|
1868
1680
|
socket.disconnect();
|
|
1869
|
-
|
|
1870
1681
|
if (_payload.reason !== 'manual') {
|
|
1871
1682
|
emit('disconnected', _payload);
|
|
1872
1683
|
}
|
|
1873
|
-
|
|
1874
1684
|
return;
|
|
1875
1685
|
}
|
|
1876
|
-
|
|
1877
1686
|
case PREFETCH_TOKEN:
|
|
1878
1687
|
if (action.payload.fresh) {
|
|
1879
1688
|
auth.getFreshToken()["catch"](dataUtils.noop);
|
|
1880
1689
|
return;
|
|
1881
1690
|
}
|
|
1882
|
-
|
|
1883
1691
|
auth.hasToken().then(function (hasToken) {
|
|
1884
1692
|
if (!hasToken) {
|
|
1885
1693
|
return auth.getToken();
|
|
1886
1694
|
}
|
|
1887
|
-
|
|
1888
1695
|
return auth.getToken().then(function (_ref10) {
|
|
1889
1696
|
var creationDate = _ref10.creationDate,
|
|
1890
|
-
|
|
1891
|
-
var ONE_HOUR = 60 * 60 * 1000;
|
|
1697
|
+
expiresIn = _ref10.expiresIn;
|
|
1698
|
+
var ONE_HOUR = 60 * 60 * 1000;
|
|
1699
|
+
// check if the token is worth reusing
|
|
1892
1700
|
// we don't want to get disconnected in a moment because of expired token
|
|
1893
|
-
|
|
1894
1701
|
if (creationDate + expiresIn - Date.now() > ONE_HOUR) {
|
|
1895
1702
|
return;
|
|
1896
1703
|
}
|
|
1897
|
-
|
|
1898
1704
|
return auth.invalidate().then(auth.getFreshToken);
|
|
1899
1705
|
});
|
|
1900
1706
|
})["catch"](dataUtils.noop);
|
|
1901
1707
|
return;
|
|
1902
|
-
|
|
1903
1708
|
case PUSH_RECEIVED:
|
|
1904
1709
|
// TODO: this if doesn't seem to make much sense
|
|
1905
1710
|
// I'm too afraid to remove it right now though
|
|
@@ -1910,46 +1715,39 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
1910
1715
|
}, action);
|
|
1911
1716
|
return;
|
|
1912
1717
|
}
|
|
1913
|
-
|
|
1914
1718
|
updateStateIfNeeded(store, action);
|
|
1915
1719
|
handlePush({
|
|
1916
1720
|
emit: emit,
|
|
1917
1721
|
store: store
|
|
1918
1722
|
}, action);
|
|
1919
1723
|
return;
|
|
1920
|
-
|
|
1921
1724
|
case PUSH_RESPONSE_RECEIVED:
|
|
1922
1725
|
updateStateIfNeeded(store, action);
|
|
1923
1726
|
handleResponse({
|
|
1924
1727
|
emit: emit
|
|
1925
1728
|
}, action);
|
|
1926
1729
|
return;
|
|
1927
|
-
|
|
1928
1730
|
case RECONNECT:
|
|
1929
1731
|
failAllRequests(store, CONNECTION_LOST);
|
|
1930
1732
|
socket.reconnect(action.payload.delay);
|
|
1931
1733
|
return;
|
|
1932
|
-
|
|
1933
1734
|
case REQUEST_FAILED:
|
|
1934
1735
|
{
|
|
1935
1736
|
var _action$payload3 = action.payload,
|
|
1936
|
-
|
|
1937
|
-
|
|
1737
|
+
reject = _action$payload3.reject,
|
|
1738
|
+
_error = _action$payload3.error;
|
|
1938
1739
|
reject(createError(_error));
|
|
1939
1740
|
return;
|
|
1940
1741
|
}
|
|
1941
|
-
|
|
1942
1742
|
case RESPONSE_RECEIVED:
|
|
1943
1743
|
updateStateIfNeeded(store, action);
|
|
1944
1744
|
handleResponse({
|
|
1945
1745
|
emit: emit
|
|
1946
1746
|
}, action);
|
|
1947
1747
|
return;
|
|
1948
|
-
|
|
1949
1748
|
case SEND_REQUEST:
|
|
1950
1749
|
{
|
|
1951
1750
|
var state = store.getState();
|
|
1952
|
-
|
|
1953
1751
|
if (isDestroyed(state)) {
|
|
1954
1752
|
failRequest(store, action, {
|
|
1955
1753
|
code: SDK_DESTROYED,
|
|
@@ -1957,7 +1755,6 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
1957
1755
|
});
|
|
1958
1756
|
return;
|
|
1959
1757
|
}
|
|
1960
|
-
|
|
1961
1758
|
if (!isConnected(state) && action.payload.source !== 'login') {
|
|
1962
1759
|
failRequest(store, action, {
|
|
1963
1760
|
code: NO_CONNECTION,
|
|
@@ -1965,56 +1762,44 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
1965
1762
|
});
|
|
1966
1763
|
return;
|
|
1967
1764
|
}
|
|
1968
|
-
|
|
1969
1765
|
sendRequest$1(socket, action);
|
|
1970
1766
|
}
|
|
1971
1767
|
return;
|
|
1972
|
-
|
|
1973
1768
|
case SET_SELF_ID:
|
|
1974
1769
|
emit('customer_id', action.payload.id);
|
|
1975
1770
|
return;
|
|
1976
|
-
|
|
1977
1771
|
case SOCKET_DISCONNECTED:
|
|
1978
1772
|
emit('disconnected', {
|
|
1979
1773
|
reason: 'connection_lost'
|
|
1980
1774
|
});
|
|
1981
1775
|
return;
|
|
1982
|
-
|
|
1983
1776
|
case SOCKET_CONNECTED:
|
|
1984
1777
|
loginTask.sendLogin(store);
|
|
1985
1778
|
return;
|
|
1986
|
-
|
|
1987
1779
|
case SOCKET_RECOVERED:
|
|
1988
1780
|
// don't emit if from consumer's perspective we haven't been connected
|
|
1989
1781
|
if (!isConnected(store.getState())) {
|
|
1990
1782
|
return;
|
|
1991
1783
|
}
|
|
1992
|
-
|
|
1993
1784
|
emit('connection_recovered');
|
|
1994
1785
|
return;
|
|
1995
|
-
|
|
1996
1786
|
case SOCKET_UNSTABLE:
|
|
1997
1787
|
// don't emit if from consumer's perspective we haven't been connected
|
|
1998
1788
|
if (!isConnected(store.getState())) {
|
|
1999
1789
|
return;
|
|
2000
1790
|
}
|
|
2001
|
-
|
|
2002
1791
|
emit('connection_unstable');
|
|
2003
1792
|
return;
|
|
2004
|
-
|
|
2005
1793
|
case START_CONNECTION:
|
|
2006
1794
|
socket.connect();
|
|
2007
1795
|
store.dispatch(prefetchToken());
|
|
2008
1796
|
return;
|
|
2009
|
-
|
|
2010
1797
|
case UPDATE_CUSTOMER_PAGE:
|
|
2011
1798
|
if (!isConnected(store.getState())) {
|
|
2012
1799
|
return;
|
|
2013
1800
|
}
|
|
2014
|
-
|
|
2015
1801
|
sendRequestAction(store, sendRequest(UPDATE_CUSTOMER_PAGE$1, action.payload))["catch"](dataUtils.noop);
|
|
2016
1802
|
return;
|
|
2017
|
-
|
|
2018
1803
|
default:
|
|
2019
1804
|
return;
|
|
2020
1805
|
}
|
|
@@ -2022,7 +1807,6 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
2022
1807
|
});
|
|
2023
1808
|
|
|
2024
1809
|
var HISTORY_EVENT_COUNT_TARGET = 25;
|
|
2025
|
-
|
|
2026
1810
|
var createState = function createState() {
|
|
2027
1811
|
return {
|
|
2028
1812
|
status: 'idle',
|
|
@@ -2030,10 +1814,8 @@ var createState = function createState() {
|
|
|
2030
1814
|
nextPageId: null
|
|
2031
1815
|
};
|
|
2032
1816
|
};
|
|
2033
|
-
|
|
2034
1817
|
var createChatHistoryIterator = function createChatHistoryIterator(sdk, chatId) {
|
|
2035
1818
|
var historyState = createState();
|
|
2036
|
-
|
|
2037
1819
|
var next = function next(resolve, reject) {
|
|
2038
1820
|
switch (historyState.status) {
|
|
2039
1821
|
case 'idle':
|
|
@@ -2046,9 +1828,8 @@ var createChatHistoryIterator = function createChatHistoryIterator(sdk, chatId)
|
|
|
2046
1828
|
minEventsCount: HISTORY_EVENT_COUNT_TARGET
|
|
2047
1829
|
}).then(function (_ref) {
|
|
2048
1830
|
var threads = _ref.threads,
|
|
2049
|
-
|
|
1831
|
+
nextPageId = _ref.nextPageId;
|
|
2050
1832
|
historyState.nextPageId = nextPageId;
|
|
2051
|
-
|
|
2052
1833
|
if (!historyState.nextPageId) {
|
|
2053
1834
|
historyState.status = 'done';
|
|
2054
1835
|
resolve({
|
|
@@ -2066,13 +1847,10 @@ var createChatHistoryIterator = function createChatHistoryIterator(sdk, chatId)
|
|
|
2066
1847
|
done: false
|
|
2067
1848
|
});
|
|
2068
1849
|
}
|
|
2069
|
-
|
|
2070
1850
|
var queuedTask = historyState.queuedTasks.shift();
|
|
2071
|
-
|
|
2072
1851
|
if (!queuedTask) {
|
|
2073
1852
|
return;
|
|
2074
1853
|
}
|
|
2075
|
-
|
|
2076
1854
|
next(queuedTask.resolve, queuedTask.reject);
|
|
2077
1855
|
}, function (err) {
|
|
2078
1856
|
var queuedTasks = historyState.queuedTasks;
|
|
@@ -2084,14 +1862,12 @@ var createChatHistoryIterator = function createChatHistoryIterator(sdk, chatId)
|
|
|
2084
1862
|
});
|
|
2085
1863
|
});
|
|
2086
1864
|
return;
|
|
2087
|
-
|
|
2088
1865
|
case 'fetching':
|
|
2089
1866
|
historyState.queuedTasks.push({
|
|
2090
1867
|
resolve: resolve,
|
|
2091
1868
|
reject: reject
|
|
2092
1869
|
});
|
|
2093
1870
|
return;
|
|
2094
|
-
|
|
2095
1871
|
case 'done':
|
|
2096
1872
|
resolve({
|
|
2097
1873
|
value: undefined,
|
|
@@ -2100,17 +1876,14 @@ var createChatHistoryIterator = function createChatHistoryIterator(sdk, chatId)
|
|
|
2100
1876
|
return;
|
|
2101
1877
|
}
|
|
2102
1878
|
};
|
|
2103
|
-
|
|
2104
1879
|
return {
|
|
2105
1880
|
next: function (_next) {
|
|
2106
1881
|
function next() {
|
|
2107
1882
|
return _next.apply(this, arguments);
|
|
2108
1883
|
}
|
|
2109
|
-
|
|
2110
1884
|
next.toString = function () {
|
|
2111
1885
|
return _next.toString();
|
|
2112
1886
|
};
|
|
2113
|
-
|
|
2114
1887
|
return next;
|
|
2115
1888
|
}(function () {
|
|
2116
1889
|
return new Promise(next);
|
|
@@ -2123,22 +1896,19 @@ var initialize = function initialize(store, emitter) {
|
|
|
2123
1896
|
var url = (getServerUrl(state) + "/rtm/ws").replace(/^https/, 'wss');
|
|
2124
1897
|
return createPlatformClient__default['default'](url, {
|
|
2125
1898
|
query: {
|
|
2126
|
-
|
|
1899
|
+
organization_id: state.organizationId
|
|
2127
1900
|
},
|
|
2128
1901
|
emitter: emitter
|
|
2129
1902
|
});
|
|
2130
1903
|
};
|
|
2131
|
-
|
|
2132
1904
|
var createSocketClient = function createSocketClient(store) {
|
|
2133
1905
|
var emitter = mitt__default['default']();
|
|
2134
1906
|
var client = initialize(store, emitter);
|
|
2135
1907
|
return _extends({}, Object.keys(client).reduce(function (proxy, method) {
|
|
2136
1908
|
proxy[method] = function () {
|
|
2137
1909
|
var _client;
|
|
2138
|
-
|
|
2139
1910
|
return (_client = client)[method].apply(_client, arguments);
|
|
2140
1911
|
};
|
|
2141
|
-
|
|
2142
1912
|
return proxy;
|
|
2143
1913
|
}, {}), {
|
|
2144
1914
|
reinitialize: function reinitialize() {
|
|
@@ -2155,14 +1925,12 @@ var parseChatPropertiesDeletedPush = function parseChatPropertiesDeletedPush(pay
|
|
|
2155
1925
|
properties: payload.properties
|
|
2156
1926
|
};
|
|
2157
1927
|
};
|
|
2158
|
-
|
|
2159
1928
|
var parseChatPropertiesUpdatedPush = function parseChatPropertiesUpdatedPush(payload) {
|
|
2160
1929
|
return {
|
|
2161
1930
|
chatId: payload.chat_id,
|
|
2162
1931
|
properties: payload.properties
|
|
2163
1932
|
};
|
|
2164
1933
|
};
|
|
2165
|
-
|
|
2166
1934
|
var parseChatTransferredPush = function parseChatTransferredPush(payload) {
|
|
2167
1935
|
var basePayload = {
|
|
2168
1936
|
chatId: payload.chat_id,
|
|
@@ -2174,19 +1942,16 @@ var parseChatTransferredPush = function parseChatTransferredPush(payload) {
|
|
|
2174
1942
|
}),
|
|
2175
1943
|
queue: payload.queue ? parseQueue(payload.queue) : null
|
|
2176
1944
|
};
|
|
2177
|
-
|
|
2178
1945
|
if (payload.reason === 'manual') {
|
|
2179
1946
|
return _extends({}, basePayload, {
|
|
2180
1947
|
reason: payload.reason,
|
|
2181
1948
|
requesterId: payload.requester_id
|
|
2182
1949
|
});
|
|
2183
1950
|
}
|
|
2184
|
-
|
|
2185
1951
|
return _extends({}, basePayload, {
|
|
2186
1952
|
reason: payload.reason
|
|
2187
1953
|
});
|
|
2188
1954
|
};
|
|
2189
|
-
|
|
2190
1955
|
var parseCustomerPageUpdatedPush = function parseCustomerPageUpdatedPush(payload) {
|
|
2191
1956
|
return {
|
|
2192
1957
|
url: payload.url,
|
|
@@ -2194,13 +1959,11 @@ var parseCustomerPageUpdatedPush = function parseCustomerPageUpdatedPush(payload
|
|
|
2194
1959
|
openedAt: payload.opened_at
|
|
2195
1960
|
};
|
|
2196
1961
|
};
|
|
2197
|
-
|
|
2198
1962
|
var parseCustomerUpdatedPush = function parseCustomerUpdatedPush(payload) {
|
|
2199
1963
|
return _extends({
|
|
2200
1964
|
id: payload.id
|
|
2201
1965
|
}, parseCustomerOptionalProps(payload));
|
|
2202
1966
|
};
|
|
2203
|
-
|
|
2204
1967
|
var parseEventPropertiesDeletedPush = function parseEventPropertiesDeletedPush(payload) {
|
|
2205
1968
|
return {
|
|
2206
1969
|
chatId: payload.chat_id,
|
|
@@ -2209,7 +1972,6 @@ var parseEventPropertiesDeletedPush = function parseEventPropertiesDeletedPush(p
|
|
|
2209
1972
|
properties: payload.properties
|
|
2210
1973
|
};
|
|
2211
1974
|
};
|
|
2212
|
-
|
|
2213
1975
|
var parseEventPropertiesUpdatedPush = function parseEventPropertiesUpdatedPush(payload) {
|
|
2214
1976
|
return {
|
|
2215
1977
|
chatId: payload.chat_id,
|
|
@@ -2218,7 +1980,6 @@ var parseEventPropertiesUpdatedPush = function parseEventPropertiesUpdatedPush(p
|
|
|
2218
1980
|
properties: payload.properties
|
|
2219
1981
|
};
|
|
2220
1982
|
};
|
|
2221
|
-
|
|
2222
1983
|
var parseEventUpdatedPush = function parseEventUpdatedPush(payload) {
|
|
2223
1984
|
var threadId = payload.thread_id;
|
|
2224
1985
|
return {
|
|
@@ -2227,7 +1988,6 @@ var parseEventUpdatedPush = function parseEventUpdatedPush(payload) {
|
|
|
2227
1988
|
event: parseEvent$1(threadId, payload.event)
|
|
2228
1989
|
};
|
|
2229
1990
|
};
|
|
2230
|
-
|
|
2231
1991
|
var parseEventsMarkedAsSeenPush = function parseEventsMarkedAsSeenPush(payload) {
|
|
2232
1992
|
return {
|
|
2233
1993
|
chatId: payload.chat_id,
|
|
@@ -2235,19 +1995,16 @@ var parseEventsMarkedAsSeenPush = function parseEventsMarkedAsSeenPush(payload)
|
|
|
2235
1995
|
seenUpTo: payload.seen_up_to
|
|
2236
1996
|
};
|
|
2237
1997
|
};
|
|
2238
|
-
|
|
2239
1998
|
var parseGreetingAcceptedPush = function parseGreetingAcceptedPush(payload) {
|
|
2240
1999
|
return {
|
|
2241
2000
|
uniqueId: payload.unique_id
|
|
2242
2001
|
};
|
|
2243
2002
|
};
|
|
2244
|
-
|
|
2245
2003
|
var parseGetChatResponse = function parseGetChatResponse(payload) {
|
|
2246
2004
|
return _extends({}, parseChatCommon(payload), {
|
|
2247
2005
|
thread: payload.thread ? parseThread(payload.id, payload.thread) : null
|
|
2248
2006
|
});
|
|
2249
2007
|
};
|
|
2250
|
-
|
|
2251
2008
|
var parseIncomingChatPush = function parseIncomingChatPush(payload) {
|
|
2252
2009
|
var chat = payload.chat;
|
|
2253
2010
|
return {
|
|
@@ -2256,18 +2013,15 @@ var parseIncomingChatPush = function parseIncomingChatPush(payload) {
|
|
|
2256
2013
|
})
|
|
2257
2014
|
};
|
|
2258
2015
|
};
|
|
2259
|
-
|
|
2260
2016
|
var parseIncomingEventPush = function parseIncomingEventPush(payload) {
|
|
2261
2017
|
return {
|
|
2262
2018
|
chatId: payload.chat_id,
|
|
2263
2019
|
event: parseEvent$1(payload.thread_id, payload.event)
|
|
2264
2020
|
};
|
|
2265
2021
|
};
|
|
2266
|
-
|
|
2267
2022
|
var parseIncomingGreetingPush = function parseIncomingGreetingPush(payload) {
|
|
2268
2023
|
return parseGreeting(payload);
|
|
2269
2024
|
};
|
|
2270
|
-
|
|
2271
2025
|
var parseIncomingRichMessagePostbackPush = function parseIncomingRichMessagePostbackPush(payload) {
|
|
2272
2026
|
return {
|
|
2273
2027
|
userId: payload.user_id,
|
|
@@ -2277,10 +2031,9 @@ var parseIncomingRichMessagePostbackPush = function parseIncomingRichMessagePost
|
|
|
2277
2031
|
postback: payload.postback
|
|
2278
2032
|
};
|
|
2279
2033
|
};
|
|
2280
|
-
|
|
2281
2034
|
var parseIncomingTypingIndicatorPush = function parseIncomingTypingIndicatorPush(payload) {
|
|
2282
2035
|
var chatId = payload.chat_id,
|
|
2283
|
-
|
|
2036
|
+
typingIndicator = payload.typing_indicator;
|
|
2284
2037
|
return {
|
|
2285
2038
|
chatId: chatId,
|
|
2286
2039
|
typingIndicator: {
|
|
@@ -2289,7 +2042,6 @@ var parseIncomingTypingIndicatorPush = function parseIncomingTypingIndicatorPush
|
|
|
2289
2042
|
}
|
|
2290
2043
|
};
|
|
2291
2044
|
};
|
|
2292
|
-
|
|
2293
2045
|
var parseQueuePositionUpdatedPush = function parseQueuePositionUpdatedPush(payload) {
|
|
2294
2046
|
return {
|
|
2295
2047
|
chatId: payload.chat_id,
|
|
@@ -2297,7 +2049,6 @@ var parseQueuePositionUpdatedPush = function parseQueuePositionUpdatedPush(paylo
|
|
|
2297
2049
|
queue: parseQueueUpdate(payload.queue)
|
|
2298
2050
|
};
|
|
2299
2051
|
};
|
|
2300
|
-
|
|
2301
2052
|
var parseThreadPropertiesDeletedPush = function parseThreadPropertiesDeletedPush(payload) {
|
|
2302
2053
|
return {
|
|
2303
2054
|
chatId: payload.chat_id,
|
|
@@ -2305,7 +2056,6 @@ var parseThreadPropertiesDeletedPush = function parseThreadPropertiesDeletedPush
|
|
|
2305
2056
|
properties: payload.properties
|
|
2306
2057
|
};
|
|
2307
2058
|
};
|
|
2308
|
-
|
|
2309
2059
|
var parseThreadPropertiesUpdatedPush = function parseThreadPropertiesUpdatedPush(payload) {
|
|
2310
2060
|
return {
|
|
2311
2061
|
chatId: payload.chat_id,
|
|
@@ -2313,7 +2063,6 @@ var parseThreadPropertiesUpdatedPush = function parseThreadPropertiesUpdatedPush
|
|
|
2313
2063
|
properties: payload.properties
|
|
2314
2064
|
};
|
|
2315
2065
|
};
|
|
2316
|
-
|
|
2317
2066
|
var parseUserAddedToChatPush = function parseUserAddedToChatPush(payload) {
|
|
2318
2067
|
return {
|
|
2319
2068
|
chatId: payload.chat_id,
|
|
@@ -2321,14 +2070,12 @@ var parseUserAddedToChatPush = function parseUserAddedToChatPush(payload) {
|
|
|
2321
2070
|
present: payload.user.present
|
|
2322
2071
|
};
|
|
2323
2072
|
};
|
|
2324
|
-
|
|
2325
2073
|
var parseUserRemovedFromChatPush = function parseUserRemovedFromChatPush(payload) {
|
|
2326
2074
|
return {
|
|
2327
2075
|
chatId: payload.chat_id,
|
|
2328
2076
|
userId: payload.user_id
|
|
2329
2077
|
};
|
|
2330
2078
|
};
|
|
2331
|
-
|
|
2332
2079
|
var parseFields = function parseFields(fields) {
|
|
2333
2080
|
return fields.map(function (field) {
|
|
2334
2081
|
switch (field.type) {
|
|
@@ -2336,30 +2083,25 @@ var parseFields = function parseFields(fields) {
|
|
|
2336
2083
|
return _extends({}, field, {
|
|
2337
2084
|
options: field.options.map(function (_ref) {
|
|
2338
2085
|
var groupId = _ref.group_id,
|
|
2339
|
-
|
|
2340
|
-
|
|
2086
|
+
option = _objectWithoutPropertiesLoose(_ref, ["group_id"]);
|
|
2341
2087
|
return _extends({}, option, {
|
|
2342
2088
|
groupId: groupId
|
|
2343
2089
|
});
|
|
2344
2090
|
})
|
|
2345
2091
|
});
|
|
2346
|
-
|
|
2347
2092
|
case 'rating':
|
|
2348
2093
|
{
|
|
2349
2094
|
var commentLabel = field.comment_label,
|
|
2350
|
-
|
|
2351
|
-
|
|
2095
|
+
parsed = _objectWithoutPropertiesLoose(field, ["comment_label"]);
|
|
2352
2096
|
return _extends({}, parsed, {
|
|
2353
2097
|
commentLabel: commentLabel
|
|
2354
2098
|
});
|
|
2355
2099
|
}
|
|
2356
|
-
|
|
2357
2100
|
default:
|
|
2358
2101
|
return field;
|
|
2359
2102
|
}
|
|
2360
2103
|
});
|
|
2361
2104
|
};
|
|
2362
|
-
|
|
2363
2105
|
var parseTicketFormFields = function parseTicketFormFields(fields) {
|
|
2364
2106
|
var withFakeIds = fields.map(function (field, index) {
|
|
2365
2107
|
return _extends({}, field, {
|
|
@@ -2368,7 +2110,6 @@ var parseTicketFormFields = function parseTicketFormFields(fields) {
|
|
|
2368
2110
|
});
|
|
2369
2111
|
return parseFields(withFakeIds);
|
|
2370
2112
|
};
|
|
2371
|
-
|
|
2372
2113
|
var parseForm$1 = function parseForm(form) {
|
|
2373
2114
|
var isTicketForm = !('id' in form.fields[0]);
|
|
2374
2115
|
return {
|
|
@@ -2376,66 +2117,54 @@ var parseForm$1 = function parseForm(form) {
|
|
|
2376
2117
|
fields: isTicketForm ? parseTicketFormFields(form.fields) : parseFields(form.fields)
|
|
2377
2118
|
};
|
|
2378
2119
|
};
|
|
2379
|
-
|
|
2380
2120
|
var parseGetFormResponse = function parseGetFormResponse(payload) {
|
|
2381
2121
|
if (!payload.enabled) {
|
|
2382
2122
|
return payload;
|
|
2383
2123
|
}
|
|
2384
|
-
|
|
2385
2124
|
return _extends({}, payload, {
|
|
2386
2125
|
form: parseForm$1(payload.form)
|
|
2387
2126
|
});
|
|
2388
2127
|
};
|
|
2389
|
-
|
|
2390
2128
|
var parseGetUrlInfoResponse = function parseGetUrlInfoResponse(payload) {
|
|
2391
2129
|
var urlInfo = {
|
|
2392
2130
|
url: payload.url
|
|
2393
2131
|
};
|
|
2394
|
-
|
|
2395
2132
|
if (payload.title) {
|
|
2396
2133
|
urlInfo.title = payload.title;
|
|
2397
2134
|
}
|
|
2398
|
-
|
|
2399
2135
|
if (payload.description) {
|
|
2400
2136
|
urlInfo.description = payload.description;
|
|
2401
2137
|
}
|
|
2402
|
-
|
|
2403
2138
|
if (payload.image_url) {
|
|
2404
|
-
urlInfo.imageUrl = "https://" + payload.image_url;
|
|
2405
|
-
|
|
2139
|
+
urlInfo.imageUrl = "https://" + urlUtils.removeProtocol(payload.image_url);
|
|
2406
2140
|
if (payload.image_width && payload.image_height) {
|
|
2407
2141
|
urlInfo.imageWidth = payload.image_width;
|
|
2408
2142
|
urlInfo.imageHeight = payload.image_height;
|
|
2409
2143
|
}
|
|
2410
2144
|
}
|
|
2411
|
-
|
|
2412
2145
|
return urlInfo;
|
|
2413
2146
|
};
|
|
2414
|
-
|
|
2415
2147
|
var getAvailabilityBasedOnDynamicConfig = function getAvailabilityBasedOnDynamicConfig(_ref2) {
|
|
2416
2148
|
var onlineGroups = _ref2.online_groups_ids,
|
|
2417
|
-
|
|
2418
|
-
|
|
2149
|
+
customerGroups = _ref2.customer_groups;
|
|
2419
2150
|
// this might be missing if all groups are offline
|
|
2420
2151
|
if (!onlineGroups) {
|
|
2421
2152
|
return 'offline';
|
|
2422
2153
|
}
|
|
2423
|
-
|
|
2424
2154
|
var monitoringGroupId = customerGroups.monitoring.id;
|
|
2425
2155
|
return dataUtils.includes(monitoringGroupId, onlineGroups) ? 'online' : 'offline';
|
|
2426
2156
|
};
|
|
2427
|
-
|
|
2428
2157
|
var parseListChatsResponse = function parseListChatsResponse(payload) {
|
|
2429
2158
|
var chatsSummary = payload.chats_summary.map(function (_ref3) {
|
|
2430
2159
|
var id = _ref3.id,
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2160
|
+
active = _ref3.active,
|
|
2161
|
+
access = _ref3.access,
|
|
2162
|
+
lastThreadCreatedAt = _ref3.last_thread_created_at,
|
|
2163
|
+
lastThreadId = _ref3.last_thread_id,
|
|
2164
|
+
lastEventsPerType = _ref3.last_event_per_type,
|
|
2165
|
+
_ref3$properties = _ref3.properties,
|
|
2166
|
+
properties = _ref3$properties === void 0 ? {} : _ref3$properties,
|
|
2167
|
+
users = _ref3.users;
|
|
2439
2168
|
var chatSummary = {
|
|
2440
2169
|
id: id,
|
|
2441
2170
|
active: active,
|
|
@@ -2446,11 +2175,9 @@ var parseListChatsResponse = function parseListChatsResponse(payload) {
|
|
|
2446
2175
|
lastThreadCreatedAt: lastThreadCreatedAt || null,
|
|
2447
2176
|
eventsSeenUpToMap: getEventsSeenUpToMap(users)
|
|
2448
2177
|
};
|
|
2449
|
-
|
|
2450
2178
|
if (!lastEventsPerType) {
|
|
2451
2179
|
return chatSummary;
|
|
2452
2180
|
}
|
|
2453
|
-
|
|
2454
2181
|
chatSummary.lastEventsPerType = dataUtils.mapValues(function (lastEventPerType) {
|
|
2455
2182
|
return parseEvent$1(lastEventPerType.thread_id, lastEventPerType.event);
|
|
2456
2183
|
}, lastEventsPerType);
|
|
@@ -2461,18 +2188,17 @@ var parseListChatsResponse = function parseListChatsResponse(payload) {
|
|
|
2461
2188
|
var lastEventSummary = dataUtils.last(lastEventSummariesArray.sort(function (eventSummaryA, eventSummaryB) {
|
|
2462
2189
|
return eventSummaryA.thread_id === eventSummaryB.thread_id ? dataUtils.stringCompare(eventSummaryA.event.created_at, eventSummaryB.event.created_at) : dataUtils.stringCompare(eventSummaryA.thread_created_at, eventSummaryB.thread_created_at);
|
|
2463
2190
|
}));
|
|
2464
|
-
|
|
2465
|
-
if (lastEventSummary) {
|
|
2191
|
+
if (lastEventSummary && chatSummary.lastEventsPerType) {
|
|
2466
2192
|
chatSummary.lastEvent = chatSummary.lastEventsPerType[lastEventSummary.event.type];
|
|
2467
2193
|
}
|
|
2468
|
-
|
|
2469
2194
|
return chatSummary;
|
|
2470
2195
|
});
|
|
2471
2196
|
return {
|
|
2472
2197
|
chatsSummary: dataUtils.numericSortBy(function (_ref4) {
|
|
2198
|
+
var _ref5;
|
|
2473
2199
|
var lastEvent = _ref4.lastEvent,
|
|
2474
|
-
|
|
2475
|
-
return -1 * (lastEvent !== undefined ? lastEvent.timestamp : order);
|
|
2200
|
+
order = _ref4.order;
|
|
2201
|
+
return -1 * ((_ref5 = lastEvent !== undefined ? lastEvent.timestamp : order) != null ? _ref5 : 0);
|
|
2476
2202
|
}, chatsSummary),
|
|
2477
2203
|
totalChats: payload.total_chats,
|
|
2478
2204
|
users: dataUtils.uniqBy(function (user) {
|
|
@@ -2484,11 +2210,9 @@ var parseListChatsResponse = function parseListChatsResponse(payload) {
|
|
|
2484
2210
|
nextPageId: payload.next_page_id || null
|
|
2485
2211
|
};
|
|
2486
2212
|
};
|
|
2487
|
-
|
|
2488
2213
|
var parseListGroupStatusesResponse = function parseListGroupStatusesResponse(payload) {
|
|
2489
2214
|
return payload.groups_status;
|
|
2490
2215
|
};
|
|
2491
|
-
|
|
2492
2216
|
var parseListThreadsResponse = function parseListThreadsResponse(request, payload) {
|
|
2493
2217
|
return {
|
|
2494
2218
|
threads: payload.threads.map(function (thread) {
|
|
@@ -2498,11 +2222,10 @@ var parseListThreadsResponse = function parseListThreadsResponse(request, payloa
|
|
|
2498
2222
|
nextPageId: payload.next_page_id || null
|
|
2499
2223
|
};
|
|
2500
2224
|
};
|
|
2501
|
-
|
|
2502
2225
|
var parseLoginResponse = function parseLoginResponse(payload) {
|
|
2503
2226
|
var dynamicConfig = payload.__priv_dynamic_config,
|
|
2504
|
-
|
|
2505
|
-
|
|
2227
|
+
chats = payload.chats,
|
|
2228
|
+
greeting = payload.greeting;
|
|
2506
2229
|
return _extends({
|
|
2507
2230
|
dynamicConfig: dynamicConfig,
|
|
2508
2231
|
customer: parseCustomer(payload.customer),
|
|
@@ -2510,7 +2233,8 @@ var parseLoginResponse = function parseLoginResponse(payload) {
|
|
|
2510
2233
|
chats: chats.map(function (chat) {
|
|
2511
2234
|
return {
|
|
2512
2235
|
id: chat.chat_id,
|
|
2513
|
-
active: 'has_active_thread' in chat ? chat.has_active_thread :
|
|
2236
|
+
active: 'has_active_thread' in chat ? chat.has_active_thread :
|
|
2237
|
+
// temporary fallback, waiting for API to move this flag into `chats` array
|
|
2514
2238
|
payload.has_active_thread,
|
|
2515
2239
|
hasUnreadEvents: chat.has_unread_events
|
|
2516
2240
|
};
|
|
@@ -2519,7 +2243,6 @@ var parseLoginResponse = function parseLoginResponse(payload) {
|
|
|
2519
2243
|
greeting: parseGreeting(greeting)
|
|
2520
2244
|
});
|
|
2521
2245
|
};
|
|
2522
|
-
|
|
2523
2246
|
var parsePush = function parsePush(push) {
|
|
2524
2247
|
switch (push.action) {
|
|
2525
2248
|
case CHAT_DEACTIVATED:
|
|
@@ -2529,146 +2252,122 @@ var parsePush = function parsePush(push) {
|
|
|
2529
2252
|
chatId: push.payload.chat_id
|
|
2530
2253
|
}
|
|
2531
2254
|
};
|
|
2532
|
-
|
|
2533
2255
|
case CHAT_PROPERTIES_DELETED:
|
|
2534
2256
|
return {
|
|
2535
2257
|
action: push.action,
|
|
2536
2258
|
payload: parseChatPropertiesDeletedPush(push.payload)
|
|
2537
2259
|
};
|
|
2538
|
-
|
|
2539
2260
|
case CHAT_PROPERTIES_UPDATED:
|
|
2540
2261
|
return {
|
|
2541
2262
|
action: push.action,
|
|
2542
2263
|
payload: parseChatPropertiesUpdatedPush(push.payload)
|
|
2543
2264
|
};
|
|
2544
|
-
|
|
2545
2265
|
case CHAT_TRANSFERRED:
|
|
2546
2266
|
return {
|
|
2547
2267
|
action: push.action,
|
|
2548
2268
|
payload: parseChatTransferredPush(push.payload)
|
|
2549
2269
|
};
|
|
2550
|
-
|
|
2551
2270
|
case CUSTOMER_SIDE_STORAGE_UPDATED:
|
|
2552
2271
|
return {
|
|
2553
2272
|
action: push.action,
|
|
2554
2273
|
payload: push.payload
|
|
2555
2274
|
};
|
|
2556
|
-
|
|
2557
2275
|
case CUSTOMER_DISCONNECTED:
|
|
2558
2276
|
return {
|
|
2559
2277
|
action: push.action,
|
|
2560
2278
|
payload: push.payload
|
|
2561
2279
|
};
|
|
2562
|
-
|
|
2563
2280
|
case CUSTOMER_PAGE_UPDATED:
|
|
2564
2281
|
return {
|
|
2565
2282
|
action: push.action,
|
|
2566
2283
|
payload: parseCustomerPageUpdatedPush(push.payload)
|
|
2567
2284
|
};
|
|
2568
|
-
|
|
2569
2285
|
case CUSTOMER_UPDATED:
|
|
2570
2286
|
return {
|
|
2571
2287
|
action: push.action,
|
|
2572
2288
|
payload: parseCustomerUpdatedPush(push.payload)
|
|
2573
2289
|
};
|
|
2574
|
-
|
|
2575
2290
|
case EVENT_PROPERTIES_DELETED:
|
|
2576
2291
|
return {
|
|
2577
2292
|
action: push.action,
|
|
2578
2293
|
payload: parseEventPropertiesDeletedPush(push.payload)
|
|
2579
2294
|
};
|
|
2580
|
-
|
|
2581
2295
|
case EVENT_PROPERTIES_UPDATED:
|
|
2582
2296
|
return {
|
|
2583
2297
|
action: push.action,
|
|
2584
2298
|
payload: parseEventPropertiesUpdatedPush(push.payload)
|
|
2585
2299
|
};
|
|
2586
|
-
|
|
2587
2300
|
case EVENT_UPDATED:
|
|
2588
2301
|
return {
|
|
2589
2302
|
action: push.action,
|
|
2590
2303
|
payload: parseEventUpdatedPush(push.payload)
|
|
2591
2304
|
};
|
|
2592
|
-
|
|
2593
2305
|
case EVENTS_MARKED_AS_SEEN:
|
|
2594
2306
|
return {
|
|
2595
2307
|
action: push.action,
|
|
2596
2308
|
payload: parseEventsMarkedAsSeenPush(push.payload)
|
|
2597
2309
|
};
|
|
2598
|
-
|
|
2599
2310
|
case GREETING_ACCEPTED:
|
|
2600
2311
|
return {
|
|
2601
2312
|
action: push.action,
|
|
2602
2313
|
payload: parseGreetingAcceptedPush(push.payload)
|
|
2603
2314
|
};
|
|
2604
|
-
|
|
2605
2315
|
case GREETING_CANCELED:
|
|
2606
2316
|
return {
|
|
2607
2317
|
action: push.action,
|
|
2608
2318
|
// 'greeting_canceled' has the same payload as `greeting_accepted`
|
|
2609
2319
|
payload: parseGreetingAcceptedPush(push.payload)
|
|
2610
2320
|
};
|
|
2611
|
-
|
|
2612
2321
|
case INCOMING_CHAT:
|
|
2613
2322
|
return {
|
|
2614
2323
|
action: push.action,
|
|
2615
2324
|
payload: parseIncomingChatPush(push.payload)
|
|
2616
2325
|
};
|
|
2617
|
-
|
|
2618
2326
|
case INCOMING_EVENT:
|
|
2619
2327
|
return {
|
|
2620
2328
|
action: push.action,
|
|
2621
2329
|
payload: parseIncomingEventPush(push.payload)
|
|
2622
2330
|
};
|
|
2623
|
-
|
|
2624
2331
|
case INCOMING_GREETING:
|
|
2625
2332
|
return {
|
|
2626
2333
|
action: push.action,
|
|
2627
2334
|
payload: parseIncomingGreetingPush(push.payload)
|
|
2628
2335
|
};
|
|
2629
|
-
|
|
2630
2336
|
case INCOMING_MULTICAST:
|
|
2631
2337
|
return {
|
|
2632
2338
|
action: push.action,
|
|
2633
2339
|
payload: push.payload
|
|
2634
2340
|
};
|
|
2635
|
-
|
|
2636
2341
|
case INCOMING_RICH_MESSAGE_POSTBACK:
|
|
2637
2342
|
return {
|
|
2638
2343
|
action: push.action,
|
|
2639
2344
|
payload: parseIncomingRichMessagePostbackPush(push.payload)
|
|
2640
2345
|
};
|
|
2641
|
-
|
|
2642
2346
|
case INCOMING_TYPING_INDICATOR:
|
|
2643
2347
|
return {
|
|
2644
2348
|
action: push.action,
|
|
2645
2349
|
payload: parseIncomingTypingIndicatorPush(push.payload)
|
|
2646
2350
|
};
|
|
2647
|
-
|
|
2648
2351
|
case QUEUE_POSITION_UPDATED:
|
|
2649
2352
|
return {
|
|
2650
2353
|
action: push.action,
|
|
2651
2354
|
payload: parseQueuePositionUpdatedPush(push.payload)
|
|
2652
2355
|
};
|
|
2653
|
-
|
|
2654
2356
|
case THREAD_PROPERTIES_DELETED:
|
|
2655
2357
|
return {
|
|
2656
2358
|
action: push.action,
|
|
2657
2359
|
payload: parseThreadPropertiesDeletedPush(push.payload)
|
|
2658
2360
|
};
|
|
2659
|
-
|
|
2660
2361
|
case THREAD_PROPERTIES_UPDATED:
|
|
2661
2362
|
return {
|
|
2662
2363
|
action: push.action,
|
|
2663
2364
|
payload: parseThreadPropertiesUpdatedPush(push.payload)
|
|
2664
2365
|
};
|
|
2665
|
-
|
|
2666
2366
|
case USER_ADDED_TO_CHAT:
|
|
2667
2367
|
return {
|
|
2668
2368
|
action: push.action,
|
|
2669
2369
|
payload: parseUserAddedToChatPush(push.payload)
|
|
2670
2370
|
};
|
|
2671
|
-
|
|
2672
2371
|
case USER_REMOVED_FROM_CHAT:
|
|
2673
2372
|
return {
|
|
2674
2373
|
action: push.action,
|
|
@@ -2676,143 +2375,120 @@ var parsePush = function parsePush(push) {
|
|
|
2676
2375
|
};
|
|
2677
2376
|
}
|
|
2678
2377
|
};
|
|
2679
|
-
var parseResponse = function parseResponse(
|
|
2680
|
-
var request =
|
|
2681
|
-
|
|
2682
|
-
|
|
2378
|
+
var parseResponse = function parseResponse(_ref6) {
|
|
2379
|
+
var request = _ref6.request,
|
|
2380
|
+
response = _ref6.response;
|
|
2683
2381
|
switch (response.action) {
|
|
2684
2382
|
case ACCEPT_GREETING:
|
|
2685
2383
|
return {
|
|
2686
2384
|
action: response.action,
|
|
2687
2385
|
payload: SUCCESS
|
|
2688
2386
|
};
|
|
2689
|
-
|
|
2690
2387
|
case CANCEL_GREETING:
|
|
2691
2388
|
return {
|
|
2692
2389
|
action: response.action,
|
|
2693
2390
|
payload: SUCCESS
|
|
2694
2391
|
};
|
|
2695
|
-
|
|
2696
2392
|
case DELETE_CHAT_PROPERTIES:
|
|
2697
2393
|
return {
|
|
2698
2394
|
action: response.action,
|
|
2699
2395
|
payload: SUCCESS
|
|
2700
2396
|
};
|
|
2701
|
-
|
|
2702
2397
|
case DELETE_EVENT_PROPERTIES:
|
|
2703
2398
|
return {
|
|
2704
2399
|
action: response.action,
|
|
2705
2400
|
payload: SUCCESS
|
|
2706
2401
|
};
|
|
2707
|
-
|
|
2708
2402
|
case DELETE_THREAD_PROPERTIES:
|
|
2709
2403
|
return {
|
|
2710
2404
|
action: response.action,
|
|
2711
2405
|
payload: SUCCESS
|
|
2712
2406
|
};
|
|
2713
|
-
|
|
2714
2407
|
case GET_CHAT:
|
|
2715
2408
|
return {
|
|
2716
2409
|
action: response.action,
|
|
2717
2410
|
payload: parseGetChatResponse(response.payload)
|
|
2718
2411
|
};
|
|
2719
|
-
|
|
2720
2412
|
case GET_CUSTOMER:
|
|
2721
2413
|
return {
|
|
2722
2414
|
action: response.action,
|
|
2723
2415
|
payload: parseCustomer(response.payload)
|
|
2724
2416
|
};
|
|
2725
|
-
|
|
2726
2417
|
case GET_FORM:
|
|
2727
2418
|
return {
|
|
2728
2419
|
action: response.action,
|
|
2729
2420
|
payload: parseGetFormResponse(response.payload)
|
|
2730
2421
|
};
|
|
2731
|
-
|
|
2732
2422
|
case GET_PREDICTED_AGENT:
|
|
2733
2423
|
return {
|
|
2734
2424
|
action: response.action,
|
|
2735
2425
|
payload: parsePredictedAgent(response.payload)
|
|
2736
2426
|
};
|
|
2737
|
-
|
|
2738
2427
|
case GET_URL_INFO:
|
|
2739
2428
|
return {
|
|
2740
2429
|
action: response.action,
|
|
2741
2430
|
payload: parseGetUrlInfoResponse(response.payload)
|
|
2742
2431
|
};
|
|
2743
|
-
|
|
2744
2432
|
case LIST_CHATS:
|
|
2745
2433
|
return {
|
|
2746
2434
|
action: response.action,
|
|
2747
2435
|
payload: parseListChatsResponse(response.payload)
|
|
2748
2436
|
};
|
|
2749
|
-
|
|
2750
2437
|
case LIST_GROUP_STATUSES:
|
|
2751
2438
|
return {
|
|
2752
2439
|
action: response.action,
|
|
2753
2440
|
payload: parseListGroupStatusesResponse(response.payload)
|
|
2754
2441
|
};
|
|
2755
|
-
|
|
2756
2442
|
case LIST_THREADS:
|
|
2757
2443
|
return {
|
|
2758
2444
|
action: response.action,
|
|
2759
2445
|
payload: parseListThreadsResponse(request, response.payload)
|
|
2760
2446
|
};
|
|
2761
|
-
|
|
2762
2447
|
case LOGIN:
|
|
2763
2448
|
return {
|
|
2764
2449
|
action: response.action,
|
|
2765
2450
|
payload: parseLoginResponse(response.payload)
|
|
2766
2451
|
};
|
|
2767
|
-
|
|
2768
2452
|
case MARK_EVENTS_AS_SEEN:
|
|
2769
2453
|
return {
|
|
2770
2454
|
action: response.action,
|
|
2771
2455
|
payload: SUCCESS
|
|
2772
2456
|
};
|
|
2773
|
-
|
|
2774
2457
|
case SEND_SNEAK_PEEK:
|
|
2775
2458
|
return {
|
|
2776
2459
|
action: response.action,
|
|
2777
2460
|
payload: SUCCESS
|
|
2778
2461
|
};
|
|
2779
|
-
|
|
2780
2462
|
case SET_CUSTOMER_SESSION_FIELDS:
|
|
2781
2463
|
return {
|
|
2782
2464
|
action: response.action,
|
|
2783
2465
|
payload: SUCCESS
|
|
2784
2466
|
};
|
|
2785
|
-
|
|
2786
2467
|
case SEND_RICH_MESSAGE_POSTBACK:
|
|
2787
2468
|
return {
|
|
2788
2469
|
action: response.action,
|
|
2789
2470
|
payload: SUCCESS
|
|
2790
2471
|
};
|
|
2791
|
-
|
|
2792
2472
|
case UPDATE_CHAT_PROPERTIES:
|
|
2793
2473
|
return {
|
|
2794
2474
|
action: response.action,
|
|
2795
2475
|
payload: SUCCESS
|
|
2796
2476
|
};
|
|
2797
|
-
|
|
2798
2477
|
case UPDATE_CUSTOMER:
|
|
2799
2478
|
return {
|
|
2800
2479
|
action: response.action,
|
|
2801
2480
|
payload: SUCCESS
|
|
2802
2481
|
};
|
|
2803
|
-
|
|
2804
2482
|
case UPDATE_CUSTOMER_PAGE$1:
|
|
2805
2483
|
return {
|
|
2806
2484
|
action: response.action,
|
|
2807
2485
|
payload: SUCCESS
|
|
2808
2486
|
};
|
|
2809
|
-
|
|
2810
2487
|
case UPDATE_EVENT_PROPERTIES:
|
|
2811
2488
|
return {
|
|
2812
2489
|
action: response.action,
|
|
2813
2490
|
payload: SUCCESS
|
|
2814
2491
|
};
|
|
2815
|
-
|
|
2816
2492
|
case UPDATE_THREAD_PROPERTIES:
|
|
2817
2493
|
return {
|
|
2818
2494
|
action: response.action,
|
|
@@ -2829,13 +2505,11 @@ var parseServerError = function parseServerError(error) {
|
|
|
2829
2505
|
|
|
2830
2506
|
var handleResponseError = function handleResponseError(_ref, response) {
|
|
2831
2507
|
var dispatch = _ref.dispatch,
|
|
2832
|
-
|
|
2508
|
+
getState = _ref.getState;
|
|
2833
2509
|
var requestId = response.request_id,
|
|
2834
|
-
|
|
2835
|
-
|
|
2510
|
+
payload = response.payload;
|
|
2836
2511
|
var _getRequest = getRequest(getState(), requestId),
|
|
2837
|
-
|
|
2838
|
-
|
|
2512
|
+
reject = _getRequest.reject;
|
|
2839
2513
|
dispatch({
|
|
2840
2514
|
type: REQUEST_FAILED,
|
|
2841
2515
|
payload: {
|
|
@@ -2845,17 +2519,14 @@ var handleResponseError = function handleResponseError(_ref, response) {
|
|
|
2845
2519
|
}
|
|
2846
2520
|
});
|
|
2847
2521
|
};
|
|
2848
|
-
|
|
2849
2522
|
var handleResponse$1 = function handleResponse(_ref2, response) {
|
|
2850
2523
|
var dispatch = _ref2.dispatch,
|
|
2851
|
-
|
|
2524
|
+
getState = _ref2.getState;
|
|
2852
2525
|
var requestId = response.request_id;
|
|
2853
|
-
|
|
2854
2526
|
var _getRequest2 = getRequest(getState(), requestId),
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2527
|
+
promise = _getRequest2.promise,
|
|
2528
|
+
resolve = _getRequest2.resolve,
|
|
2529
|
+
request = _getRequest2.request;
|
|
2859
2530
|
var parsedResponse = parseResponse({
|
|
2860
2531
|
request: request,
|
|
2861
2532
|
response: response
|
|
@@ -2869,16 +2540,13 @@ var handleResponse$1 = function handleResponse(_ref2, response) {
|
|
|
2869
2540
|
}, parsedResponse)
|
|
2870
2541
|
});
|
|
2871
2542
|
};
|
|
2872
|
-
|
|
2873
2543
|
var handlePushResponse = function handlePushResponse(_ref3, response) {
|
|
2874
2544
|
var dispatch = _ref3.dispatch,
|
|
2875
|
-
|
|
2545
|
+
getState = _ref3.getState;
|
|
2876
2546
|
var requestId = response.request_id;
|
|
2877
|
-
|
|
2878
2547
|
var _getRequest3 = getRequest(getState(), requestId),
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2548
|
+
promise = _getRequest3.promise,
|
|
2549
|
+
resolve = _getRequest3.resolve;
|
|
2882
2550
|
var parsedPush = parsePush(response);
|
|
2883
2551
|
dispatch({
|
|
2884
2552
|
type: PUSH_RESPONSE_RECEIVED,
|
|
@@ -2889,21 +2557,17 @@ var handlePushResponse = function handlePushResponse(_ref3, response) {
|
|
|
2889
2557
|
}, parsedPush)
|
|
2890
2558
|
});
|
|
2891
2559
|
};
|
|
2892
|
-
|
|
2893
2560
|
var handlePush$1 = function handlePush(store, push) {
|
|
2894
2561
|
var parsedPush = parsePush(push);
|
|
2895
|
-
|
|
2896
2562
|
if (!parsedPush) {
|
|
2897
2563
|
// defensive measure against receiving unknown push
|
|
2898
2564
|
return;
|
|
2899
2565
|
}
|
|
2900
|
-
|
|
2901
2566
|
store.dispatch({
|
|
2902
2567
|
type: PUSH_RECEIVED,
|
|
2903
2568
|
payload: parsedPush
|
|
2904
2569
|
});
|
|
2905
2570
|
};
|
|
2906
|
-
|
|
2907
2571
|
var socketListener = (function (store, socket) {
|
|
2908
2572
|
var dispatch = store.dispatch;
|
|
2909
2573
|
socket.on('connect', function () {
|
|
@@ -2917,20 +2581,17 @@ var socketListener = (function (store, socket) {
|
|
|
2917
2581
|
handleResponseError(store, message);
|
|
2918
2582
|
return;
|
|
2919
2583
|
}
|
|
2920
|
-
|
|
2921
2584
|
switch (message.action) {
|
|
2922
2585
|
case RESUME_CHAT:
|
|
2923
2586
|
case SEND_EVENT:
|
|
2924
2587
|
case START_CHAT:
|
|
2925
2588
|
// those are requests with indirect responses
|
|
2926
2589
|
return;
|
|
2927
|
-
|
|
2928
2590
|
default:
|
|
2929
2591
|
handleResponse$1(store, message);
|
|
2930
2592
|
return;
|
|
2931
2593
|
}
|
|
2932
2594
|
}
|
|
2933
|
-
|
|
2934
2595
|
if ('request_id' in message) {
|
|
2935
2596
|
switch (message.action) {
|
|
2936
2597
|
case INCOMING_CHAT:
|
|
@@ -2940,12 +2601,10 @@ var socketListener = (function (store, socket) {
|
|
|
2940
2601
|
return;
|
|
2941
2602
|
}
|
|
2942
2603
|
}
|
|
2943
|
-
|
|
2944
2604
|
handlePush$1(store, message);
|
|
2945
2605
|
});
|
|
2946
2606
|
socket.on('disconnect', function () {
|
|
2947
2607
|
failAllRequests(store, CONNECTION_LOST);
|
|
2948
|
-
|
|
2949
2608
|
if (getConnectionStatus(store.getState()) === CONNECTED) {
|
|
2950
2609
|
store.dispatch(socketDisconnected());
|
|
2951
2610
|
}
|
|
@@ -2964,20 +2623,18 @@ var socketListener = (function (store, socket) {
|
|
|
2964
2623
|
});
|
|
2965
2624
|
|
|
2966
2625
|
var INCORRECT_REQUESTER_STRUCTURE = 'incorrect requester structure';
|
|
2967
|
-
|
|
2968
2626
|
var appendString = function appendString(input, str) {
|
|
2969
2627
|
return input.length ? input + "\n" + str : str;
|
|
2970
2628
|
};
|
|
2971
|
-
|
|
2972
2629
|
var createTicketBody = function createTicketBody(state, _ref) {
|
|
2973
2630
|
var fields = _ref.fields,
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2631
|
+
customerId = _ref.customerId,
|
|
2632
|
+
_ref$groupId = _ref.groupId,
|
|
2633
|
+
groupId = _ref$groupId === void 0 ? state.groupId : _ref$groupId,
|
|
2634
|
+
licenseId = _ref.licenseId,
|
|
2635
|
+
timeZone = _ref.timeZone;
|
|
2979
2636
|
var ticketBody = _extends({
|
|
2980
|
-
licence_id:
|
|
2637
|
+
licence_id: licenseId,
|
|
2981
2638
|
ticket_message: '',
|
|
2982
2639
|
offline_message: '',
|
|
2983
2640
|
visitor_id: customerId,
|
|
@@ -2991,106 +2648,85 @@ var createTicketBody = function createTicketBody(state, _ref) {
|
|
|
2991
2648
|
}, timeZone && {
|
|
2992
2649
|
timezone: timeZone
|
|
2993
2650
|
});
|
|
2994
|
-
|
|
2995
2651
|
return fields.reduce(function (body, field) {
|
|
2996
2652
|
switch (field.type) {
|
|
2997
2653
|
case 'subject':
|
|
2998
2654
|
{
|
|
2999
2655
|
var value = field.answer;
|
|
3000
2656
|
var text = value ? field.label + " " + value : field.label;
|
|
3001
|
-
|
|
3002
2657
|
if (value) {
|
|
3003
2658
|
body.subject = value;
|
|
3004
2659
|
}
|
|
3005
|
-
|
|
3006
2660
|
body.offline_message = appendString(body.offline_message, text);
|
|
3007
2661
|
return body;
|
|
3008
2662
|
}
|
|
3009
|
-
|
|
3010
2663
|
case 'name':
|
|
3011
2664
|
{
|
|
3012
2665
|
var _value = field.answer;
|
|
3013
|
-
|
|
3014
2666
|
var _text = _value ? field.label + " " + _value : field.label;
|
|
3015
|
-
|
|
3016
2667
|
if (_value) {
|
|
3017
2668
|
body.requester.name = _value;
|
|
3018
2669
|
}
|
|
3019
|
-
|
|
3020
2670
|
body.offline_message = appendString(body.offline_message, _text);
|
|
3021
2671
|
return body;
|
|
3022
2672
|
}
|
|
3023
|
-
|
|
3024
2673
|
case 'email':
|
|
3025
2674
|
{
|
|
3026
2675
|
var _value2 = field.answer;
|
|
3027
|
-
|
|
3028
2676
|
var _text2 = _value2 ? field.label + " " + _value2 : field.label;
|
|
3029
|
-
|
|
3030
2677
|
body.requester.mail = _value2;
|
|
3031
2678
|
body.offline_message = appendString(body.offline_message, _text2);
|
|
3032
2679
|
return body;
|
|
3033
2680
|
}
|
|
3034
|
-
|
|
3035
2681
|
case 'question':
|
|
3036
2682
|
case 'textarea':
|
|
3037
2683
|
{
|
|
3038
2684
|
var _value3 = field.answer;
|
|
3039
|
-
|
|
3040
2685
|
var _text3 = _value3 ? field.label + " " + _value3 : field.label;
|
|
3041
|
-
|
|
3042
2686
|
body.offline_message = appendString(body.offline_message, _text3);
|
|
3043
2687
|
body.ticket_message = appendString(body.ticket_message, _text3);
|
|
3044
2688
|
return body;
|
|
3045
2689
|
}
|
|
3046
|
-
|
|
3047
2690
|
case 'radio':
|
|
3048
2691
|
case 'select':
|
|
3049
2692
|
{
|
|
3050
2693
|
var _value4 = field.answer && field.answer.label;
|
|
3051
|
-
|
|
3052
2694
|
var _text4 = _value4 ? field.label + " " + _value4 : field.label;
|
|
3053
|
-
|
|
3054
2695
|
body.offline_message = appendString(body.offline_message, _text4);
|
|
3055
2696
|
body.ticket_message = appendString(body.ticket_message, _text4);
|
|
3056
2697
|
return body;
|
|
3057
2698
|
}
|
|
3058
|
-
|
|
3059
2699
|
case 'checkbox':
|
|
3060
2700
|
{
|
|
3061
2701
|
var _value5 = field.answers && field.answers.map(function (answer) {
|
|
3062
2702
|
return answer.label;
|
|
3063
2703
|
}).join(', ');
|
|
3064
|
-
|
|
3065
2704
|
var _text5 = _value5 ? field.label + " " + _value5 : field.label;
|
|
3066
|
-
|
|
3067
2705
|
body.offline_message = appendString(body.offline_message, _text5);
|
|
3068
2706
|
body.ticket_message = appendString(body.ticket_message, _text5);
|
|
3069
2707
|
return body;
|
|
3070
2708
|
}
|
|
3071
|
-
|
|
3072
2709
|
default:
|
|
3073
2710
|
return body;
|
|
3074
2711
|
}
|
|
3075
2712
|
}, ticketBody);
|
|
3076
2713
|
};
|
|
3077
|
-
|
|
3078
2714
|
var sendTicketForm = function sendTicketForm(store, auth, _ref2) {
|
|
3079
2715
|
var filledForm = _ref2.filledForm,
|
|
3080
|
-
|
|
3081
|
-
|
|
2716
|
+
groupId = _ref2.groupId,
|
|
2717
|
+
licenseId = _ref2.licenseId,
|
|
2718
|
+
timeZone = _ref2.timeZone;
|
|
3082
2719
|
return auth.getToken().then(function (token) {
|
|
3083
2720
|
var state = store.getState();
|
|
3084
|
-
|
|
3085
2721
|
if (getSelfId(state) === null) {
|
|
3086
2722
|
store.dispatch(setSelfId(token.entityId));
|
|
3087
2723
|
}
|
|
3088
|
-
|
|
3089
2724
|
var url = getApiOrigin(state) + "/v2/tickets/new";
|
|
3090
2725
|
var body = createTicketBody(state, {
|
|
3091
2726
|
fields: filledForm.fields,
|
|
3092
2727
|
customerId: token.entityId,
|
|
3093
2728
|
groupId: groupId,
|
|
2729
|
+
licenseId: licenseId,
|
|
3094
2730
|
timeZone: timeZone
|
|
3095
2731
|
});
|
|
3096
2732
|
return unfetch__default['default'](url, {
|
|
@@ -3106,33 +2742,28 @@ var sendTicketForm = function sendTicketForm(store, auth, _ref2) {
|
|
|
3106
2742
|
text: body.ticket_message
|
|
3107
2743
|
});
|
|
3108
2744
|
});
|
|
3109
|
-
}
|
|
3110
|
-
|
|
2745
|
+
}
|
|
3111
2746
|
|
|
2747
|
+
// we actually should normalize this somehow
|
|
3112
2748
|
if (response.status === 400 || response.status === 422) {
|
|
3113
2749
|
var errHandler = function errHandler(error) {
|
|
3114
2750
|
if (!error || !error.errors) {
|
|
3115
2751
|
// TODO: I honestly don't know if this can even be reached and even if it is - What error should be thrown here
|
|
3116
2752
|
throw new Error();
|
|
3117
|
-
}
|
|
3118
|
-
|
|
3119
|
-
|
|
2753
|
+
}
|
|
2754
|
+
// we receive some hardcore aggregate error here 😱
|
|
3120
2755
|
var firstError = error.errors[0];
|
|
3121
2756
|
var type = Object.keys(firstError)[0];
|
|
3122
|
-
|
|
3123
2757
|
if (type === INCORRECT_REQUESTER_STRUCTURE) {
|
|
3124
2758
|
throw createError({
|
|
3125
2759
|
message: firstError[INCORRECT_REQUESTER_STRUCTURE][0],
|
|
3126
2760
|
code: 'VALIDATION'
|
|
3127
2761
|
});
|
|
3128
2762
|
}
|
|
3129
|
-
|
|
3130
2763
|
throw new Error();
|
|
3131
2764
|
};
|
|
3132
|
-
|
|
3133
2765
|
return response.json().then(errHandler, errHandler);
|
|
3134
2766
|
}
|
|
3135
|
-
|
|
3136
2767
|
throw new Error();
|
|
3137
2768
|
});
|
|
3138
2769
|
});
|
|
@@ -3142,32 +2773,24 @@ var KILOBYTE = 1024;
|
|
|
3142
2773
|
var MEGABYTE = 1024 * KILOBYTE;
|
|
3143
2774
|
var GIGABYTE = 1024 * MEGABYTE;
|
|
3144
2775
|
var SIZE_LIMIT = 10 * MEGABYTE;
|
|
3145
|
-
|
|
3146
2776
|
var formatBytes = function formatBytes(bytes, precision) {
|
|
3147
2777
|
if (precision === void 0) {
|
|
3148
2778
|
precision = 2;
|
|
3149
2779
|
}
|
|
3150
|
-
|
|
3151
2780
|
if (bytes < KILOBYTE) {
|
|
3152
2781
|
return bytes + " b";
|
|
3153
2782
|
}
|
|
3154
|
-
|
|
3155
2783
|
var kilobytes = bytes / 1024;
|
|
3156
|
-
|
|
3157
2784
|
if (bytes < MEGABYTE) {
|
|
3158
2785
|
return kilobytes.toFixed(precision) + " kb";
|
|
3159
2786
|
}
|
|
3160
|
-
|
|
3161
2787
|
var megabytes = kilobytes / 1024;
|
|
3162
|
-
|
|
3163
2788
|
if (bytes < GIGABYTE) {
|
|
3164
2789
|
return megabytes.toFixed(precision) + " MB";
|
|
3165
2790
|
}
|
|
3166
|
-
|
|
3167
2791
|
var gigabytes = megabytes / 1024;
|
|
3168
2792
|
return gigabytes.toFixed(precision) + " GB";
|
|
3169
2793
|
};
|
|
3170
|
-
|
|
3171
2794
|
var validateFile = function validateFile(file) {
|
|
3172
2795
|
if (file.size > SIZE_LIMIT) {
|
|
3173
2796
|
throw createError({
|
|
@@ -3179,16 +2802,16 @@ var validateFile = function validateFile(file) {
|
|
|
3179
2802
|
|
|
3180
2803
|
var uploadFile = function uploadFile(_ref, _ref2) {
|
|
3181
2804
|
var auth = _ref.auth,
|
|
3182
|
-
|
|
2805
|
+
store = _ref.store;
|
|
3183
2806
|
var file = _ref2.file,
|
|
3184
|
-
|
|
2807
|
+
onProgress = _ref2.onProgress;
|
|
3185
2808
|
var upload;
|
|
3186
2809
|
var cancelled = false;
|
|
3187
2810
|
var send = new Promise(function (resolve, reject) {
|
|
3188
2811
|
validateFile(file);
|
|
3189
2812
|
var state = store.getState();
|
|
3190
2813
|
var query = urlUtils.buildQueryString({
|
|
3191
|
-
|
|
2814
|
+
organization_id: state.organizationId
|
|
3192
2815
|
});
|
|
3193
2816
|
var url = getServerUrl(state) + "/action/" + UPLOAD_FILE + "?" + query;
|
|
3194
2817
|
var payload = {
|
|
@@ -3199,7 +2822,6 @@ var uploadFile = function uploadFile(_ref, _ref2) {
|
|
|
3199
2822
|
reject(new Error('Upload cancelled.'));
|
|
3200
2823
|
return;
|
|
3201
2824
|
}
|
|
3202
|
-
|
|
3203
2825
|
upload = rawUploadFile__default['default'](url, payload, {
|
|
3204
2826
|
headers: {
|
|
3205
2827
|
Authorization: token.tokenType + " " + token.accessToken
|
|
@@ -3212,10 +2834,9 @@ var uploadFile = function uploadFile(_ref, _ref2) {
|
|
|
3212
2834
|
reject(uploadError);
|
|
3213
2835
|
return;
|
|
3214
2836
|
}
|
|
3215
|
-
|
|
3216
2837
|
var _uploadError$response = uploadError.response.error,
|
|
3217
|
-
|
|
3218
|
-
|
|
2838
|
+
type = _uploadError$response.type,
|
|
2839
|
+
message = _uploadError$response.message;
|
|
3219
2840
|
reject(createError({
|
|
3220
2841
|
message: message,
|
|
3221
2842
|
code: type.toUpperCase()
|
|
@@ -3229,9 +2850,7 @@ var uploadFile = function uploadFile(_ref, _ref2) {
|
|
|
3229
2850
|
if (cancelled) {
|
|
3230
2851
|
return;
|
|
3231
2852
|
}
|
|
3232
|
-
|
|
3233
2853
|
cancelled = true;
|
|
3234
|
-
|
|
3235
2854
|
if (upload) {
|
|
3236
2855
|
upload.cancel();
|
|
3237
2856
|
}
|
|
@@ -3258,20 +2877,18 @@ var makeGraylogRequest = function makeGraylogRequest(url, body) {
|
|
|
3258
2877
|
*/
|
|
3259
2878
|
var log = function log(_ref) {
|
|
3260
2879
|
var env = _ref.env,
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
2880
|
+
organizationId = _ref.organizationId,
|
|
2881
|
+
eventName = _ref.eventName;
|
|
3264
2882
|
if (env !== 'production' || "customer_sdk" !== 'customer_sdk') {
|
|
3265
2883
|
return Promise.resolve();
|
|
3266
2884
|
}
|
|
3267
|
-
|
|
3268
2885
|
var message = {
|
|
3269
2886
|
event_name: eventName,
|
|
3270
2887
|
severity: 'Informational',
|
|
3271
|
-
sdkVersion: "3.1.
|
|
2888
|
+
sdkVersion: "3.1.3"
|
|
3272
2889
|
};
|
|
3273
2890
|
var body = {
|
|
3274
|
-
|
|
2891
|
+
organizationId: organizationId,
|
|
3275
2892
|
event_id: 'chat_widget_customer_sdk',
|
|
3276
2893
|
message: JSON.stringify(message)
|
|
3277
2894
|
};
|
|
@@ -3280,26 +2897,20 @@ var log = function log(_ref) {
|
|
|
3280
2897
|
|
|
3281
2898
|
var LISTENER_IDENTITY = 'LISTENER_IDENTITY';
|
|
3282
2899
|
var listenersMap = {};
|
|
3283
|
-
|
|
3284
2900
|
var createDebuggedMethods = function createDebuggedMethods(methods, prefix) {
|
|
3285
2901
|
if (prefix === void 0) {
|
|
3286
2902
|
prefix = '';
|
|
3287
2903
|
}
|
|
3288
|
-
|
|
3289
2904
|
var methodNames = Object.keys(methods);
|
|
3290
2905
|
return methodNames.map(function (methodName) {
|
|
3291
2906
|
var method = methods[methodName];
|
|
3292
2907
|
return function () {
|
|
3293
2908
|
var _console;
|
|
3294
|
-
|
|
3295
2909
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3296
2910
|
args[_key] = arguments[_key];
|
|
3297
2911
|
}
|
|
3298
|
-
|
|
3299
2912
|
(_console = console).info.apply(_console, [prefix + "." + methodName + "() ===>"].concat(args));
|
|
3300
|
-
|
|
3301
2913
|
var result = method.apply(void 0, args);
|
|
3302
|
-
|
|
3303
2914
|
if (typeof (result == null ? void 0 : result.then) === 'function') {
|
|
3304
2915
|
return result.then(function (data) {
|
|
3305
2916
|
console.info(prefix + "." + methodName + "() <===", data);
|
|
@@ -3309,7 +2920,6 @@ var createDebuggedMethods = function createDebuggedMethods(methods, prefix) {
|
|
|
3309
2920
|
throw err;
|
|
3310
2921
|
});
|
|
3311
2922
|
}
|
|
3312
|
-
|
|
3313
2923
|
return result;
|
|
3314
2924
|
};
|
|
3315
2925
|
}).reduce(function (acc, method, index) {
|
|
@@ -3317,78 +2927,61 @@ var createDebuggedMethods = function createDebuggedMethods(methods, prefix) {
|
|
|
3317
2927
|
return acc;
|
|
3318
2928
|
}, {});
|
|
3319
2929
|
};
|
|
3320
|
-
|
|
3321
2930
|
var createEnhancedListener = function createEnhancedListener(label, event, listener) {
|
|
3322
2931
|
if (listener[LISTENER_IDENTITY] === undefined) {
|
|
3323
2932
|
Object.defineProperty(listener, LISTENER_IDENTITY, {
|
|
3324
2933
|
value: {}
|
|
3325
2934
|
});
|
|
3326
2935
|
}
|
|
3327
|
-
|
|
3328
2936
|
if (listener[LISTENER_IDENTITY][event]) {
|
|
3329
2937
|
var enhancedListenerId = listener[LISTENER_IDENTITY][event];
|
|
3330
2938
|
return listenersMap[enhancedListenerId];
|
|
3331
2939
|
}
|
|
3332
|
-
|
|
3333
2940
|
var enhancedListener = function enhancedListener(data) {
|
|
3334
2941
|
console.info("." + label + "(\"" + event + "\") <===", data);
|
|
3335
2942
|
listener(data);
|
|
3336
2943
|
};
|
|
3337
|
-
|
|
3338
2944
|
var uniqueId = dataUtils.generateUniqueId(listenersMap);
|
|
3339
2945
|
listener[LISTENER_IDENTITY][event] = uniqueId;
|
|
3340
2946
|
listenersMap[uniqueId] = enhancedListener;
|
|
3341
2947
|
return enhancedListener;
|
|
3342
|
-
};
|
|
3343
|
-
|
|
2948
|
+
};
|
|
3344
2949
|
|
|
2950
|
+
// TODO: this really should just accept & return CustomerSdk type
|
|
3345
2951
|
var debug = (function (_sdk) {
|
|
3346
2952
|
var sdk = _sdk;
|
|
3347
|
-
|
|
3348
2953
|
if (process.env.NODE_ENV === 'production') {
|
|
3349
2954
|
console.warn('You probably do not want to use debug(customerSDK) in your production environment.');
|
|
3350
2955
|
}
|
|
3351
|
-
|
|
3352
2956
|
var _on = sdk.on,
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
2957
|
+
_once = sdk.once,
|
|
2958
|
+
_off = sdk.off,
|
|
2959
|
+
_getChatHistory = sdk.getChatHistory,
|
|
2960
|
+
auth = sdk.auth,
|
|
2961
|
+
rest = _objectWithoutPropertiesLoose(sdk, ["on", "once", "off", "getChatHistory", "auth"]);
|
|
3359
2962
|
var methods = createDebuggedMethods(rest);
|
|
3360
2963
|
return Object.freeze(_extends({
|
|
3361
2964
|
auth: Object.freeze(createDebuggedMethods(auth, '.auth'))
|
|
3362
2965
|
}, methods, {
|
|
3363
2966
|
getChatHistory: function getChatHistory() {
|
|
3364
2967
|
var _console2;
|
|
3365
|
-
|
|
3366
2968
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
3367
2969
|
args[_key2] = arguments[_key2];
|
|
3368
2970
|
}
|
|
3369
|
-
|
|
3370
2971
|
(_console2 = console).info.apply(_console2, [".getChatHistory()"].concat(args));
|
|
3371
|
-
|
|
3372
2972
|
var history = _getChatHistory.apply(void 0, args);
|
|
3373
|
-
|
|
3374
2973
|
var logLabel = 'history.next()';
|
|
3375
2974
|
return {
|
|
3376
2975
|
next: function next() {
|
|
3377
2976
|
var _console3;
|
|
3378
|
-
|
|
3379
2977
|
(_console3 = console).info.apply(_console3, [logLabel + " ===>"].concat(args));
|
|
3380
|
-
|
|
3381
2978
|
return history.next().then(function (data) {
|
|
3382
2979
|
var _console4;
|
|
3383
|
-
|
|
3384
2980
|
(_console4 = console).info.apply(_console4, [logLabel + " <==="].concat(args, [data]));
|
|
3385
|
-
|
|
3386
2981
|
return data;
|
|
3387
2982
|
}, function (err) {
|
|
3388
2983
|
var _console5;
|
|
3389
|
-
|
|
3390
2984
|
(_console5 = console).error.apply(_console5, [logLabel + " <==="].concat(args, [err]));
|
|
3391
|
-
|
|
3392
2985
|
throw err;
|
|
3393
2986
|
});
|
|
3394
2987
|
}
|
|
@@ -3397,12 +2990,10 @@ var debug = (function (_sdk) {
|
|
|
3397
2990
|
off: function off(event, listener) {
|
|
3398
2991
|
console.info(".off(\"" + event + "\", " + (listener.name || 'anonymous') + ")");
|
|
3399
2992
|
var enhancedListener = listener;
|
|
3400
|
-
|
|
3401
2993
|
if (listener[LISTENER_IDENTITY] !== undefined) {
|
|
3402
2994
|
var enhancedListenerId = listener[LISTENER_IDENTITY][event];
|
|
3403
2995
|
enhancedListener = listenersMap[enhancedListenerId];
|
|
3404
2996
|
}
|
|
3405
|
-
|
|
3406
2997
|
_off(event, enhancedListener);
|
|
3407
2998
|
},
|
|
3408
2999
|
on: function on(event, listener) {
|
|
@@ -3415,45 +3006,40 @@ var debug = (function (_sdk) {
|
|
|
3415
3006
|
});
|
|
3416
3007
|
|
|
3417
3008
|
var CHATS_PAGINATION_MAX_LIMIT = 25;
|
|
3418
|
-
var init = function init(config, env) {
|
|
3009
|
+
var init = function init(config, env, licenseId) {
|
|
3419
3010
|
if (env === void 0) {
|
|
3420
3011
|
env = 'production';
|
|
3421
3012
|
}
|
|
3422
|
-
|
|
3423
3013
|
createAuth.validateConfig(config);
|
|
3424
|
-
|
|
3425
3014
|
var _config$autoConnect = config.autoConnect,
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3015
|
+
autoConnect = _config$autoConnect === void 0 ? true : _config$autoConnect,
|
|
3016
|
+
customerDataProvider = config.customerDataProvider,
|
|
3017
|
+
identityProvider = config.identityProvider,
|
|
3018
|
+
instanceConfig = _objectWithoutPropertiesLoose(config, ["autoConnect", "customerDataProvider", "identityProvider"]);
|
|
3431
3019
|
var store = finalCreateStore(_extends({}, instanceConfig, {
|
|
3432
3020
|
env: env
|
|
3433
3021
|
}));
|
|
3434
3022
|
var emitter = mitt__default['default']();
|
|
3435
3023
|
var socket = createSocketClient(store);
|
|
3436
|
-
var auth = typeof identityProvider === 'function' ? identityProvider() : createAuth__default['default'](instanceConfig, env);
|
|
3024
|
+
var auth = typeof identityProvider === 'function' ? identityProvider() : createAuth__default['default'](instanceConfig, licenseId, env);
|
|
3437
3025
|
store.addSideEffectsHandler(createSideEffectsHandler({
|
|
3438
3026
|
emitter: emitter,
|
|
3439
3027
|
socket: socket,
|
|
3440
3028
|
auth: auth,
|
|
3441
|
-
customerDataProvider: customerDataProvider
|
|
3029
|
+
customerDataProvider: customerDataProvider,
|
|
3030
|
+
licenseId: licenseId
|
|
3442
3031
|
}));
|
|
3443
3032
|
socketListener(store, socket);
|
|
3444
|
-
|
|
3445
3033
|
var sendRequestAction$1 = sendRequestAction.bind(null, store);
|
|
3446
|
-
|
|
3447
3034
|
var startConnection = function startConnection() {
|
|
3448
3035
|
store.dispatch({
|
|
3449
3036
|
type: START_CONNECTION
|
|
3450
3037
|
});
|
|
3451
3038
|
};
|
|
3452
|
-
|
|
3453
3039
|
var api = Object.freeze({
|
|
3454
3040
|
acceptGreeting: function acceptGreeting(_ref) {
|
|
3455
3041
|
var greetingId = _ref.greetingId,
|
|
3456
|
-
|
|
3042
|
+
uniqueId = _ref.uniqueId;
|
|
3457
3043
|
return sendRequestAction$1(sendRequest(ACCEPT_GREETING, {
|
|
3458
3044
|
greeting_id: greetingId,
|
|
3459
3045
|
unique_id: uniqueId
|
|
@@ -3468,20 +3054,18 @@ var init = function init(config, env) {
|
|
|
3468
3054
|
},
|
|
3469
3055
|
cancelRate: function cancelRate(params) {
|
|
3470
3056
|
var chatId = params.chatId,
|
|
3471
|
-
|
|
3472
|
-
|
|
3057
|
+
_params$properties = params.properties,
|
|
3058
|
+
properties = _params$properties === void 0 ? ['score'] : _params$properties;
|
|
3473
3059
|
return api.listThreads({
|
|
3474
3060
|
chatId: chatId
|
|
3475
3061
|
}).then(function (_ref3) {
|
|
3476
3062
|
var threads = _ref3.threads;
|
|
3477
|
-
|
|
3478
3063
|
if (!threads.length) {
|
|
3479
3064
|
throw createError({
|
|
3480
3065
|
message: "There is no thread in \"" + chatId + "\".",
|
|
3481
3066
|
code: MISSING_CHAT_THREAD
|
|
3482
3067
|
});
|
|
3483
3068
|
}
|
|
3484
|
-
|
|
3485
3069
|
return api.deleteThreadProperties({
|
|
3486
3070
|
chatId: chatId,
|
|
3487
3071
|
threadId: threads[0].id,
|
|
@@ -3500,7 +3084,7 @@ var init = function init(config, env) {
|
|
|
3500
3084
|
},
|
|
3501
3085
|
deleteChatProperties: function deleteChatProperties(_ref5) {
|
|
3502
3086
|
var id = _ref5.id,
|
|
3503
|
-
|
|
3087
|
+
properties = _ref5.properties;
|
|
3504
3088
|
return sendRequestAction$1(sendRequest(DELETE_CHAT_PROPERTIES, {
|
|
3505
3089
|
id: id,
|
|
3506
3090
|
properties: properties
|
|
@@ -3508,9 +3092,9 @@ var init = function init(config, env) {
|
|
|
3508
3092
|
},
|
|
3509
3093
|
deleteEventProperties: function deleteEventProperties(_ref6) {
|
|
3510
3094
|
var chatId = _ref6.chatId,
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3095
|
+
threadId = _ref6.threadId,
|
|
3096
|
+
eventId = _ref6.eventId,
|
|
3097
|
+
properties = _ref6.properties;
|
|
3514
3098
|
return sendRequestAction$1(sendRequest(DELETE_EVENT_PROPERTIES, {
|
|
3515
3099
|
chat_id: chatId,
|
|
3516
3100
|
thread_id: threadId,
|
|
@@ -3520,8 +3104,8 @@ var init = function init(config, env) {
|
|
|
3520
3104
|
},
|
|
3521
3105
|
deleteThreadProperties: function deleteThreadProperties(_ref7) {
|
|
3522
3106
|
var chatId = _ref7.chatId,
|
|
3523
|
-
|
|
3524
|
-
|
|
3107
|
+
threadId = _ref7.threadId,
|
|
3108
|
+
properties = _ref7.properties;
|
|
3525
3109
|
return sendRequestAction$1(sendRequest(DELETE_THREAD_PROPERTIES, {
|
|
3526
3110
|
chat_id: chatId,
|
|
3527
3111
|
thread_id: threadId,
|
|
@@ -3536,7 +3120,7 @@ var init = function init(config, env) {
|
|
|
3536
3120
|
},
|
|
3537
3121
|
getChat: function getChat(_ref8) {
|
|
3538
3122
|
var chatId = _ref8.chatId,
|
|
3539
|
-
|
|
3123
|
+
threadId = _ref8.threadId;
|
|
3540
3124
|
return sendRequestAction$1(sendRequest(GET_CHAT, {
|
|
3541
3125
|
chat_id: chatId,
|
|
3542
3126
|
thread_id: threadId
|
|
@@ -3551,7 +3135,7 @@ var init = function init(config, env) {
|
|
|
3551
3135
|
},
|
|
3552
3136
|
getForm: function getForm(_ref10) {
|
|
3553
3137
|
var groupId = _ref10.groupId,
|
|
3554
|
-
|
|
3138
|
+
type = _ref10.type;
|
|
3555
3139
|
return sendRequestAction$1(sendRequest(GET_FORM, {
|
|
3556
3140
|
group_id: groupId,
|
|
3557
3141
|
type: type
|
|
@@ -3561,9 +3145,8 @@ var init = function init(config, env) {
|
|
|
3561
3145
|
if (params === void 0) {
|
|
3562
3146
|
params = {};
|
|
3563
3147
|
}
|
|
3564
|
-
|
|
3565
3148
|
var _params = params,
|
|
3566
|
-
|
|
3149
|
+
groupId = _params.groupId;
|
|
3567
3150
|
return sendRequestAction$1(sendRequest(GET_PREDICTED_AGENT, typeof groupId === 'number' ? {
|
|
3568
3151
|
group_id: groupId
|
|
3569
3152
|
} : {}));
|
|
@@ -3578,11 +3161,9 @@ var init = function init(config, env) {
|
|
|
3578
3161
|
if (params === void 0) {
|
|
3579
3162
|
params = {};
|
|
3580
3163
|
}
|
|
3581
|
-
|
|
3582
3164
|
if ('limit' in params && typeof params.limit === 'number' && params.limit > CHATS_PAGINATION_MAX_LIMIT) {
|
|
3583
3165
|
return Promise.reject(new Error("Specified limit is too high (max " + CHATS_PAGINATION_MAX_LIMIT + ")."));
|
|
3584
3166
|
}
|
|
3585
|
-
|
|
3586
3167
|
return sendRequestAction$1(sendRequest(LIST_CHATS, params.pageId === undefined ? {
|
|
3587
3168
|
limit: params.limit || 10
|
|
3588
3169
|
} : {
|
|
@@ -3591,8 +3172,7 @@ var init = function init(config, env) {
|
|
|
3591
3172
|
},
|
|
3592
3173
|
listGroupStatuses: function listGroupStatuses(_temp) {
|
|
3593
3174
|
var _ref12 = _temp === void 0 ? {} : _temp,
|
|
3594
|
-
|
|
3595
|
-
|
|
3175
|
+
groupIds = _ref12.groupIds;
|
|
3596
3176
|
return sendRequestAction$1(sendRequest(LIST_GROUP_STATUSES, groupIds ? {
|
|
3597
3177
|
group_ids: groupIds
|
|
3598
3178
|
} : {
|
|
@@ -3612,7 +3192,7 @@ var init = function init(config, env) {
|
|
|
3612
3192
|
},
|
|
3613
3193
|
markEventsAsSeen: function markEventsAsSeen(_ref13) {
|
|
3614
3194
|
var chatId = _ref13.chatId,
|
|
3615
|
-
|
|
3195
|
+
seenUpTo = _ref13.seenUpTo;
|
|
3616
3196
|
return sendRequestAction$1(sendRequest(MARK_EVENTS_AS_SEEN, {
|
|
3617
3197
|
chat_id: chatId,
|
|
3618
3198
|
seen_up_to: seenUpTo
|
|
@@ -3623,19 +3203,17 @@ var init = function init(config, env) {
|
|
|
3623
3203
|
off: emitter.off,
|
|
3624
3204
|
rateChat: function rateChat(params) {
|
|
3625
3205
|
var chatId = params.chatId,
|
|
3626
|
-
|
|
3206
|
+
rating = params.rating;
|
|
3627
3207
|
return api.listThreads({
|
|
3628
3208
|
chatId: chatId
|
|
3629
3209
|
}).then(function (_ref14) {
|
|
3630
3210
|
var threads = _ref14.threads;
|
|
3631
|
-
|
|
3632
3211
|
if (!threads.length) {
|
|
3633
3212
|
throw createError({
|
|
3634
3213
|
message: "There is no thread in \"" + chatId + "\".",
|
|
3635
3214
|
code: MISSING_CHAT_THREAD
|
|
3636
3215
|
});
|
|
3637
3216
|
}
|
|
3638
|
-
|
|
3639
3217
|
return api.updateThreadProperties({
|
|
3640
3218
|
chatId: chatId,
|
|
3641
3219
|
threadId: threads[0].id,
|
|
@@ -3648,7 +3226,7 @@ var init = function init(config, env) {
|
|
|
3648
3226
|
resumeChat: function resumeChat(data) {
|
|
3649
3227
|
log({
|
|
3650
3228
|
env: env,
|
|
3651
|
-
|
|
3229
|
+
organizationId: config.organizationId,
|
|
3652
3230
|
eventName: 'chat_started'
|
|
3653
3231
|
});
|
|
3654
3232
|
return sendRequestAction$1(sendRequest(RESUME_CHAT, parseResumeChatData(data)));
|
|
@@ -3657,11 +3235,9 @@ var init = function init(config, env) {
|
|
|
3657
3235
|
function sendEvent(_x) {
|
|
3658
3236
|
return _sendEvent.apply(this, arguments);
|
|
3659
3237
|
}
|
|
3660
|
-
|
|
3661
3238
|
sendEvent.toString = function () {
|
|
3662
3239
|
return _sendEvent.toString();
|
|
3663
3240
|
};
|
|
3664
|
-
|
|
3665
3241
|
return sendEvent;
|
|
3666
3242
|
}(function (params) {
|
|
3667
3243
|
return sendRequestAction$1(sendEvent(params));
|
|
@@ -3671,9 +3247,9 @@ var init = function init(config, env) {
|
|
|
3671
3247
|
},
|
|
3672
3248
|
sendRichMessagePostback: function sendRichMessagePostback(_ref15) {
|
|
3673
3249
|
var chatId = _ref15.chatId,
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3250
|
+
threadId = _ref15.threadId,
|
|
3251
|
+
eventId = _ref15.eventId,
|
|
3252
|
+
postback = _ref15.postback;
|
|
3677
3253
|
return sendRequestAction$1(sendRequest(SEND_RICH_MESSAGE_POSTBACK, {
|
|
3678
3254
|
chat_id: chatId,
|
|
3679
3255
|
event_id: eventId,
|
|
@@ -3689,13 +3265,11 @@ var init = function init(config, env) {
|
|
|
3689
3265
|
},
|
|
3690
3266
|
setSneakPeek: function setSneakPeek(_ref17) {
|
|
3691
3267
|
var chatId = _ref17.chatId,
|
|
3692
|
-
|
|
3268
|
+
sneakPeekText = _ref17.sneakPeekText;
|
|
3693
3269
|
var state = store.getState();
|
|
3694
|
-
|
|
3695
3270
|
if (!isChatActive(state, chatId) || !isConnected(state)) {
|
|
3696
3271
|
return;
|
|
3697
3272
|
}
|
|
3698
|
-
|
|
3699
3273
|
sendRequestAction$1(sendRequest(SEND_SNEAK_PEEK, {
|
|
3700
3274
|
chat_id: chatId,
|
|
3701
3275
|
sneak_peek_text: sneakPeekText
|
|
@@ -3705,17 +3279,16 @@ var init = function init(config, env) {
|
|
|
3705
3279
|
if (data === void 0) {
|
|
3706
3280
|
data = {};
|
|
3707
3281
|
}
|
|
3708
|
-
|
|
3709
3282
|
log({
|
|
3710
3283
|
env: env,
|
|
3711
|
-
|
|
3284
|
+
organizationId: config.organizationId,
|
|
3712
3285
|
eventName: 'chat_started'
|
|
3713
3286
|
});
|
|
3714
3287
|
return sendRequestAction$1(sendRequest(START_CHAT, parseStartChatData(data)));
|
|
3715
3288
|
},
|
|
3716
3289
|
updateChatProperties: function updateChatProperties(_ref18) {
|
|
3717
3290
|
var id = _ref18.id,
|
|
3718
|
-
|
|
3291
|
+
properties = _ref18.properties;
|
|
3719
3292
|
return sendRequestAction$1(sendRequest(UPDATE_CHAT_PROPERTIES, {
|
|
3720
3293
|
id: id,
|
|
3721
3294
|
properties: properties
|
|
@@ -3732,9 +3305,9 @@ var init = function init(config, env) {
|
|
|
3732
3305
|
},
|
|
3733
3306
|
updateEventProperties: function updateEventProperties(_ref19) {
|
|
3734
3307
|
var chatId = _ref19.chatId,
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3308
|
+
threadId = _ref19.threadId,
|
|
3309
|
+
eventId = _ref19.eventId,
|
|
3310
|
+
properties = _ref19.properties;
|
|
3738
3311
|
return sendRequestAction$1(sendRequest(UPDATE_EVENT_PROPERTIES, {
|
|
3739
3312
|
chat_id: chatId,
|
|
3740
3313
|
event_id: eventId,
|
|
@@ -3744,8 +3317,8 @@ var init = function init(config, env) {
|
|
|
3744
3317
|
},
|
|
3745
3318
|
updateThreadProperties: function updateThreadProperties(_ref20) {
|
|
3746
3319
|
var chatId = _ref20.chatId,
|
|
3747
|
-
|
|
3748
|
-
|
|
3320
|
+
threadId = _ref20.threadId,
|
|
3321
|
+
properties = _ref20.properties;
|
|
3749
3322
|
return sendRequestAction$1(sendRequest(UPDATE_THREAD_PROPERTIES, {
|
|
3750
3323
|
chat_id: chatId,
|
|
3751
3324
|
thread_id: threadId,
|
|
@@ -3759,7 +3332,6 @@ var init = function init(config, env) {
|
|
|
3759
3332
|
}, options);
|
|
3760
3333
|
}
|
|
3761
3334
|
});
|
|
3762
|
-
|
|
3763
3335
|
if (autoConnect) {
|
|
3764
3336
|
startConnection();
|
|
3765
3337
|
} else {
|
|
@@ -3770,7 +3342,6 @@ var init = function init(config, env) {
|
|
|
3770
3342
|
}
|
|
3771
3343
|
});
|
|
3772
3344
|
}
|
|
3773
|
-
|
|
3774
3345
|
return api;
|
|
3775
3346
|
};
|
|
3776
3347
|
|