bulltrackers-module 1.0.93 → 1.0.94

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.
@@ -2,18 +2,22 @@
2
2
  * @fileoverview Data loader sub-pipes for the Computation System.
3
3
  * REFACTORED: Now stateless and receive dependencies.
4
4
  */
5
- const { withRetry } = require('aiden-shared-calculations-unified').utils;
6
- const { FieldPath } = require('@google-cloud/firestore'); // <<< --- ADD FieldPath
5
+
6
+ // <<< FIX: REMOVED all top-level 'require' and 'dependencies' lines >>>
7
7
 
8
8
  /**
9
9
  * Sub-pipe: pipe.computationSystem.dataLoader.getPortfolioPartRefs
10
10
  * @param {object} config - The computation system configuration object.
11
- * @param {object} dependencies - Contains db, logger.
11
+ * @param {object} dependencies - Contains db, logger, calculationUtils.
12
12
  * @param {string} dateString - The date in YYYY-MM-DD format.
13
13
  * @returns {Promise<Firestore.DocumentReference[]>} An array of DocumentReferences.
14
14
  */
15
15
  async function getPortfolioPartRefs(config, dependencies, dateString) {
16
- const { db, logger } = dependencies;
16
+ // <<< FIX: Destructure all dependencies here, inside the function >>>
17
+ const { db, logger, calculationUtils } = dependencies;
18
+ const { withRetry } = calculationUtils;
19
+ // <<< END FIX >>>
20
+
17
21
  logger.log('INFO', `Getting portfolio part references for date: ${dateString}`);
18
22
  const allPartRefs = [];
19
23
  const collectionsToQuery = [config.normalUserPortfolioCollection, config.speculatorPortfolioCollection];
@@ -47,12 +51,16 @@ async function getPortfolioPartRefs(config, dependencies, dateString) {
47
51
  /**
48
52
  * Sub-pipe: pipe.computationSystem.dataLoader.loadDataByRefs
49
53
  * @param {object} config - The computation system configuration object.
50
- * @param {object} dependencies - Contains db, logger.
54
+ * @param {object} dependencies - Contains db, logger, calculationUtils.
51
55
  * @param {Firestore.DocumentReference[]} refs - An array of DocumentReferences to load.
52
56
  * @returns {Promise<object>} A single map of { [userId]: portfolioData }.
53
57
  */
54
58
  async function loadDataByRefs(config, dependencies, refs) {
55
- const { db, logger } = dependencies;
59
+ // <<< FIX: Destructure all dependencies here, inside the function >>>
60
+ const { db, logger, calculationUtils } = dependencies;
61
+ const { withRetry } = calculationUtils;
62
+ // <<< END FIX >>>
63
+
56
64
  if (!refs || refs.length === 0) { return {}; }
57
65
  const mergedPortfolios = {};
58
66
  const batchSize = config.partRefBatchSize || 50;
@@ -86,7 +94,10 @@ async function loadDataByRefs(config, dependencies, refs) {
86
94
  * @returns {Promise<object>} A single map of { [userId]: portfolioData }.
87
95
  */
88
96
  async function loadFullDayMap(config, dependencies, partRefs) {
97
+ // <<< FIX: Destructure only what's needed for this specific function >>>
89
98
  const { logger } = dependencies;
99
+ // <<< END FIX >>>
100
+
90
101
  if (partRefs.length === 0) return {};
91
102
  logger.log('TRACE', `Loading full day map from ${partRefs.length} references...`);
92
103
 
@@ -100,12 +111,16 @@ async function loadFullDayMap(config, dependencies, partRefs) {
100
111
  * Sub-pipe: pipe.computationSystem.dataLoader.loadDailyInsights
101
112
  * Fetches the daily instrument insights document for a specific date.
102
113
  * @param {object} config - The computation system configuration object.
103
- * @param {object} dependencies - Contains db, logger.
114
+ * @param {object} dependencies - Contains db, logger, calculationUtils.
104
115
  * @param {string} dateString - The date in YYYY-MM-DD format.
105
116
  * @returns {Promise<object|null>} The insights data object or null if not found/error.
106
117
  */
107
118
  async function loadDailyInsights(config, dependencies, dateString) {
108
- const { db, logger } = dependencies;
119
+ // <<< FIX: Destructure all dependencies here, inside the function >>>
120
+ const { db, logger, calculationUtils } = dependencies;
121
+ const { withRetry } = calculationUtils;
122
+ // <<< END FIX >>>
123
+
109
124
  const insightsCollectionName = config.insightsCollectionName || 'daily_instrument_insights'; // Use config or default
110
125
  logger.log('INFO', `Loading daily insights for date: ${dateString} from ${insightsCollectionName}`);
111
126
  try {
@@ -129,12 +144,16 @@ async function loadDailyInsights(config, dependencies, dateString) {
129
144
  * Sub-pipe: pipe.computationSystem.dataLoader.loadDailySocialPostInsights
130
145
  * Fetches all analyzed social post documents for a specific date.
131
146
  * @param {object} config - The computation system configuration object.
132
- * @param {object} dependencies - Contains db, logger.
147
+ * @param {object} dependencies - Contains db, logger, calculationUtils.
133
148
  * @param {string} dateString - The date in YYYY-MM-DD format.
134
149
  * @returns {Promise<object|null>} An object map of { [postId]: postData } or null.
135
150
  */
136
151
  async function loadDailySocialPostInsights(config, dependencies, dateString) {
137
- const { db, logger } = dependencies;
152
+ // <<< FIX: Destructure all dependencies here, inside the function >>>
153
+ const { db, logger, calculationUtils } = dependencies;
154
+ const { withRetry } = calculationUtils;
155
+ // <<< END FIX >>>
156
+
138
157
  // Use the new config property, or fall back to a default
139
158
  const socialInsightsCollectionName = config.socialInsightsCollectionName || 'daily_social_insights';
140
159
  logger.log('INFO', `Loading social post insights for date: ${dateString} from ${socialInsightsCollectionName}`);
@@ -170,4 +189,4 @@ module.exports = {
170
189
  loadFullDayMap,
171
190
  loadDailyInsights,
172
191
  loadDailySocialPostInsights,
173
- };
192
+ };
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  const { FieldValue, FieldPath } = require('@google-cloud/firestore');
8
+
8
9
  // --- REMOVED ---
9
10
  // const { utils } = require('aiden-shared-calculations-unified');
10
11
  // const { withRetry } = utils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.93",
3
+ "version": "1.0.94",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [