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

@rest-hooks/normalizr

Package Overview
Dependencies
Maintainers
2
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 8.2.8 to 8.2.9

ts3.4/denormalize.d.ts

13

CHANGELOG.md

@@ -6,3 +6,3 @@ # Change Log

### [8.2.8](https://github.com/coinbase/rest-hooks/compare/@rest-hooks/normalizr@8.2.7...@rest-hooks/normalizr@8.2.8) (2022-07-01)
### [8.2.9](https://github.com/coinbase/rest-hooks/compare/@rest-hooks/normalizr@8.2.6...@rest-hooks/normalizr@8.2.9) (2022-07-20)

@@ -12,15 +12,6 @@

* Normalizr exports ([7bfb663](https://github.com/coinbase/rest-hooks/commit/7bfb663024f6dce85291dcc66d19c35b3cfaf830))
* Fix package exports support for latest resolve pkg ([#2062](https://github.com/coinbase/rest-hooks/issues/2062)) ([0088494](https://github.com/coinbase/rest-hooks/commit/0088494e5cab91da7becebe7d9b62796fb9f4f2e))
### [8.2.7](https://github.com/coinbase/rest-hooks/compare/@rest-hooks/normalizr@8.2.6...@rest-hooks/normalizr@8.2.7) (2022-07-01)
### 🐛 Bug Fix
* Fix package exports support for latest resolve pkg ([4263506](https://github.com/coinbase/rest-hooks/commit/426350653b17235f9e92159db0946660a00a03f6))
### [8.2.6](https://github.com/coinbase/rest-hooks/compare/@rest-hooks/normalizr@8.2.5...@rest-hooks/normalizr@8.2.6) (2022-05-30)

@@ -27,0 +18,0 @@

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

function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function t(e,t){return e(t={exports:{}},t.exports),t.exports}var n=t((function(e){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports}));e(n);var r=t((function(e){e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}));e(r);var o=e(t((function(e){e.exports=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=r(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}))),i=e(t((function(e){function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports})));function s(e){return!("function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function a(e,t,n){var r=!0,o=!1;return[Object.keys(e).reduce((function(t,i){var s=""+i,a=n(t.get(s),e[s]),u=a[0],c=a[1],f=a[2];return c||(r=!1),f&&(o=!0),t.has(s)?t.set(s,u):t}),t),r,o]}var u=function(){function e(){}return e.toJSON=function(){return{name:this.name,schema:this.schema,key:this.key}},e.pk=function(e,t,n){return this.prototype.pk.call(e,t,n)},e.useIncoming=function(e,t,n,r){return e.fetchedAt<=t.fetchedAt},e.merge=function(e,t){return Object.assign({},e,t)},e.fromJS=function(e){void 0===e&&(e={});var t=new this(e);return Object.assign(t,e),t},e.process=function(e){function t(t,n,r){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e,t,n){if("production"!==process.env.NODE_ENV&&"silent"!==this.automaticValidation&&Array.isArray(e)){var r="Attempted to initialize "+this.name+" with an array, but named members were expected\n\nThis is likely due to a malformed response.\nTry inspecting the network response or fetch() return value.\nOr use debugging tools: https://resthooks.io/docs/guides/debugging\nLearn more about schemas: https://resthooks.io/docs/api/schema\nIf this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\nFirst three members: "+JSON.stringify(e.slice(0,3),null,2);if("warn"!==this.automaticValidation){var o=new Error(r);throw o.status=400,o}console.warn(r)}return Object.assign({},e)})),e.normalize=function(e,t,n,r,o,i){var s=this,a=this.process(e,t,n),u=this.pk(a,t,n);if(void 0!==u&&""!==u){var c=this.key;if(c in i||(i[c]={}),u in i[c]||(i[c][u]=[]),i[c][u].some((function(t){return t===e})))return u;var f=this.validate(a);if(f){var l=new Error(f);throw l.status=400,l}return i[c][u].push(e),Object.keys(this.schema).forEach((function(e){if(Object.prototype.hasOwnProperty.call(a,e)){var t=s.schema[e];a[e]=r(a[e],a,e,t,o,i)}})),o(this,a,u),u}if("production"!==process.env.NODE_ENV){var p=new Error("Missing usable primary 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 Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Entity: "+this.name+"\n Value (processed): "+(a&&JSON.stringify(a,null,2))+"\n ");throw p.status=400,p}},e.validate=function(e){if("production"!==process.env.NODE_ENV&&"silent"!==this.automaticValidation){for(var t=new Set(Object.keys(this.defaults)),n=Object.keys(e),r=[],i=[],s=[],a=0,u=n;a<u.length;a++){var c=u[a];t.has(c)?r.push(c):s.push(c)}for(var f,l=o(t);!(f=l()).done;){var p=f.value;r.includes(p)||i.push(p)}if(t.size){var h=Math.max(n.length/2,1)<=s.length&&t.size>Math.max(s.length,2)&&Math.pow(r.length,1.5)/2<=s.length,d=r.length<Math.min(1,t.size/2);if(h||d){var y="",m="substantially different than expected keys";d&&(y+="\n Missing: "+i,m="no matching keys found"),h&&(y+="\n Unexpected keys: "+s,m="a large number of unexpected keys found");var v="Attempted to initialize "+this.name+" with "+m+"\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n If this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\n Expected keys:\n Found: "+r+y+"\n Value (processed): "+JSON.stringify(e,null,2);if(!(r.length>=4&&h||"warn"===this.automaticValidation))return v;console.warn(v)}}}if("production"!==process.env.NODE_ENV)for(var g=0,b=Object.keys(this.schema);g<b.length;g++){var O=b[g];if(!Object.prototype.hasOwnProperty.call(e,O)&&!Object.prototype.hasOwnProperty.call(this.defaults,O))return"Schema key is missing in Entity\n\n Be sure all schema members are also part of the entity\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about nesting schemas: https://resthooks.io/docs/guides/nested-response\n\n Entity keys: "+Object.keys(this.defaults)+"\n Schema key(missing): "+O+"\n "}},e.infer=function(e,t,n){if(e[0]){var r=this.pk(e[0],void 0,"");if(void 0!==r&&""!==r)return r;var o=function(e,t){return t?t.find((function(t){return Object.prototype.hasOwnProperty.call(e,t)})):void 0}(e[0],this.indexes);if(o&&t[this.key])return t[this.key][o][e[0][o]]}},e.expiresAt=function(e,t){return e.expiresAt},e.denormalize=function(e,t){var n=this;if(s(e)){if(this.validate(e.toJS()))return[void 0,!1,!0];null==t.setLocal||t.setLocal(e);var r=a(this.schema,e,t),o=r[0],i=r[1],u=r[2];return[this.fromJS(o.toObject()),i,u]}if(this.validate(e))return[void 0,!1,!0];var c=this.fromJS(e);null==t.setLocal||t.setLocal(c);var f=!1;return Object.keys(this.schema).forEach((function(r){var o=n.schema[r],i=Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0,s=t(i,o),a=s[0];!s[2]||Object.prototype.hasOwnProperty.call(e,r)&&!n.defaults[r]||(f=!0),Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==a&&n.set(c,r,a)})),[c,!0,f]},e.set=function(e,t,n){e[t]=n},i(e,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name||"_temp"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}},{key:"defaults",get:function(){return Object.prototype.hasOwnProperty.call(this,"__defaults")||(this.__defaults=new this),this.__defaults}}]),e}();if(u.schema={},"production"!==process.env.NODE_ENV){var c=u.fromJS;u.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return c.call(this,e)}}function f(e){return null!==e&&void 0!==e.pk}var l=Symbol("ENTITY WAS DELETED"),p=t((function(e){function t(n,r){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}));e(p);var h=e(t((function(e){e.exports=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,p(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports}))),d=t((function(e){function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}));e(d);var y=t((function(e){e.exports=function(e){return-1!==Function.toString.call(e).indexOf("[native code]")},e.exports.__esModule=!0,e.exports.default=e.exports}));e(y);var m=t((function(e){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}},e.exports.__esModule=!0,e.exports.default=e.exports}));e(m);var v=t((function(e){function t(n,r,o){return m()?(e.exports=t=Reflect.construct.bind(),e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=t=function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&p(o,n.prototype),o},e.exports.__esModule=!0,e.exports.default=e.exports),t.apply(null,arguments)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}));e(v);var g=e(t((function(e){function t(n){var r="function"==typeof Map?new Map:void 0;return e.exports=t=function(e){if(null===e||!y(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return v(e,arguments,d(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),p(t,e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}))),b=function(){this.children=new WeakMap},O=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return(t=e.call.apply(e,[this].concat(r))||this).message="Keys must include at least one member",t}return h(t,e),t}(g(Error)),x=function(){function e(){this.first=new WeakMap}var t=e.prototype;return t.delete=function(e){var t=this.traverse(e);return null==t||delete t.value,!!t},t.get=function(e){var t=this.traverse(e);return null==t?void 0:t.value},t.has=function(e){var t=this.traverse(e);return!!t&&Object.prototype.hasOwnProperty.call(t,"value")},t.set=function(e,t){if(e.length<1)throw new O;for(var n,r=this.first,o=0;o<e.length;o++)r.has(e[o])?n=r.get(e[o]):(n=new b,r.set(e[o],n)),r=n.children,o===e.length-1&&(n.value=t);return this},t.traverse=function(e){for(var t,n=this.first,r=0;r<e.length;r++){if(!(t=n.get(e[r])))return;n=t.children}return t},e}(),k=function(){function e(e,t){this.schema=void 0,t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=e},t.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},t.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},t.normalizeValue=function(e,t,n,r,o,i){var s=this.inferSchema(e,t,n);if(!s){if("production"!==process.env.NODE_ENV){var a=this.getSchemaAttribute(e,t,n);console.warn("Schema attribute "+JSON.stringify(a,void 0,2)+" is not expected.\nExpected one of: "+Object.keys(this.schema).map((function(e){return'"'+e+'"'})).join(", ")+"\n\nValue: "+JSON.stringify(e,void 0,2))}return e}var u=r(e,t,n,s,o,i);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,t,n)}},t.denormalizeValue=function(e,t){var n=s(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?t((this.isSingleSchema?void 0:s(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[n]):("production"!==process.env.NODE_ENV&&console.warn("TypeError: Unable to infer schema for "+this.constructor.name+"\nValue: "+JSON.stringify(e,void 0,2)+"."),[e,!0,!1])},i(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),w=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},_=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},j=function(e){var t=e[0],n=e[2];return void 0!==t&&!n},E=function(e,t,n,r,o,i,s){return e=w(e),_(t).map((function(t,a){return o(t,n,r,e,i,s)}))},S=function(e,t,n){return e=w(e),[t.map?t.map((function(t){return n(t,e)})).filter(j).map((function(e){return e[0]})):t,!0,!1]};function A(e,t,n,r){}var N=function(e){function t(){return e.apply(this,arguments)||this}h(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,o,i){var s=this;return _(e).map((function(e,a){return s.normalizeValue(e,t,n,r,o,i)})).filter((function(e){return null!=e}))},n.denormalize=function(e,t){var n=this;return[e.map?e.map((function(e){return n.denormalizeValue(e,t)})).filter(j).map((function(e){return e[0]})):e,!0,!1]},n.infer=function(e,t,n){this.schema},t}(k),z=function(e,t,n,r,o,i,s){var a=Object.assign({},t);return Object.keys(e).forEach((function(n){var r=e[n],u=o(t[n],t,n,r,i,s);null==u?delete a[n]:a[n]=u})),a},M=function(e,t,n){if(s(t))return a(e,t,n);var r=Object.assign({},t),o=!0,i=!1;return Object.keys(e).forEach((function(t){var s=n(r[t],e[t]),a=s[0],u=s[1],c=s[2];void 0!==r[t]&&(r[t]=a),c&&(i=!0),u||(o=!1)})),[r,o,i]};function V(e,t,n,r){for(var o={},i=0,s=Object.keys(e);i<s.length;i++){var a=s[i];o[a]=r(e[a],t,n)}return o}var D=function(){function e(e){this.schema=void 0,this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var r,o=e[n];return Object.assign({},t,((r={})[n]=o,r))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return z.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return M.apply(void 0,[this.schema].concat(t))},t.infer=function(e,t,n){return V(this.schema,e,t,n)},e}(),P=Symbol("draft"),J=function(e,t,n,r,o,i,a,u){var c=r(e,t);if(c===l)return[void 0,!0,!0];if("production"!==process.env.NODE_ENV&&"symbol"==typeof c&&c.toString().includes("DELETED"))throw new Error("Unrecognized symbol detected.\nMake sure you do not have multiple versions of @rest-hooks/normalizr installed.");if("object"!=typeof c||null===c)return[c,!1,!1];var f="string"==typeof e?e:t.pk(s(c)?c.toJS():c);if(void 0===f||""===f)return[c,!1,!1];void 0===o[t.key]&&(o[t.key]=Object.create(null));var p=!0,h=!1;if(o[t.key][f]){if(Object.prototype.hasOwnProperty.call(o[t.key][f],P))return u.i=o[t.key][f].i,[o[t.key][f][P],p,h];a.push(c)}else{var d=a.length;a.push(c);var y=function(e){var t=e.og||e,n=function(e,n){return t(e,n)};return n.og=e,n}(n);y.setLocal=function(e){var n;return o[t.key][f]=((n={})[P]=e,n.i=d,n)};var m=function(e,t,n){e[t.key]||(e[t.key]={});e[t.key][n]||(e[t.key][n]=new x);return e[t.key][n]}(i,t,f),v=t.denormalize(c,y);o[t.key][f]=v[0],p=v[1],h=v[2];var g=a.slice(-1===u.i?d:u.i);m.has(g)?o[t.key][f]=m.get(g):m.set(g,o[t.key][f]),u.i===d&&(u.i=-1)}return[o[t.key][f],p,h]},I=function(e){var t=s(e);return function(n,r){var o,i=r.key;return"object"==typeof n?n:t?e.getIn([i,n]):null==(o=e[i])?void 0:o[n]}},T=function(e,t,n,r,o){if(void 0===r&&(r={}),void 0===o&&(o=new x),void 0===t)return[e,!0,!1,{}];if(void 0===e)return[void 0,!1,!1,{}];var i={},s=function(e,t,n,r){var o=I(e),i=[],s={i:-1};function a(e,n){if(!n)return[e,!0,!1];if(null===e)return[e,!0,!1];var u="function"==typeof n.denormalize;return u||"function"!=typeof n?void 0===e?[e,!1,!1]:u||"object"!=typeof n?f(n)?J(e,n,a,o,r,t,i,s):u?n.denormalize(e,a):[e,!0,!1]:(Array.isArray(n)?S:M)(n,e,a):e instanceof n||void 0===e?[e,!0,!1]:[new n(e),!0,!1]}return function(e,t){var r=a(e,t);return Object(e)!==e?r:(i.push(e),n.has(i)?[n.get(i),r[1],r[2]]:(n.set(i,r[0]),r))}}(n,r,o,i);return[].concat(s(e,t),[i])};var L=function e(t,n,r,o,i,s){return t&&o?o.normalize&&"function"==typeof o.normalize?"object"!=typeof t?t:o.normalize(t,n,r,e,i,s):"function"==typeof o?new o(t):"object"!=typeof t||"object"!=typeof o?t:(Array.isArray(o)?E:z)(o,t,n,r,e,i,s):t};var U=function(e,t,n,r,i,s){if(void 0===n&&(n={}),void 0===r&&(r={}),void 0===i&&(i={}),void 0===s&&(s={date:Date.now(),expiresAt:1/0,fetchedAt:0}),void 0===t)return{entities:n,indexes:r,result:e,entityMeta:i};var a=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==a&&(void 0===t.key||"string"!=typeof e)){if("production"!==process.env.NODE_ENV){throw"string"==typeof e&&function(e){try{return"string"!=typeof JSON.parse(e)}catch(e){return!1}}(e)?new Error('Normalizing a string, but this does match schema.\n\nParsing this input string as JSON worked. This likely indicates fetch function did not parse\nthe JSON. By default, this only happens if "content-type" header includes "json".\nSee https://resthooks.io/docs/guides/custom-networking for more information\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"'):new Error('Unexpected input given to normalize. Expected type to be "'+a+'", found "'+(null===e?"null":typeof e)+'".\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"')}throw new Error('Unexpected input given to normalize. Expected type to be "'+a+'", found "'+(null===e?"null":typeof e)+'".')}var u=Object.assign({},n),c=Object.assign({},r),f=Object.assign({},i),p=function(e,t,n,r,i,s){return function(a,u,c){var f=a.key;f in e||(e[f]={},n[f]=Object.assign({},n[f]),i[f]=Object.assign({},i[f]));var p=e[f][c];if(p)e[f][c]=a.merge(p,u);else{var h=a.expiresAt?a.expiresAt(s,u):s.expiresAt,d=n[f][c];if(d){var y,m,v,g,b,O,x=i[f][c],k=!x||(a.useIncoming&&s.fetchedAt?a.useIncoming(x,s,d,u):i[f][c].date<=s.date);e[f][c]=k?typeof u!=typeof d?u:a.merge(d,u):d,i[f][c]={expiresAt:Math.max(h,null==(y=i[f][c])?void 0:y.expiresAt),date:Math.max(s.date,null!=(m=null==(v=i[f][c])?void 0:v.date)?m:0),fetchedAt:Math.max(null!=(g=s.fetchedAt)?g:0,null!=(b=null==(O=i[f][c])?void 0:O.fetchedAt)?b:0)}}else{var w;e[f][c]=u,i[f][c]={expiresAt:h,date:s.date,fetchedAt:null!=(w=s.fetchedAt)?w:s.date}}}if(Array.isArray(a.indexes)){var _=e[f][c];f in t||(t[f]={},r[f]=Object.assign({},r[f]));for(var j,E=o(a.indexes);!(j=E()).done;){var S=j.value;S in t[f]||(r[f][S]=t[f][S]={});var A=t[f][S];p&&delete A[p[S]],n[f]&&n[f][c]&&n[f][c][S]!==_[S]&&(A[n[f][c][S]]=l),S in _?A[_[S]]=c:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+S+"\nEntity: "+JSON.stringify(_,void 0,2))}}n[f][c]=e[f][c]}}({},{},u,c,f,s);return{entities:u,indexes:c,result:L(e,e,void 0,t,p,{}),entityMeta:f}},R=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}h(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,o,i){return this.normalizeValue(e,t,n,r,o,i)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},n.infer=function(e,t,n){if(e[0]){var r=this.getSchemaAttribute(e[0],void 0,""),o=this.schema[r];if(void 0!==o)return{id:n(o,e,t),schema:r}}},t}(k),B=function(e){function t(){return e.apply(this,arguments)||this}h(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,o,i){var s=this;return Object.keys(e).reduce((function(t,n,a){var u,c=e[n];return null!=c?Object.assign({},t,((u={})[n]=s.normalizeValue(c,e,n,r,o,i),u)):t}),{})},n.denormalize=function(e,t){var n=this,r=!0,o=!1;return[Object.keys(e).reduce((function(i,s){var a,u=e[s],c=n.denormalizeValue(u,t),f=c[0],l=c[1],p=c[2];return l||(r=!1),p&&(o=!0),!l||p?i:Object.assign({},i,((a={})[s]=f,a))}),{}),r,o]},n.infer=function(e,t,n){},t}(k),F=function(){function e(e){if("production"!==process.env.NODE_ENV&&!e)throw new Error('Expected option "entity" not found on DeleteSchema.');this._entity=e}var t=e.prototype;return t.normalize=function(e,t,n,r,o,i){var s=this._entity.process(e,t,n),a=this._entity.pk(s,t,n);if("production"!==process.env.NODE_ENV&&(void 0===a||""===a)){var u,c=new Error("Missing usable primary 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 Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Delete(Entity): Delete("+(null!=(u=this._entity.name)?u:this._entity)+")\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw c.status=400,c}return o(this,l,a),a},t.infer=function(e,t,n){},t.denormalize=function(e,t){return t(e,this._entity)},t._denormalizeNullable=function(){return[]},t._normalizeNullable=function(){return[]},t.merge=function(e,t){return t},t.useIncoming=function(e,t,n,r){return e.date<=t.date},i(e,[{key:"key",get:function(){return this._entity.key}}]),e}(),W=Object.freeze({__proto__:null,Union:R,Values:B,Array:N,Object:D,Delete:F});function C(e,t,n){return function(e){return!!e&&"function"==typeof e.infer}(e)?e.infer(t,n,C):"object"==typeof e&&e?(Array.isArray(e)?A:V)(e,t,n,C):e}export{l as DELETED,u as Entity,x as WeakListMap,T as denormalize,C as inferResults,f as isEntity,U as normalize,W as schema};
function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function t(e,t){return e(t={exports:{}},t.exports),t.exports}var n=t((function(e){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports}));e(n);var r=t((function(e){e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}));e(r);var o=e(t((function(e){e.exports=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=r(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}))),i=e(t((function(e){function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports})));function s(e){return!("function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function a(e,t,n){var r=!0,o=!1;return[Object.keys(e).reduce((function(t,i){var s=""+i,a=n(t.get(s),e[s]),u=a[0],c=a[1],f=a[2];return c||(r=!1),f&&(o=!0),t.has(s)?t.set(s,u):t}),t),r,o]}var u=function(){function e(){}return e.toJSON=function(){return{name:this.name,schema:this.schema,key:this.key}},e.pk=function(e,t,n){return this.prototype.pk.call(e,t,n)},e.useIncoming=function(e,t,n,r){return e.fetchedAt<=t.fetchedAt},e.merge=function(e,t){return Object.assign({},e,t)},e.fromJS=function(e){void 0===e&&(e={});var t=new this(e);return Object.assign(t,e),t},e.process=function(e){function t(t,n,r){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e,t,n){if("production"!==process.env.NODE_ENV&&"silent"!==this.automaticValidation&&Array.isArray(e)){var r="Attempted to initialize "+this.name+" with an array, but named members were expected\n\nThis is likely due to a malformed response.\nTry inspecting the network response or fetch() return value.\nOr use debugging tools: https://resthooks.io/docs/guides/debugging\nLearn more about schemas: https://resthooks.io/docs/api/schema\nIf this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\nFirst three members: "+JSON.stringify(e.slice(0,3),null,2);if("warn"!==this.automaticValidation){var o=new Error(r);throw o.status=400,o}console.warn(r)}return Object.assign({},e)})),e.normalize=function(e,t,n,r,o,i){var s=this,a=this.process(e,t,n),u=this.pk(a,t,n);if(void 0!==u&&""!==u){var c=this.key;if(c in i||(i[c]={}),u in i[c]||(i[c][u]=[]),i[c][u].some((function(t){return t===e})))return u;var f=this.validate(a);if(f){var l=new Error(f);throw l.status=400,l}return i[c][u].push(e),Object.keys(this.schema).forEach((function(e){if(Object.prototype.hasOwnProperty.call(a,e)){var t=s.schema[e];a[e]=r(a[e],a,e,t,o,i)}})),o(this,a,u),u}if("production"!==process.env.NODE_ENV){var p=new Error("Missing usable primary 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 Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Entity: "+this.name+"\n Value (processed): "+(a&&JSON.stringify(a,null,2))+"\n ");throw p.status=400,p}},e.validate=function(e){if("production"!==process.env.NODE_ENV&&"silent"!==this.automaticValidation){for(var t=new Set(Object.keys(this.defaults)),n=Object.keys(e),r=[],i=[],s=[],a=0,u=n;a<u.length;a++){var c=u[a];t.has(c)?r.push(c):s.push(c)}for(var f,l=o(t);!(f=l()).done;){var p=f.value;r.includes(p)||i.push(p)}if(t.size){var h=Math.max(n.length/2,1)<=s.length&&t.size>Math.max(s.length,2)&&Math.pow(r.length,1.5)/2<=s.length,d=r.length<Math.min(1,t.size/2);if(h||d){var y="",m="substantially different than expected keys";d&&(y+="\n Missing: "+i,m="no matching keys found"),h&&(y+="\n Unexpected keys: "+s,m="a large number of unexpected keys found");var v="Attempted to initialize "+this.name+" with "+m+"\n\n This is likely due to a malformed response.\n Try inspecting the network response or fetch() return value.\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n If this is a mistake, you can disable this check by setting static automaticValidation = 'silent'\n\n Expected keys:\n Found: "+r+y+"\n Value (processed): "+JSON.stringify(e,null,2);if(!(r.length>=4&&h||"warn"===this.automaticValidation))return v;console.warn(v)}}}if("production"!==process.env.NODE_ENV)for(var g=0,b=Object.keys(this.schema);g<b.length;g++){var O=b[g];if(!Object.prototype.hasOwnProperty.call(e,O)&&!Object.prototype.hasOwnProperty.call(this.defaults,O))return"Schema key is missing in Entity\n\n Be sure all schema members are also part of the entity\n Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about nesting schemas: https://resthooks.io/docs/guides/nested-response\n\n Entity keys: "+Object.keys(this.defaults)+"\n Schema key(missing): "+O+"\n "}},e.infer=function(e,t,n){if(e[0]){var r=this.pk(e[0],void 0,"");if(void 0!==r&&""!==r)return r;var o=function(e,t){return t?t.find((function(t){return Object.prototype.hasOwnProperty.call(e,t)})):void 0}(e[0],this.indexes);if(o&&t[this.key])return t[this.key][o][e[0][o]]}},e.expiresAt=function(e,t){return e.expiresAt},e.denormalize=function(e,t){var n=this;if(s(e)){if(this.validate(e.toJS()))return[void 0,!1,!0];null==t.setLocal||t.setLocal(e);var r=a(this.schema,e,t),o=r[0],i=r[1],u=r[2];return[this.fromJS(o.toObject()),i,u]}if(this.validate(e))return[void 0,!1,!0];var c=this.fromJS(e);null==t.setLocal||t.setLocal(c);var f=!1;return Object.keys(this.schema).forEach((function(r){var o=n.schema[r],i=Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0,s=t(i,o),a=s[0];!s[2]||Object.prototype.hasOwnProperty.call(e,r)&&!n.defaults[r]||(f=!0),Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==a&&n.set(c,r,a)})),[c,!0,f]},e.set=function(e,t,n){e[t]=n},i(e,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name||"_temp"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}},{key:"defaults",get:function(){return Object.prototype.hasOwnProperty.call(this,"__defaults")||(this.__defaults=new this),this.__defaults}}]),e}();if(u.schema={},"production"!==process.env.NODE_ENV){var c=u.fromJS;u.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return c.call(this,e)}}function f(e){return null!==e&&void 0!==e.pk}var l=Symbol("ENTITY WAS DELETED"),p=t((function(e){function t(n,r){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}));e(p);var h=e(t((function(e){e.exports=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,p(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports}))),d=t((function(e){function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}));e(d);var y=t((function(e){e.exports=function(e){return-1!==Function.toString.call(e).indexOf("[native code]")},e.exports.__esModule=!0,e.exports.default=e.exports}));e(y);var m=t((function(e){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}},e.exports.__esModule=!0,e.exports.default=e.exports}));e(m);var v=t((function(e){function t(n,r,o){return m()?(e.exports=t=Reflect.construct.bind(),e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=t=function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&p(o,n.prototype),o},e.exports.__esModule=!0,e.exports.default=e.exports),t.apply(null,arguments)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}));e(v);var g=t((function(e){function t(n){var r="function"==typeof Map?new Map:void 0;return e.exports=t=function(e){if(null===e||!y(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return v(e,arguments,d(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),p(t,e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})),b=e(g),O=function(){this.children=new WeakMap},x=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return(t=e.call.apply(e,[this].concat(r))||this).message="Keys must include at least one member",t}return h(t,e),t}(b(Error)),k=function(){function e(){this.first=new WeakMap}var t=e.prototype;return t.delete=function(e){var t=this.traverse(e);return null==t||delete t.value,!!t},t.get=function(e){var t=this.traverse(e);return null==t?void 0:t.value},t.has=function(e){var t=this.traverse(e);return!!t&&Object.prototype.hasOwnProperty.call(t,"value")},t.set=function(e,t){if(e.length<1)throw new x;for(var n,r=this.first,o=0;o<e.length;o++)r.has(e[o])?n=r.get(e[o]):(n=new O,r.set(e[o],n)),r=n.children,o===e.length-1&&(n.value=t);return this},t.traverse=function(e){for(var t,n=this.first,r=0;r<e.length;r++){if(!(t=n.get(e[r])))return;n=t.children}return t},e}(),w=function(){function e(e,t){this.schema=void 0,t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=e},t.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},t.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},t.normalizeValue=function(e,t,n,r,o,i){var s=this.inferSchema(e,t,n);if(!s){if("production"!==process.env.NODE_ENV){var a=this.getSchemaAttribute(e,t,n);console.warn("Schema attribute "+JSON.stringify(a,void 0,2)+" is not expected.\nExpected one of: "+Object.keys(this.schema).map((function(e){return'"'+e+'"'})).join(", ")+"\n\nValue: "+JSON.stringify(e,void 0,2))}return e}var u=r(e,t,n,s,o,i);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,t,n)}},t.denormalizeValue=function(e,t){var n=s(e)?e.get("schema"):e.schema;return this.isSingleSchema||n?t((this.isSingleSchema?void 0:s(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[n]):("production"!==process.env.NODE_ENV&&console.warn("TypeError: Unable to infer schema for "+this.constructor.name+"\nValue: "+JSON.stringify(e,void 0,2)+"."),[e,!0,!1])},i(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),_=function(e){if(Array.isArray(e)&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},j=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},E=function(e){var t=e[0],n=e[2];return void 0!==t&&!n},S=function(e,t,n,r,o,i,s){return e=_(e),j(t).map((function(t,a){return o(t,n,r,e,i,s)}))},A=function(e,t,n){return e=_(e),[t.map?t.map((function(t){return n(t,e)})).filter(E).map((function(e){return e[0]})):t,!0,!1]};function N(e,t,n,r){}var z=function(e){function t(){return e.apply(this,arguments)||this}h(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,o,i){var s=this;return j(e).map((function(e,a){return s.normalizeValue(e,t,n,r,o,i)})).filter((function(e){return null!=e}))},n.denormalize=function(e,t){var n=this;return[e.map?e.map((function(e){return n.denormalizeValue(e,t)})).filter(E).map((function(e){return e[0]})):e,!0,!1]},n.infer=function(e,t,n){this.schema},t}(w),M=function(e,t,n,r,o,i,s){var a=Object.assign({},t);return Object.keys(e).forEach((function(n){var r=e[n],u=o(t[n],t,n,r,i,s);null==u?delete a[n]:a[n]=u})),a},V=function(e,t,n){if(s(t))return a(e,t,n);var r=Object.assign({},t),o=!0,i=!1;return Object.keys(e).forEach((function(t){var s=n(r[t],e[t]),a=s[0],u=s[1],c=s[2];void 0!==r[t]&&(r[t]=a),c&&(i=!0),u||(o=!1)})),[r,o,i]};function D(e,t,n,r){for(var o={},i=0,s=Object.keys(e);i<s.length;i++){var a=s[i];o[a]=r(e[a],t,n)}return o}var P=function(){function e(e){this.schema=void 0,this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var r,o=e[n];return Object.assign({},t,((r={})[n]=o,r))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return M.apply(void 0,[this.schema].concat(t))},t.denormalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return V.apply(void 0,[this.schema].concat(t))},t.infer=function(e,t,n){return D(this.schema,e,t,n)},e}(),J=Symbol("draft"),I=function(e,t,n,r,o,i,a,u){var c=r(e,t);if(c===l)return[void 0,!0,!0];if("production"!==process.env.NODE_ENV&&"symbol"==typeof c&&c.toString().includes("DELETED"))throw new Error("Unrecognized symbol detected.\nMake sure you do not have multiple versions of @rest-hooks/normalizr installed.");if("object"!=typeof c||null===c)return[c,!1,!1];var f="string"==typeof e?e:t.pk(s(c)?c.toJS():c);if(void 0===f||""===f)return[c,!1,!1];void 0===o[t.key]&&(o[t.key]=Object.create(null));var p=!0,h=!1;if(o[t.key][f]){if(Object.prototype.hasOwnProperty.call(o[t.key][f],J))return u.i=o[t.key][f].i,[o[t.key][f][J],p,h];a.push(c)}else{var d=a.length;a.push(c);var y=function(e){var t=e.og||e,n=function(e,n){return t(e,n)};return n.og=e,n}(n);y.setLocal=function(e){var n;return o[t.key][f]=((n={})[J]=e,n.i=d,n)};var m=function(e,t,n){e[t.key]||(e[t.key]={});e[t.key][n]||(e[t.key][n]=new k);return e[t.key][n]}(i,t,f),v=t.denormalize(c,y);o[t.key][f]=v[0],p=v[1],h=v[2];var g=a.slice(-1===u.i?d:u.i);m.has(g)?o[t.key][f]=m.get(g):m.set(g,o[t.key][f]),u.i===d&&(u.i=-1)}return[o[t.key][f],p,h]},T=function(e){var t=s(e);return function(n,r){var o,i=r.key;return"object"==typeof n?n:t?e.getIn([i,n]):null==(o=e[i])?void 0:o[n]}},L=function(e,t,n,r,o){if(void 0===r&&(r={}),void 0===o&&(o=new k),void 0===t)return[e,!0,!1,{}];if(void 0===e)return[void 0,!1,!1,{}];var i={},s=function(e,t,n,r){var o=T(e),i=[],s={i:-1};function a(e,n){if(!n)return[e,!0,!1];if(null===e)return[e,!0,!1];var u="function"==typeof n.denormalize;return u||"function"!=typeof n?void 0===e?[e,!1,!1]:u||"object"!=typeof n?f(n)?I(e,n,a,o,r,t,i,s):u?n.denormalize(e,a):[e,!0,!1]:(Array.isArray(n)?A:V)(n,e,a):e instanceof n||void 0===e?[e,!0,!1]:[new n(e),!0,!1]}return function(e,t){var r=a(e,t);return Object(e)!==e?r:(i.push(e),n.has(i)?[n.get(i),r[1],r[2]]:(n.set(i,r[0]),r))}}(n,r,o,i);return[].concat(s(e,t),[i])};var U=function e(t,n,r,o,i,s){return t&&o?o.normalize&&"function"==typeof o.normalize?"object"!=typeof t?t:o.normalize(t,n,r,e,i,s):"function"==typeof o?new o(t):"object"!=typeof t||"object"!=typeof o?t:(Array.isArray(o)?S:M)(o,t,n,r,e,i,s):t};var R=function(e,t,n,r,i,s){if(void 0===n&&(n={}),void 0===r&&(r={}),void 0===i&&(i={}),void 0===s&&(s={date:Date.now(),expiresAt:1/0,fetchedAt:0}),void 0===t)return{entities:n,indexes:r,result:e,entityMeta:i};var a=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==a&&(void 0===t.key||"string"!=typeof e)){if("production"!==process.env.NODE_ENV){throw"string"==typeof e&&function(e){try{return"string"!=typeof JSON.parse(e)}catch(e){return!1}}(e)?new Error('Normalizing a string, but this does match schema.\n\nParsing this input string as JSON worked. This likely indicates fetch function did not parse\nthe JSON. By default, this only happens if "content-type" header includes "json".\nSee https://resthooks.io/docs/guides/custom-networking for more information\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"'):new Error('Unexpected input given to normalize. Expected type to be "'+a+'", found "'+(null===e?"null":typeof e)+'".\n\n Schema: '+JSON.stringify(t,void 0,2)+'\n Input: "'+e+'"')}throw new Error('Unexpected input given to normalize. Expected type to be "'+a+'", found "'+(null===e?"null":typeof e)+'".')}var u=Object.assign({},n),c=Object.assign({},r),f=Object.assign({},i),p=function(e,t,n,r,i,s){return function(a,u,c){var f=a.key;f in e||(e[f]={},n[f]=Object.assign({},n[f]),i[f]=Object.assign({},i[f]));var p=e[f][c];if(p)e[f][c]=a.merge(p,u);else{var h=a.expiresAt?a.expiresAt(s,u):s.expiresAt,d=n[f][c];if(d){var y,m,v,g,b,O,x=i[f][c],k=!x||(a.useIncoming&&s.fetchedAt?a.useIncoming(x,s,d,u):i[f][c].date<=s.date);e[f][c]=k?typeof u!=typeof d?u:a.merge(d,u):d,i[f][c]={expiresAt:Math.max(h,null==(y=i[f][c])?void 0:y.expiresAt),date:Math.max(s.date,null!=(m=null==(v=i[f][c])?void 0:v.date)?m:0),fetchedAt:Math.max(null!=(g=s.fetchedAt)?g:0,null!=(b=null==(O=i[f][c])?void 0:O.fetchedAt)?b:0)}}else{var w;e[f][c]=u,i[f][c]={expiresAt:h,date:s.date,fetchedAt:null!=(w=s.fetchedAt)?w:s.date}}}if(Array.isArray(a.indexes)){var _=e[f][c];f in t||(t[f]={},r[f]=Object.assign({},r[f]));for(var j,E=o(a.indexes);!(j=E()).done;){var S=j.value;S in t[f]||(r[f][S]=t[f][S]={});var A=t[f][S];p&&delete A[p[S]],n[f]&&n[f][c]&&n[f][c][S]!==_[S]&&(A[n[f][c][S]]=l),S in _?A[_[S]]=c:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+S+"\nEntity: "+JSON.stringify(_,void 0,2))}}n[f][c]=e[f][c]}}({},{},u,c,f,s);return{entities:u,indexes:c,result:U(e,e,void 0,t,p,{}),entityMeta:f}},B=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}h(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,o,i){return this.normalizeValue(e,t,n,r,o,i)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},n.infer=function(e,t,n){if(e[0]){var r=this.getSchemaAttribute(e[0],void 0,""),o=this.schema[r];if(void 0!==o)return{id:n(o,e,t),schema:r}}},t}(w),F=function(e){function t(){return e.apply(this,arguments)||this}h(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,o,i){var s=this;return Object.keys(e).reduce((function(t,n,a){var u,c=e[n];return null!=c?Object.assign({},t,((u={})[n]=s.normalizeValue(c,e,n,r,o,i),u)):t}),{})},n.denormalize=function(e,t){var n=this,r=!0,o=!1;return[Object.keys(e).reduce((function(i,s){var a,u=e[s],c=n.denormalizeValue(u,t),f=c[0],l=c[1],p=c[2];return l||(r=!1),p&&(o=!0),!l||p?i:Object.assign({},i,((a={})[s]=f,a))}),{}),r,o]},n.infer=function(e,t,n){},t}(w),W=function(){function e(e){if("production"!==process.env.NODE_ENV&&!e)throw new Error('Expected option "entity" not found on DeleteSchema.');this._entity=e}var t=e.prototype;return t.normalize=function(e,t,n,r,o,i){var s=this._entity.process(e,t,n),a=this._entity.pk(s,t,n);if("production"!==process.env.NODE_ENV&&(void 0===a||""===a)){var u,c=new Error("Missing usable primary 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 Or use debugging tools: https://resthooks.io/docs/guides/debugging\n Learn more about schemas: https://resthooks.io/docs/api/schema\n\n Delete(Entity): Delete("+(null!=(u=this._entity.name)?u:this._entity)+")\n Value: "+(e&&JSON.stringify(e,null,2))+"\n ");throw c.status=400,c}return o(this,l,a),a},t.infer=function(e,t,n){},t.denormalize=function(e,t){return t(e,this._entity)},t._denormalizeNullable=function(){return[]},t._normalizeNullable=function(){return[]},t.merge=function(e,t){return t},t.useIncoming=function(e,t,n,r){return e.date<=t.date},i(e,[{key:"key",get:function(){return this._entity.key}}]),e}(),C=Object.freeze({__proto__:null,Union:B,Values:F,Array:z,Object:P,Delete:W});function K(e,t,n){return function(e){return!!e&&"function"==typeof e.infer}(e)?e.infer(t,n,K):"object"==typeof e&&e?(Array.isArray(e)?N:D)(e,t,n,K):e}export{l as DELETED,u as Entity,k as WeakListMap,L as denormalize,K as inferResults,f as isEntity,R as normalize,C as schema};
{
"name": "@rest-hooks/normalizr",
"version": "8.2.8",
"version": "8.2.9",
"description": "Normalizes and denormalizes JSON according to schema for Redux and Flux applications",

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

},
"gitHead": "2e86aee48ce7e2b8fc006f719d79a96aa6584a2f"
"gitHead": "a34477ee514c1d705555dbe5338cca976df665aa"
}
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