musora-content-services 1.0.82 → 1.0.83
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/.github/workflows/node.js.yml +0 -0
- package/CHANGELOG.md +2 -0
- package/README.md +0 -0
- package/babel.config.js +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/scripts/collapse.js +0 -0
- package/docs/scripts/commonNav.js +0 -0
- package/docs/scripts/linenumber.js +0 -0
- package/docs/scripts/nav.js +0 -0
- package/docs/scripts/polyfill.js +0 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -0
- package/docs/scripts/prettify/lang-css.js +0 -0
- package/docs/scripts/prettify/prettify.js +0 -0
- package/docs/scripts/search.js +0 -0
- package/docs/styles/jsdoc.css +0 -0
- package/docs/styles/prettify.css +0 -0
- package/jest.config.js +0 -0
- package/jsdoc.json +0 -0
- package/package.json +1 -1
- package/src/contentTypeConfig.js +13 -11
- package/src/index.js +2 -0
- package/src/services/config.js +0 -0
- package/src/services/sanity.js +31 -0
- package/test/sanityQueryService.test.js +8 -2
|
File without changes
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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.83](https://github.com/railroadmedia/musora-content-services/compare/v1.0.82...v1.0.83) (2024-09-06)
|
|
6
|
+
|
|
5
7
|
### [1.0.82](https://github.com/railroadmedia/musora-content-services/compare/v1.0.81...v1.0.82) (2024-09-06)
|
|
6
8
|
|
|
7
9
|
### [1.0.81](https://github.com/railroadmedia/musora-content-services/compare/v1.0.80...v1.0.81) (2024-09-05)
|
package/README.md
CHANGED
|
File without changes
|
package/babel.config.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/scripts/collapse.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/scripts/nav.js
CHANGED
|
File without changes
|
package/docs/scripts/polyfill.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/scripts/search.js
CHANGED
|
File without changes
|
package/docs/styles/jsdoc.css
CHANGED
|
File without changes
|
package/docs/styles/prettify.css
CHANGED
|
File without changes
|
package/jest.config.js
CHANGED
|
File without changes
|
package/jsdoc.json
CHANGED
|
File without changes
|
package/package.json
CHANGED
package/src/contentTypeConfig.js
CHANGED
|
@@ -225,17 +225,19 @@ function getFieldsForContentType(contentType, asQueryString=true) {
|
|
|
225
225
|
function filtersToGroq(filters) {
|
|
226
226
|
const groq = filters.map(field => {
|
|
227
227
|
let [key, value] = field.split(',');
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
228
|
+
if(key && value){
|
|
229
|
+
switch (key) {
|
|
230
|
+
case 'difficulty':
|
|
231
|
+
return `&& difficulty_string == "${value}"`;
|
|
232
|
+
case 'genre':
|
|
233
|
+
return `&& genre[]->name match "${value}"`;
|
|
234
|
+
case 'topic':
|
|
235
|
+
return `&& topic[]->name match "${value}"`;
|
|
236
|
+
case 'instrumentless':
|
|
237
|
+
return `&& instrumentless == ${value}`;
|
|
238
|
+
default:
|
|
239
|
+
return `&& ${key} == ${/^\d+$/.test(value) ? value : `"$${value}"`}`;
|
|
240
|
+
}
|
|
239
241
|
}
|
|
240
242
|
}).join(' ');
|
|
241
243
|
return groq;
|
package/src/index.js
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
fetchMethodPreviousNextLesson,
|
|
33
33
|
fetchLiveEvent,
|
|
34
34
|
fetchChallengeOverview,
|
|
35
|
+
fetchCoachLessons,
|
|
35
36
|
} from './services/sanity.js';
|
|
36
37
|
|
|
37
38
|
import {
|
|
@@ -81,4 +82,5 @@ export {
|
|
|
81
82
|
fetchChallengeOverview,
|
|
82
83
|
fetchVimeoData,
|
|
83
84
|
fetchContentPageUserData,
|
|
85
|
+
fetchCoachLessons,
|
|
84
86
|
}
|
package/src/services/config.js
CHANGED
|
File without changes
|
package/src/services/sanity.js
CHANGED
|
@@ -948,6 +948,37 @@ export async function fetchChallengeOverview(id) {
|
|
|
948
948
|
return fetchSanity(query, false);
|
|
949
949
|
}
|
|
950
950
|
|
|
951
|
+
/**
|
|
952
|
+
* Fetch the data needed for the coach screen.
|
|
953
|
+
* @param {string} id - The Railcontent ID of the coach
|
|
954
|
+
* @returns {Promise<Object|null>} - The lessons for the instructor or null if not found.
|
|
955
|
+
*
|
|
956
|
+
* @example
|
|
957
|
+
* fetchCoachLessons('coach123')
|
|
958
|
+
* .then(lessons => console.log(lessons))
|
|
959
|
+
* .catch(error => console.error(error));
|
|
960
|
+
*/
|
|
961
|
+
export async function fetchCoachLessons(brand, id, {
|
|
962
|
+
sortOrder = '-published_on',
|
|
963
|
+
searchTerm = '',
|
|
964
|
+
page = 1,
|
|
965
|
+
limit = 20,
|
|
966
|
+
} = {}) {
|
|
967
|
+
const fieldsString = DEFAULT_FIELDS.join(',');
|
|
968
|
+
const start = (page - 1) * limit;
|
|
969
|
+
const end = start + limit;
|
|
970
|
+
const searchFilter = searchTerm ? `&& title match "${searchTerm}*"`: ''
|
|
971
|
+
|
|
972
|
+
const query = `{
|
|
973
|
+
"entity": *[brand == '${brand}' ${searchFilter} && references(*[_type=='instructor' && railcontent_id == ${id}]._id)] | order(${sortOrder}) [${start}...${end}]
|
|
974
|
+
{
|
|
975
|
+
${fieldsString}
|
|
976
|
+
},
|
|
977
|
+
"total": count(*[brand == '${brand}' && references(*[_type=='instructor' && railcontent_id == ${id}]._id)])
|
|
978
|
+
}`;
|
|
979
|
+
return fetchSanity(query, true);
|
|
980
|
+
}
|
|
981
|
+
|
|
951
982
|
/**
|
|
952
983
|
* Fetch the data needed for the Course Overview screen.
|
|
953
984
|
* @param {string} id - The Railcontent ID of the course
|
|
@@ -28,6 +28,7 @@ const {
|
|
|
28
28
|
fetchMethod,
|
|
29
29
|
fetchMethods,
|
|
30
30
|
fetchFoundation,
|
|
31
|
+
fetchCoachLessons,
|
|
31
32
|
} = require('../src/services/sanity.js');
|
|
32
33
|
|
|
33
34
|
describe('Sanity Queries', function () {
|
|
@@ -212,7 +213,7 @@ describe('Sanity Queries', function () {
|
|
|
212
213
|
|
|
213
214
|
test('fetchMethods', async () => {
|
|
214
215
|
const response = await fetchMethods('drumeo');
|
|
215
|
-
|
|
216
|
+
console.log(response);
|
|
216
217
|
expect(response.length).toBeGreaterThan(0);
|
|
217
218
|
expect(response[0].type).toBe('learning-path');
|
|
218
219
|
});
|
|
@@ -246,8 +247,13 @@ describe('Sanity Queries', function () {
|
|
|
246
247
|
|
|
247
248
|
test('fetchFoundation', async () => {
|
|
248
249
|
const response = await fetchFoundation('foundations-2019');
|
|
249
|
-
|
|
250
|
+
console.log(response);
|
|
250
251
|
expect(response.units.length).toBeGreaterThan(0);
|
|
251
252
|
expect(response.type).toBe('foundation');
|
|
252
253
|
});
|
|
254
|
+
|
|
255
|
+
test('fetchCoachLessons', async () => {
|
|
256
|
+
const response = await fetchCoachLessons('drumeo',233797);
|
|
257
|
+
expect(response.entity.length).toBeGreaterThan(0);
|
|
258
|
+
});
|
|
253
259
|
});
|