@ethersphere/bee-js 3.3.2 → 3.3.3-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/mjs/bee-debug.js +294 -189
- package/dist/mjs/bee.js +316 -237
- package/dist/mjs/chunk/signer.js +46 -12
- package/dist/mjs/chunk/soc.js +71 -31
- package/dist/mjs/chunk/span.js +1 -1
- package/dist/mjs/feed/index.js +86 -42
- package/dist/mjs/feed/json.js +46 -10
- package/dist/mjs/index.js +2 -1
- package/dist/mjs/modules/bytes.js +61 -24
- package/dist/mjs/modules/bzz.js +96 -58
- package/dist/mjs/modules/chunk.js +51 -16
- package/dist/mjs/modules/debug/balance.js +60 -20
- package/dist/mjs/modules/debug/chequebook.js +115 -67
- package/dist/mjs/modules/debug/chunk.js +47 -11
- package/dist/mjs/modules/debug/connectivity.js +76 -32
- package/dist/mjs/modules/debug/settlements.js +46 -10
- package/dist/mjs/modules/debug/stamps.js +91 -47
- package/dist/mjs/modules/debug/states.js +48 -12
- package/dist/mjs/modules/debug/status.js +97 -49
- package/dist/mjs/modules/debug/tag.js +39 -5
- package/dist/mjs/modules/debug/transactions.js +65 -25
- package/dist/mjs/modules/feed.js +50 -16
- package/dist/mjs/modules/pinning.js +67 -27
- package/dist/mjs/modules/pss.js +44 -10
- package/dist/mjs/modules/soc.js +47 -14
- package/dist/mjs/modules/status.js +37 -3
- package/dist/mjs/modules/stewardship.js +46 -10
- package/dist/mjs/modules/tag.js +73 -31
- package/dist/mjs/utils/collection.browser.js +41 -4
- package/dist/mjs/utils/collection.js +45 -11
- package/dist/mjs/utils/collection.node.js +137 -42
- package/dist/mjs/utils/data.browser.js +88 -52
- package/dist/mjs/utils/data.js +57 -21
- package/dist/mjs/utils/error.js +0 -9
- package/dist/mjs/utils/eth.js +68 -32
- package/dist/mjs/utils/file.js +42 -8
- package/dist/mjs/utils/headers.js +4 -4
- package/dist/mjs/utils/http.js +110 -64
- package/dist/mjs/utils/merge.js +2 -2
- package/dist/mjs/utils/stream.js +0 -4
- package/dist/mjs/utils/type.js +6 -6
- package/package.json +2 -2
package/dist/mjs/utils/http.js
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) {
|
|
3
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
+
resolve(value);
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) {
|
|
10
|
+
try {
|
|
11
|
+
step(generator.next(value));
|
|
12
|
+
} catch (e) {
|
|
13
|
+
reject(e);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function rejected(value) {
|
|
18
|
+
try {
|
|
19
|
+
step(generator["throw"](value));
|
|
20
|
+
} catch (e) {
|
|
21
|
+
reject(e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function step(result) {
|
|
26
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
34
|
+
var t = {};
|
|
35
|
+
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
37
|
+
|
|
38
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
39
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
40
|
+
}
|
|
41
|
+
return t;
|
|
42
|
+
};
|
|
43
|
+
|
|
1
44
|
import { BeeError, BeeNotAJsonError, BeeRequestError, BeeResponseError } from "./error.js";
|
|
2
45
|
import kyFactory from 'ky-universal';
|
|
3
46
|
import { normalizeToReadableStream } from "./stream.js";
|
|
@@ -34,19 +77,19 @@ function wrapRequest(request) {
|
|
|
34
77
|
}
|
|
35
78
|
|
|
36
79
|
export function wrapRequestClosure(cb) {
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
};
|
|
80
|
+
return request => __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
yield cb(wrapRequest(request));
|
|
82
|
+
});
|
|
40
83
|
}
|
|
41
84
|
export function wrapResponseClosure(cb) {
|
|
42
|
-
return
|
|
43
|
-
|
|
85
|
+
return (request, options, response) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
yield cb({
|
|
44
87
|
headers: headersToObject(response.headers),
|
|
45
88
|
status: response.status,
|
|
46
89
|
statusText: response.statusText,
|
|
47
90
|
request: wrapRequest(request)
|
|
48
91
|
});
|
|
49
|
-
};
|
|
92
|
+
});
|
|
50
93
|
}
|
|
51
94
|
/**
|
|
52
95
|
* Filters out entries that has undefined value from headers object.
|
|
@@ -82,73 +125,76 @@ export function filterHeaders(obj) {
|
|
|
82
125
|
* @param config
|
|
83
126
|
*/
|
|
84
127
|
|
|
85
|
-
export
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
128
|
+
export function http(ky, config) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
try {
|
|
131
|
+
const {
|
|
132
|
+
path,
|
|
133
|
+
responseType
|
|
134
|
+
} = config,
|
|
135
|
+
kyConfig = __rest(config, ["path", "responseType"]);
|
|
136
|
+
|
|
137
|
+
const response = yield ky(path, Object.assign(Object.assign({}, kyConfig), {
|
|
138
|
+
searchParams: filterHeaders(kyConfig.searchParams)
|
|
139
|
+
}));
|
|
140
|
+
|
|
141
|
+
switch (responseType) {
|
|
142
|
+
case 'stream':
|
|
143
|
+
if (!response.body) {
|
|
144
|
+
throw new BeeError('Response was expected to get data but did not get any!');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
response.data = normalizeToReadableStream(response.body);
|
|
148
|
+
break;
|
|
149
|
+
|
|
150
|
+
case 'arraybuffer':
|
|
151
|
+
response.data = yield response.arrayBuffer();
|
|
152
|
+
break;
|
|
153
|
+
|
|
154
|
+
case 'json':
|
|
155
|
+
try {
|
|
156
|
+
response.data = yield response.json();
|
|
157
|
+
} catch (e) {
|
|
158
|
+
throw new BeeNotAJsonError();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
break;
|
|
162
|
+
|
|
163
|
+
default:
|
|
164
|
+
break;
|
|
165
|
+
// If responseType is not set, then no data are expected
|
|
166
|
+
}
|
|
95
167
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
168
|
+
return response;
|
|
169
|
+
} catch (e) {
|
|
170
|
+
// Passthrough thrown errors
|
|
171
|
+
if (e instanceof BeeNotAJsonError) {
|
|
172
|
+
throw e;
|
|
173
|
+
}
|
|
101
174
|
|
|
102
|
-
|
|
103
|
-
|
|
175
|
+
if (isHttpError(e)) {
|
|
176
|
+
let message; // We store the response body here as it can be read only once in Response's lifecycle so to make it exposed
|
|
177
|
+
// to the user in the BeeResponseError, for further analysis.
|
|
104
178
|
|
|
105
|
-
|
|
106
|
-
response.data = await response.arrayBuffer();
|
|
107
|
-
break;
|
|
179
|
+
const body = yield e.response.text();
|
|
108
180
|
|
|
109
|
-
case 'json':
|
|
110
181
|
try {
|
|
111
|
-
response
|
|
112
|
-
|
|
113
|
-
|
|
182
|
+
// The response can be Bee's JSON with structure `{code, message}` lets try to parse it
|
|
183
|
+
message = JSON.parse(body).message;
|
|
184
|
+
} catch (e) {}
|
|
185
|
+
|
|
186
|
+
if (message) {
|
|
187
|
+
throw new BeeResponseError(e.response.status, e.response, body, config, `${e.response.statusText}: ${message}`);
|
|
188
|
+
} else {
|
|
189
|
+
throw new BeeResponseError(e.response.status, e.response, body, config, e.response.statusText);
|
|
114
190
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
default:
|
|
119
|
-
break;
|
|
120
|
-
// If responseType is not set, then no data are expected
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return response;
|
|
124
|
-
} catch (e) {
|
|
125
|
-
// Passthrough thrown errors
|
|
126
|
-
if (e instanceof BeeNotAJsonError) {
|
|
127
|
-
throw e;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (isHttpError(e)) {
|
|
131
|
-
let message; // We store the response body here as it can be read only once in Response's lifecycle so to make it exposed
|
|
132
|
-
// to the user in the BeeResponseError, for further analysis.
|
|
133
|
-
|
|
134
|
-
const body = await e.response.text();
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
// The response can be Bee's JSON with structure `{code, message}` lets try to parse it
|
|
138
|
-
message = JSON.parse(body).message;
|
|
139
|
-
} catch (e) {}
|
|
140
|
-
|
|
141
|
-
if (message) {
|
|
142
|
-
throw new BeeResponseError(e.response.status, e.response, body, config, `${e.response.statusText}: ${message}`);
|
|
191
|
+
} else if (isHttpRequestError(e)) {
|
|
192
|
+
throw new BeeRequestError(e.message, config);
|
|
143
193
|
} else {
|
|
144
|
-
throw new
|
|
194
|
+
throw new BeeError(e.message);
|
|
145
195
|
}
|
|
146
|
-
} else if (isHttpRequestError(e)) {
|
|
147
|
-
throw new BeeRequestError(e.message, config);
|
|
148
|
-
} else {
|
|
149
|
-
throw new BeeError(e.message);
|
|
150
196
|
}
|
|
151
|
-
}
|
|
197
|
+
});
|
|
152
198
|
}
|
|
153
199
|
export function makeDefaultKy(kyConfig) {
|
|
154
200
|
return kyFactory.create(deepMerge(DEFAULT_KY_CONFIG, kyConfig));
|
package/dist/mjs/utils/merge.js
CHANGED
package/dist/mjs/utils/stream.js
CHANGED
package/dist/mjs/utils/type.js
CHANGED
|
@@ -214,11 +214,11 @@ export function assertPostageBatchOptions(value) {
|
|
|
214
214
|
const options = value;
|
|
215
215
|
assertRequestOptions(options, 'PostageBatchOptions');
|
|
216
216
|
|
|
217
|
-
if (options
|
|
217
|
+
if (options === null || options === void 0 ? void 0 : options.gasPrice) {
|
|
218
218
|
assertNonNegativeInteger(options.gasPrice);
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
if (options
|
|
221
|
+
if ((options === null || options === void 0 ? void 0 : options.immutableFlag) !== undefined) {
|
|
222
222
|
assertBoolean(options.immutableFlag);
|
|
223
223
|
}
|
|
224
224
|
}
|
|
@@ -231,11 +231,11 @@ export function assertCashoutOptions(value) {
|
|
|
231
231
|
const options = value;
|
|
232
232
|
assertRequestOptions(options, 'PostageBatchOptions');
|
|
233
233
|
|
|
234
|
-
if (options
|
|
234
|
+
if (options === null || options === void 0 ? void 0 : options.gasLimit) {
|
|
235
235
|
assertNonNegativeInteger(options.gasLimit);
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
if (options
|
|
238
|
+
if (options === null || options === void 0 ? void 0 : options.gasPrice) {
|
|
239
239
|
assertNonNegativeInteger(options.gasPrice);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
@@ -274,7 +274,7 @@ export function assertAllTagsOptions(entry) {
|
|
|
274
274
|
assertRequestOptions(entry, 'AllTagsOptions');
|
|
275
275
|
const options = entry;
|
|
276
276
|
|
|
277
|
-
if (options
|
|
277
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) !== undefined) {
|
|
278
278
|
if (typeof options.limit !== 'number') {
|
|
279
279
|
throw new TypeError('AllTagsOptions.limit has to be a number or undefined!');
|
|
280
280
|
}
|
|
@@ -288,7 +288,7 @@ export function assertAllTagsOptions(entry) {
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
if (options
|
|
291
|
+
if ((options === null || options === void 0 ? void 0 : options.offset) !== undefined) {
|
|
292
292
|
assertNonNegativeInteger(options.offset, 'AllTagsOptions.offset');
|
|
293
293
|
}
|
|
294
294
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ethersphere/bee-js",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.3-pre.0",
|
|
4
4
|
"description": "Javascript client for Bee",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bee",
|
|
@@ -138,4 +138,4 @@
|
|
|
138
138
|
"beeDebugApiVersion": "2.0.0",
|
|
139
139
|
"bee": "1.5.0-dda5606e"
|
|
140
140
|
}
|
|
141
|
-
}
|
|
141
|
+
}
|