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

@lighthouse/sdk

Package Overview
Dependencies
Maintainers
3
Versions
860
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lighthouse/sdk - npm Package Compare versions

Comparing version 8.0.0-map-beta-1 to 8.0.0-rc-1

37

build/crud/selectors/index.js

@@ -52,6 +52,9 @@ 'use strict';

cache: cachedSelector,
list: function list() {
var listId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_LIST_ID;
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return (0, _reselect.createSelector)(cachedSelector, listSelector, function (cache, list) {
list: (0, _reselect.createSelector)(cachedSelector, listSelector,
// NOTE opts for sorting are unsupported until we figure out a good way to memoize them
function (cache, list) {
return (0, _memoize2.default)(function () {
var listId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_LIST_ID;
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var listIds = (0, _get2.default)(list, listId + '.items');

@@ -97,27 +100,13 @@ var sort = opts.sort;

}
return sortedResources;
});
},
state: function state() {
var listId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_LIST_ID;
return (0, _reselect.createSelector)(listSelector, function (list) {
}),
state: (0, _reselect.createSelector)(listSelector, function (list) {
return function () {
var listId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_LIST_ID;
return (0, _get2.default)(list, listId + '.state');
});
},
};
}),
current: (0, _reselect.createSelector)(cachedSelector, currentSelector, function (cache, current) {
return getCachedResource(cache, current.id);
}),
// NOTE you need to be careful when using this selector. If you have a
// component that has other state props that cause a re-render, then this
// won't return immutable data you can just compare with `===` in
// `componentShouldUpdate`. `filter` will always return a new array so be
// aware of that (although the objects contained are references to the
// immutable data). Keep all this in mind regarding performance issues as
// react will treat the prop received from this selector as new data and
// re-render, which can be expensive
filter: (0, _memoize2.default)(function (filterObj) {
return (0, _reselect.createSelector)(cachedSelector, function (cache) {
return (0, _filter2.default)(cache, { entity: filterObj });
});
})

@@ -124,0 +113,0 @@ };

@@ -25,5 +25,5 @@ 'use strict';

var _promiseRetry = require('promise-retry');
var _bluebirdRetry = require('bluebird-retry');
var _promiseRetry2 = _interopRequireDefault(_promiseRetry);
var _bluebirdRetry2 = _interopRequireDefault(_bluebirdRetry);

@@ -72,3 +72,3 @@ var _fetchPonyfill = require('fetch-ponyfill');

// NOTE wait this amount of time before invalidating request
var TIMEOUT_MS = 20000; // 20s
var TIMEOUT_MS = 6000; // 6s

@@ -88,3 +88,3 @@ // Debounce are connection status responses to avoid hammering our

var fatalErrorResponse = {
message: 'FatalError'
message: 'FatalHttpError'
};

@@ -234,11 +234,15 @@

// ~32s max retry time
// ~1.5s max retry time
var retryOpts = {
retries: 7,
factor: 2,
minTimeout: 250
max_tries: 2,
backoff: 2,
interval: 500
};
var attempts = 0;
// NOTE - retry promise pattern
return _bluebird2.default.resolve((0, _promiseRetry2.default)(function (retry, number) {
// return Promise.resolve(promiseRetry((retry, number) => {
return (0, _bluebirdRetry2.default)(function makeRequest() {
++attempts;
return callApi(endpoint, fetchOpts).catch(function () {

@@ -250,10 +254,9 @@ // Notify reducer of error with retry details

retrying: {
attempt: 3
attempt: attempts
}
};
next(actionWith(actionObj));
// NOTE it's important this is called after the action is fired
retry();
return _bluebird2.default.reject(new Error(fatalErrorResponse.message));
});
}, retryOpts)).then(function (response) {
}, retryOpts).then(function (response) {
// Error response

@@ -356,3 +359,3 @@ if (response.error) {

return _bluebird2.default.reject(fatalErrorResponse);
return _bluebird2.default.reject(new Error(fatalErrorResponse.message));
});

@@ -359,0 +362,0 @@

@@ -89,14 +89,12 @@ 'use strict';

// application Id and then fire the registration request for that
return deregister().then(function () {
return deregister().catch(function (error) {
throw new Error('MessagesDeregistrationError');
}).then(function () {
return next(action);
}).then(function (result) {
return (
// NOTE it's important we resovle the result of the action we're catching
// and not the registration result
register().then(function () {
return _bluebird2.default.resolve(result);
})
);
}).catch(function (error) {
if (console) console.error(error);
return register().then(function () {
return _bluebird2.default.resolve(result);
}).catch(function (error) {
throw new Error('MessagesRegistrationError');
});
});

@@ -103,0 +101,0 @@ };

@@ -85,9 +85,10 @@ 'use strict';

var filterListByType = function filterListByType(options) {
return (0, _reselect.createSelector)([crudSelectors.list(options.listId)], function (activities) {
return (0, _orderBy2.default)((0, _filter2.default)(activities, function (activity) {
var filterListByType = (0, _reselect.createSelector)([crudSelectors.list], function (activities) {
return function (options) {
var listActivities = activities(options.listId);
return (0, _orderBy2.default)((0, _filter2.default)(listActivities, function (activity) {
return options.type ? activity.entity.type === options.type : true;
}), ['entity.timestamp'], ['desc']);
});
};
};
});

@@ -94,0 +95,0 @@ var selectors = exports.selectors = (0, _assign2.default)({}, crudSelectors, {

@@ -95,4 +95,4 @@ 'use strict';

var crudSelectors = _crud2.default.selectors(resource);
var getUserFullName = (0, _memoize2.default)(function (userId) {
return (0, _reselect.createSelector)(crudSelectors.cache, function (cache) {
var getUserFullName = (0, _reselect.createSelector)(crudSelectors.cache, function (cache) {
return (0, _memoize2.default)(function (userId) {
var applicationUser = (0, _find2.default)(cache, ['entity.user._id', userId]);

@@ -111,9 +111,8 @@

});
var onlineCount = function onlineCount() {
return (0, _reselect.createSelector)(crudSelectors.cache, function (cache) {
var onlineUsers = (0, _filter2.default)(cache, 'entity.user.online');
return onlineUsers.length;
});
};
var onlineCount = (0, _reselect.createSelector)(crudSelectors.cache, function (cache) {
var onlineUsers = (0, _filter2.default)(cache, 'entity.user.online');
return onlineUsers.length;
});
var selectors = exports.selectors = _extends({}, crudSelectors, {

@@ -120,0 +119,0 @@ getUserFullName: getUserFullName,

@@ -59,3 +59,2 @@ 'use strict';

activity: require('./activity'),
areas: require('./areas'),
userApplications: require('./user-applications'),

@@ -100,3 +99,2 @@ user: require('./user'),

activity: (0, _reduxRecycle2.default)(modules.activity.reducer, _constants.defaultRecycleActions),
areas: (0, _reduxRecycle2.default)(modules.areas.reducer, _constants.defaultRecycleActions),
applicationUsers: (0, _reduxRecycle2.default)(modules.applicationUsers.reducer, _constants.defaultRecycleActions),

@@ -179,5 +177,3 @@ roles: (0, _reduxRecycle2.default)(modules.roles.reducer, _constants.defaultRecycleActions),

var wrappedCustomSelectors = (0, _transform2.default)(customSelectors, function (accum, selectorFn, selectorKey) {
accum[selectorKey] = function () {
return selectorFn.apply(undefined, arguments)(state);
};
accum[selectorKey] = selectorFn(state);
}, {});

@@ -189,10 +185,7 @@ return _extends({

list: function list(opts) {
return _selectors.list(listId, opts)(state);
return _selectors.list(state)(listId, opts);
},
state: _selectors.state(listId)(state),
state: _selectors.state(state)(listId),
current: function current() {
return _selectors.current(state);
},
filter: function filter(filterObj) {
return _selectors.filter(filterObj)(state);
}

@@ -199,0 +192,0 @@ }, wrappedCustomSelectors);

@@ -6,8 +6,15 @@ 'use strict';

});
exports.RESET = exports.CLEAR_TIMELINE_EXCEPTIONS = exports.ADD_TIMELINE_EXCEPTIONS = exports.SET_TIMELINE_PROPS = exports.REMOVE_HEATMAP = exports.SET_HEATMAP = exports.CLEAR_MARKERS = exports.REMOVE_MARKER = exports.SET_MARKER = exports.SET_DATES = exports.SET_LOADING = exports.SET_MODE = exports.SET_PROPERTIES = undefined;
exports.RESET = exports.CLEAR_TIMELINE_EXCEPTIONS = exports.ADD_TIMELINE_EXCEPTIONS = exports.SET_TIMELINE_PROPS = exports.REMOVE_HEATMAP = exports.SET_HEATMAP = exports.CLEAR_MARKERS = exports.REMOVE_MARKER = exports.SET_MARKER = exports.CLEAR_ASSETS = exports.REMOVE_ASSETS = exports.REMOVE_ASSET = exports.SET_ASSETS = exports.SET_ASSET = exports.CLEAR_DEVICES = exports.REMOVE_DEVICES = exports.REMOVE_DEVICE = exports.SET_DEVICES = exports.SET_DEVICE = exports.SET_DATES = exports.SET_LOADING = exports.SET_MODE = exports.SET_LOCATION = undefined;
exports.reducer = reducer;
exports.setProperties = setProperties;
exports.setLocation = setLocation;
exports.setMode = setMode;
exports.setLoading = setLoading;
exports.setDates = setDates;
exports.setDevice = setDevice;
exports.setDevices = setDevices;
exports.removeDevices = removeDevices;
exports.clearDevices = clearDevices;
exports.setAssets = setAssets;
exports.removeAssets = removeAssets;
exports.clearAssets = clearAssets;
exports.setMarker = setMarker;

@@ -45,11 +52,26 @@ exports.removeMarker = removeMarker;

var SET_PROPERTIES = exports.SET_PROPERTIES = 'lighthouse/maps/SET_PROPERTIES'; /*
* Maps Module
* ===========
* Note: Example state at bottom of file
*/
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /*
* Maps Module
* ===========
* Note: Example state at bottom of file
*/
// SET_LOCATION can be used for setting/updating the location and it's
// attributes, such as the currently selected floor
var SET_LOCATION = exports.SET_LOCATION = 'lighthouse/maps/SET_LOCATION';
var SET_MODE = exports.SET_MODE = 'lighthouse/maps/SET_MODE';
var SET_LOADING = exports.SET_LOADING = 'lighthouse/maps/SET_LOADING';
var SET_DATES = exports.SET_DATES = 'lighthouse/maps/SET_DATES';
var SET_DEVICE = exports.SET_DEVICE = 'lighthouse/maps/SET_DEVICE';
var SET_DEVICES = exports.SET_DEVICES = 'lighthouse/maps/SET_DEVICES';
var REMOVE_DEVICE = exports.REMOVE_DEVICE = 'lighthouse/maps/REMOVE_DEVICE';
var REMOVE_DEVICES = exports.REMOVE_DEVICES = 'lighthouse/maps/REMOVE_DEVICES';
var CLEAR_DEVICES = exports.CLEAR_DEVICES = 'lighthouse/maps/CLEAR_DEVICES';
var SET_ASSET = exports.SET_ASSET = 'lighthouse/maps/SET_ASSET';
var SET_ASSETS = exports.SET_ASSETS = 'lighthouse/maps/SET_ASSETS';
var REMOVE_ASSET = exports.REMOVE_ASSET = 'lighthouse/maps/REMOVE_ASSET';
var REMOVE_ASSETS = exports.REMOVE_ASSETS = 'lighthouse/maps/REMOVE_ASSETS';
var CLEAR_ASSETS = exports.CLEAR_ASSETS = 'lighthouse/maps/CLEAR_ASSETS';
var SET_MARKER = exports.SET_MARKER = 'lighthouse/maps/SET_MARKER';

@@ -67,2 +89,4 @@ var REMOVE_MARKER = exports.REMOVE_MARKER = 'lighthouse/maps/REMOVE_MARKER';

// The properties to pick for map objects (assets, devices)
var mapObjectProps = ['icon', 'zoneId', 'popup', 'geoJSON'];
var validDateProps = ['from', 'to', 'editing'];

@@ -86,4 +110,11 @@ var validMarkerProps = ['type', 'icon', 'data', 'geoJSON'];

switch (action.type) {
case SET_PROPERTIES:
return state.merge({ properties: action.options }, { deep: true });
case SET_LOCATION:
var end = new Date();
end.setHours(23, 59, 59, 999);
state = state.set('current', action.locationId);
state = state.merge(_defineProperty({}, action.locationId, (0, _assign2.default)({}, {
timeline: { isLive: true, end: end }
}, state[action.locationId], action.options)));
return state;
case SET_MODE:

@@ -112,49 +143,42 @@ if (validModes.indexOf(action.mode) === -1) {

});
// case SET_MARKER:
// let newMarkerProps = pick(action.props, validMarkerProps)
// let currentMarkerProps = get(state, `${action.locationId}.markers.${action.markerId}`) || Immutable({})
// return state.setIn([
// action.locationId,
// 'markers',
// action.markerId
// ], currentMarkerProps.merge(newMarkerProps, { deep: true }))
// case REMOVE_MARKER:
// return state.setIn(
// [action.locationId, 'markers'],
// omit(state[action.locationId].markers, action.markerId)
// )
// case CLEAR_MARKERS:
// return state.setIn(
// [action.locationId, 'markers'],
// blankObject
// )
// case SET_HEATMAP:
// return state.setIn([
// action.locationId,
// 'heatmap'
// ], { description: action.description, points: action.points })
// case REMOVE_HEATMAP:
// return state.setIn([
// action.locationId,
// 'heatmap'
// ], null)
// case SET_TIMELINE_PROPS:
// existingTimelineState = get(state, `${action.locationId}.timeline`) || Immutable({})
// return state.setIn([
// action.locationId,
// 'timeline'
// ], existingTimelineState.merge(pick(action.props, validTimelineProps)))
// case ADD_TIMELINE_EXCEPTIONS:
// existingTimelineState = get(state, `${action.locationId}.timeline.exceptions`) || Immutable([])
// return state.setIn([
// action.locationId,
// 'timeline',
// 'exceptions'
// ], existingTimelineState.concat(action.exceptions))
// case CLEAR_TIMELINE_EXCEPTIONS:
// return state.setIn([
// action.locationId,
// 'timeline',
// 'exceptions'
// ], [])
case SET_DEVICE:
return state.setIn([action.locationId, 'devices', action.deviceId], (0, _pick2.default)(action.data, mapObjectProps));
case SET_DEVICES:
action.data.forEach(function (item) {
state = state.setIn([action.locationId, 'devices', item.id], (0, _pick2.default)(item, mapObjectProps));
});
return state;
case REMOVE_DEVICES:
return state.setIn([action.locationId, 'devices'], _omit2.default.apply(undefined, [state[action.locationId].devices].concat(_toConsumableArray(action.deviceIds))));
case CLEAR_DEVICES:
return state.setIn([action.locationId, 'devices'], blankObject);
case SET_ASSETS:
action.data.forEach(function (item) {
state = state.setIn([action.locationId, 'assets', item.id], (0, _pick2.default)(item, mapObjectProps));
});
return state;
case REMOVE_ASSETS:
return state.setIn([action.locationId, 'assets'], _omit2.default.apply(undefined, [state[action.locationId].assets].concat(_toConsumableArray(action.assetIds))));
case CLEAR_ASSETS:
return state.setIn([action.locationId, 'assets'], blankObject);
case SET_MARKER:
var newMarkerProps = (0, _pick2.default)(action.props, validMarkerProps);
var currentMarkerProps = (0, _get2.default)(state, action.locationId + '.markers.' + action.markerId) || (0, _seamlessImmutable2.default)({});
return state.setIn([action.locationId, 'markers', action.markerId], currentMarkerProps.merge(newMarkerProps, { deep: true }));
case REMOVE_MARKER:
return state.setIn([action.locationId, 'markers'], (0, _omit2.default)(state[action.locationId].markers, action.markerId));
case CLEAR_MARKERS:
return state.setIn([action.locationId, 'markers'], blankObject);
case SET_HEATMAP:
return state.setIn([action.locationId, 'heatmap'], { description: action.description, points: action.points });
case REMOVE_HEATMAP:
return state.setIn([action.locationId, 'heatmap'], null);
case SET_TIMELINE_PROPS:
existingTimelineState = (0, _get2.default)(state, action.locationId + '.timeline') || (0, _seamlessImmutable2.default)({});
return state.setIn([action.locationId, 'timeline'], existingTimelineState.merge((0, _pick2.default)(action.props, validTimelineProps)));
case ADD_TIMELINE_EXCEPTIONS:
existingTimelineState = (0, _get2.default)(state, action.locationId + '.timeline.exceptions') || (0, _seamlessImmutable2.default)([]);
return state.setIn([action.locationId, 'timeline', 'exceptions'], existingTimelineState.concat(action.exceptions));
case CLEAR_TIMELINE_EXCEPTIONS:
return state.setIn([action.locationId, 'timeline', 'exceptions'], []);
case RESET:

@@ -167,4 +191,4 @@ return (0, _seamlessImmutable2.default)({});

function setProperties(options) {
return { type: SET_PROPERTIES, options: options };
function setLocation(locationId, options) {
return { type: SET_LOCATION, locationId: locationId, options: options };
}

@@ -184,2 +208,29 @@

function setDevice(locationId, deviceId, data) {
return { type: SET_DEVICE, locationId: locationId, deviceId: deviceId, data: data };
}
function setDevices(locationId, data) {
return { type: SET_DEVICES, locationId: locationId, data: data };
}
function removeDevices(locationId, deviceIds) {
return { type: REMOVE_DEVICES, locationId: locationId, deviceIds: deviceIds };
}
function clearDevices(locationId) {
return { type: CLEAR_DEVICES, locationId: locationId };
}
function setAssets(locationId, data) {
return { type: SET_ASSETS, locationId: locationId, data: data };
}
function removeAssets(locationId, assetIds) {
return { type: REMOVE_ASSETS, locationId: locationId, assetIds: assetIds };
}
function clearAssets(locationId) {
return { type: CLEAR_ASSETS, locationId: locationId };
}
function setMarker(locationId, markerId, props) {

@@ -225,4 +276,4 @@ return { type: SET_MARKER, locationId: locationId, markerId: markerId, props: props };

* maps: {
* current: {locationId},
* mode: 'live', // heat
* loading: false,
* dates: {

@@ -232,4 +283,59 @@ * from: Date(),

* },
* filters: {
* zones: true,
* devices: false
* },
* [locationId]: {
* floor: 'floor-id', // floors available from location cache
* // possible add a zones array, but we don't necessarily need
* // this as these are stored elsewhere in the state. The
* // question is whether we benefit from storing them here too
* zones: [{}],
* // markers are generic markers that can be used in arbitary
* // ways on the map. They hold data that should be interpreted
* // by UI logic to display/edit map data in whatever way
* markers: {
* [id]: {
* type: 'zone',
* icon: '',
* geoJSON: {},
* data: {}, // arbitary data associated with marker
* }
* },
* devices: {
* [deviceId]: {
* icon: 'person', // or wifi-hub
* // zoneId used to determine whether to show/hide the asset
* // based on the selected floor (component will handle that)
* zoneId: 'zoneId123',
* popup: 'Joe Bloggs', // or asset name 'Defibulator'
* geoJSON: {}
* }
* }],
* assets: {
* [assetId]: {
* icon: 'defibulator', // or patient
* // zoneId used to determine whether to show/hide the asset
* // based on the selected floor (component will handle that)
* zoneId: 'zoneId123',
* popup: 'Joe Bloggs', // or asset name 'Defibulator'
* geoJSON: {}
* }
* }],
* // For heat maps we need to think about handling differnt types
* // of heat maps. We could store each one in separate objects or
* // just hold a reference to the current type of heat map
* heatmap: {
* description: 'visits', // or servicing
* points: []
* },
* timeline: {
* start: Date(),
* end: Date(),
* current: Date(),
* exceptions: [{ start, end, weight }],
* }
* }
* }
* }
*/

@@ -69,7 +69,4 @@ 'use strict';

// NOTE we memoize the factory function for the selector to ensure it is not
// rebuilt on repeat calls. This just ensures the same selector is used when the
// same `roomId` is provided
var filterByRoom = (0, _memoize2.default)(function (roomId) {
return (0, _reselect.createSelector)(crudSelectors.cache, function (cache) {
var filterByRoom = (0, _reselect.createSelector)(crudSelectors.cache, function (cache) {
return (0, _memoize2.default)(function (roomId) {
return (0, _filter2.default)(cache, ['entity.room', roomId]);

@@ -76,0 +73,0 @@ });

@@ -94,16 +94,16 @@ 'use strict';

// create a new selector for every call
var hasUnread = (0, _memoize2.default)(function (roomId, speakerId) {
return (0, _reselect.createSelector)(crudSelectors.cache, function (cache) {
var hasUnread = (0, _reselect.createSelector)(crudSelectors.cache, function (cache) {
return (0, _memoize2.default)(function (roomId, speakerId) {
var room = cache[roomId].entity;
return speakerHasUnreadInRoom(room, speakerId);
}, function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return args.join('-');
});
}, function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return args.join('-');
});
var unreadCountSelector = (0, _reselect.createSelector)(crudSelectors.cache, _userApplications.speakerIdSelector, function (cache, speakerId) {
var unreadCount = (0, _reselect.createSelector)(crudSelectors.cache, _userApplications.speakerIdSelector, function (cache, speakerId) {
var count = (0, _reduce2.default)(cache, function (accum, room) {

@@ -116,9 +116,5 @@ var hasUnreadInRoom = speakerHasUnreadInRoom(room.entity, speakerId);

var unreadCount = function unreadCount() {
return unreadCountSelector;
};
// NOTE speakerIdSelector is handled within the userApplications module, because
// that's where the speakers Id is stored for the appropriate application
var speakerRoomsSelector = (0, _reselect.createSelector)(crudSelectors.cache, _userApplications.speakerIdSelector, function (cache, speakerId) {
var speakerRooms = (0, _reselect.createSelector)(crudSelectors.cache, _userApplications.speakerIdSelector, function (cache, speakerId) {
return (0, _filter2.default)(cache, {

@@ -133,6 +129,2 @@ entity: {

var speakerRooms = function speakerRooms() {
return speakerRoomsSelector;
};
var selectors = exports.selectors = _extends({}, crudSelectors, {

@@ -139,0 +131,0 @@ hasUnread: hasUnread,

@@ -78,4 +78,4 @@ 'use strict';

var aliases = (0, _memoize2.default)(function (speakerIdOrIds) {
return (0, _reselect.createSelector)(crudSelectors.cache, function (cache) {
var aliases = (0, _reselect.createSelector)(crudSelectors.cache, function (cache) {
return (0, _memoize2.default)(function (speakerIdOrIds) {
var filteredSpeakers = (0, _pick2.default)(cache, speakerIdOrIds);

@@ -85,5 +85,5 @@ return (0, _map2.default)(filteredSpeakers, function (speaker) {

});
}, function (speakerIdOrIds) {
return (0, _isArray2.default)(speakerIdOrIds) ? speakerIdOrIds.join('-') : speakerIdOrIds;
});
}, function (speakerIdOrIds) {
return (0, _isArray2.default)(speakerIdOrIds) ? speakerIdOrIds.join('-') : speakerIdOrIds;
});

@@ -90,0 +90,0 @@

@@ -20,3 +20,2 @@ 'use strict';

app: {},
areas: defaultCrudState(),
userApplications: {},

@@ -23,0 +22,0 @@ user: {},

@@ -7,2 +7,21 @@ 'use strict';

exports.speakerIdSelector = exports.askPermission = exports.getPermissions = exports.getCurrentApplication = exports.QUERY_ERROR = exports.QUERY_SUCCESS = exports.QUERY_REQUEST = undefined;
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; }; /*
* User Applications Module
*
* Example State:
* ==============
*
* {
* current: '1',
* list: [{
* _id: '1',
* name: 'Application1'
* }, {
* _id: '2',
* name: 'Application2'
* }]
* }
*/
exports.reducer = reducer;

@@ -42,19 +61,3 @@ exports.queryRequest = queryRequest;

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /*
* User Applications Module
*
* Example State:
* ==============
*
* {
* current: '1',
* list: [{
* _id: '1',
* name: 'Application1'
* }, {
* _id: '2',
* name: 'Application2'
* }]
* }
*/
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

@@ -74,45 +77,61 @@ var QUERY_REQUEST = exports.QUERY_REQUEST = 'lighthouse/user-applications/QUERY_REQUEST';

switch (action.type) {
case QUERY_REQUEST:
return state.set('state', 'resolving');
// TODO API needs updating to match expected response
case QUERY_SUCCESS:
return state.merge({
state: 'resolved',
applications: action.data
});
case QUERY_ERROR:
return state.merge({
state: 'resolved',
error: action.error
});
case _authentication.AUTHENTICATE_SUCCESS:
return state.merge({
state: 'resolved',
applications: action.data.applications
});
/**
NOTE
We need to handle this here for when users have never logged into the app
before. The speakerId is stored on a users' userApplication, but if
they're a new user, when they first login then they won't have a speakerId
in the place. So what we do here is use the speakerId returned by
messagesRegistration and set that on the speakerbox configuration for that
user
*/
case _applicationUsers.actions.MESSAGES_REGISTRATION_SUCCESS:
action.data = action.data || {};
var _action$data = action.data,
applicationId = _action$data.applicationId,
speakerId = _action$data.speakerId;
var _ret = function () {
switch (action.type) {
case QUERY_REQUEST:
return {
v: state.set('state', 'resolving')
};
// TODO API needs updating to match expected response
case QUERY_SUCCESS:
return {
v: state.merge({
state: 'resolved',
applications: action.data
})
};
case QUERY_ERROR:
return {
v: state.merge({
state: 'resolved',
error: action.error
})
};
case _authentication.AUTHENTICATE_SUCCESS:
return {
v: state.merge({
state: 'resolved',
applications: action.data.applications
})
};
/**
NOTE
We need to handle this here for when users have never logged into the app
before. The speakerId is stored on a users' userApplication, but if
they're a new user, when they first login then they won't have a speakerId
in the place. So what we do here is use the speakerId returned by
messagesRegistration and set that on the speakerbox configuration for that
user
*/
case _applicationUsers.actions.MESSAGES_REGISTRATION_SUCCESS:
action.data = action.data || {};
var _action$data = action.data,
applicationId = _action$data.applicationId,
speakerId = _action$data.speakerId;
return state.set('applications', (0, _map2.default)(state.applications, function (userApplication) {
var matchesApplication = userApplication.application._id === applicationId;
if (!matchesApplication) return userApplication;
return {
v: state.set('applications', (0, _map2.default)(state.applications, function (userApplication) {
var matchesApplication = userApplication.application._id === applicationId;
if (!matchesApplication) return userApplication;
return userApplication.setIn(['speakerbox', 'speakerId'], speakerId);
}));
default:
return state;
}
return userApplication.setIn(['speakerbox', 'speakerId'], speakerId);
}))
};
default:
return {
v: state
};
}
}();
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
}

@@ -158,4 +177,4 @@

*/
var askPermission = exports.askPermission = function askPermission(options) {
return (0, _reselect.createSelector)(getPermissions, function (permissions) {
var askPermission = exports.askPermission = (0, _reselect.createSelector)(getPermissions, function (permissions) {
return function (options) {
var action = options.action,

@@ -171,4 +190,4 @@ module = options.module,

return result;
});
};
};
});

@@ -175,0 +194,0 @@ var speakerIdSelector = exports.speakerIdSelector = (0, _reselect.createSelector)(getCurrentApplication, function (currentApplication) {

@@ -45,2 +45,6 @@ 'use strict';

var _isEmpty = require('lodash/isEmpty');
var _isEmpty2 = _interopRequireDefault(_isEmpty);
var _crud = require('../../crud');

@@ -88,7 +92,10 @@

var crudSelectors = _crud2.default.selectors(resource);
var getZoneByBeacon = (0, _memoize2.default)(function (beacon) {
return (0, _reselect.createSelector)(crudSelectors.cache, function (cache) {
var getZoneByBeacon = (0, _reselect.createSelector)(crudSelectors.cache, function (cache) {
return (0, _memoize2.default)(function (beacon) {
if (!beacon) return null;
var beaconObj = (0, _mapValues2.default)(beacon, _toString2.default);
if ((0, _isEmpty2.default)(beaconObj)) return false;
var zone = (0, _find2.default)(cache, function (zone) {

@@ -107,15 +114,15 @@ var _get = (0, _get3.default)(zone, 'entity.beacon', {}),

return zone && zone.entity;
});
}, function () {
var beacon = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var uuid = beacon.uuid,
major = beacon.major,
minor = beacon.minor;
}, function () {
var beacon = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var uuid = beacon.uuid,
major = beacon.major,
minor = beacon.minor;
var isValid = uuid && major && minor;
var isValid = uuid && major && minor;
if (!isValid) return null;
if (!isValid) return null;
var cacheKey = uuid + '-' + major + '-' + minor;
return cacheKey;
var cacheKey = uuid + '-' + major + '-' + minor;
return cacheKey;
});
});

@@ -122,0 +129,0 @@

{
"name": "@lighthouse/sdk",
"version": "8.0.0-map-beta-1",
"version": "8.0.0-rc-1",
"description": "Lighthouse.io SDK for JavaScript applications",

@@ -52,2 +52,3 @@ "main": "build/index.js",

"bluebird": "^3.4.0",
"bluebird-retry": "^0.10.1",
"cuid": "^1.3.8",

@@ -59,3 +60,2 @@ "es6-symbol": "^3.0.2",

"pluralize": "^3.1.0",
"promise-retry": "^1.1.1",
"pubnub": "^3.15.1",

@@ -62,0 +62,0 @@ "query-string": "^3.0.0",

Sorry, the diff of this file is not supported yet

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