musora-content-services 1.0.87 → 1.0.89
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 +4 -0
- package/package.json +1 -1
- package/src/services/config.js +4 -1
- package/src/services/railcontent.js +15 -6
- package/src/services/sanity.js +24 -14
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
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
|
+
### [1.0.89](https://github.com/railroadmedia/musora-content-services/compare/v1.0.88...v1.0.89) (2024-09-11)
|
|
6
|
+
|
|
7
|
+
### [1.0.88](https://github.com/railroadmedia/musora-content-services/compare/v1.0.87...v1.0.88) (2024-09-11)
|
|
8
|
+
|
|
5
9
|
### [1.0.87](https://github.com/railroadmedia/musora-content-services/compare/v1.0.86...v1.0.87) (2024-09-09)
|
|
6
10
|
|
|
7
11
|
### [1.0.86](https://github.com/railroadmedia/musora-content-services/compare/v1.0.85...v1.0.86) (2024-09-09)
|
package/package.json
CHANGED
package/src/services/config.js
CHANGED
|
@@ -22,6 +22,8 @@ let globalConfig = {
|
|
|
22
22
|
* @param {Object} config.railcontentConfig - Configuration for user services.
|
|
23
23
|
* @param {string} config.railcontentConfig.token - The token for authenticating user-specific requests.
|
|
24
24
|
* @param {string} config.railcontentConfig.userId - The user ID for fetching user-specific data.
|
|
25
|
+
* @param {string} config.railcontentConfig.baseUrl - The url for the enviroment.
|
|
26
|
+
|
|
25
27
|
*
|
|
26
28
|
* @example
|
|
27
29
|
* // Initialize the service in your app.js
|
|
@@ -36,7 +38,8 @@ let globalConfig = {
|
|
|
36
38
|
* },
|
|
37
39
|
* railcontentConfig: {
|
|
38
40
|
* token: 'your-user-api-token',
|
|
39
|
-
* userId: 'current-user-id'
|
|
41
|
+
* userId: 'current-user-id',
|
|
42
|
+
* baseUrl: 'https://web-staging-one.musora.com'
|
|
40
43
|
* }
|
|
41
44
|
* });
|
|
42
45
|
*/
|
|
@@ -24,7 +24,7 @@ export async function fetchCompletedState(content_id) {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
try {
|
|
27
|
-
const response = await
|
|
27
|
+
const response = await fetchAbsolute(url, { headers });
|
|
28
28
|
const result = await response.json();
|
|
29
29
|
|
|
30
30
|
if (result && result[content_id]) { return result[content_id]; // Return the correct object
|
|
@@ -56,7 +56,7 @@ export async function fetchVimeoData(vimeo_id) {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
try {
|
|
59
|
-
const response = await
|
|
59
|
+
const response = await fetchAbsolute(url, { headers });
|
|
60
60
|
const result = await response.json();
|
|
61
61
|
|
|
62
62
|
if (result) {
|
|
@@ -91,7 +91,7 @@ export async function fetchAllCompletedStates(contentIds) {
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
try {
|
|
94
|
-
const response = await
|
|
94
|
+
const response = await fetchAbsolute(url, { headers });
|
|
95
95
|
const result = await response.json();
|
|
96
96
|
if(result){
|
|
97
97
|
return result;
|
|
@@ -123,7 +123,7 @@ export async function fetchSongsInProgress(brand) {
|
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
try {
|
|
126
|
-
const response = await
|
|
126
|
+
const response = await fetchAbsolute(url, { headers });
|
|
127
127
|
const result = await response.json();
|
|
128
128
|
if(result){
|
|
129
129
|
console.log('fetchSongsInProgress', result);
|
|
@@ -160,7 +160,7 @@ export async function fetchContentInProgress(type="all", brand) {
|
|
|
160
160
|
'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
|
|
161
161
|
};
|
|
162
162
|
try {
|
|
163
|
-
const response = await
|
|
163
|
+
const response = await fetchAbsolute(url, { headers });
|
|
164
164
|
const result = await response.json();
|
|
165
165
|
if(result){
|
|
166
166
|
console.log('contentInProgress', result);
|
|
@@ -191,8 +191,9 @@ export async function fetchContentPageUserData(contentId) {
|
|
|
191
191
|
'Content-Type': 'application/json',
|
|
192
192
|
'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
|
|
193
193
|
};
|
|
194
|
+
|
|
194
195
|
try {
|
|
195
|
-
const response = await
|
|
196
|
+
const response = await fetchAbsolute(url, { headers });
|
|
196
197
|
const result = await response.json();
|
|
197
198
|
if(result){
|
|
198
199
|
console.log('fetchContentPageUserData', result);
|
|
@@ -204,4 +205,12 @@ export async function fetchContentPageUserData(contentId) {
|
|
|
204
205
|
console.error('Fetch error:', error);
|
|
205
206
|
return null;
|
|
206
207
|
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function fetchAbsolute(url, params) {
|
|
211
|
+
if (url.startsWith('/')) {
|
|
212
|
+
return fetch(globalConfig.railcontentConfig.baseUrl + url, params)
|
|
213
|
+
} else {
|
|
214
|
+
return fetch(url, params);
|
|
215
|
+
}
|
|
207
216
|
}
|
package/src/services/sanity.js
CHANGED
|
@@ -224,7 +224,7 @@ export async function fetchSongFilterOptions(brand) {
|
|
|
224
224
|
*/
|
|
225
225
|
export async function fetchSongCount(brand) {
|
|
226
226
|
const query = `count(*[_type == 'song' && brand == "${brand}"])`;
|
|
227
|
-
return fetchSanity(query,
|
|
227
|
+
return fetchSanity(query, true);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
/**
|
|
@@ -672,6 +672,7 @@ export async function fetchMethodChildren(railcontentId) {
|
|
|
672
672
|
"description": ${descriptionField},
|
|
673
673
|
title,
|
|
674
674
|
xp,
|
|
675
|
+
total_xp,
|
|
675
676
|
'children': child[]->{
|
|
676
677
|
${getFieldsForContentType('method')}
|
|
677
678
|
},
|
|
@@ -812,7 +813,9 @@ export async function fetchLessonContent(railContentId) {
|
|
|
812
813
|
"instructors":instructor[]->name,
|
|
813
814
|
instructor[]->,
|
|
814
815
|
${assignmentsField}
|
|
815
|
-
|
|
816
|
+
video,
|
|
817
|
+
length_in_seconds
|
|
818
|
+
}`
|
|
816
819
|
return fetchSanity(query, false);
|
|
817
820
|
}
|
|
818
821
|
|
|
@@ -838,6 +841,22 @@ export async function fetchRelatedLessons(railContentId, brand) {
|
|
|
838
841
|
return fetchSanity(query, false);
|
|
839
842
|
}
|
|
840
843
|
|
|
844
|
+
/**
|
|
845
|
+
* Fetch all packs.
|
|
846
|
+
* @param {string} brand - The brand for which to fetch packs.
|
|
847
|
+
* @param {string} [searchTerm=""] - The search term to filter packs.
|
|
848
|
+
* @param {string} [sort="-published_on"] - The field to sort the packs by.
|
|
849
|
+
* @returns {Promise<Array<Object>|null>} - The fetched pack content data or null if not found.
|
|
850
|
+
*/
|
|
851
|
+
export async function fetchAllPacks(brand, sort = "-published_on", searchTerm = "") {
|
|
852
|
+
const sortOrder = getSortOrder(sort);
|
|
853
|
+
|
|
854
|
+
const query = `*[_type == 'pack' && brand == '${brand}' && title match "${searchTerm}*"]{
|
|
855
|
+
${getFieldsForContentType('pack')}
|
|
856
|
+
} | order(${sortOrder})`
|
|
857
|
+
return fetchSanity(query, true);
|
|
858
|
+
}
|
|
859
|
+
|
|
841
860
|
/**
|
|
842
861
|
* Fetch all content for a specific pack by Railcontent ID.
|
|
843
862
|
* @param {string} railcontentId - The Railcontent ID of the pack.
|
|
@@ -846,18 +865,9 @@ export async function fetchRelatedLessons(railContentId, brand) {
|
|
|
846
865
|
export async function fetchPackAll(railcontentId) {
|
|
847
866
|
//TODO: Implement getPacks
|
|
848
867
|
const query = `*[railcontent_id == ${railcontentId}]{
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
"image": thumbnail.asset->url,
|
|
853
|
-
"artist_name": artist->name,
|
|
854
|
-
artist,
|
|
855
|
-
difficulty,
|
|
856
|
-
difficulty_string,
|
|
857
|
-
web_url_path,
|
|
858
|
-
published_on
|
|
859
|
-
} | order(published_on asc)[0...5]`
|
|
860
|
-
return fetchSanity(query, true);
|
|
868
|
+
${getFieldsForContentType('pack')}
|
|
869
|
+
} | order(published_on asc)[0...1]`
|
|
870
|
+
return fetchSanity(query, false);
|
|
861
871
|
}
|
|
862
872
|
|
|
863
873
|
export async function fetchLiveEvent(brand) {
|