musora-content-services 1.0.58 → 1.0.59
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 +2 -0
- package/package.json +1 -1
- package/src/services/sanity.js +17 -23
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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.59](https://github.com/railroadmedia/musora-content-services/compare/v1.0.58...v1.0.59) (2024-08-26)
|
|
6
|
+
|
|
5
7
|
### [1.0.58](https://github.com/railroadmedia/musora-content-services/compare/v1.0.57...v1.0.58) (2024-08-26)
|
|
6
8
|
|
|
7
9
|
### [1.0.57](https://github.com/railroadmedia/musora-content-services/compare/v1.0.56...v1.0.57) (2024-08-26)
|
package/package.json
CHANGED
package/src/services/sanity.js
CHANGED
|
@@ -6,6 +6,18 @@ import {globalConfig} from "./config";
|
|
|
6
6
|
|
|
7
7
|
import { fetchAllCompletedStates, fetchCurrentSongComplete } from './railcontent.js';
|
|
8
8
|
|
|
9
|
+
const DEFAULT_FIELDS = [
|
|
10
|
+
'"id": railcontent_id',
|
|
11
|
+
'railcontent_id',
|
|
12
|
+
'"type": _type',
|
|
13
|
+
'title',
|
|
14
|
+
'"image": thumbnail.asset->url',
|
|
15
|
+
'difficulty',
|
|
16
|
+
'difficulty_string',
|
|
17
|
+
'web_url_path',
|
|
18
|
+
'published_on'
|
|
19
|
+
];
|
|
20
|
+
|
|
9
21
|
/**
|
|
10
22
|
* Fetch a song by its document ID from Sanity.
|
|
11
23
|
*
|
|
@@ -363,6 +375,7 @@ export async function fetchByRailContentId(id) {
|
|
|
363
375
|
* Fetch content by an array of Railcontent IDs.
|
|
364
376
|
*
|
|
365
377
|
* @param {Array<string>} ids - The array of Railcontent IDs of the content to fetch.
|
|
378
|
+
* @param {string} [contentType] - The content type the IDs to add needed fields to the response.
|
|
366
379
|
* @returns {Promise<Array<Object>|null>} - A promise that resolves to an array of content objects or null if not found.
|
|
367
380
|
*
|
|
368
381
|
* @example
|
|
@@ -370,18 +383,11 @@ export async function fetchByRailContentId(id) {
|
|
|
370
383
|
* .then(contents => console.log(contents))
|
|
371
384
|
* .catch(error => console.error(error));
|
|
372
385
|
*/
|
|
373
|
-
export async function fetchByRailContentIds(ids) {
|
|
386
|
+
export async function fetchByRailContentIds(ids, contentType = undefined) {
|
|
387
|
+
const fields = contentType ? DEFAULT_FIELDS.concat(contentTypeConfig?.[contentType]?.fields ?? []) : DEFAULT_FIELDS;
|
|
374
388
|
const idsString = ids.join(',');
|
|
375
389
|
const query = `*[railcontent_id in [${idsString}]]{
|
|
376
|
-
|
|
377
|
-
title,
|
|
378
|
-
"image": thumbnail.asset->url,
|
|
379
|
-
"artist_name": artist->name,
|
|
380
|
-
artist,
|
|
381
|
-
difficulty,
|
|
382
|
-
difficulty_string,
|
|
383
|
-
web_url_path,
|
|
384
|
-
published_on
|
|
390
|
+
${fields.join(', ')}
|
|
385
391
|
}`
|
|
386
392
|
return fetchSanity(query, true);
|
|
387
393
|
}
|
|
@@ -474,19 +480,7 @@ export async function fetchAll(brand, type, {
|
|
|
474
480
|
break;
|
|
475
481
|
}
|
|
476
482
|
|
|
477
|
-
let
|
|
478
|
-
'"id": railcontent_id',
|
|
479
|
-
'railcontent_id',
|
|
480
|
-
'"type": _type',
|
|
481
|
-
'title',
|
|
482
|
-
'"image": thumbnail.asset->url',
|
|
483
|
-
'difficulty',
|
|
484
|
-
'difficulty_string',
|
|
485
|
-
'web_url_path',
|
|
486
|
-
'published_on'
|
|
487
|
-
];
|
|
488
|
-
|
|
489
|
-
let fields = defaultFields.concat(additionalFields);
|
|
483
|
+
let fields = DEFAULT_FIELDS.concat(additionalFields);
|
|
490
484
|
let fieldsString = fields.join(',');
|
|
491
485
|
|
|
492
486
|
// Determine the group by clause
|