@calimero-network/mero-react 2.2.1 → 2.3.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 +203 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -6
- package/dist/index.d.ts +43 -6
- package/dist/index.js +182 -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
|
@@ -1910,6 +1910,86 @@ function useSetSubgroupVisibility() {
|
|
|
1910
1910
|
);
|
|
1911
1911
|
return { setSubgroupVisibility, loading, error };
|
|
1912
1912
|
}
|
|
1913
|
+
function useDefaultCapabilities(groupId) {
|
|
1914
|
+
const { mero } = useMero();
|
|
1915
|
+
const [defaultCapabilities, setDefaultCapabilitiesState] = react.useState(null);
|
|
1916
|
+
const [loading, setLoading] = react.useState(false);
|
|
1917
|
+
const [error, setError] = react.useState(null);
|
|
1918
|
+
const mountedRef = useMountedRef();
|
|
1919
|
+
const refetch = react.useCallback(async () => {
|
|
1920
|
+
if (!mero || !groupId) {
|
|
1921
|
+
if (mountedRef.current) {
|
|
1922
|
+
setDefaultCapabilitiesState(null);
|
|
1923
|
+
setError(null);
|
|
1924
|
+
setLoading(false);
|
|
1925
|
+
}
|
|
1926
|
+
return;
|
|
1927
|
+
}
|
|
1928
|
+
if (mountedRef.current) {
|
|
1929
|
+
setLoading(true);
|
|
1930
|
+
setError(null);
|
|
1931
|
+
}
|
|
1932
|
+
try {
|
|
1933
|
+
const result = await mero.admin.getDefaultCapabilities(groupId);
|
|
1934
|
+
if (mountedRef.current) {
|
|
1935
|
+
setDefaultCapabilitiesState(result);
|
|
1936
|
+
}
|
|
1937
|
+
} catch (err) {
|
|
1938
|
+
const errorValue = toError(err);
|
|
1939
|
+
if (mountedRef.current) {
|
|
1940
|
+
setError(errorValue);
|
|
1941
|
+
}
|
|
1942
|
+
} finally {
|
|
1943
|
+
if (mountedRef.current) {
|
|
1944
|
+
setLoading(false);
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
}, [groupId, mero, mountedRef]);
|
|
1948
|
+
react.useEffect(() => {
|
|
1949
|
+
void refetch();
|
|
1950
|
+
}, [refetch]);
|
|
1951
|
+
return { defaultCapabilities, loading, error, refetch };
|
|
1952
|
+
}
|
|
1953
|
+
function useSubgroupVisibility(groupId) {
|
|
1954
|
+
const { mero } = useMero();
|
|
1955
|
+
const [subgroupVisibility, setSubgroupVisibilityState] = react.useState(null);
|
|
1956
|
+
const [loading, setLoading] = react.useState(false);
|
|
1957
|
+
const [error, setError] = react.useState(null);
|
|
1958
|
+
const mountedRef = useMountedRef();
|
|
1959
|
+
const refetch = react.useCallback(async () => {
|
|
1960
|
+
if (!mero || !groupId) {
|
|
1961
|
+
if (mountedRef.current) {
|
|
1962
|
+
setSubgroupVisibilityState(null);
|
|
1963
|
+
setError(null);
|
|
1964
|
+
setLoading(false);
|
|
1965
|
+
}
|
|
1966
|
+
return;
|
|
1967
|
+
}
|
|
1968
|
+
if (mountedRef.current) {
|
|
1969
|
+
setLoading(true);
|
|
1970
|
+
setError(null);
|
|
1971
|
+
}
|
|
1972
|
+
try {
|
|
1973
|
+
const result = await mero.admin.getSubgroupVisibility(groupId);
|
|
1974
|
+
if (mountedRef.current) {
|
|
1975
|
+
setSubgroupVisibilityState(result);
|
|
1976
|
+
}
|
|
1977
|
+
} catch (err) {
|
|
1978
|
+
const errorValue = toError(err);
|
|
1979
|
+
if (mountedRef.current) {
|
|
1980
|
+
setError(errorValue);
|
|
1981
|
+
}
|
|
1982
|
+
} finally {
|
|
1983
|
+
if (mountedRef.current) {
|
|
1984
|
+
setLoading(false);
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
}, [groupId, mero, mountedRef]);
|
|
1988
|
+
react.useEffect(() => {
|
|
1989
|
+
void refetch();
|
|
1990
|
+
}, [refetch]);
|
|
1991
|
+
return { subgroupVisibility, loading, error, refetch };
|
|
1992
|
+
}
|
|
1913
1993
|
function useSetTeeAdmissionPolicy() {
|
|
1914
1994
|
const { mero } = useMero();
|
|
1915
1995
|
const { loading, error, run } = useAsyncMutation();
|
|
@@ -1934,29 +2014,121 @@ function useUpdateGroupSettings() {
|
|
|
1934
2014
|
);
|
|
1935
2015
|
return { updateGroupSettings, loading, error };
|
|
1936
2016
|
}
|
|
1937
|
-
function
|
|
2017
|
+
function useSetGroupMetadata() {
|
|
1938
2018
|
const { mero } = useMero();
|
|
1939
2019
|
const { loading, error, run } = useAsyncMutation();
|
|
1940
|
-
const
|
|
2020
|
+
const setGroupMetadata = react.useCallback(
|
|
1941
2021
|
async (groupId, request) => {
|
|
1942
2022
|
if (!mero) return null;
|
|
1943
|
-
return run(() => mero.admin.
|
|
2023
|
+
return run(() => mero.admin.setGroupMetadata(groupId, request));
|
|
1944
2024
|
},
|
|
1945
2025
|
[mero, run]
|
|
1946
2026
|
);
|
|
1947
|
-
return {
|
|
2027
|
+
return { setGroupMetadata, loading, error };
|
|
1948
2028
|
}
|
|
1949
|
-
function
|
|
2029
|
+
function useSetMemberMetadata() {
|
|
1950
2030
|
const { mero } = useMero();
|
|
1951
2031
|
const { loading, error, run } = useAsyncMutation();
|
|
1952
|
-
const
|
|
2032
|
+
const setMemberMetadata = react.useCallback(
|
|
1953
2033
|
async (groupId, identity, request) => {
|
|
1954
2034
|
if (!mero) return null;
|
|
1955
|
-
return run(() => mero.admin.
|
|
2035
|
+
return run(() => mero.admin.setMemberMetadata(groupId, identity, request));
|
|
2036
|
+
},
|
|
2037
|
+
[mero, run]
|
|
2038
|
+
);
|
|
2039
|
+
return { setMemberMetadata, loading, error };
|
|
2040
|
+
}
|
|
2041
|
+
function useSetContextMetadata() {
|
|
2042
|
+
const { mero } = useMero();
|
|
2043
|
+
const { loading, error, run } = useAsyncMutation();
|
|
2044
|
+
const setContextMetadata = react.useCallback(
|
|
2045
|
+
async (groupId, contextId, request) => {
|
|
2046
|
+
if (!mero) return null;
|
|
2047
|
+
return run(() => mero.admin.setContextMetadata(groupId, contextId, request));
|
|
1956
2048
|
},
|
|
1957
2049
|
[mero, run]
|
|
1958
2050
|
);
|
|
1959
|
-
return {
|
|
2051
|
+
return { setContextMetadata, loading, error };
|
|
2052
|
+
}
|
|
2053
|
+
function useGroupMetadata(groupId) {
|
|
2054
|
+
const { mero } = useMero();
|
|
2055
|
+
const [metadata, setMetadata] = react.useState(null);
|
|
2056
|
+
const [loading, setLoading] = react.useState(false);
|
|
2057
|
+
const [error, setError] = react.useState(null);
|
|
2058
|
+
const mountedRef = useMountedRef();
|
|
2059
|
+
const refetch = react.useCallback(async () => {
|
|
2060
|
+
if (!mero || !groupId) {
|
|
2061
|
+
if (mountedRef.current) {
|
|
2062
|
+
setMetadata(null);
|
|
2063
|
+
setError(null);
|
|
2064
|
+
setLoading(false);
|
|
2065
|
+
}
|
|
2066
|
+
return;
|
|
2067
|
+
}
|
|
2068
|
+
if (mountedRef.current) {
|
|
2069
|
+
setLoading(true);
|
|
2070
|
+
setError(null);
|
|
2071
|
+
}
|
|
2072
|
+
try {
|
|
2073
|
+
const result = await mero.admin.getGroupMetadata(groupId);
|
|
2074
|
+
if (mountedRef.current) {
|
|
2075
|
+
setMetadata(result);
|
|
2076
|
+
}
|
|
2077
|
+
} catch (err) {
|
|
2078
|
+
const errorValue = toError(err);
|
|
2079
|
+
if (mountedRef.current) {
|
|
2080
|
+
setError(errorValue);
|
|
2081
|
+
}
|
|
2082
|
+
} finally {
|
|
2083
|
+
if (mountedRef.current) {
|
|
2084
|
+
setLoading(false);
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}, [groupId, mero, mountedRef]);
|
|
2088
|
+
react.useEffect(() => {
|
|
2089
|
+
void refetch();
|
|
2090
|
+
}, [refetch]);
|
|
2091
|
+
return { metadata, loading, error, refetch };
|
|
2092
|
+
}
|
|
2093
|
+
function useMemberMetadata(groupId, identity) {
|
|
2094
|
+
const { mero } = useMero();
|
|
2095
|
+
const [metadata, setMetadata] = react.useState(null);
|
|
2096
|
+
const [loading, setLoading] = react.useState(false);
|
|
2097
|
+
const [error, setError] = react.useState(null);
|
|
2098
|
+
const mountedRef = useMountedRef();
|
|
2099
|
+
const refetch = react.useCallback(async () => {
|
|
2100
|
+
if (!mero || !groupId || !identity) {
|
|
2101
|
+
if (mountedRef.current) {
|
|
2102
|
+
setMetadata(null);
|
|
2103
|
+
setError(null);
|
|
2104
|
+
setLoading(false);
|
|
2105
|
+
}
|
|
2106
|
+
return;
|
|
2107
|
+
}
|
|
2108
|
+
if (mountedRef.current) {
|
|
2109
|
+
setLoading(true);
|
|
2110
|
+
setError(null);
|
|
2111
|
+
}
|
|
2112
|
+
try {
|
|
2113
|
+
const result = await mero.admin.getMemberMetadata(groupId, identity);
|
|
2114
|
+
if (mountedRef.current) {
|
|
2115
|
+
setMetadata(result);
|
|
2116
|
+
}
|
|
2117
|
+
} catch (err) {
|
|
2118
|
+
const errorValue = toError(err);
|
|
2119
|
+
if (mountedRef.current) {
|
|
2120
|
+
setError(errorValue);
|
|
2121
|
+
}
|
|
2122
|
+
} finally {
|
|
2123
|
+
if (mountedRef.current) {
|
|
2124
|
+
setLoading(false);
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
}, [groupId, identity, mero, mountedRef]);
|
|
2128
|
+
react.useEffect(() => {
|
|
2129
|
+
void refetch();
|
|
2130
|
+
}, [refetch]);
|
|
2131
|
+
return { metadata, loading, error, refetch };
|
|
1960
2132
|
}
|
|
1961
2133
|
function useRegisterGroupSigningKey() {
|
|
1962
2134
|
const { mero } = useMero();
|
|
@@ -2111,6 +2283,22 @@ function useDetachContextFromGroup() {
|
|
|
2111
2283
|
return { detachContextFromGroup, loading, error };
|
|
2112
2284
|
}
|
|
2113
2285
|
|
|
2286
|
+
Object.defineProperty(exports, "CAPABILITIES", {
|
|
2287
|
+
enumerable: true,
|
|
2288
|
+
get: function () { return meroJs.CAPABILITIES; }
|
|
2289
|
+
});
|
|
2290
|
+
Object.defineProperty(exports, "hasCap", {
|
|
2291
|
+
enumerable: true,
|
|
2292
|
+
get: function () { return meroJs.hasCap; }
|
|
2293
|
+
});
|
|
2294
|
+
Object.defineProperty(exports, "withCap", {
|
|
2295
|
+
enumerable: true,
|
|
2296
|
+
get: function () { return meroJs.withCap; }
|
|
2297
|
+
});
|
|
2298
|
+
Object.defineProperty(exports, "withoutCap", {
|
|
2299
|
+
enumerable: true,
|
|
2300
|
+
get: function () { return meroJs.withoutCap; }
|
|
2301
|
+
});
|
|
2114
2302
|
exports.AppMode = AppMode;
|
|
2115
2303
|
exports.CalimeroLogo = CalimeroLogo;
|
|
2116
2304
|
exports.ConnectButton = ConnectButton;
|
|
@@ -2146,6 +2334,7 @@ exports.useCreateContext = useCreateContext;
|
|
|
2146
2334
|
exports.useCreateGroupInNamespace = useCreateGroupInNamespace;
|
|
2147
2335
|
exports.useCreateNamespace = useCreateNamespace;
|
|
2148
2336
|
exports.useCreateNamespaceInvitation = useCreateNamespaceInvitation;
|
|
2337
|
+
exports.useDefaultCapabilities = useDefaultCapabilities;
|
|
2149
2338
|
exports.useDeleteContext = useDeleteContext;
|
|
2150
2339
|
exports.useDeleteGroup = useDeleteGroup;
|
|
2151
2340
|
exports.useDeleteNamespace = useDeleteNamespace;
|
|
@@ -2156,10 +2345,12 @@ exports.useGroupContexts = useGroupContexts;
|
|
|
2156
2345
|
exports.useGroupInfo = useGroupInfo;
|
|
2157
2346
|
exports.useGroupInvitations = useGroupInvitations;
|
|
2158
2347
|
exports.useGroupMembers = useGroupMembers;
|
|
2348
|
+
exports.useGroupMetadata = useGroupMetadata;
|
|
2159
2349
|
exports.useGroupUpgradeStatus = useGroupUpgradeStatus;
|
|
2160
2350
|
exports.useJoinContext = useJoinContext;
|
|
2161
2351
|
exports.useJoinGroup = useJoinGroup;
|
|
2162
2352
|
exports.useJoinNamespace = useJoinNamespace;
|
|
2353
|
+
exports.useMemberMetadata = useMemberMetadata;
|
|
2163
2354
|
exports.useMero = useMero;
|
|
2164
2355
|
exports.useNamespace = useNamespace;
|
|
2165
2356
|
exports.useNamespaceGroups = useNamespaceGroups;
|
|
@@ -2170,11 +2361,13 @@ exports.useNestGroup = useNestGroup;
|
|
|
2170
2361
|
exports.useRegisterGroupSigningKey = useRegisterGroupSigningKey;
|
|
2171
2362
|
exports.useRemoveGroupMembers = useRemoveGroupMembers;
|
|
2172
2363
|
exports.useRetryGroupUpgrade = useRetryGroupUpgrade;
|
|
2364
|
+
exports.useSetContextMetadata = useSetContextMetadata;
|
|
2173
2365
|
exports.useSetDefaultCapabilities = useSetDefaultCapabilities;
|
|
2174
|
-
exports.
|
|
2175
|
-
exports.
|
|
2366
|
+
exports.useSetGroupMetadata = useSetGroupMetadata;
|
|
2367
|
+
exports.useSetMemberMetadata = useSetMemberMetadata;
|
|
2176
2368
|
exports.useSetSubgroupVisibility = useSetSubgroupVisibility;
|
|
2177
2369
|
exports.useSetTeeAdmissionPolicy = useSetTeeAdmissionPolicy;
|
|
2370
|
+
exports.useSubgroupVisibility = useSubgroupVisibility;
|
|
2178
2371
|
exports.useSubgroups = useSubgroups;
|
|
2179
2372
|
exports.useSubscription = useSubscription;
|
|
2180
2373
|
exports.useSyncGroup = useSyncGroup;
|