musora-content-services 2.99.5 → 2.100.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,36 @@
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.100.3](https://github.com/railroadmedia/musora-content-services/compare/v2.100.2...v2.100.3) (2025-12-10)
6
+
7
+ ### [2.100.2](https://github.com/railroadmedia/musora-content-services/compare/v2.100.1...v2.100.2) (2025-12-10)
8
+
9
+ ### [2.100.1](https://github.com/railroadmedia/musora-content-services/compare/v2.100.0...v2.100.1) (2025-12-10)
10
+
11
+ ## [2.100.0](https://github.com/railroadmedia/musora-content-services/compare/v2.98.0...v2.100.0) (2025-12-10)
12
+
13
+
14
+ ### Features
15
+
16
+ * **BEH-1421:** Content Migration : child lesson type migrations ([#624](https://github.com/railroadmedia/musora-content-services/issues/624)) ([77300ed](https://github.com/railroadmedia/musora-content-services/commit/77300eddabc4deed46c26f7b1291d9540a3ef486))
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * **agi:** optional query options property access ([e8d9a33](https://github.com/railroadmedia/musora-content-services/commit/e8d9a333462dc8bcfed7af9171bff4380c9d67fd))
22
+ * ai broke everything because it loves js ([#634](https://github.com/railroadmedia/musora-content-services/issues/634)) ([213a8d5](https://github.com/railroadmedia/musora-content-services/commit/213a8d5b724bcaa284acdc2a76b935c52d2e4004))
23
+ * daily session created when method intro video completed ([#636](https://github.com/railroadmedia/musora-content-services/issues/636)) ([fdfbb62](https://github.com/railroadmedia/musora-content-services/commit/fdfbb6287348307920ec50b798a0f14520fe4f10))
24
+ * **groq:** query order and slicing out of place ([97a3c1c](https://github.com/railroadmedia/musora-content-services/commit/97a3c1c9d27745ee78894f3d2c9c5d3e8195efb0))
25
+ * Update category_id for thread ([8b4cee6](https://github.com/railroadmedia/musora-content-services/commit/8b4cee62435e813e2e5b6d77f19fe78298444f5e))
26
+ * update get enriched LPs ([#635](https://github.com/railroadmedia/musora-content-services/issues/635)) ([01995dc](https://github.com/railroadmedia/musora-content-services/commit/01995dcd2c013c8cca31e29a44c41118623d9d9b))
27
+ * User without owned content & without membership have Owned content have Owned Lessons/Songs in For You tab ([901f487](https://github.com/railroadmedia/musora-content-services/commit/901f48716a152c0771a4c5197d85e16d45b60bdc))
28
+
29
+ ### [2.99.8](https://github.com/railroadmedia/musora-content-services/compare/v2.99.7...v2.99.8) (2025-12-09)
30
+
31
+ ### [2.99.7](https://github.com/railroadmedia/musora-content-services/compare/v2.99.6...v2.99.7) (2025-12-09)
32
+
33
+ ### [2.99.6](https://github.com/railroadmedia/musora-content-services/compare/v2.99.5...v2.99.6) (2025-12-09)
34
+
5
35
  ### [2.99.5](https://github.com/railroadmedia/musora-content-services/compare/v2.99.4...v2.99.5) (2025-12-09)
6
36
 
7
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "2.99.5",
3
+ "version": "2.100.3",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -1,12 +1,37 @@
1
1
  import { globalConfig } from '../services/config.js'
2
2
 
3
+ async function message(response) {
4
+ const contentType = response.headers.get('content-type')
5
+ if (
6
+ contentType &&
7
+ contentType.indexOf('application/json') !== -1 &&
8
+ response.status !== 204
9
+ ) {
10
+ return await response.json()
11
+ } else {
12
+ return await response.text()
13
+ }
14
+ }
15
+
16
+ async function handleError(response, method, url) {
17
+ console.error(`Fetch error: ${method} ${url} ${response.status} ${response.statusText}`)
18
+ console.log(response)
19
+ const contentType = response.headers.get('content-type')
20
+ if (contentType && contentType.indexOf('json') !== -1) {
21
+ const data = await response.json()
22
+ console.log(data)
23
+ }
24
+ }
25
+
3
26
  export async function fetchJSONHandler(
4
27
  url,
5
28
  token,
6
29
  baseUrl,
7
30
  method = 'get',
8
31
  dataVersion = null,
9
- body = null
32
+ body = null,
33
+ fullResponse = false,
34
+ logError = true
10
35
  ) {
11
36
  const headers = {
12
37
  'Content-Type': 'application/json',
@@ -23,23 +48,13 @@ export async function fetchJSONHandler(
23
48
  const response = await fetchHandler(url, token, baseUrl, method, headers, dataVersion, body)
24
49
 
25
50
  if (response.ok) {
26
- const contentType = response.headers.get('content-type')
27
- if (
28
- contentType &&
29
- contentType.indexOf('application/json') !== -1 &&
30
- response.status !== 204
31
- ) {
32
- return await response.json()
33
- } else {
34
- return await response.text()
51
+ if (fullResponse) {
52
+ return response
35
53
  }
54
+ return await message(response)
36
55
  } else {
37
- console.error(`Fetch error: ${method} ${url} ${response.status} ${response.statusText}`)
38
- console.log(response)
39
- const contentType = response.headers.get('content-type')
40
- if (contentType && contentType.indexOf('json') !== -1) {
41
- const data = await response.json()
42
- console.log(data)
56
+ if (logError) {
57
+ await handleError(response, method, url)
43
58
  }
44
59
  }
45
60
  } catch (error) {
@@ -2,7 +2,7 @@
2
2
  * @module LearningPaths
3
3
  */
4
4
 
5
- import { fetchHandler } from '../railcontent.js'
5
+ import { fetchHandler, fetchResponseHandler } from '../railcontent.js'
6
6
  import { fetchByRailContentId, fetchByRailContentIds, fetchMethodV2Structure } from '../sanity.js'
7
7
  import { addContextToLearningPaths } from '../contentAggregator.js'
8
8
  import {
@@ -48,13 +48,19 @@ interface CollectionObject {
48
48
 
49
49
  /**
50
50
  * Gets today's daily session for the user.
51
+ * If the daily session doesn't exist, it will be created.
51
52
  * @param brand
52
53
  * @param userDate
53
54
  */
54
55
  export async function getDailySession(brand: string, userDate: Date) {
55
56
  const stringDate = userDate.toISOString().split('T')[0]
56
57
  const url: string = `${LEARNING_PATHS_PATH}/daily-session/get?brand=${brand}&userDate=${stringDate}`
57
- return (await fetchHandler(url, 'GET', null, null)) as DailySessionResponse
58
+ let options = {dataVersion: null, body: null, fullResponse: true, logError: true}
59
+ const response = await fetchResponseHandler(url, 'GET', options)
60
+ if (response.status === 204) {
61
+ return await updateDailySession(brand, userDate, false)
62
+ }
63
+ return await response.json() as DailySessionResponse
58
64
  }
59
65
 
60
66
  /**
@@ -82,7 +88,6 @@ export async function getActivePath(brand: string) {
82
88
  const url: string = `${LEARNING_PATHS_PATH}/active-path/get?brand=${brand}`
83
89
  return (await fetchHandler(url, 'GET', null, null)) as ActiveLearningPathResponse
84
90
  }
85
-
86
91
  /**
87
92
  * Sets a new learning path as the user's active learning path.
88
93
  * @param brand
@@ -32,6 +32,7 @@ export async function createThread(
32
32
  export interface UpdateThreadParams {
33
33
  title: string
34
34
  brand: string
35
+ category_id?: number
35
36
  }
36
37
  /**
37
38
  * Updates an existing thread under a forum category.
@@ -153,7 +153,7 @@ export class PermissionsV2Adapter extends PermissionsAdapter {
153
153
  if (ownedContentIds.length === 0) {
154
154
  // User has no owned content permissions
155
155
  // Return filter that matches nothing
156
- return `railcontent_id == null`
156
+ return `railcontent_id == 0`
157
157
  }
158
158
 
159
159
  // Content must be in owned content IDs
@@ -649,4 +649,16 @@ export async function fetchHandler(url, method = 'get', dataVersion = null, body
649
649
  dataVersion,
650
650
  body
651
651
  )
652
+ }
653
+ export async function fetchResponseHandler(url, method = 'get', {dataVersion = null, body = null, fullResponse = true, logError = true}) {
654
+ return fetchJSONHandler(
655
+ url,
656
+ globalConfig.sessionConfig.token,
657
+ globalConfig.baseUrl,
658
+ method,
659
+ dataVersion,
660
+ body,
661
+ fullResponse,
662
+ logError,
663
+ )
652
664
  }
@@ -1,9 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(rg:*)",
5
- "Bash(npm run lint:*)"
6
- ],
7
- "deny": []
8
- }
9
- }