@soundx/services 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/album.d.ts +25 -0
- package/dist/cjs/album.js +98 -0
- package/dist/cjs/artist.d.ts +17 -0
- package/dist/cjs/artist.js +66 -0
- package/dist/cjs/auth.d.ts +15 -0
- package/dist/cjs/auth.js +38 -0
- package/dist/cjs/folder.d.ts +12 -0
- package/dist/cjs/folder.js +31 -0
- package/dist/cjs/import.d.ts +27 -0
- package/dist/cjs/import.js +42 -0
- package/dist/cjs/index.d.ts +13 -0
- package/dist/cjs/index.js +148 -0
- package/dist/cjs/models.d.ts +174 -0
- package/dist/cjs/models.js +11 -0
- package/dist/cjs/playlist.d.ts +9 -0
- package/dist/cjs/playlist.js +55 -0
- package/dist/cjs/request.d.ts +16 -0
- package/dist/cjs/request.js +33 -0
- package/dist/cjs/search-record.d.ts +8 -0
- package/dist/cjs/search-record.js +26 -0
- package/dist/cjs/search.d.ts +10 -0
- package/dist/cjs/search.js +47 -0
- package/dist/cjs/track.d.ts +21 -0
- package/dist/cjs/track.js +72 -0
- package/dist/cjs/user.d.ts +13 -0
- package/dist/cjs/user.js +115 -0
- package/dist/cjs/userAudiobookHistory.d.ts +6 -0
- package/dist/cjs/userAudiobookHistory.js +12 -0
- package/dist/esm/album.d.ts +25 -0
- package/dist/esm/album.js +80 -0
- package/dist/esm/artist.d.ts +17 -0
- package/dist/esm/artist.js +49 -0
- package/dist/esm/auth.d.ts +15 -0
- package/dist/esm/auth.js +48 -0
- package/dist/esm/folder.d.ts +12 -0
- package/dist/esm/folder.js +20 -0
- package/dist/esm/import.d.ts +27 -0
- package/dist/esm/import.js +33 -0
- package/dist/esm/index.d.ts +13 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/models.d.ts +174 -0
- package/dist/esm/models.js +7 -0
- package/dist/esm/playlist.d.ts +9 -0
- package/dist/esm/playlist.js +172 -0
- package/dist/esm/request.d.ts +16 -0
- package/dist/esm/request.js +45 -0
- package/dist/esm/search-record.d.ts +8 -0
- package/dist/esm/search-record.js +15 -0
- package/dist/esm/search.d.ts +10 -0
- package/dist/esm/search.js +70 -0
- package/dist/esm/track.d.ts +21 -0
- package/dist/esm/track.js +55 -0
- package/dist/esm/user.d.ts +13 -0
- package/dist/esm/user.js +100 -0
- package/dist/esm/userAudiobookHistory.d.ts +6 -0
- package/dist/esm/userAudiobookHistory.js +4 -0
- package/package.json +26 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
import request from "./request";
|
|
6
|
+
export var createPlaylist = /*#__PURE__*/function () {
|
|
7
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(name, type, userId) {
|
|
8
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9
|
+
while (1) switch (_context.prev = _context.next) {
|
|
10
|
+
case 0:
|
|
11
|
+
_context.next = 2;
|
|
12
|
+
return request.post("/playlists", {
|
|
13
|
+
name: name,
|
|
14
|
+
type: type,
|
|
15
|
+
userId: userId
|
|
16
|
+
});
|
|
17
|
+
case 2:
|
|
18
|
+
return _context.abrupt("return", _context.sent);
|
|
19
|
+
case 3:
|
|
20
|
+
case "end":
|
|
21
|
+
return _context.stop();
|
|
22
|
+
}
|
|
23
|
+
}, _callee);
|
|
24
|
+
}));
|
|
25
|
+
return function createPlaylist(_x, _x2, _x3) {
|
|
26
|
+
return _ref.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
}();
|
|
29
|
+
export var getPlaylists = /*#__PURE__*/function () {
|
|
30
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(type, userId) {
|
|
31
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
32
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
33
|
+
case 0:
|
|
34
|
+
_context2.next = 2;
|
|
35
|
+
return request.get("/playlists", {
|
|
36
|
+
params: {
|
|
37
|
+
userId: userId,
|
|
38
|
+
type: type
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
case 2:
|
|
42
|
+
return _context2.abrupt("return", _context2.sent);
|
|
43
|
+
case 3:
|
|
44
|
+
case "end":
|
|
45
|
+
return _context2.stop();
|
|
46
|
+
}
|
|
47
|
+
}, _callee2);
|
|
48
|
+
}));
|
|
49
|
+
return function getPlaylists(_x4, _x5) {
|
|
50
|
+
return _ref2.apply(this, arguments);
|
|
51
|
+
};
|
|
52
|
+
}();
|
|
53
|
+
export var getPlaylistById = /*#__PURE__*/function () {
|
|
54
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(id) {
|
|
55
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
56
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
57
|
+
case 0:
|
|
58
|
+
_context3.next = 2;
|
|
59
|
+
return request.get("/playlists/".concat(id));
|
|
60
|
+
case 2:
|
|
61
|
+
return _context3.abrupt("return", _context3.sent);
|
|
62
|
+
case 3:
|
|
63
|
+
case "end":
|
|
64
|
+
return _context3.stop();
|
|
65
|
+
}
|
|
66
|
+
}, _callee3);
|
|
67
|
+
}));
|
|
68
|
+
return function getPlaylistById(_x6) {
|
|
69
|
+
return _ref3.apply(this, arguments);
|
|
70
|
+
};
|
|
71
|
+
}();
|
|
72
|
+
export var updatePlaylist = /*#__PURE__*/function () {
|
|
73
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(id, name) {
|
|
74
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
75
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
76
|
+
case 0:
|
|
77
|
+
_context4.next = 2;
|
|
78
|
+
return request.put("/playlists/".concat(id), {
|
|
79
|
+
name: name
|
|
80
|
+
});
|
|
81
|
+
case 2:
|
|
82
|
+
return _context4.abrupt("return", _context4.sent);
|
|
83
|
+
case 3:
|
|
84
|
+
case "end":
|
|
85
|
+
return _context4.stop();
|
|
86
|
+
}
|
|
87
|
+
}, _callee4);
|
|
88
|
+
}));
|
|
89
|
+
return function updatePlaylist(_x7, _x8) {
|
|
90
|
+
return _ref4.apply(this, arguments);
|
|
91
|
+
};
|
|
92
|
+
}();
|
|
93
|
+
export var deletePlaylist = /*#__PURE__*/function () {
|
|
94
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id) {
|
|
95
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
96
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
97
|
+
case 0:
|
|
98
|
+
_context5.next = 2;
|
|
99
|
+
return request.delete("/playlists/".concat(id));
|
|
100
|
+
case 2:
|
|
101
|
+
return _context5.abrupt("return", _context5.sent);
|
|
102
|
+
case 3:
|
|
103
|
+
case "end":
|
|
104
|
+
return _context5.stop();
|
|
105
|
+
}
|
|
106
|
+
}, _callee5);
|
|
107
|
+
}));
|
|
108
|
+
return function deletePlaylist(_x9) {
|
|
109
|
+
return _ref5.apply(this, arguments);
|
|
110
|
+
};
|
|
111
|
+
}();
|
|
112
|
+
export var addTrackToPlaylist = /*#__PURE__*/function () {
|
|
113
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(playlistId, trackId) {
|
|
114
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
115
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
116
|
+
case 0:
|
|
117
|
+
_context6.next = 2;
|
|
118
|
+
return request.post("/playlists/".concat(playlistId, "/tracks"), {
|
|
119
|
+
trackId: trackId
|
|
120
|
+
});
|
|
121
|
+
case 2:
|
|
122
|
+
return _context6.abrupt("return", _context6.sent);
|
|
123
|
+
case 3:
|
|
124
|
+
case "end":
|
|
125
|
+
return _context6.stop();
|
|
126
|
+
}
|
|
127
|
+
}, _callee6);
|
|
128
|
+
}));
|
|
129
|
+
return function addTrackToPlaylist(_x10, _x11) {
|
|
130
|
+
return _ref6.apply(this, arguments);
|
|
131
|
+
};
|
|
132
|
+
}();
|
|
133
|
+
export var addTracksToPlaylist = /*#__PURE__*/function () {
|
|
134
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(playlistId, trackIds) {
|
|
135
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
136
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
137
|
+
case 0:
|
|
138
|
+
_context7.next = 2;
|
|
139
|
+
return request.post("/playlists/".concat(playlistId, "/tracks/batch"), {
|
|
140
|
+
trackIds: trackIds
|
|
141
|
+
});
|
|
142
|
+
case 2:
|
|
143
|
+
return _context7.abrupt("return", _context7.sent);
|
|
144
|
+
case 3:
|
|
145
|
+
case "end":
|
|
146
|
+
return _context7.stop();
|
|
147
|
+
}
|
|
148
|
+
}, _callee7);
|
|
149
|
+
}));
|
|
150
|
+
return function addTracksToPlaylist(_x12, _x13) {
|
|
151
|
+
return _ref7.apply(this, arguments);
|
|
152
|
+
};
|
|
153
|
+
}();
|
|
154
|
+
export var removeTrackFromPlaylist = /*#__PURE__*/function () {
|
|
155
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(playlistId, trackId) {
|
|
156
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
157
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
158
|
+
case 0:
|
|
159
|
+
_context8.next = 2;
|
|
160
|
+
return request.delete("/playlists/".concat(playlistId, "/tracks/").concat(trackId));
|
|
161
|
+
case 2:
|
|
162
|
+
return _context8.abrupt("return", _context8.sent);
|
|
163
|
+
case 3:
|
|
164
|
+
case "end":
|
|
165
|
+
return _context8.stop();
|
|
166
|
+
}
|
|
167
|
+
}, _callee8);
|
|
168
|
+
}));
|
|
169
|
+
return function removeTrackFromPlaylist(_x14, _x15) {
|
|
170
|
+
return _ref8.apply(this, arguments);
|
|
171
|
+
};
|
|
172
|
+
}();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
|
+
export declare const setRequestInstance: (instance: AxiosInstance) => void;
|
|
3
|
+
export declare const getRequestInstance: () => AxiosInstance;
|
|
4
|
+
export declare const request: {
|
|
5
|
+
get: <T = any, R = any, D = any>(url: string, config?: any) => Promise<R>;
|
|
6
|
+
delete: <T_1 = any, R_1 = any, D_1 = any>(url: string, config?: any) => Promise<R_1>;
|
|
7
|
+
head: <T_2 = any, R_2 = any, D_2 = any>(url: string, config?: any) => Promise<R_2>;
|
|
8
|
+
options: <T_3 = any, R_3 = any, D_3 = any>(url: string, config?: any) => Promise<R_3>;
|
|
9
|
+
post: <T_4 = any, R_4 = any, D_4 = any>(url: string, data?: D_4 | undefined, config?: any) => Promise<R_4>;
|
|
10
|
+
put: <T_5 = any, R_5 = any, D_5 = any>(url: string, data?: D_5 | undefined, config?: any) => Promise<R_5>;
|
|
11
|
+
patch: <T_6 = any, R_6 = any, D_6 = any>(url: string, data?: D_6 | undefined, config?: any) => Promise<R_6>;
|
|
12
|
+
postForm: <T_7 = any, R_7 = any, D_7 = any>(url: string, data?: D_7 | undefined, config?: any) => Promise<R_7>;
|
|
13
|
+
putForm: <T_8 = any, R_8 = any, D_8 = any>(url: string, data?: D_8 | undefined, config?: any) => Promise<R_8>;
|
|
14
|
+
patchForm: <T_9 = any, R_9 = any, D_9 = any>(url: string, data?: D_9 | undefined, config?: any) => Promise<R_9>;
|
|
15
|
+
};
|
|
16
|
+
export default request;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var requestInstance = null;
|
|
2
|
+
export var setRequestInstance = function setRequestInstance(instance) {
|
|
3
|
+
requestInstance = instance;
|
|
4
|
+
};
|
|
5
|
+
export var getRequestInstance = function getRequestInstance() {
|
|
6
|
+
if (!requestInstance) {
|
|
7
|
+
throw new Error("Request instance not initialized. Please call setRequestInstance first.");
|
|
8
|
+
}
|
|
9
|
+
return requestInstance;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// Facade to match typical axios usage: request.get, request.post etc.
|
|
13
|
+
export var request = {
|
|
14
|
+
get: function get(url, config) {
|
|
15
|
+
return getRequestInstance().get(url, config);
|
|
16
|
+
},
|
|
17
|
+
delete: function _delete(url, config) {
|
|
18
|
+
return getRequestInstance().delete(url, config);
|
|
19
|
+
},
|
|
20
|
+
head: function head(url, config) {
|
|
21
|
+
return getRequestInstance().head(url, config);
|
|
22
|
+
},
|
|
23
|
+
options: function options(url, config) {
|
|
24
|
+
return getRequestInstance().options(url, config);
|
|
25
|
+
},
|
|
26
|
+
post: function post(url, data, config) {
|
|
27
|
+
return getRequestInstance().post(url, data, config);
|
|
28
|
+
},
|
|
29
|
+
put: function put(url, data, config) {
|
|
30
|
+
return getRequestInstance().put(url, data, config);
|
|
31
|
+
},
|
|
32
|
+
patch: function patch(url, data, config) {
|
|
33
|
+
return getRequestInstance().patch(url, data, config);
|
|
34
|
+
},
|
|
35
|
+
postForm: function postForm(url, data, config) {
|
|
36
|
+
return getRequestInstance().postForm(url, data, config);
|
|
37
|
+
},
|
|
38
|
+
putForm: function putForm(url, data, config) {
|
|
39
|
+
return getRequestInstance().putForm(url, data, config);
|
|
40
|
+
},
|
|
41
|
+
patchForm: function patchForm(url, data, config) {
|
|
42
|
+
return getRequestInstance().patchForm(url, data, config);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export default request;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ISuccessResponse } from "./models";
|
|
2
|
+
export declare const addSearchRecord: (keyword: string) => Promise<ISuccessResponse<any>>;
|
|
3
|
+
export declare const getSearchHistory: () => Promise<ISuccessResponse<string[]>>;
|
|
4
|
+
export declare const getHotSearches: () => Promise<ISuccessResponse<{
|
|
5
|
+
keyword: string;
|
|
6
|
+
count: number;
|
|
7
|
+
}[]>>;
|
|
8
|
+
export declare const clearSearchHistory: () => Promise<ISuccessResponse<any>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import request from "./request";
|
|
2
|
+
export var addSearchRecord = function addSearchRecord(keyword) {
|
|
3
|
+
return request.post("/search-record", {
|
|
4
|
+
keyword: keyword
|
|
5
|
+
});
|
|
6
|
+
};
|
|
7
|
+
export var getSearchHistory = function getSearchHistory() {
|
|
8
|
+
return request.get("/search-record/history");
|
|
9
|
+
};
|
|
10
|
+
export var getHotSearches = function getHotSearches() {
|
|
11
|
+
return request.get("/search-record/hot");
|
|
12
|
+
};
|
|
13
|
+
export var clearSearchHistory = function clearSearchHistory() {
|
|
14
|
+
return request.delete("/search-record/history");
|
|
15
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Album, Artist, ISuccessResponse, Track } from "./models";
|
|
2
|
+
export interface SearchResults {
|
|
3
|
+
tracks: Track[];
|
|
4
|
+
artists: Artist[];
|
|
5
|
+
albums: Album[];
|
|
6
|
+
}
|
|
7
|
+
export declare const searchTracks: (keyword: string, type?: string, limit?: number) => Promise<ISuccessResponse<Track[]>>;
|
|
8
|
+
export declare const searchArtists: (keyword: string, type?: string, limit?: number) => Promise<ISuccessResponse<Artist[]>>;
|
|
9
|
+
export declare const searchAlbums: (keyword: string, type?: string, limit?: number) => Promise<ISuccessResponse<Album[]>>;
|
|
10
|
+
export declare const searchAll: (keyword: string, type?: string) => Promise<SearchResults>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
8
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
10
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
11
|
+
import request from "./request";
|
|
12
|
+
export var searchTracks = function searchTracks(keyword, type) {
|
|
13
|
+
var limit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
|
|
14
|
+
return request.get("/track/search", {
|
|
15
|
+
params: {
|
|
16
|
+
keyword: keyword,
|
|
17
|
+
type: type,
|
|
18
|
+
limit: limit
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export var searchArtists = function searchArtists(keyword, type) {
|
|
23
|
+
var limit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
|
|
24
|
+
return request.get("/artist/search", {
|
|
25
|
+
params: {
|
|
26
|
+
keyword: keyword,
|
|
27
|
+
type: type,
|
|
28
|
+
limit: limit
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
export var searchAlbums = function searchAlbums(keyword, type) {
|
|
33
|
+
var limit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
|
|
34
|
+
return request.get("/album/search", {
|
|
35
|
+
params: {
|
|
36
|
+
keyword: keyword,
|
|
37
|
+
type: type,
|
|
38
|
+
limit: limit
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
export var searchAll = /*#__PURE__*/function () {
|
|
43
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(keyword, type) {
|
|
44
|
+
var _yield$Promise$all, _yield$Promise$all2, tracksRes, artistsRes, albumsRes;
|
|
45
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
46
|
+
while (1) switch (_context.prev = _context.next) {
|
|
47
|
+
case 0:
|
|
48
|
+
_context.next = 2;
|
|
49
|
+
return Promise.all([searchTracks(keyword, type, 5), searchArtists(keyword, type, 5), searchAlbums(keyword, type, 5)]);
|
|
50
|
+
case 2:
|
|
51
|
+
_yield$Promise$all = _context.sent;
|
|
52
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
|
|
53
|
+
tracksRes = _yield$Promise$all2[0];
|
|
54
|
+
artistsRes = _yield$Promise$all2[1];
|
|
55
|
+
albumsRes = _yield$Promise$all2[2];
|
|
56
|
+
return _context.abrupt("return", {
|
|
57
|
+
tracks: tracksRes.code === 200 ? tracksRes.data : [],
|
|
58
|
+
artists: artistsRes.code === 200 ? artistsRes.data : [],
|
|
59
|
+
albums: albumsRes.code === 200 ? albumsRes.data : []
|
|
60
|
+
});
|
|
61
|
+
case 8:
|
|
62
|
+
case "end":
|
|
63
|
+
return _context.stop();
|
|
64
|
+
}
|
|
65
|
+
}, _callee);
|
|
66
|
+
}));
|
|
67
|
+
return function searchAll(_x, _x2) {
|
|
68
|
+
return _ref.apply(this, arguments);
|
|
69
|
+
};
|
|
70
|
+
}();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ILoadMoreData, ISuccessResponse, ITableData, Track } from "./models";
|
|
2
|
+
export declare const getTrackList: () => Promise<ISuccessResponse<Track[]>>;
|
|
3
|
+
export declare const getTrackTableList: (params: {
|
|
4
|
+
pageSize: number;
|
|
5
|
+
current: number;
|
|
6
|
+
}) => Promise<ISuccessResponse<ITableData<Track[]>>>;
|
|
7
|
+
export declare const loadMoreTrack: (params: {
|
|
8
|
+
pageSize: number;
|
|
9
|
+
loadCount: number;
|
|
10
|
+
}) => Promise<ISuccessResponse<ILoadMoreData<Track[]>>>;
|
|
11
|
+
export declare const createTrack: (data: Omit<Track, "id">) => Promise<ISuccessResponse<Track>>;
|
|
12
|
+
export declare const updateTrack: (id: number, data: Partial<Track>) => Promise<ISuccessResponse<Track>>;
|
|
13
|
+
export declare const deleteTrack: (id: number, deleteAlbum?: boolean) => Promise<ISuccessResponse<boolean>>;
|
|
14
|
+
export declare const getDeletionImpact: (id: number) => Promise<ISuccessResponse<{
|
|
15
|
+
isLastTrackInAlbum: boolean;
|
|
16
|
+
albumName: string | null;
|
|
17
|
+
}>>;
|
|
18
|
+
export declare const batchCreateTracks: (data: Omit<Track, "id">[]) => Promise<ISuccessResponse<boolean>>;
|
|
19
|
+
export declare const batchDeleteTracks: (ids: number[]) => Promise<ISuccessResponse<boolean>>;
|
|
20
|
+
export declare const getLatestTracks: (type?: string, random?: boolean, pageSize?: number) => Promise<ISuccessResponse<Track[]>>;
|
|
21
|
+
export declare const getTracksByArtist: (artist: string) => Promise<ISuccessResponse<Track[]>>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import request from "./request";
|
|
2
|
+
export var getTrackList = function getTrackList() {
|
|
3
|
+
return request.get("/track/list");
|
|
4
|
+
};
|
|
5
|
+
export var getTrackTableList = function getTrackTableList(params) {
|
|
6
|
+
return request.get("/table-list", {
|
|
7
|
+
params: params
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export var loadMoreTrack = function loadMoreTrack(params) {
|
|
11
|
+
return request.get("/load-more", {
|
|
12
|
+
params: params
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
export var createTrack = function createTrack(data) {
|
|
16
|
+
return request.post("/track", data);
|
|
17
|
+
};
|
|
18
|
+
export var updateTrack = function updateTrack(id, data) {
|
|
19
|
+
return request.put("/track/".concat(id), data);
|
|
20
|
+
};
|
|
21
|
+
export var deleteTrack = function deleteTrack(id) {
|
|
22
|
+
var deleteAlbum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
23
|
+
return request.delete("/track/".concat(id), {
|
|
24
|
+
params: {
|
|
25
|
+
deleteAlbum: deleteAlbum
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
export var getDeletionImpact = function getDeletionImpact(id) {
|
|
30
|
+
return request.get("/track/".concat(id, "/deletion-impact"));
|
|
31
|
+
};
|
|
32
|
+
export var batchCreateTracks = function batchCreateTracks(data) {
|
|
33
|
+
return request.post("/track/batch-create", data);
|
|
34
|
+
};
|
|
35
|
+
export var batchDeleteTracks = function batchDeleteTracks(ids) {
|
|
36
|
+
return request.delete("/track/batch-delete", {
|
|
37
|
+
data: ids
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
export var getLatestTracks = function getLatestTracks(type, random, pageSize) {
|
|
41
|
+
return request.get("/track/latest", {
|
|
42
|
+
params: {
|
|
43
|
+
type: type,
|
|
44
|
+
random: random,
|
|
45
|
+
pageSize: pageSize
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
export var getTracksByArtist = function getTracksByArtist(artist) {
|
|
50
|
+
return request.get("/track/artist", {
|
|
51
|
+
params: {
|
|
52
|
+
artist: artist
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ILoadMoreData, type ISuccessResponse } from "./models";
|
|
2
|
+
export declare const addToHistory: (trackId: number, userId: number, progress?: number, deviceName?: string, deviceId?: number, isSyncMode?: boolean) => Promise<ISuccessResponse<any>>;
|
|
3
|
+
export declare const getLatestHistory: (userId: number) => Promise<ISuccessResponse<any>>;
|
|
4
|
+
export declare const addAlbumToHistory: (albumId: number, userId: number) => Promise<ISuccessResponse<any>>;
|
|
5
|
+
export declare const getAlbumHistory: (userId: number, loadCount: number, pageSize: number, type?: string) => Promise<ISuccessResponse<ILoadMoreData<any>>>;
|
|
6
|
+
export declare const toggleLike: (trackId: number, userId: number) => Promise<ISuccessResponse<any>>;
|
|
7
|
+
export declare const toggleUnLike: (trackId: number, userId: number) => Promise<ISuccessResponse<any>>;
|
|
8
|
+
export declare const toggleAlbumLike: (albumId: number, userId: number) => Promise<ISuccessResponse<any>>;
|
|
9
|
+
export declare const unlikeAlbum: (albumId: number, userId: number) => Promise<ISuccessResponse<any>>;
|
|
10
|
+
export declare const getFavoriteAlbums: (userId: number, loadCount: number, pageSize: number, type?: string) => Promise<ISuccessResponse<ILoadMoreData<any>>>;
|
|
11
|
+
export declare const getFavoriteTracks: (userId: number, loadCount: number, pageSize: number, type?: string) => Promise<ISuccessResponse<ILoadMoreData<any>>>;
|
|
12
|
+
export declare const getTrackHistory: (userId: number, loadCount: number, pageSize: number, type?: string) => Promise<ISuccessResponse<ILoadMoreData<any>>>;
|
|
13
|
+
export declare const getUserList: () => Promise<ISuccessResponse<any[]>>;
|
package/dist/esm/user.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import request from "./request";
|
|
2
|
+
export var addToHistory = function addToHistory(trackId, userId) {
|
|
3
|
+
var progress = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
4
|
+
var deviceName = arguments.length > 3 ? arguments[3] : undefined;
|
|
5
|
+
var deviceId = arguments.length > 4 ? arguments[4] : undefined;
|
|
6
|
+
var isSyncMode = arguments.length > 5 ? arguments[5] : undefined;
|
|
7
|
+
return request.post("/user-track-histories", {
|
|
8
|
+
trackId: trackId,
|
|
9
|
+
userId: userId,
|
|
10
|
+
progress: progress,
|
|
11
|
+
deviceName: deviceName,
|
|
12
|
+
deviceId: deviceId,
|
|
13
|
+
isSyncMode: isSyncMode
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export var getLatestHistory = function getLatestHistory(userId) {
|
|
17
|
+
return request.get("/user-track-histories/latest", {
|
|
18
|
+
params: {
|
|
19
|
+
userId: userId
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
export var addAlbumToHistory = function addAlbumToHistory(albumId, userId) {
|
|
24
|
+
return request.post("/user-album-histories", {
|
|
25
|
+
albumId: albumId,
|
|
26
|
+
userId: userId
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
export var getAlbumHistory = function getAlbumHistory(userId, loadCount, pageSize, type) {
|
|
30
|
+
return request.get("/user-album-histories/load-more", {
|
|
31
|
+
params: {
|
|
32
|
+
pageSize: pageSize,
|
|
33
|
+
loadCount: loadCount,
|
|
34
|
+
userId: userId,
|
|
35
|
+
type: type
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export var toggleLike = function toggleLike(trackId, userId) {
|
|
40
|
+
return request.post("/user-track-likes/create", {
|
|
41
|
+
trackId: trackId,
|
|
42
|
+
userId: userId
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export var toggleUnLike = function toggleUnLike(trackId, userId) {
|
|
46
|
+
return request.delete("/user-track-likes/unlike", {
|
|
47
|
+
params: {
|
|
48
|
+
trackId: trackId,
|
|
49
|
+
userId: userId
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
export var toggleAlbumLike = function toggleAlbumLike(albumId, userId) {
|
|
54
|
+
return request.post("/user-album-likes", {
|
|
55
|
+
albumId: albumId,
|
|
56
|
+
userId: userId
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
export var unlikeAlbum = function unlikeAlbum(albumId, userId) {
|
|
60
|
+
return request.delete("/user-album-likes/unlike", {
|
|
61
|
+
params: {
|
|
62
|
+
albumId: albumId,
|
|
63
|
+
userId: userId
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
export var getFavoriteAlbums = function getFavoriteAlbums(userId, loadCount, pageSize, type) {
|
|
68
|
+
return request.get("/user-album-likes/load-more", {
|
|
69
|
+
params: {
|
|
70
|
+
pageSize: pageSize,
|
|
71
|
+
loadCount: loadCount,
|
|
72
|
+
userId: userId,
|
|
73
|
+
type: type
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
export var getFavoriteTracks = function getFavoriteTracks(userId, loadCount, pageSize, type) {
|
|
78
|
+
return request.get("/user-track-likes/load-more", {
|
|
79
|
+
params: {
|
|
80
|
+
pageSize: pageSize,
|
|
81
|
+
loadCount: loadCount,
|
|
82
|
+
userId: userId,
|
|
83
|
+
lastId: loadCount,
|
|
84
|
+
type: type
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
export var getTrackHistory = function getTrackHistory(userId, loadCount, pageSize, type) {
|
|
89
|
+
return request.get("/user-track-histories/load-more", {
|
|
90
|
+
params: {
|
|
91
|
+
pageSize: pageSize,
|
|
92
|
+
loadCount: loadCount,
|
|
93
|
+
userId: userId,
|
|
94
|
+
type: type
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
export var getUserList = function getUserList() {
|
|
99
|
+
return request.get("/user/list");
|
|
100
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@soundx/services",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared API services and models",
|
|
5
|
+
"main": "dist/cjs/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "father dev",
|
|
10
|
+
"build": "father build",
|
|
11
|
+
"prepublishOnly": "father doctor && npm run build"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"axios": "^1.13.2"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"father": "^4.5.3",
|
|
18
|
+
"typescript": "~5.9.3"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
}
|
|
26
|
+
}
|