musora-content-services 2.28.2 → 2.28.4
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 +9 -0
- package/docs/ContentOrganization.html +2 -2
- 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_playlists-types.js.html +2 -2
- package/docs/content-org_playlists.js.html +2 -2
- package/docs/content.js.html +23 -16
- package/docs/gamification_awards.js.html +4 -522
- package/docs/gamification_gamification.js.html +2 -2
- package/docs/gamification_types.js.html +2 -2
- package/docs/global.html +2 -2
- package/docs/index.html +2 -2
- package/docs/module-Awards.html +2 -2
- package/docs/module-Config.html +2 -2
- package/docs/module-Content-Services-V2.html +9 -9
- package/docs/module-Interests.html +2 -2
- package/docs/module-Permissions.html +2 -2
- package/docs/module-Playlists.html +2 -2
- package/docs/module-Railcontent-Services.html +591 -2988
- package/docs/module-Sanity-Services.html +228 -680
- package/docs/module-Sessions.html +2 -2
- package/docs/module-UserActivity.html +50 -24
- package/docs/module-UserChat.html +2 -2
- package/docs/module-UserManagement.html +8 -8
- package/docs/module-UserNotifications.html +465 -21
- package/docs/module-UserProfile.html +106 -2
- package/docs/railcontent.js.html +13 -210
- package/docs/sanity.js.html +110 -256
- package/docs/userActivity.js.html +112 -88
- package/docs/user_chat.js.html +2 -2
- package/docs/user_interests.js.html +2 -2
- package/docs/user_management.js.html +5 -3
- package/docs/user_notifications.js.html +63 -15
- package/docs/user_permissions.js.html +2 -2
- package/docs/user_profile.js.html +18 -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/contentMetaData.js +0 -24
- package/src/contentTypeConfig.js +2 -41
- package/src/index.d.ts +0 -30
- package/src/index.js +1 -31
- package/src/services/content.js +2 -2
- package/src/services/railcontent.js +5 -199
- package/src/services/sanity.js +3 -168
- package/src/services/userActivity.js +0 -1
- package/test/live/railcontentLive.test.js +0 -7
- package/test/sanityQueryService.test.js +3 -55
- package/.claude/settings.local.json +0 -8
- package/docs/Content-Organization.html +0 -245
- package/docs/UserManagement.html +0 -269
- package/docs/global.html#User +0 -293
- package/docs/module-Notifications.html +0 -1183
- package/docs/module-Session-Management.html +0 -575
- package/docs/module-User-Activity.html +0 -4410
- package/docs/module-User-Management.html +0 -490
- package/docs/module-User-Permissions.html +0 -406
- package/docs/types.js.html +0 -122
- package/docs/user_user-management.js.html +0 -78
package/src/index.d.ts
CHANGED
|
@@ -115,14 +115,9 @@ import {
|
|
|
115
115
|
editComment,
|
|
116
116
|
fetchAllCompletedStates,
|
|
117
117
|
fetchCarouselCardData,
|
|
118
|
-
fetchChallengeIndexMetadata,
|
|
119
|
-
fetchChallengeLessonData,
|
|
120
|
-
fetchChallengeMetadata,
|
|
121
|
-
fetchChallengeUserActiveChallenges,
|
|
122
118
|
fetchComment,
|
|
123
119
|
fetchCommentRelies,
|
|
124
120
|
fetchComments,
|
|
125
|
-
fetchCompletedChallenges,
|
|
126
121
|
fetchCompletedContent,
|
|
127
122
|
fetchCompletedState,
|
|
128
123
|
fetchContentInProgress,
|
|
@@ -132,13 +127,11 @@ import {
|
|
|
132
127
|
fetchLastInteractedChild,
|
|
133
128
|
fetchLikeCount,
|
|
134
129
|
fetchNextContentDataForParent,
|
|
135
|
-
fetchOwnedChallenges,
|
|
136
130
|
fetchRecentUserActivities,
|
|
137
131
|
fetchSongsInProgress,
|
|
138
132
|
fetchTopComment,
|
|
139
133
|
fetchUserAward,
|
|
140
134
|
fetchUserBadges,
|
|
141
|
-
fetchUserChallengeProgress,
|
|
142
135
|
fetchUserLikes,
|
|
143
136
|
fetchUserPermissionsData,
|
|
144
137
|
fetchUserPracticeMeta,
|
|
@@ -147,14 +140,6 @@ import {
|
|
|
147
140
|
likeComment,
|
|
148
141
|
logUserPractice,
|
|
149
142
|
openComment,
|
|
150
|
-
postChallengesCommunityNotification,
|
|
151
|
-
postChallengesEnroll,
|
|
152
|
-
postChallengesEnrollmentNotification,
|
|
153
|
-
postChallengesHideCompletedBanner,
|
|
154
|
-
postChallengesLeave,
|
|
155
|
-
postChallengesSetStartDate,
|
|
156
|
-
postChallengesSoloNotification,
|
|
157
|
-
postChallengesUnlock,
|
|
158
143
|
postContentComplete,
|
|
159
144
|
postContentLiked,
|
|
160
145
|
postContentReset,
|
|
@@ -353,10 +338,6 @@ declare module 'musora-content-services' {
|
|
|
353
338
|
fetchByRailContentIds,
|
|
354
339
|
fetchByReference,
|
|
355
340
|
fetchCarouselCardData,
|
|
356
|
-
fetchChallengeIndexMetadata,
|
|
357
|
-
fetchChallengeLessonData,
|
|
358
|
-
fetchChallengeMetadata,
|
|
359
|
-
fetchChallengeUserActiveChallenges,
|
|
360
341
|
fetchChatAndLiveEnvent,
|
|
361
342
|
fetchChatSettings,
|
|
362
343
|
fetchCoachLessons,
|
|
@@ -365,7 +346,6 @@ declare module 'musora-content-services' {
|
|
|
365
346
|
fetchCommentModContentData,
|
|
366
347
|
fetchCommentRelies,
|
|
367
348
|
fetchComments,
|
|
368
|
-
fetchCompletedChallenges,
|
|
369
349
|
fetchCompletedContent,
|
|
370
350
|
fetchCompletedState,
|
|
371
351
|
fetchContentInProgress,
|
|
@@ -396,7 +376,6 @@ declare module 'musora-content-services' {
|
|
|
396
376
|
fetchNotificationSettings,
|
|
397
377
|
fetchNotifications,
|
|
398
378
|
fetchOtherSongVersions,
|
|
399
|
-
fetchOwnedChallenges,
|
|
400
379
|
fetchPackAll,
|
|
401
380
|
fetchPackData,
|
|
402
381
|
fetchParentForDownload,
|
|
@@ -428,7 +407,6 @@ declare module 'musora-content-services' {
|
|
|
428
407
|
fetchUpcomingEvents,
|
|
429
408
|
fetchUserAward,
|
|
430
409
|
fetchUserBadges,
|
|
431
|
-
fetchUserChallengeProgress,
|
|
432
410
|
fetchUserLikes,
|
|
433
411
|
fetchUserPermissions,
|
|
434
412
|
fetchUserPermissionsData,
|
|
@@ -496,14 +474,6 @@ declare module 'musora-content-services' {
|
|
|
496
474
|
pinGuidedCourse,
|
|
497
475
|
pinProgressRow,
|
|
498
476
|
pinnedGuidedCourses,
|
|
499
|
-
postChallengesCommunityNotification,
|
|
500
|
-
postChallengesEnroll,
|
|
501
|
-
postChallengesEnrollmentNotification,
|
|
502
|
-
postChallengesHideCompletedBanner,
|
|
503
|
-
postChallengesLeave,
|
|
504
|
-
postChallengesSetStartDate,
|
|
505
|
-
postChallengesSoloNotification,
|
|
506
|
-
postChallengesUnlock,
|
|
507
477
|
postContentComplete,
|
|
508
478
|
postContentLiked,
|
|
509
479
|
postContentReset,
|
package/src/index.js
CHANGED
|
@@ -115,14 +115,9 @@ import {
|
|
|
115
115
|
editComment,
|
|
116
116
|
fetchAllCompletedStates,
|
|
117
117
|
fetchCarouselCardData,
|
|
118
|
-
fetchChallengeIndexMetadata,
|
|
119
|
-
fetchChallengeLessonData,
|
|
120
|
-
fetchChallengeMetadata,
|
|
121
|
-
fetchChallengeUserActiveChallenges,
|
|
122
118
|
fetchComment,
|
|
123
119
|
fetchCommentRelies,
|
|
124
120
|
fetchComments,
|
|
125
|
-
fetchCompletedChallenges,
|
|
126
121
|
fetchCompletedContent,
|
|
127
122
|
fetchCompletedState,
|
|
128
123
|
fetchContentInProgress,
|
|
@@ -132,13 +127,11 @@ import {
|
|
|
132
127
|
fetchLastInteractedChild,
|
|
133
128
|
fetchLikeCount,
|
|
134
129
|
fetchNextContentDataForParent,
|
|
135
|
-
fetchOwnedChallenges,
|
|
136
130
|
fetchRecentUserActivities,
|
|
137
131
|
fetchSongsInProgress,
|
|
138
|
-
fetchTopComment,
|
|
139
132
|
fetchUserAward,
|
|
140
133
|
fetchUserBadges,
|
|
141
|
-
|
|
134
|
+
fetchTopComment,
|
|
142
135
|
fetchUserLikes,
|
|
143
136
|
fetchUserPermissionsData,
|
|
144
137
|
fetchUserPracticeMeta,
|
|
@@ -147,14 +140,6 @@ import {
|
|
|
147
140
|
likeComment,
|
|
148
141
|
logUserPractice,
|
|
149
142
|
openComment,
|
|
150
|
-
postChallengesCommunityNotification,
|
|
151
|
-
postChallengesEnroll,
|
|
152
|
-
postChallengesEnrollmentNotification,
|
|
153
|
-
postChallengesHideCompletedBanner,
|
|
154
|
-
postChallengesLeave,
|
|
155
|
-
postChallengesSetStartDate,
|
|
156
|
-
postChallengesSoloNotification,
|
|
157
|
-
postChallengesUnlock,
|
|
158
143
|
postContentComplete,
|
|
159
144
|
postContentLiked,
|
|
160
145
|
postContentReset,
|
|
@@ -352,10 +337,6 @@ export {
|
|
|
352
337
|
fetchByRailContentIds,
|
|
353
338
|
fetchByReference,
|
|
354
339
|
fetchCarouselCardData,
|
|
355
|
-
fetchChallengeIndexMetadata,
|
|
356
|
-
fetchChallengeLessonData,
|
|
357
|
-
fetchChallengeMetadata,
|
|
358
|
-
fetchChallengeUserActiveChallenges,
|
|
359
340
|
fetchChatAndLiveEnvent,
|
|
360
341
|
fetchChatSettings,
|
|
361
342
|
fetchCoachLessons,
|
|
@@ -364,7 +345,6 @@ export {
|
|
|
364
345
|
fetchCommentModContentData,
|
|
365
346
|
fetchCommentRelies,
|
|
366
347
|
fetchComments,
|
|
367
|
-
fetchCompletedChallenges,
|
|
368
348
|
fetchCompletedContent,
|
|
369
349
|
fetchCompletedState,
|
|
370
350
|
fetchContentInProgress,
|
|
@@ -395,7 +375,6 @@ export {
|
|
|
395
375
|
fetchNotificationSettings,
|
|
396
376
|
fetchNotifications,
|
|
397
377
|
fetchOtherSongVersions,
|
|
398
|
-
fetchOwnedChallenges,
|
|
399
378
|
fetchPackAll,
|
|
400
379
|
fetchPackData,
|
|
401
380
|
fetchParentForDownload,
|
|
@@ -427,7 +406,6 @@ export {
|
|
|
427
406
|
fetchUpcomingEvents,
|
|
428
407
|
fetchUserAward,
|
|
429
408
|
fetchUserBadges,
|
|
430
|
-
fetchUserChallengeProgress,
|
|
431
409
|
fetchUserLikes,
|
|
432
410
|
fetchUserPermissions,
|
|
433
411
|
fetchUserPermissionsData,
|
|
@@ -495,14 +473,6 @@ export {
|
|
|
495
473
|
pinGuidedCourse,
|
|
496
474
|
pinProgressRow,
|
|
497
475
|
pinnedGuidedCourses,
|
|
498
|
-
postChallengesCommunityNotification,
|
|
499
|
-
postChallengesEnroll,
|
|
500
|
-
postChallengesEnrollmentNotification,
|
|
501
|
-
postChallengesHideCompletedBanner,
|
|
502
|
-
postChallengesLeave,
|
|
503
|
-
postChallengesSetStartDate,
|
|
504
|
-
postChallengesSoloNotification,
|
|
505
|
-
postChallengesUnlock,
|
|
506
476
|
postContentComplete,
|
|
507
477
|
postContentLiked,
|
|
508
478
|
postContentReset,
|
package/src/services/content.js
CHANGED
|
@@ -41,7 +41,7 @@ export async function getLessonContentRows (brand='drumeo', pageName = 'lessons'
|
|
|
41
41
|
/**
|
|
42
42
|
* Get data that should be displayed for a specific tab with pagination
|
|
43
43
|
* @param {string} brand - The brand for which to fetch data.
|
|
44
|
-
* @param {string} pageName - The page name (e.g., 'lessons', 'songs'
|
|
44
|
+
* @param {string} pageName - The page name (e.g., 'lessons', 'songs').
|
|
45
45
|
* @param {string} tabName - The name for the selected tab. Should be same name received from fetchMetadata (e.g., 'Individuals', 'Collections','For You').
|
|
46
46
|
* @param {Object} params - Parameters for pagination, sorting, and filter.
|
|
47
47
|
* @param {number} [params.page=1] - The page number for pagination.
|
|
@@ -166,7 +166,7 @@ export async function getRecent(brand, pageName, tabName = 'all', {
|
|
|
166
166
|
* Fetches content rows for a given brand and page with optional filtering by content row slug.
|
|
167
167
|
*
|
|
168
168
|
* @param {string} brand - The brand for which to fetch content rows.
|
|
169
|
-
* @param {string} pageName - The page name (e.g., 'lessons', 'songs'
|
|
169
|
+
* @param {string} pageName - The page name (e.g., 'lessons', 'songs').
|
|
170
170
|
* @param {string|null} contentRowSlug - The specific content row ID to fetch.
|
|
171
171
|
* @param {Object} params - Parameters for pagination.
|
|
172
172
|
* @param {number} [params.page=1] - The page number for pagination.
|
|
@@ -21,8 +21,6 @@ const excludeFromGeneratedIndex = [
|
|
|
21
21
|
'fetchUserPermissionsData',
|
|
22
22
|
]
|
|
23
23
|
|
|
24
|
-
let challengeIndexMetaDataPromise = null
|
|
25
|
-
|
|
26
24
|
/**
|
|
27
25
|
* Fetches the completion status of a specific lesson for the current user.
|
|
28
26
|
*
|
|
@@ -286,8 +284,8 @@ async function postDataHandler(url, data) {
|
|
|
286
284
|
return fetchHandler(url, 'post', null, data)
|
|
287
285
|
}
|
|
288
286
|
|
|
289
|
-
async function
|
|
290
|
-
|
|
287
|
+
async function patchDataHandler_depreciated(url, data) {
|
|
288
|
+
throw Error("PATCH verb throws a CORS error on the FEW. Use PATCH instead")
|
|
291
289
|
}
|
|
292
290
|
|
|
293
291
|
async function putDataHandler(url, data) {
|
|
@@ -347,67 +345,6 @@ export async function postRecordWatchSession(
|
|
|
347
345
|
})
|
|
348
346
|
}
|
|
349
347
|
|
|
350
|
-
/**
|
|
351
|
-
* Fetch enrolled user data for a given challenge. Intended to be used in the enrolled modal
|
|
352
|
-
*
|
|
353
|
-
* @param contentId - railcontent id of the challenge
|
|
354
|
-
* @returns {Promise<any|null>}
|
|
355
|
-
*/
|
|
356
|
-
export async function fetchChallengeMetadata(contentId) {
|
|
357
|
-
let url = `/challenges/${contentId}`
|
|
358
|
-
return await fetchHandler(url, 'get')
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* Fetch lesson, user, and challenge data for a given lesson
|
|
363
|
-
*
|
|
364
|
-
* @param contentId - railcontent id of the lesson
|
|
365
|
-
* @returns {Promise<any|null>}
|
|
366
|
-
*/
|
|
367
|
-
export async function fetchChallengeLessonData(contentId) {
|
|
368
|
-
let url = `/challenges/lessons/${contentId}`
|
|
369
|
-
return await fetchHandler(url, 'get')
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Fetch all owned brand challenges for user
|
|
374
|
-
* @param {string|null} brand - brand
|
|
375
|
-
* @param {int} page - page of data to pull
|
|
376
|
-
* @param {int} limit - number of elements to pull
|
|
377
|
-
* @returns {Promise<any|null>}
|
|
378
|
-
*/
|
|
379
|
-
export async function fetchOwnedChallenges(brand = null, page, limit) {
|
|
380
|
-
let brandParam = brand ? `&brand=${brand}` : ''
|
|
381
|
-
let pageAndLimit = `?page=${page}&limit=${limit}`
|
|
382
|
-
let url = `/challenges/tab_owned/get${pageAndLimit}${brandParam}`
|
|
383
|
-
return await fetchHandler(url, 'get')
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Fetch all completed brand challenges for user
|
|
388
|
-
* @param {string|null} brand - brand
|
|
389
|
-
* @param {int} page - page of data to pull
|
|
390
|
-
* @param {int} limit - number of elements to pull
|
|
391
|
-
* @returns {Promise<any|null>}
|
|
392
|
-
*/
|
|
393
|
-
export async function fetchCompletedChallenges(brand = null, page, limit) {
|
|
394
|
-
let brandParam = brand ? `&brand=${brand}` : ''
|
|
395
|
-
let pageAndLimit = `?page=${page}&limit=${limit}`
|
|
396
|
-
let url = `/challenges/tab_completed/get${pageAndLimit}${brandParam}`
|
|
397
|
-
return await fetchHandler(url, 'get')
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Fetch challenge, lesson, and user metadata for a given challenge
|
|
402
|
-
*
|
|
403
|
-
* @param contentId - railcontent id of the challenge
|
|
404
|
-
* @returns {Promise<any|null>}
|
|
405
|
-
*/
|
|
406
|
-
export async function fetchUserChallengeProgress(contentId) {
|
|
407
|
-
let url = `/challenges/user_data/${contentId}`
|
|
408
|
-
return await fetchHandler(url, 'get')
|
|
409
|
-
}
|
|
410
|
-
|
|
411
348
|
/**
|
|
412
349
|
* Fetch the user's best award for this challenge
|
|
413
350
|
*
|
|
@@ -419,44 +356,6 @@ export async function fetchUserAward(contentId) {
|
|
|
419
356
|
return await fetchHandler(url, 'get')
|
|
420
357
|
}
|
|
421
358
|
|
|
422
|
-
/**
|
|
423
|
-
* Get challenge duration, user progress, and status for the list of challenges
|
|
424
|
-
* Intended to be used on the index page for challenges
|
|
425
|
-
*
|
|
426
|
-
* @param {array} contentIds - arary of railcontent ids of the challenges
|
|
427
|
-
* @returns {Promise<any|null>}
|
|
428
|
-
*/
|
|
429
|
-
export async function fetchChallengeIndexMetadata(contentIds) {
|
|
430
|
-
if (!challengeIndexMetaDataPromise) {
|
|
431
|
-
challengeIndexMetaDataPromise = getChallengeIndexMetadataPromise()
|
|
432
|
-
}
|
|
433
|
-
let results = await challengeIndexMetaDataPromise
|
|
434
|
-
if (Array.isArray(contentIds)) {
|
|
435
|
-
results = results.filter(function (challenge) {
|
|
436
|
-
return contentIds.includes(challenge.content_id)
|
|
437
|
-
})
|
|
438
|
-
}
|
|
439
|
-
return results
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
async function getChallengeIndexMetadataPromise() {
|
|
443
|
-
let url = `/challenges/user_progress_for_index_page/get`
|
|
444
|
-
const result = await fetchHandler(url, 'get')
|
|
445
|
-
challengeIndexMetaDataPromise = null
|
|
446
|
-
return result
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
* Get active brand challenges for the authorized user
|
|
451
|
-
*
|
|
452
|
-
* @returns {Promise<any|null>}
|
|
453
|
-
*/
|
|
454
|
-
export async function fetchChallengeUserActiveChallenges(brand = null) {
|
|
455
|
-
let brandParam = brand ? `?brand=${brand}` : ''
|
|
456
|
-
let url = `/challenges/user_active_challenges/get${brandParam}`
|
|
457
|
-
return await fetchHandler(url, 'get')
|
|
458
|
-
}
|
|
459
|
-
|
|
460
359
|
/**
|
|
461
360
|
* Fetch All Carousel Card Data
|
|
462
361
|
*
|
|
@@ -480,99 +379,6 @@ export async function fetchUserBadges(brand = null) {
|
|
|
480
379
|
return await fetchHandler(url, 'get')
|
|
481
380
|
}
|
|
482
381
|
|
|
483
|
-
/**
|
|
484
|
-
* Enroll a user in a challenge and set the start date of the challenge to the provided day.
|
|
485
|
-
* Clears any existing progress data for this challenge
|
|
486
|
-
*
|
|
487
|
-
* @param {int|string} contentId - railcontent id of the challenge
|
|
488
|
-
* @param {string} startDate - prefered format YYYYMMDD, but any Carbon parsable string will do.
|
|
489
|
-
* @returns {Promise<any|null>}
|
|
490
|
-
*/
|
|
491
|
-
export async function postChallengesSetStartDate(contentId, startDate) {
|
|
492
|
-
let url = `/challenges/set_start_date/${contentId}?start_date=${startDate}`
|
|
493
|
-
return await fetchHandler(url, 'post')
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Enroll the user in the provided challenge and set to unlocked
|
|
498
|
-
* Clears any current progress data for this challenge
|
|
499
|
-
*
|
|
500
|
-
* @param {int|string} contentId - railcontent id of the challenge
|
|
501
|
-
* @returns {Promise<any|null>}
|
|
502
|
-
*/
|
|
503
|
-
export async function postChallengesUnlock(contentId) {
|
|
504
|
-
let url = `/challenges/unlock/${contentId}`
|
|
505
|
-
return await fetchHandler(url, 'post')
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
* Enroll the user in the given challenge on the challenge published_on date
|
|
510
|
-
* Clears any current progress data for this challenge
|
|
511
|
-
*
|
|
512
|
-
* @param {int|string} contentId - railcontent id of the challenge
|
|
513
|
-
* @returns {Promise<any|null>}
|
|
514
|
-
*/
|
|
515
|
-
export async function postChallengesEnroll(contentId) {
|
|
516
|
-
let url = `/challenges/enroll/${contentId}`
|
|
517
|
-
return await fetchHandler(url, 'post')
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* Remove the user from the provided challenge
|
|
522
|
-
* Clears any current progress data for this challenge
|
|
523
|
-
*
|
|
524
|
-
* @param {int|string} contentId - railcontent id of the challenge
|
|
525
|
-
* @returns {Promise<any|null>}
|
|
526
|
-
*/
|
|
527
|
-
export async function postChallengesLeave(contentId) {
|
|
528
|
-
let url = `/challenges/leave/${contentId}`
|
|
529
|
-
return await fetchHandler(url, 'post')
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* Enable enrollment notifications for the provided challenge
|
|
534
|
-
*
|
|
535
|
-
* @param {int|string} contentId - railcontent id of the challenge
|
|
536
|
-
* @returns {Promise<any|null>}
|
|
537
|
-
*/
|
|
538
|
-
export async function postChallengesEnrollmentNotification(contentId) {
|
|
539
|
-
let url = `/challenges/notifications/enrollment_open/${contentId}`
|
|
540
|
-
return await fetchHandler(url, 'post')
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
/**
|
|
544
|
-
* Enable community notifications for the provided challenge
|
|
545
|
-
*
|
|
546
|
-
* @param {int|string} contentId - railcontent id of the challenge
|
|
547
|
-
* @returns {Promise<any|null>}
|
|
548
|
-
*/
|
|
549
|
-
export async function postChallengesCommunityNotification(contentId) {
|
|
550
|
-
let url = `/challenges/notifications/community_reminders/${contentId}`
|
|
551
|
-
return await fetchHandler(url, 'post')
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Enable solo notifications for the provided challenge
|
|
556
|
-
*
|
|
557
|
-
* @param {int|string} contentId - railcontent id of the challenge
|
|
558
|
-
* @returns {Promise<any|null>}
|
|
559
|
-
*/
|
|
560
|
-
export async function postChallengesSoloNotification(contentId) {
|
|
561
|
-
let url = `/challenges/notifications/solo_reminders/${contentId}`
|
|
562
|
-
return await fetchHandler(url, 'post')
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* Hide challenge completed award bannare
|
|
567
|
-
*
|
|
568
|
-
* @param {int|string} contentId - railcontent id of the challenge
|
|
569
|
-
* @returns {Promise<any|null>}
|
|
570
|
-
*/
|
|
571
|
-
export async function postChallengesHideCompletedBanner(contentId) {
|
|
572
|
-
let url = `/challenges/hide_completed_banner/${contentId}`
|
|
573
|
-
return await fetchHandler(url, 'post')
|
|
574
|
-
}
|
|
575
|
-
|
|
576
382
|
export async function postContentComplete(contentId) {
|
|
577
383
|
let url = `/api/content/v1/user/progress/complete/${contentId}`
|
|
578
384
|
return postDataHandler(url)
|
|
@@ -593,7 +399,7 @@ export async function postContentReset(contentId) {
|
|
|
593
399
|
export async function setStudentViewForUser(userId, enable) {
|
|
594
400
|
let url = `/user-management-system/user/update/${userId}`
|
|
595
401
|
let data = { use_student_view: enable ? 1 : 0 }
|
|
596
|
-
return await
|
|
402
|
+
return await putDataHandler(url, data)
|
|
597
403
|
}
|
|
598
404
|
|
|
599
405
|
/**
|
|
@@ -719,7 +525,7 @@ export async function closeComment(commentId) {
|
|
|
719
525
|
const data = {
|
|
720
526
|
conversation_status: 'closed',
|
|
721
527
|
}
|
|
722
|
-
return await
|
|
528
|
+
return await putDataHandler(url, data)
|
|
723
529
|
}
|
|
724
530
|
|
|
725
531
|
/**
|
|
@@ -731,7 +537,7 @@ export async function openComment(commentId) {
|
|
|
731
537
|
const data = {
|
|
732
538
|
conversation_status: 'open',
|
|
733
539
|
}
|
|
734
|
-
return await
|
|
540
|
+
return await putDataHandler(url, data)
|
|
735
541
|
}
|
|
736
542
|
|
|
737
543
|
/**
|
package/src/services/sanity.js
CHANGED
|
@@ -25,8 +25,6 @@ import { processMetadata, typeWithSortOrder } from '../contentMetaData.js'
|
|
|
25
25
|
import { globalConfig } from './config.js'
|
|
26
26
|
|
|
27
27
|
import {
|
|
28
|
-
fetchCompletedChallenges,
|
|
29
|
-
fetchOwnedChallenges,
|
|
30
28
|
fetchNextContentDataForParent,
|
|
31
29
|
fetchHandler,
|
|
32
30
|
} from './railcontent.js'
|
|
@@ -40,7 +38,7 @@ import {fetchRecentActivitiesActiveTabs} from "./userActivity.js";
|
|
|
40
38
|
*
|
|
41
39
|
* @type {string[]}
|
|
42
40
|
*/
|
|
43
|
-
const excludeFromGeneratedIndex = ['
|
|
41
|
+
const excludeFromGeneratedIndex = ['fetchRelatedByLicense']
|
|
44
42
|
|
|
45
43
|
/**
|
|
46
44
|
* Fetch a song by its document ID from Sanity.
|
|
@@ -628,21 +626,6 @@ export async function fetchAll(
|
|
|
628
626
|
progress = 'all',
|
|
629
627
|
} = {}
|
|
630
628
|
) {
|
|
631
|
-
let customResults = await handleCustomFetchAll(brand, type, {
|
|
632
|
-
page,
|
|
633
|
-
limit,
|
|
634
|
-
searchTerm,
|
|
635
|
-
sort,
|
|
636
|
-
includedFields,
|
|
637
|
-
groupBy,
|
|
638
|
-
progressIds,
|
|
639
|
-
useDefaultFields,
|
|
640
|
-
customFields,
|
|
641
|
-
progress,
|
|
642
|
-
})
|
|
643
|
-
if (customResults) {
|
|
644
|
-
return customResults
|
|
645
|
-
}
|
|
646
629
|
let config = contentTypeConfig[type] ?? {}
|
|
647
630
|
let additionalFields = config?.fields ?? []
|
|
648
631
|
let isGroupByOneToOne = (groupBy ? config?.relationships?.[groupBy]?.isOneToOne : false) ?? false
|
|
@@ -665,9 +648,7 @@ export async function fetchAll(
|
|
|
665
648
|
} else {
|
|
666
649
|
typeFilter = type
|
|
667
650
|
? `&& _type == '${type}'`
|
|
668
|
-
:
|
|
669
|
-
? " && (_type != 'challenge-part' && _type != 'challenge')"
|
|
670
|
-
: ''
|
|
651
|
+
: ''
|
|
671
652
|
}
|
|
672
653
|
|
|
673
654
|
// Construct the search filter
|
|
@@ -765,152 +746,6 @@ export async function fetchAll(
|
|
|
765
746
|
return fetchSanity(query, true)
|
|
766
747
|
}
|
|
767
748
|
|
|
768
|
-
/**
|
|
769
|
-
* Fetch all content that requires custom handling or a distinct external call
|
|
770
|
-
* @param {string} brand - The brand for which to fetch content.
|
|
771
|
-
* @param {string} type - The content type to fetch (e.g., 'song', 'artist').
|
|
772
|
-
* @param {Object} params - Parameters for pagination, filtering, sorting, and grouping.
|
|
773
|
-
* @param {number} [params.page=1] - The page number for pagination.
|
|
774
|
-
* @param {number} [params.limit=10] - The number of items per page.
|
|
775
|
-
* @param {string} [params.searchTerm=""] - The search term to filter content by title or artist.
|
|
776
|
-
* @param {string} [params.sort="-published_on"] - The field to sort the content by.
|
|
777
|
-
* @param {Array<string>} [params.includedFields=[]] - The fields to include in the query.
|
|
778
|
-
* @param {string} [params.groupBy=""] - The field to group the results by (e.g., 'artist', 'genre').
|
|
779
|
-
* @param {Array<string>} [params.progressIds=undefined] - An array of railcontent IDs to filter the results by. Used for filtering by progress.
|
|
780
|
-
* @param {boolean} [params.useDefaultFields=true] - use the default sanity fields for content Type
|
|
781
|
-
* @param {Array<string>} [params.customFields=[]] - An array of sanity fields to include in the request
|
|
782
|
-
* @param {string} [params.progress="all"] - An string representing which progress filter to use ("all", "in progress", "complete", "not started").
|
|
783
|
-
* @returns {Promise<Object|null>} - The fetched content data or null if not found.
|
|
784
|
-
*/
|
|
785
|
-
async function handleCustomFetchAll(
|
|
786
|
-
brand,
|
|
787
|
-
type,
|
|
788
|
-
{
|
|
789
|
-
page = 1,
|
|
790
|
-
limit = 10,
|
|
791
|
-
searchTerm = '',
|
|
792
|
-
sort = '-published_on',
|
|
793
|
-
includedFields = [],
|
|
794
|
-
groupBy = '',
|
|
795
|
-
progressIds = undefined,
|
|
796
|
-
useDefaultFields = true,
|
|
797
|
-
customFields = [],
|
|
798
|
-
progress = 'all',
|
|
799
|
-
} = {}
|
|
800
|
-
) {
|
|
801
|
-
if (type === 'challenge') {
|
|
802
|
-
if (groupBy === 'completed') {
|
|
803
|
-
const completedIds = await fetchCompletedChallenges(brand, page, limit)
|
|
804
|
-
return fetchAll(brand, type, {
|
|
805
|
-
page,
|
|
806
|
-
limit,
|
|
807
|
-
searchTerm,
|
|
808
|
-
sort,
|
|
809
|
-
includedFields,
|
|
810
|
-
groupBy: '',
|
|
811
|
-
progressIds: completedIds,
|
|
812
|
-
useDefaultFields,
|
|
813
|
-
customFields,
|
|
814
|
-
progress,
|
|
815
|
-
})
|
|
816
|
-
} else if (groupBy === 'owned') {
|
|
817
|
-
const ownedIds = await fetchOwnedChallenges(brand, page, limit)
|
|
818
|
-
return fetchAll(brand, type, {
|
|
819
|
-
page,
|
|
820
|
-
limit,
|
|
821
|
-
searchTerm,
|
|
822
|
-
sort,
|
|
823
|
-
includedFields,
|
|
824
|
-
groupBy: '',
|
|
825
|
-
progressIds: ownedIds,
|
|
826
|
-
useDefaultFields,
|
|
827
|
-
customFields,
|
|
828
|
-
progress,
|
|
829
|
-
})
|
|
830
|
-
} else if (groupBy === 'difficulty_string') {
|
|
831
|
-
return fetchChallengesByDifficulty(
|
|
832
|
-
brand,
|
|
833
|
-
type,
|
|
834
|
-
page,
|
|
835
|
-
limit,
|
|
836
|
-
searchTerm,
|
|
837
|
-
sort,
|
|
838
|
-
includedFields,
|
|
839
|
-
groupBy,
|
|
840
|
-
progressIds,
|
|
841
|
-
useDefaultFields,
|
|
842
|
-
customFields,
|
|
843
|
-
progress
|
|
844
|
-
)
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
return null
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
async function fetchChallengesByDifficulty(
|
|
851
|
-
brand,
|
|
852
|
-
type,
|
|
853
|
-
page,
|
|
854
|
-
limit,
|
|
855
|
-
searchTerm,
|
|
856
|
-
sort,
|
|
857
|
-
includedFields,
|
|
858
|
-
groupBy,
|
|
859
|
-
progressIds,
|
|
860
|
-
useDefaultFields,
|
|
861
|
-
customFields,
|
|
862
|
-
progress
|
|
863
|
-
) {
|
|
864
|
-
let config = contentTypeConfig['challenge'] ?? {}
|
|
865
|
-
let additionalFields = config?.fields ?? []
|
|
866
|
-
|
|
867
|
-
// Construct the search filter
|
|
868
|
-
const searchFilter = searchTerm
|
|
869
|
-
? groupBy !== ''
|
|
870
|
-
? `&& (^.name match "${searchTerm}*" || title match "${searchTerm}*")`
|
|
871
|
-
: `&& (artist->name match "${searchTerm}*" || instructor[]->name match "${searchTerm}*" || title match "${searchTerm}*" || name match "${searchTerm}*")`
|
|
872
|
-
: ''
|
|
873
|
-
|
|
874
|
-
// Construct the included fields filter, replacing 'difficulty' with 'difficulty_string'
|
|
875
|
-
const includedFieldsFilter = includedFields.length > 0 ? filtersToGroq(includedFields) : ''
|
|
876
|
-
|
|
877
|
-
// limits the results to supplied progressIds for started & completed filters
|
|
878
|
-
const progressFilter = await getProgressFilter(progress, progressIds)
|
|
879
|
-
|
|
880
|
-
let fields = useDefaultFields
|
|
881
|
-
? customFields.concat(DEFAULT_FIELDS, additionalFields)
|
|
882
|
-
: customFields
|
|
883
|
-
let fieldsString = fields.join(',')
|
|
884
|
-
|
|
885
|
-
const lessonsFilter = `_type == 'challenge' && brand == '${brand}' && ^.name == difficulty_string ${searchFilter} ${includedFieldsFilter} ${progressFilter}`
|
|
886
|
-
const lessonsFilterWithRestrictions = await new FilterBuilder(lessonsFilter).buildFilter()
|
|
887
|
-
|
|
888
|
-
const query = `{
|
|
889
|
-
"entity": [
|
|
890
|
-
{"name": "All"},
|
|
891
|
-
{"name": "Novice"},
|
|
892
|
-
{"name": "Beginner"},
|
|
893
|
-
{"name": "Intermediate"},
|
|
894
|
-
{"name": "Advanced"},
|
|
895
|
-
{"name": "Expert"}]
|
|
896
|
-
{
|
|
897
|
-
'id': 0,
|
|
898
|
-
name,
|
|
899
|
-
'all_lessons_count': count(*[${lessonsFilterWithRestrictions}]._id),
|
|
900
|
-
'lessons': *[${lessonsFilterWithRestrictions}]{
|
|
901
|
-
${fieldsString},
|
|
902
|
-
name
|
|
903
|
-
}[0...20]
|
|
904
|
-
},
|
|
905
|
-
"total": 0
|
|
906
|
-
}`
|
|
907
|
-
let data = await fetchSanity(query, true)
|
|
908
|
-
data.entity = data.entity.filter(function (difficulty) {
|
|
909
|
-
return difficulty.lessons.length > 0
|
|
910
|
-
})
|
|
911
|
-
return data
|
|
912
|
-
}
|
|
913
|
-
|
|
914
749
|
async function getProgressFilter(progress, progressIds) {
|
|
915
750
|
switch (progress) {
|
|
916
751
|
case 'all':
|
|
@@ -1632,7 +1467,7 @@ export async function fetchLiveEvent(brand, forcedContentId = null) {
|
|
|
1632
1467
|
*
|
|
1633
1468
|
* @example
|
|
1634
1469
|
* fetchPackData(404048)
|
|
1635
|
-
* .then(
|
|
1470
|
+
* .then(pack => console.log(pack))
|
|
1636
1471
|
* .catch(error => console.error(error));
|
|
1637
1472
|
*/
|
|
1638
1473
|
export async function fetchPackData(id) {
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { initializeTestService } from '../initializeTests'
|
|
2
|
-
import { fetchChallengeIndexMetadata } from '../../src'
|
|
3
2
|
|
|
4
3
|
describe('railcontentLive', function () {
|
|
5
4
|
beforeEach(async () => {
|
|
6
5
|
await initializeTestService(true)
|
|
7
6
|
}, 1000000)
|
|
8
|
-
|
|
9
|
-
test('challengeIndexMetadata', async () => {
|
|
10
|
-
let contentId = 281709
|
|
11
|
-
let results = await fetchChallengeIndexMetadata([contentId])
|
|
12
|
-
expect(Array.isArray(results)).toBe(true)
|
|
13
|
-
})
|
|
14
7
|
})
|