bulltrackers-module 1.0.105 → 1.0.106

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 (33) hide show
  1. package/README.MD +222 -222
  2. package/functions/appscript-api/helpers/errors.js +19 -19
  3. package/functions/appscript-api/index.js +58 -58
  4. package/functions/computation-system/helpers/orchestration_helpers.js +647 -113
  5. package/functions/computation-system/utils/data_loader.js +191 -191
  6. package/functions/computation-system/utils/utils.js +149 -254
  7. package/functions/core/utils/firestore_utils.js +433 -433
  8. package/functions/core/utils/pubsub_utils.js +53 -53
  9. package/functions/dispatcher/helpers/dispatch_helpers.js +47 -47
  10. package/functions/dispatcher/index.js +52 -52
  11. package/functions/etoro-price-fetcher/helpers/handler_helpers.js +124 -124
  12. package/functions/fetch-insights/helpers/handler_helpers.js +91 -91
  13. package/functions/generic-api/helpers/api_helpers.js +379 -379
  14. package/functions/generic-api/index.js +150 -150
  15. package/functions/invalid-speculator-handler/helpers/handler_helpers.js +75 -75
  16. package/functions/orchestrator/helpers/discovery_helpers.js +226 -226
  17. package/functions/orchestrator/helpers/update_helpers.js +92 -92
  18. package/functions/orchestrator/index.js +147 -147
  19. package/functions/price-backfill/helpers/handler_helpers.js +116 -123
  20. package/functions/social-orchestrator/helpers/orchestrator_helpers.js +61 -61
  21. package/functions/social-task-handler/helpers/handler_helpers.js +288 -288
  22. package/functions/task-engine/handler_creator.js +78 -78
  23. package/functions/task-engine/helpers/discover_helpers.js +125 -125
  24. package/functions/task-engine/helpers/update_helpers.js +118 -118
  25. package/functions/task-engine/helpers/verify_helpers.js +162 -162
  26. package/functions/task-engine/utils/firestore_batch_manager.js +258 -258
  27. package/index.js +105 -113
  28. package/package.json +45 -45
  29. package/functions/computation-system/computation_dependencies.json +0 -120
  30. package/functions/computation-system/helpers/worker_helpers.js +0 -340
  31. package/functions/computation-system/utils/computation_state_manager.js +0 -178
  32. package/functions/computation-system/utils/dependency_graph.js +0 -191
  33. package/functions/speculator-cleanup-orchestrator/helpers/cleanup_helpers.js +0 -160
@@ -1,62 +1,62 @@
1
- /**
2
- * @fileoverview Main pipe: pipe.maintenance.runSocialOrchestrator
3
- * This function is triggered by a schedule. It fans out the work by
4
- * publishing one Pub/Sub message for each target ticker.
5
- */
6
-
7
- /**
8
- * Main pipe (Orchestrator): pipe.maintenance.runSocialOrchestrator
9
- * @param {object} config - Configuration object.
10
- * @param {object} dependencies - Contains db, logger, firestoreUtils, pubsubUtils.
11
- * @returns {Promise<object>} Summary of the orchestration.
12
- */
13
- exports.runSocialOrchestrator = async (config, dependencies) => {
14
- const { logger, pubsubUtils } = dependencies;
15
- logger.log('INFO', '[SocialOrchestrator] Starting social post fetching orchestration...');
16
-
17
- // Validate configuration
18
- if (!config.targetTickerIds || !Array.isArray(config.targetTickerIds) || !config.socialFetchTaskTopicName || !config.socialFetchTimeWindowHours) {
19
- logger.log('ERROR', '[SocialOrchestrator] Missing required configuration: targetTickerIds (array), socialFetchTaskTopicName, or socialFetchTimeWindowHours.');
20
- throw new Error('Missing required configuration for Social Orchestrator.');
21
- }
22
-
23
- try {
24
- const tasks = [];
25
- const { targetTickerIds, socialFetchTimeWindowHours } = config;
26
-
27
- // Calculate the 'since' timestamp
28
- const sinceTimestamp = new Date();
29
- sinceTimestamp.setHours(sinceTimestamp.getHours() - socialFetchTimeWindowHours);
30
-
31
- // Add a 15-minute buffer to ensure overlap
32
- sinceTimestamp.setMinutes(sinceTimestamp.getMinutes() - 15);
33
-
34
- const sinceISO = sinceTimestamp.toISOString();
35
-
36
- for (const tickerId of targetTickerIds) {
37
- tasks.push({
38
- tickerId: String(tickerId), // Ensure it's a string
39
- since: sinceISO
40
- });
41
- }
42
-
43
- if (tasks.length === 0) {
44
- logger.log('WARN', '[SocialOrchestrator] No target tickers found to process.');
45
- return { success: true, message: "No target tickers configured." };
46
- }
47
-
48
- // Use pubsubUtils to batch publish all ticker tasks
49
- await pubsubUtils.batchPublishTasks(dependencies, {
50
- topicName: config.socialFetchTaskTopicName,
51
- tasks: tasks,
52
- taskType: 'social-fetch-task'
53
- });
54
-
55
- logger.log('SUCCESS', `[SocialOrchestrator] Successfully published ${tasks.length} social fetch tasks for window >= ${sinceISO}.`);
56
- return { success: true, tasksQueued: tasks.length };
57
-
58
- } catch (error) {
59
- logger.log('ERROR', '[SocialOrchestrator] Fatal error during orchestration.', { errorMessage: error.message, errorStack: error.stack });
60
- throw error;
61
- }
1
+ /**
2
+ * @fileoverview Main pipe: pipe.maintenance.runSocialOrchestrator
3
+ * This function is triggered by a schedule. It fans out the work by
4
+ * publishing one Pub/Sub message for each target ticker.
5
+ */
6
+
7
+ /**
8
+ * Main pipe (Orchestrator): pipe.maintenance.runSocialOrchestrator
9
+ * @param {object} config - Configuration object.
10
+ * @param {object} dependencies - Contains db, logger, firestoreUtils, pubsubUtils.
11
+ * @returns {Promise<object>} Summary of the orchestration.
12
+ */
13
+ exports.runSocialOrchestrator = async (config, dependencies) => {
14
+ const { logger, pubsubUtils } = dependencies;
15
+ logger.log('INFO', '[SocialOrchestrator] Starting social post fetching orchestration...');
16
+
17
+ // Validate configuration
18
+ if (!config.targetTickerIds || !Array.isArray(config.targetTickerIds) || !config.socialFetchTaskTopicName || !config.socialFetchTimeWindowHours) {
19
+ logger.log('ERROR', '[SocialOrchestrator] Missing required configuration: targetTickerIds (array), socialFetchTaskTopicName, or socialFetchTimeWindowHours.');
20
+ throw new Error('Missing required configuration for Social Orchestrator.');
21
+ }
22
+
23
+ try {
24
+ const tasks = [];
25
+ const { targetTickerIds, socialFetchTimeWindowHours } = config;
26
+
27
+ // Calculate the 'since' timestamp
28
+ const sinceTimestamp = new Date();
29
+ sinceTimestamp.setHours(sinceTimestamp.getHours() - socialFetchTimeWindowHours);
30
+
31
+ // Add a 15-minute buffer to ensure overlap
32
+ sinceTimestamp.setMinutes(sinceTimestamp.getMinutes() - 15);
33
+
34
+ const sinceISO = sinceTimestamp.toISOString();
35
+
36
+ for (const tickerId of targetTickerIds) {
37
+ tasks.push({
38
+ tickerId: String(tickerId), // Ensure it's a string
39
+ since: sinceISO
40
+ });
41
+ }
42
+
43
+ if (tasks.length === 0) {
44
+ logger.log('WARN', '[SocialOrchestrator] No target tickers found to process.');
45
+ return { success: true, message: "No target tickers configured." };
46
+ }
47
+
48
+ // Use pubsubUtils to batch publish all ticker tasks
49
+ await pubsubUtils.batchPublishTasks(dependencies, {
50
+ topicName: config.socialFetchTaskTopicName,
51
+ tasks: tasks,
52
+ taskType: 'social-fetch-task'
53
+ });
54
+
55
+ logger.log('SUCCESS', `[SocialOrchestrator] Successfully published ${tasks.length} social fetch tasks for window >= ${sinceISO}.`);
56
+ return { success: true, tasksQueued: tasks.length };
57
+
58
+ } catch (error) {
59
+ logger.log('ERROR', '[SocialOrchestrator] Fatal error during orchestration.', { errorMessage: error.message, errorStack: error.stack });
60
+ throw error;
61
+ }
62
62
  };