@calimero-network/mero-react 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +61 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +62 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2352,6 +2352,8 @@ function useMigrationStatus(namespaceId, options) {
|
|
|
2352
2352
|
members,
|
|
2353
2353
|
allMigrated: rollup?.allMigrated ?? false,
|
|
2354
2354
|
membersPendingSignature: rollup?.membersPendingSignature ?? 0,
|
|
2355
|
+
/** Members whose migrate aborted (migration-check failed or apply errored). */
|
|
2356
|
+
failed: rollup?.failed ?? 0,
|
|
2355
2357
|
loading,
|
|
2356
2358
|
error,
|
|
2357
2359
|
refetch
|
|
@@ -2415,6 +2417,55 @@ function useAppVersion(contextId, expected) {
|
|
|
2415
2417
|
const isStale = appVersion != null && expected != null && appVersion !== expected;
|
|
2416
2418
|
return { appVersion, expected, isStale, loading, error, refetch };
|
|
2417
2419
|
}
|
|
2420
|
+
function useLatestVersion(registryUrl, packageName, currentVersion) {
|
|
2421
|
+
const { mero } = useMero();
|
|
2422
|
+
const [versions, setVersions] = react.useState([]);
|
|
2423
|
+
const [loading, setLoading] = react.useState(false);
|
|
2424
|
+
const [error, setError] = react.useState(null);
|
|
2425
|
+
const mountedRef = useMountedRef();
|
|
2426
|
+
const reqRef = react.useRef(0);
|
|
2427
|
+
const refetch = react.useCallback(async () => {
|
|
2428
|
+
if (!mero || !registryUrl || !packageName) {
|
|
2429
|
+
reqRef.current += 1;
|
|
2430
|
+
if (mountedRef.current) {
|
|
2431
|
+
setVersions([]);
|
|
2432
|
+
setError(null);
|
|
2433
|
+
setLoading(false);
|
|
2434
|
+
}
|
|
2435
|
+
return;
|
|
2436
|
+
}
|
|
2437
|
+
const seq = ++reqRef.current;
|
|
2438
|
+
if (mountedRef.current) {
|
|
2439
|
+
setLoading(true);
|
|
2440
|
+
setError(null);
|
|
2441
|
+
}
|
|
2442
|
+
try {
|
|
2443
|
+
const result = await mero.admin.getRegistryVersions(registryUrl, packageName);
|
|
2444
|
+
if (mountedRef.current && seq === reqRef.current) {
|
|
2445
|
+
setVersions(result);
|
|
2446
|
+
}
|
|
2447
|
+
} catch (err) {
|
|
2448
|
+
const errorValue = toError(err);
|
|
2449
|
+
if (mountedRef.current && seq === reqRef.current) {
|
|
2450
|
+
setError(errorValue);
|
|
2451
|
+
}
|
|
2452
|
+
} finally {
|
|
2453
|
+
if (mountedRef.current && seq === reqRef.current) {
|
|
2454
|
+
setLoading(false);
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
}, [mero, registryUrl, packageName, mountedRef]);
|
|
2458
|
+
react.useEffect(() => {
|
|
2459
|
+
setVersions([]);
|
|
2460
|
+
setError(null);
|
|
2461
|
+
}, [registryUrl, packageName]);
|
|
2462
|
+
react.useEffect(() => {
|
|
2463
|
+
void refetch();
|
|
2464
|
+
}, [refetch]);
|
|
2465
|
+
const latestVersion = versions[0] ?? null;
|
|
2466
|
+
const updateAvailable = latestVersion != null && currentVersion != null && meroJs.compareSemver(latestVersion, currentVersion) > 0;
|
|
2467
|
+
return { versions, latestVersion, currentVersion, updateAvailable, loading, error, refetch };
|
|
2468
|
+
}
|
|
2418
2469
|
function useMyAuthoredMigration(contextId) {
|
|
2419
2470
|
const { mero } = useMero();
|
|
2420
2471
|
const [summary, setSummary] = react.useState(null);
|
|
@@ -2478,7 +2529,7 @@ function MigrationPendingBanner({
|
|
|
2478
2529
|
] });
|
|
2479
2530
|
}
|
|
2480
2531
|
function MigrationAdminPanel({ namespaceId, pollIntervalMs, className }) {
|
|
2481
|
-
const { status, rollup, members, membersPendingSignature, error } = useMigrationStatus(
|
|
2532
|
+
const { status, rollup, members, membersPendingSignature, failed, error } = useMigrationStatus(
|
|
2482
2533
|
namespaceId,
|
|
2483
2534
|
{ pollIntervalMs }
|
|
2484
2535
|
);
|
|
@@ -2515,6 +2566,10 @@ function MigrationAdminPanel({ namespaceId, pollIntervalMs, className }) {
|
|
|
2515
2566
|
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: "Unknown" }),
|
|
2516
2567
|
/* @__PURE__ */ jsxRuntime.jsx("dd", { children: rollup.unknown })
|
|
2517
2568
|
] }),
|
|
2569
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2570
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: "Failed" }),
|
|
2571
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { "data-testid": "migration-failed-count", children: failed })
|
|
2572
|
+
] }),
|
|
2518
2573
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2519
2574
|
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: "Total" }),
|
|
2520
2575
|
/* @__PURE__ */ jsxRuntime.jsx("dd", { children: rollup.total })
|
|
@@ -2533,13 +2588,15 @@ function MigrationAdminPanel({ namespaceId, pollIntervalMs, className }) {
|
|
|
2533
2588
|
/* @__PURE__ */ jsxRuntime.jsx("th", { children: "Peer" }),
|
|
2534
2589
|
/* @__PURE__ */ jsxRuntime.jsx("th", { children: "State" }),
|
|
2535
2590
|
/* @__PURE__ */ jsxRuntime.jsx("th", { children: "Schema" }),
|
|
2536
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { children: "Pending" })
|
|
2591
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { children: "Pending" }),
|
|
2592
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { children: "Reason" })
|
|
2537
2593
|
] }) }),
|
|
2538
2594
|
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: members.map((m) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { "data-testid": "migration-member-row", children: [
|
|
2539
2595
|
/* @__PURE__ */ jsxRuntime.jsx("td", { children: m.peer }),
|
|
2540
2596
|
/* @__PURE__ */ jsxRuntime.jsx("td", { children: m.state }),
|
|
2541
2597
|
/* @__PURE__ */ jsxRuntime.jsx("td", { children: m.report?.schemaVersion ?? "\u2014" }),
|
|
2542
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { children: m.report?.authoredRemaining ?? "\u2014" })
|
|
2598
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: m.report?.authoredRemaining ?? "\u2014" }),
|
|
2599
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: m.report?.migrationFailed ?? "\u2014" })
|
|
2543
2600
|
] }, m.peer)) })
|
|
2544
2601
|
] })
|
|
2545
2602
|
] });
|
|
@@ -2616,6 +2673,7 @@ exports.useJoinContext = useJoinContext;
|
|
|
2616
2673
|
exports.useJoinGroup = useJoinGroup;
|
|
2617
2674
|
exports.useJoinNamespace = useJoinNamespace;
|
|
2618
2675
|
exports.useJoinSubgroupInheritance = useJoinSubgroupInheritance;
|
|
2676
|
+
exports.useLatestVersion = useLatestVersion;
|
|
2619
2677
|
exports.useMemberMetadata = useMemberMetadata;
|
|
2620
2678
|
exports.useMero = useMero;
|
|
2621
2679
|
exports.useMigrationStatus = useMigrationStatus;
|