Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@livechat/chat.io-customer-sdk

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@livechat/chat.io-customer-sdk - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0-0

15

es/index.js

@@ -30,3 +30,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var serverUrl = 'https://api' + (env !== 'production' ? '.' + env : '') + '.chat.io/customer/v0.3';
var serverUrl = 'https://api' + (env !== 'production' ? '.' + env : '') + '.chat.io/customer/v0.4';

@@ -131,2 +131,15 @@ var emitter = mitt();

},
updateChatProperties: function updateChatProperties(chat, properties) {
return sendRequestAction(requestActions.sendRequest('update_chat_properties', {
chat_id: chat,
properties: properties
}));
},
updateChatThreadProperties: function updateChatThreadProperties(chat, thread, properties) {
return sendRequestAction(requestActions.sendRequest('update_chat_thread_properties', {
chat_id: chat,
thread_id: thread,
properties: properties
}));
},
updateCustomer: function updateCustomer(properties) {

@@ -133,0 +146,0 @@ return sendRequestAction(requestActions.sendRequest('update_customer', { customer: properties }));

47

es/serverDataParser.js

@@ -6,3 +6,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

import { isEmpty, flatMap, keyBy, last, mapValues, numericSortBy, omit } from './utils';
import { cloneDeep, isEmpty, flatMap, keyBy, last, mapValues, numericSortBy, omit } from './utils';

@@ -234,5 +234,3 @@ var parseServerTimestamp = function parseServerTimestamp(timestamp) {

order = _ref2.order,
_ref2$last_event_per_ = _ref2.last_event_per_type,
lastThread = _ref2$last_event_per_.thread_id,
lastEvents = _ref2$last_event_per_.events,
lastEventsPerType = _ref2.last_event_per_type,
users = _ref2.users;

@@ -251,14 +249,33 @@

if (!isEmpty(lastEvents)) {
chatSummary.lastEvent = parseEvent(lastThread, last(numericSortBy('order', Object.keys(lastEvents).map(function (eventType) {
return lastEvents[eventType];
}))));
if (!lastEventsPerType) {
return chatSummary;
}
chatSummary.lastEventsPerType = mapValues(function (_ref4) {
var thread = _ref4.thread_id,
event = _ref4.event;
return parseEvent(thread, event);
}, lastEventsPerType);
var lastEventsArray = Object.keys(lastEventsPerType).map(function (eventType) {
return lastEventsPerType[eventType];
});
var lastEvent = last(lastEventsArray.sort(function (eventA, eventB) {
if (eventA.thread_id === eventB.thread_id) {
return eventA.event.order - eventB.event.order;
}
return eventA.thread_order - eventB.thread_order;
}));
if (lastEvent) {
chatSummary.lastEvent = cloneDeep(chatSummary.lastEventsPerType[lastEvent.event.type]);
}
return chatSummary;
});
return {
chatsSummary: numericSortBy(function (_ref4) {
var lastEvent = _ref4.lastEvent,
order = _ref4.order;
chatsSummary: numericSortBy(function (_ref5) {
var lastEvent = _ref5.lastEvent,
order = _ref5.order;
return -1 * (lastEvent !== undefined ? lastEvent.timestamp : order);

@@ -268,4 +285,4 @@ }, chatsSummary),

users: flatMap(function (_ref5) {
var users = _ref5.users;
users: flatMap(function (_ref6) {
var users = _ref6.users;
return users.map(parseUser);

@@ -294,4 +311,4 @@ }, payload.chats_summary)

id: id,
users: users.map(function (_ref6) {
var userId = _ref6.id;
users: users.map(function (_ref7) {
var userId = _ref7.id;
return userId;

@@ -298,0 +315,0 @@ }),

@@ -30,2 +30,4 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

export var isArray = Array.isArray;
export var isEmpty = function isEmpty(obj) {

@@ -54,3 +56,3 @@ return Object.keys(obj).length === 0;

};
return arr.sort(function (elementA, elementB) {
return [].concat(arr).sort(function (elementA, elementB) {
return mapper(elementA) - mapper(elementB);

@@ -67,2 +69,14 @@ });

export var cloneDeep = function cloneDeep(value) {
if (isArray(value)) {
return value.map(cloneDeep);
}
if (isObject(value)) {
return mapValues(cloneDeep, value);
}
return value;
};
export var noop = function noop() {};

@@ -83,4 +97,5 @@

export var splitRightWhenAccum = function splitRightWhenAccum(fn, acc, arr) {
export var splitRightWhenAccum = function splitRightWhenAccum(fn, initialAcc, arr) {
var result = false;
var acc = initialAcc;

@@ -87,0 +102,0 @@ for (var index = arr.length; index > 0; index--) {

@@ -80,3 +80,3 @@ 'use strict';

var serverUrl = 'https://api' + (env !== 'production' ? '.' + env : '') + '.chat.io/customer/v0.3';
var serverUrl = 'https://api' + (env !== 'production' ? '.' + env : '') + '.chat.io/customer/v0.4';

@@ -181,2 +181,15 @@ var emitter = (0, _mitt2.default)();

},
updateChatProperties: function updateChatProperties(chat, properties) {
return sendRequestAction(requestActions.sendRequest('update_chat_properties', {
chat_id: chat,
properties: properties
}));
},
updateChatThreadProperties: function updateChatThreadProperties(chat, thread, properties) {
return sendRequestAction(requestActions.sendRequest('update_chat_thread_properties', {
chat_id: chat,
thread_id: thread,
properties: properties
}));
},
updateCustomer: function updateCustomer(properties) {

@@ -183,0 +196,0 @@ return sendRequestAction(requestActions.sendRequest('update_customer', { customer: properties }));

@@ -237,5 +237,3 @@ 'use strict';

order = _ref2.order,
_ref2$last_event_per_ = _ref2.last_event_per_type,
lastThread = _ref2$last_event_per_.thread_id,
lastEvents = _ref2$last_event_per_.events,
lastEventsPerType = _ref2.last_event_per_type,
users = _ref2.users;

@@ -254,14 +252,33 @@

if (!(0, _utils.isEmpty)(lastEvents)) {
chatSummary.lastEvent = parseEvent(lastThread, (0, _utils.last)((0, _utils.numericSortBy)('order', Object.keys(lastEvents).map(function (eventType) {
return lastEvents[eventType];
}))));
if (!lastEventsPerType) {
return chatSummary;
}
chatSummary.lastEventsPerType = (0, _utils.mapValues)(function (_ref4) {
var thread = _ref4.thread_id,
event = _ref4.event;
return parseEvent(thread, event);
}, lastEventsPerType);
var lastEventsArray = Object.keys(lastEventsPerType).map(function (eventType) {
return lastEventsPerType[eventType];
});
var lastEvent = (0, _utils.last)(lastEventsArray.sort(function (eventA, eventB) {
if (eventA.thread_id === eventB.thread_id) {
return eventA.event.order - eventB.event.order;
}
return eventA.thread_order - eventB.thread_order;
}));
if (lastEvent) {
chatSummary.lastEvent = (0, _utils.cloneDeep)(chatSummary.lastEventsPerType[lastEvent.event.type]);
}
return chatSummary;
});
return {
chatsSummary: (0, _utils.numericSortBy)(function (_ref4) {
var lastEvent = _ref4.lastEvent,
order = _ref4.order;
chatsSummary: (0, _utils.numericSortBy)(function (_ref5) {
var lastEvent = _ref5.lastEvent,
order = _ref5.order;
return -1 * (lastEvent !== undefined ? lastEvent.timestamp : order);

@@ -271,4 +288,4 @@ }, chatsSummary),

users: (0, _utils.flatMap)(function (_ref5) {
var users = _ref5.users;
users: (0, _utils.flatMap)(function (_ref6) {
var users = _ref6.users;
return users.map(parseUser);

@@ -297,4 +314,4 @@ }, payload.chats_summary)

id: id,
users: users.map(function (_ref6) {
var userId = _ref6.id;
users: users.map(function (_ref7) {
var userId = _ref7.id;
return userId;

@@ -301,0 +318,0 @@ }),

@@ -34,2 +34,4 @@ 'use strict';

var isArray = exports.isArray = Array.isArray;
var isEmpty = exports.isEmpty = function isEmpty(obj) {

@@ -58,3 +60,3 @@ return Object.keys(obj).length === 0;

};
return arr.sort(function (elementA, elementB) {
return [].concat(arr).sort(function (elementA, elementB) {
return mapper(elementA) - mapper(elementB);

@@ -71,2 +73,14 @@ });

var cloneDeep = exports.cloneDeep = function cloneDeep(value) {
if (isArray(value)) {
return value.map(cloneDeep);
}
if (isObject(value)) {
return mapValues(cloneDeep, value);
}
return value;
};
var noop = exports.noop = function noop() {};

@@ -87,4 +101,5 @@

var splitRightWhenAccum = exports.splitRightWhenAccum = function splitRightWhenAccum(fn, acc, arr) {
var splitRightWhenAccum = exports.splitRightWhenAccum = function splitRightWhenAccum(fn, initialAcc, arr) {
var result = false;
var acc = initialAcc;

@@ -91,0 +106,0 @@ for (var index = arr.length; index > 0; index--) {

{
"name": "@livechat/chat.io-customer-sdk",
"version": "0.7.0",
"version": "0.8.0-0",
"description": "SDK for connecting to chat.io as a customer",

@@ -16,3 +16,3 @@ "contributors": [

"dependencies": {
"@livechat/chat.io-customer-auth": "^0.2.1",
"@livechat/chat.io-customer-auth": "^0.3.0",
"@livechat/file-upload": "^0.1.0",

@@ -19,0 +19,0 @@ "@livechat/side-effects-middleware": "^0.1.0",

@@ -996,3 +996,3 @@

* it's possible now to create 2 independent instances of the SDK
* `file` events having `url` property
* `file` events with `url` property

@@ -1003,3 +1003,4 @@ #### [v0.6.0] - 2017-11-23

* `customId` is added only if it was explicitly passed in as part of an event
* `customId` is added only if it has been explicitly passed in as part of an
event
* `customId` is not reused as request's id anymore

@@ -1006,0 +1007,0 @@ * made it impossible to send 2 requests with identical ids until a response

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc