@sixb/client 0.1.10 → 0.1.12

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 (48) hide show
  1. package/README.md +26 -0
  2. package/dist/browser.js +2 -2
  3. package/dist/{chunk-rvaq39w5.js → chunk-bsy1hg20.js} +1 -1
  4. package/dist/{chunk-62nthgkf.js → chunk-e8qjsvha.js} +12 -2
  5. package/dist/chunk-e8qjsvha.js.map +19 -0
  6. package/dist/{chunk-6pmyt76w.js → chunk-hx3n4fer.js} +8 -6
  7. package/dist/{chunk-6pmyt76w.js.map → chunk-hx3n4fer.js.map} +3 -3
  8. package/dist/{chunk-cs98dfbc.js → chunk-kh20z2mt.js} +6 -4
  9. package/dist/chunk-kh20z2mt.js.map +10 -0
  10. package/dist/{chunk-d0m9gz29.js → chunk-sjb188se.js} +1 -1
  11. package/dist/{chunk-dp68jpeq.js → chunk-t50n91tk.js} +2 -2
  12. package/dist/connectors/connection.d.ts.map +1 -1
  13. package/dist/connectors/mutations.d.ts.map +1 -1
  14. package/dist/connectors/queries.d.ts +0 -4
  15. package/dist/connectors/queries.d.ts.map +1 -1
  16. package/dist/file.d.ts +3 -1
  17. package/dist/file.d.ts.map +1 -1
  18. package/dist/generated/@tanstack/react-query.gen.d.ts +1087 -120
  19. package/dist/generated/@tanstack/react-query.gen.d.ts.map +1 -1
  20. package/dist/generated/index.d.ts +2 -2
  21. package/dist/generated/index.d.ts.map +1 -1
  22. package/dist/generated/sdk.gen.d.ts +9 -1
  23. package/dist/generated/sdk.gen.d.ts.map +1 -1
  24. package/dist/generated/types.gen.d.ts +466 -16
  25. package/dist/generated/types.gen.d.ts.map +1 -1
  26. package/dist/hooks.js +92 -32
  27. package/dist/hooks.js.map +6 -6
  28. package/dist/index.js +10 -6
  29. package/dist/index.js.map +1 -1
  30. package/dist/logs.js +3 -3
  31. package/dist/models.js +6 -2
  32. package/dist/models.js.map +1 -1
  33. package/dist/query.d.ts.map +1 -1
  34. package/dist/query.js +3 -3
  35. package/package.json +2 -2
  36. package/src/connectors/connection.ts +45 -7
  37. package/src/connectors/mutations.ts +9 -4
  38. package/src/file.ts +11 -6
  39. package/src/generated/@tanstack/react-query.gen.ts +63 -0
  40. package/src/generated/index.ts +13 -0
  41. package/src/generated/sdk.gen.ts +38 -0
  42. package/src/generated/types.gen.ts +540 -16
  43. package/src/query.ts +3 -1
  44. package/dist/chunk-62nthgkf.js.map +0 -19
  45. package/dist/chunk-cs98dfbc.js.map +0 -10
  46. /package/dist/{chunk-rvaq39w5.js.map → chunk-bsy1hg20.js.map} +0 -0
  47. /package/dist/{chunk-d0m9gz29.js.map → chunk-sjb188se.js.map} +0 -0
  48. /package/dist/{chunk-dp68jpeq.js.map → chunk-t50n91tk.js.map} +0 -0
package/dist/index.js CHANGED
@@ -44,6 +44,7 @@ import {
44
44
  listConnectorConnections2,
45
45
  disconnectConnectorConnection2,
46
46
  revokeConnectorConnection2,
47
+ listPendingConnectorConnectionRuns2,
47
48
  startConnectorConnectionRun2,
48
49
  getConnectorConnectionRun2,
49
50
  addConnectorConnection2,
@@ -117,6 +118,7 @@ import {
117
118
  listAgentThreads2,
118
119
  createAgentThread2,
119
120
  getAgentThread2,
121
+ recreateAgentThreadSandbox2,
120
122
  listAgentThreadMessages2,
121
123
  postAgentThreadMessage2,
122
124
  getAgentMessageFileContent2,
@@ -139,7 +141,7 @@ import {
139
141
  listProjectionRuns2,
140
142
  getProjectionRun2,
141
143
  listWebhookRuns2
142
- } from "./chunk-62nthgkf.js";
144
+ } from "./chunk-e8qjsvha.js";
143
145
  import {
144
146
  createSixbAgentsWebSocketUrl2,
145
147
  createAgentRunSocket2,
@@ -164,7 +166,7 @@ import {
164
166
  objectFileContentUrl2,
165
167
  SixbFileUploadError2,
166
168
  uploadFile2
167
- } from "./chunk-6pmyt76w.js";
169
+ } from "./chunk-hx3n4fer.js";
168
170
  import {
169
171
  SIXB_CSRF_HEADER_NAME2,
170
172
  SIXB_CSRF_TOKEN_RESPONSE_HEADER_NAME2,
@@ -175,7 +177,7 @@ import {
175
177
  configureSixbClient2,
176
178
  createSixbClientConfig2,
177
179
  normalizeSixbApiBaseUrl2
178
- } from "./chunk-rvaq39w5.js";
180
+ } from "./chunk-bsy1hg20.js";
179
181
  import {
180
182
  encodeObjectId2,
181
183
  decodeObjectId2,
@@ -191,8 +193,8 @@ import {
191
193
  logs2,
192
194
  isStoredLogLine2,
193
195
  isStoredLogLine3
194
- } from "./chunk-dp68jpeq.js";
195
- import"./chunk-d0m9gz29.js";
196
+ } from "./chunk-t50n91tk.js";
197
+ import"./chunk-sjb188se.js";
196
198
  import"./chunk-0ka9ykez.js";
197
199
  export {
198
200
  ActionRunFailedError2 as ActionRunFailedError,
@@ -315,6 +317,7 @@ export {
315
317
  listModels2 as listModels,
316
318
  listObjectTypes2 as listObjectTypes,
317
319
  listObjects2 as listObjects,
320
+ listPendingConnectorConnectionRuns2 as listPendingConnectorConnectionRuns,
318
321
  listPipelineRuns2 as listPipelineRuns,
319
322
  listPipelines2 as listPipelines,
320
323
  listProjectionRuns2 as listProjectionRuns,
@@ -341,6 +344,7 @@ export {
341
344
  queryObjects2 as queryObjects,
342
345
  reactivateAuthMember2 as reactivateAuthMember,
343
346
  reauthorizeConnectorConnection2 as reauthorizeConnectorConnection,
347
+ recreateAgentThreadSandbox2 as recreateAgentThreadSandbox,
344
348
  removeObjectLink2 as removeObjectLink,
345
349
  requestAction2 as requestAction,
346
350
  requestActionAndWait2 as requestActionAndWait,
@@ -379,4 +383,4 @@ export {
379
383
  waitForActionRun2 as waitForActionRun
380
384
  };
381
385
 
382
- //# debugId=6189424E3E6D0CAB64756E2164756E21
386
+ //# debugId=48628C20D5DA927D64756E2164756E21
package/dist/index.js.map CHANGED
@@ -4,6 +4,6 @@
4
4
  "sourcesContent": [
5
5
  ],
6
6
  "mappings": "",
7
- "debugId": "6189424E3E6D0CAB64756E2164756E21",
7
+ "debugId": "48628C20D5DA927D64756E2164756E21",
8
8
  "names": []
9
9
  }
package/dist/logs.js CHANGED
@@ -6,11 +6,11 @@ import {
6
6
  logs2,
7
7
  isStoredLogLine2,
8
8
  isStoredLogLine3
9
- } from "./chunk-dp68jpeq.js";
10
- import"./chunk-d0m9gz29.js";
9
+ } from "./chunk-t50n91tk.js";
10
+ import"./chunk-sjb188se.js";
11
11
  import"./chunk-0ka9ykez.js";
12
12
  import"./chunk-65zz479s.js";
13
- import"./chunk-62nthgkf.js";
13
+ import"./chunk-e8qjsvha.js";
14
14
  export {
15
15
  createLogSocket2 as createLogSocket,
16
16
  createSixbLogsWebSocketUrl2 as createSixbLogsWebSocketUrl,
package/dist/models.js CHANGED
@@ -52,6 +52,7 @@ import {
52
52
  listConnectorConnections2,
53
53
  disconnectConnectorConnection2,
54
54
  revokeConnectorConnection2,
55
+ listPendingConnectorConnectionRuns2,
55
56
  startConnectorConnectionRun2,
56
57
  getConnectorConnectionRun2,
57
58
  addConnectorConnection2,
@@ -125,6 +126,7 @@ import {
125
126
  listAgentThreads2,
126
127
  createAgentThread2,
127
128
  getAgentThread2,
129
+ recreateAgentThreadSandbox2,
128
130
  listAgentThreadMessages2,
129
131
  postAgentThreadMessage2,
130
132
  getAgentMessageFileContent2,
@@ -147,7 +149,7 @@ import {
147
149
  listProjectionRuns2,
148
150
  getProjectionRun2,
149
151
  listWebhookRuns2
150
- } from "./chunk-62nthgkf.js";
152
+ } from "./chunk-e8qjsvha.js";
151
153
  export {
152
154
  abortFileUpload2 as abortFileUpload,
153
155
  addConnectorConnection2 as addConnectorConnection,
@@ -244,6 +246,7 @@ export {
244
246
  listModels2 as listModels,
245
247
  listObjectTypes2 as listObjectTypes,
246
248
  listObjects2 as listObjects,
249
+ listPendingConnectorConnectionRuns2 as listPendingConnectorConnectionRuns,
247
250
  listPipelineRuns2 as listPipelineRuns,
248
251
  listPipelines2 as listPipelines,
249
252
  listProjectionRuns2 as listProjectionRuns,
@@ -262,6 +265,7 @@ export {
262
265
  queryObjects2 as queryObjects,
263
266
  reactivateAuthMember2 as reactivateAuthMember,
264
267
  reauthorizeConnectorConnection2 as reauthorizeConnectorConnection,
268
+ recreateAgentThreadSandbox2 as recreateAgentThreadSandbox,
265
269
  removeObjectLink2 as removeObjectLink,
266
270
  requestAction2 as requestAction,
267
271
  requestPipelineRun2 as requestPipelineRun,
@@ -295,4 +299,4 @@ export {
295
299
  upsertObjectLink2 as upsertObjectLink
296
300
  };
297
301
 
298
- //# debugId=59C3D01363E76F2D64756E2164756E21
302
+ //# debugId=E15246A0F616437364756E2164756E21
@@ -4,6 +4,6 @@
4
4
  "sourcesContent": [
5
5
  ],
6
6
  "mappings": "",
7
- "debugId": "59C3D01363E76F2D64756E2164756E21",
7
+ "debugId": "E15246A0F616437364756E2164756E21",
8
8
  "names": []
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,KAAK,EAEV,kBAAkB,EAClB,mBAAmB,EAKnB,4BAA4B,EAC7B,MAAM,kBAAkB,CAAA;AAGzB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,KAAK,EACV,gBAAgB,EAGjB,MAAM,uBAAuB,CAAA;AAE9B,YAAY,EAAE,gBAAgB,EAAE,CAAA;AAEhC,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,SAAS,gBAAgB,EAAE,CAAA;gBAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,SAAS,gBAAgB,EAAO;CAKtE;AAED,MAAM,WAAW,sBAAsB;IACrC,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAKD,KAAK,2BAA2B,CAAC,WAAW,SAAS,4BAA4B,IAC7E,WAAW,GACX,OAAO,CAAC,iBAAiB,CAAC,MAAM,iBAAiB,CAAC,EAAE,4BAA4B,CAAC,CAAA;AAErF,MAAM,MAAM,wBAAwB,CAAC,WAAW,SAAS,4BAA4B,IACnF,kBAAkB,CAAC,WAAW,EAAE,2BAA2B,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC,CAAA;AAExF,wBAAgB,OAAO,CAAC,WAAW,SAAS,4BAA4B,EACtE,UAAU,EAAE,WAAW,EACvB,OAAO,CAAC,EAAE,sBAAsB,GAC/B;IAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC,WAAW,CAAC,CAAA;CAAE,CAQxD;AAED,wBAAgB,uBAAuB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAoD5E"}
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,KAAK,EAEV,kBAAkB,EAClB,mBAAmB,EAKnB,4BAA4B,EAC7B,MAAM,kBAAkB,CAAA;AAGzB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,KAAK,EACV,gBAAgB,EAGjB,MAAM,uBAAuB,CAAA;AAE9B,YAAY,EAAE,gBAAgB,EAAE,CAAA;AAEhC,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,SAAS,gBAAgB,EAAE,CAAA;gBAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,SAAS,gBAAgB,EAAO;CAKtE;AAED,MAAM,WAAW,sBAAsB;IACrC,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAKD,KAAK,2BAA2B,CAAC,WAAW,SAAS,4BAA4B,IAC7E,WAAW,GACX,OAAO,CAAC,iBAAiB,CAAC,MAAM,iBAAiB,CAAC,EAAE,4BAA4B,CAAC,CAAA;AAErF,MAAM,MAAM,wBAAwB,CAAC,WAAW,SAAS,4BAA4B,IACnF,kBAAkB,CAAC,WAAW,EAAE,2BAA2B,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC,CAAA;AAExF,wBAAgB,OAAO,CAAC,WAAW,SAAS,4BAA4B,EACtE,UAAU,EAAE,WAAW,EACvB,OAAO,CAAC,EAAE,sBAAsB,GAC/B;IAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC,WAAW,CAAC,CAAA;CAAE,CAQxD;AAED,wBAAgB,uBAAuB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAqD5E"}
package/dist/query.js CHANGED
@@ -3,10 +3,10 @@ import {
3
3
  SixbQueryError2,
4
4
  objects2,
5
5
  createHttpQueryExecutor2
6
- } from "./chunk-cs98dfbc.js";
7
- import"./chunk-rvaq39w5.js";
6
+ } from "./chunk-kh20z2mt.js";
7
+ import"./chunk-bsy1hg20.js";
8
8
  import"./chunk-65zz479s.js";
9
- import"./chunk-62nthgkf.js";
9
+ import"./chunk-e8qjsvha.js";
10
10
  export {
11
11
  SixbQueryError2 as SixbQueryError,
12
12
  createHttpQueryExecutor2 as createHttpQueryExecutor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/client",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Type-safe SDK for Sixb API with TanStack Query hooks",
5
5
  "keywords": [
6
6
  "sixb",
@@ -67,7 +67,7 @@
67
67
  "prepack": "bun run build"
68
68
  },
69
69
  "dependencies": {
70
- "@sixb/core": "^0.1.10"
70
+ "@sixb/core": "^0.1.12"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "@tanstack/react-query": "^5.0.0",
@@ -1,5 +1,11 @@
1
+ import { useQuery, useQueryClient } from "@tanstack/react-query"
1
2
  import { useCallback, useEffect, useMemo, useRef, useState } from "react"
2
3
  import { isSixbApiError } from "../api"
4
+ import { useSixbProviderClient } from "../client-provider"
5
+ import {
6
+ listPendingConnectorConnectionRunsOptions,
7
+ listPendingConnectorConnectionRunsQueryKey,
8
+ } from "../generated/@tanstack/react-query.gen"
3
9
  import {
4
10
  useConnectConnector,
5
11
  useDisconnectConnector,
@@ -88,13 +94,35 @@ export function useConnectorConnection({
88
94
  returnTo,
89
95
  }: UseConnectorConnectionOptions): UseConnectorConnectionResult {
90
96
  const [callback, setCallback] = useState(readConnectorConnectionCallback)
97
+ const providerClient = useSixbProviderClient()
98
+ const queryClient = useQueryClient()
99
+ const [dismissedRunIds, setDismissedRunIds] = useState<readonly string[]>([])
91
100
  const connectInFlightRef = useRef<Promise<void> | null>(null)
92
101
  const callbackRunId = callback?.connectorId === connectorId ? callback.runId : null
102
+ const pendingRunsQuery = useQuery({
103
+ ...listPendingConnectorConnectionRunsOptions({ client: providerClient, path: { connectorId } }),
104
+ enabled: callbackRunId === null,
105
+ staleTime: 0,
106
+ })
107
+ const recoveryPending = callbackRunId === null && pendingRunsQuery.isPending
108
+ const recoveryError = callbackRunId === null ? pendingRunsQuery.error : null
93
109
  const connectionsQuery = useConnectorConnections({ connectorId })
94
110
  const connection = useMemo(
95
111
  () => connectionsQuery.data?.find((candidate) => candidate.slot === slot),
96
112
  [connectionsQuery.data, slot]
97
113
  )
114
+ const pendingRun = pendingRunsQuery.data?.find(
115
+ (run) => run.slot === slot && !dismissedRunIds.includes(run.id)
116
+ )
117
+ useEffect(() => {
118
+ if (
119
+ callbackRunId === null &&
120
+ !connectionsQuery.isPending &&
121
+ !connectionsQuery.error &&
122
+ pendingRun
123
+ )
124
+ setCallback({ connectorId, runId: pendingRun.id })
125
+ }, [callbackRunId, connectorId, pendingRun, connectionsQuery.isPending, connectionsQuery.error])
98
126
  const runQuery = useConnectorConnectionRun({
99
127
  connectorId,
100
128
  runId: callbackRunId,
@@ -131,12 +159,20 @@ export function useConnectorConnection({
131
159
  if (result.error || !expectedCallback || !canConsume()) return
132
160
  if (!result.data?.some((candidate) => candidate.slot === slot)) return
133
161
 
162
+ await queryClient.invalidateQueries({
163
+ queryKey: listPendingConnectorConnectionRunsQueryKey({
164
+ client: providerClient,
165
+ path: { connectorId },
166
+ }),
167
+ })
168
+ if (!canConsume()) return
169
+ setDismissedRunIds((current) => [...current, expectedCallback.runId])
134
170
  clearConnectorConnectionCallback(expectedCallback)
135
171
  setCallback((current) =>
136
172
  sameConnectorConnectionCallback(current, expectedCallback) ? null : current
137
173
  )
138
174
  },
139
- [connectionsQuery.refetch, slot]
175
+ [connectionsQuery.refetch, slot, queryClient, connectorId, providerClient]
140
176
  )
141
177
 
142
178
  const completedRunId = resumedRun?.status === "succeeded" ? resumedRun.id : null
@@ -197,6 +233,7 @@ export function useConnectorConnection({
197
233
  }
198
234
 
199
235
  async function refresh(): Promise<void> {
236
+ if (callbackRunId === null) await pendingRunsQuery.refetch()
200
237
  let completedCallback: ConnectorConnectionCallback | undefined
201
238
  if (callbackRunId !== null) {
202
239
  const runResult = await runQuery.refetch()
@@ -217,6 +254,7 @@ export function useConnectorConnection({
217
254
 
218
255
  function dismiss(): void {
219
256
  if (!callback) return
257
+ setDismissedRunIds((current) => [...current, callback.runId])
220
258
  clearConnectorConnectionCallback(callback)
221
259
  setCallback(null)
222
260
  resetError()
@@ -232,8 +270,8 @@ export function useConnectorConnection({
232
270
 
233
271
  const status = connectionStatus({
234
272
  callbackRunId,
235
- connectionsPending: connectionsQuery.isPending,
236
- connectionsError: connectionsQuery.error,
273
+ connectionsPending: connectionsQuery.isPending || recoveryPending,
274
+ connectionsError: connectionsQuery.error ?? recoveryError,
237
275
  runPending: runQuery.isPending,
238
276
  runError: runQuery.error,
239
277
  run: resumedRun,
@@ -247,7 +285,7 @@ export function useConnectorConnection({
247
285
  revokeMutation.isPending
248
286
  const canConnect = connectorCanConnect({
249
287
  status,
250
- connectionsError: connectionsQuery.error,
288
+ connectionsError: connectionsQuery.error ?? recoveryError,
251
289
  runError: runQuery.error,
252
290
  run: resumedRun,
253
291
  connection,
@@ -265,7 +303,7 @@ export function useConnectorConnection({
265
303
  mutationFailure("disconnect", disconnectMutation.error) ??
266
304
  mutationFailure("revoke", revokeMutation.error) ??
267
305
  runFailure(callbackRunId, resumedRun, runQuery.error) ??
268
- mutationFailure("load", connectionsQuery.error),
306
+ mutationFailure("load", connectionsQuery.error ?? recoveryError),
269
307
  canConnect,
270
308
  isPending: status === "loading" || status === "authorizing" || mutationPending,
271
309
  selectedAccountId: selectMutation.variables?.accountId,
@@ -291,7 +329,7 @@ export function isConnectorReplacementRequired(error: unknown): boolean {
291
329
 
292
330
  function connectorCanConnect(input: {
293
331
  readonly status: ConnectorConnectionStatus
294
- readonly connectionsError: Error | null
332
+ readonly connectionsError: unknown
295
333
  readonly runError: Error | null
296
334
  readonly run: ConnectorConnectionRun | undefined
297
335
  readonly connection: ConnectorConnection | undefined
@@ -308,7 +346,7 @@ function connectorCanConnect(input: {
308
346
  function connectionStatus(input: {
309
347
  readonly callbackRunId: string | null
310
348
  readonly connectionsPending: boolean
311
- readonly connectionsError: Error | null
349
+ readonly connectionsError: unknown
312
350
  readonly runPending: boolean
313
351
  readonly runError: Error | null
314
352
  readonly run: ConnectorConnectionRun | undefined
@@ -9,6 +9,7 @@ import { useSixbProviderClient } from "../client-provider"
9
9
  import {
10
10
  getConnectorConnectionRunQueryKey,
11
11
  listConnectorConnectionsQueryKey,
12
+ listPendingConnectorConnectionRunsQueryKey,
12
13
  } from "../generated/@tanstack/react-query.gen"
13
14
  import type { Client } from "../generated/client"
14
15
  import {
@@ -201,7 +202,7 @@ export function selectConnectorAccountMutationOptions<TContext = unknown>(
201
202
  onSuccess: async (run, variables, context, mutation) => {
202
203
  const resolvedPath = path()
203
204
  queryClient?.setQueryData(getConnectorConnectionRunQueryKey({ path: resolvedPath }), run)
204
- await invalidateConnectorConnections(queryClient, resolvedPath.connectorId)
205
+ await invalidateConnectorConnections(queryClient, resolvedPath.connectorId, client)
205
206
  await onSuccess?.(run, variables, context, mutation)
206
207
  },
207
208
  }
@@ -263,7 +264,7 @@ export function disconnectConnectorMutationOptions<TContext = unknown>(
263
264
  return data
264
265
  },
265
266
  onSuccess: async (result, variables, context, mutation) => {
266
- await invalidateConnectorConnections(queryClient, normalizedConnectorId)
267
+ await invalidateConnectorConnections(queryClient, normalizedConnectorId, client)
267
268
  await onSuccess?.(result, variables, context, mutation)
268
269
  },
269
270
  }
@@ -310,7 +311,7 @@ export function revokeConnectorMutationOptions<TContext = unknown>(
310
311
  return data
311
312
  },
312
313
  onSuccess: async (result, variables, context, mutation) => {
313
- await invalidateConnectorConnections(queryClient, normalizedConnectorId)
314
+ await invalidateConnectorConnections(queryClient, normalizedConnectorId, client)
314
315
  await onSuccess?.(result, variables, context, mutation)
315
316
  },
316
317
  }
@@ -408,9 +409,13 @@ function resolveReturnTo(value: string): string {
408
409
 
409
410
  async function invalidateConnectorConnections(
410
411
  queryClient: QueryClient | undefined,
411
- connectorId: string
412
+ connectorId: string,
413
+ client: Client | undefined
412
414
  ): Promise<void> {
413
415
  if (!queryClient) return
416
+ await queryClient.invalidateQueries({
417
+ queryKey: listPendingConnectorConnectionRunsQueryKey({ client, path: { connectorId } }),
418
+ })
414
419
  await queryClient.invalidateQueries({
415
420
  queryKey: listConnectorConnectionsQueryKey({ path: { connectorId } }),
416
421
  })
package/src/file.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { FileRef } from "@sixb/core"
1
+ import type { AuthSessionAudience, FileRef } from "@sixb/core"
2
2
  import { DEFAULT_SIMPLE_FILE_UPLOAD_BYTES } from "@sixb/core/blob-storage"
3
3
  import { isSixbApiError, type SixbClient } from "./api"
4
4
  import { client as sharedClient } from "./generated/client.gen"
@@ -18,6 +18,8 @@ export interface ObjectFileContentUrlInput {
18
18
  /** Property path segments, without the leading `properties` segment. */
19
19
  readonly pathSegments: readonly string[]
20
20
  readonly fileRef: FileRef
21
+ /** Session audience for browser file navigation, e.g. "app" in split-domain deployments. */
22
+ readonly audience?: AuthSessionAudience
21
23
  readonly disposition?: "inline" | "attachment"
22
24
  readonly client?: SixbClient
23
25
  }
@@ -38,6 +40,7 @@ export function objectFileContentUrl(input: ObjectFileContentUrlInput): string {
38
40
  .map((segment) => segment.replaceAll("~", "~0").replaceAll("/", "~1"))
39
41
  .join("/")}`,
40
42
  disposition: input.disposition,
43
+ audience: input.audience,
41
44
  // Opaque cache key, not a historical-file selector. Include per-reference metadata.
42
45
  // Encode each field so Elysia won't interpret commas in filenames as an array.
43
46
  v: [digest, fileName ?? "", mediaType ?? "", logicalPath ?? ""]
@@ -131,7 +134,7 @@ async function uploadFileStaged(file: File | Blob, options: UploadFileOptions):
131
134
  createFileUpload({ body: uploadBody, client: options.client, ...callOptions(options.signal) })
132
135
  )
133
136
 
134
- let parts: Array<{ partNumber: number; etag: string }> | undefined
137
+ let parts: Array<{ partNumber: number; etag?: string }> | undefined
135
138
  let completed: Omit<FileRef, "digest"> & { readonly digest: string }
136
139
  try {
137
140
  if (upload.strategy === "server") {
@@ -158,6 +161,7 @@ async function uploadFileStaged(file: File | Blob, options: UploadFileOptions):
158
161
  fetch: options.fetch ?? globalThis.fetch,
159
162
  file,
160
163
  partSizeBytes: upload.partSizeBytes,
164
+ partReceipt: upload.partReceipt ?? "etag",
161
165
  uploadId: upload.uploadId,
162
166
  signal: options.signal,
163
167
  })
@@ -220,10 +224,11 @@ async function uploadMultipartFile(input: {
220
224
  readonly fetch: typeof fetch
221
225
  readonly file: File | Blob
222
226
  readonly partSizeBytes: number
227
+ readonly partReceipt: "etag" | "none"
223
228
  readonly uploadId: string
224
229
  readonly signal?: AbortSignal
225
- }): Promise<Array<{ partNumber: number; etag: string }>> {
226
- const parts: Array<{ partNumber: number; etag: string }> = []
230
+ }): Promise<Array<{ partNumber: number; etag?: string }>> {
231
+ const parts: Array<{ partNumber: number; etag?: string }> = []
227
232
  let partNumber = 1
228
233
 
229
234
  for (let offset = 0; offset < input.file.size; offset += input.partSizeBytes) {
@@ -255,14 +260,14 @@ async function uploadMultipartFile(input: {
255
260
  }
256
261
 
257
262
  const etag = response.headers.get("etag")
258
- if (!etag) {
263
+ if (input.partReceipt === "etag" && !etag) {
259
264
  throw new SixbFileUploadError(
260
265
  `[SixbClient] Multipart file upload part ${partNumber} did not return an ETag.`,
261
266
  { stage: "multipart" }
262
267
  )
263
268
  }
264
269
 
265
- parts.push({ partNumber, etag })
270
+ parts.push(input.partReceipt === "etag" && etag ? { partNumber, etag } : { partNumber })
266
271
  partNumber += 1
267
272
  }
268
273
 
@@ -97,6 +97,7 @@ import {
97
97
  listModels,
98
98
  listObjects,
99
99
  listObjectTypes,
100
+ listPendingConnectorConnectionRuns,
100
101
  listPipelineRuns,
101
102
  listPipelines,
102
103
  listProjectionRuns,
@@ -116,6 +117,7 @@ import {
116
117
  queryObjects,
117
118
  reactivateAuthMember,
118
119
  reauthorizeConnectorConnection,
120
+ recreateAgentThreadSandbox,
119
121
  removeObjectLink,
120
122
  requestAction,
121
123
  requestPipelineRun,
@@ -398,6 +400,9 @@ import type {
398
400
  ListObjectsResponse,
399
401
  ListObjectTypesData,
400
402
  ListObjectTypesResponse,
403
+ ListPendingConnectorConnectionRunsData,
404
+ ListPendingConnectorConnectionRunsError,
405
+ ListPendingConnectorConnectionRunsResponse,
401
406
  ListPipelineRunsData,
402
407
  ListPipelineRunsError,
403
408
  ListPipelineRunsResponse,
@@ -447,6 +452,9 @@ import type {
447
452
  ReauthorizeConnectorConnectionData,
448
453
  ReauthorizeConnectorConnectionError,
449
454
  ReauthorizeConnectorConnectionResponse,
455
+ RecreateAgentThreadSandboxData,
456
+ RecreateAgentThreadSandboxError,
457
+ RecreateAgentThreadSandboxResponse,
450
458
  RemoveObjectLinkData,
451
459
  RemoveObjectLinkError,
452
460
  RemoveObjectLinkResponse,
@@ -1867,6 +1875,34 @@ export const revokeConnectorConnectionMutation = (
1867
1875
  return mutationOptions
1868
1876
  }
1869
1877
 
1878
+ export const listPendingConnectorConnectionRunsQueryKey = (
1879
+ options: Options<ListPendingConnectorConnectionRunsData>
1880
+ ) => createQueryKey("listPendingConnectorConnectionRuns", options)
1881
+
1882
+ /**
1883
+ * List the initiating user's pending connector connection runs
1884
+ */
1885
+ export const listPendingConnectorConnectionRunsOptions = (
1886
+ options: Options<ListPendingConnectorConnectionRunsData>
1887
+ ) =>
1888
+ queryOptions<
1889
+ ListPendingConnectorConnectionRunsResponse,
1890
+ ListPendingConnectorConnectionRunsError,
1891
+ ListPendingConnectorConnectionRunsResponse,
1892
+ ReturnType<typeof listPendingConnectorConnectionRunsQueryKey>
1893
+ >({
1894
+ queryFn: async ({ queryKey, signal }) => {
1895
+ const { data } = await listPendingConnectorConnectionRuns({
1896
+ ...options,
1897
+ ...queryKey[0],
1898
+ signal,
1899
+ throwOnError: true,
1900
+ })
1901
+ return data
1902
+ },
1903
+ queryKey: listPendingConnectorConnectionRunsQueryKey(options),
1904
+ })
1905
+
1870
1906
  /**
1871
1907
  * Start a connector connection run
1872
1908
  */
@@ -4056,6 +4092,33 @@ export const getAgentThreadOptions = (options: Options<GetAgentThreadData>) =>
4056
4092
  queryKey: getAgentThreadQueryKey(options),
4057
4093
  })
4058
4094
 
4095
+ /**
4096
+ * Explicitly recreate an unavailable or uncertain workspace without deleting its previous state
4097
+ */
4098
+ export const recreateAgentThreadSandboxMutation = (
4099
+ options?: Partial<Options<RecreateAgentThreadSandboxData>>
4100
+ ): UseMutationOptions<
4101
+ RecreateAgentThreadSandboxResponse,
4102
+ RecreateAgentThreadSandboxError,
4103
+ Options<RecreateAgentThreadSandboxData>
4104
+ > => {
4105
+ const mutationOptions: UseMutationOptions<
4106
+ RecreateAgentThreadSandboxResponse,
4107
+ RecreateAgentThreadSandboxError,
4108
+ Options<RecreateAgentThreadSandboxData>
4109
+ > = {
4110
+ mutationFn: async (fnOptions) => {
4111
+ const { data } = await recreateAgentThreadSandbox({
4112
+ ...options,
4113
+ ...fnOptions,
4114
+ throwOnError: true,
4115
+ })
4116
+ return data
4117
+ },
4118
+ }
4119
+ return mutationOptions
4120
+ }
4121
+
4059
4122
  export const listAgentThreadMessagesQueryKey = (options: Options<ListAgentThreadMessagesData>) =>
4060
4123
  createQueryKey("listAgentThreadMessages", options)
4061
4124
 
@@ -93,6 +93,7 @@ export {
93
93
  listModels,
94
94
  listObjects,
95
95
  listObjectTypes,
96
+ listPendingConnectorConnectionRuns,
96
97
  listPipelineRuns,
97
98
  listPipelines,
98
99
  listProjectionRuns,
@@ -112,6 +113,7 @@ export {
112
113
  queryObjects,
113
114
  reactivateAuthMember,
114
115
  reauthorizeConnectorConnection,
116
+ recreateAgentThreadSandbox,
115
117
  removeObjectLink,
116
118
  requestAction,
117
119
  requestPipelineRun,
@@ -151,6 +153,7 @@ export type {
151
153
  AddConnectorConnectionErrors,
152
154
  AddConnectorConnectionResponse,
153
155
  AddConnectorConnectionResponses,
156
+ AiUsageLimitErrorResponse,
154
157
  AppendTelemetryData,
155
158
  AppendTelemetryError,
156
159
  AppendTelemetryErrors,
@@ -582,6 +585,11 @@ export type {
582
585
  ListObjectTypesData,
583
586
  ListObjectTypesResponse,
584
587
  ListObjectTypesResponses,
588
+ ListPendingConnectorConnectionRunsData,
589
+ ListPendingConnectorConnectionRunsError,
590
+ ListPendingConnectorConnectionRunsErrors,
591
+ ListPendingConnectorConnectionRunsResponse,
592
+ ListPendingConnectorConnectionRunsResponses,
585
593
  ListPipelineRunsData,
586
594
  ListPipelineRunsError,
587
595
  ListPipelineRunsErrors,
@@ -686,6 +694,11 @@ export type {
686
694
  ReauthorizeConnectorConnectionErrors,
687
695
  ReauthorizeConnectorConnectionResponse,
688
696
  ReauthorizeConnectorConnectionResponses,
697
+ RecreateAgentThreadSandboxData,
698
+ RecreateAgentThreadSandboxError,
699
+ RecreateAgentThreadSandboxErrors,
700
+ RecreateAgentThreadSandboxResponse,
701
+ RecreateAgentThreadSandboxResponses,
689
702
  RemoveObjectLinkData,
690
703
  RemoveObjectLinkError,
691
704
  RemoveObjectLinkErrors,
@@ -276,6 +276,9 @@ import type {
276
276
  ListObjectsResponses,
277
277
  ListObjectTypesData,
278
278
  ListObjectTypesResponses,
279
+ ListPendingConnectorConnectionRunsData,
280
+ ListPendingConnectorConnectionRunsErrors,
281
+ ListPendingConnectorConnectionRunsResponses,
279
282
  ListPipelineRunsData,
280
283
  ListPipelineRunsErrors,
281
284
  ListPipelineRunsResponses,
@@ -325,6 +328,9 @@ import type {
325
328
  ReauthorizeConnectorConnectionData,
326
329
  ReauthorizeConnectorConnectionErrors,
327
330
  ReauthorizeConnectorConnectionResponses,
331
+ RecreateAgentThreadSandboxData,
332
+ RecreateAgentThreadSandboxErrors,
333
+ RecreateAgentThreadSandboxResponses,
328
334
  RemoveObjectLinkData,
329
335
  RemoveObjectLinkErrors,
330
336
  RemoveObjectLinkResponses,
@@ -1090,6 +1096,18 @@ export const revokeConnectorConnection = <ThrowOnError extends boolean = false>(
1090
1096
  ...options,
1091
1097
  })
1092
1098
 
1099
+ /**
1100
+ * List the initiating user's pending connector connection runs
1101
+ */
1102
+ export const listPendingConnectorConnectionRuns = <ThrowOnError extends boolean = false>(
1103
+ options: Options<ListPendingConnectorConnectionRunsData, ThrowOnError>
1104
+ ) =>
1105
+ (options.client ?? client).get<
1106
+ ListPendingConnectorConnectionRunsResponses,
1107
+ ListPendingConnectorConnectionRunsErrors,
1108
+ ThrowOnError
1109
+ >({ url: "/api/connectors/{connectorId}/connection-runs", ...options })
1110
+
1093
1111
  /**
1094
1112
  * Start a connector connection run
1095
1113
  */
@@ -2219,6 +2237,26 @@ export const getAgentThread = <ThrowOnError extends boolean = false>(
2219
2237
  ...options,
2220
2238
  })
2221
2239
 
2240
+ /**
2241
+ * Explicitly recreate an unavailable or uncertain workspace without deleting its previous state
2242
+ */
2243
+ export const recreateAgentThreadSandbox = <ThrowOnError extends boolean = false>(
2244
+ options: Options<RecreateAgentThreadSandboxData, ThrowOnError>
2245
+ ) =>
2246
+ (options.client ?? client).post<
2247
+ RecreateAgentThreadSandboxResponses,
2248
+ RecreateAgentThreadSandboxErrors,
2249
+ ThrowOnError
2250
+ >({
2251
+ security: [{ name: "x-sixb-csrf", type: "apiKey" }],
2252
+ url: "/api/agent-threads/{threadId}/sandbox/recreate",
2253
+ ...options,
2254
+ headers: {
2255
+ "Content-Type": "application/json",
2256
+ ...options.headers,
2257
+ },
2258
+ })
2259
+
2222
2260
  /**
2223
2261
  * List agent thread messages
2224
2262
  */