kitsu-core
Advanced tools
Comparing version 8.0.5 to 8.1.0
@@ -6,2 +6,18 @@ # Change Log | ||
# [8.1.0](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/compare/v8.0.5...v8.1.0) (2020-02-28) | ||
### Chores | ||
* **release:** update documentation ([8f1b075](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/8f1b075)) | ||
### New Features | ||
* **kitsu:** deserialise POST and PATCH responses ([#371](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/issues/371)) ([3c9c3ce](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/3c9c3ce)) | ||
## [8.0.5](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/compare/v8.0.4...v8.0.5) (2020-02-12) | ||
@@ -8,0 +24,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./deattribute.js");require("./error.js"),require("./filterIncludes.js");var t=require("./linkRelationships.js");exports.deserialise=function(a){return a.data&&a.data.constructor===Array?a=function(a){for(let r of a.data)a.included&&(r=t.linkRelationships(r,a.included)),r.attributes&&(r=e.deattribute(r)),a.data[a.data.indexOf(r)]=r;return a}(a):a.included&&(a.data=t.linkRelationships(a.data,a.included)),delete a.included,a.data&&a.data.attributes&&(a.data=e.deattribute(a.data)),a}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./deattribute.js");require("./error.js"),require("./filterIncludes.js");var t=require("./linkRelationships.js");exports.deserialise=function(a){if(a)return a.data&&a.data.constructor===Array?a=function(a){for(let r of a.data)a.included&&(r=t.linkRelationships(r,a.included)),r.attributes&&(r=e.deattribute(r)),a.data[a.data.indexOf(r)]=r;return a}(a):a.included&&(a.data=t.linkRelationships(a.data,a.included)),delete a.included,a.data&&a.data.attributes&&(a.data=e.deattribute(a.data)),a}; |
@@ -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,e){let{id:n,type:o}=e;try{const e=t.filter(t=>t.id===n&&t.type===o)[0]||{id:n,type:o};return Object.assign({},e)}catch(t){r(t)}}function o(t,r){let{id:o,type:i,meta:a}=t;const c=n(r,{id:o,type:i});return c.relationships&&s(c,r),a&&(c.meta=a),e(c)}function i(t,e,r){t[r]=[];for(const n of t.relationships[r].data)t[r].push(o(n,e))}function a(t,e,r){t[r]=o(t.relationships[r].data,e),delete t[r].relationships}function s(t,e){const{relationships:r}=t;let n=!1;for(const o in r)r[o].data&&Array.isArray(r[o].data)?(i(t,e,o),n=!0):r[o].data&&(a(t,e,o),n=!0);return n&&delete t.relationships,t}function c(t,e){return null!==t&&"object"==typeof t?u(t,e):encodeURIComponent(e)+"="+encodeURIComponent(t)}function u(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const r=[];for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&r.push(c(t[n],e?"".concat(e,"[").concat(n,"]"):n));return r.join("&")}const l=(t,e)=>"".concat(t," requires an ID for the ").concat(e," relationships");function d(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"))}function p(t,e,r,n,o){if("string"!=typeof t.id)throw new Error(l(o,r));return n.relationships||(n.relationships={}),t.type||(t.type=e),n.relationships[r]={data:Object.assign(t)},n}function f(t,e,r,n,o){return n.relationships||(n.relationships={}),n.relationships[r]={data:t.map(t=>{let{id:n,type:i}=t;if(!n)throw new Error(l(o,r));return{id:n,type:i||e}})},n}function h(t,e,r){return r.attributes||(r.attributes={}),r.attributes[e]=t,r}t.camel=t=>t.replace(/[-_][a-z\u00E0-\u00F6\u00F8-\u00FE]/g,t=>t.slice(1).toUpperCase()),t.deattribute=e,t.deserialise=function(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=u,t.serialise=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"POST";try{const r=this.plural(this.camel(t));let o={type:r};d(e,n,r),e.id&&(o.id=String(e.id));for(const t in e){const r=e[t],i=this.plural(this.camel(t));null!==r&&r.constructor===Object?o=p(r,i,t,o,n):null!==r&&Array.isArray(r)?o=f(r,i,t,o,n):"id"!==t&&"type"!==t&&(o=h(r,t,o))}return{data:o}}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,e){let{id:n,type:o}=e;try{const e=t.filter(t=>t.id===n&&t.type===o)[0]||{id:n,type:o};return Object.assign({},e)}catch(t){r(t)}}function o(t,r){let{id:o,type:i,meta:a}=t;const c=n(r,{id:o,type:i});return c.relationships&&s(c,r),a&&(c.meta=a),e(c)}function i(t,e,r){t[r]=[];for(const n of t.relationships[r].data)t[r].push(o(n,e))}function a(t,e,r){t[r]=o(t.relationships[r].data,e),delete t[r].relationships}function s(t,e){const{relationships:r}=t;let n=!1;for(const o in r)r[o].data&&Array.isArray(r[o].data)?(i(t,e,o),n=!0):r[o].data&&(a(t,e,o),n=!0);return n&&delete t.relationships,t}function c(t,e){return null!==t&&"object"==typeof t?u(t,e):encodeURIComponent(e)+"="+encodeURIComponent(t)}function u(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const r=[];for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&r.push(c(t[n],e?"".concat(e,"[").concat(n,"]"):n));return r.join("&")}const l=(t,e)=>"".concat(t," requires an ID for the ").concat(e," relationships");function d(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"))}function p(t,e,r,n,o){if("string"!=typeof t.id)throw new Error(l(o,r));return n.relationships||(n.relationships={}),t.type||(t.type=e),n.relationships[r]={data:Object.assign(t)},n}function f(t,e,r,n,o){return n.relationships||(n.relationships={}),n.relationships[r]={data:t.map(t=>{let{id:n,type:i}=t;if(!n)throw new Error(l(o,r));return{id:n,type:i||e}})},n}function h(t,e,r){return r.attributes||(r.attributes={}),r.attributes[e]=t,r}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=u,t.serialise=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"POST";try{const r=this.plural(this.camel(t));let o={type:r};d(e,n,r),e.id&&(o.id=String(e.id));for(const t in e){const r=e[t],i=this.plural(this.camel(t));null!==r&&r.constructor===Object?o=p(r,i,t,o,n):null!==r&&Array.isArray(r)?o=f(r,i,t,o,n):"id"!==t&&"type"!==t&&(o=h(r,t,o))}return{data:o}}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.0.5", | ||
"version": "8.1.0", | ||
"name": "kitsu-core", | ||
@@ -55,3 +55,3 @@ "description": "Core serialisation and deserialsation functions for the kitsu JSON:API client", | ||
], | ||
"gitHead": "34901a9bf1e995522bbf7d8d061cf48cf24d6406", | ||
"gitHead": "0b3b903953ff9f7d4abea62e3f970ff3fefaac1f", | ||
"devDependencies": { | ||
@@ -58,0 +58,0 @@ "@size-limit/preset-small-lib": "~4.0.1" |
@@ -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/09d337313e18403be78eb7853f441b8b41c44b8e/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/3c9c3ced7d139ed24a29653f538fc4f870bc8bc3/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-70](https://github.com/wopian/kitsu/blob/09d337313e18403be78eb7853f441b8b41c44b8e/packages/kitsu-core/src/deserialise/index.js#L56-L70 "Source code on GitHub") | ||
[packages/kitsu-core/src/deserialise/index.js:56-72](https://github.com/wopian/kitsu/blob/3c9c3ced7d139ed24a29653f538fc4f870bc8bc3/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/09d337313e18403be78eb7853f441b8b41c44b8e/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/3c9c3ced7d139ed24a29653f538fc4f870bc8bc3/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/09d337313e18403be78eb7853f441b8b41c44b8e/packages/kitsu-core/src/filterIncludes/index.js#L12-L21 "Source code on GitHub") | ||
[packages/kitsu-core/src/filterIncludes/index.js:12-21](https://github.com/wopian/kitsu/blob/3c9c3ced7d139ed24a29653f538fc4f870bc8bc3/packages/kitsu-core/src/filterIncludes/index.js#L12-L21 "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/09d337313e18403be78eb7853f441b8b41c44b8e/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/3c9c3ced7d139ed24a29653f538fc4f870bc8bc3/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/09d337313e18403be78eb7853f441b8b41c44b8e/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/3c9c3ced7d139ed24a29653f538fc4f870bc8bc3/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:96-121](https://github.com/wopian/kitsu/blob/09d337313e18403be78eb7853f441b8b41c44b8e/packages/kitsu-core/src/serialise/index.js#L96-L121 "Source code on GitHub") | ||
[packages/kitsu-core/src/serialise/index.js:96-121](https://github.com/wopian/kitsu/blob/3c9c3ced7d139ed24a29653f538fc4f870bc8bc3/packages/kitsu-core/src/serialise/index.js#L96-L121 "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/09d337313e18403be78eb7853f441b8b41c44b8e/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/3c9c3ced7d139ed24a29653f538fc4f870bc8bc3/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/09d337313e18403be78eb7853f441b8b41c44b8e/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/3c9c3ced7d139ed24a29653f538fc4f870bc8bc3/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/09d337313e18403be78eb7853f441b8b41c44b8e/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/3c9c3ced7d139ed24a29653f538fc4f870bc8bc3/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
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
65653