musora-content-services 1.0.107 → 1.0.109
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 +4 -0
- package/README.md +0 -0
- package/babel.config.js +0 -0
- package/docs/config.js.html +2 -2
- 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/index.html +2 -2
- package/docs/module-Config.html +2 -2
- package/docs/module-Railcontent-Services.html +2 -2
- package/docs/module-Sanity-Services.html +393 -42
- package/docs/railcontent.js.html +2 -2
- package/docs/sanity.js.html +307 -86
- 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 +1330 -11
- package/src/filterBuilder.js +0 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +4 -0
- package/src/services/config.js +0 -0
- package/src/services/railcontent.js +0 -0
- package/src/services/sanity.js +68 -3
- package/src/services/userContext.js +0 -0
- package/test/localStorageMock.js +0 -0
- package/test/log.js +0 -0
- package/test/sanityQueryService.test.js +15 -0
- package/test/userContext.test.js +0 -0
package/src/filterBuilder.js
CHANGED
|
File without changes
|
package/src/index.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ import {
|
|
|
31
31
|
fetchScheduledReleases,
|
|
32
32
|
fetchArtistLessons,
|
|
33
33
|
fetchGenreLessons,
|
|
34
|
+
fetchShowsData,
|
|
35
|
+
fetchCatalogMetadata,
|
|
34
36
|
} from './services/sanity.js';
|
|
35
37
|
|
|
36
38
|
import {
|
|
@@ -86,6 +88,8 @@ declare module 'musora-content-services' {
|
|
|
86
88
|
fetchScheduledReleases,
|
|
87
89
|
fetchArtistLessons,
|
|
88
90
|
fetchGenreLessons,
|
|
91
|
+
fetchShowsData,
|
|
92
|
+
fetchCatalogMetadata,
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
}
|
package/src/index.js
CHANGED
|
@@ -39,6 +39,8 @@ import {
|
|
|
39
39
|
fetchArtistLessons,
|
|
40
40
|
fetchGenreLessons,
|
|
41
41
|
fetchRelatedMethodLessons,
|
|
42
|
+
fetchShowsData,
|
|
43
|
+
fetchCatalogMetadata,
|
|
42
44
|
} from './services/sanity.js';
|
|
43
45
|
|
|
44
46
|
import {
|
|
@@ -97,4 +99,6 @@ export {
|
|
|
97
99
|
fetchArtistLessons,
|
|
98
100
|
fetchGenreLessons,
|
|
99
101
|
fetchRelatedMethodLessons,
|
|
102
|
+
fetchShowsData,
|
|
103
|
+
fetchCatalogMetadata,
|
|
100
104
|
}
|
package/src/services/config.js
CHANGED
|
File without changes
|
|
File without changes
|
package/src/services/sanity.js
CHANGED
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
filtersToGroq,
|
|
13
13
|
getUpcomingEventsTypes,
|
|
14
14
|
getNewReleasesTypes,
|
|
15
|
+
showsTypes,
|
|
16
|
+
contentMetadata
|
|
15
17
|
} from "../contentTypeConfig";
|
|
16
18
|
import {globalConfig} from "./config";
|
|
17
19
|
|
|
@@ -257,7 +259,7 @@ export async function fetchWorkouts(brand) {
|
|
|
257
259
|
* @param {string} brand - The brand for which to fetch new releases.
|
|
258
260
|
* @returns {Promise<Object|null>} - The fetched new releases data or null if not found.
|
|
259
261
|
*/
|
|
260
|
-
export async function fetchNewReleases(brand, { page = 1, limit =
|
|
262
|
+
export async function fetchNewReleases(brand, { page = 1, limit = 20, sort="-published_on" } = {}) {
|
|
261
263
|
const newTypes = getNewReleasesTypes(brand);
|
|
262
264
|
const typesString = arrayToStringRepresentation(newTypes);
|
|
263
265
|
const start = (page - 1) * limit;
|
|
@@ -510,7 +512,7 @@ export async function fetchAll(brand, type, {
|
|
|
510
512
|
'lessons': *[_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{
|
|
511
513
|
${fieldsString},
|
|
512
514
|
${groupBy}
|
|
513
|
-
}[0...
|
|
515
|
+
}[0...20]
|
|
514
516
|
}
|
|
515
517
|
|order(${sortOrder})
|
|
516
518
|
[${start}...${end}]
|
|
@@ -531,7 +533,7 @@ export async function fetchAll(brand, type, {
|
|
|
531
533
|
'lessons': *[brand == '${brand}' && ^._id in ${groupBy}[]._ref ${typeFilter} ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{
|
|
532
534
|
${fieldsString},
|
|
533
535
|
${groupBy}
|
|
534
|
-
}[0...
|
|
536
|
+
}[0...20]
|
|
535
537
|
}
|
|
536
538
|
|order(${sortOrder})
|
|
537
539
|
[${start}...${end}]
|
|
@@ -1327,6 +1329,48 @@ export async function fetchCatalogMetadata(contentType)
|
|
|
1327
1329
|
return fetchSanity(query, false);
|
|
1328
1330
|
}
|
|
1329
1331
|
|
|
1332
|
+
/**
|
|
1333
|
+
* Fetch shows data for a brand.
|
|
1334
|
+
*
|
|
1335
|
+
* @param brand - The brand for which to fetch shows.
|
|
1336
|
+
* @returns {Promise<[]>}
|
|
1337
|
+
*
|
|
1338
|
+
* @example
|
|
1339
|
+
*
|
|
1340
|
+
* fetchShowsData('drumeo')
|
|
1341
|
+
* .then(data => console.log(data))
|
|
1342
|
+
* .catch(error => console.error(error));
|
|
1343
|
+
*/
|
|
1344
|
+
export async function fetchShowsData(brand) {
|
|
1345
|
+
let shows = showsTypes[brand] ?? [];
|
|
1346
|
+
const showsInfo = [];
|
|
1347
|
+
|
|
1348
|
+
shows.forEach(type => {
|
|
1349
|
+
const processedData = processMetadata(brand, type);
|
|
1350
|
+
if (processedData) showsInfo.push(processedData)
|
|
1351
|
+
});
|
|
1352
|
+
|
|
1353
|
+
return showsInfo;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
/**
|
|
1357
|
+
* Fetch metadata from the contentTypeConfig.js based on brand and type.
|
|
1358
|
+
*
|
|
1359
|
+
* @param {string} brand - The brand for which to fetch metadata.
|
|
1360
|
+
* @param {string} type - The type for which to fetch metadata.
|
|
1361
|
+
* @returns {Promise<{name, description, type: *, thumbnailUrl}>}
|
|
1362
|
+
*
|
|
1363
|
+
* @example
|
|
1364
|
+
*
|
|
1365
|
+
* fetchMetadata('drumeo','song')
|
|
1366
|
+
* .then(data => console.log(data))
|
|
1367
|
+
* .catch(error => console.error(error));
|
|
1368
|
+
*/
|
|
1369
|
+
export async function fetchMetadata(brand, type) {
|
|
1370
|
+
const processedData = processMetadata(brand, type, true);
|
|
1371
|
+
return processedData ? processedData : {};
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1330
1374
|
|
|
1331
1375
|
//Helper Functions
|
|
1332
1376
|
function arrayJoinWithQuotes(array, delimiter = ',') {
|
|
@@ -1421,7 +1465,28 @@ function buildEntityAndTotalQuery(
|
|
|
1421
1465
|
}`;
|
|
1422
1466
|
return query;
|
|
1423
1467
|
}
|
|
1468
|
+
function processMetadata(brand, type, withFilters = false) {
|
|
1469
|
+
const metadataElement = contentMetadata[brand]?.[type];
|
|
1470
|
+
if (!metadataElement) {
|
|
1471
|
+
return null;
|
|
1472
|
+
}
|
|
1473
|
+
const processedData = {
|
|
1474
|
+
type,
|
|
1475
|
+
thumbnailUrl: metadataElement.thumbnailUrl || null,
|
|
1476
|
+
name: metadataElement.name || null,
|
|
1477
|
+
description: metadataElement.description || null
|
|
1478
|
+
};
|
|
1479
|
+
|
|
1480
|
+
if (withFilters) {
|
|
1481
|
+
Object.keys(metadataElement).forEach(key => {
|
|
1482
|
+
if ( !['thumbnailUrl', 'name', 'description'].includes(key) ) {
|
|
1483
|
+
processedData[key] = metadataElement[key];
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1424
1487
|
|
|
1488
|
+
return processedData;
|
|
1489
|
+
}
|
|
1425
1490
|
|
|
1426
1491
|
|
|
1427
1492
|
|
|
File without changes
|
package/test/localStorageMock.js
CHANGED
|
File without changes
|
package/test/log.js
CHANGED
|
File without changes
|
|
@@ -31,6 +31,8 @@ const {
|
|
|
31
31
|
fetchByReference,
|
|
32
32
|
fetchScheduledReleases,
|
|
33
33
|
getSortOrder,
|
|
34
|
+
fetchShowsData,
|
|
35
|
+
fetchMetadata
|
|
34
36
|
} = require('../src/services/sanity.js');
|
|
35
37
|
|
|
36
38
|
const {
|
|
@@ -355,6 +357,19 @@ describe('Sanity Queries', function () {
|
|
|
355
357
|
log(response);
|
|
356
358
|
expect(response.entity[0].web_url_path).toContain('/drumeo/coaches/');
|
|
357
359
|
});
|
|
360
|
+
|
|
361
|
+
test('fetchShowsData', async () => {
|
|
362
|
+
const response = await fetchShowsData('singeo');
|
|
363
|
+
log(response);
|
|
364
|
+
expect(response.length).toBeGreaterThan(0);
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
test('fetchMetadata', async () => {
|
|
368
|
+
const response = await fetchMetadata('drumeo','song');
|
|
369
|
+
log(response);
|
|
370
|
+
expect(response.tabs.length).toBeGreaterThan(0);
|
|
371
|
+
});
|
|
372
|
+
|
|
358
373
|
});
|
|
359
374
|
|
|
360
375
|
describe('Filter Builder', function () {
|
package/test/userContext.test.js
CHANGED
|
File without changes
|