sr-npm 1.7.15 → 1.7.17
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 +48 -0
- package/backend/consts.js +1 -43
- package/backend/data.js +5 -7
- package/package.json +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const COLLECTIONS = {
|
|
2
|
+
AMOUNT_OF_JOBS_PER_DEPARTMENT: 'AmountOfJobsPerDepartment',
|
|
3
|
+
CITIES: 'cities',
|
|
4
|
+
JOBS: 'Jobs',
|
|
5
|
+
API_KEY: 'ApiKey',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const COLLECTIONS_FIELDS = {
|
|
9
|
+
AMOUNT_OF_JOBS_PER_DEPARTMENT: [
|
|
10
|
+
{key:'title', type: 'TEXT'},
|
|
11
|
+
{ key: 'count', type: 'NUMBER' },
|
|
12
|
+
],
|
|
13
|
+
CITIES: [
|
|
14
|
+
{key:'title', type: 'TEXT'},
|
|
15
|
+
{ key: 'regionCode', type: 'TEXT' },
|
|
16
|
+
{ key: 'city', type: 'TEXT' },
|
|
17
|
+
{key:'location', type: 'OBJECT'},
|
|
18
|
+
{key:'count', type: 'NUMBER'},
|
|
19
|
+
{key:'country', type: 'TEXT'},
|
|
20
|
+
{key:'remote', type: 'TEXT'},
|
|
21
|
+
{key:'countryCode', type: 'TEXT'},
|
|
22
|
+
{key:'manual', type: 'TEXT'},
|
|
23
|
+
{key:'region', type: 'TEXT'},
|
|
24
|
+
{key:'latitude', type: 'NUMBER'},
|
|
25
|
+
{key:'longitude', type: 'NUMBER'},
|
|
26
|
+
],
|
|
27
|
+
JOBS: [
|
|
28
|
+
{key:'location', type: 'OBJECT'},
|
|
29
|
+
{key:'postingStatus', type: 'TEXT'},
|
|
30
|
+
{key:'country', type: 'TEXT'},
|
|
31
|
+
{key:'department', type: 'TEXT'},
|
|
32
|
+
{key:'language', type: 'TEXT'},
|
|
33
|
+
{key:'jobDescription', type: 'OBJECT'},
|
|
34
|
+
{key:'cityText', type: 'TEXT'},
|
|
35
|
+
{key:'departmentref', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: 'AmountOfJobsPerDepartment' } } },
|
|
36
|
+
{key:'city', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: 'cities' } } },
|
|
37
|
+
],
|
|
38
|
+
API_KEY: [
|
|
39
|
+
{key:'token', type: 'TEXT'},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
module.exports = {
|
|
46
|
+
COLLECTIONS,
|
|
47
|
+
COLLECTIONS_FIELDS,
|
|
48
|
+
};
|
package/backend/consts.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const {saveDataJobsToCMS,saveJobsDescriptionsAndLocationToCMS,aggregateJobsByFieldToCMS,referenceJobsToField,createApiKeyCollectionAndFillIt} = require('./data');
|
|
2
2
|
const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
|
|
3
|
+
const { COLLECTIONS, COLLECTIONS_FIELDS } = require('./collectionConsts');
|
|
3
4
|
const TASKS_NAMES = {
|
|
4
5
|
SYNC_JOBS: 'syncJobsFromSRAPIToCMS',
|
|
5
6
|
INSERT_JOBS_TO_CMS: 'insertJobsToCMS',
|
|
@@ -104,47 +105,6 @@ const TASKS = {
|
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
const COLLECTIONS = {
|
|
108
|
-
AMOUNT_OF_JOBS_PER_DEPARTMENT: 'AmountOfJobsPerDepartment',
|
|
109
|
-
CITIES: 'cities',
|
|
110
|
-
JOBS: 'Jobs',
|
|
111
|
-
API_KEY: 'ApiKey',
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const COLLECTIONS_FIELDS = {
|
|
115
|
-
AMOUNT_OF_JOBS_PER_DEPARTMENT: [
|
|
116
|
-
{key:'title', type: 'TEXT'},
|
|
117
|
-
{ key: 'count', type: 'NUMBER' },
|
|
118
|
-
],
|
|
119
|
-
CITIES: [
|
|
120
|
-
{key:'title', type: 'TEXT'},
|
|
121
|
-
{ key: 'regionCode', type: 'TEXT' },
|
|
122
|
-
{ key: 'city', type: 'TEXT' },
|
|
123
|
-
{key:'location', type: 'OBJECT'},
|
|
124
|
-
{key:'count', type: 'NUMBER'},
|
|
125
|
-
{key:'country', type: 'TEXT'},
|
|
126
|
-
{key:'remote', type: 'TEXT'},
|
|
127
|
-
{key:'countryCode', type: 'TEXT'},
|
|
128
|
-
{key:'manual', type: 'TEXT'},
|
|
129
|
-
{key:'region', type: 'TEXT'},
|
|
130
|
-
{key:'latitude', type: 'NUMBER'},
|
|
131
|
-
{key:'longitude', type: 'NUMBER'},
|
|
132
|
-
],
|
|
133
|
-
JOBS: [
|
|
134
|
-
{key:'location', type: 'OBJECT'},
|
|
135
|
-
{key:'postingStatus', type: 'TEXT'},
|
|
136
|
-
{key:'country', type: 'TEXT'},
|
|
137
|
-
{key:'department', type: 'TEXT'},
|
|
138
|
-
{key:'language', type: 'TEXT'},
|
|
139
|
-
{key:'jobDescription', type: 'OBJECT'},
|
|
140
|
-
{key:'cityText', type: 'TEXT'},
|
|
141
|
-
{key:'departmentref', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: 'AmountOfJobsPerDepartment' } } },
|
|
142
|
-
{key:'city', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: 'cities' } } },
|
|
143
|
-
],
|
|
144
|
-
API_KEY: [
|
|
145
|
-
{key:'token', type: 'TEXT'},
|
|
146
|
-
],
|
|
147
|
-
};
|
|
148
108
|
|
|
149
109
|
|
|
150
110
|
const TASK_TYPE = {
|
|
@@ -156,6 +116,4 @@ const TASK_TYPE = {
|
|
|
156
116
|
TASKS_NAMES,
|
|
157
117
|
TASK_TYPE,
|
|
158
118
|
TASKS,
|
|
159
|
-
COLLECTIONS,
|
|
160
|
-
COLLECTIONS_FIELDS,
|
|
161
119
|
};
|
package/backend/data.js
CHANGED
|
@@ -2,7 +2,7 @@ const { items: wixData } = require('@wix/data');
|
|
|
2
2
|
const { fetchPositionsFromSRAPI, fetchJobDescription } = require('./fetchPositionsFromSRAPI');
|
|
3
3
|
const { chunkedBulkOperation } = require('./utils');
|
|
4
4
|
const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
|
|
5
|
-
const { COLLECTIONS, COLLECTIONS_FIELDS } = require('./
|
|
5
|
+
const { COLLECTIONS, COLLECTIONS_FIELDS } = require('./collectionConsts');
|
|
6
6
|
const { secrets } = require("wix-secrets-backend.v2");
|
|
7
7
|
const { elevate } = require("wix-auth");
|
|
8
8
|
|
|
@@ -334,16 +334,14 @@ function getSmartToken() {
|
|
|
334
334
|
|
|
335
335
|
async function createApiKeyCollectionAndFillIt() {
|
|
336
336
|
console.log("Creating ApiKey collection and filling it with the smart token");
|
|
337
|
-
console.log("COLLECTIONS ", COLLECTIONS);
|
|
338
|
-
console.log("COLLECTIONS_FIELDS ", COLLECTIONS_FIELDS);
|
|
339
337
|
await createCollectionIfMissing(COLLECTIONS.API_KEY, COLLECTIONS_FIELDS.API_KEY);
|
|
340
338
|
console.log("Getting the smart token");
|
|
341
339
|
const token = await getSmartToken();
|
|
342
340
|
console.log("Inserting the smart token into the ApiKey collection");
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
341
|
+
await wixData.insert("ApiKey", {
|
|
342
|
+
token: token
|
|
343
|
+
});
|
|
344
|
+
|
|
347
345
|
console.log("Smart token inserted into the ApiKey collection");
|
|
348
346
|
}
|
|
349
347
|
|