New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 4.3.2 to 4.3.3

9

CHANGELOG.md

@@ -6,2 +6,11 @@ # Change Log

### [4.3.3](https://github.com/coinbase/rest-hooks/compare/@rest-hooks/normalizr@4.3.2...@rest-hooks/normalizr@4.3.3) (2020-01-27)
### 💅 Enhancement
* Keep referential equality in list views ([#251](https://github.com/coinbase/rest-hooks/issues/251)) ([caf2bf7](https://github.com/coinbase/rest-hooks/commit/caf2bf78e6c48af8a32b080291ae60615ad05b34))
### [4.3.2](https://github.com/coinbase/rest-hooks/compare/@rest-hooks/normalizr@4.3.1...@rest-hooks/normalizr@4.3.2) (2020-01-18)

@@ -8,0 +17,0 @@

18

dist/normalizr.amd.js

@@ -655,3 +655,3 @@ define(['exports'], function (exports) { 'use strict';

var getEntity = getEntities(entities);
return function unvisit(input, schema) {
return [function unvisit(input, schema) {
if (!schema) return [input, true];

@@ -683,3 +683,3 @@

return [input, true];
};
}, cache];
};

@@ -704,3 +704,3 @@

var denormalize$1 = function denormalize(input, schema, entities) {
var denormalizeAndTracked = function denormalizeAndTracked(input, schema, entities) {
/* istanbul ignore next */

@@ -711,9 +711,17 @@ // eslint-disable-next-line no-undef

if (typeof input !== 'undefined') {
return getUnvisit(entities)(input, schema);
var _getUnvisit = getUnvisit(entities),
unvisit = _getUnvisit[0],
cache = _getUnvisit[1];
return [].concat(unvisit(input, schema), [cache]);
}
return [undefined, false];
return [undefined, false, {}];
};
var denormalize$1 = function denormalize(input, schema, entities) {
return denormalizeAndTracked(input, schema, entities).slice(0, 2);
};
exports.denormalize = denormalize$1;
exports.denormalizeAndTracked = denormalizeAndTracked;
exports.normalize = normalize$1;

@@ -720,0 +728,0 @@ exports.schema = schema;

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

define(["exports"],(function(e){"use strict";function t(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function r(e,t,r){let n=!0;return[Object.keys(e).reduce((t,i)=>{const s=""+i,[o,c]=r(t.get(s),e[s]);return c||(n=!1),t.has(s)?t.set(s,o):t},t),n]}class n{constructor(e,t){t&&(this._schemaAttribute="string"==typeof t?e=>e[t]:t),this.define(e)}get isSingleSchema(){return!this._schemaAttribute}define(e){this.schema=e}getSchemaAttribute(e,t,r){return!this.isSingleSchema&&this._schemaAttribute(e,t,r)}inferSchema(e,t,r){if(this.isSingleSchema)return this.schema;const n=this.getSchemaAttribute(e,t,r);return this.schema[n]}normalizeValue(e,t,r,n,i,s){const o=this.inferSchema(e,t,r);if(!o)return e;const c=n(e,t,r,o,i,s);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,r)}}denormalizeValue(e,r){const n=t(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?r((t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[n]):[e,!0]}}const i=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]},s=e=>Array.isArray(e)?e:Object.keys(e).map(t=>e[t]),o=(e,t,r,n,o,c,a)=>(e=i(e),s(t).map((t,i)=>o(t,r,n,e,c,a))),c=(e,t,r)=>{e=i(e);let n=!0;return void 0===t&&e&&([,n]=r(void 0,e)),[t&&t.map?t.map(t=>r(t,e)).filter(([,e])=>e).map(([e])=>e):t,n]};const a=(e,t,r,n,i,s,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(r=>{const n=e[r],a=i(t[r],t,r,n,s,o);null==a?delete c[r]:c[r]=a}),c},u=(e,n,i)=>{if(t(n))return r(e,n,i);const s=Object.assign({},n);let o=!0;return Object.keys(e).forEach(t=>{const[r,n]=i(s[t],e[t]);void 0!==s[t]&&(s[t]=r),n||(o=!1)}),[s,o]};const h=(e,t,r,n,i,s)=>{if("object"!=typeof e||!e||!n)return e;if("object"==typeof n&&(!n.normalize||"function"!=typeof n.normalize)){return(Array.isArray(n)?o:a)(n,e,t,r,h,i,s)}return n.normalize(e,t,r,h,i,s)},l={Array:class extends n{normalize(e,t,r,n,i,o){return s(e).map((e,s)=>this.normalizeValue(e,t,r,n,i,o)).filter(e=>null!=e)}denormalize(e,t){let r=!0;return void 0===e&&this.schema&&([,r]=t(void 0,this.schema)),[e&&e.map?e.map(e=>this.denormalizeValue(e,t)).filter(([,e])=>e).map(([e])=>e):e,r]}},Entity:class{constructor(e,r={},n={}){if(!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");const{idAttribute:i="id",mergeStrategy:s=((e,t)=>Object.assign({},e,{},t)),processStrategy:o=(e=>Object.assign({},e))}=n;this._key=e,this._getId="function"==typeof i?i:(e=>r=>t(r)?r.get(e):r[e])(i),this._idAttribute=i,this._mergeStrategy=s,this._processStrategy=o,this.define(r)}get key(){return this._key}get idAttribute(){return this._idAttribute}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}getId(e,t,r){return this._getId(e,t,r)}merge(e,t){return this._mergeStrategy(e,t)}normalize(e,t,r,n,i,s){const o=this.getId(e,t,r),c=this.key;if(c in s||(s[c]={}),o in s[c]||(s[c][o]=[]),s[c][o].some(t=>t===e))return o;s[c][o].push(e);const a=this._processStrategy(e,t,r);return Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(a,e)&&"object"==typeof a[e]){const t=this.schema[e];a[e]=n(a[e],a,e,t,i,s)}}),i(this,a,e,t,r),o}denormalize(e,n){if(t(e))return r(this.schema,e,n);let i=!0;return Object.keys(this.schema).forEach(t=>{const r=this.schema[t],[s,o]=n(e[t],r);o||(i=!1),Object.hasOwnProperty.call(e,t)&&(e[t]=s)}),[e,i]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}normalize(...e){return a(this.schema,...e)}denormalize(...e){return u(this.schema,...e)}},Union:class extends n{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,r,n,i,s){return this.normalizeValue(e,t,r,n,i,s)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends n{normalize(e,t,r,n,i,s){return Object.keys(e).reduce((t,r,o)=>{const c=e[r];return null!=c?Object.assign({},t,{[r]:this.normalizeValue(c,e,r,n,i,s)}):t},{})}denormalize(e,t){let r=!0;return[Object.keys(e).reduce((n,i)=>{const s=e[i],[o,c]=this.denormalizeValue(s,t);return c||(r=!1),Object.assign({},n,{[i]:o})},{}),r]}}};const m=e=>{const r={},n=d(e);return function e(i,s){if(!s)return[i,!0];if("object"==typeof s&&(!s.denormalize||"function"!=typeof s.denormalize)){return(Array.isArray(s)?c:u)(s,i,e)}return null===i?[i,!0]:"function"==typeof s.getId&&"function"==typeof s.normalize?void 0===i?[i,!1]:((e,r,n,i,s)=>{const o=i(e,r);if("object"!=typeof o||null===o)return[o,!1];s[r.key]||(s[r.key]={});let c=!0;if(!s[r.key][e]){const i=t(o)?o:Object.assign({},o);s[r.key][e]=i,[s[r.key][e],c]=r.denormalize(i,n)}return[s[r.key][e],c]})(i,s,e,n,r):"function"==typeof s.denormalize?s.denormalize(i,e):[i,!0]}},d=e=>{const r=t(e);return(t,n)=>{const i=n.key;return"object"==typeof t?t:r?e.getIn([i,t.toString()]):e[i]&&e[i][t]}};e.denormalize=(e,t,r)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("shema needed");return void 0!==e?m(r)(e,t):[void 0,!1]},e.normalize=(e,t)=>{const r=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==r)throw new Error('Unexpected input given to normalize. Expected type to be "'+r+'", found "'+(null===e?"null":typeof e)+'".');const n={},i={},s=((e,t)=>(r,n,i,s,o)=>{const c=r.key,a=r.getId(i,s,o);c in e||(e[c]={});const u=e[c][a];if(e[c][a]=u?r.merge(u,n):n,Array.isArray(r.indexes)){const n=e[c][a];c in t||(t[c]={});for(const e of r.indexes){e in t[c]||(t[c][e]={});const r=t[c][e];u&&delete r[u[e]],e in n?r[n[e]]=a:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+e+"\nEntity: "+JSON.stringify(n,void 0,2))}}})(n,i);return{entities:n,indexes:i,result:h(e,e,void 0,t,s,{})}},e.schema=l,Object.defineProperty(e,"__esModule",{value:!0})}));
define(["exports"],(function(e){"use strict";function t(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function r(e,t,r){let n=!0;return[Object.keys(e).reduce((t,i)=>{const s=""+i,[o,c]=r(t.get(s),e[s]);return c||(n=!1),t.has(s)?t.set(s,o):t},t),n]}class n{constructor(e,t){t&&(this._schemaAttribute="string"==typeof t?e=>e[t]:t),this.define(e)}get isSingleSchema(){return!this._schemaAttribute}define(e){this.schema=e}getSchemaAttribute(e,t,r){return!this.isSingleSchema&&this._schemaAttribute(e,t,r)}inferSchema(e,t,r){if(this.isSingleSchema)return this.schema;const n=this.getSchemaAttribute(e,t,r);return this.schema[n]}normalizeValue(e,t,r,n,i,s){const o=this.inferSchema(e,t,r);if(!o)return e;const c=n(e,t,r,o,i,s);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,r)}}denormalizeValue(e,r){const n=t(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?r((t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[n]):[e,!0]}}const i=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]},s=e=>Array.isArray(e)?e:Object.keys(e).map(t=>e[t]),o=(e,t,r,n,o,c,a)=>(e=i(e),s(t).map((t,i)=>o(t,r,n,e,c,a))),c=(e,t,r)=>{e=i(e);let n=!0;return void 0===t&&e&&([,n]=r(void 0,e)),[t&&t.map?t.map(t=>r(t,e)).filter(([,e])=>e).map(([e])=>e):t,n]};const a=(e,t,r,n,i,s,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(r=>{const n=e[r],a=i(t[r],t,r,n,s,o);null==a?delete c[r]:c[r]=a}),c},u=(e,n,i)=>{if(t(n))return r(e,n,i);const s=Object.assign({},n);let o=!0;return Object.keys(e).forEach(t=>{const[r,n]=i(s[t],e[t]);void 0!==s[t]&&(s[t]=r),n||(o=!1)}),[s,o]};const h=(e,t,r,n,i,s)=>{if("object"!=typeof e||!e||!n)return e;if("object"==typeof n&&(!n.normalize||"function"!=typeof n.normalize)){return(Array.isArray(n)?o:a)(n,e,t,r,h,i,s)}return n.normalize(e,t,r,h,i,s)},l={Array:class extends n{normalize(e,t,r,n,i,o){return s(e).map((e,s)=>this.normalizeValue(e,t,r,n,i,o)).filter(e=>null!=e)}denormalize(e,t){let r=!0;return void 0===e&&this.schema&&([,r]=t(void 0,this.schema)),[e&&e.map?e.map(e=>this.denormalizeValue(e,t)).filter(([,e])=>e).map(([e])=>e):e,r]}},Entity:class{constructor(e,r={},n={}){if(!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");const{idAttribute:i="id",mergeStrategy:s=((e,t)=>Object.assign({},e,{},t)),processStrategy:o=(e=>Object.assign({},e))}=n;this._key=e,this._getId="function"==typeof i?i:(e=>r=>t(r)?r.get(e):r[e])(i),this._idAttribute=i,this._mergeStrategy=s,this._processStrategy=o,this.define(r)}get key(){return this._key}get idAttribute(){return this._idAttribute}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}getId(e,t,r){return this._getId(e,t,r)}merge(e,t){return this._mergeStrategy(e,t)}normalize(e,t,r,n,i,s){const o=this.getId(e,t,r),c=this.key;if(c in s||(s[c]={}),o in s[c]||(s[c][o]=[]),s[c][o].some(t=>t===e))return o;s[c][o].push(e);const a=this._processStrategy(e,t,r);return Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(a,e)&&"object"==typeof a[e]){const t=this.schema[e];a[e]=n(a[e],a,e,t,i,s)}}),i(this,a,e,t,r),o}denormalize(e,n){if(t(e))return r(this.schema,e,n);let i=!0;return Object.keys(this.schema).forEach(t=>{const r=this.schema[t],[s,o]=n(e[t],r);o||(i=!1),Object.hasOwnProperty.call(e,t)&&(e[t]=s)}),[e,i]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}normalize(...e){return a(this.schema,...e)}denormalize(...e){return u(this.schema,...e)}},Union:class extends n{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,r,n,i,s){return this.normalizeValue(e,t,r,n,i,s)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends n{normalize(e,t,r,n,i,s){return Object.keys(e).reduce((t,r,o)=>{const c=e[r];return null!=c?Object.assign({},t,{[r]:this.normalizeValue(c,e,r,n,i,s)}):t},{})}denormalize(e,t){let r=!0;return[Object.keys(e).reduce((n,i)=>{const s=e[i],[o,c]=this.denormalizeValue(s,t);return c||(r=!1),Object.assign({},n,{[i]:o})},{}),r]}}};const m=e=>{const r={},n=d(e);return[function e(i,s){if(!s)return[i,!0];if("object"==typeof s&&(!s.denormalize||"function"!=typeof s.denormalize)){return(Array.isArray(s)?c:u)(s,i,e)}return null===i?[i,!0]:"function"==typeof s.getId&&"function"==typeof s.normalize?void 0===i?[i,!1]:((e,r,n,i,s)=>{const o=i(e,r);if("object"!=typeof o||null===o)return[o,!1];s[r.key]||(s[r.key]={});let c=!0;if(!s[r.key][e]){const i=t(o)?o:Object.assign({},o);s[r.key][e]=i,[s[r.key][e],c]=r.denormalize(i,n)}return[s[r.key][e],c]})(i,s,e,n,r):"function"==typeof s.denormalize?s.denormalize(i,e):[i,!0]},r]},d=e=>{const r=t(e);return(t,n)=>{const i=n.key;return"object"==typeof t?t:r?e.getIn([i,t.toString()]):e[i]&&e[i][t]}},f=(e,t,r)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("shema needed");if(void 0!==e){const[n,i]=m(r);return[...n(e,t),i]}return[void 0,!1,{}]};e.denormalize=(e,t,r)=>f(e,t,r).slice(0,2),e.denormalizeAndTracked=f,e.normalize=(e,t)=>{const r=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==r)throw new Error('Unexpected input given to normalize. Expected type to be "'+r+'", found "'+(null===e?"null":typeof e)+'".');const n={},i={},s=((e,t)=>(r,n,i,s,o)=>{const c=r.key,a=r.getId(i,s,o);c in e||(e[c]={});const u=e[c][a];if(e[c][a]=u?r.merge(u,n):n,Array.isArray(r.indexes)){const n=e[c][a];c in t||(t[c]={});for(const e of r.indexes){e in t[c]||(t[c][e]={});const r=t[c][e];u&&delete r[u[e]],e in n?r[n[e]]=a:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+e+"\nEntity: "+JSON.stringify(n,void 0,2))}}})(n,i);return{entities:n,indexes:i,result:h(e,e,void 0,t,s,{})}},e.schema=l,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -656,3 +656,3 @@ var rest_hooks_normalizr = (function (exports) {

var getEntity = getEntities(entities);
return function unvisit(input, schema) {
return [function unvisit(input, schema) {
if (!schema) return [input, true];

@@ -684,3 +684,3 @@

return [input, true];
};
}, cache];
};

@@ -705,3 +705,3 @@

var denormalize$1 = function denormalize(input, schema, entities) {
var denormalizeAndTracked = function denormalizeAndTracked(input, schema, entities) {
/* istanbul ignore next */

@@ -712,9 +712,17 @@ // eslint-disable-next-line no-undef

if (typeof input !== 'undefined') {
return getUnvisit(entities)(input, schema);
var _getUnvisit = getUnvisit(entities),
unvisit = _getUnvisit[0],
cache = _getUnvisit[1];
return [].concat(unvisit(input, schema), [cache]);
}
return [undefined, false];
return [undefined, false, {}];
};
var denormalize$1 = function denormalize(input, schema, entities) {
return denormalizeAndTracked(input, schema, entities).slice(0, 2);
};
exports.denormalize = denormalize$1;
exports.denormalizeAndTracked = denormalizeAndTracked;
exports.normalize = normalize$1;

@@ -721,0 +729,0 @@ exports.schema = schema;

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

var rest_hooks_normalizr=function(e){"use strict";function t(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function r(e,t,r){let n=!0;return[Object.keys(e).reduce((t,i)=>{const s=""+i,[o,c]=r(t.get(s),e[s]);return c||(n=!1),t.has(s)?t.set(s,o):t},t),n]}class n{constructor(e,t){t&&(this._schemaAttribute="string"==typeof t?e=>e[t]:t),this.define(e)}get isSingleSchema(){return!this._schemaAttribute}define(e){this.schema=e}getSchemaAttribute(e,t,r){return!this.isSingleSchema&&this._schemaAttribute(e,t,r)}inferSchema(e,t,r){if(this.isSingleSchema)return this.schema;const n=this.getSchemaAttribute(e,t,r);return this.schema[n]}normalizeValue(e,t,r,n,i,s){const o=this.inferSchema(e,t,r);if(!o)return e;const c=n(e,t,r,o,i,s);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,r)}}denormalizeValue(e,r){const n=t(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?r((t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[n]):[e,!0]}}const i=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]},s=e=>Array.isArray(e)?e:Object.keys(e).map(t=>e[t]),o=(e,t,r,n,o,c,a)=>(e=i(e),s(t).map((t,i)=>o(t,r,n,e,c,a))),c=(e,t,r)=>{e=i(e);let n=!0;return void 0===t&&e&&([,n]=r(void 0,e)),[t&&t.map?t.map(t=>r(t,e)).filter(([,e])=>e).map(([e])=>e):t,n]};const a=(e,t,r,n,i,s,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(r=>{const n=e[r],a=i(t[r],t,r,n,s,o);null==a?delete c[r]:c[r]=a}),c},u=(e,n,i)=>{if(t(n))return r(e,n,i);const s=Object.assign({},n);let o=!0;return Object.keys(e).forEach(t=>{const[r,n]=i(s[t],e[t]);void 0!==s[t]&&(s[t]=r),n||(o=!1)}),[s,o]};const h=(e,t,r,n,i,s)=>{if("object"!=typeof e||!e||!n)return e;if("object"==typeof n&&(!n.normalize||"function"!=typeof n.normalize)){return(Array.isArray(n)?o:a)(n,e,t,r,h,i,s)}return n.normalize(e,t,r,h,i,s)},l={Array:class extends n{normalize(e,t,r,n,i,o){return s(e).map((e,s)=>this.normalizeValue(e,t,r,n,i,o)).filter(e=>null!=e)}denormalize(e,t){let r=!0;return void 0===e&&this.schema&&([,r]=t(void 0,this.schema)),[e&&e.map?e.map(e=>this.denormalizeValue(e,t)).filter(([,e])=>e).map(([e])=>e):e,r]}},Entity:class{constructor(e,r={},n={}){if(!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");const{idAttribute:i="id",mergeStrategy:s=((e,t)=>Object.assign({},e,{},t)),processStrategy:o=(e=>Object.assign({},e))}=n;this._key=e,this._getId="function"==typeof i?i:(e=>r=>t(r)?r.get(e):r[e])(i),this._idAttribute=i,this._mergeStrategy=s,this._processStrategy=o,this.define(r)}get key(){return this._key}get idAttribute(){return this._idAttribute}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}getId(e,t,r){return this._getId(e,t,r)}merge(e,t){return this._mergeStrategy(e,t)}normalize(e,t,r,n,i,s){const o=this.getId(e,t,r),c=this.key;if(c in s||(s[c]={}),o in s[c]||(s[c][o]=[]),s[c][o].some(t=>t===e))return o;s[c][o].push(e);const a=this._processStrategy(e,t,r);return Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(a,e)&&"object"==typeof a[e]){const t=this.schema[e];a[e]=n(a[e],a,e,t,i,s)}}),i(this,a,e,t,r),o}denormalize(e,n){if(t(e))return r(this.schema,e,n);let i=!0;return Object.keys(this.schema).forEach(t=>{const r=this.schema[t],[s,o]=n(e[t],r);o||(i=!1),Object.hasOwnProperty.call(e,t)&&(e[t]=s)}),[e,i]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}normalize(...e){return a(this.schema,...e)}denormalize(...e){return u(this.schema,...e)}},Union:class extends n{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,r,n,i,s){return this.normalizeValue(e,t,r,n,i,s)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends n{normalize(e,t,r,n,i,s){return Object.keys(e).reduce((t,r,o)=>{const c=e[r];return null!=c?Object.assign({},t,{[r]:this.normalizeValue(c,e,r,n,i,s)}):t},{})}denormalize(e,t){let r=!0;return[Object.keys(e).reduce((n,i)=>{const s=e[i],[o,c]=this.denormalizeValue(s,t);return c||(r=!1),Object.assign({},n,{[i]:o})},{}),r]}}};const m=e=>{const r={},n=d(e);return function e(i,s){if(!s)return[i,!0];if("object"==typeof s&&(!s.denormalize||"function"!=typeof s.denormalize)){return(Array.isArray(s)?c:u)(s,i,e)}return null===i?[i,!0]:"function"==typeof s.getId&&"function"==typeof s.normalize?void 0===i?[i,!1]:((e,r,n,i,s)=>{const o=i(e,r);if("object"!=typeof o||null===o)return[o,!1];s[r.key]||(s[r.key]={});let c=!0;if(!s[r.key][e]){const i=t(o)?o:Object.assign({},o);s[r.key][e]=i,[s[r.key][e],c]=r.denormalize(i,n)}return[s[r.key][e],c]})(i,s,e,n,r):"function"==typeof s.denormalize?s.denormalize(i,e):[i,!0]}},d=e=>{const r=t(e);return(t,n)=>{const i=n.key;return"object"==typeof t?t:r?e.getIn([i,t.toString()]):e[i]&&e[i][t]}};return e.denormalize=(e,t,r)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("shema needed");return void 0!==e?m(r)(e,t):[void 0,!1]},e.normalize=(e,t)=>{const r=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==r)throw new Error('Unexpected input given to normalize. Expected type to be "'+r+'", found "'+(null===e?"null":typeof e)+'".');const n={},i={},s=((e,t)=>(r,n,i,s,o)=>{const c=r.key,a=r.getId(i,s,o);c in e||(e[c]={});const u=e[c][a];if(e[c][a]=u?r.merge(u,n):n,Array.isArray(r.indexes)){const n=e[c][a];c in t||(t[c]={});for(const e of r.indexes){e in t[c]||(t[c][e]={});const r=t[c][e];u&&delete r[u[e]],e in n?r[n[e]]=a:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+e+"\nEntity: "+JSON.stringify(n,void 0,2))}}})(n,i);return{entities:n,indexes:i,result:h(e,e,void 0,t,s,{})}},e.schema=l,e}({});
var rest_hooks_normalizr=function(e){"use strict";function t(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function r(e,t,r){let n=!0;return[Object.keys(e).reduce((t,i)=>{const s=""+i,[o,c]=r(t.get(s),e[s]);return c||(n=!1),t.has(s)?t.set(s,o):t},t),n]}class n{constructor(e,t){t&&(this._schemaAttribute="string"==typeof t?e=>e[t]:t),this.define(e)}get isSingleSchema(){return!this._schemaAttribute}define(e){this.schema=e}getSchemaAttribute(e,t,r){return!this.isSingleSchema&&this._schemaAttribute(e,t,r)}inferSchema(e,t,r){if(this.isSingleSchema)return this.schema;const n=this.getSchemaAttribute(e,t,r);return this.schema[n]}normalizeValue(e,t,r,n,i,s){const o=this.inferSchema(e,t,r);if(!o)return e;const c=n(e,t,r,o,i,s);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,r)}}denormalizeValue(e,r){const n=t(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?r((t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[n]):[e,!0]}}const i=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]},s=e=>Array.isArray(e)?e:Object.keys(e).map(t=>e[t]),o=(e,t,r,n,o,c,a)=>(e=i(e),s(t).map((t,i)=>o(t,r,n,e,c,a))),c=(e,t,r)=>{e=i(e);let n=!0;return void 0===t&&e&&([,n]=r(void 0,e)),[t&&t.map?t.map(t=>r(t,e)).filter(([,e])=>e).map(([e])=>e):t,n]};const a=(e,t,r,n,i,s,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(r=>{const n=e[r],a=i(t[r],t,r,n,s,o);null==a?delete c[r]:c[r]=a}),c},u=(e,n,i)=>{if(t(n))return r(e,n,i);const s=Object.assign({},n);let o=!0;return Object.keys(e).forEach(t=>{const[r,n]=i(s[t],e[t]);void 0!==s[t]&&(s[t]=r),n||(o=!1)}),[s,o]};const h=(e,t,r,n,i,s)=>{if("object"!=typeof e||!e||!n)return e;if("object"==typeof n&&(!n.normalize||"function"!=typeof n.normalize)){return(Array.isArray(n)?o:a)(n,e,t,r,h,i,s)}return n.normalize(e,t,r,h,i,s)},l={Array:class extends n{normalize(e,t,r,n,i,o){return s(e).map((e,s)=>this.normalizeValue(e,t,r,n,i,o)).filter(e=>null!=e)}denormalize(e,t){let r=!0;return void 0===e&&this.schema&&([,r]=t(void 0,this.schema)),[e&&e.map?e.map(e=>this.denormalizeValue(e,t)).filter(([,e])=>e).map(([e])=>e):e,r]}},Entity:class{constructor(e,r={},n={}){if(!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");const{idAttribute:i="id",mergeStrategy:s=((e,t)=>Object.assign({},e,{},t)),processStrategy:o=(e=>Object.assign({},e))}=n;this._key=e,this._getId="function"==typeof i?i:(e=>r=>t(r)?r.get(e):r[e])(i),this._idAttribute=i,this._mergeStrategy=s,this._processStrategy=o,this.define(r)}get key(){return this._key}get idAttribute(){return this._idAttribute}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}getId(e,t,r){return this._getId(e,t,r)}merge(e,t){return this._mergeStrategy(e,t)}normalize(e,t,r,n,i,s){const o=this.getId(e,t,r),c=this.key;if(c in s||(s[c]={}),o in s[c]||(s[c][o]=[]),s[c][o].some(t=>t===e))return o;s[c][o].push(e);const a=this._processStrategy(e,t,r);return Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(a,e)&&"object"==typeof a[e]){const t=this.schema[e];a[e]=n(a[e],a,e,t,i,s)}}),i(this,a,e,t,r),o}denormalize(e,n){if(t(e))return r(this.schema,e,n);let i=!0;return Object.keys(this.schema).forEach(t=>{const r=this.schema[t],[s,o]=n(e[t],r);o||(i=!1),Object.hasOwnProperty.call(e,t)&&(e[t]=s)}),[e,i]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}normalize(...e){return a(this.schema,...e)}denormalize(...e){return u(this.schema,...e)}},Union:class extends n{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,r,n,i,s){return this.normalizeValue(e,t,r,n,i,s)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends n{normalize(e,t,r,n,i,s){return Object.keys(e).reduce((t,r,o)=>{const c=e[r];return null!=c?Object.assign({},t,{[r]:this.normalizeValue(c,e,r,n,i,s)}):t},{})}denormalize(e,t){let r=!0;return[Object.keys(e).reduce((n,i)=>{const s=e[i],[o,c]=this.denormalizeValue(s,t);return c||(r=!1),Object.assign({},n,{[i]:o})},{}),r]}}};const m=e=>{const r={},n=d(e);return[function e(i,s){if(!s)return[i,!0];if("object"==typeof s&&(!s.denormalize||"function"!=typeof s.denormalize)){return(Array.isArray(s)?c:u)(s,i,e)}return null===i?[i,!0]:"function"==typeof s.getId&&"function"==typeof s.normalize?void 0===i?[i,!1]:((e,r,n,i,s)=>{const o=i(e,r);if("object"!=typeof o||null===o)return[o,!1];s[r.key]||(s[r.key]={});let c=!0;if(!s[r.key][e]){const i=t(o)?o:Object.assign({},o);s[r.key][e]=i,[s[r.key][e],c]=r.denormalize(i,n)}return[s[r.key][e],c]})(i,s,e,n,r):"function"==typeof s.denormalize?s.denormalize(i,e):[i,!0]},r]},d=e=>{const r=t(e);return(t,n)=>{const i=n.key;return"object"==typeof t?t:r?e.getIn([i,t.toString()]):e[i]&&e[i][t]}},f=(e,t,r)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("shema needed");if(void 0!==e){const[n,i]=m(r);return[...n(e,t),i]}return[void 0,!1,{}]};return e.denormalize=(e,t,r)=>f(e,t,r).slice(0,2),e.denormalizeAndTracked=f,e.normalize=(e,t)=>{const r=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==r)throw new Error('Unexpected input given to normalize. Expected type to be "'+r+'", found "'+(null===e?"null":typeof e)+'".');const n={},i={},s=((e,t)=>(r,n,i,s,o)=>{const c=r.key,a=r.getId(i,s,o);c in e||(e[c]={});const u=e[c][a];if(e[c][a]=u?r.merge(u,n):n,Array.isArray(r.indexes)){const n=e[c][a];c in t||(t[c]={});for(const e of r.indexes){e in t[c]||(t[c][e]={});const r=t[c][e];u&&delete r[u[e]],e in n?r[n[e]]=a:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+e+"\nEntity: "+JSON.stringify(n,void 0,2))}}})(n,i);return{entities:n,indexes:i,result:h(e,e,void 0,t,s,{})}},e.schema=l,e}({});

@@ -634,3 +634,3 @@ import _createClass from '@babel/runtime/helpers/esm/createClass';

var getEntity = getEntities(entities);
return function unvisit(input, schema) {
return [function unvisit(input, schema) {
if (!schema) return [input, true];

@@ -662,3 +662,3 @@

return [input, true];
};
}, cache];
};

@@ -683,3 +683,3 @@

var denormalize$1 = function denormalize(input, schema, entities) {
var denormalizeAndTracked = function denormalizeAndTracked(input, schema, entities) {
/* istanbul ignore next */

@@ -690,8 +690,15 @@ // eslint-disable-next-line no-undef

if (typeof input !== 'undefined') {
return getUnvisit(entities)(input, schema);
var _getUnvisit = getUnvisit(entities),
unvisit = _getUnvisit[0],
cache = _getUnvisit[1];
return [].concat(unvisit(input, schema), [cache]);
}
return [undefined, false];
return [undefined, false, {}];
};
var denormalize$1 = function denormalize(input, schema, entities) {
return denormalizeAndTracked(input, schema, entities).slice(0, 2);
};
export { denormalize$1 as denormalize, normalize$1 as normalize, schema };
export { denormalize$1 as denormalize, denormalizeAndTracked, normalize$1 as normalize, schema };

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

function e(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function t(e,t,r){let n=!0;return[Object.keys(e).reduce((t,i)=>{const s=""+i,[o,c]=r(t.get(s),e[s]);return c||(n=!1),t.has(s)?t.set(s,o):t},t),n]}class r{constructor(e,t){t&&(this._schemaAttribute="string"==typeof t?e=>e[t]:t),this.define(e)}get isSingleSchema(){return!this._schemaAttribute}define(e){this.schema=e}getSchemaAttribute(e,t,r){return!this.isSingleSchema&&this._schemaAttribute(e,t,r)}inferSchema(e,t,r){if(this.isSingleSchema)return this.schema;const n=this.getSchemaAttribute(e,t,r);return this.schema[n]}normalizeValue(e,t,r,n,i,s){const o=this.inferSchema(e,t,r);if(!o)return e;const c=n(e,t,r,o,i,s);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,r)}}denormalizeValue(t,r){const n=e(t)?t.get("schema"):t.schema;return this.isSingleSchema||n?r((e(t)?t.get("id"):t.id)||t,this.isSingleSchema?this.schema:this.schema[n]):[t,!0]}}const n=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]},i=e=>Array.isArray(e)?e:Object.keys(e).map(t=>e[t]),s=(e,t,r,s,o,c,a)=>(e=n(e),i(t).map((t,n)=>o(t,r,s,e,c,a))),o=(e,t,r)=>{e=n(e);let i=!0;return void 0===t&&e&&([,i]=r(void 0,e)),[t&&t.map?t.map(t=>r(t,e)).filter(([,e])=>e).map(([e])=>e):t,i]};const c=(e,t,r,n,i,s,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(r=>{const n=e[r],a=i(t[r],t,r,n,s,o);null==a?delete c[r]:c[r]=a}),c},a=(r,n,i)=>{if(e(n))return t(r,n,i);const s=Object.assign({},n);let o=!0;return Object.keys(r).forEach(e=>{const[t,n]=i(s[e],r[e]);void 0!==s[e]&&(s[e]=t),n||(o=!1)}),[s,o]};const u=(e,t,r,n,i,o)=>{if("object"!=typeof e||!e||!n)return e;if("object"==typeof n&&(!n.normalize||"function"!=typeof n.normalize)){return(Array.isArray(n)?s:c)(n,e,t,r,u,i,o)}return n.normalize(e,t,r,u,i,o)},h={Array:class extends r{normalize(e,t,r,n,s,o){return i(e).map((e,i)=>this.normalizeValue(e,t,r,n,s,o)).filter(e=>null!=e)}denormalize(e,t){let r=!0;return void 0===e&&this.schema&&([,r]=t(void 0,this.schema)),[e&&e.map?e.map(e=>this.denormalizeValue(e,t)).filter(([,e])=>e).map(([e])=>e):e,r]}},Entity:class{constructor(t,r={},n={}){if(!t||"string"!=typeof t)throw new Error("Expected a string key for Entity, but found "+t+".");const{idAttribute:i="id",mergeStrategy:s=((e,t)=>Object.assign({},e,{},t)),processStrategy:o=(e=>Object.assign({},e))}=n;this._key=t,this._getId="function"==typeof i?i:(t=>r=>e(r)?r.get(t):r[t])(i),this._idAttribute=i,this._mergeStrategy=s,this._processStrategy=o,this.define(r)}get key(){return this._key}get idAttribute(){return this._idAttribute}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}getId(e,t,r){return this._getId(e,t,r)}merge(e,t){return this._mergeStrategy(e,t)}normalize(e,t,r,n,i,s){const o=this.getId(e,t,r),c=this.key;if(c in s||(s[c]={}),o in s[c]||(s[c][o]=[]),s[c][o].some(t=>t===e))return o;s[c][o].push(e);const a=this._processStrategy(e,t,r);return Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(a,e)&&"object"==typeof a[e]){const t=this.schema[e];a[e]=n(a[e],a,e,t,i,s)}}),i(this,a,e,t,r),o}denormalize(r,n){if(e(r))return t(this.schema,r,n);let i=!0;return Object.keys(this.schema).forEach(e=>{const t=this.schema[e],[s,o]=n(r[e],t);o||(i=!1),Object.hasOwnProperty.call(r,e)&&(r[e]=s)}),[r,i]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}normalize(...e){return c(this.schema,...e)}denormalize(...e){return a(this.schema,...e)}},Union:class extends r{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,r,n,i,s){return this.normalizeValue(e,t,r,n,i,s)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends r{normalize(e,t,r,n,i,s){return Object.keys(e).reduce((t,r,o)=>{const c=e[r];return null!=c?Object.assign({},t,{[r]:this.normalizeValue(c,e,r,n,i,s)}):t},{})}denormalize(e,t){let r=!0;return[Object.keys(e).reduce((n,i)=>{const s=e[i],[o,c]=this.denormalizeValue(s,t);return c||(r=!1),Object.assign({},n,{[i]:o})},{}),r]}}};const l=(e,t)=>{const r=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==r)throw new Error('Unexpected input given to normalize. Expected type to be "'+r+'", found "'+(null===e?"null":typeof e)+'".');const n={},i={},s=((e,t)=>(r,n,i,s,o)=>{const c=r.key,a=r.getId(i,s,o);c in e||(e[c]={});const u=e[c][a];if(e[c][a]=u?r.merge(u,n):n,Array.isArray(r.indexes)){const n=e[c][a];c in t||(t[c]={});for(const e of r.indexes){e in t[c]||(t[c][e]={});const r=t[c][e];u&&delete r[u[e]],e in n?r[n[e]]=a:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+e+"\nEntity: "+JSON.stringify(n,void 0,2))}}})(n,i);return{entities:n,indexes:i,result:u(e,e,void 0,t,s,{})}},m=t=>{const r={},n=d(t);return function t(i,s){if(!s)return[i,!0];if("object"==typeof s&&(!s.denormalize||"function"!=typeof s.denormalize)){return(Array.isArray(s)?o:a)(s,i,t)}return null===i?[i,!0]:"function"==typeof s.getId&&"function"==typeof s.normalize?void 0===i?[i,!1]:((t,r,n,i,s)=>{const o=i(t,r);if("object"!=typeof o||null===o)return[o,!1];s[r.key]||(s[r.key]={});let c=!0;if(!s[r.key][t]){const i=e(o)?o:Object.assign({},o);s[r.key][t]=i,[s[r.key][t],c]=r.denormalize(i,n)}return[s[r.key][t],c]})(i,s,t,n,r):"function"==typeof s.denormalize?s.denormalize(i,t):[i,!0]}},d=t=>{const r=e(t);return(e,n)=>{const i=n.key;return"object"==typeof e?e:r?t.getIn([i,e.toString()]):t[i]&&t[i][e]}},f=(e,t,r)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("shema needed");return void 0!==e?m(r)(e,t):[void 0,!1]};export{f as denormalize,l as normalize,h as schema};
function e(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function t(e,t,r){let n=!0;return[Object.keys(e).reduce((t,i)=>{const s=""+i,[o,c]=r(t.get(s),e[s]);return c||(n=!1),t.has(s)?t.set(s,o):t},t),n]}class r{constructor(e,t){t&&(this._schemaAttribute="string"==typeof t?e=>e[t]:t),this.define(e)}get isSingleSchema(){return!this._schemaAttribute}define(e){this.schema=e}getSchemaAttribute(e,t,r){return!this.isSingleSchema&&this._schemaAttribute(e,t,r)}inferSchema(e,t,r){if(this.isSingleSchema)return this.schema;const n=this.getSchemaAttribute(e,t,r);return this.schema[n]}normalizeValue(e,t,r,n,i,s){const o=this.inferSchema(e,t,r);if(!o)return e;const c=n(e,t,r,o,i,s);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,r)}}denormalizeValue(t,r){const n=e(t)?t.get("schema"):t.schema;return this.isSingleSchema||n?r((e(t)?t.get("id"):t.id)||t,this.isSingleSchema?this.schema:this.schema[n]):[t,!0]}}const n=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]},i=e=>Array.isArray(e)?e:Object.keys(e).map(t=>e[t]),s=(e,t,r,s,o,c,a)=>(e=n(e),i(t).map((t,n)=>o(t,r,s,e,c,a))),o=(e,t,r)=>{e=n(e);let i=!0;return void 0===t&&e&&([,i]=r(void 0,e)),[t&&t.map?t.map(t=>r(t,e)).filter(([,e])=>e).map(([e])=>e):t,i]};const c=(e,t,r,n,i,s,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(r=>{const n=e[r],a=i(t[r],t,r,n,s,o);null==a?delete c[r]:c[r]=a}),c},a=(r,n,i)=>{if(e(n))return t(r,n,i);const s=Object.assign({},n);let o=!0;return Object.keys(r).forEach(e=>{const[t,n]=i(s[e],r[e]);void 0!==s[e]&&(s[e]=t),n||(o=!1)}),[s,o]};const u=(e,t,r,n,i,o)=>{if("object"!=typeof e||!e||!n)return e;if("object"==typeof n&&(!n.normalize||"function"!=typeof n.normalize)){return(Array.isArray(n)?s:c)(n,e,t,r,u,i,o)}return n.normalize(e,t,r,u,i,o)},h={Array:class extends r{normalize(e,t,r,n,s,o){return i(e).map((e,i)=>this.normalizeValue(e,t,r,n,s,o)).filter(e=>null!=e)}denormalize(e,t){let r=!0;return void 0===e&&this.schema&&([,r]=t(void 0,this.schema)),[e&&e.map?e.map(e=>this.denormalizeValue(e,t)).filter(([,e])=>e).map(([e])=>e):e,r]}},Entity:class{constructor(t,r={},n={}){if(!t||"string"!=typeof t)throw new Error("Expected a string key for Entity, but found "+t+".");const{idAttribute:i="id",mergeStrategy:s=((e,t)=>Object.assign({},e,{},t)),processStrategy:o=(e=>Object.assign({},e))}=n;this._key=t,this._getId="function"==typeof i?i:(t=>r=>e(r)?r.get(t):r[t])(i),this._idAttribute=i,this._mergeStrategy=s,this._processStrategy=o,this.define(r)}get key(){return this._key}get idAttribute(){return this._idAttribute}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}getId(e,t,r){return this._getId(e,t,r)}merge(e,t){return this._mergeStrategy(e,t)}normalize(e,t,r,n,i,s){const o=this.getId(e,t,r),c=this.key;if(c in s||(s[c]={}),o in s[c]||(s[c][o]=[]),s[c][o].some(t=>t===e))return o;s[c][o].push(e);const a=this._processStrategy(e,t,r);return Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(a,e)&&"object"==typeof a[e]){const t=this.schema[e];a[e]=n(a[e],a,e,t,i,s)}}),i(this,a,e,t,r),o}denormalize(r,n){if(e(r))return t(this.schema,r,n);let i=!0;return Object.keys(this.schema).forEach(e=>{const t=this.schema[e],[s,o]=n(r[e],t);o||(i=!1),Object.hasOwnProperty.call(r,e)&&(r[e]=s)}),[r,i]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}normalize(...e){return c(this.schema,...e)}denormalize(...e){return a(this.schema,...e)}},Union:class extends r{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,r,n,i,s){return this.normalizeValue(e,t,r,n,i,s)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends r{normalize(e,t,r,n,i,s){return Object.keys(e).reduce((t,r,o)=>{const c=e[r];return null!=c?Object.assign({},t,{[r]:this.normalizeValue(c,e,r,n,i,s)}):t},{})}denormalize(e,t){let r=!0;return[Object.keys(e).reduce((n,i)=>{const s=e[i],[o,c]=this.denormalizeValue(s,t);return c||(r=!1),Object.assign({},n,{[i]:o})},{}),r]}}};const l=(e,t)=>{const r=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==r)throw new Error('Unexpected input given to normalize. Expected type to be "'+r+'", found "'+(null===e?"null":typeof e)+'".');const n={},i={},s=((e,t)=>(r,n,i,s,o)=>{const c=r.key,a=r.getId(i,s,o);c in e||(e[c]={});const u=e[c][a];if(e[c][a]=u?r.merge(u,n):n,Array.isArray(r.indexes)){const n=e[c][a];c in t||(t[c]={});for(const e of r.indexes){e in t[c]||(t[c][e]={});const r=t[c][e];u&&delete r[u[e]],e in n?r[n[e]]=a:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+e+"\nEntity: "+JSON.stringify(n,void 0,2))}}})(n,i);return{entities:n,indexes:i,result:u(e,e,void 0,t,s,{})}},m=t=>{const r={},n=d(t);return[function t(i,s){if(!s)return[i,!0];if("object"==typeof s&&(!s.denormalize||"function"!=typeof s.denormalize)){return(Array.isArray(s)?o:a)(s,i,t)}return null===i?[i,!0]:"function"==typeof s.getId&&"function"==typeof s.normalize?void 0===i?[i,!1]:((t,r,n,i,s)=>{const o=i(t,r);if("object"!=typeof o||null===o)return[o,!1];s[r.key]||(s[r.key]={});let c=!0;if(!s[r.key][t]){const i=e(o)?o:Object.assign({},o);s[r.key][t]=i,[s[r.key][t],c]=r.denormalize(i,n)}return[s[r.key][t],c]})(i,s,t,n,r):"function"==typeof s.denormalize?s.denormalize(i,t):[i,!0]},r]},d=t=>{const r=e(t);return(e,n)=>{const i=n.key;return"object"==typeof e?e:r?t.getIn([i,e.toString()]):t[i]&&t[i][e]}},f=(e,t,r)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("shema needed");if(void 0!==e){const[n,i]=m(r);return[...n(e,t),i]}return[void 0,!1,{}]},y=(e,t,r)=>f(e,t,r).slice(0,2);export{y as denormalize,f as denormalizeAndTracked,l as normalize,h as schema};

@@ -657,3 +657,3 @@ 'use strict';

var getEntity = getEntities(entities);
return function unvisit(input, schema) {
return [function unvisit(input, schema) {
if (!schema) return [input, true];

@@ -685,3 +685,3 @@

return [input, true];
};
}, cache];
};

@@ -706,3 +706,3 @@

var denormalize$1 = function denormalize(input, schema, entities) {
var denormalizeAndTracked = function denormalizeAndTracked(input, schema, entities) {
/* istanbul ignore next */

@@ -713,10 +713,18 @@ // eslint-disable-next-line no-undef

if (typeof input !== 'undefined') {
return getUnvisit(entities)(input, schema);
var _getUnvisit = getUnvisit(entities),
unvisit = _getUnvisit[0],
cache = _getUnvisit[1];
return [].concat(unvisit(input, schema), [cache]);
}
return [undefined, false];
return [undefined, false, {}];
};
var denormalize$1 = function denormalize(input, schema, entities) {
return denormalizeAndTracked(input, schema, entities).slice(0, 2);
};
exports.denormalize = denormalize$1;
exports.denormalizeAndTracked = denormalizeAndTracked;
exports.normalize = normalize$1;
exports.schema = schema;

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

"use strict";function e(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function t(e,t,r){let n=!0;return[Object.keys(e).reduce((t,i)=>{const s=""+i,[o,c]=r(t.get(s),e[s]);return c||(n=!1),t.has(s)?t.set(s,o):t},t),n]}Object.defineProperty(exports,"__esModule",{value:!0});class r{constructor(e,t){t&&(this._schemaAttribute="string"==typeof t?e=>e[t]:t),this.define(e)}get isSingleSchema(){return!this._schemaAttribute}define(e){this.schema=e}getSchemaAttribute(e,t,r){return!this.isSingleSchema&&this._schemaAttribute(e,t,r)}inferSchema(e,t,r){if(this.isSingleSchema)return this.schema;const n=this.getSchemaAttribute(e,t,r);return this.schema[n]}normalizeValue(e,t,r,n,i,s){const o=this.inferSchema(e,t,r);if(!o)return e;const c=n(e,t,r,o,i,s);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,r)}}denormalizeValue(t,r){const n=e(t)?t.get("schema"):t.schema;return this.isSingleSchema||n?r((e(t)?t.get("id"):t.id)||t,this.isSingleSchema?this.schema:this.schema[n]):[t,!0]}}const n=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]},i=e=>Array.isArray(e)?e:Object.keys(e).map(t=>e[t]),s=(e,t,r,s,o,c,a)=>(e=n(e),i(t).map((t,n)=>o(t,r,s,e,c,a))),o=(e,t,r)=>{e=n(e);let i=!0;return void 0===t&&e&&([,i]=r(void 0,e)),[t&&t.map?t.map(t=>r(t,e)).filter(([,e])=>e).map(([e])=>e):t,i]};const c=(e,t,r,n,i,s,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(r=>{const n=e[r],a=i(t[r],t,r,n,s,o);null==a?delete c[r]:c[r]=a}),c},a=(r,n,i)=>{if(e(n))return t(r,n,i);const s=Object.assign({},n);let o=!0;return Object.keys(r).forEach(e=>{const[t,n]=i(s[e],r[e]);void 0!==s[e]&&(s[e]=t),n||(o=!1)}),[s,o]};const u=(e,t,r,n,i,o)=>{if("object"!=typeof e||!e||!n)return e;if("object"==typeof n&&(!n.normalize||"function"!=typeof n.normalize)){return(Array.isArray(n)?s:c)(n,e,t,r,u,i,o)}return n.normalize(e,t,r,u,i,o)},h={Array:class extends r{normalize(e,t,r,n,s,o){return i(e).map((e,i)=>this.normalizeValue(e,t,r,n,s,o)).filter(e=>null!=e)}denormalize(e,t){let r=!0;return void 0===e&&this.schema&&([,r]=t(void 0,this.schema)),[e&&e.map?e.map(e=>this.denormalizeValue(e,t)).filter(([,e])=>e).map(([e])=>e):e,r]}},Entity:class{constructor(t,r={},n={}){if(!t||"string"!=typeof t)throw new Error("Expected a string key for Entity, but found "+t+".");const{idAttribute:i="id",mergeStrategy:s=((e,t)=>Object.assign({},e,{},t)),processStrategy:o=(e=>Object.assign({},e))}=n;this._key=t,this._getId="function"==typeof i?i:(t=>r=>e(r)?r.get(t):r[t])(i),this._idAttribute=i,this._mergeStrategy=s,this._processStrategy=o,this.define(r)}get key(){return this._key}get idAttribute(){return this._idAttribute}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}getId(e,t,r){return this._getId(e,t,r)}merge(e,t){return this._mergeStrategy(e,t)}normalize(e,t,r,n,i,s){const o=this.getId(e,t,r),c=this.key;if(c in s||(s[c]={}),o in s[c]||(s[c][o]=[]),s[c][o].some(t=>t===e))return o;s[c][o].push(e);const a=this._processStrategy(e,t,r);return Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(a,e)&&"object"==typeof a[e]){const t=this.schema[e];a[e]=n(a[e],a,e,t,i,s)}}),i(this,a,e,t,r),o}denormalize(r,n){if(e(r))return t(this.schema,r,n);let i=!0;return Object.keys(this.schema).forEach(e=>{const t=this.schema[e],[s,o]=n(r[e],t);o||(i=!1),Object.hasOwnProperty.call(r,e)&&(r[e]=s)}),[r,i]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}normalize(...e){return c(this.schema,...e)}denormalize(...e){return a(this.schema,...e)}},Union:class extends r{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,r,n,i,s){return this.normalizeValue(e,t,r,n,i,s)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends r{normalize(e,t,r,n,i,s){return Object.keys(e).reduce((t,r,o)=>{const c=e[r];return null!=c?Object.assign({},t,{[r]:this.normalizeValue(c,e,r,n,i,s)}):t},{})}denormalize(e,t){let r=!0;return[Object.keys(e).reduce((n,i)=>{const s=e[i],[o,c]=this.denormalizeValue(s,t);return c||(r=!1),Object.assign({},n,{[i]:o})},{}),r]}}};const l=t=>{const r={},n=m(t);return function t(i,s){if(!s)return[i,!0];if("object"==typeof s&&(!s.denormalize||"function"!=typeof s.denormalize)){return(Array.isArray(s)?o:a)(s,i,t)}return null===i?[i,!0]:"function"==typeof s.getId&&"function"==typeof s.normalize?void 0===i?[i,!1]:((t,r,n,i,s)=>{const o=i(t,r);if("object"!=typeof o||null===o)return[o,!1];s[r.key]||(s[r.key]={});let c=!0;if(!s[r.key][t]){const i=e(o)?o:Object.assign({},o);s[r.key][t]=i,[s[r.key][t],c]=r.denormalize(i,n)}return[s[r.key][t],c]})(i,s,t,n,r):"function"==typeof s.denormalize?s.denormalize(i,t):[i,!0]}},m=t=>{const r=e(t);return(e,n)=>{const i=n.key;return"object"==typeof e?e:r?t.getIn([i,e.toString()]):t[i]&&t[i][e]}};exports.denormalize=(e,t,r)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("shema needed");return void 0!==e?l(r)(e,t):[void 0,!1]},exports.normalize=(e,t)=>{const r=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==r)throw new Error('Unexpected input given to normalize. Expected type to be "'+r+'", found "'+(null===e?"null":typeof e)+'".');const n={},i={},s=((e,t)=>(r,n,i,s,o)=>{const c=r.key,a=r.getId(i,s,o);c in e||(e[c]={});const u=e[c][a];if(e[c][a]=u?r.merge(u,n):n,Array.isArray(r.indexes)){const n=e[c][a];c in t||(t[c]={});for(const e of r.indexes){e in t[c]||(t[c][e]={});const r=t[c][e];u&&delete r[u[e]],e in n?r[n[e]]=a:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+e+"\nEntity: "+JSON.stringify(n,void 0,2))}}})(n,i);return{entities:n,indexes:i,result:u(e,e,void 0,t,s,{})}},exports.schema=h;
"use strict";function e(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function t(e,t,r){let n=!0;return[Object.keys(e).reduce((t,i)=>{const s=""+i,[o,c]=r(t.get(s),e[s]);return c||(n=!1),t.has(s)?t.set(s,o):t},t),n]}Object.defineProperty(exports,"__esModule",{value:!0});class r{constructor(e,t){t&&(this._schemaAttribute="string"==typeof t?e=>e[t]:t),this.define(e)}get isSingleSchema(){return!this._schemaAttribute}define(e){this.schema=e}getSchemaAttribute(e,t,r){return!this.isSingleSchema&&this._schemaAttribute(e,t,r)}inferSchema(e,t,r){if(this.isSingleSchema)return this.schema;const n=this.getSchemaAttribute(e,t,r);return this.schema[n]}normalizeValue(e,t,r,n,i,s){const o=this.inferSchema(e,t,r);if(!o)return e;const c=n(e,t,r,o,i,s);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,r)}}denormalizeValue(t,r){const n=e(t)?t.get("schema"):t.schema;return this.isSingleSchema||n?r((e(t)?t.get("id"):t.id)||t,this.isSingleSchema?this.schema:this.schema[n]):[t,!0]}}const n=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]},i=e=>Array.isArray(e)?e:Object.keys(e).map(t=>e[t]),s=(e,t,r,s,o,c,a)=>(e=n(e),i(t).map((t,n)=>o(t,r,s,e,c,a))),o=(e,t,r)=>{e=n(e);let i=!0;return void 0===t&&e&&([,i]=r(void 0,e)),[t&&t.map?t.map(t=>r(t,e)).filter(([,e])=>e).map(([e])=>e):t,i]};const c=(e,t,r,n,i,s,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(r=>{const n=e[r],a=i(t[r],t,r,n,s,o);null==a?delete c[r]:c[r]=a}),c},a=(r,n,i)=>{if(e(n))return t(r,n,i);const s=Object.assign({},n);let o=!0;return Object.keys(r).forEach(e=>{const[t,n]=i(s[e],r[e]);void 0!==s[e]&&(s[e]=t),n||(o=!1)}),[s,o]};const u=(e,t,r,n,i,o)=>{if("object"!=typeof e||!e||!n)return e;if("object"==typeof n&&(!n.normalize||"function"!=typeof n.normalize)){return(Array.isArray(n)?s:c)(n,e,t,r,u,i,o)}return n.normalize(e,t,r,u,i,o)},h={Array:class extends r{normalize(e,t,r,n,s,o){return i(e).map((e,i)=>this.normalizeValue(e,t,r,n,s,o)).filter(e=>null!=e)}denormalize(e,t){let r=!0;return void 0===e&&this.schema&&([,r]=t(void 0,this.schema)),[e&&e.map?e.map(e=>this.denormalizeValue(e,t)).filter(([,e])=>e).map(([e])=>e):e,r]}},Entity:class{constructor(t,r={},n={}){if(!t||"string"!=typeof t)throw new Error("Expected a string key for Entity, but found "+t+".");const{idAttribute:i="id",mergeStrategy:s=((e,t)=>Object.assign({},e,{},t)),processStrategy:o=(e=>Object.assign({},e))}=n;this._key=t,this._getId="function"==typeof i?i:(t=>r=>e(r)?r.get(t):r[t])(i),this._idAttribute=i,this._mergeStrategy=s,this._processStrategy=o,this.define(r)}get key(){return this._key}get idAttribute(){return this._idAttribute}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}getId(e,t,r){return this._getId(e,t,r)}merge(e,t){return this._mergeStrategy(e,t)}normalize(e,t,r,n,i,s){const o=this.getId(e,t,r),c=this.key;if(c in s||(s[c]={}),o in s[c]||(s[c][o]=[]),s[c][o].some(t=>t===e))return o;s[c][o].push(e);const a=this._processStrategy(e,t,r);return Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(a,e)&&"object"==typeof a[e]){const t=this.schema[e];a[e]=n(a[e],a,e,t,i,s)}}),i(this,a,e,t,r),o}denormalize(r,n){if(e(r))return t(this.schema,r,n);let i=!0;return Object.keys(this.schema).forEach(e=>{const t=this.schema[e],[s,o]=n(r[e],t);o||(i=!1),Object.hasOwnProperty.call(r,e)&&(r[e]=s)}),[r,i]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,r)=>{const n=e[r];return Object.assign({},t,{[r]:n})},this.schema||{})}normalize(...e){return c(this.schema,...e)}denormalize(...e){return a(this.schema,...e)}},Union:class extends r{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,r,n,i,s){return this.normalizeValue(e,t,r,n,i,s)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends r{normalize(e,t,r,n,i,s){return Object.keys(e).reduce((t,r,o)=>{const c=e[r];return null!=c?Object.assign({},t,{[r]:this.normalizeValue(c,e,r,n,i,s)}):t},{})}denormalize(e,t){let r=!0;return[Object.keys(e).reduce((n,i)=>{const s=e[i],[o,c]=this.denormalizeValue(s,t);return c||(r=!1),Object.assign({},n,{[i]:o})},{}),r]}}};const l=t=>{const r={},n=m(t);return[function t(i,s){if(!s)return[i,!0];if("object"==typeof s&&(!s.denormalize||"function"!=typeof s.denormalize)){return(Array.isArray(s)?o:a)(s,i,t)}return null===i?[i,!0]:"function"==typeof s.getId&&"function"==typeof s.normalize?void 0===i?[i,!1]:((t,r,n,i,s)=>{const o=i(t,r);if("object"!=typeof o||null===o)return[o,!1];s[r.key]||(s[r.key]={});let c=!0;if(!s[r.key][t]){const i=e(o)?o:Object.assign({},o);s[r.key][t]=i,[s[r.key][t],c]=r.denormalize(i,n)}return[s[r.key][t],c]})(i,s,t,n,r):"function"==typeof s.denormalize?s.denormalize(i,t):[i,!0]},r]},m=t=>{const r=e(t);return(e,n)=>{const i=n.key;return"object"==typeof e?e:r?t.getIn([i,e.toString()]):t[i]&&t[i][e]}},d=(e,t,r)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("shema needed");if(void 0!==e){const[n,i]=l(r);return[...n(e,t),i]}return[void 0,!1,{}]};exports.denormalize=(e,t,r)=>d(e,t,r).slice(0,2),exports.denormalizeAndTracked=d,exports.normalize=(e,t)=>{const r=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==r)throw new Error('Unexpected input given to normalize. Expected type to be "'+r+'", found "'+(null===e?"null":typeof e)+'".');const n={},i={},s=((e,t)=>(r,n,i,s,o)=>{const c=r.key,a=r.getId(i,s,o);c in e||(e[c]={});const u=e[c][a];if(e[c][a]=u?r.merge(u,n):n,Array.isArray(r.indexes)){const n=e[c][a];c in t||(t[c]={});for(const e of r.indexes){e in t[c]||(t[c][e]={});const r=t[c][e];u&&delete r[u[e]],e in n?r[n[e]]=a:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+e+"\nEntity: "+JSON.stringify(n,void 0,2))}}})(n,i);return{entities:n,indexes:i,result:u(e,e,void 0,t,s,{})}},exports.schema=h;

@@ -659,3 +659,3 @@ (function (global, factory) {

var getEntity = getEntities(entities);
return function unvisit(input, schema) {
return [function unvisit(input, schema) {
if (!schema) return [input, true];

@@ -687,3 +687,3 @@

return [input, true];
};
}, cache];
};

@@ -708,3 +708,3 @@

var denormalize$1 = function denormalize(input, schema, entities) {
var denormalizeAndTracked = function denormalizeAndTracked(input, schema, entities) {
/* istanbul ignore next */

@@ -715,9 +715,17 @@ // eslint-disable-next-line no-undef

if (typeof input !== 'undefined') {
return getUnvisit(entities)(input, schema);
var _getUnvisit = getUnvisit(entities),
unvisit = _getUnvisit[0],
cache = _getUnvisit[1];
return [].concat(unvisit(input, schema), [cache]);
}
return [undefined, false];
return [undefined, false, {}];
};
var denormalize$1 = function denormalize(input, schema, entities) {
return denormalizeAndTracked(input, schema, entities).slice(0, 2);
};
exports.denormalize = denormalize$1;
exports.denormalizeAndTracked = denormalizeAndTracked;
exports.normalize = normalize$1;

@@ -724,0 +732,0 @@ exports.schema = schema;

@@ -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).rest_hooks_normalizr={})}(this,(function(e){"use strict";function t(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function n(e,t,n){let r=!0;return[Object.keys(e).reduce((t,i)=>{const s=""+i,[o,c]=n(t.get(s),e[s]);return c||(r=!1),t.has(s)?t.set(s,o):t},t),r]}class r{constructor(e,t){t&&(this._schemaAttribute="string"==typeof t?e=>e[t]:t),this.define(e)}get isSingleSchema(){return!this._schemaAttribute}define(e){this.schema=e}getSchemaAttribute(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)}inferSchema(e,t,n){if(this.isSingleSchema)return this.schema;const r=this.getSchemaAttribute(e,t,n);return this.schema[r]}normalizeValue(e,t,n,r,i,s){const o=this.inferSchema(e,t,n);if(!o)return e;const c=r(e,t,n,o,i,s);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,n)}}denormalizeValue(e,n){const r=t(e)?e.get("schema"):e.schema;return this.isSingleSchema||r?n((t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0]}}const i=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]},s=e=>Array.isArray(e)?e:Object.keys(e).map(t=>e[t]),o=(e,t,n,r,o,c,a)=>(e=i(e),s(t).map((t,i)=>o(t,n,r,e,c,a))),c=(e,t,n)=>{e=i(e);let r=!0;return void 0===t&&e&&([,r]=n(void 0,e)),[t&&t.map?t.map(t=>n(t,e)).filter(([,e])=>e).map(([e])=>e):t,r]};const a=(e,t,n,r,i,s,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(n=>{const r=e[n],a=i(t[n],t,n,r,s,o);null==a?delete c[n]:c[n]=a}),c},u=(e,r,i)=>{if(t(r))return n(e,r,i);const s=Object.assign({},r);let o=!0;return Object.keys(e).forEach(t=>{const[n,r]=i(s[t],e[t]);void 0!==s[t]&&(s[t]=n),r||(o=!1)}),[s,o]};const h=(e,t,n,r,i,s)=>{if("object"!=typeof e||!e||!r)return e;if("object"==typeof r&&(!r.normalize||"function"!=typeof r.normalize)){return(Array.isArray(r)?o:a)(r,e,t,n,h,i,s)}return r.normalize(e,t,n,h,i,s)},l={Array:class extends r{normalize(e,t,n,r,i,o){return s(e).map((e,s)=>this.normalizeValue(e,t,n,r,i,o)).filter(e=>null!=e)}denormalize(e,t){let n=!0;return void 0===e&&this.schema&&([,n]=t(void 0,this.schema)),[e&&e.map?e.map(e=>this.denormalizeValue(e,t)).filter(([,e])=>e).map(([e])=>e):e,n]}},Entity:class{constructor(e,n={},r={}){if(!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");const{idAttribute:i="id",mergeStrategy:s=((e,t)=>Object.assign({},e,{},t)),processStrategy:o=(e=>Object.assign({},e))}=r;this._key=e,this._getId="function"==typeof i?i:(e=>n=>t(n)?n.get(e):n[e])(i),this._idAttribute=i,this._mergeStrategy=s,this._processStrategy=o,this.define(n)}get key(){return this._key}get idAttribute(){return this._idAttribute}define(e){this.schema=Object.keys(e).reduce((t,n)=>{const r=e[n];return Object.assign({},t,{[n]:r})},this.schema||{})}getId(e,t,n){return this._getId(e,t,n)}merge(e,t){return this._mergeStrategy(e,t)}normalize(e,t,n,r,i,s){const o=this.getId(e,t,n),c=this.key;if(c in s||(s[c]={}),o in s[c]||(s[c][o]=[]),s[c][o].some(t=>t===e))return o;s[c][o].push(e);const a=this._processStrategy(e,t,n);return Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(a,e)&&"object"==typeof a[e]){const t=this.schema[e];a[e]=r(a[e],a,e,t,i,s)}}),i(this,a,e,t,n),o}denormalize(e,r){if(t(e))return n(this.schema,e,r);let i=!0;return Object.keys(this.schema).forEach(t=>{const n=this.schema[t],[s,o]=r(e[t],n);o||(i=!1),Object.hasOwnProperty.call(e,t)&&(e[t]=s)}),[e,i]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,n)=>{const r=e[n];return Object.assign({},t,{[n]:r})},this.schema||{})}normalize(...e){return a(this.schema,...e)}denormalize(...e){return u(this.schema,...e)}},Union:class extends r{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,n,r,i,s){return this.normalizeValue(e,t,n,r,i,s)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends r{normalize(e,t,n,r,i,s){return Object.keys(e).reduce((t,n,o)=>{const c=e[n];return null!=c?Object.assign({},t,{[n]:this.normalizeValue(c,e,n,r,i,s)}):t},{})}denormalize(e,t){let n=!0;return[Object.keys(e).reduce((r,i)=>{const s=e[i],[o,c]=this.denormalizeValue(s,t);return c||(n=!1),Object.assign({},r,{[i]:o})},{}),n]}}};const m=e=>{const n={},r=d(e);return function e(i,s){if(!s)return[i,!0];if("object"==typeof s&&(!s.denormalize||"function"!=typeof s.denormalize)){return(Array.isArray(s)?c:u)(s,i,e)}return null===i?[i,!0]:"function"==typeof s.getId&&"function"==typeof s.normalize?void 0===i?[i,!1]:((e,n,r,i,s)=>{const o=i(e,n);if("object"!=typeof o||null===o)return[o,!1];s[n.key]||(s[n.key]={});let c=!0;if(!s[n.key][e]){const i=t(o)?o:Object.assign({},o);s[n.key][e]=i,[s[n.key][e],c]=n.denormalize(i,r)}return[s[n.key][e],c]})(i,s,e,r,n):"function"==typeof s.denormalize?s.denormalize(i,e):[i,!0]}},d=e=>{const n=t(e);return(t,r)=>{const i=r.key;return"object"==typeof t?t:n?e.getIn([i,t.toString()]):e[i]&&e[i][t]}};e.denormalize=(e,t,n)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("shema needed");return void 0!==e?m(n)(e,t):[void 0,!1]},e.normalize=(e,t)=>{const n=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==n)throw new Error('Unexpected input given to normalize. Expected type to be "'+n+'", found "'+(null===e?"null":typeof e)+'".');const r={},i={},s=((e,t)=>(n,r,i,s,o)=>{const c=n.key,a=n.getId(i,s,o);c in e||(e[c]={});const u=e[c][a];if(e[c][a]=u?n.merge(u,r):r,Array.isArray(n.indexes)){const r=e[c][a];c in t||(t[c]={});for(const e of n.indexes){e in t[c]||(t[c][e]={});const n=t[c][e];u&&delete n[u[e]],e in r?n[r[e]]=a:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+e+"\nEntity: "+JSON.stringify(r,void 0,2))}}})(r,i);return{entities:r,indexes:i,result:h(e,e,void 0,t,s,{})}},e.schema=l,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){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function n(e,t,n){let r=!0;return[Object.keys(e).reduce((t,i)=>{const s=""+i,[o,c]=n(t.get(s),e[s]);return c||(r=!1),t.has(s)?t.set(s,o):t},t),r]}class r{constructor(e,t){t&&(this._schemaAttribute="string"==typeof t?e=>e[t]:t),this.define(e)}get isSingleSchema(){return!this._schemaAttribute}define(e){this.schema=e}getSchemaAttribute(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)}inferSchema(e,t,n){if(this.isSingleSchema)return this.schema;const r=this.getSchemaAttribute(e,t,n);return this.schema[r]}normalizeValue(e,t,n,r,i,s){const o=this.inferSchema(e,t,n);if(!o)return e;const c=r(e,t,n,o,i,s);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,n)}}denormalizeValue(e,n){const r=t(e)?e.get("schema"):e.schema;return this.isSingleSchema||r?n((t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0]}}const i=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]},s=e=>Array.isArray(e)?e:Object.keys(e).map(t=>e[t]),o=(e,t,n,r,o,c,a)=>(e=i(e),s(t).map((t,i)=>o(t,n,r,e,c,a))),c=(e,t,n)=>{e=i(e);let r=!0;return void 0===t&&e&&([,r]=n(void 0,e)),[t&&t.map?t.map(t=>n(t,e)).filter(([,e])=>e).map(([e])=>e):t,r]};const a=(e,t,n,r,i,s,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(n=>{const r=e[n],a=i(t[n],t,n,r,s,o);null==a?delete c[n]:c[n]=a}),c},u=(e,r,i)=>{if(t(r))return n(e,r,i);const s=Object.assign({},r);let o=!0;return Object.keys(e).forEach(t=>{const[n,r]=i(s[t],e[t]);void 0!==s[t]&&(s[t]=n),r||(o=!1)}),[s,o]};const h=(e,t,n,r,i,s)=>{if("object"!=typeof e||!e||!r)return e;if("object"==typeof r&&(!r.normalize||"function"!=typeof r.normalize)){return(Array.isArray(r)?o:a)(r,e,t,n,h,i,s)}return r.normalize(e,t,n,h,i,s)},l={Array:class extends r{normalize(e,t,n,r,i,o){return s(e).map((e,s)=>this.normalizeValue(e,t,n,r,i,o)).filter(e=>null!=e)}denormalize(e,t){let n=!0;return void 0===e&&this.schema&&([,n]=t(void 0,this.schema)),[e&&e.map?e.map(e=>this.denormalizeValue(e,t)).filter(([,e])=>e).map(([e])=>e):e,n]}},Entity:class{constructor(e,n={},r={}){if(!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");const{idAttribute:i="id",mergeStrategy:s=((e,t)=>Object.assign({},e,{},t)),processStrategy:o=(e=>Object.assign({},e))}=r;this._key=e,this._getId="function"==typeof i?i:(e=>n=>t(n)?n.get(e):n[e])(i),this._idAttribute=i,this._mergeStrategy=s,this._processStrategy=o,this.define(n)}get key(){return this._key}get idAttribute(){return this._idAttribute}define(e){this.schema=Object.keys(e).reduce((t,n)=>{const r=e[n];return Object.assign({},t,{[n]:r})},this.schema||{})}getId(e,t,n){return this._getId(e,t,n)}merge(e,t){return this._mergeStrategy(e,t)}normalize(e,t,n,r,i,s){const o=this.getId(e,t,n),c=this.key;if(c in s||(s[c]={}),o in s[c]||(s[c][o]=[]),s[c][o].some(t=>t===e))return o;s[c][o].push(e);const a=this._processStrategy(e,t,n);return Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(a,e)&&"object"==typeof a[e]){const t=this.schema[e];a[e]=r(a[e],a,e,t,i,s)}}),i(this,a,e,t,n),o}denormalize(e,r){if(t(e))return n(this.schema,e,r);let i=!0;return Object.keys(this.schema).forEach(t=>{const n=this.schema[t],[s,o]=r(e[t],n);o||(i=!1),Object.hasOwnProperty.call(e,t)&&(e[t]=s)}),[e,i]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,n)=>{const r=e[n];return Object.assign({},t,{[n]:r})},this.schema||{})}normalize(...e){return a(this.schema,...e)}denormalize(...e){return u(this.schema,...e)}},Union:class extends r{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,n,r,i,s){return this.normalizeValue(e,t,n,r,i,s)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends r{normalize(e,t,n,r,i,s){return Object.keys(e).reduce((t,n,o)=>{const c=e[n];return null!=c?Object.assign({},t,{[n]:this.normalizeValue(c,e,n,r,i,s)}):t},{})}denormalize(e,t){let n=!0;return[Object.keys(e).reduce((r,i)=>{const s=e[i],[o,c]=this.denormalizeValue(s,t);return c||(n=!1),Object.assign({},r,{[i]:o})},{}),n]}}};const m=e=>{const n={},r=d(e);return[function e(i,s){if(!s)return[i,!0];if("object"==typeof s&&(!s.denormalize||"function"!=typeof s.denormalize)){return(Array.isArray(s)?c:u)(s,i,e)}return null===i?[i,!0]:"function"==typeof s.getId&&"function"==typeof s.normalize?void 0===i?[i,!1]:((e,n,r,i,s)=>{const o=i(e,n);if("object"!=typeof o||null===o)return[o,!1];s[n.key]||(s[n.key]={});let c=!0;if(!s[n.key][e]){const i=t(o)?o:Object.assign({},o);s[n.key][e]=i,[s[n.key][e],c]=n.denormalize(i,r)}return[s[n.key][e],c]})(i,s,e,r,n):"function"==typeof s.denormalize?s.denormalize(i,e):[i,!0]},n]},d=e=>{const n=t(e);return(t,r)=>{const i=r.key;return"object"==typeof t?t:n?e.getIn([i,t.toString()]):e[i]&&e[i][t]}},f=(e,t,n)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("shema needed");if(void 0!==e){const[r,i]=m(n);return[...r(e,t),i]}return[void 0,!1,{}]};e.denormalize=(e,t,n)=>f(e,t,n).slice(0,2),e.denormalizeAndTracked=f,e.normalize=(e,t)=>{const n=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==n)throw new Error('Unexpected input given to normalize. Expected type to be "'+n+'", found "'+(null===e?"null":typeof e)+'".');const r={},i={},s=((e,t)=>(n,r,i,s,o)=>{const c=n.key,a=n.getId(i,s,o);c in e||(e[c]={});const u=e[c][a];if(e[c][a]=u?n.merge(u,r):r,Array.isArray(n.indexes)){const r=e[c][a];c in t||(t[c]={});for(const e of n.indexes){e in t[c]||(t[c][e]={});const n=t[c][e];u&&delete n[u[e]],e in r?n[r[e]]=a:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+e+"\nEntity: "+JSON.stringify(r,void 0,2))}}})(r,i);return{entities:r,indexes:i,result:h(e,e,void 0,t,s,{})}},e.schema=l,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@rest-hooks/normalizr",
"version": "4.3.2",
"version": "4.3.3",
"description": "Normalizes and denormalizes JSON according to schema for Redux and Flux applications",

@@ -63,3 +63,3 @@ "homepage": "https://github.com/coinbase/rest-hooks/tree/master/packages/normalizr#readme",

},
"gitHead": "89ad47351c96ad574146d3961a6ad8c2d2cf7c7c"
"gitHead": "75849f63bea3fe910e8f2202306e5ab42de913a8"
}

@@ -336,1 +336,9 @@ declare namespace schema {

): [Denormalize<S>, true] | [DenormalizeNullable<S>, false];
export function denormalizeAndTracked<S extends Schema>(
input: any,
schema: S,
entities: any,
):
| [Denormalize<S>, true, { [key: string]: { [key: string]: any } }]
| [DenormalizeNullable<S>, false, { [key: string]: { [key: string]: any } }];
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