musora-content-services 1.0.136 → 1.0.138

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/src/index.d.ts CHANGED
@@ -59,6 +59,7 @@ import {
59
59
  fetchNextPreviousLesson,
60
60
  fetchPackAll,
61
61
  fetchPackChildren,
62
+ fetchPackData,
62
63
  fetchParentByRailContentId,
63
64
  fetchRelatedLessons,
64
65
  fetchRelatedMethodLessons,
@@ -113,6 +114,7 @@ declare module 'musora-content-services' {
113
114
  fetchNextPreviousLesson,
114
115
  fetchPackAll,
115
116
  fetchPackChildren,
117
+ fetchPackData,
116
118
  fetchParentByRailContentId,
117
119
  fetchRelatedLessons,
118
120
  fetchRelatedMethodLessons,
package/src/index.js CHANGED
@@ -59,6 +59,7 @@ import {
59
59
  fetchNextPreviousLesson,
60
60
  fetchPackAll,
61
61
  fetchPackChildren,
62
+ fetchPackData,
62
63
  fetchParentByRailContentId,
63
64
  fetchRelatedLessons,
64
65
  fetchRelatedMethodLessons,
@@ -112,6 +113,7 @@ export {
112
113
  fetchNextPreviousLesson,
113
114
  fetchPackAll,
114
115
  fetchPackChildren,
116
+ fetchPackData,
115
117
  fetchParentByRailContentId,
116
118
  fetchRelatedLessons,
117
119
  fetchRelatedMethodLessons,
@@ -299,6 +299,7 @@ export async function fetchNewReleases(brand, { page = 1, limit = 20, sort="-pub
299
299
  fields,
300
300
  {
301
301
  sortOrder: sortOrder,
302
+ start,
302
303
  end: end,
303
304
  });
304
305
  return fetchSanity(query, true);
@@ -965,14 +966,13 @@ export async function fetchLessonContent(railContentId) {
965
966
  export async function fetchRelatedLessons(railContentId, brand) {
966
967
  const query = `*[railcontent_id == ${railContentId} && brand == "${brand}" && references(*[_type=='permission']._id)]{
967
968
  _type, parent_type, railcontent_id,
968
- "related_lessons" : array::unique([
969
- ...(*[references(^._id)][0].child[]->{_id, "id":railcontent_id, published_on, title, "thumbnail_url":thumbnail.asset->url, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,_type}),
970
- ...(*[_type=="song" && _type==^._type && brand == "${brand}" && references(^.artist->_id) && railcontent_id !=${railContentId}]{_id, "id":railcontent_id, published_on, title, "thumbnail_url":thumbnail.asset->url, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,_type}|order(published_on desc, title asc)[0...10]),
971
- ...(*[_type=="song" && _type==^._type && brand == "${brand}" && references(^.genre[]->_id) && railcontent_id !=${railContentId}]{_id, "id":railcontent_id, published_on, title, "thumbnail_url":thumbnail.asset->url, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,_type}|order(published_on desc, title asc)[0...10]),
972
- ...(*[_type==^._type && _type in ${JSON.stringify(typeWithSortOrder)} && brand == "${brand}" && railcontent_id !=${railContentId}]{_id, "id":railcontent_id, published_on, title, "thumbnail_url":thumbnail.asset->url, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,_type, sort}|order(sort asc, title asc)[0...10]),
973
- ...(*[_type==^._type && !(_type in ${JSON.stringify(typeWithSortOrder)}) && !(defined(parent_type)) && brand == "${brand}" && railcontent_id !=${railContentId}]{_id, "id":railcontent_id, published_on, title, "thumbnail_url":thumbnail.asset->url, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,_type}|order(published_on desc, title asc)[0...10]),
974
- ])[0...10]}`;
975
-
969
+ "related_lessons" : array::unique([
970
+ ...(*[references(^._id)][0].child[]->{_id, "id":railcontent_id, published_on, "instructor": instructor[0]->name, title, "thumbnail_url":thumbnail.asset->url, length_in_seconds, web_url_path, "type": _type, difficulty, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,_type}),
971
+ ...(*[_type=="song" && _type==^._type && brand == "${brand}" && references(^.artist->_id) && railcontent_id !=${railContentId}]{_id, "id":railcontent_id, published_on, "instructor": instructor[0]->name, title, "thumbnail_url":thumbnail.asset->url, length_in_seconds, web_url_path, "type": _type, difficulty, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,_type}|order(published_on desc, title asc)[0...10]),
972
+ ...(*[_type=="song" && _type==^._type && brand == "${brand}" && references(^.genre[]->_id) && railcontent_id !=${railContentId}]{_id, "id":railcontent_id, published_on, "instructor": instructor[0]->name, title, "thumbnail_url":thumbnail.asset->url, length_in_seconds, web_url_path, "type": _type, difficulty, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,_type}|order(published_on desc, title asc)[0...10]),
973
+ ...(*[_type==^._type && _type in ${JSON.stringify(typeWithSortOrder)} && brand == "${brand}" && railcontent_id !=${railContentId}]{_id, "id":railcontent_id, published_on, "instructor": instructor[0]->name, title, "thumbnail_url":thumbnail.asset->url, length_in_seconds, web_url_path, "type": _type, difficulty, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,_type, sort}|order(sort asc, title asc)[0...10]),
974
+ ...(*[_type==^._type && !(_type in ${JSON.stringify(typeWithSortOrder)}) && !(defined(parent_type)) && brand == "${brand}" && railcontent_id !=${railContentId}]{_id, "id":railcontent_id, published_on, "instructor": instructor[0]->name, title, "thumbnail_url":thumbnail.asset->url, length_in_seconds, web_url_path, "type": _type, difficulty, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,_type}|order(published_on desc, title asc)[0...10]),
975
+ ])[0...10]}`;
976
976
  return fetchSanity(query, false);
977
977
  }
978
978
 
@@ -1005,13 +1005,18 @@ export async function fetchRelatedMethodLessons(railContentId, brand) {
1005
1005
  * @param {string} brand - The brand for which to fetch packs.
1006
1006
  * @param {string} [searchTerm=""] - The search term to filter packs.
1007
1007
  * @param {string} [sort="-published_on"] - The field to sort the packs by.
1008
+ * @param {number} [params.page=1] - The page number for pagination.
1009
+ * @param {number} [params.limit=10] - The number of items per page.
1008
1010
  * @returns {Promise<Array<Object>|null>} - The fetched pack content data or null if not found.
1009
1011
  */
1010
- export async function fetchAllPacks(brand, sort = "-published_on", searchTerm = "") {
1012
+ export async function fetchAllPacks(brand, sort = "-published_on", searchTerm = "", page = 1, limit = 10) {
1011
1013
  const sortOrder = getSortOrder(sort);
1012
1014
  const filter = `_type == 'pack' && brand == '${brand}' && title match "${searchTerm}*"`
1013
1015
  const filterParams = {};
1014
1016
  const fields = getFieldsForContentType('pack');
1017
+ const start = (page - 1) * limit;
1018
+ const end = start + limit;
1019
+
1015
1020
  const query = buildQuery(
1016
1021
  filter,
1017
1022
  filterParams,
@@ -1019,6 +1024,8 @@ export async function fetchAllPacks(brand, sort = "-published_on", searchTerm =
1019
1024
  {
1020
1025
  logo_image_url: 'logo_image_url.asset->url',
1021
1026
  sortOrder: sortOrder,
1027
+ start,
1028
+ end
1022
1029
  }
1023
1030
  );
1024
1031
  return fetchSanity(query, true);
@@ -1093,6 +1100,23 @@ export async function fetchPackChildren(railcontentId) {
1093
1100
  return fetchChildren(railcontentId, 'pack-children');
1094
1101
  }
1095
1102
 
1103
+ /**
1104
+ * Fetch the data needed for the Pack Overview screen.
1105
+ * @param {number} id - The Railcontent ID of the pack
1106
+ * @returns {Promise<Object|null>} - The pack information and lessons or null if not found.
1107
+ *
1108
+ * @example
1109
+ * fetchPackData(404048)
1110
+ * .then(challenge => console.log(challenge))
1111
+ * .catch(error => console.error(error));
1112
+ */
1113
+ export async function fetchPackData(id) {
1114
+ const query = `*[railcontent_id == ${id}]{
1115
+ ${getFieldsForContentType("pack")}
1116
+ } [0...1]`;
1117
+ return fetchSanity(query, false);
1118
+ }
1119
+
1096
1120
  /**
1097
1121
  * Fetch the data needed for the Challenge Overview screen.
1098
1122
  * @param {string} id - The Railcontent ID of the course