@griddo/cx 11.7.7-rc.0 → 11.7.7-rc.1
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/README.md +226 -27
- package/build/adapters/gatsby/index.d.ts +4 -0
- package/build/adapters/gatsby/utils.d.ts +22 -0
- package/build/artifacts/index.d.ts +6 -0
- package/build/commands/end-render.d.ts +2 -0
- package/build/commands/move-assets.d.ts +1 -0
- package/build/commands/prepare-domains-render.d.ts +1 -0
- package/build/commands/reset-render.d.ts +2 -0
- package/build/commands/start-render.d.ts +2 -0
- package/build/commands/upload-search-content.d.ts +2 -0
- package/build/constants/endpoints.d.ts +19 -0
- package/build/constants/envs.d.ts +37 -0
- package/build/constants/index.d.ts +57 -0
- package/build/end-render.js +74 -0
- package/build/end-render.js.map +7 -0
- package/build/errors/errors-data.d.ts +22 -0
- package/build/errors/index.d.ts +15 -0
- package/build/index.d.ts +29 -0
- package/build/index.js +73 -0
- package/build/index.js.map +7 -0
- package/build/prepare-domains-render.js +73 -0
- package/build/prepare-domains-render.js.map +7 -0
- package/build/react/Favicon/index.d.ts +5 -0
- package/build/react/Favicon/utils.d.ts +9 -0
- package/build/react/GriddoIntegrations/index.d.ts +20 -0
- package/build/react/GriddoIntegrations/utils.d.ts +26 -0
- package/{react/index.tsx → build/react/index.d.ts} +0 -1
- package/build/react/index.js +3 -0
- package/build/registers/api.d.ts +9 -0
- package/build/registers/gatsby.d.ts +9 -0
- package/build/registers/index.d.ts +3 -0
- package/build/reset-render.js +74 -0
- package/build/reset-render.js.map +7 -0
- package/build/services/auth.d.ts +10 -0
- package/build/services/domains.d.ts +6 -0
- package/build/services/navigation.d.ts +50 -0
- package/build/services/reference-fields.d.ts +20 -0
- package/build/services/register.d.ts +36 -0
- package/build/services/robots.d.ts +19 -0
- package/build/services/settings.d.ts +4 -0
- package/build/services/sites.d.ts +29 -0
- package/build/services/store.d.ts +6 -0
- package/build/start-render.js +100 -0
- package/build/start-render.js.map +7 -0
- package/build/types/api.d.ts +142 -0
- package/build/types/global.d.ts +84 -0
- package/build/types/navigation.d.ts +28 -0
- package/build/types/pages.d.ts +144 -0
- package/build/types/sites.d.ts +57 -0
- package/build/types/templates.d.ts +8 -0
- package/build/upload-search-content.js +74 -0
- package/build/upload-search-content.js.map +7 -0
- package/build/utils/alerts.d.ts +3 -0
- package/build/utils/api.d.ts +23 -0
- package/build/utils/cache.d.ts +35 -0
- package/build/utils/core-utils.d.ts +107 -0
- package/build/utils/create-build-data.d.ts +8 -0
- package/build/utils/domains.d.ts +13 -0
- package/build/utils/folders.d.ts +53 -0
- package/build/utils/health-checks.d.ts +7 -0
- package/build/utils/images.d.ts +16 -0
- package/build/utils/instance.d.ts +21 -0
- package/build/utils/loggin.d.ts +51 -0
- package/build/utils/pages.d.ts +34 -0
- package/build/utils/render.d.ts +13 -0
- package/build/utils/searches.d.ts +15 -0
- package/build/utils/sites.d.ts +31 -0
- package/build/utils/store.d.ts +81 -0
- package/cx.config.d.ts +5 -0
- package/cx.config.js +36 -0
- package/exporter/adapters/gatsby/index.ts +147 -67
- package/exporter/adapters/gatsby/utils.ts +161 -0
- package/exporter/artifacts/README.md +34 -0
- package/exporter/artifacts/index.ts +33 -0
- package/exporter/build.sh +38 -4
- package/exporter/commands/end-render.ts +69 -73
- package/exporter/commands/move-assets.ts +11 -0
- package/exporter/commands/prepare-domains-render.ts +31 -144
- package/exporter/commands/reset-render.ts +1 -10
- package/exporter/commands/start-render.ts +44 -23
- package/exporter/commands/upload-search-content.ts +20 -194
- package/exporter/constants/envs.ts +55 -57
- package/exporter/constants/index.ts +129 -0
- package/exporter/{constants/errors.ts → errors/errors-data.ts} +14 -24
- package/exporter/{utils/errors.ts → errors/index.ts} +9 -10
- package/exporter/index.ts +82 -0
- package/{react → exporter/react}/Favicon/index.tsx +7 -1
- package/{react → exporter/react}/GriddoIntegrations/index.tsx +14 -6
- package/{react → exporter/react}/GriddoIntegrations/utils.ts +9 -4
- package/exporter/react/index.tsx +11 -0
- package/exporter/registers/api.ts +14 -0
- package/exporter/registers/gatsby.ts +14 -0
- package/exporter/registers/index.ts +4 -0
- package/exporter/services/auth.ts +6 -7
- package/exporter/services/domains.ts +16 -0
- package/exporter/services/navigation.ts +10 -4
- package/exporter/services/reference-fields.ts +23 -8
- package/exporter/services/register.ts +113 -0
- package/exporter/services/robots.ts +16 -9
- package/exporter/services/settings.ts +17 -0
- package/exporter/services/sites.ts +24 -35
- package/exporter/services/store.ts +78 -120
- package/exporter/types/api.ts +27 -24
- package/exporter/types/global.ts +10 -7
- package/exporter/types/navigation.ts +1 -1
- package/exporter/types/pages.ts +3 -2
- package/exporter/types/sites.ts +2 -1
- package/exporter/utils/alerts.ts +29 -0
- package/exporter/utils/api.ts +82 -46
- package/exporter/utils/cache.ts +62 -37
- package/exporter/utils/core-utils.ts +248 -129
- package/exporter/utils/create-build-data.ts +17 -0
- package/exporter/utils/domains.ts +7 -10
- package/exporter/utils/folders.ts +95 -187
- package/exporter/utils/health-checks.ts +64 -0
- package/exporter/utils/images.ts +6 -1
- package/exporter/utils/instance.ts +12 -9
- package/exporter/utils/loggin.ts +91 -32
- package/exporter/utils/pages.ts +88 -23
- package/exporter/utils/render.ts +48 -149
- package/exporter/utils/searches.ts +156 -0
- package/exporter/utils/sites.ts +90 -81
- package/exporter/utils/store.ts +180 -87
- package/gatsby-browser.tsx +58 -41
- package/gatsby-config.ts +12 -6
- package/gatsby-node.ts +77 -15
- package/gatsby-ssr.tsx +1 -2
- package/package.json +78 -36
- package/src/README.md +7 -0
- package/src/components/Head.tsx +46 -13
- package/src/components/template.tsx +30 -8
- package/src/gatsby-node-utils.ts +2 -91
- package/src/html.tsx +11 -2
- package/src/types.ts +5 -5
- package/start-render.js +7 -0
- package/tsconfig.json +3 -5
- package/build/adapters/gatsby/actions/clean.js +0 -10
- package/build/adapters/gatsby/actions/clean.js.map +0 -1
- package/build/adapters/gatsby/actions/close.js +0 -12
- package/build/adapters/gatsby/actions/close.js.map +0 -1
- package/build/adapters/gatsby/actions/data.js +0 -18
- package/build/adapters/gatsby/actions/data.js.map +0 -1
- package/build/adapters/gatsby/actions/healthCheck.js +0 -10
- package/build/adapters/gatsby/actions/healthCheck.js.map +0 -1
- package/build/adapters/gatsby/actions/init.js +0 -9
- package/build/adapters/gatsby/actions/init.js.map +0 -1
- package/build/adapters/gatsby/actions/meta.js +0 -14
- package/build/adapters/gatsby/actions/meta.js.map +0 -1
- package/build/adapters/gatsby/actions/prepare.js +0 -9
- package/build/adapters/gatsby/actions/prepare.js.map +0 -1
- package/build/adapters/gatsby/actions/relocation.js +0 -15
- package/build/adapters/gatsby/actions/relocation.js.map +0 -1
- package/build/adapters/gatsby/actions/restore.js +0 -26
- package/build/adapters/gatsby/actions/restore.js.map +0 -1
- package/build/adapters/gatsby/actions/ssg.js +0 -9
- package/build/adapters/gatsby/actions/ssg.js.map +0 -1
- package/build/adapters/gatsby/actions/sync.js +0 -51
- package/build/adapters/gatsby/actions/sync.js.map +0 -1
- package/build/adapters/gatsby/index.js +0 -79
- package/build/adapters/gatsby/index.js.map +0 -1
- package/build/adapters/gatsby/shared/context.js +0 -31
- package/build/adapters/gatsby/shared/context.js.map +0 -1
- package/build/adapters/gatsby/shared/diff-assets.js +0 -101
- package/build/adapters/gatsby/shared/diff-assets.js.map +0 -1
- package/build/adapters/gatsby/shared/extract-assets.js +0 -58
- package/build/adapters/gatsby/shared/extract-assets.js.map +0 -1
- package/build/adapters/gatsby/shared/gatsby-build.js +0 -49
- package/build/adapters/gatsby/shared/gatsby-build.js.map +0 -1
- package/build/adapters/gatsby/shared/sync-render.js +0 -210
- package/build/adapters/gatsby/shared/sync-render.js.map +0 -1
- package/build/adapters/gatsby/shared/types.js +0 -3
- package/build/adapters/gatsby/shared/types.js.map +0 -1
- package/build/commands/end-render.js +0 -88
- package/build/commands/end-render.js.map +0 -1
- package/build/commands/prepare-assets-directory.js +0 -32
- package/build/commands/prepare-assets-directory.js.map +0 -1
- package/build/commands/prepare-domains-render.js +0 -133
- package/build/commands/prepare-domains-render.js.map +0 -1
- package/build/commands/reset-render.js +0 -22
- package/build/commands/reset-render.js.map +0 -1
- package/build/commands/start-render.js +0 -45
- package/build/commands/start-render.js.map +0 -1
- package/build/commands/upload-search-content.js +0 -180
- package/build/commands/upload-search-content.js.map +0 -1
- package/build/constants/endpoints.js +0 -42
- package/build/constants/endpoints.js.map +0 -1
- package/build/constants/envs.js +0 -68
- package/build/constants/envs.js.map +0 -1
- package/build/constants/errors.js +0 -81
- package/build/constants/errors.js.map +0 -1
- package/build/services/auth.js +0 -40
- package/build/services/auth.js.map +0 -1
- package/build/services/db-class.js +0 -49
- package/build/services/db-class.js.map +0 -1
- package/build/services/db.js +0 -34
- package/build/services/db.js.map +0 -1
- package/build/services/navigation.js +0 -96
- package/build/services/navigation.js.map +0 -1
- package/build/services/reference-fields.js +0 -131
- package/build/services/reference-fields.js.map +0 -1
- package/build/services/robots.js +0 -60
- package/build/services/robots.js.map +0 -1
- package/build/services/sites.js +0 -109
- package/build/services/sites.js.map +0 -1
- package/build/services/store.js +0 -282
- package/build/services/store.js.map +0 -1
- package/build/types/api.js +0 -3
- package/build/types/api.js.map +0 -1
- package/build/types/global.js +0 -3
- package/build/types/global.js.map +0 -1
- package/build/types/navigation.js +0 -3
- package/build/types/navigation.js.map +0 -1
- package/build/types/pages.js +0 -3
- package/build/types/pages.js.map +0 -1
- package/build/types/render.js +0 -10
- package/build/types/render.js.map +0 -1
- package/build/types/sites.js +0 -3
- package/build/types/sites.js.map +0 -1
- package/build/types/templates.js +0 -3
- package/build/types/templates.js.map +0 -1
- package/build/utils/api.js +0 -161
- package/build/utils/api.js.map +0 -1
- package/build/utils/artifacts.js +0 -34
- package/build/utils/artifacts.js.map +0 -1
- package/build/utils/brush.js +0 -30
- package/build/utils/brush.js.map +0 -1
- package/build/utils/cache.js +0 -106
- package/build/utils/cache.js.map +0 -1
- package/build/utils/check-health.js +0 -68
- package/build/utils/check-health.js.map +0 -1
- package/build/utils/core-utils.js +0 -283
- package/build/utils/core-utils.js.map +0 -1
- package/build/utils/domains.js +0 -37
- package/build/utils/domains.js.map +0 -1
- package/build/utils/errors.js +0 -30
- package/build/utils/errors.js.map +0 -1
- package/build/utils/folders.js +0 -362
- package/build/utils/folders.js.map +0 -1
- package/build/utils/images.js +0 -45
- package/build/utils/images.js.map +0 -1
- package/build/utils/instance.js +0 -66
- package/build/utils/instance.js.map +0 -1
- package/build/utils/loggin.js +0 -108
- package/build/utils/loggin.js.map +0 -1
- package/build/utils/pages.js +0 -359
- package/build/utils/pages.js.map +0 -1
- package/build/utils/render.js +0 -144
- package/build/utils/render.js.map +0 -1
- package/build/utils/sites.js +0 -240
- package/build/utils/sites.js.map +0 -1
- package/build/utils/store.js +0 -193
- package/build/utils/store.js.map +0 -1
- package/exporter/adapters/gatsby/actions/clean.ts +0 -14
- package/exporter/adapters/gatsby/actions/close.ts +0 -17
- package/exporter/adapters/gatsby/actions/data.ts +0 -25
- package/exporter/adapters/gatsby/actions/healthCheck.ts +0 -10
- package/exporter/adapters/gatsby/actions/init.ts +0 -12
- package/exporter/adapters/gatsby/actions/meta.ts +0 -18
- package/exporter/adapters/gatsby/actions/prepare.ts +0 -9
- package/exporter/adapters/gatsby/actions/relocation.ts +0 -15
- package/exporter/adapters/gatsby/actions/restore.ts +0 -36
- package/exporter/adapters/gatsby/actions/ssg.ts +0 -12
- package/exporter/adapters/gatsby/actions/sync.ts +0 -71
- package/exporter/adapters/gatsby/shared/context.ts +0 -50
- package/exporter/adapters/gatsby/shared/diff-assets.ts +0 -113
- package/exporter/adapters/gatsby/shared/extract-assets.ts +0 -61
- package/exporter/adapters/gatsby/shared/gatsby-build.ts +0 -54
- package/exporter/adapters/gatsby/shared/sync-render.ts +0 -276
- package/exporter/adapters/gatsby/shared/types.ts +0 -35
- package/exporter/build-esbuild.noop +0 -42
- package/exporter/commands/prepare-assets-directory.ts +0 -33
- package/exporter/services/db-class.ts +0 -54
- package/exporter/services/db.ts +0 -32
- package/exporter/types/render.ts +0 -59
- package/exporter/utils/artifacts.ts +0 -34
- package/exporter/utils/brush.ts +0 -34
- package/exporter/utils/check-health.ts +0 -79
- package/plugins/gatsby-plugin-svgr-loader/gatsby-node.js +0 -55
- package/plugins/gatsby-plugin-svgr-loader/package.json +0 -8
- /package/{react → exporter/react}/Favicon/utils.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BuildProcessData
|
|
1
|
+
import type { BuildProcessData } from "../types/global";
|
|
2
2
|
import type {
|
|
3
3
|
GriddoListPage,
|
|
4
4
|
GriddoMultiPage,
|
|
@@ -6,24 +6,20 @@ import type {
|
|
|
6
6
|
GriddoSinglePage,
|
|
7
7
|
PageAdditionalInfo,
|
|
8
8
|
} from "../types/pages";
|
|
9
|
-
import type { RenderMode } from "../types/render";
|
|
10
9
|
|
|
11
|
-
import
|
|
10
|
+
import fs from "node:fs";
|
|
12
11
|
import path from "node:path";
|
|
13
12
|
|
|
14
13
|
import pLimit from "p-limit";
|
|
15
14
|
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
GRIDDO_REACT_APP_INSTANCE,
|
|
22
|
-
} from "../constants/envs";
|
|
23
|
-
import { get } from "../utils/api";
|
|
15
|
+
import { envs } from "../constants";
|
|
16
|
+
import { NavigationService } from "./navigation";
|
|
17
|
+
import { getReferenceFieldData } from "./reference-fields";
|
|
18
|
+
import { getAllSettings } from "./settings";
|
|
19
|
+
import { getPage } from "./sites";
|
|
24
20
|
import { updatedSiteHash } from "../utils/cache";
|
|
25
|
-
import { removeAllSiteDirsFromStore } from "../utils/core-utils";
|
|
26
|
-
import {
|
|
21
|
+
import { getConfig, removeAllSiteDirsFromStore } from "../utils/core-utils";
|
|
22
|
+
import { buildLog, listSitesLog } from "../utils/loggin";
|
|
27
23
|
import {
|
|
28
24
|
createGriddoListPages,
|
|
29
25
|
createGriddoMultiPages,
|
|
@@ -33,38 +29,26 @@ import {
|
|
|
33
29
|
} from "../utils/pages";
|
|
34
30
|
import { getSiteData, getSitesToRender, unpublishSites } from "../utils/sites";
|
|
35
31
|
import {
|
|
32
|
+
getMissingPublishedPagesInStore,
|
|
36
33
|
getZombiePagesInStore,
|
|
37
34
|
removeOrphanSites,
|
|
38
35
|
removeSitePagesFromStore,
|
|
39
36
|
saveRenderInfoInStore,
|
|
40
37
|
saveSitePagesInStore,
|
|
41
38
|
} from "../utils/store";
|
|
42
|
-
import { NavigationService } from "./navigation";
|
|
43
|
-
import { getReferenceFieldData } from "./reference-fields";
|
|
44
|
-
import { getPage } from "./sites";
|
|
45
39
|
|
|
46
|
-
const renderId = Date.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
40
|
+
const renderId = new Date().valueOf().toString();
|
|
41
|
+
const { griddoVersion, paths } = getConfig();
|
|
42
|
+
const { __cx } = paths();
|
|
43
|
+
const storeDir = path.join(__cx, "store");
|
|
51
44
|
|
|
52
45
|
/**
|
|
53
46
|
* Fetch, process and save object pages and sites data into the file system to
|
|
54
47
|
* be consumed by other services (Griddo itself, Adapters, etc.)
|
|
55
48
|
*/
|
|
56
|
-
async function createStore(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
griddoVersion: string;
|
|
60
|
-
basePath: string;
|
|
61
|
-
}) {
|
|
62
|
-
console.info(`API calls with ${GRIDDO_API_CONCURRENCY_COUNT} threads`);
|
|
63
|
-
console.info(`API URL ${GRIDDO_API_URL as string}`);
|
|
64
|
-
|
|
65
|
-
const { renderMode, domain, griddoVersion, basePath } = options;
|
|
66
|
-
const renderFromScratch = renderMode === "FROM_SCRATCH";
|
|
67
|
-
const storeDir = path.join(basePath, "store");
|
|
49
|
+
async function createStore(domain: string) {
|
|
50
|
+
console.info(`API calls with ${envs.GRIDDO_API_CONCURRENCY_COUNT} threads`);
|
|
51
|
+
console.info(`API URL ${envs.GRIDDO_API_URL as string}`);
|
|
68
52
|
|
|
69
53
|
try {
|
|
70
54
|
// Vars to save later in the report file
|
|
@@ -74,7 +58,8 @@ async function createStore(options: {
|
|
|
74
58
|
// Get sites objects to publish and unpublish from this domain
|
|
75
59
|
const { sitesToPublish, sitesToUnpublish } = await getSitesToRender(domain);
|
|
76
60
|
|
|
77
|
-
const domainHasSites =
|
|
61
|
+
const domainHasSites =
|
|
62
|
+
sitesToPublish.length > 0 || sitesToUnpublish.length > 0;
|
|
78
63
|
|
|
79
64
|
if (!domainHasSites) {
|
|
80
65
|
console.warn(`There are no sites to update in the domain ${domain}`);
|
|
@@ -84,39 +69,20 @@ async function createStore(options: {
|
|
|
84
69
|
listSitesLog("Sites to unpublish:", sitesToUnpublish);
|
|
85
70
|
|
|
86
71
|
// Send unpublished sites to API.
|
|
72
|
+
// @todo ¿mover esta llamada al final del proceso de render?
|
|
73
|
+
// Aquí también se están eliminado físicamente los archivos json del
|
|
74
|
+
// store de los sites para despublicar.
|
|
87
75
|
await unpublishSites(sitesToUnpublish);
|
|
88
76
|
|
|
89
77
|
// Eliminamos posibles sites que estén en el store pero que no deberían
|
|
90
78
|
// porque han sido cambiados de dominio. Si han sido despublicados ya se
|
|
91
79
|
// despublican bien porque entran en `sitesToUnpublish`
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const allPagesToRemoveFromBuild: Array<number> = [];
|
|
95
|
-
// let numberOfFinalActivePages: Array<number> = [];
|
|
96
|
-
|
|
97
|
-
for (const site of sitesToUnpublish) {
|
|
98
|
-
const { pagesStatus } = site;
|
|
99
|
-
|
|
100
|
-
// Añadimos a allPagesToRemoveFromBuild todas las páginas de un site
|
|
101
|
-
// para despublicar.
|
|
102
|
-
allPagesToRemoveFromBuild.push(
|
|
103
|
-
...pagesStatus.active,
|
|
104
|
-
...pagesStatus.offlinePending,
|
|
105
|
-
...pagesStatus.uploadPending,
|
|
106
|
-
...pagesStatus.deleted,
|
|
107
|
-
...pagesStatus.offline,
|
|
108
|
-
);
|
|
109
|
-
}
|
|
80
|
+
removeOrphanSites(sitesToPublish, domain);
|
|
110
81
|
|
|
82
|
+
// Solo los sites to publish...
|
|
111
83
|
for (const site of sitesToPublish) {
|
|
112
84
|
const { id: siteId, slug: siteSlug, theme, favicon, pagesStatus } = site;
|
|
113
85
|
const siteDirName = siteId.toString();
|
|
114
|
-
// numberOfFinalActivePages.push(
|
|
115
|
-
// ...pagesStatus.active,
|
|
116
|
-
// ...pagesStatus.uploadPending,
|
|
117
|
-
// );
|
|
118
|
-
|
|
119
|
-
allPagesToRemoveFromBuild.push(...pagesStatus.offlinePending, ...pagesStatus.deleted);
|
|
120
86
|
|
|
121
87
|
const {
|
|
122
88
|
siteInfo,
|
|
@@ -138,7 +104,7 @@ async function createStore(options: {
|
|
|
138
104
|
avoidSelfReferenceCanonicals,
|
|
139
105
|
avoidHrefLangXDefault,
|
|
140
106
|
avoidDebugMetas,
|
|
141
|
-
} = await
|
|
107
|
+
} = await getAllSettings();
|
|
142
108
|
|
|
143
109
|
buildProcessData[siteId] = {
|
|
144
110
|
siteHash,
|
|
@@ -152,7 +118,7 @@ async function createStore(options: {
|
|
|
152
118
|
|
|
153
119
|
site.languages = siteLangs;
|
|
154
120
|
|
|
155
|
-
const shouldUpdateSite =
|
|
121
|
+
const shouldUpdateSite = updatedSiteHash(siteId, siteHash);
|
|
156
122
|
|
|
157
123
|
const siteScript = siteInfo.siteScript;
|
|
158
124
|
|
|
@@ -163,9 +129,9 @@ async function createStore(options: {
|
|
|
163
129
|
};
|
|
164
130
|
|
|
165
131
|
const additionalInfo = {
|
|
166
|
-
baseUrl: GRIDDO_API_URL,
|
|
167
|
-
publicBaseUrl: GRIDDO_PUBLIC_API_URL,
|
|
168
|
-
instance: GRIDDO_REACT_APP_INSTANCE,
|
|
132
|
+
baseUrl: envs.GRIDDO_API_URL,
|
|
133
|
+
publicBaseUrl: envs.GRIDDO_PUBLIC_API_URL,
|
|
134
|
+
instance: envs.GRIDDO_REACT_APP_INSTANCE,
|
|
169
135
|
siteSlug,
|
|
170
136
|
theme,
|
|
171
137
|
siteMetadata,
|
|
@@ -185,10 +151,10 @@ async function createStore(options: {
|
|
|
185
151
|
siteScript,
|
|
186
152
|
};
|
|
187
153
|
|
|
188
|
-
|
|
154
|
+
buildLog(`${site.name} site`);
|
|
189
155
|
|
|
190
156
|
/// Creates the store directory for each site using the id
|
|
191
|
-
|
|
157
|
+
fs.mkdirSync(path.join(storeDir, siteDirName), {
|
|
192
158
|
recursive: true,
|
|
193
159
|
});
|
|
194
160
|
|
|
@@ -197,7 +163,10 @@ async function createStore(options: {
|
|
|
197
163
|
// -------------------------------------------------------------------------
|
|
198
164
|
// Async function that process every page for one site to use later in the
|
|
199
165
|
// `Promise.all` with pLimit.
|
|
200
|
-
const fetchSitePageAndSaveInStore = async (
|
|
166
|
+
const fetchSitePageAndSaveInStore = async (
|
|
167
|
+
siteIdName: string,
|
|
168
|
+
pageId: number,
|
|
169
|
+
) => {
|
|
201
170
|
// Here will be store every page returned by the API and processed
|
|
202
171
|
let griddoPageObjects: Array<GriddoPageObject> = [];
|
|
203
172
|
|
|
@@ -216,7 +185,9 @@ async function createStore(options: {
|
|
|
216
185
|
// SHAME: This new pageAdditionalInfo needs to be a copy because
|
|
217
186
|
// additionalInfo referenced from outside this function and
|
|
218
187
|
// its used by other pages.
|
|
219
|
-
const pageAdditionalInfo = JSON.parse(
|
|
188
|
+
const pageAdditionalInfo = JSON.parse(
|
|
189
|
+
JSON.stringify(additionalInfo),
|
|
190
|
+
) as PageAdditionalInfo;
|
|
220
191
|
|
|
221
192
|
// Updated with navigations (header & footer)
|
|
222
193
|
pageAdditionalInfo.navigations = NavService.getPageNavigations(page);
|
|
@@ -246,7 +217,8 @@ async function createStore(options: {
|
|
|
246
217
|
// - Single: just one page
|
|
247
218
|
|
|
248
219
|
// Griddo page types
|
|
249
|
-
const isStaticListPage =
|
|
220
|
+
const isStaticListPage =
|
|
221
|
+
page?.mode === "list" || page?.mode === "paginated-data";
|
|
250
222
|
const isMultiPage = !isStaticListPage && multiPageElements;
|
|
251
223
|
const isSinglePage = !isMultiPage && !isStaticListPage;
|
|
252
224
|
|
|
@@ -262,12 +234,10 @@ async function createStore(options: {
|
|
|
262
234
|
} as GriddoListPage;
|
|
263
235
|
|
|
264
236
|
// pageObjects = await createGriddoListPages({ adapter: "Gatsby" })
|
|
265
|
-
griddoPageObjects = await createGriddoListPages(
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
// Esto hace que no se pueda rastrear bien el render.
|
|
270
|
-
allPagesToRemoveFromBuild.push(page.id);
|
|
237
|
+
griddoPageObjects = await createGriddoListPages(
|
|
238
|
+
griddoListPage,
|
|
239
|
+
pageAdditionalInfo,
|
|
240
|
+
);
|
|
271
241
|
}
|
|
272
242
|
|
|
273
243
|
// >> Multi-page <<
|
|
@@ -279,12 +249,10 @@ async function createStore(options: {
|
|
|
279
249
|
griddoMultipage.multiPageElements = multiPageElements;
|
|
280
250
|
griddoMultipage.defaultLang = defaultLang;
|
|
281
251
|
|
|
282
|
-
griddoPageObjects = await createGriddoMultiPages(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
// Esto hace que no se pueda rastrear bien el render.
|
|
287
|
-
allPagesToRemoveFromBuild.push(page.id);
|
|
252
|
+
griddoPageObjects = await createGriddoMultiPages(
|
|
253
|
+
griddoMultipage,
|
|
254
|
+
pageAdditionalInfo,
|
|
255
|
+
);
|
|
288
256
|
}
|
|
289
257
|
|
|
290
258
|
// >> Single template <<
|
|
@@ -295,7 +263,9 @@ async function createStore(options: {
|
|
|
295
263
|
griddoSinglePage.template = template;
|
|
296
264
|
griddoSinglePage.defaultLang = defaultLang;
|
|
297
265
|
|
|
298
|
-
griddoPageObjects = [
|
|
266
|
+
griddoPageObjects = [
|
|
267
|
+
await createGriddoSinglePage(griddoSinglePage, pageAdditionalInfo),
|
|
268
|
+
];
|
|
299
269
|
}
|
|
300
270
|
|
|
301
271
|
// Upload only the valid pages hashes or ids of pages that has
|
|
@@ -306,26 +276,25 @@ async function createStore(options: {
|
|
|
306
276
|
}
|
|
307
277
|
|
|
308
278
|
// Save build data to store
|
|
309
|
-
|
|
279
|
+
saveSitePagesInStore(siteIdName, griddoPageObjects);
|
|
310
280
|
};
|
|
311
281
|
|
|
312
|
-
// Pages that needs to be fetched from the API and written to the
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
282
|
+
// Pages that needs to be fetched from the API and written to the
|
|
283
|
+
// store.
|
|
284
|
+
const pagesToFetchFromAPI = [
|
|
285
|
+
// These pages are news or has been updated.
|
|
286
|
+
...pagesStatus.uploadPending,
|
|
287
|
+
// You should take into account the pages that, even though they are
|
|
288
|
+
// already published and therefore should be avoided from requesting
|
|
289
|
+
// them to the API, are not in the store, probably due to a failed
|
|
290
|
+
// render. In that case, you have to request them again from the API
|
|
291
|
+
// to include them in the store.
|
|
292
|
+
...getMissingPublishedPagesInStore(siteDirName, pagesStatus.active),
|
|
293
|
+
];
|
|
325
294
|
|
|
326
295
|
// Create pages to the store. First requesting from API,
|
|
327
296
|
// transform, etc., and then writing them to disk.
|
|
328
|
-
const limit = pLimit(GRIDDO_API_CONCURRENCY_COUNT);
|
|
297
|
+
const limit = pLimit(envs.GRIDDO_API_CONCURRENCY_COUNT);
|
|
329
298
|
const pagesToStore = pagesToFetchFromAPI.map((id: number) =>
|
|
330
299
|
limit(() => fetchSitePageAndSaveInStore(siteDirName, id)),
|
|
331
300
|
);
|
|
@@ -333,13 +302,13 @@ async function createStore(options: {
|
|
|
333
302
|
await Promise.all(pagesToStore);
|
|
334
303
|
|
|
335
304
|
// @ts-expect-error Mutate pagesStatus for reading pourposes.
|
|
336
|
-
pagesStatus.zombie =
|
|
305
|
+
pagesStatus.zombie = getZombiePagesInStore(siteDirName, [
|
|
337
306
|
...pagesStatus.active,
|
|
338
307
|
...pagesStatus.uploadPending,
|
|
339
308
|
]);
|
|
340
309
|
|
|
341
310
|
// Delete pages from the store removing them from disk.
|
|
342
|
-
|
|
311
|
+
removeSitePagesFromStore(siteDirName, [
|
|
343
312
|
pagesStatus.deleted,
|
|
344
313
|
pagesStatus.offline,
|
|
345
314
|
pagesStatus.offlinePending,
|
|
@@ -367,31 +336,20 @@ async function createStore(options: {
|
|
|
367
336
|
|
|
368
337
|
if (domainHasSites) {
|
|
369
338
|
// ( 1 )
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
},
|
|
376
|
-
domain,
|
|
377
|
-
);
|
|
339
|
+
saveRenderInfoInStore({
|
|
340
|
+
buildProcessData,
|
|
341
|
+
createdPages,
|
|
342
|
+
sitesToPublish,
|
|
343
|
+
});
|
|
378
344
|
} else {
|
|
379
345
|
// ( 2 )
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
},
|
|
387
|
-
domain,
|
|
388
|
-
);
|
|
346
|
+
removeAllSiteDirsFromStore();
|
|
347
|
+
saveRenderInfoInStore({
|
|
348
|
+
buildProcessData,
|
|
349
|
+
createdPages: [],
|
|
350
|
+
sitesToPublish: [],
|
|
351
|
+
});
|
|
389
352
|
}
|
|
390
|
-
|
|
391
|
-
return {
|
|
392
|
-
pagesToCreate: createdPages,
|
|
393
|
-
pagesToDelete: allPagesToRemoveFromBuild,
|
|
394
|
-
};
|
|
395
353
|
} catch (e) {
|
|
396
354
|
const error = e as { message: string };
|
|
397
355
|
console.error(error.message);
|
package/exporter/types/api.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Core, Fields } from "@griddo/core";
|
|
2
1
|
import type { Domains, Robots, Settings } from "./global";
|
|
3
2
|
import type { APIPageObject } from "./pages";
|
|
4
3
|
import type { Site } from "./sites";
|
|
4
|
+
import type { Core, Fields } from "@griddo/core";
|
|
5
5
|
|
|
6
6
|
/** EndSiteRender Body */
|
|
7
7
|
export type EndSiteRenderBody = {
|
|
@@ -29,28 +29,29 @@ export interface ReferenceFieldBody {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/** Describes the props of the body object for the get page */
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
+
interface PageBody {
|
|
34
|
+
/** The title of the page. */
|
|
35
|
+
title?: string;
|
|
36
|
+
/** The description of the page. */
|
|
37
|
+
description?: string;
|
|
38
|
+
/** The URL of the page's image. */
|
|
39
|
+
image?: string;
|
|
40
|
+
/** The ID of the page. */
|
|
41
|
+
pageId?: number;
|
|
42
|
+
/** The ID of the page's language. */
|
|
43
|
+
languageId?: number;
|
|
44
|
+
/** The ID of the page's site. */
|
|
45
|
+
siteId?: number;
|
|
46
|
+
/** The URL of the page. */
|
|
47
|
+
url?: string;
|
|
48
|
+
/** The template of the page. */
|
|
49
|
+
template?: string | null | number;
|
|
50
|
+
/** The content of the page. */
|
|
51
|
+
content?: string;
|
|
52
|
+
/** Additional properties. */
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
}
|
|
54
55
|
|
|
55
56
|
/** Describes an item in a sitemap. */
|
|
56
57
|
interface SitemapItem {
|
|
@@ -119,8 +120,10 @@ export interface APIRequest {
|
|
|
119
120
|
attempt?: number;
|
|
120
121
|
/**
|
|
121
122
|
* Headers for the post api fetch
|
|
123
|
+
* @shame any
|
|
124
|
+
* @todo type this correctly from axios types
|
|
122
125
|
*/
|
|
123
|
-
headers?: Record<string, unknown>;
|
|
126
|
+
headers?: any; // Record<string, unknown>;
|
|
124
127
|
/* Save results in apiCache folder */
|
|
125
128
|
useApiCacheDir?: boolean;
|
|
126
129
|
}
|
package/exporter/types/global.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Core, Fields } from "@griddo/core";
|
|
2
1
|
import type { EndSiteRenderBody } from "./api";
|
|
3
2
|
import type { Site } from "./sites";
|
|
3
|
+
import type { Core, Fields } from "@griddo/core";
|
|
4
4
|
|
|
5
5
|
interface Settings {
|
|
6
6
|
apiVersion?: string;
|
|
@@ -70,7 +70,9 @@ interface RenderInfo {
|
|
|
70
70
|
sitesToPublish: Array<Site>;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
type
|
|
73
|
+
type LifeCycleSteps = Array<
|
|
74
|
+
(...args: Array<unknown>) => unknown | Promise<unknown>
|
|
75
|
+
>;
|
|
74
76
|
|
|
75
77
|
type LifeCyclesNames =
|
|
76
78
|
| "Init"
|
|
@@ -80,11 +82,12 @@ type LifeCyclesNames =
|
|
|
80
82
|
| "SSG"
|
|
81
83
|
| "Relocation"
|
|
82
84
|
| "Meta"
|
|
83
|
-
| "
|
|
85
|
+
| "Archive"
|
|
84
86
|
| "Clean"
|
|
85
87
|
| "Close"
|
|
86
88
|
| "HealthCheck"
|
|
87
|
-
| "Close"
|
|
89
|
+
| "Close"
|
|
90
|
+
| "__DEBUG__";
|
|
88
91
|
|
|
89
92
|
type PlaceholderPath =
|
|
90
93
|
| "__exports"
|
|
@@ -94,12 +97,13 @@ type PlaceholderPath =
|
|
|
94
97
|
| "__components"
|
|
95
98
|
| "__root"
|
|
96
99
|
| "__exports_dist"
|
|
97
|
-
| "
|
|
100
|
+
| "__cx_dist";
|
|
98
101
|
|
|
99
102
|
interface CXConfig {
|
|
100
103
|
proDomain: string;
|
|
101
104
|
griddoVersion: string;
|
|
102
105
|
buildReportFileName: string;
|
|
106
|
+
paths: (domain?: string) => Record<PlaceholderPath, string>;
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
interface AIEmbeddingsResponse {
|
|
@@ -112,7 +116,6 @@ interface Artifacts {
|
|
|
112
116
|
cacheables: Array<string>;
|
|
113
117
|
initials: Array<string>;
|
|
114
118
|
archivables: Array<string>;
|
|
115
|
-
restaurable: Array<string>;
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
export type {
|
|
@@ -131,5 +134,5 @@ export type {
|
|
|
131
134
|
Robot,
|
|
132
135
|
Robots,
|
|
133
136
|
Settings,
|
|
134
|
-
|
|
137
|
+
LifeCycleSteps,
|
|
135
138
|
};
|
package/exporter/types/pages.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Core, Fields } from "@griddo/core";
|
|
2
1
|
import type { SocialsResponse } from "./api";
|
|
3
2
|
import type { Settings } from "./global";
|
|
4
3
|
import type { Site } from "./sites";
|
|
4
|
+
import type { Core, Fields } from "@griddo/core";
|
|
5
5
|
|
|
6
6
|
// TODO: In @griddo/core the type Core.Page has header/footer as React-Types,
|
|
7
7
|
// but API return `number | null`.
|
|
@@ -156,7 +156,8 @@ export interface Dimensions {
|
|
|
156
156
|
dimensionsSelect?: Array<string>;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
export interface GatsbyPageTemplateProps
|
|
159
|
+
export interface GatsbyPageTemplateProps
|
|
160
|
+
extends Omit<GriddoPageObject, "context"> {
|
|
160
161
|
pageContext: GriddoPageObject["context"] & {
|
|
161
162
|
page: Core.Page;
|
|
162
163
|
};
|
package/exporter/types/sites.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Core } from "@griddo/core";
|
|
2
1
|
import type { SocialsResponse } from "./api";
|
|
3
2
|
import type { Footer, Header } from "./navigation";
|
|
3
|
+
import type { Core } from "@griddo/core";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Describes a Griddo site object from API.
|
|
@@ -43,6 +43,7 @@ export interface Site
|
|
|
43
43
|
*/
|
|
44
44
|
pages: Array<number>;
|
|
45
45
|
onlinePages: Array<number>;
|
|
46
|
+
changedPages: Array<number>;
|
|
46
47
|
published: string;
|
|
47
48
|
rendering: boolean;
|
|
48
49
|
renderingHours: number;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { GriddoAlertRegisterProps } from "@griddo/core";
|
|
2
|
+
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
import { endpoints } from "../constants";
|
|
6
|
+
|
|
7
|
+
// Esta función está duplicada de core de manera intencionada por si esta recibe
|
|
8
|
+
// cambios necesitados solo por CX.
|
|
9
|
+
// Nota: Sí estamos reutilizando el type.
|
|
10
|
+
async function insertAlert({
|
|
11
|
+
area,
|
|
12
|
+
description,
|
|
13
|
+
fullData,
|
|
14
|
+
instantNotification = false,
|
|
15
|
+
level,
|
|
16
|
+
}: Omit<GriddoAlertRegisterProps, "publicApiUrl">) {
|
|
17
|
+
const url = endpoints.ALERT;
|
|
18
|
+
const body = { level, area, description, fullData, instantNotification };
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
await axios.post(url, body, {
|
|
22
|
+
headers: { "Content-Type": "application/json", Connection: "close" },
|
|
23
|
+
});
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error("Error creating Griddo alert:", error);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { insertAlert };
|