sr-npm 1.7.1065 → 1.7.1067
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/.github/workflows/update-sites.yml +1 -1
- package/backend/careersMultiBoxesPageIds.js +16 -0
- package/backend/collectionConsts.js +2 -0
- package/backend/consts.js +9 -15
- package/backend/data.js +28 -23
- package/backend/fetchPositionsFromSRAPI.js +3 -40
- package/package.json +1 -1
- package/pages/brandPage.js +1 -0
- package/pages/careersMultiBoxesPage.js +153 -51
- package/pages/careersPage.js +124 -127
- package/pages/pagesUtils.js +14 -5
- package/public/selectors.js +53 -0
- package/tests/multiSearchBoxCareers.spec.js +28 -5
|
@@ -39,6 +39,11 @@ const fieldTitlesInCMS={
|
|
|
39
39
|
"brand": "Brands",
|
|
40
40
|
category: "Category",
|
|
41
41
|
visibility: "Visibility",
|
|
42
|
+
location: "Location",
|
|
43
|
+
employmenttype: "Employment Type",
|
|
44
|
+
contracttype: "Contract Type",
|
|
45
|
+
companysegment: "Company Segment",
|
|
46
|
+
storename: "Store Name",
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
const FiltersIds={
|
|
@@ -52,10 +57,21 @@ const FiltersIds={
|
|
|
52
57
|
Visibility: 'Visibility',
|
|
53
58
|
}
|
|
54
59
|
|
|
60
|
+
const possibleUrlParams=[
|
|
61
|
+
"brand",
|
|
62
|
+
"location",
|
|
63
|
+
"employmenttype",
|
|
64
|
+
"contracttype",
|
|
65
|
+
"visibility",
|
|
66
|
+
"category",
|
|
67
|
+
"companysegment",
|
|
68
|
+
"storename",
|
|
69
|
+
]
|
|
55
70
|
|
|
56
71
|
module.exports = {
|
|
57
72
|
CAREERS_MULTI_BOXES_PAGE_CONSTS,
|
|
58
73
|
FiltersIds,
|
|
59
74
|
fieldTitlesInCMS,
|
|
60
75
|
CATEGORY_CUSTOM_FIELD_ID_IN_CMS,
|
|
76
|
+
possibleUrlParams,
|
|
61
77
|
}
|
|
@@ -31,6 +31,7 @@ const JOBS_COLLECTION_FIELDS = {
|
|
|
31
31
|
MULTI_REF_JOBS_CUSTOM_VALUES: 'multiRefJobsCustomValues',
|
|
32
32
|
EMPLOYMENT_TYPE: 'employmentType',
|
|
33
33
|
RELEASED_DATE: 'releasedDate',
|
|
34
|
+
REF_ID: 'refId',
|
|
34
35
|
}
|
|
35
36
|
const AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION_FIELDS = {
|
|
36
37
|
TITLE: 'title',
|
|
@@ -93,6 +94,7 @@ const COLLECTIONS_FIELDS = {
|
|
|
93
94
|
{key: 'image', type: 'IMAGE' },
|
|
94
95
|
{key:'employmentType', type: 'TEXT'},
|
|
95
96
|
{key:'releasedDate', type: 'TEXT'},
|
|
97
|
+
{key:'refId', type: 'TEXT'},
|
|
96
98
|
],
|
|
97
99
|
TEMPLATE_TYPE: [
|
|
98
100
|
{key:'templateType', type: 'TEXT'},
|
package/backend/consts.js
CHANGED
|
@@ -72,9 +72,6 @@ const TASKS = {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
75
|
const TASK_TYPE = {
|
|
79
76
|
SCHEDULED: 'scheduled',
|
|
80
77
|
EVENT: 'event',
|
|
@@ -92,10 +89,6 @@ const supportTeamsPageIds={
|
|
|
92
89
|
VIDEO_TITLE: "#videoTitle",
|
|
93
90
|
VIDEO_PLAYER: "#videoPlayer",
|
|
94
91
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
92
|
RECENTLEY_ADDED_JOBS_ITEM: "#recentleyAddedJobsItem",
|
|
100
93
|
JOB_LOCATION: "#jobLocation",
|
|
101
94
|
JOB_TITLE: "#jobTitle",
|
|
@@ -137,12 +130,13 @@ const supportTeamsPageSections={
|
|
|
137
130
|
VIDEO: "video",
|
|
138
131
|
}
|
|
139
132
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
133
|
+
|
|
134
|
+
module.exports = {
|
|
135
|
+
TASKS_NAMES,
|
|
136
|
+
TASK_TYPE,
|
|
137
|
+
TASKS,
|
|
138
|
+
QUERY_MAX_LIMIT,
|
|
139
|
+
supportTeamsPageIds,
|
|
140
|
+
LINKS,
|
|
141
|
+
supportTeamsPageSections,
|
|
148
142
|
};
|
package/backend/data.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
const { items: wixData } = require('@wix/data');
|
|
2
|
-
const { fetchPositionsFromSRAPI, fetchJobDescription
|
|
2
|
+
const { fetchPositionsFromSRAPI, fetchJobDescription } = require('./fetchPositionsFromSRAPI');
|
|
3
3
|
const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
|
|
4
4
|
const { COLLECTIONS, COLLECTIONS_FIELDS,JOBS_COLLECTION_FIELDS,TEMPLATE_TYPE,TOKEN_NAME,CUSTOM_VALUES_COLLECTION_FIELDS } = require('./collectionConsts');
|
|
5
5
|
const { chunkedBulkOperation, countJobsPerGivenField, fillCityLocationAndLocationAddress ,prepareToSaveArray,normalizeString} = require('./utils');
|
|
6
6
|
const { getAllPositions } = require('./queries');
|
|
7
7
|
const { retrieveSecretVal, getTokenFromCMS ,getApiKeys} = require('./secretsData');
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
9
|
let customValuesToJobs = {}
|
|
12
10
|
let locationToJobs = {}
|
|
13
11
|
let siteconfig;
|
|
@@ -21,6 +19,7 @@ async function getSiteConfig() {
|
|
|
21
19
|
const queryresult = await wixData.query(COLLECTIONS.SITE_CONFIGS).find();
|
|
22
20
|
siteconfig = queryresult.items[0];
|
|
23
21
|
}
|
|
22
|
+
|
|
24
23
|
function validatePosition(position) {
|
|
25
24
|
if (!position.id) {
|
|
26
25
|
throw new Error('Position id is required');
|
|
@@ -40,22 +39,22 @@ function validatePosition(position) {
|
|
|
40
39
|
async function filterBasedOnBrand(positions) {
|
|
41
40
|
try{
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} catch (error) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
const desiredBrand = await getTokenFromCMS(TOKEN_NAME.DESIRED_BRAND);
|
|
43
|
+
validateSingleDesiredBrand(desiredBrand);
|
|
44
|
+
console.log("filtering positions based on brand: ", desiredBrand);
|
|
45
|
+
return positions.content.filter(position => {
|
|
46
|
+
const brand = getBrand(position.customField);
|
|
47
|
+
if (!brand) return false;
|
|
48
|
+
return brand === desiredBrand;
|
|
49
|
+
});
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if(error.message==="[getTokenFromCMS], No desiredBrand found")
|
|
52
|
+
{
|
|
53
|
+
console.log("no desiredBrand found, fetching all positions")
|
|
54
|
+
return positions.content;
|
|
55
|
+
}
|
|
56
|
+
throw error;
|
|
56
57
|
}
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
function validateSingleDesiredBrand(desiredBrand) {
|
|
@@ -63,11 +62,12 @@ function validateSingleDesiredBrand(desiredBrand) {
|
|
|
63
62
|
throw new Error("Desired brand must be a single brand");
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
|
-
function getLocation(position,basicJob) {
|
|
67
65
|
|
|
66
|
+
function getLocation(position,basicJob) {
|
|
68
67
|
locationToJobs[basicJob.cityText] ? locationToJobs[basicJob.cityText].push(position.id) : locationToJobs[basicJob.cityText]=[position.id]
|
|
69
68
|
|
|
70
69
|
}
|
|
70
|
+
|
|
71
71
|
function getVisibility(position,customFieldsValues) {
|
|
72
72
|
if (!customFieldsValues["Visibility"]) {
|
|
73
73
|
customFieldsValues["Visibility"] = {};
|
|
@@ -99,8 +99,8 @@ function getCustomFieldsAndValuesFromPosition(position,customFieldsLabels,custom
|
|
|
99
99
|
if (!customFieldsValues[fieldId]) {
|
|
100
100
|
customFieldsValues[fieldId] = {};
|
|
101
101
|
}
|
|
102
|
+
|
|
102
103
|
customFieldsValues[fieldId][valueId] = valueLabel;
|
|
103
|
-
|
|
104
104
|
customValuesToJobs[valueId] ? customValuesToJobs[valueId].add(position.id) : customValuesToJobs[valueId]=new Set([position.id])
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -140,7 +140,8 @@ async function saveJobsDataToCMS() {
|
|
|
140
140
|
brand: siteconfig.disableMultiBrand==="false" ? getBrand(position.customField) : '',
|
|
141
141
|
jobDescription: null, // Will be filled later
|
|
142
142
|
employmentType: position.typeOfEmployment.label,
|
|
143
|
-
releasedDate: position.releasedDate
|
|
143
|
+
releasedDate: position.releasedDate,
|
|
144
|
+
refId: position.refNumber
|
|
144
145
|
};
|
|
145
146
|
|
|
146
147
|
getCustomFieldsAndValuesFromPosition(position,customFieldsLabels,customFieldsValues);
|
|
@@ -269,13 +270,14 @@ async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS() {
|
|
|
269
270
|
const chunkPromises = chunk.map(async job => {
|
|
270
271
|
try {
|
|
271
272
|
const jobDetails = await fetchJobDescription(job._id);
|
|
272
|
-
const richContentDescription=await htmlRichContentConverter(jobDetails.jobAd.sections);
|
|
273
273
|
const jobLocation = fetchJobLocation(jobDetails);
|
|
274
274
|
const {applyLink , referFriendLink} = fetchApplyAndReferFriendLink(jobDetails);
|
|
275
|
+
|
|
276
|
+
|
|
275
277
|
const updatedJob = {
|
|
276
278
|
...job,
|
|
277
279
|
locationAddress: jobLocation,
|
|
278
|
-
jobDescription:
|
|
280
|
+
jobDescription: jobDetails.jobAd.sections,
|
|
279
281
|
applyLink: applyLink,
|
|
280
282
|
referFriendLink: referFriendLink,
|
|
281
283
|
};
|
|
@@ -484,11 +486,14 @@ async function syncJobsFast() {
|
|
|
484
486
|
await createCollections();
|
|
485
487
|
await clearCollections();
|
|
486
488
|
await fillSecretManagerMirror();
|
|
489
|
+
|
|
487
490
|
console.log("saving jobs data to CMS");
|
|
488
491
|
await saveJobsDataToCMS();
|
|
489
492
|
console.log("saved jobs data to CMS successfully");
|
|
493
|
+
|
|
490
494
|
console.log("saving jobs descriptions and location apply url to CMS");
|
|
491
495
|
await saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS();
|
|
496
|
+
|
|
492
497
|
console.log("saved jobs descriptions and location apply url to CMS successfully");
|
|
493
498
|
await aggregateJobs();
|
|
494
499
|
await referenceJobs();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const { fetch } = require('wix-fetch');
|
|
2
2
|
const { TEMPLATE_TYPE,TOKEN_NAME } = require('./collectionConsts');
|
|
3
3
|
const { getTokenFromCMS,getApiKeys } = require('./secretsData');
|
|
4
|
+
|
|
4
5
|
async function makeSmartRecruitersRequest(path,templateType) {
|
|
5
|
-
|
|
6
|
+
const baseUrl = 'https://api.smartrecruiters.com';
|
|
6
7
|
const fullUrl = `${baseUrl}${path}`;
|
|
7
8
|
|
|
8
9
|
try {
|
|
@@ -113,49 +114,11 @@ async function fetchJobDescription(jobId,testObject=undefined) {
|
|
|
113
114
|
return await makeSmartRecruitersRequest(`/v1/companies/${companyId}/postings/${jobId}`,templateType);
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
async function htmlRichContentConverter(sections) {
|
|
117
|
-
|
|
118
|
-
console.log("sections: are ",sections);
|
|
119
|
-
const richContentObject = {}
|
|
120
|
-
for (const section of sections) {
|
|
121
|
-
console.log("section: is ",section);
|
|
122
|
-
if (section.text) {
|
|
123
|
-
const raw = JSON.stringify({
|
|
124
|
-
content: section.text,
|
|
125
|
-
});
|
|
126
|
-
const requestOptions = {
|
|
127
|
-
method: 'post',
|
|
128
|
-
headers: {
|
|
129
|
-
'Content-Type': 'application/json',
|
|
130
|
-
Cookie: 'XSRF-TOKEN=1753949844|p--a7HsuVjR4',
|
|
131
|
-
Authorization: 'Bearer 2e19efe5f44d29d74480f5b744a5a90f19ba6ca7012ced19e7b14edb1ad6a641',
|
|
132
|
-
},
|
|
133
|
-
body: raw,
|
|
134
|
-
};
|
|
135
|
-
const response = await fetch(
|
|
136
|
-
'https://www.wixapis.com/data-sync/v1/abmp-content-converter',
|
|
137
|
-
requestOptions
|
|
138
|
-
);
|
|
139
|
-
if (response.ok) {
|
|
140
|
-
const data = await response.json();
|
|
141
|
-
console.log("response is ok")
|
|
142
|
-
richContentObject[section.title] = data.richContent.richContent;
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
throw new Error("Error converting html to rich content response: "+response);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
console.log("richContentObject: are ",richContentObject);
|
|
150
|
-
return richContentObject;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
117
|
|
|
154
118
|
|
|
155
119
|
|
|
156
120
|
module.exports = {
|
|
157
121
|
fetchPositionsFromSRAPI,
|
|
158
122
|
fetchJobDescription,
|
|
159
|
-
makeSmartRecruitersRequest
|
|
160
|
-
htmlRichContentConverter
|
|
123
|
+
makeSmartRecruitersRequest
|
|
161
124
|
};
|
package/package.json
CHANGED