@griddo/cx 10.6.3 → 10.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/build/adapters/gatsby/index.d.ts +1 -1
- package/build/build-complete.js +69 -30
- package/build/constants/endpoints.d.ts +18 -0
- package/build/constants/envs.d.ts +33 -0
- package/build/constants/index.d.ts +53 -0
- package/build/index.d.ts +4 -3
- package/build/index.js +90 -49
- package/build/reset-render.js +69 -30
- package/build/run-start-render.js +90 -49
- package/build/services/settings.d.ts +3 -22
- package/build/services/sites.d.ts +34 -36
- package/build/start-render.js +90 -49
- package/build/types/global.d.ts +1 -1
- package/build/upload-search-content.js +70 -31
- package/build/utils/core-utils.d.ts +9 -60
- package/build/utils/domains.d.ts +5 -1
- package/build/utils/loggin.d.ts +49 -0
- package/build/utils/render.d.ts +11 -0
- package/cx.config.js +3 -4
- package/exporter/adapters/gatsby/index.ts +95 -257
- package/exporter/adapters/gatsby/utils.ts +11 -10
- package/exporter/browser/index.ts +4 -4
- package/exporter/constants/endpoints.ts +42 -0
- package/exporter/constants/envs.ts +86 -0
- package/exporter/constants/index.ts +120 -0
- package/exporter/errors/index.ts +2 -2
- package/exporter/index.ts +11 -10
- package/exporter/react/GriddoIntegrations/index.tsx +3 -3
- package/exporter/{build-complete.ts → scripts/build-complete.ts} +4 -4
- package/exporter/{reset-render.ts → scripts/reset-render.ts} +3 -3
- package/exporter/scripts/start-render.ts +26 -0
- package/exporter/{upload-search-content.ts → scripts/upload-search-content.ts} +3 -3
- package/exporter/services/auth.ts +7 -5
- package/exporter/services/distributors.ts +12 -18
- package/exporter/services/domains.ts +2 -12
- package/exporter/services/navigation.ts +10 -8
- package/exporter/services/robots.ts +2 -6
- package/exporter/services/settings.ts +7 -44
- package/exporter/services/sites.ts +115 -159
- package/exporter/services/store.ts +24 -29
- package/exporter/types/api.ts +1 -1
- package/exporter/types/global.ts +1 -0
- package/exporter/utils/api.ts +11 -10
- package/exporter/utils/core-utils.ts +49 -180
- package/exporter/utils/domains.ts +21 -3
- package/exporter/utils/folders.ts +3 -3
- package/exporter/utils/health-checks.ts +4 -4
- package/exporter/utils/instance.ts +3 -3
- package/exporter/utils/integrations.ts +12 -12
- package/exporter/utils/loggin.ts +159 -0
- package/exporter/utils/pages.ts +15 -15
- package/exporter/utils/render.ts +49 -0
- package/exporter/utils/searches.ts +5 -5
- package/exporter/utils/sites.ts +42 -48
- package/exporter/utils/store.ts +9 -9
- package/gatsby-browser.tsx +46 -48
- package/gatsby-config.ts +5 -5
- package/gatsby-node.ts +7 -7
- package/package.json +21 -26
- package/src/components/Head.tsx +1 -1
- package/src/gatsby-node-utils.ts +1 -1
- package/src/utils.ts +1 -1
- package/exporter/start-render.ts +0 -18
- /package/build/{build-complete.d.ts → scripts/build-complete.d.ts} +0 -0
- /package/build/{move-assets.d.ts → scripts/move-assets.d.ts} +0 -0
- /package/build/{reset-render.d.ts → scripts/reset-render.d.ts} +0 -0
- /package/build/{run-start-render.d.ts → scripts/run-start-render.d.ts} +0 -0
- /package/build/{start-render.d.ts → scripts/start-render.d.ts} +0 -0
- /package/build/{upload-search-content.d.ts → scripts/upload-search-content.d.ts} +0 -0
- /package/exporter/{move-assets.ts → scripts/move-assets.ts} +0 -0
- /package/exporter/{run-start-render.ts → scripts/run-start-render.ts} +0 -0
|
@@ -1,51 +1,14 @@
|
|
|
1
1
|
import type { Settings } from "../types/global";
|
|
2
2
|
|
|
3
|
+
import { endpoints } from "../constants";
|
|
3
4
|
import { get, post } from "../utils/api";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
class SettingsService {
|
|
9
|
-
baseURL?: string;
|
|
10
|
-
settings: Settings;
|
|
11
|
-
ENDPOINTS: { settings: string; resetRender: string };
|
|
12
|
-
|
|
13
|
-
constructor() {
|
|
14
|
-
this.baseURL = process.env.API_URL;
|
|
15
|
-
this.settings = {
|
|
16
|
-
cloudinaryName: "",
|
|
17
|
-
useMetaTitle: false,
|
|
18
|
-
useMetaKeywords: false,
|
|
19
|
-
showBasicMetaRobots: false,
|
|
20
|
-
avoidHrefLangsOnCanonicals: false,
|
|
21
|
-
avoidSelfReferenceCanonicals: false,
|
|
22
|
-
avoidHrefLangXDefault: false,
|
|
23
|
-
avoidDebugMetas: false,
|
|
24
|
-
};
|
|
25
|
-
this.ENDPOINTS = {
|
|
26
|
-
settings: `${this.baseURL}/settings`,
|
|
27
|
-
resetRender: `${this.baseURL}/debug/reset-render`,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Get settings for a full domain render.
|
|
33
|
-
*/
|
|
34
|
-
async getAll() {
|
|
35
|
-
const { settings } = this.ENDPOINTS;
|
|
36
|
-
const response = await get<Settings>({ endpoint: settings });
|
|
37
|
-
this.settings = response;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* TODO: JSDoc
|
|
42
|
-
*/
|
|
43
|
-
async resetRender() {
|
|
44
|
-
const { resetRender } = this.ENDPOINTS;
|
|
45
|
-
await post({ endpoint: resetRender });
|
|
46
|
-
}
|
|
6
|
+
async function getAllSettings() {
|
|
7
|
+
return await get<Settings>({ endpoint: endpoints.SETTINGS });
|
|
47
8
|
}
|
|
48
9
|
|
|
49
|
-
|
|
10
|
+
async function resetRender() {
|
|
11
|
+
await post({ endpoint: endpoints.RESET_RENDER });
|
|
12
|
+
}
|
|
50
13
|
|
|
51
|
-
export {
|
|
14
|
+
export { getAllSettings, resetRender };
|
|
@@ -13,170 +13,126 @@ import type {
|
|
|
13
13
|
import type { Site } from "../types/sites";
|
|
14
14
|
import type { Core } from "@griddo/core";
|
|
15
15
|
|
|
16
|
-
import
|
|
17
|
-
|
|
16
|
+
import { endpoints } from "../constants";
|
|
18
17
|
import { get, post } from "../utils/api";
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Get a list of site objects.
|
|
21
|
+
*/
|
|
22
|
+
async function getAllSites() {
|
|
23
|
+
return await get<AllSitesReponse>({ endpoint: endpoints.GET_ALL });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fetch a page object from API.
|
|
28
|
+
*/
|
|
29
|
+
async function getPage(id: number, cacheKey: string) {
|
|
30
|
+
return await get<PageResponse>({
|
|
31
|
+
endpoint: `${endpoints.GET_PAGE}/${id}`,
|
|
32
|
+
cacheKey,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get site info
|
|
38
|
+
*/
|
|
39
|
+
async function getSiteInfo(id: number, cacheKey = "") {
|
|
40
|
+
const [prefix, suffix] = endpoints.INFO;
|
|
41
|
+
|
|
42
|
+
return await get<Site>({
|
|
43
|
+
endpoint: `${prefix}${id}${suffix}`,
|
|
44
|
+
cacheKey,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* TODO: JSDoc
|
|
50
|
+
*/
|
|
51
|
+
async function getSiteLanguages(id: number, cacheKey = "") {
|
|
52
|
+
const [prefix, suffix] = endpoints.LANGUAGES;
|
|
53
|
+
|
|
54
|
+
return await get<LanguagesResponse>({
|
|
55
|
+
endpoint: `${prefix}${id}${suffix}`,
|
|
56
|
+
cacheKey,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* TODO: JSDoc
|
|
62
|
+
*/
|
|
63
|
+
async function startSiteRender(id: number) {
|
|
64
|
+
const [prefix, suffix] = endpoints.BUILD_START;
|
|
65
|
+
|
|
66
|
+
return await get<StartPageRenderResponse>({
|
|
67
|
+
endpoint: `${prefix}${id}${suffix}`,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Send the end signal to API for a render site.
|
|
73
|
+
*/
|
|
74
|
+
async function endSiteRender(id: number, body: EndSiteRenderBody) {
|
|
75
|
+
const [prefix, suffix] = endpoints.BUILD_END;
|
|
76
|
+
|
|
77
|
+
return await post<EndPageInfoResponse>({
|
|
78
|
+
endpoint: `${prefix}${id}${suffix}`,
|
|
79
|
+
body,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* TODO: JSDoc
|
|
85
|
+
*/
|
|
86
|
+
async function getDistributorData(
|
|
87
|
+
page: Core.Page,
|
|
88
|
+
body: DistributorBody,
|
|
89
|
+
cacheKey: string,
|
|
90
|
+
dataSiteId?: number,
|
|
91
|
+
dataLangID?: number
|
|
92
|
+
) {
|
|
93
|
+
const [prefix, suffix] = endpoints.GET_REFERENCE_FIELD_DATA;
|
|
94
|
+
const site = dataSiteId || page.site;
|
|
95
|
+
const lang = dataLangID || page.language;
|
|
96
|
+
|
|
97
|
+
return await post<DistributorResponse>({
|
|
98
|
+
endpoint: `${prefix}${site}${suffix}`,
|
|
99
|
+
body,
|
|
100
|
+
headers: { lang },
|
|
101
|
+
cacheKey,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
39
104
|
|
|
40
105
|
/**
|
|
41
106
|
* TODO: JSDoc
|
|
42
107
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Fetch a page object from API.
|
|
53
|
-
*/
|
|
54
|
-
static async getPage(id: number, cacheKey: string) {
|
|
55
|
-
const {
|
|
56
|
-
GET_PAGE: [prefix, suffix],
|
|
57
|
-
} = ENDPOINTS;
|
|
58
|
-
const response = await get<PageResponse>({
|
|
59
|
-
endpoint: `${prefix}${id}${suffix}`,
|
|
60
|
-
cacheKey,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
return response;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Get site info
|
|
68
|
-
*/
|
|
69
|
-
static async getInfo(id: number, cacheKey = "") {
|
|
70
|
-
const {
|
|
71
|
-
INFO: [prefix, suffix],
|
|
72
|
-
} = ENDPOINTS;
|
|
73
|
-
const response = await get<Site>({
|
|
74
|
-
endpoint: `${prefix}${id}${suffix}`,
|
|
75
|
-
cacheKey,
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
return response;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* TODO: JSDoc
|
|
83
|
-
*/
|
|
84
|
-
static async getLanguages(id: number, cacheKey = "") {
|
|
85
|
-
const {
|
|
86
|
-
LANGUAGES: [prefix, suffix],
|
|
87
|
-
} = ENDPOINTS;
|
|
88
|
-
const response = await get<LanguagesResponse>({
|
|
89
|
-
endpoint: `${prefix}${id}${suffix}`,
|
|
90
|
-
cacheKey,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
return response;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* TODO: JSDoc
|
|
98
|
-
*/
|
|
99
|
-
static async startSiteRender(id: number) {
|
|
100
|
-
const {
|
|
101
|
-
BUILD_START: [prefix, suffix],
|
|
102
|
-
} = ENDPOINTS;
|
|
103
|
-
const response = await get<StartPageRenderResponse>({
|
|
104
|
-
endpoint: `${prefix}${id}${suffix}`,
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
return response;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Send the end signal to API for a render site.
|
|
112
|
-
*/
|
|
113
|
-
static async endSiteRender(id: number, body: EndSiteRenderBody) {
|
|
114
|
-
const {
|
|
115
|
-
BUILD_END: [prefix, suffix],
|
|
116
|
-
} = ENDPOINTS;
|
|
117
|
-
const response = await post<EndPageInfoResponse>({
|
|
118
|
-
endpoint: `${prefix}${id}${suffix}`,
|
|
119
|
-
body,
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
return response;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* TODO: JSDoc
|
|
127
|
-
*/
|
|
128
|
-
static async getDistributorData(
|
|
129
|
-
page: Core.Page,
|
|
130
|
-
body: DistributorBody,
|
|
131
|
-
cacheKey: string,
|
|
132
|
-
dataSiteId?: number,
|
|
133
|
-
dataLangID?: number
|
|
134
|
-
) {
|
|
135
|
-
const {
|
|
136
|
-
GET_DISTRIBUTOR_DATA: [prefix, suffix],
|
|
137
|
-
} = ENDPOINTS;
|
|
138
|
-
|
|
139
|
-
const site = dataSiteId || page.site;
|
|
140
|
-
const lang = dataLangID || page.language;
|
|
141
|
-
|
|
142
|
-
const response = await post<DistributorResponse>({
|
|
143
|
-
endpoint: `${prefix}${site}${suffix}`,
|
|
144
|
-
body,
|
|
145
|
-
headers: { lang },
|
|
146
|
-
cacheKey,
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
return response;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* TODO: JSDoc
|
|
154
|
-
*/
|
|
155
|
-
static async getSitemap(id: number) {
|
|
156
|
-
const {
|
|
157
|
-
GET_SITEMAP: [prefix, suffix],
|
|
158
|
-
} = ENDPOINTS;
|
|
159
|
-
const response = await get<SitemapAPIResponse>({
|
|
160
|
-
endpoint: `${prefix}${id}${suffix}`,
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
return response;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* TODO: JSDoc
|
|
168
|
-
*/
|
|
169
|
-
static async getSocials(id: number, cacheKey = "") {
|
|
170
|
-
const {
|
|
171
|
-
SOCIALS: [prefix, suffix],
|
|
172
|
-
} = ENDPOINTS;
|
|
173
|
-
const response = await get<SocialsResponse>({
|
|
174
|
-
endpoint: `${prefix}${id}${suffix}`,
|
|
175
|
-
cacheKey,
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
return response;
|
|
179
|
-
}
|
|
108
|
+
async function getSitemap(id: number) {
|
|
109
|
+
const [prefix, suffix] = endpoints.GET_SITEMAP;
|
|
110
|
+
|
|
111
|
+
return await get<SitemapAPIResponse>({
|
|
112
|
+
endpoint: `${prefix}${id}${suffix}`,
|
|
113
|
+
});
|
|
180
114
|
}
|
|
181
115
|
|
|
182
|
-
|
|
116
|
+
/**
|
|
117
|
+
* TODO: JSDoc
|
|
118
|
+
*/
|
|
119
|
+
async function getSiteSocials(id: number, cacheKey = "") {
|
|
120
|
+
const [prefix, suffix] = endpoints.SOCIALS;
|
|
121
|
+
|
|
122
|
+
return await get<SocialsResponse>({
|
|
123
|
+
endpoint: `${prefix}${id}${suffix}`,
|
|
124
|
+
cacheKey,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export {
|
|
129
|
+
endSiteRender,
|
|
130
|
+
getAllSites,
|
|
131
|
+
getSiteLanguages,
|
|
132
|
+
getPage,
|
|
133
|
+
getDistributorData,
|
|
134
|
+
getSiteInfo,
|
|
135
|
+
getSitemap,
|
|
136
|
+
getSiteSocials,
|
|
137
|
+
startSiteRender,
|
|
138
|
+
};
|
|
@@ -14,10 +14,12 @@ import pLimit from "p-limit";
|
|
|
14
14
|
|
|
15
15
|
import { DistributorService } from "./distributors";
|
|
16
16
|
import { NavigationService } from "./navigation";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
17
|
+
import { getAllSettings } from "./settings";
|
|
18
|
+
import { getPage } from "./sites";
|
|
19
|
+
import { envs } from "../constants";
|
|
19
20
|
import { updatedSiteHash } from "../utils/cache";
|
|
20
|
-
import { getConfig,
|
|
21
|
+
import { getConfig, siteList } from "../utils/core-utils";
|
|
22
|
+
import { infoLog, verboseLog } from "../utils/loggin";
|
|
21
23
|
import {
|
|
22
24
|
createGriddoListPages,
|
|
23
25
|
createGriddoMultiPages,
|
|
@@ -38,12 +40,7 @@ const config = getConfig();
|
|
|
38
40
|
|
|
39
41
|
dotenv.config();
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
/* prettier-ignore */ const API_URL = process.env.API_URL as string;
|
|
43
|
-
/* prettier-ignore */ const REACT_APP_INSTANCE = process.env.GRIDDO_REACT_APP_INSTANCE || process.env.REACT_APP_INSTANCE;
|
|
44
|
-
/* prettier-ignore */ const API_CONCURRENCY_COUNT = parseInt(process.env.GRIDDO_API_CONCURRENCY_COUNT || "10");
|
|
45
|
-
/* prettier-ignore */ const PUBLIC_API_URL = process.env.PUBLIC_API_URL as string;
|
|
46
|
-
/* prettier-ignore */ const RENDER_ID = new Date().valueOf().toString();
|
|
43
|
+
const RENDER_ID = new Date().valueOf().toString();
|
|
47
44
|
|
|
48
45
|
/**
|
|
49
46
|
* Fetch, process and save object pages and sites data into the file system to
|
|
@@ -52,7 +49,7 @@ dotenv.config();
|
|
|
52
49
|
async function createStore(domain: string) {
|
|
53
50
|
createStoreDir();
|
|
54
51
|
|
|
55
|
-
console.info(`API calls with ${
|
|
52
|
+
console.info(`API calls with ${envs.GRIDDO_API_CONCURRENCY_COUNT} threads`);
|
|
56
53
|
|
|
57
54
|
const { __cx } = config.paths();
|
|
58
55
|
const { griddoVersion } = config;
|
|
@@ -66,8 +63,6 @@ async function createStore(domain: string) {
|
|
|
66
63
|
// Get sites objects to publish and unpublish.
|
|
67
64
|
const { sitesToPublish, sitesToUnpublish } = await checkSites(domain);
|
|
68
65
|
|
|
69
|
-
await SettingsService.getAll();
|
|
70
|
-
|
|
71
66
|
// If no activity in sites, exit
|
|
72
67
|
if (!(sitesToPublish.length || sitesToUnpublish.length)) {
|
|
73
68
|
console.warn("There are no sites to update");
|
|
@@ -112,7 +107,7 @@ async function createStore(domain: string) {
|
|
|
112
107
|
avoidSelfReferenceCanonicals,
|
|
113
108
|
avoidHrefLangXDefault,
|
|
114
109
|
avoidDebugMetas,
|
|
115
|
-
} =
|
|
110
|
+
} = await getAllSettings();
|
|
116
111
|
|
|
117
112
|
buildProcessData[siteId] = {
|
|
118
113
|
siteHash,
|
|
@@ -136,9 +131,9 @@ async function createStore(domain: string) {
|
|
|
136
131
|
};
|
|
137
132
|
|
|
138
133
|
const additionalInfo = {
|
|
139
|
-
baseUrl:
|
|
140
|
-
publicBaseUrl:
|
|
141
|
-
instance:
|
|
134
|
+
baseUrl: envs.GRIDDO_API_URL,
|
|
135
|
+
publicBaseUrl: envs.GRIDDO_PUBLIC_API_URL,
|
|
136
|
+
instance: envs.GRIDDO_REACT_APP_INSTANCE,
|
|
142
137
|
siteSlug,
|
|
143
138
|
theme,
|
|
144
139
|
siteMetadata,
|
|
@@ -158,7 +153,7 @@ async function createStore(domain: string) {
|
|
|
158
153
|
siteScript,
|
|
159
154
|
};
|
|
160
155
|
|
|
161
|
-
|
|
156
|
+
infoLog(`${site.name} site`);
|
|
162
157
|
|
|
163
158
|
// -------------------------------------------------------------------------
|
|
164
159
|
// Pages loop promise creation
|
|
@@ -170,7 +165,7 @@ async function createStore(domain: string) {
|
|
|
170
165
|
let griddoPageObjects: Array<GriddoPageObject> = [];
|
|
171
166
|
|
|
172
167
|
// Get page data
|
|
173
|
-
const page = await
|
|
168
|
+
const page = await getPage(pageId, shouldUpdateSite);
|
|
174
169
|
|
|
175
170
|
// Probably a 404
|
|
176
171
|
if (!page) return;
|
|
@@ -183,7 +178,7 @@ async function createStore(domain: string) {
|
|
|
183
178
|
// additionalInfo referenced from outside this function and
|
|
184
179
|
// its used by other pages.
|
|
185
180
|
const pageAdditionalInfo = JSON.parse(
|
|
186
|
-
JSON.stringify(additionalInfo)
|
|
181
|
+
JSON.stringify(additionalInfo),
|
|
187
182
|
) as PageAdditionalInfo;
|
|
188
183
|
|
|
189
184
|
// Updated with navigations (header & footer)
|
|
@@ -231,7 +226,7 @@ async function createStore(domain: string) {
|
|
|
231
226
|
// pageObjects = await createGriddoListPages({ adapter: "Gatsby" })
|
|
232
227
|
griddoPageObjects = await createGriddoListPages(
|
|
233
228
|
griddoListPage,
|
|
234
|
-
pageAdditionalInfo
|
|
229
|
+
pageAdditionalInfo,
|
|
235
230
|
);
|
|
236
231
|
}
|
|
237
232
|
|
|
@@ -246,7 +241,7 @@ async function createStore(domain: string) {
|
|
|
246
241
|
|
|
247
242
|
griddoPageObjects = await createGriddoMultiPages(
|
|
248
243
|
griddoMultipage,
|
|
249
|
-
pageAdditionalInfo
|
|
244
|
+
pageAdditionalInfo,
|
|
250
245
|
);
|
|
251
246
|
}
|
|
252
247
|
|
|
@@ -289,17 +284,17 @@ async function createStore(domain: string) {
|
|
|
289
284
|
|
|
290
285
|
// Debug time
|
|
291
286
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
287
|
+
verboseLog(`Store site: ${site.name}`);
|
|
288
|
+
verboseLog(`${validPagesIds.length} valid pages from API`);
|
|
289
|
+
verboseLog(`changed ${changedPages.length} pages from API`);
|
|
290
|
+
verboseLog(`deleted ${pagesToDeleteFromStore.length} pages from store`);
|
|
291
|
+
verboseLog(`missing ${pagesMissingInStore.length} pages in store`);
|
|
292
|
+
verboseLog(`write ${pagesToWriteToStore.length} pages to store`);
|
|
298
293
|
|
|
299
294
|
// Create (async)
|
|
300
|
-
const limit = pLimit(
|
|
295
|
+
const limit = pLimit(envs.GRIDDO_API_CONCURRENCY_COUNT);
|
|
301
296
|
const pagesToStore = pagesToWriteToStore.map((id: number) =>
|
|
302
|
-
limit(() => fetchPageAndSaveInStore(id))
|
|
297
|
+
limit(() => fetchPageAndSaveInStore(id)),
|
|
303
298
|
);
|
|
304
299
|
|
|
305
300
|
await Promise.all(pagesToStore);
|
package/exporter/types/api.ts
CHANGED
|
@@ -149,7 +149,7 @@ export interface EndPageInfoResponse {
|
|
|
149
149
|
message: string;
|
|
150
150
|
}
|
|
151
151
|
/** Response type for the embedding answer in the ai search feature */
|
|
152
|
-
export type PostEmbeddingsResponse = string
|
|
152
|
+
export type PostEmbeddingsResponse = string;
|
|
153
153
|
|
|
154
154
|
/** Describes a response type for GET all sites */
|
|
155
155
|
export type AllSitesReponse = Array<Site>;
|
package/exporter/types/global.ts
CHANGED
package/exporter/utils/api.ts
CHANGED
|
@@ -13,7 +13,8 @@ import chalk from "chalk";
|
|
|
13
13
|
import dotenv from "dotenv";
|
|
14
14
|
|
|
15
15
|
import { saveCache, searchCacheData } from "./cache";
|
|
16
|
-
import { delay, getSafeSiteId,
|
|
16
|
+
import { delay, getSafeSiteId, msToSec } from "./core-utils";
|
|
17
|
+
import { infoLog } from "./loggin";
|
|
17
18
|
import { AuthService } from "../services/auth";
|
|
18
19
|
|
|
19
20
|
dotenv.config();
|
|
@@ -39,7 +40,7 @@ const {
|
|
|
39
40
|
async function requestAPI<T extends APIResponses>(
|
|
40
41
|
props: APIRequest,
|
|
41
42
|
method: Method,
|
|
42
|
-
appendToLog = ""
|
|
43
|
+
appendToLog = "",
|
|
43
44
|
): Promise<T> {
|
|
44
45
|
const { endpoint, body, cacheKey = "", attempt = 1, headers } = props;
|
|
45
46
|
const cacheOptions = { endpoint, body, headers, cacheKey };
|
|
@@ -53,8 +54,8 @@ async function requestAPI<T extends APIResponses>(
|
|
|
53
54
|
const siteId = getSafeSiteId(cacheData);
|
|
54
55
|
const siteIdMsg = siteId ? `site: ${siteId}` : "";
|
|
55
56
|
const duration = msToSec(new Date().getTime() - start.getTime());
|
|
56
|
-
|
|
57
|
-
`${method} (cache) ${siteIdMsg} ${endpoint} - ${duration}s ${appendToLog}
|
|
57
|
+
infoLog(
|
|
58
|
+
`${method} (cache) ${siteIdMsg} ${endpoint} - ${duration}s ${appendToLog}`,
|
|
58
59
|
);
|
|
59
60
|
return cacheData;
|
|
60
61
|
}
|
|
@@ -73,8 +74,8 @@ async function requestAPI<T extends APIResponses>(
|
|
|
73
74
|
const siteId = getSafeSiteId(data);
|
|
74
75
|
const siteIdMsg = siteId ? `site: ${siteId}` : "";
|
|
75
76
|
const duration = msToSec(new Date().getTime() - start.getTime());
|
|
76
|
-
|
|
77
|
-
`${method} (fetch) ${siteIdMsg} ${endpoint} - ${duration}s ${appendToLog}
|
|
77
|
+
infoLog(
|
|
78
|
+
`${method} (fetch) ${siteIdMsg} ${endpoint} - ${duration}s ${appendToLog}`,
|
|
78
79
|
);
|
|
79
80
|
|
|
80
81
|
saveCache(cacheOptions, data);
|
|
@@ -123,7 +124,7 @@ Max attempts ${RETRY_ATTEMPTS} reached
|
|
|
123
124
|
attempt: attempt + 1,
|
|
124
125
|
},
|
|
125
126
|
method,
|
|
126
|
-
appendToLog
|
|
127
|
+
appendToLog,
|
|
127
128
|
);
|
|
128
129
|
}
|
|
129
130
|
}
|
|
@@ -159,7 +160,7 @@ async function postApi<T extends APIResponses>(props: PostAPI) {
|
|
|
159
160
|
const distributorBodyParams =
|
|
160
161
|
endpoint.endsWith("/distributor") &&
|
|
161
162
|
`# Distributor body: ${JSON.stringify(body)} lang: ${JSON.stringify(
|
|
162
|
-
headers?.lang
|
|
163
|
+
headers?.lang,
|
|
163
164
|
)}`;
|
|
164
165
|
|
|
165
166
|
return await requestAPI<T>(props, "post", distributorBodyParams || "");
|
|
@@ -180,7 +181,7 @@ function showApiError(error: AxiosError, options: ShowApiErrorOptions) {
|
|
|
180
181
|
typeof callInfo[item] === "object"
|
|
181
182
|
? JSON.stringify(callInfo[item])
|
|
182
183
|
: callInfo[item]
|
|
183
|
-
}
|
|
184
|
+
}`,
|
|
184
185
|
);
|
|
185
186
|
}
|
|
186
187
|
|
|
@@ -206,7 +207,7 @@ ${apiResponseStr}
|
|
|
206
207
|
${errorDetailsStr}
|
|
207
208
|
|
|
208
209
|
=============
|
|
209
|
-
`)
|
|
210
|
+
`),
|
|
210
211
|
);
|
|
211
212
|
}
|
|
212
213
|
|