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

help-fem

Package Overview
Dependencies
Maintainers
3
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

help-fem - npm Package Compare versions

Comparing version 0.1.21 to 0.1.22

558

help-fem.js

@@ -24,2 +24,10 @@ ;(function() {

function defaultHandler(type, error, response) {
if (error) {
throw error;
}
console.log('Successful ' + type + ': ' + JSON.stringify(response));
}
// ## HelpFem.Client

@@ -206,60 +214,20 @@ // ### HelpFem.Client.constructor

// Default `server session event start` callback.
_sessionStart: function(error, response) {
if (error) {
throw error;
}
console.log('Successful session start: ' + JSON.stringify(response));
},
_sessionStart: _.partial(defaultHandler, 'session start'),
// Default `server session event end` callback.
_sessionEnd: function(error, response) {
if (error) {
throw error;
}
console.log('Successful session end: ' + JSON.stringify(response));
},
_sessionEnd: _.partial(defaultHandler, 'session end'),
// Default `server session event login` callback.
_sessionLogin: function(error, response) {
if (error) {
throw error;
}
defaultHandler('session login', error, response);
// Update with new Client ID.
this.info.clientId = response.data.clientId;
console.log('Successful session login: ' + JSON.stringify(response));
},
// Default `server session event logout` callback.
_sessionLogout: function(error, response) {
if (error) {
throw error;
}
console.log('Successful session logout: ' + JSON.stringify(response));
},
_sessionLogout: _.partial(defaultHandler, 'session logout'),
// Default `server chat event start` callback.
_chatStart: function(error, response) {
if (error) {
throw error;
}
console.log('Successful chat start: ' + JSON.stringify(response));
},
_chatStart: _.partial(defaultHandler, 'chat start'),
// Default `server chat event join` callback.
_chatJoin: function(error, response) {
if (error) {
throw error;
}
console.log('Successful chat join: ' + JSON.stringify(response));
},
_chatJoin: _.partial(defaultHandler, 'chat join'),
// Default `server chat event leave` callback.
_chatLeave: function(error, response) {
if (error) {
throw error;
}
console.log('Successful chat leave: ' + JSON.stringify(response));
},
_chatLeave: _.partial(defaultHandler, 'chat leave'),
// ### Built-In Actions

@@ -274,173 +242,123 @@ // #### Initialization

start: function(callback) {
var payload = {
meta: this.parent.generateMeta({
type: 'start'
}),
data: null
};
this.parent.emit('client session event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitSessionEvent,
{type: 'start'},
null,
callback
);
},
// End a session.
end: function(callback) {
var payload = {
meta: this.parent.generateMeta({
type: 'end'
}),
data: null
};
this.parent.emit('client session event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitSessionEvent,
{type: 'end'},
null,
callback
);
},
// Login to a session.
login: function(data, callback) {
var payload = {
meta: this.parent.generateMeta({
type: 'login'
}),
data: data
};
this.parent.emit('client session event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitSessionEvent,
{type: 'login'},
data,
callback
);
},
// Logout of a session.
logout: function(data, callback) {
var payload = {
meta: this.parent.generateMeta({
type: 'logout'
}),
data: data
};
this.parent.emit('client session event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitSessionEvent,
{type: 'logout'},
data,
callback
);
},
initializeState: function(data) {
var payload = {
meta: this.parent.generateMeta({type: 'initialize state'}),
data: data || {}
};
this.parent.emit('client session event', payload);
this.parent._doSimpleEmit(
this.parent._emitSessionEvent,
{type: 'initialize state'},
data
);
},
// Send a chat status update.
chatStatus: function(data) {
var payload = {
meta: this.parent.generateMeta({
type: 'chat status'
}),
data: data
};
this.parent.emit('client session event', payload);
this.parent._doSimpleEmit(
this.parent._emitSessionEvent,
{type: 'chat status'},
data
);
},
// Set rep availability.
updateAvailability: function(availability) {
var payload = {
meta: this.parent.generateMeta({type: 'update availability'}),
data: {availability: availability}
};
this.parent.emit('client session event', payload);
this.parent._doSimpleEmit(
this.parent._emitSessionEvent,
{type: 'update availability'},
{availability: availability}
);
},
suggestion: function(data) {
var payload = {
meta: this.parent.generateMeta({type: 'suggestion'}),
data: data
};
this.parent.emit('client session event', payload);
this.parent._doSimpleEmit(
this.parent._emitSessionEvent,
{type: 'suggestion'},
data
);
},
postchat: function(data) {
var payload = {
meta: this.parent.generateMeta({type: 'postchat'}),
data: data
};
this.parent.emit('client session event', payload);
this.parent._doSimpleEmit(
this.parent._emitSessionEvent,
{type: 'postchat'},
data
);
},
getOrganizationSettings: function(data, callback) {
var _data = {};
_.extend(_data, this.parent.info, data);
var payload = {
meta: this.parent.generateMeta({
type: 'get organization settings'
}),
data: _data
};
this.parent.emit('client session event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitSessionEvent,
{type: 'get organization settings'},
data,
callback
);
},
updateOrganizationSettings: function(data, callback) {
var _data = {};
_.extend(_data, this.parent.info, data);
var payload = {
meta: this.parent.generateMeta({
type: 'update organization settings'
}),
data: _data
};
this.parent.emit('client session event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitSessionEvent,
{type: 'update organization settings'},
data,
callback
);
},
getAnalyticsSession: function(data, callback) {
var _data = {};
_.extend(_data, this.parent.info, data);
var payload = {
meta: this.parent.generateMeta({
type: 'get analytics session'
}),
data: _data
};
this.parent.emit('client session event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitSessionEvent,
{type: 'get analytics session'},
data,
callback
);
},
sendOfflineMessage: function(data, callback) {
var _data = {
uri: '/sendEmail',
method: 'POST',
body: data
};
_.extend(_data, this.parent.info);
var payload = {
meta: this.parent.generateMeta({
type: 'sendOfflineMessage'
}),
data: _data
};
this.parent.emit('client session event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doHyperJSONEmit(
this.parent._emitSessionEvent,
{type: 'sendOfflineMessage'},
{uri: '/sendEmail', method: 'POST'},
data,
callback
);
},
getHistory: function(data, callback) {
this.parent._doHyperJSONEmit(
this.parent._emitSessionEvent,
{type: 'chatHistory'},
{uri: '/listChats', method: 'GET'},
data,
callback
);
},
getEventsForChat: function(data, callback) {
this.parent._doHyperJSONEmit(
this.parent._emitSessionEvent,
{type: 'chatHistory'},
{uri: '/eventsForChat', method: 'GET'},
data,
callback
);
}

@@ -452,196 +370,97 @@ },

start: function(data, callback) {
// Add any Client information to the data. Override with any explicitly
// set properties.
var _data = {};
_.extend(_data, this.parent.info, data);
var payload = {
meta: this.parent.generateMeta({
type: 'start'
}),
data: _data
};
this.parent.emit('client chat event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitChatEvent,
{type: 'start'},
data,
callback
);
},
// End a chat.
end: function(data, callback) {
// Add any Client information to the data. Override with any explicitly
// set properties.
var _data = {};
_.extend(_data, this.parent.info, data);
var payload = {
meta: this.parent.generateMeta({
type: 'end'
}),
data: _data
};
this.parent.emit('client chat event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitChatEvent,
{type: 'end'},
data,
callback
);
},
// Join a chat room.
join: function(data, callback) {
var payload = {
meta: this.parent.generateMeta({
type: 'join'
}),
data: data
};
this.parent.emit('client chat event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitChatEvent,
{type: 'join'},
data,
callback
);
},
// Leave a chat.
leave: function(data, callback) {
var payload = {
meta: this.parent.generateMeta({
type: 'leave'
}),
data: data
};
this.parent.emit('client chat event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitChatEvent,
{type: 'leave'},
data,
callback
);
},
// Send a chat message.
message: function(data, callback) {
var payload = {
meta: this.parent.generateMeta({
type: 'message'
}),
data: data
};
this.parent.emit('client chat event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitChatEvent,
{type: 'message'},
data,
callback
);
},
// Request the latest chat cache.
cache: function(data, callback) {
var payload = {
meta: this.parent.generateMeta({
type: 'cache'
}),
data: data
};
this.parent.emit('client chat event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitChatEvent,
{type: 'cache'},
data,
callback
);
},
// Request to transfer chat.
requestTransfer: function(data, callback) {
// Add any Client information to the data. Override with any explicitly
// set properties.
var _data = {};
_.extend(_data, this.parent.info, data);
var payload = {
meta: this.parent.generateMeta({
type: 'transfer request'
}),
data: _data
};
this.parent.emit('client chat event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitChatEvent,
{type: 'transfer request'},
data,
callback
);
},
// Respond to transfer chat.
respondToTransfer: function(data, callback) {
// Add any Client information to the data. Override with any explicitly
// set properties.
var _data = {};
_.extend(_data, this.parent.info, data);
var payload = {
meta: this.parent.generateMeta({
type: 'transfer response'
}),
data: _data
};
this.parent.emit('client chat event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitChatEvent,
{type: 'transfer response'},
data,
callback
);
},
// Request message cache.
getCacheMessages: function(data, callback) {
// Add any Client information to the data. Override with any explicitly
// set properties.
var _data = {};
_.extend(_data, this.parent.info, data);
var payload = {
meta: this.parent.generateMeta({
type: 'get cache messages'
}),
data: _data
};
this.parent.emit('client chat event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitChatEvent,
{type: 'get cache messages'},
data,
callback
);
},
// Request metadata cache.
getCacheMetadata: function(data, callback) {
// Add any Client information to the data. Override with any explicitly
// set properties.
var _data = {};
_.extend(_data, this.parent.info, data);
var payload = {
meta: this.parent.generateMeta({
type: 'get cache metadata'
}),
data: _data
};
this.parent.emit('client chat event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitChatEvent,
{type: 'get cache metadata'},
data,
callback
);
},
requestRepAvailability: function(data, callback) {
var _data = {};
_.extend(_data, this.parent.info, data);
var payload = {
meta: this.parent.generateMeta({
type: 'get rep availability'
}),
data: _data
};
this.parent.emit('client session event', payload);
if (typeof callback === 'function') {
this.parent.replyCallbacks[payload.meta.id] = callback;
}
this.parent._doSimpleEmit(
this.parent._emitSessionEvent,
{type: 'get rep availability'},
data,
callback
);
}

@@ -669,2 +488,33 @@ },

return meta;
},
_doSimpleEmit: function(emitter, metaProperties, data, callback) {
if(typeof data === 'function' && typeof callback === 'undefined') {
callback = data;
data = {};
}
var _data = _.extend({}, data, this.info);
emitter.call(this, metaProperties, _data, callback);
},
_doHyperJSONEmit: function(emitter, metaProperties, hyperJSON, data, callback) {
if(typeof data === 'function' && typeof callback === 'undefined') {
callback = data;
data = {};
}
var _data = _.extend({}, hyperJSON, {body: data}, this.info);
emitter.call(this, metaProperties, _data, callback);
},
_emitChatEvent: function(metaProperties, data, callback) {
return this._emitEvent('client chat event', metaProperties, data, callback);
},
_emitSessionEvent: function(metaProperties, data, callback) {
return this._emitEvent('client session event', metaProperties, data, callback);
},
_emitEvent: function(event, metaProperties, data, callback) {
var payload = {meta: this.generateMeta(metaProperties), data: data};
this.emit(event, payload);
if (typeof callback === 'function') {
this.replyCallbacks[payload.meta.id] = callback;
}
}

@@ -671,0 +521,0 @@ });

{
"name": "help-fem",
"version": "0.1.21",
"version": "0.1.22",
"description": "A Browserify/Node.js client module for the Help.com team's FEM.",

@@ -5,0 +5,0 @@ "main": "help-fem.js",

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