abmp-npm 1.9.5 → 1.9.7

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.
@@ -0,0 +1,118 @@
1
+ /**
2
+ * DEBUG WEB METHOD
3
+ *
4
+ * Instructions for use:
5
+ *
6
+ * 1. Import this in your host site's web-methods.web.js:
7
+ * import { runContactUpdateTests, testContactElevation } from 'abmp-npm/backend/test-methods';
8
+ * import { Permissions, webMethod } from 'wix-web-module';
9
+ *
10
+ * export const runContactUpdateTests = webMethod(Permissions.SiteMember, _runContactUpdateTests);
11
+ * export const testContactElevation = webMethod(Permissions.SiteMember, _testContactElevation);
12
+ *
13
+ * 2. Call from frontend console or page code:
14
+ * import { runContactUpdateTests } from 'backend/web-methods.web';
15
+ *
16
+ * // Get your contactId from your member data
17
+ * const results = await runContactUpdateTests('YOUR_CONTACT_ID', 'newemail@test.com');
18
+ * console.log('Test results:', results);
19
+ *
20
+ * 3. Check the Wix logs (Site Monitoring) for detailed output
21
+ */
22
+
23
+ const { updateMemberContactInfo } = require('./contacts-methods-DEBUG');
24
+ const { runAllTests, testElevation } = require('./contacts-methods-TEST');
25
+
26
+ /**
27
+ * Run all contact update test variations
28
+ */
29
+ async function runContactUpdateTests(contactId, newEmail) {
30
+ console.log(`[TEST RUNNER] Starting tests for contactId: ${contactId}, email: ${newEmail}`);
31
+
32
+ if (!contactId) {
33
+ throw new Error('contactId is required');
34
+ }
35
+
36
+ if (!newEmail) {
37
+ throw new Error('newEmail is required');
38
+ }
39
+
40
+ try {
41
+ const results = await runAllTests(contactId, newEmail);
42
+ return {
43
+ success: true,
44
+ message: 'Tests completed - check logs for details',
45
+ results,
46
+ };
47
+ } catch (error) {
48
+ console.error(`[TEST RUNNER] Error:`, error);
49
+ return {
50
+ success: false,
51
+ error: error.message,
52
+ stack: error.stack,
53
+ };
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Test if elevation is working correctly
59
+ */
60
+ async function testContactElevation(contactId) {
61
+ console.log(`[TEST RUNNER] Testing elevation for contactId: ${contactId}`);
62
+
63
+ if (!contactId) {
64
+ throw new Error('contactId is required');
65
+ }
66
+
67
+ try {
68
+ const results = await testElevation(contactId);
69
+ return {
70
+ success: true,
71
+ message: 'Elevation test completed - check logs for details',
72
+ results,
73
+ };
74
+ } catch (error) {
75
+ console.error(`[TEST RUNNER] Error:`, error);
76
+ return {
77
+ success: false,
78
+ error: error.message,
79
+ stack: error.stack,
80
+ };
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Test the debug version of updateMemberContactInfo
86
+ */
87
+ async function testUpdateMemberContactInfo(data, existingMemberData) {
88
+ console.log(`[TEST RUNNER] Testing updateMemberContactInfo with DEBUG logging`);
89
+
90
+ if (!data) {
91
+ throw new Error('data is required');
92
+ }
93
+
94
+ if (!existingMemberData) {
95
+ throw new Error('existingMemberData is required');
96
+ }
97
+
98
+ try {
99
+ await updateMemberContactInfo(data, existingMemberData);
100
+ return {
101
+ success: true,
102
+ message: 'updateMemberContactInfo completed - check logs for details',
103
+ };
104
+ } catch (error) {
105
+ console.error(`[TEST RUNNER] Error:`, error);
106
+ return {
107
+ success: false,
108
+ error: error.message,
109
+ stack: error.stack,
110
+ };
111
+ }
112
+ }
113
+
114
+ module.exports = {
115
+ runContactUpdateTests,
116
+ testContactElevation,
117
+ testUpdateMemberContactInfo,
118
+ };
package/backend/utils.js CHANGED
@@ -154,7 +154,7 @@ const normalizeUrlForComparison = url => {
154
154
  };
155
155
 
156
156
  async function getSecret(secretKey) {
157
- return await elevatedGetSecretValue(secretKey).value;
157
+ return (await elevatedGetSecretValue(secretKey)).value;
158
158
  }
159
159
 
160
160
  async function getSiteBaseUrl() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abmp-npm",
3
- "version": "1.9.5",
3
+ "version": "1.9.7",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "check-cycles": "madge --circular .",
@@ -7,7 +7,7 @@ async function loadingPageOnReady(authenticateSSOToken) {
7
7
  const renderingEnv = await rendering.env();
8
8
  //This calls needs to triggered on client side, otherwise PAC API will return 401 error
9
9
  if (renderingEnv === 'browser') {
10
- //Need to pass processSubmission to checkAndLogin so it will run as a web method not a public one.
10
+ //Need to pass authenticateSSOToken to checkAndLogin so it will run as a web method not a public one.
11
11
  await checkAndLogin(authenticateSSOToken).catch(error => {
12
12
  wixWindow.openLightbox(LIGHTBOX_NAMES.LOGIN_ERROR_ALERT);
13
13
  console.error(`Something went wrong while logging in: ${error}`);
package/pages/QAPage.js CHANGED
@@ -10,7 +10,7 @@ async function qaPageOnReady({ $w: _$w, loginQAMember }) {
10
10
  throw new Error('Missing required parameters: userEmail and/or secret');
11
11
  }
12
12
 
13
- const result = await loginQAMember(userEmail, secret);
13
+ const result = await loginQAMember({ userEmail, secret });
14
14
 
15
15
  if (!result.success || !result.token) {
16
16
  throw new Error(result.error || 'Login failed');
@@ -0,0 +1,13 @@
1
+ const { lightbox } = require('@wix/site-window');
2
+
3
+ async function saveAlertsOnReady({ $w: _$w }) {
4
+ const receivedData = await lightbox.getContext();
5
+ _$w('#closeButton').onClick(() => lightbox.close());
6
+ _$w('#cancelButton').onClick(() => lightbox.close());
7
+ _$w('#leaveButton').link = receivedData?.membersExternalPortalUrl;
8
+ _$w('#leaveButton').target = '_blank';
9
+ }
10
+
11
+ module.exports = {
12
+ saveAlertsOnReady,
13
+ };
@@ -0,0 +1,46 @@
1
+ const { lightbox } = require('@wix/site-window');
2
+
3
+ function selectBannerImagesOnReady({ $w: _$w }) {
4
+ _$w('#imageDataset').onReady(async () => {
5
+ const numOfItems = _$w('#imageDataset').getTotalCount();
6
+ const result = await _$w('#imageDataset').getItems(0, numOfItems);
7
+ const items = result.items;
8
+ console.log('Loaded items from dataset:', items);
9
+
10
+ _$w('#bannerImagesRepeater').data = items;
11
+ });
12
+
13
+ _$w('#bannerImagesRepeater').onItemReady(($item, itemData, index) => {
14
+ $item('#bannerImage').src = itemData.image; // image field
15
+ $item('#bannerSelected').checked = false;
16
+
17
+ // Only one checkbox can be selected
18
+ $item('#bannerSelected').onChange(() => {
19
+ if ($item('#bannerSelected').checked) {
20
+ _$w('#bannerImagesRepeater').forEachItem(($otherItem, _, otherIndex) => {
21
+ if (otherIndex !== index) {
22
+ $otherItem('#bannerSelected').checked = false;
23
+ }
24
+ });
25
+ }
26
+ });
27
+ });
28
+
29
+ _$w('#uploadSelectedImages').onClick(() => {
30
+ let selectedImage = null;
31
+
32
+ _$w('#bannerImagesRepeater').forEachItem(($item, itemData) => {
33
+ if ($item('#bannerSelected').checked) {
34
+ selectedImage = {
35
+ image: itemData.image,
36
+ title: itemData.title,
37
+ };
38
+ }
39
+ });
40
+ lightbox.close(selectedImage);
41
+ });
42
+ }
43
+
44
+ module.exports = {
45
+ selectBannerImagesOnReady,
46
+ };
@@ -1,14 +1,14 @@
1
- const { window } = require('@wix/site-window');
1
+ const { lightbox } = require('@wix/site-window');
2
2
 
3
3
  function deleteConfirmOnReady({ $w: _$w }) {
4
4
  _$w('#delete').onClick(() => {
5
- window.lightbox.close({
5
+ lightbox.close({
6
6
  toDelete: true,
7
7
  });
8
8
  });
9
9
 
10
10
  _$w('#cancel').onClick(() => {
11
- window.lightbox.close({
11
+ lightbox.close({
12
12
  toDelete: false,
13
13
  });
14
14
  });
package/pages/index.js CHANGED
@@ -5,5 +5,7 @@ module.exports = {
5
5
  ...require('./personalDetails.js'),
6
6
  ...require('./QAPage.js'),
7
7
  ...require('./LoadingPage.js'),
8
+ ...require('./SelectBannerImages.js'),
8
9
  ...require('./deleteConfirm.js'),
10
+ ...require('./SaveAlerts.js'),
9
11
  };
package/public/consts.js CHANGED
@@ -12,7 +12,7 @@ const COLLECTIONS = {
12
12
  INTERESTS: 'interests',
13
13
  STATE_CITY_MAP: 'City',
14
14
  UPDATED_LOGIN_EMAILS: 'updatedLoginEmails',
15
- QA_Users: 'QA_Users', //Make QA users configurable per site
15
+ QA_USERS: 'QA_Users', //Make QA users configurable per site
16
16
  };
17
17
 
18
18
  /**
@@ -9,7 +9,7 @@ const checkAndLogin = async authenticateSSOToken => {
9
9
  const token = query['token']?.trim();
10
10
  try {
11
11
  if (token) {
12
- const authObj = await authenticateSSOToken(token);
12
+ const authObj = await authenticateSSOToken({ token });
13
13
  console.log('authObj', authObj);
14
14
  if (authObj.type == 'success') {
15
15
  console.log('success');