musora-content-services 2.15.0 → 2.16.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.
Files changed (52) hide show
  1. package/.github/workflows/node.js.yml +0 -0
  2. package/.prettierignore +0 -0
  3. package/.prettierrc +0 -0
  4. package/CHANGELOG.md +10 -0
  5. package/babel.config.cjs +0 -0
  6. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  7. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  8. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  9. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  10. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  11. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  12. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  13. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  14. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  15. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -0
  16. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  17. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  18. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  19. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  20. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -0
  21. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  22. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  23. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  24. package/docs/scripts/collapse.js +0 -0
  25. package/docs/scripts/commonNav.js +0 -0
  26. package/docs/scripts/linenumber.js +0 -0
  27. package/docs/scripts/nav.js +0 -0
  28. package/docs/scripts/polyfill.js +0 -0
  29. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -0
  30. package/docs/scripts/prettify/lang-css.js +0 -0
  31. package/docs/scripts/prettify/prettify.js +0 -0
  32. package/docs/scripts/search.js +0 -0
  33. package/docs/styles/jsdoc.css +0 -0
  34. package/docs/styles/prettify.css +0 -0
  35. package/jest.config.js +0 -0
  36. package/link_mcs.sh +0 -0
  37. package/package.json +1 -1
  38. package/src/contentTypeConfig.js +4 -3
  39. package/src/index.d.ts +10 -2
  40. package/src/index.js +10 -2
  41. package/src/services/content-org/guided-courses.ts +20 -0
  42. package/src/services/contentAggregator.js +2 -2
  43. package/src/services/contentProgress.js +1 -1
  44. package/src/services/userActivity.js +13 -19
  45. package/test/dataContext.test.js +0 -0
  46. package/test/imageSRCBuilder.test.js +0 -0
  47. package/test/imageSRCVerify.test.js +0 -0
  48. package/test/live/contentProgressLive.test.js +0 -0
  49. package/test/live/railcontentLive.test.js +0 -0
  50. package/test/localStorageMock.js +0 -0
  51. package/test/log.js +0 -0
  52. package/.yarnrc.yml +0 -1
File without changes
package/.prettierignore CHANGED
File without changes
package/.prettierrc CHANGED
File without changes
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
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
+ ## [2.16.0](https://github.com/railroadmedia/musora-content-services/compare/v2.15.1...v2.16.0) (2025-07-04)
6
+
7
+
8
+ ### Features
9
+
10
+ * media type id updates ([d005e51](https://github.com/railroadmedia/musora-content-services/commit/d005e5190e384ae352c2011d18a1ae5eb0a8272a))
11
+ * remove console in contentAggregator ([3e9bf97](https://github.com/railroadmedia/musora-content-services/commit/3e9bf97bfc45775a4c66e5be9714ec327ab1592b))
12
+
13
+ ### [2.15.1](https://github.com/railroadmedia/musora-content-services/compare/v2.15.0...v2.15.1) (2025-07-01)
14
+
5
15
  ## [2.15.0](https://github.com/railroadmedia/musora-content-services/compare/v2.12.0...v2.15.0) (2025-07-01)
6
16
 
7
17
 
package/babel.config.cjs CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/jest.config.js CHANGED
File without changes
package/link_mcs.sh CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "2.15.0",
3
+ "version": "2.16.0",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -154,11 +154,12 @@ export const individualLessonsTypes = [
154
154
  ...studentArchivesLessonTypes
155
155
  ];
156
156
 
157
- export const coursesLessonTypes = ['course', 'pack','spotlight'];
157
+ export const coursesLessonTypes = ['course', 'pack','spotlight', 'guided-course'];
158
158
  export const showsLessonTypes = ['diy-drum-experiment','exploring-beats','in-rhythm', 'rhythmic-adventures-of-captain-carson','rhythms-from-another-planet','study-the-greats'];
159
159
  export const collectionLessonTypes = [
160
160
  ...coursesLessonTypes,
161
- ...showsLessonTypes
161
+ ...showsLessonTypes,
162
+ 'song-tutorial',
162
163
  ];
163
164
 
164
165
  export const lessonTypesMapping = {
@@ -187,7 +188,7 @@ export const progressTypesMapping = {
187
188
  'song tutorial': tutorialsLessonTypes,
188
189
  'songs': transcriptionsLessonTypes,
189
190
  'play-along': playAlongLessonTypes,
190
- 'guided course': ['challenge'],
191
+ 'guided course': ['guided-course'],
191
192
  'pack': ['pack', 'semester-pack'],
192
193
  'method': ['learning-path']
193
194
  };
package/src/index.d.ts CHANGED
@@ -8,8 +8,12 @@ import {
8
8
  import {
9
9
  enrollUserInGuidedCourse,
10
10
  fetchEnrollmentPageMetadata,
11
- unEnrollUserInGuidedCourse
12
- } from './services/content-org/guided-courses.js';
11
+ guidedCourses,
12
+ pinGuidedCourse,
13
+ pinnedGuidedCourses,
14
+ unEnrollUserInGuidedCourse,
15
+ unPinGuidedCourse
16
+ } from './services/content-org/guided-courses.ts';
13
17
 
14
18
  import {
15
19
  addItemToPlaylist,
@@ -439,6 +443,7 @@ declare module 'musora-content-services' {
439
443
  getUserWeeklyStats,
440
444
  getWeekNumber,
441
445
  globalConfig,
446
+ guidedCourses,
442
447
  initializeService,
443
448
  isBucketUrl,
444
449
  isContentLiked,
@@ -459,7 +464,9 @@ declare module 'musora-content-services' {
459
464
  markNotificationAsUnread,
460
465
  openComment,
461
466
  otherStats,
467
+ pinGuidedCourse,
462
468
  pinProgressRow,
469
+ pinnedGuidedCourses,
463
470
  postChallengesCommunityNotification,
464
471
  postChallengesEnroll,
465
472
  postChallengesEnrollmentNotification,
@@ -493,6 +500,7 @@ declare module 'musora-content-services' {
493
500
  setStudentViewForUser,
494
501
  togglePlaylistPrivate,
495
502
  unEnrollUserInGuidedCourse,
503
+ unPinGuidedCourse,
496
504
  unassignModeratorToComment,
497
505
  unblockUser,
498
506
  undeletePlaylist,
package/src/index.js CHANGED
@@ -8,8 +8,12 @@ import {
8
8
  import {
9
9
  enrollUserInGuidedCourse,
10
10
  fetchEnrollmentPageMetadata,
11
- unEnrollUserInGuidedCourse
12
- } from './services/content-org/guided-courses.js';
11
+ guidedCourses,
12
+ pinGuidedCourse,
13
+ pinnedGuidedCourses,
14
+ unEnrollUserInGuidedCourse,
15
+ unPinGuidedCourse
16
+ } from './services/content-org/guided-courses.ts';
13
17
 
14
18
  import {
15
19
  addItemToPlaylist,
@@ -438,6 +442,7 @@ export {
438
442
  getUserWeeklyStats,
439
443
  getWeekNumber,
440
444
  globalConfig,
445
+ guidedCourses,
441
446
  initializeService,
442
447
  isBucketUrl,
443
448
  isContentLiked,
@@ -458,7 +463,9 @@ export {
458
463
  markNotificationAsUnread,
459
464
  openComment,
460
465
  otherStats,
466
+ pinGuidedCourse,
461
467
  pinProgressRow,
468
+ pinnedGuidedCourses,
462
469
  postChallengesCommunityNotification,
463
470
  postChallengesEnroll,
464
471
  postChallengesEnrollmentNotification,
@@ -492,6 +499,7 @@ export {
492
499
  setStudentViewForUser,
493
500
  togglePlaylistPrivate,
494
501
  unEnrollUserInGuidedCourse,
502
+ unPinGuidedCourse,
495
503
  unassignModeratorToComment,
496
504
  unblockUser,
497
505
  undeletePlaylist,
@@ -24,3 +24,23 @@ export async function fetchEnrollmentPageMetadata(guidedCourse) {
24
24
  const url: string = `${BASE_PATH}/v1/user/guided-courses/enrollment/${guidedCourse}`
25
25
  return await fetchHandler(url, 'GET')
26
26
  }
27
+
28
+ export async function pinGuidedCourse(guidedCourse) {
29
+ const url: string = `${BASE_PATH}/v1/user/guided-courses/pin/${guidedCourse}`
30
+ return await fetchHandler(url, 'POST')
31
+ }
32
+
33
+ export async function unPinGuidedCourse(guidedCourse) {
34
+ const url: string = `${BASE_PATH}/v1/user/guided-courses/unpin/${guidedCourse}`
35
+ return await fetchHandler(url, 'POST')
36
+ }
37
+
38
+ export async function guidedCourses() {
39
+ const url: string = `${BASE_PATH}/v1/user/guided-courses/`
40
+ return await fetchHandler(url, 'GET')
41
+ }
42
+
43
+ export async function pinnedGuidedCourses() {
44
+ const url: string = `${BASE_PATH}/v1/user/guided-courses/pinned`
45
+ return await fetchHandler(url, 'GET')
46
+ }
@@ -43,8 +43,7 @@ export async function addContextToContent(dataPromise, ...dataArgs)
43
43
  addResumeTimeSeconds ? getResumeTimeSecondsByIds(ids) : Promise.resolve(null),
44
44
  addLastInteractedChild ? fetchLastInteractedChild(ids) : Promise.resolve(null),
45
45
  ])
46
- console.log('ids', ids)
47
- console.log('lastInteractedChildData', lastInteractedChildData)
46
+
48
47
  const addContext = async (item) => ({
49
48
  ...item,
50
49
  ...(addProgressPercentage ? { progressPercentage: progressPercentageData?.[item.id] } : {}),
@@ -54,6 +53,7 @@ export async function addContextToContent(dataPromise, ...dataArgs)
54
53
  ...(addResumeTimeSeconds ? { resumeTime: resumeTimeData?.[item.id] } : {}),
55
54
  ...(addLastInteractedChild ? { lastInteractedChild: lastInteractedChildData?.[item.id] } : {}),
56
55
  })
56
+
57
57
  if (dataField) {
58
58
  data[dataField] = Array.isArray(data[dataField])
59
59
  ? await Promise.all(data[dataField].map(addContext))
@@ -361,7 +361,7 @@ function getMediaTypeId(mediaType, mediaCategory) {
361
361
  case 'practice_play-alongs':
362
362
  return 4
363
363
  case 'video_soundslice':
364
- return 6
364
+ return 3
365
365
  default:
366
366
  return 5
367
367
  }
@@ -1030,7 +1030,7 @@ async function processContentItem(item) {
1030
1030
  let ctaText = 'Continue';
1031
1031
  if (contentType === 'transcription' || contentType === 'play-along' || contentType === 'jam-track') ctaText = 'Replay Song';
1032
1032
  if (contentType === 'lesson') ctaText = status === 'completed' ? 'Revisit Lesson' : 'Continue';
1033
- if ((contentType === 'guided course' || contentType === 'song tutorial' || collectionLessonTypes.includes(contentType)) && status === 'completed') ctaText = 'Revisit Lessons' ;
1033
+ if (collectionLessonTypes.includes(contentType) && status === 'completed') ctaText = 'Revisit Lessons' ;
1034
1034
  if (contentType === 'pack' && status === 'completed') {
1035
1035
  ctaText = 'View Lessons';
1036
1036
  }
@@ -1064,15 +1064,6 @@ async function processContentItem(item) {
1064
1064
  const nextLesson = lessons.find(lesson => lesson.id === nextId)
1065
1065
  data.first_incomplete_child = nextLesson?.parent ?? nextLesson
1066
1066
  data.second_incomplete_child = (nextLesson?.parent) ? nextLesson : null
1067
- if(data.type === 'challenge' && nextByProgress !== undefined ){
1068
- const challenge = await fetchChallengeLessonData(nextByProgress)
1069
- if(challenge.lesson.is_locked) {
1070
- const timeRemaining = getTimeRemainingUntilLocal(challenge.lesson.unlock_date, {withTotalSeconds:true})
1071
- data.is_locked = true
1072
- data.time_remaining_seconds = timeRemaining.totalSeconds
1073
- ctaText = 'Next lesson in ' + timeRemaining.formatted
1074
- }
1075
- }
1076
1067
  }
1077
1068
  }
1078
1069
 
@@ -1250,7 +1241,7 @@ function mergeAndSortItems(items, limit) {
1250
1241
 
1251
1242
  function findIncompleteLesson(progressOnItems, currentContentId, contentType) {
1252
1243
  const ids = Object.keys(progressOnItems).map(Number);
1253
- if (contentType === 'challenge') {
1244
+ if (contentType === 'guided-course') {
1254
1245
  // Return first incomplete lesson
1255
1246
  return ids.find(id => progressOnItems[id] !== 'completed') || ids.at(0);
1256
1247
  }
@@ -1283,10 +1274,11 @@ function findIncompleteLesson(progressOnItems, currentContentId, contentType) {
1283
1274
  * .catch(error => console.error(error));
1284
1275
  */
1285
1276
  export async function pinProgressRow(brand, id, progressType) {
1277
+ if (!(brand && id && progressType)) throw new Error(`undefined parameter progressType: ${progressType} brand: ${brand} or id: ${id}`)
1286
1278
  const url = `/api/user-management-system/v1/progress/pin?brand=${brand}&id=${id}&progressType=${progressType}`;
1287
1279
  const response = await fetchHandler(url, 'PUT', null)
1288
- if (response && !response.error) {
1289
- await updatePinnedProgressRow(brand, {
1280
+ if (response && !response.error && response['action'] === 'update_user_pin') {
1281
+ await updateUserPinnedProgressRow(brand, {
1290
1282
  id,
1291
1283
  progressType,
1292
1284
  pinnedAt: new Date().toISOString(),
@@ -1298,23 +1290,25 @@ export async function pinProgressRow(brand, id, progressType) {
1298
1290
  * Unpins the current pinned progress row for a user, scoped by brand.
1299
1291
  *
1300
1292
  * @param {string} brand - The brand context for the unpin action.
1293
+ * @param {string} id - The content or playlist id to unpin.
1301
1294
  * @returns {Promise<Object>} - A promise resolving to the response from the unpin API.
1302
1295
  *
1303
1296
  * @example
1304
- * unpinProgressRow('drumeo')
1297
+ * unpinProgressRow('drumeo', 123456)
1305
1298
  * .then(response => console.log(response))
1306
1299
  * .catch(error => console.error(error));
1307
1300
  */
1308
- export async function unpinProgressRow(brand) {
1309
- const url = `/api/user-management-system/v1/progress/unpin?brand=${brand}`
1301
+ export async function unpinProgressRow(brand, id) {
1302
+ if (!(brand && id)) throw new Error(`undefined parameter brand: ${brand} or id: ${id}`)
1303
+ const url = `/api/user-management-system/v1/progress/unpin?brand=${brand}&id=${id}`
1310
1304
  const response = await fetchHandler(url, 'PUT', null)
1311
- if (response && !response.error) {
1312
- await updatePinnedProgressRow(brand, null)
1305
+ if (response && !response.error && response['action'] === 'clear_user_pin') {
1306
+ await updateUserPinnedProgressRow(brand, null)
1313
1307
  }
1314
1308
  return response
1315
1309
  }
1316
1310
 
1317
- async function updatePinnedProgressRow(brand, pinnedData) {
1311
+ async function updateUserPinnedProgressRow(brand, pinnedData) {
1318
1312
  const userRaw = await globalConfig.localStorage.getItem('user');
1319
1313
  const user = userRaw ? JSON.parse(userRaw) : {};
1320
1314
  user.brand_pinned_progress = user.brand_pinned_progress || {}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/test/log.js CHANGED
File without changes
package/.yarnrc.yml DELETED
@@ -1 +0,0 @@
1
- nodeLinker: node-modules