@griddo/cx 10.1.44 → 10.1.46

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.
@@ -23,7 +23,10 @@ GFS4: `),console.error(e)});H[K]||(ho=global[K]||[],mo(H,ho),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 un;var cc=fe(tn()),lc=fe(Qt()),fc=fe(ln());var du=fe(require("crypto")),gr=fe(require("fs")),qn=fe(require("path")),pu=fe(Mn()),mu=qn.default.resolve(__dirname,"./../../apiCache"),Jp=`${mu}/siteHash.json`;function yu(e){let t=du.default.createHash("sha256");return t.update(JSON.stringify(e)),`${mu}/${t.digest("hex")}`}function gu(e,t){let r=typeof t=="string"?t:JSON.stringify(t),n=yu(e),i=qn.default.dirname(n);gr.default.existsSync(i)||gr.default.mkdirSync(i,{recursive:!0}),gr.default.writeFileSync(n,r,"utf8")}function vu(e){try{let t=yu(e);return pu.default.readJSONSync(t,{encoding:"utf-8"})}catch{return null}}var ad=fe(Qt()),oc=fe(ln()),ud=fe(Mn()),cd=fe(sc());oc.default.config();var ld=!!process.env.GRIDDO_BUILD_LOGS&&!!JSON.parse(process.env.GRIDDO_BUILD_LOGS)||!!process.env.LOGS&&!!JSON.parse(process.env.LOGS);function zn(e){ld&&console.info(e.replace(/(\s)\s+/g,"$1"))}function ac(e){return new Promise(t=>setTimeout(t,e))}function Wn(e,t=3){return(e/1e3).toFixed(t)}function Jn(e){return"site"in e&&e.site?e?.site:void 0}fc.default.config();var{env:{RETRY_WAIT_SECONDS:fd="4",RETRY_ATTEMPTS:uc="4"}}=process;async function Vn(e,t,r=""){let{endpoint:n,body:i,cacheKey:s="",attempt:o=1,headers:a}=e,u={endpoint:n,body:i,headers:a,cacheKey:s};if(s){let d=new Date,h=vu(u);if(h){let p=Jn(h),y=p?`site: ${p}`:"",m=Wn(new Date().getTime()-d.getTime());return zn(`${t} (cache) ${y} ${n} - ${m}s ${r}`),h}}try{let d=new Date,{data:h}=await(0,cc.default)({url:n,method:t,headers:Object.assign({},a,Zt.headers),data:i}),p=Jn(h),y=p?`site: ${p}`:"",m=Wn(new Date().getTime()-d.getTime());return zn(`${t} (fetch) ${y} ${n} - ${m}s ${r}`),gu(u,h),h}catch(d){let h=d;return h.response?.status===404?null:(o>parseInt(uc)&&(console.log(`Max attempts ${uc} reached`),process.exit(1)),h.response||(console.log("Unknown error occurred"),console.log(JSON.stringify(h,null,2)),process.exit(1)),hd(h,{callInfo:{endpoint:n,body:i}}),console.warn(`Waiting for retry: ${t}`,n),await ac(parseInt(fd)*1e3),Vn({endpoint:n,body:i,cacheKey:s,attempt:o+1},t,r))}}async function hc(e){return await Vn(e,"get")}async function dc(e){let{endpoint:t,body:r,headers:n}=e,i=t.endsWith("/distributor")&&`# Distributor body: ${JSON.stringify(r)} lang: ${JSON.stringify(n?.lang)}`;return await Vn(e,"post",i||"")}function hd(e,t){let{response:r,message:n,stack:i}=e,{callInfo:s}=t,{status:o,statusText:a,data:u}=r||{},d=[];for(let m of Object.keys(s))d.push(`${m}: ${typeof s[m]=="object"?JSON.stringify(s[m]):s[m]}`);let h=d.join(`
26
+ `)),process.exit(1)}}},Zt=new un;var cc=fe(tn()),lc=fe(Qt()),fc=fe(ln());var du=fe(require("crypto")),gr=fe(require("fs")),qn=fe(require("path")),pu=fe(Mn()),mu=qn.default.resolve(__dirname,"./../../apiCache"),Jp=`${mu}/siteHash.json`;function yu(e){let t=du.default.createHash("sha256");return t.update(JSON.stringify(e)),`${mu}/${t.digest("hex")}`}function gu(e,t){let r=typeof t=="string"?t:JSON.stringify(t),n=yu(e),i=qn.default.dirname(n);gr.default.existsSync(i)||gr.default.mkdirSync(i,{recursive:!0}),gr.default.writeFileSync(n,r,"utf8")}function vu(e){try{let t=yu(e);return pu.default.readJSONSync(t,{encoding:"utf-8"})}catch{return null}}var ad=fe(Qt()),oc=fe(ln()),ud=fe(Mn()),cd=fe(sc());oc.default.config();var ld=!!process.env.GRIDDO_BUILD_LOGS&&!!JSON.parse(process.env.GRIDDO_BUILD_LOGS)||!!process.env.LOGS&&!!JSON.parse(process.env.LOGS);function zn(e){ld&&console.info(e.replace(/(\s)\s+/g,"$1"))}function ac(e){return new Promise(t=>setTimeout(t,e))}function Wn(e,t=3){return(e/1e3).toFixed(t)}function Jn(e){return"site"in e&&e.site?e?.site:void 0}fc.default.config();var{env:{RETRY_WAIT_SECONDS:fd="4",RETRY_ATTEMPTS:uc="4"}}=process;async function Vn(e,t,r=""){let{endpoint:n,body:i,cacheKey:s="",attempt:o=1,headers:a}=e,u={endpoint:n,body:i,headers:a,cacheKey:s};if(s){let d=new Date,h=vu(u);if(h){let p=Jn(h),y=p?`site: ${p}`:"",m=Wn(new Date().getTime()-d.getTime());return zn(`${t} (cache) ${y} ${n} - ${m}s ${r}`),h}}try{let d=new Date,{data:h}=await(0,cc.default)({url:n,method:t,headers:Object.assign({},a,Zt.headers),data:i}),p=Jn(h),y=p?`site: ${p}`:"",m=Wn(new Date().getTime()-d.getTime());return zn(`${t} (fetch) ${y} ${n} - ${m}s ${r}`),gu(u,h),h}catch(d){let h=d;return h.response?.status===404?null:(o>parseInt(uc)&&(console.log(`Max attempts ${uc} reached
27
+ - ${t.toUpperCase()} ${n}
28
+ - BODY: ${i||"NULL"}
29
+ - HEADERS: ${a||"NULL"})`),process.exit(1)),h.response||(console.log("Unknown error occurred"),console.log(JSON.stringify(h,null,2)),process.exit(1)),hd(h,{callInfo:{endpoint:n,body:i}}),console.warn(`Waiting for retry: ${t}`,n),await ac(parseInt(fd)*1e3),Vn({endpoint:n,body:i,cacheKey:s,attempt:o+1},t,r))}}async function hc(e){return await Vn(e,"get")}async function dc(e){let{endpoint:t,body:r,headers:n}=e,i=t.endsWith("/distributor")&&`# Distributor body: ${JSON.stringify(r)} lang: ${JSON.stringify(n?.lang)}`;return await Vn(e,"post",i||"")}function hd(e,t){let{response:r,message:n,stack:i}=e,{callInfo:s}=t,{status:o,statusText:a,data:u}=r||{},d=[];for(let m of Object.keys(s))d.push(`${m}: ${typeof s[m]=="object"?JSON.stringify(s[m]):s[m]}`);let h=d.join(`
27
30
  `),p=r?`Code: ${o} - ${a}
28
31
  Response: ${JSON.stringify(u)}`:"",y=`${n}
29
32
  ${i}`;console.warn(lc.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": "10.1.44",
4
+ "version": "10.1.46",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -68,7 +68,7 @@
68
68
  "react-helmet": "^6.0.0"
69
69
  },
70
70
  "devDependencies": {
71
- "@griddo/eslint-config-back": "^10.1.44",
71
+ "@griddo/eslint-config-back": "^10.1.46",
72
72
  "@types/babel__core": "^7.20.0",
73
73
  "@types/babel__preset-env": "^7.9.2",
74
74
  "@types/csvtojson": "^2.0.0",
@@ -116,5 +116,5 @@
116
116
  "publishConfig": {
117
117
  "access": "public"
118
118
  },
119
- "gitHead": "02253ff3a2d6236aca3be2d0917cc755d48da198"
119
+ "gitHead": "d2c56d5c8447df80d2c11fbdfb308fc7e9c0e820"
120
120
  }
package/src/utils/api.ts CHANGED
@@ -89,7 +89,12 @@ async function requestAPI<T extends APIResponses>(
89
89
  }
90
90
 
91
91
  if (attempt > parseInt(RETRY_ATTEMPTS)) {
92
- console.log(`Max attempts ${RETRY_ATTEMPTS} reached`);
92
+ // console.log(`Max attempts ${RETRY_ATTEMPTS} reached`);
93
+ console.log(
94
+ `Max attempts ${RETRY_ATTEMPTS} reached\n- ${method.toUpperCase()} ${endpoint}\n- BODY: ${
95
+ body || "NULL"
96
+ }\n- HEADERS: ${headers || "NULL"})`
97
+ );
93
98
  process.exit(1);
94
99
  }
95
100