musora-content-services 1.0.147 → 1.0.150
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 +6 -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 +2593 -221
- package/docs/module-Sanity-Services.html +30 -30
- package/docs/railcontent.js.html +308 -5
- package/docs/sanity.js.html +7 -3
- package/link_mcs.sh +0 -0
- package/package.json +1 -1
- package/src/contentTypeConfig.js +3 -0
- package/src/index.d.ts +61 -4
- package/src/index.js +61 -4
- package/src/services/contentLikes.js +11 -11
- package/src/services/contentProgress.js +153 -0
- package/src/services/dataContext.js +3 -2
- package/src/services/railcontent.js +363 -6
- package/src/services/sanity.js +74 -0
- package/test/contentLikes.test.js +1 -1
- package/test/contentProgress.test.js +56 -0
- package/test/sanityQueryService.test.js +84 -49
package/docs/railcontent.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#.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#.fetchSongsInProgress">fetchSongsInProgress</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#.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#.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#.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>
|
|
33
33
|
|
|
34
34
|
</nav>
|
|
35
35
|
|
|
@@ -285,14 +285,21 @@ async function fetchDataHandler(url, dataVersion, method = "get") {
|
|
|
285
285
|
return fetchHandler(url, method, dataVersion);
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
-
export async function fetchHandler(url, method = "get", dataVersion = null) {
|
|
288
|
+
export async function fetchHandler(url, method = "get", dataVersion = null, body = null) {
|
|
289
289
|
let headers = {
|
|
290
290
|
'Content-Type': 'application/json',
|
|
291
291
|
'X-CSRF-TOKEN': globalConfig.railcontentConfig.token,
|
|
292
292
|
};
|
|
293
293
|
if (dataVersion) headers['Data-Version'] = dataVersion;
|
|
294
|
+
const options = {
|
|
295
|
+
method,
|
|
296
|
+
headers,
|
|
297
|
+
};
|
|
298
|
+
if (body) {
|
|
299
|
+
options.body = JSON.stringify(body);
|
|
300
|
+
}
|
|
294
301
|
try {
|
|
295
|
-
const response = await fetchAbsolute(url,
|
|
302
|
+
const response = await fetchAbsolute(url, options);
|
|
296
303
|
const result = await response.json();
|
|
297
304
|
if (result) {
|
|
298
305
|
return result;
|
|
@@ -370,6 +377,301 @@ export async function postChallengesCommunityNotification(contentId) {
|
|
|
370
377
|
return await fetchHandler(url, 'post');
|
|
371
378
|
}
|
|
372
379
|
|
|
380
|
+
/**
|
|
381
|
+
* Fetches user playlists for a specific brand.
|
|
382
|
+
*
|
|
383
|
+
* Allows optional pagination, sorting, and search parameters to control the result set.
|
|
384
|
+
*
|
|
385
|
+
* @param {string} brand - The brand identifier for which playlists are being fetched.
|
|
386
|
+
* @param {number} [params.limit=10] - The maximum number of playlists to return per page (default is 10).
|
|
387
|
+
* @param {number} [params.page=1] - The page number for pagination.
|
|
388
|
+
* @param {string} [params.sort='-created_at'] - The sorting order for the playlists (default is by created_at in descending order).
|
|
389
|
+
* @param {string} [params.searchTerm] - A search term to filter playlists by name.
|
|
390
|
+
*
|
|
391
|
+
* @returns {Promise<Object|null>} - A promise that resolves to the response from the API, containing the user playlists data.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* fetchUserPlaylists('drumeo', { page: 1, sort: 'name', searchTerm: 'rock' })
|
|
395
|
+
* .then(playlists => console.log(playlists))
|
|
396
|
+
* .catch(error => console.error(error));
|
|
397
|
+
*/
|
|
398
|
+
export async function fetchUserPlaylists(brand, {page, limit, sort, searchTerm} = {}) {
|
|
399
|
+
let url;
|
|
400
|
+
const limitString = limit ? `&limit=${limit}` : '';
|
|
401
|
+
const pageString = page ? `&page=${page}` : '';
|
|
402
|
+
const sortString = sort ? `&sort=${sort}`:'';
|
|
403
|
+
const searchFilter = searchTerm ? `&term=${searchTerm}`: '';
|
|
404
|
+
url = `/playlists/all?brand=${brand}${limitString}${pageString}${sortString}${searchFilter}`;
|
|
405
|
+
return await fetchHandler(url);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Duplicates an existing playlist by sending a POST request to the API.
|
|
410
|
+
*
|
|
411
|
+
* This function calls the `/playlists/duplicate` endpoint, where the server replicates the specified playlist,
|
|
412
|
+
* including its items. Optionally, new `name`, `description`, `category`, or `thumbnail_url` parameters can be provided
|
|
413
|
+
* to customize the duplicated playlist. If a new name is not provided, the server appends " (Duplicate)" to the original name.
|
|
414
|
+
*
|
|
415
|
+
* @param {string|number} playlistId - The unique identifier of the playlist to be duplicated.
|
|
416
|
+
* @param {Object} [playlistData] - Optional data to customize the duplicated playlist.
|
|
417
|
+
* @param {string} [playlistData.name] - New name for the duplicated playlist (default is original name + " (Duplicate)").
|
|
418
|
+
* @param {string} [playlistData.description] - New description for the duplicated playlist (defaults to original description).
|
|
419
|
+
* @param {string} [playlistData.category] - New category for the duplicated playlist (defaults to original category).
|
|
420
|
+
* @param {string} [playlistData.thumbnail_url] - New URL for the duplicated playlist thumbnail (defaults to original thumbnail).
|
|
421
|
+
*
|
|
422
|
+
* @returns {Promise<Object>} - A promise that resolves to the duplicated playlist data, or rejects with an error if the duplication fails.
|
|
423
|
+
*
|
|
424
|
+
* The duplicated playlist contains:
|
|
425
|
+
* - `name` (string): Name of the new playlist.
|
|
426
|
+
* - `description` (string|null): Description of the duplicated playlist.
|
|
427
|
+
* - `category` (string|null): Category of the duplicated playlist.
|
|
428
|
+
* - `thumbnail_url` (string|null): URL of the playlist thumbnail.
|
|
429
|
+
* - `items` (Array): A list of items (e.g., songs, tracks) copied from the original playlist.
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* duplicatePlaylist(12345, { name: "My New Playlist" })
|
|
433
|
+
* .then(duplicatedPlaylist => console.log(duplicatedPlaylist))
|
|
434
|
+
* .catch(error => console.error('Error duplicating playlist:', error));
|
|
435
|
+
*/
|
|
436
|
+
export async function duplicatePlaylist(playlistId, playlistData) {
|
|
437
|
+
let url = `/playlists/duplicate/${playlistId}`;
|
|
438
|
+
return await fetchHandler(url, "post",null, playlistData);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Deletes a user’s playlist along with all associated items by sending a DELETE request to the API.
|
|
443
|
+
*
|
|
444
|
+
* This function calls the `/playlists/playlist` endpoint, where the server verifies the user’s ownership of the specified playlist.
|
|
445
|
+
* If the user is authorized, it deletes both the playlist and its associated items.
|
|
446
|
+
*
|
|
447
|
+
* @param {string|number} playlistId - The unique identifier of the playlist to be deleted.
|
|
448
|
+
*
|
|
449
|
+
* @returns {Promise<Object>} - A promise that resolves to an object containing:
|
|
450
|
+
* - `success` (boolean): Indicates if the deletion was successful (`true` for success).
|
|
451
|
+
* - `message` (string): Success confirmation message (e.g., "Playlist and associated items deleted successfully").
|
|
452
|
+
*
|
|
453
|
+
* If the user is unauthorized or the playlist does not exist, the promise rejects with an error.
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* deletePlaylist(12345)
|
|
457
|
+
* .then(response => {
|
|
458
|
+
* if (response.success) {
|
|
459
|
+
* console.log(response.message);
|
|
460
|
+
* }
|
|
461
|
+
* })
|
|
462
|
+
* .catch(error => console.error('Error deleting playlist:', error));
|
|
463
|
+
*/
|
|
464
|
+
export async function deletePlaylist(playlistId) {
|
|
465
|
+
let url = `/playlists/playlist`;
|
|
466
|
+
const payload = { playlist_id: playlistId };
|
|
467
|
+
return await fetchHandler(url, "delete", null, payload);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Updates a user’s playlist by sending a PUT request with updated data to the API.
|
|
472
|
+
*
|
|
473
|
+
* This function calls the `/playlists/playlist/{playlistId}` endpoint, where the server validates the incoming data
|
|
474
|
+
* and verifies that the authenticated user is the playlist owner. If authorized, it updates the playlist details with the provided data.
|
|
475
|
+
*
|
|
476
|
+
* @param {string|number} playlistId - The unique identifier of the playlist to be updated.
|
|
477
|
+
* @param {Object} updatedData - An object containing the playlist data to update. The possible fields include:
|
|
478
|
+
* - `name` (string): The new name of the playlist (max 255 characters).
|
|
479
|
+
* - `description` (string): A new description for the playlist (max 1000 characters).
|
|
480
|
+
* - `category` (string): The updated category of the playlist (max 255 characters).
|
|
481
|
+
* - `private` (boolean): Whether the playlist is private.
|
|
482
|
+
* - `thumbnail_url` (string): The URL of the playlist thumbnail.
|
|
483
|
+
*
|
|
484
|
+
* @returns {Promise<Object>} - A promise that resolves to an object containing:
|
|
485
|
+
* - `success` (boolean): Indicates if the update was successful (`true` for success).
|
|
486
|
+
* - `message` (string): Success confirmation message if the update is successful.
|
|
487
|
+
* - Other fields containing the updated playlist data.
|
|
488
|
+
*
|
|
489
|
+
* If the user is unauthorized or the data validation fails, the promise rejects with an error.
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* updatePlaylist(12345, { name: "My New Playlist Name", description: "Updated description" })
|
|
493
|
+
* .then(response => {
|
|
494
|
+
* if (response.success) {
|
|
495
|
+
* console.log(response.message);
|
|
496
|
+
* }
|
|
497
|
+
* })
|
|
498
|
+
* .catch(error => console.error('Error updating playlist:', error));
|
|
499
|
+
*/
|
|
500
|
+
export async function updatePlaylist(playlistId, updatedData) {
|
|
501
|
+
const url = `/playlists/playlist/${playlistId}`;
|
|
502
|
+
return await fetchHandler(url, "PUT", null, updatedData);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Creates a new user playlist by sending a POST request with playlist data to the API.
|
|
507
|
+
*
|
|
508
|
+
* This function calls the `/playlists/playlist` endpoint, where the server validates the incoming data and associates
|
|
509
|
+
* the new playlist with the authenticated user. The `name` field is required, while other fields are optional.
|
|
510
|
+
*
|
|
511
|
+
* @param {Object} playlistData - An object containing data to create the playlist. The fields include:
|
|
512
|
+
* - `name` (string): The name of the new playlist (required, max 255 characters).
|
|
513
|
+
* - `description` (string): A description of the playlist (optional, max 1000 characters).
|
|
514
|
+
* - `category` (string): The category of the playlist.
|
|
515
|
+
* - `thumbnail_url` (string): The URL of the playlist thumbnail (optional, must be a valid URL).
|
|
516
|
+
* - `private` (boolean): Whether the playlist is private (optional, defaults to true).
|
|
517
|
+
* - `brand` (string): Brand identifier for the playlist.
|
|
518
|
+
*
|
|
519
|
+
* @returns {Promise<Object>} - A promise that resolves to the created playlist data if successful, or an error response if validation fails.
|
|
520
|
+
*
|
|
521
|
+
* The server response includes:
|
|
522
|
+
* - `message`: Success message indicating playlist creation (e.g., "Playlist created successfully").
|
|
523
|
+
* - `playlist`: The data for the created playlist, including the `user_id` of the authenticated user.
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* createPlaylist({ name: "My Playlist", description: "A cool playlist", private: true })
|
|
527
|
+
* .then(response => console.log(response.message))
|
|
528
|
+
* .catch(error => console.error('Error creating playlist:', error));
|
|
529
|
+
*/
|
|
530
|
+
export async function createPlaylist(playlistData) {
|
|
531
|
+
const url = `/playlists/playlist`;
|
|
532
|
+
return await fetchHandler(url, "POST", null, playlistData);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Sends a request to "like" a playlist on behalf of the authenticated user.
|
|
537
|
+
*
|
|
538
|
+
* This function calls the `/playlists/playlist/like` endpoint, where the server validates the `playlist_id` and checks
|
|
539
|
+
* if the authenticated user has already liked the playlist. If not, it creates a new "like" entry associated with the playlist.
|
|
540
|
+
*
|
|
541
|
+
* @param {string|number} playlistId - The unique identifier of the playlist to be liked.
|
|
542
|
+
*
|
|
543
|
+
* @returns {Promise<Object>} - A promise that resolves with the response from the API. The response contains:
|
|
544
|
+
* - `success` (boolean): Indicates if the like action was successful (`true` for success).
|
|
545
|
+
* - `message` (string): A success message if the playlist is liked successfully, or a notification if it was already liked.
|
|
546
|
+
* - `like` (Object|null): Details of the created "like" entry if the playlist is newly liked, or null if it was already liked.
|
|
547
|
+
*
|
|
548
|
+
* The `like` object in the response includes:
|
|
549
|
+
* - `playlist_id`: The ID of the liked playlist.
|
|
550
|
+
* - `user_id`: The ID of the user who liked the playlist.
|
|
551
|
+
* - `brand`: The brand associated with the like.
|
|
552
|
+
* - `created_at`: Timestamp of when the like was created.
|
|
553
|
+
*
|
|
554
|
+
* @example
|
|
555
|
+
* likePlaylist(12345)
|
|
556
|
+
* .then(response => {
|
|
557
|
+
* if (response.success) {
|
|
558
|
+
* console.log(response.message);
|
|
559
|
+
* }
|
|
560
|
+
* })
|
|
561
|
+
* .catch(error => console.error('Error liking playlist:', error));
|
|
562
|
+
*/
|
|
563
|
+
export async function likePlaylist(playlistId) {
|
|
564
|
+
const url = `/playlists/like`;
|
|
565
|
+
const payload = { playlist_id: playlistId };
|
|
566
|
+
return await fetchHandler(url, "PUT", null, payload);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Removes a "like" from a playlist for the authenticated user.
|
|
571
|
+
*
|
|
572
|
+
* This function sends a DELETE request to the `/playlists/like` endpoint, where the server validates the `playlist_id`
|
|
573
|
+
* and checks if a like by the authenticated user already exists for the specified playlist. If so, it deletes the like.
|
|
574
|
+
*
|
|
575
|
+
* @param {string|number} playlistId - The unique identifier of the playlist whose like is to be removed.
|
|
576
|
+
*
|
|
577
|
+
* @returns {Promise<Object>} - A promise that resolves with the response from the API. The response contains:
|
|
578
|
+
* - `success` (boolean): Indicates if the removal was successful (`true` for success).
|
|
579
|
+
* - `message` (string): A success message if the playlist like is removed successfully or a notification if the playlist was not previously liked.
|
|
580
|
+
*
|
|
581
|
+
* @example
|
|
582
|
+
* deletePlaylistLike(12345)
|
|
583
|
+
* .then(response => {
|
|
584
|
+
* if (response.success) {
|
|
585
|
+
* console.log(response.message);
|
|
586
|
+
* }
|
|
587
|
+
* })
|
|
588
|
+
* .catch(error => console.error('Error removing playlist like:', error));
|
|
589
|
+
*/
|
|
590
|
+
export async function deletePlaylistLike(playlistId) {
|
|
591
|
+
const url = `/playlists/like`;
|
|
592
|
+
const payload = { playlist_id: playlistId };
|
|
593
|
+
return await fetchHandler(url, "DELETE", null, payload);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Retrieves details of a specific playlist by its ID.
|
|
598
|
+
*
|
|
599
|
+
* This function sends a GET request to the `/playlists/playlist` endpoint with a specified playlist ID.
|
|
600
|
+
* The server validates the user's access to the playlist and returns playlist details if the user is authorized.
|
|
601
|
+
*
|
|
602
|
+
* @param {string|number} playlistId - The unique identifier of the playlist to retrieve.
|
|
603
|
+
*
|
|
604
|
+
* @returns {Promise<Object>} - A promise that resolves to the response from the API, containing:
|
|
605
|
+
* - `data` (Object): The playlist details, or an error message if access is denied or the playlist is not found.
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* fetchPlaylist(12345)
|
|
609
|
+
* .then(response => console.log(response.data))
|
|
610
|
+
* .catch(error => console.error('Error fetching playlist:', error));
|
|
611
|
+
*/
|
|
612
|
+
export async function fetchPlaylist(playlistId) {
|
|
613
|
+
const url = `/playlists/playlist?playlist_id=${playlistId}`;
|
|
614
|
+
return await fetchHandler(url, "GET");
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Retrieves items within a specified playlist by playlist ID.
|
|
619
|
+
*
|
|
620
|
+
* This function sends a GET request to the `/playlists/playlist-lessons` endpoint to fetch items in the given playlist.
|
|
621
|
+
* The server combines data from the playlist and additional metadata from Sanity to enhance item details.
|
|
622
|
+
*
|
|
623
|
+
* @param {string|number} playlistId - The unique identifier of the playlist whose items are to be fetched.
|
|
624
|
+
*
|
|
625
|
+
* @returns {Promise<Array<Object>>} - A promise that resolves to an array of playlist items
|
|
626
|
+
*
|
|
627
|
+
* @example
|
|
628
|
+
* fetchPlaylistItems(12345)
|
|
629
|
+
* .then(items => console.log(items))
|
|
630
|
+
* .catch(error => console.error('Error fetching playlist items:', error));
|
|
631
|
+
*/
|
|
632
|
+
export async function fetchPlaylistItems(playlistId) {
|
|
633
|
+
const url = `/playlists/playlist-lessons?playlist_id=${playlistId}`;
|
|
634
|
+
return await fetchHandler(url, "GET");
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Updates a playlist item with the provided data.
|
|
639
|
+
*
|
|
640
|
+
* @param {Object} updatedData - The data to update the playlist item with.
|
|
641
|
+
* @param {number} updatedData.user_playlist_item_id - The ID of the playlist item to update.
|
|
642
|
+
* @param {number} [updatedData.start_second] - (Optional) The start time in seconds for the item.
|
|
643
|
+
* @param {number} [updatedData.end_second] - (Optional) The end time in seconds for the item.
|
|
644
|
+
* @param {string} [updatedData.playlist_item_name] - (Optional) The new name for the playlist item.
|
|
645
|
+
* @returns {Promise<Object|null>} - A promise that resolves to an object containing:
|
|
646
|
+
* - `success` (boolean): Indicates if the update was successful (`true` for success).
|
|
647
|
+
* - `data` (Object): The updated playlist item data.
|
|
648
|
+
*
|
|
649
|
+
* Resolves to `null` if the request fails.
|
|
650
|
+
* @throws {Error} - Throws an error if the request fails.
|
|
651
|
+
*
|
|
652
|
+
* @example
|
|
653
|
+
* const updatedData = {
|
|
654
|
+
* user_playlist_item_id: 123,
|
|
655
|
+
* start_second: 30,
|
|
656
|
+
* end_second: 120,
|
|
657
|
+
* playlist_item_name: "Updated Playlist Item Name"
|
|
658
|
+
* };
|
|
659
|
+
*
|
|
660
|
+
* updatePlaylistItem(updatedData)
|
|
661
|
+
* .then(response => {
|
|
662
|
+
* if (response.success) {
|
|
663
|
+
* console.log("Playlist item updated successfully:", response.data);
|
|
664
|
+
* }
|
|
665
|
+
* })
|
|
666
|
+
* .catch(error => {
|
|
667
|
+
* console.error("Error updating playlist item:", error);
|
|
668
|
+
* });
|
|
669
|
+
*/
|
|
670
|
+
export async function updatePlaylistItem(updatedData) {
|
|
671
|
+
const url = `/playlists/item`;
|
|
672
|
+
return await fetchHandler(url, "POST", null, updatedData);
|
|
673
|
+
}
|
|
674
|
+
|
|
373
675
|
|
|
374
676
|
|
|
375
677
|
function fetchAbsolute(url, params) {
|
|
@@ -379,7 +681,8 @@ function fetchAbsolute(url, params) {
|
|
|
379
681
|
}
|
|
380
682
|
}
|
|
381
683
|
return fetch(url, params);
|
|
382
|
-
}
|
|
684
|
+
}
|
|
685
|
+
</code></pre>
|
|
383
686
|
</article>
|
|
384
687
|
</section>
|
|
385
688
|
|
|
@@ -393,7 +696,7 @@ function fetchAbsolute(url, params) {
|
|
|
393
696
|
<br class="clear">
|
|
394
697
|
|
|
395
698
|
<footer>
|
|
396
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Oct
|
|
699
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Oct 31 2024 13:45:42 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
397
700
|
</footer>
|
|
398
701
|
|
|
399
702
|
<script>prettyPrint();</script>
|
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#.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#.fetchSongsInProgress">fetchSongsInProgress</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#.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#.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#.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>
|
|
33
33
|
|
|
34
34
|
</nav>
|
|
35
35
|
|
|
@@ -691,6 +691,7 @@ export async function fetchAllFilterOptions(
|
|
|
691
691
|
const metaData = processMetadata(brand, contentType, true);
|
|
692
692
|
const allowableFilters = metaData?.allowableFilters || [];
|
|
693
693
|
const tabs = metaData?.tabs || [];
|
|
694
|
+
const catalogName = metaData?.shortname || metaData?.name;
|
|
694
695
|
|
|
695
696
|
const dynamicFilterOptions = allowableFilters.map(filter => getFilterOptions(filter, constructCommonFilter(filter), contentType, brand)).join(' ');
|
|
696
697
|
|
|
@@ -707,7 +708,7 @@ export async function fetchAllFilterOptions(
|
|
|
707
708
|
|
|
708
709
|
const results = await fetchSanity(query, true, { processNeedAccess: false });
|
|
709
710
|
|
|
710
|
-
return includeTabs ? { ...results, tabs } : results;
|
|
711
|
+
return includeTabs ? { ...results, tabs, catalogName } : results;
|
|
711
712
|
}
|
|
712
713
|
|
|
713
714
|
|
|
@@ -950,6 +951,9 @@ export async function fetchNextPreviousLesson(railcontentId) {
|
|
|
950
951
|
*/
|
|
951
952
|
export async function fetchLessonContent(railContentId) {
|
|
952
953
|
const filterParams = {};
|
|
954
|
+
// Format changes made to the `fields` object may also need to be reflected in Musora-web-platform SanityGateway.php $fields object
|
|
955
|
+
// Currently only for challenges and challenge lessons
|
|
956
|
+
// If you're unsure, message Adrian, or just add them.
|
|
953
957
|
const fields = `title,
|
|
954
958
|
published_on,
|
|
955
959
|
"type":_type,
|
|
@@ -1789,7 +1793,7 @@ function cleanUpGroq(query) {
|
|
|
1789
1793
|
<br class="clear">
|
|
1790
1794
|
|
|
1791
1795
|
<footer>
|
|
1792
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Oct
|
|
1796
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Oct 31 2024 13:45:42 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1793
1797
|
</footer>
|
|
1794
1798
|
|
|
1795
1799
|
<script>prettyPrint();</script>
|
package/link_mcs.sh
CHANGED
|
File without changes
|
package/package.json
CHANGED
package/src/contentTypeConfig.js
CHANGED
|
@@ -103,6 +103,7 @@ let contentTypeConfig = {
|
|
|
103
103
|
'"gold_award": gold_award.asset->url',
|
|
104
104
|
'"silver_award": silver_award.asset->url',
|
|
105
105
|
'"bronze_award": bronze_award.asset->url',
|
|
106
|
+
'is_solo_challenge',
|
|
106
107
|
`"lessons": child[]->{
|
|
107
108
|
"id": railcontent_id,
|
|
108
109
|
title,
|
|
@@ -480,6 +481,8 @@ function filtersToGroq(filters, selectedFilters = []) {
|
|
|
480
481
|
return filterClauses;
|
|
481
482
|
}
|
|
482
483
|
function groupFilters(filters) {
|
|
484
|
+
if (filters.length === 0) return {};
|
|
485
|
+
|
|
483
486
|
return filters.reduce((acc, filter) => {
|
|
484
487
|
const [category, value] = filter.split(',');
|
|
485
488
|
if (!acc[category]) acc[category] = [];
|
package/src/index.d.ts
CHANGED
|
@@ -12,6 +12,20 @@ import {
|
|
|
12
12
|
} from './services/contentLikes.js';
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
|
+
contentStatusCompleted,
|
|
16
|
+
contentStatusReset,
|
|
17
|
+
contentStatusStarted,
|
|
18
|
+
getProgressPercentage,
|
|
19
|
+
getProgressState,
|
|
20
|
+
getResumeTimeSeconds,
|
|
21
|
+
recordWatchSession
|
|
22
|
+
} from './services/contentProgress.js';
|
|
23
|
+
|
|
24
|
+
import {
|
|
25
|
+
createPlaylist,
|
|
26
|
+
deletePlaylist,
|
|
27
|
+
deletePlaylistLike,
|
|
28
|
+
duplicatePlaylist,
|
|
15
29
|
fetchAllCompletedStates,
|
|
16
30
|
fetchChallengeLessonData,
|
|
17
31
|
fetchChallengeMetadata,
|
|
@@ -19,17 +33,31 @@ import {
|
|
|
19
33
|
fetchCompletedState,
|
|
20
34
|
fetchContentInProgress,
|
|
21
35
|
fetchContentPageUserData,
|
|
36
|
+
fetchContentProgress,
|
|
22
37
|
fetchHandler,
|
|
38
|
+
fetchPlaylist,
|
|
39
|
+
fetchPlaylistItems,
|
|
23
40
|
fetchSongsInProgress,
|
|
24
41
|
fetchUserAward,
|
|
25
42
|
fetchUserChallengeProgress,
|
|
43
|
+
fetchUserLikes,
|
|
26
44
|
fetchUserPermissions,
|
|
45
|
+
fetchUserPlaylists,
|
|
46
|
+
likePlaylist,
|
|
27
47
|
postChallengesCommunityNotification,
|
|
28
48
|
postChallengesEnroll,
|
|
29
49
|
postChallengesEnrollmentNotification,
|
|
30
50
|
postChallengesLeave,
|
|
31
51
|
postChallengesSetStartDate,
|
|
32
|
-
postChallengesUnlock
|
|
52
|
+
postChallengesUnlock,
|
|
53
|
+
postContentCompleted,
|
|
54
|
+
postContentLiked,
|
|
55
|
+
postContentReset,
|
|
56
|
+
postContentStarted,
|
|
57
|
+
postContentUnliked,
|
|
58
|
+
postRecordWatchSession,
|
|
59
|
+
updatePlaylist,
|
|
60
|
+
updatePlaylistItem
|
|
33
61
|
} from './services/railcontent.js';
|
|
34
62
|
|
|
35
63
|
import {
|
|
@@ -49,6 +77,7 @@ import {
|
|
|
49
77
|
fetchCourseOverview,
|
|
50
78
|
fetchFoundation,
|
|
51
79
|
fetchGenreLessons,
|
|
80
|
+
fetchHierarchy,
|
|
52
81
|
fetchLessonContent,
|
|
53
82
|
fetchLiveEvent,
|
|
54
83
|
fetchMetadata,
|
|
@@ -64,6 +93,7 @@ import {
|
|
|
64
93
|
fetchPackChildren,
|
|
65
94
|
fetchPackData,
|
|
66
95
|
fetchParentByRailContentId,
|
|
96
|
+
fetchParentForDownload,
|
|
67
97
|
fetchRelatedLessons,
|
|
68
98
|
fetchRelatedMethodLessons,
|
|
69
99
|
fetchRelatedSongs,
|
|
@@ -74,14 +104,21 @@ import {
|
|
|
74
104
|
fetchSongById,
|
|
75
105
|
fetchSongCount,
|
|
76
106
|
fetchSongFilterOptions,
|
|
107
|
+
fetchTopLevelParentId,
|
|
77
108
|
fetchUpcomingEvents,
|
|
78
109
|
fetchWorkouts,
|
|
79
|
-
getSortOrder
|
|
80
|
-
fetchParentForDownload,
|
|
110
|
+
getSortOrder
|
|
81
111
|
} from './services/sanity.js';
|
|
82
112
|
|
|
83
113
|
declare module 'musora-content-services' {
|
|
84
114
|
export {
|
|
115
|
+
contentStatusCompleted,
|
|
116
|
+
contentStatusReset,
|
|
117
|
+
contentStatusStarted,
|
|
118
|
+
createPlaylist,
|
|
119
|
+
deletePlaylist,
|
|
120
|
+
deletePlaylistLike,
|
|
121
|
+
duplicatePlaylist,
|
|
85
122
|
fetchAll,
|
|
86
123
|
fetchAllCompletedStates,
|
|
87
124
|
fetchAllFilterOptions,
|
|
@@ -102,10 +139,12 @@ declare module 'musora-content-services' {
|
|
|
102
139
|
fetchCompletedState,
|
|
103
140
|
fetchContentInProgress,
|
|
104
141
|
fetchContentPageUserData,
|
|
142
|
+
fetchContentProgress,
|
|
105
143
|
fetchCourseOverview,
|
|
106
144
|
fetchFoundation,
|
|
107
145
|
fetchGenreLessons,
|
|
108
146
|
fetchHandler,
|
|
147
|
+
fetchHierarchy,
|
|
109
148
|
fetchLessonContent,
|
|
110
149
|
fetchLiveEvent,
|
|
111
150
|
fetchMetadata,
|
|
@@ -121,6 +160,9 @@ declare module 'musora-content-services' {
|
|
|
121
160
|
fetchPackChildren,
|
|
122
161
|
fetchPackData,
|
|
123
162
|
fetchParentByRailContentId,
|
|
163
|
+
fetchParentForDownload,
|
|
164
|
+
fetchPlaylist,
|
|
165
|
+
fetchPlaylistItems,
|
|
124
166
|
fetchRelatedLessons,
|
|
125
167
|
fetchRelatedMethodLessons,
|
|
126
168
|
fetchRelatedSongs,
|
|
@@ -132,23 +174,38 @@ declare module 'musora-content-services' {
|
|
|
132
174
|
fetchSongCount,
|
|
133
175
|
fetchSongFilterOptions,
|
|
134
176
|
fetchSongsInProgress,
|
|
177
|
+
fetchTopLevelParentId,
|
|
135
178
|
fetchUpcomingEvents,
|
|
136
179
|
fetchUserAward,
|
|
137
180
|
fetchUserChallengeProgress,
|
|
181
|
+
fetchUserLikes,
|
|
138
182
|
fetchUserPermissions,
|
|
183
|
+
fetchUserPlaylists,
|
|
139
184
|
fetchWorkouts,
|
|
185
|
+
getProgressPercentage,
|
|
186
|
+
getProgressState,
|
|
187
|
+
getResumeTimeSeconds,
|
|
140
188
|
getSortOrder,
|
|
141
189
|
globalConfig,
|
|
142
190
|
initializeService,
|
|
143
191
|
isContentLiked,
|
|
144
192
|
likeContent,
|
|
193
|
+
likePlaylist,
|
|
145
194
|
postChallengesCommunityNotification,
|
|
146
195
|
postChallengesEnroll,
|
|
147
196
|
postChallengesEnrollmentNotification,
|
|
148
197
|
postChallengesLeave,
|
|
149
198
|
postChallengesSetStartDate,
|
|
150
199
|
postChallengesUnlock,
|
|
200
|
+
postContentCompleted,
|
|
201
|
+
postContentLiked,
|
|
202
|
+
postContentReset,
|
|
203
|
+
postContentStarted,
|
|
204
|
+
postContentUnliked,
|
|
205
|
+
postRecordWatchSession,
|
|
206
|
+
recordWatchSession,
|
|
151
207
|
unlikeContent,
|
|
152
|
-
|
|
208
|
+
updatePlaylist,
|
|
209
|
+
updatePlaylistItem,
|
|
153
210
|
}
|
|
154
211
|
}
|