Comparing version 3.2.2 to 3.2.3
# v3.2.0 | ||
* **Added** Support denormoalizing from Immutable entities (gh-228) | ||
* **Added** Support denormalizing from Immutable entities (gh-228) | ||
* **Added** Brought back `get idAttribute()` to `schema.Entity` (gh-226) | ||
@@ -5,0 +5,0 @@ * **Fixed** Gracefully handle missing data in `denormalize` (gh-232) |
@@ -348,7 +348,9 @@ 'use strict'; | ||
value: function denormalizeValue(value, unvisit) { | ||
if (!this.isSingleSchema && !value.schema) { | ||
var schemaKey = isImmutable(value) ? value.get('schema') : value.schema; | ||
if (!this.isSingleSchema && !schemaKey) { | ||
return value; | ||
} | ||
var schema = this.isSingleSchema ? this.schema : this.schema[value.schema]; | ||
return unvisit(value.id || value, schema); | ||
var id = isImmutable(value) ? value.get('id') : value.id; | ||
var schema = this.isSingleSchema ? this.schema : this.schema[schemaKey]; | ||
return unvisit(id || value, schema); | ||
} | ||
@@ -355,0 +357,0 @@ }, { |
@@ -1,1 +0,1 @@ | ||
"use strict";function isImmutable(e){return!(!e||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function denormalizeImmutable(e,t,n){return Object.keys(e).reduce(function(t,r){var i=""+r;return t.has(i)?t.set(i,n(t.get(i),e[i])):t},t)}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(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)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),defineProperty=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},get$1=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,r)}if("value"in i)return i.value;var a=i.get;if(void 0!==a)return a.call(r)},inherits=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},possibleConstructorReturn=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},set=function e(t,n,r,i){var o=Object.getOwnPropertyDescriptor(t,n);if(void 0===o){var a=Object.getPrototypeOf(t);null!==a&&e(a,n,r,i)}else if("value"in o&&o.writable)o.value=r;else{var u=o.set;void 0!==u&&u.call(i,r)}return r},getDefaultGetId=function(e){return function(t){return isImmutable(t)?t.get(e):t[e]}},EntitySchema=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(classCallCheck(this,e),!t||"string"!=typeof t)throw new Error("Expected a string key for Entity, but found "+t+".");var i=r.idAttribute,o=void 0===i?"id":i,a=r.mergeStrategy,u=void 0===a?function(e,t){return _extends({},e,t)}:a,c=r.processStrategy,s=void 0===c?function(e){return _extends({},e)}:c;this._key=t,this._getId="function"==typeof o?o:getDefaultGetId(o),this._idAttribute=o,this._mergeStrategy=u,this._processStrategy=s,this.define(n)}return createClass(e,[{key:"define",value:function(e){this.schema=Object.keys(e).reduce(function(t,n){var r=e[n];return _extends({},t,defineProperty({},n,r))},this.schema||{})}},{key:"getId",value:function(e,t,n){return this._getId(e,t,n)}},{key:"merge",value:function(e,t){return this._mergeStrategy(e,t)}},{key:"normalize",value:function(e,t,n,r,i){var o=this,a=this._processStrategy(e,t,n);return Object.keys(this.schema).forEach(function(e){if(a.hasOwnProperty(e)&&"object"===_typeof(a[e])){var t=o.schema[e];a[e]=r(a[e],a,e,t,i)}}),i(this,a,e,t,n),this.getId(e,t,n)}},{key:"denormalize",value:function(e,t){var n=this;return isImmutable(e)?denormalizeImmutable(this.schema,e,t):(Object.keys(this.schema).forEach(function(r){if(e.hasOwnProperty(r)){var i=n.schema[r];e[r]=t(e[r],i)}}),e)}},{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),e}(),PolymorphicSchema=function(){function e(t,n){classCallCheck(this,e),n&&(this._schemaAttribute="string"==typeof n?function(e){return e[n]}:n),this.define(t)}return createClass(e,[{key:"define",value:function(e){this.schema=e}},{key:"getSchemaAttribute",value:function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)}},{key:"inferSchema",value:function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]}},{key:"normalizeValue",value:function(e,t,n,r,i){var o=this.inferSchema(e,t,n);if(!o)return e;var a=r(e,t,n,o,i);return this.isSingleSchema||void 0===a||null===a?a:{id:a,schema:this.getSchemaAttribute(e,t,n)}}},{key:"denormalizeValue",value:function(e,t){if(!this.isSingleSchema&&!e.schema)return e;var n=this.isSingleSchema?this.schema:this.schema[e.schema];return t(e.id||e,n)}},{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),UnionSchema=function(e){function t(e,n){if(classCallCheck(this,t),!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n))}return inherits(t,e),createClass(t,[{key:"normalize",value:function(e,t,n,r,i){return this.normalizeValue(e,t,n,r,i)}},{key:"denormalize",value:function(e,t){return this.denormalizeValue(e,t)}}]),t}(PolymorphicSchema),ValuesSchema=function(e){function t(){return classCallCheck(this,t),possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return inherits(t,e),createClass(t,[{key:"normalize",value:function(e,t,n,r,i){var o=this;return Object.keys(e).reduce(function(t,n,a){var u=e[n];return void 0!==u&&null!==u?_extends({},t,defineProperty({},n,o.normalizeValue(u,e,n,r,i))):t},{})}},{key:"denormalize",value:function(e,t){var n=this;return Object.keys(e).reduce(function(r,i){var o=e[i];return _extends({},r,defineProperty({},i,n.denormalizeValue(o,t)))},{})}}]),t}(PolymorphicSchema),validateSchema=function(e){var t=Array.isArray(e);if(t&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},getValues=function(e){return Array.isArray(e)?e:Object.keys(e).map(function(t){return e[t]})},normalize$2=function(e,t,n,r,i,o){e=validateSchema(e);var a=getValues(t);return a.map(function(t,a){return i(t,n,r,e,o)})},denormalize$2=function(e,t,n){return e=validateSchema(e),t&&t.map?t.map(function(t){return n(t,e)}):t},ArraySchema=function(e){function t(){return classCallCheck(this,t),possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return inherits(t,e),createClass(t,[{key:"normalize",value:function(e,t,n,r,i){var o=this,a=getValues(e);return a.map(function(e,a){return o.normalizeValue(e,t,n,r,i)}).filter(function(e){return void 0!==e&&null!==e})}},{key:"denormalize",value:function(e,t){var n=this;return e&&e.map?e.map(function(e){return n.denormalizeValue(e,t)}):e}}]),t}(PolymorphicSchema),_normalize=function(e,t,n,r,i,o){var a=_extends({},t);return Object.keys(e).forEach(function(n){var r=e[n],u=i(t[n],t,n,r,o);void 0===u||null===u?delete a[n]:a[n]=u}),a},_denormalize=function(e,t,n){if(isImmutable(t))return denormalizeImmutable(e,t,n);var r=_extends({},t);return Object.keys(e).forEach(function(t){r[t]&&(r[t]=n(r[t],e[t]))}),r},ObjectSchema=function(){function e(t){classCallCheck(this,e),this.define(t)}return createClass(e,[{key:"define",value:function(e){this.schema=Object.keys(e).reduce(function(t,n){var r=e[n];return _extends({},t,defineProperty({},n,r))},this.schema||{})}},{key:"normalize",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return _normalize.apply(void 0,[this.schema].concat(t))}},{key:"denormalize",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return _denormalize.apply(void 0,[this.schema].concat(t))}}]),e}(),visit=function e(t,n,r,i,o){if("object"!==("undefined"==typeof t?"undefined":_typeof(t))||!t)return t;if("object"===("undefined"==typeof i?"undefined":_typeof(i))&&(!i.normalize||"function"!=typeof i.normalize)){var a=Array.isArray(i)?normalize$2:_normalize;return a(i,t,n,r,e,o)}return i.normalize(t,n,r,e,o)},addEntities=function(e){return function(t,n,r,i,o){var a=t.key,u=t.getId(r,i,o);a in e||(e[a]={});var c=e[a][u];c?e[a][u]=t.merge(c,n):e[a][u]=n}},schema={Array:ArraySchema,Entity:EntitySchema,Object:ObjectSchema,Union:UnionSchema,Values:ValuesSchema},normalize$1=function(e,t){if(!e||"object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+("undefined"==typeof e?"undefined":_typeof(e))+'".');var n={},r=addEntities(n),i=visit(e,e,null,t,r);return{entities:n,result:i}},unvisitEntity=function(e,t,n,r,i){var o=r(e,t);if("object"!==("undefined"==typeof o?"undefined":_typeof(o))||null===o)return o;var a=t.getId(o);if(i[t.key]||(i[t.key]={}),!i[t.key][a]){var u=isImmutable(o)?o:_extends({},o);i[t.key][a]=u,i[t.key][a]=t.denormalize(u,n)}return i[t.key][a]},getUnvisit=function(e){var t={},n=getEntities(e);return function e(r,i){if("object"===("undefined"==typeof i?"undefined":_typeof(i))&&(!i.denormalize||"function"!=typeof i.denormalize)){var o=Array.isArray(i)?denormalize$2:_denormalize;return o(i,r,e)}return void 0===r||null===r?r:i instanceof EntitySchema?unvisitEntity(r,i,e,n,t):i.denormalize(r,e)}},getEntities=function(e){var t=isImmutable(e);return function(n,r){var i=r.key;return"object"===("undefined"==typeof n?"undefined":_typeof(n))?n:t?e.getIn([i,n.toString()]):e[i][n]}},denormalize$1=function(e,t,n){return e?getUnvisit(n)(e,t):e};exports.schema=schema,exports.normalize=normalize$1,exports.denormalize=denormalize$1; | ||
"use strict";function isImmutable(e){return!(!e||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function denormalizeImmutable(e,t,n){return Object.keys(e).reduce(function(t,r){var i=""+r;return t.has(i)?t.set(i,n(t.get(i),e[i])):t},t)}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(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)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),defineProperty=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},get$1=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,r)}if("value"in i)return i.value;var a=i.get;if(void 0!==a)return a.call(r)},inherits=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},possibleConstructorReturn=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},set=function e(t,n,r,i){var o=Object.getOwnPropertyDescriptor(t,n);if(void 0===o){var a=Object.getPrototypeOf(t);null!==a&&e(a,n,r,i)}else if("value"in o&&o.writable)o.value=r;else{var u=o.set;void 0!==u&&u.call(i,r)}return r},getDefaultGetId=function(e){return function(t){return isImmutable(t)?t.get(e):t[e]}},EntitySchema=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(classCallCheck(this,e),!t||"string"!=typeof t)throw new Error("Expected a string key for Entity, but found "+t+".");var i=r.idAttribute,o=void 0===i?"id":i,a=r.mergeStrategy,u=void 0===a?function(e,t){return _extends({},e,t)}:a,c=r.processStrategy,s=void 0===c?function(e){return _extends({},e)}:c;this._key=t,this._getId="function"==typeof o?o:getDefaultGetId(o),this._idAttribute=o,this._mergeStrategy=u,this._processStrategy=s,this.define(n)}return createClass(e,[{key:"define",value:function(e){this.schema=Object.keys(e).reduce(function(t,n){var r=e[n];return _extends({},t,defineProperty({},n,r))},this.schema||{})}},{key:"getId",value:function(e,t,n){return this._getId(e,t,n)}},{key:"merge",value:function(e,t){return this._mergeStrategy(e,t)}},{key:"normalize",value:function(e,t,n,r,i){var o=this,a=this._processStrategy(e,t,n);return Object.keys(this.schema).forEach(function(e){if(a.hasOwnProperty(e)&&"object"===_typeof(a[e])){var t=o.schema[e];a[e]=r(a[e],a,e,t,i)}}),i(this,a,e,t,n),this.getId(e,t,n)}},{key:"denormalize",value:function(e,t){var n=this;return isImmutable(e)?denormalizeImmutable(this.schema,e,t):(Object.keys(this.schema).forEach(function(r){if(e.hasOwnProperty(r)){var i=n.schema[r];e[r]=t(e[r],i)}}),e)}},{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),e}(),PolymorphicSchema=function(){function e(t,n){classCallCheck(this,e),n&&(this._schemaAttribute="string"==typeof n?function(e){return e[n]}:n),this.define(t)}return createClass(e,[{key:"define",value:function(e){this.schema=e}},{key:"getSchemaAttribute",value:function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)}},{key:"inferSchema",value:function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]}},{key:"normalizeValue",value:function(e,t,n,r,i){var o=this.inferSchema(e,t,n);if(!o)return e;var a=r(e,t,n,o,i);return this.isSingleSchema||void 0===a||null===a?a:{id:a,schema:this.getSchemaAttribute(e,t,n)}}},{key:"denormalizeValue",value:function(e,t){var n=isImmutable(e)?e.get("schema"):e.schema;if(!this.isSingleSchema&&!n)return e;var r=isImmutable(e)?e.get("id"):e.id,i=this.isSingleSchema?this.schema:this.schema[n];return t(r||e,i)}},{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),UnionSchema=function(e){function t(e,n){if(classCallCheck(this,t),!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n))}return inherits(t,e),createClass(t,[{key:"normalize",value:function(e,t,n,r,i){return this.normalizeValue(e,t,n,r,i)}},{key:"denormalize",value:function(e,t){return this.denormalizeValue(e,t)}}]),t}(PolymorphicSchema),ValuesSchema=function(e){function t(){return classCallCheck(this,t),possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return inherits(t,e),createClass(t,[{key:"normalize",value:function(e,t,n,r,i){var o=this;return Object.keys(e).reduce(function(t,n,a){var u=e[n];return void 0!==u&&null!==u?_extends({},t,defineProperty({},n,o.normalizeValue(u,e,n,r,i))):t},{})}},{key:"denormalize",value:function(e,t){var n=this;return Object.keys(e).reduce(function(r,i){var o=e[i];return _extends({},r,defineProperty({},i,n.denormalizeValue(o,t)))},{})}}]),t}(PolymorphicSchema),validateSchema=function(e){var t=Array.isArray(e);if(t&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},getValues=function(e){return Array.isArray(e)?e:Object.keys(e).map(function(t){return e[t]})},normalize$2=function(e,t,n,r,i,o){e=validateSchema(e);var a=getValues(t);return a.map(function(t,a){return i(t,n,r,e,o)})},denormalize$2=function(e,t,n){return e=validateSchema(e),t&&t.map?t.map(function(t){return n(t,e)}):t},ArraySchema=function(e){function t(){return classCallCheck(this,t),possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return inherits(t,e),createClass(t,[{key:"normalize",value:function(e,t,n,r,i){var o=this,a=getValues(e);return a.map(function(e,a){return o.normalizeValue(e,t,n,r,i)}).filter(function(e){return void 0!==e&&null!==e})}},{key:"denormalize",value:function(e,t){var n=this;return e&&e.map?e.map(function(e){return n.denormalizeValue(e,t)}):e}}]),t}(PolymorphicSchema),_normalize=function(e,t,n,r,i,o){var a=_extends({},t);return Object.keys(e).forEach(function(n){var r=e[n],u=i(t[n],t,n,r,o);void 0===u||null===u?delete a[n]:a[n]=u}),a},_denormalize=function(e,t,n){if(isImmutable(t))return denormalizeImmutable(e,t,n);var r=_extends({},t);return Object.keys(e).forEach(function(t){r[t]&&(r[t]=n(r[t],e[t]))}),r},ObjectSchema=function(){function e(t){classCallCheck(this,e),this.define(t)}return createClass(e,[{key:"define",value:function(e){this.schema=Object.keys(e).reduce(function(t,n){var r=e[n];return _extends({},t,defineProperty({},n,r))},this.schema||{})}},{key:"normalize",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return _normalize.apply(void 0,[this.schema].concat(t))}},{key:"denormalize",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return _denormalize.apply(void 0,[this.schema].concat(t))}}]),e}(),visit=function e(t,n,r,i,o){if("object"!==("undefined"==typeof t?"undefined":_typeof(t))||!t)return t;if("object"===("undefined"==typeof i?"undefined":_typeof(i))&&(!i.normalize||"function"!=typeof i.normalize)){var a=Array.isArray(i)?normalize$2:_normalize;return a(i,t,n,r,e,o)}return i.normalize(t,n,r,e,o)},addEntities=function(e){return function(t,n,r,i,o){var a=t.key,u=t.getId(r,i,o);a in e||(e[a]={});var c=e[a][u];c?e[a][u]=t.merge(c,n):e[a][u]=n}},schema={Array:ArraySchema,Entity:EntitySchema,Object:ObjectSchema,Union:UnionSchema,Values:ValuesSchema},normalize$1=function(e,t){if(!e||"object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+("undefined"==typeof e?"undefined":_typeof(e))+'".');var n={},r=addEntities(n),i=visit(e,e,null,t,r);return{entities:n,result:i}},unvisitEntity=function(e,t,n,r,i){var o=r(e,t);if("object"!==("undefined"==typeof o?"undefined":_typeof(o))||null===o)return o;var a=t.getId(o);if(i[t.key]||(i[t.key]={}),!i[t.key][a]){var u=isImmutable(o)?o:_extends({},o);i[t.key][a]=u,i[t.key][a]=t.denormalize(u,n)}return i[t.key][a]},getUnvisit=function(e){var t={},n=getEntities(e);return function e(r,i){if("object"===("undefined"==typeof i?"undefined":_typeof(i))&&(!i.denormalize||"function"!=typeof i.denormalize)){var o=Array.isArray(i)?denormalize$2:_denormalize;return o(i,r,e)}return void 0===r||null===r?r:i instanceof EntitySchema?unvisitEntity(r,i,e,n,t):i.denormalize(r,e)}},getEntities=function(e){var t=isImmutable(e);return function(n,r){var i=r.key;return"object"===("undefined"==typeof n?"undefined":_typeof(n))?n:t?e.getIn([i,n.toString()]):e[i][n]}},denormalize$1=function(e,t,n){return e?getUnvisit(n)(e,t):e};exports.schema=schema,exports.normalize=normalize$1,exports.denormalize=denormalize$1; |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _ImmutableUtils = require('./ImmutableUtils'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -57,7 +59,9 @@ | ||
value: function denormalizeValue(value, unvisit) { | ||
if (!this.isSingleSchema && !value.schema) { | ||
var schemaKey = (0, _ImmutableUtils.isImmutable)(value) ? value.get('schema') : value.schema; | ||
if (!this.isSingleSchema && !schemaKey) { | ||
return value; | ||
} | ||
var schema = this.isSingleSchema ? this.schema : this.schema[value.schema]; | ||
return unvisit(value.id || value, schema); | ||
var id = (0, _ImmutableUtils.isImmutable)(value) ? value.get('id') : value.id; | ||
var schema = this.isSingleSchema ? this.schema : this.schema[schemaKey]; | ||
return unvisit(id || value, schema); | ||
} | ||
@@ -64,0 +68,0 @@ }, { |
@@ -20,3 +20,3 @@ declare namespace schema { | ||
define(definition: Schema): void | ||
key(): string | ||
key: string | ||
} | ||
@@ -23,0 +23,0 @@ |
{ | ||
"name": "normalizr", | ||
"version": "3.2.2", | ||
"version": "3.2.3", | ||
"description": "Normalizes and denormalizes JSON according to schema for Redux and Flux applications", | ||
@@ -30,3 +30,3 @@ "bugs": { | ||
"scripts": { | ||
"build": "npm run clean && mkdirp dist && npm-run-all --parallel build:development build:production build:node", | ||
"build": "npm run clean && mkdirp dist && npm run build:node && npm-run-all --parallel build:development build:production", | ||
"build:development": "NODE_ENV=development rollup -c", | ||
@@ -58,3 +58,3 @@ "build:production": "NODE_ENV=production rollup -c", | ||
"immutable": "^3.8.1", | ||
"jest": "^18.0.0", | ||
"jest": "19.0.2", | ||
"mkdirp": "^0.5.1", | ||
@@ -65,3 +65,3 @@ "npm-run-all": "^3.1.2", | ||
"rollup-plugin-babel": "^2.7.1", | ||
"rollup-plugin-filesize": "^1.0.1", | ||
"rollup-plugin-filesize": "^1.2.1", | ||
"rollup-plugin-uglify": "^1.0.1", | ||
@@ -68,0 +68,0 @@ "typescript": "^2.1.4", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124314
19
2356