@calimero-network/mero-js 6.0.0 → 6.0.2
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/admin-api/admin-client.d.ts +24 -0
- package/dist/admin-api/admin-client.d.ts.map +1 -1
- package/dist/admin-api/admin-client.js +83 -18
- package/dist/admin-api/admin-client.js.map +1 -1
- package/dist/admin-api/admin-types.d.ts +3 -1
- package/dist/admin-api/admin-types.d.ts.map +1 -1
- package/dist/http-client/web-client.d.ts.map +1 -1
- package/dist/http-client/web-client.js +15 -2
- package/dist/http-client/web-client.js.map +1 -1
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +92 -33
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +92 -33
- package/dist/index.mjs.map +2 -2
- package/package.json +4 -2
package/dist/index.mjs
CHANGED
|
@@ -328,8 +328,17 @@ var WebHttpClient = class {
|
|
|
328
328
|
case "response":
|
|
329
329
|
return response;
|
|
330
330
|
case "json":
|
|
331
|
-
default:
|
|
332
|
-
|
|
331
|
+
default: {
|
|
332
|
+
const text = await response.text();
|
|
333
|
+
if (!text) return null;
|
|
334
|
+
try {
|
|
335
|
+
return JSON.parse(text);
|
|
336
|
+
} catch {
|
|
337
|
+
throw new Error(
|
|
338
|
+
`Expected a JSON response (status ${response.status}) but body was not JSON: ${text.slice(0, 200)}`
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
333
342
|
}
|
|
334
343
|
}
|
|
335
344
|
async getBodyText(response) {
|
|
@@ -646,7 +655,7 @@ function createAuthApiClientFromHttpClient(httpClient, _config) {
|
|
|
646
655
|
|
|
647
656
|
// src/admin-api/admin-client.ts
|
|
648
657
|
function unwrap(response) {
|
|
649
|
-
return response
|
|
658
|
+
return response?.data;
|
|
650
659
|
}
|
|
651
660
|
function compareSemver(a, b) {
|
|
652
661
|
const pa = a.split(".");
|
|
@@ -756,14 +765,16 @@ var AdminApiClient = class {
|
|
|
756
765
|
}
|
|
757
766
|
// ---- Package Management ----
|
|
758
767
|
async listPackages() {
|
|
759
|
-
|
|
768
|
+
const r = await this.httpClient.get(
|
|
769
|
+
"/admin-api/packages"
|
|
770
|
+
);
|
|
771
|
+
return r?.data ?? r;
|
|
760
772
|
}
|
|
761
773
|
async listPackageVersions(packageName) {
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
`/admin-api/packages/${encodeURIComponent(packageName)}/versions`
|
|
765
|
-
)
|
|
774
|
+
const r = await this.httpClient.get(
|
|
775
|
+
`/admin-api/packages/${encodeURIComponent(packageName)}/versions`
|
|
766
776
|
);
|
|
777
|
+
return r?.data ?? r;
|
|
767
778
|
}
|
|
768
779
|
async getLatestPackageVersion(packageName) {
|
|
769
780
|
return this.httpClient.get(
|
|
@@ -772,7 +783,8 @@ var AdminApiClient = class {
|
|
|
772
783
|
}
|
|
773
784
|
// ---- Context Management ----
|
|
774
785
|
async createContext(request) {
|
|
775
|
-
|
|
786
|
+
const body = { ...request, initializationParams: request.initializationParams ?? [] };
|
|
787
|
+
return unwrap(await this.httpClient.post("/admin-api/contexts", body));
|
|
776
788
|
}
|
|
777
789
|
async deleteContext(contextId, request) {
|
|
778
790
|
if (request) {
|
|
@@ -844,11 +856,9 @@ var AdminApiClient = class {
|
|
|
844
856
|
await this.httpClient.post(`/admin-api/contexts/${contextId}/application`, request);
|
|
845
857
|
}
|
|
846
858
|
async getContextsWithExecutorsForApplication(applicationId) {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
)
|
|
851
|
-
);
|
|
859
|
+
const r = await this.httpClient.get(`/admin-api/contexts/with-executors/for-application/${applicationId}`);
|
|
860
|
+
if (Array.isArray(r)) return r;
|
|
861
|
+
return r?.contexts ?? r?.data ?? [];
|
|
852
862
|
}
|
|
853
863
|
// ---- Blob Management ----
|
|
854
864
|
async uploadBlob(request) {
|
|
@@ -983,7 +993,10 @@ var AdminApiClient = class {
|
|
|
983
993
|
return unwrap(await this.httpClient.get(`/admin-api/namespaces/${namespaceId}`));
|
|
984
994
|
}
|
|
985
995
|
async getNamespaceIdentity(namespaceId) {
|
|
986
|
-
|
|
996
|
+
const r = await this.httpClient.get(
|
|
997
|
+
`/admin-api/namespaces/${namespaceId}/identity`
|
|
998
|
+
);
|
|
999
|
+
return r?.data ?? r;
|
|
987
1000
|
}
|
|
988
1001
|
async listNamespacesForApplication(applicationId) {
|
|
989
1002
|
return unwrap(await this.httpClient.get(`/admin-api/namespaces/for-application/${applicationId}`));
|
|
@@ -995,8 +1008,8 @@ var AdminApiClient = class {
|
|
|
995
1008
|
return unwrap(
|
|
996
1009
|
await this.httpClient.request(`/admin-api/namespaces/${namespaceId}`, {
|
|
997
1010
|
method: "DELETE",
|
|
998
|
-
body:
|
|
999
|
-
headers:
|
|
1011
|
+
body: JSON.stringify(request ?? {}),
|
|
1012
|
+
headers: { "Content-Type": "application/json" }
|
|
1000
1013
|
})
|
|
1001
1014
|
);
|
|
1002
1015
|
}
|
|
@@ -1041,16 +1054,13 @@ var AdminApiClient = class {
|
|
|
1041
1054
|
return (await this.getGroupInfo(groupId)).subgroupVisibility;
|
|
1042
1055
|
}
|
|
1043
1056
|
async deleteGroup(groupId, request) {
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
);
|
|
1052
|
-
}
|
|
1053
|
-
return unwrap(await this.httpClient.delete(`/admin-api/groups/${groupId}`));
|
|
1057
|
+
return unwrap(
|
|
1058
|
+
await this.httpClient.request(`/admin-api/groups/${groupId}`, {
|
|
1059
|
+
method: "DELETE",
|
|
1060
|
+
body: JSON.stringify(request ?? {}),
|
|
1061
|
+
headers: { "Content-Type": "application/json" }
|
|
1062
|
+
})
|
|
1063
|
+
);
|
|
1054
1064
|
}
|
|
1055
1065
|
async listGroupMembers(groupId) {
|
|
1056
1066
|
const response = await this.httpClient.get(
|
|
@@ -1171,12 +1181,8 @@ var AdminApiClient = class {
|
|
|
1171
1181
|
}
|
|
1172
1182
|
/** Move `childGroupId` under `request.newParentId`. */
|
|
1173
1183
|
async reparentGroup(childGroupId, request) {
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
`/admin-api/groups/${childGroupId}/reparent`,
|
|
1177
|
-
request
|
|
1178
|
-
)
|
|
1179
|
-
);
|
|
1184
|
+
const r = await this.httpClient.post(`/admin-api/groups/${childGroupId}/reparent`, request);
|
|
1185
|
+
return r?.data ?? r;
|
|
1180
1186
|
}
|
|
1181
1187
|
async listSubgroups(groupId) {
|
|
1182
1188
|
const response = await this.httpClient.get(
|
|
@@ -1225,6 +1231,59 @@ var AdminApiClient = class {
|
|
|
1225
1231
|
async getPeersCount() {
|
|
1226
1232
|
return this.httpClient.get("/admin-api/peers");
|
|
1227
1233
|
}
|
|
1234
|
+
/** Node network status (GET /admin-api/network/status). */
|
|
1235
|
+
async getNetworkStatus() {
|
|
1236
|
+
return this.httpClient.get("/admin-api/network/status");
|
|
1237
|
+
}
|
|
1238
|
+
/** Node storage/usage stats (GET /admin-api/usage). */
|
|
1239
|
+
async getUsage() {
|
|
1240
|
+
return this.httpClient.get("/admin-api/usage");
|
|
1241
|
+
}
|
|
1242
|
+
/** Node TLS certificate, PEM text (GET /admin-api/certificate). */
|
|
1243
|
+
async getCertificate() {
|
|
1244
|
+
return this.httpClient.get("/admin-api/certificate", { parse: "text" });
|
|
1245
|
+
}
|
|
1246
|
+
// ---- Group / context / namespace membership ----
|
|
1247
|
+
/** Create a standalone group (POST /admin-api/groups). */
|
|
1248
|
+
async createGroup(request) {
|
|
1249
|
+
return unwrap(
|
|
1250
|
+
await this.httpClient.post("/admin-api/groups", request)
|
|
1251
|
+
);
|
|
1252
|
+
}
|
|
1253
|
+
/** Leave a group (POST /admin-api/groups/:group_id/leave). */
|
|
1254
|
+
async leaveGroup(groupId, request) {
|
|
1255
|
+
await this.httpClient.post(`/admin-api/groups/${groupId}/leave`, request ?? {});
|
|
1256
|
+
}
|
|
1257
|
+
/** Leave a context (POST /admin-api/contexts/:context_id/leave). */
|
|
1258
|
+
async leaveContext(contextId, request) {
|
|
1259
|
+
await this.httpClient.post(`/admin-api/contexts/${contextId}/leave`, request ?? {});
|
|
1260
|
+
}
|
|
1261
|
+
/** Leave a namespace (POST /admin-api/namespaces/:namespace_id/leave). */
|
|
1262
|
+
async leaveNamespace(namespaceId, request) {
|
|
1263
|
+
await this.httpClient.post(`/admin-api/namespaces/${namespaceId}/leave`, request ?? {});
|
|
1264
|
+
}
|
|
1265
|
+
/** Issue a group ownership proof (POST /admin-api/groups/:group_id/issue-ownership-proof). */
|
|
1266
|
+
async issueOwnershipProof(groupId, request) {
|
|
1267
|
+
return this.httpClient.post(`/admin-api/groups/${groupId}/issue-ownership-proof`, request ?? {});
|
|
1268
|
+
}
|
|
1269
|
+
/** Issue a namespace ownership proof (POST /admin-api/groups/:group_id/issue-namespace-ownership-proof). */
|
|
1270
|
+
async issueNamespaceOwnershipProof(groupId, request) {
|
|
1271
|
+
return this.httpClient.post(
|
|
1272
|
+
`/admin-api/groups/${groupId}/issue-namespace-ownership-proof`,
|
|
1273
|
+
request ?? {}
|
|
1274
|
+
);
|
|
1275
|
+
}
|
|
1276
|
+
/** Set a member's auto-follow flag (PUT /admin-api/groups/:group_id/members/:identity/auto-follow). */
|
|
1277
|
+
async setMemberAutoFollow(groupId, identity, request) {
|
|
1278
|
+
await this.httpClient.put(`/admin-api/groups/${groupId}/members/${identity}/auto-follow`, request);
|
|
1279
|
+
}
|
|
1280
|
+
/** Abort a namespace migration (POST /admin-api/groups/:namespace_id/migration/abort). */
|
|
1281
|
+
async abortMigration(namespaceId, request) {
|
|
1282
|
+
return this.httpClient.post(
|
|
1283
|
+
`/admin-api/groups/${namespaceId}/migration/abort`,
|
|
1284
|
+
request ?? {}
|
|
1285
|
+
);
|
|
1286
|
+
}
|
|
1228
1287
|
};
|
|
1229
1288
|
|
|
1230
1289
|
// src/admin-api/admin-factory.ts
|