sr-npm 1.7.470 → 1.7.471
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 -23
- package/backend/fetchPositionsFromSRAPI.js +1 -1
- package/backend/secretsData.js +28 -3
- package/package.json +1 -1
package/backend/data.js
CHANGED
|
@@ -377,28 +377,8 @@ async function fillSecretManagerMirror() {
|
|
|
377
377
|
console.log("Error creating SecretManagerMirror collection:", error);
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
|
-
async function getTokenFromCMS(tokenName) {
|
|
381
|
-
const result = await wixData.query(COLLECTIONS.SECRET_MANAGER_MIRROR).eq('tokenName',tokenName).find();
|
|
382
|
-
if (result.items.length > 0) {
|
|
383
|
-
return result.items[0].tokenValue;
|
|
384
|
-
} else {
|
|
385
|
-
throw new Error(`[getTokenFromCMS], No ${tokenName} found`);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
async function getTemplateTypeFromCMS() {
|
|
389
|
-
const result = await wixData.query(COLLECTIONS.TEMPLATE_TYPE).limit(1).find();
|
|
390
|
-
if (result.items.length > 0) {
|
|
391
|
-
return result.items[0].templateType;
|
|
392
|
-
} else {
|
|
393
|
-
throw new Error('[getTemplateTypeFromCMS], No templateType found');
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
380
|
|
|
397
|
-
|
|
398
|
-
const companyId = await getTokenFromCMS(TOKEN_NAME.COMPANY_ID);
|
|
399
|
-
const templateType = await getTemplateTypeFromCMS();
|
|
400
|
-
return {companyId,templateType};
|
|
401
|
-
}
|
|
381
|
+
|
|
402
382
|
|
|
403
383
|
|
|
404
384
|
module.exports = {
|
|
@@ -413,6 +393,4 @@ module.exports = {
|
|
|
413
393
|
fillSecretManagerMirror,
|
|
414
394
|
markTemplateAsExternal,
|
|
415
395
|
markTemplateAsInternal,
|
|
416
|
-
getApiKeys,
|
|
417
|
-
getTokenFromCMS,
|
|
418
396
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { fetch } = require('wix-fetch');
|
|
2
2
|
const { TEMPLATE_TYPE,TOKEN_NAME } = require('./collectionConsts');
|
|
3
|
-
const { getApiKeys
|
|
3
|
+
const { getTokenFromCMS,getApiKeys } = require('./secretsData');
|
|
4
4
|
async function makeSmartRecruitersRequest(path,templateType) {
|
|
5
5
|
const baseUrl = 'https://api.smartrecruiters.com';
|
|
6
6
|
const fullUrl = `${baseUrl}${path}`;
|
package/backend/secretsData.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { secrets } = require("@wix/secrets");
|
|
2
2
|
const { auth } = require('@wix/essentials');
|
|
3
|
-
const {
|
|
4
|
-
const { TOKEN_NAME } = require('./collectionConsts');
|
|
3
|
+
const { items: wixData } = require('@wix/data');
|
|
4
|
+
const { COLLECTIONS,TOKEN_NAME } = require('./collectionConsts');
|
|
5
5
|
|
|
6
6
|
const getSecretValue = auth.elevate(secrets.getSecretValue);
|
|
7
7
|
|
|
@@ -26,7 +26,32 @@ function getSmartToken() {
|
|
|
26
26
|
})
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
async function getTokenFromCMS(tokenName) {
|
|
30
|
+
const result = await wixData.query(COLLECTIONS.SECRET_MANAGER_MIRROR).eq('tokenName',tokenName).find();
|
|
31
|
+
if (result.items.length > 0) {
|
|
32
|
+
return result.items[0].tokenValue;
|
|
33
|
+
} else {
|
|
34
|
+
throw new Error(`[getTokenFromCMS], No ${tokenName} found`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function getTemplateTypeFromCMS() {
|
|
38
|
+
const result = await wixData.query(COLLECTIONS.TEMPLATE_TYPE).limit(1).find();
|
|
39
|
+
if (result.items.length > 0) {
|
|
40
|
+
return result.items[0].templateType;
|
|
41
|
+
} else {
|
|
42
|
+
throw new Error('[getTemplateTypeFromCMS], No templateType found');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function getApiKeys() {
|
|
47
|
+
const companyId = await getTokenFromCMS(TOKEN_NAME.COMPANY_ID);
|
|
48
|
+
const templateType = await getTemplateTypeFromCMS();
|
|
49
|
+
return {companyId,templateType};
|
|
50
|
+
}
|
|
51
|
+
|
|
29
52
|
module.exports = {
|
|
30
53
|
getCompanyId,
|
|
31
|
-
getSmartToken
|
|
54
|
+
getSmartToken,
|
|
55
|
+
getTokenFromCMS,
|
|
56
|
+
getApiKeys
|
|
32
57
|
};
|