musora-content-services 1.0.180 → 1.0.182
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 +4 -0
- package/README.md +0 -0
- package/jest.config.js +0 -0
- package/package.json +1 -1
- package/src/contentTypeConfig.js +1 -1
- package/src/services/config.js +0 -0
- package/src/services/contentLikes.js +0 -0
- package/src/services/dataContext.js +9 -0
- package/src/services/lastUpdated.js +0 -0
- package/src/services/sanity.js +8 -5
- package/src/services/userPermissions.js +0 -0
- package/test/contentLikes.test.js +0 -0
- package/test/initializeTests.js +0 -0
- package/test/lastUpdated.test.js +0 -0
- package/test/localStorageMock.js +0 -0
- package/test/log.js +0 -0
- package/test/sanityQueryService.test.js +5 -5
- package/test/userPermissions.test.js +0 -0
- package/tools/generate-index.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
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.182](https://github.com/railroadmedia/musora-content-services/compare/v1.0.181...v1.0.182) (2024-11-25)
|
|
6
|
+
|
|
7
|
+
### [1.0.181](https://github.com/railroadmedia/musora-content-services/compare/v1.0.180...v1.0.181) (2024-11-25)
|
|
8
|
+
|
|
5
9
|
### [1.0.180](https://github.com/railroadmedia/musora-content-services/compare/v1.0.179...v1.0.180) (2024-11-23)
|
|
6
10
|
|
|
7
11
|
### [1.0.179](https://github.com/railroadmedia/musora-content-services/compare/v1.0.178...v1.0.179) (2024-11-19)
|
package/README.md
CHANGED
|
File without changes
|
package/jest.config.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
package/src/contentTypeConfig.js
CHANGED
|
@@ -347,7 +347,7 @@ let contentTypeConfig = {
|
|
|
347
347
|
'"focus": focus[]->name',
|
|
348
348
|
'focus_text',
|
|
349
349
|
'forum_thread_id',
|
|
350
|
-
'"long_bio": long_bio[0].children[0].text
|
|
350
|
+
'"long_bio": long_bio[0].children[0].text',
|
|
351
351
|
'name',
|
|
352
352
|
'"short_bio" : short_bio[0].children[0].text',
|
|
353
353
|
'bands',
|
package/src/services/config.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -15,6 +15,7 @@ let cache = null;
|
|
|
15
15
|
|
|
16
16
|
export class DataContext {
|
|
17
17
|
context = null;
|
|
18
|
+
dataPromise = null;
|
|
18
19
|
|
|
19
20
|
constructor(dataVersionKey, fetchDataFunction) {
|
|
20
21
|
this.dataVersionKey = dataVersionKey;
|
|
@@ -24,6 +25,13 @@ export class DataContext {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
async getData() {
|
|
28
|
+
if (!this.dataPromise) {
|
|
29
|
+
this.dataPromise = this.getDataPromise();
|
|
30
|
+
}
|
|
31
|
+
return this.dataPromise;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async getDataPromise() {
|
|
27
35
|
await this.ensureLocalContextLoaded();
|
|
28
36
|
const shouldVerify = await this.shouldVerifyServerVerions();
|
|
29
37
|
|
|
@@ -36,6 +44,7 @@ export class DataContext {
|
|
|
36
44
|
}
|
|
37
45
|
cache.setItem(this.localStorageLastUpdatedKey, new Date().getTime()?.toString());
|
|
38
46
|
}
|
|
47
|
+
this.dataPromise = null;
|
|
39
48
|
return this.context.data;
|
|
40
49
|
}
|
|
41
50
|
|
|
File without changes
|
package/src/services/sanity.js
CHANGED
|
@@ -510,7 +510,7 @@ export async function fetchAll(brand, type, {
|
|
|
510
510
|
let webUrlPathType = config?.slug ?? type;
|
|
511
511
|
const start = (page - 1) * limit;
|
|
512
512
|
const end = start + limit;
|
|
513
|
-
let bypassStatusAndPublishedValidation = (type == 'instructor');
|
|
513
|
+
let bypassStatusAndPublishedValidation = (type == 'instructor' || groupBy == 'artist' || groupBy == 'genre' || groupBy == 'instructor');
|
|
514
514
|
|
|
515
515
|
// Construct the type filter
|
|
516
516
|
const typeFilter = type ? `&& _type == '${type}'` : "";
|
|
@@ -543,14 +543,15 @@ export async function fetchAll(brand, type, {
|
|
|
543
543
|
if (groupBy !== "" && isGroupByOneToOne) {
|
|
544
544
|
const webUrlPath = 'artists';
|
|
545
545
|
const lessonsFilter = `_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ${searchFilter} ${includedFieldsFilter} ${progressFilter}`;
|
|
546
|
+
const lessonsFilterWithRestrictions = await new FilterBuilder(lessonsFilter).buildFilter();
|
|
546
547
|
entityFieldsString = `
|
|
547
548
|
'id': railcontent_id,
|
|
548
549
|
'type': _type,
|
|
549
550
|
name,
|
|
550
551
|
'head_shot_picture_url': thumbnail_url.asset->url,
|
|
551
552
|
'web_url_path': '/${brand}/${webUrlPath}/'+name+'?included_fieds[]=type,${type}',
|
|
552
|
-
'all_lessons_count': count(*[${
|
|
553
|
-
'lessons': *[${
|
|
553
|
+
'all_lessons_count': count(*[${lessonsFilterWithRestrictions}]._id),
|
|
554
|
+
'lessons': *[${lessonsFilterWithRestrictions}]{
|
|
554
555
|
${fieldsString},
|
|
555
556
|
${groupBy}
|
|
556
557
|
}[0...20]
|
|
@@ -559,14 +560,16 @@ export async function fetchAll(brand, type, {
|
|
|
559
560
|
} else if (groupBy !== "") {
|
|
560
561
|
const webUrlPath = (groupBy == 'genre') ? '/genres' : '';
|
|
561
562
|
const lessonsFilter = `brand == '${brand}' && ^._id in ${groupBy}[]._ref ${typeFilter} ${searchFilter} ${includedFieldsFilter} ${progressFilter}`;
|
|
563
|
+
const lessonsFilterWithRestrictions = await new FilterBuilder(lessonsFilter).buildFilter();
|
|
564
|
+
|
|
562
565
|
entityFieldsString = `
|
|
563
566
|
'id': railcontent_id,
|
|
564
567
|
'type': _type,
|
|
565
568
|
name,
|
|
566
569
|
'head_shot_picture_url': thumbnail_url.asset->url,
|
|
567
570
|
'web_url_path': select(defined(web_url_path)=> web_url_path +'?included_fieds[]=type,${type}',!defined(web_url_path)=> '/${brand}${webUrlPath}/'+name+'/${webUrlPathType}'),
|
|
568
|
-
'all_lessons_count': count(*[${
|
|
569
|
-
'lessons': *[${
|
|
571
|
+
'all_lessons_count': count(*[${lessonsFilterWithRestrictions}]._id),
|
|
572
|
+
'lessons': *[${lessonsFilterWithRestrictions}]{
|
|
570
573
|
${fieldsString},
|
|
571
574
|
${groupBy}
|
|
572
575
|
}[0...20]`;
|
|
File without changes
|
|
File without changes
|
package/test/initializeTests.js
CHANGED
|
File without changes
|
package/test/lastUpdated.test.js
CHANGED
|
File without changes
|
package/test/localStorageMock.js
CHANGED
|
File without changes
|
package/test/log.js
CHANGED
|
File without changes
|
|
@@ -66,7 +66,7 @@ describe('Sanity Queries', function () {
|
|
|
66
66
|
test('fetchArtists', async () => {
|
|
67
67
|
const response = await fetchArtists('drumeo');
|
|
68
68
|
const artistNames = response.map((x) => x.name);
|
|
69
|
-
expect(artistNames).toContain("
|
|
69
|
+
expect(artistNames).toContain("Audioslave");
|
|
70
70
|
|
|
71
71
|
}, 10000);
|
|
72
72
|
|
|
@@ -161,11 +161,11 @@ describe('Sanity Queries', function () {
|
|
|
161
161
|
|
|
162
162
|
test('fetchAllSongsInProgress', async () => {
|
|
163
163
|
var mock = jest.spyOn(dataContext, 'fetchData');
|
|
164
|
-
var json = JSON.parse(`{"version":1,"config":{"key":1,"enabled":1,"checkInterval":1,"refreshInterval":2},"data":{"
|
|
164
|
+
var json = JSON.parse(`{"version":1,"config":{"key":1,"enabled":1,"checkInterval":1,"refreshInterval":2},"data":{"412941":{"s":"started","p":6,"t":20,"u":1731108082}}}`);
|
|
165
165
|
mock.mockImplementation(() =>
|
|
166
166
|
json);
|
|
167
167
|
const response = await fetchAll('drumeo', 'song',{progress:"in progress"});
|
|
168
|
-
expect(response.entity[0].id).toBe(
|
|
168
|
+
expect(response.entity[0].id).toBe(412941);
|
|
169
169
|
expect(response.entity.length).toBe(1);
|
|
170
170
|
});
|
|
171
171
|
|
|
@@ -361,13 +361,13 @@ describe('Sanity Queries', function () {
|
|
|
361
361
|
});
|
|
362
362
|
|
|
363
363
|
test('fetchAll-WithProgress', async () => {
|
|
364
|
-
const ids = [410213,
|
|
364
|
+
const ids = [410213, 410215];
|
|
365
365
|
let response = await fetchAll('drumeo', 'song', {
|
|
366
366
|
sort: 'slug',
|
|
367
367
|
progressIds: ids,
|
|
368
368
|
});
|
|
369
369
|
expect(response.entity.length).toBe(2);
|
|
370
|
-
expect(response.entity[0].id =
|
|
370
|
+
expect(response.entity[0].id = 410215);
|
|
371
371
|
expect(response.entity[1].id = 410213);
|
|
372
372
|
// change the type and we expect no results
|
|
373
373
|
response = await fetchAll('drumeo', 'quick-tip', {
|
|
File without changes
|
package/tools/generate-index.js
CHANGED
|
File without changes
|