@robosystems/client 0.2.1 → 0.2.2
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/extensions/GraphClient.d.ts +14 -1
- package/extensions/GraphClient.js +16 -3
- package/extensions/GraphClient.ts +17 -3
- package/extensions/TableIngestClient.d.ts +1 -1
- package/extensions/TableIngestClient.js +20 -20
- package/extensions/TableIngestClient.test.ts +1 -1
- package/extensions/TableIngestClient.ts +23 -28
- package/package.json +1 -1
- package/sdk/sdk.gen.d.ts +528 -26
- package/sdk/sdk.gen.js +534 -32
- package/sdk/sdk.gen.ts +532 -30
- package/sdk/types.gen.d.ts +289 -82
- package/sdk/types.gen.ts +293 -82
- package/sdk-extensions/GraphClient.d.ts +14 -1
- package/sdk-extensions/GraphClient.js +16 -3
- package/sdk-extensions/GraphClient.ts +17 -3
- package/sdk-extensions/TableIngestClient.d.ts +1 -1
- package/sdk-extensions/TableIngestClient.js +20 -20
- package/sdk-extensions/TableIngestClient.test.ts +1 -1
- package/sdk-extensions/TableIngestClient.ts +23 -28
- package/sdk.gen.d.ts +528 -26
- package/sdk.gen.js +534 -32
- package/sdk.gen.ts +532 -30
- package/types.gen.d.ts +289 -82
- package/types.gen.ts +293 -82
|
@@ -21,6 +21,7 @@ export interface GraphInfo {
|
|
|
21
21
|
status?: string;
|
|
22
22
|
}
|
|
23
23
|
export interface CreateGraphOptions {
|
|
24
|
+
createEntity?: boolean;
|
|
24
25
|
timeout?: number;
|
|
25
26
|
pollInterval?: number;
|
|
26
27
|
onProgress?: (message: string) => void;
|
|
@@ -36,6 +37,18 @@ export declare class GraphClient {
|
|
|
36
37
|
});
|
|
37
38
|
/**
|
|
38
39
|
* Create a graph and wait for completion
|
|
40
|
+
*
|
|
41
|
+
* @param metadata - Graph metadata (name, description, etc.)
|
|
42
|
+
* @param initialEntity - Optional initial entity to create
|
|
43
|
+
* @param options - Additional options including:
|
|
44
|
+
* - createEntity: Whether to create the entity node and upload initial data.
|
|
45
|
+
* Only applies when initialEntity is provided. Set to false to
|
|
46
|
+
* create graph without populating entity data (useful for file-based ingestion).
|
|
47
|
+
* Defaults to true.
|
|
48
|
+
* - timeout: Maximum time to wait in milliseconds (default: 60000)
|
|
49
|
+
* - pollInterval: Time between status checks in milliseconds (default: 2000)
|
|
50
|
+
* - onProgress: Callback for progress updates
|
|
51
|
+
* @returns The graph ID when creation completes
|
|
39
52
|
*/
|
|
40
53
|
createGraphAndWait(metadata: GraphMetadataInput, initialEntity?: InitialEntityInput, options?: CreateGraphOptions): Promise<string>;
|
|
41
54
|
/**
|
|
@@ -50,7 +63,7 @@ export declare class GraphClient {
|
|
|
50
63
|
* Delete a graph
|
|
51
64
|
* Note: This will be implemented when the deleteGraph endpoint is available in the SDK
|
|
52
65
|
*/
|
|
53
|
-
deleteGraph(
|
|
66
|
+
deleteGraph(_graphId: string): Promise<void>;
|
|
54
67
|
/**
|
|
55
68
|
* Clean up resources
|
|
56
69
|
*/
|
|
@@ -15,9 +15,21 @@ class GraphClient {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Create a graph and wait for completion
|
|
18
|
+
*
|
|
19
|
+
* @param metadata - Graph metadata (name, description, etc.)
|
|
20
|
+
* @param initialEntity - Optional initial entity to create
|
|
21
|
+
* @param options - Additional options including:
|
|
22
|
+
* - createEntity: Whether to create the entity node and upload initial data.
|
|
23
|
+
* Only applies when initialEntity is provided. Set to false to
|
|
24
|
+
* create graph without populating entity data (useful for file-based ingestion).
|
|
25
|
+
* Defaults to true.
|
|
26
|
+
* - timeout: Maximum time to wait in milliseconds (default: 60000)
|
|
27
|
+
* - pollInterval: Time between status checks in milliseconds (default: 2000)
|
|
28
|
+
* - onProgress: Callback for progress updates
|
|
29
|
+
* @returns The graph ID when creation completes
|
|
18
30
|
*/
|
|
19
31
|
async createGraphAndWait(metadata, initialEntity, options = {}) {
|
|
20
|
-
const { timeout = 60000, pollInterval = 2000, onProgress } = options;
|
|
32
|
+
const { createEntity = true, timeout = 60000, pollInterval = 2000, onProgress } = options;
|
|
21
33
|
if (!this.config.token) {
|
|
22
34
|
throw new Error('No API key provided. Set token in config.');
|
|
23
35
|
}
|
|
@@ -47,6 +59,7 @@ class GraphClient {
|
|
|
47
59
|
body: {
|
|
48
60
|
metadata: apiMetadata,
|
|
49
61
|
initial_entity: initialEntityData || null,
|
|
62
|
+
create_entity: createEntity,
|
|
50
63
|
},
|
|
51
64
|
});
|
|
52
65
|
// Check if we got immediate graph_id
|
|
@@ -145,10 +158,10 @@ class GraphClient {
|
|
|
145
158
|
* Delete a graph
|
|
146
159
|
* Note: This will be implemented when the deleteGraph endpoint is available in the SDK
|
|
147
160
|
*/
|
|
148
|
-
async deleteGraph(
|
|
161
|
+
async deleteGraph(_graphId) {
|
|
149
162
|
throw new Error('deleteGraph is not yet implemented - waiting for SDK endpoint to be generated');
|
|
150
163
|
// TODO: Implement when deleteGraph endpoint is available
|
|
151
|
-
// const response = await deleteGraph({ path: { graph_id:
|
|
164
|
+
// const response = await deleteGraph({ path: { graph_id: _graphId } })
|
|
152
165
|
// if (response.status !== 200 && response.status !== 204) {
|
|
153
166
|
// throw new Error(`Failed to delete graph: ${response.status}`)
|
|
154
167
|
// }
|
|
@@ -66,6 +66,7 @@ export interface GraphInfo {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export interface CreateGraphOptions {
|
|
69
|
+
createEntity?: boolean
|
|
69
70
|
timeout?: number
|
|
70
71
|
pollInterval?: number
|
|
71
72
|
onProgress?: (message: string) => void
|
|
@@ -92,13 +93,25 @@ export class GraphClient {
|
|
|
92
93
|
|
|
93
94
|
/**
|
|
94
95
|
* Create a graph and wait for completion
|
|
96
|
+
*
|
|
97
|
+
* @param metadata - Graph metadata (name, description, etc.)
|
|
98
|
+
* @param initialEntity - Optional initial entity to create
|
|
99
|
+
* @param options - Additional options including:
|
|
100
|
+
* - createEntity: Whether to create the entity node and upload initial data.
|
|
101
|
+
* Only applies when initialEntity is provided. Set to false to
|
|
102
|
+
* create graph without populating entity data (useful for file-based ingestion).
|
|
103
|
+
* Defaults to true.
|
|
104
|
+
* - timeout: Maximum time to wait in milliseconds (default: 60000)
|
|
105
|
+
* - pollInterval: Time between status checks in milliseconds (default: 2000)
|
|
106
|
+
* - onProgress: Callback for progress updates
|
|
107
|
+
* @returns The graph ID when creation completes
|
|
95
108
|
*/
|
|
96
109
|
async createGraphAndWait(
|
|
97
110
|
metadata: GraphMetadataInput,
|
|
98
111
|
initialEntity?: InitialEntityInput,
|
|
99
112
|
options: CreateGraphOptions = {}
|
|
100
113
|
): Promise<string> {
|
|
101
|
-
const { timeout = 60000, pollInterval = 2000, onProgress } = options
|
|
114
|
+
const { createEntity = true, timeout = 60000, pollInterval = 2000, onProgress } = options
|
|
102
115
|
|
|
103
116
|
if (!this.config.token) {
|
|
104
117
|
throw new Error('No API key provided. Set token in config.')
|
|
@@ -133,6 +146,7 @@ export class GraphClient {
|
|
|
133
146
|
body: {
|
|
134
147
|
metadata: apiMetadata,
|
|
135
148
|
initial_entity: initialEntityData || null,
|
|
149
|
+
create_entity: createEntity,
|
|
136
150
|
},
|
|
137
151
|
})
|
|
138
152
|
|
|
@@ -249,10 +263,10 @@ export class GraphClient {
|
|
|
249
263
|
* Delete a graph
|
|
250
264
|
* Note: This will be implemented when the deleteGraph endpoint is available in the SDK
|
|
251
265
|
*/
|
|
252
|
-
async deleteGraph(
|
|
266
|
+
async deleteGraph(_graphId: string): Promise<void> {
|
|
253
267
|
throw new Error('deleteGraph is not yet implemented - waiting for SDK endpoint to be generated')
|
|
254
268
|
// TODO: Implement when deleteGraph endpoint is available
|
|
255
|
-
// const response = await deleteGraph({ path: { graph_id:
|
|
269
|
+
// const response = await deleteGraph({ path: { graph_id: _graphId } })
|
|
256
270
|
// if (response.status !== 200 && response.status !== 204) {
|
|
257
271
|
// throw new Error(`Failed to delete graph: ${response.status}`)
|
|
258
272
|
// }
|
|
@@ -44,7 +44,7 @@ export declare class TableIngestClient {
|
|
|
44
44
|
* This method handles the complete 3-step upload process:
|
|
45
45
|
* 1. Get presigned upload URL
|
|
46
46
|
* 2. Upload file to S3
|
|
47
|
-
* 3.
|
|
47
|
+
* 3. Mark file as 'uploaded' (backend validates, calculates size/row count)
|
|
48
48
|
*
|
|
49
49
|
* Supports File (browser), Blob (browser), Buffer (Node.js), and ReadableStream.
|
|
50
50
|
*/
|
|
@@ -19,7 +19,7 @@ class TableIngestClient {
|
|
|
19
19
|
* This method handles the complete 3-step upload process:
|
|
20
20
|
* 1. Get presigned upload URL
|
|
21
21
|
* 2. Upload file to S3
|
|
22
|
-
* 3.
|
|
22
|
+
* 3. Mark file as 'uploaded' (backend validates, calculates size/row count)
|
|
23
23
|
*
|
|
24
24
|
* Supports File (browser), Blob (browser), Buffer (Node.js), and ReadableStream.
|
|
25
25
|
*/
|
|
@@ -32,7 +32,7 @@ class TableIngestClient {
|
|
|
32
32
|
file_name: fileName,
|
|
33
33
|
content_type: 'application/x-parquet',
|
|
34
34
|
};
|
|
35
|
-
const uploadUrlResponse = await (0, sdk_gen_1.
|
|
35
|
+
const uploadUrlResponse = await (0, sdk_gen_1.getUploadUrl)({
|
|
36
36
|
path: { graph_id: graphId, table_name: tableName },
|
|
37
37
|
body: uploadRequest,
|
|
38
38
|
query: this.config.token ? { token: this.config.token } : undefined,
|
|
@@ -77,36 +77,36 @@ class TableIngestClient {
|
|
|
77
77
|
error: `S3 upload failed: ${s3Response.status} ${s3Response.statusText}`,
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
// Step 3:
|
|
81
|
-
options.onProgress?.(`
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const estimatedRowCount = Math.floor(fileSize / 100);
|
|
85
|
-
const metadataUpdate = {
|
|
86
|
-
file_size_bytes: fileSize,
|
|
87
|
-
row_count: estimatedRowCount,
|
|
80
|
+
// Step 3: Mark file as uploaded (backend validates and calculates size/row count)
|
|
81
|
+
options.onProgress?.(`Marking ${fileName} as uploaded...`);
|
|
82
|
+
const statusUpdate = {
|
|
83
|
+
status: 'uploaded',
|
|
88
84
|
};
|
|
89
|
-
const updateResponse = await (0, sdk_gen_1.
|
|
85
|
+
const updateResponse = await (0, sdk_gen_1.updateFileStatus)({
|
|
90
86
|
path: { graph_id: graphId, file_id: fileId },
|
|
91
|
-
body:
|
|
87
|
+
body: statusUpdate,
|
|
92
88
|
query: this.config.token ? { token: this.config.token } : undefined,
|
|
93
89
|
});
|
|
94
|
-
if (updateResponse.error) {
|
|
90
|
+
if (updateResponse.error || !updateResponse.data) {
|
|
95
91
|
return {
|
|
96
92
|
fileId,
|
|
97
93
|
fileSize,
|
|
98
|
-
rowCount:
|
|
94
|
+
rowCount: 0,
|
|
99
95
|
tableName,
|
|
100
96
|
fileName,
|
|
101
97
|
success: false,
|
|
102
|
-
error: 'Failed to
|
|
98
|
+
error: 'Failed to complete file upload',
|
|
103
99
|
};
|
|
104
100
|
}
|
|
105
|
-
|
|
101
|
+
// Extract size and row count from response (calculated by backend)
|
|
102
|
+
const responseData = updateResponse.data;
|
|
103
|
+
const actualFileSize = responseData.file_size_bytes || 0;
|
|
104
|
+
const actualRowCount = responseData.row_count || 0;
|
|
105
|
+
options.onProgress?.(`✅ Uploaded ${fileName} (${actualFileSize.toLocaleString()} bytes, ${actualRowCount.toLocaleString()} rows)`);
|
|
106
106
|
return {
|
|
107
107
|
fileId,
|
|
108
|
-
fileSize,
|
|
109
|
-
rowCount:
|
|
108
|
+
fileSize: actualFileSize,
|
|
109
|
+
rowCount: actualRowCount,
|
|
110
110
|
tableName,
|
|
111
111
|
fileName,
|
|
112
112
|
success: true,
|
|
@@ -129,7 +129,7 @@ class TableIngestClient {
|
|
|
129
129
|
*/
|
|
130
130
|
async listStagingTables(graphId) {
|
|
131
131
|
try {
|
|
132
|
-
const response = await (0, sdk_gen_1.
|
|
132
|
+
const response = await (0, sdk_gen_1.listTables)({
|
|
133
133
|
path: { graph_id: graphId },
|
|
134
134
|
query: this.config.token ? { token: this.config.token } : undefined,
|
|
135
135
|
});
|
|
@@ -160,7 +160,7 @@ class TableIngestClient {
|
|
|
160
160
|
ignore_errors: options.ignoreErrors ?? true,
|
|
161
161
|
rebuild: options.rebuild ?? false,
|
|
162
162
|
};
|
|
163
|
-
const response = await (0, sdk_gen_1.
|
|
163
|
+
const response = await (0, sdk_gen_1.ingestTables)({
|
|
164
164
|
path: { graph_id: graphId },
|
|
165
165
|
body: ingestRequest,
|
|
166
166
|
query: this.config.token ? { token: this.config.token } : undefined,
|
|
@@ -153,7 +153,7 @@ describe('TableIngestClient', () => {
|
|
|
153
153
|
const result = await tableClient.uploadParquetFile('graph_123', 'Entity', buffer)
|
|
154
154
|
|
|
155
155
|
expect(result.success).toBe(false)
|
|
156
|
-
expect(result.error).toContain('Failed to
|
|
156
|
+
expect(result.error).toContain('Failed to complete file upload')
|
|
157
157
|
})
|
|
158
158
|
})
|
|
159
159
|
|
|
@@ -7,15 +7,10 @@
|
|
|
7
7
|
* Supports File (browser), Blob (browser), Buffer (Node.js), and ReadableStream.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
getUploadUrlV1GraphsGraphIdTablesTableNameFilesPost,
|
|
12
|
-
ingestTablesV1GraphsGraphIdTablesIngestPost,
|
|
13
|
-
listTablesV1GraphsGraphIdTablesGet,
|
|
14
|
-
updateFileV1GraphsGraphIdTablesFilesFileIdPatch,
|
|
15
|
-
} from '../sdk.gen'
|
|
10
|
+
import { getUploadUrl, ingestTables, listTables, updateFileStatus } from '../sdk.gen'
|
|
16
11
|
import type {
|
|
17
12
|
BulkIngestRequest,
|
|
18
|
-
|
|
13
|
+
FileStatusUpdate,
|
|
19
14
|
FileUploadRequest,
|
|
20
15
|
FileUploadResponse,
|
|
21
16
|
TableListResponse,
|
|
@@ -83,7 +78,7 @@ export class TableIngestClient {
|
|
|
83
78
|
* This method handles the complete 3-step upload process:
|
|
84
79
|
* 1. Get presigned upload URL
|
|
85
80
|
* 2. Upload file to S3
|
|
86
|
-
* 3.
|
|
81
|
+
* 3. Mark file as 'uploaded' (backend validates, calculates size/row count)
|
|
87
82
|
*
|
|
88
83
|
* Supports File (browser), Blob (browser), Buffer (Node.js), and ReadableStream.
|
|
89
84
|
*/
|
|
@@ -104,7 +99,7 @@ export class TableIngestClient {
|
|
|
104
99
|
content_type: 'application/x-parquet',
|
|
105
100
|
}
|
|
106
101
|
|
|
107
|
-
const uploadUrlResponse = await
|
|
102
|
+
const uploadUrlResponse = await getUploadUrl({
|
|
108
103
|
path: { graph_id: graphId, table_name: tableName },
|
|
109
104
|
body: uploadRequest,
|
|
110
105
|
query: this.config.token ? { token: this.config.token } : undefined,
|
|
@@ -157,44 +152,44 @@ export class TableIngestClient {
|
|
|
157
152
|
}
|
|
158
153
|
}
|
|
159
154
|
|
|
160
|
-
// Step 3:
|
|
161
|
-
options.onProgress?.(`
|
|
155
|
+
// Step 3: Mark file as uploaded (backend validates and calculates size/row count)
|
|
156
|
+
options.onProgress?.(`Marking ${fileName} as uploaded...`)
|
|
162
157
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const estimatedRowCount = Math.floor(fileSize / 100)
|
|
166
|
-
|
|
167
|
-
const metadataUpdate: FileUpdateRequest = {
|
|
168
|
-
file_size_bytes: fileSize,
|
|
169
|
-
row_count: estimatedRowCount,
|
|
158
|
+
const statusUpdate: FileStatusUpdate = {
|
|
159
|
+
status: 'uploaded',
|
|
170
160
|
}
|
|
171
161
|
|
|
172
|
-
const updateResponse = await
|
|
162
|
+
const updateResponse = await updateFileStatus({
|
|
173
163
|
path: { graph_id: graphId, file_id: fileId },
|
|
174
|
-
body:
|
|
164
|
+
body: statusUpdate,
|
|
175
165
|
query: this.config.token ? { token: this.config.token } : undefined,
|
|
176
166
|
})
|
|
177
167
|
|
|
178
|
-
if (updateResponse.error) {
|
|
168
|
+
if (updateResponse.error || !updateResponse.data) {
|
|
179
169
|
return {
|
|
180
170
|
fileId,
|
|
181
171
|
fileSize,
|
|
182
|
-
rowCount:
|
|
172
|
+
rowCount: 0,
|
|
183
173
|
tableName,
|
|
184
174
|
fileName,
|
|
185
175
|
success: false,
|
|
186
|
-
error: 'Failed to
|
|
176
|
+
error: 'Failed to complete file upload',
|
|
187
177
|
}
|
|
188
178
|
}
|
|
189
179
|
|
|
180
|
+
// Extract size and row count from response (calculated by backend)
|
|
181
|
+
const responseData = updateResponse.data as any
|
|
182
|
+
const actualFileSize = responseData.file_size_bytes || 0
|
|
183
|
+
const actualRowCount = responseData.row_count || 0
|
|
184
|
+
|
|
190
185
|
options.onProgress?.(
|
|
191
|
-
`✅ Uploaded ${fileName} (${
|
|
186
|
+
`✅ Uploaded ${fileName} (${actualFileSize.toLocaleString()} bytes, ${actualRowCount.toLocaleString()} rows)`
|
|
192
187
|
)
|
|
193
188
|
|
|
194
189
|
return {
|
|
195
190
|
fileId,
|
|
196
|
-
fileSize,
|
|
197
|
-
rowCount:
|
|
191
|
+
fileSize: actualFileSize,
|
|
192
|
+
rowCount: actualRowCount,
|
|
198
193
|
tableName,
|
|
199
194
|
fileName,
|
|
200
195
|
success: true,
|
|
@@ -217,7 +212,7 @@ export class TableIngestClient {
|
|
|
217
212
|
*/
|
|
218
213
|
async listStagingTables(graphId: string): Promise<TableInfo[]> {
|
|
219
214
|
try {
|
|
220
|
-
const response = await
|
|
215
|
+
const response = await listTables({
|
|
221
216
|
path: { graph_id: graphId },
|
|
222
217
|
query: this.config.token ? { token: this.config.token } : undefined,
|
|
223
218
|
})
|
|
@@ -255,7 +250,7 @@ export class TableIngestClient {
|
|
|
255
250
|
rebuild: options.rebuild ?? false,
|
|
256
251
|
}
|
|
257
252
|
|
|
258
|
-
const response = await
|
|
253
|
+
const response = await ingestTables({
|
|
259
254
|
path: { graph_id: graphId },
|
|
260
255
|
body: ingestRequest,
|
|
261
256
|
query: this.config.token ? { token: this.config.token } : undefined,
|