sr-npm 1.7.266 → 1.7.268

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/data.js CHANGED
@@ -4,7 +4,7 @@ const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend
4
4
  const { COLLECTIONS, COLLECTIONS_FIELDS,JOBS_COLLECTION_FIELDS } = require('./collectionConsts');
5
5
  const { chunkedBulkOperation, delay, countJobsPerGivenField, fillCityLocationAndLocationAddress ,prepareToSaveArray,normalizeCityName} = require('./utils');
6
6
  const { getAllPositions } = require('./queries');
7
- const secretsData = require('./secretsData');
7
+ const { getSmartToken } = require('./secretsData');
8
8
 
9
9
  function validatePosition(position) {
10
10
  if (!position.id) {
@@ -127,7 +127,7 @@ async function saveJobsDescriptionsAndLocationApplyUrlToCMS() {
127
127
  const updatedJob = {
128
128
  ...job,
129
129
  locationAddress: jobLocation,
130
- jobDescription: jobDetails.jobAd.sections,
130
+ jobDescription: jobDetails.jobAd.sections.jobDescription,
131
131
  applyLink: applyLink,
132
132
  };
133
133
  await wixData.update(COLLECTIONS.JOBS, updatedJob);
@@ -260,7 +260,7 @@ async function referenceJobsToField({ referenceField, sourceCollection, jobField
260
260
  }
261
261
 
262
262
  function fetchApplyLink(jobDetails) {
263
- return jobDetails.actions.applyOnWeb.url;
263
+ return jobDetails.applyUrl;
264
264
  }
265
265
 
266
266
  function fetchJobLocation(jobDetails) {
@@ -293,7 +293,7 @@ async function createApiKeyCollectionAndFillIt() {
293
293
  console.log("Creating ApiKey collection and filling it with the smart token");
294
294
  await createCollectionIfMissing(COLLECTIONS.API_KEY, COLLECTIONS_FIELDS.API_KEY,null,'singleItem');
295
295
  console.log("Getting the smart token");
296
- const token = await secretsData.getSmartToken();
296
+ const token = await getSmartToken();
297
297
  console.log("token is : ", token);
298
298
  console.log("Inserting the smart token into the ApiKey collection");
299
299
  await wixData.insert(COLLECTIONS.API_KEY, {
@@ -48,9 +48,6 @@ async function fetchPositionsFromSRAPI() {
48
48
 
49
49
  // Build the API path - first request has no page parameter, subsequent use nextPageId
50
50
  let apiPath = `/v1/companies/${companyId.value}/postings?offset=${offset}`;
51
- if (nextPageId) {
52
- apiPath += `&pageId=${nextPageId}`;
53
- }
54
51
 
55
52
  console.log(`Fetching page ${page} with path: ${apiPath}`);
56
53
  const response = await makeSmartRecruitersRequest(apiPath,token);
@@ -69,13 +66,9 @@ async function fetchPositionsFromSRAPI() {
69
66
  }
70
67
 
71
68
  // Get the nextPageId for the next iteration
72
- nextPageId = response.nextPageId && response.nextPageId !== '' ? response.nextPageId : null;
73
-
74
- if (nextPageId) {
75
- console.log(`Next page ID: ${nextPageId}`);
76
- } else {
77
- console.log('No more pages to fetch');
78
- }
69
+ // nextPageId = response.nextPageId && response.nextPageId !== '' ? response.nextPageId : null;
70
+ offset+=100;
71
+
79
72
  } catch (error) {
80
73
  console.error(`Error fetching page ${page}:`, error);
81
74
  throw error;
@@ -86,7 +79,7 @@ async function fetchPositionsFromSRAPI() {
86
79
  console.warn(`Reached maximum page limit of ${MAX_PAGES}. Stopping pagination.`);
87
80
  break;
88
81
  }
89
- } while (nextPageId); // Continue while there's a nextPageId
82
+ } while (offset<totalFound); // Continue while there's a nextPageId
90
83
 
91
84
  console.log(`Finished fetching all pages. Total positions collected: ${allPositions.length}`);
92
85
 
@@ -111,7 +104,8 @@ async function fetchPositionsFromSRAPI() {
111
104
 
112
105
  async function fetchJobDescription(jobId) {
113
106
  const token = await getSmartTokenFromCMS();
114
- return await makeSmartRecruitersRequest(`/jobs/${jobId}`,token);
107
+ const companyId = await secretsData.getCompanyId();
108
+ return await makeSmartRecruitersRequest(`/v1/companies/${companyId.value}/postings/${jobId}`,token);
115
109
  }
116
110
 
117
111
  async function getSmartTokenFromCMS() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.266",
3
+ "version": "1.7.268",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {