sr-npm 1.7.259 → 1.7.261

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");
@@ -37,6 +37,7 @@ async function fetchPositionsFromSRAPI() {
37
37
  let page = 0;
38
38
  const MAX_PAGES = 30 // Safety limit to prevent infinite loops
39
39
  const token = await getSmartTokenFromCMS();
40
+ const companyId=await getCompanyId();
40
41
  console.log('Starting to fetch all positions with pagination...');
41
42
 
42
43
  do {
@@ -44,7 +45,8 @@ async function fetchPositionsFromSRAPI() {
44
45
  page++;
45
46
 
46
47
  // Build the API path - first request has no page parameter, subsequent use nextPageId
47
- let apiPath = '/jobs?limit=50&postingStatus=PUBLIC';
48
+ //let apiPath = '/jobs?limit=50&postingStatus=PUBLIC';
49
+ let apiPath = `/v1/companies/${companyId}/postings?offset=0`;
48
50
  if (nextPageId) {
49
51
  apiPath += `&pageId=${nextPageId}`;
50
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.259",
3
+ "version": "1.7.261",
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
@@ -25,7 +25,7 @@ async function homePageOnReady(_$w,thisObject) {
25
25
  const numOfItems = await _$w('#citiesDataset').getTotalCount();
26
26
  const items = await _$w('#citiesDataset').getItems(0, numOfItems);
27
27
  let baseUrl = await location.baseUrl();
28
- const markers = filterBrokenMarkers(items.items).map(item => {
28
+ const markers = items.items.map(item => {
29
29
  const location = item.locationAddress.location;
30
30
  const cityName = encodeURIComponent(item.title); // Use the city name from the item
31
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
  };