@robosystems/client 0.2.22 → 0.2.24
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/AgentClient.js +2 -2
- package/extensions/AgentClient.ts +2 -2
- package/extensions/MaterializationClient.d.ts +13 -3
- package/extensions/MaterializationClient.js +68 -18
- package/extensions/MaterializationClient.ts +78 -18
- package/package.json +1 -1
- package/sdk/sdk.gen.d.ts +3 -3
- package/sdk/sdk.gen.js +3 -3
- package/sdk/sdk.gen.ts +3 -3
- package/sdk/types.gen.d.ts +6 -25
- package/sdk/types.gen.ts +6 -25
- package/sdk-extensions/AgentClient.js +2 -2
- package/sdk-extensions/AgentClient.ts +2 -2
- package/sdk-extensions/MaterializationClient.d.ts +13 -3
- package/sdk-extensions/MaterializationClient.js +68 -18
- package/sdk-extensions/MaterializationClient.ts +78 -18
- package/sdk-extensions/README.md +19 -21
- package/sdk.gen.d.ts +3 -3
- package/sdk.gen.js +3 -3
- package/sdk.gen.ts +3 -3
- package/types.gen.d.ts +6 -25
- package/types.gen.ts +6 -25
|
@@ -43,7 +43,7 @@ class AgentClient {
|
|
|
43
43
|
timestamp: new Date().toISOString(),
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
// Check if this is a queued response (async
|
|
46
|
+
// Check if this is a queued response (async background task execution)
|
|
47
47
|
if (responseData?.operation_id) {
|
|
48
48
|
const queuedResponse = responseData;
|
|
49
49
|
// If user doesn't want to wait, throw with queue info
|
|
@@ -87,7 +87,7 @@ class AgentClient {
|
|
|
87
87
|
timestamp: new Date().toISOString(),
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
// Check if this is a queued response (async
|
|
90
|
+
// Check if this is a queued response (async background task execution)
|
|
91
91
|
if (responseData?.operation_id) {
|
|
92
92
|
const queuedResponse = responseData;
|
|
93
93
|
// If user doesn't want to wait, throw with queue info
|
|
@@ -102,7 +102,7 @@ export class AgentClient {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
// Check if this is a queued response (async
|
|
105
|
+
// Check if this is a queued response (async background task execution)
|
|
106
106
|
if (responseData?.operation_id) {
|
|
107
107
|
const queuedResponse = responseData as QueuedAgentResponse
|
|
108
108
|
|
|
@@ -158,7 +158,7 @@ export class AgentClient {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
// Check if this is a queued response (async
|
|
161
|
+
// Check if this is a queued response (async background task execution)
|
|
162
162
|
if (responseData?.operation_id) {
|
|
163
163
|
const queuedResponse = responseData as QueuedAgentResponse
|
|
164
164
|
|
|
@@ -2,6 +2,7 @@ export interface MaterializationOptions {
|
|
|
2
2
|
ignoreErrors?: boolean;
|
|
3
3
|
rebuild?: boolean;
|
|
4
4
|
force?: boolean;
|
|
5
|
+
timeout?: number;
|
|
5
6
|
onProgress?: (message: string) => void;
|
|
6
7
|
}
|
|
7
8
|
export interface MaterializationResult {
|
|
@@ -27,6 +28,7 @@ export interface MaterializationStatus {
|
|
|
27
28
|
}
|
|
28
29
|
export declare class MaterializationClient {
|
|
29
30
|
private config;
|
|
31
|
+
private operationClient;
|
|
30
32
|
constructor(config: {
|
|
31
33
|
baseUrl: string;
|
|
32
34
|
credentials?: 'include' | 'same-origin' | 'omit';
|
|
@@ -36,11 +38,15 @@ export declare class MaterializationClient {
|
|
|
36
38
|
/**
|
|
37
39
|
* Materialize graph from DuckDB staging tables
|
|
38
40
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
41
|
+
* Submits a materialization job to Dagster and monitors progress via SSE.
|
|
42
|
+
* The operation runs asynchronously on the server but this method waits
|
|
43
|
+
* for completion and returns the final result.
|
|
42
44
|
*/
|
|
43
45
|
materialize(graphId: string, options?: MaterializationOptions): Promise<MaterializationResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Convert SSE operation result to MaterializationResult
|
|
48
|
+
*/
|
|
49
|
+
private convertOperationResult;
|
|
44
50
|
/**
|
|
45
51
|
* Get current materialization status for the graph
|
|
46
52
|
*
|
|
@@ -48,4 +54,8 @@ export declare class MaterializationClient {
|
|
|
48
54
|
* when it was last materialized, and how long since last materialization.
|
|
49
55
|
*/
|
|
50
56
|
status(graphId: string): Promise<MaterializationStatus | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Close any active SSE connections
|
|
59
|
+
*/
|
|
60
|
+
close(): void;
|
|
51
61
|
}
|
|
@@ -6,23 +6,25 @@ exports.MaterializationClient = void 0;
|
|
|
6
6
|
* Materialization Client for RoboSystems API
|
|
7
7
|
*
|
|
8
8
|
* Manages graph materialization from DuckDB staging tables.
|
|
9
|
-
*
|
|
9
|
+
* Submits materialization jobs to Dagster and monitors progress via SSE.
|
|
10
10
|
*/
|
|
11
11
|
const sdk_gen_1 = require("../sdk.gen");
|
|
12
|
+
const OperationClient_1 = require("./OperationClient");
|
|
12
13
|
class MaterializationClient {
|
|
13
14
|
constructor(config) {
|
|
14
15
|
this.config = config;
|
|
16
|
+
this.operationClient = new OperationClient_1.OperationClient(config);
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* Materialize graph from DuckDB staging tables
|
|
18
20
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
21
|
+
* Submits a materialization job to Dagster and monitors progress via SSE.
|
|
22
|
+
* The operation runs asynchronously on the server but this method waits
|
|
23
|
+
* for completion and returns the final result.
|
|
22
24
|
*/
|
|
23
25
|
async materialize(graphId, options = {}) {
|
|
24
26
|
try {
|
|
25
|
-
options.onProgress?.('
|
|
27
|
+
options.onProgress?.('Submitting materialization job...');
|
|
26
28
|
const request = {
|
|
27
29
|
ignore_errors: options.ignoreErrors ?? true,
|
|
28
30
|
rebuild: options.rebuild ?? false,
|
|
@@ -44,19 +46,24 @@ class MaterializationClient {
|
|
|
44
46
|
error: `Failed to materialize graph: ${response.error}`,
|
|
45
47
|
};
|
|
46
48
|
}
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
const queuedResponse = response.data;
|
|
50
|
+
const operationId = queuedResponse.operation_id;
|
|
51
|
+
options.onProgress?.(`Materialization queued (operation: ${operationId})`);
|
|
52
|
+
// Monitor the operation via SSE until completion
|
|
53
|
+
const opResult = await this.operationClient.monitorOperation(operationId, {
|
|
54
|
+
timeout: (options.timeout ?? 600) * 1000, // Convert to milliseconds, 10 minute default
|
|
55
|
+
onProgress: (progress) => {
|
|
56
|
+
if (options.onProgress) {
|
|
57
|
+
let msg = progress.message;
|
|
58
|
+
if (progress.progressPercent !== undefined) {
|
|
59
|
+
msg += ` (${progress.progressPercent.toFixed(0)}%)`;
|
|
60
|
+
}
|
|
61
|
+
options.onProgress(msg);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
// Convert operation result to materialization result
|
|
66
|
+
return this.convertOperationResult(opResult, options);
|
|
60
67
|
}
|
|
61
68
|
catch (error) {
|
|
62
69
|
return {
|
|
@@ -71,6 +78,43 @@ class MaterializationClient {
|
|
|
71
78
|
};
|
|
72
79
|
}
|
|
73
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Convert SSE operation result to MaterializationResult
|
|
83
|
+
*/
|
|
84
|
+
convertOperationResult(opResult, options) {
|
|
85
|
+
if (opResult.success) {
|
|
86
|
+
// Extract details from SSE completion event result
|
|
87
|
+
const sseResult = opResult.result || {};
|
|
88
|
+
const tables = sseResult.tables_materialized || [];
|
|
89
|
+
const rows = sseResult.total_rows || 0;
|
|
90
|
+
const timeMs = sseResult.execution_time_ms || 0;
|
|
91
|
+
options.onProgress?.(`✅ Materialization complete: ${tables.length} tables, ` +
|
|
92
|
+
`${rows.toLocaleString()} rows in ${timeMs.toFixed(2)}ms`);
|
|
93
|
+
return {
|
|
94
|
+
status: 'success',
|
|
95
|
+
wasStale: sseResult.was_stale || false,
|
|
96
|
+
staleReason: sseResult.stale_reason,
|
|
97
|
+
tablesMaterialized: tables,
|
|
98
|
+
totalRows: rows,
|
|
99
|
+
executionTimeMs: timeMs,
|
|
100
|
+
message: sseResult.message || 'Graph materialized successfully',
|
|
101
|
+
success: true,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// Operation failed or was cancelled
|
|
106
|
+
return {
|
|
107
|
+
status: 'failed',
|
|
108
|
+
wasStale: false,
|
|
109
|
+
tablesMaterialized: [],
|
|
110
|
+
totalRows: 0,
|
|
111
|
+
executionTimeMs: 0,
|
|
112
|
+
message: opResult.error || 'Operation failed',
|
|
113
|
+
success: false,
|
|
114
|
+
error: opResult.error,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
74
118
|
/**
|
|
75
119
|
* Get current materialization status for the graph
|
|
76
120
|
*
|
|
@@ -103,5 +147,11 @@ class MaterializationClient {
|
|
|
103
147
|
return null;
|
|
104
148
|
}
|
|
105
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Close any active SSE connections
|
|
152
|
+
*/
|
|
153
|
+
close() {
|
|
154
|
+
this.operationClient.closeAll();
|
|
155
|
+
}
|
|
106
156
|
}
|
|
107
157
|
exports.MaterializationClient = MaterializationClient;
|
|
@@ -4,16 +4,18 @@
|
|
|
4
4
|
* Materialization Client for RoboSystems API
|
|
5
5
|
*
|
|
6
6
|
* Manages graph materialization from DuckDB staging tables.
|
|
7
|
-
*
|
|
7
|
+
* Submits materialization jobs to Dagster and monitors progress via SSE.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { getMaterializationStatus, materializeGraph } from '../sdk.gen'
|
|
11
11
|
import type { MaterializeRequest } from '../types.gen'
|
|
12
|
+
import { OperationClient, type OperationResult } from './OperationClient'
|
|
12
13
|
|
|
13
14
|
export interface MaterializationOptions {
|
|
14
15
|
ignoreErrors?: boolean
|
|
15
16
|
rebuild?: boolean
|
|
16
17
|
force?: boolean
|
|
18
|
+
timeout?: number // Default 10 minutes
|
|
17
19
|
onProgress?: (message: string) => void
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -47,6 +49,7 @@ export class MaterializationClient {
|
|
|
47
49
|
headers?: Record<string, string>
|
|
48
50
|
token?: string
|
|
49
51
|
}
|
|
52
|
+
private operationClient: OperationClient
|
|
50
53
|
|
|
51
54
|
constructor(config: {
|
|
52
55
|
baseUrl: string
|
|
@@ -55,21 +58,22 @@ export class MaterializationClient {
|
|
|
55
58
|
token?: string
|
|
56
59
|
}) {
|
|
57
60
|
this.config = config
|
|
61
|
+
this.operationClient = new OperationClient(config)
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
/**
|
|
61
65
|
* Materialize graph from DuckDB staging tables
|
|
62
66
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
67
|
+
* Submits a materialization job to Dagster and monitors progress via SSE.
|
|
68
|
+
* The operation runs asynchronously on the server but this method waits
|
|
69
|
+
* for completion and returns the final result.
|
|
66
70
|
*/
|
|
67
71
|
async materialize(
|
|
68
72
|
graphId: string,
|
|
69
73
|
options: MaterializationOptions = {}
|
|
70
74
|
): Promise<MaterializationResult> {
|
|
71
75
|
try {
|
|
72
|
-
options.onProgress?.('
|
|
76
|
+
options.onProgress?.('Submitting materialization job...')
|
|
73
77
|
|
|
74
78
|
const request: MaterializeRequest = {
|
|
75
79
|
ignore_errors: options.ignoreErrors ?? true,
|
|
@@ -95,33 +99,82 @@ export class MaterializationClient {
|
|
|
95
99
|
}
|
|
96
100
|
}
|
|
97
101
|
|
|
98
|
-
const
|
|
102
|
+
const queuedResponse = response.data as { operation_id: string; message: string }
|
|
103
|
+
const operationId = queuedResponse.operation_id
|
|
104
|
+
|
|
105
|
+
options.onProgress?.(`Materialization queued (operation: ${operationId})`)
|
|
106
|
+
|
|
107
|
+
// Monitor the operation via SSE until completion
|
|
108
|
+
const opResult = await this.operationClient.monitorOperation(operationId, {
|
|
109
|
+
timeout: (options.timeout ?? 600) * 1000, // Convert to milliseconds, 10 minute default
|
|
110
|
+
onProgress: (progress) => {
|
|
111
|
+
if (options.onProgress) {
|
|
112
|
+
let msg = progress.message
|
|
113
|
+
if (progress.progressPercent !== undefined) {
|
|
114
|
+
msg += ` (${progress.progressPercent.toFixed(0)}%)`
|
|
115
|
+
}
|
|
116
|
+
options.onProgress(msg)
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
// Convert operation result to materialization result
|
|
122
|
+
return this.convertOperationResult(opResult, options)
|
|
123
|
+
} catch (error) {
|
|
124
|
+
return {
|
|
125
|
+
status: 'failed',
|
|
126
|
+
wasStale: false,
|
|
127
|
+
tablesMaterialized: [],
|
|
128
|
+
totalRows: 0,
|
|
129
|
+
executionTimeMs: 0,
|
|
130
|
+
message: error instanceof Error ? error.message : String(error),
|
|
131
|
+
success: false,
|
|
132
|
+
error: error instanceof Error ? error.message : String(error),
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Convert SSE operation result to MaterializationResult
|
|
139
|
+
*/
|
|
140
|
+
private convertOperationResult(
|
|
141
|
+
opResult: OperationResult,
|
|
142
|
+
options: MaterializationOptions
|
|
143
|
+
): MaterializationResult {
|
|
144
|
+
if (opResult.success) {
|
|
145
|
+
// Extract details from SSE completion event result
|
|
146
|
+
const sseResult = opResult.result || {}
|
|
147
|
+
|
|
148
|
+
const tables = sseResult.tables_materialized || []
|
|
149
|
+
const rows = sseResult.total_rows || 0
|
|
150
|
+
const timeMs = sseResult.execution_time_ms || 0
|
|
99
151
|
|
|
100
152
|
options.onProgress?.(
|
|
101
|
-
`✅ Materialization complete: ${
|
|
102
|
-
`${
|
|
153
|
+
`✅ Materialization complete: ${tables.length} tables, ` +
|
|
154
|
+
`${rows.toLocaleString()} rows in ${timeMs.toFixed(2)}ms`
|
|
103
155
|
)
|
|
104
156
|
|
|
105
157
|
return {
|
|
106
|
-
status:
|
|
107
|
-
wasStale:
|
|
108
|
-
staleReason:
|
|
109
|
-
tablesMaterialized:
|
|
110
|
-
totalRows:
|
|
111
|
-
executionTimeMs:
|
|
112
|
-
message:
|
|
158
|
+
status: 'success',
|
|
159
|
+
wasStale: sseResult.was_stale || false,
|
|
160
|
+
staleReason: sseResult.stale_reason,
|
|
161
|
+
tablesMaterialized: tables,
|
|
162
|
+
totalRows: rows,
|
|
163
|
+
executionTimeMs: timeMs,
|
|
164
|
+
message: sseResult.message || 'Graph materialized successfully',
|
|
113
165
|
success: true,
|
|
114
166
|
}
|
|
115
|
-
}
|
|
167
|
+
} else {
|
|
168
|
+
// Operation failed or was cancelled
|
|
116
169
|
return {
|
|
117
170
|
status: 'failed',
|
|
118
171
|
wasStale: false,
|
|
119
172
|
tablesMaterialized: [],
|
|
120
173
|
totalRows: 0,
|
|
121
174
|
executionTimeMs: 0,
|
|
122
|
-
message: error
|
|
175
|
+
message: opResult.error || 'Operation failed',
|
|
123
176
|
success: false,
|
|
124
|
-
error:
|
|
177
|
+
error: opResult.error,
|
|
125
178
|
}
|
|
126
179
|
}
|
|
127
180
|
}
|
|
@@ -160,4 +213,11 @@ export class MaterializationClient {
|
|
|
160
213
|
return null
|
|
161
214
|
}
|
|
162
215
|
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Close any active SSE connections
|
|
219
|
+
*/
|
|
220
|
+
close(): void {
|
|
221
|
+
this.operationClient.closeAll()
|
|
222
|
+
}
|
|
163
223
|
}
|
package/package.json
CHANGED
package/sdk/sdk.gen.d.ts
CHANGED
|
@@ -433,7 +433,7 @@ export declare const listAgents: <ThrowOnError extends boolean = false>(options:
|
|
|
433
433
|
* **Execution Strategies (automatic):**
|
|
434
434
|
* - Fast operations (<5s): Immediate synchronous response
|
|
435
435
|
* - Medium operations (5-30s): SSE streaming with progress updates
|
|
436
|
-
* - Long operations (>30s):
|
|
436
|
+
* - Long operations (>30s): Background queue with operation tracking
|
|
437
437
|
*
|
|
438
438
|
* **Response Mode Override:**
|
|
439
439
|
* Use query parameter `?mode=sync|async` to override automatic strategy selection.
|
|
@@ -494,7 +494,7 @@ export declare const getAgentMetadata: <ThrowOnError extends boolean = false>(op
|
|
|
494
494
|
* **Execution Strategies (automatic):**
|
|
495
495
|
* - Fast operations (<5s): Immediate synchronous response
|
|
496
496
|
* - Medium operations (5-30s): SSE streaming with progress updates
|
|
497
|
-
* - Long operations (>30s):
|
|
497
|
+
* - Long operations (>30s): Background queue with operation tracking
|
|
498
498
|
*
|
|
499
499
|
* **Response Mode Override:**
|
|
500
500
|
* Use query parameter `?mode=sync|async` to override automatic strategy selection.
|
|
@@ -1708,7 +1708,7 @@ export declare const getFile: <ThrowOnError extends boolean = false>(options: Op
|
|
|
1708
1708
|
* **What Happens (status='uploaded'):**
|
|
1709
1709
|
* 1. File validated in S3
|
|
1710
1710
|
* 2. Row count calculated
|
|
1711
|
-
* 3. DuckDB staging triggered immediately (
|
|
1711
|
+
* 3. DuckDB staging triggered immediately (background task)
|
|
1712
1712
|
* 4. If ingest_to_graph=true, graph ingestion queued
|
|
1713
1713
|
* 5. File queryable in DuckDB within seconds
|
|
1714
1714
|
*
|
package/sdk/sdk.gen.js
CHANGED
|
@@ -1079,7 +1079,7 @@ exports.listAgents = listAgents;
|
|
|
1079
1079
|
* **Execution Strategies (automatic):**
|
|
1080
1080
|
* - Fast operations (<5s): Immediate synchronous response
|
|
1081
1081
|
* - Medium operations (5-30s): SSE streaming with progress updates
|
|
1082
|
-
* - Long operations (>30s):
|
|
1082
|
+
* - Long operations (>30s): Background queue with operation tracking
|
|
1083
1083
|
*
|
|
1084
1084
|
* **Response Mode Override:**
|
|
1085
1085
|
* Use query parameter `?mode=sync|async` to override automatic strategy selection.
|
|
@@ -1176,7 +1176,7 @@ exports.getAgentMetadata = getAgentMetadata;
|
|
|
1176
1176
|
* **Execution Strategies (automatic):**
|
|
1177
1177
|
* - Fast operations (<5s): Immediate synchronous response
|
|
1178
1178
|
* - Medium operations (5-30s): SSE streaming with progress updates
|
|
1179
|
-
* - Long operations (>30s):
|
|
1179
|
+
* - Long operations (>30s): Background queue with operation tracking
|
|
1180
1180
|
*
|
|
1181
1181
|
* **Response Mode Override:**
|
|
1182
1182
|
* Use query parameter `?mode=sync|async` to override automatic strategy selection.
|
|
@@ -3130,7 +3130,7 @@ exports.getFile = getFile;
|
|
|
3130
3130
|
* **What Happens (status='uploaded'):**
|
|
3131
3131
|
* 1. File validated in S3
|
|
3132
3132
|
* 2. Row count calculated
|
|
3133
|
-
* 3. DuckDB staging triggered immediately (
|
|
3133
|
+
* 3. DuckDB staging triggered immediately (background task)
|
|
3134
3134
|
* 4. If ingest_to_graph=true, graph ingestion queued
|
|
3135
3135
|
* 5. File queryable in DuckDB within seconds
|
|
3136
3136
|
*
|
package/sdk/sdk.gen.ts
CHANGED
|
@@ -1092,7 +1092,7 @@ export const listAgents = <ThrowOnError extends boolean = false>(options: Option
|
|
|
1092
1092
|
* **Execution Strategies (automatic):**
|
|
1093
1093
|
* - Fast operations (<5s): Immediate synchronous response
|
|
1094
1094
|
* - Medium operations (5-30s): SSE streaming with progress updates
|
|
1095
|
-
* - Long operations (>30s):
|
|
1095
|
+
* - Long operations (>30s): Background queue with operation tracking
|
|
1096
1096
|
*
|
|
1097
1097
|
* **Response Mode Override:**
|
|
1098
1098
|
* Use query parameter `?mode=sync|async` to override automatic strategy selection.
|
|
@@ -1189,7 +1189,7 @@ export const getAgentMetadata = <ThrowOnError extends boolean = false>(options:
|
|
|
1189
1189
|
* **Execution Strategies (automatic):**
|
|
1190
1190
|
* - Fast operations (<5s): Immediate synchronous response
|
|
1191
1191
|
* - Medium operations (5-30s): SSE streaming with progress updates
|
|
1192
|
-
* - Long operations (>30s):
|
|
1192
|
+
* - Long operations (>30s): Background queue with operation tracking
|
|
1193
1193
|
*
|
|
1194
1194
|
* **Response Mode Override:**
|
|
1195
1195
|
* Use query parameter `?mode=sync|async` to override automatic strategy selection.
|
|
@@ -3143,7 +3143,7 @@ export const getFile = <ThrowOnError extends boolean = false>(options: Options<G
|
|
|
3143
3143
|
* **What Happens (status='uploaded'):**
|
|
3144
3144
|
* 1. File validated in S3
|
|
3145
3145
|
* 2. Row count calculated
|
|
3146
|
-
* 3. DuckDB staging triggered immediately (
|
|
3146
|
+
* 3. DuckDB staging triggered immediately (background task)
|
|
3147
3147
|
* 4. If ingest_to_graph=true, graph ingestion queued
|
|
3148
3148
|
* 5. File queryable in DuckDB within seconds
|
|
3149
3149
|
*
|
package/sdk/types.gen.d.ts
CHANGED
|
@@ -3018,43 +3018,24 @@ export type MaterializeRequest = {
|
|
|
3018
3018
|
};
|
|
3019
3019
|
/**
|
|
3020
3020
|
* MaterializeResponse
|
|
3021
|
+
* Response for queued materialization operation.
|
|
3021
3022
|
*/
|
|
3022
3023
|
export type MaterializeResponse = {
|
|
3023
3024
|
/**
|
|
3024
3025
|
* Status
|
|
3025
|
-
*
|
|
3026
|
+
* Operation status
|
|
3026
3027
|
*/
|
|
3027
|
-
status
|
|
3028
|
+
status?: string;
|
|
3028
3029
|
/**
|
|
3029
3030
|
* Graph Id
|
|
3030
3031
|
* Graph database identifier
|
|
3031
3032
|
*/
|
|
3032
3033
|
graph_id: string;
|
|
3033
3034
|
/**
|
|
3034
|
-
*
|
|
3035
|
-
*
|
|
3036
|
-
*/
|
|
3037
|
-
was_stale: boolean;
|
|
3038
|
-
/**
|
|
3039
|
-
* Stale Reason
|
|
3040
|
-
* Reason graph was stale
|
|
3041
|
-
*/
|
|
3042
|
-
stale_reason?: string | null;
|
|
3043
|
-
/**
|
|
3044
|
-
* Tables Materialized
|
|
3045
|
-
* List of tables successfully materialized
|
|
3046
|
-
*/
|
|
3047
|
-
tables_materialized: Array<string>;
|
|
3048
|
-
/**
|
|
3049
|
-
* Total Rows
|
|
3050
|
-
* Total rows materialized across all tables
|
|
3051
|
-
*/
|
|
3052
|
-
total_rows: number;
|
|
3053
|
-
/**
|
|
3054
|
-
* Execution Time Ms
|
|
3055
|
-
* Total materialization time
|
|
3035
|
+
* Operation Id
|
|
3036
|
+
* SSE operation ID for progress tracking
|
|
3056
3037
|
*/
|
|
3057
|
-
|
|
3038
|
+
operation_id: string;
|
|
3058
3039
|
/**
|
|
3059
3040
|
* Message
|
|
3060
3041
|
* Human-readable status message
|
package/sdk/types.gen.ts
CHANGED
|
@@ -3112,43 +3112,24 @@ export type MaterializeRequest = {
|
|
|
3112
3112
|
|
|
3113
3113
|
/**
|
|
3114
3114
|
* MaterializeResponse
|
|
3115
|
+
* Response for queued materialization operation.
|
|
3115
3116
|
*/
|
|
3116
3117
|
export type MaterializeResponse = {
|
|
3117
3118
|
/**
|
|
3118
3119
|
* Status
|
|
3119
|
-
*
|
|
3120
|
+
* Operation status
|
|
3120
3121
|
*/
|
|
3121
|
-
status
|
|
3122
|
+
status?: string;
|
|
3122
3123
|
/**
|
|
3123
3124
|
* Graph Id
|
|
3124
3125
|
* Graph database identifier
|
|
3125
3126
|
*/
|
|
3126
3127
|
graph_id: string;
|
|
3127
3128
|
/**
|
|
3128
|
-
*
|
|
3129
|
-
*
|
|
3130
|
-
*/
|
|
3131
|
-
was_stale: boolean;
|
|
3132
|
-
/**
|
|
3133
|
-
* Stale Reason
|
|
3134
|
-
* Reason graph was stale
|
|
3135
|
-
*/
|
|
3136
|
-
stale_reason?: string | null;
|
|
3137
|
-
/**
|
|
3138
|
-
* Tables Materialized
|
|
3139
|
-
* List of tables successfully materialized
|
|
3140
|
-
*/
|
|
3141
|
-
tables_materialized: Array<string>;
|
|
3142
|
-
/**
|
|
3143
|
-
* Total Rows
|
|
3144
|
-
* Total rows materialized across all tables
|
|
3145
|
-
*/
|
|
3146
|
-
total_rows: number;
|
|
3147
|
-
/**
|
|
3148
|
-
* Execution Time Ms
|
|
3149
|
-
* Total materialization time
|
|
3129
|
+
* Operation Id
|
|
3130
|
+
* SSE operation ID for progress tracking
|
|
3150
3131
|
*/
|
|
3151
|
-
|
|
3132
|
+
operation_id: string;
|
|
3152
3133
|
/**
|
|
3153
3134
|
* Message
|
|
3154
3135
|
* Human-readable status message
|
|
@@ -43,7 +43,7 @@ class AgentClient {
|
|
|
43
43
|
timestamp: new Date().toISOString(),
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
// Check if this is a queued response (async
|
|
46
|
+
// Check if this is a queued response (async background task execution)
|
|
47
47
|
if (responseData?.operation_id) {
|
|
48
48
|
const queuedResponse = responseData;
|
|
49
49
|
// If user doesn't want to wait, throw with queue info
|
|
@@ -87,7 +87,7 @@ class AgentClient {
|
|
|
87
87
|
timestamp: new Date().toISOString(),
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
// Check if this is a queued response (async
|
|
90
|
+
// Check if this is a queued response (async background task execution)
|
|
91
91
|
if (responseData?.operation_id) {
|
|
92
92
|
const queuedResponse = responseData;
|
|
93
93
|
// If user doesn't want to wait, throw with queue info
|
|
@@ -102,7 +102,7 @@ export class AgentClient {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
// Check if this is a queued response (async
|
|
105
|
+
// Check if this is a queued response (async background task execution)
|
|
106
106
|
if (responseData?.operation_id) {
|
|
107
107
|
const queuedResponse = responseData as QueuedAgentResponse
|
|
108
108
|
|
|
@@ -158,7 +158,7 @@ export class AgentClient {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
// Check if this is a queued response (async
|
|
161
|
+
// Check if this is a queued response (async background task execution)
|
|
162
162
|
if (responseData?.operation_id) {
|
|
163
163
|
const queuedResponse = responseData as QueuedAgentResponse
|
|
164
164
|
|
|
@@ -2,6 +2,7 @@ export interface MaterializationOptions {
|
|
|
2
2
|
ignoreErrors?: boolean;
|
|
3
3
|
rebuild?: boolean;
|
|
4
4
|
force?: boolean;
|
|
5
|
+
timeout?: number;
|
|
5
6
|
onProgress?: (message: string) => void;
|
|
6
7
|
}
|
|
7
8
|
export interface MaterializationResult {
|
|
@@ -27,6 +28,7 @@ export interface MaterializationStatus {
|
|
|
27
28
|
}
|
|
28
29
|
export declare class MaterializationClient {
|
|
29
30
|
private config;
|
|
31
|
+
private operationClient;
|
|
30
32
|
constructor(config: {
|
|
31
33
|
baseUrl: string;
|
|
32
34
|
credentials?: 'include' | 'same-origin' | 'omit';
|
|
@@ -36,11 +38,15 @@ export declare class MaterializationClient {
|
|
|
36
38
|
/**
|
|
37
39
|
* Materialize graph from DuckDB staging tables
|
|
38
40
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
41
|
+
* Submits a materialization job to Dagster and monitors progress via SSE.
|
|
42
|
+
* The operation runs asynchronously on the server but this method waits
|
|
43
|
+
* for completion and returns the final result.
|
|
42
44
|
*/
|
|
43
45
|
materialize(graphId: string, options?: MaterializationOptions): Promise<MaterializationResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Convert SSE operation result to MaterializationResult
|
|
48
|
+
*/
|
|
49
|
+
private convertOperationResult;
|
|
44
50
|
/**
|
|
45
51
|
* Get current materialization status for the graph
|
|
46
52
|
*
|
|
@@ -48,4 +54,8 @@ export declare class MaterializationClient {
|
|
|
48
54
|
* when it was last materialized, and how long since last materialization.
|
|
49
55
|
*/
|
|
50
56
|
status(graphId: string): Promise<MaterializationStatus | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Close any active SSE connections
|
|
59
|
+
*/
|
|
60
|
+
close(): void;
|
|
51
61
|
}
|
|
@@ -6,23 +6,25 @@ exports.MaterializationClient = void 0;
|
|
|
6
6
|
* Materialization Client for RoboSystems API
|
|
7
7
|
*
|
|
8
8
|
* Manages graph materialization from DuckDB staging tables.
|
|
9
|
-
*
|
|
9
|
+
* Submits materialization jobs to Dagster and monitors progress via SSE.
|
|
10
10
|
*/
|
|
11
11
|
const sdk_gen_1 = require("../sdk/sdk.gen");
|
|
12
|
+
const OperationClient_1 = require("./OperationClient");
|
|
12
13
|
class MaterializationClient {
|
|
13
14
|
constructor(config) {
|
|
14
15
|
this.config = config;
|
|
16
|
+
this.operationClient = new OperationClient_1.OperationClient(config);
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* Materialize graph from DuckDB staging tables
|
|
18
20
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
21
|
+
* Submits a materialization job to Dagster and monitors progress via SSE.
|
|
22
|
+
* The operation runs asynchronously on the server but this method waits
|
|
23
|
+
* for completion and returns the final result.
|
|
22
24
|
*/
|
|
23
25
|
async materialize(graphId, options = {}) {
|
|
24
26
|
try {
|
|
25
|
-
options.onProgress?.('
|
|
27
|
+
options.onProgress?.('Submitting materialization job...');
|
|
26
28
|
const request = {
|
|
27
29
|
ignore_errors: options.ignoreErrors ?? true,
|
|
28
30
|
rebuild: options.rebuild ?? false,
|
|
@@ -44,19 +46,24 @@ class MaterializationClient {
|
|
|
44
46
|
error: `Failed to materialize graph: ${response.error}`,
|
|
45
47
|
};
|
|
46
48
|
}
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
const queuedResponse = response.data;
|
|
50
|
+
const operationId = queuedResponse.operation_id;
|
|
51
|
+
options.onProgress?.(`Materialization queued (operation: ${operationId})`);
|
|
52
|
+
// Monitor the operation via SSE until completion
|
|
53
|
+
const opResult = await this.operationClient.monitorOperation(operationId, {
|
|
54
|
+
timeout: (options.timeout ?? 600) * 1000, // Convert to milliseconds, 10 minute default
|
|
55
|
+
onProgress: (progress) => {
|
|
56
|
+
if (options.onProgress) {
|
|
57
|
+
let msg = progress.message;
|
|
58
|
+
if (progress.progressPercent !== undefined) {
|
|
59
|
+
msg += ` (${progress.progressPercent.toFixed(0)}%)`;
|
|
60
|
+
}
|
|
61
|
+
options.onProgress(msg);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
// Convert operation result to materialization result
|
|
66
|
+
return this.convertOperationResult(opResult, options);
|
|
60
67
|
}
|
|
61
68
|
catch (error) {
|
|
62
69
|
return {
|
|
@@ -71,6 +78,43 @@ class MaterializationClient {
|
|
|
71
78
|
};
|
|
72
79
|
}
|
|
73
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Convert SSE operation result to MaterializationResult
|
|
83
|
+
*/
|
|
84
|
+
convertOperationResult(opResult, options) {
|
|
85
|
+
if (opResult.success) {
|
|
86
|
+
// Extract details from SSE completion event result
|
|
87
|
+
const sseResult = opResult.result || {};
|
|
88
|
+
const tables = sseResult.tables_materialized || [];
|
|
89
|
+
const rows = sseResult.total_rows || 0;
|
|
90
|
+
const timeMs = sseResult.execution_time_ms || 0;
|
|
91
|
+
options.onProgress?.(`✅ Materialization complete: ${tables.length} tables, ` +
|
|
92
|
+
`${rows.toLocaleString()} rows in ${timeMs.toFixed(2)}ms`);
|
|
93
|
+
return {
|
|
94
|
+
status: 'success',
|
|
95
|
+
wasStale: sseResult.was_stale || false,
|
|
96
|
+
staleReason: sseResult.stale_reason,
|
|
97
|
+
tablesMaterialized: tables,
|
|
98
|
+
totalRows: rows,
|
|
99
|
+
executionTimeMs: timeMs,
|
|
100
|
+
message: sseResult.message || 'Graph materialized successfully',
|
|
101
|
+
success: true,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// Operation failed or was cancelled
|
|
106
|
+
return {
|
|
107
|
+
status: 'failed',
|
|
108
|
+
wasStale: false,
|
|
109
|
+
tablesMaterialized: [],
|
|
110
|
+
totalRows: 0,
|
|
111
|
+
executionTimeMs: 0,
|
|
112
|
+
message: opResult.error || 'Operation failed',
|
|
113
|
+
success: false,
|
|
114
|
+
error: opResult.error,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
74
118
|
/**
|
|
75
119
|
* Get current materialization status for the graph
|
|
76
120
|
*
|
|
@@ -103,5 +147,11 @@ class MaterializationClient {
|
|
|
103
147
|
return null;
|
|
104
148
|
}
|
|
105
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Close any active SSE connections
|
|
152
|
+
*/
|
|
153
|
+
close() {
|
|
154
|
+
this.operationClient.closeAll();
|
|
155
|
+
}
|
|
106
156
|
}
|
|
107
157
|
exports.MaterializationClient = MaterializationClient;
|
|
@@ -4,16 +4,18 @@
|
|
|
4
4
|
* Materialization Client for RoboSystems API
|
|
5
5
|
*
|
|
6
6
|
* Manages graph materialization from DuckDB staging tables.
|
|
7
|
-
*
|
|
7
|
+
* Submits materialization jobs to Dagster and monitors progress via SSE.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { getMaterializationStatus, materializeGraph } from '../sdk/sdk.gen'
|
|
11
11
|
import type { MaterializeRequest } from '../sdk/types.gen'
|
|
12
|
+
import { OperationClient, type OperationResult } from './OperationClient'
|
|
12
13
|
|
|
13
14
|
export interface MaterializationOptions {
|
|
14
15
|
ignoreErrors?: boolean
|
|
15
16
|
rebuild?: boolean
|
|
16
17
|
force?: boolean
|
|
18
|
+
timeout?: number // Default 10 minutes
|
|
17
19
|
onProgress?: (message: string) => void
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -47,6 +49,7 @@ export class MaterializationClient {
|
|
|
47
49
|
headers?: Record<string, string>
|
|
48
50
|
token?: string
|
|
49
51
|
}
|
|
52
|
+
private operationClient: OperationClient
|
|
50
53
|
|
|
51
54
|
constructor(config: {
|
|
52
55
|
baseUrl: string
|
|
@@ -55,21 +58,22 @@ export class MaterializationClient {
|
|
|
55
58
|
token?: string
|
|
56
59
|
}) {
|
|
57
60
|
this.config = config
|
|
61
|
+
this.operationClient = new OperationClient(config)
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
/**
|
|
61
65
|
* Materialize graph from DuckDB staging tables
|
|
62
66
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
67
|
+
* Submits a materialization job to Dagster and monitors progress via SSE.
|
|
68
|
+
* The operation runs asynchronously on the server but this method waits
|
|
69
|
+
* for completion and returns the final result.
|
|
66
70
|
*/
|
|
67
71
|
async materialize(
|
|
68
72
|
graphId: string,
|
|
69
73
|
options: MaterializationOptions = {}
|
|
70
74
|
): Promise<MaterializationResult> {
|
|
71
75
|
try {
|
|
72
|
-
options.onProgress?.('
|
|
76
|
+
options.onProgress?.('Submitting materialization job...')
|
|
73
77
|
|
|
74
78
|
const request: MaterializeRequest = {
|
|
75
79
|
ignore_errors: options.ignoreErrors ?? true,
|
|
@@ -95,33 +99,82 @@ export class MaterializationClient {
|
|
|
95
99
|
}
|
|
96
100
|
}
|
|
97
101
|
|
|
98
|
-
const
|
|
102
|
+
const queuedResponse = response.data as { operation_id: string; message: string }
|
|
103
|
+
const operationId = queuedResponse.operation_id
|
|
104
|
+
|
|
105
|
+
options.onProgress?.(`Materialization queued (operation: ${operationId})`)
|
|
106
|
+
|
|
107
|
+
// Monitor the operation via SSE until completion
|
|
108
|
+
const opResult = await this.operationClient.monitorOperation(operationId, {
|
|
109
|
+
timeout: (options.timeout ?? 600) * 1000, // Convert to milliseconds, 10 minute default
|
|
110
|
+
onProgress: (progress) => {
|
|
111
|
+
if (options.onProgress) {
|
|
112
|
+
let msg = progress.message
|
|
113
|
+
if (progress.progressPercent !== undefined) {
|
|
114
|
+
msg += ` (${progress.progressPercent.toFixed(0)}%)`
|
|
115
|
+
}
|
|
116
|
+
options.onProgress(msg)
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
// Convert operation result to materialization result
|
|
122
|
+
return this.convertOperationResult(opResult, options)
|
|
123
|
+
} catch (error) {
|
|
124
|
+
return {
|
|
125
|
+
status: 'failed',
|
|
126
|
+
wasStale: false,
|
|
127
|
+
tablesMaterialized: [],
|
|
128
|
+
totalRows: 0,
|
|
129
|
+
executionTimeMs: 0,
|
|
130
|
+
message: error instanceof Error ? error.message : String(error),
|
|
131
|
+
success: false,
|
|
132
|
+
error: error instanceof Error ? error.message : String(error),
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Convert SSE operation result to MaterializationResult
|
|
139
|
+
*/
|
|
140
|
+
private convertOperationResult(
|
|
141
|
+
opResult: OperationResult,
|
|
142
|
+
options: MaterializationOptions
|
|
143
|
+
): MaterializationResult {
|
|
144
|
+
if (opResult.success) {
|
|
145
|
+
// Extract details from SSE completion event result
|
|
146
|
+
const sseResult = opResult.result || {}
|
|
147
|
+
|
|
148
|
+
const tables = sseResult.tables_materialized || []
|
|
149
|
+
const rows = sseResult.total_rows || 0
|
|
150
|
+
const timeMs = sseResult.execution_time_ms || 0
|
|
99
151
|
|
|
100
152
|
options.onProgress?.(
|
|
101
|
-
`✅ Materialization complete: ${
|
|
102
|
-
`${
|
|
153
|
+
`✅ Materialization complete: ${tables.length} tables, ` +
|
|
154
|
+
`${rows.toLocaleString()} rows in ${timeMs.toFixed(2)}ms`
|
|
103
155
|
)
|
|
104
156
|
|
|
105
157
|
return {
|
|
106
|
-
status:
|
|
107
|
-
wasStale:
|
|
108
|
-
staleReason:
|
|
109
|
-
tablesMaterialized:
|
|
110
|
-
totalRows:
|
|
111
|
-
executionTimeMs:
|
|
112
|
-
message:
|
|
158
|
+
status: 'success',
|
|
159
|
+
wasStale: sseResult.was_stale || false,
|
|
160
|
+
staleReason: sseResult.stale_reason,
|
|
161
|
+
tablesMaterialized: tables,
|
|
162
|
+
totalRows: rows,
|
|
163
|
+
executionTimeMs: timeMs,
|
|
164
|
+
message: sseResult.message || 'Graph materialized successfully',
|
|
113
165
|
success: true,
|
|
114
166
|
}
|
|
115
|
-
}
|
|
167
|
+
} else {
|
|
168
|
+
// Operation failed or was cancelled
|
|
116
169
|
return {
|
|
117
170
|
status: 'failed',
|
|
118
171
|
wasStale: false,
|
|
119
172
|
tablesMaterialized: [],
|
|
120
173
|
totalRows: 0,
|
|
121
174
|
executionTimeMs: 0,
|
|
122
|
-
message: error
|
|
175
|
+
message: opResult.error || 'Operation failed',
|
|
123
176
|
success: false,
|
|
124
|
-
error:
|
|
177
|
+
error: opResult.error,
|
|
125
178
|
}
|
|
126
179
|
}
|
|
127
180
|
}
|
|
@@ -160,4 +213,11 @@ export class MaterializationClient {
|
|
|
160
213
|
return null
|
|
161
214
|
}
|
|
162
215
|
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Close any active SSE connections
|
|
219
|
+
*/
|
|
220
|
+
close(): void {
|
|
221
|
+
this.operationClient.closeAll()
|
|
222
|
+
}
|
|
163
223
|
}
|
package/sdk-extensions/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# RoboSystems Typescript Client Extensions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Enhanced SSE and Real-time Features** for the RoboSystems Typescript Client
|
|
4
4
|
|
|
5
5
|
[](https://www.typescriptlang.org/)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -17,7 +17,7 @@ The RoboSystems Typescript Client Extensions provide production-ready enhancemen
|
|
|
17
17
|
- **React Hooks** for seamless UI integration
|
|
18
18
|
- **Full TypeScript Support** with comprehensive type definitions
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## Quick Start
|
|
21
21
|
|
|
22
22
|
### Installation
|
|
23
23
|
|
|
@@ -137,7 +137,7 @@ if (result.success) {
|
|
|
137
137
|
}
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
-
##
|
|
140
|
+
## SSE Event Types
|
|
141
141
|
|
|
142
142
|
The SDK supports all RoboSystems SSE event types:
|
|
143
143
|
|
|
@@ -162,7 +162,7 @@ enum EventType {
|
|
|
162
162
|
}
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
-
##
|
|
165
|
+
## Advanced SSE Features
|
|
166
166
|
|
|
167
167
|
### Automatic Reconnection
|
|
168
168
|
|
|
@@ -227,7 +227,7 @@ try {
|
|
|
227
227
|
}
|
|
228
228
|
```
|
|
229
229
|
|
|
230
|
-
##
|
|
230
|
+
## Table Ingestion
|
|
231
231
|
|
|
232
232
|
### TableIngestClient for Parquet File Uploads
|
|
233
233
|
|
|
@@ -250,9 +250,9 @@ const result = await tableClient.uploadParquetFile('graph-id', 'Entity', Buffer.
|
|
|
250
250
|
})
|
|
251
251
|
|
|
252
252
|
if (result.success) {
|
|
253
|
-
console.log(
|
|
253
|
+
console.log(`Uploaded ${result.rowCount} rows to ${result.tableName}`)
|
|
254
254
|
} else {
|
|
255
|
-
console.error(
|
|
255
|
+
console.error(`Upload failed: ${result.error}`)
|
|
256
256
|
}
|
|
257
257
|
```
|
|
258
258
|
|
|
@@ -331,7 +331,7 @@ if (result.success) {
|
|
|
331
331
|
}
|
|
332
332
|
```
|
|
333
333
|
|
|
334
|
-
##
|
|
334
|
+
## Operation Monitoring
|
|
335
335
|
|
|
336
336
|
### OperationClient for Long-Running Tasks
|
|
337
337
|
|
|
@@ -420,7 +420,7 @@ await operationClient.monitor('operation-id', {
|
|
|
420
420
|
})
|
|
421
421
|
```
|
|
422
422
|
|
|
423
|
-
##
|
|
423
|
+
## React Integration
|
|
424
424
|
|
|
425
425
|
### useSSE Hook
|
|
426
426
|
|
|
@@ -569,7 +569,7 @@ function DataImporter({ graphId }: { graphId: string }) {
|
|
|
569
569
|
|
|
570
570
|
{result && result.status === 'completed' && (
|
|
571
571
|
<div style={{ color: 'green' }}>
|
|
572
|
-
<p
|
|
572
|
+
<p>Successfully imported {result.rowsImported} rows</p>
|
|
573
573
|
<p>Execution time: {(result.executionTimeMs / 1000).toFixed(2)}s</p>
|
|
574
574
|
</div>
|
|
575
575
|
)}
|
|
@@ -578,7 +578,7 @@ function DataImporter({ graphId }: { graphId: string }) {
|
|
|
578
578
|
}
|
|
579
579
|
```
|
|
580
580
|
|
|
581
|
-
##
|
|
581
|
+
## Error Handling & Resilience
|
|
582
582
|
|
|
583
583
|
### Circuit Breaker Pattern
|
|
584
584
|
|
|
@@ -649,7 +649,7 @@ sseClient.on('connection_recycled', ({ old, new }) => {
|
|
|
649
649
|
})
|
|
650
650
|
```
|
|
651
651
|
|
|
652
|
-
##
|
|
652
|
+
## Configuration
|
|
653
653
|
|
|
654
654
|
### Environment Variables
|
|
655
655
|
|
|
@@ -713,7 +713,7 @@ const result = await extensions.files.upload('graph-id', 'TableName', fileBuffer
|
|
|
713
713
|
})
|
|
714
714
|
```
|
|
715
715
|
|
|
716
|
-
##
|
|
716
|
+
## Performance Optimization
|
|
717
717
|
|
|
718
718
|
### Stream Processing for Large Datasets
|
|
719
719
|
|
|
@@ -761,7 +761,7 @@ cachedClient.on('cache_invalidated', (query) => {
|
|
|
761
761
|
})
|
|
762
762
|
```
|
|
763
763
|
|
|
764
|
-
##
|
|
764
|
+
## Testing
|
|
765
765
|
|
|
766
766
|
### Mock SSE for Testing
|
|
767
767
|
|
|
@@ -796,7 +796,7 @@ describe('SSE Integration', () => {
|
|
|
796
796
|
})
|
|
797
797
|
```
|
|
798
798
|
|
|
799
|
-
##
|
|
799
|
+
## API Reference
|
|
800
800
|
|
|
801
801
|
### Core Classes
|
|
802
802
|
|
|
@@ -826,7 +826,7 @@ describe('SSE Integration', () => {
|
|
|
826
826
|
- **`formatDuration`** - Human-readable duration formatting
|
|
827
827
|
- **`parseSSEEvent`** - SSE event parsing utility
|
|
828
828
|
|
|
829
|
-
##
|
|
829
|
+
## Troubleshooting
|
|
830
830
|
|
|
831
831
|
### Common Issues
|
|
832
832
|
|
|
@@ -882,15 +882,15 @@ sseClient.on('*', (event, data) => {
|
|
|
882
882
|
})
|
|
883
883
|
```
|
|
884
884
|
|
|
885
|
-
##
|
|
885
|
+
## License
|
|
886
886
|
|
|
887
887
|
MIT License - see [LICENSE](../../LICENSE) file for details.
|
|
888
888
|
|
|
889
|
-
##
|
|
889
|
+
## Contributing
|
|
890
890
|
|
|
891
891
|
See the [Contributing Guide](../../CONTRIBUTING.md) for development setup and guidelines.
|
|
892
892
|
|
|
893
|
-
##
|
|
893
|
+
## Support
|
|
894
894
|
|
|
895
895
|
- **API Reference**: [api.robosystems.ai/docs](https://api.robosystems.ai/docs)
|
|
896
896
|
- **Discord**: [Join our community](https://discord.gg/V9vjcqstxX)
|
|
@@ -899,5 +899,3 @@ See the [Contributing Guide](../../CONTRIBUTING.md) for development setup and gu
|
|
|
899
899
|
---
|
|
900
900
|
|
|
901
901
|
**RoboSystems Typescript Client Extensions** - Production-ready SSE streaming and real-time monitoring for financial knowledge graphs.
|
|
902
|
-
|
|
903
|
-
_Built with ❤️ by the RoboSystems team_
|
package/sdk.gen.d.ts
CHANGED
|
@@ -433,7 +433,7 @@ export declare const listAgents: <ThrowOnError extends boolean = false>(options:
|
|
|
433
433
|
* **Execution Strategies (automatic):**
|
|
434
434
|
* - Fast operations (<5s): Immediate synchronous response
|
|
435
435
|
* - Medium operations (5-30s): SSE streaming with progress updates
|
|
436
|
-
* - Long operations (>30s):
|
|
436
|
+
* - Long operations (>30s): Background queue with operation tracking
|
|
437
437
|
*
|
|
438
438
|
* **Response Mode Override:**
|
|
439
439
|
* Use query parameter `?mode=sync|async` to override automatic strategy selection.
|
|
@@ -494,7 +494,7 @@ export declare const getAgentMetadata: <ThrowOnError extends boolean = false>(op
|
|
|
494
494
|
* **Execution Strategies (automatic):**
|
|
495
495
|
* - Fast operations (<5s): Immediate synchronous response
|
|
496
496
|
* - Medium operations (5-30s): SSE streaming with progress updates
|
|
497
|
-
* - Long operations (>30s):
|
|
497
|
+
* - Long operations (>30s): Background queue with operation tracking
|
|
498
498
|
*
|
|
499
499
|
* **Response Mode Override:**
|
|
500
500
|
* Use query parameter `?mode=sync|async` to override automatic strategy selection.
|
|
@@ -1708,7 +1708,7 @@ export declare const getFile: <ThrowOnError extends boolean = false>(options: Op
|
|
|
1708
1708
|
* **What Happens (status='uploaded'):**
|
|
1709
1709
|
* 1. File validated in S3
|
|
1710
1710
|
* 2. Row count calculated
|
|
1711
|
-
* 3. DuckDB staging triggered immediately (
|
|
1711
|
+
* 3. DuckDB staging triggered immediately (background task)
|
|
1712
1712
|
* 4. If ingest_to_graph=true, graph ingestion queued
|
|
1713
1713
|
* 5. File queryable in DuckDB within seconds
|
|
1714
1714
|
*
|
package/sdk.gen.js
CHANGED
|
@@ -1079,7 +1079,7 @@ exports.listAgents = listAgents;
|
|
|
1079
1079
|
* **Execution Strategies (automatic):**
|
|
1080
1080
|
* - Fast operations (<5s): Immediate synchronous response
|
|
1081
1081
|
* - Medium operations (5-30s): SSE streaming with progress updates
|
|
1082
|
-
* - Long operations (>30s):
|
|
1082
|
+
* - Long operations (>30s): Background queue with operation tracking
|
|
1083
1083
|
*
|
|
1084
1084
|
* **Response Mode Override:**
|
|
1085
1085
|
* Use query parameter `?mode=sync|async` to override automatic strategy selection.
|
|
@@ -1176,7 +1176,7 @@ exports.getAgentMetadata = getAgentMetadata;
|
|
|
1176
1176
|
* **Execution Strategies (automatic):**
|
|
1177
1177
|
* - Fast operations (<5s): Immediate synchronous response
|
|
1178
1178
|
* - Medium operations (5-30s): SSE streaming with progress updates
|
|
1179
|
-
* - Long operations (>30s):
|
|
1179
|
+
* - Long operations (>30s): Background queue with operation tracking
|
|
1180
1180
|
*
|
|
1181
1181
|
* **Response Mode Override:**
|
|
1182
1182
|
* Use query parameter `?mode=sync|async` to override automatic strategy selection.
|
|
@@ -3130,7 +3130,7 @@ exports.getFile = getFile;
|
|
|
3130
3130
|
* **What Happens (status='uploaded'):**
|
|
3131
3131
|
* 1. File validated in S3
|
|
3132
3132
|
* 2. Row count calculated
|
|
3133
|
-
* 3. DuckDB staging triggered immediately (
|
|
3133
|
+
* 3. DuckDB staging triggered immediately (background task)
|
|
3134
3134
|
* 4. If ingest_to_graph=true, graph ingestion queued
|
|
3135
3135
|
* 5. File queryable in DuckDB within seconds
|
|
3136
3136
|
*
|
package/sdk.gen.ts
CHANGED
|
@@ -1092,7 +1092,7 @@ export const listAgents = <ThrowOnError extends boolean = false>(options: Option
|
|
|
1092
1092
|
* **Execution Strategies (automatic):**
|
|
1093
1093
|
* - Fast operations (<5s): Immediate synchronous response
|
|
1094
1094
|
* - Medium operations (5-30s): SSE streaming with progress updates
|
|
1095
|
-
* - Long operations (>30s):
|
|
1095
|
+
* - Long operations (>30s): Background queue with operation tracking
|
|
1096
1096
|
*
|
|
1097
1097
|
* **Response Mode Override:**
|
|
1098
1098
|
* Use query parameter `?mode=sync|async` to override automatic strategy selection.
|
|
@@ -1189,7 +1189,7 @@ export const getAgentMetadata = <ThrowOnError extends boolean = false>(options:
|
|
|
1189
1189
|
* **Execution Strategies (automatic):**
|
|
1190
1190
|
* - Fast operations (<5s): Immediate synchronous response
|
|
1191
1191
|
* - Medium operations (5-30s): SSE streaming with progress updates
|
|
1192
|
-
* - Long operations (>30s):
|
|
1192
|
+
* - Long operations (>30s): Background queue with operation tracking
|
|
1193
1193
|
*
|
|
1194
1194
|
* **Response Mode Override:**
|
|
1195
1195
|
* Use query parameter `?mode=sync|async` to override automatic strategy selection.
|
|
@@ -3143,7 +3143,7 @@ export const getFile = <ThrowOnError extends boolean = false>(options: Options<G
|
|
|
3143
3143
|
* **What Happens (status='uploaded'):**
|
|
3144
3144
|
* 1. File validated in S3
|
|
3145
3145
|
* 2. Row count calculated
|
|
3146
|
-
* 3. DuckDB staging triggered immediately (
|
|
3146
|
+
* 3. DuckDB staging triggered immediately (background task)
|
|
3147
3147
|
* 4. If ingest_to_graph=true, graph ingestion queued
|
|
3148
3148
|
* 5. File queryable in DuckDB within seconds
|
|
3149
3149
|
*
|
package/types.gen.d.ts
CHANGED
|
@@ -3018,43 +3018,24 @@ export type MaterializeRequest = {
|
|
|
3018
3018
|
};
|
|
3019
3019
|
/**
|
|
3020
3020
|
* MaterializeResponse
|
|
3021
|
+
* Response for queued materialization operation.
|
|
3021
3022
|
*/
|
|
3022
3023
|
export type MaterializeResponse = {
|
|
3023
3024
|
/**
|
|
3024
3025
|
* Status
|
|
3025
|
-
*
|
|
3026
|
+
* Operation status
|
|
3026
3027
|
*/
|
|
3027
|
-
status
|
|
3028
|
+
status?: string;
|
|
3028
3029
|
/**
|
|
3029
3030
|
* Graph Id
|
|
3030
3031
|
* Graph database identifier
|
|
3031
3032
|
*/
|
|
3032
3033
|
graph_id: string;
|
|
3033
3034
|
/**
|
|
3034
|
-
*
|
|
3035
|
-
*
|
|
3036
|
-
*/
|
|
3037
|
-
was_stale: boolean;
|
|
3038
|
-
/**
|
|
3039
|
-
* Stale Reason
|
|
3040
|
-
* Reason graph was stale
|
|
3041
|
-
*/
|
|
3042
|
-
stale_reason?: string | null;
|
|
3043
|
-
/**
|
|
3044
|
-
* Tables Materialized
|
|
3045
|
-
* List of tables successfully materialized
|
|
3046
|
-
*/
|
|
3047
|
-
tables_materialized: Array<string>;
|
|
3048
|
-
/**
|
|
3049
|
-
* Total Rows
|
|
3050
|
-
* Total rows materialized across all tables
|
|
3051
|
-
*/
|
|
3052
|
-
total_rows: number;
|
|
3053
|
-
/**
|
|
3054
|
-
* Execution Time Ms
|
|
3055
|
-
* Total materialization time
|
|
3035
|
+
* Operation Id
|
|
3036
|
+
* SSE operation ID for progress tracking
|
|
3056
3037
|
*/
|
|
3057
|
-
|
|
3038
|
+
operation_id: string;
|
|
3058
3039
|
/**
|
|
3059
3040
|
* Message
|
|
3060
3041
|
* Human-readable status message
|
package/types.gen.ts
CHANGED
|
@@ -3112,43 +3112,24 @@ export type MaterializeRequest = {
|
|
|
3112
3112
|
|
|
3113
3113
|
/**
|
|
3114
3114
|
* MaterializeResponse
|
|
3115
|
+
* Response for queued materialization operation.
|
|
3115
3116
|
*/
|
|
3116
3117
|
export type MaterializeResponse = {
|
|
3117
3118
|
/**
|
|
3118
3119
|
* Status
|
|
3119
|
-
*
|
|
3120
|
+
* Operation status
|
|
3120
3121
|
*/
|
|
3121
|
-
status
|
|
3122
|
+
status?: string;
|
|
3122
3123
|
/**
|
|
3123
3124
|
* Graph Id
|
|
3124
3125
|
* Graph database identifier
|
|
3125
3126
|
*/
|
|
3126
3127
|
graph_id: string;
|
|
3127
3128
|
/**
|
|
3128
|
-
*
|
|
3129
|
-
*
|
|
3130
|
-
*/
|
|
3131
|
-
was_stale: boolean;
|
|
3132
|
-
/**
|
|
3133
|
-
* Stale Reason
|
|
3134
|
-
* Reason graph was stale
|
|
3135
|
-
*/
|
|
3136
|
-
stale_reason?: string | null;
|
|
3137
|
-
/**
|
|
3138
|
-
* Tables Materialized
|
|
3139
|
-
* List of tables successfully materialized
|
|
3140
|
-
*/
|
|
3141
|
-
tables_materialized: Array<string>;
|
|
3142
|
-
/**
|
|
3143
|
-
* Total Rows
|
|
3144
|
-
* Total rows materialized across all tables
|
|
3145
|
-
*/
|
|
3146
|
-
total_rows: number;
|
|
3147
|
-
/**
|
|
3148
|
-
* Execution Time Ms
|
|
3149
|
-
* Total materialization time
|
|
3129
|
+
* Operation Id
|
|
3130
|
+
* SSE operation ID for progress tracking
|
|
3150
3131
|
*/
|
|
3151
|
-
|
|
3132
|
+
operation_id: string;
|
|
3152
3133
|
/**
|
|
3153
3134
|
* Message
|
|
3154
3135
|
* Human-readable status message
|