@upcoming/bee-js 9.9.1 → 10.1.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.
@@ -1,8 +1,8 @@
1
- import type { BeeRequestOptions, GlobalPostageBatch, NumberString, PostageBatch, PostageBatchBuckets, PostageBatchOptions } from '../../types';
1
+ import type { BeeRequestOptions, GlobalPostageBatch, NumberString, PostageBatch, PostageBatchBuckets, PostageBatchOptions, RedundancyLevel } from '../../types';
2
2
  import { BatchId } from '../../utils/typed-bytes';
3
3
  export declare function getGlobalPostageBatches(requestOptions: BeeRequestOptions): Promise<GlobalPostageBatch[]>;
4
4
  export declare function getAllPostageBatches(requestOptions: BeeRequestOptions): Promise<PostageBatch[]>;
5
- export declare function getPostageBatch(requestOptions: BeeRequestOptions, postageBatchId: BatchId): Promise<PostageBatch>;
5
+ export declare function getPostageBatch(requestOptions: BeeRequestOptions, postageBatchId: BatchId, encryption?: boolean, erasureCodeLevel?: RedundancyLevel): Promise<PostageBatch>;
6
6
  export declare function getPostageBatchBuckets(requestOptions: BeeRequestOptions, postageBatchId: BatchId): Promise<PostageBatchBuckets>;
7
7
  export declare function createPostageBatch(requestOptions: BeeRequestOptions, amount: NumberString, depth: number, options?: PostageBatchOptions): Promise<BatchId>;
8
8
  export declare function topUpBatch(requestOptions: BeeRequestOptions, id: BatchId, amount: NumberString): Promise<BatchId>;
@@ -23,7 +23,7 @@ export interface Peer {
23
23
  fullNode?: boolean;
24
24
  }
25
25
  export interface ChequebookAddressResponse {
26
- chequebookAddress: string;
26
+ chequebookAddress: EthAddress;
27
27
  }
28
28
  export interface ChequebookBalanceResponse {
29
29
  totalBalance: BZZ;
@@ -13,16 +13,24 @@ export declare const BRANCHES = 128;
13
13
  export declare const CHUNK_SIZE: number;
14
14
  export declare const PSS_TARGET_HEX_LENGTH_MAX = 4;
15
15
  /**
16
- * Minimal depth that can be used for creation of postage batch
16
+ * Minimum postage batch depth.
17
17
  */
18
18
  export declare const STAMPS_DEPTH_MIN = 17;
19
19
  /**
20
- * Maximal depth that can be used for creation of postage batch
20
+ * Maximum postage batch depth.
21
21
  */
22
22
  export declare const STAMPS_DEPTH_MAX = 255;
23
+ /**
24
+ * Minimum tags API page size.
25
+ */
23
26
  export declare const TAGS_LIMIT_MIN = 1;
27
+ /**
28
+ * Maximum tags API page size.
29
+ */
24
30
  export declare const TAGS_LIMIT_MAX = 1000;
25
- export declare const FEED_INDEX_HEX_LENGTH = 16;
31
+ /**
32
+ * Behavior of the HTTP client, such as `timeout`, additional `headers`, custom `httpAgent`, etc.
33
+ */
26
34
  export type BeeRequestOptions = {
27
35
  baseURL?: string;
28
36
  timeout?: number;
@@ -32,13 +40,29 @@ export type BeeRequestOptions = {
32
40
  httpsAgent?: unknown;
33
41
  endlesslyRetry?: boolean;
34
42
  };
43
+ /**
44
+ * Options for the Bee client which affect all method calls *(unless overridden in the method call itself)*.
45
+ *
46
+ * Extends `BeeRequestOptions`, which allows configuring the HTTP client behavior,
47
+ * such as `timeout`, additional `headers`, custom `httpAgent`, etc.
48
+ */
35
49
  export interface BeeOptions extends BeeRequestOptions {
36
50
  /**
37
- * Signer object or private key of the Signer in form of either hex string or Uint8Array that will be default signer for the instance.
51
+ * Default signer (a private key) used for signing.
52
+ *
53
+ * Mainly used in single-owner chunk (SOC) related operations, and consequently in feeds.
54
+ *
55
+ * If not provided, methods such as `makeFeedWriter` and `makeSOCWriter`
56
+ * must be provided with a private key in their respective function calls.
38
57
  */
39
58
  signer?: PrivateKey | Uint8Array | string;
40
59
  /**
41
- * Default gnosis when unspecified.
60
+ * Network on which the Bee node is running.
61
+ *
62
+ * This is currently used to determine block time for postage batch time-to-live (TTL) calculations.
63
+ * The block time for `gnosis` is `5` seconds, and for `sepolia` it is `15` seconds.
64
+ *
65
+ * Default value is `gnosis`.
42
66
  */
43
67
  network?: 'gnosis' | 'sepolia';
44
68
  }
@@ -146,14 +170,20 @@ export declare enum RedundancyStrategy {
146
170
  export interface DownloadOptions {
147
171
  /**
148
172
  * Specify the retrieve strategy on redundant data.
173
+ *
174
+ * Only applicable for erasure coded data.
149
175
  */
150
176
  redundancyStrategy?: RedundancyStrategy;
151
177
  /**
152
178
  * Specify if the retrieve strategies (chunk prefetching on redundant data) are used in a fallback cascade. The default is true.
179
+ *
180
+ * Only applicable for erasure coded data.
153
181
  */
154
182
  fallback?: boolean;
155
183
  /**
156
184
  * Specify the timeout for chunk retrieval. The default is 30 seconds.
185
+ *
186
+ * This is not the timeout for the whole download operation, but rather for each chunk retrieval.
157
187
  */
158
188
  timeoutMs?: number;
159
189
  actPublisher?: PublicKey | Uint8Array | string;
@@ -200,7 +230,11 @@ export interface UploadHeaders {
200
230
  'swarm-postage-batch-id'?: string;
201
231
  }
202
232
  /**
203
- * Object that contains infromation about progress of upload of data to network.
233
+ * Object that contains information about upload progress of data to network.
234
+ *
235
+ * The total amount of chunks is represented by `split` property.
236
+ *
237
+ * The actual progress of the upload can be tracked by the `seen + synced` properties.
204
238
  *
205
239
  * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
206
240
  */
@@ -273,6 +307,7 @@ export interface PssSubscription {
273
307
  export interface PssMessageHandler {
274
308
  onMessage: (message: Bytes, subscription: PssSubscription) => void;
275
309
  onError: (error: BeeError, subscription: PssSubscription) => void;
310
+ onClose: (subscription: PssSubscription) => void;
276
311
  }
277
312
  export interface GsocSubscription {
278
313
  readonly address: EthAddress;
@@ -281,6 +316,7 @@ export interface GsocSubscription {
281
316
  export interface GsocMessageHandler {
282
317
  onMessage: (message: Bytes, subscription: GsocSubscription) => void;
283
318
  onError: (error: BeeError, subscription: GsocSubscription) => void;
319
+ onClose: (subscription: GsocSubscription) => void;
284
320
  }
285
321
  export interface ReferenceResponse {
286
322
  reference: Reference;
@@ -414,6 +450,16 @@ export interface PostageBatch {
414
450
  * Theoretical size in bytes
415
451
  */
416
452
  theoreticalSize: Size;
453
+ /**
454
+ * Calculates the effective size of data that can be uploaded with this postage batch
455
+ * based on whether encryption is used and the desired redundancy level.
456
+ */
457
+ calculateSize(encryption: boolean, redundancyLevel: RedundancyLevel): Size;
458
+ /**
459
+ * Calculates the remaining size of data that can be uploaded with this postage batch
460
+ * based on whether encryption is used and the desired redundancy level.
461
+ */
462
+ calculateRemainingSize(encryption: boolean, redundancyLevel: RedundancyLevel): Size;
417
463
  }
418
464
  export interface BatchBucket {
419
465
  bucketID: number;
@@ -9,6 +9,30 @@ export declare class Duration {
9
9
  static fromWeeks(weeks: number): Duration;
10
10
  static fromYears(years: number): Duration;
11
11
  static fromEndDate(endDate: Date, startDate?: Date): Duration;
12
+ /**
13
+ * Parses a duration string and returns a `Duration` instance.
14
+ *
15
+ * Case insensitive. E.g. both `"28h"` and `"1D"` are valid.
16
+ *
17
+ * Whitespaces are ignored. E.g. both `"5 d"` and `"2weeks"` are valid.
18
+ *
19
+ * Decimal numbers are supported. E.g. `"1.5h"` is valid.
20
+ *
21
+ * Supported units:
22
+ *
23
+ * - ms, milli, millis, millisecond, milliseconds
24
+ * - s, sec, second, seconds
25
+ * - m, min, minute, minutes
26
+ * - h, hour, hours
27
+ * - d, day, days
28
+ * - w, week, weeks
29
+ * - month, months
30
+ * - y, year, years
31
+ *
32
+ * @param duration - A string representing a duration
33
+ * @returns a `Duration` instance
34
+ */
35
+ static parseFromString(duration: string): Duration;
12
36
  toSeconds(): number;
13
37
  toHours(): number;
14
38
  toDays(): number;
@@ -12,6 +12,29 @@ export declare class Size {
12
12
  static fromKilobytes(kilobytes: number): Size;
13
13
  static fromMegabytes(megabytes: number): Size;
14
14
  static fromGigabytes(gigabytes: number): Size;
15
+ /**
16
+ * Parses a size string and returns a `Size` instance.
17
+ *
18
+ * Case insensitive. E.g. both `"28MB"` and `"1gb"` are valid.
19
+ *
20
+ * Whitespaces are ignored. E.g. both `"512 kb"` and `"2megabytes"` are valid.
21
+ *
22
+ * Decimal numbers are supported. E.g. `"1.5gb"` is valid.
23
+ *
24
+ * Uses 1000 as the base for conversions. E.g. 1kb = 1000 bytes.
25
+ * This is consistent with the effective stamp utilization table.
26
+ *
27
+ * Supported units:
28
+ * - b, byte, bytes
29
+ * - kb, kilobyte, kilobytes
30
+ * - mb, megabyte, megabytes
31
+ * - gb, gigabyte, gigabytes
32
+ * - tb, terabyte, terabytes
33
+ *
34
+ * @param size - A string representing a size
35
+ * @returns a `Size` instance
36
+ */
37
+ static parseFromString(size: string): Size;
15
38
  toBytes(): number;
16
39
  toGigabytes(): number;
17
40
  toFormattedString(): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upcoming/bee-js",
3
- "version": "9.9.1",
3
+ "version": "10.1.2",
4
4
  "description": "Javascript client for Bee",
5
5
  "keywords": [
6
6
  "bee",
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "dependencies": {
64
64
  "axios": "^0.30.0",
65
- "cafe-utility": "^31.0.0",
65
+ "cafe-utility": "^32.2.0",
66
66
  "debug": "^4.4.1",
67
67
  "isomorphic-ws": "^4.0.1",
68
68
  "semver": "^7.3.5",