musora-content-services 1.0.137 → 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);
@@ -1004,13 +1005,18 @@ export async function fetchRelatedMethodLessons(railContentId, brand) {
1004
1005
  * @param {string} brand - The brand for which to fetch packs.
1005
1006
  * @param {string} [searchTerm=""] - The search term to filter packs.
1006
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.
1007
1010
  * @returns {Promise<Array<Object>|null>} - The fetched pack content data or null if not found.
1008
1011
  */
1009
- export async function fetchAllPacks(brand, sort = "-published_on", searchTerm = "") {
1012
+ export async function fetchAllPacks(brand, sort = "-published_on", searchTerm = "", page = 1, limit = 10) {
1010
1013
  const sortOrder = getSortOrder(sort);
1011
1014
  const filter = `_type == 'pack' && brand == '${brand}' && title match "${searchTerm}*"`
1012
1015
  const filterParams = {};
1013
1016
  const fields = getFieldsForContentType('pack');
1017
+ const start = (page - 1) * limit;
1018
+ const end = start + limit;
1019
+
1014
1020
  const query = buildQuery(
1015
1021
  filter,
1016
1022
  filterParams,
@@ -1018,6 +1024,8 @@ export async function fetchAllPacks(brand, sort = "-published_on", searchTerm =
1018
1024
  {
1019
1025
  logo_image_url: 'logo_image_url.asset->url',
1020
1026
  sortOrder: sortOrder,
1027
+ start,
1028
+ end
1021
1029
  }
1022
1030
  );
1023
1031
  return fetchSanity(query, true);
@@ -1092,6 +1100,23 @@ export async function fetchPackChildren(railcontentId) {
1092
1100
  return fetchChildren(railcontentId, 'pack-children');
1093
1101
  }
1094
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
+
1095
1120
  /**
1096
1121
  * Fetch the data needed for the Challenge Overview screen.
1097
1122
  * @param {string} id - The Railcontent ID of the course