musora-content-services 1.3.10 → 1.3.14
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 +8 -0
- package/docs/config.js.html +14 -14
- package/docs/index.html +2 -2
- package/docs/module-Config.html +2 -2
- package/docs/module-Railcontent-Services.html +46 -46
- package/docs/module-Sanity-Services.html +540 -36
- package/docs/railcontent.js.html +370 -366
- package/docs/sanity.js.html +1111 -967
- package/package.json +1 -1
- package/src/contentTypeConfig.js +6 -1
- package/src/filterBuilder.js +2 -2
- package/src/services/config.js +0 -0
- package/src/services/railcontent.js +37 -0
- package/src/services/sanity.js +6 -1
- package/.yarnrc.yml +0 -1
- package/docs/global.html +0 -809
- package/docs/module-Content-Services.html +0 -763
package/package.json
CHANGED
package/src/contentTypeConfig.js
CHANGED
|
@@ -453,9 +453,14 @@ export let contentTypeConfig = {
|
|
|
453
453
|
'behind-the-scenes': contentWithSortField,
|
|
454
454
|
'exploring-beats': contentWithSortField,
|
|
455
455
|
sonor: contentWithSortField,
|
|
456
|
+
returning: {
|
|
457
|
+
fields: [
|
|
458
|
+
`quarter_published`,
|
|
459
|
+
]
|
|
460
|
+
}
|
|
456
461
|
}
|
|
457
462
|
|
|
458
|
-
export const
|
|
463
|
+
export const plusMembershipPermissions = 92
|
|
459
464
|
|
|
460
465
|
export function getNewReleasesTypes(brand) {
|
|
461
466
|
const baseNewTypes = [
|
package/src/filterBuilder.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fetchUserPermissions } from './services/userPermissions.js'
|
|
2
|
-
import {
|
|
2
|
+
import { plusMembershipPermissions } from './contentTypeConfig.js'
|
|
3
3
|
|
|
4
4
|
export class FilterBuilder {
|
|
5
5
|
STATUS_SCHEDULED = 'scheduled'
|
|
@@ -116,7 +116,7 @@ export class FilterBuilder {
|
|
|
116
116
|
if (this.bypassPermissions || this.userData.isAdmin) return this
|
|
117
117
|
let requiredPermissions = this._getUserPermissions()
|
|
118
118
|
if (this.userData.isABasicMember && this.allowsPullSongsContent) {
|
|
119
|
-
requiredPermissions = [...requiredPermissions,
|
|
119
|
+
requiredPermissions = [...requiredPermissions, plusMembershipPermissions]
|
|
120
120
|
}
|
|
121
121
|
this._andWhere(
|
|
122
122
|
`(!defined(permission) || references(*[_type == 'permission' && railcontent_id in ${arrayToRawRepresentation(requiredPermissions)}]._id))`
|
package/src/services/config.js
CHANGED
|
File without changes
|
|
@@ -1198,6 +1198,43 @@ export async function setStudentViewForUser(userId, enable) {
|
|
|
1198
1198
|
return await patchDataHandler(url, data)
|
|
1199
1199
|
}
|
|
1200
1200
|
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* Fetch the top comment for a given content
|
|
1204
|
+
*
|
|
1205
|
+
* @param {int} railcontentId - The railcontent id to fetch.
|
|
1206
|
+
* @returns {Promise<Object|null>} - A promise that resolves to an comment object
|
|
1207
|
+
*/
|
|
1208
|
+
export async function fetchTopComment(railcontentId) {
|
|
1209
|
+
const url = `/api/content/v1/comments/${railcontentId}/top`
|
|
1210
|
+
return await fetchHandler(url)
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
/**
|
|
1215
|
+
*
|
|
1216
|
+
* @param railcontentId
|
|
1217
|
+
* @param page
|
|
1218
|
+
* @param limit
|
|
1219
|
+
* @returns {Promise<*|null>}
|
|
1220
|
+
*/
|
|
1221
|
+
export async function fetchComments(railcontentId, page = 1, limit = 20) {
|
|
1222
|
+
const url = `/api/content/v1/comments/${railcontentId}/all?page=${page}&limit=${limit}`
|
|
1223
|
+
return await fetchHandler(url)
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
/**
|
|
1227
|
+
*
|
|
1228
|
+
* @param commentId
|
|
1229
|
+
* @param page
|
|
1230
|
+
* @param limit
|
|
1231
|
+
* @returns {Promise<*|null>}
|
|
1232
|
+
*/
|
|
1233
|
+
export async function fetchCommentRelies(commentId, page = 1, limit = 20) {
|
|
1234
|
+
const url = `/api/content/v1/comments/${commentId}/replies?page=${page}&limit=${limit}`
|
|
1235
|
+
return await fetchHandler(url)
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1201
1238
|
function fetchAbsolute(url, params) {
|
|
1202
1239
|
if (globalConfig.railcontentConfig.authToken) {
|
|
1203
1240
|
params.headers['Authorization'] = `Bearer ${globalConfig.railcontentConfig.authToken}`
|
package/src/services/sanity.js
CHANGED
|
@@ -99,7 +99,7 @@ export async function fetchReturning(
|
|
|
99
99
|
const filterString = `brand == '${brand}' && quarter_published == '${nextQuarter}'`;
|
|
100
100
|
const startEndOrder = getQueryFromPage(pageNumber, contentPerPage);
|
|
101
101
|
const sortOrder = {sortOrder: "published_on desc, id desc", start: startEndOrder['start'], end: startEndOrder['end']};
|
|
102
|
-
const query = await buildQuery(filterString, {pullFutureContent: true, availableContentStatuses: ["draft"]}, getFieldsForContentType(), sortOrder);
|
|
102
|
+
const query = await buildQuery(filterString, {pullFutureContent: true, availableContentStatuses: ["draft"]}, getFieldsForContentType('returning'), sortOrder);
|
|
103
103
|
|
|
104
104
|
return fetchSanity(query, true);
|
|
105
105
|
}
|
|
@@ -255,6 +255,7 @@ export async function fetchRelatedSongs(brand, songId) {
|
|
|
255
255
|
"published_on": published_on,
|
|
256
256
|
status,
|
|
257
257
|
"image": thumbnail.asset->url,
|
|
258
|
+
"permission_id": permission[]->railcontent_id,
|
|
258
259
|
"fields": [
|
|
259
260
|
{
|
|
260
261
|
"key": "title",
|
|
@@ -280,6 +281,7 @@ export async function fetchRelatedSongs(brand, songId) {
|
|
|
280
281
|
"id": railcontent_id,
|
|
281
282
|
"url": web_url_path,
|
|
282
283
|
"published_on": published_on,
|
|
284
|
+
"permission_id": permission[]->railcontent_id,
|
|
283
285
|
status,
|
|
284
286
|
"fields": [
|
|
285
287
|
{
|
|
@@ -486,6 +488,9 @@ export async function fetchByRailContentId(id, contentType) {
|
|
|
486
488
|
* .catch(error => console.error(error));
|
|
487
489
|
*/
|
|
488
490
|
export async function fetchByRailContentIds(ids, contentType = undefined) {
|
|
491
|
+
if (!ids) {
|
|
492
|
+
return [];
|
|
493
|
+
}
|
|
489
494
|
const idsString = ids.join(',')
|
|
490
495
|
|
|
491
496
|
const query = `*[railcontent_id in [${idsString}]]{
|
package/.yarnrc.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
nodeLinker: node-modules
|