@upcoming/bee-js 0.3.0 → 0.5.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.
Files changed (62) hide show
  1. package/dist/cjs/bee-dev.js +78 -0
  2. package/dist/cjs/bee.js +69 -113
  3. package/dist/cjs/feed/retrievable.js +4 -4
  4. package/dist/cjs/index.js +3 -1
  5. package/dist/cjs/modules/bytes.js +12 -4
  6. package/dist/cjs/modules/bzz.js +12 -27
  7. package/dist/cjs/modules/chunk.js +6 -3
  8. package/dist/cjs/modules/debug/connectivity.js +2 -1
  9. package/dist/cjs/modules/feed.js +1 -1
  10. package/dist/cjs/modules/grantee.js +9 -8
  11. package/dist/cjs/modules/pss.js +1 -1
  12. package/dist/cjs/modules/soc.js +4 -2
  13. package/dist/cjs/utils/collection.js +1 -1
  14. package/dist/cjs/utils/collection.node.js +0 -1
  15. package/dist/cjs/utils/expose.js +2 -1
  16. package/dist/cjs/utils/headers.js +61 -54
  17. package/dist/cjs/utils/http.js +9 -0
  18. package/dist/cjs/utils/tar-uploader.browser.js +2 -2
  19. package/dist/cjs/utils/tar-uploader.js +2 -2
  20. package/dist/cjs/utils/type.js +119 -191
  21. package/dist/index.browser.min.js +1 -1
  22. package/dist/index.browser.min.js.map +1 -1
  23. package/dist/mjs/bee-dev.js +98 -0
  24. package/dist/mjs/bee.js +75 -117
  25. package/dist/mjs/feed/retrievable.js +4 -4
  26. package/dist/mjs/index.js +2 -1
  27. package/dist/mjs/modules/bytes.js +13 -7
  28. package/dist/mjs/modules/bzz.js +9 -25
  29. package/dist/mjs/modules/chunk.js +7 -6
  30. package/dist/mjs/modules/debug/connectivity.js +1 -1
  31. package/dist/mjs/modules/feed.js +2 -2
  32. package/dist/mjs/modules/grantee.js +12 -11
  33. package/dist/mjs/modules/pss.js +2 -2
  34. package/dist/mjs/modules/soc.js +4 -4
  35. package/dist/mjs/utils/collection.js +1 -1
  36. package/dist/mjs/utils/collection.node.js +0 -1
  37. package/dist/mjs/utils/expose.js +1 -1
  38. package/dist/mjs/utils/headers.js +59 -50
  39. package/dist/mjs/utils/http.js +9 -0
  40. package/dist/mjs/utils/tar-uploader.browser.js +2 -2
  41. package/dist/mjs/utils/tar-uploader.js +2 -2
  42. package/dist/mjs/utils/type.js +202 -163
  43. package/dist/types/bee-dev.d.ts +5 -0
  44. package/dist/types/bee.d.ts +21 -21
  45. package/dist/types/feed/retrievable.d.ts +2 -2
  46. package/dist/types/index.d.ts +3 -1
  47. package/dist/types/modules/bytes.d.ts +4 -4
  48. package/dist/types/modules/bzz.d.ts +5 -10
  49. package/dist/types/modules/chunk.d.ts +2 -2
  50. package/dist/types/modules/debug/chequebook.d.ts +2 -2
  51. package/dist/types/modules/debug/connectivity.d.ts +2 -1
  52. package/dist/types/modules/grantee.d.ts +4 -4
  53. package/dist/types/types/debug.d.ts +0 -1
  54. package/dist/types/types/index.d.ts +12 -6
  55. package/dist/types/utils/collection.d.ts +1 -1
  56. package/dist/types/utils/collection.node.d.ts +0 -1
  57. package/dist/types/utils/expose.d.ts +1 -1
  58. package/dist/types/utils/headers.d.ts +2 -4
  59. package/dist/types/utils/tar-uploader.browser.d.ts +2 -2
  60. package/dist/types/utils/tar-uploader.d.ts +2 -2
  61. package/dist/types/utils/type.d.ts +12 -18
  62. package/package.json +2 -2
@@ -1,8 +1,8 @@
1
1
  import { Types } from 'cafe-utility';
2
2
  import * as stream from 'stream';
3
3
  import { TAGS_LIMIT_MAX, TAGS_LIMIT_MIN } from "../types/index.js";
4
- import { BeeArgumentError } from "./error.js";
5
4
  import { isFile } from "./file.js";
5
+ import { PublicKey, Reference } from "./typed-bytes.js";
6
6
  export function isReadable(obj) {
7
7
  return typeof stream.Readable !== 'undefined' && obj instanceof stream.Readable;
8
8
  }
@@ -12,153 +12,204 @@ export function asNumberString(value, options) {
12
12
  }
13
13
  return Types.asIntegerString(value, options);
14
14
  }
15
- export function isInteger(value) {
16
- return typeof value === 'string' && /^-?(0|[1-9][0-9]*)$/g.test(value) || typeof value === 'number' && value > Number.MIN_SAFE_INTEGER && value < Number.MAX_SAFE_INTEGER && Number.isInteger(value);
17
- }
18
- export function isObject(value) {
19
- return value !== null && typeof value === 'object';
20
- }
21
- export function isStrictlyObject(value) {
22
- return isObject(value) && !Array.isArray(value);
23
- }
24
- export function assertStrictlyObject(value, name = 'value') {
25
- if (!isStrictlyObject(value)) {
26
- throw new TypeError(`${name} has to be an object that is not null nor array!`);
27
- }
28
- }
29
- export function assertBoolean(value, name = 'value') {
30
- if (value !== true && value !== false) throw new TypeError(`${name} is not boolean`);
31
- }
32
- export function assertInteger(value, name = 'value') {
33
- if (!isInteger(value)) throw new TypeError(`${name} is not integer`);
15
+ export function prepareBeeRequestOptions(value) {
16
+ const object = Types.asObject(value, {
17
+ name: 'BeeRequestOptions'
18
+ });
19
+ return {
20
+ baseURL: Types.asOptional(x => Types.asString(x, {
21
+ name: 'baseURL'
22
+ }), object.baseURL),
23
+ timeout: Types.asOptional(x => Types.asInteger(x, {
24
+ name: 'timeout',
25
+ min: 0
26
+ }), object.timeout),
27
+ headers: Types.asOptional(x => Types.asStringMap(x, {
28
+ name: 'headers'
29
+ }), object.headers),
30
+ onRequest: Types.asOptional(x => Types.asFunction(x, {
31
+ name: 'onRequest'
32
+ }), object.onRequest),
33
+ httpAgent: object.httpAgent,
34
+ httpsAgent: object.httpsAgent,
35
+ endlesslyRetry: Types.asOptional(x => Types.asBoolean(x, {
36
+ name: 'endlesslyRetry'
37
+ }), object.endlesslyRetry)
38
+ };
34
39
  }
35
- export function assertNonNegativeInteger(value, name = 'Value') {
36
- assertInteger(value, name);
37
- if (Number(value) < 0) throw new BeeArgumentError(`${name} has to be bigger or equal to zero`, value);
40
+ export function prepareDownloadOptions(value) {
41
+ const object = Types.asObject(value, {
42
+ name: 'DownloadOptions'
43
+ });
44
+ return {
45
+ redundancyStrategy: Types.asOptional(x => Types.asInteger(x, {
46
+ name: 'redundancyStrategy'
47
+ }), object.redundancyStrategy),
48
+ fallback: Types.asOptional(x => Types.asBoolean(x, {
49
+ name: 'fallback'
50
+ }), object.fallback),
51
+ timeoutMs: Types.asOptional(x => Types.asInteger(x, {
52
+ name: 'timeoutMs',
53
+ min: 0
54
+ }), object.timeoutMs),
55
+ actPublisher: Types.asOptional(x => new PublicKey(x), object.actPublisher),
56
+ actHistoryAddress: Types.asOptional(x => new Reference(x), object.actHistoryAddress),
57
+ actTimestamp: Types.asOptional(x => Types.asNumber(x, {
58
+ name: 'actTimestamp'
59
+ }), object.actTimestamp)
60
+ };
38
61
  }
39
- export function assertRequestOptions(value, name = 'RequestOptions') {
40
- if (value === undefined) {
41
- return;
42
- }
43
- if (!isStrictlyObject(value)) {
44
- throw new TypeError(`${name} has to be an object!`);
45
- }
46
- const options = value;
47
- if (options.timeout) {
48
- assertNonNegativeInteger(options.timeout, `${name}.timeout`);
49
- }
62
+ export function prepareUploadOptions(value, name = 'UploadOptions') {
63
+ const object = Types.asObject(value, {
64
+ name
65
+ });
66
+ return {
67
+ act: Types.asOptional(x => Types.asBoolean(x, {
68
+ name: 'act'
69
+ }), object.act),
70
+ deferred: Types.asOptional(x => Types.asBoolean(x, {
71
+ name: 'deferred'
72
+ }), object.deferred),
73
+ encrypt: Types.asOptional(x => Types.asBoolean(x, {
74
+ name: 'encrypt'
75
+ }), object.encrypt),
76
+ pin: Types.asOptional(x => Types.asBoolean(x, {
77
+ name: 'pin'
78
+ }), object.pin),
79
+ tag: Types.asOptional(x => Types.asInteger(x, {
80
+ name: 'tag',
81
+ min: 0
82
+ }), object.tag)
83
+ };
50
84
  }
51
- export function assertUploadOptions(value, name = 'UploadOptions') {
52
- if (!isStrictlyObject(value)) {
53
- throw new TypeError(`${name} has to be an object!`);
54
- }
55
- assertRequestOptions(value, name);
56
- const options = value;
57
- if (options.pin && typeof options.pin !== 'boolean') {
58
- throw new TypeError(`options.pin property in ${name} has to be boolean or undefined!`);
59
- }
60
- if (options.encrypt && typeof options.encrypt !== 'boolean') {
61
- throw new TypeError(`options.encrypt property in ${name} has to be boolean or undefined!`);
62
- }
63
- if (options.tag) {
64
- if (typeof options.tag !== 'number') {
65
- throw new TypeError(`options.tag property in ${name} has to be number or undefined!`);
66
- }
67
- assertNonNegativeInteger(options.tag, 'options.tag');
68
- }
85
+ export function prepareRedundantUploadOptions(value, name = 'UploadOptions') {
86
+ const uploadOptions = prepareUploadOptions(value, name);
87
+ const object = Types.asObject(value, {
88
+ name
89
+ });
90
+ return {
91
+ ...uploadOptions,
92
+ redundancyLevel: Types.asOptional(x => Types.asInteger(x, {
93
+ name: 'redundancyLevel',
94
+ min: 0
95
+ }), object.redundancyLevel)
96
+ };
69
97
  }
70
- export function assertFileUploadOptions(value) {
71
- assertUploadOptions(value, 'FileUploadOptions');
72
- const options = value;
73
- if (options.size) {
74
- if (typeof options.size !== 'number') {
75
- throw new TypeError('tag property in FileUploadOptions has to be number or undefined!');
76
- }
77
- assertNonNegativeInteger(options.size, 'options.size');
78
- }
79
- if (options.contentType && typeof options.contentType !== 'string') {
80
- throw new TypeError('contentType property in FileUploadOptions has to be string or undefined!');
81
- }
98
+ export function prepareFileUploadOptions(value) {
99
+ const uploadOptions = prepareUploadOptions(value, 'FileUploadOptions');
100
+ const object = Types.asObject(value, {
101
+ name: 'FileUploadOptions'
102
+ });
103
+ return {
104
+ ...uploadOptions,
105
+ size: Types.asOptional(x => Types.asInteger(x, {
106
+ name: 'size',
107
+ min: 0
108
+ }), object.size),
109
+ contentType: Types.asOptional(x => Types.asString(x, {
110
+ name: 'contentType'
111
+ }), object.contentType),
112
+ redundancyLevel: Types.asOptional(x => Types.asInteger(x, {
113
+ name: 'redundancyLevel',
114
+ min: 0
115
+ }), object.redundancyLevel)
116
+ };
82
117
  }
83
- export function assertCollectionUploadOptions(value) {
84
- assertUploadOptions(value, 'CollectionUploadOptions');
85
- const options = value;
86
- if (options.indexDocument && typeof options.indexDocument !== 'string') {
87
- throw new TypeError('indexDocument property in CollectionUploadOptions has to be string or undefined!');
88
- }
89
- if (options.errorDocument && typeof options.errorDocument !== 'string') {
90
- throw new TypeError('errorDocument property in CollectionUploadOptions has to be string or undefined!');
91
- }
118
+ export function prepareCollectionUploadOptions(value) {
119
+ const uploadOptions = prepareUploadOptions(value, 'CollectionUploadOptions');
120
+ const object = Types.asObject(value, {
121
+ name: 'CollectionUploadOptions'
122
+ });
123
+ return {
124
+ ...uploadOptions,
125
+ errorDocument: Types.asOptional(x => Types.asString(x, {
126
+ name: 'errorDocument'
127
+ }), object.errorDocument),
128
+ indexDocument: Types.asOptional(x => Types.asString(x, {
129
+ name: 'indexDocument'
130
+ }), object.indexDocument),
131
+ redundancyLevel: Types.asOptional(x => Types.asInteger(x, {
132
+ name: 'redundancyLevel',
133
+ min: 0
134
+ }), object.redundancyLevel)
135
+ };
92
136
  }
93
137
  export function isTag(value) {
94
- if (!isStrictlyObject(value)) {
138
+ try {
139
+ const object = Types.asObject(value, {
140
+ name: 'Tag'
141
+ });
142
+ Types.asInteger(object.uid, {
143
+ name: 'Tag.uid'
144
+ });
145
+ return true;
146
+ } catch {
95
147
  return false;
96
148
  }
97
- return Boolean(value.uid);
98
149
  }
99
- export function assertPssMessageHandler(value) {
150
+ export function preparePssMessageHandler(value) {
100
151
  const object = Types.asObject(value, {
101
152
  name: 'PssMessageHandler'
102
153
  });
103
- Types.asFunction(object.onMessage, {
104
- name: 'onMessage'
105
- });
106
- Types.asFunction(object.onError, {
107
- name: 'onError'
108
- });
154
+ return {
155
+ onMessage: Types.asFunction(object.onMessage, {
156
+ name: 'onMessage'
157
+ }),
158
+ onError: Types.asFunction(object.onError, {
159
+ name: 'onError'
160
+ })
161
+ };
109
162
  }
110
- export function assertGsocMessageHandler(value) {
163
+ export function prepareGsocMessageHandler(value) {
111
164
  const object = Types.asObject(value, {
112
165
  name: 'GsocMessageHandler'
113
166
  });
114
- Types.asFunction(object.onMessage, {
115
- name: 'onMessage'
116
- });
117
- Types.asFunction(object.onError, {
118
- name: 'onError'
119
- });
120
- }
121
- export function assertPostageBatchOptions(value) {
122
- if (value === undefined) {
123
- return;
124
- }
125
- assertStrictlyObject(value);
126
- const options = value;
127
- assertRequestOptions(options, 'PostageBatchOptions');
128
- if (options?.gasPrice) {
129
- assertNonNegativeInteger(options.gasPrice);
130
- }
131
- if (options?.immutableFlag !== undefined) {
132
- assertBoolean(options.immutableFlag);
133
- }
134
- if (options?.waitForUsable !== undefined) {
135
- assertBoolean(options.waitForUsable);
136
- }
137
- if (options?.waitForUsableTimeout !== undefined) {
138
- assertNonNegativeInteger(options.waitForUsableTimeout, 'options.waitForUsableTimeout');
139
- }
167
+ return {
168
+ onMessage: Types.asFunction(object.onMessage, {
169
+ name: 'onMessage'
170
+ }),
171
+ onError: Types.asFunction(object.onError, {
172
+ name: 'onError'
173
+ })
174
+ };
140
175
  }
141
- export function assertTransactionOptions(value, name = 'TransactionOptions') {
142
- if (value === undefined) {
143
- return;
144
- }
145
- assertStrictlyObject(value, name);
146
- const options = value;
147
- if (options?.gasLimit) {
148
- assertNonNegativeInteger(options.gasLimit, name);
149
- }
150
- if (options?.gasPrice) {
151
- assertNonNegativeInteger(options.gasPrice, name);
152
- }
176
+ export function preparePostageBatchOptions(value) {
177
+ const object = Types.asObject(value, {
178
+ name: 'PostageBatchOptions'
179
+ });
180
+ return {
181
+ gasPrice: Types.asOptional(x => asNumberString(x, {
182
+ name: 'gasPrice'
183
+ }), object.gasPrice),
184
+ immutableFlag: Types.asOptional(x => Types.asBoolean(x, {
185
+ name: 'immutableFlag'
186
+ }), object.immutableFlag),
187
+ label: Types.asOptional(x => Types.asString(x, {
188
+ name: 'label'
189
+ }), object.label),
190
+ waitForUsable: Types.asOptional(x => Types.asBoolean(x, {
191
+ name: 'waitForUsable'
192
+ }), object.waitForUsable),
193
+ waitForUsableTimeout: Types.asOptional(x => Types.asInteger(x, {
194
+ name: 'waitForUsableTimeout',
195
+ min: 0
196
+ }), object.waitForUsableTimeout)
197
+ };
153
198
  }
154
- export function assertCashoutOptions(value) {
155
- if (value === undefined) {
156
- return;
157
- }
158
- assertStrictlyObject(value);
159
- const options = value;
160
- assertRequestOptions(options, 'CashoutOptions');
161
- assertTransactionOptions(options, 'CashoutOptions');
199
+ export function prepareTransactionOptions(value, name = 'TransactionOptions') {
200
+ const object = Types.asObject(value, {
201
+ name
202
+ });
203
+ return {
204
+ gasLimit: Types.asOptional(x => asNumberString(x, {
205
+ name: 'gasLimit',
206
+ min: 0n
207
+ }), object.gasLimit),
208
+ gasPrice: Types.asOptional(x => asNumberString(x, {
209
+ name: 'gasPrice',
210
+ min: 0n
211
+ }), object.gasPrice)
212
+ };
162
213
  }
163
214
  /**
164
215
  * Check whether the given parameter is valid data to upload
@@ -184,26 +235,21 @@ export function assertFileData(value) {
184
235
  * Checks whether optional options for AllTags query are valid
185
236
  * @param options
186
237
  */
187
- export function assertAllTagsOptions(entry) {
188
- if (entry !== undefined && !isStrictlyObject(entry)) {
189
- throw new TypeError('options has to be an object or undefined!');
190
- }
191
- assertRequestOptions(entry, 'AllTagsOptions');
192
- const options = entry;
193
- if (options?.limit !== undefined) {
194
- if (typeof options.limit !== 'number') {
195
- throw new TypeError('AllTagsOptions.limit has to be a number or undefined!');
196
- }
197
- if (options.limit < TAGS_LIMIT_MIN) {
198
- throw new BeeArgumentError(`AllTagsOptions.limit has to be at least ${TAGS_LIMIT_MIN}`, options.limit);
199
- }
200
- if (options.limit > TAGS_LIMIT_MAX) {
201
- throw new BeeArgumentError(`AllTagsOptions.limit has to be at most ${TAGS_LIMIT_MAX}`, options.limit);
202
- }
203
- }
204
- if (options?.offset !== undefined) {
205
- assertNonNegativeInteger(options.offset, 'AllTagsOptions.offset');
206
- }
238
+ export function prepareAllTagsOptions(value) {
239
+ const object = Types.asObject(value, {
240
+ name: 'AllTagsOptions'
241
+ });
242
+ return {
243
+ limit: Types.asOptional(x => Types.asInteger(x, {
244
+ name: 'limit',
245
+ min: TAGS_LIMIT_MIN,
246
+ max: TAGS_LIMIT_MAX
247
+ }), object.limit),
248
+ offset: Types.asOptional(x => Types.asInteger(x, {
249
+ name: 'offset',
250
+ min: 0
251
+ }), object.offset)
252
+ };
207
253
  }
208
254
  /**
209
255
  * Utility functions that return Tag UID
@@ -211,22 +257,15 @@ export function assertAllTagsOptions(entry) {
211
257
  */
212
258
  export function makeTagUid(tagUid) {
213
259
  if (tagUid === undefined || tagUid === null) {
214
- throw new TypeError('TagUid was expected but got undefined or null instead!');
260
+ throw new TypeError(`Expected number | Tag | string from tagUid, got: ${tagUid}`);
215
261
  }
216
262
  if (isTag(tagUid)) {
217
263
  return tagUid.uid;
218
- } else if (typeof tagUid === 'number') {
219
- assertNonNegativeInteger(tagUid, 'UID');
220
- return tagUid;
221
- } else if (typeof tagUid === 'string') {
222
- const int = parseInt(tagUid);
223
- if (isNaN(int)) {
224
- throw new TypeError('Passed tagUid string is not valid integer!');
225
- }
226
- if (int < 0) {
227
- throw new TypeError(`TagUid was expected to be positive non-negative integer! Got ${int}`);
228
- }
229
- return int;
264
+ } else if (typeof tagUid === 'number' || typeof tagUid === 'string') {
265
+ return Types.asNumber(tagUid, {
266
+ name: 'tagUid',
267
+ min: 0
268
+ });
230
269
  }
231
- throw new TypeError('tagUid has to be either Tag or a number (UID)!');
270
+ throw new TypeError(`Expected number | Tag | string from tagUid, got: ${tagUid}`);
232
271
  }
@@ -0,0 +1,5 @@
1
+ import { Bee, BeeRequestOptions, NodeAddresses, Topology } from '.';
2
+ export declare class BeeDev extends Bee {
3
+ getNodeAddresses(options?: BeeRequestOptions): Promise<NodeAddresses>;
4
+ getTopology(options?: BeeRequestOptions): Promise<Topology>;
5
+ }
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import { Readable } from 'stream';
3
3
  import { Chunk } from './chunk/cac';
4
- import type { AllSettlements, BalanceResponse, BeeOptions, BeeRequestOptions, BeeVersions, ChainState, ChequebookAddressResponse, ChequebookBalanceResponse, CollectionUploadOptions, DebugStatus, EnvelopeWithBatchId, FeedReader, FeedWriter, FileData, FileUploadOptions, GetGranteesResult, GlobalPostageBatch, GranteesResult, GsocMessageHandler, GsocSubscription, Health, LastCashoutActionResponse, LastChequesForPeerResponse, LastChequesResponse, NodeAddresses, NodeInfo, NumberString, Peer, PeerBalance, Pin, PingResponse, PostageBatch, PostageBatchBuckets, PssMessageHandler, PssSubscription, Readiness, RedistributionState, ReferenceInformation, RemovePeerResponse, ReserveState, SOCReader, SOCWriter, Settlements, Tag, Topology, TransactionInfo, UploadOptions, UploadRedundancyOptions, WalletBalance } from './types';
5
- import { AllTagsOptions, CashoutOptions, Collection, PostageBatchOptions, TransactionOptions, UploadResult } from './types';
4
+ import type { AllSettlements, BalanceResponse, BeeOptions, BeeRequestOptions, BeeVersions, ChainState, ChequebookAddressResponse, ChequebookBalanceResponse, CollectionUploadOptions, DebugStatus, DownloadOptions, EnvelopeWithBatchId, FeedReader, FeedWriter, FileData, FileUploadOptions, GetGranteesResult, GlobalPostageBatch, GranteesResult, GsocMessageHandler, GsocSubscription, Health, LastCashoutActionResponse, LastChequesForPeerResponse, LastChequesResponse, NodeAddresses, NodeInfo, NumberString, Peer, PeerBalance, Pin, PingResponse, PostageBatch, PostageBatchBuckets, PssMessageHandler, PssSubscription, Readiness, RedistributionState, RedundantUploadOptions, ReferenceInformation, RemovePeerResponse, ReserveState, SOCReader, SOCWriter, Settlements, Tag, Topology, TransactionInfo, UploadOptions, WalletBalance } from './types';
5
+ import { AllTagsOptions, Collection, PostageBatchOptions, TransactionOptions, UploadResult } from './types';
6
6
  import { Bytes } from './utils/bytes';
7
7
  import { BZZ } from './utils/tokens';
8
8
  import { BatchId, EthAddress, FeedIndex, Identifier, PeerAddress, PrivateKey, PublicKey, Reference, Topic, TransactionId } from './utils/typed-bytes';
@@ -43,7 +43,7 @@ export declare class Bee {
43
43
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
44
44
  * @see [Bee API reference - `POST /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes/post)
45
45
  */
46
- uploadData(postageBatchId: BatchId | Uint8Array | string, data: string | Uint8Array, options?: UploadOptions & UploadRedundancyOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>;
46
+ uploadData(postageBatchId: BatchId | Uint8Array | string, data: string | Uint8Array, options?: RedundantUploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>;
47
47
  /**
48
48
  * Requests content length for a `/bytes` reference
49
49
  *
@@ -60,7 +60,7 @@ export declare class Bee {
60
60
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
61
61
  * @see [Bee API reference - `GET /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1{reference}/get)
62
62
  */
63
- downloadData(reference: Reference | string | Uint8Array, options?: BeeRequestOptions): Promise<Bytes>;
63
+ downloadData(reference: Reference | string | Uint8Array, options?: DownloadOptions, requestOptions?: BeeRequestOptions): Promise<Bytes>;
64
64
  /**
65
65
  * Download data as a Readable stream
66
66
  *
@@ -71,7 +71,7 @@ export declare class Bee {
71
71
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
72
72
  * @see [Bee API reference - `GET /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1{reference}/get)
73
73
  */
74
- downloadReadableData(reference: Reference | Uint8Array | string, options?: BeeRequestOptions): Promise<ReadableStream<Uint8Array>>;
74
+ downloadReadableData(reference: Reference | Uint8Array | string, options?: DownloadOptions, requestOptions?: BeeRequestOptions): Promise<ReadableStream<Uint8Array>>;
75
75
  /**
76
76
  * Upload chunk to a Bee node
77
77
  *
@@ -94,7 +94,7 @@ export declare class Bee {
94
94
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
95
95
  * @see [Bee API reference - `GET /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks~1{address}/get)
96
96
  */
97
- downloadChunk(reference: Reference | Uint8Array | string, options?: BeeRequestOptions): Promise<Uint8Array>;
97
+ downloadChunk(reference: Reference | Uint8Array | string, options?: DownloadOptions, requestOptions?: BeeRequestOptions): Promise<Uint8Array>;
98
98
  /**
99
99
  * Create a grantees list from the given array of public keys.
100
100
  *
@@ -105,7 +105,7 @@ export declare class Bee {
105
105
  * @param requestOptions - Optional request options.
106
106
  * @returns A promise that resolves to a `GranteesResult` object.
107
107
  */
108
- createGrantees(postageBatchId: BatchId | Uint8Array | string, grantees: string[], requestOptions?: BeeRequestOptions): Promise<GranteesResult>;
108
+ createGrantees(postageBatchId: BatchId | Uint8Array | string, grantees: PublicKey[] | Uint8Array[] | string[], requestOptions?: BeeRequestOptions): Promise<GranteesResult>;
109
109
  /**
110
110
  * Retrieves the grantees for a given reference.
111
111
  *
@@ -113,7 +113,7 @@ export declare class Bee {
113
113
  * @param requestOptions - Optional request options.
114
114
  * @returns A promise that resolves to a `GetGranteesResult` object.
115
115
  */
116
- getGrantees(reference: Reference | string, requestOptions?: BeeRequestOptions): Promise<GetGranteesResult>;
116
+ getGrantees(reference: Reference | Uint8Array | string, requestOptions?: BeeRequestOptions): Promise<GetGranteesResult>;
117
117
  /**
118
118
  * Updates the grantees of a specific reference and history.
119
119
  *
@@ -125,8 +125,8 @@ export declare class Bee {
125
125
  * @returns A Promise that resolves to to a `GranteesResult` object.
126
126
  */
127
127
  patchGrantees(postageBatchId: BatchId | Uint8Array | string, reference: Reference | Uint8Array | string, history: Reference | Uint8Array | string, grantees: {
128
- add?: string[];
129
- revoke?: string[];
128
+ add?: PublicKey[] | Uint8Array[] | string[];
129
+ revoke?: PublicKey[] | Uint8Array[] | string[];
130
130
  }, requestOptions?: BeeRequestOptions): Promise<GranteesResult>;
131
131
  /**
132
132
  * Upload single file to a Bee node.
@@ -141,7 +141,7 @@ export declare class Bee {
141
141
  * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post)
142
142
  * @returns reference is a content hash of the file
143
143
  */
144
- uploadFile(postageBatchId: BatchId | Uint8Array | string, data: string | Uint8Array | Readable | File, name?: string, options?: FileUploadOptions & UploadRedundancyOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>;
144
+ uploadFile(postageBatchId: BatchId | Uint8Array | string, data: string | Uint8Array | Readable | File, name?: string, options?: FileUploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>;
145
145
  /**
146
146
  * Download single file.
147
147
  *
@@ -154,7 +154,7 @@ export declare class Bee {
154
154
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
155
155
  * @see [Bee API reference - `GET /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz~1%7Breference%7D~1%7Bpath%7D/get)
156
156
  */
157
- downloadFile(reference: Reference | Uint8Array | string, path?: string, options?: BeeRequestOptions): Promise<FileData<Bytes>>;
157
+ downloadFile(reference: Reference | Uint8Array | string, path?: string, options?: DownloadOptions, requestOptions?: BeeRequestOptions): Promise<FileData<Bytes>>;
158
158
  /**
159
159
  * Download single file as a readable stream
160
160
  *
@@ -167,7 +167,7 @@ export declare class Bee {
167
167
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
168
168
  * @see [Bee API reference - `GET /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz~1%7Breference%7D~1%7Bpath%7D/get)
169
169
  */
170
- downloadReadableFile(reference: Reference | Uint8Array | string, path?: string, options?: BeeRequestOptions): Promise<FileData<ReadableStream<Uint8Array>>>;
170
+ downloadReadableFile(reference: Reference | Uint8Array | string, path?: string, options?: DownloadOptions, requestOptions?: BeeRequestOptions): Promise<FileData<ReadableStream<Uint8Array>>>;
171
171
  /**
172
172
  * Upload collection of files to a Bee node
173
173
  *
@@ -184,7 +184,7 @@ export declare class Bee {
184
184
  * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download#upload-a-directory)
185
185
  * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post)
186
186
  */
187
- uploadFiles(postageBatchId: BatchId | Uint8Array | string, fileList: FileList | File[], options?: CollectionUploadOptions & UploadRedundancyOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>;
187
+ uploadFiles(postageBatchId: BatchId | Uint8Array | string, fileList: FileList | File[], options?: CollectionUploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>;
188
188
  hashDirectory(dir: string): Promise<Reference>;
189
189
  streamDirectory(postageBatchId: BatchId | Uint8Array | string, dir: string, onUploadProgress?: (progress: UploadProgress) => void, options?: UploadOptions, requestOptions?: BeeRequestOptions): Promise<Reference>;
190
190
  streamFiles(postageBatchId: BatchId | Uint8Array | string, files: File[] | FileList, onUploadProgress?: (progress: UploadProgress) => void, options?: UploadOptions): Promise<Reference>;
@@ -198,7 +198,7 @@ export declare class Bee {
198
198
  * @param collection
199
199
  * @param options Collections and request options
200
200
  */
201
- uploadCollection(postageBatchId: BatchId | Uint8Array | string, collection: Collection, options?: CollectionUploadOptions & UploadRedundancyOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>;
201
+ uploadCollection(postageBatchId: BatchId | Uint8Array | string, collection: Collection, options?: CollectionUploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>;
202
202
  /**
203
203
  * Upload collection of files.
204
204
  *
@@ -215,7 +215,7 @@ export declare class Bee {
215
215
  * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download#upload-a-directory)
216
216
  * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post)
217
217
  */
218
- uploadFilesFromDirectory(postageBatchId: BatchId | Uint8Array | string, dir: string, options?: CollectionUploadOptions & UploadRedundancyOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>;
218
+ uploadFilesFromDirectory(postageBatchId: BatchId | Uint8Array | string, dir: string, options?: CollectionUploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>;
219
219
  /**
220
220
  * Create a new Tag which is meant for tracking progres of syncing data across network.
221
221
  *
@@ -353,7 +353,7 @@ export declare class Bee {
353
353
  * @param index
354
354
  * @param options
355
355
  */
356
- isFeedRetrievable(owner: EthAddress | Uint8Array | string, topic: Topic | Uint8Array | string, index?: FeedIndex, options?: BeeRequestOptions): Promise<boolean>;
356
+ isFeedRetrievable(owner: EthAddress | Uint8Array | string, topic: Topic | Uint8Array | string, index?: FeedIndex, options?: DownloadOptions, requestOptions?: BeeRequestOptions): Promise<boolean>;
357
357
  /**
358
358
  * Send data to recipient or target with Postal Service for Swarm.
359
359
  *
@@ -549,7 +549,7 @@ export declare class Bee {
549
549
  * @param options.gasPrice Gas price for the cashout transaction in WEI
550
550
  * @param options.gasLimit Gas limit for the cashout transaction in WEI
551
551
  */
552
- cashoutLastCheque(address: PeerAddress | string, options?: CashoutOptions, requestOptions?: BeeRequestOptions): Promise<TransactionId>;
552
+ cashoutLastCheque(address: PeerAddress | string, options?: TransactionOptions, requestOptions?: BeeRequestOptions): Promise<TransactionId>;
553
553
  /**
554
554
  * Deposit tokens from overlay address into chequebook
555
555
  *
@@ -661,7 +661,7 @@ export declare class Bee {
661
661
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
662
662
  * @see [Bee Debug API reference - `PATCH /stamps/topup/${id}/${amount}`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1topup~1{id}~1{amount}/patch)
663
663
  */
664
- topUpBatch(postageBatchId: BatchId | Uint8Array | string, amount: NumberString | string | bigint, options?: BeeRequestOptions): Promise<void>;
664
+ topUpBatch(postageBatchId: BatchId | Uint8Array | string, amount: NumberString | string | bigint, options?: BeeRequestOptions): Promise<BatchId>;
665
665
  /**
666
666
  * Dilute given Postage Batch with new depth (that has to be bigger then the original depth), which allows
667
667
  * the Postage Batch to be used for more chunks.
@@ -678,7 +678,7 @@ export declare class Bee {
678
678
  * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
679
679
  * @see [Bee Debug API reference - `PATCH /stamps/topup/${id}/${amount}`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1topup~1{id}~1{amount}/patch)
680
680
  */
681
- diluteBatch(postageBatchId: BatchId | Uint8Array | string, depth: number, options?: BeeRequestOptions): Promise<void>;
681
+ diluteBatch(postageBatchId: BatchId | Uint8Array | string, depth: number, options?: BeeRequestOptions): Promise<BatchId>;
682
682
  /**
683
683
  * Return details for specific postage batch.
684
684
  *
@@ -752,5 +752,5 @@ export declare class Bee {
752
752
  */
753
753
  getRedistributionState(options?: BeeRequestOptions): Promise<RedistributionState>;
754
754
  private waitForUsablePostageStamp;
755
- private getRequestOptionsForCall;
755
+ protected getRequestOptionsForCall(options?: BeeRequestOptions): BeeRequestOptions;
756
756
  }
@@ -1,4 +1,4 @@
1
1
  import { Bee } from '../bee';
2
- import { BeeRequestOptions } from '../types';
2
+ import { BeeRequestOptions, DownloadOptions } from '../types';
3
3
  import { EthAddress, FeedIndex, Topic } from '../utils/typed-bytes';
4
- export declare function areAllSequentialFeedsUpdateRetrievable(bee: Bee, owner: EthAddress, topic: Topic, index: FeedIndex, requestOptions: BeeRequestOptions): Promise<boolean>;
4
+ export declare function areAllSequentialFeedsUpdateRetrievable(bee: Bee, owner: EthAddress, topic: Topic, index: FeedIndex, options: DownloadOptions | undefined, requestOptions: BeeRequestOptions): Promise<boolean>;
@@ -1,4 +1,5 @@
1
1
  import { Bee } from './bee';
2
+ import { BeeDev } from './bee-dev';
2
3
  export { MerkleTree } from 'cafe-utility';
3
4
  export { MantarayNode } from './manifest/manifest';
4
5
  export { SUPPORTED_BEE_VERSION, SUPPORTED_BEE_VERSION_EXACT } from './modules/debug/status';
@@ -9,11 +10,12 @@ export * from './utils/error';
9
10
  export * as Utils from './utils/expose';
10
11
  export * from './utils/tokens';
11
12
  export * from './utils/typed-bytes';
12
- export { Bee };
13
+ export { Bee, BeeDev };
13
14
  declare global {
14
15
  interface Window {
15
16
  BeeJs: {
16
17
  Bee: typeof import('./bee').Bee;
18
+ BeeDev: typeof import('./bee-dev').BeeDev;
17
19
  Utils: typeof import('./utils/expose');
18
20
  BeeError: typeof import('./utils/error').BeeError;
19
21
  BeeArgumentError: typeof import('./utils/error').BeeArgumentError;