sr-npm 3.1.3 → 3.1.4
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/collectionConsts.js +2 -0
- package/backend/data.js +11 -3
- package/backend/utils.js +7 -1
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ const COLLECTIONS = {
|
|
|
14
14
|
const JOBS_COLLECTION_FIELDS = {
|
|
15
15
|
LOCATION: 'location',
|
|
16
16
|
TITLE: 'title',
|
|
17
|
+
SLUG: 'slug',
|
|
17
18
|
LOCATION_ADDRESS: 'locationAddress',
|
|
18
19
|
COUNTRY: 'country',
|
|
19
20
|
DEPARTMENT: 'department',
|
|
@@ -77,6 +78,7 @@ const COLLECTIONS_FIELDS = {
|
|
|
77
78
|
JOBS: [
|
|
78
79
|
{key:'location', type: 'OBJECT'},
|
|
79
80
|
{key:'title', type: 'TEXT'},
|
|
81
|
+
{key:'slug', type: 'TEXT'},
|
|
80
82
|
{key:'locationAddress', type: 'ADDRESS'},
|
|
81
83
|
{key:'country', type: 'TEXT'},
|
|
82
84
|
{key:'department', type: 'TEXT'},
|
package/backend/data.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
const { items: wixData } = require('@wix/data');
|
|
2
2
|
const { fetchPositionsFromSRAPI, fetchJobDescription } = require('./fetchPositionsFromSRAPI');
|
|
3
3
|
const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
|
|
4
|
-
|
|
5
|
-
const { chunkedBulkOperation, countJobsPerGivenField, fillCityLocationAndLocationAddress ,prepareToSaveArray,normalizeString} = require('./utils');
|
|
4
|
+
|
|
6
5
|
const { getAllPositions } = require('./queries');
|
|
7
6
|
const { retrieveSecretVal, getTokenFromCMS ,getApiKeys} = require('./secretsData');
|
|
7
|
+
const { COLLECTIONS, COLLECTIONS_FIELDS,JOBS_COLLECTION_FIELDS,TEMPLATE_TYPE,TOKEN_NAME,CUSTOM_VALUES_COLLECTION_FIELDS } = require('./collectionConsts');
|
|
8
|
+
const { chunkedBulkOperation,
|
|
9
|
+
countJobsPerGivenField,
|
|
10
|
+
fillCityLocationAndLocationAddress,
|
|
11
|
+
prepareToSaveArray,
|
|
12
|
+
normalizeString,
|
|
13
|
+
generateSlug}
|
|
14
|
+
= require('./utils');
|
|
8
15
|
|
|
9
16
|
let customValuesToJobs = {}
|
|
10
17
|
let locationToJobs = {}
|
|
@@ -110,7 +117,7 @@ async function saveJobsDataToCMS() {
|
|
|
110
117
|
const customFieldsLabels = {}
|
|
111
118
|
const customFieldsValues = {}
|
|
112
119
|
|
|
113
|
-
const {companyId,templateType} = await getApiKeys();
|
|
120
|
+
const {companyId ,templateType} = await getApiKeys();
|
|
114
121
|
if(siteconfig===undefined) {
|
|
115
122
|
await getSiteConfig();
|
|
116
123
|
}
|
|
@@ -120,6 +127,7 @@ async function saveJobsDataToCMS() {
|
|
|
120
127
|
const basicJob = {
|
|
121
128
|
_id: position.id,
|
|
122
129
|
title: position.name || '',
|
|
130
|
+
slug: generateSlug(position.name || ''),
|
|
123
131
|
department: position.department?.label || 'Other',
|
|
124
132
|
cityText: normalizeString(position.location?.city),
|
|
125
133
|
location: position.location && Object.keys(position.location).length > 0
|
package/backend/utils.js
CHANGED
|
@@ -65,6 +65,12 @@ function normalizeString(str) {
|
|
|
65
65
|
.trim();
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
function generateSlug(title){
|
|
69
|
+
return title
|
|
70
|
+
.replace(/[^a-zA-Z0-9-]+/g, "-") // allow uppercase AND lowercase letters
|
|
71
|
+
.replace(/-+/g, "-") // collapse multiple hyphens
|
|
72
|
+
.replace(/^-|-$/g, ""); // remove leading/trailing hyphens
|
|
73
|
+
}
|
|
68
74
|
|
|
69
75
|
|
|
70
76
|
module.exports = {
|
|
@@ -74,5 +80,5 @@ module.exports = {
|
|
|
74
80
|
fillCityLocationAndLocationAddress,
|
|
75
81
|
prepareToSaveArray,
|
|
76
82
|
normalizeString,
|
|
77
|
-
|
|
83
|
+
generateSlug,
|
|
78
84
|
};
|