sr-npm 1.7.457 → 1.7.458
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/consts.js +1 -12
- package/backend/data.js +4 -7
- package/backend/fetchPositionsFromSRAPI.js +15 -8
- package/backend/secretsData.js +1 -0
- package/package.json +1 -1
package/backend/consts.js
CHANGED
|
@@ -73,15 +73,6 @@ const TASKS = {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
const TEMPLATE_TYPE = {
|
|
77
|
-
INTERNAL: 'INTERNAL',
|
|
78
|
-
EXTERNAL: 'PUBLIC',
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const TOKEN_NAME = {
|
|
82
|
-
COMPANY_ID: 'companyId',
|
|
83
|
-
SMART_TOKEN: 'x-smarttoken',
|
|
84
|
-
}
|
|
85
76
|
|
|
86
77
|
const TASK_TYPE = {
|
|
87
78
|
SCHEDULED: 'scheduled',
|
|
@@ -92,7 +83,5 @@ const TASK_TYPE = {
|
|
|
92
83
|
TASKS_NAMES,
|
|
93
84
|
TASK_TYPE,
|
|
94
85
|
TASKS,
|
|
95
|
-
QUERY_MAX_LIMIT
|
|
96
|
-
TEMPLATE_TYPE,
|
|
97
|
-
TOKEN_NAME,
|
|
86
|
+
QUERY_MAX_LIMIT
|
|
98
87
|
};
|
package/backend/data.js
CHANGED
|
@@ -4,7 +4,6 @@ const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend
|
|
|
4
4
|
const { COLLECTIONS, COLLECTIONS_FIELDS,JOBS_COLLECTION_FIELDS } = require('./collectionConsts');
|
|
5
5
|
const { chunkedBulkOperation, countJobsPerGivenField, fillCityLocationAndLocationAddress ,prepareToSaveArray,normalizeCityName} = require('./utils');
|
|
6
6
|
const { getAllPositions } = require('./queries');
|
|
7
|
-
const{TEMPLATE_TYPE,TOKEN_NAME,TASK_TYPE} = require('./consts');
|
|
8
7
|
const { getCompanyId, getSmartToken } = require('./secretsData');
|
|
9
8
|
|
|
10
9
|
function validatePosition(position) {
|
|
@@ -347,18 +346,16 @@ async function clearCollections() {
|
|
|
347
346
|
}
|
|
348
347
|
|
|
349
348
|
async function markTemplateAsExternal() {
|
|
350
|
-
console.log("TEMPLATE_TYPE$#@#$$@#@#$",TEMPLATE_TYPE);
|
|
351
|
-
console.log("TASK_TYPE$#@#$$@#@#$",TASK_TYPE);
|
|
352
349
|
await createCollectionIfMissing(COLLECTIONS.TEMPLATE_TYPE, COLLECTIONS_FIELDS.TEMPLATE_TYPE,null,'singleItem');
|
|
353
350
|
await wixData.save(COLLECTIONS.TEMPLATE_TYPE, {
|
|
354
|
-
templateType:
|
|
351
|
+
templateType: "PUBLIC"
|
|
355
352
|
});
|
|
356
353
|
}
|
|
357
354
|
|
|
358
355
|
async function markTemplateAsInternal() {
|
|
359
356
|
await createCollectionIfMissing(COLLECTIONS.TEMPLATE_TYPE, COLLECTIONS_FIELDS.TEMPLATE_TYPE,null,'singleItem');
|
|
360
357
|
await wixData.save(COLLECTIONS.TEMPLATE_TYPE, {
|
|
361
|
-
templateType:
|
|
358
|
+
templateType: "INTERNAL"
|
|
362
359
|
});
|
|
363
360
|
}
|
|
364
361
|
|
|
@@ -367,14 +364,14 @@ async function fillSecretManagerMirror() {
|
|
|
367
364
|
const companyId = await getCompanyId();
|
|
368
365
|
console.log("companyId is : ", companyId);
|
|
369
366
|
await wixData.insert(COLLECTIONS.SECRET_MANAGER_MIRROR, {
|
|
370
|
-
tokenName:
|
|
367
|
+
tokenName: "companyId",
|
|
371
368
|
tokenValue: companyId.value
|
|
372
369
|
});
|
|
373
370
|
console.log("companyId inserted into the SecretManagerMirror collection");
|
|
374
371
|
try{
|
|
375
372
|
const token = await getSmartToken();
|
|
376
373
|
await wixData.insert(COLLECTIONS.SECRET_MANAGER_MIRROR, {
|
|
377
|
-
tokenName:
|
|
374
|
+
tokenName: "x-smarttoken",
|
|
378
375
|
tokenValue: token.value
|
|
379
376
|
});
|
|
380
377
|
console.log("x-smarttoken inserted into the SecretManagerMirror collection");
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const { fetch } = require('wix-fetch');
|
|
2
2
|
const { items: wixData } = require('@wix/data');
|
|
3
3
|
const { COLLECTIONS } = require('./collectionConsts');
|
|
4
|
-
const { TEMPLATE_TYPE,TOKEN_NAME } = require('./consts');
|
|
5
4
|
|
|
6
5
|
async function makeSmartRecruitersRequest(path,templateType) {
|
|
7
6
|
const baseUrl = 'https://api.smartrecruiters.com';
|
|
@@ -15,8 +14,8 @@ async function makeSmartRecruitersRequest(path,templateType) {
|
|
|
15
14
|
'Cookie': 'AWSALB=GYltFw3fLKortMxHR5vIOT1CuUROyhWNIX/qL8ZnPl1/8mhOcnIsBKYslzmNJPEzSy/jvNbO+6tXpH8yqcpQJagYt57MhbKlLqTSzoNq1G/w7TjOxPGR3UTdXW0d; AWSALBCORS=GYltFw3fLKortMxHR5vIOT1CuUROyhWNIX/qL8ZnPl1/8mhOcnIsBKYslzmNJPEzSy/jvNbO+6tXpH8yqcpQJagYt57MhbKlLqTSzoNq1G/w7TjOxPGR3UTdXW0d'
|
|
16
15
|
};
|
|
17
16
|
//here is the only place where we check templateType
|
|
18
|
-
if (templateType ===
|
|
19
|
-
const smartToken = await
|
|
17
|
+
if (templateType === 'INTERNAL') {
|
|
18
|
+
const smartToken = await getSmartTokenFromCMS();
|
|
20
19
|
headers['x-smarttoken'] = smartToken;
|
|
21
20
|
}
|
|
22
21
|
const response = await fetch(fullUrl, {
|
|
@@ -106,13 +105,21 @@ async function fetchJobDescription(jobId) {
|
|
|
106
105
|
return await makeSmartRecruitersRequest(`/v1/companies/${companyId}/postings/${jobId}`,templateType);
|
|
107
106
|
}
|
|
108
107
|
|
|
108
|
+
async function getCompanyIdFromCMS() {
|
|
109
|
+
const result = await wixData.query(COLLECTIONS.SECRET_MANAGER_MIRROR).eq('tokenName','companyId').find();
|
|
110
|
+
if (result.items.length > 0) {
|
|
111
|
+
return result.items[0].tokenValue;
|
|
112
|
+
} else {
|
|
113
|
+
throw new Error('[getCompanyIdFromCMS], No companyId found');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
109
116
|
|
|
110
|
-
async function
|
|
111
|
-
const result = await wixData.query(COLLECTIONS.SECRET_MANAGER_MIRROR).eq('tokenName',
|
|
117
|
+
async function getSmartTokenFromCMS() {
|
|
118
|
+
const result = await wixData.query(COLLECTIONS.SECRET_MANAGER_MIRROR).eq('tokenName','x-smarttoken').find();
|
|
112
119
|
if (result.items.length > 0) {
|
|
113
120
|
return result.items[0].tokenValue;
|
|
114
121
|
} else {
|
|
115
|
-
throw new Error(
|
|
122
|
+
throw new Error('[getSmartTokenFromCMS], No smarttoken found');
|
|
116
123
|
}
|
|
117
124
|
}
|
|
118
125
|
async function getTemplateTypeFromCMS() {
|
|
@@ -125,7 +132,7 @@ async function getTemplateTypeFromCMS() {
|
|
|
125
132
|
}
|
|
126
133
|
|
|
127
134
|
async function getApiKeys() {
|
|
128
|
-
const companyId = await
|
|
135
|
+
const companyId = await getCompanyIdFromCMS();
|
|
129
136
|
const templateType = await getTemplateTypeFromCMS();
|
|
130
137
|
return {companyId,templateType};
|
|
131
138
|
}
|
|
@@ -133,5 +140,5 @@ async function getApiKeys() {
|
|
|
133
140
|
module.exports = {
|
|
134
141
|
fetchPositionsFromSRAPI,
|
|
135
142
|
fetchJobDescription,
|
|
136
|
-
|
|
143
|
+
getCompanyIdFromCMS
|
|
137
144
|
};
|
package/backend/secretsData.js
CHANGED