@sixb/client 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +5 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/browser.d.ts +18 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +201 -56
- package/dist/browser.js.map +3 -3
- package/dist/{chunk-r8p88mbg.js → chunk-62nthgkf.js} +263 -181
- package/dist/chunk-62nthgkf.js.map +19 -0
- package/dist/chunk-65zz479s.js +23 -0
- package/dist/chunk-65zz479s.js.map +10 -0
- package/dist/{chunk-dcebhkmz.js → chunk-6pmyt76w.js} +103 -83
- package/dist/chunk-6pmyt76w.js.map +17 -0
- package/dist/{chunk-p0xrjaz6.js → chunk-cs98dfbc.js} +20 -20
- package/dist/{chunk-p0xrjaz6.js.map → chunk-cs98dfbc.js.map} +2 -2
- package/dist/{chunk-h80qj1f8.js → chunk-d0m9gz29.js} +19 -4
- package/dist/chunk-d0m9gz29.js.map +10 -0
- package/dist/{chunk-m4by7m5r.js → chunk-dp68jpeq.js} +32 -15
- package/dist/chunk-dp68jpeq.js.map +12 -0
- package/dist/chunk-rvaq39w5.js +215 -0
- package/dist/chunk-rvaq39w5.js.map +10 -0
- package/dist/{chunk-mpgzkmwc.js → chunk-tyym13kq.js} +10 -10
- package/dist/{chunk-mpgzkmwc.js.map → chunk-tyym13kq.js.map} +2 -2
- package/dist/client-authority.d.ts +6 -0
- package/dist/client-authority.d.ts.map +1 -0
- package/dist/connectors/queries.d.ts +8 -0
- package/dist/connectors/queries.d.ts.map +1 -1
- package/dist/events-builder.d.ts.map +1 -1
- package/dist/generated/@tanstack/react-query.gen.d.ts +1195 -135
- package/dist/generated/@tanstack/react-query.gen.d.ts.map +1 -1
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/sdk.gen.d.ts +25 -1
- package/dist/generated/sdk.gen.d.ts.map +1 -1
- package/dist/generated/types.gen.d.ts +501 -3
- package/dist/generated/types.gen.d.ts.map +1 -1
- package/dist/hooks.js +783 -669
- package/dist/hooks.js.map +3 -3
- package/dist/index.js +373 -358
- package/dist/index.js.map +1 -1
- package/dist/logs-builder.d.ts.map +1 -1
- package/dist/logs.js +18 -17
- package/dist/logs.js.map +1 -1
- package/dist/models.js +292 -280
- package/dist/models.js.map +1 -1
- package/dist/query.js +11 -10
- package/dist/query.js.map +1 -1
- package/dist/ws-socket.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/api.ts +92 -3
- package/src/browser.ts +257 -48
- package/src/client-authority.ts +31 -0
- package/src/events-builder.ts +18 -1
- package/src/generated/@tanstack/react-query.gen.ts +229 -0
- package/src/generated/index.ts +36 -0
- package/src/generated/sdk.gen.ts +178 -12
- package/src/generated/types.gen.ts +550 -3
- package/src/logs-builder.ts +14 -1
- package/src/ws-socket.ts +11 -0
- package/dist/chunk-b3bfdm80.js +0 -160
- package/dist/chunk-b3bfdm80.js.map +0 -10
- package/dist/chunk-dcebhkmz.js.map +0 -17
- package/dist/chunk-h80qj1f8.js.map +0 -10
- package/dist/chunk-m4by7m5r.js.map +0 -12
- package/dist/chunk-r8p88mbg.js.map +0 -19
- /package/dist/{chunk-trpg18dp.js → chunk-0ka9ykez.js} +0 -0
- /package/dist/{chunk-trpg18dp.js.map → chunk-0ka9ykez.js.map} +0 -0
|
@@ -1,36 +1,40 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./chunk-
|
|
3
|
+
SHARED_ACCESS_REALTIME_UNAVAILABLE,
|
|
4
|
+
hasClientSharedAuthority
|
|
5
|
+
} from "./chunk-65zz479s.js";
|
|
6
|
+
import {
|
|
7
|
+
client2,
|
|
8
|
+
requestAction2,
|
|
9
|
+
uploadFileRaw2,
|
|
10
|
+
createFileUpload2,
|
|
11
|
+
uploadFileContent2,
|
|
12
|
+
signFileUploadPart2,
|
|
13
|
+
completeFileUpload2,
|
|
14
|
+
abortFileUpload2,
|
|
15
|
+
getActionRun2
|
|
16
|
+
} from "./chunk-62nthgkf.js";
|
|
6
17
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
18
|
+
encodeObjectId2,
|
|
19
|
+
decodeObjectId2
|
|
20
|
+
} from "./chunk-tyym13kq.js";
|
|
10
21
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./chunk-
|
|
22
|
+
isSixbApiError2
|
|
23
|
+
} from "./chunk-rvaq39w5.js";
|
|
13
24
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
createFileUpload,
|
|
18
|
-
getActionRun,
|
|
19
|
-
requestAction,
|
|
20
|
-
signFileUploadPart,
|
|
21
|
-
uploadFileContent,
|
|
22
|
-
uploadFileRaw
|
|
23
|
-
} from "./chunk-r8p88mbg.js";
|
|
25
|
+
createReconnectingSocket,
|
|
26
|
+
createSixbWebSocketUrl
|
|
27
|
+
} from "./chunk-d0m9gz29.js";
|
|
24
28
|
|
|
25
29
|
// src/agent-streams.ts
|
|
26
30
|
import { isAgentRunActivityEvent, isAgentRunStreamEvent } from "@sixb/core/agents/streams";
|
|
27
|
-
function
|
|
31
|
+
function createSixbAgentsWebSocketUrl2(baseUrl) {
|
|
28
32
|
return createSixbWebSocketUrl("/ws/agents", baseUrl);
|
|
29
33
|
}
|
|
30
|
-
function
|
|
34
|
+
function createAgentRunSocket2(options) {
|
|
31
35
|
let latestCursor = options.afterCursor;
|
|
32
36
|
return createReconnectingSocket({
|
|
33
|
-
url:
|
|
37
|
+
url: createSixbAgentsWebSocketUrl2(options.baseUrl),
|
|
34
38
|
reconnect: options.reconnect,
|
|
35
39
|
reconnectDelayMs: options.reconnectDelayMs,
|
|
36
40
|
connectionErrorMessage: "Agent stream websocket connection failed.",
|
|
@@ -42,7 +46,7 @@ function createAgentRunSocket(options) {
|
|
|
42
46
|
...latestCursor ? { afterCursor: latestCursor } : {}
|
|
43
47
|
}),
|
|
44
48
|
onMessage: (data, sink) => {
|
|
45
|
-
const message =
|
|
49
|
+
const message = parseAgentRunStreamServerMessage2(data);
|
|
46
50
|
if (!message)
|
|
47
51
|
return;
|
|
48
52
|
if (message.type === "record") {
|
|
@@ -60,9 +64,9 @@ function createAgentRunSocket(options) {
|
|
|
60
64
|
}
|
|
61
65
|
});
|
|
62
66
|
}
|
|
63
|
-
function
|
|
67
|
+
function createAgentActivitySocket2(options) {
|
|
64
68
|
return createReconnectingSocket({
|
|
65
|
-
url:
|
|
69
|
+
url: createSixbAgentsWebSocketUrl2(options.baseUrl),
|
|
66
70
|
reconnect: options.reconnect,
|
|
67
71
|
reconnectDelayMs: options.reconnectDelayMs,
|
|
68
72
|
connectionErrorMessage: "Agent activity websocket connection failed.",
|
|
@@ -70,7 +74,7 @@ function createAgentActivitySocket(options) {
|
|
|
70
74
|
onStateChange: options.onStateChange,
|
|
71
75
|
subscribeMessage: () => ({ type: "subscribe.activity" }),
|
|
72
76
|
onMessage: (data, sink) => {
|
|
73
|
-
const message =
|
|
77
|
+
const message = parseAgentRunStreamServerMessage2(data);
|
|
74
78
|
if (!message)
|
|
75
79
|
return;
|
|
76
80
|
if (message.type === "activity") {
|
|
@@ -86,7 +90,7 @@ function createAgentActivitySocket(options) {
|
|
|
86
90
|
}
|
|
87
91
|
});
|
|
88
92
|
}
|
|
89
|
-
function
|
|
93
|
+
function parseAgentRunStreamServerMessage2(value) {
|
|
90
94
|
if (typeof value !== "string") {
|
|
91
95
|
return null;
|
|
92
96
|
}
|
|
@@ -166,7 +170,7 @@ function isRecord(value) {
|
|
|
166
170
|
}
|
|
167
171
|
|
|
168
172
|
// src/events-model.ts
|
|
169
|
-
function
|
|
173
|
+
function isSixbEvent2(value) {
|
|
170
174
|
return isRecord2(value) && typeof value.id === "string" && typeof value.cursor === "string" && typeof value.projectId === "string" && typeof value.occurredAt === "string" && typeof value.type === "string" && typeof value.topic === "string" && typeof value.partitionKey === "string";
|
|
171
175
|
}
|
|
172
176
|
function isRecord2(value) {
|
|
@@ -174,7 +178,7 @@ function isRecord2(value) {
|
|
|
174
178
|
}
|
|
175
179
|
|
|
176
180
|
// src/events-transport.ts
|
|
177
|
-
function
|
|
181
|
+
function createEventSocket2(options) {
|
|
178
182
|
const { topic, types, objectTypeId, primaryId, actionId, runId, limit } = options;
|
|
179
183
|
let latestCursor = options.afterCursor;
|
|
180
184
|
let transportState = {
|
|
@@ -190,7 +194,7 @@ function createEventSocket(options) {
|
|
|
190
194
|
});
|
|
191
195
|
};
|
|
192
196
|
return createReconnectingSocket({
|
|
193
|
-
url:
|
|
197
|
+
url: createSixbEventsWebSocketUrl2(options.baseUrl),
|
|
194
198
|
reconnect: options.reconnect,
|
|
195
199
|
reconnectDelayMs: options.reconnectDelayMs,
|
|
196
200
|
readyTimeoutMs: options.handshakeTimeoutMs,
|
|
@@ -214,15 +218,15 @@ function createEventSocket(options) {
|
|
|
214
218
|
...latestCursor ? { afterCursor: latestCursor } : {},
|
|
215
219
|
...limit ? { limit } : {}
|
|
216
220
|
}),
|
|
217
|
-
subscribeWhen: (data) =>
|
|
218
|
-
readyWhen: (data) =>
|
|
221
|
+
subscribeWhen: (data) => parseEventStreamMessage2(data)?.type === "connected",
|
|
222
|
+
readyWhen: (data) => parseEventStreamMessage2(data)?.type === "subscribed",
|
|
219
223
|
onMessage: (data, sink) => {
|
|
220
|
-
const message =
|
|
224
|
+
const message = parseEventStreamMessage2(data);
|
|
221
225
|
if (!message)
|
|
222
226
|
return;
|
|
223
227
|
if (message.type === "event") {
|
|
224
228
|
latestCursor = message.event.cursor;
|
|
225
|
-
if (
|
|
229
|
+
if (matchesSubscription2(message.event, topic, types)) {
|
|
226
230
|
options.onEvent(message.event);
|
|
227
231
|
}
|
|
228
232
|
return;
|
|
@@ -238,10 +242,10 @@ function createEventSocket(options) {
|
|
|
238
242
|
}
|
|
239
243
|
});
|
|
240
244
|
}
|
|
241
|
-
function
|
|
245
|
+
function createSixbEventsWebSocketUrl2(baseUrl) {
|
|
242
246
|
return createSixbWebSocketUrl("/ws/events", baseUrl);
|
|
243
247
|
}
|
|
244
|
-
function
|
|
248
|
+
function parseEventStreamMessage2(value) {
|
|
245
249
|
if (typeof value !== "string") {
|
|
246
250
|
return null;
|
|
247
251
|
}
|
|
@@ -254,7 +258,7 @@ function parseEventStreamMessage(value) {
|
|
|
254
258
|
if (!isRecord3(parsed) || typeof parsed.type !== "string") {
|
|
255
259
|
return null;
|
|
256
260
|
}
|
|
257
|
-
if (parsed.type === "event" &&
|
|
261
|
+
if (parsed.type === "event" && isSixbEvent2(parsed.event)) {
|
|
258
262
|
return { type: "event", event: parsed.event };
|
|
259
263
|
}
|
|
260
264
|
if (parsed.type === "error") {
|
|
@@ -265,7 +269,7 @@ function parseEventStreamMessage(value) {
|
|
|
265
269
|
}
|
|
266
270
|
return null;
|
|
267
271
|
}
|
|
268
|
-
function
|
|
272
|
+
function matchesSubscription2(event, topic, types) {
|
|
269
273
|
if (topic && event.topic !== topic) {
|
|
270
274
|
return false;
|
|
271
275
|
}
|
|
@@ -284,12 +288,28 @@ import {
|
|
|
284
288
|
eventSelectorSpec,
|
|
285
289
|
events as selectEvents
|
|
286
290
|
} from "@sixb/core/events/selectors";
|
|
287
|
-
function
|
|
288
|
-
const
|
|
291
|
+
function createWsSubscribeExecutor2(options) {
|
|
292
|
+
const transportClient = options?.client ?? client2;
|
|
293
|
+
const baseUrl = transportClient.getConfig().baseUrl;
|
|
294
|
+
if (hasClientSharedAuthority(transportClient)) {
|
|
295
|
+
return {
|
|
296
|
+
subscribe(_filter, _handler, subscribeOptions) {
|
|
297
|
+
subscribeOptions?.onError?.(SHARED_ACCESS_REALTIME_UNAVAILABLE);
|
|
298
|
+
subscribeOptions?.onStateChange?.({
|
|
299
|
+
connected: false,
|
|
300
|
+
reconnecting: false,
|
|
301
|
+
error: SHARED_ACCESS_REALTIME_UNAVAILABLE
|
|
302
|
+
});
|
|
303
|
+
return () => {
|
|
304
|
+
return;
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
289
309
|
return {
|
|
290
310
|
subscribe(filter, handler, subscribeOptions) {
|
|
291
|
-
const matches =
|
|
292
|
-
const socket =
|
|
311
|
+
const matches = buildEventPredicate2(filter);
|
|
312
|
+
const socket = createEventSocket2({
|
|
293
313
|
topic: filter.topic,
|
|
294
314
|
types: filter.types,
|
|
295
315
|
objectTypeId: filter.objectTypeId,
|
|
@@ -313,7 +333,7 @@ function createWsSubscribeExecutor(options) {
|
|
|
313
333
|
}
|
|
314
334
|
};
|
|
315
335
|
}
|
|
316
|
-
function
|
|
336
|
+
function buildEventPredicate2(filter) {
|
|
317
337
|
const matches = buildEventSelectorPredicate(filter);
|
|
318
338
|
return (event) => matches(event);
|
|
319
339
|
}
|
|
@@ -472,7 +492,7 @@ class EventsBuilderImpl {
|
|
|
472
492
|
}
|
|
473
493
|
}
|
|
474
494
|
function createBuilder(filter, options, params = {}) {
|
|
475
|
-
return new EventsBuilderImpl({ filter, executor:
|
|
495
|
+
return new EventsBuilderImpl({ filter, executor: createWsSubscribeExecutor2(options), ...params });
|
|
476
496
|
}
|
|
477
497
|
function createPropertySelectorMap(tokens, createSelector) {
|
|
478
498
|
return Object.fromEntries(Object.entries(tokens).map(([propertyId, token]) => [propertyId, createSelector(token)]));
|
|
@@ -535,10 +555,10 @@ eventsApi.datasets = (options) => topicBuilder("datasets", options);
|
|
|
535
555
|
eventsApi.workflows = (options) => runBuilder("workflows", options);
|
|
536
556
|
eventsApi.pipelines = (options) => runBuilder("pipelines", options);
|
|
537
557
|
eventsApi.syncs = (options) => runBuilder("syncs", options);
|
|
538
|
-
var
|
|
558
|
+
var events2 = eventsApi;
|
|
539
559
|
|
|
540
560
|
// src/telemetry-events.ts
|
|
541
|
-
function
|
|
561
|
+
function telemetryUpdateFromEvent2(event) {
|
|
542
562
|
return {
|
|
543
563
|
type: "telemetryUpdate",
|
|
544
564
|
projectId: event.projectId,
|
|
@@ -552,13 +572,13 @@ function telemetryUpdateFromEvent(event) {
|
|
|
552
572
|
unit: event.payload.unit
|
|
553
573
|
};
|
|
554
574
|
}
|
|
555
|
-
function
|
|
556
|
-
const parsed =
|
|
575
|
+
function objectIdAliases2(objectId) {
|
|
576
|
+
const parsed = decodeObjectId2(objectId);
|
|
557
577
|
if (!parsed)
|
|
558
578
|
return [objectId];
|
|
559
|
-
return [objectId, parsed.primaryId,
|
|
579
|
+
return [objectId, parsed.primaryId, encodeObjectId2(parsed.objectTypeId, parsed.primaryId)];
|
|
560
580
|
}
|
|
561
|
-
function
|
|
581
|
+
function telemetryUpdateKey2(projectId, objectId, propertyId) {
|
|
562
582
|
return `${projectId}:${objectId}:${propertyId}`;
|
|
563
583
|
}
|
|
564
584
|
function normalizeTelemetryValue(value) {
|
|
@@ -579,7 +599,7 @@ var DEFAULT_ACTION_WAIT_TIMEOUT_MS = 60000;
|
|
|
579
599
|
var DEFAULT_ACTION_WAIT_FALLBACK_POLL_MS = 1e4;
|
|
580
600
|
var DEFAULT_ACTION_WAIT_DISCONNECTED_POLL_MS = 1000;
|
|
581
601
|
|
|
582
|
-
class
|
|
602
|
+
class ActionRunFailedError2 extends Error {
|
|
583
603
|
name = "ActionRunFailedError";
|
|
584
604
|
run;
|
|
585
605
|
runId;
|
|
@@ -598,7 +618,7 @@ class ActionRunFailedError extends Error {
|
|
|
598
618
|
}
|
|
599
619
|
}
|
|
600
620
|
|
|
601
|
-
class
|
|
621
|
+
class ActionRunTimeoutError2 extends Error {
|
|
602
622
|
name = "ActionRunTimeoutError";
|
|
603
623
|
runId;
|
|
604
624
|
timeoutMs;
|
|
@@ -608,7 +628,7 @@ class ActionRunTimeoutError extends Error {
|
|
|
608
628
|
this.timeoutMs = params.timeoutMs;
|
|
609
629
|
}
|
|
610
630
|
}
|
|
611
|
-
async function
|
|
631
|
+
async function requestActionAndWait2(input) {
|
|
612
632
|
const {
|
|
613
633
|
timeoutMs,
|
|
614
634
|
fallbackPollIntervalMs,
|
|
@@ -617,12 +637,12 @@ async function requestActionAndWait(input) {
|
|
|
617
637
|
onRequested,
|
|
618
638
|
...requestOptions
|
|
619
639
|
} = input;
|
|
620
|
-
const response = await
|
|
640
|
+
const response = await requestAction2({
|
|
621
641
|
...requestOptions,
|
|
622
642
|
throwOnError: true
|
|
623
643
|
});
|
|
624
644
|
await onRequested?.(response.data);
|
|
625
|
-
return
|
|
645
|
+
return waitForActionRun2({
|
|
626
646
|
runId: response.data.runId,
|
|
627
647
|
client: input.client,
|
|
628
648
|
signal: input.signal,
|
|
@@ -632,7 +652,7 @@ async function requestActionAndWait(input) {
|
|
|
632
652
|
rejectOnTerminalFailure
|
|
633
653
|
});
|
|
634
654
|
}
|
|
635
|
-
function
|
|
655
|
+
function waitForActionRun2(input) {
|
|
636
656
|
const timeoutMs = input.timeoutMs ?? DEFAULT_ACTION_WAIT_TIMEOUT_MS;
|
|
637
657
|
const fallbackPollIntervalMs = input.fallbackPollIntervalMs ?? DEFAULT_ACTION_WAIT_FALLBACK_POLL_MS;
|
|
638
658
|
const disconnectedPollIntervalMs = input.disconnectedPollIntervalMs ?? DEFAULT_ACTION_WAIT_DISCONNECTED_POLL_MS;
|
|
@@ -670,7 +690,7 @@ function waitForActionRun(input) {
|
|
|
670
690
|
const resolveWith = (run) => {
|
|
671
691
|
cleanup();
|
|
672
692
|
if (rejectOnTerminalFailure && isTerminalFailureRun(run)) {
|
|
673
|
-
reject(new
|
|
693
|
+
reject(new ActionRunFailedError2(run));
|
|
674
694
|
return;
|
|
675
695
|
}
|
|
676
696
|
resolve(run);
|
|
@@ -709,7 +729,7 @@ function waitForActionRun(input) {
|
|
|
709
729
|
client: input.client,
|
|
710
730
|
signal
|
|
711
731
|
});
|
|
712
|
-
if (run &&
|
|
732
|
+
if (run && isTerminalActionRun2(run)) {
|
|
713
733
|
resolveWith(run);
|
|
714
734
|
return;
|
|
715
735
|
}
|
|
@@ -728,10 +748,10 @@ function waitForActionRun(input) {
|
|
|
728
748
|
rejectWith(signal?.reason ?? new Error("aborted"));
|
|
729
749
|
};
|
|
730
750
|
timeoutTimer = setTimeout(() => {
|
|
731
|
-
rejectWith(new
|
|
751
|
+
rejectWith(new ActionRunTimeoutError2({ runId: input.runId, timeoutMs }));
|
|
732
752
|
}, Math.max(0, timeoutMs - (Date.now() - startedAt)));
|
|
733
753
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
734
|
-
unsubscribeFromTerminalEvents =
|
|
754
|
+
unsubscribeFromTerminalEvents = events2.actions({ client: input.client }).run(input.runId).terminal().subscribe(() => {
|
|
735
755
|
wakeAndCheck();
|
|
736
756
|
}, {
|
|
737
757
|
onError: () => {
|
|
@@ -752,14 +772,14 @@ function waitForActionRun(input) {
|
|
|
752
772
|
check();
|
|
753
773
|
});
|
|
754
774
|
}
|
|
755
|
-
function
|
|
775
|
+
function isTerminalActionRun2(run) {
|
|
756
776
|
return run.status === "succeeded" || isTerminalFailureRun(run);
|
|
757
777
|
}
|
|
758
778
|
function isTerminalFailureRun(run) {
|
|
759
779
|
return run.status === "failed" || run.status === "cancelled";
|
|
760
780
|
}
|
|
761
781
|
async function fetchActionRun(runId, options) {
|
|
762
|
-
const result = await
|
|
782
|
+
const result = await getActionRun2({
|
|
763
783
|
client: options.client,
|
|
764
784
|
path: { runId },
|
|
765
785
|
signal: options.signal,
|
|
@@ -974,14 +994,14 @@ async function computeStreamingBlobDigest(file, chunkBytes = 8 * 1024 * 1024) {
|
|
|
974
994
|
}
|
|
975
995
|
|
|
976
996
|
// src/file.ts
|
|
977
|
-
function
|
|
997
|
+
function objectFileContentUrl2(input) {
|
|
978
998
|
if (!input.objectTypeId || !input.objectId || input.pathSegments.length === 0) {
|
|
979
999
|
throw new Error("[SixbClient] File content URLs require an object type, ID, and property path.");
|
|
980
1000
|
}
|
|
981
|
-
const
|
|
1001
|
+
const client = input.client ?? client2;
|
|
982
1002
|
const { digest, fileName, mediaType, logicalPath } = input.fileRef;
|
|
983
|
-
return
|
|
984
|
-
baseUrl:
|
|
1003
|
+
return client.buildUrl({
|
|
1004
|
+
baseUrl: client.getConfig().baseUrl,
|
|
985
1005
|
url: "/api/objects/{objectTypeId}/{objectId}/files/content",
|
|
986
1006
|
path: { objectTypeId: input.objectTypeId, objectId: input.objectId },
|
|
987
1007
|
query: {
|
|
@@ -992,7 +1012,7 @@ function objectFileContentUrl(input) {
|
|
|
992
1012
|
});
|
|
993
1013
|
}
|
|
994
1014
|
|
|
995
|
-
class
|
|
1015
|
+
class SixbFileUploadError2 extends Error {
|
|
996
1016
|
stage;
|
|
997
1017
|
status;
|
|
998
1018
|
aborted;
|
|
@@ -1004,7 +1024,7 @@ class SixbFileUploadError extends Error {
|
|
|
1004
1024
|
this.aborted = options.aborted ?? false;
|
|
1005
1025
|
}
|
|
1006
1026
|
}
|
|
1007
|
-
async function
|
|
1027
|
+
async function uploadFile2(file, options = {}) {
|
|
1008
1028
|
const thresholdBytes = options.stagedUploadThresholdBytes ?? DEFAULT_SIMPLE_FILE_UPLOAD_BYTES;
|
|
1009
1029
|
if (file.size > thresholdBytes) {
|
|
1010
1030
|
return uploadFileStaged(file, options);
|
|
@@ -1016,7 +1036,7 @@ async function uploadFileSimple(file, options) {
|
|
|
1016
1036
|
file: resolveUploadFile(file, options.fileName),
|
|
1017
1037
|
...options.logicalPath === undefined ? {} : { logicalPath: options.logicalPath }
|
|
1018
1038
|
};
|
|
1019
|
-
const data = await runUploadStep("server-put", () =>
|
|
1039
|
+
const data = await runUploadStep("server-put", () => uploadFileRaw2({ body, client: options.client, ...callOptions(options.signal) }));
|
|
1020
1040
|
return toFileRef(data, "server-put");
|
|
1021
1041
|
}
|
|
1022
1042
|
async function uploadFileStaged(file, options) {
|
|
@@ -1028,12 +1048,12 @@ async function uploadFileStaged(file, options) {
|
|
|
1028
1048
|
digest,
|
|
1029
1049
|
...options.logicalPath === undefined ? {} : { logicalPath: options.logicalPath }
|
|
1030
1050
|
};
|
|
1031
|
-
const upload = await runUploadStep("create", () =>
|
|
1051
|
+
const upload = await runUploadStep("create", () => createFileUpload2({ body: uploadBody, client: options.client, ...callOptions(options.signal) }));
|
|
1032
1052
|
let parts;
|
|
1033
1053
|
let completed;
|
|
1034
1054
|
try {
|
|
1035
1055
|
if (upload.strategy === "server") {
|
|
1036
|
-
await runUploadStep("server-put", () =>
|
|
1056
|
+
await runUploadStep("server-put", () => uploadFileContent2({
|
|
1037
1057
|
body: resolveUploadFile(file, options.fileName),
|
|
1038
1058
|
path: { uploadId: upload.uploadId },
|
|
1039
1059
|
client: options.client,
|
|
@@ -1058,14 +1078,14 @@ async function uploadFileStaged(file, options) {
|
|
|
1058
1078
|
signal: options.signal
|
|
1059
1079
|
});
|
|
1060
1080
|
}
|
|
1061
|
-
completed = await runUploadStep("complete", () =>
|
|
1081
|
+
completed = await runUploadStep("complete", () => completeFileUpload2({
|
|
1062
1082
|
body: { digest, sizeBytes: file.size, ...parts === undefined ? {} : { parts } },
|
|
1063
1083
|
path: { uploadId: upload.uploadId },
|
|
1064
1084
|
client: options.client,
|
|
1065
1085
|
...callOptions(options.signal)
|
|
1066
1086
|
}));
|
|
1067
1087
|
} catch (error) {
|
|
1068
|
-
await
|
|
1088
|
+
await abortFileUpload2({
|
|
1069
1089
|
path: { uploadId: upload.uploadId },
|
|
1070
1090
|
client: options.client,
|
|
1071
1091
|
responseStyle: "fields",
|
|
@@ -1090,14 +1110,14 @@ async function putDirectUpload(input) {
|
|
|
1090
1110
|
throw toSixbFileUploadError(error, "direct-put");
|
|
1091
1111
|
}
|
|
1092
1112
|
if (!response.ok) {
|
|
1093
|
-
throw new
|
|
1113
|
+
throw new SixbFileUploadError2(`[SixbClient] Direct file upload failed with HTTP ${response.status}.`, { stage: "direct-put", status: response.status });
|
|
1094
1114
|
}
|
|
1095
1115
|
}
|
|
1096
1116
|
async function uploadMultipartFile(input) {
|
|
1097
1117
|
const parts = [];
|
|
1098
1118
|
let partNumber = 1;
|
|
1099
1119
|
for (let offset = 0;offset < input.file.size; offset += input.partSizeBytes) {
|
|
1100
|
-
const signedPart = await runUploadStep("multipart", () =>
|
|
1120
|
+
const signedPart = await runUploadStep("multipart", () => signFileUploadPart2({
|
|
1101
1121
|
path: { uploadId: input.uploadId, partNumber: partNumber.toString() },
|
|
1102
1122
|
client: input.client,
|
|
1103
1123
|
...callOptions(input.signal)
|
|
@@ -1114,11 +1134,11 @@ async function uploadMultipartFile(input) {
|
|
|
1114
1134
|
throw toSixbFileUploadError(error, "multipart");
|
|
1115
1135
|
}
|
|
1116
1136
|
if (!response.ok) {
|
|
1117
|
-
throw new
|
|
1137
|
+
throw new SixbFileUploadError2(`[SixbClient] Multipart file upload part ${partNumber} failed with HTTP ${response.status}.`, { stage: "multipart", status: response.status });
|
|
1118
1138
|
}
|
|
1119
1139
|
const etag = response.headers.get("etag");
|
|
1120
1140
|
if (!etag) {
|
|
1121
|
-
throw new
|
|
1141
|
+
throw new SixbFileUploadError2(`[SixbClient] Multipart file upload part ${partNumber} did not return an ETag.`, { stage: "multipart" });
|
|
1122
1142
|
}
|
|
1123
1143
|
parts.push({ partNumber, etag });
|
|
1124
1144
|
partNumber += 1;
|
|
@@ -1151,7 +1171,7 @@ async function runUploadStep(stage, call) {
|
|
|
1151
1171
|
}
|
|
1152
1172
|
function toSixbFileUploadError(error, stage, status) {
|
|
1153
1173
|
if (isAbortError(error)) {
|
|
1154
|
-
return new
|
|
1174
|
+
return new SixbFileUploadError2("[SixbClient] File upload was aborted.", {
|
|
1155
1175
|
stage: "abort",
|
|
1156
1176
|
aborted: true,
|
|
1157
1177
|
cause: error
|
|
@@ -1159,9 +1179,9 @@ function toSixbFileUploadError(error, stage, status) {
|
|
|
1159
1179
|
}
|
|
1160
1180
|
const detail = uploadErrorDetail(error);
|
|
1161
1181
|
const message = detail ? `[SixbClient] ${detail}` : "[SixbClient] File upload request failed.";
|
|
1162
|
-
return new
|
|
1182
|
+
return new SixbFileUploadError2(message, {
|
|
1163
1183
|
stage,
|
|
1164
|
-
status: status ?? (
|
|
1184
|
+
status: status ?? (isSixbApiError2(error) ? error.status : undefined),
|
|
1165
1185
|
cause: error
|
|
1166
1186
|
});
|
|
1167
1187
|
}
|
|
@@ -1169,7 +1189,7 @@ function isAbortError(error) {
|
|
|
1169
1189
|
return typeof error === "object" && error !== null && "name" in error && error.name === "AbortError";
|
|
1170
1190
|
}
|
|
1171
1191
|
function uploadErrorDetail(error) {
|
|
1172
|
-
const body =
|
|
1192
|
+
const body = isSixbApiError2(error) ? error.body : error;
|
|
1173
1193
|
if (typeof body === "string") {
|
|
1174
1194
|
return body.trim() || undefined;
|
|
1175
1195
|
}
|
|
@@ -1199,7 +1219,7 @@ function resolveUploadFileName(file, fileName) {
|
|
|
1199
1219
|
}
|
|
1200
1220
|
function toFileRef(value, stage) {
|
|
1201
1221
|
if (!value.digest.startsWith("sha256:")) {
|
|
1202
|
-
throw new
|
|
1222
|
+
throw new SixbFileUploadError2("[SixbClient] File upload response did not include a sha256 digest.", { stage });
|
|
1203
1223
|
}
|
|
1204
1224
|
return {
|
|
1205
1225
|
...value,
|
|
@@ -1207,6 +1227,6 @@ function toFileRef(value, stage) {
|
|
|
1207
1227
|
};
|
|
1208
1228
|
}
|
|
1209
1229
|
|
|
1210
|
-
export {
|
|
1230
|
+
export { createSixbAgentsWebSocketUrl2, createAgentRunSocket2, createAgentActivitySocket2, parseAgentRunStreamServerMessage2, isSixbEvent2, createEventSocket2, createSixbEventsWebSocketUrl2, parseEventStreamMessage2, matchesSubscription2, createWsSubscribeExecutor2, buildEventPredicate2, events2, telemetryUpdateFromEvent2, objectIdAliases2, telemetryUpdateKey2, ActionRunFailedError2, ActionRunTimeoutError2, requestActionAndWait2, waitForActionRun2, isTerminalActionRun2, objectFileContentUrl2, SixbFileUploadError2, uploadFile2 };
|
|
1211
1231
|
|
|
1212
|
-
//# debugId=
|
|
1232
|
+
//# debugId=B5B0F60FD368FE6A64756E2164756E21
|