@ethersphere/bee-js 3.2.0 → 3.3.2-pre.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/dist/cjs/bee-debug.js +615 -0
- package/dist/cjs/bee.js +922 -0
- package/dist/cjs/chunk/bmt.js +55 -0
- package/dist/cjs/chunk/cac.js +56 -0
- package/dist/cjs/chunk/serialize.js +19 -0
- package/dist/cjs/chunk/signer.js +137 -0
- package/dist/cjs/chunk/soc.js +172 -0
- package/dist/cjs/chunk/span.js +29 -0
- package/dist/cjs/feed/index.js +184 -0
- package/dist/cjs/feed/json.js +41 -0
- package/dist/cjs/feed/topic.js +25 -0
- package/dist/cjs/feed/type.js +15 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/modules/bytes.js +74 -0
- package/dist/cjs/modules/bzz.js +131 -0
- package/dist/cjs/modules/chunk.js +58 -0
- package/dist/cjs/modules/debug/balance.js +77 -0
- package/dist/cjs/modules/debug/chequebook.js +167 -0
- package/dist/cjs/modules/debug/chunk.js +51 -0
- package/dist/cjs/modules/debug/connectivity.js +75 -0
- package/dist/cjs/modules/debug/settlements.js +45 -0
- package/dist/cjs/modules/debug/stamps.js +89 -0
- package/dist/cjs/modules/debug/states.js +47 -0
- package/dist/cjs/modules/debug/status.js +153 -0
- package/dist/cjs/modules/debug/tag.js +30 -0
- package/dist/cjs/modules/debug/transactions.js +81 -0
- package/dist/cjs/modules/feed.js +76 -0
- package/dist/cjs/modules/pinning.js +84 -0
- package/dist/cjs/modules/pss.js +55 -0
- package/dist/cjs/modules/soc.js +40 -0
- package/dist/cjs/modules/status.js +26 -0
- package/dist/cjs/modules/stewardship.js +41 -0
- package/dist/cjs/modules/tag.js +96 -0
- package/dist/cjs/package.json +8 -0
- package/dist/cjs/types/debug.js +9 -0
- package/dist/cjs/types/index.js +46 -0
- package/dist/cjs/types/ky-options.js +8 -0
- package/dist/cjs/types/ky-universal/common.js +8 -0
- package/dist/cjs/types/ky-universal/hooks.js +8 -0
- package/dist/cjs/types/ky-universal/retry.js +8 -0
- package/dist/cjs/utils/bytes.js +107 -0
- package/dist/cjs/utils/collection.browser.js +36 -0
- package/dist/cjs/utils/collection.js +70 -0
- package/dist/cjs/utils/collection.node.js +115 -0
- package/dist/cjs/utils/data.browser.js +78 -0
- package/dist/cjs/utils/data.js +60 -0
- package/dist/cjs/utils/error.js +50 -0
- package/dist/cjs/utils/eth.js +211 -0
- package/dist/cjs/utils/expose.js +44 -0
- package/dist/cjs/utils/file.js +49 -0
- package/dist/cjs/utils/hash.js +21 -0
- package/dist/cjs/utils/headers.js +59 -0
- package/dist/cjs/utils/hex.js +150 -0
- package/dist/cjs/utils/http.js +166 -0
- package/dist/cjs/utils/merge.js +34 -0
- package/dist/cjs/utils/pss.js +18 -0
- package/dist/cjs/utils/stamps.js +17 -0
- package/dist/cjs/utils/stream.js +146 -0
- package/dist/cjs/utils/tar.js +25 -0
- package/dist/cjs/utils/type.js +327 -0
- package/dist/cjs/utils/uint64.js +29 -0
- package/dist/cjs/utils/url.js +56 -0
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.LICENSE.txt +12 -11
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-debug.js +609 -0
- package/dist/mjs/bee.js +944 -0
- package/dist/mjs/chunk/bmt.js +56 -0
- package/dist/mjs/chunk/cac.js +52 -0
- package/dist/mjs/chunk/serialize.js +15 -0
- package/dist/mjs/chunk/signer.js +131 -0
- package/dist/mjs/chunk/soc.js +139 -0
- package/dist/mjs/chunk/span.js +28 -0
- package/dist/mjs/feed/index.js +145 -0
- package/dist/mjs/feed/json.js +27 -0
- package/dist/mjs/feed/topic.js +21 -0
- package/dist/mjs/feed/type.js +10 -0
- package/dist/mjs/index.js +7 -0
- package/dist/mjs/modules/bytes.js +59 -0
- package/dist/mjs/modules/bzz.js +122 -0
- package/dist/mjs/modules/chunk.js +45 -0
- package/dist/mjs/modules/debug/balance.js +57 -0
- package/dist/mjs/modules/debug/chequebook.js +150 -0
- package/dist/mjs/modules/debug/chunk.js +35 -0
- package/dist/mjs/modules/debug/connectivity.js +45 -0
- package/dist/mjs/modules/debug/settlements.js +29 -0
- package/dist/mjs/modules/debug/stamps.js +64 -0
- package/dist/mjs/modules/debug/states.js +31 -0
- package/dist/mjs/modules/debug/status.js +134 -0
- package/dist/mjs/modules/debug/tag.js +16 -0
- package/dist/mjs/modules/debug/transactions.js +63 -0
- package/dist/mjs/modules/feed.js +67 -0
- package/dist/mjs/modules/pinning.js +66 -0
- package/dist/mjs/modules/pss.js +40 -0
- package/dist/mjs/modules/soc.js +31 -0
- package/dist/mjs/modules/status.js +12 -0
- package/dist/mjs/modules/stewardship.js +24 -0
- package/dist/mjs/modules/tag.js +77 -0
- package/dist/mjs/package.json +8 -0
- package/dist/mjs/types/debug.js +7 -0
- package/dist/mjs/types/index.js +37 -0
- package/dist/mjs/types/ky-options.js +7 -0
- package/dist/mjs/types/ky-universal/common.js +7 -0
- package/dist/mjs/types/ky-universal/hooks.js +7 -0
- package/dist/mjs/types/ky-universal/retry.js +7 -0
- package/dist/mjs/utils/bytes.js +101 -0
- package/dist/mjs/utils/collection.browser.js +19 -0
- package/dist/mjs/utils/collection.js +64 -0
- package/dist/mjs/utils/collection.node.js +74 -0
- package/dist/mjs/utils/data.browser.js +73 -0
- package/dist/mjs/utils/data.js +43 -0
- package/dist/mjs/utils/error.js +56 -0
- package/dist/mjs/utils/eth.js +199 -0
- package/dist/mjs/utils/expose.js +9 -0
- package/dist/mjs/utils/file.js +36 -0
- package/dist/mjs/utils/hash.js +17 -0
- package/dist/mjs/utils/headers.js +58 -0
- package/dist/mjs/utils/hex.js +154 -0
- package/dist/mjs/utils/http.js +155 -0
- package/dist/mjs/utils/merge.js +36 -0
- package/dist/mjs/utils/pss.js +16 -0
- package/dist/mjs/utils/stamps.js +17 -0
- package/dist/mjs/utils/stream.js +156 -0
- package/dist/mjs/utils/tar.js +21 -0
- package/dist/mjs/utils/type.js +336 -0
- package/dist/mjs/utils/uint64.js +23 -0
- package/dist/mjs/utils/url.js +57 -0
- package/dist/{src → types}/bee-debug.d.ts +47 -1
- package/dist/{src → types}/bee.d.ts +0 -0
- package/dist/{src → types}/chunk/bmt.d.ts +0 -0
- package/dist/{src → types}/chunk/cac.d.ts +0 -0
- package/dist/{src → types}/chunk/serialize.d.ts +0 -0
- package/dist/{src → types}/chunk/signer.d.ts +0 -0
- package/dist/{src → types}/chunk/soc.d.ts +0 -0
- package/dist/{src → types}/chunk/span.d.ts +0 -0
- package/dist/{src → types}/feed/index.d.ts +0 -0
- package/dist/{src → types}/feed/json.d.ts +0 -0
- package/dist/{src → types}/feed/topic.d.ts +0 -0
- package/dist/{src → types}/feed/type.d.ts +0 -0
- package/dist/{src → types}/index.d.ts +0 -0
- package/dist/{src → types}/modules/bytes.d.ts +0 -0
- package/dist/{src → types}/modules/bzz.d.ts +0 -0
- package/dist/{src → types}/modules/chunk.d.ts +0 -0
- package/dist/{src → types}/modules/debug/balance.d.ts +0 -0
- package/dist/{src → types}/modules/debug/chequebook.d.ts +0 -0
- package/dist/{src → types}/modules/debug/chunk.d.ts +0 -0
- package/dist/{src → types}/modules/debug/connectivity.d.ts +0 -0
- package/dist/{src → types}/modules/debug/settlements.d.ts +0 -0
- package/dist/{src → types}/modules/debug/stamps.d.ts +0 -0
- package/dist/{src → types}/modules/debug/states.d.ts +0 -0
- package/dist/types/modules/debug/status.d.ts +72 -0
- package/dist/{src → types}/modules/debug/tag.d.ts +0 -0
- package/dist/{src → types}/modules/debug/transactions.d.ts +0 -0
- package/dist/{src → types}/modules/feed.d.ts +0 -0
- package/dist/{src → types}/modules/pinning.d.ts +0 -0
- package/dist/{src → types}/modules/pss.d.ts +0 -0
- package/dist/{src → types}/modules/soc.d.ts +0 -0
- package/dist/{src → types}/modules/status.d.ts +0 -0
- package/dist/{src → types}/modules/stewardship.d.ts +0 -0
- package/dist/{src → types}/modules/tag.d.ts +0 -0
- package/dist/{src → types}/types/debug.d.ts +8 -0
- package/dist/{src → types}/types/index.d.ts +3 -2
- package/dist/types/types/ky-options.d.ts +221 -0
- package/dist/types/types/ky-universal/common.d.ts +13 -0
- package/dist/types/types/ky-universal/hooks.d.ts +92 -0
- package/dist/types/types/ky-universal/retry.d.ts +38 -0
- package/dist/{src → types}/utils/bytes.d.ts +0 -0
- package/dist/types/utils/collection.browser.d.ts +15 -0
- package/dist/{src → types}/utils/collection.d.ts +0 -14
- package/dist/types/utils/collection.node.d.ts +15 -0
- package/dist/{src → types}/utils/data.browser.d.ts +0 -0
- package/dist/{src → types}/utils/data.d.ts +0 -0
- package/dist/{src → types}/utils/error.d.ts +0 -0
- package/dist/{src → types}/utils/eth.d.ts +0 -0
- package/dist/{src → types}/utils/expose.d.ts +2 -1
- package/dist/{src → types}/utils/file.d.ts +0 -0
- package/dist/{src → types}/utils/hash.d.ts +0 -0
- package/dist/{src → types}/utils/headers.d.ts +0 -0
- package/dist/{src → types}/utils/hex.d.ts +0 -0
- package/dist/{src → types}/utils/http.d.ts +0 -0
- package/dist/{src → types}/utils/merge.d.ts +0 -0
- package/dist/{src → types}/utils/pss.d.ts +0 -0
- package/dist/{src → types}/utils/stamps.d.ts +0 -0
- package/dist/{src → types}/utils/stream.d.ts +11 -8
- package/dist/{src → types}/utils/tar.d.ts +0 -0
- package/dist/{src → types}/utils/type.d.ts +0 -0
- package/dist/{src → types}/utils/uint64.d.ts +0 -0
- package/dist/{src → types}/utils/url.d.ts +0 -0
- package/package.json +55 -36
- package/dist/index.min.js +0 -3
- package/dist/index.min.js.LICENSE.txt +0 -50
- package/dist/index.min.js.map +0 -1
- package/dist/src/modules/debug/status.d.ts +0 -24
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types extracted from Ky as a backport for older Ky non-ESM version
|
|
3
|
+
*
|
|
4
|
+
* @author https://github.com/sindresorhus
|
|
5
|
+
* @licence MIT https://github.com/sindresorhus/ky/blob/main/license
|
|
6
|
+
*/
|
|
7
|
+
import type { LiteralUnion, Required } from './ky-universal/common';
|
|
8
|
+
import type { Hooks } from './ky-universal/hooks';
|
|
9
|
+
import type { RetryOptions } from './ky-universal/retry';
|
|
10
|
+
export declare type SearchParamsInit = string | string[][] | Record<string, string> | URLSearchParams | undefined;
|
|
11
|
+
export declare type SearchParamsOption = SearchParamsInit | Record<string, string | number | boolean> | Array<Array<string | number | boolean>>;
|
|
12
|
+
export declare type HTTPMethod = 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete';
|
|
13
|
+
export declare type Input = string | URL | Request;
|
|
14
|
+
export interface DownloadProgress {
|
|
15
|
+
percent: number;
|
|
16
|
+
transferredBytes: number;
|
|
17
|
+
/**
|
|
18
|
+
Note: If it's not possible to retrieve the body size, it will be `0`.
|
|
19
|
+
*/
|
|
20
|
+
totalBytes: number;
|
|
21
|
+
}
|
|
22
|
+
export declare type KyHeadersInit = HeadersInit | Record<string, string | undefined>;
|
|
23
|
+
/**
|
|
24
|
+
Options are the same as `window.fetch`, with some exceptions.
|
|
25
|
+
*/
|
|
26
|
+
export interface Options extends Omit<RequestInit, 'headers'> {
|
|
27
|
+
/**
|
|
28
|
+
HTTP method used to make the request.
|
|
29
|
+
|
|
30
|
+
Internally, the standard methods (`GET`, `POST`, `PUT`, `PATCH`, `HEAD` and `DELETE`) are uppercased in order to avoid server errors due to case sensitivity.
|
|
31
|
+
*/
|
|
32
|
+
method?: LiteralUnion<HTTPMethod, string>;
|
|
33
|
+
/**
|
|
34
|
+
HTTP headers used to make the request.
|
|
35
|
+
|
|
36
|
+
You can pass a `Headers` instance or a plain object.
|
|
37
|
+
|
|
38
|
+
You can remove a header with `.extend()` by passing the header with an `undefined` value.
|
|
39
|
+
|
|
40
|
+
@example
|
|
41
|
+
```
|
|
42
|
+
import ky from 'ky';
|
|
43
|
+
|
|
44
|
+
const url = 'https://sindresorhus.com';
|
|
45
|
+
|
|
46
|
+
const original = ky.create({
|
|
47
|
+
headers: {
|
|
48
|
+
rainbow: 'rainbow',
|
|
49
|
+
unicorn: 'unicorn'
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const extended = original.extend({
|
|
54
|
+
headers: {
|
|
55
|
+
rainbow: undefined
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const response = await extended(url).json();
|
|
60
|
+
|
|
61
|
+
console.log('rainbow' in response);
|
|
62
|
+
//=> false
|
|
63
|
+
|
|
64
|
+
console.log('unicorn' in response);
|
|
65
|
+
//=> true
|
|
66
|
+
```
|
|
67
|
+
*/
|
|
68
|
+
headers?: KyHeadersInit;
|
|
69
|
+
/**
|
|
70
|
+
Shortcut for sending JSON. Use this instead of the `body` option.
|
|
71
|
+
|
|
72
|
+
Accepts any plain object or value, which will be `JSON.stringify()`'d and sent in the body with the correct header set.
|
|
73
|
+
*/
|
|
74
|
+
json?: unknown;
|
|
75
|
+
/**
|
|
76
|
+
User-defined JSON-parsing function.
|
|
77
|
+
|
|
78
|
+
Use-cases:
|
|
79
|
+
1. Parse JSON via the [`bourne` package](https://github.com/hapijs/bourne) to protect from prototype pollution.
|
|
80
|
+
2. Parse JSON with [`reviver` option of `JSON.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
|
|
81
|
+
|
|
82
|
+
@default JSON.parse()
|
|
83
|
+
|
|
84
|
+
@example
|
|
85
|
+
```
|
|
86
|
+
import ky from 'ky';
|
|
87
|
+
import bourne from '@hapijs/bourne';
|
|
88
|
+
|
|
89
|
+
const json = await ky('https://example.com', {
|
|
90
|
+
parseJson: text => bourne(text)
|
|
91
|
+
}).json();
|
|
92
|
+
```
|
|
93
|
+
*/
|
|
94
|
+
parseJson?: (text: string) => unknown;
|
|
95
|
+
/**
|
|
96
|
+
Search parameters to include in the request URL. Setting this will override all existing search parameters in the input URL.
|
|
97
|
+
|
|
98
|
+
Accepts any value supported by [`URLSearchParams()`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/URLSearchParams).
|
|
99
|
+
*/
|
|
100
|
+
searchParams?: SearchParamsOption;
|
|
101
|
+
/**
|
|
102
|
+
A prefix to prepend to the `input` URL when making the request. It can be any valid URL, either relative or absolute. A trailing slash `/` is optional and will be added automatically, if needed, when it is joined with `input`. Only takes effect when `input` is a string. The `input` argument cannot start with a slash `/` when using this option.
|
|
103
|
+
|
|
104
|
+
Useful when used with `ky.extend()` to create niche-specific Ky-instances.
|
|
105
|
+
|
|
106
|
+
Notes:
|
|
107
|
+
- After `prefixUrl` and `input` are joined, the result is resolved against the [base URL](https://developer.mozilla.org/en-US/docs/Web/API/Node/baseURI) of the page (if any).
|
|
108
|
+
- Leading slashes in `input` are disallowed when using this option to enforce consistency and avoid confusion about how the `input` URL is handled, given that `input` will not follow the normal URL resolution rules when `prefixUrl` is being used, which changes the meaning of a leading slash.
|
|
109
|
+
|
|
110
|
+
@example
|
|
111
|
+
```
|
|
112
|
+
import ky from 'ky';
|
|
113
|
+
|
|
114
|
+
// On https://example.com
|
|
115
|
+
|
|
116
|
+
const response = await ky('unicorn', {prefixUrl: '/api'});
|
|
117
|
+
//=> 'https://example.com/api/unicorn'
|
|
118
|
+
|
|
119
|
+
const response = await ky('unicorn', {prefixUrl: 'https://cats.com'});
|
|
120
|
+
//=> 'https://cats.com/unicorn'
|
|
121
|
+
```
|
|
122
|
+
*/
|
|
123
|
+
prefixUrl?: URL | string;
|
|
124
|
+
/**
|
|
125
|
+
An object representing `limit`, `methods`, `statusCodes` and `maxRetryAfter` fields for maximum retry count, allowed methods, allowed status codes and maximum [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) time.
|
|
126
|
+
|
|
127
|
+
If `retry` is a number, it will be used as `limit` and other defaults will remain in place.
|
|
128
|
+
|
|
129
|
+
If `maxRetryAfter` is set to `undefined`, it will use `options.timeout`. If [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header is greater than `maxRetryAfter`, it will cancel the request.
|
|
130
|
+
|
|
131
|
+
Delays between retries is calculated with the function `0.3 * (2 ** (retry - 1)) * 1000`, where `retry` is the attempt number (starts from 1).
|
|
132
|
+
|
|
133
|
+
@example
|
|
134
|
+
```
|
|
135
|
+
import ky from 'ky';
|
|
136
|
+
|
|
137
|
+
const json = await ky('https://example.com', {
|
|
138
|
+
retry: {
|
|
139
|
+
limit: 10,
|
|
140
|
+
methods: ['get'],
|
|
141
|
+
statusCodes: [413]
|
|
142
|
+
}
|
|
143
|
+
}).json();
|
|
144
|
+
```
|
|
145
|
+
*/
|
|
146
|
+
retry?: RetryOptions | number;
|
|
147
|
+
/**
|
|
148
|
+
Timeout in milliseconds for getting a response. Can not be greater than 2147483647.
|
|
149
|
+
If set to `false`, there will be no timeout.
|
|
150
|
+
|
|
151
|
+
@default 10000
|
|
152
|
+
*/
|
|
153
|
+
timeout?: number | false;
|
|
154
|
+
/**
|
|
155
|
+
Hooks allow modifications during the request lifecycle. Hook functions may be async and are run serially.
|
|
156
|
+
*/
|
|
157
|
+
hooks?: Hooks;
|
|
158
|
+
/**
|
|
159
|
+
Throw an `HTTPError` when, after following redirects, the response has a non-2xx status code. To also throw for redirects instead of following them, set the [`redirect`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) option to `'manual'`.
|
|
160
|
+
|
|
161
|
+
Setting this to `false` may be useful if you are checking for resource availability and are expecting error responses.
|
|
162
|
+
|
|
163
|
+
@default true
|
|
164
|
+
*/
|
|
165
|
+
throwHttpErrors?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
Download progress event handler.
|
|
168
|
+
|
|
169
|
+
@param chunk - Note: It's empty for the first call.
|
|
170
|
+
|
|
171
|
+
@example
|
|
172
|
+
```
|
|
173
|
+
import ky from 'ky';
|
|
174
|
+
|
|
175
|
+
const response = await ky('https://example.com', {
|
|
176
|
+
onDownloadProgress: (progress, chunk) => {
|
|
177
|
+
// Example output:
|
|
178
|
+
// `0% - 0 of 1271 bytes`
|
|
179
|
+
// `100% - 1271 of 1271 bytes`
|
|
180
|
+
console.log(`${progress.percent * 100}% - ${progress.transferredBytes} of ${progress.totalBytes} bytes`);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
```
|
|
184
|
+
*/
|
|
185
|
+
onDownloadProgress?: (progress: DownloadProgress, chunk: Uint8Array) => void;
|
|
186
|
+
/**
|
|
187
|
+
User-defined `fetch` function.
|
|
188
|
+
Has to be fully compatible with the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) standard.
|
|
189
|
+
|
|
190
|
+
Use-cases:
|
|
191
|
+
1. Use custom `fetch` implementations like [`isomorphic-unfetch`](https://www.npmjs.com/package/isomorphic-unfetch).
|
|
192
|
+
2. Use the `fetch` wrapper function provided by some frameworks that use server-side rendering (SSR).
|
|
193
|
+
|
|
194
|
+
@default fetch
|
|
195
|
+
|
|
196
|
+
@example
|
|
197
|
+
```
|
|
198
|
+
import ky from 'ky';
|
|
199
|
+
import fetch from 'isomorphic-unfetch';
|
|
200
|
+
|
|
201
|
+
const json = await ky('https://example.com', {fetch}).json();
|
|
202
|
+
```
|
|
203
|
+
*/
|
|
204
|
+
fetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
205
|
+
}
|
|
206
|
+
export declare type InternalOptions = Required<Omit<Options, 'hooks' | 'retry'>, 'credentials' | 'fetch' | 'prefixUrl' | 'timeout'> & {
|
|
207
|
+
hooks: Required<Hooks>;
|
|
208
|
+
retry: Required<RetryOptions>;
|
|
209
|
+
prefixUrl: string;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
Normalized options passed to the `fetch` call and the `beforeRequest` hooks.
|
|
213
|
+
*/
|
|
214
|
+
export interface NormalizedOptions extends RequestInit {
|
|
215
|
+
method: RequestInit['method'];
|
|
216
|
+
credentials: RequestInit['credentials'];
|
|
217
|
+
retry: RetryOptions;
|
|
218
|
+
prefixUrl: string;
|
|
219
|
+
onDownloadProgress: Options['onDownloadProgress'];
|
|
220
|
+
}
|
|
221
|
+
export { RetryOptions };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types extracted from Ky as a backport for older Ky non-ESM version
|
|
3
|
+
*
|
|
4
|
+
* @author https://github.com/sindresorhus
|
|
5
|
+
* @licence MIT https://github.com/sindresorhus/ky/blob/main/license
|
|
6
|
+
*/
|
|
7
|
+
export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
8
|
+
export declare type Required<T, K extends keyof T = keyof T> = T & {
|
|
9
|
+
[P in K]-?: T[P];
|
|
10
|
+
};
|
|
11
|
+
export declare type LiteralUnion<LiteralType extends BaseType, BaseType extends Primitive> = LiteralType | (BaseType & {
|
|
12
|
+
_?: never;
|
|
13
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types extracted from Ky as a backport for older Ky non-ESM version
|
|
3
|
+
*
|
|
4
|
+
* @author https://github.com/sindresorhus
|
|
5
|
+
* @licence MIT https://github.com/sindresorhus/ky/blob/main/license
|
|
6
|
+
*/
|
|
7
|
+
import type { NormalizedOptions } from '../ky-options';
|
|
8
|
+
export declare const stop: unique symbol;
|
|
9
|
+
export declare type BeforeRequestHook = (request: Request, options: NormalizedOptions) => Request | Response | void | Promise<Request | Response | void>;
|
|
10
|
+
export declare type BeforeRetryState = {
|
|
11
|
+
request: Request;
|
|
12
|
+
response: Response;
|
|
13
|
+
options: NormalizedOptions;
|
|
14
|
+
error: Error;
|
|
15
|
+
retryCount: number;
|
|
16
|
+
};
|
|
17
|
+
export declare type BeforeRetryHook = (options: BeforeRetryState) => typeof stop | void | Promise<typeof stop | void>;
|
|
18
|
+
export declare type AfterResponseHook = (request: Request, options: NormalizedOptions, response: Response) => Response | void | Promise<Response | void>;
|
|
19
|
+
export interface Hooks {
|
|
20
|
+
/**
|
|
21
|
+
This hook enables you to modify the request right before it is sent. Ky will make no further changes to the request after this. The hook function receives normalized input and options as arguments. You could, forf example, modiy `options.headers` here.
|
|
22
|
+
|
|
23
|
+
A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned from this hook to completely avoid making a HTTP request. This can be used to mock a request, check an internal cache, etc. An **important** consideration when returning a `Response` from this hook is that all the following hooks will be skipped, so **ensure you only return a `Response` from the last hook**.
|
|
24
|
+
|
|
25
|
+
@default []
|
|
26
|
+
*/
|
|
27
|
+
beforeRequest?: BeforeRequestHook[];
|
|
28
|
+
/**
|
|
29
|
+
This hook enables you to modify the request right before retry. Ky will make no further changes to the request after this. The hook function receives an object with the normalized request and options, an error instance, and the retry count. You could, for example, modify `request.headers` here.
|
|
30
|
+
|
|
31
|
+
If the request received a response, the error will be of type `HTTPError` and the `Response` object will be available at `error.response`. Be aware that some types of errors, such as network errors, inherently mean that a response was not received. In that case, the error will not be an instance of `HTTPError`.
|
|
32
|
+
|
|
33
|
+
You can prevent Ky from retrying the request by throwing an error. Ky will not handle it in any way and the error will be propagated to the request initiator. The rest of the `beforeRetry` hooks will not be called in this case. Alternatively, you can return the [`ky.stop`](#ky.stop) symbol to do the same thing but without propagating an error (this has some limitations, see `ky.stop` docs for details).
|
|
34
|
+
|
|
35
|
+
@example
|
|
36
|
+
```
|
|
37
|
+
import ky from 'ky';
|
|
38
|
+
|
|
39
|
+
const response = await ky('https://example.com', {
|
|
40
|
+
hooks: {
|
|
41
|
+
beforeRetry: [
|
|
42
|
+
async ({request, options, error, retryCount}) => {
|
|
43
|
+
const token = await ky('https://example.com/refresh-token');
|
|
44
|
+
options.headers.set('Authorization', `token ${token}`);
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
@default []
|
|
52
|
+
*/
|
|
53
|
+
beforeRetry?: BeforeRetryHook[];
|
|
54
|
+
/**
|
|
55
|
+
This hook enables you to read and optionally modify the response. The hook function receives normalized input, options, and a clone of the response as arguments. The return value of the hook function will be used by Ky as the response object if it's an instance of [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
|
|
56
|
+
|
|
57
|
+
@default []
|
|
58
|
+
|
|
59
|
+
@example
|
|
60
|
+
```
|
|
61
|
+
import ky from 'ky';
|
|
62
|
+
|
|
63
|
+
const response = await ky('https://example.com', {
|
|
64
|
+
hooks: {
|
|
65
|
+
afterResponse: [
|
|
66
|
+
(_input, _options, response) => {
|
|
67
|
+
// You could do something with the response, for example, logging.
|
|
68
|
+
log(response);
|
|
69
|
+
|
|
70
|
+
// Or return a `Response` instance to overwrite the response.
|
|
71
|
+
return new Response('A different response', {status: 200});
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
// Or retry with a fresh token on a 403 error
|
|
75
|
+
async (input, options, response) => {
|
|
76
|
+
if (response.status === 403) {
|
|
77
|
+
// Get a fresh token
|
|
78
|
+
const token = await ky('https://example.com/token').text();
|
|
79
|
+
|
|
80
|
+
// Retry with the token
|
|
81
|
+
options.headers.set('Authorization', `token ${token}`);
|
|
82
|
+
|
|
83
|
+
return ky(input, options);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
*/
|
|
91
|
+
afterResponse?: AfterResponseHook[];
|
|
92
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types extracted from Ky as a backport for older Ky non-ESM version
|
|
3
|
+
*
|
|
4
|
+
* @author https://github.com/sindresorhus
|
|
5
|
+
* @licence MIT https://github.com/sindresorhus/ky/blob/main/license
|
|
6
|
+
*/
|
|
7
|
+
export interface RetryOptions {
|
|
8
|
+
/**
|
|
9
|
+
The number of times to retry failed requests.
|
|
10
|
+
|
|
11
|
+
@default 2
|
|
12
|
+
*/
|
|
13
|
+
limit?: number;
|
|
14
|
+
/**
|
|
15
|
+
The HTTP methods allowed to retry.
|
|
16
|
+
|
|
17
|
+
@default ['get', 'put', 'head', 'delete', 'options', 'trace']
|
|
18
|
+
*/
|
|
19
|
+
methods?: string[];
|
|
20
|
+
/**
|
|
21
|
+
The HTTP status codes allowed to retry.
|
|
22
|
+
|
|
23
|
+
@default [408, 413, 429, 500, 502, 503, 504]
|
|
24
|
+
*/
|
|
25
|
+
statusCodes?: number[];
|
|
26
|
+
/**
|
|
27
|
+
The HTTP status codes allowed to retry with a `Retry-After` header.
|
|
28
|
+
|
|
29
|
+
@default [413, 429, 503]
|
|
30
|
+
*/
|
|
31
|
+
afterStatusCodes?: number[];
|
|
32
|
+
/**
|
|
33
|
+
If the `Retry-After` header is greater than `maxRetryAfter`, the request will be canceled.
|
|
34
|
+
|
|
35
|
+
@default Infinity
|
|
36
|
+
*/
|
|
37
|
+
maxRetryAfter?: number;
|
|
38
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Collection } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates array in the format of Collection with data loaded from directory on filesystem.
|
|
4
|
+
* The function loads all the data into memory!
|
|
5
|
+
*
|
|
6
|
+
* @param dir path to the directory
|
|
7
|
+
*/
|
|
8
|
+
export declare function makeCollectionFromFS(dir: string): Promise<Collection<Uint8Array>>;
|
|
9
|
+
/**
|
|
10
|
+
* Calculate folder size recursively
|
|
11
|
+
*
|
|
12
|
+
* @param dir the path to the folder to check
|
|
13
|
+
* @returns size in bytes
|
|
14
|
+
*/
|
|
15
|
+
export declare function getFolderSize(dir: string): Promise<number>;
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { Collection } from '../types';
|
|
2
2
|
export declare function isCollection(data: unknown): data is Collection<Uint8Array>;
|
|
3
3
|
export declare function assertCollection(data: unknown): asserts data is Collection<Uint8Array>;
|
|
4
|
-
/**
|
|
5
|
-
* Creates array in the format of Collection with data loaded from directory on filesystem.
|
|
6
|
-
* The function loads all the data into memory!
|
|
7
|
-
*
|
|
8
|
-
* @param dir path to the directory
|
|
9
|
-
*/
|
|
10
|
-
export declare function makeCollectionFromFS(dir: string): Promise<Collection<Uint8Array>>;
|
|
11
4
|
export declare function makeCollectionFromFileList(fileList: FileList | File[]): Promise<Collection<Uint8Array>>;
|
|
12
5
|
/**
|
|
13
6
|
* Calculate cumulative size of files
|
|
@@ -16,10 +9,3 @@ export declare function makeCollectionFromFileList(fileList: FileList | File[]):
|
|
|
16
9
|
* @returns size in bytes
|
|
17
10
|
*/
|
|
18
11
|
export declare function getCollectionSize(fileList: FileList | File[]): number;
|
|
19
|
-
/**
|
|
20
|
-
* Calculate folder size recursively
|
|
21
|
-
*
|
|
22
|
-
* @param dir the path to the folder to check
|
|
23
|
-
* @returns size in bytes
|
|
24
|
-
*/
|
|
25
|
-
export declare function getFolderSize(dir: string): Promise<number>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Collection } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates array in the format of Collection with data loaded from directory on filesystem.
|
|
4
|
+
* The function loads all the data into memory!
|
|
5
|
+
*
|
|
6
|
+
* @param dir path to the directory
|
|
7
|
+
*/
|
|
8
|
+
export declare function makeCollectionFromFS(dir: string): Promise<Collection<Uint8Array>>;
|
|
9
|
+
/**
|
|
10
|
+
* Calculate folder size recursively
|
|
11
|
+
*
|
|
12
|
+
* @param dir the path to the folder to check
|
|
13
|
+
* @returns size in bytes
|
|
14
|
+
*/
|
|
15
|
+
export declare function getFolderSize(dir: string): Promise<number>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { getCollectionSize
|
|
1
|
+
export { getCollectionSize } from './collection';
|
|
2
|
+
export { getFolderSize } from './collection.node';
|
|
2
3
|
export { Bytes, FlexBytes, isBytes, assertBytes, isFlexBytes, assertFlexBytes, bytesAtOffset, flexBytesAtOffset, bytesEqual, } from './bytes';
|
|
3
4
|
export { HexString, PrefixedHexString, makeHexString, hexToBytes, bytesToHex, intToHex, isHexString, assertHexString, assertPrefixedHexString, } from './hex';
|
|
4
5
|
export { EthAddress, makeEthAddress, makeHexEthAddress, isHexEthAddress, ethToSwarmAddress, toLittleEndian, fromLittleEndian, makeEthereumWalletSigner, } from './eth';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
3
|
-
import { ReadableStream } from 'web-streams-polyfill
|
|
4
|
-
import { ReadableOptions as NodeReadableOptions } from 'readable-stream';
|
|
2
|
+
import { Readable as NodeReadableNative, ReadableOptions as NodeReadableOptions } from 'stream';
|
|
3
|
+
import { ReadableStream } from 'web-streams-polyfill';
|
|
5
4
|
import { Readable } from '../types';
|
|
6
5
|
/**
|
|
7
6
|
* Validates if passed object is either browser's ReadableStream
|
|
@@ -9,9 +8,9 @@ import { Readable } from '../types';
|
|
|
9
8
|
*
|
|
10
9
|
* @param entry
|
|
11
10
|
*/
|
|
12
|
-
export declare function isReadable(entry: unknown): entry is
|
|
11
|
+
export declare function isReadable(entry: unknown): entry is Readable;
|
|
13
12
|
export declare function isReadableStream(entry: unknown): entry is ReadableStream;
|
|
14
|
-
export declare function isNodeReadable(entry: unknown): entry is
|
|
13
|
+
export declare function isNodeReadable(entry: unknown): entry is NodeReadableNative;
|
|
15
14
|
/**
|
|
16
15
|
* Function that converts Node's Readable into WHATWG ReadableStream
|
|
17
16
|
*
|
|
@@ -22,16 +21,20 @@ export declare function isNodeReadable(entry: unknown): entry is NodeReadableTyp
|
|
|
22
21
|
* @licence Apache License 2.0 https://github.com/gwicke/node-web-streams/blob/master/LICENSE
|
|
23
22
|
* @param nodeStream
|
|
24
23
|
*/
|
|
25
|
-
export declare function readableNodeToWeb(nodeStream:
|
|
24
|
+
export declare function readableNodeToWeb(nodeStream: NodeReadableNative): ReadableStream<Uint8Array>;
|
|
26
25
|
/**
|
|
27
26
|
* Function that converts WHATWG ReadableStream into Node's Readable
|
|
28
27
|
*
|
|
29
28
|
* Taken over from https://github.com/gwicke/node-web-streams/blob/master/lib/conversions.js
|
|
30
|
-
* Because it uses forked web-streams-polyfill that
|
|
29
|
+
* Because it uses forked web-streams-polyfill that is outdated.
|
|
30
|
+
*
|
|
31
|
+
* **Warning!**
|
|
32
|
+
* If you want to use this function in browser you have to polyfill `stream` package with your bundler.
|
|
31
33
|
*
|
|
32
34
|
* @author https://github.com/gwicke
|
|
33
35
|
* @licence Apache License 2.0 https://github.com/gwicke/node-web-streams/blob/master/LICENSE
|
|
34
36
|
* @param webStream
|
|
37
|
+
* @param options
|
|
35
38
|
*/
|
|
36
|
-
export declare function readableWebToNode(webStream: ReadableStream
|
|
39
|
+
export declare function readableWebToNode(webStream: ReadableStream<unknown>, options?: NodeReadableOptions): NodeReadableNative;
|
|
37
40
|
export declare function normalizeToReadableStream(stream: Readable): ReadableStream;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|