musora-content-services 1.0.115 → 1.0.118

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 (57) hide show
  1. package/.github/workflows/node.js.yml +0 -0
  2. package/CHANGELOG.md +6 -0
  3. package/README.md +0 -0
  4. package/babel.config.js +0 -0
  5. package/docs/config.js.html +0 -0
  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 +0 -0
  25. package/docs/module-Config.html +0 -0
  26. package/docs/module-Railcontent-Services.html +0 -0
  27. package/docs/module-Sanity-Services.html +0 -0
  28. package/docs/railcontent.js.html +0 -0
  29. package/docs/sanity.js.html +0 -0
  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 +2 -1
  44. package/src/contentMetaData.js +1091 -0
  45. package/src/contentTypeConfig.js +45 -1414
  46. package/src/filterBuilder.js +0 -0
  47. package/src/index.d.ts +137 -88
  48. package/src/index.js +135 -97
  49. package/src/services/config.js +1 -0
  50. package/src/services/railcontent.js +24 -12
  51. package/src/services/sanity.js +178 -77
  52. package/src/services/userContext.js +0 -0
  53. package/test/localStorageMock.js +0 -0
  54. package/test/log.js +0 -0
  55. package/test/sanityQueryService.test.js +154 -2
  56. package/test/userContext.test.js +0 -0
  57. package/tools/generate-index.js +85 -0
File without changes
package/src/index.d.ts CHANGED
@@ -1,95 +1,144 @@
1
+ /*** This file was generated automatically. To recreate, please run `npm run build-index`. ***/
2
+
1
3
  import {
2
- fetchSongById,
3
- fetchArtists,
4
- fetchSongArtistCount,
5
- fetchRelatedSongs,
6
- fetchAllSongs,
7
- fetchSongFilterOptions,
8
- fetchSongCount,
9
- fetchWorkouts,
10
- fetchNewReleases,
11
- fetchLiveEvent,
12
- fetchUpcomingEvents,
13
- fetchByRailContentId,
14
- fetchByRailContentIds,
15
- fetchAll,
16
- fetchAllFilterOptions,
17
- fetchFoundation,
18
- fetchMethods,
19
- fetchMethod,
20
- fetchMethodChildren,
21
- fetchMethodNextLesson,
22
- fetchMethodChildrenIds,
23
- fetchNextPreviousLesson,
24
- fetchRelatedLessons,
25
- fetchAllPacks,
26
- fetchPackAll,
27
- fetchPackChildren,
28
- fetchLessonContent,
29
- fetchCourseOverview,
30
- fetchChallengeOverview,
31
- fetchScheduledReleases,
32
- fetchArtistLessons,
33
- fetchGenreLessons,
34
- fetchShowsData,
35
- fetchMetadata,
36
- } from './services/sanity.js';
4
+ globalConfig,
5
+ initializeService
6
+ } from './services/config.js';
37
7
 
38
- import {
39
- fetchCompletedState,
40
- fetchAllCompletedStates,
41
- fetchContentInProgress,
42
- fetchCompletedContent,
43
- fetchVimeoData,
44
- fetchContentPageUserData,
8
+ import {
9
+ fetchAllCompletedStates,
10
+ fetchCompletedContent,
11
+ fetchCompletedState,
12
+ fetchContentInProgress,
13
+ fetchContentPageUserData,
14
+ fetchHandler,
15
+ fetchLikeContent,
16
+ fetchSongsInProgress,
17
+ fetchUnlikeContent,
18
+ fetchUserContext,
19
+ fetchVimeoData
45
20
  } from './services/railcontent.js';
46
21
 
47
- import { initializeService } from './services/config.js';
22
+ import {
23
+ fetchAll,
24
+ fetchAllFilterOptions,
25
+ fetchAllPacks,
26
+ fetchAllSongs,
27
+ fetchArtistLessons,
28
+ fetchArtists,
29
+ fetchByRailContentId,
30
+ fetchByRailContentIds,
31
+ fetchByReference,
32
+ fetchCatalogMetadata,
33
+ fetchChallengeOverview,
34
+ fetchChildren,
35
+ fetchCoachLessons,
36
+ fetchCourseOverview,
37
+ fetchFoundation,
38
+ fetchGenreLessons,
39
+ fetchLessonContent,
40
+ fetchLiveEvent,
41
+ fetchMetadata,
42
+ fetchMethod,
43
+ fetchMethodChildren,
44
+ fetchMethodChildrenIds,
45
+ fetchMethodNextLesson,
46
+ fetchMethodPreviousNextLesson,
47
+ fetchMethods,
48
+ fetchNewReleases,
49
+ fetchNextPreviousLesson,
50
+ fetchPackAll,
51
+ fetchPackChildren,
52
+ fetchParentByRailContentId,
53
+ fetchRelatedLessons,
54
+ fetchRelatedMethodLessons,
55
+ fetchRelatedSongs,
56
+ fetchSanity,
57
+ fetchScheduledReleases,
58
+ fetchShowsData,
59
+ fetchSongArtistCount,
60
+ fetchSongById,
61
+ fetchSongCount,
62
+ fetchSongFilterOptions,
63
+ fetchUpcomingEvents,
64
+ fetchWorkouts,
65
+ getSortOrder
66
+ } from './services/sanity.js';
48
67
 
68
+ import {
69
+ clearCache,
70
+ fetchContentData,
71
+ init,
72
+ likeContent,
73
+ testClearLocal,
74
+ unlikeContent,
75
+ version
76
+ } from './services/userContext.js';
49
77
 
50
78
  declare module 'musora-content-services' {
51
- export {
52
- initializeService,
53
- fetchSongById,
54
- fetchArtists,
55
- fetchSongArtistCount,
56
- fetchRelatedSongs,
57
- fetchAllSongs,
58
- fetchSongFilterOptions,
59
- fetchSongCount,
60
- fetchWorkouts,
61
- fetchNewReleases,
62
- fetchUpcomingEvents,
63
- fetchByRailContentId,
64
- fetchByRailContentIds,
65
- fetchAll,
66
- fetchAllFilterOptions,
67
- fetchFoundation,
68
- fetchMethods,
69
- fetchMethod,
70
- fetchMethodNextLesson,
71
- fetchMethodChildren,
72
- fetchMethodChildrenIds,
73
- fetchNextPreviousLesson,
74
- fetchRelatedLessons,
75
- fetchAllPacks,
76
- fetchPackAll,
77
- fetchPackChildren,
78
- fetchLessonContent,
79
- fetchCourseOverview,
80
- fetchLiveEvent,
81
- fetchChallengeOverview,
82
- fetchVimeoData,
83
- fetchCompletedState,
84
- fetchAllCompletedStates,
85
- fetchContentInProgress,
86
- fetchCompletedContent,
87
- fetchContentPageUserData,
88
- fetchScheduledReleases,
89
- fetchArtistLessons,
90
- fetchGenreLessons,
91
- fetchShowsData,
92
- fetchMetadata,
93
- }
94
-
95
- }
79
+ export {
80
+ clearCache,
81
+ fetchAll,
82
+ fetchAllCompletedStates,
83
+ fetchAllFilterOptions,
84
+ fetchAllPacks,
85
+ fetchAllSongs,
86
+ fetchArtistLessons,
87
+ fetchArtists,
88
+ fetchByRailContentId,
89
+ fetchByRailContentIds,
90
+ fetchByReference,
91
+ fetchCatalogMetadata,
92
+ fetchChallengeOverview,
93
+ fetchChildren,
94
+ fetchCoachLessons,
95
+ fetchCompletedContent,
96
+ fetchCompletedState,
97
+ fetchContentData,
98
+ fetchContentInProgress,
99
+ fetchContentPageUserData,
100
+ fetchCourseOverview,
101
+ fetchFoundation,
102
+ fetchGenreLessons,
103
+ fetchHandler,
104
+ fetchLessonContent,
105
+ fetchLikeContent,
106
+ fetchLiveEvent,
107
+ fetchMetadata,
108
+ fetchMethod,
109
+ fetchMethodChildren,
110
+ fetchMethodChildrenIds,
111
+ fetchMethodNextLesson,
112
+ fetchMethodPreviousNextLesson,
113
+ fetchMethods,
114
+ fetchNewReleases,
115
+ fetchNextPreviousLesson,
116
+ fetchPackAll,
117
+ fetchPackChildren,
118
+ fetchParentByRailContentId,
119
+ fetchRelatedLessons,
120
+ fetchRelatedMethodLessons,
121
+ fetchRelatedSongs,
122
+ fetchSanity,
123
+ fetchScheduledReleases,
124
+ fetchShowsData,
125
+ fetchSongArtistCount,
126
+ fetchSongById,
127
+ fetchSongCount,
128
+ fetchSongFilterOptions,
129
+ fetchSongsInProgress,
130
+ fetchUnlikeContent,
131
+ fetchUpcomingEvents,
132
+ fetchUserContext,
133
+ fetchVimeoData,
134
+ fetchWorkouts,
135
+ getSortOrder,
136
+ globalConfig,
137
+ init,
138
+ initializeService,
139
+ likeContent,
140
+ testClearLocal,
141
+ unlikeContent,
142
+ version,
143
+ }
144
+ }
package/src/index.js CHANGED
@@ -1,104 +1,142 @@
1
- import { initializeService } from './services/config.js';
1
+ /*** This file was generated automatically. To recreate, please run `npm run build-index`. ***/
2
2
 
3
3
  import {
4
- fetchSongById,
5
- fetchArtists,
6
- fetchSongArtistCount,
7
- fetchRelatedSongs,
8
- fetchAllSongs,
9
- fetchSongFilterOptions,
10
- fetchSongCount,
11
- fetchWorkouts,
12
- fetchNewReleases,
13
- fetchUpcomingEvents,
14
- fetchByRailContentId,
15
- fetchByRailContentIds,
16
- fetchAll,
17
- fetchAllFilterOptions,
18
- fetchMethodNextLesson,
19
- fetchFoundation,
20
- fetchMethod,
21
- fetchMethods,
22
- fetchMethodChildren,
23
- fetchMethodChildrenIds,
24
- fetchNextPreviousLesson,
25
- fetchRelatedLessons,
26
- fetchAllPacks,
27
- fetchPackAll,
28
- fetchPackChildren,
29
- fetchLessonContent,
30
- fetchCourseOverview,
31
- fetchChildren,
32
- fetchParentByRailContentId,
33
- fetchMethodPreviousNextLesson,
34
- fetchLiveEvent,
35
- fetchChallengeOverview,
36
- fetchCoachLessons,
37
- fetchByReference,
38
- fetchScheduledReleases,
39
- fetchArtistLessons,
40
- fetchGenreLessons,
41
- fetchRelatedMethodLessons,
42
- fetchShowsData,
43
- fetchMetadata,
44
- } from './services/sanity.js';
4
+ globalConfig,
5
+ initializeService
6
+ } from './services/config.js';
45
7
 
46
- import {
47
- fetchCompletedState,
48
- fetchAllCompletedStates,
49
- fetchContentInProgress,
50
- fetchCompletedContent,
51
- fetchVimeoData,
52
- fetchContentPageUserData,
8
+ import {
9
+ fetchAllCompletedStates,
10
+ fetchCompletedContent,
11
+ fetchCompletedState,
12
+ fetchContentInProgress,
13
+ fetchContentPageUserData,
14
+ fetchHandler,
15
+ fetchLikeContent,
16
+ fetchSongsInProgress,
17
+ fetchUnlikeContent,
18
+ fetchUserContext,
19
+ fetchVimeoData
53
20
  } from './services/railcontent.js';
54
21
 
22
+ import {
23
+ fetchAll,
24
+ fetchAllFilterOptions,
25
+ fetchAllPacks,
26
+ fetchAllSongs,
27
+ fetchArtistLessons,
28
+ fetchArtists,
29
+ fetchByRailContentId,
30
+ fetchByRailContentIds,
31
+ fetchByReference,
32
+ fetchCatalogMetadata,
33
+ fetchChallengeOverview,
34
+ fetchChildren,
35
+ fetchCoachLessons,
36
+ fetchCourseOverview,
37
+ fetchFoundation,
38
+ fetchGenreLessons,
39
+ fetchLessonContent,
40
+ fetchLiveEvent,
41
+ fetchMetadata,
42
+ fetchMethod,
43
+ fetchMethodChildren,
44
+ fetchMethodChildrenIds,
45
+ fetchMethodNextLesson,
46
+ fetchMethodPreviousNextLesson,
47
+ fetchMethods,
48
+ fetchNewReleases,
49
+ fetchNextPreviousLesson,
50
+ fetchPackAll,
51
+ fetchPackChildren,
52
+ fetchParentByRailContentId,
53
+ fetchRelatedLessons,
54
+ fetchRelatedMethodLessons,
55
+ fetchRelatedSongs,
56
+ fetchSanity,
57
+ fetchScheduledReleases,
58
+ fetchShowsData,
59
+ fetchSongArtistCount,
60
+ fetchSongById,
61
+ fetchSongCount,
62
+ fetchSongFilterOptions,
63
+ fetchUpcomingEvents,
64
+ fetchWorkouts,
65
+ getSortOrder
66
+ } from './services/sanity.js';
67
+
68
+ import {
69
+ clearCache,
70
+ fetchContentData,
71
+ init,
72
+ likeContent,
73
+ testClearLocal,
74
+ unlikeContent,
75
+ version
76
+ } from './services/userContext.js';
55
77
 
56
78
  export {
57
- initializeService,
58
- fetchSongById,
59
- fetchArtists,
60
- fetchSongArtistCount,
61
- fetchRelatedSongs,
62
- fetchAllSongs,
63
- fetchSongFilterOptions,
64
- fetchSongCount,
65
- fetchWorkouts,
66
- fetchNewReleases,
67
- fetchUpcomingEvents,
68
- fetchByRailContentId,
69
- fetchByRailContentIds,
70
- fetchAll,
71
- fetchAllFilterOptions,
72
- fetchFoundation,
73
- fetchMethods,
74
- fetchMethod,
75
- fetchMethodChildren,
76
- fetchMethodNextLesson,
77
- fetchMethodChildrenIds,
78
- fetchNextPreviousLesson,
79
- fetchRelatedLessons,
80
- fetchAllPacks,
81
- fetchPackAll,
82
- fetchPackChildren,
83
- fetchLessonContent,
84
- fetchCompletedState,
85
- fetchAllCompletedStates,
86
- fetchContentInProgress,
87
- fetchCompletedContent,
88
- fetchCourseOverview,
89
- fetchChildren,
90
- fetchParentByRailContentId,
91
- fetchMethodPreviousNextLesson,
92
- fetchLiveEvent,
93
- fetchChallengeOverview,
94
- fetchVimeoData,
95
- fetchContentPageUserData,
96
- fetchCoachLessons,
97
- fetchByReference,
98
- fetchScheduledReleases,
99
- fetchArtistLessons,
100
- fetchGenreLessons,
101
- fetchRelatedMethodLessons,
102
- fetchShowsData,
103
- fetchMetadata,
104
- }
79
+ clearCache,
80
+ fetchAll,
81
+ fetchAllCompletedStates,
82
+ fetchAllFilterOptions,
83
+ fetchAllPacks,
84
+ fetchAllSongs,
85
+ fetchArtistLessons,
86
+ fetchArtists,
87
+ fetchByRailContentId,
88
+ fetchByRailContentIds,
89
+ fetchByReference,
90
+ fetchCatalogMetadata,
91
+ fetchChallengeOverview,
92
+ fetchChildren,
93
+ fetchCoachLessons,
94
+ fetchCompletedContent,
95
+ fetchCompletedState,
96
+ fetchContentData,
97
+ fetchContentInProgress,
98
+ fetchContentPageUserData,
99
+ fetchCourseOverview,
100
+ fetchFoundation,
101
+ fetchGenreLessons,
102
+ fetchHandler,
103
+ fetchLessonContent,
104
+ fetchLikeContent,
105
+ fetchLiveEvent,
106
+ fetchMetadata,
107
+ fetchMethod,
108
+ fetchMethodChildren,
109
+ fetchMethodChildrenIds,
110
+ fetchMethodNextLesson,
111
+ fetchMethodPreviousNextLesson,
112
+ fetchMethods,
113
+ fetchNewReleases,
114
+ fetchNextPreviousLesson,
115
+ fetchPackAll,
116
+ fetchPackChildren,
117
+ fetchParentByRailContentId,
118
+ fetchRelatedLessons,
119
+ fetchRelatedMethodLessons,
120
+ fetchRelatedSongs,
121
+ fetchSanity,
122
+ fetchScheduledReleases,
123
+ fetchShowsData,
124
+ fetchSongArtistCount,
125
+ fetchSongById,
126
+ fetchSongCount,
127
+ fetchSongFilterOptions,
128
+ fetchSongsInProgress,
129
+ fetchUnlikeContent,
130
+ fetchUpcomingEvents,
131
+ fetchUserContext,
132
+ fetchVimeoData,
133
+ fetchWorkouts,
134
+ getSortOrder,
135
+ globalConfig,
136
+ init,
137
+ initializeService,
138
+ likeContent,
139
+ testClearLocal,
140
+ unlikeContent,
141
+ version,
142
+ };
@@ -19,6 +19,7 @@ let globalConfig = {
19
19
  * @param {string} config.sanityConfig.version - The API version to use.
20
20
  * @param {boolean} [config.sanityConfig.debug=false] - Optional flag to enable debug mode.
21
21
  * @param {boolean} [config.sanityConfig.useCachedAPI=true] - Optional flag to enable or disable the use of the cached API.
22
+ * @param {boolean} [config.sanityConfig.useDummyRailContentMethods=false] - Optional flag to use test harness for railcontent methods. Should only be used by jest tests.
22
23
  * @param {Object} config.railcontentConfig - Configuration for user services.
23
24
  * @param {string} config.railcontentConfig.token - The token for authenticating user-specific requests.
24
25
  * @param {string} config.railcontentConfig.userId - The user ID for fetching user-specific data.
@@ -254,15 +254,6 @@ export async function fetchContentPageUserData(contentId) {
254
254
  }
255
255
  }
256
256
 
257
- function fetchAbsolute(url, params) {
258
- if(globalConfig.railcontentConfig.baseUrl) {
259
- if (url.startsWith('/')) {
260
- return fetch(globalConfig.railcontentConfig.baseUrl + url, params)
261
- }
262
- }
263
- return fetch(url, params);
264
- }
265
-
266
257
  export async function fetchUserContext() {
267
258
  let url = `/content/user_data_all`;
268
259
  const headers = {
@@ -270,7 +261,7 @@ export async function fetchUserContext() {
270
261
  'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
271
262
  };
272
263
  try {
273
- const response = await fetch(url, {headers});
264
+ const response = await fetchAbsolute(url, {headers});
274
265
  const result = await response.json();
275
266
  if (result) {
276
267
  console.log('fetchUserContext', result);
@@ -284,13 +275,25 @@ export async function fetchUserContext() {
284
275
  }
285
276
  }
286
277
 
278
+ export async function fetchUserPermissions() {
279
+ //TODO: Should be investigate why throw 500 errors on MA
280
+ return [];
281
+ let url = `/content/user_data_permissions`;
282
+ const headers = {
283
+ 'Content-Type': 'application/json',
284
+ 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
285
+ };
286
+ // in the case of an unauthorized user, we return empty permissions
287
+ return fetchHandler(url, 'get') ?? [];
288
+ }
289
+
287
290
  export async function fetchHandler(url, method = "get") {
288
291
  const headers = {
289
292
  'Content-Type': 'application/json',
290
293
  'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
291
294
  };
292
295
  try {
293
- const response = await fetch(url, {method, headers});
296
+ const response = await fetchAbsolute(url, {method, headers});
294
297
  const result = await response.json();
295
298
  if (result) {
296
299
  return result;
@@ -299,8 +302,8 @@ export async function fetchHandler(url, method = "get") {
299
302
  }
300
303
  } catch (error) {
301
304
  console.error('Fetch error:', error);
302
- return null;
303
305
  }
306
+ return null;
304
307
  }
305
308
 
306
309
  export async function fetchLikeContent(contentId) {
@@ -311,4 +314,13 @@ export async function fetchLikeContent(contentId) {
311
314
  export async function fetchUnlikeContent(contentId) {
312
315
  let url = `/content/${contentId}/unlike`;
313
316
  return await fetchHandler(url, "post");
317
+ }
318
+
319
+ function fetchAbsolute(url, params) {
320
+ if(globalConfig.railcontentConfig.baseUrl) {
321
+ if (url.startsWith('/')) {
322
+ return fetch(globalConfig.railcontentConfig.baseUrl + url, params)
323
+ }
324
+ }
325
+ return fetch(url, params);
314
326
  }