@ethersphere/bee-js 12.3.2-upcoming.116 → 13.0.0-upcoming.gc013bdf
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/api/balance.js +24 -0
- package/dist/cjs/api/batches.js +26 -0
- package/dist/cjs/{modules → api}/bytes.js +4 -29
- package/dist/cjs/{modules → api}/bzz.js +6 -34
- package/dist/cjs/{modules/debug → api}/chequebook.js +48 -87
- package/dist/cjs/api/chunk.js +43 -0
- package/dist/cjs/api/connectivity.js +86 -0
- package/dist/cjs/api/consumed.js +24 -0
- package/dist/cjs/{modules → api}/envelope.js +3 -2
- package/dist/cjs/api/feed.js +55 -0
- package/dist/cjs/api/grantee.js +62 -0
- package/dist/cjs/{modules/pinning.js → api/pin.js} +13 -34
- package/dist/cjs/api/pss.js +19 -0
- package/dist/cjs/api/redistributionstate.js +17 -0
- package/dist/cjs/{modules/debug/settlements.js → api/settlement.js} +3 -11
- package/dist/cjs/api/soc.js +34 -0
- package/dist/cjs/{modules/debug → api}/stake.js +15 -43
- package/dist/cjs/{modules/debug/stamps.js → api/stamp.js} +41 -57
- package/dist/cjs/api/status.js +67 -0
- package/dist/cjs/{modules → api}/stewardship.js +1 -6
- package/dist/cjs/api/tag.js +51 -0
- package/dist/cjs/{modules/debug/transactions.js → api/transaction.js} +10 -31
- package/dist/cjs/{modules/debug/states.js → api/wallet.js} +4 -36
- package/dist/cjs/bee.js +115 -1978
- package/dist/cjs/chunk/soc.js +23 -65
- package/dist/cjs/feed/identifier.js +3 -4
- package/dist/cjs/feed/index.js +20 -22
- package/dist/cjs/feed/retrievable.js +3 -3
- package/dist/cjs/index.js +18 -8
- package/dist/cjs/manifest/manifest.js +99 -335
- package/dist/cjs/modules/balance.js +86 -0
- package/dist/cjs/modules/cheque.js +92 -0
- package/dist/cjs/modules/chequebook.js +90 -0
- package/dist/cjs/modules/chunk.js +87 -53
- package/dist/cjs/modules/collection.js +145 -0
- package/dist/cjs/modules/connectivity.js +141 -0
- package/dist/cjs/modules/context.js +2 -0
- package/dist/cjs/modules/data.js +119 -0
- package/dist/cjs/modules/feed.js +94 -70
- package/dist/cjs/modules/file.js +113 -0
- package/dist/cjs/modules/grantee.js +86 -55
- package/dist/cjs/modules/messaging.js +248 -0
- package/dist/cjs/modules/pin.js +100 -0
- package/dist/cjs/modules/settlement.js +67 -0
- package/dist/cjs/modules/soc.js +39 -36
- package/dist/cjs/modules/stake.js +110 -0
- package/dist/cjs/modules/stamp.js +199 -0
- package/dist/cjs/modules/status.js +128 -20
- package/dist/cjs/modules/storage.js +191 -0
- package/dist/cjs/modules/tag.js +97 -71
- package/dist/cjs/modules/transaction.js +92 -0
- package/dist/cjs/modules/wallet.js +82 -0
- package/dist/cjs/types/schema/chequebook.js +5 -5
- package/dist/cjs/types/schema/connectivity.js +5 -5
- package/dist/cjs/types/schema/envelope.js +5 -5
- package/dist/cjs/types/schema/grantee.js +4 -4
- package/dist/cjs/types/schema/stake.js +2 -2
- package/dist/cjs/types/schema/stamps.js +4 -4
- package/dist/cjs/types/schema/states.js +2 -2
- package/dist/cjs/types/schema/transactions.js +3 -3
- package/dist/cjs/types/schema/upload.js +2 -2
- package/dist/cjs/utils/chunk-stream.browser.js +24 -16
- package/dist/cjs/utils/chunk-stream.js +17 -9
- package/dist/cjs/utils/constants.js +3 -3
- package/dist/cjs/utils/expose.js +4 -4
- package/dist/cjs/utils/headers.js +4 -4
- package/dist/cjs/utils/pss.js +2 -2
- package/dist/cjs/utils/resource-locator.js +2 -2
- package/dist/cjs/utils/schema.js +4 -4
- package/dist/cjs/utils/stamps.js +15 -130
- package/dist/index.browser.min.js +2 -1
- package/dist/index.browser.min.js.LICENSE.txt +3 -0
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/api/balance.js +20 -0
- package/dist/mjs/api/batches.js +22 -0
- package/dist/mjs/{modules → api}/bytes.js +2 -27
- package/dist/mjs/{modules → api}/bzz.js +2 -30
- package/dist/mjs/{modules/debug → api}/chequebook.js +50 -89
- package/dist/mjs/api/chunk.js +37 -0
- package/dist/mjs/api/connectivity.js +76 -0
- package/dist/mjs/api/consumed.js +20 -0
- package/dist/mjs/{modules → api}/envelope.js +3 -2
- package/dist/mjs/api/feed.js +52 -0
- package/dist/mjs/api/grantee.js +59 -0
- package/dist/mjs/{modules/pinning.js → api/pin.js} +14 -35
- package/dist/mjs/api/pss.js +18 -0
- package/dist/mjs/api/redistributionstate.js +14 -0
- package/dist/mjs/{modules/debug/settlements.js → api/settlement.js} +3 -11
- package/dist/mjs/api/soc.js +31 -0
- package/dist/mjs/{modules/debug → api}/stake.js +14 -41
- package/dist/mjs/{modules/debug/stamps.js → api/stamp.js} +37 -51
- package/dist/mjs/api/status.js +59 -0
- package/dist/mjs/{modules → api}/stewardship.js +1 -6
- package/dist/mjs/api/tag.js +49 -0
- package/dist/mjs/api/transaction.js +41 -0
- package/dist/mjs/api/wallet.js +38 -0
- package/dist/mjs/bee.js +115 -1965
- package/dist/mjs/chunk/soc.js +13 -51
- package/dist/mjs/feed/identifier.js +2 -3
- package/dist/mjs/feed/index.js +9 -11
- package/dist/mjs/feed/retrievable.js +2 -2
- package/dist/mjs/index.js +2 -5
- package/dist/mjs/manifest/manifest.js +97 -341
- package/dist/mjs/modules/balance.js +49 -0
- package/dist/mjs/modules/cheque.js +55 -0
- package/dist/mjs/modules/chequebook.js +65 -0
- package/dist/mjs/modules/chunk.js +52 -49
- package/dist/mjs/modules/collection.js +108 -0
- package/dist/mjs/modules/connectivity.js +102 -0
- package/dist/mjs/modules/context.js +1 -0
- package/dist/mjs/modules/data.js +82 -0
- package/dist/mjs/modules/feed.js +89 -67
- package/dist/mjs/modules/file.js +78 -0
- package/dist/mjs/modules/grantee.js +52 -55
- package/dist/mjs/modules/messaging.js +213 -0
- package/dist/mjs/modules/pin.js +63 -0
- package/dist/mjs/modules/settlement.js +30 -0
- package/dist/mjs/modules/soc.js +36 -34
- package/dist/mjs/modules/stake.js +76 -0
- package/dist/mjs/modules/stamp.js +170 -0
- package/dist/mjs/modules/status.js +98 -18
- package/dist/mjs/modules/storage.js +185 -0
- package/dist/mjs/modules/tag.js +61 -68
- package/dist/mjs/modules/transaction.js +58 -0
- package/dist/mjs/modules/wallet.js +45 -0
- package/dist/mjs/types/schema/chequebook.js +1 -1
- package/dist/mjs/types/schema/connectivity.js +1 -1
- package/dist/mjs/types/schema/envelope.js +5 -5
- package/dist/mjs/types/schema/grantee.js +1 -1
- package/dist/mjs/types/schema/stake.js +1 -1
- package/dist/mjs/types/schema/stamps.js +1 -1
- package/dist/mjs/types/schema/states.js +1 -1
- package/dist/mjs/types/schema/transactions.js +1 -1
- package/dist/mjs/types/schema/upload.js +1 -1
- package/dist/mjs/utils/chunk-stream.browser.js +28 -18
- package/dist/mjs/utils/chunk-stream.js +21 -11
- package/dist/mjs/utils/constants.js +1 -1
- package/dist/mjs/utils/expose.js +1 -1
- package/dist/mjs/utils/headers.js +1 -1
- package/dist/mjs/utils/pss.js +1 -1
- package/dist/mjs/utils/resource-locator.js +1 -1
- package/dist/mjs/utils/schema.js +1 -1
- package/dist/mjs/utils/stamps.js +5 -99
- package/dist/types/api/balance.d.ts +7 -0
- package/dist/types/api/batches.d.ts +7 -0
- package/dist/types/api/bytes.d.ts +11 -0
- package/dist/types/api/bzz.d.ts +12 -0
- package/dist/types/api/chequebook.d.ts +21 -0
- package/dist/types/api/chunk.d.ts +7 -0
- package/dist/types/api/connectivity.d.ts +22 -0
- package/dist/types/api/consumed.d.ts +7 -0
- package/dist/types/{modules → api}/envelope.d.ts +1 -1
- package/dist/types/api/feed.d.ts +40 -0
- package/dist/types/api/grantee.d.ts +11 -0
- package/dist/types/api/pin.d.ts +10 -0
- package/dist/types/api/pss.d.ts +6 -0
- package/dist/types/api/redistributionstate.d.ts +5 -0
- package/dist/types/api/settlement.d.ts +7 -0
- package/dist/types/api/soc.d.ts +6 -0
- package/dist/types/api/stake.d.ts +11 -0
- package/dist/types/api/stamp.d.ts +12 -0
- package/dist/types/api/status.d.ts +11 -0
- package/dist/types/api/stewardship.d.ts +7 -0
- package/dist/types/api/tag.d.ts +12 -0
- package/dist/types/api/transaction.d.ts +9 -0
- package/dist/types/api/wallet.d.ts +9 -0
- package/dist/types/bee.d.ts +71 -1199
- package/dist/types/chunk/soc.d.ts +3 -48
- package/dist/types/feed/identifier.d.ts +1 -1
- package/dist/types/feed/index.d.ts +2 -4
- package/dist/types/feed/retrievable.d.ts +1 -1
- package/dist/types/index.d.ts +17 -20
- package/dist/types/manifest/manifest.d.ts +25 -34
- package/dist/types/modules/balance.d.ts +38 -0
- package/dist/types/modules/cheque.d.ts +40 -0
- package/dist/types/modules/chequebook.d.ts +41 -0
- package/dist/types/modules/chunk.d.ts +30 -20
- package/dist/types/modules/collection.d.ts +77 -0
- package/dist/types/modules/connectivity.d.ts +74 -0
- package/dist/types/modules/context.d.ts +24 -0
- package/dist/types/modules/data.d.ts +55 -0
- package/dist/types/modules/feed.d.ts +47 -49
- package/dist/types/modules/file.d.ts +43 -0
- package/dist/types/modules/grantee.d.ts +40 -8
- package/dist/types/modules/messaging.d.ts +79 -0
- package/dist/types/modules/pin.d.ts +47 -0
- package/dist/types/modules/settlement.d.ts +25 -0
- package/dist/types/modules/soc.d.ts +23 -11
- package/dist/types/modules/stake.d.ts +55 -0
- package/dist/types/modules/stamp.d.ts +96 -0
- package/dist/types/modules/status.d.ts +66 -5
- package/dist/types/modules/storage.d.ts +107 -0
- package/dist/types/modules/tag.d.ts +44 -33
- package/dist/types/modules/transaction.d.ts +42 -0
- package/dist/types/modules/wallet.d.ts +35 -0
- package/dist/types/types/debug.d.ts +1 -1
- package/dist/types/types/index.d.ts +3 -12
- package/dist/types/types/schema/chequebook.d.ts +1 -1
- package/dist/types/types/schema/connectivity.d.ts +1 -1
- package/dist/types/types/schema/grantee.d.ts +1 -1
- package/dist/types/types/schema/stake.d.ts +1 -1
- package/dist/types/types/schema/stamps.d.ts +1 -1
- package/dist/types/types/schema/states.d.ts +1 -1
- package/dist/types/types/schema/transactions.d.ts +1 -1
- package/dist/types/types/schema/upload.d.ts +1 -1
- package/dist/types/utils/chunk-stream.browser.d.ts +1 -1
- package/dist/types/utils/chunk-stream.d.ts +2 -2
- package/dist/types/utils/constants.d.ts +1 -1
- package/dist/types/utils/expose.d.ts +1 -1
- package/dist/types/utils/headers.d.ts +1 -1
- package/dist/types/utils/pss.d.ts +1 -1
- package/dist/types/utils/resource-locator.d.ts +1 -1
- package/dist/types/utils/schema.d.ts +1 -1
- package/dist/types/utils/stamps.d.ts +2 -27
- package/dist/types/utils/tar-uploader.browser.d.ts +1 -1
- package/dist/types/utils/tar-uploader.d.ts +1 -1
- package/package.json +4 -2
- package/dist/cjs/chunk/bmt.js +0 -37
- package/dist/cjs/chunk/cac.js +0 -43
- package/dist/cjs/modules/debug/balance.js +0 -60
- package/dist/cjs/modules/debug/connectivity.js +0 -54
- package/dist/cjs/modules/debug/status.js +0 -104
- package/dist/cjs/modules/gsoc.js +0 -23
- package/dist/cjs/modules/pss.js +0 -48
- package/dist/cjs/stamper/stamper.js +0 -44
- package/dist/cjs/utils/bytes.js +0 -116
- package/dist/cjs/utils/cid.js +0 -37
- package/dist/cjs/utils/redundancy.js +0 -133
- package/dist/cjs/utils/typed-bytes.js +0 -186
- package/dist/mjs/chunk/bmt.js +0 -34
- package/dist/mjs/chunk/cac.js +0 -34
- package/dist/mjs/modules/debug/balance.js +0 -54
- package/dist/mjs/modules/debug/connectivity.js +0 -46
- package/dist/mjs/modules/debug/states.js +0 -68
- package/dist/mjs/modules/debug/status.js +0 -99
- package/dist/mjs/modules/debug/transactions.js +0 -62
- package/dist/mjs/modules/gsoc.js +0 -16
- package/dist/mjs/modules/pss.js +0 -43
- package/dist/mjs/stamper/stamper.js +0 -40
- package/dist/mjs/utils/bytes.js +0 -102
- package/dist/mjs/utils/cid.js +0 -32
- package/dist/mjs/utils/redundancy.js +0 -98
- package/dist/mjs/utils/typed-bytes.js +0 -167
- package/dist/types/chunk/bmt.d.ts +0 -16
- package/dist/types/chunk/cac.d.ts +0 -40
- package/dist/types/modules/bytes.d.ts +0 -35
- package/dist/types/modules/bzz.d.ts +0 -40
- package/dist/types/modules/debug/balance.d.ts +0 -28
- package/dist/types/modules/debug/chequebook.d.ts +0 -60
- package/dist/types/modules/debug/connectivity.d.ts +0 -9
- package/dist/types/modules/debug/settlements.d.ts +0 -15
- package/dist/types/modules/debug/stake.d.ts +0 -30
- package/dist/types/modules/debug/stamps.d.ts +0 -11
- package/dist/types/modules/debug/states.d.ts +0 -23
- package/dist/types/modules/debug/status.d.ts +0 -46
- package/dist/types/modules/debug/transactions.d.ts +0 -30
- package/dist/types/modules/gsoc.d.ts +0 -6
- package/dist/types/modules/pinning.d.ts +0 -30
- package/dist/types/modules/pss.d.ts +0 -22
- package/dist/types/modules/stewardship.d.ts +0 -10
- package/dist/types/stamper/stamper.d.ts +0 -15
- package/dist/types/utils/bytes.d.ts +0 -19
- package/dist/types/utils/cid.d.ts +0 -10
- package/dist/types/utils/redundancy.d.ts +0 -21
- package/dist/types/utils/typed-bytes.d.ts +0 -69
- /package/dist/cjs/{modules → api}/rchash.js +0 -0
- /package/dist/mjs/{modules → api}/rchash.js +0 -0
- /package/dist/types/{modules → api}/rchash.d.ts +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createGrantees = createGrantees;
|
|
4
|
+
exports.getGrantees = getGrantees;
|
|
5
|
+
exports.patchGrantees = patchGrantees;
|
|
6
|
+
const grantee_1 = require("../types/schema/grantee");
|
|
7
|
+
const headers_1 = require("../utils/headers");
|
|
8
|
+
const http_1 = require("../utils/http");
|
|
9
|
+
const granteeEndpoint = 'grantee';
|
|
10
|
+
/** Creates grantees for a postage batch. */
|
|
11
|
+
async function createGrantees(requestOptions, batchId, publicKeys) {
|
|
12
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
13
|
+
method: 'post',
|
|
14
|
+
url: granteeEndpoint,
|
|
15
|
+
data: { grantees: publicKeys.map(x => x.toCompressedHex()) },
|
|
16
|
+
headers: (0, headers_1.prepareRequestHeaders)(batchId),
|
|
17
|
+
responseType: 'json',
|
|
18
|
+
});
|
|
19
|
+
const body = grantee_1.GranteesResultBodyResponse.parse(response.data);
|
|
20
|
+
return {
|
|
21
|
+
status: response.status,
|
|
22
|
+
statusText: response.statusText,
|
|
23
|
+
ref: body.ref,
|
|
24
|
+
historyref: body.historyref,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** Retrieves the grantees for a given reference. */
|
|
28
|
+
async function getGrantees(requestOptions, reference) {
|
|
29
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
30
|
+
method: 'get',
|
|
31
|
+
url: `${granteeEndpoint}/${reference}`,
|
|
32
|
+
responseType: 'json',
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
status: response.status,
|
|
36
|
+
statusText: response.statusText,
|
|
37
|
+
grantees: grantee_1.GetGranteesBodyResponse.parse(response.data),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Updates the grantees of a specific reference and history. */
|
|
41
|
+
async function patchGrantees(requestOptions, batchId, reference, history, publicKeys) {
|
|
42
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
43
|
+
method: 'patch',
|
|
44
|
+
url: `${granteeEndpoint}/${reference}`,
|
|
45
|
+
data: {
|
|
46
|
+
add: publicKeys.add.map(x => x.toCompressedHex()),
|
|
47
|
+
revoke: publicKeys.revoke.map(x => x.toCompressedHex()),
|
|
48
|
+
},
|
|
49
|
+
headers: {
|
|
50
|
+
...(0, headers_1.prepareRequestHeaders)(batchId),
|
|
51
|
+
'swarm-act-history-address': history.toHex(),
|
|
52
|
+
},
|
|
53
|
+
responseType: 'json',
|
|
54
|
+
});
|
|
55
|
+
const body = grantee_1.GranteesResultBodyResponse.parse(response.data);
|
|
56
|
+
return {
|
|
57
|
+
status: response.status,
|
|
58
|
+
statusText: response.statusText,
|
|
59
|
+
ref: body.ref,
|
|
60
|
+
historyref: body.historyref,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -2,19 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pin = pin;
|
|
4
4
|
exports.unpin = unpin;
|
|
5
|
-
exports.getPin = getPin;
|
|
6
5
|
exports.getAllPins = getAllPins;
|
|
6
|
+
exports.getPin = getPin;
|
|
7
|
+
const swarm_core_1 = require("swarm-core");
|
|
7
8
|
const pinning_1 = require("../types/schema/pinning");
|
|
8
9
|
const upload_1 = require("../types/schema/upload");
|
|
9
10
|
const http_1 = require("../utils/http");
|
|
10
|
-
const typed_bytes_1 = require("../utils/typed-bytes");
|
|
11
11
|
const PINNING_ENDPOINT = 'pins';
|
|
12
|
-
/**
|
|
13
|
-
* Pin data with given reference
|
|
14
|
-
*
|
|
15
|
-
* @param requestOptions Options for making requests
|
|
16
|
-
* @param reference Bee data reference
|
|
17
|
-
*/
|
|
12
|
+
/** Pins local data with the given reference. */
|
|
18
13
|
async function pin(requestOptions, reference) {
|
|
19
14
|
await (0, http_1.http)(requestOptions, {
|
|
20
15
|
method: 'post',
|
|
@@ -22,12 +17,7 @@ async function pin(requestOptions, reference) {
|
|
|
22
17
|
url: `${PINNING_ENDPOINT}/${reference}`,
|
|
23
18
|
});
|
|
24
19
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Unpin data with given reference
|
|
27
|
-
*
|
|
28
|
-
* @param requestOptions Options for making requests
|
|
29
|
-
* @param reference Bee data reference
|
|
30
|
-
*/
|
|
20
|
+
/** Unpins local data with the given reference. */
|
|
31
21
|
async function unpin(requestOptions, reference) {
|
|
32
22
|
await (0, http_1.http)(requestOptions, {
|
|
33
23
|
method: 'delete',
|
|
@@ -35,33 +25,22 @@ async function unpin(requestOptions, reference) {
|
|
|
35
25
|
url: `${PINNING_ENDPOINT}/${reference}`,
|
|
36
26
|
});
|
|
37
27
|
}
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
*
|
|
41
|
-
* @param requestOptions Options for making requests
|
|
42
|
-
* @param reference
|
|
43
|
-
* @throws Error if given address is not pinned
|
|
44
|
-
*/
|
|
45
|
-
async function getPin(requestOptions, reference) {
|
|
28
|
+
/** Gets the list of all locally pinned references. */
|
|
29
|
+
async function getAllPins(requestOptions) {
|
|
46
30
|
const response = await (0, http_1.http)(requestOptions, {
|
|
47
31
|
method: 'get',
|
|
48
32
|
responseType: 'json',
|
|
49
|
-
url:
|
|
33
|
+
url: PINNING_ENDPOINT,
|
|
50
34
|
});
|
|
51
|
-
|
|
35
|
+
const { references } = pinning_1.GetAllPinsResponse.parse(response.data);
|
|
36
|
+
return (references ?? []).map(x => new swarm_core_1.Reference(x));
|
|
52
37
|
}
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
* @param requestOptions Options for making requests
|
|
57
|
-
*/
|
|
58
|
-
async function getAllPins(requestOptions) {
|
|
38
|
+
/** Gets the pinning status of the chunk with the given reference. */
|
|
39
|
+
async function getPin(requestOptions, reference) {
|
|
59
40
|
const response = await (0, http_1.http)(requestOptions, {
|
|
60
41
|
method: 'get',
|
|
61
42
|
responseType: 'json',
|
|
62
|
-
url: `${PINNING_ENDPOINT}`,
|
|
43
|
+
url: `${PINNING_ENDPOINT}/${reference}`,
|
|
63
44
|
});
|
|
64
|
-
|
|
65
|
-
const { references } = pinning_1.GetAllPinsResponse.parse(response.data);
|
|
66
|
-
return (references ?? []).map(x => new typed_bytes_1.Reference(x));
|
|
45
|
+
return upload_1.UploadResultBody.parse(response.data);
|
|
67
46
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.send = send;
|
|
4
|
+
const headers_1 = require("../utils/headers");
|
|
5
|
+
const http_1 = require("../utils/http");
|
|
6
|
+
const pssEndpoint = 'pss';
|
|
7
|
+
/**
|
|
8
|
+
* Sends a message with the Postal Service for Swarm through the `POST /pss/send` endpoint.
|
|
9
|
+
*/
|
|
10
|
+
async function send(requestOptions, batchId, topic, target, data, recipient) {
|
|
11
|
+
await (0, http_1.http)(requestOptions, {
|
|
12
|
+
method: 'post',
|
|
13
|
+
url: `${pssEndpoint}/send/${topic}/${target}`,
|
|
14
|
+
data,
|
|
15
|
+
responseType: 'json',
|
|
16
|
+
params: { recipient },
|
|
17
|
+
headers: (0, headers_1.prepareRequestHeaders)(batchId),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRedistributionState = getRedistributionState;
|
|
4
|
+
const stake_1 = require("../types/schema/stake");
|
|
5
|
+
const http_1 = require("../utils/http");
|
|
6
|
+
const redistributionStateEndpoint = 'redistributionstate';
|
|
7
|
+
/**
|
|
8
|
+
* Raw HTTP calls for the `/redistributionstate` endpoint.
|
|
9
|
+
*/
|
|
10
|
+
async function getRedistributionState(requestOptions) {
|
|
11
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
12
|
+
method: 'get',
|
|
13
|
+
responseType: 'json',
|
|
14
|
+
url: redistributionStateEndpoint,
|
|
15
|
+
});
|
|
16
|
+
return stake_1.GetRedistributionStateResponse.parse(response.data);
|
|
17
|
+
}
|
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSettlements = getSettlements;
|
|
4
4
|
exports.getAllSettlements = getAllSettlements;
|
|
5
|
-
const settlements_1 = require("
|
|
6
|
-
const http_1 = require("
|
|
5
|
+
const settlements_1 = require("../types/schema/settlements");
|
|
6
|
+
const http_1 = require("../utils/http");
|
|
7
7
|
const settlementsEndpoint = 'settlements';
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @param requestOptions Options for making requests
|
|
12
|
-
* @param peer Swarm address of peer
|
|
9
|
+
* Raw HTTP calls for the `/settlements` endpoint.
|
|
13
10
|
*/
|
|
14
11
|
async function getSettlements(requestOptions, peer) {
|
|
15
12
|
const response = await (0, http_1.http)(requestOptions, {
|
|
@@ -18,11 +15,6 @@ async function getSettlements(requestOptions, peer) {
|
|
|
18
15
|
});
|
|
19
16
|
return settlements_1.GetSettlementsResponse.parse(response.data);
|
|
20
17
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Get settlements with all known peers and total amount sent or received
|
|
23
|
-
*
|
|
24
|
-
* @param requestOptions Options for making requests
|
|
25
|
-
*/
|
|
26
18
|
async function getAllSettlements(requestOptions) {
|
|
27
19
|
const response = await (0, http_1.http)(requestOptions, {
|
|
28
20
|
url: settlementsEndpoint,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.upload = upload;
|
|
4
|
+
const swarm_core_1 = require("swarm-core");
|
|
5
|
+
const cafe_utility_1 = require("cafe-utility");
|
|
6
|
+
const upload_1 = require("../types/schema/upload");
|
|
7
|
+
const headers_1 = require("../utils/headers");
|
|
8
|
+
const http_1 = require("../utils/http");
|
|
9
|
+
const type_1 = require("../utils/type");
|
|
10
|
+
const socEndpoint = 'soc';
|
|
11
|
+
/**
|
|
12
|
+
* Raw HTTP calls for the `/soc` endpoint.
|
|
13
|
+
*/
|
|
14
|
+
async function upload(requestOptions, owner, identifier, signature, data, stamp, options) {
|
|
15
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
16
|
+
method: 'post',
|
|
17
|
+
url: `${socEndpoint}/${owner}/${identifier}`,
|
|
18
|
+
data,
|
|
19
|
+
headers: {
|
|
20
|
+
'content-type': 'application/octet-stream',
|
|
21
|
+
...(0, headers_1.prepareRequestHeaders)(stamp, options),
|
|
22
|
+
},
|
|
23
|
+
responseType: 'json',
|
|
24
|
+
params: { sig: signature.toHex() },
|
|
25
|
+
});
|
|
26
|
+
const body = upload_1.UploadResultBody.parse(response.data);
|
|
27
|
+
return {
|
|
28
|
+
reference: body.reference,
|
|
29
|
+
tagUid: response.headers['swarm-tag'] ? (0, type_1.makeTagUid)(response.headers['swarm-tag']) : undefined,
|
|
30
|
+
historyAddress: response.headers['swarm-act-history-address']
|
|
31
|
+
? cafe_utility_1.Optional.of(new swarm_core_1.Reference(response.headers['swarm-act-history-address']))
|
|
32
|
+
: cafe_utility_1.Optional.empty(),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -2,33 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getStake = getStake;
|
|
4
4
|
exports.getWithdrawableStake = getWithdrawableStake;
|
|
5
|
+
exports.depositStake = depositStake;
|
|
5
6
|
exports.withdrawSurplusStake = withdrawSurplusStake;
|
|
6
7
|
exports.migrateStake = migrateStake;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const headers_1 = require("../../utils/headers");
|
|
11
|
-
const http_1 = require("../../utils/http");
|
|
8
|
+
const stake_1 = require("../types/schema/stake");
|
|
9
|
+
const headers_1 = require("../utils/headers");
|
|
10
|
+
const http_1 = require("../utils/http");
|
|
12
11
|
const STAKE_ENDPOINT = 'stake';
|
|
13
|
-
const REDISTRIBUTION_ENDPOINT = 'redistributionstate';
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @param requestOptions Options for making requests
|
|
13
|
+
* Raw HTTP calls for the `/stake` endpoint.
|
|
18
14
|
*/
|
|
19
15
|
async function getStake(requestOptions) {
|
|
20
16
|
const response = await (0, http_1.http)(requestOptions, {
|
|
21
17
|
method: 'get',
|
|
22
18
|
responseType: 'json',
|
|
23
|
-
url:
|
|
19
|
+
url: STAKE_ENDPOINT,
|
|
24
20
|
});
|
|
25
21
|
return stake_1.GetStakeResponse.parse(response.data).stakedAmount;
|
|
26
22
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Gets the amount of withdrawable staked BZZ
|
|
29
|
-
*
|
|
30
|
-
* @param requestOptions Options for making requests
|
|
31
|
-
*/
|
|
32
23
|
async function getWithdrawableStake(requestOptions) {
|
|
33
24
|
const response = await (0, http_1.http)(requestOptions, {
|
|
34
25
|
method: 'get',
|
|
@@ -37,47 +28,28 @@ async function getWithdrawableStake(requestOptions) {
|
|
|
37
28
|
});
|
|
38
29
|
return stake_1.GetWithdrawableStakeResponse.parse(response.data).withdrawableAmount;
|
|
39
30
|
}
|
|
40
|
-
async function
|
|
31
|
+
async function depositStake(requestOptions, amountString, options) {
|
|
41
32
|
const response = await (0, http_1.http)(requestOptions, {
|
|
42
|
-
method: '
|
|
33
|
+
method: 'post',
|
|
43
34
|
responseType: 'json',
|
|
44
|
-
url: `${STAKE_ENDPOINT}
|
|
35
|
+
url: `${STAKE_ENDPOINT}/${amountString}`,
|
|
36
|
+
headers: (0, headers_1.prepareRequestHeaders)(null, options),
|
|
45
37
|
});
|
|
46
38
|
return stake_1.TxHashResponse.parse(response.data).txHash;
|
|
47
39
|
}
|
|
48
|
-
async function
|
|
40
|
+
async function withdrawSurplusStake(requestOptions) {
|
|
49
41
|
const response = await (0, http_1.http)(requestOptions, {
|
|
50
42
|
method: 'delete',
|
|
51
43
|
responseType: 'json',
|
|
52
|
-
url: STAKE_ENDPOINT
|
|
44
|
+
url: `${STAKE_ENDPOINT}/withdrawable`,
|
|
53
45
|
});
|
|
54
46
|
return stake_1.TxHashResponse.parse(response.data).txHash;
|
|
55
47
|
}
|
|
56
|
-
|
|
57
|
-
* Stake given amount of tokens.
|
|
58
|
-
*
|
|
59
|
-
* @param requestOptions Options for making requests
|
|
60
|
-
* @param amount
|
|
61
|
-
*/
|
|
62
|
-
async function stake(requestOptions, amount, options) {
|
|
48
|
+
async function migrateStake(requestOptions) {
|
|
63
49
|
const response = await (0, http_1.http)(requestOptions, {
|
|
64
|
-
method: '
|
|
50
|
+
method: 'delete',
|
|
65
51
|
responseType: 'json',
|
|
66
|
-
url:
|
|
67
|
-
headers: (0, headers_1.prepareRequestHeaders)(null, options),
|
|
52
|
+
url: STAKE_ENDPOINT,
|
|
68
53
|
});
|
|
69
54
|
return stake_1.TxHashResponse.parse(response.data).txHash;
|
|
70
55
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Get current status of node in redistribution game
|
|
73
|
-
*
|
|
74
|
-
* @param requestOptions Options for making requests
|
|
75
|
-
*/
|
|
76
|
-
async function getRedistributionState(requestOptions) {
|
|
77
|
-
const response = await (0, http_1.http)(requestOptions, {
|
|
78
|
-
method: 'get',
|
|
79
|
-
responseType: 'json',
|
|
80
|
-
url: REDISTRIBUTION_ENDPOINT,
|
|
81
|
-
});
|
|
82
|
-
return stake_1.GetRedistributionStateResponse.parse(response.data);
|
|
83
|
-
}
|
|
@@ -1,77 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGlobalPostageBatches = getGlobalPostageBatches;
|
|
4
|
-
exports.getGlobalPostageBatch = getGlobalPostageBatch;
|
|
5
|
-
exports.getAllPostageBatches = getAllPostageBatches;
|
|
6
|
-
exports.getPostageBatch = getPostageBatch;
|
|
7
|
-
exports.getPostageBatchBuckets = getPostageBatchBuckets;
|
|
8
3
|
exports.createPostageBatch = createPostageBatch;
|
|
9
|
-
exports.
|
|
4
|
+
exports.updateLabel = updateLabel;
|
|
10
5
|
exports.topUpBatch = topUpBatch;
|
|
11
6
|
exports.diluteBatch = diluteBatch;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
exports.getPostageBatch = getPostageBatch;
|
|
8
|
+
exports.getPostageBatchBuckets = getPostageBatchBuckets;
|
|
9
|
+
exports.getAllPostageBatches = getAllPostageBatches;
|
|
10
|
+
const stamps_1 = require("../types/schema/stamps");
|
|
11
|
+
const http_1 = require("../utils/http");
|
|
12
|
+
const stamps_2 = require("../utils/stamps");
|
|
15
13
|
const STAMPS_ENDPOINT = 'stamps';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
url: `${BATCHES_ENDPOINT}`,
|
|
21
|
-
responseType: 'json',
|
|
22
|
-
});
|
|
23
|
-
return stamps_1.GetGlobalPostageBatchesResponse.parse(response.data).batches;
|
|
24
|
-
}
|
|
25
|
-
async function getGlobalPostageBatch(requestOptions, postageBatchId) {
|
|
26
|
-
const response = await (0, http_1.http)(requestOptions, {
|
|
27
|
-
method: 'get',
|
|
28
|
-
url: `${BATCHES_ENDPOINT}/${postageBatchId}`,
|
|
29
|
-
responseType: 'json',
|
|
30
|
-
});
|
|
31
|
-
return stamps_1.GetGlobalPostageBatchResponse.parse(response.data);
|
|
32
|
-
}
|
|
33
|
-
async function getAllPostageBatches(requestOptions) {
|
|
34
|
-
const response = await (0, http_1.http)(requestOptions, {
|
|
35
|
-
method: 'get',
|
|
36
|
-
url: `${STAMPS_ENDPOINT}`,
|
|
37
|
-
responseType: 'json',
|
|
38
|
-
});
|
|
39
|
-
return stamps_1.GetAllPostageBatchesResponse.parse(response.data).stamps.map(x => (0, stamps_2.mapPostageBatch)(x));
|
|
40
|
-
}
|
|
41
|
-
async function getPostageBatch(requestOptions, postageBatchId, encryption, erasureCodeLevel) {
|
|
42
|
-
const response = await (0, http_1.http)(requestOptions, {
|
|
43
|
-
method: 'get',
|
|
44
|
-
url: `${STAMPS_ENDPOINT}/${postageBatchId}`,
|
|
45
|
-
responseType: 'json',
|
|
46
|
-
});
|
|
47
|
-
return (0, stamps_2.mapPostageBatch)(stamps_1.GetPostageBatchResponse.parse(response.data), encryption, erasureCodeLevel);
|
|
48
|
-
}
|
|
49
|
-
async function getPostageBatchBuckets(requestOptions, postageBatchId) {
|
|
50
|
-
const response = await (0, http_1.http)(requestOptions, {
|
|
51
|
-
method: 'get',
|
|
52
|
-
url: `${STAMPS_ENDPOINT}/${postageBatchId}/buckets`,
|
|
53
|
-
responseType: 'json',
|
|
54
|
-
});
|
|
55
|
-
return stamps_1.GetPostageBatchBucketsResponse.parse(response.data);
|
|
56
|
-
}
|
|
57
|
-
async function createPostageBatch(requestOptions, amount, depth, options) {
|
|
14
|
+
/**
|
|
15
|
+
* Raw HTTP calls for the `/stamps` endpoint.
|
|
16
|
+
*/
|
|
17
|
+
async function createPostageBatch(requestOptions, amount, depth, label, gasPrice, immutableFlag) {
|
|
58
18
|
const headers = {};
|
|
59
|
-
if (
|
|
60
|
-
headers['gas-price'] =
|
|
19
|
+
if (gasPrice) {
|
|
20
|
+
headers['gas-price'] = gasPrice;
|
|
61
21
|
}
|
|
62
|
-
if (
|
|
63
|
-
headers.immutable = String(
|
|
22
|
+
if (immutableFlag !== undefined) {
|
|
23
|
+
headers.immutable = String(immutableFlag);
|
|
64
24
|
}
|
|
65
25
|
const response = await (0, http_1.http)(requestOptions, {
|
|
66
26
|
method: 'post',
|
|
67
27
|
url: `${STAMPS_ENDPOINT}/${amount}/${depth}`,
|
|
68
28
|
responseType: 'json',
|
|
69
|
-
params: { label
|
|
29
|
+
params: { label },
|
|
70
30
|
headers,
|
|
71
31
|
});
|
|
72
32
|
return stamps_1.BatchIdResponse.parse(response.data).batchID;
|
|
73
33
|
}
|
|
74
|
-
async function
|
|
34
|
+
async function updateLabel(requestOptions, id, label) {
|
|
75
35
|
await (0, http_1.http)(requestOptions, {
|
|
76
36
|
method: 'patch',
|
|
77
37
|
url: `${STAMPS_ENDPOINT}/${id}`,
|
|
@@ -95,3 +55,27 @@ async function diluteBatch(requestOptions, id, depth) {
|
|
|
95
55
|
});
|
|
96
56
|
return stamps_1.BatchIdResponse.parse(response.data).batchID;
|
|
97
57
|
}
|
|
58
|
+
async function getPostageBatch(requestOptions, id, encryption, erasureCodeLevel) {
|
|
59
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
60
|
+
method: 'get',
|
|
61
|
+
url: `${STAMPS_ENDPOINT}/${id}`,
|
|
62
|
+
responseType: 'json',
|
|
63
|
+
});
|
|
64
|
+
return (0, stamps_2.mapPostageBatch)(stamps_1.GetPostageBatchResponse.parse(response.data), encryption, erasureCodeLevel);
|
|
65
|
+
}
|
|
66
|
+
async function getPostageBatchBuckets(requestOptions, id) {
|
|
67
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
68
|
+
method: 'get',
|
|
69
|
+
url: `${STAMPS_ENDPOINT}/${id}/buckets`,
|
|
70
|
+
responseType: 'json',
|
|
71
|
+
});
|
|
72
|
+
return stamps_1.GetPostageBatchBucketsResponse.parse(response.data);
|
|
73
|
+
}
|
|
74
|
+
async function getAllPostageBatches(requestOptions) {
|
|
75
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
76
|
+
method: 'get',
|
|
77
|
+
url: STAMPS_ENDPOINT,
|
|
78
|
+
responseType: 'json',
|
|
79
|
+
});
|
|
80
|
+
return stamps_1.GetAllPostageBatchesResponse.parse(response.data).stamps.map(x => (0, stamps_2.mapPostageBatch)(x));
|
|
81
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDebugStatus = getDebugStatus;
|
|
4
|
+
exports.getHealth = getHealth;
|
|
5
|
+
exports.getReadiness = getReadiness;
|
|
6
|
+
exports.getNodeInfo = getNodeInfo;
|
|
7
|
+
exports.getReserveState = getReserveState;
|
|
8
|
+
exports.getChainState = getChainState;
|
|
9
|
+
const status_1 = require("../types/schema/status");
|
|
10
|
+
const states_1 = require("../types/schema/states");
|
|
11
|
+
const http_1 = require("../utils/http");
|
|
12
|
+
const NODE_INFO_URL = 'node';
|
|
13
|
+
const STATUS_URL = 'status';
|
|
14
|
+
const HEALTH_URL = 'health';
|
|
15
|
+
const READINESS_URL = 'readiness';
|
|
16
|
+
const RESERVE_STATE_ENDPOINT = 'reservestate';
|
|
17
|
+
const CHAIN_STATE_ENDPOINT = 'chainstate';
|
|
18
|
+
/**
|
|
19
|
+
* Raw HTTP calls for the node status, health, version and chain/reserve state endpoints.
|
|
20
|
+
*/
|
|
21
|
+
async function getDebugStatus(requestOptions) {
|
|
22
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
23
|
+
method: 'get',
|
|
24
|
+
url: STATUS_URL,
|
|
25
|
+
responseType: 'json',
|
|
26
|
+
});
|
|
27
|
+
return status_1.GetDebugStatusResponse.parse(response.data);
|
|
28
|
+
}
|
|
29
|
+
async function getHealth(requestOptions) {
|
|
30
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
31
|
+
method: 'get',
|
|
32
|
+
url: HEALTH_URL,
|
|
33
|
+
responseType: 'json',
|
|
34
|
+
});
|
|
35
|
+
return status_1.GetHealthResponse.parse(response.data);
|
|
36
|
+
}
|
|
37
|
+
async function getReadiness(requestOptions) {
|
|
38
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
39
|
+
method: 'get',
|
|
40
|
+
url: READINESS_URL,
|
|
41
|
+
});
|
|
42
|
+
return status_1.GetReadinessResponse.parse(response.data);
|
|
43
|
+
}
|
|
44
|
+
async function getNodeInfo(requestOptions) {
|
|
45
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
46
|
+
method: 'get',
|
|
47
|
+
url: NODE_INFO_URL,
|
|
48
|
+
responseType: 'json',
|
|
49
|
+
});
|
|
50
|
+
return status_1.GetNodeInfoResponse.parse(response.data);
|
|
51
|
+
}
|
|
52
|
+
async function getReserveState(requestOptions) {
|
|
53
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
54
|
+
method: 'get',
|
|
55
|
+
url: RESERVE_STATE_ENDPOINT,
|
|
56
|
+
responseType: 'json',
|
|
57
|
+
});
|
|
58
|
+
return states_1.GetReserveStateResponse.parse(response.data);
|
|
59
|
+
}
|
|
60
|
+
async function getChainState(requestOptions) {
|
|
61
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
62
|
+
method: 'get',
|
|
63
|
+
url: CHAIN_STATE_ENDPOINT,
|
|
64
|
+
responseType: 'json',
|
|
65
|
+
});
|
|
66
|
+
return states_1.GetChainStateResponse.parse(response.data);
|
|
67
|
+
}
|
|
@@ -4,13 +4,9 @@ exports.reupload = reupload;
|
|
|
4
4
|
exports.isRetrievable = isRetrievable;
|
|
5
5
|
const stewardship_1 = require("../types/schema/stewardship");
|
|
6
6
|
const http_1 = require("../utils/http");
|
|
7
|
-
const typed_bytes_1 = require("../utils/typed-bytes");
|
|
8
7
|
const stewardshipEndpoint = 'stewardship';
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @param requestOptions Options for making requests
|
|
12
|
-
* @param reference
|
|
13
|
-
* @throws BeeResponseError if not locally pinned or invalid data
|
|
9
|
+
* Raw HTTP calls for the `/stewardship` endpoint.
|
|
14
10
|
*/
|
|
15
11
|
async function reupload(requestOptions, stamp, reference) {
|
|
16
12
|
await (0, http_1.http)(requestOptions, {
|
|
@@ -20,7 +16,6 @@ async function reupload(requestOptions, stamp, reference) {
|
|
|
20
16
|
});
|
|
21
17
|
}
|
|
22
18
|
async function isRetrievable(requestOptions, reference) {
|
|
23
|
-
reference = new typed_bytes_1.Reference(reference);
|
|
24
19
|
const response = await (0, http_1.http)(requestOptions, {
|
|
25
20
|
method: 'get',
|
|
26
21
|
responseType: 'json',
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTag = createTag;
|
|
4
|
+
exports.getAllTags = getAllTags;
|
|
5
|
+
exports.getTag = getTag;
|
|
6
|
+
exports.deleteTag = deleteTag;
|
|
7
|
+
exports.updateTag = updateTag;
|
|
8
|
+
const tag_1 = require("../types/schema/tag");
|
|
9
|
+
const http_1 = require("../utils/http");
|
|
10
|
+
const endpoint = 'tags';
|
|
11
|
+
/** Creates a new tag. */
|
|
12
|
+
async function createTag(requestOptions) {
|
|
13
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
14
|
+
method: 'post',
|
|
15
|
+
url: endpoint,
|
|
16
|
+
responseType: 'json',
|
|
17
|
+
});
|
|
18
|
+
return tag_1.TagSchema.parse(response.data);
|
|
19
|
+
}
|
|
20
|
+
/** Fetches all tags in a paginated manner. */
|
|
21
|
+
async function getAllTags(requestOptions, options) {
|
|
22
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
23
|
+
url: endpoint,
|
|
24
|
+
params: { offset: options?.offset, limit: options?.limit },
|
|
25
|
+
responseType: 'json',
|
|
26
|
+
});
|
|
27
|
+
return tag_1.GetAllTagsResponse.parse(response.data).tags;
|
|
28
|
+
}
|
|
29
|
+
/** Retrieves tag information from the Bee node. */
|
|
30
|
+
async function getTag(requestOptions, uid) {
|
|
31
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
32
|
+
url: `${endpoint}/${uid}`,
|
|
33
|
+
responseType: 'json',
|
|
34
|
+
});
|
|
35
|
+
return tag_1.TagSchema.parse(response.data);
|
|
36
|
+
}
|
|
37
|
+
/** Deletes a tag. */
|
|
38
|
+
async function deleteTag(requestOptions, uid) {
|
|
39
|
+
await (0, http_1.http)(requestOptions, {
|
|
40
|
+
method: 'delete',
|
|
41
|
+
url: `${endpoint}/${uid}`,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/** Updates a tag's total chunks count. */
|
|
45
|
+
async function updateTag(requestOptions, uid, reference) {
|
|
46
|
+
await (0, http_1.http)(requestOptions, {
|
|
47
|
+
method: 'patch',
|
|
48
|
+
url: `${endpoint}/${uid}`,
|
|
49
|
+
data: { reference },
|
|
50
|
+
});
|
|
51
|
+
}
|