musora-content-services 1.0.160 → 1.0.161
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 +2 -0
- package/docs/config.js.html +2 -2
- package/docs/index.html +2 -2
- package/docs/module-Config.html +2 -2
- package/docs/module-Railcontent-Services.html +3557 -978
- package/docs/module-Sanity-Services.html +6 -6
- package/docs/railcontent.js.html +239 -17
- package/docs/sanity.js.html +73 -2
- package/package.json +1 -1
- package/src/index.d.ts +4 -0
- package/src/index.js +4 -0
- package/src/services/contentLikes.js +0 -0
- package/src/services/railcontent.js +75 -0
package/docs/sanity.js.html
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<nav >
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Config.html">Config</a><ul class='methods'><li data-type='method'><a href="module-Config.html#~initializeService">initializeService</a></li></ul></li><li><a href="module-Railcontent-Services.html">Railcontent-Services</a><ul class='methods'><li data-type='method'><a href="module-Railcontent-Services.html#.createPlaylist">createPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylist">deletePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistItem">deletePlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistLike">deletePlaylistLike</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.duplicatePlaylist">duplicatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchAllCompletedStates">fetchAllCompletedStates</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedContent">fetchCompletedContent</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedState">fetchCompletedState</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentInProgress">fetchContentInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentPageUserData">fetchContentPageUserData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylist">fetchPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItem">fetchPlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItems">fetchPlaylistItems</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchSongsInProgress">fetchSongsInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserPlaylists">fetchUserPlaylists</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.likePlaylist">likePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylist">updatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylistItem">updatePlaylistItem</a></li></ul></li><li><a href="module-Sanity-Services.html">Sanity-Services</a><ul class='methods'><li data-type='method'><a href="module-Sanity-Services.html#.fetchAll">fetchAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllFilterOptions">fetchAllFilterOptions</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllPacks">fetchAllPacks</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllSongs">fetchAllSongs</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtistLessons">fetchArtistLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtists">fetchArtists</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentId">fetchByRailContentId</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentIds">fetchByRailContentIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByReference">fetchByReference</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCatalogMetadata">fetchCatalogMetadata</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchChallengeOverview">fetchChallengeOverview</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchChildren">fetchChildren</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCoachLessons">fetchCoachLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCourseOverview">fetchCourseOverview</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchFoundation">fetchFoundation</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchGenreLessons">fetchGenreLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchLessonContent">fetchLessonContent</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMetadata">fetchMetadata</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethod">fetchMethod</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildren">fetchMethodChildren</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildrenIds">fetchMethodChildrenIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodNextLesson">fetchMethodNextLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodPreviousNextLesson">fetchMethodPreviousNextLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethods">fetchMethods</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNewReleases">fetchNewReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNextPreviousLesson">fetchNextPreviousLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackAll">fetchPackAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackChildren">fetchPackChildren</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackData">fetchPackData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchParentByRailContentId">fetchParentByRailContentId</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchParentForDownload">fetchParentForDownload</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedLessons">fetchRelatedLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedMethodLessons">fetchRelatedMethodLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedSongs">fetchRelatedSongs</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSanity">fetchSanity</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchScheduledReleases">fetchScheduledReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchShowsData">fetchShowsData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongArtistCount">fetchSongArtistCount</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongById">fetchSongById</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongCount">fetchSongCount</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongFilterOptions">fetchSongFilterOptions</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchUpcomingEvents">fetchUpcomingEvents</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchWorkouts">fetchWorkouts</a></li></ul></li></ul>
|
|
32
|
+
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Config.html">Config</a><ul class='methods'><li data-type='method'><a href="module-Config.html#~initializeService">initializeService</a></li></ul></li><li><a href="module-Railcontent-Services.html">Railcontent-Services</a><ul class='methods'><li data-type='method'><a href="module-Railcontent-Services.html#.addItemToPlaylist">addItemToPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.countAssignmentsAndLessons">countAssignmentsAndLessons</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.createPlaylist">createPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylist">deletePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistItem">deletePlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistLike">deletePlaylistLike</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.duplicatePlaylist">duplicatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchAllCompletedStates">fetchAllCompletedStates</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeIndexMetadata">fetchChallengeIndexMetadata</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeLessonData">fetchChallengeLessonData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeMetadata">fetchChallengeMetadata</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedContent">fetchCompletedContent</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedState">fetchCompletedState</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentInProgress">fetchContentInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentPageUserData">fetchContentPageUserData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylist">fetchPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItem">fetchPlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItems">fetchPlaylistItems</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchSongsInProgress">fetchSongsInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserAward">fetchUserAward</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserChallengeProgress">fetchUserChallengeProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserPlaylists">fetchUserPlaylists</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.likePlaylist">likePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesCommunityNotification">postChallengesCommunityNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesEnroll">postChallengesEnroll</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesEnrollmentNotification">postChallengesEnrollmentNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesLeave">postChallengesLeave</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesSetStartDate">postChallengesSetStartDate</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesUnlock">postChallengesUnlock</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postCompleteLesson">postCompleteLesson</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylist">updatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylistItem">updatePlaylistItem</a></li></ul></li><li><a href="module-Sanity-Services.html">Sanity-Services</a><ul class='methods'><li data-type='method'><a href="module-Sanity-Services.html#.fetchAll">fetchAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllFilterOptions">fetchAllFilterOptions</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllPacks">fetchAllPacks</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllSongs">fetchAllSongs</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtistLessons">fetchArtistLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtists">fetchArtists</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentId">fetchByRailContentId</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentIds">fetchByRailContentIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByReference">fetchByReference</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCatalogMetadata">fetchCatalogMetadata</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchChallengeOverview">fetchChallengeOverview</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchChildren">fetchChildren</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCoachLessons">fetchCoachLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCourseOverview">fetchCourseOverview</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchFoundation">fetchFoundation</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchGenreLessons">fetchGenreLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchLessonContent">fetchLessonContent</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMetadata">fetchMetadata</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethod">fetchMethod</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildren">fetchMethodChildren</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildrenIds">fetchMethodChildrenIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodNextLesson">fetchMethodNextLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodPreviousNextLesson">fetchMethodPreviousNextLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethods">fetchMethods</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNewReleases">fetchNewReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNextPreviousLesson">fetchNextPreviousLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackAll">fetchPackAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackChildren">fetchPackChildren</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackData">fetchPackData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchParentByRailContentId">fetchParentByRailContentId</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchParentForDownload">fetchParentForDownload</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedLessons">fetchRelatedLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedMethodLessons">fetchRelatedMethodLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedSongs">fetchRelatedSongs</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSanity">fetchSanity</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchScheduledReleases">fetchScheduledReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchShowsData">fetchShowsData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongArtistCount">fetchSongArtistCount</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongById">fetchSongById</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongCount">fetchSongCount</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongFilterOptions">fetchSongFilterOptions</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchUpcomingEvents">fetchUpcomingEvents</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchWorkouts">fetchWorkouts</a></li></ul></li></ul>
|
|
33
33
|
|
|
34
34
|
</nav>
|
|
35
35
|
|
|
@@ -1409,6 +1409,77 @@ export async function fetchGenreLessons(brand, name, contentType, {
|
|
|
1409
1409
|
return fetchSanity(query, true);
|
|
1410
1410
|
}
|
|
1411
1411
|
|
|
1412
|
+
export async function fetchTopLevelParentId(railcontentId) {
|
|
1413
|
+
const query = `*[railcontent_id == ${railcontentId}]{
|
|
1414
|
+
railcontent_id,
|
|
1415
|
+
'parents': *[^._id in child[]._ref && !(_id in path('drafts.**'))]{
|
|
1416
|
+
railcontent_id,
|
|
1417
|
+
'parents': *[^._id in child[]._ref && !(_id in path('drafts.**'))]{
|
|
1418
|
+
railcontent_id,
|
|
1419
|
+
'parents': *[^._id in child[]._ref && !(_id in path('drafts.**'))]{
|
|
1420
|
+
railcontent_id,
|
|
1421
|
+
'parents': *[^._id in child[]._ref && !(_id in path('drafts.**'))]{
|
|
1422
|
+
railcontent_id,
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
}`;
|
|
1428
|
+
let response = await fetchSanity(query, false, {processNeedAccess: false});
|
|
1429
|
+
if (!response) return null;
|
|
1430
|
+
let currentLevel = response;
|
|
1431
|
+
for (let i = 0; i < 4; i++) {
|
|
1432
|
+
if (currentLevel['parents'].length > 0) {
|
|
1433
|
+
currentLevel = currentLevel['parents'][0];
|
|
1434
|
+
} else {
|
|
1435
|
+
return currentLevel['railcontent_id'];
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
return null;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
export async function fetchHierarchy(railcontentId) {
|
|
1442
|
+
let topLevelId = await fetchTopLevelParentId(railcontentId);
|
|
1443
|
+
const query = `*[railcontent_id == ${topLevelId}]{
|
|
1444
|
+
railcontent_id,
|
|
1445
|
+
'children': child[]->{
|
|
1446
|
+
railcontent_id,
|
|
1447
|
+
'children': child[]->{
|
|
1448
|
+
railcontent_id,
|
|
1449
|
+
'children': child[]->{
|
|
1450
|
+
railcontent_id,
|
|
1451
|
+
'children': child[]->{
|
|
1452
|
+
railcontent_id,
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
}`;
|
|
1458
|
+
let response = await fetchSanity(query, false, {processNeedAccess: false});
|
|
1459
|
+
if (!response) return null;
|
|
1460
|
+
let data = {
|
|
1461
|
+
parents: {},
|
|
1462
|
+
children: {}
|
|
1463
|
+
};
|
|
1464
|
+
populateHierarchyLookups(response, data, null);
|
|
1465
|
+
return data;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
function populateHierarchyLookups(currentLevel, data, parentId) {
|
|
1469
|
+
let contentId = currentLevel['railcontent_id'];
|
|
1470
|
+
let children = currentLevel['children'];
|
|
1471
|
+
data.parents[contentId] = parentId;
|
|
1472
|
+
if (children) {
|
|
1473
|
+
data.children[contentId] = children.map(child => child['railcontent_id']);
|
|
1474
|
+
for (let i = 0; i < children.length; i++) {
|
|
1475
|
+
populateHierarchyLookups(children[i], data, contentId);
|
|
1476
|
+
}
|
|
1477
|
+
} else {
|
|
1478
|
+
data.children[contentId] = [];
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
|
|
1412
1483
|
|
|
1413
1484
|
/**
|
|
1414
1485
|
*
|
|
@@ -1793,7 +1864,7 @@ function cleanUpGroq(query) {
|
|
|
1793
1864
|
<br class="clear">
|
|
1794
1865
|
|
|
1795
1866
|
<footer>
|
|
1796
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Fri Nov
|
|
1867
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Fri Nov 08 2024 14:13:46 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1797
1868
|
</footer>
|
|
1798
1869
|
|
|
1799
1870
|
<script>prettyPrint();</script>
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ import {
|
|
|
23
23
|
} from './services/contentProgress.js';
|
|
24
24
|
|
|
25
25
|
import {
|
|
26
|
+
addItemToPlaylist,
|
|
27
|
+
countAssignmentsAndLessons,
|
|
26
28
|
createPlaylist,
|
|
27
29
|
deletePlaylist,
|
|
28
30
|
deletePlaylistItem,
|
|
@@ -122,8 +124,10 @@ import {
|
|
|
122
124
|
|
|
123
125
|
declare module 'musora-content-services' {
|
|
124
126
|
export {
|
|
127
|
+
addItemToPlaylist,
|
|
125
128
|
contentStatusCompleted,
|
|
126
129
|
contentStatusReset,
|
|
130
|
+
countAssignmentsAndLessons,
|
|
127
131
|
createPlaylist,
|
|
128
132
|
deletePlaylist,
|
|
129
133
|
deletePlaylistItem,
|
package/src/index.js
CHANGED
|
@@ -23,6 +23,8 @@ import {
|
|
|
23
23
|
} from './services/contentProgress.js';
|
|
24
24
|
|
|
25
25
|
import {
|
|
26
|
+
addItemToPlaylist,
|
|
27
|
+
countAssignmentsAndLessons,
|
|
26
28
|
createPlaylist,
|
|
27
29
|
deletePlaylist,
|
|
28
30
|
deletePlaylistItem,
|
|
@@ -121,8 +123,10 @@ import {
|
|
|
121
123
|
} from './services/userPermissions.js';
|
|
122
124
|
|
|
123
125
|
export {
|
|
126
|
+
addItemToPlaylist,
|
|
124
127
|
contentStatusCompleted,
|
|
125
128
|
contentStatusReset,
|
|
129
|
+
countAssignmentsAndLessons,
|
|
126
130
|
createPlaylist,
|
|
127
131
|
deletePlaylist,
|
|
128
132
|
deletePlaylistItem,
|
|
File without changes
|
|
@@ -835,6 +835,81 @@ export async function postContentReset(contentId) {
|
|
|
835
835
|
return postDataHandler(url);
|
|
836
836
|
}
|
|
837
837
|
|
|
838
|
+
/**
|
|
839
|
+
* Adds an item to one or more playlists by making a POST request to the `/playlists/add-item` endpoint.
|
|
840
|
+
*
|
|
841
|
+
* @param {Object} payload - The request payload containing necessary parameters.
|
|
842
|
+
* @param {number} payload.content_id - The ID of the content to add to the playlist(s).
|
|
843
|
+
* @param {Array<number>} payload.playlist_id - An array of playlist IDs where the content should be added.
|
|
844
|
+
* @param {boolean} [payload.import_full_soundslice_assignment=false] - Flag to include full Soundslice assignments.
|
|
845
|
+
* @param {boolean} [payload.import_instrumentless_soundslice_assignment=false] - Flag to include instrumentless Soundslice assignments.
|
|
846
|
+
* @param {boolean} [payload.import_high_routine=false] - Flag to include high routine content.
|
|
847
|
+
* @param {boolean} [payload.import_low_routine=false] - Flag to include low routine content.
|
|
848
|
+
* @param {boolean} [payload.import_all_assignments=false] - Flag to include all Soundslice assignments if true.
|
|
849
|
+
*
|
|
850
|
+
* @returns {Promise<Object|null>} - A promise that resolves to an object with the response data, including:
|
|
851
|
+
* - `success` (boolean): Indicates if the items were added successfully (`true` on success).
|
|
852
|
+
* - `limit_excedeed` (Array): A list of playlists where the item limit was exceeded, if any.
|
|
853
|
+
* - `successful` (Array): A list of successfully added items (empty if none).
|
|
854
|
+
*
|
|
855
|
+
* Resolves to `null` if the request fails.
|
|
856
|
+
* @throws {Error} - Throws an error if the request encounters issues during the operation.
|
|
857
|
+
*
|
|
858
|
+
* @example
|
|
859
|
+
* const payload = {
|
|
860
|
+
* content_id: 123,
|
|
861
|
+
* playlist_id: [1, 2, 3],
|
|
862
|
+
* import_all_assignments: true
|
|
863
|
+
* };
|
|
864
|
+
*
|
|
865
|
+
* addItemToPlaylist(payload)
|
|
866
|
+
* .then(response => {
|
|
867
|
+
* if (response?.success) {
|
|
868
|
+
* console.log("Item(s) added to playlist successfully");
|
|
869
|
+
* }
|
|
870
|
+
* if (response?.limit_excedeed) {
|
|
871
|
+
* console.warn("Some playlists exceeded the item limit:", response.limit_excedeed);
|
|
872
|
+
* }
|
|
873
|
+
* })
|
|
874
|
+
* .catch(error => {
|
|
875
|
+
* console.error("Error adding item to playlist:", error);
|
|
876
|
+
* });
|
|
877
|
+
*/
|
|
878
|
+
export async function addItemToPlaylist(payload) {
|
|
879
|
+
const url = `/playlists/add-item`;
|
|
880
|
+
return await fetchHandler(url, "POST", null, payload);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Retrieves the count of lessons and assignments associated with a specific content ID.
|
|
885
|
+
*
|
|
886
|
+
* @param {number} contentId - The ID of the content for which to count lessons and assignments.
|
|
887
|
+
*
|
|
888
|
+
* @returns {Promise<Object|null>} - A promise that resolves to an object containing the counts:
|
|
889
|
+
* - `lessons_count` (number): The number of lessons associated with the content.
|
|
890
|
+
* - `soundslice_assignments_count` (number): The number of Soundslice assignments associated with the content.
|
|
891
|
+
*
|
|
892
|
+
* @example
|
|
893
|
+
* const contentId = 123;
|
|
894
|
+
*
|
|
895
|
+
* countAssignmentsAndLessons(contentId)
|
|
896
|
+
* .then(response => {
|
|
897
|
+
* if (response) {
|
|
898
|
+
* console.log("Lessons count:", response.lessons_count);
|
|
899
|
+
* console.log("Soundslice assignments count:", response.soundslice_assignments_count);
|
|
900
|
+
* } else {
|
|
901
|
+
* console.log("Failed to retrieve counts.");
|
|
902
|
+
* }
|
|
903
|
+
* })
|
|
904
|
+
* .catch(error => {
|
|
905
|
+
* console.error("Error fetching assignments and lessons count:", error);
|
|
906
|
+
* });
|
|
907
|
+
*/
|
|
908
|
+
export async function countAssignmentsAndLessons(contentId) {
|
|
909
|
+
const url = `/playlists/count-lessons-and-assignments/${contentId}`;
|
|
910
|
+
return await fetchHandler(url);
|
|
911
|
+
}
|
|
912
|
+
|
|
838
913
|
|
|
839
914
|
function fetchAbsolute(url, params) {
|
|
840
915
|
if (globalConfig.railcontentConfig.baseUrl) {
|