sr-npm 1.7.491 → 1.7.493
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/backend/collectionConsts.js +1 -1
- package/backend/data.js +17 -18
- package/backend/secretsData.js +2 -10
- package/package.json +1 -1
package/backend/data.js
CHANGED
|
@@ -4,7 +4,7 @@ const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend
|
|
|
4
4
|
const { COLLECTIONS, COLLECTIONS_FIELDS,JOBS_COLLECTION_FIELDS,TEMPLATE_TYPE,TOKEN_NAME } = require('./collectionConsts');
|
|
5
5
|
const { chunkedBulkOperation, countJobsPerGivenField, fillCityLocationAndLocationAddress ,prepareToSaveArray,normalizeString} = require('./utils');
|
|
6
6
|
const { getAllPositions } = require('./queries');
|
|
7
|
-
const {
|
|
7
|
+
const { retrieveSecretVal } = require('./secretsData');
|
|
8
8
|
|
|
9
9
|
function getBrand(customField) {
|
|
10
10
|
return customField.find(field => field.fieldLabel === 'Brands')?.valueLabel;
|
|
@@ -366,26 +366,25 @@ async function markTemplateAsInternal() {
|
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
async function fillSecretManagerMirror() {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
console.log("companyId inserted into the SecretManagerMirror collection");
|
|
377
|
-
try{
|
|
378
|
-
const token = await getSmartToken();
|
|
379
|
-
await wixData.insert(COLLECTIONS.SECRET_MANAGER_MIRROR, {
|
|
380
|
-
tokenName: TOKEN_NAME.SMART_TOKEN,
|
|
381
|
-
tokenValue: token.value
|
|
382
|
-
});
|
|
383
|
-
console.log("x-smarttoken inserted into the SecretManagerMirror collection");
|
|
384
|
-
} catch (error) {
|
|
385
|
-
console.warn("Error with inserting x-smarttoken into the SecretManagerMirror collection:", error);
|
|
369
|
+
for(const tokenName of Object.values(TOKEN_NAME)){
|
|
370
|
+
try{
|
|
371
|
+
await insertSecretValToCMS(tokenName);
|
|
372
|
+
console.log("inserted ", tokenName, "into the SecretManagerMirror collection successfully");
|
|
373
|
+
} catch (error) {
|
|
374
|
+
console.warn("Error with inserting ", tokenName, "into the SecretManagerMirror collection:", error);
|
|
375
|
+
}
|
|
386
376
|
}
|
|
387
377
|
}
|
|
388
378
|
|
|
379
|
+
async function insertSecretValToCMS(tokenName) {
|
|
380
|
+
const token = await retrieveSecretVal(tokenName);
|
|
381
|
+
await wixData.save(COLLECTIONS.SECRET_MANAGER_MIRROR, {
|
|
382
|
+
tokenName: tokenName,
|
|
383
|
+
tokenValue: token.value,
|
|
384
|
+
_id: normalizeString(tokenName)
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
|
|
389
388
|
|
|
390
389
|
module.exports = {
|
|
391
390
|
syncJobsFast,
|
package/backend/secretsData.js
CHANGED
|
@@ -5,13 +5,6 @@ const { COLLECTIONS,TOKEN_NAME } = require('./collectionConsts');
|
|
|
5
5
|
|
|
6
6
|
const getSecretValue = auth.elevate(secrets.getSecretValue);
|
|
7
7
|
|
|
8
|
-
function getSmartToken() {
|
|
9
|
-
return retrieveSecretVal(TOKEN_NAME.SMART_TOKEN)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getCompanyId() {
|
|
13
|
-
return retrieveSecretVal(TOKEN_NAME.COMPANY_ID_SM)
|
|
14
|
-
}
|
|
15
8
|
|
|
16
9
|
async function retrieveSecretVal(tokenName)
|
|
17
10
|
{
|
|
@@ -50,8 +43,7 @@ function getSmartToken() {
|
|
|
50
43
|
}
|
|
51
44
|
|
|
52
45
|
module.exports = {
|
|
53
|
-
getCompanyId,
|
|
54
|
-
getSmartToken,
|
|
55
46
|
getTokenFromCMS,
|
|
56
|
-
getApiKeys
|
|
47
|
+
getApiKeys,
|
|
48
|
+
retrieveSecretVal
|
|
57
49
|
};
|