sr-npm 1.7.543 → 1.7.545

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.
@@ -25,7 +25,7 @@ const JOBS_COLLECTION_FIELDS = {
25
25
  REFER_FRIEND_LINK: 'referFriendLink',
26
26
  BRAND: 'brand',
27
27
  BRAND_REF: 'brandRef',
28
- CUSTOM_VALUES: 'customValues',
28
+ MULTI_REF_JOBS_CUSTOM_VALUES: 'multiRefJobsCustomValues',
29
29
  }
30
30
  const AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION_FIELDS = {
31
31
  TITLE: 'title',
@@ -35,7 +35,7 @@ const AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION_FIELDS = {
35
35
  const CUSTOM_VALUES_COLLECTION_FIELDS = {
36
36
  TITLE: 'title',
37
37
  CUSTOM_FIELD: 'customField',
38
- JOBS: 'jobs',
38
+ MULTI_REF_JOBS_CUSTOM_VALUES: 'multiRefJobsCustomValues',
39
39
  }
40
40
  const CUSTOM_FIELDS_COLLECTION_FIELDS = {
41
41
  TITLE: 'title',
@@ -73,7 +73,7 @@ const COLLECTIONS_FIELDS = {
73
73
  {key:'language', type: 'TEXT'},
74
74
  {key:'remote', type: 'BOOLEAN'},
75
75
  {key:'jobDescription', type: 'OBJECT'},
76
- {key:'customValues', type: 'MULTI_REFERENCE', typeMetadata: { multiReference: { referencedCollectionId: COLLECTIONS.CUSTOM_VALUES,referencingFieldKey:'customValues',referencingDisplayName:'customValues' } } },
76
+ {key:'multiRefJobsCustomValues', type: 'MULTI_REFERENCE', typeMetadata: { multiReference: { referencedCollectionId: COLLECTIONS.CUSTOM_VALUES,referencingFieldKey:JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,referencingDisplayName:JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES } } },
77
77
  {key:'cityText', type: 'TEXT'},
78
78
  {key:'applyLink', type: 'URL'},
79
79
  {key:'referFriendLink', type: 'URL'},
@@ -97,7 +97,7 @@ const COLLECTIONS_FIELDS = {
97
97
  CUSTOM_VALUES: [
98
98
  {key:'title', type: 'TEXT'},
99
99
  {key:'customField', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.CUSTOM_FIELDS } } },
100
- {key:'jobs', type: 'MULTI_REFERENCE', typeMetadata: { multiReference: { referencedCollectionId: COLLECTIONS.JOBS,referencingFieldKey:'jobs',referencingDisplayName:'jobs' } } },
100
+ {key:'multiRefJobsCustomValues', type: 'MULTI_REFERENCE', typeMetadata: { multiReference: { referencedCollectionId: COLLECTIONS.JOBS,referencingFieldKey:CUSTOM_VALUES_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,referencingDisplayName:MULTI_REF_JOBS_CUSTOM_VALUES.MULTI_REF_JOBS_CUSTOM_VALUES } } },
101
101
  ],
102
102
  CUSTOM_FIELDS: [
103
103
  {key:'title', type: 'TEXT'},
package/backend/data.js CHANGED
@@ -111,6 +111,7 @@ async function saveJobsDataToCMS() {
111
111
 
112
112
  console.log("customFieldsLabels: ", customFieldsLabels);
113
113
  console.log("customFieldsValues: ", customFieldsValues);
114
+ console.log("jobToCustomValues: ", jobToCustomValues);
114
115
  populateCustomFieldsCollection(customFieldsLabels);
115
116
  populateCustomValuesCollection(customFieldsValues);
116
117
  // Sort jobs by title (ascending, case-insensitive, numeric-aware)
@@ -147,8 +148,10 @@ async function saveJobsDataToCMS() {
147
148
  }
148
149
  },
149
150
  });
150
-
151
+
151
152
  await insertValuesReference(jobToCustomValues);
153
+ await insertJOBSsReference(jobToCustomValues);
154
+
152
155
 
153
156
  console.log(`✓ All chunks processed. Total jobs saved: ${totalSaved}/${jobsData.length}`);
154
157
  }
@@ -156,7 +159,14 @@ async function saveJobsDataToCMS() {
156
159
  async function insertValuesReference(jobToCustomValues) {
157
160
  for (const jobId of Object.keys(jobToCustomValues)) {
158
161
  const items = jobToCustomValues[jobId];
159
- await wixData.insertReference(COLLECTIONS.JOBS, JOBS_COLLECTION_FIELDS.CUSTOM_VALUES,jobId, items);
162
+ await wixData.insertReference(COLLECTIONS.JOBS, JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,jobId, items);
163
+ }
164
+ }
165
+ async function insertJOBSsReference(jobToCustomValues) {
166
+ for (const jobId of Object.keys(jobToCustomValues)) {
167
+ for (const valueId of jobToCustomValues[jobId]) {
168
+ await wixData.insertReference(COLLECTIONS.CUSTOM_VALUES, CUSTOM_VALUES_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,valueId, jobId);
169
+ }
160
170
  }
161
171
  }
162
172
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.543",
3
+ "version": "1.7.545",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {