@calimero-network/mero-react 2.2.1 → 2.4.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 +4 -2
- package/dist/index.cjs +216 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -6
- package/dist/index.d.ts +48 -6
- package/dist/index.js +194 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -351,8 +351,10 @@ useJoinGroup, useDeleteGroup, useAddGroupMembers, useRemoveGroupMembers
|
|
|
351
351
|
useSyncGroup, useNestGroup, useUnnestGroup, useSubgroups
|
|
352
352
|
useUpgradeGroup, useGroupUpgradeStatus, useRetryGroupUpgrade
|
|
353
353
|
useRegisterGroupSigningKey, useUpdateGroupSettings
|
|
354
|
-
|
|
355
|
-
|
|
354
|
+
useSetGroupMetadata, useSetMemberMetadata, useSetContextMetadata
|
|
355
|
+
useGroupMetadata, useMemberMetadata, useUpdateMemberRole
|
|
356
|
+
useSetDefaultCapabilities, useDefaultCapabilities
|
|
357
|
+
useSetSubgroupVisibility, useSubgroupVisibility, useSetTeeAdmissionPolicy
|
|
356
358
|
useDetachContextFromGroup
|
|
357
359
|
useNamespaces, useNamespace, useNamespaceGroups, useNamespaceIdentity
|
|
358
360
|
useNamespacesForApplication, useCreateNamespace, useDeleteNamespace
|
package/dist/index.cjs
CHANGED
|
@@ -1493,6 +1493,18 @@ function useJoinContext() {
|
|
|
1493
1493
|
);
|
|
1494
1494
|
return { joinContext, loading, error };
|
|
1495
1495
|
}
|
|
1496
|
+
function useJoinSubgroupInheritance() {
|
|
1497
|
+
const { mero } = useMero();
|
|
1498
|
+
const { loading, error, run } = useAsyncMutation();
|
|
1499
|
+
const joinSubgroupInheritance = react.useCallback(
|
|
1500
|
+
async (groupId) => {
|
|
1501
|
+
if (!mero) return null;
|
|
1502
|
+
return run(() => mero.admin.joinSubgroupInheritance(groupId));
|
|
1503
|
+
},
|
|
1504
|
+
[mero, run]
|
|
1505
|
+
);
|
|
1506
|
+
return { joinSubgroupInheritance, loading, error };
|
|
1507
|
+
}
|
|
1496
1508
|
function useContextGroup(contextId) {
|
|
1497
1509
|
const { mero } = useMero();
|
|
1498
1510
|
const [groupId, setGroupId] = react.useState(null);
|
|
@@ -1910,6 +1922,86 @@ function useSetSubgroupVisibility() {
|
|
|
1910
1922
|
);
|
|
1911
1923
|
return { setSubgroupVisibility, loading, error };
|
|
1912
1924
|
}
|
|
1925
|
+
function useDefaultCapabilities(groupId) {
|
|
1926
|
+
const { mero } = useMero();
|
|
1927
|
+
const [defaultCapabilities, setDefaultCapabilitiesState] = react.useState(null);
|
|
1928
|
+
const [loading, setLoading] = react.useState(false);
|
|
1929
|
+
const [error, setError] = react.useState(null);
|
|
1930
|
+
const mountedRef = useMountedRef();
|
|
1931
|
+
const refetch = react.useCallback(async () => {
|
|
1932
|
+
if (!mero || !groupId) {
|
|
1933
|
+
if (mountedRef.current) {
|
|
1934
|
+
setDefaultCapabilitiesState(null);
|
|
1935
|
+
setError(null);
|
|
1936
|
+
setLoading(false);
|
|
1937
|
+
}
|
|
1938
|
+
return;
|
|
1939
|
+
}
|
|
1940
|
+
if (mountedRef.current) {
|
|
1941
|
+
setLoading(true);
|
|
1942
|
+
setError(null);
|
|
1943
|
+
}
|
|
1944
|
+
try {
|
|
1945
|
+
const result = await mero.admin.getDefaultCapabilities(groupId);
|
|
1946
|
+
if (mountedRef.current) {
|
|
1947
|
+
setDefaultCapabilitiesState(result);
|
|
1948
|
+
}
|
|
1949
|
+
} catch (err) {
|
|
1950
|
+
const errorValue = toError(err);
|
|
1951
|
+
if (mountedRef.current) {
|
|
1952
|
+
setError(errorValue);
|
|
1953
|
+
}
|
|
1954
|
+
} finally {
|
|
1955
|
+
if (mountedRef.current) {
|
|
1956
|
+
setLoading(false);
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
}, [groupId, mero, mountedRef]);
|
|
1960
|
+
react.useEffect(() => {
|
|
1961
|
+
void refetch();
|
|
1962
|
+
}, [refetch]);
|
|
1963
|
+
return { defaultCapabilities, loading, error, refetch };
|
|
1964
|
+
}
|
|
1965
|
+
function useSubgroupVisibility(groupId) {
|
|
1966
|
+
const { mero } = useMero();
|
|
1967
|
+
const [subgroupVisibility, setSubgroupVisibilityState] = react.useState(null);
|
|
1968
|
+
const [loading, setLoading] = react.useState(false);
|
|
1969
|
+
const [error, setError] = react.useState(null);
|
|
1970
|
+
const mountedRef = useMountedRef();
|
|
1971
|
+
const refetch = react.useCallback(async () => {
|
|
1972
|
+
if (!mero || !groupId) {
|
|
1973
|
+
if (mountedRef.current) {
|
|
1974
|
+
setSubgroupVisibilityState(null);
|
|
1975
|
+
setError(null);
|
|
1976
|
+
setLoading(false);
|
|
1977
|
+
}
|
|
1978
|
+
return;
|
|
1979
|
+
}
|
|
1980
|
+
if (mountedRef.current) {
|
|
1981
|
+
setLoading(true);
|
|
1982
|
+
setError(null);
|
|
1983
|
+
}
|
|
1984
|
+
try {
|
|
1985
|
+
const result = await mero.admin.getSubgroupVisibility(groupId);
|
|
1986
|
+
if (mountedRef.current) {
|
|
1987
|
+
setSubgroupVisibilityState(result);
|
|
1988
|
+
}
|
|
1989
|
+
} catch (err) {
|
|
1990
|
+
const errorValue = toError(err);
|
|
1991
|
+
if (mountedRef.current) {
|
|
1992
|
+
setError(errorValue);
|
|
1993
|
+
}
|
|
1994
|
+
} finally {
|
|
1995
|
+
if (mountedRef.current) {
|
|
1996
|
+
setLoading(false);
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
}, [groupId, mero, mountedRef]);
|
|
2000
|
+
react.useEffect(() => {
|
|
2001
|
+
void refetch();
|
|
2002
|
+
}, [refetch]);
|
|
2003
|
+
return { subgroupVisibility, loading, error, refetch };
|
|
2004
|
+
}
|
|
1913
2005
|
function useSetTeeAdmissionPolicy() {
|
|
1914
2006
|
const { mero } = useMero();
|
|
1915
2007
|
const { loading, error, run } = useAsyncMutation();
|
|
@@ -1934,29 +2026,121 @@ function useUpdateGroupSettings() {
|
|
|
1934
2026
|
);
|
|
1935
2027
|
return { updateGroupSettings, loading, error };
|
|
1936
2028
|
}
|
|
1937
|
-
function
|
|
2029
|
+
function useSetGroupMetadata() {
|
|
1938
2030
|
const { mero } = useMero();
|
|
1939
2031
|
const { loading, error, run } = useAsyncMutation();
|
|
1940
|
-
const
|
|
2032
|
+
const setGroupMetadata = react.useCallback(
|
|
1941
2033
|
async (groupId, request) => {
|
|
1942
2034
|
if (!mero) return null;
|
|
1943
|
-
return run(() => mero.admin.
|
|
2035
|
+
return run(() => mero.admin.setGroupMetadata(groupId, request));
|
|
1944
2036
|
},
|
|
1945
2037
|
[mero, run]
|
|
1946
2038
|
);
|
|
1947
|
-
return {
|
|
2039
|
+
return { setGroupMetadata, loading, error };
|
|
1948
2040
|
}
|
|
1949
|
-
function
|
|
2041
|
+
function useSetMemberMetadata() {
|
|
1950
2042
|
const { mero } = useMero();
|
|
1951
2043
|
const { loading, error, run } = useAsyncMutation();
|
|
1952
|
-
const
|
|
2044
|
+
const setMemberMetadata = react.useCallback(
|
|
1953
2045
|
async (groupId, identity, request) => {
|
|
1954
2046
|
if (!mero) return null;
|
|
1955
|
-
return run(() => mero.admin.
|
|
2047
|
+
return run(() => mero.admin.setMemberMetadata(groupId, identity, request));
|
|
1956
2048
|
},
|
|
1957
2049
|
[mero, run]
|
|
1958
2050
|
);
|
|
1959
|
-
return {
|
|
2051
|
+
return { setMemberMetadata, loading, error };
|
|
2052
|
+
}
|
|
2053
|
+
function useSetContextMetadata() {
|
|
2054
|
+
const { mero } = useMero();
|
|
2055
|
+
const { loading, error, run } = useAsyncMutation();
|
|
2056
|
+
const setContextMetadata = react.useCallback(
|
|
2057
|
+
async (groupId, contextId, request) => {
|
|
2058
|
+
if (!mero) return null;
|
|
2059
|
+
return run(() => mero.admin.setContextMetadata(groupId, contextId, request));
|
|
2060
|
+
},
|
|
2061
|
+
[mero, run]
|
|
2062
|
+
);
|
|
2063
|
+
return { setContextMetadata, loading, error };
|
|
2064
|
+
}
|
|
2065
|
+
function useGroupMetadata(groupId) {
|
|
2066
|
+
const { mero } = useMero();
|
|
2067
|
+
const [metadata, setMetadata] = react.useState(null);
|
|
2068
|
+
const [loading, setLoading] = react.useState(false);
|
|
2069
|
+
const [error, setError] = react.useState(null);
|
|
2070
|
+
const mountedRef = useMountedRef();
|
|
2071
|
+
const refetch = react.useCallback(async () => {
|
|
2072
|
+
if (!mero || !groupId) {
|
|
2073
|
+
if (mountedRef.current) {
|
|
2074
|
+
setMetadata(null);
|
|
2075
|
+
setError(null);
|
|
2076
|
+
setLoading(false);
|
|
2077
|
+
}
|
|
2078
|
+
return;
|
|
2079
|
+
}
|
|
2080
|
+
if (mountedRef.current) {
|
|
2081
|
+
setLoading(true);
|
|
2082
|
+
setError(null);
|
|
2083
|
+
}
|
|
2084
|
+
try {
|
|
2085
|
+
const result = await mero.admin.getGroupMetadata(groupId);
|
|
2086
|
+
if (mountedRef.current) {
|
|
2087
|
+
setMetadata(result);
|
|
2088
|
+
}
|
|
2089
|
+
} catch (err) {
|
|
2090
|
+
const errorValue = toError(err);
|
|
2091
|
+
if (mountedRef.current) {
|
|
2092
|
+
setError(errorValue);
|
|
2093
|
+
}
|
|
2094
|
+
} finally {
|
|
2095
|
+
if (mountedRef.current) {
|
|
2096
|
+
setLoading(false);
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
}, [groupId, mero, mountedRef]);
|
|
2100
|
+
react.useEffect(() => {
|
|
2101
|
+
void refetch();
|
|
2102
|
+
}, [refetch]);
|
|
2103
|
+
return { metadata, loading, error, refetch };
|
|
2104
|
+
}
|
|
2105
|
+
function useMemberMetadata(groupId, identity) {
|
|
2106
|
+
const { mero } = useMero();
|
|
2107
|
+
const [metadata, setMetadata] = react.useState(null);
|
|
2108
|
+
const [loading, setLoading] = react.useState(false);
|
|
2109
|
+
const [error, setError] = react.useState(null);
|
|
2110
|
+
const mountedRef = useMountedRef();
|
|
2111
|
+
const refetch = react.useCallback(async () => {
|
|
2112
|
+
if (!mero || !groupId || !identity) {
|
|
2113
|
+
if (mountedRef.current) {
|
|
2114
|
+
setMetadata(null);
|
|
2115
|
+
setError(null);
|
|
2116
|
+
setLoading(false);
|
|
2117
|
+
}
|
|
2118
|
+
return;
|
|
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);
|
|
2128
|
+
}
|
|
2129
|
+
} catch (err) {
|
|
2130
|
+
const errorValue = toError(err);
|
|
2131
|
+
if (mountedRef.current) {
|
|
2132
|
+
setError(errorValue);
|
|
2133
|
+
}
|
|
2134
|
+
} finally {
|
|
2135
|
+
if (mountedRef.current) {
|
|
2136
|
+
setLoading(false);
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
}, [groupId, identity, mero, mountedRef]);
|
|
2140
|
+
react.useEffect(() => {
|
|
2141
|
+
void refetch();
|
|
2142
|
+
}, [refetch]);
|
|
2143
|
+
return { metadata, loading, error, refetch };
|
|
1960
2144
|
}
|
|
1961
2145
|
function useRegisterGroupSigningKey() {
|
|
1962
2146
|
const { mero } = useMero();
|
|
@@ -2111,6 +2295,22 @@ function useDetachContextFromGroup() {
|
|
|
2111
2295
|
return { detachContextFromGroup, loading, error };
|
|
2112
2296
|
}
|
|
2113
2297
|
|
|
2298
|
+
Object.defineProperty(exports, "CAPABILITIES", {
|
|
2299
|
+
enumerable: true,
|
|
2300
|
+
get: function () { return meroJs.CAPABILITIES; }
|
|
2301
|
+
});
|
|
2302
|
+
Object.defineProperty(exports, "hasCap", {
|
|
2303
|
+
enumerable: true,
|
|
2304
|
+
get: function () { return meroJs.hasCap; }
|
|
2305
|
+
});
|
|
2306
|
+
Object.defineProperty(exports, "withCap", {
|
|
2307
|
+
enumerable: true,
|
|
2308
|
+
get: function () { return meroJs.withCap; }
|
|
2309
|
+
});
|
|
2310
|
+
Object.defineProperty(exports, "withoutCap", {
|
|
2311
|
+
enumerable: true,
|
|
2312
|
+
get: function () { return meroJs.withoutCap; }
|
|
2313
|
+
});
|
|
2114
2314
|
exports.AppMode = AppMode;
|
|
2115
2315
|
exports.CalimeroLogo = CalimeroLogo;
|
|
2116
2316
|
exports.ConnectButton = ConnectButton;
|
|
@@ -2146,6 +2346,7 @@ exports.useCreateContext = useCreateContext;
|
|
|
2146
2346
|
exports.useCreateGroupInNamespace = useCreateGroupInNamespace;
|
|
2147
2347
|
exports.useCreateNamespace = useCreateNamespace;
|
|
2148
2348
|
exports.useCreateNamespaceInvitation = useCreateNamespaceInvitation;
|
|
2349
|
+
exports.useDefaultCapabilities = useDefaultCapabilities;
|
|
2149
2350
|
exports.useDeleteContext = useDeleteContext;
|
|
2150
2351
|
exports.useDeleteGroup = useDeleteGroup;
|
|
2151
2352
|
exports.useDeleteNamespace = useDeleteNamespace;
|
|
@@ -2156,10 +2357,13 @@ exports.useGroupContexts = useGroupContexts;
|
|
|
2156
2357
|
exports.useGroupInfo = useGroupInfo;
|
|
2157
2358
|
exports.useGroupInvitations = useGroupInvitations;
|
|
2158
2359
|
exports.useGroupMembers = useGroupMembers;
|
|
2360
|
+
exports.useGroupMetadata = useGroupMetadata;
|
|
2159
2361
|
exports.useGroupUpgradeStatus = useGroupUpgradeStatus;
|
|
2160
2362
|
exports.useJoinContext = useJoinContext;
|
|
2161
2363
|
exports.useJoinGroup = useJoinGroup;
|
|
2162
2364
|
exports.useJoinNamespace = useJoinNamespace;
|
|
2365
|
+
exports.useJoinSubgroupInheritance = useJoinSubgroupInheritance;
|
|
2366
|
+
exports.useMemberMetadata = useMemberMetadata;
|
|
2163
2367
|
exports.useMero = useMero;
|
|
2164
2368
|
exports.useNamespace = useNamespace;
|
|
2165
2369
|
exports.useNamespaceGroups = useNamespaceGroups;
|
|
@@ -2170,11 +2374,13 @@ exports.useNestGroup = useNestGroup;
|
|
|
2170
2374
|
exports.useRegisterGroupSigningKey = useRegisterGroupSigningKey;
|
|
2171
2375
|
exports.useRemoveGroupMembers = useRemoveGroupMembers;
|
|
2172
2376
|
exports.useRetryGroupUpgrade = useRetryGroupUpgrade;
|
|
2377
|
+
exports.useSetContextMetadata = useSetContextMetadata;
|
|
2173
2378
|
exports.useSetDefaultCapabilities = useSetDefaultCapabilities;
|
|
2174
|
-
exports.
|
|
2175
|
-
exports.
|
|
2379
|
+
exports.useSetGroupMetadata = useSetGroupMetadata;
|
|
2380
|
+
exports.useSetMemberMetadata = useSetMemberMetadata;
|
|
2176
2381
|
exports.useSetSubgroupVisibility = useSetSubgroupVisibility;
|
|
2177
2382
|
exports.useSetTeeAdmissionPolicy = useSetTeeAdmissionPolicy;
|
|
2383
|
+
exports.useSubgroupVisibility = useSubgroupVisibility;
|
|
2178
2384
|
exports.useSubgroups = useSubgroups;
|
|
2179
2385
|
exports.useSubscription = useSubscription;
|
|
2180
2386
|
exports.useSyncGroup = useSyncGroup;
|