@calimero-network/mero-react 2.5.0 → 2.6.1
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 +93 -32
- 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 +94 -34
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2107,39 +2107,42 @@ function useMemberMetadata(groupId, identity) {
|
|
|
2107
2107
|
const [metadata, setMetadata] = react.useState(null);
|
|
2108
2108
|
const [loading, setLoading] = react.useState(false);
|
|
2109
2109
|
const [error, setError] = react.useState(null);
|
|
2110
|
-
const
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
}
|
|
2120
|
-
if (mountedRef.current) {
|
|
2121
|
-
setLoading(true);
|
|
2122
|
-
setError(null);
|
|
2123
|
-
}
|
|
2124
|
-
try {
|
|
2125
|
-
const result = await mero.admin.getMemberMetadata(groupId, identity);
|
|
2126
|
-
if (mountedRef.current) {
|
|
2127
|
-
setMetadata(result);
|
|
2110
|
+
const run = react.useCallback(
|
|
2111
|
+
async (signal) => {
|
|
2112
|
+
if (!mero || !groupId || !identity) {
|
|
2113
|
+
if (!signal.aborted) {
|
|
2114
|
+
setMetadata(null);
|
|
2115
|
+
setError(null);
|
|
2116
|
+
setLoading(false);
|
|
2117
|
+
}
|
|
2118
|
+
return;
|
|
2128
2119
|
}
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
setError(errorValue);
|
|
2120
|
+
if (!signal.aborted) {
|
|
2121
|
+
setLoading(true);
|
|
2122
|
+
setError(null);
|
|
2133
2123
|
}
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2124
|
+
try {
|
|
2125
|
+
const result = await mero.admin.getMemberMetadata(groupId, identity);
|
|
2126
|
+
if (!signal.aborted) setMetadata(result);
|
|
2127
|
+
} catch (err) {
|
|
2128
|
+
if (!signal.aborted) setError(toError(err));
|
|
2129
|
+
} finally {
|
|
2130
|
+
if (!signal.aborted) setLoading(false);
|
|
2137
2131
|
}
|
|
2138
|
-
}
|
|
2139
|
-
|
|
2132
|
+
},
|
|
2133
|
+
[mero, groupId, identity]
|
|
2134
|
+
);
|
|
2140
2135
|
react.useEffect(() => {
|
|
2141
|
-
|
|
2142
|
-
|
|
2136
|
+
const signal = { aborted: false };
|
|
2137
|
+
void run(signal);
|
|
2138
|
+
return () => {
|
|
2139
|
+
signal.aborted = true;
|
|
2140
|
+
};
|
|
2141
|
+
}, [run]);
|
|
2142
|
+
const refetch = react.useCallback(async () => {
|
|
2143
|
+
const signal = { aborted: false };
|
|
2144
|
+
await run(signal);
|
|
2145
|
+
}, [run]);
|
|
2143
2146
|
return { metadata, loading, error, refetch };
|
|
2144
2147
|
}
|
|
2145
2148
|
function useRegisterGroupSigningKey() {
|
|
@@ -2352,6 +2355,8 @@ function useMigrationStatus(namespaceId, options) {
|
|
|
2352
2355
|
members,
|
|
2353
2356
|
allMigrated: rollup?.allMigrated ?? false,
|
|
2354
2357
|
membersPendingSignature: rollup?.membersPendingSignature ?? 0,
|
|
2358
|
+
/** Members whose migrate aborted (migration-check failed or apply errored). */
|
|
2359
|
+
failed: rollup?.failed ?? 0,
|
|
2355
2360
|
loading,
|
|
2356
2361
|
error,
|
|
2357
2362
|
refetch
|
|
@@ -2415,6 +2420,55 @@ function useAppVersion(contextId, expected) {
|
|
|
2415
2420
|
const isStale = appVersion != null && expected != null && appVersion !== expected;
|
|
2416
2421
|
return { appVersion, expected, isStale, loading, error, refetch };
|
|
2417
2422
|
}
|
|
2423
|
+
function useLatestVersion(registryUrl, packageName, currentVersion) {
|
|
2424
|
+
const { mero } = useMero();
|
|
2425
|
+
const [versions, setVersions] = react.useState([]);
|
|
2426
|
+
const [loading, setLoading] = react.useState(false);
|
|
2427
|
+
const [error, setError] = react.useState(null);
|
|
2428
|
+
const mountedRef = useMountedRef();
|
|
2429
|
+
const reqRef = react.useRef(0);
|
|
2430
|
+
const refetch = react.useCallback(async () => {
|
|
2431
|
+
if (!mero || !registryUrl || !packageName) {
|
|
2432
|
+
reqRef.current += 1;
|
|
2433
|
+
if (mountedRef.current) {
|
|
2434
|
+
setVersions([]);
|
|
2435
|
+
setError(null);
|
|
2436
|
+
setLoading(false);
|
|
2437
|
+
}
|
|
2438
|
+
return;
|
|
2439
|
+
}
|
|
2440
|
+
const seq = ++reqRef.current;
|
|
2441
|
+
if (mountedRef.current) {
|
|
2442
|
+
setLoading(true);
|
|
2443
|
+
setError(null);
|
|
2444
|
+
}
|
|
2445
|
+
try {
|
|
2446
|
+
const result = await mero.admin.getRegistryVersions(registryUrl, packageName);
|
|
2447
|
+
if (mountedRef.current && seq === reqRef.current) {
|
|
2448
|
+
setVersions(result);
|
|
2449
|
+
}
|
|
2450
|
+
} catch (err) {
|
|
2451
|
+
const errorValue = toError(err);
|
|
2452
|
+
if (mountedRef.current && seq === reqRef.current) {
|
|
2453
|
+
setError(errorValue);
|
|
2454
|
+
}
|
|
2455
|
+
} finally {
|
|
2456
|
+
if (mountedRef.current && seq === reqRef.current) {
|
|
2457
|
+
setLoading(false);
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
}, [mero, registryUrl, packageName, mountedRef]);
|
|
2461
|
+
react.useEffect(() => {
|
|
2462
|
+
setVersions([]);
|
|
2463
|
+
setError(null);
|
|
2464
|
+
}, [registryUrl, packageName]);
|
|
2465
|
+
react.useEffect(() => {
|
|
2466
|
+
void refetch();
|
|
2467
|
+
}, [refetch]);
|
|
2468
|
+
const latestVersion = versions[0] ?? null;
|
|
2469
|
+
const updateAvailable = latestVersion != null && currentVersion != null && meroJs.compareSemver(latestVersion, currentVersion) > 0;
|
|
2470
|
+
return { versions, latestVersion, currentVersion, updateAvailable, loading, error, refetch };
|
|
2471
|
+
}
|
|
2418
2472
|
function useMyAuthoredMigration(contextId) {
|
|
2419
2473
|
const { mero } = useMero();
|
|
2420
2474
|
const [summary, setSummary] = react.useState(null);
|
|
@@ -2478,7 +2532,7 @@ function MigrationPendingBanner({
|
|
|
2478
2532
|
] });
|
|
2479
2533
|
}
|
|
2480
2534
|
function MigrationAdminPanel({ namespaceId, pollIntervalMs, className }) {
|
|
2481
|
-
const { status, rollup, members, membersPendingSignature, error } = useMigrationStatus(
|
|
2535
|
+
const { status, rollup, members, membersPendingSignature, failed, error } = useMigrationStatus(
|
|
2482
2536
|
namespaceId,
|
|
2483
2537
|
{ pollIntervalMs }
|
|
2484
2538
|
);
|
|
@@ -2515,6 +2569,10 @@ function MigrationAdminPanel({ namespaceId, pollIntervalMs, className }) {
|
|
|
2515
2569
|
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: "Unknown" }),
|
|
2516
2570
|
/* @__PURE__ */ jsxRuntime.jsx("dd", { children: rollup.unknown })
|
|
2517
2571
|
] }),
|
|
2572
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2573
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: "Failed" }),
|
|
2574
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { "data-testid": "migration-failed-count", children: failed })
|
|
2575
|
+
] }),
|
|
2518
2576
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2519
2577
|
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: "Total" }),
|
|
2520
2578
|
/* @__PURE__ */ jsxRuntime.jsx("dd", { children: rollup.total })
|
|
@@ -2533,13 +2591,15 @@ function MigrationAdminPanel({ namespaceId, pollIntervalMs, className }) {
|
|
|
2533
2591
|
/* @__PURE__ */ jsxRuntime.jsx("th", { children: "Peer" }),
|
|
2534
2592
|
/* @__PURE__ */ jsxRuntime.jsx("th", { children: "State" }),
|
|
2535
2593
|
/* @__PURE__ */ jsxRuntime.jsx("th", { children: "Schema" }),
|
|
2536
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { children: "Pending" })
|
|
2594
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { children: "Pending" }),
|
|
2595
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { children: "Reason" })
|
|
2537
2596
|
] }) }),
|
|
2538
2597
|
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: members.map((m) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { "data-testid": "migration-member-row", children: [
|
|
2539
2598
|
/* @__PURE__ */ jsxRuntime.jsx("td", { children: m.peer }),
|
|
2540
2599
|
/* @__PURE__ */ jsxRuntime.jsx("td", { children: m.state }),
|
|
2541
2600
|
/* @__PURE__ */ jsxRuntime.jsx("td", { children: m.report?.schemaVersion ?? "\u2014" }),
|
|
2542
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { children: m.report?.authoredRemaining ?? "\u2014" })
|
|
2601
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: m.report?.authoredRemaining ?? "\u2014" }),
|
|
2602
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: m.report?.migrationFailed ?? "\u2014" })
|
|
2543
2603
|
] }, m.peer)) })
|
|
2544
2604
|
] })
|
|
2545
2605
|
] });
|
|
@@ -2616,6 +2676,7 @@ exports.useJoinContext = useJoinContext;
|
|
|
2616
2676
|
exports.useJoinGroup = useJoinGroup;
|
|
2617
2677
|
exports.useJoinNamespace = useJoinNamespace;
|
|
2618
2678
|
exports.useJoinSubgroupInheritance = useJoinSubgroupInheritance;
|
|
2679
|
+
exports.useLatestVersion = useLatestVersion;
|
|
2619
2680
|
exports.useMemberMetadata = useMemberMetadata;
|
|
2620
2681
|
exports.useMero = useMero;
|
|
2621
2682
|
exports.useMigrationStatus = useMigrationStatus;
|