@ethersphere/bee-js 2.1.0 → 3.2.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/README.md +3 -3
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/src/bee-debug.d.ts +5 -1
- package/dist/src/bee.d.ts +23 -46
- package/dist/src/modules/chunk.d.ts +2 -10
- package/dist/src/modules/debug/status.d.ts +10 -4
- package/dist/src/types/debug.d.ts +19 -0
- package/dist/src/types/index.d.ts +31 -2
- package/dist/src/utils/bytes.d.ts +1 -1
- package/dist/src/utils/error.d.ts +21 -2
- package/dist/src/utils/expose.d.ts +1 -0
- package/dist/src/utils/http.d.ts +7 -9
- package/dist/src/utils/stamps.d.ts +12 -0
- package/dist/src/utils/type.d.ts +6 -0
- package/package.json +28 -27
- package/.babelrc.js +0 -33
- package/.depcheckrc.json +0 -27
- package/.editorconfig +0 -6
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -109
- package/.gitattributes +0 -1
- package/.github/config.yaml +0 -23
- package/.github/workflows/check.yaml +0 -57
- package/.github/workflows/publish_npmjs.yaml +0 -20
- package/.github/workflows/release_github.yaml +0 -20
- package/.github/workflows/tests.yaml +0 -128
- package/.huskyrc +0 -5
- package/.prettierrc +0 -13
- package/.vscode/launch.json +0 -49
- package/.vscode/settings.json +0 -39
- package/CHANGELOG.md +0 -520
- package/CODEOWNERS +0 -1
- package/CODE_OF_CONDUCT.md +0 -76
- package/commitlint.config.js +0 -3
- package/dist/src/modules/stamps.d.ts +0 -4
- package/jest-puppeteer.config.js +0 -5
- package/jest.config.ts +0 -85
- package/src/bee-debug.ts +0 -601
- package/src/bee.ts +0 -1087
- package/src/chunk/bmt.ts +0 -55
- package/src/chunk/cac.ts +0 -79
- package/src/chunk/serialize.ts +0 -16
- package/src/chunk/signer.ts +0 -141
- package/src/chunk/soc.ts +0 -190
- package/src/chunk/span.ts +0 -33
- package/src/feed/index.ts +0 -217
- package/src/feed/json.ts +0 -33
- package/src/feed/topic.ts +0 -23
- package/src/feed/type.ts +0 -12
- package/src/index.ts +0 -24
- package/src/modules/bytes.ts +0 -70
- package/src/modules/bzz.ts +0 -179
- package/src/modules/chunk.ts +0 -69
- package/src/modules/debug/balance.ts +0 -63
- package/src/modules/debug/chequebook.ts +0 -175
- package/src/modules/debug/chunk.ts +0 -39
- package/src/modules/debug/connectivity.ts +0 -61
- package/src/modules/debug/settlements.ts +0 -33
- package/src/modules/debug/stamps.ts +0 -96
- package/src/modules/debug/states.ts +0 -35
- package/src/modules/debug/status.ts +0 -34
- package/src/modules/debug/tag.ts +0 -19
- package/src/modules/debug/transactions.ts +0 -79
- package/src/modules/feed.ts +0 -105
- package/src/modules/pinning.ts +0 -74
- package/src/modules/pss.ts +0 -49
- package/src/modules/soc.ts +0 -40
- package/src/modules/stamps.ts +0 -59
- package/src/modules/status.ts +0 -13
- package/src/modules/stewardship.ts +0 -32
- package/src/modules/tag.ts +0 -83
- package/src/types/debug.ts +0 -204
- package/src/types/index.ts +0 -561
- package/src/types/ky-universal/common.d.ts +0 -17
- package/src/types/ky-universal/hooks.d.ts +0 -103
- package/src/types/ky-universal/index.d.ts +0 -125
- package/src/types/ky-universal/options.d.ts +0 -235
- package/src/types/ky-universal/response.d.ts +0 -38
- package/src/types/ky-universal/retry.d.ts +0 -39
- package/src/types/tar-js.d.ts +0 -1
- package/src/types/webpack-bundle-analyzer/index.d.ts +0 -13
- package/src/utils/bytes.ts +0 -144
- package/src/utils/collection.ts +0 -151
- package/src/utils/data.browser.ts +0 -68
- package/src/utils/data.ts +0 -48
- package/src/utils/error.ts +0 -23
- package/src/utils/eth.ts +0 -229
- package/src/utils/expose.ts +0 -48
- package/src/utils/file.ts +0 -40
- package/src/utils/hash.ts +0 -16
- package/src/utils/headers.ts +0 -63
- package/src/utils/hex.ts +0 -186
- package/src/utils/http.ts +0 -141
- package/src/utils/merge.ts +0 -34
- package/src/utils/pss.ts +0 -16
- package/src/utils/stream.ts +0 -146
- package/src/utils/tar.ts +0 -30
- package/src/utils/type.ts +0 -394
- package/src/utils/uint64.ts +0 -31
- package/src/utils/url.ts +0 -52
- package/test/bee.sh +0 -187
- package/test/data/1.txt +0 -1
- package/test/data/2.txt +0 -0
- package/test/data/empty +0 -0
- package/test/data/sub/3.txt +0 -1
- package/test/data/sub//303/251 +0 -0
- package/test/data/sub//360/237/230/216 +0 -0
- package/test/integration/bee-class.browser.spec.ts +0 -272
- package/test/integration/bee-class.spec.ts +0 -648
- package/test/integration/bee-debug-class.spec.ts +0 -114
- package/test/integration/chunk/bmt.spec.ts +0 -33
- package/test/integration/chunk/cac.spec.ts +0 -27
- package/test/integration/chunk/soc.spec.ts +0 -38
- package/test/integration/feed/index.spec.ts +0 -84
- package/test/integration/modules/bytes.spec.ts +0 -23
- package/test/integration/modules/bzz.spec.ts +0 -265
- package/test/integration/modules/chunk.spec.ts +0 -29
- package/test/integration/modules/debug/balance.spec.ts +0 -70
- package/test/integration/modules/debug/chequebook.spec.ts +0 -64
- package/test/integration/modules/debug/connectivity.spec.ts +0 -69
- package/test/integration/modules/debug/settlements.spec.ts +0 -34
- package/test/integration/modules/debug/states.spec.ts +0 -34
- package/test/integration/modules/debug/status.spec.ts +0 -65
- package/test/integration/modules/debug/tag.spec.ts +0 -27
- package/test/integration/modules/debug/transactions.spec.ts +0 -10
- package/test/integration/modules/feed.spec.ts +0 -61
- package/test/integration/modules/pinning.spec.ts +0 -155
- package/test/integration/modules/pss.spec.ts +0 -105
- package/test/integration/modules/status.spec.ts +0 -10
- package/test/integration/modules/stewardship.spec.ts +0 -32
- package/test/integration/modules/tag.spec.ts +0 -51
- package/test/test-type-sequencer.js +0 -36
- package/test/testpage/testpage.html +0 -20
- package/test/tests-setup.ts +0 -94
- package/test/unit/assertions.ts +0 -460
- package/test/unit/bee-class.spec.ts +0 -976
- package/test/unit/bee-debug-class.spec.ts +0 -435
- package/test/unit/chunk/bmt.spec.ts +0 -16
- package/test/unit/chunk/cac.spec.ts +0 -29
- package/test/unit/chunk/serialize.spec.ts +0 -24
- package/test/unit/chunk/signer.spec.ts +0 -140
- package/test/unit/chunk/soc.spec.ts +0 -25
- package/test/unit/chunk/span.spec.ts +0 -38
- package/test/unit/feed/json.spec.ts +0 -73
- package/test/unit/nock.ts +0 -151
- package/test/unit/utils/bytes.spec.ts +0 -32
- package/test/unit/utils/collection.spec.ts +0 -22
- package/test/unit/utils/eth.spec.ts +0 -224
- package/test/unit/utils/hex.spec.ts +0 -115
- package/test/unit/utils/stream.spec.ts +0 -30
- package/test/unit/utils/type.spec.ts +0 -32
- package/test/unit/utils/uint64.spec.ts +0 -102
- package/test/utils.ts +0 -426
- package/tsconfig.json +0 -18
- package/tsconfig.test.json +0 -11
- package/typedoc.json +0 -7
- package/webpack.config.ts +0 -141
package/dist/src/bee-debug.d.ts
CHANGED
|
@@ -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, NodeInfo } 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<NodeInfo>;
|
|
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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FeedType } from './feed/type';
|
|
2
2
|
import { EthAddress } from './utils/eth';
|
|
3
|
-
import { AllTagsOptions, Collection,
|
|
4
|
-
import type { Tag, FileData, Reference, UploadOptions, PublicKey, AddressPrefix, PssMessageHandler, PssSubscription, CollectionUploadOptions, FileUploadOptions, Data, Signer, FeedReader, FeedWriter, SOCWriter, SOCReader, Topic, BeeOptions, JsonFeedOptions, AnyJson, Pin,
|
|
3
|
+
import { AllTagsOptions, Collection, Readable, RequestOptions, UploadResult } from './types';
|
|
4
|
+
import type { Tag, FileData, Reference, UploadOptions, PublicKey, AddressPrefix, PssMessageHandler, PssSubscription, CollectionUploadOptions, FileUploadOptions, Data, Signer, FeedReader, FeedWriter, SOCWriter, SOCReader, Topic, BeeOptions, JsonFeedOptions, AnyJson, Pin, BatchId } from './types';
|
|
5
5
|
/**
|
|
6
6
|
* The main component that abstracts operations available on the main Bee API.
|
|
7
7
|
*
|
|
@@ -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
|
*
|
|
@@ -448,50 +469,6 @@ export declare class Bee {
|
|
|
448
469
|
* @see [Bee docs - Chunk Types](https://docs.ethswarm.org/docs/dapps-on-swarm/chunk-types#single-owner-chunks)
|
|
449
470
|
*/
|
|
450
471
|
makeSOCWriter(signer?: Signer | Uint8Array | string, options?: RequestOptions): SOCWriter;
|
|
451
|
-
/**
|
|
452
|
-
* Creates new postage batch from the funds that the node has available in its Ethereum account.
|
|
453
|
-
*
|
|
454
|
-
* For better understanding what each parameter means and what are the optimal values please see
|
|
455
|
-
* [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive).
|
|
456
|
-
*
|
|
457
|
-
* **WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY**
|
|
458
|
-
* **Warning! Not allowed when node is in Gateway mode!**
|
|
459
|
-
*
|
|
460
|
-
* @param amount Amount that represents the value per chunk, has to be greater or equal zero.
|
|
461
|
-
* @param depth Logarithm of the number of chunks that can be stamped with the batch.
|
|
462
|
-
* @param options Options for creation of postage batch and request options
|
|
463
|
-
* @throws BeeArgumentError when negative amount or depth is specified
|
|
464
|
-
* @throws TypeError if non-integer value is passed to amount or depth
|
|
465
|
-
*
|
|
466
|
-
* @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
|
|
467
|
-
* @see [Bee API reference - `POST /stamps`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1{amount}~1{depth}/post)
|
|
468
|
-
* @deprecated Use DebugBee for postage batch management
|
|
469
|
-
*/
|
|
470
|
-
createPostageBatch(amount: NumberString, depth: number, options?: PostageBatchOptions): Promise<BatchId>;
|
|
471
|
-
/**
|
|
472
|
-
* Return details for specific postage batch.
|
|
473
|
-
*
|
|
474
|
-
* **Warning! Not allowed when node is in Gateway mode!**
|
|
475
|
-
*
|
|
476
|
-
* @param postageBatchId Batch ID
|
|
477
|
-
* @param options Options that affects the request behavior
|
|
478
|
-
*
|
|
479
|
-
* @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
|
|
480
|
-
* @see [Bee API reference - `GET /stamps/${id}`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1{id}/get)
|
|
481
|
-
* @deprecated Use DebugBee for postage batch management
|
|
482
|
-
*/
|
|
483
|
-
getPostageBatch(postageBatchId: BatchId | string, options?: RequestOptions): Promise<PostageBatch>;
|
|
484
|
-
/**
|
|
485
|
-
* Return all postage batches that has the node available.
|
|
486
|
-
*
|
|
487
|
-
* **Warning! Not allowed when node is in Gateway mode!**
|
|
488
|
-
*
|
|
489
|
-
* @param options Options that affects the request behavior
|
|
490
|
-
* @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
|
|
491
|
-
* @see [Bee API reference - `GET /stamps`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps/get)
|
|
492
|
-
* @deprecated Use DebugBee for postage batch management
|
|
493
|
-
*/
|
|
494
|
-
getAllPostageBatch(options?: RequestOptions): Promise<PostageBatch[]>;
|
|
495
472
|
/**
|
|
496
473
|
* Ping the Bee node to see if there is a live Bee node on the given URL.
|
|
497
474
|
*
|
|
@@ -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<
|
|
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, NodeInfo } 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
|
|
10
|
+
export declare function getHealth(ky: Ky): Promise<Health>;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Get information about Bee node
|
|
13
|
+
*
|
|
14
|
+
* @param ky Ky debug instance
|
|
15
|
+
*/
|
|
16
|
+
export declare function getNodeInfo(ky: Ky): Promise<NodeInfo>;
|
|
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
|
|
24
|
+
export declare function isSupportedVersion(ky: Ky): Promise<boolean>;
|
|
@@ -118,7 +118,26 @@ export interface BalanceResponse {
|
|
|
118
118
|
export interface Health {
|
|
119
119
|
status: 'ok';
|
|
120
120
|
version: string;
|
|
121
|
+
apiVersion: string;
|
|
122
|
+
debugApiVersion: string;
|
|
121
123
|
}
|
|
124
|
+
export declare enum BeeModes {
|
|
125
|
+
FULL = "full",
|
|
126
|
+
LIGHT = "light",
|
|
127
|
+
DEV = "dev"
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Information about Bee node and its configuration
|
|
131
|
+
*/
|
|
132
|
+
export interface NodeInfo {
|
|
133
|
+
gatewayMode: boolean;
|
|
134
|
+
beeMode: BeeModes;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Information about Bee node and its configuration
|
|
138
|
+
* @deprecated Use NodeInfo instead
|
|
139
|
+
*/
|
|
140
|
+
export declare type NodesInfo = NodeInfo;
|
|
122
141
|
export interface RemovePeerResponse {
|
|
123
142
|
message: string;
|
|
124
143
|
code: 0;
|
|
@@ -11,11 +11,16 @@ import type ky from 'ky-universal';
|
|
|
11
11
|
import type { Readable as NativeReadable } from 'stream';
|
|
12
12
|
import type { Readable as CompatibilityReadable } from 'readable-stream';
|
|
13
13
|
import type { ReadableStream as ReadableStreamPonyfill } from 'web-streams-polyfill/ponyfill';
|
|
14
|
+
import { Options as KyOptions } from 'ky-universal';
|
|
14
15
|
export * from './debug';
|
|
15
16
|
export declare type Ky = typeof ky;
|
|
16
17
|
export interface Dictionary<T> {
|
|
17
18
|
[Key: string]: T;
|
|
18
19
|
}
|
|
20
|
+
export declare const SPAN_SIZE = 8;
|
|
21
|
+
export declare const SECTION_SIZE = 32;
|
|
22
|
+
export declare const BRANCHES = 128;
|
|
23
|
+
export declare const CHUNK_SIZE: number;
|
|
19
24
|
export declare const ADDRESS_HEX_LENGTH = 64;
|
|
20
25
|
export declare const PSS_TARGET_HEX_LENGTH_MAX = 6;
|
|
21
26
|
export declare const PUBKEY_HEX_LENGTH = 66;
|
|
@@ -59,6 +64,17 @@ export declare type BatchId = HexString<typeof BATCH_ID_HEX_LENGTH>;
|
|
|
59
64
|
* It represents PSS Address Prefix that is used to define address neighborhood that will receive the PSS message.
|
|
60
65
|
*/
|
|
61
66
|
export declare type AddressPrefix = HexString;
|
|
67
|
+
/**
|
|
68
|
+
* Internal interface that represents configuration for creating a request with Ky
|
|
69
|
+
*/
|
|
70
|
+
export interface KyRequestOptions extends Omit<KyOptions, 'searchParams'> {
|
|
71
|
+
path: string;
|
|
72
|
+
responseType?: 'json' | 'arraybuffer' | 'stream';
|
|
73
|
+
/**
|
|
74
|
+
* Overridden parameter that allows undefined as a value.
|
|
75
|
+
*/
|
|
76
|
+
searchParams?: Record<string, string | number | boolean | undefined>;
|
|
77
|
+
}
|
|
62
78
|
export interface RequestOptions {
|
|
63
79
|
/**
|
|
64
80
|
* Timeout of requests in milliseconds
|
|
@@ -138,6 +154,17 @@ export interface UploadOptions extends RequestOptions {
|
|
|
138
154
|
* @link Tag
|
|
139
155
|
*/
|
|
140
156
|
tag?: number;
|
|
157
|
+
/**
|
|
158
|
+
* Determines if the uploaded data should be sent to the network immediately (eq. deferred=false) or in a deferred fashion (eq. deferred=true).
|
|
159
|
+
*
|
|
160
|
+
* With deferred style client uploads all the data to Bee node first and only then Bee node starts push the data to network itself. The progress of this upload can be tracked with tags.
|
|
161
|
+
* With non-deferred style client uploads the data to Bee which immediately starts pushing the data to network. The request is only finished once all the data was pushed through the Bee node to the network.
|
|
162
|
+
*
|
|
163
|
+
* In future there will be move to the non-deferred style and even the support for deferred upload will be removed from Bee itself.
|
|
164
|
+
*
|
|
165
|
+
* @default true
|
|
166
|
+
*/
|
|
167
|
+
deferred?: boolean;
|
|
141
168
|
}
|
|
142
169
|
export interface FileUploadOptions extends UploadOptions {
|
|
143
170
|
/**
|
|
@@ -368,14 +395,16 @@ export interface PostageBatch {
|
|
|
368
395
|
bucketDepth: number;
|
|
369
396
|
blockNumber: number;
|
|
370
397
|
immutableFlag: boolean;
|
|
371
|
-
}
|
|
372
|
-
export interface DebugPostageBatch extends PostageBatch {
|
|
373
398
|
/**
|
|
374
399
|
* The time (in seconds) remaining until the batch expires; -1 signals that the batch never expires; 0 signals that the batch has already expired.
|
|
375
400
|
*/
|
|
376
401
|
batchTTL: number;
|
|
377
402
|
exists: boolean;
|
|
378
403
|
}
|
|
404
|
+
/**
|
|
405
|
+
* @deprecated Use PostageBatch instead.
|
|
406
|
+
*/
|
|
407
|
+
export declare type DebugPostageBatch = PostageBatch;
|
|
379
408
|
export interface BatchBucket {
|
|
380
409
|
bucketID: number;
|
|
381
410
|
collisions: number;
|
|
@@ -22,7 +22,7 @@ export interface FlexBytes<Min extends number, Max extends number> extends Uint8
|
|
|
22
22
|
readonly __max__: Max;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Type guard for Bytes<T
|
|
25
|
+
* Type guard for `Bytes<T>` type
|
|
26
26
|
*
|
|
27
27
|
* @param b The byte array
|
|
28
28
|
* @param length The length of the byte array
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KyRequestOptions } from '../types';
|
|
1
2
|
export declare class BeeError extends Error {
|
|
2
3
|
constructor(message: string);
|
|
3
4
|
}
|
|
@@ -6,9 +7,27 @@ export declare class BeeArgumentError extends BeeError {
|
|
|
6
7
|
constructor(message: string, value: unknown);
|
|
7
8
|
}
|
|
8
9
|
export declare class BeeRequestError extends BeeError {
|
|
9
|
-
|
|
10
|
+
readonly requestOptions: KyRequestOptions;
|
|
11
|
+
/**
|
|
12
|
+
* @param message
|
|
13
|
+
* @param requestOptions KyOptions that were used to assemble the request. THIS MIGHT NOT BE COMPLETE! If custom Ky instance was used that has set defaults then these defaults are not visible in this object!
|
|
14
|
+
*/
|
|
15
|
+
constructor(message: string, requestOptions: KyRequestOptions);
|
|
10
16
|
}
|
|
11
17
|
export declare class BeeResponseError extends BeeError {
|
|
12
18
|
readonly status: number;
|
|
13
|
-
|
|
19
|
+
readonly response: Response;
|
|
20
|
+
readonly responseBody: string;
|
|
21
|
+
readonly requestOptions: KyRequestOptions;
|
|
22
|
+
/**
|
|
23
|
+
* @param status HTTP status code number
|
|
24
|
+
* @param response Response returned from the server
|
|
25
|
+
* @param responseBody Response body as string which is returned from response.text() call
|
|
26
|
+
* @param requestOptions KyOptions that were used to assemble the request. THIS MIGHT NOT BE COMPLETE! If custom Ky instance was used that has set defaults then these defaults are not visible in this object!
|
|
27
|
+
* @param message
|
|
28
|
+
*/
|
|
29
|
+
constructor(status: number, response: Response, responseBody: string, requestOptions: KyRequestOptions, message: string);
|
|
30
|
+
}
|
|
31
|
+
export declare class BeeNotAJsonError extends BeeError {
|
|
32
|
+
constructor();
|
|
14
33
|
}
|
|
@@ -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';
|
package/dist/src/utils/http.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import type { BeeRequest, BeeResponse, HookCallback, Ky } from '../types';
|
|
2
2
|
import { Options as KyOptions } from 'ky-universal';
|
|
3
|
-
|
|
4
|
-
path: string;
|
|
5
|
-
responseType?: 'json' | 'arraybuffer' | 'stream';
|
|
6
|
-
/**
|
|
7
|
-
* Overridden parameter that allows undefined as a value.
|
|
8
|
-
*/
|
|
9
|
-
searchParams?: Record<string, string | number | boolean | undefined>;
|
|
10
|
-
}
|
|
3
|
+
import { KyRequestOptions } from '../types';
|
|
11
4
|
interface KyResponse<T> extends Response {
|
|
12
5
|
data: T;
|
|
13
6
|
}
|
|
@@ -20,6 +13,11 @@ export declare function wrapResponseClosure(cb: HookCallback<BeeResponse>): (req
|
|
|
20
13
|
* @param obj
|
|
21
14
|
*/
|
|
22
15
|
export declare function filterHeaders(obj?: object): Record<string, string> | undefined;
|
|
23
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Main utility function to make HTTP requests.
|
|
18
|
+
* @param ky
|
|
19
|
+
* @param config
|
|
20
|
+
*/
|
|
21
|
+
export declare function http<T>(ky: Ky, config: KyRequestOptions): Promise<KyResponse<T>>;
|
|
24
22
|
export declare function makeDefaultKy(kyConfig: KyOptions): Ky;
|
|
25
23
|
export {};
|
|
@@ -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/dist/src/utils/type.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ export declare function isObject(value: unknown): value is Record<string, unknow
|
|
|
12
12
|
* @param value
|
|
13
13
|
*/
|
|
14
14
|
export declare function isStrictlyObject(value: unknown): value is object;
|
|
15
|
+
/**
|
|
16
|
+
* Asserts if object is Error
|
|
17
|
+
*
|
|
18
|
+
* @param e
|
|
19
|
+
*/
|
|
20
|
+
export declare function isError(e: unknown): e is Error;
|
|
15
21
|
export declare function assertStrictlyObject(value: unknown, name?: string): asserts value is object;
|
|
16
22
|
export declare function assertBoolean(value: unknown, name?: string): asserts value is boolean;
|
|
17
23
|
export declare function assertInteger(value: unknown, name?: string): asserts value is number | NumberString;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ethersphere/bee-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Javascript client for Bee",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bee",
|
|
@@ -27,9 +27,12 @@
|
|
|
27
27
|
"./dist/index.min.js": "./dist/index.browser.min.js",
|
|
28
28
|
"data": "data.browser"
|
|
29
29
|
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
30
33
|
"types": "dist/src/index.d.ts",
|
|
31
34
|
"scripts": {
|
|
32
|
-
"
|
|
35
|
+
"prepublishOnly": "rimraf dist && npm run compile:types && npm run compile:browser --env mode=production && npm run compile:node --env mode=production",
|
|
33
36
|
"compile:node": "webpack --progress --env target=node",
|
|
34
37
|
"compile:types": "tsc --emitDeclarationOnly --declaration",
|
|
35
38
|
"compile:browser": "webpack --progress --env target=web",
|
|
@@ -48,29 +51,33 @@
|
|
|
48
51
|
"depcheck": "depcheck ."
|
|
49
52
|
},
|
|
50
53
|
"dependencies": {
|
|
54
|
+
"@types/readable-stream": "^2.3.11",
|
|
55
|
+
"bufferutil": "^4.0.3",
|
|
51
56
|
"cross-blob": "^2.0.1",
|
|
52
57
|
"elliptic": "^6.5.4",
|
|
53
58
|
"isomorphic-ws": "^4.0.1",
|
|
54
59
|
"js-sha3": "^0.8.0",
|
|
55
60
|
"ky": "^0.25.1",
|
|
56
61
|
"ky-universal": "^0.8.2",
|
|
62
|
+
"readable-stream": "^3.6.0",
|
|
57
63
|
"tar-js": "^0.3.0",
|
|
64
|
+
"utf-8-validate": "^5.0.8",
|
|
58
65
|
"web-streams-polyfill": "^3.1.0",
|
|
59
66
|
"ws": "^7.5.0"
|
|
60
67
|
},
|
|
61
68
|
"devDependencies": {
|
|
62
69
|
"@babel/core": "^7.14.6",
|
|
63
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
70
|
+
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
64
71
|
"@babel/plugin-transform-runtime": "^7.14.5",
|
|
65
72
|
"@babel/preset-env": "^7.14.7",
|
|
66
73
|
"@babel/preset-typescript": "^7.14.5",
|
|
67
74
|
"@commitlint/cli": "^12.1.1",
|
|
68
|
-
"@commitlint/config-conventional": "^
|
|
75
|
+
"@commitlint/config-conventional": "^16.0.0",
|
|
69
76
|
"@fluffy-spoon/substitute": "^1.208.0",
|
|
70
77
|
"@jest/test-sequencer": "^27.0.5",
|
|
71
78
|
"@jest/types": "^27.0.2",
|
|
72
|
-
"@types/content-disposition": "^0.5.
|
|
73
|
-
"@types/debug": "^4.1.
|
|
79
|
+
"@types/content-disposition": "^0.5.4",
|
|
80
|
+
"@types/debug": "^4.1.7",
|
|
74
81
|
"@types/elliptic": "^6.4.12",
|
|
75
82
|
"@types/expect-puppeteer": "^4.4.5",
|
|
76
83
|
"@types/glob": "^7.1.3",
|
|
@@ -78,44 +85,38 @@
|
|
|
78
85
|
"@types/jest-environment-puppeteer": "^4.4.1",
|
|
79
86
|
"@types/node": "^15.12.4",
|
|
80
87
|
"@types/puppeteer": "^5.4.3",
|
|
81
|
-
"@types/readable-stream": "^2.3.11",
|
|
82
|
-
"@types/tar-stream": "^2.2.0",
|
|
83
|
-
"@types/terser-webpack-plugin": "^5.0.3",
|
|
84
88
|
"@types/ws": "^7.4.5",
|
|
85
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
86
|
-
"@typescript-eslint/parser": "^
|
|
89
|
+
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
|
90
|
+
"@typescript-eslint/parser": "^5.10.0",
|
|
87
91
|
"babel-jest": "^27.0.5",
|
|
88
92
|
"babel-loader": "^8.2.2",
|
|
89
|
-
"bufferutil": "^4.0.3",
|
|
90
93
|
"debug": "^4.3.1",
|
|
91
|
-
"depcheck": "^1.4.
|
|
92
|
-
"eslint": "^7.
|
|
94
|
+
"depcheck": "^1.4.3",
|
|
95
|
+
"eslint": "^8.7.0",
|
|
93
96
|
"eslint-config-prettier": "^8.3.0",
|
|
94
|
-
"eslint-plugin-jest": "^
|
|
95
|
-
"eslint-plugin-prettier": "^
|
|
96
|
-
"eslint-plugin-unused-imports": "^
|
|
97
|
+
"eslint-plugin-jest": "^25.7.0",
|
|
98
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
99
|
+
"eslint-plugin-unused-imports": "^2.0.0",
|
|
97
100
|
"glob": "^7.1.7",
|
|
98
101
|
"husky": "^6.0.0",
|
|
99
102
|
"jest": "^27.0.5",
|
|
100
103
|
"jest-puppeteer": "^5.0.4",
|
|
101
|
-
"nock": "^13.
|
|
104
|
+
"nock": "^13.2.2",
|
|
102
105
|
"prettier": "^2.3.1",
|
|
103
106
|
"puppeteer": "^9.1.1",
|
|
104
|
-
"readable-stream": "^3.6.0",
|
|
105
107
|
"rimraf": "^3.0.2",
|
|
106
|
-
"terser-webpack-plugin": "^5.
|
|
108
|
+
"terser-webpack-plugin": "^5.3.0",
|
|
107
109
|
"ts-node": "^10.0.0",
|
|
108
|
-
"typedoc": "^0.
|
|
109
|
-
"typedoc-plugin-markdown": "^3.
|
|
110
|
-
"typescript": "^4.
|
|
111
|
-
"
|
|
112
|
-
"webpack": "^5.40.0",
|
|
110
|
+
"typedoc": "^0.22.11",
|
|
111
|
+
"typedoc-plugin-markdown": "^3.11.12",
|
|
112
|
+
"typescript": "^4.5.4",
|
|
113
|
+
"webpack": "^5.65.0",
|
|
113
114
|
"webpack-bundle-analyzer": "^4.4.1",
|
|
114
|
-
"webpack-cli": "^4.
|
|
115
|
+
"webpack-cli": "^4.9.2"
|
|
115
116
|
},
|
|
116
117
|
"engines": {
|
|
117
118
|
"node": ">=12.0.0",
|
|
118
119
|
"npm": ">=6.0.0",
|
|
119
|
-
"bee": "1.
|
|
120
|
+
"bee": "1.4.1-238867f1"
|
|
120
121
|
}
|
|
121
122
|
}
|
package/.babelrc.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
module.exports = function (api) {
|
|
4
|
-
const targets = '>1% or node >=10 and not ie 11 and not dead'
|
|
5
|
-
api.cache(true)
|
|
6
|
-
api.cacheDirectory = true
|
|
7
|
-
|
|
8
|
-
return {
|
|
9
|
-
presets: [
|
|
10
|
-
'@babel/preset-typescript',
|
|
11
|
-
[
|
|
12
|
-
'@babel/preset-env',
|
|
13
|
-
{
|
|
14
|
-
corejs: 3,
|
|
15
|
-
useBuiltIns: 'entry',
|
|
16
|
-
modules: 'commonjs',
|
|
17
|
-
bugfixes: true,
|
|
18
|
-
targets
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
],
|
|
22
|
-
plugins: [
|
|
23
|
-
'@babel/plugin-proposal-class-properties',
|
|
24
|
-
[
|
|
25
|
-
'@babel/plugin-transform-runtime',
|
|
26
|
-
{
|
|
27
|
-
helpers: false,
|
|
28
|
-
regenerator: true
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
}
|
package/.depcheckrc.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"ignores": [
|
|
3
|
-
"@babel/core",
|
|
4
|
-
"@babel/plugin-proposal-class-properties",
|
|
5
|
-
"@babel/plugin-transform-runtime",
|
|
6
|
-
"@babel/preset-env",
|
|
7
|
-
"@babel/preset-typescript",
|
|
8
|
-
"@commitlint/cli",
|
|
9
|
-
"@commitlint/config-conventional",
|
|
10
|
-
"@types/content-disposition",
|
|
11
|
-
"@types/debug",
|
|
12
|
-
"@types/expect-puppeteer",
|
|
13
|
-
"@types/jest",
|
|
14
|
-
"@types/jest-environment-puppeteer",
|
|
15
|
-
"@types/puppeteer",
|
|
16
|
-
"@types/tar-stream",
|
|
17
|
-
"babel-jest",
|
|
18
|
-
"babel-loader",
|
|
19
|
-
"debug",
|
|
20
|
-
"husky",
|
|
21
|
-
"jest-puppeteer",
|
|
22
|
-
"puppeteer",
|
|
23
|
-
"ts-node",
|
|
24
|
-
"typedoc-plugin-markdown",
|
|
25
|
-
"webpack-cli"
|
|
26
|
-
]
|
|
27
|
-
}
|
package/.editorconfig
DELETED
package/.eslintignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
dist/**
|