bulltrackers-module 1.0.524 → 1.0.525

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.
@@ -65,21 +65,25 @@ async function processAlertForPI(db, logger, piCid, alertType, computationMetada
65
65
  };
66
66
 
67
67
  // Use writeWithMigration to write to new path (with legacy fallback)
68
+ // notifications is a subcollection, so we need isCollection: true and documentId
68
69
  const writePromise = writeWithMigration(
69
70
  db,
70
71
  'signedInUsers',
71
72
  'notifications',
72
- { cid: String(userCid), notificationId },
73
+ { cid: String(userCid) },
73
74
  notificationData,
74
75
  {
75
- isCollection: false,
76
+ isCollection: true,
76
77
  merge: false,
77
78
  dataType: 'notifications',
79
+ documentId: notificationId,
80
+ dualWrite: false, // Disable dual write - we're fully migrated to new path
78
81
  config,
79
82
  collectionRegistry
80
83
  }
81
84
  ).catch(err => {
82
- logger.log('WARN', `[processAlertForPI] Failed to write notification for CID ${userCid}: ${err.message}`);
85
+ logger.log('ERROR', `[processAlertForPI] Failed to write notification for CID ${userCid}: ${err.message}`, err);
86
+ throw err; // Re-throw so we know if writes are failing
83
87
  });
84
88
 
85
89
  notificationPromises.push(writePromise);
@@ -406,17 +406,20 @@ async function sendAllClearNotification(db, logger, userCid, piCid, piUsername,
406
406
  };
407
407
 
408
408
  // Use writeWithMigration to write to new path (with legacy fallback)
409
+ // notifications is a subcollection, so we need isCollection: true and documentId
409
410
  const { writeWithMigration } = require('../generic-api/user-api/helpers/core/path_resolution_helpers');
410
411
  await writeWithMigration(
411
412
  db,
412
413
  'signedInUsers',
413
414
  'notifications',
414
- { cid: String(userCid), notificationId },
415
+ { cid: String(userCid) },
415
416
  notificationData,
416
417
  {
417
- isCollection: false,
418
+ isCollection: true,
418
419
  merge: false,
419
420
  dataType: 'notifications',
421
+ documentId: notificationId,
422
+ dualWrite: false, // Disable dual write - we're fully migrated to new path
420
423
  config,
421
424
  collectionRegistry
422
425
  }
@@ -155,21 +155,25 @@ async function sendTestAlert(req, res, dependencies, config) {
155
155
  };
156
156
 
157
157
  // Use writeWithMigration to write to new path (with legacy fallback)
158
+ // notifications is a subcollection, so we need isCollection: true and documentId
158
159
  const writePromise = writeWithMigration(
159
160
  db,
160
161
  'signedInUsers',
161
162
  'notifications',
162
- { cid: String(targetCid), notificationId },
163
+ { cid: String(targetCid) },
163
164
  notificationData,
164
165
  {
165
- isCollection: false,
166
+ isCollection: true,
166
167
  merge: false,
167
168
  dataType: 'notifications',
169
+ documentId: notificationId,
170
+ dualWrite: false, // Disable dual write - we're fully migrated to new path
168
171
  config,
169
172
  collectionRegistry
170
173
  }
171
174
  ).catch(err => {
172
- logger.log('WARN', `[sendTestAlert] Failed to write notification for CID ${targetCid}: ${err.message}`);
175
+ logger.log('ERROR', `[sendTestAlert] Failed to write notification for CID ${targetCid}: ${err.message}`, err);
176
+ throw err; // Re-throw so we know if writes are failing
173
177
  });
174
178
 
175
179
  notificationPromises.push(writePromise);
@@ -469,10 +469,21 @@ async function writeWithMigration(db, category, subcategory, params, data, optio
469
469
  // Get legacy path if dual write is enabled
470
470
  let legacyPath = null;
471
471
  if (dualWrite && dataType && userCid) {
472
- const { resolvePath: resolve } = getRegistryFunctions(registryOptions);
473
- legacyPath = getLegacyPath(dataType, userCid, config, params, null, null, registryOptions);
474
- if (legacyPath) {
475
- legacyPath = resolve(legacyPath, params);
472
+ try {
473
+ const registryFuncs = getRegistryFunctions(registryOptions);
474
+ const resolve = registryFuncs?.resolvePath;
475
+ legacyPath = getLegacyPath(dataType, userCid, config, params, null, null, registryOptions);
476
+ if (legacyPath && resolve && typeof resolve === 'function') {
477
+ legacyPath = resolve(legacyPath, params);
478
+ } else if (legacyPath) {
479
+ // If resolve is not available, manually replace placeholders
480
+ for (const [key, value] of Object.entries(params)) {
481
+ legacyPath = legacyPath.replace(`{${key}}`, String(value));
482
+ }
483
+ }
484
+ } catch (error) {
485
+ console.warn('[writeWithMigration] Could not resolve legacy path, skipping dual write:', error.message);
486
+ legacyPath = null; // Skip dual write if we can't resolve legacy path
476
487
  }
477
488
  }
478
489
 
@@ -127,17 +127,20 @@ async function sendOnDemandNotification(db, logger, userCid, type, title, messag
127
127
  };
128
128
 
129
129
  // Write using collection registry
130
+ // notifications is a subcollection, so we need isCollection: true and documentId
130
131
  if (collectionRegistry) {
131
132
  await writeWithMigration(
132
133
  db,
133
134
  'signedInUsers',
134
135
  'notifications',
135
- { cid: String(userCid), notificationId },
136
+ { cid: String(userCid) },
136
137
  notificationData,
137
138
  {
138
- isCollection: false,
139
+ isCollection: true,
139
140
  merge: false,
140
141
  dataType: 'notifications',
142
+ documentId: notificationId,
143
+ dualWrite: false, // Disable dual write - we're fully migrated to new path
141
144
  config,
142
145
  collectionRegistry
143
146
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.524",
3
+ "version": "1.0.525",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [