@ethersphere/bee-js 13.0.0-upcoming.gf9d33e6 → 13.0.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,9 +1,9 @@
1
1
  import { BatchId, Reference } from '@ethersphere/core-sdk';
2
+ import * as bytes from "../api/bytes.js";
3
+ import * as stewardship from "../api/stewardship.js";
2
4
  import { ResourceLocator } from "../utils/resource-locator.js";
3
5
  import { DownloadOptionsSchema, RedundantUploadOptionsSchema } from "../utils/schema.js";
4
6
  import { assertData } from "../utils/type.js";
5
- import * as bytes from "../api/bytes.js";
6
- import * as stewardship from "../api/stewardship.js";
7
7
  /**
8
8
  * Raw data operations backed by the `/bytes` endpoint.
9
9
  *
@@ -17,7 +17,12 @@ export const DEFAULT_HTTP_CONFIG = {
17
17
  * @param config Internal settings and/or Bee settings
18
18
  */
19
19
  export async function http(options, config) {
20
- const requestConfig = Objects.deepMerge3(DEFAULT_HTTP_CONFIG, config, options);
20
+ const rawData = config.data;
21
+ const requestConfig = Objects.deepMerge3(DEFAULT_HTTP_CONFIG, {
22
+ ...config,
23
+ data: undefined
24
+ }, options);
25
+ requestConfig.data = rawData;
21
26
  if (options.signal) {
22
27
  requestConfig.signal = options.signal;
23
28
  }
@@ -28,8 +28,8 @@ export function isTag(value) {
28
28
  * @throws TypeError if not valid
29
29
  */
30
30
  export function assertData(value) {
31
- if (typeof value !== 'string' && !(value instanceof Uint8Array)) {
32
- throw new TypeError('Data must be either string or Uint8Array!');
31
+ if (typeof value !== 'string' && !(value instanceof Uint8Array) && !(value instanceof Blob) && !isReadable(value)) {
32
+ throw new TypeError('Data must be either string, Uint8Array, Blob or Readable!');
33
33
  }
34
34
  }
35
35
  /**
@@ -1,11 +1,12 @@
1
1
  import { BatchId, Bytes, Reference } from '@ethersphere/core-sdk';
2
+ import { Readable } from 'stream';
2
3
  import type { BeeRequestOptions, DownloadOptions, RedundantUploadOptions, ReferenceInformation } from '../types';
3
4
  import { UploadResult } from '../types';
4
5
  import { ResourceLocator } from '../utils/resource-locator';
5
6
  /**
6
7
  * Raw HTTP calls for the `/bytes` endpoint.
7
8
  */
8
- export declare function upload(requestOptions: BeeRequestOptions, data: string | Uint8Array, postageBatchId: BatchId, options?: RedundantUploadOptions): Promise<UploadResult>;
9
+ export declare function upload(requestOptions: BeeRequestOptions, data: string | Uint8Array | Blob | Readable, postageBatchId: BatchId, options?: RedundantUploadOptions): Promise<UploadResult>;
9
10
  export declare function head(requestOptions: BeeRequestOptions, reference: Reference): Promise<ReferenceInformation>;
10
11
  export declare function download(requestOptions: BeeRequestOptions, resource: ResourceLocator, options?: DownloadOptions): Promise<Bytes>;
11
12
  export declare function downloadReadable(requestOptions: BeeRequestOptions, resource: ResourceLocator, options?: DownloadOptions): Promise<ReadableStream<Uint8Array>>;
@@ -1,4 +1,5 @@
1
1
  import { BatchId, Bytes, Reference } from '@ethersphere/core-sdk';
2
+ import { Readable } from 'stream';
2
3
  import type { BeeRequestOptions, DownloadOptions, RedundantUploadOptions, ReferenceInformation, UploadResult } from '../types';
3
4
  import type { BeeContext } from './context';
4
5
  /**
@@ -19,7 +20,7 @@ export declare class Data {
19
20
  * @param options Additional options like tag, encryption, pinning, content-type and request options.
20
21
  * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
21
22
  */
22
- upload(postageBatchId: BatchId | Uint8Array | string, data: string | Uint8Array, options?: RedundantUploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>;
23
+ upload(postageBatchId: BatchId | Uint8Array | string, data: string | Uint8Array | Blob | Readable, options?: RedundantUploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>;
23
24
  /**
24
25
  * Downloads raw data through the `GET /bytes/{reference}` endpoint.
25
26
  *
@@ -12,7 +12,7 @@ export declare function isTag(value: unknown): value is Tag;
12
12
  * @param value
13
13
  * @throws TypeError if not valid
14
14
  */
15
- export declare function assertData(value: unknown): asserts value is string | Uint8Array;
15
+ export declare function assertData(value: unknown): asserts value is string | Uint8Array | Blob | stream.Readable;
16
16
  /**
17
17
  * Check whether the given parameter is a correct file representation to file upload.
18
18
  * @param value
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethersphere/bee-js",
3
- "version": "13.0.0-upcoming.gf9d33e6",
3
+ "version": "13.0.0",
4
4
  "description": "Javascript client for Bee",
5
5
  "keywords": [
6
6
  "bee",