bulltrackers-module 1.0.476 → 1.0.477

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.
@@ -84,7 +84,10 @@ function resolveDependencyChain(computationName, manifest) {
84
84
  */
85
85
  async function triggerComputationWithDependencies(targetComputation, date, dependencies, config, metadata = {}) {
86
86
  const { pubsub, logger } = dependencies;
87
- const computationTopic = config.computationTopicStandard || 'computation-tasks';
87
+ // Use on-demand topic for on-demand computation requests
88
+ const computationTopic = config.computationTopicOnDemand ||
89
+ (config.getComputationTopic && config.getComputationTopic(true)) ||
90
+ 'computation-tasks-ondemand';
88
91
  const topic = pubsub.topic(computationTopic);
89
92
  const crypto = require('crypto');
90
93
 
@@ -134,8 +134,10 @@ async function requestPiFetch(req, res, dependencies, config) {
134
134
  updatedAt: FieldValue.serverTimestamp()
135
135
  }, { merge: true });
136
136
 
137
- // Publish to task engine
138
- const topicName = config.taskEngine?.PUBSUB_TOPIC_USER_FETCH || 'etoro-user-fetch-topic';
137
+ // Publish to task engine - use on-demand topic for API requests
138
+ const topicName = config.taskEngine?.PUBSUB_TOPIC_USER_FETCH_ONDEMAND ||
139
+ config.pubsubTopicUserFetchOnDemand ||
140
+ 'etoro-user-fetch-topic-ondemand';
139
141
  const topic = pubsub.topic(topicName);
140
142
 
141
143
  const message = {
@@ -148,8 +148,10 @@ async function requestUserSync(req, res, dependencies, config) {
148
148
  updatedAt: FieldValue.serverTimestamp()
149
149
  }, { merge: true });
150
150
 
151
- // Publish to task engine
152
- const topicName = config.taskEngine?.PUBSUB_TOPIC_USER_FETCH || 'etoro-user-fetch-topic';
151
+ // Publish to task engine - use on-demand topic for API requests
152
+ const topicName = config.taskEngine?.PUBSUB_TOPIC_USER_FETCH_ONDEMAND ||
153
+ config.pubsubTopicUserFetchOnDemand ||
154
+ 'etoro-user-fetch-topic-ondemand';
153
155
  const topic = pubsub.topic(topicName);
154
156
 
155
157
  const message = {
@@ -57,8 +57,12 @@ async function finalizeVerification(req, res, dependencies, config) {
57
57
  proxyConfig,
58
58
  headerConfig,
59
59
  pubsubTopicUserFetch,
60
+ pubsubTopicUserFetchOnDemand,
60
61
  pubsubTopicSocialFetch
61
62
  } = config;
63
+
64
+ // Use on-demand topic for user signup (API-triggered)
65
+ const taskEngineTopic = pubsubTopicUserFetchOnDemand || pubsubTopicUserFetch || 'etoro-user-fetch-topic-ondemand';
62
66
 
63
67
  if (!username) return res.status(400).json({ error: "Missing username." });
64
68
 
@@ -187,8 +191,8 @@ async function finalizeVerification(req, res, dependencies, config) {
187
191
 
188
192
  // Only trigger if user is public (has portfolio data)
189
193
  if (!isOptOut) {
190
- await pubsubUtils.publish(pubsubTopicUserFetch, unifiedTask);
191
- logger.log('INFO', `[Verification] Triggered unified data fetch (portfolio + social) for ${username} (${realCID})`);
194
+ await pubsubUtils.publish(taskEngineTopic, unifiedTask);
195
+ logger.log('INFO', `[Verification] Triggered unified data fetch (portfolio + social) for ${username} (${realCID}) via on-demand topic`);
192
196
  } else {
193
197
  // For private users, still fetch social data but no portfolio
194
198
  const socialOnlyTask = {
@@ -208,8 +212,8 @@ async function finalizeVerification(req, res, dependencies, config) {
208
212
  requestedAt: new Date().toISOString()
209
213
  }
210
214
  };
211
- await pubsubUtils.publish(pubsubTopicUserFetch, socialOnlyTask);
212
- logger.log('INFO', `[Verification] Triggered social-only fetch for private user ${username} (${realCID})`);
215
+ await pubsubUtils.publish(taskEngineTopic, socialOnlyTask);
216
+ logger.log('INFO', `[Verification] Triggered social-only fetch for private user ${username} (${realCID}) via on-demand topic`);
213
217
  }
214
218
 
215
219
  return res.status(200).json({
@@ -13,15 +13,19 @@ const { handleSocialFetch } = require('./helpers/social_helpers');
13
13
  const { executeTasks, prepareTaskBatches } = require('./utils/task_engine_utils');
14
14
 
15
15
  async function handleRequest(message, context, configObj, dependencies) {
16
- // Support both old format (single config) and new format (object with taskEngine, rootDataIndexer, and social)
16
+ // Support both old format (single config) and new format (object with taskEngine, rootDataIndexer, social, and computationSystem)
17
17
  const config = configObj.taskEngine || configObj; // Backward compatibility
18
18
  const rootDataIndexerConfig = configObj.rootDataIndexer;
19
19
  const socialConfig = configObj.social;
20
+ const computationSystemConfig = configObj.computationSystem;
20
21
 
21
- // Merge social config into main config for easy access
22
+ // Merge configs into main config for easy access
22
23
  if (socialConfig) {
23
24
  config.social = socialConfig;
24
25
  }
26
+ if (computationSystemConfig) {
27
+ config.computationSystem = computationSystemConfig;
28
+ }
25
29
  const { logger, batchManager, db } = dependencies;
26
30
 
27
31
  // [CRITICAL FIX] Max Age increased to 25m to match the larger dedup window.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.476",
3
+ "version": "1.0.477",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [