@griddo/cx 11.10.4-rc.3 → 11.10.5

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.
@@ -10,9 +10,10 @@ declare const SEARCH: string;
10
10
  declare const SETTINGS: string;
11
11
  declare const BUILD_END: string[];
12
12
  declare const BUILD_START: string[];
13
+ declare const GET_PAGES: string[];
13
14
  declare const GET_REFERENCE_FIELD_DATA: string[];
14
15
  declare const GET_SITEMAP: string[];
15
16
  declare const INFO: string[];
16
17
  declare const LANGUAGES: string[];
17
18
  declare const SOCIALS: string[];
18
- export { AI_EMBEDDINGS, ALERT, BUILD_END, BUILD_START, DOMAINS, GET_ALL, GET_PAGE, GET_REFERENCE_FIELD_DATA, GET_SITEMAP, INFO, LANGUAGES, LOGIN, RESET_RENDER, ROBOTS, SEARCH, SETTINGS, SOCIALS, };
19
+ export { AI_EMBEDDINGS, ALERT, BUILD_END, BUILD_START, DOMAINS, GET_ALL, GET_PAGE, GET_PAGES, GET_REFERENCE_FIELD_DATA, GET_SITEMAP, INFO, LANGUAGES, LOGIN, RESET_RENDER, ROBOTS, SEARCH, SETTINGS, SOCIALS, };
@@ -4,10 +4,10 @@ import type { Dimensions } from "../../shared/types/pages";
4
4
  import * as React from "react";
5
5
 
6
6
  import { generateAutomaticDimensions } from "@griddo-instance";
7
+ import parse from "html-react-parser";
7
8
 
8
9
  import {
9
10
  composeAnalytics,
10
- extractScriptContent,
11
11
  filterBodyIntegrationFromPosition,
12
12
  filterHeadIntegrations,
13
13
  } from "./utils";
@@ -66,13 +66,9 @@ function GriddoIntegrations(props: GriddoIntegrationsProps) {
66
66
  `https://www.googletagmanager.com/gtag/js?id=${analyticsScript}`) ||
67
67
  null;
68
68
 
69
- const siteScriptContent = extractScriptContent(siteScript);
70
-
71
69
  return (
72
70
  <>
73
71
  {integrationsOrdered?.map((integration, key) => {
74
- const integrationScriptContent = extractScriptContent(integration.content);
75
-
76
72
  /* Data Layer */
77
73
  if (integration.type === "datalayer") {
78
74
  return (
@@ -91,16 +87,18 @@ function GriddoIntegrations(props: GriddoIntegrationsProps) {
91
87
  return <script key={key} src={analyticsWithUA} data-griddo-id={id} />;
92
88
  }
93
89
 
94
- return siteScriptContent ? (
95
- <script key={key} dangerouslySetInnerHTML={{ __html: siteScriptContent }} />
96
- ) : null;
90
+ return (
91
+ <React.Fragment key={key}>
92
+ {siteScript && parse(siteScript, { trim: true })}
93
+ </React.Fragment>
94
+ );
97
95
  }
98
96
 
99
97
  /* Integration integration.type === "addon" */
100
98
  if (integration.type === "addon") {
101
- return integrationScriptContent ? (
102
- <script key={key} dangerouslySetInnerHTML={{ __html: integrationScriptContent }} />
103
- ) : null;
99
+ return (
100
+ <React.Fragment key={key}>{parse(integration.content, { trim: true })}</React.Fragment>
101
+ );
104
102
  }
105
103
 
106
104
  return null;
@@ -109,25 +109,8 @@ function composeAnalytics(
109
109
  };
110
110
  }
111
111
 
112
- function extractScriptContent(rawInput?: unknown) {
113
- if (typeof rawInput !== "string" || !rawInput) {
114
- return null;
115
- }
116
-
117
- const trimmedInput = rawInput.trim();
118
-
119
- if (!trimmedInput.startsWith("<script>") || !trimmedInput.endsWith("</script>")) {
120
- return null;
121
- }
122
-
123
- const content = trimmedInput.replace(/<script>|<\/script>/g, "").trim();
124
-
125
- return content || null;
126
- }
127
-
128
112
  export {
129
113
  composeAnalytics,
130
- extractScriptContent,
131
114
  filterBodyIntegrationFromPosition,
132
115
  filterHeadIntegrations,
133
116
  filterPositionIntegrations,
@@ -16,7 +16,6 @@ import { RenderError } from "../core/errors";
16
16
  import { pathExists } from "../core/fs";
17
17
  import { GriddoLog } from "../core/GriddoLog";
18
18
  import { addLogToBuffer } from "../core/logger";
19
- import { DEFAULT_HEADERS } from "../shared/headers";
20
19
  import { brush } from "../shared/npm-modules/brush";
21
20
  import { AuthService } from "./auth";
22
21
  import { getRenderPathsHydratedWithDomainFromDB } from "./render";
@@ -77,10 +76,7 @@ async function requestAPI<T extends APIResponses>(
77
76
  // Prepare fetch options
78
77
  const fetchOptions: RequestInit = {
79
78
  method: method.toUpperCase(),
80
- headers: Object.assign({}, DEFAULT_HEADERS, headers, AuthService.headers) as Record<
81
- string,
82
- string
83
- >,
79
+ headers: Object.assign({}, headers, AuthService.headers) as Record<string, string>,
84
80
  };
85
81
 
86
82
  // Add body for non-GET requests
@@ -4,7 +4,6 @@ import { throwError } from "../core/errors";
4
4
  import { LOGIN } from "../shared/endpoints";
5
5
  import { GRIDDO_BOT_PASSWORD, GRIDDO_BOT_USER } from "../shared/envs";
6
6
  import { LoginError } from "../shared/errors";
7
- import { DEFAULT_HEADERS } from "../shared/headers";
8
7
 
9
8
  class AuthService {
10
9
  headers: AuthHeaders | undefined;
@@ -13,10 +12,7 @@ class AuthService {
13
12
  try {
14
13
  const response = await fetch(LOGIN, {
15
14
  method: "POST",
16
- headers: Object.assign({}, DEFAULT_HEADERS, {
17
- "Content-Type": "application/json",
18
- Connection: "close",
19
- }),
15
+ headers: { "Content-Type": "application/json", Connection: "close" },
20
16
  body: JSON.stringify({
21
17
  username: GRIDDO_BOT_USER,
22
18
  password: GRIDDO_BOT_PASSWORD,
@@ -16,6 +16,7 @@ const SETTINGS = `${GRIDDO_API_URL}/settings`;
16
16
  const SITE_URI = `${GRIDDO_API_URL}/site/`;
17
17
  const BUILD_END = [SITE_URI, "/build/end"];
18
18
  const BUILD_START = [SITE_URI, "/build/start"];
19
+ const GET_PAGES = [SITE_URI, "/pages?pagination=false"];
19
20
  const GET_REFERENCE_FIELD_DATA = [SITE_URI, "/distributor"];
20
21
  const GET_SITEMAP = [SITE_URI, "/sitemap"];
21
22
  const INFO = [SITE_URI, "/all"];
@@ -30,6 +31,7 @@ export {
30
31
  DOMAINS,
31
32
  GET_ALL,
32
33
  GET_PAGE,
34
+ GET_PAGES,
33
35
  GET_REFERENCE_FIELD_DATA,
34
36
  GET_SITEMAP,
35
37
  INFO,
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": "11.10.4-rc.3",
4
+ "version": "11.10.5",
5
5
  "authors": [
6
6
  "Hisco <francis.vega@griddo.io>"
7
7
  ],
@@ -56,7 +56,8 @@
56
56
  "watch:ts-lint": "tsc --noEmit --watch"
57
57
  },
58
58
  "dependencies": {
59
- "gatsby": "5.15.0"
59
+ "gatsby": "5.15.0",
60
+ "html-react-parser": "^5.2.10"
60
61
  },
61
62
  "devDependencies": {
62
63
  "@biomejs/biome": "2.3.4",
@@ -93,5 +94,5 @@
93
94
  "publishConfig": {
94
95
  "access": "public"
95
96
  },
96
- "gitHead": "bcd57d7f4aeeb8a1d939c464fd44ac26a5393103"
97
+ "gitHead": "c53ffb9d9d4890b4ef87a00decb31f178247779f"
97
98
  }
@@ -1,5 +0,0 @@
1
- export declare const DEFAULT_HEADERS: {
2
- readonly "x-application-id": "griddo-cx";
3
- readonly "x-client-version": string;
4
- readonly "x-client-name": "CX";
5
- };
@@ -1,7 +0,0 @@
1
- import packageJson from "../../package.json";
2
-
3
- export const DEFAULT_HEADERS = {
4
- "x-application-id": "griddo-cx",
5
- "x-client-version": packageJson.version,
6
- "x-client-name": "CX",
7
- } as const;