bulltrackers-module 1.0.634 → 1.0.636

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.
@@ -1,5 +1,7 @@
1
1
  /**
2
+ * FILENAME: computation-system/data/DependencyFetcher.js
2
3
  * @fileoverview Fetches dependencies for computations.
4
+ * UPDATED: Added 'fetchExistingResults' bridge for WorkflowOrchestrator compatibility.
3
5
  * UPDATED: Uses 'manifestLookup' to resolve the correct category (Core vs Non-Core).
4
6
  * UPDATED: Supports automatic reassembly of sharded results (_shards subcollection).
5
7
  * UPDATED: Supports decompression of zipped results.
@@ -7,6 +9,28 @@
7
9
  const { normalizeName } = require('../utils/utils');
8
10
  const zlib = require('zlib');
9
11
 
12
+ /**
13
+ * BRIDGE FUNCTION: Matches WorkflowOrchestrator signature.
14
+ * Adapts (dateStr, calcs, manifest, ...) -> (dateObj, calcs, ..., manifestLookup).
15
+ * This fixes the 'fetchExistingResults is not a function' TypeError.
16
+ */
17
+ async function fetchExistingResults(dateStr, calcs, fullManifest, config, deps, isHistoricalContext) {
18
+ // 1. Build Manifest Lookup (Name -> Category)
19
+ const manifestLookup = {};
20
+ if (Array.isArray(fullManifest)) {
21
+ fullManifest.forEach(c => {
22
+ manifestLookup[normalizeName(c.name)] = c.category || 'analytics';
23
+ });
24
+ }
25
+
26
+ // 2. Convert Date String to Date Object
27
+ // We append T00:00:00Z to ensure it parses as UTC date if only YYYY-MM-DD is provided.
28
+ const dateObj = new Date(dateStr + (dateStr.includes('T') ? '' : 'T00:00:00Z'));
29
+
30
+ // 3. Delegate to fetchDependencies
31
+ return fetchDependencies(dateObj, calcs, config, deps, manifestLookup);
32
+ }
33
+
10
34
  /**
11
35
  * Fetches dependencies for a specific date (Standard pass).
12
36
  * @param {Date} date - The target date.
@@ -20,11 +44,22 @@ async function fetchDependencies(date, calcs, config, deps, manifestLookup = {})
20
44
  const dStr = date.toISOString().slice(0, 10);
21
45
 
22
46
  // 1. Identify unique dependencies needed
23
- const needed = new Set();
47
+ // CHANGED: Use a Map to track { normalizedName: originalName }
48
+ const needed = new Map();
49
+
24
50
  calcs.forEach(c => {
25
- if (c.getDependencies) {
26
- const reqs = c.getDependencies();
27
- reqs.forEach(r => needed.add(normalizeName(r)));
51
+ // [FIX] Support both .getDependencies() method and .dependencies array
52
+ const reqs = (typeof c.getDependencies === 'function')
53
+ ? c.getDependencies()
54
+ : (c.dependencies || []);
55
+
56
+ if (Array.isArray(reqs)) {
57
+ reqs.forEach(r => {
58
+ // We map the normalized version to the original requested version
59
+ // This ensures we fetch the right file (normalized) but return it
60
+ // with the casing the user code expects (original).
61
+ needed.set(normalizeName(r), r);
62
+ });
28
63
  }
29
64
  });
30
65
 
@@ -33,14 +68,20 @@ async function fetchDependencies(date, calcs, config, deps, manifestLookup = {})
33
68
  logger.log('INFO', `[DependencyFetcher] Fetching ${needed.size} dependencies for ${dStr}`);
34
69
 
35
70
  const results = {};
36
- const promises = Array.from(needed).map(async (name) => {
71
+ // CHANGED: Iterate over the entries to access both normalized and original names
72
+ const promises = Array.from(needed.entries()).map(async ([normName, originalName]) => {
37
73
  try {
38
74
  // Resolve Category from Lookup, default to 'analytics' if unknown
39
- const category = manifestLookup[name] || 'analytics';
40
- const data = await fetchSingleResult(db, config, dStr, name, category);
41
- if (data) results[name] = data;
75
+ // Note: manifestLookup keys are expected to be normalized
76
+ const category = manifestLookup[normName] || 'analytics';
77
+
78
+ // Fetch using the normalized name (system standard)
79
+ const data = await fetchSingleResult(db, config, dStr, normName, category);
80
+
81
+ // CHANGED: Store result using the ORIGINAL name so context.computed['CaseSensitive'] works
82
+ if (data) results[originalName] = data;
42
83
  } catch (e) {
43
- logger.log('WARN', `[DependencyFetcher] Failed to load dependency ${name}: ${e.message}`);
84
+ logger.log('WARN', `[DependencyFetcher] Failed to load dependency ${originalName}: ${e.message}`);
44
85
  }
45
86
  });
46
87
 
@@ -150,4 +191,4 @@ async function fetchSingleResult(db, config, dateStr, name, category) {
150
191
  return data;
151
192
  }
152
193
 
153
- module.exports = { fetchDependencies, fetchResultSeries };
194
+ module.exports = { fetchDependencies, fetchResultSeries, fetchExistingResults };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.634",
3
+ "version": "1.0.636",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [