@robosystems/client 0.2.43 → 0.2.45

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.
Files changed (73) hide show
  1. package/extensions/LedgerClient.d.ts +88 -0
  2. package/extensions/LedgerClient.js +143 -0
  3. package/extensions/LedgerClient.ts +267 -0
  4. package/extensions/ReportClient.d.ts +14 -6
  5. package/extensions/ReportClient.js +19 -15
  6. package/extensions/ReportClient.ts +37 -21
  7. package/extensions/hooks.d.ts +1 -40
  8. package/extensions/hooks.js +0 -134
  9. package/extensions/hooks.ts +0 -156
  10. package/extensions/index.d.ts +2 -24
  11. package/extensions/index.js +1 -65
  12. package/extensions/index.test.ts +4 -38
  13. package/extensions/index.ts +0 -78
  14. package/index.ts +2 -2
  15. package/package.json +1 -1
  16. package/sdk/index.d.ts +2 -2
  17. package/sdk/index.js +9 -6
  18. package/sdk/index.ts +2 -2
  19. package/sdk/sdk.gen.d.ts +33 -34
  20. package/sdk/sdk.gen.js +68 -46
  21. package/sdk/sdk.gen.ts +66 -44
  22. package/sdk/types.gen.d.ts +709 -278
  23. package/sdk/types.gen.ts +730 -270
  24. package/sdk-extensions/LedgerClient.d.ts +88 -0
  25. package/sdk-extensions/LedgerClient.js +143 -0
  26. package/sdk-extensions/LedgerClient.ts +267 -0
  27. package/sdk-extensions/ReportClient.d.ts +14 -6
  28. package/sdk-extensions/ReportClient.js +19 -15
  29. package/sdk-extensions/ReportClient.ts +37 -21
  30. package/sdk-extensions/hooks.d.ts +1 -40
  31. package/sdk-extensions/hooks.js +0 -134
  32. package/sdk-extensions/hooks.ts +0 -156
  33. package/sdk-extensions/index.d.ts +2 -24
  34. package/sdk-extensions/index.js +1 -65
  35. package/sdk-extensions/index.test.ts +4 -38
  36. package/sdk-extensions/index.ts +0 -78
  37. package/sdk.gen.d.ts +33 -34
  38. package/sdk.gen.js +68 -46
  39. package/sdk.gen.ts +66 -44
  40. package/types.gen.d.ts +709 -278
  41. package/types.gen.ts +730 -270
  42. package/extensions/DocumentClient.d.ts +0 -102
  43. package/extensions/DocumentClient.js +0 -176
  44. package/extensions/DocumentClient.ts +0 -297
  45. package/extensions/FileClient.d.ts +0 -57
  46. package/extensions/FileClient.js +0 -246
  47. package/extensions/FileClient.ts +0 -330
  48. package/extensions/GraphClient.d.ts +0 -91
  49. package/extensions/GraphClient.js +0 -244
  50. package/extensions/GraphClient.test.ts +0 -455
  51. package/extensions/GraphClient.ts +0 -371
  52. package/extensions/MaterializationClient.d.ts +0 -61
  53. package/extensions/MaterializationClient.js +0 -157
  54. package/extensions/MaterializationClient.ts +0 -223
  55. package/extensions/TableClient.d.ts +0 -38
  56. package/extensions/TableClient.js +0 -92
  57. package/extensions/TableClient.ts +0 -132
  58. package/sdk-extensions/DocumentClient.d.ts +0 -102
  59. package/sdk-extensions/DocumentClient.js +0 -176
  60. package/sdk-extensions/DocumentClient.ts +0 -297
  61. package/sdk-extensions/FileClient.d.ts +0 -57
  62. package/sdk-extensions/FileClient.js +0 -246
  63. package/sdk-extensions/FileClient.ts +0 -330
  64. package/sdk-extensions/GraphClient.d.ts +0 -91
  65. package/sdk-extensions/GraphClient.js +0 -244
  66. package/sdk-extensions/GraphClient.test.ts +0 -455
  67. package/sdk-extensions/GraphClient.ts +0 -371
  68. package/sdk-extensions/MaterializationClient.d.ts +0 -61
  69. package/sdk-extensions/MaterializationClient.js +0 -157
  70. package/sdk-extensions/MaterializationClient.ts +0 -223
  71. package/sdk-extensions/TableClient.d.ts +0 -38
  72. package/sdk-extensions/TableClient.js +0 -92
  73. package/sdk-extensions/TableClient.ts +0 -132
@@ -1,223 +0,0 @@
1
- 'use client'
2
-
3
- /**
4
- * Materialization Client for RoboSystems API
5
- *
6
- * Manages graph materialization from DuckDB staging tables.
7
- * Submits materialization jobs to Dagster and monitors progress via SSE.
8
- */
9
-
10
- import { getMaterializationStatus, materializeGraph } from '../sdk.gen'
11
- import type { MaterializeRequest } from '../types.gen'
12
- import { OperationClient, type OperationResult } from './OperationClient'
13
-
14
- export interface MaterializationOptions {
15
- ignoreErrors?: boolean
16
- rebuild?: boolean
17
- force?: boolean
18
- timeout?: number // Default 10 minutes
19
- onProgress?: (message: string) => void
20
- }
21
-
22
- export interface MaterializationResult {
23
- status: string
24
- wasStale: boolean
25
- staleReason?: string
26
- tablesMaterialized: string[]
27
- totalRows: number
28
- executionTimeMs: number
29
- message: string
30
- success: boolean
31
- error?: string
32
- }
33
-
34
- export interface MaterializationStatus {
35
- graphId: string
36
- isStale: boolean
37
- staleReason?: string
38
- staleSince?: string
39
- lastMaterializedAt?: string
40
- materializationCount: number
41
- hoursSinceMaterialization?: number
42
- message: string
43
- }
44
-
45
- export class MaterializationClient {
46
- private config: {
47
- baseUrl: string
48
- credentials?: 'include' | 'same-origin' | 'omit'
49
- headers?: Record<string, string>
50
- token?: string
51
- }
52
- private operationClient: OperationClient
53
-
54
- constructor(config: {
55
- baseUrl: string
56
- credentials?: 'include' | 'same-origin' | 'omit'
57
- headers?: Record<string, string>
58
- token?: string
59
- }) {
60
- this.config = config
61
- this.operationClient = new OperationClient(config)
62
- }
63
-
64
- /**
65
- * Materialize graph from DuckDB staging tables
66
- *
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.
70
- */
71
- async materialize(
72
- graphId: string,
73
- options: MaterializationOptions = {}
74
- ): Promise<MaterializationResult> {
75
- try {
76
- options.onProgress?.('Submitting materialization job...')
77
-
78
- const request: MaterializeRequest = {
79
- ignore_errors: options.ignoreErrors ?? true,
80
- rebuild: options.rebuild ?? false,
81
- force: options.force ?? false,
82
- }
83
-
84
- const response = await materializeGraph({
85
- path: { graph_id: graphId },
86
- body: request,
87
- })
88
-
89
- if (response.error || !response.data) {
90
- return {
91
- status: 'failed',
92
- wasStale: false,
93
- tablesMaterialized: [],
94
- totalRows: 0,
95
- executionTimeMs: 0,
96
- message: `Failed to materialize graph: ${response.error}`,
97
- success: false,
98
- error: `Failed to materialize graph: ${response.error}`,
99
- }
100
- }
101
-
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
151
-
152
- options.onProgress?.(
153
- `✅ Materialization complete: ${tables.length} tables, ` +
154
- `${rows.toLocaleString()} rows in ${timeMs.toFixed(2)}ms`
155
- )
156
-
157
- return {
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',
165
- success: true,
166
- }
167
- } else {
168
- // Operation failed or was cancelled
169
- return {
170
- status: 'failed',
171
- wasStale: false,
172
- tablesMaterialized: [],
173
- totalRows: 0,
174
- executionTimeMs: 0,
175
- message: opResult.error || 'Operation failed',
176
- success: false,
177
- error: opResult.error,
178
- }
179
- }
180
- }
181
-
182
- /**
183
- * Get current materialization status for the graph
184
- *
185
- * Shows whether the graph is stale (DuckDB has changes not yet in graph database),
186
- * when it was last materialized, and how long since last materialization.
187
- */
188
- async status(graphId: string): Promise<MaterializationStatus | null> {
189
- try {
190
- const response = await getMaterializationStatus({
191
- path: { graph_id: graphId },
192
- })
193
-
194
- if (response.error || !response.data) {
195
- console.error('Failed to get materialization status:', response.error)
196
- return null
197
- }
198
-
199
- const status = response.data as any
200
-
201
- return {
202
- graphId: status.graph_id,
203
- isStale: status.is_stale,
204
- staleReason: status.stale_reason,
205
- staleSince: status.stale_since,
206
- lastMaterializedAt: status.last_materialized_at,
207
- materializationCount: status.materialization_count || 0,
208
- hoursSinceMaterialization: status.hours_since_materialization,
209
- message: status.message,
210
- }
211
- } catch (error) {
212
- console.error('Failed to get materialization status:', error)
213
- return null
214
- }
215
- }
216
-
217
- /**
218
- * Close any active SSE connections
219
- */
220
- close(): void {
221
- this.operationClient.closeAll()
222
- }
223
- }
@@ -1,38 +0,0 @@
1
- export interface TableInfo {
2
- tableName: string;
3
- rowCount: number;
4
- fileCount: number;
5
- totalSizeBytes: number;
6
- s3Location?: string | null;
7
- }
8
- export interface TableQueryResult {
9
- columns: string[];
10
- rows: any[][];
11
- rowCount: number;
12
- executionTimeMs: number;
13
- success: boolean;
14
- error?: string;
15
- }
16
- export declare class TableClient {
17
- private config;
18
- constructor(config: {
19
- baseUrl: string;
20
- credentials?: 'include' | 'same-origin' | 'omit';
21
- headers?: Record<string, string>;
22
- token?: string;
23
- });
24
- /**
25
- * List all DuckDB staging tables in a graph
26
- */
27
- list(graphId: string): Promise<TableInfo[]>;
28
- /**
29
- * Execute SQL query against DuckDB staging tables
30
- *
31
- * Example:
32
- * const result = await client.tables.query(
33
- * graphId,
34
- * "SELECT * FROM Entity WHERE entity_type = 'CORPORATION'"
35
- * )
36
- */
37
- query(graphId: string, sqlQuery: string, limit?: number): Promise<TableQueryResult>;
38
- }
@@ -1,92 +0,0 @@
1
- 'use client';
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.TableClient = void 0;
5
- /**
6
- * Table Client for RoboSystems API
7
- *
8
- * Manages DuckDB staging table operations.
9
- * Tables provide SQL-queryable staging layer before graph materialization.
10
- */
11
- const sdk_gen_1 = require("../sdk.gen");
12
- class TableClient {
13
- constructor(config) {
14
- this.config = config;
15
- }
16
- /**
17
- * List all DuckDB staging tables in a graph
18
- */
19
- async list(graphId) {
20
- try {
21
- const response = await (0, sdk_gen_1.listTables)({
22
- path: { graph_id: graphId },
23
- });
24
- if (response.error || !response.data) {
25
- console.error('Failed to list tables:', response.error);
26
- return [];
27
- }
28
- const tableData = response.data;
29
- return (tableData.tables?.map((table) => ({
30
- tableName: table.table_name,
31
- rowCount: table.row_count,
32
- fileCount: table.file_count || 0,
33
- totalSizeBytes: table.total_size_bytes || 0,
34
- s3Location: table.s3_location,
35
- })) || []);
36
- }
37
- catch (error) {
38
- console.error('Failed to list tables:', error);
39
- return [];
40
- }
41
- }
42
- /**
43
- * Execute SQL query against DuckDB staging tables
44
- *
45
- * Example:
46
- * const result = await client.tables.query(
47
- * graphId,
48
- * "SELECT * FROM Entity WHERE entity_type = 'CORPORATION'"
49
- * )
50
- */
51
- async query(graphId, sqlQuery, limit) {
52
- try {
53
- const finalQuery = limit !== undefined ? `${sqlQuery.replace(/;?\s*$/, '')} LIMIT ${limit}` : sqlQuery;
54
- const request = {
55
- sql: finalQuery,
56
- };
57
- const response = await (0, sdk_gen_1.queryTables)({
58
- path: { graph_id: graphId },
59
- body: request,
60
- });
61
- if (response.error || !response.data) {
62
- return {
63
- columns: [],
64
- rows: [],
65
- rowCount: 0,
66
- executionTimeMs: 0,
67
- success: false,
68
- error: `Query failed: ${response.error}`,
69
- };
70
- }
71
- const result = response.data;
72
- return {
73
- columns: result.columns || [],
74
- rows: result.rows || [],
75
- rowCount: result.rows?.length || 0,
76
- executionTimeMs: result.execution_time_ms || 0,
77
- success: true,
78
- };
79
- }
80
- catch (error) {
81
- return {
82
- columns: [],
83
- rows: [],
84
- rowCount: 0,
85
- executionTimeMs: 0,
86
- success: false,
87
- error: error instanceof Error ? error.message : String(error),
88
- };
89
- }
90
- }
91
- }
92
- exports.TableClient = TableClient;
@@ -1,132 +0,0 @@
1
- 'use client'
2
-
3
- /**
4
- * Table Client for RoboSystems API
5
- *
6
- * Manages DuckDB staging table operations.
7
- * Tables provide SQL-queryable staging layer before graph materialization.
8
- */
9
-
10
- import { listTables, queryTables } from '../sdk.gen'
11
- import type { TableListResponse, TableQueryRequest } from '../types.gen'
12
-
13
- export interface TableInfo {
14
- tableName: string
15
- rowCount: number
16
- fileCount: number
17
- totalSizeBytes: number
18
- s3Location?: string | null
19
- }
20
-
21
- export interface TableQueryResult {
22
- columns: string[]
23
- rows: any[][]
24
- rowCount: number
25
- executionTimeMs: number
26
- success: boolean
27
- error?: string
28
- }
29
-
30
- export class TableClient {
31
- private config: {
32
- baseUrl: string
33
- credentials?: 'include' | 'same-origin' | 'omit'
34
- headers?: Record<string, string>
35
- token?: string
36
- }
37
-
38
- constructor(config: {
39
- baseUrl: string
40
- credentials?: 'include' | 'same-origin' | 'omit'
41
- headers?: Record<string, string>
42
- token?: string
43
- }) {
44
- this.config = config
45
- }
46
-
47
- /**
48
- * List all DuckDB staging tables in a graph
49
- */
50
- async list(graphId: string): Promise<TableInfo[]> {
51
- try {
52
- const response = await listTables({
53
- path: { graph_id: graphId },
54
- })
55
-
56
- if (response.error || !response.data) {
57
- console.error('Failed to list tables:', response.error)
58
- return []
59
- }
60
-
61
- const tableData = response.data as TableListResponse
62
-
63
- return (
64
- tableData.tables?.map((table) => ({
65
- tableName: table.table_name,
66
- rowCount: table.row_count,
67
- fileCount: table.file_count || 0,
68
- totalSizeBytes: table.total_size_bytes || 0,
69
- s3Location: table.s3_location,
70
- })) || []
71
- )
72
- } catch (error) {
73
- console.error('Failed to list tables:', error)
74
- return []
75
- }
76
- }
77
-
78
- /**
79
- * Execute SQL query against DuckDB staging tables
80
- *
81
- * Example:
82
- * const result = await client.tables.query(
83
- * graphId,
84
- * "SELECT * FROM Entity WHERE entity_type = 'CORPORATION'"
85
- * )
86
- */
87
- async query(graphId: string, sqlQuery: string, limit?: number): Promise<TableQueryResult> {
88
- try {
89
- const finalQuery =
90
- limit !== undefined ? `${sqlQuery.replace(/;?\s*$/, '')} LIMIT ${limit}` : sqlQuery
91
-
92
- const request: TableQueryRequest = {
93
- sql: finalQuery,
94
- }
95
-
96
- const response = await queryTables({
97
- path: { graph_id: graphId },
98
- body: request,
99
- })
100
-
101
- if (response.error || !response.data) {
102
- return {
103
- columns: [],
104
- rows: [],
105
- rowCount: 0,
106
- executionTimeMs: 0,
107
- success: false,
108
- error: `Query failed: ${response.error}`,
109
- }
110
- }
111
-
112
- const result = response.data as any
113
-
114
- return {
115
- columns: result.columns || [],
116
- rows: result.rows || [],
117
- rowCount: result.rows?.length || 0,
118
- executionTimeMs: result.execution_time_ms || 0,
119
- success: true,
120
- }
121
- } catch (error) {
122
- return {
123
- columns: [],
124
- rows: [],
125
- rowCount: 0,
126
- executionTimeMs: 0,
127
- success: false,
128
- error: error instanceof Error ? error.message : String(error),
129
- }
130
- }
131
- }
132
- }
@@ -1,102 +0,0 @@
1
- import type { BulkDocumentUploadResponse, DocumentDetailResponse, DocumentListResponse, DocumentSection, DocumentUploadResponse, SearchResponse } from '../sdk/types.gen';
2
- export interface DocumentSearchOptions {
3
- /** Filter by source type (xbrl_textblock, narrative_section, ixbrl_disclosure, uploaded_doc, memory) */
4
- sourceType?: string;
5
- /** Filter by ticker, CIK, or entity name */
6
- entity?: string;
7
- /** Filter by SEC form type (10-K, 10-Q) */
8
- formType?: string;
9
- /** Filter by section ID (item_1, item_1a, item_7, etc.) */
10
- section?: string;
11
- /** Filter by XBRL element qname (e.g., us-gaap:Goodwill) */
12
- element?: string;
13
- /** Filter by fiscal year */
14
- fiscalYear?: number;
15
- /** Filter filings on or after date (YYYY-MM-DD) */
16
- dateFrom?: string;
17
- /** Filter filings on or before date (YYYY-MM-DD) */
18
- dateTo?: string;
19
- /** Max results to return (default: 10) */
20
- size?: number;
21
- /** Pagination offset */
22
- offset?: number;
23
- }
24
- export interface DocumentUploadOptions {
25
- /** Optional tags for filtering */
26
- tags?: string[];
27
- /** Optional folder/category */
28
- folder?: string;
29
- /** Optional external ID for upsert behavior */
30
- externalId?: string;
31
- }
32
- export interface DocumentUpdateOptions {
33
- /** Updated title */
34
- title?: string;
35
- /** Updated markdown content */
36
- content?: string;
37
- /** Updated tags (null to clear) */
38
- tags?: string[] | null;
39
- /** Updated folder (null to clear) */
40
- folder?: string | null;
41
- }
42
- export declare class DocumentClient {
43
- private config;
44
- constructor(config: {
45
- baseUrl: string;
46
- credentials?: 'include' | 'same-origin' | 'omit';
47
- headers?: Record<string, string>;
48
- token?: string;
49
- });
50
- /**
51
- * Upload a markdown document for text indexing.
52
- *
53
- * The document is sectioned on headings, embedded, and indexed
54
- * into OpenSearch for full-text and semantic search.
55
- */
56
- upload(graphId: string, title: string, content: string, options?: DocumentUploadOptions): Promise<DocumentUploadResponse>;
57
- /**
58
- * Get a document with full content by ID.
59
- *
60
- * Returns the raw markdown content and metadata from PostgreSQL.
61
- *
62
- * @returns DocumentDetailResponse or null if not found.
63
- */
64
- get(graphId: string, documentId: string): Promise<DocumentDetailResponse | null>;
65
- /**
66
- * Update a document's content and/or metadata.
67
- *
68
- * Only provided fields are updated. Content is re-sectioned,
69
- * re-embedded, and re-indexed in OpenSearch.
70
- */
71
- update(graphId: string, documentId: string, options: DocumentUpdateOptions): Promise<DocumentUploadResponse>;
72
- /**
73
- * Upload multiple markdown documents (max 50 per request).
74
- */
75
- uploadBulk(graphId: string, documents: Array<{
76
- title: string;
77
- content: string;
78
- tags?: string[];
79
- folder?: string;
80
- externalId?: string;
81
- }>): Promise<BulkDocumentUploadResponse>;
82
- /**
83
- * Search documents with hybrid (BM25 + kNN) search.
84
- */
85
- search(graphId: string, query: string, options?: DocumentSearchOptions): Promise<SearchResponse>;
86
- /**
87
- * Retrieve the full text of a document section by ID.
88
- *
89
- * @returns DocumentSection or null if not found.
90
- */
91
- getSection(graphId: string, documentId: string): Promise<DocumentSection | null>;
92
- /**
93
- * List indexed documents for a graph.
94
- */
95
- list(graphId: string, sourceType?: string): Promise<DocumentListResponse>;
96
- /**
97
- * Delete a document and all its sections.
98
- *
99
- * @returns true if deleted, false if not found.
100
- */
101
- delete(graphId: string, documentId: string): Promise<boolean>;
102
- }