Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kitsu-core

Package Overview
Dependencies
Maintainers
1
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kitsu-core - npm Package Compare versions

Comparing version 8.2.0 to 8.3.0

17

CHANGELOG.md

@@ -6,2 +6,19 @@ # Change Log

# [8.3.0](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/compare/v8.2.0...v8.3.0) (2020-05-02)
### Chores
* **release:** update documentation ([5382aad](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/5382aad))
### New Features
* **kitsu-core:** check id exists before serialising objects/arrays as relationships ([#402](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/issues/402)) ([79287d0](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/79287d0))
* **kitsu-core:** serialise deletion of to-one and to-many relationships ([#403](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/issues/403)) ([5f868e7](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/5f868e7))
# [8.2.0](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/compare/v8.1.1...v8.2.0) (2020-04-26)

@@ -8,0 +25,0 @@

2

lib/filterIncludes.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./error.js");exports.filterIncludes=function(r,t){let{id:i,type:s}=t;try{const e=r.filter(e=>e.id===i&&e.type===s)[0]||{id:i,type:s};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{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)}};

@@ -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:i}=e;try{const e=t.filter(t=>t.id===n&&t.type===i)[0]||{id:n,type:i};return Object.assign({},e)}catch(t){r(t)}}function i(t,r){let{id:i,type:o,meta:a}=t;const c=n(r,{id:i,type:o});return c.relationships&&s(c,r),a&&(c.meta=a),e(c)}function o(t,e,r){t[r]=[];for(const n of t.relationships[r].data)t[r].push(i(n,e))}function a(t,e,r){t[r]=i(t.relationships[r].data,e),delete t[r].relationships}function s(t,e){const{relationships:r}=t;let n=!1;for(const i in r)r[i].data&&Array.isArray(r[i].data)?(o(t,e,i),n=!0):r[i].data&&(a(t,e,i),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,i){if("string"!=typeof t.id)throw new Error(l(i,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,i){return n.relationships||(n.relationships={}),n.relationships[r]={data:t.map(t=>{let{id:n,type:o}=t;if(!n)throw new Error(l(i,r));return{id:n,type:o||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.plural(this.camel(t)):this.camel(t);let i={type:r};d(e,n,r),e.id&&(i.id=String(e.id));for(const t in e){const r=e[t],o=this.plural?this.plural(this.camel(t)):this.camel(t);null!==r&&r.constructor===Object?i=p(r,o,t,i,n):null!==r&&Array.isArray(r)?i=f(r,o,t,i,n):"id"!==t&&"type"!==t&&(i=h(r,t,i))}return{data:i}}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{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})}));

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./deattribute.js");require("./error.js");var t=require("./filterIncludes.js");function r(r,i){let{id:s,type:n,meta:o}=r;const l=t.filterIncludes(i,{id:s,type:n});return l.relationships&&a(l,i),o&&(l.meta=o),e.deattribute(l)}function i(e,t,i){e[i]=[];for(const s of e.relationships[i].data)e[i].push(r(s,t))}function s(e,t,i){e[i]=r(e.relationships[i].data,t),delete e[i].relationships}function a(e,t){const{relationships:r}=e;let a=!1;for(const n in r)r[n].data&&Array.isArray(r[n].data)?(i(e,t,n),a=!0):r[n].data&&(s(e,t,n),a=!0);return a&&delete e.relationships,e}exports.linkRelationships=a;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./deattribute.js");require("./error.js");var t=require("./filterIncludes.js");function r({id:r,type:i,meta:s},n){const o=t.filterIncludes(n,{id:r,type:i});return o.relationships&&a(o,n),s&&(o.meta=s),e.deattribute(o)}function i(e,t,i){e[i]=[];for(const s of e.relationships[i].data)e[i].push(r(s,t))}function s(e,t,i){e[i]=r(e.relationships[i].data,t),delete e[i].relationships}function a(e,t){const{relationships:r}=e;let a=!1;for(const n in r)r[n].data&&Array.isArray(r[n].data)?(i(e,t,n),a=!0):r[n].data&&(s(e,t,n),a=!0);return a&&delete e.relationships,e}exports.linkRelationships=a;

@@ -1,1 +0,1 @@

"use strict";function e(e,t){return null!==e&&"object"==typeof e?o(e,t):encodeURIComponent(t)+"="+encodeURIComponent(e)}function o(o){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const n=[];for(const c in o)Object.prototype.hasOwnProperty.call(o,c)&&n.push(e(o[c],t?"".concat(t,"[").concat(c,"]"):c));return n.join("&")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.query=o;
"use strict";function e(o,t=null){const n=[];for(const p in o)Object.prototype.hasOwnProperty.call(o,p)&&n.push((c=o[p],r=t?"".concat(t,"[").concat(p,"]"):p,null!==c&&"object"==typeof c?e(c,r):encodeURIComponent(r)+"="+encodeURIComponent(c)));var c,r;return n.join("&")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.query=e;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./error.js");const r=(t,r)=>"".concat(t," requires an ID for the ").concat(r," relationships");function e(t,r,e){if(t.constructor!==Object||0===Object.keys(t).length)throw new Error("".concat(r," requires a JSON object body"));if("POST"!==r&&!t.id)throw new Error("".concat(r," requires an ID for the ").concat(e," type"))}function i(t,e,i,n,o){if("string"!=typeof t.id)throw new Error(r(o,i));return n.relationships||(n.relationships={}),t.type||(t.type=e),n.relationships[i]={data:Object.assign(t)},n}function n(t,e,i,n,o){return n.relationships||(n.relationships={}),n.relationships[i]={data:t.map(t=>{let{id:n,type:s}=t;if(!n)throw new Error(r(o,i));return{id:n,type:s||e}})},n}function o(t,r,e){return e.attributes||(e.attributes={}),e.attributes[r]=t,e}exports.serialise=function(r){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"POST";try{const t=this.plural?this.plural(this.camel(r)):this.camel(r);let c={type:t};e(s,a,t),s.id&&(c.id=String(s.id));for(const t in s){const r=s[t],e=this.plural?this.plural(this.camel(t)):this.camel(t);null!==r&&r.constructor===Object?c=i(r,e,t,c,a):null!==r&&Array.isArray(r)?c=n(r,e,t,c,a):"id"!==t&&"type"!==t&&(c=o(r,t,c))}return{data:c}}catch(r){throw t.error(r)}};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./error.js");function r(t,r,e,i,n){return i.relationships||(i.relationships={}),t.type||(t.type=r),i.relationships[e]={data:Object.assign(t)},i}function e(t,r,e,i,n){return i.relationships||(i.relationships={}),i.relationships[e]={data:t.map(({id:t,type:e})=>({id:t,type:e||r}))},i}function i(t,r,e){return e.attributes||(e.attributes={}),e.attributes[r]=t,e}function n(t){return Object.prototype.hasOwnProperty.call(t,"id")}exports.serialise=function(s,a={},o="POST"){try{if(null===a||Array.isArray(a)&&0===a.length)return{data:a};const t=this.plural?this.plural(this.camel(s)):this.camel(s);let c={type:t};!function(t,r,e){if(t.constructor!==Object||0===Object.keys(t).length)throw new Error("".concat(r," requires a JSON object body"));if("POST"!==r&&!t.id)throw new Error("".concat(r," requires an ID for the ").concat(e," type"))}(a,o,t),a.id&&(c.id=String(a.id));for(const t in a){const s=a[t],o=this.plural?this.plural(this.camel(t)):this.camel(t);null!==s&&s.constructor===Object&&n(s)?c=r(s,o,t,c):null!==s&&Array.isArray(s)&&s.length>0&&n(s[0])?c=e(s,o,t,c):"id"!==t&&"type"!==t&&(c=i(s,t,c))}return{data:c}}catch(r){throw t.error(r)}};
{
"version": "8.2.0",
"version": "8.3.0",
"name": "kitsu-core",

@@ -55,3 +55,3 @@ "description": "Core serialisation and deserialsation functions for the kitsu JSON:API client",

],
"gitHead": "7164fae3ffbb2f9a1e8f20b636794f26395dd8af",
"gitHead": "bdea71e4729f57c9227eb3a6e58f6ab269c0c9cf",
"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/82b8eb4223c32ee16b3a6aec132ef843bf567493/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/79287d0a71d36e540b69c27f86b115e56ed0674d/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/82b8eb4223c32ee16b3a6aec132ef843bf567493/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/79287d0a71d36e540b69c27f86b115e56ed0674d/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/82b8eb4223c32ee16b3a6aec132ef843bf567493/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/79287d0a71d36e540b69c27f86b115e56ed0674d/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/82b8eb4223c32ee16b3a6aec132ef843bf567493/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/79287d0a71d36e540b69c27f86b115e56ed0674d/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/82b8eb4223c32ee16b3a6aec132ef843bf567493/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/79287d0a71d36e540b69c27f86b115e56ed0674d/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/82b8eb4223c32ee16b3a6aec132ef843bf567493/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/79287d0a71d36e540b69c27f86b115e56ed0674d/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/82b8eb4223c32ee16b3a6aec132ef843bf567493/packages/kitsu-core/src/serialise/index.js#L96-L121 "Source code on GitHub")
[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")

@@ -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/82b8eb4223c32ee16b3a6aec132ef843bf567493/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/79287d0a71d36e540b69c27f86b115e56ed0674d/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/82b8eb4223c32ee16b3a6aec132ef843bf567493/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/79287d0a71d36e540b69c27f86b115e56ed0674d/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/82b8eb4223c32ee16b3a6aec132ef843bf567493/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/79287d0a71d36e540b69c27f86b115e56ed0674d/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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc