musora-content-services 1.2.3 → 1.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -1012,6 +1012,7 @@ const contentMetadata = {
1012
1012
  allowableFilters: ['difficulty', 'genre', 'essential', 'theory', 'lifestyle'],
1013
1013
  },
1014
1014
  'question-and-answer': {
1015
+ thumbnailUrl: 'https://d1923uyy6spedc.cloudfront.net/question-answer-singeo.png',
1015
1016
  icon: "fas fa-question-circle",
1016
1017
  description: "Each week we go live to answer your questions. Submit your questions in advance using the button below, in the Q&A thread in the forums, or live in the community chat.",
1017
1018
  allowableFilters: ['difficulty', 'genre', 'essential', 'theory'],
@@ -34,14 +34,26 @@ export const resourcesField = `[
34
34
  ... *[railcontent_id == ^.parent_content_data[0].id] [0].resource[]{resource_name, _key, "resource_url": coalesce('${CloudFrontURl}'+string::split(resource_aws.asset->fileURL, '${AWSUrl}')[1], resource_url )},
35
35
  ]`;
36
36
 
37
-
37
+ /*
38
+ * NOTE: TP-366 - Arrays can be either arrays of different objects or arrays of different primitives, not both
39
+ * updated query so assignment_sheet_music_image can be either an image or a URL
40
+ * see: https://www.sanity.io/docs/array-type#fNBIr84P
41
+ */
38
42
  export const assignmentsField = `"assignments":assignment[]{
39
43
  "id": railcontent_id,
40
44
  "soundslice_slug": assignment_soundslice,
41
45
  "title": assignment_title,
42
- "sheet_music_image_url": assignment_sheet_music_image,
46
+ "sheet_music_image_url":
47
+ coalesce(assignment_sheet_music_image_new[]{
48
+ _type == 'Image' => {
49
+ 'url': asset->url
50
+ },
51
+ _type == 'URL' => {
52
+ url
53
+ }
54
+ }.url, assignment_sheet_music_image),
43
55
  "timecode": assignment_timecode,
44
- "description": assignment_description
56
+ "description": coalesce(assignment_description,'')
45
57
  },`
46
58
 
47
59
  const contentWithInstructorsField = {
@@ -191,7 +203,7 @@ export let contentTypeConfig = {
191
203
  "id":railcontent_id,
192
204
  name,
193
205
  short_bio,
194
- "biography": short_bio[0].children[0].text,
206
+ "biography": short_bio[0].children[0].text,
195
207
  web_url_path,
196
208
  "coach_card_image": coach_card_image.asset->url,
197
209
  "coach_profile_image":thumbnail_url.asset->url
@@ -391,8 +403,8 @@ export let contentTypeConfig = {
391
403
  'backstage-secret': contentWithInstructorsField,
392
404
  'question-and-answer': contentWithInstructorsField,
393
405
  'student-collaboration': contentWithInstructorsField,
394
- 'live': {...contentWithInstructorsField, 'slug': 'live-streams'},
395
- 'solo': {...contentWithInstructorsField, 'slug': 'solos'},
406
+ 'live': { ...contentWithInstructorsField, 'slug': 'live-streams' },
407
+ 'solo': { ...contentWithInstructorsField, 'slug': 'solos' },
396
408
  'boot-camp': contentWithInstructorsField,
397
409
  'gear-guids': contentWithInstructorsField,
398
410
  'performance': contentWithInstructorsField,
package/src/index.d.ts CHANGED
@@ -89,20 +89,14 @@ import {
89
89
  fetchAll,
90
90
  fetchAllFilterOptions,
91
91
  fetchAllPacks,
92
- fetchAllSongs,
93
92
  fetchArtistLessons,
94
93
  fetchArtists,
95
- fetchAssignments,
96
94
  fetchByRailContentId,
97
95
  fetchByRailContentIds,
98
96
  fetchByReference,
99
- fetchCatalogMetadata,
100
- fetchChallengeOverview,
101
97
  fetchChatAndLiveEnvent,
102
- fetchChildren,
103
98
  fetchCoachLessons,
104
99
  fetchCommentModContentData,
105
- fetchCourseOverview,
106
100
  fetchFoundation,
107
101
  fetchGenreLessons,
108
102
  fetchHierarchy,
@@ -112,30 +106,22 @@ import {
112
106
  fetchMethod,
113
107
  fetchMethodChildren,
114
108
  fetchMethodChildrenIds,
115
- fetchMethodNextLesson,
116
109
  fetchMethodPreviousNextLesson,
117
- fetchMethods,
118
110
  fetchNewReleases,
119
111
  fetchNextPreviousLesson,
120
112
  fetchPackAll,
121
- fetchPackChildren,
122
113
  fetchPackData,
123
- fetchParentByRailContentId,
124
114
  fetchParentForDownload,
125
115
  fetchPlayAlongsCount,
126
116
  fetchRelatedLessons,
127
- fetchRelatedMethodLessons,
128
117
  fetchRelatedSongs,
129
118
  fetchSanity,
130
119
  fetchScheduledReleases,
131
120
  fetchShowsData,
132
121
  fetchSongArtistCount,
133
122
  fetchSongById,
134
- fetchSongCount,
135
- fetchSongFilterOptions,
136
123
  fetchTopLevelParentId,
137
124
  fetchUpcomingEvents,
138
- fetchWorkouts,
139
125
  getSortOrder,
140
126
  jumpToContinueContent
141
127
  } from './services/sanity.js';
@@ -162,22 +148,17 @@ declare module 'musora-content-services' {
162
148
  fetchAllCompletedStates,
163
149
  fetchAllFilterOptions,
164
150
  fetchAllPacks,
165
- fetchAllSongs,
166
151
  fetchArtistLessons,
167
152
  fetchArtists,
168
- fetchAssignments,
169
153
  fetchByRailContentId,
170
154
  fetchByRailContentIds,
171
155
  fetchByReference,
172
156
  fetchCarouselCardData,
173
- fetchCatalogMetadata,
174
157
  fetchChallengeIndexMetadata,
175
158
  fetchChallengeLessonData,
176
159
  fetchChallengeMetadata,
177
- fetchChallengeOverview,
178
160
  fetchChallengeUserActiveChallenges,
179
161
  fetchChatAndLiveEnvent,
180
- fetchChildren,
181
162
  fetchCoachLessons,
182
163
  fetchCommentModContentData,
183
164
  fetchCompletedChallenges,
@@ -186,7 +167,6 @@ declare module 'musora-content-services' {
186
167
  fetchContentInProgress,
187
168
  fetchContentPageUserData,
188
169
  fetchContentProgress,
189
- fetchCourseOverview,
190
170
  fetchFoundation,
191
171
  fetchGenreLessons,
192
172
  fetchHandler,
@@ -197,17 +177,13 @@ declare module 'musora-content-services' {
197
177
  fetchMethod,
198
178
  fetchMethodChildren,
199
179
  fetchMethodChildrenIds,
200
- fetchMethodNextLesson,
201
180
  fetchMethodPreviousNextLesson,
202
- fetchMethods,
203
181
  fetchNewReleases,
204
182
  fetchNextContentDataForParent,
205
183
  fetchNextPreviousLesson,
206
184
  fetchOwnedChallenges,
207
185
  fetchPackAll,
208
- fetchPackChildren,
209
186
  fetchPackData,
210
- fetchParentByRailContentId,
211
187
  fetchParentForDownload,
212
188
  fetchPinnedPlaylists,
213
189
  fetchPlayAlongsCount,
@@ -215,15 +191,12 @@ declare module 'musora-content-services' {
215
191
  fetchPlaylistItem,
216
192
  fetchPlaylistItems,
217
193
  fetchRelatedLessons,
218
- fetchRelatedMethodLessons,
219
194
  fetchRelatedSongs,
220
195
  fetchSanity,
221
196
  fetchScheduledReleases,
222
197
  fetchShowsData,
223
198
  fetchSongArtistCount,
224
199
  fetchSongById,
225
- fetchSongCount,
226
- fetchSongFilterOptions,
227
200
  fetchSongsInProgress,
228
201
  fetchTopLevelParentId,
229
202
  fetchUpcomingEvents,
@@ -234,7 +207,6 @@ declare module 'musora-content-services' {
234
207
  fetchUserPermissions,
235
208
  fetchUserPermissionsData,
236
209
  fetchUserPlaylists,
237
- fetchWorkouts,
238
210
  getAllCompleted,
239
211
  getAllStarted,
240
212
  getAllStartedOrCompleted,
package/src/index.js CHANGED
@@ -89,20 +89,14 @@ import {
89
89
  fetchAll,
90
90
  fetchAllFilterOptions,
91
91
  fetchAllPacks,
92
- fetchAllSongs,
93
92
  fetchArtistLessons,
94
93
  fetchArtists,
95
- fetchAssignments,
96
94
  fetchByRailContentId,
97
95
  fetchByRailContentIds,
98
96
  fetchByReference,
99
- fetchCatalogMetadata,
100
- fetchChallengeOverview,
101
97
  fetchChatAndLiveEnvent,
102
- fetchChildren,
103
98
  fetchCoachLessons,
104
99
  fetchCommentModContentData,
105
- fetchCourseOverview,
106
100
  fetchFoundation,
107
101
  fetchGenreLessons,
108
102
  fetchHierarchy,
@@ -112,30 +106,22 @@ import {
112
106
  fetchMethod,
113
107
  fetchMethodChildren,
114
108
  fetchMethodChildrenIds,
115
- fetchMethodNextLesson,
116
109
  fetchMethodPreviousNextLesson,
117
- fetchMethods,
118
110
  fetchNewReleases,
119
111
  fetchNextPreviousLesson,
120
112
  fetchPackAll,
121
- fetchPackChildren,
122
113
  fetchPackData,
123
- fetchParentByRailContentId,
124
114
  fetchParentForDownload,
125
115
  fetchPlayAlongsCount,
126
116
  fetchRelatedLessons,
127
- fetchRelatedMethodLessons,
128
117
  fetchRelatedSongs,
129
118
  fetchSanity,
130
119
  fetchScheduledReleases,
131
120
  fetchShowsData,
132
121
  fetchSongArtistCount,
133
122
  fetchSongById,
134
- fetchSongCount,
135
- fetchSongFilterOptions,
136
123
  fetchTopLevelParentId,
137
124
  fetchUpcomingEvents,
138
- fetchWorkouts,
139
125
  getSortOrder,
140
126
  jumpToContinueContent
141
127
  } from './services/sanity.js';
@@ -161,22 +147,17 @@ export {
161
147
  fetchAllCompletedStates,
162
148
  fetchAllFilterOptions,
163
149
  fetchAllPacks,
164
- fetchAllSongs,
165
150
  fetchArtistLessons,
166
151
  fetchArtists,
167
- fetchAssignments,
168
152
  fetchByRailContentId,
169
153
  fetchByRailContentIds,
170
154
  fetchByReference,
171
155
  fetchCarouselCardData,
172
- fetchCatalogMetadata,
173
156
  fetchChallengeIndexMetadata,
174
157
  fetchChallengeLessonData,
175
158
  fetchChallengeMetadata,
176
- fetchChallengeOverview,
177
159
  fetchChallengeUserActiveChallenges,
178
160
  fetchChatAndLiveEnvent,
179
- fetchChildren,
180
161
  fetchCoachLessons,
181
162
  fetchCommentModContentData,
182
163
  fetchCompletedChallenges,
@@ -185,7 +166,6 @@ export {
185
166
  fetchContentInProgress,
186
167
  fetchContentPageUserData,
187
168
  fetchContentProgress,
188
- fetchCourseOverview,
189
169
  fetchFoundation,
190
170
  fetchGenreLessons,
191
171
  fetchHandler,
@@ -196,17 +176,13 @@ export {
196
176
  fetchMethod,
197
177
  fetchMethodChildren,
198
178
  fetchMethodChildrenIds,
199
- fetchMethodNextLesson,
200
179
  fetchMethodPreviousNextLesson,
201
- fetchMethods,
202
180
  fetchNewReleases,
203
181
  fetchNextContentDataForParent,
204
182
  fetchNextPreviousLesson,
205
183
  fetchOwnedChallenges,
206
184
  fetchPackAll,
207
- fetchPackChildren,
208
185
  fetchPackData,
209
- fetchParentByRailContentId,
210
186
  fetchParentForDownload,
211
187
  fetchPinnedPlaylists,
212
188
  fetchPlayAlongsCount,
@@ -214,15 +190,12 @@ export {
214
190
  fetchPlaylistItem,
215
191
  fetchPlaylistItems,
216
192
  fetchRelatedLessons,
217
- fetchRelatedMethodLessons,
218
193
  fetchRelatedSongs,
219
194
  fetchSanity,
220
195
  fetchScheduledReleases,
221
196
  fetchShowsData,
222
197
  fetchSongArtistCount,
223
198
  fetchSongById,
224
- fetchSongCount,
225
- fetchSongFilterOptions,
226
199
  fetchSongsInProgress,
227
200
  fetchTopLevelParentId,
228
201
  fetchUpcomingEvents,
@@ -233,7 +206,6 @@ export {
233
206
  fetchUserPermissions,
234
207
  fetchUserPermissionsData,
235
208
  fetchUserPlaylists,
236
- fetchWorkouts,
237
209
  getAllCompleted,
238
210
  getAllStarted,
239
211
  getAllStartedOrCompleted,
@@ -5,7 +5,7 @@ import {
5
5
  postRecordWatchSession
6
6
  } from "./railcontent.js";
7
7
  import {DataContext, ContentProgressVersionKey} from "./dataContext.js";
8
- import {fetchAssignments, fetchHierarchy} from "./sanity.js";
8
+ import {fetchHierarchy} from "./sanity.js";
9
9
 
10
10
  const STATE_STARTED = 'started';
11
11
  const STATE_COMPLETED = 'completed';
@@ -183,107 +183,6 @@ export async function fetchRelatedSongs(brand, songId) {
183
183
  return fetchSanity(query, false);
184
184
  }
185
185
 
186
- /**
187
- * Fetch all songs for a specific brand with pagination and search options.
188
- * @param {string} brand - The brand for which to fetch songs.
189
- * @param {Object} params - Parameters for pagination, filtering, and sorting.
190
- * @param {number} [params.page=1] - The page number for pagination.
191
- * @param {number} [params.limit=10] - The number of songs per page.
192
- * @param {string} [params.searchTerm=""] - The search term to filter songs by title or artist.
193
- * @param {string} [params.sort="-published_on"] - The field to sort the songs by.
194
- * @param {Array<string>} [params.includedFields=[]] - The fields to include in the query.
195
- * @param {string} [params.groupBy=""] - The field to group the results by.
196
- * @returns {Promise<Object|null>} - The fetched song data or null if not found.
197
- *
198
- * @example
199
- * fetchAllSongs('drumeo', {
200
- * page: 2,
201
- * limit: 20,
202
- * searchTerm: 'rock',
203
- * sort: 'published_on',
204
- * includedFields: ['difficulty', 'style'],
205
- * groupBy: 'artist'
206
- * })
207
- * .then(result => console.log(result))
208
- * .catch(error => console.error(error));
209
- */
210
- export async function fetchAllSongs(brand, {
211
- page = 1,
212
- limit = 10,
213
- searchTerm = "",
214
- sort = "-published_on",
215
- includedFields = [],
216
- groupBy = ""
217
- }) {
218
- return fetchAll(brand, 'song', {page, limit, searchTerm, sort, includedFields, groupBy});
219
- }
220
-
221
- /**
222
- * Fetch filter options for a specific brand.
223
- *
224
- * @param {string} brand - The brand for which to fetch filter options.
225
- * @returns {Promise<Object|null>} - A promise that resolves to an object containing filter options or null if not found.
226
- *
227
- * @example
228
- * fetchSongFilterOptions('drumeo')
229
- * .then(options => console.log(options))
230
- * .catch(error => console.error(error));
231
- */
232
- export async function fetchSongFilterOptions(brand) {
233
- const query = `
234
- {
235
- "difficulty": [
236
- {"type": "Introductory", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Introductory"]._id)},
237
- {"type": "Beginner", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Beginner"]._id)},
238
- {"type": "Intermediate", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Intermediate"]._id)},
239
- {"type": "Advanced", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Advanced"]._id)},
240
- {"type": "Expert", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Expert"]._id)}
241
- ],
242
- "genre": *[_type == 'genre' && 'song' in filter_types] {
243
- "type": name,
244
- "count": count(*[_type == 'song' && brand == '${brand}' && references(^._id)]._id)
245
- },
246
- "instrumentless": [
247
- {"type": "Full Song Only", "count": count(*[_type == 'song' && brand == '${brand}' && instrumentless == false]._id)},
248
- {"type": "Instrument Removed", "count": count(*[_type == 'song' && brand == '${brand}' && instrumentless == true]._id)}
249
- ]
250
- }`;
251
-
252
- return fetchSanity(query, true);
253
- }
254
-
255
- /**
256
- * Fetch the total count of songs for a specific brand.
257
- * @param {string} brand - The brand for which to fetch the song count.
258
- * @returns {Promise<number|null>} - The total count of songs or null if an error occurs.
259
- */
260
- export async function fetchSongCount(brand) {
261
- const query = `count(*[_type == 'song' && brand == "${brand}"])`;
262
- return fetchSanity(query, true, {processNeedAccess: false});
263
- }
264
-
265
- /**
266
- * Fetch the latest workouts for a specific brand, including completion status and progress.
267
- * This function retrieves up to five of the latest workout content for a given brand, sorted in descending order by their publication date.
268
- * It also includes completion status and progress percentage for each workout by fetching additional data about user progress.
269
- *
270
- * @param {string} brand - The brand for which to fetch workouts (e.g., 'drumeo', 'pianote').
271
- * @returns {Promise<Array<Object>|null>} - A promise that resolves to an array of workout data objects with additional properties for completion status and progress percentage,
272
- * or null if no workouts are found.
273
- *
274
- * @example
275
- * fetchWorkouts('drumeo')
276
- * .then(workouts => console.log(workouts))
277
- * .catch(error => console.error(error));
278
- */
279
- export async function fetchWorkouts(brand) {
280
- const fields = getFieldsForContentType('workout');
281
- const query = `*[_type == 'workout' && brand == '${brand}'] [0...5] {
282
- ${fields.toString()}
283
- } | order(published_on desc)[0...5]`
284
- return fetchSanity(query, true);
285
- }
286
-
287
186
  /**
288
187
  * Fetch the latest new releases for a specific brand.
289
188
  * @param {string} brand - The brand for which to fetch new releases.
@@ -546,7 +445,6 @@ export async function fetchAll(brand, type, {
546
445
  if (customResults) {
547
446
  return customResults;
548
447
  }
549
-
550
448
  let config = contentTypeConfig[type] ?? {};
551
449
  let additionalFields = config?.fields ?? [];
552
450
  let isGroupByOneToOne = (groupBy ? config?.relationships?.[groupBy]?.isOneToOne : false) ?? false;
@@ -917,60 +815,6 @@ export async function fetchAllFilterOptions(
917
815
  return includeTabs ? {...results, tabs, catalogName} : results;
918
816
  }
919
817
 
920
-
921
- /**
922
- * Fetch children content by Railcontent ID.
923
- * @param {string} railcontentId - The Railcontent ID of the parent content.
924
- * @param {string} [contentType] - The content type the IDs to add needed fields to the response.
925
- * @returns {Promise<Array<Object>|null>} - The fetched children content data or [] if not found.
926
- */
927
- export async function fetchChildren(railcontentId, contentType) {
928
- const query = `*[railcontent_id == ${railcontentId}]{
929
- title,
930
-
931
- 'children': child[]->{
932
- ${getFieldsForContentType(contentType)}
933
- },
934
- }[0..1]`;
935
- let parent = await fetchSanity(query, false);
936
- return parent['children'] ?? [];
937
- }
938
-
939
- /**
940
- *
941
- * @param railcontentId - railcontent id of the child
942
- * @returns {Promise<Array<string>|null>} - The fetched parent content data or [] if not found
943
- */
944
- export async function fetchParentByRailContentId(railcontentId) {
945
- const query = `*[railcontent_id == ${railcontentId}]{
946
- 'parents': array::unique([
947
- ...(*[references(^._id)]{
948
- ${getFieldsForContentType()}
949
- })
950
- ])
951
- }[0...1]`;
952
- let child = await fetchSanity(query, false);
953
- return child['parents'][0] ?? [];
954
- }
955
-
956
- /**
957
- * Fetch the Methods (learning-paths) for a specific brand.
958
- * @param {string} brand - The brand for which to fetch methods.
959
- * @returns {Promise<Object|null>} - The fetched methods data or null if not found.
960
- */
961
- export async function fetchMethods(brand) {
962
- const query = `*[_type == 'learning-path' && brand == '${brand}'] {
963
- parent_content_data,
964
- "breadcrumbs_data": parent_content_data[] {
965
- "id": id,
966
- "title": *[railcontent_id == ^.id][0].title,
967
- "url": *[railcontent_id == ^.id][0].web_url_path
968
- } | order(length(url)),
969
- ${getFieldsForContentType()}
970
- } | order(published_on asc)`
971
- return fetchSanity(query, true);
972
- }
973
-
974
818
  /**
975
819
  * Fetch the Foundations 2019.
976
820
  * @param {string} slug - The slug of the method.
@@ -1069,19 +913,6 @@ export async function fetchMethodChildren(railcontentId) {
1069
913
  return fetchSanity(query, true);
1070
914
  }
1071
915
 
1072
- /**
1073
- * Fetch the next lesson for a specific method by Railcontent ID.
1074
- * @param {string} railcontentId - The Railcontent ID of the current lesson.
1075
- * @param {string} methodId - The RailcontentID of the method
1076
- * @returns {Promise<Object|null>} - The fetched next lesson data or null if not found.
1077
- */
1078
- export async function fetchMethodNextLesson(railcontentId, methodId) {
1079
- const sortedChildren = await fetchMethodChildrenIds(methodId);
1080
- const index = sortedChildren.indexOf(railcontentId);
1081
- const childIndex = sortedChildren[index + 1];
1082
- return childIndex ? await fetchByRailContentId(childIndex) : null;
1083
- }
1084
-
1085
916
  /**
1086
917
  * Fetch the next lesson for a specific method by Railcontent ID.
1087
918
  * @param {string} railcontentId - The Railcontent ID of the current lesson.
@@ -1302,30 +1133,6 @@ export async function fetchRelatedLessons(railContentId, brand) {
1302
1133
  return fetchSanity(query, false);
1303
1134
  }
1304
1135
 
1305
- /**
1306
- * Fetch related method lessons for a specific lesson by RailContent ID and type.
1307
- * @param {string} railContentId - The RailContent ID of the current lesson.
1308
- * @param {string} brand - The current brand.
1309
- * @returns {Promise<Array<Object>|null>} - The fetched related lessons
1310
- */
1311
- export async function fetchRelatedMethodLessons(railContentId, brand) {
1312
- const query = `*[railcontent_id == ${railContentId} && brand == "${brand}"]{
1313
- "id":_id,
1314
- "related_lessons": *[references(^._id)][0].child[]->{
1315
- "id": railcontent_id,
1316
- "type": _type,
1317
- title,
1318
- "description": description[0].children[0].text, // Extraer texto plano
1319
- "thumbnail_url": thumbnail.asset->url,
1320
- "url": web_url_path,
1321
- difficulty,
1322
- difficulty_string,
1323
- }
1324
- }
1325
- }`
1326
- return fetchSanity(query, false);
1327
- }
1328
-
1329
1136
  /**
1330
1137
  * Fetch all packs.
1331
1138
  * @param {string} brand - The brand for which to fetch packs.
@@ -1415,20 +1222,6 @@ export async function fetchLiveEvent(brand) {
1415
1222
  return await fetchSanity(query, false, {processNeedAccess: false});
1416
1223
  }
1417
1224
 
1418
- /**
1419
- * Fetch all children of a specific pack by Railcontent ID.
1420
- * @param {string} railcontentId - The Railcontent ID of the pack.
1421
- * @returns {Promise<Array<Object>|null>} - The fetched pack children data or null if not found.
1422
- *
1423
- * @example
1424
- * fetchPackChildren('pack123')
1425
- * .then(children => console.log(children))
1426
- * .catch(error => console.error(error));
1427
- */
1428
- export async function fetchPackChildren(railcontentId) {
1429
- return fetchChildren(railcontentId, 'pack-children');
1430
- }
1431
-
1432
1225
  /**
1433
1226
  * Fetch the data needed for the Pack Overview screen.
1434
1227
  * @param {number} id - The Railcontent ID of the pack
@@ -1446,24 +1239,6 @@ export async function fetchPackData(id) {
1446
1239
  return fetchSanity(query, false);
1447
1240
  }
1448
1241
 
1449
- /**
1450
- * Fetch the data needed for the Challenge Overview screen.
1451
- * @param {string} id - The Railcontent ID of the course
1452
- * @returns {Promise<Object|null>} - The challenge information and lessons or null if not found.
1453
- *
1454
- * @example
1455
- * fetchChallengeOverview('challenge123')
1456
- * .then(challenge => console.log(challenge))
1457
- * .catch(error => console.error(error));
1458
- */
1459
- export async function fetchChallengeOverview(id) {
1460
- // WIP
1461
- const query = `*[railcontent_id == ${id}]{
1462
- ${getFieldsForContentType("challenge")}
1463
- } [0...1]`;
1464
- return fetchSanity(query, false);
1465
- }
1466
-
1467
1242
  /**
1468
1243
  * Fetch the data needed for the coach screen.
1469
1244
  * @param {string} brand - The brand for which to fetch coach lessons
@@ -1511,20 +1286,6 @@ export async function fetchCoachLessons(brand, id, {
1511
1286
  return fetchSanity(query, true);
1512
1287
  }
1513
1288
 
1514
- /**
1515
- * Fetch the data needed for the Course Overview screen.
1516
- * @param {string} id - The Railcontent ID of the course
1517
- * @returns {Promise<Object|null>} - The course information and lessons or null if not found.
1518
- *
1519
- * @example
1520
- * fetchCourseOverview('course123')
1521
- * .then(course => console.log(course))
1522
- * .catch(error => console.error(error));
1523
- */
1524
- export async function fetchCourseOverview(id) {
1525
- return fetchByRailContentId(id, 'course');
1526
- }
1527
-
1528
1289
  /**
1529
1290
  * Fetch the data needed for the Course Overview screen.
1530
1291
  * @param {string} id - The Railcontent ID of the course
@@ -1780,26 +1541,6 @@ function populateHierarchyLookups(currentLevel, data, parentId) {
1780
1541
 
1781
1542
  }
1782
1543
 
1783
- /**
1784
- * Fetch assignments for content
1785
- *
1786
- * @param {integer} contentId - List of ids get data for
1787
- * @returns {Promise<array|null>} - A promise that resolves to an array containing the data
1788
- */
1789
- export async function fetchAssignments(contentId) {
1790
- const fields = `"id": railcontent_id,"assignments":assignment[]{"id": railcontent_id}`;
1791
- const query = await buildQuery(`railcontent_id == ${contentId}`,
1792
- {bypassPermissions: true},
1793
- fields,
1794
- {end: 100});
1795
- let data = await fetchSanity(query, false);
1796
- let mapped = [];
1797
- data.assignments.forEach(function (content) {
1798
- mapped.push(content.id);
1799
- });
1800
- return mapped;
1801
- }
1802
-
1803
1544
  /**
1804
1545
  * Fetch data for comment mod page
1805
1546
  *
@@ -1949,32 +1690,6 @@ function doesUserNeedAccessToContent(result, userPermissions, isAdmin) {
1949
1690
  return true;
1950
1691
  }
1951
1692
 
1952
- /**
1953
- * Fetch CatalogueMetadata from Sanity. This information may be duplicated in the contentTypeConfig.js.
1954
- * It's an ongoing discussion (Aug 2024), but it's been included here if necessary
1955
- *
1956
- * @param {string} contentType - name of the contentype to pull
1957
- * @returns {Promise<Object|null>} - A promise that resolves to the fetched data or null if an error occurs or no results are found.
1958
- *
1959
- * @example
1960
- *
1961
- * fetchCatalogMetadata('song')
1962
- * .then(data => console.log(data))
1963
- * .catch(error => console.error(error));
1964
- */
1965
- export async function fetchCatalogMetadata(contentType) {
1966
- const query = `*[_type == 'CatalogMetadata']{
1967
- catalog_type,
1968
- brand,
1969
- groq_results,
1970
- groq_search_fields,
1971
- meta_data_groq,
1972
- modal_text,
1973
- sort_by,
1974
- }`
1975
- return fetchSanity(query, false, {processNeedAccess: false});
1976
- }
1977
-
1978
1693
  /**
1979
1694
  * Fetch shows data for a brand.
1980
1695
  *
File without changes