Sanity-Services

Members

(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) fetchAllPacks(brand, searchTermopt, sortopt) → {Promise.<(Array.<Object>|null)>}

Description:
  • Fetch all packs.
Source:
Parameters:
Name Type Attributes Default Description
brand string The brand for which to fetch packs.
searchTerm string <optional>
"" The search term to filter packs.
sort string <optional>
"-published_on" The field to sort the packs by.
params.page number <optional>
1 The page number for pagination.
params.limit number <optional>
10 The number of items per page.
Returns:
- The fetched pack content data or null if not found.
Type
Promise.<(Array.<Object>|null)>

(static) fetchArtistLessons(brand, name, contentType, params) → {Promise.<(Object|null)>}

Description:
  • Fetch the artist's lessons.
Source:
Example
fetchArtistLessons('drumeo', '10 Years', 'song', {'-published_on', '', 1, 10, ["difficulty,Intermediate"], [232168, 232824, 303375, 232194, 393125]})
  .then(lessons => console.log(lessons))
  .catch(error => console.error(error));
Parameters:
Name Type Description
brand string The brand for which to fetch lessons.
name string The name of the artist
contentType string The type of the lessons we need to get from the artist. If not defined, groq will get lessons from all content types
params Object Parameters for sorting, searching, pagination and filtering.
Properties
Name Type Attributes Default Description
sort string <optional>
"-published_on" The field to sort the lessons by.
searchTerm string <optional>
"" The search term to filter the lessons.
page number <optional>
1 The page number for pagination.
limit number <optional>
10 The number of items per page.
includedFields Array.<string> <optional>
[] Additional filters to apply to the query in the format of a key,value array. eg. ['difficulty,Intermediate', 'genre,rock'].
progressIds Array.<number> <optional>
The ids of the lessons that are in progress or completed
Returns:
- The lessons for the artist and some details about the artist (name and thumbnail).
Type
Promise.<(Object|null)>

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

Description:
  • Fetch all artists with lessons available for a specific brand.
Source:
Example
fetchArtists('drumeo')
  .then(artists => console.log(artists))
  .catch(error => console.error(error));
Parameters:
Name Type Description
brand string The brand for which to fetch artists.
Returns:
- A promise that resolves to an array of artist objects or null if not found.
Type
Promise.<(Object|null)>

(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> 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) fetchCoachLessons(brand, id, params) → {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
brand string The brand for which to fetch coach lessons
id string The Railcontent ID of the coach
params Object Parameters for pagination, filtering and sorting.
Properties
Name Type Attributes Default Description
sortOrder string <optional>
"-published_on" The field to sort the lessons by.
searchTerm string <optional>
"" The search term to filter content by title.
page number <optional>
1 The page number for pagination.
limit number <optional>
10 The number of items per page.
includedFields Array.<string> <optional>
[] Additional filters to apply to the query in the format of a key,value array. eg. ['difficulty,Intermediate', 'genre,rock'].
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) fetchFoundation(slug) → {Promise.<(Object|null)>}

Description:
  • Fetch the Foundations 2019.
Source:
Parameters:
Name Type Description
slug string The slug of the method.
Returns:
- The fetched foundation data or null if not found.
Type
Promise.<(Object|null)>

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

Description:
  • Fetch the genre's lessons.
Source:
Example
fetchGenreLessons('drumeo', 'Blues', 'song', {'-published_on', '', 1, 10, ["difficulty,Intermediate"], [232168, 232824, 303375, 232194, 393125]})
  .then(lessons => console.log(lessons))
  .catch(error => console.error(error));
Parameters:
Name Type Description
brand string The brand for which to fetch lessons.
name string The name of the genre
params Object Parameters for sorting, searching, pagination and filtering.
Properties
Name Type Attributes Default Description
sort string <optional>
"-published_on" The field to sort the lessons by.
searchTerm string <optional>
"" The search term to filter the lessons.
page number <optional>
1 The page number for pagination.
limit number <optional>
10 The number of items per page.
includedFields Array.<string> <optional>
[] Additional filters to apply to the query in the format of a key,value array. eg. ['difficulty,Intermediate', 'genre,rock'].
progressIds Array.<number> <optional>
The ids of the lessons that are in progress or completed
Returns:
- The lessons for the artist and some details about the artist (name and thumbnail).
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) fetchMetadata(brand, type) → {Promise.<{name, description, type: *, thumbnailUrl}>}

Description:
  • Fetch metadata from the contentMetaData.js based on brand and type.
Source:
Example
fetchMetadata('drumeo','song')
  .then(data => console.log(data))
  .catch(error => console.error(error));
Parameters:
Name Type Description
brand string The brand for which to fetch metadata.
type string The type for which to fetch metadata.
Returns:
Type
Promise.<{name, description, type: *, thumbnailUrl}>

(static) fetchMethod(brand, slug) → {Promise.<(Object|null)>}

Description:
  • Fetch the Method (learning-paths) for a specific brand.
Source:
Parameters:
Name Type Description
brand string The brand for which to fetch methods.
slug string The slug of the method.
Returns:
- The fetched methods data or null if not found.
Type
Promise.<(Object|null)>

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

Description:
  • Fetch the child courses for a specific method by Railcontent ID.
Source:
Parameters:
Name Type Description
railcontentId string The Railcontent ID of the current lesson.
Returns:
- The fetched next lesson data or null if not found.
Type
Promise.<(Object|null)>

(static) fetchMethodChildrenIds(railcontentId) → {Promise.<(Array.<Object>|null)>}

Description:
  • Fetch all children of a specific method by Railcontent ID.
Source:
Parameters:
Name Type Description
railcontentId string The Railcontent ID of the method.
Returns:
- The fetched children data or null if not found.
Type
Promise.<(Array.<Object>|null)>

(static) fetchMethodPreviousNextLesson(railcontentId, methodId) → {Promise.<(Object|null)>}

Description:
  • Fetch the next lesson for a specific method by Railcontent ID.
Source:
Example
fetchMethodPreviousNextLesson(241284, 241247)
 .then(data => { console.log('nextLesson', data.nextLesson); console.log('prevlesson', data.prevLesson);})
 .catch(error => console.error(error));
Parameters:
Name Type Description
railcontentId string The Railcontent ID of the current lesson.
methodId string The RailcontentID of the method
Returns:
- object with `nextLesson` and `previousLesson` attributes
Type
Promise.<(Object|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) fetchNextPreviousLesson(railcontentId) → {Promise.<(Object|null)>}

Description:
  • Fetch the next and previous lessons for a specific lesson by Railcontent ID.
Source:
Parameters:
Name Type Description
railcontentId string The Railcontent ID of the current lesson.
Returns:
- The fetched next and previous lesson data or null if found.
Type
Promise.<(Object|null)>

(static) fetchPackAll(railcontentId) → {Promise.<(Array.<Object>|null)>}

Description:
  • Fetch all content for a specific pack by Railcontent ID.
Source:
Parameters:
Name Type Description
railcontentId string The Railcontent ID of the pack.
Returns:
- The fetched pack content data or null if not found.
Type
Promise.<(Array.<Object>|null)>

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

Description:
  • Fetch the data needed for the Pack Overview screen.
Source:
Example
fetchPackData(404048)
  .then(challenge => console.log(challenge))
  .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) fetchParentForDownload(id) → {Promise.<(Object|null)>}

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

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

Description:
  • Fetch related lessons for a specific lesson by RailContent ID and type.
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) 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) fetchRelatedTutorials(railContentId, brand) → {Promise.<(Object|null)>}

Description:
  • fetch song tutorials related to a specific tutorial, by genre and difficulty.
Source:
Parameters:
Name Type Description
railContentId number
brand string
Returns:
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, customPostProcessopt, processNeedAccessopt) → {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 Attributes Default Description
query string The GROQ query to execute against the Sanity API.
isList boolean Whether to return an array or a single result.
customPostProcess function <optional>
null custom post process callback
processNeedAccess boolean <optional>
true execute the needs_access 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) 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) 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) 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)>

(inner) buildQueryForFetch(railContentId, brand) → {string}

Description:
  • build query for fetch of parent data
Source:
Parameters:
Name Type Description
railContentId number
brand string
Returns:
Type
string

(async, inner) buildRelatedLessonsQuery(currentContent) → {Promise.<string>}

Description:
  • build query for related lessons by content type
Source:
Parameters:
Name Type Description
currentContent Object
Returns:
Type
Promise.<string>

(async, inner) buildSubQueryForFetch(type, brand, id, difficulty, genres) → {Promise.<string>}

Description:
  • build filters for use in related_lessons query
Source:
Parameters:
Name Type Default Description
type string
brand string
id number
difficulty string
genres string | null null
Returns:
Type
Promise.<string>

(async, inner) fetchParentContentGenres(contentData) → {Promise.<(Object|null)>}

Description:
  • fetch genres of parent content
Source:
Parameters:
Name Type Description
contentData Object
Returns:
Type
Promise.<(Object|null)>

(async, inner) fetchParentData(railContentId, brand) → {Promise.<(Object|null)>}

Description:
  • fetch data of parent content, and combine with some of current content
Source:
Parameters:
Name Type Description
railContentId number
brand string
Returns:
Type
Promise.<(Object|null)>

(async, inner) fetchRelatedLessonsSectionData(currentContent) → {Promise.<(Object|null)>}

Description:
  • fetch related lessons content
Source:
Parameters:
Name Type Description
currentContent Object
Returns:
Type
Promise.<(Object|null)>

(inner) formatForResponse(parentObject, relatedLessonObject) → {Object}

Description:
  • format return Object for use by page
Source:
Parameters:
Name Type Description
parentObject Object
relatedLessonObject Object
Returns:
Type
Object

(inner) formatGenresToString(genres) → {string}

Description:
  • combine data into Object
Source:
Parameters:
Name Type Description
genres Object
Returns:
Type
string

(async, inner) getCurrentContentDataForQuery(currentContent) → {Object}

Description:
  • get data, primarily brand, for use in the related_lessons query
Source:
Parameters:
Name Type Description
currentContent Object
Returns:
Type
Object

(inner) getNextAndPreviousQuarterDates() → {Array.<any>}

Description:
  • returns array of next and previous quarter dates as strings
Source:
Returns:
Type
Array.<any>

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

Source:
Returns:
Type
Array.<number>

(inner) groupCurrentContentData(currentContent) → {Object}

Description:
  • group and return specific data retrieved from parent data
Source:
Parameters:
Name Type Description
currentContent Object
Returns:
Type
Object

(async, inner) handleCustomFetchAll(brand, type, params) → {Promise.<(Object|null)>}

Description:
  • Fetch all content that requires custom handling or a distinct external call
Source:
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)>