@kolmo/scout 0.1.0 → 0.1.1

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.
@@ -44,6 +44,7 @@ export async function buildScoutManifest(options) {
44
44
  const result = await scanExcel(absPath);
45
45
  columns = result.columns;
46
46
  sampleRows = result.sampleRows;
47
+ signals = result.cellValues; // cell values feed the asset detector
47
48
  metadata.sheetNames = result.sheetNames;
48
49
  metadata.sampleRowCount = result.sampleRows.length;
49
50
  metadata.profile = profileTabularData(columns, sampleRows);
@@ -2,4 +2,5 @@ export declare function scanExcel(filepath: string): Promise<{
2
2
  columns: string[];
3
3
  sheetNames: string[];
4
4
  sampleRows: Array<Record<string, unknown>>;
5
+ cellValues: string[];
5
6
  }>;
@@ -1,25 +1,64 @@
1
1
  import { readFile } from 'fs/promises';
2
2
  import * as XLSX from 'xlsx';
3
+ // Column names that likely contain asset/commodity names as cell values
4
+ const COMMODITY_COL_PATTERNS = [
5
+ /commodity/i, /instrument/i, /asset/i, /product/i, /grade/i,
6
+ /hub/i, /symbol/i, /ticker/i, /contract/i, /market/i,
7
+ /underlying/i, /security/i,
8
+ ];
9
+ function isCommodityColumn(colName) {
10
+ return COMMODITY_COL_PATTERNS.some((re) => re.test(colName));
11
+ }
3
12
  export async function scanExcel(filepath) {
4
13
  try {
5
14
  const buffer = await readFile(filepath);
6
- const workbook = XLSX.read(buffer, { type: 'buffer', sheetRows: 26 });
15
+ const workbook = XLSX.read(buffer, { type: 'buffer', sheetRows: 200 });
7
16
  const sheetNames = workbook.SheetNames;
8
17
  if (sheetNames.length === 0) {
9
- return { columns: [], sheetNames: [], sampleRows: [] };
18
+ return { columns: [], sheetNames: [], sampleRows: [], cellValues: [] };
19
+ }
20
+ // Collect cell values from all sheets (not just the first)
21
+ const allCellValues = new Set();
22
+ for (const sheetName of sheetNames) {
23
+ const sheet = workbook.Sheets[sheetName];
24
+ const rows = XLSX.utils.sheet_to_json(sheet, { defval: '' });
25
+ if (rows.length === 0)
26
+ continue;
27
+ // Column headers from every sheet are valuable (e.g. a "Forward Curves" sheet
28
+ // where commodity names ARE the column headers: "Brent Dated", "WTI Cushing"...)
29
+ const headers = Object.keys(rows[0]);
30
+ for (const h of headers) {
31
+ const v = h.trim();
32
+ if (v && v.length > 1 && v.length < 60)
33
+ allCellValues.add(v);
34
+ }
35
+ // Cell values from commodity-like columns + all short string values
36
+ const commodityCols = headers.filter(isCommodityColumn);
37
+ for (const row of rows) {
38
+ for (const col of commodityCols) {
39
+ const v = String(row[col] ?? '').trim();
40
+ if (v && v.length > 1 && v.length < 60)
41
+ allCellValues.add(v);
42
+ }
43
+ for (const col of headers) {
44
+ const v = String(row[col] ?? '').trim();
45
+ if (v && v.length > 1 && v.length < 40 && isNaN(Number(v)) && !/^\d{1,2}\/\d{1,2}\/\d{2,4}$/.test(v)) {
46
+ allCellValues.add(v);
47
+ }
48
+ }
49
+ }
10
50
  }
51
+ // Use first sheet for columns + sampleRows (legacy behaviour)
11
52
  const firstSheet = workbook.Sheets[sheetNames[0]];
12
53
  const rows = XLSX.utils.sheet_to_json(firstSheet, { header: 1 });
13
- const sampleRows = XLSX.utils.sheet_to_json(firstSheet, {
14
- defval: '',
15
- });
54
+ const sampleRows = XLSX.utils.sheet_to_json(firstSheet, { defval: '' });
16
55
  const headerRow = rows[0];
17
56
  const columns = Array.isArray(headerRow)
18
57
  ? headerRow.map((v) => String(v ?? '').trim()).filter(Boolean)
19
58
  : [];
20
- return { columns, sheetNames, sampleRows };
59
+ return { columns, sheetNames, sampleRows, cellValues: Array.from(allCellValues) };
21
60
  }
22
61
  catch {
23
- return { columns: [], sheetNames: [], sampleRows: [] };
62
+ return { columns: [], sheetNames: [], sampleRows: [], cellValues: [] };
24
63
  }
25
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kolmo/scout",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Kolmo Scout — scan local energy projects and connect to Kolmo analytics",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {