musora-content-services 2.135.2 → 2.135.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.
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
+ ### [2.135.3](https://github.com/railroadmedia/musora-content-services/compare/v2.135.2...v2.135.3) (2026-02-19)
6
+
5
7
  ### [2.135.2](https://github.com/railroadmedia/musora-content-services/compare/v2.135.1...v2.135.2) (2026-02-19)
6
8
 
7
9
  ### [2.135.1](https://github.com/railroadmedia/musora-content-services/compare/v2.135.0...v2.135.1) (2026-02-19)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "2.135.2",
3
+ "version": "2.135.3",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -12,7 +12,7 @@ async function getCompletionStates(contentIds, collection = null) {
12
12
  return contentIds.map(id => {
13
13
  return {
14
14
  id,
15
- completed: progress[id] === STATE.COMPLETED
15
+ completed: progress.get(id) === STATE.COMPLETED
16
16
  }
17
17
  })
18
18
  }
@@ -110,7 +110,7 @@ export async function addContextToContent(dataPromise, ...dataArgs) {
110
110
  ...(addProgressTimestamp ? { progressTimestamp: progressData?.[item.id]?.last_update } : {}),
111
111
  ...(addIsLiked ? { isLiked: isLikedData?.[item.id] } : {}),
112
112
  ...(addLikeCount && ids.length === 1 ? { likeCount: await fetchLikeCount(item.id) } : {}),
113
- ...(addResumeTimeSeconds ? { resumeTime: resumeTimeData?.[item.id] } : {}),
113
+ ...(addResumeTimeSeconds ? { resumeTime: resumeTimeData?.get(item.id) } : {}),
114
114
  ...(addNavigateTo ? { navigateTo: navigateToData?.[item.id] } : {}),
115
115
  ...(addAwards ? { awards: awards?.[item.id].awards || [] } : {}),
116
116
  })
@@ -250,12 +250,12 @@ export async function getNavigateToForPlaylists(data, { dataField = null } = {})
250
250
 
251
251
  const allItemsCompleted = accessibleItems.every((i) => {
252
252
  const itemId = i.content_id
253
- const progress = progressOnItems[itemId]
253
+ const progress = progressOnItems.get(itemId)
254
254
  return progress && progress === 'completed'
255
255
  })
256
256
  let nextItem = accessibleItems[0] ?? playlist.items[0] ?? null
257
257
  if (!allItemsCompleted) {
258
- const lastItemProgress = progressOnItems[playlist.last_engaged_on]
258
+ const lastItemProgress = progressOnItems.get(playlist.last_engaged_on)
259
259
  const index = accessibleItems.findIndex((i) => i.content_id === playlist.last_engaged_on)
260
260
  if (lastItemProgress === 'completed') {
261
261
  nextItem = accessibleItems[index + 1] ?? nextItem
@@ -46,7 +46,7 @@ export async function getNavigateToForMethod(data) {
46
46
  const {content, collection} = tuple
47
47
 
48
48
  const findFirstIncomplete = (ids, progresses) =>
49
- ids.find(id => progresses[id] !== STATE_COMPLETED) || ids[0]
49
+ ids.find(id => progresses.get(id) !== STATE_COMPLETED) || ids[0]
50
50
 
51
51
  const findChildById = (children, id) =>
52
52
  children?.find(child => child.id === Number(id)) || null
@@ -132,7 +132,7 @@ export async function getNavigateTo(data, collection = null) {
132
132
  } else {
133
133
  const childrenStates = await getProgressStateByIds(childrenIds, collection)
134
134
  const lastInteracted = await getLastInteractedOf(childrenIds, collection)
135
- const lastInteractedStatus = childrenStates[lastInteracted]
135
+ const lastInteractedStatus = childrenStates.get(lastInteracted)
136
136
 
137
137
  if (['course', 'skill-pack', 'song-tutorial'].includes(content.type)) {
138
138
  if (lastInteractedStatus === STATE_STARTED) {
@@ -168,7 +168,7 @@ export async function getNavigateTo(data, collection = null) {
168
168
  firstChildren.map((child) => child.id),
169
169
  collection
170
170
  )
171
- if (childrenStates[lastInteractedChildId] === STATE_COMPLETED) {
171
+ if (childrenStates.get(lastInteractedChildId) === STATE_COMPLETED) {
172
172
  // TODO: course collections have an extra situation where we need to jump to the next course if all lessons in the last engaged course are completed
173
173
  }
174
174
  let lastInteractedChildNavToData = await getNavigateTo(firstChildren, collection)
@@ -292,12 +292,12 @@ async function getById(contentId, collection, dataKey, defaultValue) {
292
292
  }
293
293
 
294
294
  async function getByIds(contentIds, collection, dataKey, defaultValue) {
295
- if (contentIds.length === 0) return {}
295
+ if (contentIds.length === 0) return new Map()
296
296
 
297
- const progress = Object.fromEntries(contentIds.map((id) => [id, defaultValue]))
297
+ const progress = new Map(contentIds.map((id) => [id, defaultValue]))
298
298
  await db.contentProgress.getSomeProgressByContentIds(normalizeContentIds(contentIds), normalizeCollection(collection)).then((r) => {
299
299
  r.data.forEach((p) => {
300
- progress[p.content_id] = p[dataKey] ?? defaultValue
300
+ progress.set(p.content_id, p[dataKey] ?? defaultValue)
301
301
  })
302
302
  })
303
303
  return progress
@@ -750,7 +750,7 @@ function averageProgressesFor(hierarchy, contentId, progressData, depth = 1) {
750
750
  if (!parentId) return {}
751
751
 
752
752
  const parentChildProgress = hierarchy?.children?.[parentId]?.map((childId) => {
753
- return progressData[childId] ?? 0
753
+ return progressData.get(childId) ?? 0
754
754
  })
755
755
  const avgParentProgress =
756
756
  parentChildProgress.length > 0
@@ -180,7 +180,7 @@ async function getCompletedChildren(content, contentType) {
180
180
  } else if (content.lesson_count > 0) {
181
181
  const lessonIds = getLeafNodes(content)
182
182
  const progressOnItems = await getProgressStateByIds(lessonIds)
183
- completedChildren = Object.values(progressOnItems).filter(
183
+ completedChildren = Array.from(progressOnItems.values()).filter(
184
184
  (value) => value === 'completed'
185
185
  ).length
186
186
  allChildren = lessonIds.length
@@ -892,19 +892,20 @@ export async function restoreUserActivity(id) {
892
892
  }
893
893
 
894
894
  export function findIncompleteLesson(progressOnItems, currentContentId, contentType) {
895
- const ids = Object.keys(progressOnItems).map(Number)
895
+ const isMap = progressOnItems instanceof Map
896
+ const ids = isMap ? Array.from(progressOnItems.keys()) : Object.keys(progressOnItems).map(Number)
897
+ const getProgress = (id) => isMap ? progressOnItems.get(id) : progressOnItems[id]
898
+
896
899
  if (contentType === 'guided-course' || contentType === COLLECTION_TYPE.LEARNING_PATH) {
897
- // Return first incomplete lesson
898
- return ids.find((id) => progressOnItems[id] !== 'completed') || ids.at(0)
900
+ return ids.find((id) => getProgress(id) !== 'completed') || ids.at(0)
899
901
  }
900
902
 
901
- // For other types, find next incomplete after current
902
903
  const currentIndex = ids.indexOf(Number(currentContentId))
903
904
  if (currentIndex === -1) return null
904
905
 
905
906
  for (let i = currentIndex + 1; i < ids.length; i++) {
906
907
  const id = ids[i]
907
- if (progressOnItems[id] !== 'completed') {
908
+ if (getProgress(id) !== 'completed') {
908
909
  return id
909
910
  }
910
911
  }