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.
- package/.github/workflows/node.js.yml +0 -0
- package/CHANGELOG.md +6 -0
- package/README.md +0 -0
- package/babel.config.js +0 -0
- package/docs/config.js.html +0 -0
- 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/index.html +0 -0
- package/docs/module-Config.html +0 -0
- package/docs/module-Railcontent-Services.html +0 -0
- package/docs/module-Sanity-Services.html +0 -0
- package/docs/railcontent.js.html +0 -0
- package/docs/sanity.js.html +0 -0
- 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/jest.config.js +0 -0
- package/jsdoc.json +0 -0
- package/package.json +2 -1
- package/src/contentMetaData.js +1091 -0
- package/src/contentTypeConfig.js +45 -1414
- package/src/filterBuilder.js +0 -0
- package/src/index.d.ts +137 -88
- package/src/index.js +135 -97
- package/src/services/config.js +1 -0
- package/src/services/railcontent.js +24 -12
- package/src/services/sanity.js +178 -77
- package/src/services/userContext.js +0 -0
- package/test/localStorageMock.js +0 -0
- package/test/log.js +0 -0
- package/test/sanityQueryService.test.js +154 -2
- package/test/userContext.test.js +0 -0
- package/tools/generate-index.js +85 -0
package/src/filterBuilder.js
CHANGED
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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 {
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
1
|
+
/*** This file was generated automatically. To recreate, please run `npm run build-index`. ***/
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
+
};
|
package/src/services/config.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
}
|