musora-content-services 1.0.148 → 1.0.152
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 +8 -0
- package/README.md +0 -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 +3137 -211
- package/docs/module-Sanity-Services.html +30 -30
- package/docs/railcontent.js.html +373 -5
- package/docs/sanity.js.html +7 -3
- package/package.json +1 -1
- package/src/contentMetaData.js +0 -0
- package/src/contentTypeConfig.js +2 -0
- package/src/filterBuilder.js +0 -0
- package/src/index.d.ts +69 -4
- package/src/index.js +69 -4
- package/src/services/config.js +0 -0
- 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 +520 -6
- package/src/services/sanity.js +74 -0
- package/test/contentLikes.test.js +1 -1
- package/test/contentProgress.test.js +56 -0
- package/test/localStorageMock.js +0 -0
- package/test/log.js +0 -0
- package/test/sanityQueryService.test.js +84 -49
- package/tools/generate-index.js +0 -0
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#.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>
|
|
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,7 +377,367 @@ 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
|
+
}
|
|
373
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
|
+
* @param {number} [updatedData.position] - (Optional) The new position for the playlist item within the playlist.
|
|
646
|
+
* @returns {Promise<Object|null>} - A promise that resolves to an object containing:
|
|
647
|
+
* - `success` (boolean): Indicates if the update was successful (`true` for success).
|
|
648
|
+
* - `data` (Object): The updated playlist item data.
|
|
649
|
+
*
|
|
650
|
+
* Resolves to `null` if the request fails.
|
|
651
|
+
* @throws {Error} - Throws an error if the request fails.
|
|
652
|
+
*
|
|
653
|
+
* @example
|
|
654
|
+
* const updatedData = {
|
|
655
|
+
* user_playlist_item_id: 123,
|
|
656
|
+
* start_second: 30,
|
|
657
|
+
* end_second: 120,
|
|
658
|
+
* playlist_item_name: "Updated Playlist Item Name",
|
|
659
|
+
* position: 2
|
|
660
|
+
* };
|
|
661
|
+
*
|
|
662
|
+
* updatePlaylistItem(updatedData)
|
|
663
|
+
* .then(response => {
|
|
664
|
+
* if (response.success) {
|
|
665
|
+
* console.log("Playlist item updated successfully:", response.data);
|
|
666
|
+
* }
|
|
667
|
+
* })
|
|
668
|
+
* .catch(error => {
|
|
669
|
+
* console.error("Error updating playlist item:", error);
|
|
670
|
+
* });
|
|
671
|
+
*/
|
|
672
|
+
export async function updatePlaylistItem(updatedData) {
|
|
673
|
+
const url = `/playlists/item`;
|
|
674
|
+
return await fetchHandler(url, "POST", null, updatedData);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Deletes a playlist item and repositions other items in the playlist if necessary.
|
|
679
|
+
*
|
|
680
|
+
* @param {Object} payload - The data required to delete the playlist item.
|
|
681
|
+
* @param {number} payload.user_playlist_item_id - The ID of the playlist item to delete.
|
|
682
|
+
* @returns {Promise<Object|null>} - A promise that resolves to an object containing:
|
|
683
|
+
* - `success` (boolean): Indicates if the deletion was successful (`true` for success).
|
|
684
|
+
* - `message` (string): A success message if the item is deleted successfully.
|
|
685
|
+
* - `error` (string): An error message if the deletion fails.
|
|
686
|
+
*
|
|
687
|
+
* Resolves to `null` if the request fails.
|
|
688
|
+
* @throws {Error} - Throws an error if the request fails.
|
|
689
|
+
*
|
|
690
|
+
* @example
|
|
691
|
+
* const payload = {
|
|
692
|
+
* user_playlist_item_id: 123
|
|
693
|
+
* };
|
|
694
|
+
*
|
|
695
|
+
* deletePlaylistItem(payload)
|
|
696
|
+
* .then(response => {
|
|
697
|
+
* if (response.success) {
|
|
698
|
+
* console.log("Playlist item deleted successfully:", response.message);
|
|
699
|
+
* } else {
|
|
700
|
+
* console.error("Error:", response.error);
|
|
701
|
+
* }
|
|
702
|
+
* })
|
|
703
|
+
* .catch(error => {
|
|
704
|
+
* console.error("Error deleting playlist item:", error);
|
|
705
|
+
* });
|
|
706
|
+
*/
|
|
707
|
+
export async function deletePlaylistItem(payload) {
|
|
708
|
+
const url = `/playlists/item`;
|
|
709
|
+
return await fetchHandler(url, "DELETE", null, payload);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Fetches detailed data for a specific playlist item, including associated Sanity and Assignment information if available.
|
|
714
|
+
*
|
|
715
|
+
* @param {Object} payload - The request payload containing necessary parameters.
|
|
716
|
+
* @param {number} payload.user_playlist_item_id - The ID of the playlist item to fetch.
|
|
717
|
+
* @returns {Promise<Object|null>} - A promise that resolves to an object containing the playlist item data, including:
|
|
718
|
+
* - `success` (boolean): Indicates if the retrieval was successful (`true` for success).
|
|
719
|
+
* - `data` (Object): The playlist item data enriched with Sanity and Assignment details.
|
|
720
|
+
*
|
|
721
|
+
* Resolves to `null` if the request fails.
|
|
722
|
+
* @throws {Error} - Throws an error if the request fails.
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* const payload = { user_playlist_item_id: 123 };
|
|
726
|
+
*
|
|
727
|
+
* fetchPlaylistItem(payload)
|
|
728
|
+
* .then(response => {
|
|
729
|
+
* if (response.success) {
|
|
730
|
+
* console.log("Fetched playlist item data:", response.data);
|
|
731
|
+
* }
|
|
732
|
+
* })
|
|
733
|
+
* .catch(error => {
|
|
734
|
+
* console.error("Error fetching playlist item:", error);
|
|
735
|
+
* });
|
|
736
|
+
*/
|
|
737
|
+
export async function fetchPlaylistItem(payload) {
|
|
738
|
+
const url = `/playlists/item`;
|
|
739
|
+
return await fetchHandler(url, "GET", null, payload);
|
|
740
|
+
}
|
|
374
741
|
|
|
375
742
|
function fetchAbsolute(url, params) {
|
|
376
743
|
if (globalConfig.railcontentConfig.baseUrl) {
|
|
@@ -379,7 +746,8 @@ function fetchAbsolute(url, params) {
|
|
|
379
746
|
}
|
|
380
747
|
}
|
|
381
748
|
return fetch(url, params);
|
|
382
|
-
}
|
|
749
|
+
}
|
|
750
|
+
</code></pre>
|
|
383
751
|
</article>
|
|
384
752
|
</section>
|
|
385
753
|
|
|
@@ -393,7 +761,7 @@ function fetchAbsolute(url, params) {
|
|
|
393
761
|
<br class="clear">
|
|
394
762
|
|
|
395
763
|
<footer>
|
|
396
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on
|
|
764
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Fri Nov 01 2024 14:03:54 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
397
765
|
</footer>
|
|
398
766
|
|
|
399
767
|
<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#.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>
|
|
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
|
|
1796
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Fri Nov 01 2024 14:03:54 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/package.json
CHANGED
package/src/contentMetaData.js
CHANGED
|
File without changes
|
package/src/contentTypeConfig.js
CHANGED
|
@@ -481,6 +481,8 @@ function filtersToGroq(filters, selectedFilters = []) {
|
|
|
481
481
|
return filterClauses;
|
|
482
482
|
}
|
|
483
483
|
function groupFilters(filters) {
|
|
484
|
+
if (filters.length === 0) return {};
|
|
485
|
+
|
|
484
486
|
return filters.reduce((acc, filter) => {
|
|
485
487
|
const [category, value] = filter.split(',');
|
|
486
488
|
if (!acc[category]) acc[category] = [];
|
package/src/filterBuilder.js
CHANGED
|
File without changes
|