@nodetool-ai/data-nodes 0.8.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.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # @nodetool-ai/data-nodes
2
+
3
+ Dataframe iteration and chart nodes for [NodeTool](https://nodetool.ai).
4
+
5
+ Iterate tabular data and render charts to images in visual AI workflows. CSV
6
+ parsing and dataframe shaping (filter, join, aggregate, pivot) now happen
7
+ inside a `nodetool.code.Code` node via the `@nodetool-ai/sandbox-csv`
8
+ (papaparse) sandbox pack instead of dedicated node classes.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install @nodetool-ai/data-nodes
14
+ ```
15
+
16
+ ## Nodes
17
+
18
+ **Dataframe** (`nodetool.data.*`) — `ForEachRow` (stream rows of a dataframe),
19
+ `LoadCSVAssets` (load dataframes from an asset folder).
20
+
21
+ **Charts** (`lib.charts.ChartRenderer`) — render a Chart.js chart definition to
22
+ a PNG image.
23
+
24
+ ## Links
25
+
26
+ - [NodeTool](https://nodetool.ai)
27
+ - [GitHub](https://github.com/nodetool-ai/nodetool)
@@ -0,0 +1 @@
1
+ 2026-09-28T09:19:11.273Z
@@ -0,0 +1,3 @@
1
+ export * from "./nodes/data.js";
2
+ export * from "./nodes/lib-charts.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./nodes/data.js";
2
+ export * from "./nodes/lib-charts.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,118 @@
1
+ import { BaseNode } from "@nodetool-ai/node-sdk";
2
+ import type { ColumnDef, FolderRef, InputMode, Platform } from "@nodetool-ai/protocol";
3
+ /**
4
+ * One dataframe cell. CSV parsing yields the scalars; a dataframe another node
5
+ * built can carry nested JSON in a cell, which these nodes pass through
6
+ * untouched.
7
+ */
8
+ export type CellValue = string | number | boolean | null | CellValue[] | {
9
+ [column: string]: CellValue;
10
+ };
11
+ /** A dataframe row keyed by column name. */
12
+ export type Row = {
13
+ [column: string]: CellValue;
14
+ };
15
+ /** The `{ rows }` dataframe these nodes emit and {@link asRows} reads back. */
16
+ type RowsDataframe = {
17
+ rows: Row[];
18
+ };
19
+ /**
20
+ * A column header as a dataframe payload carries it: the protocol's `ColumnDef`
21
+ * for a `DataframeRef`, or a bare name for a hand-built `{ columns, data }`.
22
+ */
23
+ type ColumnHeader = ColumnDef | string;
24
+ /**
25
+ * A dataframe that wraps its rows instead of being an array of them: `{ rows }`
26
+ * from these nodes, or the `{ columns, data }` column matrix a `DataframeRef`
27
+ * carries.
28
+ */
29
+ type DataframeEnvelope = {
30
+ rows?: DataframeInput;
31
+ data?: DataframeInput;
32
+ columns?: ColumnHeader[];
33
+ };
34
+ /** Whatever a `dataframe` property holds by the time it reaches these nodes. */
35
+ export type DataframeInput = DataframeEnvelope | CellValue | undefined;
36
+ export declare function asRows(value: DataframeInput): Row[];
37
+ /** Output handles ForEachRowNode emits — all of them from genProcess(). */
38
+ type ForEachRowNodeOutputs = {
39
+ row: Row;
40
+ index: number;
41
+ };
42
+ export declare class ForEachRowNode extends BaseNode {
43
+ static readonly nodeType = "nodetool.data.ForEachRow";
44
+ static readonly retrySafe = true;
45
+ static readonly title = "For Each Row";
46
+ static readonly description = "Iterate over rows of a dataframe.\n iterator, loop, dataframe, sequence, rows\n\n Use cases:\n - Process each row of a dataframe individually\n - Trigger actions for every record in a dataset";
47
+ static readonly inlineFields: never[];
48
+ static readonly inputFields: string[];
49
+ static readonly metadataOutputTypes: {
50
+ row: string;
51
+ index: string;
52
+ };
53
+ static readonly inputMode: InputMode;
54
+ static readonly outputCorrelation: {
55
+ row: {
56
+ kind: "iteration";
57
+ source: string;
58
+ group: string;
59
+ };
60
+ index: {
61
+ kind: "iteration";
62
+ source: string;
63
+ group: string;
64
+ };
65
+ };
66
+ dataframe: DataframeInput;
67
+ process(): Promise<Partial<ForEachRowNodeOutputs>>;
68
+ genProcess(): AsyncGenerator<ForEachRowNodeOutputs>;
69
+ }
70
+ /** Output handles LoadCSVAssetsNode emits; genProcess() emits them in batches. */
71
+ type LoadCSVAssetsNodeOutputs = {
72
+ dataframe: RowsDataframe;
73
+ name: string;
74
+ dataframes: RowsDataframe[];
75
+ names: string[];
76
+ };
77
+ export declare class LoadCSVAssetsNode extends BaseNode {
78
+ static readonly nodeType = "nodetool.data.LoadCSVAssets";
79
+ static readonly platforms: readonly Platform[];
80
+ static readonly title = "Load CSV Assets";
81
+ static readonly description = "Load dataframes from an asset folder.\n load, dataframe, file, import\n\n Use cases:\n - Load multiple dataframes from a folder\n - Process multiple datasets in sequence\n - Batch import of data files";
82
+ static readonly inlineFields: never[];
83
+ static readonly inputFields: string[];
84
+ static readonly metadataOutputTypes: {
85
+ dataframe: string;
86
+ name: string;
87
+ dataframes: string;
88
+ names: string;
89
+ };
90
+ static readonly inputMode: InputMode;
91
+ static readonly outputCorrelation: {
92
+ dataframe: {
93
+ kind: "iteration";
94
+ source: string;
95
+ group: string;
96
+ };
97
+ name: {
98
+ kind: "iteration";
99
+ source: string;
100
+ group: string;
101
+ };
102
+ dataframes: {
103
+ kind: "single";
104
+ source: string;
105
+ };
106
+ names: {
107
+ kind: "single";
108
+ source: string;
109
+ };
110
+ };
111
+ folder: FolderRef | string;
112
+ process(): Promise<LoadCSVAssetsNodeOutputs>;
113
+ private _collectItems;
114
+ genProcess(): AsyncGenerator<Partial<LoadCSVAssetsNodeOutputs>>;
115
+ }
116
+ export declare const DATA_NODES: (typeof ForEachRowNode | typeof LoadCSVAsset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;;;;;;;;;;;;;;;;MAKa;IActC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC;IAE7B,OAAO,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAajD;YAEc,aAAa;IAiBrB,UAAU,IAAI,cAAc,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAUrE;CACF;AAED,eAAO,MAAM,UAAU,sDAAmD,CAAC"}
@@ -0,0 +1,206 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseNode, isString, prop } from "@nodetool-ai/node-sdk";
8
+ import { loadNodeFsPromises, loadNodePath, loadNodeUrl } from "@nodetool-ai/nodes-utils";
9
+ import Papa from "papaparse";
10
+ import { tagAsServer } from "@nodetool-ai/nodes-utils";
11
+ const NODE_ONLY = ["node"];
12
+ function isRow(value) {
13
+ return typeof value === "object" && value !== null && !Array.isArray(value);
14
+ }
15
+ function isEnvelope(value) {
16
+ return typeof value === "object" && value !== null && !Array.isArray(value);
17
+ }
18
+ function isColumnDef(header) {
19
+ return typeof header === "object" && header !== null && "name" in header;
20
+ }
21
+ /** `header.name` is untrusted despite `ColumnDef` declaring it a string. */
22
+ function columnName(header) {
23
+ return isColumnDef(header) ? String(header.name ?? "") : String(header);
24
+ }
25
+ function rowsFromColumnData(columns, data) {
26
+ const names = columns.map(columnName).filter((name) => name.length > 0);
27
+ if (names.length === 0)
28
+ return [];
29
+ return data.map((row) => {
30
+ const record = {};
31
+ names.forEach((name, index) => {
32
+ record[name] = row[index] ?? null;
33
+ });
34
+ return record;
35
+ });
36
+ }
37
+ function isArrayMatrix(data) {
38
+ if (data.length === 0)
39
+ return true;
40
+ return data.every((row) => Array.isArray(row));
41
+ }
42
+ export function asRows(value) {
43
+ if (Array.isArray(value)) {
44
+ return value.filter(isRow).map((row) => ({ ...row }));
45
+ }
46
+ if (isEnvelope(value)) {
47
+ if (Array.isArray(value.rows))
48
+ return asRows(value.rows);
49
+ if (Array.isArray(value.columns) &&
50
+ Array.isArray(value.data) &&
51
+ isArrayMatrix(value.data)) {
52
+ return rowsFromColumnData(value.columns, value.data);
53
+ }
54
+ if (Array.isArray(value.data))
55
+ return asRows(value.data);
56
+ }
57
+ return [];
58
+ }
59
+ function toDataframe(rows) {
60
+ return { rows };
61
+ }
62
+ /**
63
+ * A `folder` prop carries a `FolderRef`, not a path. Its `uri` is the directory
64
+ * to scan; an empty ref (the descriptor default) means the working directory.
65
+ */
66
+ async function folderPath(folder) {
67
+ const uri = isString(folder) ? folder : (folder?.uri ?? "");
68
+ if (!uri)
69
+ return ".";
70
+ if (!uri.startsWith("file://"))
71
+ return uri;
72
+ try {
73
+ const { fileURLToPath } = await loadNodeUrl();
74
+ return fileURLToPath(new URL(uri));
75
+ }
76
+ catch {
77
+ return uri.slice("file://".length);
78
+ }
79
+ }
80
+ function parseCsv(csv) {
81
+ if (!csv)
82
+ return [];
83
+ const result = Papa.parse(csv, {
84
+ header: true,
85
+ dynamicTyping: true,
86
+ skipEmptyLines: true,
87
+ transformHeader: (h) => h.trim()
88
+ });
89
+ return (result.data ?? []).filter((row) => !!row && typeof row === "object");
90
+ }
91
+ export class ForEachRowNode extends BaseNode {
92
+ static nodeType = "nodetool.data.ForEachRow";
93
+ static retrySafe = true;
94
+ static title = "For Each Row";
95
+ static description = "Iterate over rows of a dataframe.\n iterator, loop, dataframe, sequence, rows\n\n Use cases:\n - Process each row of a dataframe individually\n - Trigger actions for every record in a dataset";
96
+ static inlineFields = [];
97
+ static inputFields = ["dataframe"];
98
+ static metadataOutputTypes = {
99
+ row: "dict",
100
+ index: "any"
101
+ };
102
+ static inputMode = "buffered";
103
+ static outputCorrelation = {
104
+ row: { kind: "iteration", source: "dataframe", group: "items" },
105
+ index: { kind: "iteration", source: "dataframe", group: "items" }
106
+ };
107
+ async process() {
108
+ return {};
109
+ }
110
+ async *genProcess() {
111
+ const rows = asRows(this.dataframe);
112
+ for (const [index, row] of rows.entries()) {
113
+ yield { row, index };
114
+ }
115
+ }
116
+ }
117
+ __decorate([
118
+ prop({
119
+ type: "dataframe",
120
+ default: {
121
+ type: "dataframe",
122
+ uri: "",
123
+ asset_id: null,
124
+ data: null,
125
+ metadata: null,
126
+ columns: null
127
+ },
128
+ title: "Dataframe",
129
+ description: "The input dataframe."
130
+ })
131
+ ], ForEachRowNode.prototype, "dataframe", void 0);
132
+ export class LoadCSVAssetsNode extends BaseNode {
133
+ static nodeType = "nodetool.data.LoadCSVAssets";
134
+ static platforms = NODE_ONLY;
135
+ static title = "Load CSV Assets";
136
+ static description = "Load dataframes from an asset folder.\n load, dataframe, file, import\n\n Use cases:\n - Load multiple dataframes from a folder\n - Process multiple datasets in sequence\n - Batch import of data files";
137
+ static inlineFields = [];
138
+ static inputFields = ["folder"];
139
+ static metadataOutputTypes = {
140
+ dataframe: "dataframe",
141
+ name: "str",
142
+ dataframes: "list",
143
+ names: "list"
144
+ };
145
+ static inputMode = "buffered";
146
+ static outputCorrelation = {
147
+ dataframe: { kind: "iteration", source: "folder", group: "items" },
148
+ name: { kind: "iteration", source: "folder", group: "items" },
149
+ dataframes: { kind: "single", source: "folder" },
150
+ names: { kind: "single", source: "folder" }
151
+ };
152
+ async process() {
153
+ const allDataframes = [];
154
+ const allNames = [];
155
+ for await (const item of this._collectItems()) {
156
+ allDataframes.push(item.dataframe);
157
+ allNames.push(item.name);
158
+ }
159
+ return {
160
+ dataframe: allDataframes[0] ?? toDataframe([]),
161
+ name: allNames[0] ?? "",
162
+ dataframes: allDataframes,
163
+ names: allNames
164
+ };
165
+ }
166
+ async *_collectItems() {
167
+ const folder = await folderPath(this.folder);
168
+ const fs = await loadNodeFsPromises();
169
+ const path = await loadNodePath();
170
+ const entries = await fs.readdir(folder, { withFileTypes: true });
171
+ for (const entry of entries) {
172
+ if (!entry.isFile() || !entry.name.toLowerCase().endsWith(".csv"))
173
+ continue;
174
+ const full = path.join(folder, entry.name);
175
+ const csv = await fs.readFile(full, "utf8");
176
+ yield { name: entry.name, dataframe: toDataframe(parseCsv(csv)) };
177
+ }
178
+ }
179
+ async *genProcess() {
180
+ const allDataframes = [];
181
+ const allNames = [];
182
+ for await (const item of this._collectItems()) {
183
+ allDataframes.push(item.dataframe);
184
+ allNames.push(item.name);
185
+ yield { name: item.name, dataframe: item.dataframe };
186
+ }
187
+ // Emit collected lists as final output
188
+ yield { dataframes: allDataframes, names: allNames };
189
+ }
190
+ }
191
+ __decorate([
192
+ prop({
193
+ type: "folder",
194
+ default: {
195
+ type: "folder",
196
+ uri: "",
197
+ asset_id: null,
198
+ data: null,
199
+ metadata: null
200
+ },
201
+ title: "Folder",
202
+ description: "The asset folder to load the dataframes from."
203
+ })
204
+ ], LoadCSVAssetsNode.prototype, "folder", void 0);
205
+ export const DATA_NODES = tagAsServer([ForEachRowNode, LoadCSVAssetsNode]);
206
+ //# sourceMappingURL=data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/nodes/data.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAQjE,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,MAAM,SAAS,GAAwB,CAAC,MAAM,CAAC,CAAC;AAyChD,SAAS,KAAK,CAAC,KAAgB;IAC7B,OAAO,OAAO,KA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EAAE,QAAQ,EAAE,CAAC;IACvD,CAAC;CACF;AA7CS;IAZP,IAAI,CAAC;QACJ,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,GAAG,EAAE,EAAE;YACP,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,IAAI;SACf;QACD,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,+CAA+C;KAC7D,CAAC;iDACiC;AA+CrC,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { BaseNode } from "@nodetool-ai/node-sdk";
2
+ import type { ChartConfig } from "@nodetool-ai/protocol";
3
+ import { type DataframeInput } from "./data.js";
4
+ /** Output handles ChartRendererLibNode.process() emits. */
5
+ type ChartRendererLibNodeOutputs = {
6
+ output: {
7
+ type: string;
8
+ data: string;
9
+ };
10
+ };
11
+ export declare class ChartRendererLibNode extends BaseNode {
12
+ static readonly nodeType = "lib.charts.ChartRenderer";
13
+ static readonly retrySafe = true;
14
+ static readonly title = "Chart Renderer";
15
+ static readonly description = "Node responsible for rendering chart configurations into image format using seaborn.\n chart, seaborn, plot, visualization, data";
16
+ static readonly inlineFields: string[];
17
+ static readonly inputFields: string[];
18
+ static readonly metadataOutputTypes: {
19
+ output: string;
20
+ };
21
+ chart_config: ChartConfig;
22
+ width: number;
23
+ height: number;
24
+ data: DataframeInput;
25
+ background_color: string;
26
+ trim_margins: boolean;
27
+ process(): Promise<ChartRendererLibNodeOutputs>;
28
+ }
29
+ export declare const LIB_SEABORN_NODES: (typeof ChartRendererLibNode)[];
30
+ export {};
31
+ //# sourceMappingURL=lib-charts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib-charts.d.ts","sourceRoot":"","sources":["../../src/nodes/lib-charts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAQ,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAA0B,MAAM,uBAAuB,CAAC;AACjF,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAExD,2DAA2D;AAC3D,KAAK,2BAA2B,GAAG;IACjC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC,CAAC;AAmBF,qBAAa,oBAAqB,SAAQ,QAAQ;IAChD,MAAM,CAAC,QAAQ,CAAC,QAAQ,8BAA8B;IACtD,MAAM,CAAC,QAAQ,CAAC,SAAS,QAAQ;IACjC,MAAM,CAAC,QAAQ,CAAC,KAAK,oBAAoB;IACzC,MAAM,CAAC,QAAQ,CAAC,WAAW,yIAC6G;IACxI,MAAM,CAAC,QAAQ,CAAC,YAAY,WAAoB;IAChD,MAAM,CAAC,QAAQ,CAAC,WAAW,WAAY;IACvC,MAAM,CAAC,QAAQ,CAAC,mBAAmB;QACjC,MAAM;MACN;IA6CM,YAAY,EAAE,WAAW,CAAC;IAU1B,KAAK,EAAE,MAAM,CAAC;IAUd,MAAM,EAAE,MAAM,CAAC;IAef,IAAI,EAAE,cAAc,CAAC;IAQrB,gBAAgB,EAAE,MAAM,CAAC;IAQzB,YAAY,EAAE,OAAO,CAAC;IAExB,OAAO,IAAI,OAAO,CAAC,2BAA2B,CAAC,CAgKpD;CACF;AAKD,eAAO,MAAM,iBAAiB,iCAAyB,CAAC"}
@@ -0,0 +1,275 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseNode, prop } from "@nodetool-ai/node-sdk";
8
+ import { asRows } from "./data.js";
9
+ /** Seaborn plot kinds a chart config can name, mapped to what chart.js draws. */
10
+ const PLOT_TYPE_CHARTS = {
11
+ scatter: "scatter",
12
+ line: "line",
13
+ barplot: "bar",
14
+ histplot: "bar",
15
+ boxplot: "bar",
16
+ pointplot: "line",
17
+ countplot: "bar"
18
+ };
19
+ function isPlotType(plot) {
20
+ return Object.hasOwn(PLOT_TYPE_CHARTS, plot);
21
+ }
22
+ export class ChartRendererLibNode extends BaseNode {
23
+ static nodeType = "lib.charts.ChartRenderer";
24
+ static retrySafe = true;
25
+ static title = "Chart Renderer";
26
+ static description = "Node responsible for rendering chart configurations into image format using seaborn.\n chart, seaborn, plot, visualization, data";
27
+ static inlineFields = ["chart_config"];
28
+ static inputFields = ["data"];
29
+ static metadataOutputTypes = {
30
+ output: "image"
31
+ };
32
+ async process() {
33
+ const config = this.chart_config;
34
+ const width = this.width;
35
+ const height = this.height;
36
+ // Accept both dataframe shapes: row-records ({ rows }), as produced by the
37
+ // data nodes, and the canonical column matrix ({ columns, data }). asRows
38
+ // normalizes either into row records, which we turn into the column matrix
39
+ // chart.js consumes below.
40
+ const records = asRows(this.data);
41
+ if (!records.length) {
42
+ throw new Error("Data is required for rendering the chart.");
43
+ }
44
+ const keys = new Set();
45
+ for (let i = 0; i < records.length; i++) {
46
+ const row = records[i];
47
+ if (row) {
48
+ for (const key in row) {
49
+ if (Object.prototype.hasOwnProperty.call(row, key)) {
50
+ keys.add(key);
51
+ }
52
+ }
53
+ }
54
+ }
55
+ const colNames = [...keys];
56
+ const rows = records.map((r) => colNames.map((name) => r[name] ?? null));
57
+ let createCanvas;
58
+ let napiPath2D;
59
+ let ChartJS;
60
+ try {
61
+ ({ createCanvas, Path2D: napiPath2D } = await import("@napi-rs/canvas"));
62
+ ChartJS = await import("chart.js");
63
+ }
64
+ catch (e) {
65
+ throw new Error("Chart rendering requires '@napi-rs/canvas' and 'chart.js'. " +
66
+ "Install them with: npm install @napi-rs/canvas chart.js. " +
67
+ `(${e instanceof Error ? e.message : String(e)})`);
68
+ }
69
+ // chart.js reads globalThis.Path2D for path caching. Some peer libraries
70
+ // (e.g. @llamaindex/liteparse, used by ConvertToMarkdown for PDF text
71
+ // extraction) install a no-op Path2D stub so pdf.js can import in Node;
72
+ // chart.js then constructs that empty stub and crashes with
73
+ // "ctx.moveTo is not a function". Restore @napi-rs/canvas's real Path2D
74
+ // for the duration of rendering.
75
+ const previousPath2D = globalThis.Path2D;
76
+ // SAFETY: `lib.dom` types `Path2D` as a global class, so its declared type
77
+ // admits neither skia's constructor here nor the `delete` below. The
78
+ // `finally` restores exactly what `previousPath2D` captured.
79
+ globalThis.Path2D = napiPath2D;
80
+ const { Chart, registerables } = ChartJS;
81
+ Chart.register(...registerables);
82
+ const configData = config.data ?? {
83
+ type: "chart_data",
84
+ series: []
85
+ };
86
+ const series = configData.series ?? [];
87
+ const firstSeries = series[0] ?? {};
88
+ const plotType = String(firstSeries.plot_type ?? "barplot").toLowerCase();
89
+ const chartType = isPlotType(plotType)
90
+ ? PLOT_TYPE_CHARTS[plotType]
91
+ : "bar";
92
+ // Extract x and y column indices
93
+ const xCol = String(firstSeries.x ?? colNames[0] ?? "");
94
+ const yCol = String(firstSeries.y ?? colNames[1] ?? "");
95
+ const xIdx = colNames.indexOf(xCol);
96
+ const yIdx = colNames.indexOf(yCol);
97
+ const labels = xIdx >= 0
98
+ ? rows.map((r) => String(r[xIdx]))
99
+ : rows.map((_, i) => String(i));
100
+ const values = yIdx >= 0 ? rows.map((r) => Number(r[yIdx])) : [];
101
+ const datasets = series.length > 0
102
+ ? series.map((s) => {
103
+ const sYCol = String(s.y ?? yCol);
104
+ const sYIdx = colNames.indexOf(sYCol);
105
+ const data = sYIdx >= 0 ? rows.map((r) => Number(r[sYIdx])) : values;
106
+ return {
107
+ label: sYCol,
108
+ data,
109
+ backgroundColor: s.color ? String(s.color) : undefined
110
+ };
111
+ })
112
+ : [{ label: yCol, data: values }];
113
+ const chartConfig = {
114
+ type: chartType,
115
+ data: { labels, datasets },
116
+ options: {
117
+ responsive: false,
118
+ // "Tight layout" in the seaborn config this node ports: no padding
119
+ // around the plot area.
120
+ layout: { padding: this.trim_margins ? 0 : 8 },
121
+ plugins: {
122
+ title: config.title
123
+ ? { display: true, text: String(config.title) }
124
+ : undefined
125
+ },
126
+ scales: {
127
+ x: config.x_label
128
+ ? { title: { display: true, text: String(config.x_label) } }
129
+ : undefined,
130
+ y: config.y_label
131
+ ? { title: { display: true, text: String(config.y_label) } }
132
+ : undefined
133
+ }
134
+ }
135
+ };
136
+ const backgroundColor = this.background_color;
137
+ const cvs = createCanvas(width, height);
138
+ const ctx = cvs.getContext("2d");
139
+ // Fill background
140
+ ctx.fillStyle = backgroundColor;
141
+ ctx.fillRect(0, 0, width, height);
142
+ let buffer;
143
+ try {
144
+ // SAFETY: Chart.js only draws through the 2D methods a skia canvas
145
+ // implements. The DOM `CanvasRenderingContext2D` it names also declares
146
+ // members skia cannot have (`drawFocusIfNeeded`, an `HTMLCanvasElement`
147
+ // `canvas`) and Chart.js never calls.
148
+ const chartCtx = ctx;
149
+ const chart = new Chart(chartCtx, {
150
+ ...chartConfig,
151
+ options: {
152
+ ...chartConfig.options,
153
+ responsive: false,
154
+ animation: false
155
+ }
156
+ });
157
+ chart.draw();
158
+ buffer = cvs.toBuffer("image/png");
159
+ chart.destroy();
160
+ }
161
+ finally {
162
+ if (previousPath2D === undefined) {
163
+ // SAFETY: nothing declared `Path2D` before this render, so removing the
164
+ // one installed above restores the environment the node inherited.
165
+ delete globalThis.Path2D;
166
+ }
167
+ else {
168
+ globalThis.Path2D = previousPath2D;
169
+ }
170
+ }
171
+ const data = Buffer.from(buffer).toString("base64");
172
+ return { output: { type: "image", data } };
173
+ }
174
+ }
175
+ __decorate([
176
+ prop({
177
+ type: "chart_config",
178
+ default: {
179
+ type: "chart_config",
180
+ title: "",
181
+ x_label: "",
182
+ y_label: "",
183
+ legend: true,
184
+ data: {
185
+ type: "chart_data",
186
+ series: [],
187
+ row: null,
188
+ col: null,
189
+ col_wrap: null
190
+ },
191
+ height: null,
192
+ aspect: null,
193
+ x_lim: null,
194
+ y_lim: null,
195
+ x_scale: null,
196
+ y_scale: null,
197
+ legend_position: "auto",
198
+ palette: null,
199
+ hue_order: null,
200
+ hue_norm: null,
201
+ sizes: null,
202
+ size_order: null,
203
+ size_norm: null,
204
+ marginal_kws: null,
205
+ joint_kws: null,
206
+ diag_kind: null,
207
+ corner: false,
208
+ center: null,
209
+ vmin: null,
210
+ vmax: null,
211
+ cmap: null,
212
+ annot: false,
213
+ fmt: ".2g",
214
+ square: false
215
+ },
216
+ title: "Chart Config",
217
+ description: "The chart configuration to render."
218
+ })
219
+ ], ChartRendererLibNode.prototype, "chart_config", void 0);
220
+ __decorate([
221
+ prop({
222
+ type: "int",
223
+ default: 640,
224
+ title: "Width",
225
+ description: "The width of the chart in pixels.",
226
+ min: 0,
227
+ max: 10000
228
+ })
229
+ ], ChartRendererLibNode.prototype, "width", void 0);
230
+ __decorate([
231
+ prop({
232
+ type: "int",
233
+ default: 480,
234
+ title: "Height",
235
+ description: "The height of the chart in pixels.",
236
+ min: 0,
237
+ max: 10000
238
+ })
239
+ ], ChartRendererLibNode.prototype, "height", void 0);
240
+ __decorate([
241
+ prop({
242
+ type: "dataframe",
243
+ default: {
244
+ type: "dataframe",
245
+ uri: "",
246
+ asset_id: null,
247
+ data: null,
248
+ metadata: null,
249
+ columns: null
250
+ },
251
+ title: "Data",
252
+ description: "The data to visualize as a pandas DataFrame."
253
+ })
254
+ ], ChartRendererLibNode.prototype, "data", void 0);
255
+ __decorate([
256
+ prop({
257
+ type: "str",
258
+ default: "#ffffff",
259
+ title: "Background Color",
260
+ description: "Background color of the chart (CSS color string)."
261
+ })
262
+ ], ChartRendererLibNode.prototype, "background_color", void 0);
263
+ __decorate([
264
+ prop({
265
+ type: "bool",
266
+ default: true,
267
+ title: "Trim Margins",
268
+ description: "Whether to use tight layout for margins."
269
+ })
270
+ ], ChartRendererLibNode.prototype, "trim_margins", void 0);
271
+ // Node-only: chart rendering requires the native @napi-rs/canvas addon, which
272
+ // V8-isolate runtimes (workers/edge) cannot load. Untagged → registry default
273
+ // ["node"].
274
+ export const LIB_SEABORN_NODES = [ChartRendererLibNode];
275
+ //# sourceMappingURL=lib-charts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib-charts.js","sourceRoot":"","sources":["../../src/nodes/lib-charts.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAuB,MAAM,WAAW,CAAC;AASxD,iFAAiF;AACjF,MAAM,gBAAgB,GAAG;IACvB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,KAAK;CAC4B,CAAC;AAE/C,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,OAAO,oBAAqB,SAAQ,QAAQ;IAChD,MAAM,CAAU,QAAQ,GAAG,0BAA0B,CAAC;IACtD,MAAM,CAAU,SAAS,GAAG,IAAI,CAAC;IACjC,MAAM,CAAU,KAAK,GAAG,gBAAgB,CAAC;IACzC,MAAM,CAAU,WAAW,GACzB,qIAAqI,CAAC;IACxI,MAAM,CAAU,YAAY,GAAG,CAAC,cAAc,CAAC,CAAC;IAChD,MAAM,CAAU,WAAW,GAAG,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,CAAU,mBAAmB,GAAG;QACpC,MAAM,EAAE,OAAO;KAChB,CAAC;IAkGF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QACjD,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,KAAK;KACX,CAAC;oDACqB;AAef;IAbP,IAAI,CAAC;QACJ,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE;YACP,IAAI,EAAE,WAAW;YACjB,GAAG,EAAE,EAAE;YACP,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,IAAI;SACd;QACD,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,8CAA8C;KAC5D,CAAC;kDAC2B;AAQrB;IANP,IAAI,CAAC;QACJ,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,mDAAmD;KACjE,CAAC;8DAC+B;AAQzB;IANP,IAAI,CAAC;QACJ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,0CAA0C;KACxD,CAAC;0DAC4B;AAqKhC,8EAA8E;AAC9E,8EAA8E;AAC9E,YAAY;AACZ,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,oBAAoB,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@nodetool-ai/data-nodes",
3
+ "version": "0.8.1",
4
+ "description": "NodeTool data nodes — dataframes (CSV), RSS feeds, charts",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=22.0.0"
8
+ },
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "scripts": {
12
+ "build": "node ../../scripts/build-typescript-workspace.mjs",
13
+ "test": "node ../../scripts/run-vitest.mjs run",
14
+ "test:watch": "node ../../scripts/run-vitest.mjs",
15
+ "lint": "node ../../scripts/run-tsc.mjs --noEmit"
16
+ },
17
+ "dependencies": {
18
+ "@napi-rs/canvas": "^0.1.65",
19
+ "@nodetool-ai/node-sdk": "^0.8.1",
20
+ "@nodetool-ai/nodes-utils": "^0.8.1",
21
+ "@nodetool-ai/protocol": "^0.8.1",
22
+ "@nodetool-ai/runtime": "^0.8.1",
23
+ "chart.js": "^4.5.1",
24
+ "papaparse": "^5.5.3"
25
+ },
26
+ "devDependencies": {
27
+ "@nodetool-ai/kernel": "*",
28
+ "@types/node": "^22.0.0",
29
+ "@types/papaparse": "^5.5.2",
30
+ "typescript": "npm:@typescript/typescript6@6.0.2",
31
+ "vitest": "^5.0.1"
32
+ },
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "import": "./dist/index.js",
37
+ "default": "./dist/index.js"
38
+ },
39
+ "./nodes/*": {
40
+ "types": "./dist/nodes/*.d.ts",
41
+ "import": "./dist/nodes/*.js",
42
+ "default": "./dist/nodes/*.js"
43
+ },
44
+ "./lib/*": {
45
+ "types": "./dist/lib/*.d.ts",
46
+ "import": "./dist/lib/*.js",
47
+ "default": "./dist/lib/*.js"
48
+ }
49
+ },
50
+ "license": "MIT",
51
+ "files": [
52
+ "dist",
53
+ "README.md"
54
+ ],
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "https://github.com/nodetool-ai/nodetool.git",
58
+ "directory": "packages/data-nodes"
59
+ },
60
+ "homepage": "https://nodetool.ai",
61
+ "bugs": {
62
+ "url": "https://github.com/nodetool-ai/nodetool/issues"
63
+ },
64
+ "publishConfig": {
65
+ "access": "public"
66
+ },
67
+ "keywords": [
68
+ "nodetool",
69
+ "ai",
70
+ "workflow",
71
+ "workflow-automation",
72
+ "typescript",
73
+ "ai-nodes",
74
+ "no-code",
75
+ "visual-programming",
76
+ "workflow-nodes",
77
+ "data",
78
+ "dataframe",
79
+ "csv",
80
+ "rss",
81
+ "charts"
82
+ ]
83
+ }