sr-npm 1.7.64 → 1.7.66

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.
@@ -4,7 +4,32 @@ const COLLECTIONS = {
4
4
  JOBS: 'Jobs1',
5
5
  API_KEY: 'ApiKey',
6
6
  }
7
-
7
+ const JOBS_COLLECTION_FIELDS = {
8
+ LOCATION: 'location',
9
+ TITLE: 'title',
10
+ LOCATION_ADDRESS: 'locationAddress',
11
+ POSTING_STATUS: 'postingStatus',
12
+ COUNTRY: 'country',
13
+ DEPARTMENT: 'department',
14
+ LANGUAGE: 'language',
15
+ REMOTE: 'remote',
16
+ JOB_DESCRIPTION: 'jobDescription',
17
+ DEPARTMENT_REF: 'departmentRef',
18
+ CITY: 'city',
19
+ CITY_TEXT: 'cityText',
20
+ }
21
+ const AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION_FIELDS = {
22
+ TITLE: 'title',
23
+ COUNT: 'count',
24
+ IMAGE: 'image',
25
+ }
26
+ const CITIES_COLLECTION_FIELDS = {
27
+ TITLE: 'title',
28
+ CITY: 'city',
29
+ LOCATION_ADDRESS: 'locationAddress',
30
+ COUNT: 'count',
31
+ COUNTRY: 'country',
32
+ }
8
33
  const COLLECTIONS_FIELDS = {
9
34
  AMOUNT_OF_JOBS_PER_DEPARTMENT: [
10
35
  {key:'title', type: 'TEXT'},
@@ -41,4 +66,7 @@ const COLLECTIONS_FIELDS = {
41
66
  module.exports = {
42
67
  COLLECTIONS,
43
68
  COLLECTIONS_FIELDS,
69
+ JOBS_COLLECTION_FIELDS,
70
+ AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION_FIELDS,
71
+ CITIES_COLLECTION_FIELDS,
44
72
  };
package/backend/consts.js CHANGED
@@ -6,7 +6,7 @@ const {
6
6
  createApiKeyCollectionAndFillIt,
7
7
  } = require('./data');
8
8
  const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
9
- const { COLLECTIONS, COLLECTIONS_FIELDS } = require('./collectionConsts');
9
+ const { COLLECTIONS, COLLECTIONS_FIELDS, JOBS_COLLECTION_FIELDS } = require('./collectionConsts');
10
10
 
11
11
  const QUERY_MAX_LIMIT = 1000;
12
12
 
@@ -86,7 +86,7 @@ const TASKS = {
86
86
  getIdentifier: () => 'SHOULD_NEVER_SKIP',
87
87
  process: () =>
88
88
  aggregateJobsByFieldToCMS({
89
- field: COLLECTIONS_FIELDS.JOBS[9].key,
89
+ field: JOBS_COLLECTION_FIELDS.CITY_TEXT,
90
90
  collection: COLLECTIONS.CITIES,
91
91
  }),
92
92
  shouldSkipCheck: () => false,
@@ -97,7 +97,7 @@ const TASKS = {
97
97
  getIdentifier: () => 'SHOULD_NEVER_SKIP',
98
98
  process: () =>
99
99
  aggregateJobsByFieldToCMS({
100
- field: COLLECTIONS_FIELDS.JOBS[5].key,
100
+ field: JOBS_COLLECTION_FIELDS.DEPARTMENT,
101
101
  collection: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT,
102
102
  }),
103
103
  shouldSkipCheck: () => false,
@@ -108,9 +108,9 @@ const TASKS = {
108
108
  getIdentifier: () => 'SHOULD_NEVER_SKIP',
109
109
  process: () =>
110
110
  referenceJobsToField({
111
- referenceField: COLLECTIONS_FIELDS.JOBS[11].key,
111
+ referenceField: JOBS_COLLECTION_FIELDS.CITY,
112
112
  sourceCollection: COLLECTIONS.CITIES,
113
- jobField: COLLECTIONS_FIELDS.JOBS[9].key,
113
+ jobField: JOBS_COLLECTION_FIELDS.CITY_TEXT,
114
114
  }),
115
115
  shouldSkipCheck: () => false,
116
116
  estimatedDurationSec: 3,
@@ -120,9 +120,9 @@ const TASKS = {
120
120
  getIdentifier: () => 'SHOULD_NEVER_SKIP',
121
121
  process: () =>
122
122
  referenceJobsToField({
123
- referenceField: COLLECTIONS_FIELDS.JOBS[10].key,
123
+ referenceField: JOBS_COLLECTION_FIELDS.DEPARTMENT_REF,
124
124
  sourceCollection: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT,
125
- jobField: COLLECTIONS_FIELDS.JOBS[5].key,
125
+ jobField: JOBS_COLLECTION_FIELDS.DEPARTMENT,
126
126
  }),
127
127
  shouldSkipCheck: () => false,
128
128
  estimatedDurationSec: 3,
package/backend/data.js CHANGED
@@ -8,11 +8,27 @@ const { chunkedBulkOperation, delay, countJobsPerGivenField, fillCityLocationAnd
8
8
  const { getAllPositions } = require('./queries');
9
9
 
10
10
 
11
+ function validatePosition(position) {
12
+ if (!position.id) {
13
+ throw new Error('Position id is required');
14
+ }
15
+ if (!position.title) {
16
+ throw new Error('Position title is required');
17
+ }
18
+ if (!position.department || !position.department.label) {
19
+ throw new Error('Position department is required and must have a label');
20
+ }
21
+ if (!position.location || !position.location.city || !position.location.remote) {
22
+ throw new Error('Position location is required and must have a city and remote');
23
+ }
24
+
25
+ }
11
26
 
12
27
  async function saveJobsDataToCMS() {
13
28
  const positions = await fetchPositionsFromSRAPI();
14
29
  // bulk insert to jobs collection without descriptions first
15
30
  const jobsData = positions.content.map(position => {
31
+ validatePosition(position);
16
32
  const basicJob = {
17
33
  _id: position.id,
18
34
  title: position.title,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.64",
3
+ "version": "1.7.66",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/pages/index.js ADDED
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ ...require('./positionPage'),
3
+ };
4
+
@@ -0,0 +1,34 @@
1
+ const {
2
+ htmlToText,
3
+ } = require('../public/utils');
4
+
5
+ async function positionPageOnReady(_$w) {
6
+
7
+ bind(_$w);
8
+ }
9
+
10
+ async function bind(_$w) {
11
+ _$w('#datasetJobsItem').onReady(async () => {
12
+
13
+ const item = await _$w('#datasetJobsItem').getCurrentItem();
14
+
15
+ _$w('#companyDescriptionText').text = htmlToText(item.jobDescription.companyDescription.text);
16
+ _$w('#responsibilitiesText').text = htmlToText(item.jobDescription.jobDescription.text);
17
+ _$w('#qualificationsText').text = htmlToText(item.jobDescription.qualifications.text);
18
+ _$w('#relatedJobsTitleText').text = `More ${item.department} Positions`;
19
+ });
20
+
21
+ _$w('#relatedJobsDataset').onReady(async () => {
22
+ const count = await _$w('#relatedJobsDataset').getTotalCount();
23
+ if(!count){
24
+ _$w('#relatedJobsSection').collapse();
25
+ }
26
+ });
27
+ }
28
+
29
+
30
+
31
+ module.exports = {
32
+ positionPageOnReady,
33
+ };
34
+
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ ...require('./utils'),
3
+ };
4
+
@@ -0,0 +1,28 @@
1
+
2
+
3
+ function htmlToText(html) {
4
+ if (!html) return '';
5
+
6
+ // Remove HTML tags and decode entities
7
+ let text = html
8
+ .replace(/<br\s*\/?>/gi, '\n')
9
+ .replace(/<\/?(p|div|h[1-6])\s*\/?>/gi, '\n')
10
+ .replace(/<li[^>]*>/gi, '• ')
11
+ .replace(/<\/li>/gi, '\n')
12
+ .replace(/<[^>]*>/g, '')
13
+ .replace(/&amp;/g, '&')
14
+ .replace(/&lt;/g, '<')
15
+ .replace(/&gt;/g, '>')
16
+ .replace(/&quot;/g, '"')
17
+ .replace(/&#39;/g, "'")
18
+ .replace(/&nbsp;/g, ' ');
19
+
20
+ console.log(text);
21
+ // Clean up whitespace
22
+ return text.replace(/\n\s*\n+/g, '\n\n').replace(/[ \t]+\n/g, '\n').trim();
23
+ }
24
+
25
+
26
+ module.exports = {
27
+ htmlToText
28
+ };