@robosystems/client 0.2.48 → 0.3.0
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/InvestorClient.d.ts +91 -0
- package/extensions/InvestorClient.js +223 -0
- package/extensions/InvestorClient.ts +501 -0
- package/extensions/LedgerClient.d.ts +213 -165
- package/extensions/LedgerClient.js +315 -393
- package/extensions/LedgerClient.ts +887 -564
- package/extensions/ReportClient.d.ts +77 -115
- package/extensions/ReportClient.js +124 -211
- package/extensions/ReportClient.ts +298 -358
- package/extensions/config.js +1 -1
- package/extensions/config.ts +1 -1
- package/extensions/graphql/client.d.ts +46 -0
- package/extensions/graphql/client.js +75 -0
- package/extensions/graphql/client.ts +82 -0
- package/extensions/graphql/generated/graphql.d.ts +1786 -0
- package/extensions/graphql/generated/graphql.js +2671 -0
- package/extensions/graphql/generated/graphql.ts +4491 -0
- package/extensions/graphql/queries/investor/holdings.d.ts +8 -0
- package/extensions/graphql/queries/investor/holdings.js +36 -0
- package/extensions/graphql/queries/investor/holdings.ts +34 -0
- package/extensions/graphql/queries/investor/portfolio.d.ts +4 -0
- package/extensions/graphql/queries/investor/portfolio.js +21 -0
- package/extensions/graphql/queries/investor/portfolio.ts +19 -0
- package/extensions/graphql/queries/investor/portfolios.d.ts +4 -0
- package/extensions/graphql/queries/investor/portfolios.js +29 -0
- package/extensions/graphql/queries/investor/portfolios.ts +27 -0
- package/extensions/graphql/queries/investor/position.d.ts +4 -0
- package/extensions/graphql/queries/investor/position.js +33 -0
- package/extensions/graphql/queries/investor/position.ts +31 -0
- package/extensions/graphql/queries/investor/positions.d.ts +8 -0
- package/extensions/graphql/queries/investor/positions.js +57 -0
- package/extensions/graphql/queries/investor/positions.ts +55 -0
- package/extensions/graphql/queries/investor/securities.d.ts +8 -0
- package/extensions/graphql/queries/investor/securities.js +50 -0
- package/extensions/graphql/queries/investor/securities.ts +48 -0
- package/extensions/graphql/queries/investor/security.d.ts +4 -0
- package/extensions/graphql/queries/investor/security.js +26 -0
- package/extensions/graphql/queries/investor/security.ts +24 -0
- package/extensions/graphql/queries/ledger/accountRollups.d.ts +7 -0
- package/extensions/graphql/queries/ledger/accountRollups.js +36 -0
- package/extensions/graphql/queries/ledger/accountRollups.ts +34 -0
- package/extensions/graphql/queries/ledger/accountTree.d.ts +11 -0
- package/extensions/graphql/queries/ledger/accountTree.js +61 -0
- package/extensions/graphql/queries/ledger/accountTree.ts +59 -0
- package/extensions/graphql/queries/ledger/accounts.d.ts +8 -0
- package/extensions/graphql/queries/ledger/accounts.js +45 -0
- package/extensions/graphql/queries/ledger/accounts.ts +43 -0
- package/extensions/graphql/queries/ledger/closingBookStructures.d.ts +6 -0
- package/extensions/graphql/queries/ledger/closingBookStructures.js +27 -0
- package/extensions/graphql/queries/ledger/closingBookStructures.ts +25 -0
- package/extensions/graphql/queries/ledger/elements.d.ts +6 -0
- package/extensions/graphql/queries/ledger/elements.js +56 -0
- package/extensions/graphql/queries/ledger/elements.ts +54 -0
- package/extensions/graphql/queries/ledger/entities.d.ts +7 -0
- package/extensions/graphql/queries/ledger/entities.js +31 -0
- package/extensions/graphql/queries/ledger/entities.ts +29 -0
- package/extensions/graphql/queries/ledger/entity.d.ts +14 -0
- package/extensions/graphql/queries/ledger/entity.js +55 -0
- package/extensions/graphql/queries/ledger/entity.ts +54 -0
- package/extensions/graphql/queries/ledger/fiscalCalendar.d.ts +8 -0
- package/extensions/graphql/queries/ledger/fiscalCalendar.js +35 -0
- package/extensions/graphql/queries/ledger/fiscalCalendar.ts +33 -0
- package/extensions/graphql/queries/ledger/mappedTrialBalance.d.ts +9 -0
- package/extensions/graphql/queries/ledger/mappedTrialBalance.js +29 -0
- package/extensions/graphql/queries/ledger/mappedTrialBalance.ts +27 -0
- package/extensions/graphql/queries/ledger/mapping.d.ts +5 -0
- package/extensions/graphql/queries/ledger/mapping.js +35 -0
- package/extensions/graphql/queries/ledger/mapping.ts +33 -0
- package/extensions/graphql/queries/ledger/mappingCoverage.d.ts +5 -0
- package/extensions/graphql/queries/ledger/mappingCoverage.js +22 -0
- package/extensions/graphql/queries/ledger/mappingCoverage.ts +20 -0
- package/extensions/graphql/queries/ledger/mappings.d.ts +6 -0
- package/extensions/graphql/queries/ledger/mappings.js +23 -0
- package/extensions/graphql/queries/ledger/mappings.ts +21 -0
- package/extensions/graphql/queries/ledger/periodCloseStatus.d.ts +6 -0
- package/extensions/graphql/queries/ledger/periodCloseStatus.js +29 -0
- package/extensions/graphql/queries/ledger/periodCloseStatus.ts +27 -0
- package/extensions/graphql/queries/ledger/periodDrafts.d.ts +8 -0
- package/extensions/graphql/queries/ledger/periodDrafts.js +45 -0
- package/extensions/graphql/queries/ledger/periodDrafts.ts +43 -0
- package/extensions/graphql/queries/ledger/publishList.d.ts +5 -0
- package/extensions/graphql/queries/ledger/publishList.js +29 -0
- package/extensions/graphql/queries/ledger/publishList.ts +27 -0
- package/extensions/graphql/queries/ledger/publishLists.d.ts +5 -0
- package/extensions/graphql/queries/ledger/publishLists.js +29 -0
- package/extensions/graphql/queries/ledger/publishLists.ts +27 -0
- package/extensions/graphql/queries/ledger/report.d.ts +5 -0
- package/extensions/graphql/queries/ledger/report.js +40 -0
- package/extensions/graphql/queries/ledger/report.ts +38 -0
- package/extensions/graphql/queries/ledger/reportingTaxonomy.d.ts +6 -0
- package/extensions/graphql/queries/ledger/reportingTaxonomy.js +27 -0
- package/extensions/graphql/queries/ledger/reportingTaxonomy.ts +25 -0
- package/extensions/graphql/queries/ledger/reports.d.ts +8 -0
- package/extensions/graphql/queries/ledger/reports.js +45 -0
- package/extensions/graphql/queries/ledger/reports.ts +43 -0
- package/extensions/graphql/queries/ledger/scheduleFacts.d.ts +7 -0
- package/extensions/graphql/queries/ledger/scheduleFacts.js +24 -0
- package/extensions/graphql/queries/ledger/scheduleFacts.ts +22 -0
- package/extensions/graphql/queries/ledger/schedules.d.ts +6 -0
- package/extensions/graphql/queries/ledger/schedules.js +24 -0
- package/extensions/graphql/queries/ledger/schedules.ts +22 -0
- package/extensions/graphql/queries/ledger/statement.d.ts +9 -0
- package/extensions/graphql/queries/ledger/statement.js +43 -0
- package/extensions/graphql/queries/ledger/statement.ts +41 -0
- package/extensions/graphql/queries/ledger/structures.d.ts +5 -0
- package/extensions/graphql/queries/ledger/structures.js +22 -0
- package/extensions/graphql/queries/ledger/structures.ts +20 -0
- package/extensions/graphql/queries/ledger/summary.d.ts +7 -0
- package/extensions/graphql/queries/ledger/summary.js +25 -0
- package/extensions/graphql/queries/ledger/summary.ts +23 -0
- package/extensions/graphql/queries/ledger/taxonomies.d.ts +5 -0
- package/extensions/graphql/queries/ledger/taxonomies.js +28 -0
- package/extensions/graphql/queries/ledger/taxonomies.ts +26 -0
- package/extensions/graphql/queries/ledger/transaction.d.ts +6 -0
- package/extensions/graphql/queries/ledger/transaction.js +49 -0
- package/extensions/graphql/queries/ledger/transaction.ts +47 -0
- package/extensions/graphql/queries/ledger/transactions.d.ts +7 -0
- package/extensions/graphql/queries/ledger/transactions.js +49 -0
- package/extensions/graphql/queries/ledger/transactions.ts +47 -0
- package/extensions/graphql/queries/ledger/trialBalance.d.ts +7 -0
- package/extensions/graphql/queries/ledger/trialBalance.js +28 -0
- package/extensions/graphql/queries/ledger/trialBalance.ts +26 -0
- package/extensions/graphql/queries/ledger/unmappedElements.d.ts +8 -0
- package/extensions/graphql/queries/ledger/unmappedElements.js +29 -0
- package/extensions/graphql/queries/ledger/unmappedElements.ts +27 -0
- package/extensions/hooks.d.ts +1 -1
- package/extensions/index.d.ts +5 -1
- package/extensions/index.js +13 -1
- package/extensions/index.ts +14 -0
- package/index.ts +2 -2
- package/package.json +14 -5
- package/sdk/index.d.ts +2 -2
- package/sdk/index.js +38 -65
- package/sdk/index.ts +2 -2
- package/sdk/sdk.gen.d.ts +101 -220
- package/sdk/sdk.gen.js +251 -445
- package/sdk/sdk.gen.ts +216 -409
- package/sdk/types.gen.d.ts +4586 -7045
- package/sdk/types.gen.ts +4702 -7334
- package/sdk.gen.d.ts +101 -220
- package/sdk.gen.js +251 -445
- package/sdk.gen.ts +216 -409
- package/types.gen.d.ts +4586 -7045
- package/types.gen.ts +4702 -7334
- package/extensions/AgentClient.test.ts +0 -403
- package/extensions/LedgerClient.test.ts +0 -1138
- package/extensions/OperationClient.test.ts +0 -365
- package/extensions/QueryClient.test.ts +0 -432
- package/extensions/ReportClient.test.ts +0 -828
- package/extensions/SSEClient.test.ts +0 -375
- package/extensions/config.test.ts +0 -199
- package/extensions/hooks.test.ts +0 -373
- package/extensions/index.test.ts +0 -420
- package/sdk-extensions/AgentClient.d.ts +0 -82
- package/sdk-extensions/AgentClient.js +0 -218
- package/sdk-extensions/AgentClient.test.ts +0 -403
- package/sdk-extensions/AgentClient.ts +0 -321
- package/sdk-extensions/LedgerClient.d.ts +0 -242
- package/sdk-extensions/LedgerClient.js +0 -496
- package/sdk-extensions/LedgerClient.test.ts +0 -1138
- package/sdk-extensions/LedgerClient.ts +0 -800
- package/sdk-extensions/OperationClient.d.ts +0 -65
- package/sdk-extensions/OperationClient.js +0 -251
- package/sdk-extensions/OperationClient.test.ts +0 -365
- package/sdk-extensions/OperationClient.ts +0 -324
- package/sdk-extensions/QueryClient.d.ts +0 -52
- package/sdk-extensions/QueryClient.js +0 -313
- package/sdk-extensions/QueryClient.test.ts +0 -432
- package/sdk-extensions/QueryClient.ts +0 -420
- package/sdk-extensions/README.md +0 -901
- package/sdk-extensions/ReportClient.d.ts +0 -151
- package/sdk-extensions/ReportClient.js +0 -278
- package/sdk-extensions/ReportClient.test.ts +0 -828
- package/sdk-extensions/ReportClient.ts +0 -486
- package/sdk-extensions/SSEClient.d.ts +0 -62
- package/sdk-extensions/SSEClient.js +0 -154
- package/sdk-extensions/SSEClient.test.ts +0 -375
- package/sdk-extensions/SSEClient.ts +0 -210
- package/sdk-extensions/config.d.ts +0 -57
- package/sdk-extensions/config.js +0 -152
- package/sdk-extensions/config.test.ts +0 -199
- package/sdk-extensions/config.ts +0 -175
- package/sdk-extensions/hooks.d.ts +0 -110
- package/sdk-extensions/hooks.js +0 -384
- package/sdk-extensions/hooks.test.ts +0 -373
- package/sdk-extensions/hooks.ts +0 -459
- package/sdk-extensions/index.d.ts +0 -63
- package/sdk-extensions/index.js +0 -164
- package/sdk-extensions/index.test.ts +0 -420
- package/sdk-extensions/index.ts +0 -203
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
-
import { RoboSystemsExtensions } from './index'
|
|
3
|
-
|
|
4
|
-
// Mock the SDK client
|
|
5
|
-
vi.mock('../sdk/client.gen', () => ({
|
|
6
|
-
client: {
|
|
7
|
-
getConfig: vi.fn(() => ({
|
|
8
|
-
baseUrl: 'http://mock-sdk.com',
|
|
9
|
-
headers: {},
|
|
10
|
-
})),
|
|
11
|
-
},
|
|
12
|
-
}))
|
|
13
|
-
|
|
14
|
-
describe('RoboSystemsExtensions', () => {
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
vi.clearAllMocks()
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
describe('constructor', () => {
|
|
20
|
-
it('should create instance with default config', () => {
|
|
21
|
-
const ext = new RoboSystemsExtensions()
|
|
22
|
-
|
|
23
|
-
expect(ext).toBeDefined()
|
|
24
|
-
expect(ext.query).toBeDefined()
|
|
25
|
-
expect(ext.operations).toBeDefined()
|
|
26
|
-
expect(ext.ledger).toBeDefined()
|
|
27
|
-
expect(ext.reports).toBeDefined()
|
|
28
|
-
expect(typeof ext.query.executeQuery).toBe('function')
|
|
29
|
-
expect(typeof ext.operations.monitorOperation).toBe('function')
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('should create instance with custom baseUrl', () => {
|
|
33
|
-
const ext = new RoboSystemsExtensions({
|
|
34
|
-
baseUrl: 'https://custom-api.com',
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
expect(ext.query).toBeDefined()
|
|
38
|
-
expect(ext.operations).toBeDefined()
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('should create instance with JWT token', () => {
|
|
42
|
-
const ext = new RoboSystemsExtensions({
|
|
43
|
-
token: 'eyJhbGc.eyJzdWI.SflKxw',
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
expect(ext.query).toBeDefined()
|
|
47
|
-
expect(typeof ext.query.query).toBe('function')
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('should create instance with credentials option', () => {
|
|
51
|
-
const ext = new RoboSystemsExtensions({
|
|
52
|
-
credentials: 'omit',
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
expect(ext.query).toBeDefined()
|
|
56
|
-
expect(ext.operations).toBeDefined()
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('should create instance with custom headers', () => {
|
|
60
|
-
const ext = new RoboSystemsExtensions({
|
|
61
|
-
headers: {
|
|
62
|
-
'X-Custom-Header': 'test-value',
|
|
63
|
-
},
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
expect(ext.query).toBeDefined()
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
it('should create instance with retry config', () => {
|
|
70
|
-
const ext = new RoboSystemsExtensions({
|
|
71
|
-
maxRetries: 10,
|
|
72
|
-
retryDelay: 5000,
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
expect(ext.operations).toBeDefined()
|
|
76
|
-
expect(typeof ext.operations.monitorOperation).toBe('function')
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
it('should merge config with SDK client config', () => {
|
|
80
|
-
const ext = new RoboSystemsExtensions({
|
|
81
|
-
token: 'custom-token',
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
expect(ext.query).toBeDefined()
|
|
85
|
-
expect(ext.operations).toBeDefined()
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
it('should initialize all five client types', () => {
|
|
89
|
-
const ext = new RoboSystemsExtensions()
|
|
90
|
-
|
|
91
|
-
// Verify each client has its signature methods
|
|
92
|
-
expect(typeof ext.query.executeQuery).toBe('function')
|
|
93
|
-
expect(typeof ext.query.query).toBe('function')
|
|
94
|
-
expect(typeof ext.agent.executeQuery).toBe('function')
|
|
95
|
-
expect(typeof ext.agent.analyzeFinancials).toBe('function')
|
|
96
|
-
expect(typeof ext.operations.monitorOperation).toBe('function')
|
|
97
|
-
expect(typeof ext.operations.closeAll).toBe('function')
|
|
98
|
-
expect(typeof ext.ledger.listAccounts).toBe('function')
|
|
99
|
-
expect(typeof ext.ledger.getTrialBalance).toBe('function')
|
|
100
|
-
expect(typeof ext.reports.create).toBe('function')
|
|
101
|
-
expect(typeof ext.reports.statement).toBe('function')
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
it('should default credentials to include', () => {
|
|
105
|
-
const ext = new RoboSystemsExtensions()
|
|
106
|
-
|
|
107
|
-
// Access private config via casting
|
|
108
|
-
const config = (ext as any).config
|
|
109
|
-
expect(config.credentials).toBe('include')
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
it('should default maxRetries to 5 and retryDelay to 1000', () => {
|
|
113
|
-
const ext = new RoboSystemsExtensions()
|
|
114
|
-
|
|
115
|
-
const config = (ext as any).config
|
|
116
|
-
expect(config.maxRetries).toBe(5)
|
|
117
|
-
expect(config.retryDelay).toBe(1000)
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
it('should fall back to SDK client baseUrl or default', () => {
|
|
121
|
-
const ext = new RoboSystemsExtensions()
|
|
122
|
-
|
|
123
|
-
const config = (ext as any).config
|
|
124
|
-
// Should use SDK baseUrl or localhost default
|
|
125
|
-
expect(typeof config.baseUrl).toBe('string')
|
|
126
|
-
expect(config.baseUrl.length).toBeGreaterThan(0)
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
it('should prefer explicit baseUrl over SDK client', () => {
|
|
130
|
-
const ext = new RoboSystemsExtensions({
|
|
131
|
-
baseUrl: 'https://explicit.com',
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
const config = (ext as any).config
|
|
135
|
-
expect(config.baseUrl).toBe('https://explicit.com')
|
|
136
|
-
})
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
describe('createSSEClient', () => {
|
|
140
|
-
it('should create a new SSEClient instance', () => {
|
|
141
|
-
const ext = new RoboSystemsExtensions()
|
|
142
|
-
const sseClient = ext.createSSEClient()
|
|
143
|
-
|
|
144
|
-
expect(sseClient).toBeDefined()
|
|
145
|
-
expect(typeof sseClient.connect).toBe('function')
|
|
146
|
-
expect(typeof sseClient.close).toBe('function')
|
|
147
|
-
expect(typeof sseClient.on).toBe('function')
|
|
148
|
-
expect(typeof sseClient.off).toBe('function')
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
it('should create SSEClient with config', () => {
|
|
152
|
-
const ext = new RoboSystemsExtensions({
|
|
153
|
-
baseUrl: 'https://custom-api.com',
|
|
154
|
-
token: 'test-token',
|
|
155
|
-
})
|
|
156
|
-
const sseClient = ext.createSSEClient()
|
|
157
|
-
|
|
158
|
-
expect(sseClient).toBeDefined()
|
|
159
|
-
expect(typeof sseClient.connect).toBe('function')
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
it('should create independent SSEClient instances each time', () => {
|
|
163
|
-
const ext = new RoboSystemsExtensions()
|
|
164
|
-
const client1 = ext.createSSEClient()
|
|
165
|
-
const client2 = ext.createSSEClient()
|
|
166
|
-
|
|
167
|
-
expect(client1).not.toBe(client2)
|
|
168
|
-
})
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
describe('monitorOperation', () => {
|
|
172
|
-
it('should delegate to operations.monitorOperation', async () => {
|
|
173
|
-
const ext = new RoboSystemsExtensions()
|
|
174
|
-
|
|
175
|
-
const monitorSpy = vi.spyOn(ext.operations, 'monitorOperation').mockResolvedValue({
|
|
176
|
-
success: true,
|
|
177
|
-
result: { data: 'test' },
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
const result = await ext.monitorOperation('op_123')
|
|
181
|
-
|
|
182
|
-
expect(monitorSpy).toHaveBeenCalledWith('op_123', { onProgress: undefined })
|
|
183
|
-
expect(result).toEqual({
|
|
184
|
-
success: true,
|
|
185
|
-
result: { data: 'test' },
|
|
186
|
-
})
|
|
187
|
-
})
|
|
188
|
-
|
|
189
|
-
it('should pass progress callback through', async () => {
|
|
190
|
-
const ext = new RoboSystemsExtensions()
|
|
191
|
-
|
|
192
|
-
const monitorSpy = vi.spyOn(ext.operations, 'monitorOperation').mockResolvedValue({
|
|
193
|
-
success: true,
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
const progressCallback = vi.fn()
|
|
197
|
-
await ext.monitorOperation('op_123', progressCallback)
|
|
198
|
-
|
|
199
|
-
expect(monitorSpy).toHaveBeenCalledWith('op_123', { onProgress: progressCallback })
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
it('should propagate errors from operations client', async () => {
|
|
203
|
-
const ext = new RoboSystemsExtensions()
|
|
204
|
-
|
|
205
|
-
vi.spyOn(ext.operations, 'monitorOperation').mockRejectedValue(new Error('Operation timeout'))
|
|
206
|
-
|
|
207
|
-
await expect(ext.monitorOperation('op_bad')).rejects.toThrow('Operation timeout')
|
|
208
|
-
})
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
describe('close', () => {
|
|
212
|
-
it('should close all three closeable clients', () => {
|
|
213
|
-
const ext = new RoboSystemsExtensions()
|
|
214
|
-
|
|
215
|
-
const queryCloseSpy = vi.spyOn(ext.query, 'close')
|
|
216
|
-
const agentCloseSpy = vi.spyOn(ext.agent, 'close')
|
|
217
|
-
const operationsCloseSpy = vi.spyOn(ext.operations, 'closeAll')
|
|
218
|
-
|
|
219
|
-
ext.close()
|
|
220
|
-
|
|
221
|
-
expect(queryCloseSpy).toHaveBeenCalled()
|
|
222
|
-
expect(agentCloseSpy).toHaveBeenCalled()
|
|
223
|
-
expect(operationsCloseSpy).toHaveBeenCalled()
|
|
224
|
-
})
|
|
225
|
-
|
|
226
|
-
it('should not throw when called multiple times', () => {
|
|
227
|
-
const ext = new RoboSystemsExtensions()
|
|
228
|
-
|
|
229
|
-
expect(() => {
|
|
230
|
-
ext.close()
|
|
231
|
-
ext.close()
|
|
232
|
-
}).not.toThrow()
|
|
233
|
-
})
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
describe('full config integration', () => {
|
|
237
|
-
it('should properly configure all clients with full config', () => {
|
|
238
|
-
const fullConfig = {
|
|
239
|
-
baseUrl: 'https://api.production.com',
|
|
240
|
-
credentials: 'include' as const,
|
|
241
|
-
token: 'jwt-token-123',
|
|
242
|
-
headers: {
|
|
243
|
-
'X-API-Key': 'key-123',
|
|
244
|
-
'X-Custom': 'value',
|
|
245
|
-
},
|
|
246
|
-
maxRetries: 7,
|
|
247
|
-
retryDelay: 3000,
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const ext = new RoboSystemsExtensions(fullConfig)
|
|
251
|
-
|
|
252
|
-
expect(ext.query).toBeDefined()
|
|
253
|
-
expect(ext.operations).toBeDefined()
|
|
254
|
-
expect(ext.ledger).toBeDefined()
|
|
255
|
-
expect(ext.reports).toBeDefined()
|
|
256
|
-
expect(ext.agent).toBeDefined()
|
|
257
|
-
expect(typeof ext.query.executeQuery).toBe('function')
|
|
258
|
-
expect(typeof ext.operations.monitorOperation).toBe('function')
|
|
259
|
-
})
|
|
260
|
-
|
|
261
|
-
it('should use SDK client baseUrl when no baseUrl provided', () => {
|
|
262
|
-
const ext = new RoboSystemsExtensions({})
|
|
263
|
-
|
|
264
|
-
expect(ext.query).toBeDefined()
|
|
265
|
-
expect(ext.operations).toBeDefined()
|
|
266
|
-
})
|
|
267
|
-
})
|
|
268
|
-
})
|
|
269
|
-
|
|
270
|
-
describe('extensions singleton', () => {
|
|
271
|
-
beforeEach(() => {
|
|
272
|
-
vi.clearAllMocks()
|
|
273
|
-
// Reset the lazy singleton between tests
|
|
274
|
-
vi.resetModules()
|
|
275
|
-
})
|
|
276
|
-
|
|
277
|
-
it('should export extensions object with getter properties', async () => {
|
|
278
|
-
const { extensions } = await import('./index')
|
|
279
|
-
|
|
280
|
-
expect(extensions).toBeDefined()
|
|
281
|
-
expect(typeof extensions.monitorOperation).toBe('function')
|
|
282
|
-
expect(typeof extensions.createSSEClient).toBe('function')
|
|
283
|
-
expect(typeof extensions.close).toBe('function')
|
|
284
|
-
})
|
|
285
|
-
|
|
286
|
-
it('should lazily create clients on first access', async () => {
|
|
287
|
-
const { extensions } = await import('./index')
|
|
288
|
-
|
|
289
|
-
const query = extensions.query
|
|
290
|
-
expect(query).toBeDefined()
|
|
291
|
-
expect(typeof query.executeQuery).toBe('function')
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
it('should return same instance on repeated access', async () => {
|
|
295
|
-
const { extensions } = await import('./index')
|
|
296
|
-
|
|
297
|
-
const query1 = extensions.query
|
|
298
|
-
const query2 = extensions.query
|
|
299
|
-
expect(query1).toBe(query2)
|
|
300
|
-
})
|
|
301
|
-
|
|
302
|
-
it('should expose all five client getters', async () => {
|
|
303
|
-
const { extensions } = await import('./index')
|
|
304
|
-
|
|
305
|
-
expect(typeof extensions.query.executeQuery).toBe('function')
|
|
306
|
-
expect(typeof extensions.agent.executeQuery).toBe('function')
|
|
307
|
-
expect(typeof extensions.operations.monitorOperation).toBe('function')
|
|
308
|
-
expect(typeof extensions.ledger.listAccounts).toBe('function')
|
|
309
|
-
expect(typeof extensions.reports.create).toBe('function')
|
|
310
|
-
})
|
|
311
|
-
|
|
312
|
-
it('should create SSEClient from singleton', async () => {
|
|
313
|
-
const { extensions } = await import('./index')
|
|
314
|
-
|
|
315
|
-
const sseClient = extensions.createSSEClient()
|
|
316
|
-
expect(typeof sseClient.connect).toBe('function')
|
|
317
|
-
expect(typeof sseClient.close).toBe('function')
|
|
318
|
-
})
|
|
319
|
-
|
|
320
|
-
it('should close without error', async () => {
|
|
321
|
-
const { extensions } = await import('./index')
|
|
322
|
-
|
|
323
|
-
// Access to initialize
|
|
324
|
-
extensions.query
|
|
325
|
-
expect(() => extensions.close()).not.toThrow()
|
|
326
|
-
})
|
|
327
|
-
})
|
|
328
|
-
|
|
329
|
-
describe('convenience functions', () => {
|
|
330
|
-
let mockFetch: any
|
|
331
|
-
|
|
332
|
-
beforeEach(async () => {
|
|
333
|
-
vi.clearAllMocks()
|
|
334
|
-
vi.resetModules()
|
|
335
|
-
mockFetch = vi.fn()
|
|
336
|
-
global.fetch = mockFetch
|
|
337
|
-
globalThis.fetch = mockFetch
|
|
338
|
-
})
|
|
339
|
-
|
|
340
|
-
it('should export executeQuery function', async () => {
|
|
341
|
-
const { executeQuery } = await import('./index')
|
|
342
|
-
expect(typeof executeQuery).toBe('function')
|
|
343
|
-
})
|
|
344
|
-
|
|
345
|
-
it('should export streamQuery function', async () => {
|
|
346
|
-
const { streamQuery } = await import('./index')
|
|
347
|
-
expect(typeof streamQuery).toBe('function')
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
it('should export agentQuery function', async () => {
|
|
351
|
-
const { agentQuery } = await import('./index')
|
|
352
|
-
expect(typeof agentQuery).toBe('function')
|
|
353
|
-
})
|
|
354
|
-
|
|
355
|
-
it('should export analyzeFinancials function', async () => {
|
|
356
|
-
const { analyzeFinancials } = await import('./index')
|
|
357
|
-
expect(typeof analyzeFinancials).toBe('function')
|
|
358
|
-
})
|
|
359
|
-
|
|
360
|
-
it('should export monitorOperation function', async () => {
|
|
361
|
-
const mod = await import('./index')
|
|
362
|
-
expect(typeof mod.monitorOperation).toBe('function')
|
|
363
|
-
})
|
|
364
|
-
})
|
|
365
|
-
|
|
366
|
-
describe('re-exports', () => {
|
|
367
|
-
it('should re-export all client classes', async () => {
|
|
368
|
-
const mod = await import('./index')
|
|
369
|
-
|
|
370
|
-
// Verify these are constructor functions (classes)
|
|
371
|
-
expect(typeof mod.QueryClient).toBe('function')
|
|
372
|
-
expect(typeof mod.AgentClient).toBe('function')
|
|
373
|
-
expect(typeof mod.OperationClient).toBe('function')
|
|
374
|
-
expect(typeof mod.SSEClient).toBe('function')
|
|
375
|
-
expect(typeof mod.LedgerClient).toBe('function')
|
|
376
|
-
expect(typeof mod.ReportClient).toBe('function')
|
|
377
|
-
|
|
378
|
-
// Verify they can be instantiated
|
|
379
|
-
const q = new mod.QueryClient({ baseUrl: 'http://test.com' })
|
|
380
|
-
expect(typeof q.executeQuery).toBe('function')
|
|
381
|
-
})
|
|
382
|
-
|
|
383
|
-
it('should re-export config functions', async () => {
|
|
384
|
-
const mod = await import('./index')
|
|
385
|
-
|
|
386
|
-
expect(typeof mod.setSDKExtensionsConfig).toBe('function')
|
|
387
|
-
expect(typeof mod.getSDKExtensionsConfig).toBe('function')
|
|
388
|
-
expect(typeof mod.resetSDKExtensionsConfig).toBe('function')
|
|
389
|
-
expect(typeof mod.extractJWTFromHeader).toBe('function')
|
|
390
|
-
expect(typeof mod.isValidJWT).toBe('function')
|
|
391
|
-
expect(typeof mod.configureWithJWT).toBe('function')
|
|
392
|
-
expect(typeof mod.getEnvironmentConfig).toBe('function')
|
|
393
|
-
})
|
|
394
|
-
|
|
395
|
-
it('should re-export React hooks', async () => {
|
|
396
|
-
const mod = await import('./index')
|
|
397
|
-
|
|
398
|
-
expect(typeof mod.useQuery).toBe('function')
|
|
399
|
-
expect(typeof mod.useStreamingQuery).toBe('function')
|
|
400
|
-
expect(typeof mod.useOperation).toBe('function')
|
|
401
|
-
expect(typeof mod.useMultipleOperations).toBe('function')
|
|
402
|
-
expect(typeof mod.useSDKClients).toBe('function')
|
|
403
|
-
})
|
|
404
|
-
|
|
405
|
-
it('should re-export error classes', async () => {
|
|
406
|
-
const mod = await import('./index')
|
|
407
|
-
|
|
408
|
-
expect(typeof mod.QueuedQueryError).toBe('function')
|
|
409
|
-
expect(typeof mod.QueuedAgentError).toBe('function')
|
|
410
|
-
})
|
|
411
|
-
|
|
412
|
-
it('should re-export EventType enum', async () => {
|
|
413
|
-
const mod = await import('./index')
|
|
414
|
-
|
|
415
|
-
expect(mod.EventType).toBeDefined()
|
|
416
|
-
expect(mod.EventType.OPERATION_COMPLETED).toBeDefined()
|
|
417
|
-
expect(mod.EventType.OPERATION_ERROR).toBeDefined()
|
|
418
|
-
expect(mod.EventType.OPERATION_PROGRESS).toBeDefined()
|
|
419
|
-
})
|
|
420
|
-
})
|
package/sdk-extensions/index.ts
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RoboSystems SDK Extensions
|
|
3
|
-
* Enhanced clients with SSE support for the RoboSystems API
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { client } from '../sdk/client.gen'
|
|
7
|
-
import { extractTokenFromSDKClient } from './config'
|
|
8
|
-
import { OperationClient } from './OperationClient'
|
|
9
|
-
import { QueryClient } from './QueryClient'
|
|
10
|
-
import { AgentClient } from './AgentClient'
|
|
11
|
-
import { SSEClient } from './SSEClient'
|
|
12
|
-
import { LedgerClient } from './LedgerClient'
|
|
13
|
-
import { ReportClient } from './ReportClient'
|
|
14
|
-
|
|
15
|
-
export interface RoboSystemsExtensionConfig {
|
|
16
|
-
baseUrl?: string
|
|
17
|
-
credentials?: 'include' | 'same-origin' | 'omit'
|
|
18
|
-
token?: string // JWT token for authentication
|
|
19
|
-
headers?: Record<string, string>
|
|
20
|
-
maxRetries?: number
|
|
21
|
-
retryDelay?: number
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Properly typed configuration interface
|
|
25
|
-
interface ResolvedConfig {
|
|
26
|
-
baseUrl: string
|
|
27
|
-
credentials: 'include' | 'same-origin' | 'omit'
|
|
28
|
-
token?: string
|
|
29
|
-
headers?: Record<string, string>
|
|
30
|
-
maxRetries: number
|
|
31
|
-
retryDelay: number
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export class RoboSystemsExtensions {
|
|
35
|
-
public readonly query: QueryClient
|
|
36
|
-
public readonly agent: AgentClient
|
|
37
|
-
public readonly operations: OperationClient
|
|
38
|
-
public readonly ledger: LedgerClient
|
|
39
|
-
public readonly reports: ReportClient
|
|
40
|
-
private config: ResolvedConfig
|
|
41
|
-
|
|
42
|
-
constructor(config: RoboSystemsExtensionConfig = {}) {
|
|
43
|
-
// Get base URL from SDK client config or use provided/default
|
|
44
|
-
const sdkConfig = client.getConfig()
|
|
45
|
-
|
|
46
|
-
// Extract JWT token using centralized logic
|
|
47
|
-
const token = config.token || extractTokenFromSDKClient()
|
|
48
|
-
|
|
49
|
-
this.config = {
|
|
50
|
-
baseUrl: config.baseUrl || sdkConfig.baseUrl || 'http://localhost:8000',
|
|
51
|
-
credentials: config.credentials || 'include',
|
|
52
|
-
token,
|
|
53
|
-
headers: config.headers,
|
|
54
|
-
maxRetries: config.maxRetries || 5,
|
|
55
|
-
retryDelay: config.retryDelay || 1000,
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
this.query = new QueryClient({
|
|
59
|
-
baseUrl: this.config.baseUrl,
|
|
60
|
-
credentials: this.config.credentials,
|
|
61
|
-
token: this.config.token,
|
|
62
|
-
headers: this.config.headers,
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
this.agent = new AgentClient({
|
|
66
|
-
baseUrl: this.config.baseUrl,
|
|
67
|
-
credentials: this.config.credentials,
|
|
68
|
-
token: this.config.token,
|
|
69
|
-
headers: this.config.headers,
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
this.operations = new OperationClient({
|
|
73
|
-
baseUrl: this.config.baseUrl,
|
|
74
|
-
credentials: this.config.credentials,
|
|
75
|
-
token: this.config.token,
|
|
76
|
-
maxRetries: this.config.maxRetries,
|
|
77
|
-
retryDelay: this.config.retryDelay,
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
this.ledger = new LedgerClient({
|
|
81
|
-
baseUrl: this.config.baseUrl,
|
|
82
|
-
credentials: this.config.credentials,
|
|
83
|
-
token: this.config.token,
|
|
84
|
-
headers: this.config.headers,
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
this.reports = new ReportClient({
|
|
88
|
-
baseUrl: this.config.baseUrl,
|
|
89
|
-
credentials: this.config.credentials,
|
|
90
|
-
token: this.config.token,
|
|
91
|
-
headers: this.config.headers,
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Convenience method to monitor any operation
|
|
97
|
-
*/
|
|
98
|
-
async monitorOperation(operationId: string, onProgress?: (progress: any) => void): Promise<any> {
|
|
99
|
-
return this.operations.monitorOperation(operationId, { onProgress })
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Create custom SSE client for advanced use cases
|
|
104
|
-
*/
|
|
105
|
-
createSSEClient(): SSEClient {
|
|
106
|
-
return new SSEClient({
|
|
107
|
-
baseUrl: this.config.baseUrl,
|
|
108
|
-
credentials: this.config.credentials,
|
|
109
|
-
token: this.config.token,
|
|
110
|
-
headers: this.config.headers,
|
|
111
|
-
maxRetries: this.config.maxRetries,
|
|
112
|
-
retryDelay: this.config.retryDelay,
|
|
113
|
-
})
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Clean up all active connections
|
|
118
|
-
*/
|
|
119
|
-
close(): void {
|
|
120
|
-
this.query.close()
|
|
121
|
-
this.agent.close()
|
|
122
|
-
this.operations.closeAll()
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Export all types and classes
|
|
127
|
-
export * from './OperationClient'
|
|
128
|
-
export * from './QueryClient'
|
|
129
|
-
export * from './AgentClient'
|
|
130
|
-
export * from './SSEClient'
|
|
131
|
-
export * from './LedgerClient'
|
|
132
|
-
export * from './ReportClient'
|
|
133
|
-
export * from './config'
|
|
134
|
-
|
|
135
|
-
export {
|
|
136
|
-
OperationClient,
|
|
137
|
-
QueryClient,
|
|
138
|
-
AgentClient,
|
|
139
|
-
SSEClient,
|
|
140
|
-
LedgerClient,
|
|
141
|
-
ReportClient,
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Export React hooks
|
|
145
|
-
export {
|
|
146
|
-
useMultipleOperations,
|
|
147
|
-
useOperation,
|
|
148
|
-
useQuery,
|
|
149
|
-
useSDKClients,
|
|
150
|
-
useStreamingQuery,
|
|
151
|
-
} from './hooks'
|
|
152
|
-
|
|
153
|
-
// Lazy initialization of default instance
|
|
154
|
-
let _extensions: RoboSystemsExtensions | null = null
|
|
155
|
-
|
|
156
|
-
function getExtensions(): RoboSystemsExtensions {
|
|
157
|
-
if (!_extensions) {
|
|
158
|
-
_extensions = new RoboSystemsExtensions()
|
|
159
|
-
}
|
|
160
|
-
return _extensions
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export const extensions = {
|
|
164
|
-
get query() {
|
|
165
|
-
return getExtensions().query
|
|
166
|
-
},
|
|
167
|
-
get agent() {
|
|
168
|
-
return getExtensions().agent
|
|
169
|
-
},
|
|
170
|
-
get operations() {
|
|
171
|
-
return getExtensions().operations
|
|
172
|
-
},
|
|
173
|
-
get ledger() {
|
|
174
|
-
return getExtensions().ledger
|
|
175
|
-
},
|
|
176
|
-
get reports() {
|
|
177
|
-
return getExtensions().reports
|
|
178
|
-
},
|
|
179
|
-
monitorOperation: (operationId: string, onProgress?: (progress: any) => void) =>
|
|
180
|
-
getExtensions().monitorOperation(operationId, onProgress),
|
|
181
|
-
createSSEClient: () => getExtensions().createSSEClient(),
|
|
182
|
-
close: () => getExtensions().close(),
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Export convenience functions that use the default instance
|
|
186
|
-
export const monitorOperation = (operationId: string, onProgress?: (progress: any) => void) =>
|
|
187
|
-
getExtensions().monitorOperation(operationId, onProgress)
|
|
188
|
-
|
|
189
|
-
export const executeQuery = (graphId: string, query: string, parameters?: Record<string, any>) =>
|
|
190
|
-
getExtensions().query.query(graphId, query, parameters)
|
|
191
|
-
|
|
192
|
-
export const streamQuery = (
|
|
193
|
-
graphId: string,
|
|
194
|
-
query: string,
|
|
195
|
-
parameters?: Record<string, any>,
|
|
196
|
-
chunkSize?: number
|
|
197
|
-
) => getExtensions().query.streamQuery(graphId, query, parameters, chunkSize)
|
|
198
|
-
|
|
199
|
-
export const agentQuery = (graphId: string, message: string, context?: Record<string, any>) =>
|
|
200
|
-
getExtensions().agent.query(graphId, message, context)
|
|
201
|
-
|
|
202
|
-
export const analyzeFinancials = (graphId: string, message: string) =>
|
|
203
|
-
getExtensions().agent.analyzeFinancials(graphId, message)
|