@sixb/client 0.1.1 → 0.1.3
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/README.md +2 -2
- package/dist/agent-streams.d.ts +26 -3
- package/dist/agent-streams.d.ts.map +1 -1
- package/dist/api.d.ts +6 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +2 -2
- package/dist/browser.js.map +1 -1
- package/dist/{chunk-2vsyqn32.js → chunk-6esh0dxx.js} +1 -1
- package/dist/{chunk-hkrfakyt.js → chunk-7ts981a8.js} +2 -2
- package/dist/{chunk-h8bd95xf.js → chunk-eyd61e4t.js} +55 -2
- package/dist/chunk-eyd61e4t.js.map +19 -0
- package/dist/{chunk-1mnf48s9.js → chunk-heqezbjc.js} +2 -2
- package/dist/{chunk-dkd2wgva.js → chunk-hfk246y4.js} +40 -28
- package/dist/{chunk-dkd2wgva.js.map → chunk-hfk246y4.js.map} +3 -3
- package/dist/{chunk-w527w02k.js → chunk-mpgzkmwc.js} +2 -74
- package/dist/chunk-mpgzkmwc.js.map +10 -0
- package/dist/{chunk-6w5w9e75.js → chunk-yjank04c.js} +27 -12
- package/dist/chunk-yjank04c.js.map +10 -0
- package/dist/client-provider.d.ts +8 -0
- package/dist/client-provider.d.ts.map +1 -0
- package/dist/connectors/connection.d.ts +50 -0
- package/dist/connectors/connection.d.ts.map +1 -0
- package/dist/connectors/index.d.ts +4 -0
- package/dist/connectors/index.d.ts.map +1 -0
- package/dist/connectors/mutations.d.ts +62 -0
- package/dist/connectors/mutations.d.ts.map +1 -0
- package/dist/connectors/queries.d.ts +536 -0
- package/dist/connectors/queries.d.ts.map +1 -0
- package/dist/generated/@tanstack/react-query.gen.d.ts +5679 -809
- package/dist/generated/@tanstack/react-query.gen.d.ts.map +1 -1
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/sdk.gen.d.ts +41 -1
- package/dist/generated/sdk.gen.d.ts.map +1 -1
- package/dist/generated/types.gen.d.ts +2330 -218
- package/dist/generated/types.gen.d.ts.map +1 -1
- package/dist/hooks.d.ts +2 -0
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +1180 -360
- package/dist/hooks.js.map +11 -6
- package/dist/index.js +29 -11
- package/dist/index.js.map +1 -1
- package/dist/logs.js +3 -3
- package/dist/models.d.ts +0 -31
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +23 -7
- package/dist/models.js.map +1 -1
- package/dist/query-hooks.d.ts +2 -6
- package/dist/query-hooks.d.ts.map +1 -1
- package/dist/query.js +3 -3
- package/dist/useAgentActivityStream.d.ts +14 -0
- package/dist/useAgentActivityStream.d.ts.map +1 -0
- package/package.json +6 -2
- package/src/agent-streams.ts +68 -45
- package/src/api.ts +26 -2
- package/src/browser.ts +1 -1
- package/src/client-provider.ts +12 -0
- package/src/connectors/connection.ts +443 -0
- package/src/connectors/index.ts +12 -0
- package/src/connectors/mutations.ts +417 -0
- package/src/connectors/queries.ts +150 -0
- package/src/generated/@tanstack/react-query.gen.ts +346 -0
- package/src/generated/index.ts +60 -0
- package/src/generated/sdk.gen.ts +189 -0
- package/src/generated/types.gen.ts +3048 -254
- package/src/hooks.ts +6 -0
- package/src/models.ts +0 -103
- package/src/query-hooks.ts +8 -14
- package/src/useAgentActivityStream.ts +48 -0
- package/dist/chunk-6w5w9e75.js.map +0 -10
- package/dist/chunk-h8bd95xf.js.map +0 -19
- package/dist/chunk-w527w02k.js.map +0 -10
- /package/dist/{chunk-2vsyqn32.js.map → chunk-6esh0dxx.js.map} +0 -0
- /package/dist/{chunk-hkrfakyt.js.map → chunk-7ts981a8.js.map} +0 -0
- /package/dist/{chunk-1mnf48s9.js.map → chunk-heqezbjc.js.map} +0 -0
package/dist/hooks.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
ActionRunFailedError,
|
|
4
4
|
buildEventPredicate,
|
|
5
|
+
createAgentActivitySocket,
|
|
5
6
|
createAgentRunSocket,
|
|
6
7
|
createEventSocket,
|
|
7
8
|
createSixbAgentsWebSocketUrl,
|
|
@@ -17,22 +18,25 @@ import {
|
|
|
17
18
|
telemetryUpdateFromEvent,
|
|
18
19
|
telemetryUpdateKey,
|
|
19
20
|
uploadFile
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import"./chunk-
|
|
21
|
+
} from "./chunk-hfk246y4.js";
|
|
22
|
+
import"./chunk-6esh0dxx.js";
|
|
22
23
|
import {
|
|
23
24
|
decodeObjectId,
|
|
24
25
|
encodeObjectId,
|
|
25
26
|
toObjectDetail,
|
|
26
27
|
toObjectSummary,
|
|
27
28
|
toTelemetryHistoryWithRange
|
|
28
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-mpgzkmwc.js";
|
|
29
30
|
import"./chunk-trpg18dp.js";
|
|
30
31
|
import {
|
|
31
32
|
createHttpQueryExecutor
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import
|
|
33
|
+
} from "./chunk-7ts981a8.js";
|
|
34
|
+
import {
|
|
35
|
+
isSixbApiError
|
|
36
|
+
} from "./chunk-yjank04c.js";
|
|
34
37
|
import {
|
|
35
38
|
abortFileUpload,
|
|
39
|
+
addConnectorConnection,
|
|
36
40
|
appendTelemetry,
|
|
37
41
|
cancelAgentRun,
|
|
38
42
|
cancelWorkflowIntervention,
|
|
@@ -47,6 +51,7 @@ import {
|
|
|
47
51
|
createAuthServiceAccountAccessToken,
|
|
48
52
|
createFileUpload,
|
|
49
53
|
disableAuthServiceAccount,
|
|
54
|
+
disconnectConnectorConnection,
|
|
50
55
|
existsObjects,
|
|
51
56
|
facetObjects,
|
|
52
57
|
getAction,
|
|
@@ -56,12 +61,14 @@ import {
|
|
|
56
61
|
getAgentMessageFileContent,
|
|
57
62
|
getAgentRun,
|
|
58
63
|
getAgentThread,
|
|
64
|
+
getAiAccountingOverview,
|
|
59
65
|
getAuthAccessManagementOptions,
|
|
60
66
|
getAuthInvitationOptions,
|
|
61
67
|
getAuthMembershipOptions,
|
|
62
68
|
getAuthSession,
|
|
63
69
|
getBulkTelemetryHistory,
|
|
64
70
|
getConnector,
|
|
71
|
+
getConnectorConnectionRun,
|
|
65
72
|
getDataset,
|
|
66
73
|
getDatasetVersion,
|
|
67
74
|
getLatestTelemetry,
|
|
@@ -89,12 +96,14 @@ import {
|
|
|
89
96
|
listAgentThreadRuns,
|
|
90
97
|
listAgentThreads,
|
|
91
98
|
listAgents,
|
|
99
|
+
listAiModelCalls,
|
|
92
100
|
listAuthAccessTokens,
|
|
93
101
|
listAuthInvitations,
|
|
94
102
|
listAuthMembers,
|
|
95
103
|
listAuthServiceAccountAccessTokens,
|
|
96
104
|
listAuthServiceAccounts,
|
|
97
105
|
listAuthSessions,
|
|
106
|
+
listConnectorConnections,
|
|
98
107
|
listConnectors,
|
|
99
108
|
listDatasetRows,
|
|
100
109
|
listDatasetVersions,
|
|
@@ -119,6 +128,7 @@ import {
|
|
|
119
128
|
postAgentThreadMessage,
|
|
120
129
|
queryObjects,
|
|
121
130
|
reactivateAuthMember,
|
|
131
|
+
reauthorizeConnectorConnection,
|
|
122
132
|
removeObjectLink,
|
|
123
133
|
requestAction,
|
|
124
134
|
requestPipelineRun,
|
|
@@ -129,10 +139,13 @@ import {
|
|
|
129
139
|
revokeAuthInvitation,
|
|
130
140
|
revokeAuthServiceAccountAccessToken,
|
|
131
141
|
revokeAuthSession,
|
|
142
|
+
revokeConnectorConnection,
|
|
132
143
|
searchObjects,
|
|
144
|
+
selectConnectorConnectionRunAccount,
|
|
133
145
|
signFileUploadPart,
|
|
134
146
|
signOut,
|
|
135
147
|
signOutAll,
|
|
148
|
+
startConnectorConnectionRun,
|
|
136
149
|
submitWorkflowIntervention,
|
|
137
150
|
suspendAuthMember,
|
|
138
151
|
updateAuthMemberGroups,
|
|
@@ -140,217 +153,29 @@ import {
|
|
|
140
153
|
uploadFileRaw,
|
|
141
154
|
upsertObject,
|
|
142
155
|
upsertObjectLink
|
|
143
|
-
} from "./chunk-
|
|
156
|
+
} from "./chunk-eyd61e4t.js";
|
|
144
157
|
|
|
145
158
|
// src/hooks.ts
|
|
146
|
-
import { infiniteQueryOptions as infiniteQueryOptions3, queryOptions as
|
|
147
|
-
// src/
|
|
148
|
-
import {
|
|
149
|
-
import { startTransition, useCallback, useEffect as useEffect2, useRef, useState } from "react";
|
|
159
|
+
import { infiniteQueryOptions as infiniteQueryOptions3, queryOptions as queryOptions4 } from "@tanstack/react-query";
|
|
160
|
+
// src/connectors/connection.ts
|
|
161
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
150
162
|
|
|
151
|
-
// src/
|
|
152
|
-
import {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const subscribers = new Set;
|
|
157
|
-
const closeDelayMs = options.closeDelayMs ?? DEFAULT_CLOSE_DELAY_MS;
|
|
158
|
-
let socket = null;
|
|
159
|
-
let state = DISCONNECTED;
|
|
160
|
-
let latestCursor;
|
|
161
|
-
let closeTimer = null;
|
|
162
|
-
const cancelPendingClose = () => {
|
|
163
|
-
if (closeTimer) {
|
|
164
|
-
clearTimeout(closeTimer);
|
|
165
|
-
closeTimer = null;
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
const teardown = () => {
|
|
169
|
-
socket?.close();
|
|
170
|
-
socket = null;
|
|
171
|
-
state = DISCONNECTED;
|
|
172
|
-
};
|
|
173
|
-
const open = () => {
|
|
174
|
-
if (socket)
|
|
175
|
-
return;
|
|
176
|
-
socket = createEventSocket({
|
|
177
|
-
baseUrl: options.baseUrl,
|
|
178
|
-
afterCursor: latestCursor,
|
|
179
|
-
onEvent: (event) => {
|
|
180
|
-
latestCursor = event.cursor;
|
|
181
|
-
for (const subscriber of subscribers) {
|
|
182
|
-
if (subscriber.matches(event))
|
|
183
|
-
subscriber.handler(event);
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
onError: (message) => {
|
|
187
|
-
for (const subscriber of subscribers)
|
|
188
|
-
subscriber.options?.onError?.(message);
|
|
189
|
-
},
|
|
190
|
-
onStateChange: (next) => {
|
|
191
|
-
state = next;
|
|
192
|
-
for (const subscriber of subscribers)
|
|
193
|
-
subscriber.options?.onStateChange?.(next);
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
};
|
|
197
|
-
return {
|
|
198
|
-
register(filter, handler, registrationOptions) {
|
|
199
|
-
cancelPendingClose();
|
|
200
|
-
const subscriber = {
|
|
201
|
-
matches: buildEventPredicate(filter),
|
|
202
|
-
handler,
|
|
203
|
-
options: registrationOptions
|
|
204
|
-
};
|
|
205
|
-
subscribers.add(subscriber);
|
|
206
|
-
registrationOptions?.onStateChange?.(state);
|
|
207
|
-
open();
|
|
208
|
-
return () => {
|
|
209
|
-
subscribers.delete(subscriber);
|
|
210
|
-
if (subscribers.size === 0) {
|
|
211
|
-
cancelPendingClose();
|
|
212
|
-
closeTimer = setTimeout(() => {
|
|
213
|
-
closeTimer = null;
|
|
214
|
-
teardown();
|
|
215
|
-
}, closeDelayMs);
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
},
|
|
219
|
-
close() {
|
|
220
|
-
cancelPendingClose();
|
|
221
|
-
subscribers.clear();
|
|
222
|
-
teardown();
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
var EventsSocketContext = createContext(null);
|
|
227
|
-
function useEventsRegistry() {
|
|
228
|
-
return useContext(EventsSocketContext);
|
|
229
|
-
}
|
|
230
|
-
function SixbEventsProvider(props) {
|
|
231
|
-
const registry = useMemo(() => createEventsRegistry({ baseUrl: props.baseUrl }), [props.baseUrl]);
|
|
232
|
-
useEffect(() => () => registry.close(), [registry]);
|
|
233
|
-
return createElement(EventsSocketContext.Provider, { value: registry }, props.children);
|
|
234
|
-
}
|
|
163
|
+
// src/connectors/mutations.ts
|
|
164
|
+
import {
|
|
165
|
+
useMutation,
|
|
166
|
+
useQueryClient
|
|
167
|
+
} from "@tanstack/react-query";
|
|
235
168
|
|
|
236
|
-
// src/
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
const onEventRef = useRef(onEvent);
|
|
242
|
-
onEventRef.current = onEvent;
|
|
243
|
-
const onErrorRef = useRef(options?.onError);
|
|
244
|
-
onErrorRef.current = options?.onError;
|
|
245
|
-
const [state, setState] = useState(DISCONNECTED2);
|
|
246
|
-
const registry = useEventsRegistry();
|
|
247
|
-
const enabled = options?.enabled ?? true;
|
|
248
|
-
const afterCursor = options?.afterCursor;
|
|
249
|
-
const limit = options?.limit;
|
|
250
|
-
const reconnect = options?.reconnect;
|
|
251
|
-
const reconnectDelayMs = options?.reconnectDelayMs;
|
|
252
|
-
const handshakeTimeoutMs = options?.handshakeTimeoutMs;
|
|
253
|
-
const irKey = JSON.stringify(builder.ir);
|
|
254
|
-
useEffect2(() => {
|
|
255
|
-
if (!enabled) {
|
|
256
|
-
setState(DISCONNECTED2);
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
const handler = (event) => onEventRef.current(event);
|
|
260
|
-
const onError = (message) => onErrorRef.current?.(message);
|
|
261
|
-
if (registry) {
|
|
262
|
-
return registry.register(builderRef.current.ir, handler, { onError, onStateChange: setState });
|
|
263
|
-
}
|
|
264
|
-
return builderRef.current.subscribe((event) => onEventRef.current(event), {
|
|
265
|
-
afterCursor,
|
|
266
|
-
limit,
|
|
267
|
-
reconnect,
|
|
268
|
-
reconnectDelayMs,
|
|
269
|
-
handshakeTimeoutMs,
|
|
270
|
-
onError,
|
|
271
|
-
onStateChange: setState
|
|
272
|
-
});
|
|
273
|
-
}, [
|
|
274
|
-
enabled,
|
|
275
|
-
irKey,
|
|
276
|
-
afterCursor,
|
|
277
|
-
limit,
|
|
278
|
-
reconnect,
|
|
279
|
-
reconnectDelayMs,
|
|
280
|
-
handshakeTimeoutMs,
|
|
281
|
-
registry
|
|
282
|
-
]);
|
|
283
|
-
return state;
|
|
284
|
-
}
|
|
285
|
-
function useLatest(builder, options) {
|
|
286
|
-
const [values, setValues] = useState({});
|
|
287
|
-
const irKey = JSON.stringify(builder.ir);
|
|
288
|
-
const enabled = options?.enabled ?? true;
|
|
289
|
-
useEffect2(() => {
|
|
290
|
-
setValues({});
|
|
291
|
-
}, [irKey, enabled]);
|
|
292
|
-
const { connected } = useEvents(builder, (event) => {
|
|
293
|
-
const update = telemetryUpdateFromEvent(event);
|
|
294
|
-
setValues((prev) => ({ ...prev, [update.propertyId]: update }));
|
|
295
|
-
}, options);
|
|
296
|
-
return { values, connected };
|
|
297
|
-
}
|
|
298
|
-
function useLatestByObject(builder, options) {
|
|
299
|
-
const [byObject, setByObject] = useState({});
|
|
300
|
-
const irKey = JSON.stringify(builder.ir);
|
|
301
|
-
const enabled = options?.enabled ?? true;
|
|
302
|
-
useEffect2(() => {
|
|
303
|
-
setByObject({});
|
|
304
|
-
}, [irKey, enabled]);
|
|
305
|
-
const { connected } = useEvents(builder, (event) => {
|
|
306
|
-
const update = telemetryUpdateFromEvent(event);
|
|
307
|
-
setByObject((prev) => ({
|
|
308
|
-
...prev,
|
|
309
|
-
[update.objectId]: { ...prev[update.objectId], [update.propertyId]: update }
|
|
310
|
-
}));
|
|
311
|
-
}, options);
|
|
312
|
-
return { byObject, connected };
|
|
169
|
+
// src/client-provider.ts
|
|
170
|
+
import { createContext, createElement, useContext } from "react";
|
|
171
|
+
var SixbClientContext = createContext(undefined);
|
|
172
|
+
function SixbProvider(props) {
|
|
173
|
+
return createElement(SixbClientContext.Provider, { value: props.client }, props.children);
|
|
313
174
|
}
|
|
314
|
-
function
|
|
315
|
-
|
|
316
|
-
const resolveKeysRef = useRef(resolveKeys);
|
|
317
|
-
resolveKeysRef.current = resolveKeys;
|
|
318
|
-
const pendingRef = useRef(new Map);
|
|
319
|
-
const timerRef = useRef(null);
|
|
320
|
-
const debounceMs = options?.debounceMs ?? 0;
|
|
321
|
-
const flush = useCallback(() => {
|
|
322
|
-
if (timerRef.current) {
|
|
323
|
-
clearTimeout(timerRef.current);
|
|
324
|
-
timerRef.current = null;
|
|
325
|
-
}
|
|
326
|
-
const keys = Array.from(pendingRef.current.values());
|
|
327
|
-
pendingRef.current.clear();
|
|
328
|
-
if (keys.length === 0)
|
|
329
|
-
return;
|
|
330
|
-
startTransition(() => {
|
|
331
|
-
for (const queryKey of keys) {
|
|
332
|
-
queryClient.invalidateQueries({ queryKey });
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
}, [queryClient]);
|
|
336
|
-
const flushRef = useRef(flush);
|
|
337
|
-
flushRef.current = flush;
|
|
338
|
-
const state = useEvents(builder, (event) => {
|
|
339
|
-
for (const key of resolveKeysRef.current(event)) {
|
|
340
|
-
pendingRef.current.set(JSON.stringify(key), key);
|
|
341
|
-
}
|
|
342
|
-
if (debounceMs > 0) {
|
|
343
|
-
if (!timerRef.current)
|
|
344
|
-
timerRef.current = setTimeout(flush, debounceMs);
|
|
345
|
-
} else {
|
|
346
|
-
flush();
|
|
347
|
-
}
|
|
348
|
-
}, options);
|
|
349
|
-
useEffect2(() => {
|
|
350
|
-
return () => flushRef.current();
|
|
351
|
-
}, []);
|
|
352
|
-
return state;
|
|
175
|
+
function useSixbProviderClient() {
|
|
176
|
+
return useContext(SixbClientContext);
|
|
353
177
|
}
|
|
178
|
+
|
|
354
179
|
// src/generated/@tanstack/react-query.gen.ts
|
|
355
180
|
import {
|
|
356
181
|
infiniteQueryOptions,
|
|
@@ -759,10 +584,10 @@ var reactivateAuthMemberMutation = (options) => {
|
|
|
759
584
|
};
|
|
760
585
|
return mutationOptions;
|
|
761
586
|
};
|
|
762
|
-
var
|
|
763
|
-
var
|
|
587
|
+
var getAiAccountingOverviewQueryKey = (options) => createQueryKey("getAiAccountingOverview", options);
|
|
588
|
+
var getAiAccountingOverviewOptions = (options) => queryOptions({
|
|
764
589
|
queryFn: async ({ queryKey, signal }) => {
|
|
765
|
-
const { data } = await
|
|
590
|
+
const { data } = await getAiAccountingOverview({
|
|
766
591
|
...options,
|
|
767
592
|
...queryKey[0],
|
|
768
593
|
signal,
|
|
@@ -770,12 +595,12 @@ var getProjectInfoOptions = (options) => queryOptions({
|
|
|
770
595
|
});
|
|
771
596
|
return data;
|
|
772
597
|
},
|
|
773
|
-
queryKey:
|
|
598
|
+
queryKey: getAiAccountingOverviewQueryKey(options)
|
|
774
599
|
});
|
|
775
|
-
var
|
|
776
|
-
var
|
|
600
|
+
var listAiModelCallsQueryKey = (options) => createQueryKey("listAiModelCalls", options);
|
|
601
|
+
var listAiModelCallsOptions = (options) => queryOptions({
|
|
777
602
|
queryFn: async ({ queryKey, signal }) => {
|
|
778
|
-
const { data } = await
|
|
603
|
+
const { data } = await listAiModelCalls({
|
|
779
604
|
...options,
|
|
780
605
|
...queryKey[0],
|
|
781
606
|
signal,
|
|
@@ -783,25 +608,31 @@ var getStatusOptions = (options) => queryOptions({
|
|
|
783
608
|
});
|
|
784
609
|
return data;
|
|
785
610
|
},
|
|
786
|
-
queryKey:
|
|
611
|
+
queryKey: listAiModelCallsQueryKey(options)
|
|
787
612
|
});
|
|
788
|
-
var
|
|
789
|
-
var
|
|
790
|
-
queryFn: async ({ queryKey, signal }) => {
|
|
791
|
-
const
|
|
613
|
+
var listAiModelCallsInfiniteQueryKey = (options) => createQueryKey("listAiModelCalls", options, true);
|
|
614
|
+
var listAiModelCallsInfiniteOptions = (options) => infiniteQueryOptions({
|
|
615
|
+
queryFn: async ({ pageParam, queryKey, signal }) => {
|
|
616
|
+
const page = typeof pageParam === "object" ? pageParam : {
|
|
617
|
+
query: {
|
|
618
|
+
offset: pageParam
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
const params = createInfiniteParams(queryKey, page);
|
|
622
|
+
const { data } = await listAiModelCalls({
|
|
792
623
|
...options,
|
|
793
|
-
...
|
|
624
|
+
...params,
|
|
794
625
|
signal,
|
|
795
626
|
throwOnError: true
|
|
796
627
|
});
|
|
797
628
|
return data;
|
|
798
629
|
},
|
|
799
|
-
queryKey:
|
|
630
|
+
queryKey: listAiModelCallsInfiniteQueryKey(options)
|
|
800
631
|
});
|
|
801
|
-
var
|
|
802
|
-
var
|
|
632
|
+
var getProjectInfoQueryKey = (options) => createQueryKey("getProjectInfo", options);
|
|
633
|
+
var getProjectInfoOptions = (options) => queryOptions({
|
|
803
634
|
queryFn: async ({ queryKey, signal }) => {
|
|
804
|
-
const { data } = await
|
|
635
|
+
const { data } = await getProjectInfo({
|
|
805
636
|
...options,
|
|
806
637
|
...queryKey[0],
|
|
807
638
|
signal,
|
|
@@ -809,12 +640,12 @@ var getConnectorOptions = (options) => queryOptions({
|
|
|
809
640
|
});
|
|
810
641
|
return data;
|
|
811
642
|
},
|
|
812
|
-
queryKey:
|
|
643
|
+
queryKey: getProjectInfoQueryKey(options)
|
|
813
644
|
});
|
|
814
|
-
var
|
|
815
|
-
var
|
|
645
|
+
var getStatusQueryKey = (options) => createQueryKey("getStatus", options);
|
|
646
|
+
var getStatusOptions = (options) => queryOptions({
|
|
816
647
|
queryFn: async ({ queryKey, signal }) => {
|
|
817
|
-
const { data } = await
|
|
648
|
+
const { data } = await getStatus({
|
|
818
649
|
...options,
|
|
819
650
|
...queryKey[0],
|
|
820
651
|
signal,
|
|
@@ -822,12 +653,12 @@ var listDatasetsOptions = (options) => queryOptions({
|
|
|
822
653
|
});
|
|
823
654
|
return data;
|
|
824
655
|
},
|
|
825
|
-
queryKey:
|
|
656
|
+
queryKey: getStatusQueryKey(options)
|
|
826
657
|
});
|
|
827
|
-
var
|
|
828
|
-
var
|
|
658
|
+
var listConnectorsQueryKey = (options) => createQueryKey("listConnectors", options);
|
|
659
|
+
var listConnectorsOptions = (options) => queryOptions({
|
|
829
660
|
queryFn: async ({ queryKey, signal }) => {
|
|
830
|
-
const { data } = await
|
|
661
|
+
const { data } = await listConnectors({
|
|
831
662
|
...options,
|
|
832
663
|
...queryKey[0],
|
|
833
664
|
signal,
|
|
@@ -835,12 +666,12 @@ var getDatasetOptions = (options) => queryOptions({
|
|
|
835
666
|
});
|
|
836
667
|
return data;
|
|
837
668
|
},
|
|
838
|
-
queryKey:
|
|
669
|
+
queryKey: listConnectorsQueryKey(options)
|
|
839
670
|
});
|
|
840
|
-
var
|
|
841
|
-
var
|
|
671
|
+
var getConnectorQueryKey = (options) => createQueryKey("getConnector", options);
|
|
672
|
+
var getConnectorOptions = (options) => queryOptions({
|
|
842
673
|
queryFn: async ({ queryKey, signal }) => {
|
|
843
|
-
const { data } = await
|
|
674
|
+
const { data } = await getConnector({
|
|
844
675
|
...options,
|
|
845
676
|
...queryKey[0],
|
|
846
677
|
signal,
|
|
@@ -848,12 +679,12 @@ var listDatasetVersionsOptions = (options) => queryOptions({
|
|
|
848
679
|
});
|
|
849
680
|
return data;
|
|
850
681
|
},
|
|
851
|
-
queryKey:
|
|
682
|
+
queryKey: getConnectorQueryKey(options)
|
|
852
683
|
});
|
|
853
|
-
var
|
|
854
|
-
var
|
|
684
|
+
var listConnectorConnectionsQueryKey = (options) => createQueryKey("listConnectorConnections", options);
|
|
685
|
+
var listConnectorConnectionsOptions = (options) => queryOptions({
|
|
855
686
|
queryFn: async ({ queryKey, signal }) => {
|
|
856
|
-
const { data } = await
|
|
687
|
+
const { data } = await listConnectorConnections({
|
|
857
688
|
...options,
|
|
858
689
|
...queryKey[0],
|
|
859
690
|
signal,
|
|
@@ -861,20 +692,163 @@ var getDatasetVersionOptions = (options) => queryOptions({
|
|
|
861
692
|
});
|
|
862
693
|
return data;
|
|
863
694
|
},
|
|
864
|
-
queryKey:
|
|
695
|
+
queryKey: listConnectorConnectionsQueryKey(options)
|
|
865
696
|
});
|
|
866
|
-
var
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
}
|
|
877
|
-
|
|
697
|
+
var disconnectConnectorConnectionMutation = (options) => {
|
|
698
|
+
const mutationOptions = {
|
|
699
|
+
mutationFn: async (fnOptions) => {
|
|
700
|
+
const { data } = await disconnectConnectorConnection({
|
|
701
|
+
...options,
|
|
702
|
+
...fnOptions,
|
|
703
|
+
throwOnError: true
|
|
704
|
+
});
|
|
705
|
+
return data;
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
return mutationOptions;
|
|
709
|
+
};
|
|
710
|
+
var revokeConnectorConnectionMutation = (options) => {
|
|
711
|
+
const mutationOptions = {
|
|
712
|
+
mutationFn: async (fnOptions) => {
|
|
713
|
+
const { data } = await revokeConnectorConnection({
|
|
714
|
+
...options,
|
|
715
|
+
...fnOptions,
|
|
716
|
+
throwOnError: true
|
|
717
|
+
});
|
|
718
|
+
return data;
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
return mutationOptions;
|
|
722
|
+
};
|
|
723
|
+
var startConnectorConnectionRunMutation = (options) => {
|
|
724
|
+
const mutationOptions = {
|
|
725
|
+
mutationFn: async (fnOptions) => {
|
|
726
|
+
const { data } = await startConnectorConnectionRun({
|
|
727
|
+
...options,
|
|
728
|
+
...fnOptions,
|
|
729
|
+
throwOnError: true
|
|
730
|
+
});
|
|
731
|
+
return data;
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
return mutationOptions;
|
|
735
|
+
};
|
|
736
|
+
var getConnectorConnectionRunQueryKey = (options) => createQueryKey("getConnectorConnectionRun", options);
|
|
737
|
+
var getConnectorConnectionRunOptions = (options) => queryOptions({
|
|
738
|
+
queryFn: async ({ queryKey, signal }) => {
|
|
739
|
+
const { data } = await getConnectorConnectionRun({
|
|
740
|
+
...options,
|
|
741
|
+
...queryKey[0],
|
|
742
|
+
signal,
|
|
743
|
+
throwOnError: true
|
|
744
|
+
});
|
|
745
|
+
return data;
|
|
746
|
+
},
|
|
747
|
+
queryKey: getConnectorConnectionRunQueryKey(options)
|
|
748
|
+
});
|
|
749
|
+
var addConnectorConnectionMutation = (options) => {
|
|
750
|
+
const mutationOptions = {
|
|
751
|
+
mutationFn: async (fnOptions) => {
|
|
752
|
+
const { data } = await addConnectorConnection({
|
|
753
|
+
...options,
|
|
754
|
+
...fnOptions,
|
|
755
|
+
throwOnError: true
|
|
756
|
+
});
|
|
757
|
+
return data;
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
return mutationOptions;
|
|
761
|
+
};
|
|
762
|
+
var selectConnectorConnectionRunAccountMutation = (options) => {
|
|
763
|
+
const mutationOptions = {
|
|
764
|
+
mutationFn: async (fnOptions) => {
|
|
765
|
+
const { data } = await selectConnectorConnectionRunAccount({
|
|
766
|
+
...options,
|
|
767
|
+
...fnOptions,
|
|
768
|
+
throwOnError: true
|
|
769
|
+
});
|
|
770
|
+
return data;
|
|
771
|
+
}
|
|
772
|
+
};
|
|
773
|
+
return mutationOptions;
|
|
774
|
+
};
|
|
775
|
+
var reauthorizeConnectorConnectionMutation = (options) => {
|
|
776
|
+
const mutationOptions = {
|
|
777
|
+
mutationFn: async (fnOptions) => {
|
|
778
|
+
const { data } = await reauthorizeConnectorConnection({
|
|
779
|
+
...options,
|
|
780
|
+
...fnOptions,
|
|
781
|
+
throwOnError: true
|
|
782
|
+
});
|
|
783
|
+
return data;
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
return mutationOptions;
|
|
787
|
+
};
|
|
788
|
+
var listDatasetsQueryKey = (options) => createQueryKey("listDatasets", options);
|
|
789
|
+
var listDatasetsOptions = (options) => queryOptions({
|
|
790
|
+
queryFn: async ({ queryKey, signal }) => {
|
|
791
|
+
const { data } = await listDatasets({
|
|
792
|
+
...options,
|
|
793
|
+
...queryKey[0],
|
|
794
|
+
signal,
|
|
795
|
+
throwOnError: true
|
|
796
|
+
});
|
|
797
|
+
return data;
|
|
798
|
+
},
|
|
799
|
+
queryKey: listDatasetsQueryKey(options)
|
|
800
|
+
});
|
|
801
|
+
var getDatasetQueryKey = (options) => createQueryKey("getDataset", options);
|
|
802
|
+
var getDatasetOptions = (options) => queryOptions({
|
|
803
|
+
queryFn: async ({ queryKey, signal }) => {
|
|
804
|
+
const { data } = await getDataset({
|
|
805
|
+
...options,
|
|
806
|
+
...queryKey[0],
|
|
807
|
+
signal,
|
|
808
|
+
throwOnError: true
|
|
809
|
+
});
|
|
810
|
+
return data;
|
|
811
|
+
},
|
|
812
|
+
queryKey: getDatasetQueryKey(options)
|
|
813
|
+
});
|
|
814
|
+
var listDatasetVersionsQueryKey = (options) => createQueryKey("listDatasetVersions", options);
|
|
815
|
+
var listDatasetVersionsOptions = (options) => queryOptions({
|
|
816
|
+
queryFn: async ({ queryKey, signal }) => {
|
|
817
|
+
const { data } = await listDatasetVersions({
|
|
818
|
+
...options,
|
|
819
|
+
...queryKey[0],
|
|
820
|
+
signal,
|
|
821
|
+
throwOnError: true
|
|
822
|
+
});
|
|
823
|
+
return data;
|
|
824
|
+
},
|
|
825
|
+
queryKey: listDatasetVersionsQueryKey(options)
|
|
826
|
+
});
|
|
827
|
+
var getDatasetVersionQueryKey = (options) => createQueryKey("getDatasetVersion", options);
|
|
828
|
+
var getDatasetVersionOptions = (options) => queryOptions({
|
|
829
|
+
queryFn: async ({ queryKey, signal }) => {
|
|
830
|
+
const { data } = await getDatasetVersion({
|
|
831
|
+
...options,
|
|
832
|
+
...queryKey[0],
|
|
833
|
+
signal,
|
|
834
|
+
throwOnError: true
|
|
835
|
+
});
|
|
836
|
+
return data;
|
|
837
|
+
},
|
|
838
|
+
queryKey: getDatasetVersionQueryKey(options)
|
|
839
|
+
});
|
|
840
|
+
var listDatasetRowsQueryKey = (options) => createQueryKey("listDatasetRows", options);
|
|
841
|
+
var listDatasetRowsOptions = (options) => queryOptions({
|
|
842
|
+
queryFn: async ({ queryKey, signal }) => {
|
|
843
|
+
const { data } = await listDatasetRows({
|
|
844
|
+
...options,
|
|
845
|
+
...queryKey[0],
|
|
846
|
+
signal,
|
|
847
|
+
throwOnError: true
|
|
848
|
+
});
|
|
849
|
+
return data;
|
|
850
|
+
},
|
|
851
|
+
queryKey: listDatasetRowsQueryKey(options)
|
|
878
852
|
});
|
|
879
853
|
var listDatasetRowsInfiniteQueryKey = (options) => createQueryKey("listDatasetRows", options, true);
|
|
880
854
|
var listDatasetRowsInfiniteOptions = (options) => infiniteQueryOptions({
|
|
@@ -1970,80 +1944,865 @@ var listProjectionRunsInfiniteOptions = (options) => infiniteQueryOptions({
|
|
|
1970
1944
|
query: {
|
|
1971
1945
|
offset: pageParam
|
|
1972
1946
|
}
|
|
1973
|
-
};
|
|
1974
|
-
const params = createInfiniteParams(queryKey, page);
|
|
1975
|
-
const { data } = await listProjectionRuns({
|
|
1976
|
-
...options,
|
|
1977
|
-
...params,
|
|
1978
|
-
signal,
|
|
1979
|
-
throwOnError: true
|
|
1980
|
-
});
|
|
1981
|
-
return data;
|
|
1982
|
-
},
|
|
1983
|
-
queryKey: listProjectionRunsInfiniteQueryKey(options)
|
|
1984
|
-
});
|
|
1985
|
-
var getProjectionRunQueryKey = (options) => createQueryKey("getProjectionRun", options);
|
|
1986
|
-
var getProjectionRunOptions = (options) => queryOptions({
|
|
1987
|
-
queryFn: async ({ queryKey, signal }) => {
|
|
1988
|
-
const { data } = await getProjectionRun({
|
|
1989
|
-
...options,
|
|
1990
|
-
...queryKey[0],
|
|
1991
|
-
signal,
|
|
1992
|
-
throwOnError: true
|
|
1947
|
+
};
|
|
1948
|
+
const params = createInfiniteParams(queryKey, page);
|
|
1949
|
+
const { data } = await listProjectionRuns({
|
|
1950
|
+
...options,
|
|
1951
|
+
...params,
|
|
1952
|
+
signal,
|
|
1953
|
+
throwOnError: true
|
|
1954
|
+
});
|
|
1955
|
+
return data;
|
|
1956
|
+
},
|
|
1957
|
+
queryKey: listProjectionRunsInfiniteQueryKey(options)
|
|
1958
|
+
});
|
|
1959
|
+
var getProjectionRunQueryKey = (options) => createQueryKey("getProjectionRun", options);
|
|
1960
|
+
var getProjectionRunOptions = (options) => queryOptions({
|
|
1961
|
+
queryFn: async ({ queryKey, signal }) => {
|
|
1962
|
+
const { data } = await getProjectionRun({
|
|
1963
|
+
...options,
|
|
1964
|
+
...queryKey[0],
|
|
1965
|
+
signal,
|
|
1966
|
+
throwOnError: true
|
|
1967
|
+
});
|
|
1968
|
+
return data;
|
|
1969
|
+
},
|
|
1970
|
+
queryKey: getProjectionRunQueryKey(options)
|
|
1971
|
+
});
|
|
1972
|
+
var listWebhookRunsQueryKey = (options) => createQueryKey("listWebhookRuns", options);
|
|
1973
|
+
var listWebhookRunsOptions = (options) => queryOptions({
|
|
1974
|
+
queryFn: async ({ queryKey, signal }) => {
|
|
1975
|
+
const { data } = await listWebhookRuns({
|
|
1976
|
+
...options,
|
|
1977
|
+
...queryKey[0],
|
|
1978
|
+
signal,
|
|
1979
|
+
throwOnError: true
|
|
1980
|
+
});
|
|
1981
|
+
return data;
|
|
1982
|
+
},
|
|
1983
|
+
queryKey: listWebhookRunsQueryKey(options)
|
|
1984
|
+
});
|
|
1985
|
+
var listWebhookRunsInfiniteQueryKey = (options) => createQueryKey("listWebhookRuns", options, true);
|
|
1986
|
+
var listWebhookRunsInfiniteOptions = (options) => infiniteQueryOptions({
|
|
1987
|
+
queryFn: async ({ pageParam, queryKey, signal }) => {
|
|
1988
|
+
const page = typeof pageParam === "object" ? pageParam : {
|
|
1989
|
+
query: {
|
|
1990
|
+
offset: pageParam
|
|
1991
|
+
}
|
|
1992
|
+
};
|
|
1993
|
+
const params = createInfiniteParams(queryKey, page);
|
|
1994
|
+
const { data } = await listWebhookRuns({
|
|
1995
|
+
...options,
|
|
1996
|
+
...params,
|
|
1997
|
+
signal,
|
|
1998
|
+
throwOnError: true
|
|
1999
|
+
});
|
|
2000
|
+
return data;
|
|
2001
|
+
},
|
|
2002
|
+
queryKey: listWebhookRunsInfiniteQueryKey(options)
|
|
2003
|
+
});
|
|
2004
|
+
|
|
2005
|
+
// src/connectors/mutations.ts
|
|
2006
|
+
function addConnectorConnectionMutationOptions(options) {
|
|
2007
|
+
const {
|
|
2008
|
+
connectorId,
|
|
2009
|
+
fromConnectionId,
|
|
2010
|
+
slot,
|
|
2011
|
+
client: client2,
|
|
2012
|
+
queryClient,
|
|
2013
|
+
onSuccess,
|
|
2014
|
+
...mutationOptions
|
|
2015
|
+
} = options;
|
|
2016
|
+
const normalizedConnectorId = nonblank(connectorId, "connectorId");
|
|
2017
|
+
const path = {
|
|
2018
|
+
connectorId: normalizedConnectorId,
|
|
2019
|
+
connectionId: nonblank(fromConnectionId, "fromConnectionId")
|
|
2020
|
+
};
|
|
2021
|
+
return {
|
|
2022
|
+
...mutationOptions,
|
|
2023
|
+
mutationFn: async () => {
|
|
2024
|
+
const { data } = await addConnectorConnection({
|
|
2025
|
+
client: client2,
|
|
2026
|
+
path,
|
|
2027
|
+
body: { slot: nonblank(slot, "slot") },
|
|
2028
|
+
throwOnError: true
|
|
2029
|
+
});
|
|
2030
|
+
return data;
|
|
2031
|
+
},
|
|
2032
|
+
onSuccess: async (run, variables, context, mutation) => {
|
|
2033
|
+
queryClient?.setQueryData(getConnectorConnectionRunQueryKey({
|
|
2034
|
+
path: { connectorId: normalizedConnectorId, runId: run.id }
|
|
2035
|
+
}), run);
|
|
2036
|
+
await onSuccess?.(run, variables, context, mutation);
|
|
2037
|
+
}
|
|
2038
|
+
};
|
|
2039
|
+
}
|
|
2040
|
+
function useAddConnectorConnection(options) {
|
|
2041
|
+
const providerClient = useSixbProviderClient();
|
|
2042
|
+
const queryClient = useQueryClient();
|
|
2043
|
+
return useMutation(addConnectorConnectionMutationOptions({
|
|
2044
|
+
...options,
|
|
2045
|
+
client: options.client ?? providerClient,
|
|
2046
|
+
queryClient: options.queryClient ?? queryClient
|
|
2047
|
+
}));
|
|
2048
|
+
}
|
|
2049
|
+
function connectConnectorMutationOptions(options) {
|
|
2050
|
+
const { connectorId, slot, returnTo, client: client2, ...mutationOptions } = options;
|
|
2051
|
+
const normalizedConnectorId = nonblank(connectorId, "connectorId");
|
|
2052
|
+
const normalizedSlot = nonblank(slot, "slot");
|
|
2053
|
+
return {
|
|
2054
|
+
...mutationOptions,
|
|
2055
|
+
mutationFn: async () => {
|
|
2056
|
+
const { data } = await startConnectorConnectionRun({
|
|
2057
|
+
client: client2,
|
|
2058
|
+
path: { connectorId: normalizedConnectorId },
|
|
2059
|
+
body: {
|
|
2060
|
+
slot: normalizedSlot,
|
|
2061
|
+
returnTo: resolveReturnTo(returnTo)
|
|
2062
|
+
},
|
|
2063
|
+
throwOnError: true
|
|
2064
|
+
});
|
|
2065
|
+
return data;
|
|
2066
|
+
}
|
|
2067
|
+
};
|
|
2068
|
+
}
|
|
2069
|
+
function useConnectConnector(options) {
|
|
2070
|
+
const providerClient = useSixbProviderClient();
|
|
2071
|
+
return useMutation(connectConnectorMutationOptions({
|
|
2072
|
+
...options,
|
|
2073
|
+
client: options.client ?? providerClient
|
|
2074
|
+
}));
|
|
2075
|
+
}
|
|
2076
|
+
function selectConnectorAccountMutationOptions(options) {
|
|
2077
|
+
const { connectorId, runId, client: client2, queryClient, onSuccess, ...mutationOptions } = options;
|
|
2078
|
+
const normalizedConnectorId = nonblank(connectorId, "connectorId");
|
|
2079
|
+
const path = () => ({
|
|
2080
|
+
connectorId: normalizedConnectorId,
|
|
2081
|
+
runId: nonblank(runId, "runId")
|
|
2082
|
+
});
|
|
2083
|
+
return {
|
|
2084
|
+
...mutationOptions,
|
|
2085
|
+
mutationFn: async ({ accountId, replace }) => {
|
|
2086
|
+
const resolvedPath = path();
|
|
2087
|
+
const { data } = await selectConnectorConnectionRunAccount({
|
|
2088
|
+
client: client2,
|
|
2089
|
+
path: resolvedPath,
|
|
2090
|
+
body: {
|
|
2091
|
+
accountId: nonblank(accountId, "accountId"),
|
|
2092
|
+
...replace === undefined ? {} : { replace }
|
|
2093
|
+
},
|
|
2094
|
+
throwOnError: true
|
|
2095
|
+
});
|
|
2096
|
+
return data;
|
|
2097
|
+
},
|
|
2098
|
+
onSuccess: async (run, variables, context, mutation) => {
|
|
2099
|
+
const resolvedPath = path();
|
|
2100
|
+
queryClient?.setQueryData(getConnectorConnectionRunQueryKey({ path: resolvedPath }), run);
|
|
2101
|
+
await invalidateConnectorConnections(queryClient, resolvedPath.connectorId);
|
|
2102
|
+
await onSuccess?.(run, variables, context, mutation);
|
|
2103
|
+
}
|
|
2104
|
+
};
|
|
2105
|
+
}
|
|
2106
|
+
function useSelectConnectorAccount(options) {
|
|
2107
|
+
const providerClient = useSixbProviderClient();
|
|
2108
|
+
const queryClient = useQueryClient();
|
|
2109
|
+
return useMutation(selectConnectorAccountMutationOptions({
|
|
2110
|
+
...options,
|
|
2111
|
+
client: options.client ?? providerClient,
|
|
2112
|
+
queryClient: options.queryClient ?? queryClient
|
|
2113
|
+
}));
|
|
2114
|
+
}
|
|
2115
|
+
function disconnectConnectorMutationOptions(options) {
|
|
2116
|
+
const { connectorId, connectionId, client: client2, queryClient, onSuccess, ...mutationOptions } = options;
|
|
2117
|
+
const normalizedConnectorId = nonblank(connectorId, "connectorId");
|
|
2118
|
+
const path = () => ({
|
|
2119
|
+
connectorId: normalizedConnectorId,
|
|
2120
|
+
connectionId: nonblank(connectionId, "connectionId")
|
|
2121
|
+
});
|
|
2122
|
+
return {
|
|
2123
|
+
...mutationOptions,
|
|
2124
|
+
mutationFn: async () => {
|
|
2125
|
+
const resolvedPath = path();
|
|
2126
|
+
const { data } = await disconnectConnectorConnection({
|
|
2127
|
+
client: client2,
|
|
2128
|
+
path: resolvedPath,
|
|
2129
|
+
throwOnError: true
|
|
2130
|
+
});
|
|
2131
|
+
return data;
|
|
2132
|
+
},
|
|
2133
|
+
onSuccess: async (result, variables, context, mutation) => {
|
|
2134
|
+
await invalidateConnectorConnections(queryClient, normalizedConnectorId);
|
|
2135
|
+
await onSuccess?.(result, variables, context, mutation);
|
|
2136
|
+
}
|
|
2137
|
+
};
|
|
2138
|
+
}
|
|
2139
|
+
function useDisconnectConnector(options) {
|
|
2140
|
+
const providerClient = useSixbProviderClient();
|
|
2141
|
+
const queryClient = useQueryClient();
|
|
2142
|
+
return useMutation(disconnectConnectorMutationOptions({
|
|
2143
|
+
...options,
|
|
2144
|
+
client: options.client ?? providerClient,
|
|
2145
|
+
queryClient: options.queryClient ?? queryClient
|
|
2146
|
+
}));
|
|
2147
|
+
}
|
|
2148
|
+
function revokeConnectorMutationOptions(options) {
|
|
2149
|
+
const { connectorId, connectionId, client: client2, queryClient, onSuccess, ...mutationOptions } = options;
|
|
2150
|
+
const normalizedConnectorId = nonblank(connectorId, "connectorId");
|
|
2151
|
+
const path = () => ({
|
|
2152
|
+
connectorId: normalizedConnectorId,
|
|
2153
|
+
connectionId: nonblank(connectionId, "connectionId")
|
|
2154
|
+
});
|
|
2155
|
+
return {
|
|
2156
|
+
...mutationOptions,
|
|
2157
|
+
mutationFn: async () => {
|
|
2158
|
+
const resolvedPath = path();
|
|
2159
|
+
const { data } = await revokeConnectorConnection({
|
|
2160
|
+
client: client2,
|
|
2161
|
+
path: resolvedPath,
|
|
2162
|
+
throwOnError: true
|
|
2163
|
+
});
|
|
2164
|
+
return data;
|
|
2165
|
+
},
|
|
2166
|
+
onSuccess: async (result, variables, context, mutation) => {
|
|
2167
|
+
await invalidateConnectorConnections(queryClient, normalizedConnectorId);
|
|
2168
|
+
await onSuccess?.(result, variables, context, mutation);
|
|
2169
|
+
}
|
|
2170
|
+
};
|
|
2171
|
+
}
|
|
2172
|
+
function useRevokeConnector(options) {
|
|
2173
|
+
const providerClient = useSixbProviderClient();
|
|
2174
|
+
const queryClient = useQueryClient();
|
|
2175
|
+
return useMutation(revokeConnectorMutationOptions({
|
|
2176
|
+
...options,
|
|
2177
|
+
client: options.client ?? providerClient,
|
|
2178
|
+
queryClient: options.queryClient ?? queryClient
|
|
2179
|
+
}));
|
|
2180
|
+
}
|
|
2181
|
+
function reauthorizeConnectorMutationOptions(options) {
|
|
2182
|
+
const { connectorId, connectionId, returnTo, client: client2, ...mutationOptions } = options;
|
|
2183
|
+
const normalizedConnectorId = nonblank(connectorId, "connectorId");
|
|
2184
|
+
return {
|
|
2185
|
+
...mutationOptions,
|
|
2186
|
+
mutationFn: async () => {
|
|
2187
|
+
const { data } = await reauthorizeConnectorConnection({
|
|
2188
|
+
client: client2,
|
|
2189
|
+
path: {
|
|
2190
|
+
connectorId: normalizedConnectorId,
|
|
2191
|
+
connectionId: nonblank(connectionId, "connectionId")
|
|
2192
|
+
},
|
|
2193
|
+
body: { returnTo: resolveReturnTo(returnTo) },
|
|
2194
|
+
throwOnError: true
|
|
2195
|
+
});
|
|
2196
|
+
return data;
|
|
2197
|
+
}
|
|
2198
|
+
};
|
|
2199
|
+
}
|
|
2200
|
+
function useReauthorizeConnector(options) {
|
|
2201
|
+
const providerClient = useSixbProviderClient();
|
|
2202
|
+
return useMutation(reauthorizeConnectorMutationOptions({
|
|
2203
|
+
...options,
|
|
2204
|
+
client: options.client ?? providerClient
|
|
2205
|
+
}));
|
|
2206
|
+
}
|
|
2207
|
+
function nonblank(value, field) {
|
|
2208
|
+
const normalized = value.trim();
|
|
2209
|
+
if (!normalized) {
|
|
2210
|
+
throw new Error(`[SixbClient] ${field} must be a non-empty string.`);
|
|
2211
|
+
}
|
|
2212
|
+
return normalized;
|
|
2213
|
+
}
|
|
2214
|
+
function resolveReturnTo(value) {
|
|
2215
|
+
const returnTo = nonblank(value, "returnTo");
|
|
2216
|
+
try {
|
|
2217
|
+
return new URL(returnTo).toString();
|
|
2218
|
+
} catch {
|
|
2219
|
+
const currentUrl = globalThis.location?.href;
|
|
2220
|
+
if (!currentUrl) {
|
|
2221
|
+
throw new Error("[SixbClient] A relative connector returnTo can only be resolved in a browser.");
|
|
2222
|
+
}
|
|
2223
|
+
try {
|
|
2224
|
+
return new URL(returnTo, currentUrl).toString();
|
|
2225
|
+
} catch (error) {
|
|
2226
|
+
throw new Error("[SixbClient] Connector returnTo must be a valid URL.", { cause: error });
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
async function invalidateConnectorConnections(queryClient, connectorId) {
|
|
2231
|
+
if (!queryClient)
|
|
2232
|
+
return;
|
|
2233
|
+
await queryClient.invalidateQueries({
|
|
2234
|
+
queryKey: listConnectorConnectionsQueryKey({ path: { connectorId } })
|
|
2235
|
+
});
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
// src/connectors/queries.ts
|
|
2239
|
+
import {
|
|
2240
|
+
queryOptions as queryOptions2,
|
|
2241
|
+
useQuery
|
|
2242
|
+
} from "@tanstack/react-query";
|
|
2243
|
+
function connectorConnectionsQueryOptions(options) {
|
|
2244
|
+
const { connectorId, client: client2, ...queryOptionsInput } = options;
|
|
2245
|
+
const path = { connectorId: nonblank2(connectorId, "connectorId") };
|
|
2246
|
+
return queryOptions2({
|
|
2247
|
+
...queryOptionsInput,
|
|
2248
|
+
queryKey: listConnectorConnectionsQueryKey({ path }),
|
|
2249
|
+
queryFn: async ({ signal }) => {
|
|
2250
|
+
const { data } = await listConnectorConnections({
|
|
2251
|
+
client: client2,
|
|
2252
|
+
path,
|
|
2253
|
+
signal,
|
|
2254
|
+
throwOnError: true
|
|
2255
|
+
});
|
|
2256
|
+
return data;
|
|
2257
|
+
}
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2260
|
+
function useConnectorConnections(options) {
|
|
2261
|
+
const providerClient = useSixbProviderClient();
|
|
2262
|
+
return useQuery(connectorConnectionsQueryOptions({
|
|
2263
|
+
...options,
|
|
2264
|
+
client: options.client ?? providerClient
|
|
2265
|
+
}));
|
|
2266
|
+
}
|
|
2267
|
+
function connectorConnectionRunQueryOptions(options) {
|
|
2268
|
+
const { connectorId, runId, client: client2, ...queryOptionsInput } = options;
|
|
2269
|
+
const normalizedRunId = optionalNonblank(runId, "runId");
|
|
2270
|
+
const path = {
|
|
2271
|
+
connectorId: nonblank2(connectorId, "connectorId"),
|
|
2272
|
+
runId: normalizedRunId ?? ""
|
|
2273
|
+
};
|
|
2274
|
+
return queryOptions2({
|
|
2275
|
+
...queryOptionsInput,
|
|
2276
|
+
enabled: normalizedRunId === undefined ? false : queryOptionsInput.enabled,
|
|
2277
|
+
queryKey: getConnectorConnectionRunQueryKey({ path }),
|
|
2278
|
+
queryFn: async ({ signal }) => {
|
|
2279
|
+
if (normalizedRunId === undefined) {
|
|
2280
|
+
throw new Error("[SixbClient] runId is required to read a connector connection run.");
|
|
2281
|
+
}
|
|
2282
|
+
const { data } = await getConnectorConnectionRun({
|
|
2283
|
+
client: client2,
|
|
2284
|
+
path,
|
|
2285
|
+
signal,
|
|
2286
|
+
throwOnError: true
|
|
2287
|
+
});
|
|
2288
|
+
return data;
|
|
2289
|
+
}
|
|
2290
|
+
});
|
|
2291
|
+
}
|
|
2292
|
+
function useConnectorConnectionRun(options) {
|
|
2293
|
+
const providerClient = useSixbProviderClient();
|
|
2294
|
+
return useQuery(connectorConnectionRunQueryOptions({
|
|
2295
|
+
...options,
|
|
2296
|
+
client: options.client ?? providerClient
|
|
2297
|
+
}));
|
|
2298
|
+
}
|
|
2299
|
+
function nonblank2(value, field) {
|
|
2300
|
+
const normalized = value.trim();
|
|
2301
|
+
if (!normalized) {
|
|
2302
|
+
throw new Error(`[SixbClient] ${field} must be a non-empty string.`);
|
|
2303
|
+
}
|
|
2304
|
+
return normalized;
|
|
2305
|
+
}
|
|
2306
|
+
function optionalNonblank(value, field) {
|
|
2307
|
+
if (value === null || value === undefined)
|
|
2308
|
+
return;
|
|
2309
|
+
return nonblank2(value, field);
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
// src/connectors/connection.ts
|
|
2313
|
+
var CONNECTOR_CALLBACK_CONNECTOR_PARAM = "connectionConnectorId";
|
|
2314
|
+
var CONNECTOR_CALLBACK_RUN_PARAM = "connectionRunId";
|
|
2315
|
+
var RUN_POLL_INTERVAL_MS = 1000;
|
|
2316
|
+
function useConnectorConnection({
|
|
2317
|
+
connectorId,
|
|
2318
|
+
slot,
|
|
2319
|
+
returnTo
|
|
2320
|
+
}) {
|
|
2321
|
+
const [callback, setCallback] = useState(readConnectorConnectionCallback);
|
|
2322
|
+
const connectInFlightRef = useRef(null);
|
|
2323
|
+
const callbackRunId = callback?.connectorId === connectorId ? callback.runId : null;
|
|
2324
|
+
const connectionsQuery = useConnectorConnections({ connectorId });
|
|
2325
|
+
const connection = useMemo(() => connectionsQuery.data?.find((candidate) => candidate.slot === slot), [connectionsQuery.data, slot]);
|
|
2326
|
+
const runQuery = useConnectorConnectionRun({
|
|
2327
|
+
connectorId,
|
|
2328
|
+
runId: callbackRunId,
|
|
2329
|
+
refetchInterval: (query) => isRunInProgress(query.state.data) ? RUN_POLL_INTERVAL_MS : false
|
|
2330
|
+
});
|
|
2331
|
+
const resumedRun = runQuery.data?.slot === slot ? runQuery.data : undefined;
|
|
2332
|
+
const resolvedReturnTo = returnTo ?? connectorConnectionReturnTo();
|
|
2333
|
+
const connectMutation = useConnectConnector({ connectorId, slot, returnTo: resolvedReturnTo });
|
|
2334
|
+
const reauthorizeMutation = useReauthorizeConnector({
|
|
2335
|
+
connectorId,
|
|
2336
|
+
connectionId: connection?.id ?? "",
|
|
2337
|
+
returnTo: resolvedReturnTo
|
|
2338
|
+
});
|
|
2339
|
+
const selectMutation = useSelectConnectorAccount({
|
|
2340
|
+
connectorId,
|
|
2341
|
+
runId: resumedRun?.id ?? ""
|
|
2342
|
+
});
|
|
2343
|
+
const disconnectMutation = useDisconnectConnector({
|
|
2344
|
+
connectorId,
|
|
2345
|
+
connectionId: connection?.id ?? ""
|
|
2346
|
+
});
|
|
2347
|
+
const revokeMutation = useRevokeConnector({
|
|
2348
|
+
connectorId,
|
|
2349
|
+
connectionId: connection?.id ?? ""
|
|
2350
|
+
});
|
|
2351
|
+
const refreshConnectionsAndConsumeCallback = useCallback(async (expectedCallback, canConsume = () => true) => {
|
|
2352
|
+
const result = await connectionsQuery.refetch();
|
|
2353
|
+
if (result.error || !expectedCallback || !canConsume())
|
|
2354
|
+
return;
|
|
2355
|
+
if (!result.data?.some((candidate) => candidate.slot === slot))
|
|
2356
|
+
return;
|
|
2357
|
+
clearConnectorConnectionCallback(expectedCallback);
|
|
2358
|
+
setCallback((current) => sameConnectorConnectionCallback(current, expectedCallback) ? null : current);
|
|
2359
|
+
}, [connectionsQuery.refetch, slot]);
|
|
2360
|
+
const completedRunId = resumedRun?.status === "succeeded" ? resumedRun.id : null;
|
|
2361
|
+
useEffect(() => {
|
|
2362
|
+
if (!completedRunId || !callback)
|
|
2363
|
+
return;
|
|
2364
|
+
let active = true;
|
|
2365
|
+
refreshConnectionsAndConsumeCallback(callback, () => active);
|
|
2366
|
+
return () => {
|
|
2367
|
+
active = false;
|
|
2368
|
+
};
|
|
2369
|
+
}, [callback, completedRunId, refreshConnectionsAndConsumeCallback]);
|
|
2370
|
+
function connect() {
|
|
2371
|
+
if (connectInFlightRef.current)
|
|
2372
|
+
return connectInFlightRef.current;
|
|
2373
|
+
if (!canConnect)
|
|
2374
|
+
return Promise.resolve();
|
|
2375
|
+
resetError();
|
|
2376
|
+
const operation = (async () => {
|
|
2377
|
+
const started = resumedRun?.kind === "reauthorize" || connection?.status === "needs_reauthorization" ? await reauthorizeMutation.mutateAsync() : await connectMutation.mutateAsync();
|
|
2378
|
+
redirectToAuthorization(started.authorizationUrl);
|
|
2379
|
+
})();
|
|
2380
|
+
connectInFlightRef.current = operation;
|
|
2381
|
+
operation.then(clearConnectInFlight, clearConnectInFlight);
|
|
2382
|
+
return operation;
|
|
2383
|
+
function clearConnectInFlight() {
|
|
2384
|
+
if (connectInFlightRef.current === operation)
|
|
2385
|
+
connectInFlightRef.current = null;
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
async function selectAccount(accountId, options = {}) {
|
|
2389
|
+
if (resumedRun?.status !== "waiting" || resumedRun.waitingFor !== "account_selection") {
|
|
2390
|
+
throw new Error("[SixbClient] No connector account selection is currently pending.");
|
|
2391
|
+
}
|
|
2392
|
+
await selectMutation.mutateAsync({ accountId, replace: options.replace });
|
|
2393
|
+
}
|
|
2394
|
+
async function disconnect() {
|
|
2395
|
+
if (!connection) {
|
|
2396
|
+
throw new Error("[SixbClient] Connector connection is unavailable.");
|
|
2397
|
+
}
|
|
2398
|
+
await disconnectMutation.mutateAsync();
|
|
2399
|
+
}
|
|
2400
|
+
async function revoke() {
|
|
2401
|
+
if (!connection) {
|
|
2402
|
+
throw new Error("[SixbClient] Connector connection is unavailable.");
|
|
2403
|
+
}
|
|
2404
|
+
await revokeMutation.mutateAsync();
|
|
2405
|
+
}
|
|
2406
|
+
async function refresh() {
|
|
2407
|
+
let completedCallback;
|
|
2408
|
+
if (callbackRunId !== null) {
|
|
2409
|
+
const runResult = await runQuery.refetch();
|
|
2410
|
+
if (!runResult.error && runResult.data?.slot === slot && runResult.data.status === "succeeded" && sameConnectorConnectionCallback(callback, {
|
|
2411
|
+
connectorId,
|
|
2412
|
+
runId: runResult.data.id
|
|
2413
|
+
})) {
|
|
2414
|
+
completedCallback = callback ?? undefined;
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
await refreshConnectionsAndConsumeCallback(completedCallback);
|
|
2418
|
+
}
|
|
2419
|
+
function dismiss() {
|
|
2420
|
+
if (!callback)
|
|
2421
|
+
return;
|
|
2422
|
+
clearConnectorConnectionCallback(callback);
|
|
2423
|
+
setCallback(null);
|
|
2424
|
+
resetError();
|
|
2425
|
+
}
|
|
2426
|
+
function resetError() {
|
|
2427
|
+
connectMutation.reset();
|
|
2428
|
+
reauthorizeMutation.reset();
|
|
2429
|
+
selectMutation.reset();
|
|
2430
|
+
disconnectMutation.reset();
|
|
2431
|
+
revokeMutation.reset();
|
|
2432
|
+
}
|
|
2433
|
+
const status = connectionStatus({
|
|
2434
|
+
callbackRunId,
|
|
2435
|
+
connectionsPending: connectionsQuery.isPending,
|
|
2436
|
+
connectionsError: connectionsQuery.error,
|
|
2437
|
+
runPending: runQuery.isPending,
|
|
2438
|
+
runError: runQuery.error,
|
|
2439
|
+
run: resumedRun,
|
|
2440
|
+
connection
|
|
2441
|
+
});
|
|
2442
|
+
const mutationPending = connectMutation.isPending || reauthorizeMutation.isPending || selectMutation.isPending || disconnectMutation.isPending || revokeMutation.isPending;
|
|
2443
|
+
const canConnect = connectorCanConnect({
|
|
2444
|
+
status,
|
|
2445
|
+
connectionsError: connectionsQuery.error,
|
|
2446
|
+
runError: runQuery.error,
|
|
2447
|
+
run: resumedRun,
|
|
2448
|
+
connection,
|
|
2449
|
+
mutationPending
|
|
2450
|
+
});
|
|
2451
|
+
return {
|
|
2452
|
+
status,
|
|
2453
|
+
connection,
|
|
2454
|
+
accounts: accountSelection(resumedRun),
|
|
2455
|
+
error: mutationFailure("connect", connectMutation.error) ?? mutationFailure("connect", reauthorizeMutation.error) ?? mutationFailure("select_account", selectMutation.error) ?? mutationFailure("disconnect", disconnectMutation.error) ?? mutationFailure("revoke", revokeMutation.error) ?? runFailure(callbackRunId, resumedRun, runQuery.error) ?? mutationFailure("load", connectionsQuery.error),
|
|
2456
|
+
canConnect,
|
|
2457
|
+
isPending: status === "loading" || status === "authorizing" || mutationPending,
|
|
2458
|
+
selectedAccountId: selectMutation.variables?.accountId,
|
|
2459
|
+
connect,
|
|
2460
|
+
selectAccount,
|
|
2461
|
+
disconnect,
|
|
2462
|
+
revoke,
|
|
2463
|
+
refresh,
|
|
2464
|
+
dismiss,
|
|
2465
|
+
resetError
|
|
2466
|
+
};
|
|
2467
|
+
}
|
|
2468
|
+
function isConnectorReplacementRequired(error) {
|
|
2469
|
+
if (isSixbApiError(error))
|
|
2470
|
+
return error.code === "connector.replacement_required";
|
|
2471
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "connector.replacement_required";
|
|
2472
|
+
}
|
|
2473
|
+
function connectorCanConnect(input) {
|
|
2474
|
+
if (input.mutationPending || input.connectionsError || input.runError)
|
|
2475
|
+
return false;
|
|
2476
|
+
if (input.status === "disconnected" || input.status === "needs_reauthorization")
|
|
2477
|
+
return true;
|
|
2478
|
+
const run = input.run;
|
|
2479
|
+
if (input.status !== "error" || !run || !isRunTerminal(run))
|
|
2480
|
+
return false;
|
|
2481
|
+
if (run.kind === "reauthorize")
|
|
2482
|
+
return input.connection !== undefined;
|
|
2483
|
+
return input.connection?.status !== "connected";
|
|
2484
|
+
}
|
|
2485
|
+
function connectionStatus(input) {
|
|
2486
|
+
const { run } = input;
|
|
2487
|
+
if (run?.status === "waiting" && run.waitingFor === "account_selection") {
|
|
2488
|
+
return "selecting_account";
|
|
2489
|
+
}
|
|
2490
|
+
if (input.callbackRunId !== null) {
|
|
2491
|
+
if (input.runError || run?.status === "failed" || run?.status === "cancelled" || run?.status === "expired") {
|
|
2492
|
+
return "error";
|
|
2493
|
+
}
|
|
2494
|
+
if (input.runPending || run?.status === "waiting" || run?.status === "running" || run?.status === "succeeded") {
|
|
2495
|
+
return "authorizing";
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
if (input.connectionsError)
|
|
2499
|
+
return "error";
|
|
2500
|
+
if (input.connectionsPending)
|
|
2501
|
+
return "loading";
|
|
2502
|
+
if (input.connection?.status === "connected")
|
|
2503
|
+
return "connected";
|
|
2504
|
+
if (input.connection?.status === "needs_reauthorization")
|
|
2505
|
+
return "needs_reauthorization";
|
|
2506
|
+
return "disconnected";
|
|
2507
|
+
}
|
|
2508
|
+
function accountSelection(run) {
|
|
2509
|
+
if (run?.status !== "waiting" || run.waitingFor !== "account_selection")
|
|
2510
|
+
return [];
|
|
2511
|
+
return run.accounts;
|
|
2512
|
+
}
|
|
2513
|
+
function mutationFailure(operation, cause) {
|
|
2514
|
+
return cause ? { operation, cause } : null;
|
|
2515
|
+
}
|
|
2516
|
+
function runFailure(callbackRunId, run, queryError) {
|
|
2517
|
+
if (callbackRunId === null)
|
|
2518
|
+
return null;
|
|
2519
|
+
if (queryError)
|
|
2520
|
+
return { operation: "resume", cause: queryError };
|
|
2521
|
+
if (run?.status === "failed")
|
|
2522
|
+
return { operation: "resume", cause: run.error };
|
|
2523
|
+
if (run?.status === "cancelled") {
|
|
2524
|
+
return {
|
|
2525
|
+
operation: "resume",
|
|
2526
|
+
cause: new Error("[SixbClient] Connector authorization was cancelled.")
|
|
2527
|
+
};
|
|
2528
|
+
}
|
|
2529
|
+
if (run?.status === "expired") {
|
|
2530
|
+
return {
|
|
2531
|
+
operation: "resume",
|
|
2532
|
+
cause: new Error("[SixbClient] Connector authorization expired before completion.")
|
|
2533
|
+
};
|
|
2534
|
+
}
|
|
2535
|
+
return null;
|
|
2536
|
+
}
|
|
2537
|
+
function isRunInProgress(run) {
|
|
2538
|
+
return run?.status === "running" || run?.status === "waiting" && run.waitingFor === "provider_authorization";
|
|
2539
|
+
}
|
|
2540
|
+
function isRunTerminal(run) {
|
|
2541
|
+
return run?.status === "failed" || run?.status === "cancelled" || run?.status === "expired";
|
|
2542
|
+
}
|
|
2543
|
+
function sameConnectorConnectionCallback(left, right) {
|
|
2544
|
+
return left?.connectorId === right.connectorId && left.runId === right.runId;
|
|
2545
|
+
}
|
|
2546
|
+
function readConnectorConnectionCallback(href = globalThis.location?.href) {
|
|
2547
|
+
if (!href)
|
|
2548
|
+
return null;
|
|
2549
|
+
const url = new URL(href);
|
|
2550
|
+
const connectorId = url.searchParams.get(CONNECTOR_CALLBACK_CONNECTOR_PARAM)?.trim();
|
|
2551
|
+
const runId = url.searchParams.get(CONNECTOR_CALLBACK_RUN_PARAM)?.trim();
|
|
2552
|
+
return connectorId && runId ? { connectorId, runId } : null;
|
|
2553
|
+
}
|
|
2554
|
+
function connectorConnectionReturnTo(href = globalThis.location?.href) {
|
|
2555
|
+
if (!href)
|
|
2556
|
+
return "";
|
|
2557
|
+
return withoutConnectorConnectionCallback(href).toString();
|
|
2558
|
+
}
|
|
2559
|
+
function clearConnectorConnectionCallback(expected) {
|
|
2560
|
+
const href = globalThis.location?.href;
|
|
2561
|
+
if (!href || !globalThis.history)
|
|
2562
|
+
return;
|
|
2563
|
+
const current = readConnectorConnectionCallback(href);
|
|
2564
|
+
if (current?.connectorId !== expected.connectorId || current.runId !== expected.runId) {
|
|
2565
|
+
return;
|
|
2566
|
+
}
|
|
2567
|
+
const url = withoutConnectorConnectionCallback(href);
|
|
2568
|
+
globalThis.history.replaceState(globalThis.history.state, "", `${url.pathname}${url.search}${url.hash}`);
|
|
2569
|
+
}
|
|
2570
|
+
function withoutConnectorConnectionCallback(href) {
|
|
2571
|
+
const url = new URL(href);
|
|
2572
|
+
url.searchParams.delete(CONNECTOR_CALLBACK_CONNECTOR_PARAM);
|
|
2573
|
+
url.searchParams.delete(CONNECTOR_CALLBACK_RUN_PARAM);
|
|
2574
|
+
return url;
|
|
2575
|
+
}
|
|
2576
|
+
function redirectToAuthorization(authorizationUrl) {
|
|
2577
|
+
if (!globalThis.location) {
|
|
2578
|
+
throw new Error("[SixbClient] Connector authorization requires a browser.");
|
|
2579
|
+
}
|
|
2580
|
+
globalThis.location.assign(authorizationUrl);
|
|
2581
|
+
}
|
|
2582
|
+
// src/events-hooks.ts
|
|
2583
|
+
import { useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
2584
|
+
import { startTransition, useCallback as useCallback2, useEffect as useEffect3, useRef as useRef2, useState as useState2 } from "react";
|
|
2585
|
+
|
|
2586
|
+
// src/events-provider.ts
|
|
2587
|
+
import { createContext as createContext2, createElement as createElement2, useContext as useContext2, useEffect as useEffect2, useMemo as useMemo2 } from "react";
|
|
2588
|
+
var DISCONNECTED = { connected: false, reconnecting: false, error: null };
|
|
2589
|
+
var DEFAULT_CLOSE_DELAY_MS = 3000;
|
|
2590
|
+
function createEventsRegistry(options = {}) {
|
|
2591
|
+
const subscribers = new Set;
|
|
2592
|
+
const closeDelayMs = options.closeDelayMs ?? DEFAULT_CLOSE_DELAY_MS;
|
|
2593
|
+
let socket = null;
|
|
2594
|
+
let state = DISCONNECTED;
|
|
2595
|
+
let latestCursor;
|
|
2596
|
+
let closeTimer = null;
|
|
2597
|
+
const cancelPendingClose = () => {
|
|
2598
|
+
if (closeTimer) {
|
|
2599
|
+
clearTimeout(closeTimer);
|
|
2600
|
+
closeTimer = null;
|
|
2601
|
+
}
|
|
2602
|
+
};
|
|
2603
|
+
const teardown = () => {
|
|
2604
|
+
socket?.close();
|
|
2605
|
+
socket = null;
|
|
2606
|
+
state = DISCONNECTED;
|
|
2607
|
+
};
|
|
2608
|
+
const open = () => {
|
|
2609
|
+
if (socket)
|
|
2610
|
+
return;
|
|
2611
|
+
socket = createEventSocket({
|
|
2612
|
+
baseUrl: options.baseUrl,
|
|
2613
|
+
afterCursor: latestCursor,
|
|
2614
|
+
onEvent: (event) => {
|
|
2615
|
+
latestCursor = event.cursor;
|
|
2616
|
+
for (const subscriber of subscribers) {
|
|
2617
|
+
if (subscriber.matches(event))
|
|
2618
|
+
subscriber.handler(event);
|
|
2619
|
+
}
|
|
2620
|
+
},
|
|
2621
|
+
onError: (message) => {
|
|
2622
|
+
for (const subscriber of subscribers)
|
|
2623
|
+
subscriber.options?.onError?.(message);
|
|
2624
|
+
},
|
|
2625
|
+
onStateChange: (next) => {
|
|
2626
|
+
state = next;
|
|
2627
|
+
for (const subscriber of subscribers)
|
|
2628
|
+
subscriber.options?.onStateChange?.(next);
|
|
2629
|
+
}
|
|
1993
2630
|
});
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2631
|
+
};
|
|
2632
|
+
return {
|
|
2633
|
+
register(filter, handler, registrationOptions) {
|
|
2634
|
+
cancelPendingClose();
|
|
2635
|
+
const subscriber = {
|
|
2636
|
+
matches: buildEventPredicate(filter),
|
|
2637
|
+
handler,
|
|
2638
|
+
options: registrationOptions
|
|
2639
|
+
};
|
|
2640
|
+
subscribers.add(subscriber);
|
|
2641
|
+
registrationOptions?.onStateChange?.(state);
|
|
2642
|
+
open();
|
|
2643
|
+
return () => {
|
|
2644
|
+
subscribers.delete(subscriber);
|
|
2645
|
+
if (subscribers.size === 0) {
|
|
2646
|
+
cancelPendingClose();
|
|
2647
|
+
closeTimer = setTimeout(() => {
|
|
2648
|
+
closeTimer = null;
|
|
2649
|
+
teardown();
|
|
2650
|
+
}, closeDelayMs);
|
|
2651
|
+
}
|
|
2652
|
+
};
|
|
2653
|
+
},
|
|
2654
|
+
close() {
|
|
2655
|
+
cancelPendingClose();
|
|
2656
|
+
subscribers.clear();
|
|
2657
|
+
teardown();
|
|
2658
|
+
}
|
|
2659
|
+
};
|
|
2660
|
+
}
|
|
2661
|
+
var EventsSocketContext = createContext2(null);
|
|
2662
|
+
function useEventsRegistry() {
|
|
2663
|
+
return useContext2(EventsSocketContext);
|
|
2664
|
+
}
|
|
2665
|
+
function SixbEventsProvider(props) {
|
|
2666
|
+
const registry = useMemo2(() => createEventsRegistry({ baseUrl: props.baseUrl }), [props.baseUrl]);
|
|
2667
|
+
useEffect2(() => () => registry.close(), [registry]);
|
|
2668
|
+
return createElement2(EventsSocketContext.Provider, { value: registry }, props.children);
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
// src/events-hooks.ts
|
|
2672
|
+
var DISCONNECTED2 = { connected: false, reconnecting: false, error: null };
|
|
2673
|
+
function useEvents(builder, onEvent, options) {
|
|
2674
|
+
const builderRef = useRef2(builder);
|
|
2675
|
+
builderRef.current = builder;
|
|
2676
|
+
const onEventRef = useRef2(onEvent);
|
|
2677
|
+
onEventRef.current = onEvent;
|
|
2678
|
+
const onErrorRef = useRef2(options?.onError);
|
|
2679
|
+
onErrorRef.current = options?.onError;
|
|
2680
|
+
const [state, setState] = useState2(DISCONNECTED2);
|
|
2681
|
+
const registry = useEventsRegistry();
|
|
2682
|
+
const enabled = options?.enabled ?? true;
|
|
2683
|
+
const afterCursor = options?.afterCursor;
|
|
2684
|
+
const limit = options?.limit;
|
|
2685
|
+
const reconnect = options?.reconnect;
|
|
2686
|
+
const reconnectDelayMs = options?.reconnectDelayMs;
|
|
2687
|
+
const handshakeTimeoutMs = options?.handshakeTimeoutMs;
|
|
2688
|
+
const irKey = JSON.stringify(builder.ir);
|
|
2689
|
+
useEffect3(() => {
|
|
2690
|
+
if (!enabled) {
|
|
2691
|
+
setState(DISCONNECTED2);
|
|
2692
|
+
return;
|
|
2693
|
+
}
|
|
2694
|
+
const handler = (event) => onEventRef.current(event);
|
|
2695
|
+
const onError = (message) => onErrorRef.current?.(message);
|
|
2696
|
+
if (registry) {
|
|
2697
|
+
return registry.register(builderRef.current.ir, handler, { onError, onStateChange: setState });
|
|
2698
|
+
}
|
|
2699
|
+
return builderRef.current.subscribe((event) => onEventRef.current(event), {
|
|
2700
|
+
afterCursor,
|
|
2701
|
+
limit,
|
|
2702
|
+
reconnect,
|
|
2703
|
+
reconnectDelayMs,
|
|
2704
|
+
handshakeTimeoutMs,
|
|
2705
|
+
onError,
|
|
2706
|
+
onStateChange: setState
|
|
2006
2707
|
});
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2708
|
+
}, [
|
|
2709
|
+
enabled,
|
|
2710
|
+
irKey,
|
|
2711
|
+
afterCursor,
|
|
2712
|
+
limit,
|
|
2713
|
+
reconnect,
|
|
2714
|
+
reconnectDelayMs,
|
|
2715
|
+
handshakeTimeoutMs,
|
|
2716
|
+
registry
|
|
2717
|
+
]);
|
|
2718
|
+
return state;
|
|
2719
|
+
}
|
|
2720
|
+
function useLatest(builder, options) {
|
|
2721
|
+
const [values, setValues] = useState2({});
|
|
2722
|
+
const irKey = JSON.stringify(builder.ir);
|
|
2723
|
+
const enabled = options?.enabled ?? true;
|
|
2724
|
+
useEffect3(() => {
|
|
2725
|
+
setValues({});
|
|
2726
|
+
}, [irKey, enabled]);
|
|
2727
|
+
const { connected } = useEvents(builder, (event) => {
|
|
2728
|
+
const update = telemetryUpdateFromEvent(event);
|
|
2729
|
+
setValues((prev) => ({ ...prev, [update.propertyId]: update }));
|
|
2730
|
+
}, options);
|
|
2731
|
+
return { values, connected };
|
|
2732
|
+
}
|
|
2733
|
+
function useLatestByObject(builder, options) {
|
|
2734
|
+
const [byObject, setByObject] = useState2({});
|
|
2735
|
+
const irKey = JSON.stringify(builder.ir);
|
|
2736
|
+
const enabled = options?.enabled ?? true;
|
|
2737
|
+
useEffect3(() => {
|
|
2738
|
+
setByObject({});
|
|
2739
|
+
}, [irKey, enabled]);
|
|
2740
|
+
const { connected } = useEvents(builder, (event) => {
|
|
2741
|
+
const update = telemetryUpdateFromEvent(event);
|
|
2742
|
+
setByObject((prev) => ({
|
|
2743
|
+
...prev,
|
|
2744
|
+
[update.objectId]: { ...prev[update.objectId], [update.propertyId]: update }
|
|
2745
|
+
}));
|
|
2746
|
+
}, options);
|
|
2747
|
+
return { byObject, connected };
|
|
2748
|
+
}
|
|
2749
|
+
function useInvalidateOnEvent(builder, resolveKeys, options) {
|
|
2750
|
+
const queryClient = useQueryClient2();
|
|
2751
|
+
const resolveKeysRef = useRef2(resolveKeys);
|
|
2752
|
+
resolveKeysRef.current = resolveKeys;
|
|
2753
|
+
const pendingRef = useRef2(new Map);
|
|
2754
|
+
const timerRef = useRef2(null);
|
|
2755
|
+
const debounceMs = options?.debounceMs ?? 0;
|
|
2756
|
+
const flush = useCallback2(() => {
|
|
2757
|
+
if (timerRef.current) {
|
|
2758
|
+
clearTimeout(timerRef.current);
|
|
2759
|
+
timerRef.current = null;
|
|
2760
|
+
}
|
|
2761
|
+
const keys = Array.from(pendingRef.current.values());
|
|
2762
|
+
pendingRef.current.clear();
|
|
2763
|
+
if (keys.length === 0)
|
|
2764
|
+
return;
|
|
2765
|
+
startTransition(() => {
|
|
2766
|
+
for (const queryKey of keys) {
|
|
2767
|
+
queryClient.invalidateQueries({ queryKey });
|
|
2017
2768
|
}
|
|
2018
|
-
};
|
|
2019
|
-
const params = createInfiniteParams(queryKey, page);
|
|
2020
|
-
const { data } = await listWebhookRuns({
|
|
2021
|
-
...options,
|
|
2022
|
-
...params,
|
|
2023
|
-
signal,
|
|
2024
|
-
throwOnError: true
|
|
2025
2769
|
});
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2770
|
+
}, [queryClient]);
|
|
2771
|
+
const flushRef = useRef2(flush);
|
|
2772
|
+
flushRef.current = flush;
|
|
2773
|
+
const state = useEvents(builder, (event) => {
|
|
2774
|
+
for (const key of resolveKeysRef.current(event)) {
|
|
2775
|
+
pendingRef.current.set(JSON.stringify(key), key);
|
|
2776
|
+
}
|
|
2777
|
+
if (debounceMs > 0) {
|
|
2778
|
+
if (!timerRef.current)
|
|
2779
|
+
timerRef.current = setTimeout(flush, debounceMs);
|
|
2780
|
+
} else {
|
|
2781
|
+
flush();
|
|
2782
|
+
}
|
|
2783
|
+
}, options);
|
|
2784
|
+
useEffect3(() => {
|
|
2785
|
+
return () => flushRef.current();
|
|
2786
|
+
}, []);
|
|
2787
|
+
return state;
|
|
2788
|
+
}
|
|
2030
2789
|
// src/logs-hooks.ts
|
|
2031
|
-
import { useEffect as
|
|
2790
|
+
import { useEffect as useEffect4, useRef as useRef3, useState as useState3 } from "react";
|
|
2032
2791
|
var DISCONNECTED3 = { connected: false, reconnecting: false, error: null };
|
|
2033
2792
|
function useSixbLogs(builder, options) {
|
|
2034
|
-
const builderRef =
|
|
2793
|
+
const builderRef = useRef3(builder);
|
|
2035
2794
|
builderRef.current = builder;
|
|
2036
|
-
const onErrorRef =
|
|
2795
|
+
const onErrorRef = useRef3(options?.onError);
|
|
2037
2796
|
onErrorRef.current = options?.onError;
|
|
2038
|
-
const [lines, setLines] =
|
|
2039
|
-
const [state, setState] =
|
|
2797
|
+
const [lines, setLines] = useState3([]);
|
|
2798
|
+
const [state, setState] = useState3(DISCONNECTED3);
|
|
2040
2799
|
const enabled = options?.enabled ?? true;
|
|
2041
2800
|
const history = options?.history ?? 200;
|
|
2042
2801
|
const max = options?.max ?? 1000;
|
|
2043
2802
|
const reconnect = options?.reconnect;
|
|
2044
2803
|
const reconnectDelayMs = options?.reconnectDelayMs;
|
|
2045
2804
|
const irKey = JSON.stringify(builder.ir);
|
|
2046
|
-
|
|
2805
|
+
useEffect4(() => {
|
|
2047
2806
|
if (!enabled) {
|
|
2048
2807
|
setLines([]);
|
|
2049
2808
|
setState(DISCONNECTED3);
|
|
@@ -2099,13 +2858,13 @@ function useSixbLogs(builder, options) {
|
|
|
2099
2858
|
// src/query-hooks.ts
|
|
2100
2859
|
import {
|
|
2101
2860
|
infiniteQueryOptions as infiniteQueryOptions2,
|
|
2102
|
-
queryOptions as
|
|
2861
|
+
queryOptions as queryOptions3,
|
|
2103
2862
|
useInfiniteQuery,
|
|
2104
|
-
useMutation,
|
|
2105
|
-
useQuery,
|
|
2106
|
-
useQueryClient as
|
|
2863
|
+
useMutation as useMutation2,
|
|
2864
|
+
useQuery as useQuery2,
|
|
2865
|
+
useQueryClient as useQueryClient3
|
|
2107
2866
|
} from "@tanstack/react-query";
|
|
2108
|
-
import {
|
|
2867
|
+
import { useMemo as useMemo3 } from "react";
|
|
2109
2868
|
var objectQueryBaseKey = ["sixb", "objects"];
|
|
2110
2869
|
function objectQueryKey(scope, ir, extra) {
|
|
2111
2870
|
return [...objectQueryBaseKey, scope, ir, extra ?? null];
|
|
@@ -2189,25 +2948,25 @@ function toBulkTelemetryHistoryLimit(value) {
|
|
|
2189
2948
|
return typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.trunc(value)) : undefined;
|
|
2190
2949
|
}
|
|
2191
2950
|
function objectQueryOptions(query, options) {
|
|
2192
|
-
return
|
|
2951
|
+
return queryOptions3({
|
|
2193
2952
|
queryKey: objectQueryKeys.list(query, options),
|
|
2194
2953
|
queryFn: () => query.list(options)
|
|
2195
2954
|
});
|
|
2196
2955
|
}
|
|
2197
2956
|
function objectQueryCountOptions(query) {
|
|
2198
|
-
return
|
|
2957
|
+
return queryOptions3({
|
|
2199
2958
|
queryKey: objectQueryKeys.count(query),
|
|
2200
2959
|
queryFn: () => query.count()
|
|
2201
2960
|
});
|
|
2202
2961
|
}
|
|
2203
2962
|
function objectQueryExistsOptions(query) {
|
|
2204
|
-
return
|
|
2963
|
+
return queryOptions3({
|
|
2205
2964
|
queryKey: objectQueryKeys.exists(query),
|
|
2206
2965
|
queryFn: () => query.exists()
|
|
2207
2966
|
});
|
|
2208
2967
|
}
|
|
2209
2968
|
function objectQueryFacetsOptions(query, facets) {
|
|
2210
|
-
return
|
|
2969
|
+
return queryOptions3({
|
|
2211
2970
|
queryKey: objectQueryKeys.facets(query, facets),
|
|
2212
2971
|
queryFn: () => query.facets(facets)
|
|
2213
2972
|
});
|
|
@@ -2222,13 +2981,9 @@ function objectQueryInfiniteOptions(query, options) {
|
|
|
2222
2981
|
getNextPageParam: (lastPage) => lastPage.nextPageToken
|
|
2223
2982
|
});
|
|
2224
2983
|
}
|
|
2225
|
-
var SixbClientContext = createContext2(undefined);
|
|
2226
|
-
function SixbProvider(props) {
|
|
2227
|
-
return createElement2(SixbClientContext.Provider, { value: props.client }, props.children);
|
|
2228
|
-
}
|
|
2229
2984
|
function useUploadFile() {
|
|
2230
|
-
const client2 =
|
|
2231
|
-
return
|
|
2985
|
+
const client2 = useSixbProviderClient();
|
|
2986
|
+
return useMutation2({
|
|
2232
2987
|
mutationFn: ({
|
|
2233
2988
|
file,
|
|
2234
2989
|
fetch,
|
|
@@ -2298,9 +3053,9 @@ function createActionRunMutationOptions(options) {
|
|
|
2298
3053
|
};
|
|
2299
3054
|
}
|
|
2300
3055
|
function useActionRunMutation(options) {
|
|
2301
|
-
const providerClient =
|
|
2302
|
-
const queryClient =
|
|
2303
|
-
return
|
|
3056
|
+
const providerClient = useSixbProviderClient();
|
|
3057
|
+
const queryClient = useQueryClient3();
|
|
3058
|
+
return useMutation2(createActionRunMutationOptions({
|
|
2304
3059
|
...options,
|
|
2305
3060
|
client: options?.client ?? providerClient,
|
|
2306
3061
|
queryClient: options?.queryClient ?? queryClient
|
|
@@ -2478,23 +3233,23 @@ async function fetchBulkTelemetryHistory(options, signal) {
|
|
|
2478
3233
|
}));
|
|
2479
3234
|
}
|
|
2480
3235
|
function telemetryHistoryQueryOptions(options) {
|
|
2481
|
-
return
|
|
3236
|
+
return queryOptions3({
|
|
2482
3237
|
queryKey: telemetryHistoryQueryKey(options),
|
|
2483
3238
|
queryFn: ({ signal }) => fetchTelemetryHistory(options, signal)
|
|
2484
3239
|
});
|
|
2485
3240
|
}
|
|
2486
3241
|
function bulkTelemetryHistoryQueryOptions(options) {
|
|
2487
|
-
return
|
|
3242
|
+
return queryOptions3({
|
|
2488
3243
|
queryKey: bulkTelemetryHistoryQueryKey(options),
|
|
2489
3244
|
queryFn: ({ signal }) => fetchBulkTelemetryHistory(options, signal)
|
|
2490
3245
|
});
|
|
2491
3246
|
}
|
|
2492
3247
|
function useClientQueryExecutor() {
|
|
2493
|
-
const client2 =
|
|
2494
|
-
return
|
|
3248
|
+
const client2 = useSixbProviderClient();
|
|
3249
|
+
return useMemo3(() => createHttpQueryExecutor(client2), [client2]);
|
|
2495
3250
|
}
|
|
2496
3251
|
function useTelemetryHistoryQuery(options) {
|
|
2497
|
-
const client2 =
|
|
3252
|
+
const client2 = useSixbProviderClient();
|
|
2498
3253
|
const {
|
|
2499
3254
|
enabled,
|
|
2500
3255
|
staleTime,
|
|
@@ -2508,7 +3263,7 @@ function useTelemetryHistoryQuery(options) {
|
|
|
2508
3263
|
...historyOptions,
|
|
2509
3264
|
client: historyOptions.client ?? client2
|
|
2510
3265
|
};
|
|
2511
|
-
return
|
|
3266
|
+
return useQuery2({
|
|
2512
3267
|
...telemetryHistoryQueryOptions(historyInput),
|
|
2513
3268
|
enabled,
|
|
2514
3269
|
staleTime,
|
|
@@ -2519,7 +3274,7 @@ function useTelemetryHistoryQuery(options) {
|
|
|
2519
3274
|
});
|
|
2520
3275
|
}
|
|
2521
3276
|
function useBulkTelemetryHistoryQuery(options) {
|
|
2522
|
-
const client2 =
|
|
3277
|
+
const client2 = useSixbProviderClient();
|
|
2523
3278
|
const {
|
|
2524
3279
|
enabled,
|
|
2525
3280
|
staleTime,
|
|
@@ -2533,7 +3288,7 @@ function useBulkTelemetryHistoryQuery(options) {
|
|
|
2533
3288
|
...historyOptions,
|
|
2534
3289
|
client: historyOptions.client ?? client2
|
|
2535
3290
|
};
|
|
2536
|
-
return
|
|
3291
|
+
return useQuery2({
|
|
2537
3292
|
...bulkTelemetryHistoryQueryOptions(historyInput),
|
|
2538
3293
|
enabled,
|
|
2539
3294
|
staleTime,
|
|
@@ -2546,7 +3301,7 @@ function useBulkTelemetryHistoryQuery(options) {
|
|
|
2546
3301
|
function useObjectsQuery(query, options) {
|
|
2547
3302
|
const executor = useClientQueryExecutor();
|
|
2548
3303
|
const ir = query.ir;
|
|
2549
|
-
return
|
|
3304
|
+
return useQuery2({
|
|
2550
3305
|
queryKey: objectQueryKeys.list(query),
|
|
2551
3306
|
queryFn: async () => {
|
|
2552
3307
|
const result = await executor.list(ir);
|
|
@@ -2563,7 +3318,7 @@ function useObjectsQuery(query, options) {
|
|
|
2563
3318
|
function useObjectsCount(query, options) {
|
|
2564
3319
|
const executor = useClientQueryExecutor();
|
|
2565
3320
|
const ir = query.ir;
|
|
2566
|
-
return
|
|
3321
|
+
return useQuery2({
|
|
2567
3322
|
queryKey: objectQueryKeys.count(query),
|
|
2568
3323
|
queryFn: () => executor.count(ir),
|
|
2569
3324
|
...options
|
|
@@ -2572,7 +3327,7 @@ function useObjectsCount(query, options) {
|
|
|
2572
3327
|
function useObjectsExists(query, options) {
|
|
2573
3328
|
const executor = useClientQueryExecutor();
|
|
2574
3329
|
const ir = query.ir;
|
|
2575
|
-
return
|
|
3330
|
+
return useQuery2({
|
|
2576
3331
|
queryKey: objectQueryKeys.exists(query),
|
|
2577
3332
|
queryFn: () => executor.exists(ir),
|
|
2578
3333
|
...options
|
|
@@ -2585,7 +3340,7 @@ function useObjectsFacets(query, facets, options) {
|
|
|
2585
3340
|
propertyId: facet.property.id,
|
|
2586
3341
|
limit: facet.limit
|
|
2587
3342
|
}));
|
|
2588
|
-
return
|
|
3343
|
+
return useQuery2({
|
|
2589
3344
|
queryKey: objectQueryKeys.facets(query, facets),
|
|
2590
3345
|
queryFn: () => executor.facets(ir, facetRequests),
|
|
2591
3346
|
...options
|
|
@@ -2610,21 +3365,50 @@ function useObjectsInfinite(query, options) {
|
|
|
2610
3365
|
...extras
|
|
2611
3366
|
});
|
|
2612
3367
|
}
|
|
2613
|
-
// src/
|
|
2614
|
-
import { useEffect as
|
|
3368
|
+
// src/useAgentActivityStream.ts
|
|
3369
|
+
import { useEffect as useEffect5, useRef as useRef4, useState as useState4 } from "react";
|
|
2615
3370
|
var DISCONNECTED4 = { connected: false, reconnecting: false, error: null };
|
|
3371
|
+
function useAgentActivityStream(options) {
|
|
3372
|
+
const { enabled = true, reconnect, reconnectDelayMs } = options;
|
|
3373
|
+
const onActivityRef = useRef4(options.onActivity);
|
|
3374
|
+
onActivityRef.current = options.onActivity;
|
|
3375
|
+
const onSubscribedRef = useRef4(options.onSubscribed);
|
|
3376
|
+
onSubscribedRef.current = options.onSubscribed;
|
|
3377
|
+
const onErrorRef = useRef4(options.onError);
|
|
3378
|
+
onErrorRef.current = options.onError;
|
|
3379
|
+
const [state, setState] = useState4(DISCONNECTED4);
|
|
3380
|
+
useEffect5(() => {
|
|
3381
|
+
if (!enabled) {
|
|
3382
|
+
setState(DISCONNECTED4);
|
|
3383
|
+
return;
|
|
3384
|
+
}
|
|
3385
|
+
const socket = createAgentActivitySocket({
|
|
3386
|
+
reconnect,
|
|
3387
|
+
reconnectDelayMs,
|
|
3388
|
+
onActivity: (event) => onActivityRef.current?.(event),
|
|
3389
|
+
onSubscribed: () => onSubscribedRef.current?.(),
|
|
3390
|
+
onError: (message) => onErrorRef.current?.(message),
|
|
3391
|
+
onStateChange: setState
|
|
3392
|
+
});
|
|
3393
|
+
return () => socket.close();
|
|
3394
|
+
}, [enabled, reconnect, reconnectDelayMs]);
|
|
3395
|
+
return state;
|
|
3396
|
+
}
|
|
3397
|
+
// src/useAgentRunStream.ts
|
|
3398
|
+
import { useEffect as useEffect6, useRef as useRef5, useState as useState5 } from "react";
|
|
3399
|
+
var DISCONNECTED5 = { connected: false, reconnecting: false, error: null };
|
|
2616
3400
|
function useAgentRunStream(options) {
|
|
2617
3401
|
const { runId, afterCursor, enabled = true, reconnect, reconnectDelayMs } = options;
|
|
2618
|
-
const onEventRef =
|
|
3402
|
+
const onEventRef = useRef5(options.onEvent);
|
|
2619
3403
|
onEventRef.current = options.onEvent;
|
|
2620
|
-
const onSnapshotRef =
|
|
3404
|
+
const onSnapshotRef = useRef5(options.onRunSnapshot);
|
|
2621
3405
|
onSnapshotRef.current = options.onRunSnapshot;
|
|
2622
|
-
const onErrorRef =
|
|
3406
|
+
const onErrorRef = useRef5(options.onError);
|
|
2623
3407
|
onErrorRef.current = options.onError;
|
|
2624
|
-
const [state, setState] =
|
|
2625
|
-
|
|
3408
|
+
const [state, setState] = useState5(DISCONNECTED5);
|
|
3409
|
+
useEffect6(() => {
|
|
2626
3410
|
if (!enabled || !runId) {
|
|
2627
|
-
setState(
|
|
3411
|
+
setState(DISCONNECTED5);
|
|
2628
3412
|
return;
|
|
2629
3413
|
}
|
|
2630
3414
|
const socket = createAgentRunSocket({
|
|
@@ -2715,7 +3499,7 @@ var listRelationshipsQueryKey = (options) => {
|
|
|
2715
3499
|
});
|
|
2716
3500
|
};
|
|
2717
3501
|
var listRelationshipsOptions = (options) => {
|
|
2718
|
-
return
|
|
3502
|
+
return queryOptions4({
|
|
2719
3503
|
queryKey: listRelationshipsQueryKey(options),
|
|
2720
3504
|
queryFn: async () => {
|
|
2721
3505
|
const objectId = options?.query?.objectId;
|
|
@@ -2790,13 +3574,13 @@ async function fetchObjectListPage(options, offsetOverride) {
|
|
|
2790
3574
|
};
|
|
2791
3575
|
}
|
|
2792
3576
|
var listObjectsPageOptions = (options) => {
|
|
2793
|
-
return
|
|
3577
|
+
return queryOptions4({
|
|
2794
3578
|
queryKey: listObjectsPageQueryKey(options),
|
|
2795
3579
|
queryFn: async () => fetchObjectListPage(options)
|
|
2796
3580
|
});
|
|
2797
3581
|
};
|
|
2798
3582
|
var listObjectsOptions = (options) => {
|
|
2799
|
-
return
|
|
3583
|
+
return queryOptions4({
|
|
2800
3584
|
queryKey: listObjectsQueryKey(options),
|
|
2801
3585
|
queryFn: async () => (await fetchObjectListPage(options)).objects
|
|
2802
3586
|
});
|
|
@@ -2808,7 +3592,7 @@ var objectCountQueryKey = (options) => {
|
|
|
2808
3592
|
});
|
|
2809
3593
|
};
|
|
2810
3594
|
var objectCountOptions = (options) => {
|
|
2811
|
-
return
|
|
3595
|
+
return queryOptions4({
|
|
2812
3596
|
queryKey: objectCountQueryKey(options),
|
|
2813
3597
|
queryFn: async () => {
|
|
2814
3598
|
const { path: _path, query, ...rest } = options ?? {};
|
|
@@ -2852,7 +3636,7 @@ var getObjectQueryKey = (options) => {
|
|
|
2852
3636
|
});
|
|
2853
3637
|
};
|
|
2854
3638
|
var getObjectOptions = (options) => {
|
|
2855
|
-
return
|
|
3639
|
+
return queryOptions4({
|
|
2856
3640
|
queryKey: getObjectQueryKey(options),
|
|
2857
3641
|
queryFn: async () => {
|
|
2858
3642
|
const parsed = decodeObjectId(options.path.objectId);
|
|
@@ -2878,7 +3662,7 @@ var getTelemetryHistoryQueryKey = (options) => {
|
|
|
2878
3662
|
});
|
|
2879
3663
|
};
|
|
2880
3664
|
var getTelemetryHistoryOptions = (options) => {
|
|
2881
|
-
return
|
|
3665
|
+
return queryOptions4({
|
|
2882
3666
|
queryKey: getTelemetryHistoryQueryKey(options),
|
|
2883
3667
|
queryFn: async () => {
|
|
2884
3668
|
const parsed = decodeObjectId(options.path.objectId);
|
|
@@ -2917,6 +3701,9 @@ export {
|
|
|
2917
3701
|
useUploadFile,
|
|
2918
3702
|
useTelemetryHistoryQuery,
|
|
2919
3703
|
useSixbLogs,
|
|
3704
|
+
useSelectConnectorAccount,
|
|
3705
|
+
useRevokeConnector,
|
|
3706
|
+
useReauthorizeConnector,
|
|
2920
3707
|
useObjectsQuery,
|
|
2921
3708
|
useObjectsInfinite,
|
|
2922
3709
|
useObjectsFacets,
|
|
@@ -2927,8 +3714,15 @@ export {
|
|
|
2927
3714
|
useInvalidateOnEvent,
|
|
2928
3715
|
useEventsRegistry,
|
|
2929
3716
|
useEvents,
|
|
3717
|
+
useDisconnectConnector,
|
|
3718
|
+
useConnectorConnections,
|
|
3719
|
+
useConnectorConnectionRun,
|
|
3720
|
+
useConnectorConnection,
|
|
3721
|
+
useConnectConnector,
|
|
2930
3722
|
useBulkTelemetryHistoryQuery,
|
|
2931
3723
|
useAgentRunStream,
|
|
3724
|
+
useAgentActivityStream,
|
|
3725
|
+
useAddConnectorConnection,
|
|
2932
3726
|
useActionRunMutation,
|
|
2933
3727
|
upsertObjectMutation,
|
|
2934
3728
|
upsertObjectLinkMutation,
|
|
@@ -2941,11 +3735,16 @@ export {
|
|
|
2941
3735
|
telemetryHistoryQueryKey,
|
|
2942
3736
|
suspendAuthMemberMutation,
|
|
2943
3737
|
submitWorkflowInterventionMutation,
|
|
3738
|
+
startConnectorConnectionRunMutation,
|
|
2944
3739
|
signOutMutation,
|
|
2945
3740
|
signOutAllMutation,
|
|
2946
3741
|
signFileUploadPartMutation,
|
|
3742
|
+
selectConnectorConnectionRunAccountMutation,
|
|
3743
|
+
selectConnectorAccountMutationOptions,
|
|
2947
3744
|
searchObjectsQueryKey,
|
|
2948
3745
|
searchObjectsOptions,
|
|
3746
|
+
revokeConnectorMutationOptions,
|
|
3747
|
+
revokeConnectorConnectionMutation,
|
|
2949
3748
|
revokeAuthSessionMutation,
|
|
2950
3749
|
revokeAuthServiceAccountAccessTokenMutation,
|
|
2951
3750
|
revokeAuthInvitationMutation,
|
|
@@ -2956,6 +3755,8 @@ export {
|
|
|
2956
3755
|
requestPipelineRunMutation,
|
|
2957
3756
|
requestActionMutation,
|
|
2958
3757
|
removeObjectLinkMutation,
|
|
3758
|
+
reauthorizeConnectorMutationOptions,
|
|
3759
|
+
reauthorizeConnectorConnectionMutation,
|
|
2959
3760
|
reactivateAuthMemberMutation,
|
|
2960
3761
|
queryObjectsMutation,
|
|
2961
3762
|
postAgentThreadMessageMutation,
|
|
@@ -3035,6 +3836,8 @@ export {
|
|
|
3035
3836
|
listDatasetRowsInfiniteOptions,
|
|
3036
3837
|
listConnectorsQueryKey,
|
|
3037
3838
|
listConnectorsOptions,
|
|
3839
|
+
listConnectorConnectionsQueryKey,
|
|
3840
|
+
listConnectorConnectionsOptions,
|
|
3038
3841
|
listAuthSessionsQueryKey,
|
|
3039
3842
|
listAuthSessionsOptions,
|
|
3040
3843
|
listAuthServiceAccountsQueryKey,
|
|
@@ -3051,6 +3854,10 @@ export {
|
|
|
3051
3854
|
listAuthInvitationsInfiniteOptions,
|
|
3052
3855
|
listAuthAccessTokensQueryKey,
|
|
3053
3856
|
listAuthAccessTokensOptions,
|
|
3857
|
+
listAiModelCallsQueryKey,
|
|
3858
|
+
listAiModelCallsOptions,
|
|
3859
|
+
listAiModelCallsInfiniteQueryKey,
|
|
3860
|
+
listAiModelCallsInfiniteOptions,
|
|
3054
3861
|
listAgentsQueryKey,
|
|
3055
3862
|
listAgentsOptions,
|
|
3056
3863
|
listAgentThreadsQueryKey,
|
|
@@ -3072,6 +3879,7 @@ export {
|
|
|
3072
3879
|
listActionRunsInfiniteQueryKey,
|
|
3073
3880
|
listActionRunsInfiniteOptions,
|
|
3074
3881
|
isSixbEvent,
|
|
3882
|
+
isConnectorReplacementRequired,
|
|
3075
3883
|
invalidateObjectQuery,
|
|
3076
3884
|
invalidateObjectQueries,
|
|
3077
3885
|
invalidateObjectInfiniteQuery,
|
|
@@ -3122,6 +3930,8 @@ export {
|
|
|
3122
3930
|
getDatasetOptions,
|
|
3123
3931
|
getConnectorQueryKey,
|
|
3124
3932
|
getConnectorOptions,
|
|
3933
|
+
getConnectorConnectionRunQueryKey,
|
|
3934
|
+
getConnectorConnectionRunOptions,
|
|
3125
3935
|
getBulkTelemetryHistoryMutation,
|
|
3126
3936
|
getAuthSessionQueryKey,
|
|
3127
3937
|
getAuthSessionOptions,
|
|
@@ -3131,6 +3941,8 @@ export {
|
|
|
3131
3941
|
getAuthInvitationOptionsOptions,
|
|
3132
3942
|
getAuthAccessManagementOptionsQueryKey,
|
|
3133
3943
|
getAuthAccessManagementOptionsOptions,
|
|
3944
|
+
getAiAccountingOverviewQueryKey,
|
|
3945
|
+
getAiAccountingOverviewOptions,
|
|
3134
3946
|
getAgentThreadQueryKey,
|
|
3135
3947
|
getAgentThreadOptions,
|
|
3136
3948
|
getAgentRunQueryKey,
|
|
@@ -3148,6 +3960,8 @@ export {
|
|
|
3148
3960
|
facetObjectsMutation,
|
|
3149
3961
|
existsObjectsMutation,
|
|
3150
3962
|
events,
|
|
3963
|
+
disconnectConnectorMutationOptions,
|
|
3964
|
+
disconnectConnectorConnectionMutation,
|
|
3151
3965
|
disableAuthServiceAccountMutation,
|
|
3152
3966
|
createWsSubscribeExecutor,
|
|
3153
3967
|
createSixbEventsWebSocketUrl,
|
|
@@ -3161,7 +3975,11 @@ export {
|
|
|
3161
3975
|
createAuthInvitationMutation,
|
|
3162
3976
|
createAgentThreadMutation,
|
|
3163
3977
|
createAgentRunSocket,
|
|
3978
|
+
createAgentActivitySocket,
|
|
3164
3979
|
countObjectsMutation,
|
|
3980
|
+
connectorConnectionsQueryOptions,
|
|
3981
|
+
connectorConnectionRunQueryOptions,
|
|
3982
|
+
connectConnectorMutationOptions,
|
|
3165
3983
|
completeFileUploadMutation,
|
|
3166
3984
|
cancelWorkflowRunMutation,
|
|
3167
3985
|
cancelWorkflowInterventionMutation,
|
|
@@ -3170,10 +3988,12 @@ export {
|
|
|
3170
3988
|
bulkTelemetryHistoryQueryKey,
|
|
3171
3989
|
buildEventPredicate,
|
|
3172
3990
|
appendTelemetryMutation,
|
|
3991
|
+
addConnectorConnectionMutationOptions,
|
|
3992
|
+
addConnectorConnectionMutation,
|
|
3173
3993
|
actionRunMutationOptions,
|
|
3174
3994
|
abortFileUploadMutation,
|
|
3175
3995
|
SixbProvider,
|
|
3176
3996
|
SixbEventsProvider
|
|
3177
3997
|
};
|
|
3178
3998
|
|
|
3179
|
-
//# debugId=
|
|
3999
|
+
//# debugId=9FF2BF8CCA95916A64756E2164756E21
|