contentful-parsers
Advanced tools
Comparing version 1.2.14 to 1.2.15
@@ -50,2 +50,4 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
function cleanClone(clone, ref) { | ||
var _clone$sys, _clone$sys2; | ||
if (!clone) return clone; // Capitalize entry __typename | ||
@@ -70,3 +72,3 @@ | ||
if (clone.sys.createdAt) { | ||
if (clone === null || clone === void 0 ? void 0 : (_clone$sys = clone.sys) === null || _clone$sys === void 0 ? void 0 : _clone$sys.createdAt) { | ||
clone.sys.firstPublishedAt = clone.sys.createdAt; | ||
@@ -76,3 +78,3 @@ delete clone.sys.createdAt; | ||
if (clone.sys.updatedAt) { | ||
if (clone === null || clone === void 0 ? void 0 : (_clone$sys2 = clone.sys) === null || _clone$sys2 === void 0 ? void 0 : _clone$sys2.updatedAt) { | ||
clone.sys.publishedAt = clone.sys.updatedAt; | ||
@@ -88,2 +90,6 @@ delete clone.sys.updatedAt; | ||
if (clone.createdAt) { | ||
if (!clone.sys.firstPublishedAt) { | ||
clone.sys.firstPublishedAt = clone.createdAt; | ||
} | ||
delete clone.createdAt; | ||
@@ -93,2 +99,6 @@ } | ||
if (clone.updatedAt) { | ||
if (!clone.sys.publishedAt) { | ||
clone.sys.publishedAt = clone.updatedAt; | ||
} | ||
delete clone.updatedAt; | ||
@@ -95,0 +105,0 @@ } |
{ | ||
"name": "contentful-parsers", | ||
"version": "1.2.14", | ||
"version": "1.2.15", | ||
"description": "Library of useful parsers to use when working with Contentful API responses.", | ||
@@ -5,0 +5,0 @@ "repository": "ryanhefner/contentful-parsers.git", |
@@ -61,2 +61,4 @@ "use strict"; | ||
function cleanClone(clone, ref) { | ||
var _clone$sys, _clone$sys2; | ||
if (!clone) return clone; // Capitalize entry __typename | ||
@@ -81,3 +83,3 @@ | ||
if (clone.sys.createdAt) { | ||
if (clone === null || clone === void 0 ? void 0 : (_clone$sys = clone.sys) === null || _clone$sys === void 0 ? void 0 : _clone$sys.createdAt) { | ||
clone.sys.firstPublishedAt = clone.sys.createdAt; | ||
@@ -87,3 +89,3 @@ delete clone.sys.createdAt; | ||
if (clone.sys.updatedAt) { | ||
if (clone === null || clone === void 0 ? void 0 : (_clone$sys2 = clone.sys) === null || _clone$sys2 === void 0 ? void 0 : _clone$sys2.updatedAt) { | ||
clone.sys.publishedAt = clone.sys.updatedAt; | ||
@@ -99,2 +101,6 @@ delete clone.sys.updatedAt; | ||
if (clone.createdAt) { | ||
if (!clone.sys.firstPublishedAt) { | ||
clone.sys.firstPublishedAt = clone.createdAt; | ||
} | ||
delete clone.createdAt; | ||
@@ -104,2 +110,6 @@ } | ||
if (clone.updatedAt) { | ||
if (!clone.sys.publishedAt) { | ||
clone.sys.publishedAt = clone.updatedAt; | ||
} | ||
delete clone.updatedAt; | ||
@@ -106,0 +116,0 @@ } |
@@ -56,3 +56,3 @@ import { fieldsParser } from './fieldsParser' | ||
// Map dates to GraphQL equivalents | ||
if (clone.sys.createdAt) { | ||
if (clone?.sys?.createdAt) { | ||
clone.sys.firstPublishedAt = clone.sys.createdAt | ||
@@ -62,3 +62,3 @@ delete clone.sys.createdAt | ||
if (clone.sys.updatedAt) { | ||
if (clone?.sys?.updatedAt) { | ||
clone.sys.publishedAt = clone.sys.updatedAt | ||
@@ -74,2 +74,5 @@ delete clone.sys.updatedAt | ||
if (clone.createdAt) { | ||
if (!clone.sys.firstPublishedAt) { | ||
clone.sys.firstPublishedAt = clone.createdAt | ||
} | ||
delete clone.createdAt | ||
@@ -79,2 +82,5 @@ } | ||
if (clone.updatedAt) { | ||
if (!clone.sys.publishedAt) { | ||
clone.sys.publishedAt = clone.updatedAt | ||
} | ||
delete clone.updatedAt | ||
@@ -81,0 +87,0 @@ } |
@@ -317,3 +317,2 @@ import { graphqlParser } from './graphqlParser'; | ||
}, | ||
createdAt: "2020-10-06T20:51:57.359Z", | ||
environment: { | ||
@@ -326,4 +325,6 @@ sys: { | ||
}, | ||
firstPublishedAt: "2020-10-06T20:51:57.359Z", | ||
id: "4oB6Wn7uraF4N3uVSbjkoS", | ||
locale: "en-US", | ||
publishedAt: "2020-10-06T20:51:57.359Z", | ||
revision: 1, | ||
@@ -338,3 +339,2 @@ space: { | ||
type: "Entry", | ||
updatedAt: "2020-10-06T20:51:57.359Z", | ||
}, | ||
@@ -341,0 +341,0 @@ title: 'Empty Lesson', |
@@ -1,2 +0,2 @@ | ||
/*! contentful-parsers v1.2.14 | (c) 2020 Ryan Hefner | MIT License | https://github.com/ryanhefner/contentful-parsers.git !*/ | ||
/*! contentful-parsers v1.2.15 | (c) 2020 Ryan Hefner | MIT License | https://github.com/ryanhefner/contentful-parsers.git !*/ | ||
(function (global, factory) { | ||
@@ -192,2 +192,4 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
function cleanClone(clone, ref) { | ||
var _clone$sys, _clone$sys2; | ||
if (!clone) return clone; // Capitalize entry __typename | ||
@@ -212,3 +214,3 @@ | ||
if (clone.sys.createdAt) { | ||
if (clone === null || clone === void 0 ? void 0 : (_clone$sys = clone.sys) === null || _clone$sys === void 0 ? void 0 : _clone$sys.createdAt) { | ||
clone.sys.firstPublishedAt = clone.sys.createdAt; | ||
@@ -218,3 +220,3 @@ delete clone.sys.createdAt; | ||
if (clone.sys.updatedAt) { | ||
if (clone === null || clone === void 0 ? void 0 : (_clone$sys2 = clone.sys) === null || _clone$sys2 === void 0 ? void 0 : _clone$sys2.updatedAt) { | ||
clone.sys.publishedAt = clone.sys.updatedAt; | ||
@@ -230,2 +232,6 @@ delete clone.sys.updatedAt; | ||
if (clone.createdAt) { | ||
if (!clone.sys.firstPublishedAt) { | ||
clone.sys.firstPublishedAt = clone.createdAt; | ||
} | ||
delete clone.createdAt; | ||
@@ -235,2 +241,6 @@ } | ||
if (clone.updatedAt) { | ||
if (!clone.sys.publishedAt) { | ||
clone.sys.publishedAt = clone.updatedAt; | ||
} | ||
delete clone.updatedAt; | ||
@@ -237,0 +247,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["contentful-parsers"]={})}(this,function(e){"use strict";function R(e,s,l){function o(e){return e&&"object"==typeof e&&e.hasOwnProperty("sys")&&1===Object.keys(e).length}function u(t,e,n,r){if(void 0===n&&(n={}),void 0===r&&(r=0),!t||"object"!=typeof t)return n;if(r>=s.include)return n;var i=Object.assign({},n);return Object.keys(t).forEach(function(e){i[e]=t[e]&&t[e].fields&&l.parseRefs?u(t[e].fields,t[e].sys,i[e],r+1):function t(e,n){return void 0===n&&(n=0),o(e)?null:Array.isArray(e)&&l.parseArrays?e.filter(function(e){return!o(e)}).map(function(e){return e&&"object"==typeof e&&e.fields?u(e.fields,e.sys,{},n+1):t(e,n+1)}):e}(t[e],r+1)}),e&&e.contentType&&e.contentType.sys&&e.contentType.sys.id&&(i.id=e.id,i.__typename=e.contentType.sys.id),e&&e.updatedAt&&(i.updatedAt=e.updatedAt),e&&e.createdAt&&(i.createdAt=e.createdAt),i}void 0===s&&(s={include:10}),void 0===l&&(l={parseArrays:!0,parseRefs:!0});var t=Object.assign({},e);return u(t.fields,t.sys)}var r=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e};function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function s(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach(function(e){r(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function S(e){return e.substring(0,1).toUpperCase()+e.substring(1)}e.contentfulResolver=function(e,t){return t&&t.hasOwnProperty(e)?t[e]:null},e.fieldsParser=R,e.graphqlParser=function(e,t,n,E){var r,i;function k(e,t){return e&&(e.hasOwnProperty("__typename")&&e.__typename&&(e.__typename=S(e.__typename)),t&&t.sys?e.sys=s(s({},t.sys),{},{__typename:"Sys"}):t.id&&(e.sys={id:t.id,__typename:"Sys"}),e.sys.createdAt&&(e.sys.firstPublishedAt=e.sys.createdAt,delete e.sys.createdAt),e.sys.updatedAt&&(e.sys.publishedAt=e.sys.updatedAt,delete e.sys.updatedAt),e.id&&delete e.id,e.createdAt&&delete e.createdAt,e.updatedAt&&delete e.updatedAt),e}function C(i,s,l,o){var e;if(void 0===o&&(o=0),!i)return null;if(o>=E.include)return i;var u=Object.assign({},i.hasOwnProperty("sys")&&i.hasOwnProperty("fields")?R(i,E,{parseArrays:!1,parseRefs:!1}):i);Object.keys(u).forEach(function(n){var e=u[n];if(Array.isArray(e)){var t=!1;if(e.filter(function(e){return!!e}).forEach(function(e){(e.hasOwnProperty("sys")&&e.hasOwnProperty("fields")||e.hasOwnProperty("__typename"))&&(t=!0)}),t){var r=n+"Collection";u[r]=D(e,""+s+S(r),null==l?void 0:l[r],o+1),delete u[n]}else u[n]=e.map(function(e,t){return k(e,i&&i.fields&&i.fields[n][t])}).filter(function(e){return!!e})}else e&&"object"==typeof e&&(e.hasOwnProperty("__typename")||e.hasOwnProperty("sys")&&e.hasOwnProperty("fields"))?u[n]=C(e,s,null==l?void 0:l[n],o+1):u[n]=e});var t,n,r,d,a,f,c,y,p,v,h,O,b,m,_,A,j,g,P,w=k(u,i),T="Asset"===(null==w||null===(e=w.sys)||void 0===e?void 0:e.type)?(t=w,(P=Object.assign({},t)).__typename="Asset",P.url=null==P||null===(n=P.file)||void 0===n?void 0:n.url,P.contentType=null==P||null===(r=P.file)||void 0===r?void 0:r.contentType,P.size=null==P||null===(d=P.file)||void 0===d||null===(a=d.details)||void 0===a?void 0:a.size,P.width=(null==P||null===(f=P.file)||void 0===f||null===(c=f.details)||void 0===c||null===(y=c.image)||void 0===y?void 0:y.width)||(null==P||null===(p=P.file)||void 0===p||null===(v=p.details)||void 0===v||null===(h=v.video)||void 0===h?void 0:h.width),P.height=(null==P||null===(O=P.file)||void 0===O||null===(b=O.details)||void 0===b||null===(m=b.image)||void 0===m?void 0:m.height)||(null==P||null===(_=P.file)||void 0===_||null===(A=_.details)||void 0===A||null===(j=A.video)||void 0===j?void 0:j.height),P.fileName=null==P||null===(g=P.file)||void 0===g?void 0:g.fileName,P.url.startsWith("https:")||(P.url="https:"+P.url),delete P.file,P):w;return function r(e,i,s){if(!e||!s)return e;var l=Object.assign({},e||{});return Object.keys(s).forEach(function(e){if(!l.hasOwnProperty(e))if(e.endsWith("Collection")){var t=e.replace("Collection",""),n=l.hasOwnProperty(t)&&l[t];n?(l[e]=D(n,""+i+S(e),s[e]),delete l[t]):l[e]=D([],""+i+S(e),s[e])}else e.startsWith("...")&&l.__typename&&l.__typename===e.replace("...","")?Object.assign(l,r(l,i,s[e])):l[e]=null}),l}(T,T.__typename||s,l)}function D(e,t,n,r){return void 0===e&&(e=[]),void 0===r&&(r=0),{__typename:t,total:(e&&Array.isArray(e)?e:[]).length,items:(e&&Array.isArray(e)?e:[]).map(function(e){return C(e,t,null==n?void 0:n.items,r)}).filter(function(e){return!!e})}}return void 0===E&&(E={include:10}),null!=t&&t.items?((i={})[e]=D(t.items,S(e),null==n?void 0:n[e]),i):((r={})[e]=s({__typename:S(e)},C(t,S(e),null==n?void 0:n[e])),r)},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["contentful-parsers"]={})}(this,function(e){"use strict";function R(e,s,l){function o(e){return e&&"object"==typeof e&&e.hasOwnProperty("sys")&&1===Object.keys(e).length}function u(t,e,n,r){if(void 0===n&&(n={}),void 0===r&&(r=0),!t||"object"!=typeof t)return n;if(r>=s.include)return n;var i=Object.assign({},n);return Object.keys(t).forEach(function(e){i[e]=t[e]&&t[e].fields&&l.parseRefs?u(t[e].fields,t[e].sys,i[e],r+1):function t(e,n){return void 0===n&&(n=0),o(e)?null:Array.isArray(e)&&l.parseArrays?e.filter(function(e){return!o(e)}).map(function(e){return e&&"object"==typeof e&&e.fields?u(e.fields,e.sys,{},n+1):t(e,n+1)}):e}(t[e],r+1)}),e&&e.contentType&&e.contentType.sys&&e.contentType.sys.id&&(i.id=e.id,i.__typename=e.contentType.sys.id),e&&e.updatedAt&&(i.updatedAt=e.updatedAt),e&&e.createdAt&&(i.createdAt=e.createdAt),i}void 0===s&&(s={include:10}),void 0===l&&(l={parseArrays:!0,parseRefs:!0});var t=Object.assign({},e);return u(t.fields,t.sys)}var r=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e};function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function s(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach(function(e){r(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function S(e){return e.substring(0,1).toUpperCase()+e.substring(1)}e.contentfulResolver=function(e,t){return t&&t.hasOwnProperty(e)?t[e]:null},e.fieldsParser=R,e.graphqlParser=function(e,t,n,E){var r,i;function k(e,t){var n,r;return e&&(e.hasOwnProperty("__typename")&&e.__typename&&(e.__typename=S(e.__typename)),t&&t.sys?e.sys=s(s({},t.sys),{},{__typename:"Sys"}):t.id&&(e.sys={id:t.id,__typename:"Sys"}),null!=e&&(null!==(n=e.sys)&&void 0!==n&&n.createdAt)&&(e.sys.firstPublishedAt=e.sys.createdAt,delete e.sys.createdAt),null!=e&&(null!==(r=e.sys)&&void 0!==r&&r.updatedAt)&&(e.sys.publishedAt=e.sys.updatedAt,delete e.sys.updatedAt),e.id&&delete e.id,e.createdAt&&(e.sys.firstPublishedAt||(e.sys.firstPublishedAt=e.createdAt),delete e.createdAt),e.updatedAt&&(e.sys.publishedAt||(e.sys.publishedAt=e.updatedAt),delete e.updatedAt)),e}function C(i,s,l,o){var e;if(void 0===o&&(o=0),!i)return null;if(o>=E.include)return i;var u=Object.assign({},i.hasOwnProperty("sys")&&i.hasOwnProperty("fields")?R(i,E,{parseArrays:!1,parseRefs:!1}):i);Object.keys(u).forEach(function(n){var e=u[n];if(Array.isArray(e)){var t=!1;if(e.filter(function(e){return!!e}).forEach(function(e){(e.hasOwnProperty("sys")&&e.hasOwnProperty("fields")||e.hasOwnProperty("__typename"))&&(t=!0)}),t){var r=n+"Collection";u[r]=D(e,""+s+S(r),null==l?void 0:l[r],o+1),delete u[n]}else u[n]=e.map(function(e,t){return k(e,i&&i.fields&&i.fields[n][t])}).filter(function(e){return!!e})}else e&&"object"==typeof e&&(e.hasOwnProperty("__typename")||e.hasOwnProperty("sys")&&e.hasOwnProperty("fields"))?u[n]=C(e,s,null==l?void 0:l[n],o+1):u[n]=e});var t,n,r,d,a,f,y,c,p,v,h,b,O,A,m,_,j,P,g,w=k(u,i),T="Asset"===(null==w||null===(e=w.sys)||void 0===e?void 0:e.type)?(t=w,(g=Object.assign({},t)).__typename="Asset",g.url=null==g||null===(n=g.file)||void 0===n?void 0:n.url,g.contentType=null==g||null===(r=g.file)||void 0===r?void 0:r.contentType,g.size=null==g||null===(d=g.file)||void 0===d||null===(a=d.details)||void 0===a?void 0:a.size,g.width=(null==g||null===(f=g.file)||void 0===f||null===(y=f.details)||void 0===y||null===(c=y.image)||void 0===c?void 0:c.width)||(null==g||null===(p=g.file)||void 0===p||null===(v=p.details)||void 0===v||null===(h=v.video)||void 0===h?void 0:h.width),g.height=(null==g||null===(b=g.file)||void 0===b||null===(O=b.details)||void 0===O||null===(A=O.image)||void 0===A?void 0:A.height)||(null==g||null===(m=g.file)||void 0===m||null===(_=m.details)||void 0===_||null===(j=_.video)||void 0===j?void 0:j.height),g.fileName=null==g||null===(P=g.file)||void 0===P?void 0:P.fileName,g.url.startsWith("https:")||(g.url="https:"+g.url),delete g.file,g):w;return function r(e,i,s){if(!e||!s)return e;var l=Object.assign({},e||{});return Object.keys(s).forEach(function(e){if(!l.hasOwnProperty(e))if(e.endsWith("Collection")){var t=e.replace("Collection",""),n=l.hasOwnProperty(t)&&l[t];n?(l[e]=D(n,""+i+S(e),s[e]),delete l[t]):l[e]=D([],""+i+S(e),s[e])}else e.startsWith("...")&&l.__typename&&l.__typename===e.replace("...","")?Object.assign(l,r(l,i,s[e])):l[e]=null}),l}(T,T.__typename||s,l)}function D(e,t,n,r){return void 0===e&&(e=[]),void 0===r&&(r=0),{__typename:t,total:(e&&Array.isArray(e)?e:[]).length,items:(e&&Array.isArray(e)?e:[]).map(function(e){return C(e,t,null==n?void 0:n.items,r)}).filter(function(e){return!!e})}}return void 0===E&&(E={include:10}),null!=t&&t.items?((i={})[e]=D(t.items,S(e),null==n?void 0:n[e]),i):((r={})[e]=s({__typename:S(e)},C(t,S(e),null==n?void 0:n[e])),r)},Object.defineProperty(e,"__esModule",{value:!0})}); |
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
83765
1820