sr-npm 1.7.263 → 1.7.265
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 +1 -27
- package/backend/fetchPositionsFromSRAPI.js +4 -3
- package/backend/secretsData.js +31 -0
- package/package.json +1 -1
package/backend/data.js
CHANGED
|
@@ -2,11 +2,9 @@ const { items: wixData, collections } = require('@wix/data');
|
|
|
2
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 } = require('./collectionConsts');
|
|
5
|
-
const { secrets } = require("@wix/secrets");
|
|
6
|
-
const { auth } = require('@wix/essentials');
|
|
7
5
|
const { chunkedBulkOperation, delay, countJobsPerGivenField, fillCityLocationAndLocationAddress ,prepareToSaveArray,normalizeCityName} = require('./utils');
|
|
8
6
|
const { getAllPositions } = require('./queries');
|
|
9
|
-
|
|
7
|
+
const { getSmartToken } = require('./secretsData');
|
|
10
8
|
|
|
11
9
|
function validatePosition(position) {
|
|
12
10
|
if (!position.id) {
|
|
@@ -289,29 +287,6 @@ function fetchJobLocation(jobDetails) {
|
|
|
289
287
|
}
|
|
290
288
|
|
|
291
289
|
|
|
292
|
-
function getSmartToken() {
|
|
293
|
-
const elevatedGetSecretValue = auth.elevate(secrets.getSecretValue);
|
|
294
|
-
return elevatedGetSecretValue("x-smarttoken")
|
|
295
|
-
.then((secret) => {
|
|
296
|
-
return secret;
|
|
297
|
-
})
|
|
298
|
-
.catch((error) => {
|
|
299
|
-
console.error(error);
|
|
300
|
-
throw error;
|
|
301
|
-
});
|
|
302
|
-
}
|
|
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
290
|
|
|
316
291
|
|
|
317
292
|
async function createApiKeyCollectionAndFillIt() {
|
|
@@ -389,5 +364,4 @@ module.exports = {
|
|
|
389
364
|
aggregateJobsByFieldToCMS,
|
|
390
365
|
referenceJobsToField,
|
|
391
366
|
createApiKeyCollectionAndFillIt,
|
|
392
|
-
getCompanyId
|
|
393
367
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const { fetch } = require('wix-fetch');
|
|
2
2
|
const { items: wixData } = require('@wix/data');
|
|
3
3
|
const { COLLECTIONS } = require('./collectionConsts');
|
|
4
|
-
const { getCompanyId } = require('./
|
|
4
|
+
const { getCompanyId } = require('./secretsData');
|
|
5
5
|
async function makeSmartRecruitersRequest(path,token) {
|
|
6
6
|
const baseUrl = 'https://api.smartrecruiters.com'; // PROD
|
|
7
7
|
// const baseUrl = 'https://bayank2.wixstudio.com/my-site-3//_functions'; // TEST
|
|
8
8
|
const fullUrl = `${baseUrl}${path}`;
|
|
9
9
|
|
|
10
|
-
//console.log(`Making request to: ${fullUrl}`);
|
|
10
|
+
//console.log(`Making request to: ${fullUrl}`);
|
|
11
11
|
try {
|
|
12
12
|
const response = await fetch(fullUrl, {
|
|
13
13
|
method: 'GET',
|
|
@@ -40,13 +40,14 @@ async function fetchPositionsFromSRAPI() {
|
|
|
40
40
|
const token = await getSmartTokenFromCMS();
|
|
41
41
|
const companyId=await getCompanyId();
|
|
42
42
|
console.log('Starting to fetch all positions with pagination...');
|
|
43
|
+
let offset=0;
|
|
43
44
|
|
|
44
45
|
do {
|
|
45
46
|
try {
|
|
46
47
|
page++;
|
|
47
48
|
|
|
48
49
|
// Build the API path - first request has no page parameter, subsequent use nextPageId
|
|
49
|
-
let apiPath = `/v1/companies/${companyId}/postings?offset
|
|
50
|
+
let apiPath = `/v1/companies/${companyId}/postings?offset=${offset}`;
|
|
50
51
|
if (nextPageId) {
|
|
51
52
|
apiPath += `&pageId=${nextPageId}`;
|
|
52
53
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const { secrets } = require("@wix/secrets");
|
|
2
|
+
const { auth } = require('@wix/essentials');
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function getSmartToken() {
|
|
6
|
+
const elevatedGetSecretValue = auth.elevate(secrets.getSecretValue);
|
|
7
|
+
return elevatedGetSecretValue("x-smarttoken")
|
|
8
|
+
.then((secret) => {
|
|
9
|
+
return secret;
|
|
10
|
+
})
|
|
11
|
+
.catch((error) => {
|
|
12
|
+
console.error(error);
|
|
13
|
+
throw error;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getCompanyId() {
|
|
18
|
+
const elevatedGetSecretValue = auth.elevate(secrets.getSecretValue);
|
|
19
|
+
return elevatedGetSecretValue("companyID")
|
|
20
|
+
.then((secret) => {
|
|
21
|
+
return secret;
|
|
22
|
+
})
|
|
23
|
+
.catch((error) => {
|
|
24
|
+
console.error(error);
|
|
25
|
+
throw error;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
module.exports = {
|
|
29
|
+
getSmartToken,
|
|
30
|
+
getCompanyId
|
|
31
|
+
};
|