@apolitical/content 0.7.2-beta.7 → 0.8.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +1 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -89
package/build/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("contentful"),require("query-string")):"function"==typeof define&&define.amd?define(["contentful","query-string"],t):"object"==typeof exports?exports.ApoliticalContent=t(require("contentful"),require("query-string")):e.ApoliticalContent=t(e.contentful,e["query-string"])}(this,(function(e,t){return function(){"use strict";var n={897:function(t){t.exports=e},48:function(e){e.exports=t}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return n[e](i,i.exports,o),i.exports}o.d=function(e,t){for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return function(){o.r(i),o.d(i,{getEntries:function(){return C},getEntry:function(){return T},setContext:function(){return u}});var e=o(897),t=o(48),n={CONTENTFUL:{ENVIRONMENTS_MAPING:{beta:"beta",rc:"rc",live:"master",local:"beta"},LOCALES:{DEFAULT:"en",SUPPORTED:["en","es","fr","pt"]},SPACE:"txbhe1wabmyx",HOSTS:{CDN:"cdn.contentful.com",PREVIEW:"preview.contentful.com"}}};const{CONTENTFUL:{ENVIRONMENTS_MAPING:r,SPACE:s,HOSTS:a}}=n;let c={apiKey:null,previewKey:null,environment:null,isPreview:!1,host:a.CDN,space:s};const u=({apiKey:e,environment:n,isPreview:o=!1,location:i,previewKey:a,space:u=null})=>{c.apiKey=e,c.previewKey=a,c.environment=(e=>{if(!e)throw new Error("Cannot map environment: Environment not defined");if(!r[e])throw new Error(`Cannot map environment: No mapping found for environment ${e}`);return r[e]})(n),c.isPreview=o||(e=>{let n=!1;if(e&&e.search){const r=(0,t.parse)(e.search);n=r.isPreview&&"true"===r.isPreview}return n})(i),c.space=u||s},f=(e=!1)=>{const{apiKey:t,environment:n,isPreview:r,previewKey:o,space:i}=c;return!0===r||!0===e?{accessToken:o,environment:n,host:a.PREVIEW,space:i}:{accessToken:t,environment:n,host:a.CDN,space:i}},l=e=>"object"==typeof e&&null!==e,p=e=>Array.isArray(e)&&e.length,y=(e,t)=>{if(!l(e))throw new Error("Cannot flatten fields");const{fields:n,sys:r,metadata:o}=e;if(!n)throw new Error("Cannot flatten fields");let i={...n};if(l(r)){const{contentType:e,createdAt:t,updatedAt:n}=r;e&&Object.assign(i,{contentType:e.sys.id}),t&&Object.assign(i,{createdAt:t}),n&&Object.assign(i,{updatedAt:n})}if(t&&l(o)){const e=(e=>{const{tags:t}=e;let n=[];if(p(t))for(const e of t)n.push(e.sys.id);return n})(o);p(e)&&Object.assign(i,{tags:e})}return i},{CONTENTFUL:{LOCALES:d}}=n,
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("contentful"),require("query-string")):"function"==typeof define&&define.amd?define(["contentful","query-string"],t):"object"==typeof exports?exports.ApoliticalContent=t(require("contentful"),require("query-string")):e.ApoliticalContent=t(e.contentful,e["query-string"])}(this,(function(e,t){return function(){"use strict";var n={897:function(t){t.exports=e},48:function(e){e.exports=t}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return n[e](i,i.exports,o),i.exports}o.d=function(e,t){for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return function(){o.r(i),o.d(i,{getEntries:function(){return C},getEntry:function(){return T},setContext:function(){return u},updateEntry:function(){return P}});var e=o(897),t=o(48),n={CONTENTFUL:{ENVIRONMENTS_MAPING:{beta:"beta",rc:"rc",live:"master",local:"beta"},LOCALES:{DEFAULT:"en",SUPPORTED:["en","es","fr","pt"]},SPACE:"txbhe1wabmyx",HOSTS:{CDN:"cdn.contentful.com",PREVIEW:"preview.contentful.com"}}};const{CONTENTFUL:{ENVIRONMENTS_MAPING:r,SPACE:s,HOSTS:a}}=n;let c={apiKey:null,previewKey:null,environment:null,isPreview:!1,host:a.CDN,space:s};const u=({apiKey:e,environment:n,isPreview:o=!1,location:i,previewKey:a,space:u=null})=>{c.apiKey=e,c.previewKey=a,c.environment=(e=>{if(!e)throw new Error("Cannot map environment: Environment not defined");if(!r[e])throw new Error(`Cannot map environment: No mapping found for environment ${e}`);return r[e]})(n),c.isPreview=o||(e=>{let n=!1;if(e&&e.search){const r=(0,t.parse)(e.search);n=r.isPreview&&"true"===r.isPreview}return n})(i),c.space=u||s},f=(e=!1)=>{const{apiKey:t,environment:n,isPreview:r,previewKey:o,space:i}=c;return!0===r||!0===e?{accessToken:o,environment:n,host:a.PREVIEW,space:i}:{accessToken:t,environment:n,host:a.CDN,space:i}},l=e=>"object"==typeof e&&null!==e,p=e=>Array.isArray(e)&&e.length,y=(e,t)=>{if(!l(e))throw new Error("Cannot flatten fields");const{fields:n,sys:r,metadata:o}=e;if(!n)throw new Error("Cannot flatten fields");let i={...n};if(l(r)){const{contentType:e,createdAt:t,updatedAt:n}=r;e&&Object.assign(i,{contentType:e.sys.id}),t&&Object.assign(i,{createdAt:t}),n&&Object.assign(i,{updatedAt:n})}if(t&&l(o)){const e=(e=>{const{tags:t}=e;let n=[];if(p(t))for(const e of t)n.push(e.sys.id);return n})(o);p(e)&&Object.assign(i,{tags:e})}return i},{CONTENTFUL:{LOCALES:d}}=n,E=(e,t)=>l(e)&&((e,t)=>Object.prototype.hasOwnProperty.call(e,t))(e,t),w=(e,t)=>{const n=(e=>d.SUPPORTED.includes(e)?e:d.DEFAULT)(t);return E(e,n)?e[n]:E(e,d.DEFAULT)?e[d.DEFAULT]:e},m=e=>l(e)&&e.sys&&"Asset"===e.sys.type,v=(e,t,n)=>{const{title:r,file:o}=y(e);if(!o)throw new Error("Cannot flatten asset");const{contentType:i,fileName:s,url:a,details:c}=w(o,t);if(!a)throw new Error("Cannot flatten asset");return n?{description:r||s,height:c&&c.image&&c.image.height,type:i,url:a,width:c&&c.image&&c.image.width}:a},g=e=>l(e)&&e.sys&&"Entry"===e.sys.type,b=(e,t,n,r)=>{const o={},i=((e,t)=>{const n={};for(const[r,o]of Object.entries(e))n[r]=w(o,t);return n})(y(e,r),t);for(const[e,r]of Object.entries(i))m(r)?o[e]=v(r,t,n):g(r)?o[e]=b(r,t,n):p(r)?o[e]=r.map((e=>m(e)?v(e,t,n):g(e)?b(e,t,n):e)):o[e]=r;return o},h=({items:e})=>{if(!p(e))throw new Error("Cannot read items");return e},O=async(t,n)=>{const r=f(n),o=await(0,e.createClient)(r);return await o.getEntries(t)},T=async(e={},t={},n=!1)=>((e,{flatten:t=!0,locale:n="en",assetDetails:r=!1,tags:o=!1})=>{const i=h(e);return t?b(i[0],n,r,o):i[0]})(await O(e,n),{...e,...t}),C=async(e={},t={},n=!1)=>((e,{flatten:t=!0,locale:n="en",assetDetails:r=!1,tags:o=!1})=>{const i=h(e);return t?((e,t,n,r)=>e.map((e=>b(e,t,n,r))))(i,n,r,o):i})(await O(e,n),{...e,...t}),P=async(t,n={},r,o=!1)=>{const i=f(o),s=(0,e.createClient)(i),a=await s.getEntry(t,n);return Object.keys(r).forEach((e=>{a.fields[e]=r[e]})),a.update()}}(),i}()}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apolitical/content",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-beta.0",
|
|
4
4
|
"description": "React library to interact with Apolitical's content using Contentful CDA",
|
|
5
5
|
"author": "Apolitical Group Limited <engineering@apolitical.co>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"lint": "eslint --ext .js ./lib",
|
|
17
17
|
"format": "prettier --write 'lib/**/*.+(js|json)'",
|
|
18
18
|
"lint-format": "lint-staged",
|
|
19
|
-
"prepare": "husky install",
|
|
19
|
+
"prepare": "cd ../../../../ && husky install modules/v1/apolitical-content/.husky",
|
|
20
20
|
"prepack": "yarn build"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
package/CHANGELOG.md
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [0.7.2] - 2023-03-20
|
|
9
|
-
### Changed
|
|
10
|
-
- Return tags metadata
|
|
11
|
-
|
|
12
|
-
## [0.7.1] - 2023-01-31
|
|
13
|
-
### Added
|
|
14
|
-
- Renovate config file
|
|
15
|
-
|
|
16
|
-
## [0.7.0] - 2022-10-17
|
|
17
|
-
### Changed
|
|
18
|
-
- extends locales support
|
|
19
|
-
|
|
20
|
-
## [0.6.0] - 2022-10-17
|
|
21
|
-
### Added
|
|
22
|
-
- contentType to fields
|
|
23
|
-
|
|
24
|
-
## [0.5.1] - 2022-10-07
|
|
25
|
-
### Fixed
|
|
26
|
-
- The `assetDetails` parameter on nested fields
|
|
27
|
-
|
|
28
|
-
## [0.5.0] - 2022-09-02
|
|
29
|
-
### Added
|
|
30
|
-
- New `assetDetails` parameter to include useful image info
|
|
31
|
-
|
|
32
|
-
## [0.4.2] - 2022-06-28
|
|
33
|
-
### Changed
|
|
34
|
-
- Pipeline refs
|
|
35
|
-
|
|
36
|
-
## [0.4.1] - 2022-05-13
|
|
37
|
-
### Fixed
|
|
38
|
-
- Error handling on set context function
|
|
39
|
-
|
|
40
|
-
## [0.4.0] - 2022-05-10
|
|
41
|
-
### Changed
|
|
42
|
-
- The `environment` is now defined externally
|
|
43
|
-
|
|
44
|
-
## [0.3.0] - 2022-01-31
|
|
45
|
-
### Fixed
|
|
46
|
-
- Buffer dependency
|
|
47
|
-
- Node.js version
|
|
48
|
-
|
|
49
|
-
## [0.2.3] - 2021-10-11
|
|
50
|
-
### Changed
|
|
51
|
-
- Entry parser to return the item when there are no links on the array
|
|
52
|
-
|
|
53
|
-
## [0.2.2] - 2021-09-14
|
|
54
|
-
### Added
|
|
55
|
-
- Injecting `createdAt` and `updatedAt` from `sys` to flattened content
|
|
56
|
-
|
|
57
|
-
## [0.2.1] - 2021-08-03
|
|
58
|
-
### Fixed
|
|
59
|
-
- Issue flattening an array of links
|
|
60
|
-
|
|
61
|
-
## [0.2.0] - 2021-06-24
|
|
62
|
-
### Added
|
|
63
|
-
- Support for individual previews
|
|
64
|
-
|
|
65
|
-
## [0.1.0] - 2021-03-22
|
|
66
|
-
### Changed
|
|
67
|
-
- Moved away from Create React library
|
|
68
|
-
- Project configurations refactored
|
|
69
|
-
- Support for browser and node execution
|
|
70
|
-
|
|
71
|
-
## [0.0.5] - 2021-02-23
|
|
72
|
-
### Added
|
|
73
|
-
- isPreview context variable
|
|
74
|
-
|
|
75
|
-
## [0.0.4] - 2021-02-02
|
|
76
|
-
### Fixed
|
|
77
|
-
- Apolitical website (live) config variable
|
|
78
|
-
|
|
79
|
-
## [0.0.3] - 2021-02-01
|
|
80
|
-
### Added
|
|
81
|
-
- IE support
|
|
82
|
-
|
|
83
|
-
## [0.0.2] - 2021-01-18
|
|
84
|
-
### Fixed
|
|
85
|
-
- Webpack config to export library functionality
|
|
86
|
-
|
|
87
|
-
## [0.0.1] - 2021-01-18
|
|
88
|
-
### Added
|
|
89
|
-
- Initial setup
|