musora-content-services 2.42.0 → 2.44.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/docs/ContentOrganization.html +2 -2
  3. package/docs/Forums.html +2 -2
  4. package/docs/Gamification.html +2 -2
  5. package/docs/UserManagementSystem.html +2 -2
  6. package/docs/api_types.js.html +2 -2
  7. package/docs/config.js.html +2 -2
  8. package/docs/content-org_content-org.js.html +2 -2
  9. package/docs/content-org_guided-courses.ts.html +2 -2
  10. package/docs/content-org_playlists-types.js.html +2 -2
  11. package/docs/content-org_playlists.js.html +2 -2
  12. package/docs/content.js.html +2 -2
  13. package/docs/forums_categories.ts.html +2 -2
  14. package/docs/forums_forums.ts.html +2 -2
  15. package/docs/forums_threads.ts.html +76 -5
  16. package/docs/gamification_awards.ts.html +2 -2
  17. package/docs/gamification_gamification.js.html +2 -2
  18. package/docs/global.html +2 -2
  19. package/docs/index.html +2 -2
  20. package/docs/module-Accounts.html +2 -2
  21. package/docs/module-Awards.html +2 -2
  22. package/docs/module-Categories.html +24 -0
  23. package/docs/module-Config.html +2 -2
  24. package/docs/module-Content-Services-V2.html +2 -2
  25. package/docs/module-ForumCategories.html +0 -0
  26. package/docs/module-Forums.html +2271 -151
  27. package/docs/module-GuidedCourses.html +2 -2
  28. package/docs/module-Interests.html +2 -2
  29. package/docs/module-Payments.html +2 -2
  30. package/docs/module-Permissions.html +2 -2
  31. package/docs/module-Playlists.html +2 -2
  32. package/docs/module-Railcontent-Services.html +2 -2
  33. package/docs/module-Sanity-Services.html +10 -175
  34. package/docs/module-Sessions.html +2 -2
  35. package/docs/module-Threads.html +176 -1
  36. package/docs/module-UserActivity.html +2 -2
  37. package/docs/module-UserChat.html +2 -2
  38. package/docs/module-UserManagement.html +2 -2
  39. package/docs/module-UserMemberships.html +2 -2
  40. package/docs/module-UserNotifications.html +2 -2
  41. package/docs/module-UserProfile.html +2 -2
  42. package/docs/railcontent.js.html +2 -2
  43. package/docs/sanity.js.html +3 -25
  44. package/docs/userActivity.js.html +2 -2
  45. package/docs/user_account.ts.html +2 -2
  46. package/docs/user_chat.js.html +2 -2
  47. package/docs/user_interests.js.html +2 -2
  48. package/docs/user_management.js.html +2 -2
  49. package/docs/user_memberships.js.html +2 -2
  50. package/docs/user_notifications.js.html +2 -2
  51. package/docs/user_payments.ts.html +2 -2
  52. package/docs/user_permissions.js.html +2 -2
  53. package/docs/user_profile.js.html +2 -2
  54. package/docs/user_sessions.js.html +2 -2
  55. package/docs/user_types.js.html +2 -2
  56. package/docs/user_user-management-system.js.html +2 -2
  57. package/package.json +1 -1
  58. package/src/contentTypeConfig.js +51 -42
  59. package/src/index.d.ts +11 -3
  60. package/src/index.js +11 -3
  61. package/src/services/contentProgress.js +0 -0
  62. package/src/services/forums/threads.ts +74 -3
  63. package/src/services/sanity.js +1 -23
  64. package/src/services/user/memberships.js +0 -0
@@ -17,7 +17,6 @@ export const artistField = `select(
17
17
  export const DEFAULT_FIELDS = [
18
18
  "'sanity_id' : _id",
19
19
  "'id': railcontent_id",
20
- 'railcontent_id',
21
20
  artistOrInstructorName(),
22
21
  `'artist': ${artistField}`,
23
22
  'title',
@@ -25,8 +24,6 @@ export const DEFAULT_FIELDS = [
25
24
  "'thumbnail': thumbnail.asset->url",
26
25
  'difficulty',
27
26
  'difficulty_string',
28
- 'web_url_path',
29
- "'url': web_url_path",
30
27
  'published_on',
31
28
  "'type': _type",
32
29
  "'length_in_seconds' : coalesce(length_in_seconds, soundslice[0].soundslice_length_in_second)",
@@ -35,17 +32,16 @@ export const DEFAULT_FIELDS = [
35
32
  'status',
36
33
  "'slug' : slug.current",
37
34
  "'permission_id': permission[]->railcontent_id",
38
- 'xp',
39
35
  'child_count',
40
- '"lesson_count": coalesce(count(child[]->.child[]->), child_count)',
41
36
  '"parent_id": parent_content_data[0].id',
42
37
  ]
43
38
 
39
+ // these are identical... why
44
40
  export const DEFAULT_CHILD_FIELDS = [
41
+ "'sanity_id' : _id",
45
42
  "'id': railcontent_id",
46
- 'railcontent_id',
47
43
  artistOrInstructorName(),
48
- "'artist': artist->{ 'name': name, 'thumbnail': thumbnail_url.asset->url}",
44
+ `'artist': ${artistField}`,
49
45
  'title',
50
46
  "'image': thumbnail.asset->url",
51
47
  "'thumbnail': thumbnail.asset->url",
@@ -63,6 +59,14 @@ export const DEFAULT_CHILD_FIELDS = [
63
59
  '"parent_id": parent_content_data[0].id',
64
60
  ]
65
61
 
62
+ export const playAlongMp3sField = `{
63
+ 'mp3_no_drums_no_click_url': mp3_no_drums_no_click_url,
64
+ 'mp3_no_drums_yes_click_url': mp3_no_drums_yes_click_url,
65
+ 'mp3_yes_drums_no_click_url': mp3_yes_drums_no_click_url,
66
+ 'mp3_yes_drums_yes_click_url': mp3_yes_drums_yes_click_url,
67
+ }
68
+ `
69
+
66
70
  export const instructorField = `instructor[]->{
67
71
  "id": railcontent_id,
68
72
  name,
@@ -319,44 +323,49 @@ export let contentTypeConfig = {
319
323
  ],
320
324
  slug: 'courses',
321
325
  },
322
- 'parent-download': {
326
+ 'download': {
323
327
  fields: [
324
- '"lesson_count": child_count',
325
- '"instructors": instructor[]->name',
326
- `"description": ${descriptionField}`,
327
328
  `"resource": ${resourcesField}`,
328
- 'xp',
329
- 'total_xp',
330
- '"thumbnail_url":thumbnail.asset->url',
331
- `"lessons": child[]->{
332
- "id": railcontent_id,
333
- title,
334
- published_on,
335
- "type":_type,
336
- "image": thumbnail.asset->url,
337
- length_in_seconds,
338
- "resources": ${resourcesField},
339
- difficulty,
340
- difficulty_string,
341
- artist->,
342
- "thumbnail_url":thumbnail.asset->url,
343
- "description": description[0].children[0].text,
344
- "chapters": ${chapterField},
345
- "instructors":instructor[]->name,
346
- "instructor": instructor[]->{
347
- "id":railcontent_id,
348
- name,
349
- short_bio,
350
- "biography": short_bio[0].children[0].text,
351
- web_url_path,
352
- "coach_card_image": coach_card_image.asset->url,
353
- "coach_profile_image":thumbnail_url.asset->url
354
- },
355
- ${assignmentsField}
356
- video,
357
- parent_content_data,
358
- }`,
329
+ 'soundslice',
330
+ 'instrumentless',
331
+ `"description": ${descriptionField}`,
332
+ `"chapters": ${chapterField}`,
333
+ '"instructors":instructor[]->name',
334
+ `"instructor": ${instructorField}`,
335
+ 'video',
336
+ `"play_along_mp3s": ${playAlongMp3sField}`,
337
+ `...select(
338
+ defined(live_event_start_time) => {
339
+ "live_event_start_time": live_event_start_time,
340
+ "live_event_end_time": live_event_end_time,
341
+ "live_event_youtube_id": live_event_youtube_id,
342
+ "videoId": coalesce(live_event_youtube_id, video.external_id),
343
+ "live_event_is_global": live_global_event == true
344
+ }
345
+ )`
346
+
359
347
  ],
348
+ childFields: [
349
+ `"resource": ${resourcesField}`,
350
+ 'soundslice',
351
+ 'instrumentless',
352
+ `"description": ${descriptionField}`,
353
+ `"chapters": ${chapterField}`,
354
+ '"instructors":instructor[]->name',
355
+ `"instructor": ${instructorField}`,
356
+ 'video',
357
+ `"play_along_mp3s": ${playAlongMp3sField}`,
358
+ `...select(
359
+ defined(live_event_start_time) => {
360
+ "live_event_start_time": live_event_start_time,
361
+ "live_event_end_time": live_event_end_time,
362
+ "live_event_youtube_id": live_event_youtube_id,
363
+ "videoId": coalesce(live_event_youtube_id, video.external_id),
364
+ "live_event_is_global": live_global_event == true
365
+ }
366
+ )`
367
+
368
+ ]
360
369
  },
361
370
  method: {
362
371
  fields: [
package/src/index.d.ts CHANGED
@@ -102,7 +102,12 @@ import {
102
102
  createThread,
103
103
  fetchThreads,
104
104
  followThread,
105
- unfollowThread
105
+ lockThread,
106
+ pinThread,
107
+ unfollowThread,
108
+ unlockThread,
109
+ unpinThread,
110
+ updateThread
106
111
  } from './services/forums/threads.ts';
107
112
 
108
113
  import {
@@ -211,7 +216,6 @@ import {
211
216
  fetchOtherSongVersions,
212
217
  fetchPackAll,
213
218
  fetchPackData,
214
- fetchParentForDownload,
215
219
  fetchPlayAlongsCount,
216
220
  fetchRelatedLessons,
217
221
  fetchRelatedRecommendedContent,
@@ -427,7 +431,6 @@ declare module 'musora-content-services' {
427
431
  fetchOtherSongVersions,
428
432
  fetchPackAll,
429
433
  fetchPackData,
430
- fetchParentForDownload,
431
434
  fetchPlayAlongsCount,
432
435
  fetchPlaylist,
433
436
  fetchPlaylistItems,
@@ -517,6 +520,7 @@ declare module 'musora-content-services' {
517
520
  likeComment,
518
521
  likeContent,
519
522
  likePlaylist,
523
+ lockThread,
520
524
  logUserPractice,
521
525
  login,
522
526
  loginWithProvider,
@@ -530,6 +534,7 @@ declare module 'musora-content-services' {
530
534
  otherStats,
531
535
  pauseLiveEventPolling,
532
536
  pinProgressRow,
537
+ pinThread,
533
538
  postContentComplete,
534
539
  postContentLiked,
535
540
  postContentReset,
@@ -575,12 +580,15 @@ declare module 'musora-content-services' {
575
580
  unlikeComment,
576
581
  unlikeContent,
577
582
  unlikePlaylist,
583
+ unlockThread,
578
584
  unpinProgressRow,
585
+ unpinThread,
579
586
  updateDisplayName,
580
587
  updateForumCategory,
581
588
  updateNotificationSetting,
582
589
  updatePlaylist,
583
590
  updatePracticeNotes,
591
+ updateThread,
584
592
  updateUserPractice,
585
593
  upgradeSubscription,
586
594
  uploadPicture,
package/src/index.js CHANGED
@@ -102,7 +102,12 @@ import {
102
102
  createThread,
103
103
  fetchThreads,
104
104
  followThread,
105
- unfollowThread
105
+ lockThread,
106
+ pinThread,
107
+ unfollowThread,
108
+ unlockThread,
109
+ unpinThread,
110
+ updateThread
106
111
  } from './services/forums/threads.ts';
107
112
 
108
113
  import {
@@ -211,7 +216,6 @@ import {
211
216
  fetchOtherSongVersions,
212
217
  fetchPackAll,
213
218
  fetchPackData,
214
- fetchParentForDownload,
215
219
  fetchPlayAlongsCount,
216
220
  fetchRelatedLessons,
217
221
  fetchRelatedRecommendedContent,
@@ -426,7 +430,6 @@ export {
426
430
  fetchOtherSongVersions,
427
431
  fetchPackAll,
428
432
  fetchPackData,
429
- fetchParentForDownload,
430
433
  fetchPlayAlongsCount,
431
434
  fetchPlaylist,
432
435
  fetchPlaylistItems,
@@ -516,6 +519,7 @@ export {
516
519
  likeComment,
517
520
  likeContent,
518
521
  likePlaylist,
522
+ lockThread,
519
523
  logUserPractice,
520
524
  login,
521
525
  loginWithProvider,
@@ -529,6 +533,7 @@ export {
529
533
  otherStats,
530
534
  pauseLiveEventPolling,
531
535
  pinProgressRow,
536
+ pinThread,
532
537
  postContentComplete,
533
538
  postContentLiked,
534
539
  postContentReset,
@@ -574,12 +579,15 @@ export {
574
579
  unlikeComment,
575
580
  unlikeContent,
576
581
  unlikePlaylist,
582
+ unlockThread,
577
583
  unpinProgressRow,
584
+ unpinThread,
578
585
  updateDisplayName,
579
586
  updateForumCategory,
580
587
  updateNotificationSetting,
581
588
  updatePlaylist,
582
589
  updatePracticeNotes,
590
+ updateThread,
583
591
  updateUserPractice,
584
592
  upgradeSubscription,
585
593
  uploadPicture,
File without changes
@@ -9,9 +9,8 @@ import { PaginatedResponse } from '../api/types'
9
9
  const baseUrl = `/api/forums`
10
10
 
11
11
  export interface CreateThreadParams {
12
- name: string
13
- description: string
14
- weight: number
12
+ title: string
13
+ first_post_content: string
15
14
  brand: string
16
15
  }
17
16
 
@@ -30,6 +29,26 @@ export async function createThread(
30
29
  return httpClient.post<ForumThread>(`${baseUrl}/v1/categories/${categoryId}/threads`, params)
31
30
  }
32
31
 
32
+ export interface UpdateThreadParams {
33
+ title: string
34
+ brand: string
35
+ }
36
+ /**
37
+ * Updates an existing thread under a forum category.
38
+ *
39
+ * @param {number} threadId - The ID of the thread to update.
40
+ * @param {UpdateThreadParams} params - The parameters for updating the thread.
41
+ * @returns {Promise<ForumThread>} - A promise that resolves to the updated thread.
42
+ * @throws {HttpError} - If the request fails.
43
+ */
44
+ export async function updateThread(
45
+ threadId: number,
46
+ params: UpdateThreadParams
47
+ ): Promise<ForumThread> {
48
+ const httpClient = new HttpClient(globalConfig.baseUrl)
49
+ return httpClient.put<ForumThread>(`${baseUrl}/v1/threads/${threadId}`, params)
50
+ }
51
+
33
52
  /**
34
53
  * Follow a thread.
35
54
  *
@@ -86,3 +105,55 @@ export async function fetchThreads(
86
105
  return httpClient.get<PaginatedResponse<ForumThread>>(url)
87
106
  }
88
107
 
108
+ /**
109
+ * Pins a thread to the top of its category.
110
+ *
111
+ * @param {number} threadId - The ID of the thread to pin.
112
+ * @param {string} brand - The brand context (e.g., "drumeo", "singeo").
113
+ * @return {Promise<void>} - A promise that resolves when the thread is pinned.
114
+ * @throws {HttpError} - If the request fails.
115
+ */
116
+ export async function pinThread(threadId: number, brand: string): Promise<void> {
117
+ const httpClient = new HttpClient(globalConfig.baseUrl)
118
+ return httpClient.post<void>(`${baseUrl}/v1/threads/${threadId}/pin`, { brand })
119
+ }
120
+
121
+ /**
122
+ * Unpins a thread from the top of its category.
123
+ *
124
+ * @param {number} threadId - The ID of the thread to unpin.
125
+ * @param {string} brand - The brand context (e.g., "drumeo", "singeo").
126
+ * @return {Promise<void>} - A promise that resolves when the thread is unpinned.
127
+ * @throws {HttpError} - If the request fails.
128
+ */
129
+ export async function unpinThread(threadId: number, brand: string): Promise<void> {
130
+ const httpClient = new HttpClient(globalConfig.baseUrl)
131
+ return httpClient.delete<void>(`${baseUrl}/v1/threads/${threadId}/pin?brand=${brand}`)
132
+ }
133
+
134
+ /**
135
+ * Locks a thread to prevent further posts.
136
+ *
137
+ * @param {number} threadId - The ID of the thread to lock.
138
+ * @param {string} brand - The brand context (e.g., "drumeo", "singeo").
139
+ * @return {Promise<void>} - A promise that resolves when the thread is locked.
140
+ * @throws {HttpError} - If the request fails.
141
+ */
142
+ export async function lockThread(threadId: number, brand: string): Promise<void> {
143
+ const httpClient = new HttpClient(globalConfig.baseUrl)
144
+ return httpClient.post<void>(`${baseUrl}/v1/threads/${threadId}/unlock`, { brand })
145
+ }
146
+
147
+ /**
148
+ * Unlock a thread to allow further posts.
149
+ *
150
+ * @param {number} threadId - The ID of the thread to unlock.
151
+ * @param {string} brand - The brand context (e.g., "drumeo", "singeo").
152
+ * @return {Promise<void>} - A promise that resolves when the thread is unlocked.
153
+ * @throws {HttpError} - If the request fails.
154
+ */
155
+ export async function unlockThread(threadId: number, brand: string): Promise<void> {
156
+ const httpClient = new HttpClient(globalConfig.baseUrl)
157
+ return httpClient.delete<void>(`${baseUrl}/v1/threads/${threadId}/lock?brand=${brand}`)
158
+ }
159
+
@@ -468,7 +468,7 @@ export async function fetchByRailContentId(id, contentType) {
468
468
  /**
469
469
  * Fetch content by an array of Railcontent IDs.
470
470
  *
471
- * @param {Array<string>} ids - The array of Railcontent IDs of the content to fetch.
471
+ * @param {Array<string|number>} ids - The array of Railcontent IDs of the content to fetch.
472
472
  * @param {string} [contentType] - The content type the IDs to add needed fields to the response.
473
473
  * @returns {Promise<Array<Object>|null>} - A promise that resolves to an array of content objects or null if not found.
474
474
  *
@@ -1496,28 +1496,6 @@ export async function fetchCoachLessons(
1496
1496
  return fetchSanity(query, true)
1497
1497
  }
1498
1498
 
1499
- /**
1500
- * Fetch the data needed for the Course Overview screen.
1501
- * @param {string} id - The Railcontent ID of the course
1502
- * @returns {Promise<Object|null>} - The course information and lessons or null if not found.
1503
- *
1504
- * @example
1505
- * fetchParentForDownload('course123')
1506
- * .then(course => console.log(course))
1507
- * .catch(error => console.error(error));
1508
- */
1509
- export async function fetchParentForDownload(id) {
1510
- const query = buildRawQuery(
1511
- `railcontent_id == ${id}`,
1512
- getFieldsForContentType('parent-download'),
1513
- {
1514
- isSingle: true,
1515
- }
1516
- )
1517
-
1518
- return fetchSanity(query, false)
1519
- }
1520
-
1521
1499
  /**
1522
1500
  * Fetch the data needed for the coach screen.
1523
1501
  * @param {string} id - The Railcontent ID of the coach
File without changes