bulltrackers-module 1.0.587 → 1.0.589

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.
@@ -127,6 +127,8 @@ async function findSubscriptionsForPI(db, logger, piCid, alertTypeId, computatio
127
127
  'NewSectorExposure': 'newSector',
128
128
  'PositionInvestedIncrease': 'increasedPositionSize',
129
129
  'NewSocialPost': 'newSocialPost',
130
+ // [NEW] Mapping for BehavioralAnomaly
131
+ 'BehavioralAnomaly': 'behavioralAnomaly',
130
132
  'TestSystemProbe': 'increasedRisk' // Hack: Map to 'increasedRisk' key
131
133
  };
132
134
 
@@ -155,7 +157,9 @@ async function findSubscriptionsForPI(db, logger, piCid, alertTypeId, computatio
155
157
  newSector: true,
156
158
  increasedPositionSize: true,
157
159
  newSocialPost: true,
158
- newPositions: true
160
+ newPositions: true,
161
+ // [NEW] Enable for Dev Override
162
+ behavioralAnomaly: true
159
163
  };
160
164
 
161
165
  // Check all developer accounts
@@ -224,8 +228,8 @@ async function findSubscriptionsForPI(db, logger, piCid, alertTypeId, computatio
224
228
 
225
229
  // Step 2: For each user, read their watchlists from SignedInUsers/{cid}/watchlists
226
230
  const { readWithMigration } = require('../../generic-api/user-api/helpers/core/path_resolution_helpers');
227
- const { collectionRegistry } = dependencies;
228
- const config = dependencies.config || {};
231
+ // const { collectionRegistry } = dependencies; // Already destructured above
232
+ // const config = dependencies.config || {}; // Already defined
229
233
 
230
234
  for (const userCidStr of userCids) {
231
235
  try {
@@ -1,8 +1,6 @@
1
1
  /**
2
- * @fileoverview Alert Type Registry
3
- * Defines all available alert types and their associated computations
2
+ * file: alert-system/helpers/alert_type_registry.js
4
3
  */
5
-
6
4
  const ALERT_TYPES = {
7
5
  increasedRisk: {
8
6
  id: 'increasedRisk',
@@ -54,13 +52,25 @@ const ALERT_TYPES = {
54
52
  severity: 'low',
55
53
  enabled: true
56
54
  },
55
+ // [NEW] Behavioral Anomaly Registration
56
+ behavioralAnomaly: {
57
+ id: 'behavioralAnomaly',
58
+ name: 'Behavioral Anomaly',
59
+ description: 'Alert when a Popular Investor deviates significantly from their baseline behavior',
60
+ computationName: 'BehavioralAnomaly',
61
+ category: 'alerts',
62
+ // Uses metadata keys from Behaviour.js: primaryDriver, driverSignificance, anomalyScore
63
+ messageTemplate: 'Behavioral Alert for {piUsername}: {primaryDriver} Deviation ({driverSignificance}) detected.',
64
+ severity: 'high',
65
+ enabled: true
66
+ },
57
67
  testSystemProbe: {
58
68
  id: 'testSystemProbe',
59
69
  name: 'Test System Probe',
60
70
  description: 'Always-on debug alert',
61
- computationName: 'TestSystemProbe', // Must match the class name above
71
+ computationName: 'TestSystemProbe',
62
72
  category: 'alerts',
63
- messageTemplate: 'Probe Triggered for {status} at {timestamp}', // Uses keys from the result object
73
+ messageTemplate: 'Probe Triggered for {status} at {timestamp}',
64
74
  severity: 'info',
65
75
  enabled: true
66
76
  },
@@ -113,6 +123,8 @@ function generateAlertMessage(alertType, piUsername, metadata = {}) {
113
123
  message = message.replace('{current}', metadata.current || metadata.currentValue || metadata.curr || metadata.currentRisk || 'N/A');
114
124
  message = message.replace('{sectorName}', metadata.sectorName || (metadata.newExposures && metadata.newExposures.length > 0 ? metadata.newExposures.join(', ') : 'Unknown'));
115
125
  message = message.replace('{ticker}', metadata.ticker || metadata.symbol || 'Unknown');
126
+
127
+ // Format numeric values
116
128
  message = message.replace('{volatility}', metadata.volatility ? `${(metadata.volatility * 100).toFixed(1)}` : 'N/A');
117
129
  message = message.replace('{threshold}', metadata.threshold ? `${(metadata.threshold * 100).toFixed(0)}` : 'N/A');
118
130
  message = message.replace('{diff}', metadata.diff ? `${metadata.diff.toFixed(1)}` : 'N/A');
@@ -120,6 +132,15 @@ function generateAlertMessage(alertType, piUsername, metadata = {}) {
120
132
  message = message.replace('{curr}', metadata.curr ? `${metadata.curr.toFixed(1)}` : 'N/A');
121
133
  message = message.replace('{title}', metadata.title || 'New Update');
122
134
 
135
+ // [FIX] Probe Placeholders (Missing in original)
136
+ message = message.replace('{status}', metadata.status || 'Unknown Status');
137
+ message = message.replace('{timestamp}', metadata.timestamp || new Date().toISOString());
138
+
139
+ // [NEW] Behavioral Anomaly Placeholders
140
+ message = message.replace('{primaryDriver}', metadata.primaryDriver || 'Unknown Factor');
141
+ message = message.replace('{driverSignificance}', metadata.driverSignificance || 'N/A');
142
+ message = message.replace('{anomalyScore}', metadata.anomalyScore || 'N/A');
143
+
123
144
  // Handle positions list if available
124
145
  if (metadata.positions && Array.isArray(metadata.positions) && metadata.positions.length > 0) {
125
146
  const positionsList = metadata.positions
@@ -148,5 +169,4 @@ module.exports = {
148
169
  getAllAlertTypes,
149
170
  isAlertComputation,
150
171
  generateAlertMessage
151
- };
152
-
172
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.587",
3
+ "version": "1.0.589",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [