@sixb/client 0.1.1 → 0.1.2

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.
Files changed (77) hide show
  1. package/README.md +2 -2
  2. package/dist/agent-streams.d.ts +26 -3
  3. package/dist/agent-streams.d.ts.map +1 -1
  4. package/dist/api.d.ts +6 -2
  5. package/dist/api.d.ts.map +1 -1
  6. package/dist/browser.d.ts +1 -1
  7. package/dist/browser.d.ts.map +1 -1
  8. package/dist/browser.js +2 -2
  9. package/dist/browser.js.map +1 -1
  10. package/dist/{chunk-2vsyqn32.js → chunk-5vp5zr0d.js} +1 -1
  11. package/dist/{chunk-1mnf48s9.js → chunk-ctf97s25.js} +2 -2
  12. package/dist/{chunk-w527w02k.js → chunk-mpgzkmwc.js} +2 -74
  13. package/dist/chunk-mpgzkmwc.js.map +10 -0
  14. package/dist/{chunk-h8bd95xf.js → chunk-skkt217g.js} +50 -2
  15. package/dist/chunk-skkt217g.js.map +19 -0
  16. package/dist/{chunk-hkrfakyt.js → chunk-tsdnw994.js} +2 -2
  17. package/dist/{chunk-dkd2wgva.js → chunk-v4jdc1nb.js} +40 -28
  18. package/dist/{chunk-dkd2wgva.js.map → chunk-v4jdc1nb.js.map} +3 -3
  19. package/dist/{chunk-6w5w9e75.js → chunk-zfne7wxr.js} +27 -12
  20. package/dist/chunk-zfne7wxr.js.map +10 -0
  21. package/dist/client-provider.d.ts +8 -0
  22. package/dist/client-provider.d.ts.map +1 -0
  23. package/dist/connectors/connection.d.ts +50 -0
  24. package/dist/connectors/connection.d.ts.map +1 -0
  25. package/dist/connectors/index.d.ts +4 -0
  26. package/dist/connectors/index.d.ts.map +1 -0
  27. package/dist/connectors/mutations.d.ts +62 -0
  28. package/dist/connectors/mutations.d.ts.map +1 -0
  29. package/dist/connectors/queries.d.ts +536 -0
  30. package/dist/connectors/queries.d.ts.map +1 -0
  31. package/dist/generated/@tanstack/react-query.gen.d.ts +3508 -735
  32. package/dist/generated/@tanstack/react-query.gen.d.ts.map +1 -1
  33. package/dist/generated/index.d.ts +2 -2
  34. package/dist/generated/index.d.ts.map +1 -1
  35. package/dist/generated/sdk.gen.d.ts +33 -1
  36. package/dist/generated/sdk.gen.d.ts.map +1 -1
  37. package/dist/generated/types.gen.d.ts +1819 -198
  38. package/dist/generated/types.gen.d.ts.map +1 -1
  39. package/dist/hooks.d.ts +2 -0
  40. package/dist/hooks.d.ts.map +1 -1
  41. package/dist/hooks.js +1118 -351
  42. package/dist/hooks.js.map +11 -6
  43. package/dist/index.js +25 -11
  44. package/dist/index.js.map +1 -1
  45. package/dist/logs.js +3 -3
  46. package/dist/models.d.ts +0 -31
  47. package/dist/models.d.ts.map +1 -1
  48. package/dist/models.js +19 -7
  49. package/dist/models.js.map +1 -1
  50. package/dist/query-hooks.d.ts +2 -6
  51. package/dist/query-hooks.d.ts.map +1 -1
  52. package/dist/query.js +3 -3
  53. package/dist/useAgentActivityStream.d.ts +14 -0
  54. package/dist/useAgentActivityStream.d.ts.map +1 -0
  55. package/package.json +6 -2
  56. package/src/agent-streams.ts +68 -45
  57. package/src/api.ts +26 -2
  58. package/src/browser.ts +1 -1
  59. package/src/client-provider.ts +12 -0
  60. package/src/connectors/connection.ts +443 -0
  61. package/src/connectors/index.ts +12 -0
  62. package/src/connectors/mutations.ts +417 -0
  63. package/src/connectors/queries.ts +150 -0
  64. package/src/generated/@tanstack/react-query.gen.ts +245 -0
  65. package/src/generated/index.ts +48 -0
  66. package/src/generated/sdk.gen.ts +160 -0
  67. package/src/generated/types.gen.ts +2417 -230
  68. package/src/hooks.ts +6 -0
  69. package/src/models.ts +0 -103
  70. package/src/query-hooks.ts +8 -14
  71. package/src/useAgentActivityStream.ts +48 -0
  72. package/dist/chunk-6w5w9e75.js.map +0 -10
  73. package/dist/chunk-h8bd95xf.js.map +0 -19
  74. package/dist/chunk-w527w02k.js.map +0 -10
  75. /package/dist/{chunk-2vsyqn32.js.map → chunk-5vp5zr0d.js.map} +0 -0
  76. /package/dist/{chunk-1mnf48s9.js.map → chunk-ctf97s25.js.map} +0 -0
  77. /package/dist/{chunk-hkrfakyt.js.map → chunk-tsdnw994.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-dkd2wgva.js";
21
- import"./chunk-2vsyqn32.js";
21
+ } from "./chunk-v4jdc1nb.js";
22
+ import"./chunk-5vp5zr0d.js";
22
23
  import {
23
24
  decodeObjectId,
24
25
  encodeObjectId,
25
26
  toObjectDetail,
26
27
  toObjectSummary,
27
28
  toTelemetryHistoryWithRange
28
- } from "./chunk-w527w02k.js";
29
+ } from "./chunk-mpgzkmwc.js";
29
30
  import"./chunk-trpg18dp.js";
30
31
  import {
31
32
  createHttpQueryExecutor
32
- } from "./chunk-hkrfakyt.js";
33
- import"./chunk-6w5w9e75.js";
33
+ } from "./chunk-tsdnw994.js";
34
+ import {
35
+ isSixbApiError
36
+ } from "./chunk-zfne7wxr.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,
@@ -62,6 +67,7 @@ import {
62
67
  getAuthSession,
63
68
  getBulkTelemetryHistory,
64
69
  getConnector,
70
+ getConnectorConnectionRun,
65
71
  getDataset,
66
72
  getDatasetVersion,
67
73
  getLatestTelemetry,
@@ -95,6 +101,7 @@ import {
95
101
  listAuthServiceAccountAccessTokens,
96
102
  listAuthServiceAccounts,
97
103
  listAuthSessions,
104
+ listConnectorConnections,
98
105
  listConnectors,
99
106
  listDatasetRows,
100
107
  listDatasetVersions,
@@ -119,6 +126,7 @@ import {
119
126
  postAgentThreadMessage,
120
127
  queryObjects,
121
128
  reactivateAuthMember,
129
+ reauthorizeConnectorConnection,
122
130
  removeObjectLink,
123
131
  requestAction,
124
132
  requestPipelineRun,
@@ -129,10 +137,13 @@ import {
129
137
  revokeAuthInvitation,
130
138
  revokeAuthServiceAccountAccessToken,
131
139
  revokeAuthSession,
140
+ revokeConnectorConnection,
132
141
  searchObjects,
142
+ selectConnectorConnectionRunAccount,
133
143
  signFileUploadPart,
134
144
  signOut,
135
145
  signOutAll,
146
+ startConnectorConnectionRun,
136
147
  submitWorkflowIntervention,
137
148
  suspendAuthMember,
138
149
  updateAuthMemberGroups,
@@ -140,217 +151,29 @@ import {
140
151
  uploadFileRaw,
141
152
  upsertObject,
142
153
  upsertObjectLink
143
- } from "./chunk-h8bd95xf.js";
154
+ } from "./chunk-skkt217g.js";
144
155
 
145
156
  // src/hooks.ts
146
- import { infiniteQueryOptions as infiniteQueryOptions3, queryOptions as queryOptions3 } from "@tanstack/react-query";
147
- // src/events-hooks.ts
148
- import { useQueryClient } from "@tanstack/react-query";
149
- import { startTransition, useCallback, useEffect as useEffect2, useRef, useState } from "react";
157
+ import { infiniteQueryOptions as infiniteQueryOptions3, queryOptions as queryOptions4 } from "@tanstack/react-query";
158
+ // src/connectors/connection.ts
159
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
150
160
 
151
- // src/events-provider.ts
152
- import { createContext, createElement, useContext, useEffect, useMemo } from "react";
153
- var DISCONNECTED = { connected: false, reconnecting: false, error: null };
154
- var DEFAULT_CLOSE_DELAY_MS = 3000;
155
- function createEventsRegistry(options = {}) {
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
- }
161
+ // src/connectors/mutations.ts
162
+ import {
163
+ useMutation,
164
+ useQueryClient
165
+ } from "@tanstack/react-query";
235
166
 
236
- // src/events-hooks.ts
237
- var DISCONNECTED2 = { connected: false, reconnecting: false, error: null };
238
- function useEvents(builder, onEvent, options) {
239
- const builderRef = useRef(builder);
240
- builderRef.current = builder;
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 };
167
+ // src/client-provider.ts
168
+ import { createContext, createElement, useContext } from "react";
169
+ var SixbClientContext = createContext(undefined);
170
+ function SixbProvider(props) {
171
+ return createElement(SixbClientContext.Provider, { value: props.client }, props.children);
313
172
  }
314
- function useInvalidateOnEvent(builder, resolveKeys, options) {
315
- const queryClient = useQueryClient();
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;
173
+ function useSixbProviderClient() {
174
+ return useContext(SixbClientContext);
353
175
  }
176
+
354
177
  // src/generated/@tanstack/react-query.gen.ts
355
178
  import {
356
179
  infiniteQueryOptions,
@@ -811,36 +634,10 @@ var getConnectorOptions = (options) => queryOptions({
811
634
  },
812
635
  queryKey: getConnectorQueryKey(options)
813
636
  });
814
- var listDatasetsQueryKey = (options) => createQueryKey("listDatasets", options);
815
- var listDatasetsOptions = (options) => queryOptions({
816
- queryFn: async ({ queryKey, signal }) => {
817
- const { data } = await listDatasets({
818
- ...options,
819
- ...queryKey[0],
820
- signal,
821
- throwOnError: true
822
- });
823
- return data;
824
- },
825
- queryKey: listDatasetsQueryKey(options)
826
- });
827
- var getDatasetQueryKey = (options) => createQueryKey("getDataset", options);
828
- var getDatasetOptions = (options) => queryOptions({
829
- queryFn: async ({ queryKey, signal }) => {
830
- const { data } = await getDataset({
831
- ...options,
832
- ...queryKey[0],
833
- signal,
834
- throwOnError: true
835
- });
836
- return data;
837
- },
838
- queryKey: getDatasetQueryKey(options)
839
- });
840
- var listDatasetVersionsQueryKey = (options) => createQueryKey("listDatasetVersions", options);
841
- var listDatasetVersionsOptions = (options) => queryOptions({
637
+ var listConnectorConnectionsQueryKey = (options) => createQueryKey("listConnectorConnections", options);
638
+ var listConnectorConnectionsOptions = (options) => queryOptions({
842
639
  queryFn: async ({ queryKey, signal }) => {
843
- const { data } = await listDatasetVersions({
640
+ const { data } = await listConnectorConnections({
844
641
  ...options,
845
642
  ...queryKey[0],
846
643
  signal,
@@ -848,12 +645,51 @@ var listDatasetVersionsOptions = (options) => queryOptions({
848
645
  });
849
646
  return data;
850
647
  },
851
- queryKey: listDatasetVersionsQueryKey(options)
648
+ queryKey: listConnectorConnectionsQueryKey(options)
852
649
  });
853
- var getDatasetVersionQueryKey = (options) => createQueryKey("getDatasetVersion", options);
854
- var getDatasetVersionOptions = (options) => queryOptions({
650
+ var disconnectConnectorConnectionMutation = (options) => {
651
+ const mutationOptions = {
652
+ mutationFn: async (fnOptions) => {
653
+ const { data } = await disconnectConnectorConnection({
654
+ ...options,
655
+ ...fnOptions,
656
+ throwOnError: true
657
+ });
658
+ return data;
659
+ }
660
+ };
661
+ return mutationOptions;
662
+ };
663
+ var revokeConnectorConnectionMutation = (options) => {
664
+ const mutationOptions = {
665
+ mutationFn: async (fnOptions) => {
666
+ const { data } = await revokeConnectorConnection({
667
+ ...options,
668
+ ...fnOptions,
669
+ throwOnError: true
670
+ });
671
+ return data;
672
+ }
673
+ };
674
+ return mutationOptions;
675
+ };
676
+ var startConnectorConnectionRunMutation = (options) => {
677
+ const mutationOptions = {
678
+ mutationFn: async (fnOptions) => {
679
+ const { data } = await startConnectorConnectionRun({
680
+ ...options,
681
+ ...fnOptions,
682
+ throwOnError: true
683
+ });
684
+ return data;
685
+ }
686
+ };
687
+ return mutationOptions;
688
+ };
689
+ var getConnectorConnectionRunQueryKey = (options) => createQueryKey("getConnectorConnectionRun", options);
690
+ var getConnectorConnectionRunOptions = (options) => queryOptions({
855
691
  queryFn: async ({ queryKey, signal }) => {
856
- const { data } = await getDatasetVersion({
692
+ const { data } = await getConnectorConnectionRun({
857
693
  ...options,
858
694
  ...queryKey[0],
859
695
  signal,
@@ -861,11 +697,102 @@ var getDatasetVersionOptions = (options) => queryOptions({
861
697
  });
862
698
  return data;
863
699
  },
864
- queryKey: getDatasetVersionQueryKey(options)
700
+ queryKey: getConnectorConnectionRunQueryKey(options)
865
701
  });
866
- var listDatasetRowsQueryKey = (options) => createQueryKey("listDatasetRows", options);
867
- var listDatasetRowsOptions = (options) => queryOptions({
868
- queryFn: async ({ queryKey, signal }) => {
702
+ var addConnectorConnectionMutation = (options) => {
703
+ const mutationOptions = {
704
+ mutationFn: async (fnOptions) => {
705
+ const { data } = await addConnectorConnection({
706
+ ...options,
707
+ ...fnOptions,
708
+ throwOnError: true
709
+ });
710
+ return data;
711
+ }
712
+ };
713
+ return mutationOptions;
714
+ };
715
+ var selectConnectorConnectionRunAccountMutation = (options) => {
716
+ const mutationOptions = {
717
+ mutationFn: async (fnOptions) => {
718
+ const { data } = await selectConnectorConnectionRunAccount({
719
+ ...options,
720
+ ...fnOptions,
721
+ throwOnError: true
722
+ });
723
+ return data;
724
+ }
725
+ };
726
+ return mutationOptions;
727
+ };
728
+ var reauthorizeConnectorConnectionMutation = (options) => {
729
+ const mutationOptions = {
730
+ mutationFn: async (fnOptions) => {
731
+ const { data } = await reauthorizeConnectorConnection({
732
+ ...options,
733
+ ...fnOptions,
734
+ throwOnError: true
735
+ });
736
+ return data;
737
+ }
738
+ };
739
+ return mutationOptions;
740
+ };
741
+ var listDatasetsQueryKey = (options) => createQueryKey("listDatasets", options);
742
+ var listDatasetsOptions = (options) => queryOptions({
743
+ queryFn: async ({ queryKey, signal }) => {
744
+ const { data } = await listDatasets({
745
+ ...options,
746
+ ...queryKey[0],
747
+ signal,
748
+ throwOnError: true
749
+ });
750
+ return data;
751
+ },
752
+ queryKey: listDatasetsQueryKey(options)
753
+ });
754
+ var getDatasetQueryKey = (options) => createQueryKey("getDataset", options);
755
+ var getDatasetOptions = (options) => queryOptions({
756
+ queryFn: async ({ queryKey, signal }) => {
757
+ const { data } = await getDataset({
758
+ ...options,
759
+ ...queryKey[0],
760
+ signal,
761
+ throwOnError: true
762
+ });
763
+ return data;
764
+ },
765
+ queryKey: getDatasetQueryKey(options)
766
+ });
767
+ var listDatasetVersionsQueryKey = (options) => createQueryKey("listDatasetVersions", options);
768
+ var listDatasetVersionsOptions = (options) => queryOptions({
769
+ queryFn: async ({ queryKey, signal }) => {
770
+ const { data } = await listDatasetVersions({
771
+ ...options,
772
+ ...queryKey[0],
773
+ signal,
774
+ throwOnError: true
775
+ });
776
+ return data;
777
+ },
778
+ queryKey: listDatasetVersionsQueryKey(options)
779
+ });
780
+ var getDatasetVersionQueryKey = (options) => createQueryKey("getDatasetVersion", options);
781
+ var getDatasetVersionOptions = (options) => queryOptions({
782
+ queryFn: async ({ queryKey, signal }) => {
783
+ const { data } = await getDatasetVersion({
784
+ ...options,
785
+ ...queryKey[0],
786
+ signal,
787
+ throwOnError: true
788
+ });
789
+ return data;
790
+ },
791
+ queryKey: getDatasetVersionQueryKey(options)
792
+ });
793
+ var listDatasetRowsQueryKey = (options) => createQueryKey("listDatasetRows", options);
794
+ var listDatasetRowsOptions = (options) => queryOptions({
795
+ queryFn: async ({ queryKey, signal }) => {
869
796
  const { data } = await listDatasetRows({
870
797
  ...options,
871
798
  ...queryKey[0],
@@ -1970,80 +1897,865 @@ var listProjectionRunsInfiniteOptions = (options) => infiniteQueryOptions({
1970
1897
  query: {
1971
1898
  offset: pageParam
1972
1899
  }
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
1900
+ };
1901
+ const params = createInfiniteParams(queryKey, page);
1902
+ const { data } = await listProjectionRuns({
1903
+ ...options,
1904
+ ...params,
1905
+ signal,
1906
+ throwOnError: true
1907
+ });
1908
+ return data;
1909
+ },
1910
+ queryKey: listProjectionRunsInfiniteQueryKey(options)
1911
+ });
1912
+ var getProjectionRunQueryKey = (options) => createQueryKey("getProjectionRun", options);
1913
+ var getProjectionRunOptions = (options) => queryOptions({
1914
+ queryFn: async ({ queryKey, signal }) => {
1915
+ const { data } = await getProjectionRun({
1916
+ ...options,
1917
+ ...queryKey[0],
1918
+ signal,
1919
+ throwOnError: true
1920
+ });
1921
+ return data;
1922
+ },
1923
+ queryKey: getProjectionRunQueryKey(options)
1924
+ });
1925
+ var listWebhookRunsQueryKey = (options) => createQueryKey("listWebhookRuns", options);
1926
+ var listWebhookRunsOptions = (options) => queryOptions({
1927
+ queryFn: async ({ queryKey, signal }) => {
1928
+ const { data } = await listWebhookRuns({
1929
+ ...options,
1930
+ ...queryKey[0],
1931
+ signal,
1932
+ throwOnError: true
1933
+ });
1934
+ return data;
1935
+ },
1936
+ queryKey: listWebhookRunsQueryKey(options)
1937
+ });
1938
+ var listWebhookRunsInfiniteQueryKey = (options) => createQueryKey("listWebhookRuns", options, true);
1939
+ var listWebhookRunsInfiniteOptions = (options) => infiniteQueryOptions({
1940
+ queryFn: async ({ pageParam, queryKey, signal }) => {
1941
+ const page = typeof pageParam === "object" ? pageParam : {
1942
+ query: {
1943
+ offset: pageParam
1944
+ }
1945
+ };
1946
+ const params = createInfiniteParams(queryKey, page);
1947
+ const { data } = await listWebhookRuns({
1948
+ ...options,
1949
+ ...params,
1950
+ signal,
1951
+ throwOnError: true
1952
+ });
1953
+ return data;
1954
+ },
1955
+ queryKey: listWebhookRunsInfiniteQueryKey(options)
1956
+ });
1957
+
1958
+ // src/connectors/mutations.ts
1959
+ function addConnectorConnectionMutationOptions(options) {
1960
+ const {
1961
+ connectorId,
1962
+ fromConnectionId,
1963
+ slot,
1964
+ client: client2,
1965
+ queryClient,
1966
+ onSuccess,
1967
+ ...mutationOptions
1968
+ } = options;
1969
+ const normalizedConnectorId = nonblank(connectorId, "connectorId");
1970
+ const path = {
1971
+ connectorId: normalizedConnectorId,
1972
+ connectionId: nonblank(fromConnectionId, "fromConnectionId")
1973
+ };
1974
+ return {
1975
+ ...mutationOptions,
1976
+ mutationFn: async () => {
1977
+ const { data } = await addConnectorConnection({
1978
+ client: client2,
1979
+ path,
1980
+ body: { slot: nonblank(slot, "slot") },
1981
+ throwOnError: true
1982
+ });
1983
+ return data;
1984
+ },
1985
+ onSuccess: async (run, variables, context, mutation) => {
1986
+ queryClient?.setQueryData(getConnectorConnectionRunQueryKey({
1987
+ path: { connectorId: normalizedConnectorId, runId: run.id }
1988
+ }), run);
1989
+ await onSuccess?.(run, variables, context, mutation);
1990
+ }
1991
+ };
1992
+ }
1993
+ function useAddConnectorConnection(options) {
1994
+ const providerClient = useSixbProviderClient();
1995
+ const queryClient = useQueryClient();
1996
+ return useMutation(addConnectorConnectionMutationOptions({
1997
+ ...options,
1998
+ client: options.client ?? providerClient,
1999
+ queryClient: options.queryClient ?? queryClient
2000
+ }));
2001
+ }
2002
+ function connectConnectorMutationOptions(options) {
2003
+ const { connectorId, slot, returnTo, client: client2, ...mutationOptions } = options;
2004
+ const normalizedConnectorId = nonblank(connectorId, "connectorId");
2005
+ const normalizedSlot = nonblank(slot, "slot");
2006
+ return {
2007
+ ...mutationOptions,
2008
+ mutationFn: async () => {
2009
+ const { data } = await startConnectorConnectionRun({
2010
+ client: client2,
2011
+ path: { connectorId: normalizedConnectorId },
2012
+ body: {
2013
+ slot: normalizedSlot,
2014
+ returnTo: resolveReturnTo(returnTo)
2015
+ },
2016
+ throwOnError: true
2017
+ });
2018
+ return data;
2019
+ }
2020
+ };
2021
+ }
2022
+ function useConnectConnector(options) {
2023
+ const providerClient = useSixbProviderClient();
2024
+ return useMutation(connectConnectorMutationOptions({
2025
+ ...options,
2026
+ client: options.client ?? providerClient
2027
+ }));
2028
+ }
2029
+ function selectConnectorAccountMutationOptions(options) {
2030
+ const { connectorId, runId, client: client2, queryClient, onSuccess, ...mutationOptions } = options;
2031
+ const normalizedConnectorId = nonblank(connectorId, "connectorId");
2032
+ const path = () => ({
2033
+ connectorId: normalizedConnectorId,
2034
+ runId: nonblank(runId, "runId")
2035
+ });
2036
+ return {
2037
+ ...mutationOptions,
2038
+ mutationFn: async ({ accountId, replace }) => {
2039
+ const resolvedPath = path();
2040
+ const { data } = await selectConnectorConnectionRunAccount({
2041
+ client: client2,
2042
+ path: resolvedPath,
2043
+ body: {
2044
+ accountId: nonblank(accountId, "accountId"),
2045
+ ...replace === undefined ? {} : { replace }
2046
+ },
2047
+ throwOnError: true
2048
+ });
2049
+ return data;
2050
+ },
2051
+ onSuccess: async (run, variables, context, mutation) => {
2052
+ const resolvedPath = path();
2053
+ queryClient?.setQueryData(getConnectorConnectionRunQueryKey({ path: resolvedPath }), run);
2054
+ await invalidateConnectorConnections(queryClient, resolvedPath.connectorId);
2055
+ await onSuccess?.(run, variables, context, mutation);
2056
+ }
2057
+ };
2058
+ }
2059
+ function useSelectConnectorAccount(options) {
2060
+ const providerClient = useSixbProviderClient();
2061
+ const queryClient = useQueryClient();
2062
+ return useMutation(selectConnectorAccountMutationOptions({
2063
+ ...options,
2064
+ client: options.client ?? providerClient,
2065
+ queryClient: options.queryClient ?? queryClient
2066
+ }));
2067
+ }
2068
+ function disconnectConnectorMutationOptions(options) {
2069
+ const { connectorId, connectionId, client: client2, queryClient, onSuccess, ...mutationOptions } = options;
2070
+ const normalizedConnectorId = nonblank(connectorId, "connectorId");
2071
+ const path = () => ({
2072
+ connectorId: normalizedConnectorId,
2073
+ connectionId: nonblank(connectionId, "connectionId")
2074
+ });
2075
+ return {
2076
+ ...mutationOptions,
2077
+ mutationFn: async () => {
2078
+ const resolvedPath = path();
2079
+ const { data } = await disconnectConnectorConnection({
2080
+ client: client2,
2081
+ path: resolvedPath,
2082
+ throwOnError: true
2083
+ });
2084
+ return data;
2085
+ },
2086
+ onSuccess: async (result, variables, context, mutation) => {
2087
+ await invalidateConnectorConnections(queryClient, normalizedConnectorId);
2088
+ await onSuccess?.(result, variables, context, mutation);
2089
+ }
2090
+ };
2091
+ }
2092
+ function useDisconnectConnector(options) {
2093
+ const providerClient = useSixbProviderClient();
2094
+ const queryClient = useQueryClient();
2095
+ return useMutation(disconnectConnectorMutationOptions({
2096
+ ...options,
2097
+ client: options.client ?? providerClient,
2098
+ queryClient: options.queryClient ?? queryClient
2099
+ }));
2100
+ }
2101
+ function revokeConnectorMutationOptions(options) {
2102
+ const { connectorId, connectionId, client: client2, queryClient, onSuccess, ...mutationOptions } = options;
2103
+ const normalizedConnectorId = nonblank(connectorId, "connectorId");
2104
+ const path = () => ({
2105
+ connectorId: normalizedConnectorId,
2106
+ connectionId: nonblank(connectionId, "connectionId")
2107
+ });
2108
+ return {
2109
+ ...mutationOptions,
2110
+ mutationFn: async () => {
2111
+ const resolvedPath = path();
2112
+ const { data } = await revokeConnectorConnection({
2113
+ client: client2,
2114
+ path: resolvedPath,
2115
+ throwOnError: true
2116
+ });
2117
+ return data;
2118
+ },
2119
+ onSuccess: async (result, variables, context, mutation) => {
2120
+ await invalidateConnectorConnections(queryClient, normalizedConnectorId);
2121
+ await onSuccess?.(result, variables, context, mutation);
2122
+ }
2123
+ };
2124
+ }
2125
+ function useRevokeConnector(options) {
2126
+ const providerClient = useSixbProviderClient();
2127
+ const queryClient = useQueryClient();
2128
+ return useMutation(revokeConnectorMutationOptions({
2129
+ ...options,
2130
+ client: options.client ?? providerClient,
2131
+ queryClient: options.queryClient ?? queryClient
2132
+ }));
2133
+ }
2134
+ function reauthorizeConnectorMutationOptions(options) {
2135
+ const { connectorId, connectionId, returnTo, client: client2, ...mutationOptions } = options;
2136
+ const normalizedConnectorId = nonblank(connectorId, "connectorId");
2137
+ return {
2138
+ ...mutationOptions,
2139
+ mutationFn: async () => {
2140
+ const { data } = await reauthorizeConnectorConnection({
2141
+ client: client2,
2142
+ path: {
2143
+ connectorId: normalizedConnectorId,
2144
+ connectionId: nonblank(connectionId, "connectionId")
2145
+ },
2146
+ body: { returnTo: resolveReturnTo(returnTo) },
2147
+ throwOnError: true
2148
+ });
2149
+ return data;
2150
+ }
2151
+ };
2152
+ }
2153
+ function useReauthorizeConnector(options) {
2154
+ const providerClient = useSixbProviderClient();
2155
+ return useMutation(reauthorizeConnectorMutationOptions({
2156
+ ...options,
2157
+ client: options.client ?? providerClient
2158
+ }));
2159
+ }
2160
+ function nonblank(value, field) {
2161
+ const normalized = value.trim();
2162
+ if (!normalized) {
2163
+ throw new Error(`[SixbClient] ${field} must be a non-empty string.`);
2164
+ }
2165
+ return normalized;
2166
+ }
2167
+ function resolveReturnTo(value) {
2168
+ const returnTo = nonblank(value, "returnTo");
2169
+ try {
2170
+ return new URL(returnTo).toString();
2171
+ } catch {
2172
+ const currentUrl = globalThis.location?.href;
2173
+ if (!currentUrl) {
2174
+ throw new Error("[SixbClient] A relative connector returnTo can only be resolved in a browser.");
2175
+ }
2176
+ try {
2177
+ return new URL(returnTo, currentUrl).toString();
2178
+ } catch (error) {
2179
+ throw new Error("[SixbClient] Connector returnTo must be a valid URL.", { cause: error });
2180
+ }
2181
+ }
2182
+ }
2183
+ async function invalidateConnectorConnections(queryClient, connectorId) {
2184
+ if (!queryClient)
2185
+ return;
2186
+ await queryClient.invalidateQueries({
2187
+ queryKey: listConnectorConnectionsQueryKey({ path: { connectorId } })
2188
+ });
2189
+ }
2190
+
2191
+ // src/connectors/queries.ts
2192
+ import {
2193
+ queryOptions as queryOptions2,
2194
+ useQuery
2195
+ } from "@tanstack/react-query";
2196
+ function connectorConnectionsQueryOptions(options) {
2197
+ const { connectorId, client: client2, ...queryOptionsInput } = options;
2198
+ const path = { connectorId: nonblank2(connectorId, "connectorId") };
2199
+ return queryOptions2({
2200
+ ...queryOptionsInput,
2201
+ queryKey: listConnectorConnectionsQueryKey({ path }),
2202
+ queryFn: async ({ signal }) => {
2203
+ const { data } = await listConnectorConnections({
2204
+ client: client2,
2205
+ path,
2206
+ signal,
2207
+ throwOnError: true
2208
+ });
2209
+ return data;
2210
+ }
2211
+ });
2212
+ }
2213
+ function useConnectorConnections(options) {
2214
+ const providerClient = useSixbProviderClient();
2215
+ return useQuery(connectorConnectionsQueryOptions({
2216
+ ...options,
2217
+ client: options.client ?? providerClient
2218
+ }));
2219
+ }
2220
+ function connectorConnectionRunQueryOptions(options) {
2221
+ const { connectorId, runId, client: client2, ...queryOptionsInput } = options;
2222
+ const normalizedRunId = optionalNonblank(runId, "runId");
2223
+ const path = {
2224
+ connectorId: nonblank2(connectorId, "connectorId"),
2225
+ runId: normalizedRunId ?? ""
2226
+ };
2227
+ return queryOptions2({
2228
+ ...queryOptionsInput,
2229
+ enabled: normalizedRunId === undefined ? false : queryOptionsInput.enabled,
2230
+ queryKey: getConnectorConnectionRunQueryKey({ path }),
2231
+ queryFn: async ({ signal }) => {
2232
+ if (normalizedRunId === undefined) {
2233
+ throw new Error("[SixbClient] runId is required to read a connector connection run.");
2234
+ }
2235
+ const { data } = await getConnectorConnectionRun({
2236
+ client: client2,
2237
+ path,
2238
+ signal,
2239
+ throwOnError: true
2240
+ });
2241
+ return data;
2242
+ }
2243
+ });
2244
+ }
2245
+ function useConnectorConnectionRun(options) {
2246
+ const providerClient = useSixbProviderClient();
2247
+ return useQuery(connectorConnectionRunQueryOptions({
2248
+ ...options,
2249
+ client: options.client ?? providerClient
2250
+ }));
2251
+ }
2252
+ function nonblank2(value, field) {
2253
+ const normalized = value.trim();
2254
+ if (!normalized) {
2255
+ throw new Error(`[SixbClient] ${field} must be a non-empty string.`);
2256
+ }
2257
+ return normalized;
2258
+ }
2259
+ function optionalNonblank(value, field) {
2260
+ if (value === null || value === undefined)
2261
+ return;
2262
+ return nonblank2(value, field);
2263
+ }
2264
+
2265
+ // src/connectors/connection.ts
2266
+ var CONNECTOR_CALLBACK_CONNECTOR_PARAM = "connectionConnectorId";
2267
+ var CONNECTOR_CALLBACK_RUN_PARAM = "connectionRunId";
2268
+ var RUN_POLL_INTERVAL_MS = 1000;
2269
+ function useConnectorConnection({
2270
+ connectorId,
2271
+ slot,
2272
+ returnTo
2273
+ }) {
2274
+ const [callback, setCallback] = useState(readConnectorConnectionCallback);
2275
+ const connectInFlightRef = useRef(null);
2276
+ const callbackRunId = callback?.connectorId === connectorId ? callback.runId : null;
2277
+ const connectionsQuery = useConnectorConnections({ connectorId });
2278
+ const connection = useMemo(() => connectionsQuery.data?.find((candidate) => candidate.slot === slot), [connectionsQuery.data, slot]);
2279
+ const runQuery = useConnectorConnectionRun({
2280
+ connectorId,
2281
+ runId: callbackRunId,
2282
+ refetchInterval: (query) => isRunInProgress(query.state.data) ? RUN_POLL_INTERVAL_MS : false
2283
+ });
2284
+ const resumedRun = runQuery.data?.slot === slot ? runQuery.data : undefined;
2285
+ const resolvedReturnTo = returnTo ?? connectorConnectionReturnTo();
2286
+ const connectMutation = useConnectConnector({ connectorId, slot, returnTo: resolvedReturnTo });
2287
+ const reauthorizeMutation = useReauthorizeConnector({
2288
+ connectorId,
2289
+ connectionId: connection?.id ?? "",
2290
+ returnTo: resolvedReturnTo
2291
+ });
2292
+ const selectMutation = useSelectConnectorAccount({
2293
+ connectorId,
2294
+ runId: resumedRun?.id ?? ""
2295
+ });
2296
+ const disconnectMutation = useDisconnectConnector({
2297
+ connectorId,
2298
+ connectionId: connection?.id ?? ""
2299
+ });
2300
+ const revokeMutation = useRevokeConnector({
2301
+ connectorId,
2302
+ connectionId: connection?.id ?? ""
2303
+ });
2304
+ const refreshConnectionsAndConsumeCallback = useCallback(async (expectedCallback, canConsume = () => true) => {
2305
+ const result = await connectionsQuery.refetch();
2306
+ if (result.error || !expectedCallback || !canConsume())
2307
+ return;
2308
+ if (!result.data?.some((candidate) => candidate.slot === slot))
2309
+ return;
2310
+ clearConnectorConnectionCallback(expectedCallback);
2311
+ setCallback((current) => sameConnectorConnectionCallback(current, expectedCallback) ? null : current);
2312
+ }, [connectionsQuery.refetch, slot]);
2313
+ const completedRunId = resumedRun?.status === "succeeded" ? resumedRun.id : null;
2314
+ useEffect(() => {
2315
+ if (!completedRunId || !callback)
2316
+ return;
2317
+ let active = true;
2318
+ refreshConnectionsAndConsumeCallback(callback, () => active);
2319
+ return () => {
2320
+ active = false;
2321
+ };
2322
+ }, [callback, completedRunId, refreshConnectionsAndConsumeCallback]);
2323
+ function connect() {
2324
+ if (connectInFlightRef.current)
2325
+ return connectInFlightRef.current;
2326
+ if (!canConnect)
2327
+ return Promise.resolve();
2328
+ resetError();
2329
+ const operation = (async () => {
2330
+ const started = resumedRun?.kind === "reauthorize" || connection?.status === "needs_reauthorization" ? await reauthorizeMutation.mutateAsync() : await connectMutation.mutateAsync();
2331
+ redirectToAuthorization(started.authorizationUrl);
2332
+ })();
2333
+ connectInFlightRef.current = operation;
2334
+ operation.then(clearConnectInFlight, clearConnectInFlight);
2335
+ return operation;
2336
+ function clearConnectInFlight() {
2337
+ if (connectInFlightRef.current === operation)
2338
+ connectInFlightRef.current = null;
2339
+ }
2340
+ }
2341
+ async function selectAccount(accountId, options = {}) {
2342
+ if (resumedRun?.status !== "waiting" || resumedRun.waitingFor !== "account_selection") {
2343
+ throw new Error("[SixbClient] No connector account selection is currently pending.");
2344
+ }
2345
+ await selectMutation.mutateAsync({ accountId, replace: options.replace });
2346
+ }
2347
+ async function disconnect() {
2348
+ if (!connection) {
2349
+ throw new Error("[SixbClient] Connector connection is unavailable.");
2350
+ }
2351
+ await disconnectMutation.mutateAsync();
2352
+ }
2353
+ async function revoke() {
2354
+ if (!connection) {
2355
+ throw new Error("[SixbClient] Connector connection is unavailable.");
2356
+ }
2357
+ await revokeMutation.mutateAsync();
2358
+ }
2359
+ async function refresh() {
2360
+ let completedCallback;
2361
+ if (callbackRunId !== null) {
2362
+ const runResult = await runQuery.refetch();
2363
+ if (!runResult.error && runResult.data?.slot === slot && runResult.data.status === "succeeded" && sameConnectorConnectionCallback(callback, {
2364
+ connectorId,
2365
+ runId: runResult.data.id
2366
+ })) {
2367
+ completedCallback = callback ?? undefined;
2368
+ }
2369
+ }
2370
+ await refreshConnectionsAndConsumeCallback(completedCallback);
2371
+ }
2372
+ function dismiss() {
2373
+ if (!callback)
2374
+ return;
2375
+ clearConnectorConnectionCallback(callback);
2376
+ setCallback(null);
2377
+ resetError();
2378
+ }
2379
+ function resetError() {
2380
+ connectMutation.reset();
2381
+ reauthorizeMutation.reset();
2382
+ selectMutation.reset();
2383
+ disconnectMutation.reset();
2384
+ revokeMutation.reset();
2385
+ }
2386
+ const status = connectionStatus({
2387
+ callbackRunId,
2388
+ connectionsPending: connectionsQuery.isPending,
2389
+ connectionsError: connectionsQuery.error,
2390
+ runPending: runQuery.isPending,
2391
+ runError: runQuery.error,
2392
+ run: resumedRun,
2393
+ connection
2394
+ });
2395
+ const mutationPending = connectMutation.isPending || reauthorizeMutation.isPending || selectMutation.isPending || disconnectMutation.isPending || revokeMutation.isPending;
2396
+ const canConnect = connectorCanConnect({
2397
+ status,
2398
+ connectionsError: connectionsQuery.error,
2399
+ runError: runQuery.error,
2400
+ run: resumedRun,
2401
+ connection,
2402
+ mutationPending
2403
+ });
2404
+ return {
2405
+ status,
2406
+ connection,
2407
+ accounts: accountSelection(resumedRun),
2408
+ 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),
2409
+ canConnect,
2410
+ isPending: status === "loading" || status === "authorizing" || mutationPending,
2411
+ selectedAccountId: selectMutation.variables?.accountId,
2412
+ connect,
2413
+ selectAccount,
2414
+ disconnect,
2415
+ revoke,
2416
+ refresh,
2417
+ dismiss,
2418
+ resetError
2419
+ };
2420
+ }
2421
+ function isConnectorReplacementRequired(error) {
2422
+ if (isSixbApiError(error))
2423
+ return error.code === "connector.replacement_required";
2424
+ return typeof error === "object" && error !== null && "code" in error && error.code === "connector.replacement_required";
2425
+ }
2426
+ function connectorCanConnect(input) {
2427
+ if (input.mutationPending || input.connectionsError || input.runError)
2428
+ return false;
2429
+ if (input.status === "disconnected" || input.status === "needs_reauthorization")
2430
+ return true;
2431
+ const run = input.run;
2432
+ if (input.status !== "error" || !run || !isRunTerminal(run))
2433
+ return false;
2434
+ if (run.kind === "reauthorize")
2435
+ return input.connection !== undefined;
2436
+ return input.connection?.status !== "connected";
2437
+ }
2438
+ function connectionStatus(input) {
2439
+ const { run } = input;
2440
+ if (run?.status === "waiting" && run.waitingFor === "account_selection") {
2441
+ return "selecting_account";
2442
+ }
2443
+ if (input.callbackRunId !== null) {
2444
+ if (input.runError || run?.status === "failed" || run?.status === "cancelled" || run?.status === "expired") {
2445
+ return "error";
2446
+ }
2447
+ if (input.runPending || run?.status === "waiting" || run?.status === "running" || run?.status === "succeeded") {
2448
+ return "authorizing";
2449
+ }
2450
+ }
2451
+ if (input.connectionsError)
2452
+ return "error";
2453
+ if (input.connectionsPending)
2454
+ return "loading";
2455
+ if (input.connection?.status === "connected")
2456
+ return "connected";
2457
+ if (input.connection?.status === "needs_reauthorization")
2458
+ return "needs_reauthorization";
2459
+ return "disconnected";
2460
+ }
2461
+ function accountSelection(run) {
2462
+ if (run?.status !== "waiting" || run.waitingFor !== "account_selection")
2463
+ return [];
2464
+ return run.accounts;
2465
+ }
2466
+ function mutationFailure(operation, cause) {
2467
+ return cause ? { operation, cause } : null;
2468
+ }
2469
+ function runFailure(callbackRunId, run, queryError) {
2470
+ if (callbackRunId === null)
2471
+ return null;
2472
+ if (queryError)
2473
+ return { operation: "resume", cause: queryError };
2474
+ if (run?.status === "failed")
2475
+ return { operation: "resume", cause: run.error };
2476
+ if (run?.status === "cancelled") {
2477
+ return {
2478
+ operation: "resume",
2479
+ cause: new Error("[SixbClient] Connector authorization was cancelled.")
2480
+ };
2481
+ }
2482
+ if (run?.status === "expired") {
2483
+ return {
2484
+ operation: "resume",
2485
+ cause: new Error("[SixbClient] Connector authorization expired before completion.")
2486
+ };
2487
+ }
2488
+ return null;
2489
+ }
2490
+ function isRunInProgress(run) {
2491
+ return run?.status === "running" || run?.status === "waiting" && run.waitingFor === "provider_authorization";
2492
+ }
2493
+ function isRunTerminal(run) {
2494
+ return run?.status === "failed" || run?.status === "cancelled" || run?.status === "expired";
2495
+ }
2496
+ function sameConnectorConnectionCallback(left, right) {
2497
+ return left?.connectorId === right.connectorId && left.runId === right.runId;
2498
+ }
2499
+ function readConnectorConnectionCallback(href = globalThis.location?.href) {
2500
+ if (!href)
2501
+ return null;
2502
+ const url = new URL(href);
2503
+ const connectorId = url.searchParams.get(CONNECTOR_CALLBACK_CONNECTOR_PARAM)?.trim();
2504
+ const runId = url.searchParams.get(CONNECTOR_CALLBACK_RUN_PARAM)?.trim();
2505
+ return connectorId && runId ? { connectorId, runId } : null;
2506
+ }
2507
+ function connectorConnectionReturnTo(href = globalThis.location?.href) {
2508
+ if (!href)
2509
+ return "";
2510
+ return withoutConnectorConnectionCallback(href).toString();
2511
+ }
2512
+ function clearConnectorConnectionCallback(expected) {
2513
+ const href = globalThis.location?.href;
2514
+ if (!href || !globalThis.history)
2515
+ return;
2516
+ const current = readConnectorConnectionCallback(href);
2517
+ if (current?.connectorId !== expected.connectorId || current.runId !== expected.runId) {
2518
+ return;
2519
+ }
2520
+ const url = withoutConnectorConnectionCallback(href);
2521
+ globalThis.history.replaceState(globalThis.history.state, "", `${url.pathname}${url.search}${url.hash}`);
2522
+ }
2523
+ function withoutConnectorConnectionCallback(href) {
2524
+ const url = new URL(href);
2525
+ url.searchParams.delete(CONNECTOR_CALLBACK_CONNECTOR_PARAM);
2526
+ url.searchParams.delete(CONNECTOR_CALLBACK_RUN_PARAM);
2527
+ return url;
2528
+ }
2529
+ function redirectToAuthorization(authorizationUrl) {
2530
+ if (!globalThis.location) {
2531
+ throw new Error("[SixbClient] Connector authorization requires a browser.");
2532
+ }
2533
+ globalThis.location.assign(authorizationUrl);
2534
+ }
2535
+ // src/events-hooks.ts
2536
+ import { useQueryClient as useQueryClient2 } from "@tanstack/react-query";
2537
+ import { startTransition, useCallback as useCallback2, useEffect as useEffect3, useRef as useRef2, useState as useState2 } from "react";
2538
+
2539
+ // src/events-provider.ts
2540
+ import { createContext as createContext2, createElement as createElement2, useContext as useContext2, useEffect as useEffect2, useMemo as useMemo2 } from "react";
2541
+ var DISCONNECTED = { connected: false, reconnecting: false, error: null };
2542
+ var DEFAULT_CLOSE_DELAY_MS = 3000;
2543
+ function createEventsRegistry(options = {}) {
2544
+ const subscribers = new Set;
2545
+ const closeDelayMs = options.closeDelayMs ?? DEFAULT_CLOSE_DELAY_MS;
2546
+ let socket = null;
2547
+ let state = DISCONNECTED;
2548
+ let latestCursor;
2549
+ let closeTimer = null;
2550
+ const cancelPendingClose = () => {
2551
+ if (closeTimer) {
2552
+ clearTimeout(closeTimer);
2553
+ closeTimer = null;
2554
+ }
2555
+ };
2556
+ const teardown = () => {
2557
+ socket?.close();
2558
+ socket = null;
2559
+ state = DISCONNECTED;
2560
+ };
2561
+ const open = () => {
2562
+ if (socket)
2563
+ return;
2564
+ socket = createEventSocket({
2565
+ baseUrl: options.baseUrl,
2566
+ afterCursor: latestCursor,
2567
+ onEvent: (event) => {
2568
+ latestCursor = event.cursor;
2569
+ for (const subscriber of subscribers) {
2570
+ if (subscriber.matches(event))
2571
+ subscriber.handler(event);
2572
+ }
2573
+ },
2574
+ onError: (message) => {
2575
+ for (const subscriber of subscribers)
2576
+ subscriber.options?.onError?.(message);
2577
+ },
2578
+ onStateChange: (next) => {
2579
+ state = next;
2580
+ for (const subscriber of subscribers)
2581
+ subscriber.options?.onStateChange?.(next);
2582
+ }
1993
2583
  });
1994
- return data;
1995
- },
1996
- queryKey: getProjectionRunQueryKey(options)
1997
- });
1998
- var listWebhookRunsQueryKey = (options) => createQueryKey("listWebhookRuns", options);
1999
- var listWebhookRunsOptions = (options) => queryOptions({
2000
- queryFn: async ({ queryKey, signal }) => {
2001
- const { data } = await listWebhookRuns({
2002
- ...options,
2003
- ...queryKey[0],
2004
- signal,
2005
- throwOnError: true
2584
+ };
2585
+ return {
2586
+ register(filter, handler, registrationOptions) {
2587
+ cancelPendingClose();
2588
+ const subscriber = {
2589
+ matches: buildEventPredicate(filter),
2590
+ handler,
2591
+ options: registrationOptions
2592
+ };
2593
+ subscribers.add(subscriber);
2594
+ registrationOptions?.onStateChange?.(state);
2595
+ open();
2596
+ return () => {
2597
+ subscribers.delete(subscriber);
2598
+ if (subscribers.size === 0) {
2599
+ cancelPendingClose();
2600
+ closeTimer = setTimeout(() => {
2601
+ closeTimer = null;
2602
+ teardown();
2603
+ }, closeDelayMs);
2604
+ }
2605
+ };
2606
+ },
2607
+ close() {
2608
+ cancelPendingClose();
2609
+ subscribers.clear();
2610
+ teardown();
2611
+ }
2612
+ };
2613
+ }
2614
+ var EventsSocketContext = createContext2(null);
2615
+ function useEventsRegistry() {
2616
+ return useContext2(EventsSocketContext);
2617
+ }
2618
+ function SixbEventsProvider(props) {
2619
+ const registry = useMemo2(() => createEventsRegistry({ baseUrl: props.baseUrl }), [props.baseUrl]);
2620
+ useEffect2(() => () => registry.close(), [registry]);
2621
+ return createElement2(EventsSocketContext.Provider, { value: registry }, props.children);
2622
+ }
2623
+
2624
+ // src/events-hooks.ts
2625
+ var DISCONNECTED2 = { connected: false, reconnecting: false, error: null };
2626
+ function useEvents(builder, onEvent, options) {
2627
+ const builderRef = useRef2(builder);
2628
+ builderRef.current = builder;
2629
+ const onEventRef = useRef2(onEvent);
2630
+ onEventRef.current = onEvent;
2631
+ const onErrorRef = useRef2(options?.onError);
2632
+ onErrorRef.current = options?.onError;
2633
+ const [state, setState] = useState2(DISCONNECTED2);
2634
+ const registry = useEventsRegistry();
2635
+ const enabled = options?.enabled ?? true;
2636
+ const afterCursor = options?.afterCursor;
2637
+ const limit = options?.limit;
2638
+ const reconnect = options?.reconnect;
2639
+ const reconnectDelayMs = options?.reconnectDelayMs;
2640
+ const handshakeTimeoutMs = options?.handshakeTimeoutMs;
2641
+ const irKey = JSON.stringify(builder.ir);
2642
+ useEffect3(() => {
2643
+ if (!enabled) {
2644
+ setState(DISCONNECTED2);
2645
+ return;
2646
+ }
2647
+ const handler = (event) => onEventRef.current(event);
2648
+ const onError = (message) => onErrorRef.current?.(message);
2649
+ if (registry) {
2650
+ return registry.register(builderRef.current.ir, handler, { onError, onStateChange: setState });
2651
+ }
2652
+ return builderRef.current.subscribe((event) => onEventRef.current(event), {
2653
+ afterCursor,
2654
+ limit,
2655
+ reconnect,
2656
+ reconnectDelayMs,
2657
+ handshakeTimeoutMs,
2658
+ onError,
2659
+ onStateChange: setState
2006
2660
  });
2007
- return data;
2008
- },
2009
- queryKey: listWebhookRunsQueryKey(options)
2010
- });
2011
- var listWebhookRunsInfiniteQueryKey = (options) => createQueryKey("listWebhookRuns", options, true);
2012
- var listWebhookRunsInfiniteOptions = (options) => infiniteQueryOptions({
2013
- queryFn: async ({ pageParam, queryKey, signal }) => {
2014
- const page = typeof pageParam === "object" ? pageParam : {
2015
- query: {
2016
- offset: pageParam
2661
+ }, [
2662
+ enabled,
2663
+ irKey,
2664
+ afterCursor,
2665
+ limit,
2666
+ reconnect,
2667
+ reconnectDelayMs,
2668
+ handshakeTimeoutMs,
2669
+ registry
2670
+ ]);
2671
+ return state;
2672
+ }
2673
+ function useLatest(builder, options) {
2674
+ const [values, setValues] = useState2({});
2675
+ const irKey = JSON.stringify(builder.ir);
2676
+ const enabled = options?.enabled ?? true;
2677
+ useEffect3(() => {
2678
+ setValues({});
2679
+ }, [irKey, enabled]);
2680
+ const { connected } = useEvents(builder, (event) => {
2681
+ const update = telemetryUpdateFromEvent(event);
2682
+ setValues((prev) => ({ ...prev, [update.propertyId]: update }));
2683
+ }, options);
2684
+ return { values, connected };
2685
+ }
2686
+ function useLatestByObject(builder, options) {
2687
+ const [byObject, setByObject] = useState2({});
2688
+ const irKey = JSON.stringify(builder.ir);
2689
+ const enabled = options?.enabled ?? true;
2690
+ useEffect3(() => {
2691
+ setByObject({});
2692
+ }, [irKey, enabled]);
2693
+ const { connected } = useEvents(builder, (event) => {
2694
+ const update = telemetryUpdateFromEvent(event);
2695
+ setByObject((prev) => ({
2696
+ ...prev,
2697
+ [update.objectId]: { ...prev[update.objectId], [update.propertyId]: update }
2698
+ }));
2699
+ }, options);
2700
+ return { byObject, connected };
2701
+ }
2702
+ function useInvalidateOnEvent(builder, resolveKeys, options) {
2703
+ const queryClient = useQueryClient2();
2704
+ const resolveKeysRef = useRef2(resolveKeys);
2705
+ resolveKeysRef.current = resolveKeys;
2706
+ const pendingRef = useRef2(new Map);
2707
+ const timerRef = useRef2(null);
2708
+ const debounceMs = options?.debounceMs ?? 0;
2709
+ const flush = useCallback2(() => {
2710
+ if (timerRef.current) {
2711
+ clearTimeout(timerRef.current);
2712
+ timerRef.current = null;
2713
+ }
2714
+ const keys = Array.from(pendingRef.current.values());
2715
+ pendingRef.current.clear();
2716
+ if (keys.length === 0)
2717
+ return;
2718
+ startTransition(() => {
2719
+ for (const queryKey of keys) {
2720
+ queryClient.invalidateQueries({ queryKey });
2017
2721
  }
2018
- };
2019
- const params = createInfiniteParams(queryKey, page);
2020
- const { data } = await listWebhookRuns({
2021
- ...options,
2022
- ...params,
2023
- signal,
2024
- throwOnError: true
2025
2722
  });
2026
- return data;
2027
- },
2028
- queryKey: listWebhookRunsInfiniteQueryKey(options)
2029
- });
2723
+ }, [queryClient]);
2724
+ const flushRef = useRef2(flush);
2725
+ flushRef.current = flush;
2726
+ const state = useEvents(builder, (event) => {
2727
+ for (const key of resolveKeysRef.current(event)) {
2728
+ pendingRef.current.set(JSON.stringify(key), key);
2729
+ }
2730
+ if (debounceMs > 0) {
2731
+ if (!timerRef.current)
2732
+ timerRef.current = setTimeout(flush, debounceMs);
2733
+ } else {
2734
+ flush();
2735
+ }
2736
+ }, options);
2737
+ useEffect3(() => {
2738
+ return () => flushRef.current();
2739
+ }, []);
2740
+ return state;
2741
+ }
2030
2742
  // src/logs-hooks.ts
2031
- import { useEffect as useEffect3, useRef as useRef2, useState as useState2 } from "react";
2743
+ import { useEffect as useEffect4, useRef as useRef3, useState as useState3 } from "react";
2032
2744
  var DISCONNECTED3 = { connected: false, reconnecting: false, error: null };
2033
2745
  function useSixbLogs(builder, options) {
2034
- const builderRef = useRef2(builder);
2746
+ const builderRef = useRef3(builder);
2035
2747
  builderRef.current = builder;
2036
- const onErrorRef = useRef2(options?.onError);
2748
+ const onErrorRef = useRef3(options?.onError);
2037
2749
  onErrorRef.current = options?.onError;
2038
- const [lines, setLines] = useState2([]);
2039
- const [state, setState] = useState2(DISCONNECTED3);
2750
+ const [lines, setLines] = useState3([]);
2751
+ const [state, setState] = useState3(DISCONNECTED3);
2040
2752
  const enabled = options?.enabled ?? true;
2041
2753
  const history = options?.history ?? 200;
2042
2754
  const max = options?.max ?? 1000;
2043
2755
  const reconnect = options?.reconnect;
2044
2756
  const reconnectDelayMs = options?.reconnectDelayMs;
2045
2757
  const irKey = JSON.stringify(builder.ir);
2046
- useEffect3(() => {
2758
+ useEffect4(() => {
2047
2759
  if (!enabled) {
2048
2760
  setLines([]);
2049
2761
  setState(DISCONNECTED3);
@@ -2099,13 +2811,13 @@ function useSixbLogs(builder, options) {
2099
2811
  // src/query-hooks.ts
2100
2812
  import {
2101
2813
  infiniteQueryOptions as infiniteQueryOptions2,
2102
- queryOptions as queryOptions2,
2814
+ queryOptions as queryOptions3,
2103
2815
  useInfiniteQuery,
2104
- useMutation,
2105
- useQuery,
2106
- useQueryClient as useQueryClient2
2816
+ useMutation as useMutation2,
2817
+ useQuery as useQuery2,
2818
+ useQueryClient as useQueryClient3
2107
2819
  } from "@tanstack/react-query";
2108
- import { createContext as createContext2, createElement as createElement2, useContext as useContext2, useMemo as useMemo2 } from "react";
2820
+ import { useMemo as useMemo3 } from "react";
2109
2821
  var objectQueryBaseKey = ["sixb", "objects"];
2110
2822
  function objectQueryKey(scope, ir, extra) {
2111
2823
  return [...objectQueryBaseKey, scope, ir, extra ?? null];
@@ -2189,25 +2901,25 @@ function toBulkTelemetryHistoryLimit(value) {
2189
2901
  return typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.trunc(value)) : undefined;
2190
2902
  }
2191
2903
  function objectQueryOptions(query, options) {
2192
- return queryOptions2({
2904
+ return queryOptions3({
2193
2905
  queryKey: objectQueryKeys.list(query, options),
2194
2906
  queryFn: () => query.list(options)
2195
2907
  });
2196
2908
  }
2197
2909
  function objectQueryCountOptions(query) {
2198
- return queryOptions2({
2910
+ return queryOptions3({
2199
2911
  queryKey: objectQueryKeys.count(query),
2200
2912
  queryFn: () => query.count()
2201
2913
  });
2202
2914
  }
2203
2915
  function objectQueryExistsOptions(query) {
2204
- return queryOptions2({
2916
+ return queryOptions3({
2205
2917
  queryKey: objectQueryKeys.exists(query),
2206
2918
  queryFn: () => query.exists()
2207
2919
  });
2208
2920
  }
2209
2921
  function objectQueryFacetsOptions(query, facets) {
2210
- return queryOptions2({
2922
+ return queryOptions3({
2211
2923
  queryKey: objectQueryKeys.facets(query, facets),
2212
2924
  queryFn: () => query.facets(facets)
2213
2925
  });
@@ -2222,13 +2934,9 @@ function objectQueryInfiniteOptions(query, options) {
2222
2934
  getNextPageParam: (lastPage) => lastPage.nextPageToken
2223
2935
  });
2224
2936
  }
2225
- var SixbClientContext = createContext2(undefined);
2226
- function SixbProvider(props) {
2227
- return createElement2(SixbClientContext.Provider, { value: props.client }, props.children);
2228
- }
2229
2937
  function useUploadFile() {
2230
- const client2 = useContext2(SixbClientContext);
2231
- return useMutation({
2938
+ const client2 = useSixbProviderClient();
2939
+ return useMutation2({
2232
2940
  mutationFn: ({
2233
2941
  file,
2234
2942
  fetch,
@@ -2298,9 +3006,9 @@ function createActionRunMutationOptions(options) {
2298
3006
  };
2299
3007
  }
2300
3008
  function useActionRunMutation(options) {
2301
- const providerClient = useContext2(SixbClientContext);
2302
- const queryClient = useQueryClient2();
2303
- return useMutation(createActionRunMutationOptions({
3009
+ const providerClient = useSixbProviderClient();
3010
+ const queryClient = useQueryClient3();
3011
+ return useMutation2(createActionRunMutationOptions({
2304
3012
  ...options,
2305
3013
  client: options?.client ?? providerClient,
2306
3014
  queryClient: options?.queryClient ?? queryClient
@@ -2478,23 +3186,23 @@ async function fetchBulkTelemetryHistory(options, signal) {
2478
3186
  }));
2479
3187
  }
2480
3188
  function telemetryHistoryQueryOptions(options) {
2481
- return queryOptions2({
3189
+ return queryOptions3({
2482
3190
  queryKey: telemetryHistoryQueryKey(options),
2483
3191
  queryFn: ({ signal }) => fetchTelemetryHistory(options, signal)
2484
3192
  });
2485
3193
  }
2486
3194
  function bulkTelemetryHistoryQueryOptions(options) {
2487
- return queryOptions2({
3195
+ return queryOptions3({
2488
3196
  queryKey: bulkTelemetryHistoryQueryKey(options),
2489
3197
  queryFn: ({ signal }) => fetchBulkTelemetryHistory(options, signal)
2490
3198
  });
2491
3199
  }
2492
3200
  function useClientQueryExecutor() {
2493
- const client2 = useContext2(SixbClientContext);
2494
- return useMemo2(() => createHttpQueryExecutor(client2), [client2]);
3201
+ const client2 = useSixbProviderClient();
3202
+ return useMemo3(() => createHttpQueryExecutor(client2), [client2]);
2495
3203
  }
2496
3204
  function useTelemetryHistoryQuery(options) {
2497
- const client2 = useContext2(SixbClientContext);
3205
+ const client2 = useSixbProviderClient();
2498
3206
  const {
2499
3207
  enabled,
2500
3208
  staleTime,
@@ -2508,7 +3216,7 @@ function useTelemetryHistoryQuery(options) {
2508
3216
  ...historyOptions,
2509
3217
  client: historyOptions.client ?? client2
2510
3218
  };
2511
- return useQuery({
3219
+ return useQuery2({
2512
3220
  ...telemetryHistoryQueryOptions(historyInput),
2513
3221
  enabled,
2514
3222
  staleTime,
@@ -2519,7 +3227,7 @@ function useTelemetryHistoryQuery(options) {
2519
3227
  });
2520
3228
  }
2521
3229
  function useBulkTelemetryHistoryQuery(options) {
2522
- const client2 = useContext2(SixbClientContext);
3230
+ const client2 = useSixbProviderClient();
2523
3231
  const {
2524
3232
  enabled,
2525
3233
  staleTime,
@@ -2533,7 +3241,7 @@ function useBulkTelemetryHistoryQuery(options) {
2533
3241
  ...historyOptions,
2534
3242
  client: historyOptions.client ?? client2
2535
3243
  };
2536
- return useQuery({
3244
+ return useQuery2({
2537
3245
  ...bulkTelemetryHistoryQueryOptions(historyInput),
2538
3246
  enabled,
2539
3247
  staleTime,
@@ -2546,7 +3254,7 @@ function useBulkTelemetryHistoryQuery(options) {
2546
3254
  function useObjectsQuery(query, options) {
2547
3255
  const executor = useClientQueryExecutor();
2548
3256
  const ir = query.ir;
2549
- return useQuery({
3257
+ return useQuery2({
2550
3258
  queryKey: objectQueryKeys.list(query),
2551
3259
  queryFn: async () => {
2552
3260
  const result = await executor.list(ir);
@@ -2563,7 +3271,7 @@ function useObjectsQuery(query, options) {
2563
3271
  function useObjectsCount(query, options) {
2564
3272
  const executor = useClientQueryExecutor();
2565
3273
  const ir = query.ir;
2566
- return useQuery({
3274
+ return useQuery2({
2567
3275
  queryKey: objectQueryKeys.count(query),
2568
3276
  queryFn: () => executor.count(ir),
2569
3277
  ...options
@@ -2572,7 +3280,7 @@ function useObjectsCount(query, options) {
2572
3280
  function useObjectsExists(query, options) {
2573
3281
  const executor = useClientQueryExecutor();
2574
3282
  const ir = query.ir;
2575
- return useQuery({
3283
+ return useQuery2({
2576
3284
  queryKey: objectQueryKeys.exists(query),
2577
3285
  queryFn: () => executor.exists(ir),
2578
3286
  ...options
@@ -2585,7 +3293,7 @@ function useObjectsFacets(query, facets, options) {
2585
3293
  propertyId: facet.property.id,
2586
3294
  limit: facet.limit
2587
3295
  }));
2588
- return useQuery({
3296
+ return useQuery2({
2589
3297
  queryKey: objectQueryKeys.facets(query, facets),
2590
3298
  queryFn: () => executor.facets(ir, facetRequests),
2591
3299
  ...options
@@ -2610,21 +3318,50 @@ function useObjectsInfinite(query, options) {
2610
3318
  ...extras
2611
3319
  });
2612
3320
  }
2613
- // src/useAgentRunStream.ts
2614
- import { useEffect as useEffect4, useRef as useRef3, useState as useState3 } from "react";
3321
+ // src/useAgentActivityStream.ts
3322
+ import { useEffect as useEffect5, useRef as useRef4, useState as useState4 } from "react";
2615
3323
  var DISCONNECTED4 = { connected: false, reconnecting: false, error: null };
3324
+ function useAgentActivityStream(options) {
3325
+ const { enabled = true, reconnect, reconnectDelayMs } = options;
3326
+ const onActivityRef = useRef4(options.onActivity);
3327
+ onActivityRef.current = options.onActivity;
3328
+ const onSubscribedRef = useRef4(options.onSubscribed);
3329
+ onSubscribedRef.current = options.onSubscribed;
3330
+ const onErrorRef = useRef4(options.onError);
3331
+ onErrorRef.current = options.onError;
3332
+ const [state, setState] = useState4(DISCONNECTED4);
3333
+ useEffect5(() => {
3334
+ if (!enabled) {
3335
+ setState(DISCONNECTED4);
3336
+ return;
3337
+ }
3338
+ const socket = createAgentActivitySocket({
3339
+ reconnect,
3340
+ reconnectDelayMs,
3341
+ onActivity: (event) => onActivityRef.current?.(event),
3342
+ onSubscribed: () => onSubscribedRef.current?.(),
3343
+ onError: (message) => onErrorRef.current?.(message),
3344
+ onStateChange: setState
3345
+ });
3346
+ return () => socket.close();
3347
+ }, [enabled, reconnect, reconnectDelayMs]);
3348
+ return state;
3349
+ }
3350
+ // src/useAgentRunStream.ts
3351
+ import { useEffect as useEffect6, useRef as useRef5, useState as useState5 } from "react";
3352
+ var DISCONNECTED5 = { connected: false, reconnecting: false, error: null };
2616
3353
  function useAgentRunStream(options) {
2617
3354
  const { runId, afterCursor, enabled = true, reconnect, reconnectDelayMs } = options;
2618
- const onEventRef = useRef3(options.onEvent);
3355
+ const onEventRef = useRef5(options.onEvent);
2619
3356
  onEventRef.current = options.onEvent;
2620
- const onSnapshotRef = useRef3(options.onRunSnapshot);
3357
+ const onSnapshotRef = useRef5(options.onRunSnapshot);
2621
3358
  onSnapshotRef.current = options.onRunSnapshot;
2622
- const onErrorRef = useRef3(options.onError);
3359
+ const onErrorRef = useRef5(options.onError);
2623
3360
  onErrorRef.current = options.onError;
2624
- const [state, setState] = useState3(DISCONNECTED4);
2625
- useEffect4(() => {
3361
+ const [state, setState] = useState5(DISCONNECTED5);
3362
+ useEffect6(() => {
2626
3363
  if (!enabled || !runId) {
2627
- setState(DISCONNECTED4);
3364
+ setState(DISCONNECTED5);
2628
3365
  return;
2629
3366
  }
2630
3367
  const socket = createAgentRunSocket({
@@ -2715,7 +3452,7 @@ var listRelationshipsQueryKey = (options) => {
2715
3452
  });
2716
3453
  };
2717
3454
  var listRelationshipsOptions = (options) => {
2718
- return queryOptions3({
3455
+ return queryOptions4({
2719
3456
  queryKey: listRelationshipsQueryKey(options),
2720
3457
  queryFn: async () => {
2721
3458
  const objectId = options?.query?.objectId;
@@ -2790,13 +3527,13 @@ async function fetchObjectListPage(options, offsetOverride) {
2790
3527
  };
2791
3528
  }
2792
3529
  var listObjectsPageOptions = (options) => {
2793
- return queryOptions3({
3530
+ return queryOptions4({
2794
3531
  queryKey: listObjectsPageQueryKey(options),
2795
3532
  queryFn: async () => fetchObjectListPage(options)
2796
3533
  });
2797
3534
  };
2798
3535
  var listObjectsOptions = (options) => {
2799
- return queryOptions3({
3536
+ return queryOptions4({
2800
3537
  queryKey: listObjectsQueryKey(options),
2801
3538
  queryFn: async () => (await fetchObjectListPage(options)).objects
2802
3539
  });
@@ -2808,7 +3545,7 @@ var objectCountQueryKey = (options) => {
2808
3545
  });
2809
3546
  };
2810
3547
  var objectCountOptions = (options) => {
2811
- return queryOptions3({
3548
+ return queryOptions4({
2812
3549
  queryKey: objectCountQueryKey(options),
2813
3550
  queryFn: async () => {
2814
3551
  const { path: _path, query, ...rest } = options ?? {};
@@ -2852,7 +3589,7 @@ var getObjectQueryKey = (options) => {
2852
3589
  });
2853
3590
  };
2854
3591
  var getObjectOptions = (options) => {
2855
- return queryOptions3({
3592
+ return queryOptions4({
2856
3593
  queryKey: getObjectQueryKey(options),
2857
3594
  queryFn: async () => {
2858
3595
  const parsed = decodeObjectId(options.path.objectId);
@@ -2878,7 +3615,7 @@ var getTelemetryHistoryQueryKey = (options) => {
2878
3615
  });
2879
3616
  };
2880
3617
  var getTelemetryHistoryOptions = (options) => {
2881
- return queryOptions3({
3618
+ return queryOptions4({
2882
3619
  queryKey: getTelemetryHistoryQueryKey(options),
2883
3620
  queryFn: async () => {
2884
3621
  const parsed = decodeObjectId(options.path.objectId);
@@ -2917,6 +3654,9 @@ export {
2917
3654
  useUploadFile,
2918
3655
  useTelemetryHistoryQuery,
2919
3656
  useSixbLogs,
3657
+ useSelectConnectorAccount,
3658
+ useRevokeConnector,
3659
+ useReauthorizeConnector,
2920
3660
  useObjectsQuery,
2921
3661
  useObjectsInfinite,
2922
3662
  useObjectsFacets,
@@ -2927,8 +3667,15 @@ export {
2927
3667
  useInvalidateOnEvent,
2928
3668
  useEventsRegistry,
2929
3669
  useEvents,
3670
+ useDisconnectConnector,
3671
+ useConnectorConnections,
3672
+ useConnectorConnectionRun,
3673
+ useConnectorConnection,
3674
+ useConnectConnector,
2930
3675
  useBulkTelemetryHistoryQuery,
2931
3676
  useAgentRunStream,
3677
+ useAgentActivityStream,
3678
+ useAddConnectorConnection,
2932
3679
  useActionRunMutation,
2933
3680
  upsertObjectMutation,
2934
3681
  upsertObjectLinkMutation,
@@ -2941,11 +3688,16 @@ export {
2941
3688
  telemetryHistoryQueryKey,
2942
3689
  suspendAuthMemberMutation,
2943
3690
  submitWorkflowInterventionMutation,
3691
+ startConnectorConnectionRunMutation,
2944
3692
  signOutMutation,
2945
3693
  signOutAllMutation,
2946
3694
  signFileUploadPartMutation,
3695
+ selectConnectorConnectionRunAccountMutation,
3696
+ selectConnectorAccountMutationOptions,
2947
3697
  searchObjectsQueryKey,
2948
3698
  searchObjectsOptions,
3699
+ revokeConnectorMutationOptions,
3700
+ revokeConnectorConnectionMutation,
2949
3701
  revokeAuthSessionMutation,
2950
3702
  revokeAuthServiceAccountAccessTokenMutation,
2951
3703
  revokeAuthInvitationMutation,
@@ -2956,6 +3708,8 @@ export {
2956
3708
  requestPipelineRunMutation,
2957
3709
  requestActionMutation,
2958
3710
  removeObjectLinkMutation,
3711
+ reauthorizeConnectorMutationOptions,
3712
+ reauthorizeConnectorConnectionMutation,
2959
3713
  reactivateAuthMemberMutation,
2960
3714
  queryObjectsMutation,
2961
3715
  postAgentThreadMessageMutation,
@@ -3035,6 +3789,8 @@ export {
3035
3789
  listDatasetRowsInfiniteOptions,
3036
3790
  listConnectorsQueryKey,
3037
3791
  listConnectorsOptions,
3792
+ listConnectorConnectionsQueryKey,
3793
+ listConnectorConnectionsOptions,
3038
3794
  listAuthSessionsQueryKey,
3039
3795
  listAuthSessionsOptions,
3040
3796
  listAuthServiceAccountsQueryKey,
@@ -3072,6 +3828,7 @@ export {
3072
3828
  listActionRunsInfiniteQueryKey,
3073
3829
  listActionRunsInfiniteOptions,
3074
3830
  isSixbEvent,
3831
+ isConnectorReplacementRequired,
3075
3832
  invalidateObjectQuery,
3076
3833
  invalidateObjectQueries,
3077
3834
  invalidateObjectInfiniteQuery,
@@ -3122,6 +3879,8 @@ export {
3122
3879
  getDatasetOptions,
3123
3880
  getConnectorQueryKey,
3124
3881
  getConnectorOptions,
3882
+ getConnectorConnectionRunQueryKey,
3883
+ getConnectorConnectionRunOptions,
3125
3884
  getBulkTelemetryHistoryMutation,
3126
3885
  getAuthSessionQueryKey,
3127
3886
  getAuthSessionOptions,
@@ -3148,6 +3907,8 @@ export {
3148
3907
  facetObjectsMutation,
3149
3908
  existsObjectsMutation,
3150
3909
  events,
3910
+ disconnectConnectorMutationOptions,
3911
+ disconnectConnectorConnectionMutation,
3151
3912
  disableAuthServiceAccountMutation,
3152
3913
  createWsSubscribeExecutor,
3153
3914
  createSixbEventsWebSocketUrl,
@@ -3161,7 +3922,11 @@ export {
3161
3922
  createAuthInvitationMutation,
3162
3923
  createAgentThreadMutation,
3163
3924
  createAgentRunSocket,
3925
+ createAgentActivitySocket,
3164
3926
  countObjectsMutation,
3927
+ connectorConnectionsQueryOptions,
3928
+ connectorConnectionRunQueryOptions,
3929
+ connectConnectorMutationOptions,
3165
3930
  completeFileUploadMutation,
3166
3931
  cancelWorkflowRunMutation,
3167
3932
  cancelWorkflowInterventionMutation,
@@ -3170,10 +3935,12 @@ export {
3170
3935
  bulkTelemetryHistoryQueryKey,
3171
3936
  buildEventPredicate,
3172
3937
  appendTelemetryMutation,
3938
+ addConnectorConnectionMutationOptions,
3939
+ addConnectorConnectionMutation,
3173
3940
  actionRunMutationOptions,
3174
3941
  abortFileUploadMutation,
3175
3942
  SixbProvider,
3176
3943
  SixbEventsProvider
3177
3944
  };
3178
3945
 
3179
- //# debugId=32796A49C010C32E64756E2164756E21
3946
+ //# debugId=25F06D830AC4D47664756E2164756E21