musora-content-services 1.3.15 → 1.3.16
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/CHANGELOG.md +2 -0
- package/package.json +1 -1
- package/src/filterBuilder.js +0 -0
- package/src/index.d.ts +20 -0
- package/src/index.js +20 -0
- package/src/services/config.js +0 -0
- package/src/services/dataContext.js +0 -0
- package/src/services/railcontent.js +121 -8
- package/src/services/recommendations.js +3 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.3.16](https://github.com/railroadmedia/musora-content-services/compare/v1.3.15...v1.3.16) (2025-03-14)
|
|
6
|
+
|
|
5
7
|
### [1.3.15](https://github.com/railroadmedia/musora-content-services/compare/v1.3.14...v1.3.15) (2025-03-10)
|
|
6
8
|
|
|
7
9
|
### [1.3.14](https://github.com/railroadmedia/musora-content-services/compare/v1.3.13...v1.3.14) (2025-03-06)
|
package/package.json
CHANGED
package/src/filterBuilder.js
CHANGED
|
File without changes
|
package/src/index.d.ts
CHANGED
|
@@ -38,12 +38,17 @@ import {
|
|
|
38
38
|
|
|
39
39
|
import {
|
|
40
40
|
addItemToPlaylist,
|
|
41
|
+
assignModeratorToComment,
|
|
42
|
+
closeComment,
|
|
41
43
|
countAssignmentsAndLessons,
|
|
44
|
+
createComment,
|
|
42
45
|
createPlaylist,
|
|
46
|
+
deleteComment,
|
|
43
47
|
deletePlaylist,
|
|
44
48
|
deletePlaylistItem,
|
|
45
49
|
deletePlaylistLike,
|
|
46
50
|
duplicatePlaylist,
|
|
51
|
+
editComment,
|
|
47
52
|
fetchAllCompletedStates,
|
|
48
53
|
fetchCarouselCardData,
|
|
49
54
|
fetchChallengeIndexMetadata,
|
|
@@ -73,7 +78,9 @@ import {
|
|
|
73
78
|
fetchUserLikes,
|
|
74
79
|
fetchUserPermissionsData,
|
|
75
80
|
fetchUserPlaylists,
|
|
81
|
+
likeComment,
|
|
76
82
|
likePlaylist,
|
|
83
|
+
openComment,
|
|
77
84
|
pinPlaylist,
|
|
78
85
|
playback,
|
|
79
86
|
postChallengesCommunityNotification,
|
|
@@ -90,8 +97,11 @@ import {
|
|
|
90
97
|
postContentReset,
|
|
91
98
|
postContentUnliked,
|
|
92
99
|
postRecordWatchSession,
|
|
100
|
+
replyToComment,
|
|
93
101
|
reportPlaylist,
|
|
94
102
|
setStudentViewForUser,
|
|
103
|
+
unassignModeratorToComment,
|
|
104
|
+
unlikeComment,
|
|
95
105
|
unpinPlaylist,
|
|
96
106
|
updatePlaylist,
|
|
97
107
|
updatePlaylistItem
|
|
@@ -155,16 +165,21 @@ import {
|
|
|
155
165
|
declare module 'musora-content-services' {
|
|
156
166
|
export {
|
|
157
167
|
addItemToPlaylist,
|
|
168
|
+
assignModeratorToComment,
|
|
158
169
|
assignmentStatusCompleted,
|
|
159
170
|
assignmentStatusReset,
|
|
171
|
+
closeComment,
|
|
160
172
|
contentStatusCompleted,
|
|
161
173
|
contentStatusReset,
|
|
162
174
|
countAssignmentsAndLessons,
|
|
175
|
+
createComment,
|
|
163
176
|
createPlaylist,
|
|
177
|
+
deleteComment,
|
|
164
178
|
deletePlaylist,
|
|
165
179
|
deletePlaylistItem,
|
|
166
180
|
deletePlaylistLike,
|
|
167
181
|
duplicatePlaylist,
|
|
182
|
+
editComment,
|
|
168
183
|
fetchAll,
|
|
169
184
|
fetchAllCompletedStates,
|
|
170
185
|
fetchAllFilterOptions,
|
|
@@ -247,8 +262,10 @@ declare module 'musora-content-services' {
|
|
|
247
262
|
initializeService,
|
|
248
263
|
isContentLiked,
|
|
249
264
|
jumpToContinueContent,
|
|
265
|
+
likeComment,
|
|
250
266
|
likeContent,
|
|
251
267
|
likePlaylist,
|
|
268
|
+
openComment,
|
|
252
269
|
pinPlaylist,
|
|
253
270
|
playback,
|
|
254
271
|
postChallengesCommunityNotification,
|
|
@@ -268,11 +285,14 @@ declare module 'musora-content-services' {
|
|
|
268
285
|
rankCategories,
|
|
269
286
|
rankItems,
|
|
270
287
|
recordWatchSession,
|
|
288
|
+
replyToComment,
|
|
271
289
|
reportPlaylist,
|
|
272
290
|
reset,
|
|
273
291
|
setLastUpdatedTime,
|
|
274
292
|
setStudentViewForUser,
|
|
275
293
|
similarItems,
|
|
294
|
+
unassignModeratorToComment,
|
|
295
|
+
unlikeComment,
|
|
276
296
|
unlikeContent,
|
|
277
297
|
unpinPlaylist,
|
|
278
298
|
updatePlaylist,
|
package/src/index.js
CHANGED
|
@@ -38,12 +38,17 @@ import {
|
|
|
38
38
|
|
|
39
39
|
import {
|
|
40
40
|
addItemToPlaylist,
|
|
41
|
+
assignModeratorToComment,
|
|
42
|
+
closeComment,
|
|
41
43
|
countAssignmentsAndLessons,
|
|
44
|
+
createComment,
|
|
42
45
|
createPlaylist,
|
|
46
|
+
deleteComment,
|
|
43
47
|
deletePlaylist,
|
|
44
48
|
deletePlaylistItem,
|
|
45
49
|
deletePlaylistLike,
|
|
46
50
|
duplicatePlaylist,
|
|
51
|
+
editComment,
|
|
47
52
|
fetchAllCompletedStates,
|
|
48
53
|
fetchCarouselCardData,
|
|
49
54
|
fetchChallengeIndexMetadata,
|
|
@@ -73,7 +78,9 @@ import {
|
|
|
73
78
|
fetchUserLikes,
|
|
74
79
|
fetchUserPermissionsData,
|
|
75
80
|
fetchUserPlaylists,
|
|
81
|
+
likeComment,
|
|
76
82
|
likePlaylist,
|
|
83
|
+
openComment,
|
|
77
84
|
pinPlaylist,
|
|
78
85
|
playback,
|
|
79
86
|
postChallengesCommunityNotification,
|
|
@@ -90,8 +97,11 @@ import {
|
|
|
90
97
|
postContentReset,
|
|
91
98
|
postContentUnliked,
|
|
92
99
|
postRecordWatchSession,
|
|
100
|
+
replyToComment,
|
|
93
101
|
reportPlaylist,
|
|
94
102
|
setStudentViewForUser,
|
|
103
|
+
unassignModeratorToComment,
|
|
104
|
+
unlikeComment,
|
|
95
105
|
unpinPlaylist,
|
|
96
106
|
updatePlaylist,
|
|
97
107
|
updatePlaylistItem
|
|
@@ -154,16 +164,21 @@ import {
|
|
|
154
164
|
|
|
155
165
|
export {
|
|
156
166
|
addItemToPlaylist,
|
|
167
|
+
assignModeratorToComment,
|
|
157
168
|
assignmentStatusCompleted,
|
|
158
169
|
assignmentStatusReset,
|
|
170
|
+
closeComment,
|
|
159
171
|
contentStatusCompleted,
|
|
160
172
|
contentStatusReset,
|
|
161
173
|
countAssignmentsAndLessons,
|
|
174
|
+
createComment,
|
|
162
175
|
createPlaylist,
|
|
176
|
+
deleteComment,
|
|
163
177
|
deletePlaylist,
|
|
164
178
|
deletePlaylistItem,
|
|
165
179
|
deletePlaylistLike,
|
|
166
180
|
duplicatePlaylist,
|
|
181
|
+
editComment,
|
|
167
182
|
fetchAll,
|
|
168
183
|
fetchAllCompletedStates,
|
|
169
184
|
fetchAllFilterOptions,
|
|
@@ -246,8 +261,10 @@ export {
|
|
|
246
261
|
initializeService,
|
|
247
262
|
isContentLiked,
|
|
248
263
|
jumpToContinueContent,
|
|
264
|
+
likeComment,
|
|
249
265
|
likeContent,
|
|
250
266
|
likePlaylist,
|
|
267
|
+
openComment,
|
|
251
268
|
pinPlaylist,
|
|
252
269
|
playback,
|
|
253
270
|
postChallengesCommunityNotification,
|
|
@@ -267,11 +284,14 @@ export {
|
|
|
267
284
|
rankCategories,
|
|
268
285
|
rankItems,
|
|
269
286
|
recordWatchSession,
|
|
287
|
+
replyToComment,
|
|
270
288
|
reportPlaylist,
|
|
271
289
|
reset,
|
|
272
290
|
setLastUpdatedTime,
|
|
273
291
|
setStudentViewForUser,
|
|
274
292
|
similarItems,
|
|
293
|
+
unassignModeratorToComment,
|
|
294
|
+
unlikeComment,
|
|
275
295
|
unlikeContent,
|
|
276
296
|
unpinPlaylist,
|
|
277
297
|
updatePlaylist,
|
package/src/services/config.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -290,6 +290,10 @@ async function patchDataHandler(url, data) {
|
|
|
290
290
|
return fetchHandler(url, 'patch', null, data)
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
+
async function deleteDataHandler(url, data) {
|
|
294
|
+
return fetchHandler(url, 'delete')
|
|
295
|
+
}
|
|
296
|
+
|
|
293
297
|
export async function fetchHandler(url, method = 'get', dataVersion = null, body = null) {
|
|
294
298
|
let headers = {
|
|
295
299
|
'Content-Type': 'application/json',
|
|
@@ -1206,28 +1210,28 @@ export async function setStudentViewForUser(userId, enable) {
|
|
|
1206
1210
|
* @returns {Promise<Object|null>} - A promise that resolves to an comment object
|
|
1207
1211
|
*/
|
|
1208
1212
|
export async function fetchTopComment(railcontentId) {
|
|
1209
|
-
const url = `/api/content/v1/comments/${railcontentId}/top`
|
|
1213
|
+
const url = `/api/content/v1/comments/content/${railcontentId}/top`
|
|
1210
1214
|
return await fetchHandler(url)
|
|
1211
1215
|
}
|
|
1212
1216
|
|
|
1213
1217
|
|
|
1214
1218
|
/**
|
|
1215
1219
|
*
|
|
1216
|
-
* @param railcontentId
|
|
1217
|
-
* @param page
|
|
1218
|
-
* @param limit
|
|
1220
|
+
* @param {int} railcontentId
|
|
1221
|
+
* @param {int} page
|
|
1222
|
+
* @param {int} limit
|
|
1219
1223
|
* @returns {Promise<*|null>}
|
|
1220
1224
|
*/
|
|
1221
1225
|
export async function fetchComments(railcontentId, page = 1, limit = 20) {
|
|
1222
|
-
const url = `/api/content/v1/comments/${railcontentId}/all?page=${page}&limit=${limit}`
|
|
1226
|
+
const url = `/api/content/v1/comments/content/${railcontentId}/all?page=${page}&limit=${limit}`
|
|
1223
1227
|
return await fetchHandler(url)
|
|
1224
1228
|
}
|
|
1225
1229
|
|
|
1226
1230
|
/**
|
|
1227
1231
|
*
|
|
1228
|
-
* @param commentId
|
|
1229
|
-
* @param page
|
|
1230
|
-
* @param limit
|
|
1232
|
+
* @param {int} commentId
|
|
1233
|
+
* @param {int} page
|
|
1234
|
+
* @param {int} limit
|
|
1231
1235
|
* @returns {Promise<*|null>}
|
|
1232
1236
|
*/
|
|
1233
1237
|
export async function fetchCommentRelies(commentId, page = 1, limit = 20) {
|
|
@@ -1235,6 +1239,115 @@ export async function fetchCommentRelies(commentId, page = 1, limit = 20) {
|
|
|
1235
1239
|
return await fetchHandler(url)
|
|
1236
1240
|
}
|
|
1237
1241
|
|
|
1242
|
+
/**
|
|
1243
|
+
* @param {int} commentId
|
|
1244
|
+
* @returns {Promise<*|null>}
|
|
1245
|
+
*/
|
|
1246
|
+
export async function deleteComment(commentId) {
|
|
1247
|
+
const url = `/api/content/v1/comments/${commentId}`
|
|
1248
|
+
return await fetchHandler(url, "DELETE")
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
/**
|
|
1252
|
+
* @param {int} commentId
|
|
1253
|
+
* @param {string} comment
|
|
1254
|
+
* @returns {Promise<*|null>}
|
|
1255
|
+
*/
|
|
1256
|
+
export async function replyToComment(commentId, comment) {
|
|
1257
|
+
const data = {'comment' : comment}
|
|
1258
|
+
const url = `/api/content/v1/comments/${commentId}/reply`
|
|
1259
|
+
return await postDataHandler(url, data)
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
/**
|
|
1263
|
+
* @param {int} railcontentId
|
|
1264
|
+
* @param {string} comment
|
|
1265
|
+
* @returns {Promise<*|null>}
|
|
1266
|
+
*/
|
|
1267
|
+
export async function createComment(railcontentId, comment) {
|
|
1268
|
+
const data = {
|
|
1269
|
+
'comment' : comment,
|
|
1270
|
+
'content_id' : railcontentId
|
|
1271
|
+
}
|
|
1272
|
+
const url = `/api/content/v1/comments/store`
|
|
1273
|
+
return await postDataHandler(url, data)
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* @param {int} commentId
|
|
1278
|
+
* @returns {Promise<*|null>}
|
|
1279
|
+
*/
|
|
1280
|
+
export async function assignModeratorToComment(commentId) {
|
|
1281
|
+
const url = `/api/content/v1/comments/${commentId}/assign_moderator`
|
|
1282
|
+
return await postDataHandler(url)
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* @param {int} commentId
|
|
1287
|
+
* @returns {Promise<*|null>}
|
|
1288
|
+
*/
|
|
1289
|
+
export async function unassignModeratorToComment(commentId) {
|
|
1290
|
+
const url = `/api/content/v1/comments/${commentId}/unassign_moderator`
|
|
1291
|
+
return await postDataHandler(url)
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
/**
|
|
1295
|
+
* @param {int} commentId
|
|
1296
|
+
* @returns {Promise<*|null>}
|
|
1297
|
+
*/
|
|
1298
|
+
export async function likeComment(commentId) {
|
|
1299
|
+
const url = `/api/content/v1/comments/${commentId}/like`
|
|
1300
|
+
return await postDataHandler(url)
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
/**
|
|
1304
|
+
* @param {int} commentId
|
|
1305
|
+
* @returns {Promise<*|null>}
|
|
1306
|
+
*/
|
|
1307
|
+
export async function unlikeComment(commentId) {
|
|
1308
|
+
const url = `/api/content/v1/comments/${commentId}/like`
|
|
1309
|
+
return await deleteDataHandler(url)
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* @param {int} commentId
|
|
1314
|
+
* @returns {Promise<*|null>}
|
|
1315
|
+
*/
|
|
1316
|
+
export async function closeComment(commentId) {
|
|
1317
|
+
const url = `/api/content/v1/comments/${commentId}`
|
|
1318
|
+
const data = {
|
|
1319
|
+
'conversation_status' : 'closed'
|
|
1320
|
+
}
|
|
1321
|
+
return await patchDataHandler(url, data)
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
/**
|
|
1325
|
+
* @param {int} commentId
|
|
1326
|
+
* @returns {Promise<*|null>}
|
|
1327
|
+
*/
|
|
1328
|
+
export async function openComment(commentId) {
|
|
1329
|
+
const url = `/api/content/v1/comments/${commentId}`
|
|
1330
|
+
const data = {
|
|
1331
|
+
'conversation_status' : 'open'
|
|
1332
|
+
}
|
|
1333
|
+
return await patchDataHandler(url, data)
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
/**
|
|
1337
|
+
* @param {int} commentId
|
|
1338
|
+
* @param {string} comment
|
|
1339
|
+
* @returns {Promise<*|null>}
|
|
1340
|
+
*/
|
|
1341
|
+
export async function editComment(commentId, comment) {
|
|
1342
|
+
const url = `/api/content/v1/comments/${commentId}`
|
|
1343
|
+
const data = {
|
|
1344
|
+
'comment' : comment
|
|
1345
|
+
}
|
|
1346
|
+
return await patchDataHandler(url, data)
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
|
|
1238
1351
|
function fetchAbsolute(url, params) {
|
|
1239
1352
|
if (globalConfig.railcontentConfig.authToken) {
|
|
1240
1353
|
params.headers['Authorization'] = `Bearer ${globalConfig.railcontentConfig.authToken}`
|
|
@@ -48,8 +48,7 @@ export async function similarItems(brand, content_id, count = 10) {
|
|
|
48
48
|
*
|
|
49
49
|
* @param {brand} brand - brand of the content to filter
|
|
50
50
|
* @param {Object} categories - Keyed arrays of content ids
|
|
51
|
-
* @
|
|
52
|
-
* @returns {Promise<Object|null>} - Returns the content_ids sorted by rank (most significant first)
|
|
51
|
+
* @returns {Promise<Object|null>} - Returns the content_ids sorted by rank (most significant first), elements in each category are also ranked
|
|
53
52
|
* @example
|
|
54
53
|
* rankCategories('drumeo', {
|
|
55
54
|
* 1: [111222, 23120, 402199],
|
|
@@ -59,7 +58,7 @@ export async function similarItems(brand, content_id, count = 10) {
|
|
|
59
58
|
* .then(status => console.log(status))
|
|
60
59
|
* .catch(error => console.error(error));
|
|
61
60
|
*/
|
|
62
|
-
export async function rankCategories(brand, categories
|
|
61
|
+
export async function rankCategories(brand, categories) {
|
|
63
62
|
if (categories.length === 0) {
|
|
64
63
|
return []
|
|
65
64
|
}
|
|
@@ -67,9 +66,8 @@ export async function rankCategories(brand, categories, rankEachCategory = true)
|
|
|
67
66
|
'brand': brand,
|
|
68
67
|
'user_id': globalConfig.railcontentConfig.userId,
|
|
69
68
|
'playlists': categories,
|
|
70
|
-
'rank_each_list': Boolean(rankEachCategory),
|
|
71
69
|
}
|
|
72
|
-
const url = `/
|
|
70
|
+
const url = `/rank_each_list/`
|
|
73
71
|
try {
|
|
74
72
|
const response = await fetchHandler(url, 'POST', data)
|
|
75
73
|
let rankedCategories = {}
|