musora-content-services 2.122.1 → 2.122.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,15 @@
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.122.3](https://github.com/railroadmedia/musora-content-services/compare/v2.122.2...v2.122.3) (2026-01-23)
6
+
7
+ ### [2.122.2](https://github.com/railroadmedia/musora-content-services/compare/v2.122.1...v2.122.2) (2026-01-23)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * broken method index ([#735](https://github.com/railroadmedia/musora-content-services/issues/735)) ([126f985](https://github.com/railroadmedia/musora-content-services/commit/126f985866f60bcca1d1ddb2dd97ba8847ff4219))
13
+
5
14
  ### [2.122.1](https://github.com/railroadmedia/musora-content-services/compare/v2.122.0...v2.122.1) (2026-01-23)
6
15
 
7
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "2.122.1",
3
+ "version": "2.122.3",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -56,17 +56,20 @@ interface CollectionObject {
56
56
  * @param userDate - local datetime. must have date and time - format 2025-10-31T13:45:00
57
57
  * @param forceRefresh - force cache refresh
58
58
  */
59
- export async function getDailySession(brand: string, userDate: Date, forceRefresh: boolean = false) {
59
+ export async function getDailySession(
60
+ brand: string,
61
+ userDate: Date,
62
+ forceRefresh: boolean = false
63
+ ) {
60
64
  const dateWithTimezone = formatLocalDateTime(userDate)
61
65
  const url: string = `${LEARNING_PATHS_PATH}/daily-session/get?brand=${brand}&userDate=${encodeURIComponent(dateWithTimezone)}`
62
66
  try {
63
- const response = await dataPromiseGET(url, forceRefresh) as DailySessionResponse
67
+ const response = (await dataPromiseGET(url, forceRefresh)) as DailySessionResponse
64
68
  if (!response) {
65
69
  return await updateDailySession(brand, userDate, false)
66
70
  }
67
71
  dailySessionPromise = null // reset promise after successful fetch
68
72
  return response as DailySessionResponse
69
-
70
73
  } catch (error: any) {
71
74
  if (error.status === 204) {
72
75
  return await updateDailySession(brand, userDate, false)
@@ -88,16 +91,23 @@ export async function updateDailySession(
88
91
  ) {
89
92
  const dateWithTimezone = formatLocalDateTime(userDate)
90
93
  const url: string = `${LEARNING_PATHS_PATH}/daily-session/create`
91
- const body = { brand: brand, userDate: dateWithTimezone, keepFirstLearningPath: keepFirstLearningPath }
94
+ const body = {
95
+ brand: brand,
96
+ userDate: dateWithTimezone,
97
+ keepFirstLearningPath: keepFirstLearningPath,
98
+ }
99
+ try {
100
+ const response = (await POST(url, body)) as DailySessionResponse
92
101
 
93
- const response = await POST(url, body) as DailySessionResponse
102
+ if (response) {
103
+ const urlGet: string = `${LEARNING_PATHS_PATH}/daily-session/get?brand=${brand}&userDate=${encodeURIComponent(dateWithTimezone)}`
104
+ dataPromiseGET(urlGet, true) // refresh cache
105
+ }
94
106
 
95
- if (response) {
96
- const urlGet: string = `${LEARNING_PATHS_PATH}/daily-session/get?brand=${brand}&userDate=${encodeURIComponent(dateWithTimezone)}`
97
- dataPromiseGET(urlGet, true) // refresh cache
107
+ return response
108
+ } catch (error: any) {
109
+ return null
98
110
  }
99
-
100
- return response
101
111
  }
102
112
 
103
113
  function formatLocalDateTime(date: Date): string {
@@ -112,7 +122,7 @@ function formatLocalDateTime(date: Date): string {
112
122
  export async function getActivePath(brand: string, forceRefresh: boolean = false) {
113
123
  const url: string = `${LEARNING_PATHS_PATH}/active-path/get?brand=${brand}`
114
124
 
115
- const response = await dataPromiseGET(url, forceRefresh) as ActiveLearningPathResponse
125
+ const response = (await dataPromiseGET(url, forceRefresh)) as ActiveLearningPathResponse
116
126
  activePathPromise = null // reset promise after successful fetch
117
127
 
118
128
  return response
@@ -127,7 +137,7 @@ export async function startLearningPath(brand: string, learningPathId: number) {
127
137
  const url: string = `${LEARNING_PATHS_PATH}/active-path/set`
128
138
  const body = { brand: brand, learning_path_id: learningPathId }
129
139
 
130
- const response = await POST(url, body) as ActiveLearningPathResponse
140
+ const response = (await POST(url, body)) as ActiveLearningPathResponse
131
141
 
132
142
  // manual BE call to avoid recursive POST<->GET calls
133
143
  if (response) {
@@ -138,16 +148,22 @@ export async function startLearningPath(brand: string, learningPathId: number) {
138
148
  return response
139
149
  }
140
150
 
141
- async function dataPromiseGET(url: string, forceRefresh: boolean): Promise<DailySessionResponse|ActiveLearningPathResponse> {
151
+ async function dataPromiseGET(
152
+ url: string,
153
+ forceRefresh: boolean
154
+ ): Promise<DailySessionResponse | ActiveLearningPathResponse> {
142
155
  if (url.includes('daily-session')) {
143
156
  if (!dailySessionPromise || forceRefresh) {
144
- dailySessionPromise = GET(url, {cache: forceRefresh ? 'reload' : 'default'}) as Promise<DailySessionResponse>
157
+ dailySessionPromise = GET(url, {
158
+ cache: forceRefresh ? 'reload' : 'default',
159
+ }) as Promise<DailySessionResponse>
145
160
  }
146
161
  return dailySessionPromise
147
-
148
162
  } else if (url.includes('active-path')) {
149
163
  if (!activePathPromise || forceRefresh) {
150
- activePathPromise = GET(url, {cache: forceRefresh ? 'reload' : 'default'}) as Promise<ActiveLearningPathResponse>
164
+ activePathPromise = GET(url, {
165
+ cache: forceRefresh ? 'reload' : 'default',
166
+ }) as Promise<ActiveLearningPathResponse>
151
167
  }
152
168
  return activePathPromise
153
169
  }
@@ -183,14 +199,10 @@ export async function getEnrichedLearningPath(learningPathId) {
183
199
  }
184
200
  )) as any
185
201
  // add awards to LP parents only
186
- response = await addContextToLearningPaths(() => response, {addAwards:true})
202
+ response = await addContextToLearningPaths(() => response, { addAwards: true })
187
203
  if (!response) return response
188
204
 
189
- response.children = mapContentToParent(
190
- response.children,
191
- LEARNING_PATH_LESSON,
192
- learningPathId
193
- )
205
+ response.children = mapContentToParent(response.children, LEARNING_PATH_LESSON, learningPathId)
194
206
  return response
195
207
  }
196
208
 
@@ -216,7 +228,7 @@ export async function getEnrichedLearningPaths(learningPathIds: number[]) {
216
228
  }
217
229
  )) as any
218
230
  // add awards to LP parents only
219
- response = await addContextToLearningPaths(() => response, {addAwards:true})
231
+ response = await addContextToLearningPaths(() => response, { addAwards: true })
220
232
 
221
233
  if (!response) return response
222
234
 
@@ -300,9 +312,9 @@ export async function fetchLearningPathLessons(
300
312
  userDate: Date
301
313
  ) {
302
314
  const learningPath = await getEnrichedLearningPath(learningPathId)
303
- let dailySession = await getDailySession(brand, userDate) as DailySessionResponse // what if the call just fails, and a DS does exist?
315
+ let dailySession = (await getDailySession(brand, userDate)) as DailySessionResponse // what if the call just fails, and a DS does exist?
304
316
  if (!dailySession) {
305
- dailySession = await updateDailySession(brand, userDate, false) as DailySessionResponse
317
+ dailySession = (await updateDailySession(brand, userDate, false)) as DailySessionResponse
306
318
  }
307
319
 
308
320
  const isActiveLearningPath = (dailySession?.active_learning_path_id || 0) == learningPathId
@@ -320,8 +332,6 @@ export async function fetchLearningPathLessons(
320
332
  let previousContentIds = []
321
333
  let previousLearningPathId = null
322
334
 
323
-
324
-
325
335
  for (const session of dailySession.daily_session) {
326
336
  if (session.learning_path_id === learningPathId) {
327
337
  todayContentIds = session.content_ids || []
@@ -361,13 +371,13 @@ export async function fetchLearningPathLessons(
361
371
  )
362
372
  }
363
373
  if (nextContentIds.length !== 0) {
364
- nextLPDailies = await getLearningPathLessonsByIds(
365
- nextContentIds,
366
- nextLearningPathId
367
- ).then(lessons => lessons.map(lesson => ({
368
- ...lesson,
369
- in_next_learning_path: learningPath.progressStatus === STATE.COMPLETED
370
- })))
374
+ nextLPDailies = await getLearningPathLessonsByIds(nextContentIds, nextLearningPathId).then(
375
+ (lessons) =>
376
+ lessons.map((lesson) => ({
377
+ ...lesson,
378
+ in_next_learning_path: learningPath.progressStatus === STATE.COMPLETED,
379
+ }))
380
+ )
371
381
  }
372
382
 
373
383
  return {
@@ -421,22 +431,28 @@ export async function completeMethodIntroVideo(
421
431
  const methodStructure = await fetchMethodV2Structure(brand)
422
432
 
423
433
  const firstLearningPathId = methodStructure.learning_paths[0].id
424
- response.active_path_response = await methodIntroVideoCompleteActions(brand, firstLearningPathId, new Date())
434
+ response.active_path_response = await methodIntroVideoCompleteActions(
435
+ brand,
436
+ firstLearningPathId,
437
+ new Date()
438
+ )
425
439
 
426
440
  response.intro_video_response = await completeIfNotCompleted(introVideoId)
427
441
 
428
442
  return response
429
443
  }
430
444
 
431
- async function methodIntroVideoCompleteActions(brand: string, learningPathId: number, userDate: Date) {
445
+ async function methodIntroVideoCompleteActions(
446
+ brand: string,
447
+ learningPathId: number,
448
+ userDate: Date
449
+ ) {
432
450
  const stringDate = userDate.toISOString().split('T')[0]
433
451
  const url: string = `${LEARNING_PATHS_PATH}/method-intro-video-complete-actions`
434
452
  const body = { brand: brand, learningPathId: learningPathId, userDate: stringDate }
435
453
  return (await POST(url, body)) as DailySessionResponse
436
454
  }
437
455
 
438
-
439
-
440
456
  interface completeLearningPathIntroVideo {
441
457
  intro_video_response: SyncWriteDTO<ContentProgress, any> | null
442
458
  learning_path_reset_response: SyncWriteDTO<ContentProgress, any> | null
@@ -465,19 +481,13 @@ export async function completeLearningPathIntroVideo(
465
481
  const collection: CollectionObject = { id: learningPathId, type: COLLECTION_TYPE.LEARNING_PATH }
466
482
 
467
483
  if (!lessonsToImport) {
468
-
469
484
  response.learning_path_reset_response = await resetIfPossible(learningPathId, collection)
470
485
  } else {
471
-
472
486
  response.lesson_import_response = await contentStatusCompletedMany(lessonsToImport, collection)
473
487
  const activePath = await getActivePath(brand)
474
488
 
475
489
  if (activePath.active_learning_path_id === learningPathId) {
476
- response.update_dailies_response = await updateDailySession(
477
- brand,
478
- new Date(),
479
- true
480
- )
490
+ response.update_dailies_response = await updateDailySession(brand, new Date(), true)
481
491
  }
482
492
  }
483
493
 
@@ -494,13 +504,19 @@ async function completeIfNotCompleted(
494
504
  return introVideoStatus !== 'completed' ? await contentStatusCompleted(contentId) : null
495
505
  }
496
506
 
497
- async function resetIfPossible(contentId: number, collection: CollectionParameter = null): Promise<SyncWriteDTO<ContentProgress, any> | null> {
507
+ async function resetIfPossible(
508
+ contentId: number,
509
+ collection: CollectionParameter = null
510
+ ): Promise<SyncWriteDTO<ContentProgress, any> | null> {
498
511
  const status = await getProgressState(contentId, collection)
499
512
 
500
513
  return status !== '' ? await contentStatusReset(contentId, collection) : null
501
514
  }
502
515
 
503
- export async function onContentCompletedLearningPathActions(contentId: number, collection: CollectionObject|null) {
516
+ export async function onContentCompletedLearningPathActions(
517
+ contentId: number,
518
+ collection: CollectionObject | null
519
+ ) {
504
520
  if (collection?.type !== COLLECTION_TYPE.LEARNING_PATH) return
505
521
  if (contentId !== collection?.id) return
506
522
 
@@ -525,5 +541,5 @@ export async function onContentCompletedLearningPathActions(contentId: number, c
525
541
  await startLearningPath(brand, nextLearningPath.id)
526
542
  const nextLearningPathData = await getEnrichedLearningPath(nextLearningPath.id)
527
543
 
528
- await contentStatusReset(nextLearningPathData.intro_video.id, {skipPush: true})
544
+ await contentStatusReset(nextLearningPathData.intro_video.id, { skipPush: true })
529
545
  }
@@ -1,9 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(rg:*)",
5
- "Bash(npm run lint:*)"
6
- ],
7
- "deny": []
8
- }
9
- }