abmp-npm 1.8.44 → 1.8.45

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.
Files changed (50) hide show
  1. package/CONTACT_EMAIL_UPDATE_DEBUG.md +313 -0
  2. package/DEBUG_QUICKSTART.md +133 -0
  3. package/backend/cms-data-methods.js +8 -0
  4. package/backend/consts.js +22 -7
  5. package/backend/contacts-methods-DEBUG.js +237 -0
  6. package/backend/contacts-methods-TEST.js +271 -0
  7. package/backend/contacts-methods.js +6 -1
  8. package/backend/daily-pull/consts.js +0 -3
  9. package/backend/daily-pull/process-member-methods.js +1 -1
  10. package/backend/daily-pull/sync-to-cms-methods.js +10 -6
  11. package/backend/daily-pull/utils.js +3 -3
  12. package/backend/data-hooks.js +29 -0
  13. package/backend/elevated-modules.js +2 -0
  14. package/backend/http-functions/httpFunctions.js +86 -0
  15. package/backend/http-functions/index.js +3 -0
  16. package/backend/http-functions/interests.js +37 -0
  17. package/backend/index.js +6 -1
  18. package/backend/jobs.js +15 -3
  19. package/backend/login/index.js +7 -0
  20. package/backend/login/login-methods-factory.js +24 -0
  21. package/backend/login/qa-login-methods.js +72 -0
  22. package/backend/login/sso-methods.js +158 -0
  23. package/backend/members-data-methods.js +271 -94
  24. package/backend/pac-api-methods.js +3 -4
  25. package/backend/routers/index.js +3 -0
  26. package/backend/routers/methods.js +177 -0
  27. package/backend/routers/utils.js +118 -0
  28. package/backend/search-filters-methods.js +3 -0
  29. package/backend/tasks/consts.js +19 -0
  30. package/backend/tasks/index.js +6 -0
  31. package/backend/tasks/migration-methods.js +26 -0
  32. package/backend/tasks/tasks-configs.js +124 -0
  33. package/backend/tasks/tasks-helpers-methods.js +419 -0
  34. package/backend/tasks/tasks-process-methods.js +545 -0
  35. package/backend/test-methods.js +118 -0
  36. package/backend/utils.js +85 -41
  37. package/package.json +13 -2
  38. package/pages/LoadingPage.js +20 -0
  39. package/pages/Profile.js +2 -2
  40. package/pages/QAPage.js +39 -0
  41. package/pages/SaveAlerts.js +13 -0
  42. package/pages/SelectBannerImages.js +46 -0
  43. package/pages/deleteConfirm.js +19 -0
  44. package/pages/index.js +5 -0
  45. package/pages/personalDetails.js +12 -8
  46. package/public/consts.js +6 -23
  47. package/public/sso-auth-methods.js +43 -0
  48. package/backend/routers-methods.js +0 -182
  49. package/backend/routers-utils.js +0 -158
  50. package/backend/tasks.js +0 -37
@@ -0,0 +1,313 @@
1
+ # Contact Email Update Investigation Guide
2
+
3
+ ## Problem Description
4
+
5
+ Contact email updates in Wix CRM are not working after migration to npm package:
6
+
7
+ - ✅ Members data in Wix DB updates correctly
8
+ - ❌ Contact email in Wix CRM does not update
9
+ - ❌ No errors appear in logs
10
+ - ✅ Old implementation (before npm) works fine
11
+
12
+ ## Key Differences Found
13
+
14
+ ### OLD Implementation (Working)
15
+
16
+ ```javascript
17
+ // From: src/backend/api.web.js (before npm migration)
18
+ import { contacts } from 'wix-crm.v2'; // ← Old package
19
+ import { elevate } from 'wix-auth'; // ← Old import style
20
+
21
+ // Elevated functions created INSIDE the function
22
+ async function updateContactInfo(contactId, updateInfoCallback, operationName) {
23
+ const elevatedGetContact = elevate(contacts.getContact);
24
+ const elevatedUpdateContact = elevate(contacts.updateContact);
25
+
26
+ const currentContact = await elevatedGetContact(contactId);
27
+ const updatedInfo = updateInfoCallback(currentContact.info);
28
+
29
+ // Passes updatedInfo DIRECTLY (not wrapped)
30
+ const result = await elevatedUpdateContact(
31
+ contactId,
32
+ updatedInfo, // ← Direct info object
33
+ currentContact.revision
34
+ );
35
+ return result;
36
+ }
37
+ ```
38
+
39
+ ### NEW Implementation (Not Working)
40
+
41
+ ```javascript
42
+ // From: abmp-npm/backend/contacts-methods.js
43
+ const { contacts } = require('@wix/crm'); // ← New package
44
+ const { auth } = require('@wix/essentials'); // ← New import style
45
+
46
+ // Elevated functions created at MODULE LEVEL
47
+ const elevatedGetContact = auth.elevate(contacts.getContact);
48
+ const elevatedUpdateContact = auth.elevate(contacts.updateContact);
49
+
50
+ async function updateContactInfo(contactId, updateInfoCallback, operationName) {
51
+ const contact = await elevatedGetContact(contactId);
52
+ const updatedInfo = updateInfoCallback(contact.info);
53
+
54
+ // Wraps updatedInfo in { info: }
55
+ await elevatedUpdateContact(
56
+ contactId,
57
+ { info: updatedInfo }, // ← Wrapped in { info: }
58
+ contact.revision
59
+ );
60
+ }
61
+ ```
62
+
63
+ ## Potential Issues
64
+
65
+ ### 1. Package Change: `wix-crm.v2` → `@wix/crm`
66
+
67
+ The API signature might have changed between these packages:
68
+
69
+ - **Old**: `updateContact(contactId, infoObject, revision)`
70
+ - **New**: `updateContact(contactId, { info: infoObject }, revision)` or `updateContact(contactId, contactObject, { revision })`
71
+
72
+ ### 2. Elevation Scope
73
+
74
+ - **Old**: Functions elevated inside the function (per-call elevation)
75
+ - **New**: Functions elevated at module level (shared elevation)
76
+
77
+ This could cause issues with permissions or context.
78
+
79
+ ### 3. Silent Failures
80
+
81
+ If the CRM update throws an error but it's being caught and not logged, it would appear to work but not actually update.
82
+
83
+ ## Investigation Steps
84
+
85
+ I've created three debugging files for you:
86
+
87
+ ### File 1: `contacts-methods-DEBUG.js`
88
+
89
+ This is your current implementation with extensive logging. It will show:
90
+
91
+ - Every step of the update process
92
+ - All data being passed
93
+ - Any errors (even if they're being caught)
94
+ - Success confirmations
95
+
96
+ ### File 2: `contacts-methods-TEST.js`
97
+
98
+ This contains 4 different implementations to test:
99
+
100
+ - **V1**: Current style (wrapped in `{ info: }`)
101
+ - **V2**: Old style (direct info object)
102
+ - **V3**: Minimal payload (only changed fields)
103
+ - **V4**: Revision in options object
104
+ - **Elevation Test**: Checks if elevation is working at all
105
+
106
+ ### File 3: `test-methods.js`
107
+
108
+ Web method wrappers you can call from the frontend to run the tests.
109
+
110
+ ## How to Use
111
+
112
+ ### Step 1: Update Backend Index
113
+
114
+ Add the test methods to your npm package exports:
115
+
116
+ ```javascript
117
+ // In abmp-npm/backend/index.js
118
+ module.exports = {
119
+ ...require('./forms-methods'),
120
+ ...require('./search-filters-methods'),
121
+ ...require('./jobs'),
122
+ ...require('./utils'),
123
+ ...require('./daily-pull'),
124
+ ...require('./pac-api-methods'),
125
+ ...require('./members-area-methods'),
126
+ ...require('./members-data-methods'),
127
+ ...require('./cms-data-methods'),
128
+ ...require('./routers-methods'),
129
+ ...require('./test-methods'), // ← Add this
130
+ };
131
+ ```
132
+
133
+ ### Step 2: Expose in Host Site
134
+
135
+ Add these web methods to your host site:
136
+
137
+ ```javascript
138
+ // In abmp/src/backend/web-methods.web.js
139
+ import { Permissions, webMethod } from 'wix-web-module';
140
+ import {
141
+ // ... existing imports
142
+ runContactUpdateTests as _runContactUpdateTests,
143
+ testContactElevation as _testContactElevation,
144
+ testUpdateMemberContactInfo as _testUpdateMemberContactInfo,
145
+ } from 'abmp-npm/backend';
146
+
147
+ // ... existing exports
148
+
149
+ export const runContactUpdateTests = webMethod(Permissions.SiteMember, _runContactUpdateTests);
150
+
151
+ export const testContactElevation = webMethod(Permissions.SiteMember, _testContactElevation);
152
+
153
+ export const testUpdateMemberContactInfo = webMethod(
154
+ Permissions.SiteMember,
155
+ _testUpdateMemberContactInfo
156
+ );
157
+ ```
158
+
159
+ ### Step 3: Run Tests from Frontend
160
+
161
+ Option A - Test all variations:
162
+
163
+ ```javascript
164
+ import { runContactUpdateTests } from 'backend/web-methods.web';
165
+ import wixData from 'wix-data';
166
+
167
+ // Get your member data (you need the contactId)
168
+ const memberData = await wixData.get('Members/PrivateMembersData', 'YOUR_MEMBER_ID');
169
+ const contactId = memberData.contactId;
170
+
171
+ // Run all test variations
172
+ const results = await runContactUpdateTests(contactId, 'newemail@test.com');
173
+ console.log('Test results:', results);
174
+
175
+ // Check Wix Site Monitoring logs for detailed output
176
+ ```
177
+
178
+ Option B - Test elevation only:
179
+
180
+ ```javascript
181
+ import { testContactElevation } from 'backend/web-methods.web';
182
+
183
+ const results = await testContactElevation(contactId);
184
+ console.log('Elevation test results:', results);
185
+ ```
186
+
187
+ Option C - Test with DEBUG logging (using your actual saveRegistrationData flow):
188
+
189
+ ```javascript
190
+ import { testUpdateMemberContactInfo } from 'backend/web-methods.web';
191
+ import wixData from 'wix-data';
192
+
193
+ // Get existing member data
194
+ const existingData = await wixData.get('Members/PrivateMembersData', 'YOUR_MEMBER_ID');
195
+
196
+ // Create update data (as it would come from your form)
197
+ const updateData = {
198
+ ...existingData,
199
+ contactFormEmail: 'newemail@test.com', // Change the email
200
+ firstName: existingData.firstName,
201
+ lastName: existingData.lastName,
202
+ };
203
+
204
+ // Test with DEBUG logging
205
+ const results = await testUpdateMemberContactInfo(updateData, existingData);
206
+ console.log('Debug test results:', results);
207
+
208
+ // Check Wix Site Monitoring logs for extensive output
209
+ ```
210
+
211
+ ### Step 4: Check Logs
212
+
213
+ Go to your Wix Site Monitoring (Logs) and look for entries starting with:
214
+
215
+ - `[DEBUG]` - From the debug version
216
+ - `[TEST V1]`, `[TEST V2]`, etc. - From different test implementations
217
+ - `[TEST ELEVATION]` - From elevation tests
218
+ - `[TEST RUNNER]` - From the test runner
219
+
220
+ ## What to Look For
221
+
222
+ ### 1. Elevation Issues
223
+
224
+ If you see errors like:
225
+
226
+ - "Insufficient permissions"
227
+ - "Unauthorized"
228
+ - "Forbidden"
229
+
230
+ Then elevation is not working correctly.
231
+
232
+ ### 2. API Signature Issues
233
+
234
+ If you see errors like:
235
+
236
+ - "Invalid parameter"
237
+ - "Expected object of type Contact"
238
+ - "Unexpected argument"
239
+
240
+ Then the API signature has changed between packages.
241
+
242
+ ### 3. Silent Success
243
+
244
+ If all tests show "success" but the email still doesn't update in CRM:
245
+
246
+ - Check if the contact actually exists in CRM
247
+ - Check if there are any CRM automation rules blocking updates
248
+ - Check if the email field is locked/read-only
249
+
250
+ ### 4. Which Version Works
251
+
252
+ If one of the test versions (V1, V2, V3, V4) works:
253
+
254
+ - That tells us the correct API signature to use
255
+ - Update the actual `contacts-methods.js` to match the working version
256
+
257
+ ## Quick Fix Hypothesis
258
+
259
+ Based on the code comparison, my best guess is that the issue is with the API call signature. Try this fix first:
260
+
261
+ ### Option 1: Use Old Style (Direct Info Object)
262
+
263
+ ```javascript
264
+ // In contacts-methods.js, line 23
265
+ // CHANGE FROM:
266
+ await elevatedUpdateContact(contactId, { info: updatedInfo }, contact.revision);
267
+
268
+ // CHANGE TO:
269
+ await elevatedUpdateContact(contactId, updatedInfo, contact.revision);
270
+ ```
271
+
272
+ ### Option 2: Move Elevation Inside Function
273
+
274
+ ```javascript
275
+ // In contacts-methods.js
276
+ // CHANGE FROM:
277
+ const elevatedGetContact = auth.elevate(contacts.getContact);
278
+ const elevatedUpdateContact = auth.elevate(contacts.updateContact);
279
+
280
+ async function updateContactInfo(contactId, updateInfoCallback, operationName) {
281
+ // ...
282
+ }
283
+
284
+ // CHANGE TO:
285
+ async function updateContactInfo(contactId, updateInfoCallback, operationName) {
286
+ const elevatedGetContact = auth.elevate(contacts.getContact);
287
+ const elevatedUpdateContact = auth.elevate(contacts.updateContact);
288
+ // ...
289
+ }
290
+ ```
291
+
292
+ ## Next Steps
293
+
294
+ 1. ✅ Add test files to npm package (already created)
295
+ 2. ⬜ Release new npm version with test methods
296
+ 3. ⬜ Install new version in host site
297
+ 4. ⬜ Expose test web methods in host site
298
+ 5. ⬜ Run tests from frontend
299
+ 6. ⬜ Check logs to see which version works
300
+ 7. ⬜ Apply the working solution to the actual code
301
+ 8. ⬜ Remove test files and release final version
302
+
303
+ ## Need More Help?
304
+
305
+ If the tests don't reveal the issue, we can:
306
+
307
+ 1. Add even more detailed logging
308
+ 2. Test with the actual Wix CRM dashboard to verify the contact exists
309
+ 3. Check if there are any CRM automation rules or webhooks interfering
310
+ 4. Test with a different contact to rule out data-specific issues
311
+ 5. Compare the exact bytes being sent in the old vs new implementation
312
+
313
+ Let me know what the test results show!
@@ -0,0 +1,133 @@
1
+ # Contact Email Update Investigation - Quick Start
2
+
3
+ ## 🔍 Problem Summary
4
+
5
+ After migrating to npm package, contact email updates fail silently:
6
+
7
+ - ✅ Wix DB updates work
8
+ - ❌ CRM contact email doesn't update
9
+ - ❌ No errors in logs
10
+
11
+ ## 🎯 Key Finding
12
+
13
+ The old code used `wix-crm.v2` while the new code uses `@wix/crm`. These have **different API signatures**!
14
+
15
+ **Old (Working)**:
16
+
17
+ ```javascript
18
+ elevatedUpdateContact(contactId, infoObject, revision);
19
+ ```
20
+
21
+ **New (Not Working?)**:
22
+
23
+ ```javascript
24
+ elevatedUpdateContact(contactId, { info: infoObject }, revision);
25
+ ```
26
+
27
+ ## 🚀 Quick Steps to Investigate
28
+
29
+ ### 1. I've created 4 files for you:
30
+
31
+ - ✅ `contacts-methods-DEBUG.js` - Your code with extensive logging
32
+ - ✅ `contacts-methods-TEST.js` - 4 different API call variations
33
+ - ✅ `test-methods.js` - Web methods to run tests
34
+ - ✅ `CONTACT_EMAIL_UPDATE_DEBUG.md` - Full documentation
35
+
36
+ ### 2. Release this version to test:
37
+
38
+ The test methods are already exported in `backend/index.js`.
39
+ You just need to:
40
+
41
+ 1. Release new npm version
42
+ 2. Expose test methods in host site `web-methods.web.js`
43
+ 3. Run tests from frontend
44
+ 4. Check logs to see which variation works
45
+
46
+ ### 3. Expose test methods in host site:
47
+
48
+ Add to `abmp/src/backend/web-methods.web.js`:
49
+
50
+ ```javascript
51
+ import {
52
+ // ... your existing imports
53
+ runContactUpdateTests as _runContactUpdateTests,
54
+ testContactElevation as _testContactElevation,
55
+ testUpdateMemberContactInfo as _testUpdateMemberContactInfo,
56
+ } from 'abmp-npm/backend';
57
+
58
+ // ... existing exports
59
+
60
+ export const runContactUpdateTests = webMethod(Permissions.SiteMember, _runContactUpdateTests);
61
+
62
+ export const testContactElevation = webMethod(Permissions.SiteMember, _testContactElevation);
63
+
64
+ export const testUpdateMemberContactInfo = webMethod(
65
+ Permissions.SiteMember,
66
+ _testUpdateMemberContactInfo
67
+ );
68
+ ```
69
+
70
+ ### 4. Run tests from frontend:
71
+
72
+ ```javascript
73
+ import { runContactUpdateTests } from 'backend/web-methods.web';
74
+ import wixData from 'wix-data';
75
+
76
+ // Get your contact ID from member data
77
+ const memberData = await wixData.get('Members/PrivateMembersData', 'YOUR_MEMBER_ID');
78
+
79
+ // Run all test variations
80
+ const results = await runContactUpdateTests(memberData.contactId, 'test@newemail.com');
81
+
82
+ console.log('Results:', results);
83
+ // Then check Wix Site Monitoring logs for detailed output
84
+ ```
85
+
86
+ ### 5. Check which test works:
87
+
88
+ In Wix Site Monitoring, look for:
89
+
90
+ - ✅ `[TEST V1]` - Current implementation
91
+ - ✅ `[TEST V2]` - Old style (direct info object) ← **Most likely to work**
92
+ - ✅ `[TEST V3]` - Minimal payload
93
+ - ✅ `[TEST V4]` - Revision in options
94
+
95
+ ### 6. Apply the fix:
96
+
97
+ Once you know which version works, update `contacts-methods.js` to match that signature.
98
+
99
+ ## 🔧 Most Likely Fix
100
+
101
+ Based on the code comparison, try this first:
102
+
103
+ ### Change line 23 in `contacts-methods.js`:
104
+
105
+ **FROM:**
106
+
107
+ ```javascript
108
+ await elevatedUpdateContact(contactId, { info: updatedInfo }, contact.revision);
109
+ ```
110
+
111
+ **TO:**
112
+
113
+ ```javascript
114
+ await elevatedUpdateContact(contactId, updatedInfo, contact.revision);
115
+ ```
116
+
117
+ This matches the old working implementation and might be the correct signature for the new package.
118
+
119
+ ## 📖 Full Documentation
120
+
121
+ See `CONTACT_EMAIL_UPDATE_DEBUG.md` for complete details, analysis, and troubleshooting steps.
122
+
123
+ ## ✅ What's Already Done
124
+
125
+ - ✅ Debugging files created
126
+ - ✅ Test variations created
127
+ - ✅ Test methods exported
128
+ - ⬜ Release new npm version
129
+ - ⬜ Expose in host site
130
+ - ⬜ Run tests
131
+ - ⬜ Apply fix
132
+
133
+ Let me know what the tests reveal!
@@ -231,9 +231,17 @@ async function getInterestAll() {
231
231
  throw e;
232
232
  }
233
233
  }
234
+ async function clearCollection(collectionName) {
235
+ try {
236
+ await wixData.truncate(collectionName);
237
+ } catch (err) {
238
+ throw new Error(`Failed to clearCollection ${collectionName} with error: ${err.message}`);
239
+ }
240
+ }
234
241
 
235
242
  module.exports = {
236
243
  buildMembersSearchQuery,
237
244
  fetchAllItemsInParallel,
238
245
  getInterestAll,
246
+ clearCollection,
239
247
  };
package/backend/consts.js CHANGED
@@ -1,3 +1,6 @@
1
+ const PAC_API_URL = 'https://members.abmp.com/eweb/api/Wix';
2
+ const SSO_TOKEN_AUTH_API_URL = 'https://members.professionalassistcorp.com/';
3
+
1
4
  /**
2
5
  * Valid configuration keys for getSiteConfigs function
3
6
  * @readonly
@@ -6,23 +9,35 @@
6
9
  const CONFIG_KEYS = {
7
10
  AUTOMATION_EMAIL_TRIGGER_ID: 'AUTOMATION_EMAIL_TRIGGER_ID',
8
11
  SITE_ASSOCIATION: 'SITE_ASSOCIATION',
12
+ DEFAULT_PROFILE_SEO_DESCRIPTION: 'DEFAULT_PROFILE_SEO_DESCRIPTION',
13
+ INTERESTS_API_URL: 'INTERESTS_API_URL',
14
+ SITE_LOGO_URL: 'SITE_LOGO_URL',
15
+ MEMBERS_EXTERNAL_PORTAL_URL: 'MEMBERS_EXTERNAL_PORTAL_URL',
16
+ DEFAULT_PROFILE_IMAGE: 'DEFAULT_PROFILE_IMAGE',
9
17
  };
10
18
 
11
19
  const MAX__MEMBERS_SEARCH_RESULTS = 120;
12
20
  const WIX_QUERY_MAX_LIMIT = 1000;
13
21
 
14
- const TASKS_NAMES = {
15
- ScheduleDailyMembersDataSync: 'ScheduleDailyMembersDataSync',
16
- ScheduleMembersDataPerAction: 'ScheduleMembersDataPerAction',
17
- SyncMembers: 'SyncMembers',
18
- };
19
-
20
22
  const GEO_HASH_PRECISION = 3;
21
23
 
24
+ const COMPILED_FILTERS_FIELDS = {
25
+ COMPILED_STATE_LIST: 'COMPILED_STATE_LIST',
26
+ COMPILED_AREAS_OF_PRACTICES: 'COMPILED_AREAS_OF_PRACTICES',
27
+ COMPILED_STATE_CITY_MAP: 'COMPILED_STATE_CITY_MAP',
28
+ };
29
+ const MEMBERSHIPS_TYPES = {
30
+ STUDENT: 'Student',
31
+ PAC_STAFF: 'PAC STAFF',
32
+ };
33
+
22
34
  module.exports = {
23
35
  CONFIG_KEYS,
24
36
  MAX__MEMBERS_SEARCH_RESULTS,
25
37
  WIX_QUERY_MAX_LIMIT,
26
- TASKS_NAMES,
27
38
  GEO_HASH_PRECISION,
39
+ PAC_API_URL,
40
+ COMPILED_FILTERS_FIELDS,
41
+ MEMBERSHIPS_TYPES,
42
+ SSO_TOKEN_AUTH_API_URL,
28
43
  };