musora-content-services 1.0.98 → 1.0.100
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 +4 -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 +10 -10
- package/docs/module-Sanity-Services.html +458 -29
- package/docs/railcontent.js.html +24 -17
- package/docs/sanity.js.html +102 -9
- package/link_mcs.sh +0 -0
- package/package.json +1 -1
- package/src/contentTypeConfig.js +45 -3
- package/src/index.d.ts +6 -0
- package/src/index.js +6 -0
- package/src/services/railcontent.js +50 -0
- package/src/services/sanity.js +147 -21
- package/src/services/userContext.js +105 -0
- package/test/localStorageMock.js +21 -0
- package/test/sanityQueryService.test.js +6 -0
- package/test/userContext.test.js +86 -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><li data-type='method'><a href="module-Railcontent-Services.html#.fetchVimeoData">fetchVimeoData</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#.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#.fetchLessonContent">fetchLessonContent</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#.fetchParentByRailContentId">fetchParentByRailContentId</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#.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#.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#.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><li data-type='method'><a href="module-Railcontent-Services.html#.fetchVimeoData">fetchVimeoData</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#.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#.fetchParentByRailContentId">fetchParentByRailContentId</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#.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#.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
|
|
|
@@ -173,7 +173,7 @@ export async function fetchSongsInProgress(brand) {
|
|
|
173
173
|
const response = await fetchAbsolute(url, { headers });
|
|
174
174
|
const result = await response.json();
|
|
175
175
|
if(result){
|
|
176
|
-
console.log('fetchSongsInProgress', result);
|
|
176
|
+
//console.log('fetchSongsInProgress', result);
|
|
177
177
|
return result;
|
|
178
178
|
} else {
|
|
179
179
|
console.log('result not json');
|
|
@@ -189,17 +189,20 @@ export async function fetchSongsInProgress(brand) {
|
|
|
189
189
|
*
|
|
190
190
|
* @param {string} type - The content type associated with the content.
|
|
191
191
|
* @param {string} brand - The brand associated with the content.
|
|
192
|
-
* @param {number} [limit=20] - The limit of results per page.
|
|
193
|
-
* @param {number} [page=1] - The page number for pagination.
|
|
192
|
+
* @param {number} [params.limit=20] - The limit of results per page.
|
|
193
|
+
* @param {number} [params.page=1] - The page number for pagination.
|
|
194
194
|
* @returns {Promise<Object|null>} - Returns an object containing in-progress content if found, otherwise null.
|
|
195
195
|
* @example
|
|
196
196
|
* fetchContentInProgress('song', 'drumeo')
|
|
197
197
|
* .then(songs => console.log(songs))
|
|
198
198
|
* .catch(error => console.error(error));
|
|
199
199
|
*/
|
|
200
|
-
export async function fetchContentInProgress(type="all", brand,
|
|
200
|
+
export async function fetchContentInProgress(type="all", brand, {
|
|
201
|
+
page = 1,
|
|
202
|
+
limit = 10,
|
|
203
|
+
} = {}) {
|
|
201
204
|
let url;
|
|
202
|
-
if(type
|
|
205
|
+
if(type === "all") {
|
|
203
206
|
url = `/content/in_progress/${globalConfig.railcontentConfig.userId}?brand=${brand}&limit=${limit}&page=${page}`;
|
|
204
207
|
} else {
|
|
205
208
|
url = `/content/in_progress/${globalConfig.railcontentConfig.userId}?content_type=${type}&brand=${brand}&limit=${limit}&page=${page}`;
|
|
@@ -228,17 +231,20 @@ export async function fetchContentInProgress(type="all", brand, limit=20, page=1
|
|
|
228
231
|
*
|
|
229
232
|
* @param {string} type - The content type associated with the content.
|
|
230
233
|
* @param {string} brand - The brand associated with the content.
|
|
231
|
-
* @param {number} [limit=20] - The limit of results per page.
|
|
232
|
-
* @param {number} [page=1] - The page number for pagination.
|
|
234
|
+
* @param {number} [params.limit=20] - The limit of results per page.
|
|
235
|
+
* @param {number} [params.page=1] - The page number for pagination.
|
|
233
236
|
* @returns {Promise<Object|null>} - Returns an object containing in-progress content if found, otherwise null.
|
|
234
237
|
* @example
|
|
235
238
|
* fetchCompletedContent('song', 'drumeo')
|
|
236
239
|
* .then(songs => console.log(songs))
|
|
237
240
|
* .catch(error => console.error(error));
|
|
238
241
|
*/
|
|
239
|
-
export async function fetchCompletedContent(type="all", brand,
|
|
242
|
+
export async function fetchCompletedContent(type="all", brand, {
|
|
243
|
+
page = 1,
|
|
244
|
+
limit = 10,
|
|
245
|
+
} = {}) {
|
|
240
246
|
let url;
|
|
241
|
-
if(type
|
|
247
|
+
if(type === "all") {
|
|
242
248
|
url = `/content/completed/${globalConfig.railcontentConfig.userId}?brand=${brand}&limit=${limit}&page=${page}`;
|
|
243
249
|
} else {
|
|
244
250
|
url = `/content/completed/${globalConfig.railcontentConfig.userId}?content_type=${type}&brand=${brand}&limit=${limit}&page=${page}`;
|
|
@@ -295,12 +301,13 @@ export async function fetchContentPageUserData(contentId) {
|
|
|
295
301
|
}
|
|
296
302
|
}
|
|
297
303
|
|
|
298
|
-
function fetchAbsolute(url, params) {
|
|
299
|
-
if
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
+
function fetchAbsolute(url, params) {
|
|
305
|
+
if(globalConfig.railcontentConfig.baseUrl) {
|
|
306
|
+
if (url.startsWith('/')) {
|
|
307
|
+
return fetch(globalConfig.railcontentConfig.baseUrl + url, params)
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return fetch(url, params);
|
|
304
311
|
}</code></pre>
|
|
305
312
|
</article>
|
|
306
313
|
</section>
|
|
@@ -315,7 +322,7 @@ function fetchAbsolute(url, params) {
|
|
|
315
322
|
<br class="clear">
|
|
316
323
|
|
|
317
324
|
<footer>
|
|
318
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on
|
|
325
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Sep 12 2024 18:08:47 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
319
326
|
</footer>
|
|
320
327
|
|
|
321
328
|
<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><li data-type='method'><a href="module-Railcontent-Services.html#.fetchVimeoData">fetchVimeoData</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#.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#.fetchLessonContent">fetchLessonContent</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#.fetchParentByRailContentId">fetchParentByRailContentId</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#.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#.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#.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><li data-type='method'><a href="module-Railcontent-Services.html#.fetchVimeoData">fetchVimeoData</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#.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#.fetchParentByRailContentId">fetchParentByRailContentId</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#.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#.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
|
|
|
@@ -300,7 +300,7 @@ export async function fetchWorkouts(brand) {
|
|
|
300
300
|
* @param {string} brand - The brand for which to fetch new releases.
|
|
301
301
|
* @returns {Promise<Object|null>} - The fetched new releases data or null if not found.
|
|
302
302
|
*/
|
|
303
|
-
export async function fetchNewReleases(brand) {
|
|
303
|
+
export async function fetchNewReleases(brand, { page = 1, limit = 10, sort="-published_on" } = {}) {
|
|
304
304
|
const newTypes = {
|
|
305
305
|
'drumeo': ["drum-fest-international-2022", "spotlight", "the-history-of-electronic-drums", "backstage-secrets", "quick-tips", "question-and-answer", "student-collaborations", "live-streams", "live", "podcasts", "solos", "boot-camps", "gear-guides", "performances", "in-rhythm", "challenges", "on-the-road", "diy-drum-experiments", "rhythmic-adventures-of-captain-carson", "study-the-greats", "rhythms-from-another-planet", "tama-drums", "paiste-cymbals", "behind-the-scenes", "exploring-beats", "sonor-drums", "course", "play-along", "student-focus", "coach-stream", "learning-path-level", "unit", "quick-tips", "live", "question-and-answer", "student-review", "boot-camps", "song", "chords-and-scales", "pack", "podcasts", "workout", "challenge", "challenge-part"],
|
|
306
306
|
'pianote': ["student-review", "student-reviews", "question-and-answer", "course", "play-along", "student-focus", "coach-stream", "learning-path-level", "unit", "quick-tips", "live", "question-and-answer", "student-review", "boot-camps", "song", "chords-and-scales", "pack", "podcasts", "workout", "challenge", "challenge-part"],
|
|
@@ -309,7 +309,10 @@ export async function fetchNewReleases(brand) {
|
|
|
309
309
|
'default': ["student-review", "student-reviews", "question-and-answer", "course", "play-along", "student-focus", "coach-stream", "learning-path-level", "unit", "quick-tips", "live", "question-and-answer", "student-review", "boot-camps", "song", "chords-and-scales", "pack", "podcasts", "workout", "challenge", "challenge-part"]
|
|
310
310
|
};
|
|
311
311
|
const typesString = arrayJoinWithQuotes(newTypes[brand] ?? newTypes['default']);
|
|
312
|
-
const
|
|
312
|
+
const start = (page - 1) * limit;
|
|
313
|
+
const end = start + limit;
|
|
314
|
+
const sortOrder = getSortOrder(sort);
|
|
315
|
+
const query = `*[_type in [${typesString}] && brand == '${brand}']{
|
|
313
316
|
"id": railcontent_id,
|
|
314
317
|
title,
|
|
315
318
|
"image": thumbnail.asset->url,
|
|
@@ -321,7 +324,7 @@ export async function fetchNewReleases(brand) {
|
|
|
321
324
|
published_on,
|
|
322
325
|
"type": _type,
|
|
323
326
|
web_url_path,
|
|
324
|
-
} | order(
|
|
327
|
+
} | order(${sortOrder})[${start}..${end}]`
|
|
325
328
|
return fetchSanity(query, true);
|
|
326
329
|
}
|
|
327
330
|
|
|
@@ -333,11 +336,14 @@ export async function fetchNewReleases(brand) {
|
|
|
333
336
|
* @returns {Promise<Object|null>} - A promise that resolves to an array of upcoming event objects or null if not found.
|
|
334
337
|
*
|
|
335
338
|
* @example
|
|
336
|
-
* fetchUpcomingEvents('drumeo'
|
|
339
|
+
* fetchUpcomingEvents('drumeo', {
|
|
340
|
+
* page: 2,
|
|
341
|
+
* limit: 20,
|
|
342
|
+
* })
|
|
337
343
|
* .then(events => console.log(events))
|
|
338
344
|
* .catch(error => console.error(error));
|
|
339
345
|
*/
|
|
340
|
-
export async function fetchUpcomingEvents(brand) {
|
|
346
|
+
export async function fetchUpcomingEvents(brand, { page = 1, limit = 10 } = {}) {
|
|
341
347
|
const baseLiveTypes = ["student-review", "student-reviews", "student-focus", "coach-stream", "live", "question-and-answer", "student-review", "boot-camps", "recording", "pack-bundle-lesson"];
|
|
342
348
|
const liveTypes = {
|
|
343
349
|
'drumeo': [...baseLiveTypes, "drum-fest-international-2022", "spotlight", "the-history-of-electronic-drums", "backstage-secrets", "quick-tips", "student-collaborations", "live-streams", "podcasts", "solos", "gear-guides", "performances", "in-rhythm", "challenges", "on-the-road", "diy-drum-experiments", "rhythmic-adventures-of-captain-carson", "study-the-greats", "rhythms-from-another-planet", "tama-drums", "paiste-cymbals", "behind-the-scenes", "exploring-beats", "sonor-drums"],
|
|
@@ -348,6 +354,8 @@ export async function fetchUpcomingEvents(brand) {
|
|
|
348
354
|
};
|
|
349
355
|
const typesString = arrayJoinWithQuotes(liveTypes[brand] ?? liveTypes['default']);
|
|
350
356
|
const now = getSanityDate(new Date());
|
|
357
|
+
const start = (page - 1) * limit;
|
|
358
|
+
const end = start + limit;
|
|
351
359
|
const query = `*[_type in [${typesString}] && brand == '${brand}' && published_on > '${now}' && status == 'scheduled']{
|
|
352
360
|
"id": railcontent_id,
|
|
353
361
|
title,
|
|
@@ -360,7 +368,7 @@ export async function fetchUpcomingEvents(brand) {
|
|
|
360
368
|
published_on,
|
|
361
369
|
"type": _type,
|
|
362
370
|
web_url_path,
|
|
363
|
-
|
|
371
|
+
} | order(published_on asc)[${start}...${end}]`;
|
|
364
372
|
return fetchSanity(query, true);
|
|
365
373
|
}
|
|
366
374
|
|
|
@@ -484,6 +492,7 @@ export async function fetchAll(brand, type, {
|
|
|
484
492
|
'type': _type,
|
|
485
493
|
name,
|
|
486
494
|
'head_shot_picture_url': thumbnail_url.asset->url,
|
|
495
|
+
web_url_path,
|
|
487
496
|
'all_lessons_count': count(*[_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ${searchFilter} ${includedFieldsFilter} ${progressFilter}]._id),
|
|
488
497
|
'lessons': *[_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{
|
|
489
498
|
${fieldsString},
|
|
@@ -503,6 +512,7 @@ export async function fetchAll(brand, type, {
|
|
|
503
512
|
'type': _type,
|
|
504
513
|
name,
|
|
505
514
|
'head_shot_picture_url': thumbnail_url.asset->url,
|
|
515
|
+
web_url_path,
|
|
506
516
|
'all_lessons_count': count(*[_type == '${type}' && brand == '${brand}' && ^._id in ${groupBy}[]._ref ${searchFilter} ${includedFieldsFilter} ${progressFilter}]._id),
|
|
507
517
|
'lessons': *[_type == '${type}' && brand == '${brand}' && ^._id in ${groupBy}[]._ref ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{
|
|
508
518
|
${fieldsString},
|
|
@@ -974,7 +984,7 @@ export async function fetchLiveEvent(brand) {
|
|
|
974
984
|
* .catch(error => console.error(error));
|
|
975
985
|
*/
|
|
976
986
|
export async function fetchPackChildren(railcontentId) {
|
|
977
|
-
return fetchChildren(railcontentId, 'pack');
|
|
987
|
+
return fetchChildren(railcontentId, 'pack-children');
|
|
978
988
|
}
|
|
979
989
|
|
|
980
990
|
/**
|
|
@@ -1089,6 +1099,89 @@ export async function fetchByReference(brand, {
|
|
|
1089
1099
|
return fetchSanity(query, true);
|
|
1090
1100
|
}
|
|
1091
1101
|
|
|
1102
|
+
/**
|
|
1103
|
+
* Fetch the artist's lessons.
|
|
1104
|
+
* @param {string} brand - The brand for which to fetch lessons.
|
|
1105
|
+
* @param {string} name - The name of the artist
|
|
1106
|
+
* @param {string} contentType - The type of the lessons we need to get from the artist. If not defined, groq will get lessons from all content types
|
|
1107
|
+
* @returns {Promise<Object|null>} - The lessons for the artist and some details about the artist (name and thumbnail).
|
|
1108
|
+
*
|
|
1109
|
+
* @example
|
|
1110
|
+
* fetchArtistLessons('10 Years', 'song')
|
|
1111
|
+
* .then(lessons => console.log(lessons))
|
|
1112
|
+
* .catch(error => console.error(error));
|
|
1113
|
+
*/
|
|
1114
|
+
export async function fetchArtistLessons(brand, name, contentType, {
|
|
1115
|
+
sort = '-published_on',
|
|
1116
|
+
searchTerm = '',
|
|
1117
|
+
page = 1,
|
|
1118
|
+
limit = 10,
|
|
1119
|
+
includedFields = [],
|
|
1120
|
+
} = {}) {
|
|
1121
|
+
const fieldsString = DEFAULT_FIELDS.join(',');
|
|
1122
|
+
const start = (page - 1) * limit;
|
|
1123
|
+
const end = start + limit;
|
|
1124
|
+
const searchFilter = searchTerm ? `&& title match "${searchTerm}*"`: ''
|
|
1125
|
+
const sortOrder = getSortOrder(sort);
|
|
1126
|
+
const addType = contentType ? `_type == '${contentType}' && `:''
|
|
1127
|
+
const includedFieldsFilter = includedFields.length > 0
|
|
1128
|
+
? filtersToGroq(includedFields)
|
|
1129
|
+
: "";
|
|
1130
|
+
|
|
1131
|
+
const query = `{
|
|
1132
|
+
"entity":
|
|
1133
|
+
*[_type == 'artist' && name == '${name}']
|
|
1134
|
+
{'type': _type, name, 'thumbnail_url':thumbnail_url.asset->url,
|
|
1135
|
+
'lessons_count': count(*[${addType} brand == '${brand}' && references(^._id)]),
|
|
1136
|
+
'lessons': *[${addType} brand == '${brand}' && references(^._id) ${searchFilter} ${includedFieldsFilter}]{${fieldsString}}
|
|
1137
|
+
[${start}...${end}]}
|
|
1138
|
+
|order(${sortOrder})
|
|
1139
|
+
}`;
|
|
1140
|
+
return fetchSanity(query, true);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* Fetch the genre's lessons.
|
|
1145
|
+
* @param {string} brand - The brand for which to fetch lessons.
|
|
1146
|
+
* @param {string} name - The name of the genre
|
|
1147
|
+
* @param {string} contentType - The type of the lessons we need to get from the genre. If not defined, groq will get lessons from all content types
|
|
1148
|
+
* @returns {Promise<Object|null>} - The lessons for the genre and some details about the genre (name and thumbnail).
|
|
1149
|
+
*
|
|
1150
|
+
* @example
|
|
1151
|
+
* fetchGenreLessons('Blues', 'song')
|
|
1152
|
+
* .then(lessons => console.log(lessons))
|
|
1153
|
+
* .catch(error => console.error(error));
|
|
1154
|
+
*/
|
|
1155
|
+
export async function fetchGenreLessons(brand, name, contentType, {
|
|
1156
|
+
sort = '-published_on',
|
|
1157
|
+
searchTerm = '',
|
|
1158
|
+
page = 1,
|
|
1159
|
+
limit = 10,
|
|
1160
|
+
includedFields = [],
|
|
1161
|
+
} = {}) {
|
|
1162
|
+
const fieldsString = DEFAULT_FIELDS.join(',');
|
|
1163
|
+
const start = (page - 1) * limit;
|
|
1164
|
+
const end = start + limit;
|
|
1165
|
+
const searchFilter = searchTerm ? `&& title match "${searchTerm}*"`: ''
|
|
1166
|
+
const sortOrder = getSortOrder(sort);
|
|
1167
|
+
const addType = contentType ? `_type == '${contentType}' && `:''
|
|
1168
|
+
const includedFieldsFilter = includedFields.length > 0
|
|
1169
|
+
? filtersToGroq(includedFields)
|
|
1170
|
+
: "";
|
|
1171
|
+
|
|
1172
|
+
const query = `{
|
|
1173
|
+
"entity":
|
|
1174
|
+
*[_type == 'genre' && name == '${name}']
|
|
1175
|
+
{'type': _type, name, 'thumbnail_url':thumbnail_url.asset->url,
|
|
1176
|
+
'lessons_count': count(*[${addType} brand == '${brand}' && references(^._id)]),
|
|
1177
|
+
'lessons': *[${addType} brand == '${brand}' && references(^._id) ${searchFilter} ${includedFieldsFilter}]{${fieldsString}}
|
|
1178
|
+
[${start}...${end}]}
|
|
1179
|
+
|order(${sortOrder})
|
|
1180
|
+
}`;
|
|
1181
|
+
return fetchSanity(query, true);
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
|
|
1092
1185
|
|
|
1093
1186
|
/**
|
|
1094
1187
|
* Fetch data from the Sanity API based on a provided query.
|
|
@@ -1213,7 +1306,7 @@ function checkSanityConfig(config) {
|
|
|
1213
1306
|
<br class="clear">
|
|
1214
1307
|
|
|
1215
1308
|
<footer>
|
|
1216
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on
|
|
1309
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Sep 12 2024 18:08:47 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1217
1310
|
</footer>
|
|
1218
1311
|
|
|
1219
1312
|
<script>prettyPrint();</script>
|
package/link_mcs.sh
CHANGED
|
File without changes
|
package/package.json
CHANGED
package/src/contentTypeConfig.js
CHANGED
|
@@ -78,13 +78,15 @@ let contentTypeConfig = {
|
|
|
78
78
|
'"instructors": instructor[]->name',
|
|
79
79
|
`"description": ${descriptionField}`,
|
|
80
80
|
'resource',
|
|
81
|
+
'xp',
|
|
82
|
+
'total_xp',
|
|
81
83
|
`"lessons": child[]->{
|
|
82
84
|
"id": railcontent_id,
|
|
83
85
|
title,
|
|
84
86
|
"image": thumbnail.asset->url,
|
|
85
87
|
"instructors": instructor[]->name,
|
|
86
88
|
length_in_seconds,
|
|
87
|
-
}`,
|
|
89
|
+
}`,
|
|
88
90
|
]
|
|
89
91
|
},
|
|
90
92
|
'method': {
|
|
@@ -182,9 +184,19 @@ let contentTypeConfig = {
|
|
|
182
184
|
},
|
|
183
185
|
'instructor': {
|
|
184
186
|
'fields': [
|
|
185
|
-
'
|
|
187
|
+
'"coach_top_banner_image": coach_top_banner_image.asset->url',
|
|
188
|
+
'"coach_bottom_banner_image": coach_bottom_banner_image.asset->url',
|
|
186
189
|
'"coach_card_image": coach_card_image.asset->url',
|
|
187
|
-
'
|
|
190
|
+
'"coach_featured_image": coach_featured_image.asset->url',
|
|
191
|
+
'"coach_top_banner_image": coach_top_banner_image.asset->url',
|
|
192
|
+
'focus',
|
|
193
|
+
'focus_text',
|
|
194
|
+
'forum_thread_id',
|
|
195
|
+
'long_bio',
|
|
196
|
+
'name',
|
|
197
|
+
'short_bio',
|
|
198
|
+
'bands',
|
|
199
|
+
'endorsements',
|
|
188
200
|
]
|
|
189
201
|
},
|
|
190
202
|
// content with just the added 'instructors' Field
|
|
@@ -215,6 +227,34 @@ let contentTypeConfig = {
|
|
|
215
227
|
'exploring-beats': contentWithSortField,
|
|
216
228
|
}
|
|
217
229
|
|
|
230
|
+
function getNewReleasesTypes(brand) {
|
|
231
|
+
const baseNewTypes = ["student-review", "student-reviews", "student-focus", "coach-stream", "live", "question-and-answer", "boot-camps", "quick-tips", "workout", "challenge", "challenge-part", "podcasts", "pack", "song", "learning-path-level", "play-along", "course", "unit"];
|
|
232
|
+
switch(brand) {
|
|
233
|
+
case 'drumeo':
|
|
234
|
+
return [...baseNewTypes, "drum-fest-international-2022", "spotlight", "the-history-of-electronic-drums", "backstage-secrets", "student-collaborations", "live-streams", "solos", "gear-guides", "performances", "in-rhythm", "challenges", "on-the-road", "diy-drum-experiments", "rhythmic-adventures-of-captain-carson", "study-the-greats", "rhythms-from-another-planet", "tama-drums", "paiste-cymbals", "behind-the-scenes", "exploring-beats", "sonor-drums"];
|
|
235
|
+
case 'guitareo':
|
|
236
|
+
return [...baseNewTypes, "archives", "recording", "chords-and-scales"];
|
|
237
|
+
case 'pianote':
|
|
238
|
+
case 'singeo':
|
|
239
|
+
default:
|
|
240
|
+
return baseNewTypes
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function getUpcomingEventsTypes(brand) {
|
|
245
|
+
const baseLiveTypes = ["student-review", "student-reviews", "student-focus", "coach-stream", "live", "question-and-answer", "boot-camps", "quick-tips", "recording", "pack-bundle-lesson"];
|
|
246
|
+
switch(brand) {
|
|
247
|
+
case 'drumeo':
|
|
248
|
+
return [...baseLiveTypes, "drum-fest-international-2022", "spotlight", "the-history-of-electronic-drums", "backstage-secrets", "student-collaborations", "live-streams", "podcasts", "solos", "gear-guides", "performances", "in-rhythm", "challenges", "on-the-road", "diy-drum-experiments", "rhythmic-adventures-of-captain-carson", "study-the-greats", "rhythms-from-another-planet", "tama-drums", "paiste-cymbals", "behind-the-scenes", "exploring-beats", "sonor-drums"];
|
|
249
|
+
case 'guitareo':
|
|
250
|
+
return [...baseLiveTypes, "archives"];
|
|
251
|
+
case 'pianote':
|
|
252
|
+
case 'singeo':
|
|
253
|
+
default:
|
|
254
|
+
return baseLiveTypes;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
218
258
|
function artistOrInstructorName(key='artist_name') {
|
|
219
259
|
return `'${key}': coalesce(artist->name, instructor[0]->name)`;
|
|
220
260
|
}
|
|
@@ -264,4 +304,6 @@ module.exports = {
|
|
|
264
304
|
DEFAULT_FIELDS,
|
|
265
305
|
assignmentsField,
|
|
266
306
|
filtersToGroq,
|
|
307
|
+
getNewReleasesTypes,
|
|
308
|
+
getUpcomingEventsTypes,
|
|
267
309
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -28,6 +28,9 @@ import {
|
|
|
28
28
|
fetchLessonContent,
|
|
29
29
|
fetchCourseOverview,
|
|
30
30
|
fetchChallengeOverview,
|
|
31
|
+
fetchScheduledReleases,
|
|
32
|
+
fetchArtistLessons,
|
|
33
|
+
fetchGenreLessons,
|
|
31
34
|
} from './services/sanity.js';
|
|
32
35
|
|
|
33
36
|
import {
|
|
@@ -78,6 +81,9 @@ declare module 'musora-content-services' {
|
|
|
78
81
|
fetchAllCompletedStates,
|
|
79
82
|
fetchContentInProgress,
|
|
80
83
|
fetchContentPageUserData,
|
|
84
|
+
fetchScheduledReleases,
|
|
85
|
+
fetchArtistLessons,
|
|
86
|
+
fetchGenreLessons,
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
}
|
package/src/index.js
CHANGED
|
@@ -35,6 +35,9 @@ import {
|
|
|
35
35
|
fetchChallengeOverview,
|
|
36
36
|
fetchCoachLessons,
|
|
37
37
|
fetchByReference,
|
|
38
|
+
fetchScheduledReleases,
|
|
39
|
+
fetchArtistLessons,
|
|
40
|
+
fetchGenreLessons,
|
|
38
41
|
} from './services/sanity.js';
|
|
39
42
|
|
|
40
43
|
import {
|
|
@@ -89,4 +92,7 @@ export {
|
|
|
89
92
|
fetchContentPageUserData,
|
|
90
93
|
fetchCoachLessons,
|
|
91
94
|
fetchByReference,
|
|
95
|
+
fetchScheduledReleases,
|
|
96
|
+
fetchArtistLessons,
|
|
97
|
+
fetchGenreLessons,
|
|
92
98
|
}
|
|
@@ -261,4 +261,54 @@ function fetchAbsolute(url, params) {
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
return fetch(url, params);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export async function fetchUserContext() {
|
|
267
|
+
let url = `/content/user_data_all`;
|
|
268
|
+
const headers = {
|
|
269
|
+
'Content-Type': 'application/json',
|
|
270
|
+
'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
|
|
271
|
+
};
|
|
272
|
+
try {
|
|
273
|
+
const response = await fetch(url, {headers});
|
|
274
|
+
const result = await response.json();
|
|
275
|
+
if (result) {
|
|
276
|
+
console.log('fetchUserContext', result);
|
|
277
|
+
return result;
|
|
278
|
+
} else {
|
|
279
|
+
console.log('result not json');
|
|
280
|
+
}
|
|
281
|
+
} catch (error) {
|
|
282
|
+
console.error('Fetch error:', error);
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export async function fetchHandler(url, method = "get") {
|
|
288
|
+
const headers = {
|
|
289
|
+
'Content-Type': 'application/json',
|
|
290
|
+
'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
|
|
291
|
+
};
|
|
292
|
+
try {
|
|
293
|
+
const response = await fetch(url, {method, headers});
|
|
294
|
+
const result = await response.json();
|
|
295
|
+
if (result) {
|
|
296
|
+
return result;
|
|
297
|
+
} else {
|
|
298
|
+
console.log('result not json');
|
|
299
|
+
}
|
|
300
|
+
} catch (error) {
|
|
301
|
+
console.error('Fetch error:', error);
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export async function fetchLikeContent(contentId) {
|
|
307
|
+
let url = `/content/${contentId}/like`;
|
|
308
|
+
return await fetchHandler(url, "post");
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export async function fetchUnlikeContent(contentId) {
|
|
312
|
+
let url = `/content/${contentId}/unlike`;
|
|
313
|
+
return await fetchHandler(url, "post");
|
|
264
314
|
}
|