@robosystems/client 0.1.11 → 0.1.13

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.
@@ -31,7 +31,7 @@ export function useQuery(graphId: string) {
31
31
  const [error, setError] = useState<Error | null>(null)
32
32
  const [data, setData] = useState<QueryResult | null>(null)
33
33
  const [queuePosition, setQueuePosition] = useState<number | null>(null)
34
- const clientRef = useRef<QueryClient>()
34
+ const clientRef = useRef<QueryClient>(null)
35
35
 
36
36
  // Initialize client
37
37
  useEffect(() => {
@@ -128,7 +128,7 @@ export function useStreamingQuery(graphId: string) {
128
128
  const [isStreaming, setIsStreaming] = useState(false)
129
129
  const [error, setError] = useState<Error | null>(null)
130
130
  const [rowsReceived, setRowsReceived] = useState(0)
131
- const clientRef = useRef<QueryClient>()
131
+ const clientRef = useRef<QueryClient>(null)
132
132
 
133
133
  useEffect(() => {
134
134
  const sdkConfig = getSDKExtensionsConfig()
@@ -221,7 +221,7 @@ export function useOperation<T = any>(operationId?: string) {
221
221
  const [progress, setProgress] = useState<OperationProgress | null>(null)
222
222
  const [error, setError] = useState<Error | null>(null)
223
223
  const [result, setResult] = useState<OperationResult<T> | null>(null)
224
- const clientRef = useRef<OperationClient>()
224
+ const clientRef = useRef<OperationClient>(null)
225
225
 
226
226
  useEffect(() => {
227
227
  const sdkConfig = getSDKExtensionsConfig()
@@ -329,7 +329,7 @@ export function useMultipleOperations<T = any>() {
329
329
  const [results, setResults] = useState<Map<string, OperationResult<T>>>(new Map())
330
330
  const [loading, setLoading] = useState(false)
331
331
  const [errors, setErrors] = useState<Map<string, Error>>(new Map())
332
- const clientRef = useRef<OperationClient>()
332
+ const clientRef = useRef<OperationClient>(null)
333
333
 
334
334
  useEffect(() => {
335
335
  const sdkConfig = getSDKExtensionsConfig()
@@ -0,0 +1,46 @@
1
+ /**
2
+ * RoboSystems SDK Extensions
3
+ * Enhanced clients with SSE support for the RoboSystems API
4
+ */
5
+ import { OperationClient } from './OperationClient';
6
+ import { QueryClient } from './QueryClient';
7
+ import { SSEClient } from './SSEClient';
8
+ export interface RoboSystemsExtensionConfig {
9
+ baseUrl?: string;
10
+ credentials?: 'include' | 'same-origin' | 'omit';
11
+ maxRetries?: number;
12
+ retryDelay?: number;
13
+ }
14
+ export declare class RoboSystemsExtensions {
15
+ readonly query: QueryClient;
16
+ readonly operations: OperationClient;
17
+ private config;
18
+ constructor(config?: RoboSystemsExtensionConfig);
19
+ /**
20
+ * Convenience method to monitor any operation
21
+ */
22
+ monitorOperation(operationId: string, onProgress?: (progress: any) => void): Promise<any>;
23
+ /**
24
+ * Create custom SSE client for advanced use cases
25
+ */
26
+ createSSEClient(): SSEClient;
27
+ /**
28
+ * Clean up all active connections
29
+ */
30
+ close(): void;
31
+ }
32
+ export * from './OperationClient';
33
+ export * from './QueryClient';
34
+ export * from './SSEClient';
35
+ export { OperationClient, QueryClient, SSEClient };
36
+ export { useMultipleOperations, useOperation, useQuery, useSDKClients, useStreamingQuery, } from './hooks';
37
+ export declare const extensions: {
38
+ readonly query: QueryClient;
39
+ readonly operations: OperationClient;
40
+ monitorOperation: (operationId: string, onProgress?: (progress: any) => void) => Promise<any>;
41
+ createSSEClient: () => SSEClient;
42
+ close: () => void;
43
+ };
44
+ export declare const monitorOperation: (operationId: string, onProgress?: (progress: any) => void) => Promise<any>;
45
+ export declare const executeQuery: (graphId: string, query: string, parameters?: Record<string, any>) => Promise<import("./QueryClient").QueryResult>;
46
+ export declare const streamQuery: (graphId: string, query: string, parameters?: Record<string, any>, chunkSize?: number) => AsyncIterableIterator<any>;
@@ -1,118 +1,110 @@
1
+ "use strict";
1
2
  /**
2
3
  * RoboSystems SDK Extensions
3
4
  * Enhanced clients with SSE support for the RoboSystems API
4
5
  */
5
-
6
- import { client } from '../client.gen'
7
- import { OperationClient } from './OperationClient'
8
- import { QueryClient } from './QueryClient'
9
- import { SSEClient } from './SSEClient'
10
-
11
-
12
-
13
- export class RoboSystemsExtensions {
14
- public readonly query
15
- public readonly operations
16
- private config
17
-
18
- constructor(config = {}) {
19
- // Get base URL from SDK client config or use provided/default
20
- const sdkConfig = client.getConfig()
21
-
22
- this.config = {
23
- baseUrl.baseUrl || sdkConfig.baseUrl || 'http://localhost:8000',
24
- credentials.credentials || 'include',
25
- maxRetries.maxRetries || 5,
26
- retryDelay.retryDelay || 1000,
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.streamQuery = exports.executeQuery = exports.monitorOperation = exports.extensions = exports.useStreamingQuery = exports.useSDKClients = exports.useQuery = exports.useOperation = exports.useMultipleOperations = exports.SSEClient = exports.QueryClient = exports.OperationClient = exports.RoboSystemsExtensions = void 0;
22
+ const client_gen_1 = require("../sdk/client.gen");
23
+ const OperationClient_1 = require("./OperationClient");
24
+ Object.defineProperty(exports, "OperationClient", { enumerable: true, get: function () { return OperationClient_1.OperationClient; } });
25
+ const QueryClient_1 = require("./QueryClient");
26
+ Object.defineProperty(exports, "QueryClient", { enumerable: true, get: function () { return QueryClient_1.QueryClient; } });
27
+ const SSEClient_1 = require("./SSEClient");
28
+ Object.defineProperty(exports, "SSEClient", { enumerable: true, get: function () { return SSEClient_1.SSEClient; } });
29
+ class RoboSystemsExtensions {
30
+ constructor(config = {}) {
31
+ // Get base URL from SDK client config or use provided/default
32
+ const sdkConfig = client_gen_1.client.getConfig();
33
+ this.config = {
34
+ baseUrl: config.baseUrl || sdkConfig.baseUrl || 'http://localhost:8000',
35
+ credentials: config.credentials || 'include',
36
+ maxRetries: config.maxRetries || 5,
37
+ retryDelay: config.retryDelay || 1000,
38
+ };
39
+ this.query = new QueryClient_1.QueryClient({
40
+ baseUrl: this.config.baseUrl,
41
+ credentials: this.config.credentials,
42
+ });
43
+ this.operations = new OperationClient_1.OperationClient({
44
+ baseUrl: this.config.baseUrl,
45
+ credentials: this.config.credentials,
46
+ });
47
+ }
48
+ /**
49
+ * Convenience method to monitor any operation
50
+ */
51
+ async monitorOperation(operationId, onProgress) {
52
+ return this.operations.monitorOperation(operationId, { onProgress });
53
+ }
54
+ /**
55
+ * Create custom SSE client for advanced use cases
56
+ */
57
+ createSSEClient() {
58
+ return new SSEClient_1.SSEClient({
59
+ baseUrl: this.config.baseUrl,
60
+ credentials: this.config.credentials,
61
+ maxRetries: this.config.maxRetries,
62
+ retryDelay: this.config.retryDelay,
63
+ });
64
+ }
65
+ /**
66
+ * Clean up all active connections
67
+ */
68
+ close() {
69
+ this.query.close();
70
+ this.operations.closeAll();
27
71
  }
28
-
29
- this.query = new QueryClient({
30
- baseUrl.config.baseUrl,
31
- credentials.config.credentials,
32
- })
33
-
34
- this.operations = new OperationClient({
35
- baseUrl.config.baseUrl,
36
- credentials.config.credentials,
37
- })
38
- }
39
-
40
- /**
41
- * Convenience method to monitor any operation
42
- */
43
- async monitorOperation(operationId, onProgress?) {
44
- return this.operations.monitorOperation(operationId, { onProgress })
45
- }
46
-
47
- /**
48
- * Create custom SSE client for advanced use cases
49
- */
50
- createSSEClient() {
51
- return new SSEClient({
52
- baseUrl.config.baseUrl,
53
- credentials.config.credentials,
54
- maxRetries.config.maxRetries,
55
- retryDelay.config.retryDelay,
56
- })
57
- }
58
-
59
- /**
60
- * Clean up all active connections
61
- */
62
- close() {
63
- this.query.close()
64
- this.operations.closeAll()
65
- }
66
72
  }
67
-
73
+ exports.RoboSystemsExtensions = RoboSystemsExtensions;
68
74
  // Export all types and classes
69
- export * from './OperationClient'
70
- export * from './QueryClient'
71
- export * from './SSEClient'
72
- export { OperationClient, QueryClient, SSEClient }
73
-
75
+ __exportStar(require("./OperationClient"), exports);
76
+ __exportStar(require("./QueryClient"), exports);
77
+ __exportStar(require("./SSEClient"), exports);
74
78
  // Export React hooks
75
- export {
76
- useMultipleOperations,
77
- useOperation,
78
- useQuery,
79
- useSDKClients,
80
- useStreamingQuery,
81
- } from './hooks'
82
-
79
+ var hooks_1 = require("./hooks");
80
+ Object.defineProperty(exports, "useMultipleOperations", { enumerable: true, get: function () { return hooks_1.useMultipleOperations; } });
81
+ Object.defineProperty(exports, "useOperation", { enumerable: true, get: function () { return hooks_1.useOperation; } });
82
+ Object.defineProperty(exports, "useQuery", { enumerable: true, get: function () { return hooks_1.useQuery; } });
83
+ Object.defineProperty(exports, "useSDKClients", { enumerable: true, get: function () { return hooks_1.useSDKClients; } });
84
+ Object.defineProperty(exports, "useStreamingQuery", { enumerable: true, get: function () { return hooks_1.useStreamingQuery; } });
83
85
  // Lazy initialization of default instance
84
- let _extensions | null = null
85
-
86
+ let _extensions = null;
86
87
  function getExtensions() {
87
- if (!_extensions) {
88
- _extensions = new RoboSystemsExtensions()
89
- }
90
- return _extensions
91
- }
92
-
93
- export const extensions = {
94
- get query() {
95
- return getExtensions().query
96
- },
97
- get operations() {
98
- return getExtensions().operations
99
- },
100
- monitorOperation) =>
101
- getExtensions().monitorOperation(operationId, onProgress),
102
- createSSEClient: () => getExtensions().createSSEClient(),
103
- close: () => getExtensions().close(),
88
+ if (!_extensions) {
89
+ _extensions = new RoboSystemsExtensions();
90
+ }
91
+ return _extensions;
104
92
  }
105
-
93
+ exports.extensions = {
94
+ get query() {
95
+ return getExtensions().query;
96
+ },
97
+ get operations() {
98
+ return getExtensions().operations;
99
+ },
100
+ monitorOperation: (operationId, onProgress) => getExtensions().monitorOperation(operationId, onProgress),
101
+ createSSEClient: () => getExtensions().createSSEClient(),
102
+ close: () => getExtensions().close(),
103
+ };
106
104
  // Export convenience functions that use the default instance
107
- export const monitorOperation = (operationId, onProgress?) =>
108
- getExtensions().monitorOperation(operationId, onProgress)
109
-
110
- export const executeQuery = (graphId, query, parameters?) =>
111
- getExtensions().query.query(graphId, query, parameters)
112
-
113
- export const streamQuery = (
114
- graphId,
115
- query,
116
- parameters?,
117
- chunkSize?
118
- ) => getExtensions().query.streamQuery(graphId, query, parameters, chunkSize)
105
+ const monitorOperation = (operationId, onProgress) => getExtensions().monitorOperation(operationId, onProgress);
106
+ exports.monitorOperation = monitorOperation;
107
+ const executeQuery = (graphId, query, parameters) => getExtensions().query.query(graphId, query, parameters);
108
+ exports.executeQuery = executeQuery;
109
+ const streamQuery = (graphId, query, parameters, chunkSize) => getExtensions().query.streamQuery(graphId, query, parameters, chunkSize);
110
+ exports.streamQuery = streamQuery;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robosystems/client",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "TypeScript client library for RoboSystems Financial Knowledge Graph API",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -52,13 +52,13 @@
52
52
  "url": "https://github.com/RoboFinSystems/robosystems-typescript-client/issues"
53
53
  },
54
54
  "homepage": "https://github.com/RoboFinSystems/robosystems-typescript-client#readme",
55
- "dependencies": {},
56
55
  "engines": {
57
56
  "node": ">=18.0.0"
58
57
  },
59
58
  "devDependencies": {
60
59
  "@hey-api/openapi-ts": "^0.80.2",
61
60
  "@types/node": "^22.0.0",
61
+ "@types/react": "^19.1.9",
62
62
  "@typescript-eslint/eslint-plugin": "^7.0.0",
63
63
  "@typescript-eslint/parser": "^7.0.0",
64
64
  "eslint": "^8.0.0",
package/prepare.js CHANGED
@@ -11,6 +11,16 @@ const { execSync } = require('child_process')
11
11
 
12
12
  console.log('🚀 Preparing RoboSystems SDK for publishing...')
13
13
 
14
+ // First, build the TypeScript
15
+ console.log('🔨 Building TypeScript...')
16
+ try {
17
+ execSync('npm run build', { stdio: 'inherit' })
18
+ console.log('✅ TypeScript build complete')
19
+ } catch (error) {
20
+ console.error('❌ TypeScript build failed:', error.message)
21
+ process.exit(1)
22
+ }
23
+
14
24
  const sdkSourceDir = path.join(__dirname, 'sdk')
15
25
  const currentDir = __dirname
16
26
 
@@ -80,38 +90,30 @@ if (!fs.existsSync(extensionsDestDir)) {
80
90
 
81
91
  // Copy extensions files
82
92
  if (fs.existsSync(extensionsSourceDir)) {
83
- const files = fs.readdirSync(extensionsSourceDir)
84
- files.forEach((file) => {
93
+ // The TypeScript compiler will have already built these files
94
+ // Just copy the compiled .js and .d.ts files
95
+ const sdkExtensionsBuilt = fs.readdirSync(extensionsSourceDir)
96
+
97
+ sdkExtensionsBuilt.forEach((file) => {
85
98
  const sourcePath = path.join(extensionsSourceDir, file)
86
99
  const destPath = path.join(extensionsDestDir, file)
87
-
88
- if (file.endsWith('.ts')) {
89
- // Process TypeScript files
100
+
101
+ if (file.endsWith('.js') || file.endsWith('.d.ts')) {
102
+ // Copy compiled JavaScript and declaration files
103
+ fs.copyFileSync(sourcePath, destPath)
104
+ console.log(` ✓ Copied ${file}`)
105
+ } else if (file.endsWith('.ts') && !file.endsWith('.d.ts')) {
106
+ // Copy TypeScript source files for reference
90
107
  let content = fs.readFileSync(sourcePath, 'utf8')
91
-
108
+
92
109
  // Adjust imports for published package structure
93
110
  content = content
94
111
  .replace(/from ['"]\.\.\/sdk\/sdk\.gen['"]/g, "from '../sdk.gen'")
95
112
  .replace(/from ['"]\.\.\/sdk\/types\.gen['"]/g, "from '../types.gen'")
96
113
  .replace(/from ['"]\.\.\/sdk\/client\.gen['"]/g, "from '../client.gen'")
97
-
98
- // Save TypeScript version
114
+
99
115
  fs.writeFileSync(destPath, content)
100
-
101
- // Create JavaScript version
102
- let jsContent = content
103
- .replace(/export interface \w+[^}]+}/gs, '') // Remove interfaces
104
- .replace(/export type[^;]+;/gs, '') // Remove type exports
105
- .replace(/: (\w+(\[\])?|{[^}]+}|\([^)]+\) => \w+|['"][\w-]+['"])/g, '') // Remove type annotations
106
- .replace(/<[^>]+>/g, '') // Remove generics
107
- .replace(/\?:/g, ':') // Remove optional markers
108
- .replace(/ as \w+/g, '') // Remove type assertions
109
- .replace(/import type/g, 'import') // Convert type imports
110
- .replace(/type \w+ = [^;]+;/g, '') // Remove type aliases
111
-
112
- const jsFile = file.replace('.ts', '.js')
113
- fs.writeFileSync(path.join(extensionsDestDir, jsFile), jsContent)
114
- console.log(` ✓ Copied ${file} -> ${jsFile}`)
116
+ console.log(` ✓ Copied ${file}`)
115
117
  }
116
118
  })
117
119
  console.log(' ✓ SDK extensions copied')