musicbrainz-api 0.23.1 → 0.25.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/README.md CHANGED
@@ -111,7 +111,8 @@ The MusicBrainz API allows you to look up various entities. Here’s how to use
111
111
 
112
112
  ## Lookup MusicBrainz Entities
113
113
 
114
- MusicBrainz API documentation: [XML Web Service/Version 2 Lookups](https://wiki.musicbrainz.org/Development/XML_Web_Service/Version_2#Lookups)
114
+ You can use the lookup function, to look up an entity, when you have the MBID for that entity.
115
+ MusicBrainz API documentation: [MusicBrainz API - Lookups](https://wiki.musicbrainz.org/MusicBrainz_API#Lookups)
115
116
 
116
117
  ### Lookup Function
117
118
 
@@ -127,7 +128,7 @@ Arguments:
127
128
  #### Lookup URLs
128
129
 
129
130
  There is special method to lookup URL entity / entities by one, or an array of URLs
130
- ([MusicBrainz documentation](https://musicbrainz.org/doc/MusicBrainz_API#url_(by_text))):
131
+ ([MusicBrainz API documentation: url (by text)](https://musicbrainz.org/doc/MusicBrainz_API#url_(by_text))):
131
132
 
132
133
  ```js
133
134
  const urls = await mbApi.lookupUrl(['https://open.spotify.com/track/2AMysGXOe0zzZJMtH3Nizb', 'https://open.spotify.com/track/78Teboqh9lPIxWlIW5RMQL']);
@@ -136,7 +137,7 @@ const urls = await mbApi.lookupUrl(['https://open.spotify.com/track/2AMysGXOe0zz
136
137
  or
137
138
 
138
139
  ```js
139
- const url = await mbApi.lookupUrl('https://open.spotify.com/track/2AMysGXOe0zzZJMtH3Nizb']);
140
+ const url = await mbApi.lookupUrl('https://open.spotify.com/track/2AMysGXOe0zzZJMtH3Nizb');
140
141
  ```
141
142
 
142
143
  Arguments:
@@ -145,11 +146,29 @@ Arguments:
145
146
 
146
147
  Note that the return type is different, depending on if a single URL or an array of URLs is provided.
147
148
 
149
+ ## Browse requests
150
+ Browse requests are a direct lookup of all the entities directly linked to another entity ("directly linked" here meaning it does not include entities linked by a relationship).
151
+
152
+ For example, browse _releases_:
153
+ ```js
154
+
155
+ const artist_mbid = 'ab2528d9-719f-4261-8098-21849222a0f2';
156
+
157
+ const releases = await mbApi.browse('release', {
158
+ track_artist: artist_mbid,
159
+ limit: 0,
160
+ offset: 0,
161
+ }, ['url-rels', 'isrcs', 'recordings']);
162
+ ```
163
+
164
+ For the optional include arguments (`string[]`), see [Include arguments](#include-arguments).
165
+
148
166
  ### Browse artist
149
167
 
150
168
  ```js
151
169
  const artists = await mbApi.browse('artist', query);
152
- ````
170
+ const artists = await mbApi.browse('artist', query, ['area', 'collection']);
171
+ ```
153
172
 
154
173
  | Query argument | Query value |
155
174
  |-----------------------|--------------------|
@@ -163,7 +182,8 @@ const artists = await mbApi.browse('artist', query);
163
182
  ### Browse collection
164
183
  ```js
165
184
  const collections = await mbApi.browse('collection', query);
166
- ````
185
+ const collections = await mbApi.browse('collection', query, ['area', 'artist']);
186
+ ```
167
187
 
168
188
  | Query argument | Query value |
169
189
  |-----------------------|--------------------|
@@ -181,7 +201,8 @@ const collections = await mbApi.browse('collection', query);
181
201
  ### Browse events
182
202
  ```js
183
203
  const events = await mbApi.browse('event', query);
184
- ````
204
+ const events = await mbApi.browse('instrument', query, ['area', 'artist']);
205
+ ```
185
206
 
186
207
  | Query argument | Query value |
187
208
  |-----------------------|-----------------|
@@ -192,8 +213,9 @@ const events = await mbApi.browse('event', query);
192
213
 
193
214
  ### Browse instruments
194
215
  ```js
195
- const instruments = await mbApi.browse('event', query);
196
- ````
216
+ const instruments = await mbApi.browse('instrument', query);
217
+ const instruments = await mbApi.browse('instrument', query, ['collection']);
218
+ ```
197
219
 
198
220
  | Query argument | Query value |
199
221
  |-----------------------|--------------------|
@@ -202,7 +224,8 @@ const instruments = await mbApi.browse('event', query);
202
224
  ### Browse labels
203
225
  ```js
204
226
  const labels = await mbApi.browse('label', query);
205
- ````
227
+ const places = await mbApi.browse('place', query, ['area', 'collection']);
228
+ ```
206
229
 
207
230
  | Query argument | Query value |
208
231
  |--------------------|-----------------|
@@ -213,7 +236,8 @@ const labels = await mbApi.browse('label', query);
213
236
  ### Browse places
214
237
  ```js
215
238
  const places = await mbApi.browse('place', query);
216
- ````
239
+ const places = await mbApi.browse('place', query, ['area', 'collection']);
240
+ ```
217
241
 
218
242
  | Query argument | Query value |
219
243
  |--------------------|-----------------|
@@ -222,8 +246,8 @@ const places = await mbApi.browse('place', query);
222
246
 
223
247
  ### Browse recordings
224
248
  ```js
225
- const recordings = await mbApi.browse('recording', query);
226
- ````
249
+ const recordings = await mbApi.browse('recording', query, ['artist']);
250
+ ```
227
251
 
228
252
  | Query argument | Query value |
229
253
  |--------------------|-----------------|
@@ -235,7 +259,8 @@ const recordings = await mbApi.browse('recording', query);
235
259
  ### Browse releases
236
260
  ```js
237
261
  const releases = await mbApi.browse('release', query);
238
- ````
262
+ const releases = await mbApi.browse('release', query, ['artist', 'track']);
263
+ ```
239
264
 
240
265
  | Query argument | Query value |
241
266
  |-----------------------|--------------------|
@@ -252,7 +277,8 @@ const releases = await mbApi.browse('release', query);
252
277
 
253
278
  ### Browse release-groups
254
279
  ```js
255
- const releaseGroups = await mbApi.browse('release-group',query);
280
+ const releaseGroups = await mbApi.browse('release-group', query);
281
+ const releaseGroups = await mbApi.browse('release-group', query, ['artist', 'release']);
256
282
  ```
257
283
 
258
284
  | Query argument | Query value |
@@ -264,7 +290,8 @@ const releaseGroups = await mbApi.browse('release-group',query);
264
290
  ### Browse series
265
291
  ```js
266
292
  const series = await mbApi.browse('series');
267
- ````
293
+ const series = await mbApi.browse('series', ['collection']);
294
+ ```
268
295
 
269
296
  | Query argument | Query value |
270
297
  |-----------------------|--------------------|
@@ -282,7 +309,8 @@ const series = await mbApi.browse('series');
282
309
  ### Browse works
283
310
  ```js
284
311
  const works = await mbApi.browse('work');
285
- ````
312
+ const series = await mbApi.browse('series', ['artist', 'collection']);
313
+ ```
286
314
 
287
315
  | Query argument | Query value |
288
316
  |--------------------|-----------------|
@@ -292,7 +320,8 @@ const works = await mbApi.browse('work');
292
320
  ### Browse urls
293
321
  ```js
294
322
  const urls = await mbApi.browse('url');
295
- ````
323
+ const series = await mbApi.browse('series', ['artist', 'collection', 'artist-rels']);
324
+ ```
296
325
 
297
326
  | Query argument | Query value |
298
327
  |--------------------|-----------------|
@@ -301,7 +330,7 @@ const urls = await mbApi.browse('url');
301
330
 
302
331
  ## Search (query)
303
332
 
304
- Implements [XML Web Service/Version 2/Search](https://wiki.musicbrainz.org/Development/XML_Web_Service/Version_2/Search).
333
+ Implements [MusicBrainz API: Search](https://wiki.musicbrainz.org/MusicBrainz_API/Search).
305
334
 
306
335
  There are different search fields depending on the entity.
307
336
 
@@ -311,14 +340,21 @@ Searches can be performed using the generic search function: `query(entity: mb.E
311
340
 
312
341
  Arguments:
313
342
  - Entity type, which can be one of:
314
- - `artist`: [search fields](https://wiki.musicbrainz.org/Development/XML_Web_Service/Version_2/Search#Artist)
315
- - `label`: [search fields](https://wiki.musicbrainz.org/Development/XML_Web_Service/Version_2/Search#Label)
316
- - `recording`: [search fields](https://wiki.musicbrainz.org/Development/XML_Web_Service/Version_2/Search#Recording)
317
- - `release`: [search fields](https://wiki.musicbrainz.org/Development/XML_Web_Service/Version_2/Search#Release)
318
- - `release-group`: [search fields](https://wiki.musicbrainz.org/Development/XML_Web_Service/Version_2/Search#Release_Group)
319
- - `work`: [search fields](https://wiki.musicbrainz.org/Development/XML_Web_Service/Version_2/Search#Work)
320
- - `area`: [search fields](https://wiki.musicbrainz.org/Development/XML_Web_Service/Version_2/Search#Area)
321
- - `url`: [search fields](https://wiki.musicbrainz.org/Development/XML_Web_Service/Version_2/Search#URL)
343
+ - `annotation`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#Annotation)
344
+ - `area`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#Area)
345
+ - `artist`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#Artist)
346
+ - `cdstub`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#CDStubs)
347
+ - `event`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#Event)
348
+ - `instrument`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#Instrument)
349
+ - `label`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#Label)
350
+ - `place`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#Place)
351
+ - `recording`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#Recording)
352
+ - `release`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#Release)
353
+ - `release-group`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#Release_Group)
354
+ - `series`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#Series)
355
+ - `tag`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#Tag)
356
+ - `url`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#URL)
357
+ - `work`: [search fields](https://wiki.musicbrainz.org/MusicBrainz_API/Search#Work)
322
358
  - `query {query: string, offset: number, limit: number}`
323
359
  - `query.query`: supports the full Lucene Search syntax; you can find a detailed guide at [Lucene Search Syntax](https://lucene.apache.org/core/4_3_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description). For example, you can set conditions while searching for a name with the AND operator.
324
360
  - `query.offset`: optional, return search results starting at a given offset. Used for paging through more than one page of results.
@@ -334,21 +370,21 @@ const result = await mbApi.search('release-group', {query});
334
370
 
335
371
  ```js
336
372
  mbApi.search('area', 'Île-de-France');
337
- ````
373
+ ```
338
374
 
339
375
  ##### Example: search release by barcode
340
376
 
341
377
  Search a release with the barcode 602537479870:
342
378
  ```js
343
379
  mbApi.search('release', {query: {barcode: 602537479870}});
344
- ````
380
+ ```
345
381
 
346
382
  ##### Example: search by object
347
383
 
348
384
  Same as previous example, but automatically serialize parameters to search query
349
385
  ```js
350
386
  mbApi.search('release', 'barcode: 602537479870');
351
- ````
387
+ ```
352
388
 
353
389
  ##### Example: search artist by artist name
354
390
 
@@ -443,9 +479,9 @@ As such, keep in mind requesting "artist-rels" for an artist, "release-rels" for
443
479
  In a release request, you might also be interested on relationships for the recordings linked to the release, or the release group linked to the release, or even for the works linked to those recordings that are linked to the release (for example, to find out who played guitar on a specific track, who wrote the lyrics for the song being performed, or whether the release group is part of a series). Similarly, for a recording request, you might want to get the relationships for any linked works.
444
480
  There are three additional includes for this:
445
481
 
446
- - recording-level-rels
447
- - release-group-level-rels (for releases only)
448
- - work-level-rels
482
+ - `recording-level-rels`
483
+ - `release-group-level-rels` (for releases only)
484
+ - `work-level-rels`
449
485
 
450
486
  # Submitting data via XML POST
451
487
 
@@ -1,11 +1,11 @@
1
- export { XmlMetadata } from './xml/xml-metadata.js';
2
- export { XmlIsrc } from './xml/xml-isrc.js';
3
- export { XmlIsrcList } from './xml/xml-isrc-list.js';
4
- export { XmlRecording } from './xml/xml-recording.js';
5
1
  import type { XmlMetadata } from './xml/xml-metadata.js';
6
2
  import { RateLimitThreshold } from 'rate-limit-threshold';
7
3
  import * as mb from './musicbrainz.types.js';
8
4
  import { HttpClient, type MultiQueryFormData } from "./http-client.js";
5
+ export { XmlMetadata } from './xml/xml-metadata.js';
6
+ export { XmlIsrc } from './xml/xml-isrc.js';
7
+ export { XmlIsrcList } from './xml/xml-isrc-list.js';
8
+ export { XmlRecording } from './xml/xml-recording.js';
9
9
  export * from './musicbrainz.types.js';
10
10
  export type RelationsIncludes = 'area-rels' | 'artist-rels' | 'event-rels' | 'instrument-rels' | 'label-rels' | 'place-rels' | 'recording-rels' | 'release-rels' | 'release-group-rels' | 'series-rels' | 'url-rels' | 'work-rels';
11
11
  export type SubQueryIncludes =
@@ -90,7 +90,7 @@ export declare class MusicBrainzApi {
90
90
  * Lookup entity
91
91
  * @param entity 'area', 'artist', collection', 'instrument', 'label', 'place', 'release', 'release-group', 'recording', 'series', 'work', 'url' or 'event'
92
92
  * @param mbid Entity MBID
93
- * @param inc Query, like: {<entity>: <MBID:}
93
+ * @param inc Includes, which allows you to request more information to be included about the entity
94
94
  */
95
95
  lookup(entity: 'area', mbid: string, inc?: AreaIncludes[]): Promise<mb.IArea>;
96
96
  lookup(entity: 'artist', mbid: string, inc?: ArtistIncludes[]): Promise<mb.IArtist>;
@@ -115,32 +115,41 @@ export declare class MusicBrainzApi {
115
115
  * For example: http://musicbrainz.org/ws/2/release?label=47e718e1-7ee4-460c-b1cc-1192a841c6e5&offset=12&limit=2
116
116
  * @param entity MusicBrainz entity
117
117
  * @param query Query, like: {<entity>: <MBID:}
118
+ * @param inc Includes, which allows you to request more information to be included about the entity
118
119
  */
119
- browse(entity: 'area', query?: mb.IBrowseAreasQuery): Promise<mb.IBrowseAreasResult>;
120
- browse(entity: 'artist', query?: mb.IBrowseArtistsQuery): Promise<mb.IBrowseArtistsResult>;
121
- browse(entity: 'collection', query?: mb.IBrowseCollectionsQuery): Promise<mb.IBrowseCollectionsResult>;
122
- browse(entity: 'event', query?: mb.IBrowseEventsQuery): Promise<mb.IBrowseEventsResult>;
123
- browse(entity: 'label', query?: mb.IBrowseLabelsQuery): Promise<mb.IBrowseLabelsResult>;
124
- browse(entity: 'instrument', query?: mb.IBrowseInstrumentsQuery): Promise<mb.IBrowseInstrumentsResult>;
125
- browse(entity: 'place', query?: mb.IBrowsePlacesQuery): Promise<mb.IBrowsePlacesResult>;
126
- browse(entity: 'recording', query?: mb.IBrowseRecordingsQuery): Promise<mb.IBrowseRecordingsResult>;
127
- browse(entity: 'release', query?: mb.IBrowseReleasesQuery): Promise<mb.IBrowseReleasesResult>;
128
- browse(entity: 'release-group', query?: mb.IBrowseReleaseGroupsQuery): Promise<mb.IBrowseReleaseGroupsResult>;
129
- browse(entity: 'series', query?: mb.IBrowseSeriesQuery): Promise<mb.IBrowseSeriesResult>;
130
- browse(entity: 'url', query?: mb.IBrowseUrlsQuery): Promise<mb.IUrl>;
131
- browse(entity: 'work', query?: mb.IBrowseWorksQuery): Promise<mb.IBrowseWorksResult>;
120
+ browse(entity: 'area', query?: mb.IBrowseAreasQuery, inc?: AreaIncludes[]): Promise<mb.IBrowseAreasResult>;
121
+ browse(entity: 'artist', query?: mb.IBrowseArtistsQuery, inc?: ArtistIncludes[]): Promise<mb.IBrowseArtistsResult>;
122
+ browse(entity: 'collection', query?: mb.IBrowseCollectionsQuery, inc?: CollectionIncludes[]): Promise<mb.IBrowseCollectionsResult>;
123
+ browse(entity: 'event', query?: mb.IBrowseEventsQuery, inc?: EventIncludes[]): Promise<mb.IBrowseEventsResult>;
124
+ browse(entity: 'label', query?: mb.IBrowseLabelsQuery, inc?: LabelIncludes[]): Promise<mb.IBrowseLabelsResult>;
125
+ browse(entity: 'instrument', query?: mb.IBrowseInstrumentsQuery, inc?: InstrumentIncludes[]): Promise<mb.IBrowseInstrumentsResult>;
126
+ browse(entity: 'place', query?: mb.IBrowsePlacesQuery, inc?: PlaceIncludes[]): Promise<mb.IBrowsePlacesResult>;
127
+ browse(entity: 'recording', query?: mb.IBrowseRecordingsQuery, inc?: RecordingIncludes[]): Promise<mb.IBrowseRecordingsResult>;
128
+ browse(entity: 'release', query?: mb.IBrowseReleasesQuery, inc?: ReleaseIncludes[]): Promise<mb.IBrowseReleasesResult>;
129
+ browse(entity: 'release-group', query?: mb.IBrowseReleaseGroupsQuery, inc?: ReleaseGroupIncludes[]): Promise<mb.IBrowseReleaseGroupsResult>;
130
+ browse(entity: 'series', query?: mb.IBrowseSeriesQuery, inc?: SeriesIncludes[]): Promise<mb.IBrowseSeriesResult>;
131
+ browse(entity: 'url', query?: mb.IBrowseUrlsQuery, inc?: UrlIncludes[]): Promise<mb.IUrl>;
132
+ browse(entity: 'work', query?: mb.IBrowseWorksQuery, inc?: WorkIncludes[]): Promise<mb.IBrowseWorksResult>;
132
133
  /**
133
134
  * Search an entity using a search query
134
- * @param query e.g.: '" artist: Madonna, track: Like a virgin"' or object with search terms: {artist: Madonna}
135
135
  * @param entity e.g. 'recording'
136
- * @param query Arguments
136
+ * @param query e.g.: '" artist: Madonna, track: Like a virgin"' or object with search terms: {artist: Madonna}
137
137
  */
138
+ search(entity: 'annotation', query: mb.ISearchQuery<(MiscIncludes | RelationsIncludes)>): Promise<mb.IAnnotationList>;
138
139
  search(entity: 'area', query: mb.ISearchQuery<AreaIncludes> & mb.ILinkedEntitiesArea): Promise<mb.IAreaList>;
139
- search(artist: 'artist', query: mb.ISearchQuery<ArtistIncludes> & mb.ILinkedEntitiesArea): Promise<mb.IArtistList>;
140
- search(artist: 'recording', query: mb.ISearchQuery<AreaIncludes> & mb.ILinkedEntitiesArea): Promise<mb.IRecordingList>;
141
- search(artist: 'release', query: mb.ISearchQuery<ReleaseIncludes> & mb.ILinkedEntitiesArea): Promise<mb.IReleaseList>;
142
- search(artist: 'release-group', query: mb.ISearchQuery<ReleaseGroupIncludes> & mb.ILinkedEntitiesArea): Promise<mb.IReleaseGroupList>;
143
- search(artist: 'url', query: mb.ISearchQuery<UrlIncludes> & mb.ILinkedEntitiesArea): Promise<mb.IUrlList>;
140
+ search(entity: 'artist', query: mb.ISearchQuery<ArtistIncludes> & mb.ILinkedEntitiesArea): Promise<mb.IArtistList>;
141
+ search(entity: 'cdstub', query: mb.ISearchQuery<(MiscIncludes | RelationsIncludes)>): Promise<mb.ICdStubList>;
142
+ search(entity: 'event', query: mb.ISearchQuery<EventIncludes> & mb.ILinkedEntitiesEvent): Promise<mb.IEventList>;
143
+ search(entity: 'instrument', query: mb.ISearchQuery<InstrumentIncludes> & mb.ILinkedEntitiesInstrument): Promise<mb.IInstrumentList>;
144
+ search(entity: 'label', query: mb.ISearchQuery<LabelIncludes> & mb.ILinkedEntitiesLabel): Promise<mb.ILabelList>;
145
+ search(entity: 'place', query: mb.ISearchQuery<PlaceIncludes> & mb.ILinkedEntitiesPlace): Promise<mb.IPlaceList>;
146
+ search(entity: 'recording', query: mb.ISearchQuery<RecordingIncludes> & mb.ILinkedEntitiesArea): Promise<mb.IRecordingList>;
147
+ search(entity: 'release', query: mb.ISearchQuery<ReleaseIncludes> & mb.ILinkedEntitiesArea): Promise<mb.IReleaseList>;
148
+ search(entity: 'release-group', query: mb.ISearchQuery<ReleaseGroupIncludes> & mb.ILinkedEntitiesArea): Promise<mb.IReleaseGroupList>;
149
+ search(entity: 'series', query: mb.ISearchQuery<SeriesIncludes> & mb.ILinkedEntitiesSeries): Promise<mb.ISeriesList>;
150
+ search(entity: 'tag', query: mb.ISearchQuery<MiscIncludes | RelationsIncludes>): Promise<mb.ITagList>;
151
+ search(entity: 'url', query: mb.ISearchQuery<UrlIncludes> & mb.ILinkedEntitiesUrl): Promise<mb.IUrlList>;
152
+ search(entity: 'work', query: mb.ISearchQuery<WorkIncludes> & mb.ILinkedEntitiesWork): Promise<mb.IWorkList>;
144
153
  postRecording(xmlMetadata: XmlMetadata): Promise<void>;
145
154
  post(entity: mb.EntityType, xmlMetadata: XmlMetadata): Promise<void>;
146
155
  /**
@@ -1,13 +1,13 @@
1
1
  import { StatusCodes as HttpStatus } from 'http-status-codes';
2
2
  import Debug from 'debug';
3
- export { XmlMetadata } from './xml/xml-metadata.js';
4
- export { XmlIsrc } from './xml/xml-isrc.js';
5
- export { XmlIsrcList } from './xml/xml-isrc-list.js';
6
- export { XmlRecording } from './xml/xml-recording.js';
7
3
  import { DigestAuth } from './digest-auth.js';
8
4
  import { RateLimitThreshold } from 'rate-limit-threshold';
9
5
  import * as mb from './musicbrainz.types.js';
10
6
  import { HttpClient } from "./http-client.js";
7
+ export { XmlMetadata } from './xml/xml-metadata.js';
8
+ export { XmlIsrc } from './xml/xml-isrc.js';
9
+ export { XmlIsrcList } from './xml/xml-isrc-list.js';
10
+ export { XmlRecording } from './xml/xml-recording.js';
11
11
  export * from './musicbrainz.types.js';
12
12
  const debug = Debug('musicbrainz-api');
13
13
  export class MusicBrainzApi {
@@ -60,16 +60,20 @@ export class MusicBrainzApi {
60
60
  async lookupUrl(url, inc = []) {
61
61
  const result = await this.restGet('/url', { resource: url, inc: inc.join(' ') });
62
62
  if (Array.isArray(url) && url.length <= 1) {
63
- const searchResult = {
63
+ return {
64
64
  'url-count': 1,
65
65
  'url-offset': 0,
66
66
  urls: [result],
67
67
  };
68
- return searchResult;
69
68
  }
70
69
  return result;
71
70
  }
72
- browse(entity, query) {
71
+ browse(entity, query, inc) {
72
+ query = query ? query : {};
73
+ if (inc) {
74
+ // Serialize include parameter
75
+ query.inc = inc.join(' ');
76
+ }
73
77
  return this.restGet(`/${entity}`, query);
74
78
  }
75
79
  search(entity, query) {
@@ -18,6 +18,12 @@ export interface LifeSpan {
18
18
  begin: null | string;
19
19
  end: null | string;
20
20
  }
21
+ export interface IAnnotation {
22
+ entity: string;
23
+ name: string;
24
+ text: string;
25
+ type: string;
26
+ }
21
27
  export interface IArea extends ITypedEntity {
22
28
  type: 'Country' | 'Subdivision' | 'Municipality' | 'City' | 'District' | 'Island';
23
29
  'iso-3166-1-codes'?: string[];
@@ -61,6 +67,13 @@ export interface IArtist extends ITypedEntity {
61
67
  releases?: IRelease[];
62
68
  'release-groups'?: IReleaseGroup[];
63
69
  }
70
+ export interface ICdStub {
71
+ id: string;
72
+ title: string;
73
+ artist: string;
74
+ barcode: string;
75
+ comment: string;
76
+ }
64
77
  export interface IArtistCredit {
65
78
  artist: IArtist;
66
79
  joinphrase: string;
@@ -115,6 +128,7 @@ export interface IRelease extends IEntity {
115
128
  'release-group'?: IReleaseGroup;
116
129
  collections?: ICollection[];
117
130
  'track-count'?: number;
131
+ count?: number;
118
132
  }
119
133
  export interface IReleaseEvent {
120
134
  area?: IArea;
@@ -174,42 +188,73 @@ export interface IReleaseGroup extends IEntity {
174
188
  }[];
175
189
  releases?: IRelease[];
176
190
  }
177
- export interface IAreaMatch extends IArea, IMatch {
178
- }
179
- export interface IArtistMatch extends IArtist, IMatch {
180
- }
181
- export interface IRecordingMatch extends IRecording, IMatch {
182
- }
183
- export interface IReleaseGroupMatch extends IReleaseGroup, IMatch {
184
- }
185
- export interface IReleaseMatch extends IRelease, IMatch {
186
- count: number;
187
- }
188
191
  export interface ISearchResult {
189
192
  created: DateTimeFormat;
190
193
  count: number;
191
194
  offset: number;
192
195
  }
193
- export interface IArtistList extends ISearchResult {
194
- artists: IArtistMatch[];
196
+ export type IAnnotationMatch = IAnnotation & IMatch;
197
+ export interface IAnnotationList extends ISearchResult {
198
+ annotations: IAnnotationMatch[];
195
199
  }
200
+ export type IAreaMatch = IArea & IMatch;
196
201
  export interface IAreaList extends ISearchResult {
197
202
  areas: IAreaMatch[];
198
203
  }
204
+ export type IArtistMatch = IArtist & IMatch;
205
+ export interface IArtistList extends ISearchResult {
206
+ artists: IArtistMatch[];
207
+ }
208
+ export type ICdStubMatch = ICdStub & IMatch;
209
+ export interface ICdStubList extends ISearchResult {
210
+ cdstubs: ICdStubMatch[];
211
+ }
212
+ export type IEventMatch = IEvent & IMatch;
213
+ export interface IEventList extends ISearchResult {
214
+ events: IEventMatch[];
215
+ }
216
+ export type IInstrumentMatch = IInstrument & IMatch;
217
+ export interface IInstrumentList extends ISearchResult {
218
+ instruments: IInstrumentMatch[];
219
+ }
220
+ export type ILabelMatch = ILabel & IMatch;
221
+ export interface ILabelList extends ISearchResult {
222
+ labels: ILabelMatch[];
223
+ }
224
+ export type IPlacesMatch = IPlace & IMatch;
225
+ export interface IPlaceList extends ISearchResult {
226
+ places: IPlacesMatch[];
227
+ }
228
+ export type IReleaseMatch = IRelease & IMatch;
199
229
  export interface IReleaseList extends ISearchResult {
200
230
  releases: IReleaseMatch[];
201
231
  'release-count': number;
202
232
  }
233
+ export type IRecordingMatch = IRecording & IMatch;
203
234
  export interface IRecordingList extends ISearchResult {
204
235
  recordings: IRecordingMatch[];
205
236
  'recordings-count': number;
206
237
  }
238
+ export type IReleaseGroupMatch = IReleaseGroup & IMatch;
207
239
  export interface IReleaseGroupList extends ISearchResult {
208
240
  'release-groups': IReleaseGroupMatch[];
209
241
  }
242
+ export type ISeriesGroupMatch = ISeries & IMatch;
243
+ export interface ISeriesList extends ISearchResult {
244
+ series: ISeriesGroupMatch[];
245
+ }
246
+ export type ITagMatch = ITag & IMatch;
247
+ export interface ITagList extends ISearchResult {
248
+ tags: ITagMatch[];
249
+ }
250
+ export type IUrlMatch = IUrl & IMatch;
210
251
  export interface IUrlList extends ISearchResult {
211
252
  urls: IUrlMatch[];
212
253
  }
254
+ export type IWorkMatch = IWork & IMatch;
255
+ export interface IWorkList extends ISearchResult {
256
+ works: IWorkMatch[];
257
+ }
213
258
  export type RelationDirection = 'backward' | 'forward';
214
259
  export interface IRelation {
215
260
  artist?: IArtist;
@@ -253,30 +298,28 @@ export interface ISeries extends ITypedEntity {
253
298
  name: string;
254
299
  disambiguation: string;
255
300
  }
301
+ export interface ITag {
302
+ name: string;
303
+ }
256
304
  export interface IUrl extends IEntity {
257
305
  id: string;
258
306
  resource: string;
259
307
  relations?: IRelationList[];
260
308
  }
261
- export interface IUrlMatch extends IMatch, IUrl {
262
- }
263
- export interface IUrlSearchResult extends ISearchResult {
264
- urls: IUrlMatch[];
265
- }
266
- export interface IIsrcSearchResult extends ISearchResult {
267
- 'isrc': string;
268
- 'recordings': IRecording[];
269
- }
270
309
  export interface IExernalIds {
271
310
  [type: string]: string;
272
311
  }
273
312
  export interface IReleaseSearchResult extends ISearchResult {
274
313
  releases: IRelease[];
275
314
  }
315
+ /**
316
+ * Entities without MBID
317
+ */
318
+ export type OtherEntityTypes = 'annotation' | 'cdstub' | 'tag';
276
319
  /**
277
320
  * https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2#Subqueries
278
321
  */
279
- export type EntityType = 'area' | 'artist' | 'collection' | 'event' | 'instrument' | 'label' | 'place' | 'recording' | 'release' | 'release-group' | 'series' | 'work' | 'url';
322
+ export type EntityType = 'annotation' | 'area' | 'artist' | 'collection' | 'event' | 'instrument' | 'label' | 'place' | 'recording' | 'release' | 'release-group' | 'series' | 'work' | 'url';
280
323
  export type Relationships = 'area-rels' | 'artist-rels' | 'event-rels' | 'instrument-rels' | 'label-rels' | 'place-rels' | 'recording-rels' | 'release-rels' | 'release-group-rels' | 'series-rels' | 'url-rels' | 'work-rels';
281
324
  export declare enum LinkType {
282
325
  license = 302,
@@ -375,6 +418,13 @@ export interface ILinkedEntitiesLabel {
375
418
  collection?: string;
376
419
  release?: string;
377
420
  }
421
+ /**
422
+ * https://musicbrainz.org/doc/MusicBrainz_API#Subqueries
423
+ * /ws/2/place area, collection, release
424
+ */
425
+ export interface ILinkedEntitiesPlace {
426
+ place?: string;
427
+ }
378
428
  /**
379
429
  * https://musicbrainz.org/doc/MusicBrainz_API#Subqueries
380
430
  * /ws/2/place area, collection
@@ -438,131 +488,147 @@ export interface ILinkedEntitiesWork {
438
488
  export interface ILinkedEntitiesUrl {
439
489
  resource?: string;
440
490
  }
491
+ export type OneOf<T> = {
492
+ [K in keyof T]: {
493
+ [P in K]: T[K];
494
+ } & Partial<Record<Exclude<keyof T, K>, never>>;
495
+ }[keyof T];
441
496
  /**
442
- * Browse artist query <entity>: <MBID>
443
- * https://wiki.musicbrainz.org/MusicBrainz_API#Linked_entities
497
+ * List of entity names allowed for browsing releases by a single MBID.
498
+ * Used as a key set for constructing exclusive query types.
444
499
  */
445
- export interface IBrowseAreasQuery extends IPagination {
446
- collection?: string;
447
- }
500
+ interface BrowseReleasesEntityParams {
501
+ area: string;
502
+ artist: string;
503
+ editor: string;
504
+ event: string;
505
+ label: string;
506
+ place: string;
507
+ recording: string;
508
+ release: string;
509
+ 'release-group': string;
510
+ track_artist: string;
511
+ work: string;
512
+ }
513
+ export type IBrowseReleasesQuery = IPagination & OneOf<BrowseReleasesEntityParams>;
448
514
  /**
449
- * Browse artist query <entity>: <MBID>
450
- * https://wiki.musicbrainz.org/MusicBrainz_API#Linked_entities
515
+ * List of entity names allowed for browsing artists by a single MBID.
516
+ * Used as a key set for constructing exclusive query types.
451
517
  */
452
- export interface IBrowseArtistsQuery extends IPagination {
453
- area?: string;
454
- collection?: string;
455
- recording?: string;
456
- release?: string;
457
- 'release-group'?: string;
458
- work?: string;
459
- }
518
+ interface BrowseArtistsEntityParams {
519
+ area: string;
520
+ collection: string;
521
+ recording: string;
522
+ release: string;
523
+ 'release-group': string;
524
+ work: string;
525
+ }
526
+ export type IBrowseArtistsQuery = IPagination & OneOf<BrowseArtistsEntityParams>;
460
527
  /**
461
- * Browse collection query <entity>: <MBID>
462
- * https://wiki.musicbrainz.org/MusicBrainz_API#Linked_entities
528
+ * List of entity names allowed for browsing collections by a single MBID.
529
+ * Used as a key set for constructing exclusive query types.
463
530
  */
464
- export interface IBrowseCollectionsQuery extends IPagination {
465
- area?: string;
466
- artist?: string;
467
- editor?: string;
468
- event?: string;
469
- label?: string;
470
- place?: string;
471
- recording?: string;
472
- release?: string;
473
- 'release-group'?: string;
474
- work?: string;
531
+ interface BrowseCollectionsEntityParams {
532
+ area: string;
533
+ artist: string;
534
+ editor: string;
535
+ event: string;
536
+ label: string;
537
+ place: string;
538
+ recording: string;
539
+ release: string;
540
+ 'release-group': string;
541
+ work: string;
542
+ }
543
+ export type IBrowseCollectionsQuery = IPagination & OneOf<BrowseCollectionsEntityParams>;
544
+ /**
545
+ * List of entity names allowed for browsing events by a single MBID.
546
+ * Used as a key set for constructing exclusive query types.
547
+ */
548
+ interface BrowseEventsEntityParams {
549
+ area: string;
550
+ artist: string;
551
+ collection: string;
552
+ place: string;
475
553
  }
554
+ export type IBrowseEventsQuery = IPagination & OneOf<BrowseEventsEntityParams>;
476
555
  /**
477
- * Browse events query <entity>: <MBID>
478
- * https://wiki.musicbrainz.org/MusicBrainz_API#Linked_entities
556
+ * List of entity names allowed for browsing labels by a single MBID.
557
+ * Used as a key set for constructing exclusive query types.
479
558
  */
480
- export interface IBrowseEventsQuery extends IPagination {
481
- area?: string;
482
- artist?: string;
483
- collection?: string;
484
- place?: string;
559
+ interface BrowseLabelsEntityParams {
560
+ area: string;
561
+ collection: string;
562
+ release: string;
485
563
  }
564
+ export type IBrowseLabelsQuery = IPagination & OneOf<BrowseLabelsEntityParams>;
486
565
  /**
487
- * Browse instruments query <entity>: <MBID>
488
- * https://wiki.musicbrainz.org/MusicBrainz_API#Linked_entities
566
+ * List of entity names allowed for browsing places by a single MBID.
567
+ * Used as a key set for constructing exclusive query types.
489
568
  */
490
- export interface IBrowseInstrumentsQuery extends IPagination {
491
- collection?: string;
569
+ interface BrowsePlacesEntityParams {
570
+ area: string;
571
+ collection: string;
492
572
  }
573
+ export type IBrowsePlacesQuery = IPagination & OneOf<BrowsePlacesEntityParams>;
493
574
  /**
494
- * Browse labels query <entity>: <MBID>
495
- * https://wiki.musicbrainz.org/MusicBrainz_API#Linked_entities
575
+ * List of entity names allowed for browsing recordings by a single MBID.
576
+ * Used as a key set for constructing exclusive query types.
496
577
  */
497
- export interface IBrowseLabelsQuery extends IPagination {
498
- area?: string;
499
- collection?: string;
500
- release?: string;
578
+ interface BrowseRecordingsEntityParams {
579
+ artist: string;
580
+ collection: string;
581
+ release: string;
582
+ work: string;
501
583
  }
584
+ export type IBrowseRecordingsQuery = IPagination & OneOf<BrowseRecordingsEntityParams>;
502
585
  /**
503
- * Browse places query <entity>: <MBID>
504
- * https://wiki.musicbrainz.org/MusicBrainz_API#Linked_entities
586
+ * List of entity names allowed for browsing release-groups by a single MBID.
587
+ * Used as a key set for constructing exclusive query types.
505
588
  */
506
- export interface IBrowsePlacesQuery extends IPagination {
507
- area?: string;
508
- collection?: string;
589
+ interface BrowseReleaseGroupsEntityParams {
590
+ artist: string;
591
+ collection: string;
592
+ release: string;
509
593
  }
594
+ export type IBrowseReleaseGroupsQuery = IPagination & OneOf<BrowseReleaseGroupsEntityParams>;
510
595
  /**
511
- * Browse recordings query <entity>: <MBID>
512
- * https://wiki.musicbrainz.org/MusicBrainz_API#Linked_entities
596
+ * List of entity names allowed for browsing works by a single MBID.
597
+ * Used as a key set for constructing exclusive query types.
513
598
  */
514
- export interface IBrowseRecordingsQuery extends IPagination {
515
- artist?: string;
516
- collection?: string;
517
- release?: string;
518
- work?: string;
599
+ interface BrowseWorksEntityParams {
600
+ artist: string;
601
+ collection: string;
519
602
  }
603
+ export type IBrowseWorksQuery = IPagination & OneOf<BrowseWorksEntityParams>;
520
604
  /**
521
- * Browse releases query <entity>: <MBID>
605
+ * Query for browsing areas by collection MBID.
522
606
  * https://wiki.musicbrainz.org/MusicBrainz_API#Linked_entities
523
607
  */
524
- export interface IBrowseReleasesQuery extends IPagination {
525
- area?: string;
526
- artist?: string;
527
- editor?: string;
528
- event?: string;
529
- label?: string;
530
- place?: string;
531
- recording?: string;
532
- release?: string;
533
- 'release-group'?: string;
534
- work?: string;
608
+ export interface IBrowseAreasQuery extends IPagination {
609
+ collection?: string;
535
610
  }
536
611
  /**
537
- * Browse release-groups query <entity>: <MBID>
612
+ * Query for browsing instruments by collection MBID.
613
+ * https://wiki.musicbrainz.org/MusicBrainz_API#Linked_entities
538
614
  */
539
- export interface IBrowseReleaseGroupsQuery extends IPagination {
540
- artist?: string;
615
+ export interface IBrowseInstrumentsQuery extends IPagination {
541
616
  collection?: string;
542
- release?: string;
543
617
  }
544
618
  /**
545
- * Browse release query <entity>: <MBID>
619
+ * Query for browsing series by collection MBID.
546
620
  * https://wiki.musicbrainz.org/MusicBrainz_API#Linked_entities
547
621
  */
548
622
  export interface IBrowseSeriesQuery extends IPagination {
549
623
  collection?: string;
550
624
  }
551
625
  /**
552
- * Browse urls query <entity>: <MBID>
626
+ * Query for browsing URLs by resource URI.
553
627
  * https://wiki.musicbrainz.org/MusicBrainz_API#Linked_entities
554
628
  */
555
629
  export interface IBrowseUrlsQuery extends IPagination {
556
630
  resource?: string;
557
631
  }
558
- /**
559
- * Browse works query <entity>: <MBID>
560
- * https://wiki.musicbrainz.org/MusicBrainz_API#Linked_entities
561
- */
562
- export interface IBrowseWorksQuery extends IPagination {
563
- artist?: string;
564
- collection?: string;
565
- }
566
632
  export interface IBrowseAreasResult {
567
633
  area: IArea;
568
634
  'area-count': number;
@@ -628,3 +694,4 @@ export interface IUrlLookupResult {
628
694
  'url-count': number;
629
695
  urls: IUrl[];
630
696
  }
697
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musicbrainz-api",
3
- "version": "0.23.1",
3
+ "version": "0.25.0",
4
4
  "description": "MusicBrainz API client for reading and submitting metadata",
5
5
  "exports": {
6
6
  "node": {
@@ -77,7 +77,7 @@
77
77
  "mocha": "^11.0.1",
78
78
  "remark-cli": "^12.0.0",
79
79
  "remark-preset-lint-recommended": "^7.0.0",
80
- "sinon": "^19.0.2",
80
+ "sinon": "^20.0.0",
81
81
  "source-map-support": "^0.5.21",
82
82
  "ts-node": "^10.9.2",
83
83
  "typescript": "^5.5.4"