bulltrackers-module 1.0.634 → 1.0.635

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.
@@ -22,8 +46,12 @@ async function fetchDependencies(date, calcs, config, deps, manifestLookup = {})
22
46
  // 1. Identify unique dependencies needed
23
47
  const needed = new Set();
24
48
  calcs.forEach(c => {
25
- if (c.getDependencies) {
26
- const reqs = c.getDependencies();
49
+ // [FIX] Support both .getDependencies() method and .dependencies array
50
+ const reqs = (typeof c.getDependencies === 'function')
51
+ ? c.getDependencies()
52
+ : (c.dependencies || []);
53
+
54
+ if (Array.isArray(reqs)) {
27
55
  reqs.forEach(r => needed.add(normalizeName(r)));
28
56
  }
29
57
  });
@@ -150,4 +178,4 @@ async function fetchSingleResult(db, config, dateStr, name, category) {
150
178
  return data;
151
179
  }
152
180
 
153
- module.exports = { fetchDependencies, fetchResultSeries };
181
+ 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.635",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [