sr-npm 1.7.565 → 1.7.567

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.
@@ -7,6 +7,8 @@ const COLLECTIONS = {
7
7
  BRANDS: 'Brands',
8
8
  CUSTOM_VALUES:'CustomValues',
9
9
  CUSTOM_FIELDS:'CustomFields',
10
+ SITE_CONFIGS: 'SiteConfigs',
11
+
10
12
  }
11
13
  const JOBS_COLLECTION_FIELDS = {
12
14
  LOCATION: 'location',
@@ -86,6 +88,10 @@ const COLLECTIONS_FIELDS = {
86
88
  TEMPLATE_TYPE: [
87
89
  {key:'templateType', type: 'TEXT'},
88
90
  ],
91
+ SITE_CONFIGS: [
92
+ {key:'onlyBrandKeywordUrlParams', type: 'TEXT'},
93
+ {key:'customFields', type: 'TEXT'},
94
+ ],
89
95
  SECRET_MANAGER_MIRROR: [
90
96
  {key:'tokenName', type: 'TEXT'},
91
97
  {key:'value', type: 'TEXT'},
package/backend/data.js CHANGED
@@ -9,11 +9,18 @@ const { retrieveSecretVal, getTokenFromCMS } = require('./secretsData');
9
9
 
10
10
  let jobToCustomValues = {}
11
11
  let customValuesToJobs = {}
12
+ let siteconfig;
13
+ const EXCLUDED_CUSTOM_FIELDS = new Set(["Country", "Department", "Brands"]);
12
14
 
13
15
  function getBrand(customField) {
14
16
  return customField.find(field => field.fieldLabel === 'Brands')?.valueLabel;
15
17
  }
16
18
 
19
+ async function getSiteConfig() {
20
+ const queryresult = await wixData.query(COLLECTIONS.SITE_CONFIGS).find();
21
+ siteconfig = queryresult.items[0];
22
+ console.log("siteconfig: ", siteconfig);
23
+ }
17
24
  function validatePosition(position) {
18
25
  if (!position.id) {
19
26
  throw new Error('Position id is required');
@@ -59,10 +66,9 @@ function validateSingleDesiredBrand(desiredBrand) {
59
66
  function getCustomFieldsAndValuesFromPosition(position,customFieldsLabels,customFieldsValues) {
60
67
  const customFieldsArray = Array.isArray(position?.customField) ? position.customField : [];
61
68
  for (const field of customFieldsArray) {
62
- if(field.fieldLabel==="Country" || field.fieldLabel==="Department" || field.fieldLabel==="Brands") continue; //country and department are not custom fields, they are already in the job object
63
- const label = field.fieldLabel
69
+ if(EXCLUDED_CUSTOM_FIELDS.has(field.fieldLabel)) continue; //country and department are not custom fields, they are already in the job object
64
70
  const fieldId=normalizeString(field.fieldId)
65
- const fieldLabel = label;
71
+ const fieldLabel = field.fieldLabel;
66
72
  const valueId=normalizeString(field.valueId)
67
73
  const valueLabel = field.valueLabel
68
74
  customFieldsLabels[fieldId] = fieldLabel
@@ -113,9 +119,14 @@ async function saveJobsDataToCMS() {
113
119
  getCustomFieldsAndValuesFromPosition(position,customFieldsLabels,customFieldsValues);
114
120
  return basicJob;
115
121
  });
116
-
122
+ if(siteconfig===undefined) {
123
+ siteconfig = await getSiteConfig();
124
+ }
125
+ console.log("siteconfig is @#!#!@!@$##!@: ", siteconfig);
126
+ if (siteconfig.customFields==="true") {
117
127
  await populateCustomFieldsCollection(customFieldsLabels);
118
128
  await populateCustomValuesCollection(customFieldsValues);
129
+ }
119
130
  // Sort jobs by title (ascending, case-insensitive, numeric-aware)
120
131
  jobsData.sort((a, b) => {
121
132
  const titleA = a.title || '';
@@ -189,15 +200,15 @@ async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS() {
189
200
 
190
201
  try {
191
202
  let jobsWithNoDescriptions = await getJobsWithNoDescriptions();
192
- let customValues=await getAllCustomValues();
193
-
194
- console.log("inserting jobs references to custom values collection");
195
- for (const value of customValues.items) {
196
- await insertJobsReference(value._id);
203
+ if (siteconfig.customFields==="true") {
204
+ let customValues=await getAllCustomValues();
205
+ console.log("inserting jobs references to custom values collection");
206
+ for (const value of customValues.items) {
207
+ await insertJobsReference(value._id);
208
+ }
209
+ console.log("inserted jobs references to custom values collection successfully");
197
210
  }
198
- console.log("inserted jobs references to custom values collection successfully");
199
-
200
-
211
+
201
212
  let totalUpdated = 0;
202
213
  let totalFailed = 0;
203
214
  let totalProcessed = 0;
@@ -235,7 +246,9 @@ async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS() {
235
246
  referFriendLink: referFriendLink,
236
247
  };
237
248
  await wixData.update(COLLECTIONS.JOBS, updatedJob);
249
+ if (siteconfig.customFields==="true") {
238
250
  await insertValuesReference(job._id);
251
+ }
239
252
  return { success: true, jobId: job._id, title: job.title };
240
253
  } catch (error) {
241
254
  console.error(` ❌ Failed to update ${job.title} (${job._id}):`, error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.565",
3
+ "version": "1.7.567",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -23,8 +23,13 @@ const {
23
23
  let queryJobTypeVar;
24
24
  let queryBrandVar;
25
25
  let searchInputBlurredFirstTime=true;
26
- let deletedParam=false;
26
+ let siteconfig;
27
+
27
28
  async function careersPageOnReady(_$w,thisObject,queryParams) {
29
+ if(siteconfig===undefined) {
30
+ siteconfig = await wixData.query(COLLECTIONS.SITE_CONFIGS).find();
31
+ siteconfig = siteconfig.items[0];
32
+ }
28
33
  console.log("queryParams: ", queryParams);
29
34
  const { page, keyWord, department, location,jobType,brand } = queryParams;
30
35
  queryPageVar=page;
@@ -96,21 +101,24 @@ async function handleUrlParams(_$w) {
96
101
  if (queryKeyWordVar) {
97
102
  await handleKeyWordParam(_$w,queryKeyWordVar);
98
103
  }
99
- if (queryPageVar) {
100
- await handlePageParam(_$w);
101
- }
102
- if (queryDepartmentVar) {
103
- await handleDepartmentParam(_$w,queryDepartmentVar);
104
- }
105
- if (queryLocationVar) {
106
- await handleLocationParam(_$w,queryLocationVar);
107
- }
108
- if (queryJobTypeVar) {
109
- await handleJobTypeParam(_$w,queryJobTypeVar);
110
- }
111
- if (queryBrandVar && _$w('#dropdownBrand').isVisible) { //if it is not visible, ignore it
112
- await handleBrandParam(_$w,queryBrandVar);
113
- }
104
+
105
+ if (siteconfig.onlyBrandKeywordUrlParams==="true") { // it is something else that is not TWG
106
+ if (queryPageVar) {
107
+ await handlePageParam(_$w);
108
+ }
109
+ if (queryDepartmentVar) {
110
+ await handleDepartmentParam(_$w,queryDepartmentVar);
111
+ }
112
+ if (queryLocationVar) {
113
+ await handleLocationParam(_$w,queryLocationVar);
114
+ }
115
+ if (queryJobTypeVar) {
116
+ await handleJobTypeParam(_$w,queryJobTypeVar);
117
+ }
118
+ if (queryBrandVar && _$w('#dropdownBrand').isVisible) { //if it is not visible, ignore it
119
+ await handleBrandParam(_$w,queryBrandVar);
120
+ }
121
+ }
114
122
  await applyFilters(_$w, true); // Skip URL update since we're handling initial URL params
115
123
  }
116
124