@erebos/api-bzz-base
Advanced tools
Comparing version 0.9.0 to 0.10.0
359
cjs/index.js
@@ -64,3 +64,5 @@ "use strict"; | ||
immutable: 'bzz-immutable:/', | ||
raw: 'bzz-raw:/' | ||
pin: 'bzz-pin:/', | ||
raw: 'bzz-raw:/', | ||
tag: 'bzz-tag:/' | ||
}; | ||
@@ -107,19 +109,19 @@ exports.BZZ_MODE_PROTOCOLS = BZZ_MODE_PROTOCOLS; | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee19(res) { | ||
return _regenerator.default.wrap(function _callee19$(_context19) { | ||
_regenerator.default.mark(function _callee25(res) { | ||
return _regenerator.default.wrap(function _callee25$(_context25) { | ||
while (1) { | ||
switch (_context19.prev = _context19.next) { | ||
switch (_context25.prev = _context25.next) { | ||
case 0: | ||
_context19.next = 2; | ||
_context25.next = 2; | ||
return resOrError(res).json(); | ||
case 2: | ||
return _context19.abrupt("return", _context19.sent); | ||
return _context25.abrupt("return", _context25.sent); | ||
case 3: | ||
case "end": | ||
return _context19.stop(); | ||
return _context25.stop(); | ||
} | ||
} | ||
}, _callee19); | ||
}, _callee25); | ||
})); | ||
@@ -136,19 +138,19 @@ return _resJSON.apply(this, arguments); | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee20(res) { | ||
return _regenerator.default.wrap(function _callee20$(_context20) { | ||
_regenerator.default.mark(function _callee26(res) { | ||
return _regenerator.default.wrap(function _callee26$(_context26) { | ||
while (1) { | ||
switch (_context20.prev = _context20.next) { | ||
switch (_context26.prev = _context26.next) { | ||
case 0: | ||
_context20.next = 2; | ||
_context26.next = 2; | ||
return resOrError(res).text(); | ||
case 2: | ||
return _context20.abrupt("return", _context20.sent); | ||
return _context26.abrupt("return", _context26.sent); | ||
case 3: | ||
case "end": | ||
return _context20.stop(); | ||
return _context26.stop(); | ||
} | ||
} | ||
}, _callee20); | ||
}, _callee26); | ||
})); | ||
@@ -165,19 +167,19 @@ return _resText.apply(this, arguments); | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee21(res) { | ||
return _regenerator.default.wrap(function _callee21$(_context21) { | ||
_regenerator.default.mark(function _callee27(res) { | ||
return _regenerator.default.wrap(function _callee27$(_context27) { | ||
while (1) { | ||
switch (_context21.prev = _context21.next) { | ||
switch (_context27.prev = _context27.next) { | ||
case 0: | ||
_context21.next = 2; | ||
_context27.next = 2; | ||
return resText(res); | ||
case 2: | ||
return _context21.abrupt("return", _context21.sent); | ||
return _context27.abrupt("return", _context27.sent); | ||
case 3: | ||
case "end": | ||
return _context21.stop(); | ||
return _context27.stop(); | ||
} | ||
} | ||
}, _callee21); | ||
}, _callee27); | ||
})); | ||
@@ -194,21 +196,21 @@ return _resHex.apply(this, arguments); | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee22(res) { | ||
_regenerator.default.mark(function _callee28(res) { | ||
var value; | ||
return _regenerator.default.wrap(function _callee22$(_context22) { | ||
return _regenerator.default.wrap(function _callee28$(_context28) { | ||
while (1) { | ||
switch (_context22.prev = _context22.next) { | ||
switch (_context28.prev = _context28.next) { | ||
case 0: | ||
_context22.next = 2; | ||
_context28.next = 2; | ||
return resOrError(res).arrayBuffer(); | ||
case 2: | ||
value = _context22.sent; | ||
return _context22.abrupt("return", Buffer.from(new Uint8Array(value)).toString('hex')); | ||
value = _context28.sent; | ||
return _context28.abrupt("return", Buffer.from(new Uint8Array(value)).toString('hex')); | ||
case 4: | ||
case "end": | ||
return _context22.stop(); | ||
return _context28.stop(); | ||
} | ||
} | ||
}, _callee22); | ||
}, _callee28); | ||
})); | ||
@@ -222,2 +224,26 @@ return _resSwarmHash.apply(this, arguments); | ||
function formatPinnedFile(p) { | ||
return { | ||
address: p.Address, | ||
counter: p.PinCounter, | ||
raw: p.IsRaw, | ||
size: p.FileSize | ||
}; | ||
} | ||
function formatTag(t) { | ||
return { | ||
uid: t.Uid, | ||
name: t.Name, | ||
address: t.Address, | ||
total: t.Total, | ||
split: t.Split, | ||
seen: t.Seen, | ||
stored: t.Stored, | ||
sent: t.Sent, | ||
synced: t.Synced, | ||
startedAt: new Date(t.StartedAt) | ||
}; | ||
} | ||
var BaseBzz = | ||
@@ -363,5 +389,5 @@ /*#__PURE__*/ | ||
// feed params | ||
Object.keys(hashOrParams).forEach(function (key) { | ||
// @ts-ignore | ||
var value = hashOrParams[key]; | ||
var params = hashOrParams; | ||
Object.keys(params).forEach(function (key) { | ||
var value = params[key]; | ||
@@ -381,2 +407,20 @@ if (value != null) { | ||
_proto.getPinURL = function getPinURL(hash, raw) { | ||
if (raw === void 0) { | ||
raw = false; | ||
} | ||
var url = this.url + BZZ_MODE_PROTOCOLS.pin; | ||
if (hash != null) { | ||
url += hash; | ||
} | ||
if (raw) { | ||
url += '/?raw=true'; | ||
} | ||
return url; | ||
}; | ||
_proto.hash = | ||
@@ -575,15 +619,19 @@ /*#__PURE__*/ | ||
options.headers['content-length'] = body.length; | ||
options.headers['content-length'] = options.size == null ? body.length : options.size; | ||
if (options.headers != null && options.headers['content-type'] == null && !raw) { | ||
if (options.headers['content-type'] == null && !raw) { | ||
options.headers['content-type'] = options.contentType; | ||
} | ||
_context6.next = 8; | ||
if (options.pin) { | ||
options.headers['x-swarm-pin'] = true; | ||
} | ||
_context6.next = 9; | ||
return this.uploadBody(body, options, raw); | ||
case 8: | ||
case 9: | ||
return _context6.abrupt("return", _context6.sent); | ||
case 9: | ||
case 10: | ||
case "end": | ||
@@ -1195,2 +1243,237 @@ return _context6.stop(); | ||
_proto.pinEnabled = | ||
/*#__PURE__*/ | ||
function () { | ||
var _pinEnabled = (0, _asyncToGenerator2.default)( | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee19(options) { | ||
var res; | ||
return _regenerator.default.wrap(function _callee19$(_context19) { | ||
while (1) { | ||
switch (_context19.prev = _context19.next) { | ||
case 0: | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
_context19.next = 3; | ||
return this.fetchTimeout(this.getPinURL(), options); | ||
case 3: | ||
res = _context19.sent; | ||
return _context19.abrupt("return", res.ok); | ||
case 5: | ||
case "end": | ||
return _context19.stop(); | ||
} | ||
} | ||
}, _callee19, this); | ||
})); | ||
function pinEnabled(_x52) { | ||
return _pinEnabled.apply(this, arguments); | ||
} | ||
return pinEnabled; | ||
}(); | ||
_proto.pin = | ||
/*#__PURE__*/ | ||
function () { | ||
var _pin = (0, _asyncToGenerator2.default)( | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee20(hash, options) { | ||
var url; | ||
return _regenerator.default.wrap(function _callee20$(_context20) { | ||
while (1) { | ||
switch (_context20.prev = _context20.next) { | ||
case 0: | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
if (!options.download) { | ||
_context20.next = 4; | ||
break; | ||
} | ||
_context20.next = 4; | ||
return this.download(hash, { | ||
mode: options.raw ? 'raw' : 'default' | ||
}); | ||
case 4: | ||
url = this.getPinURL(hash, options.raw); | ||
_context20.next = 7; | ||
return this.fetchTimeout(url, options, { | ||
method: 'POST' | ||
}); | ||
case 7: | ||
case "end": | ||
return _context20.stop(); | ||
} | ||
} | ||
}, _callee20, this); | ||
})); | ||
function pin(_x53, _x54) { | ||
return _pin.apply(this, arguments); | ||
} | ||
return pin; | ||
}(); | ||
_proto.unpin = | ||
/*#__PURE__*/ | ||
function () { | ||
var _unpin = (0, _asyncToGenerator2.default)( | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee21(hash, options) { | ||
return _regenerator.default.wrap(function _callee21$(_context21) { | ||
while (1) { | ||
switch (_context21.prev = _context21.next) { | ||
case 0: | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
_context21.next = 3; | ||
return this.fetchTimeout(this.getPinURL(hash), options, { | ||
method: 'DELETE' | ||
}); | ||
case 3: | ||
case "end": | ||
return _context21.stop(); | ||
} | ||
} | ||
}, _callee21, this); | ||
})); | ||
function unpin(_x55, _x56) { | ||
return _unpin.apply(this, arguments); | ||
} | ||
return unpin; | ||
}(); | ||
_proto.pins = | ||
/*#__PURE__*/ | ||
function () { | ||
var _pins = (0, _asyncToGenerator2.default)( | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee22(options) { | ||
var res, pins; | ||
return _regenerator.default.wrap(function _callee22$(_context22) { | ||
while (1) { | ||
switch (_context22.prev = _context22.next) { | ||
case 0: | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
_context22.next = 3; | ||
return this.fetchTimeout(this.getPinURL(), options); | ||
case 3: | ||
res = _context22.sent; | ||
_context22.next = 6; | ||
return resJSON(res); | ||
case 6: | ||
pins = _context22.sent; | ||
return _context22.abrupt("return", pins.map(formatPinnedFile)); | ||
case 8: | ||
case "end": | ||
return _context22.stop(); | ||
} | ||
} | ||
}, _callee22, this); | ||
})); | ||
function pins(_x57) { | ||
return _pins.apply(this, arguments); | ||
} | ||
return pins; | ||
}(); | ||
_proto.getTag = | ||
/*#__PURE__*/ | ||
function () { | ||
var _getTag = (0, _asyncToGenerator2.default)( | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee23(hash, options) { | ||
var res, tag; | ||
return _regenerator.default.wrap(function _callee23$(_context23) { | ||
while (1) { | ||
switch (_context23.prev = _context23.next) { | ||
case 0: | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
_context23.next = 3; | ||
return this.fetchTimeout(this.url + BZZ_MODE_PROTOCOLS.tag + hash, options); | ||
case 3: | ||
res = _context23.sent; | ||
_context23.next = 6; | ||
return resJSON(res); | ||
case 6: | ||
tag = _context23.sent; | ||
return _context23.abrupt("return", formatTag(tag)); | ||
case 8: | ||
case "end": | ||
return _context23.stop(); | ||
} | ||
} | ||
}, _callee23, this); | ||
})); | ||
function getTag(_x58, _x59) { | ||
return _getTag.apply(this, arguments); | ||
} | ||
return getTag; | ||
}(); | ||
_proto.pollTag = function pollTag(hash, options) { | ||
var _this5 = this; | ||
var sources = []; // Trigger the flow immediately by default | ||
if (options.immediate !== false) { | ||
sources.push([0]); | ||
} | ||
return _rxjs.merge.apply(void 0, [(0, _rxjs.interval)(options.interval)].concat(sources)).pipe((0, _operators.flatMap)( | ||
/*#__PURE__*/ | ||
(0, _asyncToGenerator2.default)( | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee24() { | ||
return _regenerator.default.wrap(function _callee24$(_context24) { | ||
while (1) { | ||
switch (_context24.prev = _context24.next) { | ||
case 0: | ||
_context24.next = 2; | ||
return _this5.getTag(hash, options); | ||
case 2: | ||
return _context24.abrupt("return", _context24.sent); | ||
case 3: | ||
case "end": | ||
return _context24.stop(); | ||
} | ||
} | ||
}, _callee24); | ||
})))); | ||
}; | ||
return BaseBzz; | ||
@@ -1197,0 +1480,0 @@ }(); |
359
esm/index.js
@@ -18,3 +18,5 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
immutable: 'bzz-immutable:/', | ||
raw: 'bzz-raw:/' | ||
pin: 'bzz-pin:/', | ||
raw: 'bzz-raw:/', | ||
tag: 'bzz-tag:/' | ||
}; | ||
@@ -56,19 +58,19 @@ export function getModeProtocol(mode) { | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee19(res) { | ||
return _regeneratorRuntime.wrap(function _callee19$(_context19) { | ||
_regeneratorRuntime.mark(function _callee25(res) { | ||
return _regeneratorRuntime.wrap(function _callee25$(_context25) { | ||
while (1) { | ||
switch (_context19.prev = _context19.next) { | ||
switch (_context25.prev = _context25.next) { | ||
case 0: | ||
_context19.next = 2; | ||
_context25.next = 2; | ||
return resOrError(res).json(); | ||
case 2: | ||
return _context19.abrupt("return", _context19.sent); | ||
return _context25.abrupt("return", _context25.sent); | ||
case 3: | ||
case "end": | ||
return _context19.stop(); | ||
return _context25.stop(); | ||
} | ||
} | ||
}, _callee19); | ||
}, _callee25); | ||
})); | ||
@@ -85,19 +87,19 @@ return _resJSON.apply(this, arguments); | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee20(res) { | ||
return _regeneratorRuntime.wrap(function _callee20$(_context20) { | ||
_regeneratorRuntime.mark(function _callee26(res) { | ||
return _regeneratorRuntime.wrap(function _callee26$(_context26) { | ||
while (1) { | ||
switch (_context20.prev = _context20.next) { | ||
switch (_context26.prev = _context26.next) { | ||
case 0: | ||
_context20.next = 2; | ||
_context26.next = 2; | ||
return resOrError(res).text(); | ||
case 2: | ||
return _context20.abrupt("return", _context20.sent); | ||
return _context26.abrupt("return", _context26.sent); | ||
case 3: | ||
case "end": | ||
return _context20.stop(); | ||
return _context26.stop(); | ||
} | ||
} | ||
}, _callee20); | ||
}, _callee26); | ||
})); | ||
@@ -114,19 +116,19 @@ return _resText.apply(this, arguments); | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee21(res) { | ||
return _regeneratorRuntime.wrap(function _callee21$(_context21) { | ||
_regeneratorRuntime.mark(function _callee27(res) { | ||
return _regeneratorRuntime.wrap(function _callee27$(_context27) { | ||
while (1) { | ||
switch (_context21.prev = _context21.next) { | ||
switch (_context27.prev = _context27.next) { | ||
case 0: | ||
_context21.next = 2; | ||
_context27.next = 2; | ||
return resText(res); | ||
case 2: | ||
return _context21.abrupt("return", _context21.sent); | ||
return _context27.abrupt("return", _context27.sent); | ||
case 3: | ||
case "end": | ||
return _context21.stop(); | ||
return _context27.stop(); | ||
} | ||
} | ||
}, _callee21); | ||
}, _callee27); | ||
})); | ||
@@ -143,21 +145,21 @@ return _resHex.apply(this, arguments); | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee22(res) { | ||
_regeneratorRuntime.mark(function _callee28(res) { | ||
var value; | ||
return _regeneratorRuntime.wrap(function _callee22$(_context22) { | ||
return _regeneratorRuntime.wrap(function _callee28$(_context28) { | ||
while (1) { | ||
switch (_context22.prev = _context22.next) { | ||
switch (_context28.prev = _context28.next) { | ||
case 0: | ||
_context22.next = 2; | ||
_context28.next = 2; | ||
return resOrError(res).arrayBuffer(); | ||
case 2: | ||
value = _context22.sent; | ||
return _context22.abrupt("return", Buffer.from(new Uint8Array(value)).toString('hex')); | ||
value = _context28.sent; | ||
return _context28.abrupt("return", Buffer.from(new Uint8Array(value)).toString('hex')); | ||
case 4: | ||
case "end": | ||
return _context22.stop(); | ||
return _context28.stop(); | ||
} | ||
} | ||
}, _callee22); | ||
}, _callee28); | ||
})); | ||
@@ -171,2 +173,26 @@ return _resSwarmHash.apply(this, arguments); | ||
function formatPinnedFile(p) { | ||
return { | ||
address: p.Address, | ||
counter: p.PinCounter, | ||
raw: p.IsRaw, | ||
size: p.FileSize | ||
}; | ||
} | ||
function formatTag(t) { | ||
return { | ||
uid: t.Uid, | ||
name: t.Name, | ||
address: t.Address, | ||
total: t.Total, | ||
split: t.Split, | ||
seen: t.Seen, | ||
stored: t.Stored, | ||
sent: t.Sent, | ||
synced: t.Synced, | ||
startedAt: new Date(t.StartedAt) | ||
}; | ||
} | ||
export var BaseBzz = | ||
@@ -316,5 +342,5 @@ /*#__PURE__*/ | ||
// feed params | ||
Object.keys(hashOrParams).forEach(function (key) { | ||
// @ts-ignore | ||
var value = hashOrParams[key]; | ||
var params = hashOrParams; | ||
Object.keys(params).forEach(function (key) { | ||
var value = params[key]; | ||
@@ -334,2 +360,20 @@ if (value != null) { | ||
_proto.getPinURL = function getPinURL(hash, raw) { | ||
if (raw === void 0) { | ||
raw = false; | ||
} | ||
var url = this.url + BZZ_MODE_PROTOCOLS.pin; | ||
if (hash != null) { | ||
url += hash; | ||
} | ||
if (raw) { | ||
url += '/?raw=true'; | ||
} | ||
return url; | ||
}; | ||
_proto.hash = | ||
@@ -528,15 +572,19 @@ /*#__PURE__*/ | ||
options.headers['content-length'] = body.length; | ||
options.headers['content-length'] = options.size == null ? body.length : options.size; | ||
if (options.headers != null && options.headers['content-type'] == null && !raw) { | ||
if (options.headers['content-type'] == null && !raw) { | ||
options.headers['content-type'] = options.contentType; | ||
} | ||
_context6.next = 8; | ||
if (options.pin) { | ||
options.headers['x-swarm-pin'] = true; | ||
} | ||
_context6.next = 9; | ||
return this.uploadBody(body, options, raw); | ||
case 8: | ||
case 9: | ||
return _context6.abrupt("return", _context6.sent); | ||
case 9: | ||
case 10: | ||
case "end": | ||
@@ -1148,3 +1196,238 @@ return _context6.stop(); | ||
_proto.pinEnabled = | ||
/*#__PURE__*/ | ||
function () { | ||
var _pinEnabled = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee19(options) { | ||
var res; | ||
return _regeneratorRuntime.wrap(function _callee19$(_context19) { | ||
while (1) { | ||
switch (_context19.prev = _context19.next) { | ||
case 0: | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
_context19.next = 3; | ||
return this.fetchTimeout(this.getPinURL(), options); | ||
case 3: | ||
res = _context19.sent; | ||
return _context19.abrupt("return", res.ok); | ||
case 5: | ||
case "end": | ||
return _context19.stop(); | ||
} | ||
} | ||
}, _callee19, this); | ||
})); | ||
function pinEnabled(_x52) { | ||
return _pinEnabled.apply(this, arguments); | ||
} | ||
return pinEnabled; | ||
}(); | ||
_proto.pin = | ||
/*#__PURE__*/ | ||
function () { | ||
var _pin = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee20(hash, options) { | ||
var url; | ||
return _regeneratorRuntime.wrap(function _callee20$(_context20) { | ||
while (1) { | ||
switch (_context20.prev = _context20.next) { | ||
case 0: | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
if (!options.download) { | ||
_context20.next = 4; | ||
break; | ||
} | ||
_context20.next = 4; | ||
return this.download(hash, { | ||
mode: options.raw ? 'raw' : 'default' | ||
}); | ||
case 4: | ||
url = this.getPinURL(hash, options.raw); | ||
_context20.next = 7; | ||
return this.fetchTimeout(url, options, { | ||
method: 'POST' | ||
}); | ||
case 7: | ||
case "end": | ||
return _context20.stop(); | ||
} | ||
} | ||
}, _callee20, this); | ||
})); | ||
function pin(_x53, _x54) { | ||
return _pin.apply(this, arguments); | ||
} | ||
return pin; | ||
}(); | ||
_proto.unpin = | ||
/*#__PURE__*/ | ||
function () { | ||
var _unpin = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee21(hash, options) { | ||
return _regeneratorRuntime.wrap(function _callee21$(_context21) { | ||
while (1) { | ||
switch (_context21.prev = _context21.next) { | ||
case 0: | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
_context21.next = 3; | ||
return this.fetchTimeout(this.getPinURL(hash), options, { | ||
method: 'DELETE' | ||
}); | ||
case 3: | ||
case "end": | ||
return _context21.stop(); | ||
} | ||
} | ||
}, _callee21, this); | ||
})); | ||
function unpin(_x55, _x56) { | ||
return _unpin.apply(this, arguments); | ||
} | ||
return unpin; | ||
}(); | ||
_proto.pins = | ||
/*#__PURE__*/ | ||
function () { | ||
var _pins = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee22(options) { | ||
var res, pins; | ||
return _regeneratorRuntime.wrap(function _callee22$(_context22) { | ||
while (1) { | ||
switch (_context22.prev = _context22.next) { | ||
case 0: | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
_context22.next = 3; | ||
return this.fetchTimeout(this.getPinURL(), options); | ||
case 3: | ||
res = _context22.sent; | ||
_context22.next = 6; | ||
return resJSON(res); | ||
case 6: | ||
pins = _context22.sent; | ||
return _context22.abrupt("return", pins.map(formatPinnedFile)); | ||
case 8: | ||
case "end": | ||
return _context22.stop(); | ||
} | ||
} | ||
}, _callee22, this); | ||
})); | ||
function pins(_x57) { | ||
return _pins.apply(this, arguments); | ||
} | ||
return pins; | ||
}(); | ||
_proto.getTag = | ||
/*#__PURE__*/ | ||
function () { | ||
var _getTag = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee23(hash, options) { | ||
var res, tag; | ||
return _regeneratorRuntime.wrap(function _callee23$(_context23) { | ||
while (1) { | ||
switch (_context23.prev = _context23.next) { | ||
case 0: | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
_context23.next = 3; | ||
return this.fetchTimeout(this.url + BZZ_MODE_PROTOCOLS.tag + hash, options); | ||
case 3: | ||
res = _context23.sent; | ||
_context23.next = 6; | ||
return resJSON(res); | ||
case 6: | ||
tag = _context23.sent; | ||
return _context23.abrupt("return", formatTag(tag)); | ||
case 8: | ||
case "end": | ||
return _context23.stop(); | ||
} | ||
} | ||
}, _callee23, this); | ||
})); | ||
function getTag(_x58, _x59) { | ||
return _getTag.apply(this, arguments); | ||
} | ||
return getTag; | ||
}(); | ||
_proto.pollTag = function pollTag(hash, options) { | ||
var _this5 = this; | ||
var sources = []; // Trigger the flow immediately by default | ||
if (options.immediate !== false) { | ||
sources.push([0]); | ||
} | ||
return merge.apply(void 0, [interval(options.interval)].concat(sources)).pipe(flatMap( | ||
/*#__PURE__*/ | ||
_asyncToGenerator( | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee24() { | ||
return _regeneratorRuntime.wrap(function _callee24$(_context24) { | ||
while (1) { | ||
switch (_context24.prev = _context24.next) { | ||
case 0: | ||
_context24.next = 2; | ||
return _this5.getTag(hash, options); | ||
case 2: | ||
return _context24.abrupt("return", _context24.sent); | ||
case 3: | ||
case "end": | ||
return _context24.stop(); | ||
} | ||
} | ||
}, _callee24); | ||
})))); | ||
}; | ||
return BaseBzz; | ||
}(); |
{ | ||
"name": "@erebos/api-bzz-base", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "Base Bzz API", | ||
@@ -27,10 +27,7 @@ "repository": "git@github.com:MainframeHQ/erebos.git", | ||
"dependencies": { | ||
"@babel/runtime": "^7.5.5", | ||
"@erebos/hex": "^0.9.0", | ||
"@erebos/keccak256": "^0.9.0", | ||
"rxjs": "^6.5.2" | ||
}, | ||
"devDependencies": { | ||
"typescript": "3.5.2" | ||
"@babel/runtime": "^7.6.2", | ||
"@erebos/hex": "^0.10.0", | ||
"@erebos/keccak256": "^0.10.0", | ||
"rxjs": "^6.5.3" | ||
} | ||
} |
/// <reference types="node" /> | ||
import { hexInput, hexValue } from '@erebos/hex'; | ||
import { Observable } from 'rxjs'; | ||
import { BaseResponse, RequestInit, Fetch, BzzConfig, BzzMode, DirectoryData, DownloadOptions, FeedMetadata, FeedParams, FeedUpdateParams, FetchOptions, ListResult, PollOptions, PollContentHashOptions, PollContentOptions, SignBytesFunc, UploadOptions } from './types'; | ||
import { BaseResponse, RequestInit, Fetch, BzzConfig, BzzMode, DirectoryData, DownloadOptions, FeedMetadata, FeedParams, FeedUpdateParams, FetchOptions, ListResult, PinOptions, PinnedFile, PollOptions, PollFeedOptions, PollFeedContentHashOptions, PollFeedContentOptions, SignBytesFunc, Tag, UploadOptions } from './types'; | ||
export * from './feed'; | ||
@@ -11,3 +11,5 @@ export * from './types'; | ||
immutable: string; | ||
pin: string; | ||
raw: string; | ||
tag: string; | ||
}; | ||
@@ -35,2 +37,3 @@ export declare function getModeProtocol(mode?: BzzMode): string; | ||
getFeedURL(hashOrParams: string | FeedParams | FeedUpdateParams, flag?: 'meta'): string; | ||
getPinURL(hash?: string, raw?: boolean): string; | ||
hash(domain: string, options?: FetchOptions): Promise<hexValue>; | ||
@@ -49,5 +52,5 @@ list(hash: string, options?: DownloadOptions): Promise<ListResult>; | ||
getFeedContent(hashOrParams: string | FeedParams, options?: DownloadOptions): Promise<Response>; | ||
pollFeedChunk(hashOrParams: string | FeedParams, options: PollOptions): Observable<Response>; | ||
pollFeedContentHash(hashOrParams: string | FeedParams, options: PollContentHashOptions): Observable<string | null>; | ||
pollFeedContent(hashOrParams: string | FeedParams, options: PollContentOptions): Observable<Response | null>; | ||
pollFeedChunk(hashOrParams: string | FeedParams, options: PollFeedOptions): Observable<Response>; | ||
pollFeedContentHash(hashOrParams: string | FeedParams, options: PollFeedContentHashOptions): Observable<string | null>; | ||
pollFeedContent(hashOrParams: string | FeedParams, options: PollFeedContentOptions): Observable<Response | null>; | ||
postSignedFeedChunk(params: FeedUpdateParams, body: Buffer, options?: FetchOptions): Promise<Response>; | ||
@@ -58,2 +61,8 @@ postFeedChunk(meta: FeedMetadata, data: hexInput, options?: FetchOptions, signParams?: any): Promise<Response>; | ||
setFeedContent(hashOrParams: string | FeedParams, data: string | Buffer | DirectoryData, options?: UploadOptions, signParams?: any): Promise<hexValue>; | ||
pinEnabled(options?: FetchOptions): Promise<boolean>; | ||
pin(hash: string, options?: PinOptions): Promise<void>; | ||
unpin(hash: string, options?: FetchOptions): Promise<void>; | ||
pins(options?: FetchOptions): Promise<Array<PinnedFile>>; | ||
getTag(hash: string, options?: FetchOptions): Promise<Tag>; | ||
pollTag(hash: string, options: PollOptions): Observable<Tag>; | ||
} |
@@ -68,2 +68,4 @@ /// <reference types="node" /> | ||
manifestHash?: hexValue | string; | ||
pin?: boolean; | ||
size?: number; | ||
} | ||
@@ -73,10 +75,34 @@ export interface PollOptions extends FetchOptions { | ||
immediate?: boolean; | ||
} | ||
export interface PollFeedOptions extends PollOptions { | ||
whenEmpty?: 'accept' | 'ignore' | 'error'; | ||
trigger?: Observable<void>; | ||
} | ||
export interface PollContentHashOptions extends PollOptions { | ||
export interface PollFeedContentHashOptions extends PollFeedOptions { | ||
changedOnly?: boolean; | ||
} | ||
export interface PollContentOptions extends DownloadOptions, PollContentHashOptions { | ||
export interface PollFeedContentOptions extends DownloadOptions, PollFeedContentHashOptions { | ||
} | ||
export interface PinOptions extends FetchOptions { | ||
download?: boolean; | ||
raw?: boolean; | ||
} | ||
export interface PinnedFile { | ||
address: string; | ||
counter: number; | ||
raw: boolean; | ||
size: number; | ||
} | ||
export interface Tag { | ||
uid: number; | ||
name: string; | ||
address: string; | ||
total: number; | ||
split: number; | ||
seen: number; | ||
stored: number; | ||
sent: number; | ||
synced: number; | ||
startedAt: Date; | ||
} | ||
export interface FeedParams { | ||
@@ -83,0 +109,0 @@ user: string; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
88846
0
2655
2
+ Added@erebos/hex@0.10.0(transitive)
+ Added@erebos/keccak256@0.10.0(transitive)
- Removed@erebos/hex@0.9.0(transitive)
- Removed@erebos/keccak256@0.9.0(transitive)
Updated@babel/runtime@^7.6.2
Updated@erebos/hex@^0.10.0
Updated@erebos/keccak256@^0.10.0
Updatedrxjs@^6.5.3