UNPKG

@react-ent/core

Version:
1,194 lines (939 loc) 268 kB
module.exports = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _del__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "del", function() { return _del__WEBPACK_IMPORTED_MODULE_0__["default"]; }); /* harmony import */ var _initialState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(38); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "initialState", function() { return _initialState__WEBPACK_IMPORTED_MODULE_1__["initialState"]; }); /* harmony import */ var _Model__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Model", function() { return _Model__WEBPACK_IMPORTED_MODULE_2__["Model"]; }); /* harmony import */ var _patch__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(39); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "patch", function() { return _patch__WEBPACK_IMPORTED_MODULE_3__["default"]; }); /* harmony import */ var _post__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(40); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "post", function() { return _post__WEBPACK_IMPORTED_MODULE_4__["default"]; }); /* harmony import */ var _put__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(41); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "put", function() { return _put__WEBPACK_IMPORTED_MODULE_5__["default"]; }); /* harmony import */ var _ReactEnt__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(37); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReactEnt", function() { return _ReactEnt__WEBPACK_IMPORTED_MODULE_6__["default"]; }); /* harmony import */ var _reducer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(42); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "reducer", function() { return _reducer__WEBPACK_IMPORTED_MODULE_7__["reducer"]; }); /* harmony import */ var _remove__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(43); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "remove", function() { return _remove__WEBPACK_IMPORTED_MODULE_8__["remove"]; }); /* harmony import */ var _removeAll__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(44); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "removeAll", function() { return _removeAll__WEBPACK_IMPORTED_MODULE_9__["removeAll"]; }); /* harmony import */ var _save__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(45); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "save", function() { return _save__WEBPACK_IMPORTED_MODULE_10__["save"]; }); /* harmony import */ var _State__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(46); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateContext", function() { return _State__WEBPACK_IMPORTED_MODULE_11__["StateContext"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateProvider", function() { return _State__WEBPACK_IMPORTED_MODULE_11__["StateProvider"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "useStateValue", function() { return _State__WEBPACK_IMPORTED_MODULE_11__["useStateValue"]; }); /* harmony import */ var _Store__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(48); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Store", function() { return _Store__WEBPACK_IMPORTED_MODULE_12__["default"]; }); /* harmony import */ var _useGet__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(51); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "useGet", function() { return _useGet__WEBPACK_IMPORTED_MODULE_13__["default"]; }); /* harmony import */ var _Utility__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(52); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Utility", function() { return _Utility__WEBPACK_IMPORTED_MODULE_14__["Utility"]; }); /***/ }), /* 1 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return del; }); /* harmony import */ var _internal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } /** * Function that executes a DELETE against the API. * * @param {Object} model * @param {Object} params */ function del(_x, _x2) { return _del.apply(this, arguments); } function _del() { _del = _asyncToGenerator( /*#__PURE__*/ regeneratorRuntime.mark(function _callee(model, params) { var o, deletePath, nullableParams, apiUriOverride, payload; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: o = Object(_internal__WEBPACK_IMPORTED_MODULE_0__["inspectClass"])(model); deletePath = model.deletePath; nullableParams = model.nullableParams; apiUriOverride = model.apiUriOverride; if (!(deletePath !== null)) { _context.next = 11; break; } payload = { path: deletePath, body: Object.assign({}, params) }; _context.next = 8; return Object(_internal__WEBPACK_IMPORTED_MODULE_0__["request"])(payload, nullableParams, _internal__WEBPACK_IMPORTED_MODULE_0__["methods"].DELETE, apiUriOverride); case 8: return _context.abrupt("return", _context.sent); case 11: console.error("The ".concat(o.ClassName, " object is missing the deletePath attribute.")); case 12: return _context.abrupt("return"); case 13: case "end": return _context.stop(); } } }, _callee); })); return _del.apply(this, arguments); } /***/ }), /* 2 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _inspectClass__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "inspectClass", function() { return _inspectClass__WEBPACK_IMPORTED_MODULE_0__["inspectClass"]; }); /* harmony import */ var _IsLoading__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IsLoading", function() { return _IsLoading__WEBPACK_IMPORTED_MODULE_1__["IsLoading"]; }); /* harmony import */ var _LastUpdated__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LastUpdated", function() { return _LastUpdated__WEBPACK_IMPORTED_MODULE_2__["LastUpdated"]; }); /* harmony import */ var _methods__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "methods", function() { return _methods__WEBPACK_IMPORTED_MODULE_3__["methods"]; }); /* harmony import */ var _request__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "request", function() { return _request__WEBPACK_IMPORTED_MODULE_4__["request"]; }); /***/ }), /* 3 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inspectClass", function() { return inspectClass; }); 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); } var inspectClass = function inspectClass(obj) { var objClass, className; var classProto; var methods = []; var attributes = {}; var t; try { if (typeof obj != 'function') { objClass = obj.constructor; } else { objClass = obj; } className = objClass.name; classProto = objClass.prototype; Object.getOwnPropertyNames(classProto).forEach(function (m) { t = _typeof(classProto[m]); if (t === 'function') { methods.push(m); } else { attributes[m] = classProto[m]; } }); } catch (err) { className = 'undefined'; } return { ClassName: className, Methods: methods, Attributes: attributes }; }; /***/ }), /* 4 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IsLoading", function() { return IsLoading; }); /* harmony import */ var _Model__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5); /* harmony import */ var ___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0); /* harmony import */ var _react_ent_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6); /* harmony import */ var _react_ent_utils__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_react_ent_utils__WEBPACK_IMPORTED_MODULE_2__); 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); } function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } 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; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var IsLoading = /*#__PURE__*/ function (_Model) { _inherits(IsLoading, _Model); function IsLoading() { _classCallCheck(this, IsLoading); return _possibleConstructorReturn(this, _getPrototypeOf(IsLoading).apply(this, arguments)); } _createClass(IsLoading, [{ key: "reducer", value: function reducer(state, action) { switch (action.type) { case this.types.SET_IS_LOADING: return _objectSpread({}, state, {}, action.isLoading); default: return state; } } }, { key: "updateState", value: function () { var _updateState = _asyncToGenerator( /*#__PURE__*/ regeneratorRuntime.mark(function _callee(isLoading, type) { return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: return _context.abrupt("return", { type: this.types.SET_IS_LOADING, isLoading: isLoading }); case 1: case "end": return _context.stop(); } } }, _callee, this); })); function updateState(_x, _x2) { return _updateState.apply(this, arguments); } return updateState; }() }, { key: "initialState", get: function get() { var models = Object(_react_ent_utils__WEBPACK_IMPORTED_MODULE_2__["get"])(___WEBPACK_IMPORTED_MODULE_1__["ReactEnt"], 'config.models', {}); var objects = Object.values(models); var isLoading = {}; for (var i = 0; i < objects.length; i++) { var key = Object.keys(objects[i].prototype.initialState)[0].toString(); // Add to isLoading if there is a getPath. if (objects[i].prototype.getPath) { Object.assign(isLoading, _defineProperty({}, key, false)); } } return { isLoading: isLoading }; } }, { key: "types", get: function get() { return { SET_IS_LOADING: 'SET_IS_LOADING' }; } /** * No need to store the isLoading state. */ }, { key: "persistData", get: function get() { return false; } }]); return IsLoading; }(_Model__WEBPACK_IMPORTED_MODULE_0__["Model"]); /***/ }), /* 5 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Model", function() { return Model; }); 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); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } var Model = /*#__PURE__*/ function (_Object) { _inherits(Model, _Object); function Model() { _classCallCheck(this, Model); return _possibleConstructorReturn(this, _getPrototypeOf(Model).apply(this, arguments)); } _createClass(Model, [{ key: "reducer", value: function reducer() { this["throw"]('reducer(state, action)'); } /** * This is your main action. This is what will be called to update your * object in state. Type is not needed if there is only one type in * your model. * * @param {Object} stateObj * @param {string} type */ }, { key: "updateState", value: function updateState(stateObj, type) { this["throw"]('updateState(stateObj, type)'); } }, { key: "throw", value: function _throw(functionName) { throw new Error("Model error: ".concat(functionName, " must be implemented in the derived class.")); } }, { key: "types", get: function get() { return this["throw"]('types getter'); } }, { key: "initialState", get: function get() { return this["throw"]('initialState getter'); } }, { key: "getPath", get: function get() { return null; } }, { key: "postPath", get: function get() { return null; } }, { key: "putPath", get: function get() { return null; } }, { key: "deletePath", get: function get() { return null; } }, { key: "patchPath", get: function get() { return null; } }, { key: "nullableParams", get: function get() { return false; } /** * If set, the api call will use the apiUriOverride path * instead of the path provided by the config. */ }, { key: "apiUriOverride", get: function get() { return null; } /** * If false, data isn't stored to storage. Api is called every time. * This will override preferStore (because there's no store) */ }, { key: "persistData", get: function get() { return true; } /** * Will rely on storage instead of calling the API repeatedly. * This will override progressiveLoading. */ }, { key: "preferStore", get: function get() { return false; } /** * Will return data in storage while the API retrieves the updated * values from the database and will do a deepCompare to check for changes. * If there are changes, it will dispatch an action to update the object. */ }, { key: "progressiveLoading", get: function get() { return false; } /** * If set, will create a timer (TODO: in a web worker) that will re-sync the data. * Should be in milliseconds. */ }, { key: "syncInterval", get: function get() { return null; } /** * If set, will make a call to the API after a certain amount of time (in milliseconds) * has elapsed. If the time has not elapsed, it will use the store. This will not * cause the data to refresh has soon as the time has elapsed, but new component * renders will trigger a new API call. */ }, { key: "syncAfterTimeElapsed", get: function get() { return null; } }]); return Model; }(_wrapNativeSuper(Object)); /***/ }), /* 6 */ /***/ (function(module, exports) { module.exports = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Compare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Compare", function() { return _Compare__WEBPACK_IMPORTED_MODULE_0__["default"]; }); /* harmony import */ var _deepCopy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "deepCopy", function() { return _deepCopy__WEBPACK_IMPORTED_MODULE_1__["deepCopy"]; }); /* harmony import */ var _formatPhoneNumber__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "formatPhoneNumber", function() { return _formatPhoneNumber__WEBPACK_IMPORTED_MODULE_2__["formatPhoneNumber"]; }); /* harmony import */ var _get__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "get", function() { return _get__WEBPACK_IMPORTED_MODULE_3__["get"]; }); /* harmony import */ var _has__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "has", function() { return _has__WEBPACK_IMPORTED_MODULE_4__["has"]; }); /* harmony import */ var _makeCamelCaseNormal__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "makeCamelCaseNormal", function() { return _makeCamelCaseNormal__WEBPACK_IMPORTED_MODULE_5__["makeCamelCaseNormal"]; }); /* harmony import */ var _objectIndexOf__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(8); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "objectIndexOf", function() { return _objectIndexOf__WEBPACK_IMPORTED_MODULE_6__["objectIndexOf"]; }); /* harmony import */ var _removeDuplicates__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(9); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "removeDuplicates", function() { return _removeDuplicates__WEBPACK_IMPORTED_MODULE_7__["removeDuplicates"]; }); /* harmony import */ var _removeNonNumericChars__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(4); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "removeNonNumericChars", function() { return _removeNonNumericChars__WEBPACK_IMPORTED_MODULE_8__["removeNonNumericChars"]; }); /* harmony import */ var _uuid__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(10); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "uuid", function() { return _uuid__WEBPACK_IMPORTED_MODULE_9__["uuid"]; }); /***/ }), /* 1 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _deepCopy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); 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); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 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; } var Compare = /*#__PURE__*/ function () { function Compare() { var _this = this; _classCallCheck(this, Compare); _defineProperty(this, "deepCompare", function (a, b) { var strictEquality = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; var _resetLog = _this._resetLog, _incrementDepth = _this._incrementDepth, _pass = _this._pass, _fail = _this._fail; /* #region Reset log if necessary */ _resetLog(); /* #endregion */ /* #region Track recursion depth */ _incrementDepth(); /* #endregion */ /* #region Undefined */ if (a === undefined && b === undefined) { // both values are undefined, so pass return _pass(); } else if (a === undefined || b === undefined) { return _fail(a, b, 'One of the values is undefined'); } /* #endregion */ /* #region Nulls */ if (a === null && b === null) { // both values are null, so pass return _pass(); } else if (a === null || b === null) { // only one value is null return _fail(a, b, 'One of the values is null'); } /* #endregion */ /* #region Function comparison */ if (typeof a === 'function' && typeof b === 'function') { var isEqual = a.toString() === b.toString(); if (!isEqual) { return _fail(a, b, 'Functions are not equal'); } return _pass(); } else if (typeof a === 'function' || typeof b === 'function') { return _fail(a, b, 'The values are not the same type'); } /* #endregion */ /* #region Neither values are objects */ if (_typeof(a) !== 'object' && _typeof(b) !== 'object') { // Values are not objects so do a simple comparison without type checking // unless strictEquality is true. var _isEqual = a == b; var isStrictEqual = a === b; if (strictEquality && !isStrictEqual) { var msg = _isEqual ? 'The values are different types' : 'The values are not equal'; return _fail(a, b, msg); } else if (!_isEqual) { return _fail(a, b, 'The values are not equal'); } return _pass(); } else if (_typeof(a) !== 'object' || _typeof(b) !== 'object') { return _fail(a, b, 'The values are different types'); } /* #endregion */ /* #region values are objects so we should deepCopy before going further */ a = Object(_deepCopy__WEBPACK_IMPORTED_MODULE_0__["deepCopy"])(a); b = Object(_deepCopy__WEBPACK_IMPORTED_MODULE_0__["deepCopy"])(b); /* #endregion */ /* #region Verify the objects have the same prototype chains */ if (a.constructor !== b.constructor) { return _fail(a, b, 'The objects have different proptype chains'); } /* #endregion */ /* #region Date comparison */ if (a instanceof Date && b instanceof Date) { // compare dates var _isEqual2 = new Date(a.getTime()).toString() === new Date(b.getTime()).toString(); if (!_isEqual2) { return _fail(a, b, 'The dates are not equal'); } return _pass(); } else if (a instanceof Date || b instanceof Date) { // only one value is a Date return _fail(a, b, 'The values are not the same type'); } /* #endregion */ /* #region Array comparison */ if (a instanceof Array && b instanceof Array) { // Check array lengths. If not of equal length, then return false. if (a.length !== b.length) { return _fail(a, b, 'The arrays are different lengths'); } for (var aI = a.length - 1; aI >= 0; --aI) { /* #region What's going on here... */ // Iterate through the first array, getting the value at each index. // Find that value in the other array. // If it's an object, need to search for that object, // iterate through the second array doing a deepCompare. // Splice from first array. if match is found in second array, // then splice from that array. // After the first array has been iterated over, // do a comparison of the array lengths to determine if the arrays are equal. /* #endregion */ var x = a[aI]; if (_typeof(x) === 'object') { _this.depthTracking.path.push("[".concat(aI, "]")); for (var bI = b.length - 1; bI >= 0; --bI) { var _isEqual3 = _this.deepCompare(x, b[bI], strictEquality).isEqual; if (_isEqual3) { b.splice(bI, 1); break; } } a.splice(aI, 1); if (a.length !== b.length) { return _fail(a, b, 'The arrays contain different values'); } else { _this.depthTracking.path.splice(_this.depthTracking.path.length - 1, 1); } } else if (typeof x === 'function') { for (var _bI = b.length - 1; _bI >= 0; --_bI) { var _isEqual4 = x.toString() === b[_bI].toString(); if (_isEqual4) { b.splice(_bI, 1); break; } } a.splice(aI, 1); } else if (strictEquality) { // Search for that value in the other array and get the index. var _bI2 = b.indexOf(x); if (_bI2 === -1) { // Value didn't exist. Exit comparison. return _fail(a, b, 'Value in first array did not exist in second array'); } else { // Value exists. Remove both values from arrays. a.splice(aI, 1); b.splice(_bI2, 1); } } else { for (var _bI3 = b.length - 1; _bI3 >= 0; --_bI3) { var _isEqual5 = x == b[_bI3]; if (_isEqual5) { // Remove value from b if there is a match. b.splice(_bI3, 1); break; } } // Remove value from a regardless of match. a.splice(aI, 1); } } // After first array is empty, check against length of second array. // if lengths are not equal, then arrays are not equal. if (a.length !== b.length) { return _fail(a, b, 'Value in second array did not exist in first array'); } // Arrays were the same length. return _pass(); } else if (a instanceof Array || b instanceof Array) { // Values are different types. Exit comparison. return _fail(a, b, 'The values are not the same type'); } /* #endregion */ /* #region Object comparison */ if (a instanceof Object && b instanceof Object) { // First check for an equal number of properties. if (Object.keys(a).length !== Object.keys(b).length) { return _fail(a, b, 'The objects have different properties'); } for (var propertyName in a) { /* #region What's going on here... */ // Need to type check these. // If the property is an object then call deepCompare // to break down the object a little further. // If not an object, handle function and primitive comparisons right here. /* #endregion */ if (_typeof(a[propertyName]) === 'object' && _typeof(b[propertyName]) === 'object') { _this.depthTracking.path.push(propertyName); var _isEqual6 = _this.deepCompare(a[propertyName], b[propertyName], strictEquality).isEqual; if (!_isEqual6) { return _fail(a, b, "The objects' properties have different values"); } else { _this.depthTracking.path.splice(_this.depthTracking.path.length - 1, 1); } } else if (_typeof(a[propertyName]) === 'object' || _typeof(b[propertyName]) === 'object') { return _fail(a, b, 'Only one of the properties is an object'); } else if (typeof a[propertyName] === 'function' && typeof b[propertyName] === 'function') { if (a[propertyName].toString() !== b[propertyName].toString()) { return _fail(a, b, 'The functions are different'); } } else if (typeof a[propertyName] === 'function' || typeof b[propertyName] === 'function') { return _fail(a, b, 'Only one of the values is a function'); } else if (strictEquality && a[propertyName] !== b[propertyName]) { var _msg = a[propertyName] == b[propertyName] ? 'The values are different types' : 'The values are not equal'; return _fail(a, b, _msg); } else if (a[propertyName] != b[propertyName]) { return _fail(a, b, 'The values are not equal'); } } return _pass(); } else if (a instanceof Object || b instanceof Object) { // Values are different types. return _fail(a, b, 'Only one of the values is an object'); } /* #endregion */ }); _defineProperty(this, "consoleLog", function () { var shouldLog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; if (shouldLog && typeof _this.log.message !== 'undefined') { console.log("######## %cdeepCompare inequality found! ".concat(_this.log.message, ": %c").concat(_this.log.path, " %c").concat(JSON.stringify(_this.log.a), "%c, %c").concat(JSON.stringify(_this.log.b), "%c"), _this.standardStyles, _this.pathStyles, _this.errorStyles, _this.standardStyles, _this.errorStyles, _this.standardStyles); } return _this; }); _defineProperty(this, "assert", function (assertTrue) { if (assertTrue && _this.value !== assertTrue) { console.error("######## %cdeepCompare inequality found! ".concat(_this.log.message, ": %c").concat(_this.log.path, " %c").concat(JSON.stringify(_this.log.a), "%c, %c").concat(JSON.stringify(_this.log.b), "%c"), _this.standardStyles, _this.pathStyles, _this.errorStyles, _this.standardStyles, _this.errorStyles, _this.standardStyles); } else if (!assertTrue && _this.value !== assertTrue) { console.error("######## deepCompare error! The values are equal but expected inequality."); } return _this; }); _defineProperty(this, "attachLogger", function (clientLogger) { var enableLogger = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; if (typeof clientLogger === 'function' && typeof _this.clientLogger === 'undefined' && enableLogger && typeof _this.log.message !== 'undefined') { clientLogger("######## deepCompare inequality found! ".concat(_this.log.message, ": ").concat(_this.log.path, " ").concat(JSON.stringify(_this.log.a), ", ").concat(JSON.stringify(_this.log.b))); } return _this; }); _defineProperty(this, "_fail", function (a, b, message) { _this._logOutput(a, b, message); _this._decrementDepth(); _this.value = false; return _this; }); _defineProperty(this, "_pass", function () { _this._decrementDepth(); _this.value = true; return _this; }); _defineProperty(this, "_logOutput", function (a, b, message) { // Only capture the first error, not the errors further up. if (typeof _this.log.message === 'undefined') { var path = ''; if (_this.depthTracking.path.length > 0) { path = "obj.".concat(_this.depthTracking.path.join('.')); path = path.replace(/(?:\.\[)/g, '['); } _this.log.message = message; _this.log.a = a; _this.log.b = b; _this.log.path = path; } }); _defineProperty(this, "_incrementDepth", function () { if (typeof _this.depthTracking.depth === 'undefined') { _this.depthTracking.depth = 0; _this.depthTracking.path = []; } else { _this.depthTracking.depth++; } }); _defineProperty(this, "_decrementDepth", function () { if (typeof _this.depthTracking.depth !== 'undefined' && _this.depthTracking.depth > 0) { _this.depthTracking.depth--; } }); _defineProperty(this, "_resetLog", function () { if (typeof _this.depthTracking.depth === 'undefined' || _this.depthTracking.depth === 0) { _this.log = {}; } }); this.value = null; this.depthTracking = {}; this.log = {}; this.errorStyles = 'color:red;'; this.standardStyles = 'color:black;'; this.pathStyles = 'font-style:italic;color:blue;'; } /** * Must be called at the end of the chain to return the result of the comparison. */ _createClass(Compare, [{ key: "isEqual", get: function get() { return this.value; } /** * Set strictEquality to false to coerce conversion if values are different types. Defaults to true. * * @param {*} a * @param {*} b * @param {boolean} strictEquality */ /* #endregion */ }]); return Compare; }(); /* harmony default export */ __webpack_exports__["default"] = (new Compare()); /***/ }), /* 2 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "deepCopy", function() { return deepCopy; }); 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); } var deepCopy = function deepCopy(obj) { if (_typeof(obj) !== 'object' || obj === null) { return obj; } if (obj instanceof Date) { return new Date(obj.getTime()); } if (obj instanceof Array) { return obj.reduce(function (arr, item, i) { arr[i] = deepCopy(item); return arr; }, []); } if (obj instanceof Object) { return Object.keys(obj).reduce(function (newObj, key) { newObj[key] = deepCopy(obj[key]); return newObj; }, {}); } }; /***/ }), /* 3 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d