mod-build 4.0.94-beta.1 → 4.0.94-beta.11
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/CHANGELOG.md +1 -1
- package/package.json +1 -1
- package/src/scripts/globals.js +0 -3
- package/tasks/serve.js +0 -3
- package/tasks/templates.js +15 -8
- package/tasks/grab-default-quad-link-values.js +0 -47
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/scripts/globals.js
CHANGED
|
@@ -4,9 +4,6 @@ import { showUtilityProviders } from './default/show-utility-providers.js';
|
|
|
4
4
|
|
|
5
5
|
function globalFunctions(config) {
|
|
6
6
|
window.gtm_container_ID = config.gtm_container_ID;
|
|
7
|
-
if (config.defaultQuadlinkData) {
|
|
8
|
-
window.defaultQuadlinkData = config.defaultQuadlinkData;
|
|
9
|
-
}
|
|
10
7
|
const { domain, pathSubdirectory } = config;
|
|
11
8
|
if (domain) {
|
|
12
9
|
if (domain.includes('/')) {
|
package/tasks/serve.js
CHANGED
|
@@ -5,7 +5,6 @@ import grabSharedComponents from './grab-shared-components.js';
|
|
|
5
5
|
import grabSharedScripts from './grab-shared-scripts.js';
|
|
6
6
|
import grabCdn from './grab-cdn.js';
|
|
7
7
|
import grabB2BData from './grab-b2b-data.js';
|
|
8
|
-
import grabDefaultQuadLinkValues from './grab-default-quad-link-values.js';
|
|
9
8
|
import getDefaultTradeQuestions from './get-default-trade-questions.js';
|
|
10
9
|
import grabFormHelpers from './grab-form-helpers.js';
|
|
11
10
|
import grabJSDoc from './grab-jsdoc.js';
|
|
@@ -18,7 +17,6 @@ export async function startModBuild(config) {
|
|
|
18
17
|
createStylelintFile();
|
|
19
18
|
await grabGlobalFonts(config);
|
|
20
19
|
await grabB2BData(config);
|
|
21
|
-
await grabDefaultQuadLinkValues(config);
|
|
22
20
|
await grabCdn(config);
|
|
23
21
|
await getDefaultTradeQuestions(config);
|
|
24
22
|
await Promise.all([
|
|
@@ -30,5 +28,4 @@ export async function startModBuild(config) {
|
|
|
30
28
|
await grabSharedScripts(config);
|
|
31
29
|
});
|
|
32
30
|
await updateConfig(config);
|
|
33
|
-
|
|
34
31
|
}
|
package/tasks/templates.js
CHANGED
|
@@ -202,23 +202,30 @@ const getConsentCaptureLanguage = async function(config, tempConfig) {
|
|
|
202
202
|
let consentCaptureObject = await resp.json(),
|
|
203
203
|
service = config.service ? config.service.toLowerCase().replace('_', ' ') : config.primary_trade.toLowerCase().replace('_', ' ');
|
|
204
204
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
throw new Error(`${brandedSiteIdentifiersResp.status}: Error while fetching branded-site-identifiers.json`);
|
|
208
|
-
}
|
|
205
|
+
if (config.isBranded) {
|
|
206
|
+
let brandedSiteIdentifiersData = {};
|
|
209
207
|
|
|
210
|
-
|
|
208
|
+
if (!config.brandedSiteIdentifiers?.publicKey) {
|
|
209
|
+
const brandedSiteIdentifiersResp = await fetch(`https://${defaultSettings.nodeEnv}/quote/resources/mod-site/data/branded-site-identifiers.json`);
|
|
210
|
+
if (brandedSiteIdentifiersResp.status !== 200) {
|
|
211
|
+
throw new Error(`${brandedSiteIdentifiersResp.status}: Error while fetching branded-site-identifiers.json`);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
brandedSiteIdentifiersData = await brandedSiteIdentifiersResp.json();
|
|
215
|
+
}
|
|
211
216
|
|
|
212
|
-
if (config.isBranded) {
|
|
213
217
|
const websiteName = config.website_name.toLowerCase(),
|
|
214
218
|
companyName = config.company_name,
|
|
215
219
|
apiDomain = 'https://form-service-hs.qnst.com/';
|
|
216
220
|
|
|
217
221
|
let apiUrl = '';
|
|
222
|
+
let publicKey = config.brandedSiteIdentifiers?.publicKey || null;
|
|
218
223
|
|
|
219
|
-
if (brandedSiteIdentifiersData[websiteName] && (brandedSiteIdentifiersData[websiteName].publicKey || brandedSiteIdentifiersData[websiteName][companyName] && brandedSiteIdentifiersData[websiteName][companyName].publicKey)) {
|
|
220
|
-
|
|
224
|
+
if (!publicKey && brandedSiteIdentifiersData[websiteName] && (brandedSiteIdentifiersData[websiteName].publicKey || brandedSiteIdentifiersData[websiteName][companyName] && brandedSiteIdentifiersData[websiteName][companyName].publicKey)) {
|
|
225
|
+
publicKey = brandedSiteIdentifiersData[websiteName][companyName] ? brandedSiteIdentifiersData[websiteName][companyName].publicKey : brandedSiteIdentifiersData[websiteName].publicKey;
|
|
226
|
+
}
|
|
221
227
|
|
|
228
|
+
if (publicKey) {
|
|
222
229
|
apiUrl = `${apiDomain}utils/vendor-display-name?publicKey=${encodeURIComponent(publicKey)}`;
|
|
223
230
|
const getBrandedDisplayName = await fetch(apiUrl);
|
|
224
231
|
if (getBrandedDisplayName.status !== 200) {
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { defaultSettings } from '../src/data/config.js';
|
|
2
|
-
import { createRetryFetch } from '../src/scripts/retry-fetch.js';
|
|
3
|
-
|
|
4
|
-
const fetchWithRetry = createRetryFetch();
|
|
5
|
-
const QUAD_LINK_VALUES_PATH = '/quote/resources/mod-site/src/data/default-quad-link-values.json';
|
|
6
|
-
|
|
7
|
-
function getDomainLookupKey(config) {
|
|
8
|
-
const domain = config.website_name || config.domain;
|
|
9
|
-
return domain ? domain.toLowerCase() : null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default async function grabDefaultQuadLinkValues(config) {
|
|
13
|
-
const { nodeEnv } = defaultSettings;
|
|
14
|
-
|
|
15
|
-
if (!nodeEnv) {
|
|
16
|
-
throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const lookupKey = getDomainLookupKey(config);
|
|
20
|
-
if (!lookupKey) {
|
|
21
|
-
console.warn('grab-default-quad-link-values: config.domain or config.website_name is required');
|
|
22
|
-
config.defaultQuadlinkData = {};
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const cachebuster = Math.round(Date.now() / 1000);
|
|
27
|
-
const url = `https://${nodeEnv}${QUAD_LINK_VALUES_PATH}?cb=${cachebuster}`;
|
|
28
|
-
|
|
29
|
-
console.log(`Fetching default quad link values from ${url}`);
|
|
30
|
-
|
|
31
|
-
const resp = await fetchWithRetry(url);
|
|
32
|
-
if (resp.status !== 200) {
|
|
33
|
-
throw new Error(`${resp.status}: Error while fetching ${url}`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const quadLinkValuesByDomain = await resp.json();
|
|
37
|
-
const defaultQuadlinkData = quadLinkValuesByDomain[lookupKey];
|
|
38
|
-
|
|
39
|
-
if (!defaultQuadlinkData) {
|
|
40
|
-
console.warn(`grab-default-quad-link-values: no entry found for domain "${lookupKey}"`);
|
|
41
|
-
config.defaultQuadlinkData = {};
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
config.defaultQuadlinkData = defaultQuadlinkData;
|
|
46
|
-
console.log(`grab-default-quad-link-values: loaded data for "${lookupKey}"`);
|
|
47
|
-
}
|