gerdur-core 2.10.0 → 2.11.0

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.11.0 - 2026-08-31
4
+
5
+ ### Added
6
+
7
+ - **`searchFacets(result)`** — flatten the per-type hit counts + Deezer's
8
+ relevance `order` out of a `searchMusic` result.
9
+
10
+ ### Internal
11
+
12
+ - The live-API test suite skips more gracefully when an upstream (Deezer public
13
+ REST, Tidal, YouTube) rate-limits or consent-walls the runner — the
14
+ `--> DEEZER` converter tests and YouTube tests now degrade to a skip instead
15
+ of a hard fail.
16
+
3
17
  ## 2.10.0 - 2026-08-31
4
18
 
5
19
  Leftovers — batch token refresh + podcast episodes. Additive.
package/README.md CHANGED
@@ -261,6 +261,16 @@ ignore the operators, so pass a plain string there.
261
261
  "as you type" UIs. `nb` (default 5) caps items per type. Needs an initialised
262
262
  session (`initDeezerApi`).
263
263
 
264
+ ### `.searchFacets(result)`
265
+
266
+ Flattens the per-type hit counts + Deezer's relevance `order` out of a
267
+ `searchMusic` result — for "207 tracks · 99 albums · 17 artists" UIs.
268
+
269
+ ```js
270
+ const r = await searchMusic('daft punk', ['TRACK', 'ALBUM', 'ARTIST']);
271
+ searchFacets(r); // {track: 207, album: 99, artist: 17, …, order: ['TOP_RESULT','TRACK',…]}
272
+ ```
273
+
264
274
  ### Browse & discovery
265
275
 
266
276
  Public REST endpoints — no `arl` needed, memoised like the rest. All return a
@@ -1,4 +1,4 @@
1
- import type { advancedSearchFilters, publicApiSearchOptions, publicApiSearchResponse, searchResultAlbum, searchResultArtist, searchResultPlaylist, searchResultTrack, suggestResult } from '../types';
1
+ import type { advancedSearchFilters, publicApiSearchOptions, publicApiSearchResponse, searchResultAlbum, searchResultArtist, searchResultPlaylist, searchResultTrack, searchType, suggestResult } from '../types';
2
2
  /**
3
3
  * Compose Deezer's advanced search operators into one query string.
4
4
  *
@@ -47,3 +47,21 @@ export declare const searchPlaylists: (query: string, options?: Omit<publicApiSe
47
47
  * @param nb max items per type (default 5)
48
48
  */
49
49
  export declare const suggest: (query: string, nb?: number) => Promise<suggestResult>;
50
+ /** Per-type total hit counts + Deezer's own relevance ordering, from a `searchMusic` result. */
51
+ export interface SearchFacets {
52
+ track: number;
53
+ album: number;
54
+ artist: number;
55
+ playlist: number;
56
+ radio: number;
57
+ show: number;
58
+ user: number;
59
+ /** the type order Deezer considers most relevant for this query, e.g. `['TOP_RESULT','ARTIST','TRACK',…]` */
60
+ order: string[];
61
+ }
62
+ /**
63
+ * Pull the facet counts out of a `searchMusic` (`deezer.pageSearch`) result —
64
+ * `pageSearch` already returns `TRACK.total`, `ALBUM.total`, … and an `ORDER`;
65
+ * this just surfaces them in one flat object for "N tracks · M albums · …" UIs.
66
+ */
67
+ export declare const searchFacets: (result: searchType) => SearchFacets;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.suggest = exports.searchPlaylists = exports.searchArtists = exports.searchAlbums = exports.searchTracks = exports.searchPublicApi = exports.buildAdvancedQuery = void 0;
3
+ exports.searchFacets = exports.suggest = exports.searchPlaylists = exports.searchArtists = exports.searchAlbums = exports.searchTracks = exports.searchPublicApi = exports.buildAdvancedQuery = void 0;
4
4
  const request_1 = require("./request");
5
5
  /**
6
6
  * Compose Deezer's advanced search operators into one query string.
@@ -108,3 +108,22 @@ const suggest = (query, nb = 5) => (0, request_1.requestLight)({
108
108
  TYPES: { ALBUM: true, ARTIST: true, TRACK: true, PLAYLIST: true, RADIO: true, SHOW: true },
109
109
  }, 'deezer.suggest');
110
110
  exports.suggest = suggest;
111
+ /**
112
+ * Pull the facet counts out of a `searchMusic` (`deezer.pageSearch`) result —
113
+ * `pageSearch` already returns `TRACK.total`, `ALBUM.total`, … and an `ORDER`;
114
+ * this just surfaces them in one flat object for "N tracks · M albums · …" UIs.
115
+ */
116
+ const searchFacets = (result) => {
117
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
118
+ return ({
119
+ track: (_b = (_a = result.TRACK) === null || _a === void 0 ? void 0 : _a.total) !== null && _b !== void 0 ? _b : 0,
120
+ album: (_d = (_c = result.ALBUM) === null || _c === void 0 ? void 0 : _c.total) !== null && _d !== void 0 ? _d : 0,
121
+ artist: (_f = (_e = result.ARTIST) === null || _e === void 0 ? void 0 : _e.total) !== null && _f !== void 0 ? _f : 0,
122
+ playlist: (_h = (_g = result.PLAYLIST) === null || _g === void 0 ? void 0 : _g.total) !== null && _h !== void 0 ? _h : 0,
123
+ radio: (_k = (_j = result.RADIO) === null || _j === void 0 ? void 0 : _j.total) !== null && _k !== void 0 ? _k : 0,
124
+ show: (_m = (_l = result.SHOW) === null || _l === void 0 ? void 0 : _l.total) !== null && _m !== void 0 ? _m : 0,
125
+ user: (_p = (_o = result.USER) === null || _o === void 0 ? void 0 : _o.total) !== null && _p !== void 0 ? _p : 0,
126
+ order: (_q = result.ORDER) !== null && _q !== void 0 ? _q : [],
127
+ });
128
+ };
129
+ exports.searchFacets = searchFacets;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gerdur-core",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "description": "Core module for gerdur.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",