musora-content-services 1.0.42 → 1.0.43

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 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.43](https://github.com/railroadmedia/musora-content-services/compare/v1.0.42...v1.0.43) (2024-08-20)
6
+
5
7
  ### [1.0.42](https://github.com/railroadmedia/musora-content-services/compare/v1.0.41...v1.0.42) (2024-08-20)
6
8
 
7
9
  ### [1.0.41](https://github.com/railroadmedia/musora-content-services/compare/v1.0.40...v1.0.41) (2024-08-20)
package/README.md CHANGED
@@ -55,6 +55,7 @@ https://railroadmedia.github.io/musora-content-services/
55
55
  ## Run tests
56
56
  Copy .env file from 1Password "musora-content-services .env"
57
57
  Run the following to execute the tests
58
+ You may need to install jest (npm install --save-dev jest)
58
59
  ```
59
60
  npm test
60
61
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.42",
3
+ "version": "1.0.43",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -28,9 +28,14 @@ let contentTypeConfig = {
28
28
  '"instructors": instructor[]->name'
29
29
  ]
30
30
  },
31
+ 'student-focus': {
32
+ 'fields': [
33
+ '"instructors": instructor[]->name',
34
+ ]
35
+ },
31
36
  }
32
37
 
33
38
 
34
39
  module.exports = {
35
40
  contentTypeConfig
36
- }
41
+ }
@@ -561,27 +561,29 @@ export async function fetchAllFilterOptions(
561
561
  contentType,
562
562
  term
563
563
  ) {
564
- const query = `
565
- {
566
- "meta": {
567
- "totalResults": count(*[_type == '${contentType}' && brand == "${brand}"${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''}${filters}
568
- ${term ? ` && (title match "${term}" || album match "${term}" || artist->name match "${term}" || genre[]->name match "${term}")` : ''}]),
569
- "filterOptions": {
570
- "difficulty": [
571
- {"type": "Introductory", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Introductory"${filters}])},
572
- {"type": "Beginner", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Beginner"${filters}])},
573
- {"type": "Intermediate", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Intermediate"${filters}])},
574
- {"type": "Advanced", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Advanced"${filters}])},
575
- {"type": "Expert", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && difficulty_string == "Expert"${filters}])}
576
- ][count > 0],
577
- "instrumentless": [
578
- {"type": "Full Song Only", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && instrumentless == false${filters}])},
579
- {"type": "Instrument Removed", "count": count(*[_type == '${contentType}' && brand == '${brand}'${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && instrumentless == true${filters}])}
580
- ][count > 0],
581
- "genre": *[_type == 'genre' && '${contentType}' in filter_types] {
582
- "type": name,
583
- "count": count(*[_type == '${contentType}' && brand == "${brand}"${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} && references(^._id)])
584
- }[count > 0]
564
+ const commonFilter = `_type == '${contentType}' && brand == "${brand}"${style ? ` && '${style}' in genre[]->name` : ''}${artist ? ` && artist->name == '${artist}'` : ''} ${filters ? filters : ''}`;
565
+ const query = `
566
+ {
567
+ "meta": {
568
+ "totalResults": count(*[${commonFilter}
569
+ ${term ? ` && (title match "${term}" || album match "${term}" || artist->name match "${term}" || genre[]->name match "${term}")` : ''}]),
570
+ "filterOptions": {
571
+ "difficulty": [
572
+ {"type": "Introductory", "count": count(*[${commonFilter} && difficulty_string == "Introductory"])},
573
+ {"type": "Beginner", "count": count(*[${commonFilter} && difficulty_string == "Beginner"])},
574
+ {"type": "Intermediate", "count": count(*[${commonFilter} && difficulty_string == "Intermediate" ])},
575
+ {"type": "Advanced", "count": count(*[${commonFilter} && difficulty_string == "Advanced" ])},
576
+ {"type": "Expert", "count": count(*[${commonFilter} && difficulty_string == "Expert" ])}
577
+ ][count > 0],
578
+ "instrumentless": [
579
+ {"type": "Full Song Only", "count": count(*[${commonFilter} && instrumentless == false ])},
580
+ {"type": "Instrument Removed", "count": count(*[${commonFilter} && instrumentless == true ])}
581
+ ][count > 0],
582
+ "genre": *[_type == 'genre' && '${contentType}' in filter_types] {
583
+ "type": name,
584
+ "count": count(*[${commonFilter} && references(^._id)])
585
+ }[count > 0]
586
+ }
585
587
  }
586
588
  }
587
589
  }`;
@@ -815,10 +817,10 @@ export async function fetchSanity(query, isList) {
815
817
  if (globalConfig.sanityConfig.debug) {
816
818
  console.log("fetchSanity Query:", query);
817
819
  }
818
-
820
+ const perspective = globalConfig.sanityConfig.perspective ?? 'published';
819
821
  const encodedQuery = encodeURIComponent(query);
820
822
  const api = globalConfig.sanityConfig.useCachedAPI ? 'apicdn' : 'api';
821
- const url = `https://${globalConfig.sanityConfig.projectId}.${api}.sanity.io/v${globalConfig.sanityConfig.version}/data/query/${globalConfig.sanityConfig.dataset}?query=${encodedQuery}`;
823
+ const url = `https://${globalConfig.sanityConfig.projectId}.${api}.sanity.io/v${globalConfig.sanityConfig.version}/data/query/${globalConfig.sanityConfig.dataset}?perspective=${perspective}&query=${encodedQuery}`;
822
824
  const headers = {
823
825
  'Authorization': `Bearer ${globalConfig.sanityConfig.token}`,
824
826
  'Content-Type': 'application/json'