musora-content-services 2.7.0 → 2.7.2
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/.coderabbit.yaml +0 -0
- package/.editorconfig +0 -0
- package/.github/pull_request_template.md +0 -0
- package/.github/workflows/node.js.yml +0 -0
- package/.prettierignore +0 -0
- package/.prettierrc +0 -0
- package/.yarnrc.yml +1 -0
- package/CHANGELOG.md +4 -0
- package/README.md +0 -0
- package/babel.config.cjs +0 -0
- package/docs/Content-Organization.html +0 -0
- package/docs/ContentOrganization.html +2 -2
- package/docs/Gamification.html +2 -2
- package/docs/UserManagement.html +0 -0
- package/docs/UserManagementSystem.html +2 -2
- package/docs/api_types.js.html +2 -2
- package/docs/config.js.html +2 -2
- package/docs/content-org_content-org.js.html +2 -2
- package/docs/content-org_playlists-types.js.html +3 -5
- package/docs/content-org_playlists.js.html +23 -9
- package/docs/content.js.html +9 -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/gamification_awards.js.html +2 -2
- package/docs/gamification_gamification.js.html +2 -2
- package/docs/gamification_types.js.html +2 -2
- package/docs/global.html +5 -53
- package/docs/global.html#User +0 -0
- package/docs/index.html +2 -2
- package/docs/module-Awards.html +2 -2
- package/docs/module-Config.html +2 -2
- package/docs/module-Content-Services-V2.html +8 -8
- package/docs/module-Content-Services.html +763 -0
- package/docs/module-Interests.html +2 -2
- package/docs/module-Permissions.html +2 -2
- package/docs/module-Playlists.html +21 -20
- package/docs/module-Railcontent-Services.html +2 -2
- package/docs/module-Sanity-Services.html +30 -30
- package/docs/module-Session-Management.html +0 -0
- package/docs/module-Sessions.html +2 -2
- package/docs/module-User-Activity.html +737 -58
- package/docs/module-User-Management.html +0 -0
- package/docs/module-User-Permissions.html +0 -0
- package/docs/module-UserManagement.html +2 -2
- package/docs/module-UserProfile.html +2 -2
- package/docs/railcontent.js.html +2 -2
- package/docs/sanity.js.html +24 -6
- 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/docs/types.js.html +0 -0
- package/docs/userActivity.js.html +360 -12
- package/docs/user_interests.js.html +2 -2
- package/docs/user_management.js.html +2 -2
- package/docs/user_permissions.js.html +2 -2
- package/docs/user_profile.js.html +4 -4
- package/docs/user_sessions.js.html +2 -2
- package/docs/user_types.js.html +2 -2
- package/docs/user_user-management-system.js.html +2 -2
- package/docs/user_user-management.js.html +0 -0
- package/jest.config.js +0 -0
- package/jsdoc.json +0 -0
- package/link_mcs.sh +0 -0
- package/package.json +1 -1
- package/src/contentMetaData.js +13 -12
- package/src/contentTypeConfig.js +18 -2
- package/src/filterBuilder.js +0 -0
- package/src/index.d.ts +10 -2
- package/src/index.js +10 -2
- package/src/infrastructure/http/HttpClient.ts +0 -0
- package/src/infrastructure/http/executors/FetchRequestExecutor.ts +0 -0
- package/src/infrastructure/http/index.ts +0 -0
- package/src/infrastructure/http/interfaces/HeaderProvider.ts +0 -0
- package/src/infrastructure/http/interfaces/HttpError.ts +0 -0
- package/src/infrastructure/http/interfaces/NetworkError.ts +0 -0
- package/src/infrastructure/http/interfaces/RequestExecutor.ts +0 -0
- package/src/infrastructure/http/interfaces/RequestOptions.ts +0 -0
- package/src/infrastructure/http/providers/DefaultHeaderProvider.ts +0 -0
- package/src/lib/httpHelper.js +0 -0
- package/src/lib/lastUpdated.js +0 -0
- package/src/services/api/types.js +0 -0
- package/src/services/config.js +0 -0
- package/src/services/content-org/content-org.js +0 -0
- package/src/services/content-org/playlists-types.js +0 -0
- package/src/services/content-org/playlists.js +0 -0
- package/src/services/content.js +7 -0
- package/src/services/contentAggregator.js +0 -0
- package/src/services/contentLikes.js +0 -0
- package/src/services/contentProgress.js +49 -20
- package/src/services/dataContext.js +0 -0
- package/src/services/dateUtils.js +0 -0
- package/src/services/forum.js +0 -0
- package/src/services/gamification/awards.js +0 -0
- package/src/services/gamification/gamification.js +0 -0
- package/src/services/gamification/types.js +0 -0
- package/src/services/imageSRCBuilder.js +0 -0
- package/src/services/imageSRCVerify.js +0 -0
- package/src/services/railcontent.js +0 -0
- package/src/services/recommendations.js +0 -0
- package/src/services/sanity.js +22 -4
- package/src/services/types.js +0 -0
- package/src/services/user/interests.js +0 -0
- package/src/services/user/management.js +0 -0
- package/src/services/user/permissions.js +0 -0
- package/src/services/user/profile.js +0 -0
- package/src/services/user/sessions.js +0 -0
- package/src/services/user/types.js +0 -0
- package/src/services/user/user-management-system.js +0 -0
- package/src/services/userActivity.js +348 -10
- package/test/HttpClient.test.js +0 -0
- package/test/content.test.js +0 -0
- package/test/contentLikes.test.js +0 -0
- package/test/contentProgress.test.js +0 -0
- package/test/dataContext.test.js +0 -0
- package/test/forum.test.js +0 -0
- package/test/imageSRCBuilder.test.js +0 -0
- package/test/imageSRCVerify.test.js +0 -0
- package/test/initializeTests.js +0 -0
- package/test/lib/lastUpdated.test.js +0 -0
- package/test/live/contentProgressLive.test.js +0 -0
- package/test/live/railcontentLive.test.js +0 -0
- package/test/localStorageMock.js +0 -0
- package/test/log.js +0 -0
- package/test/mockData/mockData_fetchByRailContentIds_one_content.json +0 -0
- package/test/mockData/mockData_progress_content.json +182 -0
- package/test/mockData/mockData_sanity_progress_content.json +1451 -0
- package/test/mockData/mockData_user_practices.json +0 -0
- package/test/progressRows.test.js +215 -0
- package/test/sanityQueryService.test.js +1 -1
- package/test/streakMessage.test.js +0 -0
- package/test/user/permissions.test.js +0 -0
- package/test/userActivity.test.js +0 -0
- package/tools/generate-index.cjs +0 -0
|
File without changes
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { getProgressRows } from '../src/services/userActivity';
|
|
2
|
+
import { fetchUserPlaylists } from '../src/services/content-org/playlists';
|
|
3
|
+
import { fetchByRailContentIds } from '../src/services/sanity';
|
|
4
|
+
import {getAllStartedOrCompleted, getProgressStateByIds} from '../src/services/contentProgress';
|
|
5
|
+
import mockData_progress_content from './mockData/mockData_progress_content.json';
|
|
6
|
+
import mockData_sanity_progress_content from "./mockData/mockData_sanity_progress_content.json";
|
|
7
|
+
|
|
8
|
+
jest.mock('../src/services/content-org/playlists');
|
|
9
|
+
jest.mock('../src/services/sanity');
|
|
10
|
+
jest.mock('../src/services/contentProgress');
|
|
11
|
+
|
|
12
|
+
describe('getProgressRows', () => {
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
jest.clearAllMocks();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('returns progress rows successfully', async () => {
|
|
18
|
+
const mockPlaylists = [
|
|
19
|
+
{
|
|
20
|
+
id: 1,
|
|
21
|
+
name: 'Playlist 1',
|
|
22
|
+
last_progress: '2025-05-19 10:00:00',
|
|
23
|
+
last_engaged_on: 101,
|
|
24
|
+
items: [{ content_id: 201 }],
|
|
25
|
+
duration_formated: '10m',
|
|
26
|
+
total_items: 1,
|
|
27
|
+
likes: 100,
|
|
28
|
+
user: { display_name: 'User1' },
|
|
29
|
+
brand: 'brand1',
|
|
30
|
+
first_items_thumbnail_url: 'url1',
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const mockPlaylistContents = [
|
|
35
|
+
{
|
|
36
|
+
id: 201,
|
|
37
|
+
railcontent_id: 201,
|
|
38
|
+
parent_content_data: [],
|
|
39
|
+
type: 'lesson',
|
|
40
|
+
thumbnail: 'thumb1',
|
|
41
|
+
title: 'Lesson 1',
|
|
42
|
+
difficulty_string: 'Easy',
|
|
43
|
+
artist_name: 'Artist 1',
|
|
44
|
+
lesson_count: 1,
|
|
45
|
+
completed_children: 0,
|
|
46
|
+
brand: 'brand1',
|
|
47
|
+
slug: 'lesson-1',
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const mockProgressContents = {
|
|
52
|
+
'201': {
|
|
53
|
+
status: 'in_progress',
|
|
54
|
+
progress: 50,
|
|
55
|
+
last_update: 1621510400, // Unix timestamp
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const mockProgressState = {
|
|
60
|
+
'201': 'in_progress',
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
fetchUserPlaylists.mockResolvedValue({ data: mockPlaylists });
|
|
64
|
+
fetchByRailContentIds.mockResolvedValue(mockPlaylistContents);
|
|
65
|
+
getAllStartedOrCompleted.mockResolvedValue(mockProgressContents);
|
|
66
|
+
getProgressStateByIds.mockResolvedValue(mockProgressState);
|
|
67
|
+
|
|
68
|
+
const result = await getProgressRows({ brand: 'brand1', limit: 8 });
|
|
69
|
+
|
|
70
|
+
expect(result).toHaveProperty('type', 'progress_rows');
|
|
71
|
+
expect(result).toHaveProperty('data');
|
|
72
|
+
expect(Array.isArray(result.data)).toBe(true);
|
|
73
|
+
expect(result.data.length).toBe(2);
|
|
74
|
+
expect(result.data[0]).toHaveProperty('id', 'progressType', 'header', 'body', 'cta');
|
|
75
|
+
expect(result.data[0].progressType).toBe('playlist');
|
|
76
|
+
expect(result.data[0].body).toHaveProperty('first_items_thumbnail_url', 'title', 'subtitle');
|
|
77
|
+
expect(result.data[0].cta).toHaveProperty('text');
|
|
78
|
+
expect(result.data[0].cta).toHaveProperty('action');
|
|
79
|
+
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('handles no progress', async () => {
|
|
83
|
+
fetchUserPlaylists.mockResolvedValue({ data: [] });
|
|
84
|
+
getAllStartedOrCompleted.mockResolvedValue({});
|
|
85
|
+
fetchByRailContentIds.mockResolvedValue([]);
|
|
86
|
+
getProgressStateByIds.mockResolvedValue({});
|
|
87
|
+
|
|
88
|
+
const result = await getProgressRows({ brand: 'brand1', limit: 8 });
|
|
89
|
+
expect(result).toHaveProperty('type', 'progress_rows');
|
|
90
|
+
expect(result.data).toEqual([]);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('check progress rows logic', async () => {
|
|
94
|
+
fetchUserPlaylists.mockResolvedValue({ data: [] });
|
|
95
|
+
fetchByRailContentIds
|
|
96
|
+
.mockImplementationOnce(() => Promise.resolve([])) // playlists
|
|
97
|
+
.mockImplementationOnce(() => Promise.resolve(mockData_sanity_progress_content) // content progress
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
getAllStartedOrCompleted.mockResolvedValue(mockData_progress_content);
|
|
101
|
+
getProgressStateByIds
|
|
102
|
+
.mockImplementationOnce(() => Promise.resolve({
|
|
103
|
+
"287853": "completed",
|
|
104
|
+
"287854": "completed",
|
|
105
|
+
"287855": "completed",
|
|
106
|
+
"287858": "completed",
|
|
107
|
+
"287859": ""
|
|
108
|
+
})) // course lessons
|
|
109
|
+
.mockImplementationOnce(() => Promise.resolve({
|
|
110
|
+
"257243": "started",
|
|
111
|
+
"257245": "started",
|
|
112
|
+
"257246": "",
|
|
113
|
+
"257247": "",
|
|
114
|
+
"257248": "",
|
|
115
|
+
"257249": "completed",
|
|
116
|
+
"257250": "completed",
|
|
117
|
+
"257251": "",
|
|
118
|
+
"257252": "",
|
|
119
|
+
"257253": "",
|
|
120
|
+
"257254": "",
|
|
121
|
+
"257255": "",
|
|
122
|
+
"257256": "",
|
|
123
|
+
"257257": "",
|
|
124
|
+
"257258": "",
|
|
125
|
+
"257259": "",
|
|
126
|
+
"257260": "",
|
|
127
|
+
"259235": "",
|
|
128
|
+
"259236": ""
|
|
129
|
+
})) //pack
|
|
130
|
+
.mockImplementationOnce(() => Promise.resolve({
|
|
131
|
+
"410479": "",
|
|
132
|
+
"410480": "completed",
|
|
133
|
+
"410481": "completed",
|
|
134
|
+
"410482": "",
|
|
135
|
+
"410483": "",
|
|
136
|
+
"410484": "",
|
|
137
|
+
"410485": "",
|
|
138
|
+
"410486": "",
|
|
139
|
+
"410487": ""
|
|
140
|
+
}) // challenge
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
const result = await getProgressRows({ brand: 'brand1', limit: 8 });
|
|
145
|
+
console.log('result', result);
|
|
146
|
+
expect(fetchByRailContentIds).toHaveBeenCalledTimes(2);
|
|
147
|
+
|
|
148
|
+
expect(result).toHaveProperty('type', 'progress_rows');
|
|
149
|
+
expect(result.data.length).toBeGreaterThan(0);
|
|
150
|
+
expect(result.data.length).toBeLessThanOrEqual(8);
|
|
151
|
+
//course 280498
|
|
152
|
+
const lesson1Progress = result.data.find(row => row.id === 280498);
|
|
153
|
+
expect(lesson1Progress).toBeDefined();
|
|
154
|
+
expect(lesson1Progress.cta).toHaveProperty('text');
|
|
155
|
+
expect(lesson1Progress.cta.text.toLowerCase()).toContain('continue');
|
|
156
|
+
expect(lesson1Progress.cta.action).toHaveProperty('type');
|
|
157
|
+
expect(lesson1Progress.cta.action.type).toBe('course');
|
|
158
|
+
expect(lesson1Progress.cta.action.id).toBe(280498);
|
|
159
|
+
expect(lesson1Progress.cta.action.child).toBeDefined();
|
|
160
|
+
expect(lesson1Progress.cta.action.child.type).toBe('course-part');
|
|
161
|
+
expect(lesson1Progress.cta.action.child.id).toBe(287859);
|
|
162
|
+
//pack 257242
|
|
163
|
+
const lesson2Progress = result.data.find(row => row.id === 257242);
|
|
164
|
+
expect(lesson2Progress).toBeDefined();
|
|
165
|
+
expect(lesson2Progress.cta).toHaveProperty('text');
|
|
166
|
+
expect(lesson2Progress.cta.text.toLowerCase()).toContain('continue');
|
|
167
|
+
console.log(lesson2Progress.cta.action)
|
|
168
|
+
expect(lesson2Progress.cta.action).toHaveProperty('type');
|
|
169
|
+
expect(lesson2Progress.cta.action.type).toBe('pack');
|
|
170
|
+
expect(lesson2Progress.cta.action.id).toBe(257242);
|
|
171
|
+
expect(lesson2Progress.cta.action.child).toBeDefined();
|
|
172
|
+
expect(lesson2Progress.cta.action.child.type).toBe('pack-bundle');
|
|
173
|
+
expect(lesson2Progress.cta.action.child.child).toBeDefined();
|
|
174
|
+
expect(lesson2Progress.cta.action.child.child.type).toBe('pack-bundle-lesson');
|
|
175
|
+
expect(lesson2Progress.cta.action.child.child.id).toBe(257251);
|
|
176
|
+
|
|
177
|
+
//challenge 410478
|
|
178
|
+
const lesson3Progress = result.data.find(row => row.id === 410478);
|
|
179
|
+
expect(lesson3Progress).toBeDefined();
|
|
180
|
+
expect(lesson3Progress.cta).toHaveProperty('text');
|
|
181
|
+
expect(lesson3Progress.cta.text.toLowerCase()).toContain('continue');
|
|
182
|
+
expect(lesson3Progress.cta.action).toHaveProperty('type');
|
|
183
|
+
expect(lesson3Progress.cta.action.type).toBe('challenge');
|
|
184
|
+
expect(lesson3Progress.cta.action.id).toBe(410478);
|
|
185
|
+
expect(lesson3Progress.cta.action.child).toBeDefined();
|
|
186
|
+
expect(lesson3Progress.cta.action.child.type).toBe('challenge-part');
|
|
187
|
+
expect(lesson3Progress.cta.action.child.id).toBe(410479);
|
|
188
|
+
|
|
189
|
+
//completed play-along 316772
|
|
190
|
+
const lesson4Progress = result.data.find(row => row.id === 316772);
|
|
191
|
+
expect(lesson4Progress).toBeDefined();
|
|
192
|
+
expect(lesson4Progress.cta).toHaveProperty('text');
|
|
193
|
+
expect(lesson4Progress.cta.text).toContain('Replay Song');
|
|
194
|
+
expect(lesson4Progress.cta.action).toHaveProperty('type');
|
|
195
|
+
expect(lesson4Progress.cta.action.type).toBe('play-along');
|
|
196
|
+
expect(lesson4Progress.cta.action.id).toBe(316772);
|
|
197
|
+
expect(lesson4Progress.body.progressPercent).toBe(100);
|
|
198
|
+
|
|
199
|
+
//in progress quick-tips 325826
|
|
200
|
+
const lesson5Progress = result.data.find(row => row.id === 325826);
|
|
201
|
+
console.log(lesson5Progress)
|
|
202
|
+
expect(lesson5Progress).toBeDefined();
|
|
203
|
+
expect(lesson5Progress.cta).toHaveProperty('text');
|
|
204
|
+
expect(lesson5Progress.cta.text).toContain('Continue');
|
|
205
|
+
expect(lesson5Progress.cta.action).toHaveProperty('type');
|
|
206
|
+
expect(lesson5Progress.cta.action.type).toBe('quick-tips');
|
|
207
|
+
expect(lesson5Progress.cta.action.id).toBe(325826);
|
|
208
|
+
expect(lesson5Progress.body.progressPercent).toBeLessThan(100);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
|
|
@@ -988,7 +988,7 @@ describe('Recommended System', function() {
|
|
|
988
988
|
})
|
|
989
989
|
|
|
990
990
|
test('fetchMetadata', async () => {
|
|
991
|
-
const response = await fetchMetadata('
|
|
991
|
+
const response = await fetchMetadata('singeo', 'recent-activities')
|
|
992
992
|
log(response)
|
|
993
993
|
expect(response.tabs.length).toBeGreaterThan(0)
|
|
994
994
|
})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/tools/generate-index.cjs
CHANGED
|
File without changes
|