@robosystems/client 0.2.20 → 0.2.22

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.
@@ -1,6 +1,5 @@
1
1
  export interface FileUploadOptions {
2
2
  onProgress?: (message: string) => void;
3
- fixLocalStackUrl?: boolean;
4
3
  fileName?: string;
5
4
  ingestToGraph?: boolean;
6
5
  }
@@ -30,6 +29,7 @@ export declare class FileClient {
30
29
  credentials?: 'include' | 'same-origin' | 'omit';
31
30
  headers?: Record<string, string>;
32
31
  token?: string;
32
+ s3EndpointUrl?: string;
33
33
  });
34
34
  /**
35
35
  * Upload a Parquet file to staging
@@ -48,8 +48,14 @@ class FileClient {
48
48
  const uploadData = uploadUrlResponse.data;
49
49
  let uploadUrl = uploadData.upload_url;
50
50
  const fileId = uploadData.file_id;
51
- if (options.fixLocalStackUrl && uploadUrl.includes('localstack:4566')) {
52
- uploadUrl = uploadUrl.replace('localstack:4566', 'localhost:4566');
51
+ // Override S3 endpoint if configured (e.g., for LocalStack)
52
+ if (this.config.s3EndpointUrl) {
53
+ const originalUrl = new URL(uploadUrl);
54
+ const overrideUrl = new URL(this.config.s3EndpointUrl);
55
+ // Replace scheme, host, and port with the override endpoint
56
+ originalUrl.protocol = overrideUrl.protocol;
57
+ originalUrl.host = overrideUrl.host;
58
+ uploadUrl = originalUrl.toString();
53
59
  }
54
60
  options.onProgress?.(`Uploading ${fileName} to S3...`);
55
61
  const fileContent = await this.getFileContent(fileOrBuffer);
@@ -12,7 +12,6 @@ import type { FileStatusUpdate, FileUploadRequest, FileUploadResponse } from '..
12
12
 
13
13
  export interface FileUploadOptions {
14
14
  onProgress?: (message: string) => void
15
- fixLocalStackUrl?: boolean
16
15
  fileName?: string
17
16
  ingestToGraph?: boolean
18
17
  }
@@ -45,6 +44,7 @@ export class FileClient {
45
44
  credentials?: 'include' | 'same-origin' | 'omit'
46
45
  headers?: Record<string, string>
47
46
  token?: string
47
+ s3EndpointUrl?: string // Override S3 endpoint (e.g., for LocalStack)
48
48
  }
49
49
 
50
50
  constructor(config: {
@@ -52,6 +52,7 @@ export class FileClient {
52
52
  credentials?: 'include' | 'same-origin' | 'omit'
53
53
  headers?: Record<string, string>
54
54
  token?: string
55
+ s3EndpointUrl?: string
55
56
  }) {
56
57
  this.config = config
57
58
  }
@@ -102,8 +103,14 @@ export class FileClient {
102
103
  let uploadUrl = uploadData.upload_url
103
104
  const fileId = uploadData.file_id
104
105
 
105
- if (options.fixLocalStackUrl && uploadUrl.includes('localstack:4566')) {
106
- uploadUrl = uploadUrl.replace('localstack:4566', 'localhost:4566')
106
+ // Override S3 endpoint if configured (e.g., for LocalStack)
107
+ if (this.config.s3EndpointUrl) {
108
+ const originalUrl = new URL(uploadUrl)
109
+ const overrideUrl = new URL(this.config.s3EndpointUrl)
110
+ // Replace scheme, host, and port with the override endpoint
111
+ originalUrl.protocol = overrideUrl.protocol
112
+ originalUrl.host = overrideUrl.host
113
+ uploadUrl = originalUrl.toString()
107
114
  }
108
115
 
109
116
  options.onProgress?.(`Uploading ${fileName} to S3...`)
@@ -121,7 +121,6 @@ export declare function useSDKClients(): {
121
121
  * const handleFileUpload = async (file: File) => {
122
122
  * const result = await upload('Entity', file, {
123
123
  * onProgress: (msg) => console.log(msg),
124
- * fixLocalStackUrl: true,
125
124
  * })
126
125
  *
127
126
  * if (result?.success) {
@@ -129,6 +128,15 @@ export declare function useSDKClients(): {
129
128
  * }
130
129
  * }
131
130
  * ```
131
+ *
132
+ * @remarks
133
+ * For local development with LocalStack, configure s3EndpointUrl when initializing RoboSystemsExtensions:
134
+ * ```tsx
135
+ * const extensions = new RoboSystemsExtensions({
136
+ * baseUrl: 'http://localhost:8000',
137
+ * s3EndpointUrl: 'http://localhost:4566', // LocalStack endpoint
138
+ * })
139
+ * ```
132
140
  */
133
141
  export declare function useTableUpload(graphId: string): {
134
142
  upload: (tableName: string, fileOrBuffer: FileInput, options?: FileUploadOptions) => Promise<FileUploadResult | null>;
@@ -396,7 +396,6 @@ function useSDKClients() {
396
396
  * const handleFileUpload = async (file: File) => {
397
397
  * const result = await upload('Entity', file, {
398
398
  * onProgress: (msg) => console.log(msg),
399
- * fixLocalStackUrl: true,
400
399
  * })
401
400
  *
402
401
  * if (result?.success) {
@@ -404,6 +403,15 @@ function useSDKClients() {
404
403
  * }
405
404
  * }
406
405
  * ```
406
+ *
407
+ * @remarks
408
+ * For local development with LocalStack, configure s3EndpointUrl when initializing RoboSystemsExtensions:
409
+ * ```tsx
410
+ * const extensions = new RoboSystemsExtensions({
411
+ * baseUrl: 'http://localhost:8000',
412
+ * s3EndpointUrl: 'http://localhost:4566', // LocalStack endpoint
413
+ * })
414
+ * ```
407
415
  */
408
416
  function useTableUpload(graphId) {
409
417
  const [loading, setLoading] = (0, react_1.useState)(false);
@@ -474,7 +474,6 @@ export function useSDKClients() {
474
474
  * const handleFileUpload = async (file: File) => {
475
475
  * const result = await upload('Entity', file, {
476
476
  * onProgress: (msg) => console.log(msg),
477
- * fixLocalStackUrl: true,
478
477
  * })
479
478
  *
480
479
  * if (result?.success) {
@@ -482,6 +481,15 @@ export function useSDKClients() {
482
481
  * }
483
482
  * }
484
483
  * ```
484
+ *
485
+ * @remarks
486
+ * For local development with LocalStack, configure s3EndpointUrl when initializing RoboSystemsExtensions:
487
+ * ```tsx
488
+ * const extensions = new RoboSystemsExtensions({
489
+ * baseUrl: 'http://localhost:8000',
490
+ * s3EndpointUrl: 'http://localhost:4566', // LocalStack endpoint
491
+ * })
492
+ * ```
485
493
  */
486
494
  export function useTableUpload(graphId: string) {
487
495
  const [loading, setLoading] = useState(false)
@@ -17,6 +17,7 @@ export interface RoboSystemsExtensionConfig {
17
17
  headers?: Record<string, string>;
18
18
  maxRetries?: number;
19
19
  retryDelay?: number;
20
+ s3EndpointUrl?: string;
20
21
  }
21
22
  export declare class RoboSystemsExtensions {
22
23
  readonly query: QueryClient;
@@ -49,6 +49,7 @@ class RoboSystemsExtensions {
49
49
  headers: config.headers,
50
50
  maxRetries: config.maxRetries || 5,
51
51
  retryDelay: config.retryDelay || 1000,
52
+ s3EndpointUrl: config.s3EndpointUrl,
52
53
  };
53
54
  this.query = new QueryClient_1.QueryClient({
54
55
  baseUrl: this.config.baseUrl,
@@ -74,6 +75,7 @@ class RoboSystemsExtensions {
74
75
  credentials: this.config.credentials,
75
76
  token: this.config.token,
76
77
  headers: this.config.headers,
78
+ s3EndpointUrl: this.config.s3EndpointUrl,
77
79
  });
78
80
  this.materialization = new MaterializationClient_1.MaterializationClient({
79
81
  baseUrl: this.config.baseUrl,
@@ -21,6 +21,7 @@ export interface RoboSystemsExtensionConfig {
21
21
  headers?: Record<string, string>
22
22
  maxRetries?: number
23
23
  retryDelay?: number
24
+ s3EndpointUrl?: string // Override S3 endpoint (e.g., for LocalStack)
24
25
  }
25
26
 
26
27
  // Properly typed configuration interface
@@ -31,6 +32,7 @@ interface ResolvedConfig {
31
32
  headers?: Record<string, string>
32
33
  maxRetries: number
33
34
  retryDelay: number
35
+ s3EndpointUrl?: string
34
36
  }
35
37
 
36
38
  export class RoboSystemsExtensions {
@@ -57,6 +59,7 @@ export class RoboSystemsExtensions {
57
59
  headers: config.headers,
58
60
  maxRetries: config.maxRetries || 5,
59
61
  retryDelay: config.retryDelay || 1000,
62
+ s3EndpointUrl: config.s3EndpointUrl,
60
63
  }
61
64
 
62
65
  this.query = new QueryClient({
@@ -86,6 +89,7 @@ export class RoboSystemsExtensions {
86
89
  credentials: this.config.credentials,
87
90
  token: this.config.token,
88
91
  headers: this.config.headers,
92
+ s3EndpointUrl: this.config.s3EndpointUrl,
89
93
  })
90
94
 
91
95
  this.materialization = new MaterializationClient({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robosystems/client",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
4
4
  "description": "TypeScript client library for RoboSystems Financial Knowledge Graph API",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,6 +1,5 @@
1
1
  export interface FileUploadOptions {
2
2
  onProgress?: (message: string) => void;
3
- fixLocalStackUrl?: boolean;
4
3
  fileName?: string;
5
4
  ingestToGraph?: boolean;
6
5
  }
@@ -30,6 +29,7 @@ export declare class FileClient {
30
29
  credentials?: 'include' | 'same-origin' | 'omit';
31
30
  headers?: Record<string, string>;
32
31
  token?: string;
32
+ s3EndpointUrl?: string;
33
33
  });
34
34
  /**
35
35
  * Upload a Parquet file to staging
@@ -48,8 +48,14 @@ class FileClient {
48
48
  const uploadData = uploadUrlResponse.data;
49
49
  let uploadUrl = uploadData.upload_url;
50
50
  const fileId = uploadData.file_id;
51
- if (options.fixLocalStackUrl && uploadUrl.includes('localstack:4566')) {
52
- uploadUrl = uploadUrl.replace('localstack:4566', 'localhost:4566');
51
+ // Override S3 endpoint if configured (e.g., for LocalStack)
52
+ if (this.config.s3EndpointUrl) {
53
+ const originalUrl = new URL(uploadUrl);
54
+ const overrideUrl = new URL(this.config.s3EndpointUrl);
55
+ // Replace scheme, host, and port with the override endpoint
56
+ originalUrl.protocol = overrideUrl.protocol;
57
+ originalUrl.host = overrideUrl.host;
58
+ uploadUrl = originalUrl.toString();
53
59
  }
54
60
  options.onProgress?.(`Uploading ${fileName} to S3...`);
55
61
  const fileContent = await this.getFileContent(fileOrBuffer);
@@ -12,7 +12,6 @@ import type { FileStatusUpdate, FileUploadRequest, FileUploadResponse } from '..
12
12
 
13
13
  export interface FileUploadOptions {
14
14
  onProgress?: (message: string) => void
15
- fixLocalStackUrl?: boolean
16
15
  fileName?: string
17
16
  ingestToGraph?: boolean
18
17
  }
@@ -45,6 +44,7 @@ export class FileClient {
45
44
  credentials?: 'include' | 'same-origin' | 'omit'
46
45
  headers?: Record<string, string>
47
46
  token?: string
47
+ s3EndpointUrl?: string // Override S3 endpoint (e.g., for LocalStack)
48
48
  }
49
49
 
50
50
  constructor(config: {
@@ -52,6 +52,7 @@ export class FileClient {
52
52
  credentials?: 'include' | 'same-origin' | 'omit'
53
53
  headers?: Record<string, string>
54
54
  token?: string
55
+ s3EndpointUrl?: string
55
56
  }) {
56
57
  this.config = config
57
58
  }
@@ -102,8 +103,14 @@ export class FileClient {
102
103
  let uploadUrl = uploadData.upload_url
103
104
  const fileId = uploadData.file_id
104
105
 
105
- if (options.fixLocalStackUrl && uploadUrl.includes('localstack:4566')) {
106
- uploadUrl = uploadUrl.replace('localstack:4566', 'localhost:4566')
106
+ // Override S3 endpoint if configured (e.g., for LocalStack)
107
+ if (this.config.s3EndpointUrl) {
108
+ const originalUrl = new URL(uploadUrl)
109
+ const overrideUrl = new URL(this.config.s3EndpointUrl)
110
+ // Replace scheme, host, and port with the override endpoint
111
+ originalUrl.protocol = overrideUrl.protocol
112
+ originalUrl.host = overrideUrl.host
113
+ uploadUrl = originalUrl.toString()
107
114
  }
108
115
 
109
116
  options.onProgress?.(`Uploading ${fileName} to S3...`)
@@ -114,7 +114,6 @@ const result = await tableClient.uploadParquetFile(
114
114
  onProgress: (message) => {
115
115
  console.log(`Upload progress: ${message}`)
116
116
  },
117
- fixLocalStackUrl: true, // Auto-fix for local development
118
117
  }
119
118
  )
120
119
 
@@ -248,7 +247,6 @@ import { readFileSync } from 'fs'
248
247
  const fileBuffer = readFileSync('data/entities.parquet')
249
248
  const result = await tableClient.uploadParquetFile('graph-id', 'Entity', Buffer.from(fileBuffer), {
250
249
  onProgress: (msg) => console.log(msg),
251
- fixLocalStackUrl: true, // Auto-fix for local development
252
250
  })
253
251
 
254
252
  if (result.success) {
@@ -673,14 +671,15 @@ NEXT_PUBLIC_PREFER_STREAMING=true
673
671
  ### Custom Configuration
674
672
 
675
673
  ```typescript
676
- import { createSSEClient } from '@robosystems/client/extensions'
674
+ import { RoboSystemsExtensions } from '@robosystems/client/extensions'
677
675
 
678
- const sseClient = createSSEClient({
676
+ const extensions = new RoboSystemsExtensions({
679
677
  // API Configuration
680
678
  baseUrl: process.env.NEXT_PUBLIC_ROBOSYSTEMS_API_URL,
681
679
 
682
680
  // Authentication
683
681
  credentials: 'include', // For cookies
682
+ token: 'your-jwt-token', // Or use JWT token
684
683
  headers: {
685
684
  'X-API-Key': process.env.ROBOSYSTEMS_API_KEY,
686
685
  },
@@ -688,12 +687,29 @@ const sseClient = createSSEClient({
688
687
  // Connection Settings
689
688
  maxRetries: 5,
690
689
  retryDelay: 1000,
691
- heartbeatInterval: 30000,
692
690
 
693
- // Advanced Options
694
- eventSourceOptions: {
695
- withCredentials: true,
696
- },
691
+ // S3 Configuration (for local development with LocalStack)
692
+ s3EndpointUrl: process.env.S3_ENDPOINT_URL, // e.g., 'http://localhost:4566'
693
+ })
694
+ ```
695
+
696
+ #### Local Development with LocalStack
697
+
698
+ For local development using LocalStack, configure the S3 endpoint URL:
699
+
700
+ ```typescript
701
+ import { RoboSystemsExtensions } from '@robosystems/client/extensions'
702
+
703
+ const extensions = new RoboSystemsExtensions({
704
+ baseUrl: 'http://localhost:8000',
705
+ credentials: 'include',
706
+ // Override S3 endpoint for LocalStack
707
+ s3EndpointUrl: 'http://localhost:4566',
708
+ })
709
+
710
+ // File uploads will now use LocalStack instead of AWS S3
711
+ const result = await extensions.files.upload('graph-id', 'TableName', fileBuffer, {
712
+ onProgress: (msg) => console.log(msg),
697
713
  })
698
714
  ```
699
715
 
@@ -121,7 +121,6 @@ export declare function useSDKClients(): {
121
121
  * const handleFileUpload = async (file: File) => {
122
122
  * const result = await upload('Entity', file, {
123
123
  * onProgress: (msg) => console.log(msg),
124
- * fixLocalStackUrl: true,
125
124
  * })
126
125
  *
127
126
  * if (result?.success) {
@@ -129,6 +128,15 @@ export declare function useSDKClients(): {
129
128
  * }
130
129
  * }
131
130
  * ```
131
+ *
132
+ * @remarks
133
+ * For local development with LocalStack, configure s3EndpointUrl when initializing RoboSystemsExtensions:
134
+ * ```tsx
135
+ * const extensions = new RoboSystemsExtensions({
136
+ * baseUrl: 'http://localhost:8000',
137
+ * s3EndpointUrl: 'http://localhost:4566', // LocalStack endpoint
138
+ * })
139
+ * ```
132
140
  */
133
141
  export declare function useTableUpload(graphId: string): {
134
142
  upload: (tableName: string, fileOrBuffer: FileInput, options?: FileUploadOptions) => Promise<FileUploadResult | null>;
@@ -396,7 +396,6 @@ function useSDKClients() {
396
396
  * const handleFileUpload = async (file: File) => {
397
397
  * const result = await upload('Entity', file, {
398
398
  * onProgress: (msg) => console.log(msg),
399
- * fixLocalStackUrl: true,
400
399
  * })
401
400
  *
402
401
  * if (result?.success) {
@@ -404,6 +403,15 @@ function useSDKClients() {
404
403
  * }
405
404
  * }
406
405
  * ```
406
+ *
407
+ * @remarks
408
+ * For local development with LocalStack, configure s3EndpointUrl when initializing RoboSystemsExtensions:
409
+ * ```tsx
410
+ * const extensions = new RoboSystemsExtensions({
411
+ * baseUrl: 'http://localhost:8000',
412
+ * s3EndpointUrl: 'http://localhost:4566', // LocalStack endpoint
413
+ * })
414
+ * ```
407
415
  */
408
416
  function useTableUpload(graphId) {
409
417
  const [loading, setLoading] = (0, react_1.useState)(false);
@@ -474,7 +474,6 @@ export function useSDKClients() {
474
474
  * const handleFileUpload = async (file: File) => {
475
475
  * const result = await upload('Entity', file, {
476
476
  * onProgress: (msg) => console.log(msg),
477
- * fixLocalStackUrl: true,
478
477
  * })
479
478
  *
480
479
  * if (result?.success) {
@@ -482,6 +481,15 @@ export function useSDKClients() {
482
481
  * }
483
482
  * }
484
483
  * ```
484
+ *
485
+ * @remarks
486
+ * For local development with LocalStack, configure s3EndpointUrl when initializing RoboSystemsExtensions:
487
+ * ```tsx
488
+ * const extensions = new RoboSystemsExtensions({
489
+ * baseUrl: 'http://localhost:8000',
490
+ * s3EndpointUrl: 'http://localhost:4566', // LocalStack endpoint
491
+ * })
492
+ * ```
485
493
  */
486
494
  export function useTableUpload(graphId: string) {
487
495
  const [loading, setLoading] = useState(false)
@@ -17,6 +17,7 @@ export interface RoboSystemsExtensionConfig {
17
17
  headers?: Record<string, string>;
18
18
  maxRetries?: number;
19
19
  retryDelay?: number;
20
+ s3EndpointUrl?: string;
20
21
  }
21
22
  export declare class RoboSystemsExtensions {
22
23
  readonly query: QueryClient;
@@ -49,6 +49,7 @@ class RoboSystemsExtensions {
49
49
  headers: config.headers,
50
50
  maxRetries: config.maxRetries || 5,
51
51
  retryDelay: config.retryDelay || 1000,
52
+ s3EndpointUrl: config.s3EndpointUrl,
52
53
  };
53
54
  this.query = new QueryClient_1.QueryClient({
54
55
  baseUrl: this.config.baseUrl,
@@ -74,6 +75,7 @@ class RoboSystemsExtensions {
74
75
  credentials: this.config.credentials,
75
76
  token: this.config.token,
76
77
  headers: this.config.headers,
78
+ s3EndpointUrl: this.config.s3EndpointUrl,
77
79
  });
78
80
  this.materialization = new MaterializationClient_1.MaterializationClient({
79
81
  baseUrl: this.config.baseUrl,
@@ -21,6 +21,7 @@ export interface RoboSystemsExtensionConfig {
21
21
  headers?: Record<string, string>
22
22
  maxRetries?: number
23
23
  retryDelay?: number
24
+ s3EndpointUrl?: string // Override S3 endpoint (e.g., for LocalStack)
24
25
  }
25
26
 
26
27
  // Properly typed configuration interface
@@ -31,6 +32,7 @@ interface ResolvedConfig {
31
32
  headers?: Record<string, string>
32
33
  maxRetries: number
33
34
  retryDelay: number
35
+ s3EndpointUrl?: string
34
36
  }
35
37
 
36
38
  export class RoboSystemsExtensions {
@@ -57,6 +59,7 @@ export class RoboSystemsExtensions {
57
59
  headers: config.headers,
58
60
  maxRetries: config.maxRetries || 5,
59
61
  retryDelay: config.retryDelay || 1000,
62
+ s3EndpointUrl: config.s3EndpointUrl,
60
63
  }
61
64
 
62
65
  this.query = new QueryClient({
@@ -86,6 +89,7 @@ export class RoboSystemsExtensions {
86
89
  credentials: this.config.credentials,
87
90
  token: this.config.token,
88
91
  headers: this.config.headers,
92
+ s3EndpointUrl: this.config.s3EndpointUrl,
89
93
  })
90
94
 
91
95
  this.materialization = new MaterializationClient({