sr-npm 1.7.260 → 1.7.262

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
@@ -30,7 +30,7 @@ async function saveJobsDataToCMS() {
30
30
  const jobsData = positions.content.map(position => {
31
31
  const basicJob = {
32
32
  _id: position.id,
33
- title: position.title || '',
33
+ title: position.name || '',
34
34
  department: position.department?.label || 'Other',
35
35
  cityText: normalizeCityName(position.location?.city),
36
36
  location: position.location && Object.keys(position.location).length > 0
@@ -48,7 +48,7 @@ async function saveJobsDataToCMS() {
48
48
  country: position.location?.country || '',
49
49
  remote: position.location?.remote || false,
50
50
  language: position.language?.label || '',
51
- postingStatus: position.postingStatus || '',
51
+ //postingStatus: position.postingStatus || '',
52
52
  jobDescription: null, // Will be filled later
53
53
  };
54
54
  return basicJob;
@@ -301,6 +301,18 @@ function getSmartToken() {
301
301
  });
302
302
  }
303
303
 
304
+ function getCompanyId() {
305
+ const elevatedGetSecretValue = auth.elevate(secrets.getSecretValue);
306
+ return elevatedGetSecretValue("companyID")
307
+ .then((secret) => {
308
+ return secret;
309
+ })
310
+ .catch((error) => {
311
+ console.error(error);
312
+ throw error;
313
+ });
314
+ }
315
+
304
316
 
305
317
  async function createApiKeyCollectionAndFillIt() {
306
318
  console.log("Creating ApiKey collection and filling it with the smart token");
@@ -377,4 +389,5 @@ module.exports = {
377
389
  aggregateJobsByFieldToCMS,
378
390
  referenceJobsToField,
379
391
  createApiKeyCollectionAndFillIt,
392
+ getCompanyId
380
393
  };
@@ -1,6 +1,7 @@
1
1
  const { fetch } = require('wix-fetch');
2
2
  const { items: wixData } = require('@wix/data');
3
3
  const { COLLECTIONS } = require('./collectionConsts');
4
+ const { getCompanyId } = require('./data');
4
5
  async function makeSmartRecruitersRequest(path,token) {
5
6
  const baseUrl = 'https://api.smartrecruiters.com'; // PROD
6
7
  // const baseUrl = 'https://bayank2.wixstudio.com/my-site-3//_functions'; // TEST
@@ -37,6 +38,7 @@ async function fetchPositionsFromSRAPI() {
37
38
  let page = 0;
38
39
  const MAX_PAGES = 30 // Safety limit to prevent infinite loops
39
40
  const token = await getSmartTokenFromCMS();
41
+ const companyId=await getCompanyId();
40
42
  console.log('Starting to fetch all positions with pagination...');
41
43
 
42
44
  do {
@@ -44,7 +46,8 @@ async function fetchPositionsFromSRAPI() {
44
46
  page++;
45
47
 
46
48
  // Build the API path - first request has no page parameter, subsequent use nextPageId
47
- let apiPath = '/jobs?limit=50&postingStatus=PUBLIC';
49
+ //let apiPath = '/jobs?limit=50&postingStatus=PUBLIC';
50
+ let apiPath = `/v1/companies/${companyId}/postings?offset=0`;
48
51
  if (nextPageId) {
49
52
  apiPath += `&pageId=${nextPageId}`;
50
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.260",
3
+ "version": "1.7.262",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -7,7 +7,7 @@ const {
7
7
  debounce,
8
8
  getFilter,
9
9
  } = require('../public/filterUtils');
10
- const { filterBrokenMarkers } = require('../public/utils');
10
+
11
11
  let currentLoadedItems =100;
12
12
  const itemsPerPage = 100;
13
13
  let allJobs=[]
@@ -349,7 +349,20 @@ async function handleLocationParam(_$w,location) {
349
349
  async function updateMapMarkers(_$w){
350
350
  const numOfItems = await _$w('#jobsDataset').getTotalCount();
351
351
  const items = await _$w('#jobsDataset').getItems(0, numOfItems);
352
- const markers = filterBrokenMarkers(items.items).map(item => {
352
+ const markers = items.items
353
+ .filter(item => {
354
+ const locationAddress = item.locationAddress;
355
+ const location = locationAddress && locationAddress.location;
356
+ return (
357
+ location !== undefined &&
358
+ location !== null &&
359
+ location.latitude !== undefined &&
360
+ location.latitude !== null &&
361
+ location.longitude !== undefined &&
362
+ location.longitude !== null
363
+ );
364
+ })
365
+ .map(item => {
353
366
  const location = item.locationAddress.location;
354
367
  return {
355
368
  location: {
package/pages/homePage.js CHANGED
@@ -3,7 +3,6 @@ const {
3
3
  getFilter,
4
4
  } = require('../public/filterUtils');
5
5
  const { handleOnLocationClick } = require('../public/mapUtils');
6
- const { filterBrokenMarkers } = require('../public/utils');
7
6
  const { location } = require('@wix/site-location');
8
7
  let thisObjectVar;
9
8
  async function homePageOnReady(_$w,thisObject) {
@@ -26,7 +25,7 @@ async function homePageOnReady(_$w,thisObject) {
26
25
  const numOfItems = await _$w('#citiesDataset').getTotalCount();
27
26
  const items = await _$w('#citiesDataset').getItems(0, numOfItems);
28
27
  let baseUrl = await location.baseUrl();
29
- const markers = filterBrokenMarkers(items.items).map(item => {
28
+ const markers = items.items.map(item => {
30
29
  const location = item.locationAddress.location;
31
30
  const cityName = encodeURIComponent(item.title); // Use the city name from the item
32
31
  const cityLinkUrl = `${baseUrl}/positions?location=${cityName}`; // Add city as search parameter
package/public/utils.js CHANGED
@@ -22,24 +22,7 @@ function htmlToText(html) {
22
22
  return text.replace(/\n\s*\n+/g, '\n\n').replace(/[ \t]+\n/g, '\n').trim();
23
23
  }
24
24
 
25
- function filterBrokenMarkers(items) {
26
- return items
27
- .filter(item => {
28
- const locationAddress = item.locationAddress;
29
- const location = locationAddress && locationAddress.location;
30
- return (
31
- location !== undefined &&
32
- location !== null &&
33
- location.latitude !== undefined &&
34
- location.latitude !== null &&
35
- location.longitude !== undefined &&
36
- location.longitude !== null
37
- );
38
- })
39
- }
40
-
41
25
 
42
26
  module.exports = {
43
- htmlToText,
44
- filterBrokenMarkers
27
+ htmlToText
45
28
  };