@griddo/cx 1.75.222 → 1.75.223

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 CHANGED
@@ -25,7 +25,7 @@ GFS4: `),console.error(e)});G[Q]||(ta=global[Q]||[],na(G,ta),G.close=function(e)
25
25
  \u2502 Access credentials failure \u2502
26
26
  \u2502 Check that the login details are correct in your .env file \u2502
27
27
  \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F
28
- `)),process.exit(1)}}},hr=new An;var Xu=Y(On()),Ku=Y(yt()),Qu=Y(Gt());var lp=Y(yt()),Gu=Y(Gt()),fp=Y(tu()),zu=Y(Hu());var Uu="1.75.222";Gu.default.config();var hp=!!process.env.GRIDDO_BUILD_LOGS&&!!JSON.parse(process.env.GRIDDO_BUILD_LOGS)||!!process.env.LOGS&&!!JSON.parse(process.env.LOGS);function Wu(...e){hp&&console.info(...e)}function Ju(e){return new Promise(t=>setTimeout(t,e))}function ci(e,t=3){return(e/1e3).toFixed(t)}function Vu(e){return"site"in e&&e.site?e?.site:void 0}function ui(...e){let t=performance.now();return e.forEach(r=>r()),ci(performance.now()-t)}function Yu(){let e=`
28
+ `)),process.exit(1)}}},hr=new An;var Xu=Y(On()),Ku=Y(yt()),Qu=Y(Gt());var lp=Y(yt()),Gu=Y(Gt()),fp=Y(tu()),zu=Y(Hu());var Uu="1.75.223";Gu.default.config();var hp=!!process.env.GRIDDO_BUILD_LOGS&&!!JSON.parse(process.env.GRIDDO_BUILD_LOGS)||!!process.env.LOGS&&!!JSON.parse(process.env.LOGS);function Wu(...e){hp&&console.info(...e)}function Ju(e){return new Promise(t=>setTimeout(t,e))}function ci(e,t=3){return(e/1e3).toFixed(t)}function Vu(e){return"site"in e&&e.site?e?.site:void 0}function ui(...e){let t=performance.now();return e.forEach(r=>r()),ci(performance.now()-t)}function Yu(){let e=`
29
29
  \xB7\xB7
30
30
  \xB7\xB7
31
31
  \xB7\xB7
@@ -41,7 +41,7 @@ GFS4: `),console.error(e)});G[Q]||(ta=global[Q]||[],na(G,ta),G.close=function(e)
41
41
  \xB7\xB7
42
42
  \xB7\xB7
43
43
  \xB7\xB7
44
- `;console.log(zu.default.cristal(e))}Qu.default.config();var{env:{RETRY_WAIT_SECONDS:dp="4",RETRY_ATTEMPTS:pp="1"}}=process;async function Zu(e){let{endpoint:t,body:r,cached:n,attempt:i=1,method:s,headers:o}=e,a={endpoint:t,body:r,cached:n};if(n){let c=ds(a);if(c)return c}try{let{data:c}=await(0,Xu.default)({url:t,method:s,headers:{...o,...hr.headers},data:r});return hs(a,c),c}catch(c){let d=c;return d.response?.status===404?null:((i>parseInt(pp)||!d.response)&&process.exit(1),mp(d,{callInfo:{endpoint:t,body:r}}),console.warn(`Waiting for retry: ${s}`,t),await Ju(parseInt(dp)*1e3),Zu({endpoint:t,body:r,cached:n,method:s,attempt:i+1}))}}async function el(e){let t=new Date,{endpoint:r}=e,n=await Zu({...e,method:"get"}),i=e.cached?"(cached)":"(fetch)",s=Vu(n),o=s?`site: ${s} `:"",a=ci(new Date().getTime()-t.getTime());return Wu(`GET ${i} ${o} ${r} - ${a}s`),n}function mp(e,t){let{response:r,message:n,stack:i}=e,{callInfo:s}=t,{status:o,statusText:a,data:c}=r||{},d=[];for(let m of Object.keys(s)){let w=m;d.push(`${m}: ${typeof s[w]=="object"?JSON.stringify(s[w]):s[w]}`)}let h=d.join(`
44
+ `;console.log(zu.default.cristal(e))}Qu.default.config();var{env:{RETRY_WAIT_SECONDS:dp="4",RETRY_ATTEMPTS:pp="1"}}=process;async function Zu(e){let{endpoint:t,body:r,cached:n,attempt:i=1,method:s,headers:o}=e,a={endpoint:t,body:r,headers:o,cached:n};if(n){let c=ds(a);if(c)return c}try{let{data:c}=await(0,Xu.default)({url:t,method:s,headers:{...o,...hr.headers},data:r});return hs(a,c),c}catch(c){let d=c;return d.response?.status===404?null:((i>parseInt(pp)||!d.response)&&process.exit(1),mp(d,{callInfo:{endpoint:t,body:r}}),console.warn(`Waiting for retry: ${s}`,t),await Ju(parseInt(dp)*1e3),Zu({endpoint:t,body:r,cached:n,method:s,attempt:i+1}))}}async function el(e){let t=new Date,{endpoint:r}=e,n=await Zu({...e,method:"get"}),i=e.cached?"(cached)":"(fetch)",s=Vu(n),o=s?`site: ${s} `:"",a=ci(new Date().getTime()-t.getTime());return Wu(`GET ${i} ${o} ${r} - ${a}s`),n}function mp(e,t){let{response:r,message:n,stack:i}=e,{callInfo:s}=t,{status:o,statusText:a,data:c}=r||{},d=[];for(let m of Object.keys(s)){let w=m;d.push(`${m}: ${typeof s[w]=="object"?JSON.stringify(s[w]):s[w]}`)}let h=d.join(`
45
45
  `),p=r?`Code: ${o} - ${a}
46
46
  Response: ${JSON.stringify(c)}`:"",y=`${n}
47
47
  ${i}`;console.warn(Ku.default.bold.red(`
@@ -23,7 +23,7 @@ GFS4: `),console.error(e)});H[K]||(ys=global[K]||[],vs(H,ys),H.close=function(e)
23
23
  \u2502 Access credentials failure \u2502
24
24
  \u2502 Check that the login details are correct in your .env file \u2502
25
25
  \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F
26
- `)),process.exit(1)}}},Zt=new an;var ac=ye(en()),uc=ye(Qt()),cc=ye(cn());var ns=ye(require("crypto")),ln=ye(require("fs")),is=ye(require("path")),os=is.default.resolve(__dirname,"./../../apiCache"),cp=`${os}/siteHash.json`;function ss(e){let t=ns.default.createHash("sha256");return t.update(JSON.stringify(e)),`${os}/${t.digest("hex")}`}function as(e,t){let r=typeof t=="string"?t:JSON.stringify(t);ln.default.writeFileSync(ss(e),r,"utf8")}function us(e){try{let t=ln.default.readFileSync(ss(e),{encoding:"utf-8"});return JSON.parse(t)}catch{return null}}var od=ye(Qt()),ic=ye(cn()),sd=ye(yu()),ad=ye(nc());ic.default.config();var ud=!!process.env.GRIDDO_BUILD_LOGS&&!!JSON.parse(process.env.GRIDDO_BUILD_LOGS)||!!process.env.LOGS&&!!JSON.parse(process.env.LOGS);function Un(...e){ud&&console.info(...e)}function oc(e){return new Promise(t=>setTimeout(t,e))}function Gn(e,t=3){return(e/1e3).toFixed(t)}function sc(e){return"site"in e&&e.site?e?.site:void 0}cc.default.config();var{env:{RETRY_WAIT_SECONDS:cd="4",RETRY_ATTEMPTS:ld="1"}}=process;async function zn(e){let{endpoint:t,body:r,cached:n,attempt:i=1,method:o,headers:s}=e,a={endpoint:t,body:r,cached:n};if(n){let u=us(a);if(u)return u}try{let{data:u}=await(0,ac.default)({url:t,method:o,headers:{...s,...Zt.headers},data:r});return as(a,u),u}catch(u){let d=u;return d.response?.status===404?null:((i>parseInt(ld)||!d.response)&&process.exit(1),fd(d,{callInfo:{endpoint:t,body:r}}),console.warn(`Waiting for retry: ${o}`,t),await oc(parseInt(cd)*1e3),zn({endpoint:t,body:r,cached:n,method:o,attempt:i+1}))}}async function lc(e){let t=new Date,{endpoint:r}=e,n=await zn({...e,method:"get"}),i=e.cached?"(cached)":"(fetch)",o=sc(n),s=o?`site: ${o} `:"",a=Gn(new Date().getTime()-t.getTime());return Un(`GET ${i} ${s} ${r} - ${a}s`),n}async function fc(e){let t=new Date,{endpoint:r,body:n,headers:i}=e,o=r.endsWith("/distributor")?`# Distributor body: ${JSON.stringify(n)} - lang: ${JSON.stringify(i?.lang)}`:"",s=await zn({...e,method:"post"}),a=e.cached?"(cached)":"(fetch)",u=Gn(new Date().getTime()-t.getTime());return Un(`POST ${a} ${r} - ${u}s ${o}`),s}function fd(e,t){let{response:r,message:n,stack:i}=e,{callInfo:o}=t,{status:s,statusText:a,data:u}=r||{},d=[];for(let m of Object.keys(o)){let _=m;d.push(`${m}: ${typeof o[_]=="object"?JSON.stringify(o[_]):o[_]}`)}let h=d.join(`
26
+ `)),process.exit(1)}}},Zt=new an;var ac=ye(en()),uc=ye(Qt()),cc=ye(cn());var ns=ye(require("crypto")),ln=ye(require("fs")),is=ye(require("path")),os=is.default.resolve(__dirname,"./../../apiCache"),cp=`${os}/siteHash.json`;function ss(e){let t=ns.default.createHash("sha256");return t.update(JSON.stringify(e)),`${os}/${t.digest("hex")}`}function as(e,t){let r=typeof t=="string"?t:JSON.stringify(t);ln.default.writeFileSync(ss(e),r,"utf8")}function us(e){try{let t=ln.default.readFileSync(ss(e),{encoding:"utf-8"});return JSON.parse(t)}catch{return null}}var od=ye(Qt()),ic=ye(cn()),sd=ye(yu()),ad=ye(nc());ic.default.config();var ud=!!process.env.GRIDDO_BUILD_LOGS&&!!JSON.parse(process.env.GRIDDO_BUILD_LOGS)||!!process.env.LOGS&&!!JSON.parse(process.env.LOGS);function Un(...e){ud&&console.info(...e)}function oc(e){return new Promise(t=>setTimeout(t,e))}function Gn(e,t=3){return(e/1e3).toFixed(t)}function sc(e){return"site"in e&&e.site?e?.site:void 0}cc.default.config();var{env:{RETRY_WAIT_SECONDS:cd="4",RETRY_ATTEMPTS:ld="1"}}=process;async function zn(e){let{endpoint:t,body:r,cached:n,attempt:i=1,method:o,headers:s}=e,a={endpoint:t,body:r,headers:s,cached:n};if(n){let u=us(a);if(u)return u}try{let{data:u}=await(0,ac.default)({url:t,method:o,headers:{...s,...Zt.headers},data:r});return as(a,u),u}catch(u){let d=u;return d.response?.status===404?null:((i>parseInt(ld)||!d.response)&&process.exit(1),fd(d,{callInfo:{endpoint:t,body:r}}),console.warn(`Waiting for retry: ${o}`,t),await oc(parseInt(cd)*1e3),zn({endpoint:t,body:r,cached:n,method:o,attempt:i+1}))}}async function lc(e){let t=new Date,{endpoint:r}=e,n=await zn({...e,method:"get"}),i=e.cached?"(cached)":"(fetch)",o=sc(n),s=o?`site: ${o} `:"",a=Gn(new Date().getTime()-t.getTime());return Un(`GET ${i} ${s} ${r} - ${a}s`),n}async function fc(e){let t=new Date,{endpoint:r,body:n,headers:i}=e,o=r.endsWith("/distributor")?`# Distributor body: ${JSON.stringify(n)} - lang: ${JSON.stringify(i?.lang)}`:"",s=await zn({...e,method:"post"}),a=e.cached?"(cached)":"(fetch)",u=Gn(new Date().getTime()-t.getTime());return Un(`POST ${a} ${r} - ${u}s ${o}`),s}function fd(e,t){let{response:r,message:n,stack:i}=e,{callInfo:o}=t,{status:s,statusText:a,data:u}=r||{},d=[];for(let m of Object.keys(o)){let _=m;d.push(`${m}: ${typeof o[_]=="object"?JSON.stringify(o[_]):o[_]}`)}let h=d.join(`
27
27
  `),p=r?`Code: ${s} - ${a}
28
28
  Response: ${JSON.stringify(u)}`:"",y=`${n}
29
29
  ${i}`;console.warn(uc.default.bold.red(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/cx",
3
3
  "description": "Griddo SSG based on Gatsby",
4
- "version": "1.75.222",
4
+ "version": "1.75.223",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -64,7 +64,7 @@
64
64
  "react-helmet": "^6.0.0"
65
65
  },
66
66
  "devDependencies": {
67
- "@griddo/eslint-config-back": "^1.75.222",
67
+ "@griddo/eslint-config-back": "^1.75.223",
68
68
  "@types/babel__core": "^7.20.0",
69
69
  "@types/babel__preset-env": "^7.9.2",
70
70
  "@types/csvtojson": "^2.0.0",
@@ -112,5 +112,5 @@
112
112
  "publishConfig": {
113
113
  "access": "public"
114
114
  },
115
- "gitHead": "f417b394d6830b80fc15f2fd691b620a34d74b2e"
115
+ "gitHead": "063dd7fbf1bdcb470d8c9d35accb6fea54464e54"
116
116
  }
@@ -112,10 +112,10 @@ class DistributorService {
112
112
  */
113
113
  static async getDistributorData({
114
114
  page,
115
- cached = false,
115
+ cached = "",
116
116
  }: {
117
117
  page: APIPageObject;
118
- cached: boolean;
118
+ cached: string;
119
119
  }) {
120
120
  try {
121
121
  const { template } = page;
@@ -129,7 +129,7 @@ class SitesService {
129
129
  static async getDistributorData(
130
130
  page: Core.Page,
131
131
  body: DistributorBody,
132
- cached: boolean
132
+ cached: string
133
133
  ) {
134
134
  const {
135
135
  GET_DISTRIBUTOR_DATA: [prefix, suffix],
@@ -280,7 +280,7 @@ class StoreService {
280
280
  // for the data.
281
281
  const template = await DistributorService.getDistributorData({
282
282
  page,
283
- cached: !!RENDER_ID,
283
+ cached: RENDER_ID,
284
284
  });
285
285
 
286
286
  // MultiPage Query
@@ -50,7 +50,7 @@ export interface FetchDataProps {
50
50
  component: {
51
51
  data: Fields.Reference<unknown>;
52
52
  };
53
- cached: boolean;
53
+ cached: string;
54
54
  }
55
55
 
56
56
  // TODO: JSDoc
package/src/utils/api.ts CHANGED
@@ -39,7 +39,7 @@ async function requestAPI<T extends APIResponses>(
39
39
  props: APIRequest & { method: Method }
40
40
  ): Promise<T> {
41
41
  const { endpoint, body, cached, attempt = 1, method, headers } = props;
42
- const cacheOptions = { endpoint, body, cached };
42
+ const cacheOptions = { endpoint, body, headers, cached };
43
43
 
44
44
  // Cache
45
45
  if (cached) {