musora-content-services 2.116.0 → 2.117.1
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 +9 -0
- package/package.json +1 -1
- package/src/constants/membership-permissions.ts +7 -0
- package/src/contentTypeConfig.js +18 -30
- package/src/index.d.ts +2 -4
- package/src/index.js +2 -4
- package/src/services/content.js +31 -20
- package/src/services/contentAggregator.js +1 -1
- package/src/services/contentProgress.js +3 -3
- package/src/services/progress-row/rows/content-card.js +1 -1
- package/src/services/sanity.js +20 -51
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [2.117.1](https://github.com/railroadmedia/musora-content-services/compare/v2.117.0...v2.117.1) (2026-01-13)
|
|
6
|
+
|
|
7
|
+
## [2.117.0](https://github.com/railroadmedia/musora-content-services/compare/v2.116.0...v2.117.0) (2026-01-13)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **BEH-1442:** old method migration + course collection updates ([#673](https://github.com/railroadmedia/musora-content-services/issues/673)) ([24dd6bf](https://github.com/railroadmedia/musora-content-services/commit/24dd6bf6a1604ef3ee639979cf2ffab5abc05a24))
|
|
13
|
+
|
|
5
14
|
## [2.116.0](https://github.com/railroadmedia/musora-content-services/compare/v2.115.3...v2.116.0) (2026-01-12)
|
|
6
15
|
|
|
7
16
|
|
package/package.json
CHANGED
package/src/contentTypeConfig.js
CHANGED
|
@@ -62,6 +62,7 @@ export const DEFAULT_FIELDS = [
|
|
|
62
62
|
"'permission_id': permission_v2",
|
|
63
63
|
'child_count',
|
|
64
64
|
'"parent_id": parent_content_data[0].id',
|
|
65
|
+
'"grandparent_id": parent_content_data[1].id',
|
|
65
66
|
]
|
|
66
67
|
|
|
67
68
|
// these are identical... why
|
|
@@ -85,6 +86,7 @@ export const DEFAULT_CHILD_FIELDS = [
|
|
|
85
86
|
"'permission_id': permission_v2",
|
|
86
87
|
'child_count',
|
|
87
88
|
'"parent_id": parent_content_data[0].id',
|
|
89
|
+
'"grandparent_id": parent_content_data[1].id',
|
|
88
90
|
]
|
|
89
91
|
|
|
90
92
|
export const playAlongMp3sField = `{
|
|
@@ -157,13 +159,12 @@ export const showsTypes = {
|
|
|
157
159
|
}
|
|
158
160
|
|
|
159
161
|
export const coachLessonsTypes = [
|
|
162
|
+
'course-collection',
|
|
160
163
|
'course',
|
|
161
164
|
'course-lesson',
|
|
162
165
|
'coach-stream',
|
|
163
166
|
'student-focus',
|
|
164
167
|
'quick-tips',
|
|
165
|
-
'pack',
|
|
166
|
-
'semester-pack',
|
|
167
168
|
'question-and-answer',
|
|
168
169
|
'song-tutorial',
|
|
169
170
|
'song-tutorial-lesson',
|
|
@@ -201,7 +202,11 @@ export const individualLessonsTypes = [
|
|
|
201
202
|
...studentArchivesLessonTypes,
|
|
202
203
|
]
|
|
203
204
|
|
|
204
|
-
export const coursesLessonTypes = [
|
|
205
|
+
export const coursesLessonTypes = [
|
|
206
|
+
'course',
|
|
207
|
+
'course-collection',
|
|
208
|
+
'guided-course',
|
|
209
|
+
]
|
|
205
210
|
|
|
206
211
|
export const skillLessonTypes = ['skill-pack']
|
|
207
212
|
|
|
@@ -250,8 +255,7 @@ export const lessonTypesMapping = {
|
|
|
250
255
|
export const getNextLessonLessonParentTypes = [
|
|
251
256
|
'course',
|
|
252
257
|
'guided-course',
|
|
253
|
-
'
|
|
254
|
-
'pack-bundle',
|
|
258
|
+
'course-collection',
|
|
255
259
|
'song-tutorial',
|
|
256
260
|
'learning-path-v2',
|
|
257
261
|
'skill-pack',
|
|
@@ -266,7 +270,7 @@ export const progressTypesMapping = {
|
|
|
266
270
|
...studentArchivesLessonTypes,
|
|
267
271
|
'documentary-lesson',
|
|
268
272
|
'live',
|
|
269
|
-
'
|
|
273
|
+
'course-lesson'
|
|
270
274
|
],
|
|
271
275
|
course: ['course'],
|
|
272
276
|
show: showsLessonTypes,
|
|
@@ -274,7 +278,7 @@ export const progressTypesMapping = {
|
|
|
274
278
|
songs: transcriptionsLessonTypes,
|
|
275
279
|
'play along': playAlongLessonTypes,
|
|
276
280
|
'guided course': ['guided-course'],
|
|
277
|
-
|
|
281
|
+
'course collection': ['course-collection'],
|
|
278
282
|
'learning path': ['learning-path-v2'],
|
|
279
283
|
'skill pack': skillLessonTypes,
|
|
280
284
|
'jam track': jamTrackLessonTypes,
|
|
@@ -311,12 +315,12 @@ export const recentTypes = {
|
|
|
311
315
|
lessons: [
|
|
312
316
|
...individualLessonsTypes,
|
|
313
317
|
'course-lesson',
|
|
314
|
-
'pack-bundle-lesson',
|
|
315
318
|
'guided-course-lesson',
|
|
316
319
|
'quick-tips',
|
|
317
320
|
],
|
|
318
321
|
songs: [...SONG_TYPES],
|
|
319
322
|
home: [
|
|
323
|
+
...skillLessonTypes,
|
|
320
324
|
...individualLessonsTypes,
|
|
321
325
|
...tutorialsLessonTypes,
|
|
322
326
|
...skillLessonTypes,
|
|
@@ -326,7 +330,7 @@ export const recentTypes = {
|
|
|
326
330
|
'learning-path-v2',
|
|
327
331
|
'live',
|
|
328
332
|
'course',
|
|
329
|
-
'
|
|
333
|
+
'course-collection',
|
|
330
334
|
],
|
|
331
335
|
}
|
|
332
336
|
|
|
@@ -339,7 +343,6 @@ export const ownedContentTypes = {
|
|
|
339
343
|
...coursesLessonTypes,
|
|
340
344
|
...skillLessonTypes,
|
|
341
345
|
...entertainmentLessonTypes,
|
|
342
|
-
'pack',
|
|
343
346
|
],
|
|
344
347
|
songs: [
|
|
345
348
|
...tutorialsLessonTypes,
|
|
@@ -396,9 +399,6 @@ export let contentTypeConfig = {
|
|
|
396
399
|
'guided-course': {
|
|
397
400
|
includeChildFields: true,
|
|
398
401
|
},
|
|
399
|
-
'course-collection': {
|
|
400
|
-
individualLessonsTypes: true,
|
|
401
|
-
},
|
|
402
402
|
course: {
|
|
403
403
|
fields: [
|
|
404
404
|
'"lesson_count": child_count',
|
|
@@ -415,6 +415,9 @@ export let contentTypeConfig = {
|
|
|
415
415
|
],
|
|
416
416
|
slug: 'courses',
|
|
417
417
|
},
|
|
418
|
+
'course-lesson': {
|
|
419
|
+
fields: [`"resources": ${resourcesField}`],
|
|
420
|
+
},
|
|
418
421
|
download: {
|
|
419
422
|
fields: [
|
|
420
423
|
`"resource": ${resourcesField}`,
|
|
@@ -490,7 +493,7 @@ export let contentTypeConfig = {
|
|
|
490
493
|
],
|
|
491
494
|
slug: 'play-alongs',
|
|
492
495
|
},
|
|
493
|
-
|
|
496
|
+
'course-collection': {
|
|
494
497
|
fields: [
|
|
495
498
|
'"lesson_count": coalesce(count(child[]->.child[]->), 0)',
|
|
496
499
|
`"description": ${descriptionField}`,
|
|
@@ -516,24 +519,9 @@ export let contentTypeConfig = {
|
|
|
516
519
|
slug: 'rudiments',
|
|
517
520
|
},
|
|
518
521
|
routine: {
|
|
519
|
-
fields: [`"description": ${descriptionField}`, '
|
|
522
|
+
fields: [`"description": ${descriptionField}`, 'soundslice_slug'],
|
|
520
523
|
slug: 'routines',
|
|
521
524
|
},
|
|
522
|
-
'pack-children': {
|
|
523
|
-
fields: [
|
|
524
|
-
'child_count',
|
|
525
|
-
`"resources": ${resourcesField}`,
|
|
526
|
-
'"image": logo_image_url.asset->url',
|
|
527
|
-
'"thumbnail": thumbnail.asset->url',
|
|
528
|
-
'"light_mode_logo": light_mode_logo_url.asset->url',
|
|
529
|
-
'"dark_mode_logo": dark_mode_logo_url.asset->url',
|
|
530
|
-
`"description": ${descriptionField}`,
|
|
531
|
-
],
|
|
532
|
-
childFields: [`"description": ${descriptionField}`],
|
|
533
|
-
},
|
|
534
|
-
'pack-bundle-lesson': {
|
|
535
|
-
fields: [`"resources": ${resourcesField}`],
|
|
536
|
-
},
|
|
537
525
|
foundation: {
|
|
538
526
|
fields: [
|
|
539
527
|
`"description": ${descriptionField}`,
|
package/src/index.d.ts
CHANGED
|
@@ -257,7 +257,6 @@ import {
|
|
|
257
257
|
buildEntityAndTotalQuery,
|
|
258
258
|
fetchAll,
|
|
259
259
|
fetchAllFilterOptions,
|
|
260
|
-
fetchAllPacks,
|
|
261
260
|
fetchBrandsByContentIds,
|
|
262
261
|
fetchByRailContentId,
|
|
263
262
|
fetchByRailContentIds,
|
|
@@ -267,6 +266,7 @@ import {
|
|
|
267
266
|
fetchCommentModContentData,
|
|
268
267
|
fetchContentRows,
|
|
269
268
|
fetchContentTypeCounts,
|
|
269
|
+
fetchCourseCollectionData,
|
|
270
270
|
fetchHierarchy,
|
|
271
271
|
fetchLearningPathHierarchy,
|
|
272
272
|
fetchLeaving,
|
|
@@ -280,7 +280,6 @@ import {
|
|
|
280
280
|
fetchNewReleases,
|
|
281
281
|
fetchOtherSongVersions,
|
|
282
282
|
fetchOwnedContent,
|
|
283
|
-
fetchPackAll,
|
|
284
283
|
fetchPackData,
|
|
285
284
|
fetchPlayAlongsCount,
|
|
286
285
|
fetchRecent,
|
|
@@ -479,7 +478,6 @@ declare module 'musora-content-services' {
|
|
|
479
478
|
extractSanityUrl,
|
|
480
479
|
fetchAll,
|
|
481
480
|
fetchAllFilterOptions,
|
|
482
|
-
fetchAllPacks,
|
|
483
481
|
fetchArtistBySlug,
|
|
484
482
|
fetchArtistLessons,
|
|
485
483
|
fetchArtists,
|
|
@@ -499,6 +497,7 @@ declare module 'musora-content-services' {
|
|
|
499
497
|
fetchContentPageUserData,
|
|
500
498
|
fetchContentRows,
|
|
501
499
|
fetchContentTypeCounts,
|
|
500
|
+
fetchCourseCollectionData,
|
|
502
501
|
fetchCustomerPayments,
|
|
503
502
|
fetchEnrollmentPageMetadata,
|
|
504
503
|
fetchFollowedThreads,
|
|
@@ -531,7 +530,6 @@ declare module 'musora-content-services' {
|
|
|
531
530
|
fetchNotifications,
|
|
532
531
|
fetchOtherSongVersions,
|
|
533
532
|
fetchOwnedContent,
|
|
534
|
-
fetchPackAll,
|
|
535
533
|
fetchPackData,
|
|
536
534
|
fetchPlayAlongsCount,
|
|
537
535
|
fetchPlaylist,
|
package/src/index.js
CHANGED
|
@@ -261,7 +261,6 @@ import {
|
|
|
261
261
|
buildEntityAndTotalQuery,
|
|
262
262
|
fetchAll,
|
|
263
263
|
fetchAllFilterOptions,
|
|
264
|
-
fetchAllPacks,
|
|
265
264
|
fetchBrandsByContentIds,
|
|
266
265
|
fetchByRailContentId,
|
|
267
266
|
fetchByRailContentIds,
|
|
@@ -271,6 +270,7 @@ import {
|
|
|
271
270
|
fetchCommentModContentData,
|
|
272
271
|
fetchContentRows,
|
|
273
272
|
fetchContentTypeCounts,
|
|
273
|
+
fetchCourseCollectionData,
|
|
274
274
|
fetchHierarchy,
|
|
275
275
|
fetchLearningPathHierarchy,
|
|
276
276
|
fetchLeaving,
|
|
@@ -284,7 +284,6 @@ import {
|
|
|
284
284
|
fetchNewReleases,
|
|
285
285
|
fetchOtherSongVersions,
|
|
286
286
|
fetchOwnedContent,
|
|
287
|
-
fetchPackAll,
|
|
288
287
|
fetchPackData,
|
|
289
288
|
fetchPlayAlongsCount,
|
|
290
289
|
fetchRecent,
|
|
@@ -478,7 +477,6 @@ export {
|
|
|
478
477
|
extractSanityUrl,
|
|
479
478
|
fetchAll,
|
|
480
479
|
fetchAllFilterOptions,
|
|
481
|
-
fetchAllPacks,
|
|
482
480
|
fetchArtistBySlug,
|
|
483
481
|
fetchArtistLessons,
|
|
484
482
|
fetchArtists,
|
|
@@ -498,6 +496,7 @@ export {
|
|
|
498
496
|
fetchContentPageUserData,
|
|
499
497
|
fetchContentRows,
|
|
500
498
|
fetchContentTypeCounts,
|
|
499
|
+
fetchCourseCollectionData,
|
|
501
500
|
fetchCustomerPayments,
|
|
502
501
|
fetchEnrollmentPageMetadata,
|
|
503
502
|
fetchFollowedThreads,
|
|
@@ -530,7 +529,6 @@ export {
|
|
|
530
529
|
fetchNotifications,
|
|
531
530
|
fetchOtherSongVersions,
|
|
532
531
|
fetchOwnedContent,
|
|
533
|
-
fetchPackAll,
|
|
534
532
|
fetchPackData,
|
|
535
533
|
fetchPlayAlongsCount,
|
|
536
534
|
fetchPlaylist,
|
package/src/services/content.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
fetchUpcomingEvents,
|
|
12
12
|
fetchScheduledReleases,
|
|
13
13
|
fetchReturning,
|
|
14
|
-
fetchLeaving, fetchScheduledAndNewReleases, fetchContentRows, fetchOwnedContent
|
|
14
|
+
fetchLeaving, fetchScheduledAndNewReleases, fetchContentRows, fetchOwnedContent, fetchCourseCollectionData
|
|
15
15
|
} from './sanity.js'
|
|
16
16
|
import {TabResponseType, Tabs, capitalizeFirstLetter} from '../contentMetaData.js'
|
|
17
17
|
import {recommendations, rankCategories, rankItems} from "./recommendations";
|
|
@@ -19,6 +19,8 @@ import {addContextToContent} from "./contentAggregator.js";
|
|
|
19
19
|
import {globalConfig} from "./config";
|
|
20
20
|
import {getUserData} from "./user/management";
|
|
21
21
|
import {filterTypes, ownedContentTypes} from "../contentTypeConfig";
|
|
22
|
+
import {getPermissionsAdapter} from "./permissions/index.ts";
|
|
23
|
+
import {MEMBERSHIP_PERMISSIONS} from "../constants/membership-permissions.ts";
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
export async function getLessonContentRows (brand='drumeo', pageName = 'lessons') {
|
|
@@ -458,24 +460,33 @@ export async function getRecommendedForYou(brand, rowId = null, {
|
|
|
458
460
|
* .then(content => console.log(content))
|
|
459
461
|
* .catch(error => console.error(error));
|
|
460
462
|
*/
|
|
461
|
-
export async function getLegacyMethods(brand)
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
463
|
+
export async function getLegacyMethods(brand)
|
|
464
|
+
{
|
|
465
|
+
const brandMap = {
|
|
466
|
+
drumeo: [241247],
|
|
467
|
+
pianote: [
|
|
468
|
+
276693,
|
|
469
|
+
215952 //Foundations 2019
|
|
470
|
+
],
|
|
471
|
+
singeo: [308514],
|
|
472
|
+
guitareo: [333652],
|
|
473
|
+
}
|
|
474
|
+
const ids = brandMap[brand] ?? null;
|
|
475
|
+
if (!ids) return [];
|
|
476
|
+
const adapter = getPermissionsAdapter()
|
|
477
|
+
const userPermissionsData = await adapter.fetchUserPermissions()
|
|
478
|
+
const userPermissions = userPermissionsData.permissions
|
|
479
|
+
// Users should only have access to this if they have an active membership AS WELL as the content access
|
|
480
|
+
// This is hardcoded behaviour and isn't found elsewhere
|
|
481
|
+
const hasMembership = userPermissionsData.isAdmin
|
|
482
|
+
|| userPermissions.includes(MEMBERSHIP_PERMISSIONS.base)
|
|
483
|
+
|| userPermissions.includes(MEMBERSHIP_PERMISSIONS.plus)
|
|
484
|
+
const hasContentPermission = userPermissions.includes(100000000 + ids[0])
|
|
485
|
+
if (hasMembership && hasContentPermission) {
|
|
486
|
+
return Promise.all(ids.map(id => fetchCourseCollectionData(id)))
|
|
487
|
+
} else {
|
|
488
|
+
return []
|
|
489
|
+
}
|
|
479
490
|
}
|
|
480
491
|
|
|
481
492
|
/**
|
|
@@ -509,7 +520,7 @@ export async function getLegacyMethods(brand) {
|
|
|
509
520
|
* @example
|
|
510
521
|
* // Fetch owned content filtered by types
|
|
511
522
|
* getOwnedContent('drumeo', {
|
|
512
|
-
* type: ['course', '
|
|
523
|
+
* type: ['course', 'course-collection'],
|
|
513
524
|
* page: 1,
|
|
514
525
|
* limit: 10
|
|
515
526
|
* })
|
|
@@ -20,7 +20,7 @@ import {getContentAwardsByIds} from "./awards/award-query.js";
|
|
|
20
20
|
* {} <- fetchLessonContent || on playback page (main window)
|
|
21
21
|
* in the examples below, dataField would be set to `children`
|
|
22
22
|
* [{id, children}, {id, children,}] <- getTabData || catalog Page
|
|
23
|
-
* {
|
|
23
|
+
* {children, } <- getCourseCollectionData || Course Collection index page
|
|
24
24
|
*
|
|
25
25
|
*
|
|
26
26
|
* @param dataPromise - promise or method that provides sanity data
|
|
@@ -94,7 +94,7 @@ export async function getNavigateTo(data, collection = null) {
|
|
|
94
94
|
collection = normalizeCollection(collection)
|
|
95
95
|
let navigateToData = {}
|
|
96
96
|
|
|
97
|
-
const twoDepthContentTypes = ['
|
|
97
|
+
const twoDepthContentTypes = ['course-collection'] // not adding method because it has its own logic (with active path)
|
|
98
98
|
//TODO add parent hierarchy upwards as well
|
|
99
99
|
// data structure is the same but instead of child{} we use parent{}
|
|
100
100
|
for (const content of data) {
|
|
@@ -134,7 +134,7 @@ export async function getNavigateTo(data, collection = null) {
|
|
|
134
134
|
const lastInteracted = await getLastInteractedOf(childrenIds, collection)
|
|
135
135
|
const lastInteractedStatus = childrenStates[lastInteracted]
|
|
136
136
|
|
|
137
|
-
if (['course', '
|
|
137
|
+
if (['course', 'skill-pack'].includes(content.type)) {
|
|
138
138
|
if (lastInteractedStatus === STATE_STARTED) {
|
|
139
139
|
// send to last interacted
|
|
140
140
|
navigateToData[content.id] = buildNavigateTo(
|
|
@@ -169,7 +169,7 @@ export async function getNavigateTo(data, collection = null) {
|
|
|
169
169
|
collection
|
|
170
170
|
)
|
|
171
171
|
if (childrenStates[lastInteractedChildId] === STATE_COMPLETED) {
|
|
172
|
-
// TODO:
|
|
172
|
+
// TODO: course collections have an extra situation where we need to jump to the next course if all lessons in the last engaged course are completed
|
|
173
173
|
}
|
|
174
174
|
let lastInteractedChildNavToData = await getNavigateTo(firstChildren, collection)
|
|
175
175
|
lastInteractedChildNavToData = lastInteractedChildNavToData[lastInteractedChildId]
|
|
@@ -169,7 +169,7 @@ function getDefaultCTATextForContent(content, contentType) {
|
|
|
169
169
|
if (contentType === 'lesson') ctaText = 'Revisit Lesson'
|
|
170
170
|
if (contentType === 'song tutorial' || collectionLessonTypes.includes(content.type))
|
|
171
171
|
ctaText = 'Revisit Lessons'
|
|
172
|
-
if (contentType === '
|
|
172
|
+
if (contentType === 'course-collection') ctaText = 'View Lessons'
|
|
173
173
|
}
|
|
174
174
|
return ctaText
|
|
175
175
|
}
|
package/src/services/sanity.js
CHANGED
|
@@ -639,8 +639,6 @@ export async function fetchAll(
|
|
|
639
639
|
bypassStatusAndPublishedValidation = true
|
|
640
640
|
} else if (type === 'lessons' || type === 'songs') {
|
|
641
641
|
typeFilter = ``
|
|
642
|
-
} else if (type === 'pack') {
|
|
643
|
-
typeFilter = `&& (_type == 'pack' || _type == 'semester-pack')`
|
|
644
642
|
} else {
|
|
645
643
|
typeFilter = type ? `&& _type == '${type}'` : ''
|
|
646
644
|
}
|
|
@@ -1163,50 +1161,6 @@ export async function fetchRelatedLessons(railContentId) {
|
|
|
1163
1161
|
return await fetchSanity(query, false, { processNeedAccess: true })
|
|
1164
1162
|
}
|
|
1165
1163
|
|
|
1166
|
-
/**
|
|
1167
|
-
* Fetch all packs.
|
|
1168
|
-
* @param {string} brand - The brand for which to fetch packs.
|
|
1169
|
-
* @param {string} [searchTerm=""] - The search term to filter packs.
|
|
1170
|
-
* @param {string} [sort="-published_on"] - The field to sort the packs by.
|
|
1171
|
-
* @param {number} [params.page=1] - The page number for pagination.
|
|
1172
|
-
* @param {number} [params.limit=10] - The number of items per page.
|
|
1173
|
-
* @returns {Promise<Array<Object>|null>} - The fetched pack content data or null if not found.
|
|
1174
|
-
*/
|
|
1175
|
-
export async function fetchAllPacks(
|
|
1176
|
-
brand,
|
|
1177
|
-
sort = '-published_on',
|
|
1178
|
-
searchTerm = '',
|
|
1179
|
-
page = 1,
|
|
1180
|
-
limit = 10
|
|
1181
|
-
) {
|
|
1182
|
-
const sortOrder = getSortOrder(sort, brand)
|
|
1183
|
-
const filter = `(_type == 'pack' || _type == 'semester-pack') && brand == '${brand}' && title match "${searchTerm}*"`
|
|
1184
|
-
const filterParams = {}
|
|
1185
|
-
const start = (page - 1) * limit
|
|
1186
|
-
const end = start + limit
|
|
1187
|
-
|
|
1188
|
-
const query = await buildQuery(
|
|
1189
|
-
filter,
|
|
1190
|
-
filterParams,
|
|
1191
|
-
await getFieldsForContentTypeWithFilteredChildren('pack'),
|
|
1192
|
-
{
|
|
1193
|
-
sortOrder: sortOrder,
|
|
1194
|
-
start,
|
|
1195
|
-
end,
|
|
1196
|
-
}
|
|
1197
|
-
)
|
|
1198
|
-
return fetchSanity(query, true)
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
/**
|
|
1202
|
-
* Fetch all content for a specific pack by Railcontent ID.
|
|
1203
|
-
* @param {string} railcontentId - The Railcontent ID of the pack.
|
|
1204
|
-
* @returns {Promise<Array<Object>|null>} - The fetched pack content data or null if not found.
|
|
1205
|
-
*/
|
|
1206
|
-
export async function fetchPackAll(railcontentId, type = 'pack') {
|
|
1207
|
-
return fetchByRailContentId(railcontentId, type)
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
1164
|
export async function fetchLiveEvent(brand, forcedContentId = null) {
|
|
1211
1165
|
const LIVE_EXTRA_MINUTES = 30
|
|
1212
1166
|
//calendarIDs taken from addevent.php
|
|
@@ -1283,6 +1237,25 @@ export async function fetchLiveEvent(brand, forcedContentId = null) {
|
|
|
1283
1237
|
}
|
|
1284
1238
|
|
|
1285
1239
|
/**
|
|
1240
|
+
* Fetch the data needed for the CourseCollection Overview screen.
|
|
1241
|
+
* @param {number} id - The Railcontent ID of the CourseCollection
|
|
1242
|
+
* @returns {Promise<Object|null>} - The CourseCollection information and lessons or null if not found.
|
|
1243
|
+
*
|
|
1244
|
+
* @example
|
|
1245
|
+
* fetchCourseCollectionData(404048)
|
|
1246
|
+
* .then(CourseCollection => console.log(CourseCollection))
|
|
1247
|
+
* .catch(error => console.error(error));
|
|
1248
|
+
*/
|
|
1249
|
+
export async function fetchCourseCollectionData(id) {
|
|
1250
|
+
const builder = await new FilterBuilder(`railcontent_id == ${id}`).buildFilter()
|
|
1251
|
+
const query = `*[${builder}]{
|
|
1252
|
+
${await getFieldsForContentTypeWithFilteredChildren('course-collection')}
|
|
1253
|
+
} [0...1]`
|
|
1254
|
+
return fetchSanity(query, false)
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
/**
|
|
1258
|
+
* DEPRECATED: Use fetchCourseCollectionData
|
|
1286
1259
|
* Fetch the data needed for the Pack Overview screen.
|
|
1287
1260
|
* @param {number} id - The Railcontent ID of the pack
|
|
1288
1261
|
* @returns {Promise<Object|null>} - The pack information and lessons or null if not found.
|
|
@@ -1293,11 +1266,7 @@ export async function fetchLiveEvent(brand, forcedContentId = null) {
|
|
|
1293
1266
|
* .catch(error => console.error(error));
|
|
1294
1267
|
*/
|
|
1295
1268
|
export async function fetchPackData(id) {
|
|
1296
|
-
|
|
1297
|
-
const query = `*[${builder}]{
|
|
1298
|
-
${await getFieldsForContentTypeWithFilteredChildren('pack')}
|
|
1299
|
-
} [0...1]`
|
|
1300
|
-
return fetchSanity(query, false)
|
|
1269
|
+
return fetchCourseCollectionData(id)
|
|
1301
1270
|
}
|
|
1302
1271
|
|
|
1303
1272
|
/**
|