sr-npm 1.7.368 → 1.7.369

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.
@@ -2,7 +2,7 @@ const COLLECTIONS = {
2
2
  AMOUNT_OF_JOBS_PER_DEPARTMENT: 'AmountOfJobsPerDepartment',
3
3
  CITIES: 'cities',
4
4
  JOBS: 'Jobs',
5
- API_KEY: 'ApiKey',
5
+ COMPANY_ID: 'CompanyId',
6
6
  }
7
7
  const JOBS_COLLECTION_FIELDS = {
8
8
  LOCATION: 'location',
@@ -59,8 +59,8 @@ const COLLECTIONS_FIELDS = {
59
59
  {key:'city', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.CITIES } } },
60
60
  { key: 'image', type: 'IMAGE' },
61
61
  ],
62
- API_KEY: [
63
- {key:'token', type: 'TEXT'},
62
+ COMPANY_ID: [
63
+ {key:'companyId', type: 'TEXT'},
64
64
  ],
65
65
  };
66
66
 
package/backend/consts.js CHANGED
@@ -1,6 +1,5 @@
1
- const {saveJobsDataToCMS,saveJobsDescriptionsAndLocationApplyUrlToCMS,aggregateJobsByFieldToCMS,referenceJobsToField,createApiKeyCollectionAndFillIt,createCollections,aggregateJobs,referenceJobs,syncJobsFast} = require('./data');
2
- const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
3
- const { COLLECTIONS, COLLECTIONS_FIELDS, JOBS_COLLECTION_FIELDS } = require('./collectionConsts');
1
+ const {saveJobsDataToCMS,saveJobsDescriptionsAndLocationApplyUrlToCMS,createCollections,aggregateJobs,referenceJobs,syncJobsFast} = require('./data')
2
+
4
3
 
5
4
  const QUERY_MAX_LIMIT = 1000;
6
5
 
@@ -11,7 +10,7 @@ const TASKS_NAMES = {
11
10
  AGGREGATE_JOBS_BY_FIELD_TO_CMS: 'aggregateJobsByFieldToCMS',
12
11
  REFERENCE_JOBS: 'referenceJobs',
13
12
  CREATE_COLLECTIONS: 'createCollections',
14
- CREATE_API_KEY_COLLECTION_AND_FILL_IT: 'createApiKeyCollectionAndFillIt',
13
+ CREATE_COMPANY_ID_COLLECTION_AND_FILL_IT: 'createCompanyIdCollectionAndFillIt',
15
14
  SYNC_JOBS_FAST: 'syncJobsFast',
16
15
  }
17
16
 
@@ -64,20 +63,13 @@ const TASKS = {
64
63
  shouldSkipCheck:()=>false,
65
64
  estimatedDurationSec:6
66
65
  },
67
- [TASKS_NAMES.CREATE_API_KEY_COLLECTION_AND_FILL_IT]: {
68
- name: TASKS_NAMES.CREATE_API_KEY_COLLECTION_AND_FILL_IT,
69
- getIdentifier:()=> "SHOULD_NEVER_SKIP",
70
- process:createApiKeyCollectionAndFillIt,
71
- shouldSkipCheck:()=>false,
72
- estimatedDurationSec:3
73
- },
74
- [TASKS_NAMES.SYNC_JOBS_FAST]: {
75
- name: TASKS_NAMES.SYNC_JOBS_FAST,
76
- getIdentifier:()=> "SHOULD_NEVER_SKIP",
77
- process:syncJobsFast,
78
- shouldSkipCheck:()=>false,
79
- estimatedDurationSec:60
80
- }
66
+ [TASKS_NAMES.SYNC_JOBS_FAST]: {
67
+ name: TASKS_NAMES.SYNC_JOBS_FAST,
68
+ getIdentifier:()=> "SHOULD_NEVER_SKIP",
69
+ process:syncJobsFast,
70
+ shouldSkipCheck:()=>false,
71
+ estimatedDurationSec:60
72
+ }
81
73
  }
82
74
 
83
75
 
package/backend/data.js CHANGED
@@ -1,10 +1,10 @@
1
- const { items: wixData, collections } = require('@wix/data');
1
+ const { items: wixData } = require('@wix/data');
2
2
  const { fetchPositionsFromSRAPI, fetchJobDescription } = require('./fetchPositionsFromSRAPI');
3
3
  const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
4
4
  const { COLLECTIONS, COLLECTIONS_FIELDS,JOBS_COLLECTION_FIELDS } = require('./collectionConsts');
5
- const { chunkedBulkOperation, delay, countJobsPerGivenField, fillCityLocationAndLocationAddress ,prepareToSaveArray,normalizeCityName} = require('./utils');
5
+ const { chunkedBulkOperation, countJobsPerGivenField, fillCityLocationAndLocationAddress ,prepareToSaveArray,normalizeCityName} = require('./utils');
6
6
  const { getAllPositions } = require('./queries');
7
- const { getSmartToken } = require('./secretsData');
7
+ const { getCompanyIdFromCMS } = require('./fetchPositionsFromSRAPI');
8
8
 
9
9
  function validatePosition(position) {
10
10
  if (!position.id) {
@@ -288,21 +288,21 @@ function fetchJobLocation(jobDetails) {
288
288
 
289
289
 
290
290
 
291
- async function createApiKeyCollectionAndFillIt() {
292
- console.log("Creating ApiKey collection and filling it with the smart token");
293
- await createCollectionIfMissing(COLLECTIONS.API_KEY, COLLECTIONS_FIELDS.API_KEY,null,'singleItem');
294
- console.log("Getting the smart token ");
295
- const token = await getSmartToken();
296
- console.log("token is : ", token);
297
- console.log("Inserting the smart token into the ApiKey collection");
291
+ async function createCompanyIdCollectionAndFillIt() {
292
+ console.log("Creating CompanyId collection and filling it with the company ID");
293
+ await createCollectionIfMissing(COLLECTIONS.COMPANY_ID, COLLECTIONS_FIELDS.COMPANY_ID,null,'singleItem');
294
+ console.log("Getting the company ID ");
295
+ const companyId = await getCompanyIdFromCMS();
296
+ console.log("companyId is : ", companyId);
297
+ console.log("Inserting the company ID into the CompanyId collection");
298
298
  try {
299
- await wixData.insert(COLLECTIONS.API_KEY, {
300
- token: token.value
299
+ await wixData.insert(COLLECTIONS.COMPANY_ID, {
300
+ companyId: companyId.value
301
301
  });
302
- console.log("Smart token inserted into the ApiKey collection");
302
+ console.log("company ID inserted into the CompanyId collection");
303
303
  } catch (error) {
304
304
  if (error.message.includes("WDE0074: An item with _id [SINGLE_ITEM_ID] already exists")) {
305
- console.log("Smart token already exists in the ApiKey collection");
305
+ console.log("company ID already exists in the CompanyId collection");
306
306
  }
307
307
  else {
308
308
  throw error;
@@ -340,7 +340,6 @@ async function referenceJobs() {
340
340
 
341
341
  async function syncJobsFast() {
342
342
  console.log("Syncing jobs fast");
343
- //await createApiKeyCollectionAndFillIt();
344
343
  await createCollections();
345
344
  await clearCollections();
346
345
  console.log("saving jobs data to CMS");
@@ -373,5 +372,5 @@ module.exports = {
373
372
  saveJobsDescriptionsAndLocationApplyUrlToCMS,
374
373
  aggregateJobsByFieldToCMS,
375
374
  referenceJobsToField,
376
- createApiKeyCollectionAndFillIt,
375
+ createCompanyIdCollectionAndFillIt,
377
376
  };
@@ -33,7 +33,7 @@ async function fetchPositionsFromSRAPI() {
33
33
  let totalFound = 0;
34
34
  let page = 0;
35
35
  const MAX_PAGES = 30 // Safety limit to prevent infinite loops
36
- const companyId = await secretsData.getCompanyId();
36
+ const companyId = await getCompanyIdFromCMS();
37
37
  console.log('Starting to fetch all positions with pagination...');
38
38
  let offset=0;
39
39
 
@@ -95,16 +95,16 @@ async function fetchPositionsFromSRAPI() {
95
95
  }
96
96
 
97
97
  async function fetchJobDescription(jobId) {
98
- const companyId = await secretsData.getCompanyId();
98
+ const companyId = await getCompanyIdFromCMS();
99
99
  return await makeSmartRecruitersRequest(`/v1/companies/${companyId.value}/postings/${jobId}`);
100
100
  }
101
101
 
102
- async function getSmartTokenFromCMS() {
103
- const result = await wixData.query(COLLECTIONS.API_KEY).limit(1).find();
102
+ async function getCompanyIdFromCMS() {
103
+ const result = await wixData.query(COLLECTIONS.COMPANY_ID).limit(1).find();
104
104
  if (result.items.length > 0) {
105
- return result.items[0].token;
105
+ return result.items[0].companyId;
106
106
  } else {
107
- throw new Error('[getSmartTokenFromCMS], No token found');
107
+ throw new Error('[getCompanyIdFromCMS], No companyId found');
108
108
  }
109
109
  }
110
110
 
@@ -112,4 +112,5 @@ async function getSmartTokenFromCMS() {
112
112
  module.exports = {
113
113
  fetchPositionsFromSRAPI,
114
114
  fetchJobDescription,
115
+ getCompanyIdFromCMS
115
116
  };
@@ -2,13 +2,6 @@ const { secrets } = require("@wix/secrets");
2
2
  const { auth } = require('@wix/essentials');
3
3
 
4
4
  const getSecretValue = auth.elevate(secrets.getSecretValue);
5
-
6
- function getSmartToken() {
7
- return getSecretValue("x-smarttoken")
8
- .then((secret) => {
9
- return secret;
10
- })
11
- }
12
5
 
13
6
  function getCompanyId() {
14
7
  return getSecretValue("companyID")
@@ -17,6 +10,5 @@ function getSmartToken() {
17
10
  })
18
11
  }
19
12
  module.exports = {
20
- getSmartToken,
21
13
  getCompanyId
22
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.368",
3
+ "version": "1.7.369",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -32,5 +32,4 @@ describe('Job details fetch from SR API Tests', () => {
32
32
  });
33
33
 
34
34
 
35
-
36
35
  });