sr-npm 3.1.4 → 3.1.5

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.
@@ -135,6 +135,7 @@ const COLLECTIONS_FIELDS = {
135
135
  COMPANY_ID: 'companyId',
136
136
  SMART_TOKEN: 'x-smarttoken',
137
137
  DESIRED_BRAND: 'desiredBrand',
138
+ RICH_CONTENT_CONVERTER_TOKEN: 'richContentConverterToken',
138
139
  }
139
140
 
140
141
 
package/backend/data.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const { items: wixData } = require('@wix/data');
2
- const { fetchPositionsFromSRAPI, fetchJobDescription } = require('./fetchPositionsFromSRAPI');
2
+ const { fetchPositionsFromSRAPI, fetchJobDescription, htmlRichContentConverter } = require('./fetchPositionsFromSRAPI');
3
3
  const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
4
4
 
5
5
  const { getAllPositions } = require('./queries');
@@ -269,7 +269,7 @@ async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS() {
269
269
 
270
270
  const API_CHUNK_SIZE = 80;
271
271
  const pageChunks = Math.ceil(jobsWithNoDescriptions.items.length / API_CHUNK_SIZE);
272
-
272
+ const richContentConverterToken = await getTokenFromCMS(TOKEN_NAME.RICH_CONTENT_CONVERTER_TOKEN);
273
273
  await chunkedBulkOperation({
274
274
  items: jobsWithNoDescriptions.items,
275
275
  chunkSize: API_CHUNK_SIZE,
@@ -278,14 +278,13 @@ async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS() {
278
278
  const chunkPromises = chunk.map(async job => {
279
279
  try {
280
280
  const jobDetails = await fetchJobDescription(job._id);
281
+ const richContentDescription=await htmlRichContentConverter(jobDetails.jobAd.sections,richContentConverterToken);
281
282
  const jobLocation = fetchJobLocation(jobDetails);
282
283
  const {applyLink , referFriendLink} = fetchApplyAndReferFriendLink(jobDetails);
283
-
284
-
285
284
  const updatedJob = {
286
285
  ...job,
287
286
  locationAddress: jobLocation,
288
- jobDescription: jobDetails.jobAd.sections,
287
+ jobDescription: richContentDescription,
289
288
  applyLink: applyLink,
290
289
  referFriendLink: referFriendLink,
291
290
  };
@@ -114,11 +114,44 @@ async function fetchJobDescription(jobId,testObject=undefined) {
114
114
  return await makeSmartRecruitersRequest(`/v1/companies/${companyId}/postings/${jobId}`,templateType);
115
115
  }
116
116
 
117
+ async function htmlRichContentConverter(sections,richContentConverterToken) {
118
+ const richContentObject = {}
119
+ for (const [sectionTitle, sectionData] of Object.entries(sections)) {
120
+ if (sectionData.text) {
121
+ const raw = JSON.stringify({
122
+ content: sectionData.text,
123
+ });
124
+ const requestOptions = {
125
+ method: 'post',
126
+ headers: {
127
+ 'Content-Type': 'application/json',
128
+ Cookie: 'XSRF-TOKEN=1753949844|p--a7HsuVjR4',
129
+ Authorization: 'Bearer '+richContentConverterToken,
130
+ },
131
+ body: raw,
132
+ };
133
+ const response = await fetch(
134
+ 'https://www.wixapis.com/data-sync/v1/abmp-content-converter',
135
+ requestOptions
136
+ );
137
+ if (response.ok) {
138
+ const data = await response.json();
139
+ richContentObject[sectionTitle] = data.richContent.richContent;
140
+ }
141
+ else {
142
+ throw new Error("Error converting html to rich content response: "+response);
143
+ }
144
+ }
145
+ }
146
+ return richContentObject;
147
+ }
148
+
117
149
 
118
150
 
119
151
 
120
152
  module.exports = {
121
153
  fetchPositionsFromSRAPI,
122
154
  fetchJobDescription,
123
- makeSmartRecruitersRequest
155
+ makeSmartRecruitersRequest,
156
+ htmlRichContentConverter
124
157
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "3.1.4",
3
+ "version": "3.1.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -595,7 +595,6 @@ async function secondarySearch(_$w,query) {
595
595
  }
596
596
  secondarySearchIsFilled=true
597
597
  }
598
-
599
598
  handlePaginationButtons(_$w);
600
599
  updateTotalJobsCountText(_$w);
601
600
  await refreshFacetCounts(_$w);
@@ -5,7 +5,6 @@ const { items: wixData } = require('@wix/data');
5
5
  const { location } = require("@wix/site-location");
6
6
  const{isElementExistOnPage} = require('psdev-utils');
7
7
  const {
8
- htmlToText,
9
8
  appendQueryParams
10
9
  } = require('../public/utils');
11
10
 
@@ -40,17 +39,14 @@ async function getCategoryValue(customValues) {
40
39
 
41
40
  handleReferFriendButton(_$w,item);
42
41
  handleApplyButton(_$w,item);
43
-
44
42
 
45
-
46
-
47
- _$w('#companyDescriptionText').text = htmlToText(item.jobDescription.companyDescription.text);
48
- _$w('#responsibilitiesText').text = htmlToText(item.jobDescription.jobDescription.text);
49
- _$w('#qualificationsText').text = htmlToText(item.jobDescription.qualifications.text);
43
+ _$w('#companyDescriptionText').content = item.jobDescription.companyDescription;
44
+ _$w('#responsibilitiesText').content = item.jobDescription.jobDescription;
45
+ _$w('#qualificationsText').content = item.jobDescription.qualifications;
50
46
  _$w('#relatedJobsTitleText').text = `More ${item.department} Positions`;
51
47
  if(isElementExistOnPage(_$w('#additionalInfoText')))
52
48
  {
53
- _$w('#additionalInfoText').text = htmlToText(item.jobDescription.additionalInformation.text);
49
+ _$w('#additionalInfoText').content = item.jobDescription.additionalInformation;
54
50
  }
55
51
  if(isElementExistOnPage(_$w('#relatedJobsRepNoDepartment'))) // when there is no department, we filter based on category
56
52
  {