@griddo/cx 11.7.6 → 11.7.7-rc.0

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 (280) hide show
  1. package/README.md +27 -226
  2. package/build/adapters/gatsby/actions/clean.js +10 -0
  3. package/build/adapters/gatsby/actions/clean.js.map +1 -0
  4. package/build/adapters/gatsby/actions/close.js +12 -0
  5. package/build/adapters/gatsby/actions/close.js.map +1 -0
  6. package/build/adapters/gatsby/actions/data.js +18 -0
  7. package/build/adapters/gatsby/actions/data.js.map +1 -0
  8. package/build/adapters/gatsby/actions/healthCheck.js +10 -0
  9. package/build/adapters/gatsby/actions/healthCheck.js.map +1 -0
  10. package/build/adapters/gatsby/actions/init.js +9 -0
  11. package/build/adapters/gatsby/actions/init.js.map +1 -0
  12. package/build/adapters/gatsby/actions/meta.js +14 -0
  13. package/build/adapters/gatsby/actions/meta.js.map +1 -0
  14. package/build/adapters/gatsby/actions/prepare.js +9 -0
  15. package/build/adapters/gatsby/actions/prepare.js.map +1 -0
  16. package/build/adapters/gatsby/actions/relocation.js +15 -0
  17. package/build/adapters/gatsby/actions/relocation.js.map +1 -0
  18. package/build/adapters/gatsby/actions/restore.js +26 -0
  19. package/build/adapters/gatsby/actions/restore.js.map +1 -0
  20. package/build/adapters/gatsby/actions/ssg.js +9 -0
  21. package/build/adapters/gatsby/actions/ssg.js.map +1 -0
  22. package/build/adapters/gatsby/actions/sync.js +51 -0
  23. package/build/adapters/gatsby/actions/sync.js.map +1 -0
  24. package/build/adapters/gatsby/index.js +79 -0
  25. package/build/adapters/gatsby/index.js.map +1 -0
  26. package/build/adapters/gatsby/shared/context.js +31 -0
  27. package/build/adapters/gatsby/shared/context.js.map +1 -0
  28. package/build/adapters/gatsby/shared/diff-assets.js +101 -0
  29. package/build/adapters/gatsby/shared/diff-assets.js.map +1 -0
  30. package/build/adapters/gatsby/shared/extract-assets.js +58 -0
  31. package/build/adapters/gatsby/shared/extract-assets.js.map +1 -0
  32. package/build/adapters/gatsby/shared/gatsby-build.js +49 -0
  33. package/build/adapters/gatsby/shared/gatsby-build.js.map +1 -0
  34. package/build/adapters/gatsby/shared/sync-render.js +210 -0
  35. package/build/adapters/gatsby/shared/sync-render.js.map +1 -0
  36. package/build/adapters/gatsby/shared/types.js +3 -0
  37. package/build/adapters/gatsby/shared/types.js.map +1 -0
  38. package/build/commands/end-render.js +88 -0
  39. package/build/commands/end-render.js.map +1 -0
  40. package/build/commands/prepare-assets-directory.js +32 -0
  41. package/build/commands/prepare-assets-directory.js.map +1 -0
  42. package/build/commands/prepare-domains-render.js +133 -0
  43. package/build/commands/prepare-domains-render.js.map +1 -0
  44. package/build/commands/reset-render.js +22 -0
  45. package/build/commands/reset-render.js.map +1 -0
  46. package/build/commands/start-render.js +45 -0
  47. package/build/commands/start-render.js.map +1 -0
  48. package/build/commands/upload-search-content.js +180 -0
  49. package/build/commands/upload-search-content.js.map +1 -0
  50. package/build/constants/endpoints.js +42 -0
  51. package/build/constants/endpoints.js.map +1 -0
  52. package/build/constants/envs.js +68 -0
  53. package/build/constants/envs.js.map +1 -0
  54. package/build/constants/errors.js +81 -0
  55. package/build/constants/errors.js.map +1 -0
  56. package/build/services/auth.js +40 -0
  57. package/build/services/auth.js.map +1 -0
  58. package/build/services/db-class.js +49 -0
  59. package/build/services/db-class.js.map +1 -0
  60. package/build/services/db.js +34 -0
  61. package/build/services/db.js.map +1 -0
  62. package/build/services/navigation.js +96 -0
  63. package/build/services/navigation.js.map +1 -0
  64. package/build/services/reference-fields.js +131 -0
  65. package/build/services/reference-fields.js.map +1 -0
  66. package/build/services/robots.js +60 -0
  67. package/build/services/robots.js.map +1 -0
  68. package/build/services/sites.js +109 -0
  69. package/build/services/sites.js.map +1 -0
  70. package/build/services/store.js +282 -0
  71. package/build/services/store.js.map +1 -0
  72. package/build/types/api.js +3 -0
  73. package/build/types/api.js.map +1 -0
  74. package/build/types/global.js +3 -0
  75. package/build/types/global.js.map +1 -0
  76. package/build/types/navigation.js +3 -0
  77. package/build/types/navigation.js.map +1 -0
  78. package/build/types/pages.js +3 -0
  79. package/build/types/pages.js.map +1 -0
  80. package/build/types/render.js +10 -0
  81. package/build/types/render.js.map +1 -0
  82. package/build/types/sites.js +3 -0
  83. package/build/types/sites.js.map +1 -0
  84. package/build/types/templates.js +3 -0
  85. package/build/types/templates.js.map +1 -0
  86. package/build/utils/api.js +161 -0
  87. package/build/utils/api.js.map +1 -0
  88. package/build/utils/artifacts.js +34 -0
  89. package/build/utils/artifacts.js.map +1 -0
  90. package/build/utils/brush.js +30 -0
  91. package/build/utils/brush.js.map +1 -0
  92. package/build/utils/cache.js +106 -0
  93. package/build/utils/cache.js.map +1 -0
  94. package/build/utils/check-health.js +68 -0
  95. package/build/utils/check-health.js.map +1 -0
  96. package/build/utils/core-utils.js +283 -0
  97. package/build/utils/core-utils.js.map +1 -0
  98. package/build/utils/domains.js +37 -0
  99. package/build/utils/domains.js.map +1 -0
  100. package/build/utils/errors.js +30 -0
  101. package/build/utils/errors.js.map +1 -0
  102. package/build/utils/folders.js +362 -0
  103. package/build/utils/folders.js.map +1 -0
  104. package/build/utils/images.js +45 -0
  105. package/build/utils/images.js.map +1 -0
  106. package/build/utils/instance.js +66 -0
  107. package/build/utils/instance.js.map +1 -0
  108. package/build/utils/loggin.js +108 -0
  109. package/build/utils/loggin.js.map +1 -0
  110. package/build/utils/pages.js +359 -0
  111. package/build/utils/pages.js.map +1 -0
  112. package/build/utils/render.js +144 -0
  113. package/build/utils/render.js.map +1 -0
  114. package/build/utils/sites.js +240 -0
  115. package/build/utils/sites.js.map +1 -0
  116. package/build/utils/store.js +193 -0
  117. package/build/utils/store.js.map +1 -0
  118. package/exporter/adapters/gatsby/actions/clean.ts +14 -0
  119. package/exporter/adapters/gatsby/actions/close.ts +17 -0
  120. package/exporter/adapters/gatsby/actions/data.ts +25 -0
  121. package/exporter/adapters/gatsby/actions/healthCheck.ts +10 -0
  122. package/exporter/adapters/gatsby/actions/init.ts +12 -0
  123. package/exporter/adapters/gatsby/actions/meta.ts +18 -0
  124. package/exporter/adapters/gatsby/actions/prepare.ts +9 -0
  125. package/exporter/adapters/gatsby/actions/relocation.ts +15 -0
  126. package/exporter/adapters/gatsby/actions/restore.ts +36 -0
  127. package/exporter/adapters/gatsby/actions/ssg.ts +12 -0
  128. package/exporter/adapters/gatsby/actions/sync.ts +71 -0
  129. package/exporter/adapters/gatsby/index.ts +67 -147
  130. package/exporter/adapters/gatsby/shared/context.ts +50 -0
  131. package/exporter/adapters/gatsby/shared/diff-assets.ts +113 -0
  132. package/exporter/adapters/gatsby/shared/extract-assets.ts +61 -0
  133. package/exporter/adapters/gatsby/shared/gatsby-build.ts +54 -0
  134. package/exporter/adapters/gatsby/shared/sync-render.ts +276 -0
  135. package/exporter/adapters/gatsby/shared/types.ts +35 -0
  136. package/exporter/build-esbuild.noop +42 -0
  137. package/exporter/build.sh +4 -38
  138. package/exporter/commands/end-render.ts +73 -69
  139. package/exporter/commands/prepare-assets-directory.ts +33 -0
  140. package/exporter/commands/prepare-domains-render.ts +144 -31
  141. package/exporter/commands/reset-render.ts +10 -1
  142. package/exporter/commands/start-render.ts +23 -44
  143. package/exporter/commands/upload-search-content.ts +194 -20
  144. package/exporter/constants/envs.ts +57 -55
  145. package/exporter/{errors/errors-data.ts → constants/errors.ts} +24 -14
  146. package/exporter/services/auth.ts +7 -6
  147. package/exporter/services/db-class.ts +54 -0
  148. package/exporter/services/db.ts +32 -0
  149. package/exporter/services/navigation.ts +4 -10
  150. package/exporter/services/reference-fields.ts +8 -23
  151. package/exporter/services/robots.ts +9 -16
  152. package/exporter/services/sites.ts +35 -24
  153. package/exporter/services/store.ts +120 -78
  154. package/exporter/types/api.ts +24 -27
  155. package/exporter/types/global.ts +7 -10
  156. package/exporter/types/navigation.ts +1 -1
  157. package/exporter/types/pages.ts +2 -3
  158. package/exporter/types/render.ts +59 -0
  159. package/exporter/types/sites.ts +1 -2
  160. package/exporter/utils/api.ts +46 -82
  161. package/exporter/utils/artifacts.ts +34 -0
  162. package/exporter/utils/brush.ts +34 -0
  163. package/exporter/utils/cache.ts +37 -62
  164. package/exporter/utils/check-health.ts +79 -0
  165. package/exporter/utils/core-utils.ts +129 -248
  166. package/exporter/utils/domains.ts +10 -7
  167. package/exporter/{errors/index.ts → utils/errors.ts} +10 -9
  168. package/exporter/utils/folders.ts +187 -95
  169. package/exporter/utils/images.ts +1 -6
  170. package/exporter/utils/instance.ts +9 -12
  171. package/exporter/utils/loggin.ts +32 -91
  172. package/exporter/utils/pages.ts +23 -88
  173. package/exporter/utils/render.ts +149 -48
  174. package/exporter/utils/sites.ts +81 -90
  175. package/exporter/utils/store.ts +87 -180
  176. package/gatsby-browser.tsx +41 -58
  177. package/gatsby-config.ts +6 -12
  178. package/gatsby-node.ts +15 -77
  179. package/gatsby-ssr.tsx +2 -1
  180. package/package.json +36 -78
  181. package/plugins/gatsby-plugin-svgr-loader/gatsby-node.js +55 -0
  182. package/plugins/gatsby-plugin-svgr-loader/package.json +8 -0
  183. package/{exporter/react → react}/Favicon/index.tsx +1 -7
  184. package/{exporter/react → react}/GriddoIntegrations/index.tsx +6 -14
  185. package/{exporter/react → react}/GriddoIntegrations/utils.ts +4 -9
  186. package/{build/react/index.d.ts → react/index.tsx} +1 -0
  187. package/src/components/Head.tsx +13 -46
  188. package/src/components/template.tsx +8 -30
  189. package/src/gatsby-node-utils.ts +91 -2
  190. package/src/html.tsx +2 -11
  191. package/src/types.ts +5 -5
  192. package/tsconfig.json +5 -3
  193. package/build/adapters/gatsby/index.d.ts +0 -4
  194. package/build/adapters/gatsby/utils.d.ts +0 -22
  195. package/build/artifacts/index.d.ts +0 -6
  196. package/build/commands/end-render.d.ts +0 -2
  197. package/build/commands/move-assets.d.ts +0 -1
  198. package/build/commands/prepare-domains-render.d.ts +0 -1
  199. package/build/commands/reset-render.d.ts +0 -2
  200. package/build/commands/start-render.d.ts +0 -2
  201. package/build/commands/upload-search-content.d.ts +0 -2
  202. package/build/constants/endpoints.d.ts +0 -19
  203. package/build/constants/envs.d.ts +0 -37
  204. package/build/constants/index.d.ts +0 -57
  205. package/build/end-render.js +0 -74
  206. package/build/end-render.js.map +0 -7
  207. package/build/errors/errors-data.d.ts +0 -22
  208. package/build/errors/index.d.ts +0 -15
  209. package/build/index.d.ts +0 -29
  210. package/build/index.js +0 -73
  211. package/build/index.js.map +0 -7
  212. package/build/prepare-domains-render.js +0 -73
  213. package/build/prepare-domains-render.js.map +0 -7
  214. package/build/react/Favicon/index.d.ts +0 -5
  215. package/build/react/Favicon/utils.d.ts +0 -9
  216. package/build/react/GriddoIntegrations/index.d.ts +0 -20
  217. package/build/react/GriddoIntegrations/utils.d.ts +0 -26
  218. package/build/react/index.js +0 -3
  219. package/build/registers/api.d.ts +0 -9
  220. package/build/registers/gatsby.d.ts +0 -9
  221. package/build/registers/index.d.ts +0 -3
  222. package/build/reset-render.js +0 -74
  223. package/build/reset-render.js.map +0 -7
  224. package/build/services/auth.d.ts +0 -10
  225. package/build/services/domains.d.ts +0 -6
  226. package/build/services/navigation.d.ts +0 -50
  227. package/build/services/reference-fields.d.ts +0 -20
  228. package/build/services/register.d.ts +0 -36
  229. package/build/services/robots.d.ts +0 -19
  230. package/build/services/settings.d.ts +0 -4
  231. package/build/services/sites.d.ts +0 -29
  232. package/build/services/store.d.ts +0 -6
  233. package/build/start-render.js +0 -100
  234. package/build/start-render.js.map +0 -7
  235. package/build/types/api.d.ts +0 -142
  236. package/build/types/global.d.ts +0 -84
  237. package/build/types/navigation.d.ts +0 -28
  238. package/build/types/pages.d.ts +0 -144
  239. package/build/types/sites.d.ts +0 -57
  240. package/build/types/templates.d.ts +0 -8
  241. package/build/upload-search-content.js +0 -74
  242. package/build/upload-search-content.js.map +0 -7
  243. package/build/utils/alerts.d.ts +0 -3
  244. package/build/utils/api.d.ts +0 -23
  245. package/build/utils/cache.d.ts +0 -35
  246. package/build/utils/core-utils.d.ts +0 -107
  247. package/build/utils/create-build-data.d.ts +0 -8
  248. package/build/utils/domains.d.ts +0 -13
  249. package/build/utils/folders.d.ts +0 -53
  250. package/build/utils/health-checks.d.ts +0 -7
  251. package/build/utils/images.d.ts +0 -16
  252. package/build/utils/instance.d.ts +0 -21
  253. package/build/utils/loggin.d.ts +0 -51
  254. package/build/utils/pages.d.ts +0 -34
  255. package/build/utils/render.d.ts +0 -13
  256. package/build/utils/searches.d.ts +0 -15
  257. package/build/utils/sites.d.ts +0 -31
  258. package/build/utils/store.d.ts +0 -81
  259. package/cx.config.d.ts +0 -5
  260. package/cx.config.js +0 -36
  261. package/exporter/adapters/gatsby/utils.ts +0 -161
  262. package/exporter/artifacts/README.md +0 -34
  263. package/exporter/artifacts/index.ts +0 -33
  264. package/exporter/commands/move-assets.ts +0 -11
  265. package/exporter/constants/index.ts +0 -129
  266. package/exporter/index.ts +0 -82
  267. package/exporter/react/index.tsx +0 -11
  268. package/exporter/registers/api.ts +0 -14
  269. package/exporter/registers/gatsby.ts +0 -14
  270. package/exporter/registers/index.ts +0 -4
  271. package/exporter/services/domains.ts +0 -16
  272. package/exporter/services/register.ts +0 -113
  273. package/exporter/services/settings.ts +0 -17
  274. package/exporter/utils/alerts.ts +0 -29
  275. package/exporter/utils/create-build-data.ts +0 -17
  276. package/exporter/utils/health-checks.ts +0 -64
  277. package/exporter/utils/searches.ts +0 -156
  278. package/src/README.md +0 -7
  279. package/start-render.js +0 -7
  280. /package/{exporter/react → react}/Favicon/utils.ts +0 -0
@@ -1,64 +0,0 @@
1
- import { boxLog } from "./loggin";
2
- import { envs } from "../constants";
3
-
4
- const GRIDDO_ENVS_VARS: ReadonlyArray<string> = [];
5
-
6
- /**
7
- * Check if the environment is secure to launch a render.
8
- * If something fails then log an error message and exit from the process.
9
- * Otherwise just return true.
10
- */
11
- function checkRenderHealthOrExit() {
12
- // Bypass the check using this env var, handy for local renders.
13
- if (envs.GRIDDO_SKIP_BUILD_CHECKS) {
14
- console.info("Build health check skipped");
15
-
16
- return true;
17
- }
18
-
19
- // Checklist
20
- const envsVars = checkEnvsVars(GRIDDO_ENVS_VARS);
21
-
22
- // Render is safe if...
23
- const renderingIsSave = envsVars;
24
-
25
- // The environment is suitable for a build-render
26
- if (renderingIsSave) {
27
- console.info("Build health check passed");
28
-
29
- return true;
30
- }
31
-
32
- // Error
33
- boxLog(
34
- "Error. The environment is not suitable for a build.",
35
- "Not valid environment",
36
- );
37
- process.exit(1);
38
- }
39
-
40
- /**
41
- * Check if a list of environments variables exist with any value.
42
- *
43
- * @todo Also check the value.
44
- * @param envs An array of environments variables
45
- * @returns exists with (1) if there are missing envs vars
46
- */
47
- function checkEnvsVars(envs: ReadonlyArray<string>) {
48
- const missingEnvs = envs.filter((envName) => {
49
- return !process.env[envName];
50
- });
51
-
52
- if (missingEnvs.length) {
53
- const missingEnvsMsg = missingEnvs.join("\n");
54
- console.error(
55
- `Env check failed. These envs vars are missing: \n\n${missingEnvsMsg}`,
56
- );
57
-
58
- return false;
59
- }
60
-
61
- return true;
62
- }
63
-
64
- export { checkRenderHealthOrExit };
@@ -1,156 +0,0 @@
1
- import type { PostSearchInfoResponse } from "../types/api";
2
- import type {
3
- AIEmbeddingsResponse,
4
- PostSearchInfoProps,
5
- } from "../types/global";
6
-
7
- import fs from "node:fs";
8
- import path from "node:path";
9
-
10
- import { post } from "./api";
11
- import { getConfig } from "./core-utils";
12
- import { getBuildPagesFromCachedStore } from "./store";
13
- import { endpoints } from "../constants";
14
-
15
- /**
16
- * Save in the BBDD the content of a page parsed without HTML tags.
17
- *
18
- * @param props Object with parts of the final page object to be saved in the BBDD.
19
- */
20
- async function postSearchInfo(props: PostSearchInfoProps) {
21
- const {
22
- title,
23
- description,
24
- image,
25
- pageId,
26
- languageId,
27
- siteId,
28
- url,
29
- content,
30
- template,
31
- } = props;
32
-
33
- const response = await post<PostSearchInfoResponse>({
34
- endpoint: endpoints.SEARCH,
35
- body: {
36
- title,
37
- description,
38
- image,
39
- pageId,
40
- languageId,
41
- siteId,
42
- url,
43
- template,
44
- content,
45
- },
46
- useApiCacheDir: false,
47
- });
48
-
49
- return response;
50
- }
51
-
52
- /**
53
- * Remove the every cntent inside some HTML tags including them.
54
- *
55
- * @param content A string with the content.
56
- */
57
- function prepareHTMLContentForSearch(content: string): string {
58
- // 1. Remove script, style, and other unwanted block tags and their content.
59
- // The regex looks for <tag...>...</tag> where tag is one of the specified ones.
60
- const tagsToRemove = [
61
- "meta",
62
- "link",
63
- "style",
64
- "script",
65
- "noscript",
66
- "nav",
67
- "header",
68
- "footer",
69
- ];
70
- const removeTagsRegex = new RegExp(
71
- `<(${tagsToRemove.join("|")})\\b[^>]*>.*?<\\/\\1>`,
72
- "gis",
73
- );
74
- let processedContent = content.replace(removeTagsRegex, "");
75
-
76
- // 2. Strip all remaining HTML tags.
77
- processedContent = processedContent.replace(/<[^>]+>/g, " ");
78
-
79
- // 3. Normalize whitespace: replace multiple spaces/newlines with a single space and trim.
80
- processedContent = processedContent.replace(/\s+/g, " ").trim();
81
-
82
- return processedContent;
83
- }
84
-
85
- /**
86
- * Function that search in the `/public` dir the content info of the pages and
87
- * send it to the search table in the ddbb using the API.
88
- */
89
- async function uploadRenderedSearchContentToAPI(
90
- distDomainPath: string,
91
- domain: string,
92
- ) {
93
- const config = getConfig();
94
- const { __cache } = config.paths(domain);
95
-
96
- // Extraemos el path de la carpeta store dentro de un dominio
97
- const storeFolder = path.join(__cache, "store");
98
-
99
- // Este caso sería que el dominio existe en la instancia pero no hay sites
100
- // renderizardos bajo el mismo. Por lo que `store` no existe.
101
- if (!fs.existsSync(storeFolder)) {
102
- console.log(
103
- `Skipping uploading content to the search endpoint for the domain ${domain}, it has not exported sites.`,
104
- );
105
- return;
106
- }
107
-
108
- // Obtenemos las páginas del store cacheado de un dominio
109
- const storePages = getBuildPagesFromCachedStore(domain);
110
-
111
- for await (const store of storePages) {
112
- const {
113
- context: { page, openGraph, pageMetadata },
114
- } = store;
115
-
116
- const { compose } = page.fullPath;
117
-
118
- const contextPath = path.resolve(`${distDomainPath}/${compose}/index.html`);
119
-
120
- const content = fs.readFileSync(contextPath).toString();
121
-
122
- const pageObject: PostSearchInfoProps = {
123
- siteId: page.site,
124
- pageId: page.id,
125
- // `pageMetadata.title` has already a fallback `metatitle ||
126
- // pageTitle` so probably `title` never will be take the
127
- // `openGraph?.title` value. Only when the `metatitle` and
128
- // `pageTitle` are empty.
129
- title: pageMetadata?.title || openGraph?.title,
130
- languageId: page.language,
131
- url: page.fullUrl,
132
- template: page.template.templateType || page.templateId,
133
- description: pageMetadata?.description || openGraph?.description,
134
- image: openGraph.image,
135
- content: prepareHTMLContentForSearch(content),
136
- };
137
-
138
- await postSearchInfo(pageObject);
139
- }
140
- }
141
-
142
- async function startAIEmbeddings() {
143
- try {
144
- await post<AIEmbeddingsResponse>({
145
- endpoint: endpoints.AI_EMBEDDINGS,
146
- useApiCacheDir: false,
147
- });
148
- } catch (error) {
149
- console.warn(
150
- "There was an error with the ai embeddings",
151
- (error as Error).message,
152
- );
153
- }
154
- }
155
-
156
- export { postSearchInfo, startAIEmbeddings, uploadRenderedSearchContentToAPI };
package/src/README.md DELETED
@@ -1,7 +0,0 @@
1
- # Griddo CX + Gatsby
2
-
3
- The `/src` dir and almost every file in the root dir is now 100% Gatsby related code along with the historical `/public`, `/dist`, `/apiCache`, `/store`, etc.. render dirs.
4
-
5
- Griddo CX code (the business logic) is now in `/exporter` dir.
6
-
7
- In the future, Griddo CX and Gatsby will split int their own packages dirs inside the mono-repo.
package/start-render.js DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- /* eslint-disable node/shebang */
3
- /* eslint-disable node/no-missing-require */
4
-
5
- // This is the "bin" for the griddo-cx package used by "infra" to trigger a
6
- // render running `npm run griddo-cx`.
7
- require("./build/start-render.js");
File without changes