@sanity/ailf-studio 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +0 -1
- package/dist/index.js +45 -41
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1701,11 +1701,6 @@ var reportSchema = defineType4({
|
|
|
1701
1701
|
name: "taskDefinitions",
|
|
1702
1702
|
title: "Task Definitions"
|
|
1703
1703
|
}),
|
|
1704
|
-
defineField4({
|
|
1705
|
-
...artifactRefSchema(),
|
|
1706
|
-
name: "evalResults",
|
|
1707
|
-
title: "Eval Results"
|
|
1708
|
-
}),
|
|
1709
1704
|
defineField4({
|
|
1710
1705
|
...artifactRefSchema(),
|
|
1711
1706
|
name: "traces",
|
|
@@ -7239,6 +7234,36 @@ async function signAndFetchNdjson(signingUrl) {
|
|
|
7239
7234
|
}
|
|
7240
7235
|
return rows;
|
|
7241
7236
|
}
|
|
7237
|
+
async function fetchBatchReadUrls(runId, type, keys) {
|
|
7238
|
+
const res = await fetch(
|
|
7239
|
+
`${ARTIFACT_API_BASE_URL}/runs/${encodeURIComponent(runId)}/artifacts/batch/read-urls`,
|
|
7240
|
+
{
|
|
7241
|
+
method: "POST",
|
|
7242
|
+
credentials: "omit",
|
|
7243
|
+
headers: { "Content-Type": "application/json" },
|
|
7244
|
+
body: JSON.stringify({ types: [type], keys: { [type]: keys } })
|
|
7245
|
+
}
|
|
7246
|
+
);
|
|
7247
|
+
if (!res.ok) {
|
|
7248
|
+
const body = await res.text().catch(() => "");
|
|
7249
|
+
throw new Error(
|
|
7250
|
+
`Batch signing failed: ${res.status} ${res.statusText}${body ? ` \u2014 ${body.slice(0, 200)}` : ""}`
|
|
7251
|
+
);
|
|
7252
|
+
}
|
|
7253
|
+
const envelope = await res.json();
|
|
7254
|
+
if (envelope.object === "error" || !envelope.urls) {
|
|
7255
|
+
throw new Error(
|
|
7256
|
+
envelope.error?.message ?? "Invalid batch signing response \u2014 missing urls"
|
|
7257
|
+
);
|
|
7258
|
+
}
|
|
7259
|
+
const entries = envelope.urls[type];
|
|
7260
|
+
if (!entries) return {};
|
|
7261
|
+
const out = {};
|
|
7262
|
+
for (const [key, entry] of Object.entries(entries)) {
|
|
7263
|
+
out[key] = entry.url;
|
|
7264
|
+
}
|
|
7265
|
+
return out;
|
|
7266
|
+
}
|
|
7242
7267
|
async function exchangeSigningUrl(signingUrl) {
|
|
7243
7268
|
const res = await fetch(signingUrl, {
|
|
7244
7269
|
credentials: "omit",
|
|
@@ -7372,49 +7397,28 @@ function useArtifactPrefetch(type) {
|
|
|
7372
7397
|
(k) => getCached({ runId, type, key: k }) === null
|
|
7373
7398
|
);
|
|
7374
7399
|
if (pending.length === 0) return;
|
|
7375
|
-
const
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
});
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
for (const k of pending) {
|
|
7389
|
-
await prefetch(k);
|
|
7390
|
-
}
|
|
7400
|
+
const signedByKey = await fetchBatchReadUrls(runId, type, pending);
|
|
7401
|
+
await Promise.all(
|
|
7402
|
+
Object.entries(signedByKey).map(async ([k, signedUrl]) => {
|
|
7403
|
+
await recordInFlight({ runId, type, key: k }, async () => {
|
|
7404
|
+
const body = await fetchSignedBody(
|
|
7405
|
+
signedUrl,
|
|
7406
|
+
NDJSON_TYPES2.has(type)
|
|
7407
|
+
);
|
|
7408
|
+
setCached({ runId, type, key: k }, body);
|
|
7409
|
+
return body;
|
|
7410
|
+
});
|
|
7411
|
+
})
|
|
7412
|
+
);
|
|
7391
7413
|
},
|
|
7392
|
-
[runId, ref, type
|
|
7414
|
+
[runId, ref, type]
|
|
7393
7415
|
);
|
|
7394
7416
|
return useMemo7(
|
|
7395
7417
|
() => ({ prefetch, onHover, prefetchWindow, warmAll }),
|
|
7396
7418
|
[prefetch, onHover, prefetchWindow, warmAll]
|
|
7397
7419
|
);
|
|
7398
7420
|
}
|
|
7399
|
-
async function
|
|
7400
|
-
try {
|
|
7401
|
-
const res = await fetch(
|
|
7402
|
-
`${ARTIFACT_API_BASE_URL}/runs/${encodeURIComponent(runId)}/artifacts/batch/read-urls`,
|
|
7403
|
-
{
|
|
7404
|
-
method: "POST",
|
|
7405
|
-
credentials: "omit",
|
|
7406
|
-
headers: { "Content-Type": "application/json" },
|
|
7407
|
-
body: JSON.stringify({ types: [type], keys: { [type]: keys } })
|
|
7408
|
-
}
|
|
7409
|
-
);
|
|
7410
|
-
if (!res.ok) return null;
|
|
7411
|
-
const body = await res.json();
|
|
7412
|
-
return body.urls?.[type] ?? null;
|
|
7413
|
-
} catch {
|
|
7414
|
-
return null;
|
|
7415
|
-
}
|
|
7416
|
-
}
|
|
7417
|
-
async function fetchSigned(signedUrl, ndjson) {
|
|
7421
|
+
async function fetchSignedBody(signedUrl, ndjson) {
|
|
7418
7422
|
const res = await fetch(signedUrl, { credentials: "omit" });
|
|
7419
7423
|
if (!res.ok) {
|
|
7420
7424
|
throw new Error(
|