@ethersphere/bee-js 3.0.0 → 3.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.
@@ -1,4 +1,4 @@
1
- import type { Address, Peer, BalanceResponse, PeerBalance, ChequebookAddressResponse, ChequebookBalanceResponse, LastChequesResponse, LastChequesForPeerResponse, LastCashoutActionResponse, Settlements, AllSettlements, RemovePeerResponse, Topology, PingResponse, Health, NodeAddresses, ReserveState, ChainState, NumberString, ExtendedTag, PostageBatchBuckets, DebugPostageBatch, TransactionInfo, TransactionHash } from './types';
1
+ import type { Address, Peer, BalanceResponse, PeerBalance, ChequebookAddressResponse, ChequebookBalanceResponse, LastChequesResponse, LastChequesForPeerResponse, LastCashoutActionResponse, Settlements, AllSettlements, RemovePeerResponse, Topology, PingResponse, Health, NodeAddresses, ReserveState, ChainState, NumberString, ExtendedTag, PostageBatchBuckets, DebugPostageBatch, TransactionInfo, TransactionHash, NodesInfo } from './types';
2
2
  import { BatchId, BeeOptions, CashoutOptions, PostageBatchOptions, RequestOptions, Tag } from './types';
3
3
  export declare class BeeDebug {
4
4
  /**
@@ -117,6 +117,10 @@ export declare class BeeDebug {
117
117
  * Get health of node
118
118
  */
119
119
  getHealth(options?: RequestOptions): Promise<Health>;
120
+ /**
121
+ * Get mode information of node
122
+ */
123
+ getNodeInfo(options?: RequestOptions): Promise<NodesInfo>;
120
124
  /**
121
125
  * Connnects to a node and checks if it is a supported Bee version by the bee-js
122
126
  *
package/dist/src/bee.d.ts CHANGED
@@ -57,6 +57,27 @@ export declare class Bee {
57
57
  * @see [Bee API reference - `GET /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1{reference}/get)
58
58
  */
59
59
  downloadReadableData(reference: Reference | string, options?: RequestOptions): Promise<ReadableStream<Uint8Array>>;
60
+ /**
61
+ * Upload chunk to a Bee node
62
+ *
63
+ * @param postageBatchId Postage BatchId to be used to upload the chunk with
64
+ * @param data Raw chunk to be uploaded
65
+ * @param options Additional options like tag, encryption, pinning, content-type and request options
66
+ *
67
+ * @returns reference is a content hash of the data
68
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
69
+ * @see [Bee API reference - `POST /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks/post)
70
+ */
71
+ uploadChunk(postageBatchId: string | BatchId, data: Uint8Array, options?: UploadOptions): Promise<Reference>;
72
+ /**
73
+ * Download chunk as a byte array
74
+ *
75
+ * @param reference Bee chunk reference
76
+ * @param options Options that affects the request behavior
77
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
78
+ * @see [Bee API reference - `GET /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks~1{reference}/get)
79
+ */
80
+ downloadChunk(reference: Reference | string, options?: RequestOptions): Promise<Data>;
60
81
  /**
61
82
  * Upload single file to a Bee node.
62
83
  *
@@ -1,5 +1,4 @@
1
- import type { BatchId, Ky, UploadOptions } from '../types';
2
- import { Reference } from '../types';
1
+ import type { BatchId, Data, Ky, Reference, UploadOptions } from '../types';
3
2
  /**
4
3
  * Upload chunk to a Bee node
5
4
  *
@@ -20,11 +19,4 @@ export declare function upload(ky: Ky, data: Uint8Array, postageBatchId: BatchId
20
19
  * @param hash Bee content reference
21
20
  *
22
21
  */
23
- export declare function download(ky: Ky, hash: string): Promise<Uint8Array>;
24
- /**
25
- * Download chunk data as a readable stream
26
- *
27
- * @param ky Ky instance for given Bee class instance
28
- * @param hash Bee content reference
29
- */
30
- export declare function downloadReadable(ky: Ky, hash: string): Promise<ReadableStream<Uint8Array>>;
22
+ export declare function download(ky: Ky, hash: string): Promise<Data>;
@@ -1,4 +1,4 @@
1
- import type { Health } from '../../types/debug';
1
+ import type { Health, NodesInfo } from '../../types/debug';
2
2
  import { Ky } from '../../types';
3
3
  export declare const SUPPORTED_BEE_VERSION_EXACT: string;
4
4
  export declare const SUPPORTED_BEE_VERSION: string;
@@ -7,12 +7,18 @@ export declare const SUPPORTED_BEE_VERSION: string;
7
7
  *
8
8
  * @param ky Ky debug instance
9
9
  */
10
- export declare function getHealth(ky: Ky): Promise<Health> | never;
10
+ export declare function getHealth(ky: Ky): Promise<Health>;
11
11
  /**
12
- * Connnects to a node and checks if it is a supported Bee version by the bee-js
12
+ * Get information about Bee node
13
+ *
14
+ * @param ky Ky debug instance
15
+ */
16
+ export declare function getNodeInfo(ky: Ky): Promise<NodesInfo>;
17
+ /**
18
+ * Connects to a node and checks if it is a supported Bee version by the bee-js
13
19
  *
14
20
  * @param ky Ky debug instance
15
21
  *
16
22
  * @returns true if the Bee node version is supported
17
23
  */
18
- export declare function isSupportedVersion(ky: Ky): Promise<boolean> | never;
24
+ export declare function isSupportedVersion(ky: Ky): Promise<boolean>;
@@ -121,6 +121,15 @@ export interface Health {
121
121
  apiVersion: string;
122
122
  debugApiVersion: string;
123
123
  }
124
+ export declare enum BeeModes {
125
+ FULL = "full",
126
+ LIGHT = "light",
127
+ DEV = "dev"
128
+ }
129
+ export interface NodesInfo {
130
+ gatewayMode: boolean;
131
+ beeMode: BeeModes;
132
+ }
124
133
  export interface RemovePeerResponse {
125
134
  message: string;
126
135
  code: 0;
@@ -16,6 +16,10 @@ export declare type Ky = typeof ky;
16
16
  export interface Dictionary<T> {
17
17
  [Key: string]: T;
18
18
  }
19
+ export declare const SPAN_SIZE = 8;
20
+ export declare const SECTION_SIZE = 32;
21
+ export declare const BRANCHES = 128;
22
+ export declare const CHUNK_SIZE: number;
19
23
  export declare const ADDRESS_HEX_LENGTH = 64;
20
24
  export declare const PSS_TARGET_HEX_LENGTH_MAX = 6;
21
25
  export declare const PUBKEY_HEX_LENGTH = 66;
@@ -5,3 +5,4 @@ export { EthAddress, makeEthAddress, makeHexEthAddress, isHexEthAddress, ethToSw
5
5
  export { readableWebToNode, readableNodeToWeb, isReadableStream, isNodeReadable, normalizeToReadableStream, isReadable, } from './stream';
6
6
  export { keccak256Hash } from './hash';
7
7
  export { makeMaxTarget } from './pss';
8
+ export { getStampUsage } from './stamps';
@@ -0,0 +1,12 @@
1
+ import { DebugPostageBatch } from '../types';
2
+ /**
3
+ * Utility function that calculates usage of postage batch based on its utilization, depth and bucket depth.
4
+ *
5
+ * Be aware for small depths (17, 18) this does not provide that much information as the provided set of distinct values
6
+ * is small.
7
+ *
8
+ * @param utilization
9
+ * @param depth
10
+ * @param bucketDepth
11
+ */
12
+ export declare function getStampUsage({ utilization, depth, bucketDepth }: DebugPostageBatch): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethersphere/bee-js",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Javascript client for Bee",
5
5
  "keywords": [
6
6
  "bee",
@@ -118,6 +118,6 @@
118
118
  "engines": {
119
119
  "node": ">=12.0.0",
120
120
  "npm": ">=6.0.0",
121
- "bee": "1.4.0-8fa696a8"
121
+ "bee": "1.4.1-238867f1"
122
122
  }
123
123
  }