kitsu-core
Advanced tools
Comparing version 10.0.0-alpha.9 to 10.0.0-alpha.10
@@ -6,2 +6,28 @@ # Change Log | ||
# [10.0.0-alpha.10](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/compare/v10.0.0-alpha.9...v10.0.0-alpha.10) (2021-02-04) | ||
### Bug Fixes | ||
* **kitsu-core:** prevent empty relationships from being stripped during serialisation ([8a7d453](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/8a7d453)), closes [#517](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/issues/517) | ||
### Chores | ||
* **release:** update documentation ([92d4246](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/92d4246)) | ||
### Documentation Changes | ||
* **kitsu-core:** fix typo in MIGRATING.md ([9a51336](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/9a51336)) | ||
### Tests | ||
* add test for empty to-one/to-many relationship serialisation ([0dda0fe](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/0dda0fe)) | ||
# [10.0.0-alpha.9](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/compare/v10.0.0-alpha.8...v10.0.0-alpha.9) (2021-01-06) | ||
@@ -8,0 +34,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(i){var a,r;if(i)return Array.isArray(i.data)?i=function(i){for(let a of i.data)i.included&&(a=t.linkRelationships(a,i.included)),a.relationships&&(a=t.linkRelationships(a)),a.attributes&&(a=e.deattribute(a)),i.data[i.data.indexOf(a)]=a;return i}(i):i.included?i.data=t.linkRelationships(i.data,i.included):(null===(a=i.data)||void 0===a?void 0:a.constructor)===Object&&(i.data=t.linkRelationships(i.data)),delete i.included,null!==(r=i.data)&&void 0!==r&&r.attributes&&(i.data=e.deattribute(i.data)),i}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./deattribute.js"),t=require("./linkRelationships.js");require("./filterIncludes.js"),require("./error.js"),exports.deserialise=function(i){var a,r;if(i)return Array.isArray(i.data)?i=function(i){for(let a of i.data)i.included&&(a=t.linkRelationships(a,i.included)),a.relationships&&(a=t.linkRelationships(a)),a.attributes&&(a=e.deattribute(a)),i.data[i.data.indexOf(a)]=a;return i}(i):i.included?i.data=t.linkRelationships(i.data,i.included):(null===(a=i.data)||void 0===a?void 0:a.constructor)===Object&&(i.data=t.linkRelationships(i.data)),delete i.included,null!==(r=i.data)&&void 0!==r&&r.attributes&&(i.data=e.deattribute(i.data)),i}; |
@@ -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="undefined"!=typeof globalThis?globalThis:t||self).kitsuCore={})}(this,(function(t){"use strict";function e(t){var r;if("object"==typeof t&&null!==t)if(Array.isArray(t))t.map((t=>e(t)));else if((null===(r=t.attributes)||void 0===r?void 0:r.constructor)===Object){for(const e of Object.keys(t.attributes))t.attributes.attributes||(t[e]=t.attributes[e]);t.attributes.attributes?t.attributes=t.attributes.attributes:delete t.attributes}return t}function r(t){if(t.response){const e=t.response.data;null!=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&&l(o,i),a&&(o.meta=a),e(o)}function i(t,e,r){t[r]={},t.relationships[r].links&&(t[r].links=t.relationships[r].links),t[r].data=[];for(const n of t.relationships[r].data)t[r].data.push(a(n,e));delete t.relationships[r]}function o(t,e,r){t[r]={},t[r].data=a(t.relationships[r].data,e),t.relationships[r].links&&(t[r].links=t.relationships[r].links),delete t.relationships[r]}function s(t,e){t[e]={},t.relationships[e].links&&(t[e].links=t.relationships[e].links),delete t.relationships[e]}function l(t,e=[]){const{relationships:r}=t;for(const a in r){var n;Array.isArray(null===(n=r[a])||void 0===n?void 0:n.data)?i(t,e,a):r[a].data?o(t,e,a):s(t,a)}return 0===Object.keys(r||[]).length&&(null==r?void 0:r.constructor)===Object&&delete t.relationships,t}function u(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?u(n,a):encodeURIComponent(a)+"="+encodeURIComponent(n)));var n,a;return r.join("&")}function c(t,e,r,n){const a=new Error("".concat(n," requires an ID for the ").concat(e," type"));if(void 0===e)throw new Error("".concat(n," requires a resource type"));if(t){if("POST"!==n&&r.length>0)for(const t of r)if(!t.id)throw a}else{if("object"!=typeof r||0===Object.keys(r).length)throw new Error("".concat(n," requires an object or array body"));if("POST"!==n&&!r.id)throw a}}function d(t,e){let r={};for(const e of Object.keys(t))["id","type"].includes(e)?r[e]=t[e]:r=y(t[e],e,r);return r.type||(r.type=e),r}function p(t,e){const r=[];for(const n of t){const t=d(n);t.type||(t.type=e),r.push(t)}return r}function f(t,e,r,n){var a,i;return n.relationships||(n.relationships={}),n.relationships[r]={data:Array.isArray(t.data)?p(t.data,e):d(t.data,e)},(null!=t&&null!==(a=t.links)&&void 0!==a&&a.self||null!=t&&null!==(i=t.links)&&void 0!==i&&i.related)&&(n.relationships[r].links=t.links),null!=t&&t.meta&&(n.relationships[r].meta=t.meta),n}function y(t,e,r){return r.attributes||(r.attributes={}),"links"!==e||"string"!=typeof t.self&&"string"!=typeof t.related?"meta"===e&&t.constructor===Object?r.meta=t:r.attributes[e]=t:r.links=t,r}function h(t){if(!t.data)return!1;const e=Array.isArray(t.data)?t.data[0]:t.data;return Object.prototype.hasOwnProperty.call(e,"id")}function b(t,e,r,n){c(!1,t,e,r);let a={type:t=n.pluralTypes(n.camelCaseTypes(t))};null!=e&&e.id&&(a.id=String(e.id));for(const t in e){const r=e[t],i=n.pluralTypes(n.camelCaseTypes(t));null!==r&&(null==r?void 0:r.constructor)===Object&&h(r)?a=f(r,i,t,a):"id"!==t&&"type"!==t&&(a=y(r,t,a))}return{data:a}}t.camel=t=>t.replace(/[-_][a-z\u00E0-\u00F6\u00F8-\u00FE]/g,(t=>t.slice(1).toUpperCase())),t.deattribute=e,t.deserialise=function(t){var r,n;if(t)return Array.isArray(t.data)?t=function(t){for(let r of t.data)t.included&&(r=l(r,t.included)),r.relationships&&(r=l(r)),r.attributes&&(r=e(r)),t.data[t.data.indexOf(r)]=r;return t}(t):t.included?t.data=l(t.data,t.included):(null===(r=t.data)||void 0===r?void 0:r.constructor)===Object&&(t.data=l(t.data)),delete t.included,null!==(n=t.data)&&void 0!==n&&n.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=l,t.query=u,t.serialise=function(t,e={},n="POST",a={}){try{return a.camelCaseTypes||(a.camelCaseTypes=t=>t),a.pluralTypes||(a.pluralTypes=t=>t),null===e||Array.isArray(e)&&0===e.length?{data:e}:Array.isArray(e)&&(null==e?void 0:e.length)>0?function(t,e,r,n){c(!0,t,e,r);const a=[];for(const i of e)a.push(b(t,i,r,n).data);return{data:a}}(t,e,n,a):b(t,e,n,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())),t.splitModel=function(t,e={}){e.pluralModel||(e.pluralModel=t=>t),e.resourceCase||(e.resourceCase=t=>t);const r=t.split("/"),n=r.pop();return r.push(e.pluralModel(e.resourceCase(n))),[n,r.join("/")]},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="undefined"!=typeof globalThis?globalThis:t||self).kitsuCore={})}(this,(function(t){"use strict";function e(t){var r;if("object"==typeof t&&null!==t)if(Array.isArray(t))t.map((t=>e(t)));else if((null===(r=t.attributes)||void 0===r?void 0:r.constructor)===Object){for(const e of Object.keys(t.attributes))t.attributes.attributes||(t[e]=t.attributes[e]);t.attributes.attributes?t.attributes=t.attributes.attributes:delete t.attributes}return t}function r(t){if(t.response){const e=t.response.data;null!=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&&l(o,i),a&&(o.meta=a),e(o)}function i(t,e,r){t[r]={},t.relationships[r].links&&(t[r].links=t.relationships[r].links),t[r].data=[];for(const n of t.relationships[r].data)t[r].data.push(a(n,e));delete t.relationships[r]}function o(t,e,r){t[r]={},t[r].data=a(t.relationships[r].data,e),t.relationships[r].links&&(t[r].links=t.relationships[r].links),delete t.relationships[r]}function s(t,e){t[e]={},t.relationships[e].links&&(t[e].links=t.relationships[e].links),delete t.relationships[e]}function l(t,e=[]){const{relationships:r}=t;for(const a in r){var n;Array.isArray(null===(n=r[a])||void 0===n?void 0:n.data)?i(t,e,a):r[a].data?o(t,e,a):s(t,a)}return 0===Object.keys(r||[]).length&&(null==r?void 0:r.constructor)===Object&&delete t.relationships,t}function u(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?u(n,a):encodeURIComponent(a)+"="+encodeURIComponent(n)));var n,a;return r.join("&")}function c(t,e,r,n){const a=new Error("".concat(n," requires an ID for the ").concat(e," type"));if(void 0===e)throw new Error("".concat(n," requires a resource type"));if(t){if("POST"!==n&&r.length>0)for(const t of r)if(!t.id)throw a}else{if("object"!=typeof r||0===Object.keys(r).length)throw new Error("".concat(n," requires an object or array body"));if("POST"!==n&&!r.id)throw a}}function d(t,e){if(null===t)return t;let r={};for(const e of Object.keys(t))["id","type"].includes(e)?r[e]=t[e]:r=y(t[e],e,r);return r.type||(r.type=e),r}function p(t,e){const r=[];for(const n of t){const t=d(n);t.type||(t.type=e),r.push(t)}return r}function f(t,e,r,n){var a,i;return n.relationships||(n.relationships={}),n.relationships[r]={data:Array.isArray(t.data)?p(t.data,e):d(t.data,e)},(null!=t&&null!==(a=t.links)&&void 0!==a&&a.self||null!=t&&null!==(i=t.links)&&void 0!==i&&i.related)&&(n.relationships[r].links=t.links),null!=t&&t.meta&&(n.relationships[r].meta=t.meta),n}function y(t,e,r){return r.attributes||(r.attributes={}),"links"!==e||"string"!=typeof t.self&&"string"!=typeof t.related?"meta"===e&&t.constructor===Object?r.meta=t:r.attributes[e]=t:r.links=t,r}function h(t){var e;if(null===(null==t?void 0:t.data)||Array.isArray(null==t?void 0:t.data)&&0===(null==t||null===(e=t.data)||void 0===e?void 0:e.length))return!0;if(!t.data)return!1;const r=Array.isArray(t.data)?t.data[0]:t.data;return Object.prototype.hasOwnProperty.call(r,"id")}function b(t,e,r,n){c(!1,t,e,r);let a={type:t=n.pluralTypes(n.camelCaseTypes(t))};null!=e&&e.id&&(a.id=String(e.id));for(const t in e){const r=e[t],i=n.pluralTypes(n.camelCaseTypes(t));null!==r&&(null==r?void 0:r.constructor)===Object&&h(r)?a=f(r,i,t,a):"id"!==t&&"type"!==t&&(a=y(r,t,a))}return{data:a}}t.camel=t=>t.replace(/[-_][a-z\u00E0-\u00F6\u00F8-\u00FE]/g,(t=>t.slice(1).toUpperCase())),t.deattribute=e,t.deserialise=function(t){var r,n;if(t)return Array.isArray(t.data)?t=function(t){for(let r of t.data)t.included&&(r=l(r,t.included)),r.relationships&&(r=l(r)),r.attributes&&(r=e(r)),t.data[t.data.indexOf(r)]=r;return t}(t):t.included?t.data=l(t.data,t.included):(null===(r=t.data)||void 0===r?void 0:r.constructor)===Object&&(t.data=l(t.data)),delete t.included,null!==(n=t.data)&&void 0!==n&&n.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=l,t.query=u,t.serialise=function(t,e={},n="POST",a={}){try{return a.camelCaseTypes||(a.camelCaseTypes=t=>t),a.pluralTypes||(a.pluralTypes=t=>t),null===e||Array.isArray(e)&&0===e.length?{data:e}:Array.isArray(e)&&(null==e?void 0:e.length)>0?function(t,e,r,n){c(!0,t,e,r);const a=[];for(const i of e)a.push(b(t,i,r,n).data);return{data:a}}(t,e,n,a):b(t,e,n,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())),t.splitModel=function(t,e={}){e.pluralModel||(e.pluralModel=t=>t),e.resourceCase||(e.resourceCase=t=>t);const r=t.split("/"),n=r.pop();return r.push(e.pluralModel(e.resourceCase(n))),[n,r.join("/")]},Object.defineProperty(t,"__esModule",{value:!0})})); |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./camel.js"),r=require("./deattribute.js"),s=require("./error.js"),i=require("./filterIncludes.js"),t=require("./linkRelationships.js"),l=require("./deserialise.js"),a=require("./kebab.js"),o=require("./query.js"),u=require("./serialise.js"),p=require("./snake.js"),d=require("./splitModel.js");exports.camel=e.camel,exports.deattribute=r.deattribute,exports.error=s.error,exports.filterIncludes=i.filterIncludes,exports.linkRelationships=t.linkRelationships,exports.deserialise=l.deserialise,exports.kebab=a.kebab,exports.query=o.query,exports.serialise=u.serialise,exports.snake=p.snake,exports.splitModel=d.splitModel; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./camel.js"),r=require("./deattribute.js"),s=require("./deserialise.js"),i=require("./error.js"),t=require("./filterIncludes.js"),l=require("./kebab.js"),a=require("./linkRelationships.js"),o=require("./query.js"),u=require("./serialise.js"),p=require("./snake.js"),d=require("./splitModel.js");exports.camel=e.camel,exports.deattribute=r.deattribute,exports.deserialise=s.deserialise,exports.error=i.error,exports.filterIncludes=t.filterIncludes,exports.kebab=l.kebab,exports.linkRelationships=a.linkRelationships,exports.query=o.query,exports.serialise=u.serialise,exports.snake=p.snake,exports.splitModel=d.splitModel; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./deattribute.js");require("./error.js");var i=require("./filterIncludes.js");function t({id:t,type:s,meta:n},r){const a=i.filterIncludes(r,{id:t,type:s});return a.relationships&&l(a,r),n&&(a.meta=n),e.deattribute(a)}function s(e,i,s){e[s]={},e.relationships[s].links&&(e[s].links=e.relationships[s].links),e[s].data=[];for(const n of e.relationships[s].data)e[s].data.push(t(n,i));delete e.relationships[s]}function n(e,i,s){e[s]={},e[s].data=t(e.relationships[s].data,i),e.relationships[s].links&&(e[s].links=e.relationships[s].links),delete e.relationships[s]}function r(e,i){e[i]={},e.relationships[i].links&&(e[i].links=e.relationships[i].links),delete e.relationships[i]}function l(e,i=[]){const{relationships:t}=e;for(const a in t){var l;Array.isArray(null===(l=t[a])||void 0===l?void 0:l.data)?s(e,i,a):t[a].data?n(e,i,a):r(e,a)}return 0===Object.keys(t||[]).length&&(null==t?void 0:t.constructor)===Object&&delete e.relationships,e}exports.linkRelationships=l; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./deattribute.js"),i=require("./filterIncludes.js");function t({id:t,type:s,meta:n},r){const a=i.filterIncludes(r,{id:t,type:s});return a.relationships&&l(a,r),n&&(a.meta=n),e.deattribute(a)}function s(e,i,s){e[s]={},e.relationships[s].links&&(e[s].links=e.relationships[s].links),e[s].data=[];for(const n of e.relationships[s].data)e[s].data.push(t(n,i));delete e.relationships[s]}function n(e,i,s){e[s]={},e[s].data=t(e.relationships[s].data,i),e.relationships[s].links&&(e[s].links=e.relationships[s].links),delete e.relationships[s]}function r(e,i){e[i]={},e.relationships[i].links&&(e[i].links=e.relationships[i].links),delete e.relationships[i]}function l(e,i=[]){const{relationships:t}=e;for(const a in t){var l;Array.isArray(null===(l=t[a])||void 0===l?void 0:l.data)?s(e,i,a):t[a].data?n(e,i,a):r(e,a)}return 0===Object.keys(t||[]).length&&(null==t?void 0:t.constructor)===Object&&delete e.relationships,e}require("./error.js"),exports.linkRelationships=l; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./error.js");function r(t,r,e,n){const a=new Error("".concat(n," requires an ID for the ").concat(r," type"));if(void 0===r)throw new Error("".concat(n," requires a resource type"));if(t){if("POST"!==n&&e.length>0)for(const t of e)if(!t.id)throw a}else{if("object"!=typeof e||0===Object.keys(e).length)throw new Error("".concat(n," requires an object or array body"));if("POST"!==n&&!e.id)throw a}}function e(t,r){let e={};for(const r of Object.keys(t))["id","type"].includes(r)?e[r]=t[r]:e=o(t[r],r,e);return e.type||(e.type=r),e}function n(t,r){const n=[];for(const a of t){const t=e(a);t.type||(t.type=r),n.push(t)}return n}function a(t,r,a,o){var s,i;return o.relationships||(o.relationships={}),o.relationships[a]={data:Array.isArray(t.data)?n(t.data,r):e(t.data,r)},(null!=t&&null!==(s=t.links)&&void 0!==s&&s.self||null!=t&&null!==(i=t.links)&&void 0!==i&&i.related)&&(o.relationships[a].links=t.links),null!=t&&t.meta&&(o.relationships[a].meta=t.meta),o}function o(t,r,e){return e.attributes||(e.attributes={}),"links"!==r||"string"!=typeof t.self&&"string"!=typeof t.related?"meta"===r&&t.constructor===Object?e.meta=t:e.attributes[r]=t:e.links=t,e}function s(t){if(!t.data)return!1;const r=Array.isArray(t.data)?t.data[0]:t.data;return Object.prototype.hasOwnProperty.call(r,"id")}function i(t,e,n,i){r(!1,t,e,n);let l={type:t=i.pluralTypes(i.camelCaseTypes(t))};null!=e&&e.id&&(l.id=String(e.id));for(const t in e){const r=e[t],n=i.pluralTypes(i.camelCaseTypes(t));null!==r&&(null==r?void 0:r.constructor)===Object&&s(r)?l=a(r,n,t,l):"id"!==t&&"type"!==t&&(l=o(r,t,l))}return{data:l}}exports.serialise=function(e,n={},a="POST",o={}){try{return o.camelCaseTypes||(o.camelCaseTypes=t=>t),o.pluralTypes||(o.pluralTypes=t=>t),null===n||Array.isArray(n)&&0===n.length?{data:n}:Array.isArray(n)&&(null==n?void 0:n.length)>0?function(t,e,n,a){r(!0,t,e,n);const o=[];for(const r of e)o.push(i(t,r,n,a).data);return{data:o}}(e,n,a,o):i(e,n,a,o)}catch(r){throw t.error(r)}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./error.js");function r(t,r,e,n){const a=new Error("".concat(n," requires an ID for the ").concat(r," type"));if(void 0===r)throw new Error("".concat(n," requires a resource type"));if(t){if("POST"!==n&&e.length>0)for(const t of e)if(!t.id)throw a}else{if("object"!=typeof e||0===Object.keys(e).length)throw new Error("".concat(n," requires an object or array body"));if("POST"!==n&&!e.id)throw a}}function e(t,r){if(null===t)return t;let e={};for(const r of Object.keys(t))["id","type"].includes(r)?e[r]=t[r]:e=o(t[r],r,e);return e.type||(e.type=r),e}function n(t,r){const n=[];for(const a of t){const t=e(a);t.type||(t.type=r),n.push(t)}return n}function a(t,r,a,o){var l,i;return o.relationships||(o.relationships={}),o.relationships[a]={data:Array.isArray(t.data)?n(t.data,r):e(t.data,r)},(null!=t&&null!==(l=t.links)&&void 0!==l&&l.self||null!=t&&null!==(i=t.links)&&void 0!==i&&i.related)&&(o.relationships[a].links=t.links),null!=t&&t.meta&&(o.relationships[a].meta=t.meta),o}function o(t,r,e){return e.attributes||(e.attributes={}),"links"!==r||"string"!=typeof t.self&&"string"!=typeof t.related?"meta"===r&&t.constructor===Object?e.meta=t:e.attributes[r]=t:e.links=t,e}function l(t){var r;if(null===(null==t?void 0:t.data)||Array.isArray(null==t?void 0:t.data)&&0===(null==t||null===(r=t.data)||void 0===r?void 0:r.length))return!0;if(!t.data)return!1;const e=Array.isArray(t.data)?t.data[0]:t.data;return Object.prototype.hasOwnProperty.call(e,"id")}function i(t,e,n,i){r(!1,t,e,n);let s={type:t=i.pluralTypes(i.camelCaseTypes(t))};null!=e&&e.id&&(s.id=String(e.id));for(const t in e){const r=e[t],n=i.pluralTypes(i.camelCaseTypes(t));null!==r&&(null==r?void 0:r.constructor)===Object&&l(r)?s=a(r,n,t,s):"id"!==t&&"type"!==t&&(s=o(r,t,s))}return{data:s}}exports.serialise=function(e,n={},a="POST",o={}){try{return o.camelCaseTypes||(o.camelCaseTypes=t=>t),o.pluralTypes||(o.pluralTypes=t=>t),null===n||Array.isArray(n)&&0===n.length?{data:n}:Array.isArray(n)&&(null==n?void 0:n.length)>0?function(t,e,n,a){r(!0,t,e,n);const o=[];for(const r of e)o.push(i(t,r,n,a).data);return{data:o}}(e,n,a,o):i(e,n,a,o)}catch(r){throw t.error(r)}}; |
{ | ||
"version": "10.0.0-alpha.9", | ||
"version": "10.0.0-alpha.10", | ||
"name": "kitsu-core", | ||
@@ -60,3 +60,3 @@ "description": "Simple, lightweight & framework agnostic JSON:API (de)serialsation components", | ||
], | ||
"gitHead": "320d1012c76ac28dddd78382638c9ecdd06f77b3", | ||
"gitHead": "0951b65f0636a48e8318c837c330c9303e29ffa6", | ||
"devDependencies": { | ||
@@ -63,0 +63,0 @@ "@size-limit/preset-small-lib": "~4.9.0" |
@@ -130,3 +130,3 @@ <h1 align=center>Kitsu Core</h1> | ||
[packages/kitsu-core/src/camel/index.js:14-14](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/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/8a7d453339bbd80393c63cad5ae6fc758fb0eb4e/packages/kitsu-core/src/camel/index.js#L14-L14 "Source code on GitHub") | ||
@@ -159,3 +159,3 @@ Converts kebab-case and snake_case into camelCase | ||
[packages/kitsu-core/src/deattribute/index.js:29-51](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/deattribute/index.js#L29-L51 "Source code on GitHub") | ||
[packages/kitsu-core/src/deattribute/index.js:29-51](https://github.com/wopian/kitsu/blob/8a7d453339bbd80393c63cad5ae6fc758fb0eb4e/packages/kitsu-core/src/deattribute/index.js#L29-L51 "Source code on GitHub") | ||
@@ -204,3 +204,3 @@ Hoists attributes to be top-level | ||
[packages/kitsu-core/src/deserialise/index.js:57-72](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/deserialise/index.js#L57-L72 "Source code on GitHub") | ||
[packages/kitsu-core/src/deserialise/index.js:57-72](https://github.com/wopian/kitsu/blob/8a7d453339bbd80393c63cad5ae6fc758fb0eb4e/packages/kitsu-core/src/deserialise/index.js#L57-L72 "Source code on GitHub") | ||
@@ -257,3 +257,3 @@ Deserialises a JSON-API response | ||
[packages/kitsu-core/src/error/index.js:27-33](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/error/index.js#L27-L33 "Source code on GitHub") | ||
[packages/kitsu-core/src/error/index.js:27-33](https://github.com/wopian/kitsu/blob/8a7d453339bbd80393c63cad5ae6fc758fb0eb4e/packages/kitsu-core/src/error/index.js#L27-L33 "Source code on GitHub") | ||
@@ -295,3 +295,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:33-46](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/filterIncludes/index.js#L33-L46 "Source code on GitHub") | ||
[packages/kitsu-core/src/filterIncludes/index.js:33-46](https://github.com/wopian/kitsu/blob/8a7d453339bbd80393c63cad5ae6fc758fb0eb4e/packages/kitsu-core/src/filterIncludes/index.js#L33-L46 "Source code on GitHub") | ||
@@ -335,3 +335,3 @@ Filters includes for the specific relationship requested | ||
[packages/kitsu-core/src/kebab/index.js:11-11](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/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/8a7d453339bbd80393c63cad5ae6fc758fb0eb4e/packages/kitsu-core/src/kebab/index.js#L11-L11 "Source code on GitHub") | ||
@@ -354,3 +354,3 @@ Converts camelCase into kebab-case | ||
[packages/kitsu-core/src/linkRelationships/index.js:97-117](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/linkRelationships/index.js#L97-L117 "Source code on GitHub") | ||
[packages/kitsu-core/src/linkRelationships/index.js:97-117](https://github.com/wopian/kitsu/blob/8a7d453339bbd80393c63cad5ae6fc758fb0eb4e/packages/kitsu-core/src/linkRelationships/index.js#L97-L117 "Source code on GitHub") | ||
@@ -393,3 +393,3 @@ Links relationships to included data | ||
[packages/kitsu-core/src/query/index.js:33-44](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/query/index.js#L33-L44 "Source code on GitHub") | ||
[packages/kitsu-core/src/query/index.js:33-44](https://github.com/wopian/kitsu/blob/8a7d453339bbd80393c63cad5ae6fc758fb0eb4e/packages/kitsu-core/src/query/index.js#L33-L44 "Source code on GitHub") | ||
@@ -422,3 +422,3 @@ Constructs a URL query string for JSON:API parameters | ||
[packages/kitsu-core/src/serialise/index.js:210-221](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/serialise/index.js#L210-L221 "Source code on GitHub") | ||
[packages/kitsu-core/src/serialise/index.js:213-224](https://github.com/wopian/kitsu/blob/8a7d453339bbd80393c63cad5ae6fc758fb0eb4e/packages/kitsu-core/src/serialise/index.js#L213-L224 "Source code on GitHub") | ||
@@ -469,3 +469,3 @@ Serialises an object into a JSON-API structure | ||
[packages/kitsu-core/src/snake/index.js:11-11](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/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/8a7d453339bbd80393c63cad5ae6fc758fb0eb4e/packages/kitsu-core/src/snake/index.js#L11-L11 "Source code on GitHub") | ||
@@ -488,3 +488,3 @@ Converts camelCase into snake_case | ||
[packages/kitsu-core/src/splitModel/index.js:29-39](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/splitModel/index.js#L29-L39 "Source code on GitHub") | ||
[packages/kitsu-core/src/splitModel/index.js:29-39](https://github.com/wopian/kitsu/blob/8a7d453339bbd80393c63cad5ae6fc758fb0eb4e/packages/kitsu-core/src/splitModel/index.js#L29-L39 "Source code on GitHub") | ||
@@ -491,0 +491,0 @@ Split model name from the model's resource URL |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
75243
335
0