@datalathe/client 1.0.0
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/LICENSE +21 -0
- package/README.md +65 -0
- package/dist/client.d.ts +68 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +152 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/command.d.ts +6 -0
- package/dist/commands/command.d.ts.map +1 -0
- package/dist/commands/command.js +2 -0
- package/dist/commands/command.js.map +1 -0
- package/dist/commands/create-chip.d.ts +10 -0
- package/dist/commands/create-chip.d.ts.map +1 -0
- package/dist/commands/create-chip.js +15 -0
- package/dist/commands/create-chip.js.map +1 -0
- package/dist/commands/generate-report.d.ts +10 -0
- package/dist/commands/generate-report.d.ts.map +1 -0
- package/dist/commands/generate-report.js +17 -0
- package/dist/commands/generate-report.js.map +1 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +23 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/results/result-set.d.ts +39 -0
- package/dist/results/result-set.d.ts.map +1 -0
- package/dist/results/result-set.js +190 -0
- package/dist/results/result-set.js.map +1 -0
- package/dist/types.d.ts +105 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 DataLathe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# @datalathe/client
|
|
2
|
+
|
|
3
|
+
TypeScript client library for the [DataLathe](https://github.com/DataLathe) data processing API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @datalathe/client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { DatalatheClient } from "@datalathe/client";
|
|
15
|
+
|
|
16
|
+
const client = new DatalatheClient("http://localhost:3000");
|
|
17
|
+
|
|
18
|
+
// Create a chip from a database query
|
|
19
|
+
const chipId = await client.createChip("my_database", "SELECT * FROM users", "users");
|
|
20
|
+
|
|
21
|
+
// Create a chip from a file
|
|
22
|
+
const fileChipId = await client.createChipFromFile("/path/to/data.csv");
|
|
23
|
+
|
|
24
|
+
// Run queries against chips
|
|
25
|
+
const results = await client.generateReport([chipId], ["SELECT count(*) FROM data"]);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## API
|
|
29
|
+
|
|
30
|
+
### `new DatalatheClient(baseUrl, options?)`
|
|
31
|
+
|
|
32
|
+
Creates a new client instance.
|
|
33
|
+
|
|
34
|
+
- `baseUrl` — Base URL of the DataLathe engine (e.g. `http://localhost:3000`)
|
|
35
|
+
- `options.fetch` — Custom fetch implementation
|
|
36
|
+
- `options.headers` — Default headers for all requests
|
|
37
|
+
- `options.timeout` — Request timeout in ms (default: 30000)
|
|
38
|
+
|
|
39
|
+
### `client.createChip(sourceName, query, tableName, partition?)`
|
|
40
|
+
|
|
41
|
+
Creates a chip from a database source. Returns the chip ID.
|
|
42
|
+
|
|
43
|
+
### `client.createChipFromFile(filePath, tableName?, partition?)`
|
|
44
|
+
|
|
45
|
+
Creates a chip from a file (CSV, Parquet, etc.). Returns the chip ID.
|
|
46
|
+
|
|
47
|
+
### `client.generateReport(chipIds, queries)`
|
|
48
|
+
|
|
49
|
+
Executes SQL queries against chip data. Returns a map of results.
|
|
50
|
+
|
|
51
|
+
### `client.getDatabases()`
|
|
52
|
+
|
|
53
|
+
Lists available databases.
|
|
54
|
+
|
|
55
|
+
### `client.getDatabaseSchema(databaseName)`
|
|
56
|
+
|
|
57
|
+
Returns table and column metadata for a database.
|
|
58
|
+
|
|
59
|
+
### `client.listChips()`
|
|
60
|
+
|
|
61
|
+
Lists all chips and their metadata.
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { DatalatheCommand } from "./commands/command.js";
|
|
2
|
+
import type { SourceRequest, Partition, ReportResultEntry, DatalatheClientOptions, DuckDBDatabase, DatabaseTable, ChipsResponse } from "./types.js";
|
|
3
|
+
import { SourceType } from "./types.js";
|
|
4
|
+
export declare class DatalatheClient {
|
|
5
|
+
private readonly baseUrl;
|
|
6
|
+
private readonly fetchFn;
|
|
7
|
+
private readonly defaultHeaders;
|
|
8
|
+
private readonly timeout;
|
|
9
|
+
constructor(baseUrl: string, options?: DatalatheClientOptions);
|
|
10
|
+
/**
|
|
11
|
+
* Creates a single chip from a MySQL source.
|
|
12
|
+
* @param sourceName The name of the source database
|
|
13
|
+
* @param query The SQL query to execute
|
|
14
|
+
* @param tableName The name of the table
|
|
15
|
+
* @param partition Optional partition configuration
|
|
16
|
+
* @returns The chip ID
|
|
17
|
+
*/
|
|
18
|
+
createChip(sourceName: string, query: string, tableName: string, partition?: Partition): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a single chip from a file source (CSV, Parquet, etc.).
|
|
21
|
+
* @param filePath Path to the file on the server
|
|
22
|
+
* @param tableName Optional table name for the chip
|
|
23
|
+
* @param partition Optional partition configuration
|
|
24
|
+
* @returns The chip ID
|
|
25
|
+
*/
|
|
26
|
+
createChipFromFile(filePath: string, tableName?: string, partition?: Partition): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Stages data from multiple source requests and returns chip IDs.
|
|
29
|
+
* @param sources List of source requests to process
|
|
30
|
+
* @param chipId Optional chip ID to use
|
|
31
|
+
* @param sourceType Source type (defaults to MYSQL)
|
|
32
|
+
* @returns List of chip IDs
|
|
33
|
+
*/
|
|
34
|
+
createChips(sources: SourceRequest[], chipId?: string, sourceType?: SourceType): Promise<string[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Executes queries against chip IDs.
|
|
37
|
+
* @param chipIds List of chip IDs to query
|
|
38
|
+
* @param queries List of SQL queries to execute
|
|
39
|
+
* @returns Map of query index to result entry
|
|
40
|
+
*/
|
|
41
|
+
generateReport(chipIds: string[], queries: string[]): Promise<Map<number, ReportResultEntry>>;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the list of databases available in the DuckDB instance.
|
|
44
|
+
*/
|
|
45
|
+
getDatabases(): Promise<DuckDBDatabase[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the schema (tables and columns) for a given database.
|
|
48
|
+
* @param databaseName The name of the database to inspect
|
|
49
|
+
*/
|
|
50
|
+
getDatabaseSchema(databaseName: string): Promise<DatabaseTable[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Returns all chips and their metadata.
|
|
53
|
+
*/
|
|
54
|
+
listChips(): Promise<ChipsResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* Sends a GET request to the Datalathe API.
|
|
57
|
+
* @param path The API path to request
|
|
58
|
+
* @returns The parsed JSON response
|
|
59
|
+
*/
|
|
60
|
+
private get;
|
|
61
|
+
/**
|
|
62
|
+
* Sends a command to the Datalathe API.
|
|
63
|
+
* @param command The command to send
|
|
64
|
+
* @returns The parsed response
|
|
65
|
+
*/
|
|
66
|
+
sendCommand<TReq, TRes>(command: DatalatheCommand<TReq, TRes>): Promise<TRes>;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,aAAa,EACb,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAc,MAAM,YAAY,CAAC;AAGpD,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;IAClD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAyB;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB;IAO7D;;;;;;;OAOG;IACG,UAAU,CACd,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,MAAM,CAAC;IAOlB;;;;;;OAMG;IACG,kBAAkB,CACtB,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,MAAM,CAAC;IASlB;;;;;;OAMG;IACG,WAAW,CACf,OAAO,EAAE,aAAa,EAAE,EACxB,MAAM,CAAC,EAAE,MAAM,EACf,UAAU,GAAE,UAA6B,GACxC,OAAO,CAAC,MAAM,EAAE,CAAC;IAepB;;;;;OAKG;IACG,cAAc,CAClB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAkB1C;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAI/C;;;OAGG;IACG,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAMvE;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;IAIzC;;;;OAIG;YACW,GAAG;IA2BjB;;;;OAIG;IACG,WAAW,CAAC,IAAI,EAAE,IAAI,EAC1B,OAAO,EAAE,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,GACpC,OAAO,CAAC,IAAI,CAAC;CA+BjB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { CreateChipCommand } from "./commands/create-chip.js";
|
|
2
|
+
import { GenerateReportCommand } from "./commands/generate-report.js";
|
|
3
|
+
import { SourceType } from "./types.js";
|
|
4
|
+
import { DatalatheApiError, DatalatheStageError } from "./errors.js";
|
|
5
|
+
export class DatalatheClient {
|
|
6
|
+
baseUrl;
|
|
7
|
+
fetchFn;
|
|
8
|
+
defaultHeaders;
|
|
9
|
+
timeout;
|
|
10
|
+
constructor(baseUrl, options) {
|
|
11
|
+
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
12
|
+
this.fetchFn = options?.fetch ?? globalThis.fetch.bind(globalThis);
|
|
13
|
+
this.defaultHeaders = options?.headers ?? {};
|
|
14
|
+
this.timeout = options?.timeout ?? 30_000;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates a single chip from a MySQL source.
|
|
18
|
+
* @param sourceName The name of the source database
|
|
19
|
+
* @param query The SQL query to execute
|
|
20
|
+
* @param tableName The name of the table
|
|
21
|
+
* @param partition Optional partition configuration
|
|
22
|
+
* @returns The chip ID
|
|
23
|
+
*/
|
|
24
|
+
async createChip(sourceName, query, tableName, partition) {
|
|
25
|
+
const chips = await this.createChips([
|
|
26
|
+
{ database_name: sourceName, table_name: tableName, query, partition },
|
|
27
|
+
]);
|
|
28
|
+
return chips[0];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a single chip from a file source (CSV, Parquet, etc.).
|
|
32
|
+
* @param filePath Path to the file on the server
|
|
33
|
+
* @param tableName Optional table name for the chip
|
|
34
|
+
* @param partition Optional partition configuration
|
|
35
|
+
* @returns The chip ID
|
|
36
|
+
*/
|
|
37
|
+
async createChipFromFile(filePath, tableName, partition) {
|
|
38
|
+
const chips = await this.createChips([{ database_name: "", query: "", file_path: filePath, table_name: tableName, partition }], undefined, SourceType.FILE);
|
|
39
|
+
return chips[0];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Stages data from multiple source requests and returns chip IDs.
|
|
43
|
+
* @param sources List of source requests to process
|
|
44
|
+
* @param chipId Optional chip ID to use
|
|
45
|
+
* @param sourceType Source type (defaults to MYSQL)
|
|
46
|
+
* @returns List of chip IDs
|
|
47
|
+
*/
|
|
48
|
+
async createChips(sources, chipId, sourceType = SourceType.MYSQL) {
|
|
49
|
+
const chipIds = [];
|
|
50
|
+
for (const source of sources) {
|
|
51
|
+
const command = new CreateChipCommand(sourceType, source, chipId);
|
|
52
|
+
const response = await this.sendCommand(command);
|
|
53
|
+
if (response.error) {
|
|
54
|
+
throw new DatalatheStageError(`Failed to stage data: ${response.error}`);
|
|
55
|
+
}
|
|
56
|
+
chipIds.push(response.chip_id);
|
|
57
|
+
}
|
|
58
|
+
return chipIds;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Executes queries against chip IDs.
|
|
62
|
+
* @param chipIds List of chip IDs to query
|
|
63
|
+
* @param queries List of SQL queries to execute
|
|
64
|
+
* @returns Map of query index to result entry
|
|
65
|
+
*/
|
|
66
|
+
async generateReport(chipIds, queries) {
|
|
67
|
+
const command = new GenerateReportCommand(chipIds, SourceType.LOCAL, queries);
|
|
68
|
+
const response = await this.sendCommand(command);
|
|
69
|
+
const results = new Map();
|
|
70
|
+
if (response.result) {
|
|
71
|
+
for (const [key, entry] of Object.entries(response.result)) {
|
|
72
|
+
results.set(parseInt(key, 10), entry);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return results;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns the list of databases available in the DuckDB instance.
|
|
79
|
+
*/
|
|
80
|
+
async getDatabases() {
|
|
81
|
+
return this.get("/lathe/stage/databases");
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns the schema (tables and columns) for a given database.
|
|
85
|
+
* @param databaseName The name of the database to inspect
|
|
86
|
+
*/
|
|
87
|
+
async getDatabaseSchema(databaseName) {
|
|
88
|
+
return this.get(`/lathe/stage/schema/${encodeURIComponent(databaseName)}`);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Returns all chips and their metadata.
|
|
92
|
+
*/
|
|
93
|
+
async listChips() {
|
|
94
|
+
return this.get("/lathe/chips");
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Sends a GET request to the Datalathe API.
|
|
98
|
+
* @param path The API path to request
|
|
99
|
+
* @returns The parsed JSON response
|
|
100
|
+
*/
|
|
101
|
+
async get(path) {
|
|
102
|
+
const url = this.baseUrl + path;
|
|
103
|
+
const controller = new AbortController();
|
|
104
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
105
|
+
try {
|
|
106
|
+
const response = await this.fetchFn(url, {
|
|
107
|
+
method: "GET",
|
|
108
|
+
headers: { ...this.defaultHeaders },
|
|
109
|
+
signal: controller.signal,
|
|
110
|
+
});
|
|
111
|
+
if (!response.ok) {
|
|
112
|
+
const body = await response.text();
|
|
113
|
+
throw new DatalatheApiError(`GET ${path} failed: ${response.status} ${body}`, response.status, body);
|
|
114
|
+
}
|
|
115
|
+
return (await response.json());
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
clearTimeout(timeoutId);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Sends a command to the Datalathe API.
|
|
123
|
+
* @param command The command to send
|
|
124
|
+
* @returns The parsed response
|
|
125
|
+
*/
|
|
126
|
+
async sendCommand(command) {
|
|
127
|
+
const url = this.baseUrl + command.endpoint;
|
|
128
|
+
const controller = new AbortController();
|
|
129
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
130
|
+
try {
|
|
131
|
+
const response = await this.fetchFn(url, {
|
|
132
|
+
method: "POST",
|
|
133
|
+
headers: {
|
|
134
|
+
"Content-Type": "application/json",
|
|
135
|
+
...this.defaultHeaders,
|
|
136
|
+
},
|
|
137
|
+
body: JSON.stringify(command.request),
|
|
138
|
+
signal: controller.signal,
|
|
139
|
+
});
|
|
140
|
+
if (!response.ok) {
|
|
141
|
+
const body = await response.text();
|
|
142
|
+
throw new DatalatheApiError(`Failed to execute command: ${response.status} ${body}`, response.status, body);
|
|
143
|
+
}
|
|
144
|
+
const json = await response.json();
|
|
145
|
+
return command.parseResponse(json);
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
clearTimeout(timeoutId);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/commands/command.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB,CAAC,QAAQ,EAAE,SAAS;IACnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/commands/command.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DatalatheCommand } from "./command.js";
|
|
2
|
+
import type { SourceRequest, StageDataRequest, StageDataResponse } from "../types.js";
|
|
3
|
+
import { SourceType } from "../types.js";
|
|
4
|
+
export declare class CreateChipCommand implements DatalatheCommand<StageDataRequest, StageDataResponse> {
|
|
5
|
+
readonly endpoint = "/lathe/stage/data";
|
|
6
|
+
readonly request: StageDataRequest;
|
|
7
|
+
constructor(sourceType: SourceType, source: SourceRequest, chipId?: string);
|
|
8
|
+
parseResponse(json: unknown): StageDataResponse;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=create-chip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-chip.d.ts","sourceRoot":"","sources":["../../src/commands/create-chip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,qBAAa,iBACX,YAAW,gBAAgB,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;IAEhE,QAAQ,CAAC,QAAQ,uBAAuB;IACxC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;gBAGjC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,MAAM;IASjB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,iBAAiB;CAGhD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class CreateChipCommand {
|
|
2
|
+
endpoint = "/lathe/stage/data";
|
|
3
|
+
request;
|
|
4
|
+
constructor(sourceType, source, chipId) {
|
|
5
|
+
this.request = {
|
|
6
|
+
source_type: sourceType,
|
|
7
|
+
source_request: source,
|
|
8
|
+
...(chipId !== undefined ? { chip_id: chipId } : {}),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
parseResponse(json) {
|
|
12
|
+
return json;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=create-chip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-chip.js","sourceRoot":"","sources":["../../src/commands/create-chip.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,iBAAiB;IAGnB,QAAQ,GAAG,mBAAmB,CAAC;IAC/B,OAAO,CAAmB;IAEnC,YACE,UAAsB,EACtB,MAAqB,EACrB,MAAe;QAEf,IAAI,CAAC,OAAO,GAAG;YACb,WAAW,EAAE,UAAU;YACvB,cAAc,EAAE,MAAM;YACtB,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACrD,CAAC;IACJ,CAAC;IAED,aAAa,CAAC,IAAa;QACzB,OAAO,IAAyB,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DatalatheCommand } from "./command.js";
|
|
2
|
+
import type { ReportRequest, ReportResponse } from "../types.js";
|
|
3
|
+
import { ReportType, SourceType } from "../types.js";
|
|
4
|
+
export declare class GenerateReportCommand implements DatalatheCommand<ReportRequest, ReportResponse> {
|
|
5
|
+
readonly endpoint = "/lathe/report";
|
|
6
|
+
readonly request: ReportRequest;
|
|
7
|
+
constructor(chipIds: string[], sourceType: SourceType, queries: string[], reportType?: ReportType);
|
|
8
|
+
parseResponse(json: unknown): ReportResponse;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=generate-report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-report.d.ts","sourceRoot":"","sources":["../../src/commands/generate-report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErD,qBAAa,qBACX,YAAW,gBAAgB,CAAC,aAAa,EAAE,cAAc,CAAC;IAE1D,QAAQ,CAAC,QAAQ,mBAAmB;IACpC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;gBAG9B,OAAO,EAAE,MAAM,EAAE,EACjB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,EAAE,EACjB,UAAU,GAAE,UAA+B;IAU7C,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,cAAc;CAG7C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReportType } from "../types.js";
|
|
2
|
+
export class GenerateReportCommand {
|
|
3
|
+
endpoint = "/lathe/report";
|
|
4
|
+
request;
|
|
5
|
+
constructor(chipIds, sourceType, queries, reportType = ReportType.GENERIC) {
|
|
6
|
+
this.request = {
|
|
7
|
+
chip_id: chipIds,
|
|
8
|
+
source_type: sourceType,
|
|
9
|
+
type: reportType,
|
|
10
|
+
query_request: { query: queries },
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
parseResponse(json) {
|
|
14
|
+
return json;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=generate-report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-report.js","sourceRoot":"","sources":["../../src/commands/generate-report.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAErD,MAAM,OAAO,qBAAqB;IAGvB,QAAQ,GAAG,eAAe,CAAC;IAC3B,OAAO,CAAgB;IAEhC,YACE,OAAiB,EACjB,UAAsB,EACtB,OAAiB,EACjB,aAAyB,UAAU,CAAC,OAAO;QAE3C,IAAI,CAAC,OAAO,GAAG;YACb,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,UAAU;YACvB,IAAI,EAAE,UAAU;YAChB,aAAa,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;SAClC,CAAC;IACJ,CAAC;IAED,aAAa,CAAC,IAAa;QACzB,OAAO,IAAsB,CAAC;IAChC,CAAC;CACF"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class DatalatheError extends Error {
|
|
2
|
+
readonly statusCode?: number;
|
|
3
|
+
constructor(message: string, statusCode?: number);
|
|
4
|
+
}
|
|
5
|
+
export declare class DatalatheApiError extends DatalatheError {
|
|
6
|
+
readonly responseBody?: string;
|
|
7
|
+
constructor(message: string, statusCode: number, responseBody?: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class DatalatheStageError extends DatalatheError {
|
|
10
|
+
constructor(message: string);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAKjD;AAED,qBAAa,iBAAkB,SAAQ,cAAc;IACnD,SAAgB,YAAY,CAAC,EAAE,MAAM,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM;CAKvE;AAED,qBAAa,mBAAoB,SAAQ,cAAc;gBACzC,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class DatalatheError extends Error {
|
|
2
|
+
statusCode;
|
|
3
|
+
constructor(message, statusCode) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "DatalatheError";
|
|
6
|
+
this.statusCode = statusCode;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class DatalatheApiError extends DatalatheError {
|
|
10
|
+
responseBody;
|
|
11
|
+
constructor(message, statusCode, responseBody) {
|
|
12
|
+
super(message, statusCode);
|
|
13
|
+
this.name = "DatalatheApiError";
|
|
14
|
+
this.responseBody = responseBody;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class DatalatheStageError extends DatalatheError {
|
|
18
|
+
constructor(message) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "DatalatheStageError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvB,UAAU,CAAU;IAEpC,YAAY,OAAe,EAAE,UAAmB;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,cAAc;IACnC,YAAY,CAAU;IAEtC,YAAY,OAAe,EAAE,UAAkB,EAAE,YAAqB;QACpE,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IACrD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { DatalatheClient } from "./client.js";
|
|
2
|
+
export { DatalatheResultSet } from "./results/result-set.js";
|
|
3
|
+
export { CreateChipCommand } from "./commands/create-chip.js";
|
|
4
|
+
export { GenerateReportCommand } from "./commands/generate-report.js";
|
|
5
|
+
export type { DatalatheCommand } from "./commands/command.js";
|
|
6
|
+
export { DatalatheError, DatalatheApiError, DatalatheStageError, } from "./errors.js";
|
|
7
|
+
export { SourceType, ReportType, type SchemaField, type SourceRequest, type Partition, type StageDataRequest, type StageDataResponse, type QueryRequest, type ReportRequest, type ReportResultEntry, type ReportResponse, type DatalatheClientOptions, type DuckDBDatabase, type DatabaseTable, type Chip, type ChipMetadata, type ChipsResponse, } from "./types.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,UAAU,EACV,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { DatalatheClient } from "./client.js";
|
|
2
|
+
export { DatalatheResultSet } from "./results/result-set.js";
|
|
3
|
+
export { CreateChipCommand } from "./commands/create-chip.js";
|
|
4
|
+
export { GenerateReportCommand } from "./commands/generate-report.js";
|
|
5
|
+
export { DatalatheError, DatalatheApiError, DatalatheStageError, } from "./errors.js";
|
|
6
|
+
export { SourceType, ReportType, } from "./types.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,UAAU,EACV,UAAU,GAgBX,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ReportResultEntry, SchemaField } from "../types.js";
|
|
2
|
+
export declare class DatalatheResultSet {
|
|
3
|
+
private readonly data;
|
|
4
|
+
private readonly schema;
|
|
5
|
+
private currentRow;
|
|
6
|
+
private _wasNull;
|
|
7
|
+
constructor(result: ReportResultEntry);
|
|
8
|
+
next(): boolean;
|
|
9
|
+
previous(): boolean;
|
|
10
|
+
first(): boolean;
|
|
11
|
+
last(): boolean;
|
|
12
|
+
beforeFirst(): void;
|
|
13
|
+
afterLast(): void;
|
|
14
|
+
absolute(row: number): boolean;
|
|
15
|
+
relative(rows: number): boolean;
|
|
16
|
+
isBeforeFirst(): boolean;
|
|
17
|
+
isAfterLast(): boolean;
|
|
18
|
+
isFirst(): boolean;
|
|
19
|
+
isLast(): boolean;
|
|
20
|
+
getRow(): number;
|
|
21
|
+
getString(column: number | string): string | null;
|
|
22
|
+
getInt(column: number | string): number;
|
|
23
|
+
getFloat(column: number | string): number;
|
|
24
|
+
getDouble(column: number | string): number;
|
|
25
|
+
getBoolean(column: number | string): boolean;
|
|
26
|
+
getObject(column: number | string): string | number | boolean | null;
|
|
27
|
+
wasNull(): boolean;
|
|
28
|
+
findColumn(columnLabel: string): number;
|
|
29
|
+
getColumnCount(): number;
|
|
30
|
+
getColumnName(columnIndex: number): string;
|
|
31
|
+
getColumnType(columnIndex: number): string;
|
|
32
|
+
getSchema(): SchemaField[];
|
|
33
|
+
get rowCount(): number;
|
|
34
|
+
toArray(): Record<string, string | number | boolean | null>[];
|
|
35
|
+
[Symbol.iterator](): Iterator<Record<string, string | number | boolean | null>>;
|
|
36
|
+
private resolveColumn;
|
|
37
|
+
private getValue;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=result-set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-set.d.ts","sourceRoot":"","sources":["../../src/results/result-set.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAElE,qBAAa,kBAAkB;IAC7B,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;IAED,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,EAAE;IAe7D,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAC3B,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,CACjD;IAqBD,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,QAAQ;CASjB"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
export class DatalatheResultSet {
|
|
2
|
+
data;
|
|
3
|
+
schema;
|
|
4
|
+
currentRow = -1;
|
|
5
|
+
_wasNull = false;
|
|
6
|
+
constructor(result) {
|
|
7
|
+
this.data = result.result ?? result.data ?? [];
|
|
8
|
+
this.schema = result.schema ?? [];
|
|
9
|
+
}
|
|
10
|
+
// --- Cursor Navigation ---
|
|
11
|
+
next() {
|
|
12
|
+
return ++this.currentRow < this.data.length;
|
|
13
|
+
}
|
|
14
|
+
previous() {
|
|
15
|
+
if (this.currentRow <= 0) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
this.currentRow--;
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
first() {
|
|
22
|
+
if (this.data.length === 0) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
this.currentRow = 0;
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
last() {
|
|
29
|
+
if (this.data.length === 0) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
this.currentRow = this.data.length - 1;
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
beforeFirst() {
|
|
36
|
+
this.currentRow = -1;
|
|
37
|
+
}
|
|
38
|
+
afterLast() {
|
|
39
|
+
this.currentRow = this.data.length;
|
|
40
|
+
}
|
|
41
|
+
absolute(row) {
|
|
42
|
+
if (row < 0) {
|
|
43
|
+
row = this.data.length + row + 1;
|
|
44
|
+
}
|
|
45
|
+
if (row < 1 || row > this.data.length) {
|
|
46
|
+
this.currentRow = this.data.length;
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
this.currentRow = row - 1;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
relative(rows) {
|
|
53
|
+
return this.absolute(this.currentRow + 1 + rows);
|
|
54
|
+
}
|
|
55
|
+
// --- Position Checks ---
|
|
56
|
+
isBeforeFirst() {
|
|
57
|
+
return this.data.length > 0 && this.currentRow === -1;
|
|
58
|
+
}
|
|
59
|
+
isAfterLast() {
|
|
60
|
+
return this.data.length > 0 && this.currentRow >= this.data.length;
|
|
61
|
+
}
|
|
62
|
+
isFirst() {
|
|
63
|
+
return this.data.length > 0 && this.currentRow === 0;
|
|
64
|
+
}
|
|
65
|
+
isLast() {
|
|
66
|
+
return (this.data.length > 0 && this.currentRow === this.data.length - 1);
|
|
67
|
+
}
|
|
68
|
+
getRow() {
|
|
69
|
+
if (this.currentRow < 0 || this.currentRow >= this.data.length) {
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
72
|
+
return this.currentRow + 1;
|
|
73
|
+
}
|
|
74
|
+
// --- Value Accessors (1-based column index) ---
|
|
75
|
+
getString(column) {
|
|
76
|
+
const value = this.getValue(this.resolveColumn(column));
|
|
77
|
+
this._wasNull = value === null;
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
getInt(column) {
|
|
81
|
+
const value = this.getValue(this.resolveColumn(column));
|
|
82
|
+
this._wasNull = value === null;
|
|
83
|
+
return value === null ? 0 : parseInt(value, 10);
|
|
84
|
+
}
|
|
85
|
+
getFloat(column) {
|
|
86
|
+
const value = this.getValue(this.resolveColumn(column));
|
|
87
|
+
this._wasNull = value === null;
|
|
88
|
+
return value === null ? 0 : parseFloat(value);
|
|
89
|
+
}
|
|
90
|
+
getDouble(column) {
|
|
91
|
+
return this.getFloat(column);
|
|
92
|
+
}
|
|
93
|
+
getBoolean(column) {
|
|
94
|
+
const value = this.getValue(this.resolveColumn(column));
|
|
95
|
+
this._wasNull = value === null;
|
|
96
|
+
return value !== null && value.toLowerCase() === "true";
|
|
97
|
+
}
|
|
98
|
+
getObject(column) {
|
|
99
|
+
const columnIndex = this.resolveColumn(column);
|
|
100
|
+
const value = this.getValue(columnIndex);
|
|
101
|
+
this._wasNull = value === null;
|
|
102
|
+
if (value === null) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const dataType = this.schema[columnIndex - 1].data_type;
|
|
106
|
+
switch (dataType) {
|
|
107
|
+
case "Int32":
|
|
108
|
+
case "Int64":
|
|
109
|
+
return parseInt(value, 10);
|
|
110
|
+
case "Float32":
|
|
111
|
+
case "Float64":
|
|
112
|
+
return parseFloat(value);
|
|
113
|
+
case "Boolean":
|
|
114
|
+
return value.toLowerCase() === "true";
|
|
115
|
+
default:
|
|
116
|
+
return value;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
wasNull() {
|
|
120
|
+
return this._wasNull;
|
|
121
|
+
}
|
|
122
|
+
// --- Column Lookup ---
|
|
123
|
+
findColumn(columnLabel) {
|
|
124
|
+
const idx = this.schema.findIndex((s) => s.name.toLowerCase() === columnLabel.toLowerCase());
|
|
125
|
+
if (idx === -1) {
|
|
126
|
+
throw new Error(`Column not found: ${columnLabel}`);
|
|
127
|
+
}
|
|
128
|
+
return idx + 1;
|
|
129
|
+
}
|
|
130
|
+
// --- Metadata ---
|
|
131
|
+
getColumnCount() {
|
|
132
|
+
return this.schema.length;
|
|
133
|
+
}
|
|
134
|
+
getColumnName(columnIndex) {
|
|
135
|
+
return this.schema[columnIndex - 1].name;
|
|
136
|
+
}
|
|
137
|
+
getColumnType(columnIndex) {
|
|
138
|
+
return this.schema[columnIndex - 1].data_type;
|
|
139
|
+
}
|
|
140
|
+
getSchema() {
|
|
141
|
+
return [...this.schema];
|
|
142
|
+
}
|
|
143
|
+
// --- JS-idiomatic extras ---
|
|
144
|
+
get rowCount() {
|
|
145
|
+
return this.data.length;
|
|
146
|
+
}
|
|
147
|
+
toArray() {
|
|
148
|
+
const saved = this.currentRow;
|
|
149
|
+
const rows = [];
|
|
150
|
+
this.beforeFirst();
|
|
151
|
+
while (this.next()) {
|
|
152
|
+
const row = {};
|
|
153
|
+
for (let i = 1; i <= this.schema.length; i++) {
|
|
154
|
+
row[this.schema[i - 1].name] = this.getObject(i);
|
|
155
|
+
}
|
|
156
|
+
rows.push(row);
|
|
157
|
+
}
|
|
158
|
+
this.currentRow = saved;
|
|
159
|
+
return rows;
|
|
160
|
+
}
|
|
161
|
+
[Symbol.iterator]() {
|
|
162
|
+
this.beforeFirst();
|
|
163
|
+
return {
|
|
164
|
+
next: () => {
|
|
165
|
+
if (this.next()) {
|
|
166
|
+
const row = {};
|
|
167
|
+
for (let i = 1; i <= this.schema.length; i++) {
|
|
168
|
+
row[this.schema[i - 1].name] = this.getObject(i);
|
|
169
|
+
}
|
|
170
|
+
return { value: row, done: false };
|
|
171
|
+
}
|
|
172
|
+
return { value: undefined, done: true };
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
// --- Private ---
|
|
177
|
+
resolveColumn(column) {
|
|
178
|
+
return typeof column === "string" ? this.findColumn(column) : column;
|
|
179
|
+
}
|
|
180
|
+
getValue(columnIndex) {
|
|
181
|
+
if (this.currentRow < 0 || this.currentRow >= this.data.length) {
|
|
182
|
+
throw new Error("No current row");
|
|
183
|
+
}
|
|
184
|
+
if (columnIndex < 1 || columnIndex > this.schema.length) {
|
|
185
|
+
throw new Error(`Invalid column index: ${columnIndex}`);
|
|
186
|
+
}
|
|
187
|
+
return this.data[this.currentRow][columnIndex - 1];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=result-set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-set.js","sourceRoot":"","sources":["../../src/results/result-set.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,kBAAkB;IACZ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ILE",
|
|
4
|
+
S3 = "S3",
|
|
5
|
+
LOCAL = "LOCAL",
|
|
6
|
+
CACHE = "CACHE"
|
|
7
|
+
}
|
|
8
|
+
export declare enum ReportType {
|
|
9
|
+
GENERIC = "Generic",
|
|
10
|
+
TABLE = "Table"
|
|
11
|
+
}
|
|
12
|
+
export interface SchemaField {
|
|
13
|
+
name: string;
|
|
14
|
+
data_type: string;
|
|
15
|
+
}
|
|
16
|
+
export interface Partition {
|
|
17
|
+
partition_by: string;
|
|
18
|
+
partition_values?: string[];
|
|
19
|
+
partition_query?: string;
|
|
20
|
+
combine_partitions?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface SourceRequest {
|
|
23
|
+
database_name: string;
|
|
24
|
+
table_name?: string;
|
|
25
|
+
query: string;
|
|
26
|
+
file_path?: string;
|
|
27
|
+
s3_path?: string;
|
|
28
|
+
partition?: Partition;
|
|
29
|
+
}
|
|
30
|
+
export interface StageDataRequest {
|
|
31
|
+
source_type: SourceType;
|
|
32
|
+
source_request: SourceRequest;
|
|
33
|
+
chip_id?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface StageDataResponse {
|
|
36
|
+
chip_id: string;
|
|
37
|
+
error: string | null;
|
|
38
|
+
}
|
|
39
|
+
export interface QueryRequest {
|
|
40
|
+
query: string[];
|
|
41
|
+
file_path?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface ReportRequest {
|
|
44
|
+
chip_id: string[];
|
|
45
|
+
source_type: SourceType;
|
|
46
|
+
type: ReportType;
|
|
47
|
+
query_request: QueryRequest;
|
|
48
|
+
}
|
|
49
|
+
export interface ReportResultEntry {
|
|
50
|
+
idx: string;
|
|
51
|
+
result: (string | null)[][] | null;
|
|
52
|
+
data?: (string | null)[][] | null;
|
|
53
|
+
error: string | null;
|
|
54
|
+
schema: SchemaField[] | null;
|
|
55
|
+
}
|
|
56
|
+
export interface ReportResponse {
|
|
57
|
+
result: Record<string, ReportResultEntry> | null;
|
|
58
|
+
error?: string | null;
|
|
59
|
+
}
|
|
60
|
+
export interface DuckDBDatabase {
|
|
61
|
+
database_name: string;
|
|
62
|
+
database_oid: number;
|
|
63
|
+
path?: string;
|
|
64
|
+
comment?: string;
|
|
65
|
+
tags?: string;
|
|
66
|
+
internal: boolean;
|
|
67
|
+
type: string;
|
|
68
|
+
readonly: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface DatabaseTable {
|
|
71
|
+
table_name: string;
|
|
72
|
+
schema_name: string;
|
|
73
|
+
column_name: string;
|
|
74
|
+
data_type: string;
|
|
75
|
+
is_nullable: string;
|
|
76
|
+
column_default?: string;
|
|
77
|
+
ordinal_position: number;
|
|
78
|
+
}
|
|
79
|
+
export interface Chip {
|
|
80
|
+
chip_id: string;
|
|
81
|
+
sub_chip_id: string;
|
|
82
|
+
table_name: string;
|
|
83
|
+
partition_value: string;
|
|
84
|
+
created_at?: number;
|
|
85
|
+
}
|
|
86
|
+
export interface ChipMetadata {
|
|
87
|
+
chip_id: string;
|
|
88
|
+
query?: string;
|
|
89
|
+
created_at: number;
|
|
90
|
+
description: string;
|
|
91
|
+
name: string;
|
|
92
|
+
}
|
|
93
|
+
export interface ChipsResponse {
|
|
94
|
+
chips: Chip[];
|
|
95
|
+
metadata: ChipMetadata[];
|
|
96
|
+
}
|
|
97
|
+
export interface DatalatheClientOptions {
|
|
98
|
+
/** Custom fetch implementation (for testing or Node 16 polyfill) */
|
|
99
|
+
fetch?: typeof globalThis.fetch;
|
|
100
|
+
/** Default request headers to include on every call */
|
|
101
|
+
headers?: Record<string, string>;
|
|
102
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
103
|
+
timeout?: number;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,EAAE,OAA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AAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,QAAQ,EAAE,YAAY,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,sBAAsB;IACrC,oEAAoE;IACpE,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export var SourceType;
|
|
2
|
+
(function (SourceType) {
|
|
3
|
+
SourceType["MYSQL"] = "MYSQL";
|
|
4
|
+
SourceType["FILE"] = "FILE";
|
|
5
|
+
SourceType["S3"] = "S3";
|
|
6
|
+
SourceType["LOCAL"] = "LOCAL";
|
|
7
|
+
SourceType["CACHE"] = "CACHE";
|
|
8
|
+
})(SourceType || (SourceType = {}));
|
|
9
|
+
export var ReportType;
|
|
10
|
+
(function (ReportType) {
|
|
11
|
+
ReportType["GENERIC"] = "Generic";
|
|
12
|
+
ReportType["TABLE"] = "Table";
|
|
13
|
+
})(ReportType || (ReportType = {}));
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,2BAAa,CAAA;IACb,uBAAS,CAAA;IACT,6BAAe,CAAA;IACf,6BAAe,CAAA;AACjB,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB;AAED,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,iCAAmB,CAAA;IACnB,6BAAe,CAAA;AACjB,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@datalathe/client",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript client for Datalathe API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"test:watch": "vitest",
|
|
23
|
+
"lint": "tsc --noEmit",
|
|
24
|
+
"prepublishOnly": "npm run build"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript": "^5.5.0",
|
|
28
|
+
"vitest": "^2.0.0"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18.0.0"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/DataLathe/datalathe-client-javascript.git"
|
|
37
|
+
},
|
|
38
|
+
"author": "DataLathe",
|
|
39
|
+
"keywords": [
|
|
40
|
+
"datalathe",
|
|
41
|
+
"data",
|
|
42
|
+
"profiling",
|
|
43
|
+
"client"
|
|
44
|
+
]
|
|
45
|
+
}
|