(configs: DataSourceConfig | DataSourceConfig[])
| 39 | } |
| 40 | |
| 41 | async load(configs: DataSourceConfig | DataSourceConfig[]): Promise<void> { |
| 42 | const sources = Array.isArray(configs) ? configs : [configs]; |
| 43 | if (sources.length !== 1) { |
| 44 | throw new Error(`JavaScriptEngine currently supports exactly one data source, received ${sources.length}`); |
| 45 | } |
| 46 | this.data = null; |
| 47 | const config = sourceInputSchema.parse(sources[0]); |
| 48 | if (config.type !== 'csv' && config.type !== 'json' && config.type !== 'text') { |
| 49 | throw new Error(`JavaScriptEngine only supports csv/json/text sources, got: ${config.type}`); |
| 50 | } |
| 51 | |
| 52 | this.data = await loadSource(config, this.llmConfig); |
| 53 | } |
| 54 | |
| 55 | async schema(): Promise<Schema> { |
| 56 | if (!this.data) throw new Error('No data loaded. Please call source() first.'); |
nothing calls this directly
no test coverage detected