sr-npm 1.0.12 → 1.0.14

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.
@@ -3,6 +3,7 @@ const COLLECTIONS = {
3
3
  CITIES: 'cities',
4
4
  JOBS: 'Jobs',
5
5
  COMPANY_ID: 'CompanyId',
6
+ TEMPLATE_TYPE: 'TemplateType',
6
7
  }
7
8
  const JOBS_COLLECTION_FIELDS = {
8
9
  LOCATION: 'location',
@@ -18,6 +19,7 @@ const JOBS_COLLECTION_FIELDS = {
18
19
  CITY_TEXT: 'cityText',
19
20
  IMAGE: 'image',
20
21
  APPLY_LINK: 'applyLink',
22
+ REFER_FRIEND_LINK: 'referFriendLink',
21
23
  }
22
24
  const AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION_FIELDS = {
23
25
  TITLE: 'title',
@@ -54,7 +56,8 @@ const COLLECTIONS_FIELDS = {
54
56
  {key:'remote', type: 'BOOLEAN'},
55
57
  {key:'jobDescription', type: 'OBJECT'},
56
58
  {key:'cityText', type: 'TEXT'},
57
- {key:'applyLink', type: 'URL'},
59
+ {key:'applyLink', type: 'URL'},
60
+ {key:'referFriendLink', type: 'URL'},
58
61
  {key:'departmentref', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT } } },
59
62
  {key:'city', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.CITIES } } },
60
63
  { key: 'image', type: 'IMAGE' },
@@ -62,6 +65,9 @@ const COLLECTIONS_FIELDS = {
62
65
  COMPANY_ID: [
63
66
  {key:'companyId', type: 'TEXT'},
64
67
  ],
68
+ TEMPLATE_TYPE: [
69
+ {key:'templateType', type: 'TEXT'},
70
+ ],
65
71
  };
66
72
 
67
73
 
package/backend/data.js CHANGED
@@ -120,7 +120,7 @@ async function saveJobsDescriptionsAndLocationApplyUrlToCMS() {
120
120
  try {
121
121
  const jobDetails = await fetchJobDescription(job._id);
122
122
  const jobLocation = fetchJobLocation(jobDetails);
123
- const applyLink = fetchApplyLink(jobDetails);
123
+ const {applyLink , referFriendLink} = fetchApplyAndReferFriendLink(jobDetails);
124
124
 
125
125
 
126
126
  const updatedJob = {
@@ -128,6 +128,7 @@ async function saveJobsDescriptionsAndLocationApplyUrlToCMS() {
128
128
  locationAddress: jobLocation,
129
129
  jobDescription: jobDetails.jobAd.sections,
130
130
  applyLink: applyLink,
131
+ referFriendLink: referFriendLink,
131
132
  };
132
133
  await wixData.update(COLLECTIONS.JOBS, updatedJob);
133
134
  return { success: true, jobId: job._id, title: job.title };
@@ -258,8 +259,8 @@ async function referenceJobsToField({ referenceField, sourceCollection, jobField
258
259
  return { success: true, updated: jobsToUpdate.length };
259
260
  }
260
261
 
261
- function fetchApplyLink(jobDetails) {
262
- return jobDetails.applyUrl;
262
+ function fetchApplyAndReferFriendLink(jobDetails) {
263
+ return {applyLink: jobDetails.applyUrl, referFriendLink: jobDetails.referralUrl};
263
264
  }
264
265
 
265
266
  function fetchJobLocation(jobDetails) {
@@ -34,6 +34,7 @@ async function fetchPositionsFromSRAPI() {
34
34
  let page = 0;
35
35
  const MAX_PAGES = 30 // Safety limit to prevent infinite loops
36
36
  const companyId = await getCompanyIdFromCMS();
37
+ const templateType = await getTemplateTypeFromCMS();
37
38
  console.log('Starting to fetch all positions with pagination...');
38
39
  let offset=0;
39
40
 
@@ -42,7 +43,7 @@ async function fetchPositionsFromSRAPI() {
42
43
  page++;
43
44
 
44
45
  // Build the API path - first request has no page parameter, subsequent use nextPageId
45
- const apiPath = `/v1/companies/${companyId}/postings?offset=${offset}`;
46
+ const apiPath = `/v1/companies/${companyId}/postings?offset=${offset}&destination=${templateType}`;
46
47
 
47
48
  console.log(`Fetching page ${page} with path: ${apiPath}`);
48
49
  const response = await makeSmartRecruitersRequest(apiPath);
@@ -107,6 +108,14 @@ async function getCompanyIdFromCMS() {
107
108
  throw new Error('[getCompanyIdFromCMS], No companyId found');
108
109
  }
109
110
  }
111
+ async function getTemplateTypeFromCMS() {
112
+ const result = await wixData.query(COLLECTIONS.TEMPLATE_TYPE).limit(1).find();
113
+ if (result.items.length > 0) {
114
+ return result.items[0].templateType;
115
+ } else {
116
+ throw new Error('[getTemplateTypeFromCMS], No templateType found');
117
+ }
118
+ }
110
119
 
111
120
 
112
121
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -10,7 +10,6 @@ describe('Job details fetch from SR API Tests', () => {
10
10
  });
11
11
 
12
12
  test('should successfully fetch job details from SR API', async () => {
13
-
14
13
  const randomPosition = getRandomPosition(positions.data.result.content);
15
14
  expect(positions.data.result.totalFound).toBeGreaterThan(0);
16
15
  expect(positions.data.result.content.length).toBeGreaterThan(0);