musora-content-services 2.83.0 → 2.85.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 (71) hide show
  1. package/.claude/settings.local.json +8 -0
  2. package/CHANGELOG.md +14 -0
  3. package/docs/ContentOrganization.html +2 -2
  4. package/docs/Forums.html +2 -2
  5. package/docs/Gamification.html +2 -2
  6. package/docs/TestUser.html +2 -2
  7. package/docs/UserManagementSystem.html +2 -2
  8. package/docs/api_types.js.html +2 -2
  9. package/docs/config.js.html +2 -5
  10. package/docs/content-org_content-org.js.html +2 -2
  11. package/docs/content-org_guided-courses.ts.html +2 -2
  12. package/docs/content-org_learning-paths.ts.html +24 -126
  13. package/docs/content-org_playlists-types.js.html +2 -2
  14. package/docs/content-org_playlists.js.html +2 -2
  15. package/docs/content.js.html +10 -88
  16. package/docs/forums_categories.ts.html +3 -22
  17. package/docs/forums_forums.ts.html +2 -2
  18. package/docs/forums_posts.ts.html +2 -2
  19. package/docs/forums_threads.ts.html +2 -2
  20. package/docs/gamification_awards.ts.html +12 -26
  21. package/docs/gamification_gamification.js.html +2 -2
  22. package/docs/global.html +2 -2
  23. package/docs/index.html +2 -2
  24. package/docs/liveTesting.ts.html +2 -2
  25. package/docs/module-Accounts.html +14 -14
  26. package/docs/module-Awards.html +6 -106
  27. package/docs/module-Config.html +4 -5
  28. package/docs/module-Content-Services-V2.html +9 -440
  29. package/docs/module-Forums.html +43 -607
  30. package/docs/module-GuidedCourses.html +2 -2
  31. package/docs/module-Interests.html +2 -2
  32. package/docs/module-LearningPaths.html +12 -640
  33. package/docs/module-Onboarding.html +2 -2
  34. package/docs/module-Payments.html +2 -2
  35. package/docs/module-Permissions.html +2 -2
  36. package/docs/module-Playlists.html +2 -2
  37. package/docs/module-ProgressRow.html +2 -2
  38. package/docs/module-Railcontent-Services.html +298 -31
  39. package/docs/module-Sanity-Services.html +1901 -530
  40. package/docs/module-Sessions.html +2 -2
  41. package/docs/module-UserActivity.html +5 -5
  42. package/docs/module-UserChat.html +2 -2
  43. package/docs/module-UserManagement.html +2 -2
  44. package/docs/module-UserMemberships.html +2 -2
  45. package/docs/module-UserNotifications.html +2 -2
  46. package/docs/module-UserProfile.html +2 -2
  47. package/docs/progress-row_method-card.js.html +3 -3
  48. package/docs/railcontent.js.html +20 -8
  49. package/docs/sanity.js.html +313 -199
  50. package/docs/userActivity.js.html +5 -17
  51. package/docs/user_account.ts.html +13 -14
  52. package/docs/user_chat.js.html +2 -2
  53. package/docs/user_interests.js.html +2 -2
  54. package/docs/user_management.js.html +2 -2
  55. package/docs/user_memberships.ts.html +2 -2
  56. package/docs/user_notifications.js.html +2 -2
  57. package/docs/user_onboarding.ts.html +2 -2
  58. package/docs/user_payments.ts.html +2 -2
  59. package/docs/user_permissions.js.html +3 -3
  60. package/docs/user_profile.js.html +2 -2
  61. package/docs/user_sessions.js.html +2 -2
  62. package/docs/user_types.js.html +2 -2
  63. package/docs/user_user-management-system.js.html +2 -2
  64. package/package.json +1 -1
  65. package/src/index.d.ts +2 -2
  66. package/src/index.js +2 -2
  67. package/src/services/contentAggregator.js +34 -31
  68. package/src/services/contentProgress.js +250 -147
  69. package/src/services/railcontent.js +18 -6
  70. package/src/services/sanity.js +18 -2
  71. package/src/services/userActivity.js +3 -14
@@ -381,31 +381,43 @@ export async function fetchUserBadges(brand = null) {
381
381
  /**
382
382
  * complete a content's progress for a given user
383
383
  * @param contentId
384
+ * @param collection {object|null} - the collection context of the progress. null is normal content progress
385
+ * @param collection.type - the type of collection. options: ["learning-path"]
386
+ * @param collection.id - the content_id of collection.
384
387
  * @returns {Promise<any|string|null>}
385
388
  */
386
- export async function postContentComplete(contentId) {
389
+ export async function postContentComplete(contentId, collection = null) {
387
390
  let url = `/api/content/v1/user/progress/complete/${contentId}`
388
- return postDataHandler(url)
391
+ const body = {collection: collection}
392
+ return postDataHandler(url, body)
389
393
  }
390
394
 
391
395
  /**
392
396
  * start the user's progress on a content
393
397
  * @param contentId
398
+ * @param collection {object|null} - the collection context of the progress. null is normal content progress
399
+ * @param collection.type - the type of collection. options: ["learning-path"]
400
+ * @param collection.id - the content_id of collection.
394
401
  * @returns {Promise<any|string|null>}
395
402
  */
396
- export async function postContentStart(contentId) {
403
+ export async function postContentStart(contentId, collection = null) {
397
404
  let url = `/api/content/v1/user/progress/start/${contentId}`
398
- return postDataHandler(url)
405
+ const body = {collection: collection}
406
+ return postDataHandler(url, body)
399
407
  }
400
408
 
401
409
  /**
402
410
  * resets the user's progress on a content
403
411
  * @param contentId
412
+ * @param collection {object|null} - the collection context of the progress. null is normal content progress
413
+ * @param collection.type - the type of collection. options: ["learning-path"]
414
+ * @param collection.id - the content_id of collection.
404
415
  * @returns {Promise<any|string|null>}
405
416
  */
406
- export async function postContentReset(contentId) {
417
+ export async function postContentReset(contentId, collection = null) {
407
418
  let url = `/api/content/v1/user/progress/reset/${contentId}`
408
- return postDataHandler(url)
419
+ const body = {collection: collection}
420
+ return postDataHandler(url, body)
409
421
  }
410
422
 
411
423
  /**
@@ -478,7 +478,6 @@ export async function fetchByRailContentIds(
478
478
  live_event_end_time,
479
479
  }`
480
480
 
481
- console.log('ids query', query)
482
481
  const customPostProcess = (results) => {
483
482
  const now = getSanityDate(new Date(), false)
484
483
  const liveProcess = (result) => {
@@ -2165,7 +2164,7 @@ export async function fetchMethodV2Structure(brand) {
2165
2164
  const _type = 'method-v2'
2166
2165
  const query = `*[_type == '${_type}' && brand == '${brand}'][0...1]{
2167
2166
  'sanity_id': _id,
2168
- 'learningPaths': child[]->{
2167
+ 'learning_paths': child[]->{
2169
2168
  'id': railcontent_id,
2170
2169
  'children': child[]->railcontent_id
2171
2170
  }
@@ -2173,6 +2172,23 @@ export async function fetchMethodV2Structure(brand) {
2173
2172
  return await fetchSanity(query, false)
2174
2173
  }
2175
2174
 
2175
+ /**
2176
+ * Fetch the structure (just ids) of the Method of a given learning path or learning path lesson.
2177
+ * @param contentId
2178
+ * @returns {Promise<*|null>}
2179
+ */
2180
+ export async function fetchMethodV2StructureFromId(contentId) {
2181
+ const _type = "method-v2";
2182
+ const query = `*[_type == '${_type}' && brand == *[railcontent_id == ${contentId}][0].brand][0...1]{
2183
+ 'sanity_id': _id,
2184
+ 'learning_paths': child[]->{
2185
+ 'id': railcontent_id,
2186
+ 'children': child[]->railcontent_id
2187
+ }
2188
+ }`
2189
+ return await fetchSanity(query, false);
2190
+ }
2191
+
2176
2192
  /**
2177
2193
  * Fetch content owned by the user (excluding membership content).
2178
2194
  * Shows only content accessible through purchases/entitlements, not through membership.
@@ -986,7 +986,7 @@ async function extractPinnedItemsAndSortAllItems(
986
986
  return mergeAndSortItems(combined, limit)
987
987
  }
988
988
 
989
- function generateContentsMap(contents, playlistsContents, methodProgressContents) {
989
+ function generateContentsMap(contents, playlistsContents) {
990
990
  const excludedTypes = new Set(['pack-bundle', 'guided-course-part'])
991
991
  const existingShows = new Set()
992
992
  const contentsMap = new Map()
@@ -1027,15 +1027,6 @@ function generateContentsMap(contents, playlistsContents, methodProgressContents
1027
1027
  parentIds.forEach((id) => contentsMap.delete(id))
1028
1028
  }
1029
1029
  }
1030
- //TODO:: remove method cards from progress rows
1031
- // if (methodProgressContents && Object.keys(methodProgressContents).length) {
1032
- // for (const item of methodProgressContents) {
1033
- // const contentId = item.id
1034
- // contentsMap.delete(contentId)
1035
- // const parentIds = item.parent_content_data || []
1036
- // parentIds.forEach((id) => contentsMap.delete(id))
1037
- // }
1038
- // }
1039
1030
 
1040
1031
  return contentsMap
1041
1032
  }
@@ -1075,23 +1066,21 @@ export async function getProgressRows({ brand = 'drumeo', limit = 8 } = {}) {
1075
1066
  }
1076
1067
  //need to update addContextToContent to accept collection info
1077
1068
  const [playlistsContents, contents] = await Promise.all([
1078
- playlistEngagedOnContents
1069
+ (playlistEngagedOnContents.length > 0)
1079
1070
  ? addContextToContent(fetchByRailContentIds, playlistEngagedOnContents, 'progress-tracker', {
1080
- addNextLesson: true,
1081
1071
  addNavigateTo: true,
1082
1072
  addProgressStatus: true,
1083
1073
  addProgressPercentage: true,
1084
1074
  addProgressTimestamp: true,
1085
1075
  })
1086
1076
  : Promise.resolve([]),
1087
- nonPlaylistContentIds
1077
+ (nonPlaylistContentIds.length > 0)
1088
1078
  ? addContextToContent(
1089
1079
  fetchByRailContentIds,
1090
1080
  nonPlaylistContentIds,
1091
1081
  'progress-tracker',
1092
1082
  brand,
1093
1083
  {
1094
- addNextLesson: true,
1095
1084
  addNavigateTo: true,
1096
1085
  addProgressStatus: true,
1097
1086
  addProgressPercentage: true,