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

apax-react-core

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apax-react-core - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

145

dist/index.es.js

@@ -0,3 +1,4 @@

import { get } from 'lodash';
import axios from 'axios';
import { call, select, all, put, take } from 'redux-saga/effects';
import { call, select, all, put, take, takeEvery } from 'redux-saga/effects';
import Cookies$1 from 'universal-cookie';

@@ -15,2 +16,5 @@

var LOGIN_ERROR = 'LOGIN_ERROR';
var PATCH_USER = 'PATCH_USER';
var PATCH_USER_SUCCESS = 'PATCH_USER_SUCCESS';
var PATCH_USER_ERROR = 'PATCH_USER_ERROR';
var LOGOUT = 'LOGOUT';

@@ -46,2 +50,9 @@ var CLEAR_ERRORS = 'CLEAR_ERRORS';

var patchUser = function patchUser(formData) {
return {
type: PATCH_USER,
formData: formData
};
};
var _extends = Object.assign || function (target) {

@@ -107,3 +118,4 @@ for (var i = 1; i < arguments.length; i++) {

signupPending: false,
signupError: null
signupError: null,
patchUserError: null
};

@@ -152,2 +164,17 @@

});
case PATCH_USER:
return _extends({}, state, {
userLoading: true
});
case PATCH_USER_SUCCESS:
return _extends({}, state, {
userLoading: false,
patchUserError: null,
user: action.response
});
case PATCH_USER_ERROR:
return _extends({}, state, {
userLoading: false,
patchUserError: action.error
});
case LOAD_USER:

@@ -234,7 +261,2 @@ return _extends({}, state, {

var getTokenType = function getTokenType(_ref3) {
var account = _ref3.account;
return account ? account.token_type : 'Token';
};
var getApiRoot = function getApiRoot(_ref) {

@@ -249,2 +271,6 @@ var env = _ref.env;

};
var getTokenType = function getTokenType(_ref3) {
var env = _ref3.env;
return get(env, 'token_type') ? env.token_type : 'Token';
};

@@ -486,2 +512,6 @@ var _marked = /*#__PURE__*/regeneratorRuntime.mark(getHeaders),

},
patchUser: function patchUser(data) {
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'api/user/';
return apiPatch(path, data);
},
loadUser: function loadUser() {

@@ -531,4 +561,5 @@ return apiGet('api/user/');

_marked3$1 = /*#__PURE__*/regeneratorRuntime.mark(loadUser),
_marked4$1 = /*#__PURE__*/regeneratorRuntime.mark(loginFlow),
_marked5$1 = /*#__PURE__*/regeneratorRuntime.mark(_callee);
_marked4$1 = /*#__PURE__*/regeneratorRuntime.mark(doPatchUser),
_marked5$1 = /*#__PURE__*/regeneratorRuntime.mark(loginFlow),
_marked6$1 = /*#__PURE__*/regeneratorRuntime.mark(_callee);

@@ -682,2 +713,36 @@ function doSignup(action$$1) {

function doPatchUser(action$$1) {
var formData, response;
return regeneratorRuntime.wrap(function doPatchUser$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
formData = action$$1.formData;
_context4.prev = 1;
_context4.next = 4;
return call(api.patchUser, formData);
case 4:
response = _context4.sent;
_context4.next = 7;
return put({ type: PATCH_USER_SUCCESS, response: response });
case 7:
_context4.next = 13;
break;
case 9:
_context4.prev = 9;
_context4.t0 = _context4['catch'](1);
_context4.next = 13;
return put({ type: PATCH_USER_ERROR, error: _context4.t0.response.data });
case 13:
case 'end':
return _context4.stop();
}
}
}, _marked4$1, this, [[1, 9]]);
}
// Finite state machine for user session

@@ -687,73 +752,73 @@ function loginFlow() {

return regeneratorRuntime.wrap(function loginFlow$(_context4) {
return regeneratorRuntime.wrap(function loginFlow$(_context5) {
while (1) {
switch (_context4.prev = _context4.next) {
switch (_context5.prev = _context5.next) {
case 0:
_context4.next = 3;
_context5.next = 3;
return select(getTokenName);
case 3:
tokenName = _context4.sent;
tokenName = _context5.sent;
token = new Cookies$1().get(tokenName);
if (!token) {
_context4.next = 8;
_context5.next = 8;
break;
}
_context4.next = 8;
_context5.next = 8;
return call(loadUser, token);
case 8:
_context4.next = 10;
_context5.next = 10;
return select(getUser);
case 10:
if (_context4.sent) {
_context4.next = 21;
if (_context5.sent) {
_context5.next = 21;
break;
}
_context4.next = 13;
_context5.next = 13;
return take([LOGIN, SIGNUP]);
case 13:
action$$1 = _context4.sent;
action$$1 = _context5.sent;
if (!(action$$1.type === LOGIN)) {
_context4.next = 19;
_context5.next = 19;
break;
}
_context4.next = 17;
_context5.next = 17;
return call(doLogin, action$$1);
case 17:
_context4.next = 21;
_context5.next = 21;
break;
case 19:
_context4.next = 21;
_context5.next = 21;
return call(doSignup, action$$1);
case 21:
_context4.next = 23;
_context5.next = 23;
return select(getUser);
case 23:
if (!_context4.sent) {
_context4.next = 30;
if (!_context5.sent) {
_context5.next = 30;
break;
}
_context4.next = 26;
_context5.next = 26;
return take(LOGOUT);
case 26:
_context4.next = 28;
_context5.next = 28;
return select(getTokenName);
case 28:
_tokenName = _context4.sent;
_tokenName = _context5.sent;

@@ -763,3 +828,3 @@ new Cookies$1().remove(_tokenName, { path: '/' });

case 30:
_context4.next = 0;
_context5.next = 0;
break;

@@ -769,25 +834,25 @@

case 'end':
return _context4.stop();
return _context5.stop();
}
}
}, _marked4$1, this);
}, _marked5$1, this);
}
function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context5) {
return regeneratorRuntime.wrap(function _callee$(_context6) {
while (1) {
switch (_context5.prev = _context5.next) {
switch (_context6.prev = _context6.next) {
case 0:
_context5.next = 2;
return all([loginFlow()]);
_context6.next = 2;
return all([loginFlow(), takeEvery(PATCH_USER, doPatchUser)]);
case 2:
case 'end':
return _context5.stop();
return _context6.stop();
}
}
}, _marked5$1, this);
}, _marked6$1, this);
}
export { account as accountReducer, env as envReducer, _callee as accountSagas, api, apiPost, apiGet, apiPut, apiPatch, apiDelete, getUser, getToken, getTokenType, getApiRoot, getTokenName, SET_USER_TOKEN, LOAD_USER, LOAD_USER_SUCCESS, LOAD_USER_ERROR, LOGIN, SIGNUP, LOGIN_SUCCESS, SIGNUP_SUCCESS, SIGNUP_ERROR, LOGIN_ERROR, LOGOUT, CLEAR_ERRORS, setUserToken, login, logout, signup, SET_ENV, setEnv };
export { account as accountReducer, env as envReducer, _callee as accountSagas, api, apiPost, apiGet, apiPut, apiPatch, apiDelete, getUser, getToken, getApiRoot, getTokenName, getTokenType, SET_USER_TOKEN, LOAD_USER, LOAD_USER_SUCCESS, LOAD_USER_ERROR, LOGIN, SIGNUP, LOGIN_SUCCESS, SIGNUP_SUCCESS, SIGNUP_ERROR, LOGIN_ERROR, PATCH_USER, PATCH_USER_SUCCESS, PATCH_USER_ERROR, LOGOUT, CLEAR_ERRORS, setUserToken, login, logout, signup, patchUser, SET_ENV, setEnv };
//# sourceMappingURL=index.es.js.map

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

var _ = require('lodash');
var axios = _interopDefault(require('axios'));

@@ -22,2 +23,5 @@ var effects = require('redux-saga/effects');

var LOGIN_ERROR = 'LOGIN_ERROR';
var PATCH_USER = 'PATCH_USER';
var PATCH_USER_SUCCESS = 'PATCH_USER_SUCCESS';
var PATCH_USER_ERROR = 'PATCH_USER_ERROR';
var LOGOUT = 'LOGOUT';

@@ -53,2 +57,9 @@ var CLEAR_ERRORS = 'CLEAR_ERRORS';

var patchUser = function patchUser(formData) {
return {
type: PATCH_USER,
formData: formData
};
};
var _extends = Object.assign || function (target) {

@@ -114,3 +125,4 @@ for (var i = 1; i < arguments.length; i++) {

signupPending: false,
signupError: null
signupError: null,
patchUserError: null
};

@@ -159,2 +171,17 @@

});
case PATCH_USER:
return _extends({}, state, {
userLoading: true
});
case PATCH_USER_SUCCESS:
return _extends({}, state, {
userLoading: false,
patchUserError: null,
user: action.response
});
case PATCH_USER_ERROR:
return _extends({}, state, {
userLoading: false,
patchUserError: action.error
});
case LOAD_USER:

@@ -241,7 +268,2 @@ return _extends({}, state, {

var getTokenType = function getTokenType(_ref3) {
var account = _ref3.account;
return account ? account.token_type : 'Token';
};
var getApiRoot = function getApiRoot(_ref) {

@@ -256,2 +278,6 @@ var env = _ref.env;

};
var getTokenType = function getTokenType(_ref3) {
var env = _ref3.env;
return _.get(env, 'token_type') ? env.token_type : 'Token';
};

@@ -493,2 +519,6 @@ var _marked = /*#__PURE__*/regeneratorRuntime.mark(getHeaders),

},
patchUser: function patchUser(data) {
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'api/user/';
return apiPatch(path, data);
},
loadUser: function loadUser() {

@@ -538,4 +568,5 @@ return apiGet('api/user/');

_marked3$1 = /*#__PURE__*/regeneratorRuntime.mark(loadUser),
_marked4$1 = /*#__PURE__*/regeneratorRuntime.mark(loginFlow),
_marked5$1 = /*#__PURE__*/regeneratorRuntime.mark(_callee);
_marked4$1 = /*#__PURE__*/regeneratorRuntime.mark(doPatchUser),
_marked5$1 = /*#__PURE__*/regeneratorRuntime.mark(loginFlow),
_marked6$1 = /*#__PURE__*/regeneratorRuntime.mark(_callee);

@@ -689,2 +720,36 @@ function doSignup(action$$1) {

function doPatchUser(action$$1) {
var formData, response;
return regeneratorRuntime.wrap(function doPatchUser$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
formData = action$$1.formData;
_context4.prev = 1;
_context4.next = 4;
return effects.call(api.patchUser, formData);
case 4:
response = _context4.sent;
_context4.next = 7;
return effects.put({ type: PATCH_USER_SUCCESS, response: response });
case 7:
_context4.next = 13;
break;
case 9:
_context4.prev = 9;
_context4.t0 = _context4['catch'](1);
_context4.next = 13;
return effects.put({ type: PATCH_USER_ERROR, error: _context4.t0.response.data });
case 13:
case 'end':
return _context4.stop();
}
}
}, _marked4$1, this, [[1, 9]]);
}
// Finite state machine for user session

@@ -694,73 +759,73 @@ function loginFlow() {

return regeneratorRuntime.wrap(function loginFlow$(_context4) {
return regeneratorRuntime.wrap(function loginFlow$(_context5) {
while (1) {
switch (_context4.prev = _context4.next) {
switch (_context5.prev = _context5.next) {
case 0:
_context4.next = 3;
_context5.next = 3;
return effects.select(getTokenName);
case 3:
tokenName = _context4.sent;
tokenName = _context5.sent;
token = new Cookies$1().get(tokenName);
if (!token) {
_context4.next = 8;
_context5.next = 8;
break;
}
_context4.next = 8;
_context5.next = 8;
return effects.call(loadUser, token);
case 8:
_context4.next = 10;
_context5.next = 10;
return effects.select(getUser);
case 10:
if (_context4.sent) {
_context4.next = 21;
if (_context5.sent) {
_context5.next = 21;
break;
}
_context4.next = 13;
_context5.next = 13;
return effects.take([LOGIN, SIGNUP]);
case 13:
action$$1 = _context4.sent;
action$$1 = _context5.sent;
if (!(action$$1.type === LOGIN)) {
_context4.next = 19;
_context5.next = 19;
break;
}
_context4.next = 17;
_context5.next = 17;
return effects.call(doLogin, action$$1);
case 17:
_context4.next = 21;
_context5.next = 21;
break;
case 19:
_context4.next = 21;
_context5.next = 21;
return effects.call(doSignup, action$$1);
case 21:
_context4.next = 23;
_context5.next = 23;
return effects.select(getUser);
case 23:
if (!_context4.sent) {
_context4.next = 30;
if (!_context5.sent) {
_context5.next = 30;
break;
}
_context4.next = 26;
_context5.next = 26;
return effects.take(LOGOUT);
case 26:
_context4.next = 28;
_context5.next = 28;
return effects.select(getTokenName);
case 28:
_tokenName = _context4.sent;
_tokenName = _context5.sent;

@@ -770,3 +835,3 @@ new Cookies$1().remove(_tokenName, { path: '/' });

case 30:
_context4.next = 0;
_context5.next = 0;
break;

@@ -776,22 +841,22 @@

case 'end':
return _context4.stop();
return _context5.stop();
}
}
}, _marked4$1, this);
}, _marked5$1, this);
}
function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context5) {
return regeneratorRuntime.wrap(function _callee$(_context6) {
while (1) {
switch (_context5.prev = _context5.next) {
switch (_context6.prev = _context6.next) {
case 0:
_context5.next = 2;
return effects.all([loginFlow()]);
_context6.next = 2;
return effects.all([loginFlow(), effects.takeEvery(PATCH_USER, doPatchUser)]);
case 2:
case 'end':
return _context5.stop();
return _context6.stop();
}
}
}, _marked5$1, this);
}, _marked6$1, this);
}

@@ -810,5 +875,5 @@

exports.getToken = getToken;
exports.getTokenType = getTokenType;
exports.getApiRoot = getApiRoot;
exports.getTokenName = getTokenName;
exports.getTokenType = getTokenType;
exports.SET_USER_TOKEN = SET_USER_TOKEN;

@@ -824,2 +889,5 @@ exports.LOAD_USER = LOAD_USER;

exports.LOGIN_ERROR = LOGIN_ERROR;
exports.PATCH_USER = PATCH_USER;
exports.PATCH_USER_SUCCESS = PATCH_USER_SUCCESS;
exports.PATCH_USER_ERROR = PATCH_USER_ERROR;
exports.LOGOUT = LOGOUT;

@@ -831,4 +899,5 @@ exports.CLEAR_ERRORS = CLEAR_ERRORS;

exports.signup = signup;
exports.patchUser = patchUser;
exports.SET_ENV = SET_ENV;
exports.setEnv = setEnv;
//# sourceMappingURL=index.js.map
{
"name": "apax-react-core",
"version": "0.5.1",
"version": "0.6.0",
"description": "Contains core react functionality developed by Apax Software LLC",

@@ -5,0 +5,0 @@ "author": "apaxsoftware",

Sorry, the diff of this file is not supported yet

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