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.
@@ -91,8 +91,8 @@ const COLLECTIONS_FIELDS = {
91
91
 
92
92
  const TOKEN_NAME = {
93
93
  COMPANY_ID: 'companyId',
94
- COMPANY_ID_SM: 'companyID',
95
94
  SMART_TOKEN: 'x-smarttoken',
95
+ DESIRED_BRAND: 'desiredBrand',
96
96
  }
97
97
 
98
98
 
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 { getCompanyId, getSmartToken } = require('./secretsData');
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
- console.log("Getting the company ID ");
370
- const companyId = await getCompanyId();
371
- console.log("companyId is : ", companyId);
372
- await wixData.insert(COLLECTIONS.SECRET_MANAGER_MIRROR, {
373
- tokenName: TOKEN_NAME.COMPANY_ID,
374
- tokenValue: companyId.value
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,
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.491",
3
+ "version": "1.7.493",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {