@workflow/web 5.0.0-beta.9 → 5.0.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/README.md +1 -0
- package/build/client/assets/app-BIKwaF7E.css +1 -0
- package/build/client/assets/arrow-up-right-jHPcOZmb.js +15 -0
- package/build/client/assets/{entry.client-DtOpLtMQ.js → entry.client-DmlDFlyx.js} +25 -185
- package/build/client/assets/{highlighted-body-B3W2YXNL-ijzNrESJ.js → highlighted-body-B3W2YXNL-CBBI0JQ-.js} +2 -2
- package/build/client/assets/{home-MRChHR_P.js → home-BcIEUw9E.js} +1791 -291
- package/build/client/assets/index-HqNj_XIX.js +200 -0
- package/build/client/assets/{index-BsV8i_Jn.js → index-thGVuYbY.js} +19 -19
- package/build/client/assets/loader-circle-HeezuKOU.js +12 -0
- package/build/client/assets/manifest-a541ae9e.js +1 -0
- package/build/client/assets/{mermaid-3ZIDBTTL-3cOa-aZ5.js → mermaid-3ZIDBTTL-ClcCzUqi.js} +17455 -12920
- package/build/client/assets/mermaid-3ZIDBTTL-D8CjRQta.css +1 -0
- package/build/client/assets/{root-3uuTxUQN.js → root-DLS5V7HU.js} +17 -42
- package/build/client/assets/root-grl25rxS.css +1 -0
- package/build/client/assets/run-detail-CWoGxu_0.css +1 -0
- package/build/client/assets/{run-detail-8qGjUNCj.js → run-detail-DWoMKBqC.js} +3035 -2447
- package/build/client/assets/{workflow-graph-viewer-DaYMiBT9.js → workflow-graph-viewer-syfKq6DB.js} +5143 -5261
- package/build/client/assets/zstd-B5R2yJjB.wasm +0 -0
- package/build/client/assets/zstd-browser-decoder-D2p6f8lN.js +27 -0
- package/build/server/assets/{server-build-Ctg6FoI8.js → app-CLF3fhv7.js} +102224 -73168
- package/build/server/assets/{highlighted-body-B3W2YXNL-B4fAdNsB.js → highlighted-body-B3W2YXNL-D21NaJQ0.js} +22 -9
- package/build/server/assets/index-BfLBLRRi.js +204 -0
- package/build/server/assets/index-CETb4fkq.js +1164 -0
- package/build/server/assets/index-DnTW8Yiv.js +1262 -0
- package/build/server/assets/index-y9xp70jn.js +184 -0
- package/build/server/assets/{mermaid-3ZIDBTTL-C6M7jb0V.js → mermaid-3ZIDBTTL-DlUUmZjL.js} +22 -9
- package/build/server/assets/{token-BNjLoJXz.js → token-DXiZgST4.js} +5 -2
- package/build/server/assets/{token-util-DwTdh-aG.js → token-util-BvEnPXwK.js} +5 -2
- package/build/server/assets/wrapper-BsMfBV09.js +67 -0
- package/build/server/assets/zstd-browser-decoder-d2YJZBik.js +77 -0
- package/build/server/index.js +55 -3
- package/handler.d.ts +22 -0
- package/handler.js +103 -0
- package/package.json +28 -15
- package/registry.d.ts +29 -0
- package/registry.js +89 -0
- package/server.d.ts +5 -1
- package/server.js +32 -39
- package/static.js +86 -0
- package/build/client/assets/encryption-C69WMRfh.js +0 -34
- package/build/client/assets/index-Byi8AWfe.js +0 -280
- package/build/client/assets/manifest-b100514d.js +0 -1
- package/build/client/assets/mermaid-3ZIDBTTL-DKxHcEOp.css +0 -1
- package/build/client/assets/root-BYtlAgHl.css +0 -1
- package/build/client/assets/server-build-ByHD2s6b.css +0 -1
- package/build/client/assets/worker-CqHKTA7D.js +0 -115
- package/build/server/assets/app-BEgkHdDF.js +0 -9213
- package/build/server/assets/index-DltGJ3CV.js +0 -89
- package/build/server/assets/index-meg9qk8y.js +0 -1282
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import { r as reactExports,
|
|
2
|
-
import { R as ResolveHookModal, S as Send,
|
|
3
|
-
import {
|
|
4
|
-
import "./
|
|
5
|
-
var PORTAL_NAME$2 = "Portal";
|
|
6
|
-
var Portal$2 = reactExports.forwardRef((props, forwardedRef) => {
|
|
7
|
-
var _a;
|
|
8
|
-
const { container: containerProp, ...portalProps } = props;
|
|
9
|
-
const [mounted, setMounted] = reactExports.useState(false);
|
|
10
|
-
useLayoutEffect2(() => setMounted(true), []);
|
|
11
|
-
const container = containerProp || mounted && ((_a = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : _a.body);
|
|
12
|
-
return container ? ReactDOM.createPortal(/* @__PURE__ */ jsxRuntimeExports.jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
|
|
13
|
-
});
|
|
14
|
-
Portal$2.displayName = PORTAL_NAME$2;
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports, z as Link, R as ReactExports, f as reactDomExports, B as useSearchParams, A as useNavigate, C as useLocation, w as withComponentProps } from "./index-thGVuYbY.js";
|
|
2
|
+
import { R as ResolveHookModal, S as Send, r as requireShim, u as unwrapOrThrow, W as WorkflowWebAPIError, f as fetchHookToken, a as Skeleton, b as RelativeTime, A as Alert, C as CircleAlert, c as AlertTitle, g as getErrorTitle, d as AlertDescription, e as getErrorMessage, h as CopyableText, D as DropdownMenu, i as DropdownMenuTrigger, E as Ellipsis, j as DropdownMenuContent, k as DropdownMenuItem, l as resumeHook, m as createCollection, n as hideOthers, o as ReactRemoveScroll, p as useDirection, q as ChevronUp, X, s as useControllableState$1, P as Primitive$1, t as composeEventHandlers$1, v as Presence, w as useSize, x as createContextScope$1, y as bulkCancelRuns, z as reenqueueRun, B as parseWorkflowName, F as StatusBadge, Z as Zap, G as CircleX, H as RunActionsDropdownItems, I as unwrapServerActionResult, J as WorkflowGraphViewer, T as Tabs, K as TabsList, L as TabsTrigger, M as TabsContent, N as ErrorBoundary } from "./workflow-graph-viewer-syfKq6DB.js";
|
|
3
|
+
import { c as createLucideIcon, h as useToast, e as cn, i as fetchRuns, j as fetchHooks, k as getPaginationDisplay, T as Tooltip, a as TooltipTrigger, C as Check, l as Copy, b as TooltipContent, D as DEFAULT_PAGE_SIZE, B as Button, m as ChevronRight, n as fetchEvents, o as useCallbackRef, p as useComposedRefs, P as Primitive, A as Anchor, q as composeEventHandlers, s as useLayoutEffect2, v as Portal$2, w as useId, x as createPopperScope, y as DismissableLayer, z as createContextScope, E as createSlot, F as Content$1, G as useControllableState, H as Root2$1, V as VISUALLY_HIDDEN_STYLES, I as Arrow, J as ChevronDown, L as useComposedRefs$1, u as useServerConfig, M as BULK_CANCEL_MAX_RUN_IDS, t as toast, N as fetchRun, O as cva, U as Presence$1, W as createContext2, X as fetchWorkflowsManifest } from "./mermaid-3ZIDBTTL-ClcCzUqi.js";
|
|
4
|
+
import { L as LoaderCircle } from "./loader-circle-HeezuKOU.js";
|
|
15
5
|
/**
|
|
16
6
|
* @license lucide-react v0.575.0 - ISC
|
|
17
7
|
*
|
|
@@ -93,6 +83,9 @@ const __iconNode = [
|
|
|
93
83
|
["rect", { width: "8", height: "8", x: "13", y: "13", rx: "2", key: "1cgmvn" }]
|
|
94
84
|
];
|
|
95
85
|
const Workflow = createLucideIcon("workflow", __iconNode);
|
|
86
|
+
function pluralize(singular, plural, count2) {
|
|
87
|
+
return count2 === 1 ? singular : plural;
|
|
88
|
+
}
|
|
96
89
|
function useHookActions({ onResolve, callbacks }) {
|
|
97
90
|
const toast2 = useToast();
|
|
98
91
|
const [isResolving, setIsResolving] = reactExports.useState(false);
|
|
@@ -295,101 +288,1309 @@ const TableCaption = reactExports.forwardRef(({ className, ...props }, ref) => /
|
|
|
295
288
|
}
|
|
296
289
|
));
|
|
297
290
|
TableCaption.displayName = "TableCaption";
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
case "hooks":
|
|
324
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
325
|
-
"div",
|
|
326
|
-
{
|
|
327
|
-
className: "grid grid-cols-[1.2fr_1.2fr_0.8fr_1fr_0.5fr_40px] items-center gap-4 py-3 px-4",
|
|
328
|
-
children: [
|
|
329
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-4/5" }),
|
|
330
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-4/5" }),
|
|
331
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-3/4" }),
|
|
332
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-3/4" }),
|
|
333
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-8" }),
|
|
334
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-6 w-6 rounded" })
|
|
335
|
-
]
|
|
336
|
-
},
|
|
337
|
-
`skeleton-row-${i}`
|
|
338
|
-
);
|
|
339
|
-
case "workflows":
|
|
340
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
341
|
-
"div",
|
|
342
|
-
{
|
|
343
|
-
className: "grid grid-cols-[1fr_1.5fr_0.5fr] items-center gap-4 py-3 px-4",
|
|
344
|
-
children: [
|
|
345
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-3/4" }),
|
|
346
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-4/5" }),
|
|
347
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-5 w-16 rounded-full mx-auto" })
|
|
348
|
-
]
|
|
349
|
-
},
|
|
350
|
-
`skeleton-row-${i}`
|
|
351
|
-
);
|
|
352
|
-
default:
|
|
353
|
-
return null;
|
|
291
|
+
var shimExports = requireShim();
|
|
292
|
+
const FOCUS_EVENT = 0;
|
|
293
|
+
const RECONNECT_EVENT = 1;
|
|
294
|
+
const MUTATE_EVENT = 2;
|
|
295
|
+
const ERROR_REVALIDATE_EVENT = 3;
|
|
296
|
+
var has = Object.prototype.hasOwnProperty;
|
|
297
|
+
function dequal(foo, bar) {
|
|
298
|
+
var ctor, len;
|
|
299
|
+
if (foo === bar) return true;
|
|
300
|
+
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
301
|
+
if (ctor === Date) return foo.getTime() === bar.getTime();
|
|
302
|
+
if (ctor === RegExp) return foo.toString() === bar.toString();
|
|
303
|
+
if (ctor === Array) {
|
|
304
|
+
if ((len = foo.length) === bar.length) {
|
|
305
|
+
while (len-- && dequal(foo[len], bar[len])) ;
|
|
306
|
+
}
|
|
307
|
+
return len === -1;
|
|
308
|
+
}
|
|
309
|
+
if (!ctor || typeof foo === "object") {
|
|
310
|
+
len = 0;
|
|
311
|
+
for (ctor in foo) {
|
|
312
|
+
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
|
|
313
|
+
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
|
|
314
|
+
}
|
|
315
|
+
return Object.keys(bar).length === len;
|
|
354
316
|
}
|
|
317
|
+
}
|
|
318
|
+
return foo !== foo && bar !== bar;
|
|
319
|
+
}
|
|
320
|
+
const SWRGlobalState = /* @__PURE__ */ new WeakMap();
|
|
321
|
+
const noop$1 = () => {
|
|
322
|
+
};
|
|
323
|
+
const UNDEFINED$1 = (
|
|
324
|
+
/*#__NOINLINE__*/
|
|
325
|
+
noop$1()
|
|
326
|
+
);
|
|
327
|
+
const OBJECT$1 = Object;
|
|
328
|
+
const isUndefined$1 = (v) => v === UNDEFINED$1;
|
|
329
|
+
const isFunction$1 = (v) => typeof v == "function";
|
|
330
|
+
const mergeObjects = (a, b) => ({
|
|
331
|
+
...a,
|
|
332
|
+
...b
|
|
333
|
+
});
|
|
334
|
+
const isPromiseLike = (x) => isFunction$1(x.then);
|
|
335
|
+
const EMPTY_CACHE = {};
|
|
336
|
+
const INITIAL_CACHE = {};
|
|
337
|
+
const STR_UNDEFINED = "undefined";
|
|
338
|
+
const isWindowDefined = typeof window != STR_UNDEFINED;
|
|
339
|
+
const isDocumentDefined = typeof document != STR_UNDEFINED;
|
|
340
|
+
const isLegacyDeno = isWindowDefined && "Deno" in window;
|
|
341
|
+
const hasRequestAnimationFrame = () => isWindowDefined && typeof window["requestAnimationFrame"] != STR_UNDEFINED;
|
|
342
|
+
const createCacheHelper = (cache2, key) => {
|
|
343
|
+
const state = SWRGlobalState.get(cache2);
|
|
344
|
+
return [
|
|
345
|
+
// Getter
|
|
346
|
+
() => !isUndefined$1(key) && cache2.get(key) || EMPTY_CACHE,
|
|
347
|
+
// Setter
|
|
348
|
+
(info) => {
|
|
349
|
+
if (!isUndefined$1(key)) {
|
|
350
|
+
const prev = cache2.get(key);
|
|
351
|
+
if (!(key in INITIAL_CACHE)) {
|
|
352
|
+
INITIAL_CACHE[key] = prev;
|
|
353
|
+
}
|
|
354
|
+
state[5](key, mergeObjects(prev, info), prev || EMPTY_CACHE);
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
// Subscriber
|
|
358
|
+
state[6],
|
|
359
|
+
// Get server cache snapshot
|
|
360
|
+
() => {
|
|
361
|
+
if (!isUndefined$1(key)) {
|
|
362
|
+
if (key in INITIAL_CACHE) return INITIAL_CACHE[key];
|
|
363
|
+
}
|
|
364
|
+
return !isUndefined$1(key) && cache2.get(key) || EMPTY_CACHE;
|
|
365
|
+
}
|
|
366
|
+
];
|
|
367
|
+
};
|
|
368
|
+
let online = true;
|
|
369
|
+
const isOnline = () => online;
|
|
370
|
+
const [onWindowEvent, offWindowEvent] = isWindowDefined && window.addEventListener ? [
|
|
371
|
+
window.addEventListener.bind(window),
|
|
372
|
+
window.removeEventListener.bind(window)
|
|
373
|
+
] : [
|
|
374
|
+
noop$1,
|
|
375
|
+
noop$1
|
|
376
|
+
];
|
|
377
|
+
const isVisible = () => {
|
|
378
|
+
const visibilityState = isDocumentDefined && document.visibilityState;
|
|
379
|
+
return isUndefined$1(visibilityState) || visibilityState !== "hidden";
|
|
380
|
+
};
|
|
381
|
+
const initFocus = (callback) => {
|
|
382
|
+
if (isDocumentDefined) {
|
|
383
|
+
document.addEventListener("visibilitychange", callback);
|
|
384
|
+
}
|
|
385
|
+
onWindowEvent("focus", callback);
|
|
386
|
+
return () => {
|
|
387
|
+
if (isDocumentDefined) {
|
|
388
|
+
document.removeEventListener("visibilitychange", callback);
|
|
389
|
+
}
|
|
390
|
+
offWindowEvent("focus", callback);
|
|
355
391
|
};
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
392
|
+
};
|
|
393
|
+
const initReconnect = (callback) => {
|
|
394
|
+
const onOnline = () => {
|
|
395
|
+
online = true;
|
|
396
|
+
callback();
|
|
397
|
+
};
|
|
398
|
+
const onOffline = () => {
|
|
399
|
+
online = false;
|
|
400
|
+
};
|
|
401
|
+
onWindowEvent("online", onOnline);
|
|
402
|
+
onWindowEvent("offline", onOffline);
|
|
403
|
+
return () => {
|
|
404
|
+
offWindowEvent("online", onOnline);
|
|
405
|
+
offWindowEvent("offline", onOffline);
|
|
406
|
+
};
|
|
407
|
+
};
|
|
408
|
+
const preset = {
|
|
409
|
+
isOnline,
|
|
410
|
+
isVisible
|
|
411
|
+
};
|
|
412
|
+
const defaultConfigOptions = {
|
|
413
|
+
initFocus,
|
|
414
|
+
initReconnect
|
|
415
|
+
};
|
|
416
|
+
const IS_REACT_LEGACY = !ReactExports.useId;
|
|
417
|
+
const IS_SERVER = !isWindowDefined || isLegacyDeno;
|
|
418
|
+
const rAF = (f) => hasRequestAnimationFrame() ? window["requestAnimationFrame"](f) : setTimeout(f, 1);
|
|
419
|
+
const useIsomorphicLayoutEffect = IS_SERVER ? reactExports.useEffect : reactExports.useLayoutEffect;
|
|
420
|
+
const navigatorConnection = typeof navigator !== "undefined" && navigator.connection;
|
|
421
|
+
const slowConnection = !IS_SERVER && navigatorConnection && ([
|
|
422
|
+
"slow-2g",
|
|
423
|
+
"2g"
|
|
424
|
+
].includes(navigatorConnection.effectiveType) || navigatorConnection.saveData);
|
|
425
|
+
const table$1 = /* @__PURE__ */ new WeakMap();
|
|
426
|
+
const getTypeName$1 = (value) => OBJECT$1.prototype.toString.call(value);
|
|
427
|
+
const isObjectTypeName$1 = (typeName, type) => typeName === `[object ${type}]`;
|
|
428
|
+
let counter$1 = 0;
|
|
429
|
+
const stableHash$1 = (arg) => {
|
|
430
|
+
const type = typeof arg;
|
|
431
|
+
const typeName = getTypeName$1(arg);
|
|
432
|
+
const isDate = isObjectTypeName$1(typeName, "Date");
|
|
433
|
+
const isRegex = isObjectTypeName$1(typeName, "RegExp");
|
|
434
|
+
const isPlainObject = isObjectTypeName$1(typeName, "Object");
|
|
435
|
+
let result;
|
|
436
|
+
let index;
|
|
437
|
+
if (OBJECT$1(arg) === arg && !isDate && !isRegex) {
|
|
438
|
+
result = table$1.get(arg);
|
|
439
|
+
if (result) return result;
|
|
440
|
+
result = ++counter$1 + "~";
|
|
441
|
+
table$1.set(arg, result);
|
|
442
|
+
if (Array.isArray(arg)) {
|
|
443
|
+
result = "@";
|
|
444
|
+
for (index = 0; index < arg.length; index++) {
|
|
445
|
+
result += stableHash$1(arg[index]) + ",";
|
|
446
|
+
}
|
|
447
|
+
table$1.set(arg, result);
|
|
384
448
|
}
|
|
449
|
+
if (isPlainObject) {
|
|
450
|
+
result = "#";
|
|
451
|
+
const keys = OBJECT$1.keys(arg).sort();
|
|
452
|
+
while (!isUndefined$1(index = keys.pop())) {
|
|
453
|
+
if (!isUndefined$1(arg[index])) {
|
|
454
|
+
result += index + ":" + stableHash$1(arg[index]) + ",";
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
table$1.set(arg, result);
|
|
458
|
+
}
|
|
459
|
+
} else {
|
|
460
|
+
result = isDate ? arg.toJSON() : type == "symbol" ? arg.toString() : type == "string" ? JSON.stringify(arg) : "" + arg;
|
|
461
|
+
}
|
|
462
|
+
return result;
|
|
463
|
+
};
|
|
464
|
+
const serialize$1 = (key) => {
|
|
465
|
+
if (isFunction$1(key)) {
|
|
466
|
+
try {
|
|
467
|
+
key = key();
|
|
468
|
+
} catch (err) {
|
|
469
|
+
key = "";
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const args = key;
|
|
473
|
+
key = typeof key == "string" ? key : (Array.isArray(key) ? key.length : key) ? stableHash$1(key) : "";
|
|
474
|
+
return [
|
|
475
|
+
key,
|
|
476
|
+
args
|
|
477
|
+
];
|
|
478
|
+
};
|
|
479
|
+
let __timestamp = 0;
|
|
480
|
+
const getTimestamp = () => ++__timestamp;
|
|
481
|
+
async function internalMutate(...args) {
|
|
482
|
+
const [cache2, _key, _data, _opts] = args;
|
|
483
|
+
const options = mergeObjects({
|
|
484
|
+
populateCache: true,
|
|
485
|
+
throwOnError: true
|
|
486
|
+
}, typeof _opts === "boolean" ? {
|
|
487
|
+
revalidate: _opts
|
|
488
|
+
} : _opts || {});
|
|
489
|
+
let populateCache = options.populateCache;
|
|
490
|
+
const rollbackOnErrorOption = options.rollbackOnError;
|
|
491
|
+
let optimisticData = options.optimisticData;
|
|
492
|
+
const rollbackOnError = (error) => {
|
|
493
|
+
return typeof rollbackOnErrorOption === "function" ? rollbackOnErrorOption(error) : rollbackOnErrorOption !== false;
|
|
385
494
|
};
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
495
|
+
const throwOnError = options.throwOnError;
|
|
496
|
+
if (isFunction$1(_key)) {
|
|
497
|
+
const keyFilter = _key;
|
|
498
|
+
const matchedKeys = [];
|
|
499
|
+
const it = cache2.keys();
|
|
500
|
+
for (const key of it) {
|
|
501
|
+
if (
|
|
502
|
+
// Skip the special useSWRInfinite and useSWRSubscription keys.
|
|
503
|
+
!/^\$(inf|sub)\$/.test(key) && keyFilter(cache2.get(key)._k)
|
|
504
|
+
) {
|
|
505
|
+
matchedKeys.push(key);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return Promise.all(matchedKeys.map(mutateByKey));
|
|
509
|
+
}
|
|
510
|
+
return mutateByKey(_key);
|
|
511
|
+
async function mutateByKey(_k) {
|
|
512
|
+
const [key] = serialize$1(_k);
|
|
513
|
+
if (!key) return;
|
|
514
|
+
const [get, set] = createCacheHelper(cache2, key);
|
|
515
|
+
const [EVENT_REVALIDATORS, MUTATION, FETCH, PRELOAD] = SWRGlobalState.get(cache2);
|
|
516
|
+
const startRevalidate = () => {
|
|
517
|
+
const revalidators = EVENT_REVALIDATORS[key];
|
|
518
|
+
const revalidate = isFunction$1(options.revalidate) ? options.revalidate(get().data, _k) : options.revalidate !== false;
|
|
519
|
+
if (revalidate) {
|
|
520
|
+
delete FETCH[key];
|
|
521
|
+
delete PRELOAD[key];
|
|
522
|
+
if (revalidators && revalidators[0]) {
|
|
523
|
+
return revalidators[0](MUTATE_EVENT).then(() => get().data);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return get().data;
|
|
527
|
+
};
|
|
528
|
+
if (args.length < 3) {
|
|
529
|
+
return startRevalidate();
|
|
530
|
+
}
|
|
531
|
+
let data = _data;
|
|
532
|
+
let error;
|
|
533
|
+
let isError = false;
|
|
534
|
+
const beforeMutationTs = getTimestamp();
|
|
535
|
+
MUTATION[key] = [
|
|
536
|
+
beforeMutationTs,
|
|
537
|
+
0
|
|
538
|
+
];
|
|
539
|
+
const hasOptimisticData = !isUndefined$1(optimisticData);
|
|
540
|
+
const state = get();
|
|
541
|
+
const displayedData = state.data;
|
|
542
|
+
const currentData = state._c;
|
|
543
|
+
const committedData = isUndefined$1(currentData) ? displayedData : currentData;
|
|
544
|
+
if (hasOptimisticData) {
|
|
545
|
+
optimisticData = isFunction$1(optimisticData) ? optimisticData(committedData, displayedData) : optimisticData;
|
|
546
|
+
set({
|
|
547
|
+
data: optimisticData,
|
|
548
|
+
_c: committedData
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
if (isFunction$1(data)) {
|
|
552
|
+
try {
|
|
553
|
+
data = data(committedData);
|
|
554
|
+
} catch (err) {
|
|
555
|
+
error = err;
|
|
556
|
+
isError = true;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
if (data && isPromiseLike(data)) {
|
|
560
|
+
data = await data.catch((err) => {
|
|
561
|
+
error = err;
|
|
562
|
+
isError = true;
|
|
563
|
+
});
|
|
564
|
+
if (beforeMutationTs !== MUTATION[key][0]) {
|
|
565
|
+
if (isError) throw error;
|
|
566
|
+
return data;
|
|
567
|
+
} else if (isError && hasOptimisticData && rollbackOnError(error)) {
|
|
568
|
+
populateCache = true;
|
|
569
|
+
set({
|
|
570
|
+
data: committedData,
|
|
571
|
+
_c: UNDEFINED$1
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
if (populateCache) {
|
|
576
|
+
if (!isError) {
|
|
577
|
+
if (isFunction$1(populateCache)) {
|
|
578
|
+
const populateCachedData = populateCache(data, committedData);
|
|
579
|
+
set({
|
|
580
|
+
data: populateCachedData,
|
|
581
|
+
error: UNDEFINED$1,
|
|
582
|
+
_c: UNDEFINED$1
|
|
583
|
+
});
|
|
584
|
+
} else {
|
|
585
|
+
set({
|
|
586
|
+
data,
|
|
587
|
+
error: UNDEFINED$1,
|
|
588
|
+
_c: UNDEFINED$1
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
MUTATION[key][1] = getTimestamp();
|
|
594
|
+
Promise.resolve(startRevalidate()).then(() => {
|
|
595
|
+
set({
|
|
596
|
+
_c: UNDEFINED$1
|
|
597
|
+
});
|
|
598
|
+
});
|
|
599
|
+
if (isError) {
|
|
600
|
+
if (throwOnError) throw error;
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
return data;
|
|
604
|
+
}
|
|
390
605
|
}
|
|
391
|
-
|
|
392
|
-
|
|
606
|
+
const revalidateAllKeys = (revalidators, type) => {
|
|
607
|
+
for (const key in revalidators) {
|
|
608
|
+
if (revalidators[key][0]) revalidators[key][0](type);
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
const initCache = (provider, options) => {
|
|
612
|
+
if (!SWRGlobalState.has(provider)) {
|
|
613
|
+
const opts = mergeObjects(defaultConfigOptions, options);
|
|
614
|
+
const EVENT_REVALIDATORS = /* @__PURE__ */ Object.create(null);
|
|
615
|
+
const mutate2 = internalMutate.bind(UNDEFINED$1, provider);
|
|
616
|
+
let unmount = noop$1;
|
|
617
|
+
const subscriptions = /* @__PURE__ */ Object.create(null);
|
|
618
|
+
const subscribe = (key, callback) => {
|
|
619
|
+
const subs = subscriptions[key] || [];
|
|
620
|
+
subscriptions[key] = subs;
|
|
621
|
+
subs.push(callback);
|
|
622
|
+
return () => subs.splice(subs.indexOf(callback), 1);
|
|
623
|
+
};
|
|
624
|
+
const setter = (key, value, prev) => {
|
|
625
|
+
provider.set(key, value);
|
|
626
|
+
const subs = subscriptions[key];
|
|
627
|
+
if (subs) {
|
|
628
|
+
for (const fn of subs) {
|
|
629
|
+
fn(value, prev);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
const initProvider = () => {
|
|
634
|
+
if (!SWRGlobalState.has(provider)) {
|
|
635
|
+
SWRGlobalState.set(provider, [
|
|
636
|
+
EVENT_REVALIDATORS,
|
|
637
|
+
/* @__PURE__ */ Object.create(null),
|
|
638
|
+
/* @__PURE__ */ Object.create(null),
|
|
639
|
+
/* @__PURE__ */ Object.create(null),
|
|
640
|
+
mutate2,
|
|
641
|
+
setter,
|
|
642
|
+
subscribe
|
|
643
|
+
]);
|
|
644
|
+
if (!IS_SERVER) {
|
|
645
|
+
const releaseFocus = opts.initFocus(setTimeout.bind(UNDEFINED$1, revalidateAllKeys.bind(UNDEFINED$1, EVENT_REVALIDATORS, FOCUS_EVENT)));
|
|
646
|
+
const releaseReconnect = opts.initReconnect(setTimeout.bind(UNDEFINED$1, revalidateAllKeys.bind(UNDEFINED$1, EVENT_REVALIDATORS, RECONNECT_EVENT)));
|
|
647
|
+
unmount = () => {
|
|
648
|
+
releaseFocus && releaseFocus();
|
|
649
|
+
releaseReconnect && releaseReconnect();
|
|
650
|
+
SWRGlobalState.delete(provider);
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
initProvider();
|
|
656
|
+
return [
|
|
657
|
+
provider,
|
|
658
|
+
mutate2,
|
|
659
|
+
initProvider,
|
|
660
|
+
unmount
|
|
661
|
+
];
|
|
662
|
+
}
|
|
663
|
+
return [
|
|
664
|
+
provider,
|
|
665
|
+
SWRGlobalState.get(provider)[4]
|
|
666
|
+
];
|
|
667
|
+
};
|
|
668
|
+
const onErrorRetry = (_, __, config, revalidate, opts) => {
|
|
669
|
+
const maxRetryCount = config.errorRetryCount;
|
|
670
|
+
const currentRetryCount = opts.retryCount;
|
|
671
|
+
const timeout = ~~((Math.random() + 0.5) * (1 << (currentRetryCount < 8 ? currentRetryCount : 8))) * config.errorRetryInterval;
|
|
672
|
+
if (!isUndefined$1(maxRetryCount) && currentRetryCount > maxRetryCount) {
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
setTimeout(revalidate, timeout, opts);
|
|
676
|
+
};
|
|
677
|
+
const compare = dequal;
|
|
678
|
+
const [cache, mutate] = initCache(/* @__PURE__ */ new Map());
|
|
679
|
+
const defaultConfig = mergeObjects(
|
|
680
|
+
{
|
|
681
|
+
// events
|
|
682
|
+
onLoadingSlow: noop$1,
|
|
683
|
+
onSuccess: noop$1,
|
|
684
|
+
onError: noop$1,
|
|
685
|
+
onErrorRetry,
|
|
686
|
+
onDiscarded: noop$1,
|
|
687
|
+
// switches
|
|
688
|
+
revalidateOnFocus: true,
|
|
689
|
+
revalidateOnReconnect: true,
|
|
690
|
+
revalidateIfStale: true,
|
|
691
|
+
shouldRetryOnError: true,
|
|
692
|
+
// timeouts
|
|
693
|
+
errorRetryInterval: slowConnection ? 1e4 : 5e3,
|
|
694
|
+
focusThrottleInterval: 5 * 1e3,
|
|
695
|
+
dedupingInterval: 2 * 1e3,
|
|
696
|
+
loadingTimeout: slowConnection ? 5e3 : 3e3,
|
|
697
|
+
// providers
|
|
698
|
+
compare,
|
|
699
|
+
isPaused: () => false,
|
|
700
|
+
cache,
|
|
701
|
+
mutate,
|
|
702
|
+
fallback: {}
|
|
703
|
+
},
|
|
704
|
+
// use web preset by default
|
|
705
|
+
preset
|
|
706
|
+
);
|
|
707
|
+
const mergeConfigs = (a, b) => {
|
|
708
|
+
const v = mergeObjects(a, b);
|
|
709
|
+
if (b) {
|
|
710
|
+
const { use: u1, fallback: f1 } = a;
|
|
711
|
+
const { use: u2, fallback: f2 } = b;
|
|
712
|
+
if (u1 && u2) {
|
|
713
|
+
v.use = u1.concat(u2);
|
|
714
|
+
}
|
|
715
|
+
if (f1 && f2) {
|
|
716
|
+
v.fallback = mergeObjects(f1, f2);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return v;
|
|
720
|
+
};
|
|
721
|
+
const SWRConfigContext = reactExports.createContext({});
|
|
722
|
+
const INFINITE_PREFIX = "$inf$";
|
|
723
|
+
const enableDevtools = isWindowDefined && window.__SWR_DEVTOOLS_USE__;
|
|
724
|
+
const use$1 = enableDevtools ? window.__SWR_DEVTOOLS_USE__ : [];
|
|
725
|
+
const setupDevTools = () => {
|
|
726
|
+
if (enableDevtools) {
|
|
727
|
+
window.__SWR_DEVTOOLS_REACT__ = ReactExports;
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
const normalize = (args) => {
|
|
731
|
+
return isFunction$1(args[1]) ? [
|
|
732
|
+
args[0],
|
|
733
|
+
args[1],
|
|
734
|
+
args[2] || {}
|
|
735
|
+
] : [
|
|
736
|
+
args[0],
|
|
737
|
+
null,
|
|
738
|
+
(args[1] === null ? args[2] : args[1]) || {}
|
|
739
|
+
];
|
|
740
|
+
};
|
|
741
|
+
const useSWRConfig = () => {
|
|
742
|
+
const parentConfig = reactExports.useContext(SWRConfigContext);
|
|
743
|
+
const mergedConfig = reactExports.useMemo(() => mergeObjects(defaultConfig, parentConfig), [
|
|
744
|
+
parentConfig
|
|
745
|
+
]);
|
|
746
|
+
return mergedConfig;
|
|
747
|
+
};
|
|
748
|
+
const middleware = (useSWRNext) => (key_, fetcher_, config) => {
|
|
749
|
+
const fetcher = fetcher_ && ((...args) => {
|
|
750
|
+
const [key] = serialize$1(key_);
|
|
751
|
+
const [, , , PRELOAD] = SWRGlobalState.get(cache);
|
|
752
|
+
if (key.startsWith(INFINITE_PREFIX)) {
|
|
753
|
+
return fetcher_(...args);
|
|
754
|
+
}
|
|
755
|
+
const req = PRELOAD[key];
|
|
756
|
+
if (isUndefined$1(req)) return fetcher_(...args);
|
|
757
|
+
delete PRELOAD[key];
|
|
758
|
+
return req;
|
|
759
|
+
});
|
|
760
|
+
return useSWRNext(key_, fetcher, config);
|
|
761
|
+
};
|
|
762
|
+
const BUILT_IN_MIDDLEWARE = use$1.concat(middleware);
|
|
763
|
+
const withArgs = (hook) => {
|
|
764
|
+
return function useSWRArgs(...args) {
|
|
765
|
+
const fallbackConfig = useSWRConfig();
|
|
766
|
+
const [key, fn, _config] = normalize(args);
|
|
767
|
+
const config = mergeConfigs(fallbackConfig, _config);
|
|
768
|
+
let next = hook;
|
|
769
|
+
const { use: use2 } = config;
|
|
770
|
+
const middleware2 = (use2 || []).concat(BUILT_IN_MIDDLEWARE);
|
|
771
|
+
for (let i = middleware2.length; i--; ) {
|
|
772
|
+
next = middleware2[i](next);
|
|
773
|
+
}
|
|
774
|
+
return next(key, fn || config.fetcher || null, config);
|
|
775
|
+
};
|
|
776
|
+
};
|
|
777
|
+
const subscribeCallback = (key, callbacks, callback) => {
|
|
778
|
+
const keyedRevalidators = callbacks[key] || (callbacks[key] = []);
|
|
779
|
+
keyedRevalidators.push(callback);
|
|
780
|
+
return () => {
|
|
781
|
+
const index = keyedRevalidators.indexOf(callback);
|
|
782
|
+
if (index >= 0) {
|
|
783
|
+
keyedRevalidators[index] = keyedRevalidators[keyedRevalidators.length - 1];
|
|
784
|
+
keyedRevalidators.pop();
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
};
|
|
788
|
+
const withMiddleware = (useSWR2, middleware2) => {
|
|
789
|
+
return (...args) => {
|
|
790
|
+
const [key, fn, config] = normalize(args);
|
|
791
|
+
const uses = (config.use || []).concat(middleware2);
|
|
792
|
+
return useSWR2(key, fn, {
|
|
793
|
+
...config,
|
|
794
|
+
use: uses
|
|
795
|
+
});
|
|
796
|
+
};
|
|
797
|
+
};
|
|
798
|
+
setupDevTools();
|
|
799
|
+
const use = ReactExports.use || // This extra generic is to avoid TypeScript mixing up the generic and JSX sytax
|
|
800
|
+
// and emitting an error.
|
|
801
|
+
// We assume that this is only for the `use(thenable)` case, not `use(context)`.
|
|
802
|
+
// https://github.com/facebook/react/blob/aed00dacfb79d17c53218404c52b1c7aa59c4a89/packages/react-server/src/ReactFizzThenable.js#L45
|
|
803
|
+
((thenable) => {
|
|
804
|
+
switch (thenable.status) {
|
|
805
|
+
case "pending":
|
|
806
|
+
throw thenable;
|
|
807
|
+
case "fulfilled":
|
|
808
|
+
return thenable.value;
|
|
809
|
+
case "rejected":
|
|
810
|
+
throw thenable.reason;
|
|
811
|
+
default:
|
|
812
|
+
thenable.status = "pending";
|
|
813
|
+
thenable.then((v) => {
|
|
814
|
+
thenable.status = "fulfilled";
|
|
815
|
+
thenable.value = v;
|
|
816
|
+
}, (e) => {
|
|
817
|
+
thenable.status = "rejected";
|
|
818
|
+
thenable.reason = e;
|
|
819
|
+
});
|
|
820
|
+
throw thenable;
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
const WITH_DEDUPE = {
|
|
824
|
+
dedupe: true
|
|
825
|
+
};
|
|
826
|
+
const resolvedUndef = Promise.resolve(UNDEFINED$1);
|
|
827
|
+
const useSWRHandler = (_key, fetcher, config) => {
|
|
828
|
+
const { cache: cache2, compare: compare2, suspense, fallbackData, revalidateOnMount, revalidateIfStale, refreshInterval, refreshWhenHidden, refreshWhenOffline, keepPreviousData } = config;
|
|
829
|
+
const [EVENT_REVALIDATORS, MUTATION, FETCH, PRELOAD] = SWRGlobalState.get(cache2);
|
|
830
|
+
const [key, fnArg] = serialize$1(_key);
|
|
831
|
+
const initialMountedRef = reactExports.useRef(false);
|
|
832
|
+
const unmountedRef = reactExports.useRef(false);
|
|
833
|
+
const keyRef = reactExports.useRef(key);
|
|
834
|
+
const fetcherRef = reactExports.useRef(fetcher);
|
|
835
|
+
const configRef = reactExports.useRef(config);
|
|
836
|
+
const getConfig = () => configRef.current;
|
|
837
|
+
const isActive = () => getConfig().isVisible() && getConfig().isOnline();
|
|
838
|
+
const [getCache, setCache, subscribeCache, getInitialCache] = createCacheHelper(cache2, key);
|
|
839
|
+
const stateDependencies = reactExports.useRef({}).current;
|
|
840
|
+
const fallback = isUndefined$1(fallbackData) ? isUndefined$1(config.fallback) ? UNDEFINED$1 : config.fallback[key] : fallbackData;
|
|
841
|
+
const isEqual = (prev, current) => {
|
|
842
|
+
for (const _ in stateDependencies) {
|
|
843
|
+
const t = _;
|
|
844
|
+
if (t === "data") {
|
|
845
|
+
if (!compare2(prev[t], current[t])) {
|
|
846
|
+
if (!isUndefined$1(prev[t])) {
|
|
847
|
+
return false;
|
|
848
|
+
}
|
|
849
|
+
if (!compare2(returnedData, current[t])) {
|
|
850
|
+
return false;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
} else {
|
|
854
|
+
if (current[t] !== prev[t]) {
|
|
855
|
+
return false;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
return true;
|
|
860
|
+
};
|
|
861
|
+
const getSnapshot = reactExports.useMemo(() => {
|
|
862
|
+
const shouldStartRequest = (() => {
|
|
863
|
+
if (!key) return false;
|
|
864
|
+
if (!fetcher) return false;
|
|
865
|
+
if (!isUndefined$1(revalidateOnMount)) return revalidateOnMount;
|
|
866
|
+
if (getConfig().isPaused()) return false;
|
|
867
|
+
if (suspense) return false;
|
|
868
|
+
return revalidateIfStale !== false;
|
|
869
|
+
})();
|
|
870
|
+
const getSelectedCache = (state) => {
|
|
871
|
+
const snapshot = mergeObjects(state);
|
|
872
|
+
delete snapshot._k;
|
|
873
|
+
if (!shouldStartRequest) {
|
|
874
|
+
return snapshot;
|
|
875
|
+
}
|
|
876
|
+
return {
|
|
877
|
+
isValidating: true,
|
|
878
|
+
isLoading: true,
|
|
879
|
+
...snapshot
|
|
880
|
+
};
|
|
881
|
+
};
|
|
882
|
+
const cachedData2 = getCache();
|
|
883
|
+
const initialData = getInitialCache();
|
|
884
|
+
const clientSnapshot = getSelectedCache(cachedData2);
|
|
885
|
+
const serverSnapshot = cachedData2 === initialData ? clientSnapshot : getSelectedCache(initialData);
|
|
886
|
+
let memorizedSnapshot = clientSnapshot;
|
|
887
|
+
return [
|
|
888
|
+
() => {
|
|
889
|
+
const newSnapshot = getSelectedCache(getCache());
|
|
890
|
+
const compareResult = isEqual(newSnapshot, memorizedSnapshot);
|
|
891
|
+
if (compareResult) {
|
|
892
|
+
memorizedSnapshot.data = newSnapshot.data;
|
|
893
|
+
memorizedSnapshot.isLoading = newSnapshot.isLoading;
|
|
894
|
+
memorizedSnapshot.isValidating = newSnapshot.isValidating;
|
|
895
|
+
memorizedSnapshot.error = newSnapshot.error;
|
|
896
|
+
return memorizedSnapshot;
|
|
897
|
+
} else {
|
|
898
|
+
memorizedSnapshot = newSnapshot;
|
|
899
|
+
return newSnapshot;
|
|
900
|
+
}
|
|
901
|
+
},
|
|
902
|
+
() => serverSnapshot
|
|
903
|
+
];
|
|
904
|
+
}, [
|
|
905
|
+
cache2,
|
|
906
|
+
key
|
|
907
|
+
]);
|
|
908
|
+
const cached = shimExports.useSyncExternalStore(reactExports.useCallback(
|
|
909
|
+
(callback) => subscribeCache(key, (current, prev) => {
|
|
910
|
+
if (!isEqual(prev, current)) callback();
|
|
911
|
+
}),
|
|
912
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
913
|
+
[
|
|
914
|
+
cache2,
|
|
915
|
+
key
|
|
916
|
+
]
|
|
917
|
+
), getSnapshot[0], getSnapshot[1]);
|
|
918
|
+
const isInitialMount = !initialMountedRef.current;
|
|
919
|
+
const hasRevalidator = EVENT_REVALIDATORS[key] && EVENT_REVALIDATORS[key].length > 0;
|
|
920
|
+
const cachedData = cached.data;
|
|
921
|
+
const data = isUndefined$1(cachedData) ? fallback && isPromiseLike(fallback) ? use(fallback) : fallback : cachedData;
|
|
922
|
+
const error = cached.error;
|
|
923
|
+
const laggyDataRef = reactExports.useRef(data);
|
|
924
|
+
const returnedData = keepPreviousData ? isUndefined$1(cachedData) ? isUndefined$1(laggyDataRef.current) ? data : laggyDataRef.current : cachedData : data;
|
|
925
|
+
const shouldDoInitialRevalidation = (() => {
|
|
926
|
+
if (hasRevalidator && !isUndefined$1(error)) return false;
|
|
927
|
+
if (isInitialMount && !isUndefined$1(revalidateOnMount)) return revalidateOnMount;
|
|
928
|
+
if (getConfig().isPaused()) return false;
|
|
929
|
+
if (suspense) return isUndefined$1(data) ? false : revalidateIfStale;
|
|
930
|
+
return isUndefined$1(data) || revalidateIfStale;
|
|
931
|
+
})();
|
|
932
|
+
const defaultValidatingState = !!(key && fetcher && isInitialMount && shouldDoInitialRevalidation);
|
|
933
|
+
const isValidating = isUndefined$1(cached.isValidating) ? defaultValidatingState : cached.isValidating;
|
|
934
|
+
const isLoading = isUndefined$1(cached.isLoading) ? defaultValidatingState : cached.isLoading;
|
|
935
|
+
const revalidate = reactExports.useCallback(
|
|
936
|
+
async (revalidateOpts) => {
|
|
937
|
+
const currentFetcher = fetcherRef.current;
|
|
938
|
+
if (!key || !currentFetcher || unmountedRef.current || getConfig().isPaused()) {
|
|
939
|
+
return false;
|
|
940
|
+
}
|
|
941
|
+
let newData;
|
|
942
|
+
let startAt;
|
|
943
|
+
let loading = true;
|
|
944
|
+
const opts = revalidateOpts || {};
|
|
945
|
+
const shouldStartNewRequest = !FETCH[key] || !opts.dedupe;
|
|
946
|
+
const callbackSafeguard = () => {
|
|
947
|
+
if (IS_REACT_LEGACY) {
|
|
948
|
+
return !unmountedRef.current && key === keyRef.current && initialMountedRef.current;
|
|
949
|
+
}
|
|
950
|
+
return key === keyRef.current;
|
|
951
|
+
};
|
|
952
|
+
const finalState = {
|
|
953
|
+
isValidating: false,
|
|
954
|
+
isLoading: false
|
|
955
|
+
};
|
|
956
|
+
const finishRequestAndUpdateState = () => {
|
|
957
|
+
setCache(finalState);
|
|
958
|
+
};
|
|
959
|
+
const cleanupState = () => {
|
|
960
|
+
const requestInfo = FETCH[key];
|
|
961
|
+
if (requestInfo && requestInfo[1] === startAt) {
|
|
962
|
+
delete FETCH[key];
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
const initialState = {
|
|
966
|
+
isValidating: true
|
|
967
|
+
};
|
|
968
|
+
if (isUndefined$1(getCache().data)) {
|
|
969
|
+
initialState.isLoading = true;
|
|
970
|
+
}
|
|
971
|
+
try {
|
|
972
|
+
if (shouldStartNewRequest) {
|
|
973
|
+
setCache(initialState);
|
|
974
|
+
if (config.loadingTimeout && isUndefined$1(getCache().data)) {
|
|
975
|
+
setTimeout(() => {
|
|
976
|
+
if (loading && callbackSafeguard()) {
|
|
977
|
+
getConfig().onLoadingSlow(key, config);
|
|
978
|
+
}
|
|
979
|
+
}, config.loadingTimeout);
|
|
980
|
+
}
|
|
981
|
+
FETCH[key] = [
|
|
982
|
+
currentFetcher(fnArg),
|
|
983
|
+
getTimestamp()
|
|
984
|
+
];
|
|
985
|
+
}
|
|
986
|
+
;
|
|
987
|
+
[newData, startAt] = FETCH[key];
|
|
988
|
+
newData = await newData;
|
|
989
|
+
if (shouldStartNewRequest) {
|
|
990
|
+
setTimeout(cleanupState, config.dedupingInterval);
|
|
991
|
+
}
|
|
992
|
+
if (!FETCH[key] || FETCH[key][1] !== startAt) {
|
|
993
|
+
if (shouldStartNewRequest) {
|
|
994
|
+
if (callbackSafeguard()) {
|
|
995
|
+
getConfig().onDiscarded(key);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
return false;
|
|
999
|
+
}
|
|
1000
|
+
finalState.error = UNDEFINED$1;
|
|
1001
|
+
const mutationInfo = MUTATION[key];
|
|
1002
|
+
if (!isUndefined$1(mutationInfo) && // case 1
|
|
1003
|
+
(startAt <= mutationInfo[0] || // case 2
|
|
1004
|
+
startAt <= mutationInfo[1] || // case 3
|
|
1005
|
+
mutationInfo[1] === 0)) {
|
|
1006
|
+
finishRequestAndUpdateState();
|
|
1007
|
+
if (shouldStartNewRequest) {
|
|
1008
|
+
if (callbackSafeguard()) {
|
|
1009
|
+
getConfig().onDiscarded(key);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
return false;
|
|
1013
|
+
}
|
|
1014
|
+
const cacheData = getCache().data;
|
|
1015
|
+
finalState.data = compare2(cacheData, newData) ? cacheData : newData;
|
|
1016
|
+
if (shouldStartNewRequest) {
|
|
1017
|
+
if (callbackSafeguard()) {
|
|
1018
|
+
getConfig().onSuccess(newData, key, config);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
} catch (err) {
|
|
1022
|
+
cleanupState();
|
|
1023
|
+
const currentConfig = getConfig();
|
|
1024
|
+
const { shouldRetryOnError } = currentConfig;
|
|
1025
|
+
if (!currentConfig.isPaused()) {
|
|
1026
|
+
finalState.error = err;
|
|
1027
|
+
if (shouldStartNewRequest && callbackSafeguard()) {
|
|
1028
|
+
currentConfig.onError(err, key, currentConfig);
|
|
1029
|
+
if (shouldRetryOnError === true || isFunction$1(shouldRetryOnError) && shouldRetryOnError(err)) {
|
|
1030
|
+
if (!getConfig().revalidateOnFocus || !getConfig().revalidateOnReconnect || isActive()) {
|
|
1031
|
+
currentConfig.onErrorRetry(err, key, currentConfig, (_opts) => {
|
|
1032
|
+
const revalidators = EVENT_REVALIDATORS[key];
|
|
1033
|
+
if (revalidators && revalidators[0]) {
|
|
1034
|
+
revalidators[0](ERROR_REVALIDATE_EVENT, _opts);
|
|
1035
|
+
}
|
|
1036
|
+
}, {
|
|
1037
|
+
retryCount: (opts.retryCount || 0) + 1,
|
|
1038
|
+
dedupe: true
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
loading = false;
|
|
1046
|
+
finishRequestAndUpdateState();
|
|
1047
|
+
return true;
|
|
1048
|
+
},
|
|
1049
|
+
// `setState` is immutable, and `eventsCallback`, `fnArg`, and
|
|
1050
|
+
// `keyValidating` are depending on `key`, so we can exclude them from
|
|
1051
|
+
// the deps array.
|
|
1052
|
+
//
|
|
1053
|
+
// FIXME:
|
|
1054
|
+
// `fn` and `config` might be changed during the lifecycle,
|
|
1055
|
+
// but they might be changed every render like this.
|
|
1056
|
+
// `useSWR('key', () => fetch('/api/'), { suspense: true })`
|
|
1057
|
+
// So we omit the values from the deps array
|
|
1058
|
+
// even though it might cause unexpected behaviors.
|
|
1059
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1060
|
+
[
|
|
1061
|
+
key,
|
|
1062
|
+
cache2
|
|
1063
|
+
]
|
|
1064
|
+
);
|
|
1065
|
+
const boundMutate = reactExports.useCallback(
|
|
1066
|
+
// Use callback to make sure `keyRef.current` returns latest result every time
|
|
1067
|
+
(...args) => {
|
|
1068
|
+
return internalMutate(cache2, keyRef.current, ...args);
|
|
1069
|
+
},
|
|
1070
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1071
|
+
[]
|
|
1072
|
+
);
|
|
1073
|
+
useIsomorphicLayoutEffect(() => {
|
|
1074
|
+
fetcherRef.current = fetcher;
|
|
1075
|
+
configRef.current = config;
|
|
1076
|
+
if (!isUndefined$1(cachedData)) {
|
|
1077
|
+
laggyDataRef.current = cachedData;
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
1080
|
+
useIsomorphicLayoutEffect(() => {
|
|
1081
|
+
if (!key) return;
|
|
1082
|
+
const softRevalidate = revalidate.bind(UNDEFINED$1, WITH_DEDUPE);
|
|
1083
|
+
let nextFocusRevalidatedAt = 0;
|
|
1084
|
+
if (getConfig().revalidateOnFocus) {
|
|
1085
|
+
const initNow = Date.now();
|
|
1086
|
+
nextFocusRevalidatedAt = initNow + getConfig().focusThrottleInterval;
|
|
1087
|
+
}
|
|
1088
|
+
const onRevalidate = (type, opts = {}) => {
|
|
1089
|
+
if (type == FOCUS_EVENT) {
|
|
1090
|
+
const now = Date.now();
|
|
1091
|
+
if (getConfig().revalidateOnFocus && now > nextFocusRevalidatedAt && isActive()) {
|
|
1092
|
+
nextFocusRevalidatedAt = now + getConfig().focusThrottleInterval;
|
|
1093
|
+
softRevalidate();
|
|
1094
|
+
}
|
|
1095
|
+
} else if (type == RECONNECT_EVENT) {
|
|
1096
|
+
if (getConfig().revalidateOnReconnect && isActive()) {
|
|
1097
|
+
softRevalidate();
|
|
1098
|
+
}
|
|
1099
|
+
} else if (type == MUTATE_EVENT) {
|
|
1100
|
+
return revalidate();
|
|
1101
|
+
} else if (type == ERROR_REVALIDATE_EVENT) {
|
|
1102
|
+
return revalidate(opts);
|
|
1103
|
+
}
|
|
1104
|
+
return;
|
|
1105
|
+
};
|
|
1106
|
+
const unsubEvents = subscribeCallback(key, EVENT_REVALIDATORS, onRevalidate);
|
|
1107
|
+
unmountedRef.current = false;
|
|
1108
|
+
keyRef.current = key;
|
|
1109
|
+
initialMountedRef.current = true;
|
|
1110
|
+
setCache({
|
|
1111
|
+
_k: fnArg
|
|
1112
|
+
});
|
|
1113
|
+
if (shouldDoInitialRevalidation) {
|
|
1114
|
+
if (!FETCH[key]) {
|
|
1115
|
+
if (isUndefined$1(data) || IS_SERVER) {
|
|
1116
|
+
softRevalidate();
|
|
1117
|
+
} else {
|
|
1118
|
+
rAF(softRevalidate);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
return () => {
|
|
1123
|
+
unmountedRef.current = true;
|
|
1124
|
+
unsubEvents();
|
|
1125
|
+
};
|
|
1126
|
+
}, [
|
|
1127
|
+
key
|
|
1128
|
+
]);
|
|
1129
|
+
useIsomorphicLayoutEffect(() => {
|
|
1130
|
+
let timer;
|
|
1131
|
+
function next() {
|
|
1132
|
+
const interval = isFunction$1(refreshInterval) ? refreshInterval(getCache().data) : refreshInterval;
|
|
1133
|
+
if (interval && timer !== -1) {
|
|
1134
|
+
timer = setTimeout(execute, interval);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
function execute() {
|
|
1138
|
+
if (!getCache().error && (refreshWhenHidden || getConfig().isVisible()) && (refreshWhenOffline || getConfig().isOnline())) {
|
|
1139
|
+
revalidate(WITH_DEDUPE).then(next);
|
|
1140
|
+
} else {
|
|
1141
|
+
next();
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
next();
|
|
1145
|
+
return () => {
|
|
1146
|
+
if (timer) {
|
|
1147
|
+
clearTimeout(timer);
|
|
1148
|
+
timer = -1;
|
|
1149
|
+
}
|
|
1150
|
+
};
|
|
1151
|
+
}, [
|
|
1152
|
+
refreshInterval,
|
|
1153
|
+
refreshWhenHidden,
|
|
1154
|
+
refreshWhenOffline,
|
|
1155
|
+
key
|
|
1156
|
+
]);
|
|
1157
|
+
reactExports.useDebugValue(returnedData);
|
|
1158
|
+
if (suspense) {
|
|
1159
|
+
const hasKeyButNoData = key && isUndefined$1(data);
|
|
1160
|
+
if (!IS_REACT_LEGACY && IS_SERVER && hasKeyButNoData) {
|
|
1161
|
+
throw new Error("Fallback data is required when using Suspense in SSR.");
|
|
1162
|
+
}
|
|
1163
|
+
if (hasKeyButNoData) {
|
|
1164
|
+
fetcherRef.current = fetcher;
|
|
1165
|
+
configRef.current = config;
|
|
1166
|
+
unmountedRef.current = false;
|
|
1167
|
+
}
|
|
1168
|
+
const req = PRELOAD[key];
|
|
1169
|
+
const mutateReq = !isUndefined$1(req) && hasKeyButNoData ? boundMutate(req) : resolvedUndef;
|
|
1170
|
+
use(mutateReq);
|
|
1171
|
+
if (!isUndefined$1(error) && hasKeyButNoData) {
|
|
1172
|
+
throw error;
|
|
1173
|
+
}
|
|
1174
|
+
const revalidation = hasKeyButNoData ? revalidate(WITH_DEDUPE) : resolvedUndef;
|
|
1175
|
+
if (!isUndefined$1(returnedData) && hasKeyButNoData) {
|
|
1176
|
+
revalidation.status = "fulfilled";
|
|
1177
|
+
revalidation.value = true;
|
|
1178
|
+
}
|
|
1179
|
+
use(revalidation);
|
|
1180
|
+
}
|
|
1181
|
+
const swrResponse = {
|
|
1182
|
+
mutate: boundMutate,
|
|
1183
|
+
get data() {
|
|
1184
|
+
stateDependencies.data = true;
|
|
1185
|
+
return returnedData;
|
|
1186
|
+
},
|
|
1187
|
+
get error() {
|
|
1188
|
+
stateDependencies.error = true;
|
|
1189
|
+
return error;
|
|
1190
|
+
},
|
|
1191
|
+
get isValidating() {
|
|
1192
|
+
stateDependencies.isValidating = true;
|
|
1193
|
+
return isValidating;
|
|
1194
|
+
},
|
|
1195
|
+
get isLoading() {
|
|
1196
|
+
stateDependencies.isLoading = true;
|
|
1197
|
+
return isLoading;
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
return swrResponse;
|
|
1201
|
+
};
|
|
1202
|
+
const useSWR = withArgs(useSWRHandler);
|
|
1203
|
+
const noop = () => {
|
|
1204
|
+
};
|
|
1205
|
+
const UNDEFINED = (
|
|
1206
|
+
/*#__NOINLINE__*/
|
|
1207
|
+
noop()
|
|
1208
|
+
);
|
|
1209
|
+
const OBJECT = Object;
|
|
1210
|
+
const isUndefined = (v) => v === UNDEFINED;
|
|
1211
|
+
const isFunction = (v) => typeof v == "function";
|
|
1212
|
+
const table = /* @__PURE__ */ new WeakMap();
|
|
1213
|
+
const getTypeName = (value) => OBJECT.prototype.toString.call(value);
|
|
1214
|
+
const isObjectTypeName = (typeName, type) => typeName === `[object ${type}]`;
|
|
1215
|
+
let counter = 0;
|
|
1216
|
+
const stableHash = (arg) => {
|
|
1217
|
+
const type = typeof arg;
|
|
1218
|
+
const typeName = getTypeName(arg);
|
|
1219
|
+
const isDate = isObjectTypeName(typeName, "Date");
|
|
1220
|
+
const isRegex = isObjectTypeName(typeName, "RegExp");
|
|
1221
|
+
const isPlainObject = isObjectTypeName(typeName, "Object");
|
|
1222
|
+
let result;
|
|
1223
|
+
let index;
|
|
1224
|
+
if (OBJECT(arg) === arg && !isDate && !isRegex) {
|
|
1225
|
+
result = table.get(arg);
|
|
1226
|
+
if (result) return result;
|
|
1227
|
+
result = ++counter + "~";
|
|
1228
|
+
table.set(arg, result);
|
|
1229
|
+
if (Array.isArray(arg)) {
|
|
1230
|
+
result = "@";
|
|
1231
|
+
for (index = 0; index < arg.length; index++) {
|
|
1232
|
+
result += stableHash(arg[index]) + ",";
|
|
1233
|
+
}
|
|
1234
|
+
table.set(arg, result);
|
|
1235
|
+
}
|
|
1236
|
+
if (isPlainObject) {
|
|
1237
|
+
result = "#";
|
|
1238
|
+
const keys = OBJECT.keys(arg).sort();
|
|
1239
|
+
while (!isUndefined(index = keys.pop())) {
|
|
1240
|
+
if (!isUndefined(arg[index])) {
|
|
1241
|
+
result += index + ":" + stableHash(arg[index]) + ",";
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
table.set(arg, result);
|
|
1245
|
+
}
|
|
1246
|
+
} else {
|
|
1247
|
+
result = isDate ? arg.toJSON() : type == "symbol" ? arg.toString() : type == "string" ? JSON.stringify(arg) : "" + arg;
|
|
1248
|
+
}
|
|
1249
|
+
return result;
|
|
1250
|
+
};
|
|
1251
|
+
const serialize = (key) => {
|
|
1252
|
+
if (isFunction(key)) {
|
|
1253
|
+
try {
|
|
1254
|
+
key = key();
|
|
1255
|
+
} catch (err) {
|
|
1256
|
+
key = "";
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
const args = key;
|
|
1260
|
+
key = typeof key == "string" ? key : (Array.isArray(key) ? key.length : key) ? stableHash(key) : "";
|
|
1261
|
+
return [
|
|
1262
|
+
key,
|
|
1263
|
+
args
|
|
1264
|
+
];
|
|
1265
|
+
};
|
|
1266
|
+
const getFirstPageKey = (getKey) => {
|
|
1267
|
+
return serialize(getKey ? getKey(0, null) : null)[0];
|
|
1268
|
+
};
|
|
1269
|
+
const EMPTY_PROMISE = Promise.resolve();
|
|
1270
|
+
const infinite = (useSWRNext) => (getKey, fn, config) => {
|
|
1271
|
+
const didMountRef = reactExports.useRef(false);
|
|
1272
|
+
const { cache: cache$1, initialSize = 1, revalidateAll = false, persistSize = false, revalidateFirstPage = true, revalidateOnMount = false, parallel = false } = config;
|
|
1273
|
+
const [, , , PRELOAD] = SWRGlobalState.get(cache);
|
|
1274
|
+
let infiniteKey;
|
|
1275
|
+
try {
|
|
1276
|
+
infiniteKey = getFirstPageKey(getKey);
|
|
1277
|
+
if (infiniteKey) infiniteKey = INFINITE_PREFIX + infiniteKey;
|
|
1278
|
+
} catch (err) {
|
|
1279
|
+
}
|
|
1280
|
+
const [get, set, subscribeCache] = createCacheHelper(cache$1, infiniteKey);
|
|
1281
|
+
const getSnapshot = reactExports.useCallback(() => {
|
|
1282
|
+
const size = isUndefined$1(get()._l) ? initialSize : get()._l;
|
|
1283
|
+
return size;
|
|
1284
|
+
}, [
|
|
1285
|
+
cache$1,
|
|
1286
|
+
infiniteKey,
|
|
1287
|
+
initialSize
|
|
1288
|
+
]);
|
|
1289
|
+
shimExports.useSyncExternalStore(reactExports.useCallback(
|
|
1290
|
+
(callback) => {
|
|
1291
|
+
if (infiniteKey) return subscribeCache(infiniteKey, () => {
|
|
1292
|
+
callback();
|
|
1293
|
+
});
|
|
1294
|
+
return () => {
|
|
1295
|
+
};
|
|
1296
|
+
},
|
|
1297
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1298
|
+
[
|
|
1299
|
+
cache$1,
|
|
1300
|
+
infiniteKey
|
|
1301
|
+
]
|
|
1302
|
+
), getSnapshot, getSnapshot);
|
|
1303
|
+
const resolvePageSize = reactExports.useCallback(() => {
|
|
1304
|
+
const cachedPageSize = get()._l;
|
|
1305
|
+
return isUndefined$1(cachedPageSize) ? initialSize : cachedPageSize;
|
|
1306
|
+
}, [
|
|
1307
|
+
infiniteKey,
|
|
1308
|
+
initialSize
|
|
1309
|
+
]);
|
|
1310
|
+
const lastPageSizeRef = reactExports.useRef(resolvePageSize());
|
|
1311
|
+
useIsomorphicLayoutEffect(() => {
|
|
1312
|
+
if (!didMountRef.current) {
|
|
1313
|
+
didMountRef.current = true;
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
if (infiniteKey) {
|
|
1317
|
+
set({
|
|
1318
|
+
_l: persistSize ? lastPageSizeRef.current : resolvePageSize()
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
}, [
|
|
1322
|
+
infiniteKey,
|
|
1323
|
+
cache$1
|
|
1324
|
+
]);
|
|
1325
|
+
const shouldRevalidateOnMount = revalidateOnMount && !didMountRef.current;
|
|
1326
|
+
const swr = useSWRNext(infiniteKey, async (key) => {
|
|
1327
|
+
const forceRevalidateAll = get()._i;
|
|
1328
|
+
const shouldRevalidatePage = get()._r;
|
|
1329
|
+
set({
|
|
1330
|
+
_r: UNDEFINED$1
|
|
1331
|
+
});
|
|
1332
|
+
const data = [];
|
|
1333
|
+
const pageSize = resolvePageSize();
|
|
1334
|
+
const [getCache] = createCacheHelper(cache$1, key);
|
|
1335
|
+
const cacheData = getCache().data;
|
|
1336
|
+
const revalidators = [];
|
|
1337
|
+
let previousPageData = null;
|
|
1338
|
+
for (let i = 0; i < pageSize; ++i) {
|
|
1339
|
+
const [pageKey, pageArg] = serialize$1(getKey(i, parallel ? null : previousPageData));
|
|
1340
|
+
if (!pageKey) {
|
|
1341
|
+
break;
|
|
1342
|
+
}
|
|
1343
|
+
const [getSWRCache, setSWRCache] = createCacheHelper(cache$1, pageKey);
|
|
1344
|
+
let pageData = getSWRCache().data;
|
|
1345
|
+
const shouldFetchPage = revalidateAll || forceRevalidateAll || isUndefined$1(pageData) || revalidateFirstPage && !i && !isUndefined$1(cacheData) || shouldRevalidateOnMount || cacheData && !isUndefined$1(cacheData[i]) && !config.compare(cacheData[i], pageData);
|
|
1346
|
+
if (fn && (typeof shouldRevalidatePage === "function" ? shouldRevalidatePage(pageData, pageArg) : shouldFetchPage)) {
|
|
1347
|
+
const revalidate = async () => {
|
|
1348
|
+
const hasPreloadedRequest = pageKey in PRELOAD;
|
|
1349
|
+
if (!hasPreloadedRequest) {
|
|
1350
|
+
pageData = await fn(pageArg);
|
|
1351
|
+
} else {
|
|
1352
|
+
const req = PRELOAD[pageKey];
|
|
1353
|
+
delete PRELOAD[pageKey];
|
|
1354
|
+
pageData = await req;
|
|
1355
|
+
}
|
|
1356
|
+
setSWRCache({
|
|
1357
|
+
data: pageData,
|
|
1358
|
+
_k: pageArg
|
|
1359
|
+
});
|
|
1360
|
+
data[i] = pageData;
|
|
1361
|
+
};
|
|
1362
|
+
if (parallel) {
|
|
1363
|
+
revalidators.push(revalidate);
|
|
1364
|
+
} else {
|
|
1365
|
+
await revalidate();
|
|
1366
|
+
}
|
|
1367
|
+
} else {
|
|
1368
|
+
data[i] = pageData;
|
|
1369
|
+
}
|
|
1370
|
+
if (!parallel) {
|
|
1371
|
+
previousPageData = pageData;
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
if (parallel) {
|
|
1375
|
+
await Promise.all(revalidators.map((r) => r()));
|
|
1376
|
+
}
|
|
1377
|
+
set({
|
|
1378
|
+
_i: UNDEFINED$1
|
|
1379
|
+
});
|
|
1380
|
+
return data;
|
|
1381
|
+
}, config);
|
|
1382
|
+
const mutate2 = reactExports.useCallback(
|
|
1383
|
+
// eslint-disable-next-line func-names
|
|
1384
|
+
function(data, opts) {
|
|
1385
|
+
const options = typeof opts === "boolean" ? {
|
|
1386
|
+
revalidate: opts
|
|
1387
|
+
} : opts || {};
|
|
1388
|
+
const shouldRevalidate = options.revalidate !== false;
|
|
1389
|
+
if (!infiniteKey) return EMPTY_PROMISE;
|
|
1390
|
+
if (shouldRevalidate) {
|
|
1391
|
+
if (!isUndefined$1(data)) {
|
|
1392
|
+
set({
|
|
1393
|
+
_i: false,
|
|
1394
|
+
_r: options.revalidate
|
|
1395
|
+
});
|
|
1396
|
+
} else {
|
|
1397
|
+
set({
|
|
1398
|
+
_i: true,
|
|
1399
|
+
_r: options.revalidate
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
return arguments.length ? swr.mutate(data, {
|
|
1404
|
+
...options,
|
|
1405
|
+
revalidate: shouldRevalidate
|
|
1406
|
+
}) : swr.mutate();
|
|
1407
|
+
},
|
|
1408
|
+
// swr.mutate is always the same reference
|
|
1409
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1410
|
+
[
|
|
1411
|
+
infiniteKey,
|
|
1412
|
+
cache$1
|
|
1413
|
+
]
|
|
1414
|
+
);
|
|
1415
|
+
const setSize = reactExports.useCallback(
|
|
1416
|
+
(arg) => {
|
|
1417
|
+
if (!infiniteKey) return EMPTY_PROMISE;
|
|
1418
|
+
const [, changeSize] = createCacheHelper(cache$1, infiniteKey);
|
|
1419
|
+
let size;
|
|
1420
|
+
if (isFunction$1(arg)) {
|
|
1421
|
+
size = arg(resolvePageSize());
|
|
1422
|
+
} else if (typeof arg == "number") {
|
|
1423
|
+
size = arg;
|
|
1424
|
+
}
|
|
1425
|
+
if (typeof size != "number") return EMPTY_PROMISE;
|
|
1426
|
+
changeSize({
|
|
1427
|
+
_l: size
|
|
1428
|
+
});
|
|
1429
|
+
lastPageSizeRef.current = size;
|
|
1430
|
+
const data = [];
|
|
1431
|
+
const [getInfiniteCache] = createCacheHelper(cache$1, infiniteKey);
|
|
1432
|
+
let previousPageData = null;
|
|
1433
|
+
for (let i = 0; i < size; ++i) {
|
|
1434
|
+
const [pageKey] = serialize$1(getKey(i, previousPageData));
|
|
1435
|
+
const [getCache] = createCacheHelper(cache$1, pageKey);
|
|
1436
|
+
const pageData = pageKey ? getCache().data : UNDEFINED$1;
|
|
1437
|
+
if (isUndefined$1(pageData)) {
|
|
1438
|
+
return mutate2(getInfiniteCache().data);
|
|
1439
|
+
}
|
|
1440
|
+
data.push(pageData);
|
|
1441
|
+
previousPageData = pageData;
|
|
1442
|
+
}
|
|
1443
|
+
return mutate2(data);
|
|
1444
|
+
},
|
|
1445
|
+
// exclude getKey from the dependencies, which isn't allowed to change during the lifecycle
|
|
1446
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1447
|
+
[
|
|
1448
|
+
infiniteKey,
|
|
1449
|
+
cache$1,
|
|
1450
|
+
mutate2,
|
|
1451
|
+
resolvePageSize
|
|
1452
|
+
]
|
|
1453
|
+
);
|
|
1454
|
+
return {
|
|
1455
|
+
size: resolvePageSize(),
|
|
1456
|
+
setSize,
|
|
1457
|
+
mutate: mutate2,
|
|
1458
|
+
get data() {
|
|
1459
|
+
return swr.data;
|
|
1460
|
+
},
|
|
1461
|
+
get error() {
|
|
1462
|
+
return swr.error;
|
|
1463
|
+
},
|
|
1464
|
+
get isValidating() {
|
|
1465
|
+
return swr.isValidating;
|
|
1466
|
+
},
|
|
1467
|
+
get isLoading() {
|
|
1468
|
+
return swr.isLoading;
|
|
1469
|
+
}
|
|
1470
|
+
};
|
|
1471
|
+
};
|
|
1472
|
+
const useSWRInfinite = withMiddleware(useSWR, infinite);
|
|
1473
|
+
function useInfiniteList(cacheKey, fetchFn, getItemKey) {
|
|
1474
|
+
var _a;
|
|
1475
|
+
const getKey = reactExports.useCallback(
|
|
1476
|
+
(_index, prev) => {
|
|
1477
|
+
if (prev && (!prev.hasMore || !prev.cursor)) return null;
|
|
1478
|
+
return [cacheKey, (prev == null ? void 0 : prev.cursor) ?? null];
|
|
1479
|
+
},
|
|
1480
|
+
[cacheKey]
|
|
1481
|
+
);
|
|
1482
|
+
const {
|
|
1483
|
+
data: pages,
|
|
1484
|
+
error,
|
|
1485
|
+
isLoading,
|
|
1486
|
+
isValidating,
|
|
1487
|
+
size,
|
|
1488
|
+
setSize,
|
|
1489
|
+
mutate: mutate2
|
|
1490
|
+
} = useSWRInfinite(
|
|
1491
|
+
getKey,
|
|
1492
|
+
([, cursor]) => fetchFn(cursor ?? void 0),
|
|
1493
|
+
{
|
|
1494
|
+
revalidateFirstPage: false,
|
|
1495
|
+
revalidateIfStale: false,
|
|
1496
|
+
revalidateOnFocus: false,
|
|
1497
|
+
keepPreviousData: true
|
|
1498
|
+
}
|
|
1499
|
+
);
|
|
1500
|
+
const items = reactExports.useMemo(() => {
|
|
1501
|
+
if (!pages) return [];
|
|
1502
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1503
|
+
const result = [];
|
|
1504
|
+
for (const page of pages) {
|
|
1505
|
+
for (const item of page.data) {
|
|
1506
|
+
const key = getItemKey(item);
|
|
1507
|
+
if (seen.has(key)) continue;
|
|
1508
|
+
seen.add(key);
|
|
1509
|
+
result.push(item);
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
return result;
|
|
1513
|
+
}, [pages, getItemKey]);
|
|
1514
|
+
const lastPage = pages == null ? void 0 : pages[pages.length - 1];
|
|
1515
|
+
const hasMore = Boolean((lastPage == null ? void 0 : lastPage.hasMore) && (lastPage == null ? void 0 : lastPage.cursor));
|
|
1516
|
+
const isLoadingMore = size > 0 && Boolean(pages) && pages.length < size;
|
|
1517
|
+
const loadMore = reactExports.useCallback(() => {
|
|
1518
|
+
if (isValidating || !hasMore) return;
|
|
1519
|
+
void setSize((s) => s + 1);
|
|
1520
|
+
}, [isValidating, hasMore, setSize]);
|
|
1521
|
+
const reload = reactExports.useCallback(() => {
|
|
1522
|
+
void setSize(1);
|
|
1523
|
+
void mutate2();
|
|
1524
|
+
}, [setSize, mutate2]);
|
|
1525
|
+
const normalizedError = error ? error instanceof Error ? error : new WorkflowWebAPIError(String(error), { layer: "client" }) : null;
|
|
1526
|
+
return {
|
|
1527
|
+
items,
|
|
1528
|
+
error: normalizedError,
|
|
1529
|
+
isLoading,
|
|
1530
|
+
isLoadingMore,
|
|
1531
|
+
hasMore,
|
|
1532
|
+
loadMore,
|
|
1533
|
+
reload,
|
|
1534
|
+
refresh: reload,
|
|
1535
|
+
pageInfo: (_a = pages == null ? void 0 : pages[0]) == null ? void 0 : _a.pageInfo
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
function useWorkflowRunsInfinite(env, params) {
|
|
1539
|
+
const {
|
|
1540
|
+
workflowName,
|
|
1541
|
+
status,
|
|
1542
|
+
limit = 25,
|
|
1543
|
+
sortOrder = "desc",
|
|
1544
|
+
startTime,
|
|
1545
|
+
endTime
|
|
1546
|
+
} = params;
|
|
1547
|
+
const cacheKey = `workflow-runs:${workflowName ?? ""}:${status ?? ""}:${sortOrder}:${limit}:${startTime ?? ""}:${endTime ?? ""}`;
|
|
1548
|
+
const fetchFn = reactExports.useCallback(
|
|
1549
|
+
(cursor) => unwrapOrThrow(
|
|
1550
|
+
fetchRuns(env, {
|
|
1551
|
+
cursor,
|
|
1552
|
+
sortOrder,
|
|
1553
|
+
limit,
|
|
1554
|
+
workflowName,
|
|
1555
|
+
status,
|
|
1556
|
+
startTime,
|
|
1557
|
+
endTime
|
|
1558
|
+
})
|
|
1559
|
+
),
|
|
1560
|
+
[env, workflowName, limit, sortOrder, status, startTime, endTime]
|
|
1561
|
+
);
|
|
1562
|
+
const getItemKey = reactExports.useCallback((run) => run.runId, []);
|
|
1563
|
+
return useInfiniteList(cacheKey, fetchFn, getItemKey);
|
|
1564
|
+
}
|
|
1565
|
+
function useLoadMoreOnScroll(loadMore, {
|
|
1566
|
+
hasMore,
|
|
1567
|
+
isLoadingMore,
|
|
1568
|
+
root = null,
|
|
1569
|
+
rootMargin = "400px"
|
|
1570
|
+
}) {
|
|
1571
|
+
const sentinelRef = reactExports.useRef(null);
|
|
1572
|
+
const loadMoreRef = reactExports.useRef(loadMore);
|
|
1573
|
+
reactExports.useEffect(() => {
|
|
1574
|
+
loadMoreRef.current = loadMore;
|
|
1575
|
+
}, [loadMore]);
|
|
1576
|
+
reactExports.useEffect(() => {
|
|
1577
|
+
const sentinel = sentinelRef.current;
|
|
1578
|
+
if (!sentinel || !hasMore || isLoadingMore) return;
|
|
1579
|
+
const observer = new IntersectionObserver(
|
|
1580
|
+
(entries) => {
|
|
1581
|
+
for (const entry of entries) {
|
|
1582
|
+
if (entry.isIntersecting) {
|
|
1583
|
+
loadMoreRef.current();
|
|
1584
|
+
break;
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
},
|
|
1588
|
+
{ root, rootMargin, threshold: 0 }
|
|
1589
|
+
);
|
|
1590
|
+
observer.observe(sentinel);
|
|
1591
|
+
return () => observer.disconnect();
|
|
1592
|
+
}, [hasMore, isLoadingMore, root, rootMargin]);
|
|
1593
|
+
return sentinelRef;
|
|
393
1594
|
}
|
|
394
1595
|
function usePaginatedList(fetchFn) {
|
|
395
1596
|
var _a;
|
|
@@ -423,7 +1624,8 @@ function usePaginatedList(fetchFn) {
|
|
|
423
1624
|
newMap.set(pageIndex, {
|
|
424
1625
|
data: cached.data,
|
|
425
1626
|
isLoading: false,
|
|
426
|
-
error: null
|
|
1627
|
+
error: null,
|
|
1628
|
+
pageInfo: cached.pageInfo
|
|
427
1629
|
});
|
|
428
1630
|
return newMap;
|
|
429
1631
|
});
|
|
@@ -437,14 +1639,16 @@ function usePaginatedList(fetchFn) {
|
|
|
437
1639
|
pageCache.current.set(cacheKey, {
|
|
438
1640
|
data: result.data,
|
|
439
1641
|
cursor: result.cursor,
|
|
440
|
-
hasMore: result.hasMore
|
|
1642
|
+
hasMore: result.hasMore,
|
|
1643
|
+
pageInfo: result.pageInfo
|
|
441
1644
|
});
|
|
442
1645
|
setAllPageResults((prev) => {
|
|
443
1646
|
const newMap = new Map(prev);
|
|
444
1647
|
newMap.set(pageIndex, {
|
|
445
1648
|
data: result.data,
|
|
446
1649
|
isLoading: false,
|
|
447
|
-
error: null
|
|
1650
|
+
error: null,
|
|
1651
|
+
pageInfo: result.pageInfo
|
|
448
1652
|
});
|
|
449
1653
|
return newMap;
|
|
450
1654
|
});
|
|
@@ -536,22 +1740,13 @@ function usePaginatedList(fetchFn) {
|
|
|
536
1740
|
totalPages,
|
|
537
1741
|
nextPage,
|
|
538
1742
|
previousPage,
|
|
539
|
-
hasNextPage: hasMore,
|
|
540
|
-
hasPreviousPage: currentPage > 0,
|
|
541
|
-
reload,
|
|
542
|
-
refresh,
|
|
543
|
-
pageInfo
|
|
544
|
-
|
|
545
|
-
}
|
|
546
|
-
function useWorkflowRuns(env, params) {
|
|
547
|
-
const { workflowName, status, limit = 10, sortOrder = "desc" } = params;
|
|
548
|
-
const fetchFn = reactExports.useCallback(
|
|
549
|
-
(cursor) => unwrapOrThrow(
|
|
550
|
-
fetchRuns(env, { cursor, sortOrder, limit, workflowName, status })
|
|
551
|
-
),
|
|
552
|
-
[env, workflowName, limit, sortOrder, status]
|
|
553
|
-
);
|
|
554
|
-
return usePaginatedList(fetchFn);
|
|
1743
|
+
hasNextPage: hasMore,
|
|
1744
|
+
hasPreviousPage: currentPage > 0,
|
|
1745
|
+
reload,
|
|
1746
|
+
refresh,
|
|
1747
|
+
pageInfo,
|
|
1748
|
+
analyticsPageInfo: currentPageResult.pageInfo
|
|
1749
|
+
};
|
|
555
1750
|
}
|
|
556
1751
|
function useWorkflowHooks(env, params) {
|
|
557
1752
|
const { runId, limit = 10, sortOrder = "desc" } = params;
|
|
@@ -561,6 +1756,137 @@ function useWorkflowHooks(env, params) {
|
|
|
561
1756
|
);
|
|
562
1757
|
return usePaginatedList(fetchFn);
|
|
563
1758
|
}
|
|
1759
|
+
function HookTokenCell({ env, runId, hookId }) {
|
|
1760
|
+
const [status, setStatus] = reactExports.useState("idle");
|
|
1761
|
+
const [error, setError] = reactExports.useState(null);
|
|
1762
|
+
const handleCopy = async (e) => {
|
|
1763
|
+
e.stopPropagation();
|
|
1764
|
+
if (status === "loading") return;
|
|
1765
|
+
setStatus("loading");
|
|
1766
|
+
setError(null);
|
|
1767
|
+
try {
|
|
1768
|
+
const token = await fetchHookToken(env, runId, hookId);
|
|
1769
|
+
await navigator.clipboard.writeText(token);
|
|
1770
|
+
setStatus("copied");
|
|
1771
|
+
setTimeout(() => setStatus("idle"), 2e3);
|
|
1772
|
+
} catch (err) {
|
|
1773
|
+
console.error("Failed to copy hook token:", err);
|
|
1774
|
+
setError("Failed to copy token");
|
|
1775
|
+
setStatus("idle");
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1778
|
+
const tooltip = error ? error : status === "copied" ? "Copied!" : status === "loading" ? "Fetching token…" : "Copy token";
|
|
1779
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "relative group/copy inline-block", children: [
|
|
1780
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-muted-foreground", children: "••••••••••••" }),
|
|
1781
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
1782
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1783
|
+
"button",
|
|
1784
|
+
{
|
|
1785
|
+
type: "button",
|
|
1786
|
+
onClick: handleCopy,
|
|
1787
|
+
disabled: status === "loading",
|
|
1788
|
+
className: "absolute right-0 top-1/2 -translate-y-1/2 opacity-0 group-hover/copy:opacity-100 transition-opacity bg-background/80 backdrop-blur-sm p-1 rounded",
|
|
1789
|
+
"aria-label": "Copy token",
|
|
1790
|
+
children: status === "loading" ? /* @__PURE__ */ jsxRuntimeExports.jsx(LoaderCircle, { className: "h-3 w-3 text-muted-foreground animate-spin" }) : status === "copied" ? /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "h-3 w-3 text-muted-foreground" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Copy, { className: "h-3 w-3 text-muted-foreground hover:text-foreground" })
|
|
1791
|
+
}
|
|
1792
|
+
) }),
|
|
1793
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: tooltip }) })
|
|
1794
|
+
] })
|
|
1795
|
+
] });
|
|
1796
|
+
}
|
|
1797
|
+
function TableSkeleton({
|
|
1798
|
+
rows = DEFAULT_PAGE_SIZE,
|
|
1799
|
+
variant = "runs"
|
|
1800
|
+
}) {
|
|
1801
|
+
const renderRow = (i) => {
|
|
1802
|
+
switch (variant) {
|
|
1803
|
+
case "runs":
|
|
1804
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1805
|
+
"div",
|
|
1806
|
+
{
|
|
1807
|
+
className: "grid grid-cols-[1fr_1.5fr_0.8fr_1fr_1fr_40px] items-center gap-4 py-3 px-4",
|
|
1808
|
+
children: [
|
|
1809
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-3/4" }),
|
|
1810
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-4/5" }),
|
|
1811
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1812
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-14" }),
|
|
1813
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-2 w-8" })
|
|
1814
|
+
] }),
|
|
1815
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-3/4" }),
|
|
1816
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-3/4" }),
|
|
1817
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-6 w-6 rounded" })
|
|
1818
|
+
]
|
|
1819
|
+
},
|
|
1820
|
+
`skeleton-row-${i}`
|
|
1821
|
+
);
|
|
1822
|
+
case "hooks":
|
|
1823
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1824
|
+
"div",
|
|
1825
|
+
{
|
|
1826
|
+
className: "grid grid-cols-[1.2fr_1.2fr_0.8fr_1fr_0.5fr_40px] items-center gap-4 py-3 px-4",
|
|
1827
|
+
children: [
|
|
1828
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-4/5" }),
|
|
1829
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-4/5" }),
|
|
1830
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-3/4" }),
|
|
1831
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-3/4" }),
|
|
1832
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-8" }),
|
|
1833
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-6 w-6 rounded" })
|
|
1834
|
+
]
|
|
1835
|
+
},
|
|
1836
|
+
`skeleton-row-${i}`
|
|
1837
|
+
);
|
|
1838
|
+
case "workflows":
|
|
1839
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1840
|
+
"div",
|
|
1841
|
+
{
|
|
1842
|
+
className: "grid grid-cols-[1fr_1.5fr_0.5fr] items-center gap-4 py-3 px-4",
|
|
1843
|
+
children: [
|
|
1844
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-3/4" }),
|
|
1845
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-4/5" }),
|
|
1846
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-5 w-16 rounded-full mx-auto" })
|
|
1847
|
+
]
|
|
1848
|
+
},
|
|
1849
|
+
`skeleton-row-${i}`
|
|
1850
|
+
);
|
|
1851
|
+
default:
|
|
1852
|
+
return null;
|
|
1853
|
+
}
|
|
1854
|
+
};
|
|
1855
|
+
const renderHeader = () => {
|
|
1856
|
+
switch (variant) {
|
|
1857
|
+
case "runs":
|
|
1858
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-[1fr_1.5fr_0.8fr_1fr_1fr_40px] items-center gap-4 py-3 px-4 border-b", children: [
|
|
1859
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-20" }),
|
|
1860
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-14" }),
|
|
1861
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-12" }),
|
|
1862
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-14" }),
|
|
1863
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-20" }),
|
|
1864
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-6" })
|
|
1865
|
+
] });
|
|
1866
|
+
case "hooks":
|
|
1867
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-[1.2fr_1.2fr_0.8fr_1fr_0.5fr_40px] items-center gap-4 py-3 px-4 border-b", children: [
|
|
1868
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-16" }),
|
|
1869
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-14" }),
|
|
1870
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-12" }),
|
|
1871
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-14" }),
|
|
1872
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-20" }),
|
|
1873
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-6" })
|
|
1874
|
+
] });
|
|
1875
|
+
case "workflows":
|
|
1876
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-[1fr_1.5fr_0.5fr] items-center gap-4 py-3 px-4 border-b", children: [
|
|
1877
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-20" }),
|
|
1878
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-10" }),
|
|
1879
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-12 mx-auto" })
|
|
1880
|
+
] });
|
|
1881
|
+
default:
|
|
1882
|
+
return null;
|
|
1883
|
+
}
|
|
1884
|
+
};
|
|
1885
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "overflow-hidden mt-4 bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "p-0", children: [
|
|
1886
|
+
renderHeader(),
|
|
1887
|
+
Array.from({ length: rows }, (_, i) => renderRow(i))
|
|
1888
|
+
] }) });
|
|
1889
|
+
}
|
|
564
1890
|
function HooksTable({
|
|
565
1891
|
runId,
|
|
566
1892
|
onHookClick,
|
|
@@ -585,7 +1911,8 @@ function HooksTable({
|
|
|
585
1911
|
});
|
|
586
1912
|
const hookActions = useHookActions({
|
|
587
1913
|
onResolve: async (hook, payload) => {
|
|
588
|
-
await
|
|
1914
|
+
const token = await fetchHookToken(env, hook.runId, hook.hookId);
|
|
1915
|
+
await resumeHook(env, token, payload);
|
|
589
1916
|
},
|
|
590
1917
|
callbacks: {
|
|
591
1918
|
onSuccess: refresh
|
|
@@ -720,7 +2047,7 @@ function HooksTable({
|
|
|
720
2047
|
] }),
|
|
721
2048
|
error ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Alert, { variant: "destructive", children: [
|
|
722
2049
|
/* @__PURE__ */ jsxRuntimeExports.jsx(CircleAlert, { className: "h-4 w-4" }),
|
|
723
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(AlertTitle, { children: "Error loading hooks" }),
|
|
2050
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(AlertTitle, { children: getErrorTitle(error, "Error loading hooks") }),
|
|
724
2051
|
/* @__PURE__ */ jsxRuntimeExports.jsx(AlertDescription, { children: getErrorMessage(error) })
|
|
725
2052
|
] }) : !loading && (!hooks || hooks.length === 0) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center py-8 text-muted-foreground", children: [
|
|
726
2053
|
"No active hooks found. ",
|
|
@@ -745,7 +2072,14 @@ function HooksTable({
|
|
|
745
2072
|
children: [
|
|
746
2073
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "font-mono text-xs py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyableText, { text: hook.hookId, overlay: true, children: hook.hookId }) }),
|
|
747
2074
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "font-mono text-xs py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyableText, { text: hook.runId, overlay: true, children: hook.runId }) }),
|
|
748
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "font-mono text-xs py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2075
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "font-mono text-xs py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2076
|
+
HookTokenCell,
|
|
2077
|
+
{
|
|
2078
|
+
env,
|
|
2079
|
+
runId: hook.runId,
|
|
2080
|
+
hookId: hook.hookId
|
|
2081
|
+
}
|
|
2082
|
+
) }),
|
|
749
2083
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "py-2 text-muted-foreground text-xs", children: hook.createdAt ? /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: hook.createdAt }) : "-" }),
|
|
750
2084
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "py-2", children: renderInvocationCount(hook) }),
|
|
751
2085
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenu, { children: [
|
|
@@ -2293,6 +3627,37 @@ const SelectSeparator = reactExports.forwardRef(({ className, ...props }, ref) =
|
|
|
2293
3627
|
}
|
|
2294
3628
|
));
|
|
2295
3629
|
SelectSeparator.displayName = Separator.displayName;
|
|
3630
|
+
function bulkCancelToastSeverity(summary) {
|
|
3631
|
+
const succeeded = summary.cancelled + summary.alreadyCancelled;
|
|
3632
|
+
const hadProblem = summary.failed + summary.notCancellable + summary.notFound > 0;
|
|
3633
|
+
if (succeeded === 0) return "error";
|
|
3634
|
+
if (hadProblem) return "warning";
|
|
3635
|
+
return "success";
|
|
3636
|
+
}
|
|
3637
|
+
function shouldRetainSelectionAfterBulkCancel(result) {
|
|
3638
|
+
return result.outcome === "failed" && result.retryable;
|
|
3639
|
+
}
|
|
3640
|
+
const windows = /* @__PURE__ */ new Map();
|
|
3641
|
+
function createWindow(periodMs) {
|
|
3642
|
+
const end = Date.now();
|
|
3643
|
+
return {
|
|
3644
|
+
startTime: new Date(end - periodMs).toISOString(),
|
|
3645
|
+
endTime: new Date(end).toISOString()
|
|
3646
|
+
};
|
|
3647
|
+
}
|
|
3648
|
+
function getListingWindow(periodId, periodMs) {
|
|
3649
|
+
let window2 = windows.get(periodId);
|
|
3650
|
+
if (!window2) {
|
|
3651
|
+
window2 = createWindow(periodMs);
|
|
3652
|
+
windows.set(periodId, window2);
|
|
3653
|
+
}
|
|
3654
|
+
return window2;
|
|
3655
|
+
}
|
|
3656
|
+
function advanceListingWindow(periodId, periodMs) {
|
|
3657
|
+
const window2 = createWindow(periodMs);
|
|
3658
|
+
windows.set(periodId, window2);
|
|
3659
|
+
return window2;
|
|
3660
|
+
}
|
|
2296
3661
|
function useTableSelection({
|
|
2297
3662
|
getItemId
|
|
2298
3663
|
}) {
|
|
@@ -2399,6 +3764,19 @@ function useTableSelection({
|
|
|
2399
3764
|
]
|
|
2400
3765
|
);
|
|
2401
3766
|
}
|
|
3767
|
+
function getRunReplayDisabledReason(run, runIdentityLoading) {
|
|
3768
|
+
var _a;
|
|
3769
|
+
if (runIdentityLoading) {
|
|
3770
|
+
return "Loading run identity...";
|
|
3771
|
+
}
|
|
3772
|
+
if (!run) {
|
|
3773
|
+
return "Unable to verify whether this run can be replayed.";
|
|
3774
|
+
}
|
|
3775
|
+
if ((_a = run.executionContext) == null ? void 0 : _a.dynamicWorkflow) {
|
|
3776
|
+
return "Dynamic runs cannot be replayed as a new run.";
|
|
3777
|
+
}
|
|
3778
|
+
return void 0;
|
|
3779
|
+
}
|
|
2402
3780
|
function SelectionBar({
|
|
2403
3781
|
selectionCount,
|
|
2404
3782
|
onClearSelection,
|
|
@@ -2645,25 +4023,32 @@ function RunActionsDropdownContentInner({
|
|
|
2645
4023
|
onSuccess
|
|
2646
4024
|
}) {
|
|
2647
4025
|
const [events, setEvents] = reactExports.useState(void 0);
|
|
2648
|
-
const [
|
|
4026
|
+
const [eventsLoading, setEventsLoading] = reactExports.useState(true);
|
|
2649
4027
|
const [run, setRun] = reactExports.useState(void 0);
|
|
4028
|
+
const [runIdentityLoading, setRunIdentityLoading] = reactExports.useState(true);
|
|
2650
4029
|
const status = (run == null ? void 0 : run.status) || runStatus;
|
|
2651
4030
|
reactExports.useEffect(() => {
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
fetchEvents(env, runId, { limit: 1e3, sortOrder: "desc" })
|
|
2656
|
-
]).then(([runResult, eventsResult]) => {
|
|
4031
|
+
setRun(void 0);
|
|
4032
|
+
setRunIdentityLoading(true);
|
|
4033
|
+
fetchRun(env, runId, "none").then((runResult) => {
|
|
2657
4034
|
if (runResult.success) {
|
|
2658
4035
|
setRun(runResult.data);
|
|
2659
4036
|
}
|
|
4037
|
+
}).catch((err) => {
|
|
4038
|
+
console.error("Failed to fetch run:", err);
|
|
4039
|
+
}).finally(() => {
|
|
4040
|
+
setRunIdentityLoading(false);
|
|
4041
|
+
});
|
|
4042
|
+
setEvents(void 0);
|
|
4043
|
+
setEventsLoading(true);
|
|
4044
|
+
fetchEvents(env, runId, { limit: 1e3, sortOrder: "desc" }).then((eventsResult) => {
|
|
2660
4045
|
if (eventsResult.success) {
|
|
2661
4046
|
setEvents(eventsResult.data.data);
|
|
2662
4047
|
}
|
|
2663
4048
|
}).catch((err) => {
|
|
2664
|
-
console.error("Failed to fetch
|
|
4049
|
+
console.error("Failed to fetch events:", err);
|
|
2665
4050
|
}).finally(() => {
|
|
2666
|
-
|
|
4051
|
+
setEventsLoading(false);
|
|
2667
4052
|
});
|
|
2668
4053
|
}, [env, runId]);
|
|
2669
4054
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -2673,7 +4058,8 @@ function RunActionsDropdownContentInner({
|
|
|
2673
4058
|
runId,
|
|
2674
4059
|
runStatus: status,
|
|
2675
4060
|
events,
|
|
2676
|
-
eventsLoading
|
|
4061
|
+
eventsLoading,
|
|
4062
|
+
replayDisabledReason: getRunReplayDisabledReason(run, runIdentityLoading),
|
|
2677
4063
|
stopPropagation: true,
|
|
2678
4064
|
callbacks: { onSuccess }
|
|
2679
4065
|
}
|
|
@@ -2715,6 +4101,20 @@ const statusMap = {
|
|
|
2715
4101
|
failed: { label: "Failed", color: "bg-red-600 dark:bg-red-400" },
|
|
2716
4102
|
cancelled: { label: "Cancelled", color: "bg-gray-600 dark:bg-gray-400" }
|
|
2717
4103
|
};
|
|
4104
|
+
const HOUR_MS = 60 * 60 * 1e3;
|
|
4105
|
+
const DAY_MS = 24 * HOUR_MS;
|
|
4106
|
+
const PERIOD_PRESETS = [
|
|
4107
|
+
{ id: "1h", label: "Last hour", ms: HOUR_MS },
|
|
4108
|
+
{ id: "6h", label: "Last 6 hours", ms: 6 * HOUR_MS },
|
|
4109
|
+
{ id: "24h", label: "Last 24 hours", ms: DAY_MS },
|
|
4110
|
+
{ id: "3d", label: "Last 3 days", ms: 3 * DAY_MS },
|
|
4111
|
+
{ id: "7d", label: "Last 7 days", ms: 7 * DAY_MS },
|
|
4112
|
+
{ id: "30d", label: "Last 30 days", ms: 30 * DAY_MS }
|
|
4113
|
+
];
|
|
4114
|
+
const DEFAULT_PERIOD = "24h";
|
|
4115
|
+
function isPeriodId(value) {
|
|
4116
|
+
return PERIOD_PRESETS.some((preset2) => preset2.id === value);
|
|
4117
|
+
}
|
|
2718
4118
|
function useWorkflowFilter() {
|
|
2719
4119
|
const navigate = useNavigate();
|
|
2720
4120
|
const { pathname } = useLocation();
|
|
@@ -2750,15 +4150,36 @@ function useStatusFilter() {
|
|
|
2750
4150
|
[navigate, pathname, searchParams]
|
|
2751
4151
|
);
|
|
2752
4152
|
}
|
|
4153
|
+
function usePeriodFilter() {
|
|
4154
|
+
const navigate = useNavigate();
|
|
4155
|
+
const { pathname } = useLocation();
|
|
4156
|
+
const [searchParams] = useSearchParams();
|
|
4157
|
+
return reactExports.useCallback(
|
|
4158
|
+
(value) => {
|
|
4159
|
+
const params = new URLSearchParams(searchParams.toString());
|
|
4160
|
+
if (value === DEFAULT_PERIOD) {
|
|
4161
|
+
params.delete("period");
|
|
4162
|
+
} else {
|
|
4163
|
+
params.set("period", value);
|
|
4164
|
+
}
|
|
4165
|
+
navigate(`${pathname}?${params.toString()}`);
|
|
4166
|
+
},
|
|
4167
|
+
[navigate, pathname, searchParams]
|
|
4168
|
+
);
|
|
4169
|
+
}
|
|
2753
4170
|
function FilterControls({
|
|
2754
4171
|
workflowNameFilter,
|
|
2755
4172
|
status,
|
|
2756
4173
|
seenWorkflowNames,
|
|
2757
4174
|
sortOrder,
|
|
2758
4175
|
loading,
|
|
2759
|
-
|
|
4176
|
+
period,
|
|
4177
|
+
showPeriodPicker,
|
|
4178
|
+
planWindowMs,
|
|
4179
|
+
planUpgradeAvailable,
|
|
2760
4180
|
onWorkflowChange,
|
|
2761
4181
|
onStatusChange,
|
|
4182
|
+
onPeriodChange,
|
|
2762
4183
|
onSortToggle,
|
|
2763
4184
|
onRefresh,
|
|
2764
4185
|
lastRefreshTime
|
|
@@ -2776,6 +4197,35 @@ function FilterControls({
|
|
|
2776
4197
|
)
|
|
2777
4198
|
] }),
|
|
2778
4199
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
4200
|
+
showPeriodPicker && /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
4201
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4202
|
+
Select,
|
|
4203
|
+
{
|
|
4204
|
+
value: period,
|
|
4205
|
+
onValueChange: onPeriodChange,
|
|
4206
|
+
disabled: loading,
|
|
4207
|
+
children: [
|
|
4208
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { className: "w-[150px] h-9", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, { placeholder: "Time window" }) }),
|
|
4209
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectContent, { children: PERIOD_PRESETS.map((preset2) => {
|
|
4210
|
+
const beyondPlan = planWindowMs !== void 0 && preset2.ms > planWindowMs;
|
|
4211
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4212
|
+
SelectItem,
|
|
4213
|
+
{
|
|
4214
|
+
value: preset2.id,
|
|
4215
|
+
disabled: beyondPlan,
|
|
4216
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4217
|
+
preset2.label,
|
|
4218
|
+
beyondPlan && planUpgradeAvailable && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-muted-foreground", children: "Observability Plus" })
|
|
4219
|
+
] })
|
|
4220
|
+
},
|
|
4221
|
+
preset2.id
|
|
4222
|
+
);
|
|
4223
|
+
}) })
|
|
4224
|
+
]
|
|
4225
|
+
}
|
|
4226
|
+
) }) }),
|
|
4227
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: planUpgradeAvailable ? "Time window for the runs list. Longer windows require Observability Plus." : "Time window for the runs list" })
|
|
4228
|
+
] }),
|
|
2779
4229
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
2780
4230
|
Select,
|
|
2781
4231
|
{
|
|
@@ -2800,7 +4250,7 @@ function FilterControls({
|
|
|
2800
4250
|
{
|
|
2801
4251
|
value: status || "all",
|
|
2802
4252
|
onValueChange: onStatusChange,
|
|
2803
|
-
disabled: loading
|
|
4253
|
+
disabled: loading,
|
|
2804
4254
|
children: [
|
|
2805
4255
|
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { className: "w-[140px] h-9", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, { placeholder: "Filter by status" }) }),
|
|
2806
4256
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(SelectContent, { children: [
|
|
@@ -2820,7 +4270,7 @@ function FilterControls({
|
|
|
2820
4270
|
]
|
|
2821
4271
|
}
|
|
2822
4272
|
) }) }),
|
|
2823
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children:
|
|
4273
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: "Filter runs by status" })
|
|
2824
4274
|
] }),
|
|
2825
4275
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
2826
4276
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
@@ -2858,7 +4308,7 @@ function FilterControls({
|
|
|
2858
4308
|
] });
|
|
2859
4309
|
}
|
|
2860
4310
|
function RunsTable({ onRunClick }) {
|
|
2861
|
-
var _a, _b, _c
|
|
4311
|
+
var _a, _b, _c;
|
|
2862
4312
|
const [searchParams] = useSearchParams();
|
|
2863
4313
|
const handleWorkflowFilter = useWorkflowFilter();
|
|
2864
4314
|
const handleStatusFilter = useStatusFilter();
|
|
@@ -2867,6 +4317,10 @@ function RunsTable({ onRunClick }) {
|
|
|
2867
4317
|
const validStatuses = Object.keys(statusMap);
|
|
2868
4318
|
const status = rawStatus === "all" || rawStatus && validStatuses.includes(rawStatus) ? rawStatus : void 0;
|
|
2869
4319
|
const workflowNameFilter = searchParams.get("workflow");
|
|
4320
|
+
const rawPeriod = searchParams.get("period");
|
|
4321
|
+
const period = isPeriodId(rawPeriod) ? rawPeriod : DEFAULT_PERIOD;
|
|
4322
|
+
const periodPreset = PERIOD_PRESETS.find((preset2) => preset2.id === period) ?? PERIOD_PRESETS[2];
|
|
4323
|
+
const handlePeriodFilter = usePeriodFilter();
|
|
2870
4324
|
const [sortOrder, setSortOrder] = reactExports.useState("desc");
|
|
2871
4325
|
const [lastRefreshTime, setLastRefreshTime] = reactExports.useState(
|
|
2872
4326
|
() => /* @__PURE__ */ new Date()
|
|
@@ -2876,35 +4330,62 @@ function RunsTable({ onRunClick }) {
|
|
|
2876
4330
|
const isLocal = serverConfig.backendId === "local" || serverConfig.backendId === "@workflow/world-local";
|
|
2877
4331
|
const localDataDirPath = (_a = serverConfig.displayInfo) == null ? void 0 : _a["local.dataDirPath"];
|
|
2878
4332
|
const localShortName = (_b = serverConfig.displayInfo) == null ? void 0 : _b["local.shortName"];
|
|
2879
|
-
const statusFilterRequiresWorkflowNameFilter = ((_c = serverConfig.backendId) == null ? void 0 : _c.includes("vercel")) || false;
|
|
2880
4333
|
const [seenWorkflowNames, setSeenWorkflowNames] = reactExports.useState(
|
|
2881
4334
|
/* @__PURE__ */ new Set()
|
|
2882
4335
|
);
|
|
4336
|
+
const isVercelBackend = ((_c = serverConfig.backendId) == null ? void 0 : _c.includes("vercel")) ?? false;
|
|
4337
|
+
const [listingWindow, setListingWindow] = reactExports.useState(
|
|
4338
|
+
() => isVercelBackend ? getListingWindow(period, periodPreset.ms) : void 0
|
|
4339
|
+
);
|
|
4340
|
+
reactExports.useEffect(() => {
|
|
4341
|
+
setListingWindow(
|
|
4342
|
+
isVercelBackend ? getListingWindow(period, periodPreset.ms) : void 0
|
|
4343
|
+
);
|
|
4344
|
+
}, [isVercelBackend, period, periodPreset.ms]);
|
|
4345
|
+
const refreshListingWindow = reactExports.useCallback(() => {
|
|
4346
|
+
if (isVercelBackend) {
|
|
4347
|
+
setListingWindow(advanceListingWindow(period, periodPreset.ms));
|
|
4348
|
+
}
|
|
4349
|
+
}, [isVercelBackend, period, periodPreset.ms]);
|
|
2883
4350
|
const {
|
|
2884
|
-
|
|
4351
|
+
items: runs,
|
|
2885
4352
|
error,
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
4353
|
+
isLoading,
|
|
4354
|
+
isLoadingMore,
|
|
4355
|
+
hasMore,
|
|
4356
|
+
loadMore,
|
|
2890
4357
|
reload,
|
|
2891
4358
|
refresh,
|
|
2892
|
-
pageInfo
|
|
2893
|
-
} =
|
|
4359
|
+
pageInfo: analyticsPageInfo
|
|
4360
|
+
} = useWorkflowRunsInfinite(env, {
|
|
2894
4361
|
sortOrder,
|
|
2895
4362
|
workflowName: workflowNameFilter === "all" ? void 0 : workflowNameFilter,
|
|
2896
|
-
status: status === "all" ? void 0 : status
|
|
4363
|
+
status: status === "all" ? void 0 : status,
|
|
4364
|
+
startTime: listingWindow == null ? void 0 : listingWindow.startTime,
|
|
4365
|
+
endTime: listingWindow == null ? void 0 : listingWindow.endTime
|
|
4366
|
+
});
|
|
4367
|
+
const [planInfo, setPlanInfo] = reactExports.useState(void 0);
|
|
4368
|
+
reactExports.useEffect(() => {
|
|
4369
|
+
if (analyticsPageInfo) {
|
|
4370
|
+
setPlanInfo(analyticsPageInfo);
|
|
4371
|
+
}
|
|
4372
|
+
}, [analyticsPageInfo]);
|
|
4373
|
+
const planWindowMs = planInfo !== void 0 ? planInfo.currentLookbackDays * DAY_MS : void 0;
|
|
4374
|
+
const [scrollRoot, setScrollRoot] = reactExports.useState(null);
|
|
4375
|
+
const sentinelRef = useLoadMoreOnScroll(loadMore, {
|
|
4376
|
+
hasMore,
|
|
4377
|
+
isLoadingMore,
|
|
4378
|
+
root: scrollRoot
|
|
2897
4379
|
});
|
|
2898
4380
|
const selection = useTableSelection({
|
|
2899
4381
|
getItemId: (run) => run.runId
|
|
2900
4382
|
});
|
|
2901
|
-
const runs = data.data ?? [];
|
|
2902
4383
|
const [isBulkCancelling, setIsBulkCancelling] = reactExports.useState(false);
|
|
2903
4384
|
const [isBulkReenqueuing, setIsBulkReenqueuing] = reactExports.useState(false);
|
|
2904
|
-
const isLocalAndHasMissingData = isLocal && (!localDataDirPath || !
|
|
4385
|
+
const isLocalAndHasMissingData = isLocal && (!localDataDirPath || !runs.length);
|
|
2905
4386
|
reactExports.useEffect(() => {
|
|
2906
|
-
if (
|
|
2907
|
-
const newNames = new Set(
|
|
4387
|
+
if (runs.length > 0) {
|
|
4388
|
+
const newNames = new Set(runs.map((run) => run.workflowName));
|
|
2908
4389
|
setSeenWorkflowNames((prev) => {
|
|
2909
4390
|
const updated = new Set(prev);
|
|
2910
4391
|
for (const name of newNames) {
|
|
@@ -2913,8 +4394,8 @@ function RunsTable({ onRunClick }) {
|
|
|
2913
4394
|
return updated;
|
|
2914
4395
|
});
|
|
2915
4396
|
}
|
|
2916
|
-
}, [
|
|
2917
|
-
const loading =
|
|
4397
|
+
}, [runs]);
|
|
4398
|
+
const loading = isLoading;
|
|
2918
4399
|
reactExports.useEffect(() => {
|
|
2919
4400
|
if (!loading && !hasLoadedOnce) {
|
|
2920
4401
|
setHasLoadedOnce(true);
|
|
@@ -2926,12 +4407,14 @@ function RunsTable({ onRunClick }) {
|
|
|
2926
4407
|
const onReload = reactExports.useCallback(() => {
|
|
2927
4408
|
setLastRefreshTime(() => /* @__PURE__ */ new Date());
|
|
2928
4409
|
setHasLoadedOnce(false);
|
|
4410
|
+
refreshListingWindow();
|
|
2929
4411
|
reload();
|
|
2930
|
-
}, [reload]);
|
|
4412
|
+
}, [reload, refreshListingWindow]);
|
|
2931
4413
|
const onRefresh = reactExports.useCallback(() => {
|
|
2932
4414
|
setLastRefreshTime(() => /* @__PURE__ */ new Date());
|
|
4415
|
+
refreshListingWindow();
|
|
2933
4416
|
refresh();
|
|
2934
|
-
}, [refresh]);
|
|
4417
|
+
}, [refresh, refreshListingWindow]);
|
|
2935
4418
|
const selectedRuns = reactExports.useMemo(() => {
|
|
2936
4419
|
return runs.filter((run) => selection.selectedIds.has(run.runId));
|
|
2937
4420
|
}, [runs, selection.selectedIds]);
|
|
@@ -2941,27 +4424,39 @@ function RunsTable({ onRunClick }) {
|
|
|
2941
4424
|
);
|
|
2942
4425
|
}, [selectedRuns]);
|
|
2943
4426
|
const hasCancellableSelection = cancellableSelectedRuns.length > 0;
|
|
4427
|
+
const exceedsBulkCancelLimit = cancellableSelectedRuns.length > BULK_CANCEL_MAX_RUN_IDS;
|
|
2944
4428
|
const handleBulkCancel = reactExports.useCallback(async () => {
|
|
2945
|
-
if (isBulkCancelling || cancellableSelectedRuns.length === 0)
|
|
4429
|
+
if (isBulkCancelling || cancellableSelectedRuns.length === 0 || cancellableSelectedRuns.length > BULK_CANCEL_MAX_RUN_IDS) {
|
|
4430
|
+
return;
|
|
4431
|
+
}
|
|
2946
4432
|
setIsBulkCancelling(true);
|
|
2947
4433
|
try {
|
|
2948
|
-
const results = await
|
|
2949
|
-
|
|
4434
|
+
const { summary, results } = await bulkCancelRuns(
|
|
4435
|
+
env,
|
|
4436
|
+
cancellableSelectedRuns.map((run) => run.runId)
|
|
2950
4437
|
);
|
|
2951
|
-
const
|
|
2952
|
-
|
|
2953
|
-
if (
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
);
|
|
2957
|
-
|
|
2958
|
-
|
|
4438
|
+
const parts = [];
|
|
4439
|
+
if (summary.cancelled > 0) parts.push(`${summary.cancelled} cancelled`);
|
|
4440
|
+
if (summary.alreadyCancelled > 0)
|
|
4441
|
+
parts.push(`${summary.alreadyCancelled} already cancelled`);
|
|
4442
|
+
if (summary.notCancellable > 0)
|
|
4443
|
+
parts.push(`${summary.notCancellable} not cancellable`);
|
|
4444
|
+
if (summary.notFound > 0) parts.push(`${summary.notFound} not found`);
|
|
4445
|
+
if (summary.failed > 0) parts.push(`${summary.failed} failed`);
|
|
4446
|
+
const message = parts.join(", ") || "No runs cancelled";
|
|
4447
|
+
const severity = bulkCancelToastSeverity(summary);
|
|
4448
|
+
if (severity === "error") {
|
|
4449
|
+
toast.error(message);
|
|
4450
|
+
} else if (severity === "warning") {
|
|
4451
|
+
toast.warning(message);
|
|
2959
4452
|
} else {
|
|
2960
|
-
toast.
|
|
2961
|
-
|
|
2962
|
-
|
|
4453
|
+
toast.success(message);
|
|
4454
|
+
}
|
|
4455
|
+
for (const result of results) {
|
|
4456
|
+
if (!shouldRetainSelectionAfterBulkCancel(result)) {
|
|
4457
|
+
selection.deselectById(result.runId);
|
|
4458
|
+
}
|
|
2963
4459
|
}
|
|
2964
|
-
selection.clearSelection();
|
|
2965
4460
|
onReload();
|
|
2966
4461
|
} catch (err) {
|
|
2967
4462
|
toast.error("Failed to cancel runs", {
|
|
@@ -3038,120 +4533,122 @@ function RunsTable({ onRunClick }) {
|
|
|
3038
4533
|
seenWorkflowNames,
|
|
3039
4534
|
sortOrder,
|
|
3040
4535
|
loading,
|
|
3041
|
-
|
|
4536
|
+
period,
|
|
4537
|
+
showPeriodPicker: isVercelBackend,
|
|
4538
|
+
planWindowMs,
|
|
4539
|
+
planUpgradeAvailable: (planInfo == null ? void 0 : planInfo.upgradeAvailable) ?? false,
|
|
3042
4540
|
onWorkflowChange: handleWorkflowFilter,
|
|
3043
4541
|
onStatusChange: handleStatusFilter,
|
|
4542
|
+
onPeriodChange: handlePeriodFilter,
|
|
3044
4543
|
onSortToggle: toggleSortOrder,
|
|
3045
4544
|
onRefresh: onReload,
|
|
3046
4545
|
lastRefreshTime
|
|
3047
4546
|
}
|
|
3048
4547
|
),
|
|
3049
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "overflow-hidden mt-4 bg-background", children: /* @__PURE__ */ jsxRuntimeExports.
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
disabled: !runs.length
|
|
3059
|
-
}
|
|
3060
|
-
) }),
|
|
3061
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { className: "sticky top-0 bg-background z-10 border-b shadow-sm h-10", children: "Workflow" }),
|
|
3062
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { className: "sticky top-0 bg-background z-10 border-b shadow-sm h-10", children: "Run ID" }),
|
|
3063
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { className: "sticky top-0 bg-background z-10 border-b shadow-sm h-10", children: "Status" }),
|
|
3064
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { className: "sticky top-0 bg-background z-10 border-b shadow-sm h-10", children: "Started" }),
|
|
3065
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { className: "sticky top-0 bg-background z-10 border-b shadow-sm h-10", children: "Completed" }),
|
|
3066
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { className: "sticky top-0 bg-background z-10 border-b shadow-sm h-10 w-10" })
|
|
3067
|
-
] }) }),
|
|
3068
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TableBody, { children: error ? /* @__PURE__ */ jsxRuntimeExports.jsx(TableRow, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { colSpan: 7, className: "h-[400px]", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Alert, { variant: "destructive", className: "max-w-md", children: [
|
|
3069
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(CircleAlert, { className: "h-4 w-4" }),
|
|
3070
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(AlertTitle, { children: "Error loading runs" }),
|
|
3071
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(AlertDescription, { children: getErrorMessage(error) })
|
|
3072
|
-
] }) }) }) }) : loading && !hasLoadedOnce ? /* @__PURE__ */ jsxRuntimeExports.jsx(TableRow, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { colSpan: 7, className: "h-[400px]", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(LoaderCircle, { className: "h-8 w-8 animate-spin text-muted-foreground" }) }) }) }) : !data.data || data.data.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(TableRow, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { colSpan: 7, className: "h-[400px]", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-sm text-center text-muted-foreground flex flex-col items-center justify-center gap-3 h-full", children: [
|
|
3073
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-sm", children: [
|
|
3074
|
-
"No workflow runs found",
|
|
3075
|
-
isLocalAndHasMissingData ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3076
|
-
" in ",
|
|
3077
|
-
localDirText
|
|
3078
|
-
] }) : "",
|
|
3079
|
-
"."
|
|
3080
|
-
] }),
|
|
3081
|
-
isLocalAndHasMissingData && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm flex items-center gap-2", children: "This view will update once you run a workflow." })
|
|
3082
|
-
] }) }) }) : runs.map((run) => {
|
|
3083
|
-
var _a2;
|
|
3084
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
3085
|
-
TableRow,
|
|
3086
|
-
{
|
|
3087
|
-
className: "cursor-pointer group relative",
|
|
3088
|
-
onClick: () => onRunClick(run.runId),
|
|
3089
|
-
"data-selected": selection.isSelected(run),
|
|
3090
|
-
children: [
|
|
3091
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4548
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "overflow-hidden mt-4 bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4549
|
+
CardContent,
|
|
4550
|
+
{
|
|
4551
|
+
ref: setScrollRoot,
|
|
4552
|
+
className: "p-0 max-h-[calc(100vh-280px)] overflow-auto",
|
|
4553
|
+
children: [
|
|
4554
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Table, { children: [
|
|
4555
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableHeader, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(TableRow, { children: [
|
|
4556
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { className: "sticky top-0 bg-background z-10 border-b shadow-sm h-10 w-10", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3092
4557
|
Checkbox,
|
|
3093
4558
|
{
|
|
3094
|
-
checked: selection.
|
|
3095
|
-
|
|
3096
|
-
|
|
4559
|
+
checked: selection.isAllSelected(runs),
|
|
4560
|
+
indeterminate: selection.isSomeSelected(runs),
|
|
4561
|
+
onCheckedChange: () => selection.toggleSelectAll(runs),
|
|
4562
|
+
"aria-label": "Select all runs",
|
|
4563
|
+
disabled: !runs.length
|
|
3097
4564
|
}
|
|
3098
4565
|
) }),
|
|
3099
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3100
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3101
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
4566
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { className: "sticky top-0 bg-background z-10 border-b shadow-sm h-10", children: "Workflow" }),
|
|
4567
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { className: "sticky top-0 bg-background z-10 border-b shadow-sm h-10", children: "Run ID" }),
|
|
4568
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { className: "sticky top-0 bg-background z-10 border-b shadow-sm h-10", children: "Status" }),
|
|
4569
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { className: "sticky top-0 bg-background z-10 border-b shadow-sm h-10", children: "Started" }),
|
|
4570
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { className: "sticky top-0 bg-background z-10 border-b shadow-sm h-10", children: "Completed" }),
|
|
4571
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { className: "sticky top-0 bg-background z-10 border-b shadow-sm h-10 w-10" })
|
|
4572
|
+
] }) }),
|
|
4573
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(TableBody, { children: [
|
|
4574
|
+
error ? /* @__PURE__ */ jsxRuntimeExports.jsx(TableRow, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { colSpan: 7, className: "h-[400px]", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Alert, { variant: "destructive", className: "max-w-md", children: [
|
|
4575
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CircleAlert, { className: "h-4 w-4" }),
|
|
4576
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(AlertTitle, { children: getErrorTitle(error, "Error loading runs") }),
|
|
4577
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(AlertDescription, { children: getErrorMessage(error) })
|
|
4578
|
+
] }) }) }) }) : loading && !hasLoadedOnce ? /* @__PURE__ */ jsxRuntimeExports.jsx(TableRow, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { colSpan: 7, className: "h-[400px]", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(LoaderCircle, { className: "h-8 w-8 animate-spin text-muted-foreground" }) }) }) }) : runs.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(TableRow, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { colSpan: 7, className: "h-[400px]", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-sm text-center text-muted-foreground flex flex-col items-center justify-center gap-3 h-full", children: [
|
|
4579
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-sm", children: [
|
|
4580
|
+
"No workflow runs found",
|
|
4581
|
+
isLocalAndHasMissingData ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
4582
|
+
" in ",
|
|
4583
|
+
localDirText
|
|
4584
|
+
] }) : "",
|
|
4585
|
+
"."
|
|
4586
|
+
] }),
|
|
4587
|
+
isLocalAndHasMissingData && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm flex items-center gap-2", children: "This view will update once you run a workflow." })
|
|
4588
|
+
] }) }) }) : runs.map((run) => {
|
|
4589
|
+
var _a2;
|
|
4590
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4591
|
+
TableRow,
|
|
4592
|
+
{
|
|
4593
|
+
className: "cursor-pointer group relative",
|
|
4594
|
+
onClick: () => onRunClick(run.runId),
|
|
4595
|
+
"data-selected": selection.isSelected(run),
|
|
4596
|
+
children: [
|
|
4597
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4598
|
+
Checkbox,
|
|
4599
|
+
{
|
|
4600
|
+
checked: selection.isSelected(run),
|
|
4601
|
+
onCheckedChange: () => selection.toggleSelection(run),
|
|
4602
|
+
"aria-label": `Select run ${run.runId}`
|
|
4603
|
+
}
|
|
4604
|
+
) }),
|
|
4605
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyableText, { text: run.workflowName, overlay: true, children: ((_a2 = parseWorkflowName(run.workflowName)) == null ? void 0 : _a2.shortName) || "?" }) }),
|
|
4606
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "font-mono text-xs py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyableText, { text: run.runId, overlay: true, children: run.runId }) }),
|
|
4607
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4608
|
+
StatusBadge,
|
|
4609
|
+
{
|
|
4610
|
+
status: run.status,
|
|
4611
|
+
context: run,
|
|
4612
|
+
durationMs: run.startedAt ? (run.completedAt ? new Date(run.completedAt).getTime() : Date.now()) - new Date(run.startedAt).getTime() : void 0
|
|
4613
|
+
}
|
|
4614
|
+
) }),
|
|
4615
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "py-2 text-muted-foreground text-xs", children: run.startedAt ? /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run.startedAt }) : "-" }),
|
|
4616
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "py-2 text-muted-foreground text-xs", children: run.completedAt ? /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run.completedAt }) : "-" }),
|
|
4617
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { className: "py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4618
|
+
LazyDropdownMenu,
|
|
4619
|
+
{
|
|
4620
|
+
env,
|
|
4621
|
+
runId: run.runId,
|
|
4622
|
+
runStatus: run.status,
|
|
4623
|
+
onSuccess: onReload
|
|
4624
|
+
}
|
|
4625
|
+
) })
|
|
4626
|
+
]
|
|
4627
|
+
},
|
|
4628
|
+
run.runId
|
|
4629
|
+
);
|
|
4630
|
+
}),
|
|
4631
|
+
isLoadingMore && /* @__PURE__ */ jsxRuntimeExports.jsx(TableRow, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { colSpan: 7, className: "py-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-center gap-2 text-sm text-muted-foreground", children: [
|
|
4632
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(LoaderCircle, { className: "h-4 w-4 animate-spin" }),
|
|
4633
|
+
"Loading more runs…"
|
|
4634
|
+
] }) }) })
|
|
4635
|
+
] })
|
|
4636
|
+
] }),
|
|
4637
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: sentinelRef, "aria-hidden": true, className: "h-px" })
|
|
4638
|
+
]
|
|
4639
|
+
}
|
|
4640
|
+
) }),
|
|
4641
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mt-4 text-sm text-muted-foreground", children: [
|
|
4642
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: runs.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
4643
|
+
"Showing ",
|
|
4644
|
+
runs.length,
|
|
4645
|
+
" run",
|
|
4646
|
+
runs.length === 1 ? "" : "s",
|
|
4647
|
+
!hasMore && !loading ? " · end of list" : ""
|
|
4648
|
+
] }) }),
|
|
4649
|
+
isVercelBackend && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
4650
|
+
periodPreset.label,
|
|
4651
|
+
(planInfo == null ? void 0 : planInfo.upgradeAvailable) ? ` · plan window ${planInfo.currentLookbackDays} day${planInfo.currentLookbackDays === 1 ? "" : "s"}` : ""
|
|
3155
4652
|
] })
|
|
3156
4653
|
] }),
|
|
3157
4654
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -3178,23 +4675,26 @@ function RunsTable({ onRunClick }) {
|
|
|
3178
4675
|
) }),
|
|
3179
4676
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: "Re-enqueue the workflow orchestration layer for selected runs. Useful if workflows appear stuck." })
|
|
3180
4677
|
] }),
|
|
3181
|
-
hasCancellableSelection && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
4678
|
+
hasCancellableSelection && /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
4679
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4680
|
+
Button,
|
|
4681
|
+
{
|
|
4682
|
+
variant: "ghost",
|
|
4683
|
+
size: "sm",
|
|
4684
|
+
className: "h-7 text-primary-foreground hover:bg-primary-foreground/10 hover:text-primary-foreground",
|
|
4685
|
+
onClick: handleBulkCancel,
|
|
4686
|
+
disabled: isBulkCancelling || exceedsBulkCancelLimit,
|
|
4687
|
+
children: [
|
|
4688
|
+
isBulkCancelling ? /* @__PURE__ */ jsxRuntimeExports.jsx(LoaderCircle, { className: "h-4 w-4 mr-1 animate-spin" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(CircleX, { className: "h-4 w-4 mr-1" }),
|
|
4689
|
+
"Cancel",
|
|
4690
|
+
" ",
|
|
4691
|
+
cancellableSelectedRuns.length !== selection.selectionCount ? `${cancellableSelectedRuns.length} ` : "",
|
|
4692
|
+
isBulkCancelling ? "cancelling..." : ""
|
|
4693
|
+
]
|
|
4694
|
+
}
|
|
4695
|
+
) }) }),
|
|
4696
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: exceedsBulkCancelLimit ? `Select up to ${BULK_CANCEL_MAX_RUN_IDS} runs at a time.` : "Cancel the selected pending and running runs." })
|
|
4697
|
+
] })
|
|
3198
4698
|
] })
|
|
3199
4699
|
}
|
|
3200
4700
|
)
|