musora-content-services 1.0.107 → 1.0.108

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.
Files changed (55) hide show
  1. package/.github/workflows/node.js.yml +0 -0
  2. package/CHANGELOG.md +2 -0
  3. package/README.md +0 -0
  4. package/babel.config.js +0 -0
  5. package/docs/config.js.html +2 -2
  6. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  7. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  8. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  9. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  10. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  11. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  12. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  13. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  14. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  15. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -0
  16. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  17. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  18. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  19. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  20. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -0
  21. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  22. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  23. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  24. package/docs/index.html +2 -2
  25. package/docs/module-Config.html +2 -2
  26. package/docs/module-Railcontent-Services.html +2 -2
  27. package/docs/module-Sanity-Services.html +393 -42
  28. package/docs/railcontent.js.html +2 -2
  29. package/docs/sanity.js.html +307 -86
  30. package/docs/scripts/collapse.js +0 -0
  31. package/docs/scripts/commonNav.js +0 -0
  32. package/docs/scripts/linenumber.js +0 -0
  33. package/docs/scripts/nav.js +0 -0
  34. package/docs/scripts/polyfill.js +0 -0
  35. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -0
  36. package/docs/scripts/prettify/lang-css.js +0 -0
  37. package/docs/scripts/prettify/prettify.js +0 -0
  38. package/docs/scripts/search.js +0 -0
  39. package/docs/styles/jsdoc.css +0 -0
  40. package/docs/styles/prettify.css +0 -0
  41. package/jest.config.js +0 -0
  42. package/jsdoc.json +0 -0
  43. package/package.json +1 -1
  44. package/src/contentTypeConfig.js +1330 -11
  45. package/src/filterBuilder.js +0 -0
  46. package/src/index.d.ts +0 -0
  47. package/src/index.js +0 -0
  48. package/src/services/config.js +0 -0
  49. package/src/services/railcontent.js +0 -0
  50. package/src/services/sanity.js +68 -3
  51. package/src/services/userContext.js +0 -0
  52. package/test/localStorageMock.js +0 -0
  53. package/test/log.js +0 -0
  54. package/test/sanityQueryService.test.js +15 -0
  55. package/test/userContext.test.js +0 -0
File without changes
package/src/index.d.ts CHANGED
File without changes
package/src/index.js CHANGED
File without changes
File without changes
File without changes
@@ -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 = 10, sort="-published_on" } = {}) {
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...10]
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...10]
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
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 () {
File without changes