Sanity-Services

Members

(inner, constant) TAB_TO_CONTENT_TYPES :Object.<string, Array.<string>>

Description:
  • Mapping from tab names to their underlying Sanity content types. Used to determine if a tab has any content available.
Source:
Mapping from tab names to their underlying Sanity content types. Used to determine if a tab has any content available.
Type:
  • Object.<string, Array.<string>>

(inner, constant) excludeFromGeneratedIndex :Array.<string>

Description:
  • Exported functions that are excluded from index generation.
Source:
Exported functions that are excluded from index generation.
Type:
  • Array.<string>

Methods

(static) fetchAll(brand, type, params) → {Promise.<(Object|null)>}

Description:
  • Fetch all content for a specific brand and type with pagination, search, and grouping options.
Source:
Example
fetchAll('drumeo', 'song', {
  page: 2,
  limit: 20,
  searchTerm: 'jazz',
  sort: '-popularity',
  includedFields: ['difficulty,Intermediate'],
  groupBy: 'artist',
  progressIds: [123, 321],
  useDefaultFields: false,
  customFields: ['is_house_coach', 'slug.current', "'instructors': instructor[]->name"],
})
  .then(content => console.log(content))
  .catch(error => console.error(error));
Parameters:
Name Type Description
brand string The brand for which to fetch content.
type string The content type to fetch (e.g., 'song', 'artist').
params Object Parameters for pagination, filtering, sorting, and grouping.
Properties
Name Type Attributes Default Description
page number <optional>
1 The page number for pagination.
limit number <optional>
10 The number of items per page.
searchTerm string <optional>
"" The search term to filter content by title or artist.
sort string <optional>
"-published_on" The field to sort the content by.
includedFields Array.<string> <optional>
[] The fields to include in the query.
groupBy string <optional>
"" The field to group the results by (e.g., 'artist', 'genre').
progressIds Array.<string> <optional>
An array of railcontent IDs to filter the results by. Used for filtering by progress.
useDefaultFields boolean <optional>
true use the default sanity fields for content Type
customFields Array.<string> <optional>
[] An array of sanity fields to include in the request
progress string <optional>
"all" An string representing which progress filter to use ("all", "in progress", "complete", "not started").
Returns:
- The fetched content data or null if not found.
Type
Promise.<(Object|null)>

(static) fetchAllFilterOptions(brand, filters, styleopt, artistopt, contentType, termopt, progressIdsopt, coachIdopt, includeTabsopt) → {Promise.<Object>}

Description:
  • Fetches all available filter options based on brand, filters, and various optional criteria. This function constructs a query to retrieve the total number of results and filter options such as difficulty, instrument type, and genre. The filter options are dynamically generated based on the provided filters, style, artist, and content type. If a coachId is provided, the content type must be 'coach-lessons'.
Source:
Examples
// Fetch filter options for 'song' content type:
fetchAllFilterOptions('myBrand', [], 'Rock', 'John Doe', 'song', 'Love')
  .then(options => console.log(options))
  .catch(error => console.error(error));
// Fetch filter options for a coach's lessons with coachId:
fetchAllFilterOptions('myBrand', [], 'Rock', 'John Doe', 'coach-lessons', 'Love', undefined, '123')
  .then(options => console.log(options))
  .catch(error => console.error(error));
Parameters:
Name Type Attributes Default Description
brand string Brand to filter.
filters Array.<string> Key-value pairs to filter the query.
style string <optional>
Optional style/genre filter.
artist string <optional>
Optional artist name filter.
contentType string Content type (e.g., 'song', 'lesson').
term string <optional>
Optional search term for title, album, artist, or genre.
progressIds Array.<string> <optional>
Optional array of progress IDs to filter by.
coachId string <optional>
Optional coach ID (only valid if contentType is 'coach-lessons').
includeTabs boolean <optional>
false Whether to include tabs in the returned metadata.
Throws:
If coachId is provided but contentType isn't 'coach-lessons'.
Type
Error
Returns:
- The filter options and metadata.
Type
Promise.<Object>

(static) fetchBrandsByContentIds(contentIds) → {Promise.<Object>}

Description:
  • Fetch brands for given content IDs.
Source:
Parameters:
Name Type Description
contentIds Array.<number> Array of railcontent IDs
Returns:
- A promise that resolves to an object mapping content IDs to brands
Type
Promise.<Object>

(static) fetchByRailContentId(id, contentType) → {Promise.<(Object|null)>}

Description:
  • Fetch content by a specific Railcontent ID.
Source:
Example
fetchByRailContentId('abc123')
  .then(content => console.log(content))
  .catch(error => console.error(error));
Parameters:
Name Type Description
id string The Railcontent ID of the content to fetch.
contentType string The document type of content to fetch
Returns:
- A promise that resolves to the content object or null if not found.
Type
Promise.<(Object|null)>

(static) fetchByRailContentIds(ids, contentTypeopt) → {Promise.<(Array.<Object>|null)>}

Description:
  • Fetch content by an array of Railcontent IDs.
Source:
Example
fetchByRailContentIds(['abc123', 'def456', 'ghi789'])
  .then(contents => console.log(contents))
  .catch(error => console.error(error));
Parameters:
Name Type Attributes Description
ids Array.<(string|number)> The array of Railcontent IDs of the content to fetch.
contentType string <optional>
The content type the IDs to add needed fields to the response.
Returns:
- A promise that resolves to an array of content objects or null if not found.
Type
Promise.<(Array.<Object>|null)>

(static) fetchByReference(id) → {Promise.<(Object|null)>}

Description:
  • Fetch the data needed for the coach screen.
Source:
Example
fetchCoachLessons('coach123')
  .then(lessons => console.log(lessons))
  .catch(error => console.error(error));
Parameters:
Name Type Description
id string The Railcontent ID of the coach
Returns:
- The lessons for the instructor or null if not found.
Type
Promise.<(Object|null)>

(static) fetchComingSoon() → {Promise.<(Object|null)>}

Description:
  • fetches from Sanity all songs coming soon (new) next quarter
Source:
Returns:
Type
Promise.<(Object|null)>

(static) fetchCommentModContentData(ids) → {Promise.<(Object|null)>}

Description:
  • Fetch data for comment mod page
Source:
Parameters:
Name Type Description
ids array List of ids get data for
Returns:
- A promise that resolves to an object containing the data
Type
Promise.<(Object|null)>

(static) fetchContentTypeCounts(brand, pageName) → {Promise.<Object.<string, number>>}

Description:
  • Fetch counts for all content types on a page (lessons/songs) in a single query. Uses GROQ aggregation to efficiently get counts for multiple content types. Only returns types with count > 0.
Source:
Example
await fetchContentTypeCounts('playbass', 'lessons')
// Returns: { 'guided-course': 45, 'skill-pack': 12, 'special': 8 }
Parameters:
Name Type Description
brand string Brand identifier (e.g., 'drumeo', 'playbass')
pageName string Page name ('lessons' or 'songs')
Returns:
- Object mapping content types to counts
Type
Promise.<Object.<string, number>>

(static) fetchCourseCollectionData(id) → {Promise.<(Object|null)>}

Description:
  • Fetch the data needed for the CourseCollection Overview screen.
Source:
Example
fetchCourseCollectionData(404048)
  .then(CourseCollection => console.log(CourseCollection))
  .catch(error => console.error(error));
Parameters:
Name Type Description
id number The Railcontent ID of the CourseCollection
Returns:
- The CourseCollection information and lessons or null if not found.
Type
Promise.<(Object|null)>

(static) fetchLeaving() → {Promise.<(Object|null)>}

Description:
  • fetches from Sanity all content marked for removal next quarter
Source:
Returns:
Type
Promise.<(Object|null)>

(static) fetchLessonContent(railContentId) → {Promise.<(Object|null)>}

Description:
  • Fetch the page data for a specific lesson by Railcontent ID.
Source:
Example
fetchLessonContent('lesson123')
  .then(data => console.log(data))
  .catch(error => console.error(error));
Parameters:
Name Type Description
railContentId string The Railcontent ID of the current lesson.
Returns:
- The fetched page data or null if found.
Type
Promise.<(Object|null)>

(static) fetchLessonsFeaturingThisContent(railcontentId, brand, count) → {Promise.<Array.<Object>>}

Description:
  • Get non-song content documents that share content information with the provided railcontent document. These are linked through content that shares a license with the provided railcontent document
Source:
Parameters:
Name Type Description
railcontentId integer
brand string
count integer:3
Returns:
Type
Promise.<Array.<Object>>

(static) fetchMetadata(brand, type, optionsopt) → {Promise.<{name, description, type: *, thumbnailUrl}>}

Description:
  • Fetch metadata from the contentMetaData.js based on brand and type. For v2 you need to provide page type('lessons' or 'songs') in type parameter
Source:
Examples
// Standard usage (with tab filtering)
fetchMetadata('drumeo', 'lessons')
// Internal usage (skip tab filtering to prevent recursion)
fetchMetadata('drumeo', 'lessons', { skipTabFiltering: true })
Parameters:
Name Type Attributes Default Description
brand string The brand for which to fetch metadata.
type string The type for which to fetch metadata.
options Object | boolean <optional>
{} Options object or legacy boolean for withFilters
Properties
Name Type Attributes Default Description
skipTabFiltering boolean <optional>
false Skip dynamic tab filtering (internal use)
Returns:
Type
Promise.<{name, description, type: *, thumbnailUrl}>

(static) fetchMethodV2IntroVideo(brand) → {Promise.<(*|null)>}

Description:
  • Fetch the method intro video for a given brand.
Source:
Parameters:
Name Type Description
brand
Returns:
Type
Promise.<(*|null)>

(static) fetchMethodV2Structure(brand) → {Promise.<(*|null)>}

Description:
  • Fetch the structure (just ids) of the Method for a given brand.
Source:
Parameters:
Name Type Description
brand
Returns:
Type
Promise.<(*|null)>

(static) fetchMethodV2StructureFromId(contentId) → {Promise.<(*|null)>}

Description:
  • Fetch the structure (just ids) of the Method of a given learning path or learning path lesson.
Source:
Parameters:
Name Type Description
contentId
Returns:
Type
Promise.<(*|null)>

(static) fetchNewReleases(brand) → {Promise.<(Object|null)>}

Description:
  • Fetch the latest new releases for a specific brand.
Source:
Parameters:
Name Type Description
brand string The brand for which to fetch new releases.
Returns:
- The fetched new releases data or null if not found.
Type
Promise.<(Object|null)>

(static) fetchOtherSongVersions(railcontentId, brand, count) → {Promise.<Array.<Object>>}

Description:
  • Get song type (transcriptions, jam packs, play alongs, tutorial children) content documents that share content information with the provided railcontent document. These are linked through content that shares a license with the provided railcontent document
Source:
Parameters:
Name Type Description
railcontentId
brand
count
Returns:
Type
Promise.<Array.<Object>>

(static) fetchOwnedContent(brand, options) → {Promise.<Object>}

Description:
  • Fetch content owned by the user (excluding membership content). Shows only content accessible through purchases/entitlements, not through membership.
Source:
Parameters:
Name Type Description
brand string The brand to filter content by
options Object Fetch options
Properties
Name Type Description
type Array.<string> Content type(s) to filter (optional array, default: [])
page number Page number (default: 1)
limit number Items per page (default: 10)
sort string Sort field and direction (default: '-published_on')
Returns:
Object with 'entity' (content array) and 'total' (count)
Type
Promise.<Object>

(static) fetchPackData(id) → {Promise.<(Object|null)>}

Description:
  • DEPRECATED: Use fetchCourseCollectionData Fetch the data needed for the Pack Overview screen.
Source:
Example
fetchPackData(404048)
  .then(pack => console.log(pack))
  .catch(error => console.error(error));
Parameters:
Name Type Description
id number The Railcontent ID of the pack
Returns:
- The pack information and lessons or null if not found.
Type
Promise.<(Object|null)>

(static) fetchRelatedLessons(railContentId) → {Promise.<(Array.<Object>|null)>}

Description:
  • Fetch lessons related to a specific lesson by RailContent ID and type.
Source:
Parameters:
Name Type Description
railContentId string The RailContent ID of the current lesson.
Returns:
- The fetched related lessons data or null if not found.
Type
Promise.<(Array.<Object>|null)>

(static) fetchRelatedRecommendedContent(railContentId, brand, count) → {Promise.<Array.<Object>>}

Description:
  • Returns a list of recommended content based on the provided railContentId. If no recommendations found in recsys, falls back to fetching related lessons.
Source:
Parameters:
Name Type Description
railContentId
brand
count
Returns:
Type
Promise.<Array.<Object>>

(static) fetchRelatedSongs(brand, songId) → {Promise.<(Object|null)>}

Description:
  • Fetch related songs for a specific brand and song ID.
Source:
Example
fetchRelatedSongs('drumeo', '12345')
  .then(relatedSongs => console.log(relatedSongs))
  .catch(error => console.error(error));
Parameters:
Name Type Description
brand string The brand for which to fetch related songs.
songId string The ID of the song to find related songs for.
Returns:
- A promise that resolves to an array of related song objects or null if not found.
Type
Promise.<(Object|null)>

(static) fetchReturning() → {Promise.<(Object|null)>}

Description:
  • fetches from Sanity all content marked for return next quarter
Source:
Returns:
Type
Promise.<(Object|null)>

(static) fetchSanity(query, isList, options) → {Promise.<(*|null)>}

Source:
Example
const query = `*[_type == "song"]{title, artist->name}`;
fetchSanity(query, true)
  .then(data => console.log(data))
  .catch(error => console.error(error));
Parameters:
Name Type Description
query string The GROQ query to execute against the Sanity API.
isList boolean Whether to return an array or a single result.
options Object Additional options for fetching data.
Properties
Name Type Attributes Default Description
customPostProcess function <optional>
null custom post process callback
processNeedAccess boolean <optional>
true execute the needs_access callback
processPageType boolean <optional>
true execute the page_type callback
Returns:
- A promise that resolves to the fetched data or null if an error occurs or no results are found.
Type
Promise.<(*|null)>

(static) fetchScheduledReleases(brand) → {Promise.<(Object|null)>}

Description:
  • Fetch scheduled releases for a specific brand.
Source:
Example
fetchScheduledReleases('drumeo', {
  page: 2,
  limit: 20,
})
  .then(content => console.log(content))
  .catch(error => console.error(error));
Parameters:
Name Type Description
brand string The brand for which to fetch scheduled releasess.
Returns:
- A promise that resolves to an array of scheduled release objects or null if not found.
Type
Promise.<(Object|null)>

(static) fetchShowsData(brand) → {Promise.<{name, description, type: *, thumbnailUrl}>}

Description:
  • Fetch shows data for a brand.
Source:
Example
fetchShowsData('drumeo')
  .then(data => console.log(data))
  .catch(error => console.error(error));
Parameters:
Name Type Description
brand The brand for which to fetch shows.
Returns:
Type
Promise.<{name, description, type: *, thumbnailUrl}>

(static) fetchSiblingContent(railContentId, brand) → {Promise.<(Array.<Object>|null)>}

Description:
  • Fetch sibling lessons to a specific lesson
Source:
Parameters:
Name Type Description
railContentId string The RailContent ID of the current lesson.
brand string The current brand.
Returns:
- The fetched related lessons data or null if not found.
Type
Promise.<(Array.<Object>|null)>

(static) fetchSongArtistCount(brand) → {Promise.<(int|null)>}

Description:
  • Fetch current number of artists for songs within a brand.
Source:
Parameters:
Name Type Description
brand string The current brand.
Returns:
- The fetched count of artists.
Type
Promise.<(int|null)>

(static) fetchSongById(documentId) → {Promise.<(Object|null)>}

Description:
  • Fetch a song by its document ID from Sanity.
Source:
Example
fetchSongById('abc123')
  .then(song => console.log(song))
  .catch(error => console.error(error));
Parameters:
Name Type Description
documentId string The ID of the document to fetch.
Returns:
- A promise that resolves to an object containing the song data or null if not found.
Type
Promise.<(Object|null)>

(static) fetchTopLevelParentId(railcontentId) → {Promise.<(int|null)>}

Description:
  • Return the top level parent content railcontent_id. Ignores learning-path-v2 parents. ex: if railcontentId is of type 'skill-pack-lesson', return the corresponding 'skill-pack' railcontent_id
Source:
Parameters:
Name Type Description
railcontentId int
Returns:
Type
Promise.<(int|null)>

(static) fetchUpcomingEvents(brand) → {Promise.<(Object|null)>}

Description:
  • Fetch upcoming events for a specific brand.
Source:
Example
fetchUpcomingEvents('drumeo', {
  page: 2,
  limit: 20,
})
  .then(events => console.log(events))
  .catch(error => console.error(error));
Parameters:
Name Type Description
brand string The brand for which to fetch upcoming events.
Returns:
- A promise that resolves to an array of upcoming event objects or null if not found.
Type
Promise.<(Object|null)>

(static) hasAnyMethodV2IntroCompleted() → {Promise.<boolean>}

Description:
  • Checks whether the user has completed a Method V2 intro video on **any** brand. Fetches all `method-intro` content IDs from Sanity (cross-brand) and checks the local progress store for any completed record among them. This intentionally ignores the current brand so that completing the intro on one brand (e.g. PlayBass) is recognised as completed when the user switches to another brand (e.g. Drumeo).
Source:
Returns:
`true` if the user has completed at least one Method V2 intro video across any brand, `false` otherwise.
Type
Promise.<boolean>

(static) jumpToContinueContent(railcontentId) → {Promise.<({next: (Object|null)}|null)>}

Description:
  • Fetch the next piece of content under a parent by Railcontent ID
Source:
Example
jumpToContinueContent(296693)
 then.(data => { console.log('next', data.next);})
 .catch(error => console.error(error));
Parameters:
Name Type Description
railcontentId int The Railcontent ID of the parent content
Returns:
- object with 'next' attribute
Type
Promise.<({next: (Object|null)}|null)>

(async, inner) fetchRelatedByLicense(railcontentId, brand, onlyUseSongTypes, count) → {Promise.<Array.<Object>>}

Description:
  • Get content documents that share license information with the provided railcontent id
Source:
Parameters:
Name Type Description
railcontentId integer
brand string
onlyUseSongTypes boolean if true, only return the song type documents. If false, return everything except those
count integer:3
Returns:
Type
Promise.<Array.<Object>>

(inner) filterTabsByContentCounts(tabs, contentTypeCounts) → {Array}

Description:
  • Filter tabs based on which content types have content. Always keeps 'For You' and 'Explore All' tabs.
Source:
Parameters:
Name Type Description
tabs Array Array of tab objects from metadata
contentTypeCounts Object.<string, number> Content type counts
Returns:
- Filtered array of tabs with content
Type
Array

(inner) filterTypeOptionsByContentCounts(filters, contentTypeCounts) → {Array}

Description:
  • Filter Type filter options based on content type counts. Removes parent/child options that have no content available. Returns a new filters array (does not mutate original).
Source:
Parameters:
Name Type Description
filters Array Filter groups array from metadata
contentTypeCounts Object.<string, number> Content type counts
Returns:
- Filtered filter groups
Type
Array

(inner) getAllContentTypesForPage(pageName) → {Array.<string>}

Description:
  • Get all possible content types for a page type (lessons or songs). Returns unique array of Sanity content type strings. Uses the existing filterTypes mapping from contentTypeConfig.
Source:
Example
getAllContentTypesForPage('lessons')
// Returns: ['lesson', 'quick-tips', 'course', 'guided-course', ...]
Parameters:
Name Type Description
pageName string Page name ('lessons' or 'songs')
Returns:
- Array of content type strings
Type
Array.<string>

(inner) getContentTypesForFilterName(displayName) → {Array.<string>|undefined}

Description:
  • Maps a display name to its corresponding content types from lessonTypesMapping.
Source:
Parameters:
Name Type Description
displayName string The display name from filter metadata
Returns:
- Array of content types or undefined if not found
Type
Array.<string> | undefined

(inner) getQueryFromPage() → {Array.<number>}

Source:
Returns:
Type
Array.<number>