@audius/sdk 1.0.17 → 1.0.19
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/api/File.d.ts +4 -1
- package/dist/api/entityManager.d.ts +3 -16
- package/dist/index.cjs.js +169 -117
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +169 -117
- package/dist/index.esm.js.map +1 -1
- package/dist/legacy.js +169 -117
- package/dist/legacy.js.map +1 -1
- package/dist/native-libs.js +169 -117
- package/dist/native-libs.js.map +1 -1
- package/dist/services/dataContracts/EntityManagerClient.d.ts +7 -1
- package/package.json +2 -2
- package/src/AudiusLibs.ts +1 -1
- package/src/NativeAudiusLibs.ts +1 -1
- package/src/api/File.ts +48 -2
- package/src/api/entityManager.ts +9 -18
- package/src/services/dataContracts/EntityManagerClient.ts +7 -1
package/dist/api/File.d.ts
CHANGED
|
@@ -2,9 +2,11 @@ import { ResponseType } from 'axios';
|
|
|
2
2
|
import { Base, BaseConstructorArgs } from './base';
|
|
3
3
|
import type { Users } from './Users';
|
|
4
4
|
import type { Nullable } from '../utils';
|
|
5
|
+
import type { ServiceProvider } from './ServiceProvider';
|
|
5
6
|
export declare class File extends Base {
|
|
6
7
|
User: Users;
|
|
7
|
-
|
|
8
|
+
ServiceProvider: ServiceProvider;
|
|
9
|
+
constructor(user: Users, serviceProvider: ServiceProvider, ...args: BaseConstructorArgs);
|
|
8
10
|
/**
|
|
9
11
|
* Fetches a file from Content Node with a given CID.
|
|
10
12
|
* @param cid IPFS content identifier
|
|
@@ -14,6 +16,7 @@ export declare class File extends Base {
|
|
|
14
16
|
* Can be used for tracking metrics on which gateways were used.
|
|
15
17
|
*/
|
|
16
18
|
fetchCID(cid: string, creatorNodeGateways: string[], callback?: Nullable<(url: string) => void>, responseType?: ResponseType, trackId?: null, premiumContentHeaders?: {}): Promise<import("axios").AxiosResponse<any> | undefined>;
|
|
19
|
+
fetchCIDInternal(cid: string, creatorNodeGateways: string[], callback?: Nullable<(url: string) => void>, responseType?: ResponseType, trackId?: null, premiumContentHeaders?: {}): Promise<import("axios").AxiosResponse<any> | undefined>;
|
|
17
20
|
/**
|
|
18
21
|
* Fetches a file from Content Node with a given CID. Follows the same pattern
|
|
19
22
|
* as fetchCID, but resolves with a download of the file rather than
|
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
import { Base } from './base';
|
|
2
|
-
|
|
3
|
-
CREATE = "Create",
|
|
4
|
-
UPDATE = "Update",
|
|
5
|
-
DELETE = "Delete",
|
|
6
|
-
FOLLOW = "Follow",
|
|
7
|
-
UNFOLLOW = "Unfollow",
|
|
8
|
-
SAVE = "Save",
|
|
9
|
-
UNSAVE = "Unsave",
|
|
10
|
-
REPOST = "Repost",
|
|
11
|
-
UNREPOST = "Unrepost"
|
|
12
|
-
}
|
|
13
|
-
export declare enum EntityType {
|
|
14
|
-
TRACK = "Track",
|
|
15
|
-
PLAYLIST = "Playlist",
|
|
16
|
-
USER = "User"
|
|
17
|
-
}
|
|
2
|
+
import { Action, EntityType } from '../services/dataContracts/EntityManagerClient';
|
|
18
3
|
export declare type EntityManagerSuccessResponse = {
|
|
19
4
|
blockHash: string;
|
|
20
5
|
blockNumber: number;
|
|
@@ -66,6 +51,8 @@ export declare class EntityManager extends Base {
|
|
|
66
51
|
unsavePlaylist: (entityId: number) => Promise<EntityManagerResponse>;
|
|
67
52
|
repostTrack: (entityId: number) => Promise<EntityManagerResponse>;
|
|
68
53
|
unrepostTrack: (entityId: number) => Promise<EntityManagerResponse>;
|
|
54
|
+
repostPlaylist: (entityId: number) => Promise<EntityManagerResponse>;
|
|
55
|
+
unrepostPlaylist: (entityId: number) => Promise<EntityManagerResponse>;
|
|
69
56
|
/** Playlist */
|
|
70
57
|
createPlaylist(playlist: PlaylistParam): Promise<EntityManagerResponse>;
|
|
71
58
|
deletePlaylist(playlistId: number): Promise<EntityManagerResponse>;
|
package/dist/index.cjs.js
CHANGED
|
@@ -34277,9 +34277,9 @@ var formatProviders = function formatProviders(providers) {
|
|
|
34277
34277
|
};
|
|
34278
34278
|
|
|
34279
34279
|
var name = "@audius/sdk";
|
|
34280
|
-
var version = "1.0.
|
|
34280
|
+
var version = "1.0.19";
|
|
34281
34281
|
var audius = {
|
|
34282
|
-
releaseSHA: "
|
|
34282
|
+
releaseSHA: "0a307f67af9a7dc7a6128b181bce45d92d9492df"
|
|
34283
34283
|
};
|
|
34284
34284
|
var description = "";
|
|
34285
34285
|
var main = "dist/index.cjs.js";
|
|
@@ -46339,23 +46339,29 @@ var UserReplicaSetManagerClient = /*#__PURE__*/function (_ContractClient) {
|
|
|
46339
46339
|
return UserReplicaSetManagerClient;
|
|
46340
46340
|
}(ContractClient);
|
|
46341
46341
|
|
|
46342
|
-
var Action
|
|
46342
|
+
var Action;
|
|
46343
46343
|
|
|
46344
46344
|
(function (Action) {
|
|
46345
46345
|
Action["CREATE"] = "Create";
|
|
46346
46346
|
Action["UPDATE"] = "Update";
|
|
46347
46347
|
Action["DELETE"] = "Delete";
|
|
46348
46348
|
Action["VERIFY"] = "Verify";
|
|
46349
|
-
|
|
46349
|
+
Action["FOLLOW"] = "Follow";
|
|
46350
|
+
Action["UNFOLLOW"] = "Unfollow";
|
|
46351
|
+
Action["SAVE"] = "Save";
|
|
46352
|
+
Action["UNSAVE"] = "Unsave";
|
|
46353
|
+
Action["REPOST"] = "Repost";
|
|
46354
|
+
Action["UNREPOST"] = "Unrepost";
|
|
46355
|
+
})(Action || (Action = {}));
|
|
46350
46356
|
|
|
46351
|
-
var EntityType
|
|
46357
|
+
var EntityType;
|
|
46352
46358
|
|
|
46353
46359
|
(function (EntityType) {
|
|
46354
46360
|
EntityType["PLAYLIST"] = "Playlist";
|
|
46355
46361
|
EntityType["TRACK"] = "Track";
|
|
46356
46362
|
EntityType["USER"] = "User";
|
|
46357
46363
|
EntityType["USER_REPLICA_SET"] = "UserReplicaSet";
|
|
46358
|
-
})(EntityType
|
|
46364
|
+
})(EntityType || (EntityType = {}));
|
|
46359
46365
|
/**
|
|
46360
46366
|
* Generic management of Audius Data entities
|
|
46361
46367
|
**/
|
|
@@ -46517,8 +46523,8 @@ var EntityManagerClient = /*#__PURE__*/function (_ContractClient) {
|
|
|
46517
46523
|
|
|
46518
46524
|
return EntityManagerClient;
|
|
46519
46525
|
}(ContractClient);
|
|
46520
|
-
EntityManagerClient.Action = Action
|
|
46521
|
-
EntityManagerClient.EntityType = EntityType
|
|
46526
|
+
EntityManagerClient.Action = Action;
|
|
46527
|
+
EntityManagerClient.EntityType = EntityType;
|
|
46522
46528
|
|
|
46523
46529
|
var abi = [
|
|
46524
46530
|
{
|
|
@@ -58305,17 +58311,18 @@ var File = /*#__PURE__*/function (_Base) {
|
|
|
58305
58311
|
|
|
58306
58312
|
var _super = _createSuper(File);
|
|
58307
58313
|
|
|
58308
|
-
function File(user) {
|
|
58314
|
+
function File(user, serviceProvider) {
|
|
58309
58315
|
var _this;
|
|
58310
58316
|
|
|
58311
58317
|
_classCallCheck(this, File);
|
|
58312
58318
|
|
|
58313
|
-
for (var _len = arguments.length, args = new Array(_len >
|
|
58314
|
-
args[_key -
|
|
58319
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
58320
|
+
args[_key - 2] = arguments[_key];
|
|
58315
58321
|
}
|
|
58316
58322
|
|
|
58317
58323
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
58318
58324
|
_this.User = user;
|
|
58325
|
+
_this.ServiceProvider = serviceProvider;
|
|
58319
58326
|
return _this;
|
|
58320
58327
|
}
|
|
58321
58328
|
/**
|
|
@@ -58331,21 +58338,86 @@ var File = /*#__PURE__*/function (_Base) {
|
|
|
58331
58338
|
_createClass(File, [{
|
|
58332
58339
|
key: "fetchCID",
|
|
58333
58340
|
value: function () {
|
|
58334
|
-
var _fetchCID = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
58341
|
+
var _fetchCID = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(cid, creatorNodeGateways) {
|
|
58342
|
+
var callback,
|
|
58343
|
+
responseType,
|
|
58344
|
+
trackId,
|
|
58345
|
+
premiumContentHeaders,
|
|
58346
|
+
replicaSetAttempt,
|
|
58347
|
+
allCreatorNodes,
|
|
58348
|
+
allCreatorNodeEndpoints,
|
|
58349
|
+
allNodesAttempt,
|
|
58350
|
+
_args = arguments;
|
|
58351
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
58352
|
+
while (1) {
|
|
58353
|
+
switch (_context.prev = _context.next) {
|
|
58354
|
+
case 0:
|
|
58355
|
+
callback = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
|
|
58356
|
+
responseType = _args.length > 3 && _args[3] !== undefined ? _args[3] : 'blob';
|
|
58357
|
+
trackId = _args.length > 4 && _args[4] !== undefined ? _args[4] : null;
|
|
58358
|
+
premiumContentHeaders = _args.length > 5 && _args[5] !== undefined ? _args[5] : {};
|
|
58359
|
+
_context.prev = 4;
|
|
58360
|
+
_context.next = 7;
|
|
58361
|
+
return this.fetchCIDInternal(cid, creatorNodeGateways, callback, responseType, trackId, premiumContentHeaders);
|
|
58362
|
+
|
|
58363
|
+
case 7:
|
|
58364
|
+
replicaSetAttempt = _context.sent;
|
|
58365
|
+
return _context.abrupt("return", replicaSetAttempt);
|
|
58366
|
+
|
|
58367
|
+
case 11:
|
|
58368
|
+
_context.prev = 11;
|
|
58369
|
+
_context.t0 = _context["catch"](4);
|
|
58370
|
+
// In the case we can't find the CID from anywhere in the user's replica set,
|
|
58371
|
+
// retry the whole network
|
|
58372
|
+
console.error(_context.t0);
|
|
58373
|
+
_context.next = 16;
|
|
58374
|
+
return this.ServiceProvider.listCreatorNodes();
|
|
58375
|
+
|
|
58376
|
+
case 16:
|
|
58377
|
+
allCreatorNodes = _context.sent;
|
|
58378
|
+
allCreatorNodeEndpoints = allCreatorNodes.map(function (node) {
|
|
58379
|
+
return urlJoin__default["default"](node.endpoint, 'ipfs');
|
|
58380
|
+
}); // Re-throw whatever error might happen here
|
|
58381
|
+
|
|
58382
|
+
_context.next = 20;
|
|
58383
|
+
return this.fetchCIDInternal(cid, allCreatorNodeEndpoints, callback, responseType, trackId, premiumContentHeaders);
|
|
58384
|
+
|
|
58385
|
+
case 20:
|
|
58386
|
+
allNodesAttempt = _context.sent;
|
|
58387
|
+
return _context.abrupt("return", allNodesAttempt);
|
|
58388
|
+
|
|
58389
|
+
case 22:
|
|
58390
|
+
case "end":
|
|
58391
|
+
return _context.stop();
|
|
58392
|
+
}
|
|
58393
|
+
}
|
|
58394
|
+
}, _callee, this, [[4, 11]]);
|
|
58395
|
+
}));
|
|
58396
|
+
|
|
58397
|
+
function fetchCID(_x, _x2) {
|
|
58398
|
+
return _fetchCID.apply(this, arguments);
|
|
58399
|
+
}
|
|
58400
|
+
|
|
58401
|
+
return fetchCID;
|
|
58402
|
+
}()
|
|
58403
|
+
}, {
|
|
58404
|
+
key: "fetchCIDInternal",
|
|
58405
|
+
value: function () {
|
|
58406
|
+
var _fetchCIDInternal = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(cid, creatorNodeGateways) {
|
|
58335
58407
|
var callback,
|
|
58336
58408
|
responseType,
|
|
58337
58409
|
trackId,
|
|
58338
58410
|
premiumContentHeaders,
|
|
58339
58411
|
urls,
|
|
58340
|
-
|
|
58341
|
-
return regeneratorRuntime.wrap(function
|
|
58412
|
+
_args3 = arguments;
|
|
58413
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
58342
58414
|
while (1) {
|
|
58343
|
-
switch (
|
|
58415
|
+
switch (_context3.prev = _context3.next) {
|
|
58344
58416
|
case 0:
|
|
58345
|
-
callback =
|
|
58346
|
-
responseType =
|
|
58347
|
-
trackId =
|
|
58348
|
-
premiumContentHeaders =
|
|
58417
|
+
callback = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : null;
|
|
58418
|
+
responseType = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : 'blob';
|
|
58419
|
+
trackId = _args3.length > 4 && _args3[4] !== undefined ? _args3[4] : null;
|
|
58420
|
+
premiumContentHeaders = _args3.length > 5 && _args3[5] !== undefined ? _args3[5] : {};
|
|
58349
58421
|
urls = [];
|
|
58350
58422
|
creatorNodeGateways.forEach(function (gateway) {
|
|
58351
58423
|
var gatewayWithCid = urlJoin__default["default"](gateway, cid);
|
|
@@ -58356,17 +58428,17 @@ var File = /*#__PURE__*/function (_Base) {
|
|
|
58356
58428
|
});
|
|
58357
58429
|
urls.push(gatewayWithCid);
|
|
58358
58430
|
});
|
|
58359
|
-
|
|
58431
|
+
_context3.next = 8;
|
|
58360
58432
|
return retry__default["default"]( /*#__PURE__*/function () {
|
|
58361
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
58433
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(bail) {
|
|
58362
58434
|
var _yield$raceRequests, response, errored, allForbidden, legacyUrls, _yield$raceRequests2, _response;
|
|
58363
58435
|
|
|
58364
|
-
return regeneratorRuntime.wrap(function
|
|
58436
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
58365
58437
|
while (1) {
|
|
58366
|
-
switch (
|
|
58438
|
+
switch (_context2.prev = _context2.next) {
|
|
58367
58439
|
case 0:
|
|
58368
|
-
|
|
58369
|
-
|
|
58440
|
+
_context2.prev = 0;
|
|
58441
|
+
_context2.next = 3;
|
|
58370
58442
|
return raceRequests(urls, callback, _objectSpread2({
|
|
58371
58443
|
method: 'get',
|
|
58372
58444
|
responseType: responseType
|
|
@@ -58375,12 +58447,12 @@ var File = /*#__PURE__*/function (_Base) {
|
|
|
58375
58447
|
null);
|
|
58376
58448
|
|
|
58377
58449
|
case 3:
|
|
58378
|
-
_yield$raceRequests =
|
|
58450
|
+
_yield$raceRequests = _context2.sent;
|
|
58379
58451
|
response = _yield$raceRequests.response;
|
|
58380
58452
|
errored = _yield$raceRequests.errored;
|
|
58381
58453
|
|
|
58382
58454
|
if (response) {
|
|
58383
|
-
|
|
58455
|
+
_context2.next = 12;
|
|
58384
58456
|
break;
|
|
58385
58457
|
}
|
|
58386
58458
|
|
|
@@ -58390,26 +58462,26 @@ var File = /*#__PURE__*/function (_Base) {
|
|
|
58390
58462
|
});
|
|
58391
58463
|
|
|
58392
58464
|
if (!allForbidden) {
|
|
58393
|
-
|
|
58465
|
+
_context2.next = 11;
|
|
58394
58466
|
break;
|
|
58395
58467
|
}
|
|
58396
58468
|
|
|
58397
58469
|
// In the case for a 403, do not retry fetching
|
|
58398
58470
|
bail(new Error('Forbidden'));
|
|
58399
|
-
return
|
|
58471
|
+
return _context2.abrupt("return");
|
|
58400
58472
|
|
|
58401
58473
|
case 11:
|
|
58402
58474
|
throw new Error("Could not fetch ".concat(cid));
|
|
58403
58475
|
|
|
58404
58476
|
case 12:
|
|
58405
|
-
return
|
|
58477
|
+
return _context2.abrupt("return", response);
|
|
58406
58478
|
|
|
58407
58479
|
case 15:
|
|
58408
|
-
|
|
58409
|
-
|
|
58480
|
+
_context2.prev = 15;
|
|
58481
|
+
_context2.t0 = _context2["catch"](0);
|
|
58410
58482
|
|
|
58411
58483
|
if (!cid.includes('/')) {
|
|
58412
|
-
|
|
58484
|
+
_context2.next = 33;
|
|
58413
58485
|
break;
|
|
58414
58486
|
}
|
|
58415
58487
|
|
|
@@ -58422,8 +58494,8 @@ var File = /*#__PURE__*/function (_Base) {
|
|
|
58422
58494
|
legacyUrls = creatorNodeGateways.map(function (gateway) {
|
|
58423
58495
|
return urlJoin__default["default"](gateway, cid.split('/')[0]);
|
|
58424
58496
|
});
|
|
58425
|
-
|
|
58426
|
-
|
|
58497
|
+
_context2.prev = 20;
|
|
58498
|
+
_context2.next = 23;
|
|
58427
58499
|
return raceRequests(legacyUrls, callback, _objectSpread2({
|
|
58428
58500
|
method: 'get',
|
|
58429
58501
|
responseType: responseType
|
|
@@ -58432,22 +58504,22 @@ var File = /*#__PURE__*/function (_Base) {
|
|
|
58432
58504
|
null);
|
|
58433
58505
|
|
|
58434
58506
|
case 23:
|
|
58435
|
-
_yield$raceRequests2 =
|
|
58507
|
+
_yield$raceRequests2 = _context2.sent;
|
|
58436
58508
|
_response = _yield$raceRequests2.response;
|
|
58437
58509
|
|
|
58438
58510
|
if (_response) {
|
|
58439
|
-
|
|
58511
|
+
_context2.next = 27;
|
|
58440
58512
|
break;
|
|
58441
58513
|
}
|
|
58442
58514
|
|
|
58443
58515
|
throw new Error("Could not fetch ".concat(cid, " via legacy method"));
|
|
58444
58516
|
|
|
58445
58517
|
case 27:
|
|
58446
|
-
return
|
|
58518
|
+
return _context2.abrupt("return", _response);
|
|
58447
58519
|
|
|
58448
58520
|
case 30:
|
|
58449
|
-
|
|
58450
|
-
|
|
58521
|
+
_context2.prev = 30;
|
|
58522
|
+
_context2.t1 = _context2["catch"](20);
|
|
58451
58523
|
throw new Error("Failed to retrieve ".concat(cid, " by legacy method"));
|
|
58452
58524
|
|
|
58453
58525
|
case 33:
|
|
@@ -58455,20 +58527,20 @@ var File = /*#__PURE__*/function (_Base) {
|
|
|
58455
58527
|
|
|
58456
58528
|
case 34:
|
|
58457
58529
|
case "end":
|
|
58458
|
-
return
|
|
58530
|
+
return _context2.stop();
|
|
58459
58531
|
}
|
|
58460
58532
|
}
|
|
58461
|
-
},
|
|
58533
|
+
}, _callee2, null, [[0, 15], [20, 30]]);
|
|
58462
58534
|
}));
|
|
58463
58535
|
|
|
58464
|
-
return function (
|
|
58536
|
+
return function (_x5) {
|
|
58465
58537
|
return _ref.apply(this, arguments);
|
|
58466
58538
|
};
|
|
58467
58539
|
}(), {
|
|
58468
58540
|
minTimeout: 500,
|
|
58469
58541
|
maxTimeout: 4000,
|
|
58470
58542
|
factor: 3,
|
|
58471
|
-
retries:
|
|
58543
|
+
retries: 3,
|
|
58472
58544
|
onRetry: function onRetry(err, i) {
|
|
58473
58545
|
// eslint-disable-next-line no-console
|
|
58474
58546
|
console.log("FetchCID attempt ".concat(i, " error: ").concat(err));
|
|
@@ -58476,21 +58548,21 @@ var File = /*#__PURE__*/function (_Base) {
|
|
|
58476
58548
|
});
|
|
58477
58549
|
|
|
58478
58550
|
case 8:
|
|
58479
|
-
return
|
|
58551
|
+
return _context3.abrupt("return", _context3.sent);
|
|
58480
58552
|
|
|
58481
58553
|
case 9:
|
|
58482
58554
|
case "end":
|
|
58483
|
-
return
|
|
58555
|
+
return _context3.stop();
|
|
58484
58556
|
}
|
|
58485
58557
|
}
|
|
58486
|
-
},
|
|
58558
|
+
}, _callee3);
|
|
58487
58559
|
}));
|
|
58488
58560
|
|
|
58489
|
-
function
|
|
58490
|
-
return
|
|
58561
|
+
function fetchCIDInternal(_x3, _x4) {
|
|
58562
|
+
return _fetchCIDInternal.apply(this, arguments);
|
|
58491
58563
|
}
|
|
58492
58564
|
|
|
58493
|
-
return
|
|
58565
|
+
return fetchCIDInternal;
|
|
58494
58566
|
}()
|
|
58495
58567
|
/**
|
|
58496
58568
|
* Fetches a file from Content Node with a given CID. Follows the same pattern
|
|
@@ -58504,12 +58576,12 @@ var File = /*#__PURE__*/function (_Base) {
|
|
|
58504
58576
|
}, {
|
|
58505
58577
|
key: "downloadCID",
|
|
58506
58578
|
value: function () {
|
|
58507
|
-
var _downloadCID = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
58579
|
+
var _downloadCID = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(cid, creatorNodeGateways, filename) {
|
|
58508
58580
|
var urls, _yield$raceRequests3, response;
|
|
58509
58581
|
|
|
58510
|
-
return regeneratorRuntime.wrap(function
|
|
58582
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
58511
58583
|
while (1) {
|
|
58512
|
-
switch (
|
|
58584
|
+
switch (_context4.prev = _context4.next) {
|
|
58513
58585
|
case 0:
|
|
58514
58586
|
urls = creatorNodeGateways.map(function (gateway) {
|
|
58515
58587
|
return urlJoin__default["default"](gateway, cid, {
|
|
@@ -58518,8 +58590,8 @@ var File = /*#__PURE__*/function (_Base) {
|
|
|
58518
58590
|
}
|
|
58519
58591
|
});
|
|
58520
58592
|
});
|
|
58521
|
-
|
|
58522
|
-
|
|
58593
|
+
_context4.prev = 1;
|
|
58594
|
+
_context4.next = 4;
|
|
58523
58595
|
return raceRequests(urls, function (url) {
|
|
58524
58596
|
return downloadURL(url, filename);
|
|
58525
58597
|
}, {
|
|
@@ -58529,24 +58601,24 @@ var File = /*#__PURE__*/function (_Base) {
|
|
|
58529
58601
|
10000);
|
|
58530
58602
|
|
|
58531
58603
|
case 4:
|
|
58532
|
-
_yield$raceRequests3 =
|
|
58604
|
+
_yield$raceRequests3 = _context4.sent;
|
|
58533
58605
|
response = _yield$raceRequests3.response;
|
|
58534
|
-
return
|
|
58606
|
+
return _context4.abrupt("return", response);
|
|
58535
58607
|
|
|
58536
58608
|
case 9:
|
|
58537
|
-
|
|
58538
|
-
|
|
58609
|
+
_context4.prev = 9;
|
|
58610
|
+
_context4.t0 = _context4["catch"](1);
|
|
58539
58611
|
throw new Error("Failed to retrieve ".concat(cid));
|
|
58540
58612
|
|
|
58541
58613
|
case 12:
|
|
58542
58614
|
case "end":
|
|
58543
|
-
return
|
|
58615
|
+
return _context4.stop();
|
|
58544
58616
|
}
|
|
58545
58617
|
}
|
|
58546
|
-
},
|
|
58618
|
+
}, _callee4, null, [[1, 9]]);
|
|
58547
58619
|
}));
|
|
58548
58620
|
|
|
58549
|
-
function downloadCID(
|
|
58621
|
+
function downloadCID(_x6, _x7, _x8) {
|
|
58550
58622
|
return _downloadCID.apply(this, arguments);
|
|
58551
58623
|
}
|
|
58552
58624
|
|
|
@@ -58562,66 +58634,66 @@ var File = /*#__PURE__*/function (_Base) {
|
|
|
58562
58634
|
}, {
|
|
58563
58635
|
key: "checkIfCidAvailable",
|
|
58564
58636
|
value: function () {
|
|
58565
|
-
var _checkIfCidAvailable = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
58637
|
+
var _checkIfCidAvailable = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(cid, creatorNodeGateways) {
|
|
58566
58638
|
var exists;
|
|
58567
|
-
return regeneratorRuntime.wrap(function
|
|
58639
|
+
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
58568
58640
|
while (1) {
|
|
58569
|
-
switch (
|
|
58641
|
+
switch (_context6.prev = _context6.next) {
|
|
58570
58642
|
case 0:
|
|
58571
58643
|
exists = {};
|
|
58572
|
-
|
|
58644
|
+
_context6.next = 3;
|
|
58573
58645
|
return Promise.all(creatorNodeGateways.map( /*#__PURE__*/function () {
|
|
58574
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
58646
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(gateway) {
|
|
58575
58647
|
var _yield$axios, status;
|
|
58576
58648
|
|
|
58577
|
-
return regeneratorRuntime.wrap(function
|
|
58649
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
58578
58650
|
while (1) {
|
|
58579
|
-
switch (
|
|
58651
|
+
switch (_context5.prev = _context5.next) {
|
|
58580
58652
|
case 0:
|
|
58581
|
-
|
|
58582
|
-
|
|
58653
|
+
_context5.prev = 0;
|
|
58654
|
+
_context5.next = 3;
|
|
58583
58655
|
return axios__default["default"]({
|
|
58584
58656
|
url: urlJoin__default["default"](gateway, cid),
|
|
58585
58657
|
method: 'head'
|
|
58586
58658
|
});
|
|
58587
58659
|
|
|
58588
58660
|
case 3:
|
|
58589
|
-
_yield$axios =
|
|
58661
|
+
_yield$axios = _context5.sent;
|
|
58590
58662
|
status = _yield$axios.status;
|
|
58591
58663
|
exists[gateway] = status === 200;
|
|
58592
|
-
|
|
58664
|
+
_context5.next = 11;
|
|
58593
58665
|
break;
|
|
58594
58666
|
|
|
58595
58667
|
case 8:
|
|
58596
|
-
|
|
58597
|
-
|
|
58668
|
+
_context5.prev = 8;
|
|
58669
|
+
_context5.t0 = _context5["catch"](0);
|
|
58598
58670
|
exists[gateway] = false;
|
|
58599
58671
|
|
|
58600
58672
|
case 11:
|
|
58601
58673
|
case "end":
|
|
58602
|
-
return
|
|
58674
|
+
return _context5.stop();
|
|
58603
58675
|
}
|
|
58604
58676
|
}
|
|
58605
|
-
},
|
|
58677
|
+
}, _callee5, null, [[0, 8]]);
|
|
58606
58678
|
}));
|
|
58607
58679
|
|
|
58608
|
-
return function (
|
|
58680
|
+
return function (_x11) {
|
|
58609
58681
|
return _ref2.apply(this, arguments);
|
|
58610
58682
|
};
|
|
58611
58683
|
}()));
|
|
58612
58684
|
|
|
58613
58685
|
case 3:
|
|
58614
|
-
return
|
|
58686
|
+
return _context6.abrupt("return", exists);
|
|
58615
58687
|
|
|
58616
58688
|
case 4:
|
|
58617
58689
|
case "end":
|
|
58618
|
-
return
|
|
58690
|
+
return _context6.stop();
|
|
58619
58691
|
}
|
|
58620
58692
|
}
|
|
58621
|
-
},
|
|
58693
|
+
}, _callee6);
|
|
58622
58694
|
}));
|
|
58623
58695
|
|
|
58624
|
-
function checkIfCidAvailable(
|
|
58696
|
+
function checkIfCidAvailable(_x9, _x10) {
|
|
58625
58697
|
return _checkIfCidAvailable.apply(this, arguments);
|
|
58626
58698
|
}
|
|
58627
58699
|
|
|
@@ -58635,40 +58707,40 @@ var File = /*#__PURE__*/function (_Base) {
|
|
|
58635
58707
|
}, {
|
|
58636
58708
|
key: "uploadImage",
|
|
58637
58709
|
value: function () {
|
|
58638
|
-
var _uploadImage = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
58710
|
+
var _uploadImage = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(file, square) {
|
|
58639
58711
|
var timeoutMs,
|
|
58640
58712
|
resp,
|
|
58641
|
-
|
|
58642
|
-
return regeneratorRuntime.wrap(function
|
|
58713
|
+
_args7 = arguments;
|
|
58714
|
+
return regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
58643
58715
|
while (1) {
|
|
58644
|
-
switch (
|
|
58716
|
+
switch (_context7.prev = _context7.next) {
|
|
58645
58717
|
case 0:
|
|
58646
|
-
timeoutMs =
|
|
58718
|
+
timeoutMs = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : null;
|
|
58647
58719
|
this.REQUIRES(Services.CREATOR_NODE);
|
|
58648
58720
|
this.FILE_IS_VALID(file); // Assign a creator_node_endpoint to the user if necessary
|
|
58649
58721
|
|
|
58650
|
-
|
|
58722
|
+
_context7.next = 5;
|
|
58651
58723
|
return this.User.assignReplicaSetIfNecessary();
|
|
58652
58724
|
|
|
58653
58725
|
case 5:
|
|
58654
|
-
|
|
58726
|
+
_context7.next = 7;
|
|
58655
58727
|
return this.creatorNode.uploadImage(file, square,
|
|
58656
58728
|
/* onProgress */
|
|
58657
58729
|
undefined, timeoutMs);
|
|
58658
58730
|
|
|
58659
58731
|
case 7:
|
|
58660
|
-
resp =
|
|
58661
|
-
return
|
|
58732
|
+
resp = _context7.sent;
|
|
58733
|
+
return _context7.abrupt("return", resp);
|
|
58662
58734
|
|
|
58663
58735
|
case 9:
|
|
58664
58736
|
case "end":
|
|
58665
|
-
return
|
|
58737
|
+
return _context7.stop();
|
|
58666
58738
|
}
|
|
58667
58739
|
}
|
|
58668
|
-
},
|
|
58740
|
+
}, _callee7, this);
|
|
58669
58741
|
}));
|
|
58670
58742
|
|
|
58671
|
-
function uploadImage(
|
|
58743
|
+
function uploadImage(_x12, _x13) {
|
|
58672
58744
|
return _uploadImage.apply(this, arguments);
|
|
58673
58745
|
}
|
|
58674
58746
|
|
|
@@ -58757,34 +58829,12 @@ var Reactions = /*#__PURE__*/function (_Base) {
|
|
|
58757
58829
|
return Reactions;
|
|
58758
58830
|
}(Base);
|
|
58759
58831
|
|
|
58760
|
-
var Action;
|
|
58761
|
-
|
|
58762
|
-
(function (Action) {
|
|
58763
|
-
Action["CREATE"] = "Create";
|
|
58764
|
-
Action["UPDATE"] = "Update";
|
|
58765
|
-
Action["DELETE"] = "Delete";
|
|
58766
|
-
Action["FOLLOW"] = "Follow";
|
|
58767
|
-
Action["UNFOLLOW"] = "Unfollow";
|
|
58768
|
-
Action["SAVE"] = "Save";
|
|
58769
|
-
Action["UNSAVE"] = "Unsave";
|
|
58770
|
-
Action["REPOST"] = "Repost";
|
|
58771
|
-
Action["UNREPOST"] = "Unrepost";
|
|
58772
|
-
})(Action || (Action = {}));
|
|
58773
|
-
|
|
58774
|
-
var EntityType;
|
|
58775
|
-
|
|
58776
|
-
(function (EntityType) {
|
|
58777
|
-
EntityType["TRACK"] = "Track";
|
|
58778
|
-
EntityType["PLAYLIST"] = "Playlist";
|
|
58779
|
-
EntityType["USER"] = "User";
|
|
58780
|
-
})(EntityType || (EntityType = {}));
|
|
58781
58832
|
/*
|
|
58782
58833
|
API surface for updated data contract interactions.
|
|
58783
58834
|
Provides simplified entity management in a generic fashion
|
|
58784
58835
|
Handles metadata + file upload etc. for entities such as Playlist/Track/User
|
|
58785
58836
|
*/
|
|
58786
58837
|
|
|
58787
|
-
|
|
58788
58838
|
var EntityManager = /*#__PURE__*/function (_Base) {
|
|
58789
58839
|
_inherits(EntityManager, _Base);
|
|
58790
58840
|
|
|
@@ -58852,6 +58902,8 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
58852
58902
|
_this.unsavePlaylist = _this.createSocialMethod(EntityType.PLAYLIST, Action.UNSAVE);
|
|
58853
58903
|
_this.repostTrack = _this.createSocialMethod(EntityType.TRACK, Action.REPOST);
|
|
58854
58904
|
_this.unrepostTrack = _this.createSocialMethod(EntityType.TRACK, Action.UNREPOST);
|
|
58905
|
+
_this.repostPlaylist = _this.createSocialMethod(EntityType.PLAYLIST, Action.REPOST);
|
|
58906
|
+
_this.unrepostPlaylist = _this.createSocialMethod(EntityType.PLAYLIST, Action.UNREPOST);
|
|
58855
58907
|
return _this;
|
|
58856
58908
|
}
|
|
58857
58909
|
|
|
@@ -59817,7 +59869,7 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
59817
59869
|
this.Account = _construct(Account, [this.User].concat(services));
|
|
59818
59870
|
this.Track = _construct(Track, services);
|
|
59819
59871
|
this.Playlist = _construct(Playlists, services);
|
|
59820
|
-
this.File = _construct(File, [this.User].concat(services));
|
|
59872
|
+
this.File = _construct(File, [this.User, this.ServiceProvider].concat(services));
|
|
59821
59873
|
this.Rewards = _construct(Rewards, [this.ServiceProvider].concat(services));
|
|
59822
59874
|
this.Reactions = _construct(Reactions, services);
|
|
59823
59875
|
this.EntityManager = _construct(EntityManager, services);
|