musora-content-services 2.99.1 → 2.99.2

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,13 @@
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.99.2](https://github.com/railroadmedia/musora-content-services/compare/v2.99.1...v2.99.2) (2025-12-09)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * update get enriched LPs ([#635](https://github.com/railroadmedia/musora-content-services/issues/635)) ([01995dc](https://github.com/railroadmedia/musora-content-services/commit/01995dcd2c013c8cca31e29a44c41118623d9d9b))
11
+
5
12
  ### [2.99.1](https://github.com/railroadmedia/musora-content-services/compare/v2.99.0...v2.99.1) (2025-12-09)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "2.99.1",
3
+ "version": "2.99.2",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.d.ts CHANGED
@@ -50,6 +50,7 @@ import {
50
50
  getActivePath,
51
51
  getDailySession,
52
52
  getEnrichedLearningPath,
53
+ getEnrichedLearningPaths,
53
54
  getLearningPathLessonsByIds,
54
55
  mapContentToParent,
55
56
  onContentCompletedLearningPathListener,
@@ -425,7 +426,7 @@ import {
425
426
  } from './services/userActivity.js';
426
427
 
427
428
  import {
428
- default as EventsAPI
429
+ default as EventsAPI
429
430
  } from './services/eventsAPI';
430
431
 
431
432
  declare module 'musora-content-services' {
@@ -588,6 +589,7 @@ declare module 'musora-content-services' {
588
589
  getContentRows,
589
590
  getDailySession,
590
591
  getEnrichedLearningPath,
592
+ getEnrichedLearningPaths,
591
593
  getInProgressAwards,
592
594
  getLastInteractedOf,
593
595
  getLearningPathLessonsByIds,
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*** This file was generated automatically. To recreate, please run `npm run build-index`. ***/
2
2
 
3
3
  import {
4
- default as EventsAPI
4
+ default as EventsAPI
5
5
  } from './services/eventsAPI';
6
6
 
7
7
  import {
@@ -54,6 +54,7 @@ import {
54
54
  getActivePath,
55
55
  getDailySession,
56
56
  getEnrichedLearningPath,
57
+ getEnrichedLearningPaths,
57
58
  getLearningPathLessonsByIds,
58
59
  mapContentToParent,
59
60
  onContentCompletedLearningPathListener,
@@ -587,6 +588,7 @@ export {
587
588
  getContentRows,
588
589
  getDailySession,
589
590
  getEnrichedLearningPath,
591
+ getEnrichedLearningPaths,
590
592
  getInProgressAwards,
591
593
  getLastInteractedOf,
592
594
  getLearningPathLessonsByIds,
@@ -3,8 +3,8 @@
3
3
  */
4
4
 
5
5
  import { fetchHandler } from '../railcontent.js'
6
- import { fetchByRailContentId, fetchMethodV2Structure } from '../sanity.js'
7
- import { addContextToContent } from '../contentAggregator.js'
6
+ import { fetchByRailContentId, fetchByRailContentIds, fetchMethodV2Structure } from '../sanity.js'
7
+ import { addContextToLearningPaths } from '../contentAggregator.js'
8
8
  import {
9
9
  contentStatusCompleted,
10
10
  contentsStatusCompleted,
@@ -107,14 +107,14 @@ export async function resetAllLearningPaths() {
107
107
  * @returns {Promise<Object>} Learning path with enriched lesson data
108
108
  */
109
109
  export async function getEnrichedLearningPath(learningPathId) {
110
- const response = (await addContextToContent(
110
+ const response = (await addContextToLearningPaths(
111
111
  fetchByRailContentId,
112
112
  learningPathId,
113
113
  COLLECTION_TYPE.LEARNING_PATH,
114
114
  {
115
- collection: { id: learningPathId, type: COLLECTION_TYPE.LEARNING_PATH },
116
115
  dataField: 'children',
117
116
  dataField_includeParent: true,
117
+ dataField_includeIntroVideo: true,
118
118
  addProgressStatus: true,
119
119
  addProgressPercentage: true,
120
120
  addProgressTimestamp: true,
@@ -125,12 +125,44 @@ export async function getEnrichedLearningPath(learningPathId) {
125
125
 
126
126
  response.children = mapContentToParent(
127
127
  response.children,
128
- 'learning-path-lesson-v2',
128
+ COLLECTION_TYPE.LEARNING_PATH,
129
129
  learningPathId
130
130
  )
131
131
  return response
132
132
  }
133
133
 
134
+ /**
135
+ * Returns learning paths with lessons and progress data
136
+ * @param {number[]} learningPathIds - The learning path IDs
137
+ * @returns {Promise<Object>} Learning paths with enriched lesson data
138
+ */
139
+ export async function getEnrichedLearningPaths(learningPathIds: number[]) {
140
+ const response = (await addContextToLearningPaths(
141
+ fetchByRailContentIds,
142
+ learningPathIds,
143
+ COLLECTION_TYPE.LEARNING_PATH,
144
+ {
145
+ dataField: 'children',
146
+ dataField_includeParent: true,
147
+ dataField_includeIntroVideo: true,
148
+ addProgressStatus: true,
149
+ addProgressPercentage: true,
150
+ addProgressTimestamp: true,
151
+ addNavigateTo: true,
152
+ }
153
+ )) as any
154
+ if (!response) return response
155
+
156
+ response.forEach((learningPath) => {
157
+ learningPath.children = mapContentToParent(
158
+ learningPath.children,
159
+ COLLECTION_TYPE.LEARNING_PATH,
160
+ learningPath.id
161
+ )
162
+ })
163
+ return response
164
+ }
165
+
134
166
  /**
135
167
  * Get specific learning path lessons by content IDs
136
168
  * @param {number[]} contentIds - Array of content IDs to filter
@@ -179,7 +211,7 @@ export async function fetchLearningPathLessons(
179
211
  userDate: Date
180
212
  ) {
181
213
  const learningPath = await getEnrichedLearningPath(learningPathId)
182
- let dailySession = await getDailySession(brand, userDate) // what if the call just fails, and a DS does exist?
214
+ let dailySession = await getDailySession(brand, userDate); // what if the call just fails, and a DS does exist?
183
215
  if (!dailySession) {
184
216
  dailySession = await updateDailySession(brand, userDate, false)
185
217
  }