musora-content-services 2.40.0 → 2.42.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.
- package/CHANGELOG.md +19 -0
- package/docs/ContentOrganization.html +2 -2
- package/docs/Forums.html +4 -4
- package/docs/Gamification.html +2 -2
- package/docs/UserManagementSystem.html +2 -2
- package/docs/api_types.js.html +2 -2
- package/docs/config.js.html +2 -2
- package/docs/content-org_content-org.js.html +2 -2
- package/docs/content-org_guided-courses.ts.html +2 -2
- package/docs/content-org_playlists-types.js.html +2 -2
- package/docs/content-org_playlists.js.html +2 -2
- package/docs/content.js.html +2 -2
- package/docs/forums_categories.ts.html +3 -3
- package/docs/forums_forums.ts.html +2 -2
- package/docs/forums_threads.ts.html +61 -3
- package/docs/gamification_awards.ts.html +23 -2
- package/docs/gamification_gamification.js.html +2 -2
- package/docs/global.html +2 -2
- package/docs/index.html +2 -2
- package/docs/module-Accounts.html +2 -2
- package/docs/module-Awards.html +165 -3
- package/docs/module-Categories.html +10 -2
- package/docs/module-Config.html +2 -2
- package/docs/module-Content-Services-V2.html +2 -2
- package/docs/module-Forums.html +2709 -85
- package/docs/module-GuidedCourses.html +2 -2
- package/docs/module-Interests.html +2 -2
- package/docs/module-Payments.html +2 -2
- package/docs/module-Permissions.html +2 -2
- package/docs/module-Playlists.html +2 -2
- package/docs/module-Railcontent-Services.html +2 -2
- package/docs/module-Sanity-Services.html +2 -2
- package/docs/module-Sessions.html +2 -2
- package/docs/module-Threads.html +646 -2
- package/docs/module-UserActivity.html +2 -2
- package/docs/module-UserChat.html +2 -2
- package/docs/module-UserManagement.html +2 -2
- package/docs/module-UserMemberships.html +2 -2
- package/docs/module-UserNotifications.html +2 -2
- package/docs/module-UserProfile.html +2 -2
- package/docs/railcontent.js.html +2 -2
- package/docs/sanity.js.html +2 -2
- package/docs/userActivity.js.html +2 -2
- package/docs/user_account.ts.html +2 -2
- package/docs/user_chat.js.html +2 -2
- package/docs/user_interests.js.html +2 -2
- package/docs/user_management.js.html +2 -2
- package/docs/user_memberships.js.html +2 -2
- package/docs/user_notifications.js.html +2 -2
- package/docs/user_payments.ts.html +2 -2
- package/docs/user_permissions.js.html +2 -2
- package/docs/user_profile.js.html +2 -2
- package/docs/user_sessions.js.html +2 -2
- package/docs/user_types.js.html +2 -2
- package/docs/user_user-management-system.js.html +2 -2
- package/package.json +1 -1
- package/src/index.d.ts +10 -2
- package/src/index.js +10 -2
- package/src/services/contentProgress.js +1 -0
- package/src/services/forums/categories.ts +1 -1
- package/src/services/forums/threads.ts +59 -1
- package/src/services/forums/types.ts +1 -0
- package/src/services/gamification/awards.ts +21 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module
|
|
2
|
+
* @module Forums
|
|
3
3
|
*/
|
|
4
4
|
import { HttpClient } from '../../infrastructure/http/HttpClient'
|
|
5
5
|
import { globalConfig } from '../config.js'
|
|
6
6
|
import { ForumThread } from './types'
|
|
7
|
+
import { PaginatedResponse } from '../api/types'
|
|
7
8
|
|
|
8
9
|
const baseUrl = `/api/forums`
|
|
9
10
|
|
|
@@ -28,3 +29,60 @@ export async function createThread(
|
|
|
28
29
|
const httpClient = new HttpClient(globalConfig.baseUrl)
|
|
29
30
|
return httpClient.post<ForumThread>(`${baseUrl}/v1/categories/${categoryId}/threads`, params)
|
|
30
31
|
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Follow a thread.
|
|
35
|
+
*
|
|
36
|
+
* @param {number} threadId - The ID of the thread to lock.
|
|
37
|
+
* @param {string} brand - The brand associated with the follow action.
|
|
38
|
+
* @return {Promise<void>} - A promise that resolves when the thread is locked.
|
|
39
|
+
* @throws {HttpError} - If the request fails.
|
|
40
|
+
*/
|
|
41
|
+
export async function followThread(threadId: number, brand: string): Promise<void> {
|
|
42
|
+
const httpClient = new HttpClient(globalConfig.baseUrl)
|
|
43
|
+
return httpClient.post<void>(`${baseUrl}/v1/threads/${threadId}/follow`, { brand })
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Unlock a thread to allow further posts.
|
|
48
|
+
*
|
|
49
|
+
* @param {number} threadId - The ID of the thread to unlock.
|
|
50
|
+
* @param {string} brand - The brand associated with the unlock action.
|
|
51
|
+
* @return {Promise<void>} - A promise that resolves when the thread is unlocked.
|
|
52
|
+
* @throws {HttpError} - If the request fails.
|
|
53
|
+
*/
|
|
54
|
+
export async function unfollowThread(threadId: number, brand: string): Promise<void> {
|
|
55
|
+
const httpClient = new HttpClient(globalConfig.baseUrl)
|
|
56
|
+
return httpClient.delete<void>(`${baseUrl}/v1/threads/${threadId}/follow?brand=${brand}`)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface FetchThreadParams {
|
|
60
|
+
is_followed?: boolean,
|
|
61
|
+
page?: number,
|
|
62
|
+
limit?: number,
|
|
63
|
+
sort?: '-last_post_published_on' | string
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Fetches forum threads for the given category.
|
|
67
|
+
*
|
|
68
|
+
* @param {number} categoryId - The ID of the forum category.
|
|
69
|
+
* @param {string} brand - The brand context (e.g., "drumeo", "singeo").
|
|
70
|
+
* @param {FetchThreadParams} params - Optional additional parameters (e.g., is_followed, sort("last_post_published_on","-last_post_published_on","mine")).
|
|
71
|
+
* @returns {Promise<PaginatedResponse<ForumThread>>} - A promise that resolves to a paginated list of forum threads.
|
|
72
|
+
* @throws {HttpError} - If the HTTP request fails.
|
|
73
|
+
*/
|
|
74
|
+
export async function fetchThreads(
|
|
75
|
+
categoryId: number,
|
|
76
|
+
brand: string,
|
|
77
|
+
params: FetchThreadParams = {}
|
|
78
|
+
): Promise<PaginatedResponse<ForumThread>> {
|
|
79
|
+
const httpClient = new HttpClient(globalConfig.baseUrl)
|
|
80
|
+
const queryObj: Record<string, string> = { brand, ...Object.fromEntries(
|
|
81
|
+
Object.entries(params).filter(([_, v]) => v !== undefined && v !== null).map(([k, v]) => [k, String(v)])
|
|
82
|
+
)}
|
|
83
|
+
const query = new URLSearchParams(queryObj).toString()
|
|
84
|
+
|
|
85
|
+
const url = `${baseUrl}/v1/categories/${categoryId}/threads?${query}`
|
|
86
|
+
return httpClient.get<PaginatedResponse<ForumThread>>(url)
|
|
87
|
+
}
|
|
88
|
+
|
|
@@ -69,6 +69,27 @@ export async function fetchAwardsForUser(
|
|
|
69
69
|
return response
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Get award progress for the guided course lesson for the authorized user.
|
|
74
|
+
*
|
|
75
|
+
* NOTE: needs error handling for the response from http client
|
|
76
|
+
* (Alexandre: I'm doing it in a different branch/PR: https://github.com/railroadmedia/musora-content-services/pull/349)
|
|
77
|
+
* NOTE: This function still expects brand because FE passes the argument. It is ignored for now
|
|
78
|
+
*
|
|
79
|
+
* @param {number} guidedCourseLessonId - The guided course lesson Id
|
|
80
|
+
* @returns {Promise<Award>} - The award data for a given award and given user.
|
|
81
|
+
*/
|
|
82
|
+
export async function getAwardDataForGuidedContent(
|
|
83
|
+
guidedCourseLessonId,
|
|
84
|
+
): Promise<Award> {
|
|
85
|
+
const httpClient = new HttpClient(globalConfig.baseUrl, globalConfig.sessionConfig.token)
|
|
86
|
+
const response = await httpClient.get<Award>(
|
|
87
|
+
`${baseUrl}/v1/users/guided_course_award/${guidedCourseLessonId}`
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
return response
|
|
91
|
+
}
|
|
92
|
+
|
|
72
93
|
/**
|
|
73
94
|
* Get certificate data for a completed user award
|
|
74
95
|
*
|