sr-npm 1.7.490 → 1.7.492

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,24 +366,22 @@ 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);
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
+ }
376
+ }
377
+ }
378
+
379
+ async function insertSecretValToCMS(tokenName) {
380
+ const token = await retrieveSecretVal(tokenName);
372
381
  await wixData.insert(COLLECTIONS.SECRET_MANAGER_MIRROR, {
373
- tokenName: TOKEN_NAME.COMPANY_ID,
374
- tokenValue: companyId.value
382
+ tokenName: tokenName,
383
+ tokenValue: token.value
375
384
  });
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);
386
- }
387
385
  }
388
386
 
389
387
 
@@ -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.490",
3
+ "version": "1.7.492",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -37,8 +37,9 @@ allJobs=await getAllPositions();
37
37
  await activateAutoLoad(_$w);
38
38
  await bind(_$w);
39
39
  await init(_$w);
40
- await handleUrlParams(_$w);
41
40
  await handleBrandDropdown(_$w);
41
+ await handleUrlParams(_$w);
42
+
42
43
 
43
44
  }
44
45
 
@@ -106,7 +107,6 @@ async function handleUrlParams(_$w) {
106
107
  if (queryJobTypeVar) {
107
108
  await handleJobTypeParam(_$w,queryJobTypeVar);
108
109
  }
109
- console.log("_$w('#dropdownBrand'): ", _$w('#dropdownBrand'));
110
110
  if (queryBrandVar && _$w('#dropdownBrand').isVisible) { //if it is not visible, ignore it
111
111
  await handleBrandParam(_$w,queryBrandVar);
112
112
  }