bulltrackers-module 1.0.28 → 1.0.30

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.
package/README.MD CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  This package encapsulates the core logic and shared utilities for the BullTrackers cloud function architecture. It promotes code reuse and separation of concerns by providing abstracted handlers and helper functions for various backend services.
8
8
 
9
- ## Core Concepts (Based on your Documentation.md)
9
+ ## Core Concepts
10
10
 
11
11
  * **eToro User IDs (CIDs):** Sequential integers assigned upon registration.
12
12
 
@@ -35,6 +35,60 @@ function createApiApp(config, dependencies, unifiedCalculations) {
35
35
  res.status(200).send('OK');
36
36
  });
37
37
 
38
+ // --- NEW: Debug Endpoint to list all computation keys ---
39
+ app.get('/list-computations', (req, res) => {
40
+ try {
41
+ const computationKeys = Object.keys(calcMap);
42
+ res.status(200).send({
43
+ status: 'success',
44
+ count: computationKeys.length,
45
+ computations: computationKeys.sort(),
46
+ });
47
+ } catch (error) {
48
+ logger.log('ERROR', 'API /list-computations failed.', { errorMessage: error.message });
49
+ res.status(500).send({ status: 'error', message: 'An internal error occurred.' });
50
+ }
51
+ });
52
+
53
+ // --- NEW: Debug Endpoint to get the structure of a computation ---
54
+ app.get('/structure/:computationName', (req, res) => {
55
+ const { computationName } = req.params;
56
+ try {
57
+ const pathInfo = calcMap[computationName];
58
+ if (!pathInfo) {
59
+ return res.status(404).send({ status: 'error', message: `Computation '${computationName}' not found.` });
60
+ }
61
+
62
+ const { category } = pathInfo;
63
+ const CalculationClass = unifiedCalculations[category]?.[computationName];
64
+
65
+ if (typeof CalculationClass !== 'function') {
66
+ logger.log('WARN', `API /structure: No calculation class found for ${category}/${computationName}.`);
67
+ return res.status(404).send({ status: 'error', message: `Could not find calculation class for '${computationName}'.` });
68
+ }
69
+
70
+ // Instantiate the class and get its default result
71
+ const calcInstance = new CalculationClass();
72
+ if (typeof calcInstance.getResult === 'function') {
73
+ const structure = calcInstance.getResult();
74
+ res.status(200).send({
75
+ status: 'success',
76
+ computation: computationName,
77
+ category: category,
78
+ structure: structure || {}, // Ensure it returns at least an empty object
79
+ });
80
+ } else {
81
+ logger.log('WARN', `API /structure: Class ${category}/${computationName} has no getResult() method.`);
82
+ return res.status(501).send({ status: 'error', message: `Calculation '${computationName}' exists but does not have a getResult() method to determine structure.` });
83
+ }
84
+
85
+ } catch (error) {
86
+ logger.log('ERROR', `API /structure/${computationName} failed.`, { errorMessage: error.message, stack: error.stack });
87
+ res.status(500).send({ status: 'error', message: `An internal error occurred while processing '${computationName}'.` });
88
+ }
89
+ });
90
+
91
+
38
92
  return app;
39
93
  }
40
94
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -17,9 +17,6 @@
17
17
  "functions/etoro-price-fetcher/",
18
18
  "functions/appscript-api/"
19
19
  ],
20
- "scripts": {
21
- "test": "echo \"Error: no test specified\" && exit 1"
22
- },
23
20
  "keywords": [
24
21
  "bulltrackers",
25
22
  "etoro",