sr-npm 1.7.534 → 1.7.536

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.
@@ -5,6 +5,8 @@ const COLLECTIONS = {
5
5
  TEMPLATE_TYPE: 'templateType',
6
6
  SECRET_MANAGER_MIRROR: 'SecretManagerMirror',
7
7
  BRANDS: 'Brands',
8
+ CUSTOM_VALUES:'CustomValues',
9
+ CUSTOM_FIELDS:'CustomFields',
8
10
  }
9
11
  const JOBS_COLLECTION_FIELDS = {
10
12
  LOCATION: 'location',
package/backend/data.js CHANGED
@@ -1,7 +1,7 @@
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
- const { COLLECTIONS, COLLECTIONS_FIELDS,JOBS_COLLECTION_FIELDS,TEMPLATE_TYPE,TOKEN_NAME } = require('./collectionConsts');
4
+ const { COLLECTIONS, COLLECTIONS_FIELDS,JOBS_COLLECTION_FIELDS,TEMPLATE_TYPE,TOKEN_NAME,CUSTOM_VALUES_COLLECTION_FIELDS,CUSTOM_FIELDS_COLLECTION_FIELDS } = require('./collectionConsts');
5
5
  const { chunkedBulkOperation, countJobsPerGivenField, fillCityLocationAndLocationAddress ,prepareToSaveArray,normalizeString} = require('./utils');
6
6
  const { getAllPositions } = require('./queries');
7
7
  const { retrieveSecretVal, getTokenFromCMS } = require('./secretsData');
@@ -96,6 +96,8 @@ async function saveJobsDataToCMS() {
96
96
  return basicJob;
97
97
  });
98
98
  console.log("customFields: ", customFields);
99
+ populateCustomFieldsCollection(customFields);
100
+ populateCustomValuesCollection(customFields);
99
101
  // Sort jobs by title (ascending, case-insensitive, numeric-aware)
100
102
  jobsData.sort((a, b) => {
101
103
  const titleA = a.title || '';
@@ -134,6 +136,21 @@ async function saveJobsDataToCMS() {
134
136
  console.log(`✓ All chunks processed. Total jobs saved: ${totalSaved}/${jobsData.length}`);
135
137
  }
136
138
 
139
+ function populateCustomFieldsCollection(customFields) {
140
+ for(const key of Object.keys(customFields)){
141
+ wixData.save(COLLECTIONS.CUSTOM_FIELDS, {
142
+ title: key,
143
+ });
144
+ }
145
+ }
146
+ function populateCustomValuesCollection(customFields) {
147
+ for(const key of Object.keys(customFields)){
148
+ wixData.save(COLLECTIONS.CUSTOM_VALUES, {
149
+ title: key,
150
+ customField: customFields[key],
151
+ });
152
+ }
153
+ }
137
154
  async function saveJobsDescriptionsAndLocationApplyUrlToCMS() {
138
155
  console.log('🚀 Starting job descriptions update process for ALL jobs');
139
156
 
@@ -291,6 +308,7 @@ async function referenceJobsToField({ referenceField, sourceCollection, jobField
291
308
  return rest;
292
309
  });
293
310
 
311
+
294
312
  // Bulk update in chunks of 1000
295
313
  const chunkSize = 1000;
296
314
  await chunkedBulkOperation({
@@ -362,6 +380,7 @@ async function referenceJobs() {
362
380
  await referenceJobsToField({ referenceField: JOBS_COLLECTION_FIELDS.DEPARTMENT_REF, sourceCollection: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT, jobField: JOBS_COLLECTION_FIELDS.DEPARTMENT });
363
381
  await referenceJobsToField({ referenceField: JOBS_COLLECTION_FIELDS.CITY, sourceCollection: COLLECTIONS.CITIES, jobField: JOBS_COLLECTION_FIELDS.CITY_TEXT });
364
382
  await referenceJobsToField({ referenceField: JOBS_COLLECTION_FIELDS.BRAND_REF, sourceCollection: COLLECTIONS.BRANDS, jobField: JOBS_COLLECTION_FIELDS.BRAND });
383
+ await referenceJobsToField({referenceField:JOBS_COLLECTION_FIELDS.CUSTOM_VALUES,sourceCollection:COLLECTIONS.CUSTOM_VALUES,jobField:JOBS_COLLECTION_FIELDS.CUSTOM_VALUES} )
365
384
  console.log("finished referencing jobs");
366
385
  }
367
386
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.534",
3
+ "version": "1.7.536",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {