@robosystems/client 0.1.21 → 0.1.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.
- package/extensions/CopyClient.d.ts +1 -0
- package/extensions/CopyClient.js +3 -0
- package/extensions/CopyClient.ts +5 -0
- package/extensions/OperationClient.d.ts +1 -0
- package/extensions/OperationClient.ts +2 -0
- package/extensions/QueryClient.d.ts +1 -0
- package/extensions/QueryClient.js +1 -0
- package/extensions/QueryClient.ts +3 -0
- package/extensions/SSEClient.d.ts +14 -0
- package/extensions/SSEClient.js +7 -1
- package/extensions/SSEClient.ts +22 -1
- package/extensions/config.d.ts +25 -0
- package/extensions/config.js +78 -0
- package/extensions/config.ts +84 -0
- package/extensions/hooks.js +16 -0
- package/extensions/hooks.ts +27 -1
- package/extensions/index.d.ts +2 -0
- package/extensions/index.js +14 -0
- package/extensions/index.ts +28 -1
- package/package.json +1 -1
- package/sdk/types.gen.d.ts +493 -59
- package/sdk/types.gen.ts +493 -59
- package/sdk-extensions/CopyClient.d.ts +1 -0
- package/sdk-extensions/CopyClient.js +3 -0
- package/sdk-extensions/CopyClient.ts +5 -0
- package/sdk-extensions/OperationClient.d.ts +1 -0
- package/sdk-extensions/OperationClient.ts +2 -0
- package/sdk-extensions/QueryClient.d.ts +1 -0
- package/sdk-extensions/QueryClient.js +1 -0
- package/sdk-extensions/QueryClient.ts +3 -0
- package/sdk-extensions/SSEClient.d.ts +14 -0
- package/sdk-extensions/SSEClient.js +7 -1
- package/sdk-extensions/SSEClient.ts +22 -1
- package/sdk-extensions/config.d.ts +25 -0
- package/sdk-extensions/config.js +78 -0
- package/sdk-extensions/config.ts +84 -0
- package/sdk-extensions/hooks.js +16 -0
- package/sdk-extensions/hooks.ts +27 -1
- package/sdk-extensions/index.d.ts +2 -0
- package/sdk-extensions/index.js +14 -0
- package/sdk-extensions/index.ts +28 -1
- package/types.gen.d.ts +493 -59
- package/types.gen.ts +493 -59
package/sdk-extensions/index.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { client } from '../sdk/client.gen'
|
|
7
|
+
import { extractTokenFromSDKClient } from './config'
|
|
7
8
|
import { CopyClient } from './CopyClient'
|
|
8
9
|
import { OperationClient } from './OperationClient'
|
|
9
10
|
import { QueryClient } from './QueryClient'
|
|
@@ -12,23 +13,40 @@ import { SSEClient } from './SSEClient'
|
|
|
12
13
|
export interface RoboSystemsExtensionConfig {
|
|
13
14
|
baseUrl?: string
|
|
14
15
|
credentials?: 'include' | 'same-origin' | 'omit'
|
|
16
|
+
token?: string // JWT token for authentication
|
|
17
|
+
headers?: Record<string, string>
|
|
15
18
|
maxRetries?: number
|
|
16
19
|
retryDelay?: number
|
|
17
20
|
}
|
|
18
21
|
|
|
22
|
+
// Properly typed configuration interface
|
|
23
|
+
interface ResolvedConfig {
|
|
24
|
+
baseUrl: string
|
|
25
|
+
credentials: 'include' | 'same-origin' | 'omit'
|
|
26
|
+
token?: string
|
|
27
|
+
headers?: Record<string, string>
|
|
28
|
+
maxRetries: number
|
|
29
|
+
retryDelay: number
|
|
30
|
+
}
|
|
31
|
+
|
|
19
32
|
export class RoboSystemsExtensions {
|
|
20
33
|
public readonly copy: CopyClient
|
|
21
34
|
public readonly query: QueryClient
|
|
22
35
|
public readonly operations: OperationClient
|
|
23
|
-
private config:
|
|
36
|
+
private config: ResolvedConfig
|
|
24
37
|
|
|
25
38
|
constructor(config: RoboSystemsExtensionConfig = {}) {
|
|
26
39
|
// Get base URL from SDK client config or use provided/default
|
|
27
40
|
const sdkConfig = client.getConfig()
|
|
28
41
|
|
|
42
|
+
// Extract JWT token using centralized logic
|
|
43
|
+
const token = config.token || extractTokenFromSDKClient()
|
|
44
|
+
|
|
29
45
|
this.config = {
|
|
30
46
|
baseUrl: config.baseUrl || sdkConfig.baseUrl || 'http://localhost:8000',
|
|
31
47
|
credentials: config.credentials || 'include',
|
|
48
|
+
token,
|
|
49
|
+
headers: config.headers,
|
|
32
50
|
maxRetries: config.maxRetries || 5,
|
|
33
51
|
retryDelay: config.retryDelay || 1000,
|
|
34
52
|
}
|
|
@@ -36,16 +54,23 @@ export class RoboSystemsExtensions {
|
|
|
36
54
|
this.copy = new CopyClient({
|
|
37
55
|
baseUrl: this.config.baseUrl,
|
|
38
56
|
credentials: this.config.credentials,
|
|
57
|
+
token: this.config.token,
|
|
58
|
+
headers: this.config.headers,
|
|
39
59
|
})
|
|
40
60
|
|
|
41
61
|
this.query = new QueryClient({
|
|
42
62
|
baseUrl: this.config.baseUrl,
|
|
43
63
|
credentials: this.config.credentials,
|
|
64
|
+
token: this.config.token,
|
|
65
|
+
headers: this.config.headers,
|
|
44
66
|
})
|
|
45
67
|
|
|
46
68
|
this.operations = new OperationClient({
|
|
47
69
|
baseUrl: this.config.baseUrl,
|
|
48
70
|
credentials: this.config.credentials,
|
|
71
|
+
token: this.config.token,
|
|
72
|
+
maxRetries: this.config.maxRetries,
|
|
73
|
+
retryDelay: this.config.retryDelay,
|
|
49
74
|
})
|
|
50
75
|
}
|
|
51
76
|
|
|
@@ -63,6 +88,8 @@ export class RoboSystemsExtensions {
|
|
|
63
88
|
return new SSEClient({
|
|
64
89
|
baseUrl: this.config.baseUrl,
|
|
65
90
|
credentials: this.config.credentials,
|
|
91
|
+
token: this.config.token,
|
|
92
|
+
headers: this.config.headers,
|
|
66
93
|
maxRetries: this.config.maxRetries,
|
|
67
94
|
retryDelay: this.config.retryDelay,
|
|
68
95
|
})
|