@dhi-solutions/domain-services
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.0.12](https://github.com/DHI-Solutions/nomads/compare/@dhi-solutions/domain-services@0.0.11...@dhi-solutions/domain-services@0.0.12) (2020-03-11) | ||
**Note:** Version bump only for package @dhi-solutions/domain-services | ||
## [0.0.11](https://github.com/DHI-Solutions/nomads/compare/@dhi-solutions/domain-services@0.0.10...@dhi-solutions/domain-services@0.0.11) (2020-03-11) | ||
@@ -8,0 +16,0 @@ |
@@ -10,7 +10,7 @@ "use strict"; | ||
var _index = require("../index"); | ||
var _options = _interopRequireDefault(require("../options")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var localStorageUserKey = _index.options.localStorageUserKey; | ||
var localStorageUserKey = _options["default"].localStorageUserKey; | ||
@@ -17,0 +17,0 @@ var _default = function _default() { |
declare const _default: { | ||
getUser: () => any; | ||
isLoggedIn: () => boolean; | ||
login: ({ baseURL, id, password, config, }: import("./types").ILogin) => Promise<any>; | ||
login: ({ id, password, config }: import("./types").ILogin) => Promise<any>; | ||
loginFromLocalStorage: () => Promise<any>; | ||
@@ -6,0 +6,0 @@ logout: () => Promise<void>; |
@@ -12,7 +12,7 @@ "use strict"; | ||
var _index = require("../index"); | ||
var _options = _interopRequireDefault(require("../options")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var localStorageUserKey = _index.options.localStorageUserKey; | ||
var localStorageUserKey = _options["default"].localStorageUserKey; | ||
@@ -19,0 +19,0 @@ var _default = function _default() { |
import * as Types from './types'; | ||
declare const _default: ({ baseURL, id, password, config, }: Types.ILogin) => Promise<any>; | ||
declare const _default: ({ id, password, config }: Types.ILogin) => Promise<any>; | ||
export default _default; |
"use strict"; | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -12,4 +10,6 @@ value: true | ||
var _index = _interopRequireWildcard(require("../index")); | ||
var _index = _interopRequireDefault(require("../index")); | ||
var _options = _interopRequireDefault(require("../options")); | ||
var _mapUser = _interopRequireDefault(require("./lib/mapUser")); | ||
@@ -19,6 +19,2 @@ | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -36,7 +32,7 @@ | ||
var localStorageUserKey = _index.options.localStorageUserKey; | ||
var localStorageUserKey = _options["default"].localStorageUserKey; | ||
var _default = function () { | ||
var _ref2 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(_ref) { | ||
var _ref$baseURL, baseURL, id, password, _ref$config, config, endpoint, validationEndpoint, tokenEndpoint, body, validationResponse, userData, tokenResponse, tokenData, accessToken, token, mappedUser, user; | ||
var id, password, _ref$config, config, endpoint, validationEndpoint, tokenEndpoint, body, validationResponse, userData, tokenResponse, tokenData, accessToken, token, mappedUser, user; | ||
@@ -47,5 +43,5 @@ return regeneratorRuntime.wrap(function _callee$(_context) { | ||
case 0: | ||
_ref$baseURL = _ref.baseURL, baseURL = _ref$baseURL === void 0 ? _index["default"].defaults.baseURL : _ref$baseURL, id = _ref.id, password = _ref.password, _ref$config = _ref.config, config = _ref$config === void 0 ? {} : _ref$config; | ||
id = _ref.id, password = _ref.password, _ref$config = _ref.config, config = _ref$config === void 0 ? {} : _ref$config; | ||
_context.prev = 1; | ||
endpoint = baseURL + '/api'; | ||
endpoint = '/api'; | ||
validationEndpoint = endpoint + '/accounts/validation'; | ||
@@ -52,0 +48,0 @@ tokenEndpoint = endpoint + '/tokens'; |
@@ -12,3 +12,3 @@ "use strict"; | ||
var _index = require("../index"); | ||
var _options = _interopRequireDefault(require("../options")); | ||
@@ -21,3 +21,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var localStorageUserKey = _index.options.localStorageUserKey; | ||
var localStorageUserKey = _options["default"].localStorageUserKey; | ||
@@ -24,0 +24,0 @@ var _default = _asyncToGenerator(regeneratorRuntime.mark(function _callee() { |
import authentication from './authentication'; | ||
export { authentication }; | ||
export declare const API: import("axios").AxiosInstance; | ||
interface IOptions { | ||
baseURL: string; | ||
localStorageUserKey: string; | ||
} | ||
export declare const options: IOptions; | ||
export declare const initialize: ({ baseURL, localStorageUserKey, }?: IOptions) => void; | ||
export declare const getDataAsJSON: (response: any) => Promise<any>; | ||
export declare const setDataAsString: (response: any) => Promise<any>; | ||
export default API; |
@@ -12,3 +12,3 @@ "use strict"; | ||
}); | ||
exports["default"] = exports.setDataAsString = exports.getDataAsJSON = exports.initialize = exports.options = exports.API = void 0; | ||
exports["default"] = exports.setDataAsString = exports.getDataAsJSON = exports.API = void 0; | ||
@@ -19,4 +19,2 @@ var _axios = _interopRequireDefault(require("axios")); | ||
var _set = _interopRequireDefault(require("lodash/set")); | ||
var _authentication = _interopRequireDefault(require("./authentication")); | ||
@@ -41,22 +39,6 @@ | ||
exports.API = API; | ||
var options = { | ||
baseURL: API.defaults.baseURL, | ||
localStorageUserKey: 'DHI_USER_DATA' | ||
}; | ||
exports.options = options; | ||
var initialize = function initialize() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : options, | ||
baseURL = _ref.baseURL, | ||
localStorageUserKey = _ref.localStorageUserKey; | ||
(0, _set["default"])(API, 'defaults.baseURL', baseURL); | ||
(0, _set["default"])(options, 'localStorageUserKey', localStorageUserKey); | ||
}; | ||
exports.initialize = initialize; | ||
var getDataAsJSON = function () { | ||
var _ref2 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(response) { | ||
var _ref3, dataAsString, isDataArray, getParsedItem, dataAsJSON; | ||
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(response) { | ||
var _ref2, dataAsString, isDataArray, getParsedItem, dataAsJSON; | ||
@@ -67,3 +49,3 @@ return regeneratorRuntime.wrap(function _callee$(_context) { | ||
case 0: | ||
_ref3 = response || {}, dataAsString = _ref3.data; | ||
_ref2 = response || {}, dataAsString = _ref2.data; | ||
isDataArray = (0, _isArray["default"])(dataAsString); | ||
@@ -92,3 +74,3 @@ | ||
return function getDataAsJSON(_x) { | ||
return _ref2.apply(this, arguments); | ||
return _ref.apply(this, arguments); | ||
}; | ||
@@ -100,4 +82,4 @@ }(); | ||
var setDataAsString = function () { | ||
var _ref4 = _asyncToGenerator(regeneratorRuntime.mark(function _callee2(response) { | ||
var _ref5, dataAsJSON, isDataArray, getStringifiedItem, dataAsString; | ||
var _ref3 = _asyncToGenerator(regeneratorRuntime.mark(function _callee2(response) { | ||
var _ref4, dataAsJSON, isDataArray, getStringifiedItem, dataAsString; | ||
@@ -108,3 +90,3 @@ return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
case 0: | ||
_ref5 = response || {}, dataAsJSON = _ref5.data; | ||
_ref4 = response || {}, dataAsJSON = _ref4.data; | ||
isDataArray = (0, _isArray["default"])(dataAsJSON); | ||
@@ -133,3 +115,3 @@ | ||
return function setDataAsString(_x2) { | ||
return _ref4.apply(this, arguments); | ||
return _ref3.apply(this, arguments); | ||
}; | ||
@@ -136,0 +118,0 @@ }(); |
{ | ||
"name": "@dhi-solutions/domain-services", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"side-effects": false, | ||
@@ -29,3 +29,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "034b6d3e028d246f29a5affeb294343981536287" | ||
"gitHead": "9ff94bec5569be496a935540369ce3f09db95b95" | ||
} |
30
488
26902