@rest-hooks/normalizr
Advanced tools
Comparing version 6.0.0-k.0 to 6.0.0-rc.0
@@ -6,2 +6,18 @@ # Change Log | ||
## 6.0.0-rc.0 (2021-01-14) | ||
* enhance: Inferred endpoints expiry based on entities (#464) ([975e0d8](https://github.com/coinbase/rest-hooks/commit/975e0d8)), closes [#464](https://github.com/coinbase/rest-hooks/issues/464) | ||
* enhance: Maintain referential equality globally (#403) ([e1e353d](https://github.com/coinbase/rest-hooks/commit/e1e353d)), closes [#403](https://github.com/coinbase/rest-hooks/issues/403) | ||
* internal: add missing dev dep ([51fc222](https://github.com/coinbase/rest-hooks/commit/51fc222)) | ||
### BREAKING CHANGE | ||
* Node engine requirement of >=0.12 | ||
* useResource() inferred endpoint will sometimes | ||
not trigger a fetch if entities are fresh enough | ||
## 6.0.0-k.0 (2021-01-06) | ||
@@ -8,0 +24,0 @@ |
@@ -626,3 +626,3 @@ define(['exports'], function (exports) { 'use strict'; | ||
Entity.denormalize = function denormalize(entity, unvisit) { | ||
Entity.denormalize = function denormalize(input, unvisit) { | ||
var _this2 = this; | ||
@@ -632,4 +632,4 @@ | ||
// itself in cache. Once we offer full memoization, we will store raw objects and this can be consolidated with SimpleRecord | ||
if (isImmutable(entity)) { | ||
var _denormalizeImmutable = denormalizeImmutable(this.schema, entity, unvisit), | ||
if (isImmutable(input)) { | ||
var _denormalizeImmutable = denormalizeImmutable(this.schema, input, unvisit), | ||
_denormEntity = _denormalizeImmutable[0], | ||
@@ -646,8 +646,9 @@ _found = _denormalizeImmutable[1], | ||
var found = true; | ||
var denormEntity = entity; | ||
var denormEntity = input; // note: iteration order must be stable | ||
Object.keys(this.schema).forEach(function (key) { | ||
var schema = _this2.schema[key]; | ||
var input = _this2.hasDefined(entity, key) ? entity[key] : undefined; | ||
var nextInput = _this2.hasDefined(input, key) ? input[key] : undefined; | ||
var _unvisit = unvisit(input, schema), | ||
var _unvisit = unvisit(nextInput, schema), | ||
value = _unvisit[0], | ||
@@ -667,3 +668,3 @@ foundItem = _unvisit[1], | ||
if (_this2.hasDefined(entity, key) && denormEntity[key] !== value) { | ||
if (_this2.hasDefined(input, key) && denormEntity[key] !== value) { | ||
denormEntity[key] = value; | ||
@@ -704,19 +705,180 @@ } | ||
var FlatEntity = /*#__PURE__*/function (_Entity) { | ||
_inheritsLoose(FlatEntity, _Entity); | ||
var DELETED = Symbol('ENTITY WAS DELETED'); | ||
function FlatEntity() { | ||
return _Entity.apply(this, arguments) || this; | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _isNativeFunction(fn) { | ||
return Function.toString.call(fn).indexOf("[native code]") !== -1; | ||
} | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
FlatEntity.denormalize = function denormalize(entity, unvisit) { | ||
return [entity, true, false]; | ||
function _construct(Parent, args, Class) { | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _construct.apply(null, arguments); | ||
} | ||
function _wrapNativeSuper(Class) { | ||
var _cache = typeof Map === "function" ? new Map() : undefined; | ||
_wrapNativeSuper = function _wrapNativeSuper(Class) { | ||
if (Class === null || !_isNativeFunction(Class)) return Class; | ||
if (typeof Class !== "function") { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
if (typeof _cache !== "undefined") { | ||
if (_cache.has(Class)) return _cache.get(Class); | ||
_cache.set(Class, Wrapper); | ||
} | ||
function Wrapper() { | ||
return _construct(Class, arguments, _getPrototypeOf(this).constructor); | ||
} | ||
Wrapper.prototype = Object.create(Class.prototype, { | ||
constructor: { | ||
value: Wrapper, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
return _setPrototypeOf(Wrapper, Class); | ||
}; | ||
return FlatEntity; | ||
}(Entity); | ||
return _wrapNativeSuper(Class); | ||
} | ||
var DELETED = Symbol('ENTITY WAS DELETED'); | ||
/** Link in a chain */ | ||
var Link = function Link() { | ||
this.children = new WeakMap(); | ||
}; | ||
var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, cache) { | ||
var KeySize = /*#__PURE__*/function (_Error) { | ||
_inheritsLoose(KeySize, _Error); | ||
function KeySize() { | ||
var _this; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _Error.call.apply(_Error, [this].concat(args)) || this; | ||
_this.message = 'Keys must include at least one member'; | ||
return _this; | ||
} | ||
return KeySize; | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
/** Maps from a list of objects (referentially) to any value | ||
* | ||
* If *any* members of the list get claned up, so does that key/value pair get removed. | ||
*/ | ||
var WeakListMap = /*#__PURE__*/function () { | ||
function WeakListMap() { | ||
this.first = new WeakMap(); | ||
} | ||
var _proto = WeakListMap.prototype; | ||
_proto.delete = function _delete(key) { | ||
var link = this.traverse(key); | ||
link === null || link === void 0 ? true : delete link.value; | ||
return !!link; | ||
}; | ||
_proto.get = function get(key) { | ||
var link = this.traverse(key); | ||
return link === null || link === void 0 ? void 0 : link.value; | ||
}; | ||
_proto.has = function has(key) { | ||
var link = this.traverse(key); | ||
if (!link) return false; | ||
return Object.prototype.hasOwnProperty.call(link, 'value'); | ||
}; | ||
_proto.set = function set(key, value) { | ||
if (key.length < 1) throw new KeySize(); | ||
var cur = this.first; | ||
var link; | ||
for (var i = 0; i < key.length; i++) { | ||
if (!cur.has(key[i])) { | ||
link = new Link(); | ||
cur.set(key[i], link); | ||
} else { | ||
link = cur.get(key[i]); | ||
} | ||
cur = link.children; // do on later iteration of loop. this makes typescript happy rather than putting after loop | ||
if (i === key.length - 1) { | ||
link.value = value; | ||
} | ||
} | ||
return this; | ||
}; | ||
_proto.traverse = function traverse(key) { | ||
var cur = this.first; | ||
var link; | ||
for (var i = 0; i < key.length; i++) { | ||
link = cur.get(key[i]); | ||
if (!link) return; | ||
cur = link.children; | ||
} | ||
return link; | ||
}; | ||
return WeakListMap; | ||
}(); | ||
var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, localCache, entityCache) { | ||
var entity = getEntity(id, schema); | ||
@@ -732,4 +894,4 @@ | ||
if (!cache[schema.key]) { | ||
cache[schema.key] = {}; | ||
if (localCache[schema.key] === undefined) { | ||
localCache[schema.key] = {}; | ||
} | ||
@@ -740,23 +902,36 @@ | ||
if (!cache[schema.key][id]) { | ||
// Ensure we don't mutate it non-immutable objects | ||
var entityCopy = isImmutable(entity) || entity instanceof FlatEntity ? entity : schema.fromJS(entity); // Need to set this first so that if it is referenced further within the | ||
if (!localCache[schema.key][id]) { | ||
var globalKey = [entity]; | ||
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey); | ||
if (!entityCache[schema.key]) entityCache[schema.key] = {}; | ||
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap(); | ||
var globalCacheEntry = entityCache[schema.key][id]; | ||
var entityCopy = isImmutable(entity) ? entity : schema.fromJS(entity); // Need to set this first so that if it is referenced further within the | ||
// denormalization the reference will already exist. | ||
cache[schema.key][id] = entityCopy; | ||
localCache[schema.key][id] = entityCopy; | ||
var _schema$denormalize = schema.denormalize(entityCopy, unvisit); | ||
var _schema$denormalize = schema.denormalize(entityCopy, wrappedUnvisit); | ||
cache[schema.key][id] = _schema$denormalize[0]; | ||
localCache[schema.key][id] = _schema$denormalize[0]; | ||
found = _schema$denormalize[1]; | ||
deleted = _schema$denormalize[2]; | ||
if (!globalCacheEntry.has(globalKey)) { | ||
globalCacheEntry.set(globalKey, localCache[schema.key][id]); | ||
} else { | ||
// localCache is only used before this point for recursive relationships | ||
// since recursive relationships must all referentially change if *any* do, we either | ||
// get the correct one here, or will never find the same version in the cache | ||
localCache[schema.key][id] = globalCacheEntry.get(globalKey); | ||
} | ||
} | ||
return [cache[schema.key][id], found, deleted]; | ||
return [localCache[schema.key][id], found, deleted]; | ||
}; | ||
var getUnvisit = function getUnvisit(entities) { | ||
var cache = {}; | ||
var getUnvisit = function getUnvisit(entities, entityCache, resultCache, localCache) { | ||
var getEntity = getEntities(entities); | ||
return [function unvisit(input, schema) { | ||
function unvisit(input, schema) { | ||
if (!schema) return [input, true, false]; | ||
@@ -770,3 +945,3 @@ | ||
var method = Array.isArray(schema) ? denormalize : _denormalize; | ||
return method(schema, input, unvisit); | ||
return method(schema, input, wrappedUnvisit); | ||
} | ||
@@ -786,11 +961,26 @@ } // null is considered intentional, thus always 'found' as true | ||
return unvisitEntity(input, schema, unvisit, getEntity, cache); | ||
return unvisitEntity(input, schema, wrappedUnvisit, getEntity, localCache, entityCache); | ||
} | ||
if (typeof schema.denormalize === 'function') { | ||
return schema.denormalize(input, unvisit); | ||
return schema.denormalize(input, wrappedUnvisit); | ||
} | ||
return [input, true, false]; | ||
}, cache]; | ||
} | ||
var globalKey = []; | ||
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey); | ||
return function (input, schema) { | ||
globalKey.push(input); | ||
var ret = unvisit(input, schema); | ||
if (typeof input !== 'object') return ret; | ||
if (!resultCache.has(globalKey)) { | ||
resultCache.set(globalKey, ret[0]); | ||
return ret; | ||
} else { | ||
return [resultCache.get(globalKey), ret[1], ret[2]]; | ||
} | ||
}; | ||
}; | ||
@@ -813,20 +1003,44 @@ | ||
}; | ||
}; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
var denormalize$1 = function denormalize(input, schema, entities, entityCache, resultCache) { | ||
if (entityCache === void 0) { | ||
entityCache = {}; | ||
} | ||
var denormalize$1 = function denormalize(input, schema, entities) { | ||
if (resultCache === void 0) { | ||
resultCache = new WeakListMap(); | ||
} | ||
/* istanbul ignore next */ | ||
if (process.env.NODE_ENV !== 'production' && schema === undefined) throw new Error('schema needed'); | ||
if (process.env.NODE_ENV !== 'production' && schema === undefined) { | ||
throw new Error('schema needed'); | ||
} | ||
if (typeof input !== 'undefined') { | ||
var _getUnvisit = getUnvisit(entities), | ||
unvisit = _getUnvisit[0], | ||
cache = _getUnvisit[1]; | ||
return [].concat(unvisit(input, schema), [cache]); | ||
if (typeof input === 'undefined') { | ||
return [undefined, false, false, {}]; | ||
} | ||
return [undefined, false, false, {}]; | ||
var resolvedEntities = {}; | ||
var unvisit = getUnvisit(entities, entityCache, resultCache, resolvedEntities); | ||
return [].concat(unvisit(input, schema), [resolvedEntities]); | ||
}; | ||
function withTrackedEntities(unvisit, globalKey) { | ||
// every time we nest, we want to unwrap back to the top. | ||
// this is due to only needed the next level of nested entities for lookup | ||
var originalUnvisit = unvisit.og || unvisit; | ||
var wrappedUnvisit = function wrappedUnvisit(input, schema) { | ||
var ret = originalUnvisit(input, schema); // pass over undefined in key | ||
if (ret[0] && schema && isEntity(schema)) globalKey.push(ret[0]); | ||
return ret; | ||
}; | ||
wrappedUnvisit.og = unvisit; | ||
return wrappedUnvisit; | ||
} | ||
var visit = function visit(value, parent, key, schema, addEntity, visitedEntities) { | ||
@@ -1086,2 +1300,17 @@ if (!value || !schema || !['function', 'object'].includes(typeof schema)) { | ||
/** @deprecated */ | ||
var FlatEntity = /*#__PURE__*/function (_Entity) { | ||
_inheritsLoose(FlatEntity, _Entity); | ||
function FlatEntity() { | ||
return _Entity.apply(this, arguments) || this; | ||
} | ||
FlatEntity.denormalize = function denormalize(entity, unvisit) { | ||
return [entity, true, false]; | ||
}; | ||
return FlatEntity; | ||
}(Entity); | ||
exports.DELETED = DELETED; | ||
@@ -1091,2 +1320,3 @@ exports.Entity = Entity; | ||
exports.SimpleRecord = SimpleRecord; | ||
exports.WeakListMap = WeakListMap; | ||
exports.denormalize = denormalize$1; | ||
@@ -1093,0 +1323,0 @@ exports.isEntity = isEntity; |
@@ -1,1 +0,1 @@ | ||
define(["exports"],(function(e){"use strict";function n(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function t(e,n,t){var r=!0,i=!1;return[Object.keys(e).reduce((function(n,o){var a=""+o,u=t(n.get(a),e[a]),c=u[0],s=u[1],f=u[2];return s||(r=!1),f&&(i=!0),n.has(a)?n.set(a,c):n}),n),r,i]}function r(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n}function i(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,n,t){return n&&i(e.prototype,n),t&&i(e,t),e}var a=function(){function e(e,n){n&&(this._schemaAttribute="string"==typeof n?function(e){return e[n]}:n),this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=e},t.getSchemaAttribute=function(e,n,t){return!this.isSingleSchema&&this._schemaAttribute(e,n,t)},t.inferSchema=function(e,n,t){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,n,t);return this.schema[r]},t.normalizeValue=function(e,n,t,r,i,o){var a=this.inferSchema(e,n,t);if(!a)return e;var u=r(e,n,t,a,i,o);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,n,t)}},t.denormalizeValue=function(e,t){var r=n(e)?e.get("schema"):e.schema;return this.isSingleSchema||r?t((this.isSingleSchema?void 0:n(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0,!0]},o(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),u=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]},c=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(n){return e[n]}))},s=function(e){var n=e[1],t=e[2];return n&&!t},f=function(e,n,t,r,i,o,a){return e=u(e),c(n).map((function(n,u){return i(n,t,r,e,o,a)}))},h=function(e,n,t){e=u(e);var r=!1,i=!0;if(void 0===n&&e){var o=t(void 0,e);i=o[1],r=o[2]}return[n&&n.map?n.map((function(n){return t(n,e)})).filter(s).map((function(e){return e[0]})):n,i,r]},l=function(e){function n(){return e.apply(this,arguments)||this}r(n,e);var t=n.prototype;return t.normalize=function(e,n,t,r,i,o){var a=this;return c(e).map((function(e,u){return a.normalizeValue(e,n,t,r,i,o)})).filter((function(e){return null!=e}))},t.denormalize=function(e,n){var t=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=n(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return t.denormalizeValue(e,n)})).filter(s).map((function(e){return e[0]})):e,i,r]},n}(a),m=function(e,n,t,r,i,o,a){var u=Object.assign({},n);return Object.keys(e).forEach((function(t){var r=e[t],c=i(n[t],n,t,r,o,a);null==c?delete u[t]:u[t]=c})),u},p=function(e,r,i){if(n(r))return t(e,r,i);var o=Object.assign({},r),a=!0,u=!1;return Object.keys(e).forEach((function(n){var t=i(o[n],e[n]),r=t[0],c=t[1],s=t[2];void 0!==o[n]&&(o[n]=r),s&&(u=!0),c||(a=!1)})),[o,a,u]},d=function(){function e(e){this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=Object.keys(e).reduce((function(n,t){var r,i=e[t];return Object.assign({},n,((r={})[t]=i,r))}),this.schema||{})},n.normalize=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return m.apply(void 0,[this.schema].concat(n))},n.denormalize=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return p.apply(void 0,[this.schema].concat(n))},e}();function y(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function v(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return y(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?y(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}var b=Symbol("Defined Members"),g=Symbol("unq"),O=function(){function e(){}return e.prototype.toString=function(){return this[g]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(n,t,r){void 0===n&&(n={});var i=new this(n);return n instanceof e&&(n=n.constructor.toObjectDefined(n)),Object.assign(i,n),Object.defineProperty(i,b,{value:Object.keys(n),writable:!1}),Object.defineProperty(i,g,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,n){var t=Object.assign(this.toObjectDefined(e),this.toObjectDefined(n));return this.fromJS(t)},e.hasDefined=function(e,n){return e[b].includes(n)},e.toObjectDefined=function(e){for(var n,t={},r=v(e[b]);!(n=r()).done;){var i=n.value;t[i]=e[i]}return t},e.keysDefined=function(e){return e[b]},e.normalize=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return m.apply(void 0,[this.schema].concat(n))},e.denormalize=function(e,n){var t=this,r=new this,i=Object.assign({},e),o=!1,a=!0;return Object.keys(this.schema).forEach((function(e){var u=n(i[e],t.schema[e]),c=u[0],s=u[1],f=u[2];void 0!==i[e]&&(i[e]=c),s||e in r&&!r[e]||(a=!1),!f||e in r&&!r[e]||(o=!0)})),[this.fromJS(i),a,o]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},e}();O.schema={};var S=function(e){function i(){return e.apply(this,arguments)||this}return r(i,e),i.toJSON=function(){return Object.assign({},e.toJSON.call(this),{key:this.key})},i.pk=function(e,n,t){return this.prototype.pk.call(e,n,t)||t},i.normalize=function(e,n,t,r,i,o){var a=this;if("string"==typeof e)return e;var u=this.fromJS(e,n,t);if("production"!==process.env.NODE_ENV){for(var c,s=new this,f=new Set(Object.keys(s)),h=this.keysDefined(u),l=[[],[],[]],m=l[0],p=l[1],d=l[2],y=v(h);!(c=y()).done;){var b=c.value;f.has(b)?m.push(b):d.push(b)}for(var g,O=v(f);!(g=O()).done;){var S=g.value;m.includes(S)||p.push(S)}if((Math.max(h.length/2,1)<=d.length&&f.size>Math.max(d.length,2)||m.length<Math.min(1,f.size/2))&&f.size){var 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: "+m+"\n Missing: "+p+"\n Unexpected keys: "+d+"\n Value: "+JSON.stringify(this.toObjectDefined(u),null,2));throw E.status=400,E}}var w=u.pk(n,t);if(void 0!==w&&""!==w){var k=this.key;return k in o||(o[k]={}),w in o[k]||(o[k][w]=[]),o[k][w].some((function(n){return n===e}))?w:(o[k][w].push(e),Object.keys(this.schema).forEach((function(e){if(Object.hasOwnProperty.call(u,e)){var n=a.schema[e];u[e]=r(u[e],u,e,n,i,o)}})),i(this,u,u,n,t),w)}if("production"!==process.env.NODE_ENV){var j=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 j.status=400,j}},i.denormalize=function(e,r){var i=this;if(n(e)){var o=t(this.schema,e,r),a=o[0],u=o[1],c=o[2];return[this.fromJS(a.toObject()),u,c]}var s=new this,f=!1,h=!0,l=e;return Object.keys(this.schema).forEach((function(n){var t=i.schema[n],o=i.hasDefined(e,n)?e[n]:void 0,a=r(o,t),u=a[0],c=a[1],m=a[2];c||n in s&&!s[n]||(h=!1),!m||n in s&&!s[n]||(f=!0),i.hasDefined(e,n)&&l[n]!==u&&(l[n]=u)})),[l,h,f]},o(i,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),i}(O);function E(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(S.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return O.fromJS.call(this,e)});var w=function(e){function n(){return e.apply(this,arguments)||this}return r(n,e),n.denormalize=function(e,n){return[e,!0,!1]},n}(S),k=Symbol("ENTITY WAS DELETED"),j=function(e){var t={},r=z(e);return[function e(i,o){if(!o)return[i,!0,!1];if(!o.denormalize||"function"!=typeof o.denormalize){if("function"==typeof o)return i instanceof o?[i,!0,!1]:[new o(i),!0,!1];if("object"==typeof o)return(Array.isArray(o)?h:p)(o,i,e)}return null===i?[i,!0,!1]:E(o)?void 0===i?[i,!1,!1]:function(e,t,r,i,o){var a=i(e,t);if(a===k)return[void 0,!0,!0];if("object"!=typeof a||null===a)return[a,!1,!1];o[t.key]||(o[t.key]={});var u=!0,c=!1;if(!o[t.key][e]){var s=n(a)||a instanceof w?a:t.fromJS(a);o[t.key][e]=s;var f=t.denormalize(s,r);o[t.key][e]=f[0],u=f[1],c=f[2]}return[o[t.key][e],u,c]}(i,o,e,r,t):"function"==typeof o.denormalize?o.denormalize(i,e):[i,!0,!1]},t]},z=function(e){var t=n(e);return function(n,r){var i=r.key;return"object"==typeof n?n:t?e.getIn([i,n]):e[i]&&e[i][n]}},_=function e(n,t,r,i,o,a){return n&&i&&["function","object"].includes(typeof i)?i.normalize&&"function"==typeof i.normalize?i.normalize(n,t,r,e,o,a):"function"==typeof i?new i(n):(Array.isArray(i)?f:m)(i,n,t,r,e,o,a):n};var N=function(e){function n(n,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,n,t)||this}r(n,e);var t=n.prototype;return t.normalize=function(e,n,t,r,i,o){return this.normalizeValue(e,n,t,r,i,o)},t.denormalize=function(e,n){return this.denormalizeValue(e,n)},n}(a),A=function(e){function n(){return e.apply(this,arguments)||this}r(n,e);var t=n.prototype;return t.normalize=function(e,n,t,r,i,o){var a=this;return Object.keys(e).reduce((function(n,t,u){var c,s=e[t];return null!=s?Object.assign({},n,((c={})[t]=a.normalizeValue(s,e,t,r,i,o),c)):n}),{})},t.denormalize=function(e,n){var t=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,a){var u,c=e[a],s=t.denormalizeValue(c,n),f=s[0],h=s[1],l=s[2];return h||(r=!1),l&&(i=!0),!h||l?o:Object.assign({},o,((u={})[a]=f,u))}),{}),r,i]},n}(a),D=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 n=e.prototype;return n.normalize=function(e,n,t,r,i,o){if("string"==typeof e)return e;var a=this._entity.fromJS(e,n,t),u=a.pk(n,t);return i(this._entity,k,a,n,t),u},n.denormalize=function(e,n){return n(e,this._entity)},n._denormalizeNullable=function(){return[]},n._normalizeNullable=function(){return[]},n.merge=function(e,n){return n},e}(),x=Object.freeze({__proto__:null,Union:N,Values:A,Array:l,Object:d,Delete:D});e.DELETED=k,e.Entity=S,e.FlatEntity=w,e.SimpleRecord=O,e.denormalize=function(e,n,t){if("production"!==process.env.NODE_ENV&&void 0===n)throw new Error("schema needed");if(void 0!==e){var r=j(t),i=r[0],o=r[1];return[].concat(i(e,n),[o])}return[void 0,!1,!1,{}]},e.isEntity=E,e.normalize=function(e,n,t,r){void 0===t&&(t={});var i=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(n);if(null===e||typeof e!==i){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(n,void 0,2)+'\n Input: "'+e+'"'):new Error('Unexpected input given to normalize. Expected type to be "'+i+'", found "'+(null===e?"null":typeof e)+'".\n\n Schema: '+JSON.stringify(n,void 0,2)+'\n Input: "'+e+'"')}throw new Error('Unexpected input given to normalize. Expected type to be "'+i+'", found "'+(null===e?"null":typeof e)+'".')}var o={},a={},u=function(e,n,t,r){return function(r,i,o,a,u){var c=r.key,s=r.pk(o,a,u);c in e||(e[c]={});var f=e[c][s];if(e[c][s]=f?r.merge(f,i):i,Array.isArray(r.indexes)){var h=e[c][s];c in n||(n[c]={});for(var l,m=v(r.indexes);!(l=m()).done;){var p=l.value;p in n[c]||(n[c][p]={});var d=n[c][p];f&&delete d[f[p]],t[c]&&t[c][s]&&t[c][s][p]!==h[p]&&(d[t[c][s][p]]=k),p in h?d[h[p]]=s:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+p+"\nEntity: "+JSON.stringify(h,void 0,2))}}}}(o,a,t);return{entities:o,indexes:a,result:_(e,e,void 0,n,u,{})}},e.schema=x,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){var r=!0,i=!1;return[Object.keys(e).reduce((function(t,o){var u=""+o,a=n(t.get(u),e[u]),c=a[0],s=a[1],f=a[2];return s||(r=!1),f&&(i=!0),t.has(u)?t.set(u,c):t}),t),r,i]}function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}var u=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=e},n.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},n.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},n.normalizeValue=function(e,t,n,r,i,o){var u=this.inferSchema(e,t,n);if(!u)return e;var a=r(e,t,n,u,i,o);return this.isSingleSchema||null==a?a:{id:a,schema:this.getSchemaAttribute(e,t,n)}},n.denormalizeValue=function(e,n){var 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,!0]},o(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),a=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]},c=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},s=function(e){var t=e[1],n=e[2];return t&&!n},f=function(e,t,n,r,i,o,u){return e=a(e),c(t).map((function(t,a){return i(t,n,r,e,o,u)}))},l=function(e,t,n){e=a(e);var r=!1,i=!0;if(void 0===t&&e){var o=n(void 0,e);i=o[1],r=o[2]}return[t&&t.map?t.map((function(t){return n(t,e)})).filter(s).map((function(e){return e[0]})):t,i,r]},h=function(e){function t(){return e.apply(this,arguments)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var u=this;return c(e).map((function(e,a){return u.normalizeValue(e,t,n,r,i,o)})).filter((function(e){return null!=e}))},n.denormalize=function(e,t){var n=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=t(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return n.denormalizeValue(e,t)})).filter(s).map((function(e){return e[0]})):e,i,r]},t}(u),p=function(e,t,n,r,i,o,u){var a=Object.assign({},t);return Object.keys(e).forEach((function(n){var r=e[n],c=i(t[n],t,n,r,o,u);null==c?delete a[n]:a[n]=c})),a},y=function(e,r,i){if(t(r))return n(e,r,i);var o=Object.assign({},r),u=!0,a=!1;return Object.keys(e).forEach((function(t){var n=i(o[t],e[t]),r=n[0],c=n[1],s=n[2];void 0!==o[t]&&(o[t]=r),s&&(a=!0),c||(u=!1)})),[o,u,a]},d=function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var r,i=e[n];return Object.assign({},t,((r={})[n]=i,r))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return p.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 y.apply(void 0,[this.schema].concat(t))},e}();function m(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}function v(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}var b=Symbol("Defined Members"),g=Symbol("unq"),O=function(){function e(){}return e.prototype.toString=function(){return this[g]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(t,n,r){void 0===t&&(t={});var i=new this(t);return t instanceof e&&(t=t.constructor.toObjectDefined(t)),Object.assign(i,t),Object.defineProperty(i,b,{value:Object.keys(t),writable:!1}),Object.defineProperty(i,g,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,t){var n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)},e.hasDefined=function(e,t){return e[b].includes(t)},e.toObjectDefined=function(e){for(var t,n={},r=v(e[b]);!(t=r()).done;){var i=t.value;n[i]=e[i]}return n},e.keysDefined=function(e){return e[b]},e.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return p.apply(void 0,[this.schema].concat(t))},e.denormalize=function(e,t){var n=this,r=new this,i=Object.assign({},e),o=!1,u=!0;return Object.keys(this.schema).forEach((function(e){var a=t(i[e],n.schema[e]),c=a[0],s=a[1],f=a[2];void 0!==i[e]&&(i[e]=c),s||e in r&&!r[e]||(u=!1),!f||e in r&&!r[e]||(o=!0)})),[this.fromJS(i),u,o]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},e}();O.schema={};var w=function(e){function i(){return e.apply(this,arguments)||this}return r(i,e),i.toJSON=function(){return Object.assign({},e.toJSON.call(this),{key:this.key})},i.pk=function(e,t,n){return this.prototype.pk.call(e,t,n)||n},i.normalize=function(e,t,n,r,i,o){var u=this;if("string"==typeof e)return e;var a=this.fromJS(e,t,n);if("production"!==process.env.NODE_ENV){for(var c,s=new this,f=new Set(Object.keys(s)),l=this.keysDefined(a),h=[[],[],[]],p=h[0],y=h[1],d=h[2],m=v(l);!(c=m()).done;){var b=c.value;f.has(b)?p.push(b):d.push(b)}for(var g,O=v(f);!(g=O()).done;){var w=g.value;p.includes(w)||y.push(w)}if((Math.max(l.length/2,1)<=d.length&&f.size>Math.max(d.length,2)||p.length<Math.min(1,f.size/2))&&f.size){var S=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: "+p+"\n Missing: "+y+"\n Unexpected keys: "+d+"\n Value: "+JSON.stringify(this.toObjectDefined(a),null,2));throw S.status=400,S}}var k=a.pk(t,n);if(void 0!==k&&""!==k){var E=this.key;return E in o||(o[E]={}),k in o[E]||(o[E][k]=[]),o[E][k].some((function(t){return t===e}))?k:(o[E][k].push(e),Object.keys(this.schema).forEach((function(e){if(Object.hasOwnProperty.call(a,e)){var t=u.schema[e];a[e]=r(a[e],a,e,t,i,o)}})),i(this,a,a,t,n),k)}if("production"!==process.env.NODE_ENV){var j=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 j.status=400,j}},i.denormalize=function(e,r){var i=this;if(t(e)){var o=n(this.schema,e,r),u=o[0],a=o[1],c=o[2];return[this.fromJS(u.toObject()),a,c]}var s=new this,f=!1,l=!0,h=e;return Object.keys(this.schema).forEach((function(t){var n=i.schema[t],o=i.hasDefined(e,t)?e[t]:void 0,u=r(o,n),a=u[0],c=u[1],p=u[2];c||t in s&&!s[t]||(l=!1),!p||t in s&&!s[t]||(f=!0),i.hasDefined(e,t)&&h[t]!==a&&(h[t]=a)})),[h,l,f]},o(i,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),i}(O);function S(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(w.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return O.fromJS.call(this,e)});var k=Symbol("ENTITY WAS DELETED");function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e,t){return(j=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function z(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function _(e,t,n){return(_=z()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&j(i,n.prototype),i}).apply(null,arguments)}function N(e){var t="function"==typeof Map?new Map:void 0;return(N=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return _(e,arguments,E(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),j(r,e)})(e)}var A=function(){this.children=new WeakMap},D=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).message="Keys must include at least one member",t}return r(t,e),t}(N(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 D;for(var n,r=this.first,i=0;i<e.length;i++)r.has(e[i])?n=r.get(e[i]):(n=new A,r.set(e[i],n)),r=n.children,i===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}(),J=function(e,n,r,i){var o=V(e);function u(e,r){if(!r)return[e,!0,!1];if(!r.denormalize||"function"!=typeof r.denormalize){if("function"==typeof r)return e instanceof r?[e,!0,!1]:[new r(e),!0,!1];if("object"==typeof r)return(Array.isArray(r)?l:y)(r,e,c)}return null===e?[e,!0,!1]:S(r)?void 0===e?[e,!1,!1]:function(e,n,r,i,o,u){var a=i(e,n);if(a===k)return[void 0,!0,!0];if("object"!=typeof a||null===a)return[a,!1,!1];void 0===o[n.key]&&(o[n.key]={});var c=!0,s=!1;if(!o[n.key][e]){var f=[a],l=P(r,f);u[n.key]||(u[n.key]={}),u[n.key][e]||(u[n.key][e]=new x);var h=u[n.key][e],p=t(a)?a:n.fromJS(a);o[n.key][e]=p;var y=n.denormalize(p,l);o[n.key][e]=y[0],c=y[1],s=y[2],h.has(f)?o[n.key][e]=h.get(f):h.set(f,o[n.key][e])}return[o[n.key][e],c,s]}(e,r,c,o,i,n):"function"==typeof r.denormalize?r.denormalize(e,c):[e,!0,!1]}var a=[],c=P(u,a);return function(e,t){a.push(e);var n=u(e,t);return"object"!=typeof e?n:r.has(a)?[r.get(a),n[1],n[2]]:(r.set(a,n[0]),n)}},V=function(e){var n=t(e);return function(t,r){var i=r.key;return"object"==typeof t?t:n?e.getIn([i,t]):e[i]&&e[i][t]}};function P(e,t){var n=e.og||e,r=function(e,r){var i=n(e,r);return i[0]&&r&&S(r)&&t.push(i[0]),i};return r.og=e,r}var M=function e(t,n,r,i,o,u){return t&&i&&["function","object"].includes(typeof i)?i.normalize&&"function"==typeof i.normalize?i.normalize(t,n,r,e,o,u):"function"==typeof i?new i(t):(Array.isArray(i)?f:p)(i,t,n,r,e,o,u):t};var I=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},t}(u),T=function(e){function t(){return e.apply(this,arguments)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var u=this;return Object.keys(e).reduce((function(t,n,a){var c,s=e[n];return null!=s?Object.assign({},t,((c={})[n]=u.normalizeValue(s,e,n,r,i,o),c)):t}),{})},n.denormalize=function(e,t){var n=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,u){var a,c=e[u],s=n.denormalizeValue(c,t),f=s[0],l=s[1],h=s[2];return l||(r=!1),h&&(i=!0),!l||h?o:Object.assign({},o,((a={})[u]=f,a))}),{}),r,i]},t}(u),R=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,i,o){if("string"==typeof e)return e;var u=this._entity.fromJS(e,t,n),a=u.pk(t,n);return i(this._entity,k,u,t,n),a},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},e}(),U=Object.freeze({__proto__:null,Union:I,Values:T,Array:h,Object:d,Delete:R}),F=function(e){function t(){return e.apply(this,arguments)||this}return r(t,e),t.denormalize=function(e,t){return[e,!0,!1]},t}(w);e.DELETED=k,e.Entity=w,e.FlatEntity=F,e.SimpleRecord=O,e.WeakListMap=x,e.denormalize=function(e,t,n,r,i){if(void 0===r&&(r={}),void 0===i&&(i=new x),"production"!==process.env.NODE_ENV&&void 0===t)throw new Error("schema needed");if(void 0===e)return[void 0,!1,!1,{}];var o={},u=J(n,r,i,o);return[].concat(u(e,t),[o])},e.isEntity=S,e.normalize=function(e,t,n,r){void 0===n&&(n={});var i=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==i){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 "'+i+'", 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 "'+i+'", found "'+(null===e?"null":typeof e)+'".')}var o={},u={},a=function(e,t,n,r){return function(r,i,o,u,a){var c=r.key,s=r.pk(o,u,a);c in e||(e[c]={});var f=e[c][s];if(e[c][s]=f?r.merge(f,i):i,Array.isArray(r.indexes)){var l=e[c][s];c in t||(t[c]={});for(var h,p=v(r.indexes);!(h=p()).done;){var y=h.value;y in t[c]||(t[c][y]={});var d=t[c][y];f&&delete d[f[y]],n[c]&&n[c][s]&&n[c][s][y]!==l[y]&&(d[n[c][s][y]]=k),y in l?d[l[y]]=s:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+y+"\nEntity: "+JSON.stringify(l,void 0,2))}}}}(o,u,n);return{entities:o,indexes:u,result:M(e,e,void 0,t,a,{})}},e.schema=U,Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -627,3 +627,3 @@ var rest_hooks_normalizr = (function (exports) { | ||
Entity.denormalize = function denormalize(entity, unvisit) { | ||
Entity.denormalize = function denormalize(input, unvisit) { | ||
var _this2 = this; | ||
@@ -633,4 +633,4 @@ | ||
// itself in cache. Once we offer full memoization, we will store raw objects and this can be consolidated with SimpleRecord | ||
if (isImmutable(entity)) { | ||
var _denormalizeImmutable = denormalizeImmutable(this.schema, entity, unvisit), | ||
if (isImmutable(input)) { | ||
var _denormalizeImmutable = denormalizeImmutable(this.schema, input, unvisit), | ||
_denormEntity = _denormalizeImmutable[0], | ||
@@ -647,8 +647,9 @@ _found = _denormalizeImmutable[1], | ||
var found = true; | ||
var denormEntity = entity; | ||
var denormEntity = input; // note: iteration order must be stable | ||
Object.keys(this.schema).forEach(function (key) { | ||
var schema = _this2.schema[key]; | ||
var input = _this2.hasDefined(entity, key) ? entity[key] : undefined; | ||
var nextInput = _this2.hasDefined(input, key) ? input[key] : undefined; | ||
var _unvisit = unvisit(input, schema), | ||
var _unvisit = unvisit(nextInput, schema), | ||
value = _unvisit[0], | ||
@@ -668,3 +669,3 @@ foundItem = _unvisit[1], | ||
if (_this2.hasDefined(entity, key) && denormEntity[key] !== value) { | ||
if (_this2.hasDefined(input, key) && denormEntity[key] !== value) { | ||
denormEntity[key] = value; | ||
@@ -705,19 +706,180 @@ } | ||
var FlatEntity = /*#__PURE__*/function (_Entity) { | ||
_inheritsLoose(FlatEntity, _Entity); | ||
var DELETED = Symbol('ENTITY WAS DELETED'); | ||
function FlatEntity() { | ||
return _Entity.apply(this, arguments) || this; | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _isNativeFunction(fn) { | ||
return Function.toString.call(fn).indexOf("[native code]") !== -1; | ||
} | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
FlatEntity.denormalize = function denormalize(entity, unvisit) { | ||
return [entity, true, false]; | ||
function _construct(Parent, args, Class) { | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _construct.apply(null, arguments); | ||
} | ||
function _wrapNativeSuper(Class) { | ||
var _cache = typeof Map === "function" ? new Map() : undefined; | ||
_wrapNativeSuper = function _wrapNativeSuper(Class) { | ||
if (Class === null || !_isNativeFunction(Class)) return Class; | ||
if (typeof Class !== "function") { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
if (typeof _cache !== "undefined") { | ||
if (_cache.has(Class)) return _cache.get(Class); | ||
_cache.set(Class, Wrapper); | ||
} | ||
function Wrapper() { | ||
return _construct(Class, arguments, _getPrototypeOf(this).constructor); | ||
} | ||
Wrapper.prototype = Object.create(Class.prototype, { | ||
constructor: { | ||
value: Wrapper, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
return _setPrototypeOf(Wrapper, Class); | ||
}; | ||
return FlatEntity; | ||
}(Entity); | ||
return _wrapNativeSuper(Class); | ||
} | ||
var DELETED = Symbol('ENTITY WAS DELETED'); | ||
/** Link in a chain */ | ||
var Link = function Link() { | ||
this.children = new WeakMap(); | ||
}; | ||
var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, cache) { | ||
var KeySize = /*#__PURE__*/function (_Error) { | ||
_inheritsLoose(KeySize, _Error); | ||
function KeySize() { | ||
var _this; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _Error.call.apply(_Error, [this].concat(args)) || this; | ||
_this.message = 'Keys must include at least one member'; | ||
return _this; | ||
} | ||
return KeySize; | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
/** Maps from a list of objects (referentially) to any value | ||
* | ||
* If *any* members of the list get claned up, so does that key/value pair get removed. | ||
*/ | ||
var WeakListMap = /*#__PURE__*/function () { | ||
function WeakListMap() { | ||
this.first = new WeakMap(); | ||
} | ||
var _proto = WeakListMap.prototype; | ||
_proto.delete = function _delete(key) { | ||
var link = this.traverse(key); | ||
link === null || link === void 0 ? true : delete link.value; | ||
return !!link; | ||
}; | ||
_proto.get = function get(key) { | ||
var link = this.traverse(key); | ||
return link === null || link === void 0 ? void 0 : link.value; | ||
}; | ||
_proto.has = function has(key) { | ||
var link = this.traverse(key); | ||
if (!link) return false; | ||
return Object.prototype.hasOwnProperty.call(link, 'value'); | ||
}; | ||
_proto.set = function set(key, value) { | ||
if (key.length < 1) throw new KeySize(); | ||
var cur = this.first; | ||
var link; | ||
for (var i = 0; i < key.length; i++) { | ||
if (!cur.has(key[i])) { | ||
link = new Link(); | ||
cur.set(key[i], link); | ||
} else { | ||
link = cur.get(key[i]); | ||
} | ||
cur = link.children; // do on later iteration of loop. this makes typescript happy rather than putting after loop | ||
if (i === key.length - 1) { | ||
link.value = value; | ||
} | ||
} | ||
return this; | ||
}; | ||
_proto.traverse = function traverse(key) { | ||
var cur = this.first; | ||
var link; | ||
for (var i = 0; i < key.length; i++) { | ||
link = cur.get(key[i]); | ||
if (!link) return; | ||
cur = link.children; | ||
} | ||
return link; | ||
}; | ||
return WeakListMap; | ||
}(); | ||
var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, localCache, entityCache) { | ||
var entity = getEntity(id, schema); | ||
@@ -733,4 +895,4 @@ | ||
if (!cache[schema.key]) { | ||
cache[schema.key] = {}; | ||
if (localCache[schema.key] === undefined) { | ||
localCache[schema.key] = {}; | ||
} | ||
@@ -741,23 +903,36 @@ | ||
if (!cache[schema.key][id]) { | ||
// Ensure we don't mutate it non-immutable objects | ||
var entityCopy = isImmutable(entity) || entity instanceof FlatEntity ? entity : schema.fromJS(entity); // Need to set this first so that if it is referenced further within the | ||
if (!localCache[schema.key][id]) { | ||
var globalKey = [entity]; | ||
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey); | ||
if (!entityCache[schema.key]) entityCache[schema.key] = {}; | ||
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap(); | ||
var globalCacheEntry = entityCache[schema.key][id]; | ||
var entityCopy = isImmutable(entity) ? entity : schema.fromJS(entity); // Need to set this first so that if it is referenced further within the | ||
// denormalization the reference will already exist. | ||
cache[schema.key][id] = entityCopy; | ||
localCache[schema.key][id] = entityCopy; | ||
var _schema$denormalize = schema.denormalize(entityCopy, unvisit); | ||
var _schema$denormalize = schema.denormalize(entityCopy, wrappedUnvisit); | ||
cache[schema.key][id] = _schema$denormalize[0]; | ||
localCache[schema.key][id] = _schema$denormalize[0]; | ||
found = _schema$denormalize[1]; | ||
deleted = _schema$denormalize[2]; | ||
if (!globalCacheEntry.has(globalKey)) { | ||
globalCacheEntry.set(globalKey, localCache[schema.key][id]); | ||
} else { | ||
// localCache is only used before this point for recursive relationships | ||
// since recursive relationships must all referentially change if *any* do, we either | ||
// get the correct one here, or will never find the same version in the cache | ||
localCache[schema.key][id] = globalCacheEntry.get(globalKey); | ||
} | ||
} | ||
return [cache[schema.key][id], found, deleted]; | ||
return [localCache[schema.key][id], found, deleted]; | ||
}; | ||
var getUnvisit = function getUnvisit(entities) { | ||
var cache = {}; | ||
var getUnvisit = function getUnvisit(entities, entityCache, resultCache, localCache) { | ||
var getEntity = getEntities(entities); | ||
return [function unvisit(input, schema) { | ||
function unvisit(input, schema) { | ||
if (!schema) return [input, true, false]; | ||
@@ -771,3 +946,3 @@ | ||
var method = Array.isArray(schema) ? denormalize : _denormalize; | ||
return method(schema, input, unvisit); | ||
return method(schema, input, wrappedUnvisit); | ||
} | ||
@@ -787,11 +962,26 @@ } // null is considered intentional, thus always 'found' as true | ||
return unvisitEntity(input, schema, unvisit, getEntity, cache); | ||
return unvisitEntity(input, schema, wrappedUnvisit, getEntity, localCache, entityCache); | ||
} | ||
if (typeof schema.denormalize === 'function') { | ||
return schema.denormalize(input, unvisit); | ||
return schema.denormalize(input, wrappedUnvisit); | ||
} | ||
return [input, true, false]; | ||
}, cache]; | ||
} | ||
var globalKey = []; | ||
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey); | ||
return function (input, schema) { | ||
globalKey.push(input); | ||
var ret = unvisit(input, schema); | ||
if (typeof input !== 'object') return ret; | ||
if (!resultCache.has(globalKey)) { | ||
resultCache.set(globalKey, ret[0]); | ||
return ret; | ||
} else { | ||
return [resultCache.get(globalKey), ret[1], ret[2]]; | ||
} | ||
}; | ||
}; | ||
@@ -814,20 +1004,44 @@ | ||
}; | ||
}; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
var denormalize$1 = function denormalize(input, schema, entities, entityCache, resultCache) { | ||
if (entityCache === void 0) { | ||
entityCache = {}; | ||
} | ||
var denormalize$1 = function denormalize(input, schema, entities) { | ||
if (resultCache === void 0) { | ||
resultCache = new WeakListMap(); | ||
} | ||
/* istanbul ignore next */ | ||
if (process.env.NODE_ENV !== 'production' && schema === undefined) throw new Error('schema needed'); | ||
if (process.env.NODE_ENV !== 'production' && schema === undefined) { | ||
throw new Error('schema needed'); | ||
} | ||
if (typeof input !== 'undefined') { | ||
var _getUnvisit = getUnvisit(entities), | ||
unvisit = _getUnvisit[0], | ||
cache = _getUnvisit[1]; | ||
return [].concat(unvisit(input, schema), [cache]); | ||
if (typeof input === 'undefined') { | ||
return [undefined, false, false, {}]; | ||
} | ||
return [undefined, false, false, {}]; | ||
var resolvedEntities = {}; | ||
var unvisit = getUnvisit(entities, entityCache, resultCache, resolvedEntities); | ||
return [].concat(unvisit(input, schema), [resolvedEntities]); | ||
}; | ||
function withTrackedEntities(unvisit, globalKey) { | ||
// every time we nest, we want to unwrap back to the top. | ||
// this is due to only needed the next level of nested entities for lookup | ||
var originalUnvisit = unvisit.og || unvisit; | ||
var wrappedUnvisit = function wrappedUnvisit(input, schema) { | ||
var ret = originalUnvisit(input, schema); // pass over undefined in key | ||
if (ret[0] && schema && isEntity(schema)) globalKey.push(ret[0]); | ||
return ret; | ||
}; | ||
wrappedUnvisit.og = unvisit; | ||
return wrappedUnvisit; | ||
} | ||
var visit = function visit(value, parent, key, schema, addEntity, visitedEntities) { | ||
@@ -1087,2 +1301,17 @@ if (!value || !schema || !['function', 'object'].includes(typeof schema)) { | ||
/** @deprecated */ | ||
var FlatEntity = /*#__PURE__*/function (_Entity) { | ||
_inheritsLoose(FlatEntity, _Entity); | ||
function FlatEntity() { | ||
return _Entity.apply(this, arguments) || this; | ||
} | ||
FlatEntity.denormalize = function denormalize(entity, unvisit) { | ||
return [entity, true, false]; | ||
}; | ||
return FlatEntity; | ||
}(Entity); | ||
exports.DELETED = DELETED; | ||
@@ -1092,2 +1321,3 @@ exports.Entity = Entity; | ||
exports.SimpleRecord = SimpleRecord; | ||
exports.WeakListMap = WeakListMap; | ||
exports.denormalize = denormalize$1; | ||
@@ -1094,0 +1324,0 @@ exports.isEntity = isEntity; |
@@ -1,1 +0,1 @@ | ||
var rest_hooks_normalizr=function(e){"use strict";function n(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function t(e,n,t){var r=!0,i=!1;return[Object.keys(e).reduce((function(n,o){var a=""+o,u=t(n.get(a),e[a]),c=u[0],s=u[1],f=u[2];return s||(r=!1),f&&(i=!0),n.has(a)?n.set(a,c):n}),n),r,i]}function r(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n}function i(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,n,t){return n&&i(e.prototype,n),t&&i(e,t),e}var a=function(){function e(e,n){n&&(this._schemaAttribute="string"==typeof n?function(e){return e[n]}:n),this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=e},t.getSchemaAttribute=function(e,n,t){return!this.isSingleSchema&&this._schemaAttribute(e,n,t)},t.inferSchema=function(e,n,t){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,n,t);return this.schema[r]},t.normalizeValue=function(e,n,t,r,i,o){var a=this.inferSchema(e,n,t);if(!a)return e;var u=r(e,n,t,a,i,o);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,n,t)}},t.denormalizeValue=function(e,t){var r=n(e)?e.get("schema"):e.schema;return this.isSingleSchema||r?t((this.isSingleSchema?void 0:n(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0,!0]},o(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),u=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]},c=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(n){return e[n]}))},s=function(e){var n=e[1],t=e[2];return n&&!t},f=function(e,n,t,r,i,o,a){return e=u(e),c(n).map((function(n,u){return i(n,t,r,e,o,a)}))},h=function(e,n,t){e=u(e);var r=!1,i=!0;if(void 0===n&&e){var o=t(void 0,e);i=o[1],r=o[2]}return[n&&n.map?n.map((function(n){return t(n,e)})).filter(s).map((function(e){return e[0]})):n,i,r]},l=function(e){function n(){return e.apply(this,arguments)||this}r(n,e);var t=n.prototype;return t.normalize=function(e,n,t,r,i,o){var a=this;return c(e).map((function(e,u){return a.normalizeValue(e,n,t,r,i,o)})).filter((function(e){return null!=e}))},t.denormalize=function(e,n){var t=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=n(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return t.denormalizeValue(e,n)})).filter(s).map((function(e){return e[0]})):e,i,r]},n}(a),m=function(e,n,t,r,i,o,a){var u=Object.assign({},n);return Object.keys(e).forEach((function(t){var r=e[t],c=i(n[t],n,t,r,o,a);null==c?delete u[t]:u[t]=c})),u},p=function(e,r,i){if(n(r))return t(e,r,i);var o=Object.assign({},r),a=!0,u=!1;return Object.keys(e).forEach((function(n){var t=i(o[n],e[n]),r=t[0],c=t[1],s=t[2];void 0!==o[n]&&(o[n]=r),s&&(u=!0),c||(a=!1)})),[o,a,u]},d=function(){function e(e){this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=Object.keys(e).reduce((function(n,t){var r,i=e[t];return Object.assign({},n,((r={})[t]=i,r))}),this.schema||{})},n.normalize=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return m.apply(void 0,[this.schema].concat(n))},n.denormalize=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return p.apply(void 0,[this.schema].concat(n))},e}();function y(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function v(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return y(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?y(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}var b=Symbol("Defined Members"),g=Symbol("unq"),O=function(){function e(){}return e.prototype.toString=function(){return this[g]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(n,t,r){void 0===n&&(n={});var i=new this(n);return n instanceof e&&(n=n.constructor.toObjectDefined(n)),Object.assign(i,n),Object.defineProperty(i,b,{value:Object.keys(n),writable:!1}),Object.defineProperty(i,g,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,n){var t=Object.assign(this.toObjectDefined(e),this.toObjectDefined(n));return this.fromJS(t)},e.hasDefined=function(e,n){return e[b].includes(n)},e.toObjectDefined=function(e){for(var n,t={},r=v(e[b]);!(n=r()).done;){var i=n.value;t[i]=e[i]}return t},e.keysDefined=function(e){return e[b]},e.normalize=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return m.apply(void 0,[this.schema].concat(n))},e.denormalize=function(e,n){var t=this,r=new this,i=Object.assign({},e),o=!1,a=!0;return Object.keys(this.schema).forEach((function(e){var u=n(i[e],t.schema[e]),c=u[0],s=u[1],f=u[2];void 0!==i[e]&&(i[e]=c),s||e in r&&!r[e]||(a=!1),!f||e in r&&!r[e]||(o=!0)})),[this.fromJS(i),a,o]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},e}();O.schema={};var S=function(e){function i(){return e.apply(this,arguments)||this}return r(i,e),i.toJSON=function(){return Object.assign({},e.toJSON.call(this),{key:this.key})},i.pk=function(e,n,t){return this.prototype.pk.call(e,n,t)||t},i.normalize=function(e,n,t,r,i,o){var a=this;if("string"==typeof e)return e;var u=this.fromJS(e,n,t);if("production"!==process.env.NODE_ENV){for(var c,s=new this,f=new Set(Object.keys(s)),h=this.keysDefined(u),l=[[],[],[]],m=l[0],p=l[1],d=l[2],y=v(h);!(c=y()).done;){var b=c.value;f.has(b)?m.push(b):d.push(b)}for(var g,O=v(f);!(g=O()).done;){var S=g.value;m.includes(S)||p.push(S)}if((Math.max(h.length/2,1)<=d.length&&f.size>Math.max(d.length,2)||m.length<Math.min(1,f.size/2))&&f.size){var 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: "+m+"\n Missing: "+p+"\n Unexpected keys: "+d+"\n Value: "+JSON.stringify(this.toObjectDefined(u),null,2));throw E.status=400,E}}var w=u.pk(n,t);if(void 0!==w&&""!==w){var k=this.key;return k in o||(o[k]={}),w in o[k]||(o[k][w]=[]),o[k][w].some((function(n){return n===e}))?w:(o[k][w].push(e),Object.keys(this.schema).forEach((function(e){if(Object.hasOwnProperty.call(u,e)){var n=a.schema[e];u[e]=r(u[e],u,e,n,i,o)}})),i(this,u,u,n,t),w)}if("production"!==process.env.NODE_ENV){var j=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 j.status=400,j}},i.denormalize=function(e,r){var i=this;if(n(e)){var o=t(this.schema,e,r),a=o[0],u=o[1],c=o[2];return[this.fromJS(a.toObject()),u,c]}var s=new this,f=!1,h=!0,l=e;return Object.keys(this.schema).forEach((function(n){var t=i.schema[n],o=i.hasDefined(e,n)?e[n]:void 0,a=r(o,t),u=a[0],c=a[1],m=a[2];c||n in s&&!s[n]||(h=!1),!m||n in s&&!s[n]||(f=!0),i.hasDefined(e,n)&&l[n]!==u&&(l[n]=u)})),[l,h,f]},o(i,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),i}(O);function E(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(S.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return O.fromJS.call(this,e)});var w=function(e){function n(){return e.apply(this,arguments)||this}return r(n,e),n.denormalize=function(e,n){return[e,!0,!1]},n}(S),k=Symbol("ENTITY WAS DELETED"),j=function(e){var t={},r=z(e);return[function e(i,o){if(!o)return[i,!0,!1];if(!o.denormalize||"function"!=typeof o.denormalize){if("function"==typeof o)return i instanceof o?[i,!0,!1]:[new o(i),!0,!1];if("object"==typeof o)return(Array.isArray(o)?h:p)(o,i,e)}return null===i?[i,!0,!1]:E(o)?void 0===i?[i,!1,!1]:function(e,t,r,i,o){var a=i(e,t);if(a===k)return[void 0,!0,!0];if("object"!=typeof a||null===a)return[a,!1,!1];o[t.key]||(o[t.key]={});var u=!0,c=!1;if(!o[t.key][e]){var s=n(a)||a instanceof w?a:t.fromJS(a);o[t.key][e]=s;var f=t.denormalize(s,r);o[t.key][e]=f[0],u=f[1],c=f[2]}return[o[t.key][e],u,c]}(i,o,e,r,t):"function"==typeof o.denormalize?o.denormalize(i,e):[i,!0,!1]},t]},z=function(e){var t=n(e);return function(n,r){var i=r.key;return"object"==typeof n?n:t?e.getIn([i,n]):e[i]&&e[i][n]}},_=function e(n,t,r,i,o,a){return n&&i&&["function","object"].includes(typeof i)?i.normalize&&"function"==typeof i.normalize?i.normalize(n,t,r,e,o,a):"function"==typeof i?new i(n):(Array.isArray(i)?f:m)(i,n,t,r,e,o,a):n};var N=function(e){function n(n,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,n,t)||this}r(n,e);var t=n.prototype;return t.normalize=function(e,n,t,r,i,o){return this.normalizeValue(e,n,t,r,i,o)},t.denormalize=function(e,n){return this.denormalizeValue(e,n)},n}(a),A=function(e){function n(){return e.apply(this,arguments)||this}r(n,e);var t=n.prototype;return t.normalize=function(e,n,t,r,i,o){var a=this;return Object.keys(e).reduce((function(n,t,u){var c,s=e[t];return null!=s?Object.assign({},n,((c={})[t]=a.normalizeValue(s,e,t,r,i,o),c)):n}),{})},t.denormalize=function(e,n){var t=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,a){var u,c=e[a],s=t.denormalizeValue(c,n),f=s[0],h=s[1],l=s[2];return h||(r=!1),l&&(i=!0),!h||l?o:Object.assign({},o,((u={})[a]=f,u))}),{}),r,i]},n}(a),D=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 n=e.prototype;return n.normalize=function(e,n,t,r,i,o){if("string"==typeof e)return e;var a=this._entity.fromJS(e,n,t),u=a.pk(n,t);return i(this._entity,k,a,n,t),u},n.denormalize=function(e,n){return n(e,this._entity)},n._denormalizeNullable=function(){return[]},n._normalizeNullable=function(){return[]},n.merge=function(e,n){return n},e}(),J=Object.freeze({__proto__:null,Union:N,Values:A,Array:l,Object:d,Delete:D});return e.DELETED=k,e.Entity=S,e.FlatEntity=w,e.SimpleRecord=O,e.denormalize=function(e,n,t){if("production"!==process.env.NODE_ENV&&void 0===n)throw new Error("schema needed");if(void 0!==e){var r=j(t),i=r[0],o=r[1];return[].concat(i(e,n),[o])}return[void 0,!1,!1,{}]},e.isEntity=E,e.normalize=function(e,n,t,r){void 0===t&&(t={});var i=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(n);if(null===e||typeof e!==i){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(n,void 0,2)+'\n Input: "'+e+'"'):new Error('Unexpected input given to normalize. Expected type to be "'+i+'", found "'+(null===e?"null":typeof e)+'".\n\n Schema: '+JSON.stringify(n,void 0,2)+'\n Input: "'+e+'"')}throw new Error('Unexpected input given to normalize. Expected type to be "'+i+'", found "'+(null===e?"null":typeof e)+'".')}var o={},a={},u=function(e,n,t,r){return function(r,i,o,a,u){var c=r.key,s=r.pk(o,a,u);c in e||(e[c]={});var f=e[c][s];if(e[c][s]=f?r.merge(f,i):i,Array.isArray(r.indexes)){var h=e[c][s];c in n||(n[c]={});for(var l,m=v(r.indexes);!(l=m()).done;){var p=l.value;p in n[c]||(n[c][p]={});var d=n[c][p];f&&delete d[f[p]],t[c]&&t[c][s]&&t[c][s][p]!==h[p]&&(d[t[c][s][p]]=k),p in h?d[h[p]]=s:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+p+"\nEntity: "+JSON.stringify(h,void 0,2))}}}}(o,a,t);return{entities:o,indexes:a,result:_(e,e,void 0,n,u,{})}},e.schema=J,Object.defineProperty(e,"__esModule",{value:!0}),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){var r=!0,i=!1;return[Object.keys(e).reduce((function(t,o){var u=""+o,a=n(t.get(u),e[u]),c=a[0],s=a[1],f=a[2];return s||(r=!1),f&&(i=!0),t.has(u)?t.set(u,c):t}),t),r,i]}function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}var u=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=e},n.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},n.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},n.normalizeValue=function(e,t,n,r,i,o){var u=this.inferSchema(e,t,n);if(!u)return e;var a=r(e,t,n,u,i,o);return this.isSingleSchema||null==a?a:{id:a,schema:this.getSchemaAttribute(e,t,n)}},n.denormalizeValue=function(e,n){var 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,!0]},o(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),a=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]},c=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},s=function(e){var t=e[1],n=e[2];return t&&!n},f=function(e,t,n,r,i,o,u){return e=a(e),c(t).map((function(t,a){return i(t,n,r,e,o,u)}))},l=function(e,t,n){e=a(e);var r=!1,i=!0;if(void 0===t&&e){var o=n(void 0,e);i=o[1],r=o[2]}return[t&&t.map?t.map((function(t){return n(t,e)})).filter(s).map((function(e){return e[0]})):t,i,r]},h=function(e){function t(){return e.apply(this,arguments)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var u=this;return c(e).map((function(e,a){return u.normalizeValue(e,t,n,r,i,o)})).filter((function(e){return null!=e}))},n.denormalize=function(e,t){var n=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=t(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return n.denormalizeValue(e,t)})).filter(s).map((function(e){return e[0]})):e,i,r]},t}(u),p=function(e,t,n,r,i,o,u){var a=Object.assign({},t);return Object.keys(e).forEach((function(n){var r=e[n],c=i(t[n],t,n,r,o,u);null==c?delete a[n]:a[n]=c})),a},y=function(e,r,i){if(t(r))return n(e,r,i);var o=Object.assign({},r),u=!0,a=!1;return Object.keys(e).forEach((function(t){var n=i(o[t],e[t]),r=n[0],c=n[1],s=n[2];void 0!==o[t]&&(o[t]=r),s&&(a=!0),c||(u=!1)})),[o,u,a]},m=function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var r,i=e[n];return Object.assign({},t,((r={})[n]=i,r))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return p.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 y.apply(void 0,[this.schema].concat(t))},e}();function d(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}function v(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}var b=Symbol("Defined Members"),g=Symbol("unq"),O=function(){function e(){}return e.prototype.toString=function(){return this[g]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(t,n,r){void 0===t&&(t={});var i=new this(t);return t instanceof e&&(t=t.constructor.toObjectDefined(t)),Object.assign(i,t),Object.defineProperty(i,b,{value:Object.keys(t),writable:!1}),Object.defineProperty(i,g,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,t){var n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)},e.hasDefined=function(e,t){return e[b].includes(t)},e.toObjectDefined=function(e){for(var t,n={},r=v(e[b]);!(t=r()).done;){var i=t.value;n[i]=e[i]}return n},e.keysDefined=function(e){return e[b]},e.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return p.apply(void 0,[this.schema].concat(t))},e.denormalize=function(e,t){var n=this,r=new this,i=Object.assign({},e),o=!1,u=!0;return Object.keys(this.schema).forEach((function(e){var a=t(i[e],n.schema[e]),c=a[0],s=a[1],f=a[2];void 0!==i[e]&&(i[e]=c),s||e in r&&!r[e]||(u=!1),!f||e in r&&!r[e]||(o=!0)})),[this.fromJS(i),u,o]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},e}();O.schema={};var w=function(e){function i(){return e.apply(this,arguments)||this}return r(i,e),i.toJSON=function(){return Object.assign({},e.toJSON.call(this),{key:this.key})},i.pk=function(e,t,n){return this.prototype.pk.call(e,t,n)||n},i.normalize=function(e,t,n,r,i,o){var u=this;if("string"==typeof e)return e;var a=this.fromJS(e,t,n);if("production"!==process.env.NODE_ENV){for(var c,s=new this,f=new Set(Object.keys(s)),l=this.keysDefined(a),h=[[],[],[]],p=h[0],y=h[1],m=h[2],d=v(l);!(c=d()).done;){var b=c.value;f.has(b)?p.push(b):m.push(b)}for(var g,O=v(f);!(g=O()).done;){var w=g.value;p.includes(w)||y.push(w)}if((Math.max(l.length/2,1)<=m.length&&f.size>Math.max(m.length,2)||p.length<Math.min(1,f.size/2))&&f.size){var S=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: "+p+"\n Missing: "+y+"\n Unexpected keys: "+m+"\n Value: "+JSON.stringify(this.toObjectDefined(a),null,2));throw S.status=400,S}}var k=a.pk(t,n);if(void 0!==k&&""!==k){var E=this.key;return E in o||(o[E]={}),k in o[E]||(o[E][k]=[]),o[E][k].some((function(t){return t===e}))?k:(o[E][k].push(e),Object.keys(this.schema).forEach((function(e){if(Object.hasOwnProperty.call(a,e)){var t=u.schema[e];a[e]=r(a[e],a,e,t,i,o)}})),i(this,a,a,t,n),k)}if("production"!==process.env.NODE_ENV){var j=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 j.status=400,j}},i.denormalize=function(e,r){var i=this;if(t(e)){var o=n(this.schema,e,r),u=o[0],a=o[1],c=o[2];return[this.fromJS(u.toObject()),a,c]}var s=new this,f=!1,l=!0,h=e;return Object.keys(this.schema).forEach((function(t){var n=i.schema[t],o=i.hasDefined(e,t)?e[t]:void 0,u=r(o,n),a=u[0],c=u[1],p=u[2];c||t in s&&!s[t]||(l=!1),!p||t in s&&!s[t]||(f=!0),i.hasDefined(e,t)&&h[t]!==a&&(h[t]=a)})),[h,l,f]},o(i,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),i}(O);function S(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(w.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return O.fromJS.call(this,e)});var k=Symbol("ENTITY WAS DELETED");function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e,t){return(j=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function z(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function _(e,t,n){return(_=z()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&j(i,n.prototype),i}).apply(null,arguments)}function N(e){var t="function"==typeof Map?new Map:void 0;return(N=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return _(e,arguments,E(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),j(r,e)})(e)}var A=function(){this.children=new WeakMap},D=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).message="Keys must include at least one member",t}return r(t,e),t}(N(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 D;for(var n,r=this.first,i=0;i<e.length;i++)r.has(e[i])?n=r.get(e[i]):(n=new A,r.set(e[i],n)),r=n.children,i===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}(),J=function(e,n,r,i){var o=V(e);function u(e,r){if(!r)return[e,!0,!1];if(!r.denormalize||"function"!=typeof r.denormalize){if("function"==typeof r)return e instanceof r?[e,!0,!1]:[new r(e),!0,!1];if("object"==typeof r)return(Array.isArray(r)?l:y)(r,e,c)}return null===e?[e,!0,!1]:S(r)?void 0===e?[e,!1,!1]:function(e,n,r,i,o,u){var a=i(e,n);if(a===k)return[void 0,!0,!0];if("object"!=typeof a||null===a)return[a,!1,!1];void 0===o[n.key]&&(o[n.key]={});var c=!0,s=!1;if(!o[n.key][e]){var f=[a],l=P(r,f);u[n.key]||(u[n.key]={}),u[n.key][e]||(u[n.key][e]=new x);var h=u[n.key][e],p=t(a)?a:n.fromJS(a);o[n.key][e]=p;var y=n.denormalize(p,l);o[n.key][e]=y[0],c=y[1],s=y[2],h.has(f)?o[n.key][e]=h.get(f):h.set(f,o[n.key][e])}return[o[n.key][e],c,s]}(e,r,c,o,i,n):"function"==typeof r.denormalize?r.denormalize(e,c):[e,!0,!1]}var a=[],c=P(u,a);return function(e,t){a.push(e);var n=u(e,t);return"object"!=typeof e?n:r.has(a)?[r.get(a),n[1],n[2]]:(r.set(a,n[0]),n)}},V=function(e){var n=t(e);return function(t,r){var i=r.key;return"object"==typeof t?t:n?e.getIn([i,t]):e[i]&&e[i][t]}};function P(e,t){var n=e.og||e,r=function(e,r){var i=n(e,r);return i[0]&&r&&S(r)&&t.push(i[0]),i};return r.og=e,r}var M=function e(t,n,r,i,o,u){return t&&i&&["function","object"].includes(typeof i)?i.normalize&&"function"==typeof i.normalize?i.normalize(t,n,r,e,o,u):"function"==typeof i?new i(t):(Array.isArray(i)?f:p)(i,t,n,r,e,o,u):t};var I=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},t}(u),T=function(e){function t(){return e.apply(this,arguments)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var u=this;return Object.keys(e).reduce((function(t,n,a){var c,s=e[n];return null!=s?Object.assign({},t,((c={})[n]=u.normalizeValue(s,e,n,r,i,o),c)):t}),{})},n.denormalize=function(e,t){var n=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,u){var a,c=e[u],s=n.denormalizeValue(c,t),f=s[0],l=s[1],h=s[2];return l||(r=!1),h&&(i=!0),!l||h?o:Object.assign({},o,((a={})[u]=f,a))}),{}),r,i]},t}(u),R=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,i,o){if("string"==typeof e)return e;var u=this._entity.fromJS(e,t,n),a=u.pk(t,n);return i(this._entity,k,u,t,n),a},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},e}(),U=Object.freeze({__proto__:null,Union:I,Values:T,Array:h,Object:m,Delete:R}),F=function(e){function t(){return e.apply(this,arguments)||this}return r(t,e),t.denormalize=function(e,t){return[e,!0,!1]},t}(w);return e.DELETED=k,e.Entity=w,e.FlatEntity=F,e.SimpleRecord=O,e.WeakListMap=x,e.denormalize=function(e,t,n,r,i){if(void 0===r&&(r={}),void 0===i&&(i=new x),"production"!==process.env.NODE_ENV&&void 0===t)throw new Error("schema needed");if(void 0===e)return[void 0,!1,!1,{}];var o={},u=J(n,r,i,o);return[].concat(u(e,t),[o])},e.isEntity=S,e.normalize=function(e,t,n,r){void 0===n&&(n={});var i=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==i){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 "'+i+'", 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 "'+i+'", found "'+(null===e?"null":typeof e)+'".')}var o={},u={},a=function(e,t,n,r){return function(r,i,o,u,a){var c=r.key,s=r.pk(o,u,a);c in e||(e[c]={});var f=e[c][s];if(e[c][s]=f?r.merge(f,i):i,Array.isArray(r.indexes)){var l=e[c][s];c in t||(t[c]={});for(var h,p=v(r.indexes);!(h=p()).done;){var y=h.value;y in t[c]||(t[c][y]={});var m=t[c][y];f&&delete m[f[y]],n[c]&&n[c][s]&&n[c][s][y]!==l[y]&&(m[n[c][s][y]]=k),y in l?m[l[y]]=s:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+y+"\nEntity: "+JSON.stringify(l,void 0,2))}}}}(o,u,n);return{entities:o,indexes:u,result:M(e,e,void 0,t,a,{})}},e.schema=U,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); |
@@ -628,3 +628,3 @@ 'use strict'; | ||
Entity.denormalize = function denormalize(entity, unvisit) { | ||
Entity.denormalize = function denormalize(input, unvisit) { | ||
var _this2 = this; | ||
@@ -634,4 +634,4 @@ | ||
// itself in cache. Once we offer full memoization, we will store raw objects and this can be consolidated with SimpleRecord | ||
if (isImmutable(entity)) { | ||
var _denormalizeImmutable = denormalizeImmutable(this.schema, entity, unvisit), | ||
if (isImmutable(input)) { | ||
var _denormalizeImmutable = denormalizeImmutable(this.schema, input, unvisit), | ||
_denormEntity = _denormalizeImmutable[0], | ||
@@ -648,8 +648,9 @@ _found = _denormalizeImmutable[1], | ||
var found = true; | ||
var denormEntity = entity; | ||
var denormEntity = input; // note: iteration order must be stable | ||
Object.keys(this.schema).forEach(function (key) { | ||
var schema = _this2.schema[key]; | ||
var input = _this2.hasDefined(entity, key) ? entity[key] : undefined; | ||
var nextInput = _this2.hasDefined(input, key) ? input[key] : undefined; | ||
var _unvisit = unvisit(input, schema), | ||
var _unvisit = unvisit(nextInput, schema), | ||
value = _unvisit[0], | ||
@@ -669,3 +670,3 @@ foundItem = _unvisit[1], | ||
if (_this2.hasDefined(entity, key) && denormEntity[key] !== value) { | ||
if (_this2.hasDefined(input, key) && denormEntity[key] !== value) { | ||
denormEntity[key] = value; | ||
@@ -706,19 +707,180 @@ } | ||
var FlatEntity = /*#__PURE__*/function (_Entity) { | ||
_inheritsLoose(FlatEntity, _Entity); | ||
var DELETED = Symbol('ENTITY WAS DELETED'); | ||
function FlatEntity() { | ||
return _Entity.apply(this, arguments) || this; | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _isNativeFunction(fn) { | ||
return Function.toString.call(fn).indexOf("[native code]") !== -1; | ||
} | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
FlatEntity.denormalize = function denormalize(entity, unvisit) { | ||
return [entity, true, false]; | ||
function _construct(Parent, args, Class) { | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _construct.apply(null, arguments); | ||
} | ||
function _wrapNativeSuper(Class) { | ||
var _cache = typeof Map === "function" ? new Map() : undefined; | ||
_wrapNativeSuper = function _wrapNativeSuper(Class) { | ||
if (Class === null || !_isNativeFunction(Class)) return Class; | ||
if (typeof Class !== "function") { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
if (typeof _cache !== "undefined") { | ||
if (_cache.has(Class)) return _cache.get(Class); | ||
_cache.set(Class, Wrapper); | ||
} | ||
function Wrapper() { | ||
return _construct(Class, arguments, _getPrototypeOf(this).constructor); | ||
} | ||
Wrapper.prototype = Object.create(Class.prototype, { | ||
constructor: { | ||
value: Wrapper, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
return _setPrototypeOf(Wrapper, Class); | ||
}; | ||
return FlatEntity; | ||
}(Entity); | ||
return _wrapNativeSuper(Class); | ||
} | ||
var DELETED = Symbol('ENTITY WAS DELETED'); | ||
/** Link in a chain */ | ||
var Link = function Link() { | ||
this.children = new WeakMap(); | ||
}; | ||
var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, cache) { | ||
var KeySize = /*#__PURE__*/function (_Error) { | ||
_inheritsLoose(KeySize, _Error); | ||
function KeySize() { | ||
var _this; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _Error.call.apply(_Error, [this].concat(args)) || this; | ||
_this.message = 'Keys must include at least one member'; | ||
return _this; | ||
} | ||
return KeySize; | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
/** Maps from a list of objects (referentially) to any value | ||
* | ||
* If *any* members of the list get claned up, so does that key/value pair get removed. | ||
*/ | ||
var WeakListMap = /*#__PURE__*/function () { | ||
function WeakListMap() { | ||
this.first = new WeakMap(); | ||
} | ||
var _proto = WeakListMap.prototype; | ||
_proto.delete = function _delete(key) { | ||
var link = this.traverse(key); | ||
link === null || link === void 0 ? true : delete link.value; | ||
return !!link; | ||
}; | ||
_proto.get = function get(key) { | ||
var link = this.traverse(key); | ||
return link === null || link === void 0 ? void 0 : link.value; | ||
}; | ||
_proto.has = function has(key) { | ||
var link = this.traverse(key); | ||
if (!link) return false; | ||
return Object.prototype.hasOwnProperty.call(link, 'value'); | ||
}; | ||
_proto.set = function set(key, value) { | ||
if (key.length < 1) throw new KeySize(); | ||
var cur = this.first; | ||
var link; | ||
for (var i = 0; i < key.length; i++) { | ||
if (!cur.has(key[i])) { | ||
link = new Link(); | ||
cur.set(key[i], link); | ||
} else { | ||
link = cur.get(key[i]); | ||
} | ||
cur = link.children; // do on later iteration of loop. this makes typescript happy rather than putting after loop | ||
if (i === key.length - 1) { | ||
link.value = value; | ||
} | ||
} | ||
return this; | ||
}; | ||
_proto.traverse = function traverse(key) { | ||
var cur = this.first; | ||
var link; | ||
for (var i = 0; i < key.length; i++) { | ||
link = cur.get(key[i]); | ||
if (!link) return; | ||
cur = link.children; | ||
} | ||
return link; | ||
}; | ||
return WeakListMap; | ||
}(); | ||
var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, localCache, entityCache) { | ||
var entity = getEntity(id, schema); | ||
@@ -734,4 +896,4 @@ | ||
if (!cache[schema.key]) { | ||
cache[schema.key] = {}; | ||
if (localCache[schema.key] === undefined) { | ||
localCache[schema.key] = {}; | ||
} | ||
@@ -742,23 +904,36 @@ | ||
if (!cache[schema.key][id]) { | ||
// Ensure we don't mutate it non-immutable objects | ||
var entityCopy = isImmutable(entity) || entity instanceof FlatEntity ? entity : schema.fromJS(entity); // Need to set this first so that if it is referenced further within the | ||
if (!localCache[schema.key][id]) { | ||
var globalKey = [entity]; | ||
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey); | ||
if (!entityCache[schema.key]) entityCache[schema.key] = {}; | ||
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap(); | ||
var globalCacheEntry = entityCache[schema.key][id]; | ||
var entityCopy = isImmutable(entity) ? entity : schema.fromJS(entity); // Need to set this first so that if it is referenced further within the | ||
// denormalization the reference will already exist. | ||
cache[schema.key][id] = entityCopy; | ||
localCache[schema.key][id] = entityCopy; | ||
var _schema$denormalize = schema.denormalize(entityCopy, unvisit); | ||
var _schema$denormalize = schema.denormalize(entityCopy, wrappedUnvisit); | ||
cache[schema.key][id] = _schema$denormalize[0]; | ||
localCache[schema.key][id] = _schema$denormalize[0]; | ||
found = _schema$denormalize[1]; | ||
deleted = _schema$denormalize[2]; | ||
if (!globalCacheEntry.has(globalKey)) { | ||
globalCacheEntry.set(globalKey, localCache[schema.key][id]); | ||
} else { | ||
// localCache is only used before this point for recursive relationships | ||
// since recursive relationships must all referentially change if *any* do, we either | ||
// get the correct one here, or will never find the same version in the cache | ||
localCache[schema.key][id] = globalCacheEntry.get(globalKey); | ||
} | ||
} | ||
return [cache[schema.key][id], found, deleted]; | ||
return [localCache[schema.key][id], found, deleted]; | ||
}; | ||
var getUnvisit = function getUnvisit(entities) { | ||
var cache = {}; | ||
var getUnvisit = function getUnvisit(entities, entityCache, resultCache, localCache) { | ||
var getEntity = getEntities(entities); | ||
return [function unvisit(input, schema) { | ||
function unvisit(input, schema) { | ||
if (!schema) return [input, true, false]; | ||
@@ -772,3 +947,3 @@ | ||
var method = Array.isArray(schema) ? denormalize : _denormalize; | ||
return method(schema, input, unvisit); | ||
return method(schema, input, wrappedUnvisit); | ||
} | ||
@@ -788,11 +963,26 @@ } // null is considered intentional, thus always 'found' as true | ||
return unvisitEntity(input, schema, unvisit, getEntity, cache); | ||
return unvisitEntity(input, schema, wrappedUnvisit, getEntity, localCache, entityCache); | ||
} | ||
if (typeof schema.denormalize === 'function') { | ||
return schema.denormalize(input, unvisit); | ||
return schema.denormalize(input, wrappedUnvisit); | ||
} | ||
return [input, true, false]; | ||
}, cache]; | ||
} | ||
var globalKey = []; | ||
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey); | ||
return function (input, schema) { | ||
globalKey.push(input); | ||
var ret = unvisit(input, schema); | ||
if (typeof input !== 'object') return ret; | ||
if (!resultCache.has(globalKey)) { | ||
resultCache.set(globalKey, ret[0]); | ||
return ret; | ||
} else { | ||
return [resultCache.get(globalKey), ret[1], ret[2]]; | ||
} | ||
}; | ||
}; | ||
@@ -815,20 +1005,44 @@ | ||
}; | ||
}; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
var denormalize$1 = function denormalize(input, schema, entities, entityCache, resultCache) { | ||
if (entityCache === void 0) { | ||
entityCache = {}; | ||
} | ||
var denormalize$1 = function denormalize(input, schema, entities) { | ||
if (resultCache === void 0) { | ||
resultCache = new WeakListMap(); | ||
} | ||
/* istanbul ignore next */ | ||
if (process.env.NODE_ENV !== 'production' && schema === undefined) throw new Error('schema needed'); | ||
if (process.env.NODE_ENV !== 'production' && schema === undefined) { | ||
throw new Error('schema needed'); | ||
} | ||
if (typeof input !== 'undefined') { | ||
var _getUnvisit = getUnvisit(entities), | ||
unvisit = _getUnvisit[0], | ||
cache = _getUnvisit[1]; | ||
return [].concat(unvisit(input, schema), [cache]); | ||
if (typeof input === 'undefined') { | ||
return [undefined, false, false, {}]; | ||
} | ||
return [undefined, false, false, {}]; | ||
var resolvedEntities = {}; | ||
var unvisit = getUnvisit(entities, entityCache, resultCache, resolvedEntities); | ||
return [].concat(unvisit(input, schema), [resolvedEntities]); | ||
}; | ||
function withTrackedEntities(unvisit, globalKey) { | ||
// every time we nest, we want to unwrap back to the top. | ||
// this is due to only needed the next level of nested entities for lookup | ||
var originalUnvisit = unvisit.og || unvisit; | ||
var wrappedUnvisit = function wrappedUnvisit(input, schema) { | ||
var ret = originalUnvisit(input, schema); // pass over undefined in key | ||
if (ret[0] && schema && isEntity(schema)) globalKey.push(ret[0]); | ||
return ret; | ||
}; | ||
wrappedUnvisit.og = unvisit; | ||
return wrappedUnvisit; | ||
} | ||
var visit = function visit(value, parent, key, schema, addEntity, visitedEntities) { | ||
@@ -1088,2 +1302,17 @@ if (!value || !schema || !['function', 'object'].includes(typeof schema)) { | ||
/** @deprecated */ | ||
var FlatEntity = /*#__PURE__*/function (_Entity) { | ||
_inheritsLoose(FlatEntity, _Entity); | ||
function FlatEntity() { | ||
return _Entity.apply(this, arguments) || this; | ||
} | ||
FlatEntity.denormalize = function denormalize(entity, unvisit) { | ||
return [entity, true, false]; | ||
}; | ||
return FlatEntity; | ||
}(Entity); | ||
exports.DELETED = DELETED; | ||
@@ -1093,2 +1322,3 @@ exports.Entity = Entity; | ||
exports.SimpleRecord = SimpleRecord; | ||
exports.WeakListMap = WeakListMap; | ||
exports.denormalize = denormalize$1; | ||
@@ -1095,0 +1325,0 @@ exports.isEntity = isEntity; |
@@ -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 n(e,n,t){var r=!0,i=!1;return[Object.keys(e).reduce((function(n,o){var a=""+o,u=t(n.get(a),e[a]),s=u[0],c=u[1],f=u[2];return c||(r=!1),f&&(i=!0),n.has(a)?n.set(a,s):n}),n),r,i]}function t(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n}function r(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,n,t){return n&&r(e.prototype,n),t&&r(e,t),e}Object.defineProperty(exports,"__esModule",{value:!0});var o=function(){function n(e,n){n&&(this._schemaAttribute="string"==typeof n?function(e){return e[n]}:n),this.define(e)}var t=n.prototype;return t.define=function(e){this.schema=e},t.getSchemaAttribute=function(e,n,t){return!this.isSingleSchema&&this._schemaAttribute(e,n,t)},t.inferSchema=function(e,n,t){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,n,t);return this.schema[r]},t.normalizeValue=function(e,n,t,r,i,o){var a=this.inferSchema(e,n,t);if(!a)return e;var u=r(e,n,t,a,i,o);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,n,t)}},t.denormalizeValue=function(n,t){var r=e(n)?n.get("schema"):n.schema;return this.isSingleSchema||r?t((this.isSingleSchema?void 0:e(n)?n.get("id"):n.id)||n,this.isSingleSchema?this.schema:this.schema[r]):[n,!0,!0]},i(n,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),n}(),a=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]},u=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(n){return e[n]}))},s=function(e){var n=e[1],t=e[2];return n&&!t},c=function(e,n,t,r,i,o,s){return e=a(e),u(n).map((function(n,a){return i(n,t,r,e,o,s)}))},f=function(e,n,t){e=a(e);var r=!1,i=!0;if(void 0===n&&e){var o=t(void 0,e);i=o[1],r=o[2]}return[n&&n.map?n.map((function(n){return t(n,e)})).filter(s).map((function(e){return e[0]})):n,i,r]},h=function(e){function n(){return e.apply(this,arguments)||this}t(n,e);var r=n.prototype;return r.normalize=function(e,n,t,r,i,o){var a=this;return u(e).map((function(e,u){return a.normalizeValue(e,n,t,r,i,o)})).filter((function(e){return null!=e}))},r.denormalize=function(e,n){var t=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=n(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return t.denormalizeValue(e,n)})).filter(s).map((function(e){return e[0]})):e,i,r]},n}(o),l=function(e,n,t,r,i,o,a){var u=Object.assign({},n);return Object.keys(e).forEach((function(t){var r=e[t],s=i(n[t],n,t,r,o,a);null==s?delete u[t]:u[t]=s})),u},p=function(t,r,i){if(e(r))return n(t,r,i);var o=Object.assign({},r),a=!0,u=!1;return Object.keys(t).forEach((function(e){var n=i(o[e],t[e]),r=n[0],s=n[1],c=n[2];void 0!==o[e]&&(o[e]=r),c&&(u=!0),s||(a=!1)})),[o,a,u]},m=function(){function e(e){this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=Object.keys(e).reduce((function(n,t){var r,i=e[t];return Object.assign({},n,((r={})[t]=i,r))}),this.schema||{})},n.normalize=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return l.apply(void 0,[this.schema].concat(n))},n.denormalize=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return p.apply(void 0,[this.schema].concat(n))},e}();function d(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function y(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return d(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?d(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}var v=Symbol("Defined Members"),b=Symbol("unq"),g=function(){function e(){}return e.prototype.toString=function(){return this[b]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(n,t,r){void 0===n&&(n={});var i=new this(n);return n instanceof e&&(n=n.constructor.toObjectDefined(n)),Object.assign(i,n),Object.defineProperty(i,v,{value:Object.keys(n),writable:!1}),Object.defineProperty(i,b,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,n){var t=Object.assign(this.toObjectDefined(e),this.toObjectDefined(n));return this.fromJS(t)},e.hasDefined=function(e,n){return e[v].includes(n)},e.toObjectDefined=function(e){for(var n,t={},r=y(e[v]);!(n=r()).done;){var i=n.value;t[i]=e[i]}return t},e.keysDefined=function(e){return e[v]},e.normalize=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return l.apply(void 0,[this.schema].concat(n))},e.denormalize=function(e,n){var t=this,r=new this,i=Object.assign({},e),o=!1,a=!0;return Object.keys(this.schema).forEach((function(e){var u=n(i[e],t.schema[e]),s=u[0],c=u[1],f=u[2];void 0!==i[e]&&(i[e]=s),c||e in r&&!r[e]||(a=!1),!f||e in r&&!r[e]||(o=!0)})),[this.fromJS(i),a,o]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},e}();g.schema={};var O=function(r){function o(){return r.apply(this,arguments)||this}return t(o,r),o.toJSON=function(){return Object.assign({},r.toJSON.call(this),{key:this.key})},o.pk=function(e,n,t){return this.prototype.pk.call(e,n,t)||t},o.normalize=function(e,n,t,r,i,o){var a=this;if("string"==typeof e)return e;var u=this.fromJS(e,n,t);if("production"!==process.env.NODE_ENV){for(var s,c=new this,f=new Set(Object.keys(c)),h=this.keysDefined(u),l=[[],[],[]],p=l[0],m=l[1],d=l[2],v=y(h);!(s=v()).done;){var b=s.value;f.has(b)?p.push(b):d.push(b)}for(var g,O=y(f);!(g=O()).done;){var S=g.value;p.includes(S)||m.push(S)}if((Math.max(h.length/2,1)<=d.length&&f.size>Math.max(d.length,2)||p.length<Math.min(1,f.size/2))&&f.size){var 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: "+p+"\n Missing: "+m+"\n Unexpected keys: "+d+"\n Value: "+JSON.stringify(this.toObjectDefined(u),null,2));throw E.status=400,E}}var w=u.pk(n,t);if(void 0!==w&&""!==w){var k=this.key;return k in o||(o[k]={}),w in o[k]||(o[k][w]=[]),o[k][w].some((function(n){return n===e}))?w:(o[k][w].push(e),Object.keys(this.schema).forEach((function(e){if(Object.hasOwnProperty.call(u,e)){var n=a.schema[e];u[e]=r(u[e],u,e,n,i,o)}})),i(this,u,u,n,t),w)}if("production"!==process.env.NODE_ENV){var j=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 j.status=400,j}},o.denormalize=function(t,r){var i=this;if(e(t)){var o=n(this.schema,t,r),a=o[0],u=o[1],s=o[2];return[this.fromJS(a.toObject()),u,s]}var c=new this,f=!1,h=!0,l=t;return Object.keys(this.schema).forEach((function(e){var n=i.schema[e],o=i.hasDefined(t,e)?t[e]:void 0,a=r(o,n),u=a[0],s=a[1],p=a[2];s||e in c&&!c[e]||(h=!1),!p||e in c&&!c[e]||(f=!0),i.hasDefined(t,e)&&l[e]!==u&&(l[e]=u)})),[l,h,f]},i(o,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),o}(g);function S(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(O.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return g.fromJS.call(this,e)});var E=function(e){function n(){return e.apply(this,arguments)||this}return t(n,e),n.denormalize=function(e,n){return[e,!0,!1]},n}(O),w=Symbol("ENTITY WAS DELETED"),k=function(n){var t={},r=j(n);return[function n(i,o){if(!o)return[i,!0,!1];if(!o.denormalize||"function"!=typeof o.denormalize){if("function"==typeof o)return i instanceof o?[i,!0,!1]:[new o(i),!0,!1];if("object"==typeof o)return(Array.isArray(o)?f:p)(o,i,n)}return null===i?[i,!0,!1]:S(o)?void 0===i?[i,!1,!1]:function(n,t,r,i,o){var a=i(n,t);if(a===w)return[void 0,!0,!0];if("object"!=typeof a||null===a)return[a,!1,!1];o[t.key]||(o[t.key]={});var u=!0,s=!1;if(!o[t.key][n]){var c=e(a)||a instanceof E?a:t.fromJS(a);o[t.key][n]=c;var f=t.denormalize(c,r);o[t.key][n]=f[0],u=f[1],s=f[2]}return[o[t.key][n],u,s]}(i,o,n,r,t):"function"==typeof o.denormalize?o.denormalize(i,n):[i,!0,!1]},t]},j=function(n){var t=e(n);return function(e,r){var i=r.key;return"object"==typeof e?e:t?n.getIn([i,e]):n[i]&&n[i][e]}},z=function e(n,t,r,i,o,a){return n&&i&&["function","object"].includes(typeof i)?i.normalize&&"function"==typeof i.normalize?i.normalize(n,t,r,e,o,a):"function"==typeof i?new i(n):(Array.isArray(i)?c:l)(i,n,t,r,e,o,a):n};var _=function(e){function n(n,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,n,t)||this}t(n,e);var r=n.prototype;return r.normalize=function(e,n,t,r,i,o){return this.normalizeValue(e,n,t,r,i,o)},r.denormalize=function(e,n){return this.denormalizeValue(e,n)},n}(o),N=function(e){function n(){return e.apply(this,arguments)||this}t(n,e);var r=n.prototype;return r.normalize=function(e,n,t,r,i,o){var a=this;return Object.keys(e).reduce((function(n,t,u){var s,c=e[t];return null!=c?Object.assign({},n,((s={})[t]=a.normalizeValue(c,e,t,r,i,o),s)):n}),{})},r.denormalize=function(e,n){var t=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,a){var u,s=e[a],c=t.denormalizeValue(s,n),f=c[0],h=c[1],l=c[2];return h||(r=!1),l&&(i=!0),!h||l?o:Object.assign({},o,((u={})[a]=f,u))}),{}),r,i]},n}(o),A=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 n=e.prototype;return n.normalize=function(e,n,t,r,i,o){if("string"==typeof e)return e;var a=this._entity.fromJS(e,n,t),u=a.pk(n,t);return i(this._entity,w,a,n,t),u},n.denormalize=function(e,n){return n(e,this._entity)},n._denormalizeNullable=function(){return[]},n._normalizeNullable=function(){return[]},n.merge=function(e,n){return n},e}(),x=Object.freeze({__proto__:null,Union:_,Values:N,Array:h,Object:m,Delete:A});exports.DELETED=w,exports.Entity=O,exports.FlatEntity=E,exports.SimpleRecord=g,exports.denormalize=function(e,n,t){if("production"!==process.env.NODE_ENV&&void 0===n)throw new Error("schema needed");if(void 0!==e){var r=k(t),i=r[0],o=r[1];return[].concat(i(e,n),[o])}return[void 0,!1,!1,{}]},exports.isEntity=S,exports.normalize=function(e,n,t,r){void 0===t&&(t={});var i=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(n);if(null===e||typeof e!==i){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(n,void 0,2)+'\n Input: "'+e+'"'):new Error('Unexpected input given to normalize. Expected type to be "'+i+'", found "'+(null===e?"null":typeof e)+'".\n\n Schema: '+JSON.stringify(n,void 0,2)+'\n Input: "'+e+'"')}throw new Error('Unexpected input given to normalize. Expected type to be "'+i+'", found "'+(null===e?"null":typeof e)+'".')}var o={},a={},u=function(e,n,t,r){return function(r,i,o,a,u){var s=r.key,c=r.pk(o,a,u);s in e||(e[s]={});var f=e[s][c];if(e[s][c]=f?r.merge(f,i):i,Array.isArray(r.indexes)){var h=e[s][c];s in n||(n[s]={});for(var l,p=y(r.indexes);!(l=p()).done;){var m=l.value;m in n[s]||(n[s][m]={});var d=n[s][m];f&&delete d[f[m]],t[s]&&t[s][c]&&t[s][c][m]!==h[m]&&(d[t[s][c][m]]=w),m in h?d[h[m]]=c:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+m+"\nEntity: "+JSON.stringify(h,void 0,2))}}}}(o,a,t);return{entities:o,indexes:a,result:z(e,e,void 0,n,u,{})}},exports.schema=x; | ||
"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){var r=!0,i=!1;return[Object.keys(e).reduce((function(t,o){var u=""+o,a=n(t.get(u),e[u]),c=a[0],s=a[1],f=a[2];return s||(r=!1),f&&(i=!0),t.has(u)?t.set(u,c):t}),t),r,i]}function n(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}Object.defineProperty(exports,"__esModule",{value:!0});var o=function(){function t(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var n=t.prototype;return n.define=function(e){this.schema=e},n.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},n.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},n.normalizeValue=function(e,t,n,r,i,o){var u=this.inferSchema(e,t,n);if(!u)return e;var a=r(e,t,n,u,i,o);return this.isSingleSchema||null==a?a:{id:a,schema:this.getSchemaAttribute(e,t,n)}},n.denormalizeValue=function(t,n){var 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,!0]},i(t,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),t}(),u=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]},a=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},c=function(e){var t=e[1],n=e[2];return t&&!n},s=function(e,t,n,r,i,o,c){return e=u(e),a(t).map((function(t,u){return i(t,n,r,e,o,c)}))},f=function(e,t,n){e=u(e);var r=!1,i=!0;if(void 0===t&&e){var o=n(void 0,e);i=o[1],r=o[2]}return[t&&t.map?t.map((function(t){return n(t,e)})).filter(c).map((function(e){return e[0]})):t,i,r]},l=function(e){function t(){return e.apply(this,arguments)||this}n(t,e);var r=t.prototype;return r.normalize=function(e,t,n,r,i,o){var u=this;return a(e).map((function(e,a){return u.normalizeValue(e,t,n,r,i,o)})).filter((function(e){return null!=e}))},r.denormalize=function(e,t){var n=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=t(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return n.denormalizeValue(e,t)})).filter(c).map((function(e){return e[0]})):e,i,r]},t}(o),h=function(e,t,n,r,i,o,u){var a=Object.assign({},t);return Object.keys(e).forEach((function(n){var r=e[n],c=i(t[n],t,n,r,o,u);null==c?delete a[n]:a[n]=c})),a},p=function(n,r,i){if(e(r))return t(n,r,i);var o=Object.assign({},r),u=!0,a=!1;return Object.keys(n).forEach((function(e){var t=i(o[e],n[e]),r=t[0],c=t[1],s=t[2];void 0!==o[e]&&(o[e]=r),s&&(a=!0),c||(u=!1)})),[o,u,a]},y=function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var r,i=e[n];return Object.assign({},t,((r={})[n]=i,r))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return h.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 p.apply(void 0,[this.schema].concat(t))},e}();function m(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}function d(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}var v=Symbol("Defined Members"),b=Symbol("unq"),g=function(){function e(){}return e.prototype.toString=function(){return this[b]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(t,n,r){void 0===t&&(t={});var i=new this(t);return t instanceof e&&(t=t.constructor.toObjectDefined(t)),Object.assign(i,t),Object.defineProperty(i,v,{value:Object.keys(t),writable:!1}),Object.defineProperty(i,b,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,t){var n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)},e.hasDefined=function(e,t){return e[v].includes(t)},e.toObjectDefined=function(e){for(var t,n={},r=d(e[v]);!(t=r()).done;){var i=t.value;n[i]=e[i]}return n},e.keysDefined=function(e){return e[v]},e.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return h.apply(void 0,[this.schema].concat(t))},e.denormalize=function(e,t){var n=this,r=new this,i=Object.assign({},e),o=!1,u=!0;return Object.keys(this.schema).forEach((function(e){var a=t(i[e],n.schema[e]),c=a[0],s=a[1],f=a[2];void 0!==i[e]&&(i[e]=c),s||e in r&&!r[e]||(u=!1),!f||e in r&&!r[e]||(o=!0)})),[this.fromJS(i),u,o]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},e}();g.schema={};var O=function(r){function o(){return r.apply(this,arguments)||this}return n(o,r),o.toJSON=function(){return Object.assign({},r.toJSON.call(this),{key:this.key})},o.pk=function(e,t,n){return this.prototype.pk.call(e,t,n)||n},o.normalize=function(e,t,n,r,i,o){var u=this;if("string"==typeof e)return e;var a=this.fromJS(e,t,n);if("production"!==process.env.NODE_ENV){for(var c,s=new this,f=new Set(Object.keys(s)),l=this.keysDefined(a),h=[[],[],[]],p=h[0],y=h[1],m=h[2],v=d(l);!(c=v()).done;){var b=c.value;f.has(b)?p.push(b):m.push(b)}for(var g,O=d(f);!(g=O()).done;){var w=g.value;p.includes(w)||y.push(w)}if((Math.max(l.length/2,1)<=m.length&&f.size>Math.max(m.length,2)||p.length<Math.min(1,f.size/2))&&f.size){var S=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: "+p+"\n Missing: "+y+"\n Unexpected keys: "+m+"\n Value: "+JSON.stringify(this.toObjectDefined(a),null,2));throw S.status=400,S}}var k=a.pk(t,n);if(void 0!==k&&""!==k){var E=this.key;return E in o||(o[E]={}),k in o[E]||(o[E][k]=[]),o[E][k].some((function(t){return t===e}))?k:(o[E][k].push(e),Object.keys(this.schema).forEach((function(e){if(Object.hasOwnProperty.call(a,e)){var t=u.schema[e];a[e]=r(a[e],a,e,t,i,o)}})),i(this,a,a,t,n),k)}if("production"!==process.env.NODE_ENV){var j=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 j.status=400,j}},o.denormalize=function(n,r){var i=this;if(e(n)){var o=t(this.schema,n,r),u=o[0],a=o[1],c=o[2];return[this.fromJS(u.toObject()),a,c]}var s=new this,f=!1,l=!0,h=n;return Object.keys(this.schema).forEach((function(e){var t=i.schema[e],o=i.hasDefined(n,e)?n[e]:void 0,u=r(o,t),a=u[0],c=u[1],p=u[2];c||e in s&&!s[e]||(l=!1),!p||e in s&&!s[e]||(f=!0),i.hasDefined(n,e)&&h[e]!==a&&(h[e]=a)})),[h,l,f]},i(o,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),o}(g);function w(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(O.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return g.fromJS.call(this,e)});var S=Symbol("ENTITY WAS DELETED");function k(e){return(k=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function E(e,t){return(E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function j(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function z(e,t,n){return(z=j()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&E(i,n.prototype),i}).apply(null,arguments)}function _(e){var t="function"==typeof Map?new Map:void 0;return(_=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return z(e,arguments,k(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),E(r,e)})(e)}var N=function(){this.children=new WeakMap},x=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).message="Keys must include at least one member",t}return n(t,e),t}(_(Error)),A=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,i=0;i<e.length;i++)r.has(e[i])?n=r.get(e[i]):(n=new N,r.set(e[i],n)),r=n.children,i===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}(),D=function(t,n,r,i){var o=J(t);function u(t,r){if(!r)return[t,!0,!1];if(!r.denormalize||"function"!=typeof r.denormalize){if("function"==typeof r)return t instanceof r?[t,!0,!1]:[new r(t),!0,!1];if("object"==typeof r)return(Array.isArray(r)?f:p)(r,t,c)}return null===t?[t,!0,!1]:w(r)?void 0===t?[t,!1,!1]:function(t,n,r,i,o,u){var a=i(t,n);if(a===S)return[void 0,!0,!0];if("object"!=typeof a||null===a)return[a,!1,!1];void 0===o[n.key]&&(o[n.key]={});var c=!0,s=!1;if(!o[n.key][t]){var f=[a],l=V(r,f);u[n.key]||(u[n.key]={}),u[n.key][t]||(u[n.key][t]=new A);var h=u[n.key][t],p=e(a)?a:n.fromJS(a);o[n.key][t]=p;var y=n.denormalize(p,l);o[n.key][t]=y[0],c=y[1],s=y[2],h.has(f)?o[n.key][t]=h.get(f):h.set(f,o[n.key][t])}return[o[n.key][t],c,s]}(t,r,c,o,i,n):"function"==typeof r.denormalize?r.denormalize(t,c):[t,!0,!1]}var a=[],c=V(u,a);return function(e,t){a.push(e);var n=u(e,t);return"object"!=typeof e?n:r.has(a)?[r.get(a),n[1],n[2]]:(r.set(a,n[0]),n)}},J=function(t){var n=e(t);return function(e,r){var i=r.key;return"object"==typeof e?e:n?t.getIn([i,e]):t[i]&&t[i][e]}};function V(e,t){var n=e.og||e,r=function(e,r){var i=n(e,r);return i[0]&&r&&w(r)&&t.push(i[0]),i};return r.og=e,r}var P=function e(t,n,r,i,o,u){return t&&i&&["function","object"].includes(typeof i)?i.normalize&&"function"==typeof i.normalize?i.normalize(t,n,r,e,o,u):"function"==typeof i?new i(t):(Array.isArray(i)?s:h)(i,t,n,r,e,o,u):t};var M=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}n(t,e);var r=t.prototype;return r.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},r.denormalize=function(e,t){return this.denormalizeValue(e,t)},t}(o),I=function(e){function t(){return e.apply(this,arguments)||this}n(t,e);var r=t.prototype;return r.normalize=function(e,t,n,r,i,o){var u=this;return Object.keys(e).reduce((function(t,n,a){var c,s=e[n];return null!=s?Object.assign({},t,((c={})[n]=u.normalizeValue(s,e,n,r,i,o),c)):t}),{})},r.denormalize=function(e,t){var n=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,u){var a,c=e[u],s=n.denormalizeValue(c,t),f=s[0],l=s[1],h=s[2];return l||(r=!1),h&&(i=!0),!l||h?o:Object.assign({},o,((a={})[u]=f,a))}),{}),r,i]},t}(o),T=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,i,o){if("string"==typeof e)return e;var u=this._entity.fromJS(e,t,n),a=u.pk(t,n);return i(this._entity,S,u,t,n),a},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},e}(),R=Object.freeze({__proto__:null,Union:M,Values:I,Array:l,Object:y,Delete:T}),U=function(e){function t(){return e.apply(this,arguments)||this}return n(t,e),t.denormalize=function(e,t){return[e,!0,!1]},t}(O);exports.DELETED=S,exports.Entity=O,exports.FlatEntity=U,exports.SimpleRecord=g,exports.WeakListMap=A,exports.denormalize=function(e,t,n,r,i){if(void 0===r&&(r={}),void 0===i&&(i=new A),"production"!==process.env.NODE_ENV&&void 0===t)throw new Error("schema needed");if(void 0===e)return[void 0,!1,!1,{}];var o={},u=D(n,r,i,o);return[].concat(u(e,t),[o])},exports.isEntity=w,exports.normalize=function(e,t,n,r){void 0===n&&(n={});var i=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==i){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 "'+i+'", 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 "'+i+'", found "'+(null===e?"null":typeof e)+'".')}var o={},u={},a=function(e,t,n,r){return function(r,i,o,u,a){var c=r.key,s=r.pk(o,u,a);c in e||(e[c]={});var f=e[c][s];if(e[c][s]=f?r.merge(f,i):i,Array.isArray(r.indexes)){var l=e[c][s];c in t||(t[c]={});for(var h,p=d(r.indexes);!(h=p()).done;){var y=h.value;y in t[c]||(t[c][y]={});var m=t[c][y];f&&delete m[f[y]],n[c]&&n[c][s]&&n[c][s][y]!==l[y]&&(m[n[c][s][y]]=S),y in l?m[l[y]]=s:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+y+"\nEntity: "+JSON.stringify(l,void 0,2))}}}}(o,u,n);return{entities:o,indexes:u,result:P(e,e,void 0,t,a,{})}},exports.schema=R; |
@@ -630,3 +630,3 @@ (function (global, factory) { | ||
Entity.denormalize = function denormalize(entity, unvisit) { | ||
Entity.denormalize = function denormalize(input, unvisit) { | ||
var _this2 = this; | ||
@@ -636,4 +636,4 @@ | ||
// itself in cache. Once we offer full memoization, we will store raw objects and this can be consolidated with SimpleRecord | ||
if (isImmutable(entity)) { | ||
var _denormalizeImmutable = denormalizeImmutable(this.schema, entity, unvisit), | ||
if (isImmutable(input)) { | ||
var _denormalizeImmutable = denormalizeImmutable(this.schema, input, unvisit), | ||
_denormEntity = _denormalizeImmutable[0], | ||
@@ -650,8 +650,9 @@ _found = _denormalizeImmutable[1], | ||
var found = true; | ||
var denormEntity = entity; | ||
var denormEntity = input; // note: iteration order must be stable | ||
Object.keys(this.schema).forEach(function (key) { | ||
var schema = _this2.schema[key]; | ||
var input = _this2.hasDefined(entity, key) ? entity[key] : undefined; | ||
var nextInput = _this2.hasDefined(input, key) ? input[key] : undefined; | ||
var _unvisit = unvisit(input, schema), | ||
var _unvisit = unvisit(nextInput, schema), | ||
value = _unvisit[0], | ||
@@ -671,3 +672,3 @@ foundItem = _unvisit[1], | ||
if (_this2.hasDefined(entity, key) && denormEntity[key] !== value) { | ||
if (_this2.hasDefined(input, key) && denormEntity[key] !== value) { | ||
denormEntity[key] = value; | ||
@@ -708,19 +709,180 @@ } | ||
var FlatEntity = /*#__PURE__*/function (_Entity) { | ||
_inheritsLoose(FlatEntity, _Entity); | ||
var DELETED = Symbol('ENTITY WAS DELETED'); | ||
function FlatEntity() { | ||
return _Entity.apply(this, arguments) || this; | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _isNativeFunction(fn) { | ||
return Function.toString.call(fn).indexOf("[native code]") !== -1; | ||
} | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
FlatEntity.denormalize = function denormalize(entity, unvisit) { | ||
return [entity, true, false]; | ||
function _construct(Parent, args, Class) { | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _construct.apply(null, arguments); | ||
} | ||
function _wrapNativeSuper(Class) { | ||
var _cache = typeof Map === "function" ? new Map() : undefined; | ||
_wrapNativeSuper = function _wrapNativeSuper(Class) { | ||
if (Class === null || !_isNativeFunction(Class)) return Class; | ||
if (typeof Class !== "function") { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
if (typeof _cache !== "undefined") { | ||
if (_cache.has(Class)) return _cache.get(Class); | ||
_cache.set(Class, Wrapper); | ||
} | ||
function Wrapper() { | ||
return _construct(Class, arguments, _getPrototypeOf(this).constructor); | ||
} | ||
Wrapper.prototype = Object.create(Class.prototype, { | ||
constructor: { | ||
value: Wrapper, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
return _setPrototypeOf(Wrapper, Class); | ||
}; | ||
return FlatEntity; | ||
}(Entity); | ||
return _wrapNativeSuper(Class); | ||
} | ||
var DELETED = Symbol('ENTITY WAS DELETED'); | ||
/** Link in a chain */ | ||
var Link = function Link() { | ||
this.children = new WeakMap(); | ||
}; | ||
var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, cache) { | ||
var KeySize = /*#__PURE__*/function (_Error) { | ||
_inheritsLoose(KeySize, _Error); | ||
function KeySize() { | ||
var _this; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _Error.call.apply(_Error, [this].concat(args)) || this; | ||
_this.message = 'Keys must include at least one member'; | ||
return _this; | ||
} | ||
return KeySize; | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
/** Maps from a list of objects (referentially) to any value | ||
* | ||
* If *any* members of the list get claned up, so does that key/value pair get removed. | ||
*/ | ||
var WeakListMap = /*#__PURE__*/function () { | ||
function WeakListMap() { | ||
this.first = new WeakMap(); | ||
} | ||
var _proto = WeakListMap.prototype; | ||
_proto.delete = function _delete(key) { | ||
var link = this.traverse(key); | ||
link === null || link === void 0 ? true : delete link.value; | ||
return !!link; | ||
}; | ||
_proto.get = function get(key) { | ||
var link = this.traverse(key); | ||
return link === null || link === void 0 ? void 0 : link.value; | ||
}; | ||
_proto.has = function has(key) { | ||
var link = this.traverse(key); | ||
if (!link) return false; | ||
return Object.prototype.hasOwnProperty.call(link, 'value'); | ||
}; | ||
_proto.set = function set(key, value) { | ||
if (key.length < 1) throw new KeySize(); | ||
var cur = this.first; | ||
var link; | ||
for (var i = 0; i < key.length; i++) { | ||
if (!cur.has(key[i])) { | ||
link = new Link(); | ||
cur.set(key[i], link); | ||
} else { | ||
link = cur.get(key[i]); | ||
} | ||
cur = link.children; // do on later iteration of loop. this makes typescript happy rather than putting after loop | ||
if (i === key.length - 1) { | ||
link.value = value; | ||
} | ||
} | ||
return this; | ||
}; | ||
_proto.traverse = function traverse(key) { | ||
var cur = this.first; | ||
var link; | ||
for (var i = 0; i < key.length; i++) { | ||
link = cur.get(key[i]); | ||
if (!link) return; | ||
cur = link.children; | ||
} | ||
return link; | ||
}; | ||
return WeakListMap; | ||
}(); | ||
var unvisitEntity = function unvisitEntity(id, schema, unvisit, getEntity, localCache, entityCache) { | ||
var entity = getEntity(id, schema); | ||
@@ -736,4 +898,4 @@ | ||
if (!cache[schema.key]) { | ||
cache[schema.key] = {}; | ||
if (localCache[schema.key] === undefined) { | ||
localCache[schema.key] = {}; | ||
} | ||
@@ -744,23 +906,36 @@ | ||
if (!cache[schema.key][id]) { | ||
// Ensure we don't mutate it non-immutable objects | ||
var entityCopy = isImmutable(entity) || entity instanceof FlatEntity ? entity : schema.fromJS(entity); // Need to set this first so that if it is referenced further within the | ||
if (!localCache[schema.key][id]) { | ||
var globalKey = [entity]; | ||
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey); | ||
if (!entityCache[schema.key]) entityCache[schema.key] = {}; | ||
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap(); | ||
var globalCacheEntry = entityCache[schema.key][id]; | ||
var entityCopy = isImmutable(entity) ? entity : schema.fromJS(entity); // Need to set this first so that if it is referenced further within the | ||
// denormalization the reference will already exist. | ||
cache[schema.key][id] = entityCopy; | ||
localCache[schema.key][id] = entityCopy; | ||
var _schema$denormalize = schema.denormalize(entityCopy, unvisit); | ||
var _schema$denormalize = schema.denormalize(entityCopy, wrappedUnvisit); | ||
cache[schema.key][id] = _schema$denormalize[0]; | ||
localCache[schema.key][id] = _schema$denormalize[0]; | ||
found = _schema$denormalize[1]; | ||
deleted = _schema$denormalize[2]; | ||
if (!globalCacheEntry.has(globalKey)) { | ||
globalCacheEntry.set(globalKey, localCache[schema.key][id]); | ||
} else { | ||
// localCache is only used before this point for recursive relationships | ||
// since recursive relationships must all referentially change if *any* do, we either | ||
// get the correct one here, or will never find the same version in the cache | ||
localCache[schema.key][id] = globalCacheEntry.get(globalKey); | ||
} | ||
} | ||
return [cache[schema.key][id], found, deleted]; | ||
return [localCache[schema.key][id], found, deleted]; | ||
}; | ||
var getUnvisit = function getUnvisit(entities) { | ||
var cache = {}; | ||
var getUnvisit = function getUnvisit(entities, entityCache, resultCache, localCache) { | ||
var getEntity = getEntities(entities); | ||
return [function unvisit(input, schema) { | ||
function unvisit(input, schema) { | ||
if (!schema) return [input, true, false]; | ||
@@ -774,3 +949,3 @@ | ||
var method = Array.isArray(schema) ? denormalize : _denormalize; | ||
return method(schema, input, unvisit); | ||
return method(schema, input, wrappedUnvisit); | ||
} | ||
@@ -790,11 +965,26 @@ } // null is considered intentional, thus always 'found' as true | ||
return unvisitEntity(input, schema, unvisit, getEntity, cache); | ||
return unvisitEntity(input, schema, wrappedUnvisit, getEntity, localCache, entityCache); | ||
} | ||
if (typeof schema.denormalize === 'function') { | ||
return schema.denormalize(input, unvisit); | ||
return schema.denormalize(input, wrappedUnvisit); | ||
} | ||
return [input, true, false]; | ||
}, cache]; | ||
} | ||
var globalKey = []; | ||
var wrappedUnvisit = withTrackedEntities(unvisit, globalKey); | ||
return function (input, schema) { | ||
globalKey.push(input); | ||
var ret = unvisit(input, schema); | ||
if (typeof input !== 'object') return ret; | ||
if (!resultCache.has(globalKey)) { | ||
resultCache.set(globalKey, ret[0]); | ||
return ret; | ||
} else { | ||
return [resultCache.get(globalKey), ret[1], ret[2]]; | ||
} | ||
}; | ||
}; | ||
@@ -817,20 +1007,44 @@ | ||
}; | ||
}; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
var denormalize$1 = function denormalize(input, schema, entities, entityCache, resultCache) { | ||
if (entityCache === void 0) { | ||
entityCache = {}; | ||
} | ||
var denormalize$1 = function denormalize(input, schema, entities) { | ||
if (resultCache === void 0) { | ||
resultCache = new WeakListMap(); | ||
} | ||
/* istanbul ignore next */ | ||
if (process.env.NODE_ENV !== 'production' && schema === undefined) throw new Error('schema needed'); | ||
if (process.env.NODE_ENV !== 'production' && schema === undefined) { | ||
throw new Error('schema needed'); | ||
} | ||
if (typeof input !== 'undefined') { | ||
var _getUnvisit = getUnvisit(entities), | ||
unvisit = _getUnvisit[0], | ||
cache = _getUnvisit[1]; | ||
return [].concat(unvisit(input, schema), [cache]); | ||
if (typeof input === 'undefined') { | ||
return [undefined, false, false, {}]; | ||
} | ||
return [undefined, false, false, {}]; | ||
var resolvedEntities = {}; | ||
var unvisit = getUnvisit(entities, entityCache, resultCache, resolvedEntities); | ||
return [].concat(unvisit(input, schema), [resolvedEntities]); | ||
}; | ||
function withTrackedEntities(unvisit, globalKey) { | ||
// every time we nest, we want to unwrap back to the top. | ||
// this is due to only needed the next level of nested entities for lookup | ||
var originalUnvisit = unvisit.og || unvisit; | ||
var wrappedUnvisit = function wrappedUnvisit(input, schema) { | ||
var ret = originalUnvisit(input, schema); // pass over undefined in key | ||
if (ret[0] && schema && isEntity(schema)) globalKey.push(ret[0]); | ||
return ret; | ||
}; | ||
wrappedUnvisit.og = unvisit; | ||
return wrappedUnvisit; | ||
} | ||
var visit = function visit(value, parent, key, schema, addEntity, visitedEntities) { | ||
@@ -1090,2 +1304,17 @@ if (!value || !schema || !['function', 'object'].includes(typeof schema)) { | ||
/** @deprecated */ | ||
var FlatEntity = /*#__PURE__*/function (_Entity) { | ||
_inheritsLoose(FlatEntity, _Entity); | ||
function FlatEntity() { | ||
return _Entity.apply(this, arguments) || this; | ||
} | ||
FlatEntity.denormalize = function denormalize(entity, unvisit) { | ||
return [entity, true, false]; | ||
}; | ||
return FlatEntity; | ||
}(Entity); | ||
exports.DELETED = DELETED; | ||
@@ -1095,2 +1324,3 @@ exports.Entity = Entity; | ||
exports.SimpleRecord = SimpleRecord; | ||
exports.WeakListMap = WeakListMap; | ||
exports.denormalize = denormalize$1; | ||
@@ -1097,0 +1327,0 @@ exports.isEntity = isEntity; |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).rest_hooks_normalizr={})}(this,(function(e){"use strict";function n(e){return!(!e||"function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}function t(e,n,t){var r=!0,i=!1;return[Object.keys(e).reduce((function(n,o){var a=""+o,u=t(n.get(a),e[a]),s=u[0],c=u[1],f=u[2];return c||(r=!1),f&&(i=!0),n.has(a)?n.set(a,s):n}),n),r,i]}function r(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n}function i(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,n,t){return n&&i(e.prototype,n),t&&i(e,t),e}var a=function(){function e(e,n){n&&(this._schemaAttribute="string"==typeof n?function(e){return e[n]}:n),this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=e},t.getSchemaAttribute=function(e,n,t){return!this.isSingleSchema&&this._schemaAttribute(e,n,t)},t.inferSchema=function(e,n,t){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,n,t);return this.schema[r]},t.normalizeValue=function(e,n,t,r,i,o){var a=this.inferSchema(e,n,t);if(!a)return e;var u=r(e,n,t,a,i,o);return this.isSingleSchema||null==u?u:{id:u,schema:this.getSchemaAttribute(e,n,t)}},t.denormalizeValue=function(e,t){var r=n(e)?e.get("schema"):e.schema;return this.isSingleSchema||r?t((this.isSingleSchema?void 0:n(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r]):[e,!0,!0]},o(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),u=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]},s=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(n){return e[n]}))},c=function(e){var n=e[1],t=e[2];return n&&!t},f=function(e,n,t,r,i,o,a){return e=u(e),s(n).map((function(n,u){return i(n,t,r,e,o,a)}))},l=function(e,n,t){e=u(e);var r=!1,i=!0;if(void 0===n&&e){var o=t(void 0,e);i=o[1],r=o[2]}return[n&&n.map?n.map((function(n){return t(n,e)})).filter(c).map((function(e){return e[0]})):n,i,r]},h=function(e){function n(){return e.apply(this,arguments)||this}r(n,e);var t=n.prototype;return t.normalize=function(e,n,t,r,i,o){var a=this;return s(e).map((function(e,u){return a.normalizeValue(e,n,t,r,i,o)})).filter((function(e){return null!=e}))},t.denormalize=function(e,n){var t=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=n(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return t.denormalizeValue(e,n)})).filter(c).map((function(e){return e[0]})):e,i,r]},n}(a),m=function(e,n,t,r,i,o,a){var u=Object.assign({},n);return Object.keys(e).forEach((function(t){var r=e[t],s=i(n[t],n,t,r,o,a);null==s?delete u[t]:u[t]=s})),u},p=function(e,r,i){if(n(r))return t(e,r,i);var o=Object.assign({},r),a=!0,u=!1;return Object.keys(e).forEach((function(n){var t=i(o[n],e[n]),r=t[0],s=t[1],c=t[2];void 0!==o[n]&&(o[n]=r),c&&(u=!0),s||(a=!1)})),[o,a,u]},d=function(){function e(e){this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=Object.keys(e).reduce((function(n,t){var r,i=e[t];return Object.assign({},n,((r={})[t]=i,r))}),this.schema||{})},n.normalize=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return m.apply(void 0,[this.schema].concat(n))},n.denormalize=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return p.apply(void 0,[this.schema].concat(n))},e}();function y(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function v(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return y(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?y(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}var b=Symbol("Defined Members"),g=Symbol("unq"),O=function(){function e(){}return e.prototype.toString=function(){return this[g]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(n,t,r){void 0===n&&(n={});var i=new this(n);return n instanceof e&&(n=n.constructor.toObjectDefined(n)),Object.assign(i,n),Object.defineProperty(i,b,{value:Object.keys(n),writable:!1}),Object.defineProperty(i,g,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,n){var t=Object.assign(this.toObjectDefined(e),this.toObjectDefined(n));return this.fromJS(t)},e.hasDefined=function(e,n){return e[b].includes(n)},e.toObjectDefined=function(e){for(var n,t={},r=v(e[b]);!(n=r()).done;){var i=n.value;t[i]=e[i]}return t},e.keysDefined=function(e){return e[b]},e.normalize=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return m.apply(void 0,[this.schema].concat(n))},e.denormalize=function(e,n){var t=this,r=new this,i=Object.assign({},e),o=!1,a=!0;return Object.keys(this.schema).forEach((function(e){var u=n(i[e],t.schema[e]),s=u[0],c=u[1],f=u[2];void 0!==i[e]&&(i[e]=s),c||e in r&&!r[e]||(a=!1),!f||e in r&&!r[e]||(o=!0)})),[this.fromJS(i),a,o]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},e}();O.schema={};var S=function(e){function i(){return e.apply(this,arguments)||this}return r(i,e),i.toJSON=function(){return Object.assign({},e.toJSON.call(this),{key:this.key})},i.pk=function(e,n,t){return this.prototype.pk.call(e,n,t)||t},i.normalize=function(e,n,t,r,i,o){var a=this;if("string"==typeof e)return e;var u=this.fromJS(e,n,t);if("production"!==process.env.NODE_ENV){for(var s,c=new this,f=new Set(Object.keys(c)),l=this.keysDefined(u),h=[[],[],[]],m=h[0],p=h[1],d=h[2],y=v(l);!(s=y()).done;){var b=s.value;f.has(b)?m.push(b):d.push(b)}for(var g,O=v(f);!(g=O()).done;){var S=g.value;m.includes(S)||p.push(S)}if((Math.max(l.length/2,1)<=d.length&&f.size>Math.max(d.length,2)||m.length<Math.min(1,f.size/2))&&f.size){var 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: "+m+"\n Missing: "+p+"\n Unexpected keys: "+d+"\n Value: "+JSON.stringify(this.toObjectDefined(u),null,2));throw E.status=400,E}}var w=u.pk(n,t);if(void 0!==w&&""!==w){var k=this.key;return k in o||(o[k]={}),w in o[k]||(o[k][w]=[]),o[k][w].some((function(n){return n===e}))?w:(o[k][w].push(e),Object.keys(this.schema).forEach((function(e){if(Object.hasOwnProperty.call(u,e)){var n=a.schema[e];u[e]=r(u[e],u,e,n,i,o)}})),i(this,u,u,n,t),w)}if("production"!==process.env.NODE_ENV){var j=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 j.status=400,j}},i.denormalize=function(e,r){var i=this;if(n(e)){var o=t(this.schema,e,r),a=o[0],u=o[1],s=o[2];return[this.fromJS(a.toObject()),u,s]}var c=new this,f=!1,l=!0,h=e;return Object.keys(this.schema).forEach((function(n){var t=i.schema[n],o=i.hasDefined(e,n)?e[n]:void 0,a=r(o,t),u=a[0],s=a[1],m=a[2];s||n in c&&!c[n]||(l=!1),!m||n in c&&!c[n]||(f=!0),i.hasDefined(e,n)&&h[n]!==u&&(h[n]=u)})),[h,l,f]},o(i,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),i}(O);function E(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(S.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return O.fromJS.call(this,e)});var w=function(e){function n(){return e.apply(this,arguments)||this}return r(n,e),n.denormalize=function(e,n){return[e,!0,!1]},n}(S),k=Symbol("ENTITY WAS DELETED"),j=function(e){var t={},r=z(e);return[function e(i,o){if(!o)return[i,!0,!1];if(!o.denormalize||"function"!=typeof o.denormalize){if("function"==typeof o)return i instanceof o?[i,!0,!1]:[new o(i),!0,!1];if("object"==typeof o)return(Array.isArray(o)?l:p)(o,i,e)}return null===i?[i,!0,!1]:E(o)?void 0===i?[i,!1,!1]:function(e,t,r,i,o){var a=i(e,t);if(a===k)return[void 0,!0,!0];if("object"!=typeof a||null===a)return[a,!1,!1];o[t.key]||(o[t.key]={});var u=!0,s=!1;if(!o[t.key][e]){var c=n(a)||a instanceof w?a:t.fromJS(a);o[t.key][e]=c;var f=t.denormalize(c,r);o[t.key][e]=f[0],u=f[1],s=f[2]}return[o[t.key][e],u,s]}(i,o,e,r,t):"function"==typeof o.denormalize?o.denormalize(i,e):[i,!0,!1]},t]},z=function(e){var t=n(e);return function(n,r){var i=r.key;return"object"==typeof n?n:t?e.getIn([i,n]):e[i]&&e[i][n]}},_=function e(n,t,r,i,o,a){return n&&i&&["function","object"].includes(typeof i)?i.normalize&&"function"==typeof i.normalize?i.normalize(n,t,r,e,o,a):"function"==typeof i?new i(n):(Array.isArray(i)?f:m)(i,n,t,r,e,o,a):n};var N=function(e){function n(n,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,n,t)||this}r(n,e);var t=n.prototype;return t.normalize=function(e,n,t,r,i,o){return this.normalizeValue(e,n,t,r,i,o)},t.denormalize=function(e,n){return this.denormalizeValue(e,n)},n}(a),A=function(e){function n(){return e.apply(this,arguments)||this}r(n,e);var t=n.prototype;return t.normalize=function(e,n,t,r,i,o){var a=this;return Object.keys(e).reduce((function(n,t,u){var s,c=e[t];return null!=c?Object.assign({},n,((s={})[t]=a.normalizeValue(c,e,t,r,i,o),s)):n}),{})},t.denormalize=function(e,n){var t=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,a){var u,s=e[a],c=t.denormalizeValue(s,n),f=c[0],l=c[1],h=c[2];return l||(r=!1),h&&(i=!0),!l||h?o:Object.assign({},o,((u={})[a]=f,u))}),{}),r,i]},n}(a),D=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 n=e.prototype;return n.normalize=function(e,n,t,r,i,o){if("string"==typeof e)return e;var a=this._entity.fromJS(e,n,t),u=a.pk(n,t);return i(this._entity,k,a,n,t),u},n.denormalize=function(e,n){return n(e,this._entity)},n._denormalizeNullable=function(){return[]},n._normalizeNullable=function(){return[]},n.merge=function(e,n){return n},e}(),x=Object.freeze({__proto__:null,Union:N,Values:A,Array:h,Object:d,Delete:D});e.DELETED=k,e.Entity=S,e.FlatEntity=w,e.SimpleRecord=O,e.denormalize=function(e,n,t){if("production"!==process.env.NODE_ENV&&void 0===n)throw new Error("schema needed");if(void 0!==e){var r=j(t),i=r[0],o=r[1];return[].concat(i(e,n),[o])}return[void 0,!1,!1,{}]},e.isEntity=E,e.normalize=function(e,n,t,r){void 0===t&&(t={});var i=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(n);if(null===e||typeof e!==i){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(n,void 0,2)+'\n Input: "'+e+'"'):new Error('Unexpected input given to normalize. Expected type to be "'+i+'", found "'+(null===e?"null":typeof e)+'".\n\n Schema: '+JSON.stringify(n,void 0,2)+'\n Input: "'+e+'"')}throw new Error('Unexpected input given to normalize. Expected type to be "'+i+'", found "'+(null===e?"null":typeof e)+'".')}var o={},a={},u=function(e,n,t,r){return function(r,i,o,a,u){var s=r.key,c=r.pk(o,a,u);s in e||(e[s]={});var f=e[s][c];if(e[s][c]=f?r.merge(f,i):i,Array.isArray(r.indexes)){var l=e[s][c];s in n||(n[s]={});for(var h,m=v(r.indexes);!(h=m()).done;){var p=h.value;p in n[s]||(n[s][p]={});var d=n[s][p];f&&delete d[f[p]],t[s]&&t[s][c]&&t[s][c][p]!==l[p]&&(d[t[s][c][p]]=k),p in l?d[l[p]]=c:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+p+"\nEntity: "+JSON.stringify(l,void 0,2))}}}}(o,a,t);return{entities:o,indexes:a,result:_(e,e,void 0,n,u,{})}},e.schema=x,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="undefined"!=typeof globalThis?globalThis: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){var r=!0,i=!1;return[Object.keys(e).reduce((function(t,o){var u=""+o,a=n(t.get(u),e[u]),c=a[0],s=a[1],f=a[2];return s||(r=!1),f&&(i=!0),t.has(u)?t.set(u,c):t}),t),r,i]}function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}var u=function(){function e(e,t){t&&(this._schemaAttribute="string"==typeof t?function(e){return e[t]}:t),this.define(e)}var n=e.prototype;return n.define=function(e){this.schema=e},n.getSchemaAttribute=function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)},n.inferSchema=function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]},n.normalizeValue=function(e,t,n,r,i,o){var u=this.inferSchema(e,t,n);if(!u)return e;var a=r(e,t,n,u,i,o);return this.isSingleSchema||null==a?a:{id:a,schema:this.getSchemaAttribute(e,t,n)}},n.denormalizeValue=function(e,n){var 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,!0]},o(e,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),a=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]},c=function(e){return Array.isArray(e)?e:Object.keys(e).map((function(t){return e[t]}))},s=function(e){var t=e[1],n=e[2];return t&&!n},f=function(e,t,n,r,i,o,u){return e=a(e),c(t).map((function(t,a){return i(t,n,r,e,o,u)}))},l=function(e,t,n){e=a(e);var r=!1,i=!0;if(void 0===t&&e){var o=n(void 0,e);i=o[1],r=o[2]}return[t&&t.map?t.map((function(t){return n(t,e)})).filter(s).map((function(e){return e[0]})):t,i,r]},h=function(e){function t(){return e.apply(this,arguments)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var u=this;return c(e).map((function(e,a){return u.normalizeValue(e,t,n,r,i,o)})).filter((function(e){return null!=e}))},n.denormalize=function(e,t){var n=this,r=!1,i=!0;if(void 0===e&&this.schema){var o=t(void 0,this.schema);i=o[1],r=o[2]}return[e&&e.map?e.map((function(e){return n.denormalizeValue(e,t)})).filter(s).map((function(e){return e[0]})):e,i,r]},t}(u),p=function(e,t,n,r,i,o,u){var a=Object.assign({},t);return Object.keys(e).forEach((function(n){var r=e[n],c=i(t[n],t,n,r,o,u);null==c?delete a[n]:a[n]=c})),a},y=function(e,r,i){if(t(r))return n(e,r,i);var o=Object.assign({},r),u=!0,a=!1;return Object.keys(e).forEach((function(t){var n=i(o[t],e[t]),r=n[0],c=n[1],s=n[2];void 0!==o[t]&&(o[t]=r),s&&(a=!0),c||(u=!1)})),[o,u,a]},d=function(){function e(e){this.define(e)}var t=e.prototype;return t.define=function(e){this.schema=Object.keys(e).reduce((function(t,n){var r,i=e[n];return Object.assign({},t,((r={})[n]=i,r))}),this.schema||{})},t.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return p.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 y.apply(void 0,[this.schema].concat(t))},e}();function m(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}function v(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}var b=Symbol("Defined Members"),g=Symbol("unq"),O=function(){function e(){}return e.prototype.toString=function(){return this[g]},e.toJSON=function(){return{name:this.name,schema:this.schema}},e.fromJS=function(t,n,r){void 0===t&&(t={});var i=new this(t);return t instanceof e&&(t=t.constructor.toObjectDefined(t)),Object.assign(i,t),Object.defineProperty(i,b,{value:Object.keys(t),writable:!1}),Object.defineProperty(i,g,{value:""+Math.random(),writable:!1}),i},e.merge=function(e,t){var n=Object.assign(this.toObjectDefined(e),this.toObjectDefined(t));return this.fromJS(n)},e.hasDefined=function(e,t){return e[b].includes(t)},e.toObjectDefined=function(e){for(var t,n={},r=v(e[b]);!(t=r()).done;){var i=t.value;n[i]=e[i]}return n},e.keysDefined=function(e){return e[b]},e.normalize=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return p.apply(void 0,[this.schema].concat(t))},e.denormalize=function(e,t){var n=this,r=new this,i=Object.assign({},e),o=!1,u=!0;return Object.keys(this.schema).forEach((function(e){var a=t(i[e],n.schema[e]),c=a[0],s=a[1],f=a[2];void 0!==i[e]&&(i[e]=c),s||e in r&&!r[e]||(u=!1),!f||e in r&&!r[e]||(o=!0)})),[this.fromJS(i),u,o]},e.asSchema=function(){return"development"===process.env.NODE_ENV&&console.error("asSchema() is deprecated - use Entity directly instead."),this},e}();O.schema={};var w=function(e){function i(){return e.apply(this,arguments)||this}return r(i,e),i.toJSON=function(){return Object.assign({},e.toJSON.call(this),{key:this.key})},i.pk=function(e,t,n){return this.prototype.pk.call(e,t,n)||n},i.normalize=function(e,t,n,r,i,o){var u=this;if("string"==typeof e)return e;var a=this.fromJS(e,t,n);if("production"!==process.env.NODE_ENV){for(var c,s=new this,f=new Set(Object.keys(s)),l=this.keysDefined(a),h=[[],[],[]],p=h[0],y=h[1],d=h[2],m=v(l);!(c=m()).done;){var b=c.value;f.has(b)?p.push(b):d.push(b)}for(var g,O=v(f);!(g=O()).done;){var w=g.value;p.includes(w)||y.push(w)}if((Math.max(l.length/2,1)<=d.length&&f.size>Math.max(d.length,2)||p.length<Math.min(1,f.size/2))&&f.size){var S=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: "+p+"\n Missing: "+y+"\n Unexpected keys: "+d+"\n Value: "+JSON.stringify(this.toObjectDefined(a),null,2));throw S.status=400,S}}var k=a.pk(t,n);if(void 0!==k&&""!==k){var E=this.key;return E in o||(o[E]={}),k in o[E]||(o[E][k]=[]),o[E][k].some((function(t){return t===e}))?k:(o[E][k].push(e),Object.keys(this.schema).forEach((function(e){if(Object.hasOwnProperty.call(a,e)){var t=u.schema[e];a[e]=r(a[e],a,e,t,i,o)}})),i(this,a,a,t,n),k)}if("production"!==process.env.NODE_ENV){var j=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 j.status=400,j}},i.denormalize=function(e,r){var i=this;if(t(e)){var o=n(this.schema,e,r),u=o[0],a=o[1],c=o[2];return[this.fromJS(u.toObject()),a,c]}var s=new this,f=!1,l=!0,h=e;return Object.keys(this.schema).forEach((function(t){var n=i.schema[t],o=i.hasDefined(e,t)?e[t]:void 0,u=r(o,n),a=u[0],c=u[1],p=u[2];c||t in s&&!s[t]||(l=!1),!p||t in s&&!s[t]||(f=!0),i.hasDefined(e,t)&&h[t]!==a&&(h[t]=a)})),[h,l,f]},o(i,null,[{key:"key",get:function(){if("production"!==process.env.NODE_ENV&&(""===this.name||"Entity"===this.name))throw new Error("Entity classes without a name must define `static get key()`");return this.name}}]),i}(O);function S(e){return null!==e&&void 0!==e.pk}"production"!==process.env.NODE_ENV&&(w.fromJS=function(e){if(void 0===this.prototype.pk)throw new Error("cannot construct on abstract types");return O.fromJS.call(this,e)});var k=Symbol("ENTITY WAS DELETED");function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e,t){return(j=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function z(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function _(e,t,n){return(_=z()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&j(i,n.prototype),i}).apply(null,arguments)}function N(e){var t="function"==typeof Map?new Map:void 0;return(N=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return _(e,arguments,E(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),j(r,e)})(e)}var A=function(){this.children=new WeakMap},D=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).message="Keys must include at least one member",t}return r(t,e),t}(N(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 D;for(var n,r=this.first,i=0;i<e.length;i++)r.has(e[i])?n=r.get(e[i]):(n=new A,r.set(e[i],n)),r=n.children,i===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}(),J=function(e,n,r,i){var o=V(e);function u(e,r){if(!r)return[e,!0,!1];if(!r.denormalize||"function"!=typeof r.denormalize){if("function"==typeof r)return e instanceof r?[e,!0,!1]:[new r(e),!0,!1];if("object"==typeof r)return(Array.isArray(r)?l:y)(r,e,c)}return null===e?[e,!0,!1]:S(r)?void 0===e?[e,!1,!1]:function(e,n,r,i,o,u){var a=i(e,n);if(a===k)return[void 0,!0,!0];if("object"!=typeof a||null===a)return[a,!1,!1];void 0===o[n.key]&&(o[n.key]={});var c=!0,s=!1;if(!o[n.key][e]){var f=[a],l=P(r,f);u[n.key]||(u[n.key]={}),u[n.key][e]||(u[n.key][e]=new x);var h=u[n.key][e],p=t(a)?a:n.fromJS(a);o[n.key][e]=p;var y=n.denormalize(p,l);o[n.key][e]=y[0],c=y[1],s=y[2],h.has(f)?o[n.key][e]=h.get(f):h.set(f,o[n.key][e])}return[o[n.key][e],c,s]}(e,r,c,o,i,n):"function"==typeof r.denormalize?r.denormalize(e,c):[e,!0,!1]}var a=[],c=P(u,a);return function(e,t){a.push(e);var n=u(e,t);return"object"!=typeof e?n:r.has(a)?[r.get(a),n[1],n[2]]:(r.set(a,n[0]),n)}},V=function(e){var n=t(e);return function(t,r){var i=r.key;return"object"==typeof t?t:n?e.getIn([i,t]):e[i]&&e[i][t]}};function P(e,t){var n=e.og||e,r=function(e,r){var i=n(e,r);return i[0]&&r&&S(r)&&t.push(i[0]),i};return r.og=e,r}var M=function e(t,n,r,i,o,u){return t&&i&&["function","object"].includes(typeof i)?i.normalize&&"function"==typeof i.normalize?i.normalize(t,n,r,e,o,u):"function"==typeof i?new i(t):(Array.isArray(i)?f:p)(i,t,n,r,e,o,u):t};var T=function(e){function t(t,n){if(!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return e.call(this,t,n)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){return this.normalizeValue(e,t,n,r,i,o)},n.denormalize=function(e,t){return this.denormalizeValue(e,t)},t}(u),I=function(e){function t(){return e.apply(this,arguments)||this}r(t,e);var n=t.prototype;return n.normalize=function(e,t,n,r,i,o){var u=this;return Object.keys(e).reduce((function(t,n,a){var c,s=e[n];return null!=s?Object.assign({},t,((c={})[n]=u.normalizeValue(s,e,n,r,i,o),c)):t}),{})},n.denormalize=function(e,t){var n=this,r=!0,i=!1;return[Object.keys(e).reduce((function(o,u){var a,c=e[u],s=n.denormalizeValue(c,t),f=s[0],l=s[1],h=s[2];return l||(r=!1),h&&(i=!0),!l||h?o:Object.assign({},o,((a={})[u]=f,a))}),{}),r,i]},t}(u),R=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,i,o){if("string"==typeof e)return e;var u=this._entity.fromJS(e,t,n),a=u.pk(t,n);return i(this._entity,k,u,t,n),a},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},e}(),U=Object.freeze({__proto__:null,Union:T,Values:I,Array:h,Object:d,Delete:R}),F=function(e){function t(){return e.apply(this,arguments)||this}return r(t,e),t.denormalize=function(e,t){return[e,!0,!1]},t}(w);e.DELETED=k,e.Entity=w,e.FlatEntity=F,e.SimpleRecord=O,e.WeakListMap=x,e.denormalize=function(e,t,n,r,i){if(void 0===r&&(r={}),void 0===i&&(i=new x),"production"!==process.env.NODE_ENV&&void 0===t)throw new Error("schema needed");if(void 0===e)return[void 0,!1,!1,{}];var o={},u=J(n,r,i,o);return[].concat(u(e,t),[o])},e.isEntity=S,e.normalize=function(e,t,n,r){void 0===n&&(n={});var i=function(e){return["object","function"].includes(typeof e)?"object":typeof e}(t);if(null===e||typeof e!==i){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 "'+i+'", 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 "'+i+'", found "'+(null===e?"null":typeof e)+'".')}var o={},u={},a=function(e,t,n,r){return function(r,i,o,u,a){var c=r.key,s=r.pk(o,u,a);c in e||(e[c]={});var f=e[c][s];if(e[c][s]=f?r.merge(f,i):i,Array.isArray(r.indexes)){var l=e[c][s];c in t||(t[c]={});for(var h,p=v(r.indexes);!(h=p()).done;){var y=h.value;y in t[c]||(t[c][y]={});var d=t[c][y];f&&delete d[f[y]],n[c]&&n[c][s]&&n[c][s][y]!==l[y]&&(d[n[c][s][y]]=k),y in l?d[l[y]]=s:"production"!==process.env.NODE_ENV&&console.warn("Index not found in entity. Indexes must be top-level members of your entity.\nIndex: "+y+"\nEntity: "+JSON.stringify(l,void 0,2))}}}}(o,u,n);return{entities:o,indexes:u,result:M(e,e,void 0,t,a,{})}},e.schema=U,Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -1,4 +0,22 @@ | ||
import { Denormalize, DenormalizeNullable, Schema } from './types'; | ||
export declare const denormalize: <S extends Schema>(input: any, schema: S, entities: any) => [Denormalize<S>, true, false, Record<string, Record<string, any>>] | [DenormalizeNullable<S>, false, boolean, Record<string, Record<string, any>>] | [DenormalizeNullable<S>, boolean, true, Record<string, Record<string, any>>]; | ||
export declare const denormalizeSimple: <S extends Schema>(input: any, schema: S, entities: any) => [Denormalize<S>, true, false] | [DenormalizeNullable<S>, boolean, true] | [DenormalizeNullable<S>, false, boolean]; | ||
import { Denormalize, DenormalizeNullable, Schema, DenormalizeCache } from './types'; | ||
import WeakListMap from './WeakListMap'; | ||
declare type DenormalizeReturn<S extends Schema> = [ | ||
denormalized: Denormalize<S>, | ||
found: true, | ||
deleted: false, | ||
resolvedEntities: Record<string, Record<string, any>> | ||
] | [ | ||
denormalized: DenormalizeNullable<S>, | ||
found: boolean, | ||
deleted: true, | ||
resolvedEntities: Record<string, Record<string, any>> | ||
] | [ | ||
denormalized: DenormalizeNullable<S>, | ||
found: false, | ||
deleted: boolean, | ||
resolvedEntities: Record<string, Record<string, any>> | ||
]; | ||
export declare const denormalize: <S extends Schema>(input: any, schema: S, entities: any, entityCache?: DenormalizeCache['entities'], resultCache?: WeakListMap<object, any>) => DenormalizeReturn<S>; | ||
export declare const denormalizeSimple: <S extends Schema>(input: any, schema: S, entities: any, entityCache?: DenormalizeCache['entities'], resultCache?: WeakListMap<object, any>) => [Denormalize<S>, true, false] | [DenormalizeNullable<S>, boolean, true] | [DenormalizeNullable<S>, false, boolean]; | ||
export {}; | ||
//# sourceMappingURL=denormalize.d.ts.map |
@@ -5,6 +5,6 @@ import { isImmutable } from './schemas/ImmutableUtils'; | ||
import { isEntity } from './entities/Entity'; | ||
import FlatEntity from './entities/FlatEntity'; | ||
import { DELETED } from './special'; | ||
import WeakListMap from './WeakListMap'; | ||
const unvisitEntity = (id, schema, unvisit, getEntity, cache) => { | ||
const unvisitEntity = (id, schema, unvisit, getEntity, localCache, entityCache) => { | ||
const entity = getEntity(id, schema); | ||
@@ -20,4 +20,4 @@ | ||
if (!cache[schema.key]) { | ||
cache[schema.key] = {}; | ||
if (localCache[schema.key] === undefined) { | ||
localCache[schema.key] = {}; | ||
} | ||
@@ -28,18 +28,31 @@ | ||
if (!cache[schema.key][id]) { | ||
// Ensure we don't mutate it non-immutable objects | ||
const entityCopy = isImmutable(entity) || entity instanceof FlatEntity ? entity : schema.fromJS(entity); // Need to set this first so that if it is referenced further within the | ||
if (!localCache[schema.key][id]) { | ||
const globalKey = [entity]; | ||
const wrappedUnvisit = withTrackedEntities(unvisit, globalKey); | ||
if (!entityCache[schema.key]) entityCache[schema.key] = {}; | ||
if (!entityCache[schema.key][id]) entityCache[schema.key][id] = new WeakListMap(); | ||
const globalCacheEntry = entityCache[schema.key][id]; | ||
const entityCopy = isImmutable(entity) ? entity : schema.fromJS(entity); // Need to set this first so that if it is referenced further within the | ||
// denormalization the reference will already exist. | ||
cache[schema.key][id] = entityCopy; | ||
[cache[schema.key][id], found, deleted] = schema.denormalize(entityCopy, unvisit); | ||
localCache[schema.key][id] = entityCopy; | ||
[localCache[schema.key][id], found, deleted] = schema.denormalize(entityCopy, wrappedUnvisit); | ||
if (!globalCacheEntry.has(globalKey)) { | ||
globalCacheEntry.set(globalKey, localCache[schema.key][id]); | ||
} else { | ||
// localCache is only used before this point for recursive relationships | ||
// since recursive relationships must all referentially change if *any* do, we either | ||
// get the correct one here, or will never find the same version in the cache | ||
localCache[schema.key][id] = globalCacheEntry.get(globalKey); | ||
} | ||
} | ||
return [cache[schema.key][id], found, deleted]; | ||
return [localCache[schema.key][id], found, deleted]; | ||
}; | ||
const getUnvisit = entities => { | ||
const cache = {}; | ||
const getUnvisit = (entities, entityCache, resultCache, localCache) => { | ||
const getEntity = getEntities(entities); | ||
return [function unvisit(input, schema) { | ||
function unvisit(input, schema) { | ||
if (!schema) return [input, true, false]; | ||
@@ -53,3 +66,3 @@ | ||
const method = Array.isArray(schema) ? arrayDenormalize : objectDenormalize; | ||
return method(schema, input, unvisit); | ||
return method(schema, input, wrappedUnvisit); | ||
} | ||
@@ -69,11 +82,26 @@ } // null is considered intentional, thus always 'found' as true | ||
return unvisitEntity(input, schema, unvisit, getEntity, cache); | ||
return unvisitEntity(input, schema, wrappedUnvisit, getEntity, localCache, entityCache); | ||
} | ||
if (typeof schema.denormalize === 'function') { | ||
return schema.denormalize(input, unvisit); | ||
return schema.denormalize(input, wrappedUnvisit); | ||
} | ||
return [input, true, false]; | ||
}, cache]; | ||
} | ||
const globalKey = []; | ||
const wrappedUnvisit = withTrackedEntities(unvisit, globalKey); | ||
return (input, schema) => { | ||
globalKey.push(input); | ||
const ret = unvisit(input, schema); | ||
if (typeof input !== 'object') return ret; | ||
if (!resultCache.has(globalKey)) { | ||
resultCache.set(globalKey, ret[0]); | ||
return ret; | ||
} else { | ||
return [resultCache.get(globalKey), ret[1], ret[2]]; | ||
} | ||
}; | ||
}; | ||
@@ -96,17 +124,36 @@ | ||
}; | ||
}; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
}; | ||
export const denormalize = (input, schema, entities) => { | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
export const denormalize = (input, schema, entities, entityCache = {}, resultCache = new WeakListMap()) => { | ||
/* istanbul ignore next */ | ||
if (process.env.NODE_ENV !== 'production' && schema === undefined) throw new Error('schema needed'); | ||
if (process.env.NODE_ENV !== 'production' && schema === undefined) { | ||
throw new Error('schema needed'); | ||
} | ||
if (typeof input !== 'undefined') { | ||
const [unvisit, cache] = getUnvisit(entities); | ||
return [...unvisit(input, schema), cache]; | ||
if (typeof input === 'undefined') { | ||
return [undefined, false, false, {}]; | ||
} | ||
return [undefined, false, false, {}]; | ||
const resolvedEntities = {}; | ||
const unvisit = getUnvisit(entities, entityCache, resultCache, resolvedEntities); | ||
return [...unvisit(input, schema), resolvedEntities]; | ||
}; | ||
export const denormalizeSimple = (input, schema, entities) => denormalize(input, schema, entities).slice(0, 3); | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9kZW5vcm1hbGl6ZS50cyJdLCJuYW1lcyI6WyJpc0ltbXV0YWJsZSIsImRlbm9ybWFsaXplIiwiYXJyYXlEZW5vcm1hbGl6ZSIsIm9iamVjdERlbm9ybWFsaXplIiwiaXNFb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lbm9ybWFsaXplU2ltcGxlID0gPFMgZXh0ZW5kcyBTY2hlbWE+KFxuICBpbnB1dDogYW55LFxuICBzY2hlbWE6IFMsXG4gIGVudGl0aWVzOiBhbnksXG4pOlxuICB8IFtEZW5vcm1hbGl6ZTxTPiwgdHJ1ZSwgZmFsc2VdXG4gIHwgW0Rlbm9ybWFsaXplTnVsbGFibGU8Uz4sIGJvb2xlYW4sIHRydWVdXG4gIHwgW0Rlbm9ybWFsaXplTnVsbGFibGU8Uz4sIGZhbHNlLCBib29sZWFuXSA9PlxuICBkZW5vcm1hbGl6ZShpbnB1dCwgc2NoZW1hLCBlbnRpdGllcykuc2xpY2UoMCwgMykgYXMgYW55O1xuIl19 | ||
export const denormalizeSimple = (input, schema, entities, entityCache = {}, resultCache = new WeakListMap()) => denormalize(input, schema, entities, entityCache, resultCache).slice(0, 3); | ||
function withTrackedEntities(unvisit, globalKey) { | ||
// every time we nest, we want to unwrap back to the top. | ||
// this is due to only needed the next level of nested entities for lookup | ||
const originalUnvisit = unvisit.og || unvisit; | ||
const wrappedUnvisit = (input, schema) => { | ||
const ret = originalUnvisit(input, schema); // pass over undefined in key | ||
if (ret[0] && schema && isEntity(schema)) globalKey.push(ret[0]); | ||
return ret; | ||
}; | ||
wrappedUnvisit.og = unvisit; | ||
return wrappedUnvisit; | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9kZW5vcm1hbGl6ZS50cyJdLCJuYW1lcyI6WyJpc0ltbXV0YWJsZSIsImRlbm9ybWFsaXplIiwiYXJyYXlEZW5vcm1hbGl6ZSIsIm9iamVjdERlbm9ybWFsaXplIiwiaXNFbnRpdHkiLCJERUxFVEVEIiwiV2Vha0xpc3RNYXAiLCJ1bnZpc2l0RW50aXR5IiwiaWQiLCJzY2hlbWEiLCJ1bnZpc2l0IiwiZ2V0RW50aXR5IiwibG9jYWxDYWNoZSIsImVudGl0eUNhY2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mZ1bmN0aW9uIHdpdGhUcmFja2VkRW50aXRpZXMoXG4gIHVudmlzaXQ6IFVudmlzaXRGdW5jdGlvbixcbiAgZ2xvYmFsS2V5OiBFbnRpdHlJbnRlcmZhY2U8YW55PltdLFxuKSB7XG4gIC8vIGV2ZXJ5IHRpbWUgd2UgbmVzdCwgd2Ugd2FudCB0byB1bndyYXAgYmFjayB0byB0aGUgdG9wLlxuICAvLyB0aGlzIGlzIGR1ZSB0byBvbmx5IG5lZWRlZCB0aGUgbmV4dCBsZXZlbCBvZiBuZXN0ZWQgZW50aXRpZXMgZm9yIGxvb2t1cFxuICBjb25zdCBvcmlnaW5hbFVudmlzaXQgPSB1bnZpc2l0Lm9nIHx8IHVudmlzaXQ7XG4gIGNvbnN0IHdyYXBwZWRVbnZpc2l0ID0gKGlucHV0OiBhbnksIHNjaGVtYTogYW55KSA9PiB7XG4gICAgY29uc3QgcmV0OiBbYW55LCBib29sZWFuLCBib29sZWFuXSA9IG9yaWdpbmFsVW52aXNpdChpbnB1dCwgc2NoZW1hKTtcbiAgICAvLyBwYXNzIG92ZXIgdW5kZWZpbmVkIGluIGtleVxuICAgIGlmIChyZXRbMF0gJiYgc2NoZW1hICYmIGlzRW50aXR5KHNjaGVtYSkpIGdsb2JhbEtleS5wdXNoKHJldFswXSk7XG4gICAgcmV0dXJuIHJldDtcbiAgfTtcbiAgd3JhcHBlZFVudmlzaXQub2cgPSB1bnZpc2l0O1xuICByZXR1cm4gd3JhcHBlZFVudmlzaXQ7XG59XG4iXX0= |
@@ -33,5 +33,5 @@ import SimpleRecord from './SimpleRecord'; | ||
static normalize(input: any, parent: any, key: string | undefined, visit: (...args: any) => any, addEntity: (...args: any) => any, visitedEntities: Record<string, any>): any; | ||
static denormalize<T extends typeof SimpleRecord>(this: T, entity: AbstractInstanceType<T>, unvisit: schema.UnvisitFunction): [AbstractInstanceType<T>, boolean, boolean]; | ||
static denormalize<T extends typeof SimpleRecord>(this: T, input: AbstractInstanceType<T>, unvisit: schema.UnvisitFunction): [AbstractInstanceType<T>, boolean, boolean]; | ||
} | ||
export declare function isEntity(schema: Schema | null): schema is typeof Entity; | ||
//# sourceMappingURL=Entity.d.ts.map |
@@ -129,7 +129,7 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
static denormalize(entity, unvisit) { | ||
static denormalize(input, unvisit) { | ||
// TODO: this entire function is redundant with SimpleRecord, however right now we're storing the Entity instance | ||
// itself in cache. Once we offer full memoization, we will store raw objects and this can be consolidated with SimpleRecord | ||
if (isImmutable(entity)) { | ||
const [denormEntity, found, deleted] = denormalizeImmutable(this.schema, entity, unvisit); | ||
if (isImmutable(input)) { | ||
const [denormEntity, found, deleted] = denormalizeImmutable(this.schema, input, unvisit); | ||
return [this.fromJS(denormEntity.toObject()), found, deleted]; | ||
@@ -142,7 +142,8 @@ } // TODO: This creates unneeded memory pressure | ||
let found = true; | ||
const denormEntity = entity; | ||
const denormEntity = input; // note: iteration order must be stable | ||
Object.keys(this.schema).forEach(key => { | ||
const schema = this.schema[key]; | ||
const input = this.hasDefined(entity, key) ? entity[key] : undefined; | ||
const [value, foundItem, deletedItem] = unvisit(input, schema); // members who default to falsy values are considered 'optional' | ||
const nextInput = this.hasDefined(input, key) ? input[key] : undefined; | ||
const [value, foundItem, deletedItem] = unvisit(nextInput, schema); // members who default to falsy values are considered 'optional' | ||
// if falsy value, and default is actually set then it is optional so pass through | ||
@@ -158,3 +159,3 @@ | ||
if (this.hasDefined(entity, key) && denormEntity[key] !== value) { | ||
if (this.hasDefined(input, key) && denormEntity[key] !== value) { | ||
denormEntity[key] = value; | ||
@@ -180,2 +181,2 @@ } | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9lbnRpdGllcy9FbnRpdHkudHMiXSwibmFtZXMiOlsiU2ltcGxlUmVjb3JkIiwiaXNJbW11dGFibGUiLCJkZW5vcm1hbGl6ZUltbXV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OiBzY2hlbWEgaXMgdHlwZW9mIEVudGl0eSB7XG4gIHJldHVybiBzY2hlbWEgIT09IG51bGwgJiYgKHNjaGVtYSBhcyBhbnkpLnBrICE9PSB1bmRlZmluZWQ7XG59XG4iXX0= |
@@ -5,2 +5,3 @@ import Entity from './Entity'; | ||
import { SimpleRecord } from '..'; | ||
/** @deprecated */ | ||
export default abstract class FlatEntity extends Entity { | ||
@@ -7,0 +8,0 @@ static denormalize<T extends typeof SimpleRecord>(this: T, entity: any, unvisit: schema.UnvisitFunction): [AbstractInstanceType<T>, boolean, boolean]; |
import Entity from './Entity'; | ||
/** @deprecated */ | ||
export default class FlatEntity extends Entity { | ||
@@ -8,2 +10,2 @@ static denormalize(entity, unvisit) { | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9lbnRpdGllcy9GbGF0RW50aXR5LnRzIl0sIm5hbWVzIjpbIkVudGl0eSIsIkZsYXRFbnRpdHkiLCJkZW5vcm1hbGl6ZSIsImVudGl0eSIsInVudmlzaXQiXSwibWFwcGluZ3MiOiJBQUFBLE9BQU9BLE1BQVAsTUFBbUIsVUFBbkI7QUFLQSxlQUFlLE1BQWVDLFVBQWYsU0FBa0NELE1BQWxDLENBQXlDO0FBQ3RELFNBQU9FLFdBQVAsQ0FFRUMsTUFGRixFQUdFQyxPQUhGLEVBSStDO0FBQzdDLFdBQU8sQ0FBQ0QsTUFBRCxFQUFTLElBQVQsRUFBZSxLQUFmLENBQVA7QUFDRDs7QUFQcUQiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgRW50aXR5IGZyb20gJy4vRW50aXR5JztcbmltcG9ydCAqIGFzIHNjaGVtYSBmcm9tICcuLi9zY2hlbWEnO1xuaW1wb3J0IHsgQWJzdHJhY3RJbnN0YW5jZVR5cGUgfSBmcm9tICcuLi90eXBlcyc7XG5pbXBvcnQgeyBTaW1wbGVSZWNvcmQg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GVSZWNvcmQgfSBmcm9tICcuLic7XG5cbi8qKiBAZGVwcmVjYXRlZCAqL1xuZXhwb3J0IGRlZmF1bHQgYWJzdHJhY3QgY2xhc3MgRmxhdEVudGl0eSBleHRlbmRzIEVudGl0eSB7XG4gIHN0YXRpYyBkZW5vcm1hbGl6ZTxUIGV4dGVuZHMgdHlwZW9mIFNpbXBsZVJlY29yZD4oXG4gICAgdGhpczogVCxcbiAgICBlbnRpdHk6IGFueSxcbiAgICB1bnZpc2l0OiBzY2hlbWEuVW52aXNpdEZ1bmN0aW9uLFxuICApOiBbQWJzdHJhY3RJbnN0YW5jZVR5cGU8VD4sIGJvb2xlYW4sIGJvb2xlYW5dIHtcbiAgICByZXR1cm4gW2VudGl0eSwgdHJ1ZSwgZmFsc2VdIGFzIGFueTtcbiAgfVxufVxuIl19 |
import { denormalize } from './denormalize'; | ||
import { normalize } from './normalize'; | ||
import WeakListMap from './WeakListMap'; | ||
import * as schema from './schema'; | ||
@@ -8,4 +9,4 @@ import Entity, { isEntity } from './entities/Entity'; | ||
export { DELETED } from './special'; | ||
export type { AbstractInstanceType, Schema, Normalize, NormalizeNullable, NormalizedIndex, NormalizeReturnType, NormalizedSchema, Denormalize, DenormalizeNullable, DenormalizeReturnType, } from './types'; | ||
export { denormalize, schema, normalize, SimpleRecord, Entity, isEntity }; | ||
export type { AbstractInstanceType, Schema, Normalize, NormalizeNullable, NormalizedIndex, NormalizeReturnType, NormalizedSchema, Denormalize, DenormalizeNullable, DenormalizeReturnType, DenormalizeCache, } from './types'; | ||
export { denormalize, schema, normalize, SimpleRecord, Entity, isEntity, WeakListMap, }; | ||
//# sourceMappingURL=index.d.ts.map |
import { denormalize } from './denormalize'; | ||
import { normalize } from './normalize'; | ||
import WeakListMap from './WeakListMap'; | ||
import * as schema from './schema'; | ||
@@ -8,3 +9,3 @@ import Entity, { isEntity } from './entities/Entity'; | ||
export { DELETED } from './special'; | ||
export { denormalize, schema, normalize, SimpleRecord, Entity, isEntity }; | ||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VudGl0aWVzL0ZsYXRFbnRpdHknO1xuZXhwb3J0IHsgREVMRVRFRCB9IGZyb20gJy4vc3BlY2lhbCc7XG5cbmV4cG9ydCB0eXBlIHtcbiAgQWJzdHJhY3RJbnN0YW5jZVR5cGUsXG4gIFNjaGVtYSxcbiAgTm9ybWFsaXplLFxuICBOb3JtYWxpemVOdWxsYWJsZSxcbiAgTm9ybWFsaXplZEluZGV4LFxuICBOb3JtYWxpemVSZXR1cm5UeXBlLFxuICBOb3JtYWxpemVkU2NoZW1hLFxuICBEZW5vcm1hbGl6ZSxcbiAgRGVub3JtYWxpemVOdWxsYWJsZSxcbiAgRGVub3JtYWxpemVSZXR1cm5UeXBlLFxufSBmcm9tICcuL3R5cGVzJztcblxuZXhwb3J0IHsgZGVub3JtYWxpemUsIHNjaGVtYSwgbm9ybWFsaXplLCBTaW1wbGVSZWNvcmQsIEVudGl0eSwgaXNFbnRpdHkgfTtcbiJdfQ== | ||
export { denormalize, schema, normalize, SimpleRecord, Entity, isEntity, WeakListMap }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6WyJkZW5vcm1hbGl6ZSIsIm5vcm1hbGl6ZSIsIldlYWtMaXN0TWFwIiwic2NoZW1hIiwiRW50aXR5IiwiaXNFbnRpdHkiLCJTaW1wbGVSZWNvcmQiLCJkZWZhdWx0IiwiRmxhdEVudGl0eSIsIkRFTEVURUQiXSwibWFwcGluZ3MiOiJBQUFBLFNBQVNBLFdBQVQsUUFBNEIsZUFBNUI7QUFDQSxTQUFTQyxTQUFULFFBQTBCLGFBQTFCO0FBQ0EsT0FBT0MsV0FBUCxNQUF3QixlQUF4QjtBQUNBLE9BQU8sS0FBS0MsTUFBWixNQUF3QixVQUF4QjtBQUNBLE9BQU9DLE1BQVAsSUFBaUJDLFFBQWpCLFFBQWlDLG1CQUFqQztBQUNBLE9BQU9DLFlB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GUsXG59IGZyb20gJy4vdHlwZXMnO1xuXG5leHBvcnQge1xuICBkZW5vcm1hbGl6ZSxcbiAgc2NoZW1hLFxuICBub3JtYWxpemUsXG4gIFNpbXBsZVJlY29yZCxcbiAgRW50aXR5LFxuICBpc0VudGl0eSxcbiAgV2Vha0xpc3RNYXAsXG59O1xuIl19 |
@@ -12,2 +12,3 @@ import { | ||
NormalizedNullableObject, | ||
UnvisitFunction, | ||
} from './types'; | ||
@@ -31,6 +32,3 @@ import { default as Delete } from './schemas/Delete'; | ||
export type EntityMap<T = any> = Record<string, EntityInterface<T>>; | ||
export type UnvisitFunction = ( | ||
input: any, | ||
schema: any, | ||
) => [any, boolean, boolean]; | ||
export type { UnvisitFunction }; | ||
export type UnionResult<Choices extends EntityMap> = { | ||
@@ -37,0 +35,0 @@ id: string; |
import type { default as schema, EntityInterface } from './schema'; | ||
import WeakListMap from './WeakListMap'; | ||
export declare type AbstractInstanceType<T> = T extends { | ||
@@ -32,2 +33,16 @@ prototype: infer U; | ||
} | ||
export interface UnvisitFunction { | ||
(input: any, schema: any): [any, boolean, boolean]; | ||
og?: UnvisitFunction; | ||
} | ||
export interface DenormalizeCache { | ||
entities: { | ||
[key: string]: { | ||
[pk: string]: WeakListMap<object, EntityInterface>; | ||
}; | ||
}; | ||
results: { | ||
[key: string]: WeakListMap<object, any>; | ||
}; | ||
} | ||
export declare type DenormalizeNullableNestedSchema<S extends NestedSchemaClass> = keyof S['schema'] extends never ? S['prototype'] : string extends keyof S['schema'] ? S['prototype'] : { | ||
@@ -34,0 +49,0 @@ [K in keyof S['prototype']]: K extends keyof S['schema'] ? DenormalizeNullable<S['schema'][K]> : S['prototype'][K]; |
{ | ||
"name": "@rest-hooks/normalizr", | ||
"version": "6.0.0-k.0", | ||
"version": "6.0.0-rc.0", | ||
"description": "Normalizes and denormalizes JSON according to schema for Redux and Flux applications", | ||
@@ -32,2 +32,5 @@ "homepage": "https://github.com/coinbase/rest-hooks/tree/master/packages/normalizr#readme", | ||
"sideEffects": false, | ||
"engines": { | ||
"node": ">=0.12" | ||
}, | ||
"scripts": { | ||
@@ -62,3 +65,4 @@ "build": "yarn run build:lib && yarn run build:bundle", | ||
"immutable": "^3.8.1", | ||
"npm-run-all": "^4.1.5" | ||
"npm-run-all": "^4.1.5", | ||
"run-p": "^0.0.0" | ||
}, | ||
@@ -68,3 +72,3 @@ "dependencies": { | ||
}, | ||
"gitHead": "3d62db99b47ac7e846cdbabba429b047fdb8d18a" | ||
"gitHead": "aac7788118bcc573da9eeba25fffb27e950ac9d6" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
422674
53
5659
0
3