@robosystems/client 0.2.37 → 0.2.39

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.
@@ -0,0 +1,77 @@
1
+ import type { BulkDocumentUploadResponse, 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 declare class DocumentClient {
33
+ private config;
34
+ constructor(config: {
35
+ baseUrl: string;
36
+ credentials?: 'include' | 'same-origin' | 'omit';
37
+ headers?: Record<string, string>;
38
+ token?: string;
39
+ });
40
+ /**
41
+ * Upload a markdown document for text indexing.
42
+ *
43
+ * The document is sectioned on headings, embedded, and indexed
44
+ * into OpenSearch for full-text and semantic search.
45
+ */
46
+ upload(graphId: string, title: string, content: string, options?: DocumentUploadOptions): Promise<DocumentUploadResponse>;
47
+ /**
48
+ * Upload multiple markdown documents (max 50 per request).
49
+ */
50
+ uploadBulk(graphId: string, documents: Array<{
51
+ title: string;
52
+ content: string;
53
+ tags?: string[];
54
+ folder?: string;
55
+ externalId?: string;
56
+ }>): Promise<BulkDocumentUploadResponse>;
57
+ /**
58
+ * Search documents with hybrid (BM25 + kNN) search.
59
+ */
60
+ search(graphId: string, query: string, options?: DocumentSearchOptions): Promise<SearchResponse>;
61
+ /**
62
+ * Retrieve the full text of a document section by ID.
63
+ *
64
+ * @returns DocumentSection or null if not found.
65
+ */
66
+ getSection(graphId: string, documentId: string): Promise<DocumentSection | null>;
67
+ /**
68
+ * List indexed documents for a graph.
69
+ */
70
+ list(graphId: string, sourceType?: string): Promise<DocumentListResponse>;
71
+ /**
72
+ * Delete a document and all its sections.
73
+ *
74
+ * @returns true if deleted, false if not found.
75
+ */
76
+ delete(graphId: string, documentId: string): Promise<boolean>;
77
+ }
@@ -0,0 +1,136 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.DocumentClient = void 0;
5
+ /**
6
+ * Document Client for RoboSystems API
7
+ *
8
+ * Upload, search, list, and delete text documents indexed in OpenSearch.
9
+ * Documents are sectioned on markdown headings, embedded for semantic search,
10
+ * and searchable alongside structured graph data.
11
+ */
12
+ const sdk_gen_1 = require("../sdk/sdk.gen");
13
+ class DocumentClient {
14
+ constructor(config) {
15
+ this.config = config;
16
+ }
17
+ /**
18
+ * Upload a markdown document for text indexing.
19
+ *
20
+ * The document is sectioned on headings, embedded, and indexed
21
+ * into OpenSearch for full-text and semantic search.
22
+ */
23
+ async upload(graphId, title, content, options = {}) {
24
+ const response = await (0, sdk_gen_1.uploadDocument)({
25
+ path: { graph_id: graphId },
26
+ body: {
27
+ title,
28
+ content,
29
+ tags: options.tags ?? null,
30
+ folder: options.folder ?? null,
31
+ external_id: options.externalId ?? null,
32
+ },
33
+ });
34
+ if (response.error) {
35
+ throw new Error(`Document upload failed: ${JSON.stringify(response.error)}`);
36
+ }
37
+ return response.data;
38
+ }
39
+ /**
40
+ * Upload multiple markdown documents (max 50 per request).
41
+ */
42
+ async uploadBulk(graphId, documents) {
43
+ const response = await (0, sdk_gen_1.uploadDocumentsBulk)({
44
+ path: { graph_id: graphId },
45
+ body: {
46
+ documents: documents.map((doc) => ({
47
+ title: doc.title,
48
+ content: doc.content,
49
+ tags: doc.tags ?? null,
50
+ folder: doc.folder ?? null,
51
+ external_id: doc.externalId ?? null,
52
+ })),
53
+ },
54
+ });
55
+ if (response.error) {
56
+ throw new Error(`Bulk upload failed: ${JSON.stringify(response.error)}`);
57
+ }
58
+ return response.data;
59
+ }
60
+ /**
61
+ * Search documents with hybrid (BM25 + kNN) search.
62
+ */
63
+ async search(graphId, query, options = {}) {
64
+ const response = await (0, sdk_gen_1.searchDocuments)({
65
+ path: { graph_id: graphId },
66
+ body: {
67
+ query,
68
+ source_type: options.sourceType ?? null,
69
+ entity: options.entity ?? null,
70
+ form_type: options.formType ?? null,
71
+ section: options.section ?? null,
72
+ element: options.element ?? null,
73
+ fiscal_year: options.fiscalYear ?? null,
74
+ date_from: options.dateFrom ?? null,
75
+ date_to: options.dateTo ?? null,
76
+ size: options.size,
77
+ offset: options.offset,
78
+ },
79
+ });
80
+ if (response.error) {
81
+ throw new Error(`Document search failed: ${JSON.stringify(response.error)}`);
82
+ }
83
+ return response.data;
84
+ }
85
+ /**
86
+ * Retrieve the full text of a document section by ID.
87
+ *
88
+ * @returns DocumentSection or null if not found.
89
+ */
90
+ async getSection(graphId, documentId) {
91
+ const response = await (0, sdk_gen_1.getDocumentSection)({
92
+ path: { graph_id: graphId, document_id: documentId },
93
+ });
94
+ if (response.response.status === 404) {
95
+ return null;
96
+ }
97
+ if (response.error) {
98
+ throw new Error(`Get section failed: ${JSON.stringify(response.error)}`);
99
+ }
100
+ return response.data;
101
+ }
102
+ /**
103
+ * List indexed documents for a graph.
104
+ */
105
+ async list(graphId, sourceType) {
106
+ const response = await (0, sdk_gen_1.listDocuments)({
107
+ path: { graph_id: graphId },
108
+ query: sourceType ? { source_type: sourceType } : undefined,
109
+ });
110
+ if (response.error) {
111
+ throw new Error(`List documents failed: ${JSON.stringify(response.error)}`);
112
+ }
113
+ return response.data;
114
+ }
115
+ /**
116
+ * Delete a document and all its sections.
117
+ *
118
+ * @returns true if deleted, false if not found.
119
+ */
120
+ async delete(graphId, documentId) {
121
+ const response = await (0, sdk_gen_1.deleteDocument)({
122
+ path: { graph_id: graphId, document_id: documentId },
123
+ });
124
+ if (response.response.status === 204) {
125
+ return true;
126
+ }
127
+ if (response.response.status === 404) {
128
+ return false;
129
+ }
130
+ if (response.error) {
131
+ throw new Error(`Delete document failed: ${JSON.stringify(response.error)}`);
132
+ }
133
+ return true;
134
+ }
135
+ }
136
+ exports.DocumentClient = DocumentClient;
@@ -0,0 +1,232 @@
1
+ 'use client'
2
+
3
+ /**
4
+ * Document Client for RoboSystems API
5
+ *
6
+ * Upload, search, list, and delete text documents indexed in OpenSearch.
7
+ * Documents are sectioned on markdown headings, embedded for semantic search,
8
+ * and searchable alongside structured graph data.
9
+ */
10
+
11
+ import {
12
+ deleteDocument,
13
+ getDocumentSection,
14
+ listDocuments,
15
+ searchDocuments,
16
+ uploadDocument,
17
+ uploadDocumentsBulk,
18
+ } from '../sdk/sdk.gen'
19
+ import type {
20
+ BulkDocumentUploadResponse,
21
+ DocumentListResponse,
22
+ DocumentSection,
23
+ DocumentUploadResponse,
24
+ SearchResponse,
25
+ } from '../sdk/types.gen'
26
+
27
+ export interface DocumentSearchOptions {
28
+ /** Filter by source type (xbrl_textblock, narrative_section, ixbrl_disclosure, uploaded_doc, memory) */
29
+ sourceType?: string
30
+ /** Filter by ticker, CIK, or entity name */
31
+ entity?: string
32
+ /** Filter by SEC form type (10-K, 10-Q) */
33
+ formType?: string
34
+ /** Filter by section ID (item_1, item_1a, item_7, etc.) */
35
+ section?: string
36
+ /** Filter by XBRL element qname (e.g., us-gaap:Goodwill) */
37
+ element?: string
38
+ /** Filter by fiscal year */
39
+ fiscalYear?: number
40
+ /** Filter filings on or after date (YYYY-MM-DD) */
41
+ dateFrom?: string
42
+ /** Filter filings on or before date (YYYY-MM-DD) */
43
+ dateTo?: string
44
+ /** Max results to return (default: 10) */
45
+ size?: number
46
+ /** Pagination offset */
47
+ offset?: number
48
+ }
49
+
50
+ export interface DocumentUploadOptions {
51
+ /** Optional tags for filtering */
52
+ tags?: string[]
53
+ /** Optional folder/category */
54
+ folder?: string
55
+ /** Optional external ID for upsert behavior */
56
+ externalId?: string
57
+ }
58
+
59
+ export class DocumentClient {
60
+ private config: {
61
+ baseUrl: string
62
+ credentials?: 'include' | 'same-origin' | 'omit'
63
+ headers?: Record<string, string>
64
+ token?: string
65
+ }
66
+
67
+ constructor(config: {
68
+ baseUrl: string
69
+ credentials?: 'include' | 'same-origin' | 'omit'
70
+ headers?: Record<string, string>
71
+ token?: string
72
+ }) {
73
+ this.config = config
74
+ }
75
+
76
+ /**
77
+ * Upload a markdown document for text indexing.
78
+ *
79
+ * The document is sectioned on headings, embedded, and indexed
80
+ * into OpenSearch for full-text and semantic search.
81
+ */
82
+ async upload(
83
+ graphId: string,
84
+ title: string,
85
+ content: string,
86
+ options: DocumentUploadOptions = {}
87
+ ): Promise<DocumentUploadResponse> {
88
+ const response = await uploadDocument({
89
+ path: { graph_id: graphId },
90
+ body: {
91
+ title,
92
+ content,
93
+ tags: options.tags ?? null,
94
+ folder: options.folder ?? null,
95
+ external_id: options.externalId ?? null,
96
+ },
97
+ })
98
+
99
+ if (response.error) {
100
+ throw new Error(`Document upload failed: ${JSON.stringify(response.error)}`)
101
+ }
102
+
103
+ return response.data as DocumentUploadResponse
104
+ }
105
+
106
+ /**
107
+ * Upload multiple markdown documents (max 50 per request).
108
+ */
109
+ async uploadBulk(
110
+ graphId: string,
111
+ documents: Array<{
112
+ title: string
113
+ content: string
114
+ tags?: string[]
115
+ folder?: string
116
+ externalId?: string
117
+ }>
118
+ ): Promise<BulkDocumentUploadResponse> {
119
+ const response = await uploadDocumentsBulk({
120
+ path: { graph_id: graphId },
121
+ body: {
122
+ documents: documents.map((doc) => ({
123
+ title: doc.title,
124
+ content: doc.content,
125
+ tags: doc.tags ?? null,
126
+ folder: doc.folder ?? null,
127
+ external_id: doc.externalId ?? null,
128
+ })),
129
+ },
130
+ })
131
+
132
+ if (response.error) {
133
+ throw new Error(`Bulk upload failed: ${JSON.stringify(response.error)}`)
134
+ }
135
+
136
+ return response.data as BulkDocumentUploadResponse
137
+ }
138
+
139
+ /**
140
+ * Search documents with hybrid (BM25 + kNN) search.
141
+ */
142
+ async search(
143
+ graphId: string,
144
+ query: string,
145
+ options: DocumentSearchOptions = {}
146
+ ): Promise<SearchResponse> {
147
+ const response = await searchDocuments({
148
+ path: { graph_id: graphId },
149
+ body: {
150
+ query,
151
+ source_type: options.sourceType ?? null,
152
+ entity: options.entity ?? null,
153
+ form_type: options.formType ?? null,
154
+ section: options.section ?? null,
155
+ element: options.element ?? null,
156
+ fiscal_year: options.fiscalYear ?? null,
157
+ date_from: options.dateFrom ?? null,
158
+ date_to: options.dateTo ?? null,
159
+ size: options.size,
160
+ offset: options.offset,
161
+ },
162
+ })
163
+
164
+ if (response.error) {
165
+ throw new Error(`Document search failed: ${JSON.stringify(response.error)}`)
166
+ }
167
+
168
+ return response.data as SearchResponse
169
+ }
170
+
171
+ /**
172
+ * Retrieve the full text of a document section by ID.
173
+ *
174
+ * @returns DocumentSection or null if not found.
175
+ */
176
+ async getSection(graphId: string, documentId: string): Promise<DocumentSection | null> {
177
+ const response = await getDocumentSection({
178
+ path: { graph_id: graphId, document_id: documentId },
179
+ })
180
+
181
+ if (response.response.status === 404) {
182
+ return null
183
+ }
184
+
185
+ if (response.error) {
186
+ throw new Error(`Get section failed: ${JSON.stringify(response.error)}`)
187
+ }
188
+
189
+ return response.data as DocumentSection
190
+ }
191
+
192
+ /**
193
+ * List indexed documents for a graph.
194
+ */
195
+ async list(graphId: string, sourceType?: string): Promise<DocumentListResponse> {
196
+ const response = await listDocuments({
197
+ path: { graph_id: graphId },
198
+ query: sourceType ? { source_type: sourceType } : undefined,
199
+ })
200
+
201
+ if (response.error) {
202
+ throw new Error(`List documents failed: ${JSON.stringify(response.error)}`)
203
+ }
204
+
205
+ return response.data as DocumentListResponse
206
+ }
207
+
208
+ /**
209
+ * Delete a document and all its sections.
210
+ *
211
+ * @returns true if deleted, false if not found.
212
+ */
213
+ async delete(graphId: string, documentId: string): Promise<boolean> {
214
+ const response = await deleteDocument({
215
+ path: { graph_id: graphId, document_id: documentId },
216
+ })
217
+
218
+ if (response.response.status === 204) {
219
+ return true
220
+ }
221
+
222
+ if (response.response.status === 404) {
223
+ return false
224
+ }
225
+
226
+ if (response.error) {
227
+ throw new Error(`Delete document failed: ${JSON.stringify(response.error)}`)
228
+ }
229
+
230
+ return true
231
+ }
232
+ }
@@ -10,6 +10,7 @@ import { FileClient } from './FileClient';
10
10
  import { MaterializationClient } from './MaterializationClient';
11
11
  import { TableClient } from './TableClient';
12
12
  import { GraphClient } from './GraphClient';
13
+ import { DocumentClient } from './DocumentClient';
13
14
  export interface RoboSystemsExtensionConfig {
14
15
  baseUrl?: string;
15
16
  credentials?: 'include' | 'same-origin' | 'omit';
@@ -27,6 +28,7 @@ export declare class RoboSystemsExtensions {
27
28
  readonly materialization: MaterializationClient;
28
29
  readonly tables: TableClient;
29
30
  readonly graphs: GraphClient;
31
+ readonly documents: DocumentClient;
30
32
  private config;
31
33
  constructor(config?: RoboSystemsExtensionConfig);
32
34
  /**
@@ -49,10 +51,11 @@ export * from './SSEClient';
49
51
  export * from './FileClient';
50
52
  export * from './MaterializationClient';
51
53
  export * from './GraphClient';
54
+ export * from './DocumentClient';
52
55
  export * from './config';
53
56
  export type { TableInfo, TableQueryResult } from './TableClient';
54
57
  export { TableClient } from './TableClient';
55
- export { OperationClient, QueryClient, AgentClient, SSEClient, FileClient, MaterializationClient, GraphClient, };
58
+ export { OperationClient, QueryClient, AgentClient, SSEClient, FileClient, MaterializationClient, GraphClient, DocumentClient, };
56
59
  export { useMultipleOperations, useOperation, useQuery, useSDKClients, useStreamingQuery, useTableUpload, } from './hooks';
57
60
  export declare const extensions: {
58
61
  readonly query: QueryClient;
@@ -62,6 +65,7 @@ export declare const extensions: {
62
65
  readonly materialization: MaterializationClient;
63
66
  readonly tables: TableClient;
64
67
  readonly graphs: GraphClient;
68
+ readonly documents: DocumentClient;
65
69
  monitorOperation: (operationId: string, onProgress?: (progress: any) => void) => Promise<any>;
66
70
  createSSEClient: () => SSEClient;
67
71
  close: () => void;
@@ -18,7 +18,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
18
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.analyzeFinancials = exports.agentQuery = exports.streamQuery = exports.executeQuery = exports.monitorOperation = exports.extensions = exports.useTableUpload = exports.useStreamingQuery = exports.useSDKClients = exports.useQuery = exports.useOperation = exports.useMultipleOperations = exports.GraphClient = exports.MaterializationClient = exports.FileClient = exports.SSEClient = exports.AgentClient = exports.QueryClient = exports.OperationClient = exports.TableClient = exports.RoboSystemsExtensions = void 0;
21
+ exports.analyzeFinancials = exports.agentQuery = exports.streamQuery = exports.executeQuery = exports.monitorOperation = exports.extensions = exports.useTableUpload = exports.useStreamingQuery = exports.useSDKClients = exports.useQuery = exports.useOperation = exports.useMultipleOperations = exports.DocumentClient = exports.GraphClient = exports.MaterializationClient = exports.FileClient = exports.SSEClient = exports.AgentClient = exports.QueryClient = exports.OperationClient = exports.TableClient = exports.RoboSystemsExtensions = void 0;
22
22
  const client_gen_1 = require("../sdk/client.gen");
23
23
  const config_1 = require("./config");
24
24
  const OperationClient_1 = require("./OperationClient");
@@ -36,6 +36,8 @@ Object.defineProperty(exports, "MaterializationClient", { enumerable: true, get:
36
36
  const TableClient_1 = require("./TableClient");
37
37
  const GraphClient_1 = require("./GraphClient");
38
38
  Object.defineProperty(exports, "GraphClient", { enumerable: true, get: function () { return GraphClient_1.GraphClient; } });
39
+ const DocumentClient_1 = require("./DocumentClient");
40
+ Object.defineProperty(exports, "DocumentClient", { enumerable: true, get: function () { return DocumentClient_1.DocumentClient; } });
39
41
  class RoboSystemsExtensions {
40
42
  constructor(config = {}) {
41
43
  // Get base URL from SDK client config or use provided/default
@@ -95,6 +97,12 @@ class RoboSystemsExtensions {
95
97
  token: this.config.token,
96
98
  headers: this.config.headers,
97
99
  });
100
+ this.documents = new DocumentClient_1.DocumentClient({
101
+ baseUrl: this.config.baseUrl,
102
+ credentials: this.config.credentials,
103
+ token: this.config.token,
104
+ headers: this.config.headers,
105
+ });
98
106
  }
99
107
  /**
100
108
  * Convenience method to monitor any operation
@@ -134,6 +142,7 @@ __exportStar(require("./SSEClient"), exports);
134
142
  __exportStar(require("./FileClient"), exports);
135
143
  __exportStar(require("./MaterializationClient"), exports);
136
144
  __exportStar(require("./GraphClient"), exports);
145
+ __exportStar(require("./DocumentClient"), exports);
137
146
  __exportStar(require("./config"), exports);
138
147
  var TableClient_2 = require("./TableClient");
139
148
  Object.defineProperty(exports, "TableClient", { enumerable: true, get: function () { return TableClient_2.TableClient; } });
@@ -175,6 +184,9 @@ exports.extensions = {
175
184
  get graphs() {
176
185
  return getExtensions().graphs;
177
186
  },
187
+ get documents() {
188
+ return getExtensions().documents;
189
+ },
178
190
  monitorOperation: (operationId, onProgress) => getExtensions().monitorOperation(operationId, onProgress),
179
191
  createSSEClient: () => getExtensions().createSSEClient(),
180
192
  close: () => getExtensions().close(),
@@ -13,6 +13,7 @@ import { FileClient } from './FileClient'
13
13
  import { MaterializationClient } from './MaterializationClient'
14
14
  import { TableClient } from './TableClient'
15
15
  import { GraphClient } from './GraphClient'
16
+ import { DocumentClient } from './DocumentClient'
16
17
 
17
18
  export interface RoboSystemsExtensionConfig {
18
19
  baseUrl?: string
@@ -43,6 +44,7 @@ export class RoboSystemsExtensions {
43
44
  public readonly materialization: MaterializationClient
44
45
  public readonly tables: TableClient
45
46
  public readonly graphs: GraphClient
47
+ public readonly documents: DocumentClient
46
48
  private config: ResolvedConfig
47
49
 
48
50
  constructor(config: RoboSystemsExtensionConfig = {}) {
@@ -112,6 +114,13 @@ export class RoboSystemsExtensions {
112
114
  token: this.config.token,
113
115
  headers: this.config.headers,
114
116
  })
117
+
118
+ this.documents = new DocumentClient({
119
+ baseUrl: this.config.baseUrl,
120
+ credentials: this.config.credentials,
121
+ token: this.config.token,
122
+ headers: this.config.headers,
123
+ })
115
124
  }
116
125
 
117
126
  /**
@@ -154,6 +163,7 @@ export * from './SSEClient'
154
163
  export * from './FileClient'
155
164
  export * from './MaterializationClient'
156
165
  export * from './GraphClient'
166
+ export * from './DocumentClient'
157
167
  export * from './config'
158
168
 
159
169
  // Export TableClient types individually to avoid conflicts with QueryClient's QueryResult
@@ -168,6 +178,7 @@ export {
168
178
  FileClient,
169
179
  MaterializationClient,
170
180
  GraphClient,
181
+ DocumentClient,
171
182
  }
172
183
 
173
184
  // Export React hooks
@@ -212,6 +223,9 @@ export const extensions = {
212
223
  get graphs() {
213
224
  return getExtensions().graphs
214
225
  },
226
+ get documents() {
227
+ return getExtensions().documents
228
+ },
215
229
  monitorOperation: (operationId: string, onProgress?: (progress: any) => void) =>
216
230
  getExtensions().monitorOperation(operationId, onProgress),
217
231
  createSSEClient: () => getExtensions().createSSEClient(),