kitsu-core
Advanced tools
Comparing version 8.3.0 to 8.3.1
@@ -6,2 +6,19 @@ # Change Log | ||
## [8.3.1](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/compare/v8.3.0...v8.3.1) (2020-05-02) | ||
### Bug Fixes | ||
* prevent undefined id for empty relationship data objects ([ee381a9](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/ee381a9)) | ||
### Chores | ||
* **release:** update documentation ([0d6e89b](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/0d6e89b)) | ||
* remove old devDependencies no longer used ([72acbe7](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/72acbe7)) | ||
# [8.3.0](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/compare/v8.2.0...v8.3.0) (2020-05-02) | ||
@@ -8,0 +25,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./error.js");exports.filterIncludes=function(r,{id:t,type:i}){try{const e=r.filter(e=>e.id===t&&e.type===i)[0]||{id:t,type:i};return Object.assign({},e)}catch(r){e.error(r)}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./error.js");exports.filterIncludes=function(r,{id:t,type:i}){try{if(t&&i){const e=r.filter(e=>e.id===t&&e.type===i)[0]||{id:t,type:i};return Object.assign({},e)}return{}}catch(r){e.error(r)}}; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).kitsuCore={})}(this,(function(t){"use strict";function e(t){return"object"==typeof t&&null!==t&&(Array.isArray(t)?t.map(t=>e(t)):t.attributes&&t.attributes.constructor===Object&&(Object.keys(t.attributes).forEach(e=>{t[e]=t.attributes[e]}),delete t.attributes)),t}function r(t){if(t.response){const e=t.response.data;e&&e.errors&&(t.errors=e.errors)}throw t}function n(t,{id:e,type:n}){try{const r=t.filter(t=>t.id===e&&t.type===n)[0]||{id:e,type:n};return Object.assign({},r)}catch(t){r(t)}}function a({id:t,type:r,meta:a},i){const o=n(i,{id:t,type:r});return o.relationships&&s(o,i),a&&(o.meta=a),e(o)}function i(t,e,r){t[r]=[];for(const n of t.relationships[r].data)t[r].push(a(n,e))}function o(t,e,r){t[r]=a(t.relationships[r].data,e),delete t[r].relationships}function s(t,e){const{relationships:r}=t;let n=!1;for(const a in r)r[a].data&&Array.isArray(r[a].data)?(i(t,e,a),n=!0):r[a].data&&(o(t,e,a),n=!0);return n&&delete t.relationships,t}function c(t,e=null){const r=[];for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&r.push((n=t[i],a=e?"".concat(e,"[").concat(i,"]"):i,null!==n&&"object"==typeof n?c(n,a):encodeURIComponent(a)+"="+encodeURIComponent(n)));var n,a;return r.join("&")}function u(t,e,r,n,a){return n.relationships||(n.relationships={}),t.type||(t.type=e),n.relationships[r]={data:Object.assign(t)},n}function l(t,e,r,n,a){return n.relationships||(n.relationships={}),n.relationships[r]={data:t.map(({id:t,type:r})=>({id:t,type:r||e}))},n}function d(t,e,r){return r.attributes||(r.attributes={}),r.attributes[e]=t,r}function p(t){return Object.prototype.hasOwnProperty.call(t,"id")}t.camel=t=>t.replace(/[-_][a-z\u00E0-\u00F6\u00F8-\u00FE]/g,t=>t.slice(1).toUpperCase()),t.deattribute=e,t.deserialise=function(t){if(t)return t.data&&t.data.constructor===Array?t=function(t){for(let r of t.data)t.included&&(r=s(r,t.included)),r.attributes&&(r=e(r)),t.data[t.data.indexOf(r)]=r;return t}(t):t.included&&(t.data=s(t.data,t.included)),delete t.included,t.data&&t.data.attributes&&(t.data=e(t.data)),t},t.error=r,t.filterIncludes=n,t.kebab=t=>t.charAt(0).toLowerCase()+t.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,t=>"-"+t.toLowerCase()),t.linkRelationships=s,t.query=c,t.serialise=function(t,e={},n="POST"){try{if(null===e||Array.isArray(e)&&0===e.length)return{data:e};const r=this.plural?this.plural(this.camel(t)):this.camel(t);let a={type:r};!function(t,e,r){if(t.constructor!==Object||0===Object.keys(t).length)throw new Error("".concat(e," requires a JSON object body"));if("POST"!==e&&!t.id)throw new Error("".concat(e," requires an ID for the ").concat(r," type"))}(e,n,r),e.id&&(a.id=String(e.id));for(const t in e){const r=e[t],n=this.plural?this.plural(this.camel(t)):this.camel(t);null!==r&&r.constructor===Object&&p(r)?a=u(r,n,t,a):null!==r&&Array.isArray(r)&&r.length>0&&p(r[0])?a=l(r,n,t,a):"id"!==t&&"type"!==t&&(a=d(r,t,a))}return{data:a}}catch(t){throw r(t)}},t.snake=t=>t.charAt(0).toLowerCase()+t.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,t=>"_"+t.toLowerCase()),Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).kitsuCore={})}(this,(function(t){"use strict";function e(t){return"object"==typeof t&&null!==t&&(Array.isArray(t)?t.map(t=>e(t)):t.attributes&&t.attributes.constructor===Object&&(Object.keys(t.attributes).forEach(e=>{t[e]=t.attributes[e]}),delete t.attributes)),t}function r(t){if(t.response){const e=t.response.data;e&&e.errors&&(t.errors=e.errors)}throw t}function n(t,{id:e,type:n}){try{if(e&&n){const r=t.filter(t=>t.id===e&&t.type===n)[0]||{id:e,type:n};return Object.assign({},r)}return{}}catch(t){r(t)}}function a({id:t,type:r,meta:a},i){const o=n(i,{id:t,type:r});return o.relationships&&s(o,i),a&&(o.meta=a),e(o)}function i(t,e,r){t[r]=[];for(const n of t.relationships[r].data)t[r].push(a(n,e))}function o(t,e,r){t[r]=a(t.relationships[r].data,e),delete t[r].relationships}function s(t,e){const{relationships:r}=t;let n=!1;for(const a in r)r[a].data&&Array.isArray(r[a].data)?(i(t,e,a),n=!0):r[a].data&&(o(t,e,a),n=!0);return n&&delete t.relationships,t}function c(t,e=null){const r=[];for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&r.push((n=t[i],a=e?"".concat(e,"[").concat(i,"]"):i,null!==n&&"object"==typeof n?c(n,a):encodeURIComponent(a)+"="+encodeURIComponent(n)));var n,a;return r.join("&")}function u(t,e,r,n,a){return n.relationships||(n.relationships={}),t.type||(t.type=e),n.relationships[r]={data:Object.assign(t)},n}function l(t,e,r,n,a){return n.relationships||(n.relationships={}),n.relationships[r]={data:t.map(({id:t,type:r})=>({id:t,type:r||e}))},n}function d(t,e,r){return r.attributes||(r.attributes={}),r.attributes[e]=t,r}function p(t){return Object.prototype.hasOwnProperty.call(t,"id")}t.camel=t=>t.replace(/[-_][a-z\u00E0-\u00F6\u00F8-\u00FE]/g,t=>t.slice(1).toUpperCase()),t.deattribute=e,t.deserialise=function(t){if(t)return t.data&&t.data.constructor===Array?t=function(t){for(let r of t.data)t.included&&(r=s(r,t.included)),r.attributes&&(r=e(r)),t.data[t.data.indexOf(r)]=r;return t}(t):t.included&&(t.data=s(t.data,t.included)),delete t.included,t.data&&t.data.attributes&&(t.data=e(t.data)),t},t.error=r,t.filterIncludes=n,t.kebab=t=>t.charAt(0).toLowerCase()+t.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,t=>"-"+t.toLowerCase()),t.linkRelationships=s,t.query=c,t.serialise=function(t,e={},n="POST"){try{if(null===e||Array.isArray(e)&&0===e.length)return{data:e};const r=this.plural?this.plural(this.camel(t)):this.camel(t);let a={type:r};!function(t,e,r){if(t.constructor!==Object||0===Object.keys(t).length)throw new Error("".concat(e," requires a JSON object body"));if("POST"!==e&&!t.id)throw new Error("".concat(e," requires an ID for the ").concat(r," type"))}(e,n,r),e.id&&(a.id=String(e.id));for(const t in e){const r=e[t],n=this.plural?this.plural(this.camel(t)):this.camel(t);null!==r&&r.constructor===Object&&p(r)?a=u(r,n,t,a):null!==r&&Array.isArray(r)&&r.length>0&&p(r[0])?a=l(r,n,t,a):"id"!==t&&"type"!==t&&(a=d(r,t,a))}return{data:a}}catch(t){throw r(t)}},t.snake=t=>t.charAt(0).toLowerCase()+t.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,t=>"_"+t.toLowerCase()),Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"version": "8.3.0", | ||
"version": "8.3.1", | ||
"name": "kitsu-core", | ||
@@ -55,3 +55,3 @@ "description": "Core serialisation and deserialsation functions for the kitsu JSON:API client", | ||
], | ||
"gitHead": "bdea71e4729f57c9227eb3a6e58f6ab269c0c9cf", | ||
"gitHead": "8fd78d56817191f2d4919f8da7d51d2ceef199aa", | ||
"devDependencies": { | ||
@@ -58,0 +58,0 @@ "@size-limit/preset-small-lib": "~4.4.0" |
@@ -112,3 +112,3 @@ <h1 align=center>Kitsu Core</h1> | ||
[packages/kitsu-core/src/deattribute/index.js:29-38](https://github.com/wopian/kitsu/blob/79287d0a71d36e540b69c27f86b115e56ed0674d/packages/kitsu-core/src/deattribute/index.js#L29-L38 "Source code on GitHub") | ||
[packages/kitsu-core/src/deattribute/index.js:29-38](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/deattribute/index.js#L29-L38 "Source code on GitHub") | ||
@@ -157,3 +157,3 @@ Hoists attributes to be top-level | ||
[packages/kitsu-core/src/deserialise/index.js:56-72](https://github.com/wopian/kitsu/blob/79287d0a71d36e540b69c27f86b115e56ed0674d/packages/kitsu-core/src/deserialise/index.js#L56-L72 "Source code on GitHub") | ||
[packages/kitsu-core/src/deserialise/index.js:56-72](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/deserialise/index.js#L56-L72 "Source code on GitHub") | ||
@@ -210,3 +210,3 @@ Deserialises a JSON-API response | ||
[packages/kitsu-core/src/error/index.js:7-13](https://github.com/wopian/kitsu/blob/79287d0a71d36e540b69c27f86b115e56ed0674d/packages/kitsu-core/src/error/index.js#L7-L13 "Source code on GitHub") | ||
[packages/kitsu-core/src/error/index.js:7-13](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/error/index.js#L7-L13 "Source code on GitHub") | ||
@@ -224,3 +224,3 @@ Uniform error handling for Axios, JSON:API and internal package errors. Mutated Error object is rethrown to the caller. | ||
[packages/kitsu-core/src/filterIncludes/index.js:12-21](https://github.com/wopian/kitsu/blob/79287d0a71d36e540b69c27f86b115e56ed0674d/packages/kitsu-core/src/filterIncludes/index.js#L12-L21 "Source code on GitHub") | ||
[packages/kitsu-core/src/filterIncludes/index.js:12-25](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/filterIncludes/index.js#L12-L25 "Source code on GitHub") | ||
@@ -240,3 +240,3 @@ Filters includes for the specific relationship | ||
[packages/kitsu-core/src/linkRelationships/index.js:55-74](https://github.com/wopian/kitsu/blob/79287d0a71d36e540b69c27f86b115e56ed0674d/packages/kitsu-core/src/linkRelationships/index.js#L55-L74 "Source code on GitHub") | ||
[packages/kitsu-core/src/linkRelationships/index.js:55-74](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/linkRelationships/index.js#L55-L74 "Source code on GitHub") | ||
@@ -252,3 +252,3 @@ Links relationships to included data | ||
[packages/kitsu-core/src/query/index.js:21-32](https://github.com/wopian/kitsu/blob/79287d0a71d36e540b69c27f86b115e56ed0674d/packages/kitsu-core/src/query/index.js#L21-L32 "Source code on GitHub") | ||
[packages/kitsu-core/src/query/index.js:21-32](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/query/index.js#L21-L32 "Source code on GitHub") | ||
@@ -266,3 +266,3 @@ Constructs a URL query string for JSON:API parameters | ||
[packages/kitsu-core/src/serialise/index.js:103-134](https://github.com/wopian/kitsu/blob/79287d0a71d36e540b69c27f86b115e56ed0674d/packages/kitsu-core/src/serialise/index.js#L103-L134 "Source code on GitHub") | ||
[packages/kitsu-core/src/serialise/index.js:103-134](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/serialise/index.js#L103-L134 "Source code on GitHub") | ||
@@ -293,3 +293,3 @@ Serialises an object into a JSON-API structure | ||
[packages/kitsu-core/src/camel/index.js:14-14](https://github.com/wopian/kitsu/blob/79287d0a71d36e540b69c27f86b115e56ed0674d/packages/kitsu-core/src/camel/index.js#L14-L14 "Source code on GitHub") | ||
[packages/kitsu-core/src/camel/index.js:14-14](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/camel/index.js#L14-L14 "Source code on GitHub") | ||
@@ -322,3 +322,3 @@ Converts kebab-case and snake_case into camelCase | ||
[packages/kitsu-core/src/kebab/index.js:11-11](https://github.com/wopian/kitsu/blob/79287d0a71d36e540b69c27f86b115e56ed0674d/packages/kitsu-core/src/kebab/index.js#L11-L11 "Source code on GitHub") | ||
[packages/kitsu-core/src/kebab/index.js:11-11](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/kebab/index.js#L11-L11 "Source code on GitHub") | ||
@@ -341,3 +341,3 @@ Converts camelCase into kebab-case | ||
[packages/kitsu-core/src/snake/index.js:11-11](https://github.com/wopian/kitsu/blob/79287d0a71d36e540b69c27f86b115e56ed0674d/packages/kitsu-core/src/snake/index.js#L11-L11 "Source code on GitHub") | ||
[packages/kitsu-core/src/snake/index.js:11-11](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/snake/index.js#L11-L11 "Source code on GitHub") | ||
@@ -344,0 +344,0 @@ Converts camelCase into snake_case |
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
68674
248
0
5