@griddo/cx 11.7.11 → 11.7.12-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.
- package/README.md +27 -226
- package/build/adapters/gatsby/actions/clean.js +10 -0
- package/build/adapters/gatsby/actions/clean.js.map +1 -0
- package/build/adapters/gatsby/actions/close.js +14 -0
- package/build/adapters/gatsby/actions/close.js.map +1 -0
- package/build/adapters/gatsby/actions/data.js +18 -0
- package/build/adapters/gatsby/actions/data.js.map +1 -0
- package/build/adapters/gatsby/actions/healthCheck.js +10 -0
- package/build/adapters/gatsby/actions/healthCheck.js.map +1 -0
- package/build/adapters/gatsby/actions/init.js +22 -0
- package/build/adapters/gatsby/actions/init.js.map +1 -0
- package/build/adapters/gatsby/actions/logs.js +9 -0
- package/build/adapters/gatsby/actions/logs.js.map +1 -0
- package/build/adapters/gatsby/actions/meta.js +13 -0
- package/build/adapters/gatsby/actions/meta.js.map +1 -0
- package/build/adapters/gatsby/actions/prepare.js +9 -0
- package/build/adapters/gatsby/actions/prepare.js.map +1 -0
- package/build/adapters/gatsby/actions/relocation.js +15 -0
- package/build/adapters/gatsby/actions/relocation.js.map +1 -0
- package/build/adapters/gatsby/actions/restore.js +26 -0
- package/build/adapters/gatsby/actions/restore.js.map +1 -0
- package/build/adapters/gatsby/actions/ssg.js +9 -0
- package/build/adapters/gatsby/actions/ssg.js.map +1 -0
- package/build/adapters/gatsby/actions/sync.js +51 -0
- package/build/adapters/gatsby/actions/sync.js.map +1 -0
- package/build/adapters/gatsby/index.js +78 -0
- package/build/adapters/gatsby/index.js.map +1 -0
- package/build/adapters/gatsby/shared/artifacts.js +20 -0
- package/build/adapters/gatsby/shared/artifacts.js.map +1 -0
- package/build/adapters/gatsby/shared/context.js +31 -0
- package/build/adapters/gatsby/shared/context.js.map +1 -0
- package/build/adapters/gatsby/shared/diff-assets.js +101 -0
- package/build/adapters/gatsby/shared/diff-assets.js.map +1 -0
- package/build/adapters/gatsby/shared/extract-assets.js +58 -0
- package/build/adapters/gatsby/shared/extract-assets.js.map +1 -0
- package/build/adapters/gatsby/shared/gatsby-build.js +55 -0
- package/build/adapters/gatsby/shared/gatsby-build.js.map +1 -0
- package/build/adapters/gatsby/shared/sync-render.js +210 -0
- package/build/adapters/gatsby/shared/sync-render.js.map +1 -0
- package/build/adapters/gatsby/shared/types.js +3 -0
- package/build/adapters/gatsby/shared/types.js.map +1 -0
- package/build/commands/end-render.js +87 -0
- package/build/commands/end-render.js.map +1 -0
- package/build/commands/prepare-assets-directory.js +30 -0
- package/build/commands/prepare-assets-directory.js.map +1 -0
- package/build/commands/prepare-domains-render.js +133 -0
- package/build/commands/prepare-domains-render.js.map +1 -0
- package/build/commands/reset-render.js +21 -0
- package/build/commands/reset-render.js.map +1 -0
- package/build/commands/start-render.js +44 -0
- package/build/commands/start-render.js.map +1 -0
- package/build/commands/upload-search-content.js +180 -0
- package/build/commands/upload-search-content.js.map +1 -0
- package/build/constants/endpoints.js +43 -0
- package/build/constants/endpoints.js.map +1 -0
- package/build/constants/envs.js +68 -0
- package/build/constants/envs.js.map +1 -0
- package/build/constants/errors.js +81 -0
- package/build/constants/errors.js.map +1 -0
- package/build/services/auth.js +40 -0
- package/build/services/auth.js.map +1 -0
- package/build/services/db-class.js +49 -0
- package/build/services/db-class.js.map +1 -0
- package/build/services/db.js +34 -0
- package/build/services/db.js.map +1 -0
- package/build/services/navigation.js +96 -0
- package/build/services/navigation.js.map +1 -0
- package/build/services/reference-fields.js +131 -0
- package/build/services/reference-fields.js.map +1 -0
- package/build/services/robots.js +60 -0
- package/build/services/robots.js.map +1 -0
- package/build/services/sites.js +110 -0
- package/build/services/sites.js.map +1 -0
- package/build/services/store.js +257 -0
- package/build/services/store.js.map +1 -0
- package/build/types/api.js +3 -0
- package/build/types/api.js.map +1 -0
- package/build/types/global.js +3 -0
- package/build/types/global.js.map +1 -0
- package/build/types/navigation.js +3 -0
- package/build/types/navigation.js.map +1 -0
- package/build/types/pages.js +3 -0
- package/build/types/pages.js.map +1 -0
- package/build/types/render.js +10 -0
- package/build/types/render.js.map +1 -0
- package/build/types/sites.js +3 -0
- package/build/types/sites.js.map +1 -0
- package/build/types/templates.js +3 -0
- package/build/types/templates.js.map +1 -0
- package/build/utils/api.js +165 -0
- package/build/utils/api.js.map +1 -0
- package/build/utils/artifacts.js +38 -0
- package/build/utils/artifacts.js.map +1 -0
- package/build/utils/brush.js +30 -0
- package/build/utils/brush.js.map +1 -0
- package/build/utils/cache.js +106 -0
- package/build/utils/cache.js.map +1 -0
- package/build/utils/check-environment-health.js +69 -0
- package/build/utils/check-environment-health.js.map +1 -0
- package/build/utils/core-utils.js +270 -0
- package/build/utils/core-utils.js.map +1 -0
- package/build/utils/domains.js +37 -0
- package/build/utils/domains.js.map +1 -0
- package/build/utils/errors.js +30 -0
- package/build/utils/errors.js.map +1 -0
- package/build/utils/folders.js +341 -0
- package/build/utils/folders.js.map +1 -0
- package/build/utils/images.js +45 -0
- package/build/utils/images.js.map +1 -0
- package/build/utils/instance.js +66 -0
- package/build/utils/instance.js.map +1 -0
- package/build/utils/loggin.js +119 -0
- package/build/utils/loggin.js.map +1 -0
- package/build/utils/npm-deps/find-up-simple.js +75 -0
- package/build/utils/npm-deps/find-up-simple.js.map +1 -0
- package/build/utils/npm-deps/pkg-dir.js +20 -0
- package/build/utils/npm-deps/pkg-dir.js.map +1 -0
- package/build/utils/npm-deps/xml-parser.js +49 -0
- package/build/utils/npm-deps/xml-parser.js.map +1 -0
- package/build/utils/pages.js +359 -0
- package/build/utils/pages.js.map +1 -0
- package/build/utils/render.js +168 -0
- package/build/utils/render.js.map +1 -0
- package/build/utils/sitemaps.js +110 -0
- package/build/utils/sitemaps.js.map +1 -0
- package/build/utils/sites.js +105 -0
- package/build/utils/sites.js.map +1 -0
- package/build/utils/store.js +193 -0
- package/build/utils/store.js.map +1 -0
- package/exporter/adapters/gatsby/actions/clean.ts +14 -0
- package/exporter/adapters/gatsby/actions/close.ts +20 -0
- package/exporter/adapters/gatsby/actions/data.ts +25 -0
- package/exporter/adapters/gatsby/actions/healthCheck.ts +10 -0
- package/exporter/adapters/gatsby/actions/init.ts +26 -0
- package/exporter/adapters/gatsby/actions/logs.ts +10 -0
- package/exporter/adapters/gatsby/actions/meta.ts +16 -0
- package/exporter/adapters/gatsby/actions/prepare.ts +9 -0
- package/exporter/adapters/gatsby/actions/relocation.ts +15 -0
- package/exporter/adapters/gatsby/actions/restore.ts +36 -0
- package/exporter/adapters/gatsby/actions/ssg.ts +12 -0
- package/exporter/adapters/gatsby/actions/sync.ts +71 -0
- package/exporter/adapters/gatsby/index.ts +73 -153
- package/exporter/adapters/gatsby/shared/artifacts.ts +16 -0
- package/exporter/adapters/gatsby/shared/context.ts +50 -0
- package/exporter/adapters/gatsby/shared/diff-assets.ts +113 -0
- package/exporter/adapters/gatsby/shared/extract-assets.ts +61 -0
- package/exporter/adapters/gatsby/shared/gatsby-build.ts +58 -0
- package/exporter/adapters/gatsby/shared/sync-render.ts +276 -0
- package/exporter/adapters/gatsby/shared/types.ts +35 -0
- package/exporter/build-esbuild.noop +42 -0
- package/exporter/build.sh +4 -38
- package/exporter/commands/end-render.ts +72 -70
- package/exporter/commands/prepare-assets-directory.ts +30 -0
- package/exporter/commands/prepare-domains-render.ts +143 -31
- package/exporter/commands/reset-render.ts +10 -3
- package/exporter/commands/start-render.ts +22 -45
- package/exporter/commands/upload-search-content.ts +194 -21
- package/exporter/constants/endpoints.ts +2 -1
- package/exporter/constants/envs.ts +57 -55
- package/exporter/{errors/errors-data.ts → constants/errors.ts} +24 -14
- package/exporter/services/auth.ts +7 -6
- package/exporter/services/db-class.ts +54 -0
- package/exporter/services/db.ts +32 -0
- package/exporter/services/navigation.ts +4 -10
- package/exporter/services/reference-fields.ts +9 -24
- package/exporter/services/robots.ts +9 -16
- package/exporter/services/sites.ts +36 -24
- package/exporter/services/store.ts +107 -96
- package/exporter/types/api.ts +27 -28
- package/exporter/types/global.ts +8 -11
- package/exporter/types/navigation.ts +1 -1
- package/exporter/types/pages.ts +2 -3
- package/exporter/types/render.ts +59 -0
- package/exporter/types/sites.ts +1 -2
- package/exporter/utils/api.ts +55 -75
- package/exporter/utils/artifacts.ts +38 -0
- package/exporter/utils/brush.ts +34 -0
- package/exporter/utils/cache.ts +37 -62
- package/exporter/utils/check-environment-health.ts +80 -0
- package/exporter/utils/core-utils.ts +133 -272
- package/exporter/utils/domains.ts +10 -7
- package/exporter/{errors/index.ts → utils/errors.ts} +10 -9
- package/exporter/utils/folders.ts +163 -98
- package/exporter/utils/images.ts +1 -6
- package/exporter/utils/instance.ts +9 -13
- package/exporter/utils/loggin.ts +44 -91
- package/exporter/utils/npm-deps/find-up-simple.ts +100 -0
- package/exporter/utils/npm-deps/pkg-dir.ts +17 -0
- package/exporter/utils/npm-deps/xml-parser.ts +57 -0
- package/exporter/utils/pages.ts +23 -88
- package/exporter/utils/render.ts +180 -48
- package/exporter/utils/sitemaps.ts +129 -0
- package/exporter/utils/sites.ts +19 -197
- package/exporter/utils/store.ts +87 -180
- package/gatsby-browser.tsx +41 -58
- package/gatsby-config.ts +10 -17
- package/gatsby-node.ts +17 -78
- package/gatsby-ssr.tsx +2 -1
- package/package.json +35 -86
- package/plugins/gatsby-plugin-svgr-loader/gatsby-node.js +55 -0
- package/plugins/gatsby-plugin-svgr-loader/package.json +8 -0
- package/react/DynamicScript/index.tsx +33 -0
- package/{exporter/react → react}/Favicon/index.tsx +1 -7
- package/{exporter/react → react}/GriddoIntegrations/index.tsx +16 -22
- package/{exporter/react → react}/GriddoIntegrations/utils.ts +21 -9
- package/{build/react/index.d.ts → react/index.tsx} +1 -0
- package/src/components/Head.tsx +13 -46
- package/src/components/template.tsx +8 -30
- package/src/gatsby-node-utils.ts +73 -2
- package/src/html.tsx +2 -11
- package/src/types.ts +5 -5
- package/tsconfig.commands.json +36 -0
- package/tsconfig.exporter.json +19 -0
- package/tsconfig.json +5 -3
- package/build/adapters/gatsby/index.d.ts +0 -4
- package/build/adapters/gatsby/utils.d.ts +0 -22
- package/build/artifacts/index.d.ts +0 -6
- package/build/commands/end-render.d.ts +0 -2
- package/build/commands/move-assets.d.ts +0 -1
- package/build/commands/prepare-domains-render.d.ts +0 -1
- package/build/commands/reset-render.d.ts +0 -2
- package/build/commands/start-render.d.ts +0 -2
- package/build/commands/upload-search-content.d.ts +0 -2
- package/build/constants/endpoints.d.ts +0 -19
- package/build/constants/envs.d.ts +0 -37
- package/build/constants/index.d.ts +0 -57
- package/build/end-render.js +0 -74
- package/build/end-render.js.map +0 -7
- package/build/errors/errors-data.d.ts +0 -22
- package/build/errors/index.d.ts +0 -15
- package/build/index.d.ts +0 -29
- package/build/index.js +0 -73
- package/build/index.js.map +0 -7
- package/build/prepare-domains-render.js +0 -73
- package/build/prepare-domains-render.js.map +0 -7
- package/build/react/Favicon/index.d.ts +0 -5
- package/build/react/Favicon/utils.d.ts +0 -9
- package/build/react/GriddoIntegrations/index.d.ts +0 -20
- package/build/react/GriddoIntegrations/utils.d.ts +0 -26
- package/build/react/index.js +0 -3
- package/build/registers/api.d.ts +0 -9
- package/build/registers/gatsby.d.ts +0 -9
- package/build/registers/index.d.ts +0 -3
- package/build/reset-render.js +0 -74
- package/build/reset-render.js.map +0 -7
- package/build/services/auth.d.ts +0 -10
- package/build/services/domains.d.ts +0 -6
- package/build/services/navigation.d.ts +0 -50
- package/build/services/reference-fields.d.ts +0 -20
- package/build/services/register.d.ts +0 -36
- package/build/services/robots.d.ts +0 -19
- package/build/services/settings.d.ts +0 -4
- package/build/services/sites.d.ts +0 -29
- package/build/services/store.d.ts +0 -6
- package/build/start-render.js +0 -100
- package/build/start-render.js.map +0 -7
- package/build/types/api.d.ts +0 -142
- package/build/types/global.d.ts +0 -84
- package/build/types/navigation.d.ts +0 -28
- package/build/types/pages.d.ts +0 -144
- package/build/types/sites.d.ts +0 -57
- package/build/types/templates.d.ts +0 -8
- package/build/upload-search-content.js +0 -74
- package/build/upload-search-content.js.map +0 -7
- package/build/utils/alerts.d.ts +0 -3
- package/build/utils/api.d.ts +0 -23
- package/build/utils/cache.d.ts +0 -35
- package/build/utils/core-utils.d.ts +0 -107
- package/build/utils/create-build-data.d.ts +0 -8
- package/build/utils/domains.d.ts +0 -13
- package/build/utils/folders.d.ts +0 -53
- package/build/utils/health-checks.d.ts +0 -7
- package/build/utils/images.d.ts +0 -16
- package/build/utils/instance.d.ts +0 -21
- package/build/utils/loggin.d.ts +0 -51
- package/build/utils/pages.d.ts +0 -34
- package/build/utils/render.d.ts +0 -13
- package/build/utils/searches.d.ts +0 -15
- package/build/utils/sites.d.ts +0 -31
- package/build/utils/store.d.ts +0 -81
- package/cx.config.d.ts +0 -5
- package/cx.config.js +0 -36
- package/exporter/adapters/gatsby/utils.ts +0 -161
- package/exporter/artifacts/README.md +0 -34
- package/exporter/artifacts/index.ts +0 -33
- package/exporter/commands/move-assets.ts +0 -11
- package/exporter/constants/index.ts +0 -129
- package/exporter/index.ts +0 -82
- package/exporter/react/index.tsx +0 -11
- package/exporter/registers/api.ts +0 -14
- package/exporter/registers/gatsby.ts +0 -14
- package/exporter/registers/index.ts +0 -4
- package/exporter/services/domains.ts +0 -16
- package/exporter/services/register.ts +0 -113
- package/exporter/services/settings.ts +0 -17
- package/exporter/utils/alerts.ts +0 -29
- package/exporter/utils/create-build-data.ts +0 -17
- package/exporter/utils/health-checks.ts +0 -64
- package/exporter/utils/searches.ts +0 -156
- package/src/README.md +0 -7
- package/start-render.js +0 -7
- /package/{exporter/react → react}/Favicon/utils.ts +0 -0
package/exporter/types/api.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { Core, Fields } from "@griddo/core";
|
|
1
2
|
import type { Domains, Robots, Settings } from "./global";
|
|
2
3
|
import type { APIPageObject } from "./pages";
|
|
3
4
|
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,32 +29,31 @@ 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
|
-
|
|
54
|
-
}
|
|
32
|
+
// interface PageBody {
|
|
33
|
+
// /** The title of the page. */
|
|
34
|
+
// title?: string;
|
|
35
|
+
// /** The description of the page. */
|
|
36
|
+
// description?: string;
|
|
37
|
+
// /** The URL of the page's image. */
|
|
38
|
+
// image?: string;
|
|
39
|
+
// /** The ID of the page. */
|
|
40
|
+
// pageId?: number;
|
|
41
|
+
// /** The ID of the page's language. */
|
|
42
|
+
// languageId?: number;
|
|
43
|
+
// /** The ID of the page's site. */
|
|
44
|
+
// siteId?: number;
|
|
45
|
+
// /** The URL of the page. */
|
|
46
|
+
// url?: string;
|
|
47
|
+
// /** The template of the page. */
|
|
48
|
+
// template?: string | null | number;
|
|
49
|
+
// /** The content of the page. */
|
|
50
|
+
// content?: string;
|
|
51
|
+
// /** Additional properties. */
|
|
52
|
+
// [key: string]: unknown;
|
|
53
|
+
// }
|
|
55
54
|
|
|
56
55
|
/** Describes an item in a sitemap. */
|
|
57
|
-
interface SitemapItem {
|
|
56
|
+
export interface SitemapItem {
|
|
58
57
|
/** The URL of the page. */
|
|
59
58
|
loc: string;
|
|
60
59
|
/** The date the page was last modified. */
|
|
@@ -120,12 +119,12 @@ export interface APIRequest {
|
|
|
120
119
|
attempt?: number;
|
|
121
120
|
/**
|
|
122
121
|
* Headers for the post api fetch
|
|
123
|
-
* @shame any
|
|
124
|
-
* @todo type this correctly from axios types
|
|
125
122
|
*/
|
|
126
|
-
headers?:
|
|
123
|
+
headers?: Record<string, unknown>;
|
|
127
124
|
/* Save results in apiCache folder */
|
|
128
125
|
useApiCacheDir?: boolean;
|
|
126
|
+
/* Save log in the cx log file */
|
|
127
|
+
logToFile?: boolean;
|
|
129
128
|
}
|
|
130
129
|
|
|
131
130
|
/** Type with the POST request properties. */
|
package/exporter/types/global.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { Core, Fields } from "@griddo/core";
|
|
1
2
|
import type { EndSiteRenderBody } from "./api";
|
|
2
3
|
import type { Site } from "./sites";
|
|
3
|
-
import type { Core, Fields } from "@griddo/core";
|
|
4
4
|
|
|
5
5
|
interface Settings {
|
|
6
6
|
apiVersion?: string;
|
|
@@ -70,9 +70,7 @@ interface RenderInfo {
|
|
|
70
70
|
sitesToPublish: Array<Site>;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
type
|
|
74
|
-
(...args: Array<unknown>) => unknown | Promise<unknown>
|
|
75
|
-
>;
|
|
73
|
+
type LifeCycleAction = (...args: Array<unknown>) => void | Promise<void>;
|
|
76
74
|
|
|
77
75
|
type LifeCyclesNames =
|
|
78
76
|
| "Init"
|
|
@@ -82,12 +80,11 @@ type LifeCyclesNames =
|
|
|
82
80
|
| "SSG"
|
|
83
81
|
| "Relocation"
|
|
84
82
|
| "Meta"
|
|
85
|
-
| "
|
|
83
|
+
| "Sync"
|
|
86
84
|
| "Clean"
|
|
87
85
|
| "Close"
|
|
88
86
|
| "HealthCheck"
|
|
89
|
-
| "Close"
|
|
90
|
-
| "__DEBUG__";
|
|
87
|
+
| "Close";
|
|
91
88
|
|
|
92
89
|
type PlaceholderPath =
|
|
93
90
|
| "__exports"
|
|
@@ -97,13 +94,12 @@ type PlaceholderPath =
|
|
|
97
94
|
| "__components"
|
|
98
95
|
| "__root"
|
|
99
96
|
| "__exports_dist"
|
|
100
|
-
| "
|
|
97
|
+
| "__sites";
|
|
101
98
|
|
|
102
99
|
interface CXConfig {
|
|
103
|
-
|
|
100
|
+
proDomainPrefix: string;
|
|
104
101
|
griddoVersion: string;
|
|
105
102
|
buildReportFileName: string;
|
|
106
|
-
paths: (domain?: string) => Record<PlaceholderPath, string>;
|
|
107
103
|
}
|
|
108
104
|
|
|
109
105
|
interface AIEmbeddingsResponse {
|
|
@@ -116,6 +112,7 @@ interface Artifacts {
|
|
|
116
112
|
cacheables: Array<string>;
|
|
117
113
|
initials: Array<string>;
|
|
118
114
|
archivables: Array<string>;
|
|
115
|
+
restaurable: Array<string>;
|
|
119
116
|
}
|
|
120
117
|
|
|
121
118
|
export type {
|
|
@@ -134,5 +131,5 @@ export type {
|
|
|
134
131
|
Robot,
|
|
135
132
|
Robots,
|
|
136
133
|
Settings,
|
|
137
|
-
|
|
134
|
+
LifeCycleAction,
|
|
138
135
|
};
|
package/exporter/types/pages.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { Core, Fields } from "@griddo/core";
|
|
1
2
|
import type { SocialsResponse } from "./api";
|
|
2
3
|
import type { Settings } from "./global";
|
|
3
4
|
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,8 +156,7 @@ export interface Dimensions {
|
|
|
156
156
|
dimensionsSelect?: Array<string>;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
export interface GatsbyPageTemplateProps
|
|
160
|
-
extends Omit<GriddoPageObject, "context"> {
|
|
159
|
+
export interface GatsbyPageTemplateProps extends Omit<GriddoPageObject, "context"> {
|
|
161
160
|
pageContext: GriddoPageObject["context"] & {
|
|
162
161
|
page: Core.Page;
|
|
163
162
|
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { RenderInfo } from "./global";
|
|
2
|
+
|
|
3
|
+
const RENDER_MODE = {
|
|
4
|
+
FROM_SCRATCH: "FROM_SCRATCH",
|
|
5
|
+
INCREMENTAL: "INCREMENTAL",
|
|
6
|
+
IDLE: "IDLE",
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
type RenderMode = (typeof RENDER_MODE)[keyof typeof RENDER_MODE];
|
|
10
|
+
|
|
11
|
+
export interface RenderModeTuple {
|
|
12
|
+
renderMode: RenderMode;
|
|
13
|
+
reason?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type DomainLike = string;
|
|
17
|
+
|
|
18
|
+
type RenderDB = {
|
|
19
|
+
proDomainPrefix: string;
|
|
20
|
+
griddoVersion: string;
|
|
21
|
+
buildReportFileName: string;
|
|
22
|
+
sortedDomains: Array<DomainLike>;
|
|
23
|
+
paths: {
|
|
24
|
+
root: string;
|
|
25
|
+
cx: string;
|
|
26
|
+
ssg: string;
|
|
27
|
+
cxCache: string;
|
|
28
|
+
components: string;
|
|
29
|
+
exportsDir: string;
|
|
30
|
+
};
|
|
31
|
+
domains: {
|
|
32
|
+
[key: DomainLike]: {
|
|
33
|
+
renderMode?: RenderMode;
|
|
34
|
+
shouldBeRendered?: boolean;
|
|
35
|
+
isRendering?: boolean;
|
|
36
|
+
renderInfo?: RenderInfo;
|
|
37
|
+
renderModeReason?: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
interface Report {
|
|
43
|
+
authControl:
|
|
44
|
+
| {
|
|
45
|
+
Authorization: string;
|
|
46
|
+
"Cache-Control": string;
|
|
47
|
+
lang?: string | undefined;
|
|
48
|
+
}
|
|
49
|
+
| undefined;
|
|
50
|
+
sites: Array<{
|
|
51
|
+
siteId: number;
|
|
52
|
+
publishHashes: Array<string>;
|
|
53
|
+
siteHash: string | null;
|
|
54
|
+
unpublishHashes: Array<string>;
|
|
55
|
+
publishPagesIds: Array<number>;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { RENDER_MODE, type RenderDB, type RenderMode, type Report };
|
package/exporter/types/sites.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { Core } from "@griddo/core";
|
|
1
2
|
import type { SocialsResponse } from "./api";
|
|
2
3
|
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,7 +43,6 @@ export interface Site
|
|
|
43
43
|
*/
|
|
44
44
|
pages: Array<number>;
|
|
45
45
|
onlinePages: Array<number>;
|
|
46
|
-
changedPages: Array<number>;
|
|
47
46
|
published: string;
|
|
48
47
|
rendering: boolean;
|
|
49
48
|
renderingHours: number;
|
package/exporter/utils/api.ts
CHANGED
|
@@ -6,25 +6,16 @@ import type {
|
|
|
6
6
|
PutAPI,
|
|
7
7
|
ShowApiErrorOptions,
|
|
8
8
|
} from "../types/api";
|
|
9
|
-
import type { AxiosError, Method } from "axios";
|
|
10
|
-
|
|
11
|
-
import axios from "axios";
|
|
12
|
-
import dotenv from "dotenv";
|
|
13
|
-
import kleur from "kleur";
|
|
14
9
|
|
|
10
|
+
import { AuthService } from "../services/auth";
|
|
11
|
+
import { brush } from "./brush";
|
|
15
12
|
import { saveCache, searchCacheData } from "./cache";
|
|
16
13
|
import { delay, getSafeSiteId, msToSec } from "./core-utils";
|
|
17
|
-
import {
|
|
18
|
-
import { envs } from "../constants";
|
|
19
|
-
import { apiRegister } from "../registers";
|
|
20
|
-
import { AuthService } from "../services/auth";
|
|
21
|
-
|
|
22
|
-
dotenv.config();
|
|
14
|
+
import { appendLogToFile } from "./loggin";
|
|
23
15
|
|
|
24
16
|
// Envs
|
|
25
|
-
const {
|
|
26
|
-
|
|
27
|
-
} = process;
|
|
17
|
+
const { env } = process;
|
|
18
|
+
const { RETRY_WAIT_SECONDS = "4", RETRY_ATTEMPTS = "4" } = env;
|
|
28
19
|
|
|
29
20
|
/**
|
|
30
21
|
* Make a GET/PUT/POST request to the Griddo API.
|
|
@@ -41,7 +32,7 @@ const {
|
|
|
41
32
|
*/
|
|
42
33
|
async function requestAPI<T extends APIResponses>(
|
|
43
34
|
props: APIRequest,
|
|
44
|
-
method:
|
|
35
|
+
method: string,
|
|
45
36
|
appendToLog = "",
|
|
46
37
|
): Promise<T> {
|
|
47
38
|
const {
|
|
@@ -51,21 +42,24 @@ async function requestAPI<T extends APIResponses>(
|
|
|
51
42
|
attempt = 1,
|
|
52
43
|
headers,
|
|
53
44
|
useApiCacheDir = true,
|
|
45
|
+
logToFile = true,
|
|
54
46
|
} = props;
|
|
55
47
|
const cacheOptions = { endpoint, body, headers, cacheKey };
|
|
56
48
|
|
|
57
49
|
// Cache
|
|
58
50
|
if (cacheKey && useApiCacheDir) {
|
|
59
51
|
const start = new Date();
|
|
60
|
-
const cacheData = searchCacheData<T>(cacheOptions);
|
|
52
|
+
const cacheData = await searchCacheData<T>(cacheOptions);
|
|
61
53
|
|
|
62
54
|
if (cacheData) {
|
|
63
55
|
const siteId = getSafeSiteId(cacheData);
|
|
64
56
|
const siteIdMsg = siteId ? `site: ${siteId}` : "";
|
|
65
|
-
const duration = msToSec(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
const duration = msToSec(Date.now() - start.getTime());
|
|
58
|
+
if (logToFile) {
|
|
59
|
+
await appendLogToFile(
|
|
60
|
+
`${method} (cache) ${siteIdMsg} ${endpoint} - ${duration}s ${appendToLog}`,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
69
63
|
return cacheData;
|
|
70
64
|
}
|
|
71
65
|
}
|
|
@@ -73,47 +67,50 @@ async function requestAPI<T extends APIResponses>(
|
|
|
73
67
|
// Network
|
|
74
68
|
try {
|
|
75
69
|
const start = new Date();
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
70
|
+
|
|
71
|
+
// Prepare fetch options
|
|
72
|
+
const fetchOptions: RequestInit = {
|
|
73
|
+
method: method.toUpperCase(),
|
|
74
|
+
headers: Object.assign({}, headers, AuthService.headers) as Record<string, string>,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// Add body for non-GET requests
|
|
78
|
+
if (method.toLowerCase() !== "get" && body) {
|
|
79
|
+
fetchOptions.body = JSON.stringify(body);
|
|
80
|
+
if (!fetchOptions.headers) fetchOptions.headers = {};
|
|
81
|
+
(fetchOptions.headers as Record<string, string>)["Content-Type"] = "application/json";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const response = await fetch(endpoint, fetchOptions);
|
|
85
|
+
|
|
86
|
+
// Handle non-2xx responses
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
if (response.status === 404) {
|
|
89
|
+
// @ts-expect-error page maybe will be 404
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const data: T = await response.json();
|
|
85
97
|
|
|
86
98
|
const siteId = getSafeSiteId(data);
|
|
87
99
|
const siteIdMsg = siteId ? `site: ${siteId}` : "";
|
|
88
|
-
const duration = msToSec(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (useApiCacheDir) {
|
|
94
|
-
saveCache(cacheOptions, data);
|
|
100
|
+
const duration = msToSec(Date.now() - start.getTime());
|
|
101
|
+
if (logToFile) {
|
|
102
|
+
await appendLogToFile(
|
|
103
|
+
`${method} (fetch) ${siteIdMsg} ${endpoint} - ${duration}s ${appendToLog}`,
|
|
104
|
+
);
|
|
95
105
|
}
|
|
96
106
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const responseSize = Number.parseInt(responseHeaders["content-length"]);
|
|
100
|
-
if (responseSize > envs.GRIDDO_API_MAX_RESPONSE_SIZE) {
|
|
101
|
-
apiRegister.insert("API_RESPONSE_TOO_BIG", {
|
|
102
|
-
endpoint,
|
|
103
|
-
responseSize,
|
|
104
|
-
duration,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
+
if (useApiCacheDir) {
|
|
108
|
+
await saveCache(cacheOptions, data);
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
return data;
|
|
110
112
|
} catch (e) {
|
|
111
|
-
const error = e as
|
|
112
|
-
|
|
113
|
-
if (error.response?.status === 404) {
|
|
114
|
-
// @ts-expect-error page maybe will be 404
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
113
|
+
const error = e as Error;
|
|
117
114
|
|
|
118
115
|
if (attempt > parseInt(RETRY_ATTEMPTS)) {
|
|
119
116
|
console.log(`
|
|
@@ -122,7 +119,7 @@ Max attempts ${RETRY_ATTEMPTS} reached
|
|
|
122
119
|
- ${method.toUpperCase()} ${endpoint}
|
|
123
120
|
- BODY: ${JSON.stringify(body)}
|
|
124
121
|
- HEADERS: ${JSON.stringify(headers)}
|
|
125
|
-
-
|
|
122
|
+
- ERROR: ${error.message}
|
|
126
123
|
--------------------------------------
|
|
127
124
|
`);
|
|
128
125
|
|
|
@@ -130,12 +127,6 @@ Max attempts ${RETRY_ATTEMPTS} reached
|
|
|
130
127
|
process.exit(1);
|
|
131
128
|
}
|
|
132
129
|
|
|
133
|
-
if (!error.response) {
|
|
134
|
-
console.log("Unknown error occurred");
|
|
135
|
-
console.log(JSON.stringify(error, null, 2));
|
|
136
|
-
process.exit(1);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
130
|
showApiError(error, {
|
|
140
131
|
callInfo: { endpoint, body },
|
|
141
132
|
});
|
|
@@ -188,9 +179,7 @@ async function postApi<T extends APIResponses>(props: PostAPI) {
|
|
|
188
179
|
const { endpoint, body, headers } = props;
|
|
189
180
|
const referenceFieldBodyParams =
|
|
190
181
|
endpoint.endsWith("/distributor") &&
|
|
191
|
-
`# ReferenceField body: ${JSON.stringify(body)} lang: ${JSON.stringify(
|
|
192
|
-
headers?.lang,
|
|
193
|
-
)}`;
|
|
182
|
+
`# ReferenceField body: ${JSON.stringify(body)} lang: ${JSON.stringify(headers?.lang)}`;
|
|
194
183
|
|
|
195
184
|
return requestAPI<T>(props, "post", referenceFieldBodyParams || "");
|
|
196
185
|
}
|
|
@@ -198,40 +187,31 @@ async function postApi<T extends APIResponses>(props: PostAPI) {
|
|
|
198
187
|
/**
|
|
199
188
|
* Shows an API error through the terminal.
|
|
200
189
|
*/
|
|
201
|
-
function showApiError(error:
|
|
202
|
-
const {
|
|
190
|
+
function showApiError(error: Error, options: ShowApiErrorOptions) {
|
|
191
|
+
const { message, stack } = error;
|
|
203
192
|
const { callInfo } = options;
|
|
204
|
-
const { status, statusText, data } = response || {};
|
|
205
193
|
const callInfoArray = [];
|
|
206
194
|
|
|
207
195
|
for (const item of Object.keys(callInfo) as Array<keyof typeof callInfo>) {
|
|
208
196
|
callInfoArray.push(
|
|
209
197
|
`${item}: ${
|
|
210
|
-
typeof callInfo[item] === "object"
|
|
211
|
-
? JSON.stringify(callInfo[item])
|
|
212
|
-
: callInfo[item]
|
|
198
|
+
typeof callInfo[item] === "object" ? JSON.stringify(callInfo[item]) : callInfo[item]
|
|
213
199
|
}`,
|
|
214
200
|
);
|
|
215
201
|
}
|
|
216
202
|
|
|
217
203
|
// Compose the errors output
|
|
218
204
|
const callInfoStr = callInfoArray.join("\n");
|
|
219
|
-
const apiResponseStr = response
|
|
220
|
-
? `Code: ${status} - ${statusText}\nResponse: ${JSON.stringify(data)}`
|
|
221
|
-
: "";
|
|
222
205
|
const errorDetailsStr = `${message}\n${stack}`;
|
|
223
206
|
|
|
224
207
|
// Print the error
|
|
225
208
|
console.warn(
|
|
226
|
-
|
|
209
|
+
brush.red(`
|
|
227
210
|
=============
|
|
228
211
|
|
|
229
212
|
{ Call info }
|
|
230
213
|
${callInfoStr}
|
|
231
214
|
|
|
232
|
-
{ API Response }
|
|
233
|
-
${apiResponseStr}
|
|
234
|
-
|
|
235
215
|
{ Error details }
|
|
236
216
|
${errorDetailsStr}
|
|
237
217
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Artifacts } from "../types/global";
|
|
2
|
+
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
import { getRenderPathsFromDB } from "./render";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns the artifacts of CX.
|
|
9
|
+
*/
|
|
10
|
+
async function getCxArtifacts(domain: string): Promise<Artifacts> {
|
|
11
|
+
const { __exports, __cache, __root, __ssg } = await getRenderPathsFromDB({ domain });
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
initials: [
|
|
15
|
+
__exports, // `<root>/exports/<domain>`
|
|
16
|
+
__cache, // `<root>/.cx-cache/<domain>`
|
|
17
|
+
path.join(__exports, "logs"),
|
|
18
|
+
path.join(__root, "store"),
|
|
19
|
+
path.join(__root, "apiCache"),
|
|
20
|
+
],
|
|
21
|
+
disposables: [
|
|
22
|
+
path.join(__root, "store"),
|
|
23
|
+
path.join(__root, "apiCache"),
|
|
24
|
+
path.join(__root, "dist"),
|
|
25
|
+
path.join(__root, "dist-restored"),
|
|
26
|
+
path.join(__root, "assets"),
|
|
27
|
+
path.join(__root, "render-detail-log.txt"),
|
|
28
|
+
path.join(__ssg, "domains.json"),
|
|
29
|
+
path.join(__ssg, "domains.txt"),
|
|
30
|
+
path.join(__ssg, "render-metadata.json"),
|
|
31
|
+
],
|
|
32
|
+
cacheables: [],
|
|
33
|
+
archivables: ["dist", "assets"],
|
|
34
|
+
restaurable: ["dist"],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { getCxArtifacts };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Brush adds color to a string|number, it does not print it!
|
|
3
|
+
// Its simple, no log, no chains, just color in a string|number
|
|
4
|
+
// usage:
|
|
5
|
+
// console.log(brush.green("sucess!"))
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
const RESET = "\x1b[0m";
|
|
9
|
+
const CODES = {
|
|
10
|
+
black: "\x1b[30m",
|
|
11
|
+
red: "\x1b[31m",
|
|
12
|
+
green: "\x1b[32m",
|
|
13
|
+
yellow: "\x1b[33m",
|
|
14
|
+
blue: "\x1b[34m",
|
|
15
|
+
magenta: "\x1b[35m",
|
|
16
|
+
cyan: "\x1b[36m",
|
|
17
|
+
white: "\x1b[37m",
|
|
18
|
+
gray: "\x1b[90m",
|
|
19
|
+
bold: "\x1b[1m",
|
|
20
|
+
dim: "\x1b[2m",
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
23
|
+
type ColorFunction = (text: string | number) => string;
|
|
24
|
+
type ColorName = keyof typeof CODES;
|
|
25
|
+
type Brush = Record<ColorName, ColorFunction>;
|
|
26
|
+
|
|
27
|
+
const brush = {} as Brush;
|
|
28
|
+
|
|
29
|
+
for (const color in CODES) {
|
|
30
|
+
const key = color as ColorName;
|
|
31
|
+
brush[key] = (text: string | number) => `${CODES[key]}${text}${RESET}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { brush };
|