sr-npm 1.7.564 → 1.7.566

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:'urlParams', 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,16 @@ const { retrieveSecretVal, getTokenFromCMS } = require('./secretsData');
9
9
 
10
10
  let jobToCustomValues = {}
11
11
  let customValuesToJobs = {}
12
+ let siteconfig;
12
13
 
13
14
  function getBrand(customField) {
14
15
  return customField.find(field => field.fieldLabel === 'Brands')?.valueLabel;
15
16
  }
16
17
 
18
+ async function getSiteConfig() {
19
+ const queryresult = await wixData.query(COLLECTIONS.SITE_CONFIGS).find();
20
+ siteconfig = queryresult.items[0];
21
+ }
17
22
  function validatePosition(position) {
18
23
  if (!position.id) {
19
24
  throw new Error('Position id is required');
@@ -113,12 +118,13 @@ async function saveJobsDataToCMS() {
113
118
  getCustomFieldsAndValuesFromPosition(position,customFieldsLabels,customFieldsValues);
114
119
  return basicJob;
115
120
  });
116
-
117
- console.log("customFieldsLabels: ", customFieldsLabels);
118
- console.log("customFieldsValues: ", customFieldsValues);
119
- console.log("jobToCustomValues: ", jobToCustomValues);
121
+ if(siteconfig===undefined) {
122
+ siteconfig = await getSiteConfig();
123
+ }
124
+ if (siteconfig.customFields==="true") {
120
125
  await populateCustomFieldsCollection(customFieldsLabels);
121
126
  await populateCustomValuesCollection(customFieldsValues);
127
+ }
122
128
  // Sort jobs by title (ascending, case-insensitive, numeric-aware)
123
129
  jobsData.sort((a, b) => {
124
130
  const titleA = a.title || '';
@@ -153,32 +159,14 @@ async function saveJobsDataToCMS() {
153
159
  }
154
160
  },
155
161
  });
156
-
157
- // await insertValuesReference(jobToCustomValues);
158
- // console.log("inserted values reference successfully");
159
- // //await insertJobsReference(customValuesToJobs);
160
- // console.log("inserted jobs reference successfully");
161
-
162
162
  console.log(`✓ All chunks processed. Total jobs saved: ${totalSaved}/${jobsData.length}`);
163
163
  }
164
164
 
165
165
  async function insertValuesReference(jobId) {
166
166
  await wixData.insertReference(COLLECTIONS.JOBS, JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,jobId, jobToCustomValues[jobId]);
167
- // console.log("inserting values reference");
168
- // for (const jobId of Object.keys(jobToCustomValues)) {
169
- // const items = jobToCustomValues[jobId];
170
- // await wixData.insertReference(COLLECTIONS.JOBS, JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,jobId, items);
171
- // }
172
- // console.log("inserted values reference successfully");
173
167
  }
174
168
  async function insertJobsReference(valueId) {
175
169
  await wixData.insertReference(COLLECTIONS.CUSTOM_VALUES, CUSTOM_VALUES_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,valueId, customValuesToJobs[valueId]);
176
- // console.log("inserting jobs reference");
177
- // for (const valueId of Object.keys(customValuesToJobs)) {
178
- // const items = customValuesToJobs[valueId];
179
- // await wixData.insertReference(COLLECTIONS.CUSTOM_VALUES, CUSTOM_VALUES_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,valueId, items);
180
- // }
181
- // console.log("inserted jobs reference successfully");
182
170
  }
183
171
 
184
172
  async function populateCustomFieldsCollection(customFields) {
@@ -210,18 +198,15 @@ async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS() {
210
198
 
211
199
  try {
212
200
  let jobsWithNoDescriptions = await getJobsWithNoDescriptions();
213
- let customValues=await getAllCustomValues();
214
- console.log("customValues: ", customValues);
215
- console.log("jobToCustomValues: ", jobToCustomValues);
216
- console.log("customValuesToJobs: ", customValuesToJobs);
217
-
218
- console.log("inserting jobs references");
219
- for (const value of customValues.items) {
220
- await insertJobsReference(value._id);
201
+ if (siteconfig.customFields==="true") {
202
+ let customValues=await getAllCustomValues();
203
+ console.log("inserting jobs references to custom values collection");
204
+ for (const value of customValues.items) {
205
+ await insertJobsReference(value._id);
206
+ }
207
+ console.log("inserted jobs references to custom values collection successfully");
221
208
  }
222
- console.log("inserted jobs references successfully");
223
-
224
-
209
+
225
210
  let totalUpdated = 0;
226
211
  let totalFailed = 0;
227
212
  let totalProcessed = 0;
@@ -259,7 +244,9 @@ async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS() {
259
244
  referFriendLink: referFriendLink,
260
245
  };
261
246
  await wixData.update(COLLECTIONS.JOBS, updatedJob);
247
+ if (siteconfig.customFields==="true") {
262
248
  await insertValuesReference(job._id);
249
+ }
263
250
  return { success: true, jobId: job._id, title: job.title };
264
251
  } catch (error) {
265
252
  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.564",
3
+ "version": "1.7.566",
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.handleCareersUrlParams==="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