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

normalizr

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

normalizr - npm Package Compare versions

Comparing version 3.4.0 to 3.4.1

11

dist/normalizr.amd.js

@@ -99,7 +99,2 @@ define(['exports'], function (exports) { 'use strict';

var ImmutableUtils = /*#__PURE__*/Object.freeze({
isImmutable: isImmutable,
denormalizeImmutable: denormalizeImmutable
});
var getDefaultGetId = function getDefaultGetId(idAttribute) {

@@ -589,3 +584,7 @@ return function (input) {

return isImmutable$1 ? entities.getIn([schemaKey, entityOrId.toString()]) : entities[schemaKey][entityOrId];
if (isImmutable$1) {
return entities.getIn([schemaKey, entityOrId.toString()]);
}
return entities[schemaKey] && entities[schemaKey][entityOrId];
};

@@ -592,0 +591,0 @@ };

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

define(["exports"],function(e){"use strict";function t(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 n(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){r(e,t,n[t])})}return e}function o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function u(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function c(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 a=function(e){return function(t){return u(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 r=n,o=r.idAttribute,u=void 0===o?"id":o,c=r.mergeStrategy,f=void 0===c?function(e,t){return i({},e,t)}:c,s=r.processStrategy,h=void 0===s?function(e){return i({},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 r,o=e[n];return i({},t,((r={})[n]=o,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,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 u(e)?c(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}(),s=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=u(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?t((u(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}(),h=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}o(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}(s),l=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,o,u){var c=this;return Object.keys(e).reduce(function(t,n,a){var f,s=e[n];return null!=s?i({},t,((f={})[n]=c.normalizeValue(s,e,n,r,o,u),f)):t},{})},n.denormalize=function(e,t){var n=this;return Object.keys(e).reduce(function(r,o){var u,c=e[o];return i({},r,((u={})[o]=n.denormalizeValue(c,t),u))},{})},t}(s),y=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]})},p=function(e,t,n,r,i,o,u){return e=y(e),m(t).map(function(t,c){return i(t,n,r,e,o,u)})},d=function(e,t,n){return e=y(e),t&&t.map?t.map(function(t){return n(t,e)}):t},v=function(e){function t(){return e.apply(this,arguments)||this}o(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}(s),b=function(e,t,n,r,o,u,c){var a=i({},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},g=function(e,t,n){if(u(t))return c(e,t,n);var r=i({},t);return Object.keys(e).forEach(function(t){null!=r[t]&&(r[t]=n(r[t],e[t]))}),r},z=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)?p:b)(i,t,n,r,e,o,u):t},j={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 r,o=e[n];return i({},t,((r={})[n]=o,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 b.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 g.apply(void 0,[this.schema].concat(t))},e}(),Union:h,Values:l},k=function(e){var t={},n=O(e);return function e(r,o){return"object"!=typeof o||o.denormalize&&"function"==typeof o.denormalize?null==r?r:o instanceof f?function(e,t,n,r,o){var c=r(e,t);if("object"!=typeof c||null===c)return c;if(o[t.key]||(o[t.key]={}),!o[t.key][e]){var a=u(c)?c:i({},c);o[t.key][e]=a,o[t.key][e]=t.denormalize(a,n)}return o[t.key][e]}(r,o,e,n,t):o.denormalize(r,e):(Array.isArray(o)?d:g)(o,r,e)}},O=function(e){var t=u(e);return function(n,r){var i=r.key;return"object"==typeof n?n:t?e.getIn([i,n.toString()]):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 "'+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:z(e,e,null,t,r,[])}},e.schema=j,Object.defineProperty(e,"__esModule",{value:!0})});
define(["exports"],function(e){"use strict";function t(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 n(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){r(e,t,n[t])})}return e}function o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function u(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function c(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 a=function(e){return function(t){return u(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 r=n,o=r.idAttribute,u=void 0===o?"id":o,c=r.mergeStrategy,f=void 0===c?function(e,t){return i({},e,t)}:c,s=r.processStrategy,h=void 0===s?function(e){return i({},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 r,o=e[n];return i({},t,((r={})[n]=o,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,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 u(e)?c(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}(),s=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=u(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?t((u(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}(),h=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}o(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}(s),l=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,o,u){var c=this;return Object.keys(e).reduce(function(t,n,a){var f,s=e[n];return null!=s?i({},t,((f={})[n]=c.normalizeValue(s,e,n,r,o,u),f)):t},{})},n.denormalize=function(e,t){var n=this;return Object.keys(e).reduce(function(r,o){var u,c=e[o];return i({},r,((u={})[o]=n.denormalizeValue(c,t),u))},{})},t}(s),y=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]})},p=function(e,t,n,r,i,o,u){return e=y(e),m(t).map(function(t,c){return i(t,n,r,e,o,u)})},d=function(e,t,n){return e=y(e),t&&t.map?t.map(function(t){return n(t,e)}):t},v=function(e){function t(){return e.apply(this,arguments)||this}o(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}(s),b=function(e,t,n,r,o,u,c){var a=i({},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},g=function(e,t,n){if(u(t))return c(e,t,n);var r=i({},t);return Object.keys(e).forEach(function(t){null!=r[t]&&(r[t]=n(r[t],e[t]))}),r},z=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)?p:b)(i,t,n,r,e,o,u):t},j={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 r,o=e[n];return i({},t,((r={})[n]=o,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 b.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 g.apply(void 0,[this.schema].concat(t))},e}(),Union:h,Values:l},k=function(e){var t={},n=O(e);return function e(r,o){return"object"!=typeof o||o.denormalize&&"function"==typeof o.denormalize?null==r?r:o instanceof f?function(e,t,n,r,o){var c=r(e,t);if("object"!=typeof c||null===c)return c;if(o[t.key]||(o[t.key]={}),!o[t.key][e]){var a=u(c)?c:i({},c);o[t.key][e]=a,o[t.key][e]=t.denormalize(a,n)}return o[t.key][e]}(r,o,e,n,t):o.denormalize(r,e):(Array.isArray(o)?d:g)(o,r,e)}},O=function(e){var t=u(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 "'+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:z(e,e,null,t,r,[])}},e.schema=j,Object.defineProperty(e,"__esModule",{value:!0})});

@@ -100,7 +100,2 @@ var normalizr = (function (exports) {

var ImmutableUtils = /*#__PURE__*/Object.freeze({
isImmutable: isImmutable,
denormalizeImmutable: denormalizeImmutable
});
var getDefaultGetId = function getDefaultGetId(idAttribute) {

@@ -590,3 +585,7 @@ return function (input) {

return isImmutable$1 ? entities.getIn([schemaKey, entityOrId.toString()]) : entities[schemaKey][entityOrId];
if (isImmutable$1) {
return entities.getIn([schemaKey, entityOrId.toString()]);
}
return entities[schemaKey] && entities[schemaKey][entityOrId];
};

@@ -593,0 +592,0 @@ };

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

var normalizr=function(t){"use strict";function e(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function n(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){r(t,e,n[e])})}return t}function o(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function u(t){return!(!t||"function"!=typeof t.hasOwnProperty||!(t.hasOwnProperty("__ownerID")||t._map&&t._map.hasOwnProperty("__ownerID")))}function c(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)}var a=function(t){return function(e){return u(e)?e.get(t):e[t]}},f=function(){function t(t,e,n){if(void 0===e&&(e={}),void 0===n&&(n={}),!t||"string"!=typeof t)throw new Error("Expected a string key for Entity, but found "+t+".");var r=n,o=r.idAttribute,u=void 0===o?"id":o,c=r.mergeStrategy,f=void 0===c?function(t,e){return i({},t,e)}:c,s=r.processStrategy,h=void 0===s?function(t){return i({},t)}:s;this._key=t,this._getId="function"==typeof u?u:a(u),this._idAttribute=u,this._mergeStrategy=f,this._processStrategy=h,this.define(e)}var e=t.prototype;return e.define=function(t){this.schema=Object.keys(t).reduce(function(e,n){var r,o=t[n];return i({},e,((r={})[n]=o,r))},this.schema||{})},e.getId=function(t,e,n){return this._getId(t,e,n)},e.merge=function(t,e){return this._mergeStrategy(t,e)},e.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 c=this._processStrategy(t,e,n);return Object.keys(this.schema).forEach(function(t){if(c.hasOwnProperty(t)&&"object"==typeof c[t]){var e=u.schema[t];c[t]=r(c[t],c,t,e,i,o)}}),i(this,c,t,e,n),this.getId(t,e,n)},e.denormalize=function(t,e){var n=this;return u(t)?c(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}(),s=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 c=r(t,e,n,u,i,o);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(t,e,n)}},e.denormalizeValue=function(t,e){var n=u(t)?t.get("schema"):t.schema;return this.isSingleSchema||n?e((u(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}(),h=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}o(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}(s),l=function(t){function e(){return t.apply(this,arguments)||this}o(e,t);var n=e.prototype;return n.normalize=function(t,e,n,r,o,u){var c=this;return Object.keys(t).reduce(function(e,n,a){var f,s=t[n];return null!=s?i({},e,((f={})[n]=c.normalizeValue(s,t,n,r,o,u),f)):e},{})},n.denormalize=function(t,e){var n=this;return Object.keys(t).reduce(function(r,o){var u,c=t[o];return i({},r,((u={})[o]=n.denormalizeValue(c,e),u))},{})},e}(s),m=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]},y=function(t){return Array.isArray(t)?t:Object.keys(t).map(function(e){return t[e]})},p=function(t,e,n,r,i,o,u){return t=m(t),y(e).map(function(e,c){return i(e,n,r,t,o,u)})},d=function(t,e,n){return t=m(t),e&&e.map?e.map(function(e){return n(e,t)}):e},v=function(t){function e(){return t.apply(this,arguments)||this}o(e,t);var n=e.prototype;return n.normalize=function(t,e,n,r,i,o){var u=this;return y(t).map(function(t,c){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}(s),b=function(t,e,n,r,o,u,c){var a=i({},e);return Object.keys(t).forEach(function(n){var r=t[n],i=o(e[n],e,n,r,u,c);null==i?delete a[n]:a[n]=i}),a},g=function(t,e,n){if(u(e))return c(t,e,n);var r=i({},e);return Object.keys(t).forEach(function(e){null!=r[e]&&(r[e]=n(r[e],t[e]))}),r},z=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)?p:b)(i,e,n,r,t,o,u):e},k={Array:v,Entity:f,Object:function(){function t(t){this.define(t)}var e=t.prototype;return e.define=function(t){this.schema=Object.keys(t).reduce(function(e,n){var r,o=t[n];return i({},e,((r={})[n]=o,r))},this.schema||{})},e.normalize=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return b.apply(void 0,[this.schema].concat(e))},e.denormalize=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return g.apply(void 0,[this.schema].concat(e))},t}(),Union:h,Values:l},S=function(t){var e={},n=j(t);return function t(r,o){return"object"!=typeof o||o.denormalize&&"function"==typeof o.denormalize?null==r?r:o instanceof f?function(t,e,n,r,o){var c=r(t,e);if("object"!=typeof c||null===c)return c;if(o[e.key]||(o[e.key]={}),!o[e.key][t]){var a=u(c)?c:i({},c);o[e.key][t]=a,o[e.key][t]=e.denormalize(a,n)}return o[e.key][t]}(r,o,t,n,e):o.denormalize(r,t):(Array.isArray(o)?d:g)(o,r,t)}},j=function(t){var e=u(t);return function(n,r){var i=r.key;return"object"==typeof n?n:e?t.getIn([i,n.toString()]):t[i][n]}};return t.denormalize=function(t,e,n){if(void 0!==t)return S(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 "'+typeof t+'".');var n={},r=function(t){return function(e,n,r,i,o){var u=e.key,c=e.getId(r,i,o);u in t||(t[u]={});var a=t[u][c];t[u][c]=a?e.merge(a,n):n}}(n);return{entities:n,result:z(t,t,null,e,r,[])}},t.schema=k,t}({});
var normalizr=function(t){"use strict";function e(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function n(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){r(t,e,n[e])})}return t}function o(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function u(t){return!(!t||"function"!=typeof t.hasOwnProperty||!(t.hasOwnProperty("__ownerID")||t._map&&t._map.hasOwnProperty("__ownerID")))}function c(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)}var a=function(t){return function(e){return u(e)?e.get(t):e[t]}},f=function(){function t(t,e,n){if(void 0===e&&(e={}),void 0===n&&(n={}),!t||"string"!=typeof t)throw new Error("Expected a string key for Entity, but found "+t+".");var r=n,o=r.idAttribute,u=void 0===o?"id":o,c=r.mergeStrategy,f=void 0===c?function(t,e){return i({},t,e)}:c,s=r.processStrategy,h=void 0===s?function(t){return i({},t)}:s;this._key=t,this._getId="function"==typeof u?u:a(u),this._idAttribute=u,this._mergeStrategy=f,this._processStrategy=h,this.define(e)}var e=t.prototype;return e.define=function(t){this.schema=Object.keys(t).reduce(function(e,n){var r,o=t[n];return i({},e,((r={})[n]=o,r))},this.schema||{})},e.getId=function(t,e,n){return this._getId(t,e,n)},e.merge=function(t,e){return this._mergeStrategy(t,e)},e.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 c=this._processStrategy(t,e,n);return Object.keys(this.schema).forEach(function(t){if(c.hasOwnProperty(t)&&"object"==typeof c[t]){var e=u.schema[t];c[t]=r(c[t],c,t,e,i,o)}}),i(this,c,t,e,n),this.getId(t,e,n)},e.denormalize=function(t,e){var n=this;return u(t)?c(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}(),s=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 c=r(t,e,n,u,i,o);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(t,e,n)}},e.denormalizeValue=function(t,e){var n=u(t)?t.get("schema"):t.schema;return this.isSingleSchema||n?e((u(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}(),h=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}o(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}(s),l=function(t){function e(){return t.apply(this,arguments)||this}o(e,t);var n=e.prototype;return n.normalize=function(t,e,n,r,o,u){var c=this;return Object.keys(t).reduce(function(e,n,a){var f,s=t[n];return null!=s?i({},e,((f={})[n]=c.normalizeValue(s,t,n,r,o,u),f)):e},{})},n.denormalize=function(t,e){var n=this;return Object.keys(t).reduce(function(r,o){var u,c=t[o];return i({},r,((u={})[o]=n.denormalizeValue(c,e),u))},{})},e}(s),m=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]},y=function(t){return Array.isArray(t)?t:Object.keys(t).map(function(e){return t[e]})},p=function(t,e,n,r,i,o,u){return t=m(t),y(e).map(function(e,c){return i(e,n,r,t,o,u)})},d=function(t,e,n){return t=m(t),e&&e.map?e.map(function(e){return n(e,t)}):e},v=function(t){function e(){return t.apply(this,arguments)||this}o(e,t);var n=e.prototype;return n.normalize=function(t,e,n,r,i,o){var u=this;return y(t).map(function(t,c){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}(s),b=function(t,e,n,r,o,u,c){var a=i({},e);return Object.keys(t).forEach(function(n){var r=t[n],i=o(e[n],e,n,r,u,c);null==i?delete a[n]:a[n]=i}),a},g=function(t,e,n){if(u(e))return c(t,e,n);var r=i({},e);return Object.keys(t).forEach(function(e){null!=r[e]&&(r[e]=n(r[e],t[e]))}),r},z=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)?p:b)(i,e,n,r,t,o,u):e},k={Array:v,Entity:f,Object:function(){function t(t){this.define(t)}var e=t.prototype;return e.define=function(t){this.schema=Object.keys(t).reduce(function(e,n){var r,o=t[n];return i({},e,((r={})[n]=o,r))},this.schema||{})},e.normalize=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return b.apply(void 0,[this.schema].concat(e))},e.denormalize=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return g.apply(void 0,[this.schema].concat(e))},t}(),Union:h,Values:l},S=function(t){var e={},n=j(t);return function t(r,o){return"object"!=typeof o||o.denormalize&&"function"==typeof o.denormalize?null==r?r:o instanceof f?function(t,e,n,r,o){var c=r(t,e);if("object"!=typeof c||null===c)return c;if(o[e.key]||(o[e.key]={}),!o[e.key][t]){var a=u(c)?c:i({},c);o[e.key][t]=a,o[e.key][t]=e.denormalize(a,n)}return o[e.key][t]}(r,o,t,n,e):o.denormalize(r,t):(Array.isArray(o)?d:g)(o,r,t)}},j=function(t){var e=u(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 S(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 "'+typeof t+'".');var n={},r=function(t){return function(e,n,r,i,o){var u=e.key,c=e.getId(r,i,o);u in t||(t[u]={});var a=t[u][c];t[u][c]=a?e.merge(a,n):n}}(n);return{entities:n,result:z(t,t,null,e,r,[])}},t.schema=k,t}({});

@@ -97,7 +97,2 @@ function _defineProperties(target, props) {

var ImmutableUtils = /*#__PURE__*/Object.freeze({
isImmutable: isImmutable,
denormalizeImmutable: denormalizeImmutable
});
var getDefaultGetId = function getDefaultGetId(idAttribute) {

@@ -587,3 +582,7 @@ return function (input) {

return isImmutable$1 ? entities.getIn([schemaKey, entityOrId.toString()]) : entities[schemaKey][entityOrId];
if (isImmutable$1) {
return entities.getIn([schemaKey, entityOrId.toString()]);
}
return entities[schemaKey] && entities[schemaKey][entityOrId];
};

@@ -590,0 +589,0 @@ };

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

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

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

var ImmutableUtils = /*#__PURE__*/Object.freeze({
isImmutable: isImmutable,
denormalizeImmutable: denormalizeImmutable
});
var getDefaultGetId = function getDefaultGetId(idAttribute) {

@@ -591,3 +586,7 @@ return function (input) {

return isImmutable$1 ? entities.getIn([schemaKey, entityOrId.toString()]) : entities[schemaKey][entityOrId];
if (isImmutable$1) {
return entities.getIn([schemaKey, entityOrId.toString()]);
}
return entities[schemaKey] && entities[schemaKey][entityOrId];
};

@@ -594,0 +593,0 @@ };

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

"use strict";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}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 _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){_defineProperty(e,t,r[t])})}return e}function _inheritsLoose(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}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)}Object.defineProperty(exports,"__esModule",{value:!0});var ImmutableUtils=Object.freeze({isImmutable:isImmutable,denormalizeImmutable:denormalizeImmutable}),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 _objectSpread({},e,t)}:a,c=n.processStrategy,s=void 0===c?function(e){return _objectSpread({},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 _objectSpread({},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}(),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?_objectSpread({},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 _objectSpread({},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=_objectSpread({},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=_objectSpread({},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 _objectSpread({},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 "'+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:_objectSpread({},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):i.denormalize(n,e):(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][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;
"use strict";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}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 _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){_defineProperty(e,t,r[t])})}return e}function _inheritsLoose(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}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)}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 _objectSpread({},e,t)}:a,c=n.processStrategy,s=void 0===c?function(e){return _objectSpread({},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 _objectSpread({},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}(),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?_objectSpread({},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 _objectSpread({},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=_objectSpread({},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=_objectSpread({},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 _objectSpread({},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 "'+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:_objectSpread({},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):i.denormalize(n,e):(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;

@@ -103,7 +103,2 @@ (function (global, factory) {

var ImmutableUtils = /*#__PURE__*/Object.freeze({
isImmutable: isImmutable,
denormalizeImmutable: denormalizeImmutable
});
var getDefaultGetId = function getDefaultGetId(idAttribute) {

@@ -593,3 +588,7 @@ return function (input) {

return isImmutable$1 ? entities.getIn([schemaKey, entityOrId.toString()]) : entities[schemaKey][entityOrId];
if (isImmutable$1) {
return entities.getIn([schemaKey, entityOrId.toString()]);
}
return entities[schemaKey] && entities[schemaKey][entityOrId];
};

@@ -596,0 +595,0 @@ };

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).normalizr={})}(this,function(e){"use strict";function t(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 n(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){r(e,t,n[t])})}return e}function o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function u(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function c(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 a=function(e){return function(t){return u(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 r=n,o=r.idAttribute,u=void 0===o?"id":o,c=r.mergeStrategy,f=void 0===c?function(e,t){return i({},e,t)}:c,s=r.processStrategy,h=void 0===s?function(e){return i({},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 r,o=e[n];return i({},t,((r={})[n]=o,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,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 u(e)?c(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}(),s=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=u(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?t((u(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}(),h=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}o(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}(s),l=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,o,u){var c=this;return Object.keys(e).reduce(function(t,n,a){var f,s=e[n];return null!=s?i({},t,((f={})[n]=c.normalizeValue(s,e,n,r,o,u),f)):t},{})},n.denormalize=function(e,t){var n=this;return Object.keys(e).reduce(function(r,o){var u,c=e[o];return i({},r,((u={})[o]=n.denormalizeValue(c,t),u))},{})},t}(s),y=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]})},p=function(e,t,n,r,i,o,u){return e=y(e),m(t).map(function(t,c){return i(t,n,r,e,o,u)})},d=function(e,t,n){return e=y(e),t&&t.map?t.map(function(t){return n(t,e)}):t},v=function(e){function t(){return e.apply(this,arguments)||this}o(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}(s),b=function(e,t,n,r,o,u,c){var a=i({},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},g=function(e,t,n){if(u(t))return c(e,t,n);var r=i({},t);return Object.keys(e).forEach(function(t){null!=r[t]&&(r[t]=n(r[t],e[t]))}),r},z=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)?p:b)(i,t,n,r,e,o,u):t},j={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 r,o=e[n];return i({},t,((r={})[n]=o,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 b.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 g.apply(void 0,[this.schema].concat(t))},e}(),Union:h,Values:l},k=function(e){var t={},n=O(e);return function e(r,o){return"object"!=typeof o||o.denormalize&&"function"==typeof o.denormalize?null==r?r:o instanceof f?function(e,t,n,r,o){var c=r(e,t);if("object"!=typeof c||null===c)return c;if(o[t.key]||(o[t.key]={}),!o[t.key][e]){var a=u(c)?c:i({},c);o[t.key][e]=a,o[t.key][e]=t.denormalize(a,n)}return o[t.key][e]}(r,o,e,n,t):o.denormalize(r,e):(Array.isArray(o)?d:g)(o,r,e)}},O=function(e){var t=u(e);return function(n,r){var i=r.key;return"object"==typeof n?n:t?e.getIn([i,n.toString()]):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 "'+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:z(e,e,null,t,r,[])}},e.schema=j,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).normalizr={})}(this,function(e){"use strict";function t(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 n(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){r(e,t,n[t])})}return e}function o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function u(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function c(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 a=function(e){return function(t){return u(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 r=n,o=r.idAttribute,u=void 0===o?"id":o,c=r.mergeStrategy,f=void 0===c?function(e,t){return i({},e,t)}:c,s=r.processStrategy,h=void 0===s?function(e){return i({},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 r,o=e[n];return i({},t,((r={})[n]=o,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,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 u(e)?c(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}(),s=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=u(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?t((u(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}(),h=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}o(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}(s),l=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,o,u){var c=this;return Object.keys(e).reduce(function(t,n,a){var f,s=e[n];return null!=s?i({},t,((f={})[n]=c.normalizeValue(s,e,n,r,o,u),f)):t},{})},n.denormalize=function(e,t){var n=this;return Object.keys(e).reduce(function(r,o){var u,c=e[o];return i({},r,((u={})[o]=n.denormalizeValue(c,t),u))},{})},t}(s),y=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]})},p=function(e,t,n,r,i,o,u){return e=y(e),m(t).map(function(t,c){return i(t,n,r,e,o,u)})},d=function(e,t,n){return e=y(e),t&&t.map?t.map(function(t){return n(t,e)}):t},v=function(e){function t(){return e.apply(this,arguments)||this}o(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}(s),b=function(e,t,n,r,o,u,c){var a=i({},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},g=function(e,t,n){if(u(t))return c(e,t,n);var r=i({},t);return Object.keys(e).forEach(function(t){null!=r[t]&&(r[t]=n(r[t],e[t]))}),r},z=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)?p:b)(i,t,n,r,e,o,u):t},j={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 r,o=e[n];return i({},t,((r={})[n]=o,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 b.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 g.apply(void 0,[this.schema].concat(t))},e}(),Union:h,Values:l},k=function(e){var t={},n=O(e);return function e(r,o){return"object"!=typeof o||o.denormalize&&"function"==typeof o.denormalize?null==r?r:o instanceof f?function(e,t,n,r,o){var c=r(e,t);if("object"!=typeof c||null===c)return c;if(o[t.key]||(o[t.key]={}),!o[t.key][e]){var a=u(c)?c:i({},c);o[t.key][e]=a,o[t.key][e]=t.denormalize(a,n)}return o[t.key][e]}(r,o,e,n,t):o.denormalize(r,e):(Array.isArray(o)?d:g)(o,r,e)}},O=function(e){var t=u(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 "'+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:z(e,e,null,t,r,[])}},e.schema=j,Object.defineProperty(e,"__esModule",{value:!0})});
declare namespace schema {
export type StrategyFunction = (value: any, parent: any, key: string) => any;
export type StrategyFunction<T> = (value: any, parent: any, key: string) => T;
export type SchemaFunction = (value: any, parent: any, key: string) => string;
export type MergeFunction = (entityA: any, entityB: any) => any;
export class Array {
constructor(definition: Schema, schemaAttribute?: string | SchemaFunction)
export class Array<T = any> {
constructor(definition: Schema<T>, schemaAttribute?: string | SchemaFunction)
define(definition: Schema): void
}
export interface EntityOptions {
export interface EntityOptions<T = any> {
idAttribute?: string | SchemaFunction
mergeStrategy?: MergeFunction
processStrategy?: StrategyFunction
processStrategy?: StrategyFunction<T>
}
export class Entity {
constructor(key: string | symbol, definition?: Schema, options?: EntityOptions)
export class Entity<T = any> {
constructor(key: string | symbol, definition?: Schema, options?: EntityOptions<T>)
define(definition: Schema): void
key: string
getId: SchemaFunction
_processStrategy: StrategyFunction<T>
}
export class Object {
constructor(definition: {[key: string]: Schema})
export class Object<T = any> {
constructor(definition: {[key: string]: Schema<T>})
define(definition: Schema): void
}
export class Union {
constructor(definition: Schema, schemaAttribute?: string | SchemaFunction)
export class Union<T = any> {
constructor(definition: Schema<T>, schemaAttribute?: string | SchemaFunction)
define(definition: Schema): void
}
export class Values {
constructor(definition: Schema, schemaAttribute?: string | SchemaFunction)
export class Values<T = any> {
constructor(definition: Schema<T>, schemaAttribute?: string | SchemaFunction)
define(definition: Schema): void

@@ -39,20 +41,21 @@ }

export type Schema =
schema.Array |
schema.Entity |
schema.Object |
schema.Union |
schema.Values |
schema.Array[] |
schema.Entity[] |
schema.Object[] |
schema.Union[] |
schema.Values[] |
{[key: string]: Schema | Schema[]};
export type Schema<T = any> =
| schema.Entity<T>
| schema.Object<T>
| schema.Union<T>
| schema.Values<T>
| SchemaObject<T>
| SchemaArray<T>;
export interface SchemaObject<T> {
[key: string]: Schema<T>
}
export interface SchemaArray<T> extends Array<Schema<T>> {}
export type NormalizedSchema<E, R> = { entities: E, result: R };
export function normalize<E = any, R = any>(
export function normalize<T = any, E = { [key:string]: { [key:string]: T }}, R = any>(
data: any,
schema: Schema
schema: Schema<T>
): NormalizedSchema<E, R>;

@@ -59,0 +62,0 @@

{
"name": "normalizr",
"version": "3.4.0",
"version": "3.4.1",
"description": "Normalizes and denormalizes JSON according to schema for Redux and Flux applications",

@@ -66,7 +66,7 @@ "bugs": {

"eslint": "^5.16.0",
"eslint-config-prettier": "^4.3.0",
"eslint-config-prettier": "^5.0.0",
"eslint-plugin-jest": "^22.6.4",
"eslint-plugin-json": "^1.4.0",
"eslint-plugin-prettier": "^3.1.0",
"flow-bin": "^0.99.0",
"flow-bin": "^0.101.0",
"husky": "^2.3.0",

@@ -79,5 +79,5 @@ "immutable": "^3.8.1",

"rimraf": "^2.6.3",
"rollup": "^1.12.4",
"rollup-plugin-babel": "^4.0.1",
"rollup-plugin-filesize": "^6.1.0",
"rollup": "^1.15.6",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-filesize": "^6.1.1",
"rollup-plugin-terser": "^5.0.0",

@@ -84,0 +84,0 @@ "typescript": "^3.4.5"

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