@calimero-network/mero-js 19.0.0 → 19.1.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/dist/admin-api/admin-client.d.ts +23 -3
- package/dist/admin-api/admin-client.js +33 -4
- package/dist/admin-api/admin-types.d.ts +19 -0
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +33 -5
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +33 -5
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1031,13 +1031,30 @@ var AdminApiClient = class {
|
|
|
1031
1031
|
);
|
|
1032
1032
|
return { blobs: res.blobs.map((b) => ({ blobId: b.blob_id, size: b.size })) };
|
|
1033
1033
|
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Blob-read query params. `context_id` is the same snake_case param
|
|
1036
|
+
* {@link uploadBlob} announces with; building it in one place keeps the read
|
|
1037
|
+
* side from drifting from the write side.
|
|
1038
|
+
*/
|
|
1039
|
+
blobPath(blobId, options) {
|
|
1040
|
+
if (!options?.contextId) return `/admin-api/blobs/${blobId}`;
|
|
1041
|
+
const params = new URLSearchParams({ context_id: options.contextId });
|
|
1042
|
+
return `/admin-api/blobs/${blobId}?${params.toString()}`;
|
|
1043
|
+
}
|
|
1034
1044
|
/**
|
|
1035
1045
|
* Download a blob's raw bytes. `GET /admin-api/blobs/:id` streams the blob
|
|
1036
1046
|
* content (e.g. `application/gzip`), NOT JSON — so fetch it as an ArrayBuffer.
|
|
1037
1047
|
* Use {@link listBlobs} for `{ blobId, size }` metadata.
|
|
1048
|
+
*
|
|
1049
|
+
* Without `contextId` the read is local-only: the node answers from its own
|
|
1050
|
+
* blob store and returns immediately, or 404s. Passing `contextId` opts into
|
|
1051
|
+
* network discovery — the node probes that context's peers (availability
|
|
1052
|
+
* nodes first) for a holder, then transfers the bytes. Budget for it: core
|
|
1053
|
+
* bounds discovery by a ~30s deadline, and the transfer is on top of that, so
|
|
1054
|
+
* the worst case is well past what a UI should block on unhinted.
|
|
1038
1055
|
*/
|
|
1039
|
-
async getBlob(blobId) {
|
|
1040
|
-
return this.httpClient.get(
|
|
1056
|
+
async getBlob(blobId, options) {
|
|
1057
|
+
return this.httpClient.get(this.blobPath(blobId, options), {
|
|
1041
1058
|
parse: "arrayBuffer"
|
|
1042
1059
|
});
|
|
1043
1060
|
}
|
|
@@ -1045,15 +1062,26 @@ var AdminApiClient = class {
|
|
|
1045
1062
|
* Fetch a blob's metadata without downloading it. `HEAD /admin-api/blobs/:id`
|
|
1046
1063
|
* returns the info in response headers (size via `content-length`, plus
|
|
1047
1064
|
* `x-blob-id`/`x-blob-hash`/`x-blob-mime-type`).
|
|
1065
|
+
*
|
|
1066
|
+
* Without `contextId` this is a local-only presence check that returns
|
|
1067
|
+
* immediately. Passing `contextId` opts into the same network discovery
|
|
1068
|
+
* {@link getBlob} uses — presence and size answered by probing the context's
|
|
1069
|
+
* peers, with no transfer — so it inherits core's ~30s discovery deadline as
|
|
1070
|
+
* its worst case. A probe only carries `found` and `size`, so a peer-sourced
|
|
1071
|
+
* answer has no `hash`/`mimeType`; read `source` to tell the two apart.
|
|
1048
1072
|
*/
|
|
1049
|
-
async getBlobInfo(blobId) {
|
|
1050
|
-
const { headers } = await this.httpClient.head(
|
|
1073
|
+
async getBlobInfo(blobId, options) {
|
|
1074
|
+
const { headers } = await this.httpClient.head(this.blobPath(blobId, options));
|
|
1051
1075
|
const size = Number(headers["content-length"]);
|
|
1052
1076
|
return {
|
|
1053
1077
|
blobId: headers["x-blob-id"] ?? blobId,
|
|
1054
1078
|
size: Number.isFinite(size) ? size : 0,
|
|
1055
1079
|
hash: headers["x-blob-hash"],
|
|
1056
|
-
mimeType: headers["x-blob-mime-type"]
|
|
1080
|
+
mimeType: headers["x-blob-mime-type"],
|
|
1081
|
+
// Nodes that predate the context-aware HEAD omit this header entirely, so
|
|
1082
|
+
// it stays undefined rather than being defaulted to 'local' — absent means
|
|
1083
|
+
// "the node didn't say", which is not the same claim as "served locally".
|
|
1084
|
+
source: headers["x-blob-source"]
|
|
1057
1085
|
};
|
|
1058
1086
|
}
|
|
1059
1087
|
// ---- Alias Management ----
|