@griddo/cx 11.7.12-rc.3 → 11.7.12

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.
Files changed (303) hide show
  1. package/README.md +226 -27
  2. package/build/adapters/gatsby/index.d.ts +4 -0
  3. package/build/adapters/gatsby/utils.d.ts +22 -0
  4. package/build/artifacts/index.d.ts +6 -0
  5. package/build/commands/end-render.d.ts +2 -0
  6. package/build/commands/move-assets.d.ts +1 -0
  7. package/build/commands/prepare-domains-render.d.ts +1 -0
  8. package/build/commands/reset-render.d.ts +2 -0
  9. package/build/commands/start-render.d.ts +2 -0
  10. package/build/commands/upload-search-content.d.ts +2 -0
  11. package/build/constants/endpoints.d.ts +19 -0
  12. package/build/constants/envs.d.ts +37 -0
  13. package/build/constants/index.d.ts +57 -0
  14. package/build/end-render.js +74 -0
  15. package/build/end-render.js.map +7 -0
  16. package/build/errors/errors-data.d.ts +22 -0
  17. package/build/errors/index.d.ts +15 -0
  18. package/build/index.d.ts +29 -0
  19. package/build/index.js +73 -0
  20. package/build/index.js.map +7 -0
  21. package/build/prepare-domains-render.js +73 -0
  22. package/build/prepare-domains-render.js.map +7 -0
  23. package/build/react/Favicon/index.d.ts +5 -0
  24. package/build/react/Favicon/utils.d.ts +9 -0
  25. package/build/react/GriddoIntegrations/index.d.ts +20 -0
  26. package/build/react/GriddoIntegrations/utils.d.ts +26 -0
  27. package/{react/index.tsx → build/react/index.d.ts} +0 -1
  28. package/build/react/index.js +3 -0
  29. package/build/registers/api.d.ts +9 -0
  30. package/build/registers/gatsby.d.ts +9 -0
  31. package/build/registers/index.d.ts +3 -0
  32. package/build/reset-render.js +74 -0
  33. package/build/reset-render.js.map +7 -0
  34. package/build/services/auth.d.ts +10 -0
  35. package/build/services/domains.d.ts +6 -0
  36. package/build/services/navigation.d.ts +50 -0
  37. package/build/services/reference-fields.d.ts +20 -0
  38. package/build/services/register.d.ts +36 -0
  39. package/build/services/robots.d.ts +19 -0
  40. package/build/services/settings.d.ts +4 -0
  41. package/build/services/sites.d.ts +29 -0
  42. package/build/services/store.d.ts +6 -0
  43. package/build/start-render.js +100 -0
  44. package/build/start-render.js.map +7 -0
  45. package/build/types/api.d.ts +142 -0
  46. package/build/types/global.d.ts +84 -0
  47. package/build/types/navigation.d.ts +28 -0
  48. package/build/types/pages.d.ts +144 -0
  49. package/build/types/sites.d.ts +57 -0
  50. package/build/types/templates.d.ts +8 -0
  51. package/build/upload-search-content.js +74 -0
  52. package/build/upload-search-content.js.map +7 -0
  53. package/build/utils/alerts.d.ts +3 -0
  54. package/build/utils/api.d.ts +23 -0
  55. package/build/utils/cache.d.ts +35 -0
  56. package/build/utils/core-utils.d.ts +107 -0
  57. package/build/utils/create-build-data.d.ts +8 -0
  58. package/build/utils/domains.d.ts +13 -0
  59. package/build/utils/folders.d.ts +53 -0
  60. package/build/utils/health-checks.d.ts +7 -0
  61. package/build/utils/images.d.ts +16 -0
  62. package/build/utils/instance.d.ts +21 -0
  63. package/build/utils/loggin.d.ts +51 -0
  64. package/build/utils/pages.d.ts +34 -0
  65. package/build/utils/render.d.ts +13 -0
  66. package/build/utils/searches.d.ts +15 -0
  67. package/build/utils/sites.d.ts +31 -0
  68. package/build/utils/store.d.ts +81 -0
  69. package/cx.config.d.ts +5 -0
  70. package/cx.config.js +36 -0
  71. package/exporter/adapters/gatsby/index.ts +153 -73
  72. package/exporter/adapters/gatsby/utils.ts +161 -0
  73. package/exporter/artifacts/README.md +34 -0
  74. package/exporter/artifacts/index.ts +33 -0
  75. package/exporter/build.sh +38 -4
  76. package/exporter/commands/end-render.ts +70 -72
  77. package/exporter/commands/move-assets.ts +11 -0
  78. package/exporter/commands/prepare-domains-render.ts +31 -143
  79. package/exporter/commands/reset-render.ts +3 -10
  80. package/exporter/commands/start-render.ts +45 -22
  81. package/exporter/commands/upload-search-content.ts +21 -194
  82. package/exporter/constants/endpoints.ts +1 -2
  83. package/exporter/constants/envs.ts +55 -57
  84. package/exporter/constants/index.ts +129 -0
  85. package/exporter/{constants/errors.ts → errors/errors-data.ts} +14 -24
  86. package/exporter/{utils/errors.ts → errors/index.ts} +9 -10
  87. package/exporter/index.ts +82 -0
  88. package/{react → exporter/react}/Favicon/index.tsx +7 -1
  89. package/{react → exporter/react}/GriddoIntegrations/index.tsx +22 -16
  90. package/{react → exporter/react}/GriddoIntegrations/utils.ts +9 -21
  91. package/exporter/react/index.tsx +11 -0
  92. package/exporter/registers/api.ts +14 -0
  93. package/exporter/registers/gatsby.ts +14 -0
  94. package/exporter/registers/index.ts +4 -0
  95. package/exporter/services/auth.ts +6 -7
  96. package/exporter/services/domains.ts +16 -0
  97. package/exporter/services/navigation.ts +10 -4
  98. package/exporter/services/reference-fields.ts +24 -9
  99. package/exporter/services/register.ts +113 -0
  100. package/exporter/services/robots.ts +16 -9
  101. package/exporter/services/settings.ts +17 -0
  102. package/exporter/services/sites.ts +24 -36
  103. package/exporter/services/store.ts +96 -107
  104. package/exporter/types/api.ts +28 -27
  105. package/exporter/types/global.ts +11 -8
  106. package/exporter/types/navigation.ts +1 -1
  107. package/exporter/types/pages.ts +3 -2
  108. package/exporter/types/sites.ts +2 -1
  109. package/exporter/utils/alerts.ts +29 -0
  110. package/exporter/utils/api.ts +75 -55
  111. package/exporter/utils/cache.ts +62 -37
  112. package/exporter/utils/core-utils.ts +272 -133
  113. package/exporter/utils/create-build-data.ts +17 -0
  114. package/exporter/utils/domains.ts +7 -10
  115. package/exporter/utils/folders.ts +98 -163
  116. package/exporter/utils/health-checks.ts +64 -0
  117. package/exporter/utils/images.ts +6 -1
  118. package/exporter/utils/instance.ts +13 -9
  119. package/exporter/utils/loggin.ts +91 -44
  120. package/exporter/utils/pages.ts +88 -23
  121. package/exporter/utils/render.ts +48 -180
  122. package/exporter/utils/searches.ts +156 -0
  123. package/exporter/utils/sites.ts +197 -19
  124. package/exporter/utils/store.ts +180 -87
  125. package/gatsby-browser.tsx +58 -41
  126. package/gatsby-config.ts +17 -10
  127. package/gatsby-node.ts +78 -17
  128. package/gatsby-ssr.tsx +1 -2
  129. package/package.json +86 -36
  130. package/src/README.md +7 -0
  131. package/src/components/Head.tsx +46 -13
  132. package/src/components/template.tsx +30 -8
  133. package/src/gatsby-node-utils.ts +2 -73
  134. package/src/html.tsx +11 -2
  135. package/src/types.ts +5 -5
  136. package/start-render.js +7 -0
  137. package/tsconfig.json +3 -5
  138. package/build/adapters/gatsby/actions/clean.js +0 -10
  139. package/build/adapters/gatsby/actions/clean.js.map +0 -1
  140. package/build/adapters/gatsby/actions/close.js +0 -12
  141. package/build/adapters/gatsby/actions/close.js.map +0 -1
  142. package/build/adapters/gatsby/actions/data.js +0 -18
  143. package/build/adapters/gatsby/actions/data.js.map +0 -1
  144. package/build/adapters/gatsby/actions/healthCheck.js +0 -10
  145. package/build/adapters/gatsby/actions/healthCheck.js.map +0 -1
  146. package/build/adapters/gatsby/actions/init.js +0 -22
  147. package/build/adapters/gatsby/actions/init.js.map +0 -1
  148. package/build/adapters/gatsby/actions/logs.js +0 -11
  149. package/build/adapters/gatsby/actions/logs.js.map +0 -1
  150. package/build/adapters/gatsby/actions/meta.js +0 -13
  151. package/build/adapters/gatsby/actions/meta.js.map +0 -1
  152. package/build/adapters/gatsby/actions/prepare.js +0 -9
  153. package/build/adapters/gatsby/actions/prepare.js.map +0 -1
  154. package/build/adapters/gatsby/actions/relocation.js +0 -15
  155. package/build/adapters/gatsby/actions/relocation.js.map +0 -1
  156. package/build/adapters/gatsby/actions/restore.js +0 -26
  157. package/build/adapters/gatsby/actions/restore.js.map +0 -1
  158. package/build/adapters/gatsby/actions/ssg.js +0 -9
  159. package/build/adapters/gatsby/actions/ssg.js.map +0 -1
  160. package/build/adapters/gatsby/actions/sync.js +0 -51
  161. package/build/adapters/gatsby/actions/sync.js.map +0 -1
  162. package/build/adapters/gatsby/index.js +0 -78
  163. package/build/adapters/gatsby/index.js.map +0 -1
  164. package/build/adapters/gatsby/shared/artifacts.js +0 -20
  165. package/build/adapters/gatsby/shared/artifacts.js.map +0 -1
  166. package/build/adapters/gatsby/shared/context.js +0 -31
  167. package/build/adapters/gatsby/shared/context.js.map +0 -1
  168. package/build/adapters/gatsby/shared/diff-assets.js +0 -101
  169. package/build/adapters/gatsby/shared/diff-assets.js.map +0 -1
  170. package/build/adapters/gatsby/shared/extract-assets.js +0 -58
  171. package/build/adapters/gatsby/shared/extract-assets.js.map +0 -1
  172. package/build/adapters/gatsby/shared/gatsby-build.js +0 -55
  173. package/build/adapters/gatsby/shared/gatsby-build.js.map +0 -1
  174. package/build/adapters/gatsby/shared/sync-render.js +0 -210
  175. package/build/adapters/gatsby/shared/sync-render.js.map +0 -1
  176. package/build/adapters/gatsby/shared/types.js +0 -3
  177. package/build/adapters/gatsby/shared/types.js.map +0 -1
  178. package/build/commands/end-render.js +0 -87
  179. package/build/commands/end-render.js.map +0 -1
  180. package/build/commands/prepare-assets-directory.js +0 -30
  181. package/build/commands/prepare-assets-directory.js.map +0 -1
  182. package/build/commands/prepare-domains-render.js +0 -133
  183. package/build/commands/prepare-domains-render.js.map +0 -1
  184. package/build/commands/reset-render.js +0 -21
  185. package/build/commands/reset-render.js.map +0 -1
  186. package/build/commands/start-render.js +0 -44
  187. package/build/commands/start-render.js.map +0 -1
  188. package/build/commands/upload-search-content.js +0 -180
  189. package/build/commands/upload-search-content.js.map +0 -1
  190. package/build/constants/endpoints.js +0 -43
  191. package/build/constants/endpoints.js.map +0 -1
  192. package/build/constants/envs.js +0 -68
  193. package/build/constants/envs.js.map +0 -1
  194. package/build/constants/errors.js +0 -81
  195. package/build/constants/errors.js.map +0 -1
  196. package/build/services/auth.js +0 -40
  197. package/build/services/auth.js.map +0 -1
  198. package/build/services/db-class.js +0 -49
  199. package/build/services/db-class.js.map +0 -1
  200. package/build/services/db.js +0 -34
  201. package/build/services/db.js.map +0 -1
  202. package/build/services/navigation.js +0 -96
  203. package/build/services/navigation.js.map +0 -1
  204. package/build/services/reference-fields.js +0 -131
  205. package/build/services/reference-fields.js.map +0 -1
  206. package/build/services/robots.js +0 -60
  207. package/build/services/robots.js.map +0 -1
  208. package/build/services/sites.js +0 -110
  209. package/build/services/sites.js.map +0 -1
  210. package/build/services/store.js +0 -257
  211. package/build/services/store.js.map +0 -1
  212. package/build/types/api.js +0 -3
  213. package/build/types/api.js.map +0 -1
  214. package/build/types/global.js +0 -3
  215. package/build/types/global.js.map +0 -1
  216. package/build/types/navigation.js +0 -3
  217. package/build/types/navigation.js.map +0 -1
  218. package/build/types/pages.js +0 -3
  219. package/build/types/pages.js.map +0 -1
  220. package/build/types/render.js +0 -10
  221. package/build/types/render.js.map +0 -1
  222. package/build/types/sites.js +0 -3
  223. package/build/types/sites.js.map +0 -1
  224. package/build/types/templates.js +0 -3
  225. package/build/types/templates.js.map +0 -1
  226. package/build/utils/api.js +0 -165
  227. package/build/utils/api.js.map +0 -1
  228. package/build/utils/artifacts.js +0 -38
  229. package/build/utils/artifacts.js.map +0 -1
  230. package/build/utils/brush.js +0 -30
  231. package/build/utils/brush.js.map +0 -1
  232. package/build/utils/cache.js +0 -106
  233. package/build/utils/cache.js.map +0 -1
  234. package/build/utils/check-environment-health.js +0 -73
  235. package/build/utils/check-environment-health.js.map +0 -1
  236. package/build/utils/core-utils.js +0 -270
  237. package/build/utils/core-utils.js.map +0 -1
  238. package/build/utils/domains.js +0 -37
  239. package/build/utils/domains.js.map +0 -1
  240. package/build/utils/errors.js +0 -30
  241. package/build/utils/errors.js.map +0 -1
  242. package/build/utils/folders.js +0 -341
  243. package/build/utils/folders.js.map +0 -1
  244. package/build/utils/images.js +0 -45
  245. package/build/utils/images.js.map +0 -1
  246. package/build/utils/instance.js +0 -66
  247. package/build/utils/instance.js.map +0 -1
  248. package/build/utils/loggin.js +0 -119
  249. package/build/utils/loggin.js.map +0 -1
  250. package/build/utils/npm-deps/find-up-simple.js +0 -75
  251. package/build/utils/npm-deps/find-up-simple.js.map +0 -1
  252. package/build/utils/npm-deps/pkg-dir.js +0 -20
  253. package/build/utils/npm-deps/pkg-dir.js.map +0 -1
  254. package/build/utils/npm-deps/xml-parser.js +0 -49
  255. package/build/utils/npm-deps/xml-parser.js.map +0 -1
  256. package/build/utils/pages.js +0 -359
  257. package/build/utils/pages.js.map +0 -1
  258. package/build/utils/render.js +0 -168
  259. package/build/utils/render.js.map +0 -1
  260. package/build/utils/sitemaps.js +0 -110
  261. package/build/utils/sitemaps.js.map +0 -1
  262. package/build/utils/sites.js +0 -105
  263. package/build/utils/sites.js.map +0 -1
  264. package/build/utils/store.js +0 -193
  265. package/build/utils/store.js.map +0 -1
  266. package/cli.mjs +0 -136
  267. package/exporter/adapters/gatsby/actions/clean.ts +0 -14
  268. package/exporter/adapters/gatsby/actions/close.ts +0 -17
  269. package/exporter/adapters/gatsby/actions/data.ts +0 -25
  270. package/exporter/adapters/gatsby/actions/healthCheck.ts +0 -10
  271. package/exporter/adapters/gatsby/actions/init.ts +0 -26
  272. package/exporter/adapters/gatsby/actions/logs.ts +0 -12
  273. package/exporter/adapters/gatsby/actions/meta.ts +0 -16
  274. package/exporter/adapters/gatsby/actions/prepare.ts +0 -9
  275. package/exporter/adapters/gatsby/actions/relocation.ts +0 -15
  276. package/exporter/adapters/gatsby/actions/restore.ts +0 -36
  277. package/exporter/adapters/gatsby/actions/ssg.ts +0 -12
  278. package/exporter/adapters/gatsby/actions/sync.ts +0 -71
  279. package/exporter/adapters/gatsby/shared/artifacts.ts +0 -16
  280. package/exporter/adapters/gatsby/shared/context.ts +0 -50
  281. package/exporter/adapters/gatsby/shared/diff-assets.ts +0 -113
  282. package/exporter/adapters/gatsby/shared/extract-assets.ts +0 -61
  283. package/exporter/adapters/gatsby/shared/gatsby-build.ts +0 -58
  284. package/exporter/adapters/gatsby/shared/sync-render.ts +0 -276
  285. package/exporter/adapters/gatsby/shared/types.ts +0 -35
  286. package/exporter/build-esbuild.noop +0 -42
  287. package/exporter/commands/prepare-assets-directory.ts +0 -30
  288. package/exporter/services/db-class.ts +0 -54
  289. package/exporter/services/db.ts +0 -32
  290. package/exporter/types/render.ts +0 -59
  291. package/exporter/utils/artifacts.ts +0 -38
  292. package/exporter/utils/brush.ts +0 -34
  293. package/exporter/utils/check-environment-health.ts +0 -84
  294. package/exporter/utils/npm-deps/find-up-simple.ts +0 -100
  295. package/exporter/utils/npm-deps/pkg-dir.ts +0 -17
  296. package/exporter/utils/npm-deps/xml-parser.ts +0 -57
  297. package/exporter/utils/sitemaps.ts +0 -129
  298. package/plugins/gatsby-plugin-svgr-loader/gatsby-node.js +0 -55
  299. package/plugins/gatsby-plugin-svgr-loader/package.json +0 -8
  300. package/react/DynamicScript/index.tsx +0 -33
  301. package/tsconfig.commands.json +0 -36
  302. package/tsconfig.exporter.json +0 -19
  303. /package/{react → exporter/react}/Favicon/utils.ts +0 -0
@@ -0,0 +1,82 @@
1
+ /**
2
+ *
3
+ * Griddo CX library main export file.
4
+ *
5
+ * This file exports functions to use in both: adapters and SSG's frameworks.
6
+ * Turning CX basically in a javascript library.
7
+ *
8
+ * # React
9
+ * There is another export in the `/react` directory to use exclusivelly in
10
+ * the browser context where nodejs (path, fs, etc..) is not available.
11
+ *
12
+ * # Separate scripts.
13
+ * There are some separate .ts files as end-render.ts or reset-render.ts
14
+ * that are intended to be used by infra via npm script like `npm run
15
+ * end-render`
16
+ *
17
+ */
18
+
19
+ import type { SocialsResponse } from "./types/api";
20
+ import type {
21
+ AdditionalInfo,
22
+ Dimensions,
23
+ GriddoListPage,
24
+ GriddoMultiPage,
25
+ GriddoPageObject,
26
+ GriddoSinglePage,
27
+ } from "./types/pages";
28
+ import type { Site } from "./types/sites";
29
+
30
+ import { endpoints, envs } from "./constants";
31
+ import { apiRegister } from "./registers/index";
32
+ import { FileRegister, MemoryRegister, Register } from "./services/register";
33
+ import { insertAlert } from "./utils/alerts";
34
+ import { getConfig, walk } from "./utils/core-utils";
35
+ import {
36
+ componentLibraryPathAlias,
37
+ isComponentLibrary,
38
+ resolveComponentsPath,
39
+ } from "./utils/instance";
40
+ import {
41
+ buildLog,
42
+ debugLog,
43
+ infoLog,
44
+ pageSizeLog,
45
+ verboseLog,
46
+ } from "./utils/loggin";
47
+ import {
48
+ getBuildPagesFromCachedStore,
49
+ getBuildPagesFromStore,
50
+ getBuildPagesPath,
51
+ } from "./utils/store";
52
+
53
+ export {
54
+ apiRegister,
55
+ buildLog,
56
+ componentLibraryPathAlias,
57
+ debugLog,
58
+ endpoints,
59
+ envs,
60
+ FileRegister,
61
+ getBuildPagesFromCachedStore,
62
+ getBuildPagesFromStore,
63
+ getBuildPagesPath,
64
+ getConfig,
65
+ infoLog,
66
+ insertAlert,
67
+ isComponentLibrary,
68
+ MemoryRegister,
69
+ pageSizeLog,
70
+ Register,
71
+ resolveComponentsPath,
72
+ verboseLog,
73
+ walk,
74
+ type AdditionalInfo,
75
+ type Dimensions,
76
+ type GriddoListPage,
77
+ type GriddoMultiPage,
78
+ type GriddoPageObject,
79
+ type GriddoSinglePage,
80
+ type Site,
81
+ type SocialsResponse,
82
+ };
@@ -1,3 +1,5 @@
1
+ import * as React from "react";
2
+
1
3
  import { formatImage } from "./utils";
2
4
 
3
5
  function Favicon({ url }: { url: string | undefined }) {
@@ -24,7 +26,11 @@ function Favicon({ url }: { url: string | undefined }) {
24
26
  sizes="180x180"
25
27
  href={formatImage(url, { width: 180, height: 180, format: "png" })}
26
28
  />
27
- <link rel="icon" type="image/svg+xml" href={formatImage(url, { format: "svg" })} />
29
+ <link
30
+ rel="icon"
31
+ type="image/svg+xml"
32
+ href={formatImage(url, { format: "svg" })}
33
+ />
28
34
  </>
29
35
  );
30
36
  }
@@ -1,13 +1,12 @@
1
+ import type { Dimensions } from "../../types/pages";
1
2
  import type { Core } from "@griddo/core";
2
- import type { Dimensions } from "../../exporter/types/pages";
3
-
4
- import * as React from "react";
5
3
 
6
4
  import { generateAutomaticDimensions } from "@griddo-instance";
5
+ import parse from "html-react-parser";
6
+ import * as React from "react";
7
7
 
8
8
  import {
9
9
  composeAnalytics,
10
- extractScriptContent,
11
10
  filterBodyIntegrationFromPosition,
12
11
  filterHeadIntegrations,
13
12
  } from "./utils";
@@ -57,7 +56,12 @@ function GriddoIntegrations(props: GriddoIntegrationsProps) {
57
56
  // @shame!
58
57
  // El fix sería llamar a `composeAnalytics()` solo si `pageInfo` existe.
59
58
  const { analyticsScript, analyticsDimensions } = pageInfo
60
- ? composeAnalytics(siteScript, dimensions, pageInfo, generateAutomaticDimensions)
59
+ ? composeAnalytics(
60
+ siteScript,
61
+ dimensions,
62
+ pageInfo,
63
+ generateAutomaticDimensions,
64
+ )
61
65
  : { analyticsDimensions: null, analyticsScript: null };
62
66
 
63
67
  // GTAG WITH UA
@@ -66,13 +70,9 @@ function GriddoIntegrations(props: GriddoIntegrationsProps) {
66
70
  `https://www.googletagmanager.com/gtag/js?id=${analyticsScript}`) ||
67
71
  null;
68
72
 
69
- const siteScriptContent = extractScriptContent(siteScript);
70
-
71
73
  return (
72
74
  <>
73
75
  {integrationsOrdered?.map((integration, key) => {
74
- const integrationScriptContent = extractScriptContent(integration.content);
75
-
76
76
  /* Data Layer */
77
77
  if (integration.type === "datalayer") {
78
78
  return (
@@ -88,19 +88,25 @@ function GriddoIntegrations(props: GriddoIntegrationsProps) {
88
88
  if (integration.type === "analytics") {
89
89
  // If UA- is provided
90
90
  if (analyticsWithUA) {
91
- return <script key={key} src={analyticsWithUA} data-griddo-id={id} />;
91
+ return (
92
+ <script key={key} src={analyticsWithUA} data-griddo-id={id} />
93
+ );
92
94
  }
93
95
 
94
- return siteScriptContent ? (
95
- <script key={key} dangerouslySetInnerHTML={{ __html: siteScriptContent }} />
96
- ) : null;
96
+ return (
97
+ <React.Fragment key={key}>
98
+ {siteScript && parse(siteScript, { trim: true })}
99
+ </React.Fragment>
100
+ );
97
101
  }
98
102
 
99
103
  /* Integration integration.type === "addon" */
100
104
  if (integration.type === "addon") {
101
- return integrationScriptContent ? (
102
- <script key={key} dangerouslySetInnerHTML={{ __html: integrationScriptContent }} />
103
- ) : null;
105
+ return (
106
+ <React.Fragment key={key}>
107
+ {parse(integration.content, { trim: true })}
108
+ </React.Fragment>
109
+ );
104
110
  }
105
111
 
106
112
  return null;
@@ -1,5 +1,5 @@
1
+ import type { Dimensions } from "../../types/pages";
1
2
  import type { Core } from "@griddo/core";
2
- import type { Dimensions } from "../../exporter/types/pages";
3
3
 
4
4
  /**
5
5
  * Return true if the argument is an object (not null)
@@ -70,13 +70,16 @@ function composeAnalytics(
70
70
  };
71
71
  };
72
72
  },
73
- generateAutomaticDimensions = (_page: Record<string, unknown>) => null,
73
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
74
+ generateAutomaticDimensions = (page: Record<string, unknown>) => null,
74
75
  ) {
75
76
  const analyticsScript = siteScriptRaw ? siteScriptRaw.trim() : "";
76
77
 
77
78
  // Las dimensiones o DataLayer
78
79
  const dynamicValuePrefix = "__SCRIPT:";
79
- const dimensionValues = isObject(dimensions?.values) ? dimensions?.values : {};
80
+ const dimensionValues = isObject(dimensions?.values)
81
+ ? dimensions?.values
82
+ : {};
80
83
  const automaticDimensionValues = generateAutomaticDimensions
81
84
  ? generateAutomaticDimensions(page || {})
82
85
  : {};
@@ -101,7 +104,9 @@ function composeAnalytics(
101
104
  );
102
105
  }
103
106
 
104
- const analyticsDimensions = allDimensions.length ? `{${allDimensions.join(",")}}` : null;
107
+ const analyticsDimensions = allDimensions.length
108
+ ? `{${allDimensions.join(",")}}`
109
+ : null;
105
110
 
106
111
  return {
107
112
  analyticsScript,
@@ -109,25 +114,8 @@ function composeAnalytics(
109
114
  };
110
115
  }
111
116
 
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
117
  export {
129
118
  composeAnalytics,
130
- extractScriptContent,
131
119
  filterBodyIntegrationFromPosition,
132
120
  filterHeadIntegrations,
133
121
  filterPositionIntegrations,
@@ -0,0 +1,11 @@
1
+ //
2
+ // Griddo CX library react export file.
3
+ // This file exports functions to use in the SSG's frameworks.
4
+ //
5
+ // import { ... } from "@griddo/cx/react";
6
+ //
7
+
8
+ import { Favicon } from "./Favicon";
9
+ import { GriddoIntegrations } from "./GriddoIntegrations";
10
+
11
+ export { Favicon, GriddoIntegrations };
@@ -0,0 +1,14 @@
1
+ import { MemoryRegister, Register } from "../services/register";
2
+
3
+ const entries = {
4
+ API_RESPONSE_TOO_BIG: {
5
+ title: "API response size is too large",
6
+ description:
7
+ "API response size is too large and may affect rendering performance",
8
+ entries: [],
9
+ },
10
+ };
11
+
12
+ const register = new Register(new MemoryRegister(entries));
13
+
14
+ export default register;
@@ -0,0 +1,14 @@
1
+ import { MemoryRegister, Register } from "../services/register";
2
+
3
+ const entries = {
4
+ GATSBY_PAGE_SIZE_TOO_BIG: {
5
+ title: "Gatsby JSON page size is too large",
6
+ description:
7
+ "The JSON of some Gatsby pages (page-data folder) are too large and may affect rendering performance",
8
+ entries: [],
9
+ },
10
+ };
11
+
12
+ const register = new Register(new MemoryRegister(entries));
13
+
14
+ export default register;
@@ -0,0 +1,4 @@
1
+ import apiRegister from "./api";
2
+ import gatsbyRegister from "./gatsby";
3
+
4
+ export { apiRegister, gatsbyRegister };
@@ -1,9 +1,8 @@
1
1
  import type { AuthHeaders } from "../types/api";
2
2
 
3
- import { LOGIN } from "../constants/endpoints";
4
- import { GRIDDO_BOT_PASSWORD, GRIDDO_BOT_USER } from "../constants/envs";
5
- import { LoginError } from "../constants/errors";
6
- import { throwError } from "../utils/errors";
3
+ import { endpoints, envs } from "../constants";
4
+ import { throwError } from "../errors";
5
+ import { LoginError } from "../errors/errors-data";
7
6
 
8
7
  /**
9
8
  * Service for authentication in the Griddo Private API
@@ -13,12 +12,12 @@ class AuthService {
13
12
 
14
13
  async login() {
15
14
  try {
16
- const response = await fetch(LOGIN, {
15
+ const response = await fetch(endpoints.LOGIN, {
17
16
  method: "POST",
18
17
  headers: { "Content-Type": "application/json", Connection: "close" },
19
18
  body: JSON.stringify({
20
- username: GRIDDO_BOT_USER,
21
- password: GRIDDO_BOT_PASSWORD,
19
+ username: envs.GRIDDO_BOT_USER,
20
+ password: envs.GRIDDO_BOT_PASSWORD,
22
21
  }),
23
22
  });
24
23
 
@@ -0,0 +1,16 @@
1
+ import type { Domains } from "../types/global";
2
+
3
+ import { endpoints } from "../constants";
4
+ import { get } from "../utils/api";
5
+
6
+ /**
7
+ * Get an array of available domain.
8
+ */
9
+ async function getAllDomains() {
10
+ return get<Domains>({
11
+ endpoint: endpoints.DOMAINS,
12
+ useApiCacheDir: false,
13
+ });
14
+ }
15
+
16
+ export { getAllDomains };
@@ -68,7 +68,9 @@ class NavigationService {
68
68
  const rightLanguageItem = list.find(
69
69
  (item) =>
70
70
  item.language === language &&
71
- item.navigationLanguages?.find((version) => version.navigationId === id),
71
+ item.navigationLanguages?.find(
72
+ (version) => version.navigationId === id,
73
+ ),
72
74
  );
73
75
 
74
76
  const result = rightLanguageItem || list.find((item) => item.id === id);
@@ -85,9 +87,13 @@ class NavigationService {
85
87
  }
86
88
 
87
89
  getPageNavigations(page: APIPageObject) {
88
- const { header: pageHeader, footer: pageFooter, language, template, templateConfig } = page;
89
- const { templateType } = template;
90
- const { defaultHeader, defaultFooter, templates } = templateConfig;
90
+ const {
91
+ header: pageHeader,
92
+ footer: pageFooter,
93
+ language,
94
+ template: { templateType },
95
+ templateConfig: { defaultHeader, defaultFooter, templates },
96
+ } = page;
91
97
 
92
98
  // The navigations would be:
93
99
  // - The one with the page or ...
@@ -1,9 +1,9 @@
1
- import type { Core, Fields } from "@griddo/core";
2
1
  import type { FetchDataProps } from "../types/global";
3
2
  import type { APIPageObject } from "../types/pages";
3
+ import type { Core, Fields } from "@griddo/core";
4
4
 
5
- import { boxLog } from "../utils/loggin";
6
5
  import { getReferenceFieldSiteData } from "./sites";
6
+ import { boxLog } from "../utils/loggin";
7
7
 
8
8
  /**
9
9
  * Get the body data from a ReferenceField.
@@ -54,7 +54,9 @@ function getBody(data: Fields.Reference<unknown>, page: Core.Page) {
54
54
  };
55
55
  }
56
56
 
57
- console.log(`Error: ReferenceField mode: ${mode} is not recognized on page ${page?.id}.`);
57
+ console.log(
58
+ `Error: ReferenceField mode: ${mode} is not recognized on page ${page?.id}.`,
59
+ );
58
60
 
59
61
  return data;
60
62
  }
@@ -69,8 +71,11 @@ function getBody(data: Fields.Reference<unknown>, page: Core.Page) {
69
71
  * @returns The ContentType data.
70
72
  */
71
73
  async function fetchContentTypeData(props: FetchDataProps) {
72
- const { page, component, cacheKey } = props;
73
- const { data } = component;
74
+ const {
75
+ page,
76
+ component: { data },
77
+ cacheKey,
78
+ } = props;
74
79
 
75
80
  // Distrubutor with `hasDistributorData: true` / `getStaticData: true` but without `data` prop
76
81
  if (!data) {
@@ -104,7 +109,13 @@ async function fetchContentTypeData(props: FetchDataProps) {
104
109
 
105
110
  const body = getBody(data, page);
106
111
 
107
- const response = await getReferenceFieldSiteData(page, body, cacheKey, site, lang);
112
+ const response = await getReferenceFieldSiteData(
113
+ page,
114
+ body,
115
+ cacheKey,
116
+ site,
117
+ lang,
118
+ );
108
119
 
109
120
  return response;
110
121
  }
@@ -154,7 +165,10 @@ async function getReferenceFieldData({
154
165
  continue;
155
166
  }
156
167
 
157
- const _key = key as "hasDistributorData" | "queriedItems" | "getStaticData";
168
+ const _key = key as
169
+ | "hasDistributorData"
170
+ | "queriedItems"
171
+ | "getStaticData";
158
172
  const component = templateChunk[_key] as unknown as {
159
173
  data: Fields.Reference<unknown>;
160
174
  queriedItems: Fields.QueriedData<unknown>;
@@ -167,7 +181,8 @@ async function getReferenceFieldData({
167
181
  continue;
168
182
  }
169
183
 
170
- const componentHasRequestForData = component.hasDistributorData || component.getStaticData;
184
+ const componentHasRequestForData =
185
+ component.hasDistributorData || component.getStaticData;
171
186
 
172
187
  if (componentHasRequestForData) {
173
188
  component.queriedItems = await fetchContentTypeData({
@@ -195,7 +210,7 @@ async function getReferenceFieldData({
195
210
  } catch (err) {
196
211
  console.error(`Error in getReferenceFieldData ${err}`);
197
212
 
198
- throw err;
213
+ process.exit(1);
199
214
  }
200
215
  }
201
216
 
@@ -0,0 +1,113 @@
1
+ import fsx from "fs-extra";
2
+
3
+ type Entry = Record<string, unknown>;
4
+
5
+ type EntryData = {
6
+ title: string;
7
+ description: string;
8
+ entries: Array<Entry>;
9
+ };
10
+
11
+ type Entries = Record<string, EntryData>;
12
+
13
+ interface RegisterBase<T extends Entries> {
14
+ insert(name: keyof T, entry: Entry): void;
15
+ get(name: keyof T): EntryData;
16
+ getAll(): T;
17
+ }
18
+
19
+ class MemoryRegister<T extends Entries> implements RegisterBase<T> {
20
+ entries: T;
21
+
22
+ constructor(entries: T) {
23
+ this.entries = entries;
24
+ }
25
+
26
+ insert(name: keyof T, entry: Entry) {
27
+ this.entries[name].entries.push(entry);
28
+ }
29
+
30
+ get(name: keyof T) {
31
+ return this.entries[name];
32
+ }
33
+
34
+ getAll() {
35
+ return this.entries;
36
+ }
37
+ }
38
+
39
+ class FileRegister<T extends Entries> implements RegisterBase<T> {
40
+ private readonly filePath: string;
41
+ entries: T;
42
+
43
+ constructor(filePath: string, entries: T) {
44
+ this.entries = entries;
45
+ this.filePath = filePath;
46
+ try {
47
+ fsx.writeJSONSync(this.filePath, this.entries);
48
+ } catch (e) {
49
+ console.error(`Error writing ${this.filePath}`, e);
50
+ }
51
+ }
52
+
53
+ private getCurrentEntries(): T {
54
+ return fsx.readJSONSync(this.filePath, "utf8") as T;
55
+ }
56
+
57
+ insert(name: keyof T, entry: Entry) {
58
+ try {
59
+ const currentEntries = this.getCurrentEntries();
60
+ currentEntries[name].entries.push(entry);
61
+ fsx.writeJSONSync(this.filePath, currentEntries);
62
+ } catch (e) {
63
+ console.error(e);
64
+ }
65
+ }
66
+
67
+ get(name: keyof T) {
68
+ try {
69
+ return fsx.readJSONSync(this.filePath, "utf8")[name] as EntryData;
70
+ } catch (e) {
71
+ console.error(e);
72
+ throw new Error(`Error reading ${this.filePath}`);
73
+ }
74
+ }
75
+
76
+ getAll() {
77
+ try {
78
+ return fsx.readJSONSync(this.filePath, "utf8") as T;
79
+ } catch (e) {
80
+ console.error(e);
81
+ throw new Error(`Error reading ${this.filePath}`);
82
+ }
83
+ }
84
+ }
85
+
86
+ class Register<T extends Entries> {
87
+ private strategy: RegisterBase<T>;
88
+
89
+ constructor(strategy: RegisterBase<T>) {
90
+ this.strategy = strategy;
91
+ }
92
+
93
+ insert<K extends keyof T>(name: K, entry: Entry) {
94
+ this.strategy.insert(name, entry);
95
+ }
96
+
97
+ get<K extends keyof T>(name: K) {
98
+ return this.strategy.get(name);
99
+ }
100
+
101
+ getAll() {
102
+ return this.strategy.getAll();
103
+ }
104
+ }
105
+
106
+ export {
107
+ FileRegister,
108
+ MemoryRegister,
109
+ Register,
110
+ type Entries,
111
+ type Entry,
112
+ type EntryData,
113
+ };
@@ -1,14 +1,18 @@
1
1
  import type { Robots } from "../types/global";
2
2
 
3
- import fsp from "node:fs/promises";
3
+ import fs from "node:fs";
4
4
  import path from "node:path";
5
5
 
6
- import { ROBOTS } from "../constants/endpoints";
6
+ import { endpoints } from "../constants";
7
7
  import { get } from "../utils/api";
8
- import { pathExists } from "../utils/folders";
8
+ import { getConfig } from "../utils/core-utils";
9
9
  import { verboseLog } from "../utils/loggin";
10
- import { getRenderPathsFromDB } from "../utils/render";
11
10
 
11
+ const config = getConfig();
12
+
13
+ /**
14
+ * TODO: JSDoc
15
+ */
12
16
  class RobotsService {
13
17
  robots: Robots;
14
18
  settings: Record<string, unknown>;
@@ -18,9 +22,12 @@ class RobotsService {
18
22
  this.settings = {};
19
23
  }
20
24
 
25
+ /**
26
+ * TODO: JSDoc
27
+ */
21
28
  private async getRobots() {
22
29
  try {
23
- const apiRobots = await get<Robots>({ endpoint: ROBOTS });
30
+ const apiRobots = await get<Robots>({ endpoint: endpoints.ROBOTS });
24
31
  this.robots =
25
32
  apiRobots
26
33
  ?.filter((r) => !!r.path)
@@ -37,8 +44,8 @@ class RobotsService {
37
44
  * Write robots.txt files for the domain.
38
45
  */
39
46
  async writeFiles(domain: string) {
40
- const { __root } = await getRenderPathsFromDB({ domain });
41
- const distDirectory = path.join(__root, "dist");
47
+ const { __cx } = config.paths(domain);
48
+ const distDirectory = path.join(__cx, "dist");
42
49
 
43
50
  await this.getRobots();
44
51
 
@@ -49,9 +56,9 @@ class RobotsService {
49
56
  return;
50
57
  }
51
58
 
52
- if (await pathExists(distDirectory)) {
59
+ if (fs.existsSync(distDirectory)) {
53
60
  const fileLocation = path.join(distDirectory, "robots.txt");
54
- await fsp.writeFile(fileLocation, robot?.content);
61
+ fs.writeFileSync(fileLocation, robot?.content);
55
62
  verboseLog(`wrote robots.txt to ${fileLocation}`);
56
63
  } else {
57
64
  console.log(`${distDirectory} not found`);
@@ -0,0 +1,17 @@
1
+ import type { Settings } from "../types/global";
2
+
3
+ import { endpoints } from "../constants";
4
+ import { get, post } from "../utils/api";
5
+
6
+ async function getAllSettings() {
7
+ return get<Settings>({ endpoint: endpoints.SETTINGS });
8
+ }
9
+
10
+ async function resetRender() {
11
+ await post({
12
+ endpoint: endpoints.RESET_RENDER,
13
+ useApiCacheDir: false,
14
+ });
15
+ }
16
+
17
+ export { getAllSettings, resetRender };