@robosystems/client 0.2.1 → 0.2.3

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.
@@ -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(graphId: string): Promise<void>;
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(graphId) {
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: graphId } })
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(graphId: string): Promise<void> {
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: graphId } })
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
  // }
@@ -23,7 +23,6 @@ class QueryClient {
23
23
  query: {
24
24
  mode: options.mode,
25
25
  test_mode: options.testMode,
26
- token: this.config.token, // Pass JWT token for SSE authentication
27
26
  },
28
27
  };
29
28
  // Execute the query
@@ -74,7 +74,6 @@ export class QueryClient {
74
74
  query: {
75
75
  mode: options.mode,
76
76
  test_mode: options.testMode,
77
- token: this.config.token, // Pass JWT token for SSE authentication
78
77
  },
79
78
  }
80
79
 
@@ -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. Update file metadata
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. Update file metadata
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,10 +32,9 @@ class TableIngestClient {
32
32
  file_name: fileName,
33
33
  content_type: 'application/x-parquet',
34
34
  };
35
- const uploadUrlResponse = await (0, sdk_gen_1.getUploadUrlV1GraphsGraphIdTablesTableNameFilesPost)({
35
+ const uploadUrlResponse = await (0, sdk_gen_1.getUploadUrl)({
36
36
  path: { graph_id: graphId, table_name: tableName },
37
37
  body: uploadRequest,
38
- query: this.config.token ? { token: this.config.token } : undefined,
39
38
  });
40
39
  if (uploadUrlResponse.error || !uploadUrlResponse.data) {
41
40
  return {
@@ -77,36 +76,35 @@ class TableIngestClient {
77
76
  error: `S3 upload failed: ${s3Response.status} ${s3Response.statusText}`,
78
77
  };
79
78
  }
80
- // Step 3: Update file metadata
81
- options.onProgress?.(`Updating file metadata for ${fileName}...`);
82
- // Estimate row count (TypeScript can't read Parquet metadata without library)
83
- // Rough estimate: ~100 bytes per row for typical data
84
- const estimatedRowCount = Math.floor(fileSize / 100);
85
- const metadataUpdate = {
86
- file_size_bytes: fileSize,
87
- row_count: estimatedRowCount,
79
+ // Step 3: Mark file as uploaded (backend validates and calculates size/row count)
80
+ options.onProgress?.(`Marking ${fileName} as uploaded...`);
81
+ const statusUpdate = {
82
+ status: 'uploaded',
88
83
  };
89
- const updateResponse = await (0, sdk_gen_1.updateFileV1GraphsGraphIdTablesFilesFileIdPatch)({
84
+ const updateResponse = await (0, sdk_gen_1.updateFileStatus)({
90
85
  path: { graph_id: graphId, file_id: fileId },
91
- body: metadataUpdate,
92
- query: this.config.token ? { token: this.config.token } : undefined,
86
+ body: statusUpdate,
93
87
  });
94
- if (updateResponse.error) {
88
+ if (updateResponse.error || !updateResponse.data) {
95
89
  return {
96
90
  fileId,
97
91
  fileSize,
98
- rowCount: estimatedRowCount,
92
+ rowCount: 0,
99
93
  tableName,
100
94
  fileName,
101
95
  success: false,
102
- error: 'Failed to update file metadata',
96
+ error: 'Failed to complete file upload',
103
97
  };
104
98
  }
105
- options.onProgress?.(`✅ Uploaded ${fileName} (${fileSize.toLocaleString()} bytes, ~${estimatedRowCount.toLocaleString()} rows)`);
99
+ // Extract size and row count from response (calculated by backend)
100
+ const responseData = updateResponse.data;
101
+ const actualFileSize = responseData.file_size_bytes || 0;
102
+ const actualRowCount = responseData.row_count || 0;
103
+ options.onProgress?.(`✅ Uploaded ${fileName} (${actualFileSize.toLocaleString()} bytes, ${actualRowCount.toLocaleString()} rows)`);
106
104
  return {
107
105
  fileId,
108
- fileSize,
109
- rowCount: estimatedRowCount,
106
+ fileSize: actualFileSize,
107
+ rowCount: actualRowCount,
110
108
  tableName,
111
109
  fileName,
112
110
  success: true,
@@ -129,9 +127,8 @@ class TableIngestClient {
129
127
  */
130
128
  async listStagingTables(graphId) {
131
129
  try {
132
- const response = await (0, sdk_gen_1.listTablesV1GraphsGraphIdTablesGet)({
130
+ const response = await (0, sdk_gen_1.listTables)({
133
131
  path: { graph_id: graphId },
134
- query: this.config.token ? { token: this.config.token } : undefined,
135
132
  });
136
133
  if (response.error || !response.data) {
137
134
  console.error('Failed to list tables:', response.error);
@@ -160,10 +157,9 @@ class TableIngestClient {
160
157
  ignore_errors: options.ignoreErrors ?? true,
161
158
  rebuild: options.rebuild ?? false,
162
159
  };
163
- const response = await (0, sdk_gen_1.ingestTablesV1GraphsGraphIdTablesIngestPost)({
160
+ const response = await (0, sdk_gen_1.ingestTables)({
164
161
  path: { graph_id: graphId },
165
162
  body: ingestRequest,
166
- query: this.config.token ? { token: this.config.token } : undefined,
167
163
  });
168
164
  if (response.error || !response.data) {
169
165
  return {
@@ -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 update file metadata')
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/sdk.gen'
10
+ import { getUploadUrl, ingestTables, listTables, updateFileStatus } from '../sdk/sdk.gen'
16
11
  import type {
17
12
  BulkIngestRequest,
18
- FileUpdateRequest,
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. Update file metadata
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,10 +99,9 @@ export class TableIngestClient {
104
99
  content_type: 'application/x-parquet',
105
100
  }
106
101
 
107
- const uploadUrlResponse = await getUploadUrlV1GraphsGraphIdTablesTableNameFilesPost({
102
+ const uploadUrlResponse = await getUploadUrl({
108
103
  path: { graph_id: graphId, table_name: tableName },
109
104
  body: uploadRequest,
110
- query: this.config.token ? { token: this.config.token } : undefined,
111
105
  })
112
106
 
113
107
  if (uploadUrlResponse.error || !uploadUrlResponse.data) {
@@ -157,44 +151,43 @@ export class TableIngestClient {
157
151
  }
158
152
  }
159
153
 
160
- // Step 3: Update file metadata
161
- options.onProgress?.(`Updating file metadata for ${fileName}...`)
154
+ // Step 3: Mark file as uploaded (backend validates and calculates size/row count)
155
+ options.onProgress?.(`Marking ${fileName} as uploaded...`)
162
156
 
163
- // Estimate row count (TypeScript can't read Parquet metadata without library)
164
- // Rough estimate: ~100 bytes per row for typical data
165
- const estimatedRowCount = Math.floor(fileSize / 100)
166
-
167
- const metadataUpdate: FileUpdateRequest = {
168
- file_size_bytes: fileSize,
169
- row_count: estimatedRowCount,
157
+ const statusUpdate: FileStatusUpdate = {
158
+ status: 'uploaded',
170
159
  }
171
160
 
172
- const updateResponse = await updateFileV1GraphsGraphIdTablesFilesFileIdPatch({
161
+ const updateResponse = await updateFileStatus({
173
162
  path: { graph_id: graphId, file_id: fileId },
174
- body: metadataUpdate,
175
- query: this.config.token ? { token: this.config.token } : undefined,
163
+ body: statusUpdate,
176
164
  })
177
165
 
178
- if (updateResponse.error) {
166
+ if (updateResponse.error || !updateResponse.data) {
179
167
  return {
180
168
  fileId,
181
169
  fileSize,
182
- rowCount: estimatedRowCount,
170
+ rowCount: 0,
183
171
  tableName,
184
172
  fileName,
185
173
  success: false,
186
- error: 'Failed to update file metadata',
174
+ error: 'Failed to complete file upload',
187
175
  }
188
176
  }
189
177
 
178
+ // Extract size and row count from response (calculated by backend)
179
+ const responseData = updateResponse.data as any
180
+ const actualFileSize = responseData.file_size_bytes || 0
181
+ const actualRowCount = responseData.row_count || 0
182
+
190
183
  options.onProgress?.(
191
- `✅ Uploaded ${fileName} (${fileSize.toLocaleString()} bytes, ~${estimatedRowCount.toLocaleString()} rows)`
184
+ `✅ Uploaded ${fileName} (${actualFileSize.toLocaleString()} bytes, ${actualRowCount.toLocaleString()} rows)`
192
185
  )
193
186
 
194
187
  return {
195
188
  fileId,
196
- fileSize,
197
- rowCount: estimatedRowCount,
189
+ fileSize: actualFileSize,
190
+ rowCount: actualRowCount,
198
191
  tableName,
199
192
  fileName,
200
193
  success: true,
@@ -217,9 +210,8 @@ export class TableIngestClient {
217
210
  */
218
211
  async listStagingTables(graphId: string): Promise<TableInfo[]> {
219
212
  try {
220
- const response = await listTablesV1GraphsGraphIdTablesGet({
213
+ const response = await listTables({
221
214
  path: { graph_id: graphId },
222
- query: this.config.token ? { token: this.config.token } : undefined,
223
215
  })
224
216
 
225
217
  if (response.error || !response.data) {
@@ -255,10 +247,9 @@ export class TableIngestClient {
255
247
  rebuild: options.rebuild ?? false,
256
248
  }
257
249
 
258
- const response = await ingestTablesV1GraphsGraphIdTablesIngestPost({
250
+ const response = await ingestTables({
259
251
  path: { graph_id: graphId },
260
252
  body: ingestRequest,
261
- query: this.config.token ? { token: this.config.token } : undefined,
262
253
  })
263
254
 
264
255
  if (response.error || !response.data) {