@griddo/cx 1.75.221 → 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.221";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.221",
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>",
@@ -35,7 +35,6 @@
35
35
  "@babel/preset-env": "^7.14.5",
36
36
  "@babel/preset-react": "^7.14.5",
37
37
  "@babel/preset-typescript": "^7.16.5",
38
- "@griddo/core": "^1.75.221",
39
38
  "@svgr/webpack": "^5.5.0",
40
39
  "babel-loader": "^8.0.6",
41
40
  "babel-plugin-styled-components": "^1.10.7",
@@ -65,7 +64,7 @@
65
64
  "react-helmet": "^6.0.0"
66
65
  },
67
66
  "devDependencies": {
68
- "@griddo/eslint-config-back": "^1.75.221",
67
+ "@griddo/eslint-config-back": "^1.75.223",
69
68
  "@types/babel__core": "^7.20.0",
70
69
  "@types/babel__preset-env": "^7.9.2",
71
70
  "@types/csvtojson": "^2.0.0",
@@ -113,5 +112,5 @@
113
112
  "publishConfig": {
114
113
  "access": "public"
115
114
  },
116
- "gitHead": "b8a0de5fd919a1e6a245c0119f30dbf7d468c233"
115
+ "gitHead": "063dd7fbf1bdcb470d8c9d35accb6fea54464e54"
117
116
  }
@@ -15,6 +15,7 @@ const Head = (props: CustomHeadProps) => {
15
15
  const {
16
16
  pageContext: {
17
17
  griddoVersion,
18
+ renderDate,
18
19
  locale,
19
20
  openGraph,
20
21
  page: { disableHrefLangs, fullUrl, defaultLang },
@@ -104,8 +105,6 @@ const Head = (props: CustomHeadProps) => {
104
105
  ?.url) ||
105
106
  null;
106
107
 
107
- const currentTime = new Date().toString();
108
-
109
108
  return (
110
109
  <>
111
110
  {/* Uncomment with Gatsby 5.5.0 */}
@@ -174,7 +173,7 @@ const Head = (props: CustomHeadProps) => {
174
173
  {!siteOptions?.avoidDebugMetas && (
175
174
  <meta
176
175
  property="debug"
177
- content={`Griddo v${griddoVersion} @ ${currentTime}}`}
176
+ content={`Griddo v${griddoVersion} @ ${renderDate}}`}
178
177
  />
179
178
  )}
180
179
 
@@ -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
@@ -108,6 +108,7 @@ export type GatsbyPageObject = {
108
108
  footer: Record<string, unknown> | null;
109
109
  fullPath: Core.Page["fullPath"];
110
110
  griddoVersion: string;
111
+ renderDate: string;
111
112
  header: Record<string, unknown> | null;
112
113
  id?: number;
113
114
  languageId: number;
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) {
@@ -164,10 +164,11 @@ async function createGatsbyPageObject(
164
164
  socialTitle,
165
165
  });
166
166
 
167
- const pagePath =
168
- NEEDS_ASSET_PREFIX || STRIP_DOMAIN_FROM_PATH
169
- ? fullPath.compose
170
- : `${fullPath?.domain}${fullPath?.compose}`;
167
+ const pagePath = STRIP_DOMAIN_FROM_PATH
168
+ ? fullPath.compose
169
+ : `${fullPath.domain}${fullPath.compose}`;
170
+
171
+ const renderDate = new Date().toString();
171
172
 
172
173
  const pageObjectForGatsby: GatsbyPageObject = {
173
174
  path: pagePath,
@@ -193,6 +194,7 @@ async function createGatsbyPageObject(
193
194
  siteOptions,
194
195
  BUILD_MODE,
195
196
  griddoVersion,
197
+ renderDate,
196
198
  siteScript,
197
199
 
198
200
  // Navigation sections
@@ -31,6 +31,9 @@ const GRIDDO_RENDER_PAGES = (
31
31
  .map((item) => parseInt(item))
32
32
  .filter(Boolean);
33
33
 
34
+ const STRIP_DOMAIN_FROM_PATH =
35
+ !!process.env.GRIDDO_EXPORT_STRIP_DOMAIN_FROM_PATH;
36
+
34
37
  /**
35
38
  * Check the instance sites and returns site prepared to be published and unpublished.
36
39
  */
@@ -232,7 +235,9 @@ async function generateSitemaps(sites: Array<Site>) {
232
235
 
233
236
  const sitemapBasePath = path.resolve(
234
237
  __dirname,
235
- `../../public/${slug.replace(domain, "")}`
238
+ `../../public/${
239
+ STRIP_DOMAIN_FROM_PATH ? slug.replace(domain, "") : slug
240
+ }`
236
241
  );
237
242
 
238
243
  for (const templateId of sitemapPageGroupKeys) {