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

@rest-hooks/normalizr

Package Overview
Dependencies
Maintainers
1
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rest-hooks/normalizr - npm Package Compare versions

Comparing version 3.4.2 to 3.4.3

99

dist/normalizr.amd.js

@@ -1,7 +0,52 @@

define(['exports', '@babel/runtime/helpers/esm/objectSpread', '@babel/runtime/helpers/esm/createClass', '@babel/runtime/helpers/esm/inheritsLoose'], function (exports, _objectSpread, _createClass, _inheritsLoose) { 'use strict';
define(['exports'], function (exports) { 'use strict';
_objectSpread = _objectSpread && _objectSpread.hasOwnProperty('default') ? _objectSpread['default'] : _objectSpread;
_createClass = _createClass && _createClass.hasOwnProperty('default') ? _createClass['default'] : _createClass;
_inheritsLoose = _inheritsLoose && _inheritsLoose.hasOwnProperty('default') ? _inheritsLoose['default'] : _inheritsLoose;
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 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 _objectSpread2(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;
}
/**

@@ -47,2 +92,18 @@ * Helpers to enable Immutable compatibility *without* bringing in

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;
}
var getDefaultGetId = function getDefaultGetId(idAttribute) {

@@ -75,7 +136,7 @@ return function (input) {

mergeStrategy = _options$mergeStrateg === void 0 ? function (entityA, entityB) {
return _objectSpread({}, entityA, entityB);
return _objectSpread2({}, entityA, {}, entityB);
} : _options$mergeStrateg,
_options$processStrat = _options.processStrategy,
processStrategy = _options$processStrat === void 0 ? function (input) {
return _objectSpread({}, input);
return _objectSpread2({}, input);
} : _options$processStrat;

@@ -94,6 +155,6 @@ this._key = key;

this.schema = Object.keys(definition).reduce(function (entitySchema, key) {
var _objectSpread2;
var _objectSpread2$1;
var schema = definition[key];
return _objectSpread({}, entitySchema, (_objectSpread2 = {}, _objectSpread2[key] = schema, _objectSpread2));
return _objectSpread2({}, entitySchema, (_objectSpread2$1 = {}, _objectSpread2$1[key] = schema, _objectSpread2$1));
}, this.schema || {});

@@ -164,2 +225,8 @@ };

function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
var PolymorphicSchema =

@@ -274,6 +341,6 @@ /*#__PURE__*/

return Object.keys(input).reduce(function (output, key, index) {
var _objectSpread2;
var _objectSpread2$1;
var value = input[key];
return value !== undefined && value !== null ? _objectSpread({}, output, (_objectSpread2 = {}, _objectSpread2[key] = _this.normalizeValue(value, input, key, visit, addEntity, visitedEntities), _objectSpread2)) : output;
return value !== undefined && value !== null ? _objectSpread2({}, output, (_objectSpread2$1 = {}, _objectSpread2$1[key] = _this.normalizeValue(value, input, key, visit, addEntity, visitedEntities), _objectSpread2$1)) : output;
}, {});

@@ -289,3 +356,3 @@ };

var entityOrId = input[key];
return _objectSpread({}, output, (_objectSpread3 = {}, _objectSpread3[key] = _this2.denormalizeValue(entityOrId, unvisit), _objectSpread3));
return _objectSpread2({}, output, (_objectSpread3 = {}, _objectSpread3[key] = _this2.denormalizeValue(entityOrId, unvisit), _objectSpread3));
}, {});

@@ -363,3 +430,3 @@ };

var _normalize = function normalize(schema, input, parent, key, visit, addEntity, visitedEntities) {
var object = _objectSpread({}, input);
var object = _objectSpread2({}, input);

@@ -384,3 +451,3 @@ Object.keys(schema).forEach(function (key) {

var object = _objectSpread({}, input);
var object = _objectSpread2({}, input);

@@ -406,6 +473,6 @@ Object.keys(schema).forEach(function (key) {

this.schema = Object.keys(definition).reduce(function (entitySchema, key) {
var _objectSpread2;
var _objectSpread2$1;
var schema = definition[key];
return _objectSpread({}, entitySchema, (_objectSpread2 = {}, _objectSpread2[key] = schema, _objectSpread2));
return _objectSpread2({}, entitySchema, (_objectSpread2$1 = {}, _objectSpread2$1[key] = schema, _objectSpread2$1));
}, this.schema || {});

@@ -500,3 +567,3 @@ };

// Ensure we don't mutate it non-immutable objects
var entityCopy = isImmutable(entity) ? entity : _objectSpread({}, entity); // Need to set this first so that if it is referenced further within the
var entityCopy = isImmutable(entity) ? entity : _objectSpread2({}, entity); // Need to set this first so that if it is referenced further within the
// denormalization the reference will already exist.

@@ -503,0 +570,0 @@

2

dist/normalizr.amd.min.js

@@ -1,1 +0,1 @@

define(["exports","@babel/runtime/helpers/esm/objectSpread","@babel/runtime/helpers/esm/createClass","@babel/runtime/helpers/esm/inheritsLoose"],function(e,t,n,r){"use strict";function i(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function o(e,t,n){return Object.keys(e).reduce(function(t,r){var i=""+r;return t.has(i)?t.set(i,n(t.get(i),e[i])):t},t)}t=t&&t.hasOwnProperty("default")?t.default:t,n=n&&n.hasOwnProperty("default")?n.default:n,r=r&&r.hasOwnProperty("default")?r.default:r;var u=function(e){return function(t){return i(t)?t.get(e):t[e]}},a=function(){function e(e,n,r){if(void 0===n&&(n={}),void 0===r&&(r={}),!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");var i=r,o=i.idAttribute,a=void 0===o?"id":o,c=i.mergeStrategy,s=void 0===c?function(e,n){return t({},e,n)}:c,f=i.processStrategy,h=void 0===f?function(e){return t({},e)}:f;this._key=e,this._getId="function"==typeof a?a:u(a),this._idAttribute=a,this._mergeStrategy=s,this._processStrategy=h,this.define(n)}var r=e.prototype;return r.define=function(e){this.schema=Object.keys(e).reduce(function(n,r){var i,o=e[r];return t({},n,((i={})[r]=o,i))},this.schema||{})},r.getId=function(e,t,n){return this._getId(e,t,n)},r.merge=function(e,t){return this._mergeStrategy(e,t)},r.normalize=function(e,t,n,r,i,o){var u=this;if(o.some(function(t){return t===e}))return this.getId(e,t,n);o.push(e);var a=this._processStrategy(e,t,n);return Object.keys(this.schema).forEach(function(e){if(a.hasOwnProperty(e)&&"object"==typeof a[e]){var t=u.schema[e];a[e]=r(a[e],a,e,t,i,o)}}),i(this,a,e,t,n),this.getId(e,t,n)},r.denormalize=function(e,t){var n=this;return i(e)?o(this.schema,e,t):(Object.keys(this.schema).forEach(function(r){if(e.hasOwnProperty(r)){var i=n.schema[r];e[r]=t(e[r],i)}}),e)},n(e,[{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),e}(),c=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=e},t.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},t.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},t.normalizeValue=function(e,t,n,r,i,o){var u=this.inferSchema(e,t,n);if(!u)return e;var a=r(e,t,n,u,i,o);return this.isSingleSchema||null==a?a:{id:a,schema:this.getSchemaAttribute(e,t,n)}},t.denormalizeValue=function(e,t){var n=i(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?t((i(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[n]):e},n(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),s=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},t}(c),f=function(e){function n(){return e.apply(this,arguments)||this}r(n,e);var i=n.prototype;return i.normalize=function(e,n,r,i,o,u){var a=this;return Object.keys(e).reduce(function(n,r,c){var s,f=e[r];return null!=f?t({},n,((s={})[r]=a.normalizeValue(f,e,r,i,o,u),s)):n},{})},i.denormalize=function(e,n){var r=this;return Object.keys(e).reduce(function(i,o){var u,a=e[o];return t({},i,((u={})[o]=r.denormalizeValue(a,n),u))},{})},n}(c),h=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},l=function(e){return Array.isArray(e)?e:Object.keys(e).map(function(t){return e[t]})},m=function(e,t,n,r,i,o,u){return e=h(e),l(t).map(function(t,a){return i(t,n,r,e,o,u)})},y=function(e,t,n){return e=h(e),t&&t.map?t.map(function(t){return n(t,e)}):t},p=function(e){function t(){return e.apply(this,arguments)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var u=this;return l(e).map(function(e,a){return u.normalizeValue(e,t,n,r,i,o)}).filter(function(e){return null!=e})},n.denormalize=function(e,t){var n=this;return e&&e.map?e.map(function(e){return n.denormalizeValue(e,t)}):e},t}(c),d=function(e,n,r,i,o,u,a){var c=t({},n);return Object.keys(e).forEach(function(t){var r=e[t],i=o(n[t],n,t,r,u,a);null==i?delete c[t]:c[t]=i}),c},v=function(e,n,r){if(i(n))return o(e,n,r);var u=t({},n);return Object.keys(e).forEach(function(t){null!=u[t]&&(u[t]=r(u[t],e[t]))}),u},g=function e(t,n,r,i,o,u){return"object"==typeof t&&t?"object"!=typeof i||i.normalize&&"function"==typeof i.normalize?i.normalize(t,n,r,e,o,u):(Array.isArray(i)?m:d)(i,t,n,r,e,o,u):t},b={Array:p,Entity:a,Object:function(){function e(e){this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=Object.keys(e).reduce(function(n,r){var i,o=e[r];return t({},n,((i={})[r]=o,i))},this.schema||{})},n.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return d.apply(void 0,[this.schema].concat(t))},n.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.apply(void 0,[this.schema].concat(t))},e}(),Union:s,Values:f},z=function(e){var n={},r=S(e);return function e(o,u){return"object"!=typeof u||u.denormalize&&"function"==typeof u.denormalize?null==o?o:u instanceof a?function(e,n,r,o,u){var a=o(e,n);if("object"!=typeof a||null===a)return a;if(u[n.key]||(u[n.key]={}),!u[n.key][e]){var c=i(a)?a:t({},a);u[n.key][e]=c,u[n.key][e]=n.denormalize(c,r)}return u[n.key][e]}(o,u,e,r,n):"function"==typeof u.denormalize?u.denormalize(o,e):o:(Array.isArray(u)?y:v)(u,o,e)}},S=function(e){var t=i(e);return function(n,r){var i=r.key;return"object"==typeof n?n:t?e.getIn([i,n.toString()]):e[i]&&e[i][n]}};e.denormalize=function(e,t,n){if(void 0!==e)return z(n)(e,t)},e.normalize=function(e,t){if(!e||"object"!=typeof e)throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+(null===e?"null":typeof e)+'".');var n={},r=function(e){return function(t,n,r,i,o){var u=t.key,a=t.getId(r,i,o);u in e||(e[u]={});var c=e[u][a];e[u][a]=c?t.merge(c,n):n}}(n);return{entities:n,result:g(e,e,null,t,r,[])}},e.schema=b,Object.defineProperty(e,"__esModule",{value:!0})});
define(["exports"],(function(e){"use strict";function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(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 n(e){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?r(i,!0).forEach((function(r){t(e,r,i[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(i).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function i(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function o(e,t,r){return Object.keys(e).reduce((function(t,n){var i=""+n;return t.has(i)?t.set(i,r(t.get(i),e[i])):t}),t)}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),e}var a=function(e){return function(t){return i(t)?t.get(e):t[e]}},f=function(){function e(e,t,r){if(void 0===t&&(t={}),void 0===r&&(r={}),!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");var i=r,o=i.idAttribute,u=void 0===o?"id":o,c=i.mergeStrategy,f=void 0===c?function(e,t){return n({},e,{},t)}:c,s=i.processStrategy,h=void 0===s?function(e){return n({},e)}:s;this._key=e,this._getId="function"==typeof u?u:a(u),this._idAttribute=u,this._mergeStrategy=f,this._processStrategy=h,this.define(t)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,r){var i,o=e[r];return n({},t,((i={})[r]=o,i))}),this.schema||{})},t.getId=function(e,t,r){return this._getId(e,t,r)},t.merge=function(e,t){return this._mergeStrategy(e,t)},t.normalize=function(e,t,r,n,i,o){var u=this;if(o.some((function(t){return t===e})))return this.getId(e,t,r);o.push(e);var c=this._processStrategy(e,t,r);return Object.keys(this.schema).forEach((function(e){if(c.hasOwnProperty(e)&&"object"==typeof c[e]){var t=u.schema[e];c[e]=n(c[e],c,e,t,i,o)}})),i(this,c,e,t,r),this.getId(e,t,r)},t.denormalize=function(e,t){var r=this;return i(e)?o(this.schema,e,t):(Object.keys(this.schema).forEach((function(n){if(e.hasOwnProperty(n)){var i=r.schema[n];e[n]=t(e[n],i)}})),e)},c(e,[{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),e}();function s(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var h=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=e},t.getSchemaAttribute=function(e,t,r){return!this.isSingleSchema&&this._schemaAttribute(e,t,r)},t.inferSchema=function(e,t,r){if(this.isSingleSchema)return this.schema;var n=this.getSchemaAttribute(e,t,r);return this.schema[n]},t.normalizeValue=function(e,t,r,n,i,o){var u=this.inferSchema(e,t,r);if(!u)return e;var c=n(e,t,r,u,i,o);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,r)}},t.denormalizeValue=function(e,t){var r=i(e)?e.get("schema"):e.schema;return this.isSingleSchema||r?t((i(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):e},c(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),l=function(e){function t(t,r){if(!r)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,r)||this}s(t,e);var r=t.prototype;return r.normalize=function(e,t,r,n,i,o){return this.normalizeValue(e,t,r,n,i,o)},r.denormalize=function(e,t){return this.denormalizeValue(e,t)},t}(h),y=function(e){function t(){return e.apply(this,arguments)||this}s(t,e);var r=t.prototype;return r.normalize=function(e,t,r,i,o,u){var c=this;return Object.keys(e).reduce((function(t,r,a){var f,s=e[r];return null!=s?n({},t,((f={})[r]=c.normalizeValue(s,e,r,i,o,u),f)):t}),{})},r.denormalize=function(e,t){var r=this;return Object.keys(e).reduce((function(i,o){var u,c=e[o];return n({},i,((u={})[o]=r.denormalizeValue(c,t),u))}),{})},t}(h),p=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},m=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},d=function(e,t,r,n,i,o,u){return e=p(e),m(t).map((function(t,c){return i(t,r,n,e,o,u)}))},v=function(e,t,r){return e=p(e),t&&t.map?t.map((function(t){return r(t,e)})):t},b=function(e){function t(){return e.apply(this,arguments)||this}s(t,e);var r=t.prototype;return r.normalize=function(e,t,r,n,i,o){var u=this;return m(e).map((function(e,c){return u.normalizeValue(e,t,r,n,i,o)})).filter((function(e){return null!=e}))},r.denormalize=function(e,t){var r=this;return e&&e.map?e.map((function(e){return r.denormalizeValue(e,t)})):e},t}(h),g=function(e,t,r,i,o,u,c){var a=n({},t);return Object.keys(e).forEach((function(r){var n=e[r],i=o(t[r],t,r,n,u,c);null==i?delete a[r]:a[r]=i})),a},O=function(e,t,r){if(i(t))return o(e,t,r);var u=n({},t);return Object.keys(e).forEach((function(t){null!=u[t]&&(u[t]=r(u[t],e[t]))})),u},j=function e(t,r,n,i,o,u){return"object"==typeof t&&t?"object"!=typeof i||i.normalize&&"function"==typeof i.normalize?i.normalize(t,r,n,e,o,u):(Array.isArray(i)?d:g)(i,t,r,n,e,o,u):t},z={Array:b,Entity:f,Object:function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,r){var i,o=e[r];return n({},t,((i={})[r]=o,i))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return g.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return O.apply(void 0,[this.schema].concat(t))},e}(),Union:l,Values:y},k=function(e){var t={},r=S(e);return function e(o,u){return"object"!=typeof u||u.denormalize&&"function"==typeof u.denormalize?null==o?o:u instanceof f?function(e,t,r,o,u){var c=o(e,t);if("object"!=typeof c||null===c)return c;if(u[t.key]||(u[t.key]={}),!u[t.key][e]){var a=i(c)?c:n({},c);u[t.key][e]=a,u[t.key][e]=t.denormalize(a,r)}return u[t.key][e]}(o,u,e,r,t):"function"==typeof u.denormalize?u.denormalize(o,e):o:(Array.isArray(u)?v:O)(u,o,e)}},S=function(e){var t=i(e);return function(r,n){var i=n.key;return"object"==typeof r?r:t?e.getIn([i,r.toString()]):e[i]&&e[i][r]}};e.denormalize=function(e,t,r){if(void 0!==e)return k(r)(e,t)},e.normalize=function(e,t){if(!e||"object"!=typeof e)throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+(null===e?"null":typeof e)+'".');var r={},n=function(e){return function(t,r,n,i,o){var u=t.key,c=t.getId(n,i,o);u in e||(e[u]={});var a=e[u][c];e[u][c]=a?t.merge(a,r):r}}(r);return{entities:r,result:j(e,e,null,t,n,[])}},e.schema=z,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -1,8 +0,53 @@

var rest_hooks_normalizr = (function (exports, _objectSpread, _createClass, _inheritsLoose) {
var rest_hooks_normalizr = (function (exports) {
'use strict';
_objectSpread = _objectSpread && _objectSpread.hasOwnProperty('default') ? _objectSpread['default'] : _objectSpread;
_createClass = _createClass && _createClass.hasOwnProperty('default') ? _createClass['default'] : _createClass;
_inheritsLoose = _inheritsLoose && _inheritsLoose.hasOwnProperty('default') ? _inheritsLoose['default'] : _inheritsLoose;
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 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 _objectSpread2(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;
}
/**

@@ -48,2 +93,18 @@ * Helpers to enable Immutable compatibility *without* bringing in

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;
}
var getDefaultGetId = function getDefaultGetId(idAttribute) {

@@ -76,7 +137,7 @@ return function (input) {

mergeStrategy = _options$mergeStrateg === void 0 ? function (entityA, entityB) {
return _objectSpread({}, entityA, entityB);
return _objectSpread2({}, entityA, {}, entityB);
} : _options$mergeStrateg,
_options$processStrat = _options.processStrategy,
processStrategy = _options$processStrat === void 0 ? function (input) {
return _objectSpread({}, input);
return _objectSpread2({}, input);
} : _options$processStrat;

@@ -95,6 +156,6 @@ this._key = key;

this.schema = Object.keys(definition).reduce(function (entitySchema, key) {
var _objectSpread2;
var _objectSpread2$1;
var schema = definition[key];
return _objectSpread({}, entitySchema, (_objectSpread2 = {}, _objectSpread2[key] = schema, _objectSpread2));
return _objectSpread2({}, entitySchema, (_objectSpread2$1 = {}, _objectSpread2$1[key] = schema, _objectSpread2$1));
}, this.schema || {});

@@ -165,2 +226,8 @@ };

function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
var PolymorphicSchema =

@@ -275,6 +342,6 @@ /*#__PURE__*/

return Object.keys(input).reduce(function (output, key, index) {
var _objectSpread2;
var _objectSpread2$1;
var value = input[key];
return value !== undefined && value !== null ? _objectSpread({}, output, (_objectSpread2 = {}, _objectSpread2[key] = _this.normalizeValue(value, input, key, visit, addEntity, visitedEntities), _objectSpread2)) : output;
return value !== undefined && value !== null ? _objectSpread2({}, output, (_objectSpread2$1 = {}, _objectSpread2$1[key] = _this.normalizeValue(value, input, key, visit, addEntity, visitedEntities), _objectSpread2$1)) : output;
}, {});

@@ -290,3 +357,3 @@ };

var entityOrId = input[key];
return _objectSpread({}, output, (_objectSpread3 = {}, _objectSpread3[key] = _this2.denormalizeValue(entityOrId, unvisit), _objectSpread3));
return _objectSpread2({}, output, (_objectSpread3 = {}, _objectSpread3[key] = _this2.denormalizeValue(entityOrId, unvisit), _objectSpread3));
}, {});

@@ -364,3 +431,3 @@ };

var _normalize = function normalize(schema, input, parent, key, visit, addEntity, visitedEntities) {
var object = _objectSpread({}, input);
var object = _objectSpread2({}, input);

@@ -385,3 +452,3 @@ Object.keys(schema).forEach(function (key) {

var object = _objectSpread({}, input);
var object = _objectSpread2({}, input);

@@ -407,6 +474,6 @@ Object.keys(schema).forEach(function (key) {

this.schema = Object.keys(definition).reduce(function (entitySchema, key) {
var _objectSpread2;
var _objectSpread2$1;
var schema = definition[key];
return _objectSpread({}, entitySchema, (_objectSpread2 = {}, _objectSpread2[key] = schema, _objectSpread2));
return _objectSpread2({}, entitySchema, (_objectSpread2$1 = {}, _objectSpread2$1[key] = schema, _objectSpread2$1));
}, this.schema || {});

@@ -501,3 +568,3 @@ };

// Ensure we don't mutate it non-immutable objects
var entityCopy = isImmutable(entity) ? entity : _objectSpread({}, entity); // Need to set this first so that if it is referenced further within the
var entityCopy = isImmutable(entity) ? entity : _objectSpread2({}, entity); // Need to set this first so that if it is referenced further within the
// denormalization the reference will already exist.

@@ -566,2 +633,2 @@

}({}, _objectSpread, _createClass, _inheritsLoose));
}({}));

@@ -1,1 +0,1 @@

var rest_hooks_normalizr=function(t,e,n,r){"use strict";function i(t){return!(!t||"function"!=typeof t.hasOwnProperty||!(t.hasOwnProperty("__ownerID")||t._map&&t._map.hasOwnProperty("__ownerID")))}function o(t,e,n){return Object.keys(t).reduce(function(e,r){var i=""+r;return e.has(i)?e.set(i,n(e.get(i),t[i])):e},e)}e=e&&e.hasOwnProperty("default")?e.default:e,n=n&&n.hasOwnProperty("default")?n.default:n,r=r&&r.hasOwnProperty("default")?r.default:r;var u=function(t){return function(e){return i(e)?e.get(t):e[t]}},a=function(){function t(t,n,r){if(void 0===n&&(n={}),void 0===r&&(r={}),!t||"string"!=typeof t)throw new Error("Expected a string key for Entity, but found "+t+".");var i=r,o=i.idAttribute,a=void 0===o?"id":o,c=i.mergeStrategy,f=void 0===c?function(t,n){return e({},t,n)}:c,s=i.processStrategy,h=void 0===s?function(t){return e({},t)}:s;this._key=t,this._getId="function"==typeof a?a:u(a),this._idAttribute=a,this._mergeStrategy=f,this._processStrategy=h,this.define(n)}var r=t.prototype;return r.define=function(t){this.schema=Object.keys(t).reduce(function(n,r){var i,o=t[r];return e({},n,((i={})[r]=o,i))},this.schema||{})},r.getId=function(t,e,n){return this._getId(t,e,n)},r.merge=function(t,e){return this._mergeStrategy(t,e)},r.normalize=function(t,e,n,r,i,o){var u=this;if(o.some(function(e){return e===t}))return this.getId(t,e,n);o.push(t);var a=this._processStrategy(t,e,n);return Object.keys(this.schema).forEach(function(t){if(a.hasOwnProperty(t)&&"object"==typeof a[t]){var e=u.schema[t];a[t]=r(a[t],a,t,e,i,o)}}),i(this,a,t,e,n),this.getId(t,e,n)},r.denormalize=function(t,e){var n=this;return i(t)?o(this.schema,t,e):(Object.keys(this.schema).forEach(function(r){if(t.hasOwnProperty(r)){var i=n.schema[r];t[r]=e(t[r],i)}}),t)},n(t,[{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),t}(),c=function(){function t(t,e){e&&(this._schemaAttribute="string"==typeof e?function(t){return t[e]}:e),this.define(t)}var e=t.prototype;return e.define=function(t){this.schema=t},e.getSchemaAttribute=function(t,e,n){return!this.isSingleSchema&&this._schemaAttribute(t,e,n)},e.inferSchema=function(t,e,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(t,e,n);return this.schema[r]},e.normalizeValue=function(t,e,n,r,i,o){var u=this.inferSchema(t,e,n);if(!u)return t;var a=r(t,e,n,u,i,o);return this.isSingleSchema||null==a?a:{id:a,schema:this.getSchemaAttribute(t,e,n)}},e.denormalizeValue=function(t,e){var n=i(t)?t.get("schema"):t.schema;return this.isSingleSchema||n?e((i(t)?t.get("id"):t.id)||t,this.isSingleSchema?this.schema:this.schema[n]):t},n(t,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),t}(),f=function(t){function e(e,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return t.call(this,e,n)||this}r(e,t);var n=e.prototype;return n.normalize=function(t,e,n,r,i,o){return this.normalizeValue(t,e,n,r,i,o)},n.denormalize=function(t,e){return this.denormalizeValue(t,e)},e}(c),s=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.normalize=function(t,n,r,i,o,u){var a=this;return Object.keys(t).reduce(function(n,r,c){var f,s=t[r];return null!=s?e({},n,((f={})[r]=a.normalizeValue(s,t,r,i,o,u),f)):n},{})},i.denormalize=function(t,n){var r=this;return Object.keys(t).reduce(function(i,o){var u,a=t[o];return e({},i,((u={})[o]=r.denormalizeValue(a,n),u))},{})},n}(c),h=function(t){if(Array.isArray(t)&&t.length>1)throw new Error("Expected schema definition to be a single schema, but found "+t.length+".");return t[0]},l=function(t){return Array.isArray(t)?t:Object.keys(t).map(function(e){return t[e]})},m=function(t,e,n,r,i,o,u){return t=h(t),l(e).map(function(e,a){return i(e,n,r,t,o,u)})},y=function(t,e,n){return t=h(t),e&&e.map?e.map(function(e){return n(e,t)}):e},d=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var n=e.prototype;return n.normalize=function(t,e,n,r,i,o){var u=this;return l(t).map(function(t,a){return u.normalizeValue(t,e,n,r,i,o)}).filter(function(t){return null!=t})},n.denormalize=function(t,e){var n=this;return t&&t.map?t.map(function(t){return n.denormalizeValue(t,e)}):t},e}(c),p=function(t,n,r,i,o,u,a){var c=e({},n);return Object.keys(t).forEach(function(e){var r=t[e],i=o(n[e],n,e,r,u,a);null==i?delete c[e]:c[e]=i}),c},v=function(t,n,r){if(i(n))return o(t,n,r);var u=e({},n);return Object.keys(t).forEach(function(e){null!=u[e]&&(u[e]=r(u[e],t[e]))}),u},g=function t(e,n,r,i,o,u){return"object"==typeof e&&e?"object"!=typeof i||i.normalize&&"function"==typeof i.normalize?i.normalize(e,n,r,t,o,u):(Array.isArray(i)?m:p)(i,e,n,r,t,o,u):e},b={Array:d,Entity:a,Object:function(){function t(t){this.define(t)}var n=t.prototype;return n.define=function(t){this.schema=Object.keys(t).reduce(function(n,r){var i,o=t[r];return e({},n,((i={})[r]=o,i))},this.schema||{})},n.normalize=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return p.apply(void 0,[this.schema].concat(e))},n.denormalize=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return v.apply(void 0,[this.schema].concat(e))},t}(),Union:f,Values:s},z=function(t){var n={},r=k(t);return function t(o,u){return"object"!=typeof u||u.denormalize&&"function"==typeof u.denormalize?null==o?o:u instanceof a?function(t,n,r,o,u){var a=o(t,n);if("object"!=typeof a||null===a)return a;if(u[n.key]||(u[n.key]={}),!u[n.key][t]){var c=i(a)?a:e({},a);u[n.key][t]=c,u[n.key][t]=n.denormalize(c,r)}return u[n.key][t]}(o,u,t,r,n):"function"==typeof u.denormalize?u.denormalize(o,t):o:(Array.isArray(u)?y:v)(u,o,t)}},k=function(t){var e=i(t);return function(n,r){var i=r.key;return"object"==typeof n?n:e?t.getIn([i,n.toString()]):t[i]&&t[i][n]}};return t.denormalize=function(t,e,n){if(void 0!==t)return z(n)(t,e)},t.normalize=function(t,e){if(!t||"object"!=typeof t)throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+(null===t?"null":typeof t)+'".');var n={},r=function(t){return function(e,n,r,i,o){var u=e.key,a=e.getId(r,i,o);u in t||(t[u]={});var c=t[u][a];t[u][a]=c?e.merge(c,n):n}}(n);return{entities:n,result:g(t,t,null,e,r,[])}},t.schema=b,t}({},_objectSpread,_createClass,_inheritsLoose);
var rest_hooks_normalizr=function(e){"use strict";function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(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 n(e){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?r(i,!0).forEach((function(r){t(e,r,i[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(i).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function i(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function o(e,t,r){return Object.keys(e).reduce((function(t,n){var i=""+n;return t.has(i)?t.set(i,r(t.get(i),e[i])):t}),t)}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),e}var a=function(e){return function(t){return i(t)?t.get(e):t[e]}},f=function(){function e(e,t,r){if(void 0===t&&(t={}),void 0===r&&(r={}),!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");var i=r,o=i.idAttribute,u=void 0===o?"id":o,c=i.mergeStrategy,f=void 0===c?function(e,t){return n({},e,{},t)}:c,s=i.processStrategy,h=void 0===s?function(e){return n({},e)}:s;this._key=e,this._getId="function"==typeof u?u:a(u),this._idAttribute=u,this._mergeStrategy=f,this._processStrategy=h,this.define(t)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,r){var i,o=e[r];return n({},t,((i={})[r]=o,i))}),this.schema||{})},t.getId=function(e,t,r){return this._getId(e,t,r)},t.merge=function(e,t){return this._mergeStrategy(e,t)},t.normalize=function(e,t,r,n,i,o){var u=this;if(o.some((function(t){return t===e})))return this.getId(e,t,r);o.push(e);var c=this._processStrategy(e,t,r);return Object.keys(this.schema).forEach((function(e){if(c.hasOwnProperty(e)&&"object"==typeof c[e]){var t=u.schema[e];c[e]=n(c[e],c,e,t,i,o)}})),i(this,c,e,t,r),this.getId(e,t,r)},t.denormalize=function(e,t){var r=this;return i(e)?o(this.schema,e,t):(Object.keys(this.schema).forEach((function(n){if(e.hasOwnProperty(n)){var i=r.schema[n];e[n]=t(e[n],i)}})),e)},c(e,[{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),e}();function s(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var h=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=e},t.getSchemaAttribute=function(e,t,r){return!this.isSingleSchema&&this._schemaAttribute(e,t,r)},t.inferSchema=function(e,t,r){if(this.isSingleSchema)return this.schema;var n=this.getSchemaAttribute(e,t,r);return this.schema[n]},t.normalizeValue=function(e,t,r,n,i,o){var u=this.inferSchema(e,t,r);if(!u)return e;var c=n(e,t,r,u,i,o);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,r)}},t.denormalizeValue=function(e,t){var r=i(e)?e.get("schema"):e.schema;return this.isSingleSchema||r?t((i(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):e},c(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),l=function(e){function t(t,r){if(!r)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,r)||this}s(t,e);var r=t.prototype;return r.normalize=function(e,t,r,n,i,o){return this.normalizeValue(e,t,r,n,i,o)},r.denormalize=function(e,t){return this.denormalizeValue(e,t)},t}(h),y=function(e){function t(){return e.apply(this,arguments)||this}s(t,e);var r=t.prototype;return r.normalize=function(e,t,r,i,o,u){var c=this;return Object.keys(e).reduce((function(t,r,a){var f,s=e[r];return null!=s?n({},t,((f={})[r]=c.normalizeValue(s,e,r,i,o,u),f)):t}),{})},r.denormalize=function(e,t){var r=this;return Object.keys(e).reduce((function(i,o){var u,c=e[o];return n({},i,((u={})[o]=r.denormalizeValue(c,t),u))}),{})},t}(h),m=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},p=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},d=function(e,t,r,n,i,o,u){return e=m(e),p(t).map((function(t,c){return i(t,r,n,e,o,u)}))},v=function(e,t,r){return e=m(e),t&&t.map?t.map((function(t){return r(t,e)})):t},b=function(e){function t(){return e.apply(this,arguments)||this}s(t,e);var r=t.prototype;return r.normalize=function(e,t,r,n,i,o){var u=this;return p(e).map((function(e,c){return u.normalizeValue(e,t,r,n,i,o)})).filter((function(e){return null!=e}))},r.denormalize=function(e,t){var r=this;return e&&e.map?e.map((function(e){return r.denormalizeValue(e,t)})):e},t}(h),g=function(e,t,r,i,o,u,c){var a=n({},t);return Object.keys(e).forEach((function(r){var n=e[r],i=o(t[r],t,r,n,u,c);null==i?delete a[r]:a[r]=i})),a},O=function(e,t,r){if(i(t))return o(e,t,r);var u=n({},t);return Object.keys(e).forEach((function(t){null!=u[t]&&(u[t]=r(u[t],e[t]))})),u},j=function e(t,r,n,i,o,u){return"object"==typeof t&&t?"object"!=typeof i||i.normalize&&"function"==typeof i.normalize?i.normalize(t,r,n,e,o,u):(Array.isArray(i)?d:g)(i,t,r,n,e,o,u):t},z={Array:b,Entity:f,Object:function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,r){var i,o=e[r];return n({},t,((i={})[r]=o,i))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return g.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return O.apply(void 0,[this.schema].concat(t))},e}(),Union:l,Values:y},k=function(e){var t={},r=S(e);return function e(o,u){return"object"!=typeof u||u.denormalize&&"function"==typeof u.denormalize?null==o?o:u instanceof f?function(e,t,r,o,u){var c=o(e,t);if("object"!=typeof c||null===c)return c;if(u[t.key]||(u[t.key]={}),!u[t.key][e]){var a=i(c)?c:n({},c);u[t.key][e]=a,u[t.key][e]=t.denormalize(a,r)}return u[t.key][e]}(o,u,e,r,t):"function"==typeof u.denormalize?u.denormalize(o,e):o:(Array.isArray(u)?v:O)(u,o,e)}},S=function(e){var t=i(e);return function(r,n){var i=n.key;return"object"==typeof r?r:t?e.getIn([i,r.toString()]):e[i]&&e[i][r]}};return e.denormalize=function(e,t,r){if(void 0!==e)return k(r)(e,t)},e.normalize=function(e,t){if(!e||"object"!=typeof e)throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+(null===e?"null":typeof e)+'".');var r={},n=function(e){return function(t,r,n,i,o){var u=t.key,c=t.getId(n,i,o);u in e||(e[u]={});var a=e[u][c];e[u][c]=a?t.merge(a,r):r}}(r);return{entities:r,result:j(e,e,null,t,n,[])}},e.schema=z,e}({});

@@ -1,2 +0,2 @@

import _objectSpread from '@babel/runtime/helpers/esm/objectSpread';
import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
import _createClass from '@babel/runtime/helpers/esm/createClass';

@@ -72,3 +72,3 @@ import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';

mergeStrategy = _options$mergeStrateg === void 0 ? function (entityA, entityB) {
return _objectSpread({}, entityA, entityB);
return _objectSpread({}, entityA, {}, entityB);
} : _options$mergeStrateg,

@@ -75,0 +75,0 @@ _options$processStrat = _options.processStrategy,

@@ -1,1 +0,1 @@

import e from"@babel/runtime/helpers/esm/objectSpread";import t from"@babel/runtime/helpers/esm/createClass";import n from"@babel/runtime/helpers/esm/inheritsLoose";function r(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function i(e,t,n){return Object.keys(e).reduce(function(t,r){var i=""+r;return t.has(i)?t.set(i,n(t.get(i),e[i])):t},t)}var o=function(e){return function(t){return r(t)?t.get(e):t[e]}},u=function(){function n(t,n,r){if(void 0===n&&(n={}),void 0===r&&(r={}),!t||"string"!=typeof t)throw new Error("Expected a string key for Entity, but found "+t+".");var i=r,u=i.idAttribute,a=void 0===u?"id":u,c=i.mergeStrategy,s=void 0===c?function(t,n){return e({},t,n)}:c,f=i.processStrategy,h=void 0===f?function(t){return e({},t)}:f;this._key=t,this._getId="function"==typeof a?a:o(a),this._idAttribute=a,this._mergeStrategy=s,this._processStrategy=h,this.define(n)}var u=n.prototype;return u.define=function(t){this.schema=Object.keys(t).reduce(function(n,r){var i,o=t[r];return e({},n,((i={})[r]=o,i))},this.schema||{})},u.getId=function(e,t,n){return this._getId(e,t,n)},u.merge=function(e,t){return this._mergeStrategy(e,t)},u.normalize=function(e,t,n,r,i,o){var u=this;if(o.some(function(t){return t===e}))return this.getId(e,t,n);o.push(e);var a=this._processStrategy(e,t,n);return Object.keys(this.schema).forEach(function(e){if(a.hasOwnProperty(e)&&"object"==typeof a[e]){var t=u.schema[e];a[e]=r(a[e],a,e,t,i,o)}}),i(this,a,e,t,n),this.getId(e,t,n)},u.denormalize=function(e,t){var n=this;return r(e)?i(this.schema,e,t):(Object.keys(this.schema).forEach(function(r){if(e.hasOwnProperty(r)){var i=n.schema[r];e[r]=t(e[r],i)}}),e)},t(n,[{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),n}(),a=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=e},n.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},n.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},n.normalizeValue=function(e,t,n,r,i,o){var u=this.inferSchema(e,t,n);if(!u)return e;var a=r(e,t,n,u,i,o);return this.isSingleSchema||null==a?a:{id:a,schema:this.getSchemaAttribute(e,t,n)}},n.denormalizeValue=function(e,t){var n=r(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?t((r(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[n]):e},t(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),c=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}n(t,e);var r=t.prototype;return r.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},r.denormalize=function(e,t){return this.denormalizeValue(e,t)},t}(a),s=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var i=r.prototype;return i.normalize=function(t,n,r,i,o,u){var a=this;return Object.keys(t).reduce(function(n,r,c){var s,f=t[r];return null!=f?e({},n,((s={})[r]=a.normalizeValue(f,t,r,i,o,u),s)):n},{})},i.denormalize=function(t,n){var r=this;return Object.keys(t).reduce(function(i,o){var u,a=t[o];return e({},i,((u={})[o]=r.denormalizeValue(a,n),u))},{})},r}(a),f=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},h=function(e){return Array.isArray(e)?e:Object.keys(e).map(function(t){return e[t]})},m=function(e,t,n,r,i,o,u){return e=f(e),h(t).map(function(t,a){return i(t,n,r,e,o,u)})},l=function(e,t,n){return e=f(e),t&&t.map?t.map(function(t){return n(t,e)}):t},y=function(e){function t(){return e.apply(this,arguments)||this}n(t,e);var r=t.prototype;return r.normalize=function(e,t,n,r,i,o){var u=this;return h(e).map(function(e,a){return u.normalizeValue(e,t,n,r,i,o)}).filter(function(e){return null!=e})},r.denormalize=function(e,t){var n=this;return e&&e.map?e.map(function(e){return n.denormalizeValue(e,t)}):e},t}(a),p=function(t,n,r,i,o,u,a){var c=e({},n);return Object.keys(t).forEach(function(e){var r=t[e],i=o(n[e],n,e,r,u,a);null==i?delete c[e]:c[e]=i}),c},d=function(t,n,o){if(r(n))return i(t,n,o);var u=e({},n);return Object.keys(t).forEach(function(e){null!=u[e]&&(u[e]=o(u[e],t[e]))}),u},v=function e(t,n,r,i,o,u){return"object"==typeof t&&t?"object"!=typeof i||i.normalize&&"function"==typeof i.normalize?i.normalize(t,n,r,e,o,u):(Array.isArray(i)?m:p)(i,t,n,r,e,o,u):t},g={Array:y,Entity:u,Object:function(){function t(e){this.define(e)}var n=t.prototype;return n.define=function(t){this.schema=Object.keys(t).reduce(function(n,r){var i,o=t[r];return e({},n,((i={})[r]=o,i))},this.schema||{})},n.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return p.apply(void 0,[this.schema].concat(t))},n.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return d.apply(void 0,[this.schema].concat(t))},t}(),Union:c,Values:s},b=function(e,t){if(!e||"object"!=typeof e)throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+(null===e?"null":typeof e)+'".');var n={},r=function(e){return function(t,n,r,i,o){var u=t.key,a=t.getId(r,i,o);u in e||(e[u]={});var c=e[u][a];e[u][a]=c?t.merge(c,n):n}}(n);return{entities:n,result:v(e,e,null,t,r,[])}},z=function(t){var n={},i=S(t);return function t(o,a){return"object"!=typeof a||a.denormalize&&"function"==typeof a.denormalize?null==o?o:a instanceof u?function(t,n,i,o,u){var a=o(t,n);if("object"!=typeof a||null===a)return a;if(u[n.key]||(u[n.key]={}),!u[n.key][t]){var c=r(a)?a:e({},a);u[n.key][t]=c,u[n.key][t]=n.denormalize(c,i)}return u[n.key][t]}(o,a,t,i,n):"function"==typeof a.denormalize?a.denormalize(o,t):o:(Array.isArray(a)?l:d)(a,o,t)}},S=function(e){var t=r(e);return function(n,r){var i=r.key;return"object"==typeof n?n:t?e.getIn([i,n.toString()]):e[i]&&e[i][n]}},k=function(e,t,n){if(void 0!==e)return z(n)(e,t)};export{k as denormalize,b as normalize,g as schema};
import e from"@babel/runtime/helpers/esm/objectSpread2";import t from"@babel/runtime/helpers/esm/createClass";import n from"@babel/runtime/helpers/esm/inheritsLoose";function r(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function i(e,t,n){return Object.keys(e).reduce((function(t,r){var i=""+r;return t.has(i)?t.set(i,n(t.get(i),e[i])):t}),t)}var o=function(e){return function(t){return r(t)?t.get(e):t[e]}},u=function(){function n(t,n,r){if(void 0===n&&(n={}),void 0===r&&(r={}),!t||"string"!=typeof t)throw new Error("Expected a string key for Entity, but found "+t+".");var i=r,u=i.idAttribute,a=void 0===u?"id":u,c=i.mergeStrategy,s=void 0===c?function(t,n){return e({},t,{},n)}:c,f=i.processStrategy,h=void 0===f?function(t){return e({},t)}:f;this._key=t,this._getId="function"==typeof a?a:o(a),this._idAttribute=a,this._mergeStrategy=s,this._processStrategy=h,this.define(n)}var u=n.prototype;return u.define=function(t){this.schema=Object.keys(t).reduce((function(n,r){var i,o=t[r];return e({},n,((i={})[r]=o,i))}),this.schema||{})},u.getId=function(e,t,n){return this._getId(e,t,n)},u.merge=function(e,t){return this._mergeStrategy(e,t)},u.normalize=function(e,t,n,r,i,o){var u=this;if(o.some((function(t){return t===e})))return this.getId(e,t,n);o.push(e);var a=this._processStrategy(e,t,n);return Object.keys(this.schema).forEach((function(e){if(a.hasOwnProperty(e)&&"object"==typeof a[e]){var t=u.schema[e];a[e]=r(a[e],a,e,t,i,o)}})),i(this,a,e,t,n),this.getId(e,t,n)},u.denormalize=function(e,t){var n=this;return r(e)?i(this.schema,e,t):(Object.keys(this.schema).forEach((function(r){if(e.hasOwnProperty(r)){var i=n.schema[r];e[r]=t(e[r],i)}})),e)},t(n,[{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),n}(),a=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=e},n.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},n.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},n.normalizeValue=function(e,t,n,r,i,o){var u=this.inferSchema(e,t,n);if(!u)return e;var a=r(e,t,n,u,i,o);return this.isSingleSchema||null==a?a:{id:a,schema:this.getSchemaAttribute(e,t,n)}},n.denormalizeValue=function(e,t){var n=r(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?t((r(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[n]):e},t(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),c=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}n(t,e);var r=t.prototype;return r.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},r.denormalize=function(e,t){return this.denormalizeValue(e,t)},t}(a),s=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var i=r.prototype;return i.normalize=function(t,n,r,i,o,u){var a=this;return Object.keys(t).reduce((function(n,r,c){var s,f=t[r];return null!=f?e({},n,((s={})[r]=a.normalizeValue(f,t,r,i,o,u),s)):n}),{})},i.denormalize=function(t,n){var r=this;return Object.keys(t).reduce((function(i,o){var u,a=t[o];return e({},i,((u={})[o]=r.denormalizeValue(a,n),u))}),{})},r}(a),f=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},h=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},m=function(e,t,n,r,i,o,u){return e=f(e),h(t).map((function(t,a){return i(t,n,r,e,o,u)}))},l=function(e,t,n){return e=f(e),t&&t.map?t.map((function(t){return n(t,e)})):t},y=function(e){function t(){return e.apply(this,arguments)||this}n(t,e);var r=t.prototype;return r.normalize=function(e,t,n,r,i,o){var u=this;return h(e).map((function(e,a){return u.normalizeValue(e,t,n,r,i,o)})).filter((function(e){return null!=e}))},r.denormalize=function(e,t){var n=this;return e&&e.map?e.map((function(e){return n.denormalizeValue(e,t)})):e},t}(a),p=function(t,n,r,i,o,u,a){var c=e({},n);return Object.keys(t).forEach((function(e){var r=t[e],i=o(n[e],n,e,r,u,a);null==i?delete c[e]:c[e]=i})),c},d=function(t,n,o){if(r(n))return i(t,n,o);var u=e({},n);return Object.keys(t).forEach((function(e){null!=u[e]&&(u[e]=o(u[e],t[e]))})),u},v=function e(t,n,r,i,o,u){return"object"==typeof t&&t?"object"!=typeof i||i.normalize&&"function"==typeof i.normalize?i.normalize(t,n,r,e,o,u):(Array.isArray(i)?m:p)(i,t,n,r,e,o,u):t},g={Array:y,Entity:u,Object:function(){function t(e){this.define(e)}var n=t.prototype;return n.define=function(t){this.schema=Object.keys(t).reduce((function(n,r){var i,o=t[r];return e({},n,((i={})[r]=o,i))}),this.schema||{})},n.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return p.apply(void 0,[this.schema].concat(t))},n.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return d.apply(void 0,[this.schema].concat(t))},t}(),Union:c,Values:s},b=function(e,t){if(!e||"object"!=typeof e)throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+(null===e?"null":typeof e)+'".');var n={},r=function(e){return function(t,n,r,i,o){var u=t.key,a=t.getId(r,i,o);u in e||(e[u]={});var c=e[u][a];e[u][a]=c?t.merge(c,n):n}}(n);return{entities:n,result:v(e,e,null,t,r,[])}},z=function(t){var n={},i=S(t);return function t(o,a){return"object"!=typeof a||a.denormalize&&"function"==typeof a.denormalize?null==o?o:a instanceof u?function(t,n,i,o,u){var a=o(t,n);if("object"!=typeof a||null===a)return a;if(u[n.key]||(u[n.key]={}),!u[n.key][t]){var c=r(a)?a:e({},a);u[n.key][t]=c,u[n.key][t]=n.denormalize(c,i)}return u[n.key][t]}(o,a,t,i,n):"function"==typeof a.denormalize?a.denormalize(o,t):o:(Array.isArray(a)?l:d)(a,o,t)}},S=function(e){var t=r(e);return function(n,r){var i=r.key;return"object"==typeof n?n:t?e.getIn([i,n.toString()]):e[i]&&e[i][n]}},k=function(e,t,n){if(void 0!==e)return z(n)(e,t)};export{k as denormalize,b as normalize,g as schema};

@@ -5,8 +5,51 @@ 'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
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;
}
var _objectSpread = _interopDefault(require('@babel/runtime/helpers/esm/objectSpread'));
var _createClass = _interopDefault(require('@babel/runtime/helpers/esm/createClass'));
var _inheritsLoose = _interopDefault(require('@babel/runtime/helpers/esm/inheritsLoose'));
return obj;
}
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 _objectSpread2(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;
}
/**

@@ -52,2 +95,18 @@ * Helpers to enable Immutable compatibility *without* bringing in

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;
}
var getDefaultGetId = function getDefaultGetId(idAttribute) {

@@ -80,7 +139,7 @@ return function (input) {

mergeStrategy = _options$mergeStrateg === void 0 ? function (entityA, entityB) {
return _objectSpread({}, entityA, entityB);
return _objectSpread2({}, entityA, {}, entityB);
} : _options$mergeStrateg,
_options$processStrat = _options.processStrategy,
processStrategy = _options$processStrat === void 0 ? function (input) {
return _objectSpread({}, input);
return _objectSpread2({}, input);
} : _options$processStrat;

@@ -99,6 +158,6 @@ this._key = key;

this.schema = Object.keys(definition).reduce(function (entitySchema, key) {
var _objectSpread2;
var _objectSpread2$1;
var schema = definition[key];
return _objectSpread({}, entitySchema, (_objectSpread2 = {}, _objectSpread2[key] = schema, _objectSpread2));
return _objectSpread2({}, entitySchema, (_objectSpread2$1 = {}, _objectSpread2$1[key] = schema, _objectSpread2$1));
}, this.schema || {});

@@ -169,2 +228,8 @@ };

function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
var PolymorphicSchema =

@@ -279,6 +344,6 @@ /*#__PURE__*/

return Object.keys(input).reduce(function (output, key, index) {
var _objectSpread2;
var _objectSpread2$1;
var value = input[key];
return value !== undefined && value !== null ? _objectSpread({}, output, (_objectSpread2 = {}, _objectSpread2[key] = _this.normalizeValue(value, input, key, visit, addEntity, visitedEntities), _objectSpread2)) : output;
return value !== undefined && value !== null ? _objectSpread2({}, output, (_objectSpread2$1 = {}, _objectSpread2$1[key] = _this.normalizeValue(value, input, key, visit, addEntity, visitedEntities), _objectSpread2$1)) : output;
}, {});

@@ -294,3 +359,3 @@ };

var entityOrId = input[key];
return _objectSpread({}, output, (_objectSpread3 = {}, _objectSpread3[key] = _this2.denormalizeValue(entityOrId, unvisit), _objectSpread3));
return _objectSpread2({}, output, (_objectSpread3 = {}, _objectSpread3[key] = _this2.denormalizeValue(entityOrId, unvisit), _objectSpread3));
}, {});

@@ -368,3 +433,3 @@ };

var _normalize = function normalize(schema, input, parent, key, visit, addEntity, visitedEntities) {
var object = _objectSpread({}, input);
var object = _objectSpread2({}, input);

@@ -389,3 +454,3 @@ Object.keys(schema).forEach(function (key) {

var object = _objectSpread({}, input);
var object = _objectSpread2({}, input);

@@ -411,6 +476,6 @@ Object.keys(schema).forEach(function (key) {

this.schema = Object.keys(definition).reduce(function (entitySchema, key) {
var _objectSpread2;
var _objectSpread2$1;
var schema = definition[key];
return _objectSpread({}, entitySchema, (_objectSpread2 = {}, _objectSpread2[key] = schema, _objectSpread2));
return _objectSpread2({}, entitySchema, (_objectSpread2$1 = {}, _objectSpread2$1[key] = schema, _objectSpread2$1));
}, this.schema || {});

@@ -505,3 +570,3 @@ };

// Ensure we don't mutate it non-immutable objects
var entityCopy = isImmutable(entity) ? entity : _objectSpread({}, entity); // Need to set this first so that if it is referenced further within the
var entityCopy = isImmutable(entity) ? entity : _objectSpread2({}, entity); // Need to set this first so that if it is referenced further within the
// denormalization the reference will already exist.

@@ -508,0 +573,0 @@

@@ -1,1 +0,1 @@

"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var _objectSpread=_interopDefault(require("@babel/runtime/helpers/esm/objectSpread")),_createClass=_interopDefault(require("@babel/runtime/helpers/esm/createClass")),_inheritsLoose=_interopDefault(require("@babel/runtime/helpers/esm/inheritsLoose"));function isImmutable(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function denormalizeImmutable(e,t,n){return Object.keys(e).reduce(function(t,r){var i=""+r;return t.has(i)?t.set(i,n(t.get(i),e[i])):t},t)}var getDefaultGetId=function(e){return function(t){return isImmutable(t)?t.get(e):t[e]}},EntitySchema=function(){function e(e,t,n){if(void 0===t&&(t={}),void 0===n&&(n={}),!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");var r=n,i=r.idAttribute,a=void 0===i?"id":i,o=r.mergeStrategy,u=void 0===o?function(e,t){return _objectSpread({},e,t)}:o,c=r.processStrategy,s=void 0===c?function(e){return _objectSpread({},e)}:c;this._key=e,this._getId="function"==typeof a?a:getDefaultGetId(a),this._idAttribute=a,this._mergeStrategy=u,this._processStrategy=s,this.define(t)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce(function(t,n){var r,i=e[n];return _objectSpread({},t,((r={})[n]=i,r))},this.schema||{})},t.getId=function(e,t,n){return this._getId(e,t,n)},t.merge=function(e,t){return this._mergeStrategy(e,t)},t.normalize=function(e,t,n,r,i,a){var o=this;if(a.some(function(t){return t===e}))return this.getId(e,t,n);a.push(e);var u=this._processStrategy(e,t,n);return Object.keys(this.schema).forEach(function(e){if(u.hasOwnProperty(e)&&"object"==typeof u[e]){var t=o.schema[e];u[e]=r(u[e],u,e,t,i,a)}}),i(this,u,e,t,n),this.getId(e,t,n)},t.denormalize=function(e,t){var n=this;return isImmutable(e)?denormalizeImmutable(this.schema,e,t):(Object.keys(this.schema).forEach(function(r){if(e.hasOwnProperty(r)){var i=n.schema[r];e[r]=t(e[r],i)}}),e)},_createClass(e,[{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),e}(),PolymorphicSchema=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=e},t.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},t.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},t.normalizeValue=function(e,t,n,r,i,a){var o=this.inferSchema(e,t,n);if(!o)return e;var u=r(e,t,n,o,i,a);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,t,n)}},t.denormalizeValue=function(e,t){var n=isImmutable(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?t((isImmutable(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[n]):e},_createClass(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),UnionSchema=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}_inheritsLoose(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,a){return this.normalizeValue(e,t,n,r,i,a)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},t}(PolymorphicSchema),ValuesSchema=function(e){function t(){return e.apply(this,arguments)||this}_inheritsLoose(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,a){var o=this;return Object.keys(e).reduce(function(t,n,u){var c,s=e[n];return null!=s?_objectSpread({},t,((c={})[n]=o.normalizeValue(s,e,n,r,i,a),c)):t},{})},n.denormalize=function(e,t){var n=this;return Object.keys(e).reduce(function(r,i){var a,o=e[i];return _objectSpread({},r,((a={})[i]=n.denormalizeValue(o,t),a))},{})},t}(PolymorphicSchema),validateSchema=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},getValues=function(e){return Array.isArray(e)?e:Object.keys(e).map(function(t){return e[t]})},normalize=function(e,t,n,r,i,a,o){return e=validateSchema(e),getValues(t).map(function(t,u){return i(t,n,r,e,a,o)})},denormalize=function(e,t,n){return e=validateSchema(e),t&&t.map?t.map(function(t){return n(t,e)}):t},ArraySchema=function(e){function t(){return e.apply(this,arguments)||this}_inheritsLoose(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,a){var o=this;return getValues(e).map(function(e,u){return o.normalizeValue(e,t,n,r,i,a)}).filter(function(e){return null!=e})},n.denormalize=function(e,t){var n=this;return e&&e.map?e.map(function(e){return n.denormalizeValue(e,t)}):e},t}(PolymorphicSchema),_normalize=function(e,t,n,r,i,a,o){var u=_objectSpread({},t);return Object.keys(e).forEach(function(n){var r=e[n],c=i(t[n],t,n,r,a,o);null==c?delete u[n]:u[n]=c}),u},_denormalize=function(e,t,n){if(isImmutable(t))return denormalizeImmutable(e,t,n);var r=_objectSpread({},t);return Object.keys(e).forEach(function(t){null!=r[t]&&(r[t]=n(r[t],e[t]))}),r},ObjectSchema=function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce(function(t,n){var r,i=e[n];return _objectSpread({},t,((r={})[n]=i,r))},this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _normalize.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _denormalize.apply(void 0,[this.schema].concat(t))},e}(),visit=function e(t,n,r,i,a,o){return"object"==typeof t&&t?"object"!=typeof i||i.normalize&&"function"==typeof i.normalize?i.normalize(t,n,r,e,a,o):(Array.isArray(i)?normalize:_normalize)(i,t,n,r,e,a,o):t},addEntities=function(e){return function(t,n,r,i,a){var o=t.key,u=t.getId(r,i,a);o in e||(e[o]={});var c=e[o][u];e[o][u]=c?t.merge(c,n):n}},schema={Array:ArraySchema,Entity:EntitySchema,Object:ObjectSchema,Union:UnionSchema,Values:ValuesSchema},normalize$1=function(e,t){if(!e||"object"!=typeof e)throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+(null===e?"null":typeof e)+'".');var n={},r=addEntities(n);return{entities:n,result:visit(e,e,null,t,r,[])}},unvisitEntity=function(e,t,n,r,i){var a=r(e,t);if("object"!=typeof a||null===a)return a;if(i[t.key]||(i[t.key]={}),!i[t.key][e]){var o=isImmutable(a)?a:_objectSpread({},a);i[t.key][e]=o,i[t.key][e]=t.denormalize(o,n)}return i[t.key][e]},getUnvisit=function(e){var t={},n=getEntities(e);return function e(r,i){return"object"!=typeof i||i.denormalize&&"function"==typeof i.denormalize?null==r?r:i instanceof EntitySchema?unvisitEntity(r,i,e,n,t):"function"==typeof i.denormalize?i.denormalize(r,e):r:(Array.isArray(i)?denormalize:_denormalize)(i,r,e)}},getEntities=function(e){var t=isImmutable(e);return function(n,r){var i=r.key;return"object"==typeof n?n:t?e.getIn([i,n.toString()]):e[i]&&e[i][n]}},denormalize$1=function(e,t,n){if(void 0!==e)return getUnvisit(n)(e,t)};exports.denormalize=denormalize$1,exports.normalize=normalize$1,exports.schema=schema;
"use strict";function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ownKeys(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 _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(r,!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(r).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function isImmutable(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function denormalizeImmutable(e,t,r){return Object.keys(e).reduce((function(t,n){var i=""+n;return t.has(i)?t.set(i,r(t.get(i),e[i])):t}),t)}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}Object.defineProperty(exports,"__esModule",{value:!0});var getDefaultGetId=function(e){return function(t){return isImmutable(t)?t.get(e):t[e]}},EntitySchema=function(){function e(e,t,r){if(void 0===t&&(t={}),void 0===r&&(r={}),!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");var n=r,i=n.idAttribute,o=void 0===i?"id":i,a=n.mergeStrategy,u=void 0===a?function(e,t){return _objectSpread2({},e,{},t)}:a,c=n.processStrategy,s=void 0===c?function(e){return _objectSpread2({},e)}:c;this._key=e,this._getId="function"==typeof o?o:getDefaultGetId(o),this._idAttribute=o,this._mergeStrategy=u,this._processStrategy=s,this.define(t)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,r){var n,i=e[r];return _objectSpread2({},t,((n={})[r]=i,n))}),this.schema||{})},t.getId=function(e,t,r){return this._getId(e,t,r)},t.merge=function(e,t){return this._mergeStrategy(e,t)},t.normalize=function(e,t,r,n,i,o){var a=this;if(o.some((function(t){return t===e})))return this.getId(e,t,r);o.push(e);var u=this._processStrategy(e,t,r);return Object.keys(this.schema).forEach((function(e){if(u.hasOwnProperty(e)&&"object"==typeof u[e]){var t=a.schema[e];u[e]=n(u[e],u,e,t,i,o)}})),i(this,u,e,t,r),this.getId(e,t,r)},t.denormalize=function(e,t){var r=this;return isImmutable(e)?denormalizeImmutable(this.schema,e,t):(Object.keys(this.schema).forEach((function(n){if(e.hasOwnProperty(n)){var i=r.schema[n];e[n]=t(e[n],i)}})),e)},_createClass(e,[{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),e}();function _inheritsLoose(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var PolymorphicSchema=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=e},t.getSchemaAttribute=function(e,t,r){return!this.isSingleSchema&&this._schemaAttribute(e,t,r)},t.inferSchema=function(e,t,r){if(this.isSingleSchema)return this.schema;var n=this.getSchemaAttribute(e,t,r);return this.schema[n]},t.normalizeValue=function(e,t,r,n,i,o){var a=this.inferSchema(e,t,r);if(!a)return e;var u=n(e,t,r,a,i,o);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,t,r)}},t.denormalizeValue=function(e,t){var r=isImmutable(e)?e.get("schema"):e.schema;return this.isSingleSchema||r?t((isImmutable(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):e},_createClass(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),UnionSchema=function(e){function t(t,r){if(!r)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,r)||this}_inheritsLoose(t,e);var r=t.prototype;return r.normalize=function(e,t,r,n,i,o){return this.normalizeValue(e,t,r,n,i,o)},r.denormalize=function(e,t){return this.denormalizeValue(e,t)},t}(PolymorphicSchema),ValuesSchema=function(e){function t(){return e.apply(this,arguments)||this}_inheritsLoose(t,e);var r=t.prototype;return r.normalize=function(e,t,r,n,i,o){var a=this;return Object.keys(e).reduce((function(t,r,u){var c,s=e[r];return null!=s?_objectSpread2({},t,((c={})[r]=a.normalizeValue(s,e,r,n,i,o),c)):t}),{})},r.denormalize=function(e,t){var r=this;return Object.keys(e).reduce((function(n,i){var o,a=e[i];return _objectSpread2({},n,((o={})[i]=r.denormalizeValue(a,t),o))}),{})},t}(PolymorphicSchema),validateSchema=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},getValues=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},normalize=function(e,t,r,n,i,o,a){return e=validateSchema(e),getValues(t).map((function(t,u){return i(t,r,n,e,o,a)}))},denormalize=function(e,t,r){return e=validateSchema(e),t&&t.map?t.map((function(t){return r(t,e)})):t},ArraySchema=function(e){function t(){return e.apply(this,arguments)||this}_inheritsLoose(t,e);var r=t.prototype;return r.normalize=function(e,t,r,n,i,o){var a=this;return getValues(e).map((function(e,u){return a.normalizeValue(e,t,r,n,i,o)})).filter((function(e){return null!=e}))},r.denormalize=function(e,t){var r=this;return e&&e.map?e.map((function(e){return r.denormalizeValue(e,t)})):e},t}(PolymorphicSchema),_normalize=function(e,t,r,n,i,o,a){var u=_objectSpread2({},t);return Object.keys(e).forEach((function(r){var n=e[r],c=i(t[r],t,r,n,o,a);null==c?delete u[r]:u[r]=c})),u},_denormalize=function(e,t,r){if(isImmutable(t))return denormalizeImmutable(e,t,r);var n=_objectSpread2({},t);return Object.keys(e).forEach((function(t){null!=n[t]&&(n[t]=r(n[t],e[t]))})),n},ObjectSchema=function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,r){var n,i=e[r];return _objectSpread2({},t,((n={})[r]=i,n))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return _normalize.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return _denormalize.apply(void 0,[this.schema].concat(t))},e}(),visit=function e(t,r,n,i,o,a){return"object"==typeof t&&t?"object"!=typeof i||i.normalize&&"function"==typeof i.normalize?i.normalize(t,r,n,e,o,a):(Array.isArray(i)?normalize:_normalize)(i,t,r,n,e,o,a):t},addEntities=function(e){return function(t,r,n,i,o){var a=t.key,u=t.getId(n,i,o);a in e||(e[a]={});var c=e[a][u];e[a][u]=c?t.merge(c,r):r}},schema={Array:ArraySchema,Entity:EntitySchema,Object:ObjectSchema,Union:UnionSchema,Values:ValuesSchema},normalize$1=function(e,t){if(!e||"object"!=typeof e)throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+(null===e?"null":typeof e)+'".');var r={},n=addEntities(r);return{entities:r,result:visit(e,e,null,t,n,[])}},unvisitEntity=function(e,t,r,n,i){var o=n(e,t);if("object"!=typeof o||null===o)return o;if(i[t.key]||(i[t.key]={}),!i[t.key][e]){var a=isImmutable(o)?o:_objectSpread2({},o);i[t.key][e]=a,i[t.key][e]=t.denormalize(a,r)}return i[t.key][e]},getUnvisit=function(e){var t={},r=getEntities(e);return function e(n,i){return"object"!=typeof i||i.denormalize&&"function"==typeof i.denormalize?null==n?n:i instanceof EntitySchema?unvisitEntity(n,i,e,r,t):"function"==typeof i.denormalize?i.denormalize(n,e):n:(Array.isArray(i)?denormalize:_denormalize)(i,n,e)}},getEntities=function(e){var t=isImmutable(e);return function(r,n){var i=n.key;return"object"==typeof r?r:t?e.getIn([i,r.toString()]):e[i]&&e[i][r]}},denormalize$1=function(e,t,r){if(void 0!==e)return getUnvisit(r)(e,t)};exports.denormalize=denormalize$1,exports.normalize=normalize$1,exports.schema=schema;
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/esm/objectSpread'), require('@babel/runtime/helpers/esm/createClass'), require('@babel/runtime/helpers/esm/inheritsLoose')) :
typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/esm/objectSpread', '@babel/runtime/helpers/esm/createClass', '@babel/runtime/helpers/esm/inheritsLoose'], factory) :
(global = global || self, factory(global.rest_hooks_normalizr = {}, global._objectSpread, global._createClass, global._inheritsLoose));
}(this, function (exports, _objectSpread, _createClass, _inheritsLoose) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.rest_hooks_normalizr = {}));
}(this, function (exports) { 'use strict';
_objectSpread = _objectSpread && _objectSpread.hasOwnProperty('default') ? _objectSpread['default'] : _objectSpread;
_createClass = _createClass && _createClass.hasOwnProperty('default') ? _createClass['default'] : _createClass;
_inheritsLoose = _inheritsLoose && _inheritsLoose.hasOwnProperty('default') ? _inheritsLoose['default'] : _inheritsLoose;
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 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 _objectSpread2(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;
}
/**

@@ -51,2 +96,18 @@ * Helpers to enable Immutable compatibility *without* bringing in

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;
}
var getDefaultGetId = function getDefaultGetId(idAttribute) {

@@ -79,7 +140,7 @@ return function (input) {

mergeStrategy = _options$mergeStrateg === void 0 ? function (entityA, entityB) {
return _objectSpread({}, entityA, entityB);
return _objectSpread2({}, entityA, {}, entityB);
} : _options$mergeStrateg,
_options$processStrat = _options.processStrategy,
processStrategy = _options$processStrat === void 0 ? function (input) {
return _objectSpread({}, input);
return _objectSpread2({}, input);
} : _options$processStrat;

@@ -98,6 +159,6 @@ this._key = key;

this.schema = Object.keys(definition).reduce(function (entitySchema, key) {
var _objectSpread2;
var _objectSpread2$1;
var schema = definition[key];
return _objectSpread({}, entitySchema, (_objectSpread2 = {}, _objectSpread2[key] = schema, _objectSpread2));
return _objectSpread2({}, entitySchema, (_objectSpread2$1 = {}, _objectSpread2$1[key] = schema, _objectSpread2$1));
}, this.schema || {});

@@ -168,2 +229,8 @@ };

function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
var PolymorphicSchema =

@@ -278,6 +345,6 @@ /*#__PURE__*/

return Object.keys(input).reduce(function (output, key, index) {
var _objectSpread2;
var _objectSpread2$1;
var value = input[key];
return value !== undefined && value !== null ? _objectSpread({}, output, (_objectSpread2 = {}, _objectSpread2[key] = _this.normalizeValue(value, input, key, visit, addEntity, visitedEntities), _objectSpread2)) : output;
return value !== undefined && value !== null ? _objectSpread2({}, output, (_objectSpread2$1 = {}, _objectSpread2$1[key] = _this.normalizeValue(value, input, key, visit, addEntity, visitedEntities), _objectSpread2$1)) : output;
}, {});

@@ -293,3 +360,3 @@ };

var entityOrId = input[key];
return _objectSpread({}, output, (_objectSpread3 = {}, _objectSpread3[key] = _this2.denormalizeValue(entityOrId, unvisit), _objectSpread3));
return _objectSpread2({}, output, (_objectSpread3 = {}, _objectSpread3[key] = _this2.denormalizeValue(entityOrId, unvisit), _objectSpread3));
}, {});

@@ -367,3 +434,3 @@ };

var _normalize = function normalize(schema, input, parent, key, visit, addEntity, visitedEntities) {
var object = _objectSpread({}, input);
var object = _objectSpread2({}, input);

@@ -388,3 +455,3 @@ Object.keys(schema).forEach(function (key) {

var object = _objectSpread({}, input);
var object = _objectSpread2({}, input);

@@ -410,6 +477,6 @@ Object.keys(schema).forEach(function (key) {

this.schema = Object.keys(definition).reduce(function (entitySchema, key) {
var _objectSpread2;
var _objectSpread2$1;
var schema = definition[key];
return _objectSpread({}, entitySchema, (_objectSpread2 = {}, _objectSpread2[key] = schema, _objectSpread2));
return _objectSpread2({}, entitySchema, (_objectSpread2$1 = {}, _objectSpread2$1[key] = schema, _objectSpread2$1));
}, this.schema || {});

@@ -504,3 +571,3 @@ };

// Ensure we don't mutate it non-immutable objects
var entityCopy = isImmutable(entity) ? entity : _objectSpread({}, entity); // Need to set this first so that if it is referenced further within the
var entityCopy = isImmutable(entity) ? entity : _objectSpread2({}, entity); // Need to set this first so that if it is referenced further within the
// denormalization the reference will already exist.

@@ -507,0 +574,0 @@

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@babel/runtime/helpers/esm/objectSpread"),require("@babel/runtime/helpers/esm/createClass"),require("@babel/runtime/helpers/esm/inheritsLoose")):"function"==typeof define&&define.amd?define(["exports","@babel/runtime/helpers/esm/objectSpread","@babel/runtime/helpers/esm/createClass","@babel/runtime/helpers/esm/inheritsLoose"],t):t((e=e||self).rest_hooks_normalizr={},e._objectSpread,e._createClass,e._inheritsLoose)}(this,function(e,t,n,r){"use strict";function i(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function o(e,t,n){return Object.keys(e).reduce(function(t,r){var i=""+r;return t.has(i)?t.set(i,n(t.get(i),e[i])):t},t)}t=t&&t.hasOwnProperty("default")?t.default:t,n=n&&n.hasOwnProperty("default")?n.default:n,r=r&&r.hasOwnProperty("default")?r.default:r;var u=function(e){return function(t){return i(t)?t.get(e):t[e]}},a=function(){function e(e,n,r){if(void 0===n&&(n={}),void 0===r&&(r={}),!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");var i=r,o=i.idAttribute,a=void 0===o?"id":o,c=i.mergeStrategy,s=void 0===c?function(e,n){return t({},e,n)}:c,f=i.processStrategy,h=void 0===f?function(e){return t({},e)}:f;this._key=e,this._getId="function"==typeof a?a:u(a),this._idAttribute=a,this._mergeStrategy=s,this._processStrategy=h,this.define(n)}var r=e.prototype;return r.define=function(e){this.schema=Object.keys(e).reduce(function(n,r){var i,o=e[r];return t({},n,((i={})[r]=o,i))},this.schema||{})},r.getId=function(e,t,n){return this._getId(e,t,n)},r.merge=function(e,t){return this._mergeStrategy(e,t)},r.normalize=function(e,t,n,r,i,o){var u=this;if(o.some(function(t){return t===e}))return this.getId(e,t,n);o.push(e);var a=this._processStrategy(e,t,n);return Object.keys(this.schema).forEach(function(e){if(a.hasOwnProperty(e)&&"object"==typeof a[e]){var t=u.schema[e];a[e]=r(a[e],a,e,t,i,o)}}),i(this,a,e,t,n),this.getId(e,t,n)},r.denormalize=function(e,t){var n=this;return i(e)?o(this.schema,e,t):(Object.keys(this.schema).forEach(function(r){if(e.hasOwnProperty(r)){var i=n.schema[r];e[r]=t(e[r],i)}}),e)},n(e,[{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),e}(),c=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=e},t.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},t.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},t.normalizeValue=function(e,t,n,r,i,o){var u=this.inferSchema(e,t,n);if(!u)return e;var a=r(e,t,n,u,i,o);return this.isSingleSchema||null==a?a:{id:a,schema:this.getSchemaAttribute(e,t,n)}},t.denormalizeValue=function(e,t){var n=i(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?t((i(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[n]):e},n(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),s=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},t}(c),f=function(e){function n(){return e.apply(this,arguments)||this}r(n,e);var i=n.prototype;return i.normalize=function(e,n,r,i,o,u){var a=this;return Object.keys(e).reduce(function(n,r,c){var s,f=e[r];return null!=f?t({},n,((s={})[r]=a.normalizeValue(f,e,r,i,o,u),s)):n},{})},i.denormalize=function(e,n){var r=this;return Object.keys(e).reduce(function(i,o){var u,a=e[o];return t({},i,((u={})[o]=r.denormalizeValue(a,n),u))},{})},n}(c),h=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},l=function(e){return Array.isArray(e)?e:Object.keys(e).map(function(t){return e[t]})},m=function(e,t,n,r,i,o,u){return e=h(e),l(t).map(function(t,a){return i(t,n,r,e,o,u)})},y=function(e,t,n){return e=h(e),t&&t.map?t.map(function(t){return n(t,e)}):t},p=function(e){function t(){return e.apply(this,arguments)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var u=this;return l(e).map(function(e,a){return u.normalizeValue(e,t,n,r,i,o)}).filter(function(e){return null!=e})},n.denormalize=function(e,t){var n=this;return e&&e.map?e.map(function(e){return n.denormalizeValue(e,t)}):e},t}(c),d=function(e,n,r,i,o,u,a){var c=t({},n);return Object.keys(e).forEach(function(t){var r=e[t],i=o(n[t],n,t,r,u,a);null==i?delete c[t]:c[t]=i}),c},b=function(e,n,r){if(i(n))return o(e,n,r);var u=t({},n);return Object.keys(e).forEach(function(t){null!=u[t]&&(u[t]=r(u[t],e[t]))}),u},v=function e(t,n,r,i,o,u){return"object"==typeof t&&t?"object"!=typeof i||i.normalize&&"function"==typeof i.normalize?i.normalize(t,n,r,e,o,u):(Array.isArray(i)?m:d)(i,t,n,r,e,o,u):t},g={Array:p,Entity:a,Object:function(){function e(e){this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=Object.keys(e).reduce(function(n,r){var i,o=e[r];return t({},n,((i={})[r]=o,i))},this.schema||{})},n.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return d.apply(void 0,[this.schema].concat(t))},n.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return b.apply(void 0,[this.schema].concat(t))},e}(),Union:s,Values:f},z=function(e){var n={},r=S(e);return function e(o,u){return"object"!=typeof u||u.denormalize&&"function"==typeof u.denormalize?null==o?o:u instanceof a?function(e,n,r,o,u){var a=o(e,n);if("object"!=typeof a||null===a)return a;if(u[n.key]||(u[n.key]={}),!u[n.key][e]){var c=i(a)?a:t({},a);u[n.key][e]=c,u[n.key][e]=n.denormalize(c,r)}return u[n.key][e]}(o,u,e,r,n):"function"==typeof u.denormalize?u.denormalize(o,e):o:(Array.isArray(u)?y:b)(u,o,e)}},S=function(e){var t=i(e);return function(n,r){var i=r.key;return"object"==typeof n?n:t?e.getIn([i,n.toString()]):e[i]&&e[i][n]}};e.denormalize=function(e,t,n){if(void 0!==e)return z(n)(e,t)},e.normalize=function(e,t){if(!e||"object"!=typeof e)throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+(null===e?"null":typeof e)+'".');var n={},r=function(e){return function(t,n,r,i,o){var u=t.key,a=t.getId(r,i,o);u in e||(e[u]={});var c=e[u][a];e[u][a]=c?t.merge(c,n):n}}(n);return{entities:n,result:v(e,e,null,t,r,[])}},e.schema=g,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).rest_hooks_normalizr={})}(this,(function(e){"use strict";function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function r(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?n(i,!0).forEach((function(n){t(e,n,i[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):n(i).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function i(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function o(e,t,n){return Object.keys(e).reduce((function(t,r){var i=""+r;return t.has(i)?t.set(i,n(t.get(i),e[i])):t}),t)}function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&u(e.prototype,t),n&&u(e,n),e}var a=function(e){return function(t){return i(t)?t.get(e):t[e]}},f=function(){function e(e,t,n){if(void 0===t&&(t={}),void 0===n&&(n={}),!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");var i=n,o=i.idAttribute,u=void 0===o?"id":o,c=i.mergeStrategy,f=void 0===c?function(e,t){return r({},e,{},t)}:c,s=i.processStrategy,h=void 0===s?function(e){return r({},e)}:s;this._key=e,this._getId="function"==typeof u?u:a(u),this._idAttribute=u,this._mergeStrategy=f,this._processStrategy=h,this.define(t)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var i,o=e[n];return r({},t,((i={})[n]=o,i))}),this.schema||{})},t.getId=function(e,t,n){return this._getId(e,t,n)},t.merge=function(e,t){return this._mergeStrategy(e,t)},t.normalize=function(e,t,n,r,i,o){var u=this;if(o.some((function(t){return t===e})))return this.getId(e,t,n);o.push(e);var c=this._processStrategy(e,t,n);return Object.keys(this.schema).forEach((function(e){if(c.hasOwnProperty(e)&&"object"==typeof c[e]){var t=u.schema[e];c[e]=r(c[e],c,e,t,i,o)}})),i(this,c,e,t,n),this.getId(e,t,n)},t.denormalize=function(e,t){var n=this;return i(e)?o(this.schema,e,t):(Object.keys(this.schema).forEach((function(r){if(e.hasOwnProperty(r)){var i=n.schema[r];e[r]=t(e[r],i)}})),e)},c(e,[{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),e}();function s(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var h=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=e},t.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},t.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},t.normalizeValue=function(e,t,n,r,i,o){var u=this.inferSchema(e,t,n);if(!u)return e;var c=r(e,t,n,u,i,o);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,n)}},t.denormalizeValue=function(e,t){var n=i(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?t((i(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[n]):e},c(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),l=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}s(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},t}(h),y=function(e){function t(){return e.apply(this,arguments)||this}s(t,e);var n=t.prototype;return n.normalize=function(e,t,n,i,o,u){var c=this;return Object.keys(e).reduce((function(t,n,a){var f,s=e[n];return null!=s?r({},t,((f={})[n]=c.normalizeValue(s,e,n,i,o,u),f)):t}),{})},n.denormalize=function(e,t){var n=this;return Object.keys(e).reduce((function(i,o){var u,c=e[o];return r({},i,((u={})[o]=n.denormalizeValue(c,t),u))}),{})},t}(h),p=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},m=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},d=function(e,t,n,r,i,o,u){return e=p(e),m(t).map((function(t,c){return i(t,n,r,e,o,u)}))},b=function(e,t,n){return e=p(e),t&&t.map?t.map((function(t){return n(t,e)})):t},v=function(e){function t(){return e.apply(this,arguments)||this}s(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var u=this;return m(e).map((function(e,c){return u.normalizeValue(e,t,n,r,i,o)})).filter((function(e){return null!=e}))},n.denormalize=function(e,t){var n=this;return e&&e.map?e.map((function(e){return n.denormalizeValue(e,t)})):e},t}(h),g=function(e,t,n,i,o,u,c){var a=r({},t);return Object.keys(e).forEach((function(n){var r=e[n],i=o(t[n],t,n,r,u,c);null==i?delete a[n]:a[n]=i})),a},O=function(e,t,n){if(i(t))return o(e,t,n);var u=r({},t);return Object.keys(e).forEach((function(t){null!=u[t]&&(u[t]=n(u[t],e[t]))})),u},j=function e(t,n,r,i,o,u){return"object"==typeof t&&t?"object"!=typeof i||i.normalize&&"function"==typeof i.normalize?i.normalize(t,n,r,e,o,u):(Array.isArray(i)?d:g)(i,t,n,r,e,o,u):t},z={Array:v,Entity:f,Object:function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var i,o=e[n];return r({},t,((i={})[n]=o,i))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return O.apply(void 0,[this.schema].concat(t))},e}(),Union:l,Values:y},k=function(e){var t={},n=S(e);return function e(o,u){return"object"!=typeof u||u.denormalize&&"function"==typeof u.denormalize?null==o?o:u instanceof f?function(e,t,n,o,u){var c=o(e,t);if("object"!=typeof c||null===c)return c;if(u[t.key]||(u[t.key]={}),!u[t.key][e]){var a=i(c)?c:r({},c);u[t.key][e]=a,u[t.key][e]=t.denormalize(a,n)}return u[t.key][e]}(o,u,e,n,t):"function"==typeof u.denormalize?u.denormalize(o,e):o:(Array.isArray(u)?b:O)(u,o,e)}},S=function(e){var t=i(e);return function(n,r){var i=r.key;return"object"==typeof n?n:t?e.getIn([i,n.toString()]):e[i]&&e[i][n]}};e.denormalize=function(e,t,n){if(void 0!==e)return k(n)(e,t)},e.normalize=function(e,t){if(!e||"object"!=typeof e)throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+(null===e?"null":typeof e)+'".');var n={},r=function(e){return function(t,n,r,i,o){var u=t.key,c=t.getId(r,i,o);u in e||(e[u]={});var a=e[u][c];e[u][c]=a?t.merge(a,n):n}}(n);return{entities:n,result:j(e,e,null,t,r,[])}},e.schema=z,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@rest-hooks/normalizr",
"version": "3.4.2",
"version": "3.4.3",
"description": "Normalizes and denormalizes JSON according to schema for Redux and Flux applications",

@@ -60,3 +60,3 @@ "bugs": {

"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.5.5",
"@babel/plugin-transform-runtime": "^7.6.0",
"@babel/preset-env": "^7.0.0",

@@ -83,3 +83,5 @@ "@babel/preset-flow": "^7.0.0",

"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-filesize": "^6.1.1",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^5.0.0",

@@ -89,4 +91,4 @@ "typescript": "^3.4.5"

"dependencies": {
"@babel/runtime": "^7.5.5"
"@babel/runtime": "^7.6.0"
}
}
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