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 6.0.0-beta.4 to 6.0.0-beta.5

9

CHANGELOG.md

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

## [6.0.0-beta.5](https://github.com/coinbase/rest-hooks/compare/@rest-hooks/normalizr@6.0.0-beta.4...@rest-hooks/normalizr@6.0.0-beta.5) (2020-05-13)
### 💅 Enhancement
* Include merge() in EntityInterface ([709cb38](https://github.com/coinbase/rest-hooks/commit/709cb380fa765c459a2b3edb72f7b7187c968f29))
## [6.0.0-beta.4](https://github.com/coinbase/rest-hooks/compare/@rest-hooks/normalizr@6.0.0-beta.3...@rest-hooks/normalizr@6.0.0-beta.4) (2020-05-13)

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

2

dist/normalizr.amd.min.js

@@ -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 n(e,t,n){let r=!0;return[Object.keys(e).reduce((t,s)=>{const i=`${s}`,[o,c]=n(t.get(i),e[i]);return c||(r=!1),t.has(i)?t.set(i,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,s,i){const o=this.inferSchema(e,t,n);if(!o)return e;const c=r(e,t,n,o,s,i);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((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0]}}const s=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]),o=(e,t,n,r,o,c,a)=>(e=s(e),i(t).map((t,s)=>o(t,n,r,e,c,a))),c=(e,t,n)=>{e=s(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,s,i,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(n=>{const r=e[n],a=s(t[n],t,n,r,i,o);null==a?delete c[n]:c[n]=a}),c},u=(e,r,s)=>{if(t(r))return n(e,r,s);const i=Object.assign({},r);let o=!0;return Object.keys(e).forEach(t=>{const[n,r]=s(i[t],e[t]);void 0!==i[t]&&(i[t]=n),r||(o=!1)}),[i,o]};const h=Symbol("Defined Members"),l=Symbol("unq");class m{toString(){return this[l]}static fromJS(e={},t,n){const r=new this(e);return Object.assign(r,e),Object.defineProperty(r,h,{value:Object.keys(e),writable:!1}),Object.defineProperty(r,l,{value:`${Math.random()}`,writable:!1}),r}static merge(e,t){const n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)}static hasDefined(e,t){return e[h].includes(t)}static toObjectDefined(e){const t={};for(const n of e[h])t[n]=e[n];return t}static keysDefined(e){return e[h]}static normalize(...e){return a(this.schema,...e)}static denormalize(...e){const[t,n]=u(this.schema,...e);return[this.fromJS(t),n]}static asSchema(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this}}m.schema={};class f extends m{static get key(){if("production"!==process.env.NODE_ENV&&""===this.name)throw new Error("Entity classes without a name must define `static get key()`");return this.name}static pk(e,t,n){return this.prototype.pk.call(e,t,n)||n}static normalize(e,t,n,r,s,i){const o=this.fromJS(e,t,n);if("production"!==process.env.NODE_ENV){const e=new this,t=new Set(Object.keys(e)),n=this.keysDefined(o),[r,s,i]=[[],[],[]];for(const e of n)t.has(e)?r.push(e):i.push(e);for(const e of t)r.includes(e)||s.push(e);if((Math.max(n.length/2,1)<=i.length&&t.size>Math.max(i.length,2)||r.length<Math.min(1,t.size/2))&&t.size){const e=new Error(`Attempted to initialize ${this.name} with substantially different than expected keys\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Expected keys:\n Found: ${r}\n Missing: ${s}\n Unexpected keys: ${i}\n Value: ${JSON.stringify(this.toObjectDefined(o),null,2)}`);throw e.status=400,e}}const c=o.pk(t,n);if(void 0===c||""===c){if("production"!==process.env.NODE_ENV){const t=new Error(`Missing usable resource key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Entity: ${this.name}\n Value: ${e&&JSON.stringify(e,null,2)}\n `);throw t.status=400,t}return}const a=this.key;return a in i||(i[a]={}),c in i[a]||(i[a][c]=[]),i[a][c].some(t=>t===e)||(i[a][c].push(e),Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(o,e)&&"object"==typeof o[e]){const t=this.schema[e];o[e]=r(o[e],o,e,t,s,i)}}),s(this,o,o,t,n)),c}static denormalize(e,r){if(t(e)){const[t,s]=n(this.schema,e,r);return[this.fromJS(t.toObject()),s]}let s=!0;const i=e;return Object.keys(this.schema).forEach(t=>{const n=this.schema[t],[o,c]=r(e[t],n);c||(s=!1),this.hasDefined(e,t)&&i[t]!==o&&(i[t]=o)}),[i,s]}}function d(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(f.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return m.fromJS.call(this,e)});class p extends f{static denormalize(e,t){return[e,!0]}}const y=e=>{const n={},r=b(e);return[function e(s,i){if(!i)return[s,!0];if("object"==typeof i&&(!i.denormalize||"function"!=typeof i.denormalize)){return(Array.isArray(i)?c:u)(i,s,e)}return null===s?[s,!0]:d(i)?void 0===s?[s,!1]:((e,n,r,s,i)=>{const o=s(e,n);if("object"!=typeof o||null===o)return[o,!1];i[n.key]||(i[n.key]={});let c=!0;if(!i[n.key][e]){const s=t(o)||o instanceof p?o:n.fromJS(o);i[n.key][e]=s,[i[n.key][e],c]=n.denormalize(s,r)}return[i[n.key][e],c]})(s,i,e,r,n):"function"==typeof i.denormalize?i.denormalize(s,e):[s,!0]},n]},b=e=>{const n=t(e);return(t,r)=>{const s=r.key;return"object"==typeof t?t:n?e.getIn([s,t]):e[s]&&e[s][t]}},O=(e,t,n,r,s,i)=>{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,O,s,i)}return r.normalize(e,t,n,O,s,i)};var g=Object.freeze({__proto__:null,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,s,i){return this.normalizeValue(e,t,n,r,s,i)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends r{normalize(e,t,n,r,s,i){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,s,i)}):t},{})}denormalize(e,t){let n=!0;return[Object.keys(e).reduce((r,s)=>{const i=e[s],[o,c]=this.denormalizeValue(i,t);return c||(n=!1),Object.assign({},r,{[s]:o})},{}),n]}},Array:class extends r{normalize(e,t,n,r,s,o){return i(e).map((e,i)=>this.normalizeValue(e,t,n,r,s,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]}},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)}}});e.Entity=f,e.FlatEntity=p,e.SimpleRecord=m,e.denormalize=(e,t,n)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("schema needed");if(void 0!==e){const[r,s]=y(n);return[...r(e,t),s]}return[void 0,!1,{}]},e.isEntity=d,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={},s={},i=((e,t)=>(n,r,s,i,o)=>{const c=n.key,a=n.pk(s,i,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,s);return{entities:r,indexes:s,result:O(e,e,void 0,t,i,{})}},e.schema=g,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 n(e,t,n){let r=!0;return[Object.keys(e).reduce((t,s)=>{const i=`${s}`,[o,c]=n(t.get(i),e[i]);return c||(r=!1),t.has(i)?t.set(i,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,s,i){const o=this.inferSchema(e,t,n);if(!o)return e;const c=r(e,t,n,o,s,i);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((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0]}}const s=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]),o=(e,t,n,r,o,c,a)=>(e=s(e),i(t).map((t,s)=>o(t,n,r,e,c,a))),c=(e,t,n)=>{e=s(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,s,i,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(n=>{const r=e[n],a=s(t[n],t,n,r,i,o);null==a?delete c[n]:c[n]=a}),c},u=(e,r,s)=>{if(t(r))return n(e,r,s);const i=Object.assign({},r);let o=!0;return Object.keys(e).forEach(t=>{const[n,r]=s(i[t],e[t]);void 0!==i[t]&&(i[t]=n),r||(o=!1)}),[i,o]};const h=Symbol("Defined Members"),l=Symbol("unq");class m{toString(){return this[l]}static fromJS(e={},t,n){const r=new this(e);return Object.assign(r,e),Object.defineProperty(r,h,{value:Object.keys(e),writable:!1}),Object.defineProperty(r,l,{value:`${Math.random()}`,writable:!1}),r}static merge(e,t){const n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)}static hasDefined(e,t){return e[h].includes(t)}static toObjectDefined(e){const t={};for(const n of e[h])t[n]=e[n];return t}static keysDefined(e){return e[h]}static normalize(...e){return a(this.schema,...e)}static denormalize(...e){const[t,n]=u(this.schema,...e);return[this.fromJS(t),n]}static asSchema(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this}}m.schema={};class f extends m{static get key(){if("production"!==process.env.NODE_ENV&&""===this.name)throw new Error("Entity classes without a name must define `static get key()`");return this.name}static pk(e,t,n){return this.prototype.pk.call(e,t,n)||n}static normalize(e,t,n,r,s,i){const o=this.fromJS(e,t,n);if("production"!==process.env.NODE_ENV){const e=new this,t=new Set(Object.keys(e)),n=this.keysDefined(o),[r,s,i]=[[],[],[]];for(const e of n)t.has(e)?r.push(e):i.push(e);for(const e of t)r.includes(e)||s.push(e);if((Math.max(n.length/2,1)<=i.length&&t.size>Math.max(i.length,2)||r.length<Math.min(1,t.size/2))&&t.size){const e=new Error(`Attempted to initialize ${this.name} with substantially different than expected keys\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Expected keys:\n Found: ${r}\n Missing: ${s}\n Unexpected keys: ${i}\n Value: ${JSON.stringify(this.toObjectDefined(o),null,2)}`);throw e.status=400,e}}const c=o.pk(t,n);if(void 0===c||""===c){if("production"!==process.env.NODE_ENV){const t=new Error(`Missing usable resource key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Entity: ${this.name}\n Value: ${e&&JSON.stringify(e,null,2)}\n `);throw t.status=400,t}return}const a=this.key;return a in i||(i[a]={}),c in i[a]||(i[a][c]=[]),i[a][c].some(t=>t===e)||(i[a][c].push(e),Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(o,e)&&"object"==typeof o[e]){const t=this.schema[e];o[e]=r(o[e],o,e,t,s,i)}}),s(this,o,o,t,n)),c}static denormalize(e,r){if(t(e)){const[t,s]=n(this.schema,e,r);return[this.fromJS(t.toObject()),s]}let s=!0;const i=e;return Object.keys(this.schema).forEach(t=>{const n=this.schema[t],[o,c]=r(e[t],n);c||(s=!1),this.hasDefined(e,t)&&i[t]!==o&&(i[t]=o)}),[i,s]}}function d(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(f.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return m.fromJS.call(this,e)});class p extends f{static denormalize(e,t){return[e,!0]}}const y=e=>{const n={},r=b(e);return[function e(s,i){if(!i)return[s,!0];if("object"==typeof i&&(!i.denormalize||"function"!=typeof i.denormalize)){return(Array.isArray(i)?c:u)(i,s,e)}return null===s?[s,!0]:d(i)?void 0===s?[s,!1]:((e,n,r,s,i)=>{const o=s(e,n);if("object"!=typeof o||null===o)return[o,!1];i[n.key]||(i[n.key]={});let c=!0;if(!i[n.key][e]){const s=t(o)||o instanceof p?o:n.fromJS(o);i[n.key][e]=s,[i[n.key][e],c]=n.denormalize(s,r)}return[i[n.key][e],c]})(s,i,e,r,n):"function"==typeof i.denormalize?i.denormalize(s,e):[s,!0]},n]},b=e=>{const n=t(e);return(t,r)=>{const s=r.key;return"object"==typeof t?t:n?e.getIn([s,t]):e[s]&&e[s][t]}},O=(e,t,n,r,s,i)=>{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,O,s,i)}return r.normalize(e,t,n,O,s,i)};var g=Object.freeze({__proto__:null,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,s,i){return this.normalizeValue(e,t,n,r,s,i)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends r{normalize(e,t,n,r,s,i){return Object.keys(e).reduce((t,n,o)=>{const c=e[n];return null!=c?Object.assign(Object.assign({},t),{},{[n]:this.normalizeValue(c,e,n,r,s,i)}):t},{})}denormalize(e,t){let n=!0;return[Object.keys(e).reduce((r,s)=>{const i=e[s],[o,c]=this.denormalizeValue(i,t);return c||(n=!1),Object.assign(Object.assign({},r),{},{[s]:o})},{}),n]}},Array:class extends r{normalize(e,t,n,r,s,o){return i(e).map((e,i)=>this.normalizeValue(e,t,n,r,s,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]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,n)=>{const r=e[n];return Object.assign(Object.assign({},t),{},{[n]:r})},this.schema||{})}normalize(...e){return a(this.schema,...e)}denormalize(...e){return u(this.schema,...e)}}});e.Entity=f,e.FlatEntity=p,e.SimpleRecord=m,e.denormalize=(e,t,n)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("schema needed");if(void 0!==e){const[r,s]=y(n);return[...r(e,t),s]}return[void 0,!1,{}]},e.isEntity=d,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={},s={},i=((e,t)=>(n,r,s,i,o)=>{const c=n.key,a=n.pk(s,i,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,s);return{entities:r,indexes:s,result:O(e,e,void 0,t,i,{})}},e.schema=g,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -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 n(e,t,n){let r=!0;return[Object.keys(e).reduce((t,s)=>{const i=`${s}`,[o,c]=n(t.get(i),e[i]);return c||(r=!1),t.has(i)?t.set(i,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,s,i){const o=this.inferSchema(e,t,n);if(!o)return e;const c=r(e,t,n,o,s,i);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((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0]}}const s=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]),o=(e,t,n,r,o,c,a)=>(e=s(e),i(t).map((t,s)=>o(t,n,r,e,c,a))),c=(e,t,n)=>{e=s(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,s,i,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(n=>{const r=e[n],a=s(t[n],t,n,r,i,o);null==a?delete c[n]:c[n]=a}),c},u=(e,r,s)=>{if(t(r))return n(e,r,s);const i=Object.assign({},r);let o=!0;return Object.keys(e).forEach(t=>{const[n,r]=s(i[t],e[t]);void 0!==i[t]&&(i[t]=n),r||(o=!1)}),[i,o]};const h=Symbol("Defined Members"),l=Symbol("unq");class m{toString(){return this[l]}static fromJS(e={},t,n){const r=new this(e);return Object.assign(r,e),Object.defineProperty(r,h,{value:Object.keys(e),writable:!1}),Object.defineProperty(r,l,{value:`${Math.random()}`,writable:!1}),r}static merge(e,t){const n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)}static hasDefined(e,t){return e[h].includes(t)}static toObjectDefined(e){const t={};for(const n of e[h])t[n]=e[n];return t}static keysDefined(e){return e[h]}static normalize(...e){return a(this.schema,...e)}static denormalize(...e){const[t,n]=u(this.schema,...e);return[this.fromJS(t),n]}static asSchema(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this}}m.schema={};class f extends m{static get key(){if("production"!==process.env.NODE_ENV&&""===this.name)throw new Error("Entity classes without a name must define `static get key()`");return this.name}static pk(e,t,n){return this.prototype.pk.call(e,t,n)||n}static normalize(e,t,n,r,s,i){const o=this.fromJS(e,t,n);if("production"!==process.env.NODE_ENV){const e=new this,t=new Set(Object.keys(e)),n=this.keysDefined(o),[r,s,i]=[[],[],[]];for(const e of n)t.has(e)?r.push(e):i.push(e);for(const e of t)r.includes(e)||s.push(e);if((Math.max(n.length/2,1)<=i.length&&t.size>Math.max(i.length,2)||r.length<Math.min(1,t.size/2))&&t.size){const e=new Error(`Attempted to initialize ${this.name} with substantially different than expected keys\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Expected keys:\n Found: ${r}\n Missing: ${s}\n Unexpected keys: ${i}\n Value: ${JSON.stringify(this.toObjectDefined(o),null,2)}`);throw e.status=400,e}}const c=o.pk(t,n);if(void 0===c||""===c){if("production"!==process.env.NODE_ENV){const t=new Error(`Missing usable resource key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Entity: ${this.name}\n Value: ${e&&JSON.stringify(e,null,2)}\n `);throw t.status=400,t}return}const a=this.key;return a in i||(i[a]={}),c in i[a]||(i[a][c]=[]),i[a][c].some(t=>t===e)||(i[a][c].push(e),Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(o,e)&&"object"==typeof o[e]){const t=this.schema[e];o[e]=r(o[e],o,e,t,s,i)}}),s(this,o,o,t,n)),c}static denormalize(e,r){if(t(e)){const[t,s]=n(this.schema,e,r);return[this.fromJS(t.toObject()),s]}let s=!0;const i=e;return Object.keys(this.schema).forEach(t=>{const n=this.schema[t],[o,c]=r(e[t],n);c||(s=!1),this.hasDefined(e,t)&&i[t]!==o&&(i[t]=o)}),[i,s]}}function d(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(f.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return m.fromJS.call(this,e)});class y extends f{static denormalize(e,t){return[e,!0]}}const p=e=>{const n={},r=b(e);return[function e(s,i){if(!i)return[s,!0];if("object"==typeof i&&(!i.denormalize||"function"!=typeof i.denormalize)){return(Array.isArray(i)?c:u)(i,s,e)}return null===s?[s,!0]:d(i)?void 0===s?[s,!1]:((e,n,r,s,i)=>{const o=s(e,n);if("object"!=typeof o||null===o)return[o,!1];i[n.key]||(i[n.key]={});let c=!0;if(!i[n.key][e]){const s=t(o)||o instanceof y?o:n.fromJS(o);i[n.key][e]=s,[i[n.key][e],c]=n.denormalize(s,r)}return[i[n.key][e],c]})(s,i,e,r,n):"function"==typeof i.denormalize?i.denormalize(s,e):[s,!0]},n]},b=e=>{const n=t(e);return(t,r)=>{const s=r.key;return"object"==typeof t?t:n?e.getIn([s,t]):e[s]&&e[s][t]}},g=(e,t,n,r,s,i)=>{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,g,s,i)}return r.normalize(e,t,n,g,s,i)};var O=Object.freeze({__proto__:null,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,s,i){return this.normalizeValue(e,t,n,r,s,i)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends r{normalize(e,t,n,r,s,i){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,s,i)}):t},{})}denormalize(e,t){let n=!0;return[Object.keys(e).reduce((r,s)=>{const i=e[s],[o,c]=this.denormalizeValue(i,t);return c||(n=!1),Object.assign({},r,{[s]:o})},{}),n]}},Array:class extends r{normalize(e,t,n,r,s,o){return i(e).map((e,i)=>this.normalizeValue(e,t,n,r,s,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]}},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)}}});return e.Entity=f,e.FlatEntity=y,e.SimpleRecord=m,e.denormalize=(e,t,n)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("schema needed");if(void 0!==e){const[r,s]=p(n);return[...r(e,t),s]}return[void 0,!1,{}]},e.isEntity=d,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={},s={},i=((e,t)=>(n,r,s,i,o)=>{const c=n.key,a=n.pk(s,i,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,s);return{entities:r,indexes:s,result:g(e,e,void 0,t,i,{})}},e.schema=O,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 n(e,t,n){let r=!0;return[Object.keys(e).reduce((t,s)=>{const i=`${s}`,[o,c]=n(t.get(i),e[i]);return c||(r=!1),t.has(i)?t.set(i,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,s,i){const o=this.inferSchema(e,t,n);if(!o)return e;const c=r(e,t,n,o,s,i);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((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0]}}const s=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]),o=(e,t,n,r,o,c,a)=>(e=s(e),i(t).map((t,s)=>o(t,n,r,e,c,a))),c=(e,t,n)=>{e=s(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,s,i,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(n=>{const r=e[n],a=s(t[n],t,n,r,i,o);null==a?delete c[n]:c[n]=a}),c},u=(e,r,s)=>{if(t(r))return n(e,r,s);const i=Object.assign({},r);let o=!0;return Object.keys(e).forEach(t=>{const[n,r]=s(i[t],e[t]);void 0!==i[t]&&(i[t]=n),r||(o=!1)}),[i,o]};const h=Symbol("Defined Members"),l=Symbol("unq");class m{toString(){return this[l]}static fromJS(e={},t,n){const r=new this(e);return Object.assign(r,e),Object.defineProperty(r,h,{value:Object.keys(e),writable:!1}),Object.defineProperty(r,l,{value:`${Math.random()}`,writable:!1}),r}static merge(e,t){const n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)}static hasDefined(e,t){return e[h].includes(t)}static toObjectDefined(e){const t={};for(const n of e[h])t[n]=e[n];return t}static keysDefined(e){return e[h]}static normalize(...e){return a(this.schema,...e)}static denormalize(...e){const[t,n]=u(this.schema,...e);return[this.fromJS(t),n]}static asSchema(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this}}m.schema={};class f extends m{static get key(){if("production"!==process.env.NODE_ENV&&""===this.name)throw new Error("Entity classes without a name must define `static get key()`");return this.name}static pk(e,t,n){return this.prototype.pk.call(e,t,n)||n}static normalize(e,t,n,r,s,i){const o=this.fromJS(e,t,n);if("production"!==process.env.NODE_ENV){const e=new this,t=new Set(Object.keys(e)),n=this.keysDefined(o),[r,s,i]=[[],[],[]];for(const e of n)t.has(e)?r.push(e):i.push(e);for(const e of t)r.includes(e)||s.push(e);if((Math.max(n.length/2,1)<=i.length&&t.size>Math.max(i.length,2)||r.length<Math.min(1,t.size/2))&&t.size){const e=new Error(`Attempted to initialize ${this.name} with substantially different than expected keys\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Expected keys:\n Found: ${r}\n Missing: ${s}\n Unexpected keys: ${i}\n Value: ${JSON.stringify(this.toObjectDefined(o),null,2)}`);throw e.status=400,e}}const c=o.pk(t,n);if(void 0===c||""===c){if("production"!==process.env.NODE_ENV){const t=new Error(`Missing usable resource key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Entity: ${this.name}\n Value: ${e&&JSON.stringify(e,null,2)}\n `);throw t.status=400,t}return}const a=this.key;return a in i||(i[a]={}),c in i[a]||(i[a][c]=[]),i[a][c].some(t=>t===e)||(i[a][c].push(e),Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(o,e)&&"object"==typeof o[e]){const t=this.schema[e];o[e]=r(o[e],o,e,t,s,i)}}),s(this,o,o,t,n)),c}static denormalize(e,r){if(t(e)){const[t,s]=n(this.schema,e,r);return[this.fromJS(t.toObject()),s]}let s=!0;const i=e;return Object.keys(this.schema).forEach(t=>{const n=this.schema[t],[o,c]=r(e[t],n);c||(s=!1),this.hasDefined(e,t)&&i[t]!==o&&(i[t]=o)}),[i,s]}}function d(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(f.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return m.fromJS.call(this,e)});class y extends f{static denormalize(e,t){return[e,!0]}}const p=e=>{const n={},r=b(e);return[function e(s,i){if(!i)return[s,!0];if("object"==typeof i&&(!i.denormalize||"function"!=typeof i.denormalize)){return(Array.isArray(i)?c:u)(i,s,e)}return null===s?[s,!0]:d(i)?void 0===s?[s,!1]:((e,n,r,s,i)=>{const o=s(e,n);if("object"!=typeof o||null===o)return[o,!1];i[n.key]||(i[n.key]={});let c=!0;if(!i[n.key][e]){const s=t(o)||o instanceof y?o:n.fromJS(o);i[n.key][e]=s,[i[n.key][e],c]=n.denormalize(s,r)}return[i[n.key][e],c]})(s,i,e,r,n):"function"==typeof i.denormalize?i.denormalize(s,e):[s,!0]},n]},b=e=>{const n=t(e);return(t,r)=>{const s=r.key;return"object"==typeof t?t:n?e.getIn([s,t]):e[s]&&e[s][t]}},g=(e,t,n,r,s,i)=>{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,g,s,i)}return r.normalize(e,t,n,g,s,i)};var O=Object.freeze({__proto__:null,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,s,i){return this.normalizeValue(e,t,n,r,s,i)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends r{normalize(e,t,n,r,s,i){return Object.keys(e).reduce((t,n,o)=>{const c=e[n];return null!=c?Object.assign(Object.assign({},t),{},{[n]:this.normalizeValue(c,e,n,r,s,i)}):t},{})}denormalize(e,t){let n=!0;return[Object.keys(e).reduce((r,s)=>{const i=e[s],[o,c]=this.denormalizeValue(i,t);return c||(n=!1),Object.assign(Object.assign({},r),{},{[s]:o})},{}),n]}},Array:class extends r{normalize(e,t,n,r,s,o){return i(e).map((e,i)=>this.normalizeValue(e,t,n,r,s,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]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,n)=>{const r=e[n];return Object.assign(Object.assign({},t),{},{[n]:r})},this.schema||{})}normalize(...e){return a(this.schema,...e)}denormalize(...e){return u(this.schema,...e)}}});return e.Entity=f,e.FlatEntity=y,e.SimpleRecord=m,e.denormalize=(e,t,n)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("schema needed");if(void 0!==e){const[r,s]=p(n);return[...r(e,t),s]}return[void 0,!1,{}]},e.isEntity=d,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={},s={},i=((e,t)=>(n,r,s,i,o)=>{const c=n.key,a=n.pk(s,i,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,s);return{entities:r,indexes:s,result:g(e,e,void 0,t,i,{})}},e.schema=O,e}({});

@@ -194,3 +194,3 @@ /**

const schema = definition[key];
return Object.assign({}, entitySchema, {
return Object.assign(Object.assign({}, entitySchema), {}, {
[key]: schema

@@ -656,3 +656,3 @@ });

const value = input[key];
return value !== undefined && value !== null ? Object.assign({}, output, {
return value !== undefined && value !== null ? Object.assign(Object.assign({}, output), {}, {
[key]: this.normalizeValue(value, input, key, visit, addEntity, visitedEntities)

@@ -673,3 +673,3 @@ }) : output;

return Object.assign({}, output, {
return Object.assign(Object.assign({}, output), {}, {
[key]: value

@@ -676,0 +676,0 @@ });

@@ -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,n){let r=!0;return[Object.keys(e).reduce((t,s)=>{const i=`${s}`,[o,c]=n(t.get(i),e[i]);return c||(r=!1),t.has(i)?t.set(i,o):t},t),r]}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,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,s,i){const o=this.inferSchema(e,t,n);if(!o)return e;const c=r(e,t,n,o,s,i);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,n)}}denormalizeValue(t,n){const r=e(t)?t.get("schema"):t.schema;return this.isSingleSchema||r?n((this.isSingleSchema?void 0:e(t)?t.get("id"):t.id)||t,this.isSingleSchema?this.schema:this.schema[r]):[t,!0]}}const r=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]),i=(e,t,n,i,o,c,a)=>(e=r(e),s(t).map((t,r)=>o(t,n,i,e,c,a))),o=(e,t,n)=>{e=r(e);let s=!0;return void 0===t&&e&&([,s]=n(void 0,e)),[t&&t.map?t.map(t=>n(t,e)).filter(([,e])=>e).map(([e])=>e):t,s]};const c=(e,t,n,r,s,i,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(n=>{const r=e[n],a=s(t[n],t,n,r,i,o);null==a?delete c[n]:c[n]=a}),c},a=(n,r,s)=>{if(e(r))return t(n,r,s);const i=Object.assign({},r);let o=!0;return Object.keys(n).forEach(e=>{const[t,r]=s(i[e],n[e]);void 0!==i[e]&&(i[e]=t),r||(o=!1)}),[i,o]};const u=Symbol("Defined Members"),h=Symbol("unq");class l{toString(){return this[h]}static fromJS(e={},t,n){const r=new this(e);return Object.assign(r,e),Object.defineProperty(r,u,{value:Object.keys(e),writable:!1}),Object.defineProperty(r,h,{value:`${Math.random()}`,writable:!1}),r}static merge(e,t){const n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)}static hasDefined(e,t){return e[u].includes(t)}static toObjectDefined(e){const t={};for(const n of e[u])t[n]=e[n];return t}static keysDefined(e){return e[u]}static normalize(...e){return c(this.schema,...e)}static denormalize(...e){const[t,n]=a(this.schema,...e);return[this.fromJS(t),n]}static asSchema(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this}}l.schema={};class m extends l{static get key(){if("production"!==process.env.NODE_ENV&&""===this.name)throw new Error("Entity classes without a name must define `static get key()`");return this.name}static pk(e,t,n){return this.prototype.pk.call(e,t,n)||n}static normalize(e,t,n,r,s,i){const o=this.fromJS(e,t,n);if("production"!==process.env.NODE_ENV){const e=new this,t=new Set(Object.keys(e)),n=this.keysDefined(o),[r,s,i]=[[],[],[]];for(const e of n)t.has(e)?r.push(e):i.push(e);for(const e of t)r.includes(e)||s.push(e);if((Math.max(n.length/2,1)<=i.length&&t.size>Math.max(i.length,2)||r.length<Math.min(1,t.size/2))&&t.size){const e=new Error(`Attempted to initialize ${this.name} with substantially different than expected keys\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Expected keys:\n Found: ${r}\n Missing: ${s}\n Unexpected keys: ${i}\n Value: ${JSON.stringify(this.toObjectDefined(o),null,2)}`);throw e.status=400,e}}const c=o.pk(t,n);if(void 0===c||""===c){if("production"!==process.env.NODE_ENV){const t=new Error(`Missing usable resource key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Entity: ${this.name}\n Value: ${e&&JSON.stringify(e,null,2)}\n `);throw t.status=400,t}return}const a=this.key;return a in i||(i[a]={}),c in i[a]||(i[a][c]=[]),i[a][c].some(t=>t===e)||(i[a][c].push(e),Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(o,e)&&"object"==typeof o[e]){const t=this.schema[e];o[e]=r(o[e],o,e,t,s,i)}}),s(this,o,o,t,n)),c}static denormalize(n,r){if(e(n)){const[e,s]=t(this.schema,n,r);return[this.fromJS(e.toObject()),s]}let s=!0;const i=n;return Object.keys(this.schema).forEach(e=>{const t=this.schema[e],[o,c]=r(n[e],t);c||(s=!1),this.hasDefined(n,e)&&i[e]!==o&&(i[e]=o)}),[i,s]}}function f(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(m.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return l.fromJS.call(this,e)});class d extends m{static denormalize(e,t){return[e,!0]}}const p=t=>{const n={},r=y(t);return[function t(s,i){if(!i)return[s,!0];if("object"==typeof i&&(!i.denormalize||"function"!=typeof i.denormalize)){return(Array.isArray(i)?o:a)(i,s,t)}return null===s?[s,!0]:f(i)?void 0===s?[s,!1]:((t,n,r,s,i)=>{const o=s(t,n);if("object"!=typeof o||null===o)return[o,!1];i[n.key]||(i[n.key]={});let c=!0;if(!i[n.key][t]){const s=e(o)||o instanceof d?o:n.fromJS(o);i[n.key][t]=s,[i[n.key][t],c]=n.denormalize(s,r)}return[i[n.key][t],c]})(s,i,t,r,n):"function"==typeof i.denormalize?i.denormalize(s,t):[s,!0]},n]},y=t=>{const n=e(t);return(e,r)=>{const s=r.key;return"object"==typeof e?e:n?t.getIn([s,e]):t[s]&&t[s][e]}},b=(e,t,n)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("schema needed");if(void 0!==e){const[r,s]=p(n);return[...r(e,t),s]}return[void 0,!1,{}]},g=(e,t,n,r,s,o)=>{if("object"!=typeof e||!e||!r)return e;if("object"==typeof r&&(!r.normalize||"function"!=typeof r.normalize)){return(Array.isArray(r)?i:c)(r,e,t,n,g,s,o)}return r.normalize(e,t,n,g,s,o)};const O=(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={},s={},i=((e,t)=>(n,r,s,i,o)=>{const c=n.key,a=n.pk(s,i,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,s);return{entities:r,indexes:s,result:g(e,e,void 0,t,i,{})}};var j=Object.freeze({__proto__:null,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,n,r,s,i){return this.normalizeValue(e,t,n,r,s,i)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends n{normalize(e,t,n,r,s,i){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,s,i)}):t},{})}denormalize(e,t){let n=!0;return[Object.keys(e).reduce((r,s)=>{const i=e[s],[o,c]=this.denormalizeValue(i,t);return c||(n=!1),Object.assign({},r,{[s]:o})},{}),n]}},Array:class extends n{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]}},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 c(this.schema,...e)}denormalize(...e){return a(this.schema,...e)}}});export{m as Entity,d as FlatEntity,l as SimpleRecord,b as denormalize,f as isEntity,O as normalize,j 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,n){let r=!0;return[Object.keys(e).reduce((t,s)=>{const i=`${s}`,[o,c]=n(t.get(i),e[i]);return c||(r=!1),t.has(i)?t.set(i,o):t},t),r]}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,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,s,i){const o=this.inferSchema(e,t,n);if(!o)return e;const c=r(e,t,n,o,s,i);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,n)}}denormalizeValue(t,n){const r=e(t)?t.get("schema"):t.schema;return this.isSingleSchema||r?n((this.isSingleSchema?void 0:e(t)?t.get("id"):t.id)||t,this.isSingleSchema?this.schema:this.schema[r]):[t,!0]}}const r=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]),i=(e,t,n,i,o,c,a)=>(e=r(e),s(t).map((t,r)=>o(t,n,i,e,c,a))),o=(e,t,n)=>{e=r(e);let s=!0;return void 0===t&&e&&([,s]=n(void 0,e)),[t&&t.map?t.map(t=>n(t,e)).filter(([,e])=>e).map(([e])=>e):t,s]};const c=(e,t,n,r,s,i,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(n=>{const r=e[n],a=s(t[n],t,n,r,i,o);null==a?delete c[n]:c[n]=a}),c},a=(n,r,s)=>{if(e(r))return t(n,r,s);const i=Object.assign({},r);let o=!0;return Object.keys(n).forEach(e=>{const[t,r]=s(i[e],n[e]);void 0!==i[e]&&(i[e]=t),r||(o=!1)}),[i,o]};const u=Symbol("Defined Members"),h=Symbol("unq");class l{toString(){return this[h]}static fromJS(e={},t,n){const r=new this(e);return Object.assign(r,e),Object.defineProperty(r,u,{value:Object.keys(e),writable:!1}),Object.defineProperty(r,h,{value:`${Math.random()}`,writable:!1}),r}static merge(e,t){const n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)}static hasDefined(e,t){return e[u].includes(t)}static toObjectDefined(e){const t={};for(const n of e[u])t[n]=e[n];return t}static keysDefined(e){return e[u]}static normalize(...e){return c(this.schema,...e)}static denormalize(...e){const[t,n]=a(this.schema,...e);return[this.fromJS(t),n]}static asSchema(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this}}l.schema={};class m extends l{static get key(){if("production"!==process.env.NODE_ENV&&""===this.name)throw new Error("Entity classes without a name must define `static get key()`");return this.name}static pk(e,t,n){return this.prototype.pk.call(e,t,n)||n}static normalize(e,t,n,r,s,i){const o=this.fromJS(e,t,n);if("production"!==process.env.NODE_ENV){const e=new this,t=new Set(Object.keys(e)),n=this.keysDefined(o),[r,s,i]=[[],[],[]];for(const e of n)t.has(e)?r.push(e):i.push(e);for(const e of t)r.includes(e)||s.push(e);if((Math.max(n.length/2,1)<=i.length&&t.size>Math.max(i.length,2)||r.length<Math.min(1,t.size/2))&&t.size){const e=new Error(`Attempted to initialize ${this.name} with substantially different than expected keys\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Expected keys:\n Found: ${r}\n Missing: ${s}\n Unexpected keys: ${i}\n Value: ${JSON.stringify(this.toObjectDefined(o),null,2)}`);throw e.status=400,e}}const c=o.pk(t,n);if(void 0===c||""===c){if("production"!==process.env.NODE_ENV){const t=new Error(`Missing usable resource key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Entity: ${this.name}\n Value: ${e&&JSON.stringify(e,null,2)}\n `);throw t.status=400,t}return}const a=this.key;return a in i||(i[a]={}),c in i[a]||(i[a][c]=[]),i[a][c].some(t=>t===e)||(i[a][c].push(e),Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(o,e)&&"object"==typeof o[e]){const t=this.schema[e];o[e]=r(o[e],o,e,t,s,i)}}),s(this,o,o,t,n)),c}static denormalize(n,r){if(e(n)){const[e,s]=t(this.schema,n,r);return[this.fromJS(e.toObject()),s]}let s=!0;const i=n;return Object.keys(this.schema).forEach(e=>{const t=this.schema[e],[o,c]=r(n[e],t);c||(s=!1),this.hasDefined(n,e)&&i[e]!==o&&(i[e]=o)}),[i,s]}}function f(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(m.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return l.fromJS.call(this,e)});class d extends m{static denormalize(e,t){return[e,!0]}}const p=t=>{const n={},r=y(t);return[function t(s,i){if(!i)return[s,!0];if("object"==typeof i&&(!i.denormalize||"function"!=typeof i.denormalize)){return(Array.isArray(i)?o:a)(i,s,t)}return null===s?[s,!0]:f(i)?void 0===s?[s,!1]:((t,n,r,s,i)=>{const o=s(t,n);if("object"!=typeof o||null===o)return[o,!1];i[n.key]||(i[n.key]={});let c=!0;if(!i[n.key][t]){const s=e(o)||o instanceof d?o:n.fromJS(o);i[n.key][t]=s,[i[n.key][t],c]=n.denormalize(s,r)}return[i[n.key][t],c]})(s,i,t,r,n):"function"==typeof i.denormalize?i.denormalize(s,t):[s,!0]},n]},y=t=>{const n=e(t);return(e,r)=>{const s=r.key;return"object"==typeof e?e:n?t.getIn([s,e]):t[s]&&t[s][e]}},b=(e,t,n)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("schema needed");if(void 0!==e){const[r,s]=p(n);return[...r(e,t),s]}return[void 0,!1,{}]},g=(e,t,n,r,s,o)=>{if("object"!=typeof e||!e||!r)return e;if("object"==typeof r&&(!r.normalize||"function"!=typeof r.normalize)){return(Array.isArray(r)?i:c)(r,e,t,n,g,s,o)}return r.normalize(e,t,n,g,s,o)};const O=(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={},s={},i=((e,t)=>(n,r,s,i,o)=>{const c=n.key,a=n.pk(s,i,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,s);return{entities:r,indexes:s,result:g(e,e,void 0,t,i,{})}};var j=Object.freeze({__proto__:null,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,n,r,s,i){return this.normalizeValue(e,t,n,r,s,i)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends n{normalize(e,t,n,r,s,i){return Object.keys(e).reduce((t,n,o)=>{const c=e[n];return null!=c?Object.assign(Object.assign({},t),{},{[n]:this.normalizeValue(c,e,n,r,s,i)}):t},{})}denormalize(e,t){let n=!0;return[Object.keys(e).reduce((r,s)=>{const i=e[s],[o,c]=this.denormalizeValue(i,t);return c||(n=!1),Object.assign(Object.assign({},r),{},{[s]:o})},{}),n]}},Array:class extends n{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]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,n)=>{const r=e[n];return Object.assign(Object.assign({},t),{},{[n]:r})},this.schema||{})}normalize(...e){return c(this.schema,...e)}denormalize(...e){return a(this.schema,...e)}}});export{m as Entity,d as FlatEntity,l as SimpleRecord,b as denormalize,f as isEntity,O as normalize,j as 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,n){let r=!0;return[Object.keys(e).reduce((t,s)=>{const i=`${s}`,[o,c]=n(t.get(i),e[i]);return c||(r=!1),t.has(i)?t.set(i,o):t},t),r]}Object.defineProperty(exports,"__esModule",{value:!0});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,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,s,i){const o=this.inferSchema(e,t,n);if(!o)return e;const c=r(e,t,n,o,s,i);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,n)}}denormalizeValue(t,n){const r=e(t)?t.get("schema"):t.schema;return this.isSingleSchema||r?n((this.isSingleSchema?void 0:e(t)?t.get("id"):t.id)||t,this.isSingleSchema?this.schema:this.schema[r]):[t,!0]}}const r=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]),i=(e,t,n,i,o,c,a)=>(e=r(e),s(t).map((t,r)=>o(t,n,i,e,c,a))),o=(e,t,n)=>{e=r(e);let s=!0;return void 0===t&&e&&([,s]=n(void 0,e)),[t&&t.map?t.map(t=>n(t,e)).filter(([,e])=>e).map(([e])=>e):t,s]};const c=(e,t,n,r,s,i,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(n=>{const r=e[n],a=s(t[n],t,n,r,i,o);null==a?delete c[n]:c[n]=a}),c},a=(n,r,s)=>{if(e(r))return t(n,r,s);const i=Object.assign({},r);let o=!0;return Object.keys(n).forEach(e=>{const[t,r]=s(i[e],n[e]);void 0!==i[e]&&(i[e]=t),r||(o=!1)}),[i,o]};const u=Symbol("Defined Members"),h=Symbol("unq");class l{toString(){return this[h]}static fromJS(e={},t,n){const r=new this(e);return Object.assign(r,e),Object.defineProperty(r,u,{value:Object.keys(e),writable:!1}),Object.defineProperty(r,h,{value:`${Math.random()}`,writable:!1}),r}static merge(e,t){const n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)}static hasDefined(e,t){return e[u].includes(t)}static toObjectDefined(e){const t={};for(const n of e[u])t[n]=e[n];return t}static keysDefined(e){return e[u]}static normalize(...e){return c(this.schema,...e)}static denormalize(...e){const[t,n]=a(this.schema,...e);return[this.fromJS(t),n]}static asSchema(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this}}l.schema={};class m extends l{static get key(){if("production"!==process.env.NODE_ENV&&""===this.name)throw new Error("Entity classes without a name must define `static get key()`");return this.name}static pk(e,t,n){return this.prototype.pk.call(e,t,n)||n}static normalize(e,t,n,r,s,i){const o=this.fromJS(e,t,n);if("production"!==process.env.NODE_ENV){const e=new this,t=new Set(Object.keys(e)),n=this.keysDefined(o),[r,s,i]=[[],[],[]];for(const e of n)t.has(e)?r.push(e):i.push(e);for(const e of t)r.includes(e)||s.push(e);if((Math.max(n.length/2,1)<=i.length&&t.size>Math.max(i.length,2)||r.length<Math.min(1,t.size/2))&&t.size){const e=new Error(`Attempted to initialize ${this.name} with substantially different than expected keys\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Expected keys:\n Found: ${r}\n Missing: ${s}\n Unexpected keys: ${i}\n Value: ${JSON.stringify(this.toObjectDefined(o),null,2)}`);throw e.status=400,e}}const c=o.pk(t,n);if(void 0===c||""===c){if("production"!==process.env.NODE_ENV){const t=new Error(`Missing usable resource key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Entity: ${this.name}\n Value: ${e&&JSON.stringify(e,null,2)}\n `);throw t.status=400,t}return}const a=this.key;return a in i||(i[a]={}),c in i[a]||(i[a][c]=[]),i[a][c].some(t=>t===e)||(i[a][c].push(e),Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(o,e)&&"object"==typeof o[e]){const t=this.schema[e];o[e]=r(o[e],o,e,t,s,i)}}),s(this,o,o,t,n)),c}static denormalize(n,r){if(e(n)){const[e,s]=t(this.schema,n,r);return[this.fromJS(e.toObject()),s]}let s=!0;const i=n;return Object.keys(this.schema).forEach(e=>{const t=this.schema[e],[o,c]=r(n[e],t);c||(s=!1),this.hasDefined(n,e)&&i[e]!==o&&(i[e]=o)}),[i,s]}}function f(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(m.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return l.fromJS.call(this,e)});class d extends m{static denormalize(e,t){return[e,!0]}}const p=t=>{const n={},r=y(t);return[function t(s,i){if(!i)return[s,!0];if("object"==typeof i&&(!i.denormalize||"function"!=typeof i.denormalize)){return(Array.isArray(i)?o:a)(i,s,t)}return null===s?[s,!0]:f(i)?void 0===s?[s,!1]:((t,n,r,s,i)=>{const o=s(t,n);if("object"!=typeof o||null===o)return[o,!1];i[n.key]||(i[n.key]={});let c=!0;if(!i[n.key][t]){const s=e(o)||o instanceof d?o:n.fromJS(o);i[n.key][t]=s,[i[n.key][t],c]=n.denormalize(s,r)}return[i[n.key][t],c]})(s,i,t,r,n):"function"==typeof i.denormalize?i.denormalize(s,t):[s,!0]},n]},y=t=>{const n=e(t);return(e,r)=>{const s=r.key;return"object"==typeof e?e:n?t.getIn([s,e]):t[s]&&t[s][e]}},b=(e,t,n,r,s,o)=>{if("object"!=typeof e||!e||!r)return e;if("object"==typeof r&&(!r.normalize||"function"!=typeof r.normalize)){return(Array.isArray(r)?i:c)(r,e,t,n,b,s,o)}return r.normalize(e,t,n,b,s,o)};var O=Object.freeze({__proto__:null,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,n,r,s,i){return this.normalizeValue(e,t,n,r,s,i)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends n{normalize(e,t,n,r,s,i){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,s,i)}):t},{})}denormalize(e,t){let n=!0;return[Object.keys(e).reduce((r,s)=>{const i=e[s],[o,c]=this.denormalizeValue(i,t);return c||(n=!1),Object.assign({},r,{[s]:o})},{}),n]}},Array:class extends n{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]}},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 c(this.schema,...e)}denormalize(...e){return a(this.schema,...e)}}});exports.Entity=m,exports.FlatEntity=d,exports.SimpleRecord=l,exports.denormalize=(e,t,n)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("schema needed");if(void 0!==e){const[r,s]=p(n);return[...r(e,t),s]}return[void 0,!1,{}]},exports.isEntity=f,exports.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={},s={},i=((e,t)=>(n,r,s,i,o)=>{const c=n.key,a=n.pk(s,i,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,s);return{entities:r,indexes:s,result:b(e,e,void 0,t,i,{})}},exports.schema=O;
"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,n){let r=!0;return[Object.keys(e).reduce((t,s)=>{const i=`${s}`,[o,c]=n(t.get(i),e[i]);return c||(r=!1),t.has(i)?t.set(i,o):t},t),r]}Object.defineProperty(exports,"__esModule",{value:!0});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,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,s,i){const o=this.inferSchema(e,t,n);if(!o)return e;const c=r(e,t,n,o,s,i);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,n)}}denormalizeValue(t,n){const r=e(t)?t.get("schema"):t.schema;return this.isSingleSchema||r?n((this.isSingleSchema?void 0:e(t)?t.get("id"):t.id)||t,this.isSingleSchema?this.schema:this.schema[r]):[t,!0]}}const r=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]),i=(e,t,n,i,o,c,a)=>(e=r(e),s(t).map((t,r)=>o(t,n,i,e,c,a))),o=(e,t,n)=>{e=r(e);let s=!0;return void 0===t&&e&&([,s]=n(void 0,e)),[t&&t.map?t.map(t=>n(t,e)).filter(([,e])=>e).map(([e])=>e):t,s]};const c=(e,t,n,r,s,i,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(n=>{const r=e[n],a=s(t[n],t,n,r,i,o);null==a?delete c[n]:c[n]=a}),c},a=(n,r,s)=>{if(e(r))return t(n,r,s);const i=Object.assign({},r);let o=!0;return Object.keys(n).forEach(e=>{const[t,r]=s(i[e],n[e]);void 0!==i[e]&&(i[e]=t),r||(o=!1)}),[i,o]};const u=Symbol("Defined Members"),h=Symbol("unq");class l{toString(){return this[h]}static fromJS(e={},t,n){const r=new this(e);return Object.assign(r,e),Object.defineProperty(r,u,{value:Object.keys(e),writable:!1}),Object.defineProperty(r,h,{value:`${Math.random()}`,writable:!1}),r}static merge(e,t){const n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)}static hasDefined(e,t){return e[u].includes(t)}static toObjectDefined(e){const t={};for(const n of e[u])t[n]=e[n];return t}static keysDefined(e){return e[u]}static normalize(...e){return c(this.schema,...e)}static denormalize(...e){const[t,n]=a(this.schema,...e);return[this.fromJS(t),n]}static asSchema(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this}}l.schema={};class m extends l{static get key(){if("production"!==process.env.NODE_ENV&&""===this.name)throw new Error("Entity classes without a name must define `static get key()`");return this.name}static pk(e,t,n){return this.prototype.pk.call(e,t,n)||n}static normalize(e,t,n,r,s,i){const o=this.fromJS(e,t,n);if("production"!==process.env.NODE_ENV){const e=new this,t=new Set(Object.keys(e)),n=this.keysDefined(o),[r,s,i]=[[],[],[]];for(const e of n)t.has(e)?r.push(e):i.push(e);for(const e of t)r.includes(e)||s.push(e);if((Math.max(n.length/2,1)<=i.length&&t.size>Math.max(i.length,2)||r.length<Math.min(1,t.size/2))&&t.size){const e=new Error(`Attempted to initialize ${this.name} with substantially different than expected keys\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Expected keys:\n Found: ${r}\n Missing: ${s}\n Unexpected keys: ${i}\n Value: ${JSON.stringify(this.toObjectDefined(o),null,2)}`);throw e.status=400,e}}const c=o.pk(t,n);if(void 0===c||""===c){if("production"!==process.env.NODE_ENV){const t=new Error(`Missing usable resource key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Entity: ${this.name}\n Value: ${e&&JSON.stringify(e,null,2)}\n `);throw t.status=400,t}return}const a=this.key;return a in i||(i[a]={}),c in i[a]||(i[a][c]=[]),i[a][c].some(t=>t===e)||(i[a][c].push(e),Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(o,e)&&"object"==typeof o[e]){const t=this.schema[e];o[e]=r(o[e],o,e,t,s,i)}}),s(this,o,o,t,n)),c}static denormalize(n,r){if(e(n)){const[e,s]=t(this.schema,n,r);return[this.fromJS(e.toObject()),s]}let s=!0;const i=n;return Object.keys(this.schema).forEach(e=>{const t=this.schema[e],[o,c]=r(n[e],t);c||(s=!1),this.hasDefined(n,e)&&i[e]!==o&&(i[e]=o)}),[i,s]}}function f(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(m.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return l.fromJS.call(this,e)});class d extends m{static denormalize(e,t){return[e,!0]}}const p=t=>{const n={},r=y(t);return[function t(s,i){if(!i)return[s,!0];if("object"==typeof i&&(!i.denormalize||"function"!=typeof i.denormalize)){return(Array.isArray(i)?o:a)(i,s,t)}return null===s?[s,!0]:f(i)?void 0===s?[s,!1]:((t,n,r,s,i)=>{const o=s(t,n);if("object"!=typeof o||null===o)return[o,!1];i[n.key]||(i[n.key]={});let c=!0;if(!i[n.key][t]){const s=e(o)||o instanceof d?o:n.fromJS(o);i[n.key][t]=s,[i[n.key][t],c]=n.denormalize(s,r)}return[i[n.key][t],c]})(s,i,t,r,n):"function"==typeof i.denormalize?i.denormalize(s,t):[s,!0]},n]},y=t=>{const n=e(t);return(e,r)=>{const s=r.key;return"object"==typeof e?e:n?t.getIn([s,e]):t[s]&&t[s][e]}},b=(e,t,n,r,s,o)=>{if("object"!=typeof e||!e||!r)return e;if("object"==typeof r&&(!r.normalize||"function"!=typeof r.normalize)){return(Array.isArray(r)?i:c)(r,e,t,n,b,s,o)}return r.normalize(e,t,n,b,s,o)};var O=Object.freeze({__proto__:null,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,n,r,s,i){return this.normalizeValue(e,t,n,r,s,i)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends n{normalize(e,t,n,r,s,i){return Object.keys(e).reduce((t,n,o)=>{const c=e[n];return null!=c?Object.assign(Object.assign({},t),{},{[n]:this.normalizeValue(c,e,n,r,s,i)}):t},{})}denormalize(e,t){let n=!0;return[Object.keys(e).reduce((r,s)=>{const i=e[s],[o,c]=this.denormalizeValue(i,t);return c||(n=!1),Object.assign(Object.assign({},r),{},{[s]:o})},{}),n]}},Array:class extends n{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]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,n)=>{const r=e[n];return Object.assign(Object.assign({},t),{},{[n]:r})},this.schema||{})}normalize(...e){return c(this.schema,...e)}denormalize(...e){return a(this.schema,...e)}}});exports.Entity=m,exports.FlatEntity=d,exports.SimpleRecord=l,exports.denormalize=(e,t,n)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("schema needed");if(void 0!==e){const[r,s]=p(n);return[...r(e,t),s]}return[void 0,!1,{}]},exports.isEntity=f,exports.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={},s={},i=((e,t)=>(n,r,s,i,o)=>{const c=n.key,a=n.pk(s,i,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,s);return{entities:r,indexes:s,result:b(e,e,void 0,t,i,{})}},exports.schema=O;

@@ -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,s)=>{const i=`${s}`,[o,c]=n(t.get(i),e[i]);return c||(r=!1),t.has(i)?t.set(i,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,s,i){const o=this.inferSchema(e,t,n);if(!o)return e;const c=r(e,t,n,o,s,i);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((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0]}}const s=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]),o=(e,t,n,r,o,c,a)=>(e=s(e),i(t).map((t,s)=>o(t,n,r,e,c,a))),c=(e,t,n)=>{e=s(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,s,i,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(n=>{const r=e[n],a=s(t[n],t,n,r,i,o);null==a?delete c[n]:c[n]=a}),c},u=(e,r,s)=>{if(t(r))return n(e,r,s);const i=Object.assign({},r);let o=!0;return Object.keys(e).forEach(t=>{const[n,r]=s(i[t],e[t]);void 0!==i[t]&&(i[t]=n),r||(o=!1)}),[i,o]};const h=Symbol("Defined Members"),l=Symbol("unq");class m{toString(){return this[l]}static fromJS(e={},t,n){const r=new this(e);return Object.assign(r,e),Object.defineProperty(r,h,{value:Object.keys(e),writable:!1}),Object.defineProperty(r,l,{value:`${Math.random()}`,writable:!1}),r}static merge(e,t){const n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)}static hasDefined(e,t){return e[h].includes(t)}static toObjectDefined(e){const t={};for(const n of e[h])t[n]=e[n];return t}static keysDefined(e){return e[h]}static normalize(...e){return a(this.schema,...e)}static denormalize(...e){const[t,n]=u(this.schema,...e);return[this.fromJS(t),n]}static asSchema(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this}}m.schema={};class f extends m{static get key(){if("production"!==process.env.NODE_ENV&&""===this.name)throw new Error("Entity classes without a name must define `static get key()`");return this.name}static pk(e,t,n){return this.prototype.pk.call(e,t,n)||n}static normalize(e,t,n,r,s,i){const o=this.fromJS(e,t,n);if("production"!==process.env.NODE_ENV){const e=new this,t=new Set(Object.keys(e)),n=this.keysDefined(o),[r,s,i]=[[],[],[]];for(const e of n)t.has(e)?r.push(e):i.push(e);for(const e of t)r.includes(e)||s.push(e);if((Math.max(n.length/2,1)<=i.length&&t.size>Math.max(i.length,2)||r.length<Math.min(1,t.size/2))&&t.size){const e=new Error(`Attempted to initialize ${this.name} with substantially different than expected keys\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Expected keys:\n Found: ${r}\n Missing: ${s}\n Unexpected keys: ${i}\n Value: ${JSON.stringify(this.toObjectDefined(o),null,2)}`);throw e.status=400,e}}const c=o.pk(t,n);if(void 0===c||""===c){if("production"!==process.env.NODE_ENV){const t=new Error(`Missing usable resource key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Entity: ${this.name}\n Value: ${e&&JSON.stringify(e,null,2)}\n `);throw t.status=400,t}return}const a=this.key;return a in i||(i[a]={}),c in i[a]||(i[a][c]=[]),i[a][c].some(t=>t===e)||(i[a][c].push(e),Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(o,e)&&"object"==typeof o[e]){const t=this.schema[e];o[e]=r(o[e],o,e,t,s,i)}}),s(this,o,o,t,n)),c}static denormalize(e,r){if(t(e)){const[t,s]=n(this.schema,e,r);return[this.fromJS(t.toObject()),s]}let s=!0;const i=e;return Object.keys(this.schema).forEach(t=>{const n=this.schema[t],[o,c]=r(e[t],n);c||(s=!1),this.hasDefined(e,t)&&i[t]!==o&&(i[t]=o)}),[i,s]}}function d(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(f.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return m.fromJS.call(this,e)});class p extends f{static denormalize(e,t){return[e,!0]}}const y=e=>{const n={},r=b(e);return[function e(s,i){if(!i)return[s,!0];if("object"==typeof i&&(!i.denormalize||"function"!=typeof i.denormalize)){return(Array.isArray(i)?c:u)(i,s,e)}return null===s?[s,!0]:d(i)?void 0===s?[s,!1]:((e,n,r,s,i)=>{const o=s(e,n);if("object"!=typeof o||null===o)return[o,!1];i[n.key]||(i[n.key]={});let c=!0;if(!i[n.key][e]){const s=t(o)||o instanceof p?o:n.fromJS(o);i[n.key][e]=s,[i[n.key][e],c]=n.denormalize(s,r)}return[i[n.key][e],c]})(s,i,e,r,n):"function"==typeof i.denormalize?i.denormalize(s,e):[s,!0]},n]},b=e=>{const n=t(e);return(t,r)=>{const s=r.key;return"object"==typeof t?t:n?e.getIn([s,t]):e[s]&&e[s][t]}},O=(e,t,n,r,s,i)=>{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,O,s,i)}return r.normalize(e,t,n,O,s,i)};var g=Object.freeze({__proto__:null,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,s,i){return this.normalizeValue(e,t,n,r,s,i)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends r{normalize(e,t,n,r,s,i){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,s,i)}):t},{})}denormalize(e,t){let n=!0;return[Object.keys(e).reduce((r,s)=>{const i=e[s],[o,c]=this.denormalizeValue(i,t);return c||(n=!1),Object.assign({},r,{[s]:o})},{}),n]}},Array:class extends r{normalize(e,t,n,r,s,o){return i(e).map((e,i)=>this.normalizeValue(e,t,n,r,s,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]}},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)}}});e.Entity=f,e.FlatEntity=p,e.SimpleRecord=m,e.denormalize=(e,t,n)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("schema needed");if(void 0!==e){const[r,s]=y(n);return[...r(e,t),s]}return[void 0,!1,{}]},e.isEntity=d,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={},s={},i=((e,t)=>(n,r,s,i,o)=>{const c=n.key,a=n.pk(s,i,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,s);return{entities:r,indexes:s,result:O(e,e,void 0,t,i,{})}},e.schema=g,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).rest_hooks_normalizr={})}(this,(function(e){"use strict";function t(e){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,s)=>{const i=`${s}`,[o,c]=n(t.get(i),e[i]);return c||(r=!1),t.has(i)?t.set(i,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,s,i){const o=this.inferSchema(e,t,n);if(!o)return e;const c=r(e,t,n,o,s,i);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((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0]}}const s=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]),o=(e,t,n,r,o,c,a)=>(e=s(e),i(t).map((t,s)=>o(t,n,r,e,c,a))),c=(e,t,n)=>{e=s(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,s,i,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach(n=>{const r=e[n],a=s(t[n],t,n,r,i,o);null==a?delete c[n]:c[n]=a}),c},u=(e,r,s)=>{if(t(r))return n(e,r,s);const i=Object.assign({},r);let o=!0;return Object.keys(e).forEach(t=>{const[n,r]=s(i[t],e[t]);void 0!==i[t]&&(i[t]=n),r||(o=!1)}),[i,o]};const h=Symbol("Defined Members"),l=Symbol("unq");class m{toString(){return this[l]}static fromJS(e={},t,n){const r=new this(e);return Object.assign(r,e),Object.defineProperty(r,h,{value:Object.keys(e),writable:!1}),Object.defineProperty(r,l,{value:`${Math.random()}`,writable:!1}),r}static merge(e,t){const n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)}static hasDefined(e,t){return e[h].includes(t)}static toObjectDefined(e){const t={};for(const n of e[h])t[n]=e[n];return t}static keysDefined(e){return e[h]}static normalize(...e){return a(this.schema,...e)}static denormalize(...e){const[t,n]=u(this.schema,...e);return[this.fromJS(t),n]}static asSchema(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this}}m.schema={};class f extends m{static get key(){if("production"!==process.env.NODE_ENV&&""===this.name)throw new Error("Entity classes without a name must define `static get key()`");return this.name}static pk(e,t,n){return this.prototype.pk.call(e,t,n)||n}static normalize(e,t,n,r,s,i){const o=this.fromJS(e,t,n);if("production"!==process.env.NODE_ENV){const e=new this,t=new Set(Object.keys(e)),n=this.keysDefined(o),[r,s,i]=[[],[],[]];for(const e of n)t.has(e)?r.push(e):i.push(e);for(const e of t)r.includes(e)||s.push(e);if((Math.max(n.length/2,1)<=i.length&&t.size>Math.max(i.length,2)||r.length<Math.min(1,t.size/2))&&t.size){const e=new Error(`Attempted to initialize ${this.name} with substantially different than expected keys\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Expected keys:\n Found: ${r}\n Missing: ${s}\n Unexpected keys: ${i}\n Value: ${JSON.stringify(this.toObjectDefined(o),null,2)}`);throw e.status=400,e}}const c=o.pk(t,n);if(void 0===c||""===c){if("production"!==process.env.NODE_ENV){const t=new Error(`Missing usable resource key when normalizing response.\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n\n Entity: ${this.name}\n Value: ${e&&JSON.stringify(e,null,2)}\n `);throw t.status=400,t}return}const a=this.key;return a in i||(i[a]={}),c in i[a]||(i[a][c]=[]),i[a][c].some(t=>t===e)||(i[a][c].push(e),Object.keys(this.schema).forEach(e=>{if(Object.hasOwnProperty.call(o,e)&&"object"==typeof o[e]){const t=this.schema[e];o[e]=r(o[e],o,e,t,s,i)}}),s(this,o,o,t,n)),c}static denormalize(e,r){if(t(e)){const[t,s]=n(this.schema,e,r);return[this.fromJS(t.toObject()),s]}let s=!0;const i=e;return Object.keys(this.schema).forEach(t=>{const n=this.schema[t],[o,c]=r(e[t],n);c||(s=!1),this.hasDefined(e,t)&&i[t]!==o&&(i[t]=o)}),[i,s]}}function d(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(f.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return m.fromJS.call(this,e)});class p extends f{static denormalize(e,t){return[e,!0]}}const y=e=>{const n={},r=b(e);return[function e(s,i){if(!i)return[s,!0];if("object"==typeof i&&(!i.denormalize||"function"!=typeof i.denormalize)){return(Array.isArray(i)?c:u)(i,s,e)}return null===s?[s,!0]:d(i)?void 0===s?[s,!1]:((e,n,r,s,i)=>{const o=s(e,n);if("object"!=typeof o||null===o)return[o,!1];i[n.key]||(i[n.key]={});let c=!0;if(!i[n.key][e]){const s=t(o)||o instanceof p?o:n.fromJS(o);i[n.key][e]=s,[i[n.key][e],c]=n.denormalize(s,r)}return[i[n.key][e],c]})(s,i,e,r,n):"function"==typeof i.denormalize?i.denormalize(s,e):[s,!0]},n]},b=e=>{const n=t(e);return(t,r)=>{const s=r.key;return"object"==typeof t?t:n?e.getIn([s,t]):e[s]&&e[s][t]}},O=(e,t,n,r,s,i)=>{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,O,s,i)}return r.normalize(e,t,n,O,s,i)};var g=Object.freeze({__proto__:null,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,s,i){return this.normalizeValue(e,t,n,r,s,i)}denormalize(e,t){return this.denormalizeValue(e,t)}},Values:class extends r{normalize(e,t,n,r,s,i){return Object.keys(e).reduce((t,n,o)=>{const c=e[n];return null!=c?Object.assign(Object.assign({},t),{},{[n]:this.normalizeValue(c,e,n,r,s,i)}):t},{})}denormalize(e,t){let n=!0;return[Object.keys(e).reduce((r,s)=>{const i=e[s],[o,c]=this.denormalizeValue(i,t);return c||(n=!1),Object.assign(Object.assign({},r),{},{[s]:o})},{}),n]}},Array:class extends r{normalize(e,t,n,r,s,o){return i(e).map((e,i)=>this.normalizeValue(e,t,n,r,s,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]}},Object:class{constructor(e){this.define(e)}define(e){this.schema=Object.keys(e).reduce((t,n)=>{const r=e[n];return Object.assign(Object.assign({},t),{},{[n]:r})},this.schema||{})}normalize(...e){return a(this.schema,...e)}denormalize(...e){return u(this.schema,...e)}}});e.Entity=f,e.FlatEntity=p,e.SimpleRecord=m,e.denormalize=(e,t,n)=>{if("production"!==process.env.NODE_ENV&&void 0===t)throw new Error("schema needed");if(void 0!==e){const[r,s]=y(n);return[...r(e,t),s]}return[void 0,!1,{}]},e.isEntity=d,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={},s={},i=((e,t)=>(n,r,s,i,o)=>{const c=n.key,a=n.pk(s,i,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,s);return{entities:r,indexes:s,result:O(e,e,void 0,t,i,{})}},e.schema=g,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -45,2 +45,3 @@ import { Schema, AbstractInstanceType } from './types';

readonly key: string;
merge(a: any, b: any): any;
prototype: T;

@@ -47,0 +48,0 @@ }

{
"name": "@rest-hooks/normalizr",
"version": "6.0.0-beta.4",
"version": "6.0.0-beta.5",
"description": "Normalizes and denormalizes JSON according to schema for Redux and Flux applications",

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

},
"gitHead": "67ced603250ef2615be0ea985089b39f82e51707"
"gitHead": "3dfb110ce5a37dd836d1b1d0fab6a0299a780a0e"
}
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