comty.js 0.59.1 → 0.60.3

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.
Files changed (48) hide show
  1. package/dist/handlers/measurePing.js +0 -0
  2. package/dist/handlers/request.js +0 -0
  3. package/dist/helpers/handleAfterRequest.js +14 -14
  4. package/dist/helpers/handleBeforeRequest.js +3 -9
  5. package/dist/helpers/handleRegenerationEvent.js +0 -0
  6. package/dist/helpers/measurePing.js +62 -0
  7. package/dist/helpers/refreshToken.js +42 -0
  8. package/dist/helpers/withSettings.js +0 -0
  9. package/dist/helpers/withStorage.js +0 -0
  10. package/dist/hooks/useRequest/index.js +3 -4
  11. package/dist/index.js +107 -87
  12. package/dist/models/auth/index.js +115 -33
  13. package/dist/models/chats/index.js +37 -0
  14. package/dist/models/feed/index.js +46 -14
  15. package/dist/models/follows/index.js +36 -18
  16. package/dist/models/index.js +1 -4
  17. package/dist/models/livestream/index.js +0 -0
  18. package/dist/models/music/getters/featuredPlaylists.js +11 -0
  19. package/dist/models/music/getters/index.js +36 -0
  20. package/dist/models/music/getters/myReleases.js +26 -0
  21. package/dist/models/music/getters/playlistData.js +11 -0
  22. package/dist/models/music/getters/playlistItem.js +11 -0
  23. package/dist/models/music/getters/playlists.js +29 -0
  24. package/dist/models/music/getters/releaseData.js +11 -0
  25. package/dist/models/music/getters/releases.js +29 -0
  26. package/dist/models/music/getters/search.js +26 -0
  27. package/dist/models/music/getters/trackData.js +12 -0
  28. package/dist/models/music/getters/trackLyrics.js +31 -0
  29. package/dist/models/music/getters/tracks.js +29 -0
  30. package/dist/models/music/index.js +95 -240
  31. package/dist/models/nfc/index.js +27 -1
  32. package/dist/models/playlists/index.js +0 -0
  33. package/dist/models/post/index.js +133 -70
  34. package/dist/models/search/index.js +17 -4
  35. package/dist/models/session/index.js +105 -56
  36. package/dist/models/sync/cores/spotifyCore.js +0 -0
  37. package/dist/models/sync/index.js +9 -15
  38. package/dist/models/sync/services/spotify.js +0 -0
  39. package/dist/models/sync/services/tidal.js +1 -1
  40. package/dist/models/sync/services/vrc.js +0 -0
  41. package/dist/models/user/index.js +78 -100
  42. package/dist/models/widget/index.js +0 -0
  43. package/dist/remote.js +43 -0
  44. package/dist/remotes.js +5 -63
  45. package/dist/request.js +51 -0
  46. package/dist/utils/generateRequest.js +52 -0
  47. package/dist/utils/importFrom.js +22 -0
  48. package/package.json +5 -4
@@ -1,100 +1,99 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _request = require('../../handlers/request'); var _request2 = _interopRequireDefault(_request);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _request = require('../../request'); var _request2 = _interopRequireDefault(_request);
2
2
  var _withSettings = require('../../helpers/withSettings'); var _withSettings2 = _interopRequireDefault(_withSettings);
3
3
 
4
4
  class Post {
5
+ /**
6
+ * Retrieves the maximum length allowed for the post text.
7
+ *
8
+ * @return {number} The maximum length allowed for the post text.
9
+ */
5
10
  static get maxPostTextLength() {
6
11
  return 3200
7
12
  }
8
13
 
14
+ /**
15
+ * Returns the maximum length allowed for a comment.
16
+ *
17
+ * @return {number} The maximum length allowed for a comment.
18
+ */
9
19
  static get maxCommentLength() {
10
20
  return 1200
11
21
  }
12
22
 
13
- static __initStatic() {this.getPostingPolicy = async () => {
23
+ /**
24
+ * Retrieves the posting policy from the server.
25
+ *
26
+ * @return {Promise<Object>} The posting policy data.
27
+ */
28
+ static async getPostingPolicy() {
14
29
  const { data } = await _request2.default.call(void 0, {
15
30
  method: "GET",
16
31
  url: "/posting_policy",
17
32
  })
18
33
 
19
34
  return data
20
- }}
35
+ }
21
36
 
22
- static __initStatic2() {this.getPost = async ({ post_id }) => {
37
+ /**
38
+ * Retrieves the data of a post by its ID.
39
+ *
40
+ * @param {Object} options - The options for retrieving the post.
41
+ * @param {string} options.post_id - The ID of the post to retrieve.
42
+ * @throws {Error} If the post_id is not provided.
43
+ * @return {Promise<Object>} The data of the post.
44
+ */
45
+ static async getPost({ post_id }) {
23
46
  if (!post_id) {
24
47
  throw new Error("Post ID is required")
25
48
  }
26
49
 
27
50
  const { data } = await _request2.default.call(void 0, {
28
51
  method: "GET",
29
- url: `/posts/post/${post_id}`,
52
+ url: `/posts/${post_id}/data`,
30
53
  })
31
54
 
32
55
  return data
33
- }}
56
+ }
34
57
 
35
- static __initStatic3() {this.getReplies = async ({ post_id, trim, limit }) => {
58
+ /**
59
+ * Retrieves the replies of a post by its ID.
60
+ *
61
+ * @param {Object} options - The options for retrieving the replies.
62
+ * @param {string} options.post_id - The ID of the post to retrieve replies for.
63
+ * @param {number} [options.trim=0] - The number of characters to trim the reply content.
64
+ * @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of replies to fetch.
65
+ * @throws {Error} If the post_id is not provided.
66
+ * @return {Promise<Object>} The data of the replies.
67
+ */
68
+ static async replies({ post_id, trim, limit }) {
36
69
  if (!post_id) {
37
70
  throw new Error("Post ID is required")
38
71
  }
39
72
 
40
73
  const { data } = await _request2.default.call(void 0, {
41
74
  method: "GET",
42
- url: `/posts/post/${post_id}/replies`,
75
+ url: `/posts/${post_id}/replies`,
43
76
  params: {
44
- offset: _nullishCoalesce(trim, () => ( 0)),
77
+ trim: _nullishCoalesce(trim, () => ( 0)),
45
78
  limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
46
79
  }
47
80
  })
48
81
 
49
82
  return data
50
- }}
51
-
52
- static __initStatic4() {this.getPostComments = async ({ post_id }) => {
53
- if (!post_id) {
54
- throw new Error("Post ID is required")
55
- }
56
-
57
- const { data } = await _request2.default.call(void 0, {
58
- method: "GET",
59
- url: `/comments/post/${post_id}`,
60
- })
61
-
62
- return data
63
- }}
64
-
65
- static __initStatic5() {this.sendComment = async ({ post_id, comment }) => {
66
- if (!post_id || !comment) {
67
- throw new Error("Post ID and/or comment are required")
68
- }
69
-
70
- const { data } = await _request2.default.call(void 0, {
71
- method: "POST",
72
- url: `/comments/post/${post_id}`,
73
- data: {
74
- message: comment,
75
- },
76
- })
77
-
78
- return data
79
- }}
80
-
81
- static __initStatic6() {this.deleteComment = async ({ post_id, comment_id }) => {
82
- if (!post_id || !comment_id) {
83
- throw new Error("Post ID and/or comment ID are required")
84
- }
85
-
86
- const { data } = await _request2.default.call(void 0, {
87
- method: "DELETE",
88
- url: `/comments/post/${post_id}/${comment_id}`,
89
- })
90
-
91
- return data
92
- }}
83
+ }
93
84
 
94
- static __initStatic7() {this.getExplorePosts = async ({ trim, limit }) => {
85
+ /**
86
+ * Retrieves the saved posts with optional trimming and limiting.
87
+ *
88
+ * @param {Object} options - The options for retrieving the saved posts.
89
+ * @param {number} [options.trim=0] - The number of posts to trim from the result.
90
+ * @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of posts to fetch.
91
+ * @return {Promise<Object>} The data of the saved posts.
92
+ */
93
+ static async getSavedPosts({ trim, limit }) {
95
94
  const { data } = await _request2.default.call(void 0, {
96
95
  method: "GET",
97
- url: `/posts/explore`,
96
+ url: `/posts/saved`,
98
97
  params: {
99
98
  trim: _nullishCoalesce(trim, () => ( 0)),
100
99
  limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
@@ -102,12 +101,19 @@ var _withSettings = require('../../helpers/withSettings'); var _withSettings2 =
102
101
  })
103
102
 
104
103
  return data
105
- }}
104
+ }
106
105
 
107
- static __initStatic8() {this.getSavedPosts = async ({ trim, limit }) => {
106
+ /**
107
+ * Retrieves the liked posts with optional trimming and limiting.
108
+ *
109
+ * @param {number} trim - The number of characters to trim the post content.
110
+ * @param {number} limit - The maximum number of liked posts to fetch.
111
+ * @return {Promise<Object>} The data of the liked posts.
112
+ */
113
+ static async getLikedPosts({ trim, limit }) {
108
114
  const { data } = await _request2.default.call(void 0, {
109
115
  method: "GET",
110
- url: `/posts/saved`,
116
+ url: `/posts/liked`,
111
117
  params: {
112
118
  trim: _nullishCoalesce(trim, () => ( 0)),
113
119
  limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
@@ -115,12 +121,21 @@ var _withSettings = require('../../helpers/withSettings'); var _withSettings2 =
115
121
  })
116
122
 
117
123
  return data
118
- }}
124
+ }
119
125
 
120
- static __initStatic9() {this.getUserPosts = async ({ user_id, trim, limit }) => {
126
+ /**
127
+ * Retrieves the posts of a user with optional trimming and limiting.
128
+ *
129
+ * @param {Object} options - The options for retrieving the user's posts.
130
+ * @param {string} options.user_id - The ID of the user whose posts to retrieve. If not provided, the current user's ID will be used.
131
+ * @param {number} [options.trim=0] - The number of characters to trim the post content.
132
+ * @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of posts to fetch.
133
+ * @return {Promise<Object>} The data of the user's posts.
134
+ */
135
+ static async getUserPosts({ user_id, trim, limit }) {
121
136
  if (!user_id) {
122
137
  // use current user_id
123
- user_id = _optionalChain([app, 'access', _3 => _3.userData, 'optionalAccess', _4 => _4._id])
138
+ user_id = _optionalChain([app, 'access', _ => _.userData, 'optionalAccess', _2 => _2._id])
124
139
  }
125
140
 
126
141
  const { data } = await _request2.default.call(void 0, {
@@ -133,9 +148,17 @@ var _withSettings = require('../../helpers/withSettings'); var _withSettings2 =
133
148
  })
134
149
 
135
150
  return data
136
- }}
151
+ }
137
152
 
138
- static __initStatic10() {this.toggleLike = async ({ post_id }) => {
153
+ /**
154
+ * Toggles the like status of a post.
155
+ *
156
+ * @param {Object} options - The options for toggling the like status.
157
+ * @param {string} options.post_id - The ID of the post to toggle the like status.
158
+ * @throws {Error} If the post_id is not provided.
159
+ * @return {Promise<Object>} The response data after toggling the like status.
160
+ */
161
+ static async toggleLike({ post_id }) {
139
162
  if (!post_id) {
140
163
  throw new Error("Post ID is required")
141
164
  }
@@ -146,9 +169,15 @@ var _withSettings = require('../../helpers/withSettings'); var _withSettings2 =
146
169
  })
147
170
 
148
171
  return data
149
- }}
172
+ }
150
173
 
151
- static __initStatic11() {this.toggleSave = async ({ post_id }) => {
174
+ /**
175
+ * Toggles the save status of a post.
176
+ *
177
+ * @param {string} post_id - The ID of the post to toggle the save status.
178
+ * @return {Promise<Object>} The response data after toggling the save status.
179
+ */
180
+ static async toggleSave({ post_id }) {
152
181
  if (!post_id) {
153
182
  throw new Error("Post ID is required")
154
183
  }
@@ -159,9 +188,15 @@ var _withSettings = require('../../helpers/withSettings'); var _withSettings2 =
159
188
  })
160
189
 
161
190
  return data
162
- }}
191
+ }
163
192
 
164
- static __initStatic12() {this.create = async (payload) => {
193
+ /**
194
+ * Creates a new post with the given payload.
195
+ *
196
+ * @param {Object} payload - The data to create the post with.
197
+ * @return {Promise<Object>} The response data after creating the post.
198
+ */
199
+ static async create(payload) {
165
200
  const { data } = await _request2.default.call(void 0, {
166
201
  method: "POST",
167
202
  url: `/posts/new`,
@@ -169,9 +204,37 @@ var _withSettings = require('../../helpers/withSettings'); var _withSettings2 =
169
204
  })
170
205
 
171
206
  return data
172
- }}
207
+ }
208
+
209
+ /**
210
+ * Updates a post with the given post ID and update payload.
211
+ *
212
+ * @param {string} post_id - The ID of the post to update.
213
+ * @param {Object} update - The data to update the post with.
214
+ * @throws {Error} If the post_id is not provided.
215
+ * @return {Promise<Object>} The response data after updating the post.
216
+ */
217
+ static async update(post_id, update) {
218
+ if (!post_id) {
219
+ throw new Error("Post ID is required")
220
+ }
221
+
222
+ const { data } = await _request2.default.call(void 0, {
223
+ method: "PUT",
224
+ url: `/posts/${post_id}/update`,
225
+ data: update,
226
+ })
227
+
228
+ return data
229
+ }
173
230
 
174
- static __initStatic13() {this.deletePost = async ({ post_id }) => {
231
+ /**
232
+ * Deletes a post with the given post ID.
233
+ *
234
+ * @param {string} post_id - The ID of the post to delete.
235
+ * @return {Object} The response data after deleting the post.
236
+ */
237
+ static async deletePost({ post_id }) {
175
238
  if (!post_id) {
176
239
  throw new Error("Post ID is required")
177
240
  }
@@ -182,5 +245,5 @@ var _withSettings = require('../../helpers/withSettings'); var _withSettings2 =
182
245
  })
183
246
 
184
247
  return data
185
- }}
186
- } Post.__initStatic(); Post.__initStatic2(); Post.__initStatic3(); Post.__initStatic4(); Post.__initStatic5(); Post.__initStatic6(); Post.__initStatic7(); Post.__initStatic8(); Post.__initStatic9(); Post.__initStatic10(); Post.__initStatic11(); Post.__initStatic12(); Post.__initStatic13(); exports.default = Post;
248
+ }
249
+ } exports.default = Post;
@@ -1,7 +1,14 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../handlers/request'); var _request2 = _interopRequireDefault(_request);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../request'); var _request2 = _interopRequireDefault(_request);
2
2
 
3
3
  class Search {
4
- static __initStatic() {this.search = async (keywords, params = {}) => {
4
+ /**
5
+ * Performs a search using the provided keywords and optional parameters.
6
+ *
7
+ * @param {string} keywords - The keywords to search for.
8
+ * @param {Object} [params={}] - Optional parameters for the search.
9
+ * @return {Promise<Object>} A promise that resolves with the search results.
10
+ */
11
+ static async search(keywords, params = {}) {
5
12
  const { data } = await _request2.default.call(void 0, {
6
13
  method: "GET",
7
14
  url: `/search`,
@@ -12,8 +19,14 @@
12
19
  })
13
20
 
14
21
  return data
15
- }}
22
+ }
16
23
 
24
+ /**
25
+ * Performs a quick search using the provided parameters.
26
+ *
27
+ * @param {Object} params - The parameters for the search.
28
+ * @return {Promise<Object>} A promise that resolves with the search results data.
29
+ */
17
30
  static async quickSearch(params) {
18
31
  const response = await _request2.default.call(void 0, {
19
32
  method: "GET",
@@ -23,4 +36,4 @@
23
36
 
24
37
  return response.data
25
38
  }
26
- } Search.__initStatic(); exports.default = Search;
39
+ } exports.default = Search;
@@ -1,73 +1,149 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _jwtdecode = require('jwt-decode'); var _jwtdecode2 = _interopRequireDefault(_jwtdecode);
2
- var _request = require('../../handlers/request'); var _request2 = _interopRequireDefault(_request);
2
+ var _request = require('../../request'); var _request2 = _interopRequireDefault(_request);
3
3
  var _withStorage = require('../../helpers/withStorage'); var _withStorage2 = _interopRequireDefault(_withStorage);
4
4
 
5
5
  class Session {
6
6
  static __initStatic() {this.storageTokenKey = "token"}
7
+ static __initStatic2() {this.storageRefreshTokenKey = "refreshToken"}
7
8
 
9
+ /**
10
+ * Retrieves the token from the storage engine.
11
+ *
12
+ * @return {type} description of return value
13
+ */
8
14
  static get token() {
9
15
  return _withStorage2.default.engine.get(this.storageTokenKey)
10
16
  }
11
17
 
18
+ /**
19
+ * Sets the token in the storage engine.
20
+ *
21
+ * @param {string} token - The token to be set.
22
+ * @return {Promise<void>} A promise that resolves when the token is successfully set.
23
+ */
12
24
  static set token(token) {
13
25
  return _withStorage2.default.engine.set(this.storageTokenKey, token)
14
26
  }
15
27
 
28
+ /**
29
+ * Retrieves the refresh token from the storage engine.
30
+ *
31
+ * @return {string} The refresh token stored in the storage engine.
32
+ */
33
+ static get refreshToken() {
34
+ return _withStorage2.default.engine.get(this.storageRefreshTokenKey)
35
+ }
36
+
37
+ /**
38
+ * Sets the refresh token in the storage engine.
39
+ *
40
+ * @param {string} token - The refresh token to be set.
41
+ * @return {Promise<void>} A promise that resolves when the refresh token is successfully set.
42
+ */
43
+ static set refreshToken(token) {
44
+ return _withStorage2.default.engine.set(this.storageRefreshTokenKey, token)
45
+ }
46
+
47
+ /**
48
+ * Retrieves the roles from the decoded token object.
49
+ *
50
+ * @return {Array<string>|undefined} The roles if they exist, otherwise undefined.
51
+ */
16
52
  static get roles() {
17
53
  return _optionalChain([this, 'access', _ => _.getDecodedToken, 'call', _2 => _2(), 'optionalAccess', _3 => _3.roles])
18
54
  }
19
55
 
56
+ /**
57
+ * Retrieves the user ID from the decoded token object.
58
+ *
59
+ * @return {string|undefined} The user ID if it exists, otherwise undefined.
60
+ */
20
61
  static get user_id() {
21
62
  return _optionalChain([this, 'access', _4 => _4.getDecodedToken, 'call', _5 => _5(), 'optionalAccess', _6 => _6.user_id])
22
63
  }
23
64
 
65
+ /**
66
+ * Retrieves the session UUID from the decoded token object.
67
+ *
68
+ * @return {string} The session UUID if it exists, otherwise undefined.
69
+ */
24
70
  static get session_uuid() {
25
71
  return _optionalChain([this, 'access', _7 => _7.getDecodedToken, 'call', _8 => _8(), 'optionalAccess', _9 => _9.session_uuid])
26
72
  }
27
73
 
28
- static __initStatic2() {this.getDecodedToken = () => {
74
+ /**
75
+ * Retrieves the decoded token from the session storage.
76
+ *
77
+ * @return {Object|null} The decoded token object if it exists, otherwise null.
78
+ */
79
+ static getDecodedToken() {
29
80
  const token = this.token
30
81
 
31
82
  return token && _jwtdecode2.default.call(void 0, token)
32
- }}
83
+ }
33
84
 
34
- static __initStatic3() {this.getAllSessions = async () => {
85
+ /**
86
+ * Removes the token from the storage engine.
87
+ *
88
+ * @return {Promise<void>} A promise that resolves when the token is successfully removed.
89
+ */
90
+ static removeToken() {
91
+ return _withStorage2.default.engine.remove(Session.storageTokenKey)
92
+ }
93
+
94
+ /**
95
+ * Retrieves all sessions from the server.
96
+ *
97
+ * @return {Promise<Object>} The data of all sessions.
98
+ */
99
+ static async getAllSessions() {
35
100
  const response = await _request2.default.call(void 0, {
36
101
  method: "get",
37
- url: "/session/all"
102
+ url: "/sessions/all"
38
103
  })
39
104
 
40
105
  return response.data
41
- }}
106
+ }
42
107
 
43
- static __initStatic4() {this.getCurrentSession = async () => {
108
+ /**
109
+ * Retrieves the current session from the server.
110
+ *
111
+ * @return {Promise<Object>} The data of the current session.
112
+ */
113
+ static async getCurrentSession() {
44
114
  const response = await _request2.default.call(void 0, {
45
115
  method: "get",
46
- url: "/session/current"
116
+ url: "/sessions/current"
47
117
  })
48
118
 
49
119
  return response.data
50
- }}
120
+ }
51
121
 
52
- static __initStatic5() {this.getTokenValidation = async () => {
122
+ /**
123
+ * Retrieves the token validation data from the server.
124
+ *
125
+ * @return {Promise<Object>} The token validation data.
126
+ */
127
+ static async getTokenValidation() {
53
128
  const session = await Session.token
54
129
 
55
130
  const response = await _request2.default.call(void 0, {
56
131
  method: "get",
57
- url: "/session/validate",
132
+ url: "/sessions/validate",
58
133
  data: {
59
134
  session: session
60
135
  }
61
136
  })
62
137
 
63
138
  return response.data
64
- }}
65
-
66
- static removeToken() {
67
- return _withStorage2.default.engine.remove(Session.storageTokenKey)
68
139
  }
69
140
 
70
- static __initStatic6() {this.destroyCurrentSession = async () => {
141
+ /**
142
+ * Destroys the current session by deleting it from the server.
143
+ *
144
+ * @return {Promise<Object>} The response data from the server after deleting the session.
145
+ */
146
+ static async destroyCurrentSession() {
71
147
  const token = await Session.token
72
148
  const session = await Session.getDecodedToken()
73
149
 
@@ -77,7 +153,7 @@ var _withStorage = require('../../helpers/withStorage'); var _withStorage2 = _in
77
153
 
78
154
  const response = await _request2.default.call(void 0, {
79
155
  method: "delete",
80
- url: "/session/current"
156
+ url: "/sessions/current"
81
157
  }).catch((error) => {
82
158
  console.error(error)
83
159
 
@@ -89,47 +165,20 @@ var _withStorage = require('../../helpers/withStorage'); var _withStorage2 = _in
89
165
  __comty_shared_state.eventBus.emit("session.destroyed")
90
166
 
91
167
  return response.data
92
- }}
93
-
94
- static __initStatic7() {this.destroyAllSessions = async () => {
95
- const session = await Session.getDecodedToken()
96
-
97
- if (!session) {
98
- return false
99
- }
100
-
101
- const response = await _request2.default.call(void 0, {
102
- method: "delete",
103
- url: "/session/all"
104
- })
105
-
106
- Session.removeToken()
107
-
108
- __comty_shared_state.eventBus.emit("session.destroyed")
109
-
110
- return response.data
111
- }}
112
-
113
- // alias for validateToken method
114
- static __initStatic8() {this.validSession = async (token) => {
115
- return await Session.validateToken(token)
116
- }}
117
-
118
- static __initStatic9() {this.validateToken = async (token) => {
119
- const response = await _request2.default.call(void 0, {
120
- method: "post",
121
- url: "/session/validate",
122
- data: {
123
- token: token
124
- }
125
- })
168
+ }
126
169
 
127
- return response.data
128
- }}
170
+ static async destroyAllSessions() {
171
+ throw new Error("Not implemented")
172
+ }
129
173
 
130
- static __initStatic10() {this.isCurrentTokenValid = async () => {
174
+ /**
175
+ * Retrieves the validity of the current token.
176
+ *
177
+ * @return {boolean} The validity status of the current token.
178
+ */
179
+ static async isCurrentTokenValid() {
131
180
  const health = await Session.getTokenValidation()
132
181
 
133
182
  return health.valid
134
- }}
135
- } Session.__initStatic(); Session.__initStatic2(); Session.__initStatic3(); Session.__initStatic4(); Session.__initStatic5(); Session.__initStatic6(); Session.__initStatic7(); Session.__initStatic8(); Session.__initStatic9(); Session.__initStatic10(); exports.default = Session;
183
+ }
184
+ } Session.__initStatic(); Session.__initStatic2(); exports.default = Session;
File without changes
@@ -1,30 +1,24 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _spotify = require('./services/spotify'); var _spotify2 = _interopRequireDefault(_spotify);
2
2
  var _tidal = require('./services/tidal'); var _tidal2 = _interopRequireDefault(_tidal);
3
- var _vrc = require('./services/vrc'); var _vrc2 = _interopRequireDefault(_vrc);
4
3
 
5
- var _request = require('../../handlers/request'); var _request2 = _interopRequireDefault(_request);
4
+ var _request = require('../../request'); var _request2 = _interopRequireDefault(_request);
6
5
 
7
- const sync_services = {
6
+ const namespacesServices = {
8
7
  spotify: _spotify2.default,
9
- tidal: _tidal2.default,
10
- vrc: _vrc2.default,
8
+ tidal: _tidal2.default
11
9
  }
12
10
 
13
11
  class SyncModel {
14
12
  static get spotifyCore() {
15
- return sync_services.spotify
13
+ return namespacesServices.spotify
16
14
  }
17
15
 
18
16
  static get tidalCore() {
19
- return sync_services.tidal
20
- }
21
-
22
- static get vrcCore() {
23
- return sync_services.vrc
17
+ return namespacesServices.tidal
24
18
  }
25
19
 
26
20
  static async linkService(namespace) {
27
- const service = sync_services[namespace]
21
+ const service = namespacesServices[namespace]
28
22
 
29
23
  if (!service || typeof service.linkAccount !== "function") {
30
24
  throw new Error(`Service ${namespace} not found or not accepting linking.`)
@@ -34,7 +28,7 @@ const sync_services = {
34
28
  }
35
29
 
36
30
  static async unlinkService(namespace) {
37
- const service = sync_services[namespace]
31
+ const service = namespacesServices[namespace]
38
32
 
39
33
  if (!service || typeof service.unlinkAccount !== "function") {
40
34
  throw new Error(`Service ${namespace} not found or not accepting unlinking.`)
@@ -44,7 +38,7 @@ const sync_services = {
44
38
  }
45
39
 
46
40
  static async hasServiceLinked(namespace) {
47
- const service = sync_services[namespace]
41
+ const service = namespacesServices[namespace]
48
42
 
49
43
  if (!service || typeof service.isActive !== "function") {
50
44
  throw new Error(`Service ${namespace} not found or not accepting linking.`)
@@ -55,7 +49,7 @@ const sync_services = {
55
49
 
56
50
  static async getLinkedServices() {
57
51
  const response = await _request2.default.call(void 0, {
58
- instance: globalThis.__comty_shared_state.instances["sync"],
52
+ instance: globalThis.__comty_shared_state.instances["sync"],
59
53
  method: "GET",
60
54
  url: "/active_services",
61
55
  })
File without changes
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../../handlers/request'); var _request2 = _interopRequireDefault(_request);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../../request'); var _request2 = _interopRequireDefault(_request);
2
2
 
3
3
  class TidalService {
4
4
  static get api_instance() {
File without changes