@audius/sdk 0.0.37 → 0.0.38
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/entityManager.d.ts +30 -55
- package/dist/index.cjs.js +151 -544
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +151 -544
- package/dist/index.esm.js.map +1 -1
- package/dist/legacy.js +151 -544
- package/dist/legacy.js.map +1 -1
- package/dist/native-libs.js +2 -2
- package/dist/sdk/api/generated/default/models/Track.d.ts +6 -0
- package/dist/sdk/api/generated/full/models/TrackFull.d.ts +6 -0
- package/package.json +2 -2
- package/src/api/entityManager.ts +54 -349
- package/src/sdk/api/generated/default/models/Track.ts +6 -0
- package/src/sdk/api/generated/full/models/TrackFull.ts +6 -0
package/dist/legacy.js
CHANGED
|
@@ -33455,9 +33455,9 @@ var formatProviders = function formatProviders(providers) {
|
|
|
33455
33455
|
};
|
|
33456
33456
|
|
|
33457
33457
|
var name = "@audius/sdk";
|
|
33458
|
-
var version = "0.0.
|
|
33458
|
+
var version = "0.0.38";
|
|
33459
33459
|
var audius = {
|
|
33460
|
-
releaseSHA: "
|
|
33460
|
+
releaseSHA: "74503074cb96dea181ec2b218c5cb6d528c1db86"
|
|
33461
33461
|
};
|
|
33462
33462
|
var description = "";
|
|
33463
33463
|
var main = "dist/index.cjs.js";
|
|
@@ -37069,7 +37069,7 @@ var Base = /*#__PURE__*/function () {
|
|
|
37069
37069
|
return Base;
|
|
37070
37070
|
}();
|
|
37071
37071
|
|
|
37072
|
-
var decodeHashId$
|
|
37072
|
+
var decodeHashId$1 = Utils.decodeHashId;
|
|
37073
37073
|
var GetAttestationError = Object.freeze({
|
|
37074
37074
|
CHALLENGE_INCOMPLETE: 'CHALLENGE_INCOMPLETE',
|
|
37075
37075
|
ALREADY_DISBURSED: 'ALREADY_DISBURSED',
|
|
@@ -37154,7 +37154,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
|
|
|
37154
37154
|
|
|
37155
37155
|
case 7:
|
|
37156
37156
|
// Aggregate
|
|
37157
|
-
logger.info("submitAndEvaluate: aggregating attestations for userId [".concat(decodeHashId$
|
|
37157
|
+
logger.info("submitAndEvaluate: aggregating attestations for userId [".concat(decodeHashId$1(encodedUserId), "], challengeId [").concat(challengeId, "]"));
|
|
37158
37158
|
phase = AttestationPhases.AGGREGATE_ATTESTATIONS;
|
|
37159
37159
|
_context.next = 11;
|
|
37160
37160
|
return this.aggregateAttestations({
|
|
@@ -37190,7 +37190,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
|
|
|
37190
37190
|
|
|
37191
37191
|
case 21:
|
|
37192
37192
|
// Submit
|
|
37193
|
-
logger.info("submitAndEvaluate: submitting for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$
|
|
37193
|
+
logger.info("submitAndEvaluate: submitting for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$1(encodedUserId), "] with [").concat(discoveryNodeAttestations === null || discoveryNodeAttestations === void 0 ? void 0 : discoveryNodeAttestations.length, "] DN and [").concat(aaoAttestation ? 1 : 0, "] oracle attestations."));
|
|
37194
37194
|
fullTokenAmount = new BN__default["default"](amount * WRAPPED_AUDIO_PRECISION);
|
|
37195
37195
|
phase = AttestationPhases.SUBMIT_ATTESTATIONS; // @ts-expect-error the return types are a bit strange here
|
|
37196
37196
|
|
|
@@ -37228,7 +37228,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
|
|
|
37228
37228
|
break;
|
|
37229
37229
|
}
|
|
37230
37230
|
|
|
37231
|
-
logger.warn("submitAndEvaluate: saw repeat senders for userId [".concat(decodeHashId$
|
|
37231
|
+
logger.warn("submitAndEvaluate: saw repeat senders for userId [".concat(decodeHashId$1(encodedUserId), "] challengeId: [").concat(challengeId, "] with err: ").concat(submitErrorCode, ", breaking up into individual transactions"));
|
|
37232
37232
|
_context.next = 35;
|
|
37233
37233
|
return this.solanaWeb3Manager.submitChallengeAttestations({
|
|
37234
37234
|
attestations: discoveryNodeAttestations,
|
|
@@ -37251,7 +37251,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
|
|
|
37251
37251
|
|
|
37252
37252
|
case 38:
|
|
37253
37253
|
// Evaluate
|
|
37254
|
-
logger.info("submitAndEvaluate: evaluating for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$
|
|
37254
|
+
logger.info("submitAndEvaluate: evaluating for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$1(encodedUserId), "]"));
|
|
37255
37255
|
phase = AttestationPhases.EVALUATE_ATTESTATIONS;
|
|
37256
37256
|
_context.next = 42;
|
|
37257
37257
|
return this.solanaWeb3Manager.evaluateChallengeAttestations({
|
|
@@ -37290,7 +37290,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
|
|
|
37290
37290
|
_context.t0 = _context["catch"](3);
|
|
37291
37291
|
err = _context.t0.message;
|
|
37292
37292
|
log = err === GetAttestationError.COGNITO_FLOW || err === GetAttestationError.HCAPTCHA ? logger.info : logger.error;
|
|
37293
|
-
log("submitAndEvaluate: failed for userId: [".concat(decodeHashId$
|
|
37293
|
+
log("submitAndEvaluate: failed for userId: [".concat(decodeHashId$1(encodedUserId), "] challenge-id [").concat(challengeId, "] at phase [").concat(phase, "] with err: ").concat(err));
|
|
37294
37294
|
return _context.abrupt("return", {
|
|
37295
37295
|
success: false,
|
|
37296
37296
|
error: err,
|
|
@@ -37405,7 +37405,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
|
|
|
37405
37405
|
_context2.prev = 25;
|
|
37406
37406
|
_context2.t0 = _context2["catch"](13);
|
|
37407
37407
|
err = _context2.t0.message;
|
|
37408
|
-
logger.error("Failed to aggregate attestations for user [".concat(decodeHashId$
|
|
37408
|
+
logger.error("Failed to aggregate attestations for user [".concat(decodeHashId$1(encodedUserId), "], challenge-id: [").concat(challengeId, "] with err: ").concat(err));
|
|
37409
37409
|
return _context2.abrupt("return", {
|
|
37410
37410
|
discoveryNodeAttestations: null,
|
|
37411
37411
|
aaoAttestation: null,
|
|
@@ -37468,7 +37468,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
|
|
|
37468
37468
|
_context2.prev = 43;
|
|
37469
37469
|
_context2.t1 = _context2["catch"](30);
|
|
37470
37470
|
_err = _context2.t1.message;
|
|
37471
|
-
logger.error("Failed to aggregate attestations for user [".concat(decodeHashId$
|
|
37471
|
+
logger.error("Failed to aggregate attestations for user [".concat(decodeHashId$1(encodedUserId), "], challenge-id: [").concat(challengeId, "] with err: ").concat(_err));
|
|
37472
37472
|
return _context2.abrupt("return", {
|
|
37473
37473
|
discoveryNodeAttestations: null,
|
|
37474
37474
|
aaoAttestation: null,
|
|
@@ -37526,7 +37526,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
|
|
|
37526
37526
|
_context3.prev = 10;
|
|
37527
37527
|
_context3.t0 = _context3["catch"](2);
|
|
37528
37528
|
err = _context3.t0.message;
|
|
37529
|
-
logger.error("Failed to get challenge attestation for userId [".concat(decodeHashId$
|
|
37529
|
+
logger.error("Failed to get challenge attestation for userId [".concat(decodeHashId$1(encodedUserId), "] challengeId [").concat(challengeId, "]from ").concat(discoveryProviderEndpoint, " with ").concat(err));
|
|
37530
37530
|
mappedErr = GetAttestationError[err] || GetAttestationError.DISCOVERY_NODE_UNKNOWN_RESPONSE;
|
|
37531
37531
|
return _context3.abrupt("return", {
|
|
37532
37532
|
success: null,
|
|
@@ -37799,9 +37799,9 @@ var Rewards = /*#__PURE__*/function (_Base) {
|
|
|
37799
37799
|
|
|
37800
37800
|
case 16:
|
|
37801
37801
|
if (needsAttestations.length || unrecoverableError) {
|
|
37802
|
-
logger.info("Failed to aggregate attestations for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$
|
|
37802
|
+
logger.info("Failed to aggregate attestations for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$1(encodedUserId), "]"));
|
|
37803
37803
|
} else {
|
|
37804
|
-
logger.info("Successfully aggregated attestations for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$
|
|
37804
|
+
logger.info("Successfully aggregated attestations for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$1(encodedUserId), "]"));
|
|
37805
37805
|
}
|
|
37806
37806
|
|
|
37807
37807
|
return _context7.abrupt("return", completedAttestations);
|
|
@@ -38026,7 +38026,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
|
|
|
38026
38026
|
return Rewards;
|
|
38027
38027
|
}(Base);
|
|
38028
38028
|
|
|
38029
|
-
var decodeHashId
|
|
38029
|
+
var decodeHashId = Utils.decodeHashId; // `BaseRewardsReporter` is intended to be subclassed, and provides
|
|
38030
38030
|
// "reporting" functionality to RewardsAttester (i.e. posts to Slack if something notable happens)
|
|
38031
38031
|
|
|
38032
38032
|
var BaseRewardsReporter = /*#__PURE__*/function () {
|
|
@@ -39030,7 +39030,7 @@ var RewardsAttester = /*#__PURE__*/function () {
|
|
|
39030
39030
|
switch (_context17.prev = _context17.next) {
|
|
39031
39031
|
case 0:
|
|
39032
39032
|
challengeId = _ref9.challengeId, userId = _ref9.userId, specifier = _ref9.specifier, amount = _ref9.amount, handle = _ref9.handle, wallet = _ref9.wallet, completedBlocknumber = _ref9.completedBlocknumber;
|
|
39033
|
-
this.logger.info("Attempting to attest for userId [".concat(decodeHashId
|
|
39033
|
+
this.logger.info("Attempting to attest for userId [".concat(decodeHashId(userId), "], challengeId: [").concat(challengeId, "], quorum size: [").concat(this.quorumSize, "]}"));
|
|
39034
39034
|
_context17.next = 4;
|
|
39035
39035
|
return this.libs.Rewards.submitAndEvaluate({
|
|
39036
39036
|
challengeId: challengeId,
|
|
@@ -39061,7 +39061,7 @@ var RewardsAttester = /*#__PURE__*/function () {
|
|
|
39061
39061
|
break;
|
|
39062
39062
|
}
|
|
39063
39063
|
|
|
39064
|
-
this.logger.info("Successfully attestested for challenge [".concat(challengeId, "] for user [").concat(decodeHashId
|
|
39064
|
+
this.logger.info("Successfully attestested for challenge [".concat(challengeId, "] for user [").concat(decodeHashId(userId), "], amount [").concat(amount, "]!"));
|
|
39065
39065
|
return _context17.abrupt("return", {
|
|
39066
39066
|
challengeId: challengeId,
|
|
39067
39067
|
userId: userId,
|
|
@@ -39075,7 +39075,7 @@ var RewardsAttester = /*#__PURE__*/function () {
|
|
|
39075
39075
|
|
|
39076
39076
|
case 13:
|
|
39077
39077
|
// Handle error path
|
|
39078
|
-
this.logger.error("Failed to attest for challenge [".concat(challengeId, "] for user [").concat(decodeHashId
|
|
39078
|
+
this.logger.error("Failed to attest for challenge [".concat(challengeId, "] for user [").concat(decodeHashId(userId), "], amount [").concat(amount, "], oracle: [").concat(this.aaoAddress, "] at phase: [").concat(phase, "] with error [").concat(error, "]"));
|
|
39079
39079
|
return _context17.abrupt("return", {
|
|
39080
39080
|
challengeId: challengeId,
|
|
39081
39081
|
userId: userId,
|
|
@@ -39333,7 +39333,7 @@ var RewardsAttester = /*#__PURE__*/function () {
|
|
|
39333
39333
|
successful.push(res);
|
|
39334
39334
|
|
|
39335
39335
|
_this5.reporter.reportSuccess({
|
|
39336
|
-
userId: (_decodeHashId = decodeHashId
|
|
39336
|
+
userId: (_decodeHashId = decodeHashId(res.userId)) !== null && _decodeHashId !== void 0 ? _decodeHashId : -1,
|
|
39337
39337
|
challengeId: res.challengeId,
|
|
39338
39338
|
amount: res.amount,
|
|
39339
39339
|
specifier: res.specifier
|
|
@@ -39354,7 +39354,7 @@ var RewardsAttester = /*#__PURE__*/function () {
|
|
|
39354
39354
|
var _decodeHashId2;
|
|
39355
39355
|
|
|
39356
39356
|
var report = {
|
|
39357
|
-
userId: (_decodeHashId2 = decodeHashId
|
|
39357
|
+
userId: (_decodeHashId2 = decodeHashId(res.userId)) !== null && _decodeHashId2 !== void 0 ? _decodeHashId2 : -1,
|
|
39358
39358
|
challengeId: res.challengeId,
|
|
39359
39359
|
amount: res.amount,
|
|
39360
39360
|
error: res.error,
|
|
@@ -57125,15 +57125,13 @@ var EntityType;
|
|
|
57125
57125
|
(function (EntityType) {
|
|
57126
57126
|
EntityType["PLAYLIST"] = "Playlist";
|
|
57127
57127
|
})(EntityType || (EntityType = {}));
|
|
57128
|
-
|
|
57129
|
-
var encodeHashId = Utils.encodeHashId,
|
|
57130
|
-
decodeHashId = Utils.decodeHashId;
|
|
57131
57128
|
/*
|
|
57132
57129
|
API surface for updated data contract interactions.
|
|
57133
57130
|
Provides simplified entity management in a generic fashion
|
|
57134
57131
|
Handles metadata + file upload etc. for entities such as Playlist/Track/User
|
|
57135
57132
|
*/
|
|
57136
57133
|
|
|
57134
|
+
|
|
57137
57135
|
var EntityManager = /*#__PURE__*/function (_Base) {
|
|
57138
57136
|
_inherits(EntityManager, _Base);
|
|
57139
57137
|
|
|
@@ -57157,46 +57155,15 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
57157
57155
|
return Math.floor(Math.random() * (max - min) + min);
|
|
57158
57156
|
}
|
|
57159
57157
|
}, {
|
|
57160
|
-
key: "
|
|
57161
|
-
value: function () {
|
|
57162
|
-
var _getFullPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(playlistId, userId) {
|
|
57163
|
-
var encodedPlaylistId, encodedUserId, playlist;
|
|
57164
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
57165
|
-
while (1) {
|
|
57166
|
-
switch (_context.prev = _context.next) {
|
|
57167
|
-
case 0:
|
|
57168
|
-
encodedPlaylistId = encodeHashId(playlistId);
|
|
57169
|
-
encodedUserId = encodeHashId(userId);
|
|
57170
|
-
_context.next = 4;
|
|
57171
|
-
return this.discoveryProvider.getFullPlaylist(encodedPlaylistId, encodedUserId);
|
|
57172
|
-
|
|
57173
|
-
case 4:
|
|
57174
|
-
playlist = _context.sent[0];
|
|
57175
|
-
return _context.abrupt("return", playlist);
|
|
57176
|
-
|
|
57177
|
-
case 6:
|
|
57178
|
-
case "end":
|
|
57179
|
-
return _context.stop();
|
|
57180
|
-
}
|
|
57181
|
-
}
|
|
57182
|
-
}, _callee, this);
|
|
57183
|
-
}));
|
|
57184
|
-
|
|
57185
|
-
function getFullPlaylist(_x, _x2) {
|
|
57186
|
-
return _getFullPlaylist.apply(this, arguments);
|
|
57187
|
-
}
|
|
57188
|
-
|
|
57189
|
-
return getFullPlaylist;
|
|
57190
|
-
}()
|
|
57191
|
-
}, {
|
|
57192
|
-
key: "mapAddedTimestamps",
|
|
57193
|
-
value: function mapAddedTimestamps(addedTimestamps) {
|
|
57158
|
+
key: "mapTimestamps",
|
|
57159
|
+
value: function mapTimestamps(addedTimestamps) {
|
|
57194
57160
|
var trackIds = addedTimestamps.map(function (trackObj) {
|
|
57195
57161
|
var _trackObj$metadata_ti;
|
|
57196
57162
|
|
|
57197
57163
|
return {
|
|
57198
|
-
track:
|
|
57199
|
-
time: (_trackObj$metadata_ti = trackObj.
|
|
57164
|
+
track: trackObj.track,
|
|
57165
|
+
time: (_trackObj$metadata_ti = trackObj.metadata_time) !== null && _trackObj$metadata_ti !== void 0 ? _trackObj$metadata_ti : trackObj.time // default to time for legacy playlists
|
|
57166
|
+
|
|
57200
57167
|
};
|
|
57201
57168
|
});
|
|
57202
57169
|
return trackIds;
|
|
@@ -57211,7 +57178,6 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
57211
57178
|
return {
|
|
57212
57179
|
blockHash: null,
|
|
57213
57180
|
blockNumber: null,
|
|
57214
|
-
playlistId: null,
|
|
57215
57181
|
error: null
|
|
57216
57182
|
};
|
|
57217
57183
|
}
|
|
@@ -57222,113 +57188,94 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
57222
57188
|
}, {
|
|
57223
57189
|
key: "createPlaylist",
|
|
57224
57190
|
value: function () {
|
|
57225
|
-
var _createPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
57226
|
-
var
|
|
57191
|
+
var _createPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(playlist) {
|
|
57192
|
+
var responseValues, _playlist$artwork, _dirCID, userId, createAction, entityType, dirCID, updatedPlaylistImage, tracks, metadata, _yield$this$creatorNo, metadataMultihash, manageEntityResponse, txReceipt, error;
|
|
57227
57193
|
|
|
57228
|
-
return regeneratorRuntime.wrap(function
|
|
57194
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
57229
57195
|
while (1) {
|
|
57230
|
-
switch (
|
|
57196
|
+
switch (_context.prev = _context.next) {
|
|
57231
57197
|
case 0:
|
|
57232
|
-
playlistId = _ref.playlistId, playlistName = _ref.playlistName, trackIds = _ref.trackIds, description = _ref.description, isAlbum = _ref.isAlbum, isPrivate = _ref.isPrivate, coverArt = _ref.coverArt, coverArtSizes = _ref.coverArtSizes;
|
|
57233
57198
|
responseValues = this.getDefaultPlaylistReponseValues();
|
|
57234
|
-
|
|
57235
|
-
|
|
57199
|
+
_context.prev = 1;
|
|
57200
|
+
userId = this.userStateManager.getCurrentUserId();
|
|
57236
57201
|
|
|
57237
|
-
if (
|
|
57238
|
-
|
|
57202
|
+
if (userId) {
|
|
57203
|
+
_context.next = 6;
|
|
57239
57204
|
break;
|
|
57240
57205
|
}
|
|
57241
57206
|
|
|
57242
57207
|
responseValues.error = 'Missing current user ID';
|
|
57243
|
-
return
|
|
57208
|
+
return _context.abrupt("return", responseValues);
|
|
57244
57209
|
|
|
57245
|
-
case
|
|
57246
|
-
userId = parseInt(currentUserId);
|
|
57210
|
+
case 6:
|
|
57247
57211
|
createAction = Action.CREATE;
|
|
57248
57212
|
entityType = EntityType.PLAYLIST;
|
|
57249
57213
|
this.REQUIRES(Services.CREATOR_NODE);
|
|
57250
57214
|
|
|
57251
|
-
if (!
|
|
57252
|
-
|
|
57215
|
+
if (!(playlist !== null && playlist !== void 0 && (_playlist$artwork = playlist.artwork) !== null && _playlist$artwork !== void 0 && _playlist$artwork.file)) {
|
|
57216
|
+
_context.next = 14;
|
|
57253
57217
|
break;
|
|
57254
57218
|
}
|
|
57255
57219
|
|
|
57256
|
-
|
|
57257
|
-
return this.creatorNode.uploadImage(
|
|
57220
|
+
_context.next = 12;
|
|
57221
|
+
return this.creatorNode.uploadImage(playlist.artwork.file, true // square
|
|
57258
57222
|
);
|
|
57259
57223
|
|
|
57260
|
-
case
|
|
57261
|
-
updatedPlaylistImage =
|
|
57224
|
+
case 12:
|
|
57225
|
+
updatedPlaylistImage = _context.sent;
|
|
57262
57226
|
dirCID = updatedPlaylistImage.dirCID;
|
|
57263
57227
|
|
|
57264
|
-
case
|
|
57265
|
-
|
|
57266
|
-
_context2.next = 19;
|
|
57267
|
-
return web3.eth.getBlockNumber();
|
|
57268
|
-
|
|
57269
|
-
case 19:
|
|
57270
|
-
currentBlockNumber = _context2.sent;
|
|
57271
|
-
_context2.next = 22;
|
|
57272
|
-
return web3.eth.getBlock(currentBlockNumber);
|
|
57273
|
-
|
|
57274
|
-
case 22:
|
|
57275
|
-
currentBlock = _context2.sent;
|
|
57276
|
-
tracks = trackIds.map(function (trackId) {
|
|
57277
|
-
return {
|
|
57278
|
-
track: trackId,
|
|
57279
|
-
time: currentBlock.timestamp
|
|
57280
|
-
};
|
|
57281
|
-
});
|
|
57228
|
+
case 14:
|
|
57229
|
+
tracks = this.mapTimestamps(playlist.playlist_contents.track_ids);
|
|
57282
57230
|
metadata = {
|
|
57283
|
-
playlist_id:
|
|
57231
|
+
playlist_id: playlist.playlist_id,
|
|
57284
57232
|
playlist_contents: {
|
|
57285
57233
|
track_ids: tracks
|
|
57286
57234
|
},
|
|
57287
|
-
playlist_name:
|
|
57288
|
-
playlist_image_sizes_multihash: (_dirCID = dirCID) !== null && _dirCID !== void 0 ? _dirCID :
|
|
57289
|
-
description: description,
|
|
57290
|
-
is_album:
|
|
57291
|
-
is_private:
|
|
57235
|
+
playlist_name: playlist.playlist_name,
|
|
57236
|
+
playlist_image_sizes_multihash: (_dirCID = dirCID) !== null && _dirCID !== void 0 ? _dirCID : playlist.cover_art_sizes,
|
|
57237
|
+
description: playlist.description,
|
|
57238
|
+
is_album: playlist.is_album,
|
|
57239
|
+
is_private: playlist.is_private
|
|
57292
57240
|
};
|
|
57293
|
-
|
|
57241
|
+
_context.next = 18;
|
|
57294
57242
|
return this.creatorNode.uploadPlaylistMetadata(metadata);
|
|
57295
57243
|
|
|
57296
|
-
case
|
|
57297
|
-
_yield$this$creatorNo =
|
|
57244
|
+
case 18:
|
|
57245
|
+
_yield$this$creatorNo = _context.sent;
|
|
57298
57246
|
metadataMultihash = _yield$this$creatorNo.metadataMultihash;
|
|
57299
|
-
|
|
57247
|
+
_context.next = 22;
|
|
57300
57248
|
return this.manageEntity({
|
|
57301
57249
|
userId: userId,
|
|
57302
57250
|
entityType: entityType,
|
|
57303
|
-
entityId:
|
|
57251
|
+
entityId: playlist.playlist_id,
|
|
57304
57252
|
action: createAction,
|
|
57305
57253
|
metadataMultihash: metadataMultihash
|
|
57306
57254
|
});
|
|
57307
57255
|
|
|
57308
|
-
case
|
|
57309
|
-
manageEntityResponse =
|
|
57256
|
+
case 22:
|
|
57257
|
+
manageEntityResponse = _context.sent;
|
|
57310
57258
|
txReceipt = manageEntityResponse.txReceipt;
|
|
57311
57259
|
responseValues.blockHash = txReceipt.blockHash;
|
|
57312
57260
|
responseValues.blockNumber = txReceipt.blockNumber;
|
|
57313
|
-
|
|
57314
|
-
return _context2.abrupt("return", responseValues);
|
|
57261
|
+
return _context.abrupt("return", responseValues);
|
|
57315
57262
|
|
|
57316
|
-
case
|
|
57317
|
-
|
|
57318
|
-
|
|
57319
|
-
error =
|
|
57263
|
+
case 29:
|
|
57264
|
+
_context.prev = 29;
|
|
57265
|
+
_context.t0 = _context["catch"](1);
|
|
57266
|
+
error = _context.t0.message;
|
|
57320
57267
|
responseValues.error = error;
|
|
57321
|
-
return
|
|
57268
|
+
return _context.abrupt("return", responseValues);
|
|
57322
57269
|
|
|
57323
|
-
case
|
|
57270
|
+
case 34:
|
|
57324
57271
|
case "end":
|
|
57325
|
-
return
|
|
57272
|
+
return _context.stop();
|
|
57326
57273
|
}
|
|
57327
57274
|
}
|
|
57328
|
-
},
|
|
57275
|
+
}, _callee, this, [[1, 29]]);
|
|
57329
57276
|
}));
|
|
57330
57277
|
|
|
57331
|
-
function createPlaylist(
|
|
57278
|
+
function createPlaylist(_x) {
|
|
57332
57279
|
return _createPlaylist.apply(this, arguments);
|
|
57333
57280
|
}
|
|
57334
57281
|
|
|
@@ -57341,29 +57288,26 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
57341
57288
|
}, {
|
|
57342
57289
|
key: "deletePlaylist",
|
|
57343
57290
|
value: function () {
|
|
57344
|
-
var _deletePlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
57345
|
-
var
|
|
57346
|
-
|
|
57347
|
-
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
57291
|
+
var _deletePlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(playlistId) {
|
|
57292
|
+
var responseValues, userId, resp, txReceipt, error;
|
|
57293
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
57348
57294
|
while (1) {
|
|
57349
|
-
switch (
|
|
57295
|
+
switch (_context2.prev = _context2.next) {
|
|
57350
57296
|
case 0:
|
|
57351
|
-
playlistId = _ref2.playlistId;
|
|
57352
57297
|
responseValues = this.getDefaultPlaylistReponseValues();
|
|
57353
|
-
|
|
57298
|
+
userId = this.userStateManager.getCurrentUserId();
|
|
57354
57299
|
|
|
57355
|
-
if (
|
|
57356
|
-
|
|
57300
|
+
if (userId) {
|
|
57301
|
+
_context2.next = 5;
|
|
57357
57302
|
break;
|
|
57358
57303
|
}
|
|
57359
57304
|
|
|
57360
57305
|
responseValues.error = 'Missing current user ID';
|
|
57361
|
-
return
|
|
57306
|
+
return _context2.abrupt("return", responseValues);
|
|
57362
57307
|
|
|
57363
|
-
case
|
|
57364
|
-
|
|
57365
|
-
|
|
57366
|
-
_context3.next = 10;
|
|
57308
|
+
case 5:
|
|
57309
|
+
_context2.prev = 5;
|
|
57310
|
+
_context2.next = 8;
|
|
57367
57311
|
return this.manageEntity({
|
|
57368
57312
|
userId: userId,
|
|
57369
57313
|
entityType: EntityType.PLAYLIST,
|
|
@@ -57372,30 +57316,29 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
57372
57316
|
metadataMultihash: ''
|
|
57373
57317
|
});
|
|
57374
57318
|
|
|
57375
|
-
case
|
|
57376
|
-
resp =
|
|
57319
|
+
case 8:
|
|
57320
|
+
resp = _context2.sent;
|
|
57377
57321
|
txReceipt = resp.txReceipt;
|
|
57378
57322
|
responseValues.blockHash = txReceipt.blockHash;
|
|
57379
57323
|
responseValues.blockNumber = txReceipt.blockNumber;
|
|
57380
|
-
|
|
57381
|
-
return _context3.abrupt("return", responseValues);
|
|
57324
|
+
return _context2.abrupt("return", responseValues);
|
|
57382
57325
|
|
|
57383
|
-
case
|
|
57384
|
-
|
|
57385
|
-
|
|
57386
|
-
error =
|
|
57326
|
+
case 15:
|
|
57327
|
+
_context2.prev = 15;
|
|
57328
|
+
_context2.t0 = _context2["catch"](5);
|
|
57329
|
+
error = _context2.t0.message;
|
|
57387
57330
|
responseValues.error = error;
|
|
57388
|
-
return
|
|
57331
|
+
return _context2.abrupt("return", responseValues);
|
|
57389
57332
|
|
|
57390
|
-
case
|
|
57333
|
+
case 20:
|
|
57391
57334
|
case "end":
|
|
57392
|
-
return
|
|
57335
|
+
return _context2.stop();
|
|
57393
57336
|
}
|
|
57394
57337
|
}
|
|
57395
|
-
},
|
|
57338
|
+
}, _callee2, this, [[5, 15]]);
|
|
57396
57339
|
}));
|
|
57397
57340
|
|
|
57398
|
-
function deletePlaylist(
|
|
57341
|
+
function deletePlaylist(_x2) {
|
|
57399
57342
|
return _deletePlaylist.apply(this, arguments);
|
|
57400
57343
|
}
|
|
57401
57344
|
|
|
@@ -57403,448 +57346,112 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
57403
57346
|
}()
|
|
57404
57347
|
/**
|
|
57405
57348
|
* Update a playlist using updated data contracts flow
|
|
57406
|
-
|
|
57349
|
+
*/
|
|
57407
57350
|
|
|
57408
57351
|
}, {
|
|
57409
|
-
key: "
|
|
57352
|
+
key: "updatePlaylist",
|
|
57410
57353
|
value: function () {
|
|
57411
|
-
var
|
|
57412
|
-
var
|
|
57354
|
+
var _updatePlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(playlist) {
|
|
57355
|
+
var responseValues, _playlist$artwork2, _dirCID2, userId, updateAction, entityType, dirCID, updatedPlaylistImage, trackIds, metadata, _yield$this$creatorNo2, metadataMultihash, resp, txReceipt, error;
|
|
57413
57356
|
|
|
57414
|
-
return regeneratorRuntime.wrap(function
|
|
57357
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
57415
57358
|
while (1) {
|
|
57416
|
-
switch (
|
|
57359
|
+
switch (_context3.prev = _context3.next) {
|
|
57417
57360
|
case 0:
|
|
57418
|
-
playlistId = _ref3.playlistId, playlistName = _ref3.playlistName, description = _ref3.description, isAlbum = _ref3.isAlbum, isPrivate = _ref3.isPrivate, coverArt = _ref3.coverArt;
|
|
57419
57361
|
responseValues = this.getDefaultPlaylistReponseValues();
|
|
57420
|
-
|
|
57421
|
-
|
|
57362
|
+
_context3.prev = 1;
|
|
57363
|
+
userId = this.userStateManager.getCurrentUserId();
|
|
57422
57364
|
|
|
57423
|
-
if (!(!
|
|
57424
|
-
|
|
57365
|
+
if (!(!playlist || playlist === undefined)) {
|
|
57366
|
+
_context3.next = 6;
|
|
57425
57367
|
break;
|
|
57426
57368
|
}
|
|
57427
57369
|
|
|
57428
|
-
responseValues.error = 'Missing current
|
|
57429
|
-
return
|
|
57370
|
+
responseValues.error = 'Missing current playlist';
|
|
57371
|
+
return _context3.abrupt("return", responseValues);
|
|
57430
57372
|
|
|
57431
|
-
case
|
|
57432
|
-
if (
|
|
57433
|
-
|
|
57373
|
+
case 6:
|
|
57374
|
+
if (userId) {
|
|
57375
|
+
_context3.next = 9;
|
|
57434
57376
|
break;
|
|
57435
57377
|
}
|
|
57436
57378
|
|
|
57437
57379
|
responseValues.error = 'Missing current user ID';
|
|
57438
|
-
return
|
|
57380
|
+
return _context3.abrupt("return", responseValues);
|
|
57439
57381
|
|
|
57440
|
-
case
|
|
57441
|
-
userId = parseInt(currentUserId);
|
|
57382
|
+
case 9:
|
|
57442
57383
|
updateAction = Action.UPDATE;
|
|
57443
57384
|
entityType = EntityType.PLAYLIST;
|
|
57444
57385
|
this.REQUIRES(Services.CREATOR_NODE);
|
|
57445
57386
|
|
|
57446
|
-
if (!
|
|
57447
|
-
|
|
57387
|
+
if (!(playlist !== null && playlist !== void 0 && (_playlist$artwork2 = playlist.artwork) !== null && _playlist$artwork2 !== void 0 && _playlist$artwork2.file)) {
|
|
57388
|
+
_context3.next = 17;
|
|
57448
57389
|
break;
|
|
57449
57390
|
}
|
|
57450
57391
|
|
|
57451
|
-
|
|
57452
|
-
return this.creatorNode.uploadImage(
|
|
57392
|
+
_context3.next = 15;
|
|
57393
|
+
return this.creatorNode.uploadImage(playlist.artwork.file, true // square
|
|
57453
57394
|
);
|
|
57454
57395
|
|
|
57455
|
-
case
|
|
57456
|
-
updatedPlaylistImage =
|
|
57396
|
+
case 15:
|
|
57397
|
+
updatedPlaylistImage = _context3.sent;
|
|
57457
57398
|
dirCID = updatedPlaylistImage.dirCID;
|
|
57458
57399
|
|
|
57459
|
-
case
|
|
57460
|
-
|
|
57461
|
-
return this.getFullPlaylist(playlistId, userId);
|
|
57462
|
-
|
|
57463
|
-
case 21:
|
|
57464
|
-
playlist = _context4.sent;
|
|
57465
|
-
existingPlaylistTracks = this.mapAddedTimestamps(playlist.added_timestamps);
|
|
57466
|
-
metadata = {
|
|
57467
|
-
playlist_id: playlistId,
|
|
57468
|
-
playlist_contents: {
|
|
57469
|
-
track_ids: existingPlaylistTracks
|
|
57470
|
-
},
|
|
57471
|
-
playlist_name: playlistName !== null && playlistName !== void 0 ? playlistName : playlist.playlist_name,
|
|
57472
|
-
playlist_image_sizes_multihash: (_dirCID2 = dirCID) !== null && _dirCID2 !== void 0 ? _dirCID2 : playlist.cover_art,
|
|
57473
|
-
description: description !== null && description !== void 0 ? description : playlist.description,
|
|
57474
|
-
is_album: isAlbum !== null && isAlbum !== void 0 ? isAlbum : playlist.is_album,
|
|
57475
|
-
is_private: isPrivate !== null && isPrivate !== void 0 ? isPrivate : playlist.is_private
|
|
57476
|
-
};
|
|
57477
|
-
_context4.next = 26;
|
|
57478
|
-
return this.creatorNode.uploadPlaylistMetadata(metadata);
|
|
57479
|
-
|
|
57480
|
-
case 26:
|
|
57481
|
-
_yield$this$creatorNo2 = _context4.sent;
|
|
57482
|
-
metadataMultihash = _yield$this$creatorNo2.metadataMultihash;
|
|
57483
|
-
_context4.next = 30;
|
|
57484
|
-
return this.manageEntity({
|
|
57485
|
-
userId: userId,
|
|
57486
|
-
entityType: entityType,
|
|
57487
|
-
entityId: playlistId,
|
|
57488
|
-
action: updateAction,
|
|
57489
|
-
metadataMultihash: metadataMultihash
|
|
57490
|
-
});
|
|
57491
|
-
|
|
57492
|
-
case 30:
|
|
57493
|
-
resp = _context4.sent;
|
|
57494
|
-
txReceipt = resp.txReceipt;
|
|
57495
|
-
responseValues.blockHash = txReceipt.blockHash;
|
|
57496
|
-
responseValues.blockNumber = txReceipt.blockNumber;
|
|
57497
|
-
responseValues.playlistId = playlistId;
|
|
57498
|
-
return _context4.abrupt("return", responseValues);
|
|
57499
|
-
|
|
57500
|
-
case 38:
|
|
57501
|
-
_context4.prev = 38;
|
|
57502
|
-
_context4.t0 = _context4["catch"](2);
|
|
57503
|
-
error = _context4.t0.message;
|
|
57504
|
-
responseValues.error = error;
|
|
57505
|
-
return _context4.abrupt("return", responseValues);
|
|
57506
|
-
|
|
57507
|
-
case 43:
|
|
57508
|
-
case "end":
|
|
57509
|
-
return _context4.stop();
|
|
57510
|
-
}
|
|
57511
|
-
}
|
|
57512
|
-
}, _callee4, this, [[2, 38]]);
|
|
57513
|
-
}));
|
|
57514
|
-
|
|
57515
|
-
function editPlaylist(_x5) {
|
|
57516
|
-
return _editPlaylist.apply(this, arguments);
|
|
57517
|
-
}
|
|
57518
|
-
|
|
57519
|
-
return editPlaylist;
|
|
57520
|
-
}()
|
|
57521
|
-
}, {
|
|
57522
|
-
key: "addPlaylistTrack",
|
|
57523
|
-
value: function () {
|
|
57524
|
-
var _addPlaylistTrack = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(_ref4) {
|
|
57525
|
-
var playlistId, trackId, timestamp, responseValues, currentUserId, userId, updateAction, entityType, playlist, updatedPlaylistTracks, metadata, _yield$this$creatorNo3, metadataMultihash, resp, txReceipt, error;
|
|
57526
|
-
|
|
57527
|
-
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
57528
|
-
while (1) {
|
|
57529
|
-
switch (_context5.prev = _context5.next) {
|
|
57530
|
-
case 0:
|
|
57531
|
-
playlistId = _ref4.playlistId, trackId = _ref4.trackId, timestamp = _ref4.timestamp;
|
|
57532
|
-
responseValues = this.getDefaultPlaylistReponseValues();
|
|
57533
|
-
_context5.prev = 2;
|
|
57534
|
-
currentUserId = this.userStateManager.getCurrentUserId();
|
|
57535
|
-
|
|
57536
|
-
if (!(!playlistId || playlistId === undefined)) {
|
|
57537
|
-
_context5.next = 7;
|
|
57538
|
-
break;
|
|
57539
|
-
}
|
|
57540
|
-
|
|
57541
|
-
responseValues.error = 'Missing current playlistId';
|
|
57542
|
-
return _context5.abrupt("return", responseValues);
|
|
57543
|
-
|
|
57544
|
-
case 7:
|
|
57545
|
-
if (currentUserId) {
|
|
57546
|
-
_context5.next = 10;
|
|
57547
|
-
break;
|
|
57548
|
-
}
|
|
57549
|
-
|
|
57550
|
-
responseValues.error = 'Missing current user ID';
|
|
57551
|
-
return _context5.abrupt("return", responseValues);
|
|
57552
|
-
|
|
57553
|
-
case 10:
|
|
57554
|
-
userId = parseInt(currentUserId);
|
|
57555
|
-
updateAction = Action.UPDATE;
|
|
57556
|
-
entityType = EntityType.PLAYLIST;
|
|
57557
|
-
this.REQUIRES(Services.CREATOR_NODE);
|
|
57558
|
-
_context5.next = 16;
|
|
57559
|
-
return this.getFullPlaylist(playlistId, userId);
|
|
57560
|
-
|
|
57561
|
-
case 16:
|
|
57562
|
-
playlist = _context5.sent;
|
|
57563
|
-
updatedPlaylistTracks = this.mapAddedTimestamps(playlist.added_timestamps);
|
|
57564
|
-
updatedPlaylistTracks.push({
|
|
57565
|
-
track: trackId,
|
|
57566
|
-
time: timestamp
|
|
57567
|
-
});
|
|
57568
|
-
metadata = {
|
|
57569
|
-
playlist_id: playlistId,
|
|
57570
|
-
playlist_contents: {
|
|
57571
|
-
track_ids: updatedPlaylistTracks
|
|
57572
|
-
},
|
|
57573
|
-
playlist_name: playlist.playlist_name,
|
|
57574
|
-
playlist_image_sizes_multihash: playlist.cover_art,
|
|
57575
|
-
description: playlist.description,
|
|
57576
|
-
is_album: playlist.is_album,
|
|
57577
|
-
is_private: playlist.is_private
|
|
57578
|
-
};
|
|
57579
|
-
_context5.next = 22;
|
|
57580
|
-
return this.creatorNode.uploadPlaylistMetadata(metadata);
|
|
57581
|
-
|
|
57582
|
-
case 22:
|
|
57583
|
-
_yield$this$creatorNo3 = _context5.sent;
|
|
57584
|
-
metadataMultihash = _yield$this$creatorNo3.metadataMultihash;
|
|
57585
|
-
_context5.next = 26;
|
|
57586
|
-
return this.manageEntity({
|
|
57587
|
-
userId: userId,
|
|
57588
|
-
entityType: entityType,
|
|
57589
|
-
entityId: playlistId,
|
|
57590
|
-
action: updateAction,
|
|
57591
|
-
metadataMultihash: metadataMultihash
|
|
57592
|
-
});
|
|
57593
|
-
|
|
57594
|
-
case 26:
|
|
57595
|
-
resp = _context5.sent;
|
|
57596
|
-
txReceipt = resp.txReceipt;
|
|
57597
|
-
responseValues.blockHash = txReceipt.blockHash;
|
|
57598
|
-
responseValues.blockNumber = txReceipt.blockNumber;
|
|
57599
|
-
responseValues.playlistId = playlistId;
|
|
57600
|
-
return _context5.abrupt("return", responseValues);
|
|
57601
|
-
|
|
57602
|
-
case 34:
|
|
57603
|
-
_context5.prev = 34;
|
|
57604
|
-
_context5.t0 = _context5["catch"](2);
|
|
57605
|
-
error = _context5.t0.message;
|
|
57606
|
-
responseValues.error = error;
|
|
57607
|
-
return _context5.abrupt("return", responseValues);
|
|
57608
|
-
|
|
57609
|
-
case 39:
|
|
57610
|
-
case "end":
|
|
57611
|
-
return _context5.stop();
|
|
57612
|
-
}
|
|
57613
|
-
}
|
|
57614
|
-
}, _callee5, this, [[2, 34]]);
|
|
57615
|
-
}));
|
|
57616
|
-
|
|
57617
|
-
function addPlaylistTrack(_x6) {
|
|
57618
|
-
return _addPlaylistTrack.apply(this, arguments);
|
|
57619
|
-
}
|
|
57620
|
-
|
|
57621
|
-
return addPlaylistTrack;
|
|
57622
|
-
}()
|
|
57623
|
-
}, {
|
|
57624
|
-
key: "deletePlaylistTrack",
|
|
57625
|
-
value: function () {
|
|
57626
|
-
var _deletePlaylistTrack = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(_ref5) {
|
|
57627
|
-
var playlistId, trackId, timestamp, responseValues, currentUserId, userId, updateAction, entityType, playlist, existingPlaylistTracks, updatedTrackIds, metadata, _yield$this$creatorNo4, metadataMultihash, resp, txReceipt, error;
|
|
57628
|
-
|
|
57629
|
-
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
57630
|
-
while (1) {
|
|
57631
|
-
switch (_context6.prev = _context6.next) {
|
|
57632
|
-
case 0:
|
|
57633
|
-
playlistId = _ref5.playlistId, trackId = _ref5.trackId, timestamp = _ref5.timestamp;
|
|
57634
|
-
responseValues = this.getDefaultPlaylistReponseValues();
|
|
57635
|
-
_context6.prev = 2;
|
|
57636
|
-
currentUserId = this.userStateManager.getCurrentUserId();
|
|
57637
|
-
|
|
57638
|
-
if (!(!playlistId || playlistId === undefined)) {
|
|
57639
|
-
_context6.next = 7;
|
|
57640
|
-
break;
|
|
57641
|
-
}
|
|
57642
|
-
|
|
57643
|
-
responseValues.error = 'Missing current playlistId';
|
|
57644
|
-
return _context6.abrupt("return", responseValues);
|
|
57645
|
-
|
|
57646
|
-
case 7:
|
|
57647
|
-
if (currentUserId) {
|
|
57648
|
-
_context6.next = 10;
|
|
57649
|
-
break;
|
|
57650
|
-
}
|
|
57651
|
-
|
|
57652
|
-
responseValues.error = 'Missing current user ID';
|
|
57653
|
-
return _context6.abrupt("return", responseValues);
|
|
57654
|
-
|
|
57655
|
-
case 10:
|
|
57656
|
-
userId = parseInt(currentUserId);
|
|
57657
|
-
updateAction = Action.UPDATE;
|
|
57658
|
-
entityType = EntityType.PLAYLIST;
|
|
57659
|
-
this.REQUIRES(Services.CREATOR_NODE);
|
|
57660
|
-
_context6.next = 16;
|
|
57661
|
-
return this.getFullPlaylist(playlistId, userId);
|
|
57662
|
-
|
|
57663
|
-
case 16:
|
|
57664
|
-
playlist = _context6.sent;
|
|
57665
|
-
existingPlaylistTracks = this.mapAddedTimestamps(playlist.added_timestamps);
|
|
57666
|
-
updatedTrackIds = existingPlaylistTracks.filter(function (trackObj) {
|
|
57667
|
-
var _ref6;
|
|
57668
|
-
|
|
57669
|
-
return (_ref6 = trackObj.track !== trackId && timestamp !== trackObj.metadata_time) !== null && _ref6 !== void 0 ? _ref6 : trackObj.time;
|
|
57670
|
-
});
|
|
57400
|
+
case 17:
|
|
57401
|
+
trackIds = this.mapTimestamps(playlist.playlist_contents.track_ids);
|
|
57671
57402
|
metadata = {
|
|
57672
|
-
playlist_id:
|
|
57403
|
+
playlist_id: playlist.playlist_id,
|
|
57673
57404
|
playlist_contents: {
|
|
57674
|
-
track_ids:
|
|
57405
|
+
track_ids: trackIds
|
|
57675
57406
|
},
|
|
57676
57407
|
playlist_name: playlist.playlist_name,
|
|
57677
|
-
playlist_image_sizes_multihash: playlist.
|
|
57408
|
+
playlist_image_sizes_multihash: (_dirCID2 = dirCID) !== null && _dirCID2 !== void 0 ? _dirCID2 : playlist.cover_art_sizes,
|
|
57678
57409
|
description: playlist.description,
|
|
57679
57410
|
is_album: playlist.is_album,
|
|
57680
57411
|
is_private: playlist.is_private
|
|
57681
57412
|
};
|
|
57682
|
-
|
|
57413
|
+
_context3.next = 21;
|
|
57683
57414
|
return this.creatorNode.uploadPlaylistMetadata(metadata);
|
|
57684
57415
|
|
|
57685
|
-
case
|
|
57686
|
-
_yield$this$
|
|
57687
|
-
metadataMultihash = _yield$this$
|
|
57688
|
-
|
|
57416
|
+
case 21:
|
|
57417
|
+
_yield$this$creatorNo2 = _context3.sent;
|
|
57418
|
+
metadataMultihash = _yield$this$creatorNo2.metadataMultihash;
|
|
57419
|
+
_context3.next = 25;
|
|
57689
57420
|
return this.manageEntity({
|
|
57690
57421
|
userId: userId,
|
|
57691
57422
|
entityType: entityType,
|
|
57692
|
-
entityId:
|
|
57423
|
+
entityId: playlist.playlist_id,
|
|
57693
57424
|
action: updateAction,
|
|
57694
57425
|
metadataMultihash: metadataMultihash
|
|
57695
57426
|
});
|
|
57696
57427
|
|
|
57697
|
-
case 26:
|
|
57698
|
-
resp = _context6.sent;
|
|
57699
|
-
txReceipt = resp.txReceipt;
|
|
57700
|
-
responseValues.blockHash = txReceipt.blockHash;
|
|
57701
|
-
responseValues.blockNumber = txReceipt.blockNumber;
|
|
57702
|
-
responseValues.playlistId = playlistId;
|
|
57703
|
-
return _context6.abrupt("return", responseValues);
|
|
57704
|
-
|
|
57705
|
-
case 34:
|
|
57706
|
-
_context6.prev = 34;
|
|
57707
|
-
_context6.t0 = _context6["catch"](2);
|
|
57708
|
-
error = _context6.t0.message;
|
|
57709
|
-
responseValues.error = error;
|
|
57710
|
-
return _context6.abrupt("return", responseValues);
|
|
57711
|
-
|
|
57712
|
-
case 39:
|
|
57713
|
-
case "end":
|
|
57714
|
-
return _context6.stop();
|
|
57715
|
-
}
|
|
57716
|
-
}
|
|
57717
|
-
}, _callee6, this, [[2, 34]]);
|
|
57718
|
-
}));
|
|
57719
|
-
|
|
57720
|
-
function deletePlaylistTrack(_x7) {
|
|
57721
|
-
return _deletePlaylistTrack.apply(this, arguments);
|
|
57722
|
-
}
|
|
57723
|
-
|
|
57724
|
-
return deletePlaylistTrack;
|
|
57725
|
-
}()
|
|
57726
|
-
/**
|
|
57727
|
-
* Update a playlist using updated data contracts flow
|
|
57728
|
-
**/
|
|
57729
|
-
|
|
57730
|
-
}, {
|
|
57731
|
-
key: "orderPlaylist",
|
|
57732
|
-
value: function () {
|
|
57733
|
-
var _orderPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(_ref7) {
|
|
57734
|
-
var playlistId, trackIds, responseValues, currentUserId, userId, updateAction, entityType, playlist, existingPlaylistTracks, trackIdsWithTimes, trackIdTimes, metadata, _yield$this$creatorNo5, metadataMultihash, resp, txReceipt, error;
|
|
57735
|
-
|
|
57736
|
-
return regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
57737
|
-
while (1) {
|
|
57738
|
-
switch (_context7.prev = _context7.next) {
|
|
57739
|
-
case 0:
|
|
57740
|
-
playlistId = _ref7.playlistId, trackIds = _ref7.trackIds;
|
|
57741
|
-
responseValues = this.getDefaultPlaylistReponseValues();
|
|
57742
|
-
_context7.prev = 2;
|
|
57743
|
-
currentUserId = this.userStateManager.getCurrentUserId();
|
|
57744
|
-
|
|
57745
|
-
if (!(!playlistId || playlistId === undefined)) {
|
|
57746
|
-
_context7.next = 7;
|
|
57747
|
-
break;
|
|
57748
|
-
}
|
|
57749
|
-
|
|
57750
|
-
responseValues.error = 'Missing current playlistId';
|
|
57751
|
-
return _context7.abrupt("return", responseValues);
|
|
57752
|
-
|
|
57753
|
-
case 7:
|
|
57754
|
-
if (currentUserId) {
|
|
57755
|
-
_context7.next = 10;
|
|
57756
|
-
break;
|
|
57757
|
-
}
|
|
57758
|
-
|
|
57759
|
-
responseValues.error = 'Missing current user ID';
|
|
57760
|
-
return _context7.abrupt("return", responseValues);
|
|
57761
|
-
|
|
57762
|
-
case 10:
|
|
57763
|
-
userId = parseInt(currentUserId);
|
|
57764
|
-
updateAction = Action.UPDATE;
|
|
57765
|
-
entityType = EntityType.PLAYLIST;
|
|
57766
|
-
this.REQUIRES(Services.CREATOR_NODE);
|
|
57767
|
-
_context7.next = 16;
|
|
57768
|
-
return this.getFullPlaylist(playlistId, userId);
|
|
57769
|
-
|
|
57770
|
-
case 16:
|
|
57771
|
-
playlist = _context7.sent;
|
|
57772
|
-
existingPlaylistTracks = this.mapAddedTimestamps(playlist.added_timestamps);
|
|
57773
|
-
trackIdsWithTimes = [];
|
|
57774
|
-
trackIdTimes = {};
|
|
57775
|
-
existingPlaylistTracks.forEach(function (trackObj) {
|
|
57776
|
-
var _trackObj$metadata_ti2;
|
|
57777
|
-
|
|
57778
|
-
var trackId = trackObj.track;
|
|
57779
|
-
var timestamp = (_trackObj$metadata_ti2 = trackObj.metadata_time) !== null && _trackObj$metadata_ti2 !== void 0 ? _trackObj$metadata_ti2 : trackObj.time;
|
|
57780
|
-
|
|
57781
|
-
if (trackId in trackIdTimes) {
|
|
57782
|
-
trackIdTimes[trackId].push(timestamp);
|
|
57783
|
-
} else {
|
|
57784
|
-
trackIdTimes[trackId] = [timestamp];
|
|
57785
|
-
}
|
|
57786
|
-
}); // new tracks default to currentBlock timestamp
|
|
57787
|
-
|
|
57788
|
-
trackIdsWithTimes = trackIds.map(function (trackId) {
|
|
57789
|
-
return {
|
|
57790
|
-
track: trackId,
|
|
57791
|
-
time: trackIdTimes[trackId].pop()
|
|
57792
|
-
};
|
|
57793
|
-
});
|
|
57794
|
-
metadata = {
|
|
57795
|
-
playlist_id: playlistId,
|
|
57796
|
-
playlist_contents: {
|
|
57797
|
-
track_ids: trackIdsWithTimes
|
|
57798
|
-
},
|
|
57799
|
-
playlist_name: playlist.playlist_name,
|
|
57800
|
-
playlist_image_sizes_multihash: playlist.cover_art,
|
|
57801
|
-
description: playlist.description,
|
|
57802
|
-
is_album: playlist.is_album,
|
|
57803
|
-
is_private: playlist.is_private
|
|
57804
|
-
};
|
|
57805
|
-
_context7.next = 25;
|
|
57806
|
-
return this.creatorNode.uploadPlaylistMetadata(metadata);
|
|
57807
|
-
|
|
57808
57428
|
case 25:
|
|
57809
|
-
|
|
57810
|
-
metadataMultihash = _yield$this$creatorNo5.metadataMultihash;
|
|
57811
|
-
_context7.next = 29;
|
|
57812
|
-
return this.manageEntity({
|
|
57813
|
-
userId: userId,
|
|
57814
|
-
entityType: entityType,
|
|
57815
|
-
entityId: playlistId,
|
|
57816
|
-
action: updateAction,
|
|
57817
|
-
metadataMultihash: metadataMultihash
|
|
57818
|
-
});
|
|
57819
|
-
|
|
57820
|
-
case 29:
|
|
57821
|
-
resp = _context7.sent;
|
|
57429
|
+
resp = _context3.sent;
|
|
57822
57430
|
txReceipt = resp.txReceipt;
|
|
57823
57431
|
responseValues.blockHash = txReceipt.blockHash;
|
|
57824
57432
|
responseValues.blockNumber = txReceipt.blockNumber;
|
|
57825
|
-
|
|
57826
|
-
return _context7.abrupt("return", responseValues);
|
|
57433
|
+
return _context3.abrupt("return", responseValues);
|
|
57827
57434
|
|
|
57828
|
-
case
|
|
57829
|
-
|
|
57830
|
-
|
|
57831
|
-
error =
|
|
57435
|
+
case 32:
|
|
57436
|
+
_context3.prev = 32;
|
|
57437
|
+
_context3.t0 = _context3["catch"](1);
|
|
57438
|
+
error = _context3.t0.message;
|
|
57832
57439
|
responseValues.error = error;
|
|
57833
|
-
return
|
|
57440
|
+
return _context3.abrupt("return", responseValues);
|
|
57834
57441
|
|
|
57835
|
-
case
|
|
57442
|
+
case 37:
|
|
57836
57443
|
case "end":
|
|
57837
|
-
return
|
|
57444
|
+
return _context3.stop();
|
|
57838
57445
|
}
|
|
57839
57446
|
}
|
|
57840
|
-
},
|
|
57447
|
+
}, _callee3, this, [[1, 32]]);
|
|
57841
57448
|
}));
|
|
57842
57449
|
|
|
57843
|
-
function
|
|
57844
|
-
return
|
|
57450
|
+
function updatePlaylist(_x3) {
|
|
57451
|
+
return _updatePlaylist.apply(this, arguments);
|
|
57845
57452
|
}
|
|
57846
57453
|
|
|
57847
|
-
return
|
|
57454
|
+
return updatePlaylist;
|
|
57848
57455
|
}()
|
|
57849
57456
|
/**
|
|
57850
57457
|
* Manage an entity with the updated data contract flow
|
|
@@ -57854,44 +57461,44 @@ var EntityManager = /*#__PURE__*/function (_Base) {
|
|
|
57854
57461
|
}, {
|
|
57855
57462
|
key: "manageEntity",
|
|
57856
57463
|
value: function () {
|
|
57857
|
-
var _manageEntity = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
57464
|
+
var _manageEntity = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(_ref) {
|
|
57858
57465
|
var userId, entityType, entityId, action, metadataMultihash, error, resp, _this$contracts$Entit;
|
|
57859
57466
|
|
|
57860
|
-
return regeneratorRuntime.wrap(function
|
|
57467
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
57861
57468
|
while (1) {
|
|
57862
|
-
switch (
|
|
57469
|
+
switch (_context4.prev = _context4.next) {
|
|
57863
57470
|
case 0:
|
|
57864
|
-
userId =
|
|
57471
|
+
userId = _ref.userId, entityType = _ref.entityType, entityId = _ref.entityId, action = _ref.action, metadataMultihash = _ref.metadataMultihash;
|
|
57865
57472
|
error = null;
|
|
57866
|
-
|
|
57867
|
-
|
|
57473
|
+
_context4.prev = 2;
|
|
57474
|
+
_context4.next = 5;
|
|
57868
57475
|
return (_this$contracts$Entit = this.contracts.EntityManagerClient) === null || _this$contracts$Entit === void 0 ? void 0 : _this$contracts$Entit.manageEntity(userId, entityType, entityId, action, metadataMultihash);
|
|
57869
57476
|
|
|
57870
57477
|
case 5:
|
|
57871
|
-
resp =
|
|
57872
|
-
return
|
|
57478
|
+
resp = _context4.sent;
|
|
57479
|
+
return _context4.abrupt("return", {
|
|
57873
57480
|
txReceipt: resp.txReceipt,
|
|
57874
57481
|
error: error
|
|
57875
57482
|
});
|
|
57876
57483
|
|
|
57877
57484
|
case 9:
|
|
57878
|
-
|
|
57879
|
-
|
|
57880
|
-
error =
|
|
57881
|
-
return
|
|
57485
|
+
_context4.prev = 9;
|
|
57486
|
+
_context4.t0 = _context4["catch"](2);
|
|
57487
|
+
error = _context4.t0.message;
|
|
57488
|
+
return _context4.abrupt("return", {
|
|
57882
57489
|
txReceipt: null,
|
|
57883
57490
|
error: error
|
|
57884
57491
|
});
|
|
57885
57492
|
|
|
57886
57493
|
case 13:
|
|
57887
57494
|
case "end":
|
|
57888
|
-
return
|
|
57495
|
+
return _context4.stop();
|
|
57889
57496
|
}
|
|
57890
57497
|
}
|
|
57891
|
-
},
|
|
57498
|
+
}, _callee4, this, [[2, 9]]);
|
|
57892
57499
|
}));
|
|
57893
57500
|
|
|
57894
|
-
function manageEntity(
|
|
57501
|
+
function manageEntity(_x4) {
|
|
57895
57502
|
return _manageEntity.apply(this, arguments);
|
|
57896
57503
|
}
|
|
57897
57504
|
|