@ethersphere/bee-js 8.0.1 → 8.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/cjs/bee.js +31 -16
- package/dist/cjs/feed/index.js +2 -1
- package/dist/cjs/feed/json.js +1 -1
- package/dist/cjs/feed/retrievable.js +1 -1
- package/dist/cjs/modules/debug/status.js +3 -4
- package/dist/cjs/modules/pinning.js +1 -1
- package/dist/cjs/utils/error.js +4 -1
- package/dist/cjs/utils/file.js +2 -2
- package/dist/cjs/utils/http.js +1 -1
- package/dist/cjs/utils/type.js +0 -3
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee.js +35 -16
- package/dist/mjs/feed/index.js +2 -1
- package/dist/mjs/feed/json.js +3 -1
- package/dist/mjs/feed/retrievable.js +1 -1
- package/dist/mjs/modules/debug/status.js +2 -3
- package/dist/mjs/modules/pinning.js +1 -1
- package/dist/mjs/utils/error.js +4 -1
- package/dist/mjs/utils/file.js +2 -2
- package/dist/mjs/utils/http.js +1 -1
- package/dist/mjs/utils/type.js +0 -3
- package/dist/types/bee.d.ts +4 -4
- package/dist/types/modules/debug/status.d.ts +2 -3
- package/dist/types/types/index.d.ts +0 -1
- package/dist/types/utils/error.d.ts +4 -1
- package/package.json +12 -15
package/dist/cjs/bee.js
CHANGED
|
@@ -104,8 +104,10 @@ class Bee {
|
|
|
104
104
|
async uploadData(postageBatchId, data, options, requestOptions) {
|
|
105
105
|
(0, type_2.assertBatchId)(postageBatchId);
|
|
106
106
|
(0, type_2.assertData)(data);
|
|
107
|
-
|
|
107
|
+
(0, type_2.assertRequestOptions)(requestOptions);
|
|
108
|
+
if (options) {
|
|
108
109
|
(0, type_2.assertUploadOptions)(options);
|
|
110
|
+
}
|
|
109
111
|
return bytes.upload(this.getRequestOptionsForCall(requestOptions), data, postageBatchId, options);
|
|
110
112
|
}
|
|
111
113
|
/**
|
|
@@ -151,6 +153,7 @@ class Bee {
|
|
|
151
153
|
*/
|
|
152
154
|
async uploadChunk(postageBatchId, data, options, requestOptions) {
|
|
153
155
|
(0, type_2.assertBatchId)(postageBatchId);
|
|
156
|
+
(0, type_2.assertRequestOptions)(requestOptions);
|
|
154
157
|
if (!(data instanceof Uint8Array)) {
|
|
155
158
|
throw new TypeError('Data has to be Uint8Array instance!');
|
|
156
159
|
}
|
|
@@ -160,8 +163,9 @@ class Bee {
|
|
|
160
163
|
if (data.length > types_1.CHUNK_SIZE + types_1.SPAN_SIZE) {
|
|
161
164
|
throw new error_1.BeeArgumentError(`Chunk has to have size of at most ${types_1.CHUNK_SIZE}.`, data);
|
|
162
165
|
}
|
|
163
|
-
if (options)
|
|
166
|
+
if (options) {
|
|
164
167
|
(0, type_2.assertUploadOptions)(options);
|
|
168
|
+
}
|
|
165
169
|
return chunk.upload(this.getRequestOptionsForCall(requestOptions), data, postageBatchId, options);
|
|
166
170
|
}
|
|
167
171
|
/**
|
|
@@ -190,6 +194,7 @@ class Bee {
|
|
|
190
194
|
* @returns A promise that resolves to a `GranteesResult` object.
|
|
191
195
|
*/
|
|
192
196
|
async createGrantees(postageBatchId, grantees, requestOptions) {
|
|
197
|
+
(0, type_2.assertRequestOptions)(requestOptions);
|
|
193
198
|
(0, type_2.assertBatchId)(postageBatchId);
|
|
194
199
|
return grantee.createGrantees(this.getRequestOptionsForCall(requestOptions), postageBatchId, grantees);
|
|
195
200
|
}
|
|
@@ -201,6 +206,7 @@ class Bee {
|
|
|
201
206
|
* @returns A promise that resolves to a `GetGranteesResult` object.
|
|
202
207
|
*/
|
|
203
208
|
async getGrantees(reference, requestOptions) {
|
|
209
|
+
(0, type_2.assertRequestOptions)(requestOptions);
|
|
204
210
|
return grantee.getGrantees(reference, this.getRequestOptionsForCall(requestOptions));
|
|
205
211
|
}
|
|
206
212
|
/**
|
|
@@ -214,6 +220,7 @@ class Bee {
|
|
|
214
220
|
* @returns A Promise that resolves to to a `GranteesResult` object.
|
|
215
221
|
*/
|
|
216
222
|
async patchGrantees(postageBatchId, reference, history, grantees, requestOptions) {
|
|
223
|
+
(0, type_2.assertRequestOptions)(requestOptions);
|
|
217
224
|
(0, type_2.assertBatchId)(postageBatchId);
|
|
218
225
|
return grantee.patchGrantees(postageBatchId, reference, history, { add: grantees.add || [], revoke: grantees.revoke || [] }, this.getRequestOptionsForCall(requestOptions));
|
|
219
226
|
}
|
|
@@ -234,10 +241,12 @@ class Bee {
|
|
|
234
241
|
* @returns reference is a content hash of the file
|
|
235
242
|
*/
|
|
236
243
|
async uploadFile(postageBatchId, data, name, options, requestOptions) {
|
|
244
|
+
(0, type_2.assertRequestOptions)(requestOptions);
|
|
237
245
|
(0, type_2.assertBatchId)(postageBatchId);
|
|
238
246
|
(0, type_2.assertFileData)(data);
|
|
239
|
-
if (options)
|
|
247
|
+
if (options) {
|
|
240
248
|
(0, type_2.assertFileUploadOptions)(options);
|
|
249
|
+
}
|
|
241
250
|
if (name && typeof name !== 'string') {
|
|
242
251
|
throw new TypeError('name has to be string or undefined!');
|
|
243
252
|
}
|
|
@@ -309,9 +318,11 @@ class Bee {
|
|
|
309
318
|
* @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post)
|
|
310
319
|
*/
|
|
311
320
|
async uploadFiles(postageBatchId, fileList, options, requestOptions) {
|
|
321
|
+
(0, type_2.assertRequestOptions)(requestOptions);
|
|
312
322
|
(0, type_2.assertBatchId)(postageBatchId);
|
|
313
|
-
if (options)
|
|
323
|
+
if (options) {
|
|
314
324
|
(0, type_2.assertCollectionUploadOptions)(options);
|
|
325
|
+
}
|
|
315
326
|
const data = await (0, collection_1.makeCollectionFromFileList)(fileList);
|
|
316
327
|
return (0, type_2.addCidConversionFunction)(await bzz.uploadCollection(this.getRequestOptionsForCall(requestOptions), data, postageBatchId, options), swarm_cid_1.ReferenceType.MANIFEST);
|
|
317
328
|
}
|
|
@@ -325,12 +336,13 @@ class Bee {
|
|
|
325
336
|
* @param collection
|
|
326
337
|
* @param options Collections and request options
|
|
327
338
|
*/
|
|
328
|
-
async uploadCollection(postageBatchId, collection, options) {
|
|
339
|
+
async uploadCollection(postageBatchId, collection, options, requestOptions) {
|
|
340
|
+
(0, type_2.assertRequestOptions)(requestOptions);
|
|
329
341
|
(0, type_2.assertBatchId)(postageBatchId);
|
|
330
342
|
(0, collection_1.assertCollection)(collection);
|
|
331
343
|
if (options)
|
|
332
344
|
(0, type_2.assertCollectionUploadOptions)(options);
|
|
333
|
-
return (0, type_2.addCidConversionFunction)(await bzz.uploadCollection(this.requestOptions, collection, postageBatchId, options), swarm_cid_1.ReferenceType.MANIFEST);
|
|
345
|
+
return (0, type_2.addCidConversionFunction)(await bzz.uploadCollection(this.getRequestOptionsForCall(this.requestOptions), collection, postageBatchId, options), swarm_cid_1.ReferenceType.MANIFEST);
|
|
334
346
|
}
|
|
335
347
|
/**
|
|
336
348
|
* Upload collection of files.
|
|
@@ -350,6 +362,7 @@ class Bee {
|
|
|
350
362
|
*/
|
|
351
363
|
async uploadFilesFromDirectory(postageBatchId, dir, options, requestOptions) {
|
|
352
364
|
(0, type_2.assertBatchId)(postageBatchId);
|
|
365
|
+
(0, type_2.assertRequestOptions)(requestOptions);
|
|
353
366
|
if (options)
|
|
354
367
|
(0, type_2.assertCollectionUploadOptions)(options);
|
|
355
368
|
const data = await (0, collection_node_1.makeCollectionFromFS)(dir);
|
|
@@ -378,10 +391,10 @@ class Bee {
|
|
|
378
391
|
* @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
|
|
379
392
|
* @see [Bee API reference - `GET /tags`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags/get)
|
|
380
393
|
*/
|
|
381
|
-
async getAllTags(options) {
|
|
382
|
-
(0, type_2.assertRequestOptions)(
|
|
394
|
+
async getAllTags(options, requestOptions) {
|
|
395
|
+
(0, type_2.assertRequestOptions)(requestOptions);
|
|
383
396
|
(0, type_2.assertAllTagsOptions)(options);
|
|
384
|
-
return tag.getAllTags(this.getRequestOptionsForCall(
|
|
397
|
+
return tag.getAllTags(this.getRequestOptionsForCall(requestOptions), options?.offset, options?.limit);
|
|
385
398
|
}
|
|
386
399
|
/**
|
|
387
400
|
* Retrieve tag information from Bee node
|
|
@@ -544,7 +557,7 @@ class Bee {
|
|
|
544
557
|
return true;
|
|
545
558
|
}
|
|
546
559
|
catch (e) {
|
|
547
|
-
if (e?.
|
|
560
|
+
if (e?.status === 404 || e?.status === 500) {
|
|
548
561
|
return false;
|
|
549
562
|
}
|
|
550
563
|
throw e;
|
|
@@ -776,7 +789,7 @@ class Bee {
|
|
|
776
789
|
* @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
|
|
777
790
|
*/
|
|
778
791
|
async setJsonFeed(postageBatchId, topic, data, options, requestOptions) {
|
|
779
|
-
(0, type_2.assertRequestOptions)(
|
|
792
|
+
(0, type_2.assertRequestOptions)(requestOptions, 'JsonFeedOptions');
|
|
780
793
|
(0, type_2.assertBatchId)(postageBatchId);
|
|
781
794
|
const hashedTopic = this.makeFeedTopic(topic);
|
|
782
795
|
const feedType = options?.type ?? type_1.DEFAULT_FEED_TYPE;
|
|
@@ -802,8 +815,8 @@ class Bee {
|
|
|
802
815
|
*
|
|
803
816
|
* @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
|
|
804
817
|
*/
|
|
805
|
-
async getJsonFeed(topic, options) {
|
|
806
|
-
(0, type_2.assertRequestOptions)(
|
|
818
|
+
async getJsonFeed(topic, options, requestOptions) {
|
|
819
|
+
(0, type_2.assertRequestOptions)(requestOptions);
|
|
807
820
|
const hashedTopic = this.makeFeedTopic(topic);
|
|
808
821
|
const feedType = options?.type ?? type_1.DEFAULT_FEED_TYPE;
|
|
809
822
|
if (options?.signer && options?.address) {
|
|
@@ -826,7 +839,7 @@ class Bee {
|
|
|
826
839
|
}
|
|
827
840
|
}
|
|
828
841
|
}
|
|
829
|
-
const reader = this.makeFeedReader(feedType, hashedTopic, address,
|
|
842
|
+
const reader = this.makeFeedReader(feedType, hashedTopic, address, requestOptions);
|
|
830
843
|
return (0, json_1.getJsonData)(this, reader);
|
|
831
844
|
}
|
|
832
845
|
/**
|
|
@@ -1044,6 +1057,7 @@ class Bee {
|
|
|
1044
1057
|
async cashoutLastCheque(address, options, requestOptions) {
|
|
1045
1058
|
(0, type_2.assertCashoutOptions)(options);
|
|
1046
1059
|
(0, type_2.assertAddress)(address);
|
|
1060
|
+
(0, type_2.assertRequestOptions)(requestOptions);
|
|
1047
1061
|
return chequebook.cashoutLastCheque(this.getRequestOptionsForCall(requestOptions), address, options);
|
|
1048
1062
|
}
|
|
1049
1063
|
/**
|
|
@@ -1226,6 +1240,7 @@ class Bee {
|
|
|
1226
1240
|
(0, type_2.assertPostageBatchOptions)(options);
|
|
1227
1241
|
(0, type_2.assertPositiveInteger)(amount);
|
|
1228
1242
|
(0, type_2.assertNonNegativeInteger)(depth);
|
|
1243
|
+
(0, type_2.assertRequestOptions)(requestOptions);
|
|
1229
1244
|
if (depth < types_1.STAMPS_DEPTH_MIN) {
|
|
1230
1245
|
throw new error_1.BeeArgumentError(`Depth has to be at least ${types_1.STAMPS_DEPTH_MIN}`, depth);
|
|
1231
1246
|
}
|
|
@@ -1385,8 +1400,8 @@ class Bee {
|
|
|
1385
1400
|
* @param options
|
|
1386
1401
|
*/
|
|
1387
1402
|
async depositStake(amount, options, requestOptions) {
|
|
1388
|
-
(0, type_2.assertRequestOptions)(options);
|
|
1389
1403
|
(0, type_2.assertTransactionOptions)(options);
|
|
1404
|
+
(0, type_2.assertRequestOptions)(requestOptions);
|
|
1390
1405
|
await stake.stake(this.getRequestOptionsForCall(requestOptions), amount, options);
|
|
1391
1406
|
}
|
|
1392
1407
|
/**
|
|
@@ -1424,7 +1439,7 @@ class Bee {
|
|
|
1424
1439
|
if (this.signer) {
|
|
1425
1440
|
return this.signer;
|
|
1426
1441
|
}
|
|
1427
|
-
throw new
|
|
1442
|
+
throw new TypeError('You have to pass Signer as property to either the method call or constructor! Non found.');
|
|
1428
1443
|
}
|
|
1429
1444
|
getRequestOptionsForCall(options) {
|
|
1430
1445
|
return options ? cafe_utility_1.Objects.deepMerge2(this.requestOptions, options) : this.requestOptions;
|
package/dist/cjs/feed/index.js
CHANGED
|
@@ -30,6 +30,7 @@ const chunkAPI = __importStar(require("../modules/chunk"));
|
|
|
30
30
|
const feed_1 = require("../modules/feed");
|
|
31
31
|
const types_1 = require("../types");
|
|
32
32
|
const bytes_1 = require("../utils/bytes");
|
|
33
|
+
const error_1 = require("../utils/error");
|
|
33
34
|
const eth_1 = require("../utils/eth");
|
|
34
35
|
const hash_1 = require("../utils/hash");
|
|
35
36
|
const hex_1 = require("../utils/hex");
|
|
@@ -45,7 +46,7 @@ async function findNextIndex(requestOptions, owner, topic, options) {
|
|
|
45
46
|
return (0, hex_1.makeHexString)(feedUpdate.feedIndexNext, types_1.FEED_INDEX_HEX_LENGTH);
|
|
46
47
|
}
|
|
47
48
|
catch (e) {
|
|
48
|
-
if (e
|
|
49
|
+
if (e instanceof error_1.BeeResponseError) {
|
|
49
50
|
return (0, hex_1.bytesToHex)((0, bytes_1.makeBytes)(8));
|
|
50
51
|
}
|
|
51
52
|
throw e;
|
package/dist/cjs/feed/json.js
CHANGED
|
@@ -23,6 +23,6 @@ exports.getJsonData = getJsonData;
|
|
|
23
23
|
async function setJsonData(bee, writer, postageBatchId, data, options, requestOptions) {
|
|
24
24
|
const serializedData = serializeJson(data);
|
|
25
25
|
const { reference } = await bee.uploadData(postageBatchId, serializedData, options, requestOptions);
|
|
26
|
-
return writer.upload(postageBatchId, reference);
|
|
26
|
+
return writer.upload(postageBatchId, reference, { pin: options?.pin });
|
|
27
27
|
}
|
|
28
28
|
exports.setJsonData = setJsonData;
|
|
@@ -3,14 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getVersions = exports.isSupportedApiVersion = exports.isSupportedMainApiVersion = exports.isSupportedExactVersion = exports.isSupportedVersion = exports.getNodeInfo = exports.getReadiness = exports.getHealth = exports.getDebugStatus = exports.SUPPORTED_BEE_VERSION = exports.
|
|
6
|
+
exports.getVersions = exports.isSupportedApiVersion = exports.isSupportedMainApiVersion = exports.isSupportedExactVersion = exports.isSupportedVersion = exports.getNodeInfo = exports.getReadiness = exports.getHealth = exports.getDebugStatus = exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_API_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT = void 0;
|
|
7
7
|
const major_js_1 = __importDefault(require("semver/functions/major.js"));
|
|
8
8
|
const http_1 = require("../../utils/http");
|
|
9
9
|
// Following lines bellow are automatically updated with GitHub Action when Bee version is updated
|
|
10
10
|
// so if you are changing anything about them change the `update_bee` action accordingly!
|
|
11
|
-
exports.SUPPORTED_BEE_VERSION_EXACT = '
|
|
12
|
-
exports.SUPPORTED_API_VERSION = '
|
|
13
|
-
exports.SUPPORTED_DEBUG_API_VERSION = '4.0.0';
|
|
11
|
+
exports.SUPPORTED_BEE_VERSION_EXACT = '2.2.0-06a0aca7';
|
|
12
|
+
exports.SUPPORTED_API_VERSION = '7.1.0';
|
|
14
13
|
exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT.split('-')[0];
|
|
15
14
|
const NODE_INFO_URL = 'node';
|
|
16
15
|
const STATUS_URL = 'status';
|
package/dist/cjs/utils/error.js
CHANGED
|
@@ -15,8 +15,11 @@ class BeeArgumentError extends BeeError {
|
|
|
15
15
|
}
|
|
16
16
|
exports.BeeArgumentError = BeeArgumentError;
|
|
17
17
|
class BeeResponseError extends BeeError {
|
|
18
|
-
constructor(message, status, statusText) {
|
|
18
|
+
constructor(method, url, message, responseBody, status, statusText) {
|
|
19
19
|
super(message);
|
|
20
|
+
this.method = method;
|
|
21
|
+
this.url = url;
|
|
22
|
+
this.responseBody = responseBody;
|
|
20
23
|
this.status = status;
|
|
21
24
|
this.statusText = statusText;
|
|
22
25
|
}
|
package/dist/cjs/utils/file.js
CHANGED
|
@@ -8,8 +8,8 @@ exports.fileArrayBuffer = exports.isFile = void 0;
|
|
|
8
8
|
*/
|
|
9
9
|
function isFile(file) {
|
|
10
10
|
// browser
|
|
11
|
-
if (typeof File === 'function') {
|
|
12
|
-
return
|
|
11
|
+
if (typeof File === 'function' && file instanceof File) {
|
|
12
|
+
return true;
|
|
13
13
|
}
|
|
14
14
|
// node.js
|
|
15
15
|
const f = file;
|
package/dist/cjs/utils/http.js
CHANGED
|
@@ -35,7 +35,7 @@ async function http(options, config) {
|
|
|
35
35
|
}
|
|
36
36
|
catch (e) {
|
|
37
37
|
if (e instanceof AxiosError) {
|
|
38
|
-
throw new index_1.BeeResponseError(e.message, e.status, e.code);
|
|
38
|
+
throw new index_1.BeeResponseError(config.method || 'get', config.url || '<unknown>', e.message, e.response?.data, e.response?.status, e.code);
|
|
39
39
|
}
|
|
40
40
|
throw e;
|
|
41
41
|
}
|
package/dist/cjs/utils/type.js
CHANGED
|
@@ -182,9 +182,6 @@ function assertRequestOptions(value, name = 'RequestOptions') {
|
|
|
182
182
|
throw new TypeError(`${name} has to be an object!`);
|
|
183
183
|
}
|
|
184
184
|
const options = value;
|
|
185
|
-
if (options.retry) {
|
|
186
|
-
assertNonNegativeInteger(options.retry, `${name}.retry`);
|
|
187
|
-
}
|
|
188
185
|
if (options.timeout) {
|
|
189
186
|
assertNonNegativeInteger(options.timeout, `${name}.timeout`);
|
|
190
187
|
}
|