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 +2 -0
- package/README.md +1 -0
- package/package.json +1 -1
- package/src/contentTypeConfig.js +6 -1
- package/src/services/sanity.js +25 -23
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
package/src/contentTypeConfig.js
CHANGED
package/src/services/sanity.js
CHANGED
|
@@ -561,27 +561,29 @@ export async function fetchAllFilterOptions(
|
|
|
561
561
|
contentType,
|
|
562
562
|
term
|
|
563
563
|
) {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
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'
|