strange-middle-end
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -26,2 +26,38 @@ 'use strict'; | ||
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 _defineProperty(obj, key, value) { | ||
@@ -377,85 +413,96 @@ if (key in obj) { | ||
return function _callee(dispatch) { | ||
var beginPayload, computedArgs, index, successPayload, error; | ||
return regeneratorRuntime.async(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
beginPayload = transform.apply(void 0, args); | ||
computedArgs = [].concat(beginPayload); | ||
return ( | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee(dispatch) { | ||
var beginPayload, computedArgs, index, successPayload, error; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
beginPayload = transform.apply(void 0, args); | ||
computedArgs = [].concat(beginPayload); | ||
index = function () { | ||
if (!indexed) { | ||
return null; | ||
} | ||
index = function () { | ||
if (!indexed) { | ||
return null; | ||
} | ||
if (typeof indexed === 'string') { | ||
return indexed; | ||
} | ||
if (typeof indexed === 'string') { | ||
return indexed; | ||
} | ||
if (typeof indexed === 'function') { | ||
return indexed.apply(void 0, _toConsumableArray(computedArgs)); | ||
} | ||
if (typeof indexed === 'function') { | ||
return indexed.apply(void 0, _toConsumableArray(computedArgs)); | ||
} | ||
return actionTypes.BASE; | ||
}(); | ||
return actionTypes.BASE; | ||
}(); | ||
_context.prev = 3; | ||
dispatch({ | ||
type: actionTypes.BEGIN, | ||
payload: beginPayload, | ||
meta: { | ||
index: index | ||
} | ||
}); | ||
_context.next = 7; | ||
return regeneratorRuntime.awrap(handler.apply(void 0, _toConsumableArray(computedArgs))); | ||
_context.prev = 3; | ||
dispatch({ | ||
type: actionTypes.BEGIN, | ||
payload: beginPayload, | ||
meta: { | ||
index: index | ||
} | ||
}); | ||
_context.next = 7; | ||
return handler.apply(void 0, _toConsumableArray(computedArgs)); | ||
case 7: | ||
successPayload = _context.sent; | ||
case 7: | ||
successPayload = _context.sent; | ||
if (schema) { | ||
successPayload = Normalizr.normalize(successPayload, schema); | ||
} | ||
if (schema) { | ||
successPayload = Normalizr.normalize(successPayload, schema); | ||
} | ||
dispatch({ | ||
type: actionTypes.SUCCESS, | ||
payload: successPayload, | ||
meta: { | ||
original: beginPayload, | ||
index: index | ||
} | ||
}); // after will possibly fire async | ||
dispatch({ | ||
type: actionTypes.SUCCESS, | ||
payload: successPayload, | ||
meta: { | ||
original: beginPayload, | ||
index: index | ||
} | ||
}); // after will possibly fire async | ||
if (after) { | ||
after({ | ||
original: beginPayload, | ||
result: successPayload | ||
}); | ||
} | ||
if (after) { | ||
after({ | ||
original: beginPayload, | ||
result: successPayload | ||
}); | ||
} | ||
return _context.abrupt("return", [null, successPayload]); | ||
return _context.abrupt("return", [null, successPayload]); | ||
case 14: | ||
_context.prev = 14; | ||
_context.t0 = _context["catch"](3); | ||
error = internals$1.ensureError(_context.t0); | ||
dispatch({ | ||
type: actionTypes.FAIL, | ||
payload: error, | ||
error: true, | ||
meta: { | ||
original: beginPayload, | ||
index: index | ||
} | ||
}); | ||
return _context.abrupt("return", [error]); | ||
case 14: | ||
_context.prev = 14; | ||
_context.t0 = _context["catch"](3); | ||
error = internals$1.ensureError(_context.t0); | ||
dispatch({ | ||
type: actionTypes.FAIL, | ||
payload: error, | ||
error: true, | ||
meta: { | ||
original: beginPayload, | ||
index: index | ||
} | ||
}); | ||
return _context.abrupt("return", [error]); | ||
case 19: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, null, null, [[3, 14]]); | ||
}; | ||
case 19: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, null, [[3, 14]]); | ||
})); | ||
return function (_x) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}() | ||
); | ||
}; | ||
@@ -462,0 +509,0 @@ }; |
@@ -20,2 +20,38 @@ import { combineReducers } from 'redux'; | ||
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 _defineProperty(obj, key, value) { | ||
@@ -371,85 +407,96 @@ if (key in obj) { | ||
return function _callee(dispatch) { | ||
var beginPayload, computedArgs, index, successPayload, error; | ||
return regeneratorRuntime.async(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
beginPayload = transform.apply(void 0, args); | ||
computedArgs = [].concat(beginPayload); | ||
return ( | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee(dispatch) { | ||
var beginPayload, computedArgs, index, successPayload, error; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
beginPayload = transform.apply(void 0, args); | ||
computedArgs = [].concat(beginPayload); | ||
index = function () { | ||
if (!indexed) { | ||
return null; | ||
} | ||
index = function () { | ||
if (!indexed) { | ||
return null; | ||
} | ||
if (typeof indexed === 'string') { | ||
return indexed; | ||
} | ||
if (typeof indexed === 'string') { | ||
return indexed; | ||
} | ||
if (typeof indexed === 'function') { | ||
return indexed.apply(void 0, _toConsumableArray(computedArgs)); | ||
} | ||
if (typeof indexed === 'function') { | ||
return indexed.apply(void 0, _toConsumableArray(computedArgs)); | ||
} | ||
return actionTypes.BASE; | ||
}(); | ||
return actionTypes.BASE; | ||
}(); | ||
_context.prev = 3; | ||
dispatch({ | ||
type: actionTypes.BEGIN, | ||
payload: beginPayload, | ||
meta: { | ||
index: index | ||
} | ||
}); | ||
_context.next = 7; | ||
return regeneratorRuntime.awrap(handler.apply(void 0, _toConsumableArray(computedArgs))); | ||
_context.prev = 3; | ||
dispatch({ | ||
type: actionTypes.BEGIN, | ||
payload: beginPayload, | ||
meta: { | ||
index: index | ||
} | ||
}); | ||
_context.next = 7; | ||
return handler.apply(void 0, _toConsumableArray(computedArgs)); | ||
case 7: | ||
successPayload = _context.sent; | ||
case 7: | ||
successPayload = _context.sent; | ||
if (schema) { | ||
successPayload = normalize(successPayload, schema); | ||
} | ||
if (schema) { | ||
successPayload = normalize(successPayload, schema); | ||
} | ||
dispatch({ | ||
type: actionTypes.SUCCESS, | ||
payload: successPayload, | ||
meta: { | ||
original: beginPayload, | ||
index: index | ||
} | ||
}); // after will possibly fire async | ||
dispatch({ | ||
type: actionTypes.SUCCESS, | ||
payload: successPayload, | ||
meta: { | ||
original: beginPayload, | ||
index: index | ||
} | ||
}); // after will possibly fire async | ||
if (after) { | ||
after({ | ||
original: beginPayload, | ||
result: successPayload | ||
}); | ||
} | ||
if (after) { | ||
after({ | ||
original: beginPayload, | ||
result: successPayload | ||
}); | ||
} | ||
return _context.abrupt("return", [null, successPayload]); | ||
return _context.abrupt("return", [null, successPayload]); | ||
case 14: | ||
_context.prev = 14; | ||
_context.t0 = _context["catch"](3); | ||
error = internals$1.ensureError(_context.t0); | ||
dispatch({ | ||
type: actionTypes.FAIL, | ||
payload: error, | ||
error: true, | ||
meta: { | ||
original: beginPayload, | ||
index: index | ||
} | ||
}); | ||
return _context.abrupt("return", [error]); | ||
case 14: | ||
_context.prev = 14; | ||
_context.t0 = _context["catch"](3); | ||
error = internals$1.ensureError(_context.t0); | ||
dispatch({ | ||
type: actionTypes.FAIL, | ||
payload: error, | ||
error: true, | ||
meta: { | ||
original: beginPayload, | ||
index: index | ||
} | ||
}); | ||
return _context.abrupt("return", [error]); | ||
case 19: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, null, null, [[3, 14]]); | ||
}; | ||
case 19: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, null, [[3, 14]]); | ||
})); | ||
return function (_x) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}() | ||
); | ||
}; | ||
@@ -456,0 +503,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("redux"),require("normalizr"),require("redux-thunk"),require("immer")):"function"==typeof define&&define.amd?define(["exports","redux","normalizr","redux-thunk","immer"],t):t((e=e||self).StrangeMiddleEnd={},e.Redux,e.normalizr,e.ReduxThunk,e.immer)}(this,(function(e,t,r,n,i){"use strict";function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(r,!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(r).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw o}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function l(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}n=n&&n.hasOwnProperty("default")?n.default:n;var s={},d={thunk:n,errorLogger:function(){return function(e){return function(t){var r=t.type,n=t.error,i=t.payload,o=t.meta;return n&&console.error('Error from action "'.concat(r,'"'),o,"\n",i),e(t)}}}};s.pickEach=function(e,t){return Object.entries(e).filter((function(e){var r=f(e,2)[1];return r&&void 0!==r[t]})).reduce((function(e,r){var n=f(r,2);return c({},e,a({},n[0],n[1][t]))}),{})},s.mapEachLeafFunction=function(e,t){return Object.entries(e).reduce((function(e,r){var n=f(r,2),i=n[0],u=n[1];return c({},e,a({},i,"function"==typeof u?t(u):u&&"object"===o(u)?s.mapEachLeafFunction(u,t):u))}),{})};var p={};p.simpleAction=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"function"==typeof t&&(t={transform:t});var r=t,n=r.transform,i=void 0===n?p.defaultTransform:n;return function(){return{type:e,payload:i.apply(void 0,arguments)}}},p.asyncAction=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"function"==typeof t&&(t={handler:t});var n=t,i=n.handler,o=void 0===i?p.defaultTransform:i,a=n.transform,u=void 0===a?p.defaultTransform:a,c=n.after,f=n.schema,s=n.index,d=void 0!==s&&s;return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return function(t){var i,a,s,y,v;return regeneratorRuntime.async((function(h){for(;;)switch(h.prev=h.next){case 0:return i=u.apply(void 0,n),a=[].concat(i),s=d?"string"==typeof d?d:"function"==typeof d?d.apply(void 0,l(a)):e.BASE:null,h.prev=3,t({type:e.BEGIN,payload:i,meta:{index:s}}),h.next=7,regeneratorRuntime.awrap(o.apply(void 0,l(a)));case 7:return y=h.sent,f&&(y=r.normalize(y,f)),t({type:e.SUCCESS,payload:y,meta:{original:i,index:s}}),c&&c({original:i,result:y}),h.abrupt("return",[null,y]);case 14:return h.prev=14,h.t0=h.catch(3),v=p.ensureError(h.t0),t({type:e.FAIL,payload:v,error:!0,meta:{original:i,index:s}}),h.abrupt("return",[v]);case 19:case"end":return h.stop()}}),null,null,[[3,14]])}}},p.defaultTransform=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.length<=1?t[0]:t},p.ensureError=function(e){if(e instanceof Error)return e;var t=new Error(e.message);return t.data=e,t};var y=function(e){return e.endsWith("/BEGIN")},v=function(e){return e.endsWith("/SUCCESS")},h=function(e){return e.endsWith("/FAIL")},m={};m.defaultShouldMerge=function(e){return Boolean(e._top)},m.getInitialEntityState=function(e){return Object.values(e).filter((function(e){return e instanceof r.schema.Entity})).reduce((function(e,t){return c({},e,a({},t.key,{}))}),{})},m.isNormalizedPayload=function(e){return e&&e.hasOwnProperty("result")&&e.entities};var b=function(n){var i=n.createStore,o=n.mods,a=void 0===o?{}:o,u={initialized:!1,initialize:function(){return!1!==u.initialized?u:(u.initialized=null,Object.values(s.pickEach(u.mods,"schema")).forEach((function(t){Object.values(t).filter((function(e){return e instanceof r.schema.Entity})).forEach((function(r){r.relatedFields=function(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e).relatedFields.apply(t,i.concat([{idAttribute:r.idAttribute}]))},r.relations&&r.define(r.relations(t))}))})),Object.values(u.mods).filter((function(e){return e&&e.initialize})).forEach((function(e){return e.initialize(u,e)})),u.initialized=!0,u)}},c=function(e,t){Object.defineProperty(u,e,{configurable:!0,enumerable:!0,get:function(){if(!1===u.initialized)throw new Error('Cannot access property "'.concat(e,'" until middle-end is initialized.'));var r=t();return Object.defineProperty(u,e,{value:r,writable:!0}),r}})};return c("mods",(function(){return"function"==typeof a?a():a})),c("store",(function(){var e=t.combineReducers(s.pickEach(u.mods,"reducer"));return i(e,u.mods)})),c("getState",(function(){return u.store.getState})),c("dispatch",(function(){var e=function(){var e;return(e=u.store).dispatch.apply(e,arguments)};return Object.entries(u.actions).forEach((function(t){var r=f(t,2),n=r[0],i=r[1];e[n]={},Object.entries(i).forEach((function(t){var r=f(t,2),i=r[0],o=r[1];e[n][i]=function(){return e(o.apply(void 0,arguments))}}))})),e})),c("actions",(function(){return s.pickEach(u.mods,"actions")})),c("select",(function(){var e=u.selectors,t=u.getState;return s.mapEachLeafFunction(e,(function(e){return function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return e.apply(void 0,[t()].concat(n))}}))})),c("selectors",(function(){return s.pickEach(u.mods,"selectors")})),u},g=d,E=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.idAttribute,i=void 0===n?"id":n,o=a({},i,e[i]);return t.forEach((function(t){e.hasOwnProperty(t)&&(o[t]=e[t])})),Object.keys(o).length>1?o:void 0},O=function(e,t){return"string"==typeof e?p.simpleAction(e,t):p.asyncAction(e,t)},S=function(e,t){return t||(t=e,e=null),e=e?"".concat(e,"/"):"",Object.entries(t).reduce((function(t,r){var n=f(r,2),i=n[0],o=n[1],u="".concat(e).concat(i);return o.isAsync?c({},t,a({},i,{BASE:u,BEGIN:"".concat(u,"/BEGIN"),SUCCESS:"".concat(u,"/SUCCESS"),FAIL:"".concat(u,"/FAIL")})):o.isSimple||!0===o?c({},t,a({},i,u)):c({},t,a({},i,o))}),{})},j={async:{isAsync:!0},simple:{isSimple:!0}},w=function(e,t){return e.startsWith("".concat(t,"/"))||e===t},A=y,x=v,P=h,z=function(e,t,r){if(void 0===r&&(r=t,t=e,e={}),r.hasOwnProperty("undefined"))throw new Error("Reducer has an undefined handler. Ensure that all actions used in this reducer exist.");var n=e.mutable;void 0!==n&&n&&(r=c({},r),Object.keys(r).forEach((function(e){r[e]=i.produce(r[e])})));var o=function(e){return"function"==typeof e?e():e};return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o(t),n=arguments.length>1?arguments[1]:void 0;return r.hasOwnProperty(n.type)?r[n.type](e,n):e}},k=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.schema,n=void 0===r?{}:r,o=e.shouldMerge,a=void 0===o?m.defaultShouldMerge:o,u=e.shouldIndex,c=void 0===u||u,l="function"==typeof a?a:function(){return a},s="function"==typeof c?c:function(){return c};return t.combineReducers({indexes:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0,r=t.type,n=t.payload,o=t.error,a=t.meta;return a&&a.index&&s(a.index)?i.produce(e,(function(e){var t=e[a.index]=e[a.index]||{original:void 0,result:void 0,error:null,inFlight:0};y(r)&&(t.inFlight++,t.original=n),(v(r)||h(r))&&(t.inFlight--,a.hasOwnProperty("original")&&(t.original=a.original)),v(r)&&(t.result=m.isNormalizedPayload(n)?n.result:n,t.error=null),o&&(t.error=n||!0)})):e},entities:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m.getInitialEntityState(n),t=arguments.length>1?arguments[1]:void 0,r=t.payload,o=t.error;return o||!m.isNormalizedPayload(r)?e:i.produce(e,(function(t){var n=r.entities;Object.keys(n).forEach((function(r){e[r]&&Object.keys(n[r]).forEach((function(e){var i=n[r][e];l(i)?(t[r][e]=t[r][e]||{},Object.entries(i).forEach((function(n){var i=f(n,2),o=i[0],a=i[1];void 0!==a&&(t[r][e][o]=a)}))):t[r][e]=i}))}))}))}})};e.create=b,e.createAction=O,e.createEntityReducer=k,e.createReducer=z,e.createTypes=S,e.isTypeBegin=A,e.isTypeFail=P,e.isTypeOfBase=w,e.isTypeSuccess=x,e.middleware=g,e.relatedFields=E,e.type=j})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("redux"),require("normalizr"),require("redux-thunk"),require("immer")):"function"==typeof define&&define.amd?define(["exports","redux","normalizr","redux-thunk","immer"],t):t((e=e||self).StrangeMiddleEnd={},e.Redux,e.normalizr,e.ReduxThunk,e.immer)}(this,(function(e,t,r,n,i){"use strict";function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t,r,n,i,o,u){try{var a=e[o](u),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,i)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){u(o,n,i,a,c,"next",e)}function c(e){u(o,n,i,a,c,"throw",e)}a(void 0)}))}}function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(r,!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(r).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var u,a=e[Symbol.iterator]();!(n=(u=a.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw o}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function d(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}n=n&&n.hasOwnProperty("default")?n.default:n;var p={},y={thunk:n,errorLogger:function(){return function(e){return function(t){var r=t.type,n=t.error,i=t.payload,o=t.meta;return n&&console.error('Error from action "'.concat(r,'"'),o,"\n",i),e(t)}}}};p.pickEach=function(e,t){return Object.entries(e).filter((function(e){var r=s(e,2)[1];return r&&void 0!==r[t]})).reduce((function(e,r){var n=s(r,2);return l({},e,c({},n[0],n[1][t]))}),{})},p.mapEachLeafFunction=function(e,t){return Object.entries(e).reduce((function(e,r){var n=s(r,2),i=n[0],u=n[1];return l({},e,c({},i,"function"==typeof u?t(u):u&&"object"===o(u)?p.mapEachLeafFunction(u,t):u))}),{})};var v={};v.simpleAction=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"function"==typeof t&&(t={transform:t});var r=t,n=r.transform,i=void 0===n?v.defaultTransform:n;return function(){return{type:e,payload:i.apply(void 0,arguments)}}},v.asyncAction=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"function"==typeof t&&(t={handler:t});var n=t,i=n.handler,o=void 0===i?v.defaultTransform:i,u=n.transform,c=void 0===u?v.defaultTransform:u,f=n.after,l=n.schema,s=n.index,p=void 0!==s&&s;return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return function(){var t=a(regeneratorRuntime.mark((function t(i){var u,a,s,y,h;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=c.apply(void 0,n),a=[].concat(u),s=p?"string"==typeof p?p:"function"==typeof p?p.apply(void 0,d(a)):e.BASE:null,t.prev=3,i({type:e.BEGIN,payload:u,meta:{index:s}}),t.next=7,o.apply(void 0,d(a));case 7:return y=t.sent,l&&(y=r.normalize(y,l)),i({type:e.SUCCESS,payload:y,meta:{original:u,index:s}}),f&&f({original:u,result:y}),t.abrupt("return",[null,y]);case 14:return t.prev=14,t.t0=t.catch(3),h=v.ensureError(t.t0),i({type:e.FAIL,payload:h,error:!0,meta:{original:u,index:s}}),t.abrupt("return",[h]);case 19:case"end":return t.stop()}}),t,null,[[3,14]])})));return function(e){return t.apply(this,arguments)}}()}},v.defaultTransform=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.length<=1?t[0]:t},v.ensureError=function(e){if(e instanceof Error)return e;var t=new Error(e.message);return t.data=e,t};var h=function(e){return e.endsWith("/BEGIN")},m=function(e){return e.endsWith("/SUCCESS")},b=function(e){return e.endsWith("/FAIL")},g={};g.defaultShouldMerge=function(e){return Boolean(e._top)},g.getInitialEntityState=function(e){return Object.values(e).filter((function(e){return e instanceof r.schema.Entity})).reduce((function(e,t){return l({},e,c({},t.key,{}))}),{})},g.isNormalizedPayload=function(e){return e&&e.hasOwnProperty("result")&&e.entities};var E=function(n){var i=n.createStore,o=n.mods,u=void 0===o?{}:o,a={initialized:!1,initialize:function(){return!1!==a.initialized?a:(a.initialized=null,Object.values(p.pickEach(a.mods,"schema")).forEach((function(t){Object.values(t).filter((function(e){return e instanceof r.schema.Entity})).forEach((function(r){r.relatedFields=function(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e).relatedFields.apply(t,i.concat([{idAttribute:r.idAttribute}]))},r.relations&&r.define(r.relations(t))}))})),Object.values(a.mods).filter((function(e){return e&&e.initialize})).forEach((function(e){return e.initialize(a,e)})),a.initialized=!0,a)}},c=function(e,t){Object.defineProperty(a,e,{configurable:!0,enumerable:!0,get:function(){if(!1===a.initialized)throw new Error('Cannot access property "'.concat(e,'" until middle-end is initialized.'));var r=t();return Object.defineProperty(a,e,{value:r,writable:!0}),r}})};return c("mods",(function(){return"function"==typeof u?u():u})),c("store",(function(){var e=t.combineReducers(p.pickEach(a.mods,"reducer"));return i(e,a.mods)})),c("getState",(function(){return a.store.getState})),c("dispatch",(function(){var e=function(){var e;return(e=a.store).dispatch.apply(e,arguments)};return Object.entries(a.actions).forEach((function(t){var r=s(t,2),n=r[0],i=r[1];e[n]={},Object.entries(i).forEach((function(t){var r=s(t,2),i=r[0],o=r[1];e[n][i]=function(){return e(o.apply(void 0,arguments))}}))})),e})),c("actions",(function(){return p.pickEach(a.mods,"actions")})),c("select",(function(){var e=a.selectors,t=a.getState;return p.mapEachLeafFunction(e,(function(e){return function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return e.apply(void 0,[t()].concat(n))}}))})),c("selectors",(function(){return p.pickEach(a.mods,"selectors")})),a},O=y,S=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.idAttribute,i=void 0===n?"id":n,o=c({},i,e[i]);return t.forEach((function(t){e.hasOwnProperty(t)&&(o[t]=e[t])})),Object.keys(o).length>1?o:void 0},j=function(e,t){return"string"==typeof e?v.simpleAction(e,t):v.asyncAction(e,t)},w=function(e,t){return t||(t=e,e=null),e=e?"".concat(e,"/"):"",Object.entries(t).reduce((function(t,r){var n=s(r,2),i=n[0],o=n[1],u="".concat(e).concat(i);return o.isAsync?l({},t,c({},i,{BASE:u,BEGIN:"".concat(u,"/BEGIN"),SUCCESS:"".concat(u,"/SUCCESS"),FAIL:"".concat(u,"/FAIL")})):o.isSimple||!0===o?l({},t,c({},i,u)):l({},t,c({},i,o))}),{})},A={async:{isAsync:!0},simple:{isSimple:!0}},x=function(e,t){return e.startsWith("".concat(t,"/"))||e===t},P=h,k=m,z=b,F=function(e,t,r){if(void 0===r&&(r=t,t=e,e={}),r.hasOwnProperty("undefined"))throw new Error("Reducer has an undefined handler. Ensure that all actions used in this reducer exist.");var n=e.mutable;void 0!==n&&n&&(r=l({},r),Object.keys(r).forEach((function(e){r[e]=i.produce(r[e])})));var o=function(e){return"function"==typeof e?e():e};return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o(t),n=arguments.length>1?arguments[1]:void 0;return r.hasOwnProperty(n.type)?r[n.type](e,n):e}},I=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.schema,n=void 0===r?{}:r,o=e.shouldMerge,u=void 0===o?g.defaultShouldMerge:o,a=e.shouldIndex,c=void 0===a||a,f="function"==typeof u?u:function(){return u},l="function"==typeof c?c:function(){return c};return t.combineReducers({indexes:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0,r=t.type,n=t.payload,o=t.error,u=t.meta;return u&&u.index&&l(u.index)?i.produce(e,(function(e){var t=e[u.index]=e[u.index]||{original:void 0,result:void 0,error:null,inFlight:0};h(r)&&(t.inFlight++,t.original=n),(m(r)||b(r))&&(t.inFlight--,u.hasOwnProperty("original")&&(t.original=u.original)),m(r)&&(t.result=g.isNormalizedPayload(n)?n.result:n,t.error=null),o&&(t.error=n||!0)})):e},entities:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:g.getInitialEntityState(n),t=arguments.length>1?arguments[1]:void 0,r=t.payload,o=t.error;return o||!g.isNormalizedPayload(r)?e:i.produce(e,(function(t){var n=r.entities;Object.keys(n).forEach((function(r){e[r]&&Object.keys(n[r]).forEach((function(e){var i=n[r][e];f(i)?(t[r][e]=t[r][e]||{},Object.entries(i).forEach((function(n){var i=s(n,2),o=i[0],u=i[1];void 0!==u&&(t[r][e][o]=u)}))):t[r][e]=i}))}))}))}})};e.create=E,e.createAction=j,e.createEntityReducer=I,e.createReducer=F,e.createTypes=w,e.isTypeBegin=P,e.isTypeFail=z,e.isTypeOfBase=x,e.isTypeSuccess=k,e.middleware=O,e.relatedFields=S,e.type=A})); | ||
//# sourceMappingURL=strange-middle-end.umd.min.js.map |
{ | ||
"name": "strange-middle-end", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "a middle-end composer using redux, normalizr, and immer", | ||
@@ -39,3 +39,3 @@ "main": "dist/strange-middle-end.js", | ||
"redux-thunk": "2.x.x", | ||
"immer": ">=1 <6", | ||
"immer": ">=1 <7", | ||
"normalizr": "3.x.x" | ||
@@ -58,3 +58,3 @@ }, | ||
"rollup-plugin-terser": "5.x.x", | ||
"immer": "5.x.x", | ||
"immer": "6.x.x", | ||
"normalizr": "3.x.x", | ||
@@ -61,0 +61,0 @@ "npm-run-all": "4.x.x", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
159472
1721
0