@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.cjs
CHANGED
|
@@ -388,8 +388,17 @@ var WebHttpClient = class {
|
|
|
388
388
|
case "response":
|
|
389
389
|
return response;
|
|
390
390
|
case "json":
|
|
391
|
-
default:
|
|
392
|
-
|
|
391
|
+
default: {
|
|
392
|
+
const text = await response.text();
|
|
393
|
+
if (!text) return null;
|
|
394
|
+
try {
|
|
395
|
+
return JSON.parse(text);
|
|
396
|
+
} catch {
|
|
397
|
+
throw new Error(
|
|
398
|
+
`Expected a JSON response (status ${response.status}) but body was not JSON: ${text.slice(0, 200)}`
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
393
402
|
}
|
|
394
403
|
}
|
|
395
404
|
async getBodyText(response) {
|
|
@@ -706,7 +715,7 @@ function createAuthApiClientFromHttpClient(httpClient, _config) {
|
|
|
706
715
|
|
|
707
716
|
// src/admin-api/admin-client.ts
|
|
708
717
|
function unwrap(response) {
|
|
709
|
-
return response
|
|
718
|
+
return response?.data;
|
|
710
719
|
}
|
|
711
720
|
function compareSemver(a, b) {
|
|
712
721
|
const pa = a.split(".");
|
|
@@ -816,14 +825,16 @@ var AdminApiClient = class {
|
|
|
816
825
|
}
|
|
817
826
|
// ---- Package Management ----
|
|
818
827
|
async listPackages() {
|
|
819
|
-
|
|
828
|
+
const r = await this.httpClient.get(
|
|
829
|
+
"/admin-api/packages"
|
|
830
|
+
);
|
|
831
|
+
return r?.data ?? r;
|
|
820
832
|
}
|
|
821
833
|
async listPackageVersions(packageName) {
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
`/admin-api/packages/${encodeURIComponent(packageName)}/versions`
|
|
825
|
-
)
|
|
834
|
+
const r = await this.httpClient.get(
|
|
835
|
+
`/admin-api/packages/${encodeURIComponent(packageName)}/versions`
|
|
826
836
|
);
|
|
837
|
+
return r?.data ?? r;
|
|
827
838
|
}
|
|
828
839
|
async getLatestPackageVersion(packageName) {
|
|
829
840
|
return this.httpClient.get(
|
|
@@ -832,7 +843,8 @@ var AdminApiClient = class {
|
|
|
832
843
|
}
|
|
833
844
|
// ---- Context Management ----
|
|
834
845
|
async createContext(request) {
|
|
835
|
-
|
|
846
|
+
const body = { ...request, initializationParams: request.initializationParams ?? [] };
|
|
847
|
+
return unwrap(await this.httpClient.post("/admin-api/contexts", body));
|
|
836
848
|
}
|
|
837
849
|
async deleteContext(contextId, request) {
|
|
838
850
|
if (request) {
|
|
@@ -904,11 +916,9 @@ var AdminApiClient = class {
|
|
|
904
916
|
await this.httpClient.post(`/admin-api/contexts/${contextId}/application`, request);
|
|
905
917
|
}
|
|
906
918
|
async getContextsWithExecutorsForApplication(applicationId) {
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
)
|
|
911
|
-
);
|
|
919
|
+
const r = await this.httpClient.get(`/admin-api/contexts/with-executors/for-application/${applicationId}`);
|
|
920
|
+
if (Array.isArray(r)) return r;
|
|
921
|
+
return r?.contexts ?? r?.data ?? [];
|
|
912
922
|
}
|
|
913
923
|
// ---- Blob Management ----
|
|
914
924
|
async uploadBlob(request) {
|
|
@@ -1043,7 +1053,10 @@ var AdminApiClient = class {
|
|
|
1043
1053
|
return unwrap(await this.httpClient.get(`/admin-api/namespaces/${namespaceId}`));
|
|
1044
1054
|
}
|
|
1045
1055
|
async getNamespaceIdentity(namespaceId) {
|
|
1046
|
-
|
|
1056
|
+
const r = await this.httpClient.get(
|
|
1057
|
+
`/admin-api/namespaces/${namespaceId}/identity`
|
|
1058
|
+
);
|
|
1059
|
+
return r?.data ?? r;
|
|
1047
1060
|
}
|
|
1048
1061
|
async listNamespacesForApplication(applicationId) {
|
|
1049
1062
|
return unwrap(await this.httpClient.get(`/admin-api/namespaces/for-application/${applicationId}`));
|
|
@@ -1055,8 +1068,8 @@ var AdminApiClient = class {
|
|
|
1055
1068
|
return unwrap(
|
|
1056
1069
|
await this.httpClient.request(`/admin-api/namespaces/${namespaceId}`, {
|
|
1057
1070
|
method: "DELETE",
|
|
1058
|
-
body:
|
|
1059
|
-
headers:
|
|
1071
|
+
body: JSON.stringify(request ?? {}),
|
|
1072
|
+
headers: { "Content-Type": "application/json" }
|
|
1060
1073
|
})
|
|
1061
1074
|
);
|
|
1062
1075
|
}
|
|
@@ -1101,16 +1114,13 @@ var AdminApiClient = class {
|
|
|
1101
1114
|
return (await this.getGroupInfo(groupId)).subgroupVisibility;
|
|
1102
1115
|
}
|
|
1103
1116
|
async deleteGroup(groupId, request) {
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
);
|
|
1112
|
-
}
|
|
1113
|
-
return unwrap(await this.httpClient.delete(`/admin-api/groups/${groupId}`));
|
|
1117
|
+
return unwrap(
|
|
1118
|
+
await this.httpClient.request(`/admin-api/groups/${groupId}`, {
|
|
1119
|
+
method: "DELETE",
|
|
1120
|
+
body: JSON.stringify(request ?? {}),
|
|
1121
|
+
headers: { "Content-Type": "application/json" }
|
|
1122
|
+
})
|
|
1123
|
+
);
|
|
1114
1124
|
}
|
|
1115
1125
|
async listGroupMembers(groupId) {
|
|
1116
1126
|
const response = await this.httpClient.get(
|
|
@@ -1231,12 +1241,8 @@ var AdminApiClient = class {
|
|
|
1231
1241
|
}
|
|
1232
1242
|
/** Move `childGroupId` under `request.newParentId`. */
|
|
1233
1243
|
async reparentGroup(childGroupId, request) {
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
`/admin-api/groups/${childGroupId}/reparent`,
|
|
1237
|
-
request
|
|
1238
|
-
)
|
|
1239
|
-
);
|
|
1244
|
+
const r = await this.httpClient.post(`/admin-api/groups/${childGroupId}/reparent`, request);
|
|
1245
|
+
return r?.data ?? r;
|
|
1240
1246
|
}
|
|
1241
1247
|
async listSubgroups(groupId) {
|
|
1242
1248
|
const response = await this.httpClient.get(
|
|
@@ -1285,6 +1291,59 @@ var AdminApiClient = class {
|
|
|
1285
1291
|
async getPeersCount() {
|
|
1286
1292
|
return this.httpClient.get("/admin-api/peers");
|
|
1287
1293
|
}
|
|
1294
|
+
/** Node network status (GET /admin-api/network/status). */
|
|
1295
|
+
async getNetworkStatus() {
|
|
1296
|
+
return this.httpClient.get("/admin-api/network/status");
|
|
1297
|
+
}
|
|
1298
|
+
/** Node storage/usage stats (GET /admin-api/usage). */
|
|
1299
|
+
async getUsage() {
|
|
1300
|
+
return this.httpClient.get("/admin-api/usage");
|
|
1301
|
+
}
|
|
1302
|
+
/** Node TLS certificate, PEM text (GET /admin-api/certificate). */
|
|
1303
|
+
async getCertificate() {
|
|
1304
|
+
return this.httpClient.get("/admin-api/certificate", { parse: "text" });
|
|
1305
|
+
}
|
|
1306
|
+
// ---- Group / context / namespace membership ----
|
|
1307
|
+
/** Create a standalone group (POST /admin-api/groups). */
|
|
1308
|
+
async createGroup(request) {
|
|
1309
|
+
return unwrap(
|
|
1310
|
+
await this.httpClient.post("/admin-api/groups", request)
|
|
1311
|
+
);
|
|
1312
|
+
}
|
|
1313
|
+
/** Leave a group (POST /admin-api/groups/:group_id/leave). */
|
|
1314
|
+
async leaveGroup(groupId, request) {
|
|
1315
|
+
await this.httpClient.post(`/admin-api/groups/${groupId}/leave`, request ?? {});
|
|
1316
|
+
}
|
|
1317
|
+
/** Leave a context (POST /admin-api/contexts/:context_id/leave). */
|
|
1318
|
+
async leaveContext(contextId, request) {
|
|
1319
|
+
await this.httpClient.post(`/admin-api/contexts/${contextId}/leave`, request ?? {});
|
|
1320
|
+
}
|
|
1321
|
+
/** Leave a namespace (POST /admin-api/namespaces/:namespace_id/leave). */
|
|
1322
|
+
async leaveNamespace(namespaceId, request) {
|
|
1323
|
+
await this.httpClient.post(`/admin-api/namespaces/${namespaceId}/leave`, request ?? {});
|
|
1324
|
+
}
|
|
1325
|
+
/** Issue a group ownership proof (POST /admin-api/groups/:group_id/issue-ownership-proof). */
|
|
1326
|
+
async issueOwnershipProof(groupId, request) {
|
|
1327
|
+
return this.httpClient.post(`/admin-api/groups/${groupId}/issue-ownership-proof`, request ?? {});
|
|
1328
|
+
}
|
|
1329
|
+
/** Issue a namespace ownership proof (POST /admin-api/groups/:group_id/issue-namespace-ownership-proof). */
|
|
1330
|
+
async issueNamespaceOwnershipProof(groupId, request) {
|
|
1331
|
+
return this.httpClient.post(
|
|
1332
|
+
`/admin-api/groups/${groupId}/issue-namespace-ownership-proof`,
|
|
1333
|
+
request ?? {}
|
|
1334
|
+
);
|
|
1335
|
+
}
|
|
1336
|
+
/** Set a member's auto-follow flag (PUT /admin-api/groups/:group_id/members/:identity/auto-follow). */
|
|
1337
|
+
async setMemberAutoFollow(groupId, identity, request) {
|
|
1338
|
+
await this.httpClient.put(`/admin-api/groups/${groupId}/members/${identity}/auto-follow`, request);
|
|
1339
|
+
}
|
|
1340
|
+
/** Abort a namespace migration (POST /admin-api/groups/:namespace_id/migration/abort). */
|
|
1341
|
+
async abortMigration(namespaceId, request) {
|
|
1342
|
+
return this.httpClient.post(
|
|
1343
|
+
`/admin-api/groups/${namespaceId}/migration/abort`,
|
|
1344
|
+
request ?? {}
|
|
1345
|
+
);
|
|
1346
|
+
}
|
|
1288
1347
|
};
|
|
1289
1348
|
|
|
1290
1349
|
// src/admin-api/admin-factory.ts
|