musora-content-services 1.0.174 → 1.0.176
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/.github/workflows/node.js.yml +0 -0
- package/CHANGELOG.md +4 -0
- package/README.md +0 -0
- package/babel.config.js +0 -0
- package/docs/config.js.html +2 -2
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/index.html +2 -2
- package/docs/module-Config.html +2 -2
- package/docs/module-Railcontent-Services.html +692 -21
- package/docs/module-Sanity-Services.html +2 -2
- package/docs/railcontent.js.html +101 -4
- package/docs/sanity.js.html +2 -2
- package/docs/scripts/collapse.js +0 -0
- package/docs/scripts/commonNav.js +0 -0
- package/docs/scripts/linenumber.js +0 -0
- package/docs/scripts/nav.js +0 -0
- package/docs/scripts/polyfill.js +0 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -0
- package/docs/scripts/prettify/lang-css.js +0 -0
- package/docs/scripts/prettify/prettify.js +0 -0
- package/docs/scripts/search.js +0 -0
- package/docs/styles/jsdoc.css +0 -0
- package/docs/styles/prettify.css +0 -0
- package/jest.config.js +0 -0
- package/jsdoc.json +0 -0
- package/package.json +1 -1
- package/src/contentMetaData.js +0 -0
- package/src/filterBuilder.js +0 -0
- package/src/index.d.ts +6 -0
- package/src/index.js +6 -0
- package/src/services/config.js +0 -0
- package/src/services/contentLikes.js +0 -0
- package/src/services/dataContext.js +0 -0
- package/src/services/lastUpdated.js +0 -0
- package/src/services/railcontent.js +99 -2
- package/src/services/userPermissions.js +0 -0
- package/test/contentLikes.test.js +0 -0
- package/test/initializeTests.js +0 -0
- package/test/lastUpdated.test.js +0 -0
- package/test/live/contentProgressLive.test.js +0 -0
- package/test/localStorageMock.js +0 -0
- package/test/log.js +0 -0
- package/test/sanityQueryService.test.js +18 -18
- package/test/userPermissions.test.js +0 -0
- package/tools/generate-index.js +0 -0
|
@@ -485,6 +485,7 @@ export async function postChallengesCompleteLesson(contentId) {
|
|
|
485
485
|
* @param {number} [params.page=1] - The page number for pagination.
|
|
486
486
|
* @param {string} [params.sort='-created_at'] - The sorting order for the playlists (default is by created_at in descending order).
|
|
487
487
|
* @param {string} [params.searchTerm] - A search term to filter playlists by name.
|
|
488
|
+
* @param {int|string} [params.content_id] - If content_id exists, the endpoint checks in each playlist if we have the content in the items.
|
|
488
489
|
*
|
|
489
490
|
* @returns {Promise<Object|null>} - A promise that resolves to the response from the API, containing the user playlists data.
|
|
490
491
|
*
|
|
@@ -493,13 +494,14 @@ export async function postChallengesCompleteLesson(contentId) {
|
|
|
493
494
|
* .then(playlists => console.log(playlists))
|
|
494
495
|
* .catch(error => console.error(error));
|
|
495
496
|
*/
|
|
496
|
-
export async function fetchUserPlaylists(brand, {page, limit, sort, searchTerm} = {}) {
|
|
497
|
+
export async function fetchUserPlaylists(brand, {page, limit, sort, searchTerm, content_id} = {}) {
|
|
497
498
|
let url;
|
|
498
499
|
const limitString = limit ? `&limit=${limit}` : '';
|
|
499
500
|
const pageString = page ? `&page=${page}` : '';
|
|
500
501
|
const sortString = sort ? `&sort=${sort}` : '';
|
|
501
502
|
const searchFilter = searchTerm ? `&term=${searchTerm}` : '';
|
|
502
|
-
|
|
503
|
+
const content = content_id ? `&content_id=${content_id}` : '';
|
|
504
|
+
url = `/playlists/all?brand=${brand}${limitString}${pageString}${sortString}${searchFilter}${content}`;
|
|
503
505
|
return await fetchHandler(url);
|
|
504
506
|
}
|
|
505
507
|
|
|
@@ -924,6 +926,101 @@ export async function countAssignmentsAndLessons(contentId) {
|
|
|
924
926
|
return await fetchHandler(url);
|
|
925
927
|
}
|
|
926
928
|
|
|
929
|
+
/**
|
|
930
|
+
* Pins a playlist to the user's playlist menu.
|
|
931
|
+
*
|
|
932
|
+
* @param {number} playlistId - The ID of the playlist to pin.
|
|
933
|
+
* @returns {Promise<Object>} - A promise that resolves to an object containing:
|
|
934
|
+
* - `success` (boolean): Indicates if the pinning operation was successful (`true` for success).
|
|
935
|
+
* - `message` (string): A success message if the playlist was pinned successfully.
|
|
936
|
+
* - `error` (string): An error message if the pinning operation fails.
|
|
937
|
+
*
|
|
938
|
+
* Resolves to an error message if the request fails.
|
|
939
|
+
* @throws {Error} - Throws an error if the request fails.
|
|
940
|
+
*
|
|
941
|
+
* @example
|
|
942
|
+
* const playlistId = 123;
|
|
943
|
+
*
|
|
944
|
+
* pinPlaylist(playlistId)
|
|
945
|
+
* .then(response => {
|
|
946
|
+
* if (response.success) {
|
|
947
|
+
* console.log("Playlist pinned successfully:", response.message);
|
|
948
|
+
* } else {
|
|
949
|
+
* console.error("Error:", response.error);
|
|
950
|
+
* }
|
|
951
|
+
* })
|
|
952
|
+
* .catch(error => {
|
|
953
|
+
* console.error("Error pinning playlist:", error);
|
|
954
|
+
* });
|
|
955
|
+
*/
|
|
956
|
+
export async function pinPlaylist(playlistId) {
|
|
957
|
+
const url = `/playlists/pin/${playlistId}`;
|
|
958
|
+
return await fetchHandler(url, "PUT");
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Unpins a playlist
|
|
963
|
+
*
|
|
964
|
+
* @param {number} playlistId - The ID of the playlist to unpin.
|
|
965
|
+
* @returns {Promise<Object>} - A promise that resolves to an object containing:
|
|
966
|
+
* - `success` (boolean): Indicates if the unpinning operation was successful (`true` for success).
|
|
967
|
+
* - `message` (string): A success message if the playlist was unpinned successfully.
|
|
968
|
+
* - `error` (string): An error message if the unpinning operation fails.
|
|
969
|
+
*
|
|
970
|
+
* Resolves to an error message if the request fails.
|
|
971
|
+
* @throws {Error} - Throws an error if the request fails.
|
|
972
|
+
*
|
|
973
|
+
* @example
|
|
974
|
+
* const playlistId = 123;
|
|
975
|
+
*
|
|
976
|
+
* unpinPlaylist(playlistId)
|
|
977
|
+
* .then(response => {
|
|
978
|
+
* if (response.success) {
|
|
979
|
+
* console.log("Playlist unpinned successfully:", response.message);
|
|
980
|
+
* } else {
|
|
981
|
+
* console.error("Error:", response.error);
|
|
982
|
+
* }
|
|
983
|
+
* })
|
|
984
|
+
* .catch(error => {
|
|
985
|
+
* console.error("Error unpinning playlist:", error);
|
|
986
|
+
* });
|
|
987
|
+
*/
|
|
988
|
+
export async function unpinPlaylist(playlistId) {
|
|
989
|
+
const url = `/playlists/unpin/${playlistId}`;
|
|
990
|
+
return await fetchHandler(url, "PUT");
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Fetches the list of pinned playlists for the authenticated user.
|
|
995
|
+
*
|
|
996
|
+
* @param {string} brand - The brand associated with the playlists to fetch.
|
|
997
|
+
* @returns {Promise<Object>} - A promise that resolves to an object containing:
|
|
998
|
+
* - `success` (boolean): Indicates if the fetching operation was successful (`true` for success).
|
|
999
|
+
* - `data` (Array): An array of pinned playlists.
|
|
1000
|
+
* - `error` (string): An error message if the fetching operation fails.
|
|
1001
|
+
*
|
|
1002
|
+
* Resolves to an error message if the request fails.
|
|
1003
|
+
* @throws {Error} - Throws an error if the request fails.
|
|
1004
|
+
*
|
|
1005
|
+
* @example
|
|
1006
|
+
* const brand = "drumeo";
|
|
1007
|
+
*
|
|
1008
|
+
* fetchPinnedPlaylists(brand)
|
|
1009
|
+
* .then(response => {
|
|
1010
|
+
* if (response.success) {
|
|
1011
|
+
* console.log("Pinned playlists:", response.data);
|
|
1012
|
+
* } else {
|
|
1013
|
+
* console.error("Error:", response.error);
|
|
1014
|
+
* }
|
|
1015
|
+
* })
|
|
1016
|
+
* .catch(error => {
|
|
1017
|
+
* console.error("Error fetching pinned playlists:", error);
|
|
1018
|
+
* });
|
|
1019
|
+
*/
|
|
1020
|
+
export async function fetchPinnedPlaylists(brand) {
|
|
1021
|
+
const url = `/playlists/my-pinned-playlists?brand=${brand}`;
|
|
1022
|
+
return await fetchHandler(url, "GET");
|
|
1023
|
+
}
|
|
927
1024
|
|
|
928
1025
|
function fetchAbsolute(url, params) {
|
|
929
1026
|
if (globalConfig.railcontentConfig.baseUrl) {
|
|
File without changes
|
|
File without changes
|
package/test/initializeTests.js
CHANGED
|
File without changes
|
package/test/lastUpdated.test.js
CHANGED
|
File without changes
|
|
File without changes
|
package/test/localStorageMock.js
CHANGED
|
File without changes
|
package/test/log.js
CHANGED
|
File without changes
|
|
@@ -169,24 +169,24 @@ describe('Sanity Queries', function () {
|
|
|
169
169
|
expect(response.entity.length).toBe(1);
|
|
170
170
|
});
|
|
171
171
|
|
|
172
|
-
test('fetchAllSongsCompleted', async () => {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
test('fetchAllSongsNotStarted', async () => {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
});
|
|
172
|
+
// test('fetchAllSongsCompleted', async () => {
|
|
173
|
+
// var mock = jest.spyOn(dataContext, 'fetchData');
|
|
174
|
+
// var json = JSON.parse(`{"version":1,"config":{"key":1,"enabled":1,"checkInterval":1,"refreshInterval":2},"data":{"232979":{"s":"completed","p":100,"t":20,"u":1731108082}}}`);
|
|
175
|
+
// mock.mockImplementation(() =>
|
|
176
|
+
// json);
|
|
177
|
+
// const response = await fetchAll('drumeo', 'song', {progress:"completed"});
|
|
178
|
+
// expect(response.entity[0].id).toBe(232979);
|
|
179
|
+
// expect(response.entity.length).toBe(1);
|
|
180
|
+
// });
|
|
181
|
+
//
|
|
182
|
+
// test('fetchAllSongsNotStarted', async () => {
|
|
183
|
+
// var mock = jest.spyOn(dataContext, 'fetchData');
|
|
184
|
+
// var json = JSON.parse(`{"version":1,"config":{"key":1,"enabled":1,"checkInterval":1,"refreshInterval":2},"data":{"198122":{"s":"started","p":100,"t":20,"u":1731108082},"231622":{"s":"completed","p":100,"t":20,"u":1731108082}}}`);
|
|
185
|
+
// mock.mockImplementation(() =>
|
|
186
|
+
// json); const response = await fetchAll('drumeo', 'song', {progress:"not started"});
|
|
187
|
+
// expect(response.entity[0].id).not.toBe(198122);
|
|
188
|
+
// expect(response.entity[0].id).not.toBe(231622);
|
|
189
|
+
// });
|
|
190
190
|
|
|
191
191
|
test('fetchSongFilterOptions', async () => {
|
|
192
192
|
const response = await fetchSongFilterOptions('drumeo', {});
|
|
File without changes
|
package/tools/generate-index.js
CHANGED
|
File without changes
|